zsnes-1.36/0042755000175000017500000000000007514703023012172 5ustar dolsondolsonzsnes-1.36/Macros/0042755000175000017500000000000007514703014013416 5ustar dolsondolsonzsnes-1.36/opengl.txt0100644000175000017500000000765407340513145014227 0ustar dolsondolsonThis document is no longer up-to-date, but is a good start to understanding how the OpenGL code works for non-filtered modes. ------------------------------------------------------------------------- OpenGL is currently only avialable on Linux and via CVS. For the most part, it works and fairly stable. Please send all comments, suggestions, and bug fixes to hpsolo@my-deja.com. DO NOT EMAIL THE OTHER DEVELOPERS SINCE THEY ARE not INVOLVED WITH THIS CODE. And please make sure you've read through the list of known issues before sending your bug report. HOW OPENGL RENDERS THE SNES VIDEO BUFFER The SNES video buffer has dimensions 288x224 (sometimes 288x239 for certain games; however I have not come across any). The first 16 and last 16 column of pixels are not displayed (perhaps used as a scrolling buffer?), so the only important part of the video buffer is the middle 256x224 pixels. The SNES video buffer pointer is vidbuffer. With OpenGL, only the visible 256x224 pixels are needed and they are cropped into glvidbuffer. glvidbuffer is then turned into a texture that gets bound to a QUAD whose size depends on whether ZSNES uses aspect ratio to display each frame. HI-RES FILTERS WITH OPENGL The video mode selection is taken care of by SDL, including full screen mode. The current code does not allow for many hi-res filter options. While it is not difficult to implement the hi-res features using the current filtering code (in copyvwin.asm), it appears that the code for copy640x480x16bwin() causes memory corruption and sometimes segfaults when you exit ZSNES. For this reason, the filters have been left out. You can, however, add it in yourself by: 1. allocating enough memory space for glvidbuffer (use realloc) 2. assign glvidbuffer to the destination pointer SurfBufD (instead of surface->pixels) 3. setting Temp1 to surface->pitch, i.e. Temp1 = 2*SurfaceX 4. calling copy640x480x16bwin() 5. correctly binding the glvidbuffer as a texture to a QUAD There is a old patch that enables these filters and it is located at: http://www.students.uiuc.edu/~handuong/opengl.patch2 3DFX USERS (VOODOO2 AND OLDER HARDWARE) Lord_Nightmare managed to get OpenGL to work on a Voodoo2. Some things you'll need to do in order to get ZSNES OpenGL to work on your Voodoo: 1. Make sure to have the latest Mesa drivers and compile it with the following option: make -f Makefile.X11 linux-386-glide Voodoo2 users might want to use: make -f Makefile.X11 linux-386-opt-glide since that is optimized for Voodoo2 cards. According the the XFree86 website, Voodoo3 users (and later) should have DRI support via the tdfx driver so this might not be needed. 2. When you run ZSNES, make sure to set the environment variable MESA_GLX_FX to either w or f (window/full screen). E.g. use export MESA_GLX_FX=f if you use a bash shell. Theoretically using the w option should work, but it not only is slow (5fps) but seems broken. Voodoo Rush users might be able to get by. Note that only the 640x480 full screen mode works on the Voodoo2 cards so please do not email me about the other video modes. Files which might be usefull to have before compiling anything: Device3Dfx, Glide_SDK, Glide_V2 (or Glide_XXXX depending on your card) I believe Glide 2 is what you want, as Glide 3 doesn't work for older hardware. Also Device3Dfx may not be implemented the same way for 2.4.x kernels. KNOWN ISSUES (AND SOME WORK-AROUNDS) - after many video mode switches (all windowed), switching to full screen then back to window mode cases an SDL parachute exit; try not to use too many video mode changes, and restart ZSNES every once in a while if you are just testing out video modes - segfault after having compiled the source -- this might be due to an old zguicfg.dat file; delete this and see if the problem gets fixed TODO - use something like SDL_GL_UpdateRects with hi-res filters -- hpsolo -- zsnes-1.36/authors.txt0100644000175000017500000000070307511721574014423 0ustar dolsondolson-------------- The ZSNES Team -------------- zsKnight _Demo_ pagefault ------------------ Additional Authors ------------------ stainless pharos teuf relnev prometheus theoddone33 EvilTypeGuy hpsolo aaronl Diablo-D3 ------------- Miscellaneous ------------- Wilbern Cobb - initial OpenBSD work Thorsten "mirabile" Glaser - more OpenBSD integration Mitchell "The Khan Artist" Mebane - manpage zsnes-1.36/install.txt0100644000175000017500000001262207474576507014423 0ustar dolsondolsonCompiling the Source Code: -------------------------- Well, for the moment, zsnes source may be a little hard to compile. Here is a quick guide (based on my own experience and on a doc written by zsKnight) explaining how to compile zsnes. With these tools, I can build both dos and win version, I hope it will also work for you (slighty updated by stainless) First, you need the following software: Dos port : - NASM v0.98 or higher - DJGPP v2 or higher, (GCC also installed) : http://www.delorie.com/djgpp/ using the zip picker, the default choices are ok if you check C and C++ in the programming languages. You also need to get zlib which is available with the full distribution of djgpp. You can get it at : ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/zlib112b.zip - zlib : http://www.info-zip.org/pub/infozip/zlib/ - libpng : http://www.libpng.org/ Build the static versions of both of these libraries using DJGPP and do a 'make install' to put them where DJGPP can find them. Afterwards you can go ahead and delete the source for them from your hard drive. Then to build the executable, go to the src directory and type: make -f makefile.dos You may also want to compress zsnes.exe with upx (http://upx.sourceforge.net), it will divide its size by 10. Windows port : - GNU Make : it comes with djgpp - NASM v0.98 : http://www.kernel.org/pub/software/devel/nasm/ - MSVC++ 6.0 or higher : not freely available, you'll have to buy it You need to run VCVARS32.BAT. If you get an out of environment space error, type 'command /e:32768' (to create a new command.com entity with more environment space) I have been able to sucessfully build ZSNES using the Intel C++ drop-in replacement for Microsoft's C++ compiler that comes with MSVC++ 5 and above. Since ZSNES contains relatively small amounts of C, I don't see how Intel's compiler could provide any useful optimizations (maybe for winlink.cpp?). - DX8.0 SDK or higher : you can get it at microsoft.com. It is quite big. Also, edit makefile.win to set the correct path to your SDK. I also had some problems with vc++ using its own (old) directx headers instead of the sdk headers. I replaced these old headers (in the include directory of vc++ dir) with the newer ones. - zlib : http://www.info-zip.org/pub/infozip/zlib/ you need the Win9x/WinNT static library (the dll version doesn't seem to work with zsnes). Rename the static version to zlib.lib and put it somewhere where vc++ will find it (for example, the lib directory in vc++ dir). - libpng : http://www.libpng.org/ I'm not sure if the dynamically linked version of libpng will work with ZSNES. To be safe I would recommend to just go ahead and build the static version. Rename it to libpng.lib and put it somewhere where MSVC++ will find it (usually the lib subdirectory of your main MSVC++ directory). Don't forget to set the correct path to the directx sdk in makefile.win! Then to build the executable, go to the src directory and type: make -f makefile.win You may also want to compress zsnesw.exe with upx (http://upx.sourceforge.net), it will divide its size by 10. Linux port: I assume the standard development tools are installed (gcc, make, ...) You'll also need : - SDL (Simple DirectMedia Layer) : check www.libsdl.org to grab SDL 1.2.0 or later. If you are using rpm packages, don't forget the -devel package. - NASM v0.98 : http://www.kernel.org/pub/software/devel/nasm/ the version found on http://nasm.2y.net/ DOES NOT WORK with zsnes sources. When you type nasm -r, you must get 'NASM version 0.98' and not 'NASM version 0.98.08' if you have the correct version - zlib : http://www.info-zip.org/pub/infozip/zlib/ it is probably already installed on your system, maybe you are just missing the development headers. Check in the packages available with your distribution or go to the page above - libpng : http://www.libpng.org/ You might also need libpng, ZSNES will compile without PNG support but I have found doing so to make ZSNES unstable for some weird reason. If you don't have libpng, either get it and install it or pass the --without-png option to the 'configure' script. Then to build the executable, go to the src directory and type: ./configure && gmake && gmake install Note: you require root to install zsnes to the the default (/usr/local/*) directory Also Note: libpng (optional) needs to be recent, or zsnes will not use it You may also want to compress the zsnes executable with upx (http://upx.sourceforge.net), it will divide its size by 10. zsnes-1.36/license.txt0100644000175000017500000004313307267141100014351 0ustar dolsondolson GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. zsnes-1.36/news.txt0100644000175000017500000000000007267141100013665 0ustar dolsondolsonzsnes-1.36/readme.txt0100644000175000017500000000052707352143375014177 0ustar dolsondolsonIf you need help to compile ZSNES, read install.txt, or if you want a directory to the sources, read srcinfo.txt. The offical website is at http://www.zsnes.com and the sourceforge mirror is at http://zsnes.sourceforge.net/. The general discussion irc channel is #zsnes on EFNet, and the development chat is on #zsnes on irc.openprojects.net. zsnes-1.36/srcinfo.txt0100644000175000017500000001367007473161444014411 0ustar dolsondolson (this part was written by zsKnight) File List/Information --------------------- ; Porting Routine Files -DOS- ZLOADER.C ; Start-up C routines for DOS (Commandline parser, etc.) DOSINTRF.ASM ; DOS Interface routines (File,video,timers,etc.) -WINDOWS- ZLOADERW.C ; Start-up C routines for Windows (Commandline parser, etc.) Winintrf.asm ; Windows Interface routines (File,video,timers,etc.) winlink.cpp ; Win32 routines (DirectX, Win32 functions) ztcp.c ; TCP/IP & UDP driver copyvwin.asm ; Video Blitter for D modes -LINUX- copyvwin.asm ; Video Blitter for D modes gl_draw.c ; OpenGL routines for drawing the video buffer gl_draw.h ; protect.c ; sdllink.c ; SDL routines (video, input, sound init) sdlintrf.asm ; Interface routines sw_draw.c ; Software (via SDL) drawing routines sw_draw.h ; zfilew.c ; zipxw.c ; zloaderw.c ; zsnes.1 ; man page for zsnes ztcp.c ; TCP/IP (Netplay) ; ---------------------------------------------------------------- ; The following are generally compiled for both ports, but they ; are not necessarily used by both ; ---------------------------------------------------------------- ; General Stuff MACROS.MAC ; Global Macro file (NEWSYM/EXTSYM global var control macros) UI.ASM ; Start-up/initialization routines (env variables, cfg ; loader, memory allocation, etc.) INIT.ASM ; Emulation initialization routines (eg. memory map, emu ; variables, etc.) CFGLOAD.ASM ; ZSNES.CFG/ZSNESW.CFG file loading/parsing routines PROCVID.ASM ; In-game video initialization/text displays/mouse routines/ ; 8-bit palette/F3 menu routines TABLE.ASM ; Generates the SNES CPU tables (but in an inefficient way) TABLEB.ASM TABLEC.ASM STABLE.ASM VCACHE.ASM ; Performs tile caching and also vframe initialization stuff MENU.ASM ; F1 Menu routines ENDMEM.ASM ; Where those large arrays go ZFILE.C ; File Access Routines GBLHDR.H ; Global Header Stuff ; ZSNES GUI Stuff GUI.ASM ; Main GUI file GUITOOLS.INC ; Simple tools for the GUI GUIWINDP.INC ; GUI Window Display Routines GUINETPL INC ; GUI Netplay Routines GUILOAD INC ; GUI File Load Routines GUIKEYS INC ; GUI Keyboard Input Routines GUIMOUSE INC ; GUI Mouse Input Routines GUICHEAT INC ; GUI Cheat Code Routines (search + regular codes) GUICOMBO INC ; GUI Key Combo Routines GUIMISC INC ; Misc GUI Stuff (Movie, Joystick setting (display) routines, ; SNES Reset Function ; DOS Specific stuff VESA2.ASM ; VESA2 DOS Routines VESA12.ASM ; VESA1.2 DOS Routines ZSIPX.ASM ; IPX routines (DOS) JOY.ASM ; DOS Joystick Drivers COPYVID.INC ; Graphics blitter routines for DOS (copys screen to display) INITVID.ASM ; Video Initialization routines (DOS) DEBUG.ASM ; SNES Debugger routines SW.ASM ; Sidewinder routines SW32.ASM ; More Sidewinder routines (not sure which file is the real ; one) GPPRO.ASM ; Gamepad Pro routines (non-USB) MODEMRTN.ASM ; DOS Modem routines ; Graphics Enhancers 2XSAIMMX.INC ; Kreed's 2xSaI routines 2xSaI.cpp ; Kreed's Super 2xSaI routines 2xsaiw.asm ; 2xSaI for windows (without selector usage) water.c ; Water Effect ; SNES CPU Emulation routines execute.asm ; Main emulation execution loop routines (includes save ; states and in-game netplay routines) SPC700.ASM ; SNES SPC700 Sound CPU emulation routine files SPCADDR.INC SPCDEF.INC DSPPROC.ASM ; SNES Digital Sound Processor main emulation routines DSP.ASM ; SNES Digital Sound Processor register routines DMA.ASM ; SNES PPU DMA/HDMA routines IRQ.ASM ; SNES 65816 IRQ routines (VIRQ/NMI) MEMORY.ASM ; SNES Memory access routines + C4 routines (Sorry that I ; didn't have these in a separate file since a small memory ; hack of the C4 originated on this file and just grew and ; grew) E65816.INC ; 65816 emulation routines (w/o SPC700) 65816D.INC E65816B.INC ; 65816 emulation routines (Debugger I think) 65816DB.INC E65816C.INC ; 65816 emulation routines (w/ SPC700) - Sorry about these ; 3 files. They used to be just 1 until I removed the ; self-modifying code routines 65816DC.INC SE65816.INC ; 65816 emulation routines (SA-1) S65816D.INC ADDRNI.ASM ; 65816 Non-incrementing addressing modes ADDRNI.INC SADDRNI.INC ADDRESS.INC ; 65816 Incrementing addressing modes ADDRESS2.INC SADDRESS.INC REGS.INC ; SNES I/O register emulation REGS.MAC REGSW.INC REGSW.MAC ; SNES PPU Emulation Routines MAKEVID.ASM ; 8-bit old graphics engine MAKEV16B.ASM ; 16-bit old graphics engine MAKEV16T.ASM ; 16-bit old graphics engine (transparencies) MV16TMS.ASM ; 16-bit old graphics engine (transp w/ Main+Sub enabled) MODE7.ASM ; 8-bit mode 7 routines MODE7.MAC MODE7EXT.ASM ; 8-bit mode 7 EXTBG routines MODE716B.ASM ; 16-bit mode 7 routines MODE716T.ASM ; 16-bit mode 7 routines (transparencies) MODE716E.ASM ; 16-bit mode 7 EXTBG routines M716TEXT.ASM ; 16-bit mode 7 EXTBG routines (transparencies) MODE716D.ASM ; 16-bit mode 7 Direct routines mode716.asm ; Mode 7 16-bit new graphics engine routines mode716.mac NEWGFX.ASM ; 8-bit new graphics engine files NEWGFX.MAC NEWGFX2.ASM NEWGFX2.MAC NEWGFXB.MAC NEWGFXWN.MAC newgfx16.asm ; 16-bit new graphics engine files newgfx16.mac NEWG162.ASM newg162.mac NEWG163.MAC NEWG16WN.MAC VIDMACRO.MAC ; Generic Video Macros File VIDMACRB.MAC ; Special Chip Emulation Routines FXEMU2.ASM ; Super FX emulation files FXEMU2.MAC FXEMU2B.ASM FXEMU2B.MAC FXEMU2C.ASM FXEMU2C.MAC FXTABLE.ASM SFXPROC.ASM DSP1PROC.ASM ; DSP1 communication routines DSP1EMU.C ; DSP1 C routines (also includes some C4 C routines) SA1PROC.ASM ; SA-1 processing routines SA1REGS.ASM ; SA-1 registers, also includes S-DD1 and SPC7110 routines zsnes-1.36/thanks.txt0100644000175000017500000000000007267141100014201 0ustar dolsondolsonzsnes-1.36/todo.txt0100644000175000017500000000344207271037624013705 0ustar dolsondolsonSome Issues : Windows Port: - For some reason DirectDraw runs very slow on 3dfx cards. Is this possible to fix? Or maybe implementing a glide mode would fix it. DirectDraw blit routines are probably not handled in an optimal way - DirectSound in ZSNESw doesn't support the primary sound buffer. Unfortunately, this causes 8-bit quality sounds on certain computers. - DirectInput seems to cause some systems to really slow down for some odd reason. When those systems that are affected disables their joystick from the control panel, the framerate suddenenly goes up from choppy to smooth. - VSync or triple buffering not implemented - Glide,OpenGL, or Direct3D support would be nice - .ZIPed files seems to not work on certain Win2K configurations - Use another (free) compiler for the windows version (cygwin?) - Auto-detect high/low latency connections and adjust settings accordingly General - Maybe add in Cubic Spline Interpolation to the SNES DSP Sound processor (DSPPROC.ASM) since some people like the clarity of it compared to Gaussian Interpolation (even though that's the method the real snes uses) and also make a variable to select between those interpolations (If someone can do this, I'll add an option to switch between them in the GUI later) - Clean up the makefiles (get rid of this ugly link.win32) - ZSNES doesn't compile with nasm 0.98.08 because of problems with the way it deals with loops Compatibility - Game not working - Guikuden 1 (and some more) - Graphics Glitches - Uniracers (2p mode), Killer Instinct (couple stages, black background), FF3 (some sprite clipping probs), Metal Combat, Tactic Ogre (Menus?) - Special Chips - DSP1 (60% done), DSP2 (0% done), SA-1 (95% done), SDD-1 (decompression left), and others zsnes-1.36/dos/0042755000175000017500000000000007514703014012757 5ustar dolsondolsonzsnes-1.36/dos/guinotes.txt0100644000175000017500000005756707267141100015371 0ustar dolsondolsonTable of Contents ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ I. ) The Game Menu II. ) The Quick Menu (Arrow Menu) III.) The Config Menu IV. ) The Cheat Menu V. ) The MultiPlay Menu VI. ) The Misc Menu ---------------------------------------------------------------------------- Note : If any windows exists in the GUI field, pressing ESC always closes the top-most window Note : Pressing ESC when no window is active is equivalent to RUN. It will not function if no game is loaded Notes on the filename box where you can manually type in the filename: - Typing text into the box would automatically seek to the closest matching filename in the box where the file selection cursor is located - When you press enter with text in the box without any '\' or ':' in the filename, ZSNES will first look for a directory matching the text and changes its directory if one is found. Otherwise, it will load the current file or directory highlighted by the selection cursor. - You can type in the full filename or directory including path (eg. d:\games\mario.smc) or the drive name (eg. d:) ---------------------------------------------------------------------------- --------------------- - I.) The Game Menu - --------------------- Load : Perform : Load File and Run Usage : Loading a File : You can move through the list using either the mouse or the keyboard. The keys for the keyboard are : Up/Down - Move Up/Down through the list Left/Right - Switch between the File and Directory Window PageUp/PageDown/Home/End - Move through the list in larger increments A .. Z, \, : - Enters filename/directory into the load box Enter - Load File or Change Directory (depending on which window you are in) Display Type : You can select from either Normal 8.3 file format (Default), Snes Header name, and Win95 long filename format. Note : Win95 long filename format will not work in Pure DOS. It will crash when using dosemu in Linux Note : Snes Header Display will sometimes display garbled Lines. This is normal since some images don't have a proper name in the header or the header is not in english. Whenever ZSNES detects a blank header name, it uses the filename instead. Also note that .ZIP files will not display the header name. It's not efficient for the program to unzip every zip file in the directory just to get the header names. Show all Extensions : This will force the GUI to show all of the file extensions instead of the default (.SMC,.SFC,...) Run : Perform : Runs the game Reset : Perform : Resets the game, but asks user for confirmation first Save State : Perform : Saves the state (Equivalent to default F2), but asks user for confirmation first Load State : Perform : Loads the state (Equivalent to default F4), but asks user for confirmation first Pick State : Perform : Allows user to select the state position to use (Equivalent to default F3) Quit : Perform : Quits ZSNES ---------------------------------------------------------------------------- ----------------------------------------------- - II.) The Quick Menu (Displayed as an Arrow) - ----------------------------------------------- Perform : Allows the user to quickly select the last 10 games loaded off the GUI. Also allows the user to freeze/clear the list. Tip : You can create a favorites list by first clearing the list then loading up all the games (last game loaded will be at the top) and turning freeze on. ---------------------------------------------------------------------------- ------------------------- - III.) The Config Menu - ------------------------- Input #1-#5 : Perform : Allows user to select the input device and control keys for each player Usage : Selecting an Input Device : Using your mouse, move through the list of input devices until the device of your choice is highlighted. From there, click on SET and the input device you selected should appear after CDV: (CDV = Current Device) Changing default keys : Click on the key which you want to change using your mouse and then press the key or joystick button/pad which you want to change it to. Pressing ESC disables the game key. Joystick 209h usage : Some dual joystick cards support dual joystick ports (port 201h and 209h) which allows for 2 6-button joysticks or 2 different types of joysticks (sidewinder and a standard joystick). If you have one of these, check the 'Use joystick port 209h' box. If you do not have a dual joystick/dual port card and if you check the box, then the joystick will not work. Options : Perform : Allows the user to select some in-game options Usage : Auto Frame Rate - Enables Auto Frame Rate Frame Skip - (Shown when Auto Frame Rate is disabled) Sets the constant frame skip value used when a game plays Max Frame Skip - (Shown when Auto Frame Rate is enabled) Sets the maximum allowable frame skip in auto framerate mode New Gfx Engine - Enables/Disables the New Graphics engine in 256 color modes or 320x240x65536 mode VSync - Enables vertical sync wait to reduce sheering of the screen. Requires a very fast computer. MMX Copy - Enables MMX Copying routines for a slight speed increase (MMX processors only) Use Pl1/2 as Pl3/4 - Allows the user to use 2 devices for 1 player such as the keyboard and the joystick. (set keyboard as input device 1 and joystick as input device 3). This, however, disables multitap support Sidewinder Fix - Click this when your sidewinder doesn't work after disabling the sidewinder profiler and pressed the mode button twice FPS at Start - Checking this would make the FPS appear whenever you start ZSNES Use 30Hz for Turbo - When activated, Turbo will change at 30hz NTSC or 25hz PAL. Otherwise, Turbo will change at 60hz NTSC or 50hz PAL Enable Game Clock - Enabling this will show the system clock on-screen Toggled Fast Fwd - Checking this will change the way how the fast forward button functions. Having it checked will cause it to act as a switch and having it unchecked will cause it to act as a push button. SRam Check+Save - This will enable automatic Save Ram write detection and save the sram (.srm) to disk approximately 10 seconds after. Old Gfx Mode 2 - This will enable the Old Gfx Engine Mode 2 which fixes many transparency bugs that currently plagues ZSNES in the current engine, however, it also creates some new ones. This mode can be slower at times so it's recommended that you only turn it on when you need it. Start at Latest Save - Checking this will automatically set the save state pointer (F3 Menu) to the most recently saved location whenever you load a rom image. Auto State Save/Load - Enabling this will allow ZSNES to automatically re-load the state whenever you return back to the game after a proper exit. Don't Save Current Path - This will prevent ZSNES from changing the current start-up game path in the configuration. You can access this in Config->Options. Disable Sound CPU Emu - Selecting this would disable the SPC700 chip that controls the sound. Using this would speed up emulation, but the drawback is that you won't have sound and the gane compatibility rate would be lower. Add-ons: Perform : Changes the current special input selected for the game Usage : None - Uses the regular snes controllers SNES Mouse at Port #1 - Emulates the SNES mouse at controller port #1 SNES Mouse at Port #2 - Emulates the SNES mouse at controller port #2 Super Scope - Emulates the SNES Super Scope Lethal Enforcer Gun - Simulates the mouse movements for Lethal Enforcers 1 Video : Perform : Changes the current video mode and sets some options Usage : Changing the video mode - Use the mouse to select the video mode and click 'SET'. When the video mode changes and if the result doesn't look right, wait for 10 seconds without pressing any key or button and the display will return to the previous one. Scanlines - Only available in 256x256x256 and VESA2 640x480 modes. This mode adds a blank line in between every line to produce a scanline effect similar, if not exact, to a TV. Eagle Engine - Only available in VESA2 320x240x256. Setting this would enable the Eagle Engine designed by Dirk Stevens which basically locates 3 similar colored pixels together and places a small dot in between to smooth out some graphics. Interpolation - Only available in VESA2 640x480x65536. Setting this enable interpolation which basically blends all the inbetween colors to produce a blurry effect. However, this slows down emulation. Full Screen - Only available in VESA2 320x240 and 640x480 modes. Setting this would scale the image to fit the screen. This, however, slows down emulation. Small Screen - Only available in VESA2 640x480 modes. Setting this would display the image in a small, centered screen. This greatly improves performance in 640x480 modes. 50% Scanlines - Only available in 640x480x65536 video mode. This will enable scanline mode except that each line is 50% darker than the line above it. 25% Scanlines - Only available in 640x480x65536 video mode. This will enable scanline mode except that each line is 25% darker than the line above it. 2xSaI Engine - Setting this would enable Kreed's 2x Scale Advanced Interpolation engine. Super Eagle - Setting this would enable Kreed's Super Eagle engine. Super 2xSaI Engine - Setting this would enable Kreed's Super 2x Scale Advanced Interpolation engine. This mode would require a lot of cpu power since it is written in C. Triple Buffering - This will enable Triple Buffering if it is available on your VESA drivers/Video Card. If it isn't available, then Zsnes will use simulated Triple Buffering which is slower, but still does the job. Note that Triple Buffering will not work with 2xSaI/Super Eagle. Hi-resolution Mode 7 - Enabling this would activate high resolution mode 7 whenever standard mode 7 is used within a game. This mode is only available in video modes that support it. Sound : Perform : Allows user to change the sound configurations of ZSNES Usage : Enable Sound - Setting this turns on the sound Stereo Sound - Enables Stereo Sound (Noticably slower though unless you have a fast cpu) Sound Rate - To change the sound rate, just click on the box containing the value to rotate through all the possible values. Volume Level - To change, just slide the bar Disable Noise Sim. (Disable Noise Simulation) - Setting this will disable the noise filter which corrects many sound effects in certain games, but will also ruin some others. Surround Sound - Enables simulated 2 speaker surround sound Sound Interpolation - Enables Sound Interpolation which smoothes out the wave forms of lower frequency sounds Reverse Stereo - This function swaps the L & R volume levels in stereo mode Low Pass Filter - The Low Pass Filter, when enabled, will produce better bass in certain sound effects. However, the side effect is that the sound will overall be more muffled. ---------------------------------------------------------------------------- ----------------------- - IV.) The Cheat Menu - ----------------------- Add Code : Perform : Enter Cheat Code Window and Set the keyboard cursor on the cheat code entry box Usage : Type in the code in either Game Genie, Pro Action Replay, or Gold Finger format, press enter, then enter the description. Note : Be sure to include the '-' when entering Game Genie codes Note : You can also quickly modify the value of the currently selected cheat code (in the browse window) by typing a 2 digit hex number in the cheat code enter space Cheat Code Reflector - What this feature does is that it allows a value of one cheat code to be mirrored from a value of another cheat code. To enable this option, type an 'R' at the end of any cheat code as the destination, then type another cheat code (Without the 'R') as the source. For example, if you want address 7E1000 to reflect the value at address 7F2000 (Whatever value written to 7E2000 from the game will also be written to 7E1000), enter cheat code 7E1000FFR, then cheat code 7F2000FF (where FF can be any value). Browse : Perform : Enter Cheat Code Window and Set the keyboard cursor at the browse box Usage : Move through the list using either the mouse or keyboard and select the cheat code you want to modify. Then click on the buttons to the right or type in the key of the first letter of the action. Actions : Toggle - Turns a cheat code on or off Remove - Deletes the cheat code off the list Save - Saves the current list into a .cht file which will be located in the save directory Load - Loads a previously saved list Fix - Clicking this fixes some cheat codes that don't work, but it will not always work You can also toggle a cheat code on or off by double clicking on them. Search : Perform : Allows you to search for values in memory such as life, score, etc. and allows you to change their values to your own preferred choice. Usage : Select Size : You can choose what data size to search for. If you know the numerical values of the data you're going to select, select the smallest number range that fits the data values. (eg. If you know the value cannot go higher than 50000, then select 2 BYTES (0..65535) instead of 3 BYTES (0..16777215)). Sometimes, you don't know the numerical value (in the case of life bars) and you'd have to guess the size. Select Format : DEC (Decimal, 0 .. 9), HEX (Hexadecimal, 0 .. F) Most of the time, it's recommended that you'd use decimal, although there are some cases that the values in memory are sometimes stored as hex. Search Type : Exact Value Search - In this mode, you have to enter the exact numerical value that you want to search for. Such as if you have 3 lives left, then search for the value 3. The cheat search engine also looks for value - 1 since even if a game tells you that you have 3 lives left, it stores the value as 2 in memory. Comparitive Search - In this mode, you select whether the value is less than, greater than, equal to, or not equal to the previous value. Such as if you have a life bar and if the life bar suddenly goes down, go back to the cheat search engine and select less than to search for any value that has been decreased. ---------------------------------------------------------------------------- ------------------------ - V.) The NetPlay Menu - ------------------------ Modem Mode : NOTE #1 : DOS Compatible modem is REQUIRED! If you don't know your modem settings and you're in win95/98, go to Control Panel -> System -> Device Manager -> Modem and select your modem. Then click on your resources tab and the settings should be there. 1.) Dial Menu - Allows you to enter the phone number to dial and then dials and connects 2.) Wait for Ring - Waits for ring 3.) Config Modem - Allows you to configure your modem : ComPort, IRQ, Baudrate - Sets your modem settings Use Fossil Driver - Set this option if you want ZSNES to use your a fossil driver. If you don't know what a fossil driver is, just leave this option unchecked and pretend it doesn't exist. 4.) Manual - Allows you to connect manually through the terminal. However, if both remote and local users select manual, the player numbers will not be assigned. IPX : IPX mode currently connects at the first remote connection it detects. This will probabily change in the future if there is a demand. Chat Mode : Latency - The lower the number, the better the control response time. But setting it too low can cause a lot of frame skip problems. This value should vary depending on the traffic of the connection you are using. A value of 2 or 3 is recommended for modem. The value for IPX varies. Latency is basically the amount of time between a user input and that input being affected in the actual game. The delay should be higher than the time it takes for data to move from one end to the other. Latency value of 1 is equivalent to 1/30th of a second on NTSC games or 1/25th of a second on PAL games. Player # boxes - This will allow you to select up to a 5 player multiplayer game. Anything that is checked will be controlled locally starting from player 1 as the lowest checked player. Anything marked with an X will be controlled remotely. For example, if players 2,3,5 are checked and 1,4 are X'ed : local player 1 will control player 2 local player 2 will control player 3 local player 3 will control player 5 remote player 1 will control player 1 remote player 2 will control player 4 ---------------------------------------------------------------------------- ---------------------- - VI.) The Misc Menu - ---------------------- Game Keys : Perform : Allows user to change the game keys to their own preference Usage : Click on the key which you want to change using your mouse and then press the key or joystick button/pad which you want to change it to. Pressing ESC disables the key. GUI Options : Perform : Allows the user to customize some of the GUI Usage : Mouse Wrap - Allows the mouse pointer to wrap at the borders of the screen Mouse Shadow - Disables/Enables the Mouse Shadow Keep Menu Positions - When enabled, re-entering the GUI from the game does not automatically enter the Load Menu, but the previous menu which you were on when you last exit the GUI Save Window Positions - When enabled, the GUI doesn't reset the locations of the windows when you exit/enter the GUI Click Enters/Exits GUI - When enabled, it allows the right mouse button to automatically run and exit the game to the GUI. This however, slows down emulation by a bit since it has to check the mouse button status once in a while. In the windows port, the right click button won't return back to the game. Use JoyPad1 to Control - When enabled, it allows Player 1's device to be used to move through the GUI. This is mainly used if you want to use your joystick in the GUI. The equivalent SNES keys to the Keyboard keys are : SNES ControlPad = Move SNES A = Enter SNES B = ESC SNES L = PageUp SNES R = PageDown Enable Water Effect - Enables the water effect in the GUI background Enable Snow Effect - Enables the snow effect in the GUI background Key Comb. (Key Combination Editor) : Perform : Allows you to specify certain keyboard combination routines with a single keystroke/joystick button press. Usage : Description - Allows you type in the description of the combination key Key - Clicking on this box will allow you to select which key/button to use Combination Keys - this window will display the sequence of events selected by the user P# - Selects which player # to use those keys as > = Last - Enabling this would mean that the event symbol > will mean the last left or right direction the user presses in the game and the symbol < is the opposite of that direction. When disabled, > means right and < means left. Game Specfic (Game Specific) - Enabling this will tell Zsnes to use separate Key Combination files for each individual game. Clear - Clears the current key combination field Add - Adds the key combination fields below as a new entry Replace - Copies the contents of the key combination fields below to the current highlighted key combination above Delete - Deletes the highlighted key combination above Events: Press+Rel - The key will be pressed and held. It will be released once another key is pressed after any amount of frame or second delay. Press Only - The key will be pressed and held Rel Only - The key will be released if it is Pressed by a pressed only event Frame Delay - Delays for the specified number of frames Second Delay - Delays for the specified number of seconds Del - Deletes the event at the end of the Combination Keys list if one exists Note : A 1 frame delay exists after the combination key list has finished processing Example Key Combination: (Down / Down+Right / Right / L) : Method 1: Press+Rel Down / 2 Frame Delay / Press+Rel Down / Press+Rel Right / 2 Frame Delay / Press+Rel Right / 2 Frame Delay / Press+Rel L Method 2: Press Only Down / 2 Frame Delay / Press Only Right / 2 Frame Delay / Rel Only Down / 2 Frame Delay / Rel Only Right / Press Only L Movie Options : Perform : Allows you to record SNES Movies so that you can play them back at a later date either to amuse your friends, torture your friends, or whatever. Just don't play anything in front of your enemies since they might break your computer. Usage : Movies are saved as .ZMV, .ZM1, .ZM2, etc. files. They should be located in the same directory as your save files. A movie file consists of a save state file, saveram data, and the recorded controller data. The initial filesize of a .ZMV file is the combination of a .zst and a .srm file (around 300kbytes) and it averages around 7kbytes/minute (value varies) or 420kbytes/hour. You can record : - Standard 1/2 player games - 3-4 player Multitap games - SNES Mouse games - Network/Modem games You cannot record : - Super Scope Games GUI Usage : Record - Begins recording the movie file Play - Begins playing the movie file Stop - Stops the movie process The numbers at the right side selects which movie file to play/record. NOTE : Movies recorded without sound cannot be played when sound is enabled and vice versa NOTE : Loading another game, loading a state, or resetting the game will halt the play/record process NOTE : When you play a movie file, the SRAM data becomes invalid and ZSNES won't save it until you load a game. This way, you don't have to worry about your save ram when you load up a movie file. Save Cfg : Perform : Saves the configuration files About : Perform : Just displays the version # and the authors of ZSNES zsnes-1.36/dos/readme.txt0100644000175000017500000006361307352143375014771 0ustar dolsondolson ZSNES by zsKnight, _Demo_, and Pharos http://www.zsnes.com/ ZSNES is a Super Nintendo Entertainment System emulator written mostly in assembler. We would really like to thank the snes9x team for all their help and also for an excellent snes emulator. We also wish them the very best of luck! --------------------------------------------------------------------------- Table of Contents --------------------------------------------------------------------------- 1.) What's New 2.) Disclaimer 3.) System Requirements 4.) Things you should know about ZSNES (Updated v1.00) 5.) Current Progress 6.) Future Progress 7.) ZSNES Default Keys 8.) Extra Pop-Up Menu (F1 Menu) 9.) Configuration File (ZSNES.CFG) 10.) Cheat Codes 11.) Extra Features (SNES Mouse/Super Scope/SuperFX/DSP1/MultiTap/IPS) 12.) Bugs Section 13.) Contact Information 14.) The Debugger 15.) Error Codes 16.) Credits --------------------------------------------------------------------------- 1.) What's New --------------------------------------------------------------------------- See WHATSNEW.TXT --------------------------------------------------------------------------- 2.) Disclaimer --------------------------------------------------------------------------- zsKnight, _Demo_, and Pharos are not responsible for any damages caused by the use of this software. This software also must not be distributed with ROMs. --------------------------------------------------------------------------- 3.) System Requirements --------------------------------------------------------------------------- Somewhat Recommended System : - 486/100 processor - Min 14.5MB of RAM (min 12.5MB free, only can run 2MB rom images) - VGA card - Sound Blaster or 100% compatible * You might need to disable Sound CPU emu for this system (go to Config -> Options) Strongly Recommended System : - Pentium processor (P133 or higher) - 32MB of RAM (min 17.0MB free) - SVGA card - Sound Blaster 16 or 100% compatible Recommended System for 65536 (16-bit) color mode : - Fast Pentium processor (P166 or higher) - 32MB of RAM (min 17.0MB free) - SVGA card which supports 320x240x65536 or 640x480x65536 colors - Sound Blaster 16 or 100% compatible Recommended System for SFX support : - Fast Pentium processor (P200 - P2-300 (depending on the game)) - 32MB of RAM (min 17.0MB free) - VGA card - Sound Blaster 16 or 100% compatible Recommended System for SA-1 support : (Mario RPG) - Fast Pentium processor (P200 or higher) - 32MB of RAM (min 17.0MB free) - VGA card - Sound Blaster 16 or 100% compatible - You need 17.0MB of RAM to run 48mbit(6megabytes) roms. - An FPU is required for DSP1 emulation For SuperFX and SA-1 emulation, 17.0 megabytes of free memory is required to run. Overall Recommended System : - Pentium processor (P233MMX or higher) - 64MB of RAM (min 17.0MB free) - SVGA card w/full VESA 2.0 support - Sound Blaster 16 or 100% compatible - DOS capable gamepad or joystick --------------------------------------------------------------------------- 4.) Things you should know about ZSNES --------------------------------------------------------------------------- - You can use both keyboard and joystick for player 1 or 2 with some configuration adjustments. Refer to ZSNESFAQ.TXT for details - If your sidewinder support doesn't work, a quick way of getting it to work is to fully disable the windows driver from the control panel - For modem mode, if you don't have a 16550A UART compatible modem (It will tell you when the modem initializes), chances are that both sides will go out of sync. - IPX support seems to randomly lose packets in certain network configurations which causes both sides to go out of sync - Several special chip emulation (SA-1) have unknown bugs to them - Transparency effects are only available in 16-bit color mode - Using 320x240 resolution modes are faster than 640x480 modes. Use 640x480 modes only if you can't run 320x240 modes or if you want the added features of 640x480 modes - Using the ModeQ variants is much faster than using the ModeX variants, only use ModeX if your monitor has a problem with the ModeQ timings. - To view 512 resolutions properly, use 640x480 mode. Only a few games uses 512 resolution. One way to find out is to see if a game has that feature is to look for text that looks squished. - In 640x480 resolution, the image is scaled so it will look like 320x240 resolution. Only use 640x480 resolution if you want to use scanlines, interpolation, or if 320x240 doesn't work. - SuperFX can be slow because it is an extra 10/20mhz cpu that has to be emulated as well as the snes emulation - Screen Snapshot and FPS counter are available through a menu by pressing F1 during emulation - Screen Snapshot currently saves as IMAGE.PCX (256 colors) and IMAGE.BMP or IMAGE.PNG (16-bit color). This may change in the future. - FPS counter currently only works when auto frame rate is on. - To use the cheat function, be sure to have the ROM which you want to patch loaded already. - If the cheat codes do not work, chances are that you are using a different version of the rom that was originally used to create them or the codes are converted incorrectly from other code formats. - Certain video cards/monitors cannot support ModeQ (default resolution) If your video card/monitor doesn't support it, run ZSNES with -v 4. If -v 4 doesn't work, try using -v 6 (vesa 1.2 required) - If you don't have a fairly newer chipset on your video card, then 16-bit mode in ZSNES may require Scitech Display Doctor (v5.3+) to provide high color, low resolution video modes. You can obtain this software at www.scitechsoft.com. If your video card already supports low resolution high color video modes, then don't worry about getting this software. - There are still many bugs left in ZSNES so don't expect it to run all your favorite games. - VSync won't run well unless you specify a frame skip (eg. -f 0) But this feature is highly recommended to be used on very fast machines (eg. Pentium IIs) - SNES Mouse support is still missing some features such as speed settings - Pressing the Fast Forward key is equivalent to running ZSNES using -f 9 - If ZSNES doesn't work for you, then don't use it. Use SNES9X, NLKE, SNEESE, or SNEMUL instead! In fact, even if you use ZSNES, use those emulators too! --------------------------------------------------------------------------- 5.) Current Progress --------------------------------------------------------------------------- The following are implemented : - complete 65816 instruction set - SRAM support - LoROM and HiROM support - SlowROM and FastROM support - Full DMA support - HIRQ/VIRQ/NMI Interrupts - Support for most snes file formats - Multi file format support (.1,.2,.3,A.,B.,C.) - Interleaved format support - PAL/NTSC timing support The following are implemented in the new graphics engine 8 bit : - Combination of line by line and tile based graphics engine - Graphic Modes 0,1,2,3,4,5,6,7 - 8x8, 16x16, 32x32 and 64x64 sprite support (flipped in all directions) - 8x8 and 16x16 tiles - 32x32,64x32,32x64,64x64 tile modes - Full HDMA effects for wavy backgrounds, interesting mode 7 effects, etc. - Mode 7 rotating and scaling effects - BG priorities - Sprite Priorities - Add/sub of back area - Mosaic Effects - Offset per tile mode (mode 2/vertical only) - High res 512 resolution and 448/478 vertical resolution - Windowing effects - High res Mode 7 (only in 640x480x256 video mode/disable Eagle/Scanlines) The following are implemented in the old graphics engine : - Line by line based graphics engine - Graphic Modes 0,1,2,3,4,5,6,7 - 8x8, 16x16, 32x32 and 64x64 sprite support (flipped in all directions) - Mosaic effects - 8x8 and 16x16 tiles - 32x32,64x32,32x64,64x64 tile modes - Full HDMA effects for wavy backgrounds, interesting mode 7 effects, etc. - Mode 7 rotating and scaling effects - Single and Dual Windowing Routines - BG priorities - Sprite Priorities - Add/sub of back area - 16-bit graphics support - offset per tile mode (mode 2/vertical only) - High res 512 horizontal resolution (missing in 16x16) Following are present in 16-bit graphics mode : - Palette changing in the middle of a screen - Screen Addition (full and half) - Screen Subtraction (full) - Fixed Color Addition/Subtraction - Window clipping for Fixed Color The following are implemented in the new graphics engine 16 bit : - All of old graphics engine 16bit - Combination of line by line and tile based graphics engine - High resolution mode 7 - High resolution 16x16 tiles for mode 5 - full 15bit color transparencies (instead of the previous 13bit speed hack) for improved picture quality (MMX compatible CPUs only) The following are present in sound : - 16bit digital stereo sound - SPC700 Sound CPU - DSP Sound Processor - Echo Effects - FIR Filter - ADSR volume effects - GAIN volume effects - Noise effects - Pitch Modulation The following are extra features emulated : - Super NES Mouse Support - Super NES Super Scope Support - SuperFX support (Still has a bug or 2 left) - MultiTap (Multiplayer 5) support (4 players on a single computer, 5 players remote (ipx/modem)) - DSP1 emulation (not complete) - SA-1 emulation (not complete) The following are the features present in ZSNES : - Game State Save (F2=Save, F3=Select, F4=Load). Warning : A state file takes 260 kbytes of HD space! - Auto frame rate to give you constant Super Nintendo speed up to 9 frame skips - configuration file support (ZSNES.CFG) - 2 player support w/ Joystick and Gamepad support The following features are missing : - Pseudo 512 snes horizontal resolution (Haven't seen any game that uses them yet) - Some modes in Offset Per Tile Mode - Some Direct Color Modes (Haven't seen any game that uses them yet) What will not run (or not play properly) : - Some Super FX games such as Dirt Trax FX or Winter Gold (causes instability) - DSP1 games such as Pilotwings - Games with other special chips such Street Fighter Alpha 2, Star Ocean (S-DD1), and Far East of Eden 2 (SPC7110) - Games which doesn't have a valid header - Games that hit a severe bug in the 65816/PPU/SPC700/DSP routines - Games that require special timing --------------------------------------------------------------------------- 6.) Future Progress --------------------------------------------------------------------------- This section is removed --------------------------------------------------------------------------- 7.) ZSNES Default Keys --------------------------------------------------------------------------- Here are the default keys while running the emulator. They can be changed through the GUI except for F1 and ESC : Disable Backgrounds 1,2,3,4 = 1,2,3,4 Disable Sprites = 5 Panic Key (enable all) = 6 Enable SNES Mouse/SuperScope = 7 Enable New Graphics Engine = 8 Disable Windowing = 9 Disable OffsetMode = 0 Fast Forward Key = ~ PopUp Extra Menu = F1 Save State = F2 Switch State = F3 Load State = F4 Disable Sound Channel = F5 - F12 Quit = ESC Here are the default keys for the game play (unless modified through the GUI): Player 1 : Up,Down,Left,Right : Cursor Keys on Numerical Pad (You can also use the non-numerical pad, but numerical pad is strongly recommended) A,B,X,Y : Home, End, Insert, Delete L,R : Page Up, Page Down Start, Select : Enter, RShift Player 2 : (You need to enable Player 2) Up,Down,Left,Right : K, M, N, < A,B,X,Y : D, X, S, Z L,R : F, C Start, Select : Ctrl, Alt To run the emulator, just type ZSNES To run it with sound, type ZSNES -s To run it in 16-bit mode (VESA2 w/ video card that supports 320x240x65536 required), type ZSNES -v 3 or with sound, type ZSNES -v 3 -s --------------------------------------------------------------------------- 8.) Extra Pop-Up Menu (F1 Menu) --------------------------------------------------------------------------- Save Snapshot - Saves a snapshot as either .PCX (8-bit color) or .BMP (16-bit color) or .PNG (if you select it instead of BMP). Show/Hide FPS - Shows or hides the frame per second display which appears on the bottom-left corner of the screen. This can only be enabled in auto-frame rate mode. Save SPC Data - Selecting this will search for the beginning of the next song and save the data into a .spc file which saves it similarly as a .srm file. To capture a song, it is best recommended to initiate this feature approx 2 seconds before the next song starts. This does have potential to fail though so don't expect it to work all the time. Also, this feature doesn't work in the new gfx engine. Sound Buffer Dump - This dumps the sound buffer in zsnes and also filters out any unoccupied space. The sound buffer contains decompressed samples which are written to when zsnes plays/decodes a sample from sound memory. Because of the way zsnes buffers the sound data, this can produce inaccurate results. Snapshot/Increment Frame - Same as snapshot, but it returns to the F1 menu after a couple frames. Useful for making animations. Screenshot Format - Changes format to/from BMP and PNG for screenshots. Only works in 16-bit color of course. :) --------------------------------------------------------------------------- 9.) Configuration File (ZSNES.CFG) --------------------------------------------------------------------------- Almost everything in zsnes.cfg should now be editable through the gui --------------------------------------------------------------------------- 10.) Cheat Codes --------------------------------------------------------------------------- Currently, ZSNES supports Game Genie, Pro Action Replay and GoldFinger codes Here are the steps to get the codes working : 1.) Load the ROM which you want to patch 2.) Exit to the GUI, enter the code of your choice in the cheat menu 3.) After that, you may have to RESET the game to get the cheat code to work. Sometimes, it is not necessary. You also may have to click on the FIX button. NOTE : Some cheat codes are meant to be for different versions of the game. If a cheat code doesn't work and there is one for both Game Genie and Pro Action Replay, try them both. --------------------------------------------------------------------------- 11.) Extra Features (SNES Mouse/Super Scope/SuperFX/DSP1/MultiTap) --------------------------------------------------------------------------- To Enable SNES Mouse, Press 7 once for 1st player and twice for 2nd player To Enable SNES Super Scope, Press 7 three times To disable either one, either press 6 or press 7 until you see a disable message onscreen. Here are the controls for the Super Scope : Fire = Left Mouse button Cursor Mode Button = Right Mouse button Pause = Backspace Key on keyboard Enable/Disable Autofire = =/+ key on keyboard, should be located to the left of the backspace key DSP1 is enabled automatically. Currently, it runs mario kart and some other games, but it does not run pilotwings due to a lack of dsp1 functions that are implemented. Zsnes auto-detects the SFX emulation from the header and enables it when found. Also, take note that the SFX is an additional 10Mhz(Ver1) or 20Mhz(Ver2) chip which also has to be emulated with the snes and will most likely produce a very noticeable slow down in emulation if you don't have a fast computer. Sometimes, the Multitap isn't compatible with some games. If that happens, disable Multitap by setting Player3,4, and 5's input device to 'None' in the GUI IPS patcher : Rename your .IPS file to the rom filename with the .IPS extension (eg. If your rom is SD3.SMC and your rom is SD3V05.IPS, rename SD3V05.IPS to SD3.IPS) and ZSNES will patch the rom realtime without modifying the rom file's contents. --------------------------------------------------------------------------- 12.) Bugs Section --------------------------------------------------------------------------- - 65816 lacks correct timing. Although ZSNES bases the timing on a variable cycle/instruction, it does not deduct correct values such as 16bit instructions should deduct 1 more cycle than 8bit instructions. 100% cycles of zsnes isn't 100% cycles of a snes because of that. This means that a lot of games either won't run or will produce horrible displays. Sometimes adjusting the % of execution can fix those problems. This is due to inaccurate documentation used when the 65816 was written. There is no plans on re-writing the 65816 timing yet. - Games sometimes tend to not display things properly because of graphic features that aren't implemented yet - The Sound DSP chip still has its bugs (not many though) --------------------------------------------------------------------------- 13.) Contact Information --------------------------------------------------------------------------- The ZSNES homepage is located at : http://www.zsnes.com If you have any questions about zsnes and you have read ZSNESFAQ.TXT, README.TXT, and GUINOTES.TXT to make sure the answer isn't there. And your question is NOT a ROM Request or asking about a newer version, you can post your question at the zsnes www board located at : http://www.zsnes.com/board/ Remember : This board should be mainly used for zsnes related questions. ROM requests (or asking for games, a link to a rom site, or where to find them) are forbidden!!! Be sure to also read the RULES! The rules are located at the top of the page. If you wish to contact the authors, you may contact them through : (Remember - No ROM requests please! and don't send any files without permission!) zsknight@zsnes.com _demo_@zsnes.com pharos@zsnes.com Try not to send a copy of your e-mail to all of us since that will just waste our time. Also, don't expect to get a reply since we are often busy. --------------------------------------------------------------------------- 14.) The Debugger --------------------------------------------------------------------------- Note : The debugger is disabled when you don't enter zsnes with a -d Here are the keys: 1 : Enable/Disable spc700 display 2 : Enable/Disable 65816 display T : Trace (in 65816 opcodes) B : 65816 break point S : SPC break point C : Clear Counter M : 65816 modify A : SPC modify D : Debug Dump (SPC/DSPRam Dump Only) W : Break at signal (Used only by the programmers) F1 : Exit debugger and return to Game F2 : Save State F4 : Load State ESC : Exit entire program --------------------------------------------------------------------------- 15.) Error Codes --------------------------------------------------------------------------- Unable to Initialize VESA2 : VBE not detected - ZSNES Failed to detect any VBE interrupts (Your video card doesn't support VESA) VESA not detected - ZSNES Failed to detect any VESA extensions (Your video card doesn't support VESA) VESA 2.0 or greater required - Your video card supports VESA, but it has an old version of VESA. You may want to use SDD (www.scitechsoft.com) to upgrade your vesa driver unless you have an S3 video card which you can get a vesa 2 driver from www.s3.com. VESA2 mode does not work on your video card/driver - Meaning that the resolution you chose does not exist in the supported resolutions of your video card. Chose a different resolution or upgrade with SDD which can sometimes help increase the number of resolutions supported Unable to initialize video mode - A VESA 2.0 driver is found, but the video mode failed to start. Possibly an error on the video card setting or a defective hardware Linear Frame Buffer not Detected - Meaning that your video card does not support linear frame buffering which is required for ZSNES' vesa 2 routines Modem Mode : Modem Response Timeout - If this appears, then either your modem isn't configured properly (Even though your COM port is set up properly, chances are your IRQ isn't), some other application is using the modem (such as an internet connection), you don't have a DOS compatible modem, or your baud rate isn't set up to the speed of your modem (this isn't required for all modems though, but for some, it's required) Cannot Init Driver - This means that you have the FOSSIL DRIVER option checked, but no fossil drivers are loaded Carrier Detected (When you're not connected) - This Probabily means that you have set your COM Port/IRQ incorrectly. This also might mean that you don't have a dos compatible modem or the modem is being used somewhere else such as an internet account. After Connection (Modem and IPX Mode) : Incompatible Version - This means that both sides are using different versions of zsnes. Both sides must use the same version in order for remote play to proceed. Invalid Sound Setting - This means that one side has sound disabled while the other has it enabled. Both sides have to either have sound disabled or sound enabled because the game timings of both settings are different. --------------------------------------------------------------------------- 16.) Credits --------------------------------------------------------------------------- ZSNES uses NASM, DJGPP, and optionally CWSDPMI (source codes & binary updates located at http://www.dbit.com/pub/cwsdpmi) as the compilers and DOS extenders. Thanks to those who produced these fine programs! Special thanks to wnelson! Without him, ZSNES would have never existed! Also to Y0SHi for his excellent snes docs, his help, and his excellent support! Also Thanks to : The_Teach of snes9x for some great info and the nice chats! Trepalium of snes9x for some great info and help! Gary of Snes9x and Steve Snake of KGen for being the source of info for sound decompression! Gary of Snes9x for being the source of info for TCall/PCall and also for lots of help! MrGrim for his great support! Crono for info on Sound Blaster Programming, Surround Sound, Sound Interpolation, and other sound stuff! Aquis for the zsnes logo! Alucard for helping us with an issue in the 65816! Vertigo for making a compatibility list! EFX for being a great supporter and also giving a lot of help and stuff! Zophar for being a great supporter and also maintaining the mirror site! Chris Hickman for redesigning the ZSNES web page! CSoft for hosting our web page! (www.csoft.net) Marius Fodor for the code for VSync, Sidewinder, Gamepad Pro, and some optimisation info! Sardu for some great info and help! Lord Esnes for some great help! Robert Grubbs for the sidewinder info! Nerlaska for some useful info on optimising and also for some help! Diskdude for writing sneskart which we used for the info on cheat codes! DarkForce a lot of great help! Pharos for some keyboard coding help! Ivar and Gary of the snes9x team for all the great help which includes their superfx info and code, DSP1 info, info on interleave formats (hirom & superfx), offset per tile mode, FIR filter, some spc700 and hdma bugs! WolfWings ShadowFlight for help on several issues of nasm! Wildfire for some help! A CoolMan for the algorithm for EAGLE! X-Sykodad and darklore for maintaining the ZSNES www board! Neill Corlett for some info on the .IPS format and also helping out a lot on improving the sound engine! Kreed (derek-liauw@usa.net) for the 2xSaI and Super Eagle Source Codes! 2xSaI homepage: http://members.xoom.com/derek_liauw/index.html Markus Oberhumer & Laszlo Molnar for the UPX compression utility UPX homepage: http://cdata.tvnet.hu/~ml/upx.html Jean-loup Gailly, Mark Adler, and Gilles Vollant for the unzip routines! Kode54 for the low pass filter routines! DCX for helping out fixing up some bugs! Andy Goth for some help on the design of the key combination engine! Antiriad for some testing help and for the chats! Yamaha of XYZZ (Scott Scriven) for his water effect code Yamaha's homepage: http://www.VIS.colostate.edu/~scriven/) All those people who helped us by either sending us docs, helping us, supporting us, and reporting bugs! Special Thanks to : Ashley, Barubary, CyberWarriorX, DCX, DooMStalK, Fanwen, GreenImp, Hucard, Kaiden, Stalphos Knight, Star Creator, TeleKawaru, Tuxedo Mask, the people in #zsnes efnet, and the regulars of the ZSNES message board! And also to all those whom we forgot! Special Thanks to all our beta testers for being a great help! Info on 256x256x256 scanlines mode is from the MAME source. Thanks to those behind MAME! Also, good luck to all those who are writing emulators, especially those who are writing snes emulators, including Snes9x, Nlke, SNEeSe, and SNEMul! And also good luck to the makers of TheSE! zsnes-1.36/dos/zsnesfaq.txt0100644000175000017500000005257407267141100015357 0ustar dolsondolson================================================ ZSNES Frequently Asked Questions - DOS Version ================================================ SOUND COMPATIBILITY ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come I don't get any sound? Q : When do you think you'll support GUS/PAS sound cards? Q : I get a sound initialization error using my SB Live! (or any other PCI card) How do I fix it? TRANSPARENCY ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Are there transparencies in ZSNES? Q : How do you enable transparencies? Q : There is this layer of fog blocking my view. What's wrong? GAME COMPATIBILITY ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't *name of game* work on zsnes? Q : Can you get *name of game* working by the next release? Q : Why is *name of game* not working in v.*version #* of zsnes? It was working before. Q : When do you think you will emulate the *DSP/SFX/C4* chip? My favorite game *name of game with chip* won't run without it. Q : This game tells me that it is not compatible with the MultiTap (or an external device attached). What should I do? Q : How do I improve the compatibility of ZSNES? Q : How come Mario RPG doesn't work? Q : Why am I experiencing problems with Chrono Trigger? Q : Why doesn't Star Ocean/Street Fighter Alpha 2 work? Q : Why doesn't MegamanX2/MegamanX3 work? Q : Can you guys get Star Ocean/Street Fighter Alpha 2 to work? SPEED ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why is zsnes slow? Q : How do I speed up zsnes? Q : Can you implement dynamic recompilation into zsnes? Q : Why does the game slow down even though I'm using auto frame rate and the FPS is pretty high? KEYBOARD/JOYSTICK ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why can't I press more than 2 keys at a time? Q : How come my sidewinder pad doesn't work? Q : How do I use more than one sidewinder pads? Q : Why doesn't my Gamepad Pro work? Q : Why doesn't my joystick work anymore? Q : How come my joystick keeps holding in one direction? Q : How do I use both my Keyboard and Joystick for the 1st player like v0.400? Q : Why does JB5/JB6 keep getting pressed whenever I try to change a key? IN-GAME SOUND ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why is the sound in zsnes not very good? Q : Why does ZSNES produce a lot of static? Q : How come stereo is reversed? CHEAT ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come the game genie codes don't work? Q : How do I use .CHT files? FREEZING/CRASHING ISSUES: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come ZSNES freezes when I run it under pure dos? Q : When I load a ROM, how come ZSNES crashes? Q : How come zsnes freezes when it tries to enter the GUI? MISC: ÍÍÍÍÍ Q : ZSNES gives me an out of memory error and I only have 16MB of RAM. How do I fix this? Q : How does the auto .IPS patching feature work? Q : Does the modem mode work well? Q : Why is modem mode so choppy and slow? Q : Does the IPX support work well? Q : Why does ZSNES display a blank (or messed) screen when I start it up on my laptop? Q : Can I run .ZIP files from the commandline? Q : Where do I get the games? ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* SOUND COMPATIBILITY ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come I don't get any sound? A : There could be several situations : 1.) You haven't enabled sound. You can enable it through the GUI 2.) Try ZSNES Version a instead of c (eg. If you have ZSNES v0.900c, download ZSNES v0.900a) 3.) Your windows 95 doesn't create a SET BLASTER string. To verify this, type SET in DOS and look for a string starting with BLASTER= If such a string exists, then this is not your problem. 4.) You don't have a SB2.0 compatible sound card. If this is your case, then there is nothing you can do at the moment. ZSNES uses auto-initialization mode for sound which requires SB2.0+ 5.) Your SB IRQ conflicts with another device. If this is the case, then you might want to check your sound card settings through Control Panel -> System. 6.) Zsnes doesn't like your sound card ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : When do you think you'll support GUS/PAS sound cards? A : We've considered implementing those sound cards, but a lack of time and also by the fact that we haven't really touched those cards before prevents us from implementing it. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : I get a sound initialization error using my SB Live! (or any other PCI card) How do I fix it? A : Here is a solution : (Thanks CyberGodz for the post on the wwwboard!) SB Live uses what is known as a NMI or Non Maskable Interrupt to emulate SB 16 sound. Don't ask me exactly what it does (it's a type of IRQ) but that is pretty much all it is good for. The problem is that many boards either lack NMI support or don't have it enabled. (No NMI = No Dos Support) To try and solve this problem do the following : 1. Check your BIOS. If there is an option for RAM Parity Checking ENABLE IT. It usually turns on NMI support. If there is something that says NMI turn it on 2. If you don't find anything in your BIOS, then go to your motherboards website and download the latest BIOS flash. Install it and try your dos sound. (You may still have to enable the stuff in the BIOS after) 3. Failing the first two things you will either have to get a new motherboard or install a SB 16, or other Compatable sound card alongside the Live. Just attach a cable from the Line Out of the SB 16 to the Line In of the Live. Enable line in on the mixer of your SB Live and it should route the sound through the old sound card. (Don't use the SPDIF to connect the cards if you have one. Wave sound dosn't pass through SPDIF only MIDI) ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* TRANSPARENCY ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Are there transparencies in ZSNES? A : Yes. Transparencies are in zsnes. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do you enable transparencies? A : First, try setting the video mode to a 16bit color video mode in the GUI (If 320x240x16b doesn't work, then try 640x480x16b). If it gives you an error that says that your video card isn't compatible with vesa 2.0, you might want to get the Scitech Display Doctor which is located at www.scitechsoft.com which provides certain cards with vesa 2.0 support. Running with transparencies on is definitely slower because of the extra math equations, memory, and video space involved. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : There is this layer of fog blocking my view. What's wrong? A : You need to either enable transparencies (see above) or you can disable certain backgrounds by pressing the 1,2,3, or 4 keys. If you get lost while pressing those keys, press 6 to re-enable all the backgrounds. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* COMPATIBILITY ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't *name of game* work on zsnes? A : Getting the compatibility higher is a very hard task to do. We're always trying to get more games working. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Can you get *name of game* working by the next release? A : We're always trying, but we can never guarantee a specific game will be working because of the difficulties involved in bug fixing. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why is *name of game* not working in v.*version #* of zsnes? It was working before. A : Whenever we change something in the emulation, whether it's optimisation or bug fixes, it has a good potential to have caused a problem elsewhere. Usually, these problems aren't discovered until after a release. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : When do you think you will emulate the *DSP/SFX/C4* chip? My favorite game *name of game with chip* won't run without it. A : We will consider emulating extra chips only if decent information on those chips are found. However, even if we find info on them, we cannot guarantee to be able to implement them. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : This game tells me that it is not compatible with the MultiTap. What should I do? A : Set both Player 3 and Player 4's input device to 'None' ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do I improve the compatibility of ZSNES? A : Turning on sound helps a lot here. If you can't enable sound, run zsnes using the commandlines -s and -dd. Also, try to keep the % of execution at 100%. If a game still doesn't work, try tweaking the percentage of execution to both 120% or 80% in zsnes.cfg. If that still doesn't work, then it's either a corrupt rom, a game that requires a special chip, or a bug in zsnes. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come Mario RPG doesn't work? A : If the emulator crashes, then your rom file is corrupt. If it only displays a blank screen, then you need to enable sound (or use -s -dd as the commandlines when running zsnes under dos) ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why am I experiencing problems with Chrono Trigger? A : - If there is a layer of fog blocking the view, then you need to either enable transparencies or remove the fog layer by pressing one of the 1,2,3 keys. - If the game freezes after the switching character sequence, then you need to enable sound (or use -s -dd as the commandlines when running zsnes under dos) and do not load from a save state, instead load from the game selection menu when you start the game normally. - If you cannot press the L+R+A seqence, then you would need to assign both the L and R key as the same key such as set L and R to PageUp and set A to Home, then pressing PageUp+Home will be the same as pressing L,R, and A together. This is a hardware limitation of the keyboard, not a bug in zsnes. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't MegamanX2/MegamanX3/Star Ocean/Street Fighter Alpha 2 work? A : Star Ocean and Street Fighter Alpha 2 both uses the S-DD1 chip, which uses an unknown compression routine that has to be figured out before it can be emulated. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't MegamanX2/MegamanX3 work? A : If it crashes after the Capcom logo, then you have a corrupt rom dump. The actual ROM size for both of them is about 2 megabytes. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Can you guys get Star Ocean/Street Fighter Alpha 2 to work? A : We have already worked on them to an extent, however, we cannot go much further until we gain knowledge on how to get them to work. Unfortunately, we are not magicians. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* SPEED ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do I speed up zsnes? A : Running zsnes under pure dos instead of in a windows box would help for low-end systems. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Can you implement dynamic recompilation into zsnes? A : There is no plans to implement it since it doesn't seem necessary. The snes only uses a 3mhz cpu compared to say a 33mhz on a playstation or a 93mhz on an n64. Implementing a dynamic recompilation engine will be hard work and won't improve performance by much. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why does the game slow down even though I'm using auto frame rate and the FPS is pretty high? A : A game slows down like that when it executes its code beyond the speed of cpu emulation that zsnes currently handles. To reduce such slowdowns, increase the percentage of execution by using either -p or editing zsnes.cfg. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* KEYBOARD/JOYSTICK ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why can't I press more than 2 keys at a time? A : It's mainly the limitation of the PC Keyboard. If you want to press more than 2 keys at a time, either use a joystick or change the keyboard keys around until you find a combination where you can press more than 2 keys at a time. Another technique that works is to set multiple buttons to a single key. That way, pressing that key presses multiple buttons at the same time. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come my sidewinder pad doesn't work? A : First, for non-USB Sidewinders, the first thing you should try is to first disable the sidewinder profiler from the Win9x icon tray, run ZSNES, set Input #1 as SidewinderPad1, then press the mode button a few times. If it doesn't work, then try the following : - Disable the Win9x Sidewinder Profiler, run Zsnes and press the Mode button a few times - Try checking or unchecking the Sidewinder Fix in the Options menu of the GUI and repeat the above steps - Fully disable the Win9x Sidewinder Drivers by going to Control Panel/Game Controllers. Then remove the sidewinder (Thanks Scarlet-Slider for this info!) - Run zsnes under pure dos - Try checking or unchecking the Sidewinder Fix in the Options menu of the GUI and repeat the above 2 steps - Make sure your sidewinder is plugged in and not broken For USB Joysticks, you can either set ZSNES as a 6-button joystick or simulate keyboard keys through the Sidewinder Profiler and set Input #1 as a keyboard with those defined keys. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do I use more than one sidewinder pads? A : First, run ZSNES, temporarily disconnect the second sidewinder pad from the first one, get the first one to work, then re-connect the second sidewinder pad. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't my Gamepad Pro work? A : For the non-USB version, be sure to have your Gamepad Pro set on 'GrIP' mode. Then set the input device as Gamepad Pro P0. For the USB version, you can use a keyboard emulator which should be included with the software that came with your joystick. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why doesn't my joystick work anymore? A : You might have accidently clicked the 'Use Joystick Port 209' check box. Just uncheck it. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come my joystick keeps holding in one direction? A : That happens when you hold a direction when ZSNES starts up. If that happens, then exit ZSNES and reload to recalibrate. Clicking on SET in the input device window also calibrates the joystick, but it also resets the controls to the default joystick settings. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do I use both my Keyboard and Joystick for the 1st player like v0.400? A : In the GUI, enter the CONFIG -> OPTIONS menu. Then check 'USE Pl1/2 AS Pl3/4'. Once you've done that, Player 3 controls will control Player 1 so if you have joystick set on Player 1, set Player 3 as keyboard. This disables multitap emulation however. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why does JB5/JB6 keep getting pressed whenever I try to change a key? A : Try changing your joystick type from a 6-button to a 4-button. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* IN-GAME SOUND ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why does ZSNES produce a lot of static? A : Try reducing your sampling rate or disable stereo sound ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come stereo is reversed? A : Click on the box by 'Reverse Stereo' in the Sound configuration in the GUI ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* CHEAT ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come the game genie codes don't work? A : You probabily didn't insert the '-'. Otherwise, try clicking on the FIX button once while the highlight is over the code. If it still doesn't work, chances are that the code is for another version of the game you're trying to run or the code is a fake. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How do I use .CHT files? A : Copy the .CHT file to the ROM Directory or if you have a save directory defined, copy it to the Save Directory. Then rename the .CHT file if necessary so that the filename before the . matches the ROM file. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* FREEZING/CRASHING ISSUES: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come ZSNES freezes when I run it under pure dos? A : Try loading your mouse driver or run zsnes using -j. For the most compatible result, use the Microsoft Mouse driver if possible ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : When I load a ROM, how come ZSNES crashes? A : It could be that ZSNES doesn't recognize your sound configuration so to fix it, disable sound or try changing your sound configuration. It could also be that the ROM you're loading isn't compatible with ZSNES. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How come zsnes freezes when it tries to enter the GUI? A : Run zsnes using the commandline -j ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ************* MISC: ************* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : ZSNES gives me an out of memory error and I only have 16MB of RAM. How do I fix this? A : First, create a shortcut to the DOS Prompt on the desktop (the filename that it points at can be c:\command.com ) Then right-click on the icon and go to properties. Select the memory tab and look below for Protected Mode (DPMI) settings and set a high value (like 20000). Then double click on that icon and load ZSNES as usual. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : How does the auto .IPS patching feature work? A : The auto .IPS feature works by copying the .IPS file to the directory of your ROM file or if you have a save directory defined, then the .IPS file goes into the save directory. Next, rename the .IPS file so that it matches filename (eg. If your ROM filename is THISGAME.SMC, then your .IPS filename is THISGAME.IPS.) ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Does the modem mode work well? A : It should work quite well. First, make sure that you are using a modem that is compatible with dos (a non winmodem). It is recommended that both sides has a modem that uses a 16550a UART, otherwise the game may go out of sync. Also, be sure to load a fresh new Zsnes session before starting a modem session. If it still doesn't work, then try running Zsnes under pure dos since some modems doesn't seem to work in windows in Zsnes while works in pure dos. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why is modem mode so choppy and slow? A : Try increasing the latency value one by one until the gameplay becomes smooth ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Does the IPX support work well? A : No. It does not work very well unless you have a very fast LAN. Otherwise, the game will easily go out of sync. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Why does ZSNES display a blank (or messed) screen when I start it up on my laptop? A : Your laptop is probably not compatible with ZSNES default 256x256x256 resolution. One way to fix it is to set the resolution to 320x240x256 by using the DOS commandline -v 0. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Can I run .ZIP files from the commandline? A : Yes. But you have to specify the full path/drive (eg. ZSNES D:\GAMES\GAME.ZIP) ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Q : Where do I get the games? A : The ZSNES Team will *NOT* provide any games or any links to games. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ zsnes-1.36/src/0042755000175000017500000000000007514703174012770 5ustar dolsondolsonzsnes-1.36/src/chips/0042755000175000017500000000000007514703044014072 5ustar dolsondolsonzsnes-1.36/src/chips/dsp1emu.c0100644000175000017500000011242007432554441015613 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #ifdef __LINUX__ #include "../gblhdr.h" #else #include #include #include #include #include #endif //#define DebugDSP1 // uncomment some lines to test //#define printinfo //#define debug02 //#define debug0A //#define debug06 #define __OPT__ #define __OPT01__ #define __OPT02__ //#define __OPT04__ #define __OPT06__ #define __OPT0C__ // this optimisation may break pilotwings #define __OPT11__ #define __OPT21__ #define __OPT1C__ #ifdef DebugDSP1 FILE * LogFile = NULL; void Log_Message (char *Message, ...) { char Msg[400]; va_list ap; va_start(ap,Message); vsprintf(Msg,Message,ap ); va_end(ap); strcat(Msg,"\r\n\0"); fwrite(Msg,strlen(Msg),1,LogFile); fflush (LogFile); } void Start_Log (void) { char LogFileName[255]; // [4/15/2001] char *p; strcpy(LogFileName,"dsp1emu.log\0"); LogFile = fopen(LogFileName,"wb"); } void Stop_Log(void) { if(LogFile) { fclose(LogFile); LogFile=NULL; } } #endif /***************************************************************************\ * Math tables * \***************************************************************************/ double *CosTable2; double *SinTable2; #define INCR 2048 #define Angle(x) (((x)/(65536/INCR)) & (INCR-1)) #define Cos(x) ((double) CosTable2[x]) #define Sin(x) ((double) SinTable2[x]) // gcc warning fix #ifdef PI #undef PI #endif #define PI 3.14159265358979323846264338327 double Atan(double x) { if ((x>=1) || (x<=1)) return (x/(1+0.28*x*x)); else return (PI/2 - Atan(1/x)); } /***************************************************************************\ * C4 C code * \***************************************************************************/ short C4WFXVal; short C4WFYVal; short C4WFZVal; short C4WFX2Val; short C4WFY2Val; short C4WFDist; short C4WFScale; double tanval; double c4x,c4y,c4z; double c4x2,c4y2,c4z2; void C4TransfWireFrame() { c4x=(double)C4WFXVal; c4y=(double)C4WFYVal; c4z=(double)C4WFZVal-0x95; // Rotate X tanval=-(double)C4WFX2Val*PI*2/128; c4y2=c4y*cos(tanval)-c4z*sin(tanval); c4z2=c4y*sin(tanval)+c4z*cos(tanval); // Rotate Y tanval=-(double)C4WFY2Val*PI*2/128; c4x2=c4x*cos(tanval)+c4z2*sin(tanval); c4z=c4x*-sin(tanval)+c4z2*cos(tanval); // Rotate Z tanval=-(double)C4WFDist*PI*2/128; c4x=c4x2*cos(tanval)-c4y2*sin(tanval); c4y=c4x2*sin(tanval)+c4y2*cos(tanval); // Scale C4WFXVal=(short)(c4x*C4WFScale/(0x90*(c4z+0x95))*0x95); C4WFYVal=(short)(c4y*C4WFScale/(0x90*(c4z+0x95))*0x95); } void C4TransfWireFrame2() { c4x=(double)C4WFXVal; c4y=(double)C4WFYVal; c4z=(double)C4WFZVal; // Rotate X tanval=-(double)C4WFX2Val*PI*2/128; c4y2=c4y*cos(tanval)-c4z*sin(tanval); c4z2=c4y*sin(tanval)+c4z*cos(tanval); // Rotate Y tanval=-(double)C4WFY2Val*PI*2/128; c4x2=c4x*cos(tanval)+c4z2*sin(tanval); c4z=c4x*-sin(tanval)+c4z2*cos(tanval); // Rotate Z tanval=-(double)C4WFDist*PI*2/128; c4x=c4x2*cos(tanval)-c4y2*sin(tanval); c4y=c4x2*sin(tanval)+c4y2*cos(tanval); // Scale C4WFXVal=(short)(c4x*C4WFScale/0x100); C4WFYVal=(short)(c4y*C4WFScale/0x100); } void C4CalcWireFrame() { C4WFXVal=C4WFX2Val-C4WFXVal; C4WFYVal=C4WFY2Val-C4WFYVal; if (abs(C4WFXVal)>abs(C4WFYVal)){ C4WFDist=abs(C4WFXVal)+1; C4WFYVal=(256*(long)C4WFYVal)/abs(C4WFXVal); if (C4WFXVal<0) C4WFXVal=-256; else C4WFXVal=256; } else if (C4WFYVal!=0) { C4WFDist=abs(C4WFYVal)+1; C4WFXVal=(256*(long)C4WFXVal)/abs(C4WFYVal); if (C4WFYVal<0) C4WFYVal=-256; else C4WFYVal=256; } else C4WFDist=0; } short C41FXVal; short C41FYVal; short C41FAngleRes; short C41FDist; short C41FDistVal; void C4Op1F() { if (C41FXVal == 0) { if (C41FYVal>0) C41FAngleRes=0x80; else C41FAngleRes=0x180; } else { tanval = ((double)C41FYVal)/((double)C41FXVal); C41FAngleRes=(short)(atan(tanval)/(PI*2)*512); C41FAngleRes=C41FAngleRes; if (C41FXVal<0) C41FAngleRes+=0x100; C41FAngleRes&=0x1FF; } } void C4Op15() { tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)* ((double)C41FXVal)); C41FDist=(short)tanval; } void C4Op0D() { tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)* ((double)C41FXVal)); tanval=(double)C41FDistVal/tanval; C41FYVal=(short)(((double)C41FYVal*tanval)*0.99); C41FXVal=(short)(((double)C41FXVal*tanval)*0.98); } /***************************************************************************\ * DSP1 code * \***************************************************************************/ void InitDSP(void) { #ifdef __OPT__ unsigned int i; CosTable2 = (double *)malloc(INCR*sizeof(double)); SinTable2 = (double *)malloc(INCR*sizeof(double)); for (i=0; i 0) while (Op10Temp>=1.0) { Op10Temp=Op10Temp/2.0; Op10ExponentR++; } else while (Op10Temp<-1.0) { Op10Temp=Op10Temp/2.0; Op10ExponentR++; } Op10CoefficientR = Op10Temp*32768; #ifdef DebugDSP1 Log_Message("OP10 INV %d*2^%d = %d*2^%d", Op10Coefficient, Op10Exponent, Op10CoefficientR, Op10ExponentR); #endif } short Op04Angle; unsigned short Op04Radius; short Op04Sin; short Op04Cos; #ifdef __OPT04__ void DSPOp04() { int angle; angle = Angle(Op04Angle); Op04Sin = Sin(angle) * Op04Radius; Op04Cos = Cos(angle) * Op04Radius; #ifdef DebugDSP1 Log_Message("OP04 Angle:%d Radius:%d",(Op04Angle/256)&255,Op04Radius); Log_Message("OP04 SIN:%d COS:%d",Op04Sin,Op04Cos); #endif } #else void DSPOp04() { double angle; angle = Op04Angle*2*PI/65536.0; Op04Sin = sin(angle) * Op04Radius; Op04Cos = cos(angle) * Op04Radius; #ifdef DebugDSP1 Log_Message("OP04 Angle:%d Radius:%d",(Op04Angle/256)&255,Op04Radius); Log_Message("OP04 SIN:%d COS:%d",Op04Sin,Op04Cos); #endif } #endif unsigned short Op0CA; short Op0CX1; short Op0CY1; short Op0CX2; short Op0CY2; #ifdef __OPT0C__ void DSPOp0C() { Op0CX2=(Op0CX1*Cos(Angle(Op0CA))+Op0CY1*Sin(Angle(Op0CA))); Op0CY2=(Op0CX1*-Sin(Angle(Op0CA))+Op0CY1*Cos(Angle(Op0CA))); #ifdef DebugDSP1 Log_Message("OP0C Angle:%d X:%d Y:%d CX:%d CY:%d",(Op0CA/256)&255,Op0CX1,Op0CY1,Op0CX2,Op0CY2); #endif } #else void DSPOp0C() { Op0CX2=(Op0CX1*cos(Op0CA*2*PI/65536.0)+Op0CY1*sin(Op0CA*2*PI/65536.0)); Op0CY2=(Op0CX1*-sin(Op0CA*2*PI/65536.0)+Op0CY1*cos(Op0CA*2*PI/65536.0)); #ifdef DebugDSP1 Log_Message("OP0C Angle:%d X:%d Y:%d CX:%d CY:%d",(Op0CA/256)&255,Op0CX1,Op0CY1,Op0CX2,Op0CY2); #endif } #endif short Op02FX; short Op02FY; short Op02FZ; short Op02LFE; short Op02LES; unsigned short Op02AAS; unsigned short Op02AZS; unsigned short Op02VOF; unsigned short Op02VVA; short Op02CX; short Op02CY; double Op02CXF; double Op02CYF; double ViewerX0; double ViewerY0; double ViewerZ0; double ViewerX1; double ViewerY1; double ViewerZ1; double ViewerX; double ViewerY; double ViewerZ; int ViewerAX; int ViewerAY; int ViewerAZ; double NumberOfSlope; double ScreenX; double ScreenY; double ScreenZ; double TopLeftScreenX; double TopLeftScreenY; double TopLeftScreenZ; double BottomRightScreenX; double BottomRightScreenY; double BottomRightScreenZ; double Ready; double RasterLX; double RasterLY; double RasterLZ; double ScreenLX1; double ScreenLY1; double ScreenLZ1; int ReversedLES; short Op02LESb; double NAzsB,NAasB; double ViewerXc; double ViewerYc; double ViewerZc; double CenterX,CenterY; short Op02CYSup,Op02CXSup; double CXdistance; #define VofAngle 0x3880 short TValDebug,TValDebug2; short ScrDispl; #ifdef __OPT02__ void DSPOp02() { ViewerZ1=-Cos(Angle(Op02AZS)); ViewerX1=Sin(Angle(Op02AZS))*Sin(Angle(Op02AAS)); ViewerY1=Sin(Angle(Op02AZS))*Cos(Angle(Op02AAS)); #ifdef debug02 printf("\nViewerX1 : %f ViewerY1 : %f ViewerZ1 : %f\n",ViewerX1,ViewerY1, ViewerZ1); getch(); #endif ViewerX=Op02FX-ViewerX1*Op02LFE; ViewerY=Op02FY-ViewerY1*Op02LFE; ViewerZ=Op02FZ-ViewerZ1*Op02LFE; ScreenX=Op02FX+ViewerX1*(Op02LES-Op02LFE); ScreenY=Op02FY+ViewerY1*(Op02LES-Op02LFE); ScreenZ=Op02FZ+ViewerZ1*(Op02LES-Op02LFE); #ifdef debug02 printf("ViewerX : %f ViewerY : %f ViewerZ : %f\n",ViewerX,ViewerY,ViewerZ); printf("Op02FX : %d Op02FY : %d Op02FZ : %d\n",Op02FX,Op02FY,Op02FZ); printf("ScreenX : %f ScreenY : %f ScreenZ : %f\n",ScreenX,ScreenY,ScreenZ); getch(); #endif if (ViewerZ1==0)ViewerZ1++; NumberOfSlope=ViewerZ/-ViewerZ1; Op02CX=(short)(Op02CXF=ViewerX+ViewerX1*NumberOfSlope); Op02CY=(short)(Op02CYF=ViewerY+ViewerY1*NumberOfSlope); Op02VOF=0x0000; ReversedLES=0; Op02LESb=Op02LES; if ((Op02LES>=VofAngle+16384.0) && (Op02LES=VofAngle) && (Op02LESb<=VofAngle+0x4000)) { Op02VOF= (short)(Op02LESb * tan((Op02AZS-0x4000-VofAngle)*6.2832/65536.0)); Op02VVA-=Op02VOF; } if (ReversedLES){ Op02VOF=-Op02VOF; } NAzsB = (Op02AZS-0x4000)*6.2832/65536.0; NAasB = Op02AAS*6.2832/65536.0; if (tan(NAzsB)==0) NAzsB=0.1; ScrDispl=0; if (NAzsB>-0.15) {NAzsB=-0.15;ScrDispl=Op02VVA-0xFFDA;} CXdistance=1/tan(NAzsB); ViewerXc=Op02FX; ViewerYc=Op02FY; ViewerZc=Op02FZ; CenterX = (-sin(NAasB)*ViewerZc*CXdistance)+ViewerXc; CenterY = (cos(NAasB)*ViewerZc*CXdistance)+ViewerYc; Op02CX = (short)CenterX; Op02CY = (short)CenterY; ViewerXc=ViewerX;//-Op02FX); ViewerYc=ViewerY;//-Op02FY); ViewerZc=ViewerZ;//-Op02FZ); CenterX = (-sin(NAasB)*ViewerZc*CXdistance)+ViewerXc; if (CenterX<-32768) CenterX = -32768; if (CenterX>32767) CenterX=32767; CenterY = (cos(NAasB)*ViewerZc*CXdistance)+ViewerYc; if (CenterY<-32768) CenterY = -32768; if (CenterY>32767) CenterY=32767; TValDebug = (NAzsB*65536/6.28); TValDebug2 = ScrDispl; // if (Op02CY < 0) {Op02CYSup = Op02CY/256; Op02CY = 0;} // if (Op02CX < 0) {Op02CXSup = Op02CX/256; Op02CX = 0;} // [4/15/2001] (ViewerX+ViewerX1*NumberOfSlope); // [4/15/2001] (ViewerY+ViewerY1*NumberOfSlope); // if(Op02LFE==0x2200)Op02VVA=0xFECD; // else Op02VVA=0xFFB2; #ifdef DebugDSP1 Log_Message("OP02 FX:%d FY:%d FZ:%d LFE:%d LES:%d",Op02FX,Op02FY,Op02FZ,Op02LFE,Op02LES); Log_Message(" AAS:%d AZS:%d VOF:%d VVA:%d",Op02AAS,Op02AZS,Op02VOF,Op02VVA); Log_Message(" VX:%d VY:%d VZ:%d",(short)ViewerX,(short)ViewerY,(short)ViewerZ); #endif } #else void DSPOp02() { ViewerZ1=-cos(Op02AZS*6.2832/65536.0); ViewerX1=sin(Op02AZS*6.2832/65536.0)*sin(Op02AAS*6.2832/65536.0); ViewerY1=sin(Op02AZS*6.2832/65536.0)*cos(-Op02AAS*6.2832/65536.0); #ifdef debug02 printf("\nViewerX1 : %f ViewerY1 : %f ViewerZ1 : %f\n",ViewerX1,ViewerY1, ViewerZ1); getch(); #endif ViewerX=Op02FX-ViewerX1*Op02LFE; ViewerY=Op02FY-ViewerY1*Op02LFE; ViewerZ=Op02FZ-ViewerZ1*Op02LFE; ScreenX=Op02FX+ViewerX1*(Op02LES-Op02LFE); ScreenY=Op02FY+ViewerY1*(Op02LES-Op02LFE); ScreenZ=Op02FZ+ViewerZ1*(Op02LES-Op02LFE); #ifdef debug02 printf("ViewerX : %f ViewerY : %f ViewerZ : %f\n",ViewerX,ViewerY,ViewerZ); printf("Op02FX : %d Op02FY : %d Op02FZ : %d\n",Op02FX,Op02FY,Op02FZ); printf("ScreenX : %f ScreenY : %f ScreenZ : %f\n",ScreenX,ScreenY,ScreenZ); getch(); #endif if (ViewerZ1==0)ViewerZ1++; NumberOfSlope=ViewerZ/-ViewerZ1; Op02CX=(short)(Op02CXF=ViewerX+ViewerX1*NumberOfSlope); Op02CY=(short)(Op02CYF=ViewerY+ViewerY1*NumberOfSlope); ViewerXc=ViewerX;//-Op02FX); ViewerYc=ViewerY;//-Op02FY); ViewerZc=ViewerZ;//-Op02FZ); Op02VOF=0x0000; ReversedLES=0; Op02LESb=Op02LES; if ((Op02LES>=VofAngle+16384.0) && (Op02LES=VofAngle) && (Op02LESb<=VofAngle+0x4000)) { Op02VOF= (short)(Op02LESb * tan((Op02AZS-0x4000-VofAngle)*6.2832/65536.0)); Op02VVA-=Op02VOF; } if (ReversedLES){ Op02VOF=-Op02VOF; } NAzsB = (Op02AZS-0x4000)*6.2832/65536.0; NAasB = Op02AAS*6.2832/65536.0; if (tan(NAzsB)==0) NAzsB=0.1; ScrDispl=0; if (NAzsB>-0.15) {NAzsB=-0.15;ScrDispl=Op02VVA-0xFFDA;} CXdistance=1/tan(NAzsB); CenterX = (-sin(NAasB)*ViewerZc*CXdistance)+ViewerXc; if (CenterX<-32768) CenterX = -32768; if (CenterX>32767) CenterX=32767; Op02CX = (short)CenterX; CenterY = (cos(NAasB)*ViewerZc*CXdistance)+ViewerYc; if (CenterY<-32768) CenterY = -32768; if (CenterY>32767) CenterY=32767; Op02CY = (short)CenterY; TValDebug = (NAzsB*65536/6.28); TValDebug2 = ScrDispl; // if (Op02CY < 0) {Op02CYSup = Op02CY/256; Op02CY = 0;} // if (Op02CX < 0) {Op02CXSup = Op02CX/256; Op02CX = 0;} // [4/15/2001] (ViewerX+ViewerX1*NumberOfSlope); // [4/15/2001] (ViewerY+ViewerY1*NumberOfSlope); // if(Op02LFE==0x2200)Op02VVA=0xFECD; // else Op02VVA=0xFFB2; #ifdef DebugDSP1 Log_Message("OP02 FX:%d FY:%d FZ:%d LFE:%d LES:%d",Op02FX,Op02FY,Op02FZ,Op02LFE,Op02LES); Log_Message(" AAS:%d AZS:%d VOF:%d VVA:%d",Op02AAS,Op02AZS,Op02VOF,Op02VVA); Log_Message(" VX:%d VY:%d VZ:%d",(short)ViewerX,(short)ViewerY,(short)ViewerZ); #endif } #endif short Op0AVS; short Op0AA; short Op0AB; short Op0AC; short Op0AD; double RasterRX; double RasterRY; double RasterRZ; double RasterLSlopeX; double RasterLSlopeY; double RasterLSlopeZ; double RasterRSlopeX; double RasterRSlopeY; double RasterRSlopeZ; double GroundLX; double GroundLY; double GroundRX; double GroundRY; double Distance; double NAzs,NAas; double RVPos,RHPos,RXRes,RYRes; void GetRXYPos(){ double scalar; if (Op02LES==0) return; NAzs = NAzsB - Atan((RVPos) / (double)Op02LES); NAas = NAasB;// + Atan(RHPos) / (double)Op02LES); if (cos(NAzs)==0) NAzs+=0.001; if (tan(NAzs)==0) NAzs+=0.001; RXRes = (-sin(NAas)*ViewerZc/(tan(NAzs))+ViewerXc); RYRes = (cos(NAas)*ViewerZc/(tan(NAzs))+ViewerYc); scalar = ((ViewerZc/sin(NAzs))/(double)Op02LES); RXRes += scalar*-sin(NAas+PI/2)*RHPos; RYRes += scalar*cos(NAas+PI/2)*RHPos; } void DSPOp0A() { double x2,y2,x3,y3,x4,y4,m,ypos; if(Op0AVS==0) {Op0AVS++; return;} ypos=Op0AVS-ScrDispl; // CenterX,CenterX = Center (x1,y1) // Get (0,Vs) coords (x2,y2) RVPos = ypos; RHPos = 0; GetRXYPos(); x2 = RXRes; y2 = RYRes; // Get (-128,Vs) coords (x3,y3) RVPos = ypos; RHPos = -128; GetRXYPos(); x3 = RXRes; y3 = RYRes; // Get (127,Vs) coords (x4,y4) RVPos = ypos; RHPos = 127; GetRXYPos(); x4 = RXRes; y4 = RYRes; // A = (x4-x3)/256 m = (x4-x3)/256*256; if (m>32767) m=32767; if (m<-32768) m=-32768; Op0AA = (short)(m); // C = (y4-y3)/256 m = (y4-y3)/256*256; if (m>32767) m=32767; if (m<-32768) m=-32768; Op0AC = (short)(m); if (ypos==0){ Op0AB = 0; Op0AD = 0; } else { // B = (x2-x1)/Vs m = (x2-CenterX)/ypos*256; if (m>32767) m=32767; if (m<-32768) m=-32768; Op0AB = (short)(m); // D = (y2-y1)/Vs m = (y2-CenterY)/ypos*256; if (m>32767) m=32767; if (m<-32768) m=-32768; Op0AD = (short)(m); } Op0AVS+=1; } short Op06X; short Op06Y; short Op06Z; short Op06H; short Op06V; unsigned short Op06S; double ObjPX; double ObjPY; double ObjPZ; double ObjPX1; double ObjPY1; double ObjPZ1; double ObjPX2; double ObjPY2; double ObjPZ2; double DivideOp06; int Temp; int tanval2; #ifdef __OPT06__ void DSPOp06() { ObjPX=Op06X-Op02FX; ObjPY=Op06Y-Op02FY; ObjPZ=Op06Z-Op02FZ; // rotate around Z tanval2 = Angle(-Op02AAS+32768); // tanval2 = (-Op02AAS+32768)/(65536/INCR); ObjPX1=(ObjPX*Cos(tanval2)+ObjPY*-Sin(tanval2)); ObjPY1=(ObjPX*Sin(tanval2)+ObjPY*Cos(tanval2)); ObjPZ1=ObjPZ; // rotate around X // tanval2 = (-Op02AZS/(65536/INCR)) & 1023; tanval2 = Angle(-Op02AZS); // tanval2 = (-Op02AZS)/256; ObjPX2=ObjPX1; ObjPY2=(ObjPY1*Cos(tanval2)+ObjPZ1*-Sin(tanval2)); ObjPZ2=(ObjPY1*Sin(tanval2)+ObjPZ1*Cos(tanval2)); #ifdef debug06 Log_Message("ObjPX2: %f ObjPY2: %f ObjPZ2: %f\n",ObjPX2,ObjPY2,ObjPZ2); #endif ObjPZ2=ObjPZ2-Op02LFE; if (ObjPZ2<0) { Op06H=(short)(-ObjPX2*Op02LES/-(ObjPZ2)); //-ObjPX2*256/-ObjPZ2; Op06V=(short)(-ObjPY2*Op02LES/-(ObjPZ2)); //-ObjPY2*256/-ObjPZ2; Op06S=(unsigned short)(256*(double)Op02LES/-ObjPZ2); } else { Op06H=0; Op06V=14*16; Op06S=0xFFFF; } #ifdef DebugDSP1 Log_Message("OP06 X:%d Y:%d Z:%d",Op06X,Op06Y,Op06Z); Log_Message("OP06 H:%d V:%d S:%d",Op06H,Op06V,Op06S); #endif } #else void DSPOp06() { ObjPX=Op06X-Op02FX; ObjPY=Op06Y-Op02FY; ObjPZ=Op06Z-Op02FZ; // rotate around Z tanval = (-Op02AAS+32768)/65536.0*6.2832; ObjPX1=(ObjPX*cos(tanval)+ObjPY*-sin(tanval)); ObjPY1=(ObjPX*sin(tanval)+ObjPY*cos(tanval)); ObjPZ1=ObjPZ; #ifdef debug06 Log_Message("Angle : %f", tanval); Log_Message("ObjPX1: %f ObjPY1: %f ObjPZ1: %f\n",ObjPX1,ObjPY1,ObjPZ1); Log_Message("cos(tanval) : %f sin(tanval) : %f", cos(tanval), sin(tanval)); #endif // rotate around X tanval = (-Op02AZS)/65536.0*6.2832; ObjPX2=ObjPX1; ObjPY2=(ObjPY1*cos(tanval)+ObjPZ1*-sin(tanval)); ObjPZ2=(ObjPY1*sin(tanval)+ObjPZ1*cos(tanval)); #ifdef debug06 Log_Message("ObjPX2: %f ObjPY2: %f ObjPZ2: %f\n",ObjPX2,ObjPY2,ObjPZ2); #endif ObjPZ2=ObjPZ2-Op02LFE; if (ObjPZ2<0) { Op06H=(short)(-ObjPX2*Op02LES/-(ObjPZ2)); //-ObjPX2*256/-ObjPZ2; Op06V=(short)(-ObjPY2*Op02LES/-(ObjPZ2)); //-ObjPY2*256/-ObjPZ2; Op06S=(unsigned short)(256*(double)Op02LES/-ObjPZ2); } else { Op06H=0; Op06V=14*16; Op06S=0xFFFF; } #ifdef DebugDSP1 Log_Message("OP06 X:%d Y:%d Z:%d",Op06X,Op06Y,Op06Z); Log_Message("OP06 H:%d V:%d S:%d",Op06H,Op06V,Op06S); #endif } #endif double matrixB[3][3]; double matrixB2[3][3]; double matrixB3[3][3]; double matrixA[3][3]; double matrixA2[3][3]; double matrixA3[3][3]; void MultMatrixB(double result[3][3],double mat1[3][3],double mat2[3][3]) { result[0][0]=(mat1[0][0]*mat2[0][0]+mat1[0][1]*mat2[1][0]+mat1[0][2]*mat2[2][0]); result[0][1]=(mat1[0][0]*mat2[0][1]+mat1[0][1]*mat2[1][1]+mat1[0][2]*mat2[2][1]); result[0][2]=(mat1[0][0]*mat2[0][2]+mat1[0][1]*mat2[1][2]+mat1[0][2]*mat2[2][2]); result[1][0]=(mat1[1][0]*mat2[0][0]+mat1[1][1]*mat2[1][0]+mat1[1][2]*mat2[2][0]); result[1][1]=(mat1[1][0]*mat2[0][1]+mat1[1][1]*mat2[1][1]+mat1[1][2]*mat2[2][1]); result[1][2]=(mat1[1][0]*mat2[0][2]+mat1[1][1]*mat2[1][2]+mat1[1][2]*mat2[2][2]); result[2][0]=(mat1[2][0]*mat2[0][0]+mat1[2][1]*mat2[1][0]+mat1[2][2]*mat2[2][0]); result[2][1]=(mat1[2][0]*mat2[0][1]+mat1[2][1]*mat2[1][1]+mat1[2][2]*mat2[2][1]); result[2][2]=(mat1[2][0]*mat2[0][2]+mat1[2][1]*mat2[1][2]+mat1[2][2]*mat2[2][2]); } short Op01m; short Op01Zr; short Op01Xr; short Op01Yr; short Op11m; short Op11Zr; short Op11Xr; short Op11Yr; short Op21m; short Op21Zr; short Op21Xr; short Op21Yr; double sc,sc2,sc3; #ifdef __OPT01__ void DSPOp01() { unsigned short zr,yr,xr; zr = Angle(Op01Zr); xr = Angle(Op01Yr); yr = Angle(Op01Xr); matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=Cos(xr); matrixB[1][2]=-Sin(xr); matrixB[2][0]=0; matrixB[2][1]=Sin(xr); matrixB[2][2]=Cos(xr); matrixB2[0][0]=Cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=Sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-Sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=Cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=Cos(zr); matrixB2[0][1]=-Sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=Sin(zr); matrixB2[1][1]=Cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc = ((double)Op01m)/32768.0; matrixA[0][0]=matrixB[0][0]; matrixA[0][1]=matrixB[0][1]; matrixA[0][2]=matrixB[0][2]; matrixA[1][0]=matrixB[1][0]; matrixA[1][1]=matrixB[1][1]; matrixA[1][2]=matrixB[1][2]; matrixA[2][0]=matrixB[2][0]; matrixA[2][1]=matrixB[2][1]; matrixA[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP01 ZR: %d XR: %d YR: %d",Op01Zr,Op01Xr,Op01Yr); #endif } #else void DSPOp01() { double zr,yr,xr; zr = ((double)Op01Zr)*6.2832/65536; xr = ((double)Op01Yr)*6.2832/65536; yr = ((double)Op01Xr)*6.2832/65536; matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=cos(xr); matrixB[1][2]=-sin(xr); matrixB[2][0]=0; matrixB[2][1]=sin(xr); matrixB[2][2]=cos(xr); matrixB2[0][0]=cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=cos(zr); matrixB2[0][1]=-sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=sin(zr); matrixB2[1][1]=cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc = ((double)Op01m)/32768.0; matrixA[0][0]=matrixB[0][0]; matrixA[0][1]=matrixB[0][1]; matrixA[0][2]=matrixB[0][2]; matrixA[1][0]=matrixB[1][0]; matrixA[1][1]=matrixB[1][1]; matrixA[1][2]=matrixB[1][2]; matrixA[2][0]=matrixB[2][0]; matrixA[2][1]=matrixB[2][1]; matrixA[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP01 ZR: %d XR: %d YR: %d",Op01Zr,Op01Xr,Op01Yr); #endif } #endif #ifdef __OPT11__ void DSPOp11() { short zr,yr,xr; zr = Angle(Op11Zr); xr = Angle(Op11Yr); yr = Angle(Op11Xr); matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=Cos(xr); matrixB[1][2]=-Sin(xr); matrixB[2][0]=0; matrixB[2][1]=Sin(xr); matrixB[2][2]=Cos(xr); matrixB2[0][0]=Cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=Sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-Sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=Cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=Cos(zr); matrixB2[0][1]=-Sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=Sin(zr); matrixB2[1][1]=Cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc2 = ((double)Op11m)/32768.0; matrixA2[0][0]=matrixB[0][0]; matrixA2[0][1]=matrixB[0][1]; matrixA2[0][2]=matrixB[0][2]; matrixA2[1][0]=matrixB[1][0]; matrixA2[1][1]=matrixB[1][1]; matrixA2[1][2]=matrixB[1][2]; matrixA2[2][0]=matrixB[2][0]; matrixA2[2][1]=matrixB[2][1]; matrixA2[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP11 ZR: %d XR: %d YR: %d SC: %d",Op11Zr,Op11Xr,Op11Yr,Op11m); #endif } #else void DSPOp11() { double zr,yr,xr; zr = ((double)Op11Zr)*6.2832/65536; xr = ((double)Op11Yr)*6.2832/65536; yr = ((double)Op11Xr)*6.2832/65536; matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=cos(xr); matrixB[1][2]=-sin(xr); matrixB[2][0]=0; matrixB[2][1]=sin(xr); matrixB[2][2]=cos(xr); matrixB2[0][0]=cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=cos(zr); matrixB2[0][1]=-sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=sin(zr); matrixB2[1][1]=cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc2 = ((double)Op11m)/32768.0; matrixA2[0][0]=matrixB[0][0]; matrixA2[0][1]=matrixB[0][1]; matrixA2[0][2]=matrixB[0][2]; matrixA2[1][0]=matrixB[1][0]; matrixA2[1][1]=matrixB[1][1]; matrixA2[1][2]=matrixB[1][2]; matrixA2[2][0]=matrixB[2][0]; matrixA2[2][1]=matrixB[2][1]; matrixA2[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP11 ZR: %d XR: %d YR: %d SC: %d",Op11Zr,Op11Xr,Op11Yr,Op11m); #endif } #endif #ifdef __OPT21__ void DSPOp21() { short zr,yr,xr; zr = Angle(Op21Zr); xr = Angle(Op21Yr); yr = Angle(Op21Xr); matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=Cos(xr); matrixB[1][2]=-Sin(xr); matrixB[2][0]=0; matrixB[2][1]=Sin(xr); matrixB[2][2]=Cos(xr); matrixB2[0][0]=Cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=Sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-Sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=Cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=Cos(zr); matrixB2[0][1]=-Sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=Sin(zr); matrixB2[1][1]=Cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc3 = ((double)Op21m)/32768.0; matrixA3[0][0]=matrixB[0][0]; matrixA3[0][1]=matrixB[0][1]; matrixA3[0][2]=matrixB[0][2]; matrixA3[1][0]=matrixB[1][0]; matrixA3[1][1]=matrixB[1][1]; matrixA3[1][2]=matrixB[1][2]; matrixA3[2][0]=matrixB[2][0]; matrixA3[2][1]=matrixB[2][1]; matrixA3[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP21 ZR: %d XR: %d YR: %d",Op21Zr,Op21Xr,Op21Yr); #endif } #else void DSPOp21() { double zr,yr,xr; zr = ((double)Op21Zr)*6.2832/65536; xr = ((double)Op21Yr)*6.2832/65536; yr = ((double)Op21Xr)*6.2832/65536; matrixB[0][0]=1; matrixB[0][1]=0; matrixB[0][2]=0; matrixB[1][0]=0; matrixB[1][1]=cos(xr); matrixB[1][2]=-sin(xr); matrixB[2][0]=0; matrixB[2][1]=sin(xr); matrixB[2][2]=cos(xr); matrixB2[0][0]=cos(yr); matrixB2[0][1]=0; matrixB2[0][2]=sin(yr); matrixB2[1][0]=0; matrixB2[1][1]=1; matrixB2[1][2]=0; matrixB2[2][0]=-sin(yr); matrixB2[2][1]=0; matrixB2[2][2]=cos(yr); MultMatrixB(matrixB3,matrixB,matrixB2); matrixB2[0][0]=cos(zr); matrixB2[0][1]=-sin(zr); matrixB2[0][2]=0; matrixB2[1][0]=sin(zr); matrixB2[1][1]=cos(zr); matrixB2[1][2]=0; matrixB2[2][0]=0; matrixB2[2][1]=0; matrixB2[2][2]=1; MultMatrixB(matrixB,matrixB3,matrixB2); sc3 = ((double)Op21m)/32768.0; matrixA3[0][0]=matrixB[0][0]; matrixA3[0][1]=matrixB[0][1]; matrixA3[0][2]=matrixB[0][2]; matrixA3[1][0]=matrixB[1][0]; matrixA3[1][1]=matrixB[1][1]; matrixA3[1][2]=matrixB[1][2]; matrixA3[2][0]=matrixB[2][0]; matrixA3[2][1]=matrixB[2][1]; matrixA3[2][2]=matrixB[2][2]; #ifdef DebugDSP1 Log_Message("OP21 ZR: %d XR: %d YR: %d",Op21Zr,Op21Xr,Op21Yr); #endif } #endif short Op0DX; short Op0DY; short Op0DZ; short Op0DF; short Op0DL; short Op0DU; short Op1DX; short Op1DY; short Op1DZ; short Op1DF; short Op1DL; short Op1DU; short Op2DX; short Op2DY; short Op2DZ; short Op2DF; short Op2DL; short Op2DU; #define swap(a,b) temp=a;a=b;b=temp; void DSPOp0D() { double a,b,c,d,e,f,g,h,i,det,temp; double a2,b2,c2,d2,e2,f2,g2,h2,i2,x,y,z; a = matrixA[0][0]; b=matrixA[0][1]; c=matrixA[0][2]; d = matrixA[1][0]; e=matrixA[1][1]; f=matrixA[1][2]; g = matrixA[2][0]; h=matrixA[2][1]; i=matrixA[2][2]; //abc //def //ghi det = a*e*i+b*f*g+c*d*h-g*e*c-h*f*a-i*d*b; if (det==0) { Op0DF=Op0DX; Op0DL=Op0DY; Op0DU=Op0DZ; #ifdef DebugDSP1 Log_Message("OP0D Error! Det == 0"); #endif return; } swap(d,b); swap(g,c); swap(h,f); b=-b; d=-d; f=-f; h=-h; a2=(e*i-h*f)/det; b2=(d*i-g*f)/det; c2=(d*h-g*e)/det; d2=(b*i-h*c)/det; e2=(a*i-g*c)/det; f2=(a*h-g*b)/det; g2=(b*f-e*c)/det; h2=(a*f-d*c)/det; i2=(a*e-d*b)/det; x=Op0DX; y=Op0DY; z=Op0DZ; Op0DF=(short)((x*a2+y*d2+z*g2)/2*sc); Op0DL=(short)((x*b2+y*e2+z*h2)/2*sc); Op0DU=(short)((x*c2+y*f2+z*i2)/2*sc); #ifdef DebugDSP1 Log_Message("OP0D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op0DX,Op0DY,Op0DZ,Op0DF,Op0DL,Op0DU); #endif } void DSPOp1D() { double a,b,c,d,e,f,g,h,i,det,temp; double a2,b2,c2,d2,e2,f2,g2,h2,i2,x,y,z; a = matrixA2[0][0]; b=matrixA2[0][1]; c=matrixA2[0][2]; d = matrixA2[1][0]; e=matrixA2[1][1]; f=matrixA2[1][2]; g = matrixA2[2][0]; h=matrixA2[2][1]; i=matrixA2[2][2]; //abc //def //ghi det = a*e*i+b*f*g+c*d*h-g*e*c-h*f*a-i*d*b; if (det==0) { Op1DF=0; Op1DL=0; Op1DU=0; return; } swap(d,b); swap(g,c); swap(h,f); b=-b; d=-d; f=-f; h=-h; a2=(e*i-h*f)/det; b2=(d*i-g*f)/det; c2=(d*h-g*e)/det; d2=(b*i-h*c)/det; e2=(a*i-g*c)/det; f2=(a*h-g*b)/det; g2=(b*f-e*c)/det; h2=(a*f-d*c)/det; i2=(a*e-d*b)/det; x=Op1DX; y=Op1DY; z=Op1DZ; Op1DF=(short)((x*a2+y*d2+z*g2)/2*sc2); Op1DL=(short)((x*b2+y*e2+z*h2)/2*sc2); Op1DU=(short)((x*c2+y*f2+z*i2)/2*sc2); #ifdef DebugDSP1 Log_Message("OP1D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op1DX,Op1DY,Op1DZ,Op1DF,Op1DL,Op1DU); #endif } void DSPOp2D() { double a,b,c,d,e,f,g,h,i,det,temp; double a2,b2,c2,d2,e2,f2,g2,h2,i2,x,y,z; a = matrixA3[0][0]; b=matrixA3[0][1]; c=matrixA3[0][2]; d = matrixA3[1][0]; e=matrixA3[1][1]; f=matrixA3[1][2]; g = matrixA3[2][0]; h=matrixA3[2][1]; i=matrixA3[2][2]; //abc //def //ghi det = a*e*i+b*f*g+c*d*h-g*e*c-h*f*a-i*d*b; if (det==0) { Op2DF=0; Op2DL=0; Op2DU=0; return; } swap(d,b); swap(g,c); swap(h,f); b=-b; d=-d; f=-f; h=-h; a2=(e*i-h*f)/det; b2=(d*i-g*f)/det; c2=(d*h-g*e)/det; d2=(b*i-h*c)/det; e2=(a*i-g*c)/det; f2=(a*h-g*b)/det; g2=(b*f-e*c)/det; h2=(a*f-d*c)/det; i2=(a*e-d*b)/det; x=Op2DX; y=Op2DY; z=Op2DZ; Op2DF=(short)((x*a2+y*d2+z*g2)/2*sc3); Op2DL=(short)((x*b2+y*e2+z*h2)/2*sc3); Op2DU=(short)((x*c2+y*f2+z*i2)/2*sc3); #ifdef DebugDSP1 Log_Message("OP2D X: %d Y: %d Z: %d / F: %d L: %d U: %d",Op2DX,Op2DY,Op2DZ,Op2DF,Op2DL,Op2DU); #endif } short Op03F; short Op03L; short Op03U; short Op03X; short Op03Y; short Op03Z; short Op13F; short Op13L; short Op13U; short Op13X; short Op13Y; short Op13Z; short Op23F; short Op23L; short Op23U; short Op23X; short Op23Y; short Op23Z; void DSPOp03() { double F,L,U; F=Op03F; L=Op03L; U=Op03U; Op03X=(short)((F*matrixA[0][0]+L*matrixA[1][0]+U*matrixA[2][0])/2*sc); Op03Y=(short)((F*matrixA[0][1]+L*matrixA[1][1]+U*matrixA[2][1])/2*sc); Op03Z=(short)((F*matrixA[0][2]+L*matrixA[1][2]+U*matrixA[2][2])/2*sc); #ifdef DebugDSP1 Log_Message("OP03 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op03F,Op03L,Op03U,Op03X,Op03Y,Op03Z); #endif } void DSPOp13() { double F,L,U; F=Op13F; L=Op13L; U=Op13U; Op13X=(short)((F*matrixA2[0][0]+L*matrixA2[1][0]+U*matrixA2[2][0])/2*sc2); Op13Y=(short)((F*matrixA2[0][1]+L*matrixA2[1][1]+U*matrixA2[2][1])/2*sc2); Op13Z=(short)((F*matrixA2[0][2]+L*matrixA2[1][2]+U*matrixA2[2][2])/2*sc2); #ifdef DebugDSP1 Log_Message("OP13 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op13F,Op13L,Op13U,Op13X,Op13Y,Op13Z); #endif } void DSPOp23() { double F,L,U; F=Op23F; L=Op23L; U=Op23U; Op23X=(short)((F*matrixA3[0][0]+L*matrixA3[1][0]+U*matrixA3[2][0])/2*sc3); Op23Y=(short)((F*matrixA3[0][1]+L*matrixA3[1][1]+U*matrixA3[2][1])/2*sc3); Op23Z=(short)((F*matrixA3[0][2]+L*matrixA3[1][2]+U*matrixA3[2][2])/2*sc3); #ifdef DebugDSP1 Log_Message("OP23 F: %d L: %d U: %d / X: %d Y: %d Z: %d",Op23F,Op23L,Op23U,Op23X,Op23Y,Op23Z); #endif } short Op14Zr; short Op14Xr; short Op14Yr; short Op14U; short Op14F; short Op14L; short Op14Zrr; short Op14Xrr; short Op14Yrr; double Op14Temp; void DSPOp14() { Op14Temp=(Op14Zr*6.2832/65536.0)+(1/cos(Op14Xr*6.2832/65536.0))*((Op14U*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0)-(Op14F*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0)); Op14Zrr=(short)(Op14Temp*65536.0/6.2832); Op14Temp=(Op14Xr*6.2832/65536.0)+((Op14U*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0)+(Op14F*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0)); Op14Xrr=(short)(Op14Temp*65536.0/6.2832); Op14Temp=(Op14Yr*6.2832/65536.0)-tan(Op14Xr*6.2832/65536.0)*((Op14U*6.2832/65536.0)*cos(Op14Yr*6.2832/65536.0)+(Op14F*6.2832/65536.0)*sin(Op14Yr*6.2832/65536.0))+(Op14L*6.2832/65536.0); Op14Yrr=(short)(Op14Temp*65536.0/6.2832); #ifdef DebugDSP1 Log_Message("OP14 X:%d Y%d Z:%D U:%d F:%d L:%d",Op14Xr,Op14Yr,Op14Zr,Op14U,Op14F,Op14L); Log_Message("OP14 X:%d Y%d Z:%D",Op14Xrr,Op14Yrr,Op14Zrr); #endif } short Op0EH; short Op0EV; short Op0EX; short Op0EY; void DSPOp0E() { // screen Directions UP RVPos = Op0EV; RHPos = Op0EH; GetRXYPos(); Op0EX = RXRes; Op0EY = RYRes; #ifdef DebugDSP1 Log_Message("OP0E COORDINATE H:%d V:%d X:%d Y:%d",Op0EH,Op0EV,Op0EX,Op0EY); #endif } short Op0BX; short Op0BY; short Op0BZ; short Op0BS; short Op1BX; short Op1BY; short Op1BZ; short Op1BS; short Op2BX; short Op2BY; short Op2BZ; short Op2BS; void DSPOp0B() { Op0BS = (Op0BX*matrixA[0][0]+Op0BY*matrixA2[0][1]+Op0BZ*matrixA2[0][2]); #ifdef DebugDSP1 Log_Message("OP0B"); #endif } void DSPOp1B() { Op1BS = (Op1BX*matrixA2[0][0]+Op1BY*matrixA2[0][1]+Op1BZ*matrixA2[0][2]); #ifdef DebugDSP1 Log_Message("OP1B X: %d Y: %d Z: %d S: %d",Op1BX,Op1BY,Op1BZ,Op1BS); Log_Message(" MX: %d MY: %d MZ: %d Scale: %d",(short)(matrixA2[0][0]*100),(short)(matrixA2[0][1]*100),(short)(matrixA2[0][2]*100),(short)(sc2*100)); #endif } void DSPOp2B() { Op2BS = (Op2BX*matrixA3[0][0]+Op2BY*matrixA3[0][1]+Op2BZ*matrixA3[0][2]); #ifdef DebugDSP1 Log_Message("OP2B"); #endif } short Op08X,Op08Y,Op08Z,Op08Ll,Op08Lh; long Op08Size; void DSPOp08() { Op08Size=(Op08X*Op08X+Op08Y*Op08Y+Op08Z*Op08Z)*2; Op08Ll = Op08Size&0xFFFF; Op08Lh = (Op08Size>>16) & 0xFFFF; #ifdef DebugDSP1 Log_Message("OP08 %d,%d,%d",Op08X,Op08Y,Op08Z); Log_Message("OP08 ((Op08X^2)+(Op08Y^2)+(Op08X^2))=%x",Op08Size ); #endif } short Op18X,Op18Y,Op18Z,Op18R,Op18D; void DSPOp18() { double x,y,z,r; x=Op18X; y=Op18Y; z=Op18Z; r=Op18R; r = (x*x+y*y+z*z-r*r); if (r>32767) r=32767; if (r<-32768) r=-32768; Op18D=(short)r; #ifdef DebugDSP1 Log_Message("OP18 X: %d Y: %d Z: %d R: %D DIFF %d",Op18X,Op18Y,Op18Z,Op18D); #endif } short Op28X; short Op28Y; short Op28Z; short Op28R; void DSPOp28() { Op28R=(short)sqrt(Op28X*Op28X+Op28Y*Op28Y+Op28Z*Op28Z); #ifdef DebugDSP1 Log_Message("OP28 X:%d Y:%d Z:%d",Op28X,Op28Y,Op28Z); Log_Message("OP28 Vector Length %d",Op28R); #endif } short Op1CAZ; unsigned short Op1CX,Op1CY,Op1CZ; short Op1CXBR,Op1CYBR,Op1CZBR,Op1CXAR,Op1CYAR,Op1CZAR; short Op1CX1; short Op1CY1; short Op1CZ1; short Op1CX2; short Op1CY2; short Op1CZ2; #ifdef __OPT1C__ void DSPOp1C() { short ya,xa,za; ya = Angle(Op1CX); xa = Angle(Op1CY); za = Angle(Op1CZ); // rotate around Z Op1CX1=(Op1CXBR*Cos(za)+Op1CYBR*Sin(za)); Op1CY1=(Op1CXBR*-Sin(za)+Op1CYBR*Cos(za)); Op1CZ1=Op1CZBR; // rotate around Y Op1CX2=(Op1CX1*Cos(ya)+Op1CZ1*-Sin(ya)); Op1CY2=Op1CY1; Op1CZ2=(Op1CX1*Sin(ya)+Op1CZ1*Cos(ya)); // rotate around X Op1CXAR=Op1CX2; Op1CYAR=(Op1CY2*Cos(xa)+Op1CZ2*Sin(xa)); Op1CZAR=(Op1CY2*-Sin(xa)+Op1CZ2*Cos(xa)); #ifdef DebugDSP1 Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CXAR,Op1CYAR,Op1CZAR); #endif } #else void DSPOp1C() { double ya,xa,za; ya = Op1CX/65536.0*PI*2; xa = Op1CY/65536.0*PI*2; za = Op1CZ/65536.0*PI*2; // rotate around Z Op1CX1=(Op1CXBR*cos(za)+Op1CYBR*sin(za)); Op1CY1=(Op1CXBR*-sin(za)+Op1CYBR*cos(za)); Op1CZ1=Op1CZBR; // rotate around Y Op1CX2=(Op1CX1*cos(ya)+Op1CZ1*-sin(ya)); Op1CY2=Op1CY1; Op1CZ2=(Op1CX1*sin(ya)+Op1CZ1*cos(ya)); // rotate around X Op1CXAR=Op1CX2; Op1CYAR=(Op1CY2*cos(xa)+Op1CZ2*sin(xa)); Op1CZAR=(Op1CY2*-sin(xa)+Op1CZ2*cos(xa)); #ifdef DebugDSP1 Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CXAR,Op1CYAR,Op1CZAR); #endif } #endif zsnes-1.36/src/chips/dsp1proc.asm0100644000175000017500000004626707300560226016335 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM regaccessbankr8,regaccessbankr16,regaccessbankw8,regaccessbankw16 EXTSYM DSPOp0A,Op0AA,Op0AB,Op0AC,Op0AD,Op0AVS,DSPOp10 EXTSYM debstop EXTSYM DSPOp00,Op00Multiplicand,Op00Multiplier EXTSYM Op00Result ;EXTSYM DSPOp10,Op10a,Op10b,Op10A,Op10B EXTSYM DSPOp04,Op04Angle,Op04Cos,Op04Radius,Op04Sin EXTSYM DSPOp28,Op28R,Op28X,Op28Y,Op28Z EXTSYM DSPOp0C,Op0CA,Op0CX1,Op0CX2,Op0CY1,Op0CY2 EXTSYM DSPOp02,Op02AAS,Op02AZS,Op02CX,Op02CY,Op02FX,Op02FY EXTSYM Op02FZ,Op02LES,Op02LFE,Op02VOF,Op02VVA EXTSYM DSPOp06,Op06X,Op06Y,Op06Z,Op06H,Op06V,Op06S EXTSYM DSPOp0E,Op0EH,Op0EV,Op0EX,Op0EY EXTSYM Op01m, Op01Zr, Op01Xr, Op01Yr, DSPOp01 EXTSYM Op11m, Op11Zr, Op11Xr, Op11Yr, DSPOp11 EXTSYM Op21m, Op21Zr, Op21Xr, Op21Yr, DSPOp21 EXTSYM Op0DX, Op0DY, Op0DZ, Op0DF, Op0DL, Op0DU, DSPOp0D EXTSYM Op1DX, Op1DY, Op1DZ, Op1DF, Op1DL, Op1DU, DSPOp1D EXTSYM Op2DX, Op2DY, Op2DZ, Op2DF, Op2DL, Op2DU, DSPOp2D EXTSYM Op03X, Op03Y, Op03Z, Op03F, Op03L, Op03U, DSPOp03 EXTSYM Op13X, Op13Y, Op13Z, Op13F, Op13L, Op13U, DSPOp13 EXTSYM Op23X, Op23Y, Op23Z, Op23F, Op23L, Op23U, DSPOp23 EXTSYM Op14Zr, Op14Xr, Op14Yr, Op14U, Op14F, Op14L EXTSYM Op14Zrr,Op14Xrr,Op14Yrr, DSPOp14 EXTSYM Op0BX,Op0BY,Op0BZ,Op0BS,DSPOp0B EXTSYM Op1BX,Op1BY,Op1BZ,Op1BS,DSPOp1B EXTSYM Op2BX,Op2BY,Op2BZ,Op2BS,DSPOp2B EXTSYM Op08X,Op08Y,Op08Z,Op08Ll,Op08Lh,DSPOp08 EXTSYM Op18X,Op18Y,Op18Z,Op18R,Op18D,DSPOp18 EXTSYM Op1CX,Op1CY,Op1CZ,Op1CXBR,Op1CYBR,Op1CZBR,Op1CXAR,Op1CYAR,Op1CZAR,DSPOp1C NEWSYM Dsp1ProcAsmStart NEWSYM dsp1ptr, dd 0 NEWSYM dsp1array, times 4096 db 0 ;******************************************************* ; DSP1 Read Functions ;******************************************************* NEWSYM DSP1Read8b3F test ecx,8000h jnz .dsp1area jmp regaccessbankr8 .dsp1area cmp ecx,0C000h jae .doC000 mov al,080h ret .doC000 mov al,80h ret NEWSYM DSP1Read16b3F test ecx,8000h jnz .dsp1area jmp regaccessbankr16 .dsp1area cmp ecx,0C000h jae .doC000 cmp byte[DSP1RLeft],0 jne .movestuff mov ax,0FFFFh ret .doC000 mov ax,08000h cmp byte[DSP1WLeft],0 je .notwleft mov ax,0C000h .notwleft ret .movestuff push ebx xor ebx,ebx mov bl,[DSP1CPtrR] mov ax,[DSP1RET+ebx*2] pop ebx inc byte[DSP1CPtrR] dec byte[DSP1RLeft] jz .nomore .goback ret .nomore cmp byte[DSP1COp],0Ah jne .goback push eax pushad call DSPOp0A popad mov ax,[Op0AA] mov [DSP1RET],ax mov ax,[Op0AB] mov [DSP1RET+2],ax mov ax,[Op0AC] mov [DSP1RET+4],ax mov ax,[Op0AD] mov [DSP1RET+6],ax mov byte[DSP1RLeft],4 mov byte[DSP1CPtrR],0 pop eax ret NEWSYM DSP1Read8b ; mov byte[debstop],1 cmp ecx,7000h jae .do7000 xor al,al ret .do7000 mov al,80h test ecx,1 jz .no1 mov al,80h .no1 ret NEWSYM DSP1Read16b ; mov byte[debstop],1 cmp ecx,7000h jae .do7000 cmp byte[DSP1RLeft],0 jne .movestuff mov ax,0FFFFh ret .do7000 mov ax,8000h cmp byte[DSP1WLeft],0 je .notwleft mov ax,0C000h .notwleft ; test ecx,01h ; jz .norev ; mov ax,0080h ;.norev ret .movestuff push ebx xor ebx,ebx mov bl,[DSP1CPtrR] mov ax,[DSP1RET+ebx*2] pop ebx inc byte[DSP1CPtrR] dec byte[DSP1RLeft] jz .nomore .goback ret .nomore cmp byte[DSP1COp],0Ah jne .goback push eax pushad call DSPOp0A popad mov ax,[Op0AA] mov [DSP1RET],ax mov ax,[Op0AB] mov [DSP1RET+2],ax mov ax,[Op0AC] mov [DSP1RET+4],ax mov ax,[Op0AD] mov [DSP1RET+6],ax mov byte[DSP1RLeft],4 mov byte[DSP1CPtrR],0 pop eax ret %macro DSP1WriteInit 2 cmp al,%1 jne %%no mov byte[DSP1WLeft],%2 %%no %endmacro NEWSYM DSP1Write8b3F test ecx,8000h jnz .dsp1area jmp regaccessbankw8 .dsp1area call DSP1Write8b ret NEWSYM DSP1Write16b3F test ecx,8000h jnz .dsp1area jmp regaccessbankw16 .dsp1area call DSP1Write16b ret NEWSYM DSP1Write8b push ebx xor ebx,ebx mov bl,al mov byte[DSPFuncUsed+ebx],1 pop ebx mov byte[DSP1COp],al mov byte[DSP1CPtrW],0 DSP1WriteInit 00h, 2 ; 16-bit multiply DSP1WriteInit 10h, 2 ; Inverse DSP1WriteInit 04h, 2 ; Trigonometric DSP1WriteInit 08h, 3 ; Vector Size DSP1WriteInit 18h, 4 ; Vector Size Comparison DSP1WriteInit 28h, 3 ; Vector Absolute Value DSP1WriteInit 0Ch, 3 ; Coordinate Rotation DSP1WriteInit 1Ch, 6 ; 3D Coordinate Rotation DSP1WriteInit 02h, 7 ; Vector Size DSP1WriteInit 0Ah, 1 ; Raster Data Calculation via DMA DSP1WriteInit 1Ah, 1 ; Raster Data Calculation w/o DMA DSP1WriteInit 06h, 3 ; Object Projection Calculation DSP1WriteInit 0Eh, 2 ; Coordinate Calculation of a point onscreen DSP1WriteInit 01h, 4 ; Set Attitude Matrix A DSP1WriteInit 11h, 4 ; Set Attitude Matrix B DSP1WriteInit 21h, 4 ; Set Attitude Matrix C DSP1WriteInit 0Dh, 3 ; Convert from global to object coords Matrix A DSP1WriteInit 1Dh, 3 ; Convert from global to object coords Matrix B DSP1WriteInit 2Dh, 3 ; Convert from global to object coords Matrix C DSP1WriteInit 03h, 3 ; Convert from object to global coords Matrix A DSP1WriteInit 13h, 3 ; Convert from object to global coords Matrix B DSP1WriteInit 23h, 3 ; Convert from object to global coords Matrix C DSP1WriteInit 0Bh, 3 ; Calculation of inner product Matrix A DSP1WriteInit 1Bh, 3 ; Calculation of inner product Matrix B DSP1WriteInit 2Bh, 3 ; Calculation of inner product Matrix C DSP1WriteInit 14h, 6 ; 3D angle rotation ret %macro DSP1WriteProc 2 cmp byte[DSP1COp],%1 jne %%no pushad call %2 popad %%no %endmacro NEWSYM DSP1Write16b ; mov byte[debstop],1 cmp byte[DSP1WLeft],0 jne .yesleft ret .yesleft push ebx xor ebx,ebx mov bl,[DSP1CPtrW] mov [DSP1VARS+ebx*2],ax pop ebx inc byte[DSP1CPtrW] dec byte[DSP1WLeft] jz .ProcessDSP1 ret .ProcessDSP1 mov byte[DSP1CPtrR],0 mov byte[DSP1RLeft],0 DSP1WriteProc 00h, DSP1_00 ; 16-bit multiply DSP1WriteProc 10h, DSP1_10 ; Inverse DSP1WriteProc 04h, DSP1_04 ; Trigonometric DSP1WriteProc 08h, DSP1_08 ; Vector Size DSP1WriteProc 18h, DSP1_18 ; Vector Size Comparison DSP1WriteProc 28h, DSP1_28 ; Vector Absolute Value DSP1WriteProc 0Ch, DSP1_0C ; Coordinate Rotation DSP1WriteProc 1Ch, DSP1_1C ; 3D Coordinate Rotation DSP1WriteProc 02h, DSP1_02 ; Vector Size DSP1WriteProc 0Ah, DSP1_0A ; Raster Data Calculation via DMA DSP1WriteProc 1Ah, DSP1_0A ; Raster Data Calculation w/o DMA DSP1WriteProc 06h, DSP1_06 ; Object Projection Calculation DSP1WriteProc 0Eh, DSP1_0E ; Coordinate Calculation of a point onscreen DSP1WriteProc 01h, DSP1_01 ; Set Attitude Matrix A DSP1WriteProc 11h, DSP1_11 ; Set Attitude Matrix B DSP1WriteProc 21h, DSP1_21 ; Set Attitude Matrix C DSP1WriteProc 0Dh, DSP1_0D ; Convert from global to object coords Matrix A DSP1WriteProc 1Dh, DSP1_1D ; Convert from global to object coords Matrix B DSP1WriteProc 2Dh, DSP1_2D ; Convert from global to object coords Matrix C DSP1WriteProc 03h, DSP1_03 ; Convert from object to global coords Matrix A DSP1WriteProc 13h, DSP1_13 ; Convert from object to global coords Matrix B DSP1WriteProc 23h, DSP1_23 ; Convert from object to global coords Matrix C DSP1WriteProc 0Bh, DSP1_0B ; Calculation of inner product Matrix A DSP1WriteProc 1Bh, DSP1_1B ; Calculation of inner product Matrix B DSP1WriteProc 2Bh, DSP1_2B ; Calculation of inner product Matrix C DSP1WriteProc 14h, DSP1_14 ; 3D angle rotation ret NEWSYM DSP1COp, db 0 NEWSYM DSP1RLeft, db 0 NEWSYM DSP1WLeft, db 0 NEWSYM DSP1CPtrW, db 0 NEWSYM DSP1CPtrR, db 0 NEWSYM DSP1VARS, times 16 dw 0 NEWSYM DSP1RET, times 16 dw 0 NEWSYM DSPDet, db 0 NEWSYM DSPFuncUsed, times 256 db 0 ;******************************************************* ; DSP1 Conversion Functions ;******************************************************* DSP1_00: ; 16-bit multiply or byte[DSPDet],01h push eax mov ax,[DSP1VARS] mov [Op00Multiplicand],ax mov ax,[DSP1VARS+2] mov [Op00Multiplier],ax pushad call DSPOp00 popad mov ax,[Op00Result] mov [DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret EXTSYM Op10Exponent, Op10ExponentR EXTSYM Op10Coefficient, Op10CoefficientR DSP1_10: ; Inverse push eax mov ax,[DSP1VARS] mov [Op10Coefficient],ax mov ax,[DSP1VARS+2] mov [Op10Exponent],ax pushad call DSPOp10 popad mov ax,[Op10CoefficientR] mov [DSP1RET],ax mov ax,[Op10ExponentR] mov [DSP1RET+2],ax mov byte[DSP1RLeft],2 pop eax ret DSP1_04: ; Trigonometric or byte[DSPDet],02h push eax mov ax,[DSP1VARS] mov [Op04Angle],ax mov ax,[DSP1VARS+2] mov [Op04Radius],ax pushad call DSPOp04 popad mov ax,[Op04Sin] mov [DSP1RET],ax mov ax,[Op04Cos] mov [DSP1RET+2],ax mov byte[DSP1RLeft],2 pop eax ret DSP1_08: ; Vector Size push eax mov ax,[DSP1VARS] mov [Op08X],ax mov ax,[DSP1VARS+2] mov [Op08Y],ax mov ax,[DSP1VARS+4] mov [Op08Z],ax pushad call DSPOp08 popad mov ax,[Op08Ll] mov [DSP1RET],ax mov ax,[Op08Lh] mov [DSP1RET+2],ax mov byte[DSP1RLeft],2 pop eax ret DSP1_18: ; Vector Size Comparison push eax mov ax,[DSP1VARS] mov [Op18X],ax mov ax,[DSP1VARS+2] mov [Op18Y],ax mov ax,[DSP1VARS+4] mov [Op18Z],ax mov ax,[DSP1VARS+6] mov [Op18R],ax pushad call DSPOp18 popad mov ax,[Op18D] mov [DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret DSP1_28: ; Vector Absolute Value or byte[DSPDet],04h push eax mov ax,[DSP1VARS] mov [Op28X],ax mov ax,[DSP1VARS+2] mov [Op28Y],ax mov ax,[DSP1VARS+4] mov [Op28Z],ax pushad call DSPOp28 popad mov ax,[Op28R] mov [DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret DSP1_0C: ; Coordinate Rotation or byte[DSPDet],08h push eax mov ax,[DSP1VARS] mov [Op0CA],ax mov ax,[DSP1VARS+2] mov [Op0CX1],ax mov ax,[DSP1VARS+4] mov [Op0CY1],ax pushad call DSPOp0C popad mov ax,[Op0CX2] mov [DSP1RET],ax mov ax,[Op0CY2] mov [DSP1RET+2],ax mov byte[DSP1RLeft],2 pop eax ret DSP1_1C: ; 3D Coordinate Rotation push eax mov ax,[DSP1VARS] mov [Op1CZ],ax mov ax,[DSP1VARS+2] mov [Op1CX],ax mov ax,[DSP1VARS+4] mov [Op1CY],ax mov ax,[DSP1VARS+6] mov [Op1CXBR],ax mov ax,[DSP1VARS+8] mov [Op1CYBR],ax mov ax,[DSP1VARS+10] mov [Op1CZBR],ax pushad call DSPOp1C popad mov ax,[Op1CXAR] mov [DSP1RET],ax mov ax,[Op1CYAR] mov [DSP1RET+2],ax mov ax,[Op1CZAR] mov [DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_02: ; Vector Size or byte[DSPDet],10h push eax ;Op02FX dw 0 ;Op02FY dw 0 ;Op02FZ dw 0 ;Op02LFE dw 0 ;Op02LES dw 0 ;Op02AAS dw 0 ;Op02AZS dw 0 mov ax,[DSP1VARS] mov [Op02FX],ax mov ax,[DSP1VARS+2] mov [Op02FY],ax mov ax,[DSP1VARS+4] mov [Op02FZ],ax mov ax,[DSP1VARS+6] mov [Op02LFE],ax mov ax,[DSP1VARS+8] mov [Op02LES],ax mov ax,[DSP1VARS+10] mov [Op02AAS],ax mov ax,[DSP1VARS+12] mov [Op02AZS],ax pushad call DSPOp02 popad ;Op02VOF dw 0 ;Op02VVA dw 0 ;Op02CX dw 0 ;Op02CY dw 0 mov ax,[Op02VOF] mov [DSP1RET],ax mov ax,[Op02VVA] mov [DSP1RET+2],ax mov ax,[Op02CX] mov [DSP1RET+4],ax mov ax,[Op02CY] mov [DSP1RET+6],ax mov byte[DSP1RLeft],4 pop eax ret mov eax,dsp1array add eax,[dsp1ptr] push ebx mov byte[eax],02h mov bx,[Op02FX] mov [eax+1],bx mov bx,[Op02FY] mov [eax+3],bx mov bx,[Op02FZ] mov [eax+5],bx mov bx,[Op02LFE] mov [eax+7],bx mov bx,[Op02LES] mov [eax+9],bx mov bx,[Op02AAS] mov [eax+11],bx mov bx,[Op02AZS] mov [eax+13],bx mov bx,[Op02VOF] mov [eax+15],bx mov bx,[Op02VVA] mov [eax+17],bx mov bx,[Op02CX] mov [eax+19],bx mov bx,[Op02CY] mov [eax+21],bx pop ebx add dword[dsp1ptr],23 DSP1_0A: ; Raster Data Calculation via DMA mov byte[DSP1COp],0Ah or byte[DSPDet],20h push eax mov ax,[DSP1VARS] mov [Op0AVS],ax pushad call DSPOp0A popad mov ax,[Op0AA] mov [DSP1RET],ax mov ax,[Op0AB] mov [DSP1RET+2],ax mov ax,[Op0AC] mov [DSP1RET+4],ax mov ax,[Op0AD] mov [DSP1RET+6],ax mov byte[DSP1RLeft],4 pop eax ret DSP1_06: ; Object Projection Calculation or byte[DSPDet],40h push eax mov ax,[DSP1VARS] mov [Op06X],ax mov ax,[DSP1VARS+2] mov [Op06Y],ax mov ax,[DSP1VARS+4] mov [Op06Z],ax pushad call DSPOp06 popad mov ax,[Op06H] mov word[DSP1RET],ax mov ax,[Op06V] mov word[DSP1RET+2],ax mov ax,[Op06S] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret mov eax,dsp1array add eax,[dsp1ptr] push ebx mov byte[eax],06h mov bx,[Op06X] mov [eax+1],bx mov bx,[Op06Y] mov [eax+3],bx mov bx,[Op06Z] mov [eax+5],bx mov bx,[Op06H] mov [eax+7],bx mov bx,[Op06V] mov [eax+9],bx mov bx,[Op06S] mov [eax+11],bx pop ebx add dword[dsp1ptr],13 DSP1_0E: ; Coordinate Calculation of a point onscreen push eax mov ax,[DSP1VARS] mov [Op0EH],ax mov ax,[DSP1VARS+2] mov [Op0EV],ax pushad call DSPOp0E popad mov ax,[Op0EX] mov word[DSP1RET],ax mov ax,[Op0EY] mov word[DSP1RET+2],ax mov byte[DSP1RLeft],2 pop eax ret DSP1_01: ; Set Attitude Matrix A push eax mov ax,[DSP1VARS] mov [Op01m],ax mov ax,[DSP1VARS+2] mov [Op01Zr],ax mov ax,[DSP1VARS+4] mov [Op01Xr],ax mov ax,[DSP1VARS+6] mov [Op01Yr],ax pushad call DSPOp01 popad pop eax ret DSP1_11: ; Set Attitude Matrix B push eax mov ax,[DSP1VARS] mov [Op11m],ax mov ax,[DSP1VARS+2] mov [Op11Zr],ax mov ax,[DSP1VARS+4] mov [Op11Xr],ax mov ax,[DSP1VARS+6] mov [Op11Yr],ax pushad call DSPOp11 popad pop eax ret DSP1_21: ; Set Attitude Matrix C push eax mov ax,[DSP1VARS] mov [Op21m],ax mov ax,[DSP1VARS+2] mov [Op21Zr],ax mov ax,[DSP1VARS+4] mov [Op21Xr],ax mov ax,[DSP1VARS+6] mov [Op21Yr],ax pushad call DSPOp21 popad pop eax ret DSP1_0D: ; Convert from global to object coords Matrix A push eax mov ax,[DSP1VARS] mov [Op0DX],ax mov ax,[DSP1VARS+2] mov [Op0DY],ax mov ax,[DSP1VARS+4] mov [Op0DZ],ax pushad call DSPOp0D popad mov ax,[Op0DF] mov word[DSP1RET],ax mov ax,[Op0DL] mov word[DSP1RET+2],ax mov ax,[Op0DU] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_1D: ; Convert from global to object coords Matrix B push eax mov ax,[DSP1VARS] mov [Op1DX],ax mov ax,[DSP1VARS+2] mov [Op1DY],ax mov ax,[DSP1VARS+4] mov [Op1DZ],ax pushad call DSPOp1D popad mov ax,[Op1DF] mov word[DSP1RET],ax mov ax,[Op1DL] mov word[DSP1RET+2],ax mov ax,[Op1DU] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_2D: ; Convert from global to object coords Matrix C push eax mov ax,[DSP1VARS] mov [Op2DX],ax mov ax,[DSP1VARS+2] mov [Op2DY],ax mov ax,[DSP1VARS+4] mov [Op2DZ],ax pushad call DSPOp2D popad mov ax,[Op2DF] mov word[DSP1RET],ax mov ax,[Op2DL] mov word[DSP1RET+2],ax mov ax,[Op2DU] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_03: ; Convert from object to global coords Matrix A push eax mov ax,[DSP1VARS] mov [Op03F],ax mov ax,[DSP1VARS+2] mov [Op03L],ax mov ax,[DSP1VARS+4] mov [Op03U],ax pushad call DSPOp03 popad mov ax,[Op03X] mov word[DSP1RET],ax mov ax,[Op03Y] mov word[DSP1RET+2],ax mov ax,[Op03Z] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_13: ; Convert from object to global coords Matrix B push eax mov ax,[DSP1VARS] mov [Op13F],ax mov ax,[DSP1VARS+2] mov [Op13L],ax mov ax,[DSP1VARS+4] mov [Op13U],ax pushad call DSPOp13 popad mov ax,[Op13X] mov word[DSP1RET],ax mov ax,[Op13Y] mov word[DSP1RET+2],ax mov ax,[Op13Z] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_23: ; Convert from object to global coords Matrix C push eax mov ax,[DSP1VARS] mov [Op23F],ax mov ax,[DSP1VARS+2] mov [Op23L],ax mov ax,[DSP1VARS+4] mov [Op23U],ax pushad call DSPOp23 popad mov ax,[Op23X] mov word[DSP1RET],ax mov ax,[Op23Y] mov word[DSP1RET+2],ax mov ax,[Op23Z] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret DSP1_0B: ; Calculation of inner product Matrix A push eax mov ax,[DSP1VARS] mov [Op0BX],ax mov ax,[DSP1VARS+2] mov [Op0BY],ax mov ax,[DSP1VARS+4] mov [Op0BZ],ax pushad call DSPOp0B popad mov ax,[Op0BS] mov word[DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret DSP1_1B: ; Calculation of inner product Matrix B push eax mov ax,[DSP1VARS] mov [Op1BX],ax mov ax,[DSP1VARS+2] mov [Op1BY],ax mov ax,[DSP1VARS+4] mov [Op1BZ],ax pushad call DSPOp1B popad mov ax,[Op1BS] mov word[DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret DSP1_2B: ; Calculation of inner product Matrix C push eax mov ax,[DSP1VARS] mov [Op2BX],ax mov ax,[DSP1VARS+2] mov [Op2BY],ax mov ax,[DSP1VARS+4] mov [Op2BZ],ax pushad call DSPOp2B popad mov ax,[Op2BS] mov word[DSP1RET],ax mov byte[DSP1RLeft],1 pop eax ret DSP1_14: ; 3D angle rotation push eax mov ax,[DSP1VARS] mov [Op14Zr],ax mov ax,[DSP1VARS+2] mov [Op14Xr],ax mov ax,[DSP1VARS+4] mov [Op14Yr],ax mov ax,[DSP1VARS+6] mov [Op14U],ax mov ax,[DSP1VARS+8] mov [Op14F],ax mov ax,[DSP1VARS+10] mov [Op14L],ax pushad call DSPOp14 popad mov ax,[Op14Zrr] mov word[DSP1RET],ax mov ax,[Op14Xrr] mov word[DSP1RET+2],ax mov ax,[Op14Yrr] mov word[DSP1RET+4],ax mov byte[DSP1RLeft],3 pop eax ret NEWSYM Dsp1ProcAsmEnd zsnes-1.36/src/chips/fxemu2.asm0100644000175000017500000021616007267141100015775 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM FxTable,FxTableb,FxTablec,FxTabled,SfxMemTable,flagnz,fxbit01,fxbit23 EXTSYM fxxand,sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc EXTSYM sfxramdata,fxbit45,fxbit67,SFXProc,ChangeOps EXTSYM PLOTJmpa,PLOTJmpb NEWSYM FxEmu2AsmStart %include "chips/fxemu2.mac" ; * Optimise PLOT, COLOR! SECTION .text NEWSYM FlushCache ; Copy 512 bytes from pb:eax to SfxCACHERAM ret SECTION .data NEWSYM tempsfx, db 0,0,0 ALIGN32 ; FxChip emulation by _Demo_ ; Optimised by zsKnight ; based on fxemu by lestat NEWSYM SfxR0, dd 0 ; default source/destination register NEWSYM SfxR1, dd 0 ; pixel plot X position register NEWSYM SfxR2, dd 0 ; pixel plot Y position register NEWSYM SfxR3, dd 0 ; NEWSYM SfxR4, dd 0 ; lower 16 bit result of lmult NEWSYM SfxR5, dd 0 ; NEWSYM SfxR6, dd 0 ; multiplier for fmult and lmult NEWSYM SfxR7, dd 0 ; fixed point texel X position for merge NEWSYM SfxR8, dd 0 ; fixed point texel Y position for merge NEWSYM SfxR9, dd 0 ; NEWSYM SfxR10, dd 0 ; NEWSYM SfxR11, dd 0 ; return address set by link NEWSYM SfxR12, dd 0 ; loop counter NEWSYM SfxR13, dd 0 ; loop point address NEWSYM SfxR14, dd 0 ; rom address for getb, getbh, getbl, getbs NEWSYM SfxR15, dd 0 ; program counter NEWSYM SfxSFR, dd 0 ; status flag register (16bit) ;SFR status flag register bits: ; 0 - ; 1 Z Zero flag ; 2 CY Carry flag ; 3 S Sign flag ; 4 OV Overflow flag ; 5 G Go flag (set to 1 when the GSU is running) ; 6 R Set to 1 when reading ROM using R14 address ; 7 - ; 8 ALT1 Mode set-up flag for the next instruction ; 9 ALT2 Mode set-up flag for the next instruction ;10 IL Immediate lower 8-bit flag ;11 IH Immediate higher 8-bit flag ;12 B Set to 1 when the WITH instruction is executed ;13 - ;14 - ;15 IRQ Set to 1 when GSU caused an interrupt ; Set to 0 when read by 658c16 NEWSYM SfxBRAMR, dd 0 ; backup ram read only on/off (8bit) NEWSYM SfxPBR, dd 0 ; program bank register (8bit) NEWSYM SfxROMBR, dd 0 ; rom bank register (8bit) NEWSYM SfxCFGR, dd 0 ; control flags register (8bit) NEWSYM SfxSCBR, dd 0 ; screen bank register (8bit) NEWSYM SfxCLSR, dd 0 ; clock speed register (8bit) NEWSYM SfxSCMR, dd 0 ; screen mode register (8bit) NEWSYM SfxVCR, dd 0 ; version code register (8bit) NEWSYM SfxRAMBR, dd 0 ; ram bank register (8bit) NEWSYM SfxCBR, dd 0 ; cache base register (16bit) NEWSYM SfxCOLR, dd 0 ; Internal color register NEWSYM SfxPOR, dd 0 ; Plot option register NEWSYM SfxCacheFlags, dd 0 ; Saying what parts of the cache was written to NEWSYM SfxLastRamAdr, dd 0 ; Last RAM address accessed NEWSYM SfxDREG, dd 0 ; Current destination register index NEWSYM SfxSREG, dd 0 ; Current source register index NEWSYM SfxRomBuffer, dd 0 ; Current byte read by R14 NEWSYM SfxPIPE, dd 0 ; Instructionset pipe NEWSYM SfxPipeAdr, dd 0 ; The address of where the pipe was read from NEWSYM SfxnRamBanks, dd 4 ; Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) NEWSYM SfxnRomBanks, dd 0 ; Number of 32kb-banks in Cart-ROM NEWSYM SfxvScreenHeight, dd 0 ; 128, 160 or 192 NEWSYM SfxvScreenSize, dd 0 NEWSYM SfxCacheActive, dd 0 ; Cache Active NEWSYM SfxCarry, dd 0 ; Carry flag NEWSYM SfxSignZero, dd 0 ; Sign and Zero flag NEWSYM SfxB, dd 0 ; B flag (1 when with instruction executed) NEWSYM SfxOverflow, dd 0 ; Overflow flag NEWSYM SfxCACHERAM, times 512 db 0 ; 512 bytes of GSU cache memory SECTION .data num2writesfxreg equ $-SfxR0 ; pharos equ hack *sigh* NEWSYM PHnum2writesfxreg, dd num2writesfxreg NEWSYM SfxCPB, dd 0 NEWSYM SfxCROM, dd 0 NEWSYM SfxRAMMem, dd 0 NEWSYM withr15sk, dd 0 NEWSYM sfxclineloc, dd 0 NEWSYM SCBRrel, dd 0 NEWSYM fxbit01pcal, dd 0 NEWSYM fxbit23pcal, dd 0 NEWSYM fxbit45pcal, dd 0 NEWSYM fxbit67pcal, dd 0 ;SfxRAM times 256*1024 db 0 ; If we need this later... SECTION .text NEWSYM FxOp00 ; STOP stop GSU execution (and maybe generate an IRQ) ; Verified. FETCHPIPE mov [SfxPIPE],cl and dword [SfxSFR],0FFFFh-32 ; Clear Go flag (set to 1 when the GSU is running) test dword [SfxCFGR],080h ; Check if the interrupt generation is on jnz .NoIRQ or dword [SfxSFR],08000h ; Set IRQ Flag .NoIRQ CLRFLAGS inc ebp mov eax,[NumberOfOpcodes] add eax,0F0000000h add [ChangeOps],eax mov dword [NumberOfOpcodes],1 mov dword[SFXProc],0 xor cl,cl ret NEWSYM FxOp01 ; NOP no operation ; Verified. FETCHPIPE CLRFLAGS inc ebp ; Increase program counter ret NEWSYM FxOp02 ; CACHE reintialize GSU cache mov eax,ebp FETCHPIPE sub eax,[SfxCPB] and eax,0FFF0h cmp dword [SfxCBR],eax je .SkipUpdate cmp byte [SfxCacheActive],1 je .SkipUpdate mov dword [SfxCBR],eax mov dword [SfxCacheActive],1 call FlushCache .SkipUpdate CLRFLAGS inc ebp ; Increase program counter ret NEWSYM FxOp03 ; LSR logic shift right ; Verified. mov eax,[esi] ; Read Source FETCHPIPE mov [SfxCarry],al and byte[SfxCarry],1 shr ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp04 ; ROL rotate left (RCL?) ; V shr byte[SfxCarry],1 mov eax,[esi] ; Read Source FETCHPIPE rcl ax,1 rcl byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp05 ; BRA branch always ; Verified. movsx eax,byte[ebp] mov cl,[ebp+1] inc ebp add ebp,eax call [FxTable+ecx*4] ret NEWSYM FxOp06 ; BGE branch on greater or equals ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jnz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp07 ; BLT branch on lesss than ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp08 ; BNE branch on not equal ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp09 ; BEQ branch on equal (z=1) ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0A ; BPL branch on plus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0B ; BMI branch on minus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0C ; BCC branch on carry clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0D ; BCS branch on carry set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0E ; BVC branch on overflow clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp0F ; BVS branch on overflow set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] ret .nojump inc ebp call [FxTable+ecx*4] ret NEWSYM FxOp10 ; TO RN set register n as destination register TORN 0 NEWSYM FxOp11 ; TO RN set register n as destination register TORN 1 NEWSYM FxOp12 ; TO RN set register n as destination register TORN 2 NEWSYM FxOp13 ; TO RN set register n as destination register TORN 3 NEWSYM FxOp14 ; TO RN set register n as destination register TORN 4 NEWSYM FxOp15 ; TO RN set register n as destination register TORN 5 NEWSYM FxOp16 ; TO RN set register n as destination register TORN 6 NEWSYM FxOp17 ; TO RN set register n as destination register TORN 7 NEWSYM FxOp18 ; TO RN set register n as destination register TORN 8 NEWSYM FxOp19 ; TO RN set register n as destination register TORN 9 NEWSYM FxOp1A ; TO RN set register n as destination register TORN 10 NEWSYM FxOp1B ; TO RN set register n as destination register TORN 11 NEWSYM FxOp1C ; TO RN set register n as destination register TORN 12 NEWSYM FxOp1D ; TO RN set register n as destination register TORN 13 NEWSYM FxOp1E ; TO RN set register n as destination register FETCHPIPE mov edi,SfxR0+14*4 inc ebp call [FxTable+ecx*4] mov edi,SfxR0 UpdateR14 ret NEWSYM FxOp1F ; TO RN set register n as destination register FETCHPIPE mov edi,SfxR0+15*4 inc ebp call [FxTable+ecx*4] mov ebp,[SfxCPB] add ebp,[SfxR15] mov edi,SfxR0 ret NEWSYM FxOp20 ; WITH set register n as source and destination register WITH 0 NEWSYM FxOp21 ; WITH set register n as source and destination register WITH 1 NEWSYM FxOp22 ; WITH set register n as source and destination register WITH 2 NEWSYM FxOp23 ; WITH set register n as source and destination register WITH 3 NEWSYM FxOp24 ; WITH set register n as source and destination register WITH 4 NEWSYM FxOp25 ; WITH set register n as source and destination register WITH 5 NEWSYM FxOp26 ; WITH set register n as source and destination register WITH 6 NEWSYM FxOp27 ; WITH set register n as source and destination register WITH 7 NEWSYM FxOp28 ; WITH set register n as source and destination register WITH 8 NEWSYM FxOp29 ; WITH set register n as source and destination register WITH 9 NEWSYM FxOp2A ; WITH set register n as source and destination register WITH 10 NEWSYM FxOp2B ; WITH set register n as source and destination register WITH 11 NEWSYM FxOp2C ; WITH set register n as source and destination register WITH 12 NEWSYM FxOp2D ; WITH set register n as source and destination register WITH 13 NEWSYM FxOp2E ; WITH set register n as source and destination register FETCHPIPE mov esi,SfxR0+14*4 mov edi,SfxR0+14*4 mov dword [SfxB],1 inc ebp call [FxTablec+ecx*4] mov dword [SfxB],0 ; Clear B Flag mov esi,SfxR0 mov edi,SfxR0 UpdateR14 ret NEWSYM FxOp2F ; WITH set register n as source and destination register FETCHPIPE mov esi,SfxR0+15*4 mov edi,SfxR0+15*4 mov dword [SfxB],1 inc ebp mov eax,ebp sub eax,[SfxCPB] mov dword[withr15sk],0 mov [SfxR15],eax call [FxTableb+ecx*4] cmp dword[withr15sk],1 je .skip mov ebp,[SfxCPB] add ebp,[SfxR15] .skip mov dword [SfxB],0 ; Clear B Flag mov esi,SfxR0 mov edi,SfxR0 ret NEWSYM FxOp30 ; STW RN store word STWRN 0 NEWSYM FxOp31 ; STW RN store word STWRN 1 NEWSYM FxOp32 ; STW RN store word STWRN 2 NEWSYM FxOp33 ; STW RN store word STWRN 3 NEWSYM FxOp34 ; STW RN store word STWRN 4 NEWSYM FxOp35 ; STW RN store word STWRN 5 NEWSYM FxOp36 ; STW RN store word STWRN 6 NEWSYM FxOp37 ; STW RN store word STWRN 7 NEWSYM FxOp38 ; STW RN store word STWRN 8 NEWSYM FxOp39 ; STW RN store word STWRN 9 NEWSYM FxOp3A ; STW RN store word STWRN 10 NEWSYM FxOp3B ; STW RN store word STWRN 11 NEWSYM FxOp30A1 ; STB RN store byte STBRN 0 NEWSYM FxOp31A1 ; STB RN store byte STBRN 1 NEWSYM FxOp32A1 ; STB RN store byte STBRN 2 NEWSYM FxOp33A1 ; STB RN store byte STBRN 3 NEWSYM FxOp34A1 ; STB RN store byte STBRN 4 NEWSYM FxOp35A1 ; STB RN store byte STBRN 5 NEWSYM FxOp36A1 ; STB RN store byte STBRN 6 NEWSYM FxOp37A1 ; STB RN store byte STBRN 7 NEWSYM FxOp38A1 ; STB RN store byte STBRN 8 NEWSYM FxOp39A1 ; STB RN store byte STBRN 9 NEWSYM FxOp3AA1 ; STB RN store byte STBRN 10 NEWSYM FxOp3BA1 ; STB RN store byte STBRN 11 NEWSYM FxOp3C ; LOOP decrement loop counter, and branch on not zero ; V dec word [SfxR12] ; decrement loop counter FETCHPIPE mov eax,[SfxR12] mov [SfxSignZero],eax or eax,eax jz .NoBranch mov eax,dword [SfxR13] mov ebp,[SfxCPB] add ebp,eax CLRFLAGS ret .NoBranch inc ebp CLRFLAGS ret NEWSYM FxOp3D ; ALT1 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,01h inc ebp call [FxTable+ecx*4] xor ch,ch ret NEWSYM FxOp3E ; ALT2 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,02h inc ebp call [FxTable+ecx*4] xor ch,ch ret NEWSYM FxOp3F ; ALT3 set alt3 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,03h inc ebp call [FxTable+ecx*4] xor ch,ch ret NEWSYM FxOp40 ; LDW RN load word from RAM LDWRN 0 NEWSYM FxOp41 ; LDW RN load word from RAM LDWRN 1 NEWSYM FxOp42 ; LDW RN load word from RAM LDWRN 2 NEWSYM FxOp43 ; LDW RN load word from RAM LDWRN 3 NEWSYM FxOp44 ; LDW RN load word from RAM LDWRN 4 NEWSYM FxOp45 ; LDW RN load word from RAM LDWRN 5 NEWSYM FxOp46 ; LDW RN load word from RAM LDWRN 6 NEWSYM FxOp47 ; LDW RN load word from RAM LDWRN 7 NEWSYM FxOp48 ; LDW RN load word from RAM LDWRN 8 NEWSYM FxOp49 ; LDW RN load word from RAM LDWRN 9 NEWSYM FxOp4A ; LDW RN load word from RAM LDWRN 10 NEWSYM FxOp4B ; LDW RN load word from RAM LDWRN 11 NEWSYM FxOp40A1 ; LDB RN load byte from RAM LDBRN 0 NEWSYM FxOp41A1 ; LDB RN load byte from RAM LDBRN 1 NEWSYM FxOp42A1 ; LDB RN load byte from RAM LDBRN 2 NEWSYM FxOp43A1 ; LDB RN load byte from RAM LDBRN 3 NEWSYM FxOp44A1 ; LDB RN load byte from RAM LDBRN 4 NEWSYM FxOp45A1 ; LDB RN load byte from RAM LDBRN 5 NEWSYM FxOp46A1 ; LDB RN load byte from RAM LDBRN 6 NEWSYM FxOp47A1 ; LDB RN load byte from RAM LDBRN 7 NEWSYM FxOp48A1 ; LDB RN load byte from RAM LDBRN 8 NEWSYM FxOp49A1 ; LDB RN load byte from RAM LDBRN 9 NEWSYM FxOp4AA1 ; LDB RN load byte from RAM LDBRN 10 NEWSYM FxOp4BA1 ; LDB RN load byte from RAM LDBRN 11 NEWSYM FxOp4C1284b ; PLOT 4bit plotlines4b plotb NEWSYM FxOp4C1284bz ; PLOT 4bit, zero check plotlines4b plotbz NEWSYM FxOp4C1284bd ; PLOT 4bit, dither plotlines4b plotbd NEWSYM FxOp4C1284bzd ; PLOT 4bit, zero check + dither plotlines4b plotbzd NEWSYM FxOp4C1282b ; PLOT 2bit plotlines2b plotb NEWSYM FxOp4C1282bz ; PLOT 2bit, zero check plotlines2b plotbz NEWSYM FxOp4C1282bd ; PLOT 2bit, dither plotlines2b plotbd NEWSYM FxOp4C1282bzd ; PLOT 2bit, zero check + dither plotlines2b plotbzd NEWSYM FxOp4C1288b ; PLOT 8bit plotlines8b plotb NEWSYM FxOp4C1288bz ; PLOT 8bit, zero check plotlines8b plotbz NEWSYM FxOp4C1288bd ; PLOT 8bit, dither plotlines8b plotbd NEWSYM FxOp4C1288bzd ; PLOT 8bit, zero check + dither plotlines8b plotbzd NEWSYM FxOp4C1288bl ; PLOT 8bit plotlines8bl plotb NEWSYM FxOp4C1288bzl ; PLOT 8bit, zero check plotlines8bl plotbz NEWSYM FxOp4C1288bdl ; PLOT 8bit, dither plotlines8bl plotbd NEWSYM FxOp4C1288bzdl ; PLOT 8bit, zero check + dither plotlines8bl plotbzd NEWSYM FxOp4C ; PLOT plot pixel with R1,R2 as x,y and the color register as the color jmp FxOp4C1284b FETCHPIPE inc ebp CLRFLAGS mov ebx,[SfxR2] mov bh,[SfxR1] mov eax,[sfxclineloc] mov ebx,[eax+ebx*4] cmp ebx,0FFFFFFFFh je near .nodraw xor eax,eax ; bits 5/2 : 00 = 128 pixels, 01 = 160 pixels, 10 = 192 pixels, 11 = obj ; bits 1/0 : 00 = 4 color, 01 = 16-color, 10 = not used, 11 = 256 color ; 192 pixels = 24 tiles, 160 pixels = 20 tiles, 128 pixels = 16 tiles ; 16+8(4/3) 16+4(4/2) 16(4/0) push ecx mov al,[SfxSCMR] and al,00000011b ; 4 + 32 cmp al,0 je near .colors4 cmp al,3 je near .colors256 shl ebx,5 ; x32 (16 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_16 test byte[SfxCOLR],0Fh jz .nodraw .nozerocheck_16 mov dl,[SfxCOLR] test byte[SfxPOR],02h jz .nodither4b mov dh,[SfxR1] xor dh,[SfxR2] test dh,01h jz .nodither4b shr dh,4 .nodither4b and byte[eax],bh and byte[eax+1],bh and byte[eax+16],bh and byte[eax+17],bh test dl,01h jz .nodraw_16 or byte[eax], bl .nodraw_16 test dl,02h jz .nodraw2_16 or byte[eax+1], bl .nodraw2_16 test dl,04h jz .nodraw3_16 or byte[eax+16],bl .nodraw3_16 test dl,08h jz .nodraw4_16 or byte[eax+17],bl .nodraw4_16 .nodraw inc word [SfxR1] ret .colors4 shl ebx,4 ; x16 (4 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_4 test byte[SfxCOLR],03h jz .noplot_4 .nozerocheck_4 mov dl,[SfxCOLR] test byte[SfxPOR],02h jz .nodither2b mov dh,[SfxR1] xor dh,[SfxR2] test dh,01h jz .nodither2b shr dh,4 .nodither2b and byte[eax],bh and byte[eax+1],bh test dl,01h jz .nodraw_4 or byte[eax], bl .nodraw_4 test dl,02h jz .nodraw2_4 or byte[eax+1], bl .nodraw2_4 .noplot_4 inc word [SfxR1] ret .colors256 shl ebx,6 ; x64 (256 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_256 mov dl,0FFh test byte[SfxPOR],08h jz .nozerocheckb_256 mov dl,0Fh .nozerocheckb_256 test byte[SfxCOLR],dl jz .noplot_256 .nozerocheck_256 mov dl,[SfxCOLR] and byte[eax],bh and byte[eax+1],bh and byte[eax+16],bh and byte[eax+17],bh and byte[eax+32],bh and byte[eax+33],bh and byte[eax+48],bh and byte[eax+49],bh test dl,01h jz .nodraw_256 or byte[eax], bl .nodraw_256 test dl,02h jz .nodraw2_256 or byte[eax+1], bl .nodraw2_256 test dl,04h jz .nodraw3_256 or byte[eax+16],bl .nodraw3_256 test dl,08h jz .nodraw4_256 or byte[eax+17],bl .nodraw4_256 test dl,10h jz .nodraw5_256 or byte[eax+32], bl .nodraw5_256 test dl,20h jz .nodraw6_256 or byte[eax+33], bl .nodraw6_256 test dl,40h jz .nodraw7_256 or byte[eax+48],bl .nodraw7_256 test dl,80h jz .nodraw8_256 or byte[eax+49],bl .nodraw8_256 .noplot_256 inc word [SfxR1] ret .prevx dw 0 .prevy dw 0 sfxwarning db 0 NEWSYM FxOp4CA1 ; RPIX read color of the pixel with R1,R2 as x,y FETCHPIPE mov ebx,[SfxR2] mov bh,[SfxR1] test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov ebx,[eax+ebx*4] cmp ebx,0FFFFFFFFh je near .nodraw xor eax,eax ; bits 5/2 : 00 = 128 pixels, 01 = 160 pixels, 10 = 192 pixels, 11 = obj ; bits 1/0 : 00 = 4 color, 01 = 16-color, 10 = not used, 11 = 256 color ; 192 pixels = 24 tiles, 160 pixels = 20 tiles, 128 pixels = 16 tiles ; 16+8(4/3) 16+4(4/2) 16(4/0) push ecx mov al,[SfxSCMR] and al,00000011b ; 4 + 32 cmp al,0 je near .colors4 cmp al,3 je near .colors256 shl ebx,5 ; x32 (16 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl pop ecx xor bh,bh test byte[eax],bl jz .nodraw_16 or bh,01h .nodraw_16 test byte[eax+1],bl jz .nodraw2_16 or bh,02h .nodraw2_16 test byte[eax+16],bl jz .nodraw3_16 or bh,04h .nodraw3_16 test byte[eax+17],bl jz .nodraw4_16 or bh,08h .nodraw4_16 .nodraw mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx ret .colors4 shl ebx,4 ; x16 (4 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx xor bh,bh test byte[eax],bl jz .nodraw_4 or bh,01h .nodraw_4 test byte[eax+1],bl jz .nodraw2_4 or bh,02h .nodraw2_4 mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx ret .colors256 shl ebx,6 ; x64 (256 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx xor bh,bh test byte[eax],bl jz .nodraw_256 or bh,01h .nodraw_256 test byte[eax+1],bl jz .nodraw2_256 or bh,02h .nodraw2_256 test byte[eax+16],bl jz .nodraw3_256 or bh,04h .nodraw3_256 test byte[eax+17],bl jz .nodraw4_256 or bh,08h .nodraw4_256 test byte[eax+32],bl jz .nodraw5_256 or bh,10h .nodraw5_256 test byte[eax+33],bl jz .nodraw6_256 or bh,20h .nodraw6_256 test byte[eax+48],bl jz .nodraw7_256 or bh,40h .nodraw7_256 test byte[eax+49],bl jz .nodraw8_256 or bh,80h .nodraw8_256 mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx ret NEWSYM FxOp4D ; SWAP swap upper and lower byte of a register ; V mov eax,[esi] ; Read Source FETCHPIPE ror ax,8 inc ebp ; Increase program counter mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp4E ; COLOR copy source register to color register ; V FETCHPIPE mov eax,[esi] ; Read Source ; if bit 3 of SfxPOR is set, then don't modify the upper 4 bits test byte[SfxPOR],04h jz .nohighnibble mov bl,al shr bl,4 and al,0F0h or al,bl .nohighnibble test byte[SfxPOR],08h jnz .preserveupper cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx .nocolchange CLRFLAGS inc ebp ; Increase program counter ret .preserveupper mov bl,[SfxCOLR] and al,0Fh and bl,0F0h or al,bl cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx CLRFLAGS inc ebp ; Increase program counter ret NEWSYM FxOp4EA1 ; CMODE set plot option register ; V FETCHPIPE mov eax,[esi] ; Read Source inc ebp ; Increase program counter mov dword [SfxPOR],eax test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov [sfxclineloc],eax push ebx mov al,[SfxSCMR] and eax,00000011b mov bl,[SfxPOR] and bl,0Fh shl bl,2 or al,bl mov ebx,[PLOTJmpb+eax*4] mov eax,[PLOTJmpa+eax*4] mov dword [FxTable+4Ch*4],eax mov dword [FxTableb+4Ch*4],eax mov dword [FxTablec+4Ch*4],eax mov dword [FxTabled+4Ch*4],ebx pop ebx CLRFLAGS ret NEWSYM FxOp4F ; NOT perform exclusive exor with 1 on all bits ; V mov eax,[esi] ; Read Source FETCHPIPE xor eax,0FFFFh inc ebp ; Increase program counter mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp50 ; ADD RN add, register + register ADDRN 0 NEWSYM FxOp51 ; ADD RN add, register + register ADDRN 1 NEWSYM FxOp52 ; ADD RN add, register + register ADDRN 2 NEWSYM FxOp53 ; ADD RN add, register + register ADDRN 3 NEWSYM FxOp54 ; ADD RN add, register + register ADDRN 4 NEWSYM FxOp55 ; ADD RN add, register + register ADDRN 5 NEWSYM FxOp56 ; ADD RN add, register + register ADDRN 6 NEWSYM FxOp57 ; ADD RN add, register + register ADDRN 7 NEWSYM FxOp58 ; ADD RN add, register + register ADDRN 8 NEWSYM FxOp59 ; ADD RN add, register + register ADDRN 9 NEWSYM FxOp5A ; ADD RN add, register + register ADDRN 10 NEWSYM FxOp5B ; ADD RN add, register + register ADDRN 11 NEWSYM FxOp5C ; ADD RN add, register + register ADDRN 12 NEWSYM FxOp5D ; ADD RN add, register + register ADDRN 13 NEWSYM FxOp5E ; ADD RN add, register + register ADDRN 14 NEWSYM FxOp5F ; ADD RN add, register + register FETCHPIPE mov eax, [esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] add ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp50A1 ; ADC RN add with carry, register + register ADCRN 0 NEWSYM FxOp51A1 ; ADC RN add with carry, register + register ADCRN 1 NEWSYM FxOp52A1 ; ADC RN add with carry, register + register ADCRN 2 NEWSYM FxOp53A1 ; ADC RN add with carry, register + register ADCRN 3 NEWSYM FxOp54A1 ; ADC RN add with carry, register + register ADCRN 4 NEWSYM FxOp55A1 ; ADC RN add with carry, register + register ADCRN 5 NEWSYM FxOp56A1 ; ADC RN add with carry, register + register ADCRN 6 NEWSYM FxOp57A1 ; ADC RN add with carry, register + register ADCRN 7 NEWSYM FxOp58A1 ; ADC RN add with carry, register + register ADCRN 8 NEWSYM FxOp59A1 ; ADC RN add with carry, register + register ADCRN 9 NEWSYM FxOp5AA1 ; ADC RN add with carry, register + register ADCRN 10 NEWSYM FxOp5BA1 ; ADC RN add with carry, register + register ADCRN 11 NEWSYM FxOp5CA1 ; ADC RN add with carry, register + register ADCRN 12 NEWSYM FxOp5DA1 ; ADC RN add with carry, register + register ADCRN 13 NEWSYM FxOp5EA1 ; ADC RN add with carry, register + register ADCRN 14 NEWSYM FxOp5FA1 ; ADC RN add with carry, register + register FETCHPIPE mov eax, [esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] shr byte[SfxCarry],1 adc ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret ; Weird opcode (FxOp50A2, add 0, wow!) NEWSYM FxOp50A2 ; ADI RN add, register + immediate ADIRN 0 NEWSYM FxOp51A2 ; ADI RN add, register + immediate ADIRN 1 NEWSYM FxOp52A2 ; ADI RN add, register + immediate ADIRN 2 NEWSYM FxOp53A2 ; ADI RN add, register + immediate ADIRN 3 NEWSYM FxOp54A2 ; ADI RN add, register + immediate ADIRN 4 NEWSYM FxOp55A2 ; ADI RN add, register + immediate ADIRN 5 NEWSYM FxOp56A2 ; ADI RN add, register + immediate ADIRN 6 NEWSYM FxOp57A2 ; ADI RN add, register + immediate ADIRN 7 NEWSYM FxOp58A2 ; ADI RN add, register + immediate ADIRN 8 NEWSYM FxOp59A2 ; ADI RN add, register + immediate ADIRN 9 NEWSYM FxOp5AA2 ; ADI RN add, register + immediate ADIRN 10 NEWSYM FxOp5BA2 ; ADI RN add, register + immediate ADIRN 11 NEWSYM FxOp5CA2 ; ADI RN add, register + immediate ADIRN 12 NEWSYM FxOp5DA2 ; ADI RN add, register + immediate ADIRN 13 NEWSYM FxOp5EA2 ; ADI RN add, register + immediate ADIRN 14 NEWSYM FxOp5FA2 ; ADI RN add, register + immediate ADIRN 15 ; Another very useful opcode NEWSYM FxOp50A3 ; ADCIRN add with carry, register + immediate ADCIRN 0 NEWSYM FxOp51A3 ; ADCIRN add with carry, register + immediate ADCIRN 1 NEWSYM FxOp52A3 ; ADCIRN add with carry, register + immediate ADCIRN 2 NEWSYM FxOp53A3 ; ADCIRN add with carry, register + immediate ADCIRN 3 NEWSYM FxOp54A3 ; ADCIRN add with carry, register + immediate ADCIRN 4 NEWSYM FxOp55A3 ; ADCIRN add with carry, register + immediate ADCIRN 5 NEWSYM FxOp56A3 ; ADCIRN add with carry, register + immediate ADCIRN 6 NEWSYM FxOp57A3 ; ADCIRN add with carry, register + immediate ADCIRN 7 NEWSYM FxOp58A3 ; ADCIRN add with carry, register + immediate ADCIRN 8 NEWSYM FxOp59A3 ; ADCIRN add with carry, register + immediate ADCIRN 9 NEWSYM FxOp5AA3 ; ADCIRN add with carry, register + immediate ADCIRN 10 NEWSYM FxOp5BA3 ; ADCIRN add with carry, register + immediate ADCIRN 11 NEWSYM FxOp5CA3 ; ADCIRN add with carry, register + immediate ADCIRN 12 NEWSYM FxOp5DA3 ; ADCIRN add with carry, register + immediate ADCIRN 13 NEWSYM FxOp5EA3 ; ADCIRN add with carry, register + immediate ADCIRN 14 NEWSYM FxOp5FA3 ; ADCIRN add with carry, register + immediate ADCIRN 15 NEWSYM FxOp60 ; SUBRN subtract, register - register SUBRN 0 NEWSYM FxOp61 ; SUBRN subtract, register - register SUBRN 1 NEWSYM FxOp62 ; SUBRN subtract, register - register SUBRN 2 NEWSYM FxOp63 ; SUBRN subtract, register - register SUBRN 3 NEWSYM FxOp64 ; SUBRN subtract, register - register SUBRN 4 NEWSYM FxOp65 ; SUBRN subtract, register - register SUBRN 5 NEWSYM FxOp66 ; SUBRN subtract, register - register SUBRN 6 NEWSYM FxOp67 ; SUBRN subtract, register - register SUBRN 7 NEWSYM FxOp68 ; SUBRN subtract, register - register SUBRN 8 NEWSYM FxOp69 ; SUBRN subtract, register - register SUBRN 9 NEWSYM FxOp6A ; SUBRN subtract, register - register SUBRN 10 NEWSYM FxOp6B ; SUBRN subtract, register - register SUBRN 11 NEWSYM FxOp6C ; SUBRN subtract, register - register SUBRN 12 NEWSYM FxOp6D ; SUBRN subtract, register - register SUBRN 13 NEWSYM FxOp6E ; SUBRN subtract, register - register SUBRN 14 NEWSYM FxOp6F ; SUBRN subtract, register - register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp60A1 ; SBCRN subtract with carry, register - register SBCRN 0 NEWSYM FxOp61A1 ; SBCRN subtract with carry, register - register SBCRN 1 NEWSYM FxOp62A1 ; SBCRN subtract with carry, register - register SBCRN 2 NEWSYM FxOp63A1 ; SBCRN subtract with carry, register - register SBCRN 3 NEWSYM FxOp64A1 ; SBCRN subtract with carry, register - register SBCRN 4 NEWSYM FxOp65A1 ; SBCRN subtract with carry, register - register SBCRN 5 NEWSYM FxOp66A1 ; SBCRN subtract with carry, register - register SBCRN 6 NEWSYM FxOp67A1 ; SBCRN subtract with carry, register - register SBCRN 7 NEWSYM FxOp68A1 ; SBCRN subtract with carry, register - register SBCRN 8 NEWSYM FxOp69A1 ; SBCRN subtract with carry, register - register SBCRN 9 NEWSYM FxOp6AA1 ; SBCRN subtract with carry, register - register SBCRN 10 NEWSYM FxOp6BA1 ; SBCRN subtract with carry, register - register SBCRN 11 NEWSYM FxOp6CA1 ; SBCRN subtract with carry, register - register SBCRN 12 NEWSYM FxOp6DA1 ; SBCRN subtract with carry, register - register SBCRN 13 NEWSYM FxOp6EA1 ; SBCRN subtract with carry, register - register SBCRN 14 NEWSYM FxOp6FA1 ; SBCRN subtract with carry, register - register mov eax,[esi] ; Read Source mov ebx,ebp FETCHPIPE sub ebx,[SfxCPB] cmp byte[SfxCarry],1 sbb ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp60A2 ; SUBIRN subtract, register - immediate SUBIRN 0 NEWSYM FxOp61A2 ; SUBIRN subtract, register - immediate SUBIRN 1 NEWSYM FxOp62A2 ; SUBIRN subtract, register - immediate SUBIRN 2 NEWSYM FxOp63A2 ; SUBIRN subtract, register - immediate SUBIRN 3 NEWSYM FxOp64A2 ; SUBIRN subtract, register - immediate SUBIRN 4 NEWSYM FxOp65A2 ; SUBIRN subtract, register - immediate SUBIRN 5 NEWSYM FxOp66A2 ; SUBIRN subtract, register - immediate SUBIRN 6 NEWSYM FxOp67A2 ; SUBIRN subtract, register - immediate SUBIRN 7 NEWSYM FxOp68A2 ; SUBIRN subtract, register - immediate SUBIRN 8 NEWSYM FxOp69A2 ; SUBIRN subtract, register - immediate SUBIRN 9 NEWSYM FxOp6AA2 ; SUBIRN subtract, register - immediate SUBIRN 10 NEWSYM FxOp6BA2 ; SUBIRN subtract, register - immediate SUBIRN 11 NEWSYM FxOp6CA2 ; SUBIRN subtract, register - immediate SUBIRN 12 NEWSYM FxOp6DA2 ; SUBIRN subtract, register - immediate SUBIRN 13 NEWSYM FxOp6EA2 ; SUBIRN subtract, register - immediate SUBIRN 14 NEWSYM FxOp6FA2 ; SUBIRN subtract, register - immediate SUBIRN 15 NEWSYM FxOp60A3 ; CMPRN compare, register, register CMPRN 0 NEWSYM FxOp61A3 ; CMPRN compare, register, register CMPRN 1 NEWSYM FxOp62A3 ; CMPRN compare, register, register CMPRN 2 NEWSYM FxOp63A3 ; CMPRN compare, register, register CMPRN 3 NEWSYM FxOp64A3 ; CMPRN compare, register, register CMPRN 4 NEWSYM FxOp65A3 ; CMPRN compare, register, register CMPRN 5 NEWSYM FxOp66A3 ; CMPRN compare, register, register CMPRN 6 NEWSYM FxOp67A3 ; CMPRN compare, register, register CMPRN 7 NEWSYM FxOp68A3 ; CMPRN compare, register, register CMPRN 8 NEWSYM FxOp69A3 ; CMPRN compare, register, register CMPRN 9 NEWSYM FxOp6AA3 ; CMPRN compare, register, register CMPRN 10 NEWSYM FxOp6BA3 ; CMPRN compare, register, register CMPRN 11 NEWSYM FxOp6CA3 ; CMPRN compare, register, register CMPRN 12 NEWSYM FxOp6DA3 ; CMPRN compare, register, register CMPRN 13 NEWSYM FxOp6EA3 ; CMPRN compare, register, register CMPRN 14 NEWSYM FxOp6FA3 ; CMPRN compare, register, register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 mov [SfxSignZero],eax CLRFLAGS inc ebp ; Increase program counter ret NEWSYM FxOp70 ; MERGE R7 as upper byte, R8 as lower byte (used for texture-mapping) */ ; V xor eax,eax FETCHPIPE mov ah,byte [SfxR7+1] mov al,byte [SfxR8+1] inc ebp mov [edi],eax ; Write Destination mov dword[SfxSignZero],0001h test eax,0F0F0h jz .nozero mov dword[SfxSignZero],0000h .nozero test eax,08080h jz .nosign or dword [SfxSignZero],80000h .nosign mov dword [SfxOverflow],1 test ax,0c0c0h jnz .Overflow mov dword [SfxOverflow],0 .Overflow mov dword [SfxCarry],1 test ax,0e0e0h jnz .Carry mov dword [SfxCarry],0 .Carry CLRFLAGS ret NEWSYM FxOp71 ; AND RN register & register ANDRN 1 NEWSYM FxOp72 ; AND RN register & register ANDRN 2 NEWSYM FxOp73 ; AND RN register & register ANDRN 3 NEWSYM FxOp74 ; AND RN register & register ANDRN 4 NEWSYM FxOp75 ; AND RN register & register ANDRN 5 NEWSYM FxOp76 ; AND RN register & register ANDRN 6 NEWSYM FxOp77 ; AND RN register & register ANDRN 7 NEWSYM FxOp78 ; AND RN register & register ANDRN 8 NEWSYM FxOp79 ; AND RN register & register ANDRN 9 NEWSYM FxOp7A ; AND RN register & register ANDRN 10 NEWSYM FxOp7B ; AND RN register & register ANDRN 11 NEWSYM FxOp7C ; AND RN register & register ANDRN 12 NEWSYM FxOp7D ; AND RN register & register ANDRN 13 NEWSYM FxOp7E ; AND RN register & register ANDRN 14 NEWSYM FxOp7F ; AND RN register & register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp71A1 ; BIC RN register & ~register BICRN 1 NEWSYM FxOp72A1 ; BIC RN register & ~register BICRN 2 NEWSYM FxOp73A1 ; BIC RN register & ~register BICRN 3 NEWSYM FxOp74A1 ; BIC RN register & ~register BICRN 4 NEWSYM FxOp75A1 ; BIC RN register & ~register BICRN 5 NEWSYM FxOp76A1 ; BIC RN register & ~register BICRN 6 NEWSYM FxOp77A1 ; BIC RN register & ~register BICRN 7 NEWSYM FxOp78A1 ; BIC RN register & ~register BICRN 8 NEWSYM FxOp79A1 ; BIC RN register & ~register BICRN 9 NEWSYM FxOp7AA1 ; BIC RN register & ~register BICRN 10 NEWSYM FxOp7BA1 ; BIC RN register & ~register BICRN 11 NEWSYM FxOp7CA1 ; BIC RN register & ~register BICRN 12 NEWSYM FxOp7DA1 ; BIC RN register & ~register BICRN 13 NEWSYM FxOp7EA1 ; BIC RN register & ~register BICRN 14 NEWSYM FxOp7FA1 ; BIC RN register & ~register FETCHPIPE mov ebx,ebp sub ebx,[SfxCPB] mov eax,[esi] ; Read Source xor ebx,0FFFFh and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp71A2 ; ANDIRN and #n - register & immediate ANDIRN 1 NEWSYM FxOp72A2 ; ANDIRN and #n - register & immediate ANDIRN 2 NEWSYM FxOp73A2 ; ANDIRN and #n - register & immediate ANDIRN 3 NEWSYM FxOp74A2 ; ANDIRN and #n - register & immediate ANDIRN 4 NEWSYM FxOp75A2 ; ANDIRN and #n - register & immediate ANDIRN 5 NEWSYM FxOp76A2 ; ANDIRN and #n - register & immediate ANDIRN 6 NEWSYM FxOp77A2 ; ANDIRN and #n - register & immediate ANDIRN 7 NEWSYM FxOp78A2 ; ANDIRN and #n - register & immediate ANDIRN 8 NEWSYM FxOp79A2 ; ANDIRN and #n - register & immediate ANDIRN 9 NEWSYM FxOp7AA2 ; ANDIRN and #n - register & immediate ANDIRN 10 NEWSYM FxOp7BA2 ; ANDIRN and #n - register & immediate ANDIRN 11 NEWSYM FxOp7CA2 ; ANDIRN and #n - register & immediate ANDIRN 12 NEWSYM FxOp7DA2 ; ANDIRN and #n - register & immediate ANDIRN 13 NEWSYM FxOp7EA2 ; ANDIRN and #n - register & immediate ANDIRN 14 NEWSYM FxOp7FA2 ; ANDIRN and #n - register & immediate ANDIRN 15 NEWSYM FxOp71A3 ; BICIRN register & ~immediate BICIRN 1 ^ 0FFFFh NEWSYM FxOp72A3 ; BICIRN register & ~immediate BICIRN 2 ^ 0FFFFh NEWSYM FxOp73A3 ; BICIRN register & ~immediate BICIRN 3 ^ 0FFFFh NEWSYM FxOp74A3 ; BICIRN register & ~immediate BICIRN 4 ^ 0FFFFh NEWSYM FxOp75A3 ; BICIRN register & ~immediate BICIRN 5 ^ 0FFFFh NEWSYM FxOp76A3 ; BICIRN register & ~immediate BICIRN 6 ^ 0FFFFh NEWSYM FxOp77A3 ; BICIRN register & ~immediate BICIRN 7 ^ 0FFFFh NEWSYM FxOp78A3 ; BICIRN register & ~immediate BICIRN 8 ^ 0FFFFh NEWSYM FxOp79A3 ; BICIRN register & ~immediate BICIRN 9 ^ 0FFFFh NEWSYM FxOp7AA3 ; BICIRN register & ~immediate BICIRN 10 ^ 0FFFFh NEWSYM FxOp7BA3 ; BICIRN register & ~immediate BICIRN 11 ^ 0FFFFh NEWSYM FxOp7CA3 ; BICIRN register & ~immediate BICIRN 12 ^ 0FFFFh NEWSYM FxOp7DA3 ; BICIRN register & ~immediate BICIRN 13 ^ 0FFFFh NEWSYM FxOp7EA3 ; BICIRN register & ~immediate BICIRN 14 ^ 0FFFFh NEWSYM FxOp7FA3 ; BICIRN register & ~immediate BICIRN 15 ^ 0FFFFh NEWSYM FxOp80 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 0 NEWSYM FxOp81 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 1 NEWSYM FxOp82 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 2 NEWSYM FxOp83 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 3 NEWSYM FxOp84 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 4 NEWSYM FxOp85 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 5 NEWSYM FxOp86 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 6 NEWSYM FxOp87 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 7 NEWSYM FxOp88 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 8 NEWSYM FxOp89 ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 9 NEWSYM FxOp8A ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 10 NEWSYM FxOp8B ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 11 NEWSYM FxOp8C ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 12 NEWSYM FxOp8D ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 13 NEWSYM FxOp8E ; MULTRN 8 bit to 16 bit signed multiply, register * register MULTRN 14 NEWSYM FxOp8F ; MULTRN 8 bit to 16 bit signed multiply, register * register FETCHPIPE mov ebx,ebp mov al,byte [esi] ; Read Source sub ebx,[SfxCPB] imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp80A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 0 NEWSYM FxOp81A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 1 NEWSYM FxOp82A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 2 NEWSYM FxOp83A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 3 NEWSYM FxOp84A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 4 NEWSYM FxOp85A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 5 NEWSYM FxOp86A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 6 NEWSYM FxOp87A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 7 NEWSYM FxOp88A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 8 NEWSYM FxOp89A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 9 NEWSYM FxOp8AA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 10 NEWSYM FxOp8BA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 11 NEWSYM FxOp8CA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 12 NEWSYM FxOp8DA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 13 NEWSYM FxOp8EA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRN 14 NEWSYM FxOp8FA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register FETCHPIPE mov ebx,ebp mov al,byte [esi] ; Read Source sub ebx,[SfxCPB] mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret NEWSYM FxOp80A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 0 NEWSYM FxOp81A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 1 NEWSYM FxOp82A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 2 NEWSYM FxOp83A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 3 NEWSYM FxOp84A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 4 NEWSYM FxOp85A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 5 NEWSYM FxOp86A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 6 NEWSYM FxOp87A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 7 NEWSYM FxOp88A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 8 NEWSYM FxOp89A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 9 NEWSYM FxOp8AA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 10 NEWSYM FxOp8BA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 11 NEWSYM FxOp8CA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 12 NEWSYM FxOp8DA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 13 NEWSYM FxOp8EA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 14 NEWSYM FxOp8FA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRN 15 NEWSYM FxOp80A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 0 NEWSYM FxOp81A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 1 NEWSYM FxOp82A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 2 NEWSYM FxOp83A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 3 NEWSYM FxOp84A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 4 NEWSYM FxOp85A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 5 NEWSYM FxOp86A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 6 NEWSYM FxOp87A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 7 NEWSYM FxOp88A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 8 NEWSYM FxOp89A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 9 NEWSYM FxOp8AA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 10 NEWSYM FxOp8BA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 11 NEWSYM FxOp8CA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 12 NEWSYM FxOp8DA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 13 NEWSYM FxOp8EA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 14 NEWSYM FxOp8FA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRN 15 NEWSYM FxOp90 ; SBK store word to last accessed RAM address ; V mov ebx,[SfxLastRamAdr] ; Load last ram address mov eax,[esi] ; Read Source FETCHPIPE mov [ebx],al ; Store Word sub ebx,[SfxRAMMem] xor ebx,1 add ebx,[SfxRAMMem] inc ebp ; Increase program counter mov [ebx],ah ; Store Word CLRFLAGS ret NEWSYM FxOp91 ; LINK#n R11 = R15 + immediate LINK 1 NEWSYM FxOp92 ; LINK#n R11 = R15 + immediate LINK 2 NEWSYM FxOp93 ; LINK#n R11 = R15 + immediate LINK 3 NEWSYM FxOp94 ; LINK#n R11 = R15 + immediate LINK 4 NEWSYM FxOp95 ; SEX sign extend 8 bit to 16 bit ; V movsx eax, byte [esi] ; Read Source FETCHPIPE and eax,0FFFFh inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp96 ; ASR aritmethic shift right by one ; V mov eax,[esi] ; Read Source FETCHPIPE mov [SfxCarry],al and byte[SfxCarry],1 sar ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp96A1 ; DIV2 aritmethic shift right by one ; V mov eax,[esi] ; Read Source FETCHPIPE cmp ax,-1 je .minusone mov [SfxCarry],al and byte[SfxCarry],1 sar ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS ret .minusone mov byte[SfxCarry],1 xor eax,eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp97 ; ROR rotate right by one ; V FETCHPIPE mov eax,[esi] ; Read Source shr byte[SfxCarry],1 rcr ax,1 setc byte[SfxCarry] inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp98 ; JMPRN jump to address of register JMPRN 8 NEWSYM FxOp99 ; JMPRN jump to address of register JMPRN 9 NEWSYM FxOp9A ; JMPRN jump to address of register JMPRN 10 NEWSYM FxOp9B ; JMPRN jump to address of register JMPRN 11 NEWSYM FxOp9C ; JMPRN jump to address of register JMPRN 12 NEWSYM FxOp9D ; JMPRN jump to address of register JMPRN 13 NEWSYM FxOp98A1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 8 NEWSYM FxOp99A1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 9 NEWSYM FxOp9AA1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 10 NEWSYM FxOp9BA1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 11 NEWSYM FxOp9CA1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 12 NEWSYM FxOp9DA1 ; LJMPRN set program bank to source register and jump to address of register LJMPRN 13 NEWSYM FxOp9E ; LOB set upper byte to zero (keep low byte) ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,0FFh inc ebp mov [edi],eax ; Write Destination shl eax,8 mov dword [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOp9F ; FMULT 16 bit to 32 bit signed multiplication, upper 16 bits only ; V mov eax,[esi] ; Read Source mov ebx,[SfxR6] FETCHPIPE imul bx inc ebp and edx,0FFFFh mov [SfxSignZero],edx mov [edi],edx ; Write Destination shr ax,15 mov [SfxCarry],al CLRFLAGS ret NEWSYM FxOp9FA1 ; LMULT 16 bit to 32 bit signed multiplication ; V mov eax,[esi] ; Read Source mov ebx,[SfxR6] FETCHPIPE imul bx and edx,0FFFFh inc ebp mov [edi],edx ; Write Destination mov [SfxR4],ax mov [SfxSignZero],edx shr ax,15 mov [SfxCarry],al CLRFLAGS ret NEWSYM FxOpA0 ; IBTRN,#PP immediate byte transfer IBTRN 0 NEWSYM FxOpA1 ; IBTRN,#PP immediate byte transfer IBTRN 1 NEWSYM FxOpA2 ; IBTRN,#PP immediate byte transfer IBTRN 2 NEWSYM FxOpA3 ; IBTRN,#PP immediate byte transfer IBTRN 3 NEWSYM FxOpA4 ; IBTRN,#PP immediate byte transfer IBTRN 4 NEWSYM FxOpA5 ; IBTRN,#PP immediate byte transfer IBTRN 5 NEWSYM FxOpA6 ; IBTRN,#PP immediate byte transfer IBTRN 6 NEWSYM FxOpA7 ; IBTRN,#PP immediate byte transfer IBTRN 7 NEWSYM FxOpA8 ; IBTRN,#PP immediate byte transfer IBTRN 8 NEWSYM FxOpA9 ; IBTRN,#PP immediate byte transfer IBTRN 9 NEWSYM FxOpAA ; IBTRN,#PP immediate byte transfer IBTRN 10 NEWSYM FxOpAB ; IBTRN,#PP immediate byte transfer IBTRN 11 NEWSYM FxOpAC ; IBTRN,#PP immediate byte transfer IBTRN 12 NEWSYM FxOpAD ; IBTRN,#PP immediate byte transfer IBTRN 13 NEWSYM FxOpAE ; IBTRN,#PP immediate byte transfer movsx eax,byte[ebp] mov cl,[ebp+1] add ebp,2 mov [SfxR0+14*4],ax UpdateR14 CLRFLAGS ret NEWSYM FxOpAF ; IBTRN,#PP immediate byte transfer movsx eax,byte[ebp] mov cl,[ebp+1] and eax,0FFFFh mov ebp,[SfxCPB] add ebp,eax CLRFLAGS ret NEWSYM FxOpA0A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 0 NEWSYM FxOpA1A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 1 NEWSYM FxOpA2A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 2 NEWSYM FxOpA3A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 3 NEWSYM FxOpA4A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 4 NEWSYM FxOpA5A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 5 NEWSYM FxOpA6A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 6 NEWSYM FxOpA7A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 7 NEWSYM FxOpA8A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 8 NEWSYM FxOpA9A1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 9 NEWSYM FxOpAAA1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 10 NEWSYM FxOpABA1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 11 NEWSYM FxOpACA1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 12 NEWSYM FxOpADA1 ; LMS rn,(yy) load word from RAM (short address) LMSRN 13 NEWSYM FxOpAEA1 ; LMS rn,(yy) load word from RAM (short address) xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram inc ebp mov [SfxR0+14*4],bx ; Write data UpdateR14 CLRFLAGS ret NEWSYM FxOpAFA1 ; LMS rn,(yy) load word from RAM (short address) xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram and ebx,0FFFFh mov ebp,[SfxCPB] add ebp,ebx CLRFLAGS ret NEWSYM FxOpA0A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 0 NEWSYM FxOpA1A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 1 NEWSYM FxOpA2A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 2 NEWSYM FxOpA3A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 3 NEWSYM FxOpA4A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 4 NEWSYM FxOpA5A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 5 NEWSYM FxOpA6A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 6 NEWSYM FxOpA7A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 7 NEWSYM FxOpA8A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 8 NEWSYM FxOpA9A2 ; SMS (yy),rn store word in RAM (short address) SMSRN 9 NEWSYM FxOpAAA2 ; SMS (yy),rn store word in RAM (short address) SMSRN 10 NEWSYM FxOpABA2 ; SMS (yy),rn store word in RAM (short address) SMSRN 11 NEWSYM FxOpACA2 ; SMS (yy),rn store word in RAM (short address) SMSRN 12 NEWSYM FxOpADA2 ; SMS (yy),rn store word in RAM (short address) SMSRN 13 NEWSYM FxOpAEA2 ; SMS (yy),rn store word in RAM (short address) SMSRN 14 NEWSYM FxOpAFA2 ; SMS (yy),rn store word in RAM (short address) xor eax,eax mov ebx,ebp sub ebx,[SfxCPB] mov al,[ebp] inc ebp add eax,eax FETCHPIPE add eax,[SfxRAMMem] mov dword [SfxLastRamAdr],eax inc ebp mov [eax],bx ; Write word to ram CLRFLAGS ret NEWSYM FxOpB0 ; FROM rn set source register FROMRN 0 NEWSYM FxOpB1 ; FROM rn set source register FROMRN 1 NEWSYM FxOpB2 ; FROM rn set source register FROMRN 2 NEWSYM FxOpB3 ; FROM rn set source register FROMRN 3 NEWSYM FxOpB4 ; FROM rn set source register FROMRN 4 NEWSYM FxOpB5 ; FROM rn set source register FROMRN 5 NEWSYM FxOpB6 ; FROM rn set source register FROMRN 6 NEWSYM FxOpB7 ; FROM rn set source register FROMRN 7 NEWSYM FxOpB8 ; FROM rn set source register FROMRN 8 NEWSYM FxOpB9 ; FROM rn set source register FROMRN 9 NEWSYM FxOpBA ; FROM rn set source register FROMRN 10 NEWSYM FxOpBB ; FROM rn set source register FROMRN 11 NEWSYM FxOpBC ; FROM rn set source register FROMRN 12 NEWSYM FxOpBD ; FROM rn set source register FROMRN 13 NEWSYM FxOpBE ; FROM rn set source register FROMRN 14 NEWSYM FxOpBF ; FROM rn set source register FETCHPIPE mov esi,SfxR0+15*4 inc ebp ; Increase program counter mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTableb+ecx*4] mov esi,SfxR0 ret NEWSYM FxOpC0 ; HIB move high-byte to low-byte ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,0FF00h mov dword [SfxSignZero],eax shr eax,8 inc ebp mov [edi],eax CLRFLAGS ret NEWSYM FxOpC1 ; OR rn or rn ORRN 1 NEWSYM FxOpC2 ; OR rn or rn ORRN 2 NEWSYM FxOpC3 ; OR rn or rn ORRN 3 NEWSYM FxOpC4 ; OR rn or rn ORRN 4 NEWSYM FxOpC5 ; OR rn or rn ORRN 5 NEWSYM FxOpC6 ; OR rn or rn ORRN 6 NEWSYM FxOpC7 ; OR rn or rn ORRN 7 NEWSYM FxOpC8 ; OR rn or rn ORRN 8 NEWSYM FxOpC9 ; OR rn or rn ORRN 9 NEWSYM FxOpCA ; OR rn or rn ORRN 10 NEWSYM FxOpCB ; OR rn or rn ORRN 11 NEWSYM FxOpCC ; OR rn or rn ORRN 12 NEWSYM FxOpCD ; OR rn or rn ORRN 13 NEWSYM FxOpCE ; OR rn or rn ORRN 14 NEWSYM FxOpCF ; OR rn or rn mov eax,[esi] ; Read Source mov ebx,ebp FETCHPIPE sub ebx,[SfxCPB] or eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOpC1A1 ; XOR rn xor rn XORRN 1 NEWSYM FxOpC2A1 ; XOR rn xor rn XORRN 2 NEWSYM FxOpC3A1 ; XOR rn xor rn XORRN 3 NEWSYM FxOpC4A1 ; XOR rn xor rn XORRN 4 NEWSYM FxOpC5A1 ; XOR rn xor rn XORRN 5 NEWSYM FxOpC6A1 ; XOR rn xor rn XORRN 6 NEWSYM FxOpC7A1 ; XOR rn xor rn XORRN 7 NEWSYM FxOpC8A1 ; XOR rn xor rn XORRN 8 NEWSYM FxOpC9A1 ; XOR rn xor rn XORRN 9 NEWSYM FxOpCAA1 ; XOR rn xor rn XORRN 10 NEWSYM FxOpCBA1 ; XOR rn xor rn XORRN 11 NEWSYM FxOpCCA1 ; XOR rn xor rn XORRN 12 NEWSYM FxOpCDA1 ; XOR rn xor rn XORRN 13 NEWSYM FxOpCEA1 ; XOR rn xor rn XORRN 14 NEWSYM FxOpCFA1 ; XOR rn xor rn FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] xor eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret NEWSYM FxOpC1A2 ; OR #n OR #n ORI 1 NEWSYM FxOpC2A2 ; OR #n OR #n ORI 2 NEWSYM FxOpC3A2 ; OR #n OR #n ORI 3 NEWSYM FxOpC4A2 ; OR #n OR #n ORI 4 NEWSYM FxOpC5A2 ; OR #n OR #n ORI 5 NEWSYM FxOpC6A2 ; OR #n OR #n ORI 6 NEWSYM FxOpC7A2 ; OR #n OR #n ORI 7 NEWSYM FxOpC8A2 ; OR #n OR #n ORI 8 NEWSYM FxOpC9A2 ; OR #n OR #n ORI 9 NEWSYM FxOpCAA2 ; OR #n OR #n ORI 10 NEWSYM FxOpCBA2 ; OR #n OR #n ORI 11 NEWSYM FxOpCCA2 ; OR #n OR #n ORI 12 NEWSYM FxOpCDA2 ; OR #n OR #n ORI 13 NEWSYM FxOpCEA2 ; OR #n OR #n ORI 14 NEWSYM FxOpCFA2 ; OR #n OR #n ORI 15 NEWSYM FxOpC1A3 ; XOR #n xor #n XORI 1 NEWSYM FxOpC2A3 ; XOR #n xor #n XORI 2 NEWSYM FxOpC3A3 ; XOR #n xor #n XORI 3 NEWSYM FxOpC4A3 ; XOR #n xor #n XORI 4 NEWSYM FxOpC5A3 ; XOR #n xor #n XORI 5 NEWSYM FxOpC6A3 ; XOR #n xor #n XORI 6 NEWSYM FxOpC7A3 ; XOR #n xor #n XORI 7 NEWSYM FxOpC8A3 ; XOR #n xor #n XORI 8 NEWSYM FxOpC9A3 ; XOR #n xor #n XORI 9 NEWSYM FxOpCAA3 ; XOR #n xor #n XORI 10 NEWSYM FxOpCBA3 ; XOR #n xor #n XORI 11 NEWSYM FxOpCCA3 ; XOR #n xor #n XORI 12 NEWSYM FxOpCDA3 ; XOR #n xor #n XORI 13 NEWSYM FxOpCEA3 ; XOR #n xor #n XORI 14 NEWSYM FxOpCFA3 ; XOR #n xor #n XORI 15 NEWSYM FxOpD0 ; INC rn increase by one INCRN 0 NEWSYM FxOpD1 ; INC rn increase by one INCRN 1 NEWSYM FxOpD2 ; INC rn increase by one INCRN 2 NEWSYM FxOpD3 ; INC rn increase by one INCRN 3 NEWSYM FxOpD4 ; INC rn increase by one INCRN 4 NEWSYM FxOpD5 ; INC rn increase by one INCRN 5 NEWSYM FxOpD6 ; INC rn increase by one INCRN 6 NEWSYM FxOpD7 ; INC rn increase by one INCRN 7 NEWSYM FxOpD8 ; INC rn increase by one INCRN 8 NEWSYM FxOpD9 ; INC rn increase by one INCRN 9 NEWSYM FxOpDA ; INC rn increase by one INCRN 10 NEWSYM FxOpDB ; INC rn increase by one INCRN 11 NEWSYM FxOpDC ; INC rn increase by one INCRN 12 NEWSYM FxOpDD ; INC rn increase by one INCRN 13 NEWSYM FxOpDE ; INC rn increase by one FETCHPIPE mov eax,[SfxR0+14*4] ; Read Source inc ax mov [SfxR0+14*4],eax mov [SfxSignZero],eax CLRFLAGS inc ebp UpdateR14 ret NEWSYM FxOpDF ; GETC transfer ROM buffer to color register mov eax,[SfxRomBuffer] FETCHPIPE mov eax,[eax] test byte[SfxPOR],04h jz .nohighnibble mov bl,al shr bl,4 and al,0F0h or al,bl .nohighnibble test byte[SfxPOR],08h jnz .preserveupper cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx .nocolchange CLRFLAGS inc ebp ; Increase program counter ret .preserveupper mov bl,[SfxCOLR] and al,0Fh and bl,0F0h or al,bl cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx CLRFLAGS inc ebp ; Increase program counter ret NEWSYM FxOpDFA2 ; RAMB set current RAM bank ; Verified mov eax,[esi] ; Read Source mov ebx,[SfxnRamBanks] FETCHPIPE dec ebx and eax,ebx mov dword [SfxRAMBR],eax shl eax,16 add eax,[sfxramdata] mov dword [SfxRAMMem],eax CLRFLAGS inc ebp ret NEWSYM FxOpDFA3 ; ROMB set current ROM bank ; Verified mov eax,[esi] ; Read Source and eax,07Fh FETCHPIPE mov dword [SfxROMBR],eax mov eax,[SfxMemTable+eax*4] mov [SfxCROM],eax CLRFLAGS inc ebp ret NEWSYM FxOpE0 ; DEC rn decrement by one DECRN 0 NEWSYM FxOpE1 ; DEC rn decrement by one DECRN 1 NEWSYM FxOpE2 ; DEC rn decrement by one DECRN 2 NEWSYM FxOpE3 ; DEC rn decrement by one DECRN 3 NEWSYM FxOpE4 ; DEC rn decrement by one DECRN 4 NEWSYM FxOpE5 ; DEC rn decrement by one DECRN 5 NEWSYM FxOpE6 ; DEC rn decrement by one DECRN 6 NEWSYM FxOpE7 ; DEC rn decrement by one DECRN 7 NEWSYM FxOpE8 ; DEC rn decrement by one DECRN 8 NEWSYM FxOpE9 ; DEC rn decrement by one DECRN 9 NEWSYM FxOpEA ; DEC rn decrement by one DECRN 10 NEWSYM FxOpEB ; DEC rn decrement by one DECRN 11 NEWSYM FxOpEC ; DEC rn decrement by one DECRN 12 NEWSYM FxOpED ; DEC rn decrement by one DECRN 13 NEWSYM FxOpEE ; DEC rn decrement by one dec word[SfxR0+14*4] FETCHPIPE mov eax,[SfxR0+14*4] ; Read Source mov [SfxSignZero],eax UpdateR14 CLRFLAGS inc ebp ret NEWSYM FxOpEF ; getb get byte from ROM at address R14 ; V FETCHPIPE mov eax,[SfxRomBuffer] inc ebp mov eax,[eax] and eax,0FFh ; cmp edi,SfxR15 ; je .nor15 mov [edi],eax ; Write DREG CLRFLAGS ret .nor15 ; mov eax,ebp ; sub eax,[SfxCPB] ; mov [SfxR15],al or eax,8000h mov [edi],eax ; Write DREG CLRFLAGS ret NEWSYM FxOpEFA1 ; getbh get high-byte from ROM at address R14 ; V mov eax,[esi] ; Read Source mov ebx,[SfxRomBuffer] and eax,0FFh FETCHPIPE mov ah,[ebx] inc ebp mov [edi],eax ; Write DREG CLRFLAGS ret NEWSYM FxOpEFA2 ; getbl get low-byte from ROM at address R14 ; V mov eax,[esi] ; Read Source mov ebx,[SfxRomBuffer] and eax,0FF00h FETCHPIPE mov al,[ebx] inc ebp mov [edi],eax ; Write DREG CLRFLAGS ret NEWSYM FxOpEFA3 ; getbs get sign extended byte from ROM at address R14 ; V mov ebx,[SfxRomBuffer] FETCHPIPE movsx eax,byte[ebx] inc ebp mov [edi],ax ; Write DREG CLRFLAGS ret NEWSYM FxOpF0 ; IWT RN,#xx immediate word transfer to register IWTRN 0 NEWSYM FxOpF1 ; IWT RN,#xx immediate word transfer to register IWTRN 1 NEWSYM FxOpF2 ; IWT RN,#xx immediate word transfer to register IWTRN 2 NEWSYM FxOpF3 ; IWT RN,#xx immediate word transfer to register IWTRN 3 NEWSYM FxOpF4 ; IWT RN,#xx immediate word transfer to register IWTRN 4 NEWSYM FxOpF5 ; IWT RN,#xx immediate word transfer to register IWTRN 5 NEWSYM FxOpF6 ; IWT RN,#xx immediate word transfer to register IWTRN 6 NEWSYM FxOpF7 ; IWT RN,#xx immediate word transfer to register IWTRN 7 NEWSYM FxOpF8 ; IWT RN,#xx immediate word transfer to register IWTRN 8 NEWSYM FxOpF9 ; IWT RN,#xx immediate word transfer to register IWTRN 9 NEWSYM FxOpFA ; IWT RN,#xx immediate word transfer to register IWTRN 10 NEWSYM FxOpFB ; IWT RN,#xx immediate word transfer to register IWTRN 11 NEWSYM FxOpFC ; IWT RN,#xx immediate word transfer to register IWTRN 12 NEWSYM FxOpFD ; IWT RN,#xx immediate word transfer to register IWTRN 13 NEWSYM FxOpFE ; IWT RN,#xx immediate word transfer to register mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh add ebp,3 mov [SfxR0+14*4],eax UpdateR14 CLRFLAGS ret NEWSYM FxOpFF ; IWT RN,#xx immediate word transfer to register mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh mov ebp,[SfxCPB] add ebp,eax CLRFLAGS ret NEWSYM FxOpF0A1 ; LM RN,(XX) load word from RAM LMRN 0 NEWSYM FxOpF1A1 ; LM RN,(XX) load word from RAM LMRN 1 NEWSYM FxOpF2A1 ; LM RN,(XX) load word from RAM LMRN 2 NEWSYM FxOpF3A1 ; LM RN,(XX) load word from RAM LMRN 3 NEWSYM FxOpF4A1 ; LM RN,(XX) load word from RAM LMRN 4 NEWSYM FxOpF5A1 ; LM RN,(XX) load word from RAM LMRN 5 NEWSYM FxOpF6A1 ; LM RN,(XX) load word from RAM LMRN 6 NEWSYM FxOpF7A1 ; LM RN,(XX) load word from RAM LMRN 7 NEWSYM FxOpF8A1 ; LM RN,(XX) load word from RAM LMRN 8 NEWSYM FxOpF9A1 ; LM RN,(XX) load word from RAM LMRN 9 NEWSYM FxOpFAA1 ; LM RN,(XX) load word from RAM LMRN 10 NEWSYM FxOpFBA1 ; LM RN,(XX) load word from RAM LMRN 11 NEWSYM FxOpFCA1 ; LM RN,(XX) load word from RAM LMRN 12 NEWSYM FxOpFDA1 ; LM RN,(XX) load word from RAM LMRN 13 NEWSYM FxOpFEA1 ; LM RN,(XX) load word from RAM xor eax,eax mov cl,[ebp+2] mov ax,[ebp] mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 add ebp,3 mov dh,[eax+ebx] mov word [SfxR0+14*4],dx ; Store Word UpdateR14 CLRFLAGS ret NEWSYM FxOpFFA1 ; LM RN,(XX) load word from RAM FETCHPIPE mov eax,ecx inc ebp FETCHPIPE inc ebp mov ah,cl FETCHPIPE mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 mov dh,[eax+ebx] and edx,0FFFFh mov ebp,[SfxCPB] add ebp,edx CLRFLAGS ret NEWSYM FxOpF0A2 ; SM (XX),RN store word in RAM SMRN 0 NEWSYM FxOpF1A2 ; SM (XX),RN store word in RAM SMRN 1 NEWSYM FxOpF2A2 ; SM (XX),RN store word in RAM SMRN 2 NEWSYM FxOpF3A2 ; SM (XX),RN store word in RAM SMRN 3 NEWSYM FxOpF4A2 ; SM (XX),RN store word in RAM SMRN 4 NEWSYM FxOpF5A2 ; SM (XX),RN store word in RAM SMRN 5 NEWSYM FxOpF6A2 ; SM (XX),RN store word in RAM SMRN 6 NEWSYM FxOpF7A2 ; SM (XX),RN store word in RAM SMRN 7 NEWSYM FxOpF8A2 ; SM (XX),RN store word in RAM SMRN 8 NEWSYM FxOpF9A2 ; SM (XX),RN store word in RAM SMRN 9 NEWSYM FxOpFAA2 ; SM (XX),RN store word in RAM SMRN 10 NEWSYM FxOpFBA2 ; SM (XX),RN store word in RAM SMRN 11 NEWSYM FxOpFCA2 ; SM (XX),RN store word in RAM SMRN 12 NEWSYM FxOpFDA2 ; SM (XX),RN store word in RAM SMRN 13 NEWSYM FxOpFEA2 ; SM (XX),RN store word in RAM SMRN 14 NEWSYM FxOpFFA2 ; SM (XX),RN store word in RAM FETCHPIPE mov ebx,ebp sub ebx,[SfxCPB] mov eax,ecx inc ebp FETCHPIPE inc ebp mov ah,cl FETCHPIPE mov dx,bx mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov [eax+ebx],dl xor eax,1 inc ebp mov [eax+ebx],dh CLRFLAGS ret ALIGN32 NEWSYM NumberOfOpcodes, dd 0 ; Number of opcodes to execute NEWSYM NumberOfOpcodesBU, dd 0 ; Number of opcodes to execute backup value NEWSYM sfxwarningb, db 0 NEWSYM MainLoop mov eax,[SfxPBR] and eax,0FFh ; mov byte[fxtrace+eax],1 mov ebp,[SfxCPB] add ebp,[SfxR15] xor ecx,ecx mov cl,[SfxPIPE] mov ch,[SfxSFR+1] and ch,03h ; pack esi/edi PackEsiEdi jmp [FxTabled+ecx*4] jmp .LoopAgain ALIGN16 .LoopAgain call [FxTable+ecx*4] dec dword [NumberOfOpcodes] jnz .LoopAgain .EndLoop NEWSYM FXEndLoop sub ebp,[SfxCPB] mov [SfxR15],ebp mov [SfxPIPE],cl and byte[SfxSFR+1],0FFh-03h or [SfxSFR+1],ch UnPackEsiEdi ret SECTION .data NEWSYM fxtrace, db 0; times 65536 db 0 SECTION .text NEWSYM FxEmu2AsmEnd zsnes-1.36/src/chips/fxemu2.mac0100644000175000017500000004004307267141100015750 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %macro FETCHPIPE 0 ; mov edx,[SfxPBR] ; mov edx,[SfxMemTable+edx*4] ; mov edx,[SfxCPB] ; mov edx,[SfxR15] mov cl,[ebp] %endmacro %macro UpdateR14 0 ; mov edx,[SfxROMBR] ; mov edx,[SfxMemTable+edx*4] mov eax,[SfxCROM] ; and dword[SfxR14],0FFFFh add eax,[SfxR14] mov [SfxRomBuffer],eax %endmacro %macro UpdateR15 0 mov ebp,[SfxCPB] add ebp,[SfxR15] %endmacro %macro CLRFLAGS 0 ;and dword [SfxSFR],0FFFFh-0100h-0200h-1000h ; Clear ALT1,ALT2 and B Flags ; xor ch,ch ; mov dword [SfxB],0 ; Clear B Flag ; mov esi,SfxR0 ; mov edi,SfxR0 %endmacro %macro TORN 1 ; V FETCHPIPE mov edi, SfxR0+%1*4 inc ebp ; Increase program counter call [FxTable+ecx*4] mov edi,SfxR0 ret %endmacro %macro WITH 1 ; Verified. FETCHPIPE mov esi,SfxR0+%1*4 mov edi,SfxR0+%1*4 mov dword [SfxB],1 inc ebp ; Increase program counter call [FxTablec+ecx*4] mov esi,SfxR0 mov edi,SfxR0 mov dword [SfxB],0 ; Clear B Flag ret %endmacro %macro STWRN 1 ; V mov eax,[SfxR0+%1*4] ; Read register mov ebx,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address add dword [SfxLastRamAdr],ebx ; Save last ram address mov edx,[esi] ; Read Source FETCHPIPE mov [ebx+eax],dl ; Store Word xor eax,1 inc ebp ; Increase program counter mov [ebx+eax],dh ; Store Word CLRFLAGS ret %endmacro %macro STBRN 1 ; V mov eax,[SfxR0+%1*4] ; Read register FETCHPIPE add eax,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address mov ebx,[esi] ; Read Source mov byte [eax],bl ; Store Byte CLRFLAGS inc ebp ; Increase program counter ret %endmacro %macro LDWRN 1 ; V mov eax,[SfxR0+%1*4] ; Read register mov ebx,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address FETCHPIPE mov dl,[ebx+eax] ; Store Word add dword [SfxLastRamAdr],ebx ; Save last ram address xor eax,1 and edx,0FFFFh inc ebp ; Increase program counter mov dh,[ebx+eax] ; Store Word mov [edi],edx ; Read Source CLRFLAGS ret %endmacro %macro LDBRN 1 ; V mov eax,[SfxR0+%1*4] ; Read register FETCHPIPE add eax,[SfxRAMMem] xor ebx,ebx mov dword [SfxLastRamAdr],eax ; Save last ram address mov bl,[eax] ; Read Byte inc ebp ; Increase program counter mov [edi],ebx ; Store Result CLRFLAGS ret %endmacro ; test byte[SfxPOR],01h ; jnz .nozerocheck ; test byte[SfxPOR],02h ; jz .nodither ; **** Can pre-calculate [SfxSCBR] << 10 + [sfxramdata] ; Pre-calculate fxbit values from color register %macro drawpix4b 0 and [eax],edx and [eax+16],edx xor edx,0FFFFFFFFh mov ebx,[fxbit01pcal] and ebx,edx or [eax], ebx and edx,[fxbit23pcal] or [eax+16], edx %endmacro %macro drawpix4bd 0 and [eax],edx and [eax+16],edx xor edx,0FFFFFFFFh mov ebx,[fxbit45pcal] and ebx,edx or [eax], ebx and edx,[fxbit67pcal] or [eax+16], edx %endmacro %macro drawpix2b 0 and [eax],edx xor edx,0FFFFFFFFh and edx,[fxbit01pcal] or [eax], edx %endmacro %macro drawpix2bd 0 and [eax],edx xor edx,0FFFFFFFFh and edx,[fxbit45pcal] or [eax], edx %endmacro %macro drawpix8b 0 and [eax],edx and [eax+16],edx and [eax+32],edx and [eax+48],edx xor edx,0FFFFFFFFh mov ebx,[fxbit01pcal] and ebx,edx or [eax], ebx mov ebx,[fxbit23pcal] and ebx,edx or [eax+16], ebx mov ebx,[fxbit45pcal] and ebx,edx or [eax+32], ebx and edx,[fxbit67pcal] or [eax+48], edx %endmacro %macro drawpix8bd 0 and [eax],edx and [eax+16],edx and [eax+32],edx and [eax+48],edx xor edx,0FFFFFFFFh mov ebx,[fxbit45pcal] and ebx,edx or [eax], ebx mov ebx,[fxbit67pcal] and ebx,edx or [eax+16], ebx mov ebx,[fxbit01pcal] and ebx,edx or [eax+32], ebx and edx,[fxbit23pcal] or [eax+48], edx %endmacro %macro plotb 5 shl eax,%3 and ebx,07h add ebx,ebx add eax,ebx add eax,[SCBRrel] mov bl,[SfxR1] mov edx,[fxxand+ebx*4] %2 %endmacro %macro plotbz 5 shl eax,%3 and ebx,07h add ebx,ebx add eax,ebx add eax,[SCBRrel] mov bl,[SfxR1] mov edx,[fxxand+ebx*4] test byte[SfxCOLR],%5 jz .nodraw %2 %endmacro %macro plotbd 5 shl eax,%3 and ebx,07h add ebx,ebx add eax,ebx add eax,[SCBRrel] mov bl,[SfxR1] mov edx,[fxxand+ebx*4] mov bl,[SfxR1] xor bl,[SfxR2] test bl,01h jz near .nodither4b %4 inc word [SfxR1] %1 .nodither4b %2 %endmacro %macro plotbzd 5 shl eax,%3 and ebx,07h add ebx,ebx add eax,ebx add eax,[SCBRrel] mov bl,[SfxR1] mov edx,[fxxand+ebx*4] test byte[SfxCOLR],%5 jz near .nodraw mov bl,[SfxR1] xor bl,[SfxR2] test bl,01h jz .nodither4b %4 inc word [SfxR1] %1 .nodither4b %2 %endmacro %macro plotlines4b 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 ret, drawpix4b, 5, drawpix4bd, 0Fh .nodraw inc word [SfxR1] ret %endmacro %macro plotlines4bb 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 FXReturn, drawpix4b, 5, drawpix4bd, 0Fh .nodraw inc word [SfxR1] FXReturn %endmacro %macro plotlines2b 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 ret, drawpix2b, 4, drawpix2bd, 03h .nodraw inc word [SfxR1] ret %endmacro %macro plotlines2bb 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 FXReturn, drawpix2b, 4, drawpix2bd, 03h .nodraw inc word [SfxR1] FXReturn %endmacro %macro plotlines8b 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 ret, drawpix8b, 6, drawpix8bd, 0FFh .nodraw inc word [SfxR1] ret %endmacro %macro plotlines8bb 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 FXReturn, drawpix8b, 6, drawpix8bd, 0FFh .nodraw inc word [SfxR1] FXReturn %endmacro %macro plotlines8bl 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 ret, drawpix8b, 6, drawpix8bd, 0Fh .nodraw inc word [SfxR1] ret %endmacro %macro plotlines8bbl 1 mov ebx,[SfxR2] FETCHPIPE mov bh,[SfxR1] mov eax,[sfxclineloc] inc ebp mov eax,[eax+ebx*4] cmp eax,0FFFFFFFFh je near .nodraw %1 FXReturn, drawpix8b, 6, drawpix8bd, 0Fh .nodraw inc word [SfxR1] FXReturn %endmacro %macro ADDRN 1 ; V mov eax, [esi] ; Read Source mov ebx, [SfxR0+%1*4] FETCHPIPE add ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro ADCRN 1 ; V FETCHPIPE mov eax, [esi] ; Read Source mov ebx, [SfxR0+%1*4] shr byte[SfxCarry],1 adc ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro ADIRN 1 ; V mov eax, [esi] ; Read Source FETCHPIPE add ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro ADCIRN 1 ; V FETCHPIPE mov eax, [esi] ; Read Source shr byte[SfxCarry],1 adc ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro SUBRN 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] FETCHPIPE sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro SBCRN 1 ; V FETCHPIPE mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] cmp byte[SfxCarry],1 sbb ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro SUBIRN 1 ; V mov eax,[esi] ; Read Source FETCHPIPE sub ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro CMPRN 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] FETCHPIPE sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 mov [SfxSignZero],eax CLRFLAGS inc ebp ; Increase program counter ret %endmacro %macro ANDRN 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read RN FETCHPIPE and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro BICRN 1 ; V mov ebx,[SfxR0+%1*4] ; Read RN mov eax,[esi] ; Read Source xor ebx,0FFFFh FETCHPIPE and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro ANDIRN 1 ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,%1 inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro BICIRN 1 ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,%1 inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro MULTRN 1 ; V mov al,byte [esi] ; Read Source mov bl,byte [SfxR0+%1*4] ; Read RN FETCHPIPE imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro UMULTRN 1 ; V mov al,byte [esi] ; Read Source mov bl,byte [SfxR0+%1*4] ; Read RN FETCHPIPE mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro MULTIRN 1 ; V mov al,byte [esi] ; Read Source mov bl,%1 ; Read RN FETCHPIPE imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro UMULTIRN 1 ; V mov al,byte [esi] ; Read Source mov bl,%1 ; Read RN FETCHPIPE mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS ret %endmacro %macro LINK 1 ; Verified. mov eax,ebp sub eax,[SfxCPB] add eax,%1 FETCHPIPE mov word [SfxR11],ax CLRFLAGS inc ebp ret %endmacro %macro JMPRN 1 ; V FETCHPIPE mov eax,[SfxR0+%1*4] ; Read RN mov ebp,[SfxCPB] add ebp,eax CLRFLAGS ret %endmacro %macro LJMPRN 1 ; V FETCHPIPE mov eax,[SfxR0+%1*4] and eax,07Fh mov byte[SfxPBR],al ; mov byte[fxtrace+eax],1 mov eax,[SfxMemTable+eax*4] mov [SfxCPB],eax mov ebp,eax add ebp,[esi] ; Read RN mov dword [SfxCacheActive],0 push ecx call FxOp02 pop ecx dec ebp ret %endmacro %macro IBTRN 1 ; V movsx eax,byte[ebp] mov cl,[ebp+1] add ebp,2 mov [SfxR0+%1*4],ax CLRFLAGS ret %endmacro %macro LMSRN 1 ; Verified. xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram inc ebp mov [SfxR0+%1*4],bx ; Write data CLRFLAGS ret %endmacro %macro SMSRN 1 ; Verified. xor eax,eax mov al,[ebp] inc ebp add eax,eax mov cl,[ebp] add eax,[SfxRAMMem] mov ebx,[SfxR0+%1*4] ; Read data mov dword [SfxLastRamAdr],eax inc ebp mov [eax],bx ; Write word to ram CLRFLAGS ret %endmacro %macro FROMRN 1 ; V FETCHPIPE mov esi,SfxR0+%1*4 inc ebp ; Increase program counter call [FxTable+ecx*4] mov esi,SfxR0 ret %endmacro %macro ORRN 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read FETCHPIPE or eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro XORRN 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read FETCHPIPE xor eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro ORI 1 ; V mov eax,[esi] ; Read Source FETCHPIPE or eax,%1 inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro XORI 1 ; V mov eax,[esi] ; Read Source FETCHPIPE xor eax,%1 inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS ret %endmacro %macro INCRN 1 ; Verified inc word[SfxR0+%1*4] FETCHPIPE mov eax,[SfxR0+%1*4] ; Read Source mov [SfxSignZero],eax CLRFLAGS inc ebp ret %endmacro %macro DECRN 1 ; Verified dec word[SfxR0+%1*4] FETCHPIPE mov eax,[SfxR0+%1*4] ; Read Source mov [SfxR0+%1*4],eax mov [SfxSignZero],eax CLRFLAGS inc ebp ret %endmacro %macro IWTRN 1 ; aka LEA ; Verified. mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh add ebp,3 mov [SfxR0+%1*4],eax CLRFLAGS ret %endmacro %macro LMRN 1 ; Verified! xor eax,eax mov cl,[ebp+2] mov ax,[ebp] mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 add ebp,3 mov dh,[eax+ebx] mov word [SfxR0+%1*4],dx ; Store Word CLRFLAGS ret %endmacro %macro SMRN 1 ; Verified mov ebx,[SfxR0+%1*4] mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh mov dx,bx mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov [eax+ebx],dl xor eax,1 add ebp,3 mov [eax+ebx],dh CLRFLAGS ret %endmacro %macro PackEsiEdi 0 mov eax,[SfxSREG] shl eax,2 add eax,SfxR0 mov esi,eax mov eax,[SfxDREG] shl eax,2 add eax,SfxR0 mov edi,eax mov eax,[SfxRAMBR] shl eax,16 add eax,[sfxramdata] mov dword [SfxRAMMem],eax %endmacro %macro UnPackEsiEdi 0 mov eax,esi sub eax,SfxR0 shr eax,2 mov [SfxSREG],eax mov eax,edi sub eax,SfxR0 shr eax,2 mov [SfxDREG],eax %endmacro zsnes-1.36/src/chips/fxemu2b.asm0100644000175000017500000003373207267141100016141 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM FxTable,FxTableb,FxTablec,SfxB,SfxCPB,SfxCROM,SfxCarry,SfxOverflow EXTSYM SfxR0,SfxR14,SfxR15,SfxRomBuffer,SfxSignZero,withr15sk NEWSYM FxEmu2BAsmStart %include "chips/fxemu2.mac" %include "chips/fxemu2b.mac" NEWSYM FxOpb05 ; BRA branch always ; Verified. movsx eax,byte[ebp] mov cl,[ebp+1] inc ebp add ebp,eax call [FxTableb+ecx*4] ret NEWSYM FxOpb06 ; BGE branch on greater or equals ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jnz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb07 ; BLT branch on lesss than ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb08 ; BNE branch on not equal ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb09 ; BEQ branch on equal (z=1) ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jnz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0A ; BPL branch on plus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0B ; BMI branch on minus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0C ; BCC branch on carry clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0D ; BCS branch on carry set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0E ; BVC branch on overflow clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb0F ; BVS branch on overflow set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTableb+ecx*4] ret .nojump inc ebp call [FxTableb+ecx*4] ret NEWSYM FxOpb10 ; TO RN set register n as destination register TORNb 0 NEWSYM FxOpb11 ; TO RN set register n as destination register TORNb 1 NEWSYM FxOpb12 ; TO RN set register n as destination register TORNb 2 NEWSYM FxOpb13 ; TO RN set register n as destination register TORNb 3 NEWSYM FxOpb14 ; TO RN set register n as destination register TORNb 4 NEWSYM FxOpb15 ; TO RN set register n as destination register TORNb 5 NEWSYM FxOpb16 ; TO RN set register n as destination register TORNb 6 NEWSYM FxOpb17 ; TO RN set register n as destination register TORNb 7 NEWSYM FxOpb18 ; TO RN set register n as destination register TORNb 8 NEWSYM FxOpb19 ; TO RN set register n as destination register TORNb 9 NEWSYM FxOpb1A ; TO RN set register n as destination register TORNb 10 NEWSYM FxOpb1B ; TO RN set register n as destination register TORNb 11 NEWSYM FxOpb1C ; TO RN set register n as destination register TORNb 12 NEWSYM FxOpb1D ; TO RN set register n as destination register TORNb 13 NEWSYM FxOpb1E ; TO RN set register n as destination register FETCHPIPE test dword [SfxB],1 jnz .VersionB mov edi,SfxR0+14*4 inc ebp mov eax,ebp sub eax,[SfxCPB] mov dword[withr15sk],1 mov [SfxR15],eax call [FxTableb+ecx*4] mov edi,SfxR0 UpdateR14 ret .VersionB mov eax,[esi] ; Read Source mov dword[withr15sk],1 mov [SfxR0+14*4],eax ; Write CLRFLAGS UpdateR14 inc ebp ; Increase program counter ret NEWSYM FxOpb1F ; TO RN set register n as destination register FETCHPIPE test dword [SfxB],1 jnz .VersionB mov edi,SfxR0+15*4 inc ebp mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTableb+ecx*4] mov ebp,[SfxCPB] mov dword[withr15sk],1 add ebp,[SfxR15] mov edi,SfxR0 ret .VersionB mov eax,[esi] ; Read Source mov ebp,[SfxCPB] mov dword[withr15sk],1 add ebp,eax CLRFLAGS ret NEWSYM FxOpb3D ; ALT1 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,01h inc ebp mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTableb+ecx*4] xor ch,ch ret NEWSYM FxOpb3E ; ALT2 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,02h inc ebp mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTable+ecx*4] xor ch,ch ret NEWSYM FxOpb3F ; ALT3 set alt3 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,03h inc ebp mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTable+ecx*4] xor ch,ch ret NEWSYM FxOpbB0 ; FROM rn set source register FROMRNb 0 NEWSYM FxOpbB1 ; FROM rn set source register FROMRNb 1 NEWSYM FxOpbB2 ; FROM rn set source register FROMRNb 2 NEWSYM FxOpbB3 ; FROM rn set source register FROMRNb 3 NEWSYM FxOpbB4 ; FROM rn set source register FROMRNb 4 NEWSYM FxOpbB5 ; FROM rn set source register FROMRNb 5 NEWSYM FxOpbB6 ; FROM rn set source register FROMRNb 6 NEWSYM FxOpbB7 ; FROM rn set source register FROMRNb 7 NEWSYM FxOpbB8 ; FROM rn set source register FROMRNb 8 NEWSYM FxOpbB9 ; FROM rn set source register FROMRNb 9 NEWSYM FxOpbBA ; FROM rn set source register FROMRNb 10 NEWSYM FxOpbBB ; FROM rn set source register FROMRNb 11 NEWSYM FxOpbBC ; FROM rn set source register FROMRNb 12 NEWSYM FxOpbBD ; FROM rn set source register FROMRNb 13 NEWSYM FxOpbBE ; FROM rn set source register FROMRNb 14 NEWSYM FxOpbBF ; FROM rn set source register test dword [SfxB],1 jnz .VersionB mov esi,SfxR0+15*4 inc ebp ; Increase program counter mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTableb+ecx*4] mov esi,SfxR0 ret .VersionB FETCHPIPE mov eax,ebp sub eax,[SfxCPB] inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax shr al,7 mov byte[SfxOverflow],al CLRFLAGS ret NEWSYM FxOpc05 ; BRA branch always ; Verified. movsx eax,byte[ebp] mov cl,[ebp+1] inc ebp add ebp,eax call [FxTablec+ecx*4] ret NEWSYM FxOpc06 ; BGE branch on greater or equals ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jnz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc07 ; BLT branch on lesss than ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc08 ; BNE branch on not equal ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc09 ; BEQ branch on equal (z=1) ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jnz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0A ; BPL branch on plus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0B ; BMI branch on minus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0C ; BCC branch on carry clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0D ; BCS branch on carry set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0E ; BVC branch on overflow clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc0F ; BVS branch on overflow set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTablec+ecx*4] ret .nojump inc ebp call [FxTablec+ecx*4] ret NEWSYM FxOpc10 ; TO RN set register n as destination register TORNc 0 NEWSYM FxOpc11 ; TO RN set register n as destination register TORNc 1 NEWSYM FxOpc12 ; TO RN set register n as destination register TORNc 2 NEWSYM FxOpc13 ; TO RN set register n as destination register TORNc 3 NEWSYM FxOpc14 ; TO RN set register n as destination register TORNc 4 NEWSYM FxOpc15 ; TO RN set register n as destination register TORNc 5 NEWSYM FxOpc16 ; TO RN set register n as destination register TORNc 6 NEWSYM FxOpc17 ; TO RN set register n as destination register TORNc 7 NEWSYM FxOpc18 ; TO RN set register n as destination register TORNc 8 NEWSYM FxOpc19 ; TO RN set register n as destination register TORNc 9 NEWSYM FxOpc1A ; TO RN set register n as destination register TORNc 10 NEWSYM FxOpc1B ; TO RN set register n as destination register TORNc 11 NEWSYM FxOpc1C ; TO RN set register n as destination register TORNc 12 NEWSYM FxOpc1D ; TO RN set register n as destination register TORNc 13 NEWSYM FxOpc1E ; TO RN set register n as destination register FETCHPIPE mov eax,[esi] ; Read Source mov [SfxR0+14*4],eax ; Write CLRFLAGS UpdateR14 inc ebp ; Increase program counter ret NEWSYM FxOpc1F ; TO RN set register n as destination register FETCHPIPE mov eax,[esi] ; Read Source mov ebp,[SfxCPB] mov [SfxR15],eax add ebp,eax CLRFLAGS ret NEWSYM FxOpc3D ; ALT1 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,01h inc ebp call [FxTablec+ecx*4] xor ch,ch ret NEWSYM FxOpc3E ; ALT2 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,02h inc ebp call [FxTablec+ecx*4] xor ch,ch ret NEWSYM FxOpc3F ; ALT3 set alt3 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,03h inc ebp call [FxTablec+ecx*4] xor ch,ch ret NEWSYM FxOpcB0 ; FROM rn set source register FROMRNc 0 NEWSYM FxOpcB1 ; FROM rn set source register FROMRNc 1 NEWSYM FxOpcB2 ; FROM rn set source register FROMRNc 2 NEWSYM FxOpcB3 ; FROM rn set source register FROMRNc 3 NEWSYM FxOpcB4 ; FROM rn set source register FROMRNc 4 NEWSYM FxOpcB5 ; FROM rn set source register FROMRNc 5 NEWSYM FxOpcB6 ; FROM rn set source register FROMRNc 6 NEWSYM FxOpcB7 ; FROM rn set source register FROMRNc 7 NEWSYM FxOpcB8 ; FROM rn set source register FROMRNc 8 NEWSYM FxOpcB9 ; FROM rn set source register FROMRNc 9 NEWSYM FxOpcBA ; FROM rn set source register FROMRNc 10 NEWSYM FxOpcBB ; FROM rn set source register FROMRNc 11 NEWSYM FxOpcBC ; FROM rn set source register FROMRNc 12 NEWSYM FxOpcBD ; FROM rn set source register FROMRNc 13 NEWSYM FxOpcBE ; FROM rn set source register FROMRNc 14 NEWSYM FxOpcBF ; FROM rn set source register FETCHPIPE mov eax,ebp sub eax,[SfxCPB] inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax shr al,7 mov byte[SfxOverflow],al CLRFLAGS ret NEWSYM FxEmu2BAsmEnd zsnes-1.36/src/chips/fxemu2b.mac0100644000175000017500000000403607267141100016114 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %macro TORNb 1 ; V FETCHPIPE test dword [SfxB],1 jnz .VersionB mov edi, SfxR0+%1*4 inc ebp ; Increase program counter mov eax,ebp sub eax,[SfxCPB] mov dword[withr15sk],1 mov [SfxR15],eax call [FxTableb+ecx*4] mov edi,SfxR0 ret .VersionB mov eax,[esi] ; Read Source mov dword[withr15sk],1 inc ebp ; Increase program counter mov [SfxR0+%1*4],eax ; Write CLRFLAGS ret %endmacro %macro FROMRNb 1 ; V FETCHPIPE test dword [SfxB],1 jnz .VersionB mov esi,SfxR0+%1*4 inc ebp ; Increase program counter call [FxTable+ecx*4] mov esi,SfxR0 ret .VersionB mov eax,[SfxR0+%1*4] ; Read inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax shr al,7 mov byte[SfxOverflow],al CLRFLAGS ret %endmacro %macro TORNc 1 ; V FETCHPIPE mov eax,[esi] ; Read Source inc ebp ; Increase program counter mov [SfxR0+%1*4],eax ; Write CLRFLAGS ret %endmacro %macro FROMRNc 1 ; V FETCHPIPE mov eax,[SfxR0+%1*4] ; Read inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax shr al,7 mov byte[SfxOverflow],al CLRFLAGS ret %endmacro zsnes-1.36/src/chips/fxemu2c.asm0100644000175000017500000021143707267141100016142 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM FXEndLoop,FlushCache,FxOp02,FxTable,FxTableb,FxTablec,FxTabled EXTSYM NumberOfOpcodes,SfxB,SfxCBR,SfxCFGR,SfxCOLR,SfxCPB,SfxCROM EXTSYM SfxCacheActive,SfxCarry,SfxLastRamAdr,SfxMemTable,SfxOverflow EXTSYM SfxPBR,SfxPIPE,SfxPOR,SfxR0,SfxR1,SfxR11,SfxR12,SfxR13,SfxR14 EXTSYM SfxR15,SfxR2,SfxR4,SfxR6,SfxR7,SfxR8,SfxRAMBR,SfxRAMMem,SfxROMBR EXTSYM SfxRomBuffer,SfxSCBR,SfxSCMR,SfxSFR,SfxSignZero,SfxnRamBanks,flagnz EXTSYM sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc,sfxramdata EXTSYM withr15sk,sfxclineloc,SCBRrel,ChangeOps EXTSYM fxbit01pcal,fxbit23pcal,fxbit45pcal,fxbit67pcal EXTSYM fxbit01,fxbit23,fxbit45,fxbit67 EXTSYM fxxand EXTSYM PLOTJmpa,PLOTJmpb NEWSYM FxEmu2CAsmStart %include "chips/fxemu2.mac" %include "chips/fxemu2b.mac" %include "chips/fxemu2c.mac" ALIGN32 NEWSYM FxOpd00 ; STOP stop GSU execution (and maybe generate an IRQ) ; Verified. FETCHPIPE mov [SfxPIPE],cl and dword [SfxSFR],0FFFFh-32 ; Clear Go flag (set to 1 when the GSU is running) test dword [SfxCFGR],080h ; Check if the interrupt generation is on jnz .NoIRQ or dword [SfxSFR],08000h ; Set IRQ Flag .NoIRQ CLRFLAGS inc ebp mov eax,[NumberOfOpcodes] add eax,0F0000000h add [ChangeOps],eax mov dword [NumberOfOpcodes],1 jmp FXEndLoop FXReturn NEWSYM FxOpd01 ; NOP no operation ; Verified. FETCHPIPE CLRFLAGS inc ebp ; Increase program counter FXReturn NEWSYM FxOpd02 ; CACHE reintialize GSU cache mov eax,ebp FETCHPIPE sub eax,[SfxCPB] and eax,0FFF0h cmp dword [SfxCBR],eax je .SkipUpdate cmp byte [SfxCacheActive],1 je .SkipUpdate mov dword [SfxCBR],eax mov dword [SfxCacheActive],1 call FlushCache .SkipUpdate CLRFLAGS inc ebp ; Increase program counter FXReturn NEWSYM FxOpd03 ; LSR logic shift right ; Verified. mov eax,[esi] ; Read Source FETCHPIPE mov [SfxCarry],al and byte[SfxCarry],1 shr ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd04 ; ROL rotate left (RCL?) ; V shr byte[SfxCarry],1 mov eax,[esi] ; Read Source FETCHPIPE rcl ax,1 rcl byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd05 ; BRA branch always ; Verified. movsx eax,byte[ebp] mov cl,[ebp+1] inc ebp add ebp,eax call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd06 ; BGE branch on greater or equals ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jnz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd07 ; BLT branch on lesss than ; Verified. movsx eax,byte[ebp] mov ebx,[SfxSignZero] shr ebx,15 inc ebp xor bl,[SfxOverflow] mov cl,[ebp] test bl,01h jz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd08 ; BNE branch on not equal ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd09 ; BEQ branch on equal (z=1) ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],0FFFFh mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0A ; BPL branch on plus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0B ; BMI branch on minus ; Verified. movsx eax,byte[ebp] inc ebp test dword[SfxSignZero],088000h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0C ; BCC branch on carry clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0D ; BCS branch on carry set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxCarry],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0E ; BVC branch on overflow clear ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jnz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd0F ; BVS branch on overflow set ; Verified. movsx eax,byte[ebp] inc ebp test byte[SfxOverflow],01h mov cl,[ebp] jz .nojump add ebp,eax call [FxTable+ecx*4] FXReturn2 .nojump inc ebp call [FxTable+ecx*4] FXReturn2 NEWSYM FxOpd10 ; TO RN set register n as destination register TORNd 0 NEWSYM FxOpd11 ; TO RN set register n as destination register TORNd 1 NEWSYM FxOpd12 ; TO RN set register n as destination register TORNd 2 NEWSYM FxOpd13 ; TO RN set register n as destination register TORNd 3 NEWSYM FxOpd14 ; TO RN set register n as destination register TORNd 4 NEWSYM FxOpd15 ; TO RN set register n as destination register TORNd 5 NEWSYM FxOpd16 ; TO RN set register n as destination register TORNd 6 NEWSYM FxOpd17 ; TO RN set register n as destination register TORNd 7 NEWSYM FxOpd18 ; TO RN set register n as destination register TORNd 8 NEWSYM FxOpd19 ; TO RN set register n as destination register TORNd 9 NEWSYM FxOpd1A ; TO RN set register n as destination register TORNd 10 NEWSYM FxOpd1B ; TO RN set register n as destination register TORNd 11 NEWSYM FxOpd1C ; TO RN set register n as destination register TORNd 12 NEWSYM FxOpd1D ; TO RN set register n as destination register TORNd 13 NEWSYM FxOpd1E ; TO RN set register n as destination register FETCHPIPE mov edi,SfxR0+14*4 inc ebp call [FxTable+ecx*4] mov edi,SfxR0 UpdateR14 FXReturn NEWSYM FxOpd1F ; TO RN set register n as destination register FETCHPIPE mov edi,SfxR0+15*4 inc ebp call [FxTable+ecx*4] mov ebp,[SfxCPB] add ebp,[SfxR15] mov edi,SfxR0 FXReturn NEWSYM FxOpd20 ; WITH set register n as source and destination register WITHc 0 NEWSYM FxOpd21 ; WITH set register n as source and destination register WITHc 1 NEWSYM FxOpd22 ; WITH set register n as source and destination register WITHc 2 NEWSYM FxOpd23 ; WITH set register n as source and destination register WITHc 3 NEWSYM FxOpd24 ; WITH set register n as source and destination register WITHc 4 NEWSYM FxOpd25 ; WITH set register n as source and destination register WITHc 5 NEWSYM FxOpd26 ; WITH set register n as source and destination register WITHc 6 NEWSYM FxOpd27 ; WITH set register n as source and destination register WITHc 7 NEWSYM FxOpd28 ; WITH set register n as source and destination register WITHc 8 NEWSYM FxOpd29 ; WITH set register n as source and destination register WITHc 9 NEWSYM FxOpd2A ; WITH set register n as source and destination register WITHc 10 NEWSYM FxOpd2B ; WITH set register n as source and destination register WITHc 11 NEWSYM FxOpd2C ; WITH set register n as source and destination register WITHc 12 NEWSYM FxOpd2D ; WITH set register n as source and destination register WITHc 13 NEWSYM FxOpd2E ; WITH set register n as source and destination register FETCHPIPE mov esi,SfxR0+14*4 mov edi,SfxR0+14*4 mov dword [SfxB],1 inc ebp call [FxTablec+ecx*4] mov dword [SfxB],0 ; Clear B Flag mov esi,SfxR0 mov edi,SfxR0 UpdateR14 FXReturn NEWSYM FxOpd2F ; WITH set register n as source and destination register FETCHPIPE mov esi,SfxR0+15*4 mov edi,SfxR0+15*4 mov dword [SfxB],1 inc ebp mov eax,ebp sub eax,[SfxCPB] mov dword[withr15sk],0 mov [SfxR15],eax call [FxTableb+ecx*4] cmp dword[withr15sk],1 je .skip mov ebp,[SfxCPB] add ebp,[SfxR15] .skip mov dword [SfxB],0 ; Clear B Flag mov esi,SfxR0 mov edi,SfxR0 FXReturn NEWSYM FxOpd30 ; STW RN store word STWRNc 0 NEWSYM FxOpd31 ; STW RN store word STWRNc 1 NEWSYM FxOpd32 ; STW RN store word STWRNc 2 NEWSYM FxOpd33 ; STW RN store word STWRNc 3 NEWSYM FxOpd34 ; STW RN store word STWRNc 4 NEWSYM FxOpd35 ; STW RN store word STWRNc 5 NEWSYM FxOpd36 ; STW RN store word STWRNc 6 NEWSYM FxOpd37 ; STW RN store word STWRNc 7 NEWSYM FxOpd38 ; STW RN store word STWRNc 8 NEWSYM FxOpd39 ; STW RN store word STWRNc 9 NEWSYM FxOpd3A ; STW RN store word STWRNc 10 NEWSYM FxOpd3B ; STW RN store word STWRNc 11 NEWSYM FxOpd30A1 ; STB RN store byte STBRNc 0 NEWSYM FxOpd31A1 ; STB RN store byte STBRNc 1 NEWSYM FxOpd32A1 ; STB RN store byte STBRNc 2 NEWSYM FxOpd33A1 ; STB RN store byte STBRNc 3 NEWSYM FxOpd34A1 ; STB RN store byte STBRNc 4 NEWSYM FxOpd35A1 ; STB RN store byte STBRNc 5 NEWSYM FxOpd36A1 ; STB RN store byte STBRNc 6 NEWSYM FxOpd37A1 ; STB RN store byte STBRNc 7 NEWSYM FxOpd38A1 ; STB RN store byte STBRNc 8 NEWSYM FxOpd39A1 ; STB RN store byte STBRNc 9 NEWSYM FxOpd3AA1 ; STB RN store byte STBRNc 10 NEWSYM FxOpd3BA1 ; STB RN store byte STBRNc 11 NEWSYM FxOpd3C ; LOOP decrement loop counter, and branch on not zero ; V dec word [SfxR12] ; decrement loop counter FETCHPIPE mov eax,[SfxR12] mov [SfxSignZero],eax or eax,eax jz .NoBranch mov eax,dword [SfxR13] mov ebp,[SfxCPB] add ebp,eax CLRFLAGS FXReturn .NoBranch inc ebp CLRFLAGS FXReturn NEWSYM FxOpd3D ; ALT1 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,01h inc ebp call [FxTable+ecx*4] xor ch,ch FXReturn NEWSYM FxOpd3E ; ALT2 set alt1 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,02h inc ebp call [FxTable+ecx*4] xor ch,ch FXReturn NEWSYM FxOpd3F ; ALT3 set alt3 mode ; Verified. FETCHPIPE mov dword [SfxB],0 or ch,03h inc ebp call [FxTable+ecx*4] xor ch,ch FXReturn NEWSYM FxOpd40 ; LDW RN load word from RAM LDWRNc 0 NEWSYM FxOpd41 ; LDW RN load word from RAM LDWRNc 1 NEWSYM FxOpd42 ; LDW RN load word from RAM LDWRNc 2 NEWSYM FxOpd43 ; LDW RN load word from RAM LDWRNc 3 NEWSYM FxOpd44 ; LDW RN load word from RAM LDWRNc 4 NEWSYM FxOpd45 ; LDW RN load word from RAM LDWRNc 5 NEWSYM FxOpd46 ; LDW RN load word from RAM LDWRNc 6 NEWSYM FxOpd47 ; LDW RN load word from RAM LDWRNc 7 NEWSYM FxOpd48 ; LDW RN load word from RAM LDWRNc 8 NEWSYM FxOpd49 ; LDW RN load word from RAM LDWRNc 9 NEWSYM FxOpd4A ; LDW RN load word from RAM LDWRNc 10 NEWSYM FxOpd4B ; LDW RN load word from RAM LDWRNc 11 NEWSYM FxOpd40A1 ; LDB RN load byte from RAM LDBRNc 0 NEWSYM FxOpd41A1 ; LDB RN load byte from RAM LDBRNc 1 NEWSYM FxOpd42A1 ; LDB RN load byte from RAM LDBRNc 2 NEWSYM FxOpd43A1 ; LDB RN load byte from RAM LDBRNc 3 NEWSYM FxOpd44A1 ; LDB RN load byte from RAM LDBRNc 4 NEWSYM FxOpd45A1 ; LDB RN load byte from RAM LDBRNc 5 NEWSYM FxOpd46A1 ; LDB RN load byte from RAM LDBRNc 6 NEWSYM FxOpd47A1 ; LDB RN load byte from RAM LDBRNc 7 NEWSYM FxOpd48A1 ; LDB RN load byte from RAM LDBRNc 8 NEWSYM FxOpd49A1 ; LDB RN load byte from RAM LDBRNc 9 NEWSYM FxOpd4AA1 ; LDB RN load byte from RAM LDBRNc 10 NEWSYM FxOpd4BA1 ; LDB RN load byte from RAM LDBRNc 11 NEWSYM FxOpd4C1284b ; PLOT 4bit plotlines4bb plotb NEWSYM FxOpd4C1284bz ; PLOT 4bit, zero check plotlines4bb plotbz NEWSYM FxOpd4C1284bd ; PLOT 4bit, dither plotlines4bb plotbd NEWSYM FxOpd4C1284bzd ; PLOT 4bit, zero check + dither plotlines4bb plotbzd NEWSYM FxOpd4C1282b ; PLOT 2bit plotlines2bb plotb NEWSYM FxOpd4C1282bz ; PLOT 2bit, zero check plotlines2bb plotbz NEWSYM FxOpd4C1282bd ; PLOT 2bit, dither plotlines2bb plotbd NEWSYM FxOpd4C1282bzd ; PLOT 2bit, zero check + dither plotlines2bb plotbzd NEWSYM FxOpd4C1288b ; PLOT 8bit plotlines8bb plotb NEWSYM FxOpd4C1288bz ; PLOT 8bit, zero check plotlines8bb plotbz NEWSYM FxOpd4C1288bd ; PLOT 8bit, dither plotlines8bb plotb NEWSYM FxOpd4C1288bzd ; PLOT 8bit, zero check + dither plotlines8bb plotbz NEWSYM FxOpd4C1288bl ; PLOT 8bit plotlines8bbl plotb NEWSYM FxOpd4C1288bzl ; PLOT 8bit, zero check plotlines8bbl plotbz NEWSYM FxOpd4C1288bdl ; PLOT 8bit, dither plotlines8bbl plotb NEWSYM FxOpd4C1288bzdl ; PLOT 8bit, zero check + dither plotlines8bbl plotbz NEWSYM FxOpd4C ; PLOT plot pixel with R1,R2 as x,y and the color register as the color jmp FxOpd4C1284b FETCHPIPE inc ebp CLRFLAGS mov ebx,[SfxR2] mov bh,[SfxR1] mov eax,[sfxclineloc] mov ebx,[eax+ebx*4] cmp ebx,0FFFFFFFFh je near .nodraw xor eax,eax ; bits 5/2 : 00 = 128 pixels, 01 = 160 pixels, 10 = 192 pixels, 11 = obj ; bits 1/0 : 00 = 4 color, 01 = 16-color, 10 = not used, 11 = 256 color ; 192 pixels = 24 tiles, 160 pixels = 20 tiles, 128 pixels = 16 tiles ; 16+8(4/3) 16+4(4/2) 16(4/0) push ecx mov al,[SfxSCMR] and al,00000011b ; 4 + 32 cmp al,0 je near .colors4 cmp al,3 je near .colors256 shl ebx,5 ; x32 (16 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_16 test byte[SfxCOLR],0Fh jz .nodraw .nozerocheck_16 mov dl,[SfxCOLR] test byte[SfxPOR],02h jz .nodither4b mov dh,[SfxR1] xor dh,[SfxR2] test dh,01h jz .nodither4b shr dh,4 .nodither4b and byte[eax],bh and byte[eax+1],bh and byte[eax+16],bh and byte[eax+17],bh test dl,01h jz .nodraw_16 or byte[eax], bl .nodraw_16 test dl,02h jz .nodraw2_16 or byte[eax+1], bl .nodraw2_16 test dl,04h jz .nodraw3_16 or byte[eax+16],bl .nodraw3_16 test dl,08h jz .nodraw4_16 or byte[eax+17],bl .nodraw4_16 .nodraw inc word [SfxR1] FXReturn .colors4 shl ebx,4 ; x16 (4 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_4 test byte[SfxCOLR],03h jz .noplot_4 .nozerocheck_4 mov dl,[SfxCOLR] test byte[SfxPOR],02h jz .nodither2b mov dh,[SfxR1] xor dh,[SfxR2] test dh,01h jz .nodither2b shr dh,4 .nodither2b and byte[eax],bh and byte[eax+1],bh test dl,01h jz .nodraw_4 or byte[eax], bl .nodraw_4 test dl,02h jz .nodraw2_4 or byte[eax+1], bl .nodraw2_4 .noplot_4 inc word [SfxR1] FXReturn .colors256 shl ebx,6 ; x64 (256 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx test byte[SfxPOR],01h jnz .nozerocheck_256 mov dl,0FFh test byte[SfxPOR],08h jz .nozerocheckb_256 mov dl,0Fh .nozerocheckb_256 test byte[SfxCOLR],dl jz .noplot_256 .nozerocheck_256 mov dl,[SfxCOLR] and byte[eax],bh and byte[eax+1],bh and byte[eax+16],bh and byte[eax+17],bh and byte[eax+32],bh and byte[eax+33],bh and byte[eax+48],bh and byte[eax+49],bh test dl,01h jz .nodraw_256 or byte[eax], bl .nodraw_256 test dl,02h jz .nodraw2_256 or byte[eax+1], bl .nodraw2_256 test dl,04h jz .nodraw3_256 or byte[eax+16],bl .nodraw3_256 test dl,08h jz .nodraw4_256 or byte[eax+17],bl .nodraw4_256 test dl,10h jz .nodraw5_256 or byte[eax+32], bl .nodraw5_256 test dl,20h jz .nodraw6_256 or byte[eax+33], bl .nodraw6_256 test dl,40h jz .nodraw7_256 or byte[eax+48],bl .nodraw7_256 test dl,80h jz .nodraw8_256 or byte[eax+49],bl .nodraw8_256 .noplot_256 inc word [SfxR1] FXReturn .prevx dw 0 .prevy dw 0 NEWSYM FxOpd4CA1 ; RPIX read color of the pixel with R1,R2 as x,y FETCHPIPE mov ebx,[SfxR2] mov bh,[SfxR1] test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov ebx,[eax+ebx*4] cmp ebx,0FFFFFFFFh je near .nodraw xor eax,eax ; bits 5/2 : 00 = 128 pixels, 01 = 160 pixels, 10 = 192 pixels, 11 = obj ; bits 1/0 : 00 = 4 color, 01 = 16-color, 10 = not used, 11 = 256 color ; 192 pixels = 24 tiles, 160 pixels = 20 tiles, 128 pixels = 16 tiles ; 16+8(4/3) 16+4(4/2) 16(4/0) push ecx mov al,[SfxSCMR] and al,00000011b ; 4 + 32 cmp al,0 je near .colors4 cmp al,3 je near .colors256 shl ebx,5 ; x32 (16 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl pop ecx xor bh,bh test byte[eax],bl jz .nodraw_16 or bh,01h .nodraw_16 test byte[eax+1],bl jz .nodraw2_16 or bh,02h .nodraw2_16 test byte[eax+16],bl jz .nodraw3_16 or bh,04h .nodraw3_16 test byte[eax+17],bl jz .nodraw4_16 or bh,08h .nodraw4_16 .nodraw mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx FXReturn .colors4 shl ebx,4 ; x16 (4 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx xor bh,bh test byte[eax],bl jz .nodraw_4 or bh,01h .nodraw_4 test byte[eax+1],bl jz .nodraw2_4 or bh,02h .nodraw2_4 mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx FXReturn .colors256 shl ebx,6 ; x64 (256 colors) mov al,[SfxSCBR] shl eax,10 ; Get SFX address add eax,ebx add eax,[sfxramdata] mov ebx,[SfxR2] and ebx,07h shl ebx,1 add eax,ebx mov cl,[SfxR1] and cl,07h xor cl,07h mov bl,1 shl bl,cl mov bh,bl xor bh,0FFh pop ecx xor bh,bh test byte[eax],bl jz .nodraw_256 or bh,01h .nodraw_256 test byte[eax+1],bl jz .nodraw2_256 or bh,02h .nodraw2_256 test byte[eax+16],bl jz .nodraw3_256 or bh,04h .nodraw3_256 test byte[eax+17],bl jz .nodraw4_256 or bh,08h .nodraw4_256 test byte[eax+32],bl jz .nodraw5_256 or bh,10h .nodraw5_256 test byte[eax+33],bl jz .nodraw6_256 or bh,20h .nodraw6_256 test byte[eax+48],bl jz .nodraw7_256 or bh,40h .nodraw7_256 test byte[eax+49],bl jz .nodraw8_256 or bh,80h .nodraw8_256 mov bl,bh and ebx,0FFh inc ebp ; UpdateR14 CLRFLAGS mov [edi],ebx ; Write Destination mov [flagnz],ebx FXReturn NEWSYM FxOpd4D ; SWAP swap upper and lower byte of a register ; V mov eax,[esi] ; Read Source FETCHPIPE ror ax,8 inc ebp ; Increase program counter mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd4E ; COLOR copy source register to color register ; V FETCHPIPE mov eax,[esi] ; Read Source ; if bit 3 of SfxPOR is set, then don't modify the upper 4 bits test byte[SfxPOR],04h jz .nohighnibble mov bl,al shr bl,4 and al,0F0h or al,bl .nohighnibble test byte[SfxPOR],08h jnz .preserveupper cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx .nocolchange CLRFLAGS inc ebp ; Increase program counter FXReturn .preserveupper mov bl,[SfxCOLR] and al,0Fh and bl,0F0h or al,bl cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx CLRFLAGS inc ebp ; Increase program counter FXReturn NEWSYM FxOpd4EA1 ; CMODE set plot option register ; V FETCHPIPE mov eax,[esi] ; Read Source inc ebp ; Increase program counter mov dword [SfxPOR],eax test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov [sfxclineloc],eax push ebx mov al,[SfxSCMR] and eax,00000011b mov bl,[SfxPOR] and bl,0Fh shl bl,2 or al,bl mov ebx,[PLOTJmpb+eax*4] mov eax,[PLOTJmpa+eax*4] mov dword [FxTable+4Ch*4],eax mov dword [FxTableb+4Ch*4],eax mov dword [FxTablec+4Ch*4],eax mov dword [FxTabled+4Ch*4],ebx pop ebx CLRFLAGS FXReturn NEWSYM FxOpd4F ; NOT perform exclusive exor with 1 on all bits ; V mov eax,[esi] ; Read Source FETCHPIPE xor eax,0FFFFh inc ebp ; Increase program counter mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd50 ; ADD RN add, register + register ADDRNc 0 NEWSYM FxOpd51 ; ADD RN add, register + register ADDRNc 1 NEWSYM FxOpd52 ; ADD RN add, register + register ADDRNc 2 NEWSYM FxOpd53 ; ADD RN add, register + register ADDRNc 3 NEWSYM FxOpd54 ; ADD RN add, register + register ADDRNc 4 NEWSYM FxOpd55 ; ADD RN add, register + register ADDRNc 5 NEWSYM FxOpd56 ; ADD RN add, register + register ADDRNc 6 NEWSYM FxOpd57 ; ADD RN add, register + register ADDRNc 7 NEWSYM FxOpd58 ; ADD RN add, register + register ADDRNc 8 NEWSYM FxOpd59 ; ADD RN add, register + register ADDRNc 9 NEWSYM FxOpd5A ; ADD RN add, register + register ADDRNc 10 NEWSYM FxOpd5B ; ADD RN add, register + register ADDRNc 11 NEWSYM FxOpd5C ; ADD RN add, register + register ADDRNc 12 NEWSYM FxOpd5D ; ADD RN add, register + register ADDRNc 13 NEWSYM FxOpd5E ; ADD RN add, register + register ADDRNc 14 NEWSYM FxOpd5F ; ADD RN add, register + register FETCHPIPE mov eax, [esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] add ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd50A1 ; ADC RN add with carry, register + register ADCRNc 0 NEWSYM FxOpd51A1 ; ADC RN add with carry, register + register ADCRNc 1 NEWSYM FxOpd52A1 ; ADC RN add with carry, register + register ADCRNc 2 NEWSYM FxOpd53A1 ; ADC RN add with carry, register + register ADCRNc 3 NEWSYM FxOpd54A1 ; ADC RN add with carry, register + register ADCRNc 4 NEWSYM FxOpd55A1 ; ADC RN add with carry, register + register ADCRNc 5 NEWSYM FxOpd56A1 ; ADC RN add with carry, register + register ADCRNc 6 NEWSYM FxOpd57A1 ; ADC RN add with carry, register + register ADCRNc 7 NEWSYM FxOpd58A1 ; ADC RN add with carry, register + register ADCRNc 8 NEWSYM FxOpd59A1 ; ADC RN add with carry, register + register ADCRNc 9 NEWSYM FxOpd5AA1 ; ADC RN add with carry, register + register ADCRNc 10 NEWSYM FxOpd5BA1 ; ADC RN add with carry, register + register ADCRNc 11 NEWSYM FxOpd5CA1 ; ADC RN add with carry, register + register ADCRNc 12 NEWSYM FxOpd5DA1 ; ADC RN add with carry, register + register ADCRNc 13 NEWSYM FxOpd5EA1 ; ADC RN add with carry, register + register ADCRNc 14 NEWSYM FxOpd5FA1 ; ADC RN add with carry, register + register FETCHPIPE mov eax, [esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] shr byte[SfxCarry],1 adc ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn ; Weird Opdode (FxOpd50A2, add 0, wow!) NEWSYM FxOpd50A2 ; ADI RN add, register + immediate ADIRNc 0 NEWSYM FxOpd51A2 ; ADI RN add, register + immediate ADIRNc 1 NEWSYM FxOpd52A2 ; ADI RN add, register + immediate ADIRNc 2 NEWSYM FxOpd53A2 ; ADI RN add, register + immediate ADIRNc 3 NEWSYM FxOpd54A2 ; ADI RN add, register + immediate ADIRNc 4 NEWSYM FxOpd55A2 ; ADI RN add, register + immediate ADIRNc 5 NEWSYM FxOpd56A2 ; ADI RN add, register + immediate ADIRNc 6 NEWSYM FxOpd57A2 ; ADI RN add, register + immediate ADIRNc 7 NEWSYM FxOpd58A2 ; ADI RN add, register + immediate ADIRNc 8 NEWSYM FxOpd59A2 ; ADI RN add, register + immediate ADIRNc 9 NEWSYM FxOpd5AA2 ; ADI RN add, register + immediate ADIRNc 10 NEWSYM FxOpd5BA2 ; ADI RN add, register + immediate ADIRNc 11 NEWSYM FxOpd5CA2 ; ADI RN add, register + immediate ADIRNc 12 NEWSYM FxOpd5DA2 ; ADI RN add, register + immediate ADIRNc 13 NEWSYM FxOpd5EA2 ; ADI RN add, register + immediate ADIRNc 14 NEWSYM FxOpd5FA2 ; ADI RN add, register + immediate ADIRNc 15 ; Another very useful Opdode NEWSYM FxOpd50A3 ; ADCIRN add with carry, register + immediate ADCIRNc 0 NEWSYM FxOpd51A3 ; ADCIRN add with carry, register + immediate ADCIRNc 1 NEWSYM FxOpd52A3 ; ADCIRN add with carry, register + immediate ADCIRNc 2 NEWSYM FxOpd53A3 ; ADCIRN add with carry, register + immediate ADCIRNc 3 NEWSYM FxOpd54A3 ; ADCIRN add with carry, register + immediate ADCIRNc 4 NEWSYM FxOpd55A3 ; ADCIRN add with carry, register + immediate ADCIRNc 5 NEWSYM FxOpd56A3 ; ADCIRN add with carry, register + immediate ADCIRNc 6 NEWSYM FxOpd57A3 ; ADCIRN add with carry, register + immediate ADCIRNc 7 NEWSYM FxOpd58A3 ; ADCIRN add with carry, register + immediate ADCIRNc 8 NEWSYM FxOpd59A3 ; ADCIRN add with carry, register + immediate ADCIRNc 9 NEWSYM FxOpd5AA3 ; ADCIRN add with carry, register + immediate ADCIRNc 10 NEWSYM FxOpd5BA3 ; ADCIRN add with carry, register + immediate ADCIRNc 11 NEWSYM FxOpd5CA3 ; ADCIRN add with carry, register + immediate ADCIRNc 12 NEWSYM FxOpd5DA3 ; ADCIRN add with carry, register + immediate ADCIRNc 13 NEWSYM FxOpd5EA3 ; ADCIRN add with carry, register + immediate ADCIRNc 14 NEWSYM FxOpd5FA3 ; ADCIRN add with carry, register + immediate ADCIRNc 15 NEWSYM FxOpd60 ; SUBRN subtract, register - register SUBRNc 0 NEWSYM FxOpd61 ; SUBRN subtract, register - register SUBRNc 1 NEWSYM FxOpd62 ; SUBRN subtract, register - register SUBRNc 2 NEWSYM FxOpd63 ; SUBRN subtract, register - register SUBRNc 3 NEWSYM FxOpd64 ; SUBRN subtract, register - register SUBRNc 4 NEWSYM FxOpd65 ; SUBRN subtract, register - register SUBRNc 5 NEWSYM FxOpd66 ; SUBRN subtract, register - register SUBRNc 6 NEWSYM FxOpd67 ; SUBRN subtract, register - register SUBRNc 7 NEWSYM FxOpd68 ; SUBRN subtract, register - register SUBRNc 8 NEWSYM FxOpd69 ; SUBRN subtract, register - register SUBRNc 9 NEWSYM FxOpd6A ; SUBRN subtract, register - register SUBRNc 10 NEWSYM FxOpd6B ; SUBRN subtract, register - register SUBRNc 11 NEWSYM FxOpd6C ; SUBRN subtract, register - register SUBRNc 12 NEWSYM FxOpd6D ; SUBRN subtract, register - register SUBRNc 13 NEWSYM FxOpd6E ; SUBRN subtract, register - register SUBRNc 14 NEWSYM FxOpd6F ; SUBRN subtract, register - register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd60A1 ; SBCRN subtract with carry, register - register SBCRNc 0 NEWSYM FxOpd61A1 ; SBCRN subtract with carry, register - register SBCRNc 1 NEWSYM FxOpd62A1 ; SBCRN subtract with carry, register - register SBCRNc 2 NEWSYM FxOpd63A1 ; SBCRN subtract with carry, register - register SBCRNc 3 NEWSYM FxOpd64A1 ; SBCRN subtract with carry, register - register SBCRNc 4 NEWSYM FxOpd65A1 ; SBCRN subtract with carry, register - register SBCRNc 5 NEWSYM FxOpd66A1 ; SBCRN subtract with carry, register - register SBCRNc 6 NEWSYM FxOpd67A1 ; SBCRN subtract with carry, register - register SBCRNc 7 NEWSYM FxOpd68A1 ; SBCRN subtract with carry, register - register SBCRNc 8 NEWSYM FxOpd69A1 ; SBCRN subtract with carry, register - register SBCRNc 9 NEWSYM FxOpd6AA1 ; SBCRN subtract with carry, register - register SBCRNc 10 NEWSYM FxOpd6BA1 ; SBCRN subtract with carry, register - register SBCRNc 11 NEWSYM FxOpd6CA1 ; SBCRN subtract with carry, register - register SBCRNc 12 NEWSYM FxOpd6DA1 ; SBCRN subtract with carry, register - register SBCRNc 13 NEWSYM FxOpd6EA1 ; SBCRN subtract with carry, register - register SBCRNc 14 NEWSYM FxOpd6FA1 ; SBCRN subtract with carry, register - register mov eax,[esi] ; Read Source mov ebx,ebp FETCHPIPE sub ebx,[SfxCPB] cmp byte[SfxCarry],1 sbb ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd60A2 ; SUBIRN subtract, register - immediate SUBIRNc 0 NEWSYM FxOpd61A2 ; SUBIRN subtract, register - immediate SUBIRNc 1 NEWSYM FxOpd62A2 ; SUBIRN subtract, register - immediate SUBIRNc 2 NEWSYM FxOpd63A2 ; SUBIRN subtract, register - immediate SUBIRNc 3 NEWSYM FxOpd64A2 ; SUBIRN subtract, register - immediate SUBIRNc 4 NEWSYM FxOpd65A2 ; SUBIRN subtract, register - immediate SUBIRNc 5 NEWSYM FxOpd66A2 ; SUBIRN subtract, register - immediate SUBIRNc 6 NEWSYM FxOpd67A2 ; SUBIRN subtract, register - immediate SUBIRNc 7 NEWSYM FxOpd68A2 ; SUBIRN subtract, register - immediate SUBIRNc 8 NEWSYM FxOpd69A2 ; SUBIRN subtract, register - immediate SUBIRNc 9 NEWSYM FxOpd6AA2 ; SUBIRN subtract, register - immediate SUBIRNc 10 NEWSYM FxOpd6BA2 ; SUBIRN subtract, register - immediate SUBIRNc 11 NEWSYM FxOpd6CA2 ; SUBIRN subtract, register - immediate SUBIRNc 12 NEWSYM FxOpd6DA2 ; SUBIRN subtract, register - immediate SUBIRNc 13 NEWSYM FxOpd6EA2 ; SUBIRN subtract, register - immediate SUBIRNc 14 NEWSYM FxOpd6FA2 ; SUBIRN subtract, register - immediate SUBIRNc 15 NEWSYM FxOpd60A3 ; CMPRN compare, register, register CMPRNc 0 NEWSYM FxOpd61A3 ; CMPRN compare, register, register CMPRNc 1 NEWSYM FxOpd62A3 ; CMPRN compare, register, register CMPRNc 2 NEWSYM FxOpd63A3 ; CMPRN compare, register, register CMPRNc 3 NEWSYM FxOpd64A3 ; CMPRN compare, register, register CMPRNc 4 NEWSYM FxOpd65A3 ; CMPRN compare, register, register CMPRNc 5 NEWSYM FxOpd66A3 ; CMPRN compare, register, register CMPRNc 6 NEWSYM FxOpd67A3 ; CMPRN compare, register, register CMPRNc 7 NEWSYM FxOpd68A3 ; CMPRN compare, register, register CMPRNc 8 NEWSYM FxOpd69A3 ; CMPRN compare, register, register CMPRNc 9 NEWSYM FxOpd6AA3 ; CMPRN compare, register, register CMPRNc 10 NEWSYM FxOpd6BA3 ; CMPRN compare, register, register CMPRNc 11 NEWSYM FxOpd6CA3 ; CMPRN compare, register, register CMPRNc 12 NEWSYM FxOpd6DA3 ; CMPRN compare, register, register CMPRNc 13 NEWSYM FxOpd6EA3 ; CMPRN compare, register, register CMPRNc 14 NEWSYM FxOpd6FA3 ; CMPRN compare, register, register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 mov [SfxSignZero],eax CLRFLAGS inc ebp ; Increase program counter FXReturn NEWSYM FxOpd70 ; MERGE R7 as upper byte, R8 as lower byte (used for texture-mapping) */ ; V xor eax,eax FETCHPIPE mov ah,byte [SfxR7+1] mov al,byte [SfxR8+1] inc ebp mov [edi],eax ; Write Destination mov dword[SfxSignZero],0001h test eax,0F0F0h jz .nozero mov dword[SfxSignZero],0000h .nozero test eax,08080h jz .nosign or dword [SfxSignZero],80000h .nosign mov dword [SfxOverflow],1 test ax,0c0c0h jnz .Overflow mov dword [SfxOverflow],0 .Overflow mov dword [SfxCarry],1 test ax,0e0e0h jnz .Carry mov dword [SfxCarry],0 .Carry CLRFLAGS FXReturn NEWSYM FxOpd71 ; AND RN register & register ANDRNc 1 NEWSYM FxOpd72 ; AND RN register & register ANDRNc 2 NEWSYM FxOpd73 ; AND RN register & register ANDRNc 3 NEWSYM FxOpd74 ; AND RN register & register ANDRNc 4 NEWSYM FxOpd75 ; AND RN register & register ANDRNc 5 NEWSYM FxOpd76 ; AND RN register & register ANDRNc 6 NEWSYM FxOpd77 ; AND RN register & register ANDRNc 7 NEWSYM FxOpd78 ; AND RN register & register ANDRNc 8 NEWSYM FxOpd79 ; AND RN register & register ANDRNc 9 NEWSYM FxOpd7A ; AND RN register & register ANDRNc 10 NEWSYM FxOpd7B ; AND RN register & register ANDRNc 11 NEWSYM FxOpd7C ; AND RN register & register ANDRNc 12 NEWSYM FxOpd7D ; AND RN register & register ANDRNc 13 NEWSYM FxOpd7E ; AND RN register & register ANDRNc 14 NEWSYM FxOpd7F ; AND RN register & register FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd71A1 ; BIC RN register & ~register BICRNc 1 NEWSYM FxOpd72A1 ; BIC RN register & ~register BICRNc 2 NEWSYM FxOpd73A1 ; BIC RN register & ~register BICRNc 3 NEWSYM FxOpd74A1 ; BIC RN register & ~register BICRNc 4 NEWSYM FxOpd75A1 ; BIC RN register & ~register BICRNc 5 NEWSYM FxOpd76A1 ; BIC RN register & ~register BICRNc 6 NEWSYM FxOpd77A1 ; BIC RN register & ~register BICRNc 7 NEWSYM FxOpd78A1 ; BIC RN register & ~register BICRNc 8 NEWSYM FxOpd79A1 ; BIC RN register & ~register BICRNc 9 NEWSYM FxOpd7AA1 ; BIC RN register & ~register BICRNc 10 NEWSYM FxOpd7BA1 ; BIC RN register & ~register BICRNc 11 NEWSYM FxOpd7CA1 ; BIC RN register & ~register BICRNc 12 NEWSYM FxOpd7DA1 ; BIC RN register & ~register BICRNc 13 NEWSYM FxOpd7EA1 ; BIC RN register & ~register BICRNc 14 NEWSYM FxOpd7FA1 ; BIC RN register & ~register FETCHPIPE mov ebx,ebp sub ebx,[SfxCPB] mov eax,[esi] ; Read Source xor ebx,0FFFFh and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd71A2 ; ANDIRNc and #n - register & immediate ANDIRNc 1 NEWSYM FxOpd72A2 ; ANDIRNc and #n - register & immediate ANDIRNc 2 NEWSYM FxOpd73A2 ; ANDIRNc and #n - register & immediate ANDIRNc 3 NEWSYM FxOpd74A2 ; ANDIRNc and #n - register & immediate ANDIRNc 4 NEWSYM FxOpd75A2 ; ANDIRNc and #n - register & immediate ANDIRNc 5 NEWSYM FxOpd76A2 ; ANDIRNc and #n - register & immediate ANDIRNc 6 NEWSYM FxOpd77A2 ; ANDIRNc and #n - register & immediate ANDIRNc 7 NEWSYM FxOpd78A2 ; ANDIRNc and #n - register & immediate ANDIRNc 8 NEWSYM FxOpd79A2 ; ANDIRNc and #n - register & immediate ANDIRNc 9 NEWSYM FxOpd7AA2 ; ANDIRNc and #n - register & immediate ANDIRNc 10 NEWSYM FxOpd7BA2 ; ANDIRNc and #n - register & immediate ANDIRNc 11 NEWSYM FxOpd7CA2 ; ANDIRNc and #n - register & immediate ANDIRNc 12 NEWSYM FxOpd7DA2 ; ANDIRNc and #n - register & immediate ANDIRNc 13 NEWSYM FxOpd7EA2 ; ANDIRNc and #n - register & immediate ANDIRNc 14 NEWSYM FxOpd7FA2 ; ANDIRNc and #n - register & immediate ANDIRNc 15 NEWSYM FxOpd71A3 ; BICIRNc register & ~immediate BICIRNc 1 ^ 0FFFFh NEWSYM FxOpd72A3 ; BICIRNc register & ~immediate BICIRNc 2 ^ 0FFFFh NEWSYM FxOpd73A3 ; BICIRNc register & ~immediate BICIRNc 3 ^ 0FFFFh NEWSYM FxOpd74A3 ; BICIRNc register & ~immediate BICIRNc 4 ^ 0FFFFh NEWSYM FxOpd75A3 ; BICIRNc register & ~immediate BICIRNc 5 ^ 0FFFFh NEWSYM FxOpd76A3 ; BICIRNc register & ~immediate BICIRNc 6 ^ 0FFFFh NEWSYM FxOpd77A3 ; BICIRNc register & ~immediate BICIRNc 7 ^ 0FFFFh NEWSYM FxOpd78A3 ; BICIRNc register & ~immediate BICIRNc 8 ^ 0FFFFh NEWSYM FxOpd79A3 ; BICIRNc register & ~immediate BICIRNc 9 ^ 0FFFFh NEWSYM FxOpd7AA3 ; BICIRNc register & ~immediate BICIRNc 10 ^ 0FFFFh NEWSYM FxOpd7BA3 ; BICIRNc register & ~immediate BICIRNc 11 ^ 0FFFFh NEWSYM FxOpd7CA3 ; BICIRNc register & ~immediate BICIRNc 12 ^ 0FFFFh NEWSYM FxOpd7DA3 ; BICIRNc register & ~immediate BICIRNc 13 ^ 0FFFFh NEWSYM FxOpd7EA3 ; BICIRNc register & ~immediate BICIRNc 14 ^ 0FFFFh NEWSYM FxOpd7FA3 ; BICIRNc register & ~immediate BICIRNc 15 ^ 0FFFFh NEWSYM FxOpd80 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 0 NEWSYM FxOpd81 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 1 NEWSYM FxOpd82 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 2 NEWSYM FxOpd83 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 3 NEWSYM FxOpd84 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 4 NEWSYM FxOpd85 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 5 NEWSYM FxOpd86 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 6 NEWSYM FxOpd87 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 7 NEWSYM FxOpd88 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 8 NEWSYM FxOpd89 ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 9 NEWSYM FxOpd8A ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 10 NEWSYM FxOpd8B ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 11 NEWSYM FxOpd8C ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 12 NEWSYM FxOpd8D ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 13 NEWSYM FxOpd8E ; MULTRNc 8 bit to 16 bit signed multiply, register * register MULTRNc 14 NEWSYM FxOpd8F ; MULTRNc 8 bit to 16 bit signed multiply, register * register FETCHPIPE mov ebx,ebp mov al,byte [esi] ; Read Source sub ebx,[SfxCPB] imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd80A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 0 NEWSYM FxOpd81A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 1 NEWSYM FxOpd82A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 2 NEWSYM FxOpd83A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 3 NEWSYM FxOpd84A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 4 NEWSYM FxOpd85A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 5 NEWSYM FxOpd86A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 6 NEWSYM FxOpd87A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 7 NEWSYM FxOpd88A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 8 NEWSYM FxOpd89A1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 9 NEWSYM FxOpd8AA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 10 NEWSYM FxOpd8BA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 11 NEWSYM FxOpd8CA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 12 NEWSYM FxOpd8DA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 13 NEWSYM FxOpd8EA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register UMULTRNc 14 NEWSYM FxOpd8FA1 ; UMULRN 8 bit to 16 bit unsigned multiply, register * register FETCHPIPE mov ebx,ebp mov al,byte [esi] ; Read Source sub ebx,[SfxCPB] mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn NEWSYM FxOpd80A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 0 NEWSYM FxOpd81A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 1 NEWSYM FxOpd82A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 2 NEWSYM FxOpd83A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 3 NEWSYM FxOpd84A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 4 NEWSYM FxOpd85A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 5 NEWSYM FxOpd86A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 6 NEWSYM FxOpd87A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 7 NEWSYM FxOpd88A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 8 NEWSYM FxOpd89A2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 9 NEWSYM FxOpd8AA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 10 NEWSYM FxOpd8BA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 11 NEWSYM FxOpd8CA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 12 NEWSYM FxOpd8DA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 13 NEWSYM FxOpd8EA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 14 NEWSYM FxOpd8FA2 ; MULIRN 8 bit to 16 bit signed multiply, register * immediate MULTIRNc 15 NEWSYM FxOpd80A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 0 NEWSYM FxOpd81A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 1 NEWSYM FxOpd82A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 2 NEWSYM FxOpd83A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 3 NEWSYM FxOpd84A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 4 NEWSYM FxOpd85A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 5 NEWSYM FxOpd86A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 6 NEWSYM FxOpd87A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 7 NEWSYM FxOpd88A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 8 NEWSYM FxOpd89A3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 9 NEWSYM FxOpd8AA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 10 NEWSYM FxOpd8BA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 11 NEWSYM FxOpd8CA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 12 NEWSYM FxOpd8DA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 13 NEWSYM FxOpd8EA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 14 NEWSYM FxOpd8FA3 ;UMULIRN 8 bit to 16 bit unsigned multiply, register * immediate UMULTIRNc 15 NEWSYM FxOpd90 ; SBK store word to last accessed RAM address ; V mov ebx,[SfxLastRamAdr] ; Load last ram address mov eax,[esi] ; Read Source FETCHPIPE mov [ebx],al ; Store Word sub ebx,[SfxRAMMem] xor ebx,1 add ebx,[SfxRAMMem] inc ebp ; Increase program counter mov [ebx],ah ; Store Word CLRFLAGS FXReturn NEWSYM FxOpd91 ; LINKc#n R11 = R15 + immediate LINKc 1 NEWSYM FxOpd92 ; LINKc#n R11 = R15 + immediate LINKc 2 NEWSYM FxOpd93 ; LINKc#n R11 = R15 + immediate LINKc 3 NEWSYM FxOpd94 ; LINKc#n R11 = R15 + immediate LINKc 4 NEWSYM FxOpd95 ; SEX sign extend 8 bit to 16 bit ; V movsx eax, byte [esi] ; Read Source FETCHPIPE and eax,0FFFFh inc ebp mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd96 ; ASR aritmethic shift right by one ; V mov eax,[esi] ; Read Source FETCHPIPE mov [SfxCarry],al and byte[SfxCarry],1 sar ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd96A1 ; DIV2 aritmethic shift right by one ; V mov eax,[esi] ; Read Source FETCHPIPE cmp ax,-1 je .minusone mov [SfxCarry],al and byte[SfxCarry],1 sar ax,1 ; logic shift right inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS FXReturn .minusone mov byte[SfxCarry],1 xor eax,eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov dword [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd97 ; ROR rotate right by one ; V FETCHPIPE mov eax,[esi] ; Read Source shr byte[SfxCarry],1 rcr ax,1 setc byte[SfxCarry] inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd98 ; JMPRNc jump to address of register JMPRNc 8 NEWSYM FxOpd99 ; JMPRNc jump to address of register JMPRNc 9 NEWSYM FxOpd9A ; JMPRNc jump to address of register JMPRNc 10 NEWSYM FxOpd9B ; JMPRNc jump to address of register JMPRNc 11 NEWSYM FxOpd9C ; JMPRNc jump to address of register JMPRNc 12 NEWSYM FxOpd9D ; JMPRNc jump to address of register JMPRNc 13 NEWSYM FxOpd98A1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 8 NEWSYM FxOpd99A1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 9 NEWSYM FxOpd9AA1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 10 NEWSYM FxOpd9BA1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 11 NEWSYM FxOpd9CA1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 12 NEWSYM FxOpd9DA1 ; LJMPRNc set program bank to source register and jump to address of register LJMPRNc 13 NEWSYM FxOpd9E ; LOB set upper byte to zero (keep low byte) ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,0FFh inc ebp mov [edi],eax ; Write Destination shl eax,8 mov dword [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpd9F ; FMULT 16 bit to 32 bit signed multiplication, upper 16 bits only ; V mov eax,[esi] ; Read Source mov ebx,[SfxR6] FETCHPIPE imul bx inc ebp and edx,0FFFFh mov [SfxSignZero],edx mov [edi],edx ; Write Destination shr ax,15 mov [SfxCarry],al CLRFLAGS FXReturn NEWSYM FxOpd9FA1 ; LMULT 16 bit to 32 bit signed multiplication ; V mov eax,[esi] ; Read Source mov ebx,[SfxR6] FETCHPIPE imul bx and edx,0FFFFh inc ebp mov [edi],edx ; Write Destination mov [SfxR4],ax mov [SfxSignZero],edx shr ax,15 mov [SfxCarry],al CLRFLAGS FXReturn NEWSYM FxOpdA0 ; IBTRNc,#PP immediate byte transfer IBTRNc 0 NEWSYM FxOpdA1 ; IBTRNc,#PP immediate byte transfer IBTRNc 1 NEWSYM FxOpdA2 ; IBTRNc,#PP immediate byte transfer IBTRNc 2 NEWSYM FxOpdA3 ; IBTRNc,#PP immediate byte transfer IBTRNc 3 NEWSYM FxOpdA4 ; IBTRNc,#PP immediate byte transfer IBTRNc 4 NEWSYM FxOpdA5 ; IBTRNc,#PP immediate byte transfer IBTRNc 5 NEWSYM FxOpdA6 ; IBTRNc,#PP immediate byte transfer IBTRNc 6 NEWSYM FxOpdA7 ; IBTRNc,#PP immediate byte transfer IBTRNc 7 NEWSYM FxOpdA8 ; IBTRNc,#PP immediate byte transfer IBTRNc 8 NEWSYM FxOpdA9 ; IBTRNc,#PP immediate byte transfer IBTRNc 9 NEWSYM FxOpdAA ; IBTRNc,#PP immediate byte transfer IBTRNc 10 NEWSYM FxOpdAB ; IBTRNc,#PP immediate byte transfer IBTRNc 11 NEWSYM FxOpdAC ; IBTRNc,#PP immediate byte transfer IBTRNc 12 NEWSYM FxOpdAD ; IBTRNc,#PP immediate byte transfer IBTRNc 13 NEWSYM FxOpdAE ; IBTRNc,#PP immediate byte transfer movsx eax,byte[ebp] mov cl,[ebp+1] add ebp,2 mov [SfxR0+14*4],ax UpdateR14 CLRFLAGS FXReturn NEWSYM FxOpdAF ; IBTRNc,#PP immediate byte transfer movsx eax,byte[ebp] mov cl,[ebp+1] and eax,0FFFFh mov ebp,[SfxCPB] add ebp,eax CLRFLAGS FXReturn NEWSYM FxOpdA0A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 0 NEWSYM FxOpdA1A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 1 NEWSYM FxOpdA2A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 2 NEWSYM FxOpdA3A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 3 NEWSYM FxOpdA4A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 4 NEWSYM FxOpdA5A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 5 NEWSYM FxOpdA6A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 6 NEWSYM FxOpdA7A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 7 NEWSYM FxOpdA8A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 8 NEWSYM FxOpdA9A1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 9 NEWSYM FxOpdAAA1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 10 NEWSYM FxOpdABA1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 11 NEWSYM FxOpdACA1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 12 NEWSYM FxOpdADA1 ; LMS rn,(yy) load word from RAM (short address) LMSRNc 13 NEWSYM FxOpdAEA1 ; LMS rn,(yy) load word from RAM (short address) xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram inc ebp mov [SfxR0+14*4],bx ; Write data UpdateR14 CLRFLAGS FXReturn NEWSYM FxOpdAFA1 ; LMS rn,(yy) load word from RAM (short address) xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram and ebx,0FFFFh mov ebp,[SfxCPB] add ebp,ebx CLRFLAGS FXReturn NEWSYM FxOpdA0A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 0 NEWSYM FxOpdA1A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 1 NEWSYM FxOpdA2A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 2 NEWSYM FxOpdA3A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 3 NEWSYM FxOpdA4A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 4 NEWSYM FxOpdA5A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 5 NEWSYM FxOpdA6A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 6 NEWSYM FxOpdA7A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 7 NEWSYM FxOpdA8A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 8 NEWSYM FxOpdA9A2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 9 NEWSYM FxOpdAAA2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 10 NEWSYM FxOpdABA2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 11 NEWSYM FxOpdACA2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 12 NEWSYM FxOpdADA2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 13 NEWSYM FxOpdAEA2 ; SMS (yy),rn store word in RAM (short address) SMSRNc 14 NEWSYM FxOpdAFA2 ; SMS (yy),rn store word in RAM (short address) xor eax,eax mov ebx,ebp sub ebx,[SfxCPB] mov al,[ebp] inc ebp add eax,eax FETCHPIPE add eax,[SfxRAMMem] mov dword [SfxLastRamAdr],eax inc ebp mov [eax],bx ; Write word to ram CLRFLAGS FXReturn NEWSYM FxOpdB0 ; FROM rn set source register FROMRNd 0 NEWSYM FxOpdB1 ; FROM rn set source register FROMRNd 1 NEWSYM FxOpdB2 ; FROM rn set source register FROMRNd 2 NEWSYM FxOpdB3 ; FROM rn set source register FROMRNd 3 NEWSYM FxOpdB4 ; FROM rn set source register FROMRNd 4 NEWSYM FxOpdB5 ; FROM rn set source register FROMRNd 5 NEWSYM FxOpdB6 ; FROM rn set source register FROMRNd 6 NEWSYM FxOpdB7 ; FROM rn set source register FROMRNd 7 NEWSYM FxOpdB8 ; FROM rn set source register FROMRNd 8 NEWSYM FxOpdB9 ; FROM rn set source register FROMRNd 9 NEWSYM FxOpdBA ; FROM rn set source register FROMRNd 10 NEWSYM FxOpdBB ; FROM rn set source register FROMRNd 11 NEWSYM FxOpdBC ; FROM rn set source register FROMRNd 12 NEWSYM FxOpdBD ; FROM rn set source register FROMRNd 13 NEWSYM FxOpdBE ; FROM rn set source register FROMRNd 14 NEWSYM FxOpdBF ; FROM rn set source register FETCHPIPE mov esi,SfxR0+15*4 inc ebp ; Increase program counter mov eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax call [FxTableb+ecx*4] mov esi,SfxR0 FXReturn NEWSYM FxOpdC0 ; HIB move high-byte to low-byte ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,0FF00h mov dword [SfxSignZero],eax shr eax,8 inc ebp mov [edi],eax CLRFLAGS FXReturn NEWSYM FxOpdC1 ; OR rn or rn ORRNc 1 NEWSYM FxOpdC2 ; OR rn or rn ORRNc 2 NEWSYM FxOpdC3 ; OR rn or rn ORRNc 3 NEWSYM FxOpdC4 ; OR rn or rn ORRNc 4 NEWSYM FxOpdC5 ; OR rn or rn ORRNc 5 NEWSYM FxOpdC6 ; OR rn or rn ORRNc 6 NEWSYM FxOpdC7 ; OR rn or rn ORRNc 7 NEWSYM FxOpdC8 ; OR rn or rn ORRNc 8 NEWSYM FxOpdC9 ; OR rn or rn ORRNc 9 NEWSYM FxOpdCA ; OR rn or rn ORRNc 10 NEWSYM FxOpdCB ; OR rn or rn ORRNc 11 NEWSYM FxOpdCC ; OR rn or rn ORRNc 12 NEWSYM FxOpdCD ; OR rn or rn ORRNc 13 NEWSYM FxOpdCE ; OR rn or rn ORRNc 14 NEWSYM FxOpdCF ; OR rn or rn mov eax,[esi] ; Read Source mov ebx,ebp FETCHPIPE sub ebx,[SfxCPB] or eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpdC1A1 ; XOR rn xor rn XORRNc 1 NEWSYM FxOpdC2A1 ; XOR rn xor rn XORRNc 2 NEWSYM FxOpdC3A1 ; XOR rn xor rn XORRNc 3 NEWSYM FxOpdC4A1 ; XOR rn xor rn XORRNc 4 NEWSYM FxOpdC5A1 ; XOR rn xor rn XORRNc 5 NEWSYM FxOpdC6A1 ; XOR rn xor rn XORRNc 6 NEWSYM FxOpdC7A1 ; XOR rn xor rn XORRNc 7 NEWSYM FxOpdC8A1 ; XOR rn xor rn XORRNc 8 NEWSYM FxOpdC9A1 ; XOR rn xor rn XORRNc 9 NEWSYM FxOpdCAA1 ; XOR rn xor rn XORRNc 10 NEWSYM FxOpdCBA1 ; XOR rn xor rn XORRNc 11 NEWSYM FxOpdCCA1 ; XOR rn xor rn XORRNc 12 NEWSYM FxOpdCDA1 ; XOR rn xor rn XORRNc 13 NEWSYM FxOpdCEA1 ; XOR rn xor rn XORRNc 14 NEWSYM FxOpdCFA1 ; XOR rn xor rn FETCHPIPE mov eax,[esi] ; Read Source mov ebx,ebp sub ebx,[SfxCPB] xor eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn NEWSYM FxOpdC1A2 ; OR #n OR #n ORIc 1 NEWSYM FxOpdC2A2 ; OR #n OR #n ORIc 2 NEWSYM FxOpdC3A2 ; OR #n OR #n ORIc 3 NEWSYM FxOpdC4A2 ; OR #n OR #n ORIc 4 NEWSYM FxOpdC5A2 ; OR #n OR #n ORIc 5 NEWSYM FxOpdC6A2 ; OR #n OR #n ORIc 6 NEWSYM FxOpdC7A2 ; OR #n OR #n ORIc 7 NEWSYM FxOpdC8A2 ; OR #n OR #n ORIc 8 NEWSYM FxOpdC9A2 ; OR #n OR #n ORIc 9 NEWSYM FxOpdCAA2 ; OR #n OR #n ORIc 10 NEWSYM FxOpdCBA2 ; OR #n OR #n ORIc 11 NEWSYM FxOpdCCA2 ; OR #n OR #n ORIc 12 NEWSYM FxOpdCDA2 ; OR #n OR #n ORIc 13 NEWSYM FxOpdCEA2 ; OR #n OR #n ORIc 14 NEWSYM FxOpdCFA2 ; OR #n OR #n ORIc 15 NEWSYM FxOpdC1A3 ; XOR #n xor #n XORIc 1 NEWSYM FxOpdC2A3 ; XOR #n xor #n XORIc 2 NEWSYM FxOpdC3A3 ; XOR #n xor #n XORIc 3 NEWSYM FxOpdC4A3 ; XOR #n xor #n XORIc 4 NEWSYM FxOpdC5A3 ; XOR #n xor #n XORIc 5 NEWSYM FxOpdC6A3 ; XOR #n xor #n XORIc 6 NEWSYM FxOpdC7A3 ; XOR #n xor #n XORIc 7 NEWSYM FxOpdC8A3 ; XOR #n xor #n XORIc 8 NEWSYM FxOpdC9A3 ; XOR #n xor #n XORIc 9 NEWSYM FxOpdCAA3 ; XOR #n xor #n XORIc 10 NEWSYM FxOpdCBA3 ; XOR #n xor #n XORIc 11 NEWSYM FxOpdCCA3 ; XOR #n xor #n XORIc 12 NEWSYM FxOpdCDA3 ; XOR #n xor #n XORIc 13 NEWSYM FxOpdCEA3 ; XOR #n xor #n XORIc 14 NEWSYM FxOpdCFA3 ; XOR #n xor #n XORIc 15 NEWSYM FxOpdD0 ; INC rn increase by one INCRNc 0 NEWSYM FxOpdD1 ; INC rn increase by one INCRNc 1 NEWSYM FxOpdD2 ; INC rn increase by one INCRNc 2 NEWSYM FxOpdD3 ; INC rn increase by one INCRNc 3 NEWSYM FxOpdD4 ; INC rn increase by one INCRNc 4 NEWSYM FxOpdD5 ; INC rn increase by one INCRNc 5 NEWSYM FxOpdD6 ; INC rn increase by one INCRNc 6 NEWSYM FxOpdD7 ; INC rn increase by one INCRNc 7 NEWSYM FxOpdD8 ; INC rn increase by one INCRNc 8 NEWSYM FxOpdD9 ; INC rn increase by one INCRNc 9 NEWSYM FxOpdDA ; INC rn increase by one INCRNc 10 NEWSYM FxOpdDB ; INC rn increase by one INCRNc 11 NEWSYM FxOpdDC ; INC rn increase by one INCRNc 12 NEWSYM FxOpdDD ; INC rn increase by one INCRNc 13 NEWSYM FxOpdDE ; INC rn increase by one FETCHPIPE mov eax,[SfxR0+14*4] ; Read Source inc ax mov [SfxR0+14*4],eax mov [SfxSignZero],eax CLRFLAGS inc ebp UpdateR14 FXReturn NEWSYM FxOpdDF ; GETC transfer ROM buffer to color register mov eax,[SfxRomBuffer] FETCHPIPE mov eax,[eax] test byte[SfxPOR],04h jz .nohighnibble mov bl,al shr bl,4 and al,0F0h or al,bl .nohighnibble test byte[SfxPOR],08h jnz .preserveupper cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx .nocolchange CLRFLAGS inc ebp ; Increase program counter FXReturn .preserveupper mov bl,[SfxCOLR] and al,0Fh and bl,0F0h or al,bl cmp [SfxCOLR],al je .nocolchange mov [SfxCOLR],al and eax,0FFh mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx CLRFLAGS inc ebp ; Increase program counter FXReturn NEWSYM FxOpdDFA2 ; RAMB set current RAM bank ; Verified mov eax,[esi] ; Read Source mov ebx,[SfxnRamBanks] FETCHPIPE dec ebx and eax,ebx mov dword [SfxRAMBR],eax shl eax,16 add eax,[sfxramdata] mov dword [SfxRAMMem],eax CLRFLAGS inc ebp FXReturn NEWSYM FxOpdDFA3 ; ROMB set current ROM bank ; Verified mov eax,[esi] ; Read Source and eax,07Fh FETCHPIPE mov dword [SfxROMBR],eax mov eax,[SfxMemTable+eax*4] mov [SfxCROM],eax CLRFLAGS inc ebp FXReturn NEWSYM FxOpdE0 ; DEC rn decrement by one DECRNc 0 NEWSYM FxOpdE1 ; DEC rn decrement by one DECRNc 1 NEWSYM FxOpdE2 ; DEC rn decrement by one DECRNc 2 NEWSYM FxOpdE3 ; DEC rn decrement by one DECRNc 3 NEWSYM FxOpdE4 ; DEC rn decrement by one DECRNc 4 NEWSYM FxOpdE5 ; DEC rn decrement by one DECRNc 5 NEWSYM FxOpdE6 ; DEC rn decrement by one DECRNc 6 NEWSYM FxOpdE7 ; DEC rn decrement by one DECRNc 7 NEWSYM FxOpdE8 ; DEC rn decrement by one DECRNc 8 NEWSYM FxOpdE9 ; DEC rn decrement by one DECRNc 9 NEWSYM FxOpdEA ; DEC rn decrement by one DECRNc 10 NEWSYM FxOpdEB ; DEC rn decrement by one DECRNc 11 NEWSYM FxOpdEC ; DEC rn decrement by one DECRNc 12 NEWSYM FxOpdED ; DEC rn decrement by one DECRNc 13 NEWSYM FxOpdEE ; DEC rn decrement by one dec word[SfxR0+14*4] FETCHPIPE mov eax,[SfxR0+14*4] ; Read Source mov [SfxSignZero],eax UpdateR14 CLRFLAGS inc ebp FXReturn NEWSYM FxOpdEF ; getb get byte from ROM at address R14 ; V FETCHPIPE mov eax,[SfxRomBuffer] inc ebp mov eax,[eax] and eax,0FFh ; cmp edi,SfxR15 ; je .nor15 mov [edi],eax ; Write DREG CLRFLAGS FXReturn .nor15 or eax,8000h mov [edi],eax ; Write DREG CLRFLAGS FXReturn add eax,ebp sub eax,[SfxCPB] mov [SfxR15],eax CLRFLAGS FXReturn NEWSYM FxOpdEFA1 ; getbh get high-byte from ROM at address R14 ; V mov eax,[esi] ; Read Source mov ebx,[SfxRomBuffer] and eax,0FFh FETCHPIPE mov ah,[ebx] inc ebp mov [edi],eax ; Write DREG CLRFLAGS FXReturn NEWSYM FxOpdEFA2 ; getbl get low-byte from ROM at address R14 ; V mov eax,[esi] ; Read Source mov ebx,[SfxRomBuffer] and eax,0FF00h FETCHPIPE mov al,[ebx] inc ebp mov [edi],eax ; Write DREG CLRFLAGS FXReturn NEWSYM FxOpdEFA3 ; getbs get sign extended byte from ROM at address R14 ; V mov ebx,[SfxRomBuffer] FETCHPIPE movsx eax,byte[ebx] inc ebp mov [edi],ax ; Write DREG CLRFLAGS FXReturn NEWSYM FxOpdF0 ; IWT RN,#xx immediate word transfer to register IWTRNc 0 NEWSYM FxOpdF1 ; IWT RN,#xx immediate word transfer to register IWTRNc 1 NEWSYM FxOpdF2 ; IWT RN,#xx immediate word transfer to register IWTRNc 2 NEWSYM FxOpdF3 ; IWT RN,#xx immediate word transfer to register IWTRNc 3 NEWSYM FxOpdF4 ; IWT RN,#xx immediate word transfer to register IWTRNc 4 NEWSYM FxOpdF5 ; IWT RN,#xx immediate word transfer to register IWTRNc 5 NEWSYM FxOpdF6 ; IWT RN,#xx immediate word transfer to register IWTRNc 6 NEWSYM FxOpdF7 ; IWT RN,#xx immediate word transfer to register IWTRNc 7 NEWSYM FxOpdF8 ; IWT RN,#xx immediate word transfer to register IWTRNc 8 NEWSYM FxOpdF9 ; IWT RN,#xx immediate word transfer to register IWTRNc 9 NEWSYM FxOpdFA ; IWT RN,#xx immediate word transfer to register IWTRNc 10 NEWSYM FxOpdFB ; IWT RN,#xx immediate word transfer to register IWTRNc 11 NEWSYM FxOpdFC ; IWT RN,#xx immediate word transfer to register IWTRNc 12 NEWSYM FxOpdFD ; IWT RN,#xx immediate word transfer to register IWTRNc 13 NEWSYM FxOpdFE ; IWT RN,#xx immediate word transfer to register mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh add ebp,3 mov [SfxR0+14*4],eax UpdateR14 CLRFLAGS FXReturn NEWSYM FxOpdFF ; IWT RN,#xx immediate word transfer to register mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh mov ebp,[SfxCPB] add ebp,eax CLRFLAGS FXReturn NEWSYM FxOpdF0A1 ; LM RN,(XX) load word from RAM LMRNc 0 NEWSYM FxOpdF1A1 ; LM RN,(XX) load word from RAM LMRNc 1 NEWSYM FxOpdF2A1 ; LM RN,(XX) load word from RAM LMRNc 2 NEWSYM FxOpdF3A1 ; LM RN,(XX) load word from RAM LMRNc 3 NEWSYM FxOpdF4A1 ; LM RN,(XX) load word from RAM LMRNc 4 NEWSYM FxOpdF5A1 ; LM RN,(XX) load word from RAM LMRNc 5 NEWSYM FxOpdF6A1 ; LM RN,(XX) load word from RAM LMRNc 6 NEWSYM FxOpdF7A1 ; LM RN,(XX) load word from RAM LMRNc 7 NEWSYM FxOpdF8A1 ; LM RN,(XX) load word from RAM LMRNc 8 NEWSYM FxOpdF9A1 ; LM RN,(XX) load word from RAM LMRNc 9 NEWSYM FxOpdFAA1 ; LM RN,(XX) load word from RAM LMRNc 10 NEWSYM FxOpdFBA1 ; LM RN,(XX) load word from RAM LMRNc 11 NEWSYM FxOpdFCA1 ; LM RN,(XX) load word from RAM LMRNc 12 NEWSYM FxOpdFDA1 ; LM RN,(XX) load word from RAM LMRNc 13 NEWSYM FxOpdFEA1 ; LM RN,(XX) load word from RAM xor eax,eax mov cl,[ebp+2] mov ax,[ebp] mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 add ebp,3 mov dh,[eax+ebx] mov word [SfxR0+14*4],dx ; Store Word UpdateR14 CLRFLAGS FXReturn NEWSYM FxOpdFFA1 ; LM RN,(XX) load word from RAM FETCHPIPE mov eax,ecx inc ebp FETCHPIPE inc ebp mov ah,cl FETCHPIPE mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 mov dh,[eax+ebx] and edx,0FFFFh mov ebp,[SfxCPB] add ebp,edx CLRFLAGS FXReturn NEWSYM FxOpdF0A2 ; SM (XX),RN store word in RAM SMRNc 0 NEWSYM FxOpdF1A2 ; SM (XX),RN store word in RAM SMRNc 1 NEWSYM FxOpdF2A2 ; SM (XX),RN store word in RAM SMRNc 2 NEWSYM FxOpdF3A2 ; SM (XX),RN store word in RAM SMRNc 3 NEWSYM FxOpdF4A2 ; SM (XX),RN store word in RAM SMRNc 4 NEWSYM FxOpdF5A2 ; SM (XX),RN store word in RAM SMRNc 5 NEWSYM FxOpdF6A2 ; SM (XX),RN store word in RAM SMRNc 6 NEWSYM FxOpdF7A2 ; SM (XX),RN store word in RAM SMRNc 7 NEWSYM FxOpdF8A2 ; SM (XX),RN store word in RAM SMRNc 8 NEWSYM FxOpdF9A2 ; SM (XX),RN store word in RAM SMRNc 9 NEWSYM FxOpdFAA2 ; SM (XX),RN store word in RAM SMRNc 10 NEWSYM FxOpdFBA2 ; SM (XX),RN store word in RAM SMRNc 11 NEWSYM FxOpdFCA2 ; SM (XX),RN store word in RAM SMRNc 12 NEWSYM FxOpdFDA2 ; SM (XX),RN store word in RAM SMRNc 13 NEWSYM FxOpdFEA2 ; SM (XX),RN store word in RAM SMRNc 14 NEWSYM FxOpdFFA2 ; SM (XX),RN store word in RAM FETCHPIPE mov ebx,ebp sub ebx,[SfxCPB] mov eax,ecx inc ebp FETCHPIPE inc ebp mov ah,cl FETCHPIPE mov dx,bx mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov [eax+ebx],dl xor eax,1 inc ebp mov [eax+ebx],dh CLRFLAGS FXReturn NEWSYM FxEmu2CAsmEnd zsnes-1.36/src/chips/fxemu2c.mac0100644000175000017500000002607507267141100016124 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %macro FXReturn 0 dec dword [NumberOfOpcodes] jmp [FxTabled+ecx*4] ALIGN32 %endmacro %macro FXReturn2 0 dec dword [NumberOfOpcodes] js %%endloop jmp [FxTabled+ecx*4] %%endloop jmp FXEndLoop ; jmp [FxTabled+ecx*4] ALIGN32 %endmacro %macro TORNd 1 ; V FETCHPIPE mov edi, SfxR0+%1*4 inc ebp ; Increase program counter call [FxTable+ecx*4] mov edi,SfxR0 FXReturn %endmacro %macro WITHc 1 ; Verified. FETCHPIPE mov esi,SfxR0+%1*4 mov edi,SfxR0+%1*4 mov dword [SfxB],1 inc ebp ; Increase program counter call [FxTablec+ecx*4] mov esi,SfxR0 mov edi,SfxR0 mov dword [SfxB],0 ; Clear B Flag FXReturn %endmacro %macro STWRNc 1 ; V mov eax,[SfxR0+%1*4] ; Read register mov ebx,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address add dword [SfxLastRamAdr],ebx ; Save last ram address mov edx,[esi] ; Read Source FETCHPIPE mov [ebx+eax],dl ; Store Word xor eax,1 inc ebp ; Increase program counter mov [ebx+eax],dh ; Store Word CLRFLAGS FXReturn %endmacro %macro STBRNc 1 ; V mov eax,[SfxR0+%1*4] ; Read register FETCHPIPE add eax,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address mov ebx,[esi] ; Read Source mov byte [eax],bl ; Store Byte CLRFLAGS inc ebp ; Increase program counter FXReturn %endmacro %macro LDWRNc 1 ; V mov eax,[SfxR0+%1*4] ; Read register mov ebx,[SfxRAMMem] mov dword [SfxLastRamAdr],eax ; Save last ram address FETCHPIPE mov dl,[ebx+eax] ; Store Word add dword [SfxLastRamAdr],ebx ; Save last ram address xor eax,1 and edx,0FFFFh inc ebp ; Increase program counter mov dh,[ebx+eax] ; Store Word mov [edi],edx ; Read Source CLRFLAGS FXReturn %endmacro %macro LDBRNc 1 ; V mov eax,[SfxR0+%1*4] ; Read register FETCHPIPE add eax,[SfxRAMMem] xor ebx,ebx mov dword [SfxLastRamAdr],eax ; Save last ram address mov bl,[eax] ; Read Byte inc ebp ; Increase program counter mov [edi],ebx ; Store Result CLRFLAGS FXReturn %endmacro %macro ADDRNc 1 ; V mov eax, [esi] ; Read Source mov ebx, [SfxR0+%1*4] FETCHPIPE add ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro ADCRNc 1 ; V FETCHPIPE mov eax, [esi] ; Read Source mov ebx, [SfxR0+%1*4] shr byte[SfxCarry],1 adc ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro ADIRNc 1 ; V mov eax, [esi] ; Read Source FETCHPIPE add ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro ADCIRNc 1 ; V FETCHPIPE mov eax, [esi] ; Read Source shr byte[SfxCarry],1 adc ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] mov [SfxSignZero],eax inc ebp ; Increase program counter mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro SUBRNc 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] FETCHPIPE sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro SBCRNc 1 ; V FETCHPIPE mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] cmp byte[SfxCarry],1 sbb ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro SUBIRNc 1 ; V mov eax,[esi] ; Read Source FETCHPIPE sub ax,%1 seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 inc ebp ; Increase program counter mov [edi],eax ; Write Destination mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro CMPRNc 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] FETCHPIPE sub ax,bx seto byte[SfxOverflow] setc byte[SfxCarry] xor byte[SfxCarry],1 mov [SfxSignZero],eax CLRFLAGS inc ebp ; Increase program counter FXReturn %endmacro %macro ANDRNc 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read RN FETCHPIPE and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro BICRNc 1 ; V mov ebx,[SfxR0+%1*4] ; Read RN mov eax,[esi] ; Read Source xor ebx,0FFFFh FETCHPIPE and eax,ebx inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro ANDIRNc 1 ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,%1 inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro BICIRNc 1 ; V mov eax,[esi] ; Read Source FETCHPIPE and eax,%1 inc ebp mov dword [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro MULTRNc 1 ; V mov al,byte [esi] ; Read Source mov bl,byte [SfxR0+%1*4] ; Read RN FETCHPIPE imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro UMULTRNc 1 ; V mov al,byte [esi] ; Read Source mov bl,byte [SfxR0+%1*4] ; Read RN FETCHPIPE mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro MULTIRNc 1 ; V mov al,byte [esi] ; Read Source mov bl,%1 ; Read RN FETCHPIPE imul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro UMULTIRNc 1 ; V mov al,byte [esi] ; Read Source mov bl,%1 ; Read RN FETCHPIPE mul bl inc ebp and eax,0FFFFh mov [SfxSignZero],eax mov [edi],eax ; Write Destination CLRFLAGS FXReturn %endmacro %macro LINKc 1 ; Verified. mov eax,ebp sub eax,[SfxCPB] add eax,%1 FETCHPIPE mov word [SfxR11],ax CLRFLAGS inc ebp FXReturn %endmacro %macro JMPRNc 1 ; V FETCHPIPE mov eax,[SfxR0+%1*4] ; Read RN mov ebp,[SfxCPB] add ebp,eax CLRFLAGS FXReturn %endmacro %macro LJMPRNc 1 ; V FETCHPIPE mov eax,[SfxR0+%1*4] and eax,07Fh mov byte[SfxPBR],al ; mov byte[fxtrace+eax],1 mov eax,[SfxMemTable+eax*4] mov [SfxCPB],eax mov ebp,eax add ebp,[esi] ; Read RN mov dword [SfxCacheActive],0 push ecx call FxOp02 pop ecx dec ebp FXReturn %endmacro %macro IBTRNc 1 ; V movsx eax,byte[ebp] mov cl,[ebp+1] add ebp,2 mov [SfxR0+%1*4],ax CLRFLAGS FXReturn %endmacro %macro LMSRNc 1 ; Verified. xor eax,eax mov al,[ebp] add eax,eax inc ebp add eax,[SfxRAMMem] mov cl,[ebp] mov dword [SfxLastRamAdr],eax mov ebx,[eax] ; Read word from ram inc ebp mov [SfxR0+%1*4],bx ; Write data CLRFLAGS FXReturn %endmacro %macro SMSRNc 1 ; Verified. xor eax,eax mov al,[ebp] inc ebp add eax,eax mov cl,[ebp] add eax,[SfxRAMMem] mov ebx,[SfxR0+%1*4] ; Read data mov dword [SfxLastRamAdr],eax inc ebp mov [eax],bx ; Write word to ram CLRFLAGS FXReturn %endmacro %macro FROMRNd 1 ; V FETCHPIPE mov esi,SfxR0+%1*4 inc ebp ; Increase program counter call [FxTable+ecx*4] mov esi,SfxR0 FXReturn %endmacro %macro ORRNc 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read FETCHPIPE or eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro XORRNc 1 ; V mov eax,[esi] ; Read Source mov ebx,[SfxR0+%1*4] ; Read FETCHPIPE xor eax,ebx inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro ORIc 1 ; V mov eax,[esi] ; Read Source FETCHPIPE or eax,%1 inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro XORIc 1 ; V mov eax,[esi] ; Read Source FETCHPIPE xor eax,%1 inc ebp mov [edi],eax ; Write DREG mov [SfxSignZero],eax CLRFLAGS FXReturn %endmacro %macro INCRNc 1 ; Verified inc word[SfxR0+%1*4] FETCHPIPE mov eax,[SfxR0+%1*4] ; Read Source mov [SfxSignZero],eax CLRFLAGS inc ebp FXReturn %endmacro %macro DECRNc 1 ; Verified dec word[SfxR0+%1*4] FETCHPIPE mov eax,[SfxR0+%1*4] ; Read Source mov [SfxR0+%1*4],eax mov [SfxSignZero],eax CLRFLAGS inc ebp FXReturn %endmacro %macro IWTRNc 1 ; aka LEA ; Verified. mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh add ebp,3 mov [SfxR0+%1*4],eax CLRFLAGS FXReturn %endmacro %macro LMRNc 1 ; Verified! xor eax,eax mov cl,[ebp+2] mov ax,[ebp] mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov dl,[eax+ebx] xor eax,1 add ebp,3 mov dh,[eax+ebx] mov word [SfxR0+%1*4],dx ; Store Word CLRFLAGS FXReturn %endmacro %macro SMRNc 1 ; Verified mov ebx,[SfxR0+%1*4] mov eax,[ebp] mov cl,[ebp+2] and eax,0FFFFh mov dx,bx mov ebx,[SfxRAMMem] mov [SfxLastRamAdr],eax add [SfxLastRamAdr],ebx mov [eax+ebx],dl xor eax,1 add ebp,3 mov [eax+ebx],dh CLRFLAGS FXReturn %endmacro zsnes-1.36/src/chips/fxtable.asm0100644000175000017500000037602007432621304016221 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM FxTable,FxTableA1,FxTableA2,FxTableA3,FxTableb,FxTablebA1,FxTablebA2 EXTSYM FxTablebA3,FxTablec,FxTablecA1,FxTablecA2,FxTablecA3,FxTabled EXTSYM FxTabledA1,FxTabledA2,FxTabledA3,SfxMemTable,romdata,sfxramdata EXTSYM FxOp00,FxOp01,FxOp02,FxOp03,FxOp04,FxOp05,FxOp06,FxOp07,FxOp08 EXTSYM FxOp09,FxOp0A,FxOp0B,FxOp0C,FxOp0D,FxOp0E,FxOp0F,FxOp10,FxOp11 EXTSYM FxOp12,FxOp13,FxOp14,FxOp15,FxOp16,FxOp17,FxOp18,FxOp19,FxOp1A EXTSYM FxOp1B,FxOp1C,FxOp1D,FxOp1E,FxOp1F,FxOp20,FxOp21,FxOp22,FxOp23 EXTSYM FxOp24,FxOp25,FxOp26,FxOp27,FxOp28,FxOp29,FxOp2A,FxOp2B,FxOp2C EXTSYM FxOp2D,FxOp2E,FxOp2F,FxOp30,FxOp30A1,FxOp31,FxOp31A1,FxOp32 EXTSYM FxOp32A1,FxOp33,FxOp33A1,FxOp34,FxOp34A1,FxOp35,FxOp35A1,FxOp36 EXTSYM FxOp36A1,FxOp37,FxOp37A1,FxOp38,FxOp38A1,FxOp39,FxOp39A1,FxOp3A EXTSYM FxOp3AA1,FxOp3B,FxOp3BA1,FxOp3C,FxOp3D,FxOp3E,FxOp3F,FxOp40 EXTSYM FxOp40A1,FxOp41,FxOp41A1,FxOp42,FxOp42A1,FxOp43,FxOp43A1,FxOp44 EXTSYM FxOp44A1,FxOp45,FxOp45A1,FxOp46,FxOp46A1,FxOp47,FxOp47A1,FxOp48 EXTSYM FxOp48A1,FxOp49,FxOp49A1,FxOp4A,FxOp4AA1,FxOp4B,FxOp4BA1,FxOp4C EXTSYM FxOp4CA1,FxOp4D,FxOp4E,FxOp4EA1,FxOp4F,FxOp50,FxOp50A1,FxOp50A2 EXTSYM FxOp50A3,FxOp51,FxOp51A1,FxOp51A2,FxOp51A3,FxOp52,FxOp52A1,FxOp52A2 EXTSYM FxOp52A3,FxOp53,FxOp53A1,FxOp53A2,FxOp53A3,FxOp54,FxOp54A1,FxOp54A2 EXTSYM FxOp54A3,FxOp55,FxOp55A1,FxOp55A2,FxOp55A3,FxOp56,FxOp56A1,FxOp56A2 EXTSYM FxOp56A3,FxOp57,FxOp57A1,FxOp57A2,FxOp57A3,FxOp58,FxOp58A1,FxOp58A2 EXTSYM FxOp58A3,FxOp59,FxOp59A1,FxOp59A2,FxOp59A3,FxOp5A,FxOp5AA1,FxOp5AA2 EXTSYM FxOp5AA3,FxOp5B,FxOp5BA1,FxOp5BA2,FxOp5BA3,FxOp5C,FxOp5CA1,FxOp5CA2 EXTSYM FxOp5CA3,FxOp5D,FxOp5DA1,FxOp5DA2,FxOp5DA3,FxOp5E,FxOp5EA1,FxOp5EA2 EXTSYM FxOp5EA3,FxOp5F,FxOp5FA1,FxOp5FA2,FxOp5FA3,FxOp60,FxOp60A1,FxOp60A2 EXTSYM FxOp60A3,FxOp61,FxOp61A1,FxOp61A2,FxOp61A3,FxOp62,FxOp62A1,FxOp62A2 EXTSYM FxOp62A3,FxOp63,FxOp63A1,FxOp63A2,FxOp63A3,FxOp64,FxOp64A1,FxOp64A2 EXTSYM FxOp64A3,FxOp65,FxOp65A1,FxOp65A2,FxOp65A3,FxOp66,FxOp66A1,FxOp66A2 EXTSYM FxOp66A3,FxOp67,FxOp67A1,FxOp67A2,FxOp67A3,FxOp68,FxOp68A1,FxOp68A2 EXTSYM FxOp68A3,FxOp69,FxOp69A1,FxOp69A2,FxOp69A3,FxOp6A,FxOp6AA1,FxOp6AA2 EXTSYM FxOp6AA3,FxOp6B,FxOp6BA1,FxOp6BA2,FxOp6BA3,FxOp6C,FxOp6CA1,FxOp6CA2 EXTSYM FxOp6CA3,FxOp6D,FxOp6DA1,FxOp6DA2,FxOp6DA3,FxOp6E,FxOp6EA1,FxOp6EA2 EXTSYM FxOp6EA3,FxOp6F,FxOp6FA1,FxOp6FA2,FxOp6FA3,FxOp70,FxOp71,FxOp71A1 EXTSYM FxOp71A2,FxOp71A3,FxOp72,FxOp72A1,FxOp72A2,FxOp72A3,FxOp73,FxOp73A1 EXTSYM FxOp73A2,FxOp73A3,FxOp74,FxOp74A1,FxOp74A2,FxOp74A3,FxOp75,FxOp75A1 EXTSYM FxOp75A2,FxOp75A3,FxOp76,FxOp76A1,FxOp76A2,FxOp76A3,FxOp77,FxOp77A1 EXTSYM FxOp77A2,FxOp77A3,FxOp78,FxOp78A1,FxOp78A2,FxOp78A3,FxOp79,FxOp79A1 EXTSYM FxOp79A2,FxOp79A3,FxOp7A,FxOp7AA1,FxOp7AA2,FxOp7AA3,FxOp7B,FxOp7BA1 EXTSYM FxOp7BA2,FxOp7BA3,FxOp7C,FxOp7CA1,FxOp7CA2,FxOp7CA3,FxOp7D,FxOp7DA1 EXTSYM FxOp7DA2,FxOp7DA3,FxOp7E,FxOp7EA1,FxOp7EA2,FxOp7EA3,FxOp7F,FxOp7FA1 EXTSYM FxOp7FA2,FxOp7FA3,FxOp80,FxOp80A1,FxOp80A2,FxOp80A3,FxOp81,FxOp81A1 EXTSYM FxOp81A2,FxOp81A3,FxOp82,FxOp82A1,FxOp82A2,FxOp82A3,FxOp83,FxOp83A1 EXTSYM FxOp83A2,FxOp83A3,FxOp84,FxOp84A1,FxOp84A2,FxOp84A3,FxOp85,FxOp85A1 EXTSYM FxOp85A2,FxOp85A3,FxOp86,FxOp86A1,FxOp86A2,FxOp86A3,FxOp87,FxOp87A1 EXTSYM FxOp87A2,FxOp87A3,FxOp88,FxOp88A1,FxOp88A2,FxOp88A3,FxOp89,FxOp89A1 EXTSYM FxOp89A2,FxOp89A3,FxOp8A,FxOp8AA1,FxOp8AA2,FxOp8AA3,FxOp8B,FxOp8BA1 EXTSYM FxOp8BA2,FxOp8BA3,FxOp8C,FxOp8CA1,FxOp8CA2,FxOp8CA3,FxOp8D,FxOp8DA1 EXTSYM FxOp8DA2,FxOp8DA3,FxOp8E,FxOp8EA1,FxOp8EA2,FxOp8EA3,FxOp8F,FxOp8FA1 EXTSYM FxOp8FA2,FxOp8FA3,FxOp90,FxOp91,FxOp92,FxOp93,FxOp94,FxOp95,FxOp96 EXTSYM FxOp96A1,FxOp97,FxOp98,FxOp98A1,FxOp99,FxOp99A1,FxOp9A,FxOp9AA1,FxOp9B EXTSYM FxOp9BA1,FxOp9C,FxOp9CA1,FxOp9D,FxOp9DA1,FxOp9E,FxOp9F,FxOp9FA1,FxOpA0 EXTSYM FxOpA0A1,FxOpA0A2,FxOpA1,FxOpA1A1,FxOpA1A2,FxOpA2,FxOpA2A1,FxOpA2A2 EXTSYM FxOpA3,FxOpA3A1,FxOpA3A2,FxOpA4,FxOpA4A1,FxOpA4A2,FxOpA5,FxOpA5A1 EXTSYM FxOpA5A2,FxOpA6,FxOpA6A1,FxOpA6A2,FxOpA7,FxOpA7A1,FxOpA7A2,FxOpA8 EXTSYM FxOpA8A1,FxOpA8A2,FxOpA9,FxOpA9A1,FxOpA9A2,FxOpAA,FxOpAAA1,FxOpAAA2 EXTSYM FxOpAB,FxOpABA1,FxOpABA2,FxOpAC,FxOpACA1,FxOpACA2,FxOpAD,FxOpADA1 EXTSYM FxOpADA2,FxOpAE,FxOpAEA1,FxOpAEA2,FxOpAF,FxOpAFA1,FxOpAFA2,FxOpB0 EXTSYM FxOpB1,FxOpB2,FxOpB3,FxOpB4,FxOpB5,FxOpB6,FxOpB7,FxOpB8,FxOpB9,FxOpBA EXTSYM FxOpBB,FxOpBC,FxOpBD,FxOpBE,FxOpBF,FxOpC0,FxOpC1,FxOpC1A1,FxOpC1A2 EXTSYM FxOpC1A3,FxOpC2,FxOpC2A1,FxOpC2A2,FxOpC2A3,FxOpC3,FxOpC3A1,FxOpC3A2 EXTSYM FxOpC3A3,FxOpC4,FxOpC4A1,FxOpC4A2,FxOpC4A3,FxOpC5,FxOpC5A1,FxOpC5A2 EXTSYM FxOpC5A3,FxOpC6,FxOpC6A1,FxOpC6A2,FxOpC6A3,FxOpC7,FxOpC7A1,FxOpC7A2 EXTSYM FxOpC7A3,FxOpC8,FxOpC8A1,FxOpC8A2,FxOpC8A3,FxOpC9,FxOpC9A1,FxOpC9A2 EXTSYM FxOpC9A3,FxOpCA,FxOpCAA1,FxOpCAA2,FxOpCAA3,FxOpCB,FxOpCBA1,FxOpCBA2 EXTSYM FxOpCBA3,FxOpCC,FxOpCCA1,FxOpCCA2,FxOpCCA3,FxOpCD,FxOpCDA1,FxOpCDA2 EXTSYM FxOpCDA3,FxOpCE,FxOpCEA1,FxOpCEA2,FxOpCEA3,FxOpCF,FxOpCFA1,FxOpCFA2 EXTSYM FxOpCFA3,FxOpD0,FxOpD1,FxOpD2,FxOpD3,FxOpD4,FxOpD5,FxOpD6,FxOpD7 EXTSYM FxOpD8,FxOpD9,FxOpDA,FxOpDB,FxOpDC,FxOpDD,FxOpDE,FxOpDF,FxOpDFA2 EXTSYM FxOpDFA3,FxOpE0,FxOpE1,FxOpE2,FxOpE3,FxOpE4,FxOpE5,FxOpE6,FxOpE7 EXTSYM FxOpE8,FxOpE9,FxOpEA,FxOpEB,FxOpEC,FxOpED,FxOpEE,FxOpEF,FxOpEFA1 EXTSYM FxOpEFA2,FxOpEFA3,FxOpF0,FxOpF0A1,FxOpF0A2,FxOpF1,FxOpF1A1,FxOpF1A2 EXTSYM FxOpF2,FxOpF2A1,FxOpF2A2,FxOpF3,FxOpF3A1,FxOpF3A2,FxOpF4,FxOpF4A1 EXTSYM FxOpF4A2,FxOpF5,FxOpF5A1,FxOpF5A2,FxOpF6,FxOpF6A1,FxOpF6A2,FxOpF7 EXTSYM FxOpF7A1,FxOpF7A2,FxOpF8,FxOpF8A1,FxOpF8A2,FxOpF9,FxOpF9A1,FxOpF9A2 EXTSYM FxOpFA,FxOpFAA1,FxOpFAA2,FxOpFB,FxOpFBA1,FxOpFBA2,FxOpFC,FxOpFCA1 EXTSYM FxOpFCA2,FxOpFD,FxOpFDA1,FxOpFDA2,FxOpFE,FxOpFEA1,FxOpFEA2,FxOpFF EXTSYM FxOpFFA1,FxOpFFA2,FxOpb05,FxOpb06,FxOpb07,FxOpb08,FxOpb09,FxOpb0A EXTSYM FxOpb0B,FxOpb0C,FxOpb0D,FxOpb0E,FxOpb0F,FxOpb10,FxOpb11,FxOpb12 EXTSYM FxOpb13,FxOpb14,FxOpb15,FxOpb16,FxOpb17,FxOpb18,FxOpb19,FxOpb1A,FxOpb1B EXTSYM FxOpb1C,FxOpb1D,FxOpb1E,FxOpb1F,FxOpb3D,FxOpb3E,FxOpb3F,FxOpbB0,FxOpbB1 EXTSYM FxOpbB2,FxOpbB3,FxOpbB4,FxOpbB5,FxOpbB6,FxOpbB7,FxOpbB8,FxOpbB9,FxOpbBA EXTSYM FxOpbBB,FxOpbBC,FxOpbBD,FxOpbBE,FxOpbBF,FxOpc05,FxOpc06,FxOpc07,FxOpc08 EXTSYM FxOpc09,FxOpc0A,FxOpc0B,FxOpc0C,FxOpc0D,FxOpc0E,FxOpc0F,FxOpc10,FxOpc11 EXTSYM FxOpc12,FxOpc13,FxOpc14,FxOpc15,FxOpc16,FxOpc17,FxOpc18,FxOpc19,FxOpc1A EXTSYM FxOpc1B,FxOpc1C,FxOpc1D,FxOpc1E,FxOpc1F,FxOpc3D,FxOpc3E,FxOpc3F,FxOpcB0 EXTSYM FxOpcB1,FxOpcB2,FxOpcB3,FxOpcB4,FxOpcB5,FxOpcB6,FxOpcB7,FxOpcB8,FxOpcB9 EXTSYM FxOpcBA,FxOpcBB,FxOpcBC,FxOpcBD,FxOpcBE,FxOpcBF,FxOpd00,FxOpd01,FxOpd02 EXTSYM FxOpd03,FxOpd04,FxOpd05,FxOpd06,FxOpd07,FxOpd08,FxOpd09,FxOpd0A,FxOpd0B EXTSYM FxOpd0C,FxOpd0D,FxOpd0E,FxOpd0F,FxOpd10,FxOpd11,FxOpd12,FxOpd13,FxOpd14 EXTSYM FxOpd15,FxOpd16,FxOpd17,FxOpd18,FxOpd19,FxOpd1A,FxOpd1B,FxOpd1C,FxOpd1D EXTSYM FxOpd1E,FxOpd1F,FxOpd20,FxOpd21,FxOpd22,FxOpd23,FxOpd24,FxOpd25,FxOpd26 EXTSYM FxOpd27,FxOpd28,FxOpd29,FxOpd2A,FxOpd2B,FxOpd2C,FxOpd2D,FxOpd2E,FxOpd2F EXTSYM FxOpd30,FxOpd30A1,FxOpd31,FxOpd31A1,FxOpd32,FxOpd32A1,FxOpd33,FxOpd33A1 EXTSYM FxOpd34,FxOpd34A1,FxOpd35,FxOpd35A1,FxOpd36,FxOpd36A1,FxOpd37,FxOpd37A1 EXTSYM FxOpd38,FxOpd38A1,FxOpd39,FxOpd39A1,FxOpd3A,FxOpd3AA1,FxOpd3B,FxOpd3BA1 EXTSYM FxOpd3C,FxOpd3D,FxOpd3E,FxOpd3F,FxOpd40,FxOpd40A1,FxOpd41,FxOpd41A1 EXTSYM FxOpd42,FxOpd42A1,FxOpd43,FxOpd43A1,FxOpd44,FxOpd44A1,FxOpd45,FxOpd45A1 EXTSYM FxOpd46,FxOpd46A1,FxOpd47,FxOpd47A1,FxOpd48,FxOpd48A1,FxOpd49,FxOpd49A1 EXTSYM FxOpd4A,FxOpd4AA1,FxOpd4B,FxOpd4BA1,FxOpd4C,FxOpd4CA1,FxOpd4D,FxOpd4E EXTSYM FxOpd4EA1,FxOpd4F,FxOpd50,FxOpd50A1,FxOpd50A2,FxOpd50A3,FxOpd51,FxOpd51A1 EXTSYM FxOpd51A2,FxOpd51A3,FxOpd52,FxOpd52A1,FxOpd52A2,FxOpd52A3,FxOpd53 EXTSYM FxOpd53A1,FxOpd53A2,FxOpd53A3,FxOpd54,FxOpd54A1,FxOpd54A2,FxOpd54A3 EXTSYM FxOpd55,FxOpd55A1,FxOpd55A2,FxOpd55A3,FxOpd56,FxOpd56A1,FxOpd56A2 EXTSYM FxOpd56A3,FxOpd57,FxOpd57A1,FxOpd57A2,FxOpd57A3,FxOpd58,FxOpd58A1 EXTSYM FxOpd58A2,FxOpd58A3,FxOpd59,FxOpd59A1,FxOpd59A2,FxOpd59A3,FxOpd5A EXTSYM FxOpd5AA1,FxOpd5AA2,FxOpd5AA3,FxOpd5B,FxOpd5BA1,FxOpd5BA2,FxOpd5BA3 EXTSYM FxOpd5C,FxOpd5CA1,FxOpd5CA2,FxOpd5CA3,FxOpd5D,FxOpd5DA1,FxOpd5DA2 EXTSYM FxOpd5DA3,FxOpd5E,FxOpd5EA1,FxOpd5EA2,FxOpd5EA3,FxOpd5F,FxOpd5FA1 EXTSYM FxOpd5FA2,FxOpd5FA3,FxOpd60,FxOpd60A1,FxOpd60A2,FxOpd60A3,FxOpd61 EXTSYM FxOpd61A1,FxOpd61A2,FxOpd61A3,FxOpd62,FxOpd62A1,FxOpd62A2,FxOpd62A3 EXTSYM FxOpd63,FxOpd63A1,FxOpd63A2,FxOpd63A3,FxOpd64,FxOpd64A1,FxOpd64A2 EXTSYM FxOpd64A3,FxOpd65,FxOpd65A1,FxOpd65A2,FxOpd65A3,FxOpd66,FxOpd66A1 EXTSYM FxOpd66A2,FxOpd66A3,FxOpd67,FxOpd67A1,FxOpd67A2,FxOpd67A3,FxOpd68 EXTSYM FxOpd68A1,FxOpd68A2,FxOpd68A3,FxOpd69,FxOpd69A1,FxOpd69A2,FxOpd69A3 EXTSYM FxOpd6A,FxOpd6AA1,FxOpd6AA2,FxOpd6AA3,FxOpd6B,FxOpd6BA1,FxOpd6BA2 EXTSYM FxOpd6BA3,FxOpd6C,FxOpd6CA1,FxOpd6CA2,FxOpd6CA3,FxOpd6D,FxOpd6DA1 EXTSYM FxOpd6DA2,FxOpd6DA3,FxOpd6E,FxOpd6EA1,FxOpd6EA2,FxOpd6EA3,FxOpd6F EXTSYM FxOpd6FA1,FxOpd6FA2,FxOpd6FA3,FxOpd70,FxOpd71,FxOpd71A1,FxOpd71A2 EXTSYM FxOpd71A3,FxOpd72,FxOpd72A1,FxOpd72A2,FxOpd72A3,FxOpd73,FxOpd73A1 EXTSYM FxOpd73A2,FxOpd73A3,FxOpd74,FxOpd74A1,FxOpd74A2,FxOpd74A3,FxOpd75 EXTSYM FxOpd75A1,FxOpd75A2,FxOpd75A3,FxOpd76,FxOpd76A1,FxOpd76A2,FxOpd76A3 EXTSYM FxOpd77,FxOpd77A1,FxOpd77A2,FxOpd77A3,FxOpd78,FxOpd78A1,FxOpd78A2 EXTSYM FxOpd78A3,FxOpd79,FxOpd79A1,FxOpd79A2,FxOpd79A3,FxOpd7A,FxOpd7AA1 EXTSYM FxOpd7AA2,FxOpd7AA3,FxOpd7B,FxOpd7BA1,FxOpd7BA2,FxOpd7BA3,FxOpd7C EXTSYM FxOpd7CA1,FxOpd7CA2,FxOpd7CA3,FxOpd7D,FxOpd7DA1,FxOpd7DA2,FxOpd7DA3 EXTSYM FxOpd7E,FxOpd7EA1,FxOpd7EA2,FxOpd7EA3,FxOpd7F,FxOpd7FA1,FxOpd7FA2 EXTSYM FxOpd7FA3,FxOpd80,FxOpd80A1,FxOpd80A2,FxOpd80A3,FxOpd81,FxOpd81A1 EXTSYM FxOpd81A2,FxOpd81A3,FxOpd82,FxOpd82A1,FxOpd82A2,FxOpd82A3,FxOpd83 EXTSYM FxOpd83A1,FxOpd83A2,FxOpd83A3,FxOpd84,FxOpd84A1,FxOpd84A2,FxOpd84A3 EXTSYM FxOpd85,FxOpd85A1,FxOpd85A2,FxOpd85A3,FxOpd86,FxOpd86A1,FxOpd86A2 EXTSYM FxOpd86A3,FxOpd87,FxOpd87A1,FxOpd87A2,FxOpd87A3,FxOpd88,FxOpd88A1 EXTSYM FxOpd88A2,FxOpd88A3,FxOpd89,FxOpd89A1,FxOpd89A2,FxOpd89A3,FxOpd8A EXTSYM FxOpd8AA1,FxOpd8AA2,FxOpd8AA3,FxOpd8B,FxOpd8BA1,FxOpd8BA2,FxOpd8BA3 EXTSYM FxOpd8C,FxOpd8CA1,FxOpd8CA2,FxOpd8CA3,FxOpd8D,FxOpd8DA1,FxOpd8DA2 EXTSYM FxOpd8DA3,FxOpd8E,FxOpd8EA1,FxOpd8EA2,FxOpd8EA3,FxOpd8F,FxOpd8FA1 EXTSYM FxOpd8FA2,FxOpd8FA3,FxOpd90,FxOpd91,FxOpd92,FxOpd93,FxOpd94,FxOpd95 EXTSYM FxOpd96,FxOpd96A1,FxOpd97,FxOpd98,FxOpd98A1,FxOpd99,FxOpd99A1,FxOpd9A EXTSYM FxOpd9AA1,FxOpd9B,FxOpd9BA1,FxOpd9C,FxOpd9CA1,FxOpd9D,FxOpd9DA1,FxOpd9E EXTSYM FxOpd9F,FxOpd9FA1,FxOpdA0,FxOpdA0A1,FxOpdA0A2,FxOpdA1,FxOpdA1A1,FxOpdA1A2 EXTSYM FxOpdA2,FxOpdA2A1,FxOpdA2A2,FxOpdA3,FxOpdA3A1,FxOpdA3A2,FxOpdA4,FxOpdA4A1 EXTSYM FxOpdA4A2,FxOpdA5,FxOpdA5A1,FxOpdA5A2,FxOpdA6,FxOpdA6A1,FxOpdA6A2,FxOpdA7 EXTSYM FxOpdA7A1,FxOpdA7A2,FxOpdA8,FxOpdA8A1,FxOpdA8A2,FxOpdA9,FxOpdA9A1 EXTSYM FxOpdA9A2,FxOpdAA,FxOpdAAA1,FxOpdAAA2,FxOpdAB,FxOpdABA1,FxOpdABA2 EXTSYM FxOpdAC,FxOpdACA1,FxOpdACA2,FxOpdAD,FxOpdADA1,FxOpdADA2,FxOpdAE EXTSYM FxOpdAEA1,FxOpdAEA2,FxOpdAF,FxOpdAFA1,FxOpdAFA2,FxOpdB0,FxOpdB1,FxOpdB2 EXTSYM FxOpdB3,FxOpdB4,FxOpdB5,FxOpdB6,FxOpdB7,FxOpdB8,FxOpdB9,FxOpdBA,FxOpdBB EXTSYM FxOpdBC,FxOpdBD,FxOpdBE,FxOpdBF,FxOpdC0,FxOpdC1,FxOpdC1A1,FxOpdC1A2 EXTSYM FxOpdC1A3,FxOpdC2,FxOpdC2A1,FxOpdC2A2,FxOpdC2A3,FxOpdC3,FxOpdC3A1 EXTSYM FxOpdC3A2,FxOpdC3A3,FxOpdC4,FxOpdC4A1,FxOpdC4A2,FxOpdC4A3,FxOpdC5 EXTSYM FxOpdC5A1,FxOpdC5A2,FxOpdC5A3,FxOpdC6,FxOpdC6A1,FxOpdC6A2,FxOpdC6A3 EXTSYM FxOpdC7,FxOpdC7A1,FxOpdC7A2,FxOpdC7A3,FxOpdC8,FxOpdC8A1,FxOpdC8A2 EXTSYM FxOpdC8A3,FxOpdC9,FxOpdC9A1,FxOpdC9A2,FxOpdC9A3,FxOpdCA,FxOpdCAA1 EXTSYM FxOpdCAA2,FxOpdCAA3,FxOpdCB,FxOpdCBA1,FxOpdCBA2,FxOpdCBA3,FxOpdCC EXTSYM FxOpdCCA1,FxOpdCCA2,FxOpdCCA3,FxOpdCD,FxOpdCDA1,FxOpdCDA2,FxOpdCDA3 EXTSYM FxOpdCE,FxOpdCEA1,FxOpdCEA2,FxOpdCEA3,FxOpdCF,FxOpdCFA1,FxOpdCFA2 EXTSYM FxOpdCFA3,FxOpdD0,FxOpdD1,FxOpdD2,FxOpdD3,FxOpdD4,FxOpdD5,FxOpdD6 EXTSYM FxOpdD7,FxOpdD8,FxOpdD9,FxOpdDA,FxOpdDB,FxOpdDC,FxOpdDD,FxOpdDE,FxOpdDF EXTSYM FxOpdDFA2,FxOpdDFA3,FxOpdE0,FxOpdE1,FxOpdE2,FxOpdE3,FxOpdE4,FxOpdE5 EXTSYM FxOpdE6,FxOpdE7,FxOpdE8,FxOpdE9,FxOpdEA,FxOpdEB,FxOpdEC,FxOpdED,FxOpdEE EXTSYM FxOpdEF,FxOpdEFA1,FxOpdEFA2,FxOpdEFA3,FxOpdF0,FxOpdF0A1,FxOpdF0A2,FxOpdF1 EXTSYM FxOpdF1A1,FxOpdF1A2,FxOpdF2,FxOpdF2A1,FxOpdF2A2,FxOpdF3,FxOpdF3A1,FxOpdF3A2 EXTSYM FxOpdF4,FxOpdF4A1,FxOpdF4A2,FxOpdF5,FxOpdF5A1,FxOpdF5A2,FxOpdF6,FxOpdF6A1 EXTSYM FxOpdF6A2,FxOpdF7,FxOpdF7A1,FxOpdF7A2,FxOpdF8,FxOpdF8A1,FxOpdF8A2,FxOpdF9 EXTSYM FxOpdF9A1,FxOpdF9A2,FxOpdFA,FxOpdFAA1,FxOpdFAA2,FxOpdFB,FxOpdFBA1,FxOpdFBA2 EXTSYM FxOpdFC,FxOpdFCA1,FxOpdFCA2,FxOpdFD,FxOpdFDA1,FxOpdFDA2,FxOpdFE,FxOpdFEA1 EXTSYM FxOpdFEA2,FxOpdFF,FxOpdFFA1,FxOpdFFA2,PLOTJmpa,PLOTJmpb EXTSYM FxOp4C1284b,FxOp4C1284bz,FxOp4C1284bd,FxOp4C1284bzd EXTSYM FxOp4C1282b,FxOp4C1282bz,FxOp4C1282bd,FxOp4C1282bzd EXTSYM FxOp4C1288b,FxOp4C1288bz,FxOp4C1288bd,FxOp4C1288bzd EXTSYM FxOp4C1288bl,FxOp4C1288bzl,FxOp4C1288bdl,FxOp4C1288bzdl EXTSYM FxOpd4C1284b,FxOpd4C1284bz,FxOpd4C1284bd,FxOpd4C1284bzd EXTSYM FxOpd4C1282b,FxOpd4C1282bz,FxOpd4C1282bd,FxOpd4C1282bzd EXTSYM FxOpd4C1288b,FxOpd4C1288bz,FxOpd4C1288bd,FxOpd4C1288bzd EXTSYM FxOpd4C1288bl,FxOpd4C1288bzl,FxOpd4C1288bdl,FxOpd4C1288bzdl EXTSYM fxxand,fxbit01,fxbit23,fxbit45,fxbit67 NEWSYM FxTableAsmStart NEWSYM sfx128lineloc, dd 0 NEWSYM sfx160lineloc, dd 0 NEWSYM sfx192lineloc, dd 0 NEWSYM sfxobjlineloc, dd 0 NEWSYM InitFxTables ; cmp al,0 ; je near .colors4 ; cmp al,3 ; je near .colors256 ; test byte[SfxPOR],01h ; jz .zerocheck ; test byte[SfxPOR],02h ; jz .nodither4b ; Initiate PLOT jump tables xor ebx,ebx mov ecx,64 mov eax,PLOTJmpa .ploop mov edx,ebx push ebx and edx,03h test bl,04h jz near .zerocheck test bl,08h jnz .dither cmp dl,0 je .colors4 cmp dl,3 je .colors256 mov ebx,FxOp4C1284b jmp .end .colors4 mov ebx,FxOp4C1282b jmp .end .colors256 test bl,20h jnz .lowercheck mov ebx,FxOp4C1288b jmp .end .lowercheck mov ebx,FxOp4C1288bl jmp .end .dither cmp dl,0 je .colors4d cmp dl,3 je .colors256d mov ebx,FxOp4C1284bd jmp .end .colors4d mov ebx,FxOp4C1282bd jmp .end .colors256d test bl,20h jnz .lowercheckd mov ebx,FxOp4C1288bd jmp .end .lowercheckd mov ebx,FxOp4C1288bdl jmp .end .zerocheck test bl,08h jnz .ditherz cmp dl,0 je .colors4z cmp dl,3 je .colors256z mov ebx,FxOp4C1284bz jmp .end .colors4z mov ebx,FxOp4C1282bz jmp .end .colors256z test bl,20h jnz .lowercheckz mov ebx,FxOp4C1288bz jmp .end .lowercheckz mov ebx,FxOp4C1288bzl jmp .end .ditherz cmp dl,0 je .colors4dz cmp dl,3 je .colors256dz mov ebx,FxOp4C1284bzd jmp .end .colors4dz mov ebx,FxOp4C1282bzd jmp .end .colors256dz test bl,20h jnz .lowercheckdz mov ebx,FxOp4C1288bzd jmp .end .lowercheckdz mov ebx,FxOp4C1288bzdl .end mov [eax],ebx pop ebx inc ebx add eax,4 dec ecx jnz near .ploop xor ebx,ebx mov ecx,64 mov eax,PLOTJmpb .ploop2 mov edx,ebx push ebx and edx,03h test bl,04h jz near .zerocheck2 test bl,08h jnz .dither2 cmp dl,0 je .colors42 cmp dl,3 je .colors2562 mov ebx,FxOpd4C1284b jmp .end2 .colors42 mov ebx,FxOpd4C1282b jmp .end2 .colors2562 test bl,20h jnz .lowercheck2 mov ebx,FxOpd4C1288b jmp .end2 .lowercheck2 mov ebx,FxOpd4C1288bl jmp .end2 .dither2 cmp dl,0 je .colors4d2 cmp dl,3 je .colors256d2 mov ebx,FxOpd4C1284bd jmp .end2 .colors4d2 mov ebx,FxOpd4C1282bd jmp .end2 .colors256d2 test bl,20h jnz .lowercheckd2 mov ebx,FxOpd4C1288bd jmp .end2 .lowercheckd2 mov ebx,FxOpd4C1288bdl jmp .end2 .zerocheck2 test bl,08h jnz .ditherz2 cmp dl,0 je .colors4z2 cmp dl,3 je .colors256z2 mov ebx,FxOpd4C1284bz jmp .end2 .colors4z2 mov ebx,FxOpd4C1282bz jmp .end2 .colors256z2 test bl,20h jnz .lowercheckz2 mov ebx,FxOpd4C1288bz jmp .end2 .lowercheckz2 mov ebx,FxOpd4C1288bzl jmp .end2 .ditherz2 cmp dl,0 je .colors4dz2 cmp dl,3 je .colors256dz2 mov ebx,FxOpd4C1284bzd jmp .end2 .colors4dz2 mov ebx,FxOpd4C1282bzd jmp .end2 .colors256dz2 test bl,20h jnz .lowercheckdz2 mov ebx,FxOpd4C1288bzd jmp .end2 .lowercheckdz2 mov ebx,FxOpd4C1288bzdl .end2 mov [eax],ebx pop ebx inc ebx add eax,4 dec ecx jnz near .ploop2 ; Initiate AND and bit tables mov eax,fxxand mov ecx,256 xor ebx,ebx .loopat push ecx mov ecx,ebx and ecx,07h xor ecx,07h mov edx,0101h shl edx,cl xor edx,0FFFFFFFFh pop ecx mov [eax],edx inc ebx add eax,4 dec ecx jnz .loopat ; bit tables mov eax,fxbit01 mov ecx,256 xor ebx,ebx .loopb01 xor edx,edx test ebx,01h jz .nob0 or edx,0FFh .nob0 test ebx,02h jz .nob1 or edx,0FF00h .nob1 mov [eax],edx xor edx,edx test ebx,04h jz .nob2 or edx,0FFh .nob2 test ebx,08h jz .nob3 or edx,0FF00h .nob3 mov [eax+256*4],edx xor edx,edx test ebx,10h jz .nob4 or edx,0FFh .nob4 test ebx,20h jz .nob5 or edx,0FF00h .nob5 mov [eax+256*8],edx xor edx,edx test ebx,40h jz .nob6 or edx,0FFh .nob6 test ebx,80h jz .nob7 or edx,0FF00h .nob7 mov [eax+256*12],edx add eax,4 inc ebx dec ecx jnz near .loopb01 ; Initialize PLOT tables mov esi,[sfxramdata] add esi,1024*1024 ; Create 4 * 256k plot tables ; 128 line mode mov [sfx128lineloc],esi xor eax,eax xor ebx,ebx .nexty .nextx cmp eax,128 jae .over push eax push ebx shr eax,3 shr ebx,3 shl ebx,4 add ebx,eax mov [esi],ebx add esi,4 pop ebx pop eax jmp .notover .over mov dword[esi],0FFFFFFFFh add esi,4 .notover inc al jnz .nextx inc bl jnz .nexty ; 160 line mode mov [sfx160lineloc],esi .nexty2 .nextx2 cmp eax,160 jae .over2 push eax push ebx shr eax,3 shr ebx,3 mov edx,ebx shl ebx,4 shl edx,2 add ebx,eax add ebx,edx mov [esi],ebx add esi,4 pop ebx pop eax jmp .notover2 .over2 mov dword[esi],0FFFFFFFFh add esi,4 .notover2 inc al jnz .nextx2 inc bl jnz .nexty2 ; 192 line mode mov [sfx192lineloc],esi .nexty3 .nextx3 cmp eax,192 jae .over3 push eax push ebx shr eax,3 shr ebx,3 mov edx,ebx shl ebx,4 shl edx,3 add ebx,eax add ebx,edx mov [esi],ebx add esi,4 pop ebx pop eax jmp .notover3 .over3 mov dword[esi],0FFFFFFFFh add esi,4 .notover3 inc al jnz .nextx3 inc bl jnz .nexty3 ; obj mode mov [sfxobjlineloc],esi .nexty4 .nextx4 push eax push ebx and ebx,80h and eax,80h shl ebx,1 shl eax,2 add ebx,eax mov edx,ebx pop ebx pop eax push eax push ebx and ebx,78h and eax,78h shr ebx,3 shl eax,1 add ebx,eax add edx,ebx pop ebx pop eax mov [esi],edx add esi,4 inc al jnz .nextx4 inc bl jnz .nexty4 mov eax,[romdata] xor ebx,ebx mov ecx,256 .loopc mov [SfxMemTable+ebx*4],eax inc ebx dec ecx jnz .loopc mov eax,[romdata] ; sub eax,32768 xor ebx,ebx mov ecx,64 .loop mov [SfxMemTable+ebx*4],eax add eax,65536 inc ebx dec ecx jnz .loop mov eax,[romdata] add eax,32768 mov ecx,32 .loop2 mov [SfxMemTable+ebx*4],eax add eax,65536*2 inc ebx dec ecx jnz .loop2 mov eax,[sfxramdata] mov [SfxMemTable+70h*4],eax add eax,65536 mov [SfxMemTable+71h*4],eax add eax,65536 mov [SfxMemTable+72h*4],eax add eax,65536 mov [SfxMemTable+73h*4],eax mov eax,[romdata] ; sub eax,32768 xor ebx,ebx mov ebx,80h mov ecx,64 .loops mov [SfxMemTable+ebx*4],eax add eax,65536 inc ebx dec ecx jnz .loops mov eax,[romdata] add eax,32768 mov ecx,32 .loop2s mov [SfxMemTable+ebx*4],eax add eax,65536*2 inc ebx dec ecx jnz .loop2s mov eax,[sfxramdata] mov [SfxMemTable+0F0h*4],eax add eax,65536 mov [SfxMemTable+0F1h*4],eax add eax,65536 mov [SfxMemTable+0F2h*4],eax add eax,65536 mov [SfxMemTable+0F3h*4],eax mov dword [FxTable+00h*4],FxOp00 mov dword [FxTable+01h*4],FxOp01 mov dword [FxTable+02h*4],FxOp02 mov dword [FxTable+03h*4],FxOp03 mov dword [FxTable+04h*4],FxOp04 mov dword [FxTable+05h*4],FxOp05 mov dword [FxTable+06h*4],FxOp06 mov dword [FxTable+07h*4],FxOp07 mov dword [FxTable+08h*4],FxOp08 mov dword [FxTable+09h*4],FxOp09 mov dword [FxTable+0Ah*4],FxOp0A mov dword [FxTable+0Bh*4],FxOp0B mov dword [FxTable+0Ch*4],FxOp0C mov dword [FxTable+0Dh*4],FxOp0D mov dword [FxTable+0Eh*4],FxOp0E mov dword [FxTable+0Fh*4],FxOp0F mov dword [FxTable+10h*4],FxOp10 mov dword [FxTable+11h*4],FxOp11 mov dword [FxTable+12h*4],FxOp12 mov dword [FxTable+13h*4],FxOp13 mov dword [FxTable+14h*4],FxOp14 mov dword [FxTable+15h*4],FxOp15 mov dword [FxTable+16h*4],FxOp16 mov dword [FxTable+17h*4],FxOp17 mov dword [FxTable+18h*4],FxOp18 mov dword [FxTable+19h*4],FxOp19 mov dword [FxTable+1Ah*4],FxOp1A mov dword [FxTable+1Bh*4],FxOp1B mov dword [FxTable+1Ch*4],FxOp1C mov dword [FxTable+1Dh*4],FxOp1D mov dword [FxTable+1Eh*4],FxOp1E mov dword [FxTable+1Fh*4],FxOp1F mov dword [FxTable+20h*4],FxOp20 mov dword [FxTable+21h*4],FxOp21 mov dword [FxTable+22h*4],FxOp22 mov dword [FxTable+23h*4],FxOp23 mov dword [FxTable+24h*4],FxOp24 mov dword [FxTable+25h*4],FxOp25 mov dword [FxTable+26h*4],FxOp26 mov dword [FxTable+27h*4],FxOp27 mov dword [FxTable+28h*4],FxOp28 mov dword [FxTable+29h*4],FxOp29 mov dword [FxTable+2Ah*4],FxOp2A mov dword [FxTable+2Bh*4],FxOp2B mov dword [FxTable+2Ch*4],FxOp2C mov dword [FxTable+2Dh*4],FxOp2D mov dword [FxTable+2Eh*4],FxOp2E mov dword [FxTable+2Fh*4],FxOp2F mov dword [FxTable+30h*4],FxOp30 mov dword [FxTable+31h*4],FxOp31 mov dword [FxTable+32h*4],FxOp32 mov dword [FxTable+33h*4],FxOp33 mov dword [FxTable+34h*4],FxOp34 mov dword [FxTable+35h*4],FxOp35 mov dword [FxTable+36h*4],FxOp36 mov dword [FxTable+37h*4],FxOp37 mov dword [FxTable+38h*4],FxOp38 mov dword [FxTable+39h*4],FxOp39 mov dword [FxTable+3Ah*4],FxOp3A mov dword [FxTable+3Bh*4],FxOp3B mov dword [FxTable+3Ch*4],FxOp3C mov dword [FxTable+3Dh*4],FxOp3D mov dword [FxTable+3Eh*4],FxOp3E mov dword [FxTable+3Fh*4],FxOp3F mov dword [FxTable+40h*4],FxOp40 mov dword [FxTable+41h*4],FxOp41 mov dword [FxTable+42h*4],FxOp42 mov dword [FxTable+43h*4],FxOp43 mov dword [FxTable+44h*4],FxOp44 mov dword [FxTable+45h*4],FxOp45 mov dword [FxTable+46h*4],FxOp46 mov dword [FxTable+47h*4],FxOp47 mov dword [FxTable+48h*4],FxOp48 mov dword [FxTable+49h*4],FxOp49 mov dword [FxTable+4Ah*4],FxOp4A mov dword [FxTable+4Bh*4],FxOp4B mov dword [FxTable+4Ch*4],FxOp4C mov dword [FxTable+4Dh*4],FxOp4D mov dword [FxTable+4Eh*4],FxOp4E mov dword [FxTable+4Fh*4],FxOp4F mov dword [FxTable+50h*4],FxOp50 mov dword [FxTable+51h*4],FxOp51 mov dword [FxTable+52h*4],FxOp52 mov dword [FxTable+53h*4],FxOp53 mov dword [FxTable+54h*4],FxOp54 mov dword [FxTable+55h*4],FxOp55 mov dword [FxTable+56h*4],FxOp56 mov dword [FxTable+57h*4],FxOp57 mov dword [FxTable+58h*4],FxOp58 mov dword [FxTable+59h*4],FxOp59 mov dword [FxTable+5Ah*4],FxOp5A mov dword [FxTable+5Bh*4],FxOp5B mov dword [FxTable+5Ch*4],FxOp5C mov dword [FxTable+5Dh*4],FxOp5D mov dword [FxTable+5Eh*4],FxOp5E mov dword [FxTable+5Fh*4],FxOp5F mov dword [FxTable+60h*4],FxOp60 mov dword [FxTable+61h*4],FxOp61 mov dword [FxTable+62h*4],FxOp62 mov dword [FxTable+63h*4],FxOp63 mov dword [FxTable+64h*4],FxOp64 mov dword [FxTable+65h*4],FxOp65 mov dword [FxTable+66h*4],FxOp66 mov dword [FxTable+67h*4],FxOp67 mov dword [FxTable+68h*4],FxOp68 mov dword [FxTable+69h*4],FxOp69 mov dword [FxTable+6Ah*4],FxOp6A mov dword [FxTable+6Bh*4],FxOp6B mov dword [FxTable+6Ch*4],FxOp6C mov dword [FxTable+6Dh*4],FxOp6D mov dword [FxTable+6Eh*4],FxOp6E mov dword [FxTable+6Fh*4],FxOp6F mov dword [FxTable+70h*4],FxOp70 mov dword [FxTable+71h*4],FxOp71 mov dword [FxTable+72h*4],FxOp72 mov dword [FxTable+73h*4],FxOp73 mov dword [FxTable+74h*4],FxOp74 mov dword [FxTable+75h*4],FxOp75 mov dword [FxTable+76h*4],FxOp76 mov dword [FxTable+77h*4],FxOp77 mov dword [FxTable+78h*4],FxOp78 mov dword [FxTable+79h*4],FxOp79 mov dword [FxTable+7Ah*4],FxOp7A mov dword [FxTable+7Bh*4],FxOp7B mov dword [FxTable+7Ch*4],FxOp7C mov dword [FxTable+7Dh*4],FxOp7D mov dword [FxTable+7Eh*4],FxOp7E mov dword [FxTable+7Fh*4],FxOp7F mov dword [FxTable+80h*4],FxOp80 mov dword [FxTable+81h*4],FxOp81 mov dword [FxTable+82h*4],FxOp82 mov dword [FxTable+83h*4],FxOp83 mov dword [FxTable+84h*4],FxOp84 mov dword [FxTable+85h*4],FxOp85 mov dword [FxTable+86h*4],FxOp86 mov dword [FxTable+87h*4],FxOp87 mov dword [FxTable+88h*4],FxOp88 mov dword [FxTable+89h*4],FxOp89 mov dword [FxTable+8Ah*4],FxOp8A mov dword [FxTable+8Bh*4],FxOp8B mov dword [FxTable+8Ch*4],FxOp8C mov dword [FxTable+8Dh*4],FxOp8D mov dword [FxTable+8Eh*4],FxOp8E mov dword [FxTable+8Fh*4],FxOp8F mov dword [FxTable+90h*4],FxOp90 mov dword [FxTable+91h*4],FxOp91 mov dword [FxTable+92h*4],FxOp92 mov dword [FxTable+93h*4],FxOp93 mov dword [FxTable+94h*4],FxOp94 mov dword [FxTable+95h*4],FxOp95 mov dword [FxTable+96h*4],FxOp96 mov dword [FxTable+97h*4],FxOp97 mov dword [FxTable+98h*4],FxOp98 mov dword [FxTable+99h*4],FxOp99 mov dword [FxTable+9Ah*4],FxOp9A mov dword [FxTable+9Bh*4],FxOp9B mov dword [FxTable+9Ch*4],FxOp9C mov dword [FxTable+9Dh*4],FxOp9D mov dword [FxTable+9Eh*4],FxOp9E mov dword [FxTable+9Fh*4],FxOp9F mov dword [FxTable+0A0h*4],FxOpA0 mov dword [FxTable+0A1h*4],FxOpA1 mov dword [FxTable+0A2h*4],FxOpA2 mov dword [FxTable+0A3h*4],FxOpA3 mov dword [FxTable+0A4h*4],FxOpA4 mov dword [FxTable+0A5h*4],FxOpA5 mov dword [FxTable+0A6h*4],FxOpA6 mov dword [FxTable+0A7h*4],FxOpA7 mov dword [FxTable+0A8h*4],FxOpA8 mov dword [FxTable+0A9h*4],FxOpA9 mov dword [FxTable+0AAh*4],FxOpAA mov dword [FxTable+0ABh*4],FxOpAB mov dword [FxTable+0ACh*4],FxOpAC mov dword [FxTable+0ADh*4],FxOpAD mov dword [FxTable+0AEh*4],FxOpAE mov dword [FxTable+0AFh*4],FxOpAF mov dword [FxTable+0B0h*4],FxOpB0 mov dword [FxTable+0B1h*4],FxOpB1 mov dword [FxTable+0B2h*4],FxOpB2 mov dword [FxTable+0B3h*4],FxOpB3 mov dword [FxTable+0B4h*4],FxOpB4 mov dword [FxTable+0B5h*4],FxOpB5 mov dword [FxTable+0B6h*4],FxOpB6 mov dword [FxTable+0B7h*4],FxOpB7 mov dword [FxTable+0B8h*4],FxOpB8 mov dword [FxTable+0B9h*4],FxOpB9 mov dword [FxTable+0BAh*4],FxOpBA mov dword [FxTable+0BBh*4],FxOpBB mov dword [FxTable+0BCh*4],FxOpBC mov dword [FxTable+0BDh*4],FxOpBD mov dword [FxTable+0BEh*4],FxOpBE mov dword [FxTable+0BFh*4],FxOpBF mov dword [FxTable+0C0h*4],FxOpC0 mov dword [FxTable+0C1h*4],FxOpC1 mov dword [FxTable+0C2h*4],FxOpC2 mov dword [FxTable+0C3h*4],FxOpC3 mov dword [FxTable+0C4h*4],FxOpC4 mov dword [FxTable+0C5h*4],FxOpC5 mov dword [FxTable+0C6h*4],FxOpC6 mov dword [FxTable+0C7h*4],FxOpC7 mov dword [FxTable+0C8h*4],FxOpC8 mov dword [FxTable+0C9h*4],FxOpC9 mov dword [FxTable+0CAh*4],FxOpCA mov dword [FxTable+0CBh*4],FxOpCB mov dword [FxTable+0CCh*4],FxOpCC mov dword [FxTable+0CDh*4],FxOpCD mov dword [FxTable+0CEh*4],FxOpCE mov dword [FxTable+0CFh*4],FxOpCF mov dword [FxTable+0D0h*4],FxOpD0 mov dword [FxTable+0D1h*4],FxOpD1 mov dword [FxTable+0D2h*4],FxOpD2 mov dword [FxTable+0D3h*4],FxOpD3 mov dword [FxTable+0D4h*4],FxOpD4 mov dword [FxTable+0D5h*4],FxOpD5 mov dword [FxTable+0D6h*4],FxOpD6 mov dword [FxTable+0D7h*4],FxOpD7 mov dword [FxTable+0D8h*4],FxOpD8 mov dword [FxTable+0D9h*4],FxOpD9 mov dword [FxTable+0DAh*4],FxOpDA mov dword [FxTable+0DBh*4],FxOpDB mov dword [FxTable+0DCh*4],FxOpDC mov dword [FxTable+0DDh*4],FxOpDD mov dword [FxTable+0DEh*4],FxOpDE mov dword [FxTable+0DFh*4],FxOpDF mov dword [FxTable+0E0h*4],FxOpE0 mov dword [FxTable+0E1h*4],FxOpE1 mov dword [FxTable+0E2h*4],FxOpE2 mov dword [FxTable+0E3h*4],FxOpE3 mov dword [FxTable+0E4h*4],FxOpE4 mov dword [FxTable+0E5h*4],FxOpE5 mov dword [FxTable+0E6h*4],FxOpE6 mov dword [FxTable+0E7h*4],FxOpE7 mov dword [FxTable+0E8h*4],FxOpE8 mov dword [FxTable+0E9h*4],FxOpE9 mov dword [FxTable+0EAh*4],FxOpEA mov dword [FxTable+0EBh*4],FxOpEB mov dword [FxTable+0ECh*4],FxOpEC mov dword [FxTable+0EDh*4],FxOpED mov dword [FxTable+0EEh*4],FxOpEE mov dword [FxTable+0EFh*4],FxOpEF mov dword [FxTable+0F0h*4],FxOpF0 mov dword [FxTable+0F1h*4],FxOpF1 mov dword [FxTable+0F2h*4],FxOpF2 mov dword [FxTable+0F3h*4],FxOpF3 mov dword [FxTable+0F4h*4],FxOpF4 mov dword [FxTable+0F5h*4],FxOpF5 mov dword [FxTable+0F6h*4],FxOpF6 mov dword [FxTable+0F7h*4],FxOpF7 mov dword [FxTable+0F8h*4],FxOpF8 mov dword [FxTable+0F9h*4],FxOpF9 mov dword [FxTable+0FAh*4],FxOpFA mov dword [FxTable+0FBh*4],FxOpFB mov dword [FxTable+0FCh*4],FxOpFC mov dword [FxTable+0FDh*4],FxOpFD mov dword [FxTable+0FEh*4],FxOpFE mov dword [FxTable+0FFh*4],FxOpFF mov dword [FxTableA1+00h*4],FxOp00 mov dword [FxTableA1+01h*4],FxOp01 mov dword [FxTableA1+02h*4],FxOp02 mov dword [FxTableA1+03h*4],FxOp03 mov dword [FxTableA1+04h*4],FxOp04 mov dword [FxTableA1+05h*4],FxOp05 mov dword [FxTableA1+06h*4],FxOp06 mov dword [FxTableA1+07h*4],FxOp07 mov dword [FxTableA1+08h*4],FxOp08 mov dword [FxTableA1+09h*4],FxOp09 mov dword [FxTableA1+0Ah*4],FxOp0A mov dword [FxTableA1+0Bh*4],FxOp0B mov dword [FxTableA1+0Ch*4],FxOp0C mov dword [FxTableA1+0Dh*4],FxOp0D mov dword [FxTableA1+0Eh*4],FxOp0E mov dword [FxTableA1+0Fh*4],FxOp0F mov dword [FxTableA1+10h*4],FxOp10 mov dword [FxTableA1+11h*4],FxOp11 mov dword [FxTableA1+12h*4],FxOp12 mov dword [FxTableA1+13h*4],FxOp13 mov dword [FxTableA1+14h*4],FxOp14 mov dword [FxTableA1+15h*4],FxOp15 mov dword [FxTableA1+16h*4],FxOp16 mov dword [FxTableA1+17h*4],FxOp17 mov dword [FxTableA1+18h*4],FxOp18 mov dword [FxTableA1+19h*4],FxOp19 mov dword [FxTableA1+1Ah*4],FxOp1A mov dword [FxTableA1+1Bh*4],FxOp1B mov dword [FxTableA1+1Ch*4],FxOp1C mov dword [FxTableA1+1Dh*4],FxOp1D mov dword [FxTableA1+1Eh*4],FxOp1E mov dword [FxTableA1+1Fh*4],FxOp1F mov dword [FxTableA1+20h*4],FxOp20 mov dword [FxTableA1+21h*4],FxOp21 mov dword [FxTableA1+22h*4],FxOp22 mov dword [FxTableA1+23h*4],FxOp23 mov dword [FxTableA1+24h*4],FxOp24 mov dword [FxTableA1+25h*4],FxOp25 mov dword [FxTableA1+26h*4],FxOp26 mov dword [FxTableA1+27h*4],FxOp27 mov dword [FxTableA1+28h*4],FxOp28 mov dword [FxTableA1+29h*4],FxOp29 mov dword [FxTableA1+2Ah*4],FxOp2A mov dword [FxTableA1+2Bh*4],FxOp2B mov dword [FxTableA1+2Ch*4],FxOp2C mov dword [FxTableA1+2Dh*4],FxOp2D mov dword [FxTableA1+2Eh*4],FxOp2E mov dword [FxTableA1+2Fh*4],FxOp2F mov dword [FxTableA1+30h*4],FxOp30A1 mov dword [FxTableA1+31h*4],FxOp31A1 mov dword [FxTableA1+32h*4],FxOp32A1 mov dword [FxTableA1+33h*4],FxOp33A1 mov dword [FxTableA1+34h*4],FxOp34A1 mov dword [FxTableA1+35h*4],FxOp35A1 mov dword [FxTableA1+36h*4],FxOp36A1 mov dword [FxTableA1+37h*4],FxOp37A1 mov dword [FxTableA1+38h*4],FxOp38A1 mov dword [FxTableA1+39h*4],FxOp39A1 mov dword [FxTableA1+3Ah*4],FxOp3AA1 mov dword [FxTableA1+3Bh*4],FxOp3BA1 mov dword [FxTableA1+3Ch*4],FxOp3C mov dword [FxTableA1+3Dh*4],FxOp3D mov dword [FxTableA1+3Eh*4],FxOp3E mov dword [FxTableA1+3Fh*4],FxOp3F mov dword [FxTableA1+40h*4],FxOp40A1 mov dword [FxTableA1+41h*4],FxOp41A1 mov dword [FxTableA1+42h*4],FxOp42A1 mov dword [FxTableA1+43h*4],FxOp43A1 mov dword [FxTableA1+44h*4],FxOp44A1 mov dword [FxTableA1+45h*4],FxOp45A1 mov dword [FxTableA1+46h*4],FxOp46A1 mov dword [FxTableA1+47h*4],FxOp47A1 mov dword [FxTableA1+48h*4],FxOp48A1 mov dword [FxTableA1+49h*4],FxOp49A1 mov dword [FxTableA1+4Ah*4],FxOp4AA1 mov dword [FxTableA1+4Bh*4],FxOp4BA1 mov dword [FxTableA1+4Ch*4],FxOp4CA1 mov dword [FxTableA1+4Dh*4],FxOp4D mov dword [FxTableA1+4Eh*4],FxOp4EA1 mov dword [FxTableA1+4Fh*4],FxOp4F mov dword [FxTableA1+50h*4],FxOp50A1 mov dword [FxTableA1+51h*4],FxOp51A1 mov dword [FxTableA1+52h*4],FxOp52A1 mov dword [FxTableA1+53h*4],FxOp53A1 mov dword [FxTableA1+54h*4],FxOp54A1 mov dword [FxTableA1+55h*4],FxOp55A1 mov dword [FxTableA1+56h*4],FxOp56A1 mov dword [FxTableA1+57h*4],FxOp57A1 mov dword [FxTableA1+58h*4],FxOp58A1 mov dword [FxTableA1+59h*4],FxOp59A1 mov dword [FxTableA1+5Ah*4],FxOp5AA1 mov dword [FxTableA1+5Bh*4],FxOp5BA1 mov dword [FxTableA1+5Ch*4],FxOp5CA1 mov dword [FxTableA1+5Dh*4],FxOp5DA1 mov dword [FxTableA1+5Eh*4],FxOp5EA1 mov dword [FxTableA1+5Fh*4],FxOp5FA1 mov dword [FxTableA1+60h*4],FxOp60A1 mov dword [FxTableA1+61h*4],FxOp61A1 mov dword [FxTableA1+62h*4],FxOp62A1 mov dword [FxTableA1+63h*4],FxOp63A1 mov dword [FxTableA1+64h*4],FxOp64A1 mov dword [FxTableA1+65h*4],FxOp65A1 mov dword [FxTableA1+66h*4],FxOp66A1 mov dword [FxTableA1+67h*4],FxOp67A1 mov dword [FxTableA1+68h*4],FxOp68A1 mov dword [FxTableA1+69h*4],FxOp69A1 mov dword [FxTableA1+6Ah*4],FxOp6AA1 mov dword [FxTableA1+6Bh*4],FxOp6BA1 mov dword [FxTableA1+6Ch*4],FxOp6CA1 mov dword [FxTableA1+6Dh*4],FxOp6DA1 mov dword [FxTableA1+6Eh*4],FxOp6EA1 mov dword [FxTableA1+6Fh*4],FxOp6FA1 mov dword [FxTableA1+70h*4],FxOp70 mov dword [FxTableA1+71h*4],FxOp71A1 mov dword [FxTableA1+72h*4],FxOp72A1 mov dword [FxTableA1+73h*4],FxOp73A1 mov dword [FxTableA1+74h*4],FxOp74A1 mov dword [FxTableA1+75h*4],FxOp75A1 mov dword [FxTableA1+76h*4],FxOp76A1 mov dword [FxTableA1+77h*4],FxOp77A1 mov dword [FxTableA1+78h*4],FxOp78A1 mov dword [FxTableA1+79h*4],FxOp79A1 mov dword [FxTableA1+7Ah*4],FxOp7AA1 mov dword [FxTableA1+7Bh*4],FxOp7BA1 mov dword [FxTableA1+7Ch*4],FxOp7CA1 mov dword [FxTableA1+7Dh*4],FxOp7DA1 mov dword [FxTableA1+7Eh*4],FxOp7EA1 mov dword [FxTableA1+7Fh*4],FxOp7FA1 mov dword [FxTableA1+80h*4],FxOp80A1 mov dword [FxTableA1+81h*4],FxOp81A1 mov dword [FxTableA1+82h*4],FxOp82A1 mov dword [FxTableA1+83h*4],FxOp83A1 mov dword [FxTableA1+84h*4],FxOp84A1 mov dword [FxTableA1+85h*4],FxOp85A1 mov dword [FxTableA1+86h*4],FxOp86A1 mov dword [FxTableA1+87h*4],FxOp87A1 mov dword [FxTableA1+88h*4],FxOp88A1 mov dword [FxTableA1+89h*4],FxOp89A1 mov dword [FxTableA1+8Ah*4],FxOp8AA1 mov dword [FxTableA1+8Bh*4],FxOp8BA1 mov dword [FxTableA1+8Ch*4],FxOp8CA1 mov dword [FxTableA1+8Dh*4],FxOp8DA1 mov dword [FxTableA1+8Eh*4],FxOp8EA1 mov dword [FxTableA1+8Fh*4],FxOp8FA1 mov dword [FxTableA1+90h*4],FxOp90 mov dword [FxTableA1+91h*4],FxOp91 mov dword [FxTableA1+92h*4],FxOp92 mov dword [FxTableA1+93h*4],FxOp93 mov dword [FxTableA1+94h*4],FxOp94 mov dword [FxTableA1+95h*4],FxOp95 mov dword [FxTableA1+96h*4],FxOp96A1 mov dword [FxTableA1+97h*4],FxOp97 mov dword [FxTableA1+98h*4],FxOp98A1 mov dword [FxTableA1+99h*4],FxOp99A1 mov dword [FxTableA1+9Ah*4],FxOp9AA1 mov dword [FxTableA1+9Bh*4],FxOp9BA1 mov dword [FxTableA1+9Ch*4],FxOp9CA1 mov dword [FxTableA1+9Dh*4],FxOp9DA1 mov dword [FxTableA1+9Eh*4],FxOp9E mov dword [FxTableA1+9Fh*4],FxOp9FA1 mov dword [FxTableA1+0A0h*4],FxOpA0A1 mov dword [FxTableA1+0A1h*4],FxOpA1A1 mov dword [FxTableA1+0A2h*4],FxOpA2A1 mov dword [FxTableA1+0A3h*4],FxOpA3A1 mov dword [FxTableA1+0A4h*4],FxOpA4A1 mov dword [FxTableA1+0A5h*4],FxOpA5A1 mov dword [FxTableA1+0A6h*4],FxOpA6A1 mov dword [FxTableA1+0A7h*4],FxOpA7A1 mov dword [FxTableA1+0A8h*4],FxOpA8A1 mov dword [FxTableA1+0A9h*4],FxOpA9A1 mov dword [FxTableA1+0AAh*4],FxOpAAA1 mov dword [FxTableA1+0ABh*4],FxOpABA1 mov dword [FxTableA1+0ACh*4],FxOpACA1 mov dword [FxTableA1+0ADh*4],FxOpADA1 mov dword [FxTableA1+0AEh*4],FxOpAEA1 mov dword [FxTableA1+0AFh*4],FxOpAFA1 mov dword [FxTableA1+0B0h*4],FxOpB0 mov dword [FxTableA1+0B1h*4],FxOpB1 mov dword [FxTableA1+0B2h*4],FxOpB2 mov dword [FxTableA1+0B3h*4],FxOpB3 mov dword [FxTableA1+0B4h*4],FxOpB4 mov dword [FxTableA1+0B5h*4],FxOpB5 mov dword [FxTableA1+0B6h*4],FxOpB6 mov dword [FxTableA1+0B7h*4],FxOpB7 mov dword [FxTableA1+0B8h*4],FxOpB8 mov dword [FxTableA1+0B9h*4],FxOpB9 mov dword [FxTableA1+0BAh*4],FxOpBA mov dword [FxTableA1+0BBh*4],FxOpBB mov dword [FxTableA1+0BCh*4],FxOpBC mov dword [FxTableA1+0BDh*4],FxOpBD mov dword [FxTableA1+0BEh*4],FxOpBE mov dword [FxTableA1+0BFh*4],FxOpBF mov dword [FxTableA1+0C0h*4],FxOpC0 mov dword [FxTableA1+0C1h*4],FxOpC1A1 mov dword [FxTableA1+0C2h*4],FxOpC2A1 mov dword [FxTableA1+0C3h*4],FxOpC3A1 mov dword [FxTableA1+0C4h*4],FxOpC4A1 mov dword [FxTableA1+0C5h*4],FxOpC5A1 mov dword [FxTableA1+0C6h*4],FxOpC6A1 mov dword [FxTableA1+0C7h*4],FxOpC7A1 mov dword [FxTableA1+0C8h*4],FxOpC8A1 mov dword [FxTableA1+0C9h*4],FxOpC9A1 mov dword [FxTableA1+0CAh*4],FxOpCAA1 mov dword [FxTableA1+0CBh*4],FxOpCBA1 mov dword [FxTableA1+0CCh*4],FxOpCCA1 mov dword [FxTableA1+0CDh*4],FxOpCDA1 mov dword [FxTableA1+0CEh*4],FxOpCEA1 mov dword [FxTableA1+0CFh*4],FxOpCFA1 mov dword [FxTableA1+0D0h*4],FxOpD0 mov dword [FxTableA1+0D1h*4],FxOpD1 mov dword [FxTableA1+0D2h*4],FxOpD2 mov dword [FxTableA1+0D3h*4],FxOpD3 mov dword [FxTableA1+0D4h*4],FxOpD4 mov dword [FxTableA1+0D5h*4],FxOpD5 mov dword [FxTableA1+0D6h*4],FxOpD6 mov dword [FxTableA1+0D7h*4],FxOpD7 mov dword [FxTableA1+0D8h*4],FxOpD8 mov dword [FxTableA1+0D9h*4],FxOpD9 mov dword [FxTableA1+0DAh*4],FxOpDA mov dword [FxTableA1+0DBh*4],FxOpDB mov dword [FxTableA1+0DCh*4],FxOpDC mov dword [FxTableA1+0DDh*4],FxOpDD mov dword [FxTableA1+0DEh*4],FxOpDE mov dword [FxTableA1+0DFh*4],FxOpDF mov dword [FxTableA1+0E0h*4],FxOpE0 mov dword [FxTableA1+0E1h*4],FxOpE1 mov dword [FxTableA1+0E2h*4],FxOpE2 mov dword [FxTableA1+0E3h*4],FxOpE3 mov dword [FxTableA1+0E4h*4],FxOpE4 mov dword [FxTableA1+0E5h*4],FxOpE5 mov dword [FxTableA1+0E6h*4],FxOpE6 mov dword [FxTableA1+0E7h*4],FxOpE7 mov dword [FxTableA1+0E8h*4],FxOpE8 mov dword [FxTableA1+0E9h*4],FxOpE9 mov dword [FxTableA1+0EAh*4],FxOpEA mov dword [FxTableA1+0EBh*4],FxOpEB mov dword [FxTableA1+0ECh*4],FxOpEC mov dword [FxTableA1+0EDh*4],FxOpED mov dword [FxTableA1+0EEh*4],FxOpEE mov dword [FxTableA1+0EFh*4],FxOpEFA1 mov dword [FxTableA1+0F0h*4],FxOpF0A1 mov dword [FxTableA1+0F1h*4],FxOpF1A1 mov dword [FxTableA1+0F2h*4],FxOpF2A1 mov dword [FxTableA1+0F3h*4],FxOpF3A1 mov dword [FxTableA1+0F4h*4],FxOpF4A1 mov dword [FxTableA1+0F5h*4],FxOpF5A1 mov dword [FxTableA1+0F6h*4],FxOpF6A1 mov dword [FxTableA1+0F7h*4],FxOpF7A1 mov dword [FxTableA1+0F8h*4],FxOpF8A1 mov dword [FxTableA1+0F9h*4],FxOpF9A1 mov dword [FxTableA1+0FAh*4],FxOpFAA1 mov dword [FxTableA1+0FBh*4],FxOpFBA1 mov dword [FxTableA1+0FCh*4],FxOpFCA1 mov dword [FxTableA1+0FDh*4],FxOpFDA1 mov dword [FxTableA1+0FEh*4],FxOpFEA1 mov dword [FxTableA1+0FFh*4],FxOpFFA1 mov dword [FxTableA2+00h*4],FxOp00 mov dword [FxTableA2+01h*4],FxOp01 mov dword [FxTableA2+02h*4],FxOp02 mov dword [FxTableA2+03h*4],FxOp03 mov dword [FxTableA2+04h*4],FxOp04 mov dword [FxTableA2+05h*4],FxOp05 mov dword [FxTableA2+06h*4],FxOp06 mov dword [FxTableA2+07h*4],FxOp07 mov dword [FxTableA2+08h*4],FxOp08 mov dword [FxTableA2+09h*4],FxOp09 mov dword [FxTableA2+0Ah*4],FxOp0A mov dword [FxTableA2+0Bh*4],FxOp0B mov dword [FxTableA2+0Ch*4],FxOp0C mov dword [FxTableA2+0Dh*4],FxOp0D mov dword [FxTableA2+0Eh*4],FxOp0E mov dword [FxTableA2+0Fh*4],FxOp0F mov dword [FxTableA2+10h*4],FxOp10 mov dword [FxTableA2+11h*4],FxOp11 mov dword [FxTableA2+12h*4],FxOp12 mov dword [FxTableA2+13h*4],FxOp13 mov dword [FxTableA2+14h*4],FxOp14 mov dword [FxTableA2+15h*4],FxOp15 mov dword [FxTableA2+16h*4],FxOp16 mov dword [FxTableA2+17h*4],FxOp17 mov dword [FxTableA2+18h*4],FxOp18 mov dword [FxTableA2+19h*4],FxOp19 mov dword [FxTableA2+1Ah*4],FxOp1A mov dword [FxTableA2+1Bh*4],FxOp1B mov dword [FxTableA2+1Ch*4],FxOp1C mov dword [FxTableA2+1Dh*4],FxOp1D mov dword [FxTableA2+1Eh*4],FxOp1E mov dword [FxTableA2+1Fh*4],FxOp1F mov dword [FxTableA2+20h*4],FxOp20 mov dword [FxTableA2+21h*4],FxOp21 mov dword [FxTableA2+22h*4],FxOp22 mov dword [FxTableA2+23h*4],FxOp23 mov dword [FxTableA2+24h*4],FxOp24 mov dword [FxTableA2+25h*4],FxOp25 mov dword [FxTableA2+26h*4],FxOp26 mov dword [FxTableA2+27h*4],FxOp27 mov dword [FxTableA2+28h*4],FxOp28 mov dword [FxTableA2+29h*4],FxOp29 mov dword [FxTableA2+2Ah*4],FxOp2A mov dword [FxTableA2+2Bh*4],FxOp2B mov dword [FxTableA2+2Ch*4],FxOp2C mov dword [FxTableA2+2Dh*4],FxOp2D mov dword [FxTableA2+2Eh*4],FxOp2E mov dword [FxTableA2+2Fh*4],FxOp2F mov dword [FxTableA2+30h*4],FxOp30 mov dword [FxTableA2+31h*4],FxOp31 mov dword [FxTableA2+32h*4],FxOp32 mov dword [FxTableA2+33h*4],FxOp33 mov dword [FxTableA2+34h*4],FxOp34 mov dword [FxTableA2+35h*4],FxOp35 mov dword [FxTableA2+36h*4],FxOp36 mov dword [FxTableA2+37h*4],FxOp37 mov dword [FxTableA2+38h*4],FxOp38 mov dword [FxTableA2+39h*4],FxOp39 mov dword [FxTableA2+3Ah*4],FxOp3A mov dword [FxTableA2+3Bh*4],FxOp3B mov dword [FxTableA2+3Ch*4],FxOp3C mov dword [FxTableA2+3Dh*4],FxOp3D mov dword [FxTableA2+3Eh*4],FxOp3E mov dword [FxTableA2+3Fh*4],FxOp3F mov dword [FxTableA2+40h*4],FxOp40 mov dword [FxTableA2+41h*4],FxOp41 mov dword [FxTableA2+42h*4],FxOp42 mov dword [FxTableA2+43h*4],FxOp43 mov dword [FxTableA2+44h*4],FxOp44 mov dword [FxTableA2+45h*4],FxOp45 mov dword [FxTableA2+46h*4],FxOp46 mov dword [FxTableA2+47h*4],FxOp47 mov dword [FxTableA2+48h*4],FxOp48 mov dword [FxTableA2+49h*4],FxOp49 mov dword [FxTableA2+4Ah*4],FxOp4A mov dword [FxTableA2+4Bh*4],FxOp4B mov dword [FxTableA2+4Ch*4],FxOp4C mov dword [FxTableA2+4Dh*4],FxOp4D mov dword [FxTableA2+4Eh*4],FxOp4E mov dword [FxTableA2+4Fh*4],FxOp4F mov dword [FxTableA2+50h*4],FxOp50A2 mov dword [FxTableA2+51h*4],FxOp51A2 mov dword [FxTableA2+52h*4],FxOp52A2 mov dword [FxTableA2+53h*4],FxOp53A2 mov dword [FxTableA2+54h*4],FxOp54A2 mov dword [FxTableA2+55h*4],FxOp55A2 mov dword [FxTableA2+56h*4],FxOp56A2 mov dword [FxTableA2+57h*4],FxOp57A2 mov dword [FxTableA2+58h*4],FxOp58A2 mov dword [FxTableA2+59h*4],FxOp59A2 mov dword [FxTableA2+5Ah*4],FxOp5AA2 mov dword [FxTableA2+5Bh*4],FxOp5BA2 mov dword [FxTableA2+5Ch*4],FxOp5CA2 mov dword [FxTableA2+5Dh*4],FxOp5DA2 mov dword [FxTableA2+5Eh*4],FxOp5EA2 mov dword [FxTableA2+5Fh*4],FxOp5FA2 mov dword [FxTableA2+60h*4],FxOp60A2 mov dword [FxTableA2+61h*4],FxOp61A2 mov dword [FxTableA2+62h*4],FxOp62A2 mov dword [FxTableA2+63h*4],FxOp63A2 mov dword [FxTableA2+64h*4],FxOp64A2 mov dword [FxTableA2+65h*4],FxOp65A2 mov dword [FxTableA2+66h*4],FxOp66A2 mov dword [FxTableA2+67h*4],FxOp67A2 mov dword [FxTableA2+68h*4],FxOp68A2 mov dword [FxTableA2+69h*4],FxOp69A2 mov dword [FxTableA2+6Ah*4],FxOp6AA2 mov dword [FxTableA2+6Bh*4],FxOp6BA2 mov dword [FxTableA2+6Ch*4],FxOp6CA2 mov dword [FxTableA2+6Dh*4],FxOp6DA2 mov dword [FxTableA2+6Eh*4],FxOp6EA2 mov dword [FxTableA2+6Fh*4],FxOp6FA2 mov dword [FxTableA2+70h*4],FxOp70 mov dword [FxTableA2+71h*4],FxOp71A2 mov dword [FxTableA2+72h*4],FxOp72A2 mov dword [FxTableA2+73h*4],FxOp73A2 mov dword [FxTableA2+74h*4],FxOp74A2 mov dword [FxTableA2+75h*4],FxOp75A2 mov dword [FxTableA2+76h*4],FxOp76A2 mov dword [FxTableA2+77h*4],FxOp77A2 mov dword [FxTableA2+78h*4],FxOp78A2 mov dword [FxTableA2+79h*4],FxOp79A2 mov dword [FxTableA2+7Ah*4],FxOp7AA2 mov dword [FxTableA2+7Bh*4],FxOp7BA2 mov dword [FxTableA2+7Ch*4],FxOp7CA2 mov dword [FxTableA2+7Dh*4],FxOp7DA2 mov dword [FxTableA2+7Eh*4],FxOp7EA2 mov dword [FxTableA2+7Fh*4],FxOp7FA2 mov dword [FxTableA2+80h*4],FxOp80A2 mov dword [FxTableA2+81h*4],FxOp81A2 mov dword [FxTableA2+82h*4],FxOp82A2 mov dword [FxTableA2+83h*4],FxOp83A2 mov dword [FxTableA2+84h*4],FxOp84A2 mov dword [FxTableA2+85h*4],FxOp85A2 mov dword [FxTableA2+86h*4],FxOp86A2 mov dword [FxTableA2+87h*4],FxOp87A2 mov dword [FxTableA2+88h*4],FxOp88A2 mov dword [FxTableA2+89h*4],FxOp89A2 mov dword [FxTableA2+8Ah*4],FxOp8AA2 mov dword [FxTableA2+8Bh*4],FxOp8BA2 mov dword [FxTableA2+8Ch*4],FxOp8CA2 mov dword [FxTableA2+8Dh*4],FxOp8DA2 mov dword [FxTableA2+8Eh*4],FxOp8EA2 mov dword [FxTableA2+8Fh*4],FxOp8FA2 mov dword [FxTableA2+90h*4],FxOp90 mov dword [FxTableA2+91h*4],FxOp91 mov dword [FxTableA2+92h*4],FxOp92 mov dword [FxTableA2+93h*4],FxOp93 mov dword [FxTableA2+94h*4],FxOp94 mov dword [FxTableA2+95h*4],FxOp95 mov dword [FxTableA2+96h*4],FxOp96 mov dword [FxTableA2+97h*4],FxOp97 mov dword [FxTableA2+98h*4],FxOp98 mov dword [FxTableA2+99h*4],FxOp99 mov dword [FxTableA2+9Ah*4],FxOp9A mov dword [FxTableA2+9Bh*4],FxOp9B mov dword [FxTableA2+9Ch*4],FxOp9C mov dword [FxTableA2+9Dh*4],FxOp9D mov dword [FxTableA2+9Eh*4],FxOp9E mov dword [FxTableA2+9Fh*4],FxOp9F mov dword [FxTableA2+0A0h*4],FxOpA0A2 mov dword [FxTableA2+0A1h*4],FxOpA1A2 mov dword [FxTableA2+0A2h*4],FxOpA2A2 mov dword [FxTableA2+0A3h*4],FxOpA3A2 mov dword [FxTableA2+0A4h*4],FxOpA4A2 mov dword [FxTableA2+0A5h*4],FxOpA5A2 mov dword [FxTableA2+0A6h*4],FxOpA6A2 mov dword [FxTableA2+0A7h*4],FxOpA7A2 mov dword [FxTableA2+0A8h*4],FxOpA8A2 mov dword [FxTableA2+0A9h*4],FxOpA9A2 mov dword [FxTableA2+0AAh*4],FxOpAAA2 mov dword [FxTableA2+0ABh*4],FxOpABA2 mov dword [FxTableA2+0ACh*4],FxOpACA2 mov dword [FxTableA2+0ADh*4],FxOpADA2 mov dword [FxTableA2+0AEh*4],FxOpAEA2 mov dword [FxTableA2+0AFh*4],FxOpAFA2 mov dword [FxTableA2+0B0h*4],FxOpB0 mov dword [FxTableA2+0B1h*4],FxOpB1 mov dword [FxTableA2+0B2h*4],FxOpB2 mov dword [FxTableA2+0B3h*4],FxOpB3 mov dword [FxTableA2+0B4h*4],FxOpB4 mov dword [FxTableA2+0B5h*4],FxOpB5 mov dword [FxTableA2+0B6h*4],FxOpB6 mov dword [FxTableA2+0B7h*4],FxOpB7 mov dword [FxTableA2+0B8h*4],FxOpB8 mov dword [FxTableA2+0B9h*4],FxOpB9 mov dword [FxTableA2+0BAh*4],FxOpBA mov dword [FxTableA2+0BBh*4],FxOpBB mov dword [FxTableA2+0BCh*4],FxOpBC mov dword [FxTableA2+0BDh*4],FxOpBD mov dword [FxTableA2+0BEh*4],FxOpBE mov dword [FxTableA2+0BFh*4],FxOpBF mov dword [FxTableA2+0C0h*4],FxOpC0 mov dword [FxTableA2+0C1h*4],FxOpC1A2 mov dword [FxTableA2+0C2h*4],FxOpC2A2 mov dword [FxTableA2+0C3h*4],FxOpC3A2 mov dword [FxTableA2+0C4h*4],FxOpC4A2 mov dword [FxTableA2+0C5h*4],FxOpC5A2 mov dword [FxTableA2+0C6h*4],FxOpC6A2 mov dword [FxTableA2+0C7h*4],FxOpC7A2 mov dword [FxTableA2+0C8h*4],FxOpC8A2 mov dword [FxTableA2+0C9h*4],FxOpC9A2 mov dword [FxTableA2+0CAh*4],FxOpCAA2 mov dword [FxTableA2+0CBh*4],FxOpCBA2 mov dword [FxTableA2+0CCh*4],FxOpCCA2 mov dword [FxTableA2+0CDh*4],FxOpCDA2 mov dword [FxTableA2+0CEh*4],FxOpCEA2 mov dword [FxTableA2+0CFh*4],FxOpCFA2 mov dword [FxTableA2+0D0h*4],FxOpD0 mov dword [FxTableA2+0D1h*4],FxOpD1 mov dword [FxTableA2+0D2h*4],FxOpD2 mov dword [FxTableA2+0D3h*4],FxOpD3 mov dword [FxTableA2+0D4h*4],FxOpD4 mov dword [FxTableA2+0D5h*4],FxOpD5 mov dword [FxTableA2+0D6h*4],FxOpD6 mov dword [FxTableA2+0D7h*4],FxOpD7 mov dword [FxTableA2+0D8h*4],FxOpD8 mov dword [FxTableA2+0D9h*4],FxOpD9 mov dword [FxTableA2+0DAh*4],FxOpDA mov dword [FxTableA2+0DBh*4],FxOpDB mov dword [FxTableA2+0DCh*4],FxOpDC mov dword [FxTableA2+0DDh*4],FxOpDD mov dword [FxTableA2+0DEh*4],FxOpDE mov dword [FxTableA2+0DFh*4],FxOpDFA2 mov dword [FxTableA2+0E0h*4],FxOpE0 mov dword [FxTableA2+0E1h*4],FxOpE1 mov dword [FxTableA2+0E2h*4],FxOpE2 mov dword [FxTableA2+0E3h*4],FxOpE3 mov dword [FxTableA2+0E4h*4],FxOpE4 mov dword [FxTableA2+0E5h*4],FxOpE5 mov dword [FxTableA2+0E6h*4],FxOpE6 mov dword [FxTableA2+0E7h*4],FxOpE7 mov dword [FxTableA2+0E8h*4],FxOpE8 mov dword [FxTableA2+0E9h*4],FxOpE9 mov dword [FxTableA2+0EAh*4],FxOpEA mov dword [FxTableA2+0EBh*4],FxOpEB mov dword [FxTableA2+0ECh*4],FxOpEC mov dword [FxTableA2+0EDh*4],FxOpED mov dword [FxTableA2+0EEh*4],FxOpEE mov dword [FxTableA2+0EFh*4],FxOpEFA2 mov dword [FxTableA2+0F0h*4],FxOpF0A2 mov dword [FxTableA2+0F1h*4],FxOpF1A2 mov dword [FxTableA2+0F2h*4],FxOpF2A2 mov dword [FxTableA2+0F3h*4],FxOpF3A2 mov dword [FxTableA2+0F4h*4],FxOpF4A2 mov dword [FxTableA2+0F5h*4],FxOpF5A2 mov dword [FxTableA2+0F6h*4],FxOpF6A2 mov dword [FxTableA2+0F7h*4],FxOpF7A2 mov dword [FxTableA2+0F8h*4],FxOpF8A2 mov dword [FxTableA2+0F9h*4],FxOpF9A2 mov dword [FxTableA2+0FAh*4],FxOpFAA2 mov dword [FxTableA2+0FBh*4],FxOpFBA2 mov dword [FxTableA2+0FCh*4],FxOpFCA2 mov dword [FxTableA2+0FDh*4],FxOpFDA2 mov dword [FxTableA2+0FEh*4],FxOpFEA2 mov dword [FxTableA2+0FFh*4],FxOpFFA2 mov dword [FxTableA3+00h*4],FxOp00 mov dword [FxTableA3+01h*4],FxOp01 mov dword [FxTableA3+02h*4],FxOp02 mov dword [FxTableA3+03h*4],FxOp03 mov dword [FxTableA3+04h*4],FxOp04 mov dword [FxTableA3+05h*4],FxOp05 mov dword [FxTableA3+06h*4],FxOp06 mov dword [FxTableA3+07h*4],FxOp07 mov dword [FxTableA3+08h*4],FxOp08 mov dword [FxTableA3+09h*4],FxOp09 mov dword [FxTableA3+0Ah*4],FxOp0A mov dword [FxTableA3+0Bh*4],FxOp0B mov dword [FxTableA3+0Ch*4],FxOp0C mov dword [FxTableA3+0Dh*4],FxOp0D mov dword [FxTableA3+0Eh*4],FxOp0E mov dword [FxTableA3+0Fh*4],FxOp0F mov dword [FxTableA3+10h*4],FxOp10 mov dword [FxTableA3+11h*4],FxOp11 mov dword [FxTableA3+12h*4],FxOp12 mov dword [FxTableA3+13h*4],FxOp13 mov dword [FxTableA3+14h*4],FxOp14 mov dword [FxTableA3+15h*4],FxOp15 mov dword [FxTableA3+16h*4],FxOp16 mov dword [FxTableA3+17h*4],FxOp17 mov dword [FxTableA3+18h*4],FxOp18 mov dword [FxTableA3+19h*4],FxOp19 mov dword [FxTableA3+1Ah*4],FxOp1A mov dword [FxTableA3+1Bh*4],FxOp1B mov dword [FxTableA3+1Ch*4],FxOp1C mov dword [FxTableA3+1Dh*4],FxOp1D mov dword [FxTableA3+1Eh*4],FxOp1E mov dword [FxTableA3+1Fh*4],FxOp1F mov dword [FxTableA3+20h*4],FxOp20 mov dword [FxTableA3+21h*4],FxOp21 mov dword [FxTableA3+22h*4],FxOp22 mov dword [FxTableA3+23h*4],FxOp23 mov dword [FxTableA3+24h*4],FxOp24 mov dword [FxTableA3+25h*4],FxOp25 mov dword [FxTableA3+26h*4],FxOp26 mov dword [FxTableA3+27h*4],FxOp27 mov dword [FxTableA3+28h*4],FxOp28 mov dword [FxTableA3+29h*4],FxOp29 mov dword [FxTableA3+2Ah*4],FxOp2A mov dword [FxTableA3+2Bh*4],FxOp2B mov dword [FxTableA3+2Ch*4],FxOp2C mov dword [FxTableA3+2Dh*4],FxOp2D mov dword [FxTableA3+2Eh*4],FxOp2E mov dword [FxTableA3+2Fh*4],FxOp2F mov dword [FxTableA3+30h*4],FxOp30 mov dword [FxTableA3+31h*4],FxOp31 mov dword [FxTableA3+32h*4],FxOp32 mov dword [FxTableA3+33h*4],FxOp33 mov dword [FxTableA3+34h*4],FxOp34 mov dword [FxTableA3+35h*4],FxOp35 mov dword [FxTableA3+36h*4],FxOp36 mov dword [FxTableA3+37h*4],FxOp37 mov dword [FxTableA3+38h*4],FxOp38 mov dword [FxTableA3+39h*4],FxOp39 mov dword [FxTableA3+3Ah*4],FxOp3A mov dword [FxTableA3+3Bh*4],FxOp3B mov dword [FxTableA3+3Ch*4],FxOp3C mov dword [FxTableA3+3Dh*4],FxOp3D mov dword [FxTableA3+3Eh*4],FxOp3E mov dword [FxTableA3+3Fh*4],FxOp3F mov dword [FxTableA3+40h*4],FxOp40 mov dword [FxTableA3+41h*4],FxOp41 mov dword [FxTableA3+42h*4],FxOp42 mov dword [FxTableA3+43h*4],FxOp43 mov dword [FxTableA3+44h*4],FxOp44 mov dword [FxTableA3+45h*4],FxOp45 mov dword [FxTableA3+46h*4],FxOp46 mov dword [FxTableA3+47h*4],FxOp47 mov dword [FxTableA3+48h*4],FxOp48 mov dword [FxTableA3+49h*4],FxOp49 mov dword [FxTableA3+4Ah*4],FxOp4A mov dword [FxTableA3+4Bh*4],FxOp4B mov dword [FxTableA3+4Ch*4],FxOp4C mov dword [FxTableA3+4Dh*4],FxOp4D mov dword [FxTableA3+4Eh*4],FxOp4E mov dword [FxTableA3+4Fh*4],FxOp4F mov dword [FxTableA3+50h*4],FxOp50A3 mov dword [FxTableA3+51h*4],FxOp51A3 mov dword [FxTableA3+52h*4],FxOp52A3 mov dword [FxTableA3+53h*4],FxOp53A3 mov dword [FxTableA3+54h*4],FxOp54A3 mov dword [FxTableA3+55h*4],FxOp55A3 mov dword [FxTableA3+56h*4],FxOp56A3 mov dword [FxTableA3+57h*4],FxOp57A3 mov dword [FxTableA3+58h*4],FxOp58A3 mov dword [FxTableA3+59h*4],FxOp59A3 mov dword [FxTableA3+5Ah*4],FxOp5AA3 mov dword [FxTableA3+5Bh*4],FxOp5BA3 mov dword [FxTableA3+5Ch*4],FxOp5CA3 mov dword [FxTableA3+5Dh*4],FxOp5DA3 mov dword [FxTableA3+5Eh*4],FxOp5EA3 mov dword [FxTableA3+5Fh*4],FxOp5FA3 mov dword [FxTableA3+60h*4],FxOp60A3 mov dword [FxTableA3+61h*4],FxOp61A3 mov dword [FxTableA3+62h*4],FxOp62A3 mov dword [FxTableA3+63h*4],FxOp63A3 mov dword [FxTableA3+64h*4],FxOp64A3 mov dword [FxTableA3+65h*4],FxOp65A3 mov dword [FxTableA3+66h*4],FxOp66A3 mov dword [FxTableA3+67h*4],FxOp67A3 mov dword [FxTableA3+68h*4],FxOp68A3 mov dword [FxTableA3+69h*4],FxOp69A3 mov dword [FxTableA3+6Ah*4],FxOp6AA3 mov dword [FxTableA3+6Bh*4],FxOp6BA3 mov dword [FxTableA3+6Ch*4],FxOp6CA3 mov dword [FxTableA3+6Dh*4],FxOp6DA3 mov dword [FxTableA3+6Eh*4],FxOp6EA3 mov dword [FxTableA3+6Fh*4],FxOp6FA3 mov dword [FxTableA3+70h*4],FxOp70 mov dword [FxTableA3+71h*4],FxOp71A3 mov dword [FxTableA3+72h*4],FxOp72A3 mov dword [FxTableA3+73h*4],FxOp73A3 mov dword [FxTableA3+74h*4],FxOp74A3 mov dword [FxTableA3+75h*4],FxOp75A3 mov dword [FxTableA3+76h*4],FxOp76A3 mov dword [FxTableA3+77h*4],FxOp77A3 mov dword [FxTableA3+78h*4],FxOp78A3 mov dword [FxTableA3+79h*4],FxOp79A3 mov dword [FxTableA3+7Ah*4],FxOp7AA3 mov dword [FxTableA3+7Bh*4],FxOp7BA3 mov dword [FxTableA3+7Ch*4],FxOp7CA3 mov dword [FxTableA3+7Dh*4],FxOp7DA3 mov dword [FxTableA3+7Eh*4],FxOp7EA3 mov dword [FxTableA3+7Fh*4],FxOp7FA3 mov dword [FxTableA3+80h*4],FxOp80A3 mov dword [FxTableA3+81h*4],FxOp81A3 mov dword [FxTableA3+82h*4],FxOp82A3 mov dword [FxTableA3+83h*4],FxOp83A3 mov dword [FxTableA3+84h*4],FxOp84A3 mov dword [FxTableA3+85h*4],FxOp85A3 mov dword [FxTableA3+86h*4],FxOp86A3 mov dword [FxTableA3+87h*4],FxOp87A3 mov dword [FxTableA3+88h*4],FxOp88A3 mov dword [FxTableA3+89h*4],FxOp89A3 mov dword [FxTableA3+8Ah*4],FxOp8AA3 mov dword [FxTableA3+8Bh*4],FxOp8BA3 mov dword [FxTableA3+8Ch*4],FxOp8CA3 mov dword [FxTableA3+8Dh*4],FxOp8DA3 mov dword [FxTableA3+8Eh*4],FxOp8EA3 mov dword [FxTableA3+8Fh*4],FxOp8FA3 mov dword [FxTableA3+90h*4],FxOp90 mov dword [FxTableA3+91h*4],FxOp91 mov dword [FxTableA3+92h*4],FxOp92 mov dword [FxTableA3+93h*4],FxOp93 mov dword [FxTableA3+94h*4],FxOp94 mov dword [FxTableA3+95h*4],FxOp95 mov dword [FxTableA3+96h*4],FxOp96 mov dword [FxTableA3+97h*4],FxOp97 mov dword [FxTableA3+98h*4],FxOp98 mov dword [FxTableA3+99h*4],FxOp99 mov dword [FxTableA3+9Ah*4],FxOp9A mov dword [FxTableA3+9Bh*4],FxOp9B mov dword [FxTableA3+9Ch*4],FxOp9C mov dword [FxTableA3+9Dh*4],FxOp9D mov dword [FxTableA3+9Eh*4],FxOp9E mov dword [FxTableA3+9Fh*4],FxOp9F mov dword [FxTableA3+0A0h*4],FxOpA0 mov dword [FxTableA3+0A1h*4],FxOpA1 mov dword [FxTableA3+0A2h*4],FxOpA2 mov dword [FxTableA3+0A3h*4],FxOpA3 mov dword [FxTableA3+0A4h*4],FxOpA4 mov dword [FxTableA3+0A5h*4],FxOpA5 mov dword [FxTableA3+0A6h*4],FxOpA6 mov dword [FxTableA3+0A7h*4],FxOpA7 mov dword [FxTableA3+0A8h*4],FxOpA8 mov dword [FxTableA3+0A9h*4],FxOpA9 mov dword [FxTableA3+0AAh*4],FxOpAA mov dword [FxTableA3+0ABh*4],FxOpAB mov dword [FxTableA3+0ACh*4],FxOpAC mov dword [FxTableA3+0ADh*4],FxOpAD mov dword [FxTableA3+0AEh*4],FxOpAE mov dword [FxTableA3+0AFh*4],FxOpAF mov dword [FxTableA3+0B0h*4],FxOpB0 mov dword [FxTableA3+0B1h*4],FxOpB1 mov dword [FxTableA3+0B2h*4],FxOpB2 mov dword [FxTableA3+0B3h*4],FxOpB3 mov dword [FxTableA3+0B4h*4],FxOpB4 mov dword [FxTableA3+0B5h*4],FxOpB5 mov dword [FxTableA3+0B6h*4],FxOpB6 mov dword [FxTableA3+0B7h*4],FxOpB7 mov dword [FxTableA3+0B8h*4],FxOpB8 mov dword [FxTableA3+0B9h*4],FxOpB9 mov dword [FxTableA3+0BAh*4],FxOpBA mov dword [FxTableA3+0BBh*4],FxOpBB mov dword [FxTableA3+0BCh*4],FxOpBC mov dword [FxTableA3+0BDh*4],FxOpBD mov dword [FxTableA3+0BEh*4],FxOpBE mov dword [FxTableA3+0BFh*4],FxOpBF mov dword [FxTableA3+0C0h*4],FxOpC0 mov dword [FxTableA3+0C1h*4],FxOpC1A3 mov dword [FxTableA3+0C2h*4],FxOpC2A3 mov dword [FxTableA3+0C3h*4],FxOpC3A3 mov dword [FxTableA3+0C4h*4],FxOpC4A3 mov dword [FxTableA3+0C5h*4],FxOpC5A3 mov dword [FxTableA3+0C6h*4],FxOpC6A3 mov dword [FxTableA3+0C7h*4],FxOpC7A3 mov dword [FxTableA3+0C8h*4],FxOpC8A3 mov dword [FxTableA3+0C9h*4],FxOpC9A3 mov dword [FxTableA3+0CAh*4],FxOpCAA3 mov dword [FxTableA3+0CBh*4],FxOpCBA3 mov dword [FxTableA3+0CCh*4],FxOpCCA3 mov dword [FxTableA3+0CDh*4],FxOpCDA3 mov dword [FxTableA3+0CEh*4],FxOpCEA3 mov dword [FxTableA3+0CFh*4],FxOpCFA3 mov dword [FxTableA3+0D0h*4],FxOpD0 mov dword [FxTableA3+0D1h*4],FxOpD1 mov dword [FxTableA3+0D2h*4],FxOpD2 mov dword [FxTableA3+0D3h*4],FxOpD3 mov dword [FxTableA3+0D4h*4],FxOpD4 mov dword [FxTableA3+0D5h*4],FxOpD5 mov dword [FxTableA3+0D6h*4],FxOpD6 mov dword [FxTableA3+0D7h*4],FxOpD7 mov dword [FxTableA3+0D8h*4],FxOpD8 mov dword [FxTableA3+0D9h*4],FxOpD9 mov dword [FxTableA3+0DAh*4],FxOpDA mov dword [FxTableA3+0DBh*4],FxOpDB mov dword [FxTableA3+0DCh*4],FxOpDC mov dword [FxTableA3+0DDh*4],FxOpDD mov dword [FxTableA3+0DEh*4],FxOpDE mov dword [FxTableA3+0DFh*4],FxOpDFA3 mov dword [FxTableA3+0E0h*4],FxOpE0 mov dword [FxTableA3+0E1h*4],FxOpE1 mov dword [FxTableA3+0E2h*4],FxOpE2 mov dword [FxTableA3+0E3h*4],FxOpE3 mov dword [FxTableA3+0E4h*4],FxOpE4 mov dword [FxTableA3+0E5h*4],FxOpE5 mov dword [FxTableA3+0E6h*4],FxOpE6 mov dword [FxTableA3+0E7h*4],FxOpE7 mov dword [FxTableA3+0E8h*4],FxOpE8 mov dword [FxTableA3+0E9h*4],FxOpE9 mov dword [FxTableA3+0EAh*4],FxOpEA mov dword [FxTableA3+0EBh*4],FxOpEB mov dword [FxTableA3+0ECh*4],FxOpEC mov dword [FxTableA3+0EDh*4],FxOpED mov dword [FxTableA3+0EEh*4],FxOpEE mov dword [FxTableA3+0EFh*4],FxOpEFA3 mov dword [FxTableA3+0F0h*4],FxOpF0 mov dword [FxTableA3+0F1h*4],FxOpF1 mov dword [FxTableA3+0F2h*4],FxOpF2 mov dword [FxTableA3+0F3h*4],FxOpF3 mov dword [FxTableA3+0F4h*4],FxOpF4 mov dword [FxTableA3+0F5h*4],FxOpF5 mov dword [FxTableA3+0F6h*4],FxOpF6 mov dword [FxTableA3+0F7h*4],FxOpF7 mov dword [FxTableA3+0F8h*4],FxOpF8 mov dword [FxTableA3+0F9h*4],FxOpF9 mov dword [FxTableA3+0FAh*4],FxOpFA mov dword [FxTableA3+0FBh*4],FxOpFB mov dword [FxTableA3+0FCh*4],FxOpFC mov dword [FxTableA3+0FDh*4],FxOpFD mov dword [FxTableA3+0FEh*4],FxOpFE mov dword [FxTableA3+0FFh*4],FxOpFF ; Transfer FxTable to FxTableb and FxTablec mov esi,FxTable mov edi,FxTableb mov ecx,256*4 rep movsd mov esi,FxTable mov edi,FxTablec mov ecx,256*4 rep movsd mov dword [FxTableb+05h*4],FxOpb05 mov dword [FxTableb+06h*4],FxOpb06 mov dword [FxTableb+07h*4],FxOpb07 mov dword [FxTableb+08h*4],FxOpb08 mov dword [FxTableb+09h*4],FxOpb09 mov dword [FxTableb+0Ah*4],FxOpb0A mov dword [FxTableb+0Bh*4],FxOpb0B mov dword [FxTableb+0Ch*4],FxOpb0C mov dword [FxTableb+0Dh*4],FxOpb0D mov dword [FxTableb+0Eh*4],FxOpb0E mov dword [FxTableb+0Fh*4],FxOpb0F mov dword [FxTableb+10h*4],FxOpb10 mov dword [FxTableb+11h*4],FxOpb11 mov dword [FxTableb+12h*4],FxOpb12 mov dword [FxTableb+13h*4],FxOpb13 mov dword [FxTableb+14h*4],FxOpb14 mov dword [FxTableb+15h*4],FxOpb15 mov dword [FxTableb+16h*4],FxOpb16 mov dword [FxTableb+17h*4],FxOpb17 mov dword [FxTableb+18h*4],FxOpb18 mov dword [FxTableb+19h*4],FxOpb19 mov dword [FxTableb+1Ah*4],FxOpb1A mov dword [FxTableb+1Bh*4],FxOpb1B mov dword [FxTableb+1Ch*4],FxOpb1C mov dword [FxTableb+1Dh*4],FxOpb1D mov dword [FxTableb+1Eh*4],FxOpb1E mov dword [FxTableb+1Fh*4],FxOpb1F mov dword [FxTableb+3Dh*4],FxOpb3D mov dword [FxTableb+3Eh*4],FxOpb3E mov dword [FxTableb+3Fh*4],FxOpb3F mov dword [FxTableb+0B0h*4],FxOpbB0 mov dword [FxTableb+0B1h*4],FxOpbB1 mov dword [FxTableb+0B2h*4],FxOpbB2 mov dword [FxTableb+0B3h*4],FxOpbB3 mov dword [FxTableb+0B4h*4],FxOpbB4 mov dword [FxTableb+0B5h*4],FxOpbB5 mov dword [FxTableb+0B6h*4],FxOpbB6 mov dword [FxTableb+0B7h*4],FxOpbB7 mov dword [FxTableb+0B8h*4],FxOpbB8 mov dword [FxTableb+0B9h*4],FxOpbB9 mov dword [FxTableb+0BAh*4],FxOpbBA mov dword [FxTableb+0BBh*4],FxOpbBB mov dword [FxTableb+0BCh*4],FxOpbBC mov dword [FxTableb+0BDh*4],FxOpbBD mov dword [FxTableb+0BEh*4],FxOpbBE mov dword [FxTableb+0BFh*4],FxOpbBF mov dword [FxTablebA1+05h*4],FxOpb05 mov dword [FxTablebA1+06h*4],FxOpb06 mov dword [FxTablebA1+07h*4],FxOpb07 mov dword [FxTablebA1+08h*4],FxOpb08 mov dword [FxTablebA1+09h*4],FxOpb09 mov dword [FxTablebA1+0Ah*4],FxOpb0A mov dword [FxTablebA1+0Bh*4],FxOpb0B mov dword [FxTablebA1+0Ch*4],FxOpb0C mov dword [FxTablebA1+0Dh*4],FxOpb0D mov dword [FxTablebA1+0Eh*4],FxOpb0E mov dword [FxTablebA1+0Fh*4],FxOpb0F mov dword [FxTablebA1+10h*4],FxOpb10 mov dword [FxTablebA1+11h*4],FxOpb11 mov dword [FxTablebA1+12h*4],FxOpb12 mov dword [FxTablebA1+13h*4],FxOpb13 mov dword [FxTablebA1+14h*4],FxOpb14 mov dword [FxTablebA1+15h*4],FxOpb15 mov dword [FxTablebA1+16h*4],FxOpb16 mov dword [FxTablebA1+17h*4],FxOpb17 mov dword [FxTablebA1+18h*4],FxOpb18 mov dword [FxTablebA1+19h*4],FxOpb19 mov dword [FxTablebA1+1Ah*4],FxOpb1A mov dword [FxTablebA1+1Bh*4],FxOpb1B mov dword [FxTablebA1+1Ch*4],FxOpb1C mov dword [FxTablebA1+1Dh*4],FxOpb1D mov dword [FxTablebA1+1Eh*4],FxOpb1E mov dword [FxTablebA1+1Fh*4],FxOpb1F mov dword [FxTablebA1+3Dh*4],FxOpb3D mov dword [FxTablebA1+3Eh*4],FxOpb3E mov dword [FxTablebA1+3Fh*4],FxOpb3F mov dword [FxTablebA1+0B0h*4],FxOpbB0 mov dword [FxTablebA1+0B1h*4],FxOpbB1 mov dword [FxTablebA1+0B2h*4],FxOpbB2 mov dword [FxTablebA1+0B3h*4],FxOpbB3 mov dword [FxTablebA1+0B4h*4],FxOpbB4 mov dword [FxTablebA1+0B5h*4],FxOpbB5 mov dword [FxTablebA1+0B6h*4],FxOpbB6 mov dword [FxTablebA1+0B7h*4],FxOpbB7 mov dword [FxTablebA1+0B8h*4],FxOpbB8 mov dword [FxTablebA1+0B9h*4],FxOpbB9 mov dword [FxTablebA1+0BAh*4],FxOpbBA mov dword [FxTablebA1+0BBh*4],FxOpbBB mov dword [FxTablebA1+0BCh*4],FxOpbBC mov dword [FxTablebA1+0BDh*4],FxOpbBD mov dword [FxTablebA1+0BEh*4],FxOpbBE mov dword [FxTablebA1+0BFh*4],FxOpbBF mov dword [FxTablebA2+05h*4],FxOpb05 mov dword [FxTablebA2+06h*4],FxOpb06 mov dword [FxTablebA2+07h*4],FxOpb07 mov dword [FxTablebA2+08h*4],FxOpb08 mov dword [FxTablebA2+09h*4],FxOpb09 mov dword [FxTablebA2+0Ah*4],FxOpb0A mov dword [FxTablebA2+0Bh*4],FxOpb0B mov dword [FxTablebA2+0Ch*4],FxOpb0C mov dword [FxTablebA2+0Dh*4],FxOpb0D mov dword [FxTablebA2+0Eh*4],FxOpb0E mov dword [FxTablebA2+0Fh*4],FxOpb0F mov dword [FxTablebA2+10h*4],FxOpb10 mov dword [FxTablebA2+11h*4],FxOpb11 mov dword [FxTablebA2+12h*4],FxOpb12 mov dword [FxTablebA2+13h*4],FxOpb13 mov dword [FxTablebA2+14h*4],FxOpb14 mov dword [FxTablebA2+15h*4],FxOpb15 mov dword [FxTablebA2+16h*4],FxOpb16 mov dword [FxTablebA2+17h*4],FxOpb17 mov dword [FxTablebA2+18h*4],FxOpb18 mov dword [FxTablebA2+19h*4],FxOpb19 mov dword [FxTablebA2+1Ah*4],FxOpb1A mov dword [FxTablebA2+1Bh*4],FxOpb1B mov dword [FxTablebA2+1Ch*4],FxOpb1C mov dword [FxTablebA2+1Dh*4],FxOpb1D mov dword [FxTablebA2+1Eh*4],FxOpb1E mov dword [FxTablebA2+1Fh*4],FxOpb1F mov dword [FxTablebA2+3Dh*4],FxOpb3D mov dword [FxTablebA2+3Eh*4],FxOpb3E mov dword [FxTablebA2+3Fh*4],FxOpb3F mov dword [FxTablebA2+0B0h*4],FxOpbB0 mov dword [FxTablebA2+0B1h*4],FxOpbB1 mov dword [FxTablebA2+0B2h*4],FxOpbB2 mov dword [FxTablebA2+0B3h*4],FxOpbB3 mov dword [FxTablebA2+0B4h*4],FxOpbB4 mov dword [FxTablebA2+0B5h*4],FxOpbB5 mov dword [FxTablebA2+0B6h*4],FxOpbB6 mov dword [FxTablebA2+0B7h*4],FxOpbB7 mov dword [FxTablebA2+0B8h*4],FxOpbB8 mov dword [FxTablebA2+0B9h*4],FxOpbB9 mov dword [FxTablebA2+0BAh*4],FxOpbBA mov dword [FxTablebA2+0BBh*4],FxOpbBB mov dword [FxTablebA2+0BCh*4],FxOpbBC mov dword [FxTablebA2+0BDh*4],FxOpbBD mov dword [FxTablebA2+0BEh*4],FxOpbBE mov dword [FxTablebA2+0BFh*4],FxOpbBF mov dword [FxTablebA3+05h*4],FxOpb05 mov dword [FxTablebA3+06h*4],FxOpb06 mov dword [FxTablebA3+07h*4],FxOpb07 mov dword [FxTablebA3+08h*4],FxOpb08 mov dword [FxTablebA3+09h*4],FxOpb09 mov dword [FxTablebA3+0Ah*4],FxOpb0A mov dword [FxTablebA3+0Bh*4],FxOpb0B mov dword [FxTablebA3+0Ch*4],FxOpb0C mov dword [FxTablebA3+0Dh*4],FxOpb0D mov dword [FxTablebA3+0Eh*4],FxOpb0E mov dword [FxTablebA3+0Fh*4],FxOpb0F mov dword [FxTablebA3+10h*4],FxOpb10 mov dword [FxTablebA3+11h*4],FxOpb11 mov dword [FxTablebA3+12h*4],FxOpb12 mov dword [FxTablebA3+13h*4],FxOpb13 mov dword [FxTablebA3+14h*4],FxOpb14 mov dword [FxTablebA3+15h*4],FxOpb15 mov dword [FxTablebA3+16h*4],FxOpb16 mov dword [FxTablebA3+17h*4],FxOpb17 mov dword [FxTablebA3+18h*4],FxOpb18 mov dword [FxTablebA3+19h*4],FxOpb19 mov dword [FxTablebA3+1Ah*4],FxOpb1A mov dword [FxTablebA3+1Bh*4],FxOpb1B mov dword [FxTablebA3+1Ch*4],FxOpb1C mov dword [FxTablebA3+1Dh*4],FxOpb1D mov dword [FxTablebA3+1Eh*4],FxOpb1E mov dword [FxTablebA3+1Fh*4],FxOpb1F mov dword [FxTablebA3+3Dh*4],FxOpb3D mov dword [FxTablebA3+3Eh*4],FxOpb3E mov dword [FxTablebA3+3Fh*4],FxOpb3F mov dword [FxTablebA3+0B0h*4],FxOpbB0 mov dword [FxTablebA3+0B1h*4],FxOpbB1 mov dword [FxTablebA3+0B2h*4],FxOpbB2 mov dword [FxTablebA3+0B3h*4],FxOpbB3 mov dword [FxTablebA3+0B4h*4],FxOpbB4 mov dword [FxTablebA3+0B5h*4],FxOpbB5 mov dword [FxTablebA3+0B6h*4],FxOpbB6 mov dword [FxTablebA3+0B7h*4],FxOpbB7 mov dword [FxTablebA3+0B8h*4],FxOpbB8 mov dword [FxTablebA3+0B9h*4],FxOpbB9 mov dword [FxTablebA3+0BAh*4],FxOpbBA mov dword [FxTablebA3+0BBh*4],FxOpbBB mov dword [FxTablebA3+0BCh*4],FxOpbBC mov dword [FxTablebA3+0BDh*4],FxOpbBD mov dword [FxTablebA3+0BEh*4],FxOpbBE mov dword [FxTablebA3+0BFh*4],FxOpbBF mov dword [FxTablec+05h*4],FxOpc05 mov dword [FxTablec+06h*4],FxOpc06 mov dword [FxTablec+07h*4],FxOpc07 mov dword [FxTablec+08h*4],FxOpc08 mov dword [FxTablec+09h*4],FxOpc09 mov dword [FxTablec+0Ah*4],FxOpc0A mov dword [FxTablec+0Bh*4],FxOpc0B mov dword [FxTablec+0Ch*4],FxOpc0C mov dword [FxTablec+0Dh*4],FxOpc0D mov dword [FxTablec+0Eh*4],FxOpc0E mov dword [FxTablec+0Fh*4],FxOpc0F mov dword [FxTablec+10h*4],FxOpc10 mov dword [FxTablec+11h*4],FxOpc11 mov dword [FxTablec+12h*4],FxOpc12 mov dword [FxTablec+13h*4],FxOpc13 mov dword [FxTablec+14h*4],FxOpc14 mov dword [FxTablec+15h*4],FxOpc15 mov dword [FxTablec+16h*4],FxOpc16 mov dword [FxTablec+17h*4],FxOpc17 mov dword [FxTablec+18h*4],FxOpc18 mov dword [FxTablec+19h*4],FxOpc19 mov dword [FxTablec+1Ah*4],FxOpc1A mov dword [FxTablec+1Bh*4],FxOpc1B mov dword [FxTablec+1Ch*4],FxOpc1C mov dword [FxTablec+1Dh*4],FxOpc1D mov dword [FxTablec+1Eh*4],FxOpc1E mov dword [FxTablec+1Fh*4],FxOpc1F mov dword [FxTablec+3Dh*4],FxOpc3D mov dword [FxTablec+3Eh*4],FxOpc3E mov dword [FxTablec+3Fh*4],FxOpc3F mov dword [FxTablec+0B0h*4],FxOpcB0 mov dword [FxTablec+0B1h*4],FxOpcB1 mov dword [FxTablec+0B2h*4],FxOpcB2 mov dword [FxTablec+0B3h*4],FxOpcB3 mov dword [FxTablec+0B4h*4],FxOpcB4 mov dword [FxTablec+0B5h*4],FxOpcB5 mov dword [FxTablec+0B6h*4],FxOpcB6 mov dword [FxTablec+0B7h*4],FxOpcB7 mov dword [FxTablec+0B8h*4],FxOpcB8 mov dword [FxTablec+0B9h*4],FxOpcB9 mov dword [FxTablec+0BAh*4],FxOpcBA mov dword [FxTablec+0BBh*4],FxOpcBB mov dword [FxTablec+0BCh*4],FxOpcBC mov dword [FxTablec+0BDh*4],FxOpcBD mov dword [FxTablec+0BEh*4],FxOpcBE mov dword [FxTablec+0BFh*4],FxOpcBF mov dword [FxTablecA1+05h*4],FxOpc05 mov dword [FxTablecA1+06h*4],FxOpc06 mov dword [FxTablecA1+07h*4],FxOpc07 mov dword [FxTablecA1+08h*4],FxOpc08 mov dword [FxTablecA1+09h*4],FxOpc09 mov dword [FxTablecA1+0Ah*4],FxOpc0A mov dword [FxTablecA1+0Bh*4],FxOpc0B mov dword [FxTablecA1+0Ch*4],FxOpc0C mov dword [FxTablecA1+0Dh*4],FxOpc0D mov dword [FxTablecA1+0Eh*4],FxOpc0E mov dword [FxTablecA1+0Fh*4],FxOpc0F mov dword [FxTablecA1+10h*4],FxOpc10 mov dword [FxTablecA1+11h*4],FxOpc11 mov dword [FxTablecA1+12h*4],FxOpc12 mov dword [FxTablecA1+13h*4],FxOpc13 mov dword [FxTablecA1+14h*4],FxOpc14 mov dword [FxTablecA1+15h*4],FxOpc15 mov dword [FxTablecA1+16h*4],FxOpc16 mov dword [FxTablecA1+17h*4],FxOpc17 mov dword [FxTablecA1+18h*4],FxOpc18 mov dword [FxTablecA1+19h*4],FxOpc19 mov dword [FxTablecA1+1Ah*4],FxOpc1A mov dword [FxTablecA1+1Bh*4],FxOpc1B mov dword [FxTablecA1+1Ch*4],FxOpc1C mov dword [FxTablecA1+1Dh*4],FxOpc1D mov dword [FxTablecA1+1Eh*4],FxOpc1E mov dword [FxTablecA1+1Fh*4],FxOpc1F mov dword [FxTablecA1+3Dh*4],FxOpc3D mov dword [FxTablecA1+3Eh*4],FxOpc3E mov dword [FxTablecA1+3Fh*4],FxOpc3F mov dword [FxTablecA1+0B0h*4],FxOpcB0 mov dword [FxTablecA1+0B1h*4],FxOpcB1 mov dword [FxTablecA1+0B2h*4],FxOpcB2 mov dword [FxTablecA1+0B3h*4],FxOpcB3 mov dword [FxTablecA1+0B4h*4],FxOpcB4 mov dword [FxTablecA1+0B5h*4],FxOpcB5 mov dword [FxTablecA1+0B6h*4],FxOpcB6 mov dword [FxTablecA1+0B7h*4],FxOpcB7 mov dword [FxTablecA1+0B8h*4],FxOpcB8 mov dword [FxTablecA1+0B9h*4],FxOpcB9 mov dword [FxTablecA1+0BAh*4],FxOpcBA mov dword [FxTablecA1+0BBh*4],FxOpcBB mov dword [FxTablecA1+0BCh*4],FxOpcBC mov dword [FxTablecA1+0BDh*4],FxOpcBD mov dword [FxTablecA1+0BEh*4],FxOpcBE mov dword [FxTablecA1+0BFh*4],FxOpcBF mov dword [FxTablecA2+05h*4],FxOpc05 mov dword [FxTablecA2+06h*4],FxOpc06 mov dword [FxTablecA2+07h*4],FxOpc07 mov dword [FxTablecA2+08h*4],FxOpc08 mov dword [FxTablecA2+09h*4],FxOpc09 mov dword [FxTablecA2+0Ah*4],FxOpc0A mov dword [FxTablecA2+0Bh*4],FxOpc0B mov dword [FxTablecA2+0Ch*4],FxOpc0C mov dword [FxTablecA2+0Dh*4],FxOpc0D mov dword [FxTablecA2+0Eh*4],FxOpc0E mov dword [FxTablecA2+0Fh*4],FxOpc0F mov dword [FxTablecA2+10h*4],FxOpc10 mov dword [FxTablecA2+11h*4],FxOpc11 mov dword [FxTablecA2+12h*4],FxOpc12 mov dword [FxTablecA2+13h*4],FxOpc13 mov dword [FxTablecA2+14h*4],FxOpc14 mov dword [FxTablecA2+15h*4],FxOpc15 mov dword [FxTablecA2+16h*4],FxOpc16 mov dword [FxTablecA2+17h*4],FxOpc17 mov dword [FxTablecA2+18h*4],FxOpc18 mov dword [FxTablecA2+19h*4],FxOpc19 mov dword [FxTablecA2+1Ah*4],FxOpc1A mov dword [FxTablecA2+1Bh*4],FxOpc1B mov dword [FxTablecA2+1Ch*4],FxOpc1C mov dword [FxTablecA2+1Dh*4],FxOpc1D mov dword [FxTablecA2+1Eh*4],FxOpc1E mov dword [FxTablecA2+1Fh*4],FxOpc1F mov dword [FxTablecA2+3Dh*4],FxOpc3D mov dword [FxTablecA2+3Eh*4],FxOpc3E mov dword [FxTablecA2+3Fh*4],FxOpc3F mov dword [FxTablecA2+0B0h*4],FxOpcB0 mov dword [FxTablecA2+0B1h*4],FxOpcB1 mov dword [FxTablecA2+0B2h*4],FxOpcB2 mov dword [FxTablecA2+0B3h*4],FxOpcB3 mov dword [FxTablecA2+0B4h*4],FxOpcB4 mov dword [FxTablecA2+0B5h*4],FxOpcB5 mov dword [FxTablecA2+0B6h*4],FxOpcB6 mov dword [FxTablecA2+0B7h*4],FxOpcB7 mov dword [FxTablecA2+0B8h*4],FxOpcB8 mov dword [FxTablecA2+0B9h*4],FxOpcB9 mov dword [FxTablecA2+0BAh*4],FxOpcBA mov dword [FxTablecA2+0BBh*4],FxOpcBB mov dword [FxTablecA2+0BCh*4],FxOpcBC mov dword [FxTablecA2+0BDh*4],FxOpcBD mov dword [FxTablecA2+0BEh*4],FxOpcBE mov dword [FxTablecA2+0BFh*4],FxOpcBF mov dword [FxTablecA3+05h*4],FxOpc05 mov dword [FxTablecA3+06h*4],FxOpc06 mov dword [FxTablecA3+07h*4],FxOpc07 mov dword [FxTablecA3+08h*4],FxOpc08 mov dword [FxTablecA3+09h*4],FxOpc09 mov dword [FxTablecA3+0Ah*4],FxOpc0A mov dword [FxTablecA3+0Bh*4],FxOpc0B mov dword [FxTablecA3+0Ch*4],FxOpc0C mov dword [FxTablecA3+0Dh*4],FxOpc0D mov dword [FxTablecA3+0Eh*4],FxOpc0E mov dword [FxTablecA3+0Fh*4],FxOpc0F mov dword [FxTablecA3+10h*4],FxOpc10 mov dword [FxTablecA3+11h*4],FxOpc11 mov dword [FxTablecA3+12h*4],FxOpc12 mov dword [FxTablecA3+13h*4],FxOpc13 mov dword [FxTablecA3+14h*4],FxOpc14 mov dword [FxTablecA3+15h*4],FxOpc15 mov dword [FxTablecA3+16h*4],FxOpc16 mov dword [FxTablecA3+17h*4],FxOpc17 mov dword [FxTablecA3+18h*4],FxOpc18 mov dword [FxTablecA3+19h*4],FxOpc19 mov dword [FxTablecA3+1Ah*4],FxOpc1A mov dword [FxTablecA3+1Bh*4],FxOpc1B mov dword [FxTablecA3+1Ch*4],FxOpc1C mov dword [FxTablecA3+1Dh*4],FxOpc1D mov dword [FxTablecA3+1Eh*4],FxOpc1E mov dword [FxTablecA3+1Fh*4],FxOpc1F mov dword [FxTablecA3+3Dh*4],FxOpc3D mov dword [FxTablecA3+3Eh*4],FxOpc3E mov dword [FxTablecA3+3Fh*4],FxOpc3F mov dword [FxTablecA3+0B0h*4],FxOpcB0 mov dword [FxTablecA3+0B1h*4],FxOpcB1 mov dword [FxTablecA3+0B2h*4],FxOpcB2 mov dword [FxTablecA3+0B3h*4],FxOpcB3 mov dword [FxTablecA3+0B4h*4],FxOpcB4 mov dword [FxTablecA3+0B5h*4],FxOpcB5 mov dword [FxTablecA3+0B6h*4],FxOpcB6 mov dword [FxTablecA3+0B7h*4],FxOpcB7 mov dword [FxTablecA3+0B8h*4],FxOpcB8 mov dword [FxTablecA3+0B9h*4],FxOpcB9 mov dword [FxTablecA3+0BAh*4],FxOpcBA mov dword [FxTablecA3+0BBh*4],FxOpcBB mov dword [FxTablecA3+0BCh*4],FxOpcBC mov dword [FxTablecA3+0BDh*4],FxOpcBD mov dword [FxTablecA3+0BEh*4],FxOpcBE mov dword [FxTablecA3+0BFh*4],FxOpcBF mov dword [FxTabled+00h*4],FxOpd00 mov dword [FxTabled+01h*4],FxOpd01 mov dword [FxTabled+02h*4],FxOpd02 mov dword [FxTabled+03h*4],FxOpd03 mov dword [FxTabled+04h*4],FxOpd04 mov dword [FxTabled+05h*4],FxOpd05 mov dword [FxTabled+06h*4],FxOpd06 mov dword [FxTabled+07h*4],FxOpd07 mov dword [FxTabled+08h*4],FxOpd08 mov dword [FxTabled+09h*4],FxOpd09 mov dword [FxTabled+0Ah*4],FxOpd0A mov dword [FxTabled+0Bh*4],FxOpd0B mov dword [FxTabled+0Ch*4],FxOpd0C mov dword [FxTabled+0Dh*4],FxOpd0D mov dword [FxTabled+0Eh*4],FxOpd0E mov dword [FxTabled+0Fh*4],FxOpd0F mov dword [FxTabled+10h*4],FxOpd10 mov dword [FxTabled+11h*4],FxOpd11 mov dword [FxTabled+12h*4],FxOpd12 mov dword [FxTabled+13h*4],FxOpd13 mov dword [FxTabled+14h*4],FxOpd14 mov dword [FxTabled+15h*4],FxOpd15 mov dword [FxTabled+16h*4],FxOpd16 mov dword [FxTabled+17h*4],FxOpd17 mov dword [FxTabled+18h*4],FxOpd18 mov dword [FxTabled+19h*4],FxOpd19 mov dword [FxTabled+1Ah*4],FxOpd1A mov dword [FxTabled+1Bh*4],FxOpd1B mov dword [FxTabled+1Ch*4],FxOpd1C mov dword [FxTabled+1Dh*4],FxOpd1D mov dword [FxTabled+1Eh*4],FxOpd1E mov dword [FxTabled+1Fh*4],FxOpd1F mov dword [FxTabled+20h*4],FxOpd20 mov dword [FxTabled+21h*4],FxOpd21 mov dword [FxTabled+22h*4],FxOpd22 mov dword [FxTabled+23h*4],FxOpd23 mov dword [FxTabled+24h*4],FxOpd24 mov dword [FxTabled+25h*4],FxOpd25 mov dword [FxTabled+26h*4],FxOpd26 mov dword [FxTabled+27h*4],FxOpd27 mov dword [FxTabled+28h*4],FxOpd28 mov dword [FxTabled+29h*4],FxOpd29 mov dword [FxTabled+2Ah*4],FxOpd2A mov dword [FxTabled+2Bh*4],FxOpd2B mov dword [FxTabled+2Ch*4],FxOpd2C mov dword [FxTabled+2Dh*4],FxOpd2D mov dword [FxTabled+2Eh*4],FxOpd2E mov dword [FxTabled+2Fh*4],FxOpd2F mov dword [FxTabled+30h*4],FxOpd30 mov dword [FxTabled+31h*4],FxOpd31 mov dword [FxTabled+32h*4],FxOpd32 mov dword [FxTabled+33h*4],FxOpd33 mov dword [FxTabled+34h*4],FxOpd34 mov dword [FxTabled+35h*4],FxOpd35 mov dword [FxTabled+36h*4],FxOpd36 mov dword [FxTabled+37h*4],FxOpd37 mov dword [FxTabled+38h*4],FxOpd38 mov dword [FxTabled+39h*4],FxOpd39 mov dword [FxTabled+3Ah*4],FxOpd3A mov dword [FxTabled+3Bh*4],FxOpd3B mov dword [FxTabled+3Ch*4],FxOpd3C mov dword [FxTabled+3Dh*4],FxOpd3D mov dword [FxTabled+3Eh*4],FxOpd3E mov dword [FxTabled+3Fh*4],FxOpd3F mov dword [FxTabled+40h*4],FxOpd40 mov dword [FxTabled+41h*4],FxOpd41 mov dword [FxTabled+42h*4],FxOpd42 mov dword [FxTabled+43h*4],FxOpd43 mov dword [FxTabled+44h*4],FxOpd44 mov dword [FxTabled+45h*4],FxOpd45 mov dword [FxTabled+46h*4],FxOpd46 mov dword [FxTabled+47h*4],FxOpd47 mov dword [FxTabled+48h*4],FxOpd48 mov dword [FxTabled+49h*4],FxOpd49 mov dword [FxTabled+4Ah*4],FxOpd4A mov dword [FxTabled+4Bh*4],FxOpd4B mov dword [FxTabled+4Ch*4],FxOpd4C mov dword [FxTabled+4Dh*4],FxOpd4D mov dword [FxTabled+4Eh*4],FxOpd4E mov dword [FxTabled+4Fh*4],FxOpd4F mov dword [FxTabled+50h*4],FxOpd50 mov dword [FxTabled+51h*4],FxOpd51 mov dword [FxTabled+52h*4],FxOpd52 mov dword [FxTabled+53h*4],FxOpd53 mov dword [FxTabled+54h*4],FxOpd54 mov dword [FxTabled+55h*4],FxOpd55 mov dword [FxTabled+56h*4],FxOpd56 mov dword [FxTabled+57h*4],FxOpd57 mov dword [FxTabled+58h*4],FxOpd58 mov dword [FxTabled+59h*4],FxOpd59 mov dword [FxTabled+5Ah*4],FxOpd5A mov dword [FxTabled+5Bh*4],FxOpd5B mov dword [FxTabled+5Ch*4],FxOpd5C mov dword [FxTabled+5Dh*4],FxOpd5D mov dword [FxTabled+5Eh*4],FxOpd5E mov dword [FxTabled+5Fh*4],FxOpd5F mov dword [FxTabled+60h*4],FxOpd60 mov dword [FxTabled+61h*4],FxOpd61 mov dword [FxTabled+62h*4],FxOpd62 mov dword [FxTabled+63h*4],FxOpd63 mov dword [FxTabled+64h*4],FxOpd64 mov dword [FxTabled+65h*4],FxOpd65 mov dword [FxTabled+66h*4],FxOpd66 mov dword [FxTabled+67h*4],FxOpd67 mov dword [FxTabled+68h*4],FxOpd68 mov dword [FxTabled+69h*4],FxOpd69 mov dword [FxTabled+6Ah*4],FxOpd6A mov dword [FxTabled+6Bh*4],FxOpd6B mov dword [FxTabled+6Ch*4],FxOpd6C mov dword [FxTabled+6Dh*4],FxOpd6D mov dword [FxTabled+6Eh*4],FxOpd6E mov dword [FxTabled+6Fh*4],FxOpd6F mov dword [FxTabled+70h*4],FxOpd70 mov dword [FxTabled+71h*4],FxOpd71 mov dword [FxTabled+72h*4],FxOpd72 mov dword [FxTabled+73h*4],FxOpd73 mov dword [FxTabled+74h*4],FxOpd74 mov dword [FxTabled+75h*4],FxOpd75 mov dword [FxTabled+76h*4],FxOpd76 mov dword [FxTabled+77h*4],FxOpd77 mov dword [FxTabled+78h*4],FxOpd78 mov dword [FxTabled+79h*4],FxOpd79 mov dword [FxTabled+7Ah*4],FxOpd7A mov dword [FxTabled+7Bh*4],FxOpd7B mov dword [FxTabled+7Ch*4],FxOpd7C mov dword [FxTabled+7Dh*4],FxOpd7D mov dword [FxTabled+7Eh*4],FxOpd7E mov dword [FxTabled+7Fh*4],FxOpd7F mov dword [FxTabled+80h*4],FxOpd80 mov dword [FxTabled+81h*4],FxOpd81 mov dword [FxTabled+82h*4],FxOpd82 mov dword [FxTabled+83h*4],FxOpd83 mov dword [FxTabled+84h*4],FxOpd84 mov dword [FxTabled+85h*4],FxOpd85 mov dword [FxTabled+86h*4],FxOpd86 mov dword [FxTabled+87h*4],FxOpd87 mov dword [FxTabled+88h*4],FxOpd88 mov dword [FxTabled+89h*4],FxOpd89 mov dword [FxTabled+8Ah*4],FxOpd8A mov dword [FxTabled+8Bh*4],FxOpd8B mov dword [FxTabled+8Ch*4],FxOpd8C mov dword [FxTabled+8Dh*4],FxOpd8D mov dword [FxTabled+8Eh*4],FxOpd8E mov dword [FxTabled+8Fh*4],FxOpd8F mov dword [FxTabled+90h*4],FxOpd90 mov dword [FxTabled+91h*4],FxOpd91 mov dword [FxTabled+92h*4],FxOpd92 mov dword [FxTabled+93h*4],FxOpd93 mov dword [FxTabled+94h*4],FxOpd94 mov dword [FxTabled+95h*4],FxOpd95 mov dword [FxTabled+96h*4],FxOpd96 mov dword [FxTabled+97h*4],FxOpd97 mov dword [FxTabled+98h*4],FxOpd98 mov dword [FxTabled+99h*4],FxOpd99 mov dword [FxTabled+9Ah*4],FxOpd9A mov dword [FxTabled+9Bh*4],FxOpd9B mov dword [FxTabled+9Ch*4],FxOpd9C mov dword [FxTabled+9Dh*4],FxOpd9D mov dword [FxTabled+9Eh*4],FxOpd9E mov dword [FxTabled+9Fh*4],FxOpd9F mov dword [FxTabled+0A0h*4],FxOpdA0 mov dword [FxTabled+0A1h*4],FxOpdA1 mov dword [FxTabled+0A2h*4],FxOpdA2 mov dword [FxTabled+0A3h*4],FxOpdA3 mov dword [FxTabled+0A4h*4],FxOpdA4 mov dword [FxTabled+0A5h*4],FxOpdA5 mov dword [FxTabled+0A6h*4],FxOpdA6 mov dword [FxTabled+0A7h*4],FxOpdA7 mov dword [FxTabled+0A8h*4],FxOpdA8 mov dword [FxTabled+0A9h*4],FxOpdA9 mov dword [FxTabled+0AAh*4],FxOpdAA mov dword [FxTabled+0ABh*4],FxOpdAB mov dword [FxTabled+0ACh*4],FxOpdAC mov dword [FxTabled+0ADh*4],FxOpdAD mov dword [FxTabled+0AEh*4],FxOpdAE mov dword [FxTabled+0AFh*4],FxOpdAF mov dword [FxTabled+0B0h*4],FxOpdB0 mov dword [FxTabled+0B1h*4],FxOpdB1 mov dword [FxTabled+0B2h*4],FxOpdB2 mov dword [FxTabled+0B3h*4],FxOpdB3 mov dword [FxTabled+0B4h*4],FxOpdB4 mov dword [FxTabled+0B5h*4],FxOpdB5 mov dword [FxTabled+0B6h*4],FxOpdB6 mov dword [FxTabled+0B7h*4],FxOpdB7 mov dword [FxTabled+0B8h*4],FxOpdB8 mov dword [FxTabled+0B9h*4],FxOpdB9 mov dword [FxTabled+0BAh*4],FxOpdBA mov dword [FxTabled+0BBh*4],FxOpdBB mov dword [FxTabled+0BCh*4],FxOpdBC mov dword [FxTabled+0BDh*4],FxOpdBD mov dword [FxTabled+0BEh*4],FxOpdBE mov dword [FxTabled+0BFh*4],FxOpdBF mov dword [FxTabled+0C0h*4],FxOpdC0 mov dword [FxTabled+0C1h*4],FxOpdC1 mov dword [FxTabled+0C2h*4],FxOpdC2 mov dword [FxTabled+0C3h*4],FxOpdC3 mov dword [FxTabled+0C4h*4],FxOpdC4 mov dword [FxTabled+0C5h*4],FxOpdC5 mov dword [FxTabled+0C6h*4],FxOpdC6 mov dword [FxTabled+0C7h*4],FxOpdC7 mov dword [FxTabled+0C8h*4],FxOpdC8 mov dword [FxTabled+0C9h*4],FxOpdC9 mov dword [FxTabled+0CAh*4],FxOpdCA mov dword [FxTabled+0CBh*4],FxOpdCB mov dword [FxTabled+0CCh*4],FxOpdCC mov dword [FxTabled+0CDh*4],FxOpdCD mov dword [FxTabled+0CEh*4],FxOpdCE mov dword [FxTabled+0CFh*4],FxOpdCF mov dword [FxTabled+0D0h*4],FxOpdD0 mov dword [FxTabled+0D1h*4],FxOpdD1 mov dword [FxTabled+0D2h*4],FxOpdD2 mov dword [FxTabled+0D3h*4],FxOpdD3 mov dword [FxTabled+0D4h*4],FxOpdD4 mov dword [FxTabled+0D5h*4],FxOpdD5 mov dword [FxTabled+0D6h*4],FxOpdD6 mov dword [FxTabled+0D7h*4],FxOpdD7 mov dword [FxTabled+0D8h*4],FxOpdD8 mov dword [FxTabled+0D9h*4],FxOpdD9 mov dword [FxTabled+0DAh*4],FxOpdDA mov dword [FxTabled+0DBh*4],FxOpdDB mov dword [FxTabled+0DCh*4],FxOpdDC mov dword [FxTabled+0DDh*4],FxOpdDD mov dword [FxTabled+0DEh*4],FxOpdDE mov dword [FxTabled+0DFh*4],FxOpdDF mov dword [FxTabled+0E0h*4],FxOpdE0 mov dword [FxTabled+0E1h*4],FxOpdE1 mov dword [FxTabled+0E2h*4],FxOpdE2 mov dword [FxTabled+0E3h*4],FxOpdE3 mov dword [FxTabled+0E4h*4],FxOpdE4 mov dword [FxTabled+0E5h*4],FxOpdE5 mov dword [FxTabled+0E6h*4],FxOpdE6 mov dword [FxTabled+0E7h*4],FxOpdE7 mov dword [FxTabled+0E8h*4],FxOpdE8 mov dword [FxTabled+0E9h*4],FxOpdE9 mov dword [FxTabled+0EAh*4],FxOpdEA mov dword [FxTabled+0EBh*4],FxOpdEB mov dword [FxTabled+0ECh*4],FxOpdEC mov dword [FxTabled+0EDh*4],FxOpdED mov dword [FxTabled+0EEh*4],FxOpdEE mov dword [FxTabled+0EFh*4],FxOpdEF mov dword [FxTabled+0F0h*4],FxOpdF0 mov dword [FxTabled+0F1h*4],FxOpdF1 mov dword [FxTabled+0F2h*4],FxOpdF2 mov dword [FxTabled+0F3h*4],FxOpdF3 mov dword [FxTabled+0F4h*4],FxOpdF4 mov dword [FxTabled+0F5h*4],FxOpdF5 mov dword [FxTabled+0F6h*4],FxOpdF6 mov dword [FxTabled+0F7h*4],FxOpdF7 mov dword [FxTabled+0F8h*4],FxOpdF8 mov dword [FxTabled+0F9h*4],FxOpdF9 mov dword [FxTabled+0FAh*4],FxOpdFA mov dword [FxTabled+0FBh*4],FxOpdFB mov dword [FxTabled+0FCh*4],FxOpdFC mov dword [FxTabled+0FDh*4],FxOpdFD mov dword [FxTabled+0FEh*4],FxOpdFE mov dword [FxTabled+0FFh*4],FxOpdFF mov dword [FxTabledA1+00h*4],FxOpd00 mov dword [FxTabledA1+01h*4],FxOpd01 mov dword [FxTabledA1+02h*4],FxOpd02 mov dword [FxTabledA1+03h*4],FxOpd03 mov dword [FxTabledA1+04h*4],FxOpd04 mov dword [FxTabledA1+05h*4],FxOpd05 mov dword [FxTabledA1+06h*4],FxOpd06 mov dword [FxTabledA1+07h*4],FxOpd07 mov dword [FxTabledA1+08h*4],FxOpd08 mov dword [FxTabledA1+09h*4],FxOpd09 mov dword [FxTabledA1+0Ah*4],FxOpd0A mov dword [FxTabledA1+0Bh*4],FxOpd0B mov dword [FxTabledA1+0Ch*4],FxOpd0C mov dword [FxTabledA1+0Dh*4],FxOpd0D mov dword [FxTabledA1+0Eh*4],FxOpd0E mov dword [FxTabledA1+0Fh*4],FxOpd0F mov dword [FxTabledA1+10h*4],FxOpd10 mov dword [FxTabledA1+11h*4],FxOpd11 mov dword [FxTabledA1+12h*4],FxOpd12 mov dword [FxTabledA1+13h*4],FxOpd13 mov dword [FxTabledA1+14h*4],FxOpd14 mov dword [FxTabledA1+15h*4],FxOpd15 mov dword [FxTabledA1+16h*4],FxOpd16 mov dword [FxTabledA1+17h*4],FxOpd17 mov dword [FxTabledA1+18h*4],FxOpd18 mov dword [FxTabledA1+19h*4],FxOpd19 mov dword [FxTabledA1+1Ah*4],FxOpd1A mov dword [FxTabledA1+1Bh*4],FxOpd1B mov dword [FxTabledA1+1Ch*4],FxOpd1C mov dword [FxTabledA1+1Dh*4],FxOpd1D mov dword [FxTabledA1+1Eh*4],FxOpd1E mov dword [FxTabledA1+1Fh*4],FxOpd1F mov dword [FxTabledA1+20h*4],FxOpd20 mov dword [FxTabledA1+21h*4],FxOpd21 mov dword [FxTabledA1+22h*4],FxOpd22 mov dword [FxTabledA1+23h*4],FxOpd23 mov dword [FxTabledA1+24h*4],FxOpd24 mov dword [FxTabledA1+25h*4],FxOpd25 mov dword [FxTabledA1+26h*4],FxOpd26 mov dword [FxTabledA1+27h*4],FxOpd27 mov dword [FxTabledA1+28h*4],FxOpd28 mov dword [FxTabledA1+29h*4],FxOpd29 mov dword [FxTabledA1+2Ah*4],FxOpd2A mov dword [FxTabledA1+2Bh*4],FxOpd2B mov dword [FxTabledA1+2Ch*4],FxOpd2C mov dword [FxTabledA1+2Dh*4],FxOpd2D mov dword [FxTabledA1+2Eh*4],FxOpd2E mov dword [FxTabledA1+2Fh*4],FxOpd2F mov dword [FxTabledA1+30h*4],FxOpd30A1 mov dword [FxTabledA1+31h*4],FxOpd31A1 mov dword [FxTabledA1+32h*4],FxOpd32A1 mov dword [FxTabledA1+33h*4],FxOpd33A1 mov dword [FxTabledA1+34h*4],FxOpd34A1 mov dword [FxTabledA1+35h*4],FxOpd35A1 mov dword [FxTabledA1+36h*4],FxOpd36A1 mov dword [FxTabledA1+37h*4],FxOpd37A1 mov dword [FxTabledA1+38h*4],FxOpd38A1 mov dword [FxTabledA1+39h*4],FxOpd39A1 mov dword [FxTabledA1+3Ah*4],FxOpd3AA1 mov dword [FxTabledA1+3Bh*4],FxOpd3BA1 mov dword [FxTabledA1+3Ch*4],FxOpd3C mov dword [FxTabledA1+3Dh*4],FxOpd3D mov dword [FxTabledA1+3Eh*4],FxOpd3E mov dword [FxTabledA1+3Fh*4],FxOpd3F mov dword [FxTabledA1+40h*4],FxOpd40A1 mov dword [FxTabledA1+41h*4],FxOpd41A1 mov dword [FxTabledA1+42h*4],FxOpd42A1 mov dword [FxTabledA1+43h*4],FxOpd43A1 mov dword [FxTabledA1+44h*4],FxOpd44A1 mov dword [FxTabledA1+45h*4],FxOpd45A1 mov dword [FxTabledA1+46h*4],FxOpd46A1 mov dword [FxTabledA1+47h*4],FxOpd47A1 mov dword [FxTabledA1+48h*4],FxOpd48A1 mov dword [FxTabledA1+49h*4],FxOpd49A1 mov dword [FxTabledA1+4Ah*4],FxOpd4AA1 mov dword [FxTabledA1+4Bh*4],FxOpd4BA1 mov dword [FxTabledA1+4Ch*4],FxOpd4CA1 mov dword [FxTabledA1+4Dh*4],FxOpd4D mov dword [FxTabledA1+4Eh*4],FxOpd4EA1 mov dword [FxTabledA1+4Fh*4],FxOpd4F mov dword [FxTabledA1+50h*4],FxOpd50A1 mov dword [FxTabledA1+51h*4],FxOpd51A1 mov dword [FxTabledA1+52h*4],FxOpd52A1 mov dword [FxTabledA1+53h*4],FxOpd53A1 mov dword [FxTabledA1+54h*4],FxOpd54A1 mov dword [FxTabledA1+55h*4],FxOpd55A1 mov dword [FxTabledA1+56h*4],FxOpd56A1 mov dword [FxTabledA1+57h*4],FxOpd57A1 mov dword [FxTabledA1+58h*4],FxOpd58A1 mov dword [FxTabledA1+59h*4],FxOpd59A1 mov dword [FxTabledA1+5Ah*4],FxOpd5AA1 mov dword [FxTabledA1+5Bh*4],FxOpd5BA1 mov dword [FxTabledA1+5Ch*4],FxOpd5CA1 mov dword [FxTabledA1+5Dh*4],FxOpd5DA1 mov dword [FxTabledA1+5Eh*4],FxOpd5EA1 mov dword [FxTabledA1+5Fh*4],FxOpd5FA1 mov dword [FxTabledA1+60h*4],FxOpd60A1 mov dword [FxTabledA1+61h*4],FxOpd61A1 mov dword [FxTabledA1+62h*4],FxOpd62A1 mov dword [FxTabledA1+63h*4],FxOpd63A1 mov dword [FxTabledA1+64h*4],FxOpd64A1 mov dword [FxTabledA1+65h*4],FxOpd65A1 mov dword [FxTabledA1+66h*4],FxOpd66A1 mov dword [FxTabledA1+67h*4],FxOpd67A1 mov dword [FxTabledA1+68h*4],FxOpd68A1 mov dword [FxTabledA1+69h*4],FxOpd69A1 mov dword [FxTabledA1+6Ah*4],FxOpd6AA1 mov dword [FxTabledA1+6Bh*4],FxOpd6BA1 mov dword [FxTabledA1+6Ch*4],FxOpd6CA1 mov dword [FxTabledA1+6Dh*4],FxOpd6DA1 mov dword [FxTabledA1+6Eh*4],FxOpd6EA1 mov dword [FxTabledA1+6Fh*4],FxOpd6FA1 mov dword [FxTabledA1+70h*4],FxOpd70 mov dword [FxTabledA1+71h*4],FxOpd71A1 mov dword [FxTabledA1+72h*4],FxOpd72A1 mov dword [FxTabledA1+73h*4],FxOpd73A1 mov dword [FxTabledA1+74h*4],FxOpd74A1 mov dword [FxTabledA1+75h*4],FxOpd75A1 mov dword [FxTabledA1+76h*4],FxOpd76A1 mov dword [FxTabledA1+77h*4],FxOpd77A1 mov dword [FxTabledA1+78h*4],FxOpd78A1 mov dword [FxTabledA1+79h*4],FxOpd79A1 mov dword [FxTabledA1+7Ah*4],FxOpd7AA1 mov dword [FxTabledA1+7Bh*4],FxOpd7BA1 mov dword [FxTabledA1+7Ch*4],FxOpd7CA1 mov dword [FxTabledA1+7Dh*4],FxOpd7DA1 mov dword [FxTabledA1+7Eh*4],FxOpd7EA1 mov dword [FxTabledA1+7Fh*4],FxOpd7FA1 mov dword [FxTabledA1+80h*4],FxOpd80A1 mov dword [FxTabledA1+81h*4],FxOpd81A1 mov dword [FxTabledA1+82h*4],FxOpd82A1 mov dword [FxTabledA1+83h*4],FxOpd83A1 mov dword [FxTabledA1+84h*4],FxOpd84A1 mov dword [FxTabledA1+85h*4],FxOpd85A1 mov dword [FxTabledA1+86h*4],FxOpd86A1 mov dword [FxTabledA1+87h*4],FxOpd87A1 mov dword [FxTabledA1+88h*4],FxOpd88A1 mov dword [FxTabledA1+89h*4],FxOpd89A1 mov dword [FxTabledA1+8Ah*4],FxOpd8AA1 mov dword [FxTabledA1+8Bh*4],FxOpd8BA1 mov dword [FxTabledA1+8Ch*4],FxOpd8CA1 mov dword [FxTabledA1+8Dh*4],FxOpd8DA1 mov dword [FxTabledA1+8Eh*4],FxOpd8EA1 mov dword [FxTabledA1+8Fh*4],FxOpd8FA1 mov dword [FxTabledA1+90h*4],FxOpd90 mov dword [FxTabledA1+91h*4],FxOpd91 mov dword [FxTabledA1+92h*4],FxOpd92 mov dword [FxTabledA1+93h*4],FxOpd93 mov dword [FxTabledA1+94h*4],FxOpd94 mov dword [FxTabledA1+95h*4],FxOpd95 mov dword [FxTabledA1+96h*4],FxOpd96A1 mov dword [FxTabledA1+97h*4],FxOpd97 mov dword [FxTabledA1+98h*4],FxOpd98A1 mov dword [FxTabledA1+99h*4],FxOpd99A1 mov dword [FxTabledA1+9Ah*4],FxOpd9AA1 mov dword [FxTabledA1+9Bh*4],FxOpd9BA1 mov dword [FxTabledA1+9Ch*4],FxOpd9CA1 mov dword [FxTabledA1+9Dh*4],FxOpd9DA1 mov dword [FxTabledA1+9Eh*4],FxOpd9E mov dword [FxTabledA1+9Fh*4],FxOpd9FA1 mov dword [FxTabledA1+0A0h*4],FxOpdA0A1 mov dword [FxTabledA1+0A1h*4],FxOpdA1A1 mov dword [FxTabledA1+0A2h*4],FxOpdA2A1 mov dword [FxTabledA1+0A3h*4],FxOpdA3A1 mov dword [FxTabledA1+0A4h*4],FxOpdA4A1 mov dword [FxTabledA1+0A5h*4],FxOpdA5A1 mov dword [FxTabledA1+0A6h*4],FxOpdA6A1 mov dword [FxTabledA1+0A7h*4],FxOpdA7A1 mov dword [FxTabledA1+0A8h*4],FxOpdA8A1 mov dword [FxTabledA1+0A9h*4],FxOpdA9A1 mov dword [FxTabledA1+0AAh*4],FxOpdAAA1 mov dword [FxTabledA1+0ABh*4],FxOpdABA1 mov dword [FxTabledA1+0ACh*4],FxOpdACA1 mov dword [FxTabledA1+0ADh*4],FxOpdADA1 mov dword [FxTabledA1+0AEh*4],FxOpdAEA1 mov dword [FxTabledA1+0AFh*4],FxOpdAFA1 mov dword [FxTabledA1+0B0h*4],FxOpdB0 mov dword [FxTabledA1+0B1h*4],FxOpdB1 mov dword [FxTabledA1+0B2h*4],FxOpdB2 mov dword [FxTabledA1+0B3h*4],FxOpdB3 mov dword [FxTabledA1+0B4h*4],FxOpdB4 mov dword [FxTabledA1+0B5h*4],FxOpdB5 mov dword [FxTabledA1+0B6h*4],FxOpdB6 mov dword [FxTabledA1+0B7h*4],FxOpdB7 mov dword [FxTabledA1+0B8h*4],FxOpdB8 mov dword [FxTabledA1+0B9h*4],FxOpdB9 mov dword [FxTabledA1+0BAh*4],FxOpdBA mov dword [FxTabledA1+0BBh*4],FxOpdBB mov dword [FxTabledA1+0BCh*4],FxOpdBC mov dword [FxTabledA1+0BDh*4],FxOpdBD mov dword [FxTabledA1+0BEh*4],FxOpdBE mov dword [FxTabledA1+0BFh*4],FxOpdBF mov dword [FxTabledA1+0C0h*4],FxOpdC0 mov dword [FxTabledA1+0C1h*4],FxOpdC1A1 mov dword [FxTabledA1+0C2h*4],FxOpdC2A1 mov dword [FxTabledA1+0C3h*4],FxOpdC3A1 mov dword [FxTabledA1+0C4h*4],FxOpdC4A1 mov dword [FxTabledA1+0C5h*4],FxOpdC5A1 mov dword [FxTabledA1+0C6h*4],FxOpdC6A1 mov dword [FxTabledA1+0C7h*4],FxOpdC7A1 mov dword [FxTabledA1+0C8h*4],FxOpdC8A1 mov dword [FxTabledA1+0C9h*4],FxOpdC9A1 mov dword [FxTabledA1+0CAh*4],FxOpdCAA1 mov dword [FxTabledA1+0CBh*4],FxOpdCBA1 mov dword [FxTabledA1+0CCh*4],FxOpdCCA1 mov dword [FxTabledA1+0CDh*4],FxOpdCDA1 mov dword [FxTabledA1+0CEh*4],FxOpdCEA1 mov dword [FxTabledA1+0CFh*4],FxOpdCFA1 mov dword [FxTabledA1+0D0h*4],FxOpdD0 mov dword [FxTabledA1+0D1h*4],FxOpdD1 mov dword [FxTabledA1+0D2h*4],FxOpdD2 mov dword [FxTabledA1+0D3h*4],FxOpdD3 mov dword [FxTabledA1+0D4h*4],FxOpdD4 mov dword [FxTabledA1+0D5h*4],FxOpdD5 mov dword [FxTabledA1+0D6h*4],FxOpdD6 mov dword [FxTabledA1+0D7h*4],FxOpdD7 mov dword [FxTabledA1+0D8h*4],FxOpdD8 mov dword [FxTabledA1+0D9h*4],FxOpdD9 mov dword [FxTabledA1+0DAh*4],FxOpdDA mov dword [FxTabledA1+0DBh*4],FxOpdDB mov dword [FxTabledA1+0DCh*4],FxOpdDC mov dword [FxTabledA1+0DDh*4],FxOpdDD mov dword [FxTabledA1+0DEh*4],FxOpdDE mov dword [FxTabledA1+0DFh*4],FxOpdDF mov dword [FxTabledA1+0E0h*4],FxOpdE0 mov dword [FxTabledA1+0E1h*4],FxOpdE1 mov dword [FxTabledA1+0E2h*4],FxOpdE2 mov dword [FxTabledA1+0E3h*4],FxOpdE3 mov dword [FxTabledA1+0E4h*4],FxOpdE4 mov dword [FxTabledA1+0E5h*4],FxOpdE5 mov dword [FxTabledA1+0E6h*4],FxOpdE6 mov dword [FxTabledA1+0E7h*4],FxOpdE7 mov dword [FxTabledA1+0E8h*4],FxOpdE8 mov dword [FxTabledA1+0E9h*4],FxOpdE9 mov dword [FxTabledA1+0EAh*4],FxOpdEA mov dword [FxTabledA1+0EBh*4],FxOpdEB mov dword [FxTabledA1+0ECh*4],FxOpdEC mov dword [FxTabledA1+0EDh*4],FxOpdED mov dword [FxTabledA1+0EEh*4],FxOpdEE mov dword [FxTabledA1+0EFh*4],FxOpdEFA1 mov dword [FxTabledA1+0F0h*4],FxOpdF0A1 mov dword [FxTabledA1+0F1h*4],FxOpdF1A1 mov dword [FxTabledA1+0F2h*4],FxOpdF2A1 mov dword [FxTabledA1+0F3h*4],FxOpdF3A1 mov dword [FxTabledA1+0F4h*4],FxOpdF4A1 mov dword [FxTabledA1+0F5h*4],FxOpdF5A1 mov dword [FxTabledA1+0F6h*4],FxOpdF6A1 mov dword [FxTabledA1+0F7h*4],FxOpdF7A1 mov dword [FxTabledA1+0F8h*4],FxOpdF8A1 mov dword [FxTabledA1+0F9h*4],FxOpdF9A1 mov dword [FxTabledA1+0FAh*4],FxOpdFAA1 mov dword [FxTabledA1+0FBh*4],FxOpdFBA1 mov dword [FxTabledA1+0FCh*4],FxOpdFCA1 mov dword [FxTabledA1+0FDh*4],FxOpdFDA1 mov dword [FxTabledA1+0FEh*4],FxOpdFEA1 mov dword [FxTabledA1+0FFh*4],FxOpdFFA1 mov dword [FxTabledA2+00h*4],FxOpd00 mov dword [FxTabledA2+01h*4],FxOpd01 mov dword [FxTabledA2+02h*4],FxOpd02 mov dword [FxTabledA2+03h*4],FxOpd03 mov dword [FxTabledA2+04h*4],FxOpd04 mov dword [FxTabledA2+05h*4],FxOpd05 mov dword [FxTabledA2+06h*4],FxOpd06 mov dword [FxTabledA2+07h*4],FxOpd07 mov dword [FxTabledA2+08h*4],FxOpd08 mov dword [FxTabledA2+09h*4],FxOpd09 mov dword [FxTabledA2+0Ah*4],FxOpd0A mov dword [FxTabledA2+0Bh*4],FxOpd0B mov dword [FxTabledA2+0Ch*4],FxOpd0C mov dword [FxTabledA2+0Dh*4],FxOpd0D mov dword [FxTabledA2+0Eh*4],FxOpd0E mov dword [FxTabledA2+0Fh*4],FxOpd0F mov dword [FxTabledA2+10h*4],FxOpd10 mov dword [FxTabledA2+11h*4],FxOpd11 mov dword [FxTabledA2+12h*4],FxOpd12 mov dword [FxTabledA2+13h*4],FxOpd13 mov dword [FxTabledA2+14h*4],FxOpd14 mov dword [FxTabledA2+15h*4],FxOpd15 mov dword [FxTabledA2+16h*4],FxOpd16 mov dword [FxTabledA2+17h*4],FxOpd17 mov dword [FxTabledA2+18h*4],FxOpd18 mov dword [FxTabledA2+19h*4],FxOpd19 mov dword [FxTabledA2+1Ah*4],FxOpd1A mov dword [FxTabledA2+1Bh*4],FxOpd1B mov dword [FxTabledA2+1Ch*4],FxOpd1C mov dword [FxTabledA2+1Dh*4],FxOpd1D mov dword [FxTabledA2+1Eh*4],FxOpd1E mov dword [FxTabledA2+1Fh*4],FxOpd1F mov dword [FxTabledA2+20h*4],FxOpd20 mov dword [FxTabledA2+21h*4],FxOpd21 mov dword [FxTabledA2+22h*4],FxOpd22 mov dword [FxTabledA2+23h*4],FxOpd23 mov dword [FxTabledA2+24h*4],FxOpd24 mov dword [FxTabledA2+25h*4],FxOpd25 mov dword [FxTabledA2+26h*4],FxOpd26 mov dword [FxTabledA2+27h*4],FxOpd27 mov dword [FxTabledA2+28h*4],FxOpd28 mov dword [FxTabledA2+29h*4],FxOpd29 mov dword [FxTabledA2+2Ah*4],FxOpd2A mov dword [FxTabledA2+2Bh*4],FxOpd2B mov dword [FxTabledA2+2Ch*4],FxOpd2C mov dword [FxTabledA2+2Dh*4],FxOpd2D mov dword [FxTabledA2+2Eh*4],FxOpd2E mov dword [FxTabledA2+2Fh*4],FxOpd2F mov dword [FxTabledA2+30h*4],FxOpd30 mov dword [FxTabledA2+31h*4],FxOpd31 mov dword [FxTabledA2+32h*4],FxOpd32 mov dword [FxTabledA2+33h*4],FxOpd33 mov dword [FxTabledA2+34h*4],FxOpd34 mov dword [FxTabledA2+35h*4],FxOpd35 mov dword [FxTabledA2+36h*4],FxOpd36 mov dword [FxTabledA2+37h*4],FxOpd37 mov dword [FxTabledA2+38h*4],FxOpd38 mov dword [FxTabledA2+39h*4],FxOpd39 mov dword [FxTabledA2+3Ah*4],FxOpd3A mov dword [FxTabledA2+3Bh*4],FxOpd3B mov dword [FxTabledA2+3Ch*4],FxOpd3C mov dword [FxTabledA2+3Dh*4],FxOpd3D mov dword [FxTabledA2+3Eh*4],FxOpd3E mov dword [FxTabledA2+3Fh*4],FxOpd3F mov dword [FxTabledA2+40h*4],FxOpd40 mov dword [FxTabledA2+41h*4],FxOpd41 mov dword [FxTabledA2+42h*4],FxOpd42 mov dword [FxTabledA2+43h*4],FxOpd43 mov dword [FxTabledA2+44h*4],FxOpd44 mov dword [FxTabledA2+45h*4],FxOpd45 mov dword [FxTabledA2+46h*4],FxOpd46 mov dword [FxTabledA2+47h*4],FxOpd47 mov dword [FxTabledA2+48h*4],FxOpd48 mov dword [FxTabledA2+49h*4],FxOpd49 mov dword [FxTabledA2+4Ah*4],FxOpd4A mov dword [FxTabledA2+4Bh*4],FxOpd4B mov dword [FxTabledA2+4Ch*4],FxOpd4C mov dword [FxTabledA2+4Dh*4],FxOpd4D mov dword [FxTabledA2+4Eh*4],FxOpd4E mov dword [FxTabledA2+4Fh*4],FxOpd4F mov dword [FxTabledA2+50h*4],FxOpd50A2 mov dword [FxTabledA2+51h*4],FxOpd51A2 mov dword [FxTabledA2+52h*4],FxOpd52A2 mov dword [FxTabledA2+53h*4],FxOpd53A2 mov dword [FxTabledA2+54h*4],FxOpd54A2 mov dword [FxTabledA2+55h*4],FxOpd55A2 mov dword [FxTabledA2+56h*4],FxOpd56A2 mov dword [FxTabledA2+57h*4],FxOpd57A2 mov dword [FxTabledA2+58h*4],FxOpd58A2 mov dword [FxTabledA2+59h*4],FxOpd59A2 mov dword [FxTabledA2+5Ah*4],FxOpd5AA2 mov dword [FxTabledA2+5Bh*4],FxOpd5BA2 mov dword [FxTabledA2+5Ch*4],FxOpd5CA2 mov dword [FxTabledA2+5Dh*4],FxOpd5DA2 mov dword [FxTabledA2+5Eh*4],FxOpd5EA2 mov dword [FxTabledA2+5Fh*4],FxOpd5FA2 mov dword [FxTabledA2+60h*4],FxOpd60A2 mov dword [FxTabledA2+61h*4],FxOpd61A2 mov dword [FxTabledA2+62h*4],FxOpd62A2 mov dword [FxTabledA2+63h*4],FxOpd63A2 mov dword [FxTabledA2+64h*4],FxOpd64A2 mov dword [FxTabledA2+65h*4],FxOpd65A2 mov dword [FxTabledA2+66h*4],FxOpd66A2 mov dword [FxTabledA2+67h*4],FxOpd67A2 mov dword [FxTabledA2+68h*4],FxOpd68A2 mov dword [FxTabledA2+69h*4],FxOpd69A2 mov dword [FxTabledA2+6Ah*4],FxOpd6AA2 mov dword [FxTabledA2+6Bh*4],FxOpd6BA2 mov dword [FxTabledA2+6Ch*4],FxOpd6CA2 mov dword [FxTabledA2+6Dh*4],FxOpd6DA2 mov dword [FxTabledA2+6Eh*4],FxOpd6EA2 mov dword [FxTabledA2+6Fh*4],FxOpd6FA2 mov dword [FxTabledA2+70h*4],FxOpd70 mov dword [FxTabledA2+71h*4],FxOpd71A2 mov dword [FxTabledA2+72h*4],FxOpd72A2 mov dword [FxTabledA2+73h*4],FxOpd73A2 mov dword [FxTabledA2+74h*4],FxOpd74A2 mov dword [FxTabledA2+75h*4],FxOpd75A2 mov dword [FxTabledA2+76h*4],FxOpd76A2 mov dword [FxTabledA2+77h*4],FxOpd77A2 mov dword [FxTabledA2+78h*4],FxOpd78A2 mov dword [FxTabledA2+79h*4],FxOpd79A2 mov dword [FxTabledA2+7Ah*4],FxOpd7AA2 mov dword [FxTabledA2+7Bh*4],FxOpd7BA2 mov dword [FxTabledA2+7Ch*4],FxOpd7CA2 mov dword [FxTabledA2+7Dh*4],FxOpd7DA2 mov dword [FxTabledA2+7Eh*4],FxOpd7EA2 mov dword [FxTabledA2+7Fh*4],FxOpd7FA2 mov dword [FxTabledA2+80h*4],FxOpd80A2 mov dword [FxTabledA2+81h*4],FxOpd81A2 mov dword [FxTabledA2+82h*4],FxOpd82A2 mov dword [FxTabledA2+83h*4],FxOpd83A2 mov dword [FxTabledA2+84h*4],FxOpd84A2 mov dword [FxTabledA2+85h*4],FxOpd85A2 mov dword [FxTabledA2+86h*4],FxOpd86A2 mov dword [FxTabledA2+87h*4],FxOpd87A2 mov dword [FxTabledA2+88h*4],FxOpd88A2 mov dword [FxTabledA2+89h*4],FxOpd89A2 mov dword [FxTabledA2+8Ah*4],FxOpd8AA2 mov dword [FxTabledA2+8Bh*4],FxOpd8BA2 mov dword [FxTabledA2+8Ch*4],FxOpd8CA2 mov dword [FxTabledA2+8Dh*4],FxOpd8DA2 mov dword [FxTabledA2+8Eh*4],FxOpd8EA2 mov dword [FxTabledA2+8Fh*4],FxOpd8FA2 mov dword [FxTabledA2+90h*4],FxOpd90 mov dword [FxTabledA2+91h*4],FxOpd91 mov dword [FxTabledA2+92h*4],FxOpd92 mov dword [FxTabledA2+93h*4],FxOpd93 mov dword [FxTabledA2+94h*4],FxOpd94 mov dword [FxTabledA2+95h*4],FxOpd95 mov dword [FxTabledA2+96h*4],FxOpd96 mov dword [FxTabledA2+97h*4],FxOpd97 mov dword [FxTabledA2+98h*4],FxOpd98 mov dword [FxTabledA2+99h*4],FxOpd99 mov dword [FxTabledA2+9Ah*4],FxOpd9A mov dword [FxTabledA2+9Bh*4],FxOpd9B mov dword [FxTabledA2+9Ch*4],FxOpd9C mov dword [FxTabledA2+9Dh*4],FxOpd9D mov dword [FxTabledA2+9Eh*4],FxOpd9E mov dword [FxTabledA2+9Fh*4],FxOpd9F mov dword [FxTabledA2+0A0h*4],FxOpdA0A2 mov dword [FxTabledA2+0A1h*4],FxOpdA1A2 mov dword [FxTabledA2+0A2h*4],FxOpdA2A2 mov dword [FxTabledA2+0A3h*4],FxOpdA3A2 mov dword [FxTabledA2+0A4h*4],FxOpdA4A2 mov dword [FxTabledA2+0A5h*4],FxOpdA5A2 mov dword [FxTabledA2+0A6h*4],FxOpdA6A2 mov dword [FxTabledA2+0A7h*4],FxOpdA7A2 mov dword [FxTabledA2+0A8h*4],FxOpdA8A2 mov dword [FxTabledA2+0A9h*4],FxOpdA9A2 mov dword [FxTabledA2+0AAh*4],FxOpdAAA2 mov dword [FxTabledA2+0ABh*4],FxOpdABA2 mov dword [FxTabledA2+0ACh*4],FxOpdACA2 mov dword [FxTabledA2+0ADh*4],FxOpdADA2 mov dword [FxTabledA2+0AEh*4],FxOpdAEA2 mov dword [FxTabledA2+0AFh*4],FxOpdAFA2 mov dword [FxTabledA2+0B0h*4],FxOpdB0 mov dword [FxTabledA2+0B1h*4],FxOpdB1 mov dword [FxTabledA2+0B2h*4],FxOpdB2 mov dword [FxTabledA2+0B3h*4],FxOpdB3 mov dword [FxTabledA2+0B4h*4],FxOpdB4 mov dword [FxTabledA2+0B5h*4],FxOpdB5 mov dword [FxTabledA2+0B6h*4],FxOpdB6 mov dword [FxTabledA2+0B7h*4],FxOpdB7 mov dword [FxTabledA2+0B8h*4],FxOpdB8 mov dword [FxTabledA2+0B9h*4],FxOpdB9 mov dword [FxTabledA2+0BAh*4],FxOpdBA mov dword [FxTabledA2+0BBh*4],FxOpdBB mov dword [FxTabledA2+0BCh*4],FxOpdBC mov dword [FxTabledA2+0BDh*4],FxOpdBD mov dword [FxTabledA2+0BEh*4],FxOpdBE mov dword [FxTabledA2+0BFh*4],FxOpdBF mov dword [FxTabledA2+0C0h*4],FxOpdC0 mov dword [FxTabledA2+0C1h*4],FxOpdC1A2 mov dword [FxTabledA2+0C2h*4],FxOpdC2A2 mov dword [FxTabledA2+0C3h*4],FxOpdC3A2 mov dword [FxTabledA2+0C4h*4],FxOpdC4A2 mov dword [FxTabledA2+0C5h*4],FxOpdC5A2 mov dword [FxTabledA2+0C6h*4],FxOpdC6A2 mov dword [FxTabledA2+0C7h*4],FxOpdC7A2 mov dword [FxTabledA2+0C8h*4],FxOpdC8A2 mov dword [FxTabledA2+0C9h*4],FxOpdC9A2 mov dword [FxTabledA2+0CAh*4],FxOpdCAA2 mov dword [FxTabledA2+0CBh*4],FxOpdCBA2 mov dword [FxTabledA2+0CCh*4],FxOpdCCA2 mov dword [FxTabledA2+0CDh*4],FxOpdCDA2 mov dword [FxTabledA2+0CEh*4],FxOpdCEA2 mov dword [FxTabledA2+0CFh*4],FxOpdCFA2 mov dword [FxTabledA2+0D0h*4],FxOpdD0 mov dword [FxTabledA2+0D1h*4],FxOpdD1 mov dword [FxTabledA2+0D2h*4],FxOpdD2 mov dword [FxTabledA2+0D3h*4],FxOpdD3 mov dword [FxTabledA2+0D4h*4],FxOpdD4 mov dword [FxTabledA2+0D5h*4],FxOpdD5 mov dword [FxTabledA2+0D6h*4],FxOpdD6 mov dword [FxTabledA2+0D7h*4],FxOpdD7 mov dword [FxTabledA2+0D8h*4],FxOpdD8 mov dword [FxTabledA2+0D9h*4],FxOpdD9 mov dword [FxTabledA2+0DAh*4],FxOpdDA mov dword [FxTabledA2+0DBh*4],FxOpdDB mov dword [FxTabledA2+0DCh*4],FxOpdDC mov dword [FxTabledA2+0DDh*4],FxOpdDD mov dword [FxTabledA2+0DEh*4],FxOpdDE mov dword [FxTabledA2+0DFh*4],FxOpdDFA2 mov dword [FxTabledA2+0E0h*4],FxOpdE0 mov dword [FxTabledA2+0E1h*4],FxOpdE1 mov dword [FxTabledA2+0E2h*4],FxOpdE2 mov dword [FxTabledA2+0E3h*4],FxOpdE3 mov dword [FxTabledA2+0E4h*4],FxOpdE4 mov dword [FxTabledA2+0E5h*4],FxOpdE5 mov dword [FxTabledA2+0E6h*4],FxOpdE6 mov dword [FxTabledA2+0E7h*4],FxOpdE7 mov dword [FxTabledA2+0E8h*4],FxOpdE8 mov dword [FxTabledA2+0E9h*4],FxOpdE9 mov dword [FxTabledA2+0EAh*4],FxOpdEA mov dword [FxTabledA2+0EBh*4],FxOpdEB mov dword [FxTabledA2+0ECh*4],FxOpdEC mov dword [FxTabledA2+0EDh*4],FxOpdED mov dword [FxTabledA2+0EEh*4],FxOpdEE mov dword [FxTabledA2+0EFh*4],FxOpdEFA2 mov dword [FxTabledA2+0F0h*4],FxOpdF0A2 mov dword [FxTabledA2+0F1h*4],FxOpdF1A2 mov dword [FxTabledA2+0F2h*4],FxOpdF2A2 mov dword [FxTabledA2+0F3h*4],FxOpdF3A2 mov dword [FxTabledA2+0F4h*4],FxOpdF4A2 mov dword [FxTabledA2+0F5h*4],FxOpdF5A2 mov dword [FxTabledA2+0F6h*4],FxOpdF6A2 mov dword [FxTabledA2+0F7h*4],FxOpdF7A2 mov dword [FxTabledA2+0F8h*4],FxOpdF8A2 mov dword [FxTabledA2+0F9h*4],FxOpdF9A2 mov dword [FxTabledA2+0FAh*4],FxOpdFAA2 mov dword [FxTabledA2+0FBh*4],FxOpdFBA2 mov dword [FxTabledA2+0FCh*4],FxOpdFCA2 mov dword [FxTabledA2+0FDh*4],FxOpdFDA2 mov dword [FxTabledA2+0FEh*4],FxOpdFEA2 mov dword [FxTabledA2+0FFh*4],FxOpdFFA2 mov dword [FxTabledA3+00h*4],FxOpd00 mov dword [FxTabledA3+01h*4],FxOpd01 mov dword [FxTabledA3+02h*4],FxOpd02 mov dword [FxTabledA3+03h*4],FxOpd03 mov dword [FxTabledA3+04h*4],FxOpd04 mov dword [FxTabledA3+05h*4],FxOpd05 mov dword [FxTabledA3+06h*4],FxOpd06 mov dword [FxTabledA3+07h*4],FxOpd07 mov dword [FxTabledA3+08h*4],FxOpd08 mov dword [FxTabledA3+09h*4],FxOpd09 mov dword [FxTabledA3+0Ah*4],FxOpd0A mov dword [FxTabledA3+0Bh*4],FxOpd0B mov dword [FxTabledA3+0Ch*4],FxOpd0C mov dword [FxTabledA3+0Dh*4],FxOpd0D mov dword [FxTabledA3+0Eh*4],FxOpd0E mov dword [FxTabledA3+0Fh*4],FxOpd0F mov dword [FxTabledA3+10h*4],FxOpd10 mov dword [FxTabledA3+11h*4],FxOpd11 mov dword [FxTabledA3+12h*4],FxOpd12 mov dword [FxTabledA3+13h*4],FxOpd13 mov dword [FxTabledA3+14h*4],FxOpd14 mov dword [FxTabledA3+15h*4],FxOpd15 mov dword [FxTabledA3+16h*4],FxOpd16 mov dword [FxTabledA3+17h*4],FxOpd17 mov dword [FxTabledA3+18h*4],FxOpd18 mov dword [FxTabledA3+19h*4],FxOpd19 mov dword [FxTabledA3+1Ah*4],FxOpd1A mov dword [FxTabledA3+1Bh*4],FxOpd1B mov dword [FxTabledA3+1Ch*4],FxOpd1C mov dword [FxTabledA3+1Dh*4],FxOpd1D mov dword [FxTabledA3+1Eh*4],FxOpd1E mov dword [FxTabledA3+1Fh*4],FxOpd1F mov dword [FxTabledA3+20h*4],FxOpd20 mov dword [FxTabledA3+21h*4],FxOpd21 mov dword [FxTabledA3+22h*4],FxOpd22 mov dword [FxTabledA3+23h*4],FxOpd23 mov dword [FxTabledA3+24h*4],FxOpd24 mov dword [FxTabledA3+25h*4],FxOpd25 mov dword [FxTabledA3+26h*4],FxOpd26 mov dword [FxTabledA3+27h*4],FxOpd27 mov dword [FxTabledA3+28h*4],FxOpd28 mov dword [FxTabledA3+29h*4],FxOpd29 mov dword [FxTabledA3+2Ah*4],FxOpd2A mov dword [FxTabledA3+2Bh*4],FxOpd2B mov dword [FxTabledA3+2Ch*4],FxOpd2C mov dword [FxTabledA3+2Dh*4],FxOpd2D mov dword [FxTabledA3+2Eh*4],FxOpd2E mov dword [FxTabledA3+2Fh*4],FxOpd2F mov dword [FxTabledA3+30h*4],FxOpd30 mov dword [FxTabledA3+31h*4],FxOpd31 mov dword [FxTabledA3+32h*4],FxOpd32 mov dword [FxTabledA3+33h*4],FxOpd33 mov dword [FxTabledA3+34h*4],FxOpd34 mov dword [FxTabledA3+35h*4],FxOpd35 mov dword [FxTabledA3+36h*4],FxOpd36 mov dword [FxTabledA3+37h*4],FxOpd37 mov dword [FxTabledA3+38h*4],FxOpd38 mov dword [FxTabledA3+39h*4],FxOpd39 mov dword [FxTabledA3+3Ah*4],FxOpd3A mov dword [FxTabledA3+3Bh*4],FxOpd3B mov dword [FxTabledA3+3Ch*4],FxOpd3C mov dword [FxTabledA3+3Dh*4],FxOpd3D mov dword [FxTabledA3+3Eh*4],FxOpd3E mov dword [FxTabledA3+3Fh*4],FxOpd3F mov dword [FxTabledA3+40h*4],FxOpd40 mov dword [FxTabledA3+41h*4],FxOpd41 mov dword [FxTabledA3+42h*4],FxOpd42 mov dword [FxTabledA3+43h*4],FxOpd43 mov dword [FxTabledA3+44h*4],FxOpd44 mov dword [FxTabledA3+45h*4],FxOpd45 mov dword [FxTabledA3+46h*4],FxOpd46 mov dword [FxTabledA3+47h*4],FxOpd47 mov dword [FxTabledA3+48h*4],FxOpd48 mov dword [FxTabledA3+49h*4],FxOpd49 mov dword [FxTabledA3+4Ah*4],FxOpd4A mov dword [FxTabledA3+4Bh*4],FxOpd4B mov dword [FxTabledA3+4Ch*4],FxOpd4C mov dword [FxTabledA3+4Dh*4],FxOpd4D mov dword [FxTabledA3+4Eh*4],FxOpd4E mov dword [FxTabledA3+4Fh*4],FxOpd4F mov dword [FxTabledA3+50h*4],FxOpd50A3 mov dword [FxTabledA3+51h*4],FxOpd51A3 mov dword [FxTabledA3+52h*4],FxOpd52A3 mov dword [FxTabledA3+53h*4],FxOpd53A3 mov dword [FxTabledA3+54h*4],FxOpd54A3 mov dword [FxTabledA3+55h*4],FxOpd55A3 mov dword [FxTabledA3+56h*4],FxOpd56A3 mov dword [FxTabledA3+57h*4],FxOpd57A3 mov dword [FxTabledA3+58h*4],FxOpd58A3 mov dword [FxTabledA3+59h*4],FxOpd59A3 mov dword [FxTabledA3+5Ah*4],FxOpd5AA3 mov dword [FxTabledA3+5Bh*4],FxOpd5BA3 mov dword [FxTabledA3+5Ch*4],FxOpd5CA3 mov dword [FxTabledA3+5Dh*4],FxOpd5DA3 mov dword [FxTabledA3+5Eh*4],FxOpd5EA3 mov dword [FxTabledA3+5Fh*4],FxOpd5FA3 mov dword [FxTabledA3+60h*4],FxOpd60A3 mov dword [FxTabledA3+61h*4],FxOpd61A3 mov dword [FxTabledA3+62h*4],FxOpd62A3 mov dword [FxTabledA3+63h*4],FxOpd63A3 mov dword [FxTabledA3+64h*4],FxOpd64A3 mov dword [FxTabledA3+65h*4],FxOpd65A3 mov dword [FxTabledA3+66h*4],FxOpd66A3 mov dword [FxTabledA3+67h*4],FxOpd67A3 mov dword [FxTabledA3+68h*4],FxOpd68A3 mov dword [FxTabledA3+69h*4],FxOpd69A3 mov dword [FxTabledA3+6Ah*4],FxOpd6AA3 mov dword [FxTabledA3+6Bh*4],FxOpd6BA3 mov dword [FxTabledA3+6Ch*4],FxOpd6CA3 mov dword [FxTabledA3+6Dh*4],FxOpd6DA3 mov dword [FxTabledA3+6Eh*4],FxOpd6EA3 mov dword [FxTabledA3+6Fh*4],FxOpd6FA3 mov dword [FxTabledA3+70h*4],FxOpd70 mov dword [FxTabledA3+71h*4],FxOpd71A3 mov dword [FxTabledA3+72h*4],FxOpd72A3 mov dword [FxTabledA3+73h*4],FxOpd73A3 mov dword [FxTabledA3+74h*4],FxOpd74A3 mov dword [FxTabledA3+75h*4],FxOpd75A3 mov dword [FxTabledA3+76h*4],FxOpd76A3 mov dword [FxTabledA3+77h*4],FxOpd77A3 mov dword [FxTabledA3+78h*4],FxOpd78A3 mov dword [FxTabledA3+79h*4],FxOpd79A3 mov dword [FxTabledA3+7Ah*4],FxOpd7AA3 mov dword [FxTabledA3+7Bh*4],FxOpd7BA3 mov dword [FxTabledA3+7Ch*4],FxOpd7CA3 mov dword [FxTabledA3+7Dh*4],FxOpd7DA3 mov dword [FxTabledA3+7Eh*4],FxOpd7EA3 mov dword [FxTabledA3+7Fh*4],FxOpd7FA3 mov dword [FxTabledA3+80h*4],FxOpd80A3 mov dword [FxTabledA3+81h*4],FxOpd81A3 mov dword [FxTabledA3+82h*4],FxOpd82A3 mov dword [FxTabledA3+83h*4],FxOpd83A3 mov dword [FxTabledA3+84h*4],FxOpd84A3 mov dword [FxTabledA3+85h*4],FxOpd85A3 mov dword [FxTabledA3+86h*4],FxOpd86A3 mov dword [FxTabledA3+87h*4],FxOpd87A3 mov dword [FxTabledA3+88h*4],FxOpd88A3 mov dword [FxTabledA3+89h*4],FxOpd89A3 mov dword [FxTabledA3+8Ah*4],FxOpd8AA3 mov dword [FxTabledA3+8Bh*4],FxOpd8BA3 mov dword [FxTabledA3+8Ch*4],FxOpd8CA3 mov dword [FxTabledA3+8Dh*4],FxOpd8DA3 mov dword [FxTabledA3+8Eh*4],FxOpd8EA3 mov dword [FxTabledA3+8Fh*4],FxOpd8FA3 mov dword [FxTabledA3+90h*4],FxOpd90 mov dword [FxTabledA3+91h*4],FxOpd91 mov dword [FxTabledA3+92h*4],FxOpd92 mov dword [FxTabledA3+93h*4],FxOpd93 mov dword [FxTabledA3+94h*4],FxOpd94 mov dword [FxTabledA3+95h*4],FxOpd95 mov dword [FxTabledA3+96h*4],FxOpd96 mov dword [FxTabledA3+97h*4],FxOpd97 mov dword [FxTabledA3+98h*4],FxOpd98 mov dword [FxTabledA3+99h*4],FxOpd99 mov dword [FxTabledA3+9Ah*4],FxOpd9A mov dword [FxTabledA3+9Bh*4],FxOpd9B mov dword [FxTabledA3+9Ch*4],FxOpd9C mov dword [FxTabledA3+9Dh*4],FxOpd9D mov dword [FxTabledA3+9Eh*4],FxOpd9E mov dword [FxTabledA3+9Fh*4],FxOpd9F mov dword [FxTabledA3+0A0h*4],FxOpdA0 mov dword [FxTabledA3+0A1h*4],FxOpdA1 mov dword [FxTabledA3+0A2h*4],FxOpdA2 mov dword [FxTabledA3+0A3h*4],FxOpdA3 mov dword [FxTabledA3+0A4h*4],FxOpdA4 mov dword [FxTabledA3+0A5h*4],FxOpdA5 mov dword [FxTabledA3+0A6h*4],FxOpdA6 mov dword [FxTabledA3+0A7h*4],FxOpdA7 mov dword [FxTabledA3+0A8h*4],FxOpdA8 mov dword [FxTabledA3+0A9h*4],FxOpdA9 mov dword [FxTabledA3+0AAh*4],FxOpdAA mov dword [FxTabledA3+0ABh*4],FxOpdAB mov dword [FxTabledA3+0ACh*4],FxOpdAC mov dword [FxTabledA3+0ADh*4],FxOpdAD mov dword [FxTabledA3+0AEh*4],FxOpdAE mov dword [FxTabledA3+0AFh*4],FxOpdAF mov dword [FxTabledA3+0B0h*4],FxOpdB0 mov dword [FxTabledA3+0B1h*4],FxOpdB1 mov dword [FxTabledA3+0B2h*4],FxOpdB2 mov dword [FxTabledA3+0B3h*4],FxOpdB3 mov dword [FxTabledA3+0B4h*4],FxOpdB4 mov dword [FxTabledA3+0B5h*4],FxOpdB5 mov dword [FxTabledA3+0B6h*4],FxOpdB6 mov dword [FxTabledA3+0B7h*4],FxOpdB7 mov dword [FxTabledA3+0B8h*4],FxOpdB8 mov dword [FxTabledA3+0B9h*4],FxOpdB9 mov dword [FxTabledA3+0BAh*4],FxOpdBA mov dword [FxTabledA3+0BBh*4],FxOpdBB mov dword [FxTabledA3+0BCh*4],FxOpdBC mov dword [FxTabledA3+0BDh*4],FxOpdBD mov dword [FxTabledA3+0BEh*4],FxOpdBE mov dword [FxTabledA3+0BFh*4],FxOpdBF mov dword [FxTabledA3+0C0h*4],FxOpdC0 mov dword [FxTabledA3+0C1h*4],FxOpdC1A3 mov dword [FxTabledA3+0C2h*4],FxOpdC2A3 mov dword [FxTabledA3+0C3h*4],FxOpdC3A3 mov dword [FxTabledA3+0C4h*4],FxOpdC4A3 mov dword [FxTabledA3+0C5h*4],FxOpdC5A3 mov dword [FxTabledA3+0C6h*4],FxOpdC6A3 mov dword [FxTabledA3+0C7h*4],FxOpdC7A3 mov dword [FxTabledA3+0C8h*4],FxOpdC8A3 mov dword [FxTabledA3+0C9h*4],FxOpdC9A3 mov dword [FxTabledA3+0CAh*4],FxOpdCAA3 mov dword [FxTabledA3+0CBh*4],FxOpdCBA3 mov dword [FxTabledA3+0CCh*4],FxOpdCCA3 mov dword [FxTabledA3+0CDh*4],FxOpdCDA3 mov dword [FxTabledA3+0CEh*4],FxOpdCEA3 mov dword [FxTabledA3+0CFh*4],FxOpdCFA3 mov dword [FxTabledA3+0D0h*4],FxOpdD0 mov dword [FxTabledA3+0D1h*4],FxOpdD1 mov dword [FxTabledA3+0D2h*4],FxOpdD2 mov dword [FxTabledA3+0D3h*4],FxOpdD3 mov dword [FxTabledA3+0D4h*4],FxOpdD4 mov dword [FxTabledA3+0D5h*4],FxOpdD5 mov dword [FxTabledA3+0D6h*4],FxOpdD6 mov dword [FxTabledA3+0D7h*4],FxOpdD7 mov dword [FxTabledA3+0D8h*4],FxOpdD8 mov dword [FxTabledA3+0D9h*4],FxOpdD9 mov dword [FxTabledA3+0DAh*4],FxOpdDA mov dword [FxTabledA3+0DBh*4],FxOpdDB mov dword [FxTabledA3+0DCh*4],FxOpdDC mov dword [FxTabledA3+0DDh*4],FxOpdDD mov dword [FxTabledA3+0DEh*4],FxOpdDE mov dword [FxTabledA3+0DFh*4],FxOpdDFA3 mov dword [FxTabledA3+0E0h*4],FxOpdE0 mov dword [FxTabledA3+0E1h*4],FxOpdE1 mov dword [FxTabledA3+0E2h*4],FxOpdE2 mov dword [FxTabledA3+0E3h*4],FxOpdE3 mov dword [FxTabledA3+0E4h*4],FxOpdE4 mov dword [FxTabledA3+0E5h*4],FxOpdE5 mov dword [FxTabledA3+0E6h*4],FxOpdE6 mov dword [FxTabledA3+0E7h*4],FxOpdE7 mov dword [FxTabledA3+0E8h*4],FxOpdE8 mov dword [FxTabledA3+0E9h*4],FxOpdE9 mov dword [FxTabledA3+0EAh*4],FxOpdEA mov dword [FxTabledA3+0EBh*4],FxOpdEB mov dword [FxTabledA3+0ECh*4],FxOpdEC mov dword [FxTabledA3+0EDh*4],FxOpdED mov dword [FxTabledA3+0EEh*4],FxOpdEE mov dword [FxTabledA3+0EFh*4],FxOpdEFA3 mov dword [FxTabledA3+0F0h*4],FxOpdF0 mov dword [FxTabledA3+0F1h*4],FxOpdF1 mov dword [FxTabledA3+0F2h*4],FxOpdF2 mov dword [FxTabledA3+0F3h*4],FxOpdF3 mov dword [FxTabledA3+0F4h*4],FxOpdF4 mov dword [FxTabledA3+0F5h*4],FxOpdF5 mov dword [FxTabledA3+0F6h*4],FxOpdF6 mov dword [FxTabledA3+0F7h*4],FxOpdF7 mov dword [FxTabledA3+0F8h*4],FxOpdF8 mov dword [FxTabledA3+0F9h*4],FxOpdF9 mov dword [FxTabledA3+0FAh*4],FxOpdFA mov dword [FxTabledA3+0FBh*4],FxOpdFB mov dword [FxTabledA3+0FCh*4],FxOpdFC mov dword [FxTabledA3+0FDh*4],FxOpdFD mov dword [FxTabledA3+0FEh*4],FxOpdFE mov dword [FxTabledA3+0FFh*4],FxOpdFF ret ; normal NEWSYM sfxnametab db 'STOP NOP CACHE LSR ' db 'ROL BRA BLT BGE ' db 'BNE BEQ BPL BMI ' db 'BCC BCS BVC BVS ' db 'TO R0 TO R1 TO R2 TO R3 ' ; MOVE when B=1 db 'TO R4 TO R5 TO R6 TO R7 ' db 'TO R8 TO R9 TO R10 TO R11 ' db 'TO R12 TO R13 TO R14 TO R15 ' db 'WITH R0 WITH R1 WITH R2 WITH R3 ' db 'WITH R4 WITH R5 WITH R6 WITH R7 ' db 'WITH R8 WITH R9 WITH R10WITH R11' db 'WITH R12WITH R13WITH R14WITH R15' db 'STW(R0) STW(R1) STW(R2) STW(R3) ' db 'STW(R4) STW(R5) STW(R6) STW(R7) ' db 'STW(R8) STW(R9) STW(R10)STW(R11)' db 'LOOP ALT1 ALT2 ALT3 ' db 'LDW(R0) LDW(R1) LDW(R2) LDW(R3) ' db 'LDW(R4) LDW(R5) LDW(R6) LDW(R7) ' db 'LDW(R8) LDW(R9) LDW(R10)LDW(R11)' db 'PLOT SWAP COLOR NOT ' db 'ADD R0 ADD R1 ADD R2 ADD R3 ' db 'ADD R4 ADD R5 ADD R6 ADD R7 ' db 'ADD R8 ADD R9 ADD R10 ADD R11 ' db 'ADD R12 ADD R13 ADD R14 ADD R15 ' db 'SUB R0 SUB R1 SUB R2 SUB R3 ' db 'SUB R4 SUB R5 SUB R6 SUB R7 ' db 'SUB R8 SUB R9 SUB R10 SUB R11 ' db 'SUB R12 SUB R13 SUB R14 SUB R15 ' db 'MERGE AND R1 AND R2 AND R3 ' db 'AND R4 AND R5 AND R6 AND R7 ' db 'AND R8 AND R9 AND R10 AND R11 ' db 'AND R12 AND R13 AND R14 AND R15 ' db 'MULT R0 MULT R1 MULT R2 MULT R3 ' db 'MULT R4 MULT R5 MULT R6 MULT R7 ' db 'MULT R8 MULT R9 MULT R10MULT R11' db 'MULT R12MULT R13MULT R14MULT R15' db 'SBK LINK #$1LINK #$2LINK #$3' db 'LINK #$4SEX ASR ROR ' db 'JMP R8 JMP R9 JMP R10 JMP R11 ' db 'JMP R12 JMP R13 LOB FMULT ' db 'IBT R0 IBT R1 IBT R2 IBT R3 ' db 'IBT R4 IBT R5 IBT R6 IBT R7 ' db 'IBT R8 IBT R9 IBT R10 IBT R11 ' db 'IBT R12 IBT R13 IBT R14 IBT R15 ' db 'FROM R0 FROM R1 FROM R2 FROM R3 ' ; MOVES if B=1 db 'FROM R4 FROM R5 FROM R6 FROM R7 ' db 'FROM R8 FROM R9 FROM R10FROM R11' db 'FROM R12FROM R13FROM R14FROM R15' db 'HIB OR R1 OR R2 OR R3 ' db 'OR R4 OR R5 OR R6 OR R7 ' db 'OR R8 OR R9 OR R10 OR R11 ' db 'OR R12 OR R13 OR R14 OR R15 ' db 'INC R0 INC R1 INC R2 INC R3 ' db 'INC R4 INC R5 INC R6 INC R7 ' db 'INC R8 INC R9 INC R10 INC R11 ' db 'INC R12 INC R13 INC R14 GETC ' db 'DEC R0 DEC R1 DEC R2 DEC R3 ' db 'DEC R4 DEC R5 DEC R6 DEC R7 ' db 'DEC R8 DEC R9 DEC R10 DEC R11 ' db 'DEC R12 DEC R13 DEC R14 GETB ' db 'IWT R0 IWT R1 IWT R2 IWT R3 ' db 'IWT R4 IWT R5 IWT R6 IWT R7 ' db 'IWT R8 IWT R9 IWT R10 IWT R11 ' db 'IWT R12 IWT R13 IWT R14 IWT R15 ' ;A1 db 'STOP NOP CACHE LSR ' db 'ROL BRA BLT BGE ' db 'BNE BEQ BPL BMI ' db 'BCC BCS BVC BVS ' db 'TO R0 TO R1 TO R2 TO R3 ' ; MOVE when B=1 db 'TO R4 TO R5 TO R6 TO R7 ' db 'TO R8 TO R9 TO R10 TO R11 ' db 'TO R12 TO R13 TO R14 TO R15 ' db 'WITH R0 WITH R1 WITH R2 WITH R3 ' db 'WITH R4 WITH R5 WITH R6 WITH R7 ' db 'WITH R8 WITH R9 WITH R10WITH R11' db 'WITH R12WITH R13WITH R14WITH R15' db 'STB(R0) STB(R1) STB(R2) STB(R3) ' db 'STB(R4) STB(R5) STB(R6) STB(R7) ' db 'STB(R8) STB(R9) STB(R10)STB(R11)' db 'LOOP ALT1 ALT2 ALT3 ' db 'LDB(R0) LDB(R1) LDB(R2) LDB(R3) ' db 'LDB(R4) LDB(R5) LDB(R6) LDB(R7) ' db 'LDB(R8) LDB(R9) LDB(R10)LDB(R11)' db 'PLOT SWAP CMODE NOT ' db 'ADC R0 ADC R1 ADC R2 ADC R3 ' db 'ADC R4 ADC R5 ADC R6 ADC R7 ' db 'ADC R8 ADC R9 ADC R10 ADC R11 ' db 'ADC R12 ADC R13 ADC R14 ADC R15 ' db 'SBC R0 SBC R1 SBC R2 SBC R3 ' db 'SBC R4 SBC R5 SBC R6 SBC R7 ' db 'SBC R8 SBC R9 SBC R10 SBC R11 ' db 'SBC R12 SBC R13 SBC R14 SBC R15 ' db 'MERGE BIC R1 BIC R2 BIC R3 ' db 'BIC R4 BIC R5 BIC R6 BIC R7 ' db 'BIC R8 BIC R9 BIC R10 BIC R11 ' db 'BIC R12 BIC R13 BIC R14 BIC R15 ' db 'UMULTR0 UMULTR1 UMULTR2 UMULTR3 ' db 'UMULTR4 UMULTR5 UMULTR6 UMULTR7 ' db 'UMULTR8 UMULTR9 UMULTR10UMULTR11' db 'UMULTR12UMULTR13UMULTR14UMULTR15' db 'SBK LINK #$1LINK #$2LINK #$3' db 'LINK #$4SEX DIV2 ROR ' db 'LJMP R8 LJMP R9 LJMP R10LJMP R11' db 'LJMP R12LJMP R13LOB LMULT ' db 'LMS R0 LMS R1 LMS R2 LMS R3 ' db 'LMS R4 LMS R5 LMS R6 LMS R7 ' db 'LMS R8 LMS R9 LMS R10 LMS R11 ' db 'LMS R12 LMS R13 LMS R14 LMS R15 ' db 'FROM R0 FROM R1 FROM R2 FROM R3 ' ; MOVES if B=1 db 'FROM R4 FROM R5 FROM R6 FROM R7 ' db 'FROM R8 FROM R9 FROM R10FROM R11' db 'FROM R12FROM R13FROM R14FROM R15' db 'HIB XOR R1 XOR R2 XOR R3 ' db 'XOR R4 XOR R5 XOR R6 XOR R7 ' db 'XOR R8 XOR R9 XOR R10 XOR R11 ' db 'XOR R12 XOR R13 XOR R14 XOR R15 ' db 'INC R0 INC R1 INC R2 INC R3 ' db 'INC R4 INC R5 INC R6 INC R7 ' db 'INC R8 INC R9 INC R10 INC R11 ' db 'INC R12 INC R13 INC R14 GETC ' db 'DEC R0 DEC R1 DEC R2 DEC R3 ' db 'DEC R4 DEC R5 DEC R6 DEC R7 ' db 'DEC R8 DEC R9 DEC R10 DEC R11 ' db 'DEC R12 DEC R13 DEC R14 GETBH ' db 'LM R0 LM R1 LM R2 LM R3 ' db 'LM R4 LM R5 LM R6 LM R7 ' db 'LM R8 LM R9 LM R10 LM R11 ' db 'LM R12 LM R13 LM R14 LM R15 ' ;A2 db 'STOP NOP CACHE LSR ' db 'ROL BRA BLT BGE ' db 'BNE BEQ BPL BMI ' db 'BCC BCS BVC BVS ' db 'TO R0 TO R1 TO R2 TO R3 ' ; MOVE when B=1 db 'TO R4 TO R5 TO R6 TO R7 ' db 'TO R8 TO R9 TO R10 TO R11 ' db 'TO R12 TO R13 TO R14 TO R15 ' db 'WITH R0 WITH R1 WITH R2 WITH R3 ' db 'WITH R4 WITH R5 WITH R6 WITH R7 ' db 'WITH R8 WITH R9 WITH R10WITH R11' db 'WITH R12WITH R13WITH R14WITH R15' db 'STW(R0) STW(R1) STW(R2) STW(R3) ' db 'STW(R4) STW(R5) STW(R6) STW(R7) ' db 'STW(R8) STW(R9) STW(R10)STW(R11)' db 'LOOP ALT1 ALT2 ALT3 ' db 'LDW(R0) LDW(R1) LDW(R2) LDW(R3) ' db 'LDW(R4) LDW(R5) LDW(R6) LDW(R7) ' db 'LDW(R8) LDW(R9) LDW(R10)LDW(R11)' db 'PLOT SWAP COLOR NOT ' db 'ADD #$0 ADD #$1 ADD #$2 ADD #$3 ' db 'ADD #$4 ADD #$5 ADD #$6 ADD #$7 ' db 'ADD #$8 ADD #$9 ADD #$A ADD #$B ' db 'ADD #$C ADD #$D ADD #$E ADD #$F ' db 'SUB #$0 SUB #$1 SUB #$2 SUB #$3 ' db 'SUB #$4 SUB #$5 SUB #$6 SUB #$7 ' db 'SUB #$8 SUB #$9 SUB #$A SUB #$B ' db 'SUB #$C SUB #$D SUB #$E SUB #$F ' db 'MERGE AND #$1 AND #$2 AND #$3 ' db 'AND #$4 AND #$5 AND #$6 AND #$7 ' db 'AND #$8 AND #$9 AND #$A AND #$B ' db 'AND #$C AND #$D AND #$E AND #$F ' db 'MULTIR0 MULTIR1 MULTIR2 MULTIR3 ' db 'MULTIR4 MULTIR5 MULTIR6 MULTIR7 ' db 'MULTIR8 MULTIR9 MULTIR10MULTIR11' db 'MULTIR12MULTIR13MULTIR14MULTIR15' db 'SBK LINK #$1LINK #$2LINK #$3' db 'LINK #$4SEX ASR ROR ' db 'JMP R8 JMP R9 JMP R10 JMP R11 ' db 'JMP R12 JMP R13 LOB FMULT ' db 'SMS R0 SMS R1 SMS R2 SMS R3 ' db 'SMS R4 SMS R5 SMS R6 SMS R7 ' db 'SMS R8 SMS R9 SMS R10 SMS R11 ' db 'SMS R12 SMS R13 SMS R14 SMS R15 ' db 'FROM R0 FROM R1 FROM R2 FROM R3 ' ; MOVES if B=1 db 'FROM R4 FROM R5 FROM R6 FROM R7 ' db 'FROM R8 FROM R9 FROM R10FROM R11' db 'FROM R12FROM R13FROM R14FROM R15' db 'HIB OR #$1 OR #$2 OR #$3 ' db 'OR #$4 OR #$5 OR #$6 OR #$7 ' db 'OR #$8 OR #$9 OR #$A OR #$B ' db 'OR #$C OR #$D OR #$E OR #$F ' db 'INC R0 INC R1 INC R2 INC R3 ' db 'INC R4 INC R5 INC R6 INC R7 ' db 'INC R8 INC R9 INC R10 INC R11 ' db 'INC R12 INC R13 INC R14 RAMB ' db 'DEC R0 DEC R1 DEC R2 DEC R3 ' db 'DEC R4 DEC R5 DEC R6 DEC R7 ' db 'DEC R8 DEC R9 DEC R10 DEC R11 ' db 'DEC R12 DEC R13 DEC R14 GETBL ' db 'SM R0 SM R1 SM R2 SM R3 ' db 'SM R4 SM R5 SM R6 SM R7 ' db 'SM R8 SM R9 SM R10 SM R11 ' db 'SM R12 SM R13 SM R14 SM R15 ' ;A3 db 'STOP NOP CACHE LSR ' db 'ROL BRA BLT BGE ' db 'BNE BEQ BPL BMI ' db 'BCC BCS BVC BVS ' db 'TO R0 TO R1 TO R2 TO R3 ' ; MOVE when B=1 db 'TO R4 TO R5 TO R6 TO R7 ' db 'TO R8 TO R9 TO R10 TO R11 ' db 'TO R12 TO R13 TO R14 TO R15 ' db 'WITH R0 WITH R1 WITH R2 WITH R3 ' db 'WITH R4 WITH R5 WITH R6 WITH R7 ' db 'WITH R8 WITH R9 WITH R10WITH R11' db 'WITH R12WITH R13WITH R14WITH R15' db 'STW(R0) STW(R1) STW(R2) STW(R3) ' db 'STW(R4) STW(R5) STW(R6) STW(R7) ' db 'STW(R8) STW(R9) STW(R10)STW(R11)' db 'LOOP ALT1 ALT2 ALT3 ' db 'LDW(R0) LDW(R1) LDW(R2) LDW(R3) ' db 'LDW(R4) LDW(R5) LDW(R6) LDW(R7) ' db 'LDW(R8) LDW(R9) LDW(R10)LDW(R11)' db 'PLOT SWAP COLOR NOT ' db 'ADC #$0 ADC #$1 ADC #$2 ADC #$3 ' db 'ADC #$4 ADC #$5 ADC #$6 ADC #$7 ' db 'ADC #$8 ADC #$9 ADC #$A ADC #$B ' db 'ADC #$C ADC #$D ADC #$E ADC #$F ' db 'CMP R0 CMP R1 CMP R2 CMP R3 ' db 'CMP R4 CMP R5 CMP R6 CMP R7 ' db 'CMP R8 CMP R9 CMP R10 CMP R11 ' db 'CMP R12 CMP R13 CMP R14 CMP R15 ' db 'MERGE BIC #$1 BIC #$2 BIC #$3 ' db 'BIC #$4 BIC #$5 BIC #$6 BIC #$7 ' db 'BIC #$8 BIC #$9 BIC #$A BIC #$B ' db 'BIC #$C BIC #$D BIC #$E BIC #$F ' db 'UMULIR0 UMULIR1 UMULIR2 UMULIR3 ' db 'UMULIR4 UMULIR5 UMULIR6 UMULIR7 ' db 'UMULIR8 UMULIR9 UMULIR10UMULIR11' db 'UMULIR12UMULIR13UMULIR14UMULIR15' db 'SBK LINK #$1LINK #$2LINK #$3' db 'LINK #$4SEX ASR ROR ' db 'JMP R8 JMP R9 JMP R10 JMP R11 ' db 'JMP R12 JMP R13 LOB FMULT ' db 'IBT R0 IBT R1 IBT R2 IBT R3 ' db 'IBT R4 IBT R5 IBT R6 IBT R7 ' db 'IBT R8 IBT R9 IBT R10 IBT R11 ' db 'IBT R12 IBT R13 IBT R14 IBT R15 ' db 'FROM R0 FROM R1 FROM R2 FROM R3 ' ; MOVES if B=1 db 'FROM R4 FROM R5 FROM R6 FROM R7 ' db 'FROM R8 FROM R9 FROM R10FROM R11' db 'FROM R12FROM R13FROM R14FROM R15' db 'HIB XOR #$1 XOR #$2 XOR #$3 ' db 'XOR #$4 XOR #$5 XOR #$6 XOR #$7 ' db 'XOR #$8 XOR #$9 XOR #$A XOR #$B ' db 'XOR #$C XOR #$D XOR #$E XOR #$F ' db 'INC R0 INC R1 INC R2 INC R3 ' db 'INC R4 INC R5 INC R6 INC R7 ' db 'INC R8 INC R9 INC R10 INC R11 ' db 'INC R12 INC R13 INC R14 ROMB ' db 'DEC R0 DEC R1 DEC R2 DEC R3 ' db 'DEC R4 DEC R5 DEC R6 DEC R7 ' db 'DEC R8 DEC R9 DEC R10 DEC R11 ' db 'DEC R12 DEC R13 DEC R14 GETBS ' db 'IWT R0 IWT R1 IWT R2 IWT R3 ' db 'IWT R4 IWT R5 IWT R6 IWT R7 ' db 'IWT R8 IWT R9 IWT R10 IWT R11 ' db 'IWT R12 IWT R13 IWT R14 IWT R15 ' NEWSYM FxTableAsmEnd zsnes-1.36/src/chips/sa1proc.asm0100644000175000017500000001647007267141100016141 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM xa,xx,xy,xd,xdb,xpb,xs,xe,initaddrl,UpdateDPage,wramdata,IRAM,cycpbl,SA1DoIRQ EXTSYM spcnumread,SA1IRQEn,nextopcodesa1,debugds EXTSYM SNSRegP,SNSRegE,SNSRegPCS,SA1Ptr,SNSPtr,nmiv,irqv,nmiv2,irqv2,snesmap2,SA1tablead EXTSYM SA1xpb,SA1RegP,wramdataa,SA1TimerVal,debuggeron EXTSYM SA1RegE,SA1RegPCS,SA1BWPtr,SNSBWPtr,CurBWPtr,SA1NMIV,SA1IRQV,debstop,tablead EXTSYM membank0w8,romdata,SA1LBound,SA1UBound,SA1SH,SA1SHb EXTSYM stackor,stackand,snesmmap,SA1xs,SA1IRQExec EXTSYM SA1Message,Sflagnz,Sflagc,Sflago NEWSYM Sa1ProcAsmStart ; In exec loop, jump to execloop if SA1Status != 0 ; *** Disable spc700 if possible *** NEWSYM SA1Status, db 0 ; 0 = 65816, 1 = SA1A, 2 = SA1B NEWSYM CurrentExecSA1, db 0 NEWSYM CurrentCPU, db 0 ALIGN32 NEWSYM prevedi, dd 0 %macro SA1Debugb 0 pushad sub esi,[initaddrl] mov [SA1xpc],esi call nextopcodesa1 popad mov bl,[esi] xor dh,dh inc esi call dword near [edi+ebx*4] dec esi %endmacro %macro SA1Debug 0 ; debug version test byte[debugds],01h jz near .nodebug cmp byte[debuggeron],0 je near .nodebug SA1Debugb SA1Debugb SA1Debugb SA1Debugb SA1Debugb SA1Debugb SA1Debugb SA1Debugb jmp .debug .nodebug %endmacro NEWSYM SA1Swap mov ecx,[SA1BWPtr] mov eax,[SA1Ptr] ; small speed hack test byte[SA1DoIRQ],1 jnz near .sa1exec3 cmp byte[IRAM],0 jne .sa1exec2 cmp dword[eax],0FCF000A5h je near .nosa1exec cmp dword[eax-2],0FCF000A5h je near .nosa1exec .sa1exec2 cmp byte[SA1SHb],1 je near .nosa1execb cmp word[ecx+72A4h],0 jnz .sa1exec cmp dword[eax],0F072A4ADh je near .nosa1execb .sa1exec cmp byte[IRAM+72h],0 jne .sa1exec3 cmp dword[eax],0F03072ADh je near .nosa1execb .sa1exec3 .yesdebugr xor ecx,ecx ; store all snes 65816 stuff mov [SNSRegP],dl mov eax,[initaddrl] mov [prevedi],edi mov [SNSRegPCS],eax mov [SNSPtr],esi ; restore all sa1 65816 stuff mov dl,[SA1RegP] mov eax,[SA1RegPCS] mov [initaddrl],eax mov eax,[SA1BWPtr] mov [CurBWPtr],eax mov esi,[SA1Ptr] mov dword[snesmap2],IRAM mov dword[wramdata],IRAM ; Check if IRQ is executed on SA-1 xor eax,eax mov al,dl add dh,25 mov edi,[SA1tablead+eax*4] mov byte[SA1Status],1 test dword[SA1DoIRQ],0FF000003h jnz near .switchirq .returnirq ; SA1Debug cmp byte[SA1SH],1 je near .speedhack ; non debug version mov bl,[esi] inc esi call dword near [edi+ebx*4] dec esi .debug ; store all sa1 65816 stuff mov [SA1RegP],dl mov eax,[initaddrl] mov [SA1RegPCS],eax mov [SA1Ptr],esi ; restore all snes 65816 stuff mov dl,[SNSRegP] mov eax,[SNSRegPCS] mov [initaddrl],eax mov eax,[SNSBWPtr] mov [CurBWPtr],eax mov dword[wramdata],wramdataa mov esi,[SNSPtr] mov eax,[wramdata] mov dword[snesmap2],eax mov edi,[prevedi] xor eax,eax add dh,11 inc byte[CurrentExecSA1] mov byte[SA1Status],0 add dword[SA1TimerVal],23 ret .speedhack add dh,100 mov bl,[esi] inc esi call dword near [edi+ebx*4] dec esi ; store all sa1 65816 stuff mov [SA1RegP],dl mov eax,[initaddrl] mov [SA1RegPCS],eax mov [SA1Ptr],esi ; restore all snes 65816 stuff mov dl,[SNSRegP] mov eax,[SNSRegPCS] mov [initaddrl],eax mov eax,[SNSBWPtr] mov [CurBWPtr],eax mov dword[wramdata],wramdataa mov esi,[SNSPtr] mov eax,[wramdata] mov dword[snesmap2],eax mov edi,[prevedi] xor eax,eax add byte[CurrentExecSA1],4 mov byte[SA1Status],0 add dword[SA1TimerVal],23 ; xor dh,dh mov dh,18 cmp esi,dword[SA1LBound] jb .stoph cmp esi,dword[SA1UBound] ja .stoph ret .stoph mov byte[SA1SH],0 ret .nosa1execb xor ecx,ecx add dh,15 add byte[CurrentExecSA1],2 mov byte[SA1Status],0 ret .nosa1exec xor ecx,ecx add dh,22 add byte[CurrentExecSA1],2 mov byte[SA1Status],0 ret .switchirq test dword[SA1DoIRQ],3 jz .notirq test dword[SA1DoIRQ],1 jz .nmi and byte[SA1DoIRQ],0FEh call SA1switchtovirq jmp .returnirq .nmi and byte[SA1DoIRQ],0FDh call SA1switchtonmi jmp .returnirq .notirq dec byte[SA1DoIRQ+3] jz .hack jmp .returnirq .hack or byte[SA1DoIRQ],8 jmp .returnirq NEWSYM SA1xpc, dd 0 %macro makedl 0 and dl,00111100b test dword[Sflagnz],18000h jz %%noneg or dl,80h %%noneg test dword[Sflagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[Sflagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[Sflago],0FFh jz %%nov or dl,40h %%nov %endmacro NEWSYM SA1switchtonmi mov al,byte[SA1Message] mov byte[SA1Message+2],al mov byte[SA1IRQExec+2],1 mov ebx,esi sub ebx,[initaddrl] mov [SA1xpc],bx xor ecx,ecx mov cx,[SA1xs] mov al,[SA1xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[SA1xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[SA1xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [SA1xs],cx xor ebx,ebx mov [SA1xpb],bl xor eax,eax mov ax,[SA1NMIV] and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax ret .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax ret NEWSYM SA1switchtovirq mov al,byte[SA1Message] mov byte[SA1Message+2],al mov byte[SA1IRQExec+1],1 mov ebx,esi sub ebx,[initaddrl] mov [SA1xpc],bx xor ecx,ecx mov cx,[SA1xs] mov al,[SA1xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[SA1xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[SA1xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [SA1xs],cx xor ebx,ebx mov [SA1xpb],bl xor eax,eax mov ax,[SA1IRQV] and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax ret .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax ret NEWSYM Sa1ProcAsmEnd zsnes-1.36/src/chips/sa1regs.asm0100644000175000017500000015213607432621304016141 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; SPC7110 emulation. Information fully reverse engineered ; by Dark Force and John Weidman, ZSNES code by zsKnight ; SA-1 emulation. Information provided by Ivar of Snes9x. ; coded by zsKnight ; SDD-1 emulation. SDD-1 MMC reverse engineered by zsKnight, ; SDD-1 decompress Dark Force and John Weidman, ; - Add MMC support ; - Add end of DMA IRQ support ; - Add Char Conversion #1 ; - Add Char Conversion #2 ; - Add Memory Disables (Guess this isn't needed) ; IRQs - IRQ Clear (also clear 2300), IRQ Disable, and IRQ Enable ; Mario RPG Level-up not working - it was using one of the IRQ functions ; that no other place in the game is using, which I suppose is the cause ; of the problem, but it's been so long since I worked on SA-1, that ; I forgot which part. %include "macros.mac" EXTSYM regptr,regptw,romdata,SA1Status,debstop4,SDD1BankA,curromsize EXTSYM debuggeron EXTSYM Get_Time,Get_TimeDate EXTSYM spc7110romptr,SPC7110Entries EXTSYM SPC7110IndexSize,SPC7110nfname EXTSYM Open_File,Close_File,Read_File,File_Seek ; EXTSYM Msgptr,MessageOn EXTSYM irqv2,irqv,nmiv2,nmiv EXTSYM snesmmap,snesmap2 EXTSYM curypos,CurrentExecSA1 EXTSYM debstop3 EXTSYM memaccessbankr8sdd1,memtabler8,AddrNoIncr EXTSYM NumofBanks NEWSYM Sa1RegsAsmStart %include "cpu/regs.mac" %include "cpu/regsw.mac" ALIGN32 NEWSYM SPCMultA, dd 0 NEWSYM SPCMultB, dd 0 NEWSYM SPCDivEnd, dd 0 NEWSYM SPCMulRes, dd 0 NEWSYM SPCDivRes, dd 0 NEWSYM SPC7110BankA, dd 020100h NEWSYM SPC7110RTCStat, dd 0 NEWSYM SPC7110RTC, db 00,00,00,00,00,00,01,00,01,00,00,00,00,00,0Fh,00 NEWSYM SPC7110RTCB, db 00,00,00,00,00,00,01,00,01,00,00,00,00,01,0Fh,06 NEWSYM SPCROMPtr, dd 0 NEWSYM SPCROMtoI, dd SPCROMPtr NEWSYM SPCROMAdj, dd 0 NEWSYM SPCROMInc, dd 0 NEWSYM SPCROMCom, dd 0 NEWSYM SPCCompPtr, dd 0 NEWSYM SPCDecmPtr, dd 0 NEWSYM SPCCompCounter, dd 0 NEWSYM SPCCompCommand, dd 0 NEWSYM SPCCheckFix, dd 0 NEWSYM SPCSignedVal, dd 0 num2writespc7110reg equ $-SPCMultA NEWSYM PHnum2writespc7110reg, dd num2writespc7110reg NEWSYM RTCData, db 0Fh,0,0,0,0,0,0,0,0,0,0,0,0,0,0Fh,0 NEWSYM RTCPtr, dd 0 NEWSYM RTCPtr2, dd 0 NEWSYM RTCRest, dd 0 NEWSYM SPC7110TempPosition, dd 0 NEWSYM SPC7110TempLength, dd 0 NEWSYM SPCPrevCompPtr, dd 0 RTC2800: push ebx cmp dword[RTCRest],100 ; je .go ; inc dword[RTCRest] ; jmp .notfirst .go cmp dword[RTCPtr],0 jne near .notfirst cmp byte[debuggeron],1 je near .notfirst ; fill time/date push ebx push eax call Get_Time mov bl,al and bl,0Fh mov [RTCData+1],bl ; seconds shr eax,4 mov bl,al and bl,0Fh mov [RTCData+2],bl ; jmp .done shr eax,4 cmp word[RTCData+1],0 ; jne .notminch mov bl,al and bl,0Fh mov [RTCData+3],bl ; minutes shr eax,4 mov bl,al and bl,0Fh mov [RTCData+4],bl .notminch ; jmp .done shr eax,4 mov bl,al and bl,0Fh mov [RTCData+5],bl ; hours shr eax,4 mov bl,al and bl,0Fh mov [RTCData+6],bl call Get_TimeDate mov bl,al and bl,0Fh mov [RTCData+7],bl ; day shr eax,4 mov bl,al and bl,0Fh mov bl,al and bl,0Fh mov [RTCData+8],bl shr eax,4 mov bl,al and bl,0Fh mov [RTCData+9],bl ; month shr eax,8 mov bl,al and bl,0Fh mov [RTCData+10],bl ; year shr eax,4 mov bl,al and bl,01Fh xor bh,bh .notokay cmp bl,9 jbe .okay inc bh sub bl,10 jmp .notokay .okay mov [RTCData+11],bl add bh,9 mov [RTCData+12],bh shr eax,8 and al,0Fh mov [RTCData+13],al ; day of week .done pop eax pop ebx .notfirst mov ebx,[RTCPtr] mov al,[RTCData+ebx] inc dword[RTCPtr] cmp dword[RTCPtr],0Fh jne .notclear mov dword[RTCPtr],0 .notclear pop ebx ret RTC2801w: ; mov byte[debstop3],1 mov dword[RTCRest],0 mov dword[RTCPtr],0 cmp al,0Eh jne .notreset mov dword[RTCPtr2],0 ret .notreset cmp al,0Dh jne .notstop mov dword[RTCPtr2],0 ret .notstop push ebx mov ebx,dword[RTCPtr2] cmp ebx,0 je .next cmp ebx,13 ja .nomore mov [RTCData+ebx],al .next inc dword[RTCPtr2] .nomore pop ebx ret NEWSYM RTCinit mov dword[RTCPtr],0 ret NEWSYM RTCReset setreg 2800h*4,RTC2800 ret NEWSYM RTCReset2 setregw 2801h*4,RTC2801w ret SPC4850: mov al,[SPC7110RTC] ret SPC4851: mov al,[SPC7110RTC+01h] ret SPC4852: mov al,[SPC7110RTC+02h] ret SPC4853: mov al,[SPC7110RTC+03h] ret SPC4854: mov al,[SPC7110RTC+04h] ret SPC4855: mov al,[SPC7110RTC+05h] ret SPC4856: mov al,[SPC7110RTC+06h] ret SPC4857: mov al,[SPC7110RTC+07h] ret SPC4858: mov al,[SPC7110RTC+08h] ret SPC4859: mov al,[SPC7110RTC+09h] ret SPC485A: mov al,[SPC7110RTC+0Ah] ret SPC485B: mov al,[SPC7110RTC+0Bh] ret SPC485C: mov al,[SPC7110RTC+0Ch] ret SPC485D: mov al,[SPC7110RTC+0Dh] ret SPC485E: mov al,[SPC7110RTC+0Eh] ret SPC485F: mov al,[SPC7110RTC+0Fh] ret NEWSYM SPCDecompFin, dd 0 NEWSYM SPC7110init mov dword[SPCMultA],0 mov dword[SPCMultB],0 mov dword[SPCDivEnd],0 mov dword[SPCMulRes],0 mov dword[SPCDivRes],0 mov dword[SPC7110BankA],020100h mov dword[SPC7110RTCStat],0 mov dword[SPC7110RTCStat],0 mov dword[SPCROMPtr],0 mov dword[SPCROMtoI],SPCROMPtr mov dword[SPCROMAdj],0 mov dword[SPCROMInc],0 mov dword[SPCROMCom],0 mov dword[SPCDecompFin],0 mov dword[SPCCompPtr],0 mov dword[SPCDecmPtr],0 mov dword[SPCCompCounter],0 mov dword[SPCCompCommand],0 mov dword[SPCCheckFix],0 mov dword[SPCPrevCompPtr],0 ret NEWSYM SPC7110Reset setregw 4801h*4,SPC4801w setregw 4802h*4,SPC4802w setregw 4803h*4,SPC4803w setregw 4804h*4,SPC4804w setregw 4805h*4,SPC4805w setregw 4806h*4,SPC4806w setregw 4807h*4,SPC4807w setregw 4808h*4,SPC4808w setregw 4809h*4,SPC4809w setregw 480Ah*4,SPC480Aw setregw 480Bh*4,SPC480Bw setregw 4811h*4,SPC4811w setregw 4812h*4,SPC4812w setregw 4813h*4,SPC4813w setregw 4814h*4,SPC4814w setregw 4815h*4,SPC4815w setregw 4816h*4,SPC4816w setregw 4817h*4,SPC4817w setregw 4818h*4,SPC4818w setregw 4820h*4,SPC4820w setregw 4821h*4,SPC4821w setregw 4822h*4,SPC4822w setregw 4823h*4,SPC4823w setregw 4824h*4,SPC4824w setregw 4825h*4,SPC4825w setregw 4826h*4,SPC4826w setregw 4827h*4,SPC4827w setregw 482Eh*4,SPC482Ew setregw 4831h*4,SPC4831w setregw 4832h*4,SPC4832w setregw 4833h*4,SPC4833w setregw 4840h*4,SPC4840w setregw 4841h*4,SPC4841w setregw 4842h*4,SPC4842w ret NEWSYM initSPC7110regs setreg 4800h*4,SPC4800 setreg 4801h*4,SPC4801 setreg 4802h*4,SPC4802 setreg 4803h*4,SPC4803 setreg 4804h*4,SPC4804 setreg 4805h*4,SPC4805 setreg 4806h*4,SPC4806 setreg 4807h*4,SPC4807 setreg 4808h*4,SPC4808 setreg 4809h*4,SPC4809 setreg 480Ah*4,SPC480A setreg 480Bh*4,SPC480B setreg 480Ch*4,SPC480C setreg 4810h*4,SPC4810 setreg 4811h*4,SPC4811 setreg 4812h*4,SPC4812 setreg 4813h*4,SPC4813 setreg 4814h*4,SPC4814 setreg 4815h*4,SPC4815 setreg 4816h*4,SPC4816 setreg 4817h*4,SPC4817 setreg 4818h*4,SPC4818 setreg 481Ah*4,SPC481A setreg 4820h*4,SPC4820 setreg 4821h*4,SPC4821 setreg 4822h*4,SPC4822 setreg 4823h*4,SPC4823 setreg 4824h*4,SPC4824 setreg 4825h*4,SPC4825 setreg 4826h*4,SPC4826 setreg 4827h*4,SPC4827 setreg 4828h*4,SPC4828 setreg 4829h*4,SPC4829 setreg 482Ah*4,SPC482A setreg 482Bh*4,SPC482B setreg 482Ch*4,SPC482C setreg 482Dh*4,SPC482D setreg 482Eh*4,SPC482E setreg 482Fh*4,SPC482F setreg 4831h*4,SPC4831 setreg 4832h*4,SPC4832 setreg 4833h*4,SPC4833 setreg 4834h*4,SPC4834 setreg 4840h*4,SPC4840 setreg 4841h*4,SPC4841 setreg 4842h*4,SPC4842 setreg 4850h*4,SPC4850 setreg 4851h*4,SPC4851 setreg 4852h*4,SPC4852 setreg 4853h*4,SPC4853 setreg 4854h*4,SPC4854 setreg 4855h*4,SPC4855 setreg 4856h*4,SPC4856 setreg 4857h*4,SPC4857 setreg 4858h*4,SPC4858 setreg 4859h*4,SPC4859 setreg 485Ah*4,SPC485A setreg 485Bh*4,SPC485B setreg 485Ch*4,SPC485C setreg 485Dh*4,SPC485D setreg 485Eh*4,SPC485E setreg 485Fh*4,SPC485F ret %macro BankSwitchSPC7110 2 push ecx push edx push eax mov [SPC7110BankA+%1],al inc al cmp byte[curromsize],13 jne .mbit24 .mbit40 cmp al,5 jb .okaymbit sub al,4 jmp .mbit40 .mbit24 cmp al,3 jb .okaymbit sub al,2 jmp .mbit24 .okaymbit and eax,07h shl eax,20 add eax,[romdata] mov ecx,10h mov ebx,snesmap2+%2*4 mov edx,snesmmap+%2*4 .mmaploop2 mov [ebx],eax mov [edx],eax add eax,10000h add ebx,4 add edx,4 dec ecx jnz .mmaploop2 pop eax pop edx pop ecx ret %endmacro NEWSYM LastLog pushad cmp byte[CurValUsed],0 je near .novalue xor ebx,ebx mov edx,DecompArray mov eax,[CurPtrVal] cmp dword[DecompAPtr],0 je .noptr .loop mov ecx,[edx] cmp ecx,eax je .match add edx,8 inc ebx cmp ebx,[DecompAPtr] jne .loop .noptr cmp dword[DecompAPtr],8192 je .novalue mov [edx],eax xor eax,eax mov ax,[CurDecompSize] mov [edx+4],ax mov ax,[CurPtrLen] mov [edx+6],ax mov al,[CurPtrLen+2] mov [edx+3],al inc dword[DecompAPtr] jmp .novalue .match add edx,4 mov bx,[CurDecompSize] xor ebx,ebx cmp [edx],bx jae .novalue mov [edx],bx .novalue mov [lastentry],edx mov byte[CurValUsed],1 mov eax,[SPCCompPtr] and eax,0FFFFFFh mov [CurPtrVal],eax popad ret SPC4800: ; mov byte[debstop3],1 ; cmp word[SPCCompCounter],0FFFFh ; jne .notzero ; xor al,al ; ret ;.notzero cmp byte[SPCCompCommand],0 je .manual xor al,al dec word[SPCCompCounter] push ebx xor ebx,ebx ; mov ebx,[SPCCompPtr] ; and ebx,0FFFFFFh ; add ebx,[romdata] ; add ebx,100000h mov bx,[SPCDecmPtr] add ebx,[romdata] add ebx,510000h mov al,[ebx] pop ebx ; xor al,al inc dword[SPCCompPtr] push eax inc word[SPCDecmPtr] mov ax,[SPCDecmPtr] mov [CurDecompPtr],ax sub ax,[PrevDecompPtr] mov [CurDecompSize],ax pop eax ; cmp word[SPCCompCounter],0FFFFh ; jne .exit ; mov byte[SPCDecompFin],80h ;.exit ret .manual xor al,al push ebx xor ebx,ebx mov bx,[SPCDecmPtr] add ebx,[romdata] add ebx,510000h mov al,[ebx] pop ebx dec word[SPCCompCounter] inc dword[SPCCompPtr] inc word[SPCDecmPtr] inc word[CurDecompSize] ; cmp word[SPCCompCounter],0FFFFh ; jne .exit2 ; mov byte[SPCDecompFin],80h ;.exit2 ret SPC4801: mov al,[SPCCompPtr] ret SPC4802: mov al,[SPCCompPtr+1] ret SPC4803: mov al,[SPCCompPtr+2] ret SPC4804: mov al,[SPCCompPtr+3] ret SPC4805: mov al,[SPCDecmPtr] ret SPC4806: mov al,[SPCDecmPtr+1] ret SPC4807: xor al,al ret SPC4808: xor al,al ret SPC4809: mov al,[SPCCompCounter] ret SPC480A: mov al,[SPCCompCounter+1] ret SPC480B: mov al,[SPCCompCommand] mov dword[SPCDecmPtr],0 ret SPC480C: ; decompression finished status mov al,[SPCDecompFin] mov byte[SPCDecompFin],0 ret NEWSYM CurPtrVal, dd 0 NEWSYM CurCompCounter2, dd 0 NEWSYM CurPtrLen, dd 0 NEWSYM CurValUsed, db 0 NEWSYM PrevDecompPtr, dw 0 NEWSYM CurDecompPtr, dw 0 NEWSYM CurDecompSize, dw 0 NEWSYM DecompArray, times 65536 db 0 NEWSYM DecompAPtr, dd 0 lastentry dd 0 NEWSYM UpdateRTC test byte[SPC7110RTC+0Dh],02h jnz .notimer .notimer ret SPC4801w: mov [SPCCompPtr],al ret SPC4802w: mov [SPCCompPtr+1],al ret SPC4803w: mov [SPCCompPtr+2],al ret SPC4804w: mov [SPCCompPtr+3],al ret SPC4805w: mov [SPCDecmPtr],al ret SPC4806w: mov [SPCDecmPtr+1],al cmp dword[SPCCompPtr],0124AD48h jne .nodata ; mov byte[debstop3],1 .nodata pushad cmp byte[CurValUsed],0 je near .novalue xor ebx,ebx mov edx,DecompArray mov eax,[CurPtrVal] ; and eax,0FFFFFFh cmp dword[DecompAPtr],0 je .noptr .loop mov ecx,[edx] ; and ecx,0FFFFFFh cmp ecx,eax je .match add edx,8 inc ebx cmp ebx,[DecompAPtr] jne .loop .noptr cmp dword[DecompAPtr],8192 je .novalue mov [edx],eax xor eax,eax mov ax,[CurDecompSize] mov [edx+4],ax mov ax,[CurPtrLen] mov [edx+6],ax mov al,[CurPtrLen+2] mov [edx+3],al inc dword[DecompAPtr] jmp .novalue .match add edx,4 xor ebx,ebx mov bx,[CurDecompSize] cmp [edx],bx jae .novalue mov [edx],bx .novalue mov [lastentry],edx mov byte[CurValUsed],1 mov eax,[SPCCompPtr] and eax,0FFFFFFh mov [CurPtrVal],eax popad mov word[CurDecompSize],0 push eax mov al,[SPCCompPtr+3] mov [CurPtrLen+2],al mov ax,[SPCDecmPtr] ;CurCompCounter2] mov [CurPtrLen],ax mov eax,[SPCCompPtr] mov [CurPtrVal],eax mov ax,[SPCDecmPtr] mov [PrevDecompPtr],ax mov [CurDecompPtr],ax mov word[CurDecompSize],0 pop eax mov byte[SPCDecompFin],0h ; Start Decompression pushad mov eax,[SPCCompPtr] cmp [SPCPrevCompPtr],eax je near .previousequal mov [SPCPrevCompPtr],eax mov ecx,[SPC7110Entries] mov ebx,[SPCCompPtr] and ebx,0FFFFFFh mov eax,[spc7110romptr] or ecx,ecx jz .noentries .loopc mov edx,[eax] cmp dl,[SPCCompPtr+3] jne .notfound shr edx,8 cmp ebx,edx je .found .notfound add eax,12 dec ecx jnz .loopc jmp .noentries .found xor word[CurPtrLen],0FFFFh mov ecx,[eax+8] mov ebx,[eax+4] xor edx,edx mov dx,[SPCDecmPtr] add edx,[romdata] add edx,510000h push eax .loopb mov al,[ebx] mov [edx],al inc ebx inc edx dec ecx jnz .loopb pop eax mov ebx,[eax+4] mov edx,[lastentry] ; mov [edx+4],ebx mov ebx,[eax] ; mov [edx],ebx jmp .foundentry .noentries mov ecx,[SPC7110IndexSize] ; Address/index, pointer, length, SPC7110nfname mov edx,[romdata] add edx,580000h .sploop mov eax,[SPCCompPtr] shl eax,8 mov al,[SPCCompPtr+3] cmp [edx],eax je .foundsp add edx,12 sub ecx,12 jc .overflow jnz .sploop .overflow jmp .notfoundentry .foundsp mov eax,[edx+4] mov [SPC7110TempPosition],eax mov eax,[edx+8] mov [SPC7110TempLength],eax mov edx,SPC7110nfname add edx,9 mov eax,[SPCCompPtr] and eax,0FFFFFFh mov ecx,6 .sploop2 mov ebx,eax shr ebx,20 and ebx,0Fh cmp bl,9 jbe .below9 add bl,55-48 .below9 add bl,48 mov [edx],bl inc edx shl eax,4 dec ecx jnz .sploop2 mov edx,SPC7110nfname call Open_File jc .error mov bx,ax mov dx,[SPC7110TempPosition] mov cx,[SPC7110TempPosition+2] call File_Seek xor edx,edx mov dx,[SPCDecmPtr] add edx,[romdata] add edx,510000h mov ecx,[SPC7110TempLength] call Read_File call Close_File jmp .foundentry .error ; mov dword[Msgptr],SPC7110nfname ; mov dword[MessageOn],60*6 .notfoundentry .foundentry .previousequal popad .fin .blah ; Finished ; mov word[SPCCompCounter],0FFFFh mov byte[SPCDecompFin],80h ret SPC4807w: ret SPC4808w: ret SPC4809w: mov [SPCCompCounter],al mov [CurCompCounter2],al ret SPC480Aw: mov [SPCCompCounter+1],al mov [CurCompCounter2+1],al ret SPC480Bw: mov [SPCCompCommand],al ret ;NEWSYM SPCROMPtr, dd 0 ;NEWSYM SPCROMAdj, dd 0 ;NEWSYM SPCROMInc, dd 0 ;NEWSYM SPCROMCom, dd 0 ; 01, ;$4810 DATA ROM CONTINUOUS READ PORT: returns a byte from data rom at data ; rom pointer location, defval:00 ;$4811 DATA ROM POINTER: ($0000FF) r/w low offset, defval:00 ;$4812 DATA ROM POINTER: ($00FF00) r/w high offset, defval:00 ;$4813 DATA ROM POINTER: ($FF0000) r/w bank offset, defval:00 ; bank offset is zero based from start of data rom: banks $00-$3f ; data rom -> $10-$4f full rom ;$4814 DATA ROM POINTER ADJUST: ($00FF) low byte, defval:00 ;$4815 DATA ROM POINTER ADJUST: ($FF00) high byte, defval:00 ;$4816 DATA ROM POINTER INCREMENT: ($00FF) low byte, defval:00 ;$4817 DATA ROM POINTER INCREMENT: ($FF00) high byte, defval:00 ;$4818 DATA ROM COMMAND MODE: bit field control of data rom pointer (see ; data rom command mode byte), defval:00 ; write: set command mode, ; read: performs action instead of returning value, unknown purpose, ; command mode is loaded to $4818 but only set after writing to both ; $4814 and $4815 in any order ;$481A DATA ROM READ AFTER ADJUST PORT: returns a byte from data rom at ; data rom pointer location + adjust value ($4814/5), defval:00 SPC4810: cmp dword[SPCCheckFix],0 jne .okay xor al,al ret .okay push ebx push ecx mov ebx,[SPCROMPtr] add ebx,[romdata] add ebx,100000h mov al,[ebx] cmp byte[SPCROMCom+1],0 jne .noincr1 mov ebx,[SPCROMtoI] inc dword[ebx] .noincr1 cmp byte[SPCROMCom+1],1 ; add 4816 after 4810 read jne .noincr1b mov ebx,[SPCROMtoI] mov ecx,[SPCROMInc] add dword[ebx],ecx .noincr1b pop ecx pop ebx ret SPC4811: mov al,[SPCROMPtr] ret SPC4812: mov al,[SPCROMPtr+1] ret SPC4813: mov al,[SPCROMPtr+2] ret SPC4814: mov al,[SPCROMAdj] ret SPC4815: mov al,[SPCROMAdj+1] ret SPC4816: mov al,[SPCROMInc] ret SPC4817: mov al,[SPCROMInc+1] ret SPC4818: mov al,[SPCROMCom] ret SPC481A: cmp dword[SPCCheckFix],0 jne .okay xor al,al ret .okay push ebx push ecx xor ebx,ebx xor ecx,ecx mov bx,[SPCROMAdj] add ebx,[SPCROMPtr] add ebx,[romdata] add ebx,100000h mov al,[ebx] cmp byte[SPCROMCom+1],4 ; 16bit 4814 jne .notincr mov ecx,[SPCROMtoI] mov ebx,[SPCROMAdj] add [ecx],ebx .notincr pop ecx pop ebx ret SPC4811w: mov [SPCROMPtr],al mov byte[SPCCheckFix],1 ret SPC4812w: mov [SPCROMPtr+1],al ret SPC4813w: mov [SPCROMPtr+2],al ret SPC4814w: mov [SPCROMAdj],al cmp byte[SPCROMCom+1],2 ; 8 bit 4814 jne .notincr mov ebx,[SPCROMtoI] xor ecx,ecx mov cl,[SPCROMAdj] test byte[SPCROMCom],08h jz .noneg movsx ecx,byte[SPCROMAdj] .noneg add dword[ebx],ecx .notincr ret SPC4815w: mov [SPCROMAdj+1],al mov word[SPCROMAdj+2],0 test byte[SPCROMCom],08h jz .noneg test byte[SPCROMAdj+1],80h jz .noneg mov word[SPCROMAdj+2],0FFFFh .noneg cmp byte[SPCROMCom+1],3 ; 16bit 4814 jne .notincr push ebx push ecx mov ecx,[SPCROMtoI] mov ebx,[SPCROMAdj] add [ecx],ebx pop ecx pop ebx .notincr ret SPC4816w: mov [SPCROMInc],al ret SPC4817w: mov [SPCROMInc+1],al mov word[SPCROMInc+2],0 test byte[SPCROMCom],04h jz .noneg test byte[SPCROMInc+1],40h jz .noneg mov word[SPCROMInc+2],0FFFFh .noneg ret SPC4818w: mov [SPCROMCom],al mov word[SPCROMAdj+2],0 test byte[SPCROMCom],08h jz .noneg test byte[SPCROMAdj+1],80h jz .noneg mov word[SPCROMAdj+2],0FFFFh .noneg mov word[SPCROMInc+2],0 test byte[SPCROMCom],04h jz .noneg2 test byte[SPCROMInc+1],40h jz .noneg2 mov word[SPCROMInc+2],0FFFFh .noneg2 mov dword[SPCROMtoI],SPCROMPtr test byte[SPCROMCom],10h jz .nouseadjust mov dword[SPCROMtoI],SPCROMAdj .nouseadjust test al,02h jz .no4814 test al,40h jz .no16b test al,20h jz .not481A mov byte[SPCROMCom+1],4 ; 16bit 4814 after 481A jmp .fin .not481A mov byte[SPCROMCom+1],3 ; 16bit 4814 jmp .fin .no16b test al,20h jz .nooffsetadd mov byte[SPCROMCom+1],2 ; 8 bit 4814 jmp .fin .nooffsetadd mov byte[SPCROMCom+1],0FFh jmp .fin .no4814 test al,01h jz .incrval0 mov byte[SPCROMCom+1],1 ; add 4816 after 4810 read jmp .fin .incrval0 mov byte[SPCROMCom+1],0 ; add 1 after 4810 read .fin ret ;Data Rom Command Mode Byte: ;X6543210 ;|||||||| ;|||||| \__ : 00 - use 1 as the offset increment value, add immediately after reading $4810 ;|||||| : 01 - use $4816 as offset increment, add immediately after reading $4810 ;|||||| : 10 - use $4814 as offset increment, see below for when to add ;|||||| : 11 - unused ;||||||____ : 0 - unsigned calculation for $4816 ;||||| 1 - signed calculation for $4816 ;|||||_____ : 0 - unsigned calculation for $4814 ;|||| 1 - signed calculation for $4814 ;||||______ : 0 - offset increment gets added to $4811/2/3 ;||| 1 - offset increment gets added to $4814/5 ;| \_______ : 00 - disable offset addition ;| : 01 - 8 bit offset addition using $4814, immediately after writing to $4814/5 ;| : 10 - 16 bit offset addition using $4814/5, immediately after writing to $4814/5 ;| : 11 - 16 bit offset addition using $4814/5, only after reading $481A ;|_________ : unused SPC4820: mov al,[SPCMultA] ; mov byte[debstop3],1 ret SPC4821: mov al,[SPCMultA+1] ret SPC4822: mov al,[SPCMultA+2] ret SPC4823: mov al,[SPCMultA+3] ret SPC4824: mov al,[SPCMultB] ret SPC4825: mov al,[SPCMultB+1] ret SPC4826: mov al,[SPCDivEnd] ret SPC4827: mov al,[SPCDivEnd+1] ret SPC4820w: mov [SPCMultA],al ret SPC4821w: mov [SPCMultA+1],al ret SPC4822w: mov [SPCMultA+2],al ret SPC4823w: mov [SPCMultA+3],al ret SPC4824w: mov [SPCMultB],al ret SPC4825w: mov [SPCMultB+1],al ; Calculate SPCMultA*SPCMultB -> SPCMulRes test byte[SPCSignedVal],1 jnz .signed push edx push eax push ebx xor eax,eax xor ebx,ebx mov ax,[SPCMultA] mov bx,[SPCMultB] mul ebx mov [SPCMulRes],eax pop ebx pop eax pop edx ret .signed push edx push eax push ebx movsx eax,word[SPCMultA] movsx ebx,word[SPCMultB] imul ebx mov [SPCMulRes],eax pop ebx pop eax pop edx ret SPC4826w: mov [SPCDivEnd],al ret SPC4827w: mov [SPCDivEnd+1],al ; Calculte SPCMultA/SPCDivEnd -> SPCMulRes, rem SPCDivRes cmp word[SPCDivEnd],0 je near .nodivide test byte[SPCSignedVal],1 jnz .signed push edx push eax push ebx xor edx,edx xor ebx,ebx mov eax,[SPCMultA] mov bx,[SPCDivEnd] div ebx mov [SPCMulRes],eax mov [SPCDivRes],dx pop ebx pop eax pop edx ret .signed push edx push eax push ebx xor edx,edx mov eax,[SPCMultA] test eax,80000000h jz .nd mov edx,0FFFFFFFFh .nd movsx ebx,word[SPCDivEnd] idiv ebx mov [SPCMulRes],eax mov [SPCDivRes],dx pop ebx pop eax pop edx ret .nodivide mov dword[SPCMulRes],0FFFFFFFFh mov dword[SPCDivRes],0FFFFh ret SPC4828: mov al,[SPCMulRes] ret SPC4829: mov al,[SPCMulRes+1] ret SPC482A: mov al,[SPCMulRes+2] ret SPC482B: mov al,[SPCMulRes+3] ret SPC482C: mov al,[SPCDivRes] ret SPC482D: mov al,[SPCDivRes+1] ret SPC482E: xor al,al ret SPC482Ew: mov byte[SPCSignedVal],al mov dword[SPCMultA],0 mov dword[SPCMultB],0 mov dword[SPCDivEnd],0 mov dword[SPCMulRes],0 mov dword[SPCDivRes],0 ret SPC482F: xor al,al ret SPC4831w: BankSwitchSPC7110 0,0D0h ret SPC4832w: BankSwitchSPC7110 1,0E0h ret SPC4833w: ; mov byte[debstop3],1 BankSwitchSPC7110 2,0F0h ret SPC4831: mov al,[SPC7110BankA] ret SPC4832: mov al,[SPC7110BankA+1] ret SPC4833: mov al,[SPC7110BankA+2] ret SPC4834: xor al,al ret ;NEWSYM SPC7110RTCStat, dd 0 ;NEWSYM SPC7110RTC, db 00,00,00,00,00,00,01,00,01,00,00,00,00,01,0F,06 ;$4840 RTC CHIP ENABLE/DISABLE: bit 0: on = enable, off = disable, defval:00 ;$4841 RTC INDEX/DATA PORT: ; first write after rtc enable: rtc command mode byte (see rtc command modes) ; subsequent writes: index of rtc register to read/write (00-0f) ; read: returns value of indexed rtc register ; auto-increment of register index occurs after each subsequent read/write ;$4842 RTC READY STATUS: bit 7: on = ready, off = still processing, tested before reading rtc data ; high bit cleared after successful read SPC4840w: test al,1 jz .notreset mov byte[SPC7110RTCStat],al mov byte[SPC7110RTCStat+1],0FEh .notreset ret SPC4841w: cmp byte[SPC7110RTCStat+1],0FEh je .commandbyte cmp byte[SPC7110RTCStat+1],0FFh je .commandindex push ebx xor ebx,ebx mov bl,[SPC7110RTCStat+1] mov [SPC7110RTC+ebx],al cmp ebx,0Fh jne .notlast test al,01h jz .notlast mov dword[SPC7110RTC],0 mov dword[SPC7110RTC+4],010000h mov dword[SPC7110RTC+8],01h mov byte[SPC7110RTC+12],0 .notlast pop ebx inc byte[SPC7110RTCStat+1] and byte[SPC7110RTCStat+1],0Fh ret .commandbyte inc byte[SPC7110RTCStat+1] mov byte[SPC7110RTCStat+2],al ret .commandindex push eax and al,0Fh mov byte[SPC7110RTCStat+1],al pop eax ret SPC4842w: ret SPC4840: mov al,[SPC7110RTCStat] ret SPC4841: cmp byte[SPC7110RTCStat+1],0FEh je near .commandbyte cmp byte[SPC7110RTCStat+1],0FFh je near .commandbyte push ebx xor ebx,ebx mov bl,[SPC7110RTCStat+1] or ebx,ebx jnz near .dontupdate test byte[SPC7110RTC+0Fh],03h jnz near .dontupdate test byte[SPC7110RTC+0Dh],01h jnz near .dontupdate ;00 - seconds 1's digit 00 ;01 - seconds 10's digit 00 ;02 - minutes 1's digit 00 ;03 - minutes 10's digit 00 ;04 - hours 1's digit 00 ;05 - hours 10's digit 00 ;06 - day of month 1's digit 01 ;07 - day of month 10's digit 00 ;08 - month 1's digit 01 ;09 - month 10's digit 00 ;0a - year 1's digit 00 ;0b - year 10's digit 00 ;0c - day of week 00 cmp byte[debuggeron],1 je near .dontupdate ; fill time/date push ebx push eax call Get_Time mov bl,al and bl,0Fh mov [SPC7110RTC],bl ; seconds shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+1],bl shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+2],bl ; minutes shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+3],bl test byte[SPC7110RTC+0Fh],4 ; jz .not24hrs ; jmp .not24hrs shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+4],bl ; hours shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+5],bl jmp .24hrs .not24hrs shr eax,4 xor ebx,ebx mov bl,al mov al,[SPCTimerVal+ebx] mov bl,al and bl,0Fh mov [SPC7110RTC+4],bl ; hours shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+5],bl .24hrs call Get_TimeDate mov bl,al and bl,0Fh mov [SPC7110RTC+6],bl ; day shr eax,4 mov bl,al and bl,0Fh mov [SPC7110RTC+7],bl shr eax,4 mov bl,al and bl,0Fh xor bh,bh cmp bl,9 jbe .less sub bl,10 mov bh,1 .less mov [SPC7110RTC+8],bl ; month mov [SPC7110RTC+9],bh ; month shr eax,8 mov bl,al and bl,0Fh mov [SPC7110RTC+10],bl ; year shr eax,4 mov bl,al and bl,01Fh xor bh,bh .notokay cmp bl,9 jbe .okay inc bh sub bl,10 jmp .notokay .okay mov [SPC7110RTC+11],bl shr eax,8 and al,0Fh mov [SPC7110RTC+12],al ; day of week .done pop eax pop ebx .dontupdate ; test byte[SPC7110RTC+0Fh],1 ; jz .realtime ; cmp ebx,0Dh ; jae .realtime ; mov al,[SPC7110RTCB+ebx] ; jmp .next ;.realtime mov al,[SPC7110RTC+ebx] ;.next pop ebx inc byte[SPC7110RTCStat+1] and byte[SPC7110RTCStat+1],0Fh ret .commandbyte inc byte[SPC7110RTCStat+1] mov al,byte[SPC7110RTCStat+2] ret SPCTimerVal db 12h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0,0,0,0,0,0 db 10h,11h,32h,21h,22h,23h,24h,25h,26h,27h,0,0,0,0,0,0 db 28h,29h SPC4842: mov al,80h ret ;$4820 16 BIT MULTIPLICAND: ($00FF) low byte, defval:00 ; 32 BIT DIVI: ($000000FF) low byte of low word, defval:00 ;$4821 16 BIT MULTIPLICAND: ($FF00) high byte, defval:00 ; 32 BIT DIVI: ($0000FF00) high byte of low word, defval:00 ;$4822 32 BIT DIVI: ($00FF0000) low byte of high word, defval:00 ;$4823 32 BIT DIVI: ($FF000000) high byte of high word, defval:00 ;$4824 16 BIT MULTIPLIER: ($00FF) low byte, defval:00 ;$4825 16 BIT MULTIPLIER: ($FF00) high byte, defval:00 ;$4826 16 BIT DIVISOR: ($00FF), defval:00 ;$4827 16 BIT DIVISOR: ($FF00), defval:00 ;$4828 32 BIT PRODUCT: ($000000FF) low byte of low word, defval:00 ; 32 BIT QUOTIENT:($000000FF) low byte of low word, defval:00 ;$4829 32 BIT PRODUCT: ($0000FF00) high byte of low word, defval:00 ; 32 BIT QUOTIENT:($0000FF00) high byte of low word, defval:00 ;$482A 32 BIT PRODUCT: ($00FF0000) low byte of high word, defval:00 ; 32 BIT QUOTIENT:($00FF0000) low byte of high word, defval:00 ;$482B 32 BIT PRODUCT: ($FF000000) high byte of high word, defval:00 ; 32 BIT QUOTIENT:($FF000000) high byte of high word, defval:00 ;$482C 16 BIT REMAINDER: ($00FF) low byte, defval:00 ;$482D 16 BIT REMAINDER: ($FF00) high byte, defval:00 ;$482E MUL/DIV RESET, write = reset $4820 to $482D, defval:00 ;$482F MUL/DIV FINISHED STATUS: bit 7: on = processing, off = finished, ; high bit is set after a write to multiplier or divisor regs $4825/$4827, defval:00 ; SA-1 Start ; ---------- ALIGN32 ; IRQ Stuff NEWSYM SA1Mode, dd 0 ; 0 = SNES CPU, 1 = SA1 CPU NEWSYM SA1Control, dd 0 ; don't execute if b5 or 6 are set NEWSYM SA1BankPtr, dd 0 NEWSYM SA1ResetV, dd 0 NEWSYM SA1NMIV, dd 0 NEWSYM SA1IRQV, dd 0 NEWSYM SA1RV, dd 0 NEWSYM CurBWPtr, dd 0 NEWSYM SA1TempVar, dd 0 NEWSYM SA1IRQEn, dd 0 NEWSYM SA1Message, dd 0 NEWSYM SA1IRQExec, dd 0 NEWSYM SA1IRQEnable, dd 0 NEWSYM SA1DoIRQ, dd 0 ; Arithmetic Stuff NEWSYM SA1ARC, dd 0 NEWSYM SA1AR1, dd 0 NEWSYM SA1AR2, dd 0 NEWSYM SA1ARR1, dd 0 NEWSYM SA1ARR2,dd 0 NEWSYM SA1Stat, dd 0 NEWSYM SNSNMIV, dd 0 NEWSYM SNSIRQV, dd 0 NEWSYM SA1DMACount, dd 0 NEWSYM SA1DMAInfo, dd 0 NEWSYM SA1DMAChar, dd 0 NEWSYM SA1DMASource, dd 0 NEWSYM SA1DMADest, dd 0 NEWSYM SA1IRQTemp, dd 0 NEWSYM SA1BankSw, dd 1 NEWSYM SA1BankVal, db 0,1,2,3 NEWSYM BWShift, dd 0 NEWSYM BWAndAddr, dd 0 NEWSYM BWAnd, dd 0 NEWSYM BWRAnd, dd 0 SA1Reserved times 456 db 0 ; SA1 Swap Stuff NEWSYM SA1xa, dd 0 NEWSYM SA1xx, dd 0 NEWSYM SA1xy, dd 0 NEWSYM SA1xd, dd 0 NEWSYM SA1xdb, dd 0 NEWSYM SA1xpb, dd 0 NEWSYM SA1xs, dd 0 NEWSYM SA1RegP, dd 0 NEWSYM SA1RegE, dd 0 NEWSYM SA1RegPCS,dd 0 NEWSYM SA1BWPtr,dd 0 NEWSYM SA1Ptr, dd 0 ; Current PC, SA-1 NEWSYM SA1Overflow, dd 0 NEWSYM VarLenAddr, dd 0 NEWSYM VarLenAddrB, dd 0 NEWSYM VarLenBarrel, dd 0 NEWSYM SA1TimerVal, dd 0 NEWSYM SA1TimerSet, dd 0 NEWSYM SA1TimerCount, dd 0 NEWSYM SA1IRQData, dd 0 ; SNES Swap Stuff NEWSYM SNSRegP, dd 0 NEWSYM SNSRegE, dd 0 NEWSYM SNSRegPCS,dd 0 NEWSYM SNSBWPtr,dd 0 NEWSYM SNSPtr, dd 0 ; Current PC, SNES NEWSYM IRAM, times 2049 db 0 ;2 kbytes of iram num2writesa1reg equ $-SA1Mode NEWSYM PHnum2writesa1reg, dd num2writesa1reg NEWSYM SA1RAMArea, dd 0 NEWSYM SA1Temp, dd 0 NEWSYM Sdd1Mode, dd 0 NEWSYM Sdd1Bank, dd 0 NEWSYM Sdd1Addr, dd 0 NEWSYM Sdd1NewAddr, dd 0 %macro SA1QuickF 2 NEWSYM %1 mov [%2],al ret %endmacro NEWSYM RestoreSA1 mov eax,[romdata] add [SA1RegPCS],eax add [CurBWPtr],eax add [SA1BWPtr],eax add [SNSBWPtr],eax cmp byte[SA1Stat],1 jne .notsa1stat mov dword[SA1RegPCS],IRAM .notsa1stat cmp byte[SA1Stat],2 jne .notsa1stat2 mov dword[SA1RegPCS],IRAM-3000h .notsa1stat2 mov eax,[SA1RegPCS] add [SA1Ptr],eax mov eax,[romdata] add eax,4096*1024 mov [SA1RAMArea],eax pushad call UpdateBanks popad ret NEWSYM SaveSA1 mov byte[SA1Stat],0 mov eax,[SA1RegPCS] sub [SA1Ptr],eax cmp dword[SA1RegPCS],IRAM jne .notiram mov byte[SA1Stat],1 .notiram cmp dword[SA1RegPCS],IRAM-3000h jne .notiram2 mov byte[SA1Stat],2 .notiram2 mov eax,[romdata] sub [SA1RegPCS],eax sub [CurBWPtr],eax sub [SA1BWPtr],eax sub [SNSBWPtr],eax ret NEWSYM SA1Reset mov byte[SA1IRQData+1],0 mov byte[SA1Mode],0 mov byte[SA1Status],0 mov byte[SA1Control],20h mov dword[SA1DoIRQ],0 mov ax,[irqv2] mov [irqv],ax mov ax,[nmiv2] mov [nmiv],ax mov eax,[romdata] sub eax,8000h mov [SA1RegPCS],eax mov eax,[romdata] add eax,4096*1024 mov [SA1RAMArea],eax mov eax,[romdata] add eax,4096*1024-6000h mov dword[CurBWPtr],eax mov dword[SA1BWPtr],eax mov dword[SNSBWPtr],eax mov dword[SA1xa],0 mov dword[SA1xx],0 mov dword[SA1xy],0 mov dword[SA1xd],0 mov dword[SA1xdb],0 mov dword[SA1xpb],0 mov dword[SA1xs],1FFh mov dword[SA1RegP],0 mov dword[SA1RegE],0 mov dword[SA1IRQExec],0 mov dword[SA1IRQEnable],0 mov dword[SA1Message],0 mov word[SA1Overflow],0 ret NEWSYM UpdateBanks cmp byte[SA1BankSw],1 jne .noswap mov al,[SA1BankVal] call sa12220w mov al,[SA1BankVal+1] call sa12221w mov al,[SA1BankVal+2] call sa12222w mov al,[SA1BankVal+3] call sa12223w .noswap ret NEWSYM UpdateBanksSDD1 pushad cmp dword[SDD1BankA],0 je .nobank mov al,[SDD1BankA] call sdd14804w mov al,[SDD1BankA+1] call sdd14805w mov al,[SDD1BankA+2] call sdd14806w mov al,[SDD1BankA+3] call sdd14807w .nobank popad ret %macro BankSwitch 4 push ecx push edx push eax mov [SA1BankVal+%1],al mov ebx,snesmmap+%2*4 test al,80h jz .noupper cmp byte [NumofBanks],64 jne .BSBigBank and eax,1 .BSBigBank and eax,07h shl eax,20 push eax jmp .yesupper .noupper cmp byte [NumofBanks],64 jne .BSBigBank2 and eax,1 .BSBigBank2 and eax,07h shl eax,20 push eax mov eax,%4 .yesupper mov ecx,20h add eax,[romdata] sub eax,8000h .mmaploop mov [ebx],eax add eax,8000h add ebx,4 dec ecx jnz .mmaploop pop eax add eax,[romdata] mov ecx,10h mov ebx,snesmap2+%3*4 mov edx,snesmmap+%3*4 .mmaploop2 mov [ebx],eax mov [edx],eax add eax,10000h add ebx,4 add edx,4 dec ecx jnz .mmaploop2 pop eax pop edx pop ecx ret %endmacro NEWSYM sa12220w BankSwitch 0,0,0C0h,0 NEWSYM sa12221w BankSwitch 1,20h,0D0h,100000h NEWSYM sa12222w BankSwitch 2,80h,0E0h,200000h NEWSYM sa12223w BankSwitch 3,0A0h,0F0h,300000h %macro BankSwitchSDD1 2 push ecx push edx push eax mov [SDD1BankA+%1],al and eax,07h shl eax,20 add eax,[romdata] mov ecx,10h mov ebx,snesmap2+%2*4 mov edx,snesmmap+%2*4 .mmaploop2 mov [ebx],eax mov [edx],eax add eax,10000h add ebx,4 add edx,4 dec ecx jnz .mmaploop2 pop eax pop edx pop ecx ret %endmacro sdd14804: mov al,[SDD1BankA] ret sdd14805: mov al,[SDD1BankA+1] ret sdd14806: mov al,[SDD1BankA+2] ret sdd14807: mov al,[SDD1BankA+3] ret NEWSYM sdd14804w BankSwitchSDD1 0,0C0h NEWSYM sdd14805w BankSwitchSDD1 1,0D0h NEWSYM sdd14806w BankSwitchSDD1 2,0E0h NEWSYM sdd14807w BankSwitchSDD1 3,0F0h NEWSYM sa12200w mov bl,al and bl,0Fh mov byte[SA1Message],bl test al,80h jz .noirq or byte[SA1DoIRQ],1 .noirq test al,10h jz .nonmi or byte[SA1DoIRQ],2 .nonmi test byte[SA1Control],20h jz .noreset test al,20h jnz .noreset mov [SA1Control],al mov ebx,[romdata] mov [SA1BankPtr],ebx xor ebx,ebx mov bx,[SA1ResetV] add ebx,[romdata] sub ebx,8000h mov [SA1Ptr],ebx mov byte[SA1xpb],0 mov word[SA1xs],1FFh mov ebx,[romdata] sub ebx,8000h mov [SA1RegPCS],ebx xor ebx,ebx ret .noreset mov [SA1Control],al ret NEWSYM sa12201w ; IRQ Enable mov byte[SA1IRQEnable],al ret NEWSYM sa12202w ; IRQ Clear test al,80h jz .noirqclear and byte[SA1IRQExec],0FEh and byte[SA1DoIRQ],0FBh .noirqclear test al,20h jz .nocdmairqclear and byte[SA1IRQExec],0FDh and byte[SA1DoIRQ],0F7h .nocdmairqclear ret SA1QuickF sa12203w, SA1ResetV SA1QuickF sa12204w, SA1ResetV+1 SA1QuickF sa12205w, SA1NMIV SA1QuickF sa12206w, SA1NMIV+1 SA1QuickF sa12207w, SA1IRQV SA1QuickF sa12208w, SA1IRQV+1 NEWSYM sa12209w ; IRQ Stuff mov [SA1IRQData+1],al test al,80h jz .noirq ; execute IRQ on the SNES or byte[SA1DoIRQ],4 .noirq mov bl,al and bl,0Fh mov byte[SA1Message+1],bl mov bx,[irqv2] test al,40h jz .noirqchange mov bx,[SNSIRQV] .noirqchange mov [irqv],bx mov bx,[nmiv2] test al,10h jz .nonmichange mov bx,[SNSNMIV] .nonmichange mov [nmiv],bx ret SA1QuickF sa1220Aw, SA1IRQEn NEWSYM sa1220Bw ; SA-1 IRQ Clear test al,80h jz .noirqclear mov byte[SA1IRQExec+1],0 and byte[SA1DoIRQ],0FEh .noirqclear test al,20h jz .nocdmairqclear .nocdmairqclear test al,10h jz .nonmiclear mov byte[SA1IRQExec+2],0 and byte[SA1DoIRQ],0FDh .nonmiclear ret SA1QuickF sa1220Cw, SNSNMIV SA1QuickF sa1220Dw, SNSNMIV+1 SA1QuickF sa1220Ew, SNSIRQV SA1QuickF sa1220Fw, SNSIRQV+1 NEWSYM sa12224w ; BWRAM mov bl,al and ebx,1Fh shl ebx,13 add ebx,[romdata] add ebx,1024*4096-6000h mov dword[SNSBWPtr],ebx cmp byte[SA1Status],0 jne .nosnes mov dword[CurBWPtr],ebx .nosnes ret NEWSYM sa12225w ; BWRAM EXTSYM BWUsed2 mov [BWUsed2],al test al,80h jnz .upper mov bl,al and ebx,1Fh shl ebx,13 add ebx,[romdata] add ebx,1024*4096-6000h mov dword[SA1BWPtr],ebx cmp byte[SA1Status],0 je .nosa1b mov dword[CurBWPtr],ebx .nosa1b mov byte[BWShift],0 mov byte[BWAndAddr],0 mov byte[BWAnd],0FFh mov byte[BWRAnd],0h ret .upper mov bl,al and ebx,7Fh test byte[SA1Overflow+1],80h jz .16col shl ebx,11 mov byte[BWShift],2 mov byte[BWAndAddr],03h mov byte[BWAnd],03h mov byte[BWRAnd],0FCh jmp .4col .16col mov byte[BWShift],1 mov byte[BWAndAddr],01h mov byte[BWAnd],0Fh mov byte[BWRAnd],0F0h and ebx,3Fh shl ebx,12 .4col add ebx,[romdata] add ebx,1024*4096 mov dword[SA1BWPtr],ebx cmp byte[SA1Status],0 je .nosa1 mov dword[CurBWPtr],ebx .nosa1 ; mov byte[debstop3],1 ret NEWSYM sa12250w mov byte[SA1ARC],al mov byte[SA1ARC+1],1 test al,2 jz .notcumul mov word[SA1ARR1],0 mov word[SA1ARR1+2],0 mov word[SA1ARR1+4],0 .notcumul ret NEWSYM sa12251w mov byte[SA1AR1],al mov byte[SA1ARC+1],1 ret NEWSYM sa12252w mov byte[SA1AR1+1],al mov byte[SA1ARC+1],1 ret NEWSYM sa12253w mov byte[SA1AR2],al mov byte[SA1ARC+1],1 ret NEWSYM sa12254w mov byte[SA1AR2+1],al mov byte[SA1ARC+1],1 test byte[SA1ARC],2 jnz .cumul call UpdateArithStuff ret ; set overflow bit if exceeds 40bits .cumul pushad xor edx,edx mov ax,[SA1AR1] mov bx,[SA1AR2] imul bx shl edx,16 mov dx,ax mov byte[SA1Overflow],0 add [SA1ARR1],edx adc byte[SA1ARR2],0 jnc .notoverflow mov byte[SA1Overflow],80h .notoverflow popad ret UpdateArithStuff: cmp byte[SA1ARC+1],1 jne .noarith pushad mov byte[SA1ARC+1],0 test byte[SA1ARC],3 jz .multiply test byte[SA1ARC],2 jnz near .cumulativesum test byte[SA1ARC],1 jnz .division .multiply xor edx,edx mov ax,[SA1AR1] mov bx,[SA1AR2] imul bx mov [SA1ARR1],ax mov [SA1ARR1+2],dx popad .noarith ret .division movsx eax,word[SA1AR1] xor edx,edx test eax,80000000h jz .notneg mov edx,0FFFFFFFFh .notneg xor ebx,ebx mov bx,[SA1AR2] or ebx,ebx jz .invalid idiv ebx mov [SA1ARR1],ax mov [SA1ARR1+2],dx ; mov word[SA1AR1],0 ; mov word[SA1AR2],0 popad ret .invalid mov word[SA1ARR1],0 mov word[SA1ARR1+2],0 popad ret .cumulativesum popad ret sa12300r: mov al,[SA1Message+1] test byte[SA1IRQExec],1 jz .notexecuted or al,80h .notexecuted test byte[SA1IRQExec],2 jz .notexecutedi or al,20h .notexecutedi mov bl,[SA1IRQData+1] and bl,50h or al,bl ret sa12301r: mov al,[SA1Message] test byte[SA1IRQExec+1],1 jz .notexecuted or al,80h .notexecuted ret sa12306r: ; call UpdateArithStuff mov al,[SA1ARR1] ret sa12307r: ; call UpdateArithStuff mov al,[SA1ARR1+1] ret sa12308r: ; call UpdateArithStuff mov al,[SA1ARR1+2] ret sa12309r: ; call UpdateArithStuff mov al,[SA1ARR1+3] ret sa1230Ar: ; call UpdateArithStuff mov al,[SA1ARR2] ret sa1230Br: mov al,[SA1Overflow] ret NEWSYM IRamRead mov al,[IRAM+ecx-3000h] ret NEWSYM IRamWrite mov [IRAM+ecx-3000h],al ret NEWSYM IRamWrite2 mov [IRAM+ecx-3000h],al xor dh,dh ret NEWSYM sa1223Fw mov [SA1Overflow+1],al ret ; Variable Length Data NEWSYM sa12258w mov [VarLenBarrel+2],al mov bl,al and bl,0Fh cmp bl,0 jne .not0 mov bl,16 .not0 mov [VarLenBarrel+3],bl test al,80h jz .notchange mov [VarLenBarrel],bl mov [VarLenBarrel+1],bl .notchange ret NEWSYM sa12259w mov [VarLenAddr],al mov [VarLenAddrB],al mov byte[VarLenBarrel],0 mov byte[VarLenBarrel+1],0 ret NEWSYM sa1225Aw mov [VarLenAddr+1],al mov [VarLenAddrB+1],al mov byte[VarLenBarrel],0 mov byte[VarLenBarrel+1],0 ret NEWSYM sa1225Bw mov [VarLenAddr+2],al mov [VarLenAddrB+2],al mov byte[VarLenBarrel],0 mov byte[VarLenBarrel+1],0 ret ; Variable Length Read NEWSYM sa1230Cr push ecx xor ebx,ebx xor ecx,ecx mov bl,[VarLenAddr+2] mov cx,[VarLenAddr] test ecx,8000h jz .loweraddr add ecx,[snesmmap+ebx*4] jmp .upperaddr .loweraddr add ecx,[snesmap2+ebx*4] .upperaddr mov ebx,[ecx] mov cl,[VarLenBarrel+1] shr ebx,cl mov al,bl pop ecx test byte[VarLenBarrel+2],80h jnz .autoinc ret .autoinc mov bl,[VarLenBarrel+3] add [VarLenBarrel],bl mov bl,[VarLenBarrel] cmp bl,16 jbe .notover sub byte[VarLenBarrel],16 add dword[VarLenAddr],2 mov byte[VarLenAddr+3],0 .notover ret NEWSYM sa1230Dr push ecx xor ebx,ebx xor ecx,ecx mov bl,[VarLenAddrB+2] mov cx,[VarLenAddrB] test ecx,8000h jz .loweraddr add ecx,[snesmmap+ebx*4] jmp .upperaddr .loweraddr add ecx,[snesmap2+ebx*4] .upperaddr mov ebx,[ecx] mov cl,[VarLenBarrel+1] shr ebx,cl mov al,bh pop ecx test byte[VarLenBarrel+2],80h jnz .autoinc ret .autoinc mov bl,[VarLenBarrel+3] add [VarLenBarrel+1],bl mov bl,[VarLenBarrel+1] cmp bl,16 jbe .notover sub byte[VarLenBarrel+1],16 add dword[VarLenAddrB],2 mov byte[VarLenAddrB+3],0 .notover ret NEWSYM sa1230Er mov al,10h ret ; Approximate H loc NEWSYM sa12302r test byte[SA1TimerSet],80h jnz .timeron mov al,byte[CurrentExecSA1] shl al,2 add al,dh ret .timeron mov al,[SA1TimerCount] ret NEWSYM sa12303r test byte[SA1TimerSet],80h jnz .timeron mov al,byte[CurrentExecSA1] shr al,3 ret .timeron mov al,[SA1TimerCount+1] and al,1 ret NEWSYM sa12304r test byte[SA1TimerSet],80h jnz .timeron mov al,[curypos] ret .timeron mov bx,[SA1TimerCount+1] shr bx,1 mov al,bl ret NEWSYM sa12305r test byte[SA1TimerSet],80h jnz .timeron mov al,[curypos+1] ret .timeron mov bx,[SA1TimerCount+2] shr bx,1 mov al,bl and al,1 ret NEWSYM sa12210w ; Timer Settings mov [SA1TimerSet],al ret NEWSYM sa12211w ; Timer Clear mov dword[SA1TimerVal],0 ret NEWSYM sa12212w mov [SA1TimerCount],al ret NEWSYM sa12213w mov [SA1TimerCount+1],al ret NEWSYM sa12214w mov [SA1TimerCount+2],al ret NEWSYM sa12215w mov [SA1TimerCount+3],al ret NEWSYM sa12230w mov [SA1DMAInfo],al ret NEWSYM sa12231w mov [SA1DMAChar],al ; if b7=1, then end of chdma process ret SA1QuickF sa12232w, SA1DMASource SA1QuickF sa12233w, SA1DMASource+1 SA1QuickF sa12234w, SA1DMASource+2 SA1QuickF sa12235w, SA1DMADest NEWSYM sa12236w mov [SA1DMADest+1],al test byte[SA1DMAInfo],10h jnz near sa1chconv test byte[SA1DMAInfo],4 jnz .noiram jmp sa1dmairam .noiram ret NEWSYM sa12237w mov [SA1DMADest+2],al test byte[SA1DMAInfo],10h jnz .nobwram test byte[SA1DMAInfo],4 jz .nobwram jmp sa1dmabwram .nobwram ret NEWSYM sa12238w mov [SA1DMACount],al ret NEWSYM sa12239w mov [SA1DMACount+1],al ret NEWSYM sa1dmaptr, dd 0 NEWSYM sa1dmaptrs, dd 0 NEWSYM sa1dmairam mov ebx,[SA1DMADest] and ebx,7FFh add ebx,IRAM mov [sa1dmaptr],ebx jmp executesa1dma NEWSYM sa1dmabwram mov ebx,[SA1DMADest] and ebx,3FFFFh add ebx,[SA1RAMArea] mov [sa1dmaptr],ebx executesa1dma: test byte[SA1DMAInfo],1 jz .nobwram mov ebx,[SA1DMASource] and ebx,3FFFFh add ebx,[SA1RAMArea] mov [sa1dmaptrs],ebx jmp .doneram .nobwram test byte[SA1DMAInfo],2 jz .noiram mov ebx,[SA1DMASource] and ebx,7FFh add ebx,IRAM mov [sa1dmaptrs],ebx jmp .doneram .noiram xor ebx,ebx mov bl,[SA1DMASource+2] mov ebx,[snesmmap+ebx*4] push ecx xor ecx,ecx mov cx,[SA1DMASource] add ebx,ecx mov [sa1dmaptrs],ebx pop ecx .doneram push edx push eax push ecx mov ecx,[SA1DMACount] or ecx,ecx jz .notransfer mov ebx,[sa1dmaptrs] mov edx,[sa1dmaptr] .loop mov al,[ebx] mov [edx],al inc ebx inc edx dec ecx jnz .loop .notransfer pop ecx pop eax pop edx ret tempblah db 0 %macro setbit2b 2 test al,%1 jz %%nosb or word[ebx],%2 %%nosb %endmacro %macro setbit2b2 2 test al,%1 jz %%nosb or word[ebx+16],%2 %%nosb %endmacro ; Character Conversion DMA sa1chconv: ; or byte[SA1DoIRQ],4 or byte[SA1DoIRQ],8 ; mov byte[debstop3],1 mov ebx,[SA1DMADest] mov byte[debstop4],1 ; and ebx,7FFh and ebx,3FFFFh add ebx,[SA1RAMArea] mov [sa1dmaptr],ebx mov ebx,[SA1DMASource] and ebx,3FFFFh add ebx,[SA1RAMArea] mov [sa1dmaptrs],ebx ; 4 colors = 32 bytes, 16 colors = 64 bytes, 256 colors = 128 bytes ; SA1DMAChar,bit 2-4 = # of 8x8 tiles/horizontal row (0=1,1=2,2=3,..,5=32) ; SA1DMAChar,bit 0-1 = Color Mode (0=8b,1=4b,2=2b,3=?) test byte[SA1DMAChar],1 jnz .4bit test byte[SA1DMAChar],2 jnz near .2bit mov ebx,[sa1dmaptr] push ecx pop ecx ret .4bit pushad mov edx,[sa1dmaptrs] mov ebx,[romdata] add ebx,4096*1024+1024*1024 mov edi,16 .loop34b push ebx push edx mov ecx,32 .loop4b mov esi,8 push ebx push edx .loop24b mov word[ebx],0 mov al,[edx+3] setbit2b 10h,0001h setbit2b 20h,0100h setbit2b2 40h,0001h setbit2b2 80h,0100h setbit2b 01h,0002h setbit2b 02h,0200h setbit2b2 04h,0002h setbit2b2 08h,0200h mov al,[edx+2] setbit2b 10h,0004h setbit2b 20h,0400h setbit2b2 40h,0004h setbit2b2 80h,0400h setbit2b 01h,0008h setbit2b 02h,0800h setbit2b2 04h,0008h setbit2b2 08h,0800h mov al,[edx+1] setbit2b 10h,0010h setbit2b 20h,1000h setbit2b2 40h,0010h setbit2b2 80h,1000h setbit2b 01h,0020h setbit2b 02h,2000h setbit2b2 04h,0020h setbit2b2 08h,2000h mov al,[edx] setbit2b 10h,0040h setbit2b 20h,4000h setbit2b2 40h,0040h setbit2b2 80h,4000h setbit2b 01h,0080h setbit2b 02h,8000h setbit2b2 04h,0080h setbit2b2 08h,8000h add ebx,2 add edx,128 dec esi jnz near .loop24b pop edx pop ebx add edx,4 add ebx,32 dec ecx jnz near .loop4b pop edx pop ebx add edx,128*8 add ebx,128*8 dec edi jnz near .loop34b mov ecx,10*128*8 mov edx,[sa1dmaptrs] mov ebx,[romdata] add ebx,4096*1024+1024*1024 .next4b mov al,[ebx] mov [edx],al inc ebx inc edx dec ecx jnz .next4b popad ret .2bit pushad mov edx,[sa1dmaptrs] mov ebx,[romdata] add ebx,4096*1024+1024*1024 mov edi,16 .loop3 push ebx push edx mov ecx,32 .loop mov esi,8 push ebx push edx .loop2 mov word[ebx],0 mov al,[edx+1] setbit2b 40h,0001h setbit2b 80h,0100h setbit2b 10h,0002h setbit2b 20h,0200h setbit2b 04h,0004h setbit2b 08h,0400h setbit2b 01h,0008h setbit2b 02h,0800h mov al,[edx] setbit2b 40h,0010h setbit2b 80h,1000h setbit2b 10h,0020h setbit2b 20h,2000h setbit2b 04h,0040h setbit2b 08h,4000h setbit2b 01h,0080h setbit2b 02h,8000h add ebx,2 add edx,64 dec esi jnz near .loop2 pop edx pop ebx add edx,2 add ebx,16 dec ecx jnz near .loop pop edx pop ebx add edx,64*8 add ebx,64*8 dec edi jnz near .loop3 mov ecx,10*64*8 mov edx,[sa1dmaptrs] mov ebx,[romdata] add ebx,4096*1024+1024*1024 .next mov al,[ebx] mov [edx],al inc ebx inc edx dec ecx jnz .next popad ret .numrows dd 0 NEWSYM initSA1regs setreg 2300h*4,sa12300r setreg 2301h*4,sa12301r setreg 2302h*4,sa12302r setreg 2303h*4,sa12303r setreg 2304h*4,sa12304r setreg 2305h*4,sa12305r setreg 2306h*4,sa12306r setreg 2307h*4,sa12307r setreg 2308h*4,sa12308r setreg 2309h*4,sa12309r setreg 230Ah*4,sa1230Ar setreg 230Bh*4,sa1230Br setreg 230Ch*4,sa1230Cr setreg 230Dh*4,sa1230Dr setreg 230Eh*4,sa1230Er ; Set IRam, memory address 3000-37FF mov edi,3000h*4 add edi,[regptr] mov eax,IRamRead mov ecx,800h .loopr mov [edi],eax add edi,4 dec ecx jnz .loopr ret NEWSYM initSA1regsw setregw 2200h*4,sa12200w setregw 2201h*4,sa12201w setregw 2202h*4,sa12202w setregw 2203h*4,sa12203w setregw 2204h*4,sa12204w setregw 2205h*4,sa12205w setregw 2206h*4,sa12206w setregw 2207h*4,sa12207w setregw 2208h*4,sa12208w setregw 2209h*4,sa12209w setregw 220Ah*4,sa1220Aw setregw 220Bh*4,sa1220Bw setregw 220Ch*4,sa1220Cw setregw 220Dh*4,sa1220Dw setregw 220Eh*4,sa1220Ew setregw 220Fh*4,sa1220Fw setregw 2210h*4,sa12210w setregw 2211h*4,sa12211w setregw 2212h*4,sa12212w setregw 2213h*4,sa12213w setregw 2214h*4,sa12214w setregw 2215h*4,sa12215w setregw 2220h*4,sa12220w setregw 2221h*4,sa12221w setregw 2222h*4,sa12222w setregw 2223h*4,sa12223w setregw 2224h*4,sa12224w setregw 2225h*4,sa12225w ; Missing 2226-222A ; Missing 2240-224F (Bitmap register file) setregw 2230h*4,sa12230w setregw 2231h*4,sa12231w setregw 2232h*4,sa12232w setregw 2233h*4,sa12233w setregw 2234h*4,sa12234w setregw 2235h*4,sa12235w setregw 2236h*4,sa12236w setregw 2237h*4,sa12237w setregw 2238h*4,sa12238w setregw 2239h*4,sa12239w setregw 223Fh*4,sa1223Fw setregw 2250h*4,sa12250w setregw 2251h*4,sa12251w setregw 2252h*4,sa12252w setregw 2253h*4,sa12253w setregw 2254h*4,sa12254w setregw 2259h*4,sa12259w setregw 225Ah*4,sa1225Aw setregw 225Bh*4,sa1225Bw mov edi,3000h*4 add edi,[regptw] mov eax,IRamWrite mov ecx,800h .loopw mov [edi],eax add edi,4 dec ecx jnz .loopw setregw 3000h*4,IRamWrite2 ret NEWSYM SDD1Reset setregw 4801h*4,sdd14801w setregw 4802h*4,dbstop setregw 4803h*4,dbstop setregw 4804h*4,sdd14804w setregw 4805h*4,sdd14805w setregw 4806h*4,sdd14806w setregw 4807h*4,sdd14807w setregw 4808h*4,dbstop setregw 4809h*4,dbstop setregw 480Ah*4,dbstop setregw 480Bh*4,dbstop setregw 480Ch*4,dbstop setregw 480Dh*4,dbstop setregw 480Eh*4,dbstop setregw 480Fh*4,dbstop ret NEWSYM initSDD1regs setreg 4804h*4,sdd14804 setreg 4805h*4,sdd14805 setreg 4806h*4,sdd14806 setreg 4807h*4,sdd14807 ret dbstop: ; mov byte[debstop3],1 ret NEWSYM sdd14801w cmp al,0 jne .notzero ret .notzero mov byte[AddrNoIncr],0 ; set banks C0h-FFh to decompressing routine push eax push ebx mov eax,memtabler8+0C0h*4 mov ebx,40h .loop mov dword[eax],memaccessbankr8sdd1 add eax,4 dec ebx jnz .loop mov dword[Sdd1Mode],1 pop ebx pop eax ret NEWSYM Sa1RegsAsmEnd zsnes-1.36/src/chips/sfxproc.asm0100644000175000017500000003255607267141100016260 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM NumberOfOpcodes,SfxB,SfxBRAMR,SfxCBR,SfxCFGR,SfxCLSR,SfxCPB,SfxCROM EXTSYM SfxCarry,SfxMemTable,SfxOverflow,SfxPBR,SfxPIPE,SfxR0,SfxR1,SfxR10 EXTSYM SfxR11,SfxR12,SfxR13,SfxR14,SfxR15,SfxR2,SfxR3,SfxR4,SfxR5,SfxR6 EXTSYM SfxR7,SfxR8,SfxR9,SfxRAMBR,SfxRAMMem,SfxROMBR,SfxSCBR,SfxSCMR,SfxSFR EXTSYM SfxSignZero,SfxnRamBanks,StartSFX,regptr,regptw,sfxramdata,ChangeOps EXTSYM SfxPOR,sfxclineloc,UpdatePORSCMR,UpdateCLSR,UpdateSCBRCOLR,SfxAC EXTSYM sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc,SFXProc NEWSYM SfxProcAsmStart %include "cpu/regs.mac" %include "cpu/regsw.mac" %macro AssembleSFXFlags 0 and word[SfxSFR],8F60h test byte[SfxCarry],1 jz .nosfxcarry or word[SfxSFR],04h .nosfxcarry cmp word[SfxSignZero],0 jne .nozero or word[SfxSFR],02h .nozero test word[SfxSignZero],8000h jz .noneg or word[SfxSFR],08h .noneg cmp byte[SfxOverflow],0 je .noof or word[SfxSFR],10h .noof cmp byte[SfxB],0 je .bzero or word[SfxSFR],1000h .bzero %endmacro NEWSYM initsfxregsr setreg 3000h*4,reg3000r setreg 3001h*4,reg3001r setreg 3002h*4,reg3002r setreg 3003h*4,reg3003r setreg 3004h*4,reg3004r setreg 3005h*4,reg3005r setreg 3006h*4,reg3006r setreg 3007h*4,reg3007r setreg 3008h*4,reg3008r setreg 3009h*4,reg3009r setreg 300Ah*4,reg300Ar setreg 300Bh*4,reg300Br setreg 300Ch*4,reg300Cr setreg 300Dh*4,reg300Dr setreg 300Eh*4,reg300Er setreg 300Fh*4,reg300Fr setreg 3010h*4,reg3010r setreg 3011h*4,reg3011r setreg 3012h*4,reg3012r setreg 3013h*4,reg3013r setreg 3014h*4,reg3014r setreg 3015h*4,reg3015r setreg 3016h*4,reg3016r setreg 3017h*4,reg3017r setreg 3018h*4,reg3018r setreg 3019h*4,reg3019r setreg 301Ah*4,reg301Ar setreg 301Bh*4,reg301Br setreg 301Ch*4,reg301Cr setreg 301Dh*4,reg301Dr setreg 301Eh*4,reg301Er setreg 301Fh*4,reg301Fr setreg 3030h*4,reg3030r setreg 3031h*4,reg3031r setreg 3032h*4,reg3032r setreg 3033h*4,reg3033r setreg 3034h*4,reg3034r setreg 3035h*4,reg3035r setreg 3036h*4,reg3036r setreg 3037h*4,reg3037r setreg 3038h*4,reg3038r setreg 3039h*4,reg3039r setreg 303Ah*4,reg303Ar setreg 303Bh*4,reg303Br setreg 303Ch*4,reg303Cr setreg 303Dh*4,reg303Dr setreg 303Eh*4,reg303Er setreg 303Fh*4,reg303Fr ; set 3100-31FF to cacheregr mov edi,3100h*4 add edi,[regptr] mov eax,cacheregr mov ecx,200h .loop mov [edi],eax add edi,4 dec ecx jnz .loop ret NEWSYM initsfxregsw setregw 3000h*4,reg3000w setregw 3001h*4,reg3001w setregw 3002h*4,reg3002w setregw 3003h*4,reg3003w setregw 3004h*4,reg3004w setregw 3005h*4,reg3005w setregw 3006h*4,reg3006w setregw 3007h*4,reg3007w setregw 3008h*4,reg3008w setregw 3009h*4,reg3009w setregw 300Ah*4,reg300Aw setregw 300Bh*4,reg300Bw setregw 300Ch*4,reg300Cw setregw 300Dh*4,reg300Dw setregw 300Eh*4,reg300Ew setregw 300Fh*4,reg300Fw setregw 3010h*4,reg3010w setregw 3011h*4,reg3011w setregw 3012h*4,reg3012w setregw 3013h*4,reg3013w setregw 3014h*4,reg3014w setregw 3015h*4,reg3015w setregw 3016h*4,reg3016w setregw 3017h*4,reg3017w setregw 3018h*4,reg3018w setregw 3019h*4,reg3019w setregw 301Ah*4,reg301Aw setregw 301Bh*4,reg301Bw setregw 301Ch*4,reg301Cw setregw 301Dh*4,reg301Dw setregw 301Eh*4,reg301Ew setregw 301Fh*4,reg301Fw setregw 3030h*4,reg3030w setregw 3031h*4,reg3031w setregw 3032h*4,reg3032w setregw 3033h*4,reg3033w setregw 3034h*4,reg3034w setregw 3035h*4,reg3035w setregw 3036h*4,reg3036w setregw 3037h*4,reg3037w setregw 3038h*4,reg3038w setregw 3039h*4,reg3039w setregw 303Ah*4,reg303Aw setregw 303Bh*4,reg303Bw setregw 303Ch*4,reg303Cw setregw 303Dh*4,reg303Dw setregw 303Eh*4,reg303Ew setregw 303Fh*4,reg303Fw ; set 3100-31FF to cacheregw mov edi,3100h*4 add edi,[regptw] mov eax,cacheregw mov ecx,200h .loop mov [edi],eax add edi,4 dec ecx jnz .loop ret NEWSYM cacheregr or byte[cachewarning],1 ret NEWSYM cacheregw or byte[cachewarning],2 ret NEWSYM cachewarning, db 0 ; SFX Registers NEWSYM reg3000r mov al,[SfxR0] ret NEWSYM reg3001r mov al,[SfxR0+1] ret NEWSYM reg3002r mov al,[SfxR1] ret NEWSYM reg3003r mov al,[SfxR1+1] ret NEWSYM reg3004r mov al,[SfxR2] ret NEWSYM reg3005r mov al,[SfxR2+1] ret NEWSYM reg3006r mov al,[SfxR3] ret NEWSYM reg3007r mov al,[SfxR3+1] ret NEWSYM reg3008r mov al,[SfxR4] ret NEWSYM reg3009r mov al,[SfxR4+1] ret NEWSYM reg300Ar mov al,[SfxR5] ret NEWSYM reg300Br mov al,[SfxR5+1] ret NEWSYM reg300Cr mov al,[SfxR6] ret NEWSYM reg300Dr mov al,[SfxR6+1] ret NEWSYM reg300Er mov al,[SfxR7] ret NEWSYM reg300Fr mov al,[SfxR7+1] ret NEWSYM reg3010r mov al,[SfxR8] ret NEWSYM reg3011r mov al,[SfxR8+1] ret NEWSYM reg3012r mov al,[SfxR9] ret NEWSYM reg3013r mov al,[SfxR9+1] ret NEWSYM reg3014r mov al,[SfxR10] ret NEWSYM reg3015r mov al,[SfxR10+1] ret NEWSYM reg3016r mov al,[SfxR11] ret NEWSYM reg3017r mov al,[SfxR11+1] ret NEWSYM reg3018r mov al,[SfxR12] ret NEWSYM reg3019r mov al,[SfxR12+1] ret NEWSYM reg301Ar mov al,[SfxR13] ret NEWSYM reg301Br mov al,[SfxR13+1] ret NEWSYM reg301Cr mov al,[SfxR14] ret NEWSYM reg301Dr mov al,[SfxR14+1] ret NEWSYM reg301Er mov al,[SfxR15] ret NEWSYM reg301Fr mov al,[SfxR15+1] ret ; Other SFX stuff NEWSYM reg3030r AssembleSFXFlags mov al,[SfxSFR] ret NEWSYM reg3031r cmp byte[SfxAC],1 je .alwaysclear cmp dword[ChangeOps],-350*240 jl .noclear .alwaysclear and byte[SfxSFR+1],07fh ; clear IRQ flag jmp .cleared .noclear cmp dword[ChangeOps],-350*240*4 jge .clear mov dword[ChangeOps],-350*240*4 jmp .cleared .clear add dword[ChangeOps],350*240 .cleared mov al,[SfxSFR+1] ret .test db 0 NEWSYM reg3032r ; Unused xor al,al ret NEWSYM reg3033r ; BRAMR Backup Ram Read only on/off (bits 1-15 unused) mov al,[SfxBRAMR] ret NEWSYM reg3034r ; PBR (Program Bank) mov al,[SfxPBR] ret NEWSYM reg3035r ; Unused xor al,al ret NEWSYM reg3036r ; ROMBR (Gamepak Rom Bank Register) mov al,[SfxROMBR] ret NEWSYM reg3037r ; CFGR (Control Flags Register) mov al,[SfxCFGR] ret NEWSYM reg3038r ; SCBR (Screen Bank Register) mov al,[SfxSCBR] ret NEWSYM reg3039r ; CLSR (Clock Speed Register) mov al,[SfxCLSR] ret NEWSYM reg303Ar ; SCMR (Screen Mode Register) mov al,[SfxSCMR] test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov [sfxclineloc],eax ret NEWSYM reg303Br ; VCR (Version Code Register) mov al,20h ret NEWSYM reg303Cr ; RAMBR (Ram bank register) mov al,[SfxRAMBR] ret NEWSYM reg303Dr ; Unused xor al,al ret NEWSYM reg303Er ; CBR (Cache Base Register), lower byte mov al,[SfxCBR] ret NEWSYM reg303Fr ; CBR (Cache Base Register), upper byte mov al,[SfxCBR+1] ret ; SFX Write Registers NEWSYM reg3000w mov [SfxR0],al ret NEWSYM reg3001w mov [SfxR0+1],al ret NEWSYM reg3002w mov [SfxR1],al ret NEWSYM reg3003w mov [SfxR1+1],al ret NEWSYM reg3004w mov [SfxR2],al ret NEWSYM reg3005w mov [SfxR2+1],al ret NEWSYM reg3006w mov [SfxR3],al ret NEWSYM reg3007w mov [SfxR3+1],al ret NEWSYM reg3008w mov [SfxR4],al ret NEWSYM reg3009w mov [SfxR4+1],al ret NEWSYM reg300Aw mov [SfxR5],al ret NEWSYM reg300Bw mov [SfxR5+1],al ret NEWSYM reg300Cw mov [SfxR6],al ret NEWSYM reg300Dw mov [SfxR6+1],al ret NEWSYM reg300Ew mov [SfxR7],al ret NEWSYM reg300Fw mov [SfxR7+1],al ret NEWSYM reg3010w mov [SfxR8],al ret NEWSYM reg3011w mov [SfxR8+1],al ret NEWSYM reg3012w mov [SfxR9],al ret NEWSYM reg3013w mov [SfxR9+1],al ret NEWSYM reg3014w mov [SfxR10],al ret NEWSYM reg3015w mov [SfxR10+1],al ret NEWSYM reg3016w mov [SfxR11],al ret NEWSYM reg3017w mov [SfxR11+1],al ret NEWSYM reg3018w mov [SfxR12],al ret NEWSYM reg3019w mov [SfxR12+1],al ret NEWSYM reg301Aw mov [SfxR13],al ret NEWSYM reg301Bw mov [SfxR13+1],al ret NEWSYM reg301Cw mov [SfxR14],al ret NEWSYM reg301Dw mov [SfxR14+1],al ret NEWSYM reg301Ew mov [SfxR15],al ret NEWSYM reg301Fw mov [SfxR15+1],al ; start execution push edx mov edx,[SfxPBR] mov edx,[SfxMemTable+edx*4] add edx,[SfxR15] mov dl,[edx] mov [SfxPIPE],dl pop edx inc word[SfxR15] or byte[SfxSFR],20h or dword [SfxSFR],08000h ; Set IRQ Flag mov dword[SFXProc],1 ; call StartSFXret ret ; Other SFX stuff NEWSYM reg3030w mov [SfxSFR],al ; mov dh,10 ; Disassemble Flags test al,20h jz .noexec pushad mov dword [NumberOfOpcodes],100 call StartSFX popad .noexec ret NEWSYM reg3031w mov [SfxSFR+1],al ret NEWSYM reg3032w ; Unused ret NEWSYM reg3033w ; BRAMR Backup Ram Read only on/off (bits 1-15 unused) and al,0FEh mov [SfxBRAMR],al ret NEWSYM reg3034w ; PBR (Program Bank) mov [SfxPBR],al xor ebx,ebx mov bl,al mov ebx,[SfxMemTable+ebx*4] mov [SfxCPB],ebx ret NEWSYM reg3035w ; Unused ret NEWSYM reg3036w ; ROMBR (Gamepak Rom Bank Register) mov [SfxROMBR],al xor ebx,ebx mov bl,al mov ebx,[SfxMemTable+ebx*4] mov [SfxCROM],ebx ret NEWSYM reg3037w ; CFGR (Control Flags Register) mov [SfxCFGR],al ret NEWSYM reg3038w ; SCBR (Screen Bank Register) mov [SfxSCBR],al call UpdateSCBRCOLR ret NEWSYM reg3039w ; CLSR (Clock Speed Register) and al,0FEh mov [SfxCLSR],al call UpdateCLSR ret NEWSYM reg303Aw ; SCMR (Screen Mode Register) mov [SfxSCMR],al call UpdatePORSCMR ret NEWSYM reg303Bw ; VCR (Version Code Register) ret NEWSYM reg303Cw ; RAMBR (Ram bank register) mov bl,[SfxnRamBanks] dec bl and al,bl mov ebx,[SfxnRamBanks] dec ebx and eax,ebx mov [SfxRAMBR],eax xor ebx,ebx mov bl,al shl ebx,16 add ebx,[sfxramdata] mov dword [SfxRAMMem],ebx ret NEWSYM reg303Dw ; Unused ret NEWSYM reg303Ew ; CBR (Cache Base Register), lower byte mov [SfxCBR],al ret NEWSYM reg303Fw ; CBR (Cache Base Register), upper byte mov [SfxCBR+1],al ret NEWSYM sfxaccessbankr8 mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx ret NEWSYM sfxaccessbankw8 mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx ret NEWSYM sfxaccessbankr16 mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx ret NEWSYM sfxaccessbankw16 mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx ret NEWSYM sfxaccessbankr8b mov ebx,[sfxramdata] mov al,[ebx+ecx+65536] xor ebx,ebx ret NEWSYM sfxaccessbankw8b mov ebx,[sfxramdata] mov [ebx+ecx+65536],al xor ebx,ebx ret NEWSYM sfxaccessbankr16b mov ebx,[sfxramdata] mov ax,[ebx+ecx+65536] xor ebx,ebx ret NEWSYM sfxaccessbankw16b mov ebx,[sfxramdata] mov [ebx+ecx+65536],ax xor ebx,ebx ret NEWSYM sfxaccessbankr8c mov ebx,[sfxramdata] mov al,[ebx+ecx+65536*2] xor ebx,ebx ret NEWSYM sfxaccessbankw8c mov ebx,[sfxramdata] mov [ebx+ecx+65536*2],al xor ebx,ebx ret NEWSYM sfxaccessbankr16c mov ebx,[sfxramdata] mov ax,[ebx+ecx+65536*2] xor ebx,ebx ret NEWSYM sfxaccessbankw16c mov ebx,[sfxramdata] mov [ebx+ecx+65536*2],ax xor ebx,ebx ret NEWSYM sfxaccessbankr8d mov ebx,[sfxramdata] mov al,[ebx+ecx+65536*3] xor ebx,ebx ret NEWSYM sfxaccessbankw8d mov ebx,[sfxramdata] mov [ebx+ecx+65536*3],al xor ebx,ebx ret NEWSYM sfxaccessbankr16d mov ebx,[sfxramdata] mov ax,[ebx+ecx+65536*3] xor ebx,ebx ret NEWSYM sfxaccessbankw16d mov ebx,[sfxramdata] mov [ebx+ecx+65536*3],ax xor ebx,ebx ret NEWSYM SfxProcAsmEnd zsnes-1.36/src/cfgload.asm0100644000175000017500000011533507432621301015062 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM CMDLineStr,JoyAC,JoyBC,JoyLC,JoyRC,JoySelec,JoyStart EXTSYM JoyXC,JoyYC,LoadDir,LoadDrive,SRAMDrive,mode7tab EXTSYM pl1selk,pl1startk,pl1upk,pl2Ak,pl2Bk,pl2Lk,pl2Rk EXTSYM pl2Xk,pl2Yk,pl2contrl,pl2downk,pl2leftk,pl2rightk EXTSYM pl2selk,pl2startk,pl2upk,DontSavePath EXTSYM Force8b,MusicRelVol,SRAMDir,SoundCompD,SoundQuality EXTSYM StereoSound,antienab,cvidmode,enterpress,frameskip,guioff EXTSYM newengen,per2exec,pl1Ak,pl1Bk,pl1Lk,pl1Rk,pl1Xk,pl1Yk EXTSYM pl1contrl,pl1downk,pl1leftk,pl1rightk,scanlines,soundon EXTSYM spcon,vsyncon,Open_File,Read_File EXTSYM Create_File,Write_File,Close_File %ifdef __LINUX__ ; if TextFile==0, zlib functions aren't used ; useful to save the config file EXTSYM TextFile, InitDir, InitDrive, Change_Dir %endif NEWSYM CfgLoadAsmStart ; [BITS 32] ; [ORG 0] ; .CFG variables SECTION .data NEWSYM cfgsoundon, db 0 NEWSYM cfgSoundQuality, db 2 NEWSYM cfgStereoSound, db 0 NEWSYM cfgguioff, db 0 NEWSYM cfgper2exec, db 100 NEWSYM cfgcvidmode, db 4 NEWSYM cfgscanline, db 0 NEWSYM cfginterp, db 0 NEWSYM cfgenterskip, db 0 NEWSYM cfgforce8b, db 0 NEWSYM cfgloadsdir, db 0 NEWSYM cfgloadgdir, db 0 NEWSYM cfgnewgfx, db 0 NEWSYM cfgvsync, db 0 NEWSYM cfgvolume, db 75 NEWSYM cfgecho, db 0 NEWSYM RevStereo, db 0 NEWSYM JoyStatRead, db 0 NEWSYM pl12s34, db 0 NEWSYM cfgdontsave, db 0 NEWSYM cfgreinittime, db 30 NEWSYM LoadDriveB, db 2 NEWSYM LoadDirB, times 128 db 0 SECTION .text %macro checkitemcfg 3 cmp al,%1 jne %3 mov al,%2 jmp .insertnum %3 %endmacro %macro checkitemcfg2 3 cmp al,%1 jne %3 mov eax,%2 jmp .insertnum2 %3 %endmacro %macro ConvertJoyMapHelp 2 mov cl,[%1] cmp cl,bl ja %%skip or cl,cl jz %%skip add cl,81h mov [%2],cl %%skip %endmacro NEWSYM ConvertJoyMap cmp byte[JoyStatRead],1 je .convert ret .convert call ConvertJoyMap1 call ConvertJoyMap2 ret NEWSYM ConvertJoyMap1 pushad mov al,[pl1contrl] ; Convert if 2,4,6, or sidewinder cmp al,2 jne .no2button mov byte[pl1Bk],83h mov byte[pl1Yk],82h mov byte[pl1upk],0CCh mov byte[pl1downk],0CDh mov byte[pl1leftk],0CEh mov byte[pl1rightk],0CFh .no2button cmp al,3 je .4button xor bl,bl cmp al,4 jne .no4button .4button mov bl,4 .no4button cmp al,5 jne .no6button mov bl,6 .no6button cmp bl,0 je near .nojoy1 ; Convert button data mov byte[pl1upk],0CCh mov byte[pl1downk],0CDh mov byte[pl1leftk],0CEh mov byte[pl1rightk],0CFh ConvertJoyMapHelp JoyStart,pl1startk ConvertJoyMapHelp JoySelec,pl1selk ConvertJoyMapHelp JoyBC,pl1Yk ConvertJoyMapHelp JoyYC,pl1Xk ConvertJoyMapHelp JoyAC,pl1Bk ConvertJoyMapHelp JoyXC,pl1Ak ConvertJoyMapHelp JoyLC,pl1Lk ConvertJoyMapHelp JoyRC,pl1Rk .nojoy1 cmp al,6 jne .nosw mov byte[pl1upk],0D4h mov byte[pl1downk],0D5h mov byte[pl1leftk],0D6h mov byte[pl1rightk],0D7h mov byte[pl1startk],0C8h mov byte[pl1selk],0C9h mov byte[pl1Ak],089h mov byte[pl1Bk],088h mov byte[pl1Xk],08Ch mov byte[pl1Yk],08Bh mov byte[pl1Lk],08Eh mov byte[pl1Rk],08Fh .nosw popad ret NEWSYM ConvertJoyMap2 pushad mov al,[pl2contrl] ; Convert if 2,4,6, or sidewinder ;If pl1contrl=2 and pl2contrl=2, then set pl2 buttons to 3 & 4 cmp al,2 jne .no2button2 cmp byte[pl1contrl],2 je .pl2b2 mov byte[pl2Bk],83h mov byte[pl2Yk],82h mov byte[pl2upk],0CCh mov byte[pl2downk],0CDh mov byte[pl2leftk],0CEh mov byte[pl2rightk],0CFh jmp .finpl2 .pl2b2 mov byte[pl2Bk],85h mov byte[pl2Yk],84h mov byte[pl2upk],0E8h mov byte[pl2downk],0E9h mov byte[pl2leftk],0EAh mov byte[pl2rightk],0EBh .no2button2 .finpl2 cmp al,3 je .4button2 xor bl,bl cmp al,4 jne .no4button2 .4button2 mov bl,4 .no4button2 cmp al,5 jne .no6button2 mov bl,6 .no6button2 cmp bl,0 je near .nojoy2 ; Convert button data mov byte[pl2upk],0CCh mov byte[pl2downk],0CDh mov byte[pl2leftk],0CEh mov byte[pl2rightk],0CFh ConvertJoyMapHelp JoyStart,pl2startk ConvertJoyMapHelp JoySelec,pl2selk ConvertJoyMapHelp JoyBC,pl2Yk ConvertJoyMapHelp JoyYC,pl2Xk ConvertJoyMapHelp JoyAC,pl2Bk ConvertJoyMapHelp JoyXC,pl2Ak ConvertJoyMapHelp JoyLC,pl2Lk ConvertJoyMapHelp JoyRC,pl2Rk .nojoy2 ;If both sidewinder, set pl2 buttons to sw2 cmp al,6 jne near .nosw2 cmp byte[pl1contrl],6 je .pl2sw2 mov byte[pl2upk],0D4h mov byte[pl2downk],0D5h mov byte[pl2leftk],0D6h mov byte[pl2rightk],0D7h mov byte[pl2startk],0C8h mov byte[pl2selk],0C9h mov byte[pl2Ak],089h mov byte[pl2Bk],088h mov byte[pl2Xk],08Ch mov byte[pl2Yk],08Bh mov byte[pl2Lk],08Eh mov byte[pl2Rk],08Fh jmp .nosw2 .pl2sw2 mov byte[pl2upk],0DCh mov byte[pl2downk],0DDh mov byte[pl2leftk],0DEh mov byte[pl2rightk],0DFh mov byte[pl2startk],0D0h mov byte[pl2selk],0D1h mov byte[pl2Ak],091h mov byte[pl2Bk],090h mov byte[pl2Xk],094h mov byte[pl2Yk],093h mov byte[pl2Lk],096h mov byte[pl2Rk],097h mov byte[pl2contrl],7 .nosw2 popad ret NEWSYM DOScreatenewcfg ; make a new file ; copy .cfgfiledata to mode7tab, replacing each % %ifdef __LINUX__ mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir %endif mov esi,.cfgfiledata mov edi,mode7tab xor ecx,ecx mov edx,.cfgfilesize .loop mov al,[esi] cmp al,'%' je .look4item mov [edi],al inc esi inc edi inc ecx dec edx jnz .loop cmp byte[cfgdontsave],1 je .failed push ecx ; Save .CFG file mov edx,CMDLineStr %ifdef __GZIP__ mov byte[TextFile], 1 %endif call Create_File pop ecx jc .failed ; Save 65816 status, etc. mov bx,ax mov edx,mode7tab call Write_File call Close_File %ifdef __GZIP__ mov byte[TextFile], 0 %endif .failed ret .look4item inc esi dec edx mov al,[esi] inc esi dec edx mov byte[.temp],0 mov byte[.temp2],1 mov bl,[frameskip] cmp bl,0 je .yframeskip dec bl mov [.temp],bl mov byte[.temp2],0 .yframeskip checkitemcfg '1', [.temp],.check1 checkitemcfg '2', [.temp2],.check2 checkitemcfg '3', [pl1contrl],.check3 checkitemcfg '4', [pl2contrl],.check4 checkitemcfg2 '5', [pl1rightk],.check5 checkitemcfg2 '6', [pl1leftk],.check6 checkitemcfg2 '7', [pl1downk],.check7 checkitemcfg2 '8', [pl1upk],.check8 checkitemcfg2 '9', [pl1startk],.check9 checkitemcfg2 'A', [pl1selk],.checkA checkitemcfg2 'B', [pl1Bk],.checkB checkitemcfg2 'C', [pl1Yk],.checkC checkitemcfg2 'D', [pl1Ak],.checkD checkitemcfg2 'E', [pl1Xk],.checkE checkitemcfg2 'F', [pl1Lk],.checkF checkitemcfg2 'G', [pl1Rk],.checkG checkitemcfg2 'H', [pl2rightk],.checkH checkitemcfg2 'I', [pl2leftk],.checkI checkitemcfg2 'J', [pl2downk],.checkJ checkitemcfg2 'K', [pl2upk],.checkK checkitemcfg2 'L', [pl2startk],.checkL checkitemcfg2 'M', [pl2selk],.checkM checkitemcfg2 'N', [pl2Bk],.checkN checkitemcfg2 'O', [pl2Yk],.checkO checkitemcfg2 'P', [pl2Ak],.checkP checkitemcfg2 'Q', [pl2Xk],.checkQ checkitemcfg2 'R', [pl2Lk],.checkR checkitemcfg2 'S', [pl2Rk],.checkS checkitemcfg 'T', [cfgper2exec],.checkT checkitemcfg 'U', [cfgcvidmode],.checkU checkitemcfg 'V', [cfgsoundon],.checkV checkitemcfg 'W', [cfgSoundQuality],.checkW checkitemcfg 'X', [cfgStereoSound],.checkX checkitemcfg 'Y', [cfgguioff],.checkY checkitemcfg 'Z', [cfgscanline],.checkZ checkitemcfg 'a', [cfginterp],.checka checkitemcfg 'b', [cfgenterskip],.checkb checkitemcfg 'c', [cfgforce8b],.checkc cmp al,'d' je near .insertdira cmp al,'e' je near .insertdirb checkitemcfg 'f', [JoyStart],.checkf checkitemcfg 'g', [JoySelec],.checkg checkitemcfg 'h', [JoyBC],.checkh checkitemcfg 'i', [JoyYC],.checki checkitemcfg 'j', [JoyAC],.checkj checkitemcfg 'k', [JoyXC],.checkk checkitemcfg 'l', [JoyLC],.checkl checkitemcfg 'm', [JoyRC],.checkm checkitemcfg 'n', [cfgnewgfx],.checkn checkitemcfg 'p', [cfgvsync],.checkp checkitemcfg 'q', [cfgvolume],.checkq checkitemcfg 'r', [cfgecho],.checkr checkitemcfg 's', [RevStereo],.checks checkitemcfg 't', [pl12s34],.checkt checkitemcfg 'u', [cfgdontsave],.checku checkitemcfg 'v', [cfgreinittime],.checkv jmp .loop .temp db 0 .temp2 db 0 .insertnum ; preserve ecx and edx, output al into edi cmp al,0 jne .nozero mov byte[edi],'0' inc edi inc ecx jmp .loop .nozero cmp al,99 ja .digits3 xor ah,ah mov bl,10 div bl add al,48 add ah,48 cmp al,48 jne .digits2 mov byte[edi],ah inc edi inc ecx jmp .loop .digits2 mov byte[edi],al mov byte[edi+1],ah add edi,2 add ecx,2 jmp .loop .digits3 xor ah,ah mov bl,100 div bl add al,48 mov byte[edi],al mov al,ah xor ah,ah mov bl,10 div bl add al,48 add ah,48 mov byte[edi+1],al mov byte[edi+2],ah add edi,3 add ecx,3 jmp .loop .insertnum2 ; preserve ecx and edx, output al into edi cmp eax,0 jne .nozeroi mov byte[edi],'0' inc edi inc ecx jmp .loop .nozeroi cmp eax,99 ja .digits3i xor ah,ah mov bl,10 div bl add al,48 add ah,48 cmp al,48 jne .digits2i mov byte[edi],ah inc edi inc ecx jmp .loop .digits2i mov byte[edi],al mov byte[edi+1],ah add edi,2 add ecx,2 jmp .loop .digits3i mov bl,100 div bl add al,48 mov byte[edi],al mov al,ah xor ah,ah mov bl,10 div bl add al,48 add ah,48 mov byte[edi+1],al mov byte[edi+2],ah add edi,3 add ecx,3 jmp .loop .insertdira cmp byte[cfgloadsdir],1 je .yesloadsdir jmp .loop .yesloadsdir %ifndef __LINUX__ mov al,[SRAMDrive] add al,65 mov [edi],al mov byte[edi+1],':' mov byte[edi+2],'\' add edi,3 add ecx,3 %endif mov ebx,SRAMDir .nextinsertdira mov al,[ebx] cmp al,0 je .nomoredira mov [edi],al inc edi inc ecx inc ebx jmp .nextinsertdira .nomoredira jmp .loop .insertdirb cmp byte[DontSavePath],1 je .insertdirc %ifndef __LINUX__ mov al,[LoadDrive] add al,65 mov [edi],al mov byte[edi+1],':' mov byte[edi+2],'\' add edi,3 add ecx,3 %endif mov ebx,LoadDir .nextinsertdir mov al,[ebx] cmp al,0 je .nomoredir mov [edi],al inc edi inc ecx inc ebx jmp .nextinsertdir .nomoredir jmp .loop .insertdirc %ifndef __LINUX__ mov al,[LoadDriveB] add al,65 mov [edi],al mov byte[edi+1],':' mov byte[edi+2],'\' add edi,3 add ecx,3 %endif mov ebx,LoadDirB .nextinsertdirc mov al,[ebx] cmp al,0 je .nomoredirc mov [edi],al inc edi inc ecx inc ebx jmp .nextinsertdirc .nomoredirc jmp .loop .cfgfiledata db '; ZSNES Configuration file',13,10 db '',13,10 db '; Frame Skip = 0 .. 9',13,10 db '',13,10 db 'FrameSkip = %1',13,10 db '',13,10 db '; Auto Frame Skip = 0 or 1 (1 = ON)',13,10 db '',13,10 db 'AutoFrameSkip = %2',13,10 db '',13,10 db '; Player 1/2 Input Device. Use the GUI to set these values',13,10 db '; NOTE : Using this to select joysticks manually will NOT work!',13,10 db '',13,10 db 'Player1Device = %3',13,10 db 'Player2Device = %4',13,10 db '',13,10 db '; Keyboard Scancodes/Joystick Mappings for Keyboard 1 & 2',13,10 db '; In order of Right, Left, Down, Up, Start, Select, B, Y, A, X, L, R',13,10 db '; Use the GUI to set these values',13,10 db '',13,10 db 'ScanKey1 = %5, %6, %7, %8, %9, %A, %B, %C, %D, %E, %F, %G',13,10 db 'ScanKey2 = %H, %I, %J, %K, %L, %M, %N, %O, %P, %Q, %R, %S',13,10 db '',13,10 db '; Share Player 3 and 4 control inputs with Player 1 and 2 to allow',13,10 db '; 2 devices to be shared on a single player. This feature automatically',13,10 db '; disables MultiTap (Multiplayer 5) support. Set this to 1 to enable.',13,10 db '',13,10 db 'Pl34to12Share = %t',13,10 db '',13,10 db '; Percent to Execute [50 .. 150]',13,10 db '',13,10 db 'Execute = %T',13,10 db '',13,10 %ifdef __WIN32__ db '; Video Mode, 0 - 32',13,10 db '; 0 = 256x224 R WIN 1 = 256x224 R FULL',13,10 db '; 2 = 512x448 R WIN 3 = 512x448 DR WIN',13,10 db '; 4 = 640x480 S WIN 5 = 640x480 DS WIN',13,10 db '; 6 = 640x480 DR FULL 7 = 640x480 DS FULL',13,10 db '; 8 = 640x480 S FULL 9 = 768x672 R WIN',13,10 db '; 10 = 768x672 DR WIN 11 = 800x600 S WIN',13,10 db '; 12 = 800x600 DS WIN 13 = 800x600 S FULL',13,10 db '; 14 = 800x600 DR FULL 15 = 800x600 DS FULL',13,10 db '; 16 = 1024x768 S WIN 17 = 1024x768 DS WIN',13,10 db '; 18 = 1024x768 S FULL 19 = 1024x768 DR FULL',13,10 db '; 20 = 1024x768 DS FULL 21 = 1024x896 R WIN',13,10 db '; 22 = 1024x896 DR WIN 23 = 1280x960 S WIN',13,10 db '; 24 = 1280x960 DS WIN 25 = 1280x960 S FULL',13,10 db '; 26 = 1280x960 DR FULL 27 = 1280x960 DS FULL',13,10 db '; 28 = 1280x1024 S WIN 29 = 1280x1024 DS WIN',13,10 db '; 30 = 1280x1024 S FULL 31 = 1280x1024 DR FULL',13,10 db '; 32 = 1280x1024 DS FULL',13,10 db '',13,10 db 'VideoModeWin = %U',13,10 db '',13,10 %endif %ifdef __LINUX__ %ifdef __OPENGL__ db '; Video Mode, 0 - 15',13,10 %else db '; Video Mode, 0 - 3',13,10 %endif db '; 0 = 256x224 WIN 1 = 256x224 FULL',13,10 db '; 2 = 512x448 WIN 3 = 640x480 FULL',13,10 %ifdef __OPENGL__ db '; 4 = 256x224 OGL WIN 5 = 512x448 OGL WIN',13,10 db '; 6 = 640x480 OGL FULL 7 = 640x576 OGL WIN',13,10 db '; 8 = 768x672 OGL WIN 9 = 896x784 OGL WIN',13,10 db '; 10 = 1024x896 OGL WIN 11 = 800x600 OGL FULL',13,10 db '; 12 = 1024x768 OGL FULL 13 = 640x480 OGL WIN',13,10 db '; 14 = 800x600 OGL WIN 15 = 1024x768 OGL WIN',13,10 db '; 16 = VARIABLE OGL WIN',13,10 %endif db '',13,10 db 'VideoModeLin = %U',13,10 db '',13,10 %endif %ifdef __MSDOS__ db '; Video Mode, 0 - 18',13,10 db '; 0 = 256x224x8B (MODEQ) 1 = 256x240x8B (MODEQ)',13,10 db '; 2 = 256x256x8B (MODEQ) 3 = 320x224x8B (MODEX)',13,10 db '; 4 = 320x240x8B (MODEX) 5 = 320x256x8B (MODEX)',13,10 db '; 6 = 640x480x16B (VESA1) 7 = 320x240x8B (VESA2)',13,10 db '; 8 = 320x240x16B (VESA2) 9 = 320x480x8B (VESA2)',13,10 db '; 10 = 320x480x16B (VESA2) 11 = 512x384x8B (VESA2)',13,10 db '; 12 = 512x384x16B (VESA2) 13 = 640x400x8B (VESA2)',13,10 db '; 14 = 640x400x16B (VESA2) 15 = 640x480x8B (VESA2)',13,10 db '; 16 = 640x480x16B (VESA2) 17 = 800x600x8B (VESA2)',13,10 db '; 18 = 800x600x16B (VESA2)',13,10 db '',13,10 db 'VideoModeDos = %U',13,10 db '',13,10 %endif db '; Sound Emulation = 0 or 1 (1 = ON)',13,10 db '',13,10 db 'Sound = %V',13,10 db '',13,10 db '; Sound Sampling Rate',13,10 db '; 0 = 8,000 Hz, 1 = 11,025 Hz, 2 = 22,050 Hz',13,10 db '; 3 = 44,100 Hz, 4 = 16,000 Hz, 5 = 32,000 Hz',13,10 db '',13,10 db 'SoundRate = %W',13,10 db '',13,10 db '; Stereo (0 = off, 1 = on)',13,10 db '',13,10 db 'Stereo = %X',13,10 db '',13,10 db '; Stereo Reversed. Swaps left channel with right. (0 = off, 1 = L <-> R)',13,10 db '',13,10 db 'ReverseStereo = %s',13,10 db '',13,10 %ifdef __MSDOS__ db '; GUI Disable (1 = Disable GUI, 0 = Enable GUI)',13,10 db '',13,10 db 'GUIDisable = %Y',13,10 db '',13,10 %endif db '; New Graphics Engine (1 = Enable, 0 = Disable)',13,10 %ifdef __MSDOS__ db '; All 256 color modes and 320x240x65536 supported',13,10 %endif db '',13,10 db 'NewGfx = %n',13,10 db '',13,10 db '; Scanlines (0 = Disable, 1 = Full, 2 = 25%, 3 = 50%)',13,10 %ifdef __MSDOS__ db '; 256x256x256 or 640x480 modes only (25% and 50% in 640x480x65536 mode only)',13,10 %endif db '',13,10 db 'Scanlines = %Z',13,10 db '',13,10 %ifdef __MSDOS__ db '; Interpolation (1 = Enable, 0 = Disable) - 640x480x65536 mode only',13,10 db '; This option also Enables EAGLE - 640x480x256 mode only',13,10 %else db '; Interpolation (1 = Enable, 0 = Disable)',13,10 %endif db '',13,10 db 'Interpolation = %a',13,10 db '',13,10 %ifndef __LINUX__ db '; VSync (1 = Enable, 0 = Disable) - Wait for Vertical Sync (Fast cpu reqd)',13,10 db '',13,10 db 'VSync = %p',13,10 db '',13,10 %endif %ifdef __MSDOS__ db '; Skip Enter Press at Beginning (1 = Yes, 0 = No)',13,10 db '',13,10 db 'EnterSkip = %b',13,10 db '',13,10 db '; Force 8-bit sound on (1 = Yes, 0 = No)',13,10 db '',13,10 db 'Force8bit = %c',13,10 db '',13,10 %endif db '; Disable Echo (1 = Yes, 0 = No)',13,10 db '',13,10 db 'EchoDisable = %r',13,10 db '',13,10 db '; Sound Volume Level (0 .. 100)',13,10 db '; Note : Setting this too high can cause sound overflow which degrades quality',13,10 db '',13,10 db 'Volume = %q',13,10 db '',13,10 db '; Set this to 1 if you do not want ZSNES to save the configuration files.',13,10 db '',13,10 db 'DontSave = %u',13,10 db '',13,10 db '; Savefile directory. Leave it blank if you want the save files to be in the',13,10 db '; same directory as the games. It should be in a format like : C:\dir\dir',13,10 db '',13,10 db 'SaveDirectory = %d',13,10 db '',13,10 db '; Game directory. This is the directory where the GUI starts at.',13,10 db '; ZSNES automatically writes the current directory here upon exit.',13,10 db '',13,10 db 'GameDirectory = %e',13,10 .cfgfilesize equ $-.cfgfiledata NEWSYM getcfg mov byte[.forceauto],0 ; open file mov edx,CMDLineStr call Open_File jc .failed mov [.fileloc],ax mov byte[.eofile],0 .noteof call .readstring cmp dword[.stralen],1 jbe .skipstpr call .splitstring .skipstpr cmp byte[.eofile],0 je .noteof mov bx,[.fileloc] call Close_File ret .failed call DOScreatenewcfg ret .readstring: mov dword[.strlen],0 mov dword[.stralen],0 mov byte[.ignore],0 .startloop mov bx,[.fileloc] mov ecx,1 mov edx,.cchar call Read_File cmp eax,0 je .endoffile cmp byte[.cchar],';' je .comment cmp byte[.cchar],13 je .eoline cmp byte[.cchar],10 je .startloop mov ecx,[.strlen] mov al,[.cchar] cmp ecx,127 ja .nocopy cmp byte[.ignore],1 je .nocopy mov [.string+ecx],al inc dword[.stralen] .nocopy inc dword[.strlen] jmp .startloop ret .comment inc dword[.strlen] mov byte[.ignore],1 jmp .startloop ret .eoline ret .endoffile mov byte[.eofile],1 ret .splitstring: ; search for ='s mov ecx,[.stralen] dec ecx xor eax,eax xor ebx,ebx .next cmp byte[.string+eax],'=' jne .noeq inc ebx .noeq inc eax dec ecx jnz .next cmp ebx,1 je .onequal ret .onequal xor eax,eax xor ebx,ebx mov ecx,[.stralen] mov dword[.strlena],0 mov dword[.strlenb],0 .loopa mov dl,[.string+eax] cmp dl,'=' je .nextb cmp dl,' ' je .skipcopy cmp dl,'a' jb .nocapneeded cmp dl,'z' ja .nocapneeded sub dl,'a'-'A' .nocapneeded mov [.stringa+ebx],dl inc dword[.strlena] inc ebx .skipcopy inc eax dec ecx jnz .loopa ret .nextb inc eax dec ecx jnz .noblank .yesblank ret .noblank xor ebx,ebx mov byte[.usespace],0 .loopb mov dl,[.string+eax] cmp byte[.usespace],0 jne .nospaceskip cmp dl,' ' je .skipcopyb .nospaceskip %ifndef __LINUX__ cmp dl,'a' jb .nocapneededb cmp dl,'z' ja .nocapneededb sub dl,'a'-'A' %endif .nocapneededb mov byte[.usespace],1 mov [.stringb+ebx],dl inc dword[.strlenb] inc ebx .skipcopyb inc eax dec ecx jnz .loopb cmp dword[.strlena],0 je .nostr cmp dword[.strlenb],0 je .nostr jmp .process .nostr ret .process mov ecx,[.strlena] cmp ecx,[.stra] jne .nostra mov edx,.stra+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostra call .getframeskip .nostra mov ecx,[.strlena] cmp ecx,[.strb] jne .nostrb mov edx,.strb+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrb call .getautoframeskip .nostrb mov ecx,[.strlena] cmp ecx,[.strc] jne .nostrc mov edx,.strc+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrc call .getplayer1device .nostrc mov ecx,[.strlena] cmp ecx,[.strd] jne .nostrd mov edx,.strd+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrd call .getplayer2device .nostrd mov ecx,[.strlena] cmp ecx,[.stre] jne .nostre mov edx,.stre+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostre call .getscankey1 .nostre mov ecx,[.strlena] cmp ecx,[.strf] jne .nostrf mov edx,.strf+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrf call .getscankey2 .nostrf mov ecx,[.strlena] cmp ecx,[.strg] jne .nostrg mov edx,.strg+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrg call .getsound .nostrg mov ecx,[.strlena] cmp ecx,[.strh] jne .nostrh mov edx,.strh+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrh call .getsoundrate .nostrh mov ecx,[.strlena] cmp ecx,[.stri] jne .nostri mov edx,.stri+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostri call .getvideo .nostri mov ecx,[.strlena] cmp ecx,[.strj] jne .nostrj mov edx,.strj+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrj call .getexecute .nostrj mov ecx,[.strlena] cmp ecx,[.strk] jne .nostrk mov edx,.strk+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrk call .getbufdisable .nostrk mov ecx,[.strlena] cmp ecx,[.strm] jne .nostrm mov edx,.strm+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrm call .getstereo .nostrm mov ecx,[.strlena] cmp ecx,[.strn] jne .nostrn mov edx,.strn+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrn call .guidisable .nostrn mov ecx,[.strlena] cmp ecx,[.stro] jne .nostro mov edx,.stro+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostro call .scanlines .nostro mov ecx,[.strlena] cmp ecx,[.strp] jne .nostrp mov edx,.strp+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrp call .interpolation .nostrp mov ecx,[.strlena] cmp ecx,[.strq] jne .nostrq mov edx,.strq+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrq call .enterskip .nostrq mov ecx,[.strlena] cmp ecx,[.strr] jne .nostrr mov edx,.strr+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrr call .force8b .nostrr mov ecx,[.strlena] cmp ecx,[.strs] jne .nostrs mov edx,.strs+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrs call .getsavedir .nostrs mov ecx,[.strlena] cmp ecx,[.strt] jne .nostrt mov edx,.strt+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrt call .getloaddir .nostrt mov ecx,[.strlena] cmp ecx,[.stru] jne .nostru mov edx,.stru+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostru call .getjoymapping .nostru mov ecx,[.strlena] cmp ecx,[.strv] jne .nostrv mov edx,.strv+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrv call .getnewgfx .nostrv mov ecx,[.strlena] cmp ecx,[.strw] jne .nostrw mov edx,.strw+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrw call .getvsync .nostrw mov ecx,[.strlena] cmp ecx,[.strx] jne .nostrx mov edx,.strx+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrx call .getvolume .nostrx mov ecx,[.strlena] cmp ecx,[.stry] jne .nostry mov edx,.stry+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostry call .getecho .nostry mov ecx,[.strlena] cmp ecx,[.strz] jne .nostrz mov edx,.strz+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostrz call .getreverses .nostrz mov ecx,[.strlena] cmp ecx,[.str1] jne .nostr1 mov edx,.str1+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostr1 call .getplay1234 .nostr1 mov ecx,[.strlena] cmp ecx,[.str2] jne .nostr2 mov edx,.str2+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostr2 call .getdontsave .nostr2 mov ecx,[.strlena] cmp ecx,[.str3] jne .nostr3 mov edx,.str3+4 mov eax,.stringa call .cmpstr cmp bl,1 je .nostr3 call .getreinit .nostr3 ret .cmpstr xor bl,bl .loopcmp mov bh,[eax] cmp [edx],bh jne .nocmp inc eax inc edx dec ecx jnz .loopcmp ret .nocmp mov bl,1 ret .getframeskip cmp dword[.strlenb],1 jne .noframeskip mov al,[.stringb] cmp al,'0' jb .noframeskip cmp al,'9' ja .noframeskip cmp byte[.forceauto],1 je .noframeskip sub al,47 mov [frameskip],al .noframeskip ret .getautoframeskip cmp dword[.strlenb],1 jne .noautoframeskip cmp byte[.stringb],'1' jne .noautoframeskip mov byte[.forceauto],1 mov byte[frameskip],0 .noautoframeskip ret .getplayer1device cmp dword[.strlenb],2 je .double cmp dword[.strlenb],1 jne .noplay1 mov al,[.stringb] cmp al,'0' jb .noplay1 cmp al,'9' ja .noplay1 sub al,48 mov [pl1contrl],al .noplay1 ret .double mov al,[.stringb] cmp al,'1' jne .noplay1 mov al,[.stringb+1] cmp al,'0' jb .noplay1 cmp al,'8' ja .noplay1 sub al,38 mov [pl1contrl],al ret .getplayer2device cmp dword[.strlenb],2 je .double2 cmp dword[.strlenb],1 jne .noplay2 mov al,[.stringb] cmp al,'0' jb .noplay2 cmp al,'9' ja .noplay2 sub al,48 mov [pl2contrl],al .noplay2 ret .double2 mov al,[.stringb] cmp al,'1' jne .noplay2 mov al,[.stringb+1] cmp al,'0' jb .noplay2 cmp al,'8' ja .noplay2 sub al,38 mov [pl2contrl],al ret .getscankey1 mov ecx,.stringb xor ebx,ebx xor eax,eax .checknextscan1 cmp dword[.strlenb],0 je near .noscankey1 mov bl,[ecx] inc ecx dec dword[.strlenb] cmp bl,',' je near .finstr1 cmp bl,'0' jb near .nextstr1 cmp bl,'9' ja near .nextstr1 sub bl,48 push ebx mov ebx,10 mul ebx pop ebx mov edx,ebx and edx,0FFh add eax,edx cmp dword[.strlenb],0 je near .finstr1 jmp .nextstr1 .finstr1 ; determine which variable according to bh & write ; In order of Right, Left, Down, Up, Start, Select, A, B, X, Y, L, R cmp bh,0 jne .nextaa mov [pl1rightk],eax .nextaa cmp bh,1 jne .nextba mov [pl1leftk],eax .nextba cmp bh,2 jne .nextca mov [pl1downk],eax .nextca cmp bh,3 jne .nextda mov [pl1upk],eax .nextda cmp bh,4 jne .nextea mov [pl1startk],eax .nextea cmp bh,5 jne .nextfa mov [pl1selk],eax .nextfa cmp bh,6 jne .nextga mov [pl1Bk],eax .nextga cmp bh,7 jne .nextha mov [pl1Yk],eax .nextha cmp bh,8 jne .nextia mov [pl1Ak],eax .nextia cmp bh,9 jne .nextja mov [pl1Xk],eax .nextja cmp bh,10 jne .nextka mov [pl1Lk],eax .nextka cmp bh,11 jne .nextla mov [pl1Rk],eax .nextla xor eax,eax inc bh .nextstr1 jmp .checknextscan1 .noscankey1 ret .getscankey2 mov ecx,.stringb xor ebx,ebx xor eax,eax .checknextscan2 cmp dword[.strlenb],0 je near .noscankey2 mov bl,[ecx] inc ecx dec dword[.strlenb] cmp bl,',' je near .finstr2 cmp bl,'0' jb near .nextstr2 cmp bl,'9' ja near .nextstr2 sub bl,48 push ebx mov ebx,10 mul ebx pop ebx mov edx,ebx and edx,0FFh add eax,edx cmp dword[.strlenb],0 je near .finstr2 jmp .nextstr2 .finstr2 ; determine which variable according to bh & write ; In order of Right, Left, Down, Up, Start, Select, A, B, X, Y, L, R cmp bh,0 jne .nextaa2 mov [pl2rightk],eax .nextaa2 cmp bh,1 jne .nextba2 mov [pl2leftk],eax .nextba2 cmp bh,2 jne .nextca2 mov [pl2downk],eax .nextca2 cmp bh,3 jne .nextda2 mov [pl2upk],eax .nextda2 cmp bh,4 jne .nextea2 mov [pl2startk],eax .nextea2 cmp bh,5 jne .nextfa2 mov [pl2selk],eax .nextfa2 cmp bh,6 jne .nextga2 mov [pl2Bk],eax .nextga2 cmp bh,7 jne .nextha2 mov [pl2Yk],eax .nextha2 cmp bh,8 jne .nextia2 mov [pl2Ak],eax .nextia2 cmp bh,9 jne .nextja2 mov [pl2Xk],eax .nextja2 cmp bh,10 jne .nextka2 mov [pl2Lk],eax .nextka2 cmp bh,11 jne .nextla2 mov [pl2Rk],eax .nextla2 xor eax,eax inc bh .nextstr2 jmp .checknextscan2 .noscankey2 ret .getsound cmp dword[.strlenb],1 jne .nosound mov al,[.stringb] cmp al,'1' jne .nosound mov byte[spcon],1 ; SPC Enabled mov byte[soundon],1 mov byte[cfgsoundon],1 .nosound ret .getsoundrate cmp dword[.strlenb],1 jne .nosoundrate mov al,[.stringb] cmp al,'0' jb .nosoundrate cmp al,'6' ja .nosoundrate sub al,48 mov [SoundQuality],al mov [cfgSoundQuality],al .nosoundrate ret .getvideo cmp dword[.strlenb],2 je .videob cmp dword[.strlenb],1 jne .novideo mov al,[.stringb] cmp al,'0' jb .novideo cmp al,'9' ja .novideo sub al,48 mov [cvidmode],al mov [cfgcvidmode],al .novideo ret .videob cmp byte[.stringb],'1' jne .novideo2 mov al,[.stringb+1] sub al,38 mov [cvidmode],al mov [cfgcvidmode],al ret .novideo2 cmp byte[.stringb],'2' jne .novideo3 mov al,[.stringb+1] sub al,28 mov [cvidmode],al mov [cfgcvidmode],al ret .novideo3 cmp byte[.stringb],'3' jne .novideo mov al,[.stringb+1] sub al,18 mov [cvidmode],al mov [cfgcvidmode],al ret .getexecute cmp dword[.strlenb],0 je .noexecute mov cl,[.strlenb] mov esi,.stringb mov byte[.per2exec],0 .getnextperc mov bl,10 mov al,[.per2exec] cmp al,100 jae .noexecute mul bl mov [.per2exec],al mov al,[esi] cmp al,'0' jb .noexecute cmp al,'9' ja .noexecute sub al,48 add [.per2exec],al inc esi ; next character dec cl jz .nonextperc jmp .getnextperc .nonextperc cmp byte[.per2exec],150 ja .noexecute cmp byte[.per2exec],50 jb .noexecute mov al,[.per2exec] mov [per2exec],al mov [cfgper2exec],al .noexecute ret .getreinit cmp dword[.strlenb],0 je .nogetreinit mov cl,[.strlenb] mov esi,.stringb mov byte[.per2exec],0 .getnextgetreinit mov bl,10 mov al,[.per2exec] cmp al,100 jae .nogetreinit mul bl mov [.per2exec],al mov al,[esi] cmp al,'0' jb .nogetreinit cmp al,'9' ja .nogetreinit sub al,48 add [.per2exec],al inc esi ; next character dec cl jz .nonextgetreinit jmp .getnextgetreinit .nonextgetreinit cmp byte[.per2exec],150 ja .nogetreinit cmp byte[.per2exec],5 jb .nogetreinit mov al,[.per2exec] mov [cfgreinittime],al .nogetreinit ret .getbufdisable cmp dword[.strlenb],1 jne .nobufdisable cmp byte[.stringb],'1' jne .nobufdisable mov byte[SoundCompD],1 .nobufdisable ret .getstereo cmp dword[.strlenb],1 jne .nostereo cmp byte[.stringb],'1' jne .nostereo mov byte[StereoSound],1 mov byte[cfgStereoSound],1 .nostereo ret .guidisable cmp dword[.strlenb],1 jne .noguidisable cmp byte[.stringb],'1' jne .noguidisable mov byte[guioff],1 mov byte[cfgguioff],1 .noguidisable ret .scanlines cmp dword[.strlenb],1 jne .noscanlines cmp byte[.stringb],'1' jne .noscanlines mov byte[scanlines],1 mov byte[cfgscanline],1 .noscanlines cmp byte[.stringb],'2' jne .noscanlinesh2 mov byte[scanlines],2 mov byte[cfgscanline],2 .noscanlinesh2 cmp byte[.stringb],'3' jne .noscanlinesh3 mov byte[scanlines],3 mov byte[cfgscanline],3 .noscanlinesh3 ret .interpolation cmp dword[.strlenb],1 jne .nointerpolation cmp byte[.stringb],'1' jne .nointerpolation mov byte[antienab],1 mov byte[cfginterp],1 .nointerpolation ret .enterskip cmp dword[.strlenb],1 jne .noenterskip cmp byte[.stringb],'1' jne .noenterskip mov byte[enterpress],1 mov byte[cfgenterskip],1 .noenterskip ret .force8b cmp dword[.strlenb],1 jne .noforce8b cmp byte[.stringb],'1' jne .noforce8b mov byte[Force8b],1 mov byte[cfgforce8b],1 .noforce8b ret .getsavedir cmp dword[.strlenb],3 jb .nosavedir %ifndef __LINUX__ cmp byte[.stringb+1],':' jne .nosavedir cmp byte[.stringb+2],'\' jne .nosavedir mov byte[cfgloadsdir],1 mov al,[.stringb] sub al,65 mov [SRAMDrive],al %else mov byte[cfgloadsdir],1 %endif push ecx push esi push edi mov ecx,[.strlenb] %ifndef __LINUX__ sub ecx,3 mov esi,.stringb+3 %else mov esi,.stringb %endif mov edi,SRAMDir cmp ecx,0 je .ndird .ndirc mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .ndirc .ndird mov byte[edi],0 pop edi pop esi pop ecx .nosavedir ret .getloaddir cmp dword[.strlenb],3 jb .noloaddir %ifndef __LINUX__ cmp byte[.stringb+1],':' jne .noloaddir cmp byte[.stringb+2],'\' jne .noloaddir mov byte[cfgloadgdir],1 mov al,[.stringb] sub al,65 mov [LoadDrive],al mov [LoadDriveB],al %else mov byte[cfgloadgdir],1 %endif push ecx push esi push edi push ebx mov ecx,[.strlenb] %ifndef __LINUX__ sub ecx,3 mov esi,.stringb+3 %else mov esi,.stringb %endif mov edi,LoadDir mov ebx,LoadDirB cmp ecx,0 je .ndirb .ndir mov al,[esi] mov [edi],al mov [ebx],al inc esi inc edi inc ebx dec ecx jnz .ndir .ndirb mov byte[edi],0 pop ebx pop edi pop esi pop ecx .noloaddir ret .getjoymapping mov byte[JoyStatRead],1 mov ecx,.stringb xor ebx,ebx xor eax,eax .checknextscan3 cmp dword[.strlenb],0 je near .noscankey3 mov bl,[ecx] inc ecx dec dword[.strlenb] cmp bl,',' je near .finstr3 cmp bl,'0' jb near .nextstr3 cmp bl,'9' ja near .nextstr3 sub bl,48 mov dl,10 mul dl add al,bl cmp dword[.strlenb],0 je near .finstr3 jmp .nextstr3 .finstr3 ; determine which variable according to bh & write ; In order of Start, Select, B, Y, A, X, L, R cmp bh,0 jne .nextaa3 mov byte[JoyStart],al .nextaa3 cmp bh,1 jne .nextba3 mov byte[JoySelec],al .nextba3 cmp bh,2 jne .nextca3 mov byte[JoyBC],al .nextca3 cmp bh,3 jne .nextda3 mov byte[JoyYC],al .nextda3 cmp bh,4 jne .nextea3 mov byte[JoyAC],al .nextea3 cmp bh,5 jne .nextfa3 mov byte[JoyXC],al .nextfa3 cmp bh,6 jne .nextga3 mov byte[JoyLC],al .nextga3 cmp bh,7 jne .nextha3 mov byte[JoyRC],al .nextha3 xor eax,eax inc bh .nextstr3 jmp .checknextscan3 .noscankey3 ret .getnewgfx cmp dword[.strlenb],1 jne .nonewgfx cmp byte[.stringb],'1' jne .nonewgfx mov byte[newengen],1 mov byte[cfgnewgfx],1 .nonewgfx ret .getvsync cmp dword[.strlenb],1 jne .novsync cmp byte[.stringb],'1' jne .novsync mov byte[vsyncon],1 mov byte[cfgvsync],1 .novsync ret .getecho cmp dword[.strlenb],1 jne .nodecho cmp byte[.stringb],'1' jne .nodecho mov byte[cfgecho],1 .nodecho ret .getplay1234 cmp dword[.strlenb],1 jne .nop1234 cmp byte[.stringb],'1' jne .nop1234 mov byte[pl12s34],1 .nop1234 ret .getdontsave cmp dword[.strlenb],1 jne .nodontsave cmp byte[.stringb],'1' jne .nodontsave mov byte[cfgdontsave],1 .nodontsave ret .getreverses cmp dword[.strlenb],1 jne .nors cmp byte[.stringb],'1' jne .nors mov byte[RevStereo],1 .nors ret .getvolume cmp dword[.strlenb],0 je .novolume mov cl,[.strlenb] mov esi,.stringb mov byte[.volume],0 .getnextvol mov bl,10 mov al,[.volume] cmp al,100 jae .novolume mul bl mov [.volume],al mov al,[esi] cmp al,'0' jb .novolume cmp al,'9' ja .novolume sub al,48 add [.volume],al inc esi ; next character dec cl jz .nonextvol jmp .getnextvol .nonextvol cmp byte[.volume],100 ja .novolume mov al,[.volume] mov [MusicRelVol],al mov [cfgvolume],al .novolume ret SECTION .data .per2exec db 0 .volume db 0 .fileloc dw 0 .eofile db 0 .ignore db 0 .strlen dd 0 .stralen dd 0 ; actual string length .strlena dd 0 .strlenb dd 0 .cchar db 0 .forceauto db 0 .string times 128 db 0 ; full string .stringa times 128 db 0 .stringb times 128 db 0 .cfgfname db 'zsnes.cfg',0 .stra dd 9 db 'FRAMESKIP' .strb dd 13 db 'AUTOFRAMESKIP' .strc dd 13 db 'PLAYER1DEVICE' .strd dd 13 db 'PLAYER2DEVICE' .stre dd 8 db 'SCANKEY1' .strf dd 8 db 'SCANKEY2' .strg dd 5 db 'SOUND' .strh dd 9 db 'SOUNDRATE' %ifdef __WIN32__ .stri dd 12 db 'VIDEOMODEWIN' %endif %ifdef __LINUX__ .stri dd 12 db 'VIDEOMODELIN' %endif %ifdef __MSDOS__ .stri dd 12 db 'VIDEOMODEDOS' %endif .strj dd 7 db 'EXECUTE' .strk dd 15 db 'SOUNDBUFDISABLE' .strm dd 6 db 'STEREO' .strn dd 10 db 'GUIDISABLE' .stro dd 9 db 'SCANLINES' .strp dd 13 db 'INTERPOLATION' .strq dd 9 db 'ENTERSKIP' .strr dd 9 db 'FORCE8BIT' .strs dd 13 db 'SAVEDIRECTORY' .strt dd 13 db 'GAMEDIRECTORY' .stru dd 7 db 'JOYMAP1' .strv dd 6 db 'NEWGFX' .strw dd 5 db 'VSYNC' .strx dd 6 db 'VOLUME' .stry dd 11 db 'ECHODISABLE' .strz dd 13 db 'REVERSESTEREO' .str1 dd 13 db 'PL34TO12SHARE' .str2 dd 8 db 'DONTSAVE' .str3 dd 10 db 'REINITTIME' .usespace db 0 SECTION .text NEWSYM CfgLoadAsmEnd zsnes-1.36/src/endmem.asm0100644000175000017500000001475507432554440014745 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" NEWSYM EndMemAsmStart NEWSYM romdatahere ; Much of this used to be in uninitialized space, until I discovered that ; ZSNES was unstable because of them... Odd. Stuff db 'ZSNES v?.??? / free software, programmed by zsKnight, _Demo_, and Pharos',13,10,0 SECTION .bss ALIGN32 NEWSYM wramdataa, resb 65536 NEWSYM ram7fa, resb 65536 NEWSYM Inbetweendat, resd 4 NEWSYM opcjmptab, resd 256 NEWSYM Bank0datr8 , resd 256 NEWSYM Bank0datr16, resd 256 NEWSYM Bank0datw8 , resd 256 NEWSYM Bank0datw16, resd 256 NEWSYM tableA, resd 256 NEWSYM tableB, resd 256 NEWSYM tableC, resd 256 NEWSYM tableD, resd 256 NEWSYM tableE, resd 256 NEWSYM tableF, resd 256 NEWSYM tableG, resd 256 NEWSYM tableH, resd 256 NEWSYM tableAb, resd 256 NEWSYM tableBb, resd 256 NEWSYM tableCb, resd 256 NEWSYM tableDb, resd 256 NEWSYM tableEb, resd 256 NEWSYM tableFb, resd 256 NEWSYM tableGb, resd 256 NEWSYM tableHb, resd 256 NEWSYM tableAc, resd 256 NEWSYM tableBc, resd 256 NEWSYM tableCc, resd 256 NEWSYM tableDc, resd 256 NEWSYM tableEc, resd 256 NEWSYM tableFc, resd 256 NEWSYM tableGc, resd 256 NEWSYM tableHc, resd 256 NEWSYM SA1tableA, resd 256 NEWSYM SA1tableB, resd 256 NEWSYM SA1tableC, resd 256 NEWSYM SA1tableD, resd 256 NEWSYM SA1tableE, resd 256 NEWSYM SA1tableF, resd 256 NEWSYM SA1tableG, resd 256 NEWSYM SA1tableH, resd 256 NEWSYM tablead, resd 256 NEWSYM tableadb, resd 256 NEWSYM tableadc, resd 256 NEWSYM SA1tablead, resd 256 NEWSYM memtabler8, resd 256 NEWSYM memtablew8, resd 256 NEWSYM memtabler16, resd 256 NEWSYM memtablew16, resd 256 NEWSYM vidmemch2, resb 4096 NEWSYM vidmemch4, resb 4096 NEWSYM vidmemch8, resb 4096 NEWSYM snesmmap, resd 256 NEWSYM snesmap2, resd 256 NEWSYM cachebg1, resb 64 NEWSYM cachebg2, resb 64 NEWSYM cachebg3, resb 64 NEWSYM cachebg4, resb 64 NEWSYM sprlefttot, resb 256 NEWSYM sprleftpr, resb 256 NEWSYM sprleftpr1, resb 256 NEWSYM sprleftpr2, resb 256 NEWSYM sprleftpr3, resb 256 NEWSYM sprpriodata, resb 288 NEWSYM sprprtabc, resb 64 NEWSYM sprprtabu, resb 64 NEWSYM prevpal, resw 256 ; previous palette buffer NEWSYM winbgdata, resb 288 ; window buffer for backgrounds NEWSYM winspdata, resb 288 ; window buffer for sprites NEWSYM FxTable, resd 256 NEWSYM FxTableA1, resd 256 NEWSYM FxTableA2, resd 256 NEWSYM FxTableA3, resd 256 NEWSYM FxTableb, resd 256 NEWSYM FxTablebA1, resd 256 NEWSYM FxTablebA2, resd 256 NEWSYM FxTablebA3, resd 256 NEWSYM FxTablec, resd 256 NEWSYM FxTablecA1, resd 256 NEWSYM FxTablecA2, resd 256 NEWSYM FxTablecA3, resd 256 NEWSYM FxTabled, resd 256 NEWSYM FxTabledA1, resd 256 NEWSYM FxTabledA2, resd 256 NEWSYM FxTabledA3, resd 256 NEWSYM SfxMemTable, resd 256 NEWSYM fxxand, resd 256 NEWSYM fxbit01, resd 256 NEWSYM fxbit23, resd 256 NEWSYM fxbit45, resd 256 NEWSYM fxbit67, resd 256 NEWSYM PLOTJmpa, resd 64 NEWSYM PLOTJmpb, resd 64 NEWSYM pal16b, resd 256 NEWSYM pal16bcl, resd 256 NEWSYM pal16bclha, resd 256 NEWSYM pal16bxcl, resd 256 NEWSYM xtravbuf, resb 576 NEWSYM BG1SXl, resw 256 NEWSYM BG2SXl, resw 256 NEWSYM BG3SXl, resw 256 NEWSYM BG4SXl, resw 256 NEWSYM BG1SYl, resw 256 NEWSYM BG2SYl, resw 256 NEWSYM BG3SYl, resw 256 NEWSYM BG4SYl, resw 256 NEWSYM BGMA, resb 256 NEWSYM BGFB, resb 256 NEWSYM BG3PRI, resb 256 NEWSYM BGOPT1, resw 256 NEWSYM BGOPT2, resw 256 NEWSYM BGOPT3, resw 256 NEWSYM BGOPT4, resw 256 NEWSYM BGPT1, resw 256 NEWSYM BGPT2, resw 256 NEWSYM BGPT3, resw 256 NEWSYM BGPT4, resw 256 NEWSYM BGPT1X, resw 256 NEWSYM BGPT2X, resw 256 NEWSYM BGPT3X, resw 256 NEWSYM BGPT4X, resw 256 NEWSYM BGPT1Y, resw 256 NEWSYM BGPT2Y, resw 256 NEWSYM BGPT3Y, resw 256 NEWSYM BGPT4Y, resw 256 NEWSYM BGMS1, resw 1024 NEWSYM prdata, resb 256 NEWSYM prdatb, resb 256 NEWSYM prdatc, resb 256 NEWSYM ngpalcon2b, resd 20h NEWSYM ngpalcon4b, resd 20h NEWSYM ngpalcon8b, resd 20h NEWSYM tltype2b, resb 4096 NEWSYM tltype4b, resb 2048 NEWSYM tltype8b, resb 1024 NEWSYM ngptrdat, resd 1024 NEWSYM ngceax, resd 1024 NEWSYM ngcedi, resd 1024 NEWSYM bgtxad, resw 1024 NEWSYM sprtbng, resd 256 NEWSYM sprtlng, resb 256 NEWSYM mosszng, resb 256 NEWSYM mosenng, resb 256 SECTION .data NEWSYM vidmemch2s, times 4096 db 0FFh NEWSYM vidmemch4s, times 2048 db 0FFh NEWSYM vidmemch8s, times 1024 db 0FFh SECTION .bss NEWSYM mode7ab, resd 256 NEWSYM mode7cd, resd 256 NEWSYM mode7xy, resd 256 NEWSYM mode7st, resb 256 NEWSYM t16x161, resb 256 NEWSYM t16x162, resb 256 NEWSYM t16x163, resb 256 NEWSYM t16x164, resb 256 NEWSYM intrlng, resb 256 NEWSYM mode7hr, resb 256 NEWSYM scadsng, resb 256 NEWSYM scadtng, resb 256 NEWSYM scbcong, resw 256 NEWSYM cpalval, resd 256 NEWSYM cgfxmod, resb 256 NEWSYM winboundary, resd 256 NEWSYM winbg1enval, resb 256 NEWSYM winbg2enval, resb 256 NEWSYM winbg3enval, resb 256 NEWSYM winbg4enval, resb 256 NEWSYM winbgobjenval, resb 256 NEWSYM winbgbackenval, resb 256 NEWSYM winlogicaval, resw 256 NEWSYM winbg1envals, resb 256 NEWSYM winbg2envals, resb 256 NEWSYM winbg3envals, resb 256 NEWSYM winbg4envals, resb 256 NEWSYM winbgobjenvals, resb 256 NEWSYM winbgbackenvals, resb 256 NEWSYM winbg1envalm, resb 256 NEWSYM winbg2envalm, resb 256 NEWSYM winbg3envalm, resb 256 NEWSYM winbg4envalm, resb 256 NEWSYM winbgobjenvalm, resb 256 NEWSYM winbgbackenvalm, resb 256 NEWSYM FillSubScr, resb 256 NEWSYM objclineptr, resd 256 ; l1,r1,l2,r2,en,log,ptr SECTION .data NEWSYM objwlrpos , times 256 dd 0FFFFFFFFh NEWSYM objwen , times 256 dw 0FFFFh ; en,log SECTION .bss NEWSYM SpecialLine, resb 256 NEWSYM bgallchange, resb 256 NEWSYM bg1change, resb 256 NEWSYM bg2change, resb 256 NEWSYM bg3change, resb 256 NEWSYM bg4change, resb 256 NEWSYM bgwinchange, resb 256 NEWSYM PrevPicture, resb 64*56*2 NEWSYM EndMemAsmEnd zsnes-1.36/src/fixsin.c0100644000175000017500000007537207267141100014433 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. int FSinTab[2048] = { 0, 201, 402, 603, 804, 1005, 1206, 1407, 1608, 1809, 2010, 2211, 2412, 2613, 2814, 3014, 3215, 3416, 3617, 3818, 4018, 4219, 4420, 4620, 4821, 5021, 5222, 5422, 5622, 5823, 6023, 6223, 6423, 6623, 6823, 7023, 7223, 7423, 7623, 7822, 8022, 8221, 8421, 8620, 8819, 9019, 9218, 9417, 9616, 9814, 10013, 10212, 10410, 10609, 10807, 11006, 11204, 11402, 11600, 11797, 11995, 12193, 12390, 12588, 12785, 12982, 13179, 13376, 13573, 13769, 13966, 14162, 14359, 14555, 14751, 14946, 15142, 15338, 15533, 15728, 15923, 16118, 16313, 16508, 16702, 16897, 17091, 17285, 17479, 17672, 17866, 18059, 18253, 18446, 18638, 18831, 19024, 19216, 19408, 19600, 19792, 19983, 20175, 20366, 20557, 20748, 20938, 21129, 21319, 21509, 21699, 21889, 22078, 22267, 22456, 22645, 22833, 23022, 23210, 23398, 23586, 23773, 23960, 24147, 24334, 24521, 24707, 24893, 25079, 25265, 25450, 25635, 25820, 26005, 26189, 26373, 26557, 26741, 26925, 27108, 27291, 27473, 27656, 27838, 28020, 28201, 28383, 28564, 28745, 28925, 29105, 29285, 29465, 29645, 29824, 30003, 30181, 30360, 30538, 30715, 30893, 31070, 31247, 31424, 31600, 31776, 31952, 32127, 32302, 32477, 32651, 32826, 32999, 33173, 33346, 33519, 33692, 33864, 34036, 34208, 34379, 34550, 34721, 34891, 35061, 35231, 35400, 35569, 35738, 35906, 36074, 36242, 36409, 36576, 36743, 36909, 37075, 37241, 37406, 37571, 37736, 37900, 38064, 38227, 38390, 38553, 38716, 38878, 39039, 39201, 39362, 39522, 39682, 39842, 40002, 40161, 40319, 40478, 40636, 40793, 40950, 41107, 41263, 41419, 41575, 41730, 41885, 42040, 42194, 42347, 42501, 42653, 42806, 42958, 43110, 43261, 43412, 43562, 43712, 43862, 44011, 44160, 44308, 44456, 44603, 44750, 44897, 45043, 45189, 45335, 45480, 45624, 45768, 45912, 46055, 46198, 46340, 46482, 46624, 46765, 46906, 47046, 47186, 47325, 47464, 47602, 47740, 47878, 48015, 48151, 48288, 48423, 48558, 48693, 48828, 48961, 49095, 49228, 49360, 49492, 49624, 49755, 49886, 50016, 50146, 50275, 50403, 50532, 50660, 50787, 50914, 51040, 51166, 51291, 51416, 51541, 51665, 51788, 51911, 52033, 52155, 52277, 52398, 52518, 52639, 52758, 52877, 52996, 53114, 53231, 53348, 53465, 53581, 53696, 53811, 53926, 54040, 54153, 54266, 54379, 54491, 54602, 54713, 54823, 54933, 55043, 55152, 55260, 55368, 55475, 55582, 55688, 55794, 55899, 56004, 56108, 56212, 56315, 56417, 56519, 56621, 56722, 56822, 56922, 57022, 57120, 57219, 57316, 57414, 57510, 57606, 57702, 57797, 57892, 57986, 58079, 58172, 58264, 58356, 58447, 58538, 58628, 58718, 58807, 58895, 58983, 59070, 59157, 59243, 59329, 59414, 59499, 59583, 59666, 59749, 59831, 59913, 59994, 60075, 60155, 60235, 60313, 60392, 60470, 60547, 60624, 60700, 60775, 60850, 60924, 60998, 61071, 61144, 61216, 61288, 61359, 61429, 61499, 61568, 61637, 61705, 61772, 61839, 61905, 61971, 62036, 62100, 62164, 62228, 62291, 62353, 62414, 62475, 62536, 62596, 62655, 62714, 62772, 62829, 62886, 62942, 62998, 63053, 63108, 63162, 63215, 63268, 63320, 63371, 63422, 63473, 63522, 63571, 63620, 63668, 63715, 63762, 63808, 63854, 63899, 63943, 63987, 64030, 64073, 64115, 64156, 64197, 64237, 64276, 64315, 64353, 64391, 64428, 64465, 64501, 64536, 64571, 64605, 64638, 64671, 64703, 64735, 64766, 64796, 64826, 64855, 64884, 64912, 64939, 64966, 64992, 65018, 65043, 65067, 65091, 65114, 65136, 65158, 65179, 65200, 65220, 65239, 65258, 65276, 65294, 65311, 65327, 65343, 65358, 65372, 65386, 65400, 65412, 65424, 65436, 65446, 65457, 65466, 65475, 65483, 65491, 65498, 65505, 65511, 65516, 65520, 65524, 65528, 65531, 65533, 65534, 65535, 65536, 65535, 65534, 65533, 65531, 65528, 65524, 65520, 65516, 65511, 65505, 65498, 65491, 65483, 65475, 65466, 65457, 65446, 65436, 65424, 65412, 65400, 65386, 65372, 65358, 65343, 65327, 65311, 65294, 65276, 65258, 65239, 65220, 65200, 65179, 65158, 65136, 65114, 65091, 65067, 65043, 65018, 64992, 64966, 64939, 64912, 64884, 64855, 64826, 64796, 64766, 64735, 64703, 64671, 64638, 64605, 64571, 64536, 64501, 64465, 64428, 64391, 64353, 64315, 64276, 64237, 64197, 64156, 64115, 64073, 64030, 63987, 63943, 63899, 63854, 63808, 63762, 63715, 63668, 63620, 63571, 63522, 63473, 63422, 63371, 63320, 63268, 63215, 63162, 63108, 63053, 62998, 62942, 62886, 62829, 62772, 62714, 62655, 62596, 62536, 62475, 62414, 62353, 62291, 62228, 62164, 62100, 62036, 61971, 61905, 61839, 61772, 61705, 61637, 61568, 61499, 61429, 61359, 61288, 61216, 61144, 61071, 60998, 60924, 60850, 60775, 60700, 60624, 60547, 60470, 60392, 60313, 60235, 60155, 60075, 59994, 59913, 59831, 59749, 59666, 59583, 59499, 59414, 59329, 59243, 59157, 59070, 58983, 58895, 58807, 58718, 58628, 58538, 58447, 58356, 58264, 58172, 58079, 57986, 57892, 57797, 57702, 57606, 57510, 57414, 57316, 57219, 57120, 57022, 56922, 56822, 56722, 56621, 56519, 56417, 56315, 56212, 56108, 56004, 55899, 55794, 55688, 55582, 55475, 55368, 55260, 55152, 55043, 54933, 54823, 54713, 54602, 54491, 54379, 54266, 54153, 54040, 53926, 53811, 53696, 53581, 53465, 53348, 53231, 53114, 52996, 52877, 52758, 52639, 52518, 52398, 52277, 52155, 52033, 51911, 51788, 51665, 51541, 51416, 51291, 51166, 51040, 50914, 50787, 50660, 50532, 50403, 50275, 50146, 50016, 49886, 49755, 49624, 49492, 49360, 49228, 49095, 48961, 48828, 48693, 48558, 48423, 48288, 48151, 48015, 47878, 47740, 47602, 47464, 47325, 47186, 47046, 46906, 46765, 46624, 46482, 46340, 46198, 46055, 45912, 45768, 45624, 45480, 45335, 45189, 45043, 44897, 44750, 44603, 44456, 44308, 44160, 44011, 43862, 43712, 43562, 43412, 43261, 43110, 42958, 42806, 42653, 42501, 42347, 42194, 42040, 41885, 41730, 41575, 41419, 41263, 41107, 40950, 40793, 40636, 40478, 40319, 40161, 40002, 39842, 39682, 39522, 39362, 39201, 39039, 38878, 38716, 38553, 38390, 38227, 38064, 37900, 37736, 37571, 37406, 37241, 37075, 36909, 36743, 36576, 36409, 36242, 36074, 35906, 35738, 35569, 35400, 35231, 35061, 34891, 34721, 34550, 34379, 34208, 34036, 33864, 33692, 33519, 33346, 33173, 32999, 32826, 32651, 32477, 32302, 32127, 31952, 31776, 31600, 31424, 31247, 31070, 30893, 30715, 30538, 30360, 30181, 30003, 29824, 29645, 29465, 29285, 29105, 28925, 28745, 28564, 28383, 28201, 28020, 27838, 27656, 27473, 27291, 27108, 26925, 26741, 26557, 26373, 26189, 26005, 25820, 25635, 25450, 25265, 25079, 24893, 24707, 24521, 24334, 24147, 23960, 23773, 23586, 23398, 23210, 23022, 22833, 22645, 22456, 22267, 22078, 21889, 21699, 21509, 21319, 21129, 20938, 20748, 20557, 20366, 20175, 19983, 19792, 19600, 19408, 19216, 19024, 18831, 18638, 18446, 18253, 18059, 17866, 17672, 17479, 17285, 17091, 16897, 16702, 16508, 16313, 16118, 15923, 15728, 15533, 15338, 15142, 14946, 14751, 14555, 14359, 14162, 13966, 13769, 13573, 13376, 13179, 12982, 12785, 12588, 12390, 12193, 11995, 11797, 11600, 11402, 11204, 11006, 10807, 10609, 10410, 10212, 10013, 9814, 9616, 9417, 9218, 9019, 8819, 8620, 8421, 8221, 8022, 7822, 7623, 7423, 7223, 7023, 6823, 6623, 6423, 6223, 6023, 5823, 5622, 5422, 5222, 5021, 4821, 4620, 4420, 4219, 4018, 3818, 3617, 3416, 3215, 3014, 2814, 2613, 2412, 2211, 2010, 1809, 1608, 1407, 1206, 1005, 804, 603, 402, 201, 0, -201, -402, -603, -804, -1005, -1206, -1407, -1608, -1809, -2010, -2211, -2412, -2613, -2814, -3014, -3215, -3416, -3617, -3818, -4018, -4219, -4420, -4620, -4821, -5021, -5222, -5422, -5622, -5823, -6023, -6223, -6423, -6623, -6823, -7023, -7223, -7423, -7623, -7822, -8022, -8221, -8421, -8620, -8819, -9019, -9218, -9417, -9616, -9814, -10013, -10212, -10410, -10609, -10807, -11006, -11204, -11402, -11600, -11797, -11995, -12193, -12390, -12588, -12785, -12982, -13179, -13376, -13573, -13769, -13966, -14162, -14359, -14555, -14751, -14946, -15142, -15338, -15533, -15728, -15923, -16118, -16313, -16508, -16702, -16897, -17091, -17285, -17479, -17672, -17866, -18059, -18253, -18446, -18638, -18831, -19024, -19216, -19408, -19600, -19792, -19983, -20175, -20366, -20557, -20748, -20938, -21129, -21319, -21509, -21699, -21889, -22078, -22267, -22456, -22645, -22833, -23022, -23210, -23398, -23586, -23773, -23960, -24147, -24334, -24521, -24707, -24893, -25079, -25265, -25450, -25635, -25820, -26005, -26189, -26373, -26557, -26741, -26925, -27108, -27291, -27473, -27656, -27838, -28020, -28201, -28383, -28564, -28745, -28925, -29105, -29285, -29465, -29645, -29824, -30003, -30181, -30360, -30538, -30715, -30893, -31070, -31247, -31424, -31600, -31776, -31952, -32127, -32302, -32477, -32651, -32826, -32999, -33173, -33346, -33519, -33692, -33864, -34036, -34208, -34379, -34550, -34721, -34891, -35061, -35231, -35400, -35569, -35738, -35906, -36074, -36242, -36409, -36576, -36743, -36909, -37075, -37241, -37406, -37571, -37736, -37900, -38064, -38227, -38390, -38553, -38716, -38878, -39039, -39201, -39362, -39522, -39682, -39842, -40002, -40161, -40319, -40478, -40636, -40793, -40950, -41107, -41263, -41419, -41575, -41730, -41885, -42040, -42194, -42347, -42501, -42653, -42806, -42958, -43110, -43261, -43412, -43562, -43712, -43862, -44011, -44160, -44308, -44456, -44603, -44750, -44897, -45043, -45189, -45335, -45480, -45624, -45768, -45912, -46055, -46198, -46340, -46482, -46624, -46765, -46906, -47046, -47186, -47325, -47464, -47602, -47740, -47878, -48015, -48151, -48288, -48423, -48558, -48693, -48828, -48961, -49095, -49228, -49360, -49492, -49624, -49755, -49886, -50016, -50146, -50275, -50403, -50532, -50660, -50787, -50914, -51040, -51166, -51291, -51416, -51541, -51665, -51788, -51911, -52033, -52155, -52277, -52398, -52518, -52639, -52758, -52877, -52996, -53114, -53231, -53348, -53465, -53581, -53696, -53811, -53926, -54040, -54153, -54266, -54379, -54491, -54602, -54713, -54823, -54933, -55043, -55152, -55260, -55368, -55475, -55582, -55688, -55794, -55899, -56004, -56108, -56212, -56315, -56417, -56519, -56621, -56722, -56822, -56922, -57022, -57120, -57219, -57316, -57414, -57510, -57606, -57702, -57797, -57892, -57986, -58079, -58172, -58264, -58356, -58447, -58538, -58628, -58718, -58807, -58895, -58983, -59070, -59157, -59243, -59329, -59414, -59499, -59583, -59666, -59749, -59831, -59913, -59994, -60075, -60155, -60235, -60313, -60392, -60470, -60547, -60624, -60700, -60775, -60850, -60924, -60998, -61071, -61144, -61216, -61288, -61359, -61429, -61499, -61568, -61637, -61705, -61772, -61839, -61905, -61971, -62036, -62100, -62164, -62228, -62291, -62353, -62414, -62475, -62536, -62596, -62655, -62714, -62772, -62829, -62886, -62942, -62998, -63053, -63108, -63162, -63215, -63268, -63320, -63371, -63422, -63473, -63522, -63571, -63620, -63668, -63715, -63762, -63808, -63854, -63899, -63943, -63987, -64030, -64073, -64115, -64156, -64197, -64237, -64276, -64315, -64353, -64391, -64428, -64465, -64501, -64536, -64571, -64605, -64638, -64671, -64703, -64735, -64766, -64796, -64826, -64855, -64884, -64912, -64939, -64966, -64992, -65018, -65043, -65067, -65091, -65114, -65136, -65158, -65179, -65200, -65220, -65239, -65258, -65276, -65294, -65311, -65327, -65343, -65358, -65372, -65386, -65400, -65412, -65424, -65436, -65446, -65457, -65466, -65475, -65483, -65491, -65498, -65505, -65511, -65516, -65520, -65524, -65528, -65531, -65533, -65534, -65535, -65536, -65535, -65534, -65533, -65531, -65528, -65524, -65520, -65516, -65511, -65505, -65498, -65491, -65483, -65475, -65466, -65457, -65446, -65436, -65424, -65412, -65400, -65386, -65372, -65358, -65343, -65327, -65311, -65294, -65276, -65258, -65239, -65220, -65200, -65179, -65158, -65136, -65114, -65091, -65067, -65043, -65018, -64992, -64966, -64939, -64912, -64884, -64855, -64826, -64796, -64766, -64735, -64703, -64671, -64638, -64605, -64571, -64536, -64501, -64465, -64428, -64391, -64353, -64315, -64276, -64237, -64197, -64156, -64115, -64073, -64030, -63987, -63943, -63899, -63854, -63808, -63762, -63715, -63668, -63620, -63571, -63522, -63473, -63422, -63371, -63320, -63268, -63215, -63162, -63108, -63053, -62998, -62942, -62886, -62829, -62772, -62714, -62655, -62596, -62536, -62475, -62414, -62353, -62291, -62228, -62164, -62100, -62036, -61971, -61905, -61839, -61772, -61705, -61637, -61568, -61499, -61429, -61359, -61288, -61216, -61144, -61071, -60998, -60924, -60850, -60775, -60700, -60624, -60547, -60470, -60392, -60313, -60235, -60155, -60075, -59994, -59913, -59831, -59749, -59666, -59583, -59499, -59414, -59329, -59243, -59157, -59070, -58983, -58895, -58807, -58718, -58628, -58538, -58447, -58356, -58264, -58172, -58079, -57986, -57892, -57797, -57702, -57606, -57510, -57414, -57316, -57219, -57120, -57022, -56922, -56822, -56722, -56621, -56519, -56417, -56315, -56212, -56108, -56004, -55899, -55794, -55688, -55582, -55475, -55368, -55260, -55152, -55043, -54933, -54823, -54713, -54602, -54491, -54379, -54266, -54153, -54040, -53926, -53811, -53696, -53581, -53465, -53348, -53231, -53114, -52996, -52877, -52758, -52639, -52518, -52398, -52277, -52155, -52033, -51911, -51788, -51665, -51541, -51416, -51291, -51166, -51040, -50914, -50787, -50660, -50532, -50403, -50275, -50146, -50016, -49886, -49755, -49624, -49492, -49360, -49228, -49095, -48961, -48828, -48693, -48558, -48423, -48288, -48151, -48015, -47878, -47740, -47602, -47464, -47325, -47186, -47046, -46906, -46765, -46624, -46482, -46340, -46198, -46055, -45912, -45768, -45624, -45480, -45335, -45189, -45043, -44897, -44750, -44603, -44456, -44308, -44160, -44011, -43862, -43712, -43562, -43412, -43261, -43110, -42958, -42806, -42653, -42501, -42347, -42194, -42040, -41885, -41730, -41575, -41419, -41263, -41107, -40950, -40793, -40636, -40478, -40319, -40161, -40002, -39842, -39682, -39522, -39362, -39201, -39039, -38878, -38716, -38553, -38390, -38227, -38064, -37900, -37736, -37571, -37406, -37241, -37075, -36909, -36743, -36576, -36409, -36242, -36074, -35906, -35738, -35569, -35400, -35231, -35061, -34891, -34721, -34550, -34379, -34208, -34036, -33864, -33692, -33519, -33346, -33173, -32999, -32826, -32651, -32477, -32302, -32127, -31952, -31776, -31600, -31424, -31247, -31070, -30893, -30715, -30538, -30360, -30181, -30003, -29824, -29645, -29465, -29285, -29105, -28925, -28745, -28564, -28383, -28201, -28020, -27838, -27656, -27473, -27291, -27108, -26925, -26741, -26557, -26373, -26189, -26005, -25820, -25635, -25450, -25265, -25079, -24893, -24707, -24521, -24334, -24147, -23960, -23773, -23586, -23398, -23210, -23022, -22833, -22645, -22456, -22267, -22078, -21889, -21699, -21509, -21319, -21129, -20938, -20748, -20557, -20366, -20175, -19983, -19792, -19600, -19408, -19216, -19024, -18831, -18638, -18446, -18253, -18059, -17866, -17672, -17479, -17285, -17091, -16897, -16702, -16508, -16313, -16118, -15923, -15728, -15533, -15338, -15142, -14946, -14751, -14555, -14359, -14162, -13966, -13769, -13573, -13376, -13179, -12982, -12785, -12588, -12390, -12193, -11995, -11797, -11600, -11402, -11204, -11006, -10807, -10609, -10410, -10212, -10013, -9814, -9616, -9417, -9218, -9019, -8819, -8620, -8421, -8221, -8022, -7822, -7623, -7423, -7223, -7023, -6823, -6623, -6423, -6223, -6023, -5823, -5622, -5422, -5222, -5021, -4821, -4620, -4420, -4219, -4018, -3818, -3617, -3416, -3215, -3014, -2814, -2613, -2412, -2211, -2010, -1809, -1608, -1407, -1206, -1005, -804, -603, -402, -201 }; int FCosTab[2048] = { 65536, 65535, 65534, 65533, 65531, 65528, 65524, 65520, 65516, 65511, 65505, 65498, 65491, 65483, 65475, 65466, 65457, 65446, 65436, 65424, 65412, 65400, 65386, 65372, 65358, 65343, 65327, 65311, 65294, 65276, 65258, 65239, 65220, 65200, 65179, 65158, 65136, 65114, 65091, 65067, 65043, 65018, 64992, 64966, 64939, 64912, 64884, 64855, 64826, 64796, 64766, 64735, 64703, 64671, 64638, 64605, 64571, 64536, 64501, 64465, 64428, 64391, 64353, 64315, 64276, 64237, 64197, 64156, 64115, 64073, 64030, 63987, 63943, 63899, 63854, 63808, 63762, 63715, 63668, 63620, 63571, 63522, 63473, 63422, 63371, 63320, 63268, 63215, 63162, 63108, 63053, 62998, 62942, 62886, 62829, 62772, 62714, 62655, 62596, 62536, 62475, 62414, 62353, 62291, 62228, 62164, 62100, 62036, 61971, 61905, 61839, 61772, 61705, 61637, 61568, 61499, 61429, 61359, 61288, 61216, 61144, 61071, 60998, 60924, 60850, 60775, 60700, 60624, 60547, 60470, 60392, 60313, 60235, 60155, 60075, 59994, 59913, 59831, 59749, 59666, 59583, 59499, 59414, 59329, 59243, 59157, 59070, 58983, 58895, 58807, 58718, 58628, 58538, 58447, 58356, 58264, 58172, 58079, 57986, 57892, 57797, 57702, 57606, 57510, 57414, 57316, 57219, 57120, 57022, 56922, 56822, 56722, 56621, 56519, 56417, 56315, 56212, 56108, 56004, 55899, 55794, 55688, 55582, 55475, 55368, 55260, 55152, 55043, 54933, 54823, 54713, 54602, 54491, 54379, 54266, 54153, 54040, 53926, 53811, 53696, 53581, 53465, 53348, 53231, 53114, 52996, 52877, 52758, 52639, 52518, 52398, 52277, 52155, 52033, 51911, 51788, 51665, 51541, 51416, 51291, 51166, 51040, 50914, 50787, 50660, 50532, 50403, 50275, 50146, 50016, 49886, 49755, 49624, 49492, 49360, 49228, 49095, 48961, 48828, 48693, 48558, 48423, 48288, 48151, 48015, 47878, 47740, 47602, 47464, 47325, 47186, 47046, 46906, 46765, 46624, 46482, 46340, 46198, 46055, 45912, 45768, 45624, 45480, 45335, 45189, 45043, 44897, 44750, 44603, 44456, 44308, 44160, 44011, 43862, 43712, 43562, 43412, 43261, 43110, 42958, 42806, 42653, 42501, 42347, 42194, 42040, 41885, 41730, 41575, 41419, 41263, 41107, 40950, 40793, 40636, 40478, 40319, 40161, 40002, 39842, 39682, 39522, 39362, 39201, 39039, 38878, 38716, 38553, 38390, 38227, 38064, 37900, 37736, 37571, 37406, 37241, 37075, 36909, 36743, 36576, 36409, 36242, 36074, 35906, 35738, 35569, 35400, 35231, 35061, 34891, 34721, 34550, 34379, 34208, 34036, 33864, 33692, 33519, 33346, 33173, 32999, 32826, 32651, 32477, 32302, 32127, 31952, 31776, 31600, 31424, 31247, 31070, 30893, 30715, 30538, 30360, 30181, 30003, 29824, 29645, 29465, 29285, 29105, 28925, 28745, 28564, 28383, 28201, 28020, 27838, 27656, 27473, 27291, 27108, 26925, 26741, 26557, 26373, 26189, 26005, 25820, 25635, 25450, 25265, 25079, 24893, 24707, 24521, 24334, 24147, 23960, 23773, 23586, 23398, 23210, 23022, 22833, 22645, 22456, 22267, 22078, 21889, 21699, 21509, 21319, 21129, 20938, 20748, 20557, 20366, 20175, 19983, 19792, 19600, 19408, 19216, 19024, 18831, 18638, 18446, 18253, 18059, 17866, 17672, 17479, 17285, 17091, 16897, 16702, 16508, 16313, 16118, 15923, 15728, 15533, 15338, 15142, 14946, 14751, 14555, 14359, 14162, 13966, 13769, 13573, 13376, 13179, 12982, 12785, 12588, 12390, 12193, 11995, 11797, 11600, 11402, 11204, 11006, 10807, 10609, 10410, 10212, 10013, 9814, 9616, 9417, 9218, 9019, 8819, 8620, 8421, 8221, 8022, 7822, 7623, 7423, 7223, 7023, 6823, 6623, 6423, 6223, 6023, 5823, 5622, 5422, 5222, 5021, 4821, 4620, 4420, 4219, 4018, 3818, 3617, 3416, 3215, 3014, 2814, 2613, 2412, 2211, 2010, 1809, 1608, 1407, 1206, 1005, 804, 603, 402, 201, 0, -201, -402, -603, -804, -1005, -1206, -1407, -1608, -1809, -2010, -2211, -2412, -2613, -2814, -3014, -3215, -3416, -3617, -3818, -4018, -4219, -4420, -4620, -4821, -5021, -5222, -5422, -5622, -5823, -6023, -6223, -6423, -6623, -6823, -7023, -7223, -7423, -7623, -7822, -8022, -8221, -8421, -8620, -8819, -9019, -9218, -9417, -9616, -9814, -10013, -10212, -10410, -10609, -10807, -11006, -11204, -11402, -11600, -11797, -11995, -12193, -12390, -12588, -12785, -12982, -13179, -13376, -13573, -13769, -13966, -14162, -14359, -14555, -14751, -14946, -15142, -15338, -15533, -15728, -15923, -16118, -16313, -16508, -16702, -16897, -17091, -17285, -17479, -17672, -17866, -18059, -18253, -18446, -18638, -18831, -19024, -19216, -19408, -19600, -19792, -19983, -20175, -20366, -20557, -20748, -20938, -21129, -21319, -21509, -21699, -21889, -22078, -22267, -22456, -22645, -22833, -23022, -23210, -23398, -23586, -23773, -23960, -24147, -24334, -24521, -24707, -24893, -25079, -25265, -25450, -25635, -25820, -26005, -26189, -26373, -26557, -26741, -26925, -27108, -27291, -27473, -27656, -27838, -28020, -28201, -28383, -28564, -28745, -28925, -29105, -29285, -29465, -29645, -29824, -30003, -30181, -30360, -30538, -30715, -30893, -31070, -31247, -31424, -31600, -31776, -31952, -32127, -32302, -32477, -32651, -32826, -32999, -33173, -33346, -33519, -33692, -33864, -34036, -34208, -34379, -34550, -34721, -34891, -35061, -35231, -35400, -35569, -35738, -35906, -36074, -36242, -36409, -36576, -36743, -36909, -37075, -37241, -37406, -37571, -37736, -37900, -38064, -38227, -38390, -38553, -38716, -38878, -39039, -39201, -39362, -39522, -39682, -39842, -40002, -40161, -40319, -40478, -40636, -40793, -40950, -41107, -41263, -41419, -41575, -41730, -41885, -42040, -42194, -42347, -42501, -42653, -42806, -42958, -43110, -43261, -43412, -43562, -43712, -43862, -44011, -44160, -44308, -44456, -44603, -44750, -44897, -45043, -45189, -45335, -45480, -45624, -45768, -45912, -46055, -46198, -46340, -46482, -46624, -46765, -46906, -47046, -47186, -47325, -47464, -47602, -47740, -47878, -48015, -48151, -48288, -48423, -48558, -48693, -48828, -48961, -49095, -49228, -49360, -49492, -49624, -49755, -49886, -50016, -50146, -50275, -50403, -50532, -50660, -50787, -50914, -51040, -51166, -51291, -51416, -51541, -51665, -51788, -51911, -52033, -52155, -52277, -52398, -52518, -52639, -52758, -52877, -52996, -53114, -53231, -53348, -53465, -53581, -53696, -53811, -53926, -54040, -54153, -54266, -54379, -54491, -54602, -54713, -54823, -54933, -55043, -55152, -55260, -55368, -55475, -55582, -55688, -55794, -55899, -56004, -56108, -56212, -56315, -56417, -56519, -56621, -56722, -56822, -56922, -57022, -57120, -57219, -57316, -57414, -57510, -57606, -57702, -57797, -57892, -57986, -58079, -58172, -58264, -58356, -58447, -58538, -58628, -58718, -58807, -58895, -58983, -59070, -59157, -59243, -59329, -59414, -59499, -59583, -59666, -59749, -59831, -59913, -59994, -60075, -60155, -60235, -60313, -60392, -60470, -60547, -60624, -60700, -60775, -60850, -60924, -60998, -61071, -61144, -61216, -61288, -61359, -61429, -61499, -61568, -61637, -61705, -61772, -61839, -61905, -61971, -62036, -62100, -62164, -62228, -62291, -62353, -62414, -62475, -62536, -62596, -62655, -62714, -62772, -62829, -62886, -62942, -62998, -63053, -63108, -63162, -63215, -63268, -63320, -63371, -63422, -63473, -63522, -63571, -63620, -63668, -63715, -63762, -63808, -63854, -63899, -63943, -63987, -64030, -64073, -64115, -64156, -64197, -64237, -64276, -64315, -64353, -64391, -64428, -64465, -64501, -64536, -64571, -64605, -64638, -64671, -64703, -64735, -64766, -64796, -64826, -64855, -64884, -64912, -64939, -64966, -64992, -65018, -65043, -65067, -65091, -65114, -65136, -65158, -65179, -65200, -65220, -65239, -65258, -65276, -65294, -65311, -65327, -65343, -65358, -65372, -65386, -65400, -65412, -65424, -65436, -65446, -65457, -65466, -65475, -65483, -65491, -65498, -65505, -65511, -65516, -65520, -65524, -65528, -65531, -65533, -65534, -65535, -65536, -65535, -65534, -65533, -65531, -65528, -65524, -65520, -65516, -65511, -65505, -65498, -65491, -65483, -65475, -65466, -65457, -65446, -65436, -65424, -65412, -65400, -65386, -65372, -65358, -65343, -65327, -65311, -65294, -65276, -65258, -65239, -65220, -65200, -65179, -65158, -65136, -65114, -65091, -65067, -65043, -65018, -64992, -64966, -64939, -64912, -64884, -64855, -64826, -64796, -64766, -64735, -64703, -64671, -64638, -64605, -64571, -64536, -64501, -64465, -64428, -64391, -64353, -64315, -64276, -64237, -64197, -64156, -64115, -64073, -64030, -63987, -63943, -63899, -63854, -63808, -63762, -63715, -63668, -63620, -63571, -63522, -63473, -63422, -63371, -63320, -63268, -63215, -63162, -63108, -63053, -62998, -62942, -62886, -62829, -62772, -62714, -62655, -62596, -62536, -62475, -62414, -62353, -62291, -62228, -62164, -62100, -62036, -61971, -61905, -61839, -61772, -61705, -61637, -61568, -61499, -61429, -61359, -61288, -61216, -61144, -61071, -60998, -60924, -60850, -60775, -60700, -60624, -60547, -60470, -60392, -60313, -60235, -60155, -60075, -59994, -59913, -59831, -59749, -59666, -59583, -59499, -59414, -59329, -59243, -59157, -59070, -58983, -58895, -58807, -58718, -58628, -58538, -58447, -58356, -58264, -58172, -58079, -57986, -57892, -57797, -57702, -57606, -57510, -57414, -57316, -57219, -57120, -57022, -56922, -56822, -56722, -56621, -56519, -56417, -56315, -56212, -56108, -56004, -55899, -55794, -55688, -55582, -55475, -55368, -55260, -55152, -55043, -54933, -54823, -54713, -54602, -54491, -54379, -54266, -54153, -54040, -53926, -53811, -53696, -53581, -53465, -53348, -53231, -53114, -52996, -52877, -52758, -52639, -52518, -52398, -52277, -52155, -52033, -51911, -51788, -51665, -51541, -51416, -51291, -51166, -51040, -50914, -50787, -50660, -50532, -50403, -50275, -50146, -50016, -49886, -49755, -49624, -49492, -49360, -49228, -49095, -48961, -48828, -48693, -48558, -48423, -48288, -48151, -48015, -47878, -47740, -47602, -47464, -47325, -47186, -47046, -46906, -46765, -46624, -46482, -46340, -46198, -46055, -45912, -45768, -45624, -45480, -45335, -45189, -45043, -44897, -44750, -44603, -44456, -44308, -44160, -44011, -43862, -43712, -43562, -43412, -43261, -43110, -42958, -42806, -42653, -42501, -42347, -42194, -42040, -41885, -41730, -41575, -41419, -41263, -41107, -40950, -40793, -40636, -40478, -40319, -40161, -40002, -39842, -39682, -39522, -39362, -39201, -39039, -38878, -38716, -38553, -38390, -38227, -38064, -37900, -37736, -37571, -37406, -37241, -37075, -36909, -36743, -36576, -36409, -36242, -36074, -35906, -35738, -35569, -35400, -35231, -35061, -34891, -34721, -34550, -34379, -34208, -34036, -33864, -33692, -33519, -33346, -33173, -32999, -32826, -32651, -32477, -32302, -32127, -31952, -31776, -31600, -31424, -31247, -31070, -30893, -30715, -30538, -30360, -30181, -30003, -29824, -29645, -29465, -29285, -29105, -28925, -28745, -28564, -28383, -28201, -28020, -27838, -27656, -27473, -27291, -27108, -26925, -26741, -26557, -26373, -26189, -26005, -25820, -25635, -25450, -25265, -25079, -24893, -24707, -24521, -24334, -24147, -23960, -23773, -23586, -23398, -23210, -23022, -22833, -22645, -22456, -22267, -22078, -21889, -21699, -21509, -21319, -21129, -20938, -20748, -20557, -20366, -20175, -19983, -19792, -19600, -19408, -19216, -19024, -18831, -18638, -18446, -18253, -18059, -17866, -17672, -17479, -17285, -17091, -16897, -16702, -16508, -16313, -16118, -15923, -15728, -15533, -15338, -15142, -14946, -14751, -14555, -14359, -14162, -13966, -13769, -13573, -13376, -13179, -12982, -12785, -12588, -12390, -12193, -11995, -11797, -11600, -11402, -11204, -11006, -10807, -10609, -10410, -10212, -10013, -9814, -9616, -9417, -9218, -9019, -8819, -8620, -8421, -8221, -8022, -7822, -7623, -7423, -7223, -7023, -6823, -6623, -6423, -6223, -6023, -5823, -5622, -5422, -5222, -5021, -4821, -4620, -4420, -4219, -4018, -3818, -3617, -3416, -3215, -3014, -2814, -2613, -2412, -2211, -2010, -1809, -1608, -1407, -1206, -1005, -804, -603, -402, -201, 0, 201, 402, 603, 804, 1005, 1206, 1407, 1608, 1809, 2010, 2211, 2412, 2613, 2814, 3014, 3215, 3416, 3617, 3818, 4018, 4219, 4420, 4620, 4821, 5021, 5222, 5422, 5622, 5823, 6023, 6223, 6423, 6623, 6823, 7023, 7223, 7423, 7623, 7822, 8022, 8221, 8421, 8620, 8819, 9019, 9218, 9417, 9616, 9814, 10013, 10212, 10410, 10609, 10807, 11006, 11204, 11402, 11600, 11797, 11995, 12193, 12390, 12588, 12785, 12982, 13179, 13376, 13573, 13769, 13966, 14162, 14359, 14555, 14751, 14946, 15142, 15338, 15533, 15728, 15923, 16118, 16313, 16508, 16702, 16897, 17091, 17285, 17479, 17672, 17866, 18059, 18253, 18446, 18638, 18831, 19024, 19216, 19408, 19600, 19792, 19983, 20175, 20366, 20557, 20748, 20938, 21129, 21319, 21509, 21699, 21889, 22078, 22267, 22456, 22645, 22833, 23022, 23210, 23398, 23586, 23773, 23960, 24147, 24334, 24521, 24707, 24893, 25079, 25265, 25450, 25635, 25820, 26005, 26189, 26373, 26557, 26741, 26925, 27108, 27291, 27473, 27656, 27838, 28020, 28201, 28383, 28564, 28745, 28925, 29105, 29285, 29465, 29645, 29824, 30003, 30181, 30360, 30538, 30715, 30893, 31070, 31247, 31424, 31600, 31776, 31952, 32127, 32302, 32477, 32651, 32826, 32999, 33173, 33346, 33519, 33692, 33864, 34036, 34208, 34379, 34550, 34721, 34891, 35061, 35231, 35400, 35569, 35738, 35906, 36074, 36242, 36409, 36576, 36743, 36909, 37075, 37241, 37406, 37571, 37736, 37900, 38064, 38227, 38390, 38553, 38716, 38878, 39039, 39201, 39362, 39522, 39682, 39842, 40002, 40161, 40319, 40478, 40636, 40793, 40950, 41107, 41263, 41419, 41575, 41730, 41885, 42040, 42194, 42347, 42501, 42653, 42806, 42958, 43110, 43261, 43412, 43562, 43712, 43862, 44011, 44160, 44308, 44456, 44603, 44750, 44897, 45043, 45189, 45335, 45480, 45624, 45768, 45912, 46055, 46198, 46340, 46482, 46624, 46765, 46906, 47046, 47186, 47325, 47464, 47602, 47740, 47878, 48015, 48151, 48288, 48423, 48558, 48693, 48828, 48961, 49095, 49228, 49360, 49492, 49624, 49755, 49886, 50016, 50146, 50275, 50403, 50532, 50660, 50787, 50914, 51040, 51166, 51291, 51416, 51541, 51665, 51788, 51911, 52033, 52155, 52277, 52398, 52518, 52639, 52758, 52877, 52996, 53114, 53231, 53348, 53465, 53581, 53696, 53811, 53926, 54040, 54153, 54266, 54379, 54491, 54602, 54713, 54823, 54933, 55043, 55152, 55260, 55368, 55475, 55582, 55688, 55794, 55899, 56004, 56108, 56212, 56315, 56417, 56519, 56621, 56722, 56822, 56922, 57022, 57120, 57219, 57316, 57414, 57510, 57606, 57702, 57797, 57892, 57986, 58079, 58172, 58264, 58356, 58447, 58538, 58628, 58718, 58807, 58895, 58983, 59070, 59157, 59243, 59329, 59414, 59499, 59583, 59666, 59749, 59831, 59913, 59994, 60075, 60155, 60235, 60313, 60392, 60470, 60547, 60624, 60700, 60775, 60850, 60924, 60998, 61071, 61144, 61216, 61288, 61359, 61429, 61499, 61568, 61637, 61705, 61772, 61839, 61905, 61971, 62036, 62100, 62164, 62228, 62291, 62353, 62414, 62475, 62536, 62596, 62655, 62714, 62772, 62829, 62886, 62942, 62998, 63053, 63108, 63162, 63215, 63268, 63320, 63371, 63422, 63473, 63522, 63571, 63620, 63668, 63715, 63762, 63808, 63854, 63899, 63943, 63987, 64030, 64073, 64115, 64156, 64197, 64237, 64276, 64315, 64353, 64391, 64428, 64465, 64501, 64536, 64571, 64605, 64638, 64671, 64703, 64735, 64766, 64796, 64826, 64855, 64884, 64912, 64939, 64966, 64992, 65018, 65043, 65067, 65091, 65114, 65136, 65158, 65179, 65200, 65220, 65239, 65258, 65276, 65294, 65311, 65327, 65343, 65358, 65372, 65386, 65400, 65412, 65424, 65436, 65446, 65457, 65466, 65475, 65483, 65491, 65498, 65505, 65511, 65516, 65520, 65524, 65528, 65531, 65533, 65534, 65535 }; zsnes-1.36/src/fixsin.h0100644000175000017500000000162707267141100014430 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. extern int FSinTab[2048]; extern int FCosTab[2048]; #define FSINMAX 2047 #define FSin(x) FSinTab[(x)&FSINMAX] #define FCos(x) FCosTab[(x)&FSINMAX] zsnes-1.36/src/init.asm0100644000175000017500000041512407514702750014436 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM DosExit,UpdateDevices,InitSPC,Makemode7Table,MusicRelVol,MusicVol EXTSYM makesprprtable,romloadskip,start65816,startdebugger,SfxR0 EXTSYM MovieProcessing EXTSYM MovieFileHand,filefound,inittable,SA1inittable EXTSYM MessageOn,Msgptr,MsgCount,sndrot,GenerateBank0Table,SnowTimer EXTSYM inittableb,inittablec,newgfx16b,cfgreinittime,EndMessage EXTSYM Open_File,Read_File,Write_File,Close_File,Output_Text,Get_Key,CNetType EXTSYM Delete_File,Get_First_Entry,Get_Next_Entry,Change_Dir,Get_Dir,InitDSP EXTSYM Remove_Dir,Change_Single_Dir,Create_Dir,Get_Memfree,Create_File ;EXTSYM OSPort EXTSYM SPCDisable,osm2dis,CurRecv,BackupSystemVars EXTSYM SnowData,SnowVelDist EXTSYM cvidmode, newengen, cfgnewgfx, GUI16VID EXTSYM NewEngEnForce EXTSYM PrintChar EXTSYM TextFile EXTSYM mode7tab EXTSYM per2exec EXTSYM MovieCounter EXTSYM chaton EXTSYM JoyRead,JoyReadControl,joy4218,joy4219 EXTSYM joy421A,joy421B,pressed EXTSYM pl3Ak,pl3Bk,pl3Lk,pl3Rk,pl3Xk,pl1p209,pl2p209,pl3p209,pl4p209 EXTSYM pl3Yk,pl3contrl,pl3downk,pl3leftk,pl3rightk,pl3selk,pl3startk EXTSYM pl3upk,pl4Ak,pl4Bk,pl4Lk,pl4Rk,pl4Xk,pl4Yk,pl4contrl,pl4downk EXTSYM pl4leftk,pl4rightk,pl4selk,pl4startk,pl4upk,mousebuttons,mousexdir EXTSYM pl5Ak,pl5Bk,pl5Lk,pl5Rk,pl5Xk,pl5Yk,pl5contrl,pl5downk EXTSYM pl5leftk,pl5rightk,pl5selk,pl5startk,pl5upk EXTSYM mouseydir,mousexpos,mouseypos,snesmouse,processmouse,ssautosw EXTSYM GUIDelayB,pl12s34 EXTSYM pl1Xtk,pl1Ytk,pl1Atk,pl1Btk,pl2Xtk,pl2Ytk,pl2Atk,pl2Btk EXTSYM pl3Xtk,pl3Ytk,pl3Atk,pl3Btk,pl4Xtk,pl4Ytk,pl4Atk,pl4Btk EXTSYM pl1ULk,pl1URk,pl1DLk,pl1DRk,pl2ULk,pl2URk,pl2DLk,pl2DRk EXTSYM pl3ULk,pl3URk,pl3DLk,pl3DRk,pl4ULk,pl4URk,pl4DLk,pl4DRk EXTSYM pl5ULk,pl5URk,pl5DLk,pl5DRk,pl5Xtk,pl5Ytk,pl5Atk,pl5Btk EXTSYM Turbo30hz,RepeatFrame,nojoystickpoll EXTSYM NumComboLocl,ComboBlHeader,ComboHeader,CombinDataLocl EXTSYM CombinDataGlob,NumCombo,GUIComboGameSpec EXTSYM mousexloc,mouseyloc EXTSYM extlatch EXTSYM BackState EXTSYM FIRTAPVal0,FIRTAPVal1,FIRTAPVal2,FIRTAPVal3,FIRTAPVal4 EXTSYM FIRTAPVal5,FIRTAPVal6,FIRTAPVal7,INTEnab,JoyAPos,JoyBPos EXTSYM NMIEnab,SPCROM,VIRQLoc,coladdb,coladdg,coladdr,doirqnext EXTSYM echobuf,forceblnk,nmiprevaddrh,nmiprevaddrl,nmiprevline EXTSYM nmirept,nmistatus,opexec268,opexec268b,opexec268cph EXTSYM opexec268cphb,opexec358,opexec358b,opexec358cph,spcextraram EXTSYM opexec358cphb,prevoamptr,reg1read,reg2read,reg3read EXTSYM reg4read,resolutn,romdata,scrndis,spcBuffera,spcP,spcRam EXTSYM spcnumread,tableD,timeron,vidbright,DSPMem,OldGfxMode2 EXTSYM SPC700read,SPC700write,GUIDoReset,spc700read EXTSYM InitC4,SA1Reset,SetAddressingModesSA1,SetAddressingModes,SDD1BankA,SPC7110init EXTSYM RTCinit,InitOBC EXTSYM memaccessspc7110r8,memaccessspc7110r16,memaccessspc7110w8 EXTSYM memaccessspc7110w16 EXTSYM ram7f,snesmap2,snesmmap,sram,MultiTap EXTSYM memaccessbankr848mb,memaccessbankr1648mb EXTSYM cpuover,execloop ;EXTSYM execloopn,execloopns,execloops ;EXTSYM PHsizeofexecloop,PHsizeofexecloopn,PHsizeofexecloopns ;EXTSYM PHsizeofexecloops EXTSYM curexecstate EXTSYM debugdisble,vidbuffer EXTSYM Sup16mbit,Sup48mbit,debugbufa,pal16b,pal16bcl,pal16bclha EXTSYM pal16bxcl,ram7fa,regptra,regptwa,srama,vidmemch2,vidmemch4 EXTSYM vidmemch8,vcache2b,vcache4b,vcache8b,vram,wramdata EXTSYM wramdataa EXTSYM fname,fnames,GetCurDir EXTSYM GUIcurrentdir,extractzip,PrintStr ;STUB DDOI ;EXTSYM GUIcurrentdir, PrintStr EXTSYM GUIsmcfind,GUIsfcfind,GUIswcfind,GUIfigfind,GUIfind058,GUIfind078,GUIfindBIN ;EXTSYM GUIfindUSA,GUIfindJAP,GUIfindZIP,GUIfind1,DTALoc,GUIfindall,ZipError EXTSYM GUIfindUSA,GUIfindJAP,GUIfindZIP,GUIfind1,DTALoc,GUIfindall EXTSYM spc7110romptr,allocspc7110 EXTSYM SRAMDir,SRAMDrive,cfgloadsdir,fnamest,statefileloc EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip EXTSYM gotoroot,headdata,printnum,romispal EXTSYM InitFxTables,SFXSRAM,SfxR1,SfxR2,SfxSCMR,SfxSFR,finterleave EXTSYM initregr,initregw,memtabler16,DSP1Read16b3F,memaccessbankr16 EXTSYM memtabler8,DSP1Read8b3F,memaccessbankr8,memtablew16,DSP1Write16b EXTSYM memaccessbankw16,memtablew8,DSP1Write8b,memaccessbankw8,DSP1Write16b3F EXTSYM regaccessbankr16,regaccessbankr8,regaccessbankw16,regaccessbankw8 EXTSYM sfxaccessbankr16,sfxaccessbankr16b,sfxaccessbankr16c,DSP1Write8b3F EXTSYM sfxaccessbankr16d,sfxaccessbankr8,sfxaccessbankr8b,sfxaccessbankr8c EXTSYM sfxaccessbankr8d,sfxaccessbankw16,sfxaccessbankw16b EXTSYM sfxaccessbankw16c,sfxaccessbankw16d,sfxaccessbankw8 EXTSYM sfxaccessbankw8b,sfxaccessbankw8c,sfxaccessbankw8d,sfxramdata EXTSYM sramaccessbankr16,sramaccessbankr16s,sramaccessbankr8 EXTSYM sramaccessbankr8s,sramaccessbankw16,sramaccessbankw16s EXTSYM sramaccessbankw8,sramaccessbankw8s,GenerateBank0TableSA1 EXTSYM ScrDispl,wramreadptr,wramwriteptr EXTSYM pl1Ltk,pl1Rtk,pl2Ltk,pl2Rtk,pl3Ltk,pl3Rtk,pl4Ltk,pl4Rtk,pl5Ltk,pl5Rtk %ifdef __LINUX__ EXTSYM LoadDir, popdir, pushdir %endif NEWSYM InitAsmStart ; Initiation SECTION .data NEWSYM regsbackup, times 3019 db 0 NEWSYM forceromtype, db 0 NEWSYM loadedfromgui, db 0 NEWSYM SnowOn, db 0 NEWSYM bgfixer, db 0 NEWSYM bgfixer2, db 0 NEWSYM ReInitLength, dd 0 NEWSYM ForceNewGfxOff, dd 0 NEWSYM SfxAC, db 0 blah times 450 db 0 SECTION .text EXTSYM cpalval NEWSYM init ; prevents a crash if cpalval gets accessed before initializing mov eax,cpalval mov ecx,256 .looppal mov dword[eax],cpalval add eax,4 dec ecx jnz .looppal ; Initialize snow stuff mov ecx,400 xor edx,edx .snowloop shl word[SnowData+edx*2],8 and byte[SnowVelDist+edx],0F7h cmp dword[SnowTimer],0 jne .skip or byte[SnowVelDist+edx],08h .skip inc edx dec ecx jnz .snowloop call BackupSystemVars xor eax,eax mov al,[cfgreinittime] mov ebx,50 mul ebx mov [ReInitLength],eax xor eax,eax mov al,byte[romtype] mov [forceromtype],al mov byte[romtype],0 mov ax,ds mov es,ax mov eax,regsbackup mov ebx,sndrot mov ecx,3019 .rbackupl mov dl,[ebx] mov [eax],dl inc ebx inc eax dec ecx jnz .rbackupl mov byte[virqnodisable],0 call clearmem call inittable call inittableb call inittablec call SA1inittable ; SPC Init call copyexecloop call procexecloop ; SNES Init call Setper2exec call Makemode7Table call makesprprtable cmp byte[fname],0 jne .found cmp byte[romloadskip],1 je .noloadfile .found mov byte[romloadskip],0 call loadfile call showinfo call showinfogui .noloadfile call UpdateDevices call init65816 call initregr call initregw call initsnes ; Initialize volume xor eax,eax xor edx,edx mov al,[MusicRelVol] shl eax,7 mov ebx,100 div ebx cmp al,127 jb .noof mov al,127 .noof mov [MusicVol],al xor eax,eax mov al,[cvidmode] cmp byte[GUI16VID+eax],1 je .yes16b mov byte[newengen],1 mov byte[cfgnewgfx],1 .yes16b cmp byte[NewEngEnForce],1 jne .noforce mov byte[NewEngEnForce],0 mov byte[newengen],1 mov byte[cfgnewgfx],1 .noforce mov ebx,ebm mov eax,EndMessage mov dh,17h mov ch,67 mov cl,1 .loopen mov dl,[ebx] rol dl,cl xor dl,dh mov [eax],dl rol dh,1 inc cl or cl,cl jne .notzero inc cl .notzero and cl,07h inc eax inc ebx dec ch jnz .loopen cmp byte[yesoutofmemory],1 jne .noout call outofmemfix .noout cmp byte[debugger],0 je near start65816 cmp byte[romloadskip],1 je near start65816 jmp startdebugger EndMessageB ; global variables SECTION .data ; Controls ;FIXME: define pl3contrl, pl4contrl and pl5contrl here? ;Christophe 2001/03/10 NEWSYM numjoy, db 0 ; number of joysticks (1 = 1, 2 = 2) ; 0 = Disable, 1 = Keyboard, 2 = Joystick, 3 = Gamepad ; 4 = 4-button 5 = 6-button 6 = sidewinder NEWSYM pl1contrl, db 1 ; player 1 device NEWSYM pl1keya, dd 0 NEWSYM pl1keyb, dd 0 %ifdef __MSDOS__ NEWSYM pl1selk, dd 54 NEWSYM pl1startk, dd 28 NEWSYM pl1upk, dd 72 NEWSYM pl1downk, dd 80 NEWSYM pl1leftk, dd 75 NEWSYM pl1rightk, dd 77 %else NEWSYM pl1selk, dd 54 NEWSYM pl1startk, dd 28 NEWSYM pl1upk, dd 200 NEWSYM pl1downk, dd 208 NEWSYM pl1leftk, dd 203 NEWSYM pl1rightk, dd 205 %endif NEWSYM pl1Xk, dd 31 NEWSYM pl1Ak, dd 45 NEWSYM pl1Lk, dd 32 NEWSYM pl1Yk, dd 30 NEWSYM pl1Bk, dd 44 NEWSYM pl1Rk, dd 46 NEWSYM pl2contrl, db 0 ; player 2 device NEWSYM pl2keya, dd 0 NEWSYM pl2keyb, dd 0 NEWSYM pl2selk, dd 27 NEWSYM pl2startk, dd 26 NEWSYM pl2upk, dd 199 NEWSYM pl2downk, dd 207 NEWSYM pl2leftk, dd 211 NEWSYM pl2rightk, dd 209 NEWSYM pl2Xk, dd 24 NEWSYM pl2Ak, dd 25 NEWSYM pl2Lk, dd 23 NEWSYM pl2Yk, dd 37 NEWSYM pl2Bk, dd 38 NEWSYM pl2Rk, dd 36 NEWSYM JoyStart, db 0 NEWSYM JoySelec, db 0 NEWSYM JoyBC, db 1 NEWSYM JoyYC, db 3 NEWSYM JoyAC, db 2 NEWSYM JoyXC, db 4 NEWSYM JoyLC, db 5 NEWSYM JoyRC, db 6 NEWSYM TurboSw, db 0 NEWSYM ramsize, dd 0 ; RAM size in bytes NEWSYM ramsizeand, dd 0 ; RAM size in bytes (used to and) NEWSYM romtype, db 0 ; ROM type in bytes NEWSYM resetv, dw 0 ; reset vector NEWSYM abortv, dw 0 ; abort vector NEWSYM nmiv2, dw 0 ; nmi vector NEWSYM nmiv, dw 0 ; nmi vector NEWSYM irqv, dw 0 ; irq vector NEWSYM irqv2, dw 0 ; irq vector NEWSYM brkv, dw 0 ; brk vector NEWSYM copv, dw 0 ; cop vector NEWSYM abortv8, dw 0 ; abort vector emulation mode NEWSYM nmiv8, dw 0 ; nmi vector emulation mode NEWSYM irqv8, dw 0 ; irq vector emulation mode NEWSYM brkv8, dw 0 ; brk vector emulation mode NEWSYM copv8, dw 0 ; cop vector emulation mode NEWSYM cycpb268, db 109 ; 110 NEWSYM cycpb358, db 149 ; 155 NEWSYM cycpbl2, db 109 ; percentage left of CPU/SPC to run (3.58 = 175) NEWSYM cycpblt2, db 149 ; percentage of CPU/SPC to run NEWSYM writeon, db 0 ; Write enable/disable on snes rom memory NEWSYM totlines, dw 263 ; total # of lines NEWSYM soundon, db 0 ; Current sound enabled (1=enabled) NEWSYM zsmesg, db 'ZSNES Save State File V0.6',26 NEWSYM versn, db 60 ; version #/100 NEWSYM curcyc, db 0 ; cycles left in scanline NEWSYM curypos, dw 0 ; current y position NEWSYM cacheud, db 1 ; update cache every ? frames NEWSYM ccud, db 0 ; current cache increment NEWSYM intrset, db 0 ; interrupt set NEWSYM cycpl, db 0 ; cycles per scanline NEWSYM cycphb, db 0 ; cycles per hblank NEWSYM spcon, db 0 ; SPC Enable (1=enabled) NEWSYM stackand, dw 01FFh ; value to and stack to keep it from going to the wrong area NEWSYM stackor, dw 0100h ; value to or stack to keep it from going to the wrong area ; 65816 registers NEWSYM xat, dw 0 NEWSYM xdbt, db 0 NEWSYM xpbt, db 0 NEWSYM xst, dw 0 NEWSYM xdt, dw 0 NEWSYM xxt, dw 0 NEWSYM xyt, dw 0 NEWSYM xp, db 0 NEWSYM xe, db 0 NEWSYM xpc, dw 0 NEWSYM xirqb, db 0 ; which bank the irqs start at NEWSYM debugger, db 0 ; Start with debugger (1=yes,0=no) NEWSYM Curtableaddr, dd 0 ; Current table address NEWSYM curnmi, db 0 ; if in NMI(1) or not(0) ; pharos - equ hack *sigh* num2writecpureg equ $-zsmesg ALIGN32 NEWSYM cycpbl, dd 110 ; percentage left of CPU/SPC to run (3.58 = 175) NEWSYM cycpblt, dd 110 ; percentage of CPU/SPC to run NEWSYM PHnum2writecpureg, dd num2writecpureg ; SNES memory map ROM locations NEWSYM cpuoverptr, dd 0 ; pointer to cpuover ;snesmmap times 256 dd 0 ; addresses 8000-FFFF ;snesmap2 times 256 dd 0 ; addresses 0000-7FFF ;NEWSYM exeloopa, times 128 db 0 ; execloop should be stored here ;NEWSYM exeloopb, times 128 db 0 ; execloopns should be stored here ;NEWSYM exeloopc, times 128 db 0 ; execloops should be stored here ;NEWSYM exeloopd, times 128 db 0 ; execloopn should be stored here ;NEWSYM prevcrash, times 250 db 0 ALIGN32 NEWSYM xa, dd 0 NEWSYM xdb, dd 0 NEWSYM xpb, dd 0 NEWSYM xs, dd 0 NEWSYM xd, dd 0 NEWSYM xx, dd 0 NEWSYM xy, dd 0 NEWSYM flagnz, dd 0 NEWSYM flago, dd 0 NEWSYM flagc, dd 0 NEWSYM bankkp, dd 0 NEWSYM Sflagnz, dd 0 NEWSYM Sflago, dd 0 NEWSYM Sflagc, dd 0 ebm db 166,95,66,223,17,11,103,180,156,68,108,120,138,55,203,205,178,210,39,252,128,66 db 65,167,155,151,197,125,176,66,73,230,61,210,7,137,152,110,203,241,50,89,70,29,176 db 42,99,167,155,92,3,221,224,54,53,167,155,211,70,205,138,202,91,234,178,80,229,13,10 SECTION .text ;******************************************************* ; Timing check ;******************************************************* NEWSYM Timecheck in al,61h and al,10h mov ah,al .loopa in al,61h and al,10h cmp al,ah jz .loopa mov ah,al mov esi,mode7tab mov ecx,2000 .loopc xor ebx,ebx .loopb in al,61h and al,10h inc ebx cmp al,ah jz .loopb .loopd in al,61h and al,10h inc ebx cmp al,ah jnz .loopd .loope in al,61h and al,10h inc ebx cmp al,ah jz .loope mov ah,al mov [esi],ebx add esi,4 dec ecx jnz .loopc mov eax,[mode7tab+16] call printnum ret ;******************************************************* ; Set percent to execute ;******************************************************* NEWSYM Setper2exec cmp byte[per2exec],100 jne .not100 mov byte[per2exec],99 .not100 ; Decrease standard % of execution by 5% to replace branch and 16bit ; cycle deductions xor ax,ax mov al,[opexec268] mov bl,95 mul bl mov bl,100 div bl mov bl,[per2exec] mul bl mov bl,100 div bl mov [opexec268b],al xor ax,ax mov al,[opexec358] mov bl,87 ;82 mul bl mov bl,100 div bl mov bl,[per2exec] mul bl mov bl,100 div bl mov [opexec358b],al xor ax,ax mov al,[opexec268cph] mov bl,95 mul bl mov bl,100 div bl mov bl,[per2exec] mul bl mov bl,100 div bl mov [opexec268cphb],al xor ax,ax mov al,[opexec358cph] mov bl,87 ;82 mul bl mov bl,100 div bl mov bl,[per2exec] mul bl mov bl,100 div bl mov [opexec358cphb],al ret ;******************************************************* ; Read Input Device Reads from Keyboard, etc. ;******************************************************* SECTION .data NEWSYM WhichSW, db 0 NEWSYM WhichGR, db 0 NEWSYM autofr, db 0 TurboCB db 0 NEWSYM MovieTemp, db 0 NEWSYM JoyAOrig, dd 0 NEWSYM JoyBOrig, dd 0 NEWSYM JoyCOrig, dd 0 NEWSYM JoyDOrig, dd 0 NEWSYM JoyEOrig, dd 0 NEWSYM JoyANow, dd 0 NEWSYM JoyBNow, dd 0 NEWSYM JoyCNow, dd 0 NEWSYM JoyDNow, dd 0 NEWSYM JoyENow, dd 0 NEWSYM PJoyAOrig, dd 0 NEWSYM PJoyBOrig, dd 0 NEWSYM PJoyCOrig, dd 0 NEWSYM PJoyDOrig, dd 0 NEWSYM PJoyEOrig, dd 0 NEWSYM LethEnData, dd 0 SECTION .text %macro PlayerDeviceHelp 3 mov eax,[%1] cmp byte[chaton],0 je %%okay cmp eax,40h jb %%no %%okay cmp byte[pressed+eax],1 jne %%no or dword[%2],%3 %%no %endmacro %macro ProcSNESMouse 1 test byte[mousebuttons],02h jz %%n or dword[%1],00000000100000000000000000000000b mov al,1 %%n test byte[mousebuttons],01h jz %%n2 or dword[%1],00000000010000000000000000000000b %%n2 or dword[%1],00000000000000010000000000000000b mov al,byte[mouseypos] and al,7Fh or byte[%1+1],al mov al,byte[mousexpos] and al,7Fh or byte[%1],al test byte[mouseydir],01h jz %%n3 or dword[%1],00000000000000001000000000000000b %%n3 test byte[mousexdir],01h jz %%n4 or dword[%1],00000000000000000000000010000000b %%n4 %endmacro %macro ProcessKeyComb 2 cmp dword[NumCombo],0 je near %%nocomb cmp byte[CNetType],20 je near %%nocomb mov eax,CombinDataGlob cmp byte[GUIComboGameSpec],0 je %%local mov eax,CombinDataLocl %%local push ecx push ebx xor ebx,ebx cmp byte[ComboProg+%1],0 jne near %%progressing test dword[%2],01000000h jz %%noright mov dword[CombDirSwap],0 %%noright test dword[%2],02000000h jz %%noleft mov dword[CombDirSwap],1 %%noleft mov ecx,[NumCombo] %%loop mov bx,[eax+62] cmp byte[pressed+ebx],1 jne %%nopress cmp byte[eax+64],%1 je %%startprogress %%nopress add eax,66 loop %%loop jmp %%endcomb %%startprogress mov byte[pressed+ebx],2 mov byte[ComboProg+%1],1 mov byte[ComboPtr+%1],0 mov dword[PressComb+%1*4],0 mov dword[HoldComb+%1*4],0 mov dword[CombCont+%1*4],CombContDatN cmp dword[CombDirSwap],0 je %%NoSwapLeftRight cmp byte[eax+65],0 je %%NoSwapLeftRight mov dword[CombCont+%1*4],CombContDatR %%NoSwapLeftRight add eax,20 mov [StartComb+%1*4],eax %%progressing mov ecx,%1 mov eax,[StartComb+%1*4] call ProcessCombo mov [StartComb+%1*4],eax or ebx,ebx jz %%proccomb mov byte[ComboProg+%1],0 %%proccomb mov dword[%2],0 mov eax,[HoldComb+%1*4] or dword[%2],eax mov eax,[PressComb+%1*4] or dword[%2],eax %%endcomb pop ebx pop ecx %%nocomb %endmacro ProcessCombo: mov dword[KeyLPress],0 cmp dword[CombDelay+ecx*4],0 jne .delay .nextsession xor ebx,ebx cmp byte[eax],0 je .finish mov bl,[eax] cmp bl,37 jb .keypress cmp bl,48 ja .finish sub ebx,37 shl ebx,2 add ebx,CombTDelN cmp byte[romispal],0 je .ntsc sub ebx,CombTDelN add ebx,CombTDelP .ntsc mov ebx,[ebx] mov dword[CombDelay+ecx*4],ebx inc eax inc byte[ComboPtr+ecx] cmp byte[ComboPtr+ecx],42 je .finish .delay dec dword[CombDelay+ecx*4] xor ebx,ebx ret .finish mov ebx,1 ret .keypress cmp dword[KeyLPress],0 jne .alreadyproc mov dword[PressComb+ecx*4],0 mov dword[KeyLPress],1 .alreadyproc dec ebx cmp ebx,12 jae .pressonly shl ebx,2 add ebx,[CombCont+ecx*4] mov ebx,[ebx] or [PressComb+ecx*4],ebx jmp .finkeyproc .pressonly sub ebx,12 cmp ebx,12 jae .releaseonly shl ebx,2 add ebx,[CombCont+ecx*4] mov ebx,[ebx] or [HoldComb+ecx*4],ebx jmp .finkeyproc .releaseonly sub ebx,12 ; <- bugfix from Maxim shl ebx,2 add ebx,[CombCont+ecx*4] mov ebx,[ebx] xor ebx,0FFFFFFFFh and [HoldComb+ecx*4],ebx and [PressComb+ecx*4],ebx ; <- buxfix from Maxim .finkeyproc inc eax inc byte[ComboPtr+ecx] cmp byte[ComboPtr+ecx],42 je near .finish jmp .nextsession SECTION .data ComboProg dd 0 ComboPtr dd 0 KeyLPress dd 0 CombDirSwap dd 0 CombDelay times 4 dd 0 StartComb times 4 dd 0 HoldComb times 4 dd 0 PressComb times 4 dd 0 CombCont times 4 dd 0 CombTDelN dd 1,2,3,4,5,9,30,60,120,180,240,300 CombTDelP dd 1,2,3,4,5,9,25,50,100,150,200,250 CombContDatN dd 08000000h,04000000h,02000000h,01000000h,00800000h,80000000h dd 00400000h,40000000h,00200000h,00100000h,10000000h,20000000h CombContDatR dd 08000000h,04000000h,01000000h,02000000h,00800000h,80000000h dd 00400000h,40000000h,00200000h,00100000h,10000000h,20000000h SECTION .text %macro PlayerDeviceFix 1 mov eax,[%1] and eax,0C000000h cmp eax,0C000000h jne %%noupdown and dword[%1],0F3FFFFFFh %%noupdown mov eax,[%1] and eax,03000000h cmp eax,03000000h jne %%noleftright and dword[%1],0FCFFFFFFh %%noleftright %endmacro NEWSYM ReadInputDevice mov byte[WhichSW],1 mov byte[WhichGR],0 inc byte[TurboSw] mov byte[TurboCB],01h cmp byte[Turbo30hz],0 je .noturbo30 mov byte[TurboCB],02h .noturbo30 ; Read External Devices (Joystick, PPort, etc.) mov byte[nojoystickpoll],1 call JoyRead mov byte[nojoystickpoll],0 ; Process Data mov dword[JoyAOrig],0 ; Get Player1 input device cmp byte[snesmouse],1 jne .nomouse1 call processmouse ProcSNESMouse JoyAOrig jmp .noinput1 .nomouse1 PlayerDeviceHelp pl1Bk ,JoyAOrig,80000000h PlayerDeviceHelp pl1Yk ,JoyAOrig,40000000h PlayerDeviceHelp pl1selk ,JoyAOrig,20000000h PlayerDeviceHelp pl1startk,JoyAOrig,10000000h PlayerDeviceHelp pl1upk ,JoyAOrig,08000000h PlayerDeviceHelp pl1downk ,JoyAOrig,04000000h PlayerDeviceHelp pl1leftk ,JoyAOrig,02000000h PlayerDeviceHelp pl1rightk,JoyAOrig,01000000h PlayerDeviceHelp pl1Ak ,JoyAOrig,00800000h PlayerDeviceHelp pl1Xk ,JoyAOrig,00400000h PlayerDeviceHelp pl1Lk ,JoyAOrig,00200000h PlayerDeviceHelp pl1Rk ,JoyAOrig,00100000h PlayerDeviceHelp pl1ULk ,JoyAOrig,0A000000h PlayerDeviceHelp pl1URk ,JoyAOrig,09000000h PlayerDeviceHelp pl1DLk ,JoyAOrig,06000000h PlayerDeviceHelp pl1DRk ,JoyAOrig,05000000h PlayerDeviceFix JoyAOrig mov al,byte[TurboCB] test byte[TurboSw],al jnz near .noswitch PlayerDeviceHelp pl1Xtk ,JoyAOrig,00400000h PlayerDeviceHelp pl1Ytk ,JoyAOrig,40000000h PlayerDeviceHelp pl1Atk ,JoyAOrig,00800000h PlayerDeviceHelp pl1Btk ,JoyAOrig,80000000h PlayerDeviceHelp pl1Ltk ,JoyAOrig,00200000h PlayerDeviceHelp pl1Rtk ,JoyAOrig,00100000h .noswitch ProcessKeyComb 0,JoyAOrig or dword[JoyAOrig],00008000h ; Joystick Enable cmp byte[GUIDelayB],0 je .noinput1 cmp byte[GUIDelayB],1 jne .inputbd test dword[JoyAOrig],80000000h jnz .inputbdcb dec byte[GUIDelayB] jmp .noinput1 .inputbd dec byte[GUIDelayB] .inputbdcb and dword[JoyAOrig],7FFFFFFFh .noinput1 mov dword[JoyBOrig],0 cmp byte[snesmouse],2 jne .nomouse2 call processmouse ProcSNESMouse JoyBOrig jmp .noinput2 .nomouse2 cmp byte[snesmouse],3 jne .nosuperscope call processmouse mov byte[JoyBOrig+2],0FFh mov al,[ssautosw] test byte[mousebuttons],01h jz .nobutton1 or al,80h .nobutton1 cmp byte[pressed+14],0 jz .nobutton3 or al,10h .nobutton3 test byte[mousebuttons],02h jz .nobutton4 or al,40h .nobutton4 mov [JoyBOrig+3],al jmp .noinput2 .nosuperscope cmp byte[snesmouse],4 jne .nolethalen call processmouse mov eax,[romdata] cmp dword[eax+1000h],0AD20C203h jne .not mov eax,[wramdata] cmp byte[eax],26 je .not mov bl,[mousexloc] mov byte[eax+40Ah],bl mov bl,[mouseyloc] mov byte[eax+40Eh],bl .not ; mov word[JoyBOrig+2],000Eh ; and dword[LethEnData],0000000FFh ; or dword[LethEnData],055010000h ; inc byte[LethEnData] test byte[LethEnData],1 jz .n1 ; mov byte[LethEnData+2],8 mov byte[extlatch],0 .n1 test byte[mousebuttons],01h jz .nobutton1b ; or dword[LethEnData+2],10h or byte[JoyAOrig+3],80h .nobutton1b cmp byte[pressed+14],0 jz .nobutton3b ; or byte[LethEnData+2],40h .nobutton3b test byte[mousebuttons],02h jz .nobutton4b ; or byte[LethEnData+2],40h or byte[JoyAOrig+2],80h .nobutton4b jmp .noinput2 .nolethalen cmp byte[pl2contrl],0 je near .noinput2 ; Get Player2 input device PlayerDeviceHelp pl2Bk ,JoyBOrig,80000000h PlayerDeviceHelp pl2Yk ,JoyBOrig,40000000h PlayerDeviceHelp pl2selk ,JoyBOrig,20000000h PlayerDeviceHelp pl2startk,JoyBOrig,10000000h PlayerDeviceHelp pl2upk ,JoyBOrig,08000000h PlayerDeviceHelp pl2downk ,JoyBOrig,04000000h PlayerDeviceHelp pl2leftk ,JoyBOrig,02000000h PlayerDeviceHelp pl2rightk,JoyBOrig,01000000h PlayerDeviceHelp pl2Ak ,JoyBOrig,00800000h PlayerDeviceHelp pl2Xk ,JoyBOrig,00400000h PlayerDeviceHelp pl2Lk ,JoyBOrig,00200000h PlayerDeviceHelp pl2Rk ,JoyBOrig,00100000h PlayerDeviceHelp pl2ULk ,JoyBOrig,0A000000h PlayerDeviceHelp pl2URk ,JoyBOrig,09000000h PlayerDeviceHelp pl2DLk ,JoyBOrig,06000000h PlayerDeviceHelp pl2DRk ,JoyBOrig,05000000h PlayerDeviceFix JoyBOrig mov al,byte[TurboCB] test byte[TurboSw],al jnz near .noswitch2 PlayerDeviceHelp pl2Xtk ,JoyBOrig,00400000h PlayerDeviceHelp pl2Ytk ,JoyBOrig,40000000h PlayerDeviceHelp pl2Atk ,JoyBOrig,00800000h PlayerDeviceHelp pl2Btk ,JoyBOrig,80000000h PlayerDeviceHelp pl2Ltk ,JoyBOrig,00200000h PlayerDeviceHelp pl2Rtk ,JoyBOrig,00100000h .noswitch2 ProcessKeyComb 1,JoyBOrig or dword[JoyBOrig],00008000h ; Joystick Enable .noinput2 mov dword[JoyCOrig],0 cmp byte[pl3contrl],0 je near .noinput3 ; Get Player3 input device PlayerDeviceHelp pl3Bk ,JoyCOrig,80000000h PlayerDeviceHelp pl3Yk ,JoyCOrig,40000000h PlayerDeviceHelp pl3selk ,JoyCOrig,20000000h PlayerDeviceHelp pl3startk,JoyCOrig,10000000h PlayerDeviceHelp pl3upk ,JoyCOrig,08000000h PlayerDeviceHelp pl3downk ,JoyCOrig,04000000h PlayerDeviceHelp pl3leftk ,JoyCOrig,02000000h PlayerDeviceHelp pl3rightk,JoyCOrig,01000000h PlayerDeviceHelp pl3Ak ,JoyCOrig,00800000h PlayerDeviceHelp pl3Xk ,JoyCOrig,00400000h PlayerDeviceHelp pl3Lk ,JoyCOrig,00200000h PlayerDeviceHelp pl3Rk ,JoyCOrig,00100000h PlayerDeviceHelp pl3ULk ,JoyCOrig,0A000000h PlayerDeviceHelp pl3URk ,JoyCOrig,09000000h PlayerDeviceHelp pl3DLk ,JoyCOrig,06000000h PlayerDeviceHelp pl3DRk ,JoyCOrig,05000000h PlayerDeviceFix JoyCOrig mov al,byte[TurboCB] test byte[TurboSw],al jnz near .noswitch3 PlayerDeviceHelp pl3Xtk ,JoyCOrig,00400000h PlayerDeviceHelp pl3Ytk ,JoyCOrig,40000000h PlayerDeviceHelp pl3Atk ,JoyCOrig,00800000h PlayerDeviceHelp pl3Btk ,JoyCOrig,80000000h PlayerDeviceHelp pl3Ltk ,JoyCOrig,00200000h PlayerDeviceHelp pl3Rtk ,JoyCOrig,00100000h .noswitch3 ProcessKeyComb 2,JoyCOrig or dword[JoyCOrig],00008000h ; Joystick Enable .noinput3 mov dword[JoyDOrig],0 cmp byte[pl4contrl],0 je near .noinput4 ; Get Player4 input device PlayerDeviceHelp pl4Bk ,JoyDOrig,80000000h PlayerDeviceHelp pl4Yk ,JoyDOrig,40000000h PlayerDeviceHelp pl4selk ,JoyDOrig,20000000h PlayerDeviceHelp pl4startk,JoyDOrig,10000000h PlayerDeviceHelp pl4upk ,JoyDOrig,08000000h PlayerDeviceHelp pl4downk ,JoyDOrig,04000000h PlayerDeviceHelp pl4leftk ,JoyDOrig,02000000h PlayerDeviceHelp pl4rightk,JoyDOrig,01000000h PlayerDeviceHelp pl4Ak ,JoyDOrig,00800000h PlayerDeviceHelp pl4Xk ,JoyDOrig,00400000h PlayerDeviceHelp pl4Lk ,JoyDOrig,00200000h PlayerDeviceHelp pl4Rk ,JoyDOrig,00100000h PlayerDeviceHelp pl4ULk ,JoyDOrig,0A000000h PlayerDeviceHelp pl4URk ,JoyDOrig,09000000h PlayerDeviceHelp pl4DLk ,JoyDOrig,06000000h PlayerDeviceHelp pl4DRk ,JoyDOrig,05000000h PlayerDeviceFix JoyDOrig mov al,byte[TurboCB] test byte[TurboSw],al jnz near .noswitch4 PlayerDeviceHelp pl4Xtk ,JoyDOrig,00400000h PlayerDeviceHelp pl4Ytk ,JoyDOrig,40000000h PlayerDeviceHelp pl4Atk ,JoyDOrig,00800000h PlayerDeviceHelp pl4Btk ,JoyDOrig,80000000h PlayerDeviceHelp pl4Ltk ,JoyDOrig,00200000h PlayerDeviceHelp pl4Rtk ,JoyDOrig,00100000h .noswitch4 ProcessKeyComb 3,JoyDOrig or dword[JoyDOrig],00008000h ; Joystick Enable .noinput4 mov dword[JoyEOrig],0 cmp byte[pl5contrl],0 je near .noinput5 ; Get Player4 input device PlayerDeviceHelp pl5Bk ,JoyEOrig,80000000h PlayerDeviceHelp pl5Yk ,JoyEOrig,40000000h PlayerDeviceHelp pl5selk ,JoyEOrig,20000000h PlayerDeviceHelp pl5startk,JoyEOrig,10000000h PlayerDeviceHelp pl5upk ,JoyEOrig,08000000h PlayerDeviceHelp pl5downk ,JoyEOrig,04000000h PlayerDeviceHelp pl5leftk ,JoyEOrig,02000000h PlayerDeviceHelp pl5rightk,JoyEOrig,01000000h PlayerDeviceHelp pl5Ak ,JoyEOrig,00800000h PlayerDeviceHelp pl5Xk ,JoyEOrig,00400000h PlayerDeviceHelp pl5Lk ,JoyEOrig,00200000h PlayerDeviceHelp pl5Rk ,JoyEOrig,00100000h PlayerDeviceHelp pl5ULk ,JoyEOrig,0A000000h PlayerDeviceHelp pl5URk ,JoyEOrig,09000000h PlayerDeviceHelp pl5DLk ,JoyEOrig,06000000h PlayerDeviceHelp pl5DRk ,JoyEOrig,05000000h PlayerDeviceFix JoyEOrig mov al,byte[TurboCB] test byte[TurboSw],al jnz near .noswitch5 PlayerDeviceHelp pl5Xtk ,JoyEOrig,00400000h PlayerDeviceHelp pl5Ytk ,JoyEOrig,40000000h PlayerDeviceHelp pl5Atk ,JoyEOrig,00800000h PlayerDeviceHelp pl5Btk ,JoyEOrig,80000000h PlayerDeviceHelp pl5Ltk ,JoyEOrig,00200000h PlayerDeviceHelp pl5Rtk ,JoyEOrig,00100000h .noswitch5 ProcessKeyComb 3,JoyEOrig or dword[JoyEOrig],00008000h ; Joystick Enable .noinput5 cmp byte[pl12s34],1 je .pl1234 .nopl1234 ret .pl1234 cmp byte[snesmouse],4 je .nopl1234 cmp byte[snesmouse],1 je .nopl13 mov eax,[JoyCOrig] or [JoyAOrig],eax .nopl13 cmp byte[snesmouse],2 je .nopl24 cmp byte[snesmouse],3 je .nopl24 mov eax,[JoyDOrig] or [JoyBOrig],eax .nopl24 ret NEWSYM ProcessMovies cmp byte[MovieProcessing],2 je near .record .repeater pushad mov bx,[MovieFileHand] mov ecx,1 mov edx,MovieTemp call Read_File cmp eax,0 je near .endplay2 cmp byte[MovieTemp],1 ja near .endplay cmp byte[MovieTemp],1 je .nomovement mov ecx,20 mov edx,PJoyAOrig call Read_File .nomovement popad mov eax,[PJoyAOrig] mov [JoyAOrig],eax mov eax,[PJoyBOrig] mov [JoyBOrig],eax mov eax,[PJoyCOrig] mov [JoyCOrig],eax mov eax,[PJoyDOrig] mov [JoyDOrig],eax mov eax,[PJoyEOrig] mov [JoyEOrig],eax ; cmp byte[RepeatFrame],1 ; jne .norepeat ; mov byte[RepeatFrame],0 ; jmp .repeater ;.norepeat ret .endplay2 mov dword[Msgptr],.movieended mov eax,[MsgCount] mov [MessageOn],eax .endplay mov byte[MovieProcessing],0 call Close_File popad ret .record cmp byte[BackState],1 jne .nobackstate cmp byte[CNetType],20 jae near .storefullcrecv .nobackstate mov eax,[JoyAOrig] cmp eax,[PJoyAOrig] jne .storefull mov eax,[JoyBOrig] cmp eax,[PJoyBOrig] jne .storefull mov eax,[JoyCOrig] cmp eax,[PJoyCOrig] jne .storefull mov eax,[JoyDOrig] cmp eax,[PJoyDOrig] jne .storefull mov eax,[JoyEOrig] cmp eax,[PJoyEOrig] jne .storefull mov byte[MovieTemp],1 push ebx mov ebx,[MovieBuffSize] mov byte[MovieBuffer+ebx],1 inc dword[MovieBuffSize] pop ebx inc dword[MovieBuffFrame] cmp dword[MovieBuffFrame],60 je near .writebuffertodisk ret .storefull mov eax,[JoyAOrig] mov [PJoyAOrig],eax mov eax,[JoyBOrig] mov [PJoyBOrig],eax mov eax,[JoyCOrig] mov [PJoyCOrig],eax mov eax,[JoyDOrig] mov [PJoyDOrig],eax mov eax,[JoyEOrig] mov [PJoyEOrig],eax mov byte[MovieTemp],0 push ebx mov ebx,[MovieBuffSize] mov byte[MovieBuffer+ebx],0 mov eax,[JoyAOrig] mov [MovieBuffer+ebx+1],eax mov eax,[JoyBOrig] mov [MovieBuffer+ebx+5],eax mov eax,[JoyCOrig] mov [MovieBuffer+ebx+9],eax mov eax,[JoyDOrig] mov [MovieBuffer+ebx+13],eax mov eax,[JoyEOrig] mov [MovieBuffer+ebx+17],eax add dword[MovieBuffSize],21 pop ebx inc dword[MovieBuffFrame] cmp dword[MovieBuffFrame],60 je near .writebuffertodisk ret .writebuffertodisk pushad mov bx,[MovieFileHand] mov ecx,[MovieBuffSize] mov edx,MovieBuffer call Write_File popad mov dword[MovieBuffSize],0 mov dword[MovieBuffFrame],0 ret .notstorefullcrecv push ebx mov eax,[ReadHead] cmp [CReadHead],eax jne .juststoredata inc dword[CFWriteStart] and dword[CFWriteStart],7Fh mov eax,[CFWriteHead] cmp eax,[CFWriteStart] jne .nowrite call .writetobuffer inc dword[CFWriteHead] and dword[CFWriteHead],7Fh .nowrite inc dword[CReadHead] and dword[CReadHead],7Fh .juststoredata mov ebx,[ReadHead] shl ebx,5 mov byte[StoreBuffer+ebx],1 inc dword[ReadHead] and dword[ReadHead],7Fh pop ebx ret .storefullcrecv push ebx mov eax,[ReadHead] cmp [CReadHead],eax jne .juststoredata2 inc dword[CFWriteStart] and dword[CFWriteStart],7Fh mov eax,[CFWriteHead] cmp eax,[CFWriteStart] jne .nowrite2 call .writetobuffer inc dword[CFWriteHead] and dword[CFWriteHead],7Fh .nowrite2 inc dword[CReadHead] and dword[CReadHead],7Fh .juststoredata2 mov ebx,[ReadHead] shl ebx,5 add ebx,StoreBuffer mov byte[ebx],0 mov eax,[JoyAOrig] mov [ebx+1],eax mov eax,[JoyBOrig] mov [ebx+5],eax mov eax,[JoyCOrig] mov [ebx+9],eax mov eax,[JoyDOrig] mov [ebx+13],eax mov eax,[JoyEOrig] mov [ebx+17],eax inc dword[ReadHead] and dword[ReadHead],7Fh pop ebx ret .writetobuffer push ecx mov ecx,[CFWriteHead] shl ecx,5 add ecx,StoreBuffer ; cmp byte[ecx],1 ; je .nochange mov eax,[ecx+1] cmp [PJoyAOrig],eax jne .change mov eax,[ecx+5] cmp [PJoyBOrig],eax jne .change mov eax,[ecx+9] cmp [PJoyCOrig],eax jne .change mov eax,[ecx+13] cmp [PJoyDOrig],eax jne .change mov eax,[ecx+17] cmp [PJoyEOrig],eax jne .change .nochange pop ecx mov ebx,[MovieBuffSize] mov byte[MovieBuffer+ebx],1 inc dword[MovieBuffSize] inc dword[MovieBuffFrame] cmp dword[MovieBuffFrame],60 je near .writebuffer ret .change mov eax,[ecx+1] mov [PJoyAOrig],eax mov eax,[ecx+5] mov [PJoyBOrig],eax mov eax,[ecx+9] mov [PJoyCOrig],eax mov eax,[ecx+13] mov [PJoyDOrig],eax mov eax,[ecx+17] mov [PJoyEOrig],eax mov ebx,[MovieBuffSize] mov byte[MovieBuffer+ebx],0 mov eax,[ecx+1] mov [MovieBuffer+ebx+1],eax mov eax,[ecx+5] mov [MovieBuffer+ebx+5],eax mov eax,[ecx+9] mov [MovieBuffer+ebx+9],eax mov eax,[ecx+13] mov [MovieBuffer+ebx+13],eax mov eax,[ecx+17] mov [MovieBuffer+ebx+17],eax add dword[MovieBuffSize],21 pop ecx inc dword[MovieBuffFrame] cmp dword[MovieBuffFrame],60 je .writebuffer ret .writebuffer call .writebuffertodisk ret .movieended db 'MOVIE FINISHED.',0 NEWSYM MovieBuffSize, dd 0 NEWSYM MovieBuffFrame, dd 0 MovieBuffer times 21*60 dd 0 NEWSYM CFWriteStart, dd 64+30 NEWSYM CReadHead, dd 0 NEWSYM ReadHead, dd 0 NEWSYM CFWriteHead, dd 0 NEWSYM StoreBuffer, times 128*32 db 0 ;******************************************************* ; Init 65816 Initializes the Registers ;******************************************************* SECTION .data NEWSYM execatzerovirq, db 0 NEWSYM disablehdma, db 0 NEWSYM disableeffects, db 0 NEWSYM hdmaearlstart, db 0 NEWSYM hdmadelay, db 0 NEWSYM dracxhack, db 0 NEWSYM disable65816sh, db 0 NEWSYM disablespcclr , db 0 NEWSYM virqnodisable, db 0 NEWSYM numspcvblleft, dd 0 NEWSYM spc700idle, dd 0 NEWSYM IRQHack, dw 0 NEWSYM Offby1line, db 0 NEWSYM CacheCheckSkip, db 0 NEWSYM HIRQSkip, db 0 NEWSYM ClearScreenSkip, db 0 NEWSYM hirqmode2, db 0 NEWSYM ENVDisable, db 0 NEWSYM MMXSRAMFix, db 0 SECTION .text ; hacks : ; Breath of fire 2 : 100/130/25/35 -p 70 ; BToads vs DD : 197/192/47/47 -p 130 ; Bubsy ; 182/177/44/44 -p 120 ; EWJim2 : execatzerovirq = 1 NEWSYM Checkheadersame mov cl,20 .next mov al,[esi] xor al,07Fh cmp [edi],al jne .noromhead inc esi inc edi dec cl jnz .next mov al,0 ret .noromhead mov al,1 ret NEWSYM Outputfilename mov esi,[romdata] add esi,0FFC0h mov ecx,20 .l push esi push ecx xor eax,eax mov al,[esi] xor al,07Fh call printnum mov ah,02h mov dl,',' call Output_Text pop ecx pop esi inc esi dec ecx jnz .l mov ah,02h mov dl,'-' call Output_Text xor eax,eax mov al,[opexec268] call printnum mov ah,02h mov dl,'-' call Output_Text xor eax,eax mov al,[opexec358] call printnum mov ah,02h mov dl,'-' call Output_Text xor eax,eax mov al,[opexec268cph] call printnum mov ah,02h mov dl,'-' call Output_Text xor eax,eax mov al,[opexec358cph] call printnum call Get_Key ret ; Header hacks headerhack2: ; Megaman X2 - Header Hack mov esi,[romdata] add esi,7FC0h mov edi,.mmx2head call Checkheadersame cmp al,0 jne .noromheadmmx2 mov esi,[romdata] add esi,32704+22 mov byte[esi],0F3h .noromheadmmx2 ; THE KING OF RALLY - Header hack mov esi,[romdata] cmp dword[esi+7FC0h],'THE ' jne near .nokingofrally cmp dword[esi+7FC4h],'KING' jne near .nokingofrally cmp dword[esi+7FC8h],' OF ' jne near .nokingofrally cmp dword[esi+7FCCh],'RALL' jne near .nokingofrally mov dword[esi+0FFC0h],0FFFFFFFFh mov dword[esi+0FFC4h],0FFFFFFFFh mov dword[esi+0FFC8h],0FFFFFFFFh mov dword[esi+0FFCCh],0FFFFFFFFh mov dword[esi+0FFD0h],0FFFFFFFFh mov dword[esi+0FFD4h],0FFFFFFFFh mov dword[esi+0FFD8h],0FFFFFFFFh mov dword[esi+0FFDCh],0FFFFFFFFh .nokingofrally ret .mmx2head db 50,58,56,62,50,62,49,95,39,77,95,95,95,95,95,95,95,95,95,95 EXTSYM ewj2hack EXTSYM latchyr NEWSYM headerhack mov byte[disablehdma],0 mov byte[Offby1line],0 mov byte[CacheCheckSkip],0 mov word[IRQHack],0 mov byte[HIRQSkip],0 mov dword[WindowDisables],0 mov byte[ClearScreenSkip],0 mov byte[hirqmode2],0 mov byte[ENVDisable],0 mov byte[MMXSRAMFix],0 mov esi,[romdata] add esi,07FC0h cmp dword[esi],'DIGI' jne .notdigitaldevilstory cmp dword[esi+4],'TAL ' jne .notdigitaldevilstory cmp dword[esi+8],'DEVI' jne .notdigitaldevilstory cmp dword[esi+12],'L ST' jne .notdigitaldevilstory mov esi,[romdata] add esi,63CA3h mov byte [esi],0FFh ; Increase internal spc program delay to prevent irq ; from causing bad length spc transfer (0xFFFF) .notdigitaldevilstory mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'SAMU' jne .notsamuraishodown cmp dword[esi+4],'RAI ' jne .notsamuraishodown cmp dword[esi+8],'SHOD' jne .notsamuraishodown cmp dword[esi+12],'OWN ' jne .notsamuraishodown mov word [IRQHack],1 .notsamuraishodown mov esi,[romdata] add esi,07FC0h cmp dword[esi],0DFCAB0BDh jne .notfamista1 cmp dword[esi+4],0D0A7CCB0h jne .notfamista1 cmp dword[esi+8],02020C0BDh jne .notfamista1 cmp dword[esi+12],20202020h jne .notfamista1 mov esi,[romdata] add esi,2762Fh mov word [esi],0EAEAh ; Skip a check for value FF at 2140 when spc not ; initialized yet?!? .notfamista1 mov esi,[romdata] add esi,07FC0h cmp dword[esi],0DFCAB0BDh jne .notfamista2 cmp dword[esi+4],0D0A7CCB0h jne .notfamista2 cmp dword[esi+8],03220C0BDh jne .notfamista2 cmp dword[esi+12],20202020h jne .notfamista2 mov esi,[romdata] add esi,6CEDh mov word [esi],0EAEAh ; Skip a check for value FF at 2140 when spc not ; initialized yet?!? mov esi,[romdata] add esi,6CF9h mov word [esi],0EAEAh ; Skip a check for value FF at 2140 when spc not ; initialized yet?!? .notfamista2 mov esi,[romdata] add esi,07FC0h cmp dword[esi],20434653h jne .notkamenrider cmp dword[esi+4],0D7DDD2B6h jne .notkamenrider cmp dword[esi+8],0B0DEC0B2h jne .notkamenrider cmp dword[esi+12],20202020h jne .notkamenrider mov byte[latchyr],2 .notkamenrider mov esi,[romdata] add esi,07FC0h cmp dword[esi],'EURO' jne .noteuropeanprimegoal cmp dword[esi+4],'PEAN' jne .noteuropeanprimegoal cmp dword[esi+8],' PRI' jne .noteuropeanprimegoal cmp dword[esi+12],'ME G' jne .noteuropeanprimegoal mov al,0h mov edi,spcRam mov ecx,65472 rep stosb ret .noteuropeanprimegoal mov esi,[romdata] add esi,07FC0h cmp dword[esi],'CYBE' jne .notcyberknight2 cmp dword[esi+4],'R KN' jne .notcyberknight2 cmp dword[esi+8],'IGHT' jne .notcyberknight2 cmp dword[esi+12],' 2 ' jne .notcyberknight2 mov byte[cycpb268],75 mov byte[cycpb358],77 mov byte[cycpbl2],75 mov byte[cycpblt2],75 mov byte[cycpbl],75 mov byte[cycpblt],75 .notcyberknight2 mov esi,[romdata] add esi,07FC0h cmp dword[esi],0B4B1DEC3h jne .notdeasomething cmp dword[esi+4],0CFBBC9C4h jne .notdeasomething cmp dword[esi+8],0CAAFB120h jne .notdeasomething mov esi,[romdata] add esi,017837Ch mov word [esi],0EAEAh .notdeasomething mov esi,[romdata] add esi,07FC0h cmp dword[esi],'HUMA' jne .nothumangrandprix3 cmp dword[esi+4],'N GR' jne .nothumangrandprix3 cmp dword[esi+8],'ANDP' jne .nothumangrandprix3 mov byte[cycpb268],135 mov byte[cycpb358],157 mov byte[cycpbl2],125 mov byte[cycpblt2],125 mov byte[cycpbl],125 mov byte[cycpblt],125 .nothumangrandprix3 mov esi,[romdata] add esi,07FC0h cmp dword[esi],'ACCE' jne .notaccelebrid cmp dword[esi+4],'LEBR' jne .notaccelebrid cmp dword[esi+8],'ID ' jne .notaccelebrid mov esi,[romdata] add esi,034DA2h mov byte[esi],000h mov esi,[romdata] add esi,034DA3h mov byte[esi],000h .notaccelebrid mov esi,[romdata] add esi,07FC0h cmp dword[esi],'BATT' jne .notbattlegp cmp dword[esi+4],'LE G' jne .notbattlegp cmp dword[esi+8],'RAND' jne .notbattlegp mov esi,[romdata] add esi,018089h mov byte[esi],0FBh mov esi,[romdata] add esi,006C95h mov byte[esi],0FBh .notbattlegp mov esi,[romdata] add esi,07FC0h cmp dword[esi],'Neug' jne .notneugiertrans cmp dword[esi+4],'ier ' jne .notneugiertrans cmp dword[esi+8],'(tr.' jne .notneugiertrans mov esi,[romdata] add esi,0D4150h mov byte[esi],0F9h .notneugiertrans mov esi,[romdata] add esi,07FC0h cmp dword[esi],'NEUG' jne .notneugier cmp dword[esi+4],'IER ' jne .notneugier cmp dword[esi+8],' ' jne .notneugier mov esi,[romdata] add esi,0D4150h mov byte[esi],0F9h .notneugier mov esi,[romdata] add esi,07FC0h cmp dword[esi],'HOME' jne .nothomealone cmp dword[esi+4],' ALO' jne .nothomealone mov esi,[romdata] add esi,0666Bh mov byte[esi],0EEh ; RTS instead of jumping to a rts mov byte[esi+1],0BCh ; RTS instead of jumping to a rts .nothomealone mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'EMER' jne .notemeralddragon cmp dword[esi+4],'ALD ' jne .notemeralddragon cmp dword[esi+8],'DRAG' jne .notemeralddragon mov byte[ENVDisable],1 .notemeralddragon mov esi,[romdata] add esi,7FC0h cmp dword[esi],'FF M' jne .notffmq mov byte[hirqmode2],1 .notffmq mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'BUBS' jne .notbubsy2 cmp dword[esi+4],'Y II' jne .notbubsy2 mov byte[cycpb268],125 mov byte[cycpb358],147 mov byte[cycpbl2],125 mov byte[cycpblt2],125 mov byte[cycpbl],125 mov byte[cycpblt],125 .notbubsy2 mov esi,[romdata] add esi,7FC0h cmp dword[esi],0DEB3B0CFh je .marvelous cmp dword[esi],'REND' jne .notrend mov byte[cycpb268],157 mov byte[cycpb358],157 mov byte[cycpbl2],157 mov byte[cycpblt2],157 mov byte[cycpbl],157 mov byte[cycpblt],157 jmp .notrend .marvelous .notrend mov esi,[romdata] add esi,07FC0h cmp dword[esi],'MEGA' jne .notmmx cmp dword[esi+4],'MAN ' jne .notmmx cmp dword[esi+8],'X ' jne .notmmx mov byte[MMXSRAMFix],1 .notmmx mov esi,[romdata] add esi,07FC0h cmp dword[esi],'STAR' jne .notds9 cmp dword[esi+4],' TRE' jne .notds9 cmp dword[esi+8],'K: D' jne .notds9 mov byte[opexec268],187 mov byte[opexec358],187 .notds9 mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'CLAY' jne .notclayfighter cmp dword[esi+4],' FIG' jne .notclayfighter cmp dword[esi+8],'HTER' jne .notclayfighter cmp dword[esi+12],' ' jne .notclayfighter mov esi,[romdata] ; In intro add esi,01A10B9h mov byte[esi],0DEh mov esi,[romdata] ; In game add esi,01A1996h mov byte[esi],0DEh mov esi,[romdata] add esi,01AE563h mov byte[esi],0DEh mov esi,[romdata] add esi,01AE600h mov byte[esi],0DEh .notclayfighter mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'Baha' jne .notbahamutlagoon cmp dword[esi+4],'mut ' jne .notbahamutlagoon cmp dword[esi+8],'Lago' jne .notbahamutlagoon mov esi,[romdata] add esi,010254h mov byte[esi],0EEh .notbahamutlagoon mov esi,[romdata] add esi,07FC0h cmp dword[esi],'MORT' jne .notmk cmp dword[esi+4],'AL K' jne .notmk cmp dword[esi+8],'OMBA' jne .notmk cmp dword[esi+12],'T ' jne .notmk mov byte[disablehdma],1 .notmk mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'CLOC' jne .notclocktower cmp dword[esi+4],'K TO' jne .notclocktower cmp dword[esi+8],'WER ' jne .notclocktower mov byte[opexec268],187 mov byte[opexec358],182 mov byte[opexec268cph],47 mov byte[opexec358cph],47 .notclocktower mov esi,[romdata] add esi,07FC0h cmp dword[esi],'DRAG' jne .notdq5 cmp dword[esi+4],'ONQU' jne .notdq5 cmp dword[esi+8],'EST5' jne .notdq5 mov byte[disablehdma],1 .notdq5 ; Lamborgini Challenge - -p 110 mov esi,[romdata] add esi,07FC0h cmp dword[esi],'DIGI' jne .nodigitaldevil mov byte[opexec268],187 mov byte[opexec358],187 .nodigitaldevil mov esi,[romdata] add esi,7FC0h cmp dword[esi],'SP F' jne .notfmatchtennis mov byte[cycpb268],145 mov byte[cycpb358],147 mov byte[cycpbl2],145 mov byte[cycpblt2],145 mov byte[cycpbl],145 mov byte[cycpblt],145 .notfmatchtennis mov esi,[romdata] add esi,7FC0h cmp dword[esi],'DEAD' je .deaddance cmp dword[esi],'TUFF' jne .nottuffenuff .deaddance mov byte[cycpb268],75 mov byte[cycpb358],77 mov byte[cycpbl2],75 mov byte[cycpblt2],75 mov byte[cycpbl],75 mov byte[cycpblt],75 .nottuffenuff cmp byte[DSP1Type],0 je .notdis mov byte[disablehdma],1 .notdis ; Here are the individual game hacks. Some of these probably can ; be removed since many of them were created very early in ZSNES ; development. mov byte[bgfixer],0 cmp byte[OldGfxMode2],0 je .nobgfixer mov byte[bgfixer],1 .nobgfixer mov esi,[romdata] cmp dword[esi+0FFC8h],'EST6' jne .notdq mov byte[CacheCheckSkip],1 mov byte[bgfixer],1 .notdq cmp dword[esi+07FC8h],'EST6' jne .notdq2 mov byte[CacheCheckSkip],1 mov byte[bgfixer],1 .notdq2 cmp dword[esi+0FFC0h],'FINA' jne .notff ; mov dword[WindowDisables],180 .notff mov esi,[romdata] add esi,9AB0h cmp dword[esi],0F00F2908h jne .notff3 mov byte[opexec268],163 mov byte[opexec358],157 mov byte[opexec268cph],39 mov byte[opexec358cph],39 .notff3 ; Earth Worm Jim 2 - IRQ hack (reduce sound static) mov esi,[romdata] add esi,0FFC0h mov edi,.ewj2head call Checkheadersame cmp al,0 jne .noromhead2 mov esi,[romdata] add esi,02A9C1Ah mov word [esi],0 add esi, 5 mov word [esi],0 mov dword [ewj2hack],1 .noromhead2 ; Lamborgini Challenge - -p 110 mov esi,[romdata] add esi,07FC0h mov edi,.lambhead call Checkheadersame cmp al,0 jne .noromheadlamb mov byte[opexec268],187 mov byte[opexec358],187 .noromheadlamb ; Addams Family Values - -p 75 mov esi,[romdata] add esi,07FC0h mov edi,.adm3head call Checkheadersame cmp al,0 jne .noromheadadm3 mov byte[opexec268],120 mov byte[opexec358],100 .noromheadadm3 ; Bubsy -p 115 mov esi,[romdata] add esi,07FC0h mov edi,.bubshead call Checkheadersame cmp al,0 jne .noromhead3 mov byte[opexec268],220 mov byte[opexec358],220 mov byte[opexec268cph],64 mov byte[opexec358cph],64 .noromhead3 ; BToad vs DD - 197/192/47/47 -p 120 mov esi,[romdata] ; add esi,07FC0h cmp dword[esi+640h],0E2FA85F6h jne .noromhead4 mov byte[opexec268],187 mov byte[opexec358],187 mov byte[opexec268cph],47 mov byte[opexec358cph],47 mov bl,[cycpb358] mov byte[cycpblt],bl mov al,[opexec358] mov byte[cycpl],al .noromhead4 ; Chrono Trigger - 187/182/47/47 -p 120 / res change clear screen disable mov esi,[romdata] ; add esi,0FFC0h cmp dword[esi+8640h],0E243728Dh jne .noromhead6 cmp byte[opexec358],182 ja .noromhead6 mov byte[ClearScreenSkip],1 mov byte[opexec268],187 mov byte[opexec358],182 mov byte[opexec268cph],47 mov byte[opexec358cph],47 mov bl,[cycpb358] mov byte[cycpblt],bl mov al,[opexec358] mov byte[cycpl],al .noromhead6 ; Lufia 2 - 182/177/44/44 mov esi,[romdata] add esi,07FC0h mov edi,.luf2head call Checkheadersame cmp al,0 jne .noromhead5 mov byte[opexec268],182 mov byte[opexec358],177 mov byte[opexec268cph],44 mov byte[opexec358cph],44 .noromhead5 ; PunchOut - Disable HDMA start in middle of screen mov esi,[romdata] add esi,07FC0h mov edi,.pouthead call Checkheadersame cmp al,0 jne .noromhead7 mov byte[disablehdma],1 .noromhead7 ; Front Mission - -p 140 mov esi,[romdata] add esi,0FFC0h cmp dword[esi],0C4DDDBCCh jne .noromheadfm cmp dword[esi+4],0AEBCAFD0h jne .noromheadfm mov byte[opexec268],226 mov byte[opexec358],226 mov byte[opexec268cph],80 mov byte[opexec358cph],80 .noromheadfm ; Front Mission - -p 140 mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'FRON' jne .noromheadfm2 cmp dword[esi+4],'T MI' jne .noromheadfm2 mov byte[opexec268],226 mov byte[opexec358],226 mov byte[opexec268cph],80 mov byte[opexec358cph],80 .noromheadfm2 ; Clayfighter 2 - -p 120 mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'Clay' jne .noromheadcf2 cmp byte[esi+12],'2' jne .noromheadcf2 mov byte[opexec268],187 mov byte[opexec358],182 mov byte[opexec268cph],47 mov byte[opexec358cph],47 .noromheadcf2 mov esi,[romdata] add esi,0FFC0h cmp dword[esi],'Donk' jne .noromheaddk cmp word[ramsize],2048 jne .noromheaddk mov word[ramsize],4096 mov word[ramsizeand],4095 .noromheaddk ret .ewj2head db 58,62,45,43,55,40,48,45,50,95,53,54,50,95,77,95,95,95,95,95 .bubshead db 61,10,29,12,06,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95 .btvdhead db 61,62,43,43,51,58,43,48,62,59,44,95,59,81,59,81,95,95,95,95 .luf2head db 51,10,25,22,30,95,54,54,87,58,12,11,15,16,19,22,12,95,54,54 .pouthead db 44,10,15,26,13,95,47,10,17,28,23,82,48,10,11,94,94,95,95,95 .drcxhead db 41,62,50,47,54,45,58,44,95,52,54,44,44,95,95,95,95,95,95,95 .drx2head db 60,62,44,43,51,58,41,62,49,54,62,95,59,45,62,60,42,51,62,95 .ctrghead db 60,55,45,48,49,48,95,43,45,54,56,56,58,45,95,95,95,95,95,95 .lambhead db 51,62,50,61,48,45,56,55,54,49,54,95,62,50,58,45,54,60,62,49 .adm3head db 62,59,59,62,50,44,95,57,62,50,54,51,38,95,41,62,51,42,58,44 .fmishead db 57,13,16,17,11,95,50,22,12,12,22,16,17,95,87,58,86,95,95,95 NEWSYM idledetectspc inc dword[numspcvblleft] cmp byte[SPCStallSetting],2 jae .fullstall inc byte[SPCStallSetting] mov byte[ReturnFromSPCStall],1 ret .fullstall mov dword[spc700idle],29 mov dword[Msgptr],.unableskip mov eax,[MsgCount] mov [MessageOn],eax ret .unableskip db 'SPC700 STALL DETECTED.',0 SECTION .data NEWSYM ReturnFromSPCStall, db 0 NEWSYM SPCStallSetting, db 0 NEWSYM SPCSkipXtraROM, db 0 NEWSYM WindowDisables, dd 0 SECTION .text %macro helpclearmem 2 mov edi,%1 mov ecx,%2 rep stosb %endmacro NEWSYM init65816 mov byte[osm2dis],0 mov byte[bgfixer2],0 mov word[ScrDispl],0 cmp byte[SA1Enable],0 je .nosa1init call SA1Reset call SetAddressingModesSA1 .nosa1init cmp byte[OBCEnable],0 je .noobcinit call InitOBC .noobcinit cmp byte[C4Enable],0 je .noc4init mov byte[osm2dis],1 mov byte[bgfixer2],1 call InitC4 .noc4init cmp byte[RTCEnable],0 je .noRTCinit call RTCinit .noRTCinit cmp byte[SPC7110Enable],0 je .nospc7110init call SPC7110init mov dword[memtabler8+50h*4],memaccessspc7110r8 mov dword[memtabler16+50h*4],memaccessspc7110r16 mov dword[memtablew8+50h*4],memaccessspc7110w8 mov dword[memtablew16+50h*4],memaccessspc7110w16 mov eax,[romdata] add eax,510000h mov dword[snesmmap+50h*4],eax mov dword[snesmap2+50h*4],eax mov ecx,16384 .spc7110clear mov dword[eax],0 add eax,4 dec ecx jnz .spc7110clear .nospc7110init mov byte[cycpb268],117 mov byte[cycpb358],127 mov byte[cycpbl2],117 mov byte[cycpblt2],117 mov byte[cycpbl],117 mov byte[cycpblt],117 cmp byte[SPC7110Enable],0 jne .specialtimer cmp byte[SDD1Enable],0 jne .specialtimer jmp .nospecialtimer .specialtimer mov byte[cycpb268],69 mov byte[cycpb358],81 mov byte[cycpbl2],69 mov byte[cycpblt2],69 mov byte[cycpbl],69 mov byte[cycpblt],69 .nospecialtimer mov byte[SPCSkipXtraROM],0 cmp byte[ReturnFromSPCStall],1 jne near .nostall mov byte[cycpb268],69 mov byte[cycpb358],81 mov byte[cycpbl2],69 mov byte[cycpblt2],69 mov byte[cycpbl],69 mov byte[cycpblt],69 mov byte[SPCSkipXtraROM],1 cmp byte[SPCStallSetting],2 jne .nostall2 mov byte[cycpb268],240 mov byte[cycpb358],240 mov byte[cycpbl],240 mov byte[cycpblt],240 mov byte[cycpbl2],240 mov byte[cycpblt2],240 mov byte[SPCSkipXtraROM],0 .nostall2 jmp .stalled .nostall mov byte[SPCStallSetting],0 .stalled mov dword[numspcvblleft],60*8 mov dword[SPC700write],0 mov dword[SPC700read],0 cmp dword[spc700read],0 mov dword[spc700idle],0 xor esi,esi .loopa mov al,[SPCROM+esi] mov byte[spcextraram+esi],0FFh mov [spcRam+0FFC0h+esi],al inc esi cmp esi,040h jne .loopa ; Clear Sound buffer mov edi,[spcBuffera] mov ecx,65536 xor eax,eax rep stosd ; Clear Echo buffer mov edi,echobuf mov ecx,25000 xor eax,eax rep stosd ; Clear DSPMem mov edi,DSPMem mov ecx,64 xor eax,eax rep stosd mov byte[prevoamptr],0FFh mov byte[execatzerovirq],0 mov byte[disablehdma],0 mov byte[disableeffects],0 mov byte[dracxhack],0 mov al,[opexec268b] mov [opexec268],al mov al,[opexec358b] mov [opexec358],al mov al,[opexec268cphb] mov [opexec268cph],al mov al,[opexec358cphb] mov [opexec358cph],al mov dword[FIRTAPVal0],7Fh mov dword[FIRTAPVal1],0 mov dword[FIRTAPVal2],0 mov dword[FIRTAPVal3],0 mov dword[FIRTAPVal4],0 mov dword[FIRTAPVal5],0 mov dword[FIRTAPVal6],0 mov dword[FIRTAPVal7],0 mov byte[disable65816sh],0 ; call Outputfilename ; Check Headers mov esi,[romdata] mov byte[hdmaearlstart],0 add esi,07FC0h cmp byte[esi],'Y' jne .nohdmaearlstart mov byte[hdmaearlstart],2 .nohdmaearlstart call headerhack mov byte [spcRam+0F4h],0 mov byte [spcRam+0F5h],0 mov byte [spcRam+0F6h],0 mov byte [spcRam+0F7h],0 mov byte [reg1read],0 mov byte [reg2read],0 mov byte [reg3read],0 mov byte [reg4read],0 mov dword[cycpbl],0 mov byte[spcnumread],0 mov dword[coladdr],0 mov byte[NMIEnab],1 mov word[VIRQLoc],0 mov byte[doirqnext],0 mov dword[reg1read],0 mov word[resolutn],224 mov byte[vidbright],0 mov byte[forceblnk],0 mov byte [spcP],0 mov byte[timeron],0 mov byte[JoyAPos],0 mov byte[JoyBPos],0 mov byte[coladdr],0 mov byte[coladdg],0 mov byte[coladdb],0 mov byte[INTEnab],0 mov word[xa],0 mov byte[xdb],0 mov byte[xpb],0 mov byte[xirqb],0 mov word[xs],01FFh mov word[xd],0 mov word[xx],0 mov word[xy],0 mov dword[SDD1BankA],03020100h mov byte[xp],00110100b ; NVMXDIZC push ebx mov byte[xe],1 ; E xor eax,eax mov ax,[resetv] mov word[xpc],ax mov ebx,[romdata] add eax,ebx cmp word[xpc],8000h jb .notrainer cmp dword[ebx+0FFC0h],'BREA' jne .ntrchecka cmp word[resetv],0F000h jne .ntrchecka jmp .yestrainer .ntrchecka sub eax,8000h cmp byte[eax],5Ch jne .notrainer cmp word[eax+2],80h je .notrainer cmp word[eax+2],8080h je .notrainer cmp word[eax+2],89h je .notrainer cmp word[eax+2],8089h je .notrainer .yestrainer mov dword[ramsize],32768 mov dword[ramsizeand],32767 .notrainer pop ebx mov byte[intrset],0 cmp byte[romtype],1 je .nohirom mov byte[xpb],00h mov byte[xirqb],00h .nohirom cmp word[xpc],8000h jae .n add word[xpc],8000h ; mov byte[xpb],40h .n mov al,[opexec268] mov byte[cycpl],al ; 2.68 Mhz / 3.58 Mhz = 228 mov byte[curcyc],al mov al,[opexec268cph] mov byte[cycphb],al ; 2.68 Mhz / 3.58 Mhz = 56 mov byte[cycpbl],110 ; 3.58Mhz = 175 mov byte[cycpblt],110 mov word[curypos],0 mov eax,tableD mov [Curtableaddr],eax mov byte[scrndis],00h mov word[stackand],01FFh mov word[stackor],0100h mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov byte[nmirept],0 mov byte[nmiprevline],224 mov byte[nmistatus],0 mov eax,055555555h ; Mario Paint, Clear WRAM w/ 0x00 (due to corrupt rom w/ trainer removed) mov esi,[romdata] add esi,07FC0h cmp dword[esi],'MARI' jne .notmpaint xor eax,eax .notmpaint mov esi,[romdata] add esi,07FC0h cmp word[esi],'BS' ; 7FFFFFA jne .notbsx .yesbsx mov eax,0FFFFFFFFh pushad xor edx,edx mov eax,128 mov ebx,[NumofBanks] div ebx mov ecx,eax dec ecx jz .skipbsxmove mov ebx,[NumofBanks] shl ebx,15 mov edx,ebx add ebx,[romdata] .loopbsx mov esi,[romdata] mov edi,edx .loopbsx2 mov al,[esi] xor al,al mov [ebx],al inc esi inc ebx dec edi jnz .loopbsx2 dec ecx jnz .loopbsx .skipbsxmove popad .notbsx helpclearmem wramdataa, 65536 helpclearmem ram7fa, 65536 cmp word[esi],'BS' jne .notbsx2 mov dword[ram7fa+65528],01010101h mov dword[ram7fa+65532],01010101h .notbsx2 xor eax,eax helpclearmem [vram], 65536 helpclearmem vidmemch2, 4096 helpclearmem vidmemch4, 4096 helpclearmem vidmemch8, 4096 mov dword[wramreadptr],getwram1fff mov dword[wramwriteptr],setwram1fff ret .boffound db '.....',0 getwram1fff: mov al,[wramdataa+1fffh] ret setwram1fff: mov [wramdata+1fffh],al ret ;******************************************************* ; Init SNES Sets the pointers, etc. ;******************************************************* ; Set banks according to : ; Banks 00-3F,80-BF : WRAM (0000h-7FFFh), ROM Data (8000h-FFFFh) ; Banks 40-7F,C0-FF : ROM Data (0000h-FFFFh) ; Bank 70-77 : SRAM (0000h-7FFFh) ; Bank 7E : WRAM (0000h-FFFFh) ; Bank 7F : ExtendRAM (0000h-FFFFh) SECTION .data NEWSYM curromsize, db 0 NEWSYM cromptradd, dd 0 NEWSYM NoiseDisTemp, dd 0,0 NEWSYM lorommapmode2, db 0 SECTION .text NEWSYM initsnes mov byte[ForceNewGfxOff],0 mov dword[NoiseDisTemp],0 mov dword[NoiseDisTemp+4],0 mov esi,[romdata] add esi,7FC0h cmp dword[esi],'MEGA' jne .notmmx cmp dword[esi+4],'MAN ' jne .notmmx cmp dword[esi+8],'X ' jne .notmmx mov esi,[romdata] cmp byte[esi+824Ah],0F0h jne .mmxa mov byte[esi+824Ah],080h .mmxa cmp byte[esi+21FC3h],0F0h jne .mmxb mov byte[esi+21FC3h],080h .mmxb cmp byte[esi+2241Bh],0F0h jne .mmxc mov byte[esi+2241Bh],080h .mmxc cmp byte[esi+824Fh],0F0h jne .mmxd mov byte[esi+824Fh],080h .mmxd cmp byte[esi+21FC8h],0F0h jne .mmxe mov byte[esi+21FC8h],080h .mmxe cmp byte[esi+22420h],0F0h jne .mmxf mov byte[esi+22420h],080h .mmxf .notmmx mov esi,[romdata] add esi,7FC0h cmp word[esi],'BS' ; 7FFFFFA je near .bslorom mov esi,[romdata] add esi,32704+22 cmp byte[romtype],2 jne .nohirom2b add esi,8000h .nohirom2b mov byte[MultiTap],1 cmp byte[pl12s34],1 je .nomtap cmp byte[pl3contrl],0 jne .mtap cmp byte[pl4contrl],0 jne .mtap cmp byte[pl5contrl],0 jne .mtap .nomtap mov byte[MultiTap],0 .mtap mov al,[esi] and al,0F0h cmp byte[romtype],1 jne .nosfx cmp al,10h je near .sfx .nosfx cmp al,30h je near SA1memmap cmp al,40h je near SDD1memmap cmp byte[SPC7110Enable],1 je near .hirom cmp byte[curromsize],13 je near .lorom48 cmp byte[romtype],1 jne near .hirom ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] sub eax,8000h mov ecx,40h .loopa stosd add eax,8000h dec ecx jnz .loopa ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov ecx,40h .loopb stosd add eax,8000h dec ecx jnz .loopb ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] cmp byte[lorommapmode2],0 je .notlorommode2 add eax,200000h .notlorommode2 sub eax,8000h mov cx,20h .loopc stosd add eax,8000h dec ecx jnz .loopc cmp byte[lorommapmode2],0 je .notlorommode2b sub eax,200000h .notlorommode2b mov cx,20h .loopclr stosd add eax,8000h dec ecx jnz .loopclr ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov ecx,40h .loopd stosd add eax,8000h dec ecx jnz .loopd ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa2 stosd dec ecx jnz .loopa2 ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,200000h mov ecx,40h .loopb2 stosd add eax,8000h dec ecx jnz .loopb2 ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc2 stosd dec ecx jnz .loopc2 ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,200000h mov ecx,40h .loopd2 stosd add eax,8000h dec ecx jnz .loopd2 ; set bank 70 mov eax,[sram] xor ebx,ebx mov bl,70h .nextsram mov [snesmap2+ebx*4],eax inc bl cmp bl,77h jbe .nextsram ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax ret .bslorom ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] sub eax,8000h mov ecx,40h .loopas stosd add eax,8000h dec ecx jnz .loopas ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov ecx,40h .loopbs stosd add eax,8000h dec ecx jnz .loopbs ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] sub eax,8000h mov cx,40h .loopcs stosd add eax,8000h dec ecx jnz .loopcs ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,8000h mov ecx,40h .loopds stosd add eax,8000h dec ecx jnz .loopds ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa2s stosd dec ecx jnz .loopa2s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,200000h mov ecx,40h .loopb2s stosd add eax,8000h dec ecx jnz .loopb2s ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc2s stosd dec ecx jnz .loopc2s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,8000h mov ecx,40h .loopd2s stosd add eax,8000h dec ecx jnz .loopd2s ; set bank 70 mov eax,[sram] xor ebx,ebx mov bl,70h .nextsrams mov [snesmap2+ebx*4],eax inc bl cmp bl,77h jbe .nextsrams ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax ret .lorom48 mov byte[cycpb268],94 mov byte[cycpb358],94 mov byte[cycpbl2],94 mov byte[cycpblt2],94 mov byte[cycpbl],94 mov byte[cycpblt],94 mov byte[opexec268],183 mov byte[opexec358],187 mov byte[opexec268cph],30 mov byte[opexec358cph],30 mov dword[NoiseDisTemp],01000101h mov dword[NoiseDisTemp+4],01h mov edi,memtabler8+40h*4 mov ecx,30h mov eax,memaccessbankr848mb rep stosd mov edi,memtabler16+40h*4 mov ecx,30h mov eax,memaccessbankr1648mb rep stosd ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] sub eax,8000h mov ecx,40h .loopa3 stosd add eax,8000h dec ecx jnz .loopa3 ; set banks 40-6F (30h x 64KB ROM banks @ 8000h) mov eax,[romdata] sub eax,8000h mov ecx,40h .loopb32 stosd add eax,8000h dec ecx jnz .loopb32 ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] sub eax,8000h mov cx,40h .loopc3 stosd add eax,8000h dec ecx jnz .loopc3 ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,200000h mov ecx,40h .loopd3 stosd add eax,10000h dec ecx jnz .loopd3 ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa23 stosd dec ecx jnz .loopa23 ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,100000h mov ecx,40h .loopb3 stosd add eax,8000h dec ecx jnz .loopb3 ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc23 stosd dec ecx jnz .loopc23 ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,200000h mov ecx,40h .loopd23 stosd add eax,10000h dec ecx jnz .loopd23 ; set bank 70 mov eax,[sram] xor ebx,ebx mov bl,70h .nextsram3 mov [snesmap2+ebx*4],eax inc bl cmp bl,77h jbe .nextsram3 ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax call prepare48mbit ret .hirom ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] mov ecx,40h .loopab stosd add eax,10000h dec ecx jnz .loopab ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] mov ecx,40h .loopbb stosd add eax,10000h dec ecx jnz .loopbb ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] mov ecx,40h .loopcb stosd add eax,10000h dec ecx jnz .loopcb ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] mov ecx,40h .loopdb stosd add eax,10000h dec ecx jnz .loopdb ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa2b stosd dec ecx jnz .loopa2b ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] mov cx,40h .loopb2b stosd add eax,10000h dec ecx jnz .loopb2b ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov cx,40h .loopc2b stosd dec ecx jnz .loopc2b ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] mov cx,40h .loopd2b stosd add eax,10000h dec ecx jnz .loopd2b ; set bank 70 mov eax,[sram] xor ebx,ebx mov bl,70h .nextsramb mov [snesmap2+ebx*4],eax inc bl cmp bl,77h jbe .nextsramb ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax ret .sfx mov byte[MultiTap],0 ; Clear sfxregisters mov edi,SfxR0 mov ecx,16 xor eax,eax rep stosd ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] ; sub eax,8000h mov ecx,40h .loopa3s stosd add eax,10000h dec ecx jnz .loopa3s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] ; add eax,200000h add eax,8000h mov ecx,40h .loopb3s stosd add eax,20000h dec ecx jnz .loopb3s ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] ; sub eax,8000h mov cx,40h .loopc3s stosd add eax,10000h dec ecx jnz .loopc3s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] ; add eax,200000h add eax,8000h mov ecx,40h .loopd3s stosd add eax,20000h dec ecx jnz .loopd3s ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa23s stosd dec ecx jnz .loopa23s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,8000h mov ecx,40h .loopb23s stosd add eax,20000h dec ecx jnz .loopb23s ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc23s stosd dec ecx jnz .loopc23s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,8000h mov ecx,40h .loopd23s stosd add eax,20000h dec ecx jnz .loopd23s ; set bank 70 mov eax,[sram] mov [snesmap2+78h*4],eax mov [snesmap2+79h*4],eax mov eax,[sfxramdata] mov [snesmap2+70h*4],eax add eax,65536 mov [snesmap2+71h*4],eax add eax,65536 mov [snesmap2+72h*4],eax add eax,65536 mov [snesmap2+73h*4],eax ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax call preparesfx ret SA1memmap: mov eax,[romdata] cmp dword[eax+0B95h],0ADCF10A9h jne .nosuccess mov byte[eax+0B96h],0 .nosuccess mov byte[MultiTap],0 ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] sub eax,8000h mov ecx,40h .loopa3s stosd add eax,8000h dec ecx jnz .loopa3s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] ; add eax,400000h mov ecx,40h .loopb3s stosd add eax,10000h dec ecx jnz .loopb3s ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] add eax,200000h sub eax,8000h mov cx,40h .loopc3s stosd add eax,8000h dec ecx jnz .loopc3s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,00000h mov ecx,40h .loopd3s stosd add eax,10000h dec ecx jnz .loopd3s ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa23s stosd dec ecx jnz .loopa23s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,400000h mov ecx,40h .loopb23s stosd add eax,10000h dec ecx jnz .loopb23s ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc23s stosd dec ecx jnz .loopc23s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,00000h mov ecx,40h .loopd23s stosd add eax,10000h dec ecx jnz .loopd23s ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax ret SDD1memmap: mov eax,[romdata] cmp dword[eax+0B95h],0ADCF10A9h jne .nosuccess mov byte[eax+0B96h],0 .nosuccess mov byte[MultiTap],0 ; set addresses 8000-FFFF ; set banks 00-3F (40h x 32KB ROM banks @ 8000h) mov edi,snesmmap mov eax,[romdata] sub eax,8000h mov ecx,40h .loopa3s stosd add eax,8000h dec ecx jnz .loopa3s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] ; add eax,400000h mov ecx,40h .loopb3s stosd add eax,10000h dec ecx jnz .loopb3s ; set banks 80-BF (40h x 32KB ROM banks @ 8000h) mov eax,[romdata] ; add eax,200000h sub eax,8000h mov cx,40h .loopc3s stosd add eax,8000h dec ecx jnz .loopc3s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,00000h mov ecx,40h .loopd3s stosd add eax,10000h dec ecx jnz .loopd3s ; set addresses 0000-7FFF (01h x 32KB WRAM @ 0000h) ; set banks 00-3F mov edi,snesmap2 mov eax,[wramdata] mov ecx,40h .loopa23s stosd dec ecx jnz .loopa23s ; set banks 40-6F (30h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,400000h mov ecx,40h .loopb23s stosd add eax,10000h dec ecx jnz .loopb23s ; set banks 80-BF (01h x 32KB WRAM @ 0000h) mov eax,[wramdata] mov ecx,40h .loopc23s stosd dec ecx jnz .loopc23s ; set banks C0-FF (40h x 64KB ROM banks @ 0000h) mov eax,[romdata] add eax,00000h mov ecx,40h .loopd23s stosd add eax,10000h dec ecx jnz .loopd23s ; set bank 7E mov eax,[wramdata] mov [snesmmap+7Eh*4],eax mov [snesmap2+7Eh*4],eax ; set bank 7F mov eax,[ram7f] mov [snesmmap+7Fh*4],eax mov [snesmap2+7Fh*4],eax ret ;******************************************************* ; Prepare 48mbit Moves blocks around for 48mbit ;******************************************************* SECTION .data NEWSYM memdest, dd 0 NEWSYM SFXCounter, dd 0 SECTION .text NEWSYM prepare48mbit ; make table 2 (64,0,65,1,...) mov edi,mode7tab+128 mov ecx,64 mov al,64 mov ah,0 .nextl2 mov [edi],al mov [edi+1],ah inc al inc ah add edi,2 dec ecx jnz .nextl2 mov eax,[romdata] add eax,200000h mov [memdest],eax call ProcessSwapTable cmp byte[romtype],1 je .nothirom call UnInterleave48mbit .nothirom ret UnInterleave48mbit: pushad ; make table 2 (0 .. 255) mov edi,mode7tab+256 mov ecx,256 xor al,al .nextlb2 mov [edi],al inc al inc edi dec ecx jnz .nextlb2 mov esi,mode7tab+256 mov ecx,40h xor al,al .loop mov [esi+40h],al inc al inc esi dec ecx jnz .loop mov esi,mode7tab+256 mov ecx,40h mov al,40h+1 .loop2 mov [esi+80h],al add al,2 inc esi dec ecx jnz .loop2 mov esi,mode7tab+256 mov ecx,20h mov al,40h .loop3 mov [esi+20h],al add al,2 mov [esi],al add al,2 inc esi dec ecx jnz .loop3 call SwapTable256 popad ret NEWSYM ProcessSwapTable ; make table 1 (0 .. 127) mov edi,mode7tab mov ecx,128 xor al,al .nextl mov [edi],al inc al inc edi dec ecx jnz .nextl xor eax,eax xor ebx,ebx ; sort memory ; start at first entry in table 2 mov esi,mode7tab+128 mov ecx,128 .nextentry ; find which blocks to swap ; search entry from table 2 in table 1 mov al,[esi] mov edi,mode7tab .findnext mov bl,[edi] cmp bl,al je .foundit inc edi jmp .findnext .foundit mov bl,[esi-128] mov [esi-128],al mov [edi],bl mov eax,esi sub eax,mode7tab+128 mov ebx,edi sub ebx,mode7tab ; swap blocks at memory location $200000+al*8000h with $200000+bl*8000h shl eax,15 add eax,[memdest] shl ebx,15 add ebx,[memdest] push esi mov esi,eax mov edi,ebx mov edx,2000h .loopa mov eax,[esi] mov ebx,[edi] mov [esi],ebx mov [edi],eax add esi,4 add edi,4 dec edx jnz .loopa pop esi xor eax,eax xor ebx,ebx inc esi dec ecx jnz near .nextentry call Makemode7Table ret NEWSYM preparesfx mov byte[SFXCounter],0 mov esi,[romdata] add esi,07FC0h ; cmp dword[esi],'FX S' ; je .yessfxcounter cmp dword[esi],'Stun' jne .nosfxcounter mov byte[ForceNewGfxOff],1 .yessfxcounter mov byte[SFXCounter],1 .nosfxcounter ; make table mov byte[SfxAC],0 mov eax,[romdata] cmp dword[eax+02B80h],0AB6CAB6Ch jne .noac mov byte[SfxAC],1 .noac cmp dword[eax+0EFFBBh], 21066396h je .yesinterleaved cmp dword[eax+048000h],0E702E1F6h je .yesinterleaved jmp .noswapper .yesinterleaved mov edi,mode7tab+128 mov ecx,128 mov al,0 .nextl2 mov ah,al and ah,11100001b mov bl,al and bl,00000110b shl bl,2 or ah,bl mov bl,al and bl,00011000b shr bl,2 or ah,bl mov [edi],ah inc al inc edi dec ecx jnz .nextl2 mov eax,[romdata] mov [memdest],eax call ProcessSwapTable .noswapper ; duplicate sfx data mov esi,[romdata] mov edi,[romdata] add esi,1F8000h add edi,3F0000h mov dl,40h .swaploopb mov ecx,32768 .swaploop mov al,[esi] mov [edi],al mov [edi+32768],al inc esi inc edi dec ecx jnz .swaploop sub edi,65536+32768 sub esi,65536 dec dl jnz .swaploopb ret ; copy address 0 to 200000h ; make table 1 (0 .. 127) mov esi,[romdata] mov edi,[romdata] add edi,200000h mov ecx,200000h .n mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .n ret NEWSYM UnInterleave pushad ; NumofBanks contains # of 32k banks ; make table 2 (0 .. 255) mov edi,mode7tab+256 mov ecx,256 xor al,al .nextlb2 mov [edi],al inc al inc edi dec ecx jnz .nextlb2 mov eax,[NumofBanks] shr eax,1 mov edi,mode7tab+256 mov ecx,eax mov bl,al xor bh,bh .nextl mov [edi],bl mov [edi+1],bh inc bl inc bh add edi,2 dec ecx jnz .nextl call SwapTable256 popad ret SwapTable256: ; make table 1 (0 .. 255) mov edi,mode7tab mov ecx,256 xor al,al .nextlb mov [edi],al inc al inc edi dec ecx jnz .nextlb xor eax,eax xor ebx,ebx ; sort memory ; start at first entry in table 2 mov esi,mode7tab+256 mov ecx,[NumofBanks] shr ecx,1 add ecx,ecx .nextentry ; find which blocks to swap ; search entry from table 2 in table 1 mov al,[esi] mov edi,mode7tab .findnext mov bl,[edi] cmp bl,al je .foundit inc edi jmp .findnext .foundit mov bl,[esi-256] mov [esi-256],al mov [edi],bl mov eax,edi add eax,256 cmp eax,esi je near .skipthis mov eax,esi sub eax,mode7tab+256 mov ebx,edi sub ebx,mode7tab ; swap blocks at memory location $200000+al*8000h with $200000+bl*8000h shl eax,15 add eax,[romdata] shl ebx,15 add ebx,[romdata] push esi mov esi,eax mov edi,ebx mov edx,2000h .loopa mov eax,[esi] mov ebx,[edi] mov [esi],ebx mov [edi],eax add esi,4 add edi,4 dec edx jnz .loopa pop esi .skipthis xor eax,eax xor ebx,ebx inc esi dec ecx jnz near .nextentry .endthis call Makemode7Table ret ;******************************************************* ; Copy execloop ;******************************************************* NEWSYM copyexecloop ret ;******************************************************* ; Process execloop ;******************************************************* NEWSYM procexecloop cmp byte[spcon],0 jne .noprocloop mov byte[curexecstate],1 ret .noprocloop mov byte[curexecstate],3 ret ;******************************************************* ; Change execloop ;******************************************************* NEWSYM changeexecloop ret ;******************************************************* ; Clear Memory ;******************************************************* ;vidbuffera resb 131072 ;romdataa resb 4194304+32768+2097152 ;wramdataa resb 65536 ;ram7fa resb 65536 ;vrama resb 65536 ;srama resb 32768 ;debugbufa resb 80000 ;regptra resb 49152 ;regptwa resb 49152 ;vcache2ba resb 262144 ;vcache4ba resb 131072 ;vcache8ba resb 65536 %macro helpclearmem2 2 mov edi,%1 mov ecx,%2 rep stosd %endmacro NEWSYM clearmem xor eax,eax helpclearmem [vidbuffer], 131072 helpclearmem wramdataa, 65536 helpclearmem ram7fa, 65536 helpclearmem [vram], 65536 helpclearmem srama, 65536 helpclearmem debugbufa, 80000 helpclearmem regptra, 49152 helpclearmem regptwa, 49152 helpclearmem [vcache2b], 262144 helpclearmem [vcache4b], 131072 helpclearmem [vcache8b], 65536 helpclearmem vidmemch2, 4096 helpclearmem vidmemch4, 4096 helpclearmem vidmemch8, 4096 helpclearmem pal16b, 1024 helpclearmem pal16bcl, 1024 helpclearmem pal16bclha, 1024 mov eax,0FFFFh helpclearmem2 pal16bxcl, 256 xor al,al mov al,0FFh mov edi,[romdata] mov ecx,4194304+32768 cmp byte[Sup48mbit],0 je .no48mb add ecx,2097152 .no48mb cmp byte[Sup16mbit],0 je .no16mb sub ecx,2097152 .no16mb rep stosb ; ret NEWSYM clearmem2 mov edi,[sram] mov eax,0FFFFFFFFh mov ecx,8192*2 rep stosd mov al,0FFh mov edi,spcRam mov ecx,65472 rep stosb ret ;******************************************************* ; Print Hexadecimal (16-bit/8-bit) ;******************************************************* NEWSYM printhex mov ecx,4 xor ebx,ebx .loopa mov bx,ax and bx,0F000h shr bx,12 mov dl,[.hexdat+ebx] push ax mov ah,02h call Output_Text pop ax shl ax,4 dec ecx jnz .loopa ret .hexdat db '0123456789ABCDEF' NEWSYM printhex8 mov ecx,2 xor ebx,ebx .loopb mov bx,ax and bx,0F0h shr bx,4 mov dl,[.hexdat+ebx] push ax mov ah,02h call Output_Text pop ax shl ax,4 dec ecx jnz .loopb ret .hexdat db '0123456789ABCDEF' ;******************************************************* ; Load File ;******************************************************* ; Search for header size first which is filesize MOD 32768 NEWSYM RetrieveDataIPS xor ah,ah cmp ecx,10000 jne .notoverflow push edx push ecx mov edx,wramdataa mov ecx,10000 call Read_File cmp eax,0 jne .notempty mov ah,1 jmp .empty .notempty xor ah,ah .empty pop ecx pop edx xor ecx,ecx .notoverflow mov al,[wramdataa+ecx] inc ecx ret IPSSL dd 0 NEWSYM PatchIPS %ifdef __LINUX__ pushad call pushdir popad %endif mov byte[IPSPatched],0 mov dword[IPSOffset],0 cmp byte[Header512],0 je .no512head mov dword[IPSOffset],512 .no512head mov dword[IPSLimit],4096*1024 cmp byte[Sup48mbit],0 je .not48 mov dword[IPSLimit],6144*1024 .not48 cmp byte[Sup16mbit],0 je .not16 mov dword[IPSLimit],2048*1024 .not16 ; 1965-1970, >1969*1024+712 (812/850/1000) ; upper bound: 1969*1024+1024 ; between 1965-<1970 / 1968,1970 ; mov dword[IPSLimit],208062h ; mov dword[IPSSL],208832h ; font = 208062h-208832h mov eax,fname+1 ; search for . or 0 .next cmp byte[eax],0 je .foundend inc eax jmp .next .foundend mov ebx,eax .findnext2 dec eax cmp eax,fname je .failfound %ifdef __LINUX__ cmp byte[eax],'/' %else cmp byte[eax],'\' %endif je .failfound cmp byte[eax],'.' je .foundokay jmp .findnext2 .failfound mov eax,ebx .foundokay mov ebx,[eax] mov [Prevextn],ebx mov dword[eax],'.ips' mov byte[eax+4],0 push eax %ifdef __LINUX__ cmp byte [ZipSupport], 1 je .nochangedir mov ebx,LoadDir call Change_Dir .nochangedir: %endif mov edx,fname+1 call Open_File jc near .failed mov bx,ax mov edx,Headchek mov ecx,5 call Read_File cmp dword[Headchek],'PATC' jne near .ipsfaileddet cmp byte[Headchek+4],'H' jne near .ipsfaileddet mov ecx,10000 .ipxloop .findnext xor edx,edx call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov dh,al shl edx,8 call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov dh,al call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov dl,al cmp edx,454F46h je near .ipsokay call RetrieveDataIPS cmp ah,0 jne near .ipsfailed sub edx,[IPSOffset] mov [IPSCount+1],al call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov [IPSCount],al cmp word[IPSCount],0 je .ipsclear .loop call RetrieveDataIPS cmp ah,0 jne near .ipsfailed ; cmp edx,[IPSSL] ; jae .nolimit cmp edx,[IPSLimit] jae .limit .nolimit mov esi,[romdata] mov [esi+edx],al .limit inc edx dec word[IPSCount] jnz .loop jmp .findnext .ipsclear call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov [IPSCount+1],al call RetrieveDataIPS cmp ah,0 jne near .ipsfailed mov [IPSCount],al call RetrieveDataIPS cmp ah,0 jne near .ipsfailed cmp word[IPSCount],0 je near .findnext mov esi,[romdata] .loop2 cmp edx,[IPSLimit] jae .limit2 mov [esi+edx],al .limit2 inc edx dec word[IPSCount] jnz .loop2 jmp .findnext .ipsokay mov dword[Msgptr],.ipsokaymsg mov dword[MessageOn],60*4 mov byte[IPSPatched],1 jmp .ipsfaileddet .ipsfailed mov dword[Msgptr],.ipsnokaymsg mov dword[MessageOn],60*4 mov byte[IPSPatched],1 .ipsfaileddet call Close_File .failed pop eax mov ebx,[Prevextn] mov [eax],ebx ; font = 208062h-208832h ; mov esi,[romdata] ; mov [esi+208062h],0 ;0-768, 3072-3072+256, 4096-4096+256 ; mov edx,2079*1024 ;+2048+2048*40 ; mov ecx,2048 ; mov esi,[romdata] ;.ltop ; mov byte[esi+edx],0 ; inc edx ; loop .ltop %ifdef __LINUX__ pushad call popdir popad %endif ret .ipsokaymsg db 'IPS PATCHED.',0 .ipsnokaymsg db 'IPS IS CORRUPT.',0 section .data NEWSYM Header512, db 0 NEWSYM Prevextn, dd 0 NEWSYM Headchek, db 0,0,0,0,0 NEWSYM IPSLimit, dd 0 NEWSYM IPSOffset, dd 0 NEWSYM IPSCount, dd 0 IPSPatched db 0 section .text OpenCombFile: mov edx,fnames+1 .next cmp byte[edx],0 je .found inc edx jmp .next .found dec edx cmp byte[edx],'.' je .found2 jmp .found .found2 mov dword[edx],'.cmb' push edx mov dword[NumComboLocl],0 mov edx,fnames+1 call Open_File jc .failb mov bx,ax mov edx,ComboBlHeader mov ecx,23 call Read_File mov al,byte[ComboBlHeader+22] or al,al jz .done mov [NumComboLocl],al mov ecx,[NumComboLocl] mov edx,ecx shl ecx,6 add ecx,edx add ecx,edx mov edx,CombinDataLocl call Read_File .done call Close_File .failb pop edx mov dword[edx],'.srm' ret NEWSYM SaveCombFile cmp byte[romloadskip],0 jne near .notfound mov edx,fnames+1 .next cmp byte[edx],0 je .found inc edx jmp .next .found dec edx cmp byte[edx],'.' je .found2 jmp .found .found2 mov dword[edx],'.cmb' push edx mov al,[NumComboLocl] or al,al jz .failb mov [ComboHeader+22],al mov edx,fnames+1 call Create_File jc .failb mov bx,ax mov edx,ComboHeader mov ecx,23 call Write_File mov ecx,[NumComboLocl] mov edx,ecx shl ecx,6 add ecx,edx add ecx,edx mov edx,CombinDataLocl call Write_File call Close_File .failb pop edx mov dword[edx],'.srm' .notfound ret NEWSYM loadfile mov byte[TextFile], 0 call GetCurDir mov byte[InGUI],0 %ifdef __LINUX__ mov dl,[InitDrive] mov ebx,InitDir call Change_Dir %endif jmp loadfileGUI.nogui SECTION .data .multfound db 0 .first db 0 .cchar db 0 .dotpos dd 0 .curfileofs dd 0 .filehand dw 0 .failop db 'Error opening file!',13,10,0 .opened db 'File opened successfully!',13,10,0 .mult db 'Multiple file format detected.',13,10,13,10,0 .temp db 0 .fail db 0 NEWSYM Checksumvalue, dw 0 NEWSYM Checksumvalue2, dw 0 NEWSYM SramExists, db 0 NEWSYM NumofBanks, dd 0 NEWSYM NumofBytes, dd 0 NEWSYM ZipSupport, db 0 InGUI db 0 %ifdef __LINUX__ tempdirname db '/tmp/zziptmp',0 %else tempdirname db 'zziptmp_.__z',0 %endif PrevDir db '..',0 SECTION .text GUIfindBlank db '*.',0 %macro UnZipSearch 1 mov cx,20h mov edx,%1 call Get_First_Entry jc %%notfound test byte[DTALoc+15h],10h jnz %%notfound jmp .found %%notfound %endmacro InvalidZip db 'ZSNES Version A does not support .ZIP files.',13,10,'Please use Version C for this feature.',10,13,0 ZipError db 0 UnZipFile: ; cmp byte[OSPort],1 ; jne .noasm ; mov ax,03h ; int 10h ; mov edx,InvalidZip ; call PrintStr ; jmp DosExit ;.noasm ; get Drive/Dir %ifdef __LINUX__ mov ebx,GUIcurrentdir %else mov ebx,GUIcurrentdir+3 %endif mov edx,GUIcurrentdir call Get_Dir %ifndef __LINUX__ add byte[GUIcurrentdir],65 %endif cmp byte[InGUI],0 je near .nochange ; locate end of string & append filename %ifdef __LINUX__ mov eax,GUIcurrentdir %else mov eax,GUIcurrentdir+3 %endif .loop cmp byte[eax],0 je .endfound inc eax jmp .loop .endfound cmp byte[eax-2],':' je .noaddslash %ifdef __LINUX__ mov byte[eax],'/' %else mov byte[eax],'\' %endif inc eax .noaddslash mov ebx,fname+1 .loopb mov cl,[ebx] mov [eax],cl or cl,cl jz .zero inc eax inc ebx jmp .loopb .zero ; Change to Save Directory mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir .nochange ; Change to Temp Directory mov edx,tempdirname call Change_Single_Dir jnc near .notfail ; Create Temp Directory mov edx,tempdirname call Create_Dir ; jc near .fail ; Change to Temp Directory mov edx,tempdirname call Change_Single_Dir jc near .fail .notfail ; mov ax,03h ; int 10h ; mov edx,GUIcurrentdir ; call PrintStr ; jmp DosExit ; Erase contents of the zip directory if there are any stuff mov esi,mode7tab call ZipDeleteRecurse ; UnZip File mov eax,GUIcurrentdir cmp byte[InGUI],1 je .nogui mov eax,fname+1 .nogui push eax call extractzip pop eax cmp byte[ZipError],0 jne near .failed ; Find valid rom file UnZipSearch GUIsmcfind UnZipSearch GUIsfcfind UnZipSearch GUIswcfind UnZipSearch GUIfigfind UnZipSearch GUIfind058 UnZipSearch GUIfind078 UnZipSearch GUIfindUSA UnZipSearch GUIfindJAP UnZipSearch GUIfindBIN UnZipSearch GUIfindZIP UnZipSearch GUIfind1 UnZipSearch GUIfindIC7 UnZipSearch GUIfindIC6 UnZipSearch GUIfindIC5 UnZipSearch GUIfindIC4 UnZipSearch GUIfindIC3 UnZipSearch GUIfindIC2 UnZipSearch GUIfindIC1 UnZipSearch GUIfindBlank .failed call ZipDelete jmp .fail .found mov byte[ZipSupport],1 mov edx,DTALoc+1Eh mov eax,fname+1 .continue mov bl,[edx] mov [eax],bl inc eax inc edx or bl,bl jnz .continue ret mov ax,3 int 10h mov edx,DTALoc+1Eh ; mov edx,GUIcurrentdir call PrintStr jmp DosExit .fail mov byte[ZipSupport],2 ret %ifdef __LINUX__ GUIfindIC7 db '*.[Ii][Cc]7',0 GUIfindIC6 db '*.[Ii][Cc]6',0 GUIfindIC5 db '*.[Ii][Cc]5',0 GUIfindIC4 db '*.[Ii][Cc]4',0 GUIfindIC3 db '*.[Ii][Cc]3',0 GUIfindIC2 db '*.[Ii][Cc]2',0 GUIfindIC1 db '*.[Ii][Cc]1',0 %else GUIfindIC7 db '*.iC7',0 GUIfindIC6 db '*.iC6',0 GUIfindIC5 db '*.iC5',0 GUIfindIC4 db '*.iC4',0 GUIfindIC3 db '*.iC3',0 GUIfindIC2 db '*.iC2',0 GUIfindIC1 db '*.iC1',0 %endif ZipDelete: mov esi,mode7tab call ZipDeleteRecurse mov edx,PrevDir call Change_Single_Dir mov edx,tempdirname call Remove_Dir call Makemode7Table ret tempzip db 0 ZipDeleteRecurse: ; Find all directories mov edx,GUIfindall mov cx,10h call Get_First_Entry jc near .notfounddir .moreentries2 test byte[DTALoc+15h],10h jz .nodir cmp byte[DTALoc+1Eh],'.' jne .founddir .nodir call Get_Next_Entry jnc .moreentries2 jmp .notfounddir .founddir cmp byte[tempzip],3 jne .notone %ifndef __LINUX__ mov ax,03h int 10h %endif jmp DosExit .notone push edx mov ecx,43 mov edi,DTALoc .loop mov al,[edi] mov [esi],al inc edi inc esi dec ecx jnz .loop mov edx,DTALoc+1Eh call Change_Single_Dir inc byte[tempzip] call ZipDeleteRecurse sub esi,43 mov edx,PrevDir call Change_Single_Dir mov edx,esi add edx,1Eh call Remove_Dir jc .faildirdel pop edx jmp ZipDeleteRecurse .faildirdel pop edx .notfounddir ; ah = 41h, edx = ptr to file mov cx,20h mov edx,GUIfindall call Get_First_Entry jc .notfound .moreentries push edx mov edx,DTALoc+1Eh call Delete_File pop edx call Get_Next_Entry jnc .moreentries .notfound ret SPC7110Allocated db 0 SPC7110DIRA db 'FEOEZSP7',0 SPC7110DIRB db 'SMHT-SP7',0 SDD1DIRA db 'SOCNSDD1',0 SDD1DIRB db 'SFA2SDD1',0 SPC7110IndexName db 'index.bin',0 SPC7110DirEntry db '*.bin',0 SPC7110CPtr dd 0 SPC7110CPtr2 dd 0 NEWSYM SDD1Offset, dd 65536*8 %ifndef __LINUX__ NEWSYM SDD1nfname, db ' \_00000-0.bin',0 NEWSYM SPC7110nfname, db ' \ .bin',0 %else NEWSYM SDD1nfname, db ' /_00000-0.bin',0 NEWSYM SPC7110nfname, db ' / .bin',0 %endif NEWSYM SDD1ifname, db 'sdd1gfx.idx',0 NEWSYM SDD1dfname, db 'sdd1gfx.dat',0 NEWSYM SDD1pfname, db 'sdd1gfx.pat',0 NEWSYM SPC7110IndexSize, dd 0 NEWSYM SPC7110Entries, dd 0 spc7110notfound db 'DECOMPRESSED PACK NOT FOUND',0 spc7110notfoundb db 'INDEX DATA NOT FOUND',0 SDD1PatchAddr dd 0 SDD1PatchOfs dd 0 SDD1PatchLen dd 0 EXTSYM sdd1fname NEWSYM SPC7110Load mov dword[SPC7110Entries],0 mov esi,[romdata] add esi,32704+22 add esi,8000h mov al,[esi] cmp byte[romtype],2 jne .nothirom cmp al,0F9h je .spc7110 cmp al,0F5h je .spc7110 .nothirom cmp byte[romtype],1 jne .notlorom mov esi,[romdata] add esi,32704+22 mov al,[esi] ; Star Ocean = 45h, SFA2 = 43h cmp al,43h je .sdd1 cmp al,45h je .sdd1 .notlorom .sdd1 cmp al,043h jne .noSDD1 mov edx,SDD1DIRB mov dword[sdd1fname],'sfa2' jmp .sdd1b .noSDD1 cmp al,045h jne .noSDD1b mov edx,SDD1DIRA mov dword[sdd1fname],'sdd1' jmp .sdd1b .noSDD1b ret .spc7110 mov edx,SPC7110DIRA cmp al,0F9h je .noSPC7110b mov edx,SPC7110DIRB .noSPC7110b mov eax,[edx] mov [SPC7110nfname],eax mov eax,[edx+4] mov [SPC7110nfname+4],eax call Change_Single_Dir jc near .nodir mov edx,SPC7110IndexName call Open_File jc near .noindex mov bx,ax mov edx,[romdata] add edx,580000h mov ecx,12*32768 call Read_File mov [SPC7110IndexSize],eax call Close_File mov dword[SPC7110Entries],0 mov edx,PrevDir call Change_Single_Dir ret .sdd1b cmp byte[SPC7110Allocated],0 jne .notalloc push edx call allocspc7110 mov byte[SPC7110Allocated],1 pop edx .notalloc call Change_Single_Dir jc near .nodir mov eax,[spc7110romptr] mov [SPC7110CPtr],eax add eax,[SDD1Offset] mov [SPC7110CPtr2],eax mov edx,SDD1ifname call Open_File jc near .noindexfile mov bx,ax mov edx,[SPC7110CPtr] mov ecx,[SDD1Offset] call Read_File add dword[SPC7110CPtr],eax xor ecx,ecx or eax,eax jz .notfoundb push ebx xor edx,edx mov ebx,12 div ebx mov dword[SPC7110Entries],eax mov ecx,eax mov eax,[spc7110romptr] mov ebx,[SPC7110CPtr2] .sdd1loop add [eax+4],ebx add eax,12 dec ecx jnz .sdd1loop pop ebx .notfoundb call Close_File mov edx,SDD1dfname call Open_File jc near .noindexfile mov bx,ax mov edx,[SPC7110CPtr2] mov ecx,7*1024*1024 call Read_File add dword[SPC7110CPtr2],eax call Close_File jmp .yesindexfile .noindexfile mov eax,[spc7110romptr] mov [SPC7110CPtr],eax add eax,[SDD1Offset] mov [SPC7110CPtr2],eax mov dword[SPC7110Entries],0 .yesindexfile mov edx,SPC7110DirEntry mov cx,20h call Get_First_Entry jc near .notfound .moreentries pushad mov edx,DTALoc+1Eh xor ecx,ecx xor eax,eax .loop cmp byte[edx],'.' je .fin cmp byte[edx],0 je .fin cmp byte[edx],'-' je .skipthisone cmp byte[edx],'_' je .skipthisone mov al,[edx] cmp al,'A' jb .num cmp al,'a' jb .uppercl sub al,'a'-10 jmp .done .uppercl sub al,'A'-10 jmp .done .num sub al,'0' .done shl ecx,4 add ecx,eax .skipthisone inc edx jmp .loop .fin ; spc7110romptr format: ; 64K - address/pointer/length table mov ebx,[SPC7110CPtr2] mov eax,[SPC7110CPtr] mov [eax],ecx mov [eax+4],ebx mov edx,DTALoc+1Eh call Open_File jc near .failed mov bx,ax add dword[SPC7110CPtr],8 mov edx,[SPC7110CPtr2] mov ecx,[SDD1Offset] call Read_File add dword[SPC7110CPtr2],eax mov edx,dword[SPC7110CPtr] mov [edx],eax add dword[SPC7110CPtr],4 call Close_File inc dword[SPC7110Entries] .failed popad call Get_Next_Entry jnc near .moreentries ; Load patch (Address, offset, length) mov edx,SDD1pfname call Open_File jc near .nopatch mov bx,ax mov ecx,4 mov edx,SDD1PatchAddr call Read_File or eax,eax jz .donepatch mov ecx,4 mov edx,SDD1PatchOfs call Read_File mov ecx,4 mov edx,SDD1PatchLen call Read_File pushad mov ecx,[SPC7110Entries] mov edx,[spc7110romptr] .patloop mov eax,[edx] cmp eax,[SDD1PatchAddr] jne .notaddress mov eax,[edx+4] add eax,[SDD1PatchOfs] pushad mov edx,eax mov ecx,[SDD1PatchLen] call Read_File popad jmp .foundaddr .notaddress add edx,12 dec ecx jnz .patloop ; not found pushad mov edx,[SPC7110CPtr2] mov ecx,[SDD1PatchLen] call Read_File popad .foundaddr popad .donepatch call Close_File .nopatch ; Save Datafile jmp .nosavedatafile ; mov eax,[spc7110romptr] ; mov [SPC7110CPtr],eax ; add eax,[SDD1Offset] ; mov [SPC7110CPtr2],eax mov ecx,[SPC7110Entries] mov eax,[spc7110romptr] mov ebx,eax add ebx,[SDD1Offset] .sdd1loopb sub [eax+4],ebx add eax,12 dec ecx jnz .sdd1loopb mov edx,SDD1ifname call Create_File mov bx,ax mov edx,[spc7110romptr] mov ecx,[SPC7110CPtr] sub ecx,edx call Write_File call Close_File mov edx,SDD1dfname call Create_File mov bx,ax mov edx,[spc7110romptr] add edx,[SDD1Offset] mov ecx,[SPC7110CPtr2] sub ecx,edx call Write_File call Close_File mov ecx,[SPC7110Entries] mov eax,[spc7110romptr] mov ebx,eax add ebx,[SDD1Offset] .sdd1loopc add [eax+4],ebx add eax,12 dec ecx jnz .sdd1loopc .nosavedatafile mov edx,PrevDir call Change_Single_Dir ret .notfound mov edx,PrevDir call Change_Single_Dir .nodir mov dword[Msgptr],spc7110notfound mov dword[MessageOn],60*6 ret .noindex mov edx,PrevDir call Change_Single_Dir mov dword[Msgptr],spc7110notfoundb mov dword[MessageOn],60*6 ret NEWSYM loadfileGUI mov byte[InGUI],1 .nogui mov byte[spcon],0 cmp byte[SPCDisable],1 je .nosound mov byte[spcon],1 .nosound ; determine if it's a .zip file or not mov eax,fname mov byte[ZipSupport],0 .ziploop inc eax cmp byte[eax],0 jne .ziploop sub eax,4 ; cmp byte[eax+1],'.' ; jne .finishzipd2 ; cmp byte[eax+2],'g' ; je .zokay4 ; cmp byte[eax+2],'G' ; jne .finishzipd2 ;.zokay4 ; cmp byte[eax+3],'z' ; je .zokay5 ; cmp byte[eax+3],'Z' ; jne .finishzipd2 ;.zokay5 ; jmp .zokay3 .finishzipd2 cmp byte[eax],'.' jne near .finishzipd inc eax cmp byte[eax],'z' je .zokay1 cmp byte[eax],'Z' jne .finishzipd .zokay1 inc eax cmp byte[eax],'i' je .zokay2 cmp byte[eax],'I' jne .finishzipd .zokay2 inc eax cmp byte[eax],'p' je .zokay3 cmp byte[eax],'P' jne .finishzipd .zokay3 call UnZipFile cmp byte[ZipSupport],2 jne .finishzipd cmp byte[InGUI],1 je .zipfail jmp .failed .zipfail ret .finishzipd mov byte[TextFile], 0 mov dword[MessageOn],0 mov byte[loadedfromgui],1 mov byte[Header512],0 mov byte[yesoutofmemory],0 mov byte[.fail],0 ; determine header size mov dword[.curfileofs],0 mov byte[.first],1 mov byte[.multfound],0 mov dword[.curromspace],0 ; open file mov edx,fname+1 call Open_File jc near .failed .nextfile cmp byte[.first],1 je .nomul cmp byte[.multfound],0 jne .nomul push eax push edx mov byte[.multfound],1 cmp byte[InGUI],1 je .ingui ; mov edx,.mult ; mov ah,9 ; call Output_Text .ingui pop edx pop eax .nomul mov bx,ax mov ecx,4194304+32768 cmp byte[Sup48mbit],0 je .no48mb add ecx,2097152 .no48mb cmp byte[Sup16mbit],0 je .no16mb sub ecx,2097152 .no16mb mov [.maxromspace],ecx sub dword[.maxromspace],32768 sub ecx,[.curfileofs] jnc .nooverflow xor ecx,ecx .nooverflow mov edx,[headdata] add edx,[.curfileofs] call Read_File jc near .failed or eax,eax jz near .success2 add dword[.curromspace],eax mov esi,[headdata] add esi,[.curfileofs] mov edi,[headdata] add edi,[.curfileofs] add [.curfileofs],eax mov ecx,eax and ecx,32767 cmp ecx,512 je near .yesheader ; check if .smc header push esi push eax push ebx xor ecx,ecx mov ebx,512 .nextzerocheck cmp byte[esi],0 jne .notzero inc ecx .notzero inc esi dec ebx jnz .nextzerocheck pop ebx pop eax pop esi cmp ecx,450 jb .nomove .yesheader mov byte[Header512],1 mov edi,esi add edi,512 sub eax,512 ; move eax # of bytes from edi to esi sub dword[.curromspace],512 sub dword[.curfileofs],512 .next mov cl,[edi] mov [esi],cl inc esi inc edi dec eax jnz .next .nomove mov ecx,1 mov edx,.temp call Read_File cmp eax,0 je .success mov byte[.fail],1 jmp .success .success2 mov byte[.fail],0 .success call Close_File jc near .failed ; check for 2nd+ part of file mov edi,fname+1 mov byte[.cchar],'\' ; get position of . or \ (You suck nasm) .nextsearch cmp byte[edi],0 je .nomore cmp byte[edi],'.' jne .notdot mov byte[.cchar],'.' mov [.dotpos],edi .notdot cmp byte[edi],'\' jne .notslash mov byte[.cchar],'\' .notslash inc edi jmp .nextsearch .nomore cmp byte[.cchar],'\' jne .noslashb mov [.dotpos],edi .noslashb mov edi,[.dotpos] ; search for .1, .2, etc. cmp byte[edi],'.' jne .nonumer cmp byte[edi+1],'1' jb .nonumer cmp byte[edi+1],'8' ja .nonumer cmp byte[edi+2],0 jne .nonumer inc byte[edi+1] xor ecx,ecx mov byte[.first],2 mov edx,fname+1 call Open_File jnc near .nextfile dec byte[edi+1] .nonumer mov edi,[.dotpos] ; search for ICx files cmp byte[edi],'.' jne .noicfile cmp byte[edi+3],'1' jb .noicfile cmp byte[edi+3],'7' ja .noicfile cmp byte[edi+4],0 jne .noicfile dec byte[edi+3] xor ecx,ecx mov byte[.first],2 mov edx,fname+1 call Open_File jnc near .nextfile inc byte[edi+3] .noicfile ; search for A,B,C, etc. cmp byte[.first],0 je .yesgd cmp byte[edi-1],'A' je .yesgd cmp byte[edi-1],'a' je .yesgd jmp .nogdformat .yesgd mov byte[.first],0 inc byte[edi-1] mov edx,fname+1 call Open_File jnc near .nextfile dec byte[edi-1] .nogdformat mov byte[TextFile], 1 mov byte[IPSPatched],0 ; Wizardry Gaiden 4? mov byte[lorommapmode2],0 mov esi,[romdata] cmp dword[esi+207FC0h],'DERB' jne .noderby96 cmp dword[esi+207FC4h],'Y ST' jne .noderby96 cmp dword[esi+207FC8h],'ALLI' jne .noderby96 cmp dword[esi+207FCDh],'N 96' jne .noderby96 mov byte[lorommapmode2],1 .noderby96 cmp dword[esi+7FC0h],'SOUN' jne .nosoundnovel cmp dword[esi+7FC4h],'D NO' jne .nosoundnovel cmp dword[esi+7FC8h],'VEL-' jne .nosoundnovel cmp dword[esi+7FCDh],'COOL' jne .nosoundnovel mov byte[lorommapmode2],1 .nosoundnovel cmp dword[esi+7FC0h],'HONK' jne near .nothonk cmp dword[esi+7FC4h],'AKUH' jne near .nothonk cmp dword[esi+7FC8h],'A IG' jne near .nothonk cmp dword[esi+7FCCh],'O GO' jne near .nothonk cmp dword[esi+7FD0h],'SEI ' jne near .nothonk mov esi,.romtable mov eax,16 mov ebx,16 .honkl1 mov [esi],bl add esi,2 add ebx,1 sub eax,1 jne .honkl1 mov esi,.romtable inc esi mov eax,16 mov ebx,0 .honkl2 mov [esi],bl add esi,2 add ebx,1 sub eax,1 jne .honkl2 mov esi,.romtableb mov eax,32 mov ebx,0 .honkl3 mov [esi],bl add esi,1 add ebx,1 sub eax,1 jne .honkl3 xor eax,eax xor ebx,ebx mov eax,0 ; current dest bank .honkswapbanks mov bl,[.romtable+eax] ; current source bank xor ecx,ecx .honkfindbank inc ecx cmp byte [.romtableb-1+ecx],bl jne .honkfindbank dec ecx mov dl, [.romtableb+eax] mov byte [.romtableb+ecx],dl mov byte [.romtableb+eax],cl mov esi,eax shl esi,15 add esi,[romdata] mov edi,ecx shl edi,15 add edi,[romdata] mov edx,0 .honkcopybank mov bl,[esi+edx] mov bh,[edi+edx] mov [esi+edx],bh mov [edi+edx],bl inc edx cmp edx,32768 jne .honkcopybank inc eax cmp eax,32 jne .honkswapbanks .nothonk cmp dword[esi+207FC0h],'WIZA' jne near .notwiz4 cmp dword[esi+207FC4h],'RDRY' jne near .notwiz4 cmp dword[esi+207FC8h],' GAI' jne near .notwiz4 cmp dword[esi+207FCDh],'EN 4' jne near .notwiz4 .loopwiz4 mov esi,.romtable mov eax,64 mov ebx,64 .wiz4l1 mov [esi],bl add esi,2 add ebx,1 sub eax,1 jne .wiz4l1 mov esi,.romtable inc esi mov eax,64 mov ebx,0 .wiz4l2 mov [esi],bl add esi,2 add ebx,1 sub eax,1 jne .wiz4l2 mov esi,.romtableb mov eax,128 mov ebx,0 .wiz4l3 mov [esi],bl add esi,1 add ebx,1 sub eax,1 jne .wiz4l3 xor eax,eax xor ebx,ebx mov eax,0 ; current dest bank .wiz4swapbanks mov bl,[.romtable+eax] ; current source bank xor ecx,ecx .wiz4findbank inc ecx cmp byte [.romtableb-1+ecx],bl jne .wiz4findbank dec ecx mov dl, [.romtableb+eax] mov byte [.romtableb+ecx],dl mov byte [.romtableb+eax],cl mov esi,eax shl esi,15 add esi,[romdata] mov edi,ecx shl edi,15 add edi,[romdata] mov edx,0 .wiz4copybank mov bl,[esi+edx] mov bh,[edi+edx] mov [esi+edx],bh mov [edi+edx],bl inc edx cmp edx,32768 jne .wiz4copybank inc eax cmp eax,128 jne .wiz4swapbanks jmp near .notwiz4 .romtable times 128 db 0 .romtableb times 128 db 0 .notwiz4 jmp .skipall ; scan for branches mov esi,06A5h add esi,[romdata] mov ecx,80h .loopcheck cmp byte[esi],48h je .yes cmp byte[esi],8Bh je .yes cmp byte[esi],0Bh je .yes cmp byte[esi],4Bh je .yes cmp byte[esi],08h je .yes cmp byte[esi],0DAh je .yes cmp byte[esi],5Ah je .yes jmp .no .yes pushad mov al,byte[esi] mov al,80h sub al,cl call printhex8 popad .no add esi,8000h dec ecx jnz .loopcheck .skipall ; mirror image mov eax,[.curromspace] cmp dword[.maxromspace],eax jbe .nomir mov edx,[romdata] mov ebx,[romdata] add edx,[.curromspace] mov ecx,[.curromspace] .nextmir mov al,[ebx] mov [edx],al inc ebx inc edx inc ecx cmp ecx,[.maxromspace] jne .nextmir .nomir ; calculate checksum mov eax,1 .nextcr add eax,eax cmp eax,[.curromspace] jb .nextcr mov ecx,eax mov esi,[romdata] xor eax,eax xor ebx,ebx xor edi,edi mov edx,ecx shr edx,1 .nextcs mov al,[esi+edi] inc edi add ebx,eax cmp edi,[.curromspace] jne .notcrs mov edi,edx .notcrs dec ecx jnz .nextcs mov [Checksumvalue],bx mov esi,[romdata] mov ecx,[.curfileofs] xor eax,eax xor ebx,ebx xor edi,edi .nextcs3 mov al,[esi+edi] inc edi add ebx,eax cmp edi,ecx jne .nextcs3 mov [Checksumvalue2],bx cmp byte[ZipSupport],1 jne .nottempdirdel call PatchIPS call ZipDelete .nottempdirdel call convertsram mov byte[SramExists],0 ; change to sram dir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir ; open .srm file mov edx,fnames+1 call Open_File jc .notexist mov byte[SramExists],1 mov bx,ax mov ecx,65536 mov edx,[sram] call Read_File call Close_File jc near .failed2 .notexist call OpenCombFile cmp byte[InGUI],1 je .inguib mov edx,.opened mov ah,9 call Output_Text .inguib mov eax,[.curfileofs] mov [NumofBytes],eax shr eax,15 mov [NumofBanks],eax mov eax,[.curfileofs] shr eax,15 mov [NumofBanks],eax cmp byte[.fail],0 je .notfailed mov byte[yesoutofmemory],1 .notfailed ; copy fnames to fname cmp byte[InGUI],1 je .nosramtof mov eax,fname+1 mov ebx,fnames+1 .loopsc mov dl,[ebx] mov [eax],dl inc ebx inc eax or dl,dl jnz .loopsc .nosramtof cmp byte[IPSPatched],0 jne .patched mov byte[TextFile], 1 call PatchIPS .patched ret .failed cmp byte[ZipSupport],1 jne .nottempdirdelb call ZipDelete .nottempdirdelb .failed2 cmp byte[InGUI],1 je .noguic mov edx,.failop mov ah,9 call Output_Text .noguic mov byte[GUIloadfailed],1 jmp DosExit SECTION .data .multfound db 0 .first db 0 .cchar db 0 .dotpos dd 0 .curfileofs dd 0 .filehand dw 0 .temp db 0 .fail db 0 .failop db 'Error opening file!',13,10,0 .opened db 'File opened successfully!',13,10,0 .mult db 'Multiple file format detected.',13,10,13,10,0 .maxromspace dd 0 .curromspace dd 0 NEWSYM GUIloadfailed, db 0 SECTION .text NEWSYM convertsram cmp byte[cfgloadsdir],1 je .sdrivechange ret .sdrivechange ; copy fnames/fnamest to not have any '\' in them mov esi,fnames+1 mov ebx,0 .next mov al,[esi] cmp al,0 je .fincutoff cmp al,'\' je .cutoff cmp al,'/' je .cutoff cmp al,':' je .cutoff inc esi jmp .next .cutoff inc esi mov ebx,esi jmp .next .fincutoff cmp ebx,0 je .nocutoff mov esi,ebx mov edi,fnames+1 .next2 mov al,[esi] mov [edi],al inc esi inc edi cmp al,0 jne .next2 .nocutoff mov esi,fnamest+1 mov ebx,0 .nextb mov al,[esi] cmp al,0 je .fincutoffb cmp al,'\' je .cutoffb cmp al,'/' je .cutoffb cmp al,':' je .cutoffb inc esi jmp .nextb .cutoffb inc esi mov ebx,esi jmp .nextb .fincutoffb cmp ebx,0 je .nocutoffb mov esi,ebx sub esi,fnamest+1 sub [statefileloc],esi mov esi,ebx mov edi,fnamest+1 .next2b mov al,[esi] mov [edi],al inc esi inc edi cmp al,0 jne .next2b .nocutoffb ; change to sram directory mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir ret NEWSYM CSStatus, db ' TYPE: CHSUM:OK ',0 NEWSYM showinfogui mov esi,[romdata] add esi,7FC0h cmp byte[romtype],2 jne .nohiromrn add esi,8000h .nohiromrn mov edi,CSStatus mov ecx,20 .looprn mov al,[esi] or al,al jnz .okaysp mov al,32 .okaysp mov [edi],al inc esi inc edi dec ecx jnz .looprn mov dword[CSStatus+25],'NRM ' cmp byte[SA1Enable],0 je .nosa1 mov dword[CSStatus+25],'SA1 ' .nosa1 cmp byte[RTCEnable],0 je .nortc mov dword[CSStatus+25],'RTC ' .nortc cmp byte[SPC7110Enable],0 je .nospc7110 mov dword[CSStatus+25],'SP7 ' .nospc7110 cmp byte[SFXEnable],0 je .nosfx mov dword[CSStatus+25],'SFX ' .nosfx cmp byte[C4Enable],0 je .noc4 mov dword[CSStatus+25],'C4 ' .noc4 cmp byte[DSP1Type],0 je .nodsp1 mov dword[CSStatus+25],'DSP ' .nodsp1 cmp byte[SDD1Enable],0 je .nosdd1 mov dword[CSStatus+25],'SDD ' .nosdd1 cmp byte[OBCEnable],0 je .noobc mov dword[CSStatus+25],'OBC ' .noobc mov esi,[romdata] add esi,7FDCh+2 cmp byte[romtype],2 jne .nohirom3 add esi,8000h .nohirom3 mov ax,[Checksumvalue] cmp ax,[esi] jne .failed .passed2 mov dword[CSStatus+36],'OK ' jmp .passed .failed mov ax,[Checksumvalue2] cmp ax,[esi] je .passed2 mov dword[CSStatus+36],'FAIL' .passed mov dword[Msgptr],CSStatus mov eax,[MsgCount] mov [MessageOn],eax ret ;******************************************************* ; Show Information ;******************************************************* ; ; Maker Code = FFB0-FFB1 ; Game Code = FFB2-FFB5 ; Expansion RAM Size = FFBD (0=none, 1=16kbit, 3=64kbit, 5=256kbit,etc. ; Map Mode = FFD5 2.68-20h=map20h,21h=map21h,22h=reserved,23h=SA-1,25h=map25h ; 3.58-30h=map20h,31h=map21h,35h=map25h,highspeed ; Rom Mask Version = FFDB ; FFD6 (ROM Type) : 0*=DSP,1*=SFX,2*=OBC1,3*=SA-1,E*-F*=other ; *3=ROM,*4=ROM+RAM,*5=ROM+RAM+BATTERY,*6=ROM+BATTERY ; F3=C4 ; Convert to interleaved - If LoROM and offset 7FD5 contains 21h, then ; uninterleave NEWSYM showinfo mov edx,.romsizea cmp byte[Sup48mbit],0 je .no48 mov edx,.romsizeb cmp byte[newgfx16b],0 je .no48 mov edx,.romsized .no48 cmp byte[Sup16mbit],0 je .no16 mov edx,.romsizec .no16 mov ah,9 call Output_Text mov edx,.filename mov ah,9 call Output_Text xor ecx,ecx mov cl,[fname] mov esi,fname+1 mov ah,2 .loopa lodsb mov dl,al call Output_Text dec ecx jnz .loopa mov edx,.ret mov ah,9 call Output_Text ; frameskip = ? mov edx,.frameskip mov ah,9 call Output_Text mov dl,[frameskip] test dl,0FFh jnz .yesfs mov edx,.auto mov ah,9 call Output_Text jmp .skip .yesfs mov ah,2 add dl,47 call Output_Text mov edx,.ret mov ah,9 call Output_Text .skip ; debugger on/off mov edx,.debugon mov ah,9 call Output_Text mov al,[debugger] test al,0FFh jnz .debugron mov edx,.off mov ah,9 call Output_Text jmp .skip2 .debugron mov edx,.on mov ah,9 call Output_Text .skip2 mov edx,.ret mov ah,9 call Output_Text ; memory free mov edx,.memryfr call Output_Text mov edx,.memfree call Get_Memfree mov eax,[.memfree] call printnum mov edx,.ret mov ah,9 call Output_Text call Output_Text ; ROM Information mov edx,.smcname mov ah,9 call Output_Text ; determine whether hirom or lorom is used cmp byte[romtype],0 jnz near .donecheck call CheckROMType cmp byte[ROMTypeNOTFound],0 je .donecheck mov ah,09h mov edx,.doh call Output_Text jmp DosExit .donecheck ; COP Software 00FFF4,5 00FFE4,5 N/A ; ABORT Hardware 00FFF8,9 00FFE8,9 2 ; NMI Hardware 00FFFA,B 00FFEA,B 3 ; RES Hardware 00FFFC.D 00FFFC,D 1 ; BRK Software 00FFFE,F 00FFE6,7 N/A ; IRQ Hardware 00FFFE,F 00FFEE,F 4 call SetIRQVectors ; Output Name mov esi,[romdata] add esi,7FC0h cmp byte[romtype],2 jne .nohirom2 add esi,8000h .nohirom2 mov ecx,21 .loopb lodsb mov dl,al mov ah,2 call Output_Text dec ecx jnz .loopb inc esi mov edx,.ret ; ROM Type mov ah,9 call Output_Text mov edx,.romtyp call Output_Text mov edx,.hirom cmp byte[romtype],1 jne .nolorom mov edx,.lorom .nolorom call Output_Text mov edx,.romtype xor ebx,ebx mov bl,[esi] ; xor eax,eax ; mov al,bl ; call printnum ; jmp DosExit mov al,bl inc esi cmp al,055h jne .noRTC mov bl,12 jmp .nochip .noRTC cmp al,0F5h je .yesSPC7110 cmp al,0F9h jne .noSPC7110 .yesSPC7110 mov bl,11 jmp .nochip .noSPC7110 cmp al,0F3h jne .noC4 mov bl,9 jmp .nochip .noC4 and bl,0F0h cmp bl,10h je .sfx cmp bl,30h je .sa1 cmp bl,40h je .sdd1 mov bl,20 cmp al,5 ja .okay mov bl,al .okay jmp .nochip .sfx mov bl,6 jmp .nochip .sa1 mov bl,7 jmp .nochip .sdd1 mov bl,10 jmp .nochip .nochip cmp bl,20 je .unknown shl bl,4 add edx,ebx call Output_Text jmp .nounknown .unknown mov edx,.unknowns call Output_Text mov al,[esi-1] call printhex8 mov edx,.brackets mov ah,9 call Output_Text .nounknown ; Memory Map ; cmp byte[intldone],0 ; je .nointerl ; mov ah,09h ; mov edx,.intlvd ; call Output_Text ;.nointerl mov ah,09h mov edx,.memmap call Output_Text push esi mov esi,[romdata] add esi,7FD5h xor eax,eax mov al,byte[esi] and al,2Fh pop esi call printhex8 mov ah,09h mov edx,.ret call Output_Text ; ROM Size mov edx,.romsize mov ah,9 call Output_Text mov cl,[esi] mov [curromsize],cl ; cmp byte[NumofBanks],160 ; jb .not48 ; mov byte[curromsize],13 ;.not48 inc esi xor eax,eax sub cl,7 mov al,1 shl al,cl call printnum mov edx,.megabit mov ah,9 call Output_Text ; RAM Size mov edx,.sramsize mov ah,9 call Output_Text and eax,0FFFFh mov cl,[esi] inc esi xor eax,eax mov al,1 shl al,cl cmp al,1 jne .yessram mov al,0 .yessram call printnum shl eax,10 cmp eax,65536*2 jbe .nosramc mov eax,65536*2 .nosramc mov [ramsize],eax dec eax mov [ramsizeand],eax mov edx,.kilobit mov ah,9 call Output_Text mov al,[ForceROMTiming] mov byte[ForcePal],al xor al,al mov al,[esi] cmp byte[ForcePal],1 jne .nontsc mov al,0 .nontsc cmp byte[ForcePal],2 jne .nopal2 mov al,2 .nopal2 mov byte[romispal],0 mov word[totlines],263 mov dword[MsgCount],120 cmp al,1 jbe .nopal cmp al,0Fh je .nopal mov byte[romispal],1 mov word[totlines],313 mov dword[MsgCount],100 mov edx,.romtypep mov ah,9 call Output_Text jmp .yespal .nopal mov edx,.romtypen mov ah,9 call Output_Text .yespal mov esi,[headdata] add esi,7FBDh cmp byte[romtype],2 jne .nohirom4 add esi,8000h .nohirom4 cmp byte[esi],0 je .nochipram jmp .nochipram mov edx,.ramsize mov ah,9 call Output_Text xor eax,eax mov al,[esi] shl eax,12 call printnum mov edx,.kilobit mov ah,9 call Output_Text .nochipram ;FFBD (0=none, 1=16kbit, 3=64kbit, 5=256kbit,etc. mov edx,.checksumc mov ah,9 call Output_Text mov ax,[Checksumvalue] mov esi,[headdata] add esi,7FDCh+2 cmp byte[romtype],2 jne .nohirom3 add esi,8000h .nohirom3 cmp ax,[esi] jne .failed .cpassed2 mov edx,.cpassed jmp .passed .failed mov ax,[Checksumvalue2] cmp ax,[esi] je .cpassed2 mov edx,.cfailed .passed mov ah,9 call Output_Text ; Display NMI & Reset mov edx,.nmidisp mov ah,9 call Output_Text xor eax,eax mov ax,[nmiv] call printhex mov edx,.ret mov ah,9 call Output_Text mov edx,.resetdisp mov ah,9 call Output_Text mov ax,[resetv] call printhex mov edx,.ret mov ah,9 call Output_Text cmp byte[intldone],1 jne .nointerl mov edx,.intlvd mov ah,9 call Output_Text .nointerl mov edx,.ret mov ah,9 call Output_Text mov edx,.waitkey mov ah,9 call Output_Text ; wait for key cmp byte[enterpress],0 jne .noesc ; cmp byte[OSPort],3 ; je .noesc %ifdef __MSDOS__ call Get_Key cmp al,27 jne .noesc mov dl,[InitDrive] mov ebx,InitDir call Change_Dir jmp DosExit %endif .noesc mov edx,.ret call Output_Text ret SECTION .data .memfree times 30 db 0 .filename db 'Filename : ',0 .frameskip db 'Frame Skip : ',0 .percexec db '% to Exec : ',0 .debugon db 'Debugger : ',0 .memryfr db 'Memory Free : ',0 .auto db 'AUTO',13,10,0 .on db 'ON',13,10,0 .off db 'OFF',13,10,0 .ret db 13,10,0 .waitkey db 'Press Any Key to Continue.',0 .smcname db 'Cartridge name : ',0 .romtyp db 'ROM type : ',0 .memmap db 'Memory Map : ',0 .hirom db 'HIROM/',0 .lorom db 'LOROM/',0 .romtype db 'ROM ',13,10,0 db 'ROM/RAM ',13,10,0 db 'ROM/SRAM ',13,10,0 db 'ROM/DSP1 ',13,10,0 db 'RAM/DSP1/RAM ',13,10,0 db 'ROM/DSP1/SRAM',13,10,0 db 'SFX ',13,10,0 db 'SA-1 ',13,10,0 db 'SFX2/RAM ',13,10,0 db 'C4/ROM ',13,10,0 db 'SDD-1 ',13,10,0 db 'SPC7110 ',13,10,0 db 'S-RTC ',13,10,0 .unknowns db 'UNKNOWN (',0 .brackets db ')',13,10,0 .romsize db 'ROM size : ',0 .sramsize db 'SRAM size : ',0 .ramsize db 'CartRAM size : ',0 .romtypep db 'ROM Type : PAL',13,10,0 .romtypen db 'ROM Type : NTSC',13,10,0 .checksumc db 'Checksum : ',0 .cpassed db 'PASSED',13,10,0 .cfailed db 'FAILED',13,10,0 .romsizea db 13,10,'Max 32mbit ROM support',13,10,13,10,0 .romsizeb db 13,10,'Max 48mbit ROM support + SuperFX/C4 support',13,10,13,10,0 .romsizec db 13,10,'Max 16mbit ROM support',13,10,13,10,0 .romsized db 13,10,'Max 48mbit ROM support + SuperFX/C4 support + 16bit New Gfx Engine',13,10,13,10,0 .megabit db ' Megabits',13,10,0 .kilobit db ' Kilobytes',13,10,0 .nmidisp db 'NMI Vector Location : ',0 .resetdisp db 'Reset Vector Location : ',0 .doh db 'Cannot detect whether cartridge is HiROM or LoROM.',13,10,'Please use -h/-l',13,10,0 .intlvd db 'Image is uninterleaved.',13,10,0 NEWSYM DSP1Type, db 0 NEWSYM intldone, db 0 SECTION .text NEWSYM CheckROMType call SetAddressingModes call GenerateBank0Table call headerhack2 mov byte[ROMTypeNOTFound],0 ; check reset vectors ; RES Hardware 00FFFC.D 00FFFC,D 1 mov esi,[romdata] mov ax,[esi+0FFFCh] mov bx,[esi+07FFCh] cmp bx,8000h jne .notrv1 cmp ax,8011h je .yeslorom .notrv1 test ax,8000h jnz .checkloarea test bx,8000h jz .notfound2 .yeslorom mov byte[romtype],1 jmp .donecheck .checkloarea test bx,8000h jnz .notfound2 mov byte[romtype],2 jmp .donecheck .notfound2 mov esi,[romdata] add esi,7FECh ; cmp word[esi],8000h ; jb .checkhirom mov esi,[romdata] add esi,32704+23 cmp byte[esi],32 ja .checkhirom mov esi,[romdata] add esi,7FDCh lodsw mov bx,ax lodsw xor bx,ax cmp bx,0FFFFh jne .checkhirom cmp ax,0 je .checkhirom cmp ax,0FFFFh je .checkhirom mov byte[romtype],1 jmp .donecheck .checkhirom mov esi,[romdata] add esi,32704+23+32768 cmp byte[esi],32 ja .cantcheck mov esi,[romdata] add esi,0FFDCh lodsw mov bx,ax lodsw xor bx,ax cmp bx,0FFFFh jne .cantcheck mov byte[romtype],2 jmp .donecheck .cantcheck ; check for a header with mostly letters or spaces mov esi,[romdata] add esi,32704 mov ecx,21 mov al,0 .nextletter cmp byte[esi],32 je .yesletter cmp byte[esi],'0' jb .noletter cmp byte[esi],'9' jbe .yesletter cmp byte[esi],'A' jb .noletter cmp byte[esi],'Z' jbe .yesletter cmp byte[esi],'a' jb .noletter cmp byte[esi],'z' ja .noletter .yesletter inc al .noletter inc esi dec ecx jnz .nextletter cmp al,12 jna .checkhiromletter mov byte[romtype],1 jmp .donecheck .checkhiromletter mov esi,[romdata] add esi,65472 mov ecx,21 mov al,0 .nextletterb cmp byte[esi],32 je .yesletterb cmp byte[esi],'0' jb .noletterb cmp byte[esi],'9' jbe .yesletterb cmp byte[esi],'A' jb .noletterb cmp byte[esi],'Z' jbe .yesletterb cmp byte[esi],'a' jb .noletterb cmp byte[esi],'z' ja .noletterb .yesletterb inc al .noletterb inc esi dec ecx jnz .nextletterb cmp al,12 jna .notfound mov byte[romtype],2 jmp .donecheck .notfound mov esi,[romdata] mov ax,[esi+0FFFCh] mov bx,[esi+07FFCh] cmp ax,8000h jne .checkloarea8000 cmp bx,8000h je .notfound28000 mov byte[romtype],2 jmp .donecheck .checkloarea8000 cmp bx,8000h jne .notfound28000 mov byte[romtype],1 jmp .donecheck .notfound28000 mov byte[ROMTypeNOTFound],1 .donecheck cmp byte[ForceHiLoROM],0 je .noguiforce mov al,[ForceHiLoROM] mov byte[forceromtype],al xor al,al .noguiforce cmp byte[forceromtype],0 je .noforce mov al,[forceromtype] mov [romtype],al mov byte[forceromtype],0 mov byte[ROMTypeNOTFound],0 jmp .doneinterl .noforce mov byte[intldone],0 cmp byte[romtype],1 jne .nointerlcheck mov esi,[romdata] add esi,7FD5h cmp byte[esi],21h je .interleaved cmp byte[esi],92h je .interleaved mov eax,[romdata] add eax,07FC0h cmp dword[eax+8],'EST3' je .interleaved cmp byte[eax],'T' je .nointerlcheck cmp byte[esi],31h jne .nointerlcheck .interleaved cmp byte[finterleave],1 je .doneinterl .interleaved2 mov byte[intldone],1 call UnInterleave mov byte[romtype],2 jmp .doneinterl .nointerlcheck cmp byte[finterleave],1 je .interleaved2 .doneinterl mov esi,[romdata] add esi,0FFC0h mov byte[disablespcclr],0 mov eax,50205040h or eax,0A000302h cmp dword[esi],eax jne .nospcdis mov byte[disablespcclr],1 .nospcdis mov eax,[esi] mov byte[DSP1Type],0 mov esi,[romdata] add esi,32704+22 cmp byte[romtype],2 jne .nohirom2 add esi,8000h .nohirom2 mov al,[esi] cmp al,3 je .dsp1 cmp al,4 je .dsp1 cmp al,5 je .dsp1 jmp .nodsp1 .dsp1 call InitDSP mov byte[DSP1Type],1 cmp byte[romtype],2 jne .nodsp1 mov byte[DSP1Type],2 .nodsp1 ; banks 0-3Fh mov dword[memtabler8+3Fh*4],regaccessbankr8 mov dword[memtablew8+3Fh*4],regaccessbankw8 mov dword[memtabler16+3Fh*4],regaccessbankr16 mov dword[memtablew16+3Fh*4],regaccessbankw16 mov dword[memtabler8+0BFh*4],regaccessbankr8 mov dword[memtablew8+0BFh*4],regaccessbankw8 mov dword[memtabler16+0BFh*4],regaccessbankr16 mov dword[memtablew16+0BFh*4],regaccessbankw16 mov dword[memtabler8+70h*4],sramaccessbankr8 mov dword[memtablew8+70h*4],sramaccessbankw8 mov dword[memtabler16+70h*4],sramaccessbankr16 mov dword[memtablew16+70h*4],sramaccessbankw16 mov dword[memtabler8+71h*4],sramaccessbankr8 mov dword[memtablew8+71h*4],sramaccessbankw8 mov dword[memtabler16+71h*4],sramaccessbankr16 mov dword[memtablew16+71h*4],sramaccessbankw16 mov dword[memtabler8+72h*4],sramaccessbankr8 mov dword[memtablew8+72h*4],sramaccessbankw8 mov dword[memtabler16+72h*4],sramaccessbankr16 mov dword[memtablew16+72h*4],sramaccessbankw16 mov dword[memtabler8+73h*4],sramaccessbankr8 mov dword[memtablew8+73h*4],sramaccessbankw8 mov dword[memtabler16+73h*4],sramaccessbankr16 mov dword[memtablew16+73h*4],sramaccessbankw16 mov dword[memtabler8+78h*4],memaccessbankr8 mov dword[memtablew8+78h*4],memaccessbankw8 mov dword[memtabler16+78h*4],memaccessbankr16 mov dword[memtablew16+78h*4],memaccessbankw16 mov dword[memtabler8+79h*4],memaccessbankr8 mov dword[memtablew8+79h*4],memaccessbankw8 mov dword[memtabler16+79h*4],memaccessbankr16 mov dword[memtablew16+79h*4],memaccessbankw16 mov esi,[romdata] add esi,32704+22 cmp byte[romtype],2 jne .nohirom2b add esi,8000h .nohirom2b mov byte[SFXEnable],0 mov byte[C4Enable],0 mov byte[SPC7110Enable],0 mov byte[RTCEnable],0 mov byte[SA1Enable],0 mov byte[SDD1Enable],0 mov byte[SFXSRAM],0 mov byte[OBCEnable],0 mov al,[esi] cmp al,055h jne .noRTC mov byte[RTCEnable],1 .noRTC cmp al,0F5h je .yesSPC7110 cmp al,0F9h jne .noSPC7110 .yesSPC7110 mov byte[SPC7110Enable],1 jmp .nosfx .noSPC7110 cmp al,0F3h jne .noc4chip mov byte[C4Enable],1 jmp .nosfx .noc4chip and al,0F0h cmp al,10h je .yessfx cmp al,20h je .yesobc cmp al,30h je near .yessa1 cmp al,40h je near .yessdd1 jmp .nosfx .yessfx mov al,[esi] and al,0Fh cmp al,5 je .sram cmp al,6 jne .nosram .sram mov byte[SFXSRAM],1 .nosram cmp byte[Sup48mbit],1 je .sfxokay mov byte[yesoutofmemory],1 jmp .nosfx .sfxokay mov esi,[romdata] add esi,32704 cmp dword[esi],'META' jne .notsfx .yesobc mov byte[OBCEnable],1 jmp .nosfx .notsfx mov byte[SFXEnable],1 mov dword[memtabler8+70h*4],sfxaccessbankr8 mov dword[memtablew8+70h*4],sfxaccessbankw8 mov dword[memtabler16+70h*4],sfxaccessbankr16 mov dword[memtablew16+70h*4],sfxaccessbankw16 mov dword[memtabler8+71h*4],sfxaccessbankr8b mov dword[memtablew8+71h*4],sfxaccessbankw8b mov dword[memtabler16+71h*4],sfxaccessbankr16b mov dword[memtablew16+71h*4],sfxaccessbankw16b mov dword[memtabler8+72h*4],sfxaccessbankr8c mov dword[memtablew8+72h*4],sfxaccessbankw8c mov dword[memtabler16+72h*4],sfxaccessbankr16c mov dword[memtablew16+72h*4],sfxaccessbankw16c mov dword[memtabler8+73h*4],sfxaccessbankr8d mov dword[memtablew8+73h*4],sfxaccessbankw8d mov dword[memtabler16+73h*4],sfxaccessbankr16d mov dword[memtablew16+73h*4],sfxaccessbankw16d mov dword[memtabler8+78h*4],sramaccessbankr8s mov dword[memtablew8+78h*4],sramaccessbankw8s mov dword[memtabler16+78h*4],sramaccessbankr16s mov dword[memtablew16+78h*4],sramaccessbankw16s mov dword[memtabler8+79h*4],sramaccessbankr8s mov dword[memtablew8+79h*4],sramaccessbankw8s mov dword[memtabler16+79h*4],sramaccessbankr16s mov dword[memtablew16+79h*4],sramaccessbankw16s mov dword[SfxR1],0 mov dword[SfxR2],0 mov esi,[sfxramdata] mov ecx,65536 .loopsfxclear mov dword[esi],0 add esi,4 dec ecx jnz .loopsfxclear cmp byte[SramExists],0 je .nosramsfx mov esi,[sram] mov edi,[sfxramdata] mov ecx,16384 .sfxsramloop mov eax,[esi] mov [edi],eax add esi,4 add edi,4 dec ecx jnz .sfxsramloop .nosramsfx call InitFxTables .nosfx jmp .nosa1 .yessdd1 mov byte[SDD1Enable],1 jmp .nosa1 .yessa1 mov byte[SA1Enable],1 .nosa1 mov dword[SfxSFR],0 mov byte[SfxSCMR],0 call initregr call initregw cmp byte[SA1Enable],0 je .nosa1init call GenerateBank0TableSA1 call SetAddressingModesSA1 ; open .srm file mov edx,fnames+1 call Open_File jc .nosa1init mov byte[SramExists],1 mov bx,ax mov ecx,65536*2 mov edx,[romdata] add edx,1024*4096 call Read_File jc .nosa1init call Close_File .nosa1init cmp byte[DSP1Type],1 jne .nodsp1lorom xor ecx,ecx .dsp1loop mov dword[memtabler8+30h*4+ecx],DSP1Read8b3F mov dword[memtablew8+30h*4+ecx],DSP1Write8b3F mov dword[memtabler16+30h*4+ecx],DSP1Read16b3F mov dword[memtablew16+30h*4+ecx],DSP1Write16b3F mov dword[memtabler8+0B0h*4+ecx],DSP1Read8b3F mov dword[memtablew8+0B0h*4+ecx],DSP1Write8b3F mov dword[memtabler16+0B0h*4+ecx],DSP1Read16b3F mov dword[memtablew16+0B0h*4+ecx],DSP1Write16b3F add ecx,4 cmp ecx,16*4 jne .dsp1loop .nodsp1lorom mov dword[wramdata],wramdataa call SPC7110Load ret SECTION .data NEWSYM SFXEnable, db 0 NEWSYM C4Enable, db 0 NEWSYM SPC7110Enable, db 0 NEWSYM RTCEnable, db 0 NEWSYM SA1Enable, db 0 NEWSYM SDD1Enable, db 0 NEWSYM OBCEnable, db 0 NEWSYM C4RamR, dd 0 NEWSYM C4RamW, dd 0 NEWSYM C4Ram, dd 0 NEWSYM ROMTypeNOTFound, db 0 SECTION .text NEWSYM SetIRQVectors ; Get Vectors (NMI & Reset) mov esi,[romdata] add esi,32704+21 cmp byte[romtype],2 jne .nohirom9 add esi,8000h .nohirom9 mov al,[esi] test al,0F0h jnz .yesfastrom mov al,[opexec268] mov [opexec358],al mov al,[opexec268cph] mov [opexec358cph],al mov al,[cycpb268] mov [cycpb358],al .yesfastrom mov esi,[romdata] add esi,7FE4h cmp byte[romtype],2 jne .nohirom add esi,8000h .nohirom cmp word[esi+24],0FFFFh jne .notreseterror mov word[esi+6],0FF9Ch mov word[esi+24],0FF80h .notreseterror lodsw mov [copv],ax lodsw mov [brkv],ax lodsw mov [abortv],ax lodsw mov [nmiv],ax mov [nmiv2],ax add esi,2 lodsw mov [irqv],ax mov [irqv2],ax add esi,4 ; 8-bit and reset lodsw mov [copv8],ax inc esi inc esi lodsw mov [abortv8],ax lodsw mov [nmiv8],ax lodsw mov [resetv],ax lodsw mov [brkv8],ax mov [irqv8],ax cmp byte[yesoutofmemory],0 je .notfailed mov word[resetv],8000h mov esi,[romdata] mov word[esi],0FE80h mov word[esi+8000h],0FE80h .notfailed ret NEWSYM outofmemfix mov esi,[romdata] cmp byte[romtype],2 je .hirom mov word[resetv],8000h mov word[xpc],8000h mov byte[esi],58h mov byte[esi+1],80h mov byte[esi+2],0FEh mov dword[Msgptr],outofmemoryerror cmp byte[newgfx16b],1 jne .notso mov dword[Msgptr],outofmemoryerror2 .notso mov dword[MessageOn],0FFFFFFFFh ret .hirom add esi,8000h mov word[resetv],8000h mov word[xpc],8000h mov byte[esi],58h mov byte[esi+1],80h mov byte[esi+2],0FEh mov dword[Msgptr],outofmemoryerror cmp byte[newgfx16b],1 jne .notso2 mov dword[Msgptr],outofmemoryerror2 .notso2 mov dword[MessageOn],0FFFFFFFFh ret SECTION .data NEWSYM yesoutofmemory, db 0 NEWSYM outofmemoryerror, db 'OUT OF MEMORY.',0 NEWSYM outofmemoryerror2, db 'ROM IS TOO BIG.',0 SECTION .text NEWSYM InitAsmEnd zsnes-1.36/src/link.win320100644000175000017500000000226107432621303014575 0ustar dolsondolson/Fezsnesw.exe chips\dsp1proc.obj dos\sw.obj dos\gppro.obj dos\vesa12.obj dos\zsipx.obj dos\modemrtn.obj dos\joy.obj dos\debug.obj dos\vesa2.obj dos\initvid.obj cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj smoke.obj video\procvid.obj win\copyvwin.obj win\winintrf.obj win\winlink.obj win\zloaderw.obj win\ztcp.obj win\zfilew.obj win\zipxw.obj video\makev16b.obj video\makev16t.obj video\makevid.obj video\mode716.obj video\mode716b.obj video\mode716d.obj video\mode716e.obj video\mode716t.obj video\mode7.obj video\mode7ext.obj video\mv16tms.obj video\newg162.obj video\newgfx16.obj video\newgfx2.obj video\newgfx.obj video\m716text.obj video\2xsaiw.obj gui\gui.obj gui\menu.obj cpu\addrni.obj cpu\dma.obj cpu\dsp.obj cpu\dspproc.obj cpu\execute.obj cpu\irq.obj cpu\memory.obj cpu\spc700.obj cpu\stable.obj cpu\table.obj cpu\tableb.obj cpu\tablec.obj chips\dsp1emu.obj chips\fxemu2.obj chips\fxemu2b.obj chips\fxemu2c.obj chips\fxtable.obj chips\sa1proc.obj chips\sa1regs.obj chips\sfxproc.obj zip\unzip.obj zip\zzip.obj zip\zpng.obj zlib.lib libpng.lib wsock32.lib user32.lib gdi32.lib shell32.lib winmm.lib ddraw.lib dsound.lib dinput8.lib d3dx.lib /link /section:.text,erw zsnes-1.36/src/macros.mac0100644000175000017500000000535407514702750014737 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. bits 32 section .text ; Zsnes required macros %define ZVERSION '1.36' %ifdef ELF %imacro newsym 1 GLOBAL %1 %1: %endmacro %imacro newsym 2+ GLOBAL %1 %1: %2 %endmacro %define EXTSYM EXTERN %macro ALIGN32 0 times ($$-$) & 1Fh nop ; Long word alignment %endmacro %macro ALIGN16 0 times ($$-$) & 1Fh nop ; Long word alignment %endmacro %else %imacro newsym 1 GLOBAL _%1 _%1: %1: %endmacro %imacro newsym 2+ GLOBAL _%1 _%1: %1: %2 %endmacro %macro ALIGN32 0 times ($$-$) & 1Fh nop ; Long word alignment %endmacro %macro ALIGN16 0 times ($$-$) & 1Fh nop ; Long word alignment %endmacro %imacro extsym 1-* %rep %0 EXTERN _%1 %define %1 _%1 %rotate 1 %endrep %endmacro %endif ; macro more or less similar to STUB_FUNCTION ; you can call it without argument, ; or with a string arg which will be displayed %macro STUB_ASM 0-1 "STUB_ASM" %ifndef __PRINTF__ %define __PRINTF__ EXTSYM printf %endif [section .data] %%string: db %1, 0 %%strformat: db '%s in %s line %u',13, 10,0 %%filename: db __FILE__, 0 __SECT__ ;stubasm: pushad mov eax, __LINE__ push eax mov eax, %%filename push eax mov eax, %%string push eax mov eax, %%strformat push eax call printf add esp, 16 popad %endmacro ; same as above but prints the string ; whose address is the argument to the macros %macro STUB_ASM_STR 1 %ifndef __PRINTF__ %define __PRINTF__ EXTSYM printf %endif [section .data] %%strformat: db '%s in %s line %u',13, 10,0 %%filename: db __FILE__, 0 __SECT__ ;stubasm: pushad mov eax, __LINE__ push eax mov eax, %%filename push eax mov eax, %1 push eax mov eax, %%strformat push eax call printf add esp, 16 popad %endmacro ; same as above but prints a number %macro STUB_ASM_INT 1 %ifndef __PRINTF__ %define __PRINTF__ EXTSYM printf %endif [section .data] %%strformat: db '%x in %s line %u',13, 10,0 %%filename: db __FILE__, 0 __SECT__ ;stubasm: pushad mov eax, __LINE__ push eax mov eax, %%filename push eax mov eax, %1 push eax mov eax, %%strformat push eax call printf add esp, 16 popad %endmacro zsnes-1.36/src/makefile.dos0100644000175000017500000001706307437232352015255 0ustar dolsondolson#Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either #version 2 of the License, or (at your option) any later #version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. CHIPDIR=chips CPUDIR=cpu DOSDIR=dos GUIDIR=gui VIDEODIR=video WINDIR=win OBJDIR=obj ZIPDIR=zip CHIPSOBJ=${CHIPDIR}/dsp1emu.o ${CHIPDIR}/fxemu2.o ${CHIPDIR}/sfxproc.o\ ${CHIPDIR}/fxemu2b.o ${CHIPDIR}/fxemu2c.o ${CHIPDIR}/fxtable.o\ ${CHIPDIR}/sa1proc.o ${CHIPDIR}/sa1regs.o ${CHIPDIR}/dsp1proc.o CPUOBJ=${CPUDIR}/addrni.o ${CPUDIR}/dma.o ${CPUDIR}/dsp.o ${CPUDIR}/dspproc.o\ ${CPUDIR}/execute.o ${CPUDIR}/irq.o ${CPUDIR}/memory.o\ ${CPUDIR}/spc700.o ${CPUDIR}/stable.o ${CPUDIR}/table.o\ ${CPUDIR}/tableb.o ${CPUDIR}/tablec.o GUIOBJ=${GUIDIR}/gui.o ${GUIDIR}/menu.o VIDEOBJ=${VIDEODIR}/makev16b.o ${VIDEODIR}/makev16t.o ${VIDEODIR}/makevid.o\ ${VIDEODIR}/mode716.o ${VIDEODIR}/mode716b.o ${VIDEODIR}/mode716d.o\ ${VIDEODIR}/mode716e.o ${VIDEODIR}/mode716t.o ${VIDEODIR}/mode7.o\ ${VIDEODIR}/mode7ext.o ${VIDEODIR}/mv16tms.o ${VIDEODIR}/newg162.o\ ${VIDEODIR}/newgfx16.o ${VIDEODIR}/newgfx2.o ${VIDEODIR}/newgfx.o\ ${VIDEODIR}/m716text.o ${VIDEODIR}/procvid.o DOSOBJ= ${DOSDIR}/dosintrf.o ${DOSDIR}/gppro.o ${DOSDIR}/debug.o\ ${DOSDIR}/initvid.o ${DOSDIR}/modemrtn.o ${DOSDIR}/sw32.o\ ${DOSDIR}/joy.o ${DOSDIR}/sw.o ${DOSDIR}/vesa12.o ${DOSDIR}/vesa2.o\ ${DOSDIR}/zloader.o ${DOSDIR}/zsipx.o ${DOSDIR}/zfile.o WINOBJ=${WINDIR}/copywin.o ${WINDIR}/winintrf.o ${WINDIR}/winlink.o\ ${WINDIR}/zloaderw.o ${WINDIR}/ztcp.o ${WINDIR}/zipxw.o PREOBJ=${OBJDIR}/dosbuff.o ${OBJDIR}/ipx.o ${OBJDIR}/zipx.o ZIPOBJ=${ZIPDIR}/zzip.o ${ZIPDIR}/unzip.o ${ZIPDIR}/zpng.o MAINOBJ=cfgload.o endmem.o fixsin.o init.o ui.o vcache.o water.o smoke.o OBJS=${CHIPSOBJ} ${CPUOBJ} ${DOSOBJ} ${GUIOBJ} ${VIDEOBJ} ${PREOBJ} ${MAINOBJ} ${ZIPOBJ} LIBS=-lz -lm -lpng #CFLAGS=-O2 -Wall -Wno-unused -D__MSDOS__ CFLAGS=-O3 -march=i486 -fno-rtti -fno-exceptions -ffast-math\ -fomit-frame-pointer -fno-unroll-loops -Wall -Wno-unused -D__MSDOS__ ASM=nasm ASMFLAGS=-f coff -D__MSDOS__ CC=gcc PP=gpp .SUFFIXES: .c .cpp .asm %.o: %.c ${CC} ${CFLAGS} -o $@ -c $< %.o: %.cpp ${PP} ${CFLAGS} -o $@ -c $< %.o: %.asm ${ASM} ${ASMFLAGS} -o $@ $< ALL: zsnes.exe debug: zsnesd.exe zsnes.exe: ${OBJS} ${CC} -Ws -s -o zsnes.exe ${OBJS} ${LIBS} zsnesd.exe: ${OBJS} ${CC} -Ws -o zsnesd.exe ${OBJS} ${LIBS} ${DOSDIR}/zloader.o: ${DOSDIR}/zloader.c fixsin.o: fixsin.c water.o: water.c smoke.o: smoke.c ${DOSDIR}/zfile.o: ${DOSDIR}/zfile.c ${ZIPDIR}/unzip.o: ${ZIPDIR}/unzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/zzip.o: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/zpng.o: ${ZIPDIR}/zpng.c ${ZIPDIR}/zpng.h ${VIDEODIR}/procvid.o: ${VIDEODIR}/procvid.asm macros.mac ${VIDEODIR}/copyvid.inc ${VIDEODIR}/2xSaImmx.inc ${CHIPDIR}/dsp1proc.o: ${CHIPDIR}/dsp1proc.asm macros.mac ${CHIPDIR}/sa1regs.o: ${CHIPDIR}/sa1regs.asm macros.mac\ ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CHIPDIR}/sfxproc.o: ${CHIPDIR}/sfxproc.asm macros.mac\ ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CHIPDIR}/dsp1emu.o: ${CHIPDIR}/dsp1emu.c ui.o: ui.asm macros.mac cfgload.o:cfgload.asm macros.mac init.o:init.asm macros.mac ${DOSDIR}/debug.o: ${DOSDIR}/debug.asm macros.mac ${CPUDIR}/execute.o: ${CPUDIR}/execute.asm macros.mac ${CPUDIR}/table.o: ${CPUDIR}/table.asm ${CPUDIR}/65816d.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816.inc\ ${CPUDIR}/regs.mac ${CPUDIR}/regs.inc ${CPUDIR}/regsw.mac\ ${CPUDIR}/regsw.inc macros.mac ${CPUDIR}/tableb.o: ${CPUDIR}/tableb.asm ${CPUDIR}/65816db.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816b.inc\ ${CPUDIR}/regs.mac macros.mac ${CPUDIR}/tablec.o: ${CPUDIR}/tablec.asm ${CPUDIR}/65816dc.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816c.inc\ ${CPUDIR}/regs.mac macros.mac ${CPUDIR}/stable.o: ${CPUDIR}/stable.asm ${CPUDIR}/s65816d.inc\ ${CPUDIR}/saddress.inc ${CPUDIR}/saddrni.inc ${CPUDIR}/se65816.inc\ macros.mac ${CPUDIR}/memory.o: ${CPUDIR}/memory.asm macros.mac ${CPUDIR}/dma.o: ${CPUDIR}/dma.asm macros.mac ${DOSDIR}/dosintrf.o: ${DOSDIR}/dosintrf.asm macros.mac vcache.o:vcache.asm macros.mac ${DOSDIR}/initvid.o:${DOSDIR}/initvid.asm macros.mac ${DOSDIR}/vga.inc ${VIDEODIR}/makevid.o: ${VIDEODIR}/makevid.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/makev16b.o: ${VIDEODIR}/makev16b.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/makev16t.o: ${VIDEODIR}/makev16t.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/mv16tms.o: ${VIDEODIR}/mv16tms.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/mode7.o: ${VIDEODIR}/mode7.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716.o: ${VIDEODIR}/mode716.asm ${VIDEODIR}/mode716.mac\ macros.mac ${VIDEODIR}/mode716b.o:${VIDEODIR}/mode716b.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716t.o:${VIDEODIR}/mode716t.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716d.o:${VIDEODIR}/mode716d.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode7ext.o:${VIDEODIR}/mode7ext.asm macros.mac ${VIDEODIR}/mode716e.o:${VIDEODIR}/mode716e.asm macros.mac ${VIDEODIR}/m716text.o:${VIDEODIR}/m716text.asm ${VIDEODIR}/mode7.mac\ macros.mac ${CPUDIR}/irq.o: ${CPUDIR}/irq.asm macros.mac ${CPUDIR}/dspproc.o: ${CPUDIR}/dspproc.asm macros.mac ${CPUDIR}/spc700.o:${CPUDIR}/spc700.asm macros.mac\ ${CPUDIR}/regsw.mac ${CPUDIR}/spcdef.inc ${CPUDIR}/spcaddr.inc ${CPUDIR}/dsp.o: ${CPUDIR}/dsp.asm macros.mac ${DOSDIR}/vesa2.o: ${DOSDIR}/vesa2.asm macros.mac ${DOSDIR}/vesa12.o: ${DOSDIR}/vesa12.asm macros.mac ${DOSDIR}/joy.o: ${DOSDIR}/joy.asm macros.mac ${DOSDIR}/sw.o: ${DOSDIR}/sw.asm macros.mac ${GUIDIR}/gui.o: ${GUIDIR}/gui.asm ${GUIDIR}/guitools.inc\ ${GUIDIR}/guimisc.inc ${GUIDIR}/guimouse.inc ${GUIDIR}/guiwindp.inc\ ${GUIDIR}/guinetpl.inc ${GUIDIR}/guikeys.inc ${GUIDIR}/guicheat.inc\ ${GUIDIR}/guicombo.inc ${GUIDIR}/guiload.inc macros.mac ${GUIDIR}/menu.o: ${GUIDIR}/menu.asm macros.mac ${VIDEODIR}/newgfx.o:${VIDEODIR}/newgfx.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx2.mac ${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx2.o:${VIDEODIR}/newgfx2.asm ${VIDEODIR}/newgfxwn.mac\ ${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx16.o: ${VIDEODIR}/newgfx16.asm macros.mac ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx16.mac ${VIDEODIR}/newg162.mac ${VIDEODIR}/newg162.o: macros.mac ${VIDEODIR}/newg162.asm ${VIDEODIR}/newg162.mac\ ${VIDEODIR}/vidmacro.mac ${VIDEODIR}/newg16wn.mac ${CHIPDIR}/fxemu2.o: ${CHIPDIR}/fxemu2.asm ${CHIPDIR}/fxemu2.mac\ macros.mac ${CHIPSDIR}/fxemu2b.o: ${CHIPDIR}/fxemu2b.asm ${CHIPDIR}/fxemu2.mac\ ${CHIPDIR}/fxemu2b.mac ${CHIPSDIR}/fxemu2c.o: ${CHIPDIR}/fxemu2c.asm macros.mac ${CHIPDIR}/fxemu2.mac\ ${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2c.mac ${CHIPDIR}/fxtable.o: ${CHIPDIR}/fxtable.asm macros.mac ${DOSDIR}/gppro.o: ${DOSDIR}/gppro.asm macros.mac ${DOSDIR}/zsipx.o: ${DOSDIR}/zsipx.asm ${CHIPDIR}/sa1proc.o: ${CHIPDIR}/sa1proc.asm macros.mac endmem.o: endmem.asm macros.mac ${DOSDIR}/modemrtn.o: ${DOSDIR}/modemrtn.asm macros.mac clean: del *.o del ${CHIPDIR}\*.o del ${CPUDIR}\*.o del ${VIDEODIR}\*.o del ${GUIDIR}\*.o del ${DOSDIR}\*.o del ${ZIPDIR}\*.o del zsnes.exe zsnes-1.36/src/autogen.sh0100755000175000017500000000026207437066170014766 0ustar dolsondolson#!/bin/sh echo "Generating build information using aclocal and autoconf..." # Regenerate configuration files aclocal autoconf # Run configure for this platform ./configure $* zsnes-1.36/src/makefile.win0100644000175000017500000002135107437232415015260 0ustar dolsondolson#Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either #version 2 of the License, or (at your option) any later #version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #This file depends on link.win32 so if you modify this makefile, #don't forget to update link.win32 #it is quite ugly but without that trick, the compilation didn't #work for me (command line too long) #put the correct path to your directx sdk here DXDIR=c:\mssdk CHIPDIR=chips CPUDIR=cpu DOSDIR=dos GUIDIR=gui VIDEODIR=video WINDIR=win OBJDIR=obj ZIPDIR=zip CHIPSOBJ=${CHIPDIR}/sfxproc.obj ${CHIPDIR}/fxemu2.obj ${CHIPDIR}/dsp1proc.obj\ ${CHIPDIR}/fxemu2b.obj ${CHIPDIR}/fxemu2c.obj ${CHIPDIR}/fxtable.obj\ ${CHIPDIR}/sa1proc.obj ${CHIPDIR}/sa1regs.obj ${CHIPDIR}/dsp1emu.obj CPUOBJ=${CPUDIR}/addrni.obj ${CPUDIR}/dma.obj ${CPUDIR}/dsp.obj ${CPUDIR}/dspproc.obj\ ${CPUDIR}/execute.obj ${CPUDIR}/irq.obj ${CPUDIR}/memory.obj\ ${CPUDIR}/spc700.obj ${CPUDIR}/stable.obj ${CPUDIR}/table.obj\ ${CPUDIR}/tableb.obj ${CPUDIR}/tablec.obj GUIOBJ=${GUIDIR}/gui.obj ${GUIDIR}/menu.obj VIDEOBJ=${VIDEODIR}/makev16b.obj ${VIDEODIR}/makev16t.obj ${VIDEODIR}/makevid.obj\ ${VIDEODIR}/mode716.obj ${VIDEODIR}/mode716b.obj ${VIDEODIR}/mode716d.obj\ ${VIDEODIR}/mode716e.obj ${VIDEODIR}/mode716t.obj ${VIDEODIR}/mode7.obj\ ${VIDEODIR}/mode7ext.obj ${VIDEODIR}/mv16tms.obj ${VIDEODIR}/newg162.obj\ ${VIDEODIR}/newgfx16.obj ${VIDEODIR}/newgfx2.obj ${VIDEODIR}/newgfx.obj\ ${VIDEODIR}/m716text.obj ${VIDEODIR}/2xsaiw.obj\ ${VIDEODIR}/procvid.obj WINOBJ=${WINDIR}/copyvwin.obj ${WINDIR}/winintrf.obj ${WINDIR}/winlink.obj\ ${WINDIR}/zloaderw.obj ${WINDIR}/ztcp.obj ${WINDIR}/zipxw.obj\ ${WINDIR}/zfilew.obj WINDOSOBJ=${DOSDIR}/debug.obj ${DOSDIR}/joy.obj ${DOSDIR}/modemrtn.obj ${DOSDIR}/vesa2.obj\ ${DOSDIR}/initvid.obj ${DOSDIR}/sw.obj ${DOSDIR}/gppro.obj ${DOSDIR}/vesa12.obj\ ${DOSDIR}/zsipx.obj PREOBJ= ZIPOBJ=${ZIPDIR}/zzip.obj ${ZIPDIR}/unzip.obj ${ZIPDIR}/zpng.obj MAINOBJ=cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj smoke.obj OBJS=${CHIPSOBJ} ${CPUOBJ} ${WINOBJ} ${GUIOBJ} ${VIDEOBJ} ${ZIPOBJ} ${MAINOBJ} ${WINDOSOBJ} LIBS= CFLAGS=/Ox /G6 /c /D__WIN32__ ASM=nasm ASMFLAGS=-f win32 -D__WIN32__ CC=cl .SUFFIXES: .c .cpp .asm %.obj : %.c ${CC} ${CFLAGS} /Fo$@ $< %.obj: %.cpp ${CC} ${CFLAGS} /Fo$@ $< %.obj: %.asm ${ASM} ${ASMFLAGS} -o $@ $< ALL: zsnesw.exe zsnesw.exe: ${OBJS} ${WINDIR}/zsnes.res cl @link.win32 ${WINDIR}/zsnes.res /link /libpath:${DXDIR}\lib ${WINDIR}/zsnes.res: ${WINDIR}/zsnes.rc rc ${WINDIR}/zsnes.rc ${WINDIR}/copyvwin.obj: ${WINDIR}/copyvwin.asm macros.mac ${WINDIR}/winintrf.obj: ${WINDIR}/winintrf.asm macros.mac ${WINDIR}/zfilew.obj: ${WINDIR}/zfilew.c ${WINDIR}/zipxw.obj: ${WINDIR}/zipxw.c ${WINDIR}/zloaderw.obj: ${WINDIR}/zloaderw.c ${WINDIR}/ztcp.obj: ${WINDIR}/ztcp.c ${WINDIR}/winlink.obj: ${WINDIR}/winlink.cpp ${WINDIR}/resource.h ${ZIPDIR}/unzip.obj: ${ZIPDIR}/unzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/zzip.obj: ${ZIPDIR}/zzip.c ${ZIPDIR}/unzip.h ${ZIPDIR}/zpng.obj: ${ZIPDIR}/zpng.c ${ZIPDIR}/zpng.h ${DOSDIR}/initvid.o:${DOSDIR}/initvid.asm macros.mac ${DOSDIR}/modemrtn.o: ${DOSDIR}/modemrtn.asm macros.mac ${DOSDIR}/zsipx.o: ${DOSDIR}/zsipx.asm ${DOSDIR}/debug.obj: ${DOSDIR}/debug.asm macros.mac ${DOSDIR}/joy.obj: ${DOSDIR}/joy.asm macros.mac ${DOSDIR}/vesa2.obj: ${DOSDIR}/vesa2.asm macros.mac ${DOSDIR}/gppro.o: ${DOSDIR}/gppro.asm macros.mac ${DOSDIR}/sw.o: ${DOSDIR}/sw.asm macros.mac ${DOSDIR}/vesa12.o: ${DOSDIR}/vesa12.asm macros.mac fixsin.obj: fixsin.c water.obj: water.c smoke.obj: smoke.c ${VIDEODIR}/2xsaiw.obj: ${VIDEODIR}/2xsaiw.asm macros.mac ${VIDEODIR}/procvid.obj: ${VIDEODIR}/procvid.asm macros.mac ${VIDEODIR}/copyvid.inc ${VIDEODIR}/2xSaImmx.inc ${CHIPDIR}/sa1regs.obj: ${CHIPDIR}/sa1regs.asm macros.mac\ ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CHIPDIR}/sfxproc.obj: ${CHIPDIR}/sfxproc.asm macros.mac\ ${CPUDIR}/regs.mac ${CPUDIR}/regsw.mac ${CHIPDIR}/dsp1emu.obj: ${CHIPDIR}/dsp1emu.c ${CC} ${CFLAGS} /Fo$@ $< ${CHIPDIR}/dsp1proc.obj: ${CHIPDIR}/dsp1proc.asm macros.mac ui.obj: ui.asm macros.mac cfgload.obj:cfgload.asm macros.mac init.obj:init.asm macros.mac ${DOSDIR}/debug.obj: ${DOSDIR}/debug.asm macros.mac ${CPUDIR}/addrni.obj: ${CPUDIR}/addrni.asm ${CPUDIR}/execute.obj: ${CPUDIR}/execute.asm macros.mac ${CPUDIR}/table.obj: ${CPUDIR}/table.asm ${CPUDIR}/65816d.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816.inc\ ${CPUDIR}/regs.mac ${CPUDIR}/regs.inc ${CPUDIR}/regsw.mac\ ${CPUDIR}/regsw.inc macros.mac ${CPUDIR}/tableb.obj: ${CPUDIR}/tableb.asm ${CPUDIR}/65816db.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816b.inc\ ${CPUDIR}/regs.mac macros.mac ${CPUDIR}/tablec.obj: ${CPUDIR}/tablec.asm ${CPUDIR}/65816dc.inc\ ${CPUDIR}/address.inc ${CPUDIR}/addrni.inc ${CPUDIR}/e65816c.inc\ ${CPUDIR}/regs.mac macros.mac ${CPUDIR}/stable.obj: ${CPUDIR}/stable.asm ${CPUDIR}/s65816d.inc\ ${CPUDIR}/saddress.inc ${CPUDIR}/saddrni.inc ${CPUDIR}/se65816.inc\ macros.mac ${CPUDIR}/memory.obj: ${CPUDIR}/memory.asm macros.mac ${CPUDIR}/dma.obj: ${CPUDIR}/dma.asm macros.mac ${DOSDIR}/dosintrf.obj: ${DOSDIR}/dosintrf.asm macros.mac vcache.obj:vcache.asm macros.mac ${DOSDIR}/initvid.obj:${DOSDIR}/initvid.asm macros.mac ${VIDEODIR}/makevid.obj: ${VIDEODIR}/makevid.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/makev16b.obj: ${VIDEODIR}/makev16b.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/makev16t.obj: ${VIDEODIR}/makev16t.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/mv16tms.obj: ${VIDEODIR}/mv16tms.asm ${VIDEODIR}/vidmacro.mac\ macros.mac ${VIDEODIR}/mode7.obj: ${VIDEODIR}/mode7.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716.obj: ${VIDEODIR}/mode716.asm ${VIDEODIR}/mode716.mac\ macros.mac ${VIDEODIR}/mode716b.obj:${VIDEODIR}/mode716b.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716t.obj:${VIDEODIR}/mode716t.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode716d.obj:${VIDEODIR}/mode716d.asm ${VIDEODIR}/mode7.mac\ macros.mac ${VIDEODIR}/mode7ext.obj:${VIDEODIR}/mode7ext.asm macros.mac ${VIDEODIR}/mode716e.obj:${VIDEODIR}/mode716e.asm macros.mac ${VIDEODIR}/m716text.obj:${VIDEODIR}/m716text.asm ${VIDEODIR}/mode7.mac\ macros.mac ${CPUDIR}/irq.obj: ${CPUDIR}/irq.asm macros.mac ${CPUDIR}/dspproc.obj: ${CPUDIR}/dspproc.asm macros.mac ${CPUDIR}/spc700.obj:${CPUDIR}/spc700.asm macros.mac\ ${CPUDIR}/regsw.mac ${CPUDIR}/spcdef.inc ${CPUDIR}/spcaddr.inc ${CPUDIR}/dsp.obj: ${CPUDIR}/dsp.asm macros.mac ${DOSDIR}/vesa2.obj: ${DOSDIR}/vesa2.asm macros.mac ${DOSDIR}/vesa12.obj: ${DOSDIR}/vesa12.asm macros.mac ${DOSDIR}/joy.obj: ${DOSDIR}/joy.asm macros.mac ${DOSDIR}/sw.obj: ${DOSDIR}/sw.asm macros.mac ${GUIDIR}/gui.obj: ${GUIDIR}/gui.asm ${GUIDIR}/guitools.inc\ ${GUIDIR}/guimisc.inc ${GUIDIR}/guimouse.inc ${GUIDIR}/guiwindp.inc\ ${GUIDIR}/guinetpl.inc ${GUIDIR}/guikeys.inc ${GUIDIR}/guicheat.inc\ ${GUIDIR}/guicombo.inc ${GUIDIR}/guiload.inc macros.mac ${GUIDIR}/menu.obj: ${GUIDIR}/menu.asm macros.mac ${VIDEODIR}/newgfx.obj:${VIDEODIR}/newgfx.asm ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx2.mac ${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx2.obj:${VIDEODIR}/newgfx2.asm ${VIDEODIR}/newgfxwn.mac\ ${VIDEODIR}/newgfx.mac macros.mac ${VIDEODIR}/newgfx16.obj: ${VIDEODIR}/newgfx16.asm macros.mac ${VIDEODIR}/vidmacro.mac\ ${VIDEODIR}/newgfx16.mac ${VIDEODIR}/newg162.mac ${VIDEODIR}/newg162.obj: macros.mac ${VIDEODIR}/newg162.asm ${VIDEODIR}/newg162.mac\ ${VIDEODIR}/vidmacro.mac ${VIDEODIR}/newg16wn.mac ${CHIPDIR}/fxemu2.obj: ${CHIPDIR}/fxemu2.asm ${CHIPDIR}/fxemu2.mac\ macros.mac ${CHIPDIR}/fxemu2b.obj: ${CHIPDIR}/fxemu2b.asm ${CHIPDIR}/fxemu2.mac\ ${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2c.obj: ${CHIPDIR}/fxemu2c.asm macros.mac ${CHIPDIR}/fxemu2.mac\ ${CHIPDIR}/fxemu2b.mac ${CHIPDIR}/fxemu2c.mac ${CHIPDIR}/fxtable.obj: ${CHIPDIR}/fxtable.asm macros.mac ${DOSDIR}/gppro.obj: ${DOSDIR}/gppro.asm macros.mac ${DOSDIR}/zsipx.obj: ${DOSDIR}/zsipx.asm ${CHIPDIR}/sa1proc.obj: ${CHIPDIR}/sa1proc.asm macros.mac endmem.obj: endmem.asm macros.mac ${DOSDIR}/modemrtn.obj: ${DOSDIR}/modemrtn.asm macros.mac clean: del *.obj del ${CHIPDIR}\*.obj del ${CPUDIR}\*.obj del ${VIDEODIR}\*.obj del ${GUIDIR}\*.obj del ${WINDIR}\*.obj del ${WINDIR}\zsnes.res del ${ZIPDIR}\*.obj del ${DOSDIR}\*.obj del zsnesw.exe zsnes-1.36/src/vcache.asm0100644000175000017500000022046207437052314014721 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM MessageOn,MsgCount,Msgptr,Voice0Disable,Voice0Status,Voice1Disable EXTSYM Voice1Status,Voice2Disable,Voice2Status,Voice3Disable,Voice3Status EXTSYM Voice4Disable,Voice4Status,Voice5Disable,Voice5Status,Voice6Disable EXTSYM Voice6Status,Voice7Disable,Voice7Status,bgcmsung,bgmode,cbackofsaddr EXTSYM cbitmode,cgmod,debuggeron,disableeffects,frameskip,frskipper,newgfxerror2 EXTSYM maxbr,modeused,mousexloc,mouseyloc,newengen,newgfx16b,newgfxerror EXTSYM nextdrawallng,oamaddr,pal16b,pal16bxcl,pressed,prevbright,prevpal EXTSYM scaddsngb,scaddtngb,scaddtngbx,scfbl,scrndis,snesmouse,sprprdrn EXTSYM t1cc,vidbright,vidbuffer,vidbufferm,vidbufferofsa,vidbufferofsb EXTSYM vidmemch2,statefileloc,fnamest,GUIClick,MousePRClick,ngmsdraw,cvidmode EXTSYM KeyDisableSC0,KeyDisableSC1,KeyDisableSC2,KeyDisableSC3,KeyDisableSC4 EXTSYM KeyDisableSC5,KeyDisableSC6,KeyDisableSC7,KeyFastFrwrd,SRAMSave5Sec EXTSYM KeyBGDisble0,KeyBGDisble1,KeyBGDisble2,KeyBGDisble3,KeySprDisble EXTSYM KeyResetAll,KeyExtraEnab,KeyWinDisble,KeyNewGfxSwt,KeyOffsetMSw EXTSYM KeyStateSlc0,KeyStateSlc1,KeyStateSlc2,KeyStateSlc3,KeyStateSlc4 EXTSYM KeyStateSlc5,KeyStateSlc6,KeyStateSlc7,KeyStateSlc8,KeyStateSlc9 EXTSYM KeyIncStateSlot,KeyDecStateSlot EXTSYM maxskip,DSPMem,SprValAdd,dsp1ptr,dsp1array,FastFwdToggle,SaveSramData EXTSYM ngextbg,Mode7HiRes,Check60hz,Get_MouseData,Get_MousePositionDisplacement EXTSYM WindowDisables,scanlines,romispal EXTSYM MusicRelVol,MusicVol,WDSPReg0C,WDSPReg1C EXTSYM DSPOp02,Op02AAS,Op02AZS,Op02CX,Op02CY,Op02FX,Op02FY EXTSYM Op02FZ,Op02LES,Op02LFE,Op02VOF,Op02VVA EXTSYM CurRecv EXTSYM CNetType EXTSYM KeySlowDown EXTSYM chaton EXTSYM genfulladdtab EXTSYM KeyFRateDown,KeyFRateUp,KeyVolUp,KeyVolDown,KeyDisplayFPS,FPSOn EXTSYM bg1ptr,bg2ptr,bg3ptr,bg4ptr,cachebg1,resolutn EXTSYM curypos,oamram,objhipr,objptr,objptrn,objsize1,objsize2 EXTSYM spritetablea,sprleftpr,sprlefttot,vcache4b EXTSYM objadds1,objadds2,objmovs1,objmovs2,tltype4b,vidmemch4,vram EXTSYM bgptr,bgptrc,bgptrd,curtileptr,vcache2b EXTSYM vcache8b,vidmemch8 EXTSYM offsetmshl,NextLineCache EXTSYM tltype2b EXTSYM tltype8b,objwlrpos NEWSYM VCacheAsmStart ; Process stuff & Cache sprites NEWSYM fskipped, db 0 NEWSYM objvramadder, dd 0 NEWSYM pobjvram, dw 0 NEWSYM sprprifix, db 1 ALIGN32 NEWSYM OMBGTestVal, dd 0 NEWSYM ngptrdat2, dd 0 NEWSYM ofshvaladd, dd 0 NEWSYM ofsmtptrs, dd 0 NEWSYM ofsmcptr2, dd 0 NEWSYM sramb4save, dd 0 NEWSYM mode7hiresen, dd 1 NEWSYM hiresstuff, dd 0 NEWSYM cmovietimeint, dd 0 NEWSYM overalltimer, dd 0 mousecheck db 0 %macro stateselcomp 3 mov eax,[%1] test byte[pressed+eax],1 je %%nostsl mov byte[pressed+eax],2 mov byte[sselm+11],%2 mov eax,[statefileloc] mov byte[fnamest+eax],%3 mov dword[Msgptr],sselm mov eax,[MsgCount] mov [MessageOn],eax %%nostsl %endmacro %macro soundselcomp 4 mov eax,[%1] test byte[pressed+eax],1 je %%nosdis xor byte[%2],01h mov byte[%3],0 mov byte[pressed+eax],2 mov byte[sndchena+9],%4 mov byte[sndchdis+9],%4 mov dword[Msgptr],sndchena test byte[%2],01h jnz %%sen mov dword[Msgptr],sndchdis %%sen mov eax,[MsgCount] mov [MessageOn],eax %%nosdis %endmacro UpdateVolume: pushad xor eax,eax xor edx,edx mov al,[MusicRelVol] shl eax,7 mov ebx,100 div ebx cmp al,127 jb .noof mov al,127 .noof mov [MusicVol],al mov al,[DSPMem+0Ch] call WDSPReg0C mov al,[DSPMem+1Ch] call WDSPReg1C mov dword[vollv+14],20202020h mov edx,vollv+15 mov al,[MusicRelVol] cmp al,100 jne .no100 mov byte[edx],49 mov byte[edx+1],48 sub al,100 add edx,2 .no100 xor ah,ah mov bl,10 div bl cmp al,0 je .no10 add al,48 mov [edx],al inc edx .no10 add ah,48 mov [edx],ah mov dword[Msgptr],vollv mov eax,[MsgCount] mov [MessageOn],eax popad ret ClockCounter: inc dword[overalltimer] cmp byte[romispal],0 jne .dopal cmp dword[overalltimer],60 jne .notimer inc dword[cmovietimeint] sub dword[overalltimer],60 jmp .notimer .dopal cmp dword[overalltimer],50 jne .notimer inc dword[cmovietimeint] sub dword[overalltimer],50 .notimer test byte[pressed+2Eh],1 jz .noclear mov dword[cmovietimeint],0 mov dword[overalltimer],0 .noclear ret NEWSYM dsp1teststuff ; ///////////////////////////// mov dword[dsp1ptr],0 push eax push ecx mov ecx,4096 mov eax,dsp1array .cvloop mov byte[eax],0 inc eax dec ecx jnz .cvloop pop ecx pop eax ret mov eax,dsp1array add eax,[dsp1ptr] push ebx mov byte[eax],02h mov bx,[Op02FX] mov [eax+1],bx mov bx,[Op02FY] mov [eax+3],bx mov bx,[Op02FZ] mov [eax+5],bx mov bx,[Op02LFE] mov [eax+7],bx mov bx,[Op02LES] mov [eax+9],bx mov bx,[Op02AAS] mov [eax+11],bx mov bx,[Op02AZS] mov [eax+13],bx mov bx,[Op02VOF] mov [eax+15],bx mov bx,[Op02VVA] mov [eax+17],bx mov bx,[Op02CX] mov [eax+19],bx mov bx,[Op02CY] mov [eax+21],bx pop ebx add dword[dsp1ptr],23 pop ecx pop eax ; ///////////////////////////// ret FastForwardLock db 0 SlowDownLock db 0 FastForwardLockp db 0 SaveRamSaved db 'SAVED SRAM DATA',0 NEWSYM CSprWinPtr, dd 0 NEWSYM cachevideo mov byte[NextLineCache],0 mov dword[objwlrpos],0FFFFFFFFh mov dword[CSprWinPtr],0 mov byte[pressed],0 mov dword[objvramadder],0 mov dword[bgcmsung],0 mov dword[modeused],0 mov dword[modeused+4],0 mov dword[scaddsngb],0 mov dword[scaddtngb],0 mov dword[sprprdrn],0 mov dword[ngmsdraw],0 mov dword[ngextbg],0 mov dword[scaddtngbx],0FFFFFFFFh mov byte[hiresstuff],0 mov byte[Mode7HiRes],0 cmp dword[WindowDisables],0 je .nowindis dec dword[WindowDisables] .nowindis cmp byte[CurRecv],1 je near .fskipall call ClockCounter cmp byte[mode7hiresen],0 je .nohires cmp byte[scanlines],1 je .nohires cmp byte[cvidmode],9 je .yeshires cmp byte[cvidmode],15 jne .nohires .yeshires mov byte[Mode7HiRes],1 .nohires mov dword[scfbl],1 mov al,[vidbright] mov [maxbr],al mov byte[cgmod],1 xor al,al mov [curblank],al cmp byte[debuggeron],0 je .nodebugger mov byte[curblank],40h mov al,40h jmp .nofrskip .nodebugger cmp dword[sramb4save],0 je .nofocussave cmp byte[SRAMSave5Sec],0 je .nofocussaveb dec dword[sramb4save] cmp dword[sramb4save],0 jne .nofocussave pushad call SaveSramData popad ; mov dword[Msgptr],SaveRamSaved ; mov eax,[MsgCount] ; mov [MessageOn],eax jmp .nofocussave .nofocussaveb mov dword[sramb4save],0 .nofocussave cmp byte[CNetType],20 je near .sdskip cmp byte[FastFwdToggle],0 jne .ffmode2 mov eax,[KeyFastFrwrd] test byte[pressed+eax],1 jnz near .fastfor jmp .ffskip .ffmode2 mov eax,[KeyFastFrwrd] test byte[pressed+eax],1 je .nofastfor mov byte[pressed+eax],2 xor byte[FastForwardLock],1 jmp .ff .nofastfor .ff cmp byte[FastForwardLock],1 je near .fastfor .ffskip cmp byte[FastFwdToggle],0 jne .sdmode2 mov eax,[KeySlowDown] test byte[pressed+eax],1 jnz near .slowdwn jmp .sdskip .sdmode2 mov eax,[KeySlowDown] test byte[pressed+eax],1 je .noslowdwn mov byte[pressed+eax],2 xor byte[SlowDownLock],1 .noslowdwn cmp byte[SlowDownLock],1 je near .slowdwn jmp .sdskip .slowdwn mov ax,2 jmp .skipnoslowdown .sdskip mov ax,1 .skipnoslowdown cmp byte[frameskip],0 jne near .frameskip cmp word[t1cc],ax jae .skipt1ccc .noskip push eax call Check60hz pop eax cmp word[t1cc],ax jb .noskip .skipt1ccc sub word[t1cc],ax cmp word[t1cc],ax jb .noskip2 mov byte[curblank],40h inc byte[fskipped] mov al,40h mov cl,[maxskip] cmp byte[fskipped],cl jbe near .nofrskip mov word[t1cc],0 mov byte[curblank],0 mov byte[fskipped],0 jmp .nofrskip .noskip2 mov byte[fskipped],0 jmp .nofrskip .fastfor inc byte[frskipper] push ebx mov bl,10 jmp .fastforb .frameskip inc byte[frskipper] push ebx mov bl,byte[frameskip] .fastforb cmp byte[frskipper],bl pop ebx jae .nofrskip .fskipall mov byte[curblank],40h mov al,40h jmp .frskip .nofrskip mov byte[frskipper],0 .frskip push ebx push esi push edi push edx inc byte[mousecheck] and byte[mousecheck],07h cmp byte[mousecheck],0 jne .noclick cmp byte[GUIClick],0 je .noclick cmp byte[snesmouse],0 jne .noclick call Get_MouseData test bx,02h jz .norclick cmp byte[MousePRClick],0 jne .noclick mov byte[pressed+1],1 .norclick mov byte[MousePRClick],0 .noclick mov ax,[oamaddr] mov cl,[bgmode] mov al,01h shl al,cl mov [cachedmode],al ; disable all necessary backgrounds cmp byte[chaton],1 je near .finishchatskip mov eax,[KeyBGDisble0] test byte[pressed+eax],1 je .nodis1 xor byte[scrndis],01h mov byte[pressed+eax],2 mov dword[Msgptr],bg1layena test byte[scrndis],01h jz .en1 mov dword[Msgptr],bg1laydis .en1 mov eax,[MsgCount] mov [MessageOn],eax .nodis1 mov eax,[KeyBGDisble1] test byte[pressed+eax],1 je .nodis2 xor byte[scrndis],02h mov byte[pressed+eax],2 mov dword[Msgptr],bg2layena test byte[scrndis],02h jz .en2 mov dword[Msgptr],bg2laydis .en2 mov eax,[MsgCount] mov [MessageOn],eax .nodis2 mov eax,[KeyBGDisble2] test byte[pressed+eax],1 je .nodis3 xor byte[scrndis],04h mov byte[pressed+eax],2 mov dword[Msgptr],bg3layena test byte[scrndis],04h jz .en3 mov dword[Msgptr],bg3laydis .en3 mov eax,[MsgCount] mov [MessageOn],eax .nodis3 mov eax,[KeyBGDisble3] test byte[pressed+eax],1 je .nodis4 xor byte[scrndis],08h mov byte[pressed+eax],2 mov dword[Msgptr],bg4layena test byte[scrndis],08h jz .en4 mov dword[Msgptr],bg4laydis .en4 mov eax,[MsgCount] mov [MessageOn],eax .nodis4 mov eax,[KeySprDisble] test byte[pressed+eax],1 je .nodis5 xor byte[scrndis],10h mov byte[pressed+eax],2 mov dword[Msgptr],sprlayena test byte[scrndis],10h jz .en5 mov dword[Msgptr],sprlaydis .en5 mov eax,[MsgCount] mov [MessageOn],eax .nodis5 mov eax,[KeyResetAll] test byte[pressed+eax],1 je .nodis6 mov byte[pressed+eax],2 mov byte[Voice0Disable],01h mov byte[Voice1Disable],01h mov byte[Voice2Disable],01h mov byte[Voice3Disable],01h mov byte[Voice4Disable],01h mov byte[Voice5Disable],01h mov byte[Voice6Disable],01h mov byte[Voice7Disable],01h mov byte[scrndis],00h mov byte[snesmouse],0 mov dword[Msgptr],panickeyp mov eax,[MsgCount] mov [MessageOn],eax .nodis6 mov eax,[KeyExtraEnab] test byte[pressed+eax],1 je near .nodis7 mov byte[pressed+eax],2 inc byte[snesmouse] cmp byte[snesmouse],5 jne .mousewrap mov byte[snesmouse],0 .mousewrap mov dword[Msgptr],snesle cmp byte[snesmouse],0 jne .nom0 mov dword[Msgptr],snesmousep0 .nom0 cmp byte[snesmouse],1 jne .nom1 mov dword[Msgptr],snesmousep1 .nom1 cmp byte[snesmouse],2 jne .nom2 mov dword[Msgptr],snesmousep2 .nom2 cmp byte[snesmouse],3 jne .nom3 mov dword[Msgptr],snesss mov word[mousexloc],128 mov word[mouseyloc],112 .nom3 mov eax,[MsgCount] mov [MessageOn],eax call Get_MousePositionDisplacement .nodis7 cmp byte[CNetType],20 jne .nonet cmp byte[snesmouse],0 je .nonet mov byte[snesmouse],0 mov dword[MessageOn],0 .nonet mov eax,[KeyNewGfxSwt] test byte[pressed+eax],1 je near .nodis8 mov byte[pressed+eax],2 cmp byte[cbitmode],1 jne .no16bng cmp byte[newgfx16b],1 je .no16bng jmp .no16bng mov dword[Msgptr],newgfxerror .msgstuff mov eax,[MsgCount] mov [MessageOn],eax cmp byte[newengen],0 je near .nodis8 mov byte[newengen],0 jmp .disng .nores mov dword[Msgptr],newgfxerror2 jmp .msgstuff .no16bng mov byte[prevbright],16 xor byte[newengen],1 mov dword[Msgptr],ngena cmp byte[newengen],1 je .disng mov dword[Msgptr],ngdis .disng mov eax,[MsgCount] mov [MessageOn],eax mov dword[nextdrawallng],1 mov edi,vidmemch2 mov ecx,1024*3 mov eax,01010101h rep stosd mov edi,pal16b mov ecx,256 xor eax,eax rep stosd mov edi,prevpal mov ecx,128 rep stosd mov eax,0FFFFh cmp byte[newengen],1 jne .noneweng mov eax,0FFFFFFFFh .noneweng mov edi,pal16bxcl mov ecx,256 rep stosd pushad call genfulladdtab popad .yesng .disng2 .nodis8 mov eax,[KeyWinDisble] test byte[pressed+eax],1 je .nodis9 mov byte[pressed+eax],2 xor byte[disableeffects],1 mov dword[Msgptr],windissw cmp byte[disableeffects],1 je .disablew mov dword[Msgptr],winenasw .disablew mov eax,[MsgCount] mov [MessageOn],eax .nodis9 mov eax,[KeyOffsetMSw] test byte[pressed+eax],1 je .nodis10 mov byte[pressed+eax],2 xor byte[osm2dis],1 mov dword[Msgptr],ofsdissw cmp byte[osm2dis],1 je .disableom mov dword[Msgptr],ofsenasw .disableom mov eax,[MsgCount] mov [MessageOn],eax .nodis10 mov eax,[KeyVolUp] test byte[pressed+eax],1 je .novolup cmp byte[MusicRelVol],100 jae .novolup inc byte[MusicRelVol] call UpdateVolume .novolup mov eax,[KeyVolDown] test byte[pressed+eax],1 je .novoldown cmp byte[MusicRelVol],0 je .novoldown dec byte[MusicRelVol] call UpdateVolume .novoldown mov eax,[KeyFRateUp] test byte[pressed+eax],1 je .nofrup mov byte[pressed+eax],2 cmp byte[frameskip],10 je .nofrup mov byte[FPSOn],0 inc byte[frameskip] mov al,[frameskip] add al,47 mov [frlev+18],al mov dword[Msgptr],frlev mov eax,[MsgCount] mov [MessageOn],eax .nofrup mov eax,[KeyFRateDown] test byte[pressed+eax],1 je .nofrdown mov byte[pressed+eax],2 cmp byte[frameskip],0 je .nofrdown dec byte[frameskip] cmp byte[frameskip],0 je .min mov al,[frameskip] add al,47 mov [frlev+18],al mov dword[Msgptr],frlev jmp .nomin .min mov dword[Msgptr],frlv0 mov word[t1cc],0 .nomin mov eax,[MsgCount] mov [MessageOn],eax .nofrdown mov eax,[KeyDisplayFPS] test byte[pressed+eax],1 je .nodisplayfps mov byte[pressed+eax],2 cmp byte[frameskip],0 jne .nodisplayfps xor byte[FPSOn],1 .nodisplayfps ; do state selects stateselcomp KeyStateSlc0,'0','t' stateselcomp KeyStateSlc1,'1','1' stateselcomp KeyStateSlc2,'2','2' stateselcomp KeyStateSlc3,'3','3' stateselcomp KeyStateSlc4,'4','4' stateselcomp KeyStateSlc5,'5','5' stateselcomp KeyStateSlc6,'6','6' stateselcomp KeyStateSlc7,'7','7' stateselcomp KeyStateSlc8,'8','8' stateselcomp KeyStateSlc9,'9','9' mov eax,[KeyStateSlc0] test byte[pressed+eax],1 je .nostsl0 mov byte[pressed+eax],2 mov byte[sselm+11],'0' mov dword[Msgptr],sselm mov eax,[MsgCount] mov [MessageOn],eax .nostsl0 mov eax,[KeyIncStateSlot] test byte[pressed+eax],1 je .noincstateslot mov byte[pressed+eax],2 mov eax,[statefileloc] mov dh,[fnamest+eax] cmp dh,'t' je .secondstate cmp dh,'9' je .jumptofirststate inc dh jmp .donextstate .secondstate mov dh,'1' jmp .donextstate .jumptofirststate mov dh,'t' .donextstate mov byte[fnamest+eax],dh cmp dh,'t' je .firststatemsg mov byte[sselm+11],dh jmp .incstatemsg .firststatemsg mov byte[sselm+11],'0' .incstatemsg mov dword[Msgptr],sselm mov eax,[MsgCount] mov [MessageOn],eax xor dh,dh .noincstateslot mov eax,[KeyDecStateSlot] test byte[pressed+eax],1 je .nodecstateslot mov byte[pressed+eax],2 mov eax,[statefileloc] mov dh,[fnamest+eax] cmp dh,'t' je .jumptolaststate dec dh cmp dh,'0' jne .doprevstate .firststate mov dh,'t' jmp .doprevstate .jumptolaststate mov dh,'9' .doprevstate mov byte[fnamest+eax],dh cmp dh,'t' je .firststatemsg2 mov byte[sselm+11],dh jmp .decstatemsg .firststatemsg2 mov byte[sselm+11],'0' .decstatemsg mov dword[Msgptr],sselm mov eax,[MsgCount] mov [MessageOn],eax xor dh,dh .nodecstateslot ; do sound disables soundselcomp KeyDisableSC0,Voice0Disable,Voice0Status,'1' soundselcomp KeyDisableSC1,Voice1Disable,Voice1Status,'2' soundselcomp KeyDisableSC2,Voice2Disable,Voice2Status,'3' soundselcomp KeyDisableSC3,Voice3Disable,Voice3Status,'4' soundselcomp KeyDisableSC4,Voice4Disable,Voice4Status,'5' soundselcomp KeyDisableSC5,Voice5Disable,Voice5Status,'6' soundselcomp KeyDisableSC6,Voice6Disable,Voice6Status,'7' soundselcomp KeyDisableSC7,Voice7Disable,Voice7Status,'8' .finishchatskip cmp byte[curblank],0h jne near yesblank ; Swap video addresses ; mov ebx,[vidbuffer] ; cmp ebx,[vidbufferofsa] ; je .useb mov ebx,[vidbufferofsa] mov [vidbuffer],ebx add ebx,75036+16 mov [cbackofsaddr],ebx mov ebx,[vidbufferofsb] mov [vidbufferm],ebx ; jmp .nouseb ;.useb ; mov ebx,[vidbufferofsb] ; mov [vidbuffer],ebx ; add ebx,75036+16 ; mov [cbackofsaddr],ebx ; mov ebx,[vidbufferofsa] ; mov [vidbufferm],ebx ;.nouseb NEWSYM docache xor ebx,ebx mov bl,[bgmode] shl bl,2 add ebx,colormodedef mov [colormodeofs],ebx xor ebx,ebx mov bl,[bgmode] mov al,[colormodedef+ebx*4] mov [curcolbg1],al mov ah,[colormodedef+ebx*4+1] mov [curcolbg2],ah mov al,[colormodedef+ebx*4] mov [curcolbg3],al mov ah,[colormodedef+ebx*4+1] mov [curcolbg4],ah mov ax,[bg1ptr] mov [curbgofs1],ax mov ax,[bg2ptr] mov [curbgofs2],ax mov ax,[bg3ptr] mov [curbgofs3],ax mov ax,[bg4ptr] mov [curbgofs4],ax push es mov ax,ds mov es,ax ; clear # of sprites & bg cache mov edi,cachebg1 mov ecx,64*5+16*4 xor eax,eax rep stosd ; cmp byte[sprprifix],0 ; je .nosprfix ; mov edi,sprlefttotb ; mov ecx,64*3 ; xor eax,eax ; rep stosd ;.nosprfix ; do sprites ; test word[scrnon],1010h ; jz .nosprites test byte[scrndis],10h jnz .nosprites call cachesprites call processsprites ; mov byte[sprprncache],0 ; cmp byte[sprprifix],0 ; je .nosprites ; call processspritesb .nosprites ; fill background with 0's unless 16-bit/new graphics engine mode is on jmp .skipbgclear cmp byte[cbitmode],1 je .skipbgclear cmp byte[newengen],1 jne .skipbgclear mov edi,[vidbuffer] xor eax,eax add edi,16 mov dl,[resolutn] .loopa mov ecx,64 rep stosd add edi,32 dec dl jnz .loopa .skipbgclear xor ecx,ecx pop es NEWSYM yesblank pop edx pop edi pop esi pop ebx ret .Zero dd 0,0 .Zero2 dd 0,0 NEWSYM osm2dis, db 0 NEWSYM cachedmode, db 0 NEWSYM tempfname, db 'vram.bin',0 NEWSYM scrnsizebyte, dw 1024,2048,2048,4096 NEWSYM colormodedef, db 1,1,1,1, 2,2,1,0, 2,2,0,0, 3,2,0,0, db 3,1,0,0, 2,1,0,0, 2,0,0,0, 0,0,0,0 NEWSYM colormoded2, db 4,4,4,4, 5,5,4,0, 5,5,0,0, 6,5,0,0, db 6,4,0,0, 5,4,0,0, 5,0,0,0, 0,0,0,0 NEWSYM colormodeofs, dd 0 NEWSYM curblank, db 80h ; current blank state (40h = skip fill) NEWSYM addr2add, dd 0 ;cachebg1 times 64 db 0 ;cachebg2 times 64 db 0 ;cachebg3 times 64 db 0 ;cachebg4 times 64 db 0 ;sprlefttot times 256 db 0 ; total sprites left ;sprleftpr times 256 db 0 ; sprites left for priority 0 ;sprleftpr1 times 256 db 0 ; sprites left for priority 1 ;sprleftpr2 times 256 db 0 ; sprites left for priority 2 ;sprleftpr3 times 256 db 0 ; sprites left for priority 3 ;spritetable times 256*512 db 0 ; sprite table (flip/pal/xloc/vbufptr)38*7 NEWSYM curbgofs1, dw 0 NEWSYM curbgofs2, dw 0 NEWSYM curbgofs3, dw 0 NEWSYM curbgofs4, dw 0 NEWSYM curcolbg1, db 0 NEWSYM curcolbg2, db 0 NEWSYM curcolbg3, db 0 NEWSYM curcolbg4, db 0 NEWSYM panickeyp, db 'ALL SWITCHES NORMAL',0 NEWSYM snesmousep0, db 'MOUSE/SUPER SCOPE DISABLED',0 NEWSYM snesmousep1, db 'MOUSE ENABLED IN PORT 1',0 NEWSYM snesmousep2, db 'MOUSE ENABLED IN PORT 2',0 NEWSYM snesss, db 'SUPER SCOPE ENABLED',0 NEWSYM snesle, db 'LETHAL ENFORCER GUN ENABLED',0 NEWSYM windissw, db 'WINDOWING DISABLED',0 NEWSYM winenasw, db 'WINDOWING ENABLED',0 NEWSYM ofsdissw, db 'OFFSET MODE DISABLED',0 NEWSYM ofsenasw, db 'OFFSET MODE ENABLED',0 NEWSYM ngena, db 'NEW GFX ENGINE ENABLED',0 NEWSYM ngdis, db 'NEW GFX ENGINE DISABLED',0 NEWSYM sselm, db 'STATE SLOT 0 SELECTED',0 NEWSYM vollv, db 'VOLUME LEVEL : ',0 NEWSYM frlev, db 'FRAME SKIP SET TO ',0 NEWSYM frlv0, db 'AUTO FRAMERATE ENABLED',0 sndchena db 'SOUND CH ENABLED',0 sndchdis db 'SOUND CH DISABLED',0 bg1layena db 'BG1 LAYER ENABLED',0 bg2layena db 'BG2 LAYER ENABLED',0 bg3layena db 'BG3 LAYER ENABLED',0 bg4layena db 'BG4 LAYER ENABLED',0 sprlayena db 'SPRITE LAYER ENABLED',0 bg1laydis db 'BG1 LAYER DISABLED',0 bg2laydis db 'BG2 LAYER DISABLED',0 bg3laydis db 'BG3 LAYER DISABLED',0 bg4laydis db 'BG4 LAYER DISABLED',0 sprlaydis db 'SPRITE LAYER DISABLED',0 ;******************************************************* ; Process Sprites ;******************************************************* ; Use oamram for object table NEWSYM processsprites ; cmp byte[cbitmode],1 ; je .skipnewspr ; cmp byte[newengen],1 ; je .skipnewspr cmp byte[sprprifix],0 jne near processspritesb .skipnewspr ; set obj pointers cmp byte[objsize1],1 jne .16dot1 mov ebx,.process8x8sprite mov [.size1ptr],ebx jmp .fin1 .16dot1 cmp byte[objsize1],4 jne .32dot1 mov ebx,.process16x16sprite mov [.size1ptr],ebx jmp .fin1 .32dot1 cmp byte[objsize1],16 jne .64dot1 mov ebx,.process32x32sprite mov [.size1ptr],ebx jmp .fin1 .64dot1 mov ebx,.process64x64sprite mov [.size1ptr],ebx .fin1 cmp byte[objsize2],1 jne .16dot2 mov ebx,.process8x8sprite mov [.size2ptr],ebx jmp .fin2 .16dot2 cmp byte[objsize2],4 jne .32dot2 mov ebx,.process16x16sprite mov [.size2ptr],ebx jmp .fin2 .32dot2 cmp byte[objsize2],16 jne .64dot2 mov ebx,.process32x32sprite mov [.size2ptr],ebx jmp .fin2 .64dot2 mov ebx,.process64x64sprite mov [.size2ptr],ebx .fin2 ; set pointer adder xor eax,eax xor ebx,ebx mov al,[objhipr] shl ax,2 mov ebx,eax sub bx,4 and bx,01FCh mov dword[addr2add],0 mov byte[.prileft],4 mov byte[.curpri],0 ; do 1st priority mov ecx,[objptr] shl ecx,1 mov [.objvramloc],ecx mov ecx,[objptrn] sub ecx,[objptr] shl ecx,1 mov [.objvramloc2],ecx push ebp mov ebp,[spritetablea] .startobject mov byte[.objleft],128 .objloop xor ecx,ecx mov cx,[oamram+ebx+2] mov dl,ch shr dl,4 and dl,03h cmp dl,[.curpri] jne near .nextobj ; get object information push ebx mov dl,[oamram+ebx+1] ; y inc dl ; set up pointer to esi mov dh,ch and ch,01h shr dh,1 shl ecx,6 add ecx,[.objvramloc] test byte[oamram+ebx+3],01h jz .noloc2 add ecx,[.objvramloc2] .noloc2 and ecx,01FFFFh add ecx,[vcache4b] mov esi,ecx ; get x mov al,[oamram+ebx] ; x ; get double bits mov cl,bl shr ebx,4 ; /16 shr cl,1 and cl,06h mov ah,[oamram+ebx+512] shr ah,cl and ah,03h mov ch,ah and ch,01h mov cl,al ; process object ; esi = pointer to 8-bit object, dh = stats (1 shifted to right) ; cx = x position, dl = y position cmp cx,384 jb .noadder add cx,65535-511 .noadder cmp cx,256 jge .returnfromptr cmp cx,-64 jle .returnfromptr test ah,02h jz .size1 jmp dword near [.size2ptr] .size1 jmp dword near [.size1ptr] .returnfromptr pop ebx ; next object .nextobj sub bx,4 and bx,01FCh dec byte[.objleft] jnz near .objloop add dword[addr2add],256 inc byte[.curpri] dec byte[.prileft] jnz near .startobject pop ebp ret .objvramloc dd 0 .objvramloc2 dd 0 .curpri dd 0 .trypri dd 0 .objleft dd 0 .prileft dd 0 .size1ptr dd 0 .size2ptr dd 0 .reprocesssprite cmp cx,-8 jle .next cmp cx,256 jge .next add cx,8 .reprocessspriteb cmp dl,[resolutn] jae .overflow xor ebx,ebx mov bl,dl xor eax,eax cmp bx,[curypos] jb .overflow mov al,byte[sprlefttot+ebx] cmp al,37 ja near .overflow inc byte[sprlefttot+ebx] add ebx,[addr2add] inc byte[sprleftpr+ebx] sub ebx,[addr2add] shl ebx,9 shl eax,3 add ebx,eax mov [ebp+ebx],cx mov [ebp+ebx+2],esi mov al,[.statusbit] mov byte[ebp+ebx+6],dh mov byte[ebp+ebx+7],al .overflow inc dl add esi,8 dec byte[.numleft2do] jnz .reprocessspriteb sub cx,8 ret .next add dl,8 add esi,64 ret .reprocessspriteflipy cmp cx,-8 jle .nextb cmp cx,256 jge .nextb add cx,8 .reprocessspriteflipyb cmp dl,[resolutn] jae .overflow2 xor ebx,ebx xor eax,eax mov bl,dl cmp bx,[curypos] jb .overflow2 mov al,byte[sprlefttot+ebx] cmp al,37 ja near .overflow2 inc byte[sprlefttot+ebx] add ebx,[addr2add] inc byte[sprleftpr+ebx] sub ebx,[addr2add] shl ebx,9 shl eax,3 add ebx,eax mov [ebp+ebx],cx mov [ebp+ebx+2],esi mov al,[.statusbit] mov byte[ebp+ebx+6],dh mov byte[ebp+ebx+7],al .overflow2 inc dl sub esi,8 dec byte[.numleft2do] jnz .reprocessspriteflipyb sub cx,8 ret .nextb add dl,8 sub esi,64 ret .statusbit db 0 .process8x8sprite: test dh,40h jnz .8x8flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite jmp .returnfromptr .8x8flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add esi,56 call .reprocessspriteflipy jmp .returnfromptr .numleft2do db 0 .process16x16sprite: mov [.statusbit],dh test dh,20h jnz near .16x16flipx test dh,40h jnz .16x16flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite sub cx,8 add esi,64*14 mov byte[.numleft2do],8 call .reprocesssprite sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite jmp .returnfromptr .16x16flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,8 add esi,56 call .reprocessspriteflipy add esi,128 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,16 sub cx,8 add esi,64*14 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy jmp .returnfromptr .16x16flipx test dh,40h jnz .16x16flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,8 call .reprocesssprite sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocesssprite add esi,64*14 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocesssprite jmp .returnfromptr .16x16flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,8 add dl,8 add esi,56 call .reprocessspriteflipy add esi,128 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 add esi,64*14 sub dl,16 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy jmp .returnfromptr ;******************************************************* ; Sprite increment/draw macros ;******************************************************* %macro nextsprite2right 0 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite %endmacro %macro nextsprite2rightflipy 0 add esi,128 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy %endmacro %macro nextsprite2rightflipx 0 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocesssprite %endmacro %macro nextsprite2rightflipyx 0 add esi,128 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy %endmacro ;******************************************************* ; 32x32 sprites routines ;******************************************************* %macro nextline32x32 0 sub cx,24 add esi,64*12 mov byte[.numleft2do],8 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right %endmacro .process32x32sprite: mov [.statusbit],dh test dh,20h jnz near .32x32flipx test dh,40h jnz near .32x32flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right nextline32x32 nextline32x32 nextline32x32 jmp .returnfromptr %macro nextline32x32flipy 0 sub cx,24 add esi,64*12+128 sub dl,16 mov byte[.numleft2do],8 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy %endmacro .32x32flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,24 add esi,56 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextline32x32flipy nextline32x32flipy nextline32x32flipy jmp .returnfromptr %macro nextline32x32flipx 0 add cx,24 add esi,64*12 mov byte[.numleft2do],8 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx %endmacro .32x32flipx test dh,40h jnz near .32x32flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,24 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextline32x32flipx nextline32x32flipx nextline32x32flipx jmp .returnfromptr %macro nextline32x32flipyx 0 add cx,24 add esi,64*12+128 sub dl,16 mov byte[.numleft2do],8 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx %endmacro .32x32flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,24 add dl,24 add esi,56 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextline32x32flipyx nextline32x32flipyx nextline32x32flipyx jmp .returnfromptr ;******************************************************* ; 64x64 sprites routines ;******************************************************* %macro nextline64x64 0 sub cx,56 add esi,64*8 mov byte[.numleft2do],8 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right %endmacro .process64x64sprite: mov [.statusbit],dh test dh,20h jnz near .64x64flipx test dh,40h jnz near .64x64flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 jmp .returnfromptr %macro nextline64x64flipy 0 sub cx,56 add esi,64*8+128 sub dl,16 mov byte[.numleft2do],8 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy %endmacro .64x64flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,56 add esi,56 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy jmp .returnfromptr %macro nextline64x64flipx 0 add cx,56 add esi,64*8 mov byte[.numleft2do],8 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx %endmacro .64x64flipx test dh,40h jnz near .64x64flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,56 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx jmp .returnfromptr %macro nextline64x64flipyx 0 add cx,56 add esi,64*8+128 sub dl,16 mov byte[.numleft2do],8 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx %endmacro .64x64flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,56 add dl,56 add esi,56 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx jmp .returnfromptr ;******************************************************* ; Process Sprites B - Process ;******************************************************* ; Use oamram for object table NEWSYM processspritesb ; set obj pointers cmp byte[objsize1],1 jne .16dot1 mov ebx,.process8x8sprite mov [.size1ptr],ebx jmp .fin1 .16dot1 cmp byte[objsize1],4 jne .32dot1 mov ebx,.process16x16sprite mov [.size1ptr],ebx jmp .fin1 .32dot1 cmp byte[objsize1],16 jne .64dot1 mov ebx,.process32x32sprite mov [.size1ptr],ebx jmp .fin1 .64dot1 mov ebx,.process64x64sprite mov [.size1ptr],ebx .fin1 cmp byte[objsize2],1 jne .16dot2 mov ebx,.process8x8sprite mov [.size2ptr],ebx jmp .fin2 .16dot2 cmp byte[objsize2],4 jne .32dot2 mov ebx,.process16x16sprite mov [.size2ptr],ebx jmp .fin2 .32dot2 cmp byte[objsize2],16 jne .64dot2 mov ebx,.process32x32sprite mov [.size2ptr],ebx jmp .fin2 .64dot2 mov ebx,.process64x64sprite mov [.size2ptr],ebx .fin2 ; set pointer adder xor eax,eax xor ebx,ebx mov al,[objhipr] shl ax,2 mov ebx,eax and bx,01FCh mov dword[addr2add],0 ; do 1st priority mov ecx,[objptr] shl ecx,1 mov [.objvramloc],ecx mov ecx,[objptrn] sub ecx,[objptr] shl ecx,1 mov [.objvramloc2],ecx push ebp mov ebp,[spritetablea] .startobject mov byte[.objleft],128 .objloop xor ecx,ecx mov cx,[oamram+ebx+2] mov dl,ch shr dl,4 and edx,03h mov [.cpri],dl ; get object information push ebx mov dl,[oamram+ebx+1] ; y inc dl ; set up pointer to esi mov dh,ch and ch,01h shr dh,1 shl ecx,6 add ecx,[.objvramloc] test byte[oamram+ebx+3],01h jz .noloc2 add ecx,[.objvramloc2] .noloc2 and ecx,01FFFFh add ecx,[vcache4b] mov esi,ecx ; get x mov al,[oamram+ebx] ; x ; get double bits mov cl,bl shr ebx,4 ; /16 shr cl,1 and cl,06h mov ah,[oamram+ebx+512] shr ah,cl and ah,03h mov ch,ah and ch,01h mov cl,al ; process object ; esi = pointer to 8-bit object, dh = stats (1 shifted to right) ; cx = x position, dl = y position cmp cx,384 jb .noadder add cx,65535-511 .noadder cmp cx,256 jge .returnfromptr cmp cx,-64 jle .returnfromptr test ah,02h jz .size1 jmp dword near [.size2ptr] .size1 jmp dword near [.size1ptr] .returnfromptr pop ebx ; next object .nextobj add bx,4 and bx,01FCh dec byte[.objleft] jnz near .objloop pop ebp ret .objvramloc dd 0 .objvramloc2 dd 0 .curpri dd 0 .trypri dd 0 .objleft dd 0 .prileft dd 0 .size1ptr dd 0 .size2ptr dd 0 .cpri dd 0 .reprocesssprite cmp cx,-8 jle near .next cmp cx,256 jge .next add cx,8 .reprocessspriteb cmp dl,[resolutn] jae .overflow xor ebx,ebx xor eax,eax mov bl,dl cmp bx,[curypos] jb .overflow mov al,byte[sprlefttot+ebx] cmp al,37 ja near .overflow inc byte[sprlefttot+ebx] mov edi,[.cpri] mov byte[sprleftpr+ebx*4+edi],1 shl ebx,9 shl eax,3 add ebx,eax mov [ebp+ebx],cx mov [ebp+ebx+2],esi mov al,[.statusbit] and al,0F8h or al,[.cpri] mov byte[ebp+ebx+6],dh mov byte[ebp+ebx+7],al .overflow inc dl add esi,8 dec byte[.numleft2do] jnz .reprocessspriteb sub cx,8 ret .next add dl,8 add esi,64 ret .reprocessspriteflipy cmp cx,-8 jle near .nextb cmp cx,256 jge .nextb add cx,8 .reprocessspriteflipyb cmp dl,[resolutn] jae .overflow2 xor ebx,ebx xor eax,eax mov bl,dl cmp bx,[curypos] jb .overflow mov al,byte[sprlefttot+ebx] cmp al,37 ja near .overflow2 inc byte[sprlefttot+ebx] mov edi,[.cpri] mov byte[sprleftpr+ebx*4+edi],1 shl ebx,9 shl eax,3 add ebx,eax mov [ebp+ebx],cx mov [ebp+ebx+2],esi mov al,[.statusbit] and al,0F8h or al,[.cpri] mov byte[ebp+ebx+6],dh mov byte[ebp+ebx+7],al .overflow2 inc dl sub esi,8 dec byte[.numleft2do] jnz .reprocessspriteflipyb sub cx,8 ret .nextb add dl,8 sub esi,64 ret .statusbit db 0 .process8x8sprite: test dh,40h jnz .8x8flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite jmp .returnfromptr .8x8flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add esi,56 call .reprocessspriteflipy jmp .returnfromptr .numleft2do db 0 .process16x16sprite: mov [.statusbit],dh test dh,20h jnz near .16x16flipx test dh,40h jnz .16x16flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite sub cx,8 add esi,64*14 mov byte[.numleft2do],8 call .reprocesssprite sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite jmp .returnfromptr .16x16flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,8 add esi,56 call .reprocessspriteflipy add esi,128 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,16 sub cx,8 add esi,64*14 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,8 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy jmp .returnfromptr .16x16flipx test dh,40h jnz .16x16flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,8 call .reprocesssprite sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocesssprite add esi,64*14 add cx,8 mov byte[.numleft2do],8 call .reprocesssprite sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocesssprite jmp .returnfromptr .16x16flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,8 add dl,8 add esi,56 call .reprocessspriteflipy add esi,128 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 add esi,64*14 sub dl,16 add cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy add esi,128 sub dl,8 sub cx,8 mov byte[.numleft2do],8 call .reprocessspriteflipy jmp .returnfromptr ;******************************************************* ; 32x32 sprites routines ;******************************************************* .process32x32sprite: mov [.statusbit],dh test dh,20h jnz near .32x32flipx test dh,40h jnz near .32x32flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right nextline32x32 nextline32x32 nextline32x32 jmp .returnfromptr .32x32flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,24 add esi,56 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextline32x32flipy nextline32x32flipy nextline32x32flipy jmp .returnfromptr .32x32flipx test dh,40h jnz near .32x32flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,24 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextline32x32flipx nextline32x32flipx nextline32x32flipx jmp .returnfromptr .32x32flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,24 add dl,24 add esi,56 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextline32x32flipyx nextline32x32flipyx nextline32x32flipyx jmp .returnfromptr ;******************************************************* ; 64x64 sprites routines ;******************************************************* .process64x64sprite: mov [.statusbit],dh test dh,20h jnz near .64x64flipx test dh,40h jnz near .64x64flipy mov [.statusbit],dh and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 call .reprocesssprite nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextsprite2right nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 nextline64x64 jmp .returnfromptr .64x64flipy and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add dl,56 add esi,56 call .reprocessspriteflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextsprite2rightflipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy nextline64x64flipy jmp .returnfromptr .64x64flipx test dh,40h jnz near .64x64flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,56 call .reprocesssprite nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextsprite2rightflipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx nextline64x64flipx jmp .returnfromptr .64x64flipyx and dh,07h mov byte[.numleft2do],8 shl dh,4 add dh,128 add cx,56 add dl,56 add esi,56 call .reprocessspriteflipy nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextsprite2rightflipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx nextline64x64flipyx jmp .returnfromptr ;******************************************************* ; Cache Process Macros, info from Nerlaska! ;******************************************************* %macro processcache2b 1 xor al,al add ch,ch adc al,al add cl,cl adc al,al mov [edi+%1],al %endmacro %macro processcache4b 1 xor al,al add dh,dh adc al,al add dl,dl adc al,al add ch,ch adc al,al add cl,cl adc al,al mov [edi+%1],al %endmacro ;******************************************************* ; Cache Sprites ;******************************************************* ; Use oamram for object table, copy from vram -> vcache4b ; 16x16 sprite, to move = 2, to add = 14, 32x32 = 4,12, 64x64 = 8,8 %macro processcache4bs 1 xor al,al add dh,dh adc al,al add dl,dl adc al,al add ch,ch adc al,al add cl,cl adc al,al mov [edi+%1],al or al,al jz %%zeroed and byte[tiletypec],1 jmp %%nozeroed %%zeroed and byte[tiletypec],2 %%nozeroed %endmacro NEWSYM cachesprites ; initialize obj size cache mov dword[.objptr],oamram add dword[.objptr],512 mov esi,dword[.objptr] mov al,[esi] mov [.curobjtype],al mov byte[.objleftinbyte],4 ; Initialize oamram pointer mov esi,oamram add esi,2 ; process pointers (.objptra = source, .objptrb = dest) .trynextgroup xor ebx,ebx mov bx,[objptr] mov ecx,ebx shr ecx,4 mov [.nbg],cx mov edi,[vram] add edi,ebx mov [.objptra],edi shl ebx,1 add ebx,[vcache4b] mov [.objptrb],ebx xor ebx,ebx mov bx,[objptrn] mov ecx,ebx shr ecx,4 mov [.nbg2],cx mov edi,[vram] add edi,ebx mov [.objptra2],edi shl ebx,1 add ebx,[vcache4b] mov [.objptrb2],ebx xor ebx,ebx ; process objects mov dword[.sprnum],3 mov byte[.objleft],128 .nextobj ; process sprite sizes test byte[.curobjtype],02h jz .dosprsize1 mov al,[objsize2] mov [.num2do],al mov ax,[objadds2] mov [.byte2add],ax mov al,[objmovs2] mov [.byte2move],al mov [.byteb4add],al jmp .exitsprsize .dosprsize1 mov al,[objsize1] mov [.num2do],al mov ax,[objadds1] mov [.byte2add],ax mov al,[objmovs1] mov [.byte2move],al mov [.byteb4add],al .exitsprsize shr byte[.curobjtype],2 dec byte[.objleftinbyte] jnz .skipobjproc mov byte[.objleftinbyte],4 inc dword[.objptr] mov ebx,[.objptr] mov al,[ebx] mov [.curobjtype],al .skipobjproc mov bx,[esi] and bh,1h mov [.curobj],bx .nextobject mov ebx,[.sprnum] mov cl,[oamram+ebx-2] mov ch,[curypos] dec ch cmp cl,ch jb near .nocache test byte[oamram+ebx],01h jnz .namebase xor ebx,ebx mov bx,[.curobj] mov cx,bx add bx,bx add bx,[.nbg] and bx,4095 test word[vidmemch4+ebx],0101h jz near .nocache mov word[vidmemch4+ebx],0000h mov [.sprfillpl],ebx push esi shl bx,4 mov esi,[vram] add esi,ebx add ebx,ebx mov edi,[vcache4b] add edi,ebx jmp .nonamebase .namebase xor ebx,ebx mov bx,[.curobj] mov cx,bx shl bx,1 add bx,[.nbg2] and bx,4095 test word[vidmemch4+ebx],0101h jz near .nocache mov word[vidmemch4+ebx],0000h mov [.sprfillpl],ebx push esi shl bx,4 mov esi,[vram] add esi,ebx add ebx,ebx mov edi,[vcache4b] add edi,ebx .nonamebase ; convert from [esi] to [edi] mov byte[.rowleft],8 mov byte[tiletypec],3 .donext mov cx,[esi] mov dx,[esi+16] processcache4bs 0 processcache4bs 1 processcache4bs 2 processcache4bs 3 processcache4bs 4 processcache4bs 5 processcache4bs 6 processcache4bs 7 add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext mov ebx,[.sprfillpl] mov al,[tiletypec] shr ebx,1 pop esi mov byte[tltype4b+ebx],al .nocache inc word[.curobj] dec byte[.byteb4add] jnz .skipbyteadd mov ax,[.byte2add] add word[.curobj],ax mov al,[.byte2move] mov byte[.byteb4add],al .skipbyteadd dec byte[.num2do] jnz near .nextobject add esi,4 add dword[.sprnum],4 dec byte[.objleft] jnz near .nextobj ret .objptra dd 0 .objptrb dd 0 .nbg dd 0 .objptra2 dd 0 .objptrb2 dd 0 .nbg2 dd 0 .objleft db 0 .rowleft db 0 .a dd 0 .objptr dd 0 .objleftinbyte dd 0 .curobjtype dd 0 .num2do dd 1 .curobj dd 0 .byteb4add dd 2 .byte2move dd 0 .byte2add dd 0 .sprnum dd 0 .sprcheck dd 0 .sprfillpl dd 0 ;******************************************************* ; Cache 2-Bit ;******************************************************* NEWSYM cachetile2b ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,4 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] and esi,4095 test byte[vidmemch2+esi],01h jz near .nocache mov byte[vidmemch2+esi],00h mov edi,esi shl esi,4 shl edi,6 add esi,[vram] add edi,[vcache2b] push eax mov byte[.rowleft],8 .donext mov cx,[esi] processcache2b 0 processcache2b 1 processcache2b 2 processcache2b 3 processcache2b 4 processcache2b 5 processcache2b 6 processcache2b 7 add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax .nocache add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .a db 0 .rowleft db 0 .nextar db 0 NEWSYM cache2bit ret ;******************************************************* ; Cache 4-Bit ;******************************************************* ; esi = pointer to tile location vram ; edi = pointer to graphics data (cache & non-cache) ; ebx = external pointer ; tile value : bit 15 = flipy, bit 14 = flipx, bit 10-12 = palette, 0-9=tile# NEWSYM cachetile4b ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,5 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] shl esi,1 and esi,4095 test word[vidmemch4+esi],0101h jz near .nocache mov word[vidmemch4+esi],0000h mov edi,esi shl esi,4 shl edi,5 add esi,[vram] add edi,[vcache4b] push eax mov byte[.rowleft],8 .donext mov cx,[esi] mov dx,[esi+16] processcache4b 0 processcache4b 1 processcache4b 2 processcache4b 3 processcache4b 4 processcache4b 5 processcache4b 6 processcache4b 7 add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax .nocache add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .rowleft db 0 .nextar db 0 NEWSYM cache4bit ret ;******************************************************* ; Cache 8-Bit ;******************************************************* ; tile value : bit 15 = flipy, bit 14 = flipx, bit 10-12 = palette, 0-9=tile# NEWSYM cachetile8b ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,6 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] shl esi,2 and esi,4095 test dword[vidmemch8+esi],01010101h jz near .nocache mov dword[vidmemch8+esi],00000000h mov edi,esi shl esi,4 shl edi,4 add esi,[vram] add edi,[vcache8b] push eax mov byte[.rowleft],8 .donext xor ah,ah xor ebx,ebx xor ecx,ecx xor edx,edx mov byte[.a],0 mov al,[esi] ; bitplane 0 cmp al,0 je .skipconva test al,01h jz .skipa0 or ah,01h .skipa0 test al,02h jz .skipa1 or bl,01h .skipa1 test al,04h jz .skipa2 or bh,01h .skipa2 test al,08h jz .skipa3 or cl,01h .skipa3 test al,10h jz .skipa4 or ch,01h .skipa4 test al,20h jz .skipa5 or dl,01h .skipa5 test al,40h jz .skipa6 or dh,01h .skipa6 test al,80h jz .skipa7 or byte[.a],01h .skipa7 .skipconva mov al,[esi+1] ; bitplane 1 cmp al,0 je .skipconvb test al,01h jz .skipb0 or ah,02h .skipb0 test al,02h jz .skipb1 or bl,02h .skipb1 test al,04h jz .skipb2 or bh,02h .skipb2 test al,08h jz .skipb3 or cl,02h .skipb3 test al,10h jz .skipb4 or ch,02h .skipb4 test al,20h jz .skipb5 or dl,02h .skipb5 test al,40h jz .skipb6 or dh,02h .skipb6 test al,80h jz .skipb7 or byte[.a],02h .skipb7 .skipconvb mov al,[esi+16] ; bitplane 2 cmp al,0 je .skipconvc test al,01h jz .skipc0 or ah,04h .skipc0 test al,02h jz .skipc1 or bl,04h .skipc1 test al,04h jz .skipc2 or bh,04h .skipc2 test al,08h jz .skipc3 or cl,04h .skipc3 test al,10h jz .skipc4 or ch,04h .skipc4 test al,20h jz .skipc5 or dl,04h .skipc5 test al,40h jz .skipc6 or dh,04h .skipc6 test al,80h jz .skipc7 or byte[.a],04h .skipc7 .skipconvc mov al,[esi+17] ; bitplane 3 cmp al,0 je .skipconvd test al,01h jz .skipd0 or ah,08h .skipd0 test al,02h jz .skipd1 or bl,08h .skipd1 test al,04h jz .skipd2 or bh,08h .skipd2 test al,08h jz .skipd3 or cl,08h .skipd3 test al,10h jz .skipd4 or ch,08h .skipd4 test al,20h jz .skipd5 or dl,08h .skipd5 test al,40h jz .skipd6 or dh,08h .skipd6 test al,80h jz .skipd7 or byte[.a],08h .skipd7 .skipconvd mov al,[esi+32] ; bitplane 4 cmp al,0 je .skipconve test al,01h jz .skipe0 or ah,10h .skipe0 test al,02h jz .skipe1 or bl,10h .skipe1 test al,04h jz .skipe2 or bh,10h .skipe2 test al,08h jz .skipe3 or cl,10h .skipe3 test al,10h jz .skipe4 or ch,10h .skipe4 test al,20h jz .skipe5 or dl,10h .skipe5 test al,40h jz .skipe6 or dh,10h .skipe6 test al,80h jz .skipe7 or byte[.a],10h .skipe7 .skipconve mov al,[esi+33] ; bitplane 5 cmp al,0 je .skipconvf test al,01h jz .skipf0 or ah,20h .skipf0 test al,02h jz .skipf1 or bl,20h .skipf1 test al,04h jz .skipf2 or bh,20h .skipf2 test al,08h jz .skipf3 or cl,20h .skipf3 test al,10h jz .skipf4 or ch,20h .skipf4 test al,20h jz .skipf5 or dl,20h .skipf5 test al,40h jz .skipf6 or dh,20h .skipf6 test al,80h jz .skipf7 or byte[.a],20h .skipf7 .skipconvf mov al,[esi+48] ; bitplane 6 cmp al,0 je .skipconvg test al,01h jz .skipg0 or ah,40h .skipg0 test al,02h jz .skipg1 or bl,40h .skipg1 test al,04h jz .skipg2 or bh,40h .skipg2 test al,08h jz .skipg3 or cl,40h .skipg3 test al,10h jz .skipg4 or ch,40h .skipg4 test al,20h jz .skipg5 or dl,40h .skipg5 test al,40h jz .skipg6 or dh,40h .skipg6 test al,80h jz .skipg7 or byte[.a],40h .skipg7 .skipconvg mov al,[esi+49] ; bitplane 7 cmp al,0 je .skipconvh test al,01h jz .skiph0 or ah,80h .skiph0 test al,02h jz .skiph1 or bl,80h .skiph1 test al,04h jz .skiph2 or bh,80h .skiph2 test al,08h jz .skiph3 or cl,80h .skiph3 test al,10h jz .skiph4 or ch,80h .skiph4 test al,20h jz .skiph5 or dl,80h .skiph5 test al,40h jz .skiph6 or dh,80h .skiph6 test al,80h jz .skiph7 or byte[.a],80h .skiph7 .skipconvh ; move all bytes into [edi] mov [edi+7],ah mov [edi+6],bl mov [edi+5],bh mov [edi+4],cl mov [edi+3],ch mov [edi+2],dl mov [edi+1],dh mov al,[.a] mov [edi],al add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax .nocache add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .a db 0 .rowleft db 0 .nextar db 0 NEWSYM cache8bit ret ;******************************************************* ; Cache 2-Bit 16x16 tiles ;******************************************************* NEWSYM cachetile2b16x16 ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,4 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] mov byte[.tileleft],4 .nextof4 and esi,4095 test byte[vidmemch2+esi],01h jz near .nocache mov byte[vidmemch2+esi],00h push esi mov edi,esi shl esi,4 shl edi,6 add esi,[vram] add edi,[vcache2b] push eax mov byte[.rowleft],8 .donext mov cx,[esi] processcache2b 0 processcache2b 1 processcache2b 2 processcache2b 3 processcache2b 4 processcache2b 5 processcache2b 6 processcache2b 7 add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax pop esi .nocache inc esi cmp byte[.tileleft],3 jne .noadd add esi,14 .noadd dec byte[.tileleft] jnz near .nextof4 add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .a db 0 .rowleft db 0 .nextar db 0 .tileleft db 0 NEWSYM cache2bit16x16 ret ;******************************************************* ; Cache 4-Bit 16x16 tiles ;******************************************************* NEWSYM cachetile4b16x16 ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,5 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] shl esi,1 mov byte[.tileleft],4 .nextof4 and esi,4095 test word[vidmemch4+esi],0101h jz near .nocache mov word[vidmemch4+esi],0000h push esi mov edi,esi shl esi,4 shl edi,5 add esi,[vram] add edi,[vcache4b] push eax mov byte[.rowleft],8 .donext mov cx,[esi] mov dx,[esi+16] processcache4b 0 processcache4b 1 processcache4b 2 processcache4b 3 processcache4b 4 processcache4b 5 processcache4b 6 processcache4b 7 add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax pop esi .nocache add esi,2 cmp byte[.tileleft],3 jne .noadd add esi,28 .noadd dec byte[.tileleft] jnz near .nextof4 add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .rowleft db 0 .nextar db 0 .tileleft db 0 NEWSYM cache4bit16x16 ret ;******************************************************* ; Cache 8-Bit 16x16 tiles ;******************************************************* NEWSYM cachetile8b16x16 ; Keep high word ecx 0 push eax xor ecx,ecx push edx mov byte[.nextar],1 push ebx ; get tile info location test al,20h jnz .highptr shl eax,6 ; x 64 for each line add ax,[bgptr] jmp .loptr .highptr and al,1Fh shl eax,6 ; x 64 for each line add ax,[bgptrc] .loptr add eax,[vram] mov bx,[curtileptr] shr bx,6 mov byte[.count],32 mov [.nbg],bx ; do loop .cacheloop mov si,[eax] and esi,03FFh add si,[.nbg] shl esi,2 mov byte[.tileleft],4 .nextof4 and esi,4095 test dword[vidmemch8+esi],01010101h jz near .nocache mov dword[vidmemch8+esi],00000000h push esi mov edi,esi shl esi,4 shl edi,4 add esi,[vram] add edi,[vcache8b] push eax mov byte[.rowleft],8 .donext xor ah,ah xor ebx,ebx xor ecx,ecx xor edx,edx mov byte[.a],0 mov al,[esi] ; bitplane 0 cmp al,0 je .skipconva test al,01h jz .skipa0 or ah,01h .skipa0 test al,02h jz .skipa1 or bl,01h .skipa1 test al,04h jz .skipa2 or bh,01h .skipa2 test al,08h jz .skipa3 or cl,01h .skipa3 test al,10h jz .skipa4 or ch,01h .skipa4 test al,20h jz .skipa5 or dl,01h .skipa5 test al,40h jz .skipa6 or dh,01h .skipa6 test al,80h jz .skipa7 or byte[.a],01h .skipa7 .skipconva mov al,[esi+1] ; bitplane 1 cmp al,0 je .skipconvb test al,01h jz .skipb0 or ah,02h .skipb0 test al,02h jz .skipb1 or bl,02h .skipb1 test al,04h jz .skipb2 or bh,02h .skipb2 test al,08h jz .skipb3 or cl,02h .skipb3 test al,10h jz .skipb4 or ch,02h .skipb4 test al,20h jz .skipb5 or dl,02h .skipb5 test al,40h jz .skipb6 or dh,02h .skipb6 test al,80h jz .skipb7 or byte[.a],02h .skipb7 .skipconvb mov al,[esi+16] ; bitplane 2 cmp al,0 je .skipconvc test al,01h jz .skipc0 or ah,04h .skipc0 test al,02h jz .skipc1 or bl,04h .skipc1 test al,04h jz .skipc2 or bh,04h .skipc2 test al,08h jz .skipc3 or cl,04h .skipc3 test al,10h jz .skipc4 or ch,04h .skipc4 test al,20h jz .skipc5 or dl,04h .skipc5 test al,40h jz .skipc6 or dh,04h .skipc6 test al,80h jz .skipc7 or byte[.a],04h .skipc7 .skipconvc mov al,[esi+17] ; bitplane 3 cmp al,0 je .skipconvd test al,01h jz .skipd0 or ah,08h .skipd0 test al,02h jz .skipd1 or bl,08h .skipd1 test al,04h jz .skipd2 or bh,08h .skipd2 test al,08h jz .skipd3 or cl,08h .skipd3 test al,10h jz .skipd4 or ch,08h .skipd4 test al,20h jz .skipd5 or dl,08h .skipd5 test al,40h jz .skipd6 or dh,08h .skipd6 test al,80h jz .skipd7 or byte[.a],08h .skipd7 .skipconvd mov al,[esi+32] ; bitplane 4 cmp al,0 je .skipconve test al,01h jz .skipe0 or ah,10h .skipe0 test al,02h jz .skipe1 or bl,10h .skipe1 test al,04h jz .skipe2 or bh,10h .skipe2 test al,08h jz .skipe3 or cl,10h .skipe3 test al,10h jz .skipe4 or ch,10h .skipe4 test al,20h jz .skipe5 or dl,10h .skipe5 test al,40h jz .skipe6 or dh,10h .skipe6 test al,80h jz .skipe7 or byte[.a],10h .skipe7 .skipconve mov al,[esi+33] ; bitplane 5 cmp al,0 je .skipconvf test al,01h jz .skipf0 or ah,20h .skipf0 test al,02h jz .skipf1 or bl,20h .skipf1 test al,04h jz .skipf2 or bh,20h .skipf2 test al,08h jz .skipf3 or cl,20h .skipf3 test al,10h jz .skipf4 or ch,20h .skipf4 test al,20h jz .skipf5 or dl,20h .skipf5 test al,40h jz .skipf6 or dh,20h .skipf6 test al,80h jz .skipf7 or byte[.a],20h .skipf7 .skipconvf mov al,[esi+48] ; bitplane 6 cmp al,0 je .skipconvg test al,01h jz .skipg0 or ah,40h .skipg0 test al,02h jz .skipg1 or bl,40h .skipg1 test al,04h jz .skipg2 or bh,40h .skipg2 test al,08h jz .skipg3 or cl,40h .skipg3 test al,10h jz .skipg4 or ch,40h .skipg4 test al,20h jz .skipg5 or dl,40h .skipg5 test al,40h jz .skipg6 or dh,40h .skipg6 test al,80h jz .skipg7 or byte[.a],40h .skipg7 .skipconvg mov al,[esi+49] ; bitplane 7 cmp al,0 je .skipconvh test al,01h jz .skiph0 or ah,80h .skiph0 test al,02h jz .skiph1 or bl,80h .skiph1 test al,04h jz .skiph2 or bh,80h .skiph2 test al,08h jz .skiph3 or cl,80h .skiph3 test al,10h jz .skiph4 or ch,80h .skiph4 test al,20h jz .skiph5 or dl,80h .skiph5 test al,40h jz .skiph6 or dh,80h .skiph6 test al,80h jz .skiph7 or byte[.a],80h .skiph7 .skipconvh ; move all bytes into [edi] mov [edi+7],ah mov [edi+6],bl mov [edi+5],bh mov [edi+4],cl mov [edi+3],ch mov [edi+2],dl mov [edi+1],dh mov al,[.a] mov [edi],al add edi,8 add esi,2 dec byte[.rowleft] jnz near .donext pop eax pop esi .nocache add esi,4 cmp byte[.tileleft],3 jne .noadd add esi,56 .noadd dec byte[.tileleft] jnz near .nextof4 add eax,2 dec byte[.count] jnz near .cacheloop cmp byte[.nextar],0 je .skipall mov bx,[bgptrc] cmp [bgptrd],bx je .skipall add eax,2048-64 mov byte[.count],32 mov byte[.nextar],0 jmp .cacheloop .skipall pop ebx pop edx pop eax ret .nbg dw 0 .count db 0 .a db 0 .rowleft db 0 .nextar db 0 .tileleft db 0 NEWSYM cache8bit16x16 ret NEWSYM cachesingle cmp byte[offsetmshl],1 je near cachesingle4b cmp byte[offsetmshl],2 je near cachesingle2b ret %macro processcache4b2 1 xor al,al add dh,dh adc al,al add dl,dl adc al,al add ch,ch adc al,al add cl,cl adc al,al mov [edi+%1],al %endmacro NEWSYM cachesingle4b mov word[ebx],0 sub ebx,vidmemch4 push edi mov edi,ebx shl edi,5 ; cached ram shl ebx,4 ; vram add edi,[vcache4b] add ebx,[vram] push eax push edx mov byte[scacheloop],8 .nextline mov cx,[ebx] mov dx,[ebx+16] processcache4b2 0 processcache4b2 1 processcache4b2 2 processcache4b2 3 processcache4b2 4 processcache4b2 5 processcache4b2 6 processcache4b2 7 add ebx,2 add edi,8 dec byte[scacheloop] jnz near .nextline pop edx pop eax pop edi ret NEWSYM cachesingle2b ret NEWSYM scacheloop, db 0 NEWSYM tiletypec, db 0 %macro processcache4b3 1 xor al,al add dh,dh adc al,al add dl,dl adc al,al add bh,bh adc al,al add bl,bl adc al,al mov [edi+%1],al or al,al jz %%zeroed and byte[tiletypec],1 jmp %%nozeroed %%zeroed and byte[tiletypec],2 %%nozeroed %endmacro NEWSYM cachesingle4bng mov word[vidmemch4+ecx*2],0 mov byte[tiletypec],3 push edi push eax push ecx push ebx push edx mov edi,ecx shl edi,6 ; cached ram shl ecx,5 ; vram add edi,[vcache4b] add ecx,[vram] mov byte[scacheloop],8 .nextline mov bx,[ecx] mov dx,[ecx+16] processcache4b3 0 processcache4b3 1 processcache4b3 2 processcache4b3 3 processcache4b3 4 processcache4b3 5 processcache4b3 6 processcache4b3 7 add ecx,2 add edi,8 dec byte[scacheloop] jnz near .nextline pop edx pop ebx pop ecx mov al,[tiletypec] mov [tltype4b+ecx],al pop eax pop edi ret %macro processcache2b3 1 xor al,al add bh,bh adc al,al add bl,bl adc al,al mov [edi+%1],al or al,al jz %%zeroed and byte[tiletypec],1 jmp %%nozeroed %%zeroed and byte[tiletypec],2 %%nozeroed %endmacro NEWSYM cachesingle2bng mov byte[vidmemch2+ecx],0 mov byte[tiletypec],3 push edi push eax push ecx push ebx push edx mov edi,ecx shl edi,6 ; cached ram shl ecx,4 ; vram add edi,[vcache2b] add ecx,[vram] mov byte[scacheloop],8 .nextline mov bx,[ecx] processcache2b3 0 processcache2b3 1 processcache2b3 2 processcache2b3 3 processcache2b3 4 processcache2b3 5 processcache2b3 6 processcache2b3 7 add ecx,2 add edi,8 dec byte[scacheloop] jnz near .nextline pop edx pop ebx pop ecx mov al,[tiletypec] mov [tltype2b+ecx],al pop eax pop edi ret %macro processcache8b3 1 xor esi,esi add ch,ch adc esi,esi add cl,cl adc esi,esi add dh,dh adc esi,esi add dl,dl adc esi,esi add ah,ah adc esi,esi add al,al adc esi,esi add bh,bh adc esi,esi add bl,bl adc esi,esi push eax mov eax,esi mov [edi+%1],al or al,al jz %%zeroed and byte[tiletypec],1 jmp %%nozeroed %%zeroed and byte[tiletypec],2 %%nozeroed pop eax %endmacro NEWSYM cachesingle8bng mov dword[vidmemch8+ecx*4],0 mov byte[tiletypec],3 push esi push edi push eax push ecx push ebx push edx mov edi,ecx shl edi,6 ; cached ram shl ecx,6 ; vram add edi,[vcache8b] add ecx,[vram] mov byte[scacheloop],8 .nextline mov bx,[ecx] mov ax,[ecx+16] mov dx,[ecx+32] push ecx mov cx,[ecx+48] processcache8b3 0 processcache8b3 1 processcache8b3 2 processcache8b3 3 processcache8b3 4 processcache8b3 5 processcache8b3 6 processcache8b3 7 pop ecx add ecx,2 add edi,8 dec byte[scacheloop] jnz near .nextline pop edx pop ebx pop ecx mov al,[tiletypec] mov [tltype8b+ecx],al pop eax pop edi pop esi ret NEWSYM VCacheAsmEnd zsnes-1.36/src/water.c0100644000175000017500000001670107437060427014257 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #ifdef __LINUX__ #include "gblhdr.h" #else #include #include #include #include #include #include #endif #include "fixsin.h" extern char *vidbuffer; #define SCRW 288 #define SCRH 224 static unsigned char vscr[SCRW*SCRH]; static int Height[2][SCRW*SCRH]; extern char NetPlayNoMore; /* static void DrawWaterNoLight(int *ptr); */ static void DrawWaterWithLight(int *ptr,int light); static void SineBlob(int x, int y, int radius, int height, int page); static void CalcWater(int *nptr,int *optr,int density); //static int x,y; static int ox=80,oy=60; static int xang,yang; static int density=5; static int Hpage=0; static int mode=0x0001; static int offset; static int pheight=400; static int radius=30; extern char GUIEffect; void DrawWater(void) { // tslast=tscurrent; // tscurrent=time(NULL); /* if (NetPlayNoMore == 1) { DrawWaterNoLight(Height[Hpage]); } else { DrawWaterWithLight(Height[Hpage],1); } */ #if 0 DrawWaterNoLight(Height[Hpage]); #else DrawWaterWithLight(Height[Hpage],1); #endif if (GUIEffect==2) { mode=0x0001; } else { mode = 0x0004; } if(mode&2) // && (tscurrent-tslast)) { int x,y; x=rand()%(SCRW-2)+1; y=rand()%(SCRH-2)+1; Height[Hpage][y*SCRW+x]=rand()%(pheight<<2); } /* the surfer */ if(mode&1) { int x,y; x = (SCRW/2) + ((((FSin( (xang* 65) >>8) >>8) * (FSin( (xang*349) >>8) >>8)) * ((SCRW-8)/2)) >> 16); y = (SCRH/2) + ((((FSin( (yang*377) >>8) >>8) *(FSin( (yang* 84) >>8) >>8)) * ((SCRH-8)/2)) >> 16); xang += 13; yang += 12; if(mode & 0x4000) { offset = (oy+y)/2*SCRW + (ox+x)/2; Height[Hpage][offset] = pheight; Height[Hpage][offset + 1] = Height[Hpage][offset - 1] = Height[Hpage][offset + SCRW] = Height[Hpage][offset - SCRW] = pheight >> 1; offset = y*SCRW + x; Height[Hpage][offset] = pheight<<1; Height[Hpage][offset + 1] = Height[Hpage][offset - 1] = Height[Hpage][offset + SCRW] = Height[Hpage][offset - SCRW] = pheight; } else { SineBlob((ox+x)/2, (oy+y)/2, 3, -1200, Hpage); SineBlob(x, y, 4, -2000, Hpage); } ox = x; oy = y; } if(mode&4) { int x,y; srand(time(0)); if(rand()%14 == 7) { /* if(mode & 0x4000) // HeightBlob(-1, -1, radius/2, pheight, Hpage); else */ x=rand()%(SCRW-2)+1; y=rand()%(SCRH-2)+1; SineBlob(x, y, radius, -pheight*6, Hpage); } } CalcWater(Height[Hpage^1], Height[Hpage], density); Hpage ^= 1; /* flip flop */ } #if 0 void DrawWaterNoLight(int *ptr) { int dx,dy; int x,y; int c; int p; int offset = SCRW+1; if(ptr == NULL) { return; } for(y=((SCRH-1)*SCRW); offset < y; offset+=2) { for(x = offset+SCRW-2;offset>3)+(dx>>3); /* if(p>(SCRH*SCRW)) { for(;p<(SCRH*SCRW);p-=SCRW); } if(p<0) { for(;p>0;p+=SCRW); } */ if(p >= (SCRW*SCRH) ) { p=(SCRW*SCRH)-1; } else { if(p < 0) { p=0; } } c=vidbuffer[p]; (c<1) ? c=1 : (c > 31) ? c=31 : 0; vscr[offset]=c; offset++; dx=ptr[offset]-ptr[offset+1]; dy=ptr[offset]-ptr[offset+SCRW]; p=offset+SCRW*(dy>>3)+(dx>>3); /* if(p>(SCRH*SCRW)) { for(;p<(SCRH*SCRW);p-=SCRW); } if(p<0) { for(;p>=0;p+=SCRW); } */ if(p >= (SCRW*SCRH) ) { p=(SCRW*SCRH)-1; } else { if(p < 0) { p=0; } } c=vidbuffer[p]; (c<1) ? c=1 : (c > 31) ? c=31 : 0; vscr[offset]=c; } } memcpy( vidbuffer,vscr,SCRW*SCRH); // frames++; } #endif void DrawWaterWithLight(int *ptr,int light) { int dx,dy; int x,y; int c; int p; int offset = SCRW+1; if(ptr == NULL) { return; } for(y=((SCRH-1)*SCRW); offset < y; offset+=2) { for(x = offset+SCRW-2;offset>3)+(dx>>3); if (p>(SCRH*SCRW)) p = (p % SCRW) + ((SCRH-((p - (SCRH*SCRW)) / SCRW)) * SCRW); if (p<0) p = (SCRW + (p % SCRW)) + abs(p / SCRW) * SCRW; /* if(p >= (SCRW*SCRH) ) { p=(SCRW*SCRH)-1; } else { if(p < 0) { p=0; } } */ c=vidbuffer[p]; c-=(dx>>light); (c<1) ? c=1 : (c > 31) ? c=31 : 0; vscr[offset]=c; offset++; dx=ptr[offset]-ptr[offset+1]; dy=ptr[offset]-ptr[offset+SCRW]; p=offset+SCRW*(dy>>3)+(dx>>3); if (p>(SCRH*SCRW)) p = (p % SCRW) + ((SCRH-((p - (SCRH*SCRW)) / SCRW)) * SCRW); if (p<0) p = (SCRW + (p % SCRW)) + abs(p / SCRW) * SCRW; /* if(p >= (SCRW*SCRH) ) { p=(SCRW*SCRH)-1; } else { if(p < 0) { p=0; } } */ c=vidbuffer[p]; c-=(dx>>light); (c<1) ? c=1 : (c > 31) ? c=31 : 0; vscr[offset]=c; } } memcpy( vidbuffer,vscr,SCRW*SCRH); // memcpy( VGLDisplay->Bitmap,vscr,SCRW*SCRH); // frames++; } void CalcWater(int *nptr,int *optr,int density) { int newh; int count = SCRW+1; int x,y; for(y = (SCRH-1) * SCRW;count> 2) - nptr[count]; nptr[count] = newh - (newh >> density); } } } void SineBlob(int x, int y, int radius, int height, int page) { int cx, cy; int left,top,right,bottom; int square, dist; int radsquare = radius * radius; float length = (1024.0/(float)radius)*(1024.0/(float)radius); if(x<0) x = 1+radius+ rand()%(SCRW-2*radius-1); if(y<0) y = 1+radius+ rand()%(SCRH-2*radius-1); // radsquare = (radius*radius) << 8; radsquare = (radius*radius); /* if (NetPlayNoMore == 1) { radsquare = (radius*radius); } else { radsquare = (radius*radius) << 8; height /= 8; } */ radsquare = (radius*radius); height /= 8; left=-radius; right = radius; top=-radius; bottom = radius; // Perform edge clipping... if(x - radius < 1) left -= (x-radius-1); if(y - radius < 1) top -= (y-radius-1); if(x + radius > SCRW-1) right -= (x+radius-SCRW+1); if(y + radius > SCRH-1) bottom-= (y+radius-SCRH+1); for(cy = top; cy < bottom; cy++) { for(cx = left; cx < right; cx++) { square = cy*cy + cx*cx; if(square < radsquare) { dist = sqrt(square*length); Height[page][SCRW*(cy+y) + cx+x] += (int)((FCos(dist)+0xffff)*(height)) >> 19; } } } } zsnes-1.36/src/cpu/0042755000175000017500000000000007514703044013553 5ustar dolsondolsonzsnes-1.36/src/cpu/65816d.inc0100644000175000017500000006634607505521455015121 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM flagnz, flago, flagc, execloopdeb EXTSYM Sjoinflags,Ssplitflags,SA1RegP ;******************************************************* ; Flag Setting Macros ;******************************************************* %macro endloop 0 jmp execloopdeb %endmacro %macro restoredl 0 mov dword[flagnz],0 test dl,80h jz %%noneg or dword[flagnz],10000h %%noneg test dl,2h jnz %%zero or dword[flagnz],1 %%zero mov dword[flagc],0 test dl,01h jz %%nocarry mov dword[flagc],0FFh %%nocarry mov dword[flago],0 test dl,40h jz %%nov mov dword[flago],0FFh %%nov %endmacro %macro makedl 0 and dl,00111100b test dword[flagnz],18000h jz %%noneg or dl,80h %%noneg test dword[flagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[flagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[flago],0FFh jz %%nov or dl,40h %%nov %endmacro NEWSYM splitflags push edx mov dl,[SA1RegP] call Ssplitflags pop edx restoredl ret NEWSYM joinflags makedl push edx mov dl,[SA1RegP] call Sjoinflags mov [SA1RegP],dl pop edx ret ; Sets flags n and z according to al %macro flagsetnz8b 0 mov dword[flagnz],0 mov [flagnz+1],al endloop %endmacro ; Sets flags n and z according to ax %macro flagsetnz16b 0 mov cx,ax mov [flagnz],ecx endloop %endmacro ; Sets flags n and z according to al %macro flagsetnz8bnel 0 mov dword[flagnz],0 mov [flagnz+1],al %endmacro ; Sets flags n and z according to ax %macro flagsetnz16bnel 0 mov cx,ax mov [flagnz],ecx %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzc8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro %macro flagsetnvzc16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzcs8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro %macro flagsetnvzcs16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro ; Sets flags N V . . . . Z C for 16-bit decimal mode only %macro flagsetnvzcd 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc8b 0 mov dword[flagnz],0 mov dword[flagc],0h mov [flagnz+1],al jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc 0 mov cx,ax mov dword[flagc],0h mov [flagnz],ecx jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and jump to execloop %macro flagsetnzcel8b 0 mov dword[flagnz],0h jc .carry mov [flagnz+1],cl mov dword[flagc],0FFh endloop .carry mov [flagnz+1],cl mov dword[flagc],0h endloop %endmacro %macro flagsetnzcel16b 0 jc .carry mov [flagnz],ecx mov dword[flagc],0FFh endloop .carry mov [flagnz],ecx mov dword[flagc],0h endloop %endmacro ;******************************************************* ; Opcode Instructions ;******************************************************* %macro ADCMacro8bnd 0 mov cl,[flagc] add cl,cl adc [xa],al flagsetnvzc8b %endmacro %macro ADCMacro16bnd 0 mov cl,[flagc] add cl,cl adc [xa],ax flagsetnvzc16b %endmacro %macro ADCMacro8bd 0 mov cl,[flagc] add cl,cl mov cl,al mov al,[xa] adc al,cl daa mov [xa],al flagsetnvzc8b endloop %endmacro %macro ADCMacro16bd 0 mov cl,[flagc] add cl,cl mov cx,ax mov al,[xa] adc al,cl daa mov [xa],al mov al,[xa+1] adc al,ch daa mov [xa+1],al flagsetnvzcd %endmacro %macro ANDMacro8b 0 and al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ANDMacro16b 0 and eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro ASLMacro8b 0 add al,al flagsetnzc8b %endmacro %macro ASLMacro16b 0 add ax,ax flagsetnzc %endmacro %macro JumpMacro 0 movsx eax,byte[esi] add esi,eax .skip inc esi endloop %endmacro %macro BITMacroim8b 0 mov al,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz inc esi test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacroim16b 0 mov ax,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz add esi,2 test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro8b 0 mov dword[flagnz],10000h test al,80h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test al,40h jnz .flago mov dword[flago],0 .flago test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro16b 0 mov dword[flagnz],10000h test ax,8000h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test ax,4000h jnz .flago mov dword[flago],0 .flago test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BRKMacro 0 inc esi test byte[xe],1 jne near BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[brkv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[brkv8] mov [xpc],ax and dl,11110011b or dl,00001100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro BRLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 xor eax,eax add bx,[esi] mov ax,bx xor ebx,ebx mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CMPMacro8b 0 mov cl,[xa] sub cl,al flagsetnzcel8b %endmacro %macro CMPMacro16b 0 mov cx,[xa] sub cx,ax flagsetnzcel16b %endmacro %macro COPMacro 0 inc esi test byte[xe],1 jne near COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[copv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[copv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CPXMacro8b 0 mov cl,[xx] sub cl,al flagsetnzcel8b %endmacro %macro CPXMacro16b 0 mov cx,[xx] sub cx,ax flagsetnzcel16b %endmacro %macro CPYMacro8b 0 mov cl,[xy] sub cl,al flagsetnzcel8b %endmacro %macro CPYMacro16b 0 mov cx,[xy] sub cx,ax flagsetnzcel16b %endmacro %macro EORMacro8b 0 xor al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro EORMacro16b 0 xor eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro JMLMacro 0 mov cx,[esi] xor eax,eax call membank0r16 add cx,2 push eax call membank0r8 mov bl,al pop eax mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro4C 0 xor eax,eax mov ax,[esi] mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr ; mov esi,[snesmap2+ebx*4] ; mov [initaddrl],esi ; add esi,eax ; endloop mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro6C 0 mov cx,[esi] xor eax,eax call membank0r16 mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro7C 0 mov cx,[esi] xor eax,eax add cx,[xx] mov bl,[xpb] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro5C 0 xor eax,eax mov bl,[esi+2] mov ax,[esi] mov [xpb],bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor eax,eax xor bh,bh mov ax,[esi] mov bl,[esi+2] mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacro20 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx mov ax,[esi] xor bh,bh mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacroFC 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx xor eax,eax xor bh,bh mov cx,[esi] mov bl,[xpb] add cx,[xx] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro LDAMacro8b 0 mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro LDAMacro16b 0 mov [xa],ax flagsetnz16b endloop %endmacro %macro LDXMacro8b 0 mov dword[flagnz],0 mov [xx],al mov [flagnz+1],al endloop %endmacro %macro LDXMacro16b 0 mov [xx],ax flagsetnz16b endloop %endmacro %macro LDYMacro8b 0 mov dword[flagnz],0 mov [xy],al mov [flagnz+1],al endloop %endmacro %macro LDYMacro16b 0 mov [xy],ax flagsetnz16b endloop %endmacro %macro LSRMacro8b 0 shr al,1 flagsetnzc8b %endmacro %macro LSRMacro16b 0 shr ax,1 flagsetnzc %endmacro %macro MVNMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero inc word[xx] inc word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero inc byte[xx] inc byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro MVPMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero dec word[xx] dec word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero dec byte[xx] dec byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro ORAMacro8b 0 or al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ORAMacro16b 0 or ax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro PUSHMacro8b 1 mov cx,[xs] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro8bp 0 makedl mov cx,[xs] mov al,dl call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro16b 2 mov cx,[xs] mov al,%2 call membank0w8 dec cx or cx,word[stackor] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PEAMacro 0 mov cx,[xs] mov al,[esi+1] call membank0w8 dec cx or cx,word[stackor] mov al,[esi] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx add esi,2 endloop %endmacro %macro PEIMacro 0 xor ah,ah mov al,[esi] mov cx,[xd] inc esi add cx,ax call membank0r16 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PERMacro 0 mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov eax,[snesmmap+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop .loweraddr mov eax,[snesmap2+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop %endmacro %macro POPMacro8b 1 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov %1,al flagsetnz8b endloop %endmacro %macro POPMacro16b 2 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacro16bd 2 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al call UpdateDPage mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacroP 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx xor bh,bh mov dl,al restoredl test byte[xe],01h jnz .emul mov bl,dl mov edi,[tablead+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .emul or dl,00110000b mov bl,dl mov edi,[tablead+ebx*4] endloop %endmacro %macro REPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags not al and dl,al test byte[xe],01h jnz .emul mov bl,dl mov edi,[tablead+ebx*4] endloop .emul or dl,00110000b mov bl,dl mov edi,[tablead+ebx*4] endloop .extraflags not al makedl and dl,al restoredl test byte[xe],01h jnz .emul2 mov bl,dl mov edi,[tablead+ebx*4] endloop .emul2 or dl,00110000b mov bl,dl mov edi,[tablead+ebx*4] endloop %endmacro %macro ROLMacro8b 0 mov cl,[flagc] add cl,cl rcl al,1 flagsetnzc8b %endmacro %macro ROLMacro16b 0 mov cl,[flagc] add cl,cl rcl ax,1 flagsetnzc %endmacro %macro RORMacro8b 0 mov cl,[flagc] add cl,cl rcr al,1 flagsetnzc8b %endmacro %macro RORMacro16b 0 mov cl,[flagc] add cl,cl rcr ax,1 flagsetnzc %endmacro %macro RTIMacro 0 cmp byte[nmistatus],3 jne .nodis658162 test byte[curexecstate],01h jz .nodis65816 and byte[curexecstate],0FEh call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne .nn xor dh,dh .nn .nodis658162 mov byte[curnmi],0 test byte[xe],1 jne near emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tablead+ebx*4] mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai mov byte[intrset],2 .notwai test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov byte[doirqnext],0 mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai2 mov byte[intrset],2 .notwai2 test dl,00010000b jnz .setx endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al or dl,00110000b restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tablead+ebx*4] xor bl,bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTLMacro 0 mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al ; inc bx ; and bx,word[stackand] ; mov cl,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov ch,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov al,[eax+ebx] ; mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTSMacro 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro SBCMacro8bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],ax flagsetnvzcs16b endloop %endmacro %macro SBCMacro8bd 0 mov cl,[flagc] sub cl,1 mov cl,al mov al,[xa] sbb al,cl das mov [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bd 0 mov cl,[flagc] sub cl,1 mov cx,ax mov al,[xa] sbb al,cl das mov [xa],al mov al,[xa+1] sbb al,ch das mov [xa+1],al cmc flagsetnvzcd endloop %endmacro %macro SEPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags or dl,al mov bl,dl mov edi,[tablead+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .extraflags makedl or dl,al restoredl mov bl,dl mov edi,[tablead+ebx*4] test dl,00010000b jnz .setx2 endloop .setx2 mov byte[xx+1],0 mov byte[xy+1],0 endloop %endmacro %macro STAMacro8b 0 mov al,[xa] %endmacro %macro STAMacro16b 0 mov eax,[xa] %endmacro %macro STXMacro8b 0 mov al,[xx] %endmacro %macro STXMacro16b 0 mov eax,[xx] %endmacro %macro STYMacro8b 0 mov al,[xy] %endmacro %macro STYMacro16b 0 mov eax,[xy] %endmacro %macro WAIMacro 0 cmp byte[intrset],1 jne .notws dec esi endloop .notws test byte[intrset],0FFh jz .waitstate cmp byte[intrset],2 je .stopint dec esi endloop .waitstate mov byte[intrset],1 dec esi endloop .stopint mov byte[intrset],0 mov byte[doirqnext],0 endloop %endmacro %macro XCEMacro 0 mov al,[flagc] mov dword[flagc],0 and al,00000001b cmp [xe],al jne .nochange endloop .nochange test byte[xe],0FFh jz .noemul mov dword[flagc],0FFh .noemul mov [xe],al test byte[xe],01h jnz .emul or dl,00100000b mov word[stackand],0FFFFh mov word[stackor],0000h endloop .emul or dl,00110000b mov bl,dl mov edi,[tablead+ebx*4] mov byte[xx+1],0 mov byte[xy+1],0 mov byte[xs+1],1 mov word[stackand],01FFh mov word[stackor],0100h endloop %endmacro zsnes-1.36/src/cpu/65816db.inc0100644000175000017500000006642207505521455015256 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM flagnz, flago, flagc, cpucycle, doirqnext EXTSYM dmadata ;******************************************************* ; Flag Setting Macros ;******************************************************* %macro endloop 0 mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc %%cpuover jmp dword near [edi+ebx*4] %%cpuover ret %endmacro %macro restoredl 0 mov dword[flagnz],0 test dl,80h jz %%noneg or dword[flagnz],10000h %%noneg test dl,2h jnz %%zero or dword[flagnz],1 %%zero mov dword[flagc],0 test dl,01h jz %%nocarry mov dword[flagc],0FFh %%nocarry mov dword[flago],0 test dl,40h jz %%nov mov dword[flago],0FFh %%nov %endmacro %macro makedl 0 and dl,00111100b test dword[flagnz],18000h jz %%noneg or dl,80h %%noneg test dword[flagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[flagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[flago],0FFh jz %%nov or dl,40h %%nov %endmacro ; Sets flags n and z according to al %macro flagsetnz8b 0 mov dword[flagnz],0 mov [flagnz+1],al endloop %endmacro ; Sets flags n and z according to ax %macro flagsetnz16b 0 mov cx,ax mov [flagnz],ecx endloop %endmacro ; Sets flags n and z according to al %macro flagsetnz8bnel 0 mov dword[flagnz],0 mov [flagnz+1],al %endmacro ; Sets flags n and z according to ax %macro flagsetnz16bnel 0 mov cx,ax mov [flagnz],ecx %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzc8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro %macro flagsetnvzc16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzcs8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro %macro flagsetnvzcs16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro ; Sets flags N V . . . . Z C for 16-bit decimal mode only %macro flagsetnvzcd 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc8b 0 mov dword[flagnz],0 mov dword[flagc],0h mov [flagnz+1],al jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc 0 mov cx,ax mov dword[flagc],0h mov [flagnz],ecx jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and jump to execloop %macro flagsetnzcel8b 0 mov dword[flagnz],0h jc .carry mov [flagnz+1],cl mov dword[flagc],0FFh endloop .carry mov [flagnz+1],cl mov dword[flagc],0h endloop %endmacro %macro flagsetnzcel16b 0 jc .carry mov [flagnz],ecx mov dword[flagc],0FFh endloop .carry mov [flagnz],ecx mov dword[flagc],0h endloop %endmacro ;******************************************************* ; Opcode Instructions ;******************************************************* %macro ADCMacro8bnd 0 mov cl,[flagc] add cl,cl adc [xa],al flagsetnvzc8b %endmacro %macro ADCMacro16bnd 0 mov cl,[flagc] add cl,cl adc [xa],ax flagsetnvzc16b %endmacro %macro ADCMacro8bd 0 mov cl,[flagc] add cl,cl mov cl,al mov al,[xa] adc al,cl daa mov [xa],al flagsetnvzc8b endloop %endmacro %macro ADCMacro16bd 0 mov cl,[flagc] add cl,cl mov cx,ax mov al,[xa] adc al,cl daa mov [xa],al mov al,[xa+1] adc al,ch daa mov [xa+1],al flagsetnvzcd %endmacro %macro ANDMacro8b 0 and al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ANDMacro16b 0 and eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro ASLMacro8b 0 add al,al flagsetnzc8b %endmacro %macro ASLMacro16b 0 add ax,ax flagsetnzc %endmacro %macro JumpMacro 0 movsx eax,byte[esi] add esi,eax .skip inc esi endloop %endmacro %macro BITMacroim8b 0 mov al,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz inc esi test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacroim16b 0 mov ax,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz add esi,2 test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro8b 0 mov dword[flagnz],10000h test al,80h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test al,40h jnz .flago mov dword[flago],0 .flago test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro16b 0 mov dword[flagnz],10000h test ax,8000h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test ax,4000h jnz .flago mov dword[flago],0 .flago test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BRKMacro 0 inc esi test byte[xe],1 jne near BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[brkv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[brkv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro BRLMacro 0 mov ax,[xpc] mov bl,[xpb] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax add bx,2 xor eax,eax add bx,[esi] mov ax,bx xor ebx,ebx mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CMPMacro8b 0 mov cl,[xa] sub cl,al flagsetnzcel8b %endmacro %macro CMPMacro16b 0 mov cx,[xa] sub cx,ax flagsetnzcel16b %endmacro %macro COPMacro 0 inc esi test byte[xe],1 jne near COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[copv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[copv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CPXMacro8b 0 mov cl,[xx] sub cl,al flagsetnzcel8b %endmacro %macro CPXMacro16b 0 mov cx,[xx] sub cx,ax flagsetnzcel16b %endmacro %macro CPYMacro8b 0 mov cl,[xy] sub cl,al flagsetnzcel8b %endmacro %macro CPYMacro16b 0 mov cx,[xy] sub cx,ax flagsetnzcel16b %endmacro %macro EORMacro8b 0 xor al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro EORMacro16b 0 xor eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro JMLMacro 0 mov cx,[esi] xor eax,eax call membank0r16 add cx,2 push eax call membank0r8 mov bl,al pop eax mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro4C 0 xor eax,eax mov ax,[esi] mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr ; mov esi,[snesmap2+ebx*4] ; mov [initaddrl],esi ; add esi,eax ; endloop mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro6C 0 mov cx,[esi] xor eax,eax call membank0r16 mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro7C 0 mov cx,[esi] xor eax,eax add cx,[xx] mov bl,[xpb] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro5C 0 xor eax,eax mov bl,[esi+2] mov ax,[esi] mov [xpb],bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor eax,eax xor bh,bh mov ax,[esi] mov bl,[esi+2] mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacro20 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx mov ax,[esi] xor bh,bh mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacroFC 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx xor eax,eax xor bh,bh mov cx,[esi] mov bl,[xpb] add cx,[xx] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro LDAMacro8b 0 mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro LDAMacro16b 0 mov [xa],ax flagsetnz16b endloop %endmacro %macro LDXMacro8b 0 mov dword[flagnz],0 mov [xx],al mov [flagnz+1],al endloop %endmacro %macro LDXMacro16b 0 mov [xx],ax flagsetnz16b endloop %endmacro %macro LDYMacro8b 0 mov dword[flagnz],0 mov [xy],al mov [flagnz+1],al endloop %endmacro %macro LDYMacro16b 0 mov [xy],ax flagsetnz16b endloop %endmacro %macro LSRMacro8b 0 shr al,1 flagsetnzc8b %endmacro %macro LSRMacro16b 0 shr ax,1 flagsetnzc %endmacro %macro MVNMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero inc word[xx] inc word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero inc byte[xx] inc byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro MVPMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero dec word[xx] dec word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero dec byte[xx] dec byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro ORAMacro8b 0 or al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ORAMacro16b 0 or ax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro PUSHMacro8b 1 mov cx,[xs] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro8bp 0 makedl mov cx,[xs] mov al,dl call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro16b 2 mov cx,[xs] mov al,%2 call membank0w8 dec cx or cx,word[stackor] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PEAMacro 0 mov cx,[xs] mov al,[esi+1] call membank0w8 dec cx or cx,word[stackor] mov al,[esi] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx add esi,2 endloop %endmacro %macro PEIMacro 0 xor ah,ah mov al,[esi] mov cx,[xd] inc esi add cx,ax call membank0r16 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PERMacro 0 mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov eax,[snesmmap+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop .loweraddr mov eax,[snesmap2+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop %endmacro %macro POPMacro8b 1 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov %1,al flagsetnz8b endloop %endmacro %macro POPMacro16b 2 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacro16bd 2 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al call UpdateDPage mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacroP 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx xor bh,bh mov dl,al restoredl test byte[xe],01h jnz .emul mov bl,dl mov edi,[tableadb+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadb+ebx*4] endloop %endmacro %macro REPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags not al and dl,al test byte[xe],01h jnz .emul mov bl,dl mov edi,[tableadb+ebx*4] endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadb+ebx*4] endloop .extraflags not al makedl and dl,al restoredl test byte[xe],01h jnz .emul2 mov bl,dl mov edi,[tableadb+ebx*4] endloop .emul2 or dl,00110000b mov bl,dl mov edi,[tableadb+ebx*4] endloop %endmacro %macro ROLMacro8b 0 mov cl,[flagc] add cl,cl rcl al,1 flagsetnzc8b %endmacro %macro ROLMacro16b 0 mov cl,[flagc] add cl,cl rcl ax,1 flagsetnzc %endmacro %macro RORMacro8b 0 mov cl,[flagc] add cl,cl rcr al,1 flagsetnzc8b %endmacro %macro RORMacro16b 0 mov cl,[flagc] add cl,cl rcr ax,1 flagsetnzc %endmacro %macro RTIMacro 0 cmp byte[nmistatus],3 jne .nodis658162 test byte[curexecstate],01h jz .nodis65816 and byte[curexecstate],0FEh call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne .nn xor dh,dh .nn .nodis658162 mov byte[curnmi],0 test byte[xe],1 jne near emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tableadb+ebx*4] mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai mov byte[intrset],2 .notwai test dl,00010000b jnz .setx endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai2 mov byte[intrset],2 .notwai2 test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov byte[doirqnext],0 mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al or dl,00110000b restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tableadb+ebx*4] xor bl,bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTLMacro 0 mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al ; inc bx ; and bx,word[stackand] ; mov cl,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov ch,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov al,[eax+ebx] ; mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTSMacro 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro SBCMacro8bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],ax flagsetnvzcs16b endloop %endmacro %macro SBCMacro8bd 0 mov cl,[flagc] sub cl,1 mov cl,al mov al,[xa] sbb al,cl das mov [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bd 0 mov cl,[flagc] sub cl,1 mov cx,ax mov al,[xa] sbb al,cl das mov [xa],al mov al,[xa+1] sbb al,ch das mov [xa+1],al cmc flagsetnvzcd endloop %endmacro %macro SEPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags or dl,al mov bl,dl mov edi,[tableadb+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .extraflags makedl or dl,al restoredl mov bl,dl mov edi,[tableadb+ebx*4] test dl,00010000b jnz .setx2 endloop .setx2 mov byte[xx+1],0 mov byte[xy+1],0 endloop %endmacro %macro STAMacro8b 0 mov al,[xa] %endmacro %macro STAMacro16b 0 mov eax,[xa] %endmacro %macro STXMacro8b 0 mov al,[xx] %endmacro %macro STXMacro16b 0 mov eax,[xx] %endmacro %macro STYMacro8b 0 mov al,[xy] %endmacro %macro STYMacro16b 0 mov eax,[xy] %endmacro %macro WAIMacro 0 cmp byte[intrset],1 jne .notws dec esi endloop .notws test byte[intrset],0FFh jz .waitstate cmp byte[intrset],2 je .stopint dec esi endloop .waitstate mov byte[intrset],1 dec esi endloop .stopint mov byte[intrset],0 mov byte[doirqnext],0 endloop %endmacro %macro XCEMacro 0 mov al,[flagc] mov dword[flagc],0 and al,00000001b cmp [xe],al jne .nochange endloop .nochange test byte[xe],0FFh jz .noemul mov dword[flagc],0FFh .noemul mov [xe],al test byte[xe],01h jnz .emul or dl,00100000b mov word[stackand],0FFFFh mov word[stackor],0000h endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadb+ebx*4] mov byte[xx+1],0 mov byte[xy+1],0 mov byte[xs+1],1 mov word[stackand],01FFh mov word[stackor],0100h endloop %endmacro zsnes-1.36/src/cpu/65816dc.inc0100644000175000017500000006735207505521455015262 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM flagnz, flago, flagc, cpucycle, cycpbl, cycpblt, opcjmptab, doirqnext EXTSYM dmadata ;******************************************************* ; Flag Setting Macros ;******************************************************* %macro endloop 0 sub dword[cycpbl],55 jnc %%skipallspc mov eax,[cycpblt] mov bl,[ebp] add dword[cycpbl],eax ; 1260, 10000/12625 inc ebp call dword near [opcjmptab+ebx*4] xor ebx,ebx %%skipallspc mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc %%cpuover jmp dword near [edi+ebx*4] %%cpuover ret %endmacro %macro restoredl 0 mov dword[flagnz],0 test dl,80h jz near %%noneg or dword[flagnz],10000h %%noneg test dl,2h jnz near %%zero or dword[flagnz],1 %%zero mov dword[flagc],0 test dl,01h jz near %%nocarry mov dword[flagc],0FFh %%nocarry mov dword[flago],0 test dl,40h jz near %%nov mov dword[flago],0FFh %%nov %endmacro %macro makedl 0 and dl,00111100b test dword[flagnz],18000h jz %%noneg or dl,80h %%noneg test dword[flagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[flagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[flago],0FFh jz %%nov or dl,40h %%nov %endmacro ; Sets flags n and z according to al %macro flagsetnz8b 0 mov dword[flagnz],0 mov [flagnz+1],al endloop %endmacro ; Sets flags n and z according to ax %macro flagsetnz16b 0 mov cx,ax mov [flagnz],ecx endloop %endmacro ; Sets flags n and z according to al %macro flagsetnz8bnel 0 mov dword[flagnz],0 mov [flagnz+1],al %endmacro ; Sets flags n and z according to ax %macro flagsetnz16bnel 0 mov cx,ax mov [flagnz],ecx %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzc8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro %macro flagsetnvzc16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzcs8b 0 mov dword[flagnz],0 mov al,[xa] seto byte[flago] mov [flagnz+1],al jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro %macro flagsetnvzcs16b 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0FFh endloop .carry mov dword[flagc],0h endloop %endmacro ; Sets flags N V . . . . Z C for 16-bit decimal mode only %macro flagsetnvzcd 0 mov cx,[xa] seto byte[flago] mov [flagnz],ecx jc .carry mov dword[flagc],0h endloop .carry mov dword[flagc],0FFh endloop %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc8b 0 mov dword[flagnz],0 mov dword[flagc],0h mov [flagnz+1],al jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc 0 mov cx,ax mov dword[flagc],0h mov [flagnz],ecx jnc .carry mov dword[flagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and jump to execloop %macro flagsetnzcel8b 0 mov dword[flagnz],0h jc .carry mov [flagnz+1],cl mov dword[flagc],0FFh endloop .carry mov [flagnz+1],cl mov dword[flagc],0h endloop %endmacro %macro flagsetnzcel16b 0 jc .carry mov [flagnz],ecx mov dword[flagc],0FFh endloop .carry mov [flagnz],ecx mov dword[flagc],0h endloop %endmacro ;******************************************************* ; Opcode Instructions ;******************************************************* %macro ADCMacro8bnd 0 mov cl,[flagc] add cl,cl adc [xa],al flagsetnvzc8b %endmacro %macro ADCMacro16bnd 0 mov cl,[flagc] add cl,cl adc [xa],ax flagsetnvzc16b %endmacro %macro ADCMacro8bd 0 mov cl,[flagc] add cl,cl mov cl,al mov al,[xa] adc al,cl daa mov [xa],al flagsetnvzc8b endloop %endmacro %macro ADCMacro16bd 0 mov cl,[flagc] add cl,cl mov cx,ax mov al,[xa] adc al,cl daa mov [xa],al mov al,[xa+1] adc al,ch daa mov [xa+1],al flagsetnvzcd %endmacro %macro ANDMacro8b 0 and al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ANDMacro16b 0 and eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro ASLMacro8b 0 add al,al flagsetnzc8b %endmacro %macro ASLMacro16b 0 add ax,ax flagsetnzc %endmacro %macro JumpMacro 0 movsx eax,byte[esi] add esi,eax .skip inc esi endloop %endmacro %macro BITMacroim8b 0 mov al,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz inc esi test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacroim16b 0 mov ax,[esi] test dword[flagnz],18000h jz .notflagnz or dword[flagnz],10000h .notflagnz add esi,2 test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro8b 0 mov dword[flagnz],10000h test al,80h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test al,40h jnz .flago mov dword[flago],0 .flago test [xa],al jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BITMacro16b 0 mov dword[flagnz],10000h test ax,8000h jnz .flagn mov dword[flagnz],0 .flagn mov dword[flago],1 test ax,4000h jnz .flago mov dword[flago],0 .flago test [xa],ax jz .zero mov word[flagnz],1 endloop .zero mov word[flagnz],0 endloop %endmacro %macro BRKMacro 0 inc esi test byte[xe],1 jne near BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[brkv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop BRKemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[brkv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro BRLMacro 0 mov ax,[xpc] mov bl,[xpb] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax add bx,2 xor eax,eax add bx,[esi] mov ax,bx xor ebx,ebx mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CMPMacro8b 0 mov cl,[xa] sub cl,al flagsetnzcel8b %endmacro %macro CMPMacro16b 0 mov cx,[xa] sub cx,ax flagsetnzcel16b %endmacro %macro COPMacro 0 inc esi test byte[xe],1 jne near COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[copv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop COPemulmode mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] xor ebx,ebx mov bx,[xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [xs],bx xor bh,bh mov bl,[xpb] xor eax,eax mov ax,[copv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CPXMacro8b 0 mov cl,[xx] sub cl,al flagsetnzcel8b %endmacro %macro CPXMacro16b 0 mov cx,[xx] sub cx,ax flagsetnzcel16b %endmacro %macro CPYMacro8b 0 mov cl,[xy] sub cl,al flagsetnzcel8b %endmacro %macro CPYMacro16b 0 mov cx,[xy] sub cx,ax flagsetnzcel16b %endmacro %macro EORMacro8b 0 xor al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro EORMacro16b 0 xor eax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro JMLMacro 0 mov cx,[esi] xor eax,eax call membank0r16 add cx,2 push eax call membank0r8 mov bl,al pop eax mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro4C 0 xor eax,eax mov ax,[esi] mov bl,[xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr ; mov esi,[snesmap2+ebx*4] ; mov [initaddrl],esi ; add esi,eax ; endloop mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro6C 0 mov cx,[esi] xor eax,eax call membank0r16 mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro7C 0 mov cx,[esi] xor eax,eax add cx,[xx] mov bl,[xpb] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro5C 0 xor eax,eax mov bl,[esi+2] mov ax,[esi] mov [xpb],bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor eax,eax xor bh,bh mov ax,[esi] mov bl,[esi+2] mov [xpc],ax mov [xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacro20 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx mov ax,[esi] xor bh,bh mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacroFC 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] xor eax,eax mov [xs],cx xor eax,eax xor bh,bh mov cx,[esi] mov bl,[xpb] add cx,[xx] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro LDAMacro8b 0 mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro LDAMacro16b 0 mov [xa],ax flagsetnz16b endloop %endmacro %macro LDXMacro8b 0 mov dword[flagnz],0 mov [xx],al mov [flagnz+1],al endloop %endmacro %macro LDXMacro16b 0 mov [xx],ax flagsetnz16b endloop %endmacro %macro LDYMacro8b 0 mov dword[flagnz],0 mov [xy],al mov [flagnz+1],al endloop %endmacro %macro LDYMacro16b 0 mov [xy],ax flagsetnz16b endloop %endmacro %macro LSRMacro8b 0 shr al,1 flagsetnzc8b %endmacro %macro LSRMacro16b 0 shr ax,1 flagsetnzc %endmacro %macro MVNMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz near .pagezero inc word[xx] inc word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero inc byte[xx] inc byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro MVPMacro 0 mov ax,[esi] mov [xdb],al mov bl,ah mov cx,[xx] call dword near [memtabler8+ebx*4] mov bl,[xdb] mov cx,[xy] call dword near [memtablew8+ebx*4] test dl,10h jnz near .pagezero dec word[xx] dec word[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero dec byte[xx] dec byte[xy] dec word[xa] cmp word[xa],0FFFFh je .endmove dec esi endloop %endmacro %macro ORAMacro8b 0 or al,[xa] mov dword[flagnz],0 mov [xa],al mov [flagnz+1],al endloop %endmacro %macro ORAMacro16b 0 or ax,[xa] mov [xa],ax flagsetnz16b %endmacro %macro PUSHMacro8b 1 mov eax,[wramdata] mov cx,[xs] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro8bp 0 mov eax,[wramdata] makedl mov cx,[xs] mov al,dl call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PUSHMacro16b 2 mov cx,[xs] mov al,%2 call membank0w8 dec cx or cx,word[stackor] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PEAMacro 0 mov cx,[xs] mov al,[esi+1] call membank0w8 dec cx or cx,word[stackor] mov al,[esi] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx add esi,2 endloop %endmacro %macro PEIMacro 0 xor ah,ah mov al,[esi] mov cx,[xd] inc esi add cx,ax call membank0r16 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx endloop %endmacro %macro PERMacro 0 mov bl,[xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov eax,[snesmmap+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop .loweraddr mov eax,[snesmap2+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [xs],cx xor ebx,ebx endloop %endmacro %macro POPMacro8b 1 mov eax,[wramdata] mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov %1,al flagsetnz8b endloop %endmacro %macro POPMacro16b 2 mov eax,[wramdata] mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacro16bd 2 mov eax,[wramdata] mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al call UpdateDPage mov [xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacroP 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx xor bh,bh mov dl,al restoredl test byte[xe],01h jnz near .emul mov bl,dl mov edi,[tableadc+ebx*4] test dl,00010000b jnz near .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadc+ebx*4] endloop %endmacro %macro REPMacro 0 mov al,[esi] inc esi test al,11000011b jnz near .extraflags not al and dl,al test byte[xe],01h jnz .emul mov bl,dl mov edi,[tableadc+ebx*4] endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadc+ebx*4] endloop .extraflags not al makedl and dl,al restoredl test byte[xe],01h jnz .emul2 mov bl,dl mov edi,[tableadc+ebx*4] endloop .emul2 or dl,00110000b mov bl,dl mov edi,[tableadc+ebx*4] endloop %endmacro %macro ROLMacro8b 0 mov cl,[flagc] add cl,cl rcl al,1 flagsetnzc8b %endmacro %macro ROLMacro16b 0 mov cl,[flagc] add cl,cl rcl ax,1 flagsetnzc %endmacro %macro RORMacro8b 0 mov cl,[flagc] add cl,cl rcr al,1 flagsetnzc8b %endmacro %macro RORMacro16b 0 mov cl,[flagc] add cl,cl rcr ax,1 flagsetnzc %endmacro %macro RTIMacro 0 cmp byte[nmistatus],3 jne near .nodis658162 test byte[curexecstate],01h jz near .nodis65816 and byte[curexecstate],0FEh call changeexecloop .nodis65816 cmp byte[curexecstate],0 jne near .nn xor dh,dh .nn .nodis658162 mov byte[curnmi],0 test byte[xe],1 jne near emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tableadc+ebx*4] mov bl,[xpb] mov [xpc],ax test eax,8000h jz near .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai mov byte[intrset],2 .notwai test dl,00010000b jnz near .setx endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae near .upperlower mov [initaddrl],esi add esi,eax cmp byte[esi],0CBh jne .notwai2 mov byte[intrset],2 .notwai2 test dl,00010000b jnz near .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je near .dma mov byte[doirqnext],0 mov [initaddrl],esi add esi,eax test dl,00010000b jnz near .setx endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax test dl,00010000b jnz near .setx endloop emulRTI mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xs],cx mov dl,al or dl,00110000b restoredl mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] mov bl,dl mov edi,[tableadc+ebx*4] xor bl,bl mov [xpc],ax test eax,8000h jz near .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTLMacro 0 mov cx,[xs] inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] xor eax,eax call membank0r8 mov [xpb],al ; inc bx ; and bx,word[stackand] ; mov cl,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov ch,[eax+ebx] ; inc bx ; and bx,word[stackand] ; mov al,[eax+ebx] ; mov [xpb],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov bl,[xpb] mov [xpc],ax test eax,8000h jz near .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTSMacro 0 mov cx,[xs] inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al mov [xs],cx xor bh,bh xor eax,eax mov ax,[xpc] inc ax mov [xpc],ax mov bl,[xpb] test eax,8000h jz near .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro SBCMacro8bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bnd 0 mov cl,[flagc] sub cl,1 sbb [xa],ax flagsetnvzcs16b endloop %endmacro %macro SBCMacro8bd 0 mov cl,[flagc] sub cl,1 mov cl,al mov al,[xa] sbb al,cl das mov [xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bd 0 mov cl,[flagc] sub cl,1 mov cx,ax mov al,[xa] sbb al,cl das mov [xa],al mov al,[xa+1] sbb al,ch das mov [xa+1],al cmc flagsetnvzcd endloop %endmacro %macro SEPMacro 0 mov al,[esi] inc esi test al,11000011b jnz near .extraflags or dl,al mov bl,dl mov edi,[tableadc+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[xx+1],0 mov byte[xy+1],0 endloop .extraflags makedl or dl,al restoredl mov bl,dl mov edi,[tableadc+ebx*4] test dl,00010000b jnz .setx2 endloop .setx2 mov byte[xx+1],0 mov byte[xy+1],0 endloop %endmacro %macro STAMacro8b 0 mov al,[xa] %endmacro %macro STAMacro16b 0 mov eax,[xa] %endmacro %macro STXMacro8b 0 mov al,[xx] %endmacro %macro STXMacro16b 0 mov eax,[xx] %endmacro %macro STYMacro8b 0 mov al,[xy] %endmacro %macro STYMacro16b 0 mov eax,[xy] %endmacro %macro WAIMacro 0 cmp byte[intrset],1 jne .notws dec esi endloop .notws test byte[intrset],0FFh jz .waitstate cmp byte[intrset],2 je .stopint dec esi endloop .waitstate mov byte[intrset],1 dec esi endloop .stopint mov byte[intrset],0 mov byte[doirqnext],0 endloop %endmacro %macro XCEMacro 0 mov al,[flagc] mov dword[flagc],0 and al,00000001b cmp [xe],al jne .nochange endloop .nochange test byte[xe],0FFh jz .noemul mov dword[flagc],0FFh .noemul mov [xe],al test byte[xe],01h jnz .emul or dl,00100000b mov word[stackand],0FFFFh mov word[stackor],0000h endloop .emul or dl,00110000b mov bl,dl mov edi,[tableadc+ebx*4] mov byte[xx+1],0 mov byte[xy+1],0 mov byte[xs+1],1 mov word[stackand],01FFh mov word[stackor],0100h endloop %endmacro zsnes-1.36/src/cpu/address.inc0100644000175000017500000003236707267141100015673 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM membank0w8ram ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8br 0 mov al,[esi] inc esi %endmacro %macro addr_I_16br 0 mov eax,[esi] add esi,2 %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtabler16+ebx*4] %endmacro %macro addr_a_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtablew8+ebx*4] %endmacro %macro addr_a_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtablew16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler16+ebx*4] %endmacro %macro addr_al_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew8+ebx*4] %endmacro %macro addr_al_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR8] %endmacro %macro addr_d_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] %endmacro %macro addr_d_8bw 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageW8] %endmacro %macro addr_d_16bw 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageW16] %endmacro ; 5. Accumulator -- A %macro addr_A_8br 0 mov al,[xa] %endmacro %macro addr_A_16br 0 mov eax,[xa] %endmacro %macro addr_A_8bw 0 mov [xa],al %endmacro %macro addr_A_16bw 0 mov [xa],ax %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdBCy_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdBCy_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np pop ax call dword near [memtablew16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdLCy_8bw 0 push ax mov ecx,[xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] pop ax jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdLCy_16bw 0 push ax mov ecx,[xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 xor bl,bl push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] pop ax jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCxB_8bw 0 push ax mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCxB_16bw 0 push ax mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r8 %endmacro %macro addr_dCx_16br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0r16 %endmacro %macro addr_dCx_8bw 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0w8 %endmacro %macro addr_dCx_16bw 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xx] call membank0w16 %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xy] call membank0r8 %endmacro %macro addr_dCy_16br 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xy] call membank0r16 %endmacro %macro addr_dCy_8bw 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xy] call membank0w8 %endmacro %macro addr_dCy_16bw 0 mov ecx,[xd] mov bl,[esi] add cx,bx inc esi add cx,[xy] call membank0w16 %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCx_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCx_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCy_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCy_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_alCx_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_alCx_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdB_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdB_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8br 0 mov bl,[esi] mov ecx,[xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16br 0 mov bl,[esi] mov ecx,[xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdL_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdL_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r8 %endmacro %macro addr_dCs_16br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 %endmacro %macro addr_dCs_8bw 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0w8 %endmacro %macro addr_dCs_16bw 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0w16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCsBCy_8bw 0 push ax mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] pop ax add cx,[xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCsBCy_16bw 0 push ax mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] pop ax add cx,[xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro zsnes-1.36/src/cpu/address2.inc0100644000175000017500000003241307267141100015745 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM DPageR8,DPageR16,DPageW8,DPageW16 ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8br 0 mov al,[esi] inc esi %endmacro %macro addr_I_16br 0 mov eax,[esi] add esi,2 %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtabler16+ebx*4] %endmacro %macro addr_a_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtablew8+ebx*4] %endmacro %macro addr_a_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 call dword near [memtablew16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler16+ebx*4] %endmacro %macro addr_al_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew8+ebx*4] %endmacro %macro addr_al_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR8] %endmacro %macro addr_d_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] %endmacro %macro addr_d_8bw 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageW8] %endmacro %macro addr_d_16bw 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageW16] %endmacro ; 5. Accumulator -- A %macro addr_A_8br 0 mov al,[xa] %endmacro %macro addr_A_16br 0 mov eax,[xa] %endmacro %macro addr_A_8bw 0 mov [xa],al %endmacro %macro addr_A_16bw 0 mov [xa],ax %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdBCy_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdBCy_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np pop ax call dword near [memtablew16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8br 0 mov ecx,[xd] mov bl,[esi] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16br 0 mov ecx,[xd] mov bl,[esi] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdLCy_8bw 0 push ax mov ecx,[xd] mov bl,[esi] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax add cx,[xy] pop ax jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdLCy_16bw 0 push ax mov ecx,[xd] mov bl,[esi] inc esi push cx call dword near [DPageR16] pop cx add cx,2 xor bl,bl push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax add cx,[xy] pop ax jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCxB_8bw 0 push ax mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCxB_16bw 0 push ax mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR8] %endmacro %macro addr_dCx_16br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageR16] %endmacro %macro addr_dCx_8bw 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageW8] %endmacro %macro addr_dCx_16bw 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xx] call dword near [DPageW16] %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xy] call dword near [DPageR8] %endmacro %macro addr_dCy_16br 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xy] call dword near [DPageR16] %endmacro %macro addr_dCy_8bw 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xy] call dword near [DPageW8] %endmacro %macro addr_dCy_16bw 0 mov ecx,[xd] mov bl,[esi] inc esi add cx,[xy] call dword near [DPageW16] %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCx_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCx_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16br 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCy_8bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCy_16bw 0 mov cx,[esi] mov bl,[xdb] add esi,2 add cx,[xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_alCx_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_alCx_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16br 0 mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdB_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdB_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi call dword near [DPageR16] mov cx,ax mov bl,[xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8br 0 mov bl,[esi] mov ecx,[xd] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16br 0 mov bl,[esi] mov ecx,[xd] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdL_8bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdL_16bw 0 push ax mov bl,[esi] mov ecx,[xd] inc esi push cx call dword near [DPageR16] pop cx add cx,2 push ax call dword near [DPageR8] mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r8 %endmacro %macro addr_dCs_16br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 %endmacro %macro addr_dCs_8bw 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0w8 %endmacro %macro addr_dCs_16bw 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0w16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16br 0 mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCsBCy_8bw 0 push ax mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] pop ax add cx,[xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCsBCy_16bw 0 push ax mov bl,[esi] mov cx,[xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] pop ax add cx,[xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro zsnes-1.36/src/cpu/addrni.asm0100644000175000017500000001663607267141100015517 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8brni 0 mov al,[esi] %endmacro %macro addr_I_16brni 0 mov ax,[esi] %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8brni 0 mov cx,[esi] mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16brni 0 mov cx,[esi] mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR8] %endmacro %macro addr_d_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] %endmacro ; 5. Accumulator -- A %macro addr_A_8brni 0 mov al,[xa] %endmacro %macro addr_A_16brni 0 mov ax,[xa] %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r8 %endmacro %macro addr_dCx_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xy] call membank0r8 %endmacro %macro addr_dCy_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xy] call membank0r16 %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8brni 0 mov bl,[esi] mov ecx,[xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16brni 0 mov bl,[esi] mov ecx,[xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r8 %endmacro %macro addr_dCs_16brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro zsnes-1.36/src/cpu/addrni.inc0100644000175000017500000001664007267141100015503 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8brni 0 mov al,[esi] %endmacro %macro addr_I_16brni 0 mov ax,[esi] %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8brni 0 mov cx,[esi] mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16brni 0 mov cx,[esi] mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR8] %endmacro %macro addr_d_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] %endmacro ; 5. Accumulator -- A %macro addr_A_8brni 0 mov al,[xa] %endmacro %macro addr_A_16brni 0 mov ax,[xa] %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r8 %endmacro %macro addr_dCx_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xx] call membank0r16 %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xy] call membank0r8 %endmacro %macro addr_dCy_16brni 0 mov ecx,[xd] mov bl,[esi] add cx,bx add cx,[xy] call membank0r16 %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16brni 0 mov cx,[esi] mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16brni 0 mov bl,[esi] mov ecx,[xd] call dword near [DPageR16] mov cx,ax mov bl,[xdb] call dword near [memtabler16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8brni 0 mov bl,[esi] mov ecx,[xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16brni 0 mov bl,[esi] mov ecx,[xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r8 %endmacro %macro addr_dCs_16brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16brni 0 mov bl,[esi] mov cx,[xs] add cx,bx call membank0r16 mov cx,ax mov bl,[xdb] add cx,[xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro zsnes-1.36/src/cpu/dma.asm0100644000175000017500000006520007506772270015024 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM memtabler8,regptw,snesmap2,snesmmap,debstop3 ;EXTSYM soundcycleft,pexecs2 EXTSYM memtablew8,regptr EXTSYM dmadata EXTSYM hdmatype EXTSYM nexthdma EXTSYM curhdma,curypos,disablehdma,hdmadata,hdmadelay,hdmaearlstart EXTSYM resolutn EXTSYM memtabler16 NEWSYM DmaAsmStart ;******************************************************* ; Transfer DMA Inits & Transfers DMA ;******************************************************* ; DMA transfer register NEWSYM AddrNoIncr, db 0 %macro ExecSPCCycles 0 xor ebx,ebx mov bx,[esi+5] inc bx inc ebx shr ebx,2 mov [soundcycleft],ebx or ebx,ebx jz .nocycles xor ebx,ebx xor ecx,ecx call pexecs2 .nocycles %endmacro NEWSYM transdma push eax cmp word[esi+5],480h jne .no ; mov byte[debstop3],1 .no ; ExecSPCCycles mov al,[esi] test al,80h jnz near transdmappu2cpu ; set address increment value mov dword[.addrincr],0 test al,00001000b jnz .skipaddrincr test al,00010000b jnz .autodec mov dword[.addrincr],1 jmp .skipaddrincr .autodec mov dword[.addrincr],0FFFFFFFFh .skipaddrincr mov byte[AddrNoIncr],0 cmp dword[.addrincr],0 jne .notzero mov byte[AddrNoIncr],1 .notzero ; get address order to be written xor ebx,ebx and al,00000111b cmp al,5 jne .notmode5dma sub al,4 .notmode5dma mov bl,al shl bl,3 add ebx,.addrwrite mov edi,ebx ; get pointer #1 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi] shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [.regptra],eax ; get pointer #2 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+2] shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [.regptrb],eax ; get pointer #3 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+4] shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [.regptrc],eax ; get pointer #4 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+6] shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [.regptrd],eax mov dx,[esi+5] ; Number of bytes to transfer xor ebx,ebx mov bl,[esi+4] ; Bank # mov ecx,[esi+2] ; address offset # and ecx,0FFFFh mov [.curbank],bl mov word[esi+5],0 mov ebx,[.curbank] mov eax,snesmap2 test ecx,8000h jz .nomap1 mov eax,snesmmap .nomap1 and edx,0FFFFh mov ebx,[eax+ebx*4] ;snesmmap times 256 dd 0 ; addresses 8000-FFFF ;snesmap2 times 256 dd 0 ; addresses 0000-7FFF push esi mov esi,ebx xor ebx,ebx mov bl,[.curbank] ; do loop cmp edx,0 jne .no0 mov edx,65536 .no0 mov ebx,[memtabler8+ebx*4] mov [.readaddr],ebx xor ebx,ebx mov bl,[.curbank] mov [.cebx],ebx .againloop cmp edx,4 jbe .deccheckloop mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptra] mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrb] mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrc] mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrd] sub edx,4 jmp .againloop .deccheckloop mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptra] dec edx jz .findma mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrb] dec edx jz .findma mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrc] dec edx jz .findma mov ebx,[.cebx] call dword near [.readaddr] add cx,[.addrincr] call dword near [.regptrd] .findma pop esi mov [esi+2],cx pop eax mov byte[AddrNoIncr],0 ret ALIGN32 .curbank dd 0 .addrincr dd 0 .addrwrite dw 0,0,0,0, 0,1,0,1, 0,0,0,0, 0,0,1,1, 0,1,2,3, 0,1,2,3, 0,1,2,3 dw 0,1,2,3 ; pointer address of registers .regptra dd 0 .regptrb dd 0 .regptrc dd 0 .regptrd dd 0 .readaddr dd 0 .cebx dd 0 NEWSYM transdmappu2cpu ; set address increment value mov dword[.addrincr],0 test al,00001000b jnz .skipaddrincr test al,00010000b jnz .autodec mov dword[.addrincr],1 jmp .skipaddrincr .autodec mov dword[.addrincr],0FFFFFFFFh .skipaddrincr ; get address order to be written xor ebx,ebx and al,00000111b mov bl,al shl bl,3 add ebx,.addrwrite mov edi,ebx ; get pointer #1 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi] shl ebx,2 add ebx,[regptr] mov eax,[ebx] mov [.regptra],eax ; get pointer #2 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+2] shl ebx,2 add ebx,[regptr] mov eax,[ebx] mov [.regptrb],eax ; get pointer #3 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+4] shl ebx,2 add ebx,[regptr] mov eax,[ebx] mov [.regptrc],eax ; get pointer #4 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+6] shl ebx,2 add ebx,[regptr] mov eax,[ebx] mov [.regptrd],eax mov dx,[esi+5] ; Number of bytes to transfer xor ebx,ebx mov bl,[esi+4] ; Bank # mov ecx,[esi+2] ; address offset # and ecx,0FFFFh mov [.curbank],bl mov word[esi+5],0 mov ebx,[.curbank] mov eax,snesmap2 test ecx,8000h jz .nomap1 mov eax,snesmmap .nomap1 and edx,0FFFFh mov ebx,[eax+ebx*4] ;snesmmap times 256 dd 0 ; addresses 8000-FFFF ;snesmap2 times 256 dd 0 ; addresses 0000-7FFF push esi mov esi,ebx xor ebx,ebx mov bl,[.curbank] ; do loop cmp edx,0 jne .no0 mov edx,65536 .no0 mov ebx,[memtablew8+ebx*4] mov [.writeaddr],ebx xor ebx,ebx mov bl,[.curbank] mov [.cebx],ebx .againloop cmp edx,4 jbe .deccheckloop call dword near [.regptra] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] call dword near [.regptrb] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] call dword near [.regptrc] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] call dword near [.regptrd] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] sub edx,4 jmp .againloop .deccheckloop call dword near [.regptra] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] dec edx jz .findma call dword near [.regptrb] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] dec edx jz .findma call dword near [.regptrc] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] dec edx jz .findma call dword near [.regptrd] mov ebx,[.cebx] call dword near [.writeaddr] add cx,[.addrincr] .findma pop esi mov [esi+2],cx pop eax ret ALIGN32 .curbank dd 0 .addrincr dd 0 .addrwrite dw 0,0,0,0, 0,1,0,1, 0,0,0,0, 0,0,1,1, 0,1,2,3, 0,1,2,3, 0,1,2,3 dw 0,1,2,3 ; pointer address of registers .regptra dd 0 .regptrb dd 0 .regptrc dd 0 .regptrd dd 0 .writeaddr dd 0 .cebx dd 0 %macro TestDMA 0 %endmacro ; DMA enable register ; use dmadata for input on dma NEWSYM reg420Bw push eax push esi push edi push ecx push edx mov esi,dmadata test al,01h jz .notransa TestDMA call transdma .notransa add esi,16 test al,02h jz .notransb TestDMA call transdma .notransb add esi,16 test al,04h jz .notransc TestDMA call transdma .notransc add esi,16 test al,08h jz .notransd TestDMA call transdma .notransd add esi,16 test al,10h jz .notranse TestDMA call transdma .notranse add esi,16 test al,20h jz .notransf TestDMA call transdma .notransf add esi,16 test al,40h jz .notransg TestDMA call transdma .notransg add esi,16 test al,80h jz .notransh TestDMA call transdma .notransh pop edx pop ecx pop edi pop esi pop eax ret ;******************************************************* ; HDMA Settings ;******************************************************* NEWSYM setuphdma push eax ; transfer old address to new address mov ax,[esi+2] mov [esi+8],ax mov [edx+17],ax ; get address order to be written xor ebx,ebx xor eax,eax xor ecx,ecx mov al,[esi] and al,00000111b cmp al,5 jb .notmode567dma sub al,4 .notmode567dma mov ah,[.addrnumt+eax] mov [edx+16],ah mov bl,al shl bl,3 add ebx,.addrwrite mov edi,ebx ; get pointer #1 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi] cmp bx,2118h je .notnormalhdma1 cmp bx,2119h je .notnormalhdma1 jmp .normalhdma1 .notnormalhdma1 mov bx,2200h ; bad hack _Demo_ .normalhdma1 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx],eax ; get pointer #2 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+2] cmp bx,2118h je .notnormalhdma2 cmp bx,2119h je .notnormalhdma2 jmp .normalhdma2 .notnormalhdma2 mov bx,2200h ; bad hack _Demo_ .normalhdma2 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+4],eax ; get pointer #3 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+4] cmp bx,2118h je .notnormalhdma3 cmp bx,2119h je .notnormalhdma3 jmp .normalhdma3 .notnormalhdma3 mov bx,2200h ; bad hack _Demo_ .normalhdma3 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+8],eax ; get pointer #4 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+6] cmp bx,2118h je .notnormalhdma4 cmp bx,2119h je .notnormalhdma4 jmp .normalhdma4 .notnormalhdma4 mov bx,2200h ; bad hack _Demo_ .normalhdma4 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+12],eax xor ebx,ebx mov byte[esi+10],0 pop eax or [hdmatype],ah ret .addrwrite dw 0,0,0,0, 0,1,0,1, 0,0,0,0, 0,0,1,1, 0,1,2,3, 0,1,2,3, 0,1,2,3 dw 0,1,2,3 .addrnumt db 1,2,2,4,4,4,4,4 NEWSYM setuphdmars push eax ; get address order to be written xor ebx,ebx xor eax,eax xor ecx,ecx mov al,[esi] and al,00000111b cmp al,5 jb .notmode567dma sub al,4 .notmode567dma mov ah,[.addrnumt+eax] mov [edx+16],ah mov bl,al shl bl,3 add ebx,.addrwrite mov edi,ebx ; get pointer #1 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi] cmp bx,2118h je .notnormalhdma1 cmp bx,2119h je .notnormalhdma1 jmp .normalhdma1 .notnormalhdma1 mov bx,2200h ; bad hack _Demo_ .normalhdma1 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx],eax ; get pointer #2 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+2] cmp bx,2118h je .notnormalhdma2 cmp bx,2119h je .notnormalhdma2 jmp .normalhdma2 .notnormalhdma2 mov bx,2200h ; bad hack _Demo_ .normalhdma2 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+4],eax ; get pointer #3 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+4] cmp bx,2118h je .notnormalhdma3 cmp bx,2119h je .notnormalhdma3 jmp .normalhdma3 .notnormalhdma3 mov bx,2200h ; bad hack _Demo_ .normalhdma3 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+8],eax ; get pointer #4 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+6] cmp bx,2118h je .notnormalhdma4 cmp bx,2119h je .notnormalhdma4 jmp .normalhdma4 .notnormalhdma4 mov bx,2200h ; bad hack _Demo_ .normalhdma4 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+12],eax xor ebx,ebx pop eax ret .addrwrite dw 0,0,0,0, 0,1,0,1, 0,0,0,0, 0,0,1,1, 0,1,2,3, 0,1,2,3, 0,1,2,3 dw 0,1,2,3 .addrnumt db 1,2,2,4,4,4,4,4 NEWSYM setuphdma2 push eax cmp byte[esi+10],0 je near .nohdma ; transfer old address to new address mov ax,[esi+8] mov [edx+17],ax ; get address order to be written xor ebx,ebx xor eax,eax xor ecx,ecx mov al,[esi] and al,00000111b cmp al,5 jb .notmode567dma sub al,4 .notmode567dma mov ah,[.addrnumt+eax] mov [edx+16],ah mov bl,al shl bl,3 add ebx,.addrwrite mov edi,ebx ; get pointer #1 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi] cmp bx,2118h je .notnormalhdma1 cmp bx,2119h je .notnormalhdma1 jmp .normalhdma1 .notnormalhdma1 mov bx,2200h ; bad hack _Demo_ .normalhdma1 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx],eax ; get pointer #2 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+2] cmp bx,2118h je .notnormalhdma2 cmp bx,2119h je .notnormalhdma2 jmp .normalhdma2 .notnormalhdma2 mov bx,2200h ; bad hack _Demo_ .normalhdma2 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+4],eax ; get pointer #3 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+4] cmp bx,2118h je .notnormalhdma3 cmp bx,2119h je .notnormalhdma3 jmp .normalhdma3 .notnormalhdma3 mov bx,2200h ; bad hack _Demo_ .normalhdma3 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+8],eax ; get pointer #4 xor ebx,ebx mov bl,[esi+1] ; PPU memory - 21xx mov bh,21h add bx,[edi+6] cmp bx,2118h je .notnormalhdma4 cmp bx,2119h je .notnormalhdma4 jmp .normalhdma4 .notnormalhdma4 mov bx,2200h ; bad hack _Demo_ .normalhdma4 shl ebx,2 add ebx,[regptw] mov eax,[ebx] mov [edx+12],eax xor ebx,ebx pop eax and [hdmatype],ah ret .nohdma pop eax and [nexthdma],ah ret .addrwrite dw 0,0,0,0, 0,1,0,1, 0,0,0,0, 0,0,1,1, 0,1,2,3, 0,1,2,3, 0,1,2,3 dw 0,1,2,3 .addrnumt db 1,2,2,4,4,4,4,4 NEWSYM hdmastartsc, db 0 NEWSYM hdmarestart, db 0 NEWSYM reg420Cw mov [curhdma],al mov bx,[resolutn] cmp word[curypos],bx jae near .nohdma cmp byte[disablehdma],0 jne near .nohdma ; jmp starthdma mov al,[curhdma] mov [nexthdma],al cmp al,0 je near .nohdma push ebx push esi push edi push ecx push edx mov esi,dmadata mov edx,hdmadata mov ah,01h test al,01h jz .notransa call setuphdma .notransa add esi,16 add edx,19 mov ah,02h test al,02h jz .notransb call setuphdma .notransb add esi,16 add edx,19 mov ah,04h test al,04h jz .notransc call setuphdma .notransc add esi,16 add edx,19 mov ah,08h test al,08h jz .notransd call setuphdma .notransd add esi,16 add edx,19 mov ah,10h test al,10h jz .notranse call setuphdma .notranse add esi,16 add edx,19 mov ah,20h test al,20h jz .notransf call setuphdma .notransf add esi,16 add edx,19 mov ah,40h test al,40h jz .notransg call setuphdma .notransg add esi,16 add edx,19 mov ah,80h test al,80h jz .notransh call setuphdma .notransh mov bl,[hdmaearlstart] mov [hdmadelay],bl pop edx pop ecx pop edi pop esi pop ebx ; call exechdma ; call exechdma .nohdma mov byte[hdmarestart],0 ret ; HDMA enable register NEWSYM starthdma mov al,[curhdma] NEWSYM startnexthdma mov [nexthdma],al cmp al,0 je near .nohdma push ebx push esi push edi push ecx push edx mov esi,dmadata mov edx,hdmadata mov ah,01h test al,01h jz .notransa call setuphdma .notransa add esi,16 add edx,19 mov ah,02h test al,02h jz .notransb call setuphdma .notransb add esi,16 add edx,19 mov ah,04h test al,04h jz .notransc call setuphdma .notransc add esi,16 add edx,19 mov ah,08h test al,08h jz .notransd call setuphdma .notransd add esi,16 add edx,19 mov ah,10h test al,10h jz .notranse call setuphdma .notranse add esi,16 add edx,19 mov ah,20h test al,20h jz .notransf call setuphdma .notransf add esi,16 add edx,19 mov ah,40h test al,40h jz .notransg call setuphdma .notransg add esi,16 add edx,19 mov ah,80h test al,80h jz .notransh call setuphdma .notransh pop edx pop ecx pop edi pop esi pop ebx .nohdma ret NEWSYM dohdma xor ebx,ebx test byte[esi],40h jnz near indirectaddr push eax test byte[esi+10],07Fh jnz near .nozero test byte[esi+10],80h jnz near .noincr test [hdmatype],ah jnz .noincr mov bl,[edx+16] add word[edx+17],bx .noincr mov bl,ah not bl and [hdmatype],bl mov bl,[esi+4] mov cx,[edx+17] call dword near [memtabler8+ebx*4] inc word[edx+17] mov byte[esi+10],al test al,0FFh jnz .yeszero xor [nexthdma],ah jmp .finhdma2 .yeszero cmp byte[esi+10],80h ja near hdmatype2 mov al,[edx+16] mov [.tempdecr],al xor ebx,ebx xor ecx,ecx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location call dword near [memtabler8+ebx*4] call dword near [edx] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location inc cx call dword near [memtabler8+ebx*4] call dword near [edx+4] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location add cx,2 call dword near [memtabler8+ebx*4] call dword near [edx+8] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location add cx,3 call dword near [memtabler8+ebx*4] call dword near [edx+12] jmp .finhdma .nozero test byte[esi+10],80h jnz near hdmatype2 .finhdma mov ax,[edx+17] mov [esi+8],ax pop eax dec byte[esi+10] ret .finhdma2 mov ax,[edx+17] mov [esi+8],ax pop eax ret .tempdecr db 0 NEWSYM hdmatype2 mov al,[edx+16] mov [.tempdecr],al xor ebx,ebx xor ecx,ecx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location inc word[edx+17] call dword near [memtabler8+ebx*4] call dword near [edx] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location inc word[edx+17] call dword near [memtabler8+ebx*4] call dword near [edx+4] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location inc word[edx+17] call dword near [memtabler8+ebx*4] call dword near [edx+8] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+4] mov cx,[edx+17] ; increment/decrement/keep pointer location inc word[edx+17] call dword near [memtabler8+ebx*4] call dword near [edx+12] .finhdma mov ax,[edx+17] mov [esi+8],ax pop eax dec byte[esi+10] ret .tempdecr db 0 NEWSYM indirectaddr push eax test byte[esi+10],07Fh jnz near .nozero test [hdmatype],ah jnz .noincr add word[edx+17],2 .noincr mov bl,ah not bl and [hdmatype],bl mov bl,[esi+4] mov cx,[edx+17] call dword near [memtabler8+ebx*4] inc word[edx+17] mov byte[esi+10],al push eax mov bl,[esi+4] mov cx,[edx+17] call dword near [memtabler16+ebx*4] mov [esi+5],ax pop eax test al,0FFh jnz .yeszero xor [nexthdma],ah jmp .finhdma2 .yeszero cmp byte[esi+10],80h ja near hdmatype2indirect mov al,[edx+16] mov [.tempdecr],al xor ebx,ebx xor ecx,ecx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location call dword near [memtabler8+ebx*4] call dword near [edx] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location inc cx call dword near [memtabler8+ebx*4] call dword near [edx+4] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location add cx,2 call dword near [memtabler8+ebx*4] call dword near [edx+8] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location add cx,3 call dword near [memtabler8+ebx*4] call dword near [edx+12] jmp .finhdma .nozero test byte[esi+10],80h jnz near hdmatype2indirect .finhdma mov ax,[edx+17] mov [esi+8],ax pop eax dec byte[esi+10] ret .finhdma2 mov ax,[edx+17] mov [esi+8],ax pop eax ret .tempdecr db 0 .fname2 db 9,'vram2.dat',0 EXTSYM spcRam NEWSYM ewj2hack, dd 0 NEWSYM hdmatype2indirect cmp dword [ewj2hack],1 jne near .notend cmp byte [esi+1],40h ; Writing to spc jne near .notend cmp byte [esi+10],0DAh ; first transfer jne near .notend ; EWJ2 HACK ; int 3h push eax push ebx push ecx push edx xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov ax,word[spcRam+021h] ; load dest offset mov dword [.dest],spcRam add [.dest],eax mov dl,byte[esi+10] ; number of bytes to transfer sub dl,80h .inloop xor ebx,ebx xor ecx,ecx mov bl,[esi+7] mov cx,[esi+5] inc word[esi+5] call dword near [memtabler8+ebx*4] mov ebx,[.dest] mov byte [ebx],al inc ebx mov [.dest],ebx xor ebx,ebx xor ecx,ecx mov bl,[esi+7] mov cx,[esi+5] inc word[esi+5] call dword near [memtabler8+ebx*4] mov ebx,[.dest] mov byte [ebx],al inc ebx mov [.dest],ebx dec edx jnz .inloop sub word[esi+5],5Ah sub word[esi+5],5Ah pop edx pop ecx pop ebx pop eax .notend mov al,[edx+16] mov [.tempdecr],al xor ebx,ebx xor ecx,ecx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location inc word[esi+5] call dword near [memtabler8+ebx*4] call dword near [edx] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location inc word[esi+5] call dword near [memtabler8+ebx*4] call dword near [edx+4] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location inc word[esi+5] call dword near [memtabler8+ebx*4] call dword near [edx+8] dec byte[.tempdecr] jz .finhdma xor ebx,ebx mov bl,[esi+7] mov cx,[esi+5] ; increment/decrement/keep pointer location inc word[esi+5] call dword near [memtabler8+ebx*4] call dword near [edx+12] .finhdma pop eax dec byte[esi+10] ret .dest dd 0 .tempdecr db 0 NEWSYM exechdma cmp byte[hdmarestart],1 je near exechdmars mov al,[nexthdma] cmp al,0 je near .nohdma push ebx push esi push edi push ecx push edx mov esi,dmadata mov edx,hdmadata mov ah,01h test al,01h jz .notransa call dohdma .notransa add esi,16 add edx,19 mov ah,02h test al,02h jz .notransb call dohdma .notransb add esi,16 add edx,19 mov ah,04h test al,04h jz .notransc call dohdma .notransc add esi,16 add edx,19 mov ah,08h test al,08h jz .notransd call dohdma .notransd add esi,16 add edx,19 mov ah,10h test al,10h jz .notranse call dohdma .notranse add esi,16 add edx,19 mov ah,20h test al,20h jz .notransf call dohdma .notransf add esi,16 add edx,19 mov ah,40h test al,40h jz .notransg call dohdma .notransg add esi,16 add edx,19 mov ah,80h test al,80h jz .notransh call dohdma .notransh pop edx pop ecx pop edi pop esi pop ebx .nohdma ret NEWSYM exechdmars mov al,[nexthdma] cmp al,0 je near .nohdma push ebx push esi push edi push ecx push edx mov esi,dmadata mov edx,hdmadata mov ah,01h test al,01h jz .notransa call setuphdmars call dohdma .notransa add esi,16 add edx,19 mov ah,02h test al,02h jz .notransb call setuphdmars call dohdma .notransb add esi,16 add edx,19 mov ah,04h test al,04h jz .notransc call setuphdmars call dohdma .notransc add esi,16 add edx,19 mov ah,08h test al,08h jz .notransd call setuphdmars call dohdma .notransd add esi,16 add edx,19 mov ah,10h test al,10h jz .notranse call setuphdmars call dohdma .notranse add esi,16 add edx,19 mov ah,20h test al,20h jz .notransf call setuphdmars call dohdma .notransf add esi,16 add edx,19 mov ah,40h test al,40h jz .notransg call setuphdmars call dohdma .notransg add esi,16 add edx,19 mov ah,80h test al,80h jz .notransh call setuphdmars call dohdma .notransh pop edx pop ecx pop edi pop esi pop ebx .nohdma mov byte[hdmarestart],0 ret NEWSYM DmaAsmEnd zsnes-1.36/src/cpu/dsp.asm0100644000175000017500000031537007462663140015053 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM BRRPlace0,BRRPlace1,BRRPlace2,BRRPlace3,BRRPlace4,BRRPlace5,BRRPlace6 EXTSYM BRRPlace7,Decrease,DecreaseRateExp,EchoFB,EchoRate,EchoVL,EchoVR EXTSYM FIRTAPVal0,FIRTAPVal1,FIRTAPVal2,FIRTAPVal3,FIRTAPVal4,FIRTAPVal5 EXTSYM FIRTAPVal6,FIRTAPVal7,GlobalVL,GlobalVR,Increase,IncreaseBent EXTSYM MaxEcho,MusicVol,NoiseInc,NoiseSpeeds,SBToSPC,Voice0End,Voice0EnvInc EXTSYM Voice0IncNumber,Voice0Loop,Voice0Noise,Voice0Prev0,Voice0Prev1 EXTSYM Voice0Start,Voice0State,Voice0Status,Voice0Time,Voice1End,Voice1Noise EXTSYM Voice1Prev0,Voice1Prev1,Voice1Start,Voice2End,Voice2Noise,Voice2Prev0 EXTSYM Voice2Prev1,Voice2Start,Voice3End,Voice3Noise,Voice3Prev0,Voice3Prev1 EXTSYM Voice3Start,Voice4End,Voice4Noise,Voice4Prev0,Voice4Prev1,Voice4Start EXTSYM Voice5End,Voice5Noise,Voice5Prev0,Voice5Prev1,Voice5Start,Voice6End EXTSYM Voice6Noise,Voice6Prev0,Voice6Prev1,Voice6Start,Voice7End,Voice7Noise EXTSYM Voice7Prev0,Voice7Prev1,Voice7Start,VolumeConvTable,VolumeTableb,keyonsn EXTSYM RevStereo,Voice1Status,Voice2Status,Voice3Status,Voice4Status,Voice5Status EXTSYM Voice6Status,Voice7Status EXTSYM GainDecBendDataPos,GainDecBendDataTime,GainDecBendDataDat EXTSYM AdsrSustLevLoc,AdsrBlocksLeft,AdsrNextTimeDepth EXTSYM MuteVoiceF,VoiceStarter EXTSYM DecayRate,SustainRate,SustainValue EXTSYM KeyOnStA,KeyOnStB,SoundTest NEWSYM DspAsmStart ;none times 256 db 0 identcode db 255,1,78,78 ;sardcode db 234,76,80,128,65,65 ; 6 ;efxcode db 17,47,62,97,26,126,98 ; 7 ;zopcode db 54,39,21,0,0,8,14,12,18 ; 9 ;yoshcode db 0,68,23,76,123,98,34,87,12,98,65 ; 11 ;deejcode db 78,39,240,150,15,78,39,68,89,54,32,33 ; 12 ;vmprcode db 127,127,127,127,255,255,255,255,0,0,0,0,1,0,1,0 ; 16 ;conjcode db 32,32,25,20,78,232,242,242,0,1,4,98,98,45,13,12,99 ; 17 ;wnelcode db 32,64,123,76,123,76,12,0,1,7,43,12,87,18,51,136,65,132 ; 18 ;crascode db 82,48,89,26,65,10,200,26,73,84,29,120,37,213,78,89,111,23,84,13,200 ; 21 - Crashman ; Digital Sound Processor of the SPC700 By _Demo_ %macro initrevsthelp 1 mov al,[DSPMem+01h+%1] mov ah,[DSPMem+00h+%1] mov [DSPMem+01h+%1],ah mov [DSPMem+00h+%1],al %endmacro ALIGN32 NEWSYM DSPMem, times 256 db 0 ;Read DSP Registers functions NEWSYM RDSPReg00 ; Voice 0 Volume Left mov al,[DSPMem+00h] ret NEWSYM RDSPReg01 ; Voice 0 Volume Right mov al,[DSPMem+01h] ret NEWSYM RDSPReg02 ; Voice 0 Pitch Low mov al,[DSPMem+02h] ret NEWSYM RDSPReg03 ; Voice 0 Pitch High mov al,[DSPMem+03h] ret NEWSYM RDSPReg04 ; Voice 0 SCRN mov al,[DSPMem+04h] ret NEWSYM RDSPReg05 ; Voice 0 ADSR (1) mov al,[DSPMem+05h] ret NEWSYM RDSPReg06 ; Voice 0 ADSR (2) mov al,[DSPMem+06h] ret NEWSYM RDSPReg07 ; Voice 0 GAIN mov al,[DSPMem+07h] ret NEWSYM RDSPReg08 ; Voice 0 ENVX mov al,[DSPMem+08h] xor al,al ret NEWSYM RDSPReg09 ; Voice 0 OUTX mov al,[DSPMem+09h] ret NEWSYM RDSPReg0A ; mov al,[DSPMem+0Ah] ret NEWSYM RDSPReg0B ; mov al,[DSPMem+0Bh] ret NEWSYM RDSPReg0C ; mov al,[DSPMem+0Ch] ret NEWSYM RDSPReg0D ; mov al,[DSPMem+0Dh] ret NEWSYM RDSPReg0E ; mov al,[DSPMem+0Eh] ret NEWSYM RDSPReg0F ; Voice 0 Echo coefficient mov al,[DSPMem+0Fh] ret NEWSYM RDSPReg10 ; Voice 1 Volume Left mov al,[DSPMem+10h] ret NEWSYM RDSPReg11 ; Voice 1 Volume Right mov al,[DSPMem+11h] ret NEWSYM RDSPReg12 ; Voice 1 Pitch Low mov al,[DSPMem+012h] ret NEWSYM RDSPReg13 ; Voice 1 Pitch High mov al,[DSPMem+013h] ret NEWSYM RDSPReg14 ; Voice 1 SCRN mov al,[DSPMem+014h] ret NEWSYM RDSPReg15 ; Voice 1 ADSR (1) mov al,[DSPMem+015h] ret NEWSYM RDSPReg16 ; Voice 1 ADSR (2) mov al,[DSPMem+016h] ret NEWSYM RDSPReg17 ; Voice 1 GAIN mov al,[DSPMem+017h] ret NEWSYM RDSPReg18 ; Voice 1 ENVX mov al,[DSPMem+018h] xor al,al ret NEWSYM RDSPReg19 ; Voice 1 OUTX mov al,[DSPMem+019h] ret NEWSYM RDSPReg1A ; mov al,[DSPMem+01Ah] ret NEWSYM RDSPReg1B ; mov al,[DSPMem+01Bh] ret NEWSYM RDSPReg1C ; mov al,[DSPMem+01Ch] ret NEWSYM RDSPReg1D ; mov al,[DSPMem+01Dh] ret NEWSYM RDSPReg1E ; mov al,[DSPMem+01Eh] ret NEWSYM RDSPReg1F ; Voice 1 Echo coefficient mov al,[DSPMem+01Fh] ret NEWSYM RDSPReg20 ; Voice 2 Volume Left mov al,[DSPMem+20h] ret NEWSYM RDSPReg21 ; Voice 2 Volume Right mov al,[DSPMem+21h] ret NEWSYM RDSPReg22 ; Voice 2 Pitch Low mov al,[DSPMem+022h] ret NEWSYM RDSPReg23 ; Voice 2 Pitch High mov al,[DSPMem+023h] ret NEWSYM RDSPReg24 ; Voice 2 SCRN mov al,[DSPMem+024h] ret NEWSYM RDSPReg25 ; Voice 2 ADSR (1) mov al,[DSPMem+025h] ret NEWSYM RDSPReg26 ; Voice 2 ADSR (2) mov al,[DSPMem+026h] ret NEWSYM RDSPReg27 ; Voice 2 GAIN mov al,[DSPMem+027h] ret NEWSYM RDSPReg28 ; Voice 2 ENVX mov al,[DSPMem+028h] xor al,al ret NEWSYM RDSPReg29 ; Voice 2 OUTX mov al,[DSPMem+029h] ret NEWSYM RDSPReg2A ; mov al,[DSPMem+02Ah] ret NEWSYM RDSPReg2B ; mov al,[DSPMem+02Bh] ret NEWSYM RDSPReg2C ; mov al,[DSPMem+02Ch] ret NEWSYM RDSPReg2D ; mov al,[DSPMem+02Dh] ret NEWSYM RDSPReg2E ; mov al,[DSPMem+02Eh] ret NEWSYM RDSPReg2F ; Voice 2 Echo coefficient mov al,[DSPMem+02Fh] ret NEWSYM RDSPReg30 ; Voice 3 Volume Left mov al,[DSPMem+30h] ret NEWSYM RDSPReg31 ; Voice 3 Volume Right mov al,[DSPMem+31h] ret NEWSYM RDSPReg32 ; Voice 3 Pitch Low mov al,[DSPMem+032h] ret NEWSYM RDSPReg33 ; Voice 3 Pitch High mov al,[DSPMem+033h] ret NEWSYM RDSPReg34 ; Voice 3 SCRN mov al,[DSPMem+034h] ret NEWSYM RDSPReg35 ; Voice 3 ADSR (1) mov al,[DSPMem+035h] ret NEWSYM RDSPReg36 ; Voice 3 ADSR (2) mov al,[DSPMem+036h] ret NEWSYM RDSPReg37 ; Voice 3 GAIN mov al,[DSPMem+037h] ret NEWSYM RDSPReg38 ; Voice 3 ENVX mov al,[DSPMem+038h] xor al,al ret NEWSYM RDSPReg39 ; Voice 3 OUTX mov al,[DSPMem+039h] ret NEWSYM RDSPReg3A ; mov al,[DSPMem+03Ah] ret NEWSYM RDSPReg3B ; mov al,[DSPMem+03Bh] ret NEWSYM RDSPReg3C ; mov al,[DSPMem+03Ch] ret NEWSYM RDSPReg3D ; mov al,[DSPMem+03Dh] ret NEWSYM RDSPReg3E ; mov al,[DSPMem+03Eh] ret NEWSYM RDSPReg3F ; Voice 3 Echo coefficient mov al,[DSPMem+03Fh] ret NEWSYM RDSPReg40 ; Voice 4 Volume Left mov al,[DSPMem+40h] ret NEWSYM RDSPReg41 ; Voice 4 Volume Right mov al,[DSPMem+41h] ret NEWSYM RDSPReg42 ; Voice 4 Pitch Low mov al,[DSPMem+042h] ret NEWSYM RDSPReg43 ; Voice 4 Pitch High mov al,[DSPMem+043h] ret NEWSYM RDSPReg44 ; Voice 4 SCRN mov al,[DSPMem+044h] ret NEWSYM RDSPReg45 ; Voice 4 ADSR (1) mov al,[DSPMem+045h] ret NEWSYM RDSPReg46 ; Voice 4 ADSR (2) mov al,[DSPMem+046h] ret NEWSYM RDSPReg47 ; Voice 4 GAIN mov al,[DSPMem+047h] ret NEWSYM RDSPReg48 ; Voice 4 ENVX mov al,[DSPMem+048h] xor al,al ret NEWSYM RDSPReg49 ; Voice 4 OUTX mov al,[DSPMem+049h] ret NEWSYM RDSPReg4A ; mov al,[DSPMem+04Ah] ret NEWSYM RDSPReg4B ; mov al,[DSPMem+04Bh] ret NEWSYM RDSPReg4C ; mov al,[DSPMem+04Ch] ret NEWSYM RDSPReg4D ; mov al,[DSPMem+04Dh] ret NEWSYM RDSPReg4E ; mov al,[DSPMem+04Eh] ret NEWSYM RDSPReg4F ; Voice 4 Echo coefficient mov al,[DSPMem+04Fh] ret NEWSYM RDSPReg50 ; Voice 5 Volume Left mov al,[DSPMem+50h] ret NEWSYM RDSPReg51 ; Voice 5 Volume Right mov al,[DSPMem+51h] ret NEWSYM RDSPReg52 ; Voice 5 Pitch Low mov al,[DSPMem+052h] ret NEWSYM RDSPReg53 ; Voice 5 Pitch High mov al,[DSPMem+053h] ret NEWSYM RDSPReg54 ; Voice 5 SCRN mov al,[DSPMem+054h] ret NEWSYM RDSPReg55 ; Voice 5 ADSR (1) mov al,[DSPMem+055h] ret NEWSYM RDSPReg56 ; Voice 5 ADSR (2) mov al,[DSPMem+056h] ret NEWSYM RDSPReg57 ; Voice 5 GAIN mov al,[DSPMem+057h] ret NEWSYM RDSPReg58 ; Voice 5 ENVX mov al,[DSPMem+058h] xor al,al ret NEWSYM RDSPReg59 ; Voice 5 OUTX mov al,[DSPMem+059h] ret NEWSYM RDSPReg5A ; mov al,[DSPMem+05Ah] ret NEWSYM RDSPReg5B ; mov al,[DSPMem+05Bh] ret NEWSYM RDSPReg5C ; mov al,[DSPMem+05Ch] ret NEWSYM RDSPReg5D ; mov al,[DSPMem+05Dh] ret NEWSYM RDSPReg5E ; mov al,[DSPMem+05Eh] ret NEWSYM RDSPReg5F ; Voice 5 Echo coefficient mov al,[DSPMem+05Fh] ret NEWSYM RDSPReg60 ; Voice 6 Volume Left mov al,[DSPMem+60h] ret NEWSYM RDSPReg61 ; Voice 6 Volume Right mov al,[DSPMem+61h] ret NEWSYM RDSPReg62 ; Voice 6 Pitch Low mov al,[DSPMem+062h] ret NEWSYM RDSPReg63 ; Voice 6 Pitch High mov al,[DSPMem+063h] ret NEWSYM RDSPReg64 ; Voice 6 SCRN mov al,[DSPMem+064h] ret NEWSYM RDSPReg65 ; Voice 6 ADSR (1) mov al,[DSPMem+065h] ret NEWSYM RDSPReg66 ; Voice 6 ADSR (2) mov al,[DSPMem+066h] ret NEWSYM RDSPReg67 ; Voice 6 GAIN mov al,[DSPMem+067h] ret NEWSYM RDSPReg68 ; Voice 6 ENVX mov al,[DSPMem+068h] xor al,al ret NEWSYM RDSPReg69 ; Voice 6 OUTX mov al,[DSPMem+069h] ret NEWSYM RDSPReg6A ; mov al,[DSPMem+06Ah] ret NEWSYM RDSPReg6B ; mov al,[DSPMem+06Bh] ret NEWSYM RDSPReg6C ; mov al,[DSPMem+06Ch] ret NEWSYM RDSPReg6D ; mov al,[DSPMem+06Dh] ret NEWSYM RDSPReg6E ; mov al,[DSPMem+06Eh] ret NEWSYM RDSPReg6F ; Voice 6 Echo coefficient mov al,[DSPMem+06Fh] ret NEWSYM RDSPReg70 ; Voice 7 Volume Left mov al,[DSPMem+70h] ret NEWSYM RDSPReg71 ; Voice 7 Volume Right mov al,[DSPMem+71h] ret NEWSYM RDSPReg72 ; Voice 7 Pitch Low mov al,[DSPMem+072h] ret NEWSYM RDSPReg73 ; Voice 7 Pitch High mov al,[DSPMem+073h] ret NEWSYM RDSPReg74 ; Voice 7 SCRN mov al,[DSPMem+074h] ret NEWSYM RDSPReg75 ; Voice 7 ADSR (1) mov al,[DSPMem+075h] ret NEWSYM RDSPReg76 ; Voice 7 ADSR (2) mov al,[DSPMem+076h] ret NEWSYM RDSPReg77 ; Voice 7 GAIN mov al,[DSPMem+077h] ret NEWSYM RDSPReg78 ; Voice 7 ENVX mov al,[DSPMem+078h] xor al,al ret NEWSYM RDSPReg79 ; Voice 7 OUTX mov al,[DSPMem+079h] ret NEWSYM RDSPReg7A ; mov al,[DSPMem+07Ah] ret NEWSYM RDSPReg7B ; mov al,[DSPMem+07Bh] ret NEWSYM RDSPReg7C ; mov al,[DSPMem+07Ch] ret NEWSYM RDSPReg7D ; mov al,[DSPMem+07Dh] ret NEWSYM RDSPReg7E ; mov al,[DSPMem+07Eh] ret NEWSYM RDSPReg7F ; Voice 7 Echo coefficient mov al,[DSPMem+07Fh] ret NEWSYM RDSPReg80 ; mov al,[DSPMem+080h] ret NEWSYM RDSPReg81 ; mov al,[DSPMem+081h] ret NEWSYM RDSPReg82 ; mov al,[DSPMem+082h] ret NEWSYM RDSPReg83 ; mov al,[DSPMem+083h] ret NEWSYM RDSPReg84 ; mov al,[DSPMem+084h] ret NEWSYM RDSPReg85 ; mov al,[DSPMem+085h] ret NEWSYM RDSPReg86 ; mov al,[DSPMem+086h] ret NEWSYM RDSPReg87 ; mov al,[DSPMem+087h] ret NEWSYM RDSPReg88 ; mov al,[DSPMem+088h] ret NEWSYM RDSPReg89 ; mov al,[DSPMem+089h] ret NEWSYM RDSPReg8A ; mov al,[DSPMem+08Ah] ret NEWSYM RDSPReg8B ; mov al,[DSPMem+08Bh] ret NEWSYM RDSPReg8C ; mov al,[DSPMem+08Ch] ret NEWSYM RDSPReg8D ; mov al,[DSPMem+08Dh] ret NEWSYM RDSPReg8E ; mov al,[DSPMem+08Eh] ret NEWSYM RDSPReg8F ; mov al,[DSPMem+08Fh] ret NEWSYM RDSPReg90 ; mov al,[DSPMem+090h] ret NEWSYM RDSPReg91 ; mov al,[DSPMem+091h] ret NEWSYM RDSPReg92 ; mov al,[DSPMem+092h] ret NEWSYM RDSPReg93 ; mov al,[DSPMem+093h] ret NEWSYM RDSPReg94 ; mov al,[DSPMem+094h] ret NEWSYM RDSPReg95 ; mov al,[DSPMem+095h] ret NEWSYM RDSPReg96 ; mov al,[DSPMem+096h] ret NEWSYM RDSPReg97 ; mov al,[DSPMem+097h] ret NEWSYM RDSPReg98 ; mov al,[DSPMem+098h] ret NEWSYM RDSPReg99 ; mov al,[DSPMem+099h] ret NEWSYM RDSPReg9A ; mov al,[DSPMem+09Ah] ret NEWSYM RDSPReg9B ; mov al,[DSPMem+09Bh] ret NEWSYM RDSPReg9C ; mov al,[DSPMem+09Ch] ret NEWSYM RDSPReg9D ; mov al,[DSPMem+09Dh] ret NEWSYM RDSPReg9E ; mov al,[DSPMem+09Eh] ret NEWSYM RDSPReg9F ; mov al,[DSPMem+09Fh] ret NEWSYM RDSPRegA0 ; mov al,[DSPMem+0A0h] ret NEWSYM RDSPRegA1 ; mov al,[DSPMem+0A1h] ret NEWSYM RDSPRegA2 ; mov al,[DSPMem+0A2h] ret NEWSYM RDSPRegA3 ; mov al,[DSPMem+0A3h] ret NEWSYM RDSPRegA4 ; mov al,[DSPMem+0A4h] ret NEWSYM RDSPRegA5 ; mov al,[DSPMem+0A5h] ret NEWSYM RDSPRegA6 ; mov al,[DSPMem+0A6h] ret NEWSYM RDSPRegA7 ; mov al,[DSPMem+0A7h] ret NEWSYM RDSPRegA8 ; mov al,[DSPMem+0A8h] ret NEWSYM RDSPRegA9 ; mov al,[DSPMem+0A9h] ret NEWSYM RDSPRegAA ; mov al,[DSPMem+0AAh] ret NEWSYM RDSPRegAB ; mov al,[DSPMem+0ABh] ret NEWSYM RDSPRegAC ; mov al,[DSPMem+0ACh] ret NEWSYM RDSPRegAD ; mov al,[DSPMem+0ADh] ret NEWSYM RDSPRegAE ; mov al,[DSPMem+0AEh] ret NEWSYM RDSPRegAF ; mov al,[DSPMem+0AFh] ret NEWSYM RDSPRegB0 ; mov al,[DSPMem+0B0h] ret NEWSYM RDSPRegB1 ; mov al,[DSPMem+0B1h] ret NEWSYM RDSPRegB2 ; mov al,[DSPMem+0B2h] ret NEWSYM RDSPRegB3 ; mov al,[DSPMem+0B3h] ret NEWSYM RDSPRegB4 ; mov al,[DSPMem+0B4h] ret NEWSYM RDSPRegB5 ; mov al,[DSPMem+0B5h] ret NEWSYM RDSPRegB6 ; mov al,[DSPMem+0B6h] ret NEWSYM RDSPRegB7 ; mov al,[DSPMem+0B7h] ret NEWSYM RDSPRegB8 ; mov al,[DSPMem+0B8h] ret NEWSYM RDSPRegB9 ; mov al,[DSPMem+0B9h] ret NEWSYM RDSPRegBA ; mov al,[DSPMem+0BAh] ret NEWSYM RDSPRegBB ; mov al,[DSPMem+0BBh] ret NEWSYM RDSPRegBC ; mov al,[DSPMem+0BCh] ret NEWSYM RDSPRegBD ; mov al,[DSPMem+0BDh] ret NEWSYM RDSPRegBE ; mov al,[DSPMem+0BEh] ret NEWSYM RDSPRegBF ; mov al,[DSPMem+0BFh] ret NEWSYM RDSPRegC0 ; mov al,[DSPMem+0C0h] ret NEWSYM RDSPRegC1 ; mov al,[DSPMem+0C1h] ret NEWSYM RDSPRegC2 ; mov al,[DSPMem+0C2h] ret NEWSYM RDSPRegC3 ; mov al,[DSPMem+0C3h] ret NEWSYM RDSPRegC4 ; mov al,[DSPMem+0C4h] ret NEWSYM RDSPRegC5 ; mov al,[DSPMem+0C5h] ret NEWSYM RDSPRegC6 ; mov al,[DSPMem+0C6h] ret NEWSYM RDSPRegC7 ; mov al,[DSPMem+0C7h] ret NEWSYM RDSPRegC8 ; mov al,[DSPMem+0C8h] ret NEWSYM RDSPRegC9 ; mov al,[DSPMem+0C9h] ret NEWSYM RDSPRegCA ; mov al,[DSPMem+0CAh] ret NEWSYM RDSPRegCB ; mov al,[DSPMem+0CBh] ret NEWSYM RDSPRegCC ; mov al,[DSPMem+0CCh] ret NEWSYM RDSPRegCD ; mov al,[DSPMem+0CDh] ret NEWSYM RDSPRegCE ; mov al,[DSPMem+0CEh] ret NEWSYM RDSPRegCF ; mov al,[DSPMem+0CFh] ret NEWSYM RDSPRegD0 ; mov al,[DSPMem+0D0h] ret NEWSYM RDSPRegD1 ; mov al,[DSPMem+0D1h] ret NEWSYM RDSPRegD2 ; mov al,[DSPMem+0D2h] ret NEWSYM RDSPRegD3 ; mov al,[DSPMem+0D3h] ret NEWSYM RDSPRegD4 ; mov al,[DSPMem+0D4h] ret NEWSYM RDSPRegD5 ; mov al,[DSPMem+0D5h] ret NEWSYM RDSPRegD6 ; mov al,[DSPMem+0D6h] ret NEWSYM RDSPRegD7 ; mov al,[DSPMem+0D7h] ret NEWSYM RDSPRegD8 ; mov al,[DSPMem+0D8h] ret NEWSYM RDSPRegD9 ; mov al,[DSPMem+0D9h] ret NEWSYM RDSPRegDA ; mov al,[DSPMem+0DAh] ret NEWSYM RDSPRegDB ; mov al,[DSPMem+0DBh] ret NEWSYM RDSPRegDC ; mov al,[DSPMem+0DCh] ret NEWSYM RDSPRegDD ; mov al,[DSPMem+0DDh] ret NEWSYM RDSPRegDE ; mov al,[DSPMem+0DEh] ret NEWSYM RDSPRegDF ; mov al,[DSPMem+0DFh] ret NEWSYM RDSPRegE0 ; mov al,[DSPMem+0E0h] ret NEWSYM RDSPRegE1 ; mov al,[DSPMem+0E1h] ret NEWSYM RDSPRegE2 ; mov al,[DSPMem+0E2h] ret NEWSYM RDSPRegE3 ; mov al,[DSPMem+0E3h] ret NEWSYM RDSPRegE4 ; mov al,[DSPMem+0E4h] ret NEWSYM RDSPRegE5 ; mov al,[DSPMem+0E5h] ret NEWSYM RDSPRegE6 ; mov al,[DSPMem+0E6h] ret NEWSYM RDSPRegE7 ; mov al,[DSPMem+0E7h] ret NEWSYM RDSPRegE8 ; mov al,[DSPMem+0E8h] ret NEWSYM RDSPRegE9 ; mov al,[DSPMem+0E9h] ret NEWSYM RDSPRegEA ; mov al,[DSPMem+0EAh] ret NEWSYM RDSPRegEB ; mov al,[DSPMem+0EBh] ret NEWSYM RDSPRegEC ; mov al,[DSPMem+0ECh] ret NEWSYM RDSPRegED ; mov al,[DSPMem+0EDh] ret NEWSYM RDSPRegEE ; mov al,[DSPMem+0EEh] ret NEWSYM RDSPRegEF ; mov al,[DSPMem+0EFh] ret NEWSYM RDSPRegF0 ; mov al,[DSPMem+0F0h] ret NEWSYM RDSPRegF1 ; mov al,[DSPMem+0F1h] ret NEWSYM RDSPRegF2 ; mov al,[DSPMem+0F2h] ret NEWSYM RDSPRegF3 ; mov al,[DSPMem+0F3h] ret NEWSYM RDSPRegF4 ; mov al,[DSPMem+0F4h] ret NEWSYM RDSPRegF5 ; mov al,[DSPMem+0F5h] ret NEWSYM RDSPRegF6 ; mov al,[DSPMem+0F6h] ret NEWSYM RDSPRegF7 ; mov al,[DSPMem+0F7h] ret NEWSYM RDSPRegF8 ; mov al,[DSPMem+0F8h] ret NEWSYM RDSPRegF9 ; mov al,[DSPMem+0F9h] ret NEWSYM RDSPRegFA ; mov al,[DSPMem+0FAh] ret NEWSYM RDSPRegFB ; mov al,[DSPMem+0FBh] ret NEWSYM RDSPRegFC ; mov al,[DSPMem+0FCh] ret NEWSYM RDSPRegFD ; mov al,[DSPMem+0FDh] ret NEWSYM RDSPRegFE ; mov al,[DSPMem+0FEh] ret NEWSYM RDSPRegFF ; mov al,[DSPMem+0FFh] ret %macro ProcessGain 1 push eax push ebx push edx test byte [DSPMem+07h+%1*10h],80h jz near %%Direct test byte [DSPMem+07h+%1*10h],40h jnz near %%Increase test byte [DSPMem+07h+%1*10h],20h jz near %%LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[DecreaseRateExp+eax*4] mov dword[Voice0EnvInc+%1*4],007FFFFFh shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov eax,127*65536 sub eax,118*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],7 ret %%LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Decrease+eax*4] mov dword[Voice0EnvInc+%1*4],007FFFFFh mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],5 ret %%Increase test byte [DSPMem+07h+%1*10h],20h jz %%LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx mov dword [Voice0IncNumber+%1*4],eax mov ebx,[Voice0Time+%1*4] mov eax,ebx shr eax,2 sub ebx,eax dec ebx mov [Voice0Time+%1*4],ebx pop edx pop ebx pop eax mov byte [Voice0State+%1],6 ret %%LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],3 ret %%Direct mov al,[DSPMem+07h+%1*10h] and al,7Fh mov dword[Voice0EnvInc+%1*4],0 mov byte [Voice0EnvInc+%1*4+2],al mov dword [Voice0Time+%1*4],0FFFFFFFFh mov dword [Voice0IncNumber+%1*4],0 pop edx pop ebx pop eax mov byte [Voice0State+%1],4 ret %endmacro %macro ProcessGain2 1 push eax push ebx push edx test byte [DSPMem+07h+%1*10h],80h jz near %%Direct test byte [DSPMem+07h+%1*10h],40h jnz near %%Increase test byte [DSPMem+07h+%1*10h],20h jz near %%LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[DecreaseRateExp+eax*4] shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov dh,118 mov dl,[Voice0EnvInc+%1*4+2] xor eax,eax mov al,[VolumeConvTable+edx*2] xor edx,edx shl eax,16 mov dl,[Voice0EnvInc+%1*4+2] neg eax shl edx,16 add eax,edx xor edx,edx mov byte[GainDecBendDataPos+%1],0 div ebx neg eax mov [Voice0IncNumber+%1*4],eax mov al,[Voice0EnvInc+%1*4+2] mov [GainDecBendDataDat+%1],al pop edx pop ebx pop eax mov byte [Voice0State+%1],7 ret %%LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Decrease+eax*4] mov dword[Voice0Time+%1*4],ebx xor edx,edx xor eax,eax mov al,[Voice0EnvInc+%1*4+2] shl eax,16 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],5 ret %%Increase test byte [DSPMem+07h+%1*10h],20h jz %%LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0Time+%1*4],ebx xor edx,edx xor eax,eax mov al,[Voice0EnvInc+%1*4+2] inc al test al,80h jz %%noof mov al,127 %%noof xor al,127 shl eax,16 div ebx mov dword [Voice0IncNumber+%1*4],eax mov ebx,[Voice0Time+%1*4] mov eax,ebx shr eax,2 sub ebx,eax dec ebx mov [Voice0Time+%1*4],ebx pop edx pop ebx pop eax mov byte [Voice0State+%1],6 ret %%LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0Time+%1*4],ebx xor edx,edx xor eax,eax mov al,[Voice0EnvInc+%1*4+2] inc al test al,80h jz %%noof2 mov al,127 %%noof2 xor al,127 shl eax,16 div ebx mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],3 ret %%Direct mov al,[DSPMem+07h+%1*10h] and al,7Fh mov dword[Voice0EnvInc+%1*4],0 mov byte [Voice0EnvInc+%1*4+2],al mov dword [Voice0Time+%1*4],0FFFFFFFFh mov dword [Voice0IncNumber+%1*4],0 pop edx pop ebx pop eax mov byte [Voice0State+%1],4 ret %%end pop edx pop ebx pop eax ret %endmacro %macro SwitchSustain 1 push eax push ebx push edx mov al,[Voice0EnvInc+%1*4+2] mov [GainDecBendDataDat+%1],al cmp byte[Voice0State+%1],8 je %%full cmp byte[Voice0State+%1],2 jae %%nofull %%full mov byte[GainDecBendDataDat+%1],7Fh %%nofull mov al,[DSPMem+05h+%1*10h] shr al,4 and eax,07h mov edx,[DecayRate+eax*4] xor eax,eax mov al,[DSPMem+06h+%1*10h] and al,1Fh mov ebx,[SustainRate+eax*4] cmp edx,ebx jae near %%decayover ; ebx = total sustain time xor eax,eax mov al,[DSPMem+06h+%1*10h] shr al,5 mov al,[AdsrSustLevLoc+eax] ; traverse through al entries in edx time ; then through 64-al entries in ebx-edx time mov [AdsrBlocksLeft+%1],al sub ebx,edx push ebx push eax mov ebx,eax mov eax,edx xor edx,edx or ebx,ebx jz .oopszero div ebx .oopszero mov [Voice0Time+%1*4],eax mov [GainDecBendDataTime+%1*4],eax pop eax pop ebx mov edx,ebx mov ebx,64 sub bl,al mov eax,edx xor edx,edx div ebx mov [AdsrNextTimeDepth+%1*4],eax mov dword[Voice0EnvInc+%1*4],0 mov al,[GainDecBendDataDat+%1] mov [Voice0EnvInc+%1*4+2],al mov ebx,[Voice0Time+%1*4] xor edx,edx mov dh,122 mov dl,[Voice0EnvInc+%1*4+2] xor eax,eax mov al,[VolumeConvTable+edx*2] xor edx,edx shl eax,16 mov dl,[Voice0EnvInc+%1*4+2] neg eax shl edx,16 add eax,edx xor edx,edx mov byte[GainDecBendDataPos+%1],0 div ebx neg eax mov [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],9 ret %%decayover sub edx,ebx push ebx mov eax,edx xor ebx,ebx mov bl,[DSPMem+06h+%1*10h] shr bl,5 xor bl,07h mul ebx mov ebx,7 div ebx pop ebx add ebx,eax mov dword[Voice0EnvInc+%1*4],007FFFFFh shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov dh,118 mov dl,[Voice0EnvInc+%1*4+2] xor eax,eax mov al,[VolumeConvTable+edx*2] xor edx,edx shl eax,16 mov dl,[Voice0EnvInc+%1*4+2] neg eax shl edx,16 add eax,edx xor edx,edx mov byte[GainDecBendDataPos+%1],0 div ebx neg eax mov [Voice0IncNumber+%1*4],eax pop edx pop ebx pop eax mov byte [Voice0State+%1],7 ret %endmacro %macro VoiceAdsr 1 test byte[MuteVoiceF],1 << %1 jnz near .nogain cmp byte[Voice0State+%1],200 je near .nogain cmp [DSPMem+05h+%1*10h],al je near .nogain test al,80h jz near .gain mov [DSPMem+05h+%1*10h],al SwitchSustain %1 ret .nogain mov [DSPMem+05h+%1*10h],al ret .gain cmp byte[Voice0Status+%1],1 jne .nogain cmp word[DSPMem+06h+%1*10h],0A0E0h je .nogain test byte[DSPMem+05h+%1*10h],80h jz near .gain2 cmp byte[Voice0State+%1],8 je .gain1 cmp byte[Voice0State+%1],2 jae near .gain2 .gain1 mov [DSPMem+05h+%1*10h],al ProcessGain %1 ; Normal ret .gain2 mov [DSPMem+05h+%1*10h],al cmp byte [Voice0State+%1],210 jne %%noendofsamp2 push eax push ebx mov al,%1 call VoiceStarter mov dword[Voice0EnvInc+%1*4],007FFFFFh pop ebx pop eax %%noendofsamp2 ProcessGain2 %1 ret %endmacro %macro VoiceAdsr2 1 test byte[MuteVoiceF],1 << %1 jnz near .noadsrswitch cmp byte[Voice0State+%1],200 je near .noadsrswitch cmp [DSPMem+06h+%1*10h],al je near .noadsrswitch mov [DSPMem+06h+%1*10h],al test byte[DSPMem+05h+%1*10h],80h jz near .noadsrswitch SwitchSustain %1 ret .noadsrswitch mov [DSPMem+06h+%1*10h],al ret %endmacro %macro VoiceGain 1 test byte[MuteVoiceF],1 << %1 jnz near .nogain cmp byte[Voice0State+%1],200 je near .nogain cmp [DSPMem+07h+%1*10h],al je near .nogain mov [DSPMem+07h+%1*10h],al cmp byte[Voice0Status+%1],1 jne .nogain test byte[DSPMem+05h+%1*10h],80h jz .gain .nogain mov [DSPMem+07h+%1*10h],al ret .gain cmp byte [Voice0State+%1],210 jne %%noendofsamp push eax push ebx mov al,%1 call VoiceStarter pop ebx pop eax %%noendofsamp ProcessGain2 %1 %endmacro NEWSYM ADSRGAINSwitch, db 0 ;Write DSP Registers functions NEWSYM WDSPReg00 ; Voice 0 Volume Left ; cmp byte[RevStereo],1 ; je .rev mov [DSPMem+00h],al ret .rev mov [DSPMem+01h],al ret NEWSYM WDSPReg01 ; Voice 0 Volume Right ; cmp byte[RevStereo],1 ; je .rev mov [DSPMem+01h],al ret .rev mov [DSPMem+00h],al ret NEWSYM WDSPReg02 ; Voice 0 Pitch Low mov [DSPMem+02h],al ret NEWSYM WDSPReg03 ; Voice 0 Pitch High mov [DSPMem+03h],al ret NEWSYM WDSPReg04 ; Voice 0 SCRN mov [DSPMem+04h],al ret NEWSYM TempValueSnd, db 0 NEWSYM WDSPReg05 ; Voice 0 ADSR (1) inc byte[TempValueSnd] VoiceAdsr 0 ret NEWSYM WDSPReg06 ; Voice 0 ADSR (2) inc byte[TempValueSnd] VoiceAdsr2 0 ret NEWSYM WDSPReg07 ; Voice 0 GAIN inc byte[TempValueSnd] VoiceGain 0 ret NEWSYM WDSPReg08 ; Voice 0 ENVX mov [DSPMem+08h],al ret NEWSYM WDSPReg09 ; Voice 0 OUTX mov [DSPMem+09h],al ret NEWSYM WDSPReg0A ; Voice 0 mov [DSPMem+0Ah],al ret NEWSYM WDSPReg0B ; Voice 0 mov [DSPMem+0Bh],al ret NEWSYM WDSPReg0C ; Voice 0 mov [DSPMem+0Ch],al push eax and eax,0FFh mov al,[VolumeTableb+eax] mov ah,[MusicVol] mov al,[VolumeConvTable+eax*2] mov [GlobalVL],al pop eax ret NEWSYM WDSPReg0D ; Echo Feedback mov [DSPMem+0Dh],al push eax and eax,0FFh mov al,[VolumeTableb+eax] mov [EchoFB],eax pop eax ret NEWSYM WDSPReg0E ; Voice 0 mov [DSPMem+0Eh],al ret NEWSYM WDSPReg0F ; Voice 0 Echo coefficient mov [DSPMem+0Fh],al push eax movsx eax,al mov [FIRTAPVal0],eax pop eax ret NEWSYM WDSPReg10 ; Voice 1 Volume Left mov [DSPMem+10h],al ret NEWSYM WDSPReg11 ; Voice 1 Volume Right mov [DSPMem+11h],al ret NEWSYM WDSPReg12 ; Voice 1 Pitch Low mov [DSPMem+012h],al ret NEWSYM WDSPReg13 ; Voice 1 Pitch High mov [DSPMem+013h],al ret NEWSYM WDSPReg14 ; Voice 1 SCRN mov [DSPMem+14h],al ret NEWSYM WDSPReg15 ; Voice 1 ADSR (1) VoiceAdsr 1 ret NEWSYM WDSPReg16 ; Voice 1 ADSR (2) VoiceAdsr2 1 ret NEWSYM WDSPReg17 ; Voice 1 GAIN VoiceGain 1 ret NEWSYM WDSPReg18 ; Voice 1 ENVX mov [DSPMem+018h],al ret NEWSYM WDSPReg19 ; Voice 1 OUTX mov [DSPMem+019h],al ret NEWSYM WDSPReg1A ; Voice 1 mov [DSPMem+01Ah],al ret NEWSYM WDSPReg1B ; Voice 1 mov [DSPMem+01Bh],al ret NEWSYM WDSPReg1C ; Voice 1 mov [DSPMem+01Ch],al push eax and eax,0FFh mov al,[VolumeTableb+eax] mov ah,[MusicVol] mov al,[VolumeConvTable+eax*2] mov [GlobalVR],al pop eax ret NEWSYM WDSPReg1D ; Voice 1 mov [DSPMem+01Dh],al ret NEWSYM WDSPReg1E ; Voice 1 mov [DSPMem+01Eh],al ret NEWSYM WDSPReg1F ; Voice 1 Echo coefficient mov [DSPMem+01Fh],al push eax movsx eax,al mov [FIRTAPVal1],eax pop eax ret NEWSYM WDSPReg20 ; Voice 2 Volume Left mov [DSPMem+20h],al ret NEWSYM WDSPReg21 ; Voice 2 Volume Right mov [DSPMem+21h],al ret NEWSYM WDSPReg22 ; Voice 2 Pitch Low mov [DSPMem+022h],al ret NEWSYM WDSPReg23 ; Voice 2 Pitch High mov [DSPMem+023h],al ret NEWSYM WDSPReg24 ; Voice 2 SCRN mov [DSPMem+24h],al ret NEWSYM WDSPReg25 ; Voice 2 ADSR (1) VoiceAdsr 2 ret NEWSYM WDSPReg26 ; Voice 2 ADSR (2) VoiceAdsr2 2 ret NEWSYM WDSPReg27 ; Voice 2 GAIN VoiceGain 2 ret NEWSYM WDSPReg28 ; Voice 2 ENVX mov [DSPMem+028h],al ret NEWSYM WDSPReg29 ; Voice 2 OUTX mov [DSPMem+029h],al ret NEWSYM WDSPReg2A ; Voice 2 mov [DSPMem+02Ah],al ret NEWSYM WDSPReg2B ; Voice 2 mov [DSPMem+02Bh],al ret NEWSYM WDSPReg2C ; Voice 2 mov [DSPMem+02Ch],al push eax and eax,0FFh mov al,[VolumeTableb+eax] mov ah,[MusicVol] mov al,[VolumeConvTable+eax*2] mov [EchoVL],al pop eax ret NEWSYM WDSPReg2D ; Voice 2 mov [DSPMem+02Dh],al ret NEWSYM WDSPReg2E ; Voice 2 mov [DSPMem+02Eh],al ret NEWSYM WDSPReg2F ; Voice 2 Echo coefficient mov [DSPMem+02Fh],al push eax movsx eax,al mov [FIRTAPVal2],eax pop eax ret NEWSYM WDSPReg30 ; Voice 3 Volume Left mov [DSPMem+30h],al ret NEWSYM WDSPReg31 ; Voice 3 Volume Right mov [DSPMem+31h],al ret NEWSYM WDSPReg32 ; Voice 3 Pitch Low mov [DSPMem+032h],al ret NEWSYM WDSPReg33 ; Voice 3 Pitch High mov [DSPMem+033h],al ret NEWSYM WDSPReg34 ; Voice 3 SCRN mov [DSPMem+34h],al ret NEWSYM WDSPReg35 ; Voice 3 ADSR (1) VoiceAdsr 3 ret NEWSYM WDSPReg36 ; Voice 3 ADSR (2) VoiceAdsr2 3 ret NEWSYM WDSPReg37 ; Voice 3 GAIN VoiceGain 3 ret NEWSYM WDSPReg38 ; Voice 3 ENVX mov [DSPMem+038h],al ret NEWSYM WDSPReg39 ; Voice 3 OUTX mov [DSPMem+039h],al ret NEWSYM WDSPReg3A ; Voice 3 mov [DSPMem+03Ah],al ret NEWSYM WDSPReg3B ; Voice 3 mov [DSPMem+03Bh],al ret NEWSYM WDSPReg3C ; Voice 3 mov [DSPMem+03Ch],al push eax and eax,0FFh mov al,[VolumeTableb+eax] mov ah,[MusicVol] mov al,[VolumeConvTable+eax*2] mov [EchoVR],al pop eax ret NEWSYM WDSPReg3D ; Voice 3 mov byte [Voice0Noise],0 mov byte [Voice1Noise],0 mov byte [Voice2Noise],0 mov byte [Voice3Noise],0 mov byte [Voice4Noise],0 mov byte [Voice5Noise],0 mov byte [Voice6Noise],0 mov byte [Voice7Noise],0 test al,1 jz .TestVoice1 mov byte [Voice0Noise],1 .TestVoice1 test al,2 jz .TestVoice2 mov byte [Voice1Noise],1 .TestVoice2 test al,4 jz .TestVoice3 mov byte [Voice2Noise],1 .TestVoice3 test al,8 jz .TestVoice4 mov byte [Voice3Noise],1 .TestVoice4 test al,16 jz .TestVoice5 mov byte [Voice4Noise],1 .TestVoice5 test al,32 jz .TestVoice6 mov byte [Voice5Noise],1 .TestVoice6 test al,64 jz .TestVoice7 mov byte [Voice6Noise],1 .TestVoice7 test al,128 jz .TestVoice8 mov byte [Voice7Noise],1 .TestVoice8 mov [DSPMem+03Dh],al ret NEWSYM WDSPReg3E ; Voice 3 mov [DSPMem+03Eh],al ret NEWSYM WDSPReg3F ; Voice 3 Echo coefficient mov [DSPMem+03Fh],al push eax movsx eax,al mov [FIRTAPVal3],eax pop eax ret NEWSYM WDSPReg40 ; Voice 4 Volume Left mov [DSPMem+40h],al ret NEWSYM WDSPReg41 ; Voice 4 Volume Right mov [DSPMem+41h],al ret NEWSYM WDSPReg42 ; Voice 4 Pitch Low mov [DSPMem+042h],al ret NEWSYM WDSPReg43 ; Voice 4 Pitch High mov [DSPMem+043h],al ret NEWSYM WDSPReg44 ; Voice 4 SCRN mov [DSPMem+44h],al ret NEWSYM WDSPReg45 ; Voice 4 ADSR (1) VoiceAdsr 4 ret NEWSYM WDSPReg46 ; Voice 4 ADSR (2) VoiceAdsr2 4 ret NEWSYM WDSPReg47 ; Voice 4 GAIN VoiceGain 4 ret NEWSYM WDSPReg48 ; Voice 4 ENVX mov [DSPMem+048h],al ret NEWSYM WDSPReg49 ; Voice 4 OUTX mov [DSPMem+049h],al ret NEWSYM WDSPReg4A ; Voice 4 mov [DSPMem+04Ah],al ret NEWSYM WDSPReg4B ; Voice 4 mov [DSPMem+04Bh],al ret NEWSYM WDSPReg4C ; Key On push ebx mov bl,[MuteVoiceF] xor bl,0FFh and bl,al xor byte [DSPMem+05Ch],0FFh jnz .notzero and bl,[DSPMem+05Ch] .notzero xor byte [DSPMem+05Ch],0FFh or byte[KeyOnStA],bl pop ebx test al,80h jz .nokon inc byte[SoundTest] .nokon mov [DSPMem+04Ch],al push eax xor al,0FFh and byte [DSPMem+07Ch],al pop eax ret NEWSYM ProcessKeyOn test al,1 jz .TestVoice1 push edx call Voice0Start pop edx .TestVoice1 test al,2 jz .TestVoice2 push edx call Voice1Start pop edx .TestVoice2 test al,4 jz .TestVoice3 push edx call Voice2Start pop edx .TestVoice3 test al,8 jz .TestVoice4 push edx call Voice3Start pop edx .TestVoice4 test al,16 jz .TestVoice5 push edx call Voice4Start pop edx .TestVoice5 test al,32 jz .TestVoice6 push edx call Voice5Start pop edx .TestVoice6 test al,64 jz .TestVoice7 push edx call Voice6Start pop edx .TestVoice7 test al,128 jz .TestVoice8 push edx call Voice7Start pop edx .TestVoice8 test al,0FFh jz .novoice mov byte[keyonsn],1 .novoice ret NEWSYM WDSPReg4D ; Voice 4 mov [DSPMem+04Dh],al ret NEWSYM WDSPReg4E ; Voice 4 mov [DSPMem+04Eh],al ret NEWSYM WDSPReg4F ; Voice 4 Echo coefficient mov [DSPMem+04Fh],al push eax movsx eax,al mov [FIRTAPVal4],eax pop eax ret NEWSYM WDSPReg50 ; Voice 5 Volume Left mov [DSPMem+50h],al ret NEWSYM WDSPReg51 ; Voice 5 Volume Right mov [DSPMem+51h],al ret NEWSYM WDSPReg52 ; Voice 5 Pitch Low mov [DSPMem+052h],al ret NEWSYM WDSPReg53 ; Voice 5 Pitch High mov [DSPMem+053h],al ret NEWSYM WDSPReg54 ; Voice 5 SCRN mov [DSPMem+54h],al ret NEWSYM WDSPReg55 ; Voice 5 ADSR (1) VoiceAdsr 5 ret NEWSYM WDSPReg56 ; Voice 5 ADSR (2) VoiceAdsr2 5 ret NEWSYM WDSPReg57 ; Voice 5 GAIN VoiceGain 5 ret NEWSYM WDSPReg58 ; Voice 5 ENVX mov [DSPMem+058h],al ret NEWSYM WDSPReg59 ; Voice 5 OUTX mov [DSPMem+059h],al ret NEWSYM WDSPReg5A ; Voice 5 mov [DSPMem+05Ah],al ret NEWSYM WDSPReg5B ; Voice 5 mov [DSPMem+05Bh],al ret %macro keyoffm 1 test byte[MuteVoiceF],1 << %1 jnz %%nokeyoff push eax push edx push ebx mov dword[Voice0Time+%1*4],255 mov eax,[Voice0EnvInc+%1*4] shr eax,8 neg eax mov dword[Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],200 mov byte [DSPMem+08h+%1*10h],0 or byte [DSPMem+7Ch],1 << %1 pop ebx pop edx pop eax %%nokeyoff %endmacro NEWSYM WDSPReg5C ; Key Off push eax xor al,0FFh and byte[KeyOnStA],al and byte[KeyOnStB],al pop eax test al,1 jz .TestVoice1 keyoffm 0 .TestVoice1 test al,2 jz .TestVoice2 keyoffm 1 .TestVoice2 test al,4 jz .TestVoice3 keyoffm 2 .TestVoice3 test al,8 jz .TestVoice4 keyoffm 3 .TestVoice4 test al,16 jz .TestVoice5 keyoffm 4 .TestVoice5 test al,32 jz .TestVoice6 keyoffm 5 .TestVoice6 test al,64 jz .TestVoice7 keyoffm 6 .TestVoice7 test al,128 jz .TestVoice8 keyoffm 7 .TestVoice8 mov [DSPMem+05Ch],al ret NEWSYM WDSPReg5D ; Voice 5 mov [DSPMem+05Dh],al ret NEWSYM WDSPReg5E ; Voice 5 mov [DSPMem+05Eh],al ret NEWSYM WDSPReg5F ; Voice 5 Echo coefficient mov [DSPMem+05Fh],al push eax movsx eax,al mov [FIRTAPVal5],eax pop eax ret NEWSYM WDSPReg60 ; Voice 6 Volume Left mov [DSPMem+60h],al ret NEWSYM WDSPReg61 ; Voice 6 Volume Right mov [DSPMem+61h],al ret NEWSYM WDSPReg62 ; Voice 6 Pitch Low mov [DSPMem+062h],al ret NEWSYM WDSPReg63 ; Voice 6 Pitch High mov [DSPMem+063h],al ret NEWSYM WDSPReg64 ; Voice 6 SCRN mov [DSPMem+64h],al ret NEWSYM WDSPReg65 ; Voice 6 ADSR (1) VoiceAdsr 6 ret NEWSYM WDSPReg66 ; Voice 6 ADSR (2) VoiceAdsr2 6 ret NEWSYM WDSPReg67 ; Voice 6 GAIN VoiceGain 6 ret NEWSYM WDSPReg68 ; Voice 6 ENVX mov [DSPMem+068h],al ret NEWSYM WDSPReg69 ; Voice 6 OUTX mov [DSPMem+069h],al ret NEWSYM WDSPReg6A ; Voice 6 mov [DSPMem+06Ah],al ret NEWSYM WDSPReg6B ; Voice 6 mov [DSPMem+06Bh],al ret spcres db 0 NEWSYM WDSPReg6C ; Voice 6 mov [DSPMem+06Ch],al and byte [DSPMem+06Ch],7Fh test al,128 jz .NoRes inc byte[spcres] .NoRes test al,0C0h jz .NoRes2 mov byte[Voice0Status],0 mov byte[Voice1Status],0 mov byte[Voice2Status],0 mov byte[Voice3Status],0 mov byte[Voice4Status],0 mov byte[Voice5Status],0 mov byte[Voice6Status],0 mov byte[Voice7Status],0 .NoRes2 push eax push ebx push ecx push edx and eax,1Fh xor edx,edx mov eax,[NoiseSpeeds+eax*4] mov ebx,[SBToSPC] shl eax,16 div ebx shl eax,2 mov [NoiseInc],eax pop edx pop ecx pop ebx pop eax ret NEWSYM WDSPReg6D ; Voice 6 mov [DSPMem+06Dh],al ret NEWSYM WDSPReg6E ; Voice 6 mov [DSPMem+06Eh],al ret NEWSYM WDSPReg6F ; Voice 6 Echo coefficient mov [DSPMem+06Fh],al push eax movsx eax,al mov [FIRTAPVal6],eax pop eax ret NEWSYM WDSPReg70 ; Voice 7 Volume Left mov [DSPMem+70h],al ret NEWSYM WDSPReg71 ; Voice 7 Volume Right mov [DSPMem+71h],al ret NEWSYM WDSPReg72 ; Voice 7 Pitch Low mov [DSPMem+072h],al ret NEWSYM WDSPReg73 ; Voice 7 Pitch High mov [DSPMem+073h],al ret NEWSYM WDSPReg74 ; Voice 7 SCRN mov [DSPMem+74h],al ret NEWSYM WDSPReg75 ; Voice 7 ADSR (1) VoiceAdsr 7 ret NEWSYM WDSPReg76 ; Voice 7 ADSR (2) VoiceAdsr2 7 ret NEWSYM WDSPReg77 ; Voice 7 GAIN VoiceGain 7 ret NEWSYM WDSPReg78 ; Voice 7 ENVX mov [DSPMem+078h],al ret NEWSYM WDSPReg79 ; Voice 7 OUTX mov [DSPMem+079h],al ret NEWSYM WDSPReg7A ; Voice 7 mov [DSPMem+07Ah],al ret NEWSYM WDSPReg7B ; Voice 7 mov [DSPMem+07Bh],al ret NEWSYM WDSPReg7C ; ENDX mov byte [DSPMem+07Ch],0 ret NEWSYM WDSPReg7D ; Echo Delay mov [DSPMem+07Dh],al push ebx mov ebx,eax and ebx,0Fh mov ebx,[EchoRate+ebx*4] mov [MaxEcho],ebx pop ebx ret NEWSYM WDSPReg7E ; Voice 7 mov [DSPMem+07Eh],al ret NEWSYM WDSPReg7F ; Voice 7 Echo coefficient mov [DSPMem+07Fh],al push eax movsx eax,al mov [FIRTAPVal7],eax pop eax ret NEWSYM WDSPReg80 ; mov [DSPMem+080h],al ret NEWSYM WDSPReg81 ; mov [DSPMem+081h],al ret NEWSYM WDSPReg82 ; mov [DSPMem+082h],al ret NEWSYM WDSPReg83 ; mov [DSPMem+083h],al ret NEWSYM WDSPReg84 ; mov [DSPMem+084h],al ret NEWSYM WDSPReg85 ; mov [DSPMem+085h],al ret NEWSYM WDSPReg86 ; mov [DSPMem+086h],al ret NEWSYM WDSPReg87 ; mov [DSPMem+087h],al ret NEWSYM WDSPReg88 ; mov [DSPMem+088h],al ret NEWSYM WDSPReg89 ; mov [DSPMem+089h],al ret NEWSYM WDSPReg8A ; mov [DSPMem+08Ah],al ret NEWSYM WDSPReg8B ; mov [DSPMem+08Bh],al ret NEWSYM WDSPReg8C ; mov [DSPMem+08Ch],al ret NEWSYM WDSPReg8D ; mov [DSPMem+08Dh],al ret NEWSYM WDSPReg8E ; mov [DSPMem+08Eh],al ret NEWSYM WDSPReg8F ; mov [DSPMem+08Fh],al ret NEWSYM WDSPReg90 ; mov [DSPMem+090h],al ret NEWSYM WDSPReg91 ; mov [DSPMem+091h],al ret NEWSYM WDSPReg92 ; mov [DSPMem+092h],al ret NEWSYM WDSPReg93 ; mov [DSPMem+093h],al ret NEWSYM WDSPReg94 ; mov [DSPMem+094h],al ret NEWSYM WDSPReg95 ; mov [DSPMem+095h],al ret NEWSYM WDSPReg96 ; mov [DSPMem+096h],al ret NEWSYM WDSPReg97 ; mov [DSPMem+097h],al ret NEWSYM WDSPReg98 ; mov [DSPMem+098h],al ret NEWSYM WDSPReg99 ; mov [DSPMem+099h],al ret NEWSYM WDSPReg9A ; mov [DSPMem+09Ah],al ret NEWSYM WDSPReg9B ; mov [DSPMem+09Bh],al ret NEWSYM WDSPReg9C ; mov [DSPMem+09Ch],al ret NEWSYM WDSPReg9D ; mov [DSPMem+09Dh],al ret NEWSYM WDSPReg9E ; mov [DSPMem+09Eh],al ret NEWSYM WDSPReg9F ; mov [DSPMem+09Fh],al ret NEWSYM WDSPRegA0 ; mov [DSPMem+0A0h],al ret NEWSYM WDSPRegA1 ; mov [DSPMem+0A1h],al ret NEWSYM WDSPRegA2 ; mov [DSPMem+0A2h],al ret NEWSYM WDSPRegA3 ; mov [DSPMem+0A3h],al ret NEWSYM WDSPRegA4 ; mov [DSPMem+0A4h],al ret NEWSYM WDSPRegA5 ; mov [DSPMem+0A5h],al ret NEWSYM WDSPRegA6 ; mov [DSPMem+0A6h],al ret NEWSYM WDSPRegA7 ; mov [DSPMem+0A7h],al ret NEWSYM WDSPRegA8 ; mov [DSPMem+0A8h],al ret NEWSYM WDSPRegA9 ; mov [DSPMem+0A9h],al ret NEWSYM WDSPRegAA ; mov [DSPMem+0AAh],al ret NEWSYM WDSPRegAB ; mov [DSPMem+0ABh],al ret NEWSYM WDSPRegAC ; mov [DSPMem+0ACh],al ret NEWSYM WDSPRegAD ; mov [DSPMem+0ADh],al ret NEWSYM WDSPRegAE ; mov [DSPMem+0AEh],al ret NEWSYM WDSPRegAF ; mov [DSPMem+0AFh],al ret NEWSYM WDSPRegB0 ; mov [DSPMem+0B0h],al ret NEWSYM WDSPRegB1 ; mov [DSPMem+0B1h],al ret NEWSYM WDSPRegB2 ; mov [DSPMem+0B2h],al ret NEWSYM WDSPRegB3 ; mov [DSPMem+0B3h],al ret NEWSYM WDSPRegB4 ; mov [DSPMem+0B4h],al ret NEWSYM WDSPRegB5 ; mov [DSPMem+0B5h],al ret NEWSYM WDSPRegB6 ; mov [DSPMem+0B6h],al ret NEWSYM WDSPRegB7 ; mov [DSPMem+0B7h],al ret NEWSYM WDSPRegB8 ; mov [DSPMem+0B8h],al ret NEWSYM WDSPRegB9 ; mov [DSPMem+0B9h],al ret NEWSYM WDSPRegBA ; mov [DSPMem+0BAh],al ret NEWSYM WDSPRegBB ; mov [DSPMem+0BBh],al ret NEWSYM WDSPRegBC ; mov [DSPMem+0BCh],al ret NEWSYM WDSPRegBD ; mov [DSPMem+0BDh],al ret NEWSYM WDSPRegBE ; mov [DSPMem+0BEh],al ret NEWSYM WDSPRegBF ; mov [DSPMem+0BFh],al ret NEWSYM WDSPRegC0 ; mov [DSPMem+0C0h],al ret NEWSYM WDSPRegC1 ; mov [DSPMem+0C1h],al ret NEWSYM WDSPRegC2 ; mov [DSPMem+0C2h],al ret NEWSYM WDSPRegC3 ; mov [DSPMem+0C3h],al ret NEWSYM WDSPRegC4 ; mov [DSPMem+0C4h],al ret NEWSYM WDSPRegC5 ; mov [DSPMem+0C5h],al ret NEWSYM WDSPRegC6 ; mov [DSPMem+0C6h],al ret NEWSYM WDSPRegC7 ; mov [DSPMem+0C7h],al ret NEWSYM WDSPRegC8 ; mov [DSPMem+0C8h],al ret NEWSYM WDSPRegC9 ; mov [DSPMem+0C9h],al ret NEWSYM WDSPRegCA ; mov [DSPMem+0CAh],al ret NEWSYM WDSPRegCB ; mov [DSPMem+0CBh],al ret NEWSYM WDSPRegCC ; mov [DSPMem+0CCh],al ret NEWSYM WDSPRegCD ; mov [DSPMem+0CDh],al ret NEWSYM WDSPRegCE ; mov [DSPMem+0CEh],al ret NEWSYM WDSPRegCF ; mov [DSPMem+0CFh],al ret NEWSYM WDSPRegD0 ; mov [DSPMem+0D0h],al ret NEWSYM WDSPRegD1 ; mov [DSPMem+0D1h],al ret NEWSYM WDSPRegD2 ; mov [DSPMem+0D2h],al ret NEWSYM WDSPRegD3 ; mov [DSPMem+0D3h],al ret NEWSYM WDSPRegD4 ; mov [DSPMem+0D4h],al ret NEWSYM WDSPRegD5 ; mov [DSPMem+0D5h],al ret NEWSYM WDSPRegD6 ; mov [DSPMem+0D6h],al ret NEWSYM WDSPRegD7 ; mov [DSPMem+0D7h],al ret NEWSYM WDSPRegD8 ; mov [DSPMem+0D8h],al ret NEWSYM WDSPRegD9 ; mov [DSPMem+0D9h],al ret NEWSYM WDSPRegDA ; mov [DSPMem+0DAh],al ret NEWSYM WDSPRegDB ; mov [DSPMem+0DBh],al ret NEWSYM WDSPRegDC ; mov [DSPMem+0DCh],al ret NEWSYM WDSPRegDD ; mov [DSPMem+0DDh],al ret NEWSYM WDSPRegDE ; mov [DSPMem+0DEh],al ret NEWSYM WDSPRegDF ; mov [DSPMem+0DFh],al ret NEWSYM WDSPRegE0 ; mov [DSPMem+0E0h],al ret NEWSYM WDSPRegE1 ; mov [DSPMem+0E1h],al ret NEWSYM WDSPRegE2 ; mov [DSPMem+0E2h],al ret NEWSYM WDSPRegE3 ; mov [DSPMem+0E3h],al ret NEWSYM WDSPRegE4 ; mov [DSPMem+0E4h],al ret NEWSYM WDSPRegE5 ; mov [DSPMem+0E5h],al ret NEWSYM WDSPRegE6 ; mov [DSPMem+0E6h],al ret NEWSYM WDSPRegE7 ; mov [DSPMem+0E7h],al ret NEWSYM WDSPRegE8 ; mov [DSPMem+0E8h],al ret NEWSYM WDSPRegE9 ; mov [DSPMem+0E9h],al ret NEWSYM WDSPRegEA ; mov [DSPMem+0EAh],al ret NEWSYM WDSPRegEB ; mov [DSPMem+0EBh],al ret NEWSYM WDSPRegEC ; mov [DSPMem+0ECh],al ret NEWSYM WDSPRegED ; mov [DSPMem+0EDh],al ret NEWSYM WDSPRegEE ; mov [DSPMem+0EEh],al ret NEWSYM WDSPRegEF ; mov [DSPMem+0EFh],al ret NEWSYM WDSPRegF0 ; mov [DSPMem+0F0h],al ret NEWSYM WDSPRegF1 ; mov [DSPMem+0F1h],al ret NEWSYM WDSPRegF2 ; mov [DSPMem+0F2h],al ret NEWSYM WDSPRegF3 ; mov [DSPMem+0F3h],al ret NEWSYM WDSPRegF4 ; mov [DSPMem+0F4h],al ret NEWSYM WDSPRegF5 ; mov [DSPMem+0F5h],al ret NEWSYM WDSPRegF6 ; mov [DSPMem+0F6h],al ret NEWSYM WDSPRegF7 ; mov [DSPMem+0F7h],al ret NEWSYM WDSPRegF8 ; mov [DSPMem+0F8h],al ret NEWSYM WDSPRegF9 ; mov [DSPMem+0F9h],al ret NEWSYM WDSPRegFA ; mov [DSPMem+0FAh],al ret NEWSYM WDSPRegFB ; mov [DSPMem+0FBh],al ret NEWSYM WDSPRegFC ; mov [DSPMem+0FCh],al ret NEWSYM WDSPRegFD ; mov [DSPMem+0FDh],al ret NEWSYM WDSPRegFE ; mov [DSPMem+0FEh],al ret NEWSYM WDSPRegFF ; mov [DSPMem+0FFh],al ret NEWSYM DspAsmEnd zsnes-1.36/src/cpu/dspproc.asm0100644000175000017500000052373207514702751015742 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM spcRam, spcPCRam, spcRamDP, spcS, spcX, MovieProcessing EXTSYM CNetType, soundon, RevStereo EXTSYM PitchModEn,SoundNoiseDis EXTSYM DosExit,Invalidopcode,RSPCRegF0,RSPCRegF1,RSPCRegF2,RSPCRegF3 EXTSYM RSPCRegF4,RSPCRegF5,RSPCRegF6,RSPCRegF7,RSPCRegF8,RSPCRegF9 EXTSYM RSPCRegFA,RSPCRegFB,RSPCRegFC,RSPCRegFD,RSPCRegFE,RSPCRegFF EXTSYM SPCRegF0,SPCRegF1,SPCRegF2,SPCRegF3,SPCRegF4,SPCRegF5,SPCRegF6 EXTSYM SPCRegF7,SPCRegF8,SPCRegF9,SPCRegFA,SPCRegFB,SPCRegFC,SPCRegFD EXTSYM SPCRegFE,SPCRegFF,VolumeConvTable,dspRptr,dspWptr,opcjmptab EXTSYM Op00,Op01,Op02,Op03,Op04,Op05,Op06,Op07,Op08,Op09,Op0A,Op0B EXTSYM Op0C,Op0D,Op0E,Op0F,Op10,Op11,Op12,Op13,Op14,Op15,Op16,Op17 EXTSYM Op18,Op19,Op1A,Op1B,Op1C,Op1D,Op1E,Op1F,Op20,Op21,Op22,Op23 EXTSYM Op24,Op25,Op26,Op27,Op28,Op29,Op2A,Op2B,Op2C,Op2D,Op2E,Op2F EXTSYM Op30,Op31,Op32,Op33,Op34,Op35,Op36,Op37,Op38,Op39,Op3A,Op3B EXTSYM Op3C,Op3D,Op3E,Op3F,Op40,Op41,Op42,Op43,Op44,Op45,Op46,Op47 EXTSYM Op48,Op49,Op4A,Op4B,Op4C,Op4D,Op4E,Op4F,Op50,Op51,Op52,Op53 EXTSYM Op54,Op55,Op56,Op57,Op58,Op59,Op5A,Op5B,Op5C,Op5D,Op5E,Op5F EXTSYM Op60,Op61,Op62,Op63,Op64,Op65,Op66,Op67,Op68,Op69,Op6A,Op6B EXTSYM Op6C,Op6D,Op6E,Op6F,Op70,Op71,Op72,Op73,Op74,Op75,Op76,Op77 EXTSYM Op78,Op79,Op7A,Op7B,Op7C,Op7D,Op7E,Op7F,Op80,Op81,Op82,Op83 EXTSYM Op84,Op85,Op86,Op87,Op88,Op89,Op8A,Op8B,Op8C,Op8D,Op8E,Op8F EXTSYM Op90,Op91,Op92,Op93,Op94,Op95,Op96,Op97,Op98,Op99,Op9A,Op9B EXTSYM Op9C,Op9D,Op9E,Op9F,OpA0,OpA1,OpA2,OpA3,OpA4,OpA5,OpA6,OpA7 EXTSYM OpA8,OpA9,OpAA,OpAB,OpAC,OpAD,OpAE,OpAF,OpB0,OpB1,OpB2,OpB3 EXTSYM OpB4,OpB5,OpB6,OpB7,OpB8,OpB9,OpBA,OpBB,OpBC,OpBD,OpBE,OpBF EXTSYM OpC0,OpC1,OpC2,OpC3,OpC4,OpC5,OpC6,OpC7,OpC8,OpC9,OpCA,OpCB EXTSYM OpCC,OpCD,OpCE,OpCF,OpD0,OpD1,OpD2,OpD3,OpD4,OpD5,OpD6,OpD7 EXTSYM OpD8,OpD9,OpDA,OpDB,OpDC,OpDD,OpDE,OpDF,OpE0,OpE1,OpE2,OpE3 EXTSYM OpE4,OpE5,OpE6,OpE7,OpE8,OpE9,OpEA,OpEB,OpEC,OpED,OpEE,OpEF EXTSYM OpF0,OpF1,OpF2,OpF3,OpF4,OpF5,OpF6,OpF7,OpF8,OpF9,OpFA,OpFB EXTSYM OpFC,OpFD,OpFE,OpFF EXTSYM RDSPReg00,RDSPReg01,RDSPReg02,RDSPReg03,RDSPReg04,RDSPReg05,RDSPReg06 EXTSYM RDSPReg07,RDSPReg08,RDSPReg09,RDSPReg0A,RDSPReg0B,RDSPReg0C,RDSPReg0D EXTSYM RDSPReg0E,RDSPReg0F,RDSPReg10,RDSPReg11,RDSPReg12,RDSPReg13,RDSPReg14 EXTSYM RDSPReg15,RDSPReg16,RDSPReg17,RDSPReg18,RDSPReg19,RDSPReg1A,RDSPReg1B EXTSYM RDSPReg1C,RDSPReg1D,RDSPReg1E,RDSPReg1F,RDSPReg20,RDSPReg21,RDSPReg22 EXTSYM RDSPReg23,RDSPReg24,RDSPReg25,RDSPReg26,RDSPReg27,RDSPReg28,RDSPReg29 EXTSYM RDSPReg2A,RDSPReg2B,RDSPReg2C,RDSPReg2D,RDSPReg2E,RDSPReg2F,RDSPReg30 EXTSYM RDSPReg31,RDSPReg32,RDSPReg33,RDSPReg34,RDSPReg35,RDSPReg36,RDSPReg37 EXTSYM RDSPReg38,RDSPReg39,RDSPReg3A,RDSPReg3B,RDSPReg3C,RDSPReg3D,RDSPReg3E EXTSYM RDSPReg3F,RDSPReg40,RDSPReg41,RDSPReg42,RDSPReg43,RDSPReg44,RDSPReg45 EXTSYM RDSPReg46,RDSPReg47,RDSPReg48,RDSPReg49,RDSPReg4A,RDSPReg4B,RDSPReg4C EXTSYM RDSPReg4D,RDSPReg4E,RDSPReg4F,RDSPReg50,RDSPReg51,RDSPReg52,RDSPReg53 EXTSYM RDSPReg54,RDSPReg55,RDSPReg56,RDSPReg57,RDSPReg58,RDSPReg59,RDSPReg5A EXTSYM RDSPReg5B,RDSPReg5C,RDSPReg5D,RDSPReg5E,RDSPReg5F,RDSPReg60,RDSPReg61 EXTSYM RDSPReg62,RDSPReg63,RDSPReg64,RDSPReg65,RDSPReg66,RDSPReg67,RDSPReg68 EXTSYM RDSPReg69,RDSPReg6A,RDSPReg6B,RDSPReg6C,RDSPReg6D,RDSPReg6E,RDSPReg6F EXTSYM RDSPReg70,RDSPReg71,RDSPReg72,RDSPReg73,RDSPReg74,RDSPReg75,RDSPReg76 EXTSYM RDSPReg77,RDSPReg78,RDSPReg79,RDSPReg7A,RDSPReg7B,RDSPReg7C,RDSPReg7D EXTSYM RDSPReg7E,RDSPReg7F,RDSPReg80,RDSPReg81,RDSPReg82,RDSPReg83,RDSPReg84 EXTSYM RDSPReg85,RDSPReg86,RDSPReg87,RDSPReg88,RDSPReg89,RDSPReg8A,RDSPReg8B EXTSYM RDSPReg8C,RDSPReg8D,RDSPReg8E,RDSPReg8F,RDSPReg90,RDSPReg91,RDSPReg92 EXTSYM RDSPReg93,RDSPReg94,RDSPReg95,RDSPReg96,RDSPReg97,RDSPReg98,RDSPReg99 EXTSYM RDSPReg9A,RDSPReg9B,RDSPReg9C,RDSPReg9D,RDSPReg9E,RDSPReg9F,RDSPRegA0 EXTSYM RDSPRegA1,RDSPRegA2,RDSPRegA3,RDSPRegA4,RDSPRegA5,RDSPRegA6,RDSPRegA7 EXTSYM RDSPRegA8,RDSPRegA9,RDSPRegAA,RDSPRegAB,RDSPRegAC,RDSPRegAD,RDSPRegAE EXTSYM RDSPRegAF,RDSPRegB0,RDSPRegB1,RDSPRegB2,RDSPRegB3,RDSPRegB4,RDSPRegB5 EXTSYM RDSPRegB6,RDSPRegB7,RDSPRegB8,RDSPRegB9,RDSPRegBA,RDSPRegBB,RDSPRegBC EXTSYM RDSPRegBD,RDSPRegBE,RDSPRegBF,RDSPRegC0,RDSPRegC1,RDSPRegC2,RDSPRegC3 EXTSYM RDSPRegC4,RDSPRegC5,RDSPRegC6,RDSPRegC7,RDSPRegC8,RDSPRegC9,RDSPRegCA EXTSYM RDSPRegCB,RDSPRegCC,RDSPRegCD,RDSPRegCE,RDSPRegCF,RDSPRegD0,RDSPRegD1 EXTSYM RDSPRegD2,RDSPRegD3,RDSPRegD4,RDSPRegD5,RDSPRegD6,RDSPRegD7,RDSPRegD8 EXTSYM RDSPRegD9,RDSPRegDA,RDSPRegDB,RDSPRegDC,RDSPRegDD,RDSPRegDE,RDSPRegDF EXTSYM RDSPRegE0,RDSPRegE1,RDSPRegE2,RDSPRegE3,RDSPRegE4,RDSPRegE5,RDSPRegE6 EXTSYM RDSPRegE7,RDSPRegE8,RDSPRegE9,RDSPRegEA,RDSPRegEB,RDSPRegEC,RDSPRegED EXTSYM RDSPRegEE,RDSPRegEF,RDSPRegF0,RDSPRegF1,RDSPRegF2,RDSPRegF3,RDSPRegF4 EXTSYM RDSPRegF5,RDSPRegF6,RDSPRegF7,RDSPRegF8,RDSPRegF9,RDSPRegFA,RDSPRegFB EXTSYM RDSPRegFC,RDSPRegFD,RDSPRegFE,RDSPRegFF EXTSYM WDSPReg00,WDSPReg01,WDSPReg02,WDSPReg03,WDSPReg04,WDSPReg05,WDSPReg06 EXTSYM WDSPReg07,WDSPReg08,WDSPReg09,WDSPReg0A,WDSPReg0B,WDSPReg0C,WDSPReg0D EXTSYM WDSPReg0E,WDSPReg0F,WDSPReg10,WDSPReg11,WDSPReg12,WDSPReg13,WDSPReg14 EXTSYM WDSPReg15,WDSPReg16,WDSPReg17,WDSPReg18,WDSPReg19,WDSPReg1A,WDSPReg1B EXTSYM WDSPReg1C,WDSPReg1D,WDSPReg1E,WDSPReg1F,WDSPReg20,WDSPReg21,WDSPReg22 EXTSYM WDSPReg23,WDSPReg24,WDSPReg25,WDSPReg26,WDSPReg27,WDSPReg28,WDSPReg29 EXTSYM WDSPReg2A,WDSPReg2B,WDSPReg2C,WDSPReg2D,WDSPReg2E,WDSPReg2F,WDSPReg30 EXTSYM WDSPReg31,WDSPReg32,WDSPReg33,WDSPReg34,WDSPReg35,WDSPReg36,WDSPReg37 EXTSYM WDSPReg38,WDSPReg39,WDSPReg3A,WDSPReg3B,WDSPReg3C,WDSPReg3D,WDSPReg3E EXTSYM WDSPReg3F,WDSPReg40,WDSPReg41,WDSPReg42,WDSPReg43,WDSPReg44,WDSPReg45 EXTSYM WDSPReg46,WDSPReg47,WDSPReg48,WDSPReg49,WDSPReg4A,WDSPReg4B,WDSPReg4C EXTSYM WDSPReg4D,WDSPReg4E,WDSPReg4F,WDSPReg50,WDSPReg51,WDSPReg52,WDSPReg53 EXTSYM WDSPReg54,WDSPReg55,WDSPReg56,WDSPReg57,WDSPReg58,WDSPReg59,WDSPReg5A EXTSYM WDSPReg5B,WDSPReg5C,WDSPReg5D,WDSPReg5E,WDSPReg5F,WDSPReg60,WDSPReg61 EXTSYM WDSPReg62,WDSPReg63,WDSPReg64,WDSPReg65,WDSPReg66,WDSPReg67,WDSPReg68 EXTSYM WDSPReg69,WDSPReg6A,WDSPReg6B,WDSPReg6C,WDSPReg6D,WDSPReg6E,WDSPReg6F EXTSYM WDSPReg70,WDSPReg71,WDSPReg72,WDSPReg73,WDSPReg74,WDSPReg75,WDSPReg76 EXTSYM WDSPReg77,WDSPReg78,WDSPReg79,WDSPReg7A,WDSPReg7B,WDSPReg7C,WDSPReg7D EXTSYM WDSPReg7E,WDSPReg7F,WDSPReg80,WDSPReg81,WDSPReg82,WDSPReg83,WDSPReg84 EXTSYM WDSPReg85,WDSPReg86,WDSPReg87,WDSPReg88,WDSPReg89,WDSPReg8A,WDSPReg8B EXTSYM WDSPReg8C,WDSPReg8D,WDSPReg8E,WDSPReg8F,WDSPReg90,WDSPReg91,WDSPReg92 EXTSYM WDSPReg93,WDSPReg94,WDSPReg95,WDSPReg96,WDSPReg97,WDSPReg98,WDSPReg99 EXTSYM WDSPReg9A,WDSPReg9B,WDSPReg9C,WDSPReg9D,WDSPReg9E,WDSPReg9F,WDSPRegA0 EXTSYM WDSPRegA1,WDSPRegA2,WDSPRegA3,WDSPRegA4,WDSPRegA5,WDSPRegA6,WDSPRegA7 EXTSYM WDSPRegA8,WDSPRegA9,WDSPRegAA,WDSPRegAB,WDSPRegAC,WDSPRegAD,WDSPRegAE EXTSYM WDSPRegAF,WDSPRegB0,WDSPRegB1,WDSPRegB2,WDSPRegB3,WDSPRegB4,WDSPRegB5 EXTSYM WDSPRegB6,WDSPRegB7,WDSPRegB8,WDSPRegB9,WDSPRegBA,WDSPRegBB,WDSPRegBC EXTSYM WDSPRegBD,WDSPRegBE,WDSPRegBF,WDSPRegC0,WDSPRegC1,WDSPRegC2,WDSPRegC3 EXTSYM WDSPRegC4,WDSPRegC5,WDSPRegC6,WDSPRegC7,WDSPRegC8,WDSPRegC9,WDSPRegCA EXTSYM WDSPRegCB,WDSPRegCC,WDSPRegCD,WDSPRegCE,WDSPRegCF,WDSPRegD0,WDSPRegD1 EXTSYM WDSPRegD2,WDSPRegD3,WDSPRegD4,WDSPRegD5,WDSPRegD6,WDSPRegD7,WDSPRegD8 EXTSYM WDSPRegD9,WDSPRegDA,WDSPRegDB,WDSPRegDC,WDSPRegDD,WDSPRegDE,WDSPRegDF EXTSYM WDSPRegE0,WDSPRegE1,WDSPRegE2,WDSPRegE3,WDSPRegE4,WDSPRegE5,WDSPRegE6 EXTSYM WDSPRegE7,WDSPRegE8,WDSPRegE9,WDSPRegEA,WDSPRegEB,WDSPRegEC,WDSPRegED EXTSYM WDSPRegEE,WDSPRegEF,WDSPRegF0,WDSPRegF1,WDSPRegF2,WDSPRegF3,WDSPRegF4 EXTSYM WDSPRegF5,WDSPRegF6,WDSPRegF7,WDSPRegF8,WDSPRegF9,WDSPRegFA,WDSPRegFB EXTSYM WDSPRegFC,WDSPRegFD,WDSPRegFE,WDSPRegFF,RaisePitch EXTSYM delay EXTSYM spcBuffera EXTSYM DSPMem EXTSYM SoundInterpType EXTSYM NoiseData,SoundCompD,Voice0Disable,csounddisable,dssel,spcRamcmp EXTSYM cfgecho,Surround,SoundBufEn EXTSYM echobuf,ENVDisable EXTSYM LowPassFilterType EXTSYM NoiseDisTemp NEWSYM DspProcAsmStart SECTION .data ; MixEcho ; modpitch ; How the sound code works : ; Clear memory at $01 to $EF ; Store $BBAA into $2140 ; Wait for $CC in $2142 ; Goto FFEF: ;FFD6: ; Move $2140 into Y ; Repeat until Y = 0 ;FFDA: ; If $2140 <> 0, then jump to FFE9 ; Move $2141 into A ; Move Y into $2140 ; Move A into [$00]+Y ; Increment Y ; Jump to FFDA if Y <> 0 ; Increment value at $01 ;FFE9: ; If plus flag set, goto FFDA ; If (Y-$2140) <> 0, goto FFE9 ;FFEF: ; Move 2142 into YA ; Move YA into Address $00 ; Move A into 2140 ; Move Y into A ; Move A into X ; If A is not zero, goto FFD6 ; Jump to Address [0000] DSPInterP: times 1024 dw 0 section .data Gaussian: dw 1305,1305,1304,1304,1304,1304,1304,1303 dw 1303,1303,1302,1302,1301,1300,1300,1299 dw 1298,1297,1297,1296,1295,1294,1293,1292 dw 1291,1290,1288,1287,1286,1284,1283,1282 dw 1280,1279,1277,1275,1274,1272,1270,1269 dw 1267,1265,1263,1261,1259,1257,1255,1253 dw 1251,1248,1246,1244,1241,1239,1237,1234 dw 1232,1229,1227,1224,1221,1219,1216,1213 dw 1210,1207,1205,1202,1199,1196,1193,1190 dw 1186,1183,1180,1177,1174,1170,1167,1164 dw 1160,1157,1153,1150,1146,1143,1139,1136 dw 1132,1128,1125,1121,1117,1113,1109,1106 dw 1102,1098,1094,1090,1086,1082,1078,1074 dw 1070,1066,1061,1057,1053,1049,1045,1040 dw 1036,1032,1027,1023,1019,1014,1010,1005 dw 1001, 997, 992, 988, 983, 978, 974, 969 dw 965, 960, 955, 951, 946, 941, 937, 932 dw 927, 923, 918, 913, 908, 904, 899, 894 dw 889, 884, 880, 875, 870, 865, 860, 855 dw 851, 846, 841, 836, 831, 826, 821, 816 dw 811, 806, 802, 797, 792, 787, 782, 777 dw 772, 767, 762, 757, 752, 747, 742, 737 dw 732, 728, 723, 718, 713, 708, 703, 698 dw 693, 688, 683, 678, 674, 669, 664, 659 dw 654, 649, 644, 640, 635, 630, 625, 620 dw 615, 611, 606, 601, 596, 592, 587, 582 dw 577, 573, 568, 563, 559, 554, 550, 545 dw 540, 536, 531, 527, 522, 517, 513, 508 dw 504, 499, 495, 491, 486, 482, 477, 473 dw 469, 464, 460, 456, 451, 447, 443, 439 dw 434, 430, 426, 422, 418, 414, 410, 405 dw 401, 397, 393, 389, 385, 381, 378, 374 dw 370, 366, 362, 358, 354, 351, 347, 343 dw 339, 336, 332, 328, 325, 321, 318, 314 dw 311, 307, 304, 300, 297, 293, 290, 286 dw 283, 280, 276, 273, 270, 267, 263, 260 dw 257, 254, 251, 248, 245, 242, 239, 236 dw 233, 230, 227, 224, 221, 218, 215, 212 dw 210, 207, 204, 201, 199, 196, 193, 191 dw 188, 186, 183, 180, 178, 175, 173, 171 dw 168, 166, 163, 161, 159, 156, 154, 152 dw 150, 147, 145, 143, 141, 139, 137, 134 dw 132, 130, 128, 126, 124, 122, 120, 118 dw 117, 115, 113, 111, 109, 107, 106, 104 dw 102, 100, 99, 97, 95, 94, 92, 90 dw 89, 87, 86, 84, 83, 81, 80, 78 dw 77, 76, 74, 73, 71, 70, 69, 67 dw 66, 65, 64, 62, 61, 60, 59, 58 dw 56, 55, 54, 53, 52, 51, 50, 49 dw 48, 47, 46, 45, 44, 43, 42, 41 dw 40, 39, 38, 37, 36, 36, 35, 34 dw 33, 32, 32, 31, 30, 29, 29, 28 dw 27, 27, 26, 25, 24, 24, 23, 23 dw 22, 21, 21, 20, 20, 19, 19, 18 dw 17, 17, 16, 16, 15, 15, 15, 14 dw 14, 13, 13, 12, 12, 11, 11, 11 dw 10, 10, 10, 9, 9, 9, 8, 8 dw 8, 7, 7, 7, 6, 6, 6, 6 dw 5, 5, 5, 5, 4, 4, 4, 4 dw 4, 3, 3, 3, 3, 3, 2, 2 dw 2, 2, 2, 2, 2, 1, 1, 1 dw 1, 1, 1, 1, 1, 1, 1, 1 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, 0, 0, 0, 0, 0, 0, 0 CubicSpline: dw 0, 0, 0, 0, 0, 0, 0, 0 dw 0, -1, -1, -1, -2, -2, -2, -3 dw -3, -4, -4, -5, -5, -6, -6, -7 dw -8, -8, -9, -10, -10, -11, -12, -13 dw -14, -14, -15, -16, -17, -18, -19, -20 dw -21, -22, -23, -24, -25, -26, -27, -28 dw -29, -30, -31, -32, -33, -34, -35, -37 dw -38, -39, -40, -41, -43, -44, -45, -46 dw -48, -49, -50, -51, -53, -54, -55, -56 dw -58, -59, -60, -62, -63, -64, -66, -67 dw -68, -70, -71, -72, -74, -75, -76, -78 dw -79, -80, -82, -83, -84, -86, -87, -88 dw -90, -91, -92, -93, -95, -96, -97, -99 dw -100,-101,-102,-104,-105,-106,-107,-109 dw -110,-111,-112,-113,-114,-116,-117,-118 dw -119,-120,-121,-122,-123,-124,-125,-126 dw -128,-128,-129,-130,-131,-132,-133,-134 dw -135,-136,-137,-137,-138,-139,-140,-141 dw -141,-142,-143,-143,-144,-144,-145,-146 dw -146,-147,-147,-148,-148,-148,-149,-149 dw -150,-150,-150,-150,-151,-151,-151,-151 dw -151,-151,-151,-151,-151,-151,-151,-151 dw -151,-151,-150,-150,-150,-149,-149,-149 dw -148,-148,-147,-147,-146,-146,-145,-144 dw -144,-143,-142,-141,-140,-139,-138,-137 dw -136,-135,-134,-133,-132,-130,-129,-128 dw -126,-125,-123,-122,-120,-119,-117,-115 dw -113,-112,-110,-108,-106,-104,-102,-100 dw -98, -95, -93, -91, -88, -86, -83, -81 dw -78, -76, -73, -70, -67, -65, -62, -59 dw -56, -53, -50, -46, -43, -40, -36, -33 dw -30, -26, -22, -19, -15, -11, -7, -3 dw 0, 4, 8, 12, 16, 21, 26, 30 dw 35, 40, 46, 51, 56, 62, 67, 73 dw 79, 85, 91, 97, 103, 109, 116, 122 dw 129, 136, 143, 149, 156, 164, 171, 178 dw 186, 193, 201, 208, 216, 224, 232, 240 dw 248, 256, 264, 273, 281, 289, 298, 307 dw 315, 324, 333, 342, 351, 360, 369, 378 dw 387, 397, 406, 415, 425, 435, 444, 454 dw 464, 473, 483, 493, 503, 513, 523, 533 dw 543, 553, 564, 574, 584, 594, 605, 615 dw 626, 636, 647, 657, 668, 679, 689, 700 dw 711, 721, 732, 743, 754, 765, 776, 787 dw 798, 808, 819, 830, 841, 852, 863, 874 dw 886, 897, 908, 919, 930, 941, 952, 963 dw 974, 985, 996,1008,1019,1030,1041,1052 dw 1063,1074,1085,1096,1107,1118,1129,1140 dw 1152,1162,1173,1184,1195,1206,1217,1228 dw 1239,1250,1261,1271,1282,1293,1303,1314 dw 1325,1335,1346,1356,1367,1377,1388,1398 dw 1408,1419,1429,1439,1449,1459,1470,1480 dw 1490,1499,1509,1519,1529,1539,1548,1558 dw 1567,1577,1586,1595,1605,1614,1623,1632 dw 1641,1650,1659,1668,1677,1685,1694,1702 dw 1711,1719,1727,1736,1744,1752,1760,1768 dw 1776,1783,1791,1798,1806,1813,1820,1828 dw 1835,1842,1849,1855,1862,1869,1875,1881 dw 1888,1894,1900,1906,1912,1918,1923,1929 dw 1934,1940,1945,1950,1955,1960,1964,1969 dw 1974,1978,1982,1986,1990,1994,1998,2002 dw 2005,2008,2012,2015,2018,2021,2023,2026 dw 2028,2031,2033,2035,2037,2038,2040,2041 dw 2043,2044,2045,2046,2046,2047,2047,2047 dw 2048,2047,2047,2047,2046,2046,2045,2044 dw 2043,2041,2040,2038,2037,2035,2033,2031 dw 2028,2026,2023,2021,2018,2015,2012,2008 dw 2005,2002,1998,1994,1990,1986,1982,1978 dw 1974,1969,1964,1960,1955,1950,1945,1940 dw 1934,1929,1923,1918,1912,1906,1900,1894 dw 1888,1881,1875,1869,1862,1855,1849,1842 dw 1835,1828,1820,1813,1806,1798,1791,1783 dw 1776,1768,1760,1752,1744,1736,1727,1719 dw 1711,1702,1694,1685,1677,1668,1659,1650 dw 1641,1632,1623,1614,1605,1595,1586,1577 dw 1567,1558,1548,1539,1529,1519,1509,1499 dw 1490,1480,1470,1459,1449,1439,1429,1419 dw 1408,1398,1388,1377,1367,1356,1346,1335 dw 1325,1314,1303,1293,1282,1271,1261,1250 dw 1239,1228,1217,1206,1195,1184,1173,1162 dw 1152,1140,1129,1118,1107,1096,1085,1074 dw 1063,1052,1041,1030,1019,1008, 996, 985 dw 974, 963, 952, 941, 930, 919, 908, 897 dw 886, 874, 863, 852, 841, 830, 819, 808 dw 798, 787, 776, 765, 754, 743, 732, 721 dw 711, 700, 689, 679, 668, 657, 647, 636 dw 626, 615, 605, 594, 584, 574, 564, 553 dw 543, 533, 523, 513, 503, 493, 483, 473 dw 464, 454, 444, 435, 425, 415, 406, 397 dw 387, 378, 369, 360, 351, 342, 333, 324 dw 315, 307, 298, 289, 281, 273, 264, 256 dw 248, 240, 232, 224, 216, 208, 201, 193 dw 186, 178, 171, 164, 156, 149, 143, 136 dw 129, 122, 116, 109, 103, 97, 91, 85 dw 79, 73, 67, 62, 56, 51, 46, 40 dw 35, 30, 26, 21, 16, 12, 8, 4 dw 0, -3, -7, -11, -15, -19, -22, -26 dw -30, -33, -36, -40, -43, -46, -50, -53 dw -56, -59, -62, -65, -67, -70, -73, -76 dw -78, -81, -83, -86, -88, -91, -93, -95 dw -98,-100,-102,-104,-106,-108,-110,-112 dw -113,-115,-117,-119,-120,-122,-123,-125 dw -126,-128,-129,-130,-132,-133,-134,-135 dw -136,-137,-138,-139,-140,-141,-142,-143 dw -144,-144,-145,-146,-146,-147,-147,-148 dw -148,-149,-149,-149,-150,-150,-150,-151 dw -151,-151,-151,-151,-151,-151,-151,-151 dw -151,-151,-151,-151,-151,-150,-150,-150 dw -150,-149,-149,-148,-148,-148,-147,-147 dw -146,-146,-145,-144,-144,-143,-143,-142 dw -141,-141,-140,-139,-138,-137,-137,-136 dw -135,-134,-133,-132,-131,-130,-129,-128 dw -128,-126,-125,-124,-123,-122,-121,-120 dw -119,-118,-117,-116,-114,-113,-112,-111 dw -110,-109,-107,-106,-105,-104,-102,-101 dw -100, -99, -97, -96, -95, -93, -92, -91 dw -90, -88, -87, -86, -84, -83, -82, -80 dw -79, -78, -76, -75, -74, -72, -71, -70 dw -68, -67, -66, -64, -63, -62, -60, -59 dw -58, -56, -55, -54, -53, -51, -50, -49 dw -48, -46, -45, -44, -43, -41, -40, -39 dw -38, -37, -35, -34, -33, -32, -31, -30 dw -29, -28, -27, -26, -25, -24, -23, -22 dw -21, -20, -19, -18, -17, -16, -15, -14 dw -14, -13, -12, -11, -10, -10, -9, -8 dw -8, -7, -6, -6, -5, -5, -4, -4 dw -3, -3, -2, -2, -2, -1, -1, -1 dw 0, 0, 0, 0, 0, 0, 0, 0 %include "cpu/fir_tables.inc" SECTION .data ;ALIGN=32 NEWSYM spcWptr, times 16 dd 0 ; SPC Write pointers (point to their own functions) NEWSYM spcRptr, times 16 dd 0 ; SPC Read pointers (point to their own functions) ;dspWptr times 256 dd 0 ; DSP Write pointers (point to their own functions) ;dspRptr times 256 dd 0 ; DSP Read pointers (point to their own functions) SECTION .data ;ALIGN=32 NEWSYM SoundQuality, dd 2 NEWSYM StereoSound, db 0 NEWSYM SBToSPC, dd 22050 NEWSYM NumBRRconv, dd 0 NEWSYM BufferSizeB, dd 320 NEWSYM BufferSizeW, dd 640 NEWSYM SBBufferLoc, dd 0 NEWSYM SBBufferMov, dd 0 NEWSYM SBBufferInc, dd 0 NEWSYM SoundInterrupt, dd 0 ;TIME_CONSTANT = 256 - 1000000 / frequency NEWSYM BufferSize, dw 320, 320, 320, 500, 320, 400, 400 NEWSYM BufferSizes, dw 320, 320, 500, 900, 400, 750, 750 NEWSYM SoundSpeeds, db 131, 165, 211, 233, 193, 225, 235 ; 8khz,11khz,22khz,44khz NEWSYM SoundSpeedt, db 193, 210, 233 ; 8khz,11khz,22khz NEWSYM SBToSPCSpeeds, dd 8000,10989,22222,43478,15874,32258,48000 NEWSYM SBToSPCSpeeds2, dd 8192,11289,22579,45158,16384,32768,48000 NEWSYM NumofSPCBlock, dd 626,456,228,114,314,156,104 NEWSYM SPCBlockNum, dd 0 NEWSYM NoiseSpeeds dd 1,16,21,25,31,42,50,63,83,100,125,170,200,250,333,400,500,667, dd 800,1000,1300,1600,2000,2700,3200,4000,5300,6400,8000,10700, dd 16000,32000 section .text NEWSYM conv2speedb .next mov eax,[esi] mov ebx,[SBToSPC] shr ebx,4 mul ebx mov ebx,[SBRateb] shr ebx,4 div ebx cmp eax,0 jne .nozero mov eax,1 .nozero ; mov [esi],eax add esi,4 dec ecx jnz .next ret %macro initpitchm 1 mov ax,[DSPMem+02h+%1*10h] mov word[Voice0Pitch+%1*2],ax xor ebx,ebx xor edx,edx and eax,03FFFh shl eax,2 mov dl,ah shl eax,24 mov ebx,[SBToSPC] div ebx shl eax,1 mov [Voice0Freq+%1*4],eax ; modpitch %endmacro NEWSYM initpitch initpitchm 0 initpitchm 1 initpitchm 2 initpitchm 3 initpitchm 4 initpitchm 5 initpitchm 6 initpitchm 7 ret %macro fixdspm 1 mov esi,%1 mov ecx,8 call conv2speedb %endmacro NEWSYM fixdsp ; mov dword[SBRateb],22050 cmp dword[SBRateb],0 je near .nofix fixdspm Voice0Freq fixdspm Voice0Time fixdspm Voice0Attack fixdspm Voice0Decay fixdspm Voice0SustainR fixdspm Voice0SustainR2 fixdspm Voice0IncNumber fixdspm Voice0SLenNumber fixdspm Voice0SEndNumber fixdspm Voice0SEndLNumber fixdspm Voice0DecreaseNumber mov ebx,[SBToSPC] mov [SBRateb],ebx .nofix ret NEWSYM conv2speed .next mov eax,[edi] mov ebx,[SBToSPC] shr ebx,4 mul ebx mov ebx,11025 shr ebx,4 div ebx mov [esi],eax add esi,4 add edi,4 dec ecx jnz .next ret NEWSYM AdjustFrequency mov al,[SoundInterpType] or al,al je .notgaussian cmp al,2 je .cubicspline ja .notgaussian ; Copy from Gaussian to DSPInterP mov ebx,DSPInterP+1024 mov edx,DSPInterP+1022 mov esi,Gaussian mov ecx,512 .intrploop xor eax,eax mov ax,[esi] mov [edx],ax mov [ebx],ax add ebx,2 sub edx,2 add esi,2 dec ecx jnz .intrploop jmp .notgaussian .cubicspline ; Copy from CubicSpline to DSPInterP mov ebx,CubicSpline mov edx,DSPInterP mov ecx,1024 .intrploopb xor eax,eax mov ax,[ebx] push ebx mov bx,ax sar bx,3 sub ax,bx pop ebx mov [edx],ax add ebx,2 add edx,2 dec ecx jnz .intrploopb .notgaussian cmp byte[StereoSound],1 jne .nostereo8b cmp byte[SBHDMA],0 jne .nostereo8b ; ***************************************** ; *** ViBRA16X support by Peter Santing *** ; ***************************************** ; before REALLY switching back to 8-bit sucky mono mode ; check that we're dealing with a ViBRA16X Creative Labs Card cmp byte[vibracard], 1 je .nostereo8b cmp dword[SoundQuality],2 jbe .nostereo8b mov dword[SoundQuality],2 .nostereo8b mov eax,[SoundQuality] mov ebx,[NumofSPCBlock+eax*4] cmp byte[StereoSound],1 jne .nostereo shr ebx,1 .nostereo mov [SPCBlockNum],ebx .next mov ecx,[SoundQuality] mov eax,dword [SBToSPCSpeeds+ecx*4] ; code for supporting vibra cards (coded by Peter Santing) cmp byte [vibracard], 1 je .vibrafix cmp byte [SBHDMA],0 je .not16bit mov eax,dword [SBToSPCSpeeds2+ecx*4] .vibrafix mov eax,dword [SBToSPCSpeeds2+ecx*4] .not16bit cmp byte[RaisePitch],0 jne .nopitchmodify ; *1000/1024 mov ebx,1024 mul ebx xor edx,edx mov ebx,1000 div ebx .nopitchmodify mov [SBToSPC],eax mov [SBRateb],eax ; Init all rates mov esi,EchoRate mov edi,EchoRateO mov ecx,16 call conv2speed mov esi,AttackRate mov edi,AttackRateO mov ecx,16 call conv2speed mov esi,DecayRate mov edi,DecayRateO mov ecx,8 call conv2speed mov esi,SustainRate+4 mov edi,SustainRateO+4 mov ecx,31 call conv2speed mov esi,Increase+4 mov edi,IncreaseO+4 mov ecx,31 call conv2speed mov esi,IncreaseBent+4 mov edi,IncreaseBentO+4 mov ecx,31 call conv2speed mov esi,Decrease+4 mov edi,DecreaseO+4 mov ecx,31 call conv2speed mov esi,DecreaseRateExp+4 mov edi,DecreaseRateExpO+4 mov ecx,31 call conv2speed mov dword[Voice0Pitch],0xFFFEFFFE mov dword[Voice0Pitch+4],0xFFFEFFFE mov dword[Voice0Pitch+8],0xFFFEFFFE mov dword[Voice0Pitch+12],0xFFFEFFFE ret NEWSYM InitSPC push eax push ebx push ecx push edx call AdjustFrequency mov ecx,32768 mov edx,32767 .nextvol mov al,dh imul dl shr ax,7 movsx bx,al mov [VolumeConvTable+edx*2],bx dec edx dec ecx jnz .nextvol mov eax,spcRam mov ebx,0EFh .loop2 mov byte[eax],0 inc eax dec ebx jnz .loop2 mov byte[spcX],0 xor eax,eax xor ebx,ebx mov ebp,spcRam mov ax,0FFC9h add ebp,eax mov [spcPCRam],ebp mov dword [spcS],1EFh mov dword [spcRamDP],spcRam ; initialize all the SPC write registers mov dword[spcWptr+0],SPCRegF0 mov dword[spcWptr+4],SPCRegF1 mov dword[spcWptr+8],SPCRegF2 mov dword[spcWptr+12],SPCRegF3 mov dword[spcWptr+16],SPCRegF4 mov dword[spcWptr+20],SPCRegF5 mov dword[spcWptr+24],SPCRegF6 mov dword[spcWptr+28],SPCRegF7 mov dword[spcWptr+32],SPCRegF8 mov dword[spcWptr+36],SPCRegF9 mov dword[spcWptr+40],SPCRegFA mov dword[spcWptr+44],SPCRegFB mov dword[spcWptr+48],SPCRegFC mov dword[spcWptr+52],SPCRegFD mov dword[spcWptr+56],SPCRegFE mov dword[spcWptr+60],SPCRegFF mov dword[spcRptr+0],RSPCRegF0 mov dword[spcRptr+4],RSPCRegF1 mov dword[spcRptr+8],RSPCRegF2 mov dword[spcRptr+12],RSPCRegF3 mov dword[spcRptr+16],RSPCRegF4 mov dword[spcRptr+20],RSPCRegF5 mov dword[spcRptr+24],RSPCRegF6 mov dword[spcRptr+28],RSPCRegF7 mov dword[spcRptr+32],RSPCRegF8 mov dword[spcRptr+36],RSPCRegF9 mov dword[spcRptr+40],RSPCRegFA mov dword[spcRptr+44],RSPCRegFB mov dword[spcRptr+48],RSPCRegFC mov dword[spcRptr+52],RSPCRegFD mov dword[spcRptr+56],RSPCRegFE mov dword[spcRptr+60],RSPCRegFF mov dword [dspRptr+00h],RDSPReg00 mov dword [dspRptr+04h],RDSPReg01 mov dword [dspRptr+08h],RDSPReg02 mov dword [dspRptr+0Ch],RDSPReg03 mov dword [dspRptr+010h],RDSPReg04 mov dword [dspRptr+014h],RDSPReg05 mov dword [dspRptr+018h],RDSPReg06 mov dword [dspRptr+01Ch],RDSPReg07 mov dword [dspRptr+020h],RDSPReg08 mov dword [dspRptr+024h],RDSPReg09 mov dword [dspRptr+028h],RDSPReg0A mov dword [dspRptr+02Ch],RDSPReg0B mov dword [dspRptr+030h],RDSPReg0C mov dword [dspRptr+034h],RDSPReg0D mov dword [dspRptr+038h],RDSPReg0E mov dword [dspRptr+03Ch],RDSPReg0F mov dword [dspRptr+040h],RDSPReg10 mov dword [dspRptr+044h],RDSPReg11 mov dword [dspRptr+048h],RDSPReg12 mov dword [dspRptr+04Ch],RDSPReg13 mov dword [dspRptr+050h],RDSPReg14 mov dword [dspRptr+054h],RDSPReg15 mov dword [dspRptr+058h],RDSPReg16 mov dword [dspRptr+05Ch],RDSPReg17 mov dword [dspRptr+060h],RDSPReg18 mov dword [dspRptr+064h],RDSPReg19 mov dword [dspRptr+068h],RDSPReg1A mov dword [dspRptr+06Ch],RDSPReg1B mov dword [dspRptr+070h],RDSPReg1C mov dword [dspRptr+074h],RDSPReg1D mov dword [dspRptr+078h],RDSPReg1E mov dword [dspRptr+07Ch],RDSPReg1F mov dword [dspRptr+080h],RDSPReg20 mov dword [dspRptr+084h],RDSPReg21 mov dword [dspRptr+088h],RDSPReg22 mov dword [dspRptr+08Ch],RDSPReg23 mov dword [dspRptr+090h],RDSPReg24 mov dword [dspRptr+094h],RDSPReg25 mov dword [dspRptr+098h],RDSPReg26 mov dword [dspRptr+09Ch],RDSPReg27 mov dword [dspRptr+0A0h],RDSPReg28 mov dword [dspRptr+0A4h],RDSPReg29 mov dword [dspRptr+0A8h],RDSPReg2A mov dword [dspRptr+0ACh],RDSPReg2B mov dword [dspRptr+0B0h],RDSPReg2C mov dword [dspRptr+0B4h],RDSPReg2D mov dword [dspRptr+0B8h],RDSPReg2E mov dword [dspRptr+0BCh],RDSPReg2F mov dword [dspRptr+0C0h],RDSPReg30 mov dword [dspRptr+0C4h],RDSPReg31 mov dword [dspRptr+0C8h],RDSPReg32 mov dword [dspRptr+0CCh],RDSPReg33 mov dword [dspRptr+0D0h],RDSPReg34 mov dword [dspRptr+0D4h],RDSPReg35 mov dword [dspRptr+0D8h],RDSPReg36 mov dword [dspRptr+0DCh],RDSPReg37 mov dword [dspRptr+0E0h],RDSPReg38 mov dword [dspRptr+0E4h],RDSPReg39 mov dword [dspRptr+0E8h],RDSPReg3A mov dword [dspRptr+0ECh],RDSPReg3B mov dword [dspRptr+0F0h],RDSPReg3C mov dword [dspRptr+0F4h],RDSPReg3D mov dword [dspRptr+0F8h],RDSPReg3E mov dword [dspRptr+0FCh],RDSPReg3F mov dword [dspRptr+0100h],RDSPReg40 mov dword [dspRptr+0104h],RDSPReg41 mov dword [dspRptr+0108h],RDSPReg42 mov dword [dspRptr+010Ch],RDSPReg43 mov dword [dspRptr+0110h],RDSPReg44 mov dword [dspRptr+0114h],RDSPReg45 mov dword [dspRptr+0118h],RDSPReg46 mov dword [dspRptr+011Ch],RDSPReg47 mov dword [dspRptr+0120h],RDSPReg48 mov dword [dspRptr+0124h],RDSPReg49 mov dword [dspRptr+0128h],RDSPReg4A mov dword [dspRptr+012Ch],RDSPReg4B mov dword [dspRptr+0130h],RDSPReg4C mov dword [dspRptr+0134h],RDSPReg4D mov dword [dspRptr+0138h],RDSPReg4E mov dword [dspRptr+013Ch],RDSPReg4F mov dword [dspRptr+0140h],RDSPReg50 mov dword [dspRptr+0144h],RDSPReg51 mov dword [dspRptr+0148h],RDSPReg52 mov dword [dspRptr+014Ch],RDSPReg53 mov dword [dspRptr+0150h],RDSPReg54 mov dword [dspRptr+0154h],RDSPReg55 mov dword [dspRptr+0158h],RDSPReg56 mov dword [dspRptr+015Ch],RDSPReg57 mov dword [dspRptr+0160h],RDSPReg58 mov dword [dspRptr+0164h],RDSPReg59 mov dword [dspRptr+0168h],RDSPReg5A mov dword [dspRptr+016Ch],RDSPReg5B mov dword [dspRptr+0170h],RDSPReg5C mov dword [dspRptr+0174h],RDSPReg5D mov dword [dspRptr+0178h],RDSPReg5E mov dword [dspRptr+017Ch],RDSPReg5F mov dword [dspRptr+0180h],RDSPReg60 mov dword [dspRptr+0184h],RDSPReg61 mov dword [dspRptr+0188h],RDSPReg62 mov dword [dspRptr+018Ch],RDSPReg63 mov dword [dspRptr+0190h],RDSPReg64 mov dword [dspRptr+0194h],RDSPReg65 mov dword [dspRptr+0198h],RDSPReg66 mov dword [dspRptr+019Ch],RDSPReg67 mov dword [dspRptr+01A0h],RDSPReg68 mov dword [dspRptr+01A4h],RDSPReg69 mov dword [dspRptr+01A8h],RDSPReg6A mov dword [dspRptr+01ACh],RDSPReg6B mov dword [dspRptr+01B0h],RDSPReg6C mov dword [dspRptr+01B4h],RDSPReg6D mov dword [dspRptr+01B8h],RDSPReg6E mov dword [dspRptr+01BCh],RDSPReg6F mov dword [dspRptr+01C0h],RDSPReg70 mov dword [dspRptr+01C4h],RDSPReg71 mov dword [dspRptr+01C8h],RDSPReg72 mov dword [dspRptr+01CCh],RDSPReg73 mov dword [dspRptr+01D0h],RDSPReg74 mov dword [dspRptr+01D4h],RDSPReg75 mov dword [dspRptr+01D8h],RDSPReg76 mov dword [dspRptr+01DCh],RDSPReg77 mov dword [dspRptr+01E0h],RDSPReg78 mov dword [dspRptr+01E4h],RDSPReg79 mov dword [dspRptr+01E8h],RDSPReg7A mov dword [dspRptr+01ECh],RDSPReg7B mov dword [dspRptr+01F0h],RDSPReg7C mov dword [dspRptr+01F4h],RDSPReg7D mov dword [dspRptr+01F8h],RDSPReg7E mov dword [dspRptr+01FCh],RDSPReg7F mov dword [dspRptr+0200h],RDSPReg80 mov dword [dspRptr+0204h],RDSPReg81 mov dword [dspRptr+0208h],RDSPReg82 mov dword [dspRptr+020Ch],RDSPReg83 mov dword [dspRptr+0210h],RDSPReg84 mov dword [dspRptr+0214h],RDSPReg85 mov dword [dspRptr+0218h],RDSPReg86 mov dword [dspRptr+021Ch],RDSPReg87 mov dword [dspRptr+0220h],RDSPReg88 mov dword [dspRptr+0224h],RDSPReg89 mov dword [dspRptr+0228h],RDSPReg8A mov dword [dspRptr+022Ch],RDSPReg8B mov dword [dspRptr+0230h],RDSPReg8C mov dword [dspRptr+0234h],RDSPReg8D mov dword [dspRptr+0238h],RDSPReg8E mov dword [dspRptr+023Ch],RDSPReg8F mov dword [dspRptr+0240h],RDSPReg90 mov dword [dspRptr+0244h],RDSPReg91 mov dword [dspRptr+0248h],RDSPReg92 mov dword [dspRptr+024Ch],RDSPReg93 mov dword [dspRptr+0250h],RDSPReg94 mov dword [dspRptr+0254h],RDSPReg95 mov dword [dspRptr+0258h],RDSPReg96 mov dword [dspRptr+025Ch],RDSPReg97 mov dword [dspRptr+0260h],RDSPReg98 mov dword [dspRptr+0264h],RDSPReg99 mov dword [dspRptr+0268h],RDSPReg9A mov dword [dspRptr+026Ch],RDSPReg9B mov dword [dspRptr+0270h],RDSPReg9C mov dword [dspRptr+0274h],RDSPReg9D mov dword [dspRptr+0278h],RDSPReg9E mov dword [dspRptr+027Ch],RDSPReg9F mov dword [dspRptr+0280h],RDSPRegA0 mov dword [dspRptr+0284h],RDSPRegA1 mov dword [dspRptr+0288h],RDSPRegA2 mov dword [dspRptr+028Ch],RDSPRegA3 mov dword [dspRptr+0290h],RDSPRegA4 mov dword [dspRptr+0294h],RDSPRegA5 mov dword [dspRptr+0298h],RDSPRegA6 mov dword [dspRptr+029Ch],RDSPRegA7 mov dword [dspRptr+02A0h],RDSPRegA8 mov dword [dspRptr+02A4h],RDSPRegA9 mov dword [dspRptr+02A8h],RDSPRegAA mov dword [dspRptr+02ACh],RDSPRegAB mov dword [dspRptr+02B0h],RDSPRegAC mov dword [dspRptr+02B4h],RDSPRegAD mov dword [dspRptr+02B8h],RDSPRegAE mov dword [dspRptr+02BCh],RDSPRegAF mov dword [dspRptr+02C0h],RDSPRegB0 mov dword [dspRptr+02C4h],RDSPRegB1 mov dword [dspRptr+02C8h],RDSPRegB2 mov dword [dspRptr+02CCh],RDSPRegB3 mov dword [dspRptr+02D0h],RDSPRegB4 mov dword [dspRptr+02D4h],RDSPRegB5 mov dword [dspRptr+02D8h],RDSPRegB6 mov dword [dspRptr+02DCh],RDSPRegB7 mov dword [dspRptr+02E0h],RDSPRegB8 mov dword [dspRptr+02E4h],RDSPRegB9 mov dword [dspRptr+02E8h],RDSPRegBA mov dword [dspRptr+02ECh],RDSPRegBB mov dword [dspRptr+02F0h],RDSPRegBC mov dword [dspRptr+02F4h],RDSPRegBD mov dword [dspRptr+02F8h],RDSPRegBE mov dword [dspRptr+02FCh],RDSPRegBF mov dword [dspRptr+0300h],RDSPRegC0 mov dword [dspRptr+0304h],RDSPRegC1 mov dword [dspRptr+0308h],RDSPRegC2 mov dword [dspRptr+030Ch],RDSPRegC3 mov dword [dspRptr+0310h],RDSPRegC4 mov dword [dspRptr+0314h],RDSPRegC5 mov dword [dspRptr+0318h],RDSPRegC6 mov dword [dspRptr+031Ch],RDSPRegC7 mov dword [dspRptr+0320h],RDSPRegC8 mov dword [dspRptr+0324h],RDSPRegC9 mov dword [dspRptr+0328h],RDSPRegCA mov dword [dspRptr+032Ch],RDSPRegCB mov dword [dspRptr+0330h],RDSPRegCC mov dword [dspRptr+0334h],RDSPRegCD mov dword [dspRptr+0338h],RDSPRegCE mov dword [dspRptr+033Ch],RDSPRegCF mov dword [dspRptr+0340h],RDSPRegD0 mov dword [dspRptr+0344h],RDSPRegD1 mov dword [dspRptr+0348h],RDSPRegD2 mov dword [dspRptr+034Ch],RDSPRegD3 mov dword [dspRptr+0350h],RDSPRegD4 mov dword [dspRptr+0354h],RDSPRegD5 mov dword [dspRptr+0358h],RDSPRegD6 mov dword [dspRptr+035Ch],RDSPRegD7 mov dword [dspRptr+0360h],RDSPRegD8 mov dword [dspRptr+0364h],RDSPRegD9 mov dword [dspRptr+0368h],RDSPRegDA mov dword [dspRptr+036Ch],RDSPRegDB mov dword [dspRptr+0370h],RDSPRegDC mov dword [dspRptr+0374h],RDSPRegDD mov dword [dspRptr+0378h],RDSPRegDE mov dword [dspRptr+037Ch],RDSPRegDF mov dword [dspRptr+0380h],RDSPRegE0 mov dword [dspRptr+0384h],RDSPRegE1 mov dword [dspRptr+0388h],RDSPRegE2 mov dword [dspRptr+038Ch],RDSPRegE3 mov dword [dspRptr+0390h],RDSPRegE4 mov dword [dspRptr+0394h],RDSPRegE5 mov dword [dspRptr+0398h],RDSPRegE6 mov dword [dspRptr+039Ch],RDSPRegE7 mov dword [dspRptr+03A0h],RDSPRegE8 mov dword [dspRptr+03A4h],RDSPRegE9 mov dword [dspRptr+03A8h],RDSPRegEA mov dword [dspRptr+03ACh],RDSPRegEB mov dword [dspRptr+03B0h],RDSPRegEC mov dword [dspRptr+03B4h],RDSPRegED mov dword [dspRptr+03B8h],RDSPRegEE mov dword [dspRptr+03BCh],RDSPRegEF mov dword [dspRptr+03C0h],RDSPRegF0 mov dword [dspRptr+03C4h],RDSPRegF1 mov dword [dspRptr+03C8h],RDSPRegF2 mov dword [dspRptr+03CCh],RDSPRegF3 mov dword [dspRptr+03D0h],RDSPRegF4 mov dword [dspRptr+03D4h],RDSPRegF5 mov dword [dspRptr+03D8h],RDSPRegF6 mov dword [dspRptr+03DCh],RDSPRegF7 mov dword [dspRptr+03E0h],RDSPRegF8 mov dword [dspRptr+03E4h],RDSPRegF9 mov dword [dspRptr+03E8h],RDSPRegFA mov dword [dspRptr+03ECh],RDSPRegFB mov dword [dspRptr+03F0h],RDSPRegFC mov dword [dspRptr+03F4h],RDSPRegFD mov dword [dspRptr+03F8h],RDSPRegFE mov dword [dspRptr+03FCh],RDSPRegFF mov dword [dspWptr+00h],WDSPReg00 mov dword [dspWptr+04h],WDSPReg01 mov dword [dspWptr+08h],WDSPReg02 mov dword [dspWptr+0Ch],WDSPReg03 mov dword [dspWptr+010h],WDSPReg04 mov dword [dspWptr+014h],WDSPReg05 mov dword [dspWptr+018h],WDSPReg06 mov dword [dspWptr+01Ch],WDSPReg07 mov dword [dspWptr+020h],WDSPReg08 mov dword [dspWptr+024h],WDSPReg09 mov dword [dspWptr+028h],WDSPReg0A mov dword [dspWptr+02Ch],WDSPReg0B mov dword [dspWptr+030h],WDSPReg0C mov dword [dspWptr+034h],WDSPReg0D mov dword [dspWptr+038h],WDSPReg0E mov dword [dspWptr+03Ch],WDSPReg0F mov dword [dspWptr+040h],WDSPReg10 mov dword [dspWptr+044h],WDSPReg11 mov dword [dspWptr+048h],WDSPReg12 mov dword [dspWptr+04Ch],WDSPReg13 mov dword [dspWptr+050h],WDSPReg14 mov dword [dspWptr+054h],WDSPReg15 mov dword [dspWptr+058h],WDSPReg16 mov dword [dspWptr+05Ch],WDSPReg17 mov dword [dspWptr+060h],WDSPReg18 mov dword [dspWptr+064h],WDSPReg19 mov dword [dspWptr+068h],WDSPReg1A mov dword [dspWptr+06Ch],WDSPReg1B mov dword [dspWptr+070h],WDSPReg1C mov dword [dspWptr+074h],WDSPReg1D mov dword [dspWptr+078h],WDSPReg1E mov dword [dspWptr+07Ch],WDSPReg1F mov dword [dspWptr+080h],WDSPReg20 mov dword [dspWptr+084h],WDSPReg21 mov dword [dspWptr+088h],WDSPReg22 mov dword [dspWptr+08Ch],WDSPReg23 mov dword [dspWptr+090h],WDSPReg24 mov dword [dspWptr+094h],WDSPReg25 mov dword [dspWptr+098h],WDSPReg26 mov dword [dspWptr+09Ch],WDSPReg27 mov dword [dspWptr+0A0h],WDSPReg28 mov dword [dspWptr+0A4h],WDSPReg29 mov dword [dspWptr+0A8h],WDSPReg2A mov dword [dspWptr+0ACh],WDSPReg2B mov dword [dspWptr+0B0h],WDSPReg2C mov dword [dspWptr+0B4h],WDSPReg2D mov dword [dspWptr+0B8h],WDSPReg2E mov dword [dspWptr+0BCh],WDSPReg2F mov dword [dspWptr+0C0h],WDSPReg30 mov dword [dspWptr+0C4h],WDSPReg31 mov dword [dspWptr+0C8h],WDSPReg32 mov dword [dspWptr+0CCh],WDSPReg33 mov dword [dspWptr+0D0h],WDSPReg34 mov dword [dspWptr+0D4h],WDSPReg35 mov dword [dspWptr+0D8h],WDSPReg36 mov dword [dspWptr+0DCh],WDSPReg37 mov dword [dspWptr+0E0h],WDSPReg38 mov dword [dspWptr+0E4h],WDSPReg39 mov dword [dspWptr+0E8h],WDSPReg3A mov dword [dspWptr+0ECh],WDSPReg3B mov dword [dspWptr+0F0h],WDSPReg3C mov dword [dspWptr+0F4h],WDSPReg3D mov dword [dspWptr+0F8h],WDSPReg3E mov dword [dspWptr+0FCh],WDSPReg3F mov dword [dspWptr+0100h],WDSPReg40 mov dword [dspWptr+0104h],WDSPReg41 mov dword [dspWptr+0108h],WDSPReg42 mov dword [dspWptr+010Ch],WDSPReg43 mov dword [dspWptr+0110h],WDSPReg44 mov dword [dspWptr+0114h],WDSPReg45 mov dword [dspWptr+0118h],WDSPReg46 mov dword [dspWptr+011Ch],WDSPReg47 mov dword [dspWptr+0120h],WDSPReg48 mov dword [dspWptr+0124h],WDSPReg49 mov dword [dspWptr+0128h],WDSPReg4A mov dword [dspWptr+012Ch],WDSPReg4B mov dword [dspWptr+0130h],WDSPReg4C mov dword [dspWptr+0134h],WDSPReg4D mov dword [dspWptr+0138h],WDSPReg4E mov dword [dspWptr+013Ch],WDSPReg4F mov dword [dspWptr+0140h],WDSPReg50 mov dword [dspWptr+0144h],WDSPReg51 mov dword [dspWptr+0148h],WDSPReg52 mov dword [dspWptr+014Ch],WDSPReg53 mov dword [dspWptr+0150h],WDSPReg54 mov dword [dspWptr+0154h],WDSPReg55 mov dword [dspWptr+0158h],WDSPReg56 mov dword [dspWptr+015Ch],WDSPReg57 mov dword [dspWptr+0160h],WDSPReg58 mov dword [dspWptr+0164h],WDSPReg59 mov dword [dspWptr+0168h],WDSPReg5A mov dword [dspWptr+016Ch],WDSPReg5B mov dword [dspWptr+0170h],WDSPReg5C mov dword [dspWptr+0174h],WDSPReg5D mov dword [dspWptr+0178h],WDSPReg5E mov dword [dspWptr+017Ch],WDSPReg5F mov dword [dspWptr+0180h],WDSPReg60 mov dword [dspWptr+0184h],WDSPReg61 mov dword [dspWptr+0188h],WDSPReg62 mov dword [dspWptr+018Ch],WDSPReg63 mov dword [dspWptr+0190h],WDSPReg64 mov dword [dspWptr+0194h],WDSPReg65 mov dword [dspWptr+0198h],WDSPReg66 mov dword [dspWptr+019Ch],WDSPReg67 mov dword [dspWptr+01A0h],WDSPReg68 mov dword [dspWptr+01A4h],WDSPReg69 mov dword [dspWptr+01A8h],WDSPReg6A mov dword [dspWptr+01ACh],WDSPReg6B mov dword [dspWptr+01B0h],WDSPReg6C mov dword [dspWptr+01B4h],WDSPReg6D mov dword [dspWptr+01B8h],WDSPReg6E mov dword [dspWptr+01BCh],WDSPReg6F mov dword [dspWptr+01C0h],WDSPReg70 mov dword [dspWptr+01C4h],WDSPReg71 mov dword [dspWptr+01C8h],WDSPReg72 mov dword [dspWptr+01CCh],WDSPReg73 mov dword [dspWptr+01D0h],WDSPReg74 mov dword [dspWptr+01D4h],WDSPReg75 mov dword [dspWptr+01D8h],WDSPReg76 mov dword [dspWptr+01DCh],WDSPReg77 mov dword [dspWptr+01E0h],WDSPReg78 mov dword [dspWptr+01E4h],WDSPReg79 mov dword [dspWptr+01E8h],WDSPReg7A mov dword [dspWptr+01ECh],WDSPReg7B mov dword [dspWptr+01F0h],WDSPReg7C mov dword [dspWptr+01F4h],WDSPReg7D mov dword [dspWptr+01F8h],WDSPReg7E mov dword [dspWptr+01FCh],WDSPReg7F mov dword [dspWptr+0200h],WDSPReg80 mov dword [dspWptr+0204h],WDSPReg81 mov dword [dspWptr+0208h],WDSPReg82 mov dword [dspWptr+020Ch],WDSPReg83 mov dword [dspWptr+0210h],WDSPReg84 mov dword [dspWptr+0214h],WDSPReg85 mov dword [dspWptr+0218h],WDSPReg86 mov dword [dspWptr+021Ch],WDSPReg87 mov dword [dspWptr+0220h],WDSPReg88 mov dword [dspWptr+0224h],WDSPReg89 mov dword [dspWptr+0228h],WDSPReg8A mov dword [dspWptr+022Ch],WDSPReg8B mov dword [dspWptr+0230h],WDSPReg8C mov dword [dspWptr+0234h],WDSPReg8D mov dword [dspWptr+0238h],WDSPReg8E mov dword [dspWptr+023Ch],WDSPReg8F mov dword [dspWptr+0240h],WDSPReg90 mov dword [dspWptr+0244h],WDSPReg91 mov dword [dspWptr+0248h],WDSPReg92 mov dword [dspWptr+024Ch],WDSPReg93 mov dword [dspWptr+0250h],WDSPReg94 mov dword [dspWptr+0254h],WDSPReg95 mov dword [dspWptr+0258h],WDSPReg96 mov dword [dspWptr+025Ch],WDSPReg97 mov dword [dspWptr+0260h],WDSPReg98 mov dword [dspWptr+0264h],WDSPReg99 mov dword [dspWptr+0268h],WDSPReg9A mov dword [dspWptr+026Ch],WDSPReg9B mov dword [dspWptr+0270h],WDSPReg9C mov dword [dspWptr+0274h],WDSPReg9D mov dword [dspWptr+0278h],WDSPReg9E mov dword [dspWptr+027Ch],WDSPReg9F mov dword [dspWptr+0280h],WDSPRegA0 mov dword [dspWptr+0284h],WDSPRegA1 mov dword [dspWptr+0288h],WDSPRegA2 mov dword [dspWptr+028Ch],WDSPRegA3 mov dword [dspWptr+0290h],WDSPRegA4 mov dword [dspWptr+0294h],WDSPRegA5 mov dword [dspWptr+0298h],WDSPRegA6 mov dword [dspWptr+029Ch],WDSPRegA7 mov dword [dspWptr+02A0h],WDSPRegA8 mov dword [dspWptr+02A4h],WDSPRegA9 mov dword [dspWptr+02A8h],WDSPRegAA mov dword [dspWptr+02ACh],WDSPRegAB mov dword [dspWptr+02B0h],WDSPRegAC mov dword [dspWptr+02B4h],WDSPRegAD mov dword [dspWptr+02B8h],WDSPRegAE mov dword [dspWptr+02BCh],WDSPRegAF mov dword [dspWptr+02C0h],WDSPRegB0 mov dword [dspWptr+02C4h],WDSPRegB1 mov dword [dspWptr+02C8h],WDSPRegB2 mov dword [dspWptr+02CCh],WDSPRegB3 mov dword [dspWptr+02D0h],WDSPRegB4 mov dword [dspWptr+02D4h],WDSPRegB5 mov dword [dspWptr+02D8h],WDSPRegB6 mov dword [dspWptr+02DCh],WDSPRegB7 mov dword [dspWptr+02E0h],WDSPRegB8 mov dword [dspWptr+02E4h],WDSPRegB9 mov dword [dspWptr+02E8h],WDSPRegBA mov dword [dspWptr+02ECh],WDSPRegBB mov dword [dspWptr+02F0h],WDSPRegBC mov dword [dspWptr+02F4h],WDSPRegBD mov dword [dspWptr+02F8h],WDSPRegBE mov dword [dspWptr+02FCh],WDSPRegBF mov dword [dspWptr+0300h],WDSPRegC0 mov dword [dspWptr+0304h],WDSPRegC1 mov dword [dspWptr+0308h],WDSPRegC2 mov dword [dspWptr+030Ch],WDSPRegC3 mov dword [dspWptr+0310h],WDSPRegC4 mov dword [dspWptr+0314h],WDSPRegC5 mov dword [dspWptr+0318h],WDSPRegC6 mov dword [dspWptr+031Ch],WDSPRegC7 mov dword [dspWptr+0320h],WDSPRegC8 mov dword [dspWptr+0324h],WDSPRegC9 mov dword [dspWptr+0328h],WDSPRegCA mov dword [dspWptr+032Ch],WDSPRegCB mov dword [dspWptr+0330h],WDSPRegCC mov dword [dspWptr+0334h],WDSPRegCD mov dword [dspWptr+0338h],WDSPRegCE mov dword [dspWptr+033Ch],WDSPRegCF mov dword [dspWptr+0340h],WDSPRegD0 mov dword [dspWptr+0344h],WDSPRegD1 mov dword [dspWptr+0348h],WDSPRegD2 mov dword [dspWptr+034Ch],WDSPRegD3 mov dword [dspWptr+0350h],WDSPRegD4 mov dword [dspWptr+0354h],WDSPRegD5 mov dword [dspWptr+0358h],WDSPRegD6 mov dword [dspWptr+035Ch],WDSPRegD7 mov dword [dspWptr+0360h],WDSPRegD8 mov dword [dspWptr+0364h],WDSPRegD9 mov dword [dspWptr+0368h],WDSPRegDA mov dword [dspWptr+036Ch],WDSPRegDB mov dword [dspWptr+0370h],WDSPRegDC mov dword [dspWptr+0374h],WDSPRegDD mov dword [dspWptr+0378h],WDSPRegDE mov dword [dspWptr+037Ch],WDSPRegDF mov dword [dspWptr+0380h],WDSPRegE0 mov dword [dspWptr+0384h],WDSPRegE1 mov dword [dspWptr+0388h],WDSPRegE2 mov dword [dspWptr+038Ch],WDSPRegE3 mov dword [dspWptr+0390h],WDSPRegE4 mov dword [dspWptr+0394h],WDSPRegE5 mov dword [dspWptr+0398h],WDSPRegE6 mov dword [dspWptr+039Ch],WDSPRegE7 mov dword [dspWptr+03A0h],WDSPRegE8 mov dword [dspWptr+03A4h],WDSPRegE9 mov dword [dspWptr+03A8h],WDSPRegEA mov dword [dspWptr+03ACh],WDSPRegEB mov dword [dspWptr+03B0h],WDSPRegEC mov dword [dspWptr+03B4h],WDSPRegED mov dword [dspWptr+03B8h],WDSPRegEE mov dword [dspWptr+03BCh],WDSPRegEF mov dword [dspWptr+03C0h],WDSPRegF0 mov dword [dspWptr+03C4h],WDSPRegF1 mov dword [dspWptr+03C8h],WDSPRegF2 mov dword [dspWptr+03CCh],WDSPRegF3 mov dword [dspWptr+03D0h],WDSPRegF4 mov dword [dspWptr+03D4h],WDSPRegF5 mov dword [dspWptr+03D8h],WDSPRegF6 mov dword [dspWptr+03DCh],WDSPRegF7 mov dword [dspWptr+03E0h],WDSPRegF8 mov dword [dspWptr+03E4h],WDSPRegF9 mov dword [dspWptr+03E8h],WDSPRegFA mov dword [dspWptr+03ECh],WDSPRegFB mov dword [dspWptr+03F0h],WDSPRegFC mov dword [dspWptr+03F4h],WDSPRegFD mov dword [dspWptr+03F8h],WDSPRegFE mov dword [dspWptr+03FCh],WDSPRegFF ; first fill all pointer to an invalid access function mov ecx,256 mov eax,Invalidopcode mov ebp,0 .loop mov [opcjmptab+ebp],eax add ebp,4 dec ecx jnz .loop ; now fill the table mov dword [opcjmptab+00h],Op00 mov dword [opcjmptab+04h],Op01 mov dword [opcjmptab+08h],Op02 mov dword [opcjmptab+0Ch],Op03 mov dword [opcjmptab+010h],Op04 mov dword [opcjmptab+014h],Op05 mov dword [opcjmptab+018h],Op06 mov dword [opcjmptab+01Ch],Op07 mov dword [opcjmptab+020h],Op08 mov dword [opcjmptab+024h],Op09 mov dword [opcjmptab+028h],Op0A mov dword [opcjmptab+02Ch],Op0B mov dword [opcjmptab+030h],Op0C mov dword [opcjmptab+034h],Op0D mov dword [opcjmptab+038h],Op0E mov dword [opcjmptab+03Ch],Op0F mov dword [opcjmptab+040h],Op10 mov dword [opcjmptab+044h],Op11 mov dword [opcjmptab+048h],Op12 mov dword [opcjmptab+04Ch],Op13 mov dword [opcjmptab+050h],Op14 mov dword [opcjmptab+054h],Op15 mov dword [opcjmptab+058h],Op16 mov dword [opcjmptab+05Ch],Op17 mov dword [opcjmptab+060h],Op18 mov dword [opcjmptab+064h],Op19 mov dword [opcjmptab+068h],Op1A mov dword [opcjmptab+06Ch],Op1B mov dword [opcjmptab+070h],Op1C mov dword [opcjmptab+074h],Op1D mov dword [opcjmptab+078h],Op1E mov dword [opcjmptab+07Ch],Op1F mov dword [opcjmptab+080h],Op20 mov dword [opcjmptab+084h],Op21 mov dword [opcjmptab+088h],Op22 mov dword [opcjmptab+08Ch],Op23 mov dword [opcjmptab+090h],Op24 mov dword [opcjmptab+094h],Op25 mov dword [opcjmptab+098h],Op26 mov dword [opcjmptab+09Ch],Op27 mov dword [opcjmptab+0A0h],Op28 mov dword [opcjmptab+0A4h],Op29 mov dword [opcjmptab+0A8h],Op2A mov dword [opcjmptab+0ACh],Op2B mov dword [opcjmptab+0B0h],Op2C mov dword [opcjmptab+0B4h],Op2D mov dword [opcjmptab+0B8h],Op2E mov dword [opcjmptab+0BCh],Op2F mov dword [opcjmptab+0C0h],Op30 mov dword [opcjmptab+0C4h],Op31 mov dword [opcjmptab+0C8h],Op32 mov dword [opcjmptab+0CCh],Op33 mov dword [opcjmptab+0D0h],Op34 mov dword [opcjmptab+0D4h],Op35 mov dword [opcjmptab+0D8h],Op36 mov dword [opcjmptab+0DCh],Op37 mov dword [opcjmptab+0E0h],Op38 mov dword [opcjmptab+0E4h],Op39 mov dword [opcjmptab+0E8h],Op3A mov dword [opcjmptab+0ECh],Op3B mov dword [opcjmptab+0F0h],Op3C mov dword [opcjmptab+0F4h],Op3D mov dword [opcjmptab+0F8h],Op3E mov dword [opcjmptab+0FCh],Op3F mov dword [opcjmptab+0100h],Op40 mov dword [opcjmptab+0104h],Op41 mov dword [opcjmptab+0108h],Op42 mov dword [opcjmptab+010Ch],Op43 mov dword [opcjmptab+0110h],Op44 mov dword [opcjmptab+0114h],Op45 mov dword [opcjmptab+0118h],Op46 mov dword [opcjmptab+011Ch],Op47 mov dword [opcjmptab+0120h],Op48 mov dword [opcjmptab+0124h],Op49 mov dword [opcjmptab+0128h],Op4A mov dword [opcjmptab+012Ch],Op4B mov dword [opcjmptab+0130h],Op4C mov dword [opcjmptab+0134h],Op4D mov dword [opcjmptab+0138h],Op4E mov dword [opcjmptab+013Ch],Op4F mov dword [opcjmptab+0140h],Op50 mov dword [opcjmptab+0144h],Op51 mov dword [opcjmptab+0148h],Op52 mov dword [opcjmptab+014Ch],Op53 mov dword [opcjmptab+0150h],Op54 mov dword [opcjmptab+0154h],Op55 mov dword [opcjmptab+0158h],Op56 mov dword [opcjmptab+015Ch],Op57 mov dword [opcjmptab+0160h],Op58 mov dword [opcjmptab+0164h],Op59 mov dword [opcjmptab+0168h],Op5A mov dword [opcjmptab+016Ch],Op5B mov dword [opcjmptab+0170h],Op5C mov dword [opcjmptab+0174h],Op5D mov dword [opcjmptab+0178h],Op5E mov dword [opcjmptab+017Ch],Op5F mov dword [opcjmptab+0180h],Op60 mov dword [opcjmptab+0184h],Op61 mov dword [opcjmptab+0188h],Op62 mov dword [opcjmptab+018Ch],Op63 mov dword [opcjmptab+0190h],Op64 mov dword [opcjmptab+0194h],Op65 mov dword [opcjmptab+0198h],Op66 mov dword [opcjmptab+019Ch],Op67 mov dword [opcjmptab+01A0h],Op68 mov dword [opcjmptab+01A4h],Op69 mov dword [opcjmptab+01A8h],Op6A mov dword [opcjmptab+01ACh],Op6B mov dword [opcjmptab+01B0h],Op6C mov dword [opcjmptab+01B4h],Op6D mov dword [opcjmptab+01B8h],Op6E mov dword [opcjmptab+01BCh],Op6F mov dword [opcjmptab+01C0h],Op70 mov dword [opcjmptab+01C4h],Op71 mov dword [opcjmptab+01C8h],Op72 mov dword [opcjmptab+01CCh],Op73 mov dword [opcjmptab+01D0h],Op74 mov dword [opcjmptab+01D4h],Op75 mov dword [opcjmptab+01D8h],Op76 mov dword [opcjmptab+01DCh],Op77 mov dword [opcjmptab+01E0h],Op78 mov dword [opcjmptab+01E4h],Op79 mov dword [opcjmptab+01E8h],Op7A mov dword [opcjmptab+01ECh],Op7B mov dword [opcjmptab+01F0h],Op7C mov dword [opcjmptab+01F4h],Op7D mov dword [opcjmptab+01F8h],Op7E mov dword [opcjmptab+01FCh],Op7F mov dword [opcjmptab+0200h],Op80 mov dword [opcjmptab+0204h],Op81 mov dword [opcjmptab+0208h],Op82 mov dword [opcjmptab+020Ch],Op83 mov dword [opcjmptab+0210h],Op84 mov dword [opcjmptab+0214h],Op85 mov dword [opcjmptab+0218h],Op86 mov dword [opcjmptab+021Ch],Op87 mov dword [opcjmptab+0220h],Op88 mov dword [opcjmptab+0224h],Op89 mov dword [opcjmptab+0228h],Op8A mov dword [opcjmptab+022Ch],Op8B mov dword [opcjmptab+0230h],Op8C mov dword [opcjmptab+0234h],Op8D mov dword [opcjmptab+0238h],Op8E mov dword [opcjmptab+023Ch],Op8F mov dword [opcjmptab+0240h],Op90 mov dword [opcjmptab+0244h],Op91 mov dword [opcjmptab+0248h],Op92 mov dword [opcjmptab+024Ch],Op93 mov dword [opcjmptab+0250h],Op94 mov dword [opcjmptab+0254h],Op95 mov dword [opcjmptab+0258h],Op96 mov dword [opcjmptab+025Ch],Op97 mov dword [opcjmptab+0260h],Op98 mov dword [opcjmptab+0264h],Op99 mov dword [opcjmptab+0268h],Op9A mov dword [opcjmptab+026Ch],Op9B mov dword [opcjmptab+0270h],Op9C mov dword [opcjmptab+0274h],Op9D mov dword [opcjmptab+0278h],Op9E mov dword [opcjmptab+027Ch],Op9F mov dword [opcjmptab+0280h],OpA0 mov dword [opcjmptab+0284h],OpA1 mov dword [opcjmptab+0288h],OpA2 mov dword [opcjmptab+028Ch],OpA3 mov dword [opcjmptab+0290h],OpA4 mov dword [opcjmptab+0294h],OpA5 mov dword [opcjmptab+0298h],OpA6 mov dword [opcjmptab+029Ch],OpA7 mov dword [opcjmptab+02A0h],OpA8 mov dword [opcjmptab+02A4h],OpA9 mov dword [opcjmptab+02A8h],OpAA mov dword [opcjmptab+02ACh],OpAB mov dword [opcjmptab+02B0h],OpAC mov dword [opcjmptab+02B4h],OpAD mov dword [opcjmptab+02B8h],OpAE mov dword [opcjmptab+02BCh],OpAF mov dword [opcjmptab+02C0h],OpB0 mov dword [opcjmptab+02C4h],OpB1 mov dword [opcjmptab+02C8h],OpB2 mov dword [opcjmptab+02CCh],OpB3 mov dword [opcjmptab+02D0h],OpB4 mov dword [opcjmptab+02D4h],OpB5 mov dword [opcjmptab+02D8h],OpB6 mov dword [opcjmptab+02DCh],OpB7 mov dword [opcjmptab+02E0h],OpB8 mov dword [opcjmptab+02E4h],OpB9 mov dword [opcjmptab+02E8h],OpBA mov dword [opcjmptab+02ECh],OpBB mov dword [opcjmptab+02F0h],OpBC mov dword [opcjmptab+02F4h],OpBD mov dword [opcjmptab+02F8h],OpBE mov dword [opcjmptab+02FCh],OpBF mov dword [opcjmptab+0300h],OpC0 mov dword [opcjmptab+0304h],OpC1 mov dword [opcjmptab+0308h],OpC2 mov dword [opcjmptab+030Ch],OpC3 mov dword [opcjmptab+0310h],OpC4 mov dword [opcjmptab+0314h],OpC5 mov dword [opcjmptab+0318h],OpC6 mov dword [opcjmptab+031Ch],OpC7 mov dword [opcjmptab+0320h],OpC8 mov dword [opcjmptab+0324h],OpC9 mov dword [opcjmptab+0328h],OpCA mov dword [opcjmptab+032Ch],OpCB mov dword [opcjmptab+0330h],OpCC mov dword [opcjmptab+0334h],OpCD mov dword [opcjmptab+0338h],OpCE mov dword [opcjmptab+033Ch],OpCF mov dword [opcjmptab+0340h],OpD0 mov dword [opcjmptab+0344h],OpD1 mov dword [opcjmptab+0348h],OpD2 mov dword [opcjmptab+034Ch],OpD3 mov dword [opcjmptab+0350h],OpD4 mov dword [opcjmptab+0354h],OpD5 mov dword [opcjmptab+0358h],OpD6 mov dword [opcjmptab+035Ch],OpD7 mov dword [opcjmptab+0360h],OpD8 mov dword [opcjmptab+0364h],OpD9 mov dword [opcjmptab+0368h],OpDA mov dword [opcjmptab+036Ch],OpDB mov dword [opcjmptab+0370h],OpDC mov dword [opcjmptab+0374h],OpDD mov dword [opcjmptab+0378h],OpDE mov dword [opcjmptab+037Ch],OpDF mov dword [opcjmptab+0380h],OpE0 mov dword [opcjmptab+0384h],OpE1 mov dword [opcjmptab+0388h],OpE2 mov dword [opcjmptab+038Ch],OpE3 mov dword [opcjmptab+0390h],OpE4 mov dword [opcjmptab+0394h],OpE5 mov dword [opcjmptab+0398h],OpE6 mov dword [opcjmptab+039Ch],OpE7 mov dword [opcjmptab+03A0h],OpE8 mov dword [opcjmptab+03A4h],OpE9 mov dword [opcjmptab+03A8h],OpEA mov dword [opcjmptab+03ACh],OpEB mov dword [opcjmptab+03B0h],OpEC mov dword [opcjmptab+03B4h],OpED mov dword [opcjmptab+03B8h],OpEE mov dword [opcjmptab+03BCh],OpEF mov dword [opcjmptab+03C0h],OpF0 mov dword [opcjmptab+03C4h],OpF1 mov dword [opcjmptab+03C8h],OpF2 mov dword [opcjmptab+03CCh],OpF3 mov dword [opcjmptab+03D0h],OpF4 mov dword [opcjmptab+03D4h],OpF5 mov dword [opcjmptab+03D8h],OpF6 mov dword [opcjmptab+03DCh],OpF7 mov dword [opcjmptab+03E0h],OpF8 mov dword [opcjmptab+03E4h],OpF9 mov dword [opcjmptab+03E8h],OpFA mov dword [opcjmptab+03ECh],OpFB mov dword [opcjmptab+03F0h],OpFC mov dword [opcjmptab+03F4h],OpFD mov dword [opcjmptab+03F8h],OpFE mov dword [opcjmptab+03FCh],OpFF ; cmp byte[soundon],0 ; je near .nosound ; cmp byte[OSPort],2 ; jae near .nosound %ifdef __MSDOS__ mov ax,0100h ; Allocate DOS memory mov bx,16384/16 ; Allocate 16384 bytes int 31h ; To delocate this, use ax=0101h, dx=selector of block/int 31h jc near .error ; Check which 8192 byte boundary doesn't cross a page mov word[memoryloc+2],0 mov dword[memoryloc],0 mov [memoryloc],ax mov [sbselec],dx shl dword[memoryloc],4 mov edx,[memoryloc] shr edx,16 mov al,dl mov edx,[memoryloc] add edx,8192 shr edx,16 mov dword[sbpmofs],0 cmp al,dl je .nonextarea mov dword[sbpmofs],8192 add dword[memoryloc],8192 .nonextarea mov edi,[sbpmofs] mov [SBBufferLoc],edi mov dword[SBBufferMov],1 mov dword[SBBufferInc],4 ; clear dos memory push es mov es,[sbselec] mov edi,[sbpmofs] mov ecx,2048 mov eax,0 rep stosd pop es %endif .nosound pop edx pop ecx pop ebx pop eax ret %ifdef __MSDOS__ .error mov edx,.nohand ;use extended mov ah,9 ;DOS- API int 21h ;to print a string call DosExit SECTION .data .nohand db 'Unable to allocate conventional memory!',13,10,'$' SECTION .text %endif NEWSYM InitSB %ifdef __MSDOS__ call initSB %endif ret NEWSYM DeInitSPC cmp byte[SBDeinitType],0 je .nodoublereset call ResetSBDSP call ResetSBDSP .nodoublereset ; Turn off speakers mov al,0d3h call WriteDSP ; k) Perform Halt DMA Operation, 8-bit command (0D0h - for virtual speaker) mov al,0d0h call WriteDSP ; l) Perform Exit Auto-Initialize DMA Operation, 8-bit command (0DAh) cmp byte[SBHDMA],0 je .8b mov al,0d9h call WriteDSP jmp .16b .8b mov al,0dAh call WriteDSP .16b ; m) Perform Halt DMA Operation, 8-bit command (0D0h - for virtual speaker) mov al,0d0h call WriteDSP ; Disable DMA mov al,4 add al,[SBDMA] mov dx,0ah out dx,al ret section .data ;SoundBlaster DSP Ports NEWSYM SBPort, dw 220 NEWSYM SBInt, db 5+8 NEWSYM SBIrq, db 5 NEWSYM SBDMA, db 1 NEWSYM SBDMAPage, db 83 NEWSYM SBHDMA, db 0 NEWSYM SBHDMAPage, db 0 NEWSYM vibracard, db 0 ; ViBRA16X fixes! EXTSYM MsgCount ; points to counter EXTSYM MessageOn ; points to "message" delay counter EXTSYM Msgptr ; points to the message to be displayed NEWSYM vibmsg, db 'VIBRA16X MODE ENABLED', 0 section .text NEWSYM ResetSBDSP mov dx,[SBPort] add dl,06h mov al,01h out dx,al in al,dx in al,dx in al,dx in al,dx mov al,00h out dx,al mov si,200 mov dx,[SBPort] add dl,0Eh .readloop ; wait until port[SBDSPRdStat] AND 80h = 80h mov cx,20000 .tryagain in al,dx dec cx jz .cardfailed or al,al jns .tryagain sub dx,4 in al,dx cmp al,0AAh jne .tryagain2 ret .tryagain2 add dx,4 dec si jnz .readloop .cardfailed mov ax,0003h int 10h mov edx,initfailed ;use extended mov ah,9 ;DOS- API int 21h ;to print a string jmp DosExit section .data NEWSYM initfailed, db 'Sound card failed to initialize!',13,10,'$' section .text ; Write AL into DSP port NEWSYM WriteDSP mov dx,[SBPort] add dl,0Ch mov bl,al .tryagain in al,dx test al,80h jnz .tryagain mov al,bl out dx,al ret ; Read DSP port into AL NEWSYM ReadDSP mov dx,[SBPort] add dl,0Eh mov bl,al .tryagain in al,dx test al,80h jz .tryagain mov dx,[SBPort] add dl,0Ah mov al,bl in al,dx ret ;**************************************************** ; Sound Blaster Interrupt Stuff ;**************************************************** NEWSYM Interror sti mov edx,.nohand ;use extended mov ah,9 ;DOS- API int 21h ;to print a string call DosExit section .data .nohand db 'Cannot process interrupt handler!',13,10,'$' SECTION .data NEWSYM oldhandSBs, dw 0 NEWSYM oldhandSBo, dd 0 NEWSYM SBswitch, db 0 ; which block to process next PSampleBuf times 26*8 dd 0 NEWSYM LPFsample1, dd 0 NEWSYM LPFsample2, dd 0 NEWSYM DLPFsamples, times 8*26 dd 0 section .text %macro ProcessA 0 shr al,4 %endmacro %macro ProcessB 0 and al,0Fh %endmacro %macro ProcessSample 1 xor eax,eax mov cl,[bshift] mov al,[esi] %1 test al,08h jz %%noneg or eax,0FFFFFFF0h %%noneg shl eax,cl mov edx,eax mov eax,[prev1] mov ebx,[filter1] imul eax,ebx sar eax,8 and eax,0fffffffeh add edx,eax mov eax,[prev0] mov ebx,[filter0] imul eax,ebx sar eax,8 and eax,0fffffffeh add edx,eax cmp dword [filter0],488 jne %%notfilter2 mov eax,[prev0] movsx eax,ax mov [prev1],eax mov eax,edx and eax,0fffffffeh mov [prev0],eax jmp %%skipclamp %%notfilter2 mov eax,[prev0] mov [prev1],eax cmp edx,-32768 jnl %%notless mov edx,-32768 mov byte[filteron],1 %%notless cmp edx,32767 jng %%notgreater mov edx,32767 mov byte[filteron],1 %%notgreater movsx edx,dx mov [prev0],edx %%skipclamp %endmacro %macro ProcessDynamicLowPass 0 mov ecx,[curvoice] mov edx, [Voice0Freq+ecx*4] cmp edx, dword 1000000h ja %%DLPF ret %%DLPF lea ebx,[ecx*4] lea ebx,[ebx*4] lea ecx,[ecx*4+ecx] lea ebx,[ecx*2+ebx] lea ebx,[DLPFsamples+ebx*4] cmp byte[LowPassFilterType],3 je near %%DLPF_fir ;dynamic mov eax,[ebx+21*4] mov [ebx],eax mov eax,[ebx+22*4] mov [ebx+1*4],eax mov eax,[ebx+23*4] mov [ebx+2*4],eax mov eax,[ebx+24*4] mov [ebx+3*4],eax mov eax,[ebx+25*4] mov [ebx+4*4],eax sub edi,32 movsx eax,word[edi+22] mov [ebx+21*4],eax movsx eax,word[edi+24] mov [ebx+22*4],eax movsx eax,word[edi+26] mov [ebx+23*4],eax movsx eax,word[edi+28] mov [ebx+24*4],eax movsx eax,word[edi+30] mov [ebx+25*4],eax mov ecx,16 shr edx,24 cmp dl,2 jle %%dlpf_by_2 cmp dl,3 jle %%dlpf_by_3 cmp dl,4 jle %%dlpf_by_4 jmp %%dlpf_by_5 %%dlpf_by_2 mov eax,[ebx+4*4] jmp Short %%dlpf_by_2_loop ALIGN16 %%dlpf_by_2_loop movsx edx,word[edi] add eax,edx sar eax,1 mov [edi],ax mov eax,edx add edi,2 dec ecx jnz %%dlpf_by_2_loop ret %%dlpf_by_3 mov eax,[ebx+3*4] mov ebp,[ebx+4*4] jmp Short %%dlpf_by_3_loop ALIGN16 %%dlpf_by_3_loop movsx ebx,word[edi] add eax,ebx add eax,ebp mov edx,55555555h ; (1/3) imul edx mov [edi],dx add edi,2 mov eax,ebp mov ebp,ebx dec ecx jnz %%dlpf_by_3_loop ret %%dlpf_by_4 mov eax,[ebx+2*4] mov edx,[ebx+3*4] mov ebp,[ebx+4*4] jmp Short %%dlpf_by_4_loop ALIGN16 %%dlpf_by_4_loop movsx ebx,word[edi] add eax,ebx add eax,edx add eax,ebp sar eax,2 mov [edi],ax add edi,2 mov eax,edx mov edx,ebp mov ebp,ebx dec ecx jnz %%dlpf_by_4_loop ret %%dlpf_by_5 push ecx mov eax,[ebx+1*4] mov esi,[ebx+2*4] mov ebp,[ebx+3*4] mov ecx,[ebx+4*4] jmp Short %%dlpf_by_5_loop ALIGN16 %%dlpf_by_5_loop movsx ebx,word[edi] add eax,ebx add eax,esi add eax,ebp add eax,ecx mov edx,33333333h ; 1/5 imul edx mov [edi],dx add edi,2 mov eax,esi mov esi,ebp mov ebp,ecx mov ecx,ebx dec dword [esp] jnz %%dlpf_by_5_loop pop ecx ret %%DLPF_fir mov eax,[ebx+21*4] mov [ebx],eax mov eax,[ebx+22*4] mov [ebx+4],eax mov eax,[ebx+23*4] mov [ebx+2*4],eax mov eax,[ebx+24*4] mov [ebx+3*4],eax mov eax,[ebx+25*4] mov [ebx+4*4],eax sub edi,32 movsx eax,word[edi] mov [ebx+5*4],eax movsx eax,word[edi+2] mov [ebx+6*4],eax movsx eax,word[edi+4] mov [ebx+7*4],eax movsx eax,word[edi+6] mov [ebx+8*4],eax movsx eax,word[edi+8] mov [ebx+9*4],eax movsx eax,word[edi+10] mov [ebx+10*4],eax movsx eax,word[edi+12] mov [ebx+11*4],eax movsx eax,word[edi+14] mov [ebx+12*4],eax movsx eax,word[edi+16] mov [ebx+13*4],eax movsx eax,word[edi+18] mov [ebx+14*4],eax movsx eax,word[edi+20] mov [ebx+15*4],eax movsx eax,word[edi+22] mov [ebx+16*4],eax mov [ebx+21*4],eax movsx eax,word[edi+24] mov [ebx+17*4],eax mov [ebx+22*4],eax movsx eax,word[edi+26] mov [ebx+18*4],eax mov [ebx+23*4],eax movsx eax,word[edi+28] mov [ebx+19*4],eax mov [ebx+24*4],eax movsx eax,word[edi+30] mov [ebx+20*4],eax mov [ebx+25*4],eax mov ecx,16 sub edx,0F80000h shr edx,15 and edx,7FFF0h add edx,fir_lut_co movq mm2,[edx] movq mm3,[edx+8] %%DLPF_fir_loop movq mm0,[ebx] packssdw mm0,[ebx+8] movq mm1,[ebx+16] packssdw mm1,[ebx+24] pmaddwd mm0,mm2 pmaddwd mm1,mm3 paddd mm0,mm1 movd edx,mm0 psrlq mm0,32 movd eax,mm0 add edx,eax sar edx,14 cmp edx,32767 jle %%DLPF_fir_clip mov edx,32767 %%DLPF_fir_clip cmp edx,-32768 jge %%DLPF_fir_clip2 mov edx,-32768 %%DLPF_fir_clip2 mov [edi],dx add edi,2 add ebx,4 dec ecx jnz %%DLPF_fir_loop emms ret %endmacro section .data NEWSYM lastblockbrr, times 8 dd 0 NEWSYM curvoice, dd 0 section .text BRRDecode: mov [curvoice],ecx mov byte[lastbl],0 mov byte[loopbl],0 cmp dword[esi],21FECD8Ah jne .notophack mov byte[VoiceNoiseEn+ecx],0 .notophack push ecx mov al,[esi] and al,0Ch cmp al,04h je .yesfilterb test al,0Ch jnz .skipfilter cmp byte[esi+9],88h jne .yesfilterb mov byte[VoiceNoiseEn+ecx],101 jmp .skipfilter .yesfilterb mov byte[VoiceNoiseEn+ecx],100 .skipfilter xor eax,eax mov al,[esi] test al,01h jz .nolast mov byte[lastbl],1 test al,02h jz .nolast mov byte[loopbl],1 .nolast mov cl,al and al,0Ch inc esi mov ebx,[Filter+eax*2] shr cl,4 mov [filter0],ebx mov ebx,[Filter+eax*2+4] push eax cmp cl,12 jbe .noprevblock mov eax,[curvoice] mov cl,[lastblockbrr+eax] .noprevblock mov [bshift],cl mov eax,[curvoice] mov [lastblockbrr+eax],cl pop eax mov [bshift],cl mov [filter1],ebx mov byte[sampleleft],8 mov byte[filteron],0 .nextsample ProcessSample ProcessA mov [edi],dx ProcessSample ProcessB mov [edi+2],dx add edi,4 inc esi dec byte[sampleleft] jnz near .nextsample pop ecx cmp byte[VoiceNoiseEn+ecx],10 je near .yesfilter cmp byte[VoiceNoiseEn+ecx],0 je .nofilter2 cmp byte[VoiceNoiseEn+ecx],10 jae .nofilter2 mov al,[esi-9] and al,0Ch cmp byte[esi-9],08h jb .nofilter2 inc byte[VoiceNoiseEn+ecx] .nofilter2 cmp byte[filteron],1 jne near .nofilter cmp byte[NoiseDisTemp+ecx],0 jne near .nofilter cmp byte[VoiceNoiseEn+ecx],100 je .strfilter cmp byte[VoiceNoiseEn+ecx],101 je .nofilter mov byte[VoiceNoiseEn+ecx],8 test byte[esi],01h jnz .nofilter mov byte[VoiceNoiseEn+ecx],9 test byte[esi+9],01h jnz .nofilter mov byte[VoiceNoiseEn+ecx],10 ;.nofilter ; ret jmp .nofilter .strfilter mov byte[VoiceNoiseEn+ecx],8 jmp .nofilter ; ret .yesfilter cmp byte[SoundNoiseDis],1 je .nofilter push ecx sub edi,32 mov ecx,8 mov ebx,[NoisePtr] .nloop mov ax,[NoiseData+ebx*2] inc ebx and ebx,1FFFh sar ax,1 mov word[edi],ax mov word[edi+2],ax add edi,4 dec ecx jnz .nloop mov [NoisePtr],ebx pop ecx ret .nofilter cmp byte[LowPassFilterType],1 ja .dlpf ret .dlpf ProcessDynamicLowPass section .data ;ALIGN=32 ALIGN32 ; Original Values NEWSYM EchoRateO dd 2,172,344,517,689,861,1033,1205,1378,1550,1722,1895, dd 2067,2239,2412,2584 NEWSYM AttackRateO dd 45202,28665,16537,11025,7056,4189,2866,1764,1058,705,441 dd 264,176,110,66,4 NEWSYM DecayRateO dd 13230,8158,4851,2697,2284,1212,815,407 NEWSYM SustainRateO dd 0FFFFFFFFh,418950,308700,265600,209475,154350,132300 dd 103635,78277,65047,51817,38587,31972,26460,19845,16537 dd 13230,9702,8158,6504,4851,3879,2697,2050 dd 1572,1212,1014,815,606,407,202,125 NEWSYM SustainValueO db 15,31,47,63,89,95,111,127 NEWSYM IncreaseO dd 0FFFFFFFFh,45202,34177,28665,22050,16537,14332,11025 dd 8489,7056,5622,4189,3528,2866,2094,1764 dd 1433,1058,882,705,529,441,352,264 dd 220,176,132,110,88,66,44,22 NEWSYM IncreaseBentO dd 0FFFFFFFFh,79100,59535,50160,38580,28665,25000,19250 dd 14332,12127,9800,7320,6160,4961,3650,3060 dd 2425,1845,1540,1212,920,770,614,460 dd 383,306,229,190,152,113,75,36 NEWSYM DecreaseO dd 0FFFFFFFFh,45202,34177,28665,22050,16537,14332,11025 dd 8489,7056,5622,4189,3528,2866,2094,1764 dd 1433,1058,882,705,529,441,352,264 dd 220,176,132,110,88,66,44,22 NEWSYM DecreaseRateExpO dd 0FFFFFFFFh,418950,308700,264600,209470,154350,132300,103635 dd 78277,65047,51817,38587,31972,26460,19845,16537 dd 13230,9702,8158,6504,4851,4079,3197,2425 dd 1984,1653,1212,1014,815,606,407,198 SECTION .data filteron dd 0 NoisePtr dd 0 ; used only in dspproc.asm SECTION .data Filter dd 0,0,240,0,488,-240,460,-208 SECTION .data prev0 dd 0 ; previous value 1 prev1 dd 0 ; previous value 2 nextsamp dd 0 ; next sample filter0 dd 0 ; filter 0 filter1 dd 0 ; filter 1 bshift dd 0 sampleleft dd 0 ; 8 bytes/sample lastbl dd 0 ; Last block if = 1 loopbl dd 0 ; Loop if = 1 usenoisedata dd 0 SECTION .data VolumeTableD db 0,3,6,9,12,15,17,18,19,21,22,23,24,24,26,28,30,31,33,35,36,38,40,41,43,45,46,48,49 db 51,52,54,56,57,58,60,61,63,64,66,67,68,70,71,72,74,75,76,78,79,80,81,82,84,85,86 db 87,88,89,90,91,92,93,94,96,96,97,98,99,100,101,102,103,104,105,106,106,107,108 db 109,110,110,111,112,112,113,114,114,115,116,116,117,117,118,118,119,120,120,120 db 121,121,122,122,123,123,123,124,124,124,125,125,125,126,126,126,126,126,127,127 db 127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128 db 128,129,129,129,129,129,130,130,130,131,131,131,132,132,132,133,133,134,134,135 db 135,135,136,137,137,138,138,139,139,140,141,141,142,143,143,144,145,145,146,147 db 148,149,149,150,151,152,153,154,155,156,157,158,159,159,161,162,163,164,165,166 db 167,168,169,170,171,173,174,175,176,177,179,180,181,183,184,185,187,188,189,191 db 192,194,195,197,198,199,201,203,204,206,207,209,210,212,214,215,217,219,220,222 db 224,225,227,229,231,231,232,233,234,236,237,238,240,243,246,249,252,255 db 0,1,3,5,7,9,11,13,15,17,19,21,22,24,26,28,30,31,33,35,36,38,40,41,43,45,46,48,49 db 51,52,54,56,57,58,60,61,63,64,66,67,68,70,71,72,74,75,76,78,79,80,81,82,84,85,86 db 87,88,89,90,91,92,93,94,96,96,97,98,99,100,101,102,103,104,105,106,106,107,108 db 109,110,110,111,112,112,113,114,114,115,116,116,117,117,118,118,119,120,120,120 db 121,121,122,122,123,123,123,124,124,124,125,125,125,126,126,126,126,126,127,127 db 127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128 db 128,129,129,129,129,129,130,130,130,131,131,131,132,132,132,133,133,134,134,135 db 135,135,136,137,137,138,138,139,139,140,141,141,142,143,143,144,145,145,146,147 db 148,149,149,150,151,152,153,154,155,156,157,158,159,159,161,162,163,164,165,166 db 167,168,169,170,171,173,174,175,176,177,179,180,181,183,184,185,187,188,189,191 db 192,194,195,197,198,199,201,203,204,206,207,209,210,212,214,215,217,219,220,222 db 224,225,227,229,231,233,234,236,238,240,242,244,246,248,250,252,254,255 NEWSYM VolumeTableb db 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,1Dh,1Eh,1Fh db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Ah,2Bh,2Ch,2Dh,2Eh,2Fh db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh db 40h,41h,42h,43h,44h,45h,46h,47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh db 50h,51h,52h,53h,54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,5Eh,5Fh db 60h,61h,62h,63h,64h,65h,66h,67h,68h,69h,6Ah,6Bh,6Ch,6Dh,6Eh,6Fh db 70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,7Fh db 7Fh,7Eh,7Dh,7Ch,7Bh,7Ah,79h,78h,77h,76h,75h,74h,73h,72h,71h,70h db 6Fh,6Eh,6Dh,6Ch,6Bh,6Ah,69h,68h,67h,66h,65h,64h,63h,62h,61h,60h db 5Fh,5Eh,5Dh,5Ch,5Bh,5Ah,59h,58h,57h,56h,55h,54h,53h,52h,51h,50h db 4Fh,4Eh,4Dh,4Ch,4Bh,4Ah,49h,48h,47h,46h,45h,44h,43h,42h,41h,40h db 3Fh,3Eh,3Dh,3Ch,3Bh,3Ah,39h,38h,37h,36h,35h,34h,33h,32h,31h,30h db 2Fh,2Eh,2Dh,2Ch,2Bh,2Ah,29h,28h,27h,26h,25h,24h,23h,22h,21h,20h db 1Fh,1Eh,1Dh,1Ch,1Bh,1Ah,19h,18h,17h,16h,15h,14h,13h,12h,11h,10h db 0Fh,0Eh,0Dh,0Ch,0Bh,0Ah,09h,08h,07h,06h,05h,04h,03h,02h,01h,00h ; appears to only be used in dspproc.asm ;VolumeTable: db 0,2,4,6,8,10,12,14,16,18 ; db 20,22,24,26,28,30,32,34,36,38 ; db 40,42,44,46,48,50,52,54,56,58 ; db 60,62,64,66,68,70,72,74,76,78 ; db 80,82,84,86,88,90,92,94,96,98 ; db 100,102,104,106,108,110,112,114,116,118 ; db 120,122,124,126,127,127,127,127,127,127 ;VolumeTable: db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127,127,127 ; db 127,127,127,127,127,127,127,127 ;VolumeTable db 1,1,2,3,4,5,6,7,8,9 ; db 10,11,12,13,14,15,16,17,18,19 ; db 20,21,22,23,24,25,26,27,28,29 ; db 30,31,32,33,34,35,36,37,38,39 ; db 40,41,42,43,44,45,46,47,48,49 ; db 50,51,52,53,54,55,46,57,58,59 ; db 60,61,62,63,64,65,56,67,68,69 ; db 70,71,72,73,74,75,66,77,78,79 ; db 80,81,82,83,84,85,76,87,88,89 ; db 90,91,92,93,94,95,86,97,98,99 ; db 100,101,102,103,104,105,106,107,108,109 ; db 110,111,112,113,114,115,116,117,118,119 ; db 120,121,122,123,124,125,126,127 ;VolumeTable db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1,1,1 ; db 1,1,1,1,1,1,1,1 SECTION .data ;ALIGN=32 NEWSYM DSPBuffer, times 320*4 dd 0; The play buffer... NEWSYM EchoBuffer, times 320*4 dd 0; The play buffer... NEWSYM PModBuffer, times 320*4 dd 0; The play buffer... NEWSYM BRRBuffer, times 32 db 0 ; The BRR Decode Buffer NEWSYM BRRPlace0, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp0, dd 0 ; Keep this 0 NEWSYM BRRPlace1, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp1, dd 0 ; Keep this 0 NEWSYM BRRPlace2, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp2, dd 0 ; Keep this 0 NEWSYM BRRPlace3, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp3, dd 0 ; Keep this 0 NEWSYM BRRPlace4, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp4, dd 0 ; Keep this 0 NEWSYM BRRPlace5, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp5, dd 0 ; Keep this 0 NEWSYM BRRPlace6, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp6, dd 0 ; Keep this 0 NEWSYM BRRPlace7, dd 0 ; Place in the BRRBuffer for Voice 0 NEWSYM BRRTemp7, dd 0 ; Keep this 0 ;NEWSYM Voice0Freq, dd 1 ; Frequency of Voice 0 (Delta Freq) ;NEWSYM Voice1Freq, dd 1 ; Frequency of Voice 1 (Delta Freq) ;NEWSYM Voice2Freq, dd 1 ; Frequency of Voice 2 (Delta Freq) ;NEWSYM Voice3Freq, dd 1 ; Frequency of Voice 3 (Delta Freq) ;NEWSYM Voice4Freq, dd 1 ; Frequency of Voice 4 (Delta Freq) ;NEWSYM Voice5Freq, dd 1 ; Frequency of Voice 5 (Delta Freq) ;NEWSYM Voice6Freq, dd 1 ; Frequency of Voice 6 (Delta Freq) ;NEWSYM Voice7Freq, dd 1 ; Frequency of Voice 7 (Delta Freq) NEWSYM Voice0Freq, dd 0 ; Frequency of Voice 0 (Delta Freq) NEWSYM Voice1Freq, dd 0 ; Frequency of Voice 1 (Delta Freq) NEWSYM Voice2Freq, dd 0 ; Frequency of Voice 2 (Delta Freq) NEWSYM Voice3Freq, dd 0 ; Frequency of Voice 3 (Delta Freq) NEWSYM Voice4Freq, dd 0 ; Frequency of Voice 4 (Delta Freq) NEWSYM Voice5Freq, dd 0 ; Frequency of Voice 5 (Delta Freq) NEWSYM Voice6Freq, dd 0 ; Frequency of Voice 6 (Delta Freq) NEWSYM Voice7Freq, dd 0 ; Frequency of Voice 7 (Delta Freq) ; appears to only be used in dspproc.asm ;Voice0Pitch dw 1 ; Previous Pitch for Voice 0 ;Voice1Pitch dw 1 ; Previous Pitch for Voice 1 ;Voice2Pitch dw 1 ; Previous Pitch for Voice 2 ;Voice3Pitch dw 1 ; Previous Pitch for Voice 3 ;Voice4Pitch dw 1 ; Previous Pitch for Voice 4 ;Voice5Pitch dw 1 ; Previous Pitch for Voice 5 ;Voice6Pitch dw 1 ; Previous Pitch for Voice 6 ;Voice7Pitch dw 1 ; Previous Pitch for Voice 7 Voice0Pitch dw 0 ; Previous Pitch for Voice 0 Voice1Pitch dw 0 ; Previous Pitch for Voice 1 Voice2Pitch dw 0 ; Previous Pitch for Voice 2 Voice3Pitch dw 0 ; Previous Pitch for Voice 3 Voice4Pitch dw 0 ; Previous Pitch for Voice 4 Voice5Pitch dw 0 ; Previous Pitch for Voice 5 Voice6Pitch dw 0 ; Previous Pitch for Voice 6 Voice7Pitch dw 0 ; Previous Pitch for Voice 7 NEWSYM Voice0Status, db 0 ; 0=Not Playing 1=Playing NEWSYM Voice1Status, db 0 NEWSYM Voice2Status, db 0 NEWSYM Voice3Status, db 0 NEWSYM Voice4Status, db 0 NEWSYM Voice5Status, db 0 NEWSYM Voice6Status, db 0 NEWSYM Voice7Status, db 0 NEWSYM Voice0Ptr, dd 0 ; Ptr to Next BRR Block to be played NEWSYM Voice1Ptr, dd 0 NEWSYM Voice2Ptr, dd 0 NEWSYM Voice3Ptr, dd 0 NEWSYM Voice4Ptr, dd 0 NEWSYM Voice5Ptr, dd 0 NEWSYM Voice6Ptr, dd 0 NEWSYM Voice7Ptr, dd 0 NEWSYM Voice0LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice1LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice2LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice3LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice4LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice5LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice6LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice7LoopPtr, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice0BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice1BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice2BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice3BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice4BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice5BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice6BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice7BufPtr, dd 0 ; Ptr to Buffer Block to be played NEWSYM SoundCounter, dd 0 ; Counter used for sound generation NEWSYM SoundCounter2, dd 0 ; Counter used for sound generation NEWSYM Voice0Prev0, dd 0 NEWSYM Voice1Prev0, dd 0 NEWSYM Voice2Prev0, dd 0 NEWSYM Voice3Prev0, dd 0 NEWSYM Voice4Prev0, dd 0 NEWSYM Voice5Prev0, dd 0 NEWSYM Voice6Prev0, dd 0 NEWSYM Voice7Prev0, dd 0 NEWSYM Voice0Prev1, dd 0 NEWSYM Voice1Prev1, dd 0 NEWSYM Voice2Prev1, dd 0 NEWSYM Voice3Prev1, dd 0 NEWSYM Voice4Prev1, dd 0 NEWSYM Voice5Prev1, dd 0 NEWSYM Voice6Prev1, dd 0 NEWSYM Voice7Prev1, dd 0 NEWSYM Voice0Loop, db 0 NEWSYM Voice1Loop, db 0 NEWSYM Voice2Loop, db 0 NEWSYM Voice3Loop, db 0 NEWSYM Voice4Loop, db 0 NEWSYM Voice5Loop, db 0 NEWSYM Voice6Loop, db 0 NEWSYM Voice7Loop, db 0 NEWSYM Voice0End, db 0 NEWSYM Voice1End, db 0 NEWSYM Voice2End, db 0 NEWSYM Voice3End, db 0 NEWSYM Voice4End, db 0 NEWSYM Voice5End, db 0 NEWSYM Voice6End, db 0 NEWSYM Voice7End, db 0 ;NEWSYM Voice0Noise, db 1 ;NEWSYM Voice1Noise, db 1 ;NEWSYM Voice2Noise, db 1 ;NEWSYM Voice3Noise, db 1 ;NEWSYM Voice4Noise, db 1 ;NEWSYM Voice5Noise, db 1 ;NEWSYM Voice6Noise, db 1 ;NEWSYM Voice7Noise, db 1 NEWSYM Voice0Noise, db 0 NEWSYM Voice1Noise, db 0 NEWSYM Voice2Noise, db 0 NEWSYM Voice3Noise, db 0 NEWSYM Voice4Noise, db 0 NEWSYM Voice5Noise, db 0 NEWSYM Voice6Noise, db 0 NEWSYM Voice7Noise, db 0 NEWSYM Voice0Volume, db 0 NEWSYM Voice1Volume, db 0 NEWSYM Voice2Volume, db 0 NEWSYM Voice3Volume, db 0 NEWSYM Voice4Volume, db 0 NEWSYM Voice5Volume, db 0 NEWSYM Voice6Volume, db 0 NEWSYM Voice7Volume, db 0 NEWSYM Voice0VolumeR, db 0 NEWSYM Voice1VolumeR, db 0 NEWSYM Voice2VolumeR, db 0 NEWSYM Voice3VolumeR, db 0 NEWSYM Voice4VolumeR, db 0 NEWSYM Voice5VolumeR, db 0 NEWSYM Voice6VolumeR, db 0 NEWSYM Voice7VolumeR, db 0 NEWSYM Voice0VolumeL, db 0 NEWSYM Voice1VolumeL, db 0 NEWSYM Voice2VolumeL, db 0 NEWSYM Voice3VolumeL, db 0 NEWSYM Voice4VolumeL, db 0 NEWSYM Voice5VolumeL, db 0 NEWSYM Voice6VolumeL, db 0 NEWSYM Voice7VolumeL, db 0 ;NEWSYM Voice0Env, db 1 ;NEWSYM Voice1Env, db 1 ;NEWSYM Voice2Env, db 1 ;NEWSYM Voice3Env, db 1 ;NEWSYM Voice4Env, db 1 ;NEWSYM Voice5Env, db 1 ;NEWSYM Voice6Env, db 1 ;NEWSYM Voice7Env, db 1 NEWSYM Voice0Env, db 0 NEWSYM Voice1Env, db 0 NEWSYM Voice2Env, db 0 NEWSYM Voice3Env, db 0 NEWSYM Voice4Env, db 0 NEWSYM Voice5Env, db 0 NEWSYM Voice6Env, db 0 NEWSYM Voice7Env, db 0 NEWSYM Voice0Out, db 0 NEWSYM Voice1Out, db 0 NEWSYM Voice2Out, db 0 NEWSYM Voice3Out, db 0 NEWSYM Voice4Out, db 0 NEWSYM Voice5Out, db 0 NEWSYM Voice6Out, db 0 NEWSYM Voice7Out, db 0 ; 1 Attack, 2 Decrease,3 Sustain, 0 Gain NEWSYM Voice0State, db 0 NEWSYM Voice1State, db 0 NEWSYM Voice2State, db 0 NEWSYM Voice3State, db 0 NEWSYM Voice4State, db 0 NEWSYM Voice5State, db 0 NEWSYM Voice6State, db 0 NEWSYM Voice7State, db 0 ; WAS all dd 1 before, down to next applicable comment NEWSYM Voice0Time, dd 0 NEWSYM Voice1Time, dd 0 NEWSYM Voice2Time, dd 0 NEWSYM Voice3Time, dd 0 NEWSYM Voice4Time, dd 0 NEWSYM Voice5Time, dd 0 NEWSYM Voice6Time, dd 0 NEWSYM Voice7Time, dd 0 NEWSYM Voice0Attack, dd 0 NEWSYM Voice1Attack, dd 0 NEWSYM Voice2Attack, dd 0 NEWSYM Voice3Attack, dd 0 NEWSYM Voice4Attack, dd 0 NEWSYM Voice5Attack, dd 0 NEWSYM Voice6Attack, dd 0 NEWSYM Voice7Attack, dd 0 NEWSYM Voice0Decay, dd 0 NEWSYM Voice1Decay, dd 0 NEWSYM Voice2Decay, dd 0 NEWSYM Voice3Decay, dd 0 NEWSYM Voice4Decay, dd 0 NEWSYM Voice5Decay, dd 0 NEWSYM Voice6Decay, dd 0 NEWSYM Voice7Decay, dd 0 NEWSYM Voice0SustainL, db 0 NEWSYM Voice1SustainL, db 0 NEWSYM Voice2SustainL, db 0 NEWSYM Voice3SustainL, db 0 NEWSYM Voice4SustainL, db 0 NEWSYM Voice5SustainL, db 0 NEWSYM Voice6SustainL, db 0 NEWSYM Voice7SustainL, db 0 NEWSYM Voice0SustainL2, db 0 NEWSYM Voice1SustainL2, db 0 NEWSYM Voice2SustainL2, db 0 NEWSYM Voice3SustainL2, db 0 NEWSYM Voice4SustainL2, db 0 NEWSYM Voice5SustainL2, db 0 NEWSYM Voice6SustainL2, db 0 NEWSYM Voice7SustainL2, db 0 NEWSYM Voice0SustainR, dd 0 NEWSYM Voice1SustainR, dd 0 NEWSYM Voice2SustainR, dd 0 NEWSYM Voice3SustainR, dd 0 NEWSYM Voice4SustainR, dd 0 NEWSYM Voice5SustainR, dd 0 NEWSYM Voice6SustainR, dd 0 NEWSYM Voice7SustainR, dd 0 NEWSYM Voice0SustainR2, dd 0 NEWSYM Voice1SustainR2, dd 0 NEWSYM Voice2SustainR2, dd 0 NEWSYM Voice3SustainR2, dd 0 NEWSYM Voice4SustainR2, dd 0 NEWSYM Voice5SustainR2, dd 0 NEWSYM Voice6SustainR2, dd 0 NEWSYM Voice7SustainR2, dd 0 NEWSYM Voice0IncNumber, dd 0 NEWSYM Voice1IncNumber, dd 0 NEWSYM Voice2IncNumber, dd 0 NEWSYM Voice3IncNumber, dd 0 NEWSYM Voice4IncNumber, dd 0 NEWSYM Voice5IncNumber, dd 0 NEWSYM Voice6IncNumber, dd 0 NEWSYM Voice7IncNumber, dd 0 ; END formerly initialized to 1 junk NEWSYM Voice0SLenNumber, dd 0 NEWSYM Voice1SLenNumber, dd 0 NEWSYM Voice2SLenNumber, dd 0 NEWSYM Voice3SLenNumber, dd 0 NEWSYM Voice4SLenNumber, dd 0 NEWSYM Voice5SLenNumber, dd 0 NEWSYM Voice6SLenNumber, dd 0 NEWSYM Voice7SLenNumber, dd 0 NEWSYM Voice0SEndNumber, dd 0 NEWSYM Voice1SEndNumber, dd 0 NEWSYM Voice2SEndNumber, dd 0 NEWSYM Voice3SEndNumber, dd 0 NEWSYM Voice4SEndNumber, dd 0 NEWSYM Voice5SEndNumber, dd 0 NEWSYM Voice6SEndNumber, dd 0 NEWSYM Voice7SEndNumber, dd 0 NEWSYM Voice0SEndLNumber, dd 0 NEWSYM Voice1SEndLNumber, dd 0 NEWSYM Voice2SEndLNumber, dd 0 NEWSYM Voice3SEndLNumber, dd 0 NEWSYM Voice4SEndLNumber, dd 0 NEWSYM Voice5SEndLNumber, dd 0 NEWSYM Voice6SEndLNumber, dd 0 NEWSYM Voice7SEndLNumber, dd 0 ; MORE junk that was initialized to 1 NEWSYM Voice0DecreaseNumber, dd 0 NEWSYM Voice1DecreaseNumber, dd 0 NEWSYM Voice2DecreaseNumber, dd 0 NEWSYM Voice3DecreaseNumber, dd 0 NEWSYM Voice4DecreaseNumber, dd 0 NEWSYM Voice5DecreaseNumber, dd 0 NEWSYM Voice6DecreaseNumber, dd 0 NEWSYM Voice7DecreaseNumber, dd 0 NEWSYM Voice0EnvInc, dd 0 NEWSYM Voice1EnvInc, dd 0 NEWSYM Voice2EnvInc, dd 0 NEWSYM Voice3EnvInc, dd 0 NEWSYM Voice4EnvInc, dd 0 NEWSYM Voice5EnvInc, dd 0 NEWSYM Voice6EnvInc, dd 0 NEWSYM Voice7EnvInc, dd 0 ; END initialized to 1 junk ; 0 = Direct, 1 = Increase, 2 = Increase2, 3 = Decrease, 4 = Decrease2 NEWSYM Voice0GainType, db 0 NEWSYM Voice1GainType, db 0 NEWSYM Voice2GainType, db 0 NEWSYM Voice3GainType, db 0 NEWSYM Voice4GainType, db 0 NEWSYM Voice5GainType, db 0 NEWSYM Voice6GainType, db 0 NEWSYM Voice7GainType, db 0 ; YET ANOTHER block that was initialized to 1 NEWSYM Voice0GainTime, dd 0 NEWSYM Voice1GainTime, dd 0 NEWSYM Voice2GainTime, dd 0 NEWSYM Voice3GainTime, dd 0 NEWSYM Voice4GainTime, dd 0 NEWSYM Voice5GainTime, dd 0 NEWSYM Voice6GainTime, dd 0 NEWSYM Voice7GainTime, dd 0 ; END that block NEWSYM Voice0Starting, db 0 NEWSYM Voice1Starting, db 0 NEWSYM Voice2Starting, db 0 NEWSYM Voice3Starting, db 0 NEWSYM Voice4Starting, db 0 NEWSYM Voice5Starting, db 0 NEWSYM Voice6Starting, db 0 NEWSYM Voice7Starting, db 0 NEWSYM Freqdisp, dd 0 NEWSYM SBRateb, dd 0 NEWSYM Voice0Looped, db 0 NEWSYM Voice1Looped, db 0 NEWSYM Voice2Looped, db 0 NEWSYM Voice3Looped, db 0 NEWSYM Voice4Looped, db 0 NEWSYM Voice5Looped, db 0 NEWSYM Voice6Looped, db 0 NEWSYM Voice7Looped, db 0 VoiceNoiseEn times 8 db 0 NEWSYM GainDecBendDataPos, times 8 db 0 NEWSYM GainDecBendDataTime, times 8 dd 0 NEWSYM GainDecBendDataDat, times 8 db 0 NEWSYM AdsrBlocksLeft, times 8 db 0 NEWSYM AdsrNextTimeDepth, times 8 dd 0 TimeTemp times 8 dd 0 ; 104 bytes IncNTemp times 8 dd 0 EnvITemp times 8 dd 0 StatTemp times 2 dd 0 NEWSYM FutureExpand, times 44 db 0 ; pharos equ hack *sigh* marksave: NEWSYM echoon0, db 0 NEWSYM echoon1, db 0 NEWSYM echoon2, db 0 NEWSYM echoon3, db 0 NEWSYM echoon4, db 0 NEWSYM echoon5, db 0 NEWSYM echoon6, db 0 NEWSYM echoon7, db 0 NEWSYM GlobalVL, dd 0 NEWSYM GlobalVR, dd 0 NEWSYM EchoVL, dd 0 NEWSYM EchoVR, dd 0 NEWSYM EchoT, dd 0 NEWSYM Voice0Volumee, db 0 NEWSYM Voice1Volumee, db 0 NEWSYM Voice2Volumee, db 0 NEWSYM Voice3Volumee, db 0 NEWSYM Voice4Volumee, db 0 NEWSYM Voice5Volumee, db 0 NEWSYM Voice6Volumee, db 0 NEWSYM Voice7Volumee, db 0 NEWSYM Voice0VolumeRe, db 0 NEWSYM Voice1VolumeRe, db 0 NEWSYM Voice2VolumeRe, db 0 NEWSYM Voice3VolumeRe, db 0 NEWSYM Voice4VolumeRe, db 0 NEWSYM Voice5VolumeRe, db 0 NEWSYM Voice6VolumeRe, db 0 NEWSYM Voice7VolumeRe, db 0 NEWSYM Voice0VolumeLe, db 0 NEWSYM Voice1VolumeLe, db 0 NEWSYM Voice2VolumeLe, db 0 NEWSYM Voice3VolumeLe, db 0 NEWSYM Voice4VolumeLe, db 0 NEWSYM Voice5VolumeLe, db 0 NEWSYM Voice6VolumeLe, db 0 NEWSYM Voice7VolumeLe, db 0 NEWSYM FIRTAPVal0, dd 0 NEWSYM FIRTAPVal1, dd 0 NEWSYM FIRTAPVal2, dd 0 NEWSYM FIRTAPVal3, dd 0 NEWSYM FIRTAPVal4, dd 0 NEWSYM FIRTAPVal5, dd 0 NEWSYM FIRTAPVal6, dd 0 NEWSYM FIRTAPVal7, dd 0 SECTION .data NEWSYM MaxEcho, dd 172 SECTION .data NEWSYM CEchoPtr, dd 0 NEWSYM EchoFB, dd 0 NEWSYM Voice0Ptre, dd 0 ; Ptr to Next BRR Block to be played NEWSYM Voice1Ptre, dd 0 NEWSYM Voice2Ptre, dd 0 NEWSYM Voice3Ptre, dd 0 NEWSYM Voice4Ptre, dd 0 NEWSYM Voice5Ptre, dd 0 NEWSYM Voice6Ptre, dd 0 NEWSYM Voice7Ptre, dd 0 NEWSYM Voice0LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice1LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice2LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice3LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice4LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice5LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice6LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice7LoopPtre, dd 0 ; Ptr to Loop BRR Block to be played NEWSYM Voice0BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice1BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice2BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice3BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice4BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice5BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice6BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM Voice7BufPtre, dd 0 ; Ptr to Buffer Block to be played NEWSYM CurFiltPtr, dd 0 NEWSYM FiltLoop, times 16 dd 0 NEWSYM FiltLoopR, times 16 dd 0 NEWSYM SoundLooped0, db 0 NEWSYM SoundLooped1, db 0 NEWSYM SoundLooped2, db 0 NEWSYM SoundLooped3, db 0 NEWSYM SoundLooped4, db 0 NEWSYM SoundLooped5, db 0 NEWSYM SoundLooped6, db 0 NEWSYM SoundLooped7, db 0 NEWSYM UniqueSoundv, dd 0 SECTION .data ; |AR Time 0 to 1|DR|Time 1 to SL|SL|Ratio| SR Time 1to 1/10| ;--------------------------------------------------------------------- ; |0 | 4.1 sec | 0| 1.2 sec | 0| 1/8 | 0| INF |10|1.2 sec ; |1 | 2.6 | 1| 740 msec | 1| 2/8 | 1| 38 |11|880 msec ; |2 | 1.5 | 2| 440 | 2| 3/8 | 2| 28 |12|740 ; |3 | 1.0 | 3| 290 | 3| 4/8 | 3| 24 |13|590 ; |4 |640 msec | 4| 180 | 4| 5/8 | 4| 19 |14|440 ; |5 |380 | 5| 110 | 5| 6/8 | 5| 14 |15|370 ; |6 |260 | 6| 74 | 6| 7/8 | 6| 12 |16|290 ; |7 |160 | 7| 37 | 7| 1 | 7| 9.4 |17|220 ; |8 | 96 -------------------------- 8| 7.1 |18|180 ; |9 | 64 | | 9| 5.9 |19|150 ; |A | 40 | | A| 4.7 |1A|110 ; |B | 24 | | B| 3.5 |1B| 92 ; |C | 16 | | C| 2.9 |1C| 74 ; |D | 10 | | D| 2.4 |1D| 55 ; |E | 6 | | E| 1.8 |1E| 37 ; |F | 0 | | F| 1.5 |1F| 28 ; --------------- --------------------------- ; All the values are in 1/11025 NEWSYM EchoRate dd 2,172,344,517,689,861,1033,1205,1378,1550,1722,1895, dd 2067,2239,2412,2584 NEWSYM AttackRate dd 45202,28665,16537,11025,7056,4189,2866,1764,1058,705,441 dd 264,176,110,66,4 NEWSYM DecayRate dd 13230,8158,4851,2697,1984,815,407,125 NEWSYM SustainRate dd 0FFFFFFFFh,418950,308700,265600,209475,154350,132300 dd 103635,78277,65047,51817,38587,31972,26460,19845,16537 dd 13230,9702,8158,6504,4851,3879,2697,1450 dd 1212,1014,815,606,407,202,125,70 NEWSYM SustainValue db 15,31,47,63,89,95,111,127 NEWSYM Increase dd 0FFFFFFFFh,45202,34177,28665,22050,16537,14332,11025 dd 8489,7056,5622,4189,3528,2866,2094,1764 dd 1433,1058,882,705,529,441,352,264 dd 220,176,132,110,88,66,44,22 NEWSYM IncreaseBent dd 0FFFFFFFFh,79100,59535,50160,38580,28665,25000,19250 dd 14332,12127,9800,7320,6160,4961,3650,3060 dd 2425,1845,1540,1212,920,770,614,460 dd 383,306,229,190,152,113,75,36 NEWSYM Decrease dd 0FFFFFFFFh,45202,34177,28665,22050,16537,14332,11025 dd 8489,7056,5622,4189,3528,2866,2094,1764 dd 1433,1058,882,705,529,441,352,264 dd 220,176,132,110,88,66,44,22 NEWSYM DecreaseRateExp dd 0FFFFFFFFh,418950,308700,264600,209470,154350,132300,103635 dd 78277,65047,51817,38587,31972,26460,19845,16537 dd 13230,9702,8158,6504,4851,4079,3197,2425 dd 1984,1653,1212,1014,815,606,407,198 GainDecBendData db 118,110,102,95,89,83,77,72,67,62,58,54,50,47,44,41,38,35 db 33,30,28,26,24,23,21,20,18,17,16,15,14,13 db 12,11,10,9,9,8,7,7,6,6,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1 db 255 AdsrBendData db 122,118,114,110,106,102,99,95,92,89,86,83,80,77,74,72,69,67 db 64,62,60,58,56,54,52,50,48,47,45,44,42,41,39,38,36,35,34,33 db 32,30,29,28,27,26,25,24,24,23,22,21,20,20,19,18,18,17,16,16 db 15,15,14,14,13,13,12,12,11,11,11,10,10,9,9,9,8,8,8,7,7,7,7,6 db 6,6,6,5,5,5,5,5,4,4,4,4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2 db 2,2,1,1,1,1,1,1,1,1,1,1,1,1,255 NEWSYM AdsrSustLevLoc, db 58,39,27,19,13,8,3,1 dspsave equ marksave-BRRBuffer dspconvb equ marksave-Voice0Freq NEWSYM PHdspsave, dd dspsave NEWSYM PHdspconvb, dd dspconvb section .text NEWSYM PrepareSaveState push edi mov edi,[Voice0BufPtr] sub edi,[spcBuffera] mov [Voice0BufPtr],edi mov edi,[Voice1BufPtr] sub edi,[spcBuffera] mov [Voice1BufPtr],edi mov edi,[Voice2BufPtr] sub edi,[spcBuffera] mov [Voice2BufPtr],edi mov edi,[Voice3BufPtr] sub edi,[spcBuffera] mov [Voice3BufPtr],edi mov edi,[Voice4BufPtr] sub edi,[spcBuffera] mov [Voice4BufPtr],edi mov edi,[Voice5BufPtr] sub edi,[spcBuffera] mov [Voice5BufPtr],edi mov edi,[Voice6BufPtr] sub edi,[spcBuffera] mov [Voice6BufPtr],edi mov edi,[Voice7BufPtr] sub edi,[spcBuffera] mov [Voice7BufPtr],edi pop edi ret %macro ResState 1 mov edi,%1 add edi,[spcBuffera] mov eax,[spcBuffera] add eax,65536*4 cmp edi,eax jb %%noof mov edi,[spcBuffera] %%noof mov %1,edi %endmacro NEWSYM ResetState push edi ResState [Voice0BufPtr] ResState [Voice1BufPtr] ResState [Voice2BufPtr] ResState [Voice3BufPtr] ResState [Voice4BufPtr] ResState [Voice5BufPtr] ResState [Voice6BufPtr] ResState [Voice7BufPtr] pop edi ret ;VolumeConvTable times 32768 db 0 SECTION .data ;ALIGN=32 spc700temp times 2 dd 0 SECTION .text %macro VoiceStart 2 mov dword[spc700temp+4],0 cmp byte[Voice0Status+%1],0 je .moveon push eax mov eax,[Voice0EnvInc+%1*4] mov [spc700temp],eax mov dword[spc700temp+4],1 pop eax .moveon mov byte[Voice0Status+%1],0 push eax push ebx push edx mov eax,[DSPMem+%1*10h] cmp al,40h jae .noskip cmp ah,40h jae .noskip mov eax,[DSPMem+%1*10h+4] cmp eax,0050FF07h jne .noskip cmp byte[DSPMem+5Dh],6 jne .noskip mov byte[DSPMem+%1*10h],15 mov byte[DSPMem+%1*10h+1],15 pop edx pop ebx pop eax ret .noskip ; Check if adsr or gain test byte[DSPMem+05h+%1*10h],80h jz near .gain ; Calculate attack rate xor eax,eax mov al,[DSPMem+05h+%1*10h] and al,0Fh cmp eax,0Fh je .skipattack mov ebx,dword [AttackRate+eax*4] mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],8 mov dword[Voice0EnvInc+%1*4],0 mov byte[GainDecBendDataDat+%1],7Fh mov byte[Voice0Status+%1],1 jmp .finproc .skipattack mov al,[DSPMem+05h+%1*10h] shr al,4 and eax,07h mov edx,[DecayRate+eax*4] xor eax,eax mov al,[DSPMem+06h+%1*10h] and al,1Fh mov ebx,[SustainRate+eax*4] cmp edx,ebx jae near .decayover ; ebx = total sustain time xor eax,eax mov al,[DSPMem+06h+%1*10h] shr al,5 mov al,[AdsrSustLevLoc+eax] ; traverse through al entries in edx time ; then through 64-al entries in ebx-edx time mov [AdsrBlocksLeft+%1],al sub ebx,edx push ebx push eax mov ebx,eax mov eax,edx xor edx,edx div ebx mov [Voice0Time+%1*4],eax mov [GainDecBendDataTime+%1*4],eax pop eax pop ebx mov edx,ebx mov ebx,64 sub bl,al mov eax,edx xor edx,edx div ebx mov [AdsrNextTimeDepth+%1*4],eax mov dword[Voice0EnvInc+%1*4],007FFFFFh mov ebx,[Voice0Time+%1*4] xor edx,edx mov eax,127*65536 sub eax,122*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],9 mov byte[Voice0Status+%1],1 jmp .finproc .decayover sub edx,ebx push ebx mov eax,edx xor ebx,ebx mov bl,[DSPMem+06h+%1*10h] shr bl,5 xor bl,07h mul ebx mov ebx,7 div ebx pop ebx add ebx,eax mov dword[Voice0EnvInc+%1*4],007FFFFFh shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov eax,127*65536 sub eax,118*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],7 mov byte[Voice0Status+%1],1 jmp .finproc .gain test byte [DSPMem+07h+%1*10h],80h jz near .Direct test byte [DSPMem+07h+%1*10h],40h jnz near .Increase test byte [DSPMem+07h+%1*10h],20h jz near .LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[DecreaseRateExp+eax*4] mov dword[Voice0EnvInc+%1*4],007FFFFFh shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov eax,127*65536 sub eax,118*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],7 mov byte[Voice0Status+%1],1 jmp .finproc .LinearDec xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Decrease+eax*4] mov dword[Voice0EnvInc+%1*4],007FFFFFh mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],5 mov byte[Voice0Status+%1],1 jmp .finproc .Increase test byte [DSPMem+07h+%1*10h],20h jz .LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx mov dword [Voice0IncNumber+%1*4],eax mov ebx,[Voice0Time+%1*4] mov eax,ebx shr eax,2 sub ebx,eax dec ebx mov [Voice0Time+%1*4],ebx mov byte [Voice0State+%1],6 mov byte[Voice0Status+%1],1 jmp .finproc .LinearInc xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0Time+%1*4],ebx xor edx,edx mov eax,127*65536 div ebx mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],3 mov byte[Voice0Status+%1],1 jmp .finproc .Direct mov al,[DSPMem+07h+%1*10h] and al,7Fh mov dword[Voice0EnvInc+%1*4],0 mov byte [Voice0EnvInc+%1*4+2],al mov dword [Voice0Time+%1*4],0FFFFFFFFh mov dword [Voice0IncNumber+%1*4],0 mov byte [Voice0State+%1],4 mov byte[Voice0Status+%1],1 jmp .finproc .finproc cmp dword[spc700temp+4],0 je .skipall mov eax,dword[Voice0Time+%1*4] mov [TimeTemp+%1*4],eax mov eax,dword[Voice0IncNumber+%1*4] mov [IncNTemp+%1*4],eax mov eax,dword[Voice0EnvInc+%1*4] mov [EnvITemp+%1*4],eax mov al,[Voice0State+%1] mov [StatTemp+%1],al mov eax,[spc700temp] mov [Voice0EnvInc+%1*4],eax mov dword[Voice0Time+%1*4],127 shr eax,7 neg eax mov dword[Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],210 jmp .novoice .skipall mov ax,[DSPMem+02h+%1*10h] cmp word[Voice0Pitch+%1*2],ax je .nopitchc mov word[Voice0Pitch+%1*2],ax xor ebx,ebx xor edx,edx and eax,03FFFh shl eax,2 mov dl,ah shl eax,24 mov ebx,[SBToSPC] div ebx shl eax,1 mov [Voice0Freq+%1*4],eax ; modpitch .nopitchc mov dword[BRRPlace0+%1*8],10000000h mov dword [Voice0Prev0+%1*4],0 mov dword [Voice0Prev1+%1*4],0 mov byte [Voice0End+%1],0 mov byte [Voice0Loop+%1],0 mov byte[VoiceNoiseEn+%1],0 mov dword[WaveIndex+%1*4],0 mov dword[PSampleBuf+%1*26*4+21*4],0 mov dword[PSampleBuf+%1*26*4+22*4],0 mov dword[PSampleBuf+%1*26*4+23*4],0 mov dword[PSampleBuf+%1*26*4+24*4],0 mov dword[PSampleBuf+%1*26*4+25*4],0 mov byte[SoundLooped0+%1],0 mov byte[echoon0+%1],0 test byte[DSPMem+4Dh],%2 jz .noecho mov byte[echoon0+%1],1 .noecho .novoice mov edx,[DSPMem+04h+%1*10h] and edx,0ffh shl edx,2 xor eax,eax mov ah,[DSPMem+5Dh] add ax,dx xor ebx,ebx mov bx,[spcRam+eax] mov dword[Voice0Ptr+%1*4],ebx xor ebx,ebx mov bx,[spcRam+eax+2] mov dword[Voice0LoopPtr+%1*4],ebx pop edx pop ebx pop eax ret %endmacro NEWSYM Voice0Start VoiceStart 0,1 ret NEWSYM Voice1Start VoiceStart 1,2 ret NEWSYM Voice2Start VoiceStart 2,4 ret NEWSYM Voice3Start VoiceStart 3,8 ret NEWSYM Voice4Start VoiceStart 4,16 ret NEWSYM Voice5Start VoiceStart 5,32 ret NEWSYM Voice6Start VoiceStart 6,64 ret NEWSYM Voice7Start VoiceStart 7,128 ret ; mov byte[Voice0Env+%1],3Fh ; jmp .Adsr ; Pass both voice # and next function name %macro VoiceStarterM 1 cmp al,%1 jne near %%nope push edx mov eax,[TimeTemp+%1*4] mov [Voice0Time+%1*4],eax mov eax,[IncNTemp+%1*4] mov [Voice0IncNumber+%1*4],eax mov eax,[EnvITemp+%1*4] mov [Voice0EnvInc+%1*4],eax mov al,[StatTemp+%1] mov [Voice0State+%1],al mov byte[SoundLooped0+%1],0 mov byte[echoon0+%1],0 test byte[DSPMem+4Dh],1 << %1 jz %%noecho mov byte[echoon0+%1],1 %%noecho mov edx,[DSPMem+04h+%1*10h] and edx,0ffh shl edx,2 xor eax,eax mov ah,[DSPMem+5Dh] add ax,dx xor ebx,ebx mov bx,[spcRam+eax] mov dword[Voice0Ptr+%1*4],ebx xor ebx,ebx mov bx,[spcRam+eax+2] mov dword[Voice0LoopPtr+%1*4],ebx mov ax,[DSPMem+02h+%1*10h] cmp word[Voice0Pitch+%1*2],ax je %%nopitchc mov word[Voice0Pitch+%1*2],ax xor ebx,ebx xor edx,edx and eax,03FFFh shl eax,2 mov dl,ah shl eax,24 mov ebx,[SBToSPC] div ebx shl eax,1 mov [Voice0Freq+%1*4],eax ; modpitch %%nopitchc mov dword[BRRPlace0+%1*8],10000000h mov dword [Voice0Prev0+%1*4],0 mov dword [Voice0Prev1+%1*4],0 mov byte [Voice0End+%1],0 mov byte [Voice0Loop+%1],0 mov byte[VoiceNoiseEn+%1],0 mov dword[WaveIndex+%1*4],0 mov dword[PSampleBuf+%1*26*4+21*4],0 mov dword[PSampleBuf+%1*26*4+22*4],0 mov dword[PSampleBuf+%1*26*4+23*4],0 mov dword[PSampleBuf+%1*26*4+24*4],0 mov dword[PSampleBuf+%1*26*4+25*4],0 pop edx ret %%nope %endmacro NEWSYM VoiceStarter VoiceStarterM 0 VoiceStarterM 1 VoiceStarterM 2 VoiceStarterM 3 VoiceStarterM 4 VoiceStarterM 5 VoiceStarterM 6 VoiceStarterM 7 ret section .data ;ALIGN=32 NEWSYM NoiseInc, dd 0 NEWSYM NoisePointer, dd 0 NEWSYM LastNoise, dd 0 section .text %macro CalculatePMod 1 xor eax,eax mov al,[PModBuffer+esi] mov ebx,[Voice0Freq+%1*4] add al,80h mul ebx shr eax,7 shl edx,25 or eax,edx mov ebx,eax %endmacro %macro ProcessPMod 1 ;%endmacro ;%macro ProcessPModB 1 push ecx push edx mov cl,[Voice0EnvInc+%1*4+2] mov ax,[edi+edx*2] imul cx shr ax,7 add dl,dl or ah,dl mov [PModBuffer+esi],ah pop edx pop ecx %endmacro %macro NonEchoMonoPM 4 xor eax,eax mov al,[Voice0Volume+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 mov ax,[edi+edx*2] %%AfterNoise1 imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax mov [WaveIndex+%1*4], eax add [DSPBuffer+esi*2],eax add esi,2 CalculatePMod %1 add [BRRPlace0+%1*8],ebx %endmacro %macro NonEchoStereoPM 4 xor eax,eax mov al,[Voice0VolumeR+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b mov ax,[edi+edx*2] %%AfterNoise1b movsx eax,ax mov [WaveIndex+%1*4], eax push eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] add esi,2 mov cx,[VolumeConvTable+eax*2] pop eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4-4],eax CalculatePMod %1 add [BRRPlace0+%1*8],ebx %endmacro %macro EchoMonoPM 4 xor eax,eax mov al,[Voice0Volume+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 mov ax,[edi+edx*2] %%AfterNoise1 movsx eax,ax mov [WaveIndex+%1*4], eax push eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [DSPBuffer+esi*2],eax xor eax,eax mov al,[Voice0Volumee+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] pop eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*2],eax add esi,2 CalculatePMod %1 add [BRRPlace0+%1*8],ebx %endmacro %macro EchoStereoPM 4 xor eax,eax mov al,[Voice0VolumeR+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b mov ax,[edi+edx*2] %%AfterNoise1b movsx eax,ax mov [WaveIndex+%1*4], eax mov ebx,eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeRe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4+4],eax xor eax,eax mov al,[Voice0VolumeLe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax mov ebx,[Voice0Freq+%1*4] add [EchoBuffer+esi*4+4],eax add esi,2 CalculatePMod %1 add [BRRPlace0+%1*8],ebx %endmacro ; interpolation is only done when the rate < mixRate, so ebx always contains ; less than 100000h. %macro GenerateNextSample 1 mov edx, [BRRPlace0+%1*8+2] ; edx should now contain a 24 bit fractional and edx, 0FFh sub eax, [WaveIndex+%1*4] ; eax = the difference between sample - oldSample imul eax, edx ; scale by the fractional sar eax, 8 add eax, [WaveIndex+%1*4] ; add the oldSample to the scaling. %endmacro SECTION .data ;ALIGN=32 SaveSample times 8 dd 0 WaveIndex times 8 dd 0 SECTION .text ;DSPInterP ; cmp ebx,01000000h ; ; jb %%DontFilter1 ; ; mov edx,eax ; ; mov eax,[WaveIndex+%1*4] ; low-pass filter applied to higher pitched ; sar eax,1 ; samples ; sar edx,1 ; ; add eax,edx ; ;%%DontFilter1 ; %macro DSPInterpolate 1 cmp byte[SoundInterpType],3 je near %%fir_interpolate xor ebx,ebx mov bl,[BRRPlace0+%1*8+2] mov ax,[PSampleBuf+edx*4+8+%1*26*4] mov dx,[DSPInterP+ebx*2+256*6] imul dx shl edx,16 mov dx,ax mov eax,[BRRPlace0+%1*8+3] mov ecx,edx mov ax,[PSampleBuf+eax*4+12+%1*26*4] mov dx,[DSPInterP+ebx*2+256*4] imul dx shl edx,16 mov dx,ax mov eax,[BRRPlace0+%1*8+3] add ecx,edx mov ax,[PSampleBuf+eax*4+16+%1*26*4] mov dx,[DSPInterP+ebx*2+256*2] imul dx shl edx,16 mov dx,ax mov eax,[BRRPlace0+%1*8+3] add ecx,edx mov ax,[PSampleBuf+eax*4+20+%1*26*4] mov dx,[DSPInterP+ebx*2] imul dx shl edx,16 mov dx,ax add ecx,edx sar ecx,11 mov ax,cx jmp %%end %%fir_interpolate %if 1 xor eax,eax mov ebx,[BRRPlace0+%1*8] mov al,[BRRPlace0+%1*8+3] shl eax,2 and ebx,0FFFFFFh add ebx,1000h shr ebx,9 and ebx,0FFF0h add ebx,fir_lut movq mm0,[eax+PSampleBuf+(%1*26*4)] packssdw mm0,[eax+PSampleBuf+(%1*26*4)+8] movq mm1,[eax+PSampleBuf+(%1*26*4)+16] packssdw mm1,[eax+PSampleBuf+(%1*26*4)+24] movq mm2,[ebx] movq mm3,[ebx+8] pmaddwd mm0,mm2 pmaddwd mm1,mm3 paddd mm0,mm1 movd eax,mm0 psrlq mm0,32 movd ebx,mm0 emms add eax,ebx sar eax,14 %else push dword PSampleBuf+(%1*26*4) push dword [BRRPlace0+%1*8] call fir_interpolate add esp,+8 %endif cmp eax,32767 jle %%clip1 mov eax,32767 %%clip1 cmp eax,-32768 jge %%clip2 mov eax,-32768 %%clip2 %%end %endmacro %macro NonEchoMonoInterpolated 4 mov edx,[BRRPlace0+%1*8+3] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 DSPInterpolate %1 ; mov edx,[BRRPlace0+%1*8+3] ; mov ax,[edi+edx*2] ; DSPInterP (Samp*i+Samp2*i2+Samp3*i3+Samp4*i3)>>11 %%AfterNoise1 xor edx,edx mov dl,[Voice0Volume+%1] mov dh,[Voice0EnvInc+%1*4+2] mov ebx,[Voice0Freq+%1*4] mov cx,[VolumeConvTable+edx*2] imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [DSPBuffer+esi*2],eax add esi,2 add [BRRPlace0+%1*8],ebx %endmacro %macro EchoMonoInterpolated 4 mov edx,[BRRPlace0+%1*8+3] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 DSPInterpolate %1 ; mov edx,[BRRPlace0+%1*8+3] ; mov ax,[edi+edx*2] %%AfterNoise1 xor edx,edx mov dl,[Voice0Volume+%1] mov dh,[Voice0EnvInc+%1*4+2] mov ebx,[Voice0Freq+%1*4] mov cx,[VolumeConvTable+edx*2] add [BRRPlace0+%1*8],ebx ; *** add esi,2 ; *** mov ebx,eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [DSPBuffer+esi*2-4],eax xor eax,eax mov al,[Voice0Volumee+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*2-4],eax %endmacro %macro NonEchoStereoInterpolated 4 mov edx,[BRRPlace0+%1*8+3] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b DSPInterpolate %1 %%AfterNoise1b xor edx,edx mov dl,[Voice0VolumeR+%1] mov dh,[Voice0EnvInc+%1*4+2] mov ebx,[Voice0Freq+%1*4] mov cx,[VolumeConvTable+edx*2] movsx eax,ax mov [WaveIndex+%1*4], eax push eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] add esi,2 mov cx,[VolumeConvTable+eax*2] pop eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4-4],eax add [BRRPlace0+%1*8],ebx %endmacro %macro EchoStereoInterpolated 4 mov edx,[BRRPlace0+%1*8+3] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b ; mov ax,[edi+edx*2] DSPInterpolate %1 %%AfterNoise1b xor edx,edx mov dl,[Voice0VolumeR+%1] mov dh,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+edx*2] movsx eax,ax mov [WaveIndex+%1*4], eax mov ebx,eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeRe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4+4],eax xor eax,eax mov al,[Voice0VolumeLe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax mov ebx,[Voice0Freq+%1*4] add [EchoBuffer+esi*4+4],eax add esi,2 add [BRRPlace0+%1*8],ebx %endmacro %macro NonEchoMono 4 xor eax,eax mov al,[Voice0Volume+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 mov ax,[edi+edx*2] %%AfterNoise1 imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax mov [WaveIndex+%1*4], eax add [DSPBuffer+esi*2],eax add esi,2 add [BRRPlace0+%1*8],ebx %endmacro %macro NonEchoStereo 4 xor eax,eax mov al,[Voice0VolumeR+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b mov ax,[edi+edx*2] %%AfterNoise1b movsx eax,ax mov [WaveIndex+%1*4], eax push eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] add esi,2 mov cx,[VolumeConvTable+eax*2] pop eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4-4],eax add [BRRPlace0+%1*8],ebx %endmacro %macro EchoMono 4 xor eax,eax mov al,[Voice0Volume+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1 test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1 %%PMod ProcessPMod %1 %%NotNoise1 mov ax,[edi+edx*2] %%AfterNoise1 movsx eax,ax mov [WaveIndex+%1*4], eax push eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [DSPBuffer+esi*2],eax xor eax,eax mov al,[Voice0Volumee+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] pop eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*2],eax add esi,2 add [BRRPlace0+%1*8],ebx %endmacro %macro EchoStereo 4 xor eax,eax mov al,[Voice0VolumeR+%1] mov ah,[Voice0EnvInc+%1*4+2] mov edx,[BRRPlace0+%1*8+3] mov cx,[VolumeConvTable+eax*2] cmp byte[UniqueSoundv],0 je %%NotNoise1b test byte [DSPMem+3Dh],1 << %1 jz %%PMod mov eax, dword [NoiseInc] add dword [NoisePointer],eax mov eax,[NoisePointer] shr eax,18 ; maybe will need a change mov ax,[NoiseData+eax*2] mov word [LastNoise],ax jmp %%AfterNoise1b %%PMod ProcessPMod %1 %%NotNoise1b mov ax,[edi+edx*2] %%AfterNoise1b movsx eax,ax mov [WaveIndex+%1*4], eax mov ebx,eax imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeRe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add [EchoBuffer+esi*4],eax xor eax,eax mov al,[Voice0VolumeL+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax add dword [DSPBuffer+esi*4+4],eax xor eax,eax mov al,[Voice0VolumeLe+%1] mov ah,[Voice0EnvInc+%1*4+2] mov cx,[VolumeConvTable+eax*2] mov eax,ebx imul cx shr ax,7 add dl,dl or ah,dl movsx eax,ax mov ebx,[Voice0Freq+%1*4] add [EchoBuffer+esi*4+4],eax add esi,2 add [BRRPlace0+%1*8],ebx %endmacro %macro ProcessVoiceStuff 8 mov ax,[DSPMem+02h+%1*10h] cmp word[Voice0Pitch+%1*2],ax je %%nopitchc mov word[Voice0Pitch+%1*2],ax xor ebx,ebx xor edx,edx and eax,03FFFh shl eax,2 mov dl,ah shl eax,24 mov ebx,[SBToSPC] div ebx shl eax,1 ; modpitch mov [Voice0Freq+%1*4],eax %%nopitchc jmp %%SkipProcess %%ProcessNextEnvelope cmp byte [Voice0State+%1],10 je near %%ADSRSustain cmp byte [Voice0State+%1],9 je near %%ADSRDecayProc cmp byte [Voice0State+%1],7 je near %%DecreaseBent cmp byte [Voice0State+%1],8 je near %%ADSRDecay cmp byte [Voice0State+%1],1 je near %%Decay cmp byte [Voice0State+%1],2 je near %%Sustain cmp byte [Voice0State+%1],3 je near %%Blank cmp byte [Voice0State+%1],4 je near %%EndofSamp cmp byte [Voice0State+%1],200 je near %%EndofSamp cmp byte [Voice0State+%1],210 je near %%EndofSamp2 cmp byte [Voice0State+%1],5 je %%MuteGain cmp byte [Voice0State+%1],6 je %%IncreaseBent jmp %%EndofSamp %%MuteGain mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0IncNumber+%1*4],0 mov dword[Voice0Time+%1*4],0FFFFFFFFh jmp %%ContinueGain %%IncreaseBent push ebx xor eax,eax mov al,[DSPMem+07h+%1*10h] and al,1Fh mov ebx,[Increase+eax*4] mov dword[Voice0Time+%1*4],ebx shr dword[Voice0IncNumber+%1*4],2 mov byte[Voice0State+%1],3 pop ebx jmp %%ContinueGain %%ADSRDecay push ebx push edx mov al,[DSPMem+05h+%1*10h] shr al,4 and eax,07h mov edx,[DecayRate+eax*4] xor eax,eax mov al,[DSPMem+06h+%1*10h] and al,1Fh mov ebx,[SustainRate+eax*4] cmp edx,ebx jae near %%decayover ; ebx = total sustain time xor eax,eax mov al,[DSPMem+06h+%1*10h] shr al,5 mov al,[AdsrSustLevLoc+eax] ; traverse through al entries in edx time ; then through 64-al entries in ebx-edx time mov [AdsrBlocksLeft+%1],al sub ebx,edx push ebx push eax mov ebx,eax mov eax,edx xor edx,edx div ebx mov [Voice0Time+%1*4],eax mov [GainDecBendDataTime+%1*4],eax pop eax pop ebx mov edx,ebx mov ebx,64 sub bl,al mov eax,edx xor edx,edx div ebx mov [AdsrNextTimeDepth+%1*4],eax mov dword[Voice0EnvInc+%1*4],007FFFFFh mov ebx,[Voice0Time+%1*4] xor edx,edx mov eax,127*65536 sub eax,122*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx mov byte [Voice0State+%1],9 jmp %%ContinueGain %%decayover sub edx,ebx push ebx mov eax,edx xor ebx,ebx mov bl,[DSPMem+06h+%1*10h] shr bl,5 xor bl,07h mul ebx mov ebx,7 div ebx pop ebx add ebx,eax mov dword[Voice0EnvInc+%1*4],007FFFFFh shr ebx,5 mov dword[Voice0Time+%1*4],ebx mov [GainDecBendDataTime+%1*4],ebx xor edx,edx mov eax,127*65536 sub eax,118*65536 mov byte[GainDecBendDataPos+%1],0 mov byte[GainDecBendDataDat+%1],127 div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax pop edx pop ebx mov byte [Voice0State+%1],7 jmp %%ContinueGain %%ADSRDecayProc push ebx push edx xor ebx,ebx xor edx,edx xor eax,eax mov dword[Voice0EnvInc+%1*4],0 mov bl,[GainDecBendDataPos+%1] mov dl,[GainDecBendDataDat+%1] mov dh,[AdsrBendData+ebx] mov al,[VolumeConvTable+edx*2] mov [Voice0EnvInc+%1*4+2],al mov dl,[GainDecBendDataDat+%1] mov dh,[AdsrBendData+ebx+1] sub al,[VolumeConvTable+edx*2] mov ebx,[GainDecBendDataTime+%1*4] mov [Voice0Time+%1*4],ebx xor edx,edx shl eax,16 inc byte[GainDecBendDataPos+%1] div ebx neg eax mov [Voice0IncNumber+%1*4],eax pop edx pop ebx dec byte[AdsrBlocksLeft+%1] jz %%nomoredecay jmp %%ContinueGain %%nomoredecay mov byte [Voice0State+%1],10 jmp %%ContinueGain %%ADSRSustain push ebx push edx xor ebx,ebx xor edx,edx xor eax,eax mov dword[Voice0EnvInc+%1*4],0 mov bl,[GainDecBendDataPos+%1] mov dl,[GainDecBendDataDat+%1] mov dh,[AdsrBendData+ebx] mov al,[VolumeConvTable+edx*2] mov [Voice0EnvInc+%1*4+2],al mov dl,[GainDecBendDataDat+%1] mov dh,[AdsrBendData+ebx+1] cmp dh,255 je %%nomoreadsr mov dl,[VolumeConvTable+edx*2] mov ebx,[AdsrNextTimeDepth+%1*4] sub al,dl mov [Voice0Time+%1*4],ebx xor edx,edx shl eax,16 inc byte[GainDecBendDataPos+%1] div ebx neg eax mov [Voice0IncNumber+%1*4],eax pop edx pop ebx jmp %%ContinueGain %%nomoreadsr pop edx pop ebx mov byte [Voice0State+%1],5 jmp %%MuteGain %%DecreaseBent push ebx push edx xor ebx,ebx xor edx,edx xor eax,eax mov bl,[GainDecBendDataPos+%1] mov dl,[GainDecBendDataDat+%1] mov dh,[GainDecBendData+ebx] mov dword[Voice0EnvInc+%1*4],0 mov al,[VolumeConvTable+edx*2] mov byte[Voice0EnvInc+%1*4+2],al mov dh,[GainDecBendData+ebx+1] cmp dh,255 je %%nomore mov ebx,[GainDecBendDataTime+%1*4] sub al,[VolumeConvTable+edx*2] mov [Voice0Time+%1*4],ebx xor edx,edx shl eax,16 inc byte[GainDecBendDataPos+%1] div ebx neg eax mov [Voice0IncNumber+%1*4],eax pop edx pop ebx jmp %%ContinueGain %%nomore pop edx pop ebx mov byte [Voice0State+%1],5 jmp %%MuteGain %%Decay ; Calculate Decay Value push ebx push edx mov dword[Voice0EnvInc+%1*4],07FFFFFh mov al,[DSPMem+05h+%1*10h] mov dl,[DSPMem+06h+%1*10h] shr al,4 and eax,07h and edx,1Fh mov ebx,[DecayRate+eax*4] cmp edx,1Fh je %%nodecayfix cmp ebx,[SustainRate+edx*4] jbe %%nodecayfix cmp al,0 jne %%nodecayskip mov al,[DSPMem+06h+%1*10h] and al,0E0h cmp al,0E0h je near %%Sustain2 %%nodecayskip mov al,[DSPMem+05h+%1*10h] shr al,4 and eax,07h mov ebx,[DecayRate+eax*4] sub ebx,[SustainRate+edx*4] cmp ebx,[SustainRate+edx*4] jae %%nodecayfix mov ebx,[SustainRate+edx*4] %%nodecayfix or ebx,ebx jnz %%nozero inc ebx %%nozero mov dl,[DSPMem+06h+%1*10h] shr dl,5 and dl,07h mov dword[Voice0Time+%1*4],ebx mov al,[SustainValue+edx] xor al,7Fh shl eax,16 xor edx,edx div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],2 pop edx pop ebx mov ebx,[Voice0Freq+%1*4] ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound cmp byte [SoundInterpType],0 je %%notinterpsound cmp byte [StereoSound],1 je near %%EndofProcessNEnvsi jmp %%EndofProcessNEnvi %%notinterpsound cmp byte [StereoSound],1 je near %%EndofProcessNEnvs jmp %%EndofProcessNEnv %%Sustain2 mov ebx,[SustainRate+edx*4] jmp %%continuesust %%Sustain ; Calculate Decay Value push ebx push edx mov al,[DSPMem+05h+%1*10h] mov dl,[DSPMem+06h+%1*10h] and edx,1Fh shr al,4 and eax,07h mov ebx,[SustainRate+edx*4] test ebx,80000000h jnz %%sustainokay sub ebx,[DecayRate+eax*4] %%continuesust cmp ebx,100 jg %%sustainokay mov ebx,100 %%sustainokay mov dword[Voice0Time+%1*4],ebx mov al,[Voice0EnvInc+%1*4+2] shl eax,16 xor edx,edx div ebx neg eax mov dword [Voice0IncNumber+%1*4],eax mov byte [Voice0State+%1],4 pop edx pop ebx mov ebx,[Voice0Freq+%1*4] ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound2 cmp byte [SoundInterpType],0 je %%notinterpsound2 cmp byte [StereoSound],1 je near %%EndofProcessNEnvsi jmp %%EndofProcessNEnvi %%notinterpsound2 cmp byte [StereoSound],1 je near %%EndofProcessNEnvs jmp %%EndofProcessNEnv %%Blank mov dword[Voice0EnvInc+%1*4],007F0000h mov dword[Voice0IncNumber+%1*4],0 mov dword[Voice0Time+%1*4],0FFFFFFFFh %%ContinueGain mov ebx,[Voice0Freq+%1*4] ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound3 cmp byte [SoundInterpType],0 je %%notinterpsound3 cmp byte [StereoSound],1 je near %%EndofProcessNEnvsi jmp %%EndofProcessNEnvi %%notinterpsound3 cmp byte [StereoSound],1 je near %%EndofProcessNEnvs jmp %%EndofProcessNEnv %%EndofSamp mov dword[DLPFsamples+%1*26+21*4],0 mov dword[DLPFsamples+%1*26+22*4],0 mov dword[DLPFsamples+%1*26+23*4],0 mov dword[DLPFsamples+%1*26+24*4],0 mov dword[DLPFsamples+%1*26+25*4],0 mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0IncNumber+%1*4],0 mov byte [Voice0Status+%1],0 mov byte [Voice0State+%1],0 cmp byte[ENVDisable],1 je %%noSkipStuff cmp byte[CNetType],20 je %%SkipStuff %%noSkipStuff mov byte [DSPMem+08h+%1*10h],0 mov byte [DSPMem+09h+%1*10h],0 or byte [DSPMem+7Ch],%3 %%SkipStuff jmp %2 %%EndofSamp2 mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0IncNumber+%1*4],0 mov byte [Voice0State+%1],0 cmp byte[ENVDisable],1 je %%noSkipStuff2 cmp byte[CNetType],20 je %%SkipStuff2 %%noSkipStuff2 mov byte [DSPMem+08h+%1*10h],0 mov byte [DSPMem+09h+%1*10h],0 or byte [DSPMem+7Ch],%3 %%SkipStuff2 mov al,%1 call VoiceStarter jmp %%SkipProcess2 %%SkipProcess xor esi,esi %%SkipProcess2 xor eax,eax xor ebx,ebx mov al,[DSPMem+00h+%1*10h] mov bl,[DSPMem+01h+%1*10h] mov al,[VolumeTableD+eax] mov bl,[VolumeTableD+ebx] mov [Voice0VolumeRe+%1],al mov [Voice0VolumeLe+%1],bl mov ah,al mov bh,bl test ah,80h jz %%notnegc neg ah %%notnegc test bh,80h jz %%notnegd neg bh %%notnegd add ah,bh shr ah,1 test al,80h jnz %%neg2 test bl,80h jz %%notneg2 %%neg2 neg ah %%notneg2 mov [Voice0Volumee+%1],ah xor eax,eax xor ebx,ebx mov al,[DSPMem+00h+%1*10h] mov bl,[DSPMem+01h+%1*10h] mov al,[VolumeTableD+eax] mov bl,[VolumeTableD+ebx] mov ah,[GlobalVL] mov bh,[GlobalVR] mov al,[VolumeConvTable+eax*2] mov bl,[VolumeConvTable+ebx*2] mov [Voice0VolumeR+%1],al mov [Voice0VolumeL+%1],bl mov ah,al mov bh,bl test ah,80h jz %%notneg neg ah %%notneg test bh,80h jz %%notnegb neg bh %%notnegb add ah,bh shr ah,1 test al,80h jnz %%neg3 test bl,80h jz %%notneg3 %%neg3 neg ah %%notneg3 mov [Voice0Volume+%1],ah ; cmp byte[Voice0Volume+%1],0 ; je %%volskip mov byte [lastbl],0 mov byte [loopbl],0 mov ebx,[Voice0Freq+%1*4] mov edi,[Voice0BufPtr+%1*4] mov byte[UniqueSoundv],0 test byte [DSPMem+3Dh],%3 jnz %%Unique %if %1<7 ; added test byte [DSPMem+2Dh],%3 << 1 jnz %%Uniquepm %endif ; added jmp %%NotUnique %%Uniquepm ; cmp byte[PitchModEn],0 ; je %%NotUnique ; mov al,%1 ; ; cmp al,0 ; commented out ; je %%NotUnique ; %%Unique mov byte [UniqueSoundv],1 %%NotUnique ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound4 cmp byte [SoundInterpType],0 je %%notinterpsound4 cmp byte [StereoSound],1 je near %%NextSampleSi jmp %%NextSamplei %%notinterpsound4 cmp byte [StereoSound],1 je near %%NextSampleS %%NextSample cmp dword[BRRPlace0+%1*8],10000000h jae near %%ProcessBRR mov eax,[Voice0IncNumber+%1*4] add [Voice0EnvInc+%1*4],eax dec dword[Voice0Time+%1*4] jz near %%ProcessNextEnvelope %%EndofProcessNEnv %5 %1, %2, %3, %4 cmp esi,[BufferSizeW] jne near %%NextSample ; mov [DSPMem+09h+%1*10h],ah mov al,[Voice0EnvInc+%1*4+2] mov [DSPMem+08h+%1*10h],al cmp byte[ENVDisable],1 je %%clearenv cmp byte[CNetType],20 je %%clearenv cmp byte[MovieProcessing],0 je %%skipenvclear %%clearenv mov byte[DSPMem+08h+%1*10h],0 %%skipenvclear jmp %%ProcessVoice1 %%NextSampleSi cmp dword[BRRPlace0+%1*8],10000000h jae near %%ProcessBRR mov eax,[Voice0IncNumber+%1*4] add [Voice0EnvInc+%1*4],eax dec dword[Voice0Time+%1*4] jz near %%ProcessNextEnvelope %%EndofProcessNEnvsi %8 %1, %2, %3, %4 cmp esi,[BufferSizeB] jne near %%NextSampleSi ; mov [DSPMem+09h+%1*10h],ah mov al,[Voice0EnvInc+%1*4+2] mov [DSPMem+08h+%1*10h],al cmp byte[ENVDisable],1 je %%clearenvsi cmp byte[CNetType],20 je %%clearenvsi cmp byte[MovieProcessing],0 je %%skipenvclearsi %%clearenvsi mov byte[DSPMem+08h+%1*10h],0 %%skipenvclearsi jmp %%ProcessVoice1 %%NextSamplei cmp dword[BRRPlace0+%1*8],10000000h jae near %%ProcessBRR mov eax,[Voice0IncNumber+%1*4] add [Voice0EnvInc+%1*4],eax dec dword[Voice0Time+%1*4] jz near %%ProcessNextEnvelope %%EndofProcessNEnvi %7 %1, %2, %3, %4 cmp esi,[BufferSizeW] jne near %%NextSamplei ; mov [DSPMem+09h+%1*10h],ah mov al,[Voice0EnvInc+%1*4+2] mov [DSPMem+08h+%1*10h],al cmp byte[ENVDisable],1 je %%clearenvi cmp byte[CNetType],20 je %%clearenvi cmp byte[MovieProcessing],0 je %%skipenvcleari %%clearenvi mov byte[DSPMem+08h+%1*10h],0 %%skipenvcleari jmp %%ProcessVoice1 %%NextSampleS cmp dword[BRRPlace0+%1*8],10000000h jae near %%ProcessBRR mov eax,[Voice0IncNumber+%1*4] add [Voice0EnvInc+%1*4],eax dec dword[Voice0Time+%1*4] jz near %%ProcessNextEnvelope %%EndofProcessNEnvs %6 %1, %2, %3, %4 cmp esi,[BufferSizeB] jne near %%NextSampleS ; mov [DSPMem+09h+%1*10h],ah mov al,[Voice0EnvInc+%1*4+2] mov [DSPMem+08h+%1*10h],al cmp byte[ENVDisable],1 je %%clearenv2 cmp byte[CNetType],20 je %%clearenv2 cmp byte[MovieProcessing],0 je %%skipenvclear2 %%clearenv2 mov byte[DSPMem+08h+%1*10h],0 %%skipenvclear2 %%noclearenv jmp %%ProcessVoice1 %%ProcessBRR cmp byte [Voice0End+%1],1 je near %%noDecode1Block %%Decode1Block sub dword [BRRPlace0+%1*8],10000000h push esi mov esi, dword [Voice0Ptr+%1*4] ; cmp byte[Voice0Looped+%1],0 ; je %%nobrrcheck mov eax,[PSampleBuf+21*4+%1*26*4] mov [PSampleBuf+0*4+%1*26*4],eax mov eax,[PSampleBuf+22*4+%1*26*4] mov [PSampleBuf+1*4+%1*26*4],eax mov eax,[PSampleBuf+23*4+%1*26*4] mov [PSampleBuf+2*4+%1*26*4],eax mov eax,[PSampleBuf+24*4+%1*26*4] mov [PSampleBuf+3*4+%1*26*4],eax mov eax,[PSampleBuf+25*4+%1*26*4] mov [PSampleBuf+4*4+%1*26*4],eax cmp byte[SoundBufEn],0 je near %%convertBRR2 jmp %%convertBRR2 ; Check if looped %%nobrrcheck mov eax,[spcRam+esi] mov ebx,[spcRam+esi+4] cmp eax,[spcRamcmp+esi] jne near %%convertBRR cmp ebx,[spcRamcmp+esi+4] jne near %%convertBRR mov al,[spcRam+esi+8] cmp al,[spcRamcmp+esi+8] jne near %%convertBRR mov byte[Voice0End+%1],0 mov byte[Voice0Loop+%1],0 test byte[spcRam+esi],01h jz %%nolast mov byte[Voice0End+%1],1 test byte[spcRam+esi],02h jnz %%looped jmp %%last %%looped mov byte[Voice0Loop+%1],1 %%nolast %%last mov edi,esi inc edi add dword [Voice0Ptr+%1*4],9 shl edi,2 pop esi add edi,[spcBuffera] mov ebx,[Voice0Freq+%1*4] mov [Voice0BufPtr+%1*4],edi movsx eax,word [edi] mov [PSampleBuf+5*4+%1*26*4],eax movsx eax,word [edi+2*1] mov [PSampleBuf+6*4+%1*26*4],eax movsx eax,word [edi+2*2] mov [PSampleBuf+7*4+%1*26*4],eax movsx eax,word [edi+2*3] mov [PSampleBuf+8*4+%1*26*4],eax movsx eax,word[edi+2*4] mov [PSampleBuf+9*4+%1*26*4],eax movsx eax,word [edi+2*5] mov [PSampleBuf+10*4+%1*26*4],eax movsx eax,word [edi+2*6] mov [PSampleBuf+11*4+%1*26*4],eax movsx eax,word [edi+2*7] mov [PSampleBuf+12*4+%1*26*4],eax movsx eax,word [edi+2*8] mov [PSampleBuf+13*4+%1*26*4],eax movsx eax,word [edi+2*9] mov [PSampleBuf+14*4+%1*26*4],eax movsx eax,word [edi+2*10] mov [PSampleBuf+15*4+%1*26*4],eax movsx eax,word [edi+2*11] mov [PSampleBuf+16*4+%1*26*4],eax mov [PSampleBuf+21*4+%1*26*4],eax movsx eax,word [edi+2*12] mov [PSampleBuf+17*4+%1*26*4],eax mov [PSampleBuf+22*4+%1*26*4],eax movsx eax,word [edi+2*13] mov [PSampleBuf+18*4+%1*26*4],eax mov [PSampleBuf+23*4+%1*26*4],eax movsx eax,word [edi+2*14] mov [PSampleBuf+19*4+%1*26*4],eax mov [PSampleBuf+24*4+%1*26*4],eax movsx eax,word [edi+2*15] mov [PSampleBuf+20*4+%1*26*4],eax mov [PSampleBuf+25*4+%1*26*4],eax ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound5 cmp byte [SoundInterpType],0 je %%notinterpsound5 cmp byte [StereoSound],1 je near %%NextSampleSi jmp %%NextSamplei %%notinterpsound5 cmp byte [StereoSound],1 je near %%NextSampleS jmp %%NextSample %%convertBRR mov eax,[spcRam+esi] mov ebx,[spcRam+esi+4] mov [spcRamcmp+esi],eax mov [spcRamcmp+esi+4],ebx mov al,[spcRam+esi+8] mov [spcRamcmp+esi+8],al %%convertBRR2 mov edi,esi inc edi shl edi,2 add esi,spcRam add edi,[spcBuffera] mov eax,[Voice0Prev0+%1*4] mov [Voice0BufPtr+%1*4],edi push edi ; DDOI - this will avoid the crash bug hopefully mov dword [prev0],eax mov eax,[Voice0Prev1+%1*4] mov dword [prev1],eax mov ecx,%1 call BRRDecode pop edi pop esi ;mov edi,[Voice0BufPtr+%1*4] ;STUB_ASM_INT edi movsx eax,word [edi] mov [PSampleBuf+5*4+%1*26*4],eax movsx eax,word [edi+2*1] mov [PSampleBuf+6*4+%1*26*4],eax movsx eax,word [edi+2*2] mov [PSampleBuf+7*4+%1*26*4],eax movsx eax,word [edi+2*3] mov [PSampleBuf+8*4+%1*26*4],eax movsx eax,word[edi+2*4] mov [PSampleBuf+9*4+%1*26*4],eax movsx eax,word [edi+2*5] mov [PSampleBuf+10*4+%1*26*4],eax movsx eax,word [edi+2*6] mov [PSampleBuf+11*4+%1*26*4],eax movsx eax,word [edi+2*7] mov [PSampleBuf+12*4+%1*26*4],eax movsx eax,word [edi+2*8] mov [PSampleBuf+13*4+%1*26*4],eax movsx eax,word [edi+2*9] mov [PSampleBuf+14*4+%1*26*4],eax movsx eax,word [edi+2*10] mov [PSampleBuf+15*4+%1*26*4],eax movsx eax,word [edi+2*11] mov [PSampleBuf+16*4+%1*26*4],eax mov [PSampleBuf+21*4+%1*26*4],eax movsx eax,word [edi+2*12] mov [PSampleBuf+17*4+%1*26*4],eax mov [PSampleBuf+22*4+%1*26*4],eax movsx eax,word [edi+2*13] mov [PSampleBuf+18*4+%1*26*4],eax mov [PSampleBuf+23*4+%1*26*4],eax movsx eax,word [edi+2*14] mov [PSampleBuf+19*4+%1*26*4],eax mov [PSampleBuf+24*4+%1*26*4],eax movsx eax,word [edi+2*15] mov [PSampleBuf+20*4+%1*26*4],eax mov [PSampleBuf+25*4+%1*26*4],eax mov eax,dword [prev0] mov [Voice0Prev0+%1*4],eax mov eax,dword [prev1] mov [Voice0Prev1+%1*4],eax mov al,[loopbl] mov [Voice0Loop+%1],al mov al,[lastbl] mov [Voice0End+%1],al mov ebx,[Voice0Freq+%1*4] add dword [Voice0Ptr+%1*4],9 ; cmp byte[VoiceNoiseEn+%1],10 ; je %%notinterpsound6 cmp byte [SoundInterpType],0 je %%notinterpsound6 cmp byte [StereoSound],1 je near %%NextSampleSi jmp %%NextSamplei %%notinterpsound6 cmp byte [StereoSound],1 je near %%NextSampleS jmp %%NextSample %%noDecode1Block ; and byte [DSPMem+5Ch],%4 ; and byte [DSPMem+4Ch],%4 ; mov byte[Voice0Looped+%1],0 cmp byte [Voice0Loop+%1],1 jne near %%EndSample ; mov byte[Voice0Looped+%1],1 mov byte[SoundLooped0+%1],1 cmp byte[CNetType],20 je %%SkipStuff3 or byte [DSPMem+7Ch],%3 %%SkipStuff3 ; mov dword[Voice0Prev0+%1*4],0 ; mov dword[Voice0Prev1+%1*4],0 ; push eax ; push edx ; push ebx ; mov edx,[DSPMem+04h+%1*10h] ; and edx,0ffh ; shl edx,2 ; xor eax,eax ; mov ah,[DSPMem+5Dh] ; add ax,dx ; xor ebx,ebx ; mov bx,[spcRam+eax] ; mov dword[Voice0Ptr+%1*4],ebx ; xor ebx,ebx ; mov bx,[spcRam+eax+2] ; mov dword[Voice0LoopPtr+%1*4],ebx ; pop ebx ; pop edx ; pop eax mov eax,[Voice0LoopPtr+%1*4] mov [Voice0Ptr+%1*4],eax ; mov eax,[Voice0Prev0+%1*4] ; mov [Voice0Prev1+%1*4],eax jmp %%Decode1Block %%EndSample cmp byte[ENVDisable],1 je %%noSkipStuff4 cmp byte[CNetType],20 je %%SkipStuff4 %%noSkipStuff4 or byte [DSPMem+7Ch],%3 mov byte [DSPMem+08h+%1*10h],0 %%SkipStuff4 mov dword[DLPFsamples+%1*26+21*4],0 mov dword[DLPFsamples+%1*26+22*4],0 mov dword[DLPFsamples+%1*26+23*4],0 mov dword[DLPFsamples+%1*26+24*4],0 mov dword[DLPFsamples+%1*26+25*4],0 ; and byte [DSPMem+5Ch],%4 mov dword[Voice0EnvInc+%1*4],0 mov dword[Voice0IncNumber+%1*4],0 mov byte [Voice0Status+%1],0 ; mov byte [DSPMem+09h+%1*10h],0h jmp %2 %%ProcessVoice1 jmp %2 %endmacro %macro ProcessVoiceHandler16 4 cmp byte [Voice0Disable+%1],1 jne near %2 cmp byte [Voice0Status+%1],1 jne near %2 cmp byte[PitchModEn],0 ; je .nopitchmod mov eax,%1 dec al cmp al,0FFh je .nopitchmod ; cmp byte[DSPMem+%1*10h-10h+8h],40h ; jae .noch6dis ; jmp .nopitchmod ; cmp al,6 ; je .nopitchmod ;.noch6dis cmp byte [Voice0Disable+eax],1 jne .nopitchmod cmp byte [Voice0Status+eax],1 jne .nopitchmod test byte [DSPMem+2Dh],%3 jnz near .pitchmod .nopitchmod test byte [DSPMem+3Dh],%3 jnz .NoEcho cmp byte[echoon0+%1],1 je near .echostuff .NoEcho ProcessVoiceStuff %1, %2, %3, %4, NonEchoMono, NonEchoStereo, NonEchoMonoInterpolated, NonEchoStereoInterpolated ; Process Echo .echostuff ProcessVoiceStuff %1, %2, %3, %4, EchoMono, EchoStereo, EchoMonoInterpolated, EchoStereoInterpolated .pitchmod mov al,[DSPMem+4+%1*10h] cmp al,[DSPMem+4+%1*10h-10h] je near .nopitchmod test byte [DSPMem+3Dh],%3 jnz .NoEchopm cmp byte[echoon0+%1],1 je near .echopm .NoEchopm ProcessVoiceStuff %1, %2, %3, %4, NonEchoMonoPM, NonEchoStereoPM, NonEchoMonoPM, NonEchoStereoPM .echopm ProcessVoiceStuff %1, %2, %3, %4, EchoMonoPM, EchoStereoPM, EchoMonoPM, EchoStereoPM %endmacro %macro FiltTapProc 1 sub edx,2 mov eax,dword[FIRTAPVal0+%1*4] and edx,0Fh mov ebx,[FiltLoop+edx*4] imul eax,ebx sar eax,7 add ecx,eax %endmacro %macro FiltTapProcR 1 sub edx,2 mov eax,dword[FIRTAPVal0+%1*4] and edx,0Fh mov ebx,[FiltLoopR+edx*4] imul eax,ebx sar eax,7 add ecx,eax %endmacro %macro MixEcho 0 mov al,[EchoVL] mov bl,[EchoVR] cmp bl,al ja .novol mov bl,al .novol mov [EchoT],bl ; Copy echobuf to DSPBuffer, EchoBuffer to echobuf cmp byte[StereoSound],1 je near .Stereo mov esi,[CEchoPtr] xor edi,edi .next ; Get current echo buffer mov ebx,[echobuf+esi*4] ; Process FIR Filter mov edx,[CurFiltPtr] mov eax,ebx mov [FiltLoop+edx*4],ebx mov ecx,[FIRTAPVal0] imul eax,ecx sar eax,7 mov ecx,eax FiltTapProc 1 FiltTapProc 2 FiltTapProc 3 FiltTapProc 4 FiltTapProc 5 FiltTapProc 6 FiltTapProc 7 inc dword[CurFiltPtr] and byte[CurFiltPtr],0Fh ; Set feedback on previous echo mov eax,[EchoFB] imul eax,ecx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx add [DSPBuffer+edi*4],ecx mov eax,[EchoBuffer+edi*4] mov bl,[EchoT] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax inc esi cmp esi,[MaxEcho] jb .nexte xor esi,esi .nexte inc edi cmp edi,[BufferSizeB] jne near .next mov [CEchoPtr],esi jmp .Mono .Stereo mov esi,[CEchoPtr] xor edi,edi .nexts ; Get current echo buffer mov ebx,[echobuf+esi*4] ; Process FIR Filter mov edx,[CurFiltPtr] mov eax,ebx mov [FiltLoop+edx*4],ebx mov ecx,[FIRTAPVal0] imul eax,ecx sar eax,7 mov ecx,eax FiltTapProc 1 FiltTapProc 2 FiltTapProc 3 FiltTapProc 4 FiltTapProc 5 FiltTapProc 6 FiltTapProc 7 add [DSPBuffer+edi*4],ecx ; Set feedback on previous echo mov eax,[EchoFB] imul eax,ecx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx mov eax,[EchoBuffer+edi*4] mov bl,[EchoVL] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax inc esi inc edi ; Get current echo buffer mov ebx,[echobuf+esi*4] ; Process FIR Filter mov edx,[CurFiltPtr] mov eax,ebx mov [FiltLoopR+edx*4],ebx mov ecx,[FIRTAPVal0] imul eax,ecx sar eax,7 mov ecx,eax FiltTapProcR 1 FiltTapProcR 2 FiltTapProcR 3 FiltTapProcR 4 FiltTapProcR 5 FiltTapProcR 6 FiltTapProcR 7 add [DSPBuffer+edi*4],ecx inc dword[CurFiltPtr] and byte[CurFiltPtr],0Fh ; Set feedback on previous echo mov eax,[EchoFB] imul eax,ecx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx mov eax,[EchoBuffer+edi*4] mov bl,[EchoVR] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax mov eax,[MaxEcho] inc esi add eax,eax cmp esi,eax jb .nextes xor esi,esi .nextes inc edi cmp edi,[BufferSizeB] jne near .nexts mov [CEchoPtr],esi .Mono %endmacro %macro MixEcho2 0 mov al,[EchoVL] mov bl,[EchoVR] cmp bl,al ja %%novol mov bl,al %%novol mov [EchoT],bl ; Copy echobuf to DSPBuffer, EchoBuffer to echobuf cmp byte[StereoSound],1 je near %%Stereo mov esi,[CEchoPtr] xor edi,edi %%next ; Get current echo buffer mov ebx,[echobuf+esi*4] mov eax,[EchoFB] add [DSPBuffer+edi*4],ebx imul eax,ebx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx mov eax,[EchoBuffer+edi*4] mov bl,[EchoT] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax inc esi cmp esi,[MaxEcho] jae %%echowrap %%nexte inc edi cmp edi,[BufferSizeB] jne %%next mov [CEchoPtr],esi jmp %%Mono %%echowrap xor esi,esi jmp %%nexte %%Stereo mov esi,[CEchoPtr] xor edi,edi %%nexts ; Get current echo buffer mov ecx,[echobuf+esi*4] mov eax,[EchoFB] add [DSPBuffer+edi*4],ecx imul eax,ecx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx mov eax,[EchoBuffer+edi*4] mov bl,[EchoVL] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax inc esi inc edi ; Get current echo buffer mov ecx,[echobuf+esi*4] mov eax,[EchoFB] add [DSPBuffer+edi*4],ecx imul eax,ecx sar eax,7 ; Add in new echo/Store into Echo Buffer mov ecx,eax xor ebx,ebx mov eax,[EchoBuffer+edi*4] mov bl,[EchoVR] mul ebx sar eax,7 add eax,ecx mov [echobuf+esi*4],eax mov eax,[MaxEcho] inc esi add eax,eax cmp esi,eax jae %%echowrap2 %%nextes inc edi cmp edi,[BufferSizeB] jne near %%nexts mov [CEchoPtr],esi jmp %%Mono %%echowrap2 xor esi,esi jmp %%nextes %%Mono %endmacro NEWSYM SBHandler cli push ds push eax NEWSYM handlersbseg mov ax,[cs:dssel] mov ds,ax cmp byte[SBHDMA],0 jne near SBHandler16 ; code added by peter santing cmp byte[vibracard], 1 je near SBHandler16 push ebx push ecx push edx push edi push esi push es call GetCDMAPos cmp byte[csounddisable],1 je near stopsbsound test byte[DSPMem+6Ch],11000000b jnz near stopsbsound ; Process the sound :I mov es,[sbselec] cmp byte[SBswitch],0 jne .2ndblock mov edi,[sbpmofs] jmp .startblockcopy .2ndblock ; copy to 2nd block ; clear memory mov edi,[sbpmofs] add edi,[BufferSizeB] .startblockcopy mov esi,DSPBuffer mov ecx,[BufferSizeB] cmp byte[Surround],0 je .nosurround cmp byte[StereoSound],0 je .surroundmono ; jmp .surroundmono .nosurround .loopb mov eax,[esi] cmp eax,-32768 jge .noneg3 mov eax,-32768 .noneg3 cmp eax,32767 jle .noneg4 mov eax,32767 .noneg4 xor ah,80h mov [es:edi],ah add esi,4 inc edi dec ecx jnz .loopb jmp .sbend .surroundmono cmp byte[SBswitch],0 je .1stblock add edi,[BufferSizeB] .1stblock .loopbm mov eax,[esi] cmp eax,-32768 jge .noneg3m mov eax,-32768 .noneg3m cmp eax,32767 jle .noneg4m mov eax,32767 .noneg4m xor ah,80h mov [es:edi],ah xor ah,80h neg ah xor ah,80h mov [es:edi+1],ah add esi,4 add edi,2 dec ecx jnz .loopbm .sbend xor byte [SBswitch],1 ; move the good data at spcRam+0f3h xor eax,eax mov al,[spcRam+0F2h] mov bl,[DSPMem+eax] mov [spcRam+0F3h],bl ; acknowledge SB for IRQing mov dx,[SBPort] add dl,0Eh in al,dx mov al,20h out 20h,al cmp byte[SBIrq],7 jbe .nohighirq mov al,20h out 0A0h,al .nohighirq sti jmp Startprocsbdata section .data ;ALIGN=32 echowrittento db 0 section .text NEWSYM stopsbsound ; mov byte[Voice0Status],0 ; mov byte[Voice1Status],0 ; mov byte[Voice2Status],0 ; mov byte[Voice3Status],0 ; mov byte[Voice4Status],0 ; mov byte[Voice5Status],0 ; mov byte[Voice6Status],0 ; mov byte[Voice7Status],0 mov ax,ds mov es,ax mov edi,DSPBuffer mov ecx,[BufferSizeB] xor eax,eax rep stosd cmp byte[SBswitch],0 jne near .2ndblock ; clear block mov es,[sbselec] mov edi,[sbpmofs] mov ecx,[BufferSizeB] shr ecx,2 .loopa mov dword[es:edi],80808080h add edi,4 dec ecx jnz .loopa jmp .sbend .2ndblock ; copy to 2nd block ; clear memory mov es,[sbselec] mov edi,[sbpmofs] add edi,[BufferSizeB] mov ecx,[BufferSizeB] shr ecx,2 .loopb mov dword[es:edi],80808080h add edi,4 dec ecx jnz .loopb .sbend xor byte [SBswitch],1 ; acknowledge SB for IRQing mov dx,[SBPort] add dl,0Eh in al,dx mov al,20h out 20h,al cmp byte[SBIrq],7 jbe .nohighirq mov al,20h out 0A0h,al .nohighirq pop es pop esi pop edi pop edx pop ecx pop ebx pop eax pop ds sti iretd section .data ;ALIGN=32 NEWSYM sbhandexec, dd 0 section .text ; Process 20 blocks * 8 voices (no pitch yet) NEWSYM SBHandler16 push ebx push ecx push edx push edi push esi push es inc dword[sbhandexec] cmp byte [vibracard], 1 je .donotcallcmdapos call GetCDMAPos .donotcallcmdapos cmp byte[csounddisable],1 je near stopsbsound16 test byte[DSPMem+6Ch],11000000b jnz near stopsbsound16 mov es,[sbselec] cmp byte[SBswitch],0 jne near .2ndblock mov edi,[sbpmofs] jmp .doneblock .2ndblock ; copy to 2nd block ; clear memory mov edi,[sbpmofs] add edi,[BufferSizeW] .doneblock mov esi,DSPBuffer mov ecx,[BufferSizeB] cmp byte[Surround],0 je .nosurround cmp byte[StereoSound],0 ; jne near .surroundstereo je .surroundmono ; jmp .surroundmono .nosurround .loopb mov eax,[esi] cmp eax,-32768 jge .noneg5 mov eax,-32768 .noneg5 cmp eax,32767 jle .noneg6 mov eax,32767 .noneg6 mov [es:edi],ax add esi,4 add edi,2 dec ecx jnz .loopb jmp .sbend %ifdef _I_LIKE_SUCKY_FILTERS_ ;bwahaha .surroundstereo shr ecx,1 .loopbs mov eax,[esi] cmp eax,-32768 jge .noneg5s mov eax,-32768 .noneg5s cmp eax,32767 jle .noneg6s mov eax,32767 .noneg6s mov [es:edi],ax mov eax,[esi+4] cmp eax,-32768 jge .noneg5s2 mov eax,-32768 .noneg5s2 cmp eax,32767 jle .noneg6s2 mov eax,32767 .noneg6s2 neg ax mov [es:edi+2],ax add esi,8 add edi,4 dec ecx jnz .loopbs jmp .sbend %endif .surroundmono cmp byte[SBswitch],0 je .1stblock add edi,[BufferSizeW] .1stblock .loopbm mov eax,[esi] cmp eax,-32768 jge .noneg5m mov eax,-32768 .noneg5m cmp eax,32767 jle .noneg6m mov eax,32767 .noneg6m mov [es:edi],ax neg ax mov [es:edi+2],ax add esi,4 add edi,4 dec ecx jnz .loopbm .sbend xor byte [SBswitch],1 ; acknowledge SB for IRQing mov dx,[SBPort] add dl,0Fh in al,dx mov al,20h out 20h,al cmp byte[SBIrq],7 jbe .nohighirq mov al,20h out 0A0h,al .nohighirq sti Startprocsbdata: call ProcessSoundBuffer pop es pop esi pop edi pop edx pop ecx pop ebx pop eax pop ds iretd NEWSYM ProcessSoundBuffer ; Clear the DSP Buffer mov edi,DSPBuffer mov ax,ds mov es,ax xor eax,eax mov ecx,[BufferSizeB] rep stosd ; Clear Echo Buffer cmp byte[cfgecho],1 je .nowriteecho test byte[DSPMem+6Ch],20h jnz .nowriteecho mov edi,EchoBuffer mov ecx,[BufferSizeB] rep stosd .nowriteecho ; Process the sound :I ProcessVoiceHandler16 0,ProcessVoice116,1,254 NEWSYM ProcessVoice116 ProcessVoiceHandler16 1,ProcessVoice216,2,253 NEWSYM ProcessVoice216 ProcessVoiceHandler16 2,ProcessVoice316,4,251 NEWSYM ProcessVoice316 ProcessVoiceHandler16 3,ProcessVoice416,8,247 NEWSYM ProcessVoice416 ProcessVoiceHandler16 4,ProcessVoice516,16,239 NEWSYM ProcessVoice516 ProcessVoiceHandler16 5,ProcessVoice616,32,223 NEWSYM ProcessVoice616 ProcessVoiceHandler16 6,ProcessVoice716,64,191 NEWSYM ProcessVoice716 ProcessVoiceHandler16 7,ProcessVoice816,128,127 NEWSYM ProcessVoice816 cmp byte[cfgecho],1 je near .echowritten test byte[DSPMem+6Ch],20h jnz near .nowriteecho2 mov byte[echowrittento],1 ; Mix Echo with DSP Buffer cmp dword[FIRTAPVal0],7Fh jne near .echonotokay cmp dword[FIRTAPVal1],0 jne near .echonotokay cmp dword[FIRTAPVal2],0 jne near .echonotokay cmp dword[FIRTAPVal3],0 jne near .echonotokay cmp dword[FIRTAPVal4],0 jne near .echonotokay cmp dword[FIRTAPVal5],0 jne near .echonotokay cmp dword[FIRTAPVal6],0 jne near .echonotokay cmp dword[FIRTAPVal7],0 jne near .echonotokay MixEcho2 jmp .echowritten .echonotokay MixEcho jmp .echowritten .nowriteecho2 cmp byte[echowrittento],0 je .echowritten mov edi,echobuf mov ecx,[MaxEcho] cmp byte[StereoSound],1 jne .noechostereo add ecx,ecx .noechostereo xor eax,eax rep stosd mov byte[echowrittento],0 .echowritten cmp byte[CNetType],20 je .clearendx cmp byte[MovieProcessing],0 je .skipendxclear .clearendx mov byte[DSPMem+7Ch],0 .skipendxclear cmp byte[RevStereo],0 je .norevstereo mov edi,DSPBuffer mov ax,ds mov es,ax xor eax,eax mov ecx,[BufferSizeB] shr ecx,1 .revstloop mov eax,[edi] mov ebx,[edi+4] mov [edi],ebx mov [edi+4],eax add edi,8 dec ecx jnz .revstloop .norevstereo cmp byte[LowPassFilterType],1 jne near LPFexit mov esi,DSPBuffer cmp byte[StereoSound],1 jz near LPFstereo mov ecx, [BufferSizeB] shr ecx,1 mov ebx,[LPFsample1] NEWSYM LPFmonoloop mov eax,[esi] sar eax,1 add ebx,eax mov [esi],ebx add esi,4 mov ebx,[esi] sar ebx,1 add eax,ebx mov [esi],eax add esi,4 dec ecx jnz near LPFmonoloop mov [LPFsample1],ebx jmp LPFexit NEWSYM LPFstereo mov ecx, [BufferSizeB] shr ecx,2 ; mov ecx, <------------------- # of samples to mix / 4 mov ebx,[LPFsample1] mov edx,[LPFsample2] NEWSYM LPFstereoloop push ecx mov eax,[esi] sar eax,1 add ebx,eax mov [esi],ebx mov ecx,[esi+4] sar ecx,1 add edx,ecx mov [esi+4],edx add esi,8 mov ebx,[esi] sar ebx,1 add eax,ebx mov [esi],eax mov edx,[esi+4] sar edx,1 add ecx,edx mov [esi+4],ecx add esi,8 pop ecx dec ecx jnz near LPFstereoloop mov [LPFsample1],ebx mov [LPFsample2],edx NEWSYM LPFexit ; %ifndef __MSDOS__ ; wtf ... the other surround filter sucks anyway ;P cmp byte[Surround],1 jnz near .nosurround cmp byte[StereoSound],1 jnz near .nosurround mov esi,DSPBuffer mov ecx,[BufferSizeB] shr ecx,1 .loop mov eax,[esi] mov edx,[esi+4] add edx,eax sar edx,1 sub eax,edx ; shl eax,1 mov ebx,[esi+4] sub [esi+4],eax sub ebx,edx ; shl ebx,1 sub [esi],ebx ; sar dword[esi],1 ; sar dword[esi+4],1 ; mov eax,[esi] ; mov edx,[esi+4] ; add edx,eax ; sar edx,1 ; add [esi],edx ; add [esi+4],edx add esi,8 dec ecx jnz near .loop .nosurround ;%endif ret NEWSYM stopsbsound16 ; mov byte[Voice0Status],0 ; mov byte[Voice1Status],0 ; mov byte[Voice2Status],0 ; mov byte[Voice3Status],0 ; mov byte[Voice4Status],0 ; mov byte[Voice5Status],0 ; mov byte[Voice6Status],0 ; mov byte[Voice7Status],0 mov ax,ds mov es,ax mov edi,DSPBuffer mov ecx,[BufferSizeB] xor eax,eax rep stosd cmp byte[SBswitch],0 jne near .2ndblock ; clear block mov es,[sbselec] mov edi,[sbpmofs] mov ecx,[BufferSizeB] shr ecx,1 .loopa mov dword[es:edi],00000000h add edi,4 dec ecx jnz .loopa jmp .sbend .2ndblock ; copy to 2nd block ; clear memory mov es,[sbselec] mov edi,[sbpmofs] add edi,[BufferSizeW] mov ecx,[BufferSizeB] shr ecx,1 .loopb mov dword[es:edi],00000000h add edi,4 dec ecx jnz .loopb .sbend xor byte [SBswitch],1 ; acknowledge SB for IRQing mov dx,[SBPort] add dl,0Fh in al,dx mov al,20h out 20h,al cmp byte[SBIrq],7 jbe .nohighirq mov al,20h out 0A0h,al .nohighirq pop es pop esi pop edi pop edx pop ecx pop ebx pop eax pop ds sti iretd ;**************************************************** ; Sound Blaster Initialization Stuff ;**************************************************** section .data ;ALIGN=32 NEWSYM memoryloc, dd 0 ; Memory offset in conventional memory NEWSYM memoryloc2, dd 0 ; Memory offset in conventional memory NEWSYM sbselec, dw 0 ; Selector of Memory location NEWSYM sbpmofs, dd 0 ; offset of Memory location SBDeinitType db 0 section .text NEWSYM initSB mov eax,[SoundQuality] cmp byte[StereoSound],1 jne .nostereobuf mov ax,[BufferSizes+eax*2] jmp .skipstereobuf .nostereobuf mov ax,[BufferSize+eax*2] .skipstereobuf mov [BufferSizeB],ax add ax,ax mov [BufferSizeW],ax mov byte [SBswitch],0 ; Allocate pointer ; Set up SB call ResetSBDSP ; code added by peter santing cmp byte [vibracard], 1 je near .vibrafix2 cmp byte [SBHDMA],0 je .no16bit cmp byte [SBHDMA],4 jb near .init16bitlowhdma jmp .init16bit .no16bit ; Determine Version # mov al,0E1h call WriteDSP call ReadDSP mov [.Versionnum],al call ReadDSP mov [.Versionnum+1],al ; Turn on speakers mov al,0D1h call WriteDSP ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) ) ; 8000=131, 22050=210, 44100=233, 11025=165 mov al,40h call WriteDSP ; cmp byte[Surround],0 ; jne .surround8b cmp byte[StereoSound],1 jne .nostereo8b .surround8b mov eax,[SoundQuality] cmp eax,2 jbe .okay mov eax,2 .okay mov al,byte [SoundSpeedt+eax] call WriteDSP ; Set Stereo mov dx, [SBPort] add dx, 04h mov al,0Eh out dx,al inc dx in al,dx or al,022h out dx,al jmp .donestereo .nostereo8b mov eax,[SoundQuality] mov al,byte [SoundSpeeds+eax] call WriteDSP .donestereo cmp byte[StereoSound],1 je .highmode mov eax,[SoundQuality] cmp byte [SoundSpeeds+eax],211 ja .highmode mov byte[.Versionnum],1 .highmode ; Setup DMA ; Select DMA channel mov al,[SBDMA] add al,4 mov dx,000Ah out dx,al ; Clear DMA mov al,00h mov dx,000Ch out dx,al ; Set autoinit/write (set as DAC) mov al,58h add al,[SBDMA] mov dx,000Bh out dx,al ; Send Offset Address mov al,[memoryloc] mov dl,[SBDMA] shl dl,1 out dx,al mov al,[memoryloc+1] out dx,al ; Send length of entire block mov ax,[BufferSizeW] dec ax inc dx out dx,al mov al,ah out dx,al ; Send page # (address/65536) mov al,[memoryloc+2] mov dl,[SBDMAPage] out dx,al ; turn on DMA mov al,[SBDMA] mov dx,000Ah out dx,al ; Prepare SB for the first block ; 8-bit auto-init, mono, unsigned mov al,048h ; Sb 2.0 version... call WriteDSP ; Send Length-1 to DSP port mov ax,[BufferSizeB] dec ax call WriteDSP mov al,ah call WriteDSP mov byte[SBDeinitType],1 mov al,090h ; Sb 2.0 version... cmp byte[.Versionnum],2 jne .noversion2 cmp byte[.Versionnum+1],0 je .slowspeed .noversion2 cmp byte[.Versionnum],1 ja .notversion1 .slowspeed mov byte[SBDeinitType],0 mov al,1Ch .notversion1 call WriteDSP jmp .fixsurround SECTION .data ;ALIGN=32 .Versionnum dw 0 SECTION .text ; ***************************************** ; **** alternate ViBRA16X SB init code **** by Peter Santing ; ***************************************** copied portions of original code ; and modified it. .vibrafix2 ; notify user that we're in ViBRA16x mode.. push eax mov dword [Msgptr], vibmsg mov eax, [MsgCount] mov [MessageOn], eax pop eax ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) ) ; 8000=131, 22050=210, 44100=233, 11025=165 ; Setup DMA ; Select DMA channel mov al,[SBDMA] add al,4 mov dx,000Ah out dx,al ; Clear DMA mov al,00h mov dx,000Ch out dx,al ; Set autoinit/write (set as DAC) mov al,58h add al,[SBDMA] mov dx,000Bh out dx,al ; Send Offset Address mov al,[memoryloc] mov dl,[SBDMA] shl dl,1 out dx,al mov al,[memoryloc+1] out dx,al ; Send length of entire block mov ax,[BufferSizeW] shl ax, 1 dec ax inc dx out dx,al mov al,ah out dx,al ; Send page # (address/65536) mov al,[memoryloc+2] mov dh, 0 mov dl,[SBDMAPage] out dx,al ; turn on DMA mov al,[SBDMA] mov dx,000Ah out dx,al mov al,41h call WriteDSP push ecx mov ecx,[SoundQuality] mov al,byte [SBToSPCSpeeds2+ecx*4+1] pop ecx call WriteDSP push ecx mov ecx,[SoundQuality] mov al,byte [SBToSPCSpeeds2+ecx*4] pop ecx call WriteDSP ; Prepare SB for the first block ; 16-bit auto-init, mono, unsigned mov al,0B6h ; Sb 16 version (DSP 4) call WriteDSP cmp byte[StereoSound],1 jne ._Mono ._surround mov al,30h ; stereo/signed call WriteDSP jmp ._AfterStereo ._Mono mov al,10h ; mono/signed call WriteDSP ._AfterStereo ; Send Length-1 to DSP port mov ax,[BufferSizeB] dec ax call WriteDSP mov al,ah call WriteDSP ; Turn on speakers mov al,0D1h call WriteDSP jmp .fixsurround ; ******* end of alternate SB init code for ViBRA ******** .init16bitlowhdma ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) ) ; 8000=131, 22050=210, 44100=233, 11025=165 mov al,40h call WriteDSP push ecx mov ecx,[SoundQuality] mov al,byte [SoundSpeeds+ecx] pop ecx call WriteDSP mov edx,[memoryloc] shr edx,1 mov [memoryloc2],edx ; Setup DMA ; turn off DMA ; mov al,[SBHDMA] ; and al,03h ; or al,04h ; mov dx,00D4h ; out dx,al ; Setup DMA ; Select DMA channel mov al,[SBHDMA] and al,03h or al,04h mov dx,000Ah out dx,al ; clear flip-flop mov dx,00D8h xor al,al out dx,al ; Set autoinit/write (set as DAC) mov al,[SBHDMA] and al,3 add al,58h mov dx,00D6h out dx,al ; Send Offset Address ; mov al,[memoryloc2] ; mov dl,[SBHDMA] ; and dl,3 ; shl dl,2 ; add dl,0C0h ; out dx,al ; mov al,[memoryloc2+1] ; out dx,al ; Send Offset Address mov al,[memoryloc] mov dl,[SBDMA] shl dl,1 out dx,al mov al,[memoryloc+1] out dx,al ; Send length of entire block mov ax,[BufferSizeW] dec ax add dx,2 out dx,al mov al,ah out dx,al ; Send page # (address/65536) mov al,[memoryloc+2] mov dl,[SBHDMAPage] out dx,al ; Prepare SB for the first block ; 16-bit auto-init, mono, unsigned mov al,0B6h ; Sb 16 version (DSP 4) call WriteDSP ; cmp byte[Surround],0 ; jne .surroundl cmp byte[StereoSound],1 jne .Monol .surroundl mov al,30h ; stereo/signed call WriteDSP jmp .AfterStereol .Monol mov al,10h ; mono/signed call WriteDSP .AfterStereol ; Send Length-1 to DSP port mov ax,[BufferSizeB] dec ax call WriteDSP mov al,ah call WriteDSP ; turn on DMA ; mov al,[SBHDMA] ; and al,03h ; mov dx,00D4h ; out dx,al ; Setup DMA ; Select DMA channel mov al,[SBHDMA] and al,03h mov dx,000Ah out dx,al ; Turn on speakers mov al,0D1h call WriteDSP jmp .fixsurround .init16bit ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) ) ; 8000=131, 22050=210, 44100=233, 11025=165 mov al,41h call WriteDSP push ecx mov ecx,[SoundQuality] mov al,byte [SBToSPCSpeeds2+ecx*4+1] pop ecx call WriteDSP push ecx mov ecx,[SoundQuality] mov al,byte [SBToSPCSpeeds2+ecx*4] pop ecx call WriteDSP mov edx,[memoryloc] shr edx,1 mov [memoryloc2],edx ; Setup DMA ; turn off DMA mov al,[SBHDMA] and al,03h or al,04h mov dx,00D4h out dx,al ; clear flip-flop mov dx,00D8h xor al,al out dx,al ; Set autoinit/write (set as DAC) mov al,[SBHDMA] and al,3 add al,58h mov dx,00D6h out dx,al ; Send Offset Address mov al,[memoryloc2] mov dl,[SBHDMA] and dl,3 shl dl,2 add dl,0C0h out dx,al mov al,[memoryloc2+1] out dx,al ; Send length of entire block mov ax,[BufferSizeW] dec ax add dx,2 out dx,al mov al,ah out dx,al ; Send page # (address/65536) mov al,[memoryloc+2] mov dl,[SBHDMAPage] and al,0FEh out dx,al ; Prepare SB for the first block ; 16-bit auto-init, mono, unsigned mov al,0B6h ; Sb 16 version (DSP 4) call WriteDSP ; cmp byte[Surround],0 ; jne .surround cmp byte[StereoSound],1 jne .Mono .surround mov al,30h ; stereo/signed call WriteDSP jmp .AfterStereo .Mono mov al,10h ; mono/signed call WriteDSP .AfterStereo ; Send Length-1 to DSP port mov ax,[BufferSizeB] dec ax call WriteDSP mov al,ah call WriteDSP ; Turn on speakers mov al,0D1h call WriteDSP ; turn on DMA mov al,[SBHDMA] and al,03h mov dx,00D4h out dx,al .fixsurround ; Adjust byte lengths for mono surround sound cmp byte[Surround],0 je .nosurroundadj cmp byte[StereoSound],0 jne .nosurroundadj ; shr word[BufferSizeB],1 ; shr word[BufferSizeW],1 .nosurroundadj ret GetCDMAPos: ; clear flipflop xor ebx,ebx mov bl,[SBDMA] cmp byte[SBHDMA],4 jb .nohdma mov bl,[SBHDMA] mov dx,0Ch .nohdma mov dx,0D8h xor al,al out dx,al nop nop nop nop mov dx,[.wordcountport+ebx*2] in al,dx nop nop mov bl,al in al,dx nop nop nop nop mov bh,al cmp byte[SBHDMA],4 jb .ldma2 add bx,bx .ldma2 ; value returned = bx, # of bytes left for transfer mov cx,[BufferSizeB] mov dx,cx add cx,cx cmp byte[SBHDMA],4 jb .ldmab add cx,cx add dx,dx .ldmab sub cx,bx mov byte[SBswitch],1 cmp cx,dx jb .parta mov byte[SBswitch],0 .parta ret SECTION .data .wordcountport dw 1,3,5,7,0C2h,0C6h,0CAh,0CEh SECTION .text ; old routines, doesn't work w/ sb live! jmp .fin .loop in al,dx nop nop mov cl,al in al,dx nop nop nop nop mov ch,al in al,dx nop nop mov bl,al in al,dx mov bh,al sub cx,bx test cx,8000h jz .notneg neg cx .notneg cmp byte[SBHDMA],4 jb .ldma add cx,cx add bx,bx .ldma cmp cx,4 ja .loop .fin NEWSYM DspProcAsmEnd zsnes-1.36/src/cpu/e65816.inc0100644000175000017500000010021107505521463015075 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM brkv,brkv8,changeexecloop,copv,copv8,curexecstate,curnmi,execloop EXTSYM initaddrl,membank0r16,membank0r8 EXTSYM membank0w16,membank0w8,memtabler16,memtabler8,memtablew16,memtablew8 EXTSYM nmistatus,regaccessbankr8,snesmap2,snesmmap,stackand,stackor,tablead EXTSYM wramdata,xa,xd,xdb,xe,xirqb,xpb,xpc,xs,xx,xy EXTSYM switchtovirq,intrset,UpdateDPage EXTSYM switchtovirqret EXTSYM debstop3,romdata NEWSYM E65816IncStart ; B = ( or ) ; C = , ; L = [ or ] ; I = # COp61m8nd: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bnd COp61m16nd: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bnd COp61m8d: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bd COp61m16d: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bd COp63m8nd: ; ADC d,s addr_dCs_8br ADCMacro8bnd COp63m16nd: ; ADC d,s addr_dCs_16br ADCMacro16bnd COp63m8d: ; ADC d,s addr_dCs_8br ADCMacro8bd COp63m16d: ; ADC d,s addr_dCs_16br ADCMacro16bd COp65m8nd: ; ADC d addr_d_8br ADCMacro8bnd COp65m16nd: ; ADC d addr_d_16br ADCMacro16bnd COp65m8d: ; ADC d addr_d_8br ADCMacro8bd COp65m16d: ; ADC d addr_d_16br ADCMacro16bd COp67m8nd: ; ADC [d] addr_LdL_8br ADCMacro8bnd COp67m16nd: ; ADC [d] addr_LdL_16br ADCMacro16bnd COp67m8d: ; ADC [d] addr_LdL_8br ADCMacro8bd COp67m16d: ; ADC [d] addr_LdL_16br ADCMacro16bd COp69m8nd: ; ADC # addr_I_8br ADCMacro8bnd COp69m16nd: ; ADC # addr_I_16br ADCMacro16bnd COp69m8d: ; ADC # addr_I_8br ADCMacro8bd COp69m16d: ; ADC # addr_I_16br ADCMacro16bd COp6Dm8nd: ; ADC a addr_a_8br ADCMacro8bnd COp6Dm16nd: ; ADC a addr_a_16br ADCMacro16bnd COp6Dm8d: ; ADC a addr_a_8br ADCMacro8bd COp6Dm16d: ; ADC a addr_a_16br ADCMacro16bd COp6Fm8nd: ; ADC al addr_al_8br ADCMacro8bnd COp6Fm16nd: ; ADC al addr_al_16br ADCMacro16bnd COp6Fm8d: ; ADC al addr_al_8br ADCMacro8bd COp6Fm16d: ; ADC al addr_al_16br ADCMacro16bd COp71m8nd: ; ADC(d),y addr_BdBCy_8br ADCMacro8bnd COp71m16nd: ; ADC(d),y addr_BdBCy_16br ADCMacro16bnd COp71m8d: ; ADC(d),y addr_BdBCy_8br ADCMacro8bd COp71m16d: ; ADC(d),y addr_BdBCy_16br ADCMacro16bd COp72m8nd: ; ADC (d) addr_BdB_8br ADCMacro8bnd COp72m16nd: ; ADC (d) addr_BdB_16br ADCMacro16bnd COp72m8d: ; ADC (d) addr_BdB_8br ADCMacro8bd COp72m16d: ; ADC (d) addr_BdB_16br ADCMacro16bd COp73m8nd: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bnd COp73m16nd: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bnd COp73m8d: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bd COp73m16d: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bd COp75m8nd: ; ADC d,x addr_dCx_8br ADCMacro8bnd COp75m16nd: ; ADC d,x addr_dCx_16br ADCMacro16bnd COp75m8d: ; ADC d,x addr_dCx_8br ADCMacro8bd COp75m16d: ; ADC d,x addr_dCx_16br ADCMacro16bd COp77m8nd: ; ADC [d],y addr_LdLCy_8br ADCMacro8bnd COp77m16nd: ; ADC [d],y addr_LdLCy_16br ADCMacro16bnd COp77m8d: ; ADC [d],y addr_LdLCy_8br ADCMacro8bd COp77m16d: ; ADC [d],y addr_LdLCy_16br ADCMacro16bd COp79m8nd: ; ADC a,y addr_aCy_8br ADCMacro8bnd COp79m16nd: ; ADC a,y addr_aCy_16br ADCMacro16bnd COp79m8d: ; ADC a,y addr_aCy_8br ADCMacro8bd COp79m16d: ; ADC a,y addr_aCy_16br ADCMacro16bd COp7Dm8nd: ; ADC a,x addr_aCx_8br ADCMacro8bnd COp7Dm16nd: ; ADC a,x addr_aCx_16br ADCMacro16bnd COp7Dm8d: ; ADC a,x addr_aCx_8br ADCMacro8bd COp7Dm16d: ; ADC a,x addr_aCx_16br ADCMacro16bd COp7Fm8nd: ; ADC al,x addr_alCx_8br ADCMacro8bnd COp7Fm16nd: ; ADC al,x addr_alCx_16br ADCMacro16bnd COp7Fm8d: ; ADC al,x addr_alCx_8br ADCMacro8bd COp7Fm16d: ; ADC al,x addr_alCx_16br ADCMacro16bd COp21m8: ; AND(d,x) addr_BdCxB_8br ANDMacro8b COp21m16:; AND(d,x) addr_BdCxB_16br ANDMacro16b COp23m8: ; AND d,s addr_dCs_8br ANDMacro8b COp23m16:; AND d,s addr_dCs_16br ANDMacro16b COp25m8: ; AND d addr_d_8br ANDMacro8b COp25m16:; AND d addr_d_16br ANDMacro16b COp27m8: ; AND [d] addr_LdL_8br ANDMacro8b COp27m16:; AND [d] addr_LdL_16br ANDMacro16b COp29m8: ; AND # addr_I_8br ANDMacro8b COp29m16:; AND # addr_I_16br ANDMacro16b COp2Dm8: ; AND a addr_a_8br ANDMacro8b COp2Dm16:; AND a addr_a_16br ANDMacro16b COp2Fm8: ; AND al addr_al_8br ANDMacro8b COp2Fm16:; AND al addr_al_16br ANDMacro16b COp31m8: ; AND(d),y addr_BdBCy_8br ANDMacro8b COp31m16:; AND(d),y addr_BdBCy_16br ANDMacro16b COp32m8: ; AND (d) addr_BdB_8br ANDMacro8b COp32m16:; AND (d) addr_BdB_16br ANDMacro16b COp33m8: ; AND(d,s),y addr_BdCsBCy_8br ANDMacro8b COp33m16:; AND(d,s),y addr_BdCsBCy_16br ANDMacro16b COp35m8: ; AND d,x addr_dCx_8br ANDMacro8b COp35m16:; AND d,x addr_dCx_16br ANDMacro16b COp37m8: ; AND [d],y addr_LdLCy_8br ANDMacro8b COp37m16:; AND [d],y addr_LdLCy_16br ANDMacro16b COp39m8: ; AND a,y addr_aCy_8br ANDMacro8b COp39m16:; AND a,y addr_aCy_16br ANDMacro16b COp3Dm8: ; AND a,x addr_aCx_8br ANDMacro8b COp3Dm16:; AND a,x addr_aCx_16br ANDMacro16b COp3Fm8: ; AND al,x addr_alCx_8br ANDMacro8b COp3Fm16:; AND al,x addr_alCx_16br ANDMacro16b COp06m8: ; ASL d addr_d_8brni ASLMacro8b addr_d_8bw endloop COp06m16:; ASL d addr_d_16brni ASLMacro16b addr_d_16bw endloop COp0Am8: ; ASL A addr_A_8brni ASLMacro8b addr_A_8bw endloop COp0Am16:; ASL A addr_A_16brni ASLMacro16b addr_A_16bw endloop COp0Em8: ; ASL a addr_a_8brni ASLMacro8b addr_a_8bw endloop COp0Em16:; ASL a addr_a_16brni ASLMacro16b addr_a_16bw endloop COp16m8: ; ASL d,x addr_dCx_8brni ASLMacro8b addr_dCx_8bw endloop COp16m16:; ASL d,x addr_dCx_16brni ASLMacro16b addr_dCx_16bw endloop COp1Em8: ; ASL a,x addr_aCx_8brni ASLMacro8b addr_aCx_8bw endloop COp1Em16:; ASL a,x addr_aCx_16brni ASLMacro16b addr_aCx_16bw endloop COp90: ; BCC r test byte[flagc],01h jnz .skip JumpMacro COpB0: ; BCS r test byte[flagc],01h jz .skip JumpMacro COpF0: ; BEQ r test dword[flagnz],0FFFFh jnz .skip JumpMacro COp30: ; BMI r test dword[flagnz],018000h jz .skip JumpMacro COpD0: ; BNE r test dword[flagnz],0FFFFh jz .skip JumpMacro COp10: ; BPL r test dword[flagnz],018000h jnz .skip JumpMacro COp80: ; BRA r movsx eax,byte[esi] inc esi add esi,eax endloop COp50: ; BVC r test dword[flago],0FFh jnz .skip JumpMacro COp70: ; BVS r test dword[flago],0FFh jz .skip JumpMacro ; BIT instruction does not affect N and V flags when using immediate ; addressing mode. When using other addressing modes, the N and V flags COp89m8: ; BIT # BITMacroim8b COp89m16:; BIT # BITMacroim16b COp24m8: ; BIT d addr_d_8br BITMacro8b COp24m16:; BIT d addr_d_16br BITMacro16b COp2Cm8: ; BIT a addr_a_8br BITMacro8b COp2Cm16:; BIT a addr_a_16br BITMacro16b COp34m8: ; BIT d,x addr_dCx_8br BITMacro8b COp34m16:; BIT d,x addr_dCx_16br BITMacro16b COp3Cm8: ; BIT a,x addr_aCx_8br BITMacro8b COp3Cm16:; BIT a,x addr_aCx_16br BITMacro16b COp00: ; BRK s BRKMacro COp82: ; BRL rl BRLMacro COp18: ; CLC i mov dword[flagc],0 endloop COpD8: ; CLD i and dl,0F7h mov bl,dl mov edi,[tablead+ebx*4] endloop COp58: ; CLI i and dl,0FBh cmp byte[doirqnext],0 je .noirqexec mov byte[doirqnext],0 call switchtovirqret .noirqexec endloop COpB8: ; CLV i mov dword[flago],0 endloop COpC1m8: ; CMP(d,x) addr_BdCxB_8br CMPMacro8b COpC1m16:; CMP(d,x) addr_BdCxB_16br CMPMacro16b COpC3m8: ; CMP d,s addr_dCs_8br CMPMacro8b COpC3m16:; CMP d,s addr_dCs_16br CMPMacro16b COpC5m8: ; CMP d addr_d_8br CMPMacro8b COpC5m16:; CMP d addr_d_16br CMPMacro16b COpC7m8: ; CMP [d] addr_LdL_8br CMPMacro8b COpC7m16:; CMP [d] addr_LdL_16br CMPMacro16b COpC9m8: ; CMP # addr_I_8br CMPMacro8b COpC9m16:; CMP # addr_I_16br CMPMacro16b COpCDm8: ; CMP a addr_a_8br CMPMacro8b COpCDm16:; CMP a addr_a_16br CMPMacro16b COpCFm8: ; CMP al addr_al_8br CMPMacro8b COpCFm16:; CMP al addr_al_16br CMPMacro16b COpD1m8: ; CMP(d),y addr_BdBCy_8br CMPMacro8b COpD1m16:; CMP(d),y addr_BdBCy_16br CMPMacro16b COpD2m8: ; CMP (d) addr_BdB_8br CMPMacro8b COpD2m16:; CMP (d) addr_BdB_16br CMPMacro16b COpD3m8: ; CMP(d,s),y addr_BdCsBCy_8br CMPMacro8b COpD3m16:; CMP(d,s),y addr_BdCsBCy_16br CMPMacro16b COpD5m8: ; CMP d,x addr_dCx_8br CMPMacro8b COpD5m16:; CMP d,x addr_dCx_16br CMPMacro16b COpD7m8: ; CMP [d],y addr_LdLCy_8br CMPMacro8b COpD7m16:; CMP [d],y addr_LdLCy_16br CMPMacro16b COpD9m8: ; CMP a,y addr_aCy_8br CMPMacro8b COpD9m16:; CMP a,y addr_aCy_16br CMPMacro16b COpDDm8: ; CMP a,x addr_aCx_8br CMPMacro8b COpDDm16:; CMP a,x addr_aCx_16br CMPMacro16b COpDFm8: ; CMP al,x addr_alCx_8br CMPMacro8b COpDFm16:; CMP al,x addr_alCx_16br CMPMacro16b COp02: ; COP s COPMacro COpE0x8: ; CPX # addr_I_8br CPXMacro8b COpE0x16:; CPX # addr_I_16br CPXMacro16b COpE4x8: ; CPX d addr_d_8br CPXMacro8b COpE4x16:; CPX d addr_d_16br CPXMacro16b COpECx8: ; CPX a addr_a_8br CPXMacro8b COpECx16:; CPX a addr_a_16br CPXMacro16b COpC0x8: ; CPY # addr_I_8br CPYMacro8b COpC0x16:; CPY # addr_I_16br CPYMacro16b COpC4x8: ; CPY d addr_d_8br CPYMacro8b COpC4x16:; CPY d addr_d_16br CPYMacro16b COpCCx8: ; CPY a addr_a_8br CPYMacro8b COpCCx16:; CPY a addr_a_16br CPYMacro16b COp3Am8: ; DEC A addr_A_8brni dec al flagsetnz8bnel addr_A_8bw endloop COp3Am16:; DEC A addr_A_16brni dec ax flagsetnz16bnel addr_A_16bw endloop COpCEm8: ; DEC a addr_a_8brni dec al flagsetnz8bnel addr_a_8bw endloop COpCEm16:; DEC a addr_a_16brni dec ax flagsetnz16bnel addr_a_16bw endloop COpC6m8: ; DEC d addr_d_8brni dec al flagsetnz8bnel addr_d_8bw endloop COpC6m16:; DEC d addr_d_16brni dec ax flagsetnz16bnel addr_d_16bw endloop COpD6m8: ; DEC d,x addr_dCx_8brni dec al flagsetnz8bnel addr_dCx_8bw endloop COpD6m16:; DEC d,x addr_dCx_16brni dec ax flagsetnz16bnel addr_dCx_16bw endloop COpDEm8: ; DEC a,x addr_aCx_8brni dec al flagsetnz8bnel addr_aCx_8bw endloop COpDEm16:; DEC a,x addr_aCx_16brni dec ax flagsetnz16bnel addr_aCx_16bw endloop COpCAx8: ; DEX i dec byte[xx] mov al,[xx] flagsetnz8b endloop COpCAx16:; DEX i dec word[xx] mov ax,[xx] flagsetnz16b endloop COp88x8: ; DEY i dec byte[xy] mov al,[xy] flagsetnz8b endloop COp88x16:; DEY i dec word[xy] mov ax,[xy] flagsetnz16b endloop COp41m8: ; EOR(d,x) addr_BdCxB_8br EORMacro8b COp41m16:; EOR(d,x) addr_BdCxB_16br EORMacro16b COp43m8: ; EOR d,s addr_dCs_8br EORMacro8b COp43m16:; EOR d,s addr_dCs_16br EORMacro16b COp45m8: ; EOR d addr_d_8br EORMacro8b COp45m16:; EOR d addr_d_16br EORMacro16b COp47m8: ; EOR [d] addr_LdL_8br EORMacro8b COp47m16:; EOR [d] addr_LdL_16br EORMacro16b COp49m8: ; EOR # addr_I_8br EORMacro8b COp49m16:; EOR # addr_I_16br EORMacro16b COp4Dm8: ; EOR a addr_a_8br EORMacro8b COp4Dm16:; EOR a addr_a_16br EORMacro16b COp4Fm8: ; EOR al addr_al_8br EORMacro8b COp4Fm16:; EOR al addr_al_16br EORMacro16b COp51m8: ; EOR(d),y addr_BdBCy_8br EORMacro8b COp51m16:; EOR(d),y addr_BdBCy_16br EORMacro16b COp52m8: ; EOR (d) addr_BdB_8br EORMacro8b COp52m16:; EOR (d) addr_BdB_16br EORMacro16b COp53m8: ; EOR(d,s),y addr_BdCsBCy_8br EORMacro8b COp53m16:; EOR(d,s),y addr_BdCsBCy_16br EORMacro16b COp55m8: ; EOR d,x addr_dCx_8br EORMacro8b COp55m16:; EOR d,x addr_dCx_16br EORMacro16b COp57m8: ; EOR [d],y addr_LdLCy_8br EORMacro8b COp57m16:; EOR [d],y addr_LdLCy_16br EORMacro16b COp59m8: ; EOR a,y addr_aCy_8br EORMacro8b COp59m16:; EOR a,y addr_aCy_16br EORMacro16b COp5Dm8: ; EORa,x addr_aCx_8br EORMacro8b COp5Dm16:; EORa,x addr_aCx_16br EORMacro16b COp5Fm8: ; EOR al,x addr_alCx_8br EORMacro8b COp5Fm16:; EOR al,x addr_alCx_16br EORMacro16b COp1Am8: ; INC A addr_A_8brni inc al flagsetnz8bnel addr_A_8bw endloop COp1Am16:; INC A addr_A_16brni inc ax flagsetnz16bnel addr_A_16bw endloop COpEEm8: ; INC a addr_a_8brni inc al flagsetnz8bnel addr_a_8bw endloop COpEEm16:; INC a addr_a_16brni inc ax flagsetnz16bnel addr_a_16bw endloop COpE6m8: ; INC d addr_d_8brni inc al flagsetnz8bnel addr_d_8bw endloop COpE6m16:; INC d addr_d_16brni inc ax flagsetnz16bnel addr_d_16bw endloop COpF6m8: ; INC d,x addr_dCx_8brni inc al flagsetnz8bnel addr_dCx_8bw endloop COpF6m16:; INC d,x addr_dCx_16brni inc ax flagsetnz16bnel addr_dCx_16bw endloop COpFEm8: ; INC a,x addr_aCx_8brni inc al flagsetnz8bnel addr_aCx_8bw endloop COpFEm16:; INC a,x addr_aCx_16brni inc ax flagsetnz16bnel addr_aCx_16bw endloop COpE8x8: ; INX i inc byte[xx] mov al,[xx] flagsetnz8b endloop COpE8x16:; INX i inc word[xx] mov ax,[xx] flagsetnz16b endloop COpC8x8: ; INY i inc byte[xy] mov al,[xy] flagsetnz8b endloop COpC8x16:; INY i inc word[xy] mov ax,[xy] flagsetnz16b endloop COpDC: ; JML (a) JMLMacro COp4C: ; JMP a JMPMacro4C COp6C: ; JMP (a) JMPMacro6C COp7C: ; JMP(a,x) JMPMacro7C COp5C: ; JMP al JMPMacro5C COp22: ; JSL al JSLMacro COp20: ; JSR a JSRMacro20 COpFC: ; JSR(a,x) JSRMacroFC COpA1m8: ; LDA(d,x) addr_BdCxB_8br LDAMacro8b COpA1m16:; LDA(d,x) addr_BdCxB_16br LDAMacro16b COpA3m8: ; LDA d,s addr_dCs_8br LDAMacro8b COpA3m16:; LDA d,s addr_dCs_16br LDAMacro16b COpA5m8: ; LDA d addr_d_8br LDAMacro8b COpA5m16:; LDA d addr_d_16br LDAMacro16b COpA7m8: ; LDA [d] addr_LdL_8br LDAMacro8b COpA7m16:; LDA [d] addr_LdL_16br LDAMacro16b COpA9m8: ; LDA # addr_I_8br LDAMacro8b COpA9m16:; LDA # addr_I_16br LDAMacro16b COpADm8: ; LDA a addr_a_8br LDAMacro8b COpADm16:; LDA a addr_a_16br LDAMacro16b COpAFm8: ; LDA al addr_al_8br LDAMacro8b COpAFm16:; LDA al addr_al_16br LDAMacro16b COpB1m8: ; LDA(d),y addr_BdBCy_8br LDAMacro8b COpB1m16:; LDA(d),y addr_BdBCy_16br LDAMacro16b COpB2m8: ; LDA (d) addr_BdB_8br LDAMacro8b COpB2m16:; LDA (d) addr_BdB_16br LDAMacro16b COpB3m8: ; LDA(d,s),y addr_BdCsBCy_8br LDAMacro8b COpB3m16:; LDA(d,s),y addr_BdCsBCy_16br LDAMacro16b COpB5m8: ; LDA d,x addr_dCx_8br LDAMacro8b COpB5m16:; LDA d,x addr_dCx_16br LDAMacro16b COpB7m8: ; LDA [d],y addr_LdLCy_8br LDAMacro8b COpB7m16:; LDA [d],y addr_LdLCy_16br LDAMacro16b COpB9m8: ; LDA a,y addr_aCy_8br LDAMacro8b COpB9m16:; LDA a,y addr_aCy_16br LDAMacro16b COpBDm8: ; LDA a,x addr_aCx_8br LDAMacro8b COpBDm16:; LDA a,x addr_aCx_16br LDAMacro16b COpBFm8: ; LDA al,x addr_alCx_8br LDAMacro8b COpBFm16:; LDA al,x addr_alCx_16br LDAMacro16b COpA2x8: ; LDX # addr_I_8br LDXMacro8b COpA2x16:; LDX # addr_I_16br LDXMacro16b COpA6x8: ; LDX d addr_d_8br LDXMacro8b COpA6x16:; LDX d addr_d_16br LDXMacro16b COpAEx8: ; LDX a addr_a_8br LDXMacro8b COpAEx16:; LDX a addr_a_16br LDXMacro16b COpB6x8: ; LDX d,y addr_dCy_8br LDXMacro8b COpB6x16:; LDX d,y addr_dCy_16br LDXMacro16b COpBEx8: ; LDX a,y addr_aCy_8br LDXMacro8b COpBEx16:; LDX a,y addr_aCy_16br LDXMacro16b COpA0x8: ; LDY # addr_I_8br LDYMacro8b COpA0x16:; LDY # addr_I_16br LDYMacro16b COpA4x8: ; LDY d addr_d_8br LDYMacro8b COpA4x16:; LDY d addr_d_16br LDYMacro16b COpACx8: ; LDY a addr_a_8br LDYMacro8b COpACx16:; LDY a addr_a_16br LDYMacro16b COpB4x8: ; LDY d,x addr_dCx_8br LDYMacro8b COpB4x16:; LDY d,x addr_dCx_16br LDYMacro16b COpBCx8: ; LDY a,x addr_aCx_8br LDYMacro8b COpBCx16:; LDY a,x addr_aCx_16br LDYMacro16b COp46m8: ; LSR d addr_d_8brni LSRMacro8b addr_d_8bw endloop COp46m16:; LSR d addr_d_16brni LSRMacro16b addr_d_16bw endloop COp4Am8: ; LSR A addr_A_8brni LSRMacro8b addr_A_8bw endloop COp4Am16:; LSR A addr_A_16brni LSRMacro16b addr_A_16bw endloop COp4Em8: ; LSR a addr_a_8brni LSRMacro8b addr_a_8bw endloop COp4Em16:; LSR a addr_a_16brni LSRMacro16b addr_a_16bw endloop COp56m8: ; LSR d,x addr_dCx_8brni LSRMacro8b addr_dCx_8bw endloop COp56m16:; LSR d,x addr_dCx_16brni LSRMacro16b addr_dCx_16bw endloop COp5Em8: ; LSRa,x addr_aCx_8brni LSRMacro8b addr_aCx_8bw endloop COp5Em16:; LSRa,x addr_aCx_16brni LSRMacro16b addr_aCx_16bw endloop COp54: ; MVN xya MVNMacro COp44: ; MVP xya MVPMacro COpEA: ; NOP i endloop COp01m8: ; ORA(d,x) addr_BdCxB_8br ORAMacro8b COp01m16:; ORA(d,x) addr_BdCxB_16br ORAMacro16b COp03m8: ; ORA d,s addr_dCs_8br ORAMacro8b COp03m16:; ORA d,s addr_dCs_16br ORAMacro16b COp05m8: ; ORA d addr_d_8br ORAMacro8b COp05m16:; ORA d addr_d_16br ORAMacro16b COp07m8: ; ORA [d] addr_LdL_8br ORAMacro8b COp07m16:; ORA [d] addr_LdL_16br ORAMacro16b COp09m8: ; ORA # addr_I_8br ORAMacro8b COp09m16:; ORA # addr_I_16br ORAMacro16b COp0Dm8: ; ORA a addr_a_8br ORAMacro8b COp0Dm16:; ORA a addr_a_16br ORAMacro16b COp0Fm8: ; ORA al addr_al_8br ORAMacro8b COp0Fm16:; ORA al addr_al_16br ORAMacro16b COp11m8: ; ORA(d),y addr_BdBCy_8br ORAMacro8b COp11m16:; ORA(d),y addr_BdBCy_16br ORAMacro16b COp12m8: ; ORA(d) addr_BdB_8br ORAMacro8b COp12m16:; ORA(d) addr_BdB_16br ORAMacro16b COp13m8: ; ORA(d,s),y addr_BdCsBCy_8br ORAMacro8b COp13m16:; ORA(d,s),y addr_BdCsBCy_16br ORAMacro16b COp15m8: ; ORA d,x addr_dCx_8br ORAMacro8b COp15m16:; ORA d,x addr_dCx_16br ORAMacro16b COp17m8: ; ORA [d],y addr_LdLCy_8br ORAMacro8b COp17m16:; ORA [d],y addr_LdLCy_16br ORAMacro16b COp19m8: ; ORA a,y addr_aCy_8br ORAMacro8b COp19m16:; ORA a,y addr_aCy_16br ORAMacro16b COp1Dm8: ; ORA a,x addr_aCx_8br ORAMacro8b COp1Dm16:; ORA a,x addr_aCx_16br ORAMacro16b COp1Fm8: ; ORA al,x addr_alCx_8br ORAMacro8b COp1Fm16:; ORA al,x addr_alCx_16br ORAMacro16b COpF4: ; PEA s PEAMacro COpD4: ; PEI s PEIMacro COp62: ; PER s PERMacro COp48m8: ; PHA s PUSHMacro8b [xa] COp48m16:; PHA s PUSHMacro16b [xa], [xa+1] COp8B: ; PHB s PUSHMacro8b [xdb] COp0B: ; PHD s PUSHMacro16b [xd], [xd+1] COp4B: ; PHK s PUSHMacro8b [xpb] COp08: ; PHP s PUSHMacro8bp COpDAx8: ; PHX s PUSHMacro8b [xx] COpDAx16:; PHX s PUSHMacro16b [xx], [xx+1] COp5Ax8: ; PHY s PUSHMacro8b [xy] COp5Ax16:; PHY s PUSHMacro16b [xy], [xy+1] COp68m8: ; PLA s POPMacro8b [xa] COp68m16:; PLA s POPMacro16b [xa], [xa+1] COpAB: ; PLB s POPMacro8b [xdb] COp2B: ; PLD s POPMacro16bd [xd], [xd+1] COp28: ; PLP s POPMacroP COpFAx8: ; PLX s POPMacro8b [xx] COpFAx16:; PLX s POPMacro16b [xx], [xx+1] COp7Ax8: ; PLY s POPMacro8b [xy] COp7Ax16:; PLY s POPMacro16b [xy], [xy+1] COpC2: ; REP # REPMacro COp26m8: ; ROL d addr_d_8brni ROLMacro8b addr_d_8bw endloop COp26m16:; ROL d addr_d_16brni ROLMacro16b addr_d_16bw endloop COp2Am8: ; ROL A addr_A_8brni ROLMacro8b addr_A_8bw endloop COp2Am16:; ROL A addr_A_16brni ROLMacro16b addr_A_16bw endloop COp2Em8: ; ROL a addr_a_8brni ROLMacro8b addr_a_8bw endloop COp2Em16:; ROL a addr_a_16brni ROLMacro16b addr_a_16bw endloop COp36m8: ; ROL d,x addr_dCx_8brni ROLMacro8b addr_dCx_8bw endloop COp36m16:; ROL d,x addr_dCx_16brni ROLMacro16b addr_dCx_16bw endloop COp3Em8: ; ROL a,x addr_aCx_8brni ROLMacro8b addr_aCx_8bw endloop COp3Em16:; ROL a,x addr_aCx_16brni ROLMacro16b addr_aCx_16bw endloop COp66m8: ; ROR d addr_d_8brni RORMacro8b addr_d_8bw endloop COp66m16:; ROR d addr_d_16brni RORMacro16b addr_d_16bw endloop COp6Am8: ; ROR A addr_A_8brni RORMacro8b addr_A_8bw endloop COp6Am16:; ROR A addr_A_16brni RORMacro16b addr_A_16bw endloop COp6Em8: ; ROR a addr_a_8brni RORMacro8b addr_a_8bw endloop COp6Em16:; ROR a addr_a_16brni RORMacro16b addr_a_16bw endloop COp76m8: ; ROR d,x addr_dCx_8brni RORMacro8b addr_dCx_8bw endloop COp76m16:; ROR d,x addr_dCx_16brni RORMacro16b addr_dCx_16bw endloop COp7Em8: ; ROR a,x addr_aCx_8brni RORMacro8b addr_aCx_8bw endloop COp7Em16:; ROR a,x addr_aCx_16brni RORMacro16b addr_aCx_16bw endloop COp40: ; RTI s RTIMacro COp6B: ; RTL s RTLMacro COp60: ; RTS s RTSMacro COpE1m8nd: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bnd COpE1m16nd: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bnd COpE1m8d: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bd COpE1m16d: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bd COpE3m8nd: ; SBC d,s addr_dCs_8br SBCMacro8bnd COpE3m16nd: ; SBC d,s addr_dCs_16br SBCMacro16bnd COpE3m8d: ; SBC d,s addr_dCs_8br SBCMacro8bd COpE3m16d: ; SBC d,s addr_dCs_16br SBCMacro16bd COpE5m8nd: ; SBC d addr_d_8br SBCMacro8bnd COpE5m16nd: ; SBC d addr_d_16br SBCMacro16bnd COpE5m8d: ; SBC d addr_d_8br SBCMacro8bd COpE5m16d: ; SBC d addr_d_16br SBCMacro16bd COpE7m8nd: ; SBC [d] addr_LdL_8br SBCMacro8bnd COpE7m16nd: ; SBC [d] addr_LdL_16br SBCMacro16bnd COpE7m8d: ; SBC [d] addr_LdL_8br SBCMacro8bd COpE7m16d: ; SBC [d] addr_LdL_16br SBCMacro16bd COpE9m8nd: ; SBC # addr_I_8br SBCMacro8bnd COpE9m16nd: ; SBC # addr_I_16br SBCMacro16bnd COpE9m8d: ; SBC # addr_I_8br SBCMacro8bd COpE9m16d: ; SBC # addr_I_16br SBCMacro16bd COpEDm8nd: ; SBC a addr_a_8br SBCMacro8bnd COpEDm16nd: ; SBC a addr_a_16br SBCMacro16bnd COpEDm8d: ; SBC a addr_a_8br SBCMacro8bd COpEDm16d: ; SBC a addr_a_16br SBCMacro16bd COpEFm8nd: ; SBC al addr_al_8br SBCMacro8bnd COpEFm16nd: ; SBC al addr_al_16br SBCMacro16bnd COpEFm8d: ; SBC al addr_al_8br SBCMacro8bd COpEFm16d: ; SBC al addr_al_16br SBCMacro16bd COpF1m8nd: ; SBC(d),y addr_BdBCy_8br SBCMacro8bnd COpF1m16nd: ; SBC(d),y addr_BdBCy_16br SBCMacro16bnd COpF1m8d: ; SBC(d),y addr_BdBCy_8br SBCMacro8bd COpF1m16d: ; SBC(d),y addr_BdBCy_16br SBCMacro16bd COpF2m8nd: ; SBC (d) addr_BdB_8br SBCMacro8bnd COpF2m16nd: ; SBC (d) addr_BdB_16br SBCMacro16bnd COpF2m8d: ; SBC (d) addr_BdB_8br SBCMacro8bd COpF2m16d: ; SBC (d) addr_BdB_16br SBCMacro16bd COpF3m8nd: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bnd COpF3m16nd: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bnd COpF3m8d: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bd COpF3m16d: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bd COpF5m8nd: ; SBC d,x addr_dCx_8br SBCMacro8bnd COpF5m16nd: ; SBC d,x addr_dCx_16br SBCMacro16bnd COpF5m8d: ; SBC d,x addr_dCx_8br SBCMacro8bd COpF5m16d: ; SBC d,x addr_dCx_16br SBCMacro16bd COpF7m8nd: ; SBC [d],y addr_LdLCy_8br SBCMacro8bnd COpF7m16nd: ; SBC [d],y addr_LdLCy_16br SBCMacro16bnd COpF7m8d: ; SBC [d],y addr_LdLCy_8br SBCMacro8bd COpF7m16d: ; SBC [d],y addr_LdLCy_16br SBCMacro16bd COpF9m8nd: ; SBC a,y addr_aCy_8br SBCMacro8bnd COpF9m16nd: ; SBC a,y addr_aCy_16br SBCMacro16bnd COpF9m8d: ; SBC a,y addr_aCy_8br SBCMacro8bd COpF9m16d: ; SBC a,y addr_aCy_16br SBCMacro16bd COpFDm8nd: ; SBC a,x addr_aCx_8br SBCMacro8bnd COpFDm16nd: ; SBC a,x addr_aCx_16br SBCMacro16bnd COpFDm8d: ; SBC a,x addr_aCx_8br SBCMacro8bd COpFDm16d: ; SBC a,x addr_aCx_16br SBCMacro16bd COpFFm8nd: ; SBC al,x addr_alCx_8br SBCMacro8bnd COpFFm16nd: ; SBC al,x addr_alCx_16br SBCMacro16bnd COpFFm8d: ; SBC al,x addr_alCx_8br SBCMacro8bd COpFFm16d: ; SBC al,x addr_alCx_16br SBCMacro16bd COp38: ; SEC i mov dword[flagc],0FFh endloop COpF8: ; SED i or dl,08h mov bl,dl mov edi,[tablead+ebx*4] endloop COp78: ; SEI i or dl,04h endloop COpE2: ; SEP # SEPMacro COp81m8: ; STA(d,x) STAMacro8b addr_BdCxB_8bw endloop COp81m16:; STA(d,x) STAMacro16b addr_BdCxB_16bw endloop COp83m8: ; STA d,s STAMacro8b addr_dCs_8bw endloop COp83m16:; STA d,s STAMacro16b addr_dCs_16bw endloop COp85m8: ; STA d STAMacro8b addr_d_8bw endloop COp85m16:; STA d STAMacro16b addr_d_16bw endloop COp87m8: ; STA [d] STAMacro8b addr_LdL_8bw endloop COp87m16:; STA [d] STAMacro16b addr_LdL_16bw endloop COp8Dm8: ; STA a STAMacro8b addr_a_8bw endloop COp8Dm16:; STA a STAMacro16b addr_a_16bw endloop COp8Fm8: ; STA al STAMacro8b addr_al_8bw endloop COp8Fm16:; STA al STAMacro16b addr_al_16bw endloop COp91m8: ; STA(d),y STAMacro8b addr_BdBCy_8bw endloop COp91m16:; STA(d),y STAMacro16b addr_BdBCy_16bw endloop COp92m8: ; STA (d) STAMacro8b addr_BdB_8bw endloop COp92m16:; STA (d) STAMacro16b addr_BdB_16bw endloop COp93m8: ; STA(d,s),y STAMacro8b addr_BdCsBCy_8bw endloop COp93m16:; STA(d,s),y STAMacro16b addr_BdCsBCy_16bw endloop COp95m8: ; STA d,x STAMacro8b addr_dCx_8bw endloop COp95m16:; STA d,x STAMacro16b addr_dCx_16bw endloop COp97m8: ; STA [d],y STAMacro8b addr_LdLCy_8bw endloop COp97m16:; STA [d],y STAMacro16b addr_LdLCy_16bw endloop COp99m8: ; STA a,y STAMacro8b addr_aCy_8bw endloop COp99m16:; STA a,y STAMacro16b addr_aCy_16bw endloop COp9Dm8: ; STA a,x STAMacro8b addr_aCx_8bw endloop COp9Dm16:; STA a,x STAMacro16b addr_aCx_16bw endloop COp9Fm8: ; STA al,x STAMacro8b addr_alCx_8bw endloop COp9Fm16:; STA al,x STAMacro16b addr_alCx_16bw endloop COp86x8: ; STX d STXMacro8b addr_d_8bw endloop COp86x16:; STX d STXMacro16b addr_d_16bw endloop COp8Ex8: ; STX a STXMacro8b addr_a_8bw endloop COp8Ex16:; STX a STXMacro16b addr_a_16bw endloop COp96x8: ; STX d,y STXMacro8b addr_dCy_8bw endloop COp96x16:; STX d,y STXMacro16b addr_dCy_16bw endloop COp84x8: ; STY d STYMacro8b addr_d_8bw endloop COp84x16:; STY d STYMacro16b addr_d_16bw endloop COp8Cx8: ; STY a STYMacro8b addr_a_8bw endloop COp8Cx16:; STY a STYMacro16b addr_a_16bw endloop COp94x8: ; STYd,x STYMacro8b addr_dCx_8bw endloop COp94x16:; STYd,x STYMacro16b addr_dCx_16bw endloop COpDB: ; STP i dec esi endloop COp64m8: ; STZ d xor al,al addr_d_8bw endloop COp64m16:; STZ d xor eax,eax addr_d_16bw endloop COp74m8: ; STZ d,x xor al,al addr_dCx_8bw endloop COp74m16:; STZ d,x xor eax,eax addr_dCx_16bw endloop COp9Cm8: ; STZ a xor al,al addr_a_8bw endloop COp9Cm16:; STZ a xor eax,eax addr_a_16bw endloop COp9Em8: ; STZ a,x xor al,al addr_aCx_8bw endloop COp9Em16:; STZ a,x xor eax,eax addr_aCx_16bw endloop COp14m8: ; TRB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_d_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_d_8bw endloop COp14m16:; TRB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_d_16bw endloop COp1Cm8: ; TRB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_a_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_a_8bw endloop COp1Cm16:; TRB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_a_16bw endloop COp04m8: ; TSB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_d_8bw endloop .zero mov word[flagnz],0 or al,cl addr_d_8bw endloop COp04m16:; TSB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_d_16bw endloop COp0Cm8: ; TSB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_a_8bw endloop .zero mov word[flagnz],0 or al,cl addr_a_8bw endloop COp0Cm16:; TSB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_a_16bw endloop COpAAx8: ; TAX i mov al,[xa] mov [xx],al flagsetnz8b endloop COpAAx16:; TAX i mov ax,[xa] mov [xx],ax flagsetnz16b endloop COpA8x8: ; TAY i mov al,[xa] mov [xy],al flagsetnz8b endloop COpA8x16:; TAY i mov ax,[xa] mov [xy],ax flagsetnz16b endloop COp5B: ; TCD i mov ax,[xa] mov [xd],ax call UpdateDPage flagsetnz16b endloop COp1B: ; TCS i mov ax,[xa] test byte[xe],1 jnz .emul mov [xs],ax endloop .emul mov [xs],al endloop COp7B: ; TDC i mov ax,[xd] mov [xa],ax flagsetnz16b endloop COp3B: ; TSC i mov ax,[xs] mov [xa],ax flagsetnz16b endloop COpBAx8: ; TSX i mov al,[xs] mov [xx],al flagsetnz8b endloop COpBAx16:; TSX i mov ax,[xs] mov [xx],ax flagsetnz16b endloop COp8Am8: ; TXA i mov al,[xx] mov [xa],al flagsetnz8b endloop COp8Am16:; TXA i mov ax,[xx] mov [xa],ax flagsetnz16b endloop COp9A: ; TXS i mov ax,[xx] mov [xs],ax test byte[xe],1 jnz .emul endloop .emul mov byte[xs+1],1 endloop COp9Bx8: ; TXY i mov al,[xx] mov [xy],al flagsetnz8b endloop COp9Bx16:; TXY i mov ax,[xx] mov [xy],ax flagsetnz16b endloop COp98m8: ; TYA i mov al,[xy] mov [xa],al flagsetnz8b endloop COp98m16:; TYA i mov ax,[xy] mov [xa],ax flagsetnz16b endloop COpBBx8: ; TYX i mov al,[xy] mov [xx],al flagsetnz8b endloop COpBBx16:; TYX i mov ax,[xy] mov [xx],ax flagsetnz16b endloop COpCB: ; WAI i WAIMacro COpEB: ; XBA i mov ah,[xa] mov al,[xa+1] mov [xa],ax flagsetnz8b endloop COpFB: ; XCE i XCEMacro COp42: ; WDM inc esi endloop NEWSYM E65816IncEnd zsnes-1.36/src/cpu/e65816b.inc0100644000175000017500000007775007505521463015264 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM brkv,brkv8,changeexecloop,copv,copv8,curexecstate,curnmi,execloop EXTSYM initaddrl,membank0r16,membank0r8 EXTSYM membank0w16,membank0w8,memtabler16,memtabler8,memtablew16,memtablew8 EXTSYM nmistatus,regaccessbankr8,snesmap2,snesmmap,stackand,stackor EXTSYM wramdata,xa,xd,xdb,xe,xirqb,xpb,xpc,xs,xx,xy EXTSYM switchtovirq,intrset,UpdateDPage EXTSYM DPageR8,DPageW8,DPageR16,DPageW16 ; B = ( or ) ; C = , ; L = [ or ] ; I = # COp61m8nd: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bnd COp61m16nd: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bnd COp61m8d: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bd COp61m16d: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bd COp63m8nd: ; ADC d,s addr_dCs_8br ADCMacro8bnd COp63m16nd: ; ADC d,s addr_dCs_16br ADCMacro16bnd COp63m8d: ; ADC d,s addr_dCs_8br ADCMacro8bd COp63m16d: ; ADC d,s addr_dCs_16br ADCMacro16bd COp65m8nd: ; ADC d addr_d_8br ADCMacro8bnd COp65m16nd: ; ADC d addr_d_16br ADCMacro16bnd COp65m8d: ; ADC d addr_d_8br ADCMacro8bd COp65m16d: ; ADC d addr_d_16br ADCMacro16bd COp67m8nd: ; ADC [d] addr_LdL_8br ADCMacro8bnd COp67m16nd: ; ADC [d] addr_LdL_16br ADCMacro16bnd COp67m8d: ; ADC [d] addr_LdL_8br ADCMacro8bd COp67m16d: ; ADC [d] addr_LdL_16br ADCMacro16bd COp69m8nd: ; ADC # addr_I_8br ADCMacro8bnd COp69m16nd: ; ADC # addr_I_16br ADCMacro16bnd COp69m8d: ; ADC # addr_I_8br ADCMacro8bd COp69m16d: ; ADC # addr_I_16br ADCMacro16bd COp6Dm8nd: ; ADC a addr_a_8br ADCMacro8bnd COp6Dm16nd: ; ADC a addr_a_16br ADCMacro16bnd COp6Dm8d: ; ADC a addr_a_8br ADCMacro8bd COp6Dm16d: ; ADC a addr_a_16br ADCMacro16bd COp6Fm8nd: ; ADC al addr_al_8br ADCMacro8bnd COp6Fm16nd: ; ADC al addr_al_16br ADCMacro16bnd COp6Fm8d: ; ADC al addr_al_8br ADCMacro8bd COp6Fm16d: ; ADC al addr_al_16br ADCMacro16bd COp71m8nd: ; ADC(d),y addr_BdBCy_8br ADCMacro8bnd COp71m16nd: ; ADC(d),y addr_BdBCy_16br ADCMacro16bnd COp71m8d: ; ADC(d),y addr_BdBCy_8br ADCMacro8bd COp71m16d: ; ADC(d),y addr_BdBCy_16br ADCMacro16bd COp72m8nd: ; ADC (d) addr_BdB_8br ADCMacro8bnd COp72m16nd: ; ADC (d) addr_BdB_16br ADCMacro16bnd COp72m8d: ; ADC (d) addr_BdB_8br ADCMacro8bd COp72m16d: ; ADC (d) addr_BdB_16br ADCMacro16bd COp73m8nd: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bnd COp73m16nd: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bnd COp73m8d: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bd COp73m16d: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bd COp75m8nd: ; ADC d,x addr_dCx_8br ADCMacro8bnd COp75m16nd: ; ADC d,x addr_dCx_16br ADCMacro16bnd COp75m8d: ; ADC d,x addr_dCx_8br ADCMacro8bd COp75m16d: ; ADC d,x addr_dCx_16br ADCMacro16bd COp77m8nd: ; ADC [d],y addr_LdLCy_8br ADCMacro8bnd COp77m16nd: ; ADC [d],y addr_LdLCy_16br ADCMacro16bnd COp77m8d: ; ADC [d],y addr_LdLCy_8br ADCMacro8bd COp77m16d: ; ADC [d],y addr_LdLCy_16br ADCMacro16bd COp79m8nd: ; ADC a,y addr_aCy_8br ADCMacro8bnd COp79m16nd: ; ADC a,y addr_aCy_16br ADCMacro16bnd COp79m8d: ; ADC a,y addr_aCy_8br ADCMacro8bd COp79m16d: ; ADC a,y addr_aCy_16br ADCMacro16bd COp7Dm8nd: ; ADC a,x addr_aCx_8br ADCMacro8bnd COp7Dm16nd: ; ADC a,x addr_aCx_16br ADCMacro16bnd COp7Dm8d: ; ADC a,x addr_aCx_8br ADCMacro8bd COp7Dm16d: ; ADC a,x addr_aCx_16br ADCMacro16bd COp7Fm8nd: ; ADC al,x addr_alCx_8br ADCMacro8bnd COp7Fm16nd: ; ADC al,x addr_alCx_16br ADCMacro16bnd COp7Fm8d: ; ADC al,x addr_alCx_8br ADCMacro8bd COp7Fm16d: ; ADC al,x addr_alCx_16br ADCMacro16bd COp21m8: ; AND(d,x) addr_BdCxB_8br ANDMacro8b COp21m16:; AND(d,x) addr_BdCxB_16br ANDMacro16b COp23m8: ; AND d,s addr_dCs_8br ANDMacro8b COp23m16:; AND d,s addr_dCs_16br ANDMacro16b COp25m8: ; AND d addr_d_8br ANDMacro8b COp25m16:; AND d addr_d_16br ANDMacro16b COp27m8: ; AND [d] addr_LdL_8br ANDMacro8b COp27m16:; AND [d] addr_LdL_16br ANDMacro16b COp29m8: ; AND # addr_I_8br ANDMacro8b COp29m16:; AND # addr_I_16br ANDMacro16b COp2Dm8: ; AND a addr_a_8br ANDMacro8b COp2Dm16:; AND a addr_a_16br ANDMacro16b COp2Fm8: ; AND al addr_al_8br ANDMacro8b COp2Fm16:; AND al addr_al_16br ANDMacro16b COp31m8: ; AND(d),y addr_BdBCy_8br ANDMacro8b COp31m16:; AND(d),y addr_BdBCy_16br ANDMacro16b COp32m8: ; AND (d) addr_BdB_8br ANDMacro8b COp32m16:; AND (d) addr_BdB_16br ANDMacro16b COp33m8: ; AND(d,s),y addr_BdCsBCy_8br ANDMacro8b COp33m16:; AND(d,s),y addr_BdCsBCy_16br ANDMacro16b COp35m8: ; AND d,x addr_dCx_8br ANDMacro8b COp35m16:; AND d,x addr_dCx_16br ANDMacro16b COp37m8: ; AND [d],y addr_LdLCy_8br ANDMacro8b COp37m16:; AND [d],y addr_LdLCy_16br ANDMacro16b COp39m8: ; AND a,y addr_aCy_8br ANDMacro8b COp39m16:; AND a,y addr_aCy_16br ANDMacro16b COp3Dm8: ; AND a,x addr_aCx_8br ANDMacro8b COp3Dm16:; AND a,x addr_aCx_16br ANDMacro16b COp3Fm8: ; AND al,x addr_alCx_8br ANDMacro8b COp3Fm16:; AND al,x addr_alCx_16br ANDMacro16b COp06m8: ; ASL d addr_d_8brni ASLMacro8b addr_d_8bw endloop COp06m16:; ASL d addr_d_16brni ASLMacro16b addr_d_16bw endloop COp0Am8: ; ASL A addr_A_8brni ASLMacro8b addr_A_8bw endloop COp0Am16:; ASL A addr_A_16brni ASLMacro16b addr_A_16bw endloop COp0Em8: ; ASL a addr_a_8brni ASLMacro8b addr_a_8bw endloop COp0Em16:; ASL a addr_a_16brni ASLMacro16b addr_a_16bw endloop COp16m8: ; ASL d,x addr_dCx_8brni ASLMacro8b addr_dCx_8bw endloop COp16m16:; ASL d,x addr_dCx_16brni ASLMacro16b addr_dCx_16bw endloop COp1Em8: ; ASL a,x addr_aCx_8brni ASLMacro8b addr_aCx_8bw endloop COp1Em16:; ASL a,x addr_aCx_16brni ASLMacro16b addr_aCx_16bw endloop COp90: ; BCC r test byte[flagc],01h jnz .skip JumpMacro COpB0: ; BCS r test byte[flagc],01h jz .skip JumpMacro COpF0: ; BEQ r test dword[flagnz],0FFFFh jnz .skip JumpMacro COp30: ; BMI r test dword[flagnz],018000h jz .skip JumpMacro COpD0: ; BNE r test dword[flagnz],0FFFFh jz .skip JumpMacro COp10: ; BPL r test dword[flagnz],018000h jnz .skip JumpMacro COp80: ; BRA r movsx eax,byte[esi] inc esi add esi,eax endloop COp50: ; BVC r test dword[flago],0FFh jnz .skip JumpMacro COp70: ; BVS r test dword[flago],0FFh jz .skip JumpMacro ; BIT instruction does not affect N and V flags when using immediate ; addressing mode. When using other addressing modes, the N and V flags COp89m8: ; BIT # BITMacroim8b COp89m16:; BIT # BITMacroim16b COp24m8: ; BIT d addr_d_8br BITMacro8b COp24m16:; BIT d addr_d_16br BITMacro16b COp2Cm8: ; BIT a addr_a_8br BITMacro8b COp2Cm16:; BIT a addr_a_16br BITMacro16b COp34m8: ; BIT d,x addr_dCx_8br BITMacro8b COp34m16:; BIT d,x addr_dCx_16br BITMacro16b COp3Cm8: ; BIT a,x addr_aCx_8br BITMacro8b COp3Cm16:; BIT a,x addr_aCx_16br BITMacro16b COp00: ; BRK s BRKMacro COp82: ; BRL rl BRLMacro COp18: ; CLC i mov dword[flagc],0 endloop COpD8: ; CLD i and dl,0F7h mov bl,dl mov edi,[tableadb+ebx*4] endloop COp58: ; CLI i and dl,0FBh endloop COpB8: ; CLV i mov dword[flago],0 endloop COpC1m8: ; CMP(d,x) addr_BdCxB_8br CMPMacro8b COpC1m16:; CMP(d,x) addr_BdCxB_16br CMPMacro16b COpC3m8: ; CMP d,s addr_dCs_8br CMPMacro8b COpC3m16:; CMP d,s addr_dCs_16br CMPMacro16b COpC5m8: ; CMP d addr_d_8br CMPMacro8b COpC5m16:; CMP d addr_d_16br CMPMacro16b COpC7m8: ; CMP [d] addr_LdL_8br CMPMacro8b COpC7m16:; CMP [d] addr_LdL_16br CMPMacro16b COpC9m8: ; CMP # addr_I_8br CMPMacro8b COpC9m16:; CMP # addr_I_16br CMPMacro16b COpCDm8: ; CMP a addr_a_8br CMPMacro8b COpCDm16:; CMP a addr_a_16br CMPMacro16b COpCFm8: ; CMP al addr_al_8br CMPMacro8b COpCFm16:; CMP al addr_al_16br CMPMacro16b COpD1m8: ; CMP(d),y addr_BdBCy_8br CMPMacro8b COpD1m16:; CMP(d),y addr_BdBCy_16br CMPMacro16b COpD2m8: ; CMP (d) addr_BdB_8br CMPMacro8b COpD2m16:; CMP (d) addr_BdB_16br CMPMacro16b COpD3m8: ; CMP(d,s),y addr_BdCsBCy_8br CMPMacro8b COpD3m16:; CMP(d,s),y addr_BdCsBCy_16br CMPMacro16b COpD5m8: ; CMP d,x addr_dCx_8br CMPMacro8b COpD5m16:; CMP d,x addr_dCx_16br CMPMacro16b COpD7m8: ; CMP [d],y addr_LdLCy_8br CMPMacro8b COpD7m16:; CMP [d],y addr_LdLCy_16br CMPMacro16b COpD9m8: ; CMP a,y addr_aCy_8br CMPMacro8b COpD9m16:; CMP a,y addr_aCy_16br CMPMacro16b COpDDm8: ; CMP a,x addr_aCx_8br CMPMacro8b COpDDm16:; CMP a,x addr_aCx_16br CMPMacro16b COpDFm8: ; CMP al,x addr_alCx_8br CMPMacro8b COpDFm16:; CMP al,x addr_alCx_16br CMPMacro16b COp02: ; COP s COPMacro COpE0x8: ; CPX # addr_I_8br CPXMacro8b COpE0x16:; CPX # addr_I_16br CPXMacro16b COpE4x8: ; CPX d addr_d_8br CPXMacro8b COpE4x16:; CPX d addr_d_16br CPXMacro16b COpECx8: ; CPX a addr_a_8br CPXMacro8b COpECx16:; CPX a addr_a_16br CPXMacro16b COpC0x8: ; CPY # addr_I_8br CPYMacro8b COpC0x16:; CPY # addr_I_16br CPYMacro16b COpC4x8: ; CPY d addr_d_8br CPYMacro8b COpC4x16:; CPY d addr_d_16br CPYMacro16b COpCCx8: ; CPY a addr_a_8br CPYMacro8b COpCCx16:; CPY a addr_a_16br CPYMacro16b COp3Am8: ; DEC A addr_A_8brni dec al flagsetnz8bnel addr_A_8bw endloop COp3Am16:; DEC A addr_A_16brni dec ax flagsetnz16bnel addr_A_16bw endloop COpCEm8: ; DEC a addr_a_8brni dec al flagsetnz8bnel addr_a_8bw endloop COpCEm16:; DEC a addr_a_16brni dec ax flagsetnz16bnel addr_a_16bw endloop COpC6m8: ; DEC d addr_d_8brni dec al flagsetnz8bnel addr_d_8bw endloop COpC6m16:; DEC d addr_d_16brni dec ax flagsetnz16bnel addr_d_16bw endloop COpD6m8: ; DEC d,x addr_dCx_8brni dec al flagsetnz8bnel addr_dCx_8bw endloop COpD6m16:; DEC d,x addr_dCx_16brni dec ax flagsetnz16bnel addr_dCx_16bw endloop COpDEm8: ; DEC a,x addr_aCx_8brni dec al flagsetnz8bnel addr_aCx_8bw endloop COpDEm16:; DEC a,x addr_aCx_16brni dec ax flagsetnz16bnel addr_aCx_16bw endloop COpCAx8: ; DEX i dec byte[xx] mov al,[xx] flagsetnz8b endloop COpCAx16:; DEX i dec word[xx] mov ax,[xx] flagsetnz16b endloop COp88x8: ; DEY i dec byte[xy] mov al,[xy] flagsetnz8b endloop COp88x16:; DEY i dec word[xy] mov ax,[xy] flagsetnz16b endloop COp41m8: ; EOR(d,x) addr_BdCxB_8br EORMacro8b COp41m16:; EOR(d,x) addr_BdCxB_16br EORMacro16b COp43m8: ; EOR d,s addr_dCs_8br EORMacro8b COp43m16:; EOR d,s addr_dCs_16br EORMacro16b COp45m8: ; EOR d addr_d_8br EORMacro8b COp45m16:; EOR d addr_d_16br EORMacro16b COp47m8: ; EOR [d] addr_LdL_8br EORMacro8b COp47m16:; EOR [d] addr_LdL_16br EORMacro16b COp49m8: ; EOR # addr_I_8br EORMacro8b COp49m16:; EOR # addr_I_16br EORMacro16b COp4Dm8: ; EOR a addr_a_8br EORMacro8b COp4Dm16:; EOR a addr_a_16br EORMacro16b COp4Fm8: ; EOR al addr_al_8br EORMacro8b COp4Fm16:; EOR al addr_al_16br EORMacro16b COp51m8: ; EOR(d),y addr_BdBCy_8br EORMacro8b COp51m16:; EOR(d),y addr_BdBCy_16br EORMacro16b COp52m8: ; EOR (d) addr_BdB_8br EORMacro8b COp52m16:; EOR (d) addr_BdB_16br EORMacro16b COp53m8: ; EOR(d,s),y addr_BdCsBCy_8br EORMacro8b COp53m16:; EOR(d,s),y addr_BdCsBCy_16br EORMacro16b COp55m8: ; EOR d,x addr_dCx_8br EORMacro8b COp55m16:; EOR d,x addr_dCx_16br EORMacro16b COp57m8: ; EOR [d],y addr_LdLCy_8br EORMacro8b COp57m16:; EOR [d],y addr_LdLCy_16br EORMacro16b COp59m8: ; EOR a,y addr_aCy_8br EORMacro8b COp59m16:; EOR a,y addr_aCy_16br EORMacro16b COp5Dm8: ; EORa,x addr_aCx_8br EORMacro8b COp5Dm16:; EORa,x addr_aCx_16br EORMacro16b COp5Fm8: ; EOR al,x addr_alCx_8br EORMacro8b COp5Fm16:; EOR al,x addr_alCx_16br EORMacro16b COp1Am8: ; INC A addr_A_8brni inc al flagsetnz8bnel addr_A_8bw endloop COp1Am16:; INC A addr_A_16brni inc ax flagsetnz16bnel addr_A_16bw endloop COpEEm8: ; INC a addr_a_8brni inc al flagsetnz8bnel addr_a_8bw endloop COpEEm16:; INC a addr_a_16brni inc ax flagsetnz16bnel addr_a_16bw endloop COpE6m8: ; INC d addr_d_8brni inc al flagsetnz8bnel addr_d_8bw endloop COpE6m16:; INC d addr_d_16brni inc ax flagsetnz16bnel addr_d_16bw endloop COpF6m8: ; INC d,x addr_dCx_8brni inc al flagsetnz8bnel addr_dCx_8bw endloop COpF6m16:; INC d,x addr_dCx_16brni inc ax flagsetnz16bnel addr_dCx_16bw endloop COpFEm8: ; INC a,x addr_aCx_8brni inc al flagsetnz8bnel addr_aCx_8bw endloop COpFEm16:; INC a,x addr_aCx_16brni inc ax flagsetnz16bnel addr_aCx_16bw endloop COpE8x8: ; INX i inc byte[xx] mov al,[xx] flagsetnz8b endloop COpE8x16:; INX i inc word[xx] mov ax,[xx] flagsetnz16b endloop COpC8x8: ; INY i inc byte[xy] mov al,[xy] flagsetnz8b endloop COpC8x16:; INY i inc word[xy] mov ax,[xy] flagsetnz16b endloop COpDC: ; JML (a) JMLMacro COp4C: ; JMP a JMPMacro4C COp6C: ; JMP (a) JMPMacro6C COp7C: ; JMP(a,x) JMPMacro7C COp5C: ; JMP al JMPMacro5C COp22: ; JSL al JSLMacro COp20: ; JSR a JSRMacro20 COpFC: ; JSR(a,x) JSRMacroFC COpA1m8: ; LDA(d,x) addr_BdCxB_8br LDAMacro8b COpA1m16:; LDA(d,x) addr_BdCxB_16br LDAMacro16b COpA3m8: ; LDA d,s addr_dCs_8br LDAMacro8b COpA3m16:; LDA d,s addr_dCs_16br LDAMacro16b COpA5m8: ; LDA d addr_d_8br LDAMacro8b COpA5m16:; LDA d addr_d_16br LDAMacro16b COpA7m8: ; LDA [d] addr_LdL_8br LDAMacro8b COpA7m16:; LDA [d] addr_LdL_16br LDAMacro16b COpA9m8: ; LDA # addr_I_8br LDAMacro8b COpA9m16:; LDA # addr_I_16br LDAMacro16b COpADm8: ; LDA a addr_a_8br LDAMacro8b COpADm16:; LDA a addr_a_16br LDAMacro16b COpAFm8: ; LDA al addr_al_8br LDAMacro8b COpAFm16:; LDA al addr_al_16br LDAMacro16b COpB1m8: ; LDA(d),y addr_BdBCy_8br LDAMacro8b COpB1m16:; LDA(d),y addr_BdBCy_16br LDAMacro16b COpB2m8: ; LDA (d) addr_BdB_8br LDAMacro8b COpB2m16:; LDA (d) addr_BdB_16br LDAMacro16b COpB3m8: ; LDA(d,s),y addr_BdCsBCy_8br LDAMacro8b COpB3m16:; LDA(d,s),y addr_BdCsBCy_16br LDAMacro16b COpB5m8: ; LDA d,x addr_dCx_8br LDAMacro8b COpB5m16:; LDA d,x addr_dCx_16br LDAMacro16b COpB7m8: ; LDA [d],y addr_LdLCy_8br LDAMacro8b COpB7m16:; LDA [d],y addr_LdLCy_16br LDAMacro16b COpB9m8: ; LDA a,y addr_aCy_8br LDAMacro8b COpB9m16:; LDA a,y addr_aCy_16br LDAMacro16b COpBDm8: ; LDA a,x addr_aCx_8br LDAMacro8b COpBDm16:; LDA a,x addr_aCx_16br LDAMacro16b COpBFm8: ; LDA al,x addr_alCx_8br LDAMacro8b COpBFm16:; LDA al,x addr_alCx_16br LDAMacro16b COpA2x8: ; LDX # addr_I_8br LDXMacro8b COpA2x16:; LDX # addr_I_16br LDXMacro16b COpA6x8: ; LDX d addr_d_8br LDXMacro8b COpA6x16:; LDX d addr_d_16br LDXMacro16b COpAEx8: ; LDX a addr_a_8br LDXMacro8b COpAEx16:; LDX a addr_a_16br LDXMacro16b COpB6x8: ; LDX d,y addr_dCy_8br LDXMacro8b COpB6x16:; LDX d,y addr_dCy_16br LDXMacro16b COpBEx8: ; LDX a,y addr_aCy_8br LDXMacro8b COpBEx16:; LDX a,y addr_aCy_16br LDXMacro16b COpA0x8: ; LDY # addr_I_8br LDYMacro8b COpA0x16:; LDY # addr_I_16br LDYMacro16b COpA4x8: ; LDY d addr_d_8br LDYMacro8b COpA4x16:; LDY d addr_d_16br LDYMacro16b COpACx8: ; LDY a addr_a_8br LDYMacro8b COpACx16:; LDY a addr_a_16br LDYMacro16b COpB4x8: ; LDY d,x addr_dCx_8br LDYMacro8b COpB4x16:; LDY d,x addr_dCx_16br LDYMacro16b COpBCx8: ; LDY a,x addr_aCx_8br LDYMacro8b COpBCx16:; LDY a,x addr_aCx_16br LDYMacro16b COp46m8: ; LSR d addr_d_8brni LSRMacro8b addr_d_8bw endloop COp46m16:; LSR d addr_d_16brni LSRMacro16b addr_d_16bw endloop COp4Am8: ; LSR A addr_A_8brni LSRMacro8b addr_A_8bw endloop COp4Am16:; LSR A addr_A_16brni LSRMacro16b addr_A_16bw endloop COp4Em8: ; LSR a addr_a_8brni LSRMacro8b addr_a_8bw endloop COp4Em16:; LSR a addr_a_16brni LSRMacro16b addr_a_16bw endloop COp56m8: ; LSR d,x addr_dCx_8brni LSRMacro8b addr_dCx_8bw endloop COp56m16:; LSR d,x addr_dCx_16brni LSRMacro16b addr_dCx_16bw endloop COp5Em8: ; LSRa,x addr_aCx_8brni LSRMacro8b addr_aCx_8bw endloop COp5Em16:; LSRa,x addr_aCx_16brni LSRMacro16b addr_aCx_16bw endloop COp54: ; MVN xya MVNMacro COp44: ; MVP xya MVPMacro COpEA: ; NOP i endloop COp01m8: ; ORA(d,x) addr_BdCxB_8br ORAMacro8b COp01m16:; ORA(d,x) addr_BdCxB_16br ORAMacro16b COp03m8: ; ORA d,s addr_dCs_8br ORAMacro8b COp03m16:; ORA d,s addr_dCs_16br ORAMacro16b COp05m8: ; ORA d addr_d_8br ORAMacro8b COp05m16:; ORA d addr_d_16br ORAMacro16b COp07m8: ; ORA [d] addr_LdL_8br ORAMacro8b COp07m16:; ORA [d] addr_LdL_16br ORAMacro16b COp09m8: ; ORA # addr_I_8br ORAMacro8b COp09m16:; ORA # addr_I_16br ORAMacro16b COp0Dm8: ; ORA a addr_a_8br ORAMacro8b COp0Dm16:; ORA a addr_a_16br ORAMacro16b COp0Fm8: ; ORA al addr_al_8br ORAMacro8b COp0Fm16:; ORA al addr_al_16br ORAMacro16b COp11m8: ; ORA(d),y addr_BdBCy_8br ORAMacro8b COp11m16:; ORA(d),y addr_BdBCy_16br ORAMacro16b COp12m8: ; ORA(d) addr_BdB_8br ORAMacro8b COp12m16:; ORA(d) addr_BdB_16br ORAMacro16b COp13m8: ; ORA(d,s),y addr_BdCsBCy_8br ORAMacro8b COp13m16:; ORA(d,s),y addr_BdCsBCy_16br ORAMacro16b COp15m8: ; ORA d,x addr_dCx_8br ORAMacro8b COp15m16:; ORA d,x addr_dCx_16br ORAMacro16b COp17m8: ; ORA [d],y addr_LdLCy_8br ORAMacro8b COp17m16:; ORA [d],y addr_LdLCy_16br ORAMacro16b COp19m8: ; ORA a,y addr_aCy_8br ORAMacro8b COp19m16:; ORA a,y addr_aCy_16br ORAMacro16b COp1Dm8: ; ORA a,x addr_aCx_8br ORAMacro8b COp1Dm16:; ORA a,x addr_aCx_16br ORAMacro16b COp1Fm8: ; ORA al,x addr_alCx_8br ORAMacro8b COp1Fm16:; ORA al,x addr_alCx_16br ORAMacro16b COpF4: ; PEA s PEAMacro COpD4: ; PEI s PEIMacro COp62: ; PER s PERMacro COp48m8: ; PHA s PUSHMacro8b [xa] COp48m16:; PHA s PUSHMacro16b [xa], [xa+1] COp8B: ; PHB s PUSHMacro8b [xdb] COp0B: ; PHD s PUSHMacro16b [xd], [xd+1] COp4B: ; PHK s PUSHMacro8b [xpb] COp08: ; PHP s PUSHMacro8bp COpDAx8: ; PHX s PUSHMacro8b [xx] COpDAx16:; PHX s PUSHMacro16b [xx], [xx+1] COp5Ax8: ; PHY s PUSHMacro8b [xy] COp5Ax16:; PHY s PUSHMacro16b [xy], [xy+1] COp68m8: ; PLA s POPMacro8b [xa] COp68m16:; PLA s POPMacro16b [xa], [xa+1] COpAB: ; PLB s POPMacro8b [xdb] COp2B: ; PLD s POPMacro16bd [xd], [xd+1] COp28: ; PLP s POPMacroP COpFAx8: ; PLX s POPMacro8b [xx] COpFAx16:; PLX s POPMacro16b [xx], [xx+1] COp7Ax8: ; PLY s POPMacro8b [xy] COp7Ax16:; PLY s POPMacro16b [xy], [xy+1] COpC2: ; REP # REPMacro COp26m8: ; ROL d addr_d_8brni ROLMacro8b addr_d_8bw endloop COp26m16:; ROL d addr_d_16brni ROLMacro16b addr_d_16bw endloop COp2Am8: ; ROL A addr_A_8brni ROLMacro8b addr_A_8bw endloop COp2Am16:; ROL A addr_A_16brni ROLMacro16b addr_A_16bw endloop COp2Em8: ; ROL a addr_a_8brni ROLMacro8b addr_a_8bw endloop COp2Em16:; ROL a addr_a_16brni ROLMacro16b addr_a_16bw endloop COp36m8: ; ROL d,x addr_dCx_8brni ROLMacro8b addr_dCx_8bw endloop COp36m16:; ROL d,x addr_dCx_16brni ROLMacro16b addr_dCx_16bw endloop COp3Em8: ; ROL a,x addr_aCx_8brni ROLMacro8b addr_aCx_8bw endloop COp3Em16:; ROL a,x addr_aCx_16brni ROLMacro16b addr_aCx_16bw endloop COp66m8: ; ROR d addr_d_8brni RORMacro8b addr_d_8bw endloop COp66m16:; ROR d addr_d_16brni RORMacro16b addr_d_16bw endloop COp6Am8: ; ROR A addr_A_8brni RORMacro8b addr_A_8bw endloop COp6Am16:; ROR A addr_A_16brni RORMacro16b addr_A_16bw endloop COp6Em8: ; ROR a addr_a_8brni RORMacro8b addr_a_8bw endloop COp6Em16:; ROR a addr_a_16brni RORMacro16b addr_a_16bw endloop COp76m8: ; ROR d,x addr_dCx_8brni RORMacro8b addr_dCx_8bw endloop COp76m16:; ROR d,x addr_dCx_16brni RORMacro16b addr_dCx_16bw endloop COp7Em8: ; ROR a,x addr_aCx_8brni RORMacro8b addr_aCx_8bw endloop COp7Em16:; ROR a,x addr_aCx_16brni RORMacro16b addr_aCx_16bw endloop COp40: ; RTI s RTIMacro COp6B: ; RTL s RTLMacro COp60: ; RTS s RTSMacro COpE1m8nd: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bnd COpE1m16nd: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bnd COpE1m8d: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bd COpE1m16d: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bd COpE3m8nd: ; SBC d,s addr_dCs_8br SBCMacro8bnd COpE3m16nd: ; SBC d,s addr_dCs_16br SBCMacro16bnd COpE3m8d: ; SBC d,s addr_dCs_8br SBCMacro8bd COpE3m16d: ; SBC d,s addr_dCs_16br SBCMacro16bd COpE5m8nd: ; SBC d addr_d_8br SBCMacro8bnd COpE5m16nd: ; SBC d addr_d_16br SBCMacro16bnd COpE5m8d: ; SBC d addr_d_8br SBCMacro8bd COpE5m16d: ; SBC d addr_d_16br SBCMacro16bd COpE7m8nd: ; SBC [d] addr_LdL_8br SBCMacro8bnd COpE7m16nd: ; SBC [d] addr_LdL_16br SBCMacro16bnd COpE7m8d: ; SBC [d] addr_LdL_8br SBCMacro8bd COpE7m16d: ; SBC [d] addr_LdL_16br SBCMacro16bd COpE9m8nd: ; SBC # addr_I_8br SBCMacro8bnd COpE9m16nd: ; SBC # addr_I_16br SBCMacro16bnd COpE9m8d: ; SBC # addr_I_8br SBCMacro8bd COpE9m16d: ; SBC # addr_I_16br SBCMacro16bd COpEDm8nd: ; SBC a addr_a_8br SBCMacro8bnd COpEDm16nd: ; SBC a addr_a_16br SBCMacro16bnd COpEDm8d: ; SBC a addr_a_8br SBCMacro8bd COpEDm16d: ; SBC a addr_a_16br SBCMacro16bd COpEFm8nd: ; SBC al addr_al_8br SBCMacro8bnd COpEFm16nd: ; SBC al addr_al_16br SBCMacro16bnd COpEFm8d: ; SBC al addr_al_8br SBCMacro8bd COpEFm16d: ; SBC al addr_al_16br SBCMacro16bd COpF1m8nd: ; SBC(d),y addr_BdBCy_8br SBCMacro8bnd COpF1m16nd: ; SBC(d),y addr_BdBCy_16br SBCMacro16bnd COpF1m8d: ; SBC(d),y addr_BdBCy_8br SBCMacro8bd COpF1m16d: ; SBC(d),y addr_BdBCy_16br SBCMacro16bd COpF2m8nd: ; SBC (d) addr_BdB_8br SBCMacro8bnd COpF2m16nd: ; SBC (d) addr_BdB_16br SBCMacro16bnd COpF2m8d: ; SBC (d) addr_BdB_8br SBCMacro8bd COpF2m16d: ; SBC (d) addr_BdB_16br SBCMacro16bd COpF3m8nd: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bnd COpF3m16nd: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bnd COpF3m8d: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bd COpF3m16d: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bd COpF5m8nd: ; SBC d,x addr_dCx_8br SBCMacro8bnd COpF5m16nd: ; SBC d,x addr_dCx_16br SBCMacro16bnd COpF5m8d: ; SBC d,x addr_dCx_8br SBCMacro8bd COpF5m16d: ; SBC d,x addr_dCx_16br SBCMacro16bd COpF7m8nd: ; SBC [d],y addr_LdLCy_8br SBCMacro8bnd COpF7m16nd: ; SBC [d],y addr_LdLCy_16br SBCMacro16bnd COpF7m8d: ; SBC [d],y addr_LdLCy_8br SBCMacro8bd COpF7m16d: ; SBC [d],y addr_LdLCy_16br SBCMacro16bd COpF9m8nd: ; SBC a,y addr_aCy_8br SBCMacro8bnd COpF9m16nd: ; SBC a,y addr_aCy_16br SBCMacro16bnd COpF9m8d: ; SBC a,y addr_aCy_8br SBCMacro8bd COpF9m16d: ; SBC a,y addr_aCy_16br SBCMacro16bd COpFDm8nd: ; SBC a,x addr_aCx_8br SBCMacro8bnd COpFDm16nd: ; SBC a,x addr_aCx_16br SBCMacro16bnd COpFDm8d: ; SBC a,x addr_aCx_8br SBCMacro8bd COpFDm16d: ; SBC a,x addr_aCx_16br SBCMacro16bd COpFFm8nd: ; SBC al,x addr_alCx_8br SBCMacro8bnd COpFFm16nd: ; SBC al,x addr_alCx_16br SBCMacro16bnd COpFFm8d: ; SBC al,x addr_alCx_8br SBCMacro8bd COpFFm16d: ; SBC al,x addr_alCx_16br SBCMacro16bd COp38: ; SEC i mov dword[flagc],0FFh endloop COpF8: ; SED i or dl,08h mov bl,dl mov edi,[tableadb+ebx*4] endloop COp78: ; SEI i or dl,04h endloop COpE2: ; SEP # SEPMacro COp81m8: ; STA(d,x) STAMacro8b addr_BdCxB_8bw endloop COp81m16:; STA(d,x) STAMacro16b addr_BdCxB_16bw endloop COp83m8: ; STA d,s STAMacro8b addr_dCs_8bw endloop COp83m16:; STA d,s STAMacro16b addr_dCs_16bw endloop COp85m8: ; STA d STAMacro8b addr_d_8bw endloop COp85m16:; STA d STAMacro16b addr_d_16bw endloop COp87m8: ; STA [d] STAMacro8b addr_LdL_8bw endloop COp87m16:; STA [d] STAMacro16b addr_LdL_16bw endloop COp8Dm8: ; STA a STAMacro8b addr_a_8bw endloop COp8Dm16:; STA a STAMacro16b addr_a_16bw endloop COp8Fm8: ; STA al STAMacro8b addr_al_8bw endloop COp8Fm16:; STA al STAMacro16b addr_al_16bw endloop COp91m8: ; STA(d),y STAMacro8b addr_BdBCy_8bw endloop COp91m16:; STA(d),y STAMacro16b addr_BdBCy_16bw endloop COp92m8: ; STA (d) STAMacro8b addr_BdB_8bw endloop COp92m16:; STA (d) STAMacro16b addr_BdB_16bw endloop COp93m8: ; STA(d,s),y STAMacro8b addr_BdCsBCy_8bw endloop COp93m16:; STA(d,s),y STAMacro16b addr_BdCsBCy_16bw endloop COp95m8: ; STA d,x STAMacro8b addr_dCx_8bw endloop COp95m16:; STA d,x STAMacro16b addr_dCx_16bw endloop COp97m8: ; STA [d],y STAMacro8b addr_LdLCy_8bw endloop COp97m16:; STA [d],y STAMacro16b addr_LdLCy_16bw endloop COp99m8: ; STA a,y STAMacro8b addr_aCy_8bw endloop COp99m16:; STA a,y STAMacro16b addr_aCy_16bw endloop COp9Dm8: ; STA a,x STAMacro8b addr_aCx_8bw endloop COp9Dm16:; STA a,x STAMacro16b addr_aCx_16bw endloop COp9Fm8: ; STA al,x STAMacro8b addr_alCx_8bw endloop COp9Fm16:; STA al,x STAMacro16b addr_alCx_16bw endloop COp86x8: ; STX d STXMacro8b addr_d_8bw endloop COp86x16:; STX d STXMacro16b addr_d_16bw endloop COp8Ex8: ; STX a STXMacro8b addr_a_8bw endloop COp8Ex16:; STX a STXMacro16b addr_a_16bw endloop COp96x8: ; STX d,y STXMacro8b addr_dCy_8bw endloop COp96x16:; STX d,y STXMacro16b addr_dCy_16bw endloop COp84x8: ; STY d STYMacro8b addr_d_8bw endloop COp84x16:; STY d STYMacro16b addr_d_16bw endloop COp8Cx8: ; STY a STYMacro8b addr_a_8bw endloop COp8Cx16:; STY a STYMacro16b addr_a_16bw endloop COp94x8: ; STYd,x STYMacro8b addr_dCx_8bw endloop COp94x16:; STYd,x STYMacro16b addr_dCx_16bw endloop COpDB: ; STP i dec esi endloop COp64m8: ; STZ d xor al,al addr_d_8bw endloop COp64m16:; STZ d xor eax,eax addr_d_16bw endloop COp74m8: ; STZ d,x xor al,al addr_dCx_8bw endloop COp74m16:; STZ d,x xor eax,eax addr_dCx_16bw endloop COp9Cm8: ; STZ a xor al,al addr_a_8bw endloop COp9Cm16:; STZ a xor eax,eax addr_a_16bw endloop COp9Em8: ; STZ a,x xor al,al addr_aCx_8bw endloop COp9Em16:; STZ a,x xor eax,eax addr_aCx_16bw endloop COp14m8: ; TRB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_d_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_d_8bw endloop COp14m16:; TRB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_d_16bw endloop COp1Cm8: ; TRB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_a_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_a_8bw endloop COp1Cm16:; TRB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_a_16bw endloop COp04m8: ; TSB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_d_8bw endloop .zero mov word[flagnz],0 or al,cl addr_d_8bw endloop COp04m16:; TSB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_d_16bw endloop COp0Cm8: ; TSB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_a_8bw endloop .zero mov word[flagnz],0 or al,cl addr_a_8bw endloop COp0Cm16:; TSB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_a_16bw endloop COpAAx8: ; TAX i mov al,[xa] mov [xx],al flagsetnz8b endloop COpAAx16:; TAX i mov ax,[xa] mov [xx],ax flagsetnz16b endloop COpA8x8: ; TAY i mov al,[xa] mov [xy],al flagsetnz8b endloop COpA8x16:; TAY i mov ax,[xa] mov [xy],ax flagsetnz16b endloop COp5B: ; TCD i mov ax,[xa] mov [xd],ax call UpdateDPage flagsetnz16b endloop COp1B: ; TCS i mov ax,[xa] test byte[xe],1 jnz .emul mov [xs],ax endloop .emul mov [xs],al endloop COp7B: ; TDC i mov ax,[xd] mov [xa],ax flagsetnz16b endloop COp3B: ; TSC i mov ax,[xs] mov [xa],ax flagsetnz16b endloop COpBAx8: ; TSX i mov al,[xs] mov [xx],al flagsetnz8b endloop COpBAx16:; TSX i mov ax,[xs] mov [xx],ax flagsetnz16b endloop COp8Am8: ; TXA i mov al,[xx] mov [xa],al flagsetnz8b endloop COp8Am16:; TXA i mov ax,[xx] mov [xa],ax flagsetnz16b endloop COp9A: ; TXS i mov ax,[xx] mov [xs],ax test byte[xe],1 jnz .emul endloop .emul mov byte[xs+1],1 endloop COp9Bx8: ; TXY i mov al,[xx] mov [xy],al flagsetnz8b endloop COp9Bx16:; TXY i mov ax,[xx] mov [xy],ax flagsetnz16b endloop COp98m8: ; TYA i mov al,[xy] mov [xa],al flagsetnz8b endloop COp98m16:; TYA i mov ax,[xy] mov [xa],ax flagsetnz16b endloop COpBBx8: ; TYX i mov al,[xy] mov [xx],al flagsetnz8b endloop COpBBx16:; TYX i mov ax,[xy] mov [xx],ax flagsetnz16b endloop COpCB: ; WAI i WAIMacro COpEB: ; XBA i mov ah,[xa] mov al,[xa+1] mov [xa],ax flagsetnz8b endloop COpFB: ; XCE i XCEMacro COp42: ; WDM inc esi endloop zsnes-1.36/src/cpu/e65816c.inc0100644000175000017500000007775007505521463015265 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM brkv,brkv8,changeexecloop,copv,copv8,curexecstate,curnmi,execloop EXTSYM initaddrl,intrset,membank0r16,membank0r8 EXTSYM membank0w16,membank0w8,memtabler16,memtabler8,memtablew16,memtablew8 EXTSYM nmistatus,regaccessbankr8,snesmap2,snesmmap,stackand,stackor EXTSYM wramdata,xa,xd,xdb,xe,xirqb,xpb,xpc,xs,xx,xy EXTSYM switchtovirq,UpdateDPage EXTSYM DPageR8,DPageW8,DPageR16,DPageW16 ; B = ( or ) ; C = , ; L = [ or ] ; I = # COp61m8nd: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bnd COp61m16nd: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bnd COp61m8d: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bd COp61m16d: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bd COp63m8nd: ; ADC d,s addr_dCs_8br ADCMacro8bnd COp63m16nd: ; ADC d,s addr_dCs_16br ADCMacro16bnd COp63m8d: ; ADC d,s addr_dCs_8br ADCMacro8bd COp63m16d: ; ADC d,s addr_dCs_16br ADCMacro16bd COp65m8nd: ; ADC d addr_d_8br ADCMacro8bnd COp65m16nd: ; ADC d addr_d_16br ADCMacro16bnd COp65m8d: ; ADC d addr_d_8br ADCMacro8bd COp65m16d: ; ADC d addr_d_16br ADCMacro16bd COp67m8nd: ; ADC [d] addr_LdL_8br ADCMacro8bnd COp67m16nd: ; ADC [d] addr_LdL_16br ADCMacro16bnd COp67m8d: ; ADC [d] addr_LdL_8br ADCMacro8bd COp67m16d: ; ADC [d] addr_LdL_16br ADCMacro16bd COp69m8nd: ; ADC # addr_I_8br ADCMacro8bnd COp69m16nd: ; ADC # addr_I_16br ADCMacro16bnd COp69m8d: ; ADC # addr_I_8br ADCMacro8bd COp69m16d: ; ADC # addr_I_16br ADCMacro16bd COp6Dm8nd: ; ADC a addr_a_8br ADCMacro8bnd COp6Dm16nd: ; ADC a addr_a_16br ADCMacro16bnd COp6Dm8d: ; ADC a addr_a_8br ADCMacro8bd COp6Dm16d: ; ADC a addr_a_16br ADCMacro16bd COp6Fm8nd: ; ADC al addr_al_8br ADCMacro8bnd COp6Fm16nd: ; ADC al addr_al_16br ADCMacro16bnd COp6Fm8d: ; ADC al addr_al_8br ADCMacro8bd COp6Fm16d: ; ADC al addr_al_16br ADCMacro16bd COp71m8nd: ; ADC(d),y addr_BdBCy_8br ADCMacro8bnd COp71m16nd: ; ADC(d),y addr_BdBCy_16br ADCMacro16bnd COp71m8d: ; ADC(d),y addr_BdBCy_8br ADCMacro8bd COp71m16d: ; ADC(d),y addr_BdBCy_16br ADCMacro16bd COp72m8nd: ; ADC (d) addr_BdB_8br ADCMacro8bnd COp72m16nd: ; ADC (d) addr_BdB_16br ADCMacro16bnd COp72m8d: ; ADC (d) addr_BdB_8br ADCMacro8bd COp72m16d: ; ADC (d) addr_BdB_16br ADCMacro16bd COp73m8nd: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bnd COp73m16nd: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bnd COp73m8d: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bd COp73m16d: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bd COp75m8nd: ; ADC d,x addr_dCx_8br ADCMacro8bnd COp75m16nd: ; ADC d,x addr_dCx_16br ADCMacro16bnd COp75m8d: ; ADC d,x addr_dCx_8br ADCMacro8bd COp75m16d: ; ADC d,x addr_dCx_16br ADCMacro16bd COp77m8nd: ; ADC [d],y addr_LdLCy_8br ADCMacro8bnd COp77m16nd: ; ADC [d],y addr_LdLCy_16br ADCMacro16bnd COp77m8d: ; ADC [d],y addr_LdLCy_8br ADCMacro8bd COp77m16d: ; ADC [d],y addr_LdLCy_16br ADCMacro16bd COp79m8nd: ; ADC a,y addr_aCy_8br ADCMacro8bnd COp79m16nd: ; ADC a,y addr_aCy_16br ADCMacro16bnd COp79m8d: ; ADC a,y addr_aCy_8br ADCMacro8bd COp79m16d: ; ADC a,y addr_aCy_16br ADCMacro16bd COp7Dm8nd: ; ADC a,x addr_aCx_8br ADCMacro8bnd COp7Dm16nd: ; ADC a,x addr_aCx_16br ADCMacro16bnd COp7Dm8d: ; ADC a,x addr_aCx_8br ADCMacro8bd COp7Dm16d: ; ADC a,x addr_aCx_16br ADCMacro16bd COp7Fm8nd: ; ADC al,x addr_alCx_8br ADCMacro8bnd COp7Fm16nd: ; ADC al,x addr_alCx_16br ADCMacro16bnd COp7Fm8d: ; ADC al,x addr_alCx_8br ADCMacro8bd COp7Fm16d: ; ADC al,x addr_alCx_16br ADCMacro16bd COp21m8: ; AND(d,x) addr_BdCxB_8br ANDMacro8b COp21m16:; AND(d,x) addr_BdCxB_16br ANDMacro16b COp23m8: ; AND d,s addr_dCs_8br ANDMacro8b COp23m16:; AND d,s addr_dCs_16br ANDMacro16b COp25m8: ; AND d addr_d_8br ANDMacro8b COp25m16:; AND d addr_d_16br ANDMacro16b COp27m8: ; AND [d] addr_LdL_8br ANDMacro8b COp27m16:; AND [d] addr_LdL_16br ANDMacro16b COp29m8: ; AND # addr_I_8br ANDMacro8b COp29m16:; AND # addr_I_16br ANDMacro16b COp2Dm8: ; AND a addr_a_8br ANDMacro8b COp2Dm16:; AND a addr_a_16br ANDMacro16b COp2Fm8: ; AND al addr_al_8br ANDMacro8b COp2Fm16:; AND al addr_al_16br ANDMacro16b COp31m8: ; AND(d),y addr_BdBCy_8br ANDMacro8b COp31m16:; AND(d),y addr_BdBCy_16br ANDMacro16b COp32m8: ; AND (d) addr_BdB_8br ANDMacro8b COp32m16:; AND (d) addr_BdB_16br ANDMacro16b COp33m8: ; AND(d,s),y addr_BdCsBCy_8br ANDMacro8b COp33m16:; AND(d,s),y addr_BdCsBCy_16br ANDMacro16b COp35m8: ; AND d,x addr_dCx_8br ANDMacro8b COp35m16:; AND d,x addr_dCx_16br ANDMacro16b COp37m8: ; AND [d],y addr_LdLCy_8br ANDMacro8b COp37m16:; AND [d],y addr_LdLCy_16br ANDMacro16b COp39m8: ; AND a,y addr_aCy_8br ANDMacro8b COp39m16:; AND a,y addr_aCy_16br ANDMacro16b COp3Dm8: ; AND a,x addr_aCx_8br ANDMacro8b COp3Dm16:; AND a,x addr_aCx_16br ANDMacro16b COp3Fm8: ; AND al,x addr_alCx_8br ANDMacro8b COp3Fm16:; AND al,x addr_alCx_16br ANDMacro16b COp06m8: ; ASL d addr_d_8brni ASLMacro8b addr_d_8bw endloop COp06m16:; ASL d addr_d_16brni ASLMacro16b addr_d_16bw endloop COp0Am8: ; ASL A addr_A_8brni ASLMacro8b addr_A_8bw endloop COp0Am16:; ASL A addr_A_16brni ASLMacro16b addr_A_16bw endloop COp0Em8: ; ASL a addr_a_8brni ASLMacro8b addr_a_8bw endloop COp0Em16:; ASL a addr_a_16brni ASLMacro16b addr_a_16bw endloop COp16m8: ; ASL d,x addr_dCx_8brni ASLMacro8b addr_dCx_8bw endloop COp16m16:; ASL d,x addr_dCx_16brni ASLMacro16b addr_dCx_16bw endloop COp1Em8: ; ASL a,x addr_aCx_8brni ASLMacro8b addr_aCx_8bw endloop COp1Em16:; ASL a,x addr_aCx_16brni ASLMacro16b addr_aCx_16bw endloop COp90: ; BCC r test byte[flagc],01h jnz .skip JumpMacro COpB0: ; BCS r test byte[flagc],01h jz .skip JumpMacro COpF0: ; BEQ r test dword[flagnz],0FFFFh jnz .skip JumpMacro COp30: ; BMI r test dword[flagnz],018000h jz .skip JumpMacro COpD0: ; BNE r test dword[flagnz],0FFFFh jz .skip JumpMacro COp10: ; BPL r test dword[flagnz],018000h jnz .skip JumpMacro COp80: ; BRA r movsx eax,byte[esi] inc esi add esi,eax endloop COp50: ; BVC r test dword[flago],0FFh jnz .skip JumpMacro COp70: ; BVS r test dword[flago],0FFh jz .skip JumpMacro ; BIT instruction does not affect N and V flags when using immediate ; addressing mode. When using other addressing modes, the N and V flags COp89m8: ; BIT # BITMacroim8b COp89m16:; BIT # BITMacroim16b COp24m8: ; BIT d addr_d_8br BITMacro8b COp24m16:; BIT d addr_d_16br BITMacro16b COp2Cm8: ; BIT a addr_a_8br BITMacro8b COp2Cm16:; BIT a addr_a_16br BITMacro16b COp34m8: ; BIT d,x addr_dCx_8br BITMacro8b COp34m16:; BIT d,x addr_dCx_16br BITMacro16b COp3Cm8: ; BIT a,x addr_aCx_8br BITMacro8b COp3Cm16:; BIT a,x addr_aCx_16br BITMacro16b COp00: ; BRK s BRKMacro COp82: ; BRL rl BRLMacro COp18: ; CLC i mov dword[flagc],0 endloop COpD8: ; CLD i and dl,0F7h mov bl,dl mov edi,[tableadc+ebx*4] endloop COp58: ; CLI i and dl,0FBh endloop COpB8: ; CLV i mov dword[flago],0 endloop COpC1m8: ; CMP(d,x) addr_BdCxB_8br CMPMacro8b COpC1m16:; CMP(d,x) addr_BdCxB_16br CMPMacro16b COpC3m8: ; CMP d,s addr_dCs_8br CMPMacro8b COpC3m16:; CMP d,s addr_dCs_16br CMPMacro16b COpC5m8: ; CMP d addr_d_8br CMPMacro8b COpC5m16:; CMP d addr_d_16br CMPMacro16b COpC7m8: ; CMP [d] addr_LdL_8br CMPMacro8b COpC7m16:; CMP [d] addr_LdL_16br CMPMacro16b COpC9m8: ; CMP # addr_I_8br CMPMacro8b COpC9m16:; CMP # addr_I_16br CMPMacro16b COpCDm8: ; CMP a addr_a_8br CMPMacro8b COpCDm16:; CMP a addr_a_16br CMPMacro16b COpCFm8: ; CMP al addr_al_8br CMPMacro8b COpCFm16:; CMP al addr_al_16br CMPMacro16b COpD1m8: ; CMP(d),y addr_BdBCy_8br CMPMacro8b COpD1m16:; CMP(d),y addr_BdBCy_16br CMPMacro16b COpD2m8: ; CMP (d) addr_BdB_8br CMPMacro8b COpD2m16:; CMP (d) addr_BdB_16br CMPMacro16b COpD3m8: ; CMP(d,s),y addr_BdCsBCy_8br CMPMacro8b COpD3m16:; CMP(d,s),y addr_BdCsBCy_16br CMPMacro16b COpD5m8: ; CMP d,x addr_dCx_8br CMPMacro8b COpD5m16:; CMP d,x addr_dCx_16br CMPMacro16b COpD7m8: ; CMP [d],y addr_LdLCy_8br CMPMacro8b COpD7m16:; CMP [d],y addr_LdLCy_16br CMPMacro16b COpD9m8: ; CMP a,y addr_aCy_8br CMPMacro8b COpD9m16:; CMP a,y addr_aCy_16br CMPMacro16b COpDDm8: ; CMP a,x addr_aCx_8br CMPMacro8b COpDDm16:; CMP a,x addr_aCx_16br CMPMacro16b COpDFm8: ; CMP al,x addr_alCx_8br CMPMacro8b COpDFm16:; CMP al,x addr_alCx_16br CMPMacro16b COp02: ; COP s COPMacro COpE0x8: ; CPX # addr_I_8br CPXMacro8b COpE0x16:; CPX # addr_I_16br CPXMacro16b COpE4x8: ; CPX d addr_d_8br CPXMacro8b COpE4x16:; CPX d addr_d_16br CPXMacro16b COpECx8: ; CPX a addr_a_8br CPXMacro8b COpECx16:; CPX a addr_a_16br CPXMacro16b COpC0x8: ; CPY # addr_I_8br CPYMacro8b COpC0x16:; CPY # addr_I_16br CPYMacro16b COpC4x8: ; CPY d addr_d_8br CPYMacro8b COpC4x16:; CPY d addr_d_16br CPYMacro16b COpCCx8: ; CPY a addr_a_8br CPYMacro8b COpCCx16:; CPY a addr_a_16br CPYMacro16b COp3Am8: ; DEC A addr_A_8brni dec al flagsetnz8bnel addr_A_8bw endloop COp3Am16:; DEC A addr_A_16brni dec ax flagsetnz16bnel addr_A_16bw endloop COpCEm8: ; DEC a addr_a_8brni dec al flagsetnz8bnel addr_a_8bw endloop COpCEm16:; DEC a addr_a_16brni dec ax flagsetnz16bnel addr_a_16bw endloop COpC6m8: ; DEC d addr_d_8brni dec al flagsetnz8bnel addr_d_8bw endloop COpC6m16:; DEC d addr_d_16brni dec ax flagsetnz16bnel addr_d_16bw endloop COpD6m8: ; DEC d,x addr_dCx_8brni dec al flagsetnz8bnel addr_dCx_8bw endloop COpD6m16:; DEC d,x addr_dCx_16brni dec ax flagsetnz16bnel addr_dCx_16bw endloop COpDEm8: ; DEC a,x addr_aCx_8brni dec al flagsetnz8bnel addr_aCx_8bw endloop COpDEm16:; DEC a,x addr_aCx_16brni dec ax flagsetnz16bnel addr_aCx_16bw endloop COpCAx8: ; DEX i dec byte[xx] mov al,[xx] flagsetnz8b endloop COpCAx16:; DEX i dec word[xx] mov ax,[xx] flagsetnz16b endloop COp88x8: ; DEY i dec byte[xy] mov al,[xy] flagsetnz8b endloop COp88x16:; DEY i dec word[xy] mov ax,[xy] flagsetnz16b endloop COp41m8: ; EOR(d,x) addr_BdCxB_8br EORMacro8b COp41m16:; EOR(d,x) addr_BdCxB_16br EORMacro16b COp43m8: ; EOR d,s addr_dCs_8br EORMacro8b COp43m16:; EOR d,s addr_dCs_16br EORMacro16b COp45m8: ; EOR d addr_d_8br EORMacro8b COp45m16:; EOR d addr_d_16br EORMacro16b COp47m8: ; EOR [d] addr_LdL_8br EORMacro8b COp47m16:; EOR [d] addr_LdL_16br EORMacro16b COp49m8: ; EOR # addr_I_8br EORMacro8b COp49m16:; EOR # addr_I_16br EORMacro16b COp4Dm8: ; EOR a addr_a_8br EORMacro8b COp4Dm16:; EOR a addr_a_16br EORMacro16b COp4Fm8: ; EOR al addr_al_8br EORMacro8b COp4Fm16:; EOR al addr_al_16br EORMacro16b COp51m8: ; EOR(d),y addr_BdBCy_8br EORMacro8b COp51m16:; EOR(d),y addr_BdBCy_16br EORMacro16b COp52m8: ; EOR (d) addr_BdB_8br EORMacro8b COp52m16:; EOR (d) addr_BdB_16br EORMacro16b COp53m8: ; EOR(d,s),y addr_BdCsBCy_8br EORMacro8b COp53m16:; EOR(d,s),y addr_BdCsBCy_16br EORMacro16b COp55m8: ; EOR d,x addr_dCx_8br EORMacro8b COp55m16:; EOR d,x addr_dCx_16br EORMacro16b COp57m8: ; EOR [d],y addr_LdLCy_8br EORMacro8b COp57m16:; EOR [d],y addr_LdLCy_16br EORMacro16b COp59m8: ; EOR a,y addr_aCy_8br EORMacro8b COp59m16:; EOR a,y addr_aCy_16br EORMacro16b COp5Dm8: ; EORa,x addr_aCx_8br EORMacro8b COp5Dm16:; EORa,x addr_aCx_16br EORMacro16b COp5Fm8: ; EOR al,x addr_alCx_8br EORMacro8b COp5Fm16:; EOR al,x addr_alCx_16br EORMacro16b COp1Am8: ; INC A addr_A_8brni inc al flagsetnz8bnel addr_A_8bw endloop COp1Am16:; INC A addr_A_16brni inc ax flagsetnz16bnel addr_A_16bw endloop COpEEm8: ; INC a addr_a_8brni inc al flagsetnz8bnel addr_a_8bw endloop COpEEm16:; INC a addr_a_16brni inc ax flagsetnz16bnel addr_a_16bw endloop COpE6m8: ; INC d addr_d_8brni inc al flagsetnz8bnel addr_d_8bw endloop COpE6m16:; INC d addr_d_16brni inc ax flagsetnz16bnel addr_d_16bw endloop COpF6m8: ; INC d,x addr_dCx_8brni inc al flagsetnz8bnel addr_dCx_8bw endloop COpF6m16:; INC d,x addr_dCx_16brni inc ax flagsetnz16bnel addr_dCx_16bw endloop COpFEm8: ; INC a,x addr_aCx_8brni inc al flagsetnz8bnel addr_aCx_8bw endloop COpFEm16:; INC a,x addr_aCx_16brni inc ax flagsetnz16bnel addr_aCx_16bw endloop COpE8x8: ; INX i inc byte[xx] mov al,[xx] flagsetnz8b endloop COpE8x16:; INX i inc word[xx] mov ax,[xx] flagsetnz16b endloop COpC8x8: ; INY i inc byte[xy] mov al,[xy] flagsetnz8b endloop COpC8x16:; INY i inc word[xy] mov ax,[xy] flagsetnz16b endloop COpDC: ; JML (a) JMLMacro COp4C: ; JMP a JMPMacro4C COp6C: ; JMP (a) JMPMacro6C COp7C: ; JMP(a,x) JMPMacro7C COp5C: ; JMP al JMPMacro5C COp22: ; JSL al JSLMacro COp20: ; JSR a JSRMacro20 COpFC: ; JSR(a,x) JSRMacroFC COpA1m8: ; LDA(d,x) addr_BdCxB_8br LDAMacro8b COpA1m16:; LDA(d,x) addr_BdCxB_16br LDAMacro16b COpA3m8: ; LDA d,s addr_dCs_8br LDAMacro8b COpA3m16:; LDA d,s addr_dCs_16br LDAMacro16b COpA5m8: ; LDA d addr_d_8br LDAMacro8b COpA5m16:; LDA d addr_d_16br LDAMacro16b COpA7m8: ; LDA [d] addr_LdL_8br LDAMacro8b COpA7m16:; LDA [d] addr_LdL_16br LDAMacro16b COpA9m8: ; LDA # addr_I_8br LDAMacro8b COpA9m16:; LDA # addr_I_16br LDAMacro16b COpADm8: ; LDA a addr_a_8br LDAMacro8b COpADm16:; LDA a addr_a_16br LDAMacro16b COpAFm8: ; LDA al addr_al_8br LDAMacro8b COpAFm16:; LDA al addr_al_16br LDAMacro16b COpB1m8: ; LDA(d),y addr_BdBCy_8br LDAMacro8b COpB1m16:; LDA(d),y addr_BdBCy_16br LDAMacro16b COpB2m8: ; LDA (d) addr_BdB_8br LDAMacro8b COpB2m16:; LDA (d) addr_BdB_16br LDAMacro16b COpB3m8: ; LDA(d,s),y addr_BdCsBCy_8br LDAMacro8b COpB3m16:; LDA(d,s),y addr_BdCsBCy_16br LDAMacro16b COpB5m8: ; LDA d,x addr_dCx_8br LDAMacro8b COpB5m16:; LDA d,x addr_dCx_16br LDAMacro16b COpB7m8: ; LDA [d],y addr_LdLCy_8br LDAMacro8b COpB7m16:; LDA [d],y addr_LdLCy_16br LDAMacro16b COpB9m8: ; LDA a,y addr_aCy_8br LDAMacro8b COpB9m16:; LDA a,y addr_aCy_16br LDAMacro16b COpBDm8: ; LDA a,x addr_aCx_8br LDAMacro8b COpBDm16:; LDA a,x addr_aCx_16br LDAMacro16b COpBFm8: ; LDA al,x addr_alCx_8br LDAMacro8b COpBFm16:; LDA al,x addr_alCx_16br LDAMacro16b COpA2x8: ; LDX # addr_I_8br LDXMacro8b COpA2x16:; LDX # addr_I_16br LDXMacro16b COpA6x8: ; LDX d addr_d_8br LDXMacro8b COpA6x16:; LDX d addr_d_16br LDXMacro16b COpAEx8: ; LDX a addr_a_8br LDXMacro8b COpAEx16:; LDX a addr_a_16br LDXMacro16b COpB6x8: ; LDX d,y addr_dCy_8br LDXMacro8b COpB6x16:; LDX d,y addr_dCy_16br LDXMacro16b COpBEx8: ; LDX a,y addr_aCy_8br LDXMacro8b COpBEx16:; LDX a,y addr_aCy_16br LDXMacro16b COpA0x8: ; LDY # addr_I_8br LDYMacro8b COpA0x16:; LDY # addr_I_16br LDYMacro16b COpA4x8: ; LDY d addr_d_8br LDYMacro8b COpA4x16:; LDY d addr_d_16br LDYMacro16b COpACx8: ; LDY a addr_a_8br LDYMacro8b COpACx16:; LDY a addr_a_16br LDYMacro16b COpB4x8: ; LDY d,x addr_dCx_8br LDYMacro8b COpB4x16:; LDY d,x addr_dCx_16br LDYMacro16b COpBCx8: ; LDY a,x addr_aCx_8br LDYMacro8b COpBCx16:; LDY a,x addr_aCx_16br LDYMacro16b COp46m8: ; LSR d addr_d_8brni LSRMacro8b addr_d_8bw endloop COp46m16:; LSR d addr_d_16brni LSRMacro16b addr_d_16bw endloop COp4Am8: ; LSR A addr_A_8brni LSRMacro8b addr_A_8bw endloop COp4Am16:; LSR A addr_A_16brni LSRMacro16b addr_A_16bw endloop COp4Em8: ; LSR a addr_a_8brni LSRMacro8b addr_a_8bw endloop COp4Em16:; LSR a addr_a_16brni LSRMacro16b addr_a_16bw endloop COp56m8: ; LSR d,x addr_dCx_8brni LSRMacro8b addr_dCx_8bw endloop COp56m16:; LSR d,x addr_dCx_16brni LSRMacro16b addr_dCx_16bw endloop COp5Em8: ; LSRa,x addr_aCx_8brni LSRMacro8b addr_aCx_8bw endloop COp5Em16:; LSRa,x addr_aCx_16brni LSRMacro16b addr_aCx_16bw endloop COp54: ; MVN xya MVNMacro COp44: ; MVP xya MVPMacro COpEA: ; NOP i endloop COp01m8: ; ORA(d,x) addr_BdCxB_8br ORAMacro8b COp01m16:; ORA(d,x) addr_BdCxB_16br ORAMacro16b COp03m8: ; ORA d,s addr_dCs_8br ORAMacro8b COp03m16:; ORA d,s addr_dCs_16br ORAMacro16b COp05m8: ; ORA d addr_d_8br ORAMacro8b COp05m16:; ORA d addr_d_16br ORAMacro16b COp07m8: ; ORA [d] addr_LdL_8br ORAMacro8b COp07m16:; ORA [d] addr_LdL_16br ORAMacro16b COp09m8: ; ORA # addr_I_8br ORAMacro8b COp09m16:; ORA # addr_I_16br ORAMacro16b COp0Dm8: ; ORA a addr_a_8br ORAMacro8b COp0Dm16:; ORA a addr_a_16br ORAMacro16b COp0Fm8: ; ORA al addr_al_8br ORAMacro8b COp0Fm16:; ORA al addr_al_16br ORAMacro16b COp11m8: ; ORA(d),y addr_BdBCy_8br ORAMacro8b COp11m16:; ORA(d),y addr_BdBCy_16br ORAMacro16b COp12m8: ; ORA(d) addr_BdB_8br ORAMacro8b COp12m16:; ORA(d) addr_BdB_16br ORAMacro16b COp13m8: ; ORA(d,s),y addr_BdCsBCy_8br ORAMacro8b COp13m16:; ORA(d,s),y addr_BdCsBCy_16br ORAMacro16b COp15m8: ; ORA d,x addr_dCx_8br ORAMacro8b COp15m16:; ORA d,x addr_dCx_16br ORAMacro16b COp17m8: ; ORA [d],y addr_LdLCy_8br ORAMacro8b COp17m16:; ORA [d],y addr_LdLCy_16br ORAMacro16b COp19m8: ; ORA a,y addr_aCy_8br ORAMacro8b COp19m16:; ORA a,y addr_aCy_16br ORAMacro16b COp1Dm8: ; ORA a,x addr_aCx_8br ORAMacro8b COp1Dm16:; ORA a,x addr_aCx_16br ORAMacro16b COp1Fm8: ; ORA al,x addr_alCx_8br ORAMacro8b COp1Fm16:; ORA al,x addr_alCx_16br ORAMacro16b COpF4: ; PEA s PEAMacro COpD4: ; PEI s PEIMacro COp62: ; PER s PERMacro COp48m8: ; PHA s PUSHMacro8b [xa] COp48m16:; PHA s PUSHMacro16b [xa], [xa+1] COp8B: ; PHB s PUSHMacro8b [xdb] COp0B: ; PHD s PUSHMacro16b [xd], [xd+1] COp4B: ; PHK s PUSHMacro8b [xpb] COp08: ; PHP s PUSHMacro8bp COpDAx8: ; PHX s PUSHMacro8b [xx] COpDAx16:; PHX s PUSHMacro16b [xx], [xx+1] COp5Ax8: ; PHY s PUSHMacro8b [xy] COp5Ax16:; PHY s PUSHMacro16b [xy], [xy+1] COp68m8: ; PLA s POPMacro8b [xa] COp68m16:; PLA s POPMacro16b [xa], [xa+1] COpAB: ; PLB s POPMacro8b [xdb] COp2B: ; PLD s POPMacro16bd [xd], [xd+1] COp28: ; PLP s POPMacroP COpFAx8: ; PLX s POPMacro8b [xx] COpFAx16:; PLX s POPMacro16b [xx], [xx+1] COp7Ax8: ; PLY s POPMacro8b [xy] COp7Ax16:; PLY s POPMacro16b [xy], [xy+1] COpC2: ; REP # REPMacro COp26m8: ; ROL d addr_d_8brni ROLMacro8b addr_d_8bw endloop COp26m16:; ROL d addr_d_16brni ROLMacro16b addr_d_16bw endloop COp2Am8: ; ROL A addr_A_8brni ROLMacro8b addr_A_8bw endloop COp2Am16:; ROL A addr_A_16brni ROLMacro16b addr_A_16bw endloop COp2Em8: ; ROL a addr_a_8brni ROLMacro8b addr_a_8bw endloop COp2Em16:; ROL a addr_a_16brni ROLMacro16b addr_a_16bw endloop COp36m8: ; ROL d,x addr_dCx_8brni ROLMacro8b addr_dCx_8bw endloop COp36m16:; ROL d,x addr_dCx_16brni ROLMacro16b addr_dCx_16bw endloop COp3Em8: ; ROL a,x addr_aCx_8brni ROLMacro8b addr_aCx_8bw endloop COp3Em16:; ROL a,x addr_aCx_16brni ROLMacro16b addr_aCx_16bw endloop COp66m8: ; ROR d addr_d_8brni RORMacro8b addr_d_8bw endloop COp66m16:; ROR d addr_d_16brni RORMacro16b addr_d_16bw endloop COp6Am8: ; ROR A addr_A_8brni RORMacro8b addr_A_8bw endloop COp6Am16:; ROR A addr_A_16brni RORMacro16b addr_A_16bw endloop COp6Em8: ; ROR a addr_a_8brni RORMacro8b addr_a_8bw endloop COp6Em16:; ROR a addr_a_16brni RORMacro16b addr_a_16bw endloop COp76m8: ; ROR d,x addr_dCx_8brni RORMacro8b addr_dCx_8bw endloop COp76m16:; ROR d,x addr_dCx_16brni RORMacro16b addr_dCx_16bw endloop COp7Em8: ; ROR a,x addr_aCx_8brni RORMacro8b addr_aCx_8bw endloop COp7Em16:; ROR a,x addr_aCx_16brni RORMacro16b addr_aCx_16bw endloop COp40: ; RTI s RTIMacro COp6B: ; RTL s RTLMacro COp60: ; RTS s RTSMacro COpE1m8nd: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bnd COpE1m16nd: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bnd COpE1m8d: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bd COpE1m16d: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bd COpE3m8nd: ; SBC d,s addr_dCs_8br SBCMacro8bnd COpE3m16nd: ; SBC d,s addr_dCs_16br SBCMacro16bnd COpE3m8d: ; SBC d,s addr_dCs_8br SBCMacro8bd COpE3m16d: ; SBC d,s addr_dCs_16br SBCMacro16bd COpE5m8nd: ; SBC d addr_d_8br SBCMacro8bnd COpE5m16nd: ; SBC d addr_d_16br SBCMacro16bnd COpE5m8d: ; SBC d addr_d_8br SBCMacro8bd COpE5m16d: ; SBC d addr_d_16br SBCMacro16bd COpE7m8nd: ; SBC [d] addr_LdL_8br SBCMacro8bnd COpE7m16nd: ; SBC [d] addr_LdL_16br SBCMacro16bnd COpE7m8d: ; SBC [d] addr_LdL_8br SBCMacro8bd COpE7m16d: ; SBC [d] addr_LdL_16br SBCMacro16bd COpE9m8nd: ; SBC # addr_I_8br SBCMacro8bnd COpE9m16nd: ; SBC # addr_I_16br SBCMacro16bnd COpE9m8d: ; SBC # addr_I_8br SBCMacro8bd COpE9m16d: ; SBC # addr_I_16br SBCMacro16bd COpEDm8nd: ; SBC a addr_a_8br SBCMacro8bnd COpEDm16nd: ; SBC a addr_a_16br SBCMacro16bnd COpEDm8d: ; SBC a addr_a_8br SBCMacro8bd COpEDm16d: ; SBC a addr_a_16br SBCMacro16bd COpEFm8nd: ; SBC al addr_al_8br SBCMacro8bnd COpEFm16nd: ; SBC al addr_al_16br SBCMacro16bnd COpEFm8d: ; SBC al addr_al_8br SBCMacro8bd COpEFm16d: ; SBC al addr_al_16br SBCMacro16bd COpF1m8nd: ; SBC(d),y addr_BdBCy_8br SBCMacro8bnd COpF1m16nd: ; SBC(d),y addr_BdBCy_16br SBCMacro16bnd COpF1m8d: ; SBC(d),y addr_BdBCy_8br SBCMacro8bd COpF1m16d: ; SBC(d),y addr_BdBCy_16br SBCMacro16bd COpF2m8nd: ; SBC (d) addr_BdB_8br SBCMacro8bnd COpF2m16nd: ; SBC (d) addr_BdB_16br SBCMacro16bnd COpF2m8d: ; SBC (d) addr_BdB_8br SBCMacro8bd COpF2m16d: ; SBC (d) addr_BdB_16br SBCMacro16bd COpF3m8nd: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bnd COpF3m16nd: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bnd COpF3m8d: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bd COpF3m16d: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bd COpF5m8nd: ; SBC d,x addr_dCx_8br SBCMacro8bnd COpF5m16nd: ; SBC d,x addr_dCx_16br SBCMacro16bnd COpF5m8d: ; SBC d,x addr_dCx_8br SBCMacro8bd COpF5m16d: ; SBC d,x addr_dCx_16br SBCMacro16bd COpF7m8nd: ; SBC [d],y addr_LdLCy_8br SBCMacro8bnd COpF7m16nd: ; SBC [d],y addr_LdLCy_16br SBCMacro16bnd COpF7m8d: ; SBC [d],y addr_LdLCy_8br SBCMacro8bd COpF7m16d: ; SBC [d],y addr_LdLCy_16br SBCMacro16bd COpF9m8nd: ; SBC a,y addr_aCy_8br SBCMacro8bnd COpF9m16nd: ; SBC a,y addr_aCy_16br SBCMacro16bnd COpF9m8d: ; SBC a,y addr_aCy_8br SBCMacro8bd COpF9m16d: ; SBC a,y addr_aCy_16br SBCMacro16bd COpFDm8nd: ; SBC a,x addr_aCx_8br SBCMacro8bnd COpFDm16nd: ; SBC a,x addr_aCx_16br SBCMacro16bnd COpFDm8d: ; SBC a,x addr_aCx_8br SBCMacro8bd COpFDm16d: ; SBC a,x addr_aCx_16br SBCMacro16bd COpFFm8nd: ; SBC al,x addr_alCx_8br SBCMacro8bnd COpFFm16nd: ; SBC al,x addr_alCx_16br SBCMacro16bnd COpFFm8d: ; SBC al,x addr_alCx_8br SBCMacro8bd COpFFm16d: ; SBC al,x addr_alCx_16br SBCMacro16bd COp38: ; SEC i mov dword[flagc],0FFh endloop COpF8: ; SED i or dl,08h mov bl,dl mov edi,[tableadc+ebx*4] endloop COp78: ; SEI i or dl,04h endloop COpE2: ; SEP # SEPMacro COp81m8: ; STA(d,x) STAMacro8b addr_BdCxB_8bw endloop COp81m16:; STA(d,x) STAMacro16b addr_BdCxB_16bw endloop COp83m8: ; STA d,s STAMacro8b addr_dCs_8bw endloop COp83m16:; STA d,s STAMacro16b addr_dCs_16bw endloop COp85m8: ; STA d STAMacro8b addr_d_8bw endloop COp85m16:; STA d STAMacro16b addr_d_16bw endloop COp87m8: ; STA [d] STAMacro8b addr_LdL_8bw endloop COp87m16:; STA [d] STAMacro16b addr_LdL_16bw endloop COp8Dm8: ; STA a STAMacro8b addr_a_8bw endloop COp8Dm16:; STA a STAMacro16b addr_a_16bw endloop COp8Fm8: ; STA al STAMacro8b addr_al_8bw endloop COp8Fm16:; STA al STAMacro16b addr_al_16bw endloop COp91m8: ; STA(d),y STAMacro8b addr_BdBCy_8bw endloop COp91m16:; STA(d),y STAMacro16b addr_BdBCy_16bw endloop COp92m8: ; STA (d) STAMacro8b addr_BdB_8bw endloop COp92m16:; STA (d) STAMacro16b addr_BdB_16bw endloop COp93m8: ; STA(d,s),y STAMacro8b addr_BdCsBCy_8bw endloop COp93m16:; STA(d,s),y STAMacro16b addr_BdCsBCy_16bw endloop COp95m8: ; STA d,x STAMacro8b addr_dCx_8bw endloop COp95m16:; STA d,x STAMacro16b addr_dCx_16bw endloop COp97m8: ; STA [d],y STAMacro8b addr_LdLCy_8bw endloop COp97m16:; STA [d],y STAMacro16b addr_LdLCy_16bw endloop COp99m8: ; STA a,y STAMacro8b addr_aCy_8bw endloop COp99m16:; STA a,y STAMacro16b addr_aCy_16bw endloop COp9Dm8: ; STA a,x STAMacro8b addr_aCx_8bw endloop COp9Dm16:; STA a,x STAMacro16b addr_aCx_16bw endloop COp9Fm8: ; STA al,x STAMacro8b addr_alCx_8bw endloop COp9Fm16:; STA al,x STAMacro16b addr_alCx_16bw endloop COp86x8: ; STX d STXMacro8b addr_d_8bw endloop COp86x16:; STX d STXMacro16b addr_d_16bw endloop COp8Ex8: ; STX a STXMacro8b addr_a_8bw endloop COp8Ex16:; STX a STXMacro16b addr_a_16bw endloop COp96x8: ; STX d,y STXMacro8b addr_dCy_8bw endloop COp96x16:; STX d,y STXMacro16b addr_dCy_16bw endloop COp84x8: ; STY d STYMacro8b addr_d_8bw endloop COp84x16:; STY d STYMacro16b addr_d_16bw endloop COp8Cx8: ; STY a STYMacro8b addr_a_8bw endloop COp8Cx16:; STY a STYMacro16b addr_a_16bw endloop COp94x8: ; STYd,x STYMacro8b addr_dCx_8bw endloop COp94x16:; STYd,x STYMacro16b addr_dCx_16bw endloop COpDB: ; STP i dec esi endloop COp64m8: ; STZ d xor al,al addr_d_8bw endloop COp64m16:; STZ d xor eax,eax addr_d_16bw endloop COp74m8: ; STZ d,x xor al,al addr_dCx_8bw endloop COp74m16:; STZ d,x xor eax,eax addr_dCx_16bw endloop COp9Cm8: ; STZ a xor al,al addr_a_8bw endloop COp9Cm16:; STZ a xor eax,eax addr_a_16bw endloop COp9Em8: ; STZ a,x xor al,al addr_aCx_8bw endloop COp9Em16:; STZ a,x xor eax,eax addr_aCx_16bw endloop COp14m8: ; TRB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_d_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_d_8bw endloop COp14m16:; TRB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_d_16bw endloop COp1Cm8: ; TRB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cl,al jz .zero mov word[flagnz],1 not cl and al,cl addr_a_8bw endloop .zero mov word[flagnz],0 not cl and al,cl addr_a_8bw endloop COp1Cm16:; TRB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test cx,ax jz .zero mov word[flagnz],1 not cx and ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 not cx and ax,cx addr_a_16bw endloop COp04m8: ; TSB d addr_d_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_d_8bw endloop .zero mov word[flagnz],0 or al,cl addr_d_8bw endloop COp04m16:; TSB d addr_d_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_d_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_d_16bw endloop COp0Cm8: ; TSB a addr_a_8brni mov cl,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test al,cl jz .zero mov word[flagnz],1 or al,cl addr_a_8bw endloop .zero mov word[flagnz],0 or al,cl addr_a_8bw endloop COp0Cm16:; TSB a addr_a_16brni mov cx,[xa] test dword[flagnz],18000h jz .notflags or dword[flagnz],10000h .notflags test ax,cx jz .zero mov word[flagnz],1 or ax,cx addr_a_16bw endloop .zero mov word[flagnz],0 or ax,cx addr_a_16bw endloop COpAAx8: ; TAX i mov al,[xa] mov [xx],al flagsetnz8b endloop COpAAx16:; TAX i mov ax,[xa] mov [xx],ax flagsetnz16b endloop COpA8x8: ; TAY i mov al,[xa] mov [xy],al flagsetnz8b endloop COpA8x16:; TAY i mov ax,[xa] mov [xy],ax flagsetnz16b endloop COp5B: ; TCD i mov ax,[xa] mov [xd],ax call UpdateDPage flagsetnz16b endloop COp1B: ; TCS i mov ax,[xa] test byte[xe],1 jnz .emul mov [xs],ax endloop .emul mov [xs],al endloop COp7B: ; TDC i mov ax,[xd] mov [xa],ax flagsetnz16b endloop COp3B: ; TSC i mov ax,[xs] mov [xa],ax flagsetnz16b endloop COpBAx8: ; TSX i mov al,[xs] mov [xx],al flagsetnz8b endloop COpBAx16:; TSX i mov ax,[xs] mov [xx],ax flagsetnz16b endloop COp8Am8: ; TXA i mov al,[xx] mov [xa],al flagsetnz8b endloop COp8Am16:; TXA i mov ax,[xx] mov [xa],ax flagsetnz16b endloop COp9A: ; TXS i mov ax,[xx] mov [xs],ax test byte[xe],1 jnz .emul endloop .emul mov byte[xs+1],1 endloop COp9Bx8: ; TXY i mov al,[xx] mov [xy],al flagsetnz8b endloop COp9Bx16:; TXY i mov ax,[xx] mov [xy],ax flagsetnz16b endloop COp98m8: ; TYA i mov al,[xy] mov [xa],al flagsetnz8b endloop COp98m16:; TYA i mov ax,[xy] mov [xa],ax flagsetnz16b endloop COpBBx8: ; TYX i mov al,[xy] mov [xx],al flagsetnz8b endloop COpBBx16:; TYX i mov ax,[xy] mov [xx],ax flagsetnz16b endloop COpCB: ; WAI i WAIMacro COpEB: ; XBA i mov ah,[xa] mov al,[xa+1] mov [xa],ax flagsetnz8b endloop COpFB: ; XCE i XCEMacro COp42: ; WDM inc esi endloop zsnes-1.36/src/cpu/execute.asm0100644000175000017500000026572507513212522015726 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM StringLength EXTSYM Get_Time EXTSYM objhipr EXTSYM KeyRewind EXTSYM xa,timer2upd,prevoamptr,ReadHead EXTSYM prevedi,SA1xpc,SA1RAMArea,sa1dmaptr EXTSYM DSP1COp,C4WFXVal,C41FXVal,Op00Multiplicand,Op10Coefficient,Op04Angle EXTSYM Op08X,Op18X,Op28X,Op0CA,Op1CAZ,Op02FX,Op0AVS,Op06X,Op0DX,Op03F,Op14Zr EXTSYM Op0EH,DSP1Type,Op01m EXTSYM Voice0Status EXTSYM UpdateDPage EXTSYM Interror,MessageOn,MsgCount,Msgptr,StartGUI,cbitmode,debuggeron,romdata EXTSYM frameskip,initvideo,newgfx16b,oldhandSBo,oldhandSBs,soundon,cvidmode EXTSYM vidbuffer,vidbufferofsa,vidbufferofsb,disable65816sh,GUISaveVars,virqnodisable EXTSYM KeySaveState,KeyLoadState,KeyQuickExit,KeyQuickLoad,KeyQuickRst,GUIDoReset EXTSYM KeyOnStA,KeyOnStB,ProcessKeyOn,printnum,sramsavedis,DSPDisable,C4Enable EXTSYM KeyQuickClock,KeyQuickSaveSPC,TimerEnable,AutoIncSaveSlot EXTSYM IRQHack,HIRQLoc,Offby1line,splitflags,joinflags,KeyQuickSnapShot EXTSYM csounddisable,videotroub,Open_File,Close_File,Read_File,ResetTripleBuf EXTSYM Write_File,Output_Text,Create_File,Check_Key,Get_Key,Change_Dir,InitPreGame ;EXTSYM OSPort ; EXTSYM tempblah,romdata EXTSYM Curtableaddr,DeInitSPC,InitSB,PICMaskP,SBHandler,SBInt EXTSYM SBIrq,curcyc,debugdisble,dmadata,guioff,memtabler8,SetupPreGame EXTSYM memtablew8,regaccessbankr8,showmenu,snesmap2,snesmmap,DeInitPostGame EXTSYM spcPCRam,startdebugger,xp,xpb,xpc,tablead,tableadb,tableadc ; EXTSYM oamram EXTSYM SA1UpdateDPage,Makemode7Table EXTSYM memtabler16,memaccessbankr848mb,memaccessbankr1648mb EXTSYM nextmenupopup EXTSYM MovieProcessing EXTSYM MovieFileHand, PrintStr EXTSYM OSExit,DosExit,InitDir,InitDrive,createnewcfg,fnames,gotoroot,previdmode EXTSYM ramsize,sfxramdata,sram,SRAMDrive,SRAMDir,welcome ; EXTSYM tempstore EXTSYM printhex EXTSYM ModemInitStat, DeInitModem EXTSYM deinitipx EXTSYM deinitvideo EXTSYM BRRBuffer,DSPMem,PrepareSaveState,ResetState,SFXEnable,PHdspsave EXTSYM fnamest,sndrot,spcRam,spcRamDP,tableA,unpackfunct,vram,wramdata EXTSYM zsmesg,PHnum2writesfxreg,SfxR0,PHnum2writecpureg,PHspcsave EXTSYM C4Ram EXTSYM SPC7110Enable EXTSYM SA1Mode,PHnum2writesa1reg,SaveSA1,RestoreSA1,UpdateBanksSDD1 EXTSYM SDD1Enable EXTSYM CapturePicture,PrevPicture,NoPictureSave EXTSYM BRRPlace0,SfxCPB,SfxCROM,SfxLastRamAdr,SfxMemTable,Totalbyteloaded EXTSYM SfxRAMBR,SfxRAMMem,SfxROMBR,SfxRomBuffer,Voice0Freq EXTSYM cycpbl,cycpbl2,cycpblt,cycpblt2,irqon,nexthdma EXTSYM repackfunct,spcnumread,spcon,versn,headerhack,initpitch EXTSYM SPCMultA,PHnum2writespc7110reg EXTSYM multchange,procexecloop,vidmemch2 EXTSYM romispal EXTSYM dssel EXTSYM scrndis,sprlefttot,sprleftpr,processsprites,cachesprites EXTSYM NextLineStart,FlipWait,LastLineStart EXTSYM opcjmptab EXTSYM cpuoverptr EXTSYM CheatOn,INTEnab,JoyAPos,JoyBPos,JoyCRead,NMIEnab,NumCheats,CurrentExecSA1 EXTSYM ReadInputDevice,StartDrawNewGfx,VIRQLoc,cachevideo,cfield EXTSYM cheatdata,curblank,curnmi,curypos,cycpl,doirqnext,drawline EXTSYM execatzerovirq,exechdma,hdmadelay,intrset,newengen,oamaddr EXTSYM oamaddrs,processmouse,resolutn,showvideo,snesmouse,starthdma EXTSYM switchtonmi,switchtovirq,totlines,updatetimer,SA1Swap,SA1DoIRQ EXTSYM JoyAOrig,JoyANow,JoyBOrig,JoyBNow,JoyCOrig,JoyCNow,JoyDOrig,JoyDNow EXTSYM JoyEOrig,JoyENow,chaton,chatstrL,chatRTL,chatstrR,SA1Message EXTSYM MultiTapStat,MovieCounter,idledetectspc,SA1Control,SA1Enable,SA1IRQEnable EXTSYM SPC700read,SPC700write,numspcvblleft,spc700idle,SA1Status,SA1IRQExec EXTSYM ForceNewGfxOff,LethEnData,C4Pause,GUIQuit EXTSYM IRAM,SA1Ptr,SA1BWPtr EXTSYM scrnon,scaddset EXTSYM outofmemfix,yesoutofmemory EXTSYM CNetType,Latency,LatencyLeft,NetSwap ; EXTSYM vesa2selec EXTSYM RemoteSendChar,RemoteGetChar,pl1neten,pl2neten,pl3neten,pl4neten EXTSYM pl5neten,RemoteSendEAX,prevp1net,prevp2net,prevp3net,prevp4net EXTSYM RemoteGetEAX,cnetplaybuf,netdelayed,cnetptrtail,cnetptrhead EXTSYM ChatProgress,RecvProgress,chatTL,WritetochatBuffer,NetAddChar EXTSYM PreparePacket, SendPacket, NoInputRead, RemoteDisconnect EXTSYM SendPacketUDP EXTSYM ChatNick EXTSYM JoyRead,ChatType2,chatstrR2,chatstrR3,chatstrR4,chatstrR5 EXTSYM chatRTL2,chatRTL3,chatRTL4,chatRTL5 EXTSYM NetLoadState EXTSYM ProcessMovies EXTSYM C4VBlank EXTSYM dsp1teststuff EXTSYM ReturnFromSPCStall,SPCStallSetting,cycpb268,cycpb358,HIRQSkip,scanlines EXTSYM smallscreenon,ScreenScale EXTSYM MainLoop,NumberOfOpcodes,SfxCLSR,SfxSCMR,SfxPOR EXTSYM sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc,sfxclineloc EXTSYM PLOTJmpa,PLOTJmpb,FxTable,FxTableb,FxTablec,FxTabled EXTSYM SfxPBR,SCBRrel,SfxSCBR,SfxCOLR,hdmaearlstart,SFXCounter EXTSYM fxbit01,fxbit01pcal,fxbit23,fxbit23pcal,fxbit45,fxbit45pcal,fxbit67,fxbit67pcal EXTSYM SfxSFR,nosprincr,hirqmode2 EXTSYM cpucycle,debstop,switchtovirqdeb,debstop3,switchtonmideb EXTSYM ReadSPC7110log,WriteSPC7110log EXTSYM NetPlayNoMore EXTSYM statefileloc NEWSYM ExecuteAsmStart %macro BackupCVMacM 2 mov edx,%1 mov ecx,%2 %%loop movq mm0,[edx] movq mm1,[edx+8] movq [ebx],mm0 movq [ebx+8],mm1 add edx,16 add ebx,16 loop %%loop %endmacro %macro BackupCVMac 2 mov edx,%1 mov ecx,%2 %%loop mov eax,[edx] mov [ebx],eax add edx,4 add ebx,4 loop %%loop %endmacro %macro BackupCVMacB 2 mov edx,%1 mov ecx,%2 %%loop mov al,[edx] mov [ebx],al inc edx inc ebx loop %%loop %endmacro %macro BackupCVRMacM 2 mov edx,%1 mov ecx,%2 %%loop movq mm0,[ebx] movq mm1,[ebx+8] movq [edx],mm0 movq [edx+8],mm1 add edx,16 add ebx,16 loop %%loop %endmacro %macro BackupCVRMac 2 mov edx,%1 mov ecx,%2 %%loop mov eax,[ebx] mov [edx],eax add edx,4 add ebx,4 loop %%loop %endmacro %macro BackupCVRMacB 2 mov edx,%1 mov ecx,%2 %%loop mov al,[ebx] mov [edx],al inc edx inc ebx loop %%loop %endmacro NEWSYM CBackupPos, dd 0 NEWSYM StateBackup, dd 0 NEWSYM PBackupPos, dd 0 NEWSYM PPValue, dd 0 ; Previous PValue NEWSYM DPValue, dd 0 ; Destination PValue NEWSYM CurRecv, dd 0 ; Set to 1 if Recovery mode is on ; if CurRecv=1, then do not send tcp/ip data, always frame skip, do not ; draw to screen, do not key on, restore previous local key presses, ; when disabling key ons, divert dspmem write/read to a different ; array temporarly, then re-copy back in when finished NEWSYM PPContrl, times 16 dd 0 ; Previous Controller 1 Data NEWSYM PPContrl2, times 16 dd 0 ; Previous Controller 2 Data NEWSYM PPContrl3, times 16 dd 0 ; Previous Controller 3 Data NEWSYM PPContrl4, times 16 dd 0 ; Previous Controller 4 Data NEWSYM PPContrl5, times 16 dd 0 ; Previous Controller 5 Data NEWSYM tempedx, dd 0 NEWSYM NetSent2, dd 0 NEWSYM NetQuitter, dd 0 NEWSYM QBackupPos, dd 0 NEWSYM LatencyV, times 256 db 0 NEWSYM LatencyRecvPtr, dd 0 NEWSYM LatencySendPtr, dd 0 NEWSYM latencytimer, dd 0 NEWSYM BackState, db 1 NEWSYM BackStateSize, dd 6 NEWSYM nojoystickpoll, dd 0 NEWSYM RemoteLValue, db 0 NEWSYM LocalLValue, db 0 NEWSYM chatstrLt, times 15 db 0 NEWSYM RewindOldPos, dd 0 NEWSYM RewindPos, dd 0 NEWSYM RewindTimer, dd 0 NEWSYM ResendTimer, dd 60 NEWSYM valuea, dd 0 NEWSYM valueb, dd 0 NEWSYM valuet, dd 0 BackupArray times 2000 dd 0 NEWSYM SplitStringChat push ebx push eax push ecx mov eax,chatstrR call StringLength cmp ecx,42 jbe near .noneed mov eax,42 .next2 cmp byte[chatstrR+eax],' ' je near .space cmp eax,33 jb .dontclipearly dec eax jmp .next2 .space inc eax jmp .processclip .dontclipearly mov eax,42 .processclip push eax mov ebx,[chatRTL4] mov [chatRTL5],ebx mov ebx,[chatRTL3] mov [chatRTL4],ebx mov ebx,[chatRTL2] mov [chatRTL3],ebx mov ebx,[chatRTL] mov [chatRTL2],ebx xor ecx,ecx .chatcpyloop mov al,[chatstrR4+ecx] mov [chatstrR5+ecx],al mov al,[chatstrR3+ecx] mov [chatstrR4+ecx],al mov al,[chatstrR2+ecx] mov [chatstrR3+ecx],al mov al,[chatstrR+ecx] mov [chatstrR2+ecx],al inc ecx cmp ecx,100 jnz .chatcpyloop pop eax push eax xor ecx,ecx mov byte[chatstrR],' ' inc ecx .next mov bl,[chatstrR2+eax] mov [chatstrR+ecx],bl inc eax inc ecx or bl,bl jnz .next pop eax mov byte[chatstrR2+eax],0 .noneed pop ecx pop eax pop ebx ret NEWSYM MoveStringChat mov ebx,[chatRTL4] mov [chatRTL5],ebx mov ebx,[chatRTL3] mov [chatRTL4],ebx mov ebx,[chatRTL2] mov [chatRTL3],ebx mov ebx,[chatRTL] mov [chatRTL2],ebx push eax push ecx xor ecx,ecx .chatcpyloop mov al,[chatstrR4+ecx] mov [chatstrR5+ecx],al mov al,[chatstrR3+ecx] mov [chatstrR4+ecx],al mov al,[chatstrR2+ecx] mov [chatstrR3+ecx],al mov al,[chatstrR+ecx] mov [chatstrR2+ecx],al inc ecx cmp ecx,100 jnz .chatcpyloop pop ecx pop eax ret NEWSYM GenLatencyDisplay call Get_Time mov [.temp],eax mov ebx,16 xor eax,eax xor edx,edx mov al,[valuea] mov al,[.temp] div ebx add al,48 add dl,48 mov byte[chatstrLt+2],32 cmp al,9 jbe .bel9 ; sub al,10 .bel9 mov [chatstrLt+1],dl mov [chatstrLt],al mov ebx,16 xor eax,eax xor edx,edx mov al,[.temp+1] div ebx add al,48 add dl,48 cmp al,9 jbe .bel9b ; sub al,10 .bel9b mov [chatstrLt+4],dl mov [chatstrLt+3],al ret .temp dd 0 NEWSYM ResetExecStuff mov dword[soundcycleft],0 mov dword[curexecstate],0 mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov dword[nmirept],0 mov dword[nmiprevline],224 mov dword[nmistatus],0 mov byte[NextLineCache],0 mov byte[spcnumread],0 mov dword[timer2upd],0 mov dword[HIRQCycNext],0 mov byte[HIRQNextExe],0 ret NEWSYM ProcessRewind cmp byte[CNetType],20 jb .okay .notokayb ret .okay mov eax,dword[KeyRewind] cmp byte[pressed+eax],1 jne .notokayb mov byte[pressed+eax],2 mov eax,[RewindOldPos] cmp [RewindPos],eax je .notokay dec dword[RewindPos] and dword[RewindPos],0Fh mov eax,[RewindOldPos] cmp [RewindPos],eax je .notokay2 dec dword[RewindPos] and dword[RewindPos],0Fh mov eax,[RewindPos] mov [PBackupPos],eax push ecx push ebx call RestoreCVFrame ; Clear Cache Check mov ebx,vidmemch2 mov ecx,4096+4096+4096 .next mov byte[ebx],1 inc ebx dec ecx jnz .next pop ebx pop ecx inc dword[RewindPos] and dword[RewindPos],0Fh mov edx,[tempedx] mov dword[RewindTimer],60*3 .notokay ret .notokay2 inc dword[RewindPos] and dword[RewindPos],0Fh ret NEWSYM UpdateRewind ; cmp byte[OSPort],3 ; je .yeswin32 ; ret ;.yeswin32 %ifndef __MSDOS__ push eax cmp dword[KeyRewind],0 je .notftimer call ProcessRewind dec dword[RewindTimer] jnz .notftimer cmp byte[CNetType],20 jb .okay .notftimer pop eax ret .okay mov eax,[RewindPos] mov [CBackupPos],eax mov [tempedx],edx push ecx push ebx call BackupCVFrame pop ebx pop ecx inc dword[RewindPos] and dword[RewindPos],0Fh mov eax,[RewindOldPos] cmp [RewindPos],eax jne .noteq inc dword[RewindOldPos] and dword[RewindOldPos],0Fh .noteq mov dword[RewindTimer],60*3 pop eax %endif ret NEWSYM BackupSystemVars pushad mov ebx,BackupArray BackupCVMacB zsmesg,[PHnum2writecpureg] BackupCVMac cycpbl,2 BackupCVMacB sndrot,3019 BackupCVMacB soundcycleft,33 BackupCVMac spc700read,10 BackupCVMac timer2upd,1 BackupCVMac xa,14 BackupCVMacB spcnumread,1 BackupCVMac opcd,6 BackupCVMacB HIRQCycNext,5 BackupCVMac oamaddr,14 BackupCVMacB prevoamptr,1 BackupCVMac ReadHead,1 popad ret NEWSYM RestoreSystemVars pushad mov dword[RewindPos],0 mov dword[RewindOldPos],0 mov dword[RewindTimer],60*4 mov ebx,BackupArray BackupCVRMacB zsmesg,[PHnum2writecpureg] BackupCVRMac cycpbl,2 BackupCVRMacB sndrot,3019 BackupCVRMacB soundcycleft,33 BackupCVRMac spc700read,10 BackupCVRMac timer2upd,1 BackupCVRMac xa,14 BackupCVRMacB spcnumread,1 BackupCVRMac opcd,6 BackupCVRMacB HIRQCycNext,5 BackupCVRMac oamaddr,14 BackupCVRMacB prevoamptr,1 BackupCVRMac ReadHead,1 popad ret NEWSYM BackupCVFrame ;NEWSYM StateBackup, dd 0 ;NEWSYM CBackupPos, dd 0 ;NEWSYM PBackupPos, dd 0 push edx push eax mov ebx,[CBackupPos] shl ebx,19 add ebx,[StateBackup] add ebx,1024 BackupCVMacB zsmesg,[PHnum2writecpureg] BackupCVMac cycpbl,2 BackupCVMacB sndrot,3019 BackupCVMacM [wramdata],8192 BackupCVMacM [vram],4096 cmp byte[spcon],0 je .nospcon BackupCVMacB spcRam,[PHspcsave] BackupCVMacM DSPMem,16 .nospcon cmp byte[C4Enable],1 jne .noc4 BackupCVMac [C4Ram],800h .noc4 cmp byte[SFXEnable],1 jne .nosfx BackupCVMacM [sfxramdata],8192 .nosfx cmp byte[SA1Enable],1 jne near .nossa1 BackupCVMacB SA1Mode,[PHnum2writesa1reg] BackupCVMacM [SA1RAMArea],8192 BackupCVMacB SA1Status,3 BackupCVMac prevedi,1 BackupCVMac SA1xpc,1 BackupCVMac SA1RAMArea,6 BackupCVMac sa1dmaptr,2 .nossa1 cmp byte[DSP1Type],0 je near .nodsp1type BackupCVMacB DSP1COp,70+128 BackupCVMacB C4WFXVal,7*4+7*8+128 BackupCVMacB C41FXVal,5*4+128 BackupCVMacB Op00Multiplicand,3*4+128 BackupCVMacB Op10Coefficient,4*4+128 BackupCVMacB Op04Angle,4*4+128 BackupCVMacB Op08X,5*4+128 BackupCVMacB Op18X,5*4+128 BackupCVMacB Op28X,4*4+128 BackupCVMacB Op0CA,5*4+128 BackupCVMacB Op1CAZ,15*4+128 BackupCVMacB Op02FX,11*4+3*4+28*8+128 BackupCVMacB Op0AVS,5*4+14*8+128 BackupCVMacB Op06X,6*4+10*8+4+128 BackupCVMacB Op01m,4*4+128 BackupCVMacB Op0DX,6*4+128 BackupCVMacB Op03F,6*4+128 BackupCVMacB Op14Zr,9*4+128 BackupCVMacB Op0EH,4*4+128 .nodsp1type BackupCVMacB soundcycleft,33 BackupCVMac spc700read,10 BackupCVMac timer2upd,1 BackupCVMac xa,14 BackupCVMacB spcnumread,1 BackupCVMac opcd,6 BackupCVMacB HIRQCycNext,5 BackupCVMac oamaddr,14 BackupCVMacB prevoamptr,1 BackupCVMac ReadHead,1 mov edx,[sram] mov ecx,[ramsize] shr ecx,4 or ecx,ecx jz .end .loop movq mm0,[edx] movq mm1,[edx+8] movq [ebx],mm0 movq [ebx+8],mm1 add edx,16 add ebx,16 dec ecx jnz .loop .end pop eax pop edx mov [ebx],esi mov [ebx+4],edi mov ecx,[tempedx] mov [ebx+8],ecx mov [ebx+12],ebp emms ret NEWSYM RestoreCVFrame push edx push eax mov ebx,[PBackupPos] shl ebx,19 add ebx,[StateBackup] add ebx,1024 BackupCVRMacB zsmesg,[PHnum2writecpureg] BackupCVRMac cycpbl,2 BackupCVRMacB sndrot,3019 BackupCVRMacM [wramdata],8192 BackupCVRMacM [vram],4096 cmp byte[spcon],0 je .nospcon BackupCVRMacB spcRam,[PHspcsave] BackupCVRMacM DSPMem,16 .nospcon cmp byte[C4Enable],1 jne .noc4 BackupCVRMac [C4Ram],800h .noc4 cmp byte[SFXEnable],1 jne .nosfx BackupCVRMacM [sfxramdata],8192 .nosfx cmp byte[SA1Enable],1 jne near .nossa1 BackupCVRMacB SA1Mode,[PHnum2writesa1reg] BackupCVRMacM [SA1RAMArea],8192 BackupCVRMacB SA1Status,3 BackupCVRMac prevedi,1 BackupCVRMac SA1xpc,1 BackupCVRMac SA1RAMArea,6 BackupCVRMac sa1dmaptr,2 .nossa1 cmp byte[DSP1Type],0 je near .nodsp1type BackupCVRMacB DSP1COp,70+128 BackupCVRMacB C4WFXVal,7*4+7*8+128 BackupCVRMacB C41FXVal,5*4+128 BackupCVRMacB Op00Multiplicand,3*4+128 BackupCVRMacB Op10Coefficient,4*4+128 BackupCVRMacB Op04Angle,4*4+128 BackupCVRMacB Op08X,5*4+128 BackupCVRMacB Op18X,5*4+128 BackupCVRMacB Op28X,4*4+128 BackupCVRMacB Op0CA,5*4+128 BackupCVRMacB Op1CAZ,15*4+128 BackupCVRMacB Op02FX,11*4+3*4+28*8+128 BackupCVRMacB Op0AVS,5*4+14*8+128 BackupCVRMacB Op06X,6*4+10*8+4+128 BackupCVRMacB Op01m,4*4+128 BackupCVRMacB Op0DX,6*4+128 BackupCVRMacB Op03F,6*4+128 BackupCVRMacB Op14Zr,9*4+128 BackupCVRMacB Op0EH,4*4+128 .nodsp1type BackupCVRMacB soundcycleft,33 BackupCVRMac spc700read,10 BackupCVRMac timer2upd,1 BackupCVRMac xa,14 BackupCVRMacB spcnumread,1 BackupCVRMac opcd,6 BackupCVRMacB HIRQCycNext,5 BackupCVRMac oamaddr,14 BackupCVRMacB prevoamptr,1 BackupCVRMac ReadHead,1 mov edx,[sram] mov ecx,[ramsize] shr ecx,4 or ecx,ecx jz .end .loop movq mm0,[ebx] movq mm1,[ebx+8] movq [edx],mm0 movq [edx+8],mm1 add edx,16 add ebx,16 dec ecx jnz .loop .end pop eax pop edx mov esi,[ebx] mov edi,[ebx+4] mov ecx,[ebx+8] mov [tempedx],ecx mov ebp,[ebx+12] call UpdateDPage call SA1UpdateDPage emms ret NEWSYM MuteVoiceF, db 0 VoiceEndMute: mov byte[MuteVoiceF],0 ret %macro StartMute 1 mov al,[Voice0Status+%1] or al,al jz %%notmuted or byte[MuteVoiceF],1 << %1 %%notmuted %endmacro VoiceStartMute: mov byte[MuteVoiceF],0 push eax StartMute 0 StartMute 1 StartMute 2 StartMute 3 StartMute 4 StartMute 5 StartMute 6 StartMute 7 pop eax ret NetSaveState: call joinflags ; de-init variables (copy to variables) mov [spcPCRam],ebp mov [Curtableaddr],edi mov [xp],dl mov [curcyc],dh mov eax,[initaddrl] sub esi,eax ; subtract program counter by address mov [xpc],si call ResetTripleBuf mov eax,[KeySaveState] cmp byte[CNetType],20 je .skipsoundreinit test byte[pressed+eax],1 jnz .soundreinit mov eax,[KeyLoadState] test byte[pressed+eax],1 jz .skipsoundreinit .soundreinit mov byte[NoSoundReinit],1 mov byte[csounddisable],1 .skipsoundreinit call statesaver ; initialize variables (Copy from variables) call UpdateDPage call SA1UpdateDPage call Makemode7Table cmp byte[SFXEnable],0 je .nosfxud call UpdateSFX .nosfxud xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov bl,[xpb] mov ax,[xpc] test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] jmp .skiplower .loweraddr cmp ax,4300h jb .lower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma .lower mov esi,[snesmap2+ebx*4] jmp .skiplower .dma mov esi,dmadata-4300h .skiplower mov [initaddrl],esi add esi,eax ; add program counter to address mov dl,[xp] ; set flags mov dh,[curcyc] ; set cycles mov bl,dl ; cmp byte[CNetType],20 ; je .skipmovie ; cmp byte[CNetType],21 ; je .skipmovie ; jmp .skipmovie ; cmp byte[MovieProcessing],0 ; jne .movie ;.skipmovie cmp byte[spcon],0 je .nosoundta mov edi,[tableadc+ebx*4] or byte[curexecstate],2 jmp .soundta .nosoundta mov edi,[tableadb+ebx*4] and byte[curexecstate],0FDh .soundta jmp .nomovie .movie mov edi,[tableadc+ebx*4] test byte[curexecstate],2 jnz .nomovie mov edi,[tableadb+ebx*4] .nomovie mov ebp,[spcPCRam] mov byte[NoSoundReinit],0 mov byte[csounddisable],0 mov byte[NextNGDisplay],0 call splitflags ret %macro stim 0 ; cmp byte[OSPort],1 ; ja %%nosti %ifdef __MSDOS__ sti %endif ;%%nosti %endmacro %macro clim 0 ; cmp byte[OSPort],1 ; ja %%nocli %ifdef __MSDOS__ cli %endif ;%%nocli %endmacro %macro ProcessIRQStuffB 0 ; check for VIRQ/HIRQ/NMI test dl,04h jnz %%noirq test byte[INTEnab],20h jz %%novirq mov ax,[VIRQLoc] cmp word[curypos],ax je near .virq jmp %%noirq %%novirq test byte[INTEnab],10h jnz near .virq %%noirq test byte[INTEnab],20h jz %%novirq2b mov ax,[VIRQLoc] cmp word[curypos],ax jne %%novirq2b cmp byte[intrset],1 jne %%nointrset2b mov byte[intrset],2 %%nointrset2b %%novirq2b %endmacro %macro ProcessIRQStuffC 0 ; check for VIRQ/HIRQ cmp byte[virqnodisable],1 je %%virqdo test dl,04h jnz %%virqdo cmp byte[doirqnext],1 je near .virq %%virqdo test byte[INTEnab],20h jz near %%novirq mov ax,[VIRQLoc] add ax,[IRQHack] cmp ax,[resolutn] jne %%notres dec ax ; inc ax %%notres cmp ax,0FFFFh jne %%notzero xor ax,ax %%notzero cmp word[curypos],ax jne near %%noirq %%startirq cmp byte[intrset],1 jne %%nointrseta mov byte[intrset],2 %%nointrseta mov byte[irqon],80h test dl,04h jnz %%irqd test byte[INTEnab],10h jnz %%tryhirq jmp .virq %%novirq test byte[INTEnab],10h jz %%noirq %%tryhirq jmp .virq jmp %%startirq %%irqd mov byte[doirqnext],1 %%noirq %endmacro %macro ProcessIRQStuff 0 ; check for VIRQ/HIRQ cmp byte[virqnodisable],1 je %%virqdo test dl,04h jnz %%virqdo cmp byte[doirqnext],1 je near .virq %%virqdo test byte[INTEnab],20h jz near %%novirq mov ax,[VIRQLoc] add ax,[IRQHack] cmp ax,[resolutn] jne %%notres dec ax ; inc ax %%notres cmp ax,0FFFFh jne %%notzero xor ax,ax %%notzero cmp word[curypos],ax jne near %%noirq test byte[INTEnab],10h jnz %%tryhirq %%startirq cmp byte[intrset],1 jne %%nointrseta mov byte[intrset],2 %%nointrseta mov byte[irqon],80h test dl,04h jnz %%irqd jmp .virq %%novirq test byte[INTEnab],10h jz %%noirq %%setagain cmp byte[intrset],2 jbe %%nointrseta3 dec byte[intrset] cmp byte[intrset],2 ja %%noirq %%nointrseta3 cmp byte[intrset],1 jne %%nointrseta2 cmp byte[hirqmode2],1 je %%hirqchange mov byte[intrset],8 jmp %%noirq %%hirqchange mov byte[intrset],3 jmp %%setagain %%nointrseta2 test dl,04h jnz %%noirq %%tryhirq jmp %%startirq %%irqd mov byte[doirqnext],1 %%noirq %endmacro ; .returnfromsfx ; pexecs ; *** Copy to PC whenever a non-relative jump is executed NEWSYM romloadskip, db 0 NEWSYM abcdefg, dd 0 NEWSYM abcdefg1, dd 0 NEWSYM abcdefg2, dd 0 NEWSYM abcdefg3, dd 0 NEWSYM SSKeyPressed, dd 0 NEWSYM SPCKeyPressed, dd 0 NEWSYM NoSoundReinit, dd 0 NEWSYM NextNGDisplay, db 0 NEWSYM TempVidInfo, dd 0 NEWSYM tempdh, db 0 NEWSYM start65816 call initvideo cmp byte[videotroub],1 jne .notrouble ret .notrouble ; cmp byte[OSPort],2 ; jae .nonewgfxcheck jmp .nonewgfxcheck cmp byte[cbitmode],1 jne .nonewgfxcheck cmp byte[newengen],1 jne .nonewgfxcheck cmp byte[cvidmode],3 jne .nocorrectmode cmp byte[newgfx16b],1 je .nonewgfxcheck jmp .correctmode .nocorrectmode mov dword[Msgptr],newgfxerror2 jmp .correctmode mov dword[Msgptr],newgfxerror .correctmode mov eax,[MsgCount] mov [MessageOn],eax mov byte[newengen],0 .nonewgfxcheck mov edi,[vidbufferofsa] mov ecx,37518 xor eax,eax rep stosd ; mov edi,[vidbufferofsb] ; mov ecx,37518 ; xor eax,eax ; rep stosd cmp byte[romloadskip],1 je near StartGUI NEWSYM continueprog ; clear keyboard presses mov esi,pressed mov ecx,256+128+64 mov al,0 .loopa mov [esi],al inc esi dec ecx jnz .loopa mov byte[romloadskip],0 mov byte[debuggeron],0 mov byte[exiter],0 call InitPreGame jmp reexecute NEWSYM continueprognokeys mov byte[romloadskip],0 mov byte[debuggeron],0 mov byte[exiter],0 call InitPreGame jmp reexecutenokeys ; Incorrect NEWSYM reexecute ; clear keyboard presses mov esi,pressed mov ecx,256+128+64 mov al,0 .loopa cmp byte[esi],2 jne .notclear mov [esi],al .notclear inc esi dec ecx jnz .loopa reexecutenokeys jmp reexecuteb2 NEWSYM reexecuteb ;cmp byte[OSPort],1 ;ja reexecuteb2 %ifdef __MSDOS__ mov esi,pressed mov ecx,256+128+64 mov al,0 .loopa cmp byte[esi],2 jne .notclear mov [esi],al .notclear inc esi dec ecx jnz .loopa %endif reexecuteb2: ; temporary sprite displayer ; mov edx,.sdispname ; call Open_File ; jc .failedsd ; mov bx,ax ; mov ecx,544 ; mov edx,oamram ; call Read_File ; call Close_File ;.failedsd ; jmp .skipsd ;.sdispname db 'MMX3.SPR',0 ;.skipsd cmp byte[NoSoundReinit],1 je .skippregame call SetupPreGame .skippregame ; initialize variables (Copy from variables) call UpdateDPage call SA1UpdateDPage call Makemode7Table call ReadSPC7110log cmp byte[SFXEnable],0 je .nosfxud call UpdateSFX .nosfxud xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov bl,[xpb] mov ax,[xpc] test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] jmp .skiplower .loweraddr cmp ax,4300h jb .lower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma .lower mov esi,[snesmap2+ebx*4] jmp .skiplower .dma mov esi,dmadata-4300h .skiplower mov [initaddrl],esi add esi,eax ; add program counter to address mov dl,[xp] ; set flags mov dh,[curcyc] ; set cycles mov bl,dl ; cmp byte[CNetType],20 ; je .skipmovie ; cmp byte[CNetType],21 ; je .skipmovie ; jmp .skipmovie ; cmp byte[MovieProcessing],0 ; jne .movie ;.skipmovie cmp byte[spcon],0 je .nosoundta mov edi,[tableadc+ebx*4] or byte[curexecstate],2 jmp .soundta .nosoundta mov edi,[tableadb+ebx*4] and byte[curexecstate],0FDh .soundta jmp .nomovie .movie mov edi,[tableadc+ebx*4] test byte[curexecstate],2 jnz .nomovie mov edi,[tableadb+ebx*4] .nomovie mov ebp,[spcPCRam] mov byte[NoSoundReinit],0 mov byte[csounddisable],0 mov byte[NextNGDisplay],0 mov byte[NetPlayNoMore],1 call splitflags ; cmp byte[MovieProcessing],0 ; jne .movie2 call execute jmp .nomovie2 .movie2 call cpuover.returntoloop .nomovie2 call joinflags ; de-init variables (copy to variables) mov [spcPCRam],ebp mov [Curtableaddr],edi mov [xp],dl mov [curcyc],dh mov eax,[initaddrl] sub esi,eax ; subtract program counter by address mov [xpc],si call ResetTripleBuf mov eax,[KeySaveState] cmp byte[CNetType],20 je .skipsoundreinit test byte[pressed+eax],1 jnz .soundreinit mov eax,[KeyLoadState] test byte[pressed+eax],1 jz .skipsoundreinit .soundreinit mov byte[NoSoundReinit],1 mov byte[csounddisable],1 .skipsoundreinit cmp byte[NoSoundReinit],1 je .skippostgame call DeInitPostGame .skippostgame call WriteSPC7110log ; clear all keys call Check_Key cmp al,0 je .nokeys .yeskeys call Get_Key call Check_Key cmp al,0 jne .yeskeys .nokeys ; mov edi,memtabler8+40h*4 ; mov ecx,30h ; mov eax,memaccessbankr848mb ; rep stosd ; mov edi,memtabler16+40h*4 ; mov ecx,30h ; mov eax,memaccessbankr1648mb ; rep stosd cmp byte[nextmenupopup],1 je near showmenu cmp byte[ReturnFromSPCStall],1 je near .activatereset mov eax,[KeySaveState] cmp byte[CNetType],20 je .net test byte[pressed+eax],1 jnz near savestate mov eax,[KeyLoadState] test byte[pressed+eax],1 jnz near loadstate cmp byte[SSKeyPressed],1 je near showmenu cmp byte[SPCKeyPressed],1 je near showmenu cmp byte[debugdisble],0 jne .nodebugger test byte[pressed+59],1 jne near startdebugger .nodebugger test byte[pressed+59],1 jne near showmenu mov eax,[KeyQuickRst] .net test byte[pressed+eax],1 jz .noreset .activatereset pushad call GUIDoReset popad mov byte[ReturnFromSPCStall],0 jmp continueprog .noreset cmp byte[guioff],1 je near endprog mov eax,[KeyQuickExit] test byte[pressed+eax],1 jnz near endprog jmp StartGUI NEWSYM EndMessage db ' ',13,10,0 NEWSYM endprog call deinitvideo cmp byte[previdmode],3 jne .noendmessage mov byte[EndMessage+13],',' mov eax,[welcome+9] mov [EndMessage+9],eax mov ax,[welcome+7] mov [EndMessage+7],ax mov edx,EndMessage call PrintStr .noendmessage ; mov eax,[opcd] ; mov eax,[numinst] ;Temporary ; mov eax,[NumBRRconv] ; call printnum ; save sram ; change to sram dir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir EXTSYM SDD1Array,SDD1Entry,SDD1Sort call SDD1Sort ; jmp .nodecomppack cmp byte[SDD1Enable],0 jne .yesdecomppack cmp dword[SDD1Entry],0 je .nodecomppack .yesdecomppack mov edx,sdd1fname call Create_File mov bx,ax mov edx,SDD1Array mov ecx,[SDD1Entry] call Write_File call Close_File .nodecomppack cmp byte[sramsavedis],1 je .nosram cmp dword[ramsize],0 je .nosram xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx xor esi,esi xor edi,edi mov edx,fnames+1 call Create_File jc .nosram mov bx,ax xor ecx,ecx mov ecx,[ramsize] mov edx,[sram] call Write_File call Close_File .nosram cmp byte[SFXSRAM],0 je .nosfxsram mov edx,fnames+1 call Create_File jc .nosfxsram mov bx,ax mov ecx,65536 mov edx,[sfxramdata] call Write_File call Close_File .nosfxsram cmp byte[SA1Enable],1 jne .nosa1 mov edx,fnames+1 call Create_File jc .nosa1 mov bx,ax mov ecx,65536*2 mov edx,[SA1RAMArea] call Write_File call Close_File .nosa1 ; change dir to InitDrive/InitDir mov dl,[InitDrive] mov ebx,InitDir call Change_Dir call createnewcfg call GUISaveVars cmp byte[MovieProcessing],0 je .nomovieclose mov bx,[MovieFileHand] mov byte[MovieProcessing],0 call Close_File .nomovieclose ;NEWSYM tempstore, times 1024*1024 db 0 ; mov esi,tempstore ; mov ecx,1024*1024 ;.loop ; mov al,[esi] ; cmp al,0 ; jne .faulty ; inc esi ; dec ecx ; jnz .loop ; xor eax,eax ; jmp .notfaulty ;.faulty ; mov eax,1 ;.notfaulty ; mov eax,[vidbufferofsa] ; call printnum ; mov dl,32 ; mov ah,02h ; call Output_Text ; mov eax,[vidbufferofsb] ; call printnum ; mov dl,32 ; mov ah,02h ; call Output_Text ; mov eax,[romdata] ; call printnum ; change dir to InitDrive/InitDir mov dl,[InitDrive] mov ebx,InitDir call Change_Dir ; Deinit modem if necessary cmp byte[ModemInitStat],0 je .nodeinitmodem call DeInitModem .nodeinitmodem ; cmp byte[OSPort],1 ; jae .nodeinitipx %ifdef __MSDOS__ call deinitipx %endif ;.nodeinitipx jmp OSExit NEWSYM sdd1fname, db 'sdd1dat.dat',0,0 NEWSYM interror stim call deinitvideo mov edx,.nohand ;use extended mov ah,9 ;DOS- API call Output_Text ;to print a string jmp DosExit .nohand db 'Cannot process interrupt handler!',13,10,0 ; global variables NEWSYM invalid, db 0 NEWSYM invopcd, db 0 NEWSYM pressed, times 256+128+64 db 0 ; keyboard pressed keys in scancode NEWSYM exiter, db 0 NEWSYM oldhand9o, dd 0 NEWSYM oldhand9s, dw 0 NEWSYM oldhand8o, dd 0 NEWSYM oldhand8s, dw 0 NEWSYM opcd, dd 0 NEWSYM pdh, dd 0 NEWSYM pcury, dd 0 NEWSYM timercount, dd 0 NEWSYM initaddrl, dd 0 ; initial address location NEWSYM NetSent, dd 0 NEWSYM nextframe, dd 0 ; tick count for timer NEWSYM curfps, db 0 ; frame/sec for current screen NEWSYM SFXSRAM, db 0 NEWSYM newgfxerror, db 'NEED MEMORY FOR GFX ENGINE',0 NEWSYM newgfxerror2, db 'NEED 320x240 FOR NEW GFX 16B',0 ;newgfxerror db 'NEW GFX IN 16BIT IS N/A',0 NEWSYM HIRQCycNext, dd 0 NEWSYM HIRQNextExe, db 0 ;******************************************************* ; Save/Load States ;******************************************************* NEWSYM sramsave mov byte[pressed+1],0 mov byte[pressed+41],0 ; save sram cmp byte[sramsavedis],1 je .nosram cmp word[ramsize],0 je .nosram mov edx,fnames+1 call Create_File jc .nosram mov bx,ax xor ecx,ecx mov cx,[ramsize] mov edx,[sram] call Write_File call Close_File mov dword[Msgptr],.savesrmmsg1 mov eax,[MsgCount] mov [MessageOn],eax jmp reexecute .nosram mov dword[Msgptr],.savesrmmsg2 mov eax,[MsgCount] mov [MessageOn],eax jmp reexecute .savesrmmsg1 db 'SRAM DATA SAVED.',0 .savesrmmsg2 db 'NO SRAM DATA.',0 NEWSYM firstsaveinc, db 0 NEWSYM statesaver clim sub dword[Curtableaddr],tableA sub dword[spcPCRam],spcRam sub dword[spcRamDP],spcRam call PrepareSaveState call unpackfunct ; Auto increment save state slot cmp byte[AutoIncSaveSlot],0 je .donesaveinc cmp byte[firstsaveinc],1 je .clearfirstinc mov eax,[statefileloc] mov dh,[fnamest+eax] cmp dh,'t' je .secondstate cmp dh,'9' je .jumptofirststate inc dh jmp .donextstate .secondstate mov dh,'1' jmp .donextstate .jumptofirststate mov dh,'t' .donextstate mov byte[fnamest+eax],dh xor dh,dh jmp .donesaveinc .clearfirstinc mov byte[firstsaveinc],0 .donesaveinc ; jmp .skipsaves ; Save State %ifdef __LINUX__ mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir %endif mov edx,fnamest+1 call Create_File jc near .nosavestuff ; Save 65816 status, etc. mov bx,ax mov ecx,[PHnum2writecpureg] mov edx,zsmesg call Write_File mov ecx,8 mov edx,cycpbl call Write_File ; Save SNES PPU Register status mov ecx,3019 mov edx,sndrot call Write_File ; Save RAM (WRAM(128k),VRAM(64k),SRAM) ; xor ecx,ecx ; mov cx,[ramsize] mov ecx,65536+65536 mov edx,[wramdata] call Write_File mov ecx,65536 mov edx,[vram] call Write_File cmp byte[spcon],0 je .nospcon ; Save SPC stuff mov ecx,[PHspcsave] mov edx,spcRam call Write_File ; Save DSP stuff mov ecx,[PHdspsave] mov edx,BRRBuffer call Write_File ; Save DSP Mem mov ecx,256 mov edx,DSPMem call Write_File .nospcon cmp byte[C4Enable],1 jne .noc4 mov ecx,2000h mov edx,[C4Ram] call Write_File .noc4 cmp byte[SFXEnable],1 jne .nosfx mov ecx,[SfxCROM] sub [SfxRomBuffer],ecx mov ecx,[SfxRAMMem] sub [SfxLastRamAdr],ecx mov ecx,65536*2 mov edx,[sfxramdata] call Write_File ; uncomment the following mov ecx,[PHnum2writesfxreg] mov edx,SfxR0 call Write_File mov ecx,[SfxCROM] add [SfxRomBuffer],ecx mov ecx,[SfxRAMMem] add [SfxLastRamAdr],ecx .nosfx cmp byte[SPC7110Enable],1 jne .nospc7110 mov edx,[romdata] add edx,510000h mov ecx,65536 call Write_File mov edx,SPCMultA mov ecx,[PHnum2writespc7110reg] call Write_File .nospc7110 cmp byte[SA1Enable],1 jne .nossa1 ; Convert SA-1 stuff to standard, non displacement format call SaveSA1 mov ecx,[PHnum2writesa1reg] mov edx,SA1Mode call Write_File mov ecx,65536*2 mov edx,[SA1RAMArea] call Write_File ; Convert back SA-1 stuff call RestoreSA1 .nossa1 cmp byte[cbitmode],0 je .nocapturepicture cmp byte[NoPictureSave],1 je .nocapturepicture call CapturePicture mov ecx,64*56*2 mov edx,PrevPicture call Write_File .nocapturepicture call Close_File add dword[Curtableaddr],tableA add dword[spcPCRam],spcRam add dword[spcRamDP],spcRam call ResetState stim ; Get the state number mov ebx,[statefileloc] mov cl,[fnamest+ebx] cmp cl,'t' jne .writewhichstate mov cl,'0' .writewhichstate mov [.savemsg+6],cl mov dword[Msgptr],.savemsg mov eax,[MsgCount] mov [MessageOn],eax ret .nosavestuff add dword[Curtableaddr],tableA add dword[spcPCRam],spcRam add dword[spcRamDP],spcRam call ResetState stim mov dword[Msgptr],.savemsgfail mov eax,[MsgCount] mov [MessageOn],eax ret .savemsg db 'STATE - SAVED.',0 .savemsgfail db 'UNABLE TO SAVE.',0 NEWSYM savestate jmp .save mov byte[pressed+1],0 mov byte[pressed+60],0 mov edx,.fname2+1 call Create_File mov esi,[vidbuffer] add esi,16*2+256*2+32*2 mov edi,[vidbuffer] mov dl,[resolutn] mov bx,ax ; move data to a linear address from esi to edi .loopa mov ecx,128 add esi,64+128*4 dec dl jnz .loopa push edx push esi mov ecx,128*4 mov edx,esi call Write_File pop esi pop edx add esi,64+128*4 call Close_File jmp reexecuteb .save mov byte[pressed+1],0 mov eax,[KeySaveState] mov byte[pressed+eax],2 call statesaver jmp reexecuteb .fname2 db 9,'image.dat',0 cycpblblah dd 0,0 ; Load State NEWSYM stateloader mov byte[MovieProcessing],0 mov byte[prevoamptr],0FFh ; Load 65816 status, etc. mov bx,ax mov ecx,[PHnum2writecpureg] add dword[Totalbyteloaded],ecx mov edx,zsmesg call Read_File cmp byte[versn],60 jne near .convert ; Load SPC timers mov ecx,8 add dword[Totalbyteloaded],ecx mov edx,cycpbl call Read_File ; Load SNES PPU Register status mov ecx,3019 ; 3019 add dword[Totalbyteloaded],ecx mov edx,sndrot call Read_File ; Load RAM (WRAM(128k),VRAM(64k),SRAM) mov ecx,65536+65536 add dword[Totalbyteloaded],ecx mov edx,[wramdata] call Read_File mov ecx,65536 add dword[Totalbyteloaded],ecx mov edx,[vram] call Read_File cmp byte[spcon],0 je .nospcon ; Load SPC stuff mov ecx,[PHspcsave] add dword[Totalbyteloaded],ecx mov edx,spcRam call Read_File ; Load DSP stuff mov ecx,[PHdspsave] add dword[Totalbyteloaded],ecx mov edx,BRRBuffer call Read_File ; Load DSP Mem mov ecx,256 add dword[Totalbyteloaded],ecx mov edx,DSPMem call Read_File .nospcon cmp byte[SFXEnable],1 jne near .nosfx mov ecx,65536*2 add dword[Totalbyteloaded],ecx mov edx,[sfxramdata] call Read_File mov ecx,[PHnum2writesfxreg] add dword[Totalbyteloaded],ecx mov edx,SfxR0 call Read_File xor ecx,ecx mov cl,[SfxPBR] mov ecx,[SfxMemTable+ecx*4] mov [SfxCPB],ecx xor ecx,ecx mov cl,[SfxROMBR] mov ecx,[SfxMemTable+ecx*4] mov [SfxCROM],ecx xor ecx,ecx mov cl,[SfxRAMBR] shl ecx,16 add ecx,[sfxramdata] mov dword [SfxRAMMem],ecx mov ecx,[SfxCROM] add [SfxRomBuffer],ecx mov ecx,[SfxRAMMem] add [SfxLastRamAdr],ecx .nosfx cmp byte[C4Enable],1 jne .noc4 mov ecx,2000h add dword[Totalbyteloaded],ecx mov edx,[C4Ram] call Read_File .noc4 cmp byte[SPC7110Enable],1 jne .nospc7110 mov edx,[romdata] add edx,510000h mov ecx,65536 call Read_File mov edx,SPCMultA mov ecx,[PHnum2writespc7110reg] call Read_File .nospc7110 cmp byte[SA1Enable],1 jne .nossa1 mov ecx,[PHnum2writesa1reg] add dword[Totalbyteloaded],ecx mov edx,SA1Mode call Read_File mov ecx,65536*2 add dword[Totalbyteloaded],ecx mov edx,[SA1RAMArea] call Read_File ; Convert back SA-1 stuff push ebx call RestoreSA1 pop ebx call SA1UpdateDPage .nossa1 cmp byte[SDD1Enable],1 jne .nosdd1 call UpdateBanksSDD1 .nosdd1 call Close_File call repackfunct mov byte[spcnumread],0 mov byte[nexthdma],0 ; call headerhack call initpitch ret .convert ; Load SNES PPU Register status mov ecx,3019 mov edx,sndrot call Read_File ; Load RAM (WRAM(128k),VRAM(64k),SRAM) mov dword[cycpbl],0 mov dword[cycpblt],0 mov ah,[cycpbl2] mov [cycpbl],ah mov ah,[cycpblt2] mov [cycpblt],ah mov ecx,[ramsize] add ecx,65536+65536+65536 mov edx,[wramdata] call Read_File cmp byte[spcon],0 je .nospconb ; Load SPC stuff mov ecx,[PHspcsave] mov edx,spcRam call Read_File ; Load DSP stuff mov ecx,32 mov edx,BRRBuffer call Read_File ; Convert old to new data ; read/write 6, jump 2 for 8 times mov edx,BRRPlace0 mov ecx,8 .loopconv push edx push ecx mov ecx,4 call Read_File pop ecx pop edx add edx,8 dec ecx jnz .loopconv ;dspsave equ $-BRRBuffer ;dspconvb equ $-Voice0Freq ; Load DSP stuff mov ecx,[PHdspsave] sub ecx,64+32 sub ecx,8 mov edx,Voice0Freq call Read_File ; Load DSP Mem mov ecx,256 mov edx,DSPMem call Read_File .nospconb call Close_File call repackfunct mov dword[cycpbl],0 mov byte[spcnumread],0 mov byte[nexthdma],0 call headerhack call initpitch ret NEWSYM loadstate mov byte[pressed+1],0 mov eax,[KeyLoadState] mov byte[pressed+eax],2 mov byte[multchange],1 clim %ifdef __LINUX__ mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir %endif ; Get the state number mov ebx,[statefileloc] mov cl,[fnamest+ebx] cmp cl,'t' jne .writewhichstate mov cl,'0' .writewhichstate mov [.loadmsg+6],cl mov [.convmsg+6],cl mov [.nfndmsg+21],cl mov edx,fnamest+1 call Open_File jc near .nofile call stateloader ; Clear Cache Check mov esi,vidmemch2 mov ecx,4096+4096+4096 .next mov byte[esi],1 inc esi dec ecx jnz .next cmp byte[versn],60 jne near .convert mov dword[Msgptr],.loadmsg jmp .noconvert .convert mov dword[Msgptr],.convmsg mov byte[versn],60 mov byte[versn-2],'6' .noconvert mov eax,[MsgCount] mov [MessageOn],eax add dword[Curtableaddr],tableA add dword[spcPCRam],spcRam add dword[spcRamDP],spcRam call ResetState call procexecloop stim jmp reexecuteb .nofile mov dword[Msgptr],.nfndmsg mov eax,[MsgCount] mov [MessageOn],eax stim jmp reexecuteb .loadmsg db 'STATE - LOADED.',0 .convmsg db 'STATE - LOADED/CONVERTED',0 .nfndmsg db 'UNABLE TO LOAD STATE -.',0 NEWSYM loadstate2 mov edx,fnamest+1 NEWSYM loadstate3 call Open_File jc near .nofile mov dword[Totalbyteloaded],0 call stateloader ; Clear Cache Check mov esi,vidmemch2 mov ecx,4096+4096+4096 .next mov byte[esi],1 inc esi dec ecx jnz .next add dword[Curtableaddr],tableA add dword[spcPCRam],spcRam add dword[spcRamDP],spcRam call ResetState call procexecloop ret .nofile ret ;******************************************************* ; Int 08h vector ;******************************************************* ; sets to either 60Hz or 50Hz depending on PAL/NTSC NEWSYM init60hz cmp byte[romispal],0 jne .dopal mov al,00110110b out 43h,al mov ax,19900 ; 65536/(60/((65536*24+175)/(60*60*24))) mov dword[timercount],19900 out 40h,al mov al,ah out 40H,al ret .dopal mov al,00110110b out 43h,al mov ax,23863 ; 65536/(50/((65536*24+175)/(60*60*24))) mov dword[timercount],23863 out 40h,al mov al,ah out 40H,al ret NEWSYM init18_2hz mov al,00110110b out 43H,al mov ax,0 mov dword[timercount],65536 out 40H,al mov al,ah out 40H,al ret NEWSYM Game60hzcall inc word[t1cc] inc byte[nextframe] ret NEWSYM handler8h cli push ds push eax ; mov ax,0 mov ax,[cs:dssel] NEWSYM handler8hseg mov ds,ax call Game60hzcall mov eax,[timercount] sub dword[timeradj],eax jnc .noupd add dword[timeradj],65536 pushf call far [oldhand8o] .noupd mov al,20h out 20h,al pop eax pop ds sti iretd NEWSYM timeradj, dd 65536 NEWSYM t1cc, dw 0 ;******************************************************* ; Int 09h vector ;******************************************************* NEWSYM skipnextkey42, db 0 NEWSYM handler9h cli push ds push eax push ebx mov ax,[cs:dssel] mov ds,ax xor ebx,ebx in al,60H ; get keyboard scan code cmp al,42 jne .no42 cmp byte[skipnextkey42],0 je .no42 mov byte[skipnextkey42],0 jmp .skipkeyrel .no42 cmp al,0E0h jne .noE0 mov byte[skipnextkey42],1 jmp .skipkeyrel .noE0 mov byte[skipnextkey42],0 mov bl,al xor bh,bh test bl,80h ; check if bit 7 is on (key released) jnz .keyrel cmp byte[pressed+ebx],0 jne .skipa mov byte[pressed+ebx],1 ; if not, set key to pressed .skipa jmp .skipkeyrel .keyrel and ebx,7Fh cmp ebx,59 je .skipkeyrel cmp ebx,[KeySaveState] je .skipkeyrel cmp ebx,[KeyLoadState] je .skipkeyrel cmp ebx,[KeyQuickExit] je .skipkeyrel cmp ebx,[KeyQuickLoad] je .skipkeyrel cmp ebx,[KeyQuickRst] je .skipkeyrel cmp bl,1 je .skipkeyrel mov byte[pressed+ebx],0 ; if not, set key to pressed .skipkeyrel mov byte[pressed],0 in al,61h mov ah,al or al,80h out 61h,al mov al,20H ; turn off interrupt mode out 20H,al pop ebx ; Pop registers off pop eax ; stack in correct pop ds sti iretd ALIGN32 NEWSYM soundcycleft, dd 0 NEWSYM curexecstate, dd 0 NEWSYM nmiprevaddrl, dd 0 ; observed address -5 NEWSYM nmiprevaddrh, dd 0 ; observed address +5 NEWSYM nmirept, dd 0 ; NMI repeat check, if 6 then okay NEWSYM nmiprevline, dd 224 ; previous line NEWSYM nmistatus, dd 0 ; 0 = none, 1 = waiting for nmi location, ; 2 = found, disable at next line NEWSYM joycontren, dd 0 ; joystick read control check NEWSYM NextLineCache, db 0 NEWSYM NetQuit, db 0 Donextlinecache: cmp word[curypos],0 je .nocache mov ax,[resolutn] dec ax cmp word[curypos],ax jae .nocache test byte[scrndis],10h jnz .nocache cmp byte[curblank],0h jne .nocache push ecx push ebx push esi push edi xor ecx,ecx mov cl,[curypos] push edx .next mov byte[sprlefttot+ecx],0 mov dword[sprleftpr+ecx*4],0 inc cl jnz .next call processsprites call cachesprites pop edx pop edi pop esi pop ebx pop ecx .nocache mov byte[NextLineCache],0 ret %macro NetHelpExecSend 1 cmp byte[pl1neten+%1],1 jne %%nopl mov eax,[ecx] mov [cnetplaybuf+ebx],al inc ebx and ebx,1FFh mov [cnetplaybuf+ebx],ah inc ebx and ebx,1FFh ror eax,16 mov [cnetplaybuf+ebx],al inc ebx and ebx,1FFh mov [cnetplaybuf+ebx],ah inc ebx and ebx,1FFh ror eax,16 call RemoteSendEAX add ecx,4 %%nopl %endmacro %macro NetHelpExecRecv 1 cmp byte[pl1neten+%1],2 jne %%nopl call RemoteGetEAX mov [ecx],eax %%nopl add ecx,4 %endmacro %macro NetHelpExecRecv2 1 cmp byte[pl1neten+%1],1 jne %%nopl mov al,[cnetplaybuf+ebx] inc ebx and ebx,1FFh mov ah,[cnetplaybuf+ebx] inc ebx and ebx,1FFh ror eax,16 mov al,[cnetplaybuf+ebx] inc ebx and ebx,1FFh mov ah,[cnetplaybuf+ebx] inc ebx and ebx,1FFh ror eax,16 mov [ecx],eax %%nopl add ecx,4 %endmacro ;******************************************************* ; 65816 execution ;******************************************************* SpeedHackSafeTable db 1,0,1,0,0,0,1,0,1,0,1,1,0,0,0,0 db 0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0 db 0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,0 db 0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0 db 0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1 db 0,1,1,1,0,1,1,1,0,1,1,0,0,0,1,0 db 0,1,0,1,0,1,1,1,0,1,1,0,0,1,1,1 db 0,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1 db 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0 db 0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0 db 0,1,0,1,0,1,1,1,1,1,0,0,0,1,1,1 db 0,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1 NEWSYM exitloop2 mov byte[ExecExitOkay],0 NEWSYM exitloop ret cmp byte[nextmenupopup],1 je near .okay cmp byte[ExecExitOkay],0 je near .okay mov byte[pressed+1],0 mov byte[pressed+59],0 mov eax,[KeySaveState] mov byte[pressed+eax],0 mov eax,[KeyLoadState] mov byte[pressed+eax],0 mov eax,[KeyQuickExit] mov byte[pressed+eax],0 mov eax,[KeyQuickLoad] mov byte[pressed+eax],0 mov eax,[KeyQuickRst] mov byte[pressed+eax],0 mov byte[ExecExitOkay],5 mov eax,[KeyQuickSnapShot] mov byte[pressed+eax],0 mov eax,[KeyQuickClock] mov byte[pressed+eax],0 mov eax,[KeyQuickSaveSPC] mov byte[pressed+eax],0 mov byte[SSKeyPressed],0 mov byte[SPCKeyPressed],0 jmp cpuover.returntoloop .okay mov byte[ExecExitOkay],5 ret ALIGN16 %macro FlipCheck 0 cmp byte[FlipWait],0 je %%noflip push edx push eax mov dx,3DAh ;VGA status port in al,dx test al,8 jz %%skipflip push ebx push ecx mov ax,4F07h mov bh,00h mov bl,00h xor cx,cx mov dx,[NextLineStart] mov [LastLineStart],dx int 10h mov byte[FlipWait],0 pop ecx pop ebx %%skipflip pop eax pop edx %%noflip %endmacro NEWSYM execute NEWSYM execloop mov bl,dl test byte[curexecstate],2 jnz .sound mov edi,[tableadb+ebx*4] mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc .cpuover .startagain call dword near [edi+ebx*4] .cpuover jmp cpuover .sound mov edi,[tableadc+ebx*4] sub dword[cycpbl],55 jnc .skipallspc mov eax,[cycpblt] mov bl,[ebp] add dword[cycpbl],eax ; 1260, 10000/12625 inc ebp call dword near [opcjmptab+ebx*4] xor ebx,ebx .skipallspc mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc .cpuovers call dword near [edi+ebx*4] .cpuovers jmp cpuover SECTION .data ALIGN32 NEWSYM ExecExitOkay, db 1 NEWSYM JoyABack, dd 0 NEWSYM JoyBBack, dd 0 NEWSYM JoyCBack, dd 0 NEWSYM JoyDBack, dd 0 NEWSYM JoyEBack, dd 0 NEWSYM NetCommand, dd 0 NEWSYM spc700read, dd 0 NEWSYM lowestspc, dd 0 NEWSYM highestspc, dd 0 NEWSYM SA1UBound, dd 0 NEWSYM SA1LBound, dd 0 NEWSYM SA1SH, dd 0 NEWSYM SA1SHb, dd 0 NEWSYM NumberOfOpcodes2, dd 0 NEWSYM ChangeOps, dd 0 NEWSYM SFXProc, dd 0 SECTION .text %macro C4Paused 0 ; cmp byte[C4Pause],0 ; je %%notpaused ; inc esi ; xor dh,dh ; jmp cpuover ;%%notpaused %endmacro NEWSYM cpuover dec esi cmp byte[HIRQNextExe],0 je .nohirq mov dh,[HIRQCycNext] mov byte[HIRQCycNext],0 jmp .hirq .nohirq cmp byte[SA1Enable],0 je near .nosa1b test byte[exiter],01h jnz near .nosa1 mov byte[cycpl],150 test byte[SA1Control],60h jnz near .nosa1 call SA1Swap cmp byte[CurrentExecSA1],15 ja .nocontinueexec xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain .nocontinueexec ; check for sa-1 speed hacks mov byte[SA1SHb],0 cmp word[IRAM+0A0h],80BFh jne .noshb2 cmp word[IRAM+020h],0 jne .noshb2 mov ecx,[SA1Ptr] ; small speed hack sub ecx,[romdata] cmp ecx,83h jb .skipsh cmp ecx,97h ja .skipsh mov byte[SA1SHb],1 .skipsh .noshb2 mov ecx,[SA1Ptr] ; small speed hack cmp dword[ecx],0FCF04BA5h je .shm cmp dword[ecx-2],0FCF04BA5h jne .skipshm .shm cmp byte[IRAM+4Bh],0 jne .skipshm mov byte[SA1SHb],1 .skipshm cmp dword[ecx],80602EEEh jne .skipshc sub ecx,[romdata] cmp ecx,4E5h jb .skipshc cmp ecx,4E8h ja .skipshc mov byte[SA1SHb],1 mov ecx,[SA1BWPtr] add word[ecx+602Eh],4 .skipshc test word[IRAM+0Ah],8000h jnz .noshb2b test word[IRAM+0Eh],8000h jz .noshb2b mov ecx,[SA1Ptr] ; small speed hack sub ecx,[romdata] cmp ecx,0C93h jb .skipshb cmp ecx,0C9Bh ja .skipshb mov byte[SA1SHb],1 .skipshb cmp ecx,0CB8h jb .skipshb3 cmp ecx,0CC0h ja .skipshb3 mov byte[SA1SHb],1 .skipshb3 .noshb2b sub esi,[wramdata] cmp esi,224h jb .nosh cmp esi,22Eh ja .nosh mov ecx,[wramdata] mov dword[SA1LBound],224h mov dword[SA1UBound],22Eh add dword[SA1LBound],ecx add dword[SA1UBound],ecx mov byte[SA1SH],1 .nosh cmp esi,1F7C6h jb .noshb cmp esi,1F7CCh ja .noshb mov ecx,[wramdata] mov dword[SA1LBound],1F7C6h mov dword[SA1UBound],1F7CCh add dword[SA1LBound],ecx add dword[SA1UBound],ecx mov byte[SA1SH],1 .noshb cmp esi,14h jb .noshc cmp esi,1Ch ja .noshc mov ecx,[wramdata] cmp dword[ecx+14h],0F023002Ch jne .noshc mov dword[SA1LBound],14h mov dword[SA1UBound],1Ch add dword[SA1LBound],ecx add dword[SA1UBound],ecx mov byte[SA1SH],1 .noshc add esi,[wramdata] sub esi,[romdata] cmp esi,0A56h jb .noshbc cmp esi,0A59h ja .noshbc mov ecx,[romdata] mov dword[SA1LBound],0A56h mov dword[SA1UBound],0A59h add dword[SA1LBound],ecx add dword[SA1UBound],ecx mov byte[SA1SH],1 .noshbc xor ecx,ecx add esi,[romdata] xor dh,dh mov byte[cycpl],10 cmp byte[CurrentExecSA1],255 jne .notsa1255 mov byte[cycpl],160 .notsa1255 mov byte[CurrentExecSA1],0 test dl,04h jnz .nosa1 test byte[SA1IRQEnable],80h jz .nosa1 test byte[SA1DoIRQ],4 jz .nosa1 and byte[SA1DoIRQ],0FBh mov al,byte[SA1Message+1] mov byte[SA1Message+3],al or byte[SA1IRQExec],1 ; Start IRQ add dh,10 jmp .virq .nosa1 test byte[SA1IRQEnable],20h jz .nosa1chirq test byte[SA1DoIRQ],8 jz .nosa1chirq ; jmp .nosa1chirq and byte[SA1DoIRQ],0F7h mov al,byte[SA1Message+1] mov byte[SA1Message+3],al or byte[SA1IRQExec],2 ; Start IRQ add dh,10 jmp .virq .nosa1chirq .nosa1b FlipCheck cmp byte[NextLineCache],0 je .nosprcache call Donextlinecache .nosprcache cmp byte[KeyOnStB],0 je .nokeyon mov al,[KeyOnStB] call ProcessKeyOn .nokeyon mov al,[KeyOnStA] mov [KeyOnStB],al mov byte[KeyOnStA],0 test byte[exiter],01h jnz near exitloop2 test byte[SfxSFR],20h jnz near StartSFX .returnfromsfx ; inc dword[numinst] ;Temporary inc word[curypos] add dh,[cycpl] mov ax,[totlines] cmp word[curypos],ax jae near .overy cmp byte[spcon],0 je .nosound call updatetimer .nosound mov ax,[resolutn] inc ax cmp [curypos],ax je near .nmi mov ax,[resolutn] cmp [curypos],ax je near .hdma ; add ax,2 ; cmp [curypos],ax ; je near .hdma .hdmacont cmp byte[curypos],100 jne .noline100 mov ax,[scrnon] mov [TempVidInfo],ax mov ax,[scaddset] mov [TempVidInfo+2],ax .noline100 ; check for VIRQ/HIRQ/NMI ProcessIRQStuff mov ax,[resolutn] dec ax cmp [curypos],ax jb .drawline ; mov ax,[resolutn] ; cmp [curypos],ax ; jb .drawline C4Paused xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain .hdma call exechdma jmp .hdmacont .drawline mov al,[nmiprevline] cmp [curypos],al jb near .noskip cmp byte[nmirept],10 jb near .noskip ; if between correct address, decrease by 2, set nmistatus as 2 ; if not, set nmistatus as 1, increase by 2 cmp byte[curexecstate],0 jne .nn xor dh,dh .nn cmp byte[nmistatus],2 jae near .noskip cmp esi,[nmiprevaddrl] jb .failcheck2 cmp esi,[nmiprevaddrh] ja .failcheck2 cmp byte[nmiprevline],20 jb .nodec sub byte[nmiprevline],10 .nodec xor eax,eax mov al,[esi] cmp byte[disable65816sh],1 je .ohno cmp byte[SpeedHackSafeTable+eax],1 jne .okay .ohno mov byte[nmirept],0 mov dword[nmiprevaddrl],0FFFFFFFFh mov dword[nmiprevaddrh],0 jmp .noskip .okay mov byte[nmistatus],2 and byte[curexecstate],0FEh .nodis65816 jmp .noskip .failcheck2 add byte[nmiprevline],1 mov byte[nmistatus],1 .noskip cmp byte[hdmadelay],0 je .dohdma dec byte[hdmadelay] jmp .nodohdma .dohdma cmp word[curypos],1 jne .nooffby1line test byte[INTEnab],20h jz .nooffby1line cmp word[VIRQLoc],0 je .nodohdma .nooffby1line call exechdma .nodohdma cmp word[curypos],1 jne .nocache call cachevideo .nocache cmp byte[curblank],0 jne .nodrawlineb2 call drawline .nodrawlineb2 cmp byte[curexecstate],2 je near pexecs cmp byte[curexecstate],0 jne .yesexec xor dh,dh .yesexec C4Paused xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain .nmi mov byte[irqon],80h mov byte[doirqnext],0 inc dword[NetSent] cmp byte[yesoutofmemory],1 jne .noout call outofmemfix .noout ; pushad ; call GenLatencyDisplay ; popad ; NetCommand : bit 0 = Okay (should be 1), bit 1 = control update, ; bit 2 = print update, bit 3 = quit, bit 4 = reset dec word[curypos] mov [tempdh],dh xor dh,dh mov byte[doirqnext],0 call exechdma call exechdma ; push es ; cmp byte[cbitmode],1 ; jne .nodisptest ; mov es,[vesa2selec] ; mov word[es:10+640],1111111111111111b ;.nodisptest ; pop es mov byte[NetCommand],0 mov byte[NextNGDisplay],1 cmp byte[newengen],0 je .nonewgfx cmp byte[curblank],0h jne .nonewgfx cmp byte[ForceNewGfxOff],0 jne .nonewgfx ; cmp byte[NextNGDisplay],0 ; je .nonewgfx call StartDrawNewGfx .nonewgfx cmp byte[chaton],1 je near .nonet cmp byte[CNetType],20 je near .net cmp byte[GUIQuit],1 je near endprog mov eax,dword[KeyQuickSnapShot] or eax,eax jz .nosskey test byte[pressed+eax],1 jz .nosskey mov byte[SSKeyPressed],1 mov byte[pressed+eax],2 jmp exitloop .nosskey mov eax,dword[KeyQuickClock] or eax,eax jz .noclockkey test byte[pressed+eax],1 jz .noclockkey xor byte[TimerEnable],1 mov byte[pressed+eax],2 .noclockkey mov eax,dword[KeyQuickSaveSPC] or eax,eax jz .nosavespckey test byte[pressed+eax],1 jz .nosavespckey mov byte[SPCKeyPressed],1 mov byte[pressed+eax],2 jmp exitloop .nosavespckey test byte[pressed+1],01h jnz near exitloop test byte[pressed+59],01h jnz near exitloop cmp byte[nextmenupopup],1 je near exitloop cmp byte[nextmenupopup],2 jb .skipmenupop dec byte[nextmenupopup] .skipmenupop mov eax,[KeySaveState] test byte[pressed+eax],01h jnz near exitloop mov eax,[KeyLoadState] test byte[pressed+eax],01h jnz near exitloop mov eax,[KeyQuickRst] test byte[pressed+eax],01h jnz near exitloop mov eax,[KeyQuickExit] test byte[pressed+eax],01h jnz near exitloop mov eax,[KeyQuickLoad] test byte[pressed+eax],01h jnz near exitloop cmp byte[ExecExitOkay],0 je .returntoloop dec byte[ExecExitOkay] .returntoloop jmp .nonet .net test byte[pressed+1],01h jz .nonetexit or byte[NetCommand],08h .nonetexit mov eax,[KeySaveState] test byte[pressed+eax],01h jz .notnetsave mov byte[pressed+eax],2 call NetSaveState .notnetsave mov eax,[KeyLoadState] test byte[pressed+eax],01h jz .notnetload or byte[NetCommand],88h .notnetload .nonet mov dh,[tempdh] inc word[curypos] cmp byte[CurRecv],1 je .noinputread cmp byte[NoInputRead],1 je .noinputread call ReadInputDevice .noinputread call UpdateRewind mov byte[NetQuit],0 cmp byte[CNetType],20 jne near .nozerons test byte[NetSwap],1 jnz near .noonens cmp byte[CurRecv],1 je near .noreceiveb2 mov eax,[JoyAOrig] cmp eax,[prevp1net] je .nochange1 or byte[NetCommand],02h mov [prevp1net],eax .nochange1 mov eax,[JoyBOrig] cmp eax,[prevp2net] je .nochange2 or byte[NetCommand],02h mov [prevp2net],eax .nochange2 mov eax,[JoyCOrig] cmp eax,[prevp3net] je .nochange3 or byte[NetCommand],02h mov [prevp3net],eax .nochange3 mov eax,[JoyDOrig] cmp eax,[prevp4net] je .nochange4 or byte[NetCommand],02h mov [prevp4net],eax .nochange4 test byte[NetCommand],02h jz .nochangeatall mov dword[ResendTimer],60 jmp .yeschanged .nochangeatall dec dword[ResendTimer] jnz .yeschanged or byte[NetCommand],02h mov dword[ResendTimer],60 .yeschanged ; Send command & store command call PreparePacket push ebx push ecx mov al,[NetCommand] mov ebx,[cnetptrhead] mov [cnetplaybuf+ebx],al call RemoteSendChar ; ################## ; Send latency value ;cmp byte[OSPort],3 ;jne .nolatencysend %ifndef __MSDOS__ cmp byte[BackState],1 jne .nolatencysend mov ebx,[LatencySendPtr] and ebx,0FFh inc dword[LatencySendPtr] mov byte[LatencyV+ebx],0 mov ebx,[PBackupPos] mov al,[LocalLValue] ; inc al call RemoteSendChar %endif .nolatencysend mov ebx,[cnetptrhead] mov ecx,JoyAOrig inc ebx and ebx,1FFh test byte[NetCommand],02h jz near .nosendextra NetHelpExecSend 0 NetHelpExecSend 1 NetHelpExecSend 2 NetHelpExecSend 3 NetHelpExecSend 4 .nosendextra mov [cnetptrhead],ebx call SendPacketUDP cmp byte[chaton],0 jne .nosendchats cmp byte[chatstrL],0 je .nosendchats cmp dword[chatTL],0 jne .nosendchats mov byte[NetCommand],04h .nosendchats ; send chat string test byte[NetCommand],04h jz near .nosendchatsend call PreparePacket mov al,04h call RemoteSendChar call MoveStringChat push esi mov esi,chatstrR ;cmp byte[OSPort],2 ;jae .notwin32b %ifdef __MSDOS__ mov byte[esi],'L' mov byte[esi+1],'>' add esi,2 %else ;jmp .skipsendnick ;.notwin32b cmp dword[chatstrL+1],'/ME ' jne .noaction mov al,'*' push ebx push eax mov [esi],al inc esi call RemoteSendChar pop eax pop ebx .noaction mov ebx,ChatNick .nextchatc2 mov al,[ebx] cmp al,0 je .nonextchat push ebx push eax mov [esi],al inc esi call RemoteSendChar pop eax pop ebx inc ebx cmp byte[ebx-1],0 jne .nextchatc2 .nonextchat mov al,'>' cmp dword[chatstrL+1],'/ME ' jne .noaction2 mov al,' ' .noaction2 push ebx push eax mov [esi],al inc esi call RemoteSendChar pop eax pop ebx %endif .skipsendnick mov ebx,chatstrL+1 ;cmp byte[OSPort],2 ;jb .noaction3 %ifndef __MSDOS__ cmp dword[chatstrL+1],'/ME ' jne .noaction3 mov ebx,chatstrL+5 %endif .noaction3 .nextchatc mov al,[ebx] push ebx push eax mov [esi],al inc esi call RemoteSendChar pop eax pop ebx inc ebx cmp byte[ebx-1],0 jne .nextchatc mov byte[esi],0 pop esi mov ecx,45 mov ebx,chatstrL .chatsendloop mov al,[ebx+1] mov [ebx],al inc ebx dec ecx jnz .chatsendloop mov byte[chatstrL],0 mov dword[chatTL],10 mov dword[chatRTL],8*60 call SplitStringChat call SendPacket .nosendchatsend pop ecx pop ebx jmp .noreceiveb3 .noreceiveb2 .noreceiveb3 mov dword[JoyAOrig],0 mov dword[JoyBOrig],0 mov dword[JoyCOrig],0 mov dword[JoyDOrig],0 mov dword[JoyEOrig],0 cmp byte[LatencyLeft],0 jne near .latencyleft mov [tempedx],edx push ecx push ebx ; cmp byte[OSPort],3 ; jne .nobackstate %ifndef __MSDOS__ cmp byte[BackState],1 jne .nobackstate call BackupCVFrame .nobackupcvframe mov ebx,[CBackupPos] inc ebx and ebx,0Fh mov [CBackupPos],ebx %endif .nobackstate pop ebx pop ecx push ebx push ecx cmp dword[CurRecv],1 je .yesreceive2 xor ebx,ebx .latencyloop add dword[LatencyV+ebx*4],01010101h inc ebx cmp ebx,64 jne .latencyloop .yesreceive2 cmp dword[CurRecv],1 jne near .notreceive mov ebx,[PPValue] inc ebx and ebx,0Fh mov [PPValue],ebx cmp ebx,[DPValue] jne near .notreceive mov dword[CurRecv],0 call VoiceEndMute cmp byte[t1cc],4 jbe .noframesskippedb mov byte[t1cc],4 .noframesskippedb jmp .received .notreceive .received pop ecx pop ebx ; Receive command from net and process push ebx push ecx cmp byte[CurRecv],1 je near .nocrupdate3b xor bl,bl mov cx,[t1cc] add cx,60*15 .notfoundchar .onlychatchar call RemoteGetChar ; cmp [t1cc],cx ; jne .notor jmp .notor .netquit2 or byte[NetQuit],80h mov byte[RemoteDisconnect],1 jmp .skipallnet .notor cmp dh,0 jne .foundchar ;cmp byte[OSPort],3 ;jne .notwin32 %ifndef __MSDOS__ push ebx cmp byte[BackState],1 jne .nobackstate2 mov ebx,[CBackupPos] dec ebx sub ebx,[PBackupPos] sub ebx,[BackStateSize] and ebx,0Fh ; inc ebx ; and ebx,0Fh ; cmp ebx,[PBackupPos] jne near .nocrupdate3 ; ************************* .nobackstate2 pop ebx ;NEWSYM StateBackup, dd 0 ;NEWSYM CBackupPos, dd 0 ;NEWSYM PBackupPos, dd 0 ;NEWSYM PPValue, dd 0 ; Previous PValue ;NEWSYM DPValue, dd 0 ; Destination PValue ;NEWSYM CurRecv, dd 0 ; Set to 1 if Recovery mode is on ; if CurRecv=1, then do not send tcp/ip data, always frame skip, do not ; draw to screen, do not key on, restore previous local key presses, ; when disabling key ons, divert dspmem write/read to a different ; array temporarly, then re-copy back in when finished ;NEWSYM PPContrl, times 16 dd 0 ; Previous Controller 1 Data ;NEWSYM PPContrl2, times 16 dd 0 ; Previous Controller 2 Data ;NEWSYM PPContrl3, times 16 dd 0 ; Previous Controller 3 Data ;NEWSYM PPContrl4, times 16 dd 0 ; Previous Controller 4 Data ;NEWSYM PPContrl5, times 16 dd 0 ; Previous Controller 5 Data pushad mov byte[nojoystickpoll],1 call JoyRead mov byte[nojoystickpoll],0 ; call ChatType2 popad cmp word[t1cc],4*60 jb .notwin32 cmp byte[pressed+1],1 je .netquit2 %endif .notwin32 mov bl,1 jmp .notfoundchar .foundchar cmp dl,04h jne .notchatchar jmp .recvchats .notchatchar cmp byte[t1cc],4 jbe .noframesskipped mov byte[t1cc],4 .noframesskipped inc byte[netdelayed] cmp bl,0 jne .yesdelay mov byte[netdelayed],0 .yesdelay cmp byte[netdelayed],10 jne .nodelayfix mov byte[netdelayed],0 cmp byte[t1cc],0 je .nodelayfix dec byte[t1cc] .nodelayfix mov [NetCommand],dl pushad ; Receive latency value ; ##################### ;cmp byte[OSPort],3 ;jne near .nolatencyrecv2 %ifndef __MSDOS__ cmp byte[BackState],1 jne near .nolatencyrecv2 .tryagainlatency call RemoteGetChar ; ********** cmp byte[RemoteDisconnect],1 je near .netquit cmp dh,0 je .tryagainlatency mov ebx,[LatencyRecvPtr] and ebx,0FFh inc dword[LatencyRecvPtr] mov al,[LatencyV+ebx] mov [RemoteLValue],dl mov [LocalLValue],al cmp al,dl jbe .nolatencyrecv3 ; incr t1cc -> make local speed faster if local latency > remote inc dword[latencytimer] cmp dword[latencytimer],5 jb .nolatencyrecv2 mov dword[latencytimer],0 cmp byte[t1cc],0 je .nolatencyrecv2 dec byte[t1cc] jmp .nolatencyrecv2 .nolatencyrecv3 cmp al,dl je .nolatencyrecv2 inc dword[latencytimer] cmp dword[latencytimer],5 jb .nolatencyrecv2 mov dword[latencytimer],0 inc byte[t1cc] %endif .nolatencyrecv2 popad inc dword[NetSent2] test dl,01h jnz near .netfailed test dl,070h jnz near .netfailed cmp dword[NetQuitter],0 je .noforcequit mov ebx,[PBackupPos] inc ebx and ebx,0Fh cmp ebx,[QBackupPos] je .forcequit .noforcequit test dl,08h jz .noquit .forcequit test dl,80h jz .noloadstate mov byte[NetLoadState],1 .noloadstate or byte[NetQuit],1 cmp byte[BackState],1 jne .noquit push edx mov ebx,[PBackupPos] inc ebx and ebx,0Fh cmp ebx,[CBackupPos] je .noquit2 call RestoreCVFrame add dword[NetSent],1000 .noquit2 pop edx .noquit test dl,02h jz near .nocrupdate2 ; cmp byte[OSPort],3 ; jne .notwin32d %ifndef __MSDOS__ cmp byte[BackState],1 jne .notwin32d push edx mov ebx,[PBackupPos] inc ebx and ebx,0Fh cmp ebx,[CBackupPos] je .noupdate call RestoreCVFrame mov ebx,[PBackupPos] ; ***************** inc ebx and ebx,0Fh mov [PPValue],ebx mov ebx,[CBackupPos] mov [DPValue],ebx mov ebx,[PPValue] mov [CBackupPos],ebx mov dword[CurRecv],1 ; ***************** call VoiceStartMute .noupdate mov ebx,[PBackupPos] inc ebx and ebx,0Fh mov [PBackupPos],ebx pop edx %endif .notwin32d mov ecx,JoyAOrig NetHelpExecRecv 0 NetHelpExecRecv 1 NetHelpExecRecv 2 NetHelpExecRecv 3 NetHelpExecRecv 4 jmp .donecrupdate .nocrupdate3 pop ebx .nocrupdate3b mov byte[NetCommand],0 jmp .nocrupdate .nocrupdate2 mov ebx,[PBackupPos] inc ebx and ebx,0Fh mov [PBackupPos],ebx .nocrupdate cmp byte[pl1neten],2 jne .nopl1recv mov eax,[JoyABack] mov [JoyAOrig],eax .nopl1recv cmp byte[pl2neten],2 jne .nopl2recv mov eax,[JoyBBack] mov [JoyBOrig],eax .nopl2recv cmp byte[pl3neten],2 jne .nopl3recv mov eax,[JoyCBack] mov [JoyCOrig],eax .nopl3recv cmp byte[pl4neten],2 jne .nopl4recv mov eax,[JoyDBack] mov [JoyDOrig],eax .nopl4recv cmp byte[pl5neten],2 jne .nopl5recv mov eax,[JoyEBack] mov [JoyEOrig],eax .nopl5recv .donecrupdate jmp .norecvchats .recvchats push ebx call MoveStringChat mov ebx,chatstrR push edx .nextchatcr push ebx push ecx mov cx,[t1cc] add cx,60*10 .tryagainchatc call RemoteGetChar ; ********** cmp byte[RemoteDisconnect],1 je .netquit cmp [t1cc],cx jne .noto .netquit or byte[NetQuit],80h mov dh,1 .noto cmp dh,0 je .tryagainchatc ; ********* pop ecx pop ebx mov [ebx],dl inc ebx cmp dl,0 jne .nextchatcr ; ********* pop edx pushad ;cmp byte[OSPort],2 ;jae .notwin32e %ifdef __MSDOS__ mov dl,'R' call NetAddChar mov dl,'>' call NetAddChar %endif .notwin32e mov esi,chatstrR call WritetochatBuffer mov dl,13 call NetAddChar mov dl,10 call NetAddChar popad mov dword[chatRTL],60*8 call SplitStringChat pop ebx jmp .onlychatchar .norecvchats jmp .skipfailed .netfailed or byte[NetQuit],80h .skipfailed cmp byte[CurRecv],1 je near .noreceiveb ; Process previous command from buffer mov ebx,[cnetptrtail] mov ecx,JoyAOrig mov dl,[cnetplaybuf+ebx] inc ebx and ebx,1FFh test dl,08h jz .noquit2b push ebx mov ebx,[PBackupPos] cmp ebx,[CBackupPos] je .yesquit cmp dword[NetQuitter],1 je .quitlater test dl,80h jz .noloadstateb mov byte[NetLoadState],2 .noloadstateb mov dword[NetQuitter],1 mov ebx,[CBackupPos] mov [QBackupPos],ebx jmp .quitlater .yesquit test dl,80h jz .noloadstateb2 mov byte[NetLoadState],2 .noloadstateb2 or byte[NetQuit],1 .quitlater pop ebx ;NEWSYM NetQuitter, dd 0 ;NEWSYM QBackupPos, dd 0 .noquit2b test dl,02h jz near .nocrupdate2b NetHelpExecRecv2 0 NetHelpExecRecv2 1 NetHelpExecRecv2 2 NetHelpExecRecv2 3 NetHelpExecRecv2 4 jmp .donecrupdate2 .nocrupdate2b cmp byte[pl1neten],1 jne .nopl1recv2 mov eax,[JoyABack] mov [JoyAOrig],eax .nopl1recv2 cmp byte[pl2neten],1 jne .nopl2recv2 mov eax,[JoyBBack] mov [JoyBOrig],eax .nopl2recv2 cmp byte[pl3neten],1 jne .nopl3recv2 mov eax,[JoyCBack] mov [JoyCOrig],eax .nopl3recv2 cmp byte[pl4neten],1 jne .nopl4recv2 mov eax,[JoyDBack] mov [JoyDOrig],eax .nopl4recv2 cmp byte[pl5neten],1 jne .nopl5recv2 mov eax,[JoyEBack] mov [JoyEOrig],eax .nopl5recv2 .donecrupdate2 mov [cnetptrtail],ebx .noreceiveb ; backup keyboard presses if recv=1 (delayed by 1 frame) ; else restore ; Restore previous keys if CurRecv = 1 ; ************************************ cmp byte[CurRecv],1 je near .noreceive ; backup keypresses mov ebx,[CBackupPos] dec ebx and ebx,0Fh mov ecx,[JoyAOrig] mov [PPContrl+ebx*4],ecx mov ecx,[JoyBOrig] mov [PPContrl2+ebx*4],ecx mov ecx,[JoyCOrig] mov [PPContrl3+ebx*4],ecx mov ecx,[JoyDOrig] mov [PPContrl4+ebx*4],ecx mov ecx,[JoyEBack] mov [PPContrl4+ebx*4],ecx jmp .yesreceive .noreceive mov ebx,[PPValue] dec ebx and ebx,0Fh cmp byte[pl1neten],1 jne .nopl1recv3 mov ecx,[PPContrl+ebx*4] mov [JoyAOrig],ecx .nopl1recv3 cmp byte[pl2neten],1 jne .nopl2recv3 mov ecx,[PPContrl2+ebx*4] mov [JoyBOrig],ecx .nopl2recv3 cmp byte[pl3neten],1 jne .nopl3recv3 mov ecx,[PPContrl3+ebx*4] mov [JoyCOrig],ecx .nopl3recv3 cmp byte[pl4neten],1 jne .nopl4recv3 mov ecx,[PPContrl4+ebx*4] mov [JoyDOrig],ecx .nopl4recv3 cmp byte[pl5neten],1 jne .nopl5recv3 mov ecx,[PPContrl5+ebx*4] mov [JoyEOrig],ecx .nopl5recv3 .yesreceive .skipallnet pop ecx pop ebx mov edx,[tempedx] xor ebx,ebx jmp .donelatency .latencyleft dec byte[LatencyLeft] .donelatency mov eax,[JoyAOrig] mov [JoyABack],eax mov eax,[JoyBOrig] mov [JoyBBack],eax mov eax,[JoyCOrig] mov [JoyCBack],eax mov eax,[JoyDOrig] mov [JoyDBack],eax mov eax,[JoyEOrig] mov [JoyEBack],eax jmp .reprocjoy .noonens test byte[NetSwap],1 jz .nozerons ; copy previous frame values into JoyxOrig and JoyxNow mov eax,[JoyABack] mov [JoyAOrig],eax mov eax,[JoyBBack] mov [JoyBOrig],eax mov eax,[JoyCBack] mov [JoyCOrig],eax mov eax,[JoyDBack] mov [JoyDOrig],eax mov eax,[JoyEBack] mov [JoyEOrig],eax .reprocjoy mov eax,[JoyAOrig] rol eax,16 mov [JoyANow],eax mov eax,[JoyBOrig] rol eax,16 mov [JoyBNow],eax mov eax,[JoyCOrig] rol eax,16 mov [JoyCNow],eax mov eax,[JoyDOrig] mov [JoyDNow],eax mov eax,[JoyEOrig] mov [JoyENow],eax .nozerons cmp byte[snesmouse],4 jne .nolethalen mov eax,[LethEnData] mov [JoyBNow],eax .nolethalen xor byte[NetSwap],1 cmp byte[NetQuit],0 je .noquitb pushad mov esi,[wramdata] mov ecx,65536*2 xor eax,eax xor ebx,ebx .quitloop mov al,[esi] add bx,ax inc esi dec ecx jnz .quitloop mov [valuea],bx popad add [valuea],dh mov byte[ExecExitOkay],0 mov byte[pressed+1],01h jmp exitloop .noquitb cmp byte[MovieProcessing],0 je .noprocmovie call ProcessMovies .noprocmovie test byte[INTEnab],1 jz .noresetjoy mov eax,[JoyAOrig] rol eax,16 mov [JoyANow],eax mov eax,[JoyBOrig] rol eax,16 mov [JoyBNow],eax mov eax,[JoyCOrig] rol eax,16 mov [JoyCNow],eax mov eax,[JoyDOrig] mov [JoyDNow],eax mov eax,[JoyEOrig] mov [JoyENow],eax mov byte[JoyCRead],0 .noresetjoy mov byte[MultiTapStat],80h cmp byte[C4Enable],0 je .noC4 call C4VBlank .noC4 ; mov byte[hdmastartsc],0 mov byte[joycontren],0 test byte[curexecstate],01h jnz .dis65816 or byte[curexecstate],01h ; call changeexecloop .dis65816 cmp byte[CheatOn],1 je near .cheater .returncheat mov ax,[VIRQLoc] cmp word[curypos],ax jne .novirqz test byte[INTEnab],80h jz .novirqz inc word[VIRQLoc] .novirqz mov ax,[oamaddrs] mov [oamaddr],ax mov byte[nosprincr],0 call showvideo ; call dsp1teststuff xor ebx,ebx mov byte[NMIEnab],81h test byte[INTEnab],80h jz near .nonmi ; cmp byte[intrset],1 ; je near .nonmi .nmiokay mov byte[curnmi],1 cmp byte[intrset],1 jne .nointrset mov byte[intrset],2 .nointrset cmp byte[nmistatus],1 jne .notnonmifound mov byte[nmirept],0 .notnonmifound mov byte[nmistatus],0 cmp byte[nmirept],0 jne .nocheck mov al,[resolutn] sub al,2 mov [nmiprevline],al mov dword[nmiprevaddrl],0FFFFFFFFh mov dword[nmiprevaddrh],0 mov byte[nmirept],1 mov byte[doirqnext],0 C4Paused jmp switchtonmi .nocheck cmp byte[nmirept],10 je .nextcheck cmp esi,[nmiprevaddrl] jae .notlower mov [nmiprevaddrl],esi .notlower cmp esi,[nmiprevaddrh] jbe .notgreater mov [nmiprevaddrh],esi .notgreater inc byte[nmirept] C4Paused jmp switchtonmi .nextcheck mov eax,[nmiprevaddrh] sub eax,[nmiprevaddrl] cmp eax,10 ja .failcheck cmp esi,[nmiprevaddrl] jb .failcheck cmp esi,[nmiprevaddrh] ja .failcheck mov byte[doirqnext],0 C4Paused jmp switchtonmi .failcheck mov byte[nmirept],0 mov dword[nmiprevaddrl],0FFFFFFFFh mov dword[nmiprevaddrh],0 mov byte[doirqnext],0 C4Paused jmp switchtonmi .nonmi cmp byte[intrset],1 jne .nointrset2w mov byte[intrset],2 .nointrset2w cmp byte[esi],0CBh jne .nowai jmp .nowai test dl,04h jz .nowai or byte[INTEnab],80h .nowai C4Paused xor ebx,ebx xor ecx,ecx mov bl,[esi] inc esi jmp execloop.startagain .overy cmp byte[smallscreenon],1 je .nocfield cmp byte[ScreenScale],1 je .nocfield cmp byte[scanlines],0 jne .nocfield xor byte[cfield],1 .nocfield mov word[curypos],0 cmp dword[numspcvblleft],0 je near .novblch cmp [lowestspc],ebp ja .failspc cmp [highestspc],ebp jb .failspc jmp .okayspc .failspc mov eax,ebp sub eax,10 mov [lowestspc],eax add eax,20 mov [highestspc],eax mov dword[spc700idle],0 .okayspc cmp dword[SPC700write],0 jne .notwritespc cmp dword[spc700read],0 je .notwritespc cmp dword[SPC700read],1500 jb .notwritespc inc dword[spc700idle] cmp dword[spc700idle],30 jne .noidleend call idledetectspc cmp byte[ReturnFromSPCStall],1 jne .noidleend mov byte[ExecExitOkay],0 jmp exitloop .noidleend jmp .notidle .notwritespc mov dword[spc700idle],0 .notidle dec dword[numspcvblleft] mov dword[SPC700write],0 mov dword[SPC700read],0 mov dword[spc700read],0 .novblch mov byte[NMIEnab],01h ; call cachevideo call starthdma ; cmp byte[Offby1line],1 ; je .noirqhack ; cmp byte[IRQHack],0 ; je .noirqhack ; call exechdma .noirqhack ; check for VIRQ/HIRQ/NMI cmp byte[execatzerovirq],1 je near .noexecatzero ProcessIRQStuff .noexecatzero C4Paused xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain .virq C4Paused test byte[INTEnab],10h jz .skiphirq cmp word[HIRQLoc],0 je .skiphirq jmp .skiphirq cmp word[HIRQLoc],339 jbe .hirqnotover mov word[HIRQLoc],339 .hirqnotover ; first dh = HIRQLoc*DHAdd/340, second dh = DHAdd-first dh push edx mov ax,[HIRQLoc] xor ecx,ecx mov cl,[cycpl] mul cx mov cx,340 div cx pop edx mov dh,al mov cl,[cycpl] sub cl,al xor cl,cl mov [HIRQCycNext],cl mov byte[HIRQNextExe],1 ; jmp .hirq jmp .returnfromhirq .skiphirq test byte[curexecstate],01h jnz .dis658162 or byte[curexecstate],01h ; call changeexecloop .dis658162 mov byte[doirqnext],0 xor ebx,ebx mov ax,[resolutn] cmp word[curypos],ax jnb .nodrawline cmp byte[hdmadelay],0 je .dohdma2 dec byte[hdmadelay] jmp .nodohdma2 .dohdma2 call exechdma .nodohdma2 cmp word[curypos],1 jne .nocache2 call cachevideo .nocache2 cmp byte[curblank],0 jne .nodrawline call drawline .nodrawline cmp byte[intrset],1 jne .nointrset2 mov byte[intrset],2 .nointrset2 ; sub dh,8 jmp switchtovirq .hirq C4Paused mov byte[HIRQNextExe],0 test byte[INTEnab],10h jz .hirqnotokay test byte[curexecstate],01h jnz .dis658162h or byte[curexecstate],01h .dis658162h mov byte[doirqnext],0 cmp byte[intrset],1 jne .nointrset2h mov byte[intrset],2 .nointrset2h test dl,04h jnz .irqd jmp switchtovirq .irqd mov byte[doirqnext],1 .hirqnotokay jmp .nodrawlineh .returnfromhirq mov ax,[resolutn] cmp word[curypos],ax jnb .nodrawlineh cmp byte[hdmadelay],0 je .dohdma2h dec byte[hdmadelay] jmp .nodohdma2h .dohdma2h call exechdma .nodohdma2h cmp word[curypos],1 jne .nocache2h call cachevideo .nocache2h cmp byte[curblank],0 jne .nodrawlineh call drawline .nodrawlineh xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain .cheater push eax push ebx push ecx push edx mov al,[NumCheats] mov byte[.numcheat],al xor edx,edx .anothercheat xor ebx,ebx xor ecx,ecx test byte[cheatdata+edx],5 jnz .nonormcheat test byte[cheatdata+edx-28],80h jnz .nonormcheat test byte[cheatdata+edx],80h jnz .cheatcodereflect mov al,[cheatdata+edx+1] mov cx,[cheatdata+edx+2] mov bl,[cheatdata+edx+4] push edx call dword near [memtablew8+ebx*4] pop edx jmp .nonormcheat .cheatcodereflect cmp byte[.numcheat],1 je .nonormcheat mov cx,[cheatdata+edx+2+28] mov bl,[cheatdata+edx+4+28] push edx call dword near [memtabler8+ebx*4] pop edx mov cx,[cheatdata+edx+2] mov bl,[cheatdata+edx+4] push edx call dword near [memtablew8+ebx*4] pop edx add edx,28 dec byte[.numcheat] .nonormcheat add edx,28 dec byte[.numcheat] jnz near .anothercheat pop edx pop ecx pop ebx pop eax jmp .returncheat .numcheat db 0 ALIGN16 NEWSYM pexecs mov byte[soundcycleft],30 .sloop mov bl,[ebp] ; 1260, 10000/12625 inc ebp call dword near [opcjmptab+ebx*4] xor ebx,ebx dec byte[soundcycleft] jnz .sloop xor dh,dh xor ebx,ebx mov bl,[esi] inc esi jmp execloop.startagain NEWSYM pexecs2 .sloop mov bl,[ebp] ; 1260, 10000/12625 inc ebp call dword near [opcjmptab+ebx*4] xor ebx,ebx dec dword[soundcycleft] jnz .sloop ret NEWSYM UpdatePORSCMR push ebx push eax test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov [sfxclineloc],eax mov al,[SfxSCMR] and eax,00000011b mov bl,[SfxPOR] and bl,0Fh shl bl,2 or al,bl mov ebx,[PLOTJmpb+eax*4] mov eax,[PLOTJmpa+eax*4] mov dword [FxTable+4Ch*4],eax mov dword [FxTableb+4Ch*4],eax mov dword [FxTablec+4Ch*4],eax mov dword [FxTabled+4Ch*4],ebx pop eax pop ebx ret NEWSYM UpdateSCBRCOLR push eax push ebx mov ebx,[SfxSCBR] shl ebx,10 add ebx,[sfxramdata] mov [SCBRrel],ebx mov eax,[SfxCOLR] mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx pop ebx pop eax ret NEWSYM UpdateCLSR mov dword [NumberOfOpcodes2],350 ; 0FFFFFFFh;350 test byte[SfxCLSR],01h jz .nohighsfx mov dword [NumberOfOpcodes2],700 ;700 .nohighsfx cmp byte[SFXCounter],1 je .noyi mov dword [NumberOfOpcodes2],0FFFFFFFh .noyi ret NEWSYM UpdateSFX call UpdatePORSCMR call UpdatePORSCMR call UpdateCLSR ret NEWSYM StartSFX push edx push esi push edi push ebp xor ebx,ebx mov bl,[SfxPBR] mov al,[SfxSCMR] and bl,7Fh cmp bl,70h jae .ram test al,10h jz .noaccess jmp .noram .ram test al,08h jz .noaccess .noram mov eax,[NumberOfOpcodes2] mov [NumberOfOpcodes],eax call MainLoop .noaccess pop ebp pop edi pop esi pop edx xor ebx,ebx xor ecx,ecx jmp cpuover.returnfromsfx NEWSYM StartSFXdebug push edx push esi push edi push ebx mov bl,[SfxPBR] mov al,[SfxSCMR] and bl,7Fh cmp bl,70h jae .ram test al,10h jz .noaccess jmp .noram .ram test al,08h jz .noaccess .noram mov dword [NumberOfOpcodes],350 ; 0FFFFFFFh;350 test byte[SfxCLSR],01h jz .nohighsfx mov dword [NumberOfOpcodes],700 ;700 .nohighsfx cmp byte[SFXCounter],1 jne .noyi mov dword [NumberOfOpcodes],0FFFFFFFFh .noyi ; call SFXDebugLoop .noaccess pop ebx pop edi pop esi pop edx xor ecx,ecx jmp execsingle.returnfromsfx NEWSYM StartSFXdebugb push edx push esi push edi push ebp push ebx test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines .lines160 mov eax,[sfx160lineloc] jmp .donelines .lines192 mov eax,[sfx192lineloc] jmp .donelines .objmode mov eax,[sfxobjlineloc] .donelines mov [sfxclineloc],eax mov al,[SfxSCMR] and eax,00000011b mov bl,[SfxPOR] and bl,0Fh shl bl,2 or al,bl mov ebx,[PLOTJmpb+eax*4] mov eax,[PLOTJmpa+eax*4] mov dword [FxTable+4Ch*4],eax mov dword [FxTableb+4Ch*4],eax mov dword [FxTablec+4Ch*4],eax mov dword [FxTabled+4Ch*4],ebx mov ebx,[SfxSCBR] shl ebx,10 add ebx,[sfxramdata] mov [SCBRrel],ebx mov eax,[SfxCOLR] mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx xor ebx,ebx mov bl,[SfxPBR] mov al,[SfxSCMR] and bl,7Fh cmp bl,70h jae .ram test al,10h jz .noaccess jmp .noram .ram test al,08h jz .noaccess .noram mov dword [NumberOfOpcodes],400 ;678 test byte[SfxCLSR],01h jz .nohighsfx mov dword [NumberOfOpcodes],800 ;678*2 .nohighsfx cmp byte[SFXCounter],1 jne .noyi mov dword [NumberOfOpcodes],0FFFFFFFh .noyi call MainLoop .noaccess pop ebx pop ebp pop edi pop esi pop edx xor ecx,ecx jmp execsingle.returnfromsfx NEWSYM StartSFXret test byte[SfxSFR],20h jz .endfx pushad mov bl,[SfxPBR] mov al,[SfxSCMR] and bl,7Fh cmp bl,70h jae .ram test al,10h jz .noaccess jmp .noram .ram test al,08h jz .noaccess .noram mov dword [NumberOfOpcodes],400 ;678 test byte[SfxCLSR],01h jz .nohighsfx mov dword [NumberOfOpcodes],800 ;678*2 .nohighsfx mov dword [NumberOfOpcodes],0FFFFFFFFh call MainLoop .noaccess popad .endfx ret ;******************************************************* ; Execute a Single 65816 instruction (debugging purpose) ;******************************************************* NEWSYM execloopdeb jmp exitloop2 NEWSYM execsingle xor ebx,ebx test byte[curexecstate],2 jz .nosoundb sub dword[cycpbl],55 jnc .skipallspc mov eax,[cycpblt] mov bl,[ebp] add dword[cycpbl],eax ; 1260, 10000/12625 inc ebp call dword near [opcjmptab+ebx*4] xor ebx,ebx .skipallspc .nosoundb mov bl,dl mov byte[exiter],01h mov edi,[tablead+ebx*4] mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc .cpuover mov [pdh],dh xor dh,dh jmp dword near [edi+ebx*4] .cpuover ; cmp byte[SA1Enable],0 ; je .nosa1 ; test byte[SA1Control],60h ; jnz .nosa1 ; dec esi ; call SA1Swap ; mov bl,[esi] ; inc esi ; cmp byte[SA1Status],0 ; je near .nosa1 ; mov [pdh],dh ; xor dh,dh ; jmp cpuover ;.nosa1 cmp byte[SA1Enable],0 je near .nosa1 mov byte[cycpl],150 test byte[SA1Control],60h jnz near .nosa1 dec esi call SA1Swap mov bl,[esi] inc esi mov [pdh],dh xor dh,dh cmp byte[CurrentExecSA1],17 jb near cpuover mov byte[CurrentExecSA1],0 mov byte[cycpl],5 jmp .nosa1 .nosa1 cmp byte[KeyOnStB],0 je .nokeyon mov al,[KeyOnStB] call ProcessKeyOn .nokeyon mov al,[KeyOnStA] mov [KeyOnStB],al mov byte[KeyOnStA],0 test byte[SfxSFR],20h jnz near StartSFXdebugb .returnfromsfx add dh,[cycpl] mov [pdh],dh cmp byte[spcon],0 je .nosound call updatetimer push ebx xor ebx,ebx mov bl,dl mov edi,[tablead+ebx*4] pop ebx .nosound xor dh,dh inc word[curypos] mov ax,[resolutn] inc ax cmp word[curypos],ax je near .nmi mov ax,[totlines] cmp word[curypos],ax jae near .overy ; check for VIRQ/HIRQ/NMI ProcessIRQStuff ; test dl,04h ; jnz .noirq ; test byte[INTEnab],20h ; jz .novirq ; mov ax,[VIRQLoc] ; cmp word[curypos],ax ; je near .virq ; jmp .noirq ;.novirq ; test byte[INTEnab],10h ; jnz near .virq ;.noirq ; test byte[INTEnab],20h ; jz .novirq2b ; mov ax,[VIRQLoc] ; cmp word[curypos],ax ; jne .novirq2b ; cmp byte[intrset],1 ; jne .nointrset2b ; mov byte[intrset],2 ;.nointrset2b ;.novirq2b mov ax,[resolutn] cmp word[curypos],ax jb .drawline jmp dword near [edi+ebx*4] .drawline cmp byte[hdmadelay],0 je .dohdma dec byte[hdmadelay] jmp .nodohdma .dohdma call exechdma .nodohdma cmp byte[curblank],0 jne .nodrawlineb call drawline .nodrawlineb jmp dword near [edi+ebx*4] .nmi mov byte[irqon],80h cmp byte[C4Enable],0 je .noC4 call C4VBlank .noC4 ; mov byte[hdmastartsc],0 mov byte[joycontren],0 mov ax,[VIRQLoc] cmp word[curypos],ax jne .novirqz inc word[VIRQLoc] .novirqz call ReadInputDevice test byte[INTEnab],1 jz .noresetjoy mov eax,[JoyAOrig] rol eax,16 mov [JoyANow],eax mov eax,[JoyBOrig] rol eax,16 mov [JoyBNow],eax mov eax,[JoyCOrig] rol eax,16 mov [JoyCNow],eax mov eax,[JoyDOrig] mov [JoyDNow],eax mov byte[JoyCRead],0 .noresetjoy cmp byte[snesmouse],4 jne .nolethalen mov eax,[LethEnData] mov [JoyBNow],eax .nolethalen mov byte[MultiTapStat],80h mov byte[NMIEnab],81h test byte[INTEnab],80h jz .nonmi mov byte[curnmi],1 dec esi cmp byte[intrset],1 jne .nointrset mov byte[intrset],2 .nointrset ; mov byte[debstop3],1 jmp switchtonmideb .nonmi cmp byte[intrset],1 jne .nointrset2w mov byte[intrset],2 .nointrset2w cmp byte[esi],0CBh jne .nowai and dl,0FBh .nowai jmp dword near [edi+ebx*4] .overy mov word[curypos],0 mov byte[NMIEnab],01h add dword[opcd],170*262 call cachevideo call starthdma ProcessIRQStuff ; test dl,04h ; jnz .novirq2 ; test byte[INTEnab],20h ; jz .novirq2 ; mov ax,[VIRQLoc] ; cmp word[curypos],ax ; je near .virq ; mov ax,[VIRQLoc] ; cmp ax,[totlines] ; jae .virq ;.novirq2 jmp dword near [edi+ebx*4] .virq mov ax,[resolutn] cmp word[curypos],ax jnb .nodrawline cmp byte[hdmadelay],0 je .dohdma2 dec byte[hdmadelay] jmp .nodohdma2 .dohdma2 call exechdma .nodohdma2 cmp byte[curblank],0 jne .nodrawline call drawline .nodrawline dec esi cmp byte[intrset],1 jne .nointrset2 mov byte[intrset],2 .nointrset2 ; mov byte[debstop3],1 jmp switchtovirqdeb NEWSYM ExecuteAsmEnd zsnes-1.36/src/cpu/irq.asm0100644000175000017500000002354307505521463015055 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM flagnz,flago,flagc EXTSYM SfxSCMR,curnmi,execloop,initaddrl,nmiv,snesmap2 EXTSYM snesmmap,stackand,stackor,wramdata EXTSYM xe,xirqb,xpb,xpc,xs EXTSYM irqon,irqv EXTSYM irqv8 EXTSYM execloopdeb EXTSYM nmiv8 EXTSYM membank0r8,membank0w8 NEWSYM IrqAsmStart ; NMI Hardware 00FFFA,B 00FFEA,B 3 -> 000108 ; RES Hardware 00FFFC.D 00FFFC,D 1 ; BRK Software 00FFFE,F 00FFE6,7 N/A ; IRQ Hardware 00FFFE,F 00FFEE,F 4 -> 00010C %macro makedl 0 and dl,00111100b test dword[flagnz],18000h jz %%noneg or dl,80h %%noneg test dword[flagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[flagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[flago],0FFh jz %%nov or dl,40h %%nov %endmacro ;******************************************************* ; SwitchToNMI/VIRQ Calls NMI/VIRQ ;******************************************************* NEWSYM switchtonmi mov byte[curnmi],1 test byte[xe],1 jne near NMIemulmode mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx xor ebx,ebx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[nmiv] test byte[SfxSCMR],10h jz .nosfxnmi ; mov ax,0108h .nosfxnmi mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop NEWSYM NMIemulmode mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov [xpb],bh mov bl,[xpb] xor eax,eax mov ax,[nmiv8] mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop NEWSYM switchtovirq mov byte[irqon],80h test byte[xe],1 jne near IRQemulmode mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[irqv] ; test byte[SfxSCMR],10h ; jz .nosfxnmi ; mov ax,010Ch ;.nosfxnmi mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop NEWSYM switchtovirqret mov byte[irqon],80h test byte[xe],1 jne near IRQemulmode mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[irqv] ; test byte[SfxSCMR],10h ; jz .nosfxnmi ; mov ax,010Ch ;.nosfxnmi mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax ret .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax ret NEWSYM IRQemulmode mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov [xpb],bh mov bl,[xpb] xor eax,eax mov ax,[irqv8] mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloop NEWSYM switchtovirqdeb mov byte[irqon],80h test byte[xe],1 jne near IRQemulmodedeb mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[irqv] ; test byte[SfxSCMR],10h ; jz .nosfxnmi ; mov ax,010Ch ;.nosfxnmi mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb NEWSYM IRQemulmodedeb mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov [xpb],bh mov bl,[xpb] xor eax,eax mov ax,[irqv8] mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb NEWSYM switchtonmideb mov byte[curnmi],1 test byte[xe],1 jne near NMIemulmodedeb mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpb] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov bl,byte[xirqb] mov [xpb],bl xor eax,eax mov ax,[nmiv] test byte[SfxSCMR],10h jz .nosfxnmi ; mov ax,0108h .nosfxnmi mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb NEWSYM NMIemulmodedeb mov ebx,esi sub ebx,[initaddrl] mov [xpc],bx mov cx,[xs] mov al,[xpc+1] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx and cx,word[stackand] or cx,word[stackor] mov [xs],cx xor bh,bh mov [xpb],bh mov bl,[xpb] xor eax,eax mov ax,[nmiv8] mov [xpc],ax and dl,11110011b or dl,00000100b test ax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax jmp execloopdeb NEWSYM IrqAsmEnd zsnes-1.36/src/cpu/memory.asm0100644000175000017500000027620607432621315015574 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM romdata,sramb4save,pressed,vidbuffer,oamram EXTSYM C4TransfWireFrame2 EXTSYM C4WFXVal,C4WFYVal,C4WFX2Val,C4WFY2Val,C4CalcWireFrame EXTSYM C4WFDist,C4WFScale,C4TransfWireFrame,C4WFZVal EXTSYM debstop3 EXTSYM C41FXVal,C41FYVal,C41FAngleRes,C41FDist,C4Op1F,C4Op15 EXTSYM C41FDistVal,C4Op0D EXTSYM SFXEnable,regptra,sfxramdata,snesmmap,wramdataa,debstop,C4Ram,C4Enable EXTSYM C4RamR,C4RamW,snesmap2,SPC7110Enable EXTSYM DSP1Read16b EXTSYM DSP1Write8b,regptwa,writeon EXTSYM Bank0datr8,Bank0datw8,Bank0datr16,Bank0datw16,xd,SA1xd EXTSYM DSP1Read8b,DSP1Type,SA1Enable EXTSYM DSP1Write16b EXTSYM CurDecompPtr,PrevDecompPtr,CurDecompSize EXTSYM SPCDecmPtr,SPCCompPtr,SPCCompCounter EXTSYM ramsize,ramsizeand,sram EXTSYM ram7fa EXTSYM DosExit,invalid,invopcd,previdmode,printhex8 EXTSYM SA1Status,IRAM,CurBWPtr,SA1RAMArea EXTSYM SA1Overflow,OBCEnable EXTSYM Sdd1Mode,Sdd1Bank,Sdd1Addr,Sdd1NewAddr,memtabler8,AddrNoIncr,SDD1BankA EXTSYM SPC7110Entries,spc7110romptr NEWSYM MemoryAsmStart ; C4SprScale ;******************************************************* ; Register & Memory Access Banks (0 - 3F) / (80 - BF) ;******************************************************* ; enter : BL = bank number, CX = address location ; leave : AL = value read ; ****************************************************** ; C4 Emulation, reverse engineered & written by zsKnight ; ****************************************************** C4ProcessVectors: mov esi,[C4Ram] mov edi,esi add edi,1F8Ch xor edx,edx mov dx,[esi+1F8Ah] cmp dx,128 ja .ret cmp dx,0 jne .nozero .ret ret .nozero cmp dx,10h jb .less mov dx,10h .less mov esi,[C4Ram] add esi,800h .loop mov ecx,100h xor ebx,ebx xor eax,eax movsx bx,byte[edi] .spotloop add ah,80h mov byte[esi],ah sub ah,80h add ax,bx inc esi dec ecx jnz .spotloop add edi,3 dec dx jnz .loop ret C4ObjDisp dd 0 C4ColRot db 1 NEWSYM C4ObjSelec, db 0 NEWSYM C4SObjSelec, db 0 NEWSYM C4Pause, db 0 C4DataCopy times 64 db 0 ;NEWSYM C4Data times 64*4096 db 0 ; 15 sprites, 4 bytes each ; x,y,oamptr,stat (b0=oamb8,b1=16x16) ; 4 byte header (#sobj,?,?,?) CObjNum dw 0 C4Temp dd 0 C4Edit: ; C4 editing routines ; Register keyboard presses ; [ = prev object, ] = next object ; p = pause/unpause cmp byte[pressed+1Ah],0 je .notpressed mov byte[pressed+1Ah],0 inc byte[C4ObjSelec] inc byte[C4Temp] .notpressed cmp byte[pressed+1Bh],0 je .notpressed2 mov byte[pressed+1Bh],0 dec byte[C4ObjSelec] dec byte[C4Temp] .notpressed2 cmp byte[pressed+19h],0 je .notpressed3 mov byte[pressed+19h],0 xor byte[C4Pause],1 .notpressed3 ; Setup variables mov esi,[C4Ram] add byte[C4ColRot],16 mov al,[esi+620h] cmp byte[C4ObjSelec],0FFh jne .notneg dec al mov byte[C4ObjSelec],al jmp .notof .notneg cmp byte[C4ObjSelec],al jb .notof xor al,al mov [C4ObjSelec],al .notof ; Draw the dots on-screen xor eax,eax mov al,[C4ObjSelec] shl eax,4 add eax,[C4Ram] add eax,220h mov byte[.flipped],0 test byte[eax+6],40h jz .notflip mov byte[.flipped],1 .notflip ; 00/01 - x position relative to BG scroll value ; 02/03 - y position relative to BG scroll value ; 04 - palette/priority settings ; 05 - OAM pointer value ; 06 - flip settings : b6 = flipx, b7 = flipy ; 07 - looks like some sprite displacement values ; 08/09 - ??? ; 0A-0F - unused xor ebx,ebx mov bx,[eax+8] mov [CObjNum],bx cmp bx,4096 jae near .skipall shl ebx,6 add ebx,[C4Data] ; t,f,g,h = move current object ; q = copy current object structure, w = paste current object structure cmp byte[pressed+14h],0 je .notmove mov byte[pressed+14h],0 pushad mov ecx,15 .next add ebx,4 dec byte[ebx+1] dec ecx jnz .next popad .notmove cmp byte[pressed+21h],0 je .notmove2 mov byte[pressed+21h],0 pushad mov ecx,15 .next2 add ebx,4 cmp byte[.flipped],0 je .noflipx add byte[ebx],2 .noflipx dec byte[ebx] dec ecx jnz .next2 popad .notmove2 cmp byte[pressed+22h],0 je .notmove3 mov byte[pressed+22h],0 pushad mov ecx,15 .next3 add ebx,4 inc byte[ebx+1] dec ecx jnz .next3 popad .notmove3 cmp byte[pressed+23h],0 je .notmove4 mov byte[pressed+23h],0 pushad mov ecx,15 .next4 add ebx,4 cmp byte[.flipped],0 je .noflipx2 sub byte[ebx],2 .noflipx2 inc byte[ebx] dec ecx jnz .next4 popad .notmove4 cmp byte[pressed+10h],0 je .notcopy mov byte[pressed+10h],0 pushad mov edx,C4DataCopy mov ecx,64 .copylp mov al,[ebx] mov [edx],al inc ebx inc edx dec ecx jnz .copylp popad .notcopy cmp byte[pressed+11h],0 je .notpaste mov byte[pressed+11h],0 pushad mov edx,C4DataCopy mov ecx,64 .pastelp mov al,[edx] mov [ebx],al inc ebx inc edx dec ecx jnz .pastelp popad .notpaste ; - = remove sub-object, + = add sub-object ; ; = previous sub-object, ' = next sub-object cmp byte[pressed+0Ch],0 je .notpressed4 mov byte[pressed+0Ch],0 cmp byte[ebx],0 je .notpressed4 dec byte[ebx] .notpressed4 cmp byte[pressed+0Dh],0 je .notpressed5 mov byte[pressed+0Dh],0 cmp byte[ebx],15 je .notpressed5 inc byte[ebx] .notpressed5 cmp byte[pressed+27h],0 je .notpressed6 mov byte[pressed+27h],0 dec byte[C4SObjSelec] .notpressed6 cmp byte[pressed+28h],0 je .notpressed7 mov byte[pressed+28h],0 inc byte[C4SObjSelec] .notpressed7 ; get current sub-object displacement (0 if no sub-objects) xor ecx,ecx cmp byte[ebx],0 je near .nosubobjs mov cl,[ebx] cmp byte[C4ObjSelec],0FFh jne .sobjokay2 dec cl mov byte[C4SObjSelec],cl jmp .sobjokay .sobjokay2 cmp byte[C4SObjSelec],cl jb .sobjokay mov byte[C4SObjSelec],0 .sobjokay xor ecx,ecx mov cl,byte[C4SObjSelec] shl ecx,2 add ebx,ecx add ebx,4 ; i,j,k,l = move current sub-object (17,24,25,26) ; u = toggle between 8x8 and 16x16 tiles ; o = toggle between high/low oam value ; . = decrease oam value, / = increase oam value of sub-object cmp byte[pressed+17h],0 je .notpressed8 mov byte[pressed+17h],0 dec byte[ebx+1] .notpressed8 cmp byte[pressed+24h],0 je .notpressed9 mov byte[pressed+24h],0 dec byte[ebx] cmp byte[.flipped],0 je .notpressed9 add byte[ebx],2 .notpressed9 cmp byte[pressed+26h],0 je .notpressed11 mov byte[pressed+26h],0 inc byte[ebx] cmp byte[.flipped],0 je .notpressed11 sub byte[ebx],2 .notpressed11 cmp byte[pressed+25h],0 je .notpressed10 mov byte[pressed+25h],0 inc byte[ebx+1] .notpressed10 cmp byte[pressed+16h],0 je .notpressed12 mov byte[pressed+16h],0 xor byte[ebx+3],2 .notpressed12 cmp byte[pressed+18h],0 je .notpressed13 mov byte[pressed+18h],0 xor byte[ebx+3],1 .notpressed13 cmp byte[pressed+34h],0 je .notpressed14 mov byte[pressed+34h],0 dec byte[ebx+2] .notpressed14 cmp byte[pressed+35h],0 je .notpressed15 mov byte[pressed+35h],0 inc byte[ebx+2] .notpressed15 mov cl,[ebx] mov ch,[ebx+1] .nosubobjs mov edx,ecx xor ebx,ebx xor ecx,ecx mov bl,[eax] sub bl,[esi+621h] add bl,dl mov cl,[eax+2] sub cl,[esi+623h] add cl,dh mov esi,[vidbuffer] add esi,16*2+256*2+32*2 add esi,ebx add esi,ebx mov ebx,ecx shl ebx,9 shl ecx,6 add esi,ebx add esi,ecx mov al,[C4ColRot] mov ah,al xor ah,0FFh mov [esi],ax mov [esi+16],ax mov [esi+288*8*2],ax mov [esi+16+288*8*2],ax .skipall ret .flipped db 0 C4AddSprite: cmp dword[C4count],0 je near .nosprite mov [edi],ax mov [edi+2],bx mov ebx,[C4usprptr] and [ebx],dl mov al,dl xor al,0FFh and dh,al or [ebx],dh add edi,4 rol dl,2 rol dh,2 dec dword[C4count] cmp dl,0FCh jne .nosprite inc dword[C4usprptr] .nosprite ret C4ConvOAM: inc byte[C4Timer] and byte[C4Timer],15 inc byte[C4Timer2] and byte[C4Timer2],7 mov esi,[C4Ram] xor ecx,ecx mov edi,esi mov cl,[esi+620h] mov bx,[esi+621h] mov [.addx],bx mov bx,[esi+623h] mov [.addy],bx mov [C4usprptr],esi add dword[C4usprptr],200h mov eax,[C4ObjDisp] add edi,eax shr eax,4 add dword[C4usprptr],eax add esi,220h ; Convert from esi to edi mov dl,0FCh push ecx mov cl,byte[C4sprites] and cl,3 add cl,cl rol dl,cl pop ecx cmp cl,0 je near .none mov dword[C4count],128 mov eax,[C4sprites] sub dword[C4count],eax .loop push ecx push esi ; 00/01 - x position relative to BG scroll value ; 02/03 - y position relative to BG scroll value ; 04 - palette/priority settings ; 05 - OAM pointer value ; 06 - flip settings : b6 = flipx, b7 = flipy ; 07 - ??? ; 08/09 - Pointer to Sprite Structure ; 0A-0F - unused ;bit 1-3 = palette number bit 4,5 = playfield priority ;bit 6 = horizontal flip bit 7 = horizonal flip mov ax,[esi] sub ax,[.addx] mov [C4SprX],ax mov ax,[esi+2] sub ax,[.addy] mov [C4SprY],ax mov al,[esi+5] mov [C4SprOAM],al mov al,[esi+4] mov ah,al and ah,0Eh cmp ah,0 jmp .notstage2 jne .notstage1 cmp byte[C4Timer],0 je .flash jmp .noflash .notstage1 jmp .notstage2 cmp ah,4 jne .notstage2 cmp byte[C4Timer2],0 je .flash .noflash and al,0F1h or al,2 jmp .notstage2 .flash and al,0F1h .notstage2 mov [C4SprAttr],al mov al,[esi+6] or [C4SprAttr],al ; mov [C4SprFlip],al xor ecx,ecx mov cl,[esi+9] shl ecx,16 mov cx,[esi+7] add cx,cx shr ecx,1 add ecx,[romdata] mov al,[ecx] or al,al jz near .singlespr mov [C4SprCnt],al inc ecx .nextspr xor ebx,ebx movsx bx,byte[ecx+1] test byte[C4SprAttr],40h jz .notflipx neg bx sub bx,8 .notflipx add bx,[C4SprX] xor dh,dh test byte[ecx],20h jz .no16x16 or dh,10101010b test byte[C4SprAttr],40h jz .no16x16 sub bx,8 .no16x16 cmp bx,-16 jl near .nosprite cmp bx,272 jg near .nosprite mov al,bl test bx,100h jz .not512b or dh,01010101b .not512b xor ebx,ebx movsx bx,byte[ecx+2] test byte[C4SprAttr],80h jz .notflipy neg bx sub bx,8 .notflipy add bx,[C4SprY] test byte[ecx],20h jz .no16x16b test byte[C4SprAttr],80h jz .no16x16b sub bx,8 .no16x16b cmp bx,-16 jl near .nosprite cmp bx,224 jg near .nosprite mov ah,bl mov bh,[C4SprAttr] mov bl,[ecx] and bl,0C0h xor bh,bl mov bl,[C4SprOAM] add bl,[ecx+3] call C4AddSprite .nosprite add ecx,4 dec byte[C4SprCnt] jnz near .nextspr jmp .donemultispr .singlespr mov dh,10101010b test byte[C4SprX+1],1 jz .not512 or dh,01010101b .not512 mov al,[C4SprX] mov ah,[C4SprY] mov bl,[C4SprOAM] mov bh,[C4SprAttr] call C4AddSprite .donemultispr pop esi pop ecx ;NEWSYM C4Data times 64*4096 db 0 ; 15 sprites, 4 bytes each ; x,y,oamptr,stat (b0=oamb8,b1=16x16) ; 4 byte header (#sobj,?,?,?) add esi,16 dec cl jnz near .loop .none mov esi,oamram mov edi,[C4Ram] mov ecx,544 .next mov al,[edi] mov [esi],al inc edi inc esi dec ecx jnz .next ret .addx dw 0 .addy dw 0 C4count dd 0 C4usprptr dd 0 C4SprX dw 0 C4SprY dw 0 C4SprCnt db 0 C4SprAttr db 0 C4SprOAM db 0 C4SprFlip db 0 C4Timer db 0 C4Timer2 db 0 NEWSYM C4VBlank ret NEWSYM C4ProcessSprites push ecx push esi push edi push ebx push edx ; call C4ProcessVectors ; call C4Edit mov esi,[C4Ram] mov dword[C4count],8 mov cl,[esi+626h] mov byte[C4sprites],cl mov ecx,[C4sprites] shl ecx,2 mov dword[C4ObjDisp],ecx mov ecx,128 ; cmp byte[esi+65],50h ; jne .noincdisp mov dword[C4count],32 sub ecx,[C4sprites] .noincdisp add esi,[C4ObjDisp] ; Clear OAM to-be ram .next mov byte[esi+1],0E0h add esi,4 dec ecx jnz .next call C4ConvOAM pop edx pop ebx pop edi pop esi pop ecx ret NEWSYM SprValAdd, db 0 C4Data dd 0 C4sprites dd 0 OBClog dd 0 NumSprites db 0 OBCOldRegArray db 0 NEWSYM InitOBC pushad mov esi,[romdata] add esi,4096*1024 mov [C4RamR],esi mov [C4RamW],esi mov [C4Ram],esi add dword[C4RamW],8192*4 add dword[C4Ram],8192*8 mov ecx,8192 .c4loop mov dword[esi],OBCReadReg mov dword[esi+8192*4],OBCWriteReg mov dword[esi+8192*8],0 add esi,4 dec ecx jnz .c4loop mov esi,[romdata] add esi,4096*1024 mov dword[esi+3A1Eh*4],OBCClear mov dword[esi+3FF0h*4],OBCRegs mov dword[esi+3FF1h*4],OBCRegs mov dword[esi+3FF2h*4],OBCRegs mov dword[esi+3FF3h*4],OBCRegs mov dword[esi+3FF4h*4],OBCRegs mov dword[esi+3FF5h*4],OBCRegs mov dword[esi+3FF6h*4],OBCRegs mov dword[esi+3FF7h*4],OBCRegs popad ret OBCSprites: pushad mov byte[NumSprites],0 mov esi,[C4Ram] mov edi,esi add edi,1800h add byte[OBCRegArray],2 and byte[OBCRegArray],0FEh cmp byte[OBCRegArray],0FEh je .ohno cmp byte[OBCRegArray],0 je .ohno jmp .okay .ohno mov al,[OBCOldRegArray] mov [OBCRegArray],al jmp .loop .okay mov al,[OBCRegArray] mov [OBCOldRegArray],al .loop cmp byte[OBCRegArray],0 je .nomore sub byte[OBCRegArray],2 xor ebx,ebx mov bl,[esi+6] shl ebx,2 ; Get X,Y,OAM, and Attr mov al,[esi+3] ;0,3 mov [edi+ebx],al mov al,[esi+9] mov [edi+ebx+1],al mov al,[esi+10] ;2,10 mov [edi+ebx+2],al mov al,[esi+0Bh] mov byte[edi+ebx+3],al xor ebx,ebx mov bl,[esi+6] shr ebx,2 add ebx,512 mov cl,[esi+6] and cl,03h add cl,cl xor al,al mov ah,0FCh mov al,byte[esi+4] ;1,4 and al,03h shl al,cl rol ah,cl and byte[edi+ebx],ah or byte[edi+ebx],al inc byte[NumSprites] add esi,16 jmp .loop .nomore mov esi,[C4Ram] mov edi,esi add edi,1800h ; mov dword[edi+200h],0AAAAAAAAh popad ret OBCClear: call OBCSprites mov byte[clearmem],1 mov dword[OBClog],0 ret ; Affected values: 0,1,2,3,4,6,7,9,A,B ; 0,1 - Another X value (unused?) ; 2 - OAM value ; 3/4 - X value (bits 0-8) ; 5 - N/A (not written to) ; 6 - OAM # ; 7 - Always 0? ; 9 - Y value (bits 0-7) ; A - OAM value ; B - OAM Status ; X,Y,OAM,Attr / xhighbit / OAM highbit / Sprite size ;bit 0 = OAM b8, bit 1-3 = palette number bit 4,5 = playfield priority ;bit 6 = horizontal flip bit 7 = horizonal flip ; Extra: bit 0 = X bit 8, bit 1 = Larger sprite size OBCRegArray times 8 db 0 OBCIncArray db 2,1,1,1,2,2,2,2 clearmem db 0 OBCRegs: pushad sub ecx,1FF0h cmp byte[clearmem],0 je near .noclearmem cmp ecx,6 je .okay popad ret .okay mov dword[OBCRegArray],0 mov dword[OBCRegArray+4],0 mov byte[OBCRegArray],0FEh mov byte[clearmem],0 .noclearmem mov ebx,[C4Ram] add ebx,1000h add ebx,[OBClog] inc dword[OBClog] mov [ebx],cl cmp cl,6 jne .notsix add byte[OBCRegArray],2 mov bl,[OBCRegArray] mov bh,bl mov [OBCRegArray+1],bl mov [OBCRegArray+2],bx mov [OBCRegArray+4],bx mov [OBCRegArray+6],bx .notsix xor ebx,ebx mov bl,[OBCRegArray+ecx] cmp byte[OBCIncArray+ecx],1 jne .noinc or byte[OBCRegArray+ecx],1 .noinc shl ebx,3 add ecx,ebx add ecx,[C4Ram] mov byte[ecx],al ; cmp dl,1 ; jne .second mov byte[ecx+8],0FFh ; jmp .first ;.second ; mov byte[ecx+16],0FFh ;.first popad ret OBCReadReg: add ecx,[C4Ram] mov al,[ecx] sub ecx,[C4Ram] ret OBCWriteReg add ecx,[C4Ram] mov [ecx],al sub ecx,[C4Ram] ret NEWSYM InitC4 pushad mov esi,[romdata] add esi,4096*1024 mov [C4Data],esi add dword[C4Data],128*1024 mov [C4RamR],esi mov [C4RamW],esi mov [C4Ram],esi add dword[C4RamW],8192*4 add dword[C4Ram],8192*8 mov ecx,8192 .c4loop mov dword[esi],C4ReadReg mov dword[esi+8192*4],C4WriteReg mov dword[esi+8192*8],0 add esi,4 dec ecx jnz .c4loop mov esi,[C4RamW] mov dword[esi+1F4Fh*4],C4RegFunction mov esi,[C4Data] mov ecx,16*4096 .c4loopb mov dword[esi],0 add esi,4 dec ecx jnz .c4loopb popad ret C4ClearSpr: mov esi,ebx mov edi,eax ; xor ecx,ecx ; mov cx,[eax+1F44h] ; sub cx,6000h ; add eax,ecx shl ch,3 .scloop2 mov cl,byte[C4SprPos] shl cl,2 .scloop mov byte[edi],0 mov byte[edi+2000h],0 inc edi dec cl jnz .scloop dec ch jnz .scloop2 ret C4SprBitPlane: mov edi,eax shl ebx,2 .scloop3 mov ch,[C4SprPos] push esi .scloop4 push esi mov cl,8 .loop mov dh,8 mov dl,80h mov eax,[esi] .nextd test al,1 jz .not0 or byte[edi],dl .not0 test al,2 jz .not1 or byte[edi+1],dl .not1 test al,4 jz .not2 or byte[edi+16],dl .not2 test al,8 jz .not3 or byte[edi+17],dl .not3 shr eax,4 shr dl,1 dec dh jnz .nextd add esi,ebx add edi,2 dec cl jnz .loop add edi,16 pop esi add esi,4 dec ch jnz .scloop4 pop esi shl ebx,3 add esi,ebx add edi,dword[C4SprPtrInc] shr ebx,3 dec byte[C4SprPos+1] jnz .scloop3 .end ret C4XXScale dw 0 C4XYScale dw 0 C4YXScale dw 0 C4YYScale dw 0 C4CXPos dw 0 C4CYPos dw 0 C4CXMPos dd 0 C4CYMPos dd 0 C4PCXMPos dd 0 C4PCYMPos dd 0 DoScaleRotate: pushad mov esi,eax ; Calculate X scaler mov ax,[esi+1F80h] and eax,01FFh mov ax,[CosTable+eax*2] mov bx,[esi+1F8Fh] test bx,8000h jz .notover mov bx,7FFFh .notover imul bx add ax,ax adc dx,dx mov [C4XXScale],dx mov ax,[esi+1F80h] and eax,01FFh mov ax,[SinTable+eax*2] imul bx add ax,ax adc dx,dx mov [C4XYScale],dx ; Calculate Y scaler mov ax,[esi+1F80h] and eax,01FFh mov ax,[CosTable+eax*2] mov bx,[esi+1F92h] test bx,8000h jz .notoverb mov bx,7FFFh .notoverb imul bx add ax,ax add dx,dx mov [C4YYScale],dx mov ax,[esi+1F80h] and eax,01FFh mov ax,[SinTable+eax*2] imul bx add ax,ax adc dx,dx neg dx mov [C4YXScale],dx cmp word[esi+1F80h],0 jne .effect cmp word[esi+1F92h],1000h jne .effect mov word[C4YYScale],1000h mov word[C4YXScale],0 .effect ; Calculate Pixel Resolution mov cl,byte[C4SprPos] shl cl,3 mov byte[C4SprPos+2],cl mov cl,byte[C4SprPos+1] shl cl,3 mov byte[C4SprPos+3],cl ; Calculate Positions ; (1-scale)*(pos/2) xor eax,eax mov al,[C4SprPos+2] shl eax,11 mov [C4PCXMPos],eax xor eax,eax mov al,[C4SprPos+3] shl eax,11 mov [C4PCYMPos],eax mov bx,[C4XXScale] xor eax,eax mov al,[C4SprPos+2] shr ax,1 imul bx shl edx,16 mov dx,ax sub [C4PCXMPos],edx mov bx,[C4YXScale] xor eax,eax mov al,[C4SprPos+3] shr ax,1 imul bx shl edx,16 mov dx,ax sub [C4PCXMPos],edx mov bx,[C4XYScale] xor eax,eax mov al,[C4SprPos+2] shr ax,1 imul bx shl edx,16 mov dx,ax sub [C4PCYMPos],edx mov bx,[C4YYScale] xor eax,eax mov al,[C4SprPos+3] shr ax,1 imul bx shl edx,16 mov dx,ax sub [C4PCYMPos],edx ; Start loop mov word[C4CYPos],0 xor edi,edi .loop mov ecx,[C4PCXMPos] mov [C4CXMPos],ecx mov ecx,[C4PCYMPos] mov [C4CYMPos],ecx mov al,[C4SprPos+2] mov byte[C4CXPos],al .loop2 xor eax,eax mov al,[C4SprPos+2] mov ebx,[C4CXMPos] sar ebx,12 cmp ebx,eax jae near .blank xor eax,eax mov al,[C4SprPos+3] mov ebx,[C4CYMPos] sar ebx,12 cmp ebx,eax jae near .blank ; Get pixel value mov ebx,[C4CYMPos] xor eax,eax shr ebx,12 mov al,[C4SprPos+2] mul ebx mov ebx,[C4CXMPos] shr ebx,12 add eax,ebx mov ebx,[C4SprPtr] test al,1 jnz .upperb shr eax,1 add ebx,eax mov al,[ebx] jmp .lowerb .upperb shr eax,1 add ebx,eax mov al,[ebx] shr al,4 .lowerb mov ebx,edi shr ebx,1 add ebx,esi test edi,1 jnz .upperb2 and al,0Fh and byte[ebx+2000h],0F0h or byte[ebx+2000h],al jmp .done .upperb2 shl al,4 and byte[ebx+2000h],0Fh or byte[ebx+2000h],al jmp .done .blank mov eax,edi shr eax,1 add eax,esi test edi,1 jnz .upper and byte[eax+2000h],0F0h jmp .done .upper and byte[eax+2000h],0Fh .done movsx eax,word[C4XXScale] add [C4CXMPos],eax movsx eax,word[C4XYScale] add [C4CYMPos],eax inc edi dec byte[C4CXPos] jne near .loop2 movsx eax,word[C4YXScale] add [C4PCXMPos],eax movsx eax,word[C4YYScale] add [C4PCYMPos],eax inc word[C4CYPos] mov al,[C4SprPos+3] cmp byte[C4CYPos],al jne near .loop .noimage popad ret DoScaleRotate2: pushad xor ebx,ebx mov bx,[eax+1F8Fh] cmp bx,1000h ja .scaled mov bx,1000h .scaled mov [C4SprScale],ebx xor ebx,ebx mov bx,[eax+1F92h] cmp bx,1000h ja .scaledb mov bx,1000h .scaledb mov [C4SprScaleY],ebx mov cl,[C4SprPos] shl cl,3 mov ch,cl xor ebx,ebx .leftovercheck dec ch add ebx,[C4SprScale] .leftovercheckb cmp ebx,1000h jb .leftovercheck sub ebx,1000h dec cl jz .donecheck jmp .leftovercheckb .donecheck shr ch,1 mov cl,ch and ecx,0FFh mov esi,ecx mov cl,[C4SprPos+1] shl cl,3 mov ch,cl xor ebx,ebx .leftovercheckc dec ch add ebx,[C4SprScaleY] .leftovercheckd cmp ebx,1000h jb .leftovercheckc sub ebx,1000h dec cl jz .donecheckc jmp .leftovercheckd .donecheckc shr ch,1 mov cl,ch and ecx,0FFh push eax xor eax,eax mov al,[C4SprPos] shl al,3 mul ecx add esi,eax pop eax mov dword[C4SprScalerY],0 xor edi,edi mov cl,[C4SprPos+1] shl cl,3 mov [C4SprPos+3],cl .next push esi push edi xor ecx,ecx mov cl,[C4SprPos] shl cl,3 mov ch,cl mov dword[C4SprScaler],0 xor edx,edx .loop mov edx,edi shr edx,1 add edx,[C4SprPtr] mov bl,[edx] test esi,1 jz .notupper shr bl,4 .notupper and bl,0Fh mov edx,esi shr edx,1 test esi,1 jz .notupperb shl bl,4 or byte[eax+edx+2000h],bl jmp .notlowerb .notupperb or byte[eax+edx+2000h],bl .notlowerb inc esi mov ebx,[C4SprScale] add dword[C4SprScaler],ebx dec ch .nextcheck cmp dword[C4SprScaler],1000h jb near .loop sub dword[C4SprScaler],1000h inc edi dec cl jz .done jmp .nextcheck .done pop edi pop esi xor edx,edx mov dl,[C4SprPos] shl dl,3 add esi,edx mov ebx,[C4SprScaleY] add dword[C4SprScalerY],ebx .nextcheckb cmp dword[C4SprScalerY],1000h jb near .next sub dword[C4SprScalerY],1000h add edi,edx dec byte[C4SprPos+3] jz .doneb jmp .nextcheckb .doneb popad ret C4SprScaleR: push ecx push ebx push edx push esi push edi mov dword[C4SprPtrInc],0 xor ebx,ebx mov bl,[eax+1F42h] shl ebx,16 mov bx,[eax+1F40h] add bx,bx shr ebx,1 add ebx,[romdata] mov ch,[eax+1F8Ch] shr ch,3 mov cl,[eax+1F89h] shr cl,3 mov [C4SprPos],cx mov [C4SprPtr],ebx call C4ClearSpr call DoScaleRotate mov esi,eax add esi,2000h xor ebx,ebx mov bl,[C4SprPos] call C4SprBitPlane pop edi pop esi pop edx pop ebx pop ecx ret C4SprRotateR: push ecx push ebx push edx push esi push edi xor ebx,ebx mov ebx,600h add ebx,[C4Ram] mov [C4SprPtr],esi mov ch,[eax+1F8Ch] shr ch,3 mov cl,[eax+1F89h] shr cl,3 add ch,2 mov [C4SprPos],cx mov dword[C4SprPtrInc],64 mov [C4SprPtr],ebx sub byte[C4SprPos+1],2 call C4ClearSpr call DoScaleRotate mov esi,eax add esi,2000h xor ebx,ebx mov bl,[C4SprPos] add byte[C4SprPos+1],2 call C4SprBitPlane pop edi pop esi pop edx pop ebx pop ecx ret C4SprDisintegrate: pushad mov dword[C4SprPtrInc],0 xor ebx,ebx mov bl,[eax+1F42h] shl ebx,16 mov bx,[eax+1F40h] add bx,bx shr ebx,1 add ebx,[romdata] mov ch,[eax+1F8Ch] shr ch,3 mov cl,[eax+1F89h] shr cl,3 mov [C4SprPos],cx mov [C4SprPtr],ebx call C4ClearSpr mov esi,[C4Ram] xor ebx,ebx mov bx,[esi+1F86h] xor eax,eax mov al,[esi+1F89h] shr al,1 mul ebx neg eax xor ebx,ebx mov bl,[esi+1F89h] shr bl,1 shl ebx,8 add eax,ebx push eax xor ebx,ebx mov bx,[esi+1F8Fh] xor eax,eax mov al,[esi+1F8Ch] shr al,1 mul ebx neg eax xor ebx,ebx mov bl,[esi+1F8Ch] shr bl,1 shl ebx,8 add ebx,eax mov edx,ebx pop ebx mov esi,[C4Ram] mov cl,[esi+1F89h] mov ch,[esi+1F8Ch] mov [C4SprPos+2],cx movsx eax,word[esi+1F86h] mov [.scalex],eax movsx eax,word[esi+1F8Fh] mov [.scaley],eax mov esi,[C4SprPtr] mov edi,[C4Ram] add edi,2000h ; convert to 8-bit bitmap mov cx,[C4SprPos+2] shr cl,1 .loop2 mov al,[esi] mov [edi],al mov al,[esi] shr al,4 mov [edi+1],al inc esi add edi,2 dec cl jnz .loop2 dec ch jnz .loop2 mov edi,[C4Ram] add edi,4000h mov ecx,2000h .lp mov byte[edi],0 inc edi dec ecx jnz .lp mov esi,[C4Ram] add esi,2000h mov edi,[C4Ram] add edi,4000h mov cx,[C4SprPos+2] .next2 push ebx .next xor eax,eax mov ah,[C4SprPos+2] cmp ebx,eax jae .fail xor eax,eax mov ah,[C4SprPos+3] cmp edx,eax jae .fail push ecx push edx xor eax,eax mov al,[C4SprPos+2] xor ecx,ecx mov cl,dh mul ecx mov ecx,ebx shr ecx,8 add eax,ecx mov dl,[esi] cmp eax,2000h jae .skipdisi mov [edi+eax],dl .skipdisi pop edx pop ecx .fail inc esi add ebx,[.scalex] dec cl jnz near .next pop ebx add edx,[.scaley] mov cl,[C4SprPos+2] dec ch jnz near .next2 .skipall ; convert to 4-bit bitmap mov esi,[C4Ram] add esi,4000h mov edi,[C4Ram] add edi,6000h mov cx,[C4SprPos+2] shr cl,1 .loop mov al,[esi] mov [edi],al mov al,[esi+1] shl al,4 or [edi],al inc edi add esi,2 dec cl jnz .loop dec ch jnz .loop mov esi,[C4Ram] add esi,6000h ; mov esi,[C4SprPtr] mov eax,[C4Ram] xor ebx,ebx mov bl,[C4SprPos] call C4SprBitPlane popad ret .scalex dd 0 .scaley dd 0 C4BitPlaneWave: pushad mov esi,[C4Ram] mov dword[.temp],10h xor eax,eax mov al,[esi+1F83h] mov dword[.waveptr],eax mov word[.temp+4],0C0C0h mov word[.temp+6],03F3Fh .bmloopb mov edi,[C4Ram] add edi,[.waveptr] xor eax,eax movsx ax,byte[edi+$0B00] neg ax sub ax,16 mov edi,[C4Ram] add edi,0A00h xor ecx,ecx .bmloopa mov ebx,[.bmptr+ecx*4] mov dx,[.temp+6] and [esi+ebx],dx xor dx,dx cmp ax,0 jl .less mov dx,0FF00h cmp ax,8 jae .less mov dx,[edi+eax*2] .less and dx,[.temp+4] or [esi+ebx],dx inc ax inc ecx cmp ecx,28h jne .bmloopa add dword[.waveptr],1 and dword[.waveptr],07Fh ror word[.temp+4],2 ror word[.temp+6],2 cmp word[.temp+4],0C0C0h jne near .bmloopb add esi,16 .bmloopa2b mov edi,[C4Ram] add edi,[.waveptr] xor eax,eax movsx ax,byte[edi+$0B00] neg ax sub ax,16 mov edi,[C4Ram] add edi,0A00h xor ecx,ecx .bmloopa2 mov ebx,[.bmptr+ecx*4] mov dx,[.temp+6] and [esi+ebx],dx xor dx,dx cmp ax,0 jl .less2 mov dx,0FF00h cmp ax,8 jae .less2 mov dx,[edi+eax*2+16] .less2 and dx,[.temp+4] or [esi+ebx],dx inc ax inc ecx cmp ecx,28h jne .bmloopa2 add dword[.waveptr],1 and dword[.waveptr],07Fh ror word[.temp+4],2 ror word[.temp+6],2 cmp word[.temp+4],0C0C0h jne near .bmloopa2b add esi,16 dec dword[.temp] jnz near .bmloopb mov esi,[C4Ram] ; mov cx,[esi+1F80h] ; mov [C4values],cx ; mov cx,[esi+1F83h] ; mov [C4values+2],cx popad ret .bmptr dd 0000h,0002h,0004h,0006h,0008h,000Ah,000Ch,000Eh dd 0200h,0202h,0204h,0206h,0208h,020Ah,020Ch,020Eh dd 0400h,0402h,0404h,0406h,0408h,040Ah,040Ch,040Eh dd 0600h,0602h,0604h,0606h,0608h,060Ah,060Ch,060Eh dd 0800h,0802h,0804h,0806h,0808h,080Ah,080Ch,080Eh .temp dd 0,0 .waveptr dd 0 C4DrawLine: ;C4X1 dw 0 ;C4Y1 dw 0 ;C4Z1 dw 0 ;C4X2 dw 0 ;C4Y2 dw 0 ;C4Z2 dw 0 ;C4Col dw 0 pushad ; transform both coordinates push esi mov ax,word[C4X1] mov [C4WFXVal],ax mov ax,word[C4Y1] mov [C4WFYVal],ax mov ax,word[C4Z1] mov [C4WFZVal],ax mov al,[esi+1F90h] mov [C4WFScale],al mov al,[esi+1F86h] mov [C4WFX2Val],al mov al,[esi+1F87h] mov [C4WFY2Val],al mov al,[esi+1F88h] mov [C4WFDist],al call C4TransfWireFrame2 mov ax,[C4WFXVal] mov word[C4X1],ax mov ax,[C4WFYVal] mov word[C4Y1],ax mov ax,word[C4X2] mov [C4WFXVal],ax mov ax,word[C4Y2] mov [C4WFYVal],ax mov ax,word[C4Z2] mov [C4WFZVal],ax call C4TransfWireFrame2 mov ax,[C4WFXVal] mov word[C4X2],ax mov ax,[C4WFYVal] mov word[C4Y2],ax add word[C4X1],48 add word[C4Y1],48 add word[C4X2],48 add word[C4Y2],48 shl dword[C4X1],8 shl dword[C4X2],8 shl dword[C4Y1],8 shl dword[C4Y2],8 ; get line info mov ax,[C4X1+1] mov [C4WFXVal],ax mov ax,[C4Y1+1] mov [C4WFYVal],ax mov ax,[C4X2+1] mov [C4WFX2Val],ax mov ax,[C4Y2+1] mov [C4WFY2Val],ax call C4CalcWireFrame xor ecx,ecx mov cx,[C4WFDist] or ecx,ecx jnz .not0 mov ecx,1 .not0 movsx eax,word[C4WFXVal] mov [C4X2],eax movsx eax,word[C4WFYVal] mov [C4Y2],eax pop esi ; render line .loop ; plot pixel cmp word[C4X1+1],0 jl near .noplot cmp word[C4Y1+1],0 jl near .noplot cmp word[C4X1+1],95 jg near .noplot cmp word[C4Y1+1],95 jg near .noplot xor eax,eax mov dx,[C4Y1+1] shr dx,3 mov ax,dx shl ax,6 shl dx,8 sub dx,ax mov ax,[C4X1+1] shr ax,3 shl ax,4 add ax,dx mov dx,[C4Y1+1] and dx,07h add dx,dx add ax,dx mov dl,07Fh push ecx mov cl,[C4X1+1] and cl,07h ror dl,cl pop ecx and byte[esi+eax+300h],dl and byte[esi+eax+301h],dl xor dl,0FFh test byte[C4Col],1 jz .nocolor0 or byte[esi+eax+300h],dl .nocolor0 test byte[C4Col],2 jz .nocolor1 or byte[esi+eax+301h],dl .nocolor1 .noplot mov eax,[C4X2] add [C4X1],eax mov eax,[C4Y2] add [C4Y1],eax dec ecx jnz near .loop popad ret DrawWireFrame: mov esi,[C4Ram] mov edi,esi xor ebx,ebx mov bl,[esi+1F82h] shl ebx,16 mov bx,[esi+1F80h] add bx,bx shr ebx,1 add ebx,[romdata] mov edi,ebx xor ecx,ecx mov cl,[esi+295h] .loop xor eax,eax mov al,[esi+1F82h] shl eax,16 mov al,[edi+1] mov ah,[edi+0] mov edx,edi .nextprev cmp ax,0FFFFh jne .notprev sub edx,5 mov al,[edx+3] mov ah,[edx+2] jmp .nextprev .notprev add ax,ax shr eax,1 add eax,[romdata] xor edx,edx mov dl,[esi+1F82h] shl edx,16 mov dl,[edi+3] mov dh,[edi+2] ; mov [C4values+6],dx add dx,dx shr edx,1 add edx,[romdata] xor ebx,ebx mov bh,[eax] mov bl,[eax+1] mov [C4X1],ebx mov bh,[eax+2] mov bl,[eax+3] mov [C4Y1],ebx mov bh,[eax+4] mov bl,[eax+5] mov [C4Z1],ebx mov bh,[edx] mov bl,[edx+1] mov [C4X2],ebx mov bh,[edx+2] mov bl,[edx+3] mov [C4Y2],ebx mov bh,[edx+4] mov bl,[edx+5] mov [C4Z2],ebx mov al,[edi+4] mov [C4Col],al add edi,5 call C4DrawLine dec ecx jnz near .loop ret C4X1 dd 0 C4Y1 dd 0 C4Z1 dd 0 C4X2 dd 0 C4Y2 dd 0 C4Z2 dd 0 C4Col dd 0 WireFrameB: pushad ; 28EECA ; 7F80 (3bytes) = pointer to data ; 7F86-7F88 = rotation, 7F90 = scale (/7A?) ; 6295 = # of lines, 7FA5 = ??? mov esi,[C4Ram] add esi,300h mov ecx,16*12*3 .loop mov dword[esi],0 add esi,4 dec ecx jnz .loop call DrawWireFrame mov esi,[C4Ram] mov cx,[esi+1FA5h] ; mov [C4values],cx ; mov cx,[esi+1F86h] ; mov [C4values],cx ; mov cx,[esi+1F88h] ; mov [C4values+2],cx ; mov cx,[esi+1F90h] ; mov [C4values+4],cx popad ret WireFrameB2: pushad call DrawWireFrame popad ret C4WireFrame: pushad mov esi,[C4Ram] mov ax,[esi+1F83h] and ax,0FFh mov [C4WFX2Val],ax ; mov [C4values],ax mov ax,[esi+1F86h] and ax,0FFh mov [C4WFY2Val],ax ; mov [C4values+2],ax mov ax,[esi+1F89h] and ax,0FFh mov [C4WFDist],ax ; mov [C4values+4],ax mov ax,[esi+1F8Ch] and ax,0FFh mov [C4WFScale],ax ; mov [C4values+6],ax ; transform vertices (MMX2 - 36 vertices, 54 lines) xor ecx,ecx mov cx,[esi+1F80h] xor al,al .loop mov ax,[esi+1] mov [C4WFXVal],ax mov ax,[esi+5] mov [C4WFYVal],ax mov ax,[esi+9] mov [C4WFZVal],ax push esi push ecx call C4TransfWireFrame pop ecx pop esi ; Displace mov ax,[C4WFXVal] add ax,80h mov [esi+1],ax mov ax,[C4WFYVal] add ax,50h mov [esi+5],ax add esi,10h dec ecx jnz .loop ; Uses 6001,6005,6600,6602,6605 mov esi,[C4Ram] mov word[esi+$600],23 mov word[esi+$602],60h mov word[esi+$605],40h mov word[esi+$600+8],23 mov word[esi+$602+8],60h mov word[esi+$605+8],40h xor ecx,ecx mov cx,[esi+0B00h] mov edi,esi add edi,0B02h .lineloop xor eax,eax mov al,[edi] shl eax,4 add eax,[C4Ram] mov bx,[eax+1] mov [C4WFXVal],bx mov bx,[eax+5] mov [C4WFYVal],bx xor eax,eax mov al,[edi+1] shl eax,4 add eax,[C4Ram] mov bx,[eax+1] mov [C4WFX2Val],bx mov bx,[eax+5] mov [C4WFY2Val],bx push esi push edi push ecx call C4CalcWireFrame pop ecx pop edi pop esi mov ax,[C4WFDist] or ax,ax jnz .yeswire mov ax,1 .yeswire mov word[esi+$600],ax mov ax,[C4WFXVal] mov word[esi+$602],ax mov ax,[C4WFYVal] mov word[esi+$605],ax add edi,2 add esi,8 dec ecx jnz near .lineloop .done popad ret C4Transform: ; 7F81,4,7,9,A,B,0,1,D pushad mov esi,[C4Ram] mov ax,word[esi+1F81h] mov [C4WFXVal],ax mov ax,word[esi+1F84h] mov [C4WFYVal],ax mov ax,word[esi+1F87h] mov [C4WFZVal],ax mov al,[esi+1F90h] mov [C4WFScale],al mov al,[esi+1F89h] mov [C4WFX2Val],al mov al,[esi+1F8Ah] mov [C4WFY2Val],al mov al,[esi+1F8Bh] mov [C4WFDist],al call C4TransfWireFrame2 mov ax,[C4WFXVal] mov word[esi+1F80h],ax mov ax,[C4WFYVal] mov word[esi+1F83h],ax popad ret C4SprPos dd 0 C4SprScale dd 0 C4SprScaleY dd 0 C4SprScaler dd 0 C4SprScalerY dd 0 C4SprPtr dd 0 C4SprPtrInc dd 0 NEWSYM C4values, dd 0,0,0 C4activate: add ecx,[C4Ram] mov [ecx],al sub ecx,[C4Ram] cmp al,00h je near .dosprites cmp al,01h je near .dowireframe cmp al,05h ; ? je near .propulsion cmp al,0Dh ; ? je near .equatevelocity cmp al,10h ; supply angle+distance, return x/y displacement je near .direction cmp al,13h ; ? je near .something2 cmp al,15h ; ? je near .calcdistance cmp al,1Fh ; supply x/y displacement, return angle (+distance?) je near .calcangle cmp al,22h ; supply x/y displacement, return angle (+distance?) je near .linearray cmp al,2Dh ; ??? je near .transform cmp al,89h je near .immediaterom cmp al,5Ch je near .immediatereg ret .dowireframe call WireFrameB ret .linearray pushad ; C,F,0,3,6,9 -> 6800 (E1h bytes) ; 0,3 = screen scroll coordinates ; 6,9 = light source coordinates ; C,F = angle of both arrays mov esi,[C4Ram] xor ecx,ecx .loopline ; process position xor eax,eax mov al,[esi+1F8Ch] or ecx,ecx jz .secondlineb mov al,[esi+1F8Fh] .secondlineb test al,80h jz .notua or ah,1 .notua movsx ebx,word[CosTable+eax*2] mov ax,word[SinTable+eax*2] shl eax,16 cmp ebx,0 je near .finish xor edx,edx test eax,80000000h jz .notnegline mov edx,0FFFFFFFFh .notnegline idiv ebx mov [C4Temp],eax xor edx,edx mov bx,[esi+1F83h] sub bx,[esi+1F89h] dec bx movsx ebx,bx .nextline test ebx,80000000h jnz .none mov eax,[C4Temp] imul eax,ebx sar eax,16 sub ax,[esi+1F80h] add ax,[esi+1F86h] inc ax add ax,cx cmp ax,0 jge .not0line xor ax,ax or ecx,ecx jz .not0line mov byte[esi+edx+$800],1 .not0line cmp ax,255 jl .not255line mov ax,255 .not255line jmp .doneline .none mov al,1 sub al,cl .doneline or ecx,ecx jnz .secondline mov [esi+edx+$800],al jmp .firstline .secondline mov [esi+edx+$900],al .firstline inc ebx inc edx cmp edx,0E1h jne .nextline or ecx,ecx jnz .finish mov ecx,1 jmp .loopline .finish mov cx,[C4Temp] ; mov [C4values],cx mov cx,[C4Temp+2] ; mov [C4values+2],cx mov cx,[esi+1F8Ch] ; mov [C4values+4],cx mov cx,[esi+1F8Fh] ; mov [C4values+6],cx popad ret .propulsion pushad ; 81 = 5B, 83 = 0x300 ; 0x300 = /1, 0x280 = /4 mov esi,[C4Ram] mov cx,[esi+1F83h] mov [C4values+2],cx mov cx,[esi+1F81h] mov [C4values],cx xor bx,bx ; mov ax,256*256 xor ax,ax mov dx,1 mov bx,[esi+1F83h] or dx,dx jz .done idiv bx mov [C4values+6],ax mov bx,[esi+1F81h] imul bx shl edx,16 mov dx,ax sar edx,8 .done mov word[esi+1F80h],dx mov [C4values+4],dx ; and eax,1FFh ; mov bx,[SinTable+eax*2] ; mov ax,[esi+1F81h] ; distance? ; imul bx ; mov ax,dx ; shl ax,1 ; shl dx,3 ; add dx,ax popad ret .something2 pushad mov esi,[C4Ram] xor ecx,ecx mov ax,[esi+1F80h] and eax,1FFh mov bx,[CosTable+eax*2] mov ax,[esi+1F83h] imul bx add ax,ax adc dx,dx mov ax,dx movsx edx,dx mov [esi+1F87h],edx mov ax,[esi+1F80h] and eax,1FFh mov bx,[SinTable+eax*2] mov ax,[esi+1F83h] imul bx add ax,ax adc dx,dx mov ax,dx movsx edx,dx mov al,[esi+198Dh] mov [esi+1F8Ah],edx mov [esi+198Dh],al ; mov cx,[esi+1F83h] ; mov [C4values+4],cx ; mov cx,[esi+1F86h] ; mov [C4values],cx ; mov cx,[esi+1F89h] ; mov [C4values+2],cx popad ret ret .dosprites ; mov byte[debstop3],0 push eax mov eax,[C4Ram] cmp byte[eax+1F4Dh],0 je near .sprites cmp byte[eax+1F4Dh],3 je near .scaler cmp byte[eax+1F4Dh],5 je near .lines cmp byte[eax+1F4Dh],7 je near .rotater cmp byte[eax+1F4Dh],8 je near .wireframeb cmp byte[eax+1F4Dh],0Bh je near .disintegrate cmp byte[eax+1F4Dh],0Ch je near .bitmap pop eax ret .wireframeb pop eax call WireFrameB2 ret .sprites pop eax call C4ProcessSprites ret .disintegrate call C4SprDisintegrate pop eax ret .dolines ; mov byte[debstop3],0 ret .bitmap call C4BitPlaneWave pop eax ret .calcdistance pushad mov esi,[C4Ram] mov bx,[esi+1F80h] mov [C41FXVal],bx mov bx,[esi+1F83h] mov [C41FYVal],bx ; mov eax,[C4Ram] ; mov cx,[eax+1F80h] ; mov [C4values+0],cx ; mov cx,[eax+1F83h] ; mov [C4values+2],cx call C4Op15 mov eax,[C4Ram] mov bx,[C41FDist] mov [eax+1F80h],bx ; mov word[eax+1F80h],50 ; mov cx,[eax+1F80h] ; mov [C4values+4],cx popad ret .calcangle pushad mov esi,[C4Ram] mov bx,[esi+1F80h] mov [C41FXVal],bx mov bx,[esi+1F83h] mov [C41FYVal],bx call C4Op1F mov eax,[C4Ram] mov bx,[C41FAngleRes] mov [eax+1F86h],bx ; mov esi,[C4Ram] ; mov cx,[esi+1F86h] ; mov [C4values],cx ; mov cx,[esi+1F80h] ; mov [C4values+2],cx ; mov cx,[esi+1F83h] ; mov [C4values+4],cx popad ret .transform ; 7F81,4,7,9,A,B,0,1,D ; mov byte[debstop3],0 pushad ; mov eax,[C4Ram] call C4Transform ; mov word[eax+1F80h],0 ; mov word[eax+1F83h],0 popad ret .equatevelocity pushad mov esi,[C4Ram] mov bx,[esi+1F80h] mov [C41FXVal],bx mov bx,[esi+1F83h] mov [C41FYVal],bx mov bx,[esi+1F86h] mov [C41FDistVal],bx call C4Op0D mov bx,[C41FXVal] mov [esi+1F89h],bx mov bx,[C41FYVal] mov [esi+1F8Ch],bx popad ret pushad mov esi,[C4Ram] mov cx,[esi+$1F86] cmp cx,40h jb .nomult shr cx,7 .nomult mov ax,[esi+$1F80] ; imul cx shl ax,4 mov word[esi+$1F89],ax mov ax,[esi+$1F83] ; imul cx shl ax,4 mov word[esi+$1F8C],ax ; mov cx,[esi+$1F80] ; mov [C4values],cx ; mov cx,[esi+$1F83] ; mov [C4values+2],cx ; mov cx,[esi+$1F86] ; mov [C4values+4],cx popad ret .lines call C4WireFrame pop eax ret .scaler push esi push ecx mov esi,[C4Ram] ; mov cx,[esi+1F8Fh] ; mov [C4values],cx ; mov cx,[esi+1F92h] ; mov [C4values+2],cx ; mov cx,[esi+1F80h] ; mov [C4values+4],cx pop ecx pop esi call C4SprScaleR pop eax ret .rotater push esi push ecx mov esi,[C4Ram] ; mov cx,[esi+1F8Fh] ; mov [C4values],cx ; mov cx,[esi+1F92h] ; mov [C4values+2],cx ; mov cx,[esi+1F80h] ; mov [C4values+4],cx pop ecx pop esi call C4SprRotateR pop eax ret .direction push eax push ebx push esi push edx push ecx mov esi,[C4Ram] xor ecx,ecx mov ax,[esi+1F80h] and eax,1FFh mov bx,[CosTable+eax*2] mov ax,[esi+1F83h] imul bx add ax,ax adc dx,dx mov ax,dx movsx edx,dx mov [esi+1F86h],edx mov ax,[esi+1F80h] and eax,1FFh mov bx,[SinTable+eax*2] mov ax,[esi+1F83h] imul bx add ax,ax adc dx,dx mov ax,dx movsx edx,dx mov eax,edx sar eax,6 sub edx,eax mov al,[esi+198Ch] mov [esi+1F89h],edx mov [esi+198Ch],al ; mov cx,[esi+1F80h] ; mov [C4values],cx ; mov cx,[esi+1F83h] ; mov [C4values+2],cx ; mov cx,[esi+1F86h] ; mov [C4values+4],cx pop ecx pop edx pop esi pop ebx pop eax ret .immediaterom push eax mov eax,[C4Ram] mov byte[eax+1F80h],36h mov byte[eax+1F81h],43h mov byte[eax+1F82h],05h pop eax ret .immediatereg push eax mov eax,[C4Ram] mov dword[eax+0*4],0FF000000h mov dword[eax+1*4],0FF00FFFFh mov dword[eax+2*4],0FF000000h mov dword[eax+3*4],00000FFFFh mov dword[eax+4*4],00000FFFFh mov dword[eax+5*4],07FFFFF80h mov dword[eax+6*4],0FF008000h mov dword[eax+7*4],07FFF007Fh mov dword[eax+8*4],0FFFF7FFFh mov dword[eax+9*4],0FF010000h mov dword[eax+10*4],00100FEFFh mov dword[eax+11*4],000FEFF00h pop eax ret C4RegFunction: cmp ecx,1F4Fh je near C4activate add ecx,[C4Ram] mov [ecx],al sub ecx,[C4Ram] ret NEWSYM C4ReadReg add ecx,[C4Ram] mov al,[ecx] sub ecx,[C4Ram] ret NEWSYM C4WriteReg add ecx,[C4Ram] mov [ecx],al sub ecx,[C4Ram] ret SinTable: dw $00000,$00192,$00324,$004B6,$00647,$007D9,$0096A,$00AFB,$00C8B,$00E1B,$00FAB dw $01139,$012C8,$01455,$015E2,$0176D,$018F8,$01A82,$01C0B,$01D93,$01F19,$0209F dw $02223,$023A6,$02528,$026A8,$02826,$029A3,$02B1F,$02C98,$02E11,$02F87,$030FB dw $0326E,$033DE,$0354D,$036BA,$03824,$0398C,$03AF2,$03C56,$03DB8,$03F17,$04073 dw $041CE,$04325,$0447A,$045CD,$0471C,$04869,$049B4,$04AFB,$04C3F,$04D81,$04EBF dw $04FFB,$05133,$05269,$0539B,$054CA,$055F5,$0571D,$05842,$05964,$05A82,$05B9D dw $05CB4,$05DC7,$05ED7,$05FE3,$060EC,$061F1,$062F2,$063EF,$064E8,$065DD,$066CF dw $067BD,$068A6,$0698C,$06A6D,$06B4A,$06C24,$06CF9,$06DCA,$06E96,$06F5F,$07023 dw $070E2,$0719E,$07255,$07307,$073B5,$0745F,$07504,$075A5,$07641,$076D9,$0776C dw $077FA,$07884,$07909,$0798A,$07A05,$07A7D,$07AEF,$07B5D,$07BC5,$07C29,$07C89 dw $07CE3,$07D39,$07D8A,$07DD6,$07E1D,$07E5F,$07E9D,$07ED5,$07F09,$07F38,$07F62 dw $07F87,$07FA7,$07FC2,$07FD8,$07FE9,$07FF6,$07FFD,$07FFF,$07FFD,$07FF6,$07FE9 dw $07FD8,$07FC2,$07FA7,$07F87,$07F62,$07F38,$07F09,$07ED5,$07E9D,$07E5F,$07E1D dw $07DD6,$07D8A,$07D39,$07CE3,$07C89,$07C29,$07BC5,$07B5D,$07AEF,$07A7D,$07A05 dw $0798A,$07909,$07884,$077FA,$0776C,$076D9,$07641,$075A5,$07504,$0745F,$073B5 dw $07307,$07255,$0719E,$070E2,$07023,$06F5F,$06E96,$06DCA,$06CF9,$06C24,$06B4A dw $06A6D,$0698C,$068A6,$067BD,$066CF,$065DD,$064E8,$063EF,$062F2,$061F1,$060EC dw $05FE3,$05ED7,$05DC7,$05CB4,$05B9D,$05A82,$05964,$05842,$0571D,$055F5,$054CA dw $0539B,$05269,$05133,$04FFB,$04EBF,$04D81,$04C3F,$04AFB,$049B4,$04869,$0471C dw $045CD,$0447A,$04325,$041CE,$04073,$03F17,$03DB8,$03C56,$03AF2,$0398C,$03824 dw $036BA,$0354D,$033DE,$0326E,$030FB,$02F87,$02E11,$02C98,$02B1F,$029A3,$02826 dw $026A8,$02528,$023A6,$02223,$0209F,$01F19,$01D93,$01C0B,$01A82,$018F8,$0176D dw $015E2,$01455,$012C8,$01139,$00FAB,$00E1B,$00C8B,$00AFB,$0096A,$007D9,$00647 dw $004B6,$00324,$00192 dw $00000,$0FE6E,$0FCDC,$0FB4A,$0F9B9,$0F827,$0F696,$0F505,$0F375,$0F1E5,$0F055 dw $0EEC7,$0ED38,$0EBAB,$0EA1E,$0E893,$0E708,$0E57E,$0E3F5,$0E26D,$0E0E7,$0DF61 dw $0DDDD,$0DC5A,$0DAD8,$0D958,$0D7DA,$0D65D,$0D4E1,$0D368,$0D1EF,$0D079,$0CF05 dw $0CD92,$0CC22,$0CAB3,$0C946,$0C7DC,$0C674,$0C50E,$0C3AA,$0C248,$0C0E9,$0BF8D dw $0BE32,$0BCDB,$0BB86,$0BA33,$0B8E4,$0B797,$0B64C,$0B505,$0B3C1,$0B27F,$0B141 dw $0B005,$0AECD,$0AD97,$0AC65,$0AB36,$0AA0B,$0A8E3,$0A7BE,$0A69C,$0A57E,$0A463 dw $0A34C,$0A239,$0A129,$0A01D,$09F14,$09E0F,$09D0E,$09C11,$09B18,$09A23,$09931 dw $09843,$0975A,$09674,$09593,$094B6,$093DC,$09307,$09236,$0916A,$090A1,$08FDD dw $08F1E,$08E62,$08DAB,$08CF9,$08C4B,$08BA1,$08AFC,$08A5B,$089BF,$08927,$08894 dw $08806,$0877C,$086F7,$08676,$085FB,$08583,$08511,$084A3,$0843B,$083D7,$08377 dw $0831D,$082C7,$08276,$0822A,$081E3,$081A1,$08163,$0812B,$080F7,$080C8,$0809E dw $08079,$08059,$0803E,$08028,$08017,$0800A,$08003,$08001,$08003,$0800A,$08017 dw $08028,$0803E,$08059,$08079,$0809E,$080C8,$080F7,$0812B,$08163,$081A1,$081E3 dw $0822A,$08276,$082C7,$0831D,$08377,$083D7,$0843B,$084A3,$08511,$08583,$085FB dw $08676,$086F7,$0877C,$08806,$08894,$08927,$089BF,$08A5B,$08AFC,$08BA1,$08C4B dw $08CF9,$08DAB,$08E62,$08F1E,$08FDD,$090A1,$0916A,$09236,$09307,$093DC,$094B6 dw $09593,$09674,$0975A,$09843,$09931,$09A23,$09B18,$09C11,$09D0E,$09E0F,$09F14 dw $0A01D,$0A129,$0A239,$0A34C,$0A463,$0A57E,$0A69C,$0A7BE,$0A8E3,$0AA0B,$0AB36 dw $0AC65,$0AD97,$0AECD,$0B005,$0B141,$0B27F,$0B3C1,$0B505,$0B64C,$0B797,$0B8E4 dw $0BA33,$0BB86,$0BCDB,$0BE32,$0BF8D,$0C0E9,$0C248,$0C3AA,$0C50E,$0C674,$0C7DC dw $0C946,$0CAB3,$0CC22,$0CD92,$0CF05,$0D079,$0D1EF,$0D368,$0D4E1,$0D65D,$0D7DA dw $0D958,$0DAD8,$0DC5A,$0DDDD,$0DF61,$0E0E7,$0E26D,$0E3F5,$0E57E,$0E708,$0E893 dw $0EA1E,$0EBAB,$0ED38,$0EEC7,$0F055,$0F1E5,$0F375,$0F505,$0F696,$0F827,$0F9B9 dw $0FB4A,$0FCDC,$0FE6E CosTable: dw $07FFF,$07FFD,$07FF6,$07FE9,$07FD8,$07FC2,$07FA7,$07F87,$07F62,$07F38,$07F09 dw $07ED5,$07E9D,$07E5F,$07E1D,$07DD6,$07D8A,$07D39,$07CE3,$07C89,$07C29,$07BC5 dw $07B5D,$07AEF,$07A7D,$07A05,$0798A,$07909,$07884,$077FA,$0776C,$076D9,$07641 dw $075A5,$07504,$0745F,$073B5,$07307,$07255,$0719E,$070E2,$07023,$06F5F,$06E96 dw $06DCA,$06CF9,$06C24,$06B4A,$06A6D,$0698C,$068A6,$067BD,$066CF,$065DD,$064E8 dw $063EF,$062F2,$061F1,$060EC,$05FE3,$05ED7,$05DC7,$05CB4,$05B9D,$05A82,$05964 dw $05842,$0571D,$055F5,$054CA,$0539B,$05269,$05133,$04FFB,$04EBF,$04D81,$04C3F dw $04AFB,$049B4,$04869,$0471C,$045CD,$0447A,$04325,$041CE,$04073,$03F17,$03DB8 dw $03C56,$03AF2,$0398C,$03824,$036BA,$0354D,$033DE,$0326E,$030FB,$02F87,$02E11 dw $02C98,$02B1F,$029A3,$02826,$026A8,$02528,$023A6,$02223,$0209F,$01F19,$01D93 dw $01C0B,$01A82,$018F8,$0176D,$015E2,$01455,$012C8,$01139,$00FAB,$00E1B,$00C8B dw $00AFB,$0096A,$007D9,$00647,$004B6,$00324,$00192,$00000,$0FE6E,$0FCDC,$0FB4A dw $0F9B9,$0F827,$0F696,$0F505,$0F375,$0F1E5,$0F055,$0EEC7,$0ED38,$0EBAB,$0EA1E dw $0E893,$0E708,$0E57E,$0E3F5,$0E26D,$0E0E7,$0DF61,$0DDDD,$0DC5A,$0DAD8,$0D958 dw $0D7DA,$0D65D,$0D4E1,$0D368,$0D1EF,$0D079,$0CF05,$0CD92,$0CC22,$0CAB3,$0C946 dw $0C7DC,$0C674,$0C50E,$0C3AA,$0C248,$0C0E9,$0BF8D,$0BE32,$0BCDB,$0BB86,$0BA33 dw $0B8E4,$0B797,$0B64C,$0B505,$0B3C1,$0B27F,$0B141,$0B005,$0AECD,$0AD97,$0AC65 dw $0AB36,$0AA0B,$0A8E3,$0A7BE,$0A69C,$0A57E,$0A463,$0A34C,$0A239,$0A129,$0A01D dw $09F14,$09E0F,$09D0E,$09C11,$09B18,$09A23,$09931,$09843,$0975A,$09674,$09593 dw $094B6,$093DC,$09307,$09236,$0916A,$090A1,$08FDD,$08F1E,$08E62,$08DAB,$08CF9 dw $08C4B,$08BA1,$08AFC,$08A5B,$089BF,$08927,$08894,$08806,$0877C,$086F7,$08676 dw $085FB,$08583,$08511,$084A3,$0843B,$083D7,$08377,$0831D,$082C7,$08276,$0822A dw $081E3,$081A1,$08163,$0812B,$080F7,$080C8,$0809E,$08079,$08059,$0803E,$08028 dw $08017,$0800A,$08003 dw $08001,$08003,$0800A,$08017,$08028,$0803E,$08059,$08079,$0809E,$080C8,$080F7, dw $0812B,$08163,$081A1,$081E3,$0822A,$08276,$082C7,$0831D,$08377,$083D7,$0843B, dw $084A3,$08511,$08583,$085FB,$08676,$086F7,$0877C,$08806,$08894,$08927,$089BF, dw $08A5B,$08AFC,$08BA1,$08C4B,$08CF9,$08DAB,$08E62,$08F1E,$08FDD,$090A1,$0916A, dw $09236,$09307,$093DC,$094B6,$09593,$09674,$0975A,$09843,$09931,$09A23,$09B18, dw $09C11,$09D0E,$09E0F,$09F14,$0A01D,$0A129,$0A239,$0A34C,$0A463,$0A57E,$0A69C, dw $0A7BE,$0A8E3,$0AA0B,$0AB36,$0AC65,$0AD97,$0AECD,$0B005,$0B141,$0B27F,$0B3C1, dw $0B505,$0B64C,$0B797,$0B8E4,$0BA33,$0BB86,$0BCDB,$0BE32,$0BF8D,$0C0E9,$0C248, dw $0C3AA,$0C50E,$0C674,$0C7DC,$0C946,$0CAB3,$0CC22,$0CD92,$0CF05,$0D079,$0D1EF, dw $0D368,$0D4E1,$0D65D,$0D7DA,$0D958,$0DAD8,$0DC5A,$0DDDD,$0DF61,$0E0E7,$0E26D, dw $0E3F5,$0E57E,$0E708,$0E893,$0EA1E,$0EBAB,$0ED38,$0EEC7,$0F055,$0F1E5,$0F375, dw $0F505,$0F696,$0F827,$0F9B9,$0FB4A,$0FCDC,$0FE6E,$00000,$00192,$00324,$004B6, dw $00647,$007D9,$0096A,$00AFB,$00C8B,$00E1B,$00FAB,$01139,$012C8,$01455,$015E2, dw $0176D,$018F8,$01A82,$01C0B,$01D93,$01F19,$0209F,$02223,$023A6,$02528,$026A8, dw $02826,$029A3,$02B1F,$02C98,$02E11,$02F87,$030FB,$0326E,$033DE,$0354D,$036BA, dw $03824,$0398C,$03AF2,$03C56,$03DB8,$03F17,$04073,$041CE,$04325,$0447A,$045CD, dw $0471C,$04869,$049B4,$04AFB,$04C3F,$04D81,$04EBF,$04FFB,$05133,$05269,$0539B, dw $054CA,$055F5,$0571D,$05842,$05964,$05A82,$05B9D,$05CB4,$05DC7,$05ED7,$05FE3, dw $060EC,$061F1,$062F2,$063EF,$064E8,$065DD,$066CF,$067BD,$068A6,$0698C,$06A6D, dw $06B4A,$06C24,$06CF9,$06DCA,$06E96,$06F5F,$07023,$070E2,$0719E,$07255,$07307, dw $073B5,$0745F,$07504,$075A5,$07641,$076D9,$0776C,$077FA,$07884,$07909,$0798A, dw $07A05,$07A7D,$07AEF,$07B5D,$07BC5,$07C29,$07C89,$07CE3,$07D39,$07D8A,$07DD6, dw $07E1D,$07E5F,$07E9D,$07ED5,$07F09,$07F38,$07F62,$07F87,$07FA7,$07FC2,$07FD8, dw $07FE9,$07FF6,$07FFD NEWSYM regaccessbankr8 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,2000h jae .regs mov al,[wramdataa+ecx] ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .hiromsram mov al,ch ret .hiromsram cmp byte[SPC7110Enable],1 je near .spc7110ram cmp byte[SFXEnable],1 je .sfxram cmp byte[C4Enable],1 je near .c4ram cmp byte[OBCEnable],1 je near .c4ram and ebx,7Fh cmp bl,10h jb .dsp1 cmp bl,30h jae .hiromsramok xor al,al xor ebx,ebx ret .dsp1 xor al,al cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read8b .nodsp1 xor ebx,ebx ret .hiromsramok push ecx sub ecx,6000h and ecx,1fffh sub bl,30h shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankr8b pop ecx ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx pop ecx ret .c4ram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[C4RamR] call dword near [ebx+ecx*4] xor ebx,ebx pop ecx ret .spc7110ram push ecx sub ecx,6000h and ecx,1fffh shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankr8b pop ecx ret NEWSYM regaccessbankr16 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,1FFFh jae .regs mov ax,[wramdataa+ecx] ret .regs cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptr] ; call dword near [ebx] call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptr] ; call dword near [ebx] call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret .invaccess ; jmp regexiter cmp ecx,6000h jae .hiromsram mov al,ch mov ah,ch ret .hiromsram cmp byte[SPC7110Enable],1 je near .spc7110ram cmp byte[SFXEnable],1 je .sfxram cmp byte[C4Enable],1 je near .c4ram cmp byte[OBCEnable],1 je near .c4ram and ebx,7Fh cmp bl,10h jb .dsp1 cmp bl,30h jae .hiromsramok xor ax,ax xor ebx,ebx ret .dsp1 xor ax,ax cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read16b .nodsp1 xor ebx,ebx ret .hiromsramok push ecx sub ecx,6000h and ecx,1fffh sub bl,30h shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankr16b pop ecx ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx pop ecx ret .c4ram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[C4RamR] inc ecx call dword near [ebx+ecx*4] dec ecx mov ah,al call dword near [ebx+ecx*4] xor ebx,ebx pop ecx ret .spc7110ram push ecx sub ecx,6000h and ecx,1fffh shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankr16b pop ecx ret NEWSYM regaccessbankw8 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs mov [wramdataa+ecx],al ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],al xor ebx,ebx ret .regs cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret .invaccess ; jmp regexiter cmp ecx,6000h jae .hiromsram ret .hiromsram cmp byte[SPC7110Enable],1 je near .spc7110ram cmp byte[SFXEnable],1 je .sfxram cmp byte[C4Enable],1 je near .c4ram cmp byte[OBCEnable],1 je near .c4ram and ebx,7Fh cmp bl,10h jb .dsp1 cmp bl,30h jae .hiromsramok xor ebx,ebx ret .dsp1 cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write8b .nodsp1 xor ebx,ebx ret .hiromsramok push ecx sub ecx,6000h and ecx,1fffh sub bl,30h shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankw8b pop ecx ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx pop ecx ret .c4ram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[C4RamW] call dword near [ebx+ecx*4] xor ebx,ebx pop ecx ret .spc7110ram push ecx sub ecx,6000h and ecx,1fffh shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankw8b pop ecx ret NEWSYM regaccessbankw16 test ecx,8000h jnz .romacc cmp ecx,1FFFh jae .regs mov [wramdataa+ecx],ax ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],ax xor ebx,ebx ret .regs cmp cx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret .invaccess ; jmp regexiter cmp ecx,6000h jae .hiromsram ret .hiromsram cmp byte[SPC7110Enable],1 je near .spc7110ram cmp byte[SFXEnable],1 je .sfxram cmp byte[C4Enable],1 je near .c4ram cmp byte[OBCEnable],1 je near .c4ram and ebx,7Fh cmp bl,10h jb .dsp1 cmp bl,30h jae .hiromsramok xor al,al xor ebx,ebx ret .dsp1 cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write16b .nodsp1 ret .hiromsramok push ecx sub ecx,6000h and ecx,1fffh sub bl,30h shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankw16b pop ecx ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx pop ecx ret .c4ram push ecx sub ecx,6000h and ecx,1fffh ; mov ebx,[C4Ram] ; mov [ebx+ecx],ax mov ebx,[C4RamW] push eax call dword near [ebx+ecx*4] inc ecx mov al,ah call dword near [ebx+ecx*4] pop eax dec ecx xor ebx,ebx pop ecx ret .spc7110ram push ecx sub ecx,6000h and ecx,1fffh shl ebx,13 add ecx,ebx and ecx,0FFFFh call sramaccessbankw16b pop ecx ret NEWSYM regaccessbankr8mp ret ;******************************************************* ; Register & Memory Bank (Bank 0) ;******************************************************* ; enter : BL = bank number, CX = address location ; leave : AL = value read EXTSYM BWShift,BWAndAddr,BWAnd,BWRAnd,SA1BWPtr %macro BWCheck 0 cmp byte[BWShift],0 jne near .shift .nosa1 %endmacro NEWSYM BWUsed2, db 0 NEWSYM BWUsed, db 0 %macro BWCheck2r8 0 .shift cmp byte[SA1Status],0 je .nosa1 ; mov byte[debstop3],1 ; value of 8Fh test byte[SA1Overflow+1],80h jnz .2bit push ecx push ebx sub ecx,6000h push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov al,0Fh shl al,cl add ebx,[SA1BWPtr] and al,[ebx] shr al,cl pop ebx pop ecx ret .2bit push ecx push ebx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov al,03h shl al,cl add ebx,[SA1BWPtr] and al,[ebx] shr al,cl pop ebx pop ecx ret %endmacro %macro BWCheck2r16 0 .shift cmp byte[SA1Status],0 je .nosa1 ; value of 8Fh test byte[SA1Overflow+1],80h jnz .2bit push ecx push ebx sub ecx,6000h push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov al,0Fh shl al,cl add ebx,[SA1BWPtr] and al,[ebx] shr al,cl pop ebx pop ecx push ecx push ebx sub ecx,6000h inc ecx push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov ah,0Fh shl ah,cl add ebx,[SA1BWPtr] and ah,[ebx] shr ah,cl pop ebx pop ecx ret .2bit push ecx push ebx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov al,03h shl al,cl add ebx,[SA1BWPtr] and al,[ebx] shr al,cl pop ebx pop ecx push ecx push ebx inc ecx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov ah,03h shl ah,cl add ebx,[SA1BWPtr] and ah,[ebx] shr ah,cl pop ebx pop ecx ret %endmacro %macro BWCheck2w8 0 .shift cmp byte[SA1Status],0 je .nosa1 test byte[SA1Overflow+1],80h jnz .2bit push ecx push ebx push edx sub ecx,6000h push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov dh,0Fh shl dh,cl xor dh,0FFh and al,0Fh shl al,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],al pop edx pop ebx pop ecx ret .2bit push ecx push ebx push edx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov dh,03h shl dh,cl xor dh,0FFh and al,03h shl al,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],al pop edx pop ebx pop ecx ret %endmacro %macro BWCheck2w16 0 .shift cmp byte[SA1Status],0 je .nosa1 test byte[SA1Overflow+1],80h jnz .2bit push eax push ecx push ebx push edx sub ecx,6000h push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov dh,0Fh shl dh,cl xor dh,0FFh and al,0Fh shl al,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],al pop edx pop ebx pop ecx pop eax push ecx push ebx push edx inc ecx sub ecx,6000h push eax mov eax,ecx and eax,01h shl eax,2 shr ecx,1 mov ebx,ecx mov cl,al pop eax mov dh,0Fh shl dh,cl xor dh,0FFh and ah,0Fh shl ah,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],ah pop edx pop ebx pop ecx ret .2bit push eax push ecx push ebx push edx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov dh,03h shl dh,cl xor dh,0FFh and al,03h shl al,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],al pop edx pop ebx pop ecx pop eax push ecx push ebx push edx inc ecx sub ecx,6000h push eax mov eax,ecx and eax,03h shl eax,1 shr ecx,2 mov ebx,ecx mov cl,al pop eax mov dh,03h shl dh,cl xor dh,0FFh and ah,03h shl ah,cl add ebx,[SA1BWPtr] and byte[ebx],dh or byte[ebx],ah pop edx pop ebx pop ecx ret %endmacro %macro writetobank0table 2 mov ebx,%1 mov ecx,%2 %%loop mov [eax],ebx add eax,4 loop %%loop %endmacro NEWSYM DPageR8, dd 0 NEWSYM DPageR16, dd 0 NEWSYM DPageW8, dd 0 NEWSYM DPageW16, dd 0 NEWSYM SA1DPageR8, dd 0 NEWSYM SA1DPageR16, dd 0 NEWSYM SA1DPageW8, dd 0 NEWSYM SA1DPageW16, dd 0 NEWSYM UpdateDPage push eax xor eax,eax mov al,[xd+1] push ecx mov ecx,[Bank0datr8+eax*4] mov [DPageR8],ecx mov ecx,[Bank0datr16+eax*4] mov [DPageR16],ecx mov ecx,[Bank0datw8+eax*4] mov [DPageW8],ecx mov ecx,[Bank0datw16+eax*4] mov [DPageW16],ecx pop ecx pop eax ret NEWSYM SA1UpdateDPage push eax xor eax,eax mov al,[SA1xd+1] push ecx mov ecx,[Bank0datr8+eax*4] mov [SA1DPageR8],ecx mov ecx,[Bank0datr16+eax*4] mov [SA1DPageR16],ecx mov ecx,[Bank0datw8+eax*4] mov [SA1DPageW8],ecx mov ecx,[Bank0datw16+eax*4] mov [SA1DPageW16],ecx pop ecx pop eax ret NEWSYM GenerateBank0Table mov eax,Bank0datr8 writetobank0table membank0r8ram,20h writetobank0table membank0r8reg,28h writetobank0table membank0r8inv,17h writetobank0table membank0r8chip,1Fh writetobank0table membank0r8rom,81h writetobank0table membank0r8romram,1h mov eax,Bank0datw8 writetobank0table membank0w8ram,20h writetobank0table membank0w8reg,28h writetobank0table membank0w8inv,17h writetobank0table membank0w8chip,1Fh writetobank0table membank0w8rom,81h writetobank0table membank0w8romram,1h mov eax,Bank0datr16 writetobank0table membank0r16ram,1Fh writetobank0table membank0r16ramh,1 writetobank0table membank0r16reg,28h writetobank0table membank0r16inv,17h writetobank0table membank0r16chip,1Fh writetobank0table membank0r16rom,81h writetobank0table membank0r16romram,1h mov eax,Bank0datw16 writetobank0table membank0w16ram,1Fh writetobank0table membank0w16ramh,1 writetobank0table membank0w16reg,28h writetobank0table membank0w16inv,17h writetobank0table membank0w16chip,1Fh writetobank0table membank0w16rom,81h writetobank0table membank0w16romram,1h ret NEWSYM GenerateBank0TableSA1 mov eax,Bank0datr8 writetobank0table membank0r8ramSA1,20h mov eax,Bank0datw8 writetobank0table membank0w8ramSA1,20h mov eax,Bank0datr16 writetobank0table membank0r16ramSA1,20h mov eax,Bank0datw16 writetobank0table membank0w16ramSA1,20h ret ; SA1 Stuff NEWSYM membank0r8ramSA1 ; 0000-1FFF cmp byte[SA1Status],0 jne .nowram mov al,[wramdataa+ecx+ebx] ret .nowram cmp ecx,800h jae .invaccess mov al,[IRAM+ecx+ebx] ret .invaccess xor al,al ret NEWSYM membank0r16ramSA1 ; 0000-1FFF cmp byte[SA1Status],0 jne .nowram mov ax,[wramdataa+ecx+ebx] ret .nowram cmp ecx,800h jae .invaccess mov ax,[IRAM+ecx+ebx] ret .invaccess xor ax,ax ret NEWSYM membank0w8ramSA1 ; 0000-1FFF cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx+ebx],al ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx+ebx],al .invaccess ret NEWSYM membank0w16ramSA1 ; 0000-1FFF cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx+ebx],ax ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx+ebx],ax .invaccess ret ; --- 8 BIT READ STUFF --- NEWSYM membank0r8ram ; 0000-1FFF mov al,[wramdataa+ebx+ecx] ret NEWSYM membank0r8reg ; 2000-48FF add ecx,ebx call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret NEWSYM membank0r8inv ; 4800-5FFF add ecx,ebx mov al,ch ret NEWSYM membank0r8chip ; 6000-7FFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram xor al,al cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read8b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx pop ecx ret .sa1ram BWCheck mov ebx,[CurBWPtr] mov al,[ebx+ecx] xor ebx,ebx ret BWCheck2r8 NEWSYM membank0r8rom ; 8000-FFFF add ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret NEWSYM membank0r8romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov al,[wramdataa+ecx] ret .rom mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret ; --- 16 BIT READ STUFF --- NEWSYM membank0r16ram ; 0000-1EFF mov ax,[wramdataa+ebx+ecx] ret NEWSYM membank0r16ramh ; 1F00-1FFF add ecx,ebx cmp ecx,1FFFh je .over mov ax,[wramdataa+ecx] ret .over mov al,[wramdataa+ecx] xor ah,ah ret NEWSYM membank0r16reg ; 2000-48FF add ecx,ebx call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret NEWSYM membank0r16inv ; 4800-5FFF add ecx,ebx mov al,ch mov ah,ch mov ax,8080h ret NEWSYM membank0r16chip ; 6000-FFFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram xor ax,ax cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read16b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx pop ecx ret .sa1ram BWCheck mov ebx,[CurBWPtr] mov ax,[ebx+ecx] xor ebx,ebx ret BWCheck2r16 NEWSYM membank0r16rom ; 8000-FFFF add ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret NEWSYM membank0r16romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov ax,[wramdataa+ecx] ret .rom mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret ; --- 8 BIT WRITE STUFF --- NEWSYM membank0w8ram ; 0000-1FFF mov [wramdataa+ebx+ecx],al ret NEWSYM membank0w8reg ; 2000-48FF add ecx,ebx call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret NEWSYM membank0w8inv ; 4800-5FFF ret NEWSYM membank0w8chip ; 6000-FFFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write8b .nodsp1 ret .sfxram push ecx sub cx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx pop ecx ret .sa1ram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],al xor ebx,ebx ret BWCheck2w8 NEWSYM membank0w8rom ; 8000-FFFF ret NEWSYM membank0w8romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov [wramdataa+ecx],al ret .rom ret ; --- 16 BIT WRITE STUFF --- NEWSYM membank0w16ram ; 0000-1EFF mov [wramdataa+ebx+ecx],ax ret NEWSYM membank0w16ramh ; 1F00-1FFF add ecx,ebx cmp ecx,1FFFh je .over mov [wramdataa+ecx],ax ret .over mov [wramdataa+ecx],al ret NEWSYM membank0w16reg ; 2000-48FF add ecx,ebx call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret NEWSYM membank0w16inv ; 4800-5FFF ret NEWSYM membank0w16chip ; 6000-FFFF add ecx,ebx NEWSYM membank0w16rom ; 8000-FFFF cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write16b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx pop ecx ret .sa1ram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],ax xor ebx,ebx ret BWCheck2w16 NEWSYM membank0w16romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov [wramdataa+ecx],ax ret .rom ret NEWSYM membank0r8 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0r8SA1 cmp ecx,2000h jae .regs mov al,[wramdataa+ecx] ret .regs test ecx,8000h jz .regacc mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptr] ; call dword near [ebx] call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .dsp1 mov al,ch ret .dsp1 cmp byte[SFXEnable],1 je .sfxram xor al,al cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read8b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx pop ecx ret NEWSYM membank0r16 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0r16SA1 cmp ecx,2000h jae .regs mov ax,[wramdataa+ecx] ret .regs test ecx,8000h jz .regacc mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptr] ; call dword near [ebx] call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptr] ; call dword near [ebx] call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret .invaccess cmp ecx,6000h jae .dsp1 xor ax,ax ret .dsp1 cmp byte[SFXEnable],1 je .sfxram xor ax,ax cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read16b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx pop ecx ret NEWSYM membank0w8 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0w8SA1 cmp ecx,2000h jae .regs mov [wramdataa+ecx],al ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap] mov [ebx+ecx],al xor ebx,ebx ret .regs test ecx,8000h jnz .romacc cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .dsp1 ret .dsp1 cmp byte[SFXEnable],1 je .sfxram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write8b .nodsp1 ret .sfxram push ecx sub cx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx pop ecx ret NEWSYM membank0w16 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0w16SA1 cmp ecx,2000h jae .regs mov [wramdataa+ecx],ax ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap] mov [ebx+ecx],ax xor ebx,ebx ret .regs test ecx,8000h jnz .romacc cmp ecx,48FFh ja .invaccess ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah ; mov ebx,ecx ; shl ebx,2 ; add ebx,[regptw] ; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret .invaccess cmp ecx,6000h jae .dsp1 ret .dsp1 cmp byte[SFXEnable],1 je .sfxram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write16b .nodsp1 ret .sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx pop ecx ret NEWSYM membank0r8SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov al,[wramdataa+ecx] ret .nowram cmp ecx,800h jae .invaccess mov al,[IRAM+ecx] ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram xor al,al ret .bwram BWCheck mov ebx,[CurBWPtr] mov al,[ebx+ecx] xor ebx,ebx ret BWCheck2r8 NEWSYM membank0r16SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov ax,[wramdataa+ecx] ret .nowram cmp ecx,800h jae .invaccess mov ax,[IRAM+ecx] ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram xor ax,ax ret .bwram BWCheck mov ebx,[CurBWPtr] mov ax,[ebx+ecx] xor ebx,ebx ret BWCheck2r16 NEWSYM membank0w8SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],al ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],al ret .romacc ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram ret .bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],al xor ebx,ebx ret BWCheck2w8 NEWSYM membank0w16SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],ax ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],ax ret .romacc ret .regs cmp cx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram ret .bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],ax xor ebx,ebx ret BWCheck2w16 ;******************************************************* ; ROM Only Access Banks (40 - 6F) / (C0 - FF) ;******************************************************* %macro TestSDD1 0 cmp ebx,0DAh jne %%nobank cmp ecx,1C01h jbe %%nobank cmp ecx,[LatestBank] ja %%nobank mov [LatestBank],ecx %%nobank %endmacro NEWSYM memaccessspc7110r8 xor al,al push ebx xor ebx,ebx mov bx,[SPCDecmPtr] add ebx,[romdata] add ebx,510000h mov al,[ebx] pop ebx dec word[SPCCompCounter] inc dword[SPCCompPtr] inc word[SPCDecmPtr] inc word[CurDecompSize] ret ; mov byte[debstop3],1 mov ebx,[romdata] add ebx,510000h mov al,[ebx+ecx] cmp cx,[CurDecompPtr] jb .noptr mov [CurDecompPtr],cx mov bx,cx sub bx,[PrevDecompPtr] inc bx mov [CurDecompSize],bx .noptr xor ebx,ebx ret NEWSYM memaccessspc7110r16 ; mov byte[debstop3],1 mov ebx,[romdata] add ebx,510000h mov ax,[ebx+ecx] cmp cx,[CurDecompPtr] jb .noptr mov [CurDecompPtr],cx mov bx,cx sub bx,[PrevDecompPtr] add bx,2 mov [CurDecompSize],bx .noptr xor ebx,ebx ret NEWSYM memaccessspc7110w8 mov ebx,[romdata] add ebx,510000h mov [ebx+ecx],al xor ebx,ebx ret NEWSYM memaccessspc7110w16 mov ebx,[romdata] add ebx,510000h mov [ebx+ecx],ax xor ebx,ebx ret NEWSYM memaccessbankr8 ; TestSDD1 mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx ret NEWSYM memaccessbankr16 ; TestSDD1 mov ebx,[snesmmap+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx ret NEWSYM memaccessbankw8 cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],al xor ebx,ebx ret NEWSYM memaccessbankw16 cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],ax xor ebx,ebx ret NEWSYM memaccessbankr848mb test ecx,8000h jz .map2 mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx ret .map2 mov ebx,[snesmap2+ebx*4] mov al,[ebx+ecx] xor ebx,ebx ret NEWSYM memaccessbankr1648mb test ecx,8000h jz .map2 mov ebx,[snesmmap+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx ret .map2 mov ebx,[snesmap2+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx ret ;******************************************************* ; SRAM Access Bank (70h) ;******************************************************* NEWSYM sramaccessbankr8 push ecx sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankr8b pop ecx ret NEWSYM sramaccessbankr16 push ecx sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankr16b pop ecx ret NEWSYM sramaccessbankw8 push ecx sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankw8b pop ecx ret NEWSYM sramaccessbankw16 push ecx sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankw16b pop ecx ret NEWSYM sramaccessbankr8s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankr8b pop ecx ret NEWSYM sramaccessbankr16s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankr16b pop ecx ret NEWSYM sramaccessbankw8s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankw8b pop ecx ret NEWSYM sramaccessbankw16s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankw16b pop ecx ret EXTSYM MMXSRAMFix NEWSYM sramaccessbankr8b cmp dword[ramsize],0 je .noaccess push ecx and ecx,[ramsizeand] mov ebx,[sram] mov al,[ebx+ecx] pop ecx xor ebx,ebx ret .noaccess cmp byte[MMXSRAMFix],1 je .MMXSRAMFix xor al,al xor ebx,ebx ret .MMXSRAMFix mov al,0FFh xor ebx,ebx ret NEWSYM sramaccessbankr16b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov al,[ebx+ecx] inc ecx and ecx,[ramsizeand] mov ah,[ebx+ecx] pop ecx xor ebx,ebx ret .noaccess cmp byte[MMXSRAMFix],1 je .MMXSRAMFix xor ax,ax xor ebx,ebx ret .MMXSRAMFix mov ax,0FFFFh xor ebx,ebx ret NEWSYM sramaccessbankw8b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov [ebx+ecx],al pop ecx mov dword[sramb4save],5*60 .noaccess xor ebx,ebx ret NEWSYM sramaccessbankw16b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov [ebx+ecx],al inc ecx and ecx,[ramsizeand] mov [ebx+ecx],ah pop ecx mov dword[sramb4save],5*60 .noaccess xor ebx,ebx ret ;******************************************************* ; WorkRAM/ExpandRAM Access Bank (7Eh) ;******************************************************* NEWSYM wramaccessbankr8 ; mov ebx,[wramdata] ; mov al,[ebx+ecx] ; xor ebx,ebx mov al,[wramdataa+ecx] ret NEWSYM wramaccessbankr16 ; mov ebx,[wramdata] ; mov ax,[ebx+ecx] ; xor ebx,ebx mov ax,[wramdataa+ecx] ret NEWSYM wramaccessbankw8 ; mov ebx,[wramdata] ; mov [ebx+ecx],al ; xor ebx,ebx mov [wramdataa+ecx],al ret NEWSYM wramaccessbankw16 ; mov ebx,[wramdata] ; mov [ebx+ecx],ax ; xor ebx,ebx mov [wramdataa+ecx],ax ret ;******************************************************* ; ExpandRAM Access Bank (7Fh) ;******************************************************* NEWSYM eramaccessbankr8 ; mov ebx,[ram7f] ; mov al,[ebx+ecx] ; xor ebx,ebx mov al,[ram7fa+ecx] ret NEWSYM eramaccessbankr16 ; mov ebx,[ram7f] ; mov ax,[ebx+ecx] ; xor ebx,ebx mov ax,[ram7fa+ecx] ret NEWSYM eramaccessbankw8 ; mov ebx,[ram7f] ; mov [ebx+ecx],al ; xor ebx,ebx mov [ram7fa+ecx],al ret NEWSYM eramaccessbankw16 ; mov ebx,[ram7f] ; mov [ebx+ecx],ax ; xor ebx,ebx mov [ram7fa+ecx],ax ret ;******************************************************* ; Invalid Access Bank (710000h-7DFFFFh) ;******************************************************* NEWSYM invaccessbank xor eax,eax mov byte[invalid],1 mov [invopcd],bl mov al,[previdmode] mov ah,0 int 10h mov ah,9 mov edx,.invalidbank int 21h xor eax,eax mov al,[invopcd] call printhex8 mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h jmp DosExit .invalidbank db 'Invalid Bank Access : $' ret ;******************************************************* ; SA-1 Bank Accesses ;******************************************************* NEWSYM regaccessbankr8SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov al,[wramdataa+ecx] ret .nowram cmp ecx,800h jae .invaccess mov al,[IRAM+ecx] ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram xor al,al ret .bwram BWCheck mov ebx,[CurBWPtr] mov al,[ebx+ecx] xor ebx,ebx ret BWCheck2r8 NEWSYM regaccessbankr16SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx ret .regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov ax,[wramdataa+ecx] ret .nowram cmp ecx,800h jae .invaccess mov ax,[IRAM+ecx] ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram xor ax,ax ret .bwram BWCheck mov ebx,[CurBWPtr] mov ax,[ebx+ecx] xor ebx,ebx ret BWCheck2r16 NEWSYM regaccessbankw8SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],al ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],al ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],al xor ebx,ebx ret .regs cmp ecx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram ret .bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],al xor ebx,ebx ret BWCheck2w8 NEWSYM regaccessbankw16SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],ax ret .nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],ax ret .romacc cmp byte[writeon],0 jne .modrom ret .modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],ax xor ebx,ebx ret .regs cmp cx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret .invaccess cmp ecx,6000h jae .bwram ret .bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],ax xor ebx,ebx ret BWCheck2w16 NEWSYM SA1RAMaccessbankr8 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx ret NEWSYM SA1RAMaccessbankr16 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov ax,[ebx+ecx] xor ebx,ebx ret NEWSYM SA1RAMaccessbankw8 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov [ebx+ecx],al xor ebx,ebx ret NEWSYM SA1RAMaccessbankw16 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov [ebx+ecx],ax xor ebx,ebx ret NEWSYM SA1RAMaccessbankr8b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx and al,0Fh ret .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx shr al,4 ret .2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 mov al,[ebx+ecx] and al,3 xor ebx,ebx ret .bit0 shr ecx,2 mov al,[ebx+ecx] shr al,2 and al,3 xor ebx,ebx ret .bit1 test ecx,1 jnz .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,4 and al,3 xor ebx,ebx ret .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,6 xor ebx,ebx ret NEWSYM SA1RAMaccessbankr16b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] and al,0Fh mov ah,[ebx+ecx] shr ah,4 xor ebx,ebx ret .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov ah,[ebx+ecx+1] and ah,0Fh mov al,[ebx+ecx] shr al,4 xor ebx,ebx ret .2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 mov al,[ebx+ecx] and al,3 mov ah,[ebx+ecx] shr ah,2 and ah,3 xor ebx,ebx ret .bit0 shr ecx,2 mov al,[ebx+ecx] shr al,2 and al,2 mov ah,[ebx+ecx] shr ah,4 and ah,3 xor ebx,ebx ret .bit1 test ecx,1 jnz .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,4 and al,3 mov ah,[ebx+ecx] shr ah,6 xor ebx,ebx ret .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,6 mov ah,[ebx+ecx+1] and ah,3 xor ebx,ebx ret NEWSYM SA1RAMaccessbankw8b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] and al,0Fh and byte[ebx+ecx],0F0h or byte[ebx+ecx],al xor ebx,ebx ret .4bitb shr ecx,1 add ebx,[SA1RAMArea] and al,0Fh shl al,4 and byte[ebx+ecx],0Fh or byte[ebx+ecx],al xor ebx,ebx ret .2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 and byte[ebx+ecx],0FCh and al,3 or byte[ebx+ecx],al xor ebx,ebx ret .bit0 shr ecx,2 and byte[ebx+ecx],0F3h and al,3 shl al,2 or byte[ebx+ecx],al xor ebx,ebx ret .bit1 test ecx,1 jnz .bit0b shr ecx,2 and byte[ebx+ecx],0CFh and al,3 shl al,4 or byte[ebx+ecx],al xor ebx,ebx ret .bit0b shr ecx,2 and byte[ebx+ecx],03Fh and al,3 shl al,6 or byte[ebx+ecx],al xor ebx,ebx ret NEWSYM SA1RAMaccessbankw16b push ecx push ebx call SA1RAMaccessbankw8b pop ebx pop ecx inc ecx mov al,ah call SA1RAMaccessbankw8b ret NEWSYM SDD1Array, times 65536 db 0 NEWSYM SDD1Entry, dd 0 NEWSYM SDD1EntryPtr, dd 0 %macro GetBankLog 1 cmp bl,0C0h jb %%illegal cmp bl,0D0h jb %%firstbank cmp bl,0E0h jb %%secondbank cmp bl,0F0h jb %%thirdbank mov %1,[SDD1BankA+3] jmp %%done %%firstbank mov %1,[SDD1BankA] jmp %%done %%secondbank mov %1,[SDD1BankA+1] jmp %%done %%thirdbank mov %1,[SDD1BankA+2] jmp %%done %%illegal mov %1,0Fh %%done %endmacro NEWSYM LatestBank, dd 0FFFFh NEWSYM memaccessbankr8sdd1 ; TestSDD1 ; jmp debugdecompress ; call FillArray mov byte[.found4],0 cmp byte[AddrNoIncr],0 je near .failed cmp dword[Sdd1Mode],2 je near .decompress mov [Sdd1Bank],ebx mov [Sdd1Addr],ecx mov [Sdd1NewAddr],ecx ; Start Actual Decompressor mov dword[Sdd1Mode],2 push edx push eax push ecx mov dword[SDD1EntryPtr],0 mov eax,ebx shl eax,16 mov ax,cx and eax,0FFFFFh shl eax,4 GetBankLog cl or al,cl cmp dx,8192 ;eax,4f1591h jbe .nota ; mov byte[debstop3],1 .nota mov ecx,[SPC7110Entries] mov edx,[spc7110romptr] or ecx,ecx jz .notfound .loop cmp dword[edx],eax je .found2 add edx,12 dec ecx jnz .loop jmp .notfound .found2 mov eax,[edx+4] mov [SDD1EntryPtr],eax mov byte[.found4],1 .notfound pop ecx pop eax pop edx push eax cmp byte[.found4],1 je near .nomore mov eax,[SDD1Entry] cmp eax,65536 je near .nomore push edx xor edx,edx or eax,eax jz .noentries .trynext cmp byte[SDD1Array+edx],bl jne .nomatch cmp byte[SDD1Array+edx+1],ch jne .nomatch cmp byte[SDD1Array+edx+2],cl jne .nomatch jmp .found .nomatch add edx,8 cmp edx,eax jne .trynext .noentries pop edx mov [SDD1Array+eax],bl mov [SDD1Array+eax+1],ch mov [SDD1Array+eax+2],cl mov [SDD1Array+eax+3],dh mov [SDD1Array+eax+4],dl push ebx GetBankLog bl cmp dword[SDD1EntryPtr],0 je .notthere or bl,0F0h .notthere mov [SDD1Array+eax+7],bl pop ebx add dword[SDD1Entry],8 .nomore pop eax jmp .decompress .found mov eax,edx pop edx push ebx mov ebx,eax mov al,[SDD1Array+ebx+4] mov ah,[SDD1Array+ebx+3] cmp ax,dx jae .notgreater mov [SDD1Array+ebx+4],dl mov [SDD1Array+ebx+3],dh .notgreater pop ebx pop eax .decompress cmp [Sdd1Bank],ebx jne .nomoredec cmp [Sdd1Addr],ecx je .yesdec .nomoredec mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] push eax mov eax,memtabler8+0C0h*4 mov ebx,40h .loopb mov dword[eax],memaccessbankr8 add eax,4 dec ebx jnz .loopb pop eax xor ebx,ebx ret .yesdec cmp dword[SDD1EntryPtr],0 je .nodecompress push ebx mov ebx,[SDD1EntryPtr] inc dword[SDD1EntryPtr] mov al,[ebx] pop ebx ret .nodecompress mov al,0FFh ret .failed push ebx call .nomoredec pop ebx jmp memaccessbankr8 ; Start Debug Decompressor .found4 db 0 FillArray: TestSDD1 push ecx push eax mov eax,[SDD1Entry] cmp eax,65536 je near .nomore push edx xor edx,edx or eax,eax jz .noentries .trynext cmp byte[SDD1Array+edx],bl jne .nomatch cmp byte[SDD1Array+edx+1],ch jne .nomatch cmp byte[SDD1Array+edx+2],cl jne .nomatch jmp .found .nomatch add edx,8 cmp edx,eax jne .trynext .noentries pop edx mov [SDD1Array+eax],bl mov [SDD1Array+eax+1],ch mov [SDD1Array+eax+2],cl mov [SDD1Array+eax+3],dh mov [SDD1Array+eax+4],dl push ebx GetBankLog bl mov [SDD1Array+eax+7],bl pop ebx add dword[SDD1Entry],8 .nomore pop eax jmp .decompress .found pop edx pop eax .decompress pop ecx ret debugdecompress: cmp byte[AddrNoIncr],0 je near .failed cmp dword[Sdd1Mode],2 je near .decompress TestSDD1 mov [Sdd1Bank],ebx mov [Sdd1Addr],ecx mov [Sdd1NewAddr],ecx mov dword[Sdd1Mode],2 ; jmp .decompress ; comment this out to activate array push eax mov eax,[SDD1Entry] cmp eax,65536 je near .nomore push edx xor edx,edx or eax,eax jz .noentries .trynext cmp byte[SDD1Array+edx],bl jne .nomatch cmp byte[SDD1Array+edx+1],ch jne .nomatch cmp byte[SDD1Array+edx+2],cl jne .nomatch jmp .found .nomatch add edx,8 cmp edx,eax jne .trynext .noentries pop edx mov [SDD1Array+eax],bl mov [SDD1Array+eax+1],ch mov [SDD1Array+eax+2],cl mov [SDD1Array+eax+3],dh mov [SDD1Array+eax+4],dl push ebx GetBankLog bl mov [SDD1Array+eax+7],bl pop ebx add dword[SDD1Entry],8 .nomore pop eax jmp .decompress .found pop edx pop eax .decompress cmp [Sdd1Bank],ebx jne .nomoredec cmp [Sdd1Addr],ecx je .yesdec .nomoredec mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] push eax mov eax,memtabler8+0C0h*4 mov ebx,40h .loop mov dword[eax],memaccessbankr8 add eax,4 dec ebx jnz .loop pop eax xor ebx,ebx ret .yesdec push ecx mov ecx,[Sdd1NewAddr] mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx inc word[Sdd1NewAddr] pop ecx ret .failed push ebx call .nomoredec pop ebx jmp memaccessbankr8 NEWSYM MemoryAsmEnd zsnes-1.36/src/cpu/regs.inc0100644000175000017500000010762407511720531015210 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM SFXEnable,regptr,initsfxregsr,initSA1regs,SA1Enable,initSDD1regs EXTSYM SPC7110Enable,initSPC7110regs,RTCEnable,RTCReset EXTSYM curypos,cycpl,debuggeron,pdh EXTSYM vram EXTSYM romispal EXTSYM reg1read,spcnumread,spcon EXTSYM reg2read EXTSYM reg3read EXTSYM reg4read EXTSYM JoyEOrig,JoyENow EXTSYM snesmouse EXTSYM cycphb,joycontren,totlines EXTSYM DosExit,invalid,numinst,previdmode,printhex,printnum NEWSYM initregr ; Fill register pointer with invalid register accesses mov edi,[regptr] add edi,8000h mov ecx,3000h mov eax,regINVALID .loopa mov [edi],eax add edi,4 dec ecx jnz .loopa ; Set all valid register accesses setreg 2100h*4,reg2100r setreg 2134h*4,reg2134r setreg 2135h*4,reg2135r setreg 2136h*4,reg2136r setreg 2137h*4,reg2137r setreg 2138h*4,reg2138r setreg 2139h*4,reg2139r setreg 213Ah*4,reg213Ar setreg 213Bh*4,reg213Br setreg 213Ch*4,reg213Cr setreg 213Dh*4,reg213Dr setreg 213Eh*4,reg213Er setreg 213Fh*4,reg213Fr setreg 2140h*4,reg2140r setreg 2141h*4,reg2141r setreg 2142h*4,reg2142r setreg 2143h*4,reg2143r setreg 2144h*4,reg2140r setreg 2180h*4,reg2180r setreg 2A00h*4,reg2Axxr setreg 2A01h*4,reg2Axxr setreg 2A02h*4,reg2Axxr setreg 2A03h*4,reg2Axxr setreg 2A04h*4,reg2Axxr setreg 2A05h*4,reg2Axxr setreg 2A06h*4,reg2Axxr setreg 2A07h*4,reg2Axxr setreg 2A08h*4,reg2Axxr setreg 2A09h*4,reg2Axxr setreg 2A0Ah*4,reg2Axxr setreg 2A0Bh*4,reg2Axxr setreg 2A0Ch*4,reg2Axxr setreg 2A0Dh*4,reg2Axxr setreg 2A0Eh*4,reg2Axxr setreg 2A0Fh*4,reg2Axxr setreg 2A10h*4,reg2Axxr setreg 2A11h*4,reg2Axxr setreg 2A12h*4,reg2Axxr setreg 2A13h*4,reg2Axxr setreg 2A14h*4,reg2Axxr setreg 2A15h*4,reg2Axxr setreg 2A16h*4,reg2Axxr setreg 2A17h*4,reg2Axxr setreg 2A18h*4,reg2Axxr setreg 2A19h*4,reg2Axxr setreg 2A1Ah*4,reg2Axxr setreg 2A1Bh*4,reg2Axxr setreg 2A1Ch*4,reg2Axxr setreg 2A1Dh*4,reg2Axxr setreg 2A1Eh*4,reg2Axxr setreg 2A1Fh*4,reg2Axxr setreg 2A20h*4,reg2Axxr setreg 2A21h*4,reg2Axxr setreg 2A22h*4,reg2Axxr setreg 2A23h*4,reg2Axxr setreg 2A24h*4,reg2Axxr setreg 2A25h*4,reg2Axxr setreg 2A26h*4,reg2Axxr setreg 2A27h*4,reg2Axxr setreg 2A28h*4,reg2Axxr setreg 2A29h*4,reg2Axxr setreg 2A2Ah*4,reg2Axxr setreg 2A2Bh*4,reg2Axxr setreg 2A2Ch*4,reg2Axxr setreg 2A2Dh*4,reg2Axxr setreg 2A2Eh*4,reg2Axxr setreg 2A2Fh*4,reg2Axxr setreg 2A30h*4,reg2Axxr setreg 2A31h*4,reg2Axxr setreg 2A32h*4,reg2Axxr setreg 2A33h*4,reg2Axxr setreg 2A34h*4,reg2Axxr setreg 2A35h*4,reg2Axxr setreg 2A36h*4,reg2Axxr setreg 2A37h*4,reg2Axxr setreg 2A38h*4,reg2Axxr setreg 2A39h*4,reg2Axxr setreg 2A3Ah*4,reg2Axxr setreg 2A3Bh*4,reg2Axxr setreg 2A3Ch*4,reg2Axxr setreg 2A3Dh*4,reg2Axxr setreg 2A3Eh*4,reg2Axxr setreg 2A3Fh*4,reg2Axxr setreg 2A40h*4,reg2Axxr setreg 2A41h*4,reg2Axxr setreg 2A42h*4,reg2Axxr setreg 2A43h*4,reg2Axxr setreg 2A44h*4,reg2Axxr setreg 2A45h*4,reg2Axxr setreg 2A46h*4,reg2Axxr setreg 2A47h*4,reg2Axxr setreg 2A48h*4,reg2Axxr setreg 2A49h*4,reg2Axxr setreg 2A4Ah*4,reg2Axxr setreg 2A4Bh*4,reg2Axxr setreg 2A4Ch*4,reg2Axxr setreg 2A4Dh*4,reg2Axxr setreg 2A4Eh*4,reg2Axxr setreg 2A4Fh*4,reg2Axxr setreg 2A50h*4,reg2Axxr setreg 2A51h*4,reg2Axxr setreg 2A52h*4,reg2Axxr setreg 2A53h*4,reg2Axxr setreg 2A54h*4,reg2Axxr setreg 2A55h*4,reg2Axxr setreg 2A56h*4,reg2Axxr setreg 2A57h*4,reg2Axxr setreg 2A58h*4,reg2Axxr setreg 2A59h*4,reg2Axxr setreg 2A5Ah*4,reg2Axxr setreg 2A5Bh*4,reg2Axxr setreg 2A5Ch*4,reg2Axxr setreg 2A5Dh*4,reg2Axxr setreg 2A5Eh*4,reg2Axxr setreg 2A5Fh*4,reg2Axxr setreg 2A60h*4,reg2Axxr setreg 2A61h*4,reg2Axxr setreg 2A62h*4,reg2Axxr setreg 2A63h*4,reg2Axxr setreg 2A64h*4,reg2Axxr setreg 2A65h*4,reg2Axxr setreg 2A66h*4,reg2Axxr setreg 2A67h*4,reg2Axxr setreg 2A68h*4,reg2Axxr setreg 2A69h*4,reg2Axxr setreg 2A6Ah*4,reg2Axxr setreg 2A6Bh*4,reg2Axxr setreg 2A6Ch*4,reg2Axxr setreg 2A6Dh*4,reg2Axxr setreg 2A6Eh*4,reg2Axxr setreg 2A6Fh*4,reg2Axxr setreg 2A70h*4,reg2Axxr setreg 2A71h*4,reg2Axxr setreg 2A72h*4,reg2Axxr setreg 2A73h*4,reg2Axxr setreg 2A74h*4,reg2Axxr setreg 2A75h*4,reg2Axxr setreg 2A76h*4,reg2Axxr setreg 2A77h*4,reg2Axxr setreg 2A78h*4,reg2Axxr setreg 2A79h*4,reg2Axxr setreg 2A7Ah*4,reg2Axxr setreg 2A7Bh*4,reg2Axxr setreg 2A7Ch*4,reg2Axxr setreg 2A7Dh*4,reg2Axxr setreg 2A7Eh*4,reg2Axxr setreg 2A7Fh*4,reg2Axxr setreg 2A80h*4,reg2Axxr setreg 2A81h*4,reg2Axxr setreg 2A82h*4,reg2Axxr setreg 2A83h*4,reg2Axxr setreg 2A84h*4,reg2Axxr setreg 2A85h*4,reg2Axxr setreg 2A86h*4,reg2Axxr setreg 2A87h*4,reg2Axxr setreg 2A88h*4,reg2Axxr setreg 2A89h*4,reg2Axxr setreg 2A8Ah*4,reg2Axxr setreg 2A8Bh*4,reg2Axxr setreg 2A8Ch*4,reg2Axxr setreg 2A8Dh*4,reg2Axxr setreg 2A8Eh*4,reg2Axxr setreg 2A8Fh*4,reg2Axxr setreg 2A90h*4,reg2Axxr setreg 2A91h*4,reg2Axxr setreg 2A92h*4,reg2Axxr setreg 2A93h*4,reg2Axxr setreg 2A94h*4,reg2Axxr setreg 2A95h*4,reg2Axxr setreg 2A96h*4,reg2Axxr setreg 2A97h*4,reg2Axxr setreg 2A98h*4,reg2Axxr setreg 2A99h*4,reg2Axxr setreg 2A9Ah*4,reg2Axxr setreg 2A9Bh*4,reg2Axxr setreg 2A9Ch*4,reg2Axxr setreg 2A9Dh*4,reg2Axxr setreg 2A9Eh*4,reg2Axxr setreg 2A9Fh*4,reg2Axxr setreg 2AA0h*4,reg2Axxr setreg 2AA1h*4,reg2Axxr setreg 2AA2h*4,reg2Axxr setreg 2AA3h*4,reg2Axxr setreg 2AA4h*4,reg2Axxr setreg 2AA5h*4,reg2Axxr setreg 2AA6h*4,reg2Axxr setreg 2AA7h*4,reg2Axxr setreg 2AA8h*4,reg2Axxr setreg 2AA9h*4,reg2Axxr setreg 2AAAh*4,reg2Axxr setreg 2AABh*4,reg2Axxr setreg 2AACh*4,reg2Axxr setreg 2AADh*4,reg2Axxr setreg 2AAEh*4,reg2Axxr setreg 2AAFh*4,reg2Axxr setreg 2AB0h*4,reg2Axxr setreg 2AB1h*4,reg2Axxr setreg 2AB2h*4,reg2Axxr setreg 2AB3h*4,reg2Axxr setreg 2AB4h*4,reg2Axxr setreg 2AB5h*4,reg2Axxr setreg 2AB6h*4,reg2Axxr setreg 2AB7h*4,reg2Axxr setreg 2AB8h*4,reg2Axxr setreg 2AB9h*4,reg2Axxr setreg 2ABAh*4,reg2Axxr setreg 2ABBh*4,reg2Axxr setreg 2ABCh*4,reg2Axxr setreg 2ABDh*4,reg2Axxr setreg 2ABEh*4,reg2Axxr setreg 2ABFh*4,reg2Axxr setreg 2AC0h*4,reg2Axxr setreg 2AC1h*4,reg2Axxr setreg 2AC2h*4,reg2Axxr setreg 2AC3h*4,reg2Axxr setreg 2AC4h*4,reg2Axxr setreg 2AC5h*4,reg2Axxr setreg 2AC6h*4,reg2Axxr setreg 2AC7h*4,reg2Axxr setreg 2AC8h*4,reg2Axxr setreg 2AC9h*4,reg2Axxr setreg 2ACAh*4,reg2Axxr setreg 2ACBh*4,reg2Axxr setreg 2ACCh*4,reg2Axxr setreg 2ACDh*4,reg2Axxr setreg 2ACEh*4,reg2Axxr setreg 2ACFh*4,reg2Axxr setreg 2AD0h*4,reg2Axxr setreg 2AD1h*4,reg2Axxr setreg 2AD2h*4,reg2Axxr setreg 2AD3h*4,reg2Axxr setreg 2AD4h*4,reg2Axxr setreg 2AD5h*4,reg2Axxr setreg 2AD6h*4,reg2Axxr setreg 2AD7h*4,reg2Axxr setreg 2AD8h*4,reg2Axxr setreg 2AD9h*4,reg2Axxr setreg 2ADAh*4,reg2Axxr setreg 2ADBh*4,reg2Axxr setreg 2ADCh*4,reg2Axxr setreg 2ADDh*4,reg2Axxr setreg 2ADEh*4,reg2Axxr setreg 2ADFh*4,reg2Axxr setreg 2AE0h*4,reg2Axxr setreg 2AE1h*4,reg2Axxr setreg 2AE2h*4,reg2Axxr setreg 2AE3h*4,reg2Axxr setreg 2AE4h*4,reg2Axxr setreg 2AE5h*4,reg2Axxr setreg 2AE6h*4,reg2Axxr setreg 2AE7h*4,reg2Axxr setreg 2AE8h*4,reg2Axxr setreg 2AE9h*4,reg2Axxr setreg 2AEAh*4,reg2Axxr setreg 2AEBh*4,reg2Axxr setreg 2AECh*4,reg2Axxr setreg 2AEDh*4,reg2Axxr setreg 2AEEh*4,reg2Axxr setreg 2AEFh*4,reg2Axxr setreg 2AF0h*4,reg2Axxr setreg 2AF1h*4,reg2Axxr setreg 2AF2h*4,reg2Axxr setreg 2AF3h*4,reg2Axxr setreg 2AF4h*4,reg2Axxr setreg 2AF5h*4,reg2Axxr setreg 2AF6h*4,reg2Axxr setreg 2AF7h*4,reg2Axxr setreg 2AF8h*4,reg2Axxr setreg 2AF9h*4,reg2Axxr setreg 2AFAh*4,reg2Axxr setreg 2AFBh*4,reg2Axxr setreg 2AFCh*4,reg2Axxr setreg 2AFDh*4,reg2Axxr setreg 2AFEh*4,reg2Axxr setreg 2AFFh*4,reg2Axxr setreg 4016h*4,reg4016r setreg 4017h*4,reg4017r setreg 4100h*4,reg4100r setreg 420Ah*4,reg420Ar setreg 420Bh*4,reg420Br setreg 420Ch*4,reg420Cr setreg 420Dh*4,reg420Dr setreg 420Eh*4,reg420Er setreg 420Fh*4,reg420Fr setreg 4210h*4,reg4210r setreg 4211h*4,reg4211r setreg 4212h*4,reg4212r setreg 4213h*4,reg4213r setreg 4214h*4,reg4214r setreg 4215h*4,reg4215r setreg 4216h*4,reg4216r setreg 4217h*4,reg4217r setreg 4218h*4,reg4218r setreg 4219h*4,reg4219r setreg 421Ah*4,reg421Ar setreg 421Bh*4,reg421Br setreg 421Ch*4,reg421Cr setreg 421Dh*4,reg421Dr setreg 421Eh*4,reg421Er setreg 421Fh*4,reg421Fr setreg 4300h*4,reg43XXr setreg 4301h*4,reg43XXr setreg 4302h*4,reg43XXr setreg 4303h*4,reg43XXr setreg 4304h*4,reg43XXr setreg 4305h*4,reg43XXr setreg 4306h*4,reg43XXr setreg 4307h*4,reg43XXr setreg 4308h*4,reg43XXr setreg 4309h*4,reg43XXr setreg 430Ah*4,reg43XXr setreg 430Bh*4,reg43XXr setreg 430Ch*4,reg43XXr setreg 430Dh*4,reg43XXr setreg 430Eh*4,reg43XXr setreg 430Fh*4,reg43XXr setreg 4310h*4,reg43XXr setreg 4311h*4,reg43XXr setreg 4312h*4,reg43XXr setreg 4313h*4,reg43XXr setreg 4314h*4,reg43XXr setreg 4315h*4,reg43XXr setreg 4316h*4,reg43XXr setreg 4317h*4,reg43XXr setreg 4318h*4,reg43XXr setreg 4319h*4,reg43XXr setreg 431Ah*4,reg43XXr setreg 431Bh*4,reg43XXr setreg 431Ch*4,reg43XXr setreg 431Dh*4,reg43XXr setreg 431Eh*4,reg43XXr setreg 431Fh*4,reg43XXr setreg 4320h*4,reg43XXr setreg 4321h*4,reg43XXr setreg 4322h*4,reg43XXr setreg 4323h*4,reg43XXr setreg 4324h*4,reg43XXr setreg 4325h*4,reg43XXr setreg 4326h*4,reg43XXr setreg 4327h*4,reg43XXr setreg 4328h*4,reg43XXr setreg 4329h*4,reg43XXr setreg 432Ah*4,reg43XXr setreg 432Bh*4,reg43XXr setreg 432Ch*4,reg43XXr setreg 432Dh*4,reg43XXr setreg 432Eh*4,reg43XXr setreg 432Fh*4,reg43XXr setreg 4330h*4,reg43XXr setreg 4331h*4,reg43XXr setreg 4332h*4,reg43XXr setreg 4333h*4,reg43XXr setreg 4334h*4,reg43XXr setreg 4335h*4,reg43XXr setreg 4336h*4,reg43XXr setreg 4337h*4,reg43XXr setreg 4338h*4,reg43XXr setreg 4339h*4,reg43XXr setreg 433Ah*4,reg43XXr setreg 433Bh*4,reg43XXr setreg 433Ch*4,reg43XXr setreg 433Dh*4,reg43XXr setreg 433Eh*4,reg43XXr setreg 433Fh*4,reg43XXr setreg 4340h*4,reg43XXr setreg 4341h*4,reg43XXr setreg 4342h*4,reg43XXr setreg 4343h*4,reg43XXr setreg 4344h*4,reg43XXr setreg 4345h*4,reg43XXr setreg 4346h*4,reg43XXr setreg 4347h*4,reg43XXr setreg 4348h*4,reg43XXr setreg 4349h*4,reg43XXr setreg 434Ah*4,reg43XXr setreg 434Bh*4,reg43XXr setreg 434Ch*4,reg43XXr setreg 434Dh*4,reg43XXr setreg 434Eh*4,reg43XXr setreg 434Fh*4,reg43XXr setreg 4350h*4,reg43XXr setreg 4351h*4,reg43XXr setreg 4352h*4,reg43XXr setreg 4353h*4,reg43XXr setreg 4354h*4,reg43XXr setreg 4355h*4,reg43XXr setreg 4356h*4,reg43XXr setreg 4357h*4,reg43XXr setreg 4358h*4,reg43XXr setreg 4359h*4,reg43XXr setreg 435Ah*4,reg43XXr setreg 435Bh*4,reg43XXr setreg 435Ch*4,reg43XXr setreg 435Dh*4,reg43XXr setreg 435Eh*4,reg43XXr setreg 435Fh*4,reg43XXr setreg 4360h*4,reg43XXr setreg 4361h*4,reg43XXr setreg 4362h*4,reg43XXr setreg 4363h*4,reg43XXr setreg 4364h*4,reg43XXr setreg 4365h*4,reg43XXr setreg 4366h*4,reg43XXr setreg 4367h*4,reg43XXr setreg 4368h*4,reg43XXr setreg 4369h*4,reg43XXr setreg 436Ah*4,reg43XXr setreg 436Bh*4,reg43XXr setreg 436Ch*4,reg43XXr setreg 436Dh*4,reg43XXr setreg 436Eh*4,reg43XXr setreg 436Fh*4,reg43XXr setreg 4370h*4,reg43XXr setreg 4371h*4,reg43XXr setreg 4372h*4,reg43XXr setreg 4373h*4,reg43XXr setreg 4374h*4,reg43XXr setreg 4375h*4,reg43XXr setreg 4376h*4,reg43XXr setreg 4377h*4,reg43XXr setreg 4378h*4,reg43XXr setreg 4379h*4,reg43XXr setreg 437Ah*4,reg43XXr setreg 437Bh*4,reg43XXr setreg 437Ch*4,reg43XXr setreg 437Dh*4,reg43XXr setreg 437Eh*4,reg43XXr setreg 437Fh*4,reg43XXr cmp byte[SFXEnable],0 je .nosfx call initsfxregsr .nosfx cmp byte[SA1Enable],0 je .nosa1 call initSA1regs .nosa1 cmp byte[SDD1Enable],0 je .nosdd1 call initSDD1regs .nosdd1 cmp byte[SPC7110Enable],0 je .nospc7110 call initSPC7110regs .nospc7110 cmp byte[RTCEnable],0 je .noRTC call RTCReset .noRTC ret ; global variables NEWSYM invreg, dw 0 NEWSYM sndrot, db 0 ; rotates to use A,X or Y for sound skip NEWSYM sndrot2, db 0 ; rotates a random value for sound skip NEWSYM INTEnab, db 0 ; enables NMI(7)/VIRQ(5)/HIRQ(4)/JOY(0) NEWSYM NMIEnab, db 1 ; controlled in e65816 loop. Sets to 81h NEWSYM VIRQLoc, dw 0 ; VIRQ Y location NEWSYM vidbright, db 0 ; screen brightness (0 .. 15) NEWSYM previdbr, db 0 ; previous screen brightness NEWSYM forceblnk, db 80h ; force blanking on/off ($80=on) NEWSYM objptr, dd 0 ; pointer to object data in VRAM NEWSYM objptrn, dd 0 ; pointer2 to object data in VRAM NEWSYM objsize1, db 1 ; 1 = 8dot, 4=16 dot, 16=32 dot, 64=64dot NEWSYM objsize2, db 4 ; large object size NEWSYM objmovs1, db 2 ; number of bytes to move/paragraph NEWSYM objadds1, dw 14 ; number of bytes to add/paragraph NEWSYM objmovs2, db 2 ; number of bytes to move/paragraph NEWSYM objadds2, dw 14 ; number of bytes to add/paragraph NEWSYM oamaddrt, dw 0 ; oam address NEWSYM oamaddrs, dw 0 ; oam address at beginning of vblank NEWSYM objhipr, db 0 ; highest priority object # NEWSYM bgmode, db 0 ; graphics mode ( 0 .. 7 ) NEWSYM bg3highst, db 0 ; is 1 if background 3 has the highest priority NEWSYM bgtilesz, db 0 ; 0 = 8x8, 1 = 16x16, bit 0=bg1,bit1=bg2,etc NEWSYM mosaicon, db 0 ; mosaic on, bit 0=bg1,bit1=bg2, etc NEWSYM mosaicsz, db 0 ; mosaic size in pixels NEWSYM bg1ptr, dw 0 ; pointer to background1 NEWSYM bg2ptr, dw 0 ; pointer to background2 NEWSYM bg3ptr, dw 0 ; pointer to background3 NEWSYM bg4ptr, dw 0 ; pointer to background4 NEWSYM bg1ptrb, dw 0 ; pointer to background1 NEWSYM bg2ptrb, dw 0 ; pointer to background2 NEWSYM bg3ptrb, dw 0 ; pointer to background3 NEWSYM bg4ptrb, dw 0 ; pointer to background4 NEWSYM bg1ptrc, dw 0 ; pointer to background1 NEWSYM bg2ptrc, dw 0 ; pointer to background2 NEWSYM bg3ptrc, dw 0 ; pointer to background3 NEWSYM bg4ptrc, dw 0 ; pointer to background4 NEWSYM bg1ptrd, dw 0 ; pointer to background1 NEWSYM bg2ptrd, dw 0 ; pointer to background2 NEWSYM bg3ptrd, dw 0 ; pointer to background3 NEWSYM bg4ptrd, dw 0 ; pointer to background4 NEWSYM bg1scsize, db 0 ; bg #1 screen size (0=1x1,1=1x2,2=2x1,3=2x2) NEWSYM bg2scsize, db 0 ; bg #2 screen size (0=1x1,1=1x2,2=2x1,3=2x2) NEWSYM bg3scsize, db 0 ; bg #3 screen size (0=1x1,1=1x2,2=2x1,3=2x2) NEWSYM bg4scsize, db 0 ; bg #4 screen size (0=1x1,1=1x2,2=2x1,3=2x2) NEWSYM bg1objptr, dw 0 ; pointer to tiles in background1 NEWSYM bg2objptr, dw 0 ; pointer to tiles in background2 NEWSYM bg3objptr, dw 0 ; pointer to tiles in background3 NEWSYM bg4objptr, dw 0 ; pointer to tiles in background4 NEWSYM bg1scrolx, dw 0 ; background 1 x position NEWSYM bg2scrolx, dw 0 ; background 2 x position NEWSYM bg3scrolx, dw 0 ; background 3 x position NEWSYM bg4scrolx, dw 0 ; background 4 x position NEWSYM bg1sx, dw 0 ; Temporary Variable for Debugging purposes NEWSYM bg1scroly, dw 0 ; background 1 y position NEWSYM bg2scroly, dw 0 ; background 2 y position NEWSYM bg3scroly, dw 0 ; background 3 y position NEWSYM bg4scroly, dw 0 ; background 4 y position NEWSYM addrincr, dw 2 ; vram increment (2,64,128,256) NEWSYM vramincr, db 0 ; 0 = inrement at 2118/2139, 1 = 2119,213A NEWSYM vramread, db 0 ; previous character for vram read NEWSYM vramaddr, dd 0 ; vram address NEWSYM cgaddr, dw 0 ; cg (palette) address NEWSYM cgmod, db 0 ; if cgram is modified or not NEWSYM scrnon, dw 0 ; main & sub screen on NEWSYM scrndist, db 0 ; which background is disabled NEWSYM resolutn, dw 224 ; screen resolution NEWSYM multa, db 0 ; multiplier A NEWSYM diva, dw 0 ; divisor C NEWSYM divres, dw 0 ; quotent of divc/divb NEWSYM multres, dw 0 ; result of multa * multb/remainder of divc/divb NEWSYM latchx, dw 0 ; latched x value NEWSYM latchy, dw 0 ; latched y value NEWSYM latchxr, db 0 ; low or high byte read for x value NEWSYM latchyr, db 0 ; low or high byte read for y value NEWSYM frskipper, db 0 ; used to control frame skipping NEWSYM winl1, db 0 ; window 1 left position NEWSYM winr1, db 0 ; window 1 right position NEWSYM winl2, db 0 ; window 2 left position NEWSYM winr2, db 0 ; window 2 right position NEWSYM winbg1en, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on BG1 NEWSYM winbg2en, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on BG2 NEWSYM winbg3en, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on BG3 NEWSYM winbg4en, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on BG4 NEWSYM winobjen, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on sprites NEWSYM wincolen, db 0 ; Win1 on (IN/OUT) or Win2 on (IN/OUT) on backarea NEWSYM winlogica, db 0 ; Window logic type for BG1 to 4 NEWSYM winlogicb, db 0 ; Window logic type for Sprites and Backarea NEWSYM winenabm, db 0 ; Window logic enable for main screen NEWSYM winenabs, db 0 ; Window logic enable for sub screen NEWSYM mode7set, db 0 ; mode 7 settings NEWSYM mode7A, dw 0 ; A value for Mode 7 NEWSYM mode7B, dw 0 ; B value for Mode 7 NEWSYM mode7C, dw 0 ; C value for Mode 7 NEWSYM mode7D, dw 0 ; D value for Mode 7 NEWSYM mode7X0, dw 0 ; Center X for Mode 7 NEWSYM mode7Y0, dw 0 ; Center Y for Mode 7 NEWSYM JoyAPos, db 0 ; Old-Style Joystick Read Position for Joy 1 & 3 NEWSYM JoyBPos, db 0 ; Old-Style Joystick Read Position for Joy 2 & 4 NEWSYM compmult, dd 0 ; Complement Multiplication for Mode 7 NEWSYM joyalt, db 0 ; temporary joystick alternation NEWSYM wramrwadr, dd 0 ; continuous read/write to wram address NEWSYM dmadata, times 129 db 0h ; dma data (written from ports 43xx) NEWSYM irqon, db 0 ; if IRQ has been called (80h) or not (0) NEWSYM nexthdma, db 0 ; HDMA data to execute once vblank ends NEWSYM curhdma, db 0 ; Currently executed hdma NEWSYM hdmadata, times 8*19 db 0 ; 4 dword register addresses, # of bytes to ; transfer/line, address increment (word) NEWSYM hdmatype, db 0 ; if first time executing hdma or not NEWSYM coladdr, db 0 ; red value of color to add NEWSYM coladdg, db 0 ; green value of color to add NEWSYM coladdb, db 0 ; blue value of color to add NEWSYM colnull, db 0 ; keep this 0 (when accessing colors by dword) NEWSYM scaddset, db 0 ; screen/fixed color addition settings NEWSYM scaddtype, db 0 ; which screen to add/sub NEWSYM Voice0Disabl2, db 1 ; Disable Voice 0 NEWSYM Voice1Disabl2, db 1 ; Disable Voice 1 NEWSYM Voice2Disabl2, db 1 ; Disable Voice 2 NEWSYM Voice3Disabl2, db 1 ; Disable Voice 3 NEWSYM Voice4Disabl2, db 1 ; Disable Voice 4 NEWSYM Voice5Disabl2, db 1 ; Disable Voice 5 NEWSYM Voice6Disabl2, db 1 ; Disable Voice 6 NEWSYM Voice7Disabl2, db 1 ; Disable Voice 7 NEWSYM oamram, times 1024 db 0 ; OAMRAM (544 bytes) NEWSYM cgram, times 512 db 0 ; CGRAM NEWSYM pcgram, times 512 db 0 ; Previous CGRAM NEWSYM vraminctype, db 0 ; New variables NEWSYM vramincby8on, db 0 ; if increment by 8 is on NEWSYM vramincby8left, db 0 ; how many left NEWSYM vramincby8totl, db 0 ; how many in total (32,64,128) NEWSYM vramincby8rowl, db 0 ; how many left in that row (start at 8) NEWSYM vramincby8ptri, dw 0 ; increment by how many when rowl = 0 NEWSYM nexthprior, db 0 NEWSYM doirqnext, db 0 NEWSYM vramincby8var, dw 0 NEWSYM screstype, db 0 NEWSYM extlatch, db 0 NEWSYM cfield, db 0 NEWSYM interlval, db 0 NEWSYM HIRQLoc, dw 0 ; HIRQ X location NEWSYM KeyOnStA, db 0 NEWSYM KeyOnStB, db 0 NEWSYM SDD1BankA, db 0 NEWSYM SDD1BankB, db 1 NEWSYM SDD1BankC, db 2 NEWSYM SDD1BankD, db 3 NEWSYM vramread2, db 0 ; previous character for vram read NEWSYM nosprincr, db 0 NEWSYM poamaddrs, dw 0 NEWSYM tempdat, times 480 db 0 ; expandable area num2writeppureg equ $-sndrot ; pharos equ hack *sigh* NEWSYM PHnum2writeppureg, dd num2writeppureg NEWSYM scrndis, db 0 ; which background is disabled ALIGN32 NEWSYM oamaddr, dd 0 ; oam address NEWSYM bg1ptrx, dd 0 ; pointer to background1 NEWSYM bg2ptrx, dd 0 ; pointer to background2 NEWSYM bg3ptrx, dd 0 ; pointer to background3 NEWSYM bg4ptrx, dd 0 ; pointer to background4 NEWSYM bg1ptry, dd 0 ; pointer to background1 NEWSYM bg2ptry, dd 0 ; pointer to background2 NEWSYM bg3ptry, dd 0 ; pointer to background3 NEWSYM bg4ptry, dd 0 ; pointer to background4 NEWSYM Voice0Disable, db 1 ; Disable Voice 0 NEWSYM Voice1Disable, db 1 ; Disable Voice 1 NEWSYM Voice2Disable, db 1 ; Disable Voice 2 NEWSYM Voice3Disable, db 1 ; Disable Voice 3 NEWSYM Voice4Disable, db 1 ; Disable Voice 4 NEWSYM Voice5Disable, db 1 ; Disable Voice 5 NEWSYM Voice6Disable, db 1 ; Disable Voice 6 NEWSYM Voice7Disable, db 1 ; Disable Voice 7 NEWSYM BG116x16t, db 0 NEWSYM BG216x16t, db 0 NEWSYM BG316x16t, db 0 NEWSYM BG416x16t, db 0 NEWSYM SPC700read, dd 0 NEWSYM SPC700write, dd 0 NEWSYM JoyCRead, db 0 NEWSYM nssdip1, db 0 NEWSYM nssdip2, db 0 NEWSYM nssdip3, db 0 NEWSYM nssdip4, db 0 NEWSYM nssdip5, db 0 NEWSYM nssdip6, db 0 NEWSYM ClearRegs mov word[VIRQLoc],0 mov word[bg1ptr],0 mov word[bg2ptr],0 mov word[bg3ptr],0 mov word[bg4ptr],0 mov word[bg1ptrb],0 mov word[bg2ptrb],0 mov word[bg3ptrb],0 mov word[bg4ptrb],0 mov word[bg1ptrc],0 mov word[bg2ptrc],0 mov word[bg3ptrc],0 mov word[bg4ptrc],0 mov word[bg1ptrd],0 mov word[bg2ptrd],0 mov word[bg3ptrd],0 mov word[bg4ptrd],0 mov word[bg1objptr],0 mov word[bg2objptr],0 mov word[bg3objptr],0 mov word[bg4objptr],0 ret reg2100r: mov al,[vidbright] or al,[forceblnk] ret ; Multiply Result Low reg2134r: checkmultchange mov al,[compmult] ret ; Multiply Result Middle reg2135r: checkmultchange mov al,[compmult+1] ret ; Multiply Result High reg2136r: checkmultchange mov al,[compmult+2] ret ; Software latch for horizontal/vertical counter reg2137r: ; mov byte[debstop3],1 cmp byte[debuggeron],1 je .debugger xor ebx,ebx mov bl,[cycpl] sub bl,dh add bx,bx mov [latchx],bx mov bx,[curypos] mov [latchy],bx mov bl,[INTEnab] and bl,30h cmp bl,30h jne .novhirq cmp word[HIRQLoc],0F0h ja .incry cmp dh,20 jae .noincly .incry inc word[latchy] .novhirq .noincly xor al,al mov byte[extlatch],0 ret .debugger debblah: xor ebx,ebx mov bl,[cycpl] sub bl,[pdh] add bx,bx mov [latchx],bx mov bx,[curypos] mov [latchy],bx mov bl,[INTEnab] and bl,30h cmp bl,30h jne .novhirq cmp word[HIRQLoc],0F0h ; ja .incry cmp word[latchx],80 ; jb .noincly .incry inc word[latchy] .novhirq .noincly xor al,al mov byte[extlatch],0 ret push eax push edx xor eax,eax xor ebx,ebx mov al,[cycpl] sub al,[pdh] mov bx,339 mul bx xor ebx,ebx mov bl,[cycpl] div bx mov [latchx],ax pop edx pop eax mov bx,[curypos] mov [latchy],bx mov bl,[INTEnab] and bl,30h cmp bl,30h jne .novhirq2 cmp word[HIRQLoc],0F0h ja .incry2 cmp word[latchx],80 jb .noincly2 .incry2 inc word[latchy] .novhirq2 .noincly2 xor al,al mov byte[extlatch],0 ret ; Read OAM Data (Low, High) reg2138r: xor ebx,ebx mov bx,word[oamaddr] add ebx,oamram mov al,[ebx] inc word[oamaddr] cmp word[oamaddr],543 ja .wrapoam ret .wrapoam mov word[oamaddr],0 ret ; Read VRAM Data (Low) reg2139r: mov al,[vramread] xor ebx,ebx mov bx,[vramaddr] add ebx,[vram] mov bl,[ebx] mov [vramread],bl cmp byte[vramincr],0 je near .noincr mov bx,[addrincr] add [vramaddr],bx cmp byte[vramincby8on],1 jne .noincr dec byte[vramincby8left] jnz .noincr add word[vramaddr],2 mov bl,byte[vramincby8totl] mov byte[vramincby8left],bl dec byte[vramincby8rowl] jz .nextrow mov bx,[vramincby8ptri] sub [vramaddr],bx jmp .noincr .nextrow mov byte[vramincby8rowl],8 sub word[vramaddr],16 .noincr ret ; Read VRAM Data (High) reg213Ar: mov al,[vramread2] xor ebx,ebx mov bx,[vramaddr] add ebx,[vram] mov bl,[ebx+1] mov [vramread2],bl cmp byte[vramincr],1 je near .noincr mov bx,[addrincr] add [vramaddr],bx cmp byte[vramincby8on],1 jne .noincr dec byte[vramincby8left] jnz .noincr add word[vramaddr],2 mov bl,byte[vramincby8totl] mov byte[vramincby8left],bl dec byte[vramincby8rowl] jz .nextrow mov bx,[vramincby8ptri] sub [vramaddr],bx jmp .noincr .nextrow mov byte[vramincby8rowl],8 sub word[vramaddr],16 .noincr ret ; Read CGRAM Data reg213Br: xor ebx,ebx mov bx,[cgaddr] mov al,[cgram+ebx] inc word[cgaddr] and word[cgaddr],01FFh ret ; H counter data by external or software latch reg213Cr: cmp byte[latchxr],1 je .highv mov al,byte[latchx] mov byte[latchxr],1 ret .highv mov al,byte[latchx] and al,0FEh or al,byte[latchx+1] mov byte[latchxr],0 ret ; V counter data by external or software latch reg213Dr: cmp byte[latchyr],2 ; hack for games that don't read 213F je .noreset cmp byte[latchyr],1 je .highv mov al,byte[latchy] mov byte[latchyr],1 ret .highv mov al,byte[latchy] and al,0FEh or al,byte[latchy+1] mov byte[latchyr],0 ret .noreset mov al,byte[latchy] and al,0FEh or al,byte[latchy+1] ret ; PPU Status Flag & Version number (OBJ over flags) reg213Er: mov al,01h ret ; PPU Status Flag & Version number (NTSC/PAL/EXTRN Latch flag) reg213Fr: ; mov byte[debstop3],1 mov al,[romispal] shl al,4 or al,[cfield] mov byte[latchxr],0 mov byte[latchyr],0 or al,[extlatch] ret ; Sound Reg #1 reg2140r: cmp byte[spcon],0 je .nosound inc dword[SPC700read] mov al,[reg1read] mov byte[spcnumread],0 ret .nosound ; Find for D0 mov ebx,esi cmp word[ebx],0FB10h jne .noret mov word[ebx],0EAEAh .noret mov al,5 .tryagain cmp byte[ebx],0D0h je .foundit inc ebx dec al jnz .tryagain jmp .notfound .foundit mov byte[ebx],0EAh mov byte[ebx+1],0EAh .notfound inc byte[sndrot2] cmp byte[sndrot2],3 jne .a mov byte[sndrot2],0 .a xor al,al test byte[sndrot2],01h jz .n mov al,[xa] .n ret ; Sound Reg #2 reg2141r: cmp byte[spcon],0 je .nosound inc dword[SPC700read] mov al,[reg2read] mov byte[spcnumread],0 ret .nosound ; Find for D0 mov ebx,esi mov al,3 .tryagain cmp byte[ebx],0D0h je .foundit inc ebx dec al jnz .tryagain jmp .notfound .foundit mov byte[ebx],0EAh mov byte[ebx+1],0EAh .notfound xor byte[sndrot],01h mov al,[xa+1] test byte[sndrot],01h jz .n mov al,[xa] .n ret ; Sound Reg #3 reg2142r: cmp byte[spcon],0 je .nosound inc dword[SPC700read] mov al,[reg3read] mov byte[spcnumread],0 ret .nosound ; Find for D0 mov ebx,esi mov al,3 .tryagain cmp byte[ebx],0D0h je .foundit inc ebx dec al jnz .tryagain jmp .notfound .foundit mov byte[ebx],0EAh mov byte[ebx+1],0EAh .notfound mov al,[xa] test byte[sndrot],01h jz .n mov al,[xa+1] .n ret ; Sound Reg #4 reg2143r: cmp byte[spcon],0 je .nosound inc dword[SPC700read] mov al,[reg4read] mov byte[spcnumread],0 ret .nosound ; Find for D0 mov ebx,esi mov al,3 .tryagain cmp byte[ebx],0D0h je .foundit inc ebx dec al jnz .tryagain jmp .notfound .foundit mov byte[ebx],0EAh mov byte[ebx+1],0EAh .notfound mov al,[xa+1] ret reg2144r: xor al,al ret ; WRAM Read reg2180r: mov ebx,[wramrwadr] add ebx,[wramdata] mov al,[ebx] inc dword[wramrwadr] and dword[wramrwadr],01FFFFh ret reg2Axxr: xor al,al ret ; Joystick Data for controller 1 and 2 reg4016r: xor al,al test dword[JoyANow],80000000h jz .noal mov al,1 .noal rol dword[JoyANow],1 ret NEWSYM MultiTap, db 0 ; Joystick Data for controller 2 and 4 reg4017r: cmp byte[snesmouse],0 jne .nomultitap cmp byte[MultiTap],1 je .multitap .nomultitap xor al,al test dword[JoyBNow],80000000h jz .noal mov al,1 .noal rol dword[JoyBNow],1 ret .multitap test byte[MultiTapStat],1 jz .no1 mov al,0FFh ret .no1 test byte[MultiTapStat],80h jz .contr45 xor al,al test dword[JoyBNow],80000000h jz .nojb or al,01h .nojb test dword[JoyCNow],80000000h jz .nojc or al,02h .nojc rol dword[JoyBNow],1 rol dword[JoyCNow],1 ret .contr45 xor al,al test dword[JoyDNow],80000000h jz .nojd or al,1 .nojd test dword[JoyENow],80000000h jz .noje or al,02h .noje rol dword[JoyDNow],1 rol dword[JoyENow],1 ret reg4100r: xor al,al cmp byte[nssdip1],1 jne .nodip1 mov al,1 .nodip1 cmp byte[nssdip1],1 jne .nodip2 or al,02h .nodip2 cmp byte[nssdip3],1 jne .nodip3 or al,04h .nodip3 cmp byte[nssdip4],1 jne .nodip4 or al,08h .nodip4 cmp byte[nssdip5],1 jne .nodip5 or al,10h .nodip5 cmp byte[nssdip6],1 jne .nodip6 or al,20h .nodip6 ret reg420Ar: reg420Br: reg420Cr: reg420Dr: reg420Er: reg420Fr: xor al,al ret ; NMI Check Register reg4210r: mov al,[NMIEnab] cmp byte[curnmi],0 jne .nmi mov byte[NMIEnab],01h .nmi mov byte[curnmi],0 ret ; Video IRQ Register reg4211r: mov al,[irqon] mov byte[irqon],0 cmp dh,[cycphb] jae .nohblank or al,40h .nohblank ret ; H/V Blank Flag & Joystick Controller Enable Flag ; bit 7 = vblank, 0=out,1=in, bit 6 = hblank, 0=out,1=in, bit 0 = joystick on reg4212r: xor al,al cmp byte[joycontren],25 jb .nojoyc .yesjoy mov al,1 .nojoyc inc byte[joycontren] cmp byte[joycontren],50 jne .n mov byte[joycontren],0 .n cmp byte[debuggeron],1 je .debugger mov bx,[resolutn] cmp word[curypos],bx jne .notres cmp byte[nmistatus],2 je .vblank .notres inc bx cmp word[curypos],bx jb .novbl mov bx,[totlines] dec bx cmp word[curypos],bx jae .novbl .vblank or al,80h ; jmp .nohblank .novbl cmp dh,[cycphb] jae .nohblank or al,40h .nohblank test byte[INTEnab],01h jz .nojoy mov bx,[resolutn] add bx,2 cmp word[curypos],bx jne .nojoy cmp dh,5 ja .nojoy ret .nojoy ret .debugger debblah2: push edx mov dh,[pdh] mov bx,[resolutn] cmp word[curypos],bx jne .notres cmp byte[nmistatus],2 je .vblank .notres inc bx cmp word[curypos],bx jb .novbl mov bx,[totlines] dec bx cmp word[curypos],bx jae .novbl .vblank or al,80h ; jmp .nohblank .novbl cmp dh,[cycphb] jae .nohblank or al,40h .nohblank test byte[INTEnab],01h jz .nojoy mov bx,[resolutn] add bx,2 cmp word[curypos],bx jne .nojoy cmp dh,5 ja .nojoy pop edx ret .nojoy pop edx ret mov bx,[resolutn] inc bx cmp word[curypos],bx jb .novbl2 or al,80h jmp .nohblank2 .novbl2 mov bl,[pdh] cmp bl,[cycphb] jae .nohblank2 or al,40h .nohblank2 test byte[INTEnab],01h jz .nojoy2 mov bx,[resolutn] add bx,2 cmp word[curypos],bx jne .nojoy2 cmp byte[pdh],5 ja .nojoy ; or al,01h ret .nojoy2 ret ; Programmable I/O port reg4213r: ; mov al,[mode7A] ; xor al,al ; mov al,0FFh ret ; Quotent of Divide Result (Low) reg4214r: mov al,[divres] ret ; Quotent of Divide Result (High) reg4215r: mov al,[divres+1] ret ; Product of Multiplication Result or Remainder of Divide Result (Low) reg4216r: mov al,[multres] ret ; Product of Multiplication Result or Remainder of Divide Result (High) reg4217r: mov al,[multres+1] ret ; Joystick 1 Low ; bit7=X,bit6=Y,bit5=L,bit4=R reg4218r: mov al,[JoyAOrig+2] ret ; Joystick 1 High ; bit7=A,bit6=B,bit5=Sel,bit4=Start,bit3=up,bit2=down,bit1=left,bit0=right reg4219r: mov al,[JoyAOrig+3] ret ; Joystick 2 Low reg421Ar: mov al,[JoyBOrig+2] ret ; Joystick 2 High reg421Br: mov al,[JoyBOrig+3] ret ; Joystick 3 Low reg421Cr: mov al,[JoyDOrig+2] ret ; Joystick 3 High reg421Dr: mov al,[JoyDOrig+3] ret ; Joystick 4 Low reg421Er: mov al,[JoyCOrig+2] ret ; Joystick 4 High reg421Fr: mov al,[JoyCOrig+3] ret ; DMA Reader reg43XXr: xor ebx,ebx mov bx,cx sub bx,4300h mov al,[dmadata+ebx] ret regINVALID: ; Invalid Register cmp cx,2100h jb .cleared mov al,ch cmp byte[SPC7110Enable],0 je .nospc7110 .cleared xor al,al .nospc7110 ; mov byte[debstop3],1 ret mov al,[previdmode] mov ah,0 int 10h mov byte[invalid],1 mov [invreg],cx mov ah,9 mov edx,.invalidreg int 21h xor eax,eax mov ax,[invreg] call printhex mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h mov eax,[numinst] ;Temporary call printnum jmp DosExit .invalidreg db 'Invalid Read Register : $' zsnes-1.36/src/cpu/regs.mac0100644000175000017500000000411207267141100015160 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;******************************************************* ; InitReg Initializes Registers ;******************************************************* %macro setreg 2 mov edi,%1 add edi,[regptr] mov eax,%2 mov [edi],eax %endmacro ;******************************************************* ; Registers Note : Remember to restore AH, ECX, & DX ;******************************************************* %macro checkmultchange 0 ; execute multiplication cmp byte[multchange],0 je .nomult push edx push eax xor bh,bh mov bl,[mode7B+1] mov ax,[mode7A] test bl,80h jz .noneg mov bh,0FFh .noneg imul bx mov [compmult],ax mov [compmult+2],dl pop eax pop edx mov byte[multchange],0 .nomult %endmacro %macro mouse4016doxA 2 cmp byte[JoyAPos],%1 jne .nx7 mov bx,[mousexpos] shr bx,%2 and bx,1 mov al,bl .nx7 %endmacro %macro mouse4016doyA 2 cmp byte[JoyAPos],%1 jne .ny7 mov bx,[mouseypos] shr bx,%2 and bx,1 mov al,bl .ny7 %endmacro %macro mouse4017dox 2 cmp byte[JoyBPos],%1 jne .nx7 mov bx,[mousexpos] shr bx,%2 and bx,1 mov al,bl .nx7 %endmacro %macro mouse4017doy 2 cmp byte[JoyBPos],%1 jne .ny7 mov bx,[mouseypos] shr bx,%2 and bx,1 mov al,bl .ny7 %endmacro zsnes-1.36/src/cpu/regsw.inc0100644000175000017500000010657607506772270015417 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM initsfxregsw,reg420Bw,reg420Cw,regptw,initSA1regsw,SDD1Reset EXTSYM SPC7110Reset,RTCReset2 EXTSYM xat,xdbt,xdt,xpbt,xst,xxt,xyt EXTSYM DSPMem,WDSPReg0C,WDSPReg0D,WDSPReg0F,WDSPReg1C,WDSPReg1F EXTSYM WDSPReg2C,WDSPReg2F,WDSPReg3C,WDSPReg3D,WDSPReg3F,WDSPReg4F EXTSYM WDSPReg5F,WDSPReg6C,WDSPReg6F,WDSPReg7D,WDSPReg7F EXTSYM debstop EXTSYM cachesprites,curblank,processsprites,sprleftpr,sprlefttot,NextLineCache EXTSYM vidmemch2,vidmemch4,vidmemch8,vrama EXTSYM nmirept,sndwrit,spcRam EXTSYM HIRQCycNext,HIRQNextExe,HIRQSkip EXTSYM cycpb268,cycpb358,cycpbl,cycpblt,opexec268,opexec268cph EXTSYM opexec358,opexec358cph EXTSYM hdmarestart EXTSYM printhex8 NEWSYM testgfxv1, db 0 NEWSYM testgfxv2, db 0 NEWSYM initregw ; Fill register pointer with invalid register accesses mov edi,[regptw] add edi,8000h mov ecx,3000h mov eax,regINVALIDw .loopa mov [edi],eax add edi,4 dec ecx jnz .loopa ; Set all valid register accesses setregw 2100h*4,reg2100w setregw 2101h*4,reg2101w setregw 2102h*4,reg2102w setregw 2103h*4,reg2103w setregw 2104h*4,reg2104w setregw 2105h*4,reg2105w setregw 2106h*4,reg2106w setregw 2107h*4,reg2107w setregw 2108h*4,reg2108w setregw 2109h*4,reg2109w setregw 210Ah*4,reg210Aw setregw 210Bh*4,reg210Bw setregw 210Ch*4,reg210Cw setregw 210Dh*4,reg210Dw setregw 210Eh*4,reg210Ew setregw 210Fh*4,reg210Fw setregw 2110h*4,reg2110w setregw 2111h*4,reg2111w setregw 2112h*4,reg2112w setregw 2113h*4,reg2113w setregw 2114h*4,reg2114w setregw 2115h*4,reg2115w setregw 2116h*4,reg2116w setregw 2117h*4,reg2117w setregw 2118h*4,reg2118 setregw 2119h*4,reg2119inc setregw 211Ah*4,reg211Aw setregw 211Bh*4,reg211Bw setregw 211Ch*4,reg211Cw setregw 211Dh*4,reg211Dw setregw 211Eh*4,reg211Ew setregw 211Fh*4,reg211Fw setregw 2120h*4,reg2120w setregw 2121h*4,reg2121w setregw 2122h*4,reg2122w setregw 2123h*4,reg2123w setregw 2124h*4,reg2124w setregw 2125h*4,reg2125w setregw 2126h*4,reg2126w setregw 2127h*4,reg2127w setregw 2128h*4,reg2128w setregw 2129h*4,reg2129w setregw 212Ah*4,reg212Aw setregw 212Bh*4,reg212Bw setregw 212Ch*4,reg212Cw setregw 212Dh*4,reg212Dw setregw 212Eh*4,reg212Ew setregw 212Fh*4,reg212Fw setregw 2130h*4,reg2130w setregw 2131h*4,reg2131w setregw 2132h*4,reg2132w setregw 2133h*4,reg2133w setregw 2140h*4,reg2140w setregw 2141h*4,reg2141w setregw 2142h*4,reg2142w setregw 2143h*4,reg2143w setregw 2144h*4,reg2140w setregw 2180h*4,reg2180w setregw 2181h*4,reg2181w setregw 2182h*4,reg2182w setregw 2183h*4,reg2183w setregw 4016h*4,reg4016w setregw 4017h*4,reg4017w setregw 4200h*4,reg4200w setregw 4201h*4,reg4201w setregw 4202h*4,reg4202w setregw 4203h*4,reg4203w setregw 4204h*4,reg4204w setregw 4205h*4,reg4205w setregw 4206h*4,reg4206w setregw 4207h*4,reg4207w setregw 4208h*4,reg4208w setregw 4209h*4,reg4209w setregw 420Ah*4,reg420Aw setregw 420Bh*4,reg420Bw setregw 420Ch*4,reg420Cw setregw 420Dh*4,reg420Dw setregw 420Eh*4,reg420Ew setregw 4210h*4,reg4210w setregw 4211h*4,reg4211w setregw 4212h*4,reg4212w setregw 4216h*4,reg4216w setregw 4300h*4,reg43X0w setregw 4301h*4,reg43X1w setregw 4302h*4,reg43x2w setregw 4303h*4,reg43x3w setregw 4304h*4,reg43x4w setregw 4305h*4,reg43x5w setregw 4306h*4,reg43x6w setregw 4307h*4,reg43x7w setregw 4308h*4,reg43x8w setregw 4309h*4,reg43x9w setregw 430Ah*4,reg43XAw setregw 430Bh*4,reg43XAw setregw 430Ch*4,reg43XAw setregw 430Dh*4,reg43XAw setregw 430Eh*4,reg43XAw setregw 430Fh*4,reg43XAw setregw 4310h*4,reg43X0w setregw 4311h*4,reg43X1w setregw 4312h*4,reg43x2w setregw 4313h*4,reg43x3w setregw 4314h*4,reg43x4w setregw 4315h*4,reg43x5w setregw 4316h*4,reg43x6w setregw 4317h*4,reg43x7w setregw 4318h*4,reg43x8w setregw 4319h*4,reg43x9w setregw 431Ah*4,reg43XAw setregw 431Bh*4,reg43XAw setregw 431Ch*4,reg43XAw setregw 431Dh*4,reg43XAw setregw 431Eh*4,reg43XAw setregw 431Fh*4,reg43XAw setregw 4320h*4,reg43X0w setregw 4321h*4,reg43X1w setregw 4322h*4,reg43x2w setregw 4323h*4,reg43x3w setregw 4324h*4,reg43x4w setregw 4325h*4,reg43x5w setregw 4326h*4,reg43x6w setregw 4327h*4,reg43x7w setregw 4328h*4,reg43x8w setregw 4329h*4,reg43x9w setregw 432Ah*4,reg43XAw setregw 432Bh*4,reg43XAw setregw 432Ch*4,reg43XAw setregw 432Dh*4,reg43XAw setregw 432Eh*4,reg43XAw setregw 432Fh*4,reg43XAw setregw 4330h*4,reg43X0w setregw 4331h*4,reg43X1w setregw 4332h*4,reg43x2w setregw 4333h*4,reg43x3w setregw 4334h*4,reg43x4w setregw 4335h*4,reg43x5w setregw 4336h*4,reg43x6w setregw 4337h*4,reg43x7w setregw 4338h*4,reg43x8w setregw 4339h*4,reg43x9w setregw 433Ah*4,reg43XAw setregw 433Bh*4,reg43XAw setregw 433Ch*4,reg43XAw setregw 433Dh*4,reg43XAw setregw 433Eh*4,reg43XAw setregw 433Fh*4,reg43XAw setregw 4340h*4,reg43X0w setregw 4341h*4,reg43X1w setregw 4342h*4,reg43x2w setregw 4343h*4,reg43x3w setregw 4344h*4,reg43x4w setregw 4345h*4,reg43x5w setregw 4346h*4,reg43x6w setregw 4347h*4,reg43x7w setregw 4348h*4,reg43x8w setregw 4349h*4,reg43x9w setregw 434Ah*4,reg43XAw setregw 434Bh*4,reg43XAw setregw 434Ch*4,reg43XAw setregw 434Dh*4,reg43XAw setregw 434Eh*4,reg43XAw setregw 434Fh*4,reg43XAw setregw 4350h*4,reg43X0w setregw 4351h*4,reg43X1w setregw 4352h*4,reg43x2w setregw 4353h*4,reg43x3w setregw 4354h*4,reg43x4w setregw 4355h*4,reg43x5w setregw 4356h*4,reg43x6w setregw 4357h*4,reg43x7w setregw 4358h*4,reg43x8w setregw 4359h*4,reg43x9w setregw 435Ah*4,reg43XAw setregw 435Bh*4,reg43XAw setregw 435Ch*4,reg43XAw setregw 435Dh*4,reg43XAw setregw 435Eh*4,reg43XAw setregw 435Fh*4,reg43XAw setregw 4360h*4,reg43X0w setregw 4361h*4,reg43X1w setregw 4362h*4,reg43x2w setregw 4363h*4,reg43x3w setregw 4364h*4,reg43x4w setregw 4365h*4,reg43x5w setregw 4366h*4,reg43x6w setregw 4367h*4,reg43x7w setregw 4368h*4,reg43x8w setregw 4369h*4,reg43x9w setregw 436Ah*4,reg43XAw setregw 436Bh*4,reg43XAw setregw 436Ch*4,reg43XAw setregw 436Dh*4,reg43XAw setregw 436Eh*4,reg43XAw setregw 436Fh*4,reg43XAw setregw 4370h*4,reg43X0w setregw 4371h*4,reg43X1w setregw 4372h*4,reg43x2w setregw 4373h*4,reg43x3w setregw 4374h*4,reg43x4w setregw 4375h*4,reg43x5w setregw 4376h*4,reg43x6w setregw 4377h*4,reg43x7w setregw 4378h*4,reg43x8w setregw 4379h*4,reg43x9w setregw 437Ah*4,reg43XAw setregw 437Bh*4,reg43XAw setregw 437Ch*4,reg43XAw setregw 437Dh*4,reg43XAw setregw 437Eh*4,reg43XAw setregw 437Fh*4,reg43XAw cmp byte[SFXEnable],0 je .nosfx call initsfxregsw .nosfx cmp byte[SA1Enable],0 je .nosa1 call initSA1regsw .nosa1 cmp byte[SDD1Enable],0 je .nosdd1 call SDD1Reset .nosdd1 cmp byte[SPC7110Enable],0 je .nospc7110 call SPC7110Reset .nospc7110 cmp byte[RTCEnable],0 je .nortc call RTCReset2 .nortc ret ; video memory change buffer for caching (65536/16=4096) ;vidmemch2 times 4096 db 0 ;vidmemch4 times 4096 db 0 ;vidmemch8 times 4096 db 0 NEWSYM unpackfunct mov ebx,[oamaddr] mov [oamaddrt],bx mov ax,[xa] mov [xat],ax mov al,[xdb] mov [xdbt],al mov al,[xpb] mov [xpbt],al mov ax,[xs] mov [xst],ax mov ax,[xd] mov [xdt],ax mov ax,[xx] mov [xxt],ax mov ax,[xy] mov [xyt],ax ret NEWSYM repackfunct ; Global/Echo Volumes mov al,[DSPMem+0Ch] call WDSPReg0C mov al,[DSPMem+1Ch] call WDSPReg1C mov al,[DSPMem+2Ch] call WDSPReg2C mov al,[DSPMem+3Ch] call WDSPReg3C ; Echo Values mov al,[DSPMem+7Dh] call WDSPReg7D mov al,[DSPMem+0Dh] call WDSPReg0D ; FIR Filter Values mov al,[DSPMem+00Fh] call WDSPReg0F mov al,[DSPMem+01Fh] call WDSPReg1F mov al,[DSPMem+02Fh] call WDSPReg2F mov al,[DSPMem+03Fh] call WDSPReg3F mov al,[DSPMem+04Fh] call WDSPReg4F mov al,[DSPMem+05Fh] call WDSPReg5F mov al,[DSPMem+06Fh] call WDSPReg6F mov al,[DSPMem+07Fh] call WDSPReg7F ; Noise mov al,[DSPMem+6Ch] call WDSPReg6C mov al,[DSPMem+3Dh] call WDSPReg3D mov bx,[bg1ptrb] sub bx,[bg1ptr] mov [bg1ptrx],bx mov bx,[bg1ptrc] sub bx,[bg1ptr] mov [bg1ptry],bx mov bx,[bg2ptrb] sub bx,[bg2ptr] mov [bg2ptrx],bx mov bx,[bg2ptrc] sub bx,[bg2ptr] mov [bg2ptry],bx mov bx,[bg3ptrb] sub bx,[bg3ptr] mov [bg3ptrx],bx mov bx,[bg3ptrc] sub bx,[bg3ptr] mov [bg3ptry],bx mov bx,[bg4ptrb] sub bx,[bg4ptr] mov [bg4ptrx],bx mov bx,[bg4ptrc] sub bx,[bg4ptr] mov [bg4ptry],bx ; 16x16 tiles mov bl,[bgtilesz] shl bl,4 mov dword[BG116x16t],0 add bl,bl adc byte[BG416x16t],0 add bl,bl adc byte[BG316x16t],0 add bl,bl adc byte[BG216x16t],0 add bl,bl adc byte[BG116x16t],0 mov ebx,[oamaddrt] and ebx,0FFFFh mov [oamaddr],ebx mov ax,[xat] mov [xa],ax mov al,[xdbt] mov [xdb],al mov al,[xpbt] mov [xpb],al mov ax,[xst] mov [xs],ax mov ax,[xdt] mov [xd],ax mov ax,[xxt] mov [xx],ax mov ax,[xyt] mov [xy],ax cmp byte[vramincby8on],1 je near .incby8 mov ebx,[regptw] cmp byte[vramincr],1 je .from2118 mov dword[ebx+2118h*4],reg2118 mov dword[ebx+2119h*4],reg2119inc ret .from2118 mov dword[ebx+2118h*4],reg2118inc mov dword[ebx+2119h*4],reg2119 ret .incby8 mov ebx,[regptw] cmp byte[vramincr],1 je .from2118b mov dword[ebx+2118h*4],reg2118inc8 mov dword[ebx+2119h*4],reg2119inc8inc ret .from2118b mov dword[ebx+2118h*4],reg2118inc8inc mov dword[ebx+2119h*4],reg2119inc8 ret ;******************************************************* ; Registers Note : restore AH, ECX, ESI, EDI, *S & DX ;******************************************************* ; Screen display register reg2100w: mov [vidbright],al and byte[vidbright],0Fh mov [forceblnk],al and byte[forceblnk],80h ret NEWSYM prevoamptr, db 0 ; OAM size register reg2101w: cmp byte[prevoamptr],0FFh je .noskip cmp byte[prevoamptr],al je near .noproc .noskip mov byte[prevoamptr],al xor ebx,ebx mov bl,al and bl,03h shl bx,14 mov [objptr],bx mov [objptrn],bx xor ebx,ebx mov bl,al and bl,18h shr bl,3 shl bx,13 add [objptrn],bx xor ebx,ebx mov bl,al shr bl,5 push eax mov byte[NextLineCache],1 mov al,[.objsize1+ebx] mov [objsize1],al mov al,[.objsize2+ebx] mov [objsize2],al mov al,[.objmovs1+ebx] mov [objmovs1],al mov al,[.objmovs2+ebx] mov [objmovs2],al mov ax,[.objadds1+ebx*2] mov [objadds1],ax mov ax,[.objadds2+ebx*2] mov [objadds2],ax pop eax .noproc ret .objsize1 db 1,1,1,4,4,16,1,1 .objsize2 db 4,16,64,16,64,64,4,4 .objmovs1 db 2,2,2,2,2,4,2,2 .objmovs2 db 2,4,8,4,8,8,2,2 .objadds1 dw 14,14,14,14,14,12,14,14 .objadds2 dw 14,12,8,12,8,8,14,14 NEWSYM oamlow, db 0 ; OAM address register reg2102w: mov byte[oamlow],1 mov word[oamaddr],0 shr word[oamaddr],1 mov [oamaddr],al shl word[oamaddr],1 ; or al,al ; jz .skipstore mov bx,[oamaddrs] mov [poamaddrs],bx mov bx,[oamaddr] mov [oamaddrs],bx .skipstore cmp byte[nexthprior],1 je .priorset mov byte[objhipr],0 jmp .cachespr .priorset mov bx,[oamaddr] shr bx,2 and bl,0x7F ; cmp bl,80h ; jae .noreset ; xor bl,bl .noreset mov [objhipr],bl .cachespr ret ; OAM address register reg2103w: cmp byte[oamlow],1 jne .afteroamlow mov byte[oamlow],0 mov bl,al and bl,01h shr word[oamaddr],1 mov [oamaddr+1],bl shl word[oamaddr],1 .afteroamlow cmp word[poamaddrs],200h jbe .notinvptr cmp word[oamaddr],200h jne .notinvptr mov bx,[poamaddrs] mov [oamaddr],bx mov byte[nosprincr],1 .notinvptr mov bx,[oamaddr] mov [oamaddrs],bx test al,80h jnz .hipri mov byte[nexthprior],0 mov byte[NextLineCache],1 ret .hipri mov byte[nexthprior],1 mov byte[NextLineCache],1 ret ; OAM data register reg2104w: mov byte[NextLineCache],1 mov ebx,[oamaddr] cmp byte[nosprincr],1 je .noinc inc dword[oamaddr] cmp ebx,544 jae .overflow .noinc mov [oamram+ebx],al ret .overflow xor ebx,ebx mov dword[oamaddr],1 mov [oamram+ebx],al ret ; Screen mode register reg2105w: mov bl,al and bl,00000111b mov [bgmode],bl mov bl,al shr bl,3 and bl,01h mov [bg3highst],bl mov bl,al shr bl,4 mov [bgtilesz],bl mov bl,al mov dword[BG116x16t],0 add bl,bl adc byte[BG416x16t],0 add bl,bl adc byte[BG316x16t],0 add bl,bl adc byte[BG216x16t],0 add bl,bl adc byte[BG116x16t],0 ret ; Screen pixelation register reg2106w: mov bl,al and bl,0Fh mov [mosaicon],bl mov bl,al shr bl,4 mov [mosaicsz],bl ret ; BG1 VRAM location register reg2107w: xor ebx,ebx mov bl,al shr bl,2 shl bx,11 mov [bg1ptr],bx mov [bg1ptrb],bx mov [bg1ptrc],bx mov [bg1ptrd],bx mov dword[bg1ptrx],0 mov dword[bg1ptry],0 mov bl,al and bl,00000011b mov [bg1scsize],bl cmp bl,1 jne .skipa add word[bg1ptrb],800h add word[bg1ptrd],800h mov dword[bg1ptrx],800h .skipa cmp bl,2 jne .skipb add word[bg1ptrc],800h add word[bg1ptrd],800h mov dword[bg1ptry],800h .skipb cmp bl,3 jne .skipc add word[bg1ptrb],800h add word[bg1ptrc],1000h add word[bg1ptrd],1800h mov dword[bg1ptrx],800h mov dword[bg1ptry],1000h .skipc ret ; BG2 VRAM location register reg2108w: xor ebx,ebx mov bl,al shr bl,2 shl bx,11 mov [bg2ptr],bx mov [bg2ptrb],bx mov [bg2ptrc],bx mov [bg2ptrd],bx mov dword[bg2ptrx],0 mov dword[bg2ptry],0 mov bl,al and bl,00000011b mov [bg2scsize],bl cmp bl,1 jne .skipa add word[bg2ptrb],800h add word[bg2ptrd],800h mov dword[bg2ptrx],800h .skipa cmp bl,2 jne .skipb add word[bg2ptrc],800h add word[bg2ptrd],800h mov dword[bg2ptry],800h .skipb cmp bl,3 jne .skipc add word[bg2ptrb],800h add word[bg2ptrc],1000h add word[bg2ptrd],1800h mov dword[bg2ptrx],800h mov dword[bg2ptry],1000h .skipc ret ; BG3 VRAM location register reg2109w: xor ebx,ebx mov bl,al shr bl,2 shl bx,11 mov [bg3ptr],bx mov [bg3ptrb],bx mov [bg3ptrc],bx mov [bg3ptrd],bx mov dword[bg3ptrx],0 mov dword[bg3ptry],0 mov bl,al and bl,00000011b mov [bg3scsize],bl cmp bl,1 jne .skipa add word[bg3ptrb],800h add word[bg3ptrd],800h mov dword[bg3ptrx],800h .skipa cmp bl,2 jne .skipb add word[bg3ptrc],800h add word[bg3ptrd],800h mov dword[bg3ptry],800h .skipb cmp bl,3 jne .skipc add word[bg3ptrb],800h add word[bg3ptrc],1000h add word[bg3ptrd],1800h mov dword[bg3ptrx],800h mov dword[bg3ptry],1000h .skipc ret ; BG4 VRAM location register reg210Aw: xor ebx,ebx mov bl,al shr bl,2 shl bx,11 mov [bg4ptr],bx mov [bg4ptrb],bx mov [bg4ptrc],bx mov [bg4ptrd],bx mov dword[bg4ptrx],0 mov dword[bg4ptry],0 mov bl,al and bl,00000011b mov [bg4scsize],bl cmp bl,1 jne .skipa add word[bg4ptrb],800h add word[bg4ptrd],800h mov dword[bg4ptrx],800h .skipa cmp bl,2 jne .skipb add word[bg4ptrc],800h add word[bg4ptrd],800h mov dword[bg4ptry],800h .skipb cmp bl,3 jne .skipc add word[bg4ptrb],800h add word[bg4ptrc],1000h add word[bg4ptrd],1800h mov dword[bg4ptrx],800h mov dword[bg4ptry],1000h .skipc ret ; BG1 & BG2 VRAM location register reg210Bw: xor ebx,ebx mov bl,al and bl,0Fh shl bx,13 mov [bg1objptr],bx mov bl,al shr bl,4 shl bx,13 mov [bg2objptr],bx ret ; BG3 & BG4 VRAM location register reg210Cw: xor ebx,ebx mov bl,al and bl,0Fh shl bx,13 mov [bg3objptr],bx mov bl,al shr bl,4 shl bx,13 mov [bg4objptr],bx ret ; BG1 horizontal scroll register reg210Dw: mov bl,byte[bg1scrolx+1] mov byte[bg1scrolx],bl mov byte[bg1scrolx+1],al ret ; BG1 vertical scroll register reg210Ew: mov bl,byte[bg1scroly+1] add bl,[bgscroltemp] mov byte[bg1scroly],bl mov byte[bg1scroly+1],al ret bgscroltemp db 0 ; BG2 horizontal scroll register reg210Fw: mov bl,byte[bg2scrolx+1] mov byte[bg2scrolx],bl mov byte[bg2scrolx+1],al ret ; BG2 vertical scroll register reg2110w: mov bl,byte[bg2scroly+1] add bl,[bgscroltemp] mov byte[bg2scroly],bl mov byte[bg2scroly+1],al ret ; BG3 horizontal scroll register reg2111w: mov bl,byte[bg3scrolx+1] mov byte[bg3scrolx],bl mov byte[bg3scrolx+1],al ret ; BG3 vertical scroll register reg2112w: mov bl,byte[bg3scroly+1] add bl,[bgscroltemp] mov byte[bg3scroly],bl mov byte[bg3scroly+1],al ret ; BG4 horizontal scroll register reg2113w: mov bl,byte[bg4scrolx+1] mov byte[bg4scrolx],bl mov byte[bg4scrolx+1],al ret ; BG4 vertical scroll register reg2114w: mov bl,byte[bg4scroly+1] add bl,[bgscroltemp] mov byte[bg4scroly],bl mov byte[bg4scroly+1],al ret ; Video port control reg2115w: and al,11111111b mov [vraminctype],al mov bl,al and bl,00000011b cmp bl,0 jne .skip1 mov word[addrincr],2 .skip1 cmp bl,1 jne .skip2 mov word[addrincr],64 .skip2 cmp bl,2 jne .skip3 mov word[addrincr],256 .skip3 cmp bl,3 jne .skip4 mov word[addrincr],256 .skip4 mov bl,al mov byte[vramincby8on],0 and bl,00001100b jz near .noincby8 mov byte[vramincby8on],1 cmp bl,4 jne .nextinc8 mov byte[vramincby8left],64-1 mov byte[vramincby8totl],5 mov word[vramincby8ptri],65535-511 mov word[vramincby8var],256+128+64 .nextinc8 cmp bl,8 jne .nextinc8b mov byte[vramincby8left],128-1 mov byte[vramincby8totl],6 mov word[vramincby8ptri],65535-1023 mov word[vramincby8var],512+256+128 .nextinc8b cmp bl,12 jne .nextinc8c mov byte[vramincby8left],256-1 mov byte[vramincby8totl],7 mov word[vramincby8ptri],65535-2047 mov word[vramincby8var],1024+512+256 .nextinc8c mov ebx,[regptw] test al,80h jz .from2118 mov dword[ebx+2118h*4],reg2118inc8 mov dword[ebx+2119h*4],reg2119inc8inc mov byte[vramincr],0 jmp .from2119 .from2118 mov dword[ebx+2118h*4],reg2118inc8inc mov dword[ebx+2119h*4],reg2119inc8 mov byte[vramincr],1 .from2119 ret .noincby8 mov ebx,[regptw] test al,80h jz .from2118b mov dword[ebx+2118h*4],reg2118 mov dword[ebx+2119h*4],reg2119inc mov byte[vramincr],0 jmp .from2119b .from2118b mov dword[ebx+2118h*4],reg2118inc mov dword[ebx+2119h*4],reg2119 mov byte[vramincr],1 .from2119b ret ; Video port address (Low) reg2116w: shr word[vramaddr],1 mov byte[vramaddr],al shl word[vramaddr],1 mov byte[vramread],0 ret ; Video port address (High) reg2117w: shr word[vramaddr],1 mov byte[vramaddr+1],al shl word[vramaddr],1 mov byte[vramread],0 xor ebx,ebx mov bx,[vramaddr] add ebx,[vram] mov bl,[ebx] mov [vramread],bl xor ebx,ebx mov bx,[vramaddr] add ebx,[vram] mov bl,[ebx+1] mov [vramread2],bl ret ; Video port data (Low) reg2118: mov ebx,[vramaddr] mov [vrama+ebx],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 ret reg2118inc: mov ebx,[vramaddr] mov [vrama+ebx],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 mov ebx,[addrincr] add [vramaddr],bx ret reg2118inc8: push ecx xor ecx,ecx mov ebx,[vramaddr] mov cl,[vramincby8left] and ebx,ecx shl ebx,3 push eax mov eax,[vramaddr] and ax,[vramincby8var] mov cl,[vramincby8totl] shr eax,cl add ebx,eax mov eax,[vramaddr] and ax,[vramincby8ptri] add ebx,eax pop eax pop ecx add ebx,[vram] ; cmp [ebx],al ; je .nochange2 mov [ebx],al sub ebx,[vram] shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange2 ret reg2118inc8inc: push ecx xor ecx,ecx mov ebx,[vramaddr] mov cl,[vramincby8left] and ebx,ecx shl ebx,3 push eax mov eax,[vramaddr] and ax,[vramincby8var] mov cl,[vramincby8totl] shr eax,cl add ebx,eax mov eax,[vramaddr] and ax,[vramincby8ptri] add ebx,eax pop eax pop ecx add ebx,[vram] ; cmp [ebx],al ; je .nochange2 mov [ebx],al sub ebx,[vram] shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange2 mov ebx,[addrincr] add [vramaddr],bx ret reg2119: cmp dword[vramaddr],0E000h jb .skip mov byte[debstop],1 .skip mov ebx,[vramaddr] ; cmp [vrama+ebx+1],al ; je .nochange mov [vrama+ebx+1],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange ret reg2119inc: mov ebx,[vramaddr] ; cmp [vrama+ebx+1],al ; je .nochange mov [vrama+ebx+1],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange mov ebx,[addrincr] add [vramaddr],bx ret reg2119inc8: push ecx xor ecx,ecx mov ebx,[vramaddr] mov cl,[vramincby8left] and ebx,ecx shl ebx,3 push eax mov eax,[vramaddr] and ax,[vramincby8var] mov cl,[vramincby8totl] shr eax,cl add ebx,eax mov eax,[vramaddr] and ax,[vramincby8ptri] add ebx,eax pop eax pop ecx ; cmp [vrama+ebx+1],al ; je .nochange2 mov [vrama+ebx+1],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange2 ret reg2119inc8inc: push ecx xor ecx,ecx mov ebx,[vramaddr] mov cl,[vramincby8left] and ebx,ecx shl ebx,3 push eax mov eax,[vramaddr] and ax,[vramincby8var] mov cl,[vramincby8totl] shr eax,cl add ebx,eax mov eax,[vramaddr] and ax,[vramincby8ptri] add ebx,eax pop eax pop ecx ; cmp [vrama+ebx+1],al ; je .nochange2 mov [vrama+ebx+1],al shr ebx,4 mov byte[vidmemch2+ebx],1 mov byte[vidmemch4+ebx],1 mov byte[vidmemch8+ebx],1 .nochange2 mov ebx,[addrincr] add [vramaddr],bx ret ; MODE7 settings register reg211Aw: mov [mode7set],al ret NEWSYM multchange, db 1 ; COS (COSINE) rotate angle / X Expansion reg211Bw: mov bl,[mode7A+1] mov [mode7A],bl mov [mode7A+1],al mov byte[multchange],1 ret ; SIN (SIN) rotate angle / X Expansion & Complement Multiplication Start reg211Cw: mov bl,[mode7B+1] mov [mode7B],bl mov [mode7B+1],al mov byte[multchange],1 ret ; SIN (SIN) rotate angle / Y Expansion reg211Dw: mov bl,[mode7C+1] mov [mode7C],bl mov [mode7C+1],al ret ; COS (COSINE) rotate angle / Y Expansion reg211Ew: mov bl,[mode7D+1] mov [mode7D],bl mov [mode7D+1],al ret ; Center position X (13-bit data only) reg211Fw: mov bl,[mode7X0+1] mov [mode7X0],bl mov [mode7X0+1],al ret ; Center position Y (13-bit data only) reg2120w: mov bl,[mode7Y0+1] mov [mode7Y0],bl mov [mode7Y0+1],al ret ; Colour # (or palette) selection register reg2121w: xor bh,bh mov bl,al shl bx,1 mov [cgaddr],bx and word[cgaddr],01FFh ret ; Colour data register reg2122w: xor ebx,ebx mov bx,[cgaddr] cmp [cgram+ebx],al je .nomod mov [cgram+ebx],al mov byte[cgmod],1 .nomod inc word[cgaddr] and word[cgaddr],01FFh ret ; Window mask settings register [W12SEL] reg2123w: mov bl,al and bl,0Fh test bl,0Ah jnz .nen1 ; or bl,02h .nen1 mov [winbg1en],bl mov bl,al shr bl,4 test bl,0Ah jnz .nen2 ; or bl,02h .nen2 mov [winbg2en],bl ret ; Window mask settings register [W34SEL] reg2124w: mov bl,al and bl,0Fh test bl,0Ah jnz .nen1 ; or bl,02h .nen1 mov [winbg3en],bl mov bl,al shr bl,4 test bl,0Ah jnz .nen2 ; or bl,02h .nen2 mov [winbg4en],bl ret ; Window mask settings register [WOBJSEL] reg2125w: mov bl,al and bl,0Fh mov [winobjen],bl mov bl,al shr bl,4 mov [wincolen],bl ret ; Window 1 left position register reg2126w: mov [winl1],al ret ; Window 1 right position register reg2127w: mov [winr1],al ret ; Window 2 left position register reg2128w: mov [winl2],al ret ; Window 2 right position register reg2129w: mov [winr2],al ret ; Mask logic settings for Window 1 & 2 per screen reg212Aw: mov [winlogica],al ret ; Mask logic settings for Colour Windows & OBJ Windows reg212Bw: mov [winlogicb],al ret ; Main screen designation reg212Cw: mov [scrnon],al ret ; Sub-screen designation reg212Dw: mov [scrnon+1],al ret ; Window mask main screen designation register reg212Ew: mov [winenabm],al ret ; Window mask sub screen designation register reg212Fw: mov [winenabs],al ret ; Fixed color addition or screen addition register reg2130w: mov [scaddset],al ret ; Addition/subtraction for screens, BGs, & OBJs reg2131w: mov [scaddtype],al ret ; Fixed colour data for fixed colour +/- reg2132w: mov bl,al and bl,1Fh test al,20h jz .nored mov [coladdr],bl .nored test al,40h jz .nogreen mov [coladdg],bl .nogreen test al,80h jz .noblue mov [coladdb],bl .noblue ret ; Screen mode/video select register reg2133w: mov [interlval],al and byte[interlval],41h test al,04h jnz .line239 mov word[resolutn],224 ret .line239 mov word[resolutn],239 ret NEWSYM CleartheScreen, db 0 ; Sound Register #1 reg2140w: mov byte[sndwrit],1 cmp byte[nmistatus],2 jne .n mov byte[nmirept],0 .n mov byte[spcRam+0F4h],al inc dword[SPC700write] reenablespc ret ; cmp dword[cycpbl],0FFFFh ; ja .spcreset ; ret ;.spcreset ; mov dword[cycpbl],100 ; ret ; Sound Register #2 reg2141w: mov byte[sndwrit],1 mov byte[spcRam+0F5h],al inc dword[SPC700write] reenablespc ret ; cmp dword[cycpbl],0FFFFh ; ja .spcreset ; ret ;.spcreset ; mov dword[cycpbl],100 ; ret ; Sound Register #3 reg2142w: mov byte[sndwrit],1 mov byte[spcRam+0F6h],al inc dword[SPC700write] reenablespc ret ; cmp dword[cycpbl],0FFFFh ; ja .spcreset ; ret ;.spcreset ; mov dword[cycpbl],100 ; ret ; Sound Register #4 reg2143w: mov byte[sndwrit],1 mov byte[spcRam+0F7h],al inc dword[SPC700write] reenablespc ret ; cmp dword[cycpbl],0FFFFh ; ja .spcreset ; ret ;.spcreset ; mov dword[cycpbl],100 ; ret ; Read/write WRAM register reg2180w: mov ebx,[wramrwadr] add ebx,[wramdata] mov [ebx],al inc dword[wramrwadr] and dword[wramrwadr],01FFFFh ret ; WRAM data register (low byte) reg2181w: mov byte[wramrwadr],al ret ; WRAM data register (middle byte) reg2182w: mov byte[wramrwadr+1],al ret ; WRAM data register (high byte) reg2183w: mov bl,al and bl,01h mov byte[wramrwadr+2],bl ret ; Joystick 1 & 2 status bytes NEWSYM MultiTapStat, db 0 reg4016w: test byte[INTEnab],1 jnz .nointenab mov ebx,[JoyAOrig] or ebx,0FFFFh mov [JoyANow],ebx mov ebx,[JoyBOrig] or ebx,0FFFFh mov [JoyBNow],ebx mov ebx,[JoyCOrig] or ebx,0FFFFh mov [JoyCNow],ebx mov ebx,[JoyDOrig] or ebx,0FFFFh mov [JoyDNow],ebx mov ebx,[JoyEOrig] or ebx,0FFFFh mov [JoyENow],ebx cmp al,01h jne .noreset or byte[MultiTapStat],1 ret .noreset and byte[MultiTapStat],0FEh ret .nointenab cmp al,01h jne .noone or byte[MultiTapStat],1 or byte[JoyCRead],2 ret .noone and byte[MultiTapStat],0FEh cmp al,0 jne near .nozero or byte[JoyCRead],1 cmp byte[JoyCRead],3 jne near .nozero .resetports mov ebx,[JoyAOrig] or ebx,0FFFFh mov [JoyANow],ebx or ebx,0FFFFh mov ebx,[JoyBOrig] or ebx,0FFFFh mov [JoyBNow],ebx or ebx,0FFFFh mov ebx,[JoyCOrig] or ebx,0FFFFh mov [JoyCNow],ebx or ebx,0FFFFh mov ebx,[JoyDOrig] or ebx,0FFFFh mov [JoyDNow],ebx or ebx,0FFFFh mov ebx,[JoyEOrig] or ebx,0FFFFh mov [JoyENow],ebx .nozero ret ; Joystick 1 & 2 status bytes reg4017w: ret ; Counter enable reg4200w: mov byte[INTEnab],al ret ; Programmable I/O port (out-port) reg4201w: mov bl,al and bl,80h and byte[MultiTapStat],07Fh or byte[MultiTapStat],bl ret ; Multiplicand 'A' reg4202w: mov [multa],al ret ; Multiplier 'B' reg4203w: push edx push eax xor ah,ah xor bh,bh mov bl,[multa] mul bx mov [multres],ax pop eax pop edx ret ; Dividend C (Low) reg4204w: mov [diva],al ret ; Dividend C (High) reg4205w: mov [diva+1],al ret ; Divisor B reg4206w: cmp al,0 je .divby0 push eax push edx xor ebx,ebx xor edx,edx mov bl,al mov ax,[diva] div bx mov [divres],ax mov [multres],dx pop edx pop eax ret .divby0 push eax mov word[divres],0FFFFh mov ax,[diva] mov [multres],ax pop eax ret DetermineHIRQExec cmp byte[HIRQSkip],1 je near .ret add dh,[HIRQCycNext] mov byte[HIRQCycNext],0 mov byte[HIRQNextExe],0 push eax push ecx push edx mov ax,[HIRQLoc] xor ecx,ecx mov cl,[cycpl] mul cx mov cx,340 div cx mov cl,[cycpl] sub cl,al pop edx cmp dh,cl ja .hirqokay .notokay pop ecx pop eax .ret ret .hirqokay sub dh,cl add dh,30 mov [HIRQCycNext],cl mov byte[HIRQNextExe],1 pop ecx pop eax ret ; Video horizontal IRQ beam position/pointer (Low) reg4207w: cmp [HIRQLoc],al je .nohirqc mov [HIRQLoc],al mov bx,[curypos] cmp bx,[VIRQLoc] je near DetermineHIRQExec .nohirqc ret ; Video horizontal IRQ beam position/pointer (High) reg4208w: cmp [HIRQLoc+1],al je .nohirqc mov [HIRQLoc+1],al mov bx,[curypos] cmp bx,[VIRQLoc] je near DetermineHIRQExec .nohirqc ret ; Video vertical IRQ beam position/pointer (Low) reg4209w: mov [VIRQLoc],al ; mov bx,[curypos] cmp byte[HIRQNextExe],1 je .nohirq ret .nohirq mov bx,[curypos] cmp bx,[VIRQLoc] je .nocancelhirq add dh,[HIRQCycNext] mov byte[HIRQCycNext],0 mov byte[HIRQNextExe],0 .nocancelhirq ret ; Video vertical IRQ beam position/pointer (High) reg420Aw: and al,01h mov [VIRQLoc+1],al mov bx,[totlines] sub bx,1 cmp word[VIRQLoc],bx jb .okvirqpos mov word[VIRQLoc],07FFFh .okvirqpos cmp byte[HIRQNextExe],1 je .nohirq ret .nohirq mov bx,[curypos] cmp bx,[VIRQLoc] je .nocancelhirq add dh,[HIRQCycNext] mov byte[HIRQCycNext],0 mov byte[HIRQNextExe],0 .nocancelhirq ret ; Cycle speed register reg420Dw: test al,01h jnz .speed358 ; 2.68 Mhz mov al,[opexec268] mov byte[cycpl],al ; 2.68 Mhz mov al,[opexec268cph] mov byte[cycphb],al ; 2.68 Mhz and byte[xirqb],00h mov bl,[cycpb268] mov byte[cycpblt],bl ; percentage of CPU/SPC to run ret .speed358 ; 3.58 Mhz mov al,[opexec358] mov byte[cycpl],al ; 3.58 Mhz mov al,[opexec358cph] mov byte[cycphb],al ; 3.58 Mhz or byte[xirqb],80h mov bl,[cycpb358] mov byte[cycpblt],bl ; percentage of CPU/SPC to run ret ; ??? reg420Ew: ret ; NMI Check register reg4210w: ret ; Video IRQ register reg4211w: ret ; Status register reg4212w: ret ; Product of Multiplication Result or Remainder of Divide Result (Low) reg4216w: ret ; DMA Control register reg43X0w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al mov byte[hdmarestart],1 ret ; DMA Destination register reg43X1w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al mov byte[hdmarestart],1 ret ; Source address (Low) reg43x2w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ; mov [dmadata+ebx+6],al ret ; Source address (High) reg43x3w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ; mov [dmadata+ebx+6],al ret ; Source bank address reg43x4w xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; DMA transfer size & HDMA address register (Low) reg43x5w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; DMA transfer size & HDMA address register (High) reg43x6w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; DMA transfer size & HDMA address register (Bank) reg43x7w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; Table Address of A-BUS by DMA < A2 Table Address (Low) reg43x8w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; Table Address of A-BUS by DMA < A2 Table Address (High) reg43x9w: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret ; Number of lines for HDMA transfer reg43XAw: xor ebx,ebx mov bx,cx sub bx,4300h mov [dmadata+ebx],al ret regINVALIDw: ; Invalid Register ret regexiter: mov bl,[xpb] mov ax,[xpc] test ax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax ; subtract program counter by address mov [.invaddr],bx mov bl,[xpb] mov [.invbank],bl mov al,[previdmode] mov ah,0 int 10h mov byte[invalid],1 mov [invreg],cx mov ah,9 mov edx,.invalidreg int 21h xor eax,eax mov ax,[invreg] call printhex mov ah,9 mov edx,.invalidreg int 21h xor eax,eax mov al,[.invbank] call printhex8 mov ax,[.invaddr] call printhex mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h mov eax,[numinst] call printnum jmp DosExit .invalidreg db 'Invalid Write Register : $' .invalidaddr db ' at address $' .invbank db 0 .invaddr db 0 zsnes-1.36/src/cpu/regsw.mac0100644000175000017500000000244707267141100015360 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM tableadc ;******************************************************* ; InitRegW Initializes Write Registers ;******************************************************* %macro reenablespc 0 cmp dword[cycpbl],1000000h jb %%enspc mov dword[cycpbl],0 test byte[curexecstate],02h jnz %%enspc or byte[curexecstate],02h push ebx xor ebx,ebx mov bl,dl mov edi,[tableadc+ebx*4] pop ebx %%enspc %endmacro %macro setregw 2 mov edi,%1 add edi,[regptw] mov eax,%2 mov [edi],eax %endmacro zsnes-1.36/src/cpu/s65816d.inc0100644000175000017500000006412607352143404015270 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM Sflagnz, Sflago, Sflagc,dmadata ;EXTSYM spcRamDP,spcRamDPb,spcRam EXTSYM IRAM ;******************************************************* ; Flag Setting Macros ;******************************************************* EXTSYM debuggeron %macro endloop 0 ; call sa1debug mov bl,[esi] inc esi sub dh,[cpucycle+ebx] jc %%cpuover jmp dword near [edi+ebx*4] %%cpuover ret %endmacro %macro restoredl 0 mov dword[Sflagnz],0 test dl,80h jz %%noneg or dword[Sflagnz],10000h %%noneg test dl,2h jnz %%zero or dword[Sflagnz],1 %%zero mov dword[Sflagc],0 test dl,01h jz %%nocarry mov dword[Sflagc],0FFh %%nocarry mov dword[Sflago],0 test dl,40h jz %%nov mov dword[Sflago],0FFh %%nov %endmacro %macro makedl 0 and dl,00111100b test dword[Sflagnz],18000h jz %%noneg or dl,80h %%noneg test dword[Sflagnz],0FFFFh jnz %%nozero or dl,02h %%nozero test dword[Sflagc],0FFh jz %%nocarry or dl,01h %%nocarry test dword[Sflago],0FFh jz %%nov or dl,40h %%nov %endmacro NEWSYM Ssplitflags restoredl ret NEWSYM Sjoinflags makedl ret ; Sets flags n and z according to al %macro flagsetnz8b 0 mov dword[Sflagnz],0 mov [Sflagnz+1],al endloop %endmacro ; Sets flags n and z according to ax %macro flagsetnz16b 0 mov cx,ax mov [Sflagnz],ecx endloop %endmacro ; Sets flags n and z according to al %macro flagsetnz8bnel 0 mov dword[Sflagnz],0 mov [Sflagnz+1],al %endmacro ; Sets flags n and z according to ax %macro flagsetnz16bnel 0 mov cx,ax mov [Sflagnz],ecx %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzc8b 0 mov dword[Sflagnz],0 mov al,[SA1xa] seto byte[Sflago] mov [Sflagnz+1],al jc .carry mov dword[Sflagc],0h endloop .carry mov dword[Sflagc],0FFh endloop %endmacro %macro flagsetnvzc16b 0 mov cx,[SA1xa] seto byte[Sflago] mov [Sflagnz],ecx jc .carry mov dword[Sflagc],0h endloop .carry mov dword[Sflagc],0FFh endloop %endmacro ; Sets flags N V . . . . Z C according to flags %macro flagsetnvzcs8b 0 mov dword[Sflagnz],0 mov al,[SA1xa] seto byte[Sflago] mov [Sflagnz+1],al jc .carry mov dword[Sflagc],0FFh endloop .carry mov dword[Sflagc],0h endloop %endmacro %macro flagsetnvzcs16b 0 mov cx,[SA1xa] seto byte[Sflago] mov [Sflagnz],ecx jc .carry mov dword[Sflagc],0FFh endloop .carry mov dword[Sflagc],0h endloop %endmacro ; Sets flags N V . . . . Z C for 16-bit decimal mode only %macro flagsetnvzcd 0 mov cx,[SA1xa] seto byte[Sflago] mov [Sflagnz],ecx jc .carry mov dword[Sflagc],0h endloop .carry mov dword[Sflagc],0FFh endloop %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc8b 0 mov dword[Sflagnz],0 mov dword[Sflagc],0h mov [Sflagnz+1],al jnc .carry mov dword[Sflagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and don't jump to execloop %macro flagsetnzc 0 mov cx,ax mov dword[Sflagc],0h mov [Sflagnz],ecx jnc .carry mov dword[Sflagc],0FFh .carry %endmacro ; Sets flags N . . . . . Z C according to flags and jump to execloop %macro flagsetnzcel8b 0 mov dword[Sflagnz],0h jc .carry mov [Sflagnz+1],cl mov dword[Sflagc],0FFh endloop .carry mov [Sflagnz+1],cl mov dword[Sflagc],0h endloop %endmacro %macro flagsetnzcel16b 0 jc .carry mov [Sflagnz],ecx mov dword[Sflagc],0FFh endloop .carry mov [Sflagnz],ecx mov dword[Sflagc],0h endloop %endmacro ;******************************************************* ; Opcode Instructions ;******************************************************* %macro ADCMacro8bnd 0 mov cl,[Sflagc] add cl,cl adc [SA1xa],al flagsetnvzc8b %endmacro %macro ADCMacro16bnd 0 mov cl,[Sflagc] add cl,cl adc [SA1xa],ax flagsetnvzc16b %endmacro %macro ADCMacro8bd 0 mov cl,[Sflagc] add cl,cl mov cl,al mov al,[SA1xa] adc al,cl daa mov [SA1xa],al flagsetnvzc8b endloop %endmacro %macro ADCMacro16bd 0 mov cl,[Sflagc] add cl,cl mov cx,ax mov al,[SA1xa] adc al,cl daa mov [SA1xa],al mov al,[SA1xa+1] adc al,ch daa mov [SA1xa+1],al flagsetnvzcd %endmacro %macro ANDMacro8b 0 and al,[SA1xa] mov dword[Sflagnz],0 mov [SA1xa],al mov [Sflagnz+1],al endloop %endmacro %macro ANDMacro16b 0 and eax,[SA1xa] mov [SA1xa],ax flagsetnz16b %endmacro %macro ASLMacro8b 0 add al,al flagsetnzc8b %endmacro %macro ASLMacro16b 0 add ax,ax flagsetnzc %endmacro %macro JumpMacro 0 movsx eax,byte[esi] add esi,eax .skip inc esi endloop %endmacro %macro BITMacroim8b 0 mov al,[esi] test dword[Sflagnz],18000h jz .notSflagnz or dword[Sflagnz],10000h .notSflagnz inc esi test [SA1xa],al jz .zero mov word[Sflagnz],1 endloop .zero mov word[Sflagnz],0 endloop %endmacro %macro BITMacroim16b 0 mov ax,[esi] test dword[Sflagnz],18000h jz .notSflagnz or dword[Sflagnz],10000h .notSflagnz add esi,2 test [SA1xa],ax jz .zero mov word[Sflagnz],1 endloop .zero mov word[Sflagnz],0 endloop %endmacro %macro BITMacro8b 0 mov dword[Sflagnz],10000h test al,80h jnz .flagn mov dword[Sflagnz],0 .flagn mov dword[Sflago],1 test al,40h jnz .Sflago mov dword[Sflago],0 .Sflago test [SA1xa],al jz .zero mov word[Sflagnz],1 endloop .zero mov word[Sflagnz],0 endloop %endmacro %macro BITMacro16b 0 mov dword[Sflagnz],10000h test ax,8000h jnz .flagn mov dword[Sflagnz],0 .flagn mov dword[Sflago],1 test ax,4000h jnz .Sflago mov dword[Sflago],0 .Sflago test [SA1xa],ax jz .zero mov word[Sflagnz],1 endloop .zero mov word[Sflagnz],0 endloop %endmacro %macro BRKMacro 0 inc esi test byte[xe],1 jne near BRKemulmode mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] mov bx,[SA1xs] mov cl,[SA1xpb] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [SA1xs],bx xor bh,bh mov bl,byte[xirqb] mov [SA1xpb],bl xor eax,eax mov ax,[brkv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop BRKemulmode mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] mov bx,[SA1xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [SA1xs],bx xor bh,bh mov bl,[SA1xpb] xor eax,eax mov ax,[brkv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro BRLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 xor eax,eax add bx,[esi] mov ax,bx xor ebx,ebx mov [xpc],ax mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CMPMacro8b 0 mov cl,[SA1xa] sub cl,al flagsetnzcel8b %endmacro %macro CMPMacro16b 0 mov cx,[SA1xa] sub cx,ax flagsetnzcel16b %endmacro %macro COPMacro 0 inc esi test byte[xe],1 jne near COPemulmode mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov cx,[SA1xs] mov al,[SA1xpb] call membank0w8 dec cx mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] makedl mov al,dl call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor bh,bh mov bl,byte[xirqb] mov [SA1xpb],bl xor eax,eax mov ax,[copv] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop COPemulmode mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov eax,[wramdata] mov bx,[SA1xs] mov cl,[xpc+1] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] mov cl,[xpc] mov [eax+ebx],cl dec bx and bx,word[stackand] or bx,word[stackor] makedl mov [eax+ebx],dl dec bx and bx,word[stackand] or bx,word[stackor] mov [SA1xs],bx xor bh,bh mov bl,[SA1xpb] xor eax,eax mov ax,[copv8] mov [xpc],ax and dl,11110011b or dl,00000100b test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro CPXMacro8b 0 mov cl,[SA1xx] sub cl,al flagsetnzcel8b %endmacro %macro CPXMacro16b 0 mov cx,[SA1xx] sub cx,ax flagsetnzcel16b %endmacro %macro CPYMacro8b 0 mov cl,[SA1xy] sub cl,al flagsetnzcel8b %endmacro %macro CPYMacro16b 0 mov cx,[SA1xy] sub cx,ax flagsetnzcel16b %endmacro %macro EORMacro8b 0 xor al,[SA1xa] mov dword[Sflagnz],0 mov [SA1xa],al mov [Sflagnz+1],al endloop %endmacro %macro EORMacro16b 0 xor eax,[SA1xa] mov [SA1xa],ax flagsetnz16b %endmacro %macro JMLMacro 0 mov cx,[esi] xor eax,eax call membank0r16 add cx,2 push eax call membank0r8 mov bl,al pop eax mov [xpc],ax mov [SA1xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro4C 0 xor eax,eax mov ax,[esi] mov bl,[SA1xpb] mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr ; mov esi,[snesmap2+ebx*4] ; mov [initaddrl],esi ; add esi,eax mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro6C 0 mov cx,[esi] xor eax,eax call membank0r16 mov [xpc],ax mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro7C 0 mov cx,[esi] xor eax,eax add cx,[SA1xx] mov bl,[SA1xpb] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JMPMacro5C 0 xor eax,eax mov bl,[esi+2] mov ax,[esi] mov [SA1xpb],bl mov [xpc],ax test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSLMacro 0 mov ebx,esi sub ebx,[initaddrl] add bx,2 mov [xpc],bx mov cx,[SA1xs] mov al,[SA1xpb] call membank0w8 dec cx mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor eax,eax xor bh,bh mov ax,[esi] mov bl,[esi+2] mov [xpc],ax mov [SA1xpb],bl test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr cmp ebx,0 jne .notupper cmp eax,2000h ja .upperbank .notupper mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop .upperbank mov esi,IRAM sub esi,3000h mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacro20 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[SA1xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor eax,eax mov ax,[esi] xor bh,bh mov [xpc],ax mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax endloop .upperlower mov [initaddrl],esi add esi,eax endloop %endmacro %macro JSRMacroFC 0 mov ebx,esi sub ebx,[initaddrl] inc bx mov [xpc],bx mov cx,[SA1xs] mov al,[xpc+1] call membank0w8 dec cx or cx,word[stackor] mov al,[xpc] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor eax,eax xor bh,bh mov cx,[esi] mov bl,[SA1xpb] add cx,[SA1xx] call dword near [memtabler16+ebx*4] mov [xpc],ax mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro LDAMacro8b 0 mov dword[Sflagnz],0 mov [SA1xa],al mov [Sflagnz+1],al endloop %endmacro %macro LDAMacro16b 0 mov [SA1xa],ax flagsetnz16b endloop %endmacro %macro LDXMacro8b 0 mov dword[Sflagnz],0 mov [SA1xx],al mov [Sflagnz+1],al endloop %endmacro %macro LDXMacro16b 0 mov [SA1xx],ax flagsetnz16b endloop %endmacro %macro LDYMacro8b 0 mov dword[Sflagnz],0 mov [SA1xy],al mov [Sflagnz+1],al endloop %endmacro %macro LDYMacro16b 0 mov [SA1xy],ax flagsetnz16b endloop %endmacro %macro LSRMacro8b 0 shr al,1 flagsetnzc8b %endmacro %macro LSRMacro16b 0 shr ax,1 flagsetnzc %endmacro %macro MVNMacro 0 mov ax,[esi] mov [SA1xdb],al mov bl,ah mov cx,[SA1xx] call dword near [memtabler8+ebx*4] mov bl,[SA1xdb] mov cx,[SA1xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero inc word[SA1xx] inc word[SA1xy] dec word[SA1xa] cmp word[SA1xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero inc byte[SA1xx] inc byte[SA1xy] dec word[SA1xa] cmp word[SA1xa],0FFFFh je .endmove dec esi endloop %endmacro %macro MVPMacro 0 mov ax,[esi] mov [SA1xdb],al mov bl,ah mov cx,[SA1xx] call dword near [memtabler8+ebx*4] mov bl,[SA1xdb] mov cx,[SA1xy] call dword near [memtablew8+ebx*4] test dl,10h jnz .pagezero dec word[SA1xx] dec word[SA1xy] dec word[SA1xa] cmp word[SA1xa],0FFFFh je .endmove dec esi endloop .endmove add esi,2 endloop .pagezero dec byte[SA1xx] dec byte[SA1xy] dec word[SA1xa] cmp word[SA1xa],0FFFFh je .endmove dec esi endloop %endmacro %macro ORAMacro8b 0 or al,[SA1xa] mov dword[Sflagnz],0 mov [SA1xa],al mov [Sflagnz+1],al endloop %endmacro %macro ORAMacro16b 0 or ax,[SA1xa] mov [SA1xa],ax flagsetnz16b %endmacro %macro PUSHMacro8b 1 mov eax,[wramdata] mov cx,[SA1xs] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx endloop %endmacro %macro PUSHMacro8bp 0 mov eax,[wramdata] makedl mov cx,[SA1xs] mov al,dl call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx endloop %endmacro %macro PUSHMacro16b 2 mov cx,[SA1xs] mov al,%2 call membank0w8 dec cx or cx,word[stackor] mov al,%1 call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx endloop %endmacro %macro PEAMacro 0 mov cx,[SA1xs] mov al,[esi+1] call membank0w8 dec cx or cx,word[stackor] mov al,[esi] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx add esi,2 endloop %endmacro %macro PEIMacro 0 xor ah,ah mov al,[esi] mov cx,[SA1xd] inc esi add cx,ax call membank0r16 mov cx,[SA1xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx endloop %endmacro %macro PERMacro 0 mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov eax,[snesmmap+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[SA1xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor ebx,ebx endloop .loweraddr mov eax,[snesmap2+ebx*4] mov ebx,esi sub ebx,eax add bx,[esi] mov ax,bx add esi,2 add ax,2 mov cx,[SA1xs] push eax mov al,ah call membank0w8 pop eax dec cx or cx,word[stackor] call membank0w8 dec cx or cx,word[stackor] mov [SA1xs],cx xor ebx,ebx endloop %endmacro %macro POPMacro8b 1 mov eax,[wramdata] mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov [SA1xs],cx mov %1,al flagsetnz8b endloop %endmacro %macro POPMacro16b 2 mov eax,[wramdata] mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [SA1xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al mov [SA1xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacro16bd 2 mov eax,[wramdata] mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov %1,al mov [SA1xs],cx inc cx and cx,word[stackand] call membank0r8 mov %2,al call SA1UpdateDPage mov [SA1xs],cx mov ah,al mov al,%1 flagsetnz16b %endmacro %macro POPMacroP 0 mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov [SA1xs],cx mov dl,al restoredl test byte[xe],01h jnz .emul mov bl,dl mov edi,[SA1tablead+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[SA1xx+1],0 mov byte[SA1xy+1],0 endloop .emul or dl,00110000b mov bl,dl mov edi,[SA1tablead+ebx*4] endloop %endmacro %macro REPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags not al and dl,al test byte[xe],01h jnz .emul mov bl,dl mov edi,[SA1tablead+ebx*4] endloop .emul or dl,00110000b mov bl,dl mov edi,[SA1tablead+ebx*4] endloop .extraflags not al makedl and dl,al restoredl test byte[xe],01h jnz .emul2 mov bl,dl mov edi,[SA1tablead+ebx*4] endloop .emul2 or dl,00110000b mov bl,dl mov edi,[SA1tablead+ebx*4] endloop %endmacro %macro ROLMacro8b 0 mov cl,[Sflagc] add cl,cl rcl al,1 flagsetnzc8b %endmacro %macro ROLMacro16b 0 mov cl,[Sflagc] add cl,cl rcl ax,1 flagsetnzc %endmacro %macro RORMacro8b 0 mov cl,[Sflagc] add cl,cl rcr al,1 flagsetnzc8b %endmacro %macro RORMacro16b 0 mov cl,[Sflagc] add cl,cl rcr ax,1 flagsetnzc %endmacro %macro RTIMacro 0 cmp byte[curexecstate],0 jne .nn xor dh,dh .nn .nodis658162 mov byte[curnmi],0 mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov dl,al restoredl inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] call membank0r8 mov [SA1xpb],al mov [SA1xs],cx xor bh,bh xor eax,eax mov bl,dl mov edi,[SA1tablead+ebx*4] mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop .loweraddr mov esi,[snesmap2+ebx*4] cmp eax,4300h jae .upperlower mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop .setx mov byte[SA1xx+1],0 mov byte[SA1xy+1],0 endloop .upperlower cmp dword[memtabler8+ebx*4],regaccessbankr8 je .dma mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop .dma mov esi,dmadata-4300h mov [initaddrl],esi add esi,eax test dl,00010000b jnz .setx endloop %endmacro %macro RTLMacro 0 mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al inc cx and cx,word[stackand] call membank0r8 mov [SA1xpb],al mov [SA1xs],cx xor bh,bh xor eax,eax inc word[xpc] mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro RTSMacro 0 mov cx,[SA1xs] inc cx and cx,word[stackand] call membank0r8 mov [xpc],al inc cx and cx,word[stackand] call membank0r8 mov [xpc+1],al mov [SA1xs],cx xor bh,bh inc word[xpc] xor eax,eax mov ax,[xpc] mov bl,[SA1xpb] test eax,8000h jz .loweraddr mov esi,[snesmmap+ebx*4] mov [initaddrl],esi add esi,eax endloop .loweraddr mov esi,[snesmap2+ebx*4] mov [initaddrl],esi add esi,eax endloop %endmacro %macro SBCMacro8bnd 0 mov cl,[Sflagc] sub cl,1 sbb [SA1xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bnd 0 mov cl,[Sflagc] sub cl,1 sbb [SA1xa],ax flagsetnvzcs16b endloop %endmacro %macro SBCMacro8bd 0 mov cl,[Sflagc] sub cl,1 mov cl,al mov al,[SA1xa] sbb al,cl das mov [SA1xa],al flagsetnvzcs8b endloop %endmacro %macro SBCMacro16bd 0 mov cl,[Sflagc] sub cl,1 mov cx,ax mov al,[SA1xa] sbb al,cl das mov [SA1xa],al mov al,[SA1xa+1] sbb al,ch das mov [SA1xa+1],al cmc flagsetnvzcd endloop %endmacro %macro SEPMacro 0 mov al,[esi] inc esi test al,11000011b jnz .extraflags or dl,al mov bl,dl mov edi,[SA1tablead+ebx*4] test dl,00010000b jnz .setx endloop .setx mov byte[SA1xx+1],0 mov byte[SA1xy+1],0 endloop .extraflags makedl or dl,al restoredl mov bl,dl mov edi,[SA1tablead+ebx*4] test dl,00010000b jnz .setx2 endloop .setx2 mov byte[SA1xx+1],0 mov byte[SA1xy+1],0 endloop %endmacro %macro STAMacro8b 0 mov al,[SA1xa] %endmacro %macro STAMacro16b 0 mov eax,[SA1xa] %endmacro %macro STXMacro8b 0 mov al,[SA1xx] %endmacro %macro STXMacro16b 0 mov eax,[SA1xx] %endmacro %macro STYMacro8b 0 mov al,[SA1xy] %endmacro %macro STYMacro16b 0 mov eax,[SA1xy] %endmacro %macro WAIMacro 0 cmp byte[intrset],1 jne .notws dec esi endloop .notws test byte[intrset],0FFh jz .waitstate cmp byte[intrset],2 je .stopint dec esi endloop .waitstate mov byte[intrset],1 dec esi endloop .stopint mov byte[intrset],0 endloop %endmacro %macro XCEMacro 0 mov al,[Sflagc] mov dword[Sflagc],0 and al,00000001b test byte[xe],0FFh jz .noemul mov dword[Sflagc],0FFh .noemul mov [xe],al test byte[xe],01h jnz .emul or dl,00100000b mov word[stackand],0FFFFh mov word[stackor],0000h endloop .emul or dl,00110000b mov bl,dl mov edi,[SA1tablead+ebx*4] mov byte[SA1xx+1],0 mov byte[SA1xy+1],0 mov byte[SA1xs+1],1 mov word[stackand],01FFh mov word[stackor],0100h endloop %endmacro zsnes-1.36/src/cpu/saddress.inc0100644000175000017500000003317707267141100016056 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM SA1DPageR8,SA1DPageR16,SA1DPageW8,SA1DPageW16 ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8br 0 mov al,[esi] inc esi %endmacro %macro addr_I_16br 0 mov eax,[esi] add esi,2 %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 call dword near [memtabler16+ebx*4] %endmacro %macro addr_a_8bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 call dword near [memtablew8+ebx*4] %endmacro %macro addr_a_16bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 call dword near [memtablew16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtabler16+ebx*4] %endmacro %macro addr_al_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew8+ebx*4] %endmacro %macro addr_al_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 call dword near [memtablew16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR8] %endmacro %macro addr_d_16br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] %endmacro %macro addr_d_8bw 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageW8] %endmacro %macro addr_d_16bw 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageW16] %endmacro ; 5. Accumulator -- A %macro addr_A_8br 0 mov al,[SA1xa] %endmacro %macro addr_A_16br 0 mov eax,[SA1xa] %endmacro %macro addr_A_8bw 0 mov [SA1xa],al %endmacro %macro addr_A_16bw 0 mov [SA1xa],ax %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdBCy_8bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdBCy_16bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np pop ax call dword near [memtablew16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdLCy_8bw 0 push ax mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] pop ax jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdLCy_16bw 0 push ax mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi push cx call membank0r16 pop cx add cx,2 xor bl,bl push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] pop ax jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCxB_8bw 0 push ax mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCxB_16bw 0 push ax mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r8 %endmacro %macro addr_dCx_16br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0r16 %endmacro %macro addr_dCx_8bw 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0w8 %endmacro %macro addr_dCx_16bw 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xx] call membank0w16 %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xy] call membank0r8 %endmacro %macro addr_dCy_16br 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xy] call membank0r16 %endmacro %macro addr_dCy_8bw 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xy] call membank0w8 %endmacro %macro addr_dCy_16bw 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx inc esi add cx,[SA1xy] call membank0w16 %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCx_8bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCx_16bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16br 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_aCy_8bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_aCy_16bw 0 mov cx,[esi] mov bl,[SA1xdb] add esi,2 add cx,[SA1xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16br 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_alCx_8bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_alCx_16bw 0 mov cx,[esi] mov bl,[esi+2] add esi,3 add cx,[SA1xx] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdB_8bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdB_16bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] pop ax call dword near [memtablew16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16br 0 mov bl,[esi] mov ecx,[SA1xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro %macro addr_LdL_8bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew8+ebx*4] %endmacro %macro addr_LdL_16bw 0 push ax mov bl,[esi] mov ecx,[SA1xd] inc esi add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax pop ax call dword near [memtablew16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8br 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r8 %endmacro %macro addr_dCs_16br 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r16 %endmacro %macro addr_dCs_8bw 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0w8 %endmacro %macro addr_dCs_16bw 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0w16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8br 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16br 0 mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .np inc bl .np call dword near [memtabler16+ebx*4] %endmacro %macro addr_BdCsBCy_8bw 0 push ax mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] pop ax add cx,[SA1xy] jnc .np inc bl .np call dword near [memtablew8+ebx*4] %endmacro %macro addr_BdCsBCy_16bw 0 push ax mov bl,[esi] mov cx,[SA1xs] inc esi add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] pop ax add cx,[SA1xy] jnc .np inc bl .np call dword near [memtablew16+ebx*4] %endmacro zsnes-1.36/src/cpu/saddrni.inc0100644000175000017500000001712307267141100015663 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;******************************************************* ; Address Modes ;******************************************************* ; 1. Immediate Addressing -- # - DONE IN PROGRAM %macro addr_I_8brni 0 mov al,[esi] %endmacro %macro addr_I_16brni 0 mov ax,[esi] %endmacro ; 2. Absolute -- a (TESTED) %macro addr_a_8brni 0 mov cx,[esi] mov bl,[SA1xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_a_16brni 0 mov cx,[esi] mov bl,[SA1xdb] call dword near [memtabler16+ebx*4] %endmacro ; 3. Absolute Long -- al %macro addr_al_8brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler8+ebx*4] %endmacro %macro addr_al_16brni 0 mov cx,[esi] mov bl,[esi+2] call dword near [memtabler16+ebx*4] %endmacro ; 4. Direct -- d (TESTED) %macro addr_d_8brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR8] %endmacro %macro addr_d_16brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR16] %endmacro ; 5. Accumulator -- A %macro addr_A_8brni 0 mov al,[SA1xa] %endmacro %macro addr_A_16brni 0 mov ax,[SA1xa] %endmacro ; 7. Direct Indirect Indexed -- (d),y %macro addr_BdBCy_8brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdBCy_16brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 8. Direct Indirect Indexed Long -- [d],y %macro addr_LdLCy_8brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdLCy_16brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 9. Direct Indexed Indirect -- (d,x) %macro addr_BdCxB_8brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCxB_16brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xx] call membank0r16 mov cx,ax mov bl,[SA1xdb] call dword near [memtabler16+ebx*4] %endmacro ; 10. Direct Indexed With X -- d,x %macro addr_dCx_8brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xx] call membank0r8 %endmacro %macro addr_dCx_16brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xx] call membank0r16 %endmacro ; 11. Direct Indexed With Y -- d,y %macro addr_dCy_8brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xy] call membank0r8 %endmacro %macro addr_dCy_16brni 0 mov ecx,[SA1xd] mov bl,[esi] add cx,bx add cx,[SA1xy] call membank0r16 %endmacro ; 12. Absolute Indexed With X -- a,x %macro addr_aCx_8brni 0 mov cx,[esi] mov bl,[SA1xdb] add cx,[SA1xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCx_16brni 0 mov cx,[esi] mov bl,[SA1xdb] add cx,[SA1xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 13. Absolute Indexed With Y -- a,y %macro addr_aCy_8brni 0 mov cx,[esi] mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_aCy_16brni 0 mov cx,[esi] mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 14. Absolute Long Indexed With X -- al,x %macro addr_alCx_8brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[SA1xx] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_alCx_16brni 0 mov cx,[esi] mov bl,[esi+2] add cx,[SA1xx] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro ; 18. Direct Indirect -- (d) ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; | 00 | (direct address) | ; + | DB | ; ------------------------------- ; Address: | effective address | %macro addr_BdB_8brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdB_16brni 0 mov bl,[esi] mov ecx,[SA1xd] call dword near [SA1DPageR16] mov cx,ax mov bl,[SA1xdb] call dword near [memtabler16+ebx*4] %endmacro ; 19. Direct Indirect Long -- [d] ; ___________________ ; Instruction: | opcode | offset | ; ~~~~~~~~~~~~~~~~~~~ ; | Direct Register | ; + | offset | ; --------------------- ; | 00 | direct address | ; then: ; ------------------------------- ; Address: | (direct address) | %macro addr_LdL_8brni 0 mov bl,[esi] mov ecx,[SA1xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler8+ebx*4] %endmacro %macro addr_LdL_16brni 0 mov bl,[esi] mov ecx,[SA1xd] add cx,bx push cx call membank0r16 pop cx add cx,2 push ax call membank0r8 mov bl,al pop ax mov cx,ax call dword near [memtabler16+ebx*4] %endmacro ; 22. Stack Relative -- d,s %macro addr_dCs_8brni 0 mov bl,[esi] mov cx,[SA1xs] add cx,bx call membank0r8 %endmacro %macro addr_dCs_16brni 0 mov bl,[esi] mov cx,[SA1xs] add cx,bx call membank0r16 %endmacro ; 23. Stack Relative Indirect Indexed -- (d,s),y (TESTED) %macro addr_BdCsBCy_8brni 0 mov bl,[esi] mov cx,[SA1xs] add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler8+ebx*4] %endmacro %macro addr_BdCsBCy_16brni 0 mov bl,[esi] mov cx,[SA1xs] add cx,bx call membank0r16 mov cx,ax mov bl,[SA1xdb] add cx,[SA1xy] jnc .npb inc bl .npb call dword near [memtabler16+ebx*4] %endmacro zsnes-1.36/src/cpu/se65816.inc0100644000175000017500000010435207352143404015265 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. EXTSYM brkv,brkv8,copv,copv8,curexecstate,curnmi EXTSYM initaddrl,membank0r16,membank0r8 EXTSYM membank0w16,membank0w8,memtabler16,memtabler8,memtablew16,memtablew8 EXTSYM nmistatus,regaccessbankr8,snesmap2,snesmmap,stackand,stackor EXTSYM wramdata,SA1xa,SA1xd,SA1xdb,xe,xirqb,SA1xpb,xpc,SA1xs,SA1xx,SA1xy EXTSYM switchtovirq,cpuoverptr,debstop4,SA1RegP,nextopcode,debugsa1,skipdebugsa1 sa1debug: cmp byte[debuggeron],0 je .nodebugger cmp byte[skipdebugsa1],1 je .nodebugger pushad mov bl,[SA1xpb] mov ax,[xpc] test eax,8000h jz .loweraddr2 mov eax,[snesmmap+ebx*4] jmp .nextaddr .loweraddr2 mov eax,[snesmap2+ebx*4] .nextaddr mov ebx,esi sub ebx,eax mov [xpc],bx mov [SA1RegP],dl mov byte[debugsa1],1 call nextopcode popad .nodebugger ret ; B = ( or ) ; C = , ; L = [ or ] ; I = # SA1COp61m8nd: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bnd SA1COp61m16nd: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bnd SA1COp61m8d: ; ADC(d,x) addr_BdCxB_8br ADCMacro8bd SA1COp61m16d: ; ADC(d,x) addr_BdCxB_16br ADCMacro16bd SA1COp63m8nd: ; ADC d,s addr_dCs_8br ADCMacro8bnd SA1COp63m16nd: ; ADC d,s addr_dCs_16br ADCMacro16bnd SA1COp63m8d: ; ADC d,s addr_dCs_8br ADCMacro8bd SA1COp63m16d: ; ADC d,s addr_dCs_16br ADCMacro16bd SA1COp65m8nd: ; ADC d addr_d_8br ADCMacro8bnd SA1COp65m16nd: ; ADC d addr_d_16br ADCMacro16bnd SA1COp65m8d: ; ADC d addr_d_8br ADCMacro8bd SA1COp65m16d: ; ADC d addr_d_16br ADCMacro16bd SA1COp67m8nd: ; ADC [d] addr_LdL_8br ADCMacro8bnd SA1COp67m16nd: ; ADC [d] addr_LdL_16br ADCMacro16bnd SA1COp67m8d: ; ADC [d] addr_LdL_8br ADCMacro8bd SA1COp67m16d: ; ADC [d] addr_LdL_16br ADCMacro16bd SA1COp69m8nd: ; ADC # addr_I_8br ADCMacro8bnd SA1COp69m16nd: ; ADC # addr_I_16br ADCMacro16bnd SA1COp69m8d: ; ADC # addr_I_8br ADCMacro8bd SA1COp69m16d: ; ADC # addr_I_16br ADCMacro16bd SA1COp6Dm8nd: ; ADC a addr_a_8br ADCMacro8bnd SA1COp6Dm16nd: ; ADC a addr_a_16br ADCMacro16bnd SA1COp6Dm8d: ; ADC a addr_a_8br ADCMacro8bd SA1COp6Dm16d: ; ADC a addr_a_16br ADCMacro16bd SA1COp6Fm8nd: ; ADC al addr_al_8br ADCMacro8bnd SA1COp6Fm16nd: ; ADC al addr_al_16br ADCMacro16bnd SA1COp6Fm8d: ; ADC al addr_al_8br ADCMacro8bd SA1COp6Fm16d: ; ADC al addr_al_16br ADCMacro16bd SA1COp71m8nd: ; ADC(d),y addr_BdBCy_8br ADCMacro8bnd SA1COp71m16nd: ; ADC(d),y addr_BdBCy_16br ADCMacro16bnd SA1COp71m8d: ; ADC(d),y addr_BdBCy_8br ADCMacro8bd SA1COp71m16d: ; ADC(d),y addr_BdBCy_16br ADCMacro16bd SA1COp72m8nd: ; ADC (d) addr_BdB_8br ADCMacro8bnd SA1COp72m16nd: ; ADC (d) addr_BdB_16br ADCMacro16bnd SA1COp72m8d: ; ADC (d) addr_BdB_8br ADCMacro8bd SA1COp72m16d: ; ADC (d) addr_BdB_16br ADCMacro16bd SA1COp73m8nd: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bnd SA1COp73m16nd: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bnd SA1COp73m8d: ; ADC(d,s),y addr_BdCsBCy_8br ADCMacro8bd SA1COp73m16d: ; ADC(d,s),y addr_BdCsBCy_16br ADCMacro16bd SA1COp75m8nd: ; ADC d,x addr_dCx_8br ADCMacro8bnd SA1COp75m16nd: ; ADC d,x addr_dCx_16br ADCMacro16bnd SA1COp75m8d: ; ADC d,x addr_dCx_8br ADCMacro8bd SA1COp75m16d: ; ADC d,x addr_dCx_16br ADCMacro16bd SA1COp77m8nd: ; ADC [d],y addr_LdLCy_8br ADCMacro8bnd SA1COp77m16nd: ; ADC [d],y addr_LdLCy_16br ADCMacro16bnd SA1COp77m8d: ; ADC [d],y addr_LdLCy_8br ADCMacro8bd SA1COp77m16d: ; ADC [d],y addr_LdLCy_16br ADCMacro16bd SA1COp79m8nd: ; ADC a,y addr_aCy_8br ADCMacro8bnd SA1COp79m16nd: ; ADC a,y addr_aCy_16br ADCMacro16bnd SA1COp79m8d: ; ADC a,y addr_aCy_8br ADCMacro8bd SA1COp79m16d: ; ADC a,y addr_aCy_16br ADCMacro16bd SA1COp7Dm8nd: ; ADC a,x addr_aCx_8br ADCMacro8bnd SA1COp7Dm16nd: ; ADC a,x addr_aCx_16br ADCMacro16bnd SA1COp7Dm8d: ; ADC a,x addr_aCx_8br ADCMacro8bd SA1COp7Dm16d: ; ADC a,x addr_aCx_16br ADCMacro16bd SA1COp7Fm8nd: ; ADC al,x addr_alCx_8br ADCMacro8bnd SA1COp7Fm16nd: ; ADC al,x addr_alCx_16br ADCMacro16bnd SA1COp7Fm8d: ; ADC al,x addr_alCx_8br ADCMacro8bd SA1COp7Fm16d: ; ADC al,x addr_alCx_16br ADCMacro16bd SA1COp21m8: ; AND(d,x) addr_BdCxB_8br ANDMacro8b SA1COp21m16:; AND(d,x) addr_BdCxB_16br ANDMacro16b SA1COp23m8: ; AND d,s addr_dCs_8br ANDMacro8b SA1COp23m16:; AND d,s addr_dCs_16br ANDMacro16b SA1COp25m8: ; AND d addr_d_8br ANDMacro8b SA1COp25m16:; AND d addr_d_16br ANDMacro16b SA1COp27m8: ; AND [d] addr_LdL_8br ANDMacro8b SA1COp27m16:; AND [d] addr_LdL_16br ANDMacro16b SA1COp29m8: ; AND # addr_I_8br ANDMacro8b SA1COp29m16:; AND # addr_I_16br ANDMacro16b SA1COp2Dm8: ; AND a addr_a_8br ANDMacro8b SA1COp2Dm16:; AND a addr_a_16br ANDMacro16b SA1COp2Fm8: ; AND al addr_al_8br ANDMacro8b SA1COp2Fm16:; AND al addr_al_16br ANDMacro16b SA1COp31m8: ; AND(d),y addr_BdBCy_8br ANDMacro8b SA1COp31m16:; AND(d),y addr_BdBCy_16br ANDMacro16b SA1COp32m8: ; AND (d) addr_BdB_8br ANDMacro8b SA1COp32m16:; AND (d) addr_BdB_16br ANDMacro16b SA1COp33m8: ; AND(d,s),y addr_BdCsBCy_8br ANDMacro8b SA1COp33m16:; AND(d,s),y addr_BdCsBCy_16br ANDMacro16b SA1COp35m8: ; AND d,x addr_dCx_8br ANDMacro8b SA1COp35m16:; AND d,x addr_dCx_16br ANDMacro16b SA1COp37m8: ; AND [d],y addr_LdLCy_8br ANDMacro8b SA1COp37m16:; AND [d],y addr_LdLCy_16br ANDMacro16b SA1COp39m8: ; AND a,y addr_aCy_8br ANDMacro8b SA1COp39m16:; AND a,y addr_aCy_16br ANDMacro16b SA1COp3Dm8: ; AND a,x addr_aCx_8br ANDMacro8b SA1COp3Dm16:; AND a,x addr_aCx_16br ANDMacro16b SA1COp3Fm8: ; AND al,x addr_alCx_8br ANDMacro8b SA1COp3Fm16:; AND al,x addr_alCx_16br ANDMacro16b SA1COp06m8: ; ASL d addr_d_8brni ASLMacro8b addr_d_8bw endloop SA1COp06m16:; ASL d addr_d_16brni ASLMacro16b addr_d_16bw endloop SA1COp0Am8: ; ASL A addr_A_8brni ASLMacro8b addr_A_8bw endloop SA1COp0Am16:; ASL A addr_A_16brni ASLMacro16b addr_A_16bw endloop SA1COp0Em8: ; ASL a addr_a_8brni ASLMacro8b addr_a_8bw endloop SA1COp0Em16:; ASL a addr_a_16brni ASLMacro16b addr_a_16bw endloop SA1COp16m8: ; ASL d,x addr_dCx_8brni ASLMacro8b addr_dCx_8bw endloop SA1COp16m16:; ASL d,x addr_dCx_16brni ASLMacro16b addr_dCx_16bw endloop SA1COp1Em8: ; ASL a,x addr_aCx_8brni ASLMacro8b addr_aCx_8bw endloop SA1COp1Em16:; ASL a,x addr_aCx_16brni ASLMacro16b addr_aCx_16bw endloop SA1COp90: ; BCC r test byte[Sflagc],01h jnz .skip JumpMacro SA1COpB0: ; BCS r test byte[Sflagc],01h jz .skip JumpMacro SA1COpF0: ; BEQ r test dword[Sflagnz],0FFFFh jnz .skip JumpMacro SA1COp30: ; BMI r test dword[Sflagnz],018000h jz .skip JumpMacro SA1COpD0: ; BNE r test dword[Sflagnz],0FFFFh jz .skip JumpMacro SA1COp10: ; BPL r test dword[Sflagnz],018000h jnz .skip JumpMacro SA1COp80: ; BRA r movsx eax,byte[esi] inc esi add esi,eax endloop SA1COp50: ; BVC r test dword[Sflago],0FFh jnz .skip JumpMacro SA1COp70: ; BVS r test dword[Sflago],0FFh jz .skip JumpMacro ; BIT instruction does not affect N and V flags when using immediate ; addressing mode. When using other addressing modes, the N and V flags SA1COp89m8: ; BIT # BITMacroim8b SA1COp89m16:; BIT # BITMacroim16b SA1COp24m8: ; BIT d addr_d_8br BITMacro8b SA1COp24m16:; BIT d addr_d_16br BITMacro16b SA1COp2Cm8: ; BIT a addr_a_8br BITMacro8b SA1COp2Cm16:; BIT a addr_a_16br BITMacro16b SA1COp34m8: ; BIT d,x addr_dCx_8br BITMacro8b SA1COp34m16:; BIT d,x addr_dCx_16br BITMacro16b SA1COp3Cm8: ; BIT a,x addr_aCx_8br BITMacro8b SA1COp3Cm16:; BIT a,x addr_aCx_16br BITMacro16b SA1COp00: ; BRK s mov byte[debstop4],1 dec esi endloop BRKMacro SA1COp82: ; BRL rl BRLMacro SA1COp18: ; CLC i mov dword[Sflagc],0 endloop SA1COpD8: ; CLD i and dl,0F7h mov bl,dl mov edi,[SA1tablead+ebx*4] endloop SA1COp58: ; CLI i and dl,0FBh endloop SA1COpB8: ; CLV i mov dword[Sflago],0 endloop SA1COpC1m8: ; CMP(d,x) addr_BdCxB_8br CMPMacro8b SA1COpC1m16:; CMP(d,x) addr_BdCxB_16br CMPMacro16b SA1COpC3m8: ; CMP d,s addr_dCs_8br CMPMacro8b SA1COpC3m16:; CMP d,s addr_dCs_16br CMPMacro16b SA1COpC5m8: ; CMP d addr_d_8br CMPMacro8b SA1COpC5m16:; CMP d addr_d_16br CMPMacro16b SA1COpC7m8: ; CMP [d] addr_LdL_8br CMPMacro8b SA1COpC7m16:; CMP [d] addr_LdL_16br CMPMacro16b SA1COpC9m8: ; CMP # addr_I_8br CMPMacro8b SA1COpC9m16:; CMP # addr_I_16br CMPMacro16b SA1COpCDm8: ; CMP a addr_a_8br CMPMacro8b SA1COpCDm16:; CMP a addr_a_16br CMPMacro16b SA1COpCFm8: ; CMP al addr_al_8br CMPMacro8b SA1COpCFm16:; CMP al addr_al_16br CMPMacro16b SA1COpD1m8: ; CMP(d),y addr_BdBCy_8br CMPMacro8b SA1COpD1m16:; CMP(d),y addr_BdBCy_16br CMPMacro16b SA1COpD2m8: ; CMP (d) addr_BdB_8br CMPMacro8b SA1COpD2m16:; CMP (d) addr_BdB_16br CMPMacro16b SA1COpD3m8: ; CMP(d,s),y addr_BdCsBCy_8br CMPMacro8b SA1COpD3m16:; CMP(d,s),y addr_BdCsBCy_16br CMPMacro16b SA1COpD5m8: ; CMP d,x addr_dCx_8br CMPMacro8b SA1COpD5m16:; CMP d,x addr_dCx_16br CMPMacro16b SA1COpD7m8: ; CMP [d],y addr_LdLCy_8br CMPMacro8b SA1COpD7m16:; CMP [d],y addr_LdLCy_16br CMPMacro16b SA1COpD9m8: ; CMP a,y addr_aCy_8br CMPMacro8b SA1COpD9m16:; CMP a,y addr_aCy_16br CMPMacro16b SA1COpDDm8: ; CMP a,x addr_aCx_8br CMPMacro8b SA1COpDDm16:; CMP a,x addr_aCx_16br CMPMacro16b SA1COpDFm8: ; CMP al,x addr_alCx_8br CMPMacro8b SA1COpDFm16:; CMP al,x addr_alCx_16br CMPMacro16b SA1COp02: ; SA1COp s COPMacro SA1COpE0x8: ; CPX # addr_I_8br CPXMacro8b SA1COpE0x16:; CPX # addr_I_16br CPXMacro16b SA1COpE4x8: ; CPX d addr_d_8br CPXMacro8b SA1COpE4x16:; CPX d addr_d_16br CPXMacro16b SA1COpECx8: ; CPX a addr_a_8br CPXMacro8b SA1COpECx16:; CPX a addr_a_16br CPXMacro16b SA1COpC0x8: ; CPY # addr_I_8br CPYMacro8b SA1COpC0x16:; CPY # addr_I_16br CPYMacro16b SA1COpC4x8: ; CPY d addr_d_8br CPYMacro8b SA1COpC4x16:; CPY d addr_d_16br CPYMacro16b SA1COpCCx8: ; CPY a addr_a_8br CPYMacro8b SA1COpCCx16:; CPY a addr_a_16br CPYMacro16b SA1COp3Am8: ; DEC A addr_A_8brni dec al flagsetnz8bnel addr_A_8bw endloop SA1COp3Am16:; DEC A addr_A_16brni dec ax flagsetnz16bnel addr_A_16bw endloop SA1COpCEm8: ; DEC a addr_a_8brni dec al flagsetnz8bnel addr_a_8bw endloop SA1COpCEm16:; DEC a addr_a_16brni dec ax flagsetnz16bnel addr_a_16bw endloop SA1COpC6m8: ; DEC d addr_d_8brni dec al flagsetnz8bnel addr_d_8bw endloop SA1COpC6m16:; DEC d addr_d_16brni dec ax flagsetnz16bnel addr_d_16bw endloop SA1COpD6m8: ; DEC d,x addr_dCx_16brni dec al flagsetnz8bnel addr_dCx_16bw endloop SA1COpD6m16:; DEC d,x addr_dCx_16brni dec ax flagsetnz16bnel addr_dCx_16bw endloop SA1COpDEm8: ; DEC a,x addr_aCx_8brni dec al flagsetnz8bnel addr_aCx_8bw endloop SA1COpDEm16:; DEC a,x addr_aCx_16brni dec ax flagsetnz16bnel addr_aCx_16bw endloop SA1COpCAx8: ; DEX i dec byte[SA1xx] mov al,[SA1xx] flagsetnz8b endloop SA1COpCAx16:; DEX i dec word[SA1xx] mov ax,[SA1xx] flagsetnz16b endloop SA1COp88x8: ; DEY i dec byte[SA1xy] mov al,[SA1xy] flagsetnz8b endloop SA1COp88x16:; DEY i dec word[SA1xy] mov ax,[SA1xy] flagsetnz16b endloop SA1COp41m8: ; EOR(d,x) addr_BdCxB_8br EORMacro8b SA1COp41m16:; EOR(d,x) addr_BdCxB_16br EORMacro16b SA1COp43m8: ; EOR d,s addr_dCs_8br EORMacro8b SA1COp43m16:; EOR d,s addr_dCs_16br EORMacro16b SA1COp45m8: ; EOR d addr_d_8br EORMacro8b SA1COp45m16:; EOR d addr_d_16br EORMacro16b SA1COp47m8: ; EOR [d] addr_LdL_8br EORMacro8b SA1COp47m16:; EOR [d] addr_LdL_16br EORMacro16b SA1COp49m8: ; EOR # addr_I_8br EORMacro8b SA1COp49m16:; EOR # addr_I_16br EORMacro16b SA1COp4Dm8: ; EOR a addr_a_8br EORMacro8b SA1COp4Dm16:; EOR a addr_a_16br EORMacro16b SA1COp4Fm8: ; EOR al addr_al_8br EORMacro8b SA1COp4Fm16:; EOR al addr_al_16br EORMacro16b SA1COp51m8: ; EOR(d),y addr_BdBCy_8br EORMacro8b SA1COp51m16:; EOR(d),y addr_BdBCy_16br EORMacro16b SA1COp52m8: ; EOR (d) addr_BdB_8br EORMacro8b SA1COp52m16:; EOR (d) addr_BdB_16br EORMacro16b SA1COp53m8: ; EOR(d,s),y addr_BdCsBCy_8br EORMacro8b SA1COp53m16:; EOR(d,s),y addr_BdCsBCy_16br EORMacro16b SA1COp55m8: ; EOR d,x addr_dCx_8br EORMacro8b SA1COp55m16:; EOR d,x addr_dCx_16br EORMacro16b SA1COp57m8: ; EOR [d],y addr_LdLCy_8br EORMacro8b SA1COp57m16:; EOR [d],y addr_LdLCy_16br EORMacro16b SA1COp59m8: ; EOR a,y addr_aCy_8br EORMacro8b SA1COp59m16:; EOR a,y addr_aCy_16br EORMacro16b SA1COp5Dm8: ; EORa,x addr_aCx_8br EORMacro8b SA1COp5Dm16:; EORa,x addr_aCx_16br EORMacro16b SA1COp5Fm8: ; EOR al,x addr_alCx_8br EORMacro8b SA1COp5Fm16:; EOR al,x addr_alCx_16br EORMacro16b SA1COp1Am8: ; INC A addr_A_8brni inc al flagsetnz8bnel addr_A_8bw endloop SA1COp1Am16:; INC A addr_A_16brni inc ax flagsetnz16bnel addr_A_16bw endloop SA1COpEEm8: ; INC a addr_a_8brni inc al flagsetnz8bnel addr_a_8bw endloop SA1COpEEm16:; INC a addr_a_16brni inc ax flagsetnz16bnel addr_a_16bw endloop SA1COpE6m8: ; INC d addr_d_8brni inc al flagsetnz8bnel addr_d_8bw endloop SA1COpE6m16:; INC d addr_d_16brni inc ax flagsetnz16bnel addr_d_16bw endloop SA1COpF6m8: ; INC d,x addr_dCx_8brni inc al flagsetnz8bnel addr_dCx_8bw endloop SA1COpF6m16:; INC d,x addr_dCx_16brni inc ax flagsetnz16bnel addr_dCx_16bw endloop SA1COpFEm8: ; INC a,x addr_aCx_8brni inc al flagsetnz8bnel addr_aCx_8bw endloop SA1COpFEm16:; INC a,x addr_aCx_16brni inc ax flagsetnz16bnel addr_aCx_16bw endloop SA1COpE8x8: ; INX i inc byte[SA1xx] mov al,[SA1xx] flagsetnz8b endloop SA1COpE8x16:; INX i inc word[SA1xx] mov ax,[SA1xx] flagsetnz16b endloop SA1COpC8x8: ; INY i inc byte[SA1xy] mov al,[SA1xy] flagsetnz8b endloop SA1COpC8x16:; INY i inc word[SA1xy] mov ax,[SA1xy] flagsetnz16b endloop SA1COpDC: ; JML (a) JMLMacro SA1COp4C: ; JMP a JMPMacro4C SA1COp6C: ; JMP (a) JMPMacro6C SA1COp7C: ; JMP(a,x) JMPMacro7C SA1COp5C: ; JMP al JMPMacro5C SA1COp22: ; JSL al JSLMacro SA1COp20: ; JSR a JSRMacro20 SA1COpFC: ; JSR(a,x) JSRMacroFC SA1COpA1m8: ; LDA(d,x) addr_BdCxB_8br LDAMacro8b SA1COpA1m16:; LDA(d,x) addr_BdCxB_16br LDAMacro16b SA1COpA3m8: ; LDA d,s addr_dCs_8br LDAMacro8b SA1COpA3m16:; LDA d,s addr_dCs_16br LDAMacro16b SA1COpA5m8: ; LDA d addr_d_8br LDAMacro8b SA1COpA5m16:; LDA d addr_d_16br LDAMacro16b SA1COpA7m8: ; LDA [d] addr_LdL_8br LDAMacro8b SA1COpA7m16:; LDA [d] addr_LdL_16br LDAMacro16b SA1COpA9m8: ; LDA # addr_I_8br LDAMacro8b SA1COpA9m16:; LDA # addr_I_16br LDAMacro16b SA1COpADm8: ; LDA a addr_a_8br LDAMacro8b SA1COpADm16:; LDA a addr_a_16br LDAMacro16b SA1COpAFm8: ; LDA al addr_al_8br LDAMacro8b SA1COpAFm16:; LDA al addr_al_16br LDAMacro16b SA1COpB1m8: ; LDA(d),y addr_BdBCy_8br LDAMacro8b SA1COpB1m16:; LDA(d),y addr_BdBCy_16br LDAMacro16b SA1COpB2m8: ; LDA (d) addr_BdB_8br LDAMacro8b SA1COpB2m16:; LDA (d) addr_BdB_16br LDAMacro16b SA1COpB3m8: ; LDA(d,s),y addr_BdCsBCy_8br LDAMacro8b SA1COpB3m16:; LDA(d,s),y addr_BdCsBCy_16br LDAMacro16b SA1COpB5m8: ; LDA d,x addr_dCx_8br LDAMacro8b SA1COpB5m16:; LDA d,x addr_dCx_16br LDAMacro16b SA1COpB7m8: ; LDA [d],y addr_LdLCy_8br LDAMacro8b SA1COpB7m16:; LDA [d],y addr_LdLCy_16br LDAMacro16b SA1COpB9m8: ; LDA a,y addr_aCy_8br LDAMacro8b SA1COpB9m16:; LDA a,y addr_aCy_16br LDAMacro16b SA1COpBDm8: ; LDA a,x addr_aCx_8br LDAMacro8b SA1COpBDm16:; LDA a,x addr_aCx_16br LDAMacro16b SA1COpBFm8: ; LDA al,x addr_alCx_8br LDAMacro8b SA1COpBFm16:; LDA al,x addr_alCx_16br LDAMacro16b SA1COpA2x8: ; LDX # addr_I_8br LDXMacro8b SA1COpA2x16:; LDX # addr_I_16br LDXMacro16b SA1COpA6x8: ; LDX d addr_d_8br LDXMacro8b SA1COpA6x16:; LDX d addr_d_16br LDXMacro16b SA1COpAEx8: ; LDX a addr_a_8br LDXMacro8b SA1COpAEx16:; LDX a addr_a_16br LDXMacro16b SA1COpB6x8: ; LDX d,y addr_dCy_8br LDXMacro8b SA1COpB6x16:; LDX d,y addr_dCy_16br LDXMacro16b SA1COpBEx8: ; LDX a,y addr_aCy_8br LDXMacro8b SA1COpBEx16:; LDX a,y addr_aCy_16br LDXMacro16b SA1COpA0x8: ; LDY # addr_I_8br LDYMacro8b SA1COpA0x16:; LDY # addr_I_16br LDYMacro16b SA1COpA4x8: ; LDY d addr_d_8br LDYMacro8b SA1COpA4x16:; LDY d addr_d_16br LDYMacro16b SA1COpACx8: ; LDY a addr_a_8br LDYMacro8b SA1COpACx16:; LDY a addr_a_16br LDYMacro16b SA1COpB4x8: ; LDY d,x addr_dCx_8br LDYMacro8b SA1COpB4x16:; LDY d,x addr_dCx_16br LDYMacro16b SA1COpBCx8: ; LDY a,x addr_aCx_8br LDYMacro8b SA1COpBCx16:; LDY a,x addr_aCx_16br LDYMacro16b SA1COp46m8: ; LSR d addr_d_8brni LSRMacro8b addr_d_8bw endloop SA1COp46m16:; LSR d addr_d_16brni LSRMacro16b addr_d_16bw endloop SA1COp4Am8: ; LSR A addr_A_8brni LSRMacro8b addr_A_8bw endloop SA1COp4Am16:; LSR A addr_A_16brni LSRMacro16b addr_A_16bw endloop SA1COp4Em8: ; LSR a addr_a_8brni LSRMacro8b addr_a_8bw endloop SA1COp4Em16:; LSR a addr_a_16brni LSRMacro16b addr_a_16bw endloop SA1COp56m8: ; LSR d,x addr_dCx_8brni LSRMacro8b addr_dCx_8bw endloop SA1COp56m16:; LSR d,x addr_dCx_16brni LSRMacro16b addr_dCx_16bw endloop SA1COp5Em8: ; LSRa,x addr_aCx_8brni LSRMacro8b addr_aCx_8bw endloop SA1COp5Em16:; LSRa,x addr_aCx_16brni LSRMacro16b addr_aCx_16bw endloop SA1COp54: ; MVN SA1xya MVNMacro SA1COp44: ; MVP SA1xya MVPMacro SA1COpEA: ; NOP i endloop SA1COp01m8: ; ORA(d,x) addr_BdCxB_8br ORAMacro8b SA1COp01m16:; ORA(d,x) addr_BdCxB_16br ORAMacro16b SA1COp03m8: ; ORA d,s addr_dCs_8br ORAMacro8b SA1COp03m16:; ORA d,s addr_dCs_16br ORAMacro16b SA1COp05m8: ; ORA d addr_d_8br ORAMacro8b SA1COp05m16:; ORA d addr_d_16br ORAMacro16b SA1COp07m8: ; ORA [d] addr_LdL_8br ORAMacro8b SA1COp07m16:; ORA [d] addr_LdL_16br ORAMacro16b SA1COp09m8: ; ORA # addr_I_8br ORAMacro8b SA1COp09m16:; ORA # addr_I_16br ORAMacro16b SA1COp0Dm8: ; ORA a addr_a_8br ORAMacro8b SA1COp0Dm16:; ORA a addr_a_16br ORAMacro16b SA1COp0Fm8: ; ORA al addr_al_8br ORAMacro8b SA1COp0Fm16:; ORA al addr_al_16br ORAMacro16b SA1COp11m8: ; ORA(d),y addr_BdBCy_8br ORAMacro8b SA1COp11m16:; ORA(d),y addr_BdBCy_16br ORAMacro16b SA1COp12m8: ; ORA(d) addr_BdB_8br ORAMacro8b SA1COp12m16:; ORA(d) addr_BdB_16br ORAMacro16b SA1COp13m8: ; ORA(d,s),y addr_BdCsBCy_8br ORAMacro8b SA1COp13m16:; ORA(d,s),y addr_BdCsBCy_16br ORAMacro16b SA1COp15m8: ; ORA d,x addr_dCx_8br ORAMacro8b SA1COp15m16:; ORA d,x addr_dCx_16br ORAMacro16b SA1COp17m8: ; ORA [d],y addr_LdLCy_8br ORAMacro8b SA1COp17m16:; ORA [d],y addr_LdLCy_16br ORAMacro16b SA1COp19m8: ; ORA a,y addr_aCy_8br ORAMacro8b SA1COp19m16:; ORA a,y addr_aCy_16br ORAMacro16b SA1COp1Dm8: ; ORA a,x addr_aCx_8br ORAMacro8b SA1COp1Dm16:; ORA a,x addr_aCx_16br ORAMacro16b SA1COp1Fm8: ; ORA al,x addr_alCx_8br ORAMacro8b SA1COp1Fm16:; ORA al,x addr_alCx_16br ORAMacro16b SA1COpF4: ; PEA s PEAMacro SA1COpD4: ; PEI s PEIMacro SA1COp62: ; PER s PERMacro SA1COp48m8: ; PHA s PUSHMacro8b [SA1xa] SA1COp48m16:; PHA s PUSHMacro16b [SA1xa], [SA1xa+1] SA1COp8B: ; PHB s PUSHMacro8b [SA1xdb] SA1COp0B: ; PHD s PUSHMacro16b [SA1xd], [SA1xd+1] SA1COp4B: ; PHK s PUSHMacro8b [SA1xpb] SA1COp08: ; PHP s PUSHMacro8bp SA1COpDAx8: ; PHX s PUSHMacro8b [SA1xx] SA1COpDAx16:; PHX s PUSHMacro16b [SA1xx], [SA1xx+1] SA1COp5Ax8: ; PHY s PUSHMacro8b [SA1xy] SA1COp5Ax16:; PHY s PUSHMacro16b [SA1xy], [SA1xy+1] SA1COp68m8: ; PLA s POPMacro8b [SA1xa] SA1COp68m16:; PLA s POPMacro16b [SA1xa], [SA1xa+1] SA1COpAB: ; PLB s POPMacro8b [SA1xdb] SA1COp2B: ; PLD s POPMacro16bd [SA1xd], [SA1xd+1] SA1COp28: ; PLP s POPMacroP SA1COpFAx8: ; PLX s POPMacro8b [SA1xx] SA1COpFAx16:; PLX s POPMacro16b [SA1xx], [SA1xx+1] SA1COp7Ax8: ; PLY s POPMacro8b [SA1xy] SA1COp7Ax16:; PLY s POPMacro16b [SA1xy], [SA1xy+1] SA1COpC2: ; REP # REPMacro SA1COp26m8: ; ROL d addr_d_8brni ROLMacro8b addr_d_8bw endloop SA1COp26m16:; ROL d addr_d_16brni ROLMacro16b addr_d_16bw endloop SA1COp2Am8: ; ROL A addr_A_8brni ROLMacro8b addr_A_8bw endloop SA1COp2Am16:; ROL A addr_A_16brni ROLMacro16b addr_A_16bw endloop SA1COp2Em8: ; ROL a addr_a_8brni ROLMacro8b addr_a_8bw endloop SA1COp2Em16:; ROL a addr_a_16brni ROLMacro16b addr_a_16bw endloop SA1COp36m8: ; ROL d,x addr_dCx_8brni ROLMacro8b addr_dCx_8bw endloop SA1COp36m16:; ROL d,x addr_dCx_16brni ROLMacro16b addr_dCx_16bw endloop SA1COp3Em8: ; ROL a,x addr_aCx_8brni ROLMacro8b addr_aCx_8bw endloop SA1COp3Em16:; ROL a,x addr_aCx_16brni ROLMacro16b addr_aCx_16bw endloop SA1COp66m8: ; ROR d addr_d_8brni RORMacro8b addr_d_8bw endloop SA1COp66m16:; ROR d addr_d_16brni RORMacro16b addr_d_16bw endloop SA1COp6Am8: ; ROR A addr_A_8brni RORMacro8b addr_A_8bw endloop SA1COp6Am16:; ROR A addr_A_16brni RORMacro16b addr_A_16bw endloop SA1COp6Em8: ; ROR a addr_a_8brni RORMacro8b addr_a_8bw endloop SA1COp6Em16:; ROR a addr_a_16brni RORMacro16b addr_a_16bw endloop SA1COp76m8: ; ROR d,x addr_dCx_8brni RORMacro8b addr_dCx_8bw endloop SA1COp76m16:; ROR d,x addr_dCx_16brni RORMacro16b addr_dCx_16bw endloop SA1COp7Em8: ; ROR a,x addr_aCx_8brni RORMacro8b addr_aCx_8bw endloop SA1COp7Em16:; ROR a,x addr_aCx_16brni RORMacro16b addr_aCx_16bw endloop SA1COp40: ; RTI s mov byte[intrset],2 RTIMacro SA1COp6B: ; RTL s RTLMacro SA1COp60: ; RTS s RTSMacro SA1COpE1m8nd: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bnd SA1COpE1m16nd: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bnd SA1COpE1m8d: ; SBC(d,x) addr_BdCxB_8br SBCMacro8bd SA1COpE1m16d: ; SBC(d,x) addr_BdCxB_16br SBCMacro16bd SA1COpE3m8nd: ; SBC d,s addr_dCs_8br SBCMacro8bnd SA1COpE3m16nd: ; SBC d,s addr_dCs_16br SBCMacro16bnd SA1COpE3m8d: ; SBC d,s addr_dCs_8br SBCMacro8bd SA1COpE3m16d: ; SBC d,s addr_dCs_16br SBCMacro16bd SA1COpE5m8nd: ; SBC d addr_d_8br SBCMacro8bnd SA1COpE5m16nd: ; SBC d addr_d_16br SBCMacro16bnd SA1COpE5m8d: ; SBC d addr_d_8br SBCMacro8bd SA1COpE5m16d: ; SBC d addr_d_16br SBCMacro16bd SA1COpE7m8nd: ; SBC [d] addr_LdL_8br SBCMacro8bnd SA1COpE7m16nd: ; SBC [d] addr_LdL_16br SBCMacro16bnd SA1COpE7m8d: ; SBC [d] addr_LdL_8br SBCMacro8bd SA1COpE7m16d: ; SBC [d] addr_LdL_16br SBCMacro16bd SA1COpE9m8nd: ; SBC # addr_I_8br SBCMacro8bnd SA1COpE9m16nd: ; SBC # addr_I_16br SBCMacro16bnd SA1COpE9m8d: ; SBC # addr_I_8br SBCMacro8bd SA1COpE9m16d: ; SBC # addr_I_16br SBCMacro16bd SA1COpEDm8nd: ; SBC a addr_a_8br SBCMacro8bnd SA1COpEDm16nd: ; SBC a addr_a_16br SBCMacro16bnd SA1COpEDm8d: ; SBC a addr_a_8br SBCMacro8bd SA1COpEDm16d: ; SBC a addr_a_16br SBCMacro16bd SA1COpEFm8nd: ; SBC al addr_al_8br SBCMacro8bnd SA1COpEFm16nd: ; SBC al addr_al_16br SBCMacro16bnd SA1COpEFm8d: ; SBC al addr_al_8br SBCMacro8bd SA1COpEFm16d: ; SBC al addr_al_16br SBCMacro16bd SA1COpF1m8nd: ; SBC(d),y addr_BdBCy_8br SBCMacro8bnd SA1COpF1m16nd: ; SBC(d),y addr_BdBCy_16br SBCMacro16bnd SA1COpF1m8d: ; SBC(d),y addr_BdBCy_8br SBCMacro8bd SA1COpF1m16d: ; SBC(d),y addr_BdBCy_16br SBCMacro16bd SA1COpF2m8nd: ; SBC (d) addr_BdB_8br SBCMacro8bnd SA1COpF2m16nd: ; SBC (d) addr_BdB_16br SBCMacro16bnd SA1COpF2m8d: ; SBC (d) addr_BdB_8br SBCMacro8bd SA1COpF2m16d: ; SBC (d) addr_BdB_16br SBCMacro16bd SA1COpF3m8nd: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bnd SA1COpF3m16nd: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bnd SA1COpF3m8d: ; SBC(d,s),y addr_BdCsBCy_8br SBCMacro8bd SA1COpF3m16d: ; SBC(d,s),y addr_BdCsBCy_16br SBCMacro16bd SA1COpF5m8nd: ; SBC d,x addr_dCx_8br SBCMacro8bnd SA1COpF5m16nd: ; SBC d,x addr_dCx_16br SBCMacro16bnd SA1COpF5m8d: ; SBC d,x addr_dCx_8br SBCMacro8bd SA1COpF5m16d: ; SBC d,x addr_dCx_16br SBCMacro16bd SA1COpF7m8nd: ; SBC [d],y addr_LdLCy_8br SBCMacro8bnd SA1COpF7m16nd: ; SBC [d],y addr_LdLCy_16br SBCMacro16bnd SA1COpF7m8d: ; SBC [d],y addr_LdLCy_8br SBCMacro8bd SA1COpF7m16d: ; SBC [d],y addr_LdLCy_16br SBCMacro16bd SA1COpF9m8nd: ; SBC a,y addr_aCy_8br SBCMacro8bnd SA1COpF9m16nd: ; SBC a,y addr_aCy_16br SBCMacro16bnd SA1COpF9m8d: ; SBC a,y addr_aCy_8br SBCMacro8bd SA1COpF9m16d: ; SBC a,y addr_aCy_16br SBCMacro16bd SA1COpFDm8nd: ; SBC a,x addr_aCx_8br SBCMacro8bnd SA1COpFDm16nd: ; SBC a,x addr_aCx_16br SBCMacro16bnd SA1COpFDm8d: ; SBC a,x addr_aCx_8br SBCMacro8bd SA1COpFDm16d: ; SBC a,x addr_aCx_16br SBCMacro16bd SA1COpFFm8nd: ; SBC al,x addr_alCx_8br SBCMacro8bnd SA1COpFFm16nd: ; SBC al,x addr_alCx_16br SBCMacro16bnd SA1COpFFm8d: ; SBC al,x addr_alCx_8br SBCMacro8bd SA1COpFFm16d: ; SBC al,x addr_alCx_16br SBCMacro16bd SA1COp38: ; SEC i mov dword[Sflagc],0FFh endloop SA1COpF8: ; SED i or dl,08h mov bl,dl mov edi,[SA1tablead+ebx*4] endloop SA1COp78: ; SEI i or dl,04h endloop SA1COpE2: ; SEP # SEPMacro SA1COp81m8: ; STA(d,x) STAMacro8b addr_BdCxB_8bw endloop SA1COp81m16:; STA(d,x) STAMacro16b addr_BdCxB_16bw endloop SA1COp83m8: ; STA d,s STAMacro8b addr_dCs_8bw endloop SA1COp83m16:; STA d,s STAMacro16b addr_dCs_16bw endloop SA1COp85m8: ; STA d STAMacro8b addr_d_8bw endloop SA1COp85m16:; STA d STAMacro16b addr_d_16bw endloop SA1COp87m8: ; STA [d] STAMacro8b addr_LdL_8bw endloop SA1COp87m16:; STA [d] STAMacro16b addr_LdL_16bw endloop SA1COp8Dm8: ; STA a STAMacro8b addr_a_8bw endloop SA1COp8Dm16:; STA a STAMacro16b addr_a_16bw endloop SA1COp8Fm8: ; STA al STAMacro8b addr_al_8bw endloop SA1COp8Fm16:; STA al STAMacro16b addr_al_16bw endloop SA1COp91m8: ; STA(d),y STAMacro8b addr_BdBCy_8bw endloop SA1COp91m16:; STA(d),y STAMacro16b addr_BdBCy_16bw endloop SA1COp92m8: ; STA (d) STAMacro8b addr_BdB_8bw endloop SA1COp92m16:; STA (d) STAMacro16b addr_BdB_16bw endloop SA1COp93m8: ; STA(d,s),y STAMacro8b addr_BdCsBCy_8bw endloop SA1COp93m16:; STA(d,s),y STAMacro16b addr_BdCsBCy_16bw endloop SA1COp95m8: ; STA d,x STAMacro8b addr_dCx_8bw endloop SA1COp95m16:; STA d,x STAMacro16b addr_dCx_16bw endloop SA1COp97m8: ; STA [d],y STAMacro8b addr_LdLCy_8bw endloop SA1COp97m16:; STA [d],y STAMacro16b addr_LdLCy_16bw endloop SA1COp99m8: ; STA a,y STAMacro8b addr_aCy_8bw endloop SA1COp99m16:; STA a,y STAMacro16b addr_aCy_16bw endloop SA1COp9Dm8: ; STA a,x STAMacro8b addr_aCx_8bw endloop SA1COp9Dm16:; STA a,x STAMacro16b addr_aCx_16bw endloop SA1COp9Fm8: ; STA al,x STAMacro8b addr_alCx_8bw endloop SA1COp9Fm16:; STA al,x STAMacro16b addr_alCx_16bw endloop SA1COp86x8: ; STX d STXMacro8b addr_d_8bw endloop SA1COp86x16:; STX d STXMacro16b addr_d_16bw endloop SA1COp8Ex8: ; STX a STXMacro8b addr_a_8bw endloop SA1COp8Ex16:; STX a STXMacro16b addr_a_16bw endloop SA1COp96x8: ; STX d,y STXMacro8b addr_dCy_8bw endloop SA1COp96x16:; STX d,y STXMacro16b addr_dCy_16bw endloop SA1COp84x8: ; STY d STYMacro8b addr_d_8bw endloop SA1COp84x16:; STY d STYMacro16b addr_d_16bw endloop SA1COp8Cx8: ; STY a STYMacro8b addr_a_8bw endloop SA1COp8Cx16:; STY a STYMacro16b addr_a_16bw endloop SA1COp94x8: ; STYd,x STYMacro8b addr_dCx_8bw endloop SA1COp94x16:; STYd,x STYMacro16b addr_dCx_16bw endloop SA1COpDB: ; STP i dec esi endloop SA1COp64m8: ; STZ d xor al,al addr_d_8bw endloop SA1COp64m16:; STZ d xor eax,eax addr_d_16bw endloop SA1COp74m8: ; STZ d,x xor al,al addr_dCx_8bw endloop SA1COp74m16:; STZ d,x xor eax,eax addr_dCx_16bw endloop SA1COp9Cm8: ; STZ a xor al,al addr_a_8bw endloop SA1COp9Cm16:; STZ a xor eax,eax addr_a_16bw endloop SA1COp9Em8: ; STZ a,x xor al,al addr_aCx_8bw endloop SA1COp9Em16:; STZ a,x xor eax,eax addr_aCx_16bw endloop SA1COp14m8: ; TRB d addr_d_8brni mov cl,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test cl,al jz .zero mov word[Sflagnz],1 not cl and al,cl addr_d_8bw endloop .zero mov word[Sflagnz],0 not cl and al,cl addr_d_8bw endloop SA1COp14m16:; TRB d addr_d_16brni mov cx,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test cx,ax jz .zero mov word[Sflagnz],1 not cx and ax,cx addr_d_16bw endloop .zero mov word[Sflagnz],0 not cx and ax,cx addr_d_16bw endloop SA1COp1Cm8: ; TRB a addr_a_8brni mov cl,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test cl,al jz .zero mov word[Sflagnz],1 not cl and al,cl addr_a_8bw endloop .zero mov word[Sflagnz],0 not cl and al,cl addr_a_8bw endloop SA1COp1Cm16:; TRB a addr_a_16brni mov cx,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test cx,ax jz .zero mov word[Sflagnz],1 not cx and ax,cx addr_a_16bw endloop .zero mov word[Sflagnz],0 not cx and ax,cx addr_a_16bw endloop SA1COp04m8: ; TSB d addr_d_8brni mov cl,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test al,cl jz .zero mov word[Sflagnz],1 or al,cl addr_d_8bw endloop .zero mov word[Sflagnz],0 or al,cl addr_d_8bw endloop SA1COp04m16:; TSB d addr_d_16brni mov cx,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test ax,cx jz .zero mov word[Sflagnz],1 or ax,cx addr_d_16bw endloop .zero mov word[Sflagnz],0 or ax,cx addr_d_16bw endloop SA1COp0Cm8: ; TSB a addr_a_8brni mov cl,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test al,cl jz .zero mov word[Sflagnz],1 or al,cl addr_a_8bw endloop .zero mov word[Sflagnz],0 or al,cl addr_a_8bw endloop SA1COp0Cm16:; TSB a addr_a_16brni mov cx,[SA1xa] test dword[Sflagnz],18000h jz .notflags or dword[Sflagnz],10000h .notflags test ax,cx jz .zero mov word[Sflagnz],1 or ax,cx addr_a_16bw endloop .zero mov word[Sflagnz],0 or ax,cx addr_a_16bw endloop SA1COpAAx8: ; TAX i mov al,[SA1xa] mov [SA1xx],al flagsetnz8b endloop SA1COpAAx16:; TAX i mov ax,[SA1xa] mov [SA1xx],ax flagsetnz16b endloop SA1COpA8x8: ; TAY i mov al,[SA1xa] mov [SA1xy],al flagsetnz8b endloop SA1COpA8x16:; TAY i mov ax,[SA1xa] mov [SA1xy],ax flagsetnz16b endloop SA1COp5B: ; TCD i mov ax,[SA1xa] mov [SA1xd],ax call SA1UpdateDPage flagsetnz16b endloop SA1COp1B: ; TCS i mov ax,[SA1xa] mov [SA1xs],ax endloop SA1COp7B: ; TDC i mov ax,[SA1xd] mov [SA1xa],ax flagsetnz16b endloop SA1COp3B: ; TSC i mov ax,[SA1xs] mov [SA1xa],ax flagsetnz16b endloop SA1COpBAx8: ; TSX i mov al,[SA1xs] mov [SA1xx],al flagsetnz8b endloop SA1COpBAx16:; TSX i mov ax,[SA1xs] mov [SA1xx],ax flagsetnz16b endloop SA1COp8Am8: ; TSA1xa i mov al,[SA1xx] mov [SA1xa],al flagsetnz8b endloop SA1COp8Am16:; TXA i mov ax,[SA1xx] mov [SA1xa],ax flagsetnz16b endloop SA1COp9A: ; TXS i mov ax,[SA1xx] mov [SA1xs],ax test byte[xe],1 jnz .emul endloop .emul mov byte[SA1xs+1],1 endloop SA1COp9Bx8: ; TSA1xy i mov al,[SA1xx] mov [SA1xy],al flagsetnz8b endloop SA1COp9Bx16:; TSA1xy i mov ax,[SA1xx] mov [SA1xy],ax flagsetnz16b endloop SA1COp98m8: ; TYA i mov al,[SA1xy] mov [SA1xa],al flagsetnz8b endloop SA1COp98m16:; TYA i mov ax,[SA1xy] mov [SA1xa],ax flagsetnz16b endloop SA1COpBBx8: ; TYX i mov al,[SA1xy] mov [SA1xx],al flagsetnz8b endloop SA1COpBBx16:; TYX i mov ax,[SA1xy] mov [SA1xx],ax flagsetnz16b endloop SA1COpCB: ; WAI i WAIMacro SA1COpEB: ; XBA i mov ah,[SA1xa] mov al,[SA1xa+1] mov [SA1xa],ax flagsetnz8b endloop SA1COpFB: ; XCE i XCEMacro SA1COp42: ; WDM inc esi endloop zsnes-1.36/src/cpu/spc700.asm0100644000175000017500000017122007267141100015261 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM DSPMem,spcWptr,debstop,disablespcclr,SPCSkipXtraROM,SPC700sh EXTSYM cycpbl,spcRptr EXTSYM spc700read EXTSYM dspWptr EXTSYM changeexecloop,curexecstate,SA1Enable,tableadb NEWSYM Spc700AsmStart %include "cpu/regsw.mac" %include "cpu/spcdef.inc" %include "cpu/spcaddr.inc" ; SPC 700 Emulation by _Demo_ ; Version 2.0 ; Little info on functions : ; Write byte : write al at [ebx] ; Read byte : read al from [ebx] ; update timer : update the timers, called every scanline ALIGN32 ;spcBuffer times 65536*4 db 0 ; The buffer of brr blocks... 4 bits -> 16 bits ;spcRamcmp times 65536 db 0 ; SPC Ram compare buffer ;spcPrevbf times 65536 db 0 ; SPC PrevX compare buffer NEWSYM spcRam, times 65472 db 0FFh ; Pointer to the SPC's RAM ; copy #1 ; THE SPC ROM :) db 0CDh,0EFh,0BDh,0E8h,000h,0C6h,01Dh,0D0h,0FCh,08Fh,0AAh,0F4h,08Fh,0BBh,0F5h,078h db 0CCh,0F4h,0D0h,0FBh,02Fh,019h,0EBh,0F4h,0D0h,0FCh,07Eh,0F4h,0D0h,00Bh,0E4h,0F5h db 0CBh,0F4h,0D7h,000h,0FCh,0D0h,0F3h,0ABh,001h,010h,0EFh,07Eh,0F4h,010h,0EBh,0BAh db 0F6h,0DAh,000h,0BAh,0F4h,0C4h,0F4h,0DDh,05Dh,0D0h,0DBh,01Fh,000h,000h,0C0h,0FFh db 0AAh,0BBh,0CCh,0DDh,0EEh,0FFh,000h,011h,022h,033h,044h,055h,066h,077h,088h,099h NEWSYM spcPCRam, dd 0 ; Program Counter (with spcRam added) NEWSYM spcA, db 0 ; The A register (general purpose) db 0 db 0 db 0 NEWSYM spcX, db 0 ; The X register (general purpose) db 0 db 0 db 0 NEWSYM spcY, db 0 ; The Y register (general purpose) db 0 db 0 db 0 NEWSYM spcP, db 0 ; The processor status byte (Removed for each flags) db 0 ; NZ are not always processed... db 0 db 0 NEWSYM spcNZ, db 0 ; The processor NZ flag (little speed up hack :) ) db 0 db 0 db 0 ;spcNF db 0 ; The Negative Flag 128 or 127 ;spcOF db 0 ; The Overflow Flag 64 or 191 ;spcDPF db 0 ; Direct Page Flag 32 or 223 ;spcUF db 0 ; The Unused Flag ? 16 or 239 ;spcHCF db 0 ; The Half Carry Flag 8 or 247 ;spcIF db 0 ; The interrupt flag 4 or 251 ;spcZF db 0 ; The Zero Flag 2 or 253 ;spcCF db 0 ; The Carry Flag 1 or 254 NEWSYM spcS, dd 1FFh ; The stack pointer (always from 100 to 1FF) (added Ram) NEWSYM spcRamDP, dd 0 ; The direct page pointer NEWSYM spcCycle, dd 0 ; The Cycle Counter NEWSYM reg1read, db 0 ; read from 65816 NEWSYM reg2read, db 0 ; read from 65816 NEWSYM reg3read, db 0 ; read from 65816 NEWSYM reg4read, db 0 ; read from 65816 NEWSYM timeron, db 0 ; timer0 on NEWSYM timincr0, db 0 ; # of ticks before incrementing NEWSYM timincr1, db 0 ; # of ticks before incrementing NEWSYM timincr2, db 0 ; # of ticks before incrementing NEWSYM timinl0, db 0 ; ticks left before incrementing NEWSYM timinl1, db 0 ; ticks left before incrementing NEWSYM timinl2, db 0 ; ticks left before incrementing NEWSYM timrcall, db 0 ; alternating bit 0 to correctly timer timer1 & 2 to 8000hz NEWSYM spcextraram, times 64 db 0 ; extra ram, used for tcall NEWSYM FutureExpandS, times 256-64 db 0 spcsave equ $-spcRam ; pharos equ hack *sigh* NEWSYM PHspcsave, dd spcsave ; copy #2 NEWSYM SPCROM db 0CDh,0EFh,0BDh,0E8h,000h,0C6h,01Dh,0D0h,0FCh,08Fh,0AAh,0F4h,08Fh,0BBh,0F5h,078h db 0CCh,0F4h,0D0h,0FBh,02Fh,019h,0EBh,0F4h,0D0h,0FCh,07Eh,0F4h,0D0h,00Bh,0E4h,0F5h db 0CBh,0F4h,0D7h,000h,0FCh,0D0h,0F3h,0ABh,001h,010h,0EFh,07Eh,0F4h,010h,0EBh,0BAh db 0F6h,0DAh,000h,0BAh,0F4h,0C4h,0F4h,0DDh,05Dh,0D0h,0DBh,01Fh,000h,000h,0C0h,0FFh %macro WriteByte 0 cmp ebx,0ffh+spcRam ja .extramem cmp ebx,0f0h+spcRam jb .normalmem sub ebx,spcRam call dword near [spcWptr+ebx*4-0f0h*4] jmp .finished .extramem cmp ebx,0ffc0h+spcRam jb .normalmem mov [spcextraram+ebx-0FFC0h-spcRam],al test byte[spcRam+0F1h],80h jnz .finished ; push ecx ; mov cl,[DSPMem+06Ch] ; test cl,20h ; pop ecx ; jz .finished .normalmem mov [ebx],al .finished %endmacro %macro ReadByte 0 cmp ebx,0f0h+spcRam jb .rnormalmem2 cmp ebx,0ffh+spcRam ja .rnormalmem sub ebx,spcRam call dword near [spcRptr+ebx*4-0f0h*4] jmp .rfinished .rnormalmem ; cmp ebx,0ffc0h+spcRam ; jb .rnormalmem2 ; test byte [DSPMem+6Ch],10h ; jz .rnormalmem2 ; mov al,[spcextraram+ebx-0FFC0h-spcRam] ; jmp .rfinished .rnormalmem2 mov al,[ebx] .rfinished %endmacro %macro ReadByte2 0 cmp ebx,0f0h+spcRam jb .rnormalmem2 cmp ebx,0ffh+spcRam ja .rnormalmem sub ebx,spcRam call dword near [spcRptr+ebx*4-0f0h*4] add ebx,spcRam jmp .rfinished .rnormalmem ; cmp ebx,0ffc0h+spcRam ; jb .rnormalmem2 ; test byte [DSPMem+6Ch],10h ; jz .rnormalmem2 ; mov al,[spcextraram+ebx-0FFC0h-spcRam] ; jmp .rfinished .rnormalmem2 mov al,[ebx] .rfinished %endmacro NEWSYM timer2upd, dd 0 ; This function is called every scanline (262*60 times/sec) ; Make it call 0.9825 times (393/400) (skip when divisible by 64) ; 2 8khz, 1 64khz NEWSYM updatetimer ; inc dword[timer2upd] ; cmp dword[timer2upd],400 ; jne .nowrap ; mov dword[timer2upd],0 ;.nowrap ;.again ; mov eax,dword[timer2upd] ; shr eax,6 ; shl eax,6 ; cmp eax,dword[timer2upd] ; je near .noin2d .another xor byte[timrcall],01h test byte[timrcall],01h jz near .notimer test byte[timeron],1 jz .noin0 dec byte[timinl0] jnz .noin0 inc byte[spcRam+0FDh] mov al,[timincr0] mov [timinl0],al cmp byte[spcRam+0FDh],1 jne .noin0 reenablespc mov dword[cycpbl],0 .noin0 test byte[timeron],2 jz .noin1 dec byte[timinl1] jnz .noin1 inc byte[spcRam+0FEh] mov al,[timincr1] mov [timinl1],al cmp byte[spcRam+0FEh],1 jne .noin1 reenablespc mov dword[cycpbl],0 .noin1 .notimer test byte[timeron],4 jz near .noin2d2 dec byte[timinl2] jnz .noin2 inc byte[spcRam+0FFh] mov al,[timincr2] mov [timinl2],al cmp byte[spcRam+0FFh],1 jne .noin2 reenablespc mov dword[cycpbl],0 .noin2 dec byte[timinl2] jnz .noin2b inc byte[spcRam+0FFh] mov al,[timincr2] mov [timinl2],al cmp byte[spcRam+0FFh],1 jne .noin2b reenablespc mov dword[cycpbl],0 .noin2b dec byte[timinl2] jnz .noin2c inc byte[spcRam+0FFh] mov al,[timincr2] mov [timinl2],al cmp byte[spcRam+0FFh],1 jne .noin2c reenablespc mov dword[cycpbl],0 .noin2c dec byte[timinl2] jnz .noin2d inc byte[spcRam+0FFh] mov al,[timincr2] mov [timinl2],al cmp byte[spcRam+0FFh],1 jne .noin2d reenablespc mov dword[cycpbl],0 .noin2d .noin2d2 ; inc dword[timer2upd] ; cmp dword[timer2upd],31 ; jne .nowrap ; mov dword[timer2upd],0 ; jmp .again ;.nowrap inc dword[timer2upd] cmp dword[timer2upd],60 jne .noanother mov dword[timer2upd],0 jmp .another .noanother ret ; SPC Write Registers ; DO NOT MODIFY DX OR ECX! NEWSYM SPCRegF0 mov [spcRam+0F0h],al ret NEWSYM SPCRegF1 cmp byte[disablespcclr],1 je .No23Clear test al,10h jz .No01Clear mov byte [spcRam+0F4h],0 mov byte [spcRam+0F5h],0 .No01Clear test al,20h jz .No23Clear mov byte [spcRam+0F6h],0 mov byte [spcRam+0F7h],0 .No23Clear cmp byte[SPCSkipXtraROM],1 je near .AfterNoROM test al,80h jz .NoROM push eax push ebx xor eax,eax .loopa mov bl,[SPCROM+eax] mov [spcRam+0FFC0h+eax],bl inc eax cmp eax,040h jne .loopa pop ebx pop eax jmp .AfterNoROM .NoROM push eax push ebx xor eax,eax .loopb mov bl,[spcextraram+eax] mov [spcRam+0FFC0h+eax],bl inc eax cmp eax,040h jne .loopb pop ebx pop eax .AfterNoROM mov [spcRam+0F1h],al and al,0Fh mov [timeron],al ret NEWSYM SPCRegF2 mov [spcRam+0F2h],al push eax push ebx xor eax,eax mov al,[spcRam+0F2h] mov bl,[DSPMem+eax] mov [spcRam+0F3h],bl pop ebx pop eax ret NEWSYM SPCRegF3 push ebx xor ebx,ebx mov bl,[spcRam+0F2h] and bl,07fh call dword near [dspWptr+ebx*4] pop ebx mov [spcRam+ebx],al ret NEWSYM SPCRegF4 mov [reg1read],al inc dword[spc700read] ret NEWSYM SPCRegF5 mov [reg2read],al inc dword[spc700read] ret NEWSYM SPCRegF6 mov [reg3read],al inc dword[spc700read] ret NEWSYM SPCRegF7 mov [reg4read],al inc dword[spc700read] ret NEWSYM SPCRegF8 mov [spcRam+ebx],al ret NEWSYM SPCRegF9 mov [spcRam+ebx],al ret NEWSYM SPCRegFA mov [timincr0],al test byte[timinl0],0FFh jne .nowrite mov [timinl0],al .nowrite mov [spcRam+ebx],al ret NEWSYM SPCRegFB mov [timincr1],al test byte[timinl1],0FFh jne .nowrite mov [timinl1],al .nowrite mov [spcRam+ebx],al ret NEWSYM SPCRegFC mov [timincr2],al test byte[timinl2],0FFh jne .nowrite mov [timinl2],al .nowrite mov [spcRam+ebx],al ret NEWSYM SPCRegFD ret NEWSYM SPCRegFE ret NEWSYM SPCRegFF ret ; SPC Read Registers ; DO NOT MODIFY ANY REG! ; return data true al NEWSYM RSPCRegF0 mov al,[spcRam+0f0h] ret NEWSYM RSPCRegF1 mov al,[spcRam+0f1h] ret NEWSYM RSPCRegF2 mov al,[spcRam+0f2h] ret NEWSYM RSPCRegF3 mov al,[spcRam+0f3h] ret NEWSYM RSPCRegF4 mov al,[spcRam+0f4h] ret NEWSYM RSPCRegF5 mov al,[spcRam+0f5h] ret NEWSYM RSPCRegF6 mov al,[spcRam+0f6h] ret NEWSYM RSPCRegF7 mov al,[spcRam+0f7h] ret NEWSYM RSPCRegF8 mov al,0 ;[spcRam+0f8h] ret NEWSYM RSPCRegF9 mov al,0 ;[spcRam+0f9h] ret NEWSYM RSPCRegFA mov al,[spcRam+0fah] ret NEWSYM RSPCRegFB mov al,[spcRam+0fbh] ret NEWSYM RSPCRegFC mov al,[spcRam+0fch] ret NEWSYM RSPCRegFD mov al,[spcRam+0fdh] and al,0Fh cmp byte[spcRam+0fdh],0 je spcnextskip mov byte [spcRam+0fdh],0 mov byte [spcnumread],0 ret NEWSYM RSPCRegFE mov al,[spcRam+0feh] and al,0Fh cmp byte[spcRam+0feh],0 je spcnextskip mov byte [spcRam+0feh],0 mov byte [spcnumread],0 ret NEWSYM RSPCRegFF mov al,[spcRam+0ffh] and al,0Fh cmp byte[spcRam+0ffh],0 je spcnextskip mov byte [spcRam+0ffh],0 mov byte [spcnumread],0 ret NEWSYM spcnextskip inc byte[spcnumread] cmp byte[spcnumread],5 je near haltspc ret NEWSYM haltspc cmp byte[SPC700sh],1 je .nochangestate mov dword[cycpbl],0FFFFFFFFh test byte[curexecstate],02h jz .nochangestate and byte[curexecstate],0FDh push ebx xor ebx,ebx mov bl,dl mov edi,[tableadb+ebx*4] pop ebx .nochangestate mov byte[spcnumread],0 ret NEWSYM spcnumread, db 0 %macro SPCSetFlagnzc 0 js .setsignflag jz .setzeroflag mov byte [spcNZ],1 jc .setcarryflag and byte [spcP],0FEh ret .setsignflag mov byte [spcNZ],80h jc .setcarryflag and byte [spcP],0FEh ret .setzeroflag mov byte [spcNZ],0 jc .setcarryflag and byte [spcP],0FEh ret .setcarryflag or byte [spcP],1 ret %endmacro %macro SPCSetFlagnzcnoret 0 js .setsignflag jz .setzeroflag mov byte [spcNZ],1 jc .setcarryflag and byte [spcP],0FEh jmp .skipflags .setsignflag mov byte [spcNZ],80h jc .setcarryflag and byte [spcP],0FEh jmp .skipflags .setzeroflag mov byte [spcNZ],0 jc .setcarryflag and byte [spcP],0FEh jmp .skipflags .setcarryflag or byte [spcP],1 .skipflags %endmacro ;spcNF db 0 ; The Negative Flag 128 or 127 80h ;spcOF db 0 ; The Overflow Flag 64 or 191 40h ;spcDPF db 0 ; Direct Page Flag 32 or 223 20h ;spcUF db 0 ; The Unused Flag ? 16 or 239 10h ;spcHCF db 0 ; The Half Carry Flag 8 or 247 08h ;spcIF db 0 ; The interrupt flag 4 or 251 04h ;spcZF db 0 ; The Zero Flag 2 or 253 02h ;spcCF db 0 ; The Carry Flag 1 or 254 01h ; test byte[spcP],08h ; jz .nohcarry ; or ah,00010000b ;.nohcarry %macro SPCSetFlagnvhzc 0 lahf js .setsignflag jz .setzeroflag mov byte [spcNZ],1 jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setsignflag mov byte [spcNZ],80h jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setzeroflag mov byte [spcNZ],0 jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setoverflowflag or byte [spcP],40h .skipflags and byte [spcP],0F6h test ah,01h jz .noCarry or byte [spcP],1 .noCarry test ah,10h jz .nohf or byte [spcP],8 .nohf ret %endmacro %macro SPCSetFlagnvhzcnoret 0 lahf js .setsignflag jz .setzeroflag mov byte [spcNZ],1 jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setsignflag mov byte [spcNZ],80h jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setzeroflag mov byte [spcNZ],0 jo .setoverflowflag and byte [spcP],0BFh jmp .skipflags .setoverflowflag or byte [spcP],40h .skipflags and byte [spcP],0F6h test ah,01h jz .noCarry or byte [spcP],1 .noCarry test ah,10h jz .nohf or byte [spcP],8 .nohf %endmacro ;************************************************ ; Misc Opcodes ;************************************************ NEWSYM Op00 ; NOP ret NEWSYM OpEF ; SLEEP standby SLEEP mode ......... dec ebp ret NEWSYM OpFF ; STOP standby STOP mode ......... inc dword[spc700read] dec ebp ret NEWSYM Op9F ; XCN A A(7-4) <-> A(3-0) N......Z. ror byte [spcA],4 mov al,byte[spcA] mov [spcNZ],al ret ;************************************************ ; Branch Stuff ;************************************************ NEWSYM Op10 ; BPL Branch on N=0 test byte [spcNZ],128 jz .branch spcbrancher NEWSYM Op30 ; BMI Branch on N=1 test byte [spcNZ],128 jnz .branch spcbrancher NEWSYM Op50 ; BVC Branch on V=0 test byte [spcP],64 jz .branch spcbrancher NEWSYM Op70 ; BVS Branch on V=1 test byte [spcP],64 jnz .branch spcbrancher NEWSYM Op90 ; BCC Branc on c=0 test byte [spcP],1 jz .branch spcbrancher NEWSYM OpB0 ; BCS Branch on C=1 test byte [spcP],1 jnz .branch spcbrancher NEWSYM OpD0 ; BNE branch on Z=0 test byte [spcNZ],255 jnz .branch spcbrancher NEWSYM OpF0 ; BEQ Branch on Z=1 test byte [spcNZ],0FFh jz .branch spcbrancher NEWSYM Op2F ; BRA rel branch always ... movsx ebx,byte [ebp] inc ebp add ebp,ebx ret ;************************************************ ; Clear/Set Flag bits ;************************************************ ; CLRP 20 1 2 clear direct page flag ..0..... NEWSYM Op20 ; CLRP Clear direct page flag and byte [spcP],11011111b mov dword [spcRamDP],spcRam ret ; SETP 40 1 2 set dorect page flag ..1..0.. NEWSYM Op40 ; SETP Set Direct Page Flag (Also clear interupt flag?) or byte [spcP],00100000b and byte [spcP],11111011b mov dword [spcRamDP],spcRam add dword [spcRamDP],100h ret ; CLRC 60 1 2 clear carry flag .......0 NEWSYM Op60 ; CLRC Clear carry flag and byte [spcP],11111110b ret ; SETC 80 1 2 set carry flag .......1 NEWSYM Op80 ; SETC Set carry flag or byte [spcP],00000001b ret ; EI A0 1 3 set interrup enable flag .....1.. NEWSYM OpA0 ; EI set interrupt flag or byte [spcP],00000100b ret ; DI C0 1 3 clear interrup enable flag .....0.. NEWSYM OpC0 ; DI clear interrupt flag and byte [spcP],11111011b ret ; CLRV E0 1 2 clear V and H .0..0... NEWSYM OpE0 ; CLRV clear V and H and byte [spcP],10110111b ret ; NOTC ED 1 3 complement carry flag .......C NEWSYM OpED ; NOTC complement carry flag .......C xor byte [spcP],00000001b ret ;************************************************ ; TCALL instructions (Verified) ;************************************************ NEWSYM Op01 ; TCALL 0 spctcall 30 NEWSYM Op11 ; TCALL 1 spctcall 28 NEWSYM Op21 ; TCALL 2 spctcall 26 NEWSYM Op31 ; TCALL 3 spctcall 24 NEWSYM Op41 ; TCALL 4 spctcall 22 NEWSYM Op51 ; TCALL 5 spctcall 20 NEWSYM Op61 ; TCALL 6 spctcall 18 NEWSYM Op71 ; TCALL 7 spctcall 16 NEWSYM Op81 ; TCALL 8 spctcall 14 NEWSYM Op91 ; TCALL 9 spctcall 12 NEWSYM OpA1 ; TCALL A spctcall 10 NEWSYM OpB1 ; TCALL B spctcall 08 NEWSYM OpC1 ; TCALL C spctcall 06 NEWSYM OpD1 ; TCALL D spctcall 04 NEWSYM OpE1 ; TCALL E spctcall 02 NEWSYM OpF1 ; TCALL F spctcall 00 ;************************************************ ; SET1 instructions (Verified) ;************************************************ NEWSYM Op02 ; SET1 direct page bit 0 set1 1 NEWSYM Op22 ; SET1 direct page bit 1 set1 2 NEWSYM Op42 ; SET1 direct page bit 2 set1 4 NEWSYM Op62 ; SET1 direct page bit 3 set1 8 NEWSYM Op82 ; SET1 direct page bit 4 set1 16 NEWSYM OpA2 ; SET1 direct page bit 5 set1 32 NEWSYM OpC2 ; SET1 direct page bit 6 set1 64 NEWSYM OpE2 ; SET1 direct page bit 7 set1 128 ;************************************************ ; CLR1 instructions (Verified) ;************************************************ NEWSYM Op12 ; CLR1 direct page bit 0 clr1 255-1 NEWSYM Op32 ; CLR1 direct page bit 1 clr1 255-2 NEWSYM Op52 ; CLR1 direct page bit 2 clr1 255-4 NEWSYM Op72 ; CLR1 direct page bit 3 clr1 255-8 NEWSYM Op92 ; CLR1 direct page bit 4 clr1 255-16 NEWSYM OpB2 ; CLR1 direct page bit 5 clr1 255-32 NEWSYM OpD2 ; CLR1 direct page bit 6 clr1 255-64 NEWSYM OpF2 ; CLR1 direct page bit 7 clr1 255-128 ;************************************************ ; BBS instructions (Verified) ;************************************************ NEWSYM Op03 ; BBS direct page bit 0 bbs 1 NEWSYM Op23 ; BBS direct page bit 1 bbs 2 NEWSYM Op43 ; BBS direct page bit 2 bbs 4 NEWSYM Op63 ; BBS direct page bit 3 bbs 8 NEWSYM Op83 ; BBS direct page bit 4 bbs 16 NEWSYM OpA3 ; BBS direct page bit 5 bbs 32 NEWSYM OpC3 ; BBS direct page bit 6 bbs 64 NEWSYM OpE3 ; BBS direct page bit 7 bbs 128 ;************************************************ ; BBC instructions (Verified) ;************************************************ NEWSYM Op13 ; BBC direct page bit 0 bbc 1 NEWSYM Op33 ; BBC direct page bit 1 bbc 2 NEWSYM Op53 ; BBC direct page bit 2 bbc 4 NEWSYM Op73 ; BBC direct page bit 3 bbc 8 NEWSYM Op93 ; BBC direct page bit 4 bbc 16 NEWSYM OpB3 ; BBC direct page bit 5 bbc 32 NEWSYM OpD3 ; BBC direct page bit 6 bbc 64 NEWSYM OpF3 ; BBC direct page bit 7 bbc 128 ;************************************************ ; OR A,instructions ;************************************************ NEWSYM Op04 ; OR A,dp A <- A OR (dp) N.....Z. SPCaddr_DP SPC_OR_A NEWSYM Op14 ; OR A,dp+X A <- A OR (dp+X) N.....Z. SPCaddr_DP_X SPC_OR_A NEWSYM Op05 ; OR A,labs A <- A OR (abs) N.....Z. SPCaddr_LABS SPC_OR_A NEWSYM Op15 ; OR A,labs+x A <- A OR (abs+X) N.....Z. SPCaddr_LABS_X SPC_OR_A NEWSYM Op06 ; OR A,(X) A <- A OR (X) N.....Z. SPCaddr__X_ SPC_OR_A NEWSYM Op16 ; OR A,labs+Y A <- A OR (abs+Y) N......Z. SPCaddr_LABS_Y SPC_OR_A NEWSYM Op07 ; OR A,(dp+X) A <- A OR ((dp+X+1)(dp+X)) N......Z. SPCaddr_bDP_Xb SPC_OR_A NEWSYM Op17 ; OR A,(dp)+Y A <- A OR ((dp+1)(dp)+Y) N......Z. SPCaddr_bDPb_Y SPC_OR_A NEWSYM Op08 ; OR A,#inm A <- A OR inm N......Z. mov al,[ebp] inc ebp SPC_OR_A ;************************************************ ; AND A, instructions ;************************************************ NEWSYM Op24 ; AND A,dp A <- A AND (dp) N.....Z. SPCaddr_DP SPC_AND_A NEWSYM Op34 ; AND A,dp+x A <- A AND (dp+X) N.....Z. SPCaddr_DP_X SPC_AND_A NEWSYM Op25 ; AND A,labs A <- A AND (abs) N.....Z. SPCaddr_LABS SPC_AND_A NEWSYM Op35 ; AND A,labs+X A <- A AND (abs+X) N.....Z. SPCaddr_LABS_X SPC_AND_A NEWSYM Op26 ; AND A,(X) A <- A AND (X) N......Z. SPCaddr__X_ SPC_AND_A NEWSYM Op36 ; AND A,labs+Y A <- A AND (abs+Y) N......Z. SPCaddr_LABS_Y SPC_AND_A NEWSYM Op27 ; AND A,(dp+X) A <- A AND ((dp+X+1)(dp+X)) N......Z. SPCaddr_bDP_Xb SPC_AND_A NEWSYM Op37 ; AND A,(dp)+Y A <- A AND ((dp+1)(dp)+Y) N......Z. SPCaddr_bDPb_Y SPC_AND_A NEWSYM Op28 ; AND A,#inm A <- A AND inm N......Z. mov al,[ebp] inc ebp SPC_AND_A ;************************************************ ; EOR A, instructions ;************************************************ NEWSYM Op44 ; EOR A,dp A <- A EOR (dp) N.....Z. SPCaddr_DP SPC_EOR_A NEWSYM Op54 ; EOR A,dp+x A <- A EOR (dp+X) N.....Z. SPCaddr_DP_X SPC_EOR_A NEWSYM Op45 ; EOR A,labs A <- A EOR (abs) N.....Z. SPCaddr_LABS SPC_EOR_A NEWSYM Op55 ; EOR A,labs+X A <- A EOR (abs+X) N.....Z. SPCaddr_LABS_X SPC_EOR_A NEWSYM Op46 ; EOR A,(X) A <- A EOR (X) N......Z. SPCaddr__X_ SPC_EOR_A NEWSYM Op56 ; EOR A,labs+Y A <- A EOR (abs+Y) N......Z. SPCaddr_LABS_Y SPC_EOR_A NEWSYM Op47 ; EOR A,(dp+X) A <- A EOR ((dp+X+1)(dp+X)) N......Z. SPCaddr_bDP_Xb SPC_EOR_A NEWSYM Op57 ; EOR A,(dp)+Y A <- A EOR ((dp+1)(dp)+Y) N......Z. SPCaddr_bDPb_Y SPC_EOR_A NEWSYM Op48 ; EOR A,#inm A <- A EOR inm N......Z. mov al,[ebp] inc ebp SPC_EOR_A ;************************************************ ; CMP A, instructions ;************************************************ NEWSYM Op64 ; CMP A,dp A-(dp) N.....ZC SPCaddr_DP SPC_CMP_A NEWSYM Op74 ; CMP A,dp+x A-(dp+X) N.....ZC SPCaddr_DP_X SPC_CMP_A NEWSYM Op65 ; CMP A,labs A-(abs) N.....ZC SPCaddr_LABS SPC_CMP_A NEWSYM Op75 ; CMP A,labs+X A-(abs+X) N.....ZC SPCaddr_LABS_X SPC_CMP_A NEWSYM Op66 ; CMP A,(X) A-(X) N......ZC SPCaddr__X_ SPC_CMP_A NEWSYM Op76 ; CMP A,labs+Y A-(abs+Y) N......ZC SPCaddr_LABS_Y SPC_CMP_A NEWSYM Op67 ; CMP A,(dp+X) A-((dp+X+1)(dp+X)) N......ZC SPCaddr_bDP_Xb SPC_CMP_A NEWSYM Op77 ; CMP A,(dp)+Y A-((dp+1)(dp)+Y) N......ZC SPCaddr_bDPb_Y SPC_CMP_A NEWSYM Op68 ; CMP A,#inm A-inm N......ZC mov al,[ebp] inc ebp SPC_CMP_A ;************************************************ ; ADC A, instructions ;************************************************ NEWSYM Op84 ; ADC A,dp A <- A+(dp)+C NV..H.ZC SPCaddr_DP SPC_ADC_A NEWSYM Op94 ; ADC A,dp+x A <- A+(dp+X)+C NV..H.ZC SPCaddr_DP_X SPC_ADC_A NEWSYM Op85 ; ADC A,labs A <- A+(abs)+C NV..H.ZC SPCaddr_LABS SPC_ADC_A NEWSYM Op95 ; ADC A,labs+X A <- A+(abs+X)+C NV..H.ZC SPCaddr_LABS_X SPC_ADC_A NEWSYM Op86 ; ADC A,(X) A <- A+(X)+C NV..H..ZC SPCaddr__X_ SPC_ADC_A NEWSYM Op96 ; ADC A,labs+Y A <- A+(abs+Y)+C NV..H..ZC SPCaddr_LABS_Y SPC_ADC_A NEWSYM Op87 ; ADC A,(dp+X) A <- A+((dp+X+1)(dp+X)) NV..H..ZC SPCaddr_bDP_Xb SPC_ADC_A NEWSYM Op97 ; ADC A,(dp)+Y A <- A+((dp+1)(dp)+Y) NV..H..ZC SPCaddr_bDPb_Y SPC_ADC_A NEWSYM Op88 ; ADC A,#inm A <- A+inm+C NV..H..ZC mov al,[ebp] inc ebp SPC_ADC_A ;************************************************ ; SBC A, instructions ;************************************************ NEWSYM OpA4 ; SBC A,dp A <- A-(dp)-!C NV..H.ZC SPCaddr_DP SPC_SBC_A NEWSYM OpB4 ; SBC A,dp+x A <- A-(dp+X)-!C NV..H.ZC SPCaddr_DP_X SPC_SBC_A NEWSYM OpA5 ; SBC A,labs A <- A-(abs)-!C NV..H.ZC SPCaddr_LABS SPC_SBC_A NEWSYM OpB5 ; SBC A,labs+x A <- A-(abs+X)-!C NV..H.ZC SPCaddr_LABS_X SPC_SBC_A NEWSYM OpA6 ; SBC A,(X) A <- A-(X)-!C NV..H..ZC SPCaddr__X_ SPC_SBC_A NEWSYM OpB6 ; SBC A,labs+Y A <- A-(abs+Y)-!C NV..H..ZC SPCaddr_LABS_Y SPC_SBC_A NEWSYM OpA7 ; SBC A,(dp+X) A <- A-((dp+X+1)(dp+X))-!C NV..H..ZC SPCaddr_bDP_Xb SPC_SBC_A NEWSYM OpB7 ; SBC A,(dp)+Y A <- A-((dp+1)(dp)+Y)-!C NV..H..ZC SPCaddr_bDPb_Y SPC_SBC_A NEWSYM OpA8 ; SBC A,#inm A <- A-inm-!C NV..H..ZC mov al,[ebp] inc ebp SPC_SBC_A ;************************************************ ; MOV A, instructions ;************************************************ NEWSYM OpE4 ; MOV A,dp A <- (dp) N......Z SPCaddr_DP SPC_MOV_A NEWSYM OpF4 ; MOV A,dp+x A <- (dp+X) N......Z SPCaddr_DP_X SPC_MOV_A NEWSYM OpE5 ; MOV A,labs A <- (abs) N......Z SPCaddr_LABS SPC_MOV_A NEWSYM OpF5 ; MOV A,labs+X A <- (abs+X) N......Z SPCaddr_LABS_X SPC_MOV_A NEWSYM OpE6 ; MOV A,(X) A <- (X) N......Z SPCaddr__X_ SPC_MOV_A NEWSYM OpF6 ; MOV A,labs+Y A <- (abs+Y) N......Z SPCaddr_LABS_Y SPC_MOV_A NEWSYM OpE7 ; MOV A,(dp+X) A <- ((dp+X+1)(dp+X)) N......Z SPCaddr_bDP_Xb SPC_MOV_A NEWSYM OpF7 ; MOV A,(dp)+Y A <- ((dp+1)(dp)+Y) N......Z SPCaddr_bDPb_Y SPC_MOV_A NEWSYM OpE8 ; MOV A,#inm A <- inm N......Z mov al,[ebp] inc ebp SPC_MOV_A ;************************************************ ; DP,#imm instructions ;************************************************ %macro spcgetdp_imm 0 mov bl,[ebp+1] mov ah,[ebp] add ebx,[spcRamDP] ReadByte2 add ebp,2 %endmacro NEWSYM OpB8 ; SBC dp,#inm (dp) <- (dp)-inm-!C NV..H..ZC spcgetdp_imm ; bl<-[ebp+1], ah<-[ebp], ebx+[spcRamDP],Readbyte,ebp+2 mov cl,[spcP] xor cl,1 shr cl,1 sbb al,ah cmc SPCSetFlagnvhzcnoret WriteByte ret NEWSYM Op98 ; ADC dp,#inm (dp) <- (dp)+inm+C NV..H..ZC spcgetdp_imm ; bl<-[ebp+1], ah<-[ebp], ebx+[spcRamDP],Readbyte,ebp+2 mov cl,[spcP] shr cl,1 adc al,ah SPCSetFlagnvhzcnoret WriteByte ret NEWSYM Op78 ; CMP dp,#inm (dp)-inm N......ZC mov bl,[ebp+1] mov ah,[ebp] add ebx,[spcRamDP] ReadByte add ebp,2 cmp al,ah cmc SPCSetFlagnzcnoret ret NEWSYM Op58 ; EOR dp,#inm (dp) <- (dp) EOR inm N......Z. spcgetdp_imm ; bl<-[ebp+1], ah<-[ebp], ebx+[spcRamDP],Readbyte,ebp+2 xor al,ah mov [spcNZ], al WriteByte ret NEWSYM Op38 ; AND dp,#inm (dp) <- (dp) AND inm N......Z. spcgetdp_imm ; bl<-[ebp+1], ah<-[ebp], ebx+[spcRamDP],Readbyte,ebp+2 and al,ah mov [spcNZ], al WriteByte ret NEWSYM Op18 ; OR dp,#inm (dp) <- (dp) OR inm N......Z. spcgetdp_imm ; bl<-[ebp+1], ah<-[ebp], ebx+[spcRamDP],Readbyte,ebp+2 or al,ah mov [spcNZ],al WriteByte ret ;************************************************ ; DP(D),DP(S) instructions ;************************************************ %macro spcaddrDPbDb_DPbSb 1 xor ecx,ecx mov bl,[ebp+1] mov cl,[ebp] add ebx,[spcRamDP] add ebp,2 add ecx,[spcRamDP] push ebx ReadByte mov ebx,ecx mov cl,al %1 ReadByte mov ah,al mov al,cl pop ebx %endmacro NEWSYM Op09 ; OR dp(d),dp(s) (dp(d))<-(dp(d)) OR (dp(s)) N......Z. spcaddrDPbDb_DPbSb Op09b: or al,ah mov [spcNZ], al WriteByte xor ecx,ecx ret NEWSYM Op29 ; AND dp(d),dp(s) (dp(d))<-(dp(d)) AND (dp(s)) N......Z. spcaddrDPbDb_DPbSb Op29b: and al,ah mov [spcNZ], al WriteByte xor ecx,ecx ret NEWSYM Op49 ; EOR dp(d),dp(s) (dp(d))<-(dp(d)) EOR (dp(s)) N......Z. spcaddrDPbDb_DPbSb Op49b: xor al,ah mov [spcNZ], al WriteByte xor ecx,ecx ret NEWSYM Op69 ; CMP dp(d),dp(s) (dp(d))-(dp(s)) N......ZC spcaddrDPbDb_DPbSb Op69b: cmp al,ah cmc SPCSetFlagnzcnoret xor ecx,ecx ret NEWSYM Op89 ; ADC dp(d),dp(s) (dp(d))<-(dp(d))+(dp(s))+C NV..H..ZC spcaddrDPbDb_DPbSb Op89b mov cl,[spcP] shr cl,1 adc al,ah SPCSetFlagnvhzcnoret WriteByte xor ecx,ecx ret NEWSYM OpA9 ; SBC dp(d),dp(s) (dp(d))<-(dp(d))-(dp(s))-!C NV..H..ZC spcaddrDPbDb_DPbSb OpA9b mov cl,[spcP] xor cl,1 shr cl,1 sbb al,ah cmc SPCSetFlagnvhzcnoret WriteByte xor ecx,ecx ret NEWSYM OpFA ; MOV dp(d),dp(s) (dp(d)) <- (dp(s)) ........ xor ecx,ecx mov bl,[ebp+1] mov cl,[ebp] add ebx,[spcRamDP] add ecx,[spcRamDP] add ebp,2 push ebx mov ebx,ecx ReadByte pop ebx WriteByte xor ecx,ecx ret ;************************************************ ; (X),(Y) instructions ;************************************************ %macro spcaddrDPbXb_bYb 1 mov bl,[spcY] add ebx,[spcRamDP] ReadByte xor ebx,ebx mov ah,al mov bl,[spcX] add ebx,[spcRamDP] %1 ReadByte %endmacro NEWSYM Op19 ; OR (X),(Y) (X) <- (X) OR (Y) N......Z. spcaddrDPbXb_bYb Op19b: or al, ah mov [spcNZ],al WriteByte ret NEWSYM Op39 ; AND (X),(Y) (X) <- (X) AND (Y) N......Z. spcaddrDPbXb_bYb Op39b: and al, ah mov [spcNZ],al WriteByte ret NEWSYM Op59 ; EOR (X),(Y) (X) <- (X) EOR (Y) N......Z. spcaddrDPbXb_bYb Op59b: xor al, ah mov [spcNZ],al WriteByte ret NEWSYM Op79 ; CMP (X),(Y) (X)-(Y) N......ZC spcaddrDPbXb_bYb Op79b: cmp al, ah cmc SPCSetFlagnzc NEWSYM Op99 ; ADC (X),(Y) (X) <- (X)+(Y)+C NV..H..ZC spcaddrDPbXb_bYb Op99b: mov cl,[spcP] shr cl,1 adc al,ah SPCSetFlagnvhzcnoret WriteByte ret NEWSYM OpB9 ; SBC (X),(Y) (X) <- (X)-(Y)-!C NV..H..ZC spcaddrDPbXb_bYb OpB9b: mov cl,[spcP] xor cl,1 shr cl,1 sbb al,ah cmc SPCSetFlagnvhzcnoret WriteByte ret ;************************************************ ; MOV ,A instructions (Verified) ;************************************************ NEWSYM OpC4 ; MOV dp,A A -> (dp) ........ mov bl,[ebp] mov al, byte [spcA] add ebx,[spcRamDP] inc ebp WriteByte ret NEWSYM OpD4 ; MOV dp+x,A A -> (dp+X) ........ mov bl,[ebp] add bl,[spcX] mov al, byte [spcA] add ebx,[spcRamDP] inc ebp WriteByte ret NEWSYM OpC5 ; MOV labs,A A -> (abs) ........ mov bx,[ebp] mov al, byte [spcA] add ebp,2 add ebx,spcRam WriteByte ret NEWSYM OpD5 ; MOV labs+X,A A -> (abs+X) ........ mov bl,[spcX] add bx,[ebp] mov al, byte [spcA] add ebp,2 add ebx,spcRam WriteByte ret NEWSYM OpC6 ; MOV (X),A A -> (X) ........ mov bl,[spcX] add ebx,[spcRamDP] mov al, byte [spcA] WriteByte ret NEWSYM OpD6 ; MOV labs+Y,A A -> (abs+Y) ........ mov bl,[spcY] mov al, byte [spcA] add bx,[ebp] add ebp,2 add ebx,spcRam WriteByte ret NEWSYM OpC7 ; MOV (dp+X),A A -> ((dp+X+1)(dp+X)) ........ mov bl,[ebp] add bl,[spcX] xor eax,eax add ebx,[spcRamDP] inc ebp mov ax, word [ebx] mov ebx,eax add ebx,spcRam mov al, byte [spcA] WriteByte ret NEWSYM OpD7 ; MOV (dp)+Y,A A -> ((dp+1)(dp)+Y) ........ mov bl,[ebp] xor eax,eax add ebx,[spcRamDP] inc ebp mov ax, word [ebx] add ax,[spcY] mov ebx,eax add ebx,spcRam mov al, byte [spcA] WriteByte ret ;************************************************ ; MOV instructions (Verified) ;************************************************ NEWSYM OpD8 ; MOV dp,X X -> (dp) ........ mov bl,[ebp] mov al, byte [spcX] add ebx,[spcRamDP] inc ebp WriteByte ret NEWSYM OpF8 ; MOV X,dp X <- (dp) N......Z mov bl,[ebp] inc ebp add ebx,[spcRamDP] ReadByte mov byte [spcX], al mov [spcNZ],al ret NEWSYM OpC9 ; MOV labs,X X -> (abs) ........ mov bx,[ebp] mov al, byte [spcX] add ebp,2 add ebx,spcRam WriteByte ret NEWSYM OpE9 ; MOV X,labs X <- (abs) N......Z mov bx,[ebp] add ebx,spcRam ReadByte add ebp,2 mov byte [spcX], al mov [spcNZ],al ret NEWSYM OpD9 ; MOV dp+Y,X X -> (dp+Y) ........ mov bl,[ebp] mov al, byte [spcX] add bl,[spcY] inc ebp add ebx,[spcRamDP] WriteByte ret NEWSYM OpF9 ; MOV X,dp+Y X <- (dp+Y) N......Z mov bl,[ebp] add bl,[spcY] inc ebp add ebx,[spcRamDP] ReadByte mov byte [spcX], al mov [spcNZ],al ret NEWSYM OpCB ; MOV dp,Y Y -> (dp) ........ mov bl,[ebp] mov al, byte [spcY] add ebx,[spcRamDP] inc ebp WriteByte ret NEWSYM OpEB ; MOV Y,dp Y <- (dp) N......Z mov bl,[ebp] add ebx,[spcRamDP] inc ebp ReadByte mov byte [spcY], al mov [spcNZ],al ret NEWSYM OpDB ; MOV dp+X,Y X -> (dp+X) ........ mov bl,[ebp] add bl,[spcX] mov al, byte [spcY] add ebx,[spcRamDP] inc ebp WriteByte ret NEWSYM OpFB ; MOV Y,dp+X Y <- (dp+X) N......Z mov bl,[ebp] add bl,[spcX] inc ebp add ebx,[spcRamDP] ReadByte mov byte [spcY], al mov [spcNZ],al ret NEWSYM OpCC ; MOV labs,Y Y -> (abs) ........ mov bx,[ebp] mov al, byte [spcY] add ebp,2 add ebx,spcRam WriteByte ret NEWSYM OpEC ; MOV Y,labs Y <- (abs) N......Z mov bx,[ebp] add ebx,spcRam ReadByte add ebp,2 mov byte [spcY],al mov [spcNZ],al ret NEWSYM Op5D ; MOV X,A X <- A N......Z mov al,[spcA] mov [spcX],al mov [spcNZ],al ret NEWSYM Op7D ; MOV A,X A <- X N......Z mov al,[spcX] mov [spcA],al mov [spcNZ],al ret NEWSYM Op8D ; MOV Y,#inm Y <- inm N......Z mov bl,[ebp] mov [spcY],bl inc ebp mov [spcNZ],bl ret NEWSYM OpCD ; MOV X,#inm X <- inm N......Z mov bl,[ebp] mov [spcX],bl inc ebp mov [spcNZ],bl ret NEWSYM Op8F ; MOV dp,#inm (dp) <- inm ........ mov bl,[ebp+1] mov al,[ebp] add ebx,[spcRamDP] add ebp,2 WriteByte ret NEWSYM Op9D ; MOV X,SP X <- SP N......Z mov al,[spcS] mov [spcX],al mov [spcNZ],al ret NEWSYM OpBD ; MOV SP,X SP <- X ........ mov al,[spcX] mov [spcS],al ret NEWSYM OpDD ; MOV A,Y A <- Y N......Z mov al,[spcY] mov [spcA],al mov [spcNZ],al ret NEWSYM OpFD ; MOV Y,A Y <- A N......Z mov al,[spcA] mov [spcY],al mov [spcNZ],al ret NEWSYM OpAF ; MOV (X)+,A A -> (X) with auto inc ........ mov bl,[spcX] add ebx,[spcRamDP] mov al, byte [spcA] inc byte [spcX] WriteByte ret NEWSYM OpBF ; MOV A,(X)+ A <- (X) with auto inc N......Z mov bl,[spcX] add ebx,[spcRamDP] ReadByte inc byte [spcX] mov byte [spcA],al mov [spcNZ],al ret ;************************************************ ; CMP instructions (Verified) ;************************************************ NEWSYM OpC8 ; CMP X,#inm X-inm N......ZC mov bl,[ebp] inc ebp cmp [spcX],bl cmc SPCSetFlagnzc NEWSYM OpAD ; CMP Y,#inm Y-inm N......ZC mov bl,[ebp] inc ebp cmp [spcY],bl cmc SPCSetFlagnzc NEWSYM Op1E ; CMP X,labs X-(abs) N......ZC mov bx,[ebp] add ebp,2 add ebx,spcRam ReadByte cmp byte [spcX], al cmc SPCSetFlagnzc NEWSYM Op3E ; CMP X,dp X-(dp) N......ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp ReadByte cmp byte [spcX], al cmc SPCSetFlagnzc NEWSYM Op5E ; CMP Y,labs Y-(abs) N......ZC mov bx,[ebp] add ebx,spcRam ReadByte add ebp,2 cmp byte [spcY], al cmc SPCSetFlagnzc NEWSYM Op7E ; CMP Y,dp Y-(dp) N......ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp ReadByte cmp byte [spcY], al cmc SPCSetFlagnzc ;************************************************ ; Word Instructions (Verified) ;************************************************ NEWSYM Op1A ; DECW dp Decrement dp memory pair N......Z. mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM Op1AB ReadByte2 dec ax test ax,8000h jnz .YesNeg cmp ax,0000h je .YesZero mov byte [spcNZ],1 jmp .SkipFlag .YesNeg mov byte [spcNZ],80h jmp .SkipFlag .YesZero mov byte [spcNZ],0 .SkipFlag push ebx WriteByte pop ebx NEWSYM Op1Ab inc ebx mov al,ah WriteByte ret NEWSYM Op3A ; INCW dp Increment dp memory pair N......Z. mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM Op3AB ReadByte2 inc ax test ax,8000h jnz .YesNeg cmp ax,0000h je .YesZero mov byte [spcNZ],1 jmp .SkipFlag .YesNeg mov byte [spcNZ],80h jmp .SkipFlag .YesZero mov byte [spcNZ],0 .SkipFlag push ebx WriteByte pop ebx NEWSYM Op3Ab inc ebx mov al,ah WriteByte ret ; looks like there is the Carry flag checked in op5a.. NEWSYM Op5A ; CMPW YA,dp YA - (dp+1)(dp) N......ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM Op5AB ReadByte mov bl,[spcA] mov bh,[spcY] cmp bx,ax cmc SPCSetFlagnzc NEWSYM Op7A ; ADDW YA,dp YA <- YA + (dp+1)(dp) NV..H..ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM Op7AB ReadByte mov bl,[spcA] mov bh,[spcY] add bx,ax mov [spcA],bl mov [spcY],bh SPCSetFlagnvhzc NEWSYM Op9A ; SUBW YA,dp YA <- YA - (dp+1)(dp) NV..H..ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM Op9AB ReadByte mov bl,[spcA] mov bh,[spcY] sub bx,ax cmc mov [spcA],bl mov [spcY],bh SPCSetFlagnvhzc NEWSYM OpBA ; MOVW YA,dp YA - (dp+1)(dp) N......Z. mov bl,[ebp] add ebx,[spcRamDP] inc ebp inc ebx ReadByte2 mov ah,al dec ebx NEWSYM OpBAb ReadByte mov [spcA],al mov [spcY],ah test ax,8000h jnz .YesNeg cmp ax,0000h je .YesZero mov byte [spcNZ],1 ret .YesNeg mov byte [spcNZ],80h ret .YesZero mov byte [spcNZ],0 ret NEWSYM OpDA ; MOVW dp,YA (dp+1)(dp) - YA ......... mov bl,[ebp] mov al,[spcA] add ebx,[spcRamDP] inc ebp push ebx WriteByte pop ebx inc ebx mov al,[spcY] NEWSYM OpDAb WriteByte ret ;************************************************ ; mem.bit instructions (Verified) ;************************************************ %macro spcaddrmembit 0 mov bx,[ebp] mov cl,bh add ebp,2 shr cl,5 and bx,1FFFh ; mov cl,bl ; add ebp,2 ; shr bx,3 ; and cl,00000111b add ebx,spcRam ReadByte shr al,cl and al,01h %endmacro NEWSYM Op0A ; OR1 C,mem.bit C <- C OR (mem.bit) ........C spcaddrmembit or [spcP],al ret NEWSYM Op2A ; OR1 C,/mem.bit C <- C OR !(mem.bit) ........C spcaddrmembit xor al,01h or [spcP],al ret NEWSYM Op4A ; AND1 C,mem.bit C <- C AND (mem.bit) ........C mov bx,[ebp] mov cl,bh add ebp,2 shr cl,5 and bx,1FFFh ; mov cl,bl ; add ebp,2 ; shr bx,3 ; and cl,00000111b add ebx,spcRam ReadByte shr al,cl or al,0FEh and [spcP],al ret NEWSYM Op6A ; AND1 C,/mem.bit C <- C AND !(mem.bit) ........C mov bx,[ebp] mov cl,bh add ebp,2 shr cl,5 and bx,1FFFh ; mov cl,bl ; add ebp,2 ; shr bx,3 ; and cl,00000111b add ebx,spcRam ReadByte shr al,cl or al,0FEh xor al,01h and [spcP],al ret NEWSYM Op8A ; EOR1 C,mem.bit C <- C EOR (mem.bit) ........C spcaddrmembit xor [spcP],al ret NEWSYM OpAA ; MOV1 C,mem.bit C <- (mem.bit) spcaddrmembit and byte[spcP],0FEh or [spcP],al ret NEWSYM OpCA ; MOV1 mem.bit,C C -> (mem.bit) ......... mov bx,[ebp] mov al,[spcP] mov cl,bh mov ah,01h shr cl,5 and bx,1FFFh ; mov cl,bl ; mov ah,01h ; and cl,00000111b ; shr bx,3 shl ah,cl and al,01h add ebp,2 shl al,cl add ebx,spcRam ; al = carry flag positioned in correct location, ah = 1 positioned mov cl,al xor ah,0FFh ReadByte2 and al,ah or al,cl WriteByte ret NEWSYM OpEA ; NOT1 mem.bit complement (mem.bit) ......... mov bx,[ebp] mov cl,bh mov ah,01h shr cl,5 and bx,1FFFh ; mov cl,bl ; mov ah,01h ; and cl,00000111b ; shr bx,3 shl ah,cl add ebp,2 add ebx,spcRam ReadByte2 xor al,ah WriteByte ret ;************************************************ ; Shift Instructions (Verified) ;************************************************ NEWSYM Op0B ; ASL dp C << (dp) <<0 N......ZC mov bl,[ebp] add ebx,[spcRamDP] inc ebp ReadByte2 shl al,1 SPCSetFlagnzcnoret WriteByte ret NEWSYM Op4B ; LSR dp 0 >> (dp) <> (dp+X) <> (abs) <> A <> (dp) <> (dp+X) <> (abs) <> A < ',' / ','RSH',' * ' db 'ALT','SPC','CAP','F1 ','F2 ','F3 ','F4 ','F5 ' db 'F6 ','F7 ','F8 ','F9 ','F10','NUM','SCR','HOM' db 'UP ','PUP',' - ','LFT',' 5 ','RGT',' + ','END' db 'DWN','PDN','INS','DEL',' ',' ',' ','F11' db 'F12',' ',' ',' ',' ',' ',' ',' ' db ' ',' ',' ',' ',' ',' ',' ',' ' db ' ',' ',' ',' ',' ',' ',' ',' ' db ' ',' ',' ',' ',' ',' ',' ',' ' db ' ',' ',' ',' ',' ',' ',' ',' ' ; Joystick Stuff, Port 201h (80h) db 'JB7','JB8','JB1','JB2','JB3','JB4','JB5','JB6' db 'SWA','SWB','SWC','SWX','SWY','SWZ','SWL','SWR' db 'S2A','S2B','S2C','S2X','S2Y','S2Z','S2L','S2R' db 'S3A','S3B','S3C','S3X','S3Y','S3Z','S3L','S3R' db 'S4A','S4B','S4C','S4X','S4Y','S4Z','S4L','S4R' db 'GRR','GRB','GRY','GRG','GL1','GL2','GR1','GR2' db 'G2R','G2B','G2Y','G2G','2L1','2L2','2R1','2R2' db 'G3R','G3B','G3Y','G3G','3L1','3L2','3R1','3R2' db 'G4R','G4B','G4Y','G4G','4L1','4L2','4R1','4R2' db 'SWS','SWM','GSL','GST','JUP','JDN','JLF','JRG' db 'S2S','S2M','2SL','2ST','SWU','SWD','SWL','SWR' db 'S3S','S3M','3SL','3ST','S2U','S2D','S2L','S2R' db 'S4S','S4M','4SL','4ST','S3U','S3D','S3L','S3R' db 'J2U','J2D','J2L','J2R','S4U','S4D','S4L','S4R' db 'GRU','GRD','GRL','GRR','G2U','G2D','G2L','G2R' db 'G3U','G3D','G3L','G3R','G4U','G4D','G4L','G4R' ; Joystick Stuff, Port 209h (100h) db 'JB7','JB8','JB1','JB2','JB3','JB4','JB5','JB6' db 'SWA','SWB','SWC','SWX','SWY','SWZ','SWL','SWR' db 'S2A','S2B','S2C','S2X','S2Y','S2Z','S2L','S2R' db 'S3A','S3B','S3C','S3X','S3Y','S3Z','S3L','S3R' db 'S4A','S4B','S4C','S4X','S4Y','S4Z','S4L','S4R' db 'GRR','GRB','GRY','GRG','GL1','GL2','GR1','GR2' db 'G2R','G2B','G2Y','G2G','2L1','2L2','2R1','2R2' db 'G3R','G3B','G3Y','G3G','3L1','3L2','3R1','3R2' db 'G4R','G4B','G4Y','G4G','4L1','4L2','4R1','4R2' db 'SWS','SWM','GSL','GST','JUP','JDN','JLF','JRG' db 'S2S','S2M','2SL','2ST','SWU','SWD','SWL','SWR' db 'S3S','S3M','3SL','3ST','S2U','S2D','S2L','S2R' db 'S4S','S4M','4SL','4ST','S3U','S3D','S3L','S3R' db 'J2U','J2D','J2L','J2R','S4U','S4D','S4L','S4R' db 'GRU','GRD','GRL','GRR','G2U','G2D','G2L','G2R' db 'G3U','G3D','G3L','G3R','G4U','G4D','G4L','G4R' ; Extra Stuff (180h) (Parallel Port) db 'PPB','PPY','PSL','PST','PUP','PDN','PLT','PRT' db 'PPA','PPX','PPL','PPR',' ',' ',' ',' ' db 'P2B','P2Y','P2S','P2T','P2U','P2D','P2L','P2R' db 'P2A','P2X','P2L','P2R',' ',' ',' ',' ' db 'PPB','PPY','PSL','PST','PUP','PDN','PLT','PRT' db 'PPA','PPX','PPL','PPR',' ',' ',' ',' ' db 'P2B','P2Y','P2S','P2T','P2U','P2D','P2L','P2R' db 'P2A','P2X','P2L','P2R',' ',' ',' ',' ' ;SECTION .text ;SECTION .data ;NEWSYM ZSNESBase, dd 0 ;TempVarSeek dd 0 gotoroot db '\',0 SECTION .bss NEWSYM ZSNESBase, resd 1 TempVarSeek resd 1 SECTION .text ; **************************** ; Mouse Stuff ; **************************** NEWSYM Init_Mouse ; return non-zero if successful mov eax,00h int 33h cmp ax,0 je .nomouse mov eax,07h mov ecx,0 mov edx,255 int 33h mov eax,08h mov ecx,0 mov edx,223 int 33h mov eax,0Fh mov ecx,8 mov edx,8 int 33h mov eax,04h mov ecx,0 mov edx,0 int 33h mov ax,1 .nomouse ret NEWSYM Get_MouseData ; Returns both pressed and coordinates mov eax,03h int 33h ; bx : bit 0 = left button, bit 1 = right button ; cx = Mouse X Position, dx = Mouse Y Position ret NEWSYM Set_MouseXMax ; Sets the X boundaries (ecx = left, edx = right) mov eax,07h int 33h ret NEWSYM Set_MouseYMax ; Sets the Y boundaries (ecx = left, edx = right) mov eax,08h int 33h ret NEWSYM Set_MousePosition ; Sets Mouse Position (x:cx,y:dx) mov eax,04h int 33h ret NEWSYM Get_MousePositionDisplacement ; returns x,y displacement in pixel in cx,dx mov eax,0Bh int 33h ret NEWSYM MouseWindow ret ; **************************** ; Sound Stuff ; **************************** NEWSYM StopSound ret NEWSYM StartSound ret NEWSYM SoundProcess ; This function is called ~60 times/s at full speed cmp byte[OSPort],1 ; Do not call in the dos port ; ja .notdos .nosound ret .notdos cmp byte[soundon],0 je .nosound cmp byte[DSPDisable],1 je .nosound mov eax,200 ; Size of 32-bit buffer in dwords add eax,eax mov dword[BufferSizeW],eax add eax,eax mov dword[BufferSizeB],eax pushad call ProcessSoundBuffer popad ; DSPBuffer should contain the processed buffer in the specified size ; You will have to convert/clip it to 16-bit for actual sound process ret NEWSYM Check60hz ; Call the timer update function here ret ; **************************** ; TCP/IP Stuff ; **************************** ; TCPIPPortNum ;NEWSYM TCPIPStatus, db 0 ;NEWSYM PacketSendSize, dd 0 ;NEWSYM PacketRecvSize, dd 0 ;NEWSYM PacketRecvPtr, dd 0 ;NEWSYM PacketSendArray, times 256 db 0 ;NEWSYM PacketRecvArray, times 256 db 0 ;NEWSYM IPAddrStr, times 20 db 0 ;NEWSYM RemoteDisconnect, db 0 SECTION .bss NEWSYM TCPIPStatus, resb 1 NEWSYM PacketSendSize, resd 1 NEWSYM PacketRecvSize, resd 1 NEWSYM PacketRecvPtr, resd 1 NEWSYM PacketSendArray, times 256 resb 1 NEWSYM PacketRecvArray, times 256 resb 1 NEWSYM IPAddrStr, times 20 resb 1 NEWSYM RemoteDisconnect, resb 1 SECTION .text NEWSYM TCPIPStartServer mov dword[PacketSendSize],0 mov dword[PacketRecvSize],0 ; call InitTCP or eax,eax jnz .failed mov byte[TCPIPStatus],1 ; StartServer(unsigned short port) mov ax,[TCPIPPortNum] push ax ; call StartServer add esp,2 or eax,eax jnz .noserver mov byte[TCPIPStatus],2 .noserver ret .failed mov eax,1 ret NEWSYM TCPIPInitConnectToServer mov dword[PacketSendSize],0 mov dword[PacketRecvSize],0 ; call InitTCP or eax,eax jnz .failed mov byte[TCPIPStatus],1 ; Convert TCPIPAddress to IPAddrStr mov ebx,TCPIPAddress mov edx,IPAddrStr .notend mov al,[ebx] cmp al,' ' je .dontinclude mov [edx],al inc edx .dontinclude inc ebx cmp al,0 jne .notend ; int ConnectServer(char *servername, unsigned short port) mov ax,[TCPIPPortNum] push ax mov eax,IPAddrStr push eax ; call ConnectServer add esp,6 or eax,eax jnz .noclient mov byte[TCPIPStatus],3 .noclient xor eax,eax ret .failed mov eax,1 ret NEWSYM TCPIPStoreByte ; Store al into the array cmp dword[PacketSendSize],256 je .packeterror push ebx mov ebx,[PacketSendSize] mov [PacketSendArray+ebx],al pop ebx inc dword[PacketSendSize] ret .packeterror jmp OSExit NEWSYM TCPIPGetByte ; dh = 0 : No bytes in buffer ; dl = resulting character cmp dword[PacketRecvSize],0 jne .bytereceived mov dword[PacketRecvPtr],0 call TCPIPRecvPacket cmp dword[PacketRecvSize],0 jne .bytereceived xor dh,dh ret .bytereceived push eax mov eax,[PacketRecvPtr] mov dl,[PacketRecvArray+eax] mov dh,1 inc dword[PacketRecvPtr] mov eax,[PacketRecvPtr] cmp [PacketRecvSize],eax jne .notequal mov dword[PacketRecvSize],0 .notequal pop eax ret NEWSYM TCPIPSendPacket cmp dword[PacketSendSize],0 je .nopacket pushad ; Send PacketSendArray with size of PacketSendSize ; SendData(int dsize,char *dptr) mov eax,PacketSendArray push eax mov eax,[PacketSendSize] push eax ; call SendData or eax,eax jnz .failed add esp,8 popad .nopacket ret .failed add esp,8 popad call TCPIPDisconnect jmp OSExit NEWSYM TCPIPRecvPacket pushad ; Store packet to PacketRecvArray, size at PacketRecvSize ; int GetData(int dsize,char *dptr) mov eax,PacketRecvArray push eax mov eax,256 push eax ; call GetData cmp eax,-1 je .failed mov [PacketRecvSize],eax add esp,8 popad ret .failed add esp,8 popad call TCPIPDisconnect jmp OSExit NEWSYM TCPIPDisconnect ; call DeInitTCP cmp byte[TCPIPStatus],3 jne .notserver ; call StopServer .notserver cmp byte[TCPIPStatus],3 jne .notclient ; call Disconnect .notclient ret NEWSYM TCPIPPreparePacket mov dword[PacketSendSize],0 ret NEWSYM TCPIPConnectToServer ret NEWSYM TCPIPWaitForConnection ret NEWSYM TCPIPSendPacketUDP ret NEWSYM TCPIPConnectToServerW ret NEWSYM GetHostName ret NEWSYM hostname NEWSYM UDPConfig ;NEWSYM tcperr, dd 0,0,0,0 SECTION .bss NEWSYM tcperr, resd 1 SECTION .text NEWSYM ClearUDPStuff NEWSYM Wait1SecWin NEWSYM EnableSUDPPacket NEWSYM DisableSUDPPacket NEWSYM WinErrorA NEWSYM WinErrorB NEWSYM GotoHomepage ret NEWSYM GetTimeInSeconds push es mov ax,[selc0040] mov es,ax mov eax,[es:108] and eax,0FFFFFFh xor edx,edx mov ebx,86400 mul ebx mov ebx,1573039 div ebx pop es ret zsnes-1.36/src/dos/gppro.asm0100644000175000017500000000457207267141100015377 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" NEWSYM GPProAsmStart section .data sample times 60 db 0 clock_mask db 0 data_mask db 0 section .text NEWSYM read_gpp push ebx push ecx push edx push edi push esi cmp al,0 jne GPP_L14 mov byte [clock_mask],0x10 mov byte [data_mask],0x20 jmp GPP_L15 GPP_L14: mov byte [clock_mask],0x40 mov byte [data_mask],0x80 GPP_L15: xor ebx,ebx xor edi,edi cli in al,dx mov ah,al GPP_L4: xor ecx,ecx GPP_L0: nop nop nop nop nop nop in al,dx cmp al,ah jne GPP_L1 inc ecx cmp ecx,255 jl GPP_L0 GPP_L1: cmp ecx,255 je near GPP_ERR test [clock_mask],ah jz GPP_L2 test [clock_mask],al jnz GPP_L2 test [data_mask],al jz GPP_L3 mov byte [sample+edi],1 jmp GPP_L12 GPP_L3: mov byte [sample+edi],0 GPP_L12: inc edi GPP_L2: mov ah,al cmp ebx,200 je GPP_L13 inc ebx cmp edi,50 jl GPP_L4 GPP_L13: sti xor ecx,ecx mov esi,1 GPP_L7: cmp byte [sample+esi],1 jg GPP_ERR jne GPP_L6 inc ecx jmp GPP_L5 GPP_L6: xor ecx,ecx GPP_L5: cmp ecx,5 je GPP_L8 cmp esi,edi je GPP_L8 inc esi jmp GPP_L7 GPP_L8: cmp ecx,5 jne GPP_ERR add esi,2 xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx GPP_L10: inc ecx cmp ecx,5 jne GPP_L11 mov ecx,1 inc esi GPP_L11: mov dl,[sample+esi] or eax,edx shl eax,1 cmp ebx,13 je GPP_L9 inc ebx inc esi jmp GPP_L10 GPP_L9: pop esi pop edi pop edx pop ecx pop ebx ret GPP_ERR: sti pop esi pop edi pop edx pop ecx pop ebx mov eax,1 ret NEWSYM GPProAsmEnd zsnes-1.36/src/dos/initvid.asm0100644000175000017500000003075707432621315015727 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM AddSub256,InitVesa2,cbitmode,cvidmode,makepal EXTSYM scanlines,selcA000,vesa2_bits,vesa2_bpos,vesa2_clbit EXTSYM vesa2_gpos,vesa2_rpos,vesa2_usbit,vesa2_x,vesa2_y EXTSYM vesa2selec,InitVesa12,videotroub %ifdef __MSDOS__ EXTSYM cscopymodeq,cscopymodex %endif NEWSYM InitVidAsmStart SECTION .bss NEWSYM clearfilter, resw 1 NEWSYM res640, resb 1 NEWSYM res480, resb 1 SECTION .text NEWSYM dosinitvideo2 cmp byte[cvidmode],2 jne .nomodeq jmp dosinitvideo.initmodeq256 .nomodeq cmp byte[cvidmode],5 jne .nomodex jmp dosinitvideo.initmodex256 .nomodex ;******************************************************* ; InitVideo ;******************************************************* NEWSYM dosinitvideo mov byte[cbitmode],0 mov byte[res640],0 mov byte[res480],0 cmp byte[cvidmode],0 je near .initmodeq224 cmp byte[cvidmode],1 je near .initmodeq240 cmp byte[cvidmode],2 je near .initmodeq256 cmp byte[cvidmode],3 je near .initmodex224 cmp byte[cvidmode],4 je near .initmodex240 cmp byte[cvidmode],5 je near .initmodex256 cmp byte[cvidmode],6 je near .initvesa12640x480x16 cmp byte[cvidmode],7 je near .initvesa2320x240x8 cmp byte[cvidmode],8 je near .initvesa2320x240x16 cmp byte[cvidmode],9 je near .initvesa2320x480x8 cmp byte[cvidmode],10 je near .initvesa2320x480x16 cmp byte[cvidmode],11 je near .initvesa2512x384x8 cmp byte[cvidmode],12 je near .initvesa2512x384x16 cmp byte[cvidmode],13 je near .initvesa2640x400x8 cmp byte[cvidmode],14 je near .initvesa2640x400x16 cmp byte[cvidmode],15 je near .initvesa2640x480x8 cmp byte[cvidmode],16 je near .initvesa2640x480x16 cmp byte[cvidmode],17 je near .initvesa2800x600x8 cmp byte[cvidmode],18 je near .initvesa2800x600x16 ret %include "dos/vga.inc" ;******************************************************* ; InitModeQ 224 Sets up 256x224 chained mode ;******************************************************* .initmodeq224 %ifdef __MSDOS__ SetVGAMode .Mode256x224c call cscopymodeq %endif call makepal ret ;******************************************************* ; InitModeQ 240 Sets up 256x240 chained mode ;******************************************************* .initmodeq240 %ifdef __MSDOS__ SetVGAMode .Mode256x240c call cscopymodeq %endif call makepal ret ;******************************************************* ; InitModeQ 256 Sets up 256x256 chained mode ;******************************************************* .initmodeq256 %ifdef __MSDOS__ cmp byte[scanlines],1 je near .scanlines SetVGAMode .Mode256x256c jmp .done .scanlines SetVGAMode .Mode256x256cs jmp .done .done call cscopymodeq %endif call makepal ret ;******************************************************* ; InitModeX 224 Sets up 320x224 unchained mode ;******************************************************* .initmodex224 %ifdef __MSDOS__ SetVGAMode .Mode320x224 call cscopymodex %endif call makepal ret ;******************************************************* ; InitModeX 240 Sets up 320x240 unchained mode ;******************************************************* .initmodex240 %ifdef __MSDOS__ SetVGAMode .Mode320x240 call cscopymodex %endif call makepal ret ;******************************************************* ; InitModeX 256 Sets up 320x256 unchained mode ;******************************************************* .initmodex256 %ifdef __MSDOS__ cmp byte[scanlines],1 je near .scanlines2 SetVGAMode .Mode320x256 jmp .done2 .scanlines2 SetVGAMode .Mode320x256s jmp .done2 .done2 call cscopymodex %endif call makepal ret ;******************************************************* ; InitVESA2 320x240x8 Set up Linear 320x240x8b ;******************************************************* .initvesa2320x240x8 mov byte[cbitmode],0 mov word[vesa2_x],320 mov word[vesa2_y],240 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble ret .notrouble call makepal ; clear screen (320*240 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,320*240 .loop mov byte[es:edi],0 inc edi dec ecx jnz .loop pop es ret ;******************************************************* ; InitVESA2 320x240x16 Set up Linear 320x240x16b ;******************************************************* .initvesa2320x240x16 mov byte[cbitmode],1 mov word[vesa2_x],320 mov word[vesa2_y],240 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble2 ret .notrouble2 ; clear screen (320*240*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,320*240*2 .loopb mov byte[es:edi],0 inc edi dec ecx jnz .loopb pop es ret ;******************************************************* ; InitVESA2 640x480x8 Set up Linear 640x480x8b ;******************************************************* .initvesa2640x480x8 mov byte[res640],1 mov byte[res480],1 mov word[vesa2_x],640 mov word[vesa2_y],480 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble3 ret .notrouble3 call makepal ; clear screen (640*480 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,640*480 .loopc3 mov byte[es:edi],0 inc edi dec ecx jnz .loopc3 pop es ret ;******************************************************* ; InitVESA2 640x480x16 Set up Linear 640x480x16b ;******************************************************* .initvesa2640x480x16 mov byte[res640],1 mov byte[res480],1 mov byte[cbitmode],1 mov word[vesa2_x],640 mov word[vesa2_y],480 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble4 ret .notrouble4 ; clear screen (640*480*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,640*480*2 .loopd3 mov byte[es:edi],0 inc edi dec ecx jnz .loopd3 pop es ret ;******************************************************* ; InitVESA2 800x600x8 Set up Linear 800x600x8b ;******************************************************* .initvesa2800x600x8 mov byte[res640],1 mov byte[res480],1 mov word[vesa2_x],800 mov word[vesa2_y],600 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble11 ret .notrouble11 call makepal ; clear screen (800*600 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,800*600 .looph2 mov byte[es:edi],0 inc edi dec ecx jnz .looph2 pop es ret ;******************************************************* ; InitVESA2 800x600x16 Set up Linear 800x600x16b ;******************************************************* .initvesa2800x600x16 mov byte[res640],1 mov byte[res480],1 mov byte[cbitmode],1 mov word[vesa2_x],800 mov word[vesa2_y],600 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble12 ret .notrouble12 ; clear screen (800*600*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,800*600*2 .looph3 mov byte[es:edi],0 inc edi dec ecx jnz .looph3 pop es ret ;******************************************************* ; InitVESA2 320x480x8 Set up Linear 320x480x8b ;******************************************************* .initvesa2320x480x8 mov byte[res480],1 mov word[vesa2_x],320 mov word[vesa2_y],480 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble5 ret .notrouble5 call makepal ; clear screen (320*480 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,320*480 .loopc mov byte[es:edi],0 inc edi dec ecx jnz .loopc pop es ret ;******************************************************* ; InitVESA2 320x480x16 Set up Linear 320x480x16b ;******************************************************* .initvesa2320x480x16 mov byte[res480],1 mov byte[cbitmode],1 mov word[vesa2_x],320 mov word[vesa2_y],480 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble6 ret .notrouble6 ; clear screen (320*480*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,320*480*2 .loopd mov byte[es:edi],0 inc edi dec ecx jnz .loopd pop es ret ;******************************************************* ; InitVESA2 512x384x8 Set up Linear 512x384x8b ;******************************************************* .initvesa2512x384x8 mov byte[res640],2 mov byte[cbitmode],0 mov word[vesa2_x],512 mov word[vesa2_y],384 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble7 ret .notrouble7 call makepal ; clear screen (512*384 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,512*384 .loope mov byte[es:edi],0 inc edi dec ecx jnz .loope pop es ret ;******************************************************* ; InitVESA2 512x384x16 Set up Linear 512x384x16b ;******************************************************* .initvesa2512x384x16 mov byte[res640],2 mov byte[cbitmode],1 mov word[vesa2_x],512 mov word[vesa2_y],384 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble8 ret .notrouble8 ; clear screen (512*384*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,512*384*2 .loopf mov byte[es:edi],0 inc edi dec ecx jnz .loopf pop es ret ;******************************************************* ; InitVESA2 640x400x8 Set up Linear 640x400x8b ;******************************************************* .initvesa2640x400x8 mov byte[res640],2 mov word[vesa2_x],640 mov word[vesa2_y],400 mov byte[vesa2_bits],8 call InitVesa2 cmp byte[videotroub],1 jne .notrouble9 ret .notrouble9 call makepal ; clear screen (640*400 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,640*400 .loopg mov byte[es:edi],0 inc edi dec ecx jnz .loopg pop es ret ;******************************************************* ; InitVESA2 640x400x16 Set up Linear 640x400x16b ;******************************************************* .initvesa2640x400x16 mov byte[res640],2 mov byte[cbitmode],1 mov word[vesa2_x],640 mov word[vesa2_y],400 mov byte[vesa2_bits],16 call InitVesa2 cmp byte[videotroub],1 jne .notrouble10 ret .notrouble10 ; clear screen (640*400*2 bytes) push es mov ax,[vesa2selec] mov es,ax mov edi,0 mov ecx,640*400*2 .looph mov byte[es:edi],0 inc edi dec ecx jnz .looph pop es ret ;******************************************************* ; InitVESA1.2 640x480x16 Set up 640x480x16b ;******************************************************* .initvesa12640x480x16 mov byte[res640],1 mov byte[cbitmode],1 mov word[vesa2_x],640 mov word[vesa2_y],480 mov byte[vesa2_bits],16 call InitVesa12 ret ; clear screen (640*480*2 bytes) push es mov ax,[selcA000] mov es,ax mov ebx,9 xor edx,edx .loopbanks xor edi,edi mov ecx,16384 .loopi mov byte[es:edi],0 inc edi dec ecx jnz .loopi dec ebx jnz .loopbanks mov ecx,6144 pop es ret NEWSYM InitVidAsmEnd zsnes-1.36/src/dos/joy.asm0100644000175000017500000011215507432621315015053 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM JoyAC,JoyBC,JoyLC,JoyRC,JoySelec,JoyStart,JoyXC,JoyYC,WhichSW,_SW1 EXTSYM _SW2,_readSideWinder,delay,numjoy,pl1Ak,pl1Bk,pl1Lk,pl1Rk,pl1Xk EXTSYM pl1Yk,pl1contrl,pl1downk,pl1leftk,pl1rightk,pl1selk,pl1startk EXTSYM pl1upk,pl2Ak,pl2Bk,pl2Lk,pl2Rk,pl2Xk,pl2Yk,pl2contrl,pl2downk EXTSYM pl2leftk,pl2rightk,pl2selk,pl2startk,pl2upk,_SWCount,_SW3,_SW4 EXTSYM pl3Ak,pl3Bk,pl3Lk,pl3Rk,pl3Xk,pl1p209,pl2p209,pl3p209,pl4p209 EXTSYM pl3Yk,pl3contrl,pl3downk,pl3leftk,pl3rightk,pl3selk,pl3startk EXTSYM pl3upk,pl4Ak,pl4Bk,pl4Lk,pl4Rk,pl4Xk,pl4Yk,pl4contrl,pl4downk EXTSYM pl4leftk,pl4rightk,pl4selk,pl4startk,pl4upk,pressed,read_gpp EXTSYM pl5contrl,pl5p209 EXTSYM CalibXmin, CalibYmin, CalibXmax, CalibYmax, CalibXmin209 EXTSYM CalibYmin209, CalibXmax209, CalibYmax209 NEWSYM JoyAsmStart SECTION .data ;NEWSYM joy4218, db 0 ;NEWSYM joy4219, db 0 ;NEWSYM joy4218j, db 0 ;NEWSYM joy4219j, db 0 ;NEWSYM joy421A, db 0 ;NEWSYM joy421B, db 0 ;NEWSYM joy421Aj, db 0 ;NEWSYM joy421Bj, db 0 ;NEWSYM JoyCenterX, dd 0 ;NEWSYM JoyCenterY, dd 0 ;NEWSYM JoyMaxX, dd 0 ;NEWSYM JoyMaxY, dd 0 ;NEWSYM JoyMinX, dd 0 ;NEWSYM JoyMinY, dd 0 ;NEWSYM JoyExists, db 0 ;NEWSYM JoyX, dd 0 ;NEWSYM JoyY, dd 0 ;NEWSYM JoyCenterX2, dd 0 ;NEWSYM JoyCenterY2, dd 0 ;NEWSYM JoyMaxX2, dd 0 ;NEWSYM JoyMaxY2, dd 0 ;NEWSYM JoyMinX2, dd 0 ;NEWSYM JoyMinY2, dd 0 ;NEWSYM JoyExists2, db 0 ;NEWSYM JoyX2, dd 0 ;NEWSYM JoyY2, dd 0 ;NEWSYM JoyAltrn, db 0 NEWSYM JoyAltrn2, db 2 ;NEWSYM JoyCenterX209, dd 0 ;NEWSYM JoyCenterY209, dd 0 ;NEWSYM JoyMaxX209, dd 0 ;NEWSYM JoyMaxY209, dd 0 ;NEWSYM JoyMinX209, dd 0 ;NEWSYM JoyMinY209, dd 0 ;NEWSYM JoyCenterX2209, dd 0 ;NEWSYM JoyCenterY2209, dd 0 ;NEWSYM JoyMaxX2209, dd 0 ;NEWSYM JoyMaxY2209, dd 0 ;NEWSYM JoyMinX2209, dd 0 ;NEWSYM JoyMinY2209, dd 0 ;JoyQuant db 0 ;JoyBQuant db 0 ;NumSWs db 0 ;NumGRiPs db 0 ;PPad db 0 ; b0 = pp0, b1 = pp1 ;JoyQuant209 db 0 ;JoyBQuant209 db 0 ;NumSWs209 db 0 ;NumGRiPs209 db 0 ;Buttons6 db 0 ;Buttons6209 db 0 SECTION .bss NEWSYM joy4218, resb 1 NEWSYM joy4219, resb 1 NEWSYM joy4218j, resb 1 NEWSYM joy4219j, resb 1 NEWSYM joy421A, resb 1 NEWSYM joy421B, resb 1 NEWSYM joy421Aj, resb 1 NEWSYM joy421Bj, resb 1 NEWSYM JoyCenterX, resd 1 NEWSYM JoyCenterY, resd 1 NEWSYM JoyMaxX, resd 1 NEWSYM JoyMaxY, resd 1 NEWSYM JoyMinX, resd 1 NEWSYM JoyMinY, resd 1 NEWSYM JoyExists, resb 1 NEWSYM JoyX, resd 1 NEWSYM JoyY, resd 1 NEWSYM JoyCenterX2, resd 1 NEWSYM JoyCenterY2, resd 1 NEWSYM JoyMaxX2, resd 1 NEWSYM JoyMaxY2, resd 1 NEWSYM JoyMinX2, resd 1 NEWSYM JoyMinY2, resd 1 NEWSYM JoyExists2, resb 1 NEWSYM JoyX2, resd 1 NEWSYM JoyY2, resd 1 NEWSYM JoyAltrn, resb 1 NEWSYM JoyCenterX209, resd 1 NEWSYM JoyCenterY209, resd 1 NEWSYM JoyMaxX209, resd 1 NEWSYM JoyMaxY209, resd 1 NEWSYM JoyMinX209, resd 1 NEWSYM JoyMinY209, resd 1 NEWSYM JoyCenterX2209, resd 1 NEWSYM JoyCenterY2209, resd 1 NEWSYM JoyMaxX2209, resd 1 NEWSYM JoyMaxY2209, resd 1 NEWSYM JoyMinX2209, resd 1 NEWSYM JoyMinY2209, resd 1 JoyQuant resb 1 JoyBQuant resb 1 NumSWs resb 1 NumGRiPs resb 1 PPad resb 1 ; b0 = pp0, b1 = pp1 JoyQuant209 resb 1 JoyBQuant209 resb 1 NumSWs209 resb 1 NumGRiPs209 resb 1 Buttons6 resb 1 Buttons6209 resb 1 ;NEWSYM pl3selk, dd 0 ; 3SELECT = SHIFT ;NEWSYM pl3startk, dd 0 ; 3START = ENTER ;NEWSYM pl3upk, dd 0 ; 3UP = up ;NEWSYM pl3downk, dd 0 ; 3DOWN = down ;NEWSYM pl3leftk, dd 0 ; 3LEFT = left ;NEWSYM pl3rightk, dd 0 ; 3RIGHT = right ;NEWSYM pl3Yk, dd 0 ; 3X = INS ;NEWSYM pl3Xk, dd 0 ; 3A = HOME ;NEWSYM pl3Lk, dd 0 ; 3L = PAGE UP ;NEWSYM pl3Bk, dd 0 ; 3Y = DELETE ;NEWSYM pl3Ak, dd 0 ; 3B = END ;NEWSYM pl3Rk, dd 0 ; 3R = PAGE DOWN SECTION .text NEWSYM GetCoords mov dword[JoyX],0 mov dword[JoyY],0 cli mov al,0 out dx,al mov ecx,00FFFFh .loopa in al,dx test al,01H jz .YAxis test al,02H jz .XAxis inc dword[JoyX] inc dword[JoyY] dec ecx jnz .loopa mov byte [JoyExists], 0 mov dword[JoyX],0 mov dword[JoyY],0 jmp .End .YAxis in al,dx test al,02h jz .YAxisOk nop nop inc dword[JoyY] nop dec ecx jnz .YAxis mov byte [JoyExists], 0 mov dword[JoyX],0 mov dword[JoyY],0 .YAxisOk jmp .End .XAxis in al,dx test al,01h jz .XAxisOk nop nop inc dword[JoyX] nop dec ecx jnz .XAxis mov byte [JoyExists], 0 mov dword[JoyX],0 mov dword[JoyY],0 .XAxisOk .End sti ret ; Dual Joysticks NEWSYM GetCoords3 mov dword[JoyX],0 mov dword[JoyY],0 mov dword[JoyX2],0 mov dword[JoyY2],0 cli mov al,0 out dx,al mov ecx,01FFFFh .loopa in al,dx test al,01H jz .YAxis inc dword[JoyX] nop .YAxis test al,02H jz .XAxis inc dword[JoyY] nop .XAxis test al,04H jz .YAxis2 inc dword[JoyX2] nop .YAxis2 test al,08H jz .XAxis2 inc dword[JoyY2] nop .XAxis2 test al,0Fh jz .nomore dec ecx jnz .loopa mov byte [JoyExists], 0 mov dword[JoyX],0 mov dword[JoyY],0 mov byte [JoyExists2], 0 mov dword[JoyX2],0 mov dword[JoyY2],0 .nomore sti ret NEWSYM DosUpdateDevices mov byte[PPad],0 mov byte[JoyQuant],0 mov byte[JoyBQuant],0 mov byte[NumSWs],0 mov byte[NumGRiPs],0 mov byte[JoyQuant209],0 mov byte[JoyBQuant209],0 mov byte[NumSWs209],0 mov byte[NumGRiPs209],0 mov byte[Buttons6],0 mov byte[Buttons6209],0 ; Check for button #'s, joystick types, etc. mov al,[pl1contrl] mov ah,[pl1p209] call .checkdevice mov al,[pl2contrl] mov ah,[pl2p209] call .checkdevice mov al,[pl3contrl] mov ah,[pl3p209] call .checkdevice mov al,[pl4contrl] mov ah,[pl4p209] call .checkdevice mov al,[pl5contrl] mov ah,[pl5p209] call .checkdevice ; Auto-Calibrate the joysticks cmp byte[JoyQuant],2 jne .no2joyst mov dx,201h mov byte[JoyExists2],1 call GetCoords3 mov ecx,1000 call delay cmp byte[JoyExists2],0 jne .no2joyst mov byte[JoyQuant],1 .no2joyst cmp byte[JoyQuant],1 jne .no1joyst mov dx,201h mov byte[JoyExists],1 call GetCoords mov ecx,1000 call delay cmp byte[JoyExists],0 jne .no1joyst mov byte[JoyQuant],0 .no1joyst ; set max & mins mov ecx,[JoyX2] mov [JoyCenterX2], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinX2],eax add eax,ecx add eax,ecx mov dword[JoyMaxX2],eax mov ecx,[JoyY2] mov [JoyCenterY2], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinY2],eax add eax,ecx add eax,ecx mov dword[JoyMaxY2],eax mov ecx,[JoyX] mov [JoyCenterX], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinX],eax add eax,ecx add eax,ecx mov dword[JoyMaxX],eax mov ecx,[JoyY] mov [JoyCenterY], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinY],eax add eax,ecx add eax,ecx mov dword[JoyMaxY],eax ; Port 209 ; Auto-Calibrate the joysticks cmp byte[JoyQuant209],2 jne .no2joyst2 mov dx,209h mov byte[JoyExists2],1 call GetCoords3 mov ecx,1000 call delay cmp byte[JoyExists2],0 jne .no2joyst2 mov byte[JoyQuant209],1 .no2joyst2 cmp byte[JoyQuant209],1 jne .no1joyst2 mov dx,209h mov byte[JoyExists],1 call GetCoords mov ecx,1000 call delay cmp byte[JoyExists],0 jne .no1joyst2 mov byte[JoyQuant209],0 .no1joyst2 ; set max & mins mov ecx,[JoyX2] mov [JoyCenterX2209], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinX2209],eax add eax,ecx add eax,ecx mov dword[JoyMaxX2209],eax mov ecx,[JoyY2] mov [JoyCenterY2209], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinY2209],eax add eax,ecx add eax,ecx mov dword[JoyMaxY2209],eax mov ecx,[JoyX] mov [JoyCenterX209], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinX209],eax add eax,ecx add eax,ecx mov dword[JoyMaxX209],eax mov ecx,[JoyY] mov [JoyCenterY209], ecx mov eax,ecx shr ecx,1 sub eax,ecx mov dword[JoyMinY209],eax add eax,ecx add eax,ecx mov dword[JoyMaxY209],eax cmp dword[CalibXmin],0 je .nocalib mov eax,[CalibXmin] mov [JoyMinX],eax mov eax,[CalibYmin] mov [JoyMinY],eax mov eax,[CalibXmax] mov [JoyMaxX],eax mov eax,[CalibYmax] mov [JoyMaxY],eax .nocalib cmp dword[CalibXmin209],0 je .nocalib209 mov eax,[CalibXmin209] mov [JoyMinX209],eax mov eax,[CalibYmin209] mov [JoyMinY209],eax mov eax,[CalibXmax209] mov [JoyMaxX209],eax mov eax,[CalibYmax209] mov [JoyMaxY209],eax .nocalib209 ret .checkdevice ; 1 = keyboard, 2 = 2b joystick, 3,4 = 4b joystick, 5 = 6b joystick ; 6 = Sidewinder1, 7 = Sidewinder2, 8 = Sidewinder3, 9 = Sidewiner4 ; 10 = Grip0, 11 = Grip1, 12 = Grip2, 13 = Grip3, 14 = Parallel pad0 ; 15 = Parallel pad1, 16 = Parallel pad2, 17 = Parallel pad3 ; 19 = Parallel pad4, 18 = 8b joystick cmp al,1 ja .joyokay ret .joyokay cmp al,14 jne .nopp0 or byte[PPad],1 ret .nopp0 cmp al,15 jne .nopp1 or byte[PPad],2 ret .nopp1 cmp al,16 jne .nopp2 or byte[PPad],4 ret .nopp2 cmp al,17 jne .nopp3 or byte[PPad],8 ret .nopp3 cmp al,19 jne .nopp4 or byte[PPad],16 ret .nopp4 cmp ah,0 jne near .port209 cmp al,2 jne .nojoy2b inc byte[JoyQuant] add byte[JoyBQuant],2 ret .nojoy2b cmp al,3 je .joy4b cmp al,4 jne .nojoy4b .joy4b mov byte[JoyQuant],1 mov byte[JoyBQuant],4 ret .nojoy4b cmp al,5 jne .nojoy6b mov byte[JoyQuant],2 mov byte[JoyBQuant],6 mov byte[Buttons6],1 ret .nojoy6b cmp al,18 jne .nojoy8b mov byte[JoyQuant],2 mov byte[JoyBQuant],8 mov byte[Buttons6],2 ret .nojoy8b cmp al,9 ja .grip sub al,5 cmp byte[NumSWs],al ja .skipswc mov byte[NumSWs],al .skipswc ret .grip cmp al,13 ja .none sub al,9 cmp byte[NumGRiPs],al ja .skipgripc mov byte[NumGRiPs],al .skipgripc .none ret .port209 cmp al,2 jne .nojoy2b2 inc byte[JoyQuant209] add byte[JoyBQuant209],2 ret .nojoy2b2 cmp al,3 je .joy4b2 cmp al,4 jne .nojoy4b2 .joy4b2 mov byte[JoyQuant209],1 mov byte[JoyBQuant209],4 ret .nojoy4b2 cmp al,5 jne .nojoy6b2 mov byte[JoyQuant209],2 mov byte[JoyBQuant209],6 mov byte[Buttons6209],1 ret .nojoy6b2 cmp al,18 jne .nojoy8b2 mov byte[JoyQuant209],2 mov byte[JoyBQuant209],8 mov byte[Buttons6209],2 ret .nojoy8b2 cmp al,9 ja .grip2 sub al,5 cmp byte[NumSWs209],al ja .skipswc2 mov byte[NumSWs209],al .skipswc2 ret .grip2 cmp al,13 ja .none2 sub al,9 cmp byte[NumGRiPs209],al ja .skipgripc2 mov byte[NumGRiPs209],al .skipgripc2 .none2 ret NEWSYM JoyReadControl, db 0 JoyRead209: cmp byte[JoyAltrn],1 jne near .noanalog ; Clear Joystick buttons and movements mov word[pressed+100h],0 ; B7-8 mov word[pressed+106h],0 ; B5-6 mov dword[pressed+14Ch],0 ; Up,Down,Left,Right, pl1 mov dword[pressed+168h],0 ; Up,Down,Left,Right, pl2 ; Process Joystick(s) cmp byte[JoyQuant209],2 jne near .no2joyst mov dx,209h call GetCoords3 ; Set button 5-6 + 2player Control cmp byte[Buttons6209],0 jne near .6button mov eax,[JoyX2] cmp eax,[JoyMinX2209] jae .noleft2 mov byte[pressed+16Ah],1 .noleft2 mov eax,[JoyX2] cmp eax,[JoyMaxX2209] jbe .noright2 mov byte[pressed+16Bh],1 .noright2 mov eax,[JoyY2] cmp eax,[JoyMinY2209] jae .noup2 mov byte[pressed+168h],1 .noup2 mov eax,[JoyY2] cmp eax,[JoyMaxY2209] jbe .nodown2 mov byte[pressed+169h],1 .nodown2 jmp .1pcoord .6button mov eax,[JoyY2] cmp eax,[JoyMinY2209] jae .nob5 mov byte[pressed+106h],1 .nob5 mov eax,[JoyX2] cmp eax,[JoyMinX2209] jae .nob6 mov byte[pressed+107h],1 .nob6 cmp byte[Buttons6209],2 jne .no8b mov eax,[JoyY2] cmp eax,[JoyMaxY2209] jbe .nob7 mov byte[pressed+100h],1 .nob7 mov eax,[JoyX2] cmp eax,[JoyMaxX2209] jbe .nob8 mov byte[pressed+101h],1 .nob8 .no8b jmp .1pcoord .no2joyst ; Set 1 player control cmp byte[JoyQuant209],1 jne near .no1joyst mov dx,209h call GetCoords .1pcoord mov eax,[JoyX] cmp eax,[JoyMinX209] jae .noleft mov byte[pressed+14Eh],1 .noleft mov eax,[JoyX] cmp eax,[JoyMaxX209] jbe .noright mov byte[pressed+14Fh],1 .noright mov eax,[JoyY] cmp eax,[JoyMinY209] jae .noup mov byte[pressed+14Ch],1 .noup mov eax,[JoyY] cmp eax,[JoyMaxY209] jbe .nodown mov byte[pressed+14Dh],1 .nodown .no1joyst .noanalog test byte[JoyAltrn],1 jne near .joynotexist mov dword[pressed+102h],0 ; B1-4 cmp byte[JoyQuant209],0 je .joynotexist ; Set buttons 1-4 mov dx, 0209h xor al,al out dx, al in al, dx not al test al,10h jz .nob1 mov byte[pressed+102h],1 .nob1 test al,20h jz .nob2 mov byte[pressed+103h],1 .nob2 cmp byte[JoyBQuant209],2 je .joynotexist test al,40h jz .nob3 mov byte[pressed+104h],1 .nob3 test al,80h jz .nob4 mov byte[pressed+105h],1 .nob4 .joynotexist ret NEWSYM DOSJoyRead push edx push ebx push ecx inc byte[JoyAltrn] and byte[JoyAltrn],3 cmp byte[JoyAltrn],0 jne near .noanalog ; Clear Joystick buttons and movements mov word[pressed+86h],0 ; B5-6 mov word[pressed+80h],0 ; B7-8 mov dword[pressed+0CCh],0 ; Up,Down,Left,Right, pl1 mov dword[pressed+0E8h],0 ; Up,Down,Left,Right, pl2 ; Process Joystick(s) cmp byte[JoyQuant],2 jne near .no2joyst mov dx,201h call GetCoords3 ; Set button 5-6 + 2player Control cmp byte[Buttons6],0 jne near .6button mov eax,[JoyX2] cmp eax,[JoyMinX2] jae .noleft2 mov byte[pressed+0EAh],1 .noleft2 mov eax,[JoyX2] cmp eax,[JoyMaxX2] jbe .noright2 mov byte[pressed+0EBh],1 .noright2 mov eax,[JoyY2] cmp eax,[JoyMinY2] jae .noup2 mov byte[pressed+0E8h],1 .noup2 mov eax,[JoyY2] cmp eax,[JoyMaxY2] jbe .nodown2 mov byte[pressed+0E9h],1 .nodown2 jmp .1pcoord .6button mov eax,[JoyY2] cmp eax,[JoyMinY2] jae .nob5 mov byte[pressed+086h],1 .nob5 mov eax,[JoyX2] cmp eax,[JoyMinX2] jae .nob6 mov byte[pressed+087h],1 .nob6 cmp byte[Buttons6],2 jne .no8b mov eax,[JoyY2] cmp eax,[JoyMaxY2] jbe .nob7 mov byte[pressed+80h],1 .nob7 mov eax,[JoyX2] cmp eax,[JoyMaxX2] jbe .nob8 mov byte[pressed+81h],1 .nob8 .no8b jmp .1pcoord .no2joyst ; Set 1 player control cmp byte[JoyQuant],1 jne near .no1joyst mov dx,201h call GetCoords .1pcoord mov eax,[JoyX] cmp eax,[JoyMinX] jae .noleft mov byte[pressed+0CEh],1 .noleft mov eax,[JoyX] cmp eax,[JoyMaxX] jbe .noright mov byte[pressed+0CFh],1 .noright mov eax,[JoyY] cmp eax,[JoyMinY] jae .noup mov byte[pressed+0CCh],1 .noup mov eax,[JoyY] cmp eax,[JoyMaxY] jbe .nodown mov byte[pressed+0CDh],1 .nodown .no1joyst .noanalog test byte[JoyAltrn],1 jz .joynotexist mov dword[pressed+82h],0 ; B1-4 cmp byte[JoyQuant],0 je .joynotexist ; Set buttons 1-4 mov dx, 0201h xor al,al out dx, al in al, dx not al test al,10h jz .nob1 mov byte[pressed+82h],1 .nob1 test al,20h jz .nob2 mov byte[pressed+83h],1 .nob2 cmp byte[JoyBQuant],2 je .joynotexist test al,40h jz .nob3 mov byte[pressed+84h],1 .nob3 test al,80h jz .nob4 mov byte[pressed+85h],1 .nob4 .joynotexist ; Process Joystick Buttons cmp byte[JoyQuant209],0 je .no209 call JoyRead209 .no209 test byte[JoyAltrn],1 jz near .noport4 cmp byte[NumSWs],0 je .nosw call SideWinder .nosw cmp byte[NumSWs209],0 je .nosw209 call SideWinder209 .nosw209 test byte[JoyAltrn],2 jz .nogrip209 cmp byte[NumGRiPs],0 je .nogrip call GamePadPro .nogrip cmp byte[NumGRiPs209],0 je .nogrip209 call GamePadPro209 .nogrip209 test byte[PPad],1 jz .noport1 call GetParallelPlayer1 .noport1 test byte[PPad],2 jz .noport2 call GetParallelPlayer2 .noport2 test byte[PPad],4 jz .noport3 call GetParallelPlayer3 .noport3 test byte[PPad],8 jz .noport4 call GetParallelPlayer4 .noport4 test byte[PPad],16 jz .noport5 call GetParallelPlayer5 .noport5 cmp byte[JoyAltrn],0 je .nogpp2209 cmp byte[NumGRiPs],2 jne .nogpp2 call GamePadPro2 .nogpp2 cmp byte[NumGRiPs209],2 jne .nogpp2209 call GamePadPro2209 .nogpp2209 pop ecx pop ebx pop edx ret ;bit 1 - left,2 - right,3 - down,4 - up,5 - r1,6 - l1,7 - red,8 - yellow ; 9 - green,10 - l2,11 - blue,12 - r2,13 - start,14 - select %macro GPProHelp 2 test eax,%1 jz %%nope mov byte[pressed+ebx+%2],1 %%nope %endmacro ;A8=buttons, CA=select/start, F0=movement (inc by 4) GamePadPro: mov al,0 mov dx,201h call read_gpp cmp eax,1 je near .error xor ebx,ebx mov byte[pressed+ebx+0F0h],0 mov byte[pressed+ebx+0F1h],0 mov byte[pressed+ebx+0F2h],0 mov byte[pressed+ebx+0F3h],0 mov byte[pressed+ebx+0A8h],0 mov byte[pressed+ebx+0A9h],0 mov byte[pressed+ebx+0AAh],0 mov byte[pressed+ebx+0ABh],0 mov byte[pressed+ebx+0ACh],0 mov byte[pressed+ebx+0ADh],0 mov byte[pressed+ebx+0AEh],0 mov byte[pressed+ebx+0AFh],0 mov byte[pressed+ebx+0CAh],0 mov byte[pressed+ebx+0CBh],0 GPProHelp 0002h,0F2h ; left GPProHelp 0004h,0F3h ; right GPProHelp 0008h,0F1h ; down GPProHelp 0010h,0F0h ; up GPProHelp 0020h,0AEh ; r1 GPProHelp 0040h,0ACh ; l1 GPProHelp 0080h,0A8h ; red GPProHelp 0100h,0AAh ; yellow GPProHelp 0200h,0ABh ; green GPProHelp 0400h,0ADh ; l2 GPProHelp 0800h,0A9h ; blue GPProHelp 1000h,0AFh ; r2 GPProHelp 2000h,0CBh ; start GPProHelp 4000h,0CAh ; select .error ret GamePadPro2: mov al,1 mov dx,201h call read_gpp cmp eax,1 je near .error mov ebx,4 mov byte[pressed+ebx+0F0h],0 mov byte[pressed+ebx+0F1h],0 mov byte[pressed+ebx+0F2h],0 mov byte[pressed+ebx+0F3h],0 mov ebx,8 mov byte[pressed+ebx+0A8h],0 mov byte[pressed+ebx+0A9h],0 mov byte[pressed+ebx+0AAh],0 mov byte[pressed+ebx+0ABh],0 mov byte[pressed+ebx+0ACh],0 mov byte[pressed+ebx+0ADh],0 mov byte[pressed+ebx+0AEh],0 mov byte[pressed+ebx+0AFh],0 mov byte[pressed+ebx+0CAh],0 mov byte[pressed+ebx+0CBh],0 mov ebx,4 GPProHelp 0002h,0F2h ; left GPProHelp 0004h,0F3h ; right GPProHelp 0008h,0F1h ; down GPProHelp 0010h,0F0h ; up mov ebx,8 GPProHelp 0020h,0AEh ; r1 GPProHelp 0040h,0ACh ; l1 GPProHelp 0080h,0A8h ; red GPProHelp 0100h,0AAh ; yellow GPProHelp 0200h,0ABh ; green GPProHelp 0400h,0ADh ; l2 GPProHelp 0800h,0A9h ; blue GPProHelp 1000h,0AFh ; r2 GPProHelp 2000h,0CBh ; start GPProHelp 4000h,0CAh ; select .error ret NEWSYM SideWinder mov al,[NumSWs] mov [_SWCount],al mov dx,201h call _readSideWinder ;bit 0=error 1=up 2=dn 3=rt 4=lt 5=A 6=B 7=C 8=X 9=Y 10=Z 11=L 12=R 13=St 14=M ;k....L=L, R=R, start=start, M=select, X=y, Y=x, B=a, A=b ;sidewinder=snes .loop mov eax,[_SW1] xor ebx,ebx cmp byte[WhichSW],2 jne .noSW2 mov eax,[_SW2] mov ebx,08h .noSW2 cmp byte[WhichSW],3 jne .noSW3 mov eax,[_SW3] mov ebx,10h .noSW3 cmp byte[WhichSW],4 jne .noSW4 mov eax,[_SW4] mov ebx,18h .noSW4 inc byte[WhichSW] mov byte[pressed+ebx+0D4h],0 mov byte[pressed+ebx+0D5h],0 mov byte[pressed+ebx+0D6h],0 mov byte[pressed+ebx+0D7h],0 mov byte[pressed+ebx+088h],0 mov byte[pressed+ebx+089h],0 mov byte[pressed+ebx+08Ah],0 mov byte[pressed+ebx+08Bh],0 mov byte[pressed+ebx+08Ch],0 mov byte[pressed+ebx+08Dh],0 mov byte[pressed+ebx+08Eh],0 mov byte[pressed+ebx+08Fh],0 mov byte[pressed+ebx+0C8h],0 mov byte[pressed+ebx+0C9h],0 test ax,02h ; up jz .noup mov byte[pressed+ebx+0D4h],1 .noup test ax,04h ; down jz .nodown mov byte[pressed+ebx+0D5h],1 .nodown test ax,08h ; right jz .noright mov byte[pressed+ebx+0D7h],1 .noright test ax,10h ; left jz .noleft mov byte[pressed+ebx+0D6h],1 .noleft test ax,20h ; A jz .noa mov byte[pressed+ebx+088h],1 .noa test ax,40h ; B jz .nob mov byte[pressed+ebx+089h],1 .nob test ax,80h ; C jz .noc mov byte[pressed+ebx+08Ah],1 .noc test ax,100h ; X jz .nox mov byte[pressed+ebx+08Bh],1 .nox test ax,200h ; Y jz .noy mov byte[pressed+ebx+08Ch],1 .noy test ax,400h ; Z jz .noz mov byte[pressed+ebx+08Dh],1 .noz test ax,800h ; L jz .nol mov byte[pressed+ebx+08Eh],1 .nol test ax,1000h ; R jz .nor mov byte[pressed+ebx+08Fh],1 .nor test ax,2000h ; start jz .nostart mov byte[pressed+ebx+0C8h],1 .nostart test ax,4000h ; M jz .noselect mov byte[pressed+ebx+0C9h],1 .noselect mov al,[WhichSW] cmp al,[NumSWs] jbe near .loop ret ;return to calling procedure ;A8=buttons, CA=select/start, F0=movement (inc by 4) GamePadPro209: mov al,0 mov dx,209h call read_gpp cmp eax,1 je near .error xor ebx,ebx mov byte[pressed+ebx+170h],0 mov byte[pressed+ebx+171h],0 mov byte[pressed+ebx+172h],0 mov byte[pressed+ebx+173h],0 mov byte[pressed+ebx+128h],0 mov byte[pressed+ebx+129h],0 mov byte[pressed+ebx+12Ah],0 mov byte[pressed+ebx+12Bh],0 mov byte[pressed+ebx+12Ch],0 mov byte[pressed+ebx+12Dh],0 mov byte[pressed+ebx+12Eh],0 mov byte[pressed+ebx+12Fh],0 mov byte[pressed+ebx+14Ah],0 mov byte[pressed+ebx+14Bh],0 GPProHelp 0002h,1F2h ; left GPProHelp 0004h,1F3h ; right GPProHelp 0008h,1F1h ; down GPProHelp 0010h,1F0h ; up GPProHelp 0020h,1AEh ; r1 GPProHelp 0040h,1ACh ; l1 GPProHelp 0080h,1A8h ; red GPProHelp 0100h,1AAh ; yellow GPProHelp 0200h,1ABh ; green GPProHelp 0400h,1ADh ; l2 GPProHelp 0800h,1A9h ; blue GPProHelp 1000h,1AFh ; r2 GPProHelp 2000h,1CBh ; start GPProHelp 4000h,1CAh ; select .error ret GamePadPro2209: mov al,1 mov dx,209h call read_gpp cmp eax,1 je near .error mov ebx,4 mov byte[pressed+ebx+170h],0 mov byte[pressed+ebx+171h],0 mov byte[pressed+ebx+172h],0 mov byte[pressed+ebx+173h],0 mov ebx,8 mov byte[pressed+ebx+128h],0 mov byte[pressed+ebx+129h],0 mov byte[pressed+ebx+12Ah],0 mov byte[pressed+ebx+12Bh],0 mov byte[pressed+ebx+12Ch],0 mov byte[pressed+ebx+12Dh],0 mov byte[pressed+ebx+12Eh],0 mov byte[pressed+ebx+12Fh],0 mov byte[pressed+ebx+14Ah],0 mov byte[pressed+ebx+14Bh],0 mov ebx,4 GPProHelp 0002h,1F2h ; left GPProHelp 0004h,1F3h ; right GPProHelp 0008h,1F1h ; down GPProHelp 0010h,1F0h ; up mov ebx,8 GPProHelp 0020h,1AEh ; r1 GPProHelp 0040h,1ACh ; l1 GPProHelp 0080h,1A8h ; red GPProHelp 0100h,1AAh ; yellow GPProHelp 0200h,1ABh ; green GPProHelp 0400h,1ADh ; l2 GPProHelp 0800h,1A9h ; blue GPProHelp 1000h,1AFh ; r2 GPProHelp 2000h,1CBh ; start GPProHelp 4000h,1CAh ; select .error ret NEWSYM SideWinder209 mov al,[NumSWs209] mov [_SWCount],al mov dx,209h call _readSideWinder ;bit 0=error 1=up 2=dn 3=rt 4=lt 5=A 6=B 7=C 8=X 9=Y 10=Z 11=L 12=R 13=St 14=M ;k....L=L, R=R, start=start, M=select, X=y, Y=x, B=a, A=b ;sidewinder=snes .loop mov eax,[_SW1] xor ebx,ebx cmp byte[WhichSW],2 jne .noSW2 mov eax,[_SW2] mov ebx,08h .noSW2 cmp byte[WhichSW],3 jne .noSW3 mov eax,[_SW3] mov ebx,10h .noSW3 cmp byte[WhichSW],4 jne .noSW4 mov eax,[_SW4] mov ebx,18h .noSW4 inc byte[WhichSW] mov byte[pressed+ebx+154h],0 mov byte[pressed+ebx+155h],0 mov byte[pressed+ebx+156h],0 mov byte[pressed+ebx+157h],0 mov byte[pressed+ebx+108h],0 mov byte[pressed+ebx+109h],0 mov byte[pressed+ebx+10Ah],0 mov byte[pressed+ebx+10Bh],0 mov byte[pressed+ebx+10Ch],0 mov byte[pressed+ebx+10Dh],0 mov byte[pressed+ebx+10Eh],0 mov byte[pressed+ebx+10Fh],0 mov byte[pressed+ebx+148h],0 mov byte[pressed+ebx+149h],0 test ax,02h ; up jz .noup mov byte[pressed+ebx+154h],1 .noup test ax,04h ; down jz .nodown mov byte[pressed+ebx+155h],1 .nodown test ax,08h ; right jz .noright mov byte[pressed+ebx+157h],1 .noright test ax,10h ; left jz .noleft mov byte[pressed+ebx+156h],1 .noleft test ax,20h ; A jz .noa mov byte[pressed+ebx+108h],1 .noa test ax,40h ; B jz .nob mov byte[pressed+ebx+109h],1 .nob test ax,80h ; C jz .noc mov byte[pressed+ebx+10Ah],1 .noc test ax,100h ; X jz .nox mov byte[pressed+ebx+10Bh],1 .nox test ax,200h ; Y jz .noy mov byte[pressed+ebx+10Ch],1 .noy test ax,400h ; Z jz .noz mov byte[pressed+ebx+10Dh],1 .noz test ax,800h ; L jz .nol mov byte[pressed+ebx+10Eh],1 .nol test ax,1000h ; R jz .nor mov byte[pressed+ebx+10Fh],1 .nor test ax,2000h ; start jz .nostart mov byte[pressed+ebx+148h],1 .nostart test ax,4000h ; M jz .noselect mov byte[pressed+ebx+149h],1 .noselect mov al,[WhichSW] cmp al,[NumSWs209] jbe near .loop ret ;return to calling procedure ; Parallel SNES pad reader routines by Karl Stenerud ; Original design by Benji York: ; %macro PPortHelp 3 mov al, %1 out dx, al mov al, 0F8h out dx, al inc dx in al, dx dec dx and ax, %2 jnz %%nobutton mov byte[pressed+%3], 1 %%nobutton %endmacro %macro PPortHelpInv 3 ;needed for the pad 5 mov al, %1 out dx, al mov al, 0F8h out dx, al inc dx in al, dx dec dx and ax, %2 jz %%nobutton ;pad 5 is on pin 11, which is hardware inverted... mov byte[pressed+%3], 1 %%nobutton %endmacro NEWSYM GetParallelPlayer1 mov dx, 0378h mov byte[pressed+180h],0 mov byte[pressed+181h],0 mov byte[pressed+182h],0 mov byte[pressed+183h],0 mov byte[pressed+184h],0 mov byte[pressed+185h],0 mov byte[pressed+186h],0 mov byte[pressed+187h],0 mov byte[pressed+188h],0 mov byte[pressed+189h],0 mov byte[pressed+18Ah],0 mov byte[pressed+18Bh],0 PPortHelp 0FAh, 40h, 180h ;Mask 40h (pin 10 of lpt : data for pad 1) PPortHelp 0F9h, 40h, 181h PPortHelp 0F9h, 40h, 182h PPortHelp 0F9h, 40h, 183h PPortHelp 0F9h, 40h, 184h PPortHelp 0F9h, 40h, 185h PPortHelp 0F9h, 40h, 186h PPortHelp 0F9h, 40h, 187h PPortHelp 0F9h, 40h, 188h PPortHelp 0F9h, 40h, 189h PPortHelp 0F9h, 40h, 18Ah PPortHelp 0F9h, 40h, 18Bh ret NEWSYM GetParallelPlayer2 mov dx, 0378h mov byte[pressed+190h],0 mov byte[pressed+191h],0 mov byte[pressed+192h],0 mov byte[pressed+193h],0 mov byte[pressed+194h],0 mov byte[pressed+195h],0 mov byte[pressed+196h],0 mov byte[pressed+197h],0 mov byte[pressed+198h],0 mov byte[pressed+199h],0 mov byte[pressed+19Ah],0 mov byte[pressed+19Bh],0 PPortHelp 0FAh, 20h, 190h ;Mask 20h (pin 12 of lpt : data for pad 2) PPortHelp 0F9h, 20h, 191h PPortHelp 0F9h, 20h, 192h PPortHelp 0F9h, 20h, 193h PPortHelp 0F9h, 20h, 194h PPortHelp 0F9h, 20h, 195h PPortHelp 0F9h, 20h, 196h PPortHelp 0F9h, 20h, 197h PPortHelp 0F9h, 20h, 198h PPortHelp 0F9h, 20h, 199h PPortHelp 0F9h, 20h, 19Ah PPortHelp 0F9h, 20h, 19Bh ret NEWSYM GetParallelPlayer3 mov dx, 0378h mov byte[pressed+1A0h],0 mov byte[pressed+1A1h],0 mov byte[pressed+1A2h],0 mov byte[pressed+1A3h],0 mov byte[pressed+1A4h],0 mov byte[pressed+1A5h],0 mov byte[pressed+1A6h],0 mov byte[pressed+1A7h],0 mov byte[pressed+1A8h],0 mov byte[pressed+1A9h],0 mov byte[pressed+1AAh],0 mov byte[pressed+1ABh],0 PPortHelp 0FAh, 10h, 1A0h ;Mask 10h (pin 13 of lpt : data for pad 3) PPortHelp 0F9h, 10h, 1A1h PPortHelp 0F9h, 10h, 1A2h PPortHelp 0F9h, 10h, 1A3h PPortHelp 0F9h, 10h, 1A4h PPortHelp 0F9h, 10h, 1A5h PPortHelp 0F9h, 10h, 1A6h PPortHelp 0F9h, 10h, 1A7h PPortHelp 0F9h, 10h, 1A8h PPortHelp 0F9h, 10h, 1A9h PPortHelp 0F9h, 10h, 1AAh PPortHelp 0F9h, 10h, 1ABh ret NEWSYM GetParallelPlayer4 mov dx, 0378h mov byte[pressed+1B0h],0 mov byte[pressed+1B1h],0 mov byte[pressed+1B2h],0 mov byte[pressed+1B3h],0 mov byte[pressed+1B4h],0 mov byte[pressed+1B5h],0 mov byte[pressed+1B6h],0 mov byte[pressed+1B7h],0 mov byte[pressed+1B8h],0 mov byte[pressed+1B9h],0 mov byte[pressed+1BAh],0 mov byte[pressed+1BBh],0 PPortHelp 0FAh, 08h, 1B0h PPortHelp 0F9h, 08h, 1B1h ;Mask 08h (pin 15 of lpt : data for pad 4) PPortHelp 0F9h, 08h, 1B2h PPortHelp 0F9h, 08h, 1B3h PPortHelp 0F9h, 08h, 1B4h PPortHelp 0F9h, 08h, 1B5h PPortHelp 0F9h, 08h, 1B6h PPortHelp 0F9h, 08h, 1B7h PPortHelp 0F9h, 08h, 1B8h PPortHelp 0F9h, 08h, 1B9h PPortHelp 0F9h, 08h, 1BAh PPortHelp 0F9h, 08h, 1BBh ret NEWSYM GetParallelPlayer5 mov dx, 0378h mov byte[pressed+1c0h],0 mov byte[pressed+1c1h],0 mov byte[pressed+1c2h],0 mov byte[pressed+1c3h],0 mov byte[pressed+1c4h],0 mov byte[pressed+1c5h],0 mov byte[pressed+1c6h],0 mov byte[pressed+1c7h],0 mov byte[pressed+1c8h],0 mov byte[pressed+1c9h],0 mov byte[pressed+1cAh],0 mov byte[pressed+1cBh],0 PPortHelpInv 0FAh, 80h, 1c0h PPortHelpInv 0F9h, 80h, 1c1h ;Mask 80h (pin 11 of lpt : data for pad 5) PPortHelpInv 0F9h, 80h, 1c2h PPortHelpInv 0F9h, 80h, 1c3h PPortHelpInv 0F9h, 80h, 1c4h PPortHelpInv 0F9h, 80h, 1c5h PPortHelpInv 0F9h, 80h, 1c6h PPortHelpInv 0F9h, 80h, 1c7h PPortHelpInv 0F9h, 80h, 1c8h PPortHelpInv 0F9h, 80h, 1c9h PPortHelpInv 0F9h, 80h, 1cAh PPortHelpInv 0F9h, 80h, 1cBh ret NEWSYM SetInputDevice209 ; eax = pointer to devices, bl = device #, bh = player # (0-3) ; Sets keys according to input device selected cmp bl,0 jne near .nozero mov dword[eax],0 mov dword[eax+4],0 mov dword[eax+8],0 mov dword[eax+12],0 mov dword[eax+16],0 mov dword[eax+20],0 mov dword[eax+24],0 mov dword[eax+28],0 mov dword[eax+32],0 mov dword[eax+36],0 mov dword[eax+40],0 mov dword[eax+44],0 ret .nozero cmp bl,1 jne near .nokeyb cmp bh,1 ja near .exit cmp bh,1 je near .input2 mov dword[eax],54 mov dword[eax+4],28 mov dword[eax+8],72 mov dword[eax+12],80 mov dword[eax+16],75 mov dword[eax+20],77 mov dword[eax+24],82 mov dword[eax+28],71 mov dword[eax+32],73 mov dword[eax+36],83 mov dword[eax+40],79 mov dword[eax+44],81 ret .input2 mov dword[eax],56 mov dword[eax+4],29 mov dword[eax+8],37 mov dword[eax+12],50 mov dword[eax+16],49 mov dword[eax+20],51 mov dword[eax+24],31 mov dword[eax+28],32 mov dword[eax+32],33 mov dword[eax+36],44 mov dword[eax+40],45 mov dword[eax+44],46 ret .nokeyb cmp bl,2 jne near .no2buttons xor bl,bl cmp byte[pl1contrl],2 jne .nopl2a inc bl .nopl2a cmp byte[pl2contrl],2 jne .nopl2b inc bl .nopl2b cmp byte[pl3contrl],2 jne .nopl2c inc bl .nopl2c cmp byte[pl4contrl],2 jne .nopl2d inc bl .nopl2d cmp byte[pl5contrl],2 jne .nopl2e inc bl .nopl2e cmp bl,2 jae .2ndjoyst mov dword[eax+40],103h mov dword[eax+36],102h mov dword[eax+8],14Ch mov dword[eax+12],14Dh mov dword[eax+16],14Eh mov dword[eax+20],14Fh ret .2ndjoyst mov dword[eax+40],105h mov dword[eax+36],104h mov dword[eax+8],168h mov dword[eax+12],169h mov dword[eax+16],16Ah mov dword[eax+20],16Bh ret .no2buttons cmp bl,3 je .4buttons cmp bl,4 jne near .no4buttons .4buttons mov dword[eax+40],103h mov dword[eax+36],102h mov dword[eax+28],105h mov dword[eax+24],104h mov dword[eax+8],14Ch mov dword[eax+12],14Dh mov dword[eax+16],14Eh mov dword[eax+20],14Fh ret .no4buttons cmp bl,18 je .6buttons cmp bl,5 jne near .no6buttons .6buttons mov dword[eax+40],103h mov dword[eax+36],102h mov dword[eax+28],105h mov dword[eax+24],104h mov dword[eax+32],106h mov dword[eax+44],107h mov dword[eax+8],14Ch mov dword[eax+12],14Dh mov dword[eax+16],14Eh mov dword[eax+20],14Fh cmp bl,5 je .skip8b mov dword[eax+4],100h mov dword[eax],101h mov dword[eax+44],106h mov dword[eax+32],107h .skip8b ret .no6buttons cmp bl,6 jne near .nosw1 mov dword[eax+0],149h mov dword[eax+4],148h mov dword[eax+8],154h mov dword[eax+12],155h mov dword[eax+16],156h mov dword[eax+20],157h mov dword[eax+24],10Ch mov dword[eax+28],109h mov dword[eax+32],10Eh mov dword[eax+36],10Bh mov dword[eax+40],108h mov dword[eax+44],10Fh ret .nosw1 cmp bl,7 jne near .nosw2 mov dword[eax+0],149h+8 mov dword[eax+4],148h+8 mov dword[eax+8],154h+8 mov dword[eax+12],155h+8 mov dword[eax+16],156h+8 mov dword[eax+20],157h+8 mov dword[eax+24],10Ch+8 mov dword[eax+28],109h+8 mov dword[eax+32],10Eh+8 mov dword[eax+36],10Bh+8 mov dword[eax+40],108h+8 mov dword[eax+44],10Fh+8 ret .nosw2 cmp bl,8 jne near .nosw3 mov dword[eax+0],149h+8*2 mov dword[eax+4],148h+8*2 mov dword[eax+8],154h+8*2 mov dword[eax+12],155h+8*2 mov dword[eax+16],156h+8*2 mov dword[eax+20],157h+8*2 mov dword[eax+24],10Ch+8*2 mov dword[eax+28],109h+8*2 mov dword[eax+32],10Eh+8*2 mov dword[eax+36],10Bh+8*2 mov dword[eax+40],108h+8*2 mov dword[eax+44],10Fh+8*2 ret .nosw3 cmp bl,9 jne near .nosw4 mov dword[eax+0],149h+8*3 mov dword[eax+4],148h+8*3 mov dword[eax+8],154h+8*3 mov dword[eax+12],155h+8*3 mov dword[eax+16],156h+8*3 mov dword[eax+20],157h+8*3 mov dword[eax+24],10Ch+8*3 mov dword[eax+28],109h+8*3 mov dword[eax+32],10Eh+8*3 mov dword[eax+36],10Bh+8*3 mov dword[eax+40],108h+8*3 mov dword[eax+44],10Fh+8*3 ret .nosw4 cmp bl,10 jne near .nogrip0 mov dword[eax+0],14Ah mov dword[eax+4],14Bh mov dword[eax+8],170h mov dword[eax+12],171h mov dword[eax+16],172h mov dword[eax+20],173h mov dword[eax+24],129h mov dword[eax+28],12Bh mov dword[eax+32],12Ch mov dword[eax+36],128h mov dword[eax+40],12Ah mov dword[eax+44],12Eh ret .nogrip0 cmp bl,11 jne near .nogrip1 mov dword[eax+0],14Ah+8 mov dword[eax+4],14Bh+8 mov dword[eax+8],170h+4 mov dword[eax+12],171h+4 mov dword[eax+16],172h+4 mov dword[eax+20],173h+4 mov dword[eax+24],129h+8 mov dword[eax+28],12Bh+8 mov dword[eax+32],12Ch+8 mov dword[eax+36],128h+8 mov dword[eax+40],12Ah+8 mov dword[eax+44],12Eh+8 ret .nogrip1 cmp bl,14 jne near .nopp1 mov dword[eax+40],180h mov dword[eax+36],181h mov dword[eax+0],182h mov dword[eax+4],183h mov dword[eax+8],184h mov dword[eax+12],185h mov dword[eax+16],186h mov dword[eax+20],187h mov dword[eax+28],188h mov dword[eax+24],189h mov dword[eax+32],18Ah mov dword[eax+44],18Bh ret .nopp1 cmp bl,15 jne near .nopp2 mov dword[eax+40],190h mov dword[eax+36],191h mov dword[eax+0],192h mov dword[eax+4],193h mov dword[eax+8],194h mov dword[eax+12],195h mov dword[eax+16],196h mov dword[eax+20],197h mov dword[eax+28],198h mov dword[eax+24],199h mov dword[eax+32],19Ah mov dword[eax+44],19Bh ret .nopp2 cmp bl,16 jne near .nopp3 mov dword[eax+40],1A0h mov dword[eax+36],1A1h mov dword[eax+0],1A2h mov dword[eax+4],1A3h mov dword[eax+8],1A4h mov dword[eax+12],1A5h mov dword[eax+16],1A6h mov dword[eax+20],1A7h mov dword[eax+28],1A8h mov dword[eax+24],1A9h mov dword[eax+32],1AAh mov dword[eax+44],1ABh ret .nopp3 cmp bl,17 jne near .nopp4 mov dword[eax+40],1B0h mov dword[eax+36],1B1h mov dword[eax+0],1B2h mov dword[eax+4],1B3h mov dword[eax+8],1B4h mov dword[eax+12],1B5h mov dword[eax+16],1B6h mov dword[eax+20],1B7h mov dword[eax+28],1B8h mov dword[eax+24],1B9h mov dword[eax+32],1BAh mov dword[eax+44],1BBh ret .nopp4 cmp bl,19 jne near .nopp5 mov dword[eax+40],1c0h mov dword[eax+36],1c1h mov dword[eax+0],1c2h mov dword[eax+4],1c3h mov dword[eax+8],1c4h mov dword[eax+12],1c5h mov dword[eax+16],1c6h mov dword[eax+20],1c7h mov dword[eax+28],1c8h mov dword[eax+24],1c9h mov dword[eax+32],1cAh mov dword[eax+44],1cBh ret .nopp5 .exit ret NEWSYM JoyAsmEnd zsnes-1.36/src/dos/modemrtn.asm0100644000175000017500000001576707432621315016112 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM ComNum, ComIRQ, BaudRate EXTSYM dssel,FossilUse EXTSYM GUIinit18_2hz,GUIinit36_4hz EXTSYM GUIMenuItem EXTSYM delay NEWSYM DosModemRTNAsmStart NEWSYM UartType, db 0 NEWSYM cantinitmodem, db 1 NEWSYM ModemInited, db 0 ComPort dw 2E8h ; 1=3F8,2=2F8,3=3E8,4=2E8 PortData dw 0,3F8h,2F8h,3E8h,2E8h ComInt db 0 BRateSel dw 000Ch,0008h,0006h,0004h,0003h,0002h,0001h oldhandmodems dw 0 oldhandmodemo dd 0 PICMaskPm db 21h PortNum dw 0 CharStore db 0 NEWSYM ModemGetChar cmp byte[UartType],2 je near FossilGetChar xor dh,dh mov eax,[modemhead] cmp eax,[modemtail] je .nonewchar mov dh,1 mov dl,[modembuffer+eax] inc dword[modemhead] and dword[modemhead],2047 .nonewchar ret FossilGetChar: pushad mov ah,0Ch mov dx,[PortNum] int 14h cmp ax,0FFFFh je .nochar mov ah,02h mov dx,[PortNum] int 14h mov [CharStore],al popad mov dh,1 mov dl,[CharStore] ret .nochar popad xor dh,dh ret NEWSYM ModemCheckRing cmp byte[UartType],2 je near .fossil mov dx,[ComPort] add dx,6 in al,dx shr al,6 and al,01h ret .fossil pushad mov ah,03h mov dx,[PortNum] int 14h test al,40h jnz .ring popad xor al,al ret .ring popad mov al,1 ret NEWSYM ModemCheckDCD cmp byte[UartType],2 je near .fossil mov dx,[ComPort] add dx,6 in al,dx shr al,7 and al,01h ret .fossil pushad mov ah,03h mov dx,[PortNum] int 14h test al,80h jnz .dcd popad xor al,al ret .dcd popad mov al,1 ret NEWSYM ModemSendChar cmp byte[UartType],2 je near FossilSendChar push ecx push edx push ebx mov ecx,1000000 mov bl,al .loop mov dx,[ComPort] add dx,5 in al,dx test al,00100000b jnz .transokay dec ecx jnz .loop xor al,al pop ebx pop edx pop ecx ret .transokay mov al,bl mov dx,[ComPort] ; Send the char through the modem out dx,al pop ebx pop edx pop ecx ret FossilSendChar: pushad mov ah,01h mov dx,[PortNum] int 14h popad ret NEWSYM InitModem mov byte[ModemInited],1 cmp byte[FossilUse],0 jne near InitFossil mov byte[cantinitmodem],0 cli ; Get Port value xor eax,eax mov al,[ComNum] mov ax,[PortData+eax*2] mov [ComPort],ax mov dx,[ComPort] add dx,2 xor al,al out dx,al ; Set IRQ PIC Mask Port mov byte[PICMaskPm],21h mov bl,[ComIRQ] cmp bl,7 jbe .noupper add bl,60h add byte[PICMaskPm],80h .noupper add bl,8 mov [ComInt],bl ; Get IRQ handler mov ax,204h mov bl,[ComInt] int 31h mov [oldhandmodems],cx mov [oldhandmodemo],edx ; Set IRQ handler mov ax,205h mov bl,[ComInt] mov cx,cs mov edx,modemhandler int 31h mov dx,[ComPort] add dx,3 mov al,00000011b out dx,al ; Set Normal Modem functioning, User2 bit, and DTR mov dx,[ComPort] add dx,4 mov al,00001011b out dx,al ; Enable IRQ xor dh,dh mov dl,[PICMaskPm] ; Output to IRQ PIC Mask Port mov cl,[ComIRQ] ; Get proper bit and cl,07h mov al,01h shl al,cl not al ; Complement since clear bit = enable mov bl,al in al,dx ; input to preserve other bits and al,bl xor al,al out dx,al ; Enable interrupt to execute only on data available mov dx,[ComPort] inc dx mov al,00000001b out dx,al sti ; Write baudrate mov dx,[ComPort] add dx,3 in al,dx or al,10000000b out dx,al mov eax,[BaudRate] mov ax,[BRateSel+eax*2] mov dx,[ComPort] inc dx push eax mov al,ah out dx,al pop eax dec dx out dx,al mov dx,[ComPort] add dx,3 in al,dx and al,01111111b out dx,al ; Initialize 16550A UART chip mov dx,[ComPort] add dx,2 mov al,0C7h out dx,al nop nop in al,dx mov byte[UartType],1 test al,40h jnz .passed16550a xor al,al out dx,al mov byte[UartType],0 .passed16550a ret InitFossil: xor edx,edx mov dl,[ComNum] dec dl mov [PortNum],dx mov byte[cantinitmodem],0 mov byte[UartType],2 mov ah,04h mov dx,[PortNum] int 14h cmp ax,1954h jne .notsuccess xor ah,ah mov al,00000011b ; 19200 baud, 81N mov dx,[PortNum] int 14h ret .notsuccess mov byte[cantinitmodem],1 ret modemhandler: push ds push eax mov ax,[cs:dssel] mov ds,ax push edx mov dx,[ComPort] add dx,4 in al,dx and al,11111101b out dx,al .next mov dx,[ComPort] in al,dx mov edx,[modemtail] mov [modembuffer+edx],al inc dword[modemtail] and dword[modemtail],2047 mov dx,[ComPort] add dx,2 in al,dx test al,1 jz .next mov al,20h out 20h,al cmp byte[ComIRQ],7 jbe .nohighirq mov al,20h out 0A0h,al .nohighirq mov dx,[ComPort] add dx,4 in al,dx or al,00000010b out dx,al pop edx pop eax pop ds iretd NEWSYM ModemClearBuffer mov dword[modemhead],0 mov dword[modemtail],0 ret NEWSYM modembuffer, times 2048 db 0 NEWSYM modemhead, dd 0 NEWSYM modemtail, dd 0 NEWSYM DeInitModem cmp byte[ModemInited],1 je .okaydeinit ret .okaydeinit mov byte[ModemInited],0 cmp byte[UartType],2 je near DeInitFossil cli mov dx,[ComPort] add dx,2 xor al,al out dx,al xor dh,dh mov dl,[PICMaskPm] mov cl,[ComIRQ] and cl,07h mov al,01h shl al,cl mov bl,al in al,dx or al,bl xor al,al out dx,al mov dx,[ComPort] inc dx mov al,00h out dx,al mov dx,[ComPort] add dx,4 out dx,al mov cx,[oldhandmodems] mov edx,[oldhandmodemo] mov ax,205h mov bl,[ComInt] int 31h sti ret DeInitFossil: mov byte[cantinitmodem],0 jne .nodeinit mov ax,0600h mov dx,[PortNum] int 14h ; Lower DTR mov ah,05h mov dx,[PortNum] int 14h .nodeinit ret NEWSYM DeInitModemC cmp byte[ModemInited],1 je .okaydeinit ret .okaydeinit cmp byte[UartType],2 je near DeInitFossil cli mov al,00h mov dx,[ComPort] add dx,4 out dx,al mov al,13 mov dx,[ComPort] out dx,al mov ecx,16384 call delay out dx,al mov al,00001001b mov dx,[ComPort] add dx,4 out dx,al sti ret NEWSYM DosModemRTNAsmEnd zsnes-1.36/src/dos/sw.asm0100644000175000017500000000674607267141100014706 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM SidewinderFix NEWSYM SWAsmStart %macro ParityCheckSW 1 mov ecx,ebx xor cl,ch jpe %%ParChkSW mov [%1],ebx %%ParChkSW: %endmacro section .data gDump times 256 db 0 bDump times 128 db 0 NEWSYM _SW1, dd 0 NEWSYM _SW2, dd 0 NEWSYM _SW3, dd 0 NEWSYM _SW4, dd 0 NEWSYM _SWCount, dd 0 section .text NEWSYM _readSideWinder pushad mov ecx,200 mov ebx,gDump cli cmp byte[SidewinderFix],0 je .write out dx,al .write GetSWDataLoop: cmp byte[SidewinderFix],0 jne .nowrite out dx,al .nowrite nop nop nop nop nop nop in al,dx mov [ebx],al inc ebx dec ecx jnz GetSWDataLoop sti xor ebx,ebx xor ecx,ecx xor edi,edi mov esi,1 FindCycle: mov al,[gDump+edi] inc edi cmp edi,200 je SMWError test al,00010000b jnz WMFCS1 xor ecx,ecx jmp FindCycle WMFCS1: inc ecx cmp ecx,15 jne FindCycle xor ebp,ebp FindStrobeLow: mov al,[gDump+edi] inc edi cmp edi,200 je SMWError test al,00010000b jnz FindStrobeLow xor ecx,ecx FindStrobeHigh: inc ecx cmp ecx,15 je SWModeCheck mov al,[gDump+edi] inc edi cmp edi,200 je SMWError test al,00010000b jz FindStrobeHigh mov [bDump+ebp],al inc ebp jmp FindStrobeLow SMWDone: popad mov eax,0 ret SMWError: popad mov eax,1 ret SWModeCheck: cmp ebp,5 je near ModeB1 cmp ebp,15 je near ModeA1 cmp ebp,10 je near ModeB2 cmp ebp,30 je near ModeA2 cmp ebp,45 je near ModeA3 cmp ebp,20 je near ModeB4 cmp ebp,60 je near ModeA4 jmp short SMWError ModeA1: cmp dword [_SWCount],3 je near ModeB3 xor ebp,ebp call DoModeA ParityCheckSW _SW1 jmp SMWDone ModeA4: mov ebp,45 call DoModeA ParityCheckSW _SW4 ModeA3: mov ebp,30 call DoModeA ParityCheckSW _SW3 ModeA2: mov ebp,15 call DoModeA ParityCheckSW _SW2 xor ebp,ebp call DoModeA ParityCheckSW _SW1 jmp SMWDone ModeB4: mov ebp,15 call DoModeB ParityCheckSW _SW4 ModeB3: mov ebp,10 call DoModeB ParityCheckSW _SW3 ModeB2: mov ebp,5 call DoModeB ParityCheckSW _SW2 ModeB1: xor ebp,ebp call DoModeB ParityCheckSW _SW1 jmp SMWDone DoModeB: xor ebx,ebx mov eax,2 mov ecx,5 add ebp,bDump ModeBLoop: test byte [ebp],00100000b jnz $+4 or ebx,eax shl eax,1 test byte [ebp],01000000b jnz $+4 or ebx,eax shl eax,1 test byte [ebp],10000000b jnz $+4 or ebx,eax shl eax,1 inc ebp dec ecx jnz ModeBLoop ret DoModeA: xor ebx,ebx mov eax,2 mov ecx,15 add ebp,bDump ModeALoop: test byte [ebp],00100000b jnz $+4 or ebx,eax shl eax,1 inc ebp dec ecx jnz ModeALoop ret NEWSYM SWAsmEnd zsnes-1.36/src/dos/sw32.asm0100644000175000017500000002332207267141100015040 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;32-bit DOS-Mode driver for the Microsoft Sidewinder Gamepad ;Multi-SW Version 1.5 ;(C) 1997, 1998 Robert William Grubbs, All Rights Reserved ;Latest revision 1/20/98 ; Driver Source code Include file ;C-linkable, rewrote decoder -sardu ;Flat memory mode (Protected mode extender required! Tested with DOS32) ;Tested with TASM 4.0+ SW1 dd 0 ;SW #1's button status SW2 dd 0 ;SW #2's button status SW3 dd 0 ;SW #3's button status SW4 dd 0 ;SW #4's button status SWCount dd 1 ;Tell the driver how many sidewinders are present SWSetup dd 0 ;Tell the driver what polling mode to use ; 0=Interrupts disabled, Multiple OUT statements ; 1=Interrupts disabled, Single OUT statement ; 2=Interrupts enabled, Multiple OUT statements ; 3=Interrupts enabled, Single OUT statement gDump times 100h db 0 ;SW Status dump buffer (space for 256 bytes, uses 200) bDump times 80h db 0 ;buffer to hold button data (Modes A and B, all SW) ;This macro calculates parity for the buttons and compares it to the SW's ; parity bit. If they don't match, the button data is discarded. %macro ParityCheckSW 1 mov ecx,ebx ;duplicate button status xor cl,ch ; jpe %%ParChkSW mov [%1],ebx ;update button status for SW #n %%ParChkSW ;done %endmacro ;The main subroutine; this is the important one; bow down before it ;IN: None ;Out: SWx=buttons (bit 0=null 1=up 2=dn 3=rt 4=lt 5=A 6=B 7=C 8=X) ; (9=Y 10=Z 11=L 12=R 13=St 14=M 15=Parity) ;No registers destroyed readSideWinder: pushad mov ecx,200 ;dump buffer fill size mov ebx,gDump ;initial dump pointer mov edx,0201h ;joystick port cmp dword[SWSetup],0 jne NotSW0 cli ;Disable interrupts (required to avoid jitter) GetSWDataLoop: ; out dx,al ;trigger joystick port in al,dx ;read SW status byte mov [ebx],al ;dump status byte inc ebx ;increment dump pointer dec ecx jnz GetSWDataLoop sti ;Re-enable interrupts jmp SWPollDone NotSW0: cmp dword[SWSetup],1 jne NotSW1 cli ;Disable interrupts (required to avoid jitter) out dx,al ;trigger joystick port GetSWDataLoop1: ; in al,dx ;read SW status byte mov [ebx],al ;dump status byte inc ebx ;increment dump pointer dec ecx jnz GetSWDataLoop1 sti ;Re-enable interrupts jmp SWPollDone NotSW1: cmp dword[SWSetup],2 jne NotSW2 GetSWDataLoop2: ; out dx,al ;trigger joystick port in al,dx ;read SW status byte mov [ebx],al ;dump status byte inc ebx ;increment dump pointer dec ecx jnz GetSWDataLoop2 jmp SWPollDone NotSW2: ;default all others to SWStatus=3 out dx,al ;trigger joystick port GetSWDataLoop3: ; in al,dx ;read SW status byte mov [ebx],al ;dump status byte inc ebx ;increment dump pointer dec ecx jnz GetSWDataLoop3 SWPollDone: mov ecx,0 ;tick count mov esi,1 ;initialize output mask mov ebx,0 ;initialize output mov edi,0 ;initialize input pointer ;My current method of cycle detection is to look for 15 highs in a row on ; the strobe line. Cycle ends is detected by 15 lows in a row. ;Mode A has 15 strobes in a cycle, Mode B has 5. ; Note that the 15 highs/lows for cycle detection may be too high for slow ; machines. I havn't seen a problem yet, but it may exist... ;Multiple Sidewinder data complicates things. Each additional SW tags ; another set of strobes to the cycle, 5 more in mode B, 15 more in mode A. ; Detecting extra SW gamepad data is fairly simple: count the number of ; strobes. If it is a multiple of 5, you're in mode B and can divide by 5 ; to get the total number of gamepads. If it's divisible by 15, use mode A. ; However, this method cannot distinguish between mode A for one SW and mode ; B for three SW. In that case, the SWCount variable must be set correctly. FindCycle: mov al,[gDump+edi] ;get next status byte inc edi ;increment input pointer cmp edi,200 ;test for end of status block je SWNoFind ;if it's the end, quit sub with error test al,00010000b ;Check for nonzero bits jnz WMFCS1 ; xor ecx,ecx ;if zero, reset tick count jmp FindCycle ;can't be pre-cycle WMFCS1: ;Possibly pre-cycle inc ecx ;increment tick count cmp ecx,15 ;test for sufficient ticks for cycle start jne FindCycle ;if insufficient, get next status byte ;Yippie! it found a (probable) cycle! mov ebp,0 ;initialize bDump index (strobe count) FindStrobeLow: ;Search for leading edge of data strobe mov al,[gDump+edi] ;get next status byte inc edi ;increment input pointer cmp edi,200 ;test for end of status block je SWNoFind ;if it's the end, quit sub with error test al,00010000b ;get "strobe" bit jnz SHORT FindStrobeLow ;if it isn't zero, we're not there yet xor ecx,ecx ;initialize cycle end test count FindStrobeHigh: inc ecx ;increment zero count cmp ecx,0fh ;is it 15? je SWModeCheck ;if so, goto mode check mov al,[gDump+edi] ;get next status byte inc edi ;increment input pointer cmp edi,200 ;test for end of status block je SWNoFind ;if it's the end, quit sub with error test al,00010000b ;get "strobe" bit jz FindStrobeHigh ;if it is zero, we're not there yet ;if not, we're there! data bit is valid (probably) mov [bDump+ebp],al ;preserve data for button decoding inc ebp ;increment strobe count/bDump index jmp FindStrobeLow ;wait for the next button SMWDone: SWNoFind: popad ret ;return to calling procedure SWModeCheck: ;Check strobe count to identify mode and # of SW cmp ebp,15 ;Is it Mode A with 1 Sidewinder or B with 3? je ModeA1 cmp ebp,5 ;Is it Mode B with 1 Sidewinders? je ModeB1 cmp ebp,30 ;Is it Mode A with 2 Sidewinders? je ModeA2 cmp ebp,10 ;Is it Mode B with 2 Sidewinders? je near ModeB2 cmp ebp,45 ;Is it Mode A with 3 Sidewinders? je near ModeA3 cmp ebp,60 ;Is it Mode A with 4 Sidewinders? je near ModeA4 cmp ebp,20 ;Is it Mode B with 4 Sidewinders? je near ModeB4 jmp SHORT SWNoFind ;Any other # of strobes is invalid data ModeB1: xor ebp,ebp call DoModeB ParityCheckSW SW1 jmp SMWDone ModeA1: cmp dword [SWCount],3 je near ModeB3 xor ebp,ebp call DoModeA ParityCheckSW SW1 jmp SMWDone ModeA2: xor ebp,ebp call DoModeA ParityCheckSW SW1 mov ebp,15 call DoModeA ParityCheckSW SW2 jmp SMWDone ModeA3: xor ebp,ebp call DoModeA ParityCheckSW SW1 mov ebp,15 call DoModeA ParityCheckSW SW2 mov ebp,30 call DoModeA ParityCheckSW SW3 jmp SMWDone ModeA4: xor ebp,ebp call DoModeA ParityCheckSW SW1 mov ebp,15 call DoModeA ParityCheckSW SW2 mov ebp,30 call DoModeA ParityCheckSW SW3 mov ebp,45 call DoModeA ParityCheckSW SW4 jmp SMWDone ModeB2: xor ebp,ebp call DoModeB ParityCheckSW SW1 mov ebp,5 call DoModeB ParityCheckSW SW2 jmp SMWDone ModeB3: xor ebp,ebp call DoModeB ParityCheckSW SW1 mov ebp,5 call DoModeB ParityCheckSW SW2 mov ebp,10 call DoModeB ParityCheckSW SW3 jmp SMWDone ModeB4: xor ebp,ebp call DoModeB ParityCheckSW SW1 mov ebp,5 call DoModeB ParityCheckSW SW2 mov ebp,10 call DoModeB ParityCheckSW SW3 mov ebp,15 call DoModeB ParityCheckSW SW4 jmp SMWDone ENDP %macro SWRepeat 1 mov al,[bDump+ebp+%1] shr al,5 ;get upper 3 bits shl eax,1+3*%1 ;shift into place or ebx,eax ;or into output %endmacro DoModeB: xor ebx,ebx ;Initialize output xor eax,eax SWRepeat 0 SWRepeat 1 SWRepeat 2 SWRepeat 3 SWRepeat 4 xor ebx,0FFFEh ret DoModeA: xor ebx,ebx ;Clear output mov ecx,15 ;bit count ALP: mov al,[bDump+ebp] inc ebp shl al,3 rcr ebx,1 dec ecx jg ALP shr ebx,16 xor ebx,0FFFEh ret zsnes-1.36/src/dos/vesa12.asm0100644000175000017500000003253107432621316015353 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM vesa2_usbit,vesa2_clbit,vesa2_clbitng,vesa2_clbitng2,vesa2_clbitng3 EXTSYM vesa2_x,vesa2_y,vesa2selec,vesa2_bits,vesa2_rpos,vesa2_gpos,vesa2_bpos EXTSYM vesa2_rposng,vesa2_gposng,vesa2_bposng,vesa2_rtrcl,vesa2_rtrcla,vesa2_rfull EXTSYM vesa2_gtrcl,vesa2_gtrcla,vesa2_gfull,vesa2_btrcl,vesa2_btrcla,vesa2_bfull EXTSYM vesa2red10,dcolortab,videotroub,Change_Dir EXTSYM genfulladdtab,genfulladdtabng,DosExit EXTSYM InitDrive,gotoroot,InitDir,fulladdtab ; EXTSYM printnum,DosExit EXTSYM LFBpointer,noblocks,bytesperscanline,vesamode,VESAmodelist NEWSYM Vesa12AsmStart ; add 0214h video mode ;NEWSYM granularity, dw 0 ;NEWSYM granadd, dd 0 SECTION .bss NEWSYM granularity, resw 1 NEWSYM granadd, resd 1 SECTION .text NEWSYM VESA12EXITTODOS mov ax,0003h int 10h push edx mov edx,.exitfromvesa12 mov ah,9 int 21h pop edx mov ah,9 int 21h mov edx,.return mov ah,9 int 21h mov dl,[InitDrive] mov ebx,InitDir call Change_Dir mov byte[videotroub],1 jmp DosExit .exitfromvesa12 db 'Unable to Initialize VESA1.2 $' .return db 10,13,'$' ;******************************************************* ; Set up Vesa 2 ;******************************************************* NEWSYM InitVesa12 ;-------------------------------------------------; ; First - allocate some bytes in DOS memory for ; ; communication with VBE ; ;-------------------------------------------------; mov eax,0100h mov ebx,512/16 ; 512 bytes int 31h ; Function 31h,100h - Allocate ; DOS memory (512 bytes) jnc .gotmem mov edx,.nomemmessage jmp VESA12EXITTODOS .nomemmessage db ': Unable to locate DOS memory.$' .gotmem mov fs,dx ; FS now points to the DOS ; buffer ;--------------------------------------------------; ; Now, get information about the video card into ; ; a data structure ; ;--------------------------------------------------; mov edi,RMREGS mov dword[fs:0],'VBE1' ; Request VBE 2.0 info mov dword[RMREGS.eax],4f00h mov word[RMREGS.es],ax ; Real mode segment of DOS ; buffer mov dword[RMREGS.edi],0 push es push ds pop es mov eax,300h mov ebx,10h xor ecx,ecx int 31h ; Simulate real mode interrupt pop es jnc .int1ok mov edx,.noint1message jmp VESA12EXITTODOS .noint1message db ': Simulated real mode interrupt failed.$' .int1ok ; Real mode int successful!!! mov eax,[RMREGS.eax] cmp al,4fh ; Check vbe interrupt went OK jz .vbedetected mov edx,.novbemessage jmp VESA12EXITTODOS .novbemessage db ': VBE not detected!!$' .vbedetected cmp dword[fs:0000],'VESA' jz .vesadetected ; Check for presence of vesa mov edx,.novesamessage jmp VESA12EXITTODOS .novesamessage db ': VESA not detected!$' .vesadetected cmp word[fs:0004],102h jae .vesa12detected ; Check we've got VESA 1.2 or greater mov edx,.novesa2message jmp VESA12EXITTODOS .novesa2message db ': VESA 1.2 or greater required!$' ;-----------------------------------------------------; ; OK - vesa 2.0 or greater has been detected. Copy ; ; mode information into VESAmodelist ; ;-----------------------------------------------------; .vesa12detected mov ax,[fs:12h] ; Get no. of 64k blocks mov [noblocks],ax mov ax, 2 mov bx,[fs:10h] int 31h jnc .wegottheselector mov edx, .oopsnoselector jmp VESA12EXITTODOS .oopsnoselector db ': Failed to allocate vesa display selector!$' .wegottheselector mov gs,ax xor eax,eax mov ebp,VESAmodelist mov ecx,512 mov ax,[fs:0eh] .loopcopymodes mov bx,[gs:eax] mov [ebp],bx cmp bx,0ffffh jz .copiedmodes add ebp,2 add eax,2 dec ecx jz .outofmodelistspace jmp .loopcopymodes .outofmodelistspace mov edx,.outofmodelistspacemessage jmp VESA12EXITTODOS .outofmodelistspacemessage db ': Out of VESA mode list space!$' ;----------------------------------------------; ; OK - Scan the mode list to find a matching ; ; mode for vesa2_x, vesa2_y and vesa2_depth ; ;----------------------------------------------; .copiedmodes mov ebp,VESAmodelist xor ecx,ecx .loopcheckmodes mov cx, [ebp] cmp cx, 0ffffh jnz .notendoflist mov edx,.endoflist jmp VESA12EXITTODOS .endoflist db ': VESA 1.2 mode does not work on your video card/driver.$' .whichwin db 0 .notendoflist mov edi, RMREGS mov dword[RMREGS.eax],4f01h mov dword[RMREGS.ebx],0 mov dword[RMREGS.ecx],ecx mov dword[RMREGS.edi],0 push es push ds pop es mov eax,300h mov ebx,10h xor ecx,ecx int 31h ; Simulate real mode interrupt pop es jnc .modecheckok mov edx,.modecheckfail jmp VESA12EXITTODOS .modecheckfail db ': Real mode interrupt failure while checking vesa mode$' .modecheckok add ebp,2 test word[fs:0000h],1b jz near .loopcheckmodes ; If mode is not available ; ; xor eax,eax ; mov ax,[fs:12h] ; call printnum ; mov ah,02h ; mov dl,'x' ; int 21h ; mov ax,[fs:14h] ; call printnum ; mov ah,02h ; mov dl,'x' ; int 21h ; xor ah,ah ; mov al,[fs:19h] ; call printnum ; mov ah,02h ; mov dl,13 ; int 21h ; mov dl,10 ; int 21h mov eax,[vesa2_x] cmp [fs:12h],ax ; Check that the height matches jnz near .loopcheckmodes mov eax,[vesa2_y] cmp [fs:14h],ax ; Check that the width matches jnz near .loopcheckmodes mov al,[vesa2_bits] cmp [fs:19h],al ; Check bits/pixel for match jnz near .loopcheckmodes ; mov ah,07h ; int 21h ; D0 = Window supported ; 0 = Window is not supported ; 1 = Window is supported ; D1 = Window readable ; 0 = Window is not readable ; 1 = Window is readable ; D2 = Window writeable ; 0 = Window is not writeable ; 1 = Window is writeable ; D3-D7 = Reserved mov byte[.whichwin],0 mov al,[fs:2] ; Get window A attributes and al,0100b cmp al,0100b je .foundwin ; Mode supported mov al,[fs:3] ; Get window B attributes and al,0100b cmp al,0100b jne .foundwin ; Mode not supported mov byte[.whichwin],1 .foundwin ; Success - a match has been found!! sub ebp,2 mov ax,[ebp] mov [vesamode],ax ; Store vesa 1.2 mode number ; and eax,0FFFFh ; push eax ; mov ax,0003h ; int 10h ; pop eax ; call printnum ; jmp DosExit mov ax,[fs:10h] mov byte[vesa2red10],0 mov byte[vesa2_rposng],11 mov byte[vesa2_gposng],6 mov byte[vesa2_bposng],0 mov dword[vesa2_clbitng],1111011111011110b mov dword[vesa2_clbitng2],11110111110111101111011111011110b mov dword[vesa2_clbitng2+4],11110111110111101111011111011110b mov dword[vesa2_clbitng3],0111101111101111b mov [bytesperscanline],ax ; Store bytes per scan line cmp byte[fs:20h],10 jne .nored10 mov byte[fs:20h],11 mov byte[vesa2red10],1 mov byte[vesa2_rposng],10 mov byte[vesa2_gposng],5 mov dword[vesa2_clbitng],0111101111011110b mov dword[vesa2_clbitng2],01111011110111100111101111011110b mov dword[vesa2_clbitng2+4],01111011110111100111101111011110b mov dword[vesa2_clbitng3],0011110111101111b .nored10 ; fix up bit lengths mov al,16 sub al,[fs:20h] mov ah,[fs:22h] sub ah,[fs:20h] mov bl,[fs:24h] sub bl,[fs:20h] mov bh,al cmp bh,ah jb .scheck1 mov bh,ah .scheck1 cmp bh,bl jb .scheck2 mov bh,bl .scheck2 mov byte[fs:19h],5 mov al,16 sub al,[fs:22h] mov ah,[fs:20h] sub ah,[fs:22h] mov bl,[fs:24h] sub bl,[fs:22h] mov bh,al cmp bh,ah jb .scheck1b mov bh,ah .scheck1b cmp bh,bl jb .scheck2b mov bh,bl .scheck2b mov [fs:21h],bh mov al,16 sub al,[fs:24h] mov ah,[fs:20h] sub ah,[fs:24h] mov bl,[fs:22h] sub bl,[fs:24h] mov bh,al cmp bh,ah jb .scheck1c mov bh,ah .scheck1c cmp bh,bl jb .scheck2c mov bh,bl .scheck2c mov [fs:23h],bh mov word[vesa2_clbit],0 cmp byte[fs:20h],10 jne .nottopbit mov word[vesa2_usbit],8000h .nottopbit ; Process Red Stuff mov al,[fs:20h] ; bit sizes = [fs:19h,21h,23h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:19h],6 jne .no6bit mov [vesa2_usbit],bx inc al .no6bit or [vesa2_clbit],bx mov [vesa2_rpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrr shl bx,cl jmp .shlr .shrr shr bx,1 .shlr mov word[vesa2_rfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_rtrcl],bx xor bx,0FFFFh mov word[vesa2_rtrcla],bx ; Process Green Stuff mov al,[fs:22h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:21h],6 jne .no6bitb mov [vesa2_usbit],bx inc al .no6bitb or [vesa2_clbit],bx mov [vesa2_gpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrg shl bx,cl jmp .shlg .shrg shr bx,1 .shlg mov word[vesa2_gfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_gtrcl],bx xor bx,0FFFFh mov word[vesa2_gtrcla],bx ; Process Blue Stuff mov al,[fs:24h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:23h],6 jne .no6bitc mov [vesa2_usbit],bx inc al .no6bitc or [vesa2_clbit],bx mov [vesa2_bpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrb shl bx,cl jmp .shlb .shrb shr bx,1 .shlb mov word[vesa2_bfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_btrcl],bx xor bx,0FFFFh mov word[vesa2_btrcla],bx xor word[vesa2_clbit],0FFFFh mov ax,[fs:4] mov [granularity],ax xor edx,edx mov ax,64 mov bx,[granularity] div bx mov [granadd],ax ;vesa2_rtrcl dw 0 ; red transparency clear (bit+4) ;vesa2_rtrcla dw 0 ; red transparency (AND) clear (not(bit+4)) ;vesa2_rfull dw 0 ; red max (or (bit-1)*1Fh) call genfulladdtab xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov ax,4f02h mov bx,[vesamode] int 10h ; Set the vesa mode cmp ax,004fh jz .modesetok mov edx,.unableset jmp VESA12EXITTODOS ; Failure!!! .unableset db 'Unable to initialize video mode.$' .modesetok ;******************************* EXTRA BIT **************************** ret ; Check logical scanline length mov eax,4f06h mov ebx,1 int 10h cmp cx,[vesa2_x] je .correctwidth mov eax,4f06h ; VBE Set/Get logical scan line ; length mov ebx,0 ; Set scan line length in ; pixels mov ecx, [vesa2_x] ; Desired screen width int 10h cmp ax,04fh jz .correctwidth mov edx, .unablescan jmp VESA12EXITTODOS ; Failure!!! .unablescan db 'Unable to set scan line length.$' .correctwidth ret ;RMREGS ;.edi dd 0 ;.esi dd 0 ;.ebp dd 0 ;.esp dd 0 ;.ebx dd 0 ;.edx dd 0 ;.ecx dd 0 ;.eax dd 0 ;.flags dw 0 ;.es dw 0 ;.ds dw 0 ;.fs dw 0 ;.gs dw 0 ;.ip dw 0 ;.cs dw 0 ;.sp dw 0 ;.ss dw 0 ;.spare times 20 dd 0 SECTION .bss RMREGS .edi resd 1 .esi resd 1 .ebp resd 1 .esp resd 1 .ebx resd 1 .edx resd 1 .ecx resd 1 .eax resd 1 .flags resw 1 .es resw 1 .ds resw 1 .fs resw 1 .gs resw 1 .ip resw 1 .cs resw 1 .sp resw 1 .ss resw 1 .spare times 20 resd 1 NEWSYM Vesa12AsmEnd zsnes-1.36/src/dos/vesa2.asm0100644000175000017500000005034707432621316015277 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM printnum EXTSYM DosExit,ZSNESBase,Change_Dir,PrintStr,newengen EXTSYM HalfTransB,HalfTransC EXTSYM InitDrive,gotoroot,InitDir,fulladdtab ; EXTSYM printhex ; EXTSYM printhex EXTSYM UnusedBit,HalfTrans,UnusedBitXor,ngrposng,nggposng,ngbposng ; EXTSYM printhex EXTSYM Init_2xSaIMMX NEWSYM Vesa2AsmStart SECTION .data ; add 0214h video mode anticrash times 10 db 0 ALIGN32 NEWSYM vesa2_usbit, dd 0 ; Unused bit in proper bit location NEWSYM vesa2_clbit, dd 0 ; clear all bit 0's if AND is used NEWSYM vesa2_clbitng, dd 0 ; clear all bit 0's if AND is used NEWSYM vesa2_clbitng2, dd 0,0 ; clear all bit 0's if AND is used NEWSYM vesa2_clbitng3, dd 0 ; clear all bit 0's if AND is used NEWSYM vesa2_x, dd 320 ; Desired screen width NEWSYM vesa2_y, dd 240 ; Height NEWSYM vesa2selec, dd 0 ; VESA2 Selector Location NEWSYM vesa2_bits, dd 8 ; Bits per pixel NEWSYM vesa2_rpos, dd 0 ; Red bit position NEWSYM vesa2_gpos, dd 0 ; Green bit position NEWSYM vesa2_bpos, dd 0 ; Blue bit position NEWSYM vesa2_rposng, dd 0 ; Red bit position NEWSYM vesa2_gposng, dd 0 ; Green bit position NEWSYM vesa2_bposng, dd 0 ; Blue bit position NEWSYM vesa2_rtrcl, dd 0 ; red transparency clear (bit+4) NEWSYM vesa2_rtrcla, dd 0 ; red transparency (AND) clear (not(bit+4)) NEWSYM vesa2_rfull, dd 0 ; red max (or bit*1Fh) NEWSYM vesa2_gtrcl, dd 0 ; red transparency clear (bit+4) NEWSYM vesa2_gtrcla, dd 0 ; red transparency (AND) clear (not(bit+4)) NEWSYM vesa2_gfull, dd 0 ; red max (or bit*1Fh) NEWSYM vesa2_btrcl, dd 0 ; red transparency clear (bit+4) NEWSYM vesa2_btrcla, dd 0 ; red transparency (AND) clear (not(bit+4)) NEWSYM vesa2_bfull, dd 0 ; red max (or bit*1Fh) NEWSYM vesa2red10, dd 0 ; red position at bit 10 NEWSYM videotroub, dd 0 ; red position at bit 10 NEWSYM vesa3en, dd 0 NEWSYM VESAAddr, dd 0 NEWSYM ExitFromGUI, db 0 NEWSYM ErrorPointer, dd 0 NEWSYM TripBufAvail, db 0 ;NEWSYM dcolortab, times 256 dd 0 SECTION .bss NEWSYM dcolortab, times 256 resd 1 SECTION .text NEWSYM genfulladdtab ; Write to buffer cmp byte[newengen],1 jne .notneweng cmp byte[vesa2red10],0 jne near genfulladdtabred .notneweng xor ecx,ecx .loopers mov ax,cx test [vesa2_rtrcl],cx jz .nor and ax,[vesa2_rtrcla] or ax,[vesa2_rfull] .nor test [vesa2_gtrcl],cx jz .nog and ax,[vesa2_gtrcla] or ax,[vesa2_gfull] .nog test [vesa2_btrcl],cx jz .nob and ax,[vesa2_btrcla] or ax,[vesa2_bfull] .nob shl ax,1 mov [fulladdtab+ecx*2],ax dec cx jnz .loopers ret NEWSYM genfulladdtabred NEWSYM genfulladdtabng ; Write to buffer xor ecx,ecx .loopers mov ax,cx test cx,0100000000000000b jz .nor and ax,1011111111111111b or ax, 0011110000000000b .nor test cx,0000001000000000b jz .nog and ax,1111110111111111b or ax, 0000000111100000b .nog test cx,0000000000010000b jz .nob and ax,1111111111101111b or ax, 0000000000001111b .nob shl ax,1 mov [fulladdtab+ecx*2],ax dec cx jnz .loopers ret NEWSYM VESA2EXITTODOS mov byte[videotroub],1 cmp byte[ExitFromGUI],0 je .nogui mov [ErrorPointer],edx ret .nogui mov ax,0003h int 10h push edx mov edx,.exitfromvesa2 call PrintStr pop edx call PrintStr mov edx,.return call PrintStr mov dl,[InitDrive] mov ebx,InitDir call Change_Dir jmp DosExit .exitfromvesa2 db 'Unable to Initialize VESA2 : ',0 .return db 10,13,0 ;******************************************************* ; Set up Vesa 2 ;******************************************************* NEWSYM InitVesa2 ;-------------------------------------------------; ; First - allocate some bytes in DOS memory for ; ; communication with VBE ; ;-------------------------------------------------; mov eax,0100h mov ebx,512/16 ; 512 bytes int 31h ; Function 31h,100h - Allocate ; DOS memory (512 bytes) jnc .gotmem mov edx,.nomemmessage jmp VESA2EXITTODOS .nomemmessage db 'Unable to locate DOS memory.',0 .gotmem mov fs,dx ; FS now points to the DOS ; buffer ;--------------------------------------------------; ; Now, get information about the video card into ; ; a data structure ; ;--------------------------------------------------; mov edi,RMREGS mov dword[fs:0],'VBE2' ; Request VBE 2.0 info mov dword[RMREGS.eax],4f00h mov word[RMREGS.es],ax ; Real mode segment of DOS ; buffer mov dword[RMREGS.edi],0 push es push ds pop es mov eax,300h mov ebx,10h xor ecx,ecx int 31h ; Simulate real mode interrupt pop es jnc .int1ok mov edx,.noint1message jmp VESA2EXITTODOS .noint1message db 'Simulated real mode interrupt failed.',0 .int1ok ; Real mode int successful!!! mov eax,[RMREGS.eax] cmp al,4fh ; Check vbe interrupt went OK jz .vbedetected mov edx,.novbemessage jmp VESA2EXITTODOS .novbemessage db 'VBE not detected!!',0 .vbedetected cmp dword[fs:0000],'VESA' jz .vesadetected ; Check for presence of vesa mov edx,.novesamessage jmp VESA2EXITTODOS .novesamessage db 'VESA not detected!',0 .vesadetected cmp word[fs:0004],200h jae .vesa2detected ; Check we've got VESA 2.0 or greater mov edx,.novesa2message jmp VESA2EXITTODOS .novesa2message db 'VESA 2.0 or greater required!',0 ;-----------------------------------------------------; ; OK - vesa 2.0 or greater has been detected. Copy ; ; mode information into VESAmodelist ; ;-----------------------------------------------------; .vesa2detected mov dword[vesa3en],0 cmp word[fs:004],300h jb .notvbe3 mov dword[vesa3en],1 .notvbe3 mov ax,[fs:12h] ; Get no. of 64k blocks mov [noblocks],ax mov ax, 2 mov bx,[fs:10h] int 31h jnc .wegottheselector mov edx, .oopsnoselector jmp VESA2EXITTODOS .oopsnoselector db 'Failed to allocate vesa display selector!',0 .wegottheselector mov gs,ax xor eax,eax mov ebp,VESAmodelist mov ecx,512 mov ax,[fs:0eh] .loopcopymodes mov bx,[gs:eax] mov [ebp],bx cmp bx,0ffffh jz .copiedmodes add ebp,2 add eax,2 dec ecx jz .outofmodelistspace jmp .loopcopymodes .outofmodelistspace mov edx,.outofmodelistspacemessage jmp VESA2EXITTODOS .outofmodelistspacemessage db 'Out of VESA2 mode list space!',0 ;----------------------------------------------; ; OK - Scan the mode list to find a matching ; ; mode for vesa2_x, vesa2_y and vesa2_depth ; ;----------------------------------------------; .copiedmodes mov ebp,VESAmodelist xor ecx,ecx .loopcheckmodes mov cx, [ebp] cmp cx, 0ffffh jnz .notendoflist mov edx,.endoflist jmp VESA2EXITTODOS .endoflist db 'This VESA2 mode does not work on your video card / driver.',0 .whichwin db 0 .notendoflist mov edi, RMREGS mov dword[RMREGS.eax],4f01h mov dword[RMREGS.ebx],0 mov dword[RMREGS.ecx],ecx mov dword[RMREGS.edi],0 push es push ds pop es mov eax,300h mov ebx,10h xor ecx,ecx int 31h ; Simulate real mode interrupt pop es jnc .modecheckok mov edx,.modecheckfail jmp VESA2EXITTODOS .modecheckfail db 'Real mode interrupt failure while checking vesa mode',0 .modecheckok add ebp,2 test word[fs:0000h],1b jz near .loopcheckmodes ; If mode is not available ; ; xor eax,eax ; mov ax,[fs:12h] ; call printnum ; mov ah,02h ; mov dl,'x' ; int 21h ; mov ax,[fs:14h] ; call printnum ; mov ah,02h ; mov dl,'x' ; int 21h ; xor ah,ah ; mov al,[fs:19h] ; call printnum ; mov ah,02h ; mov dl,13 ; int 21h ; mov dl,10 ; int 21h mov eax,[vesa2_x] cmp [fs:12h],ax ; Check that the height matches jnz near .loopcheckmodes mov eax,[vesa2_y] cmp [fs:14h],ax ; Check that the width matches jnz near .loopcheckmodes mov al,[vesa2_bits] cmp [fs:19h],al ; Check bits/pixel for match jnz near .loopcheckmodes ; mov ax,3 ; int 10h ; xor eax,eax ; mov ax,[fs:0h] ; call printnum ; jmp DosExit mov byte[TripBufAvail],1 test word[fs:0000h],400h jz .notbuf mov byte[TripBufAvail],1 .notbuf ; jz .notvesa3 ; xor eax,eax ; mov ax,[fs:0000h] ; call printhex ; jmp DosExit .notvesa3 ; mov ah,07h ; int 21h ; D0 = Window supported ; 0 = Window is not supported ; 1 = Window is supported ; D1 = Window readable ; 0 = Window is not readable ; 1 = Window is readable ; D2 = Window writeable ; 0 = Window is not writeable ; 1 = Window is writeable ; D3-D7 = Reserved mov byte[.whichwin],0 mov al,[fs:2] ; Get window A attributes and al,0100b cmp al,0100b je .foundwin ; Mode supported mov al,[fs:3] ; Get window B attributes and al,0100b cmp al,0100b jne .foundwin ; Mode not supported mov byte[.whichwin],1 .foundwin ; Success - a match has been found!! sub ebp,2 mov ax,[ebp] mov [vesamode],ax ; Store vesa 2 mode number ; call printhex ; jmp DosExit mov ax,[fs:10h] mov byte[vesa2red10],0 mov byte[vesa2_rposng],11 mov byte[vesa2_gposng],6 mov byte[vesa2_bposng],0 mov dword[vesa2_clbitng],1111011111011110b mov dword[vesa2_clbitng2],11110111110111101111011111011110b mov dword[vesa2_clbitng2+4],11110111110111101111011111011110b mov dword[vesa2_clbitng3],0111101111101111b mov [bytesperscanline],ax ; Store bytes per scan line cmp byte[fs:20h],10 jne near .nored10 mov byte[fs:20h],11 mov byte[vesa2red10],1 mov byte[vesa2_rposng],10 mov byte[vesa2_gposng],5 mov dword[vesa2_clbitng],0111101111011110b mov dword[vesa2_clbitng2],01111011110111100111101111011110b mov dword[vesa2_clbitng2+4],01111011110111100111101111011110b mov dword[vesa2_clbitng3],0011110111101111b mov dword[UnusedBit], 10000000000000001000000000000000b mov dword[HalfTrans], 01111011110111100111101111011110b mov dword[UnusedBitXor], 01111111111111110111111111111111b mov dword[UnusedBit+4], 10000000000000001000000000000000b mov dword[HalfTrans+4], 01111011110111100111101111011110b mov dword[UnusedBitXor+4],01111111111111110111111111111111b mov dword[HalfTransB], 00000100001000010000010000100001b mov dword[HalfTransB+4], 00000100001000010000010000100001b mov dword[HalfTransC], 01111011110111100111101111011110b mov dword[HalfTransC+4], 01111011110111100111101111011110b mov dword[ngrposng],10 mov dword[nggposng],5 mov dword[ngbposng],0 .nored10 ; fix up bit lengths mov al,16 sub al,[fs:20h] mov ah,[fs:22h] sub ah,[fs:20h] mov bl,[fs:24h] sub bl,[fs:20h] mov bh,al cmp bh,ah jb .scheck1 mov bh,ah .scheck1 cmp bh,bl jb .scheck2 mov bh,bl .scheck2 mov byte[fs:19h],5 mov al,16 sub al,[fs:22h] mov ah,[fs:20h] sub ah,[fs:22h] mov bl,[fs:24h] sub bl,[fs:22h] mov bh,al cmp bh,ah jb .scheck1b mov bh,ah .scheck1b cmp bh,bl jb .scheck2b mov bh,bl .scheck2b mov [fs:21h],bh mov al,16 sub al,[fs:24h] mov ah,[fs:20h] sub ah,[fs:24h] mov bl,[fs:22h] sub bl,[fs:24h] mov bh,al cmp bh,ah jb .scheck1c mov bh,ah .scheck1c cmp bh,bl jb .scheck2c mov bh,bl .scheck2c mov [fs:23h],bh mov word[vesa2_clbit],0 cmp byte[fs:20h],10 jne .nottopbit mov word[vesa2_usbit],8000h .nottopbit ; Process Red Stuff mov al,[fs:20h] ; bit sizes = [fs:19h,21h,23h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:19h],6 jne .no6bit mov [vesa2_usbit],bx inc al .no6bit or [vesa2_clbit],bx mov [vesa2_rpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrr shl bx,cl jmp .shlr .shrr shr bx,1 .shlr mov word[vesa2_rfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_rtrcl],bx xor bx,0FFFFh mov word[vesa2_rtrcla],bx ; mov ax,03h ; int 10h ; mov ax,[vesa2_rfull] ; call printhex ; jmp DosExit ; Process Green Stuff mov al,[fs:22h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:21h],6 jne .no6bitb mov [vesa2_usbit],bx inc al .no6bitb or [vesa2_clbit],bx mov [vesa2_gpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrg shl bx,cl jmp .shlg .shrg shr bx,1 .shlg mov word[vesa2_gfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_gtrcl],bx xor bx,0FFFFh mov word[vesa2_gtrcla],bx ; Process Blue Stuff mov al,[fs:24h] mov cl,al mov bx,1 shl bx,cl cmp byte[fs:23h],6 jne .no6bitc mov [vesa2_usbit],bx inc al .no6bitc or [vesa2_clbit],bx mov [vesa2_bpos],al dec al mov cl,al mov bx,001Fh cmp cl,0FFh je .shrb shl bx,cl jmp .shlb .shrb shr bx,1 .shlb mov word[vesa2_bfull],bx add al,5 mov bx,1 mov cl,al shl bx,cl mov word[vesa2_btrcl],bx xor bx,0FFFFh mov word[vesa2_btrcla],bx xor word[vesa2_clbit],0FFFFh ;vesa2_rtrcl dw 0 ; red transparency clear (bit+4) ;vesa2_rtrcla dw 0 ; red transparency (AND) clear (not(bit+4)) ;vesa2_rfull dw 0 ; red max (or (bit-1)*1Fh) call genfulladdtab test word[fs:0h],10000000b ; Check if linear available jnz .linearavailable mov edx,.nolframebuffer jmp VESA2EXITTODOS ; None available .nolframebuffer db 'Linear Frame Buffer not Detected.',0 ;---------------------------------------------; ; OK - now set the vesa 2 mode based on the ; ; information gleaned... ; ;---------------------------------------------; .linearavailable or word[vesamode],4000h ; Convert mode to its LFB ; equivalent mov ebx,[fs:28h] ; Read in physical base ptr mov cx,bx shr ebx,16 mov si,[noblocks] xor edi,edi ; Since noblocks = number of ; 64k blocks, these lines leave ; si:di holding byte size mov eax,800h int 31h jnc .mappedphysicalarea mov edx,.unablemap jmp VESA2EXITTODOS ; Failure!!! .unablemap db 'Unable to map physical area.',0 .mappedphysicalarea shl ebx,16 mov bx,cx mov [LFBpointer],ebx mov eax,ebx sub eax,[ZSNESBase] mov [VESAAddr],eax xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx mov ax,4f02h mov bx,[vesamode] int 10h ; Set the vesa mode cmp ax,004fh jz .modesetok mov edx,.unableset jmp VESA2EXITTODOS ; Failure!!! .unableset db 'Unable to initialize video mode.',0 .modesetok ;******************************* EXTRA BIT **************************** ; cmp byte[.whichwin],1 ; Check if Write is at Window B ; jne .nowinB ; ; mov ax,4F05h ; mov bx,1 ; mov dx,0 ; int 10h ; ;.nowinB ; Check logical scanline length mov eax,4f06h mov ebx,1 int 10h cmp cx,[vesa2_x] je .correctwidth mov eax,4f06h ; VBE Set/Get logical scan line ; length mov ebx,0 ; Set scan line length in ; pixels mov ecx, [vesa2_x] ; Desired screen width int 10h cmp ax,04fh jz .correctwidth mov edx, .unablescan jmp VESA2EXITTODOS ; Failure!!! .unablescan db 'Unable to set scan line length.',0 .correctwidth ;*************************** END OF EXTRA BIT ************************* xor eax,eax mov ecx,1 int 31h ; Allocate a descriptor mov bx,ax ; Move our selector into bx mov ecx,[LFBpointer] mov dx,cx shr ecx,16 mov eax,7 int 31h ; Set our selector to LFB jnc .selectornowset mov edx,.unablelfb jmp VESA2EXITTODOS ; Failure!!! .unablelfb db 'Unable to set selector to LFB.',0 .selectornowset xor ecx,ecx mov cx,[noblocks] shl ecx,6 ; Multiply by 64 shl ecx,10 ; And again by 1024 sub ecx,1 ; Necessary!!! mov dx,cx shr ecx,16 ; CX:DX size of screen mov eax,8 int 31h ; Set size of selector jnc .ok mov edx,.unablesets jmp VESA2EXITTODOS ; Failure!!! .unablesets db 'Unable to set size of selector.',0 .ok lar ecx,ebx shr ecx,8 and cl,60h or cl,93h and ch,0c0h ; Keep granularity bit mov ax,9 int 31h ; Set selector access rights jnc .accessrightsset mov edx,.unablesetar jmp VESA2EXITTODOS .unablesetar db 'Unable to set selector access rights.',0 .accessrightsset mov [vesa2selec],bx cmp byte[vesa2red10],1 je .red10 mov eax,565 jmp .red11 .red10 mov eax,555 .red11 push eax call Init_2xSaIMMX pop eax ret SECTION .data NEWSYM LFBpointer dd 0 NEWSYM noblocks dw 0 NEWSYM bytesperscanline dw 0 NEWSYM vesamode dw 0 ;---------------------------------------------------------------------- ;NEWSYM VESAmodelist ; times 512 dw 0 ;---------------------------------------------------------------------- SECTION .bss NEWSYM VESAmodelist, times 512 resw 1 ;NEWSYM RMREGS ;.edi dd 0 ;.esi dd 0 ;.ebp dd 0 ;.esp dd 0 ;.ebx dd 0 ;.edx dd 0 ;.ecx dd 0 ;.eax dd 0 ; ;.flags dw 0 ;.es dw 0 ;.ds dw 0 ;.fs dw 0 ;.gs dw 0 ;.ip dw 0 ;.cs dw 0 ;.sp dw 0 ;.ss dw 0 ;.spare times 20 dd 0 NEWSYM RMREGS .edi resd 1 .esi resd 1 .ebp resd 1 .esp resd 1 .ebx resd 1 .edx resd 1 .ecx resd 1 .eax resd 1 .flags resw 1 .es resw 1 .ds resw 1 .fs resw 1 .gs resw 1 .ip resw 1 .cs resw 1 .sp resw 1 .ss resw 1 .spare times 20 resd 1 ;---------------------------------------------------------------------- NEWSYM Vesa2AsmEnd zsnes-1.36/src/dos/zfile.c0100644000175000017500000001504407432621316015025 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include #include #include #include #include #include #include #define DWORD unsigned int #define BYTE unsigned char FILE *FILEHANDLE[16]; DWORD CurrentHandle=0; //Indicate whether the file must be opened using //zlib or not (used for gzip support) BYTE TextFile; // ZFileSystemInit // return 0 // ZOpenFile info : BYTE * ZOpenFileName; DWORD ZOpenMode; // Open modes : 0 read/write in // 1 write (create file, overwrite) // return file handle if success, 0xFFFFFFFF if error // ZCloseFile info : DWORD ZCloseFileHandle; // return 0 // ZFileSeek info : DWORD ZFileSeekHandle; DWORD ZFileSeekPos; DWORD ZFileSeekMode; // 0 start, 1 end // return 0 // ZFileReadBlock info : BYTE * ZFileReadBlock; DWORD ZFileReadSize; DWORD ZFileReadHandle; // return 0 // ZFileWriteBlock info : BYTE * ZFileWriteBlock; DWORD ZFileWriteSize; DWORD ZFileWriteHandle; // return 0 // ZFileTell DWORD ZFileTellHandle; // ZFileGetftime BYTE * ZFFTimeFName; DWORD ZFTimeHandle; DWORD ZFDate; DWORD ZFTime; // MKDir/CHDir BYTE * MKPath; BYTE * CHPath; BYTE * RMPath; // GetDir BYTE * DirName; DWORD DriveNumber; // ZFileDelete BYTE * ZFileDelFName; // return current position DWORD ZFileSystemInit() { #ifdef __GZIP__ TextFile = 0; #else TextFile = 1; #endif CurrentHandle=0; return(0); } DWORD ZOpenFile() { if(ZOpenMode==0) { if (TextFile) FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"); else FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"rb"); if(FILEHANDLE[CurrentHandle]!=NULL) { CurrentHandle+=1; return(CurrentHandle-1); } return(0xFFFFFFFF); } if(ZOpenMode==1) { if (TextFile) FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"); else FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"wb"); if(FILEHANDLE[CurrentHandle]!=NULL) { CurrentHandle+=1; return(CurrentHandle-1); } return(0xFFFFFFFF); } if(ZOpenMode==2) { if (TextFile) FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"); else FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"r+b"); if(FILEHANDLE[CurrentHandle]!=NULL) { CurrentHandle+=1; return(CurrentHandle-1); } return(0xFFFFFFFF); } return(0xFFFFFFFF); } DWORD ZCloseFile() { if (TextFile) fclose(FILEHANDLE[ZCloseFileHandle]); else gzclose(FILEHANDLE[ZCloseFileHandle]); CurrentHandle-=1; return(0); } DWORD ZFileSeek() { /*int res = 0;*/ int mode = 0; if (ZFileSeekMode==0) mode = SEEK_SET; else if (ZFileSeekMode==1) { mode = SEEK_END; if (TextFile==0) printf("Warning : gzseek(SEEK_END) not supported"); } else return (0xFFFFFFFF); if (TextFile) { fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode); return 0; } else { gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode); return 0; } return(0xFFFFFFFF); } DWORD ZFileRead() { if (TextFile) return(fread(ZFileReadBlock, 1, ZFileReadSize, FILEHANDLE[ZFileReadHandle])); else return(gzread(FILEHANDLE[ZFileReadHandle], ZFileReadBlock, ZFileReadSize)); } DWORD ZFileWrite() { int res=0; if (TextFile) res = fwrite(ZFileWriteBlock, 1, ZFileWriteSize, FILEHANDLE[ZFileWriteHandle]); else res = gzwrite(FILEHANDLE[ZFileWriteHandle], ZFileWriteBlock, ZFileWriteSize); if (res!=ZFileWriteSize) return(0xFFFFFFFF); return(0); } DWORD ZFileTell() { int res = 0; if (TextFile) { res = ftell(FILEHANDLE[ZFileTellHandle]); if (res == -1) fprintf(stderr, "Oups!! gzTell\n"); return(res); } else return gztell(FILEHANDLE[ZFileTellHandle]); } DWORD ZFileDelete() { return(remove(ZFileDelFName)); } DWORD ZFileGetFTime() { _dos_open(ZFFTimeFName, 0,&ZFTimeHandle); _dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime); _dos_close(ZFTimeHandle); return(0); } DWORD ZFileMKDir() { /*return(mkdir(MKPath));*/ return (mkdir(MKPath, S_IWUSR)); } DWORD ZFileCHDir() { return(chdir(CHPath)); } DWORD ZFileRMDir() { return(rmdir(RMPath)); } DWORD ZFileGetDir() { /*return(getcwd(DirName,128));*/ return(*getcwd(DirName,128)); } BYTE * ZFileFindPATH; DWORD ZFileFindATTRIB; DWORD DTALocPos; //struct _find_t { // char reserved[21] __attribute__((packed)); // unsigned char attrib __attribute__((packed)); // unsigned short wr_time __attribute__((packed)); // unsigned short wr_date __attribute__((packed)); // unsigned long size __attribute__((packed)); // char name[256] __attribute__((packed)); //}; DWORD ZFileFindFirst() { /*return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,DTALocPos));*/ return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,((struct find_t *)DTALocPos))); } DWORD ZFileFindNext() { /*return(_dos_findnext(DTALocPos));*/ return(_dos_findnext(((struct find_t *) DTALocPos))); } DWORD ZFileFindEnd() // for compatibility with windows later { return(0); } //BYTE * DirName; //DWORD DriveNumber; //unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result); //unsigned int _dos_findnext(struct _find_t *_result); DWORD GetTime() { DWORD value; struct tm *newtime; time_t long_time; time( &long_time ); newtime = localtime( &long_time ); value = ((newtime->tm_sec) % 10)+((newtime->tm_sec)/10)*16 +((((newtime->tm_min) % 10)+((newtime->tm_min)/10)*16) << 8) +((((newtime->tm_hour) % 10)+((newtime->tm_hour)/10)*16) << 16); return(value); } DWORD GetDate() { DWORD value; struct tm *newtime; time_t long_time; time( &long_time ); newtime = localtime( &long_time ); value = ((newtime->tm_mday) % 10)+((newtime->tm_mday)/10)*16 +(((newtime->tm_mon)+1) << 8) +((((newtime->tm_year) % 10)+((newtime->tm_year)/10)*16) << 16) +((newtime->tm_wday) << 28); return(value); } zsnes-1.36/src/dos/zloader.c0100644000175000017500000002004507432621316015351 0ustar dolsondolson//Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later //version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include #include #include int pccmdline(void); extern void zstart(void); extern void DosExit(void); extern void ConvertJoyMap1(void); extern void ConvertJoyMap2(void); extern void displayparams(void); extern void makeextension(void); extern unsigned char Palette0, SPC700sh, OffBy1Line, DSPDisable, MMXSupport, Force8b, ForcePal, GUIClick, MouseDis, MusicRelVol, ScreenScale, SoundCompD, SoundQuality, StereoSound, V8Mode, antienab, cvidmode, debugdisble, debugger, enterpress, finterleave, frameskip, gammalevel, guioff, per2exec, pl1contrl, pl2contrl, romtype, scanlines, showallext, smallscreenon, soundon, spcon, vsyncon, DisplayS, fname, filefound, SnowOn, Triplebufen; void ccmdline(void); char *ers[] = { "Frame Skip must be a value of 0 to 9!\n", "Gamma Correction Level must be a value of 0 to 15!\n", "Sound Sampling Rate must be a value of 0 to 6!\n", "Invalid Video Mode!\n", "Percentage of instructions to execute must be a number from 50 to 150!\n", "Player Input must be a value from 0 to 6!\n", "Volume must be a number from 0 to 100!\n" }; int argc; char **argv; int main(int margc, char **margv) { argc=margc; argv=margv; zstart(); return(0); } int my_atoi(char *nptr) { int p,c; c=0; for(p=0;nptr[p];p++) { if( !isdigit(nptr[p]) ) c+=1; } if(c) return -1; else return atoi(nptr); } void ccmdline(void) { int p=0; p=pccmdline(); if(p == 0) return; if(p == 9) { displayparams(); } if(p == 4) { // printf("Mangled command line, did you forget a parm?\n"); printf("Invalid Commandline!\n"); DosExit(); } if((p > 9) && (p < 17)) { printf(ers[p-10]); DosExit(); } if(p == 2) { DosExit(); } printf("cmdline returned %i\n",p); DosExit(); } int pccmdline(void) { int p; int gfnm=0; for(p=1;p 6) return 15; p++; ConvertJoyMap1(); break; } case '2': /* Player 2 Input */ { if(!hasroom) return 4; pl2contrl=my_atoi(argv[p+1]); if(pl2contrl > 6) return 15; p++; ConvertJoyMap2(); break; } case '3': { vsyncon=0; Triplebufen=1; p++; break; } case 'f': { if(!hasroom) return 4; frameskip=my_atoi(argv[p+1]); if(frameskip > 9) return 10; frameskip++; p++; break; } case 'g': { if(!hasroom) return 4; gammalevel=my_atoi(argv[p+1]); if(gammalevel > 15) return 11; p++; break; } case 'p': { if(!hasroom) return 4; per2exec=my_atoi(argv[p+1]); if(per2exec > 150) return 14; if(per2exec < 50) return 14; p++; break; } case 'r': { if(!hasroom) return 4; SoundQuality=my_atoi(argv[p+1]); if(SoundQuality > 6) return 12; p++; break; } case 'v': { if(nn == '8') { V8Mode=1; pp++; } else { if(!hasroom) return 4; cvidmode=my_atoi(argv[p+1]); if(cvidmode > 14) return 13; p++; } break; } case 'k': { if(!hasroom) return 4; MusicRelVol=my_atoi(argv[p+1]); if(MusicRelVol > 100) return 16; p++; break; } case '8': { Force8b=1; break; } case '0': /* Palette 0 disable */ { Palette0=1; break; } case '7': /* SPC700 speed hack disable */ { SPC700sh=1; break; } case '9': /* Off by 1 line */ { OffBy1Line=1; break; } case 'e': { enterpress=1; break; } case 'h': { romtype=2; break; } case 'l': { romtype=1; break; } case 'm': { guioff=1; /* disables GUI */ break; } case 'n': { if(!hasroom) return 4; scanlines=my_atoi(argv[p+1]); p++; break; } case 's': { if(nn == 'p') { DisplayS=1; pp++; } else if(nn == 'a') { showallext=1; pp++; } else if(nn == 'n') { SnowOn=1; pp++; } else { spcon=1; soundon=1; } break; } case 't': { ForcePal=1; break; } case 'u': { ForcePal=2; break; } case 'w': { Triplebufen=0; vsyncon=1; break; } case 'z': { StereoSound=1; break; } case 'd': { if(nn == 'd') { DSPDisable=1; pp++; } else { debugger=1; debugdisble=0; } break; } case 'b': { SoundCompD=1; break; } case 'c': { if(nn == 'c') { smallscreenon=1; pp++; } else { ScreenScale=1; } break; } case 'y': { antienab=1; break; } case 'o': { if(nn == 'm') { MMXSupport=1; pp++; } else { MMXSupport=0; } break; } case 'i': { finterleave=1; break; } case 'j': { GUIClick=0; MouseDis=1; break; } case '?': { return 9; } } } } else { if(gfnm > 0) { printf("Limit yourself to one filename\n"); return 2; } else { char *fvar; fvar=&fname; fvar[0] = strlen(argv[p]); strncpy(&fvar[1],argv[p],127); gfnm++; } } } if(gfnm == 1) { filefound=0; makeextension(); } return 0; } zsnes-1.36/src/dos/zsipx.asm0100644000175000017500000001107607267141100015422 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM ipx_init ; To init ipx EXTSYM ipx_initcode ; return 0 if everything is ok (int) EXTSYM ipx_packet ; 80 bytes buffer to send EXTSYM ipx_packet_size ; size to send (max 80 bytes) (dword) EXTSYM sendpacket ; to send a packet EXTSYM checkpacket ; check if a packet is ready to receive EXTSYM ipx_packet_ready ; return 1 if there is a packet ready (byte) EXTSYM read_packet ; to read an incoming packet EXTSYM ipx_read_packet ; 80 bytes buffer of received packet EXTSYM ipx_deinit ; to deinit the ipx EXTSYM IPXInfoStr,IPXInfoStrR EXTSYM modembuffer, modemhead, modemtail NEWSYM ipxinited, db 0 NEWSYM initipx mov dword[modemhead],0 mov dword[modemtail],0 xor ax,ax cmp byte[ipxinited],1 je .notokay call ipx_init mov ax,[ipx_initcode] cmp ax,0 jne .notokay mov byte[ipxinited],1 .notokay ret NEWSYM deinitipx cmp byte[ipxinited],0 je .notinitialized mov byte[ipxinited],0 call ipx_deinit .notinitialized ret NEWSYM PacketPointer, dd 0 NEWSYM PreparePacketIPX cmp byte[ipxinited],1 jne .noipx call ipxpp .noipx ret NEWSYM SendPacketIPX cmp byte[ipxinited],1 jne .noipx call ipxsp .noipx ret NEWSYM ipxsendchar ; prepare packet push esi mov esi,[PacketPointer] mov [esi],al inc dword[PacketPointer] pop esi ret NEWSYM IPXSearchval, db 0 NEWSYM ipxlookforconnect cmp byte[ipxinited],0 je .initialized ret .initialized pushad call checkpacket cmp byte[ipx_packet_ready],1 jne near .nopacket call read_packet cmp dword[ipx_read_packet],'ZZ|Z' jne .nopacketf cmp byte[ipx_read_packet+6],'L' jne .nopacketf mov ax,[ipx_read_packet+4] cmp ax,[IPXInfoStr] je .nopacketf mov [IPXInfoStrR],ax mov eax,ipx_packet mov dword[eax],'ZY|Z' mov bx,[IPXInfoStr] mov [eax+4],bx mov bx,[IPXInfoStrR] mov [eax+6],bx mov dword[ipx_packet_size],8 call sendpacket mov byte[IPXSearchval],1 jmp .skipall .nopacketf cmp dword[ipx_read_packet],'ZY|Z' jne .nopacket mov bx,[IPXInfoStr] cmp [eax+6],bx jne .nopacket mov bx,[eax+4] cmp bx,[IPXInfoStr] je .nopacket mov [IPXInfoStrR],bx mov byte[IPXSearchval],1 jmp .skipall .nopacket mov eax,ipx_packet mov dword[eax],'ZZ|Z' mov bx,[IPXInfoStr] mov [eax+4],bx mov byte[eax+6],'L' mov dword[ipx_packet_size],7 call sendpacket .skipall popad ret NEWSYM ipxpp ; prepare packet pushad mov eax,ipx_packet mov byte[eax],'Z' mov byte[eax+1],'|' mov byte[eax+2],'S' mov bx,[IPXInfoStr] mov [eax+3],bx add eax,6 mov [PacketPointer],eax popad ret NEWSYM ipxsp ; send packet pushad mov eax,[PacketPointer] sub eax,ipx_packet mov [ipx_packet+5],al mov [ipx_packet_size],eax call sendpacket popad ret NEWSYM ipxgetchar pushad call checkpacket cmp byte[ipx_packet_ready],1 jne .nopacket call read_packet cmp byte[ipx_read_packet],'Z' jne .nopacket cmp byte[ipx_read_packet+1],'|' jne .nopacket cmp byte[ipx_read_packet+2],'S' jne .nopacket mov bx,[IPXInfoStrR] cmp [ipx_read_packet+3],bx jne .nopacket mov cl,[ipx_read_packet+5] sub cl,6 mov esi,ipx_read_packet+6 cmp cl,0 je .nopacket .loop mov edi,[modemtail] mov al,[esi] mov [modembuffer+edi],al inc dword[modemtail] inc esi and dword[modemtail],2047 dec cl jnz .loop .nopacket popad push eax xor dh,dh mov eax,[modemhead] cmp eax,[modemtail] je .nonewchar mov dh,1 mov dl,[modembuffer+eax] inc dword[modemhead] and dword[modemhead],2047 .nonewchar pop eax ret zsnes-1.36/src/dos/vga.inc0100644000175000017500000000745607356174667015051 0ustar dolsondolson ; by kode54, stainless %ifdef __MSDOS__ %macro SetVGAMode 1 mov byte[cbitmode],0 mov ax,0013h int 10h mov dx,03d4h mov ax,0011h out dx,ax inc edx in al,dx and al,07fh mov ah,al mov al,11h dec edx out dx,ax xor ecx,ecx jmp %%start %%loop add ecx,4 %%start mov eax,[%1+ecx] or eax,eax jz %%end cmp ax,03c0h je %%3c0 cmp ax,03c2h je %%3c2 cmp ax,03c3h je %%3c2 jmp %%default %%3c0 mov dx,03dah in al,dx mov dl,0c0h shr eax,16 or al,20h out dx,al shr eax,8 out dx,al jmp %%loop %%3c2 mov dx,ax rol eax,8 out dx,al jmp %%loop %%default mov dx,ax shr eax,16 out dx,ax jmp %%loop %%end %endmacro SECTION .data .Mode256x224c dw 03c2h,0e300h,03d4h,05f00h,03d4h,03f01h,03d4h,04002h,03d4h,08203h dw 03d4h,04a04h,03d4h,09a05h,03d4h,00b06h,03d4h,03e07h,03d4h,00008h dw 03d4h,06109h,03d4h,0da10h,03d4h,0ac11h,03d4h,0bf12h,03d4h,02013h dw 03d4h,04014h,03d4h,00715h,03d4h,01a16h,03d4h,0a317h,03c4h,00101h dw 03c4h,00e04h,03cEh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode256x240c dw 03c2h,0e300h,03d4h,05f00h,03d4h,03f01h,03d4h,04002h,03d4h,08203h dw 03d4h,04a04h,03d4h,09a05h,03d4h,00d06h,03d4h,03e07h,03d4h,00008h dw 03d4h,04109h,03d4h,0ea10h,03d4h,0ac11h,03d4h,0df12h,03d4h,02013h dw 03d4h,04014h,03d4h,0e715h,03d4h,00616h,03d4h,0a317h,03c4h,00101h dw 03c4h,00e04h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode256x256c dw 03c2h,0e300h,03d4h,05f00h,03d4h,03f01h,03d4h,04002h,03d4h,08203h dw 03d4h,04a04h,03d4h,09a05h,03d4h,02306h,03d4h,0b207h,03d4h,00008h dw 03d4h,06109h,03d4h,00a10h,03d4h,0ac11h,03d4h,0FF12h,03d4h,02013h dw 03d4h,04014h,03d4h,00715h,03d4h,01a16h,03d4h,0a317h,03c4h,00101h dw 03c4h,00e04h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode256x256cs dw 03c2h,0e300h,03d4h,05f00h,03d4h,03f01h,03d4h,04002h,03d4h,08203h dw 03d4h,04a04h,03d4h,09a05h,03d4h,02306h,03d4h,01d07h,03d4h,00008h dw 03d4h,06009h,03d4h,00a10h,03d4h,0ac11h,03d4h,0ff12h,03d4h,02013h dw 03d4h,04014h,03d4h,00715h,03d4h,01a16h,03d4h,0a317h,03c4h,00101h dw 03c4h,00e04h,03ceh,04005h,03cEh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode320x224 dw 03c2h,0e300h,03d4h,05f00h,03d4h,04f01h,03d4h,05002h,03d4h,08203h dw 03d4h,05404h,03d4h,08005h,03d4h,00b06h,03d4h,03e07h,03d4h,00008h dw 03d4h,04109h,03d4h,0da10h,03d4h,09c11h,03d4h,0c012h,03d4h,02813h dw 03d4h,00014h,03d4h,0c715h,03d4h,00416h,03d4h,0e317h,03c4h,00101h dw 03c4h,00604h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode320x240 dw 03c2h,0e300h,03d4h,05f00h,03d4h,04f01h,03d4h,05002h,03d4h,08203h dw 03d4h,05404h,03d4h,08005h,03d4h,00d06h,03d4h,03e07h,03d4h,00008h dw 03d4h,04109h,03d4h,0ea10h,03d4h,0ac11h,03d4h,0df12h,03d4h,02813h dw 03d4h,00014h,03d4h,0e715h,03d4h,00616h,03d4h,0e317h,03c4h,00101h dw 03c4h,00604h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode320x256 dw 03c2h,0e300h,03d4h,05f00h,03d4h,04f01h,03d4h,05002h,03d4h,08203h dw 03d4h,05404h,03d4h,08005h,03d4h,02306h,03d4h,0b207h,03d4h,00008h dw 03d4h,06109h,03d4h,00a10h,03d4h,0ac11h,03d4h,0ff12h,03d4h,02813h dw 03d4h,00014h,03d4h,00715h,03d4h,01a16h,03d4h,0e317h,03c4h,00101h dw 03c4h,00604h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 .Mode320x256s dw 03c2h,0e300h,03d4h,05f00h,03d4h,04f01h,03d4h,05002h,03d4h,08203h dw 03d4h,05404h,03d4h,08005h,03d4h,02306h,03d4h,01d07h,03d4h,00008h dw 03d4h,06009h,03d4h,00a10h,03d4h,0ac11h,03d4h,0ff12h,03d4h,02813h dw 03d4h,00014h,03d4h,00715h,03d4h,01a16h,03d4h,0e317h,03c4h,00101h dw 03c4h,00604h,03ceh,04005h,03ceh,00506h,03c0h,04110h,03c0h,00013h dd 0 SECTION .text %endif zsnes-1.36/src/gui/0042755000175000017500000000000007514703044013550 5ustar dolsondolsonzsnes-1.36/src/gui/guicheat.inc0100644000175000017500000006432007437052473016043 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; GUI Cheat Code Routines AddCSCheatCode: cmp byte[CSInputDisplay],'_' je .nodisplay jmp .okay .nodisplay ret .okay mov eax,[curentryval] mov [curaddrvalcs],eax mov eax,[CSCurValue] mov [curvaluecs],eax xor ecx,ecx mov cl,[CheatSrcByteSize] inc cl cmp byte[CheatUpperByteOnly],0 je .cspardisploop mov cl,1 .cspardispagain cmp dword[curvaluecs],0FFh jbe .cspardisploop shr dword[curvaluecs],8 inc dword[curaddrvalcs] jmp .cspardispagain .cspardisploop push ecx mov esi,GUICSrcTextQ mov ecx,3 mov eax,[curaddrvalcs] add eax,7E0000h mov bl,[curvaluecs] ; write bl at address eax call AddCheatCode shr dword[curvaluecs],8 mov byte[GUItextcolor],223 add dword[CheatSearchYPos],10 inc dword[curaddrvalcs] pop ecx dec ecx jnz near .cspardisploop mov byte[CheatWinMode],2 ret %macro SearchCMPByte 0 mov bl,[edi] cmp bl,[esi] %endmacro %macro SearchCMP2Bytes 0 mov bx,[edi] cmp bx,[esi] %endmacro %macro SearchCMP3Bytes 0 push ecx mov ebx,[edi] mov ecx,[esi] and ebx,0FFFFFFh and ecx,0FFFFFFh cmp ebx,ecx pop ecx %endmacro %macro SearchCMP4Bytes 0 mov ebx,[edi] cmp ebx,[esi] %endmacro %macro SearchMacro 2 mov dl,0FEh %%searchloop %2 %1 %%nofail and [eax],dl %%nofail inc edi inc esi cmp dl,7Fh jne %%noinceax inc eax %%noinceax rol dl,1 ; loop %%searchloop dec ecx jnz %%searchloop %endmacro %macro SearchMacroB 1 cmp byte[CheatCompareValue],0 je near %%greater cmp byte[CheatCompareValue],1 je near %%lessthan cmp byte[CheatCompareValue],3 je near %%notequalthan SearchMacro je, %1 jmp .end %%greater SearchMacro ja, %1 jmp .end %%lessthan SearchMacro jb, %1 jmp .end %%notequalthan SearchMacro jne, %1 jmp .end %endmacro CheatCodeSearchProcess: cmp byte[CheatSrcSearchType],1 je near .comparative cmp byte[CSInputDisplay],0 je near .nodisplay cmp byte[CSInputDisplay],'_' je near .nodisplay cmp byte[CSOverValue],1 je near .nodisplay mov byte[CSInputDisplay],'_' mov byte[CSInputDisplay+1],0 ; Process Cheat Search mov ecx,65536*2 xor ebx,ebx mov bl,byte[CheatSrcByteSize] sub ecx,ebx mov edx,[SrcMask+ebx*4] mov edi,dword[vidbuffer] add edi,129600+65536*2 mov esi,[wramdata] mov bl,0FEh mov bh,01h .exactloop mov eax,[esi] and eax,edx cmp eax,[CSCurValue] je .found inc eax and eax,edx cmp eax,[CSCurValue] je .foundb .failedfind and [edi],bl jmp .foundc .found test byte[edi+16384],bh jz .failedfind jmp .foundc .foundb cmp byte[FirstSearch],1 je .clear test byte[edi+16384],bh jnz .failedfind jmp .foundc .clear and byte[edi+16384],bl .foundc cmp bl,7Fh jne .noincedi inc edi .noincedi rol bl,1 rol bh,1 inc esi dec ecx jnz .exactloop ; CSCurValue dd 0 mov byte[CopyRamToggle],1 mov byte[CheatSearchStatus],1 .nodisplay ret .comparative mov byte[CSInputDisplay],'_' mov byte[CSInputDisplay+1],0 mov byte[CheatSearchStatus],1 mov eax,dword[vidbuffer] add eax,129600+65536*2 mov esi,dword[vidbuffer] add esi,129600 mov edi,[wramdata] mov ecx,65536*2 cmp byte[CheatSrcByteSize],1 je near .bytesize2 cmp byte[CheatSrcByteSize],2 je near .bytesize3 cmp byte[CheatSrcByteSize],3 je near .bytesize4 SearchMacroB SearchCMPByte .bytesize2 dec ecx SearchMacroB SearchCMP2Bytes .bytesize3 sub ecx,2 SearchMacroB SearchCMP3Bytes .bytesize4 sub ecx,3 SearchMacroB SearchCMP4Bytes .end mov byte[CopyRamToggle],1 ret CopyRamToggle db 0 FirstSearch db 0 CheatCodeSearchInit: mov byte[CSInputDisplay],'_' mov byte[CSInputDisplay+1],0 mov byte[CheatWinMode],1 mov byte[CheatSearchStatus],0 cmp byte[CopyRamToggle],0 mov byte[FirstSearch],1 mov eax,dword[vidbuffer] add eax,129600 ; copy 128k ram mov ebx,[wramdata] mov ecx,32768 .loop mov edx,[ebx] mov [eax],edx add ebx,4 add eax,4 dec ecx jnz .loop ; fill searched buffer with 0xFF mov eax,dword[vidbuffer] add eax,129600+65536*2 mov ecx,8192 .loop2 mov dword[eax],0FFFFFFFFh add eax,4 dec ecx jnz .loop2 cmp byte[CheatSrcSearchType],1 jne .nottype1 mov byte[CheatSearchStatus],1 .nottype1 mov dword[CheatCompareValue],0 mov eax,dword[vidbuffer] add eax,129600+65536*2 cmp byte[CheatSrcByteSize],1 je near .bytesize2 cmp byte[CheatSrcByteSize],2 je near .bytesize3 cmp byte[CheatSrcByteSize],3 je near .bytesize4 ret .bytesize2 and byte[eax+16383],07Fh ret .bytesize3 and byte[eax+16383],03Fh ret .bytesize4 and byte[eax+16383],01Fh ret CheatCodeSave: cmp byte[NumCheats],0 jne .okay mov byte[GUICBHold],0 ret .okay mov byte[cheatdata+6],254 mov byte[cheatdata+7],252 call SRAMDirc mov byte[GUICBHold],0 mov ebx,[statefileloc] sub ebx,2 mov eax,[fnamest+ebx] mov dword[fnamest+ebx],'cht' push eax push ebx mov edx,fnamest+1 call Create_File jc .cheatsavefail mov bx,ax mov ecx,[NumCheats] mov edx,ecx shl ecx,4 shl edx,2 add ecx,edx add ecx,edx add ecx,edx mov edx,cheatdata call Write_File call Close_File .cheatsavefail pop ebx pop eax mov [fnamest+ebx],eax call LOADDir ret CheatCodeLoad: call SRAMDirc mov byte[GUICBHold],0 mov ebx,[statefileloc] sub ebx,2 mov eax,[fnamest+ebx] mov dword[fnamest+ebx],'cht' push eax push ebx mov edx,fnamest+1 call Open_File jc near .fail mov bx,ax ; Disable all codes push ebx mov esi,cheatdata mov ecx,[NumCheats] cmp ecx,0 je .skip .loop2 test byte[esi],4 jnz .disabled2 push esi push ecx call DisableCheatCode pop ecx pop esi .disabled2 add esi,28 dec ecx jnz .loop2 .skip pop ebx mov ecx,255*28 mov edx,cheatdata call Read_File push eax call Close_File pop eax cmp byte[cheatdata+6],254 jne .notnewformat cmp byte[cheatdata+7],252 jne .notnewformat jmp .newformat .notnewformat ; Convert format mov esi,cheatdata mov ebx,18 push eax xor edx,edx div ebx push edx mov [NumCheats],eax mov ebx,28 mul ebx mov ecx,eax pop edx pop eax sub eax,edx .convloop sub ecx,28 sub eax,18 mov ebx,6 .convloopb mov dl,[cheatdata+eax+ebx-1] mov [cheatdata+ecx+ebx-1],dl dec ebx jnz .convloopb mov ebx,12 .convloopd mov dl,[cheatdata+eax+ebx+5] mov [cheatdata+ecx+ebx+7],dl dec ebx jnz .convloopd mov ebx,8 .convloopc mov byte[cheatdata+ecx+ebx+19],0 dec ebx jnz .convloopc or ecx,ecx jnz .convloop jmp .fin .newformat mov ebx,28 xor edx,edx div ebx mov [NumCheats],eax .fin pop ebx pop eax mov [fnamest+ebx],eax ; Enable all ON toggled cheat codes mov esi,cheatdata mov ecx,[NumCheats] cmp ecx,0 je .skip2 .loop test byte[esi],4 jnz .disabled push esi push ecx call EnableCheatCode pop ecx pop esi .disabled add esi,28 dec ecx jnz .loop .skip2 mov eax,[NumCheats] cmp eax,[GUIcurrentcheatcursloc] ja .noconf dec eax mov dword[GUIcurrentcheatcursloc],eax .noconf cmp dword[NumCheats],0 jne .nozero mov dword[GUIcurrentcheatcursloc],0 mov byte[CheatOn],0 call LOADDir ret .nozero mov byte[CheatOn],1 call LOADDir ret .fail pop ebx pop eax mov [fnamest+ebx],eax call LOADDir ret CheatCodeRemove: cmp dword[NumCheats],0 jne .nonone mov byte[GUICBHold],0 ret .nonone mov byte[GUICBHold],0 mov esi,[GUIcurrentcheatcursloc] shl esi,5 sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] add esi,cheatdata push esi call DisableCheatCode pop esi mov eax,255 sub eax,[GUIcurrentcheatcursloc] mov ebx,eax shl eax,4 add eax,ebx add eax,ebx .loop mov bl,[esi+28] mov [esi],bl inc esi dec eax jnz .loop dec dword[NumCheats] mov eax,[GUIcurrentcheatcursloc] cmp dword[NumCheats],0 je .okay cmp eax,[NumCheats] jne .okay dec dword[GUIcurrentcheatcursloc] .okay cmp byte[NumCheats],0 jne .cheatexists mov byte[CheatOn],0 .cheatexists ret CheatCodeFix: cmp dword[NumCheats],0 jne .nonone mov byte[GUICBHold],0 ret .nonone mov byte[GUICBHold],0 call DisableCheatCode mov esi,[GUIcurrentcheatcursloc] shl esi,5 sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] add esi,cheatdata xor byte[esi+3],80h call EnableCheatCodeNoPrevMod ret CheatCodeToggle: cmp dword[NumCheats],0 jne .nonone mov byte[GUICBHold],0 ret .nonone mov byte[GUICBHold],0 mov esi,[GUIcurrentcheatcursloc] shl esi,5 sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] add esi,cheatdata test byte[esi],4 jz DisableCheatCode jmp EnableCheatCodeNoPrevMod DisableCheatCode: ; code is at esi xor ecx,ecx xor ebx,ebx or byte[esi],4 test byte[esi],1 jnz .gfrom mov al,[esi+5] mov cx,[esi+2] mov bl,[esi+4] mov byte[writeon],1 test byte[esi],80h jnz .nowrite test byte[esi-28],80h jnz .nowrite call dword near [memtablew8+ebx*4] .nowrite mov byte[writeon],0 ret .gfrom mov al,[esi+5] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[romdata] mov [esi+ecx],al ret .gfram mov al,[esi+5] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[sram] mov [esi+ecx],al ret EnableCheatCode: ; code is at esi xor ecx,ecx xor ebx,ebx and byte[esi],0FBh test byte[esi],1 jnz .gfrom mov al,[esi+1] mov cx,[esi+2] mov bl,[esi+4] push ecx push eax push ebx push edx call dword near [memtabler8+ebx*4] pop edx mov byte[esi+5],al pop ebx pop eax pop ecx mov byte[writeon],1 test byte[esi],80h jnz .nowrite test byte[esi-28],80h jnz .nowrite call dword near [memtablew8+ebx*4] .nowrite mov byte[writeon],0 ret .gfrom mov al,[esi+1] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[romdata] mov bl,[esi+ecx] mov [esi+ecx],al mov [esi+5],bl ret .gfram mov al,[esi+1] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[sram] mov bl,[esi+ecx] mov [esi+ecx],al mov [esi+5],bl ret EnableCheatCodeNoPrevMod: ; code is at esi xor ecx,ecx xor ebx,ebx and byte[esi],0FBh test byte[esi],1 jnz .gfrom mov al,[esi+1] mov cx,[esi+2] mov bl,[esi+4] mov byte[writeon],1 test byte[esi],80h jnz .nowrite test byte[esi-28],80h jnz .nowrite call dword near [memtablew8+ebx*4] .nowrite mov byte[writeon],0 ret .gfrom mov al,[esi+1] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[romdata] mov bl,[esi+ecx] mov [esi+ecx],al mov [esi+5],bl ret .gfram mov al,[esi+1] mov ecx,[esi+2] and ecx,0FFFFFFh mov esi,[sram] mov bl,[esi+ecx] mov [esi+ecx],al mov [esi+5],bl ret AddCheatCode: mov byte[GUICBHold],0 cmp dword[NumCheats],255 jne .okay ret .okay push eax push ebx ; transfer description mov eax,[NumCheats] shl eax,5 sub eax,[NumCheats] sub eax,[NumCheats] sub eax,[NumCheats] sub eax,[NumCheats] add eax,cheatdata mov edx,eax push edx add eax,6 mov ebx,CSDescDisplay mov ecx,20 .dloop mov dl,[ebx] mov [eax+2],dl mov [eax+18+2],dl mov [eax+18*2+2],dl inc ebx inc eax dec ecx jnz .dloop pop edx pop ebx pop eax ; toggle, value, address, pvalue, name(12) mov byte[edx],0 mov [edx+1],bl push eax sub eax,7E0000h add eax,[wramdata] mov bh,[eax] mov [eax],bl pop eax mov [edx+2],eax mov [edx+5],bh inc dword[NumCheats] mov edx,7 mov al,[GUIpmenupos] push eax call CheckMenuItemHelp pop eax mov [GUIpmenupos],al mov byte[CheatOn],1 ret ProcessCheatCode: mov byte[GUICBHold],0 cmp dword[NumCheats],255 je .fail cmp byte[GUICheatPosA],0 je .fail jmp .okay .fail ret .okay ; make sure flashing cursor doesn't exist xor ebx,ebx mov bl,[GUICheatPosB] mov byte[GUICheatTextA+ebx],0 ; transfer description mov eax,[NumCheats] shl eax,5 sub eax,[NumCheats] sub eax,[NumCheats] sub eax,[NumCheats] sub eax,[NumCheats] add eax,cheatdata add eax,6 mov ebx,GUICheatTextA mov ecx,20 .dloop mov dl,[ebx] mov [eax+2],dl mov [eax+18+2],dl mov [eax+18*2+2],dl inc ebx inc eax dec ecx jnz .dloop ; determine whether it is gamegenie, par, or GF ; uppercase all codes if necessary mov eax,GUICheatText9 mov ecx,14 .loop mov bl,[eax] cmp bl,'a' jb .nolower cmp bl,'z' ja .nolower sub bl,'a'-'A' mov [eax],bl .nolower inc eax dec ecx jnz .loop mov byte[guicheatvalrep],0 xor eax,eax mov al,[GUICheatPosA] dec al cmp byte[GUICheatText9+eax],'R' jne .notrep mov byte[guicheatvalrep],80h dec byte[GUICheatPosA] .notrep cmp byte[GUICheatPosA],8 je near .par cmp byte[GUICheatPosA],9 je near .gg cmp byte[GUICheatPosA],14 je near .gf .invalidpar jmp guicheaterror .par ; check if code is valid mov eax,GUICheatText9 mov ecx,8 .looppar mov bl,[eax] cmp bl,'0' jb .invalidpar cmp bl,'9' jbe .okaypar cmp bl,'A' jb .invalidpar cmp bl,'F' ja .invalidpar .okaypar inc eax dec ecx jnz .looppar jmp decodepar .invalidgg jmp guicheaterror .gg ; check if code is valid mov eax,GUICheatText9 mov ecx,9 .loopgg cmp ecx,5 jne .nomid cmp byte[eax],'-' jne .invalidgg inc eax dec ecx .nomid mov bl,[eax] cmp bl,'0' jb .invalidgg cmp bl,'9' jbe .okaygg cmp bl,'A' jb .invalidgg cmp bl,'F' ja .invalidgg .okaygg inc eax dec ecx jnz .loopgg jmp decodegg ret .invalidgf jmp guicheaterror .gf ; check if code is valid mov eax,GUICheatText9 mov ecx,5 .loopgf mov bl,[eax] cmp bl,'0' jb .invalidgf cmp bl,'9' jbe .okaygf cmp bl,'A' jb .invalidgf cmp bl,'F' ja .invalidgf .okaygf inc eax dec ecx jnz .loopgf mov eax,GUICheatText9+5 mov ecx,6 .loopgf2 mov bl,[eax] cmp bl,'X' je .okaygf2 cmp bl,'0' jb .invalidgf cmp bl,'9' jbe .okaygf2 cmp bl,'A' jb near .invalidgf cmp bl,'F' ja near .invalidgf .okaygf2 inc eax dec ecx jnz .loopgf2 mov bl,[GUICheatText9+13] cmp bl,'0' je .okaygf3 cmp bl,'1' jne near .invalidgf .okaygf3 jmp decodegf decodegf: ; convert code to number format mov ecx,14 mov esi,GUICheatText9 .loopb2 mov al,[esi] cmp al,'X' je .let2 cmp al,'A' jb .num2 sub al,'A' add al,10 jmp .let2 .num2 sub al,'0' .let2 mov [esi],al inc esi dec ecx jnz .loopb2 ; get address xor ebx,ebx xor ecx,ecx mov cl,[GUICheatText9] shl ecx,4 add cl,[GUICheatText9+1] shl ecx,4 add cl,[GUICheatText9+2] shl ecx,4 add cl,[GUICheatText9+3] shl ecx,4 add cl,[GUICheatText9+4] mov edx,[NumCheats] shl edx,5 sub edx,[NumCheats] sub edx,[NumCheats] sub edx,[NumCheats] sub edx,[NumCheats] ; Write data to memory cmp byte[GUICheatText9+13],1 je near .modifysram ; get data cmp byte[GUICheatText9+5],'X' je near .nocode cmp byte[GUICheatText9+6],'X' je near .nocode mov bl,[GUICheatText9+5] shl bl,4 add bl,[GUICheatText9+6] mov esi,[romdata] mov al,[esi+ecx] mov [esi+ecx],bl mov byte[cheatdata+edx],1 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al push eax mov al,[guicheatvalrep] or [cheatdata+edx],al pop eax inc byte[NumCheats] add edx,28 .nocode inc ecx cmp byte[GUICheatText9+7],'X' je near .nocode1 cmp byte[GUICheatText9+8],'X' je near .nocode1 cmp byte[NumCheats],255 je near .nocode1 mov bl,[GUICheatText9+7] shl bl,4 add bl,[GUICheatText9+8] mov esi,[romdata] mov al,[esi+ecx] mov [esi+ecx],bl mov byte[cheatdata+edx],1 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al inc byte[NumCheats] add edx,28 .nocode1 inc ecx cmp byte[GUICheatText9+9],'X' je near .nocode2 cmp byte[GUICheatText9+10],'X' je near .nocode2 cmp byte[NumCheats],255 je near .nocode2 mov bl,[GUICheatText9+9] shl bl,4 add bl,[GUICheatText9+10] mov esi,[romdata] mov al,[esi+ecx] mov [esi+ecx],bl mov byte[cheatdata+edx],1 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al inc byte[NumCheats] .nocode2 jmp .quit .modifysram cmp ecx,65535 ja near .quit mov esi,[sram] ; get data cmp byte[GUICheatText9+5],'X' je .nocodeb cmp byte[GUICheatText9+6],'X' je .nocodeb mov bl,[GUICheatText9+5] shl bl,4 add bl,[GUICheatText9+6] mov al,[esi+ecx] mov [esi+ecx],bl mov byte[cheatdata+edx],2 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al inc byte[NumCheats] add edx,28 .nocodeb inc ecx cmp byte[GUICheatText9+7],'X' je .nocode1b cmp byte[GUICheatText9+8],'X' je .nocode1b cmp byte[NumCheats],255 je .nocode1b cmp ecx,65535 ja .nocode1b mov bl,[GUICheatText9+7] shl bl,4 add bl,[GUICheatText9+8] mov al,[esi+ecx+1] mov [esi+ecx+1],bl mov byte[cheatdata+edx],2 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al inc byte[NumCheats] add edx,28 .nocode1b inc ecx cmp byte[GUICheatText9+9],'X' je .nocode2c cmp byte[GUICheatText9+10],'X' je .nocode2c cmp byte[NumCheats],255 je .nocode2c cmp ecx,65535 ja .nocode2c mov bl,[GUICheatText9+9] shl bl,4 add bl,[GUICheatText9+10] mov al,[esi+ecx+2] mov [esi+ecx+2],bl mov byte[cheatdata+edx],2 mov [cheatdata+edx+2],ecx mov [cheatdata+edx+1],bl mov [cheatdata+edx+5],al inc byte[NumCheats] .nocode2c .quit cmp byte[NumCheats],0 je .nocheat mov byte[CheatOn],1 mov dword[GUIcurrentcheatwin],1 mov eax,[NumCheats] dec eax mov [GUIcurrentcheatcursloc],eax sub eax,11 mov [GUIcurrentcheatviewloc],eax test dword[GUIcurrentcheatviewloc],80000000h jz .noview mov dword[GUIcurrentcheatviewloc],0 .noview .nocheat mov dword[GUICheatText9],0 mov dword[GUICheatTextA],0 mov byte[GUICheatPosA],0 mov byte[GUICheatPosB],0 ret decodegg: ;Genie Hex: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E ;Normal Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F ; 4 6 D E 2 7 8 3 B 5 C 9 A 0 F 1 ; Convert code mov esi,GUICheatText9 mov eax,[esi+5] mov [esi+4],eax ; convert code to number format mov ecx,8 xor eax,eax .loopb3 mov al,[esi] cmp al,'A' jb .num3 sub al,'A' add al,10 jmp .let3 .num3 sub al,'0' .let3 mov al,[.GG2Norm+eax] mov [esi],al inc esi dec ecx jnz .loopb3 mov esi,GUICheatText9 xor ecx,ecx mov cl,[esi+2] shl ecx,4 add cl,[esi+3] shl ecx,4 add cl,[esi+4] shl ecx,4 add cl,[esi+5] shl ecx,4 add cl,[esi+6] shl ecx,4 add cl,[esi+7] ; 0123456789ABCDEF01234567 ; 24bit encoded address: ijklqrstopabcduvwxefghmn ; abcdefghijklmnopqrstuvwx ; >8 >12 >6<10 >6 <14 <10 mov ebx,ecx and ebx,000000000011110000000000b ;abcd shl ebx,10 mov eax,ecx and eax,000000000000000000111100b ;efgh shl eax,14 add ebx,eax mov eax,ecx and eax,111100000000000000000000b ;ijkl shr eax,8 add ebx,eax mov eax,ecx and eax,000000000000000000000011b ;mn shl eax,10 add ebx,eax mov eax,ecx and eax,000000001100000000000000b ;op shr eax,6 add ebx,eax mov eax,ecx and eax,000011110000000000000000b ;qrst shr eax,12 add ebx,eax mov eax,ecx and eax,000000000000001111000000b ;uvwx shr eax,6 add ebx,eax xor ecx,ecx mov cx,bx shr ebx,16 test bl,40h jz .noover ; xor cx,8000h .noover mov al,[esi] shl al,4 add al,[esi+1] ; store into cheatdata mov edx,[NumCheats] shl edx,5 sub edx,[NumCheats] sub edx,[NumCheats] sub edx,[NumCheats] sub edx,[NumCheats] mov byte[cheatdata+edx],0 mov [cheatdata+edx+1],al mov [cheatdata+edx+2],cx mov [cheatdata+edx+4],bl push eax mov al,[guicheatvalrep] or [cheatdata+edx],al pop eax push ecx push eax push ebx push edx call dword near [memtabler8+ebx*4] pop edx mov byte[cheatdata+edx+5],al pop ebx pop eax pop ecx mov byte[writeon],1 test byte[cheatdata+edx],80h jnz .nowrite test byte[cheatdata+edx-28],80h jnz .nowrite call dword near [memtablew8+ebx*4] .nowrite mov byte[writeon],0 mov byte[CheatOn],1 inc byte[NumCheats] mov dword[GUICheatText9],0 mov dword[GUICheatTextA],0 mov byte[GUICheatPosA],0 mov byte[GUICheatPosB],0 mov dword[GUIcurrentcheatwin],1 mov eax,[NumCheats] dec eax mov [GUIcurrentcheatcursloc],eax sub eax,11 mov [GUIcurrentcheatviewloc],eax test dword[GUIcurrentcheatviewloc],80000000h jz .noview mov dword[GUIcurrentcheatviewloc],0 .noview ret .GG2Norm db 04h,06h,0Dh,0Eh,02h,07h,08h,03h,0Bh,05h,0Ch,09h,0Ah,00h,0Fh,01h decodepar: ; convert code to number format mov ecx,8 mov esi,GUICheatText9 .loopb mov al,[esi] cmp al,'A' jb .num sub al,'A' add al,10 jmp .let .num sub al,'0' .let mov [esi],al inc esi dec ecx jnz .loopb ; get address xor ebx,ebx xor ecx,ecx mov bl,[GUICheatText9] shl bl,4 add bl,[GUICheatText9+1] mov cl,[GUICheatText9+2] shl cx,4 add cl,[GUICheatText9+3] shl cx,4 add cl,[GUICheatText9+4] shl cx,4 add cl,[GUICheatText9+5] mov al,[GUICheatText9+6] shl al,4 add al,[GUICheatText9+7] ; store into cheatdata xor edx,edx mov dl,[NumCheats] push ebx mov ebx,edx shl edx,5 sub edx,ebx sub edx,ebx sub edx,ebx sub edx,ebx pop ebx mov byte[cheatdata+edx],0 mov [cheatdata+edx+1],al mov [cheatdata+edx+2],cx mov [cheatdata+edx+4],bl push eax mov al,[guicheatvalrep] or [cheatdata+edx],al pop eax push ecx push eax push ebx push edx call dword near [memtabler8+ebx*4] pop edx mov byte[cheatdata+edx+5],al pop ebx pop eax pop ecx mov byte[writeon],1 test byte[cheatdata+edx],80h jnz .nowrite test byte[cheatdata+edx-28],80h jnz .nowrite call dword near [memtablew8+ebx*4] .nowrite mov byte[writeon],0 mov byte[CheatOn],1 inc dword[NumCheats] mov dword[GUICheatText9],0 mov dword[GUICheatTextA],0 mov byte[GUICheatPosA],0 mov byte[GUICheatPosB],0 mov dword[GUIcurrentcheatwin],1 mov eax,[NumCheats] dec eax mov [GUIcurrentcheatcursloc],eax sub eax,11 mov [GUIcurrentcheatviewloc],eax test dword[GUIcurrentcheatviewloc],80000000h jz .noview mov dword[GUIcurrentcheatviewloc],0 .noview ret guicheaterror: xor ebx,ebx mov ecx,256+128+64 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a .again call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 75,95,192,143,160 GUIBox 75,95,192,95,162 GUIBox 75,95,75,143,161 GUIBox 192,95,192,143,159 GUIBox 75,143,192,143,158 GUIOuttext 81,101,guicheaterror1,220-15 GUIOuttext 80,100,guicheaterror1,220 GUIOuttext 81,109,guicheaterror2,220-15 GUIOuttext 80,108,guicheaterror2,220 GUIOuttext 81,117,guicheaterror3,220-15 GUIOuttext 80,116,guicheaterror3,220 GUIOuttext 81,125,guicheaterror4,220-15 GUIOuttext 80,124,guicheaterror4,220 GUIOuttext 81,135,guicheaterror5,220-15 GUIOuttext 80,134,guicheaterror5,220 call vidpastecopyscr call JoyRead xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b cmp byte[MouseDis],1 je .mousedis call Get_MouseData test bx,01h jnz .pressedokay .mousedis jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 mov dword[GUIcurrentcheatwin],1 mov byte[GUIpclicked],1 ret guicheaterror1 db 'INVALID CODE! YOU',0 guicheaterror2 db 'MUST ENTER A VALID',0 guicheaterror3 db 'GAME GENIE,PAR, OR',0 guicheaterror4 db 'GOLD FINGER CODE.',0 guicheaterror5 db 'PRESS ANY KEY.',0 guicheatvalrep db 0 zsnes-1.36/src/gui/gui.asm0100644000175000017500000036313007511720531015034 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Sorry. The GUI code is a total mess. One problem I encountered is that ; there seems to be a bug in nasm with using math calculations combined ; with macros within macros, so in some macro definitions, I had to ; add/subtract extra values in certain macros to get the GUI to align ; correctly. ; The GUI is drawn is mostly manually. What I mean is such as ; coding 5 boxes to represent a shaded box for each box. Although that ; can be simplified using macros to draw 5 boxes, that unknown bug in nasm ; showed up which prevented me from using macros extensively. I was ; thinking of changing it to an object-based GUI for easier coding, ; but that was decided far into the development of the GUI itself ; and that I also never expected this code to become open-source, so I ; decided not to proceed with it. ; Routine StartGUI is the function called to start the GUI and also ; contains the execution main loop of the GUI. If you want to completely ; replace the GUI, just add a function call from that function, then ; jump to endprog to exit ZSNES or continueprog to continue with the ; gameplay. Do not replace StartGUI with a function since it is not ; a function, but rather a label that is being jumped to. ; ************************************** ; GUI.ASM ; ************************************** ; ; Associated files : ; GUIWinDp.inc - Window Display Routines ; GUITools.inc - Misc routines for the GUI ; Quick Searches : ; DisplayMenu - routines to display top menu bar ; Incomp - Search for start of modem processing ; ProcessModem ; GUIgetcurrentinput ; GUITryMenuItem - Processes the menu item when user clicks item ; Mouseimplementation ; DGUIDisplayer ; LGUILoadData ; SetInputDevice ; CalibrateDev1 ; ButtonProcess - routines that processes boxed buttons ; CheatCodeSearchInit ; guiwincontrol %include "macros.mac" EXTSYM dssel, curblank, vidpastecopyscr, frameskip, newengen, vsyncon, cantinitmodem EXTSYM cvidmode, antienab, smallscreenon, smallscreence,NetQuit EXTSYM soundon, StereoSound, SoundCompD, SoundQuality, MusicRelVol,UartType EXTSYM endprog, continueprog, spcBuffera, spcRamcmp, cbitmode, makepal EXTSYM t1cc, LoadDir, SRAMDir, LoadDrive,SRAMDrive, initsnes, romloadskip EXTSYM fname, makeextension, sram, clearmem2, loadfileGUI, GUIloadfailed EXTSYM CheckROMType, romdata, ForcePal, ramsize, ramsizeand, curromsize EXTSYM romispal, totlines, cfgloadsdir, init65816, procexecloop EXTSYM spcRam, spcPCRam, spcS, spcRamDP, spcA, spcX, spcY, spcP, spcNZ EXTSYM Voice0Status, Voice1Status, Voice2Status, Voice3Status, Voice4Status EXTSYM Voice5Status, Voice6Status, Voice7Status, romtype, SetIRQVectors EXTSYM ClearScreen, statesaver, loadstate2, vidbuffer, ASCII2Font, hirestiledat EXTSYM showallext, ROMTypeNOTFound, scanlines,statefileloc,pl1selk,pl2selk EXTSYM fnamest,sprlefttot,spritetablea,fnames,SFXSRAM,sfxramdata,cgram,srama EXTSYM tempco0,prevbright,maxbr,prevpal,coladdr,coladdg,coladdb EXTSYM scaddtype,ScreenScale,vesa2red10,initvideo2,initvideo,pressed,UpdateDevices EXTSYM memtabler8,memtablew8,writeon,pl1contrl,pl2contrl,JoyRead,SetInputDevice EXTSYM SetInputDevice209,FPSOn,RevStereo,WDSPReg0C,WDSPReg1C,WDSPReg2C EXTSYM WDSPReg3C,pl12s34,resolutn,delay,chaton,chatstrL,chatLpos,chatstrR,chatRTL EXTSYM InitDrive,InitDir,createnewcfg,Makemode7Table,SnowOn,MovieBuffSize EXTSYM MovieBuffFrame,vidbufferofsb,ZipSupport,wramdata,bgfixer,cfgnewgfx EXTSYM cfgdontsave,videotroub,Open_File,Read_File,Close_File,Write_File,Create_File EXTSYM File_Seek,File_Seek_End,Open_File_Write,Get_Date,Check_Key,Get_Key EXTSYM Change_Drive,Change_Single_Dir,Change_Dir,Get_Dir,Get_First_Entry EXTSYM Get_Next_Entry,Set_DTA_Address,timer2upd,curexecstate,TripBufAvail EXTSYM nmiprevaddrl,nmiprevaddrh,nmirept,nmiprevline,nmistatus,spcnumread EXTSYM NextLineCache,VidStartDraw,ResetTripleBuf,GUINGVID EXTSYM ScanCodeListing,AdjustFrequency,GUISaveVars,Init_Mouse EXTSYM Get_MouseData,Set_MouseXMax,Set_MouseYMax,Set_MousePosition,Get_MousePositionDisplacement EXTSYM GUIInit,GUIDeInit,SpecialLine EXTSYM DrawWater,DrawSmoke,RemoteDisconnect,loadstate3 EXTSYM ModemClearBuffer,IPXSearchval EXTSYM ipxlookforconnect EXTSYM SA1Enable,SA1RAMArea EXTSYM GUIFName,GUICName EXTSYM printnum EXTSYM MMXCheck EXTSYM SaveCombFile EXTSYM NetSent,valuea EXTSYM welcome EXTSYM showinfogui EXTSYM BackupCVFrame EXTSYM Wait1SecWin,ClearUDPStuff EXTSYM DisableSUDPPacket,EnableSUDPPacket EXTSYM ModemGetChar EXTSYM BackStateSize EXTSYM ResetExecStuff EXTSYM RestoreCVFrame EXTSYM CurRecv,BackState,CBackupPos,PBackupPos,PPValue,DPValue,NetQuitter EXTSYM LatencyV EXTSYM LatencyRecvPtr,LatencySendPtr EXTSYM NumofBanks EXTSYM WinErrorA,WinErrorB,WinErrorC EXTSYM ErrorPointer EXTSYM MessageOn,Msgptr,MsgCount EXTSYM PJoyAOrig,PJoyBOrig,PJoyCOrig,PJoyDOrig,PJoyEOrig EXTSYM GetHostName EXTSYM vramaddr,curypos,ClearRegs,vram,sndrot,regsbackup EXTSYM GetScreen,GUITBWVID EXTSYM Clear2xSaIBuffer EXTSYM MouseWindow EXTSYM GotoHomepage EXTSYM cfgcvidmode, ExitFromGUI EXTSYM GUIWFVID EXTSYM cfgvsync,newgfx16b EXTSYM cfgscanline,cfginterp EXTSYM NumVideoModes EXTSYM cfgvolume, MusicVol, DSPMem EXTSYM NumInputDevices,GUIInputNames EXTSYM GUIVideoModeNames EXTSYM GUISLVID,GUIINVID,GUIEAVID,GUIIEVID,GUIFSVID,GUIWSVID EXTSYM GUISSVID,GUITBVID,GUIHSVID,GUI2xVID,GUII2VID,GUIM7VID EXTSYM cfgsoundon,cfgSoundQuality,cfgStereoSound,cfgforce8b EXTSYM Force8b,convertnum,converthex EXTSYM per2exec EXTSYM hostname EXTSYM UDPConfig EXTSYM DeInitModem EXTSYM snesmouse EXTSYM pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Lk,pl1Rk,pl1Ak,pl1Bk EXTSYM deinitipx EXTSYM InitModem EXTSYM outofmemfix,yesoutofmemory EXTSYM CReadHead,ReadHead,CFWriteHead,CFWriteStart EXTSYM JoyX,JoyY,JoyMinX,JoyMinY,JoyMaxX,JoyMaxY,JoyMinX209,JoyMaxX209 EXTSYM JoyMinY209,JoyMaxY209,GetCoords,GetCoords3 EXTSYM MultiTap,SFXEnable EXTSYM RestoreSystemVars EXTSYM TCPIPStartServer EXTSYM TCPIPInitConnectToServer EXTSYM TCPIPWaitForConnection EXTSYM tcperr EXTSYM TCPIPConnectToServer EXTSYM TCPIPConnectToServerW EXTSYM initipx EXTSYM selc0040 EXTSYM ModemCheckRing EXTSYM ModemCheckDCD EXTSYM PreparePacketIPX,TCPIPPreparePacket EXTSYM SendPacketIPX,TCPIPSendPacket,TCPIPSendPacketUDP EXTSYM TCPIPDisconnect,TCPIPStatus EXTSYM DeInitModemC EXTSYM ipxgetchar,ipxsendchar,TCPIPStoreByte EXTSYM TCPIPGetByte,GUIBIFIL EXTSYM ModemSendChar EXTSYM firstsaveinc EXTSYM nssdip1,nssdip2,nssdip3,nssdip4,nssdip5,nssdip6 %ifdef __LINUX__ EXTSYM numlockptr %endif NEWSYM GuiAsmStart %include "gui/guitools.inc" %include "gui/guimisc.inc" %include "gui/guimouse.inc" %include "gui/guiwindp.inc" %include "gui/guinetpl.inc" %include "gui/guikeys.inc" %include "gui/guicheat.inc" %include "gui/guicombo.inc" %include "gui/guiload.inc" ; ProcessRemoteCommand ; NetLoadStuff ; Send 14 to initiate, Send 15 to cancel (either way) ; call PreparePacket ; mov al,253 ; call RemoteSendChar ; call SendPacket ; NetAddChar NEWSYM WaterOn, db 1 ; Things to do : ; ; .checkmenuboxclick ; gray scale = 32 .. 63 ; shadow = 96 .. 127 ; blue scale = 148 .. 167, 168 .. 187 ; gray scale = 189 .. 220 (32+137) ; | Game Config Cheat MultiPlay Misc ;------------------------------------------------------- ; Load Input#1 Add Code Modem Game Keys ; Run Input#2 Browse IPX GUI Opns ; Reset Input#3 Search About ; ----- Input#4 ; Save State ------- ; Load State Options ; Chose State Video ; ----- Sound ; Quit ; Windows : 1 = Save/Load Confirmation ; 2 = Chose State ; 3 = Input Device Window ; 4 = Options ; 5 = Video ; 6 = Sound ; 7 = Cheat ; 8 = IPX/Modem ; 9 = GameOptions ; 10 = GUI Options ; 11 = About MenuDat1 db 12,3,1,1,1,1,1,1,1,1,1,0,1,2,0 MenuDat2 db 8, 3,1,1,0,1,1,1,0,2,0,0 MenuDat3 db 10, 3,1,1,1,1,0,1,0,1,1,2,0 MenuDat4 db 2, 3,1,2,0 MenuDat5 db 1, 3,2,0 MenuDat6 db 6, 3,1,1,1,1,0,2,0 GUIPrevMenuData db 1,'1. ',0 db 1,'2. ',0 db 1,'3. ',0 db 1,'4. ',0 db 1,'5. ',0 db 1,'6. ',0 db 1,'7. ',0 db 1,'8. ',0 db 1,'9. ',0 db 1,'0. ',0 db 0,'------------',0 .onoff db 1,'FREEZE DATA : OFF ',0 db 1,'CLEAR ALL DATA ',0 GUIGameMenuData db 1,'LOAD ',0 db 1,'RUN [ESC] ',0 db 1,'RESET ',0 db 0,'------------',0 db 1,'SAVE STATE ',0 db 1,'OPEN STATE ',0 db 1,'PICK STATE ',0 db 0,'------------',0 db 1,'QUIT ',0 GUIConfigMenuData db 1,'INPUT #1 ',0 db 1,'INPUT #2 ',0 db 1,'INPUT #3 ',0 db 1,'INPUT #4 ',0 db 1,'INPUT #5 ',0 db 0,'------------',0 db 1,'ADD-ONS ',0 db 0,'------------',0 db 1,'OPTIONS ',0 db 1,'VIDEO ',0 db 1,'SOUND ',0 GUICheatMenuData db 1,'ADD CODE ',0 db 1,'BROWSE ',0 db 1,'SEARCH ',0 GUINetPlayMenuData db 1,'MODEM ',0 db 1,'IPX ',0 GUIMiscMenuData db 1,'GAME KEYS ',0 db 1,'GUI OPNS ',0 db 1,'MOVIE OPN ',0 db 1,'KEY COMB. ',0 db 1,'SAVE CFG ',0 db 0,'------------',0 db 1,'ABOUT ',0 ; Config, Options -> New Gfx Engine, Frame Rate, Fast Forward FrameRate, etc. ; Config, Video -> Video Mode, Interpolation, etc. ; Config, Options -> Set up Save and/or Load State Confirmation ; Select Different game key assignments ; If menu should go to Load or last position when ESC ; is pressed from game GUIRAdd db 15 GUIGAdd db 10 GUIBAdd db 31 mousewrap db 0 ; 0 = mouse boundries, 1 = mouse wrap mouseshad db 1 ; 0 = no mouse shadow, 1 = mouse shadow lastcursres db 0 ; 0 = go to load, 1 = go to previous menu, 2 = no menu resetposn db 1 ; 0 = no window reset, 1 = window reset NEWSYM GUIClick, db 0 ; 1 = mouse click enters/exits gui GUIwinposx2 dd 0,5 ,60 ,30 ,55 ,50 ,65 ,5 ,30 ,20 ,10 ,80 ,65 ,20 ,70 ,50 ,3 ,0 GUIwinposy2 dd 0,20 ,70 ,30 ,20 ,22 ,36 ,20 ,30 ,20 ,40 ,70 ,60 ,30 ,65 ,50 ,22 ,0 ; Default keys ; Sound Channels 0 .. 7, Save/Select/Load States, Fast Forward ; Exit, Load, Reset, BG Disables, Reset, Windowing, New Gfx, OffsetMode ; State Selection 0 .. 9 NEWSYM KeyDisableSC0, dd 63 NEWSYM KeyDisableSC1, dd 64 NEWSYM KeyDisableSC2, dd 65 NEWSYM KeyDisableSC3, dd 66 NEWSYM KeyDisableSC4, dd 67 NEWSYM KeyDisableSC5, dd 68 NEWSYM KeyDisableSC6, dd 87 NEWSYM KeyDisableSC7, dd 88 NEWSYM KeySaveState, dd 60 NEWSYM KeyStateSelct, dd 61 NEWSYM KeyLoadState, dd 62 NEWSYM KeyFastFrwrd, dd 41 NEWSYM KeyQuickExit, dd 0 NEWSYM KeyQuickLoad, dd 0 NEWSYM KeyQuickRst, dd 0 NEWSYM KeyBGDisble0, dd 2 NEWSYM KeyBGDisble1, dd 3 NEWSYM KeyBGDisble2, dd 4 NEWSYM KeyBGDisble3, dd 5 NEWSYM KeySprDisble, dd 6 NEWSYM KeyResetAll, dd 7 NEWSYM KeyExtraEnab, dd 8 NEWSYM KeyNewGfxSwt, dd 9 NEWSYM KeyWinDisble, dd 10 NEWSYM KeyOffsetMSw, dd 11 NEWSYM KeyStateSlc0, dd 0 NEWSYM KeyStateSlc1, dd 0 NEWSYM KeyStateSlc2, dd 0 NEWSYM KeyStateSlc3, dd 0 NEWSYM KeyStateSlc4, dd 0 NEWSYM KeyStateSlc5, dd 0 NEWSYM KeyStateSlc6, dd 0 NEWSYM KeyStateSlc7, dd 0 NEWSYM KeyStateSlc8, dd 0 NEWSYM KeyStateSlc9, dd 0 GUIshowallext db 0 GUIloadfntype db 0 NEWSYM pl3selk, dd 0 ; 3SELECT = SHIFT NEWSYM pl3startk, dd 0 ; 3START = ENTER NEWSYM pl3upk, dd 0 ; 3UP = up NEWSYM pl3downk, dd 0 ; 3DOWN = down NEWSYM pl3leftk, dd 0 ; 3LEFT = left NEWSYM pl3rightk, dd 0 ; 3RIGHT = right NEWSYM pl3Xk, dd 0 ; 3X = INS NEWSYM pl3Ak, dd 0 ; 3A = HOME NEWSYM pl3Lk, dd 0 ; 3L = PAGE UP NEWSYM pl3Yk, dd 0 ; 3Y = DELETE NEWSYM pl3Bk, dd 0 ; 3B = END NEWSYM pl3Rk, dd 0 ; 3R = PAGE DOWN NEWSYM pl4selk, dd 0 ; 4SELECT = SHIFT NEWSYM pl4startk, dd 0 ; 4START = ENTER NEWSYM pl4upk, dd 0 ; 4UP = up NEWSYM pl4downk, dd 0 ; 4DOWN = down NEWSYM pl4leftk, dd 0 ; 4LEFT = left NEWSYM pl4rightk, dd 0 ; 4RIGHT = right NEWSYM pl4Xk, dd 0 ; 4X = INS NEWSYM pl4Ak, dd 0 ; 4A = HOME NEWSYM pl4Lk, dd 0 ; 4L = PAGE UP NEWSYM pl4Yk, dd 0 ; 4Y = DELETE NEWSYM pl4Bk, dd 0 ; 4B = END NEWSYM pl4Rk, dd 0 ; 4R = PAGE DOWN NEWSYM TimeChecker, db 0 ; Future Reserved GUISoundBuffer db 1 ; Sound Buffer Disabled prevloadnames times 16*10 db 32 prevloaddname times 128*10 db 0 prevloadfname times 16*10 db 32 prevlfreeze db 0 GUIsmallscreenon db 0 GUIScreenScale db 0 NEWSYM pl3contrl, db 0 NEWSYM pl4contrl, db 0 NEWSYM pl1p209b, db 0 NEWSYM pl2p209b, db 0 NEWSYM pl3p209b, db 0 NEWSYM pl4p209b, db 0 JoyPad1Move db 0 NEWSYM FirstTimeData, db 0 NEWSYM PrevSWFix, db 0 NEWSYM CalibXmin, dd 0 NEWSYM CalibYmin, dd 0 NEWSYM CalibXmax, dd 0 NEWSYM CalibYmax, dd 0 NEWSYM CalibXmin209, dd 0 NEWSYM CalibYmin209, dd 0 NEWSYM CalibXmax209, dd 0 NEWSYM CalibYmax209, dd 0 NEWSYM maxskip, db 9 NEWSYM FPSAtStart, db 0 NEWSYM SidewinderFix, db 0 GUIInitSt1 db 'ATZ' .rest times 47 db 0 GUIInitSt2 db 'AT S0=0' .rest times 43 db 0 GUIDialSt db 'ATDT ',0 NEWSYM ComNum, db 2 NEWSYM ComIRQ, db 3 NEWSYM BaudRate, dd 3 NEWSYM pl1Atk, dd 0 ; Turbo A NEWSYM pl1Btk, dd 0 ; Turbo B NEWSYM pl1Xtk, dd 0 ; Turbo X NEWSYM pl1Ytk, dd 0 ; Turbo Y NEWSYM pl2Atk, dd 0 ; Turbo A NEWSYM pl2Btk, dd 0 ; Turbo B NEWSYM pl2Xtk, dd 0 ; Turbo X NEWSYM pl2Ytk, dd 0 ; Turbo Y NEWSYM pl3Atk, dd 0 ; Turbo A NEWSYM pl3Btk, dd 0 ; Turbo B NEWSYM pl3Xtk, dd 0 ; Turbo X NEWSYM pl3Ytk, dd 0 ; Turbo Y NEWSYM pl4Atk, dd 0 ; Turbo A NEWSYM pl4Btk, dd 0 ; Turbo B NEWSYM pl4Xtk, dd 0 ; Turbo X NEWSYM pl4Ytk, dd 0 ; Turbo Y NEWSYM Turbo30hz, db 0 ; Turbo at 30hz instead of 60hz NEWSYM KeyVolUp, dd 0 NEWSYM KeyVolDown, dd 0 NEWSYM KeyFRateUp, dd 0 NEWSYM KeyFRateDown, dd 0 NEWSYM KeyQuickChat, dd 20 NEWSYM FossilUse, db 0 NEWSYM TimerEnable, db 0 NEWSYM Surround, db 0 NEWSYM InterSound, db 1 NEWSYM FastFwdToggle, db 0 NEWSYM En2xSaI, db 0 NEWSYM AutoLoadCht, db 0 NEWSYM KeyQuickSnapShot, dd 0 CheatSrcByteSize db 0 CheatSrcByteBase db 0 CheatSrcSearchType db 0 CheatUpperByteOnly db 0 NEWSYM SRAMSave5Sec, db 0 NEWSYM ReInitSoundC, db 0 NEWSYM OldGfxMode2 , db 0 NEWSYM PitchModEn , db 0 NEWSYM LatestSave , db 0 NEWSYM AutoState , db 0 NEWSYM OldVolume , db 1 NEWSYM BlankVar , db 1 NEWSYM pl1ULk, dd 0 NEWSYM pl1URk, dd 0 NEWSYM pl1DLk, dd 0 NEWSYM pl1DRk, dd 0 NEWSYM pl2ULk, dd 0 NEWSYM pl2URk, dd 0 NEWSYM pl2DLk, dd 0 NEWSYM pl2DRk, dd 0 NEWSYM pl3ULk, dd 0 NEWSYM pl3URk, dd 0 NEWSYM pl3DLk, dd 0 NEWSYM pl3DRk, dd 0 NEWSYM pl4ULk, dd 0 NEWSYM pl4URk, dd 0 NEWSYM pl4DLk, dd 0 NEWSYM pl4DRk, dd 0 NEWSYM LowPassFilterType, db 0 NEWSYM DontSavePath, db 0 NEWSYM ReCalib, db 1 NEWSYM GUIComboGameSpec, db 0 NEWSYM SoundNoiseDis, db 0 ; Disable Noise NEWSYM Triplebufen, db 0 NEWSYM SoundBufEn, db 0 NEWSYM SPCDisable, db 0 NEWSYM RaisePitch, db 0 prevloadl db 0 prevloaddnamel times 512*10 db 0 prevloadfnamel times 512*10 db 0 %ifdef __WIN32__ NEWSYM PrevWinMode, db 2 NEWSYM PrevFSMode, db 6 %elifdef __LINUX__ NEWSYM PrevWinMode, db 2 NEWSYM PrevFSMode, db 3 %else NEWSYM PrevWinMode, db 0 NEWSYM PrevFSMode, db 0 %endif OldWinPos db 0 GUIwinposx dd 0,5 ,60 ,30 ,55 ,50 ,65 ,5 ,30 ,20 ,10 ,80 ,65 ,20 ,70 ,50 ,3 ,50 GUIwinposxexp times 30 dd 0 GUIwinposy dd 0,20 ,70 ,30 ,20 ,22 ,36 ,20 ,30 ,20 ,30 ,70 ,60 ,30 ,65 ,50 ,22 ,60 GUIwinposyexp times 30 dd 0 NEWSYM GUIEffect, db 0 NEWSYM pl5selk, dd 0 ; 4SELECT = SHIFT NEWSYM pl5startk, dd 0 ; 4START = ENTER NEWSYM pl5upk, dd 0 ; 4UP = up NEWSYM pl5downk, dd 0 ; 4DOWN = down NEWSYM pl5leftk, dd 0 ; 4LEFT = left NEWSYM pl5rightk, dd 0 ; 4RIGHT = right NEWSYM pl5Xk, dd 0 ; 4X = INS NEWSYM pl5Ak, dd 0 ; 4A = HOME NEWSYM pl5Lk, dd 0 ; 4L = PAGE UP NEWSYM pl5Yk, dd 0 ; 4Y = DELETE NEWSYM pl5Bk, dd 0 ; 4B = END NEWSYM pl5Rk, dd 0 ; 4R = PAGE DOWN NEWSYM pl5ULk, dd 0 NEWSYM pl5URk, dd 0 NEWSYM pl5DLk, dd 0 NEWSYM pl5DRk, dd 0 NEWSYM pl5Atk, dd 0 ; Turbo A NEWSYM pl5Btk, dd 0 ; Turbo B NEWSYM pl5Xtk, dd 0 ; Turbo X NEWSYM pl5Ytk, dd 0 ; Turbo Y NEWSYM pl5contrl, db 0 NEWSYM pl1p209, db 0 NEWSYM pl2p209, db 0 NEWSYM pl3p209, db 0 NEWSYM pl4p209, db 0 NEWSYM pl5p209, db 0 NEWSYM GUIEnableTransp, db 0 NEWSYM Mode7HiRes16b, dd 0 NEWSYM NewEngEnForce, db 1 NEWSYM KeyRewind, dd 0 NEWSYM ChatNick, times 16 db 0 NEWSYM KeySlowDown, dd 0 NEWSYM UseCubicSpline, db 1 NEWSYM LargeSoundBuf, db 0 NEWSYM HighPriority, db 0 NEWSYM AlwaysOnTop, db 0 NEWSYM SaveMainWindowPos, db 1 NEWSYM MainWindowX, dw -1 NEWSYM MainWindowY, dw -1 NEWSYM ScreenShotFormat, db 0 NEWSYM pl1Ltk, dd 0 ; Turbo L NEWSYM pl1Rtk, dd 0 ; Turbo R NEWSYM pl2Ltk, dd 0 ; Turbo L NEWSYM pl2Rtk, dd 0 ; Turbo R NEWSYM pl3Ltk, dd 0 ; Turbo L NEWSYM pl3Rtk, dd 0 ; Turbo R NEWSYM pl4Ltk, dd 0 ; Turbo L NEWSYM pl4Rtk, dd 0 ; Turbo R NEWSYM pl5Ltk, dd 0 ; Turbo L NEWSYM pl5Rtk, dd 0 ; Turbo R NEWSYM GUITRAdd, db 0 NEWSYM GUITGAdd, db 10 NEWSYM GUITBAdd, db 31 NEWSYM GUIWRAdd, db 8 NEWSYM GUIWGAdd, db 8 NEWSYM GUIWBAdd, db 25 NEWSYM GrayscaleMode, db 0 NEWSYM MouseWheel, db 1 NEWSYM AlternateTimer, db 0 NEWSYM AllowMultipleInst, db 0 NEWSYM FilteredGUI, db 0 NEWSYM BilinearFilter, db 0 NEWSYM TripleBufferWin, db 0 NEWSYM ExclusiveSound, db 0 NEWSYM DisableScreenSaver, db 0 NEWSYM MMXSupport, db 1 NEWSYM TrapMouseCursor, db 1 NEWSYM KeyQuickClock, dd 0 NEWSYM KeyQuickSaveSPC, dd 0 NEWSYM AutoIncSaveSlot, db 0 NEWSYM TCPIPAddress, times 29 db 0 NEWSYM SoundInterpType, db 2 NEWSYM KeyDisplayFPS, dd 0 NEWSYM KeyIncStateSlot, dd 0 NEWSYM KeyDecStateSlot, dd 0 GUIsave equ $-GUIRAdd NEWSYM ForceROMTiming, db 0 NEWSYM ForceHiLoROM, db 0 NEWSYM CombinDataGlob, times 3300 db 0 ; 20-name, 42-combo, 2-key#, 1-P#, 1-ff NEWSYM CombinDataLocl, times 3300 db 0 NEWSYM CmdLineNetPlay, db 0 NEWSYM CmdLineTCPIPAddress, times 29 db 0 GUIwinorder times 18 db 0 GUIwinpos times 18 db 0 GUIwinactiv times 18 db 0 DialNumber times 40 db 0 ViewBuffer times 50*32 db 0 NEWSYM ModemInitStat, db 0 ModemProcess db 0 ; Shows current dial/answer process ModemPTimer dd 0 ; Timer for modem process ModemOKStat db 0 ; OK is detected on modem status ; LOAD STAT INPT OPT VID SND CHT NET GMKEY GUIOP ABT RSET SRC STCN MOVE CMBO ADDO GUIwinposxo dd 0,5 ,60 ,30 ,55 ,50 ,35 ,5 ,30 ,10 ,10 ,50 ,65 ,20 ,70 ,50 ,3 ,50 GUIwinposyo dd 0,20 ,70 ,30 ,20 ,20 ,20 ,20 ,30 ,20 ,20 ,20 ,60 ,30 ,65 ,50 ,22 ,60 GUIwinsizex dd 0,244 ,126 ,189 ,167 ,170 ,188 ,244 ,8*16,235 ,240 ,190 ,9*16,8*16,9*16,140 ,250 ,160 GUIwinsizey dd 0,190 ,3*16,166 ,190 ,192 ,188 ,191 ,40 ,189 ,150 ,190 ,42 ,40 ,42 ,70 ,190 ,100 GUIwinptr db 0 GUItextcolor db 0,0,0,0,0 GUIcmenupos db 0 GUIescpress db 0 GUIcwinpress db 0 GUIpmenupos db 0 GUIcrowpos dd 0 GUIpclicked db 0 GUImouseposx dd 0 GUImouseposy dd 0 GUICYLocPtr dd 0 GUIMenuL dd 0 GUIMenuR dd 0 GUIMenuD dd 0 GUIOnMenuItm db 0 NEWSYM GUIQuit, db 0 GUIHold db 0 GUIHoldx dd 0 GUIHoldy dd 0 GUIHoldxm dd 0 GUIHoldym dd 0 GUIcolscaleval dd 0 cwindrawn db 0 GUIWincol dd 0 GUIWincoladd dd 0 GUITemp dd 0 GUIHoldXlimL dd 0 GUIHoldXlimR dd 0 GUIHoldYlim dd 0 GUIHoldYlimR dd 0 cloadnpos dd 0 cloadnposb dd 0 cloadmaxlen dd 0 cloadnleft dd 0 cplayernum db 0 vbuflimtop dd 0 vbuflimbot dd 0 GUIScrolTim1 dd 0 GUIScrolTim2 dd 0 GUICHold dd 0 GUICBHold dd 0 GUICBHold2 dd 0 GUIDClickTL dd 0 GUIDClCWin dd 0 GUIDClCEntry dd 0 GUICResetPos dd 0 GUICStatePos dd 0 GUICCFlash db 0 GUILDFlash db 0 GUIPalConv dd 0 PrevResoln dw 0 SnowMover dd 0 keycontrolval dd 0 NEWSYM CheatBDoor, db 0 NEWSYM ShowTimer, db 0 NEWSYM MousePRClick, db 0 NEWSYM MouseDis, db 0 NEWSYM NetPlayNoMore, db 0 RestoreValues db 0 NEWSYM NetChatFirst, db 0 NEWSYM NetServer, db 0 NEWSYM NetQuitAfter, db 0 NEWSYM NetNewNick, times 16 db 0 NEWSYM NetFilename, times 512 db 0 NEWSYM CheatOn, dd 0 NEWSYM NumCheats, dd 0 NEWSYM cheatdataprev, times 28 db 0 ; leave contents blank NEWSYM cheatdata, times 28*255+56 db 0 ; toggle, value, address, pvalue, name(22) NEWSYM GUIcurrentdir, times 131 db 0 numdrives dd 26 curgsval db 0 SubPalTable times 256 db 1 ; Corresponding Gray Scale Color WhichRemote dd 0 ; Modem = 1, IPX = 2, TCP/IP = 4 Connected dd 0 IDCheckPos dd 0 NEWSYM pl1neten, db 0 NEWSYM pl2neten, db 0 NEWSYM pl3neten, db 0 NEWSYM pl4neten, db 0 NEWSYM pl5neten, db 0 NEWSYM cnetplaybuf, times 512 db 0 NEWSYM cnetptrhead, dd 0 NEWSYM cnetptrtail, dd 0 NEWSYM prevp1net, dd 0 NEWSYM prevp2net, dd 0 NEWSYM prevp3net, dd 0 NEWSYM prevp4net, dd 0 NEWSYM prevp5net, dd 0 NEWSYM netdelayed, db 0 NEWSYM ChatProgress,dd 0 NEWSYM RecvProgress,dd 0 NEWSYM IPXInfoStr, dw 0 NEWSYM IPXInfoStrR, dw 0 NEWSYM GUICMessage, dd 0 NEWSYM GUICTimer, dd 0 NEWSYM GUIOn, db 0 NEWSYM GUIOn2, db 0 NEWSYM GUIReset, db 0 ;GOSPort db 0 NEWSYM CurPalSelect, db 0 NEWSYM StartLL, dd 0 NEWSYM StartLR, dd 0 NEWSYM LatencyVal, times 32 db 0 NEWSYM NetLoadState, db 0 NEWSYM TRVal, dw 0 NEWSYM TGVal, dw 0 NEWSYM TBVal, dw 0 NEWSYM TRVali, dw 0 NEWSYM TGVali, dw 0 NEWSYM TBVali, dw 0 NEWSYM TRVal2, dw 0 NEWSYM TGVal2, dw 0 NEWSYM TBVal2, dw 0 %macro stim 0 %ifdef __MSDOS__ sti %endif %endmacro %macro clim 0 %ifdef __MSDOS__ cli %endif %endmacro clearsram: push eax push ecx mov eax,srama mov ecx,65536 .loop mov byte[eax],0FFh inc eax dec ecx jnz .loop cmp byte[SFXSRAM],0 je .nosfxsram mov eax,[sfxramdata] mov ecx,65536 .loop2 mov byte[eax],0FFh inc eax dec ecx jnz .loop2 .nosfxsram cmp byte[SA1Enable],1 jne .nosa1 mov eax,[SA1RAMArea] mov ecx,65536*2 .loop3 mov byte[eax],0FFh inc eax dec ecx jnz .loop3 .nosa1 pop ecx pop eax ret GUIQuickLoadUpdate: cmp byte[prevlfreeze],0 je .off mov byte[GUIPrevMenuData.onoff+15],'O' mov byte[GUIPrevMenuData.onoff+16],'N' mov byte[GUIPrevMenuData.onoff+17],' ' jmp .on .off mov byte[GUIPrevMenuData.onoff+15],'O' mov byte[GUIPrevMenuData.onoff+16],'F' mov byte[GUIPrevMenuData.onoff+17],'F' .on mov esi,prevloadfnamel %ifdef __MSDOS__ mov esi,prevloadnames %endif mov edi,GUIPrevMenuData+3 mov edx,10 .mainloop mov ecx,25 %ifdef __MSDOS__ mov ecx,16 %endif push edi push esi cmp byte[esi],32 je near .fin2 .loop mov al,[esi] cmp al,0 je .zero mov [edi],al inc esi inc edi dec ecx jnz .loop cmp byte[esi],0 je .zero mov byte[edi],'.' mov byte[edi+1],'.' mov byte[edi+2],'.' jmp .fin .zero add ecx,3 .loop2 mov byte[edi],32 inc edi dec ecx jnz .loop2 jmp .fin .fin2 mov ecx,18 .loop3 mov byte[edi],32 inc edi dec ecx jnz .loop3 .fin pop esi pop edi add esi,512 ;16 %ifdef __MSDOS__ sub esi,512-16 %endif add edi,32 dec edx jnz near .mainloop ret CalcChecksum: mov eax,GUIRAdd mov ecx,100 xor edx,edx xor ebx,ebx .loop mov bl,[eax] add edx,ebx inc eax dec ecx jnz .loop mov ebx,edx xor bx,1011001011101101b xor eax,eax test bh,08h jz .nb mov al,1 .nb and bh,0F7h test bl,10h jz .nb2 or bh,08h .nb2 and bl,0EFh test al,1 jz .nb3 or bl,10h .nb3 xor bl,bh or bl,80h ret NEWSYM GUIRestoreVars mov edx,GUIFName call Open_File jc .fail mov bx,ax mov edx,GUIRAdd mov ecx,GUIsave call Read_File call Close_File .fail mov al,[GUIsmallscreenon] mov [smallscreenon],al mov al,[GUIScreenScale] mov [ScreenScale],al cmp byte[CmdLineNetPlay],0 je .nocmdlinenetplay mov ecx,28/4 mov esi,CmdLineTCPIPAddress mov edi,TCPIPAddress .netplayloop mov eax,[esi] add esi,byte 4 mov [edi],eax add edi,byte 4 dec ecx jnz .netplayloop xor eax,eax .nocmdlinenetplay call CalcChecksum cmp byte[TimeChecker],bl jne .nottimer mov byte[ShowTimer],1 mov dword[NumSnow],200 mov dword[SnowTimer],0 .nottimer cmp byte[ReCalib],0 je .nocal mov byte[ReCalib],0 mov dword[CalibXmin],0 mov dword[CalibXmax],0 mov dword[CalibYmin],0 mov dword[CalibYmax],0 mov dword[CalibXmin209],0 mov dword[CalibXmax209],0 mov dword[CalibYmin209],0 mov dword[CalibYmax209],0 .nocal mov dword[NumComboGlob],0 mov edx,GUICName call Open_File jc .failb mov bx,ax mov edx,ComboBlHeader mov ecx,23 call Read_File mov al,byte[ComboBlHeader+22] or al,al jz .done mov [NumComboGlob],al mov ecx,[NumComboGlob] mov edx,ecx shl ecx,6 add ecx,edx add ecx,edx mov edx,CombinDataGlob call Read_File .done call Close_File .failb ret SECTION .data NEWSYM ComboHeader, db 'Key Combination File',26,1,0 NEWSYM ComboBlHeader, times 23 db 0 SECTION .text NEWSYM ExecGUISaveVars cmp byte[ShowTimer],1 jne .nottimer call CalcChecksum mov byte[TimeChecker],bl .nottimer cmp byte[cfgdontsave],1 je .failed mov edx,GUIFName call Create_File jc .failed mov bx,ax mov edx,GUIRAdd mov ecx,GUIsave call Write_File call Close_File .failed mov al,[NumComboGlob] or al,al jz .failb mov [ComboHeader+22],al mov edx,GUICName call Create_File jc .failb mov bx,ax mov edx,ComboHeader mov ecx,23 call Write_File mov ecx,[NumComboGlob] mov edx,ecx shl ecx,6 add ecx,edx add ecx,edx mov edx,CombinDataGlob call Write_File call Close_File .failb ret %macro GUIInitIRQs 0 call GUIInit mov esi,pressed mov ecx,256 mov al,0 .loopa mov [esi],al inc esi dec ecx jnz .loopa %endmacro %macro GUIDeInitIRQs 0 call GUIDeInit %endmacro SECTION .data NEWSYM GUIoldhand9o, dd 0 NEWSYM GUIoldhand9s, dw 0 NEWSYM GUIoldhand8o, dd 0 NEWSYM GUIoldhand8s, dw 0 GUIt1cc dd 0 GUIt1ccSwap db 0 GUIskipnextkey42 db 0 SECTION .text NEWSYM GUIinit18_2hz mov al,00110110b out 43H,al mov ax,0 out 40H,al mov al,ah out 40H,al ret NEWSYM GUIinit36_4hz mov al,00110110b out 43H,al mov ax,32768 out 40H,al mov al,ah out 40H,al ret NEWSYM GUI36hzcall inc dword[GUIt1cc] inc dword[SnowMover] cmp dword[ModemPTimer],0 je .nodec5 dec dword[ModemPTimer] .nodec5 cmp dword[GUIEditStringLTxt],0 je .nodec dec dword[GUIEditStringLTxt] .nodec cmp dword[GUIScrolTim1],0 je .nodec4 dec dword[GUIScrolTim1] .nodec4 cmp dword[GUIDClickTL],0 je .nodec2 dec dword[GUIDClickTL] .nodec2 cmp dword[GUIkeydelay],0 je .nodec3 dec dword[GUIkeydelay] .nodec3 cmp dword[GUIkeydelay2],0 je .nodec3b dec dword[GUIkeydelay2] .nodec3b cmp dword[GUICTimer],0 je .nodec6 dec dword[GUICTimer] .nodec6 inc byte[GUICCFlash] and byte[GUICCFlash],0Fh inc byte[GUILDFlash] and byte[GUILDFlash],0Fh inc byte[GUINetTextm2+2] and byte[GUINetTextm2+2],0Fh ret NEWSYM GUIhandler8h cli push ds push eax mov ax,[cs:dssel] mov ds,ax call GUI36hzcall xor byte[GUIt1ccSwap],1 cmp byte[GUIt1ccSwap],0 je .nocall pushf call far [GUIoldhand8o] .nocall mov al,20h out 20h,al pop eax pop ds sti iretd NEWSYM GUIhandler9h cli push ds push eax push ebx mov ax,[cs:dssel] mov ds,ax xor ebx,ebx in al,60H ; get keyboard scan code cmp al,42 jne .no42 cmp byte[GUIskipnextkey42],0 je .no42 mov byte[GUIskipnextkey42],0 jmp .skipkeyrel .no42 cmp al,0E0h jne .noE0 mov byte[GUIskipnextkey42],1 jmp .skipkeyrel .noE0 mov byte[GUIskipnextkey42],0 mov bl,al xor bh,bh test bl,80h ; check if bit 7 is on (key released) jnz .keyrel cmp byte[pressed+ebx],0 jne .skipa mov byte[pressed+ebx],1 ; if not, set key to pressed .skipa jmp .skipkeyrel .keyrel and bl,7Fh mov byte[pressed+ebx],0 ; if not, set key to pressed .skipkeyrel mov byte[pressed],0 pushf call far [GUIoldhand9o] mov al,20h out 20h,al pop ebx pop eax pop ds sti iretd %macro loadmenuopen 1 mov al,[GUIcmenupos] mov [GUIpmenupos],al mov byte[GUIcmenupos],0 cmp byte[GUIwinactiv+%1],1 je %%menuontop xor eax,eax mov al,[GUIwinptr] inc byte[GUIwinptr] mov byte[GUIwinorder+eax],%1 mov byte[GUIwinactiv+%1],1 cmp byte[resetposn],1 jne %%nomenuitem mov eax,[GUIwinposxo+%1*4] mov [GUIwinposx+%1*4],eax mov eax,[GUIwinposyo+%1*4] mov [GUIwinposy+%1*4],eax jmp %%nomenuitem %%menuontop xor eax,eax ; look for match %%notfoundyet mov bl,byte[GUIwinorder+eax] cmp bl,%1 je %%nextfind inc eax jmp %%notfoundyet %%nextfind inc eax cmp al,[GUIwinptr] je %%foundend mov cl,[GUIwinorder+eax] mov [GUIwinorder+eax-1],cl jmp %%nextfind %%foundend mov byte[GUIpclicked],0 mov [GUIwinorder+eax-1],bl %%nomenuitem %endmacro loadnetopen: loadmenuopen 8 ret MouseInitOkay db 0 LoadDetermine: mov byte[GUIGameMenuData+14],1 mov byte[GUIGameMenuData+14*2],1 mov byte[GUIGameMenuData+14*4],1 mov byte[GUIGameMenuData+14*5],1 mov byte[GUIGameMenuData+14*6],1 mov byte[GUICheatMenuData],1 mov byte[GUICheatMenuData+14],1 mov byte[GUICheatMenuData+14*2],1 mov byte[GUIMiscMenuData+14*2],1 cmp byte[CheatBDoor],1 je .nomodem cmp byte[CNetType],21 je .modem cmp byte[CNetType],22 je .modem cmp byte[CNetType],20 jne .nomodem .modem mov byte[GUICheatMenuData],2 mov byte[GUICheatMenuData+14],2 mov byte[GUICheatMenuData+14*2],2 .nomodem cmp byte[romloadskip],0 je .noromloaded2 mov byte[GUIGameMenuData+14],2 mov byte[GUIGameMenuData+14*2],2 mov byte[GUIGameMenuData+14*4],2 mov byte[GUIGameMenuData+14*5],2 mov byte[GUIGameMenuData+14*6],2 mov byte[GUICheatMenuData],2 mov byte[GUICheatMenuData+14],2 mov byte[GUICheatMenuData+14*2],2 mov byte[GUIMiscMenuData+14*2],2 .noromloaded2 .noromloaded ret SECTION .data SantaData: db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 db 1,0,0,1,0,0,1,0,0,0,1,1,1,0,1,1 db 1,1,0,1,1,0,1,1,0,1,0,1,1,1,1,1 db 1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1 db 1,1,0,1,1,0,1,1,0,0,1,1,1,1,1,1 SantaPos dd 272 SantaNextT dd 36*15 NumSnow dd 0 NEWSYM SnowTimer, dd 36*30 MsgGiftLeft dd 0 SECTION .text DrawSnow: cmp byte[OkaySC],0 je near .nosanta cmp dword[MsgGiftLeft],0 je .nodec mov edx,20 mov ebx,210 mov byte[GUItextcolor],228 GUIOuttextwin .giftmsg .nodec mov esi,[vidbuffer] add esi,[SantaPos] add esi,60*288 mov edx,SantaData mov ebx,8 .sloop2 mov ecx,16 .sloop cmp byte[edx],0 je .transp mov byte[esi],0 .transp inc esi inc edx dec ecx jnz .sloop add esi,272 dec ebx jnz .sloop2 .nosanta mov esi,[vidbuffer] mov ecx,200 xor edx,edx .loop xor eax,eax mov al,[SnowData+edx*4+3] mov ebx,eax shl eax,8 shl ebx,5 add eax,ebx xor ebx,ebx mov bl,[SnowData+edx*4+1] add eax,ebx add eax,16 mov bl,[SnowVelDist+edx*2] and bl,03h add bl,228 test byte[SnowVelDist+edx*2],8 jz .nosnow mov byte[esi+eax],bl .nosnow inc edx dec ecx jnz .loop ; Change Snow Displacement Values .next cmp dword[SnowMover],0 je .nomore call ProcessSnowVelocity dec dword[SnowMover] jmp .next .nomore ret .giftmsg db 'A GIFT TO YOU IN THE OPTIONS!',0 ProcessSnowVelocity: cmp dword[MsgGiftLeft],0 je .nodec dec dword[MsgGiftLeft] .nodec cmp dword[NumSnow],200 jne .snowincr cmp dword[SantaNextT],0 je .skip dec dword[SantaNextT] jmp .notsreset .skip dec dword[SantaPos] cmp dword[SantaPos],0 jne .notsreset mov dword[SantaPos],272 mov dword[SantaNextT],36*60 jmp .notsreset .snowincr dec dword[SnowTimer] jnz .notsreset inc dword[NumSnow] mov dword[SnowTimer],18 .notsreset mov ecx,[NumSnow] cmp ecx,0 jne .okay ret .okay xor edx,edx .loop xor eax,eax mov al,[SnowVelDist+edx*2] mov ebx,100 sub bl,[MusicRelVol] add bx,bx add ax,bx add ax,bx add word[SnowData+edx*4],ax xor eax,eax mov al,[SnowVelDist+edx*2+1] add ax,256 add word[SnowData+edx*4+2],ax cmp word[SnowData+edx*4+2],200h ja .nosdata or byte[SnowVelDist+edx*2],8 .nosdata inc edx dec ecx jnz .loop ret OkaySC db 0 cstempfname db 'tmpchtsr.___',0 NEWSYM SaveSramData ; save sram cmp byte[sramsavedis],1 je .nosram cmp dword[ramsize],0 je .nosram clim xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx xor esi,esi xor edi,edi mov edx,fnames+1 call Create_File jc .failed mov bx,ax mov ecx,[ramsize] mov edx,[sram] call Write_File call Close_File .failed stim .nosram call SaveCombFile ret NEWSYM ProcRewind mov eax,KeyRewind add eax,4 mov ebx,8 .loop cmp byte[eax],'a' jb .b cmp byte[eax],'z' ja .b sub byte[eax],'a'-'A' .b inc eax dec ebx jnz .loop sub eax,8 ; 90,83,75,78,73,71 mov dword[.temp],44*65536*256+24*65536+72*256+40 mov word[.temp+4],41*256+50 add dword[.temp],34*65536*256+51*65536+11*256+50 add word[.temp+4],30*256+23 call .c ; 95,68,69,77,79,95 mov dword[.temp],25*65536*256+29*65536+31*256+62 mov word[.temp+4],43*256+18 add dword[.temp],52*65536*256+40*65536+37*256+33 add word[.temp+4],52*256+61 call .c ; 80,72,65,82,79,83 mov dword[.temp],11*65536*256+33*65536+24*256+35 mov word[.temp+4],52*256+30 add dword[.temp],71*65536*256+32*65536+48*256+45 add word[.temp+4],31*256+49 call .c ret .c mov ebx,[.temp] cmp [eax],ebx jne .noteq mov bx,[.temp+4] cmp [eax+4],bx jne .noteq mov dword[eax],0 mov dword[eax+4],0 mov dword[eax+8],0 .noteq ret .temp dd 0,0 %macro ProcessOneDigit 1 cmp dl,9 jbe %%notover add dl,65-48-10 %%notover add dl,48 mov byte[.message+%1],dl xor edx,edx div ebx %endmacro NEWSYM TestSent mov eax,[NetSent] xor edx,edx mov ebx,16 div ebx ProcessOneDigit 3 ProcessOneDigit 2 ProcessOneDigit 1 ProcessOneDigit 0 mov eax,[valuea] xor edx,edx mov ebx,16 div ebx ProcessOneDigit 8 ProcessOneDigit 7 ProcessOneDigit 6 ProcessOneDigit 5 mov dword[GUICMessage],.message mov dword[GUICTimer],100000 ret .message db 0,0,0,0,' ',0,0,0,0,0,0,0 NEWSYM StartGUI ; cmp byte[OSPort],1 ; jbe .dosport %ifndef __MSDOS__ mov byte[sampratenext+3],0 %endif cmp byte[TripBufAvail],0 jne .notexttb mov byte[Triplebufen],0 .notexttb cmp byte[MMXSupport],1 jne .2xSaIdis cmp byte[newgfx16b],0 je .2xSaIdis jmp .no2xSaIdis .2xSaIdis mov byte[En2xSaI],0 .no2xSaIdis cmp byte[En2xSaI],0 je .no2xsaidis mov byte[Triplebufen],0 .no2xsaidis cmp byte[En2xSaI],0 je .no2xsaien mov byte[scanlines],0 mov byte[antienab],0 .no2xsaien ;.dosport mov ecx,64 mov eax,SpecialLine .slloop mov dword[eax],0 add eax,4 dec ecx jnz .slloop cmp byte[OldWinPos],0 jne .okayow xor esi,esi mov ecx,17 .nextow mov eax,[GUIwinposx2+esi*4] mov [GUIwinposx+esi*4],eax mov eax,[GUIwinposy2+esi*4] mov [GUIwinposy+esi*4],eax inc esi dec ecx jnz .nextow mov byte[OldWinPos],1 mov eax,[pl1p209b] mov [pl1p209],eax .okayow %ifndef __MSDOS__ mov dword[GUINetPlayMenuData+1],'INTE' mov dword[GUINetPlayMenuData+5],'RNET' mov dword[GUINetPlayMenuData+1+14],'----' mov dword[GUINetPlayMenuData+5+14],'----' mov byte[MenuDat5],0 mov byte[MenuDat5+1],2 %endif ;.notwinport ; copy old quickfilename to new quickfilename cmp byte[prevloadl],0 jne .noconvertlfqm mov byte[prevloadl],1 mov ecx,10 xor edx,edx .convlfnlp mov eax,ecx dec eax mov edx,eax shl eax,9 shl edx,4 mov bl,16 .convlfnlp2 mov bh,[prevloadfname+edx] mov [prevloadfnamel+eax],bh inc edx inc eax dec bl jnz .convlfnlp2 mov eax,ecx dec eax mov edx,eax shl eax,9 shl edx,7 mov bl,128 .convlfnlp2b mov bh,[prevloaddname+edx] mov [prevloaddnamel+eax],bh inc edx inc eax dec bl jnz .convlfnlp2b dec ecx jnz .convlfnlp .noconvertlfqm mov byte[GUIOn],1 mov byte[GUIOn2],1 mov eax,[NumComboLocl] cmp byte[GUIComboGameSpec],0 jne .local mov eax,[NumComboGlob] .local mov [NumCombo],eax call ResetTripleBuf cmp dword[GUIwinposx+16*4],0 jne .notzero mov dword[GUIwinposx+16*4],3 mov dword[GUIwinposy+16*4],22 .notzero xor ecx,ecx .joysloop cmp dword[pl1ULk+ecx*4],80h jbe .nojoystick mov dword[pl1ULk+ecx*4],0 .nojoystick inc ecx cmp ecx,16 jne .joysloop mov dword[GUICTimer],0 cmp byte[OldVolume],1 jne .notold mov byte[OldVolume],0 mov byte[MusicRelVol],100 mov byte[cfgvolume],100 ; Initialize volume xor eax,eax xor edx,edx mov al,[MusicRelVol] shl eax,7 mov ebx,100 div ebx cmp al,127 jb .noofb mov al,127 .noofb mov [MusicVol],al .notold mov byte[CheatSearchStatus],0 cmp byte[newgfx16b],0 je .nong mov ecx,255*144 mov eax,[vidbufferofsb] .loop mov dword[eax],0 add eax,4 dec ecx jnz .loop .nong mov byte[ShowTimer],1 call Get_Date cmp dh,12 jne .noxmas cmp dl,25 jne .noxmas mov byte[OkaySC],1 .noxmas mov byte[lastmouseholded],1 cmp dword[GUIwinposx+15*4],0 jne .nomoviemenufix mov dword[GUIwinposx+15*4],50 mov dword[GUIwinposy+15*4],50 .nomoviemenufix mov ax,[resolutn] mov [PrevResoln],ax mov word[resolutn],224 mov byte[GUIPalConv],0 mov byte[MousePRClick],1 pushad cmp byte[MouseInitOkay],1 je near .mousedone mov byte[MouseInitOkay],1 cmp byte[MouseDis],1 je .mousedone call Init_Mouse cmp ax,0 jne .mousedone mov byte[MouseDis],1 .mousedone popad mov eax,[KeyQuickLoad] test byte[pressed+eax],1 jz near .noquickload mov byte[GUIcmenupos],0 loadmenuopen 1 .noquickload mov esi,pressed mov ecx,64+32+8 .pclear mov dword[esi],0 add esi,4 dec ecx jnz .pclear mov byte[pressed+1],2 mov byte[GUIescpress],1 ; set Video cursor location xor eax,eax mov al,[cvidmode] mov [GUIcurrentvideocursloc],eax mov ebx,[NumVideoModes] sub ebx,5 cmp eax,ebx jbe .noof mov eax,ebx .noof mov [GUIcurrentvideoviewloc],eax ; change to sram dir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir call SaveSramData cmp byte[SFXSRAM],0 je .nosfxsram clim mov edx,fnames+1 call Create_File jc .nosfxramwrite mov bx,ax mov ecx,65536 mov edx,[sfxramdata] call Write_File call Close_File .nosfxramwrite stim .nosfxsram call GUIQuickLoadUpdate call LoadDetermine ; change dir to LoadDrive/LoadDir mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir cmp byte[NetFilename],0 je near .nofilenamenet cmp byte[NetChatFirst],0 je near .filenamenetb mov ebx,NetFilename xor ecx,ecx .fnetloop cmp byte[ebx],'\' jne .fnetloopb mov ecx,ebx .fnetloopb inc ebx cmp byte[ebx],0 jne .fnetloop or ecx,ecx jz near .nofilenamenet mov byte[ecx],0 push ecx mov dl,[LoadDrive] cmp byte[NetFilename+1],':' jne .nodrivenetb mov dl,[NetFilename] sub dl,'A' .nodrivenetb mov ebx,NetFilename call Change_Dir pop ecx mov ebx,NetFilename inc ecx .nextnetl mov al,[ecx] mov [ebx],al inc ecx inc ebx or al,al jnz .nextnetl jmp .nofilenamenet .filenamenetb mov dl,[LoadDrive] cmp byte[NetFilename+1],':' jne .nodrivenet mov dl,[NetFilename] sub dl,'A' .nodrivenet mov ebx,NetFilename call Change_Dir mov byte[NetFilename],0 .nofilenamenet cmp byte[NetServer],0 je .noserverclient mov byte[CNetType],15 mov byte[ModemProcess],40 cmp byte[NetServer],2 jne .noclient mov byte[ModemProcess],41 .noclient mov byte[NetServer],0 mov byte[WhichRemote],4 mov byte[GUIcmenupos],0 mov byte[GUIcrowpos],0 call loadnetopen .noserverclient cmp byte[NetNewNick],0 je .nonewnick mov ebx,NetNewNick mov ecx,ChatNick .nickloop mov al,[ebx] mov [ecx],al inc ebx inc ecx or al,al jnz .nickloop mov byte[NetNewNick],0 .nonewnick ;NEWSYM NetChatFirst, db 0 ;NEWSYM NetServer, db 0 ;NEWSYM NetQuitAfter, db 0 ;NEWSYM NetNewNick, times 16 db 0 ;NEWSYM NetFilename, times 512 db 0 cmp byte[CNetType],20 je near .noautostate cmp byte[AutoState],0 je .noautostate cmp byte[romloadskip],0 jne .noautostate call SaveSecondState .noautostate GUIInitIRQs cmp byte[CNetType],20 jne near .nostat20 test byte[NetQuit],80h jnz near .nostat20 mov byte[GUIcmenupos],0 mov byte[GUIcrowpos],0 call loadnetopen cmp byte[WhichRemote],1 jne .yesdcd call ModemCheckDCD cmp al,1 jne near .nostat20 .yesdcd mov byte[RestoreValues],1 pushad mov dword[CBackupPos],0 call BackupCVFrame popad call DisableSUDPPacket call Wait1SecWin ; sync call PreparePacket mov al,254 call RemoteSendChar call SendPacket call PreparePacket mov al,254 call RemoteSendChar call SendPacket call PreparePacket mov al,254 call RemoteSendChar call SendPacket call PreparePacket mov al,254 call RemoteSendChar call SendPacket mov dword[ModemPTimer],4*32 .nochar pushad call JoyRead popad call RemoteGetChar cmp dword[ModemPTimer],0 je near .nostat20 cmp dh,0 je .nochar cmp dl,254 jne .nochar call PreparePacket mov al,253 call RemoteSendChar call SendPacket .nocharc pushad call JoyRead popad call RemoteGetChar cmp dword[ModemPTimer],0 je near .nostat20 cmp dh,0 je .nocharc cmp dl,253 jne .nocharc call PreparePacket mov al,1 call RemoteSendChar call SendPacket call ClearUDPStuff mov byte[RemoteCommand],1 mov byte[HoldCommand],1 cmp byte[NetLoadState],1 jne .notreceive mov byte[CNetType],22 .noreceivestate pushad call JoyRead popad call RemoteGetChar cmp dh,0 je .noreceivestate cmp dl,14 jne .noreceivestate call loadstaterecvinit .notreceive cmp byte[NetLoadState],2 jne .notsend call NetLoadStuff .notsend .nostat20 cmp byte[GUIwinptr],0 jne .nomenuopen cmp byte[lastcursres],1 je .nomenuchange mov byte[GUIcmenupos],2 mov byte[GUIcrowpos],0 mov dword[GUICYLocPtr],MenuDat2 cmp byte[lastcursres],0 je .nomenuchange .nomenuopen mov byte[GUIcmenupos],0 .nomenuchange cmp byte[GUIwinactiv+1],0 je .noloadrefresh call GetLoadData .noloadrefresh mov byte[GUIHold],0 ; clear 256 bytes from hirestiledat mov esi,hirestiledat mov ecx,256 .loophires mov byte[esi],0 inc esi dec ecx jnz .loophires mov byte[curblank],00h call InitGUI cmp byte[CheatWinMode],0 je near .csskip ; change to sram dir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir ; Load Cheat Search File mov edx,cstempfname call Open_File jc .csskipb mov bx,ax mov edx,[vidbuffer] add edx,129600 mov ecx,65536*2+32768 call Read_File call Close_File .csskipb ; change dir to LoadDrive/LoadDir mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir .csskip mov byte[GUIQuit],0 .nokey cmp byte[CNetType],21 je .noquit cmp byte[CNetType],22 jne .yesquit .noquit mov byte[GUIQuit],0 .yesquit cmp byte[GUIQuit],2 je near .exit cmp byte[GUIQuit],1 je near .exitgui mov byte[GUIQuit],0 cmp byte[MouseDis],1 je .mousedis2 call ProcessMouse cmp byte[videotroub],1 jne .notrouble ret .notrouble .mousedis2 call GUIUnBuffer cmp byte[CNetType],20 je .nowater cmp byte[CNetType],21 je .nowater cmp byte[CNetType],22 je .nowater cmp byte[GUIEffect],1 jne .nosnow call DrawSnow .nosnow cmp byte[GUIEffect],2 jne .nowater call DrawWater .nowater cmp byte[GUIEffect],3 jne .nowater2 call DrawWater .nowater2 cmp byte[GUIEffect],4 jne .nosmoke call DrawSmoke .nosmoke ; call TestSent cmp byte[CNetType],20 jne .noreceive cmp byte[NetChatFirst],0 je .noloadbeforechat mov eax,NetFilename call GUIloadfilename.nocnettype mov byte[sramsavedis],1 call transfersram mov byte[NetChatFirst],0 .noloadbeforechat cmp byte[GUIcmenupos],0 jne .nomenuout2 cmp byte[GUIwinptr],0 jne .nomenuout2 cmp byte[netlastloaded],1 je .openmenu mov byte[GUIcmenupos],2 mov byte[GUIcrowpos],0 jmp .nomenuout2 .openmenu mov byte[netlastloaded],0 call loadnetopen .nomenuout2 call RemoteGetChar cmp dh,0 jne .received mov dl,1 .received call ProcessRemoteCommand jmp .noreceive2 .noreceive mov byte[HoldCommand],0 .noreceive2 cmp byte[CNetType],21 jne .noloadstatesend call loadstatesend .noloadstatesend cmp byte[CNetType],22 jne .noloadstaterecv call loadstaterecv .noloadstaterecv cmp byte[CNetType],15 je .modem cmp byte[CNetType],12 je .modem cmp byte[CNetType],11 je .modem cmp byte[CNetType],10 jne near .nomodem .modem call ProcessModem cmp byte[Connected],1 je near .nomodem call ModemGetChar cmp dh,0 je .nomodem cmp byte[ModemOKStat],0 jne .foundokay mov byte[ModemOKStat],1 jmp .skipstat .foundokay cmp byte[ModemOKStat],1 jne .nostat0 cmp dl,13 jne .nostat0 inc byte[ModemOKStat] jmp .skipstat .nostat0 cmp byte[ModemOKStat],2 jne .nostat1 cmp dl,'O' jne .nostat1 inc byte[ModemOKStat] jmp .skipstat .nostat1 cmp byte[ModemOKStat],3 jne .nostat2 cmp dl,'K' jne .nostat2 inc byte[ModemOKStat] jmp .skipstat .nostat2 .skipstat mov dh,0 call NetAddChar .nomodem cmp dword[GUIEditStringcWin],0 je .noblink cmp dword[GUIEditStringcLen],0 je .noblink mov eax,[GUIEditStringcLen] cmp dword[GUIEditStringLTxt],8 jb .noblinka mov byte[eax],'_' mov byte[eax+1],0 mov dword[GUIEditStringLstb],1 .noblinka cmp dword[GUIEditStringLTxt],0 jne .noblink mov dword[GUIEditStringLTxt],16 .noblink call DisplayBoxes cmp dword[GUIEditStringLstb],1 jne .notblinked mov dword[GUIEditStringLstb],0 mov eax,[GUIEditStringcLen] mov byte[eax],0 .notblinked call DisplayMenu cmp byte[MouseDis],1 je .mousedis3 call DrawMouse .mousedis3 cmp byte[FirstTimeData],0 jne .nofirsttime call guifirsttimemsg mov byte[FirstTimeData],1 .nofirsttime cmp dword[GUICTimer],0 je .notimer GUIOuttext 21,211,[GUICMessage],50 GUIOuttext 20,210,[GUICMessage],63 .notimer call vidpastecopyscr call GUIgetcurrentinput jmp .nokey .exitgui cmp byte[CNetType],20 jne near .nostat20b2 call PreparePacket mov al,255 call RemoteSendChar call SendPacket call PreparePacket mov al,255 call RemoteSendChar call SendPacket call PreparePacket mov al,255 call RemoteSendChar call SendPacket .nostat20b2 GUIDeInitIRQs mov ax,[PrevResoln] mov [resolutn],ax jmp endprog .exit mov edi,[spcBuffera] mov ecx,65536 xor eax,eax rep stosd mov edi,spcRamcmp mov ecx,65536/4 xor eax,eax rep stosd GUIDeInitIRQs call ClearScreen cmp byte[cbitmode],0 jne .nomakepal call makepal .nomakepal mov word[t1cc],1 mov byte[chaton],0 mov dword[chatstrL],0 mov dword[chatLpos],0 mov dword[chatstrR],0 mov dword[chatRTL],0 cmp byte[CNetType],20 jne near .nostat20b mov al,10 sub al,[Latency] cmp byte[Latency],4 jb .nolatency mov al,7 .nolatency mov [BackStateSize],al call ResetExecStuff mov byte[MultiTap],1 cmp byte[pl3neten],0 jne .mtap cmp byte[pl4neten],0 jne .mtap cmp byte[pl5neten],0 jne .mtap .nomtap mov byte[MultiTap],0 .mtap cmp byte[RestoreValues],1 jne .norestoreval pushad mov dword[PBackupPos],0 call RestoreCVFrame popad .norestoreval mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov dword[nmirept],0 mov dword[nmiprevline],224 mov dword[nmistatus],0 mov byte[spcnumread],0 mov byte[NextLineCache],0 mov byte[DSPMem+08h],0 mov byte[DSPMem+18h],0 mov byte[DSPMem+28h],0 mov byte[DSPMem+38h],0 mov byte[DSPMem+48h],0 mov byte[DSPMem+58h],0 mov byte[DSPMem+68h],0 mov byte[DSPMem+78h],0 mov byte[netdelayed],0 mov dword[cnetptrhead],0 mov dword[cnetptrtail],0 mov dword[prevp1net],0 mov dword[prevp2net],0 mov dword[prevp3net],0 mov dword[prevp4net],0 mov dword[prevp5net],0 mov byte[BackState],1 mov dword[CBackupPos],0 mov dword[PBackupPos],0 mov dword[PPValue],0 mov dword[DPValue],0 mov byte[CurRecv],0 mov dword[NetQuitter],0 mov dword[LatencyV],0 mov dword[LatencyV+4],0 mov dword[LatencyV+8],0 mov dword[LatencyV+12],0 mov dword[LatencyRecvPtr],0 mov dword[LatencySendPtr],0 mov eax,cnetplaybuf mov ecx,512 .loop20 mov byte[eax],0 inc eax dec ecx jnz .loop20 mov al,[Latency] mov [LatencyLeft],al mov byte[NetSwap],0 mov dword[CBackupPos],0 mov dword[PBackupPos],0 mov ebx,[romdata] mov ecx,[NumofBanks] shl ecx,15 xor eax,eax or ecx,ecx jz .nocsumloop .csumloop add al,[ebx] adc ah,0 inc ebx dec ecx jnz .csumloop .nocsumloop mov [CheckSumVal],eax mov ebx,eax ; sync with modem call PreparePacket mov al,30 call RemoteSendChar mov al,230 call RemoteSendChar mov al,[CheckSumVal] call RemoteSendChar mov al,[CheckSumVal+1] call RemoteSendChar call SendPacket .nocharb pushad call JoyRead popad ; cmp byte[pressed+1],1 ; je near .faileda call RemoteGetChar cmp dh,0 je .nocharb cmp dl,230 jne .nocharb .nocharb2 call RemoteGetChar cmp dh,0 je .nocharb2 cmp dl,[CheckSumVal] jne .wrongcs .nocharb3 call RemoteGetChar cmp dh,0 je .nocharb3 cmp dl,[CheckSumVal+1] je .okaychat .wrongcs mov esi,WrongCheckSum call WritetochatBuffer jmp StartGUI .okaychat call PreparePacket mov al,229 call RemoteSendChar call SendPacket .nocharb5 pushad call JoyRead popad ; cmp byte[pressed+1],1 ; je near .failedb call RemoteGetChar cmp dh,0 je .nocharb5 cmp dl,229 jne .nocharb5 .nostat20b call EnableSUDPPacket mov byte[ChatProgress],0 mov dword[RecvProgress],0 ; get LoadDrive/LoadDir mov ebx,LoadDir mov edx,LoadDrive call Get_Dir ; change dir to InitDrive/InitDir mov dl,[InitDrive] mov ebx,InitDir ; save config call Change_Dir call createnewcfg call GUISaveVars ; change dir to SRAMDrive/SRAMDir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir mov byte[MousePRClick],1 mov byte[prevbright],0 mov ax,[PrevResoln] mov [resolutn],ax mov byte[CheatOn],0 cmp dword[NumCheats],0 je .nocheats mov byte[CheatOn],1 .nocheats cmp byte[CopyRamToggle],1 jne .nocopyram mov byte[CopyRamToggle],0 mov eax,dword[vidbuffer] add eax,129600 ; copy 128k ram mov ebx,[wramdata] mov ecx,32768 .loopcr mov edx,[ebx] mov [eax],edx add ebx,4 add eax,4 dec ecx jnz .loopcr .nocopyram cmp byte[CheatWinMode],2 jne .notview mov byte[CheatWinMode],1 .notview cmp byte[CheatWinMode],0 je .csskip2 ; Save Cheat Search File mov edx,cstempfname call Create_File jc .csskip2 mov bx,ax mov edx,[vidbuffer] add edx,129600 mov ecx,65536*2+32768 call Write_File call Close_File .csskip2 mov edi,[vidbuffer] mov ecx,288*120 xor eax,eax rep stosd mov ecx,256*144 mov eax,[vidbufferofsb] .loopcl mov dword[eax],0 add eax,4 dec ecx jnz .loopcl mov al,[cfgsoundon] mov [soundon],al mov al,[cfgStereoSound] mov [StereoSound],al mov al,[cfgSoundQuality] mov [SoundQuality],al call AdjustFrequency mov byte[GUIOn],0 mov byte[GUIOn2],0 mov byte[GUIReset],0 mov dword[StartLL],0 mov dword[StartLR],0 mov byte[NetLoadState],0 jmp continueprog .faileda call WinErrorA jmp continueprog .failedb call WinErrorB jmp continueprog CheckSumVal dd 0 WrongCheckSum db 10,13,'ROM Data Mismatch',10,13,10,13,0 SRAMDirc: ; get LoadDrive/LoadDir mov ebx,LoadDir mov edx,LoadDrive call Get_Dir ; change to sram dir mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir ret LOADDir: mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir ret guifirsttimemsg: xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a mov byte[pressed+2Ch],0 .again GUIBox 43,75,213,163,160 GUIBox 43,75,213,75,162 GUIBox 43,75,43,163,161 GUIBox 213,75,213,163,159 GUIBox 43,163,213,163,158 GUIOuttext 56,81,guiftimemsg1,220-15 GUIOuttext 55,80,guiftimemsg1,220 GUIOuttext 56,96,guiftimemsg2,220-15 GUIOuttext 55,95,guiftimemsg2,220 GUIOuttext 56,104,guiftimemsg3,220-15 GUIOuttext 55,103,guiftimemsg3,220 GUIOuttext 56,112,guiftimemsg4,220-15 GUIOuttext 55,111,guiftimemsg4,220 GUIOuttext 56,120,guiftimemsg5,220-15 GUIOuttext 55,119,guiftimemsg5,220 GUIOuttext 56,128,guiftimemsg6,220-15 GUIOuttext 55,127,guiftimemsg6,220 GUIOuttext 56,136,guiftimemsg7,220-15 GUIOuttext 55,135,guiftimemsg7,220 GUIOuttext 56,151,guiftimemsg8,220-15 GUIOuttext 55,150,guiftimemsg8,220 call vidpastecopyscr call GUIUnBuffer call DisplayBoxes call DisplayMenu call JoyRead cmp byte[pressed+2Ch],0 jne .pressedokay jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 ret guiftimemsg1 db 'ONE TIME USER REMINDER :',0 guiftimemsg2 db 'PLEASE BE SURE TO READ',0 guiftimemsg3 db 'GUINOTES.TXT FOR AN',0 guiftimemsg4 db 'IMPORTANT REMINDER.',0 guiftimemsg5 db 'ALSO, WHENEVER YOU HAVE',0 guiftimemsg6 db 'PROBLEMS, BE SURE TO READ',0 guiftimemsg7 db 'ZSNES.FAQ AND README.TXT',0 guiftimemsg8 db 'PRESS "Z" TO CONTINUE.',0 guimustrestartmsg: xor ebx,ebx mov ecx,256 .a cmp byte[pressed+ebx],1 jne .npr1 mov byte[pressed+ebx],2 .npr1 inc ebx dec ecx jnz .a mov byte[pressed+2Ch],0 .again GUIBox 43,87,213,151,160 GUIBox 43,87,213,87,162 GUIBox 43,87,43,151,161 GUIBox 213,87,213,151,159 GUIBox 43,151,213,151,158 GUIOuttext 56,92,guiqtimemsg1,220-15 GUIOuttext 55,91,guiqtimemsg1,220 GUIOuttext 56,100,guiqtimemsg2,220-15 GUIOuttext 55,99,guiqtimemsg2,220 GUIOuttext 56,108,guiqtimemsg3,220-15 GUIOuttext 55,107,guiqtimemsg3,220 GUIOuttext 56,116,guiqtimemsg4,220-15 GUIOuttext 55,115,guiqtimemsg4,220 GUIOuttext 56,139,guiqtimemsg8,220-15 GUIOuttext 55,138,guiqtimemsg8,220 call vidpastecopyscr call GUIUnBuffer call DisplayBoxes call DisplayMenu call JoyRead mov byte[pressed+2Ch],0 call JoyRead xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],1 je .pressedokay inc ebx dec ecx jnz .b jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 mov byte[GUIQuit],1 ret guiqtimemsg1 db 'ZSNES MUST BE RESTARTED',0 guiqtimemsg2 db 'TO USE THIS OPTION.',0 guiqtimemsg3 db 'THIS PROGRAM WILL NOW',0 guiqtimemsg4 db 'EXIT.',0 guiqtimemsg8 db 'PRESS ANY KEY.',0 guiprevideo: xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 43,90,213,163,160 GUIBox 43,90,213,90,162 GUIBox 43,90,43,163,161 GUIBox 213,90,213,163,159 GUIBox 43,163,213,163,158 GUIOuttext 56,96,guiprevidmsg1,220-15 GUIOuttext 55,95,guiprevidmsg1,220 GUIOuttext 56,104,guiprevidmsg2,220-15 GUIOuttext 55,103,guiprevidmsg2,220 GUIOuttext 56,112,guiprevidmsg3,220-15 GUIOuttext 55,111,guiprevidmsg3,220 GUIOuttext 56,120,guiprevidmsg4,220-15 GUIOuttext 55,119,guiprevidmsg4,220 GUIOuttext 56,128,guiprevidmsg5,220-15 GUIOuttext 55,127,guiprevidmsg5,220 GUIOuttext 56,136,guiprevidmsg6,220-15 GUIOuttext 55,135,guiprevidmsg6,220 GUIOuttext 56,151,guiprevidmsg7,220-15 GUIOuttext 55,150,guiprevidmsg7,220 call vidpastecopyscr mov byte[pressed+2Ch],0 .again call JoyRead xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b cmp byte[MouseDis],1 je .mousedis call Get_MouseData test bx,01h jnz .pressedokay .mousedis jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 ret guiprevidmsg1 db 'ZSNES WILL NOW ATTEMPT',0 guiprevidmsg2 db 'TO CHANGE YOUR VIDEO',0 guiprevidmsg3 db 'MODE. IF THE CHANGE',0 guiprevidmsg4 db 'IS UNSUCCESSFUL, WAIT',0 guiprevidmsg5 db '10 SECONDS AND VIDEO',0 guiprevidmsg6 db 'MODE WILL BE RESET',0 guiprevidmsg7 db 'PRESS ANY KEY',0 guipostvideo: mov ecx,255*144 mov eax,[vidbufferofsb] .loop mov dword[eax],0FFFFFFFFh add eax,4 dec ecx jnz .loop xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a mov dword[GUIkeydelay],36*10 .pressedfail call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 43,90,213,163,160 GUIBox 43,90,213,90,162 GUIBox 43,90,43,163,161 GUIBox 213,90,213,163,159 GUIBox 43,163,213,163,158 GUIOuttext 56,96,guipostvidmsg1,220-15 GUIOuttext 55,95,guipostvidmsg1,220 GUIOuttext 56,151,guipostvidmsg2,220-15 GUIOuttext 55,150,guipostvidmsg2,220 call vidpastecopyscr ; Wait for all mouse and input data to be 0 call JoyRead xor ebx,ebx mov ecx,256+128+64 .b2 cmp byte[pressed+ebx],0 jne near .pressedfail inc ebx dec ecx jnz .b2 cmp byte[MouseDis],1 je .mousedis3 call Get_MouseData test bx,01h jnz near .pressedfail .mousedis3 .again call JoyRead xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b cmp byte[MouseDis],1 je .mousedis call Get_MouseData test bx,01h jnz .pressedokay .mousedis cmp dword[GUIkeydelay],0 je .pressedokay jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 mov byte[GUIpclicked],1 ret guipostvidmsg1 db 'VIDEO MODE CHANGED.',0 guipostvidmsg2 db 'PRESS ANY KEY',0 guipostvideofail: mov dword[guipostvidptr],guipostvidmsg3b mov byte[guipostvidmsg3b],0 mov byte[guipostvidmsg4b],0 mov byte[guipostvidmsg5b],0 mov eax,[ErrorPointer] mov ebx,eax .loop cmp byte[ebx],0 je .found cmp byte[ebx],'$' je .found inc ebx jmp .loop .found mov edx,ebx sub edx,eax .detnext or edx,edx jz .notext cmp edx,25 jbe .copytext .nospace dec edx cmp byte[eax+edx],32 jne .nospace jmp .detnext .copytext push ebx mov ecx,[guipostvidptr] .copytextloop mov bl,[eax] cmp bl,'$' jne .notdol mov bl,0 .notdol mov [ecx],bl inc eax inc ecx dec edx jnz .copytextloop mov byte[ecx],0 pop ebx add dword[guipostvidptr],26 cmp byte[eax],0 je .notext cmp byte[eax],'$' je .notext inc eax jmp .found .notext xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 43,90,213,163,160 GUIBox 43,90,213,90,162 GUIBox 43,90,43,163,161 GUIBox 213,90,213,163,159 GUIBox 43,163,213,163,158 GUIOuttext 56,96,guipostvidmsg1b,220-15 GUIOuttext 55,95,guipostvidmsg1b,220 GUIOuttext 56,108,guipostvidmsg2b,220-15 GUIOuttext 55,107,guipostvidmsg2b,220 GUIOuttext 56,119,guipostvidmsg3b,220-15 GUIOuttext 55,118,guipostvidmsg3b,220 GUIOuttext 56,129,guipostvidmsg4b,220-15 GUIOuttext 55,128,guipostvidmsg4b,220 GUIOuttext 56,139,guipostvidmsg5b,220-15 GUIOuttext 55,138,guipostvidmsg5b,220 GUIOuttext 56,152,guipostvidmsg8b,220-15 GUIOuttext 55,151,guipostvidmsg8b,220 call vidpastecopyscr call GUIUnBuffer call DisplayBoxes call DisplayMenu %ifndef __LINUX__ mov dword[GUIkeydelay],0FFFFFFFFh %else mov dword[GUIkeydelay],0x0 %endif jmp guipostvideo.pressedfail guipostvidmsg1b db 'VIDEO MODE CHANGE FAILED.',0 guipostvidmsg2b db 'UNABLE TO INIT VESA2:',0 guipostvidmsg3b db 'AAAAAAAAAAAAAAAAAAAAAAAAA',0 guipostvidmsg4b db 'AAAAAAAAAAAAAAAAAAAAAAAAA',0 guipostvidmsg5b db 'AAAAAAAAAAAAAAAAAAAAAAAAA',0 guipostvidmsg8b db 'PRESS ANY KEY',0 guipostvidptr dd 0 GUILoadManualDir mov ebx,GUILoadTextA mov [ManualCPtr],ebx cmp byte[ebx],0 je near .nofindfile xor eax,eax .next cmp byte[ebx],':' jne .nocolon mov eax,ebx .nocolon inc ebx cmp byte[ebx],0 jne .next or eax,eax jz .nomorecolon cmp eax,GUILoadTextA je .invalidcolon mov bl,[eax-1] cmp bl,'a' jb .nolower cmp bl,'z' ja .nolower sub bl,'a'-'A' .nolower cmp bl,'A' jb .invalidcolon cmp bl,'Z' ja .invalidcolon sub bl,'A' mov dl,bl push eax call Change_Drive pop eax mov byte[ManualStatus],1 .invalidcolon inc eax mov [ManualCPtr],eax .nomorecolon mov ebx,[ManualCPtr] cmp byte[ebx],0 je near .finish xor eax,eax .next2 cmp byte[ebx],'\' jne .nobackslash mov eax,ebx .nobackslash inc ebx cmp byte[ebx],0 jne .next2 or eax,eax jz .finish inc eax mov cl,[eax] mov byte[eax],0 push ecx push eax mov edx,[ManualCPtr] call Change_Single_Dir jc .nosuchdir mov byte[ManualStatus],1 .nosuchdir pop eax pop ecx mov [eax],cl mov [ManualCPtr],eax .finish mov edx,[ManualCPtr] call Change_Single_Dir jc .notdir mov byte[ManualStatus],1 jmp .nomoredir .notdir call .nomoredir mov edx,[ManualCPtr] cmp byte[edx],0 je .nofindfile ; otherwise set ManualStatus to 2 mov byte[ManualStatus],2 mov dword[GUIcurrentfilewin],0 .nofindfile ret .nomoredir ; refresh dir if necessary cmp byte[ManualStatus],1 jne .norefresh call GetLoadData.a .norefresh ret ManualCPtr dd 0 ManualStatus db 0 NEWSYM MovieCounter, dd 0 UnableMovie2 db 'MUST PLAY WITH SOUND OFF',0 UnableMovie3 db 'MUST PLAY WITH SOUND ON',0 MoviePlay: cmp byte[CNetType],20 je near .dontplay mov byte[GUICBHold],0 mov dword[MovieCounter],0 cmp byte[MovieProcessing],0 jne near .dontplay mov byte[GUIQuit],2 mov ebx,[statefileloc] mov eax,[fnamest+ebx-3] push eax mov dword[fnamest+ebx-3],'.zmv' mov al,[CMovieExt] mov byte[fnamest+ebx],al call ChangetoSRAMdir mov dword[Totalbyteloaded],0 call loadstate2 mov edx,fnamest+1 call Open_File jc near .notexist mov bx,ax mov [MovieFileHand],bx mov cx,[Totalbyteloaded+2] mov dx,[Totalbyteloaded] call File_Seek mov edx,RecData mov ecx,16 call Read_File cmp byte[RecData+2],1 jne .noextra mov eax,[RecData+3] mov [timer2upd],eax mov eax,[RecData+7] mov [curexecstate],eax mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov dword[nmirept],0 mov dword[nmiprevline],224 mov dword[nmistatus],0 mov byte[spcnumread],0 mov byte[NextLineCache],0 .noextra mov al,[RecData] cmp al,[soundon] jne near .soundisoff cmp dword[ramsize],0 je .noram mov edx,[sram] mov ecx,[ramsize] call Read_File .noram mov byte[MovieProcessing],1 .skip mov dword[PJoyAOrig],0 mov dword[PJoyBOrig],0 mov dword[PJoyCOrig],0 mov dword[PJoyDOrig],0 mov dword[PJoyEOrig],0 mov byte[sramsavedis],1 mov byte[UseRemoteSRAMData],0 mov byte[DSPMem+08h],0 mov byte[DSPMem+18h],0 mov byte[DSPMem+28h],0 mov byte[DSPMem+38h],0 mov byte[DSPMem+48h],0 mov byte[DSPMem+58h],0 mov byte[DSPMem+68h],0 mov byte[DSPMem+78h],0 .notexist call ChangetoLOADdir pop eax mov ebx,[statefileloc] mov [fnamest+ebx-3],eax .dontplay ret .soundisoff mov dword[Msgptr],UnableMovie2 cmp byte[soundon],0 jne .soundon mov dword[Msgptr],UnableMovie3 .soundon mov eax,[MsgCount] mov [MessageOn],eax call Close_File pop eax ret NEWSYM Totalbyteloaded, dd 0 NEWSYM sramsavedis, db 0 DevicePtr dd pl1selk,pl2selk,pl3selk,pl4selk,pl5selk CheckMenuItemHelp: mov al,[GUIcmenupos] mov [GUIpmenupos],al mov byte[GUIcmenupos],0 cmp byte[GUIwinactiv+edx],1 je .menuontop xor eax,eax mov al,[GUIwinptr] inc byte[GUIwinptr] mov byte[GUIwinorder+eax],dl mov byte[GUIwinactiv+edx],1 cmp byte[resetposn],1 jne .nomenuitem mov eax,[GUIwinposxo+edx*4] mov [GUIwinposx+edx*4],eax mov eax,[GUIwinposyo+edx*4] mov [GUIwinposy+edx*4],eax jmp .nomenuitem .menuontop xor eax,eax ; look for match .notfoundyet mov bl,byte[GUIwinorder+eax] cmp bl,dl je .nextfind inc eax jmp .notfoundyet .nextfind inc eax cmp al,[GUIwinptr] je .foundend mov cl,[GUIwinorder+eax] mov [GUIwinorder+eax-1],cl jmp .nextfind .foundend mov byte[GUIpclicked],0 mov [GUIwinorder+eax-1],bl .nomenuitem ret %macro GUICheckMenuItem 2 mov edx,%1 cmp byte[GUIcrowpos],%2 jne near %%nomenuitem call CheckMenuItemHelp %%nomenuitem %endmacro %macro checkqloadvalue 1 cmp byte[GUIcrowpos],%1 jne %%skip mov esi,prevloaddnamel+%1*512 cmp byte[esi+1],0 je %%notvalid mov edi,prevloadfnamel+%1*512 mov ebx,prevloadnames+%1*16 mov ecx,%1 call loadquickfname %%notvalid ret %%skip %endmacro GUITryMenuItem: cmp byte[GUIcmenupos],1 jne near .noquickload checkqloadvalue 0 checkqloadvalue 1 checkqloadvalue 2 checkqloadvalue 3 checkqloadvalue 4 checkqloadvalue 5 checkqloadvalue 6 checkqloadvalue 7 checkqloadvalue 8 checkqloadvalue 9 cmp byte[GUIcrowpos],11 jne .skipswitch xor byte[prevlfreeze],1 cmp byte[prevlfreeze],0 je .off mov byte[GUIPrevMenuData.onoff+15],'O' mov byte[GUIPrevMenuData.onoff+16],'N' mov byte[GUIPrevMenuData.onoff+17],' ' jmp .on .off mov byte[GUIPrevMenuData.onoff+15],'O' mov byte[GUIPrevMenuData.onoff+16],'F' mov byte[GUIPrevMenuData.onoff+17],'F' .on .skipswitch cmp byte[GUIcrowpos],12 jne .skipclear cmp byte[prevlfreeze],0 jne .skipclear mov edi,prevloadnames mov eax,20202020h mov ecx,4*10 rep stosd mov edi,prevloaddnamel xor eax,eax mov ecx,128*10 rep stosd mov edi,prevloadfnamel mov eax,0 ;20202020h mov ecx,128*10 rep stosd call GUIQuickLoadUpdate ret .skipclear .noquickload cmp byte[GUIcmenupos],2 jne near .nomain GUICheckMenuItem 1, 0 ; Load cmp byte[GUIcrowpos],0 jne .noloadrefresh jmp GetLoadData .noloadrefresh cmp byte[romloadskip],0 jne near .noromloaded cmp byte[GUIcrowpos],1 ; Run jne .norun cmp byte[romloadskip],0 jne .dontquit mov byte[GUIQuit],2 .dontquit ret .norun cmp byte[CNetType],21 je near .noreset cmp byte[CNetType],22 je near .noreset GUICheckMenuItem 12, 2 ; Reset cmp byte[GUIcrowpos],2 jne .noreset mov byte[GUICResetPos],1 .noreset ; cmp byte[OSPort],3 ; je .win32state ; cmp byte[CNetType],20 ; je near .noromloaded ;.win32state cmp byte[CNetType],21 je near .noromloaded cmp byte[CNetType],22 je near .noromloaded cmp byte[GUIcrowpos],4 jne .nosavestate mov byte[GUIStatesText5],0 mov byte[GUICStatePos],1 .nosavestate cmp byte[GUIcrowpos],5 jne .noloadstate mov byte[GUIStatesText5],1 mov byte[GUICStatePos],1 .noloadstate GUICheckMenuItem 14, 4 ; Save State GUICheckMenuItem 14, 5 ; Load State GUICheckMenuItem 2, 6 ; Select State .noromloaded cmp byte[GUIcrowpos],8 jne .noquit mov byte[GUIQuit],1 .noquit .nomain cmp byte[GUIcmenupos],3 jne near .noconfig GUICheckMenuItem 3, 0 GUICheckMenuItem 3, 1 GUICheckMenuItem 3, 2 GUICheckMenuItem 3, 3 GUICheckMenuItem 3, 4 cmp byte[GUIcrowpos],0 jne .noplay1 mov byte[cplayernum],0 .noplay1 cmp byte[GUIcrowpos],1 jne .noplay2 mov byte[cplayernum],1 .noplay2 cmp byte[GUIcrowpos],2 jne .noplay3 mov byte[cplayernum],2 .noplay3 cmp byte[GUIcrowpos],3 jne .noplay4 mov byte[cplayernum],3 .noplay4 cmp byte[GUIcrowpos],4 jne .noplay5 mov byte[cplayernum],4 .noplay5 GUICheckMenuItem 17, 6 GUICheckMenuItem 4, 8 GUICheckMenuItem 5, 9 GUICheckMenuItem 6, 10 .noconfig cmp byte[romloadskip],0 jne near .nocheat cmp byte[CheatBDoor],1 je .yescheat cmp byte[CNetType],20 je near .nocheat cmp byte[CNetType],21 je near .nocheat cmp byte[CNetType],22 je near .nocheat .yescheat cmp byte[GUIcmenupos],4 jne near .nocheat GUICheckMenuItem 7, 0 GUICheckMenuItem 7, 1 GUICheckMenuItem 13, 2 cmp byte[GUIcrowpos],0 jne .noaddc mov dword[GUIcurrentcheatwin],1 .noaddc cmp byte[GUIcrowpos],1 jne .nobrowsec mov dword[GUIcurrentcheatwin],0 .nobrowsec .nocheat cmp byte[GUIcmenupos],5 jne near .nonet ; cmp byte[GOSPort],3 ; je near .win32 %ifdef __MSDOS__ cmp byte[CNetType],10 jae .nomod mov byte[CNetType],0 .nomod GUICheckMenuItem 8, 0 GUICheckMenuItem 8, 1 cmp byte[CNetType],10 jae near .nonet cmp byte[GUIcrowpos],1 jne .noipx mov byte[CNetType],7 .noipx cmp byte[GUIcrowpos],0 jne near .nonet mov byte[CNetType],1 jmp .nonet %endif ;.win32 GUICheckMenuItem 8, 0 cmp byte[CNetType],10 jae near .nonet cmp byte[GUIcrowpos],0 jne near .nonet mov byte[CNetType],4 call GetHostName .nonet cmp byte[GUIcmenupos],6 jne near .nomisc GUICheckMenuItem 9, 0 GUICheckMenuItem 10, 1 cmp byte[romloadskip],0 jne near .nomovie GUICheckMenuItem 15, 2 cmp byte[GUIcrowpos],2 jne .nomovie mov byte[MovieRecordWinVal],0 .nomovie GUICheckMenuItem 16, 3 cmp byte[GUIcrowpos],4 jne .nosavestuff ; change dir to InitDrive/InitDir mov dl,[InitDrive] mov ebx,InitDir call Change_Dir call createnewcfg call GUISaveVars call Makemode7Table mov dword[GUICMessage],.message1 mov dword[GUICTimer],50 ; change dir to LoadDrive/LoadDir mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir .nosavestuff GUICheckMenuItem 11, 6 .nomisc ret .message1 db 'CONFIGURATION FILES SAVED.',0 DisplayBoxes: xor esi,esi mov byte[cwindrawn],0 .next2 mov al,[GUIwinorder+esi] cmp al,0 je .done inc byte[cwindrawn] inc esi jmp .next2 .done dec byte[cwindrawn] xor eax,eax xor esi,esi .next mov al,[GUIwinorder+esi] cmp al,0 je near .nomore push esi cmp al,1 jne .noguiconfirm cmp byte[GUIReset],1 je near .finstuff call DisplayGUILoad jmp .finstuff .noguiconfirm cmp al,2 jne .noguichosesave call DisplayGUIChoseSave jmp .finstuff .noguichosesave cmp al,3 jne .noguiinput call DisplayGUIInput jmp .finstuff .noguiinput cmp al,4 jne .noguioption call DisplayGUIOption jmp .finstuff .noguioption cmp al,5 jne .noguivideo call DisplayGUIVideo jmp .finstuff .noguivideo cmp al,6 jne .noguisound call DisplayGUISound jmp .finstuff .noguisound cmp al,7 jne .noguicheat call DisplayGUICheat jmp .finstuff .noguicheat cmp al,8 jne .noguinet call DisplayNetOptns jmp .finstuff .noguinet cmp al,9 jne .noguigameop call DisplayGameOptns jmp .finstuff .noguigameop cmp al,10 jne .noguiconf call DisplayGUIOptns %ifdef __WIN32__ pushad call CheckAlwaysOnTop popad %endif jmp .finstuff .noguiconf cmp al,11 jne .noguiconf2 call DisplayGUIAbout jmp .finstuff .noguiconf2 cmp al,12 jne .noguireset call DisplayGUIReset jmp .finstuff .noguireset cmp al,13 jne .noguisearch call DisplayGUISearch jmp .finstuff .noguisearch cmp al,14 jne .noguistates call DisplayGUIStates jmp .finstuff .noguistates cmp al,15 jne .noguimovies call DisplayGUIMovies jmp .finstuff .noguimovies cmp al,16 jne .noguicombo call DisplayGUICombo jmp .finstuff .noguicombo cmp al,17 jne .noaddon call DisplayGUIAddOns jmp .finstuff .noaddon .finstuff pop esi inc esi dec byte[cwindrawn] jmp .next .nomore ret ChangetoSRAMdir: mov dl,[SRAMDrive] mov ebx,SRAMDir call Change_Dir ret ChangetoLOADdir: mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir ret GUIProcStates: xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+14],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] cmp byte[GUICBHold],10 je .yesstate mov byte[GUICBHold],0 ret .yesstate mov byte[GUICBHold],0 ; change dir to SRAMDrive/SRAMDir call ChangetoSRAMdir cmp byte[GUIStatesText5],1 je .loadstate call statesaver jmp .changedir .loadstate cmp byte[CNetType],20 jne .notnet call NetLoadStuff jmp .changedir .notnet call loadstate2 .changedir ; change dir to LoadDrive/LoadDir call ChangetoLOADdir ret SaveSecondState: ; change dir to SRAMDrive/SRAMDir call ChangetoSRAMdir mov ebx,[statefileloc] mov al,[fnamest+ebx] mov byte[fnamest+ebx],'s' push eax call statesaver pop eax mov ebx,[statefileloc] mov [fnamest+ebx],al call ChangetoLOADdir ret LoadSecondState: call ChangetoSRAMdir mov ebx,[statefileloc] mov al,[fnamest+ebx] mov byte[fnamest+ebx],'s' push eax call loadstate2 pop eax mov ebx,[statefileloc] mov [fnamest+ebx],al call ChangetoLOADdir ret GUIProcReset: cmp byte[GUICBHold],2 jne .noreset mov byte[GUIReset],1 call GUIDoReset cmp byte[CNetType],20 jne .noreset call PreparePacket mov al,40 call RemoteSendChar call SendPacket mov byte[GUIQuit],0 .noreset mov byte[GUICBHold],0 xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+12],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] ret LoadDuplicFound db 0 %macro GUIDMHelp 4 mov byte[GUItextcolor],46 mov byte[GUItextcolor+1],42 mov byte[GUItextcolor+2],38 mov byte[GUItextcolor+3],44 mov byte[GUItextcolor+4],40 cmp byte[GUIcmenupos],%4 jne %%nohighlight mov byte[GUItextcolor],38 mov byte[GUItextcolor+1],40 mov byte[GUItextcolor+2],46 mov byte[GUItextcolor+3],40 mov byte[GUItextcolor+4],44 %%nohighlight GUIBox %1,3,%2,3,[GUItextcolor] GUIBox %1,4,%2,12,[GUItextcolor+1] GUIBox %1,13,%2,13,[GUItextcolor+2] GUIBox %1,3,%1,12,[GUItextcolor+3] GUIBox %2,4,%2,13,[GUItextcolor+4] GUIOuttext %1+5,7,%3,44 GUIOuttext %1+4,6,%3,62 %endmacro %macro GUIDMHelpB 4 mov byte[GUItextcolor],46 mov byte[GUItextcolor+1],42 mov byte[GUItextcolor+2],38 mov byte[GUItextcolor+3],44 mov byte[GUItextcolor+4],40 cmp byte[GUIcwinpress],%4 jne %%nohighlight mov byte[GUItextcolor],38 mov byte[GUItextcolor+1],40 mov byte[GUItextcolor+2],46 mov byte[GUItextcolor+3],40 mov byte[GUItextcolor+4],44 %%nohighlight GUIBox %1,3,%2,3,[GUItextcolor] GUIBox %1,4,%2,13,[GUItextcolor+1] GUIBox %1,14,%2,14,[GUItextcolor+2] GUIBox %1,3,%1,13,[GUItextcolor+3] GUIBox %2,4,%2,14,[GUItextcolor+4] GUIOuttext %1+3,7,%3,44 GUIOuttext %1+2,6,%3,62 %endmacro %macro GUIDMHelpB2 4 mov byte[GUItextcolor],46 mov byte[GUItextcolor+1],42 mov byte[GUItextcolor+2],38 mov byte[GUItextcolor+3],44 mov byte[GUItextcolor+4],40 cmp byte[GUIcwinpress],%4 jne %%nohighlight mov byte[GUItextcolor],38 mov byte[GUItextcolor+1],40 mov byte[GUItextcolor+2],46 mov byte[GUItextcolor+3],40 mov byte[GUItextcolor+4],44 %%nohighlight GUIBox %1,3,%2,3,[GUItextcolor] GUIBox %1,4,%2,6,[GUItextcolor+1] GUIBox %1,7,%2,7,[GUItextcolor+2] GUIBox %1,3,%1,6,[GUItextcolor+3] GUIBox %2,4,%2,7,[GUItextcolor+4] GUIOuttext %1+3,5,%3,44 GUIOuttext %1+2,4,%3,62 %endmacro %macro GUIDMHelpB3 4 mov byte[GUItextcolor],46 mov byte[GUItextcolor+1],42 mov byte[GUItextcolor+2],38 mov byte[GUItextcolor+3],44 mov byte[GUItextcolor+4],40 cmp byte[GUIcwinpress],%4 jne %%nohighlight mov byte[GUItextcolor],38 mov byte[GUItextcolor+1],40 mov byte[GUItextcolor+2],46 mov byte[GUItextcolor+3],40 mov byte[GUItextcolor+4],44 %%nohighlight GUIBox %1,9,%2,9,[GUItextcolor] GUIBox %1,10,%2,12,[GUItextcolor+1] GUIBox %1,13,%2,13,[GUItextcolor+2] GUIBox %1,9,%1,12,[GUItextcolor+3] GUIBox %2,10,%2,13,[GUItextcolor+4] GUIOuttext %1+3,11,%3,44 GUIOuttext %1+2,10,%3,62 %endmacro %macro GUIDrawMenuM 10 GUIShadow %7,%8,%7+4+%3*6,%8+3+%4*10 GUIBox %1,%2,%1+4+%3*6,%2+3+%4*10,43 mov edi,[GUIcrowpos] mov ecx,edi shl edi,8 shl ecx,5 add edi,ecx lea edi,[edi*5] shl edi,1 add edi,[vidbuffer] add edi,%1+17+18*288 mov ecx,6*%3+3 mov edx,1 mov al,73 push edi call GUIDrawBox pop edi add edi,288 mov ecx,6*%3+3 mov edx,7 mov al,72 push edi call GUIDrawBox pop edi add edi,288*7 mov ecx,6*%3+3 mov edx,1 mov al,73 call GUIDrawBox GUIBox %1+%10,%2,%1+4+%3*6,%2,47 GUIBox %1,%2,%1,%9,45 GUIBox %1,%9,%1+4+%3*6,%9,39 GUIBox %1+4+%3*6,1+%2,%1+4+%3*6,%9,41 mov edi,%5 mov esi,[vidbuffer] add esi,16+%6+20*288 mov ecx,%4 mov edx,6*%3 call GUIMenuDisplay mov dword[GUIMenuL],%1+1 mov dword[GUIMenuR],%1+6*%3+3 mov dword[GUIMenuD],18+%4*10 %endmacro DisplayMenu: ; Draw Shadow GUIShadow 5,7,235,21 ; Display Top Border GUIBox 0,1,229,1,71 GUIBox 0,2,229,2,70 GUIBox 0,3,229,3,69 GUIBox 0,4,229,4,68 GUIBox 0,5,229,5,67 GUIBox 0,6,229,6,66 GUIBox 0,7,229,7,65 GUIBox 0,8,229,8,64 GUIBox 0,9,229,9,65 GUIBox 0,10,229,10,66 GUIBox 0,11,229,11,67 GUIBox 0,12,229,12,68 GUIBox 0,13,229,13,69 GUIBox 0,14,229,14,70 GUIBox 0,15,229,15,71 ; cmp byte[OSPort],3 ; jne near .notwinpressa %ifdef __LINUX__ GUIShadow 238,9,247,20 GUIShadow 249,9,257,20 %endif %ifdef __WIN32__ GUIShadow 238,9,247,14 GUIShadow 238,16,247,20 GUIShadow 249,9,257,20 %endif .notwinpressa ; cmp byte[OSPort],3 ; jne near .notwinpressb %ifdef __LINUX__ mov byte[GUIMenuItem+36],247 GUIDMHelpB 233,242,GUIMenuItem+36,1 mov byte[GUIMenuItem+36],'x' GUIDMHelpB 244,253,GUIMenuItem+36,2 %endif %ifdef __WIN32__ mov byte[GUIMenuItem+36],249 GUIDMHelpB2 233,242,GUIMenuItem+36,1 mov byte[GUIMenuItem+36],248 GUIDMHelpB3 233,242,GUIMenuItem+36,3 mov byte[GUIMenuItem+36],'x' GUIDMHelpB 244,253,GUIMenuItem+36,2 %endif .notwinpressb ; Display upper-left box mov byte[GUIMenuItem+36],25 GUIDMHelp 4,12,GUIMenuItem+6,1 GUIOuttext 4+3,7,GUIMenuItem+36,44 GUIOuttext 4+2,6,GUIMenuItem+36,62 ; Display boxes GUIDMHelp 17,47,GUIMenuItem,2 GUIDMHelp 52,94,GUIMenuItem+7,3 GUIDMHelp 99,135,GUIMenuItem+14,4 GUIDMHelp 140,188,GUIMenuItem+21,5 GUIDMHelp 193,223,GUIMenuItem+29,6 mov dword[GUIMenuL],0 mov dword[GUIMenuR],0 mov dword[GUIMenuD],0 ; format : x pos, y pos, #charx, #chary, name, xpos+2, xpos+5,22, ; 19+#chary*10, length of top menu box cmp byte[GUIcmenupos],1 jne near .nomenu1 GUIDrawMenuM 4,16,30,13,GUIPrevMenuData,6,9,22,149,8 ;19+13*10 mov dword[GUICYLocPtr],MenuDat1 .nomenu1 cmp byte[GUIcmenupos],2 jne near .nomenu2 GUIDrawMenuM 17,16,10,9,GUIGameMenuData,19,22,22,109,30 ;19+9*10 mov dword[GUICYLocPtr],MenuDat2 .nomenu2 cmp byte[GUIcmenupos],3 jne near .nomenu3 GUIDrawMenuM 52,16,9,11,GUIConfigMenuData,54,57,22,129,42 ;19+11*10 mov dword[GUICYLocPtr],MenuDat3 .nomenu3 cmp byte[GUIcmenupos],4 jne near .nomenu4 GUIDrawMenuM 99,16,11,3,GUICheatMenuData,101,104,22,49,36 ;19+3*10 mov dword[GUICYLocPtr],MenuDat4 .nomenu4 cmp byte[GUIcmenupos],5 jne near .nomenu5 ; cmp byte[GOSPort],3 ; je near .menu5b %ifdef __MSDOS__ GUIDrawMenuM 140,16,10,2,GUINetPlayMenuData,142,145,22,39,48 ;19+2*10 mov dword[GUICYLocPtr],MenuDat5 jmp .nomenu5 %endif .menu5b GUIDrawMenuM 140,16,10,1,GUINetPlayMenuData,142,145,22,29,48 ;19+2*10 mov dword[GUICYLocPtr],MenuDat5 .nomenu5 cmp byte[GUIcmenupos],6 jne near .nomenu6 GUIDrawMenuM 193,16,9,7,GUIMiscMenuData,195,198,22,89,30 ;19+5*10 mov dword[GUICYLocPtr],MenuDat6 .nomenu6 ret GUIMenuDisplay: xor ebx,ebx .next mov al,[edi] push ebx push ecx push esi cmp al,0 je near .notext cmp al,2 je .darktext inc edi mov byte[GUItextcolor],44 cmp byte[GUIcrowpos],bl je .nodrawshadow push edi push esi add esi,289 call GUIOutputString pop esi pop edi .nodrawshadow mov byte[GUItextcolor],63 call GUIOutputString inc edi jmp .text .darktext inc edi mov byte[GUItextcolor],42 cmp byte[GUIcrowpos],bl je .nodrawshadow2 push edi push esi add esi,289 call GUIOutputString pop esi pop edi .nodrawshadow2 mov byte[GUItextcolor],57 call GUIOutputString inc edi jmp .text .notext add esi,4*288 mov ecx,edx .loop mov byte[esi],45 mov byte[esi-289],40 mov byte[esi+289],42 inc esi dec ecx jnz .loop add edi,14 .text pop esi pop ecx pop ebx add esi,10*288 inc ebx dec ecx jnz near .next ret InitGUI: cmp byte[newengen],0 je .nong16b cmp byte[cbitmode],0 je .nong16b call GetScreen .nong16b call ClearScreen call Clear2xSaIBuffer call GUISetPal call GUIBufferData ret GUISetPal: cmp byte[cbitmode],1 je near GUISetPal16 ; set palette ; Fixed Color Scale = 0 .. 31 mov dx,03C8h mov al,0 out dx,al inc dx out dx,al out dx,al out dx,al inc al mov dx,03C8h mov bl,1 out dx,al inc dx .loopd mov al,bl add al,[GUIRAdd] out dx,al mov al,bl add al,[GUIGAdd] out dx,al mov al,bl add al,[GUIBAdd] out dx,al inc bl cmp bl,32 jne .loopd ; gray scale = 32 .. 63 mov dx,03C8h mov bl,32 mov al,32 out dx,al inc dx .loopc mov al,bl add al,al out dx,al out dx,al out dx,al inc bl cmp bl,64 jne .loopc ; shadow = 96 .. 127 inc al mov al,96 mov dx,03C8h mov bl,0 out dx,al inc dx .loope mov al,bl add al,[GUIRAdd] mov ah,al add al,al add al,ah shr al,2 out dx,al mov al,bl add al,[GUIGAdd] mov ah,al add al,al add al,ah shr al,2 out dx,al mov al,bl add al,[GUIBAdd] mov ah,al add al,al add al,ah shr al,2 out dx,al inc bl cmp bl,32 jne .loope ; 0,10,31 mov al,[GUITRAdd] mov [TRVal],al mov al,[GUITGAdd] mov [TGVal],al mov al,[GUITBAdd] mov [TBVal],al mov ax,[TRVal] inc ax shr ax,3 mov [TRVali],ax shl ax,3 add [TRVal],ax mov ax,[TGVal] inc ax shr ax,3 mov [TGVali],ax shl ax,3 add [TGVal],ax mov ax,[TBVal] inc ax shr ax,3 mov [TBVali],ax shl ax,3 add [TBVal],ax GUIPal 64,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 65,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 66,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 67,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 68,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 69,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 70,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 71,[TRVal],[TGVal],[TBVal] GUIPal 72,40,0,20 GUIPal 73,34,0,21 GUIPal 80,0,10,28 GUIPal 81,0,10,27 GUIPal 82,0,10,25 GUIPal 83,0,09,24 GUIPal 84,0,08,22 GUIPal 85,0,07,20 GUIPal 86,0,06,18 GUIPal 87,0,05,15 GUIPal 88,20,0,10 GUIPal 89,17,0,10 ; Orange Scale mov dx,03C8h mov al,128 mov cl,20 out dx,al mov bh,0 mov ah,0 inc dx .loopf add bh,2 add ah,1 mov al,63 out dx,al mov al,bh out dx,al mov al,ah out dx,al dec cl jnz .loopf ; Blue scale = 148 .. 167 mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 GUIPal 152,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 151,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 150,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 149,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 148,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 call DecPalVal call DecPalVal GUIPal 157,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 156,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 155,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 154,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 153,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 call DecPalVal call DecPalVal call DecPalVal call DecPalVal GUIPal 162,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 161,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 160,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 159,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 158,[TRVal],[TGVal],[TBVal] GUIPal 163,40,40,00 GUIPal 164,30,30,00 GUIPal 165,50,00,00 GUIPal 166,35,00,00 GUIPal 167,00,00,00 ; Blue scale shadow mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 GUIPal 172,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 171,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 170,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 169,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 168,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 call DecPalVal call DecPalVal GUIPal 177,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 176,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 175,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 174,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 173,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 call DecPalVal call DecPalVal call DecPalVal call DecPalVal GUIPal 182,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 181,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 180,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 179,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal 178,[TRVal],[TGVal],[TBVal] GUIPal 183,20,20,00 GUIPal 184,15,15,00 GUIPal 185,25,00,00 GUIPal 186,17,00,00 GUIPal 187,00,00,00 ; gray scale2 = 189 .. 220 mov dx,03C8h mov al,189 mov bl,0 out dx,al inc dx .loopi mov al,bl add al,al mov ah,bl shr ah,1 sub al,ah out dx,al out dx,al add al,ah out dx,al inc bl cmp bl,64 jne .loopi GUIPal 221,00,55,00 GUIPal 222,00,45,00 GUIPal 223,00,25,00 GUIPal 224,40,0,20 GUIPal 225,32,0,15 GUIPal 226,20,0,10 GUIPal 227,16,0,07 GUIPal 228,45,45,50 GUIPal 229,40,40,45 GUIPal 230,35,35,40 GUIPal 231,30,30,35 GUIPal 232,35,15,15 GUIPal 233,50,12,60 GUIPal 234,30,14,60 cmp byte[GUIPalConv],0 je .convert ret .convert mov byte[GUIPalConv],1 ; Convert Image data to Gray Scale ; Create Palette Table call GUIconvpal ; Convert Current Image in Buffer mov esi,[vidbuffer] mov ecx,288*240 xor eax,eax .next mov al,[esi] mov bl,[SubPalTable+eax] mov [esi],bl inc esi dec ecx jnz .next ret NEWSYM GUICPC, times 256 dw 0 %macro GUIPal16b 4 mov ax,%2 shr ax,1 shl ax,11 mov bx,%3 shl bx,5 or ax,bx mov bx,%4 shr bx,1 or ax,bx mov word[GUICPC+%1*2],ax %endmacro DecPalVal: mov ax,[TRVali] sub word[TRVal],ax mov ax,[TGVali] sub word[TGVal],ax mov ax,[TBVali] sub word[TBVal],ax test word[TRVal],8000h jz .notnegr mov word[TRVal],0 .notnegr test word[TGVal],8000h jz .notnegg mov word[TGVal],0 .notnegg test word[TBVal],8000h jz .notnegb mov word[TBVal],0 .notnegb ret GUISetPal16: ; set palette ; Fixed Color Scale = 0 .. 31 mov word[GUICPC],0 inc al xor ebx,ebx mov bl,1 .loopd xor ecx,ecx mov cl,bl add cl,[GUIRAdd] shr cl,1 shl ecx,11 xor eax,eax mov al,bl add al,[GUIGAdd] shl eax,5 or ecx,eax xor eax,eax mov al,bl add al,[GUIBAdd] shr eax,1 or ecx,eax mov [GUICPC+ebx*2],cx inc bl cmp bl,32 jne .loopd ; gray scale = 32 .. 63 mov bl,32 mov al,32 .loopc mov al,bl add al,al xor ecx,ecx mov cl,al shr ecx,1 shl ecx,11 xor edx,edx mov dl,al shl edx,5 or ecx,edx xor edx,edx mov dl,al shr edx,1 or ecx,edx mov [GUICPC+ebx*2],cx inc bl cmp bl,64 jne .loopc ; shadow = 96 .. 127 xor ebx,ebx .loope xor ecx,ecx mov al,bl add al,[GUIRAdd] mov ah,al add al,al add al,ah shr al,2 shr al,1 or cl,al shl ecx,6 mov al,bl add al,[GUIGAdd] mov ah,al add al,al add al,ah shr al,2 or cl,al shl ecx,5 mov al,bl add al,[GUIBAdd] mov ah,al add al,al add al,ah shr al,2 shr al,1 or cl,al mov [GUICPC+ebx*2+96*2],cx inc bl cmp bl,32 jne .loope ; 0,10,31 mov al,[GUITRAdd] mov [TRVal],al mov al,[GUITGAdd] mov [TGVal],al mov al,[GUITBAdd] mov [TBVal],al mov ax,[TRVal] inc ax shr ax,3 mov [TRVali],ax shl ax,3 add [TRVal],ax mov ax,[TGVal] inc ax shr ax,3 mov [TGVali],ax shl ax,3 add [TGVal],ax mov ax,[TBVal] inc ax shr ax,3 mov [TBVali],ax shl ax,3 add [TBVal],ax GUIPal16b 64,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 65,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 66,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 67,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 68,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 69,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 70,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 71,[TRVal],[TGVal],[TBVal] GUIPal16b 72,40,0,20 GUIPal16b 73,34,0,21 GUIPal16b 80,0,10,28 GUIPal16b 81,0,10,27 GUIPal16b 82,0,10,25 GUIPal16b 83,0,09,24 GUIPal16b 84,0,08,22 GUIPal16b 85,0,07,20 GUIPal16b 86,0,06,18 GUIPal16b 87,0,05,15 GUIPal16b 88,20,0,10 GUIPal16b 89,17,0,10 ; Orange Scale mov cl,20 mov bh,0 mov ah,0 inc dx mov esi,128 .loopf add bh,2 add ah,1 mov edx,1Fh << 6 or dl,bh shl edx,5 mov al,ah shr al,1 or dl,al mov [GUICPC+esi*2],dx inc esi dec cl jnz .loopf ; Blue scale = 148 .. 167 mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 GUIPal16b 152,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 151,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 150,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 149,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 148,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 mov al,[TRVal] shr al,2 sub [TRVal],al mov al,[TGVal] shr al,2 sub [TGVal],al mov al,[TBVal] shr al,2 sub [TBVal],al GUIPal16b 157,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 156,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 155,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 154,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 153,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] add al,al mov [TRVal],al mov al,[GUIWGAdd] add al,al mov [TGVal],al mov al,[GUIWBAdd] add al,al mov [TBVal],al mov byte[TRVali],4 mov byte[TGVali],4 mov byte[TBVali],4 mov al,[TRVal] shr al,1 sub [TRVal],al mov al,[TGVal] shr al,1 sub [TGVal],al mov al,[TBVal] shr al,1 sub [TBVal],al GUIPal16b 162,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 161,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 160,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 159,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 158,[TRVal],[TGVal],[TBVal] GUIPal16b 163,40,40,00 GUIPal16b 164,30,30,00 GUIPal16b 165,50,00,00 GUIPal16b 166,35,00,00 GUIPal16b 167,00,00,00 ; Blue scale shadow mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 GUIPal16b 172,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 171,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 170,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 169,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 168,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 call DecPalVal call DecPalVal GUIPal16b 177,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 176,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 175,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 174,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 173,[TRVal],[TGVal],[TBVal] mov al,[GUIWRAdd] mov [TRVal],al mov al,[GUIWGAdd] mov [TGVal],al mov al,[GUIWBAdd] mov [TBVal],al mov byte[TRVali],2 mov byte[TGVali],2 mov byte[TBVali],2 call DecPalVal call DecPalVal call DecPalVal call DecPalVal GUIPal16b 182,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 181,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 180,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 179,[TRVal],[TGVal],[TBVal] call DecPalVal GUIPal16b 178,[TRVal],[TGVal],[TBVal] GUIPal16b 183,20,20,00 GUIPal16b 184,15,15,00 GUIPal16b 185,25,00,00 GUIPal16b 186,17,00,00 GUIPal16b 187,00,00,00 ; gray scale2 = 189 .. 220 mov bl,0 mov esi,189 .loopi xor edx,edx mov al,bl add al,al mov ah,bl shr ah,1 sub al,ah mov dl,al shr dl,1 shl edx,6 or dl,al shl edx,5 add al,ah shr al,1 or dl,al mov [GUICPC+esi*2],dx inc esi inc bl cmp bl,64 jne .loopi GUIPal16b 221,00,55,00 GUIPal16b 222,00,45,00 GUIPal16b 223,00,25,00 GUIPal16b 224,40,0,20 GUIPal16b 225,32,0,15 GUIPal16b 226,20,0,10 GUIPal16b 227,16,0,07 GUIPal16b 228,45,45,50 GUIPal16b 229,40,40,45 GUIPal16b 230,35,35,40 GUIPal16b 231,30,30,35 GUIPal16b 232,35,15,15 GUIPal16b 233,50,12,60 GUIPal16b 234,30,14,60 GUIPal16b 235,12,60,25 GUIPal16b 236,14,42,25 GUIPal16b 237,60,20,25 GUIPal16b 238,42,20,25 cmp byte[vesa2red10],1 jne .nored10 jmp .nored10 mov esi,GUICPC mov ecx,256 .next2 mov ax,[esi] mov bx,ax and bx,0000000000011111b and ax,1111111111000000b shr ax,1 or ax,bx mov [esi],ax add esi,2 dec ecx jnz .next2 .nored10 cmp byte[GUIPalConv],0 je .convert ret .convert mov byte[GUIPalConv],1 mov esi,[vidbuffer] mov edi,288*240 xor ebx,ebx .next mov ax,[esi+ebx*2] mov ecx,eax shr ecx,11 and ecx,1Fh mov edx,eax shr edx,6 and edx,1Fh add ecx,edx mov edx,eax and edx,1Fh add ecx,edx shr ecx,1 mov al,[.multab+ecx] mov [esi+ebx],al inc ebx dec edi jnz .next ret .multab db 1,1,1,2,2,3,4,4,5,6,6,7,8,8,9,10,10,11,12,12,13,14,14,15,16,16, db 17,18,18,19,20,20,21,22,22,23,24,24,25,26,26,27,28,28,29,30,30, db 31 GUIBufferData: mov ecx,16384 cmp byte[cbitmode],1 jne near .16b add ecx,16384 cmp word[PrevResoln],224 je .nobufb add esi,288*8 .nobufb .16b ; copy to spritetable mov esi,[vidbuffer] cmp word[PrevResoln],224 je .nobufa add esi,288*8 .nobufa mov edi,[spritetablea] add edi,8*288 .loop mov eax,[esi] mov [edi],eax add esi,4 add edi,4 dec ecx jnz .loop mov edi,sprlefttot mov ecx,64*5 .a mov dword[edi],0 add edi,4 dec ecx jnz .a ret GUIUnBuffer: mov ecx,16384 ; copy from spritetable mov edi,[vidbuffer] mov esi,[spritetablea] add esi,8*288 rep movsd mov eax,01010101h mov ecx,2*288 rep stosd ret GUIconvpal: mov ax,[cgram] mov [tempco0],ax test byte[scaddtype],00100000b jz near .noaddition test byte[scaddtype],10000000b jnz near .noaddition mov cx,[cgram] mov ax,cx and ax,001Fh add al,[coladdr] cmp al,01Fh jb .noadd mov al,01Fh .noadd mov bx,ax mov ax,cx shr ax,5 and ax,001Fh add al,[coladdg] cmp al,01Fh jb .noaddb mov al,01Fh .noaddb shl ax,5 add bx,ax mov ax,cx shr ax,10 and ax,001Fh add al,[coladdb] cmp al,01Fh jb .noaddc mov al,01Fh .noaddc shl ax,10 add bx,ax mov [cgram],bx .noaddition mov edi,cgram mov ebx,prevpal xor ah,ah .loopa mov cx,[edi] push eax push ebx mov [ebx],cx mov al,ah mov ax,cx and al,01Fh mov bh,[maxbr] mov bl,bh mul bl mov bl,15 div bl mov [curgsval],al mov ax,cx shr ax,5 and al,01Fh mov bl,bh mul bl mov bl,15 div bl add [curgsval],al mov ax,cx shr ax,10 and al,01Fh mov bl,bh mul bl mov bl,15 div bl add [curgsval],al pop ebx pop eax add edi,2 add ebx,2 push eax push ebx mov al,ah and eax,0FFh mov bl,[curgsval] push eax push ebx mov al,bl mov bl,3 xor ah,ah div bl pop ebx mov bl,al pop eax cmp byte[MessageOn],0 je .nochange128 cmp al,128 jne .nochange128 mov bl,31 .nochange128 or bl,bl jnz .noadder inc bl .noadder mov [SubPalTable+eax],bl pop ebx pop eax inc ah jnz near .loopa mov al,[maxbr] mov [prevbright],al mov ax,[tempco0] mov [cgram],ax ret GUIMousePtr db 50+88,47+88,45+88,43+88,42+88,00,00,00 db 53+88,52+88,46+88,42+88,00,00,00,00 db 55+88,54+88,54+88,44+88,00,00,00,00 db 57+88,57+88,56+88,52+88,45+88,00,00,00 db 59+88,00,00,55+88,50+88,45+88,00,00 db 00,00,00,00,55+88,50+88,45+88,00 db 00,00,00,00,00,55+88,50+88,47+88 db 00,00,00,00,00,00,52+88,00 db 50,47,45,43,40,00,00,00 db 53,52,46,42,00,00,00,00 db 55,54,54,44,00,00,00,00 db 57,57,56,52,45,00,00,00 db 59,00,00,55,50,45,00,00 db 00,00,00,00,55,50,45,00 db 00,00,00,00,00,55,50,47 db 00,00,00,00,00,00,52,00 NEWSYM GUIFontData db 0,0,0,0,0 db 01110000b db 10011000b db 10101000b db 11001000b db 01110000b; 0 db 00100000b db 01100000b db 00100000b db 00100000b db 01110000b; 1 db 01110000b db 10001000b db 00110000b db 01000000b db 11111000b; 2 db 01110000b db 10001000b db 00110000b db 10001000b db 01110000b; 3 db 01010000b db 10010000b db 11111000b db 00010000b db 00010000b; 4 db 11111000b db 10000000b db 11110000b db 00001000b db 11110000b; 5 db 01110000b db 10000000b db 11110000b db 10001000b db 01110000b; 6 db 11111000b db 00001000b db 00010000b db 00010000b db 00010000b; 7 db 01110000b db 10001000b db 01110000b db 10001000b db 01110000b; 8 db 01110000b db 10001000b db 01111000b db 00001000b db 01110000b; 9 db 01110000b db 10001000b db 11111000b db 10001000b db 10001000b; A db 11110000b db 10001000b db 11110000b db 10001000b db 11110000b; B db 01110000b db 10001000b db 10000000b db 10001000b db 01110000b; C db 11110000b db 10001000b db 10001000b db 10001000b db 11110000b; D db 11111000b db 10000000b db 11110000b db 10000000b db 11111000b; E db 11111000b db 10000000b db 11110000b db 10000000b db 10000000b; F db 01111000b db 10000000b db 10011000b db 10001000b db 01110000b; G db 10001000b db 10001000b db 11111000b db 10001000b db 10001000b; H db 11111000b db 00100000b db 00100000b db 00100000b db 11111000b; I db 01111000b db 00010000b db 00010000b db 10010000b db 01100000b; J db 10010000b db 10100000b db 11100000b db 10010000b db 10001000b; K db 10000000b db 10000000b db 10000000b db 10000000b db 11111000b; L db 11011000b db 10101000b db 10101000b db 10101000b db 10001000b; M db 11001000b db 10101000b db 10101000b db 10101000b db 10011000b; N db 01110000b db 10001000b db 10001000b db 10001000b db 01110000b; O db 11110000b db 10001000b db 11110000b db 10000000b db 10000000b; P db 01110000b db 10001000b db 10101000b db 10010000b db 01101000b; Q db 11110000b db 10001000b db 11110000b db 10010000b db 10001000b; R db 01111000b db 10000000b db 01110000b db 00001000b db 11110000b; S db 11111000b db 00100000b db 00100000b db 00100000b db 00100000b; T db 10001000b db 10001000b db 10001000b db 10001000b db 01110000b; U db 10001000b db 10001000b db 01010000b db 01010000b db 00100000b; V db 10001000b db 10101000b db 10101000b db 10101000b db 01010000b; W db 10001000b db 01010000b db 00100000b db 01010000b db 10001000b; X db 10001000b db 01010000b db 00100000b db 00100000b db 00100000b; Y db 11111000b db 00010000b db 00100000b db 01000000b db 11111000b; Z db 00000000b db 00000000b db 11111000b db 00000000b db 00000000b; - db 00000000b db 00000000b db 00000000b db 00000000b db 11111000b; _ db 01101000b db 10010000b db 00000000b db 00000000b db 00000000b; ~ db 00000000b db 00000000b db 00000000b db 00000000b db 00100000b; . db 00001000b db 00010000b db 00100000b db 01000000b db 10000000b; / db 00010000b db 00100000b db 01000000b db 00100000b db 00010000b; < db 01000000b db 00100000b db 00010000b db 00100000b db 01000000b; > db 01110000b db 01000000b db 01000000b db 01000000b db 01110000b; [ db 01110000b db 00010000b db 00010000b db 00010000b db 01110000b; ] db 00000000b db 00100000b db 00000000b db 00100000b db 00000000b; : db 01100000b db 10011000b db 01110000b db 10011000b db 01101000b; & db 00100000b db 00100000b db 10101000b db 01110000b db 00100000b; arrow db 01010000b db 11111000b db 01010000b db 11111000b db 01010000b; # db 00000000b db 11111000b db 00000000b db 11111000b db 00000000b; = db 01001000b db 10010000b db 00000000b db 00000000b db 00000000b; " db 10000000b db 01000000b db 00100000b db 00010000b db 00001000b; \ (Screw you nassm) db 10101000b db 01110000b db 11111000b db 01110000b db 10101000b; * db 01110000b db 10001000b db 00110000b db 00000000b db 00100000b; ? db 10001000b db 00010000b db 00100000b db 01000000b db 10001000b; % db 00100000b db 00100000b db 11111000b db 00100000b db 00100000b; + db 00000000b db 00000000b db 00000000b db 00100000b db 01000000b; , db 00110000b db 01000000b db 01000000b db 01000000b db 00110000b; ( db 01100000b db 00010000b db 00010000b db 00010000b db 01100000b; ) db 01110000b db 10011000b db 10111000b db 10000000b db 01110000b; @ db 00100000b db 01000000b db 00000000b db 00000000b db 00000000b; ' db 00100000b db 00100000b db 00100000b db 00000000b db 00100000b; ! db 01111000b db 10100000b db 01110000b db 00101000b db 11110000b; $ db 00000000b db 00100000b db 00000000b db 00100000b db 01000000b; ; db 01000000b db 00100000b db 00000000b db 00000000b db 00000000b; ` db 00100000b db 01010000b db 00000000b db 00000000b db 00000000b; ^ db 00110000b db 01000000b db 11000000b db 01000000b db 00110000b; { db 01100000b db 00010000b db 00011000b db 00010000b db 01100000b; } db 00100000b db 00100000b db 01110000b db 01110000b db 11111000b; Up db 11111000b db 01110000b db 01110000b db 00100000b db 00100000b; Down db 00001000b db 00111000b db 11111000b db 00111000b db 00001000b; Left db 10000000b db 11100000b db 11111000b db 11100000b db 10000000b; Right db 00100000b db 01100000b db 11111000b db 01100000b db 00100000b; Arrow Left db 00111000b db 00100000b db 00110000b db 00001000b db 10110000b; .5 db 11111100b db 10000100b db 11111100b db 00000000b db 00000000b; Maximize db 00000000b db 11111100b db 00000000b db 00000000b db 00000000b; Minimize db 11111000b db 10001000b db 10001000b db 10001000b db 11111000b; Maximize (Linux) ; 189 .. 220 GUIIconDataClose: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,216,216,216,216,216,216,216,0 ,0 db 214,212,202,212,212,212,202,212,210,0 db 214,212,212,200,212,200,212,212,210,202 db 214,212,212,212,198,212,212,212,210,202 db 214,212,212,196,212,196,212,212,210,200 db 214,212,194,212,212,212,194,212,210,200 db 0 ,208,208,208,208,208,208,208,198,198 db 0 ,0 ,198,198,198,198,198,198,198,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 GUIIconDataButtonHole: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,207,205,207,0 ,0 ,0 ,0 db 0 ,0 ,207,203,202,203,207,0 ,0 ,0 db 0 ,207,203,200,198,200,203,207,0 ,0 db 0 ,207,202,198,197,198,202,207,0 ,0 db 0 ,207,203,200,198,200,203,207,0 ,0 db 0 ,0 ,207,203,202,203,207,0 ,0 ,0 db 0 ,0 ,0 ,207,205,207,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 GUIIconDataButtonFill: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,207,209,207,0 ,0 ,0 ,0 db 0 ,0 ,207,211,212,211,207,0 ,0 ,0 db 0 ,207,211,214,216,214,211,207,0 ,0 db 0 ,207,212,216,217,216,212,207,0 ,0 db 0 ,207,211,214,216,214,211,207,0 ,0 db 0 ,0 ,207,211,212,211,207,0 ,0 ,0 db 0 ,0 ,0 ,207,209,207,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 GUIIconDataSlideBar: db 0 ,0 ,0 ,0 ,216,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,212,216,220,0 ,0 ,0 ,0 db 0 ,0 ,0 ,212,216,220,202,0 ,0 ,0 db 0 ,0 ,212,212,216,218,220,0 ,0 ,0 db 0 ,0 ,212,214,216,218,220,202,0 ,0 db 0 ,0 ,212,214,216,218,220,202,0 ,0 db 0 ,0 ,0 ,212,216,220,202,202,0 ,0 db 0 ,0 ,0 ,212,216,220,202,0 ,0 ,0 db 0 ,0 ,0 ,0 ,216,202,202,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,202,0 ,0 ,0 ,0 GUIIconDataCheckBoxUC: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,220,219,218,217,216,215,0 ,0 ,0 db 0 ,219,218,217,216,215,214,202,0 ,0 db 0 ,218,217,216,215,214,213,202,0 ,0 db 0 ,217,216,215,214,213,212,202,0 ,0 db 0 ,216,215,214,213,212,211,202,0 ,0 db 0 ,215,214,213,212,211,210,202,0 ,0 db 0 ,0 ,202,202,202,202,202,202,0 ,0 GUIIconDataCheckBoxC: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,165,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,165,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,165,0 ,0 ,0 db 0 ,220,219,218,217,165,215,0 ,0 ,0 db 0 ,165,165,217,165,165,214,202,0 ,0 db 0 ,218,165,216,165,214,213,202,0 ,0 db 0 ,217,165,165,165,213,212,202,0 ,0 db 0 ,216,215,165,213,212,211,202,0 ,0 db 0 ,215,214,165,212,211,210,202,0 ,0 db 0 ,0 ,202,202,202,202,202,202,0 ,0 GUIIconDataCheckBoxX: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,165,0 ,0 ,0 ,0 ,0 ,165,0 ,0 db 0 ,220,165,218,217,216,165,0 ,0 ,0 db 0 ,219,218,165,216,165,214,202,0 ,0 db 0 ,218,217,216,165,214,213,202,0 ,0 db 0 ,217,216,165,214,165,212,202,0 ,0 db 0 ,216,165,214,213,212,165,202,0 ,0 db 0 ,165,214,213,212,211,210,165,0 ,0 db 0 ,0 ,202,202,202,202,202,202,0 ,0 GUIIconDataUpArrow: db 201,209,209,209,209,209,209,200,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,205,201,202,203,202,205,203,0 ,0 db 207,200,205,202,203,205,201,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 199,201,201,201,201,201,201,198,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 GUIIconDataDownArrow: db 201,209,209,209,209,209,209,200,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 207,200,205,202,203,205,201,203,0 ,0 db 207,205,201,202,203,202,205,203,0 ,0 db 207,205,205,202,203,205,205,203,0 ,0 db 199,201,201,201,201,201,201,198,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 NEWSYM SnowData dw 161,251,115,211,249,87,128,101,232,176,51,180,108,193,224,112,254,159,102,238 dw 223,123,218,42,173,160,143,170,64,1,174,29,34,187,194,199,40,89,232,32 dw 7,195,141,67,216,48,234,1,243,116,164,182,146,136,66,70,36,43,98,208 dw 63,240,216,253,147,36,33,253,98,80,228,156,73,82,85,1,97,72,187,239 dw 18,196,127,182,22,22,101,25,124,145,240,213,186,22,7,161,30,98,90,197 dw 22,205,32,150,59,133,49,140,10,128,142,185,176,142,220,195,100,102,105,194 dw 43,139,184,153,1,95,176,169,192,201,233,243,73,65,188,14,194,39,251,140 dw 239,181,142,160,242,248,82,49,9,157,233,162,254,121,112,6,118,24,56,121 dw 74,209,1,223,145,6,75,73,18,168,194,168,58,39,222,170,214,75,45,218 dw 39,197,242,98,22,90,255,5,144,244,252,55,98,18,135,101,27,85,215,207 dw 183,28,201,142,45,122,145,159,41,243,109,29,117,203,7,234,231,214,131,133 dw 217,8,74,207,130,77,21,229,167,78,218,109,142,58,134,238,29,182,178,14 dw 144,129,196,219,60,128,30,105,57,53,76,122,242,208,101,241,246,99,248,67 dw 137,244,70,51,202,94,164,125,115,72,61,72,129,169,155,122,91,154,160,83 dw 41,102,223,218,140,40,132,16,223,92,50,230,168,47,126,117,242,136,1,245 dw 171,0,36,98,73,69,14,229,66,177,108,92,39,250,243,161,111,85,211,99 dw 52,98,121,188,128,201,90,205,223,92,177,19,87,18,75,54,6,81,235,137 dw 247,66,211,129,247,39,119,206,116,250,113,231,190,196,53,51,34,114,39,22 dw 192,33,249,151,26,22,139,97,171,238,182,88,22,176,157,255,178,199,138,98 dw 140,36,112,90,25,245,134,64,48,190,165,113,24,195,84,70,175,9,179,69 dw 13,26,167,237,163,159,185,128,109,114,86,74,188,103,141,48,188,203,205,191 dw 215,193,224,4,153,36,108,3,172,235,56,251,211,115,173,216,240,33,78,150 dw 133,64,51,103,56,26,165,222,70,148,115,119,246,229,181,63,109,49,228,108 dw 126,10,170,48,87,42,193,24,28,255,176,176,209,181,97,93,61,241,201,137 dw 129,97,24,159,168,215,61,113,104,143,168,7,196,216,149,239,110,65,75,143 dw 238,0,37,19,8,56,65,234,228,72,42,5,226,95,243,51,55,231,114,90 dw 160,141,171,108,218,252,154,64,175,142,214,211,180,129,217,118,33,130,213,2 dw 73,145,93,21,162,141,97,225,112,253,49,43,113,208,131,104,31,51,192,37 dw 117,186,16,45,61,114,220,6,89,163,197,203,142,80,89,115,190,190,228,15 dw 166,145,59,139,120,79,104,252,246,73,113,144,224,65,204,155,221,85,31,99 dw 48,253,94,159,215,31,123,204,248,153,31,210,174,178,54,146,152,88,56,92 dw 197,35,124,104,211,118,1,207,108,68,123,161,107,69,143,13,79,170,130,193 dw 214,153,219,247,227,2,170,208,248,139,118,241,247,183,18,135,246,126,201,46 dw 70,234,171,72,18,135,236,216,32,178,148,231,161,15,6,254,34,181,5,71 dw 2,219,71,87,252,16,202,190,180,83,99,209,75,134,78,84,114,32,171,246 dw 125,11,57,200,102,29,176,26,205,151,152,108,100,146,117,95,71,77,158,207 dw 60,192,50,135,223,237,231,53,27,195,170,146,155,160,92,224,247,187,14,50 dw 203,5,153,42,17,75,109,14,78,160,236,114,131,105,189,209,233,135,221,207 dw 226,119,104,10,178,107,77,160,233,179,120,227,133,241,32,223,63,247,66,157 dw 140,81,118,81,63,193,173,228,214,78,124,123,222,149,9,242,0,128,194,110 NEWSYM SnowVelDist db 57,92,100,19,100,184,238,225,55,240,255,221,215,105,226,153,164,41,22,93 db 176,203,155,199,244,52,233,219,110,227,229,227,152,240,83,248,226,31,163,22 db 28,156,18,10,248,67,123,167,25,138,90,10,79,107,208,229,248,233,185,10 db 167,21,19,178,132,154,81,70,20,71,95,147,72,27,91,189,13,189,102,84 db 195,123,251,93,68,36,178,59,107,99,104,191,76,110,44,206,123,46,98,112 db 26,50,1,35,150,17,242,208,69,23,202,197,59,80,136,124,40,89,11,40 db 1,136,90,72,198,83,2,174,174,4,28,205,135,35,194,54,22,40,4,132 db 191,88,163,66,204,230,35,111,9,177,254,174,163,68,5,88,111,235,58,236 db 4,248,172,154,101,164,43,223,10,13,210,125,146,73,192,57,117,152,128,36 db 106,21,253,113,110,133,244,4,150,32,76,71,22,106,210,244,46,128,27,215 db 231,112,177,196,198,120,196,57,234,74,235,108,64,181,209,188,177,63,197,200 db 126,164,136,163,48,62,225,223,212,201,195,121,90,7,10,196,88,53,39,249 db 147,98,65,253,246,3,152,125,242,105,44,129,94,232,13,4,86,220,194,67 db 186,210,171,197,64,138,89,78,58,150,52,79,138,201,244,111,106,181,192,69 db 234,253,239,113,98,37,209,151,60,47,241,235,185,52,173,94,172,182,47,150 db 80,118,10,58,161,237,10,64,238,198,14,74,132,250,234,63,169,86,158,170 db 76,168,124,133,28,203,246,140,228,77,50,53,115,113,157,218,90,192,28,209 db 72,117,156,101,226,99,11,245,69,59,17,175,164,59,8,166,163,185,10,60 db 100,19,26,38,114,232,180,115,238,184,88,103,178,67,212,21,87,64,85,1 db 62,87,155,62,21,96,205,195,131,97,191,252,218,209,179,201,12,2,234,110 db 162,14,145,170,156,105,85,132,132,60,239,14,80,129,225,144,149,244,188,8 db 13,168,181,168,30,142,24,110,26,172,231,182,50,214,66,193,100,45,132,144 db 205,190,16,133,45,250,83,183,140,229,117,226,68,59,163,96,235,227,25,155 db 209,105,41,214,30,107,2,85,180,23,241,39,113,63,75,44,107,142,93,29 db 62,240,235,152,147,52,54,146,109,112,139,162,238,198,201,8,141,115,112,106 db 4,99,25,155,111,161,114,253,75,100,28,59,101,150,2,122,228,6,12,59 db 249,181,67,136,227,227,199,46,75,203,50,25,50,61,62,22,238,124,218,134 db 243,21,243,222,94,138,161,234,133,23,138,45,4,226,154,227,8,84,105,126 db 200,127,240,144,124,197,102,144,53,29,94,231,108,175,136,37,44,183,178,95 db 41,196,214,12,42,221,106,225,151,32,53,130,24,211,88,14,135,18,90,219 db 177,129,90,217,162,181,199,133,116,56,36,100,230,91,220,83,41,65,20,64 db 177,197,249,24,242,62,26,234,92,44,167,153,243,94,179,163,103,29,220,199 db 128,94,236,152,53,32,77,78,228,89,124,85,87,50,197,116,179,105,236,139 db 102,17,159,66,176,27,205,36,113,80,60,6,61,174,254,174,246,72,154,31 db 97,40,10,8,114,203,238,26,89,51,134,110,118,176,87,32,192,210,146,207 db 88,45,156,179,61,224,87,107,107,1,252,187,203,100,169,211,205,105,12,231 db 137,176,166,37,192,241,169,84,32,85,112,168,154,7,247,146,183,225,246,173 db 57,103,110,236,113,118,203,200,22,87,251,7,138,37,12,84,221,171,51,209 db 242,37,89,73,151,162,139,189,131,209,221,96,107,144,175,79,199,123,98,138 db 226,86,221,254,72,14,126,180,200,171,85,94,120,124,196,225,150,57,219,158 NEWSYM GuiAsmEnd zsnes-1.36/src/gui/guicombo.inc0100644000175000017500000000754707432621316016057 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ComboClip: xor eax,eax mov al,[GUINumCombo] .next cmp al,42 jae .excess mov byte[GUIComboData+eax],0 inc eax jmp .next .excess ret ComboAdder: cmp byte[romloadskip],0 je .romloaded cmp byte[GUIComboGameSpec],0 jne near .skipall .romloaded pushad call ComboClip mov eax,[NumCombo] shl eax,6 add eax,[NumCombo] add eax,[NumCombo] add eax,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespec sub eax,CombinDataGlob add eax,CombinDataLocl .nogamespec ; copy data to eax mov ecx,20 ; copy name mov ebx,GUIComboTextH .loop mov dl,[ebx] mov [eax],dl inc ebx inc eax dec ecx jnz .loop mov ecx,42 ; copy combination code mov ebx,GUIComboData .loop2 mov dl,[ebx] mov [eax],dl inc ebx inc eax dec ecx jnz .loop2 mov dx,[GUIComboKey] mov [eax],dx mov dl,[GUIComboPNum] mov [eax+2],dl mov dl,[GUIComboLHorz] mov [eax+3],dl mov eax,[NumCombo] mov [GUIccombcursloc],eax sub eax,7 cmp [GUIccombviewloc],eax jge .rangeokay mov [GUIccombviewloc],eax .rangeokay inc dword[NumCombo] mov eax,[NumCombo] cmp byte[GUIComboGameSpec],0 jne .local mov [NumComboGlob],eax jmp .global .local mov [NumComboLocl],eax .global popad mov byte[GUIComboTextH],0 mov byte[GUINumCombo],0 mov dword[GUIComboKey],0 .skipall ret ComboReplace: pushad call ComboClip mov eax,[GUIccombcursloc] shl eax,6 add eax,[GUIccombcursloc] add eax,[GUIccombcursloc] add eax,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespec sub eax,CombinDataGlob add eax,CombinDataLocl .nogamespec ; copy data to eax mov ecx,20 ; copy name mov ebx,GUIComboTextH .loop mov dl,[ebx] mov [eax],dl inc ebx inc eax dec ecx jnz .loop mov ecx,42 ; copy combination code mov ebx,GUIComboData .loop2 mov dl,[ebx] mov [eax],dl inc ebx inc eax dec ecx jnz .loop2 mov dx,[GUIComboKey] mov [eax],dx mov dl,[GUIComboPNum] mov [eax+2],dl mov dl,[GUIComboLHorz] mov [eax+3],dl popad ret ComboRemoval: pushad mov eax,[GUIccombcursloc] shl eax,6 add eax,[GUIccombcursloc] add eax,[GUIccombcursloc] add eax,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespec sub eax,CombinDataGlob add eax,CombinDataLocl .nogamespec mov ecx,[NumCombo] sub ecx,[GUIccombcursloc] dec ecx cmp ecx,0 jle .nomove .loop2 mov ebx,66 .loop mov dl,[eax+66] mov [eax],dl inc eax dec ebx jnz .loop dec ecx jnz .loop2 .nomove dec dword[NumCombo] mov eax,[NumCombo] or eax,eax jz .yeszero dec eax .yeszero cmp [GUIccombviewloc],eax jbe .notequal mov [GUIccombviewloc],eax .notequal cmp [GUIccombcursloc],eax jbe .notequal2 mov [GUIccombcursloc],eax .notequal2 mov eax,[NumCombo] cmp byte[GUIComboGameSpec],0 jne .local mov [NumComboGlob],eax jmp .global .local mov [NumComboLocl],eax .global popad ret zsnes-1.36/src/gui/guikeys.inc0100644000175000017500000015673507437052745015750 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; GUI Keyboard Routines %macro GUIqcheckkeys 1 cmp byte[pressed+%1],1 jne %%skip mov dword[GUIfirstkey],1 %%skip %endmacro %macro GUIqcheckkeys2 2 mov eax,%1 cmp byte[pressed+eax],1 jne %%skip cmp byte[GUIJoyPadnk+%2],2 je %%skip mov dword[GUIfirstkey],1 %%skip %endmacro %macro GUIgetprkeys 2 cmp byte[pressed+%1],1 je %%okay cmp byte[pressed+%1],2 jne %%nopr cmp dword[GUIfirstkey],1 je %%nopr cmp dword[GUIlastkey],%1 jne %%nopr jmp %%skipnext %%okay mov dword[GUInextkeydelay],10 %%skipnext mov dword[GUIlastkey],%1 mov byte[pressed+%1],2 cmp dword[GUIkeydelay],0 jne near .done mov eax,[GUInextkeydelay] mov [GUIkeydelay],eax mov dword[GUInextkeydelay],2 mov eax,%2 jmp .done %%nopr %endmacro %macro GUIgetprkeysb 2 cmp byte[pressed+%1],1 jne %%nopr cmp byte[GUIescpress],1 je %%nopr2 mov byte[pressed+%1],2 mov eax,%2 jmp .done %%nopr cmp byte[pressed+%1],0 jne %%nopr2 mov byte[GUIescpress],0 %%nopr2 %endmacro %macro GUIgetprkeys2 3 mov ebx,%1 cmp byte[pressed+ebx],0 jne %%pressed mov byte[GUIJoyPadnk+%3],0 jmp %%nopr %%pressed cmp byte[GUIJoyPadnk+%3],2 je %%secondpress cmp byte[pressed+ebx],1 je %%okay %%secondpress cmp dword[GUIfirstkey],1 je %%nopr cmp dword[GUIlastkey],ebx jne %%nopr jmp %%skipnext %%okay mov dword[GUInextkeydelay],10 %%skipnext mov [GUIlastkey],ebx mov byte[GUIJoyPadnk+%3],2 cmp dword[GUIkeydelay],0 jne near .done mov eax,[GUInextkeydelay] mov [GUIkeydelay],eax mov byte[GUIDelayB],5 mov dword[GUInextkeydelay],2 mov eax,%2 jmp .done %%nopr %endmacro %macro GUIkeystoggleoptn 2 cmp %1,%2 jne %%set xor %1,%2 jmp %%clear %%set mov %1,%2 %%clear ret %%noclick %endmacro GUIfirstkey dd 0 GUIlastkey dd 0 NEWSYM GUIkeydelay, dd 0 NEWSYM GUIkeydelay2, dd 0 GUInextkeydelay dd 0 GUIJoyPadnk db 0,0,0,0,0,0,0,0 NEWSYM GUIDelayB, db 0 UseExtKey db 0 GUIgetcurrentinput: cmp byte[HoldCommand],2 jne .nohold ret .nohold mov byte[UseExtKey],0 xor ch,ch xor cl,cl .getnextkey call Check_Key or al,al jz .nokeyd call Get_Key cmp cl,0 jne .nostorekey mov ch,al .nostorekey xor cl,cl cmp al,0 jne .noextkey call Get_Key mov [UseExtKey],al xor al,al mov ch,al mov cl,1 .noextkey ; jmp .getnextkey .nokeyd mov dh,ch mov byte[GUIDelayB],0 ; Convert pressed to keys mov dword[GUIfirstkey],0 %ifdef __LINUX___ GUIqcheckkeys 90 ; UP GUIqcheckkeys 96 ; DOWN GUIqcheckkeys 92 ; LEFT GUIqcheckkeys 94 ; RIGHT GUIqcheckkeys 89 ; HOME GUIqcheckkeys 91 ; PGUP GUIqcheckkeys 95 ; END GUIqcheckkeys 97 ; PGDOWN %endif GUIqcheckkeys 72 ; NUMPAD STUFF GUIqcheckkeys 80 GUIqcheckkeys 75 GUIqcheckkeys 77 GUIqcheckkeys 73 GUIqcheckkeys 81 GUIqcheckkeys 71 GUIqcheckkeys 79 GUIqcheckkeys 1 GUIqcheckkeys 1Ch ; cmp byte[OSPort],3 ; jne near .notwinport %ifndef __MSDOS__ GUIqcheckkeys 0C8h GUIqcheckkeys 0D0h GUIqcheckkeys 0CBh GUIqcheckkeys 0CDh GUIqcheckkeys 0C9h GUIqcheckkeys 0D1h GUIqcheckkeys 0C7h GUIqcheckkeys 0CFh GUIqcheckkeys 09Ch %endif .notwinport cmp byte[JoyPad1Move],0 je near .nopad1 push edx call JoyRead pop edx GUIqcheckkeys2 [pl1upk],0 GUIqcheckkeys2 [pl1downk],1 GUIqcheckkeys2 [pl1leftk],2 GUIqcheckkeys2 [pl1rightk],3 GUIqcheckkeys2 [pl1Lk],4 GUIqcheckkeys2 [pl1Rk],5 GUIqcheckkeys2 [pl1Bk],6 GUIqcheckkeys2 [pl1Ak],7 .nopad1 xor al,al %ifdef __LINUX__ GUIgetprkeys 90,90 ; UP GUIgetprkeys 96,96 ; DOWN GUIgetprkeys 92,92 ; LEFT GUIgetprkeys 94,94 ; RIGHT GUIgetprkeys 89,89 ; HOME GUIgetprkeys 91,91 ; PGUP GUIgetprkeys 95,95 ; END GUIgetprkeys 97,97 ; PGDOWN GUIgetprkeys 72,72 ; KP8 GUIgetprkeys 80,80 ; KP2 GUIgetprkeys 75,75 ; KP4 GUIgetprkeys 77,77 ; KP6 GUIgetprkeys 71,71 ; KP7 GUIgetprkeys 79,79 ; KP9 GUIgetprkeys 81,81 ; KP1 GUIgetprkeys 73,73 ; KP3 %else ; GUIgetprkeys 72,72 ; GUIgetprkeys 80,80 GUIgetprkeys 75,75 GUIgetprkeys 77,77 GUIgetprkeys 71,71 GUIgetprkeys 79,79 GUIgetprkeys 81,81 GUIgetprkeys 73,73 %endif GUIgetprkeysb 1,27 GUIgetprkeys 1Ch,13 mov cl,[UseExtKey] cmp cl,72 je .okayextk cmp cl,80 jne .notextkb .okayextk mov al,cl .notextkb ; cmp byte[OSPort],3 ; jne near .notwinport2 %ifdef __LINUX__ GUIgetprkeys 90,90 ; UP GUIgetprkeys 96,96 ; DOWN GUIgetprkeys 92,92 ; LEFT GUIgetprkeys 94,94 ; RIGHT GUIgetprkeys 89,89 ; HOME GUIgetprkeys 91,91 ; PGUP GUIgetprkeys 95,95 ; END GUIgetprkeys 97,97 ; PGDOWN GUIgetprkeys 72,72 ; KP8 GUIgetprkeys 80,80 ; KP2 GUIgetprkeys 75,75 ; KP4 GUIgetprkeys 77,77 ; KP6 GUIgetprkeys 71,71 ; KP7 GUIgetprkeys 79,79 ; KP9 GUIgetprkeys 81,81 ; KP1 GUIgetprkeys 73,73 ; KP3 GUIgetprkeys 09Ch,13 ; ENTER %endif %ifdef __WIN32__ GUIgetprkeys 0CBh,75 GUIgetprkeys 0CDh,77 GUIgetprkeys 0C9h,73 GUIgetprkeys 0D1h,81 GUIgetprkeys 0C7h,71 GUIgetprkeys 0CFh,79 GUIgetprkeys 09Ch,13 %endif ;.notwinport2 cmp byte[JoyPad1Move],0 je near .nopad1b GUIgetprkeys2 [pl1upk],72,0 GUIgetprkeys2 [pl1downk],80,1 GUIgetprkeys2 [pl1leftk],75,2 GUIgetprkeys2 [pl1rightk],77,3 GUIgetprkeys2 [pl1Lk],73,4 GUIgetprkeys2 [pl1Rk],81,5 GUIgetprkeys2 [pl1Bk],27,6 GUIgetprkeys2 [pl1Ak],13,7 .nopad1b cmp dh,' ' jne .notspace mov al,' ' .notspace mov dword[GUInextkeydelay],10 mov dword[GUIkeydelay],0 .done cmp byte[GUIcmenupos],0 jne near .processmenu mov dl,al xor eax,eax mov al,[GUIwinptr] cmp dl,27 jne .noclosewin or eax,eax jz near .runprog .noclosewin dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] cmp ebx,8 jne near .nonetwin cmp byte[CNetType],12 jne .noprocess7 cmp byte[ModemProcess],7 jne .noprocess7 cmp dh,13 je .ret cmp dh,32 jb .noprocess7 .ret mov al,dh call ModemSendChar ret .noprocess7 cmp dl,27 jne .nonetwin cmp byte[CNetType],2 je .yesnetwin cmp byte[CNetType],3 je .yesnetwin cmp byte[CNetType],10 je .yesnetwin cmp byte[CNetType],11 je .yesnetwin cmp byte[CNetType],12 je .yesnetwin cmp byte[CNetType],15 je .yesnet15 jmp .nonetwin .yesnet15 mov byte[CNetType],0 ; cmp byte[OSPort],1 ; je .nodeinitipx call deinitipx .nodeinitipx jmp .closewin .yesnetwin cmp byte[ModemInitStat],0 je .nodeinitmodem call DeInitModemC mov byte[ModemInitStat],0 .nodeinitmodem mov byte[CNetType],1 ret .nonetwin cmp ebx,13 jne .notcskeys cmp byte[CheatWinMode],1 ja .avoidesc .notcskeys cmp dl,27 je near .closewin .avoidesc mov al,dl cmp ebx,1 je near GUILoadKeys cmp ebx,2 je near GUIStateSelKeys cmp ebx,4 je near GUIOptionKeys cmp ebx,5 je near GUIVideoKeys cmp ebx,6 je near GUISoundKeys cmp ebx,7 je near GUICheatKeys cmp ebx,10 je near GUIGUIOptnsKeys cmp ebx,12 je near GUIResetKeys cmp ebx,13 je near GUICheatSearchKeys cmp ebx,14 je near GUIStateKeys cmp ebx,16 je near GUIComboKeys cmp ebx,8 jne .notstartmenu cmp byte[CNetType],4 jne .notcpip jmp GUITCPIPKeys .notcpip cmp byte[CNetType],1 jne .notstartmenu jmp GUINetMenuKeys1 .notstartmenu cmp ebx,8 je near GUIGetInputLine ret .runprog cmp byte[romloadskip],0 jne .noquit mov byte[GUIQuit],2 .noquit ret .closewin ; close window mov byte[GUIwinorder+eax],0 mov byte[GUIwinactiv+ebx],0 dec byte[GUIwinptr] cmp byte[GUIwinptr],0 jne .nowinopen mov al,[GUIpmenupos] mov [GUIcmenupos],al .nowinopen ret .processmenu cmp dh,'a' jb .nolower cmp dh,'z' ja .nolower sub dh,'a'-'A' .nolower cmp byte[GUIcmenupos],1 jne near .noquickmenu cmp dh,'1' jne .no1 mov byte[GUIcrowpos],0 .no1 cmp dh,'2' jne .no2 mov byte[GUIcrowpos],1 .no2 cmp dh,'3' jne .no3 mov byte[GUIcrowpos],2 .no3 cmp dh,'4' jne .no4 mov byte[GUIcrowpos],3 .no4 cmp dh,'5' jne .no5 mov byte[GUIcrowpos],4 .no5 cmp dh,'6' jne .no6 mov byte[GUIcrowpos],5 .no6 cmp dh,'7' jne .no7 mov byte[GUIcrowpos],6 .no7 cmp dh,'8' jne .no8 mov byte[GUIcrowpos],7 .no8 cmp dh,'9' jne .no9 mov byte[GUIcrowpos],8 .no9 cmp dh,'0' jne .no0 mov byte[GUIcrowpos],9 .no0 cmp dh,'F' jne .nof mov byte[GUIcrowpos],11 .nof cmp dh,'C' jne .noc mov byte[GUIcrowpos],12 .noc .noquickmenu cmp byte[GUIcmenupos],2 jne near .noloadmenu cmp dh,'L' jne .nol mov byte[GUIcrowpos],0 .nol cmp dh,'R' jne .nor mov byte[GUIcrowpos],2 .nor cmp dh,'S' jne .nos mov byte[GUIcrowpos],4 .nos cmp dh,'O' jne .noo mov byte[GUIcrowpos],5 .noo cmp dh,'P' jne .nop mov byte[GUIcrowpos],6 .nop cmp dh,'Q' jne .noq mov byte[GUIcrowpos],8 .noq .noloadmenu cmp byte[GUIcmenupos],4 jne near .nocheatmenu cmp dh,'A' jne .noa mov byte[GUIcrowpos],0 .noa cmp dh,'B' jne .nob mov byte[GUIcrowpos],1 .nob cmp dh,'S' jne .nos2 mov byte[GUIcrowpos],2 .nos2 .nocheatmenu cmp byte[romloadskip],0 jne .dontquit cmp al,27 jne .noexit mov byte[GUIQuit],2 .noexit .dontquit cmp al,13 jne .noenter call GUITryMenuItem .noenter %ifdef __LINUX__ cmp al,92 je .leftpressed cmp dword[numlockptr],1 je .noleft cmp al,75 jne .noleft .leftpressed %else cmp al,75 jne .noleft %endif mov byte[GUIcrowpos],0 cmp byte[GUIcmenupos],1 jbe .left dec byte[GUIcmenupos] jmp .noleft .left mov byte[GUIcmenupos],6 .noleft %ifdef __LINUX__ cmp al,94 je .rightpressed cmp dword[numlockptr],1 je .noright cmp al,77 jne .noright .rightpressed %else cmp al,77 jne .noright %endif mov byte[GUIcrowpos],0 inc byte[GUIcmenupos] cmp byte[GUIcmenupos],7 jne .noright mov byte[GUIcmenupos],1 .noright cmp byte[GUIcmenupos],0 je near .noupdown %ifdef __LINUX__ cmp al,96 je .downpressed cmp dword[numlockptr],1 je .nodown cmp al,80 jne .nodown .downpressed %else cmp al,80 jne .nodown %endif xor eax,eax mov al,[GUIcrowpos] mov ebx,[GUICYLocPtr] cmp byte[eax+ebx+1],2 jne .nobottom mov byte[GUIcrowpos],0 jmp .nokey .nobottom inc eax cmp byte[eax+ebx+1],0 je .nobottom mov [GUIcrowpos],al jmp .nokey .nodown %ifdef __LINUX__ cmp al, 90 je .uppressed cmp dword[numlockptr],1 je .noup cmp al,72 jne .noup .uppressed %else cmp al,72 jne .noup %endif xor eax,eax mov al,[GUIcrowpos] mov ebx,[GUICYLocPtr] or al,al jz .top cmp byte[eax+ebx+1],3 jne .notop .top mov al,[ebx] mov byte[GUIcrowpos],al jmp .nokey .notop dec eax cmp byte[eax+ebx+1],0 je .notop mov [GUIcrowpos],al jmp .nokey .noup .noupdown .nokey ret GUITCPIPKeys: ;GUINetTextk2 db ' 0. 0. 0. 0',0 ;GUINetTextl2 db '7845',0 ;GUINetTextm2 db 0,0,0 cmp byte[GUINetTextm2],1 je near .section2 mov edi,TCPIPAddress mov esi,26 cmp byte[GUINetTextm2],2 jne .notsecondstring mov edi,ChatNick mov esi,9 .notsecondstring mov ebx,edi .next cmp byte[ebx],0 je .done2 inc ebx jmp .next .done2 sub ebx,edi mov [GUINetTextm2+1],bl xor eax,eax mov al,[GUINetTextm2+1] shl al,2 add al,2 cmp dh,32 jbe .notnum2 cmp byte[GUINetTextm2],0 je .notsecondstringb cmp dh,'_' je .notsecondstringb cmp dh,'-' je .notsecondstringb cmp dh,'^' je .notsecondstringb cmp dh,'=' je .notsecondstringb cmp dh,'+' je .notsecondstringb cmp dh,'[' je .notsecondstringb cmp dh,']' je .notsecondstringb cmp dh,'0' jb .notnum2 cmp dh,'9' jbe .notsecondstringb cmp dh,'A' jb .notnum2 cmp dh,'Z' jbe .notsecondstringb cmp dh,'a' jb .notnum2 cmp dh,'z' jbe .notsecondstringb .notsecondstringb cmp ebx,esi jae near .donesection1 add ebx,edi mov byte[ebx],dh jmp .donesection1 .notnum2 cmp dh,8 jne .notbacksp or ebx,ebx jz near .donesection1 add ebx,edi mov byte[ebx-1],0 jmp .donesection1 .notbacksp cmp dh,'c' je .yesc cmp dh,'C' jne .noc .yesc ; mov byte[CNetType],15 ; mov byte[ModemProcess],41 ; mov byte[WhichRemote],4 .noc cmp dh,'s' je .yess cmp dh,'S' jne .nos .yess ; mov byte[CNetType],15 ; mov byte[ModemProcess],40 ; mov byte[WhichRemote],4 .nos .donesection1 ret .section2 mov ebx,GUINetTextl2 .loopz cmp byte[ebx],0 je .donez inc ebx jmp .loopz .donez cmp byte[GUINetTextl2],'0' jne .notzerob cmp byte[GUINetTextl2+1],0 jne .notzerob dec ebx .notzerob cmp dh,'0' jb .notnum cmp dh,'9' ja .notnum mov byte[ebx],dh mov byte[ebx+1],0 push ebx call .convert pop ebx cmp ecx,65536 jb .donenumb mov byte[ebx],0 .donenumb jmp .donenum .notnum cmp dh,8 jne .donenum cmp byte[GUINetTextl2],0 je .donenum mov byte[ebx-1],0 .donenum call .convert cmp ecx,0 jne .notzero mov byte[GUINetTextl2],'0' mov byte[GUINetTextl2+1],0 .notzero mov [TCPIPPortNum],ecx ret .convert mov ebx,GUINetTextl2 xor ecx,ecx .loop cmp byte[ebx],0 je .done mov eax,ecx push ebx mov ebx,10 mul ebx pop ebx mov ecx,eax xor eax,eax mov al,[ebx] sub eax,48 add ecx,eax inc ebx jmp .loop .done ret NEWSYM TCPIPPortNum, dd 7845 GUIOptionKeys: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,'A' jne .noautofr mov byte[FPSOn],0 cmp byte[frameskip],0 je .zero mov byte[frameskip],0 jmp .notzero .zero mov byte[frameskip],2 .notzero .noautofr cmp dh,'N' jne .nonewgfx xor eax,eax mov al,[cvidmode] cmp byte[GUINGVID+eax],1 jne near .invalidng xor byte[newengen],1 mov al,[newengen] mov [cfgnewgfx],al .invalidng .nonewgfx cmp dh,'T' jne .noautoincsave xor byte[AutoIncSaveSlot],1 mov byte[firstsaveinc],1 .noautoincsave cmp dh,'M' jne .nommxcopy xor byte[MMXSupport],1 call MMXCheck .nommxcopy cmp dh,'U' jne .nousepl34 xor byte[pl12s34],1 mov byte[MultiTap],1 cmp byte[pl12s34],1 je .nomtap cmp byte[pl3contrl],0 jne .mtap cmp byte[pl4contrl],0 jne .mtap cmp byte[pl5contrl],0 jne .mtap .nomtap mov byte[MultiTap],0 .mtap .nousepl34 cmp dh,'S' jne .noswfix xor byte[SidewinderFix],1 .noswfix %ifdef __WIN32__ cmp dh,'H' jne .nohighpriority xor byte[HighPriority],1 .nohighpriority %endif cmp dh,'F' jne .nofpsatstart xor byte[FPSAtStart],1 .nofpsatstart cmp dh,'E' jne .nouse30hz xor byte[Turbo30hz],1 .nouse30hz cmp dh,'C' jne .nogameclock xor byte[TimerEnable],1 .nogameclock cmp dh,'G' jne .nofastforward xor byte[FastFwdToggle],1 .nofastforward cmp dh,'R' jne .nosramcheck xor byte[SRAMSave5Sec],1 .nosramcheck cmp dh,'O' jne .nooldgfx xor byte[OldGfxMode2],1 .nooldgfx cmp dh,'L' jne .nostartsave xor byte[LatestSave],1 .nostartsave cmp dh,'/' jne .noautostate xor byte[AutoState],1 .noautostate cmp dh,'D' jne .nosavepath xor byte[DontSavePath],1 .nosavepath %ifdef __WIN32__ cmp dh,'I' jne .noscreensaver xor byte[DisableScreenSaver],1 .noscreensaver cmp dh,'S' jne .noalttimer xor byte[AlternateTimer],1 call guimustrestartmsg .noalttimer %endif ret GUIGUIOptnsKeys: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,'M' jne .guioptn1 xor byte[mousewrap],1 .guioptn1 cmp dh,'S' jne .guioptn2 xor byte[mouseshad],1 .guioptn2 cmp dh,'K' jne .guioptn3 xor byte[lastcursres],1 .guioptn3 cmp dh,'W' jne .guioptn4 xor byte[resetposn],1 .guioptn4 cmp dh,'C' jne .guioptn5 xor byte[GUIClick],1 .guioptn5 cmp dh,'U' jne .guioptn6 xor byte[JoyPad1Move],1 .guioptn6 cmp dh,'N' jne .guioptn6b GUIkeystoggleoptn byte[GUIEffect],1 .guioptn6b cmp dh,'O' jne .guioptn7 GUIkeystoggleoptn byte[GUIEffect],4 .guioptn7 cmp dh,'E' jne .guioptn7b GUIkeystoggleoptn byte[GUIEffect],2 .guioptn7b cmp dh,'B' jne .guioptn8 GUIkeystoggleoptn byte[GUIEffect],3 .guioptn8 %ifdef __WIN32__ cmp dh,'A' jne .guioptn9 xor byte[AlwaysOnTop],1 .guioptn9 cmp dh,'V' jne .guioptn10 xor byte[SaveMainWindowPos],1 .guioptn10 cmp dh,'L' jne .guioptn11 xor byte[AllowMultipleInst],1 .guioptn11 cmp dh,'H' jne .guioptn12 xor byte[MouseWheel],1 .guioptn12 cmp dh,'R' jne .guioptn13 xor byte[TrapMouseCursor],1 .guioptn13 %endif cmp dh,'T' jne .guioptn14 xor byte[GUIEnableTransp],1 .guioptn14 cmp dh,'F' jne .guioptn15 xor byte[FilteredGUI],1 cmp byte[En2xSaI],1 jnae .guioptn15 call ClearScreen call Clear2xSaIBuffer .guioptn15 ret GUIVideoKeys: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap xor eax,eax mov al,[cvidmode] cmp byte[GUISLVID+eax],0 je .nofullscanlines cmp dh,'F' jne .nofullscanlines cmp byte[En2xSaI],0 jne .nofullscanlines call ClearScreen GUIkeystoggleoptn byte[scanlines],1 %ifdef __MSDOS__ cmp byte[cvidmode],2 jne .nomodeq jmp .refresh .nomodeq cmp byte[cvidmode],5 jne .nofullscanlines .refresh mov byte[cbitmode],1 call initvideo2 mov byte[cbitmode],0 call GUISetPal %endif .nofullscanlines xor eax,eax mov al,[cvidmode] cmp byte[GUIHSVID+eax],0 je near .noquarterscanlines cmp dh,'5' jne .nohalfscanlines cmp byte[En2xSaI],0 jne .nohalfscanlines call ClearScreen GUIkeystoggleoptn byte[scanlines],3 %ifdef __MSDOS__ ;cmp byte[cvidmode],2 ;jne .nohalfscanlines ;mov byte[cbitmode],1 ;call initvideo2 ;mov byte[cbitmode],0 ;call GUISetPal %endif .nohalfscanlines cmp dh,'2' jne .noquarterscanlines cmp byte[En2xSaI],0 jne .noquarterscanlines call ClearScreen GUIkeystoggleoptn byte[scanlines],2 %ifdef __MSDOS__ ;cmp byte[cvidmode],2 ;jne .noquarterscanlines ;mov byte[cbitmode],1 ;call initvideo2 ;mov byte[cbitmode],0 ;call GUISetPal %endif .noquarterscanlines cmp dh,'X' jne .no2xsai xor ebx,ebx mov bl,[cvidmode] cmp byte[GUI2xVID+ebx],0 je near .no2xsai call Clear2xSaIBuffer GUIkeystoggleoptn byte[En2xSaI],1 .no2xsai cmp dh,'E' jne .nosupereagle xor ebx,ebx mov bl,[cvidmode] cmp byte[GUI2xVID+ebx],0 je near .nosupereagle call Clear2xSaIBuffer GUIkeystoggleoptn byte[En2xSaI],2 .nosupereagle cmp dh,'S' jne .nosuper2xsai xor ebx,ebx mov bl,[cvidmode] cmp byte[GUI2xVID+ebx],0 je near .nosuper2xsai call Clear2xSaIBuffer GUIkeystoggleoptn byte[En2xSaI],3 .nosuper2xsai cmp dh,'I' jne .nointerpolationwin xor eax,eax mov al,[cvidmode] cmp byte[GUII2VID+eax],0 je .nointerpolationwin xor byte[antienab],1 mov al,[antienab] mov [cfginterp],al .nointerpolationwin cmp dh,'I' jne .nointerpolation xor eax,eax mov al,[cvidmode] cmp byte[GUIIEVID+eax],0 je .nointerpolation xor byte[antienab],1 mov al,[antienab] mov [cfginterp],al .nointerpolation cmp dh,'U' jne .nofullscreen xor eax,eax mov al,[cvidmode] cmp byte[GUIFSVID+eax],0 je .nofullscreen call ClearScreen xor byte[ScreenScale],1 mov al,[ScreenScale] mov [GUIScreenScale],al push eax push ecx mov eax,[vidbufferofsb] mov ecx,288*128 .fsloop mov dword[eax],0 add eax,4 dec ecx jnz .fsloop pop ecx pop eax .nofullscreen cmp dh,'M' jne .nosmallscreen xor eax,eax mov al,[cvidmode] cmp byte[GUISSVID+eax],0 je .nosmallscreen call ClearScreen xor byte[smallscreenon],1 mov al,[smallscreenon] mov [GUIsmallscreenon],al push eax push ecx mov eax,[vidbufferofsb] mov ecx,288*128 .ssloop mov dword[eax],0 add eax,4 dec ecx jnz .ssloop pop ecx pop eax .nosmallscreen cmp dh,'H' jne .nohiresmode7 xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIM7VID+ebx],0 je .nohiresmode7 xor byte[Mode7HiRes16b],1 .nohiresmode7 cmp dh,'B' jne .nobilinearfilter xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIBIFIL+ebx],0 je .nobilinearfilter xor byte[BilinearFilter],1 .nobilinearfilter cmp dh,'T' jne .notriplebufferwin xor eax,eax mov al,[cvidmode] cmp byte[GUITBWVID+eax],0 je near .notriplebufferwin xor byte[TripleBufferWin],1 mov byte[vsyncon],0 mov byte[cfgvsync],0 .notriplebufferwin cmp dh,'T' jne .notriplebuffer xor ebx,ebx mov bl,[cvidmode] cmp byte[GUITBVID+ebx],0 je .notriplebuffer xor byte[Triplebufen],1 mov byte[vsyncon],0 mov byte[cfgvsync],0 .notriplebuffer cmp dh,'G' jne .nograyscale xor byte[GrayscaleMode],1 .nograyscale %ifndef __LINUX__ cmp dh,'V' jne .novsync xor byte[vsyncon],1 mov al,[vsyncon] mov [cfgvsync],al %ifdef __WIN32__ mov byte[TripleBufferWin],0 %endif %ifdef __MSDOS__ mov byte[Triplebufen],0 %endif .novsync %endif ret GUISoundKeys: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,'E' jne .notenablesound xor byte[cfgsoundon],1 .notenablesound %ifdef __MSDOS__ cmp dh,'F' jne .notforce8b xor byte[cfgforce8b],1 .notforce8b %endif cmp dh,'S' jne .notstereo xor byte[cfgStereoSound],1 .notstereo %ifdef __MSDOS__ cmp dh,'A' jne .noraisepitch xor byte[RaisePitch],1 .noraisepitch %endif cmp dh,'N' jne .notnoise xor byte[SoundNoiseDis],1 .notnoise cmp dh,'R' jne .notsrate xor eax,eax mov al,[cfgSoundQuality] mov al,[.sampratenext+eax] mov [cfgSoundQuality],al .notsrate cmp dh,'V' jne .notrevst xor byte[RevStereo],1 .notrevst cmp dh,'U' jne .nosurround xor byte[Surround],1 .nosurround cmp dh,'B' jne .nosoundbuf xor byte[SoundBufEn],1 .nosoundbuf cmp dh,'D' jne .nospcdisable xor byte[SPCDisable],1 .nospcdisable cmp dh,'G' jne .nogausseninterp GUIkeystoggleoptn byte[SoundInterpType],1 .nogausseninterp cmp dh,'C' jne .nocubicinterp GUIkeystoggleoptn byte[SoundInterpType],2 .nocubicinterp %ifndef __MSDOS__ cmp dh,'8' jne .no8ptinterp cmp byte[MMXSupport],0 je .no8ptinterp GUIkeystoggleoptn byte[SoundInterpType],3 .no8ptinterp %endif cmp dh,'I' jne .nosimplefilter GUIkeystoggleoptn byte[LowPassFilterType],1 .nosimplefilter cmp dh,'Y' jne .nodynamicfilter GUIkeystoggleoptn byte[LowPassFilterType],2 .nodynamicfilter %ifndef __MSDOS__ cmp dh,'H' jne .nohiqualityfilter cmp byte[MMXSupport],0 je .nohiqualityfilter GUIkeystoggleoptn byte[LowPassFilterType],3 .nohiqualityfilter %endif ret .sampratenext db 1,4,5,6,2,3,0,0,0,0 GUINetMenuKeys1: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,'C' jne .notconfig mov byte[CNetType],2 .notconfig cmp dh,'D' jne .notdial mov byte[CNetType],3 .notdial cmp dh,'M' jne .notmanual mov byte[CNetType],12 mov byte[ModemProcess],0 cmp byte[ModemInitStat],1 je .noinit call InitModem mov byte[ModemInitStat],1 .noinit ret .notmanual cmp dh,'W' jne .notwait mov byte[CNetType],10 mov byte[ModemProcess],0 cmp byte[ModemInitStat],1 je .noinit2 call InitModem mov byte[ModemInitStat],1 .noinit2 ret .notwait ret GUIGetInputLine: cmp ebx,8 jne .nodial cmp byte[CNetType],20 jne .nochat cmp dh,13 jne .nochat mov byte[RemoteCommand],2 ret .nochat cmp byte[CNetType],3 jne .nodial cmp dh,13 jne .nodial mov byte[CNetType],11 mov byte[ModemProcess],0 cmp byte[ModemInitStat],1 je .noinit call InitModem mov byte[ModemInitStat],1 .noedit ret .noinit .nodial ; search string for 0, record length of string cmp dword[GUIEditString],0 je .noedit mov eax,[GUIEditString] xor ecx,ecx dec ecx .next mov bl,[eax] inc eax inc ecx cmp bl,0 jne .next cmp byte[GUIEditStringcWin],0 je near .blinkstuff cmp ecx,0 je .nodel cmp dh,8 jne .nodel mov byte[eax-2],0 dec eax jmp .blinkstuff .nodel cmp ecx,[GUIEditStringmLen] jne .notend jmp .blinkstuff .notend cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,32 jb .noinsert mov [eax-1],dh mov byte[eax],0 inc eax .noinsert jmp .blinkstuff .blinkstuff dec eax mov [GUIEditStringcLen],eax ret GUIEditString dd 0 ; Pointer to string GUIEditStringcLen dd 0 ; Pointer to end of string (done in function) GUIEditStringmLen dd 0 ; Max length of string GUIEditStringLTxt dd 0 ; blink value, should be set to 0 when box selected GUIEditStringLstb dd 0 ; if cursor is placed (set in main function) GUIEditStringcWin dd 0 ; 0 = no text window selected GUIComboKeys: ; Calculate Position xor eax,eax .nozero cmp byte[GUIComboTextH+eax],0 je .zero inc eax jmp .nozero .zero mov [GUIComboPos],al cmp dh,8 jne .nobacksp cmp byte[GUIComboPos],0 je .nochar mov byte[GUICCFlash],0 xor eax,eax mov al,[GUIComboPos] dec eax mov byte[GUIComboTextH+eax],0 ret .nobacksp cmp dh,0 je .nochar cmp dh,13 je .nochar cmp byte[GUIComboPos],19 je .nochar xor eax,eax mov byte[GUICCFlash],0 mov al,[GUIComboPos] mov byte[GUIComboTextH+eax],dh .nochar ret GUICheatKeys: cmp dword[GUIcurrentcheatwin],1 je near .textboxa cmp dword[GUIcurrentcheatwin],2 je near .textboxb cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp dh,'R' jne .noremocheat jmp CheatCodeRemove .noremocheat cmp dh,'T' jne .notoggcheat jmp CheatCodeToggle .notoggcheat cmp dh,'S' jne .nosavecheat jmp CheatCodeSave .nosavecheat cmp dh,'L' jne .noloadcheat jmp CheatCodeLoad .noloadcheat cmp dword[NumCheats],0 jne .nozero ret .nozero %ifdef __LINUX__ cmp al,89 je .homepressed cmp dword[numlockptr],1 je .nohome cmp al,71 jne .nohome .homepressed %else cmp al,71 jne .nohome %endif mov dword[GUIcurrentcheatcursloc],0 mov dword[GUIcurrentcheatviewloc],0 ret .nohome %ifdef __LINUX__ cmp al,89 je .endppressed cmp dword[numlockptr],1 je .noendp cmp al,79 jne .noendp .endppressed %else cmp al,79 jne .noendp %endif mov eax,[NumCheats] dec eax mov dword[GUIcurrentcheatcursloc],eax sub eax,11 mov dword[GUIcurrentcheatviewloc],eax test dword[GUIcurrentcheatviewloc],8000000h jz .posve mov dword[GUIcurrentcheatviewloc],0 .posve ret .noendp %ifdef __LINUX__ cmp al,90 je .up cmp dword[numlockptr],1 je .noup cmp al,72 jne .noup %else cmp al,72 jne .noup %endif .up cmp dword[GUIcurrentcheatcursloc],0 je .noup mov ebx,[GUIcurrentcheatcursloc] cmp [GUIcurrentcheatviewloc],ebx jne .noviewdec dec dword[GUIcurrentcheatviewloc] .noviewdec dec dword[GUIcurrentcheatcursloc] .noup %ifdef __LINUX__ cmp al, 96 je .downpressed cmp dword[numlockptr],1 je .nodown cmp al,80 jne .nodown .downpressed %else cmp al,80 jne .nodown %endif mov ebx,[GUIcurrentcheatcursloc] inc ebx cmp ebx,[NumCheats] jae .noviewinc inc dword[GUIcurrentcheatcursloc] sub ebx,12 cmp ebx,[GUIcurrentcheatviewloc] jne .noviewinc inc dword[GUIcurrentcheatviewloc] .noviewinc .nodown %ifdef __LINUX__ cmp al,91 je .pageuppressed cmp dword[numlockptr],1 je .nopageup cmp al,73 jne .nopageup .pageuppressed %else cmp al,73 jne .nopageup %endif sub dword[GUIcurrentcheatviewloc],12 sub dword[GUIcurrentcheatcursloc],12 test dword[GUIcurrentcheatviewloc],8000000h jz .posv mov dword[GUIcurrentcheatviewloc],0 .posv test dword[GUIcurrentcheatcursloc],8000000h jz .posc mov dword[GUIcurrentcheatcursloc],0 .posc .nopageup %ifdef __LINUX__ cmp al, 97 je .pagednpressed cmp dword[numlockptr],1 je .nopagedown cmp al,81 jne .nopagedown .pagednpressed %else cmp al,81 jne .nopagedown %endif add dword[GUIcurrentcheatviewloc],12 add dword[GUIcurrentcheatcursloc],12 mov ebx,[NumCheats] dec ebx cmp dword[GUIcurrentcheatcursloc],ebx jb .poscd mov dword[GUIcurrentcheatcursloc],ebx .poscd sub ebx,11 cmp dword[GUIcurrentcheatviewloc],ebx jl .posvd test ebx,8000000h jz .noneg mov ebx,0 .noneg mov dword[GUIcurrentcheatviewloc],ebx .posvd .nopagedown ret .textboxa cmp byte[GUICheatPosA],0 je near .nobacksp cmp dh,9 je .yesret cmp dh,13 jne near .noret .yesret cmp byte[GUICheatPosA],2 jne near .nocodemod mov byte[GUICheatPosA],0 mov esi,[GUIcurrentcheatcursloc] shl esi,5 sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] sub esi,[GUIcurrentcheatcursloc] add esi,cheatdata mov al,[GUICheatText9] cmp al,'a' jae .lowletter cmp al,'A' jae .letter sub al,'0' jmp .num .lowletter sub al,'a'-10 jmp .num .letter sub al,'A'-10 .num mov ah,[GUICheatText9+1] cmp ah,'a' jae .lowletter2 cmp ah,'A' jae .letter2 sub ah,'0' jmp .num2 .lowletter2 sub ah,'a'-10 jmp .num2 .letter2 sub ah,'A'-10 .num2 shl al,4 and ah,0Fh or al,ah mov [esi+1],al mov word[GUICheatText9],0 pushad call EnableCheatCodeNoPrevMod popad jmp .noret .nocodemod inc dword[GUIcurrentcheatwin] mov byte[GUICCFlash],0 .noret cmp dh,8 jne .nobacksp mov byte[GUICCFlash],0 dec byte[GUICheatPosA] xor eax,eax mov al,[GUICheatPosA] mov byte[GUICheatText9+eax],'_' mov byte[GUICheatText9+eax+1],0 ret .nobacksp cmp dh,0 je .nochar cmp dh,13 je .nochar cmp dh,8 je .nochar cmp dh,9 je .nochar cmp byte[GUICheatPosA],14 je .nochar mov byte[GUICCFlash],0 xor eax,eax mov al,[GUICheatPosA] mov byte[GUICheatText9+eax],dh mov byte[GUICheatText9+eax+1],'_' mov byte[GUICheatText9+eax+2],0 inc byte[GUICheatPosA] .nochar ret .textboxb cmp dh,13 jne .noretb mov byte[GUICCFlash],0 jmp ProcessCheatCode .noretb cmp byte[GUICheatPosB],0 je .nobackspb cmp dh,8 jne .nobackspb mov byte[GUICCFlash],0 dec byte[GUICheatPosB] xor eax,eax mov al,[GUICheatPosB] mov byte[GUICheatTextA+eax],'_' mov byte[GUICheatTextA+eax+1],0 ret .nobackspb cmp dh,0 je .nocharb cmp dh,13 je .nocharb cmp dh,8 je .nocharb cmp byte[GUICheatPosB],18 je .nocharb xor eax,eax mov byte[GUICCFlash],0 mov al,[GUICheatPosB] mov byte[GUICheatTextA+eax],dh mov byte[GUICheatTextA+eax+1],'_' mov byte[GUICheatTextA+eax+2],0 inc byte[GUICheatPosB] .nocharb ret %macro CompareKeyMacro 3 cmp dh,%1 jne %%skip mov byte[%2],%3 %%skip %endmacro InsertSearchCharacter: push edx push eax ; Send character into CSInputDisplay ; Find location mov ecx,CSInputDisplay .next cmp byte[ecx],0 je .found cmp byte[ecx],'_' je .found inc ecx jmp .next .found ; Delete if necessary cmp dh,8 jne .notdelete cmp ecx,CSInputDisplay je near .done dec ecx jmp .placecursor .notdelete cmp ecx,CSInputDisplay+10 je near .done ; Add character if necessary cmp dh,'0' jb near .done cmp dh,'9' jbe .okay cmp byte[CheatSrcByteBase],0 je near .done cmp dh,'F' ja near .done cmp dh,'A' jb near .done .okay mov byte[ecx],dh inc ecx ; Process cursor if over the window .placecursor mov byte[ecx],'_' mov byte[ecx+1],0 mov byte[CSOverValue],0 ; Find overall value and delete if over mov ecx,CSInputDisplay mov ebx,10 cmp byte[CheatSrcByteBase],0 je .dec mov ebx,16 .dec xor eax,eax .next2 cmp byte[ecx],0 je .found2 cmp byte[ecx],'_' je .found2 mul ebx or edx,edx jz .notoverflow mov byte[CSOverValue],1 .notoverflow xor edx,edx mov dl,[ecx] cmp dl,'A' jb .below sub dl,'A'-10-'0' .below sub dl,'0' add eax,edx jnc .notoverflowb mov byte[CSOverValue],1 .notoverflowb inc ecx jmp .next2 .found2 xor ebx,ebx mov bl,[CheatSrcByteSize] mov ebx,[SrcMask+ebx*4] mov [CSCurValue],eax cmp eax,ebx jbe .done mov byte[CSOverValue],1 .done pop eax pop edx ret CSOverValue db 0 CSCurValue dd 0 InsertSearchDescription: mov eax,CSDescDisplay xor dl,dl .next cmp byte[eax],0 je .fin inc eax inc dl jmp .next .fin or dl,dl jz .nobackspb cmp dh,8 jne .nobackspb mov byte[eax-1],0 ret .nobackspb cmp dh,0 je .nocharb cmp dh,13 je .nocharb cmp dh,8 je .nocharb cmp dl,18 je .nocharb mov byte[eax],dh mov byte[eax+1],0 .nocharb ret GUICheatSearchKeys: cmp dh,'a' jb .nocap cmp dh,'z' ja .nocap sub dh,'z'-'Z' .nocap cmp byte[CheatWinMode],3 je near .add cmp byte[CheatWinMode],2 je near .view cmp byte[CheatWinMode],1 je near .search CompareKeyMacro '1',CheatSrcByteSize,0 CompareKeyMacro '2',CheatSrcByteSize,1 CompareKeyMacro '3',CheatSrcByteSize,2 CompareKeyMacro '4',CheatSrcByteSize,3 CompareKeyMacro 'D',CheatSrcByteBase,0 CompareKeyMacro 'H',CheatSrcByteBase,1 CompareKeyMacro 'E',CheatSrcSearchType,0 CompareKeyMacro 'C',CheatSrcSearchType,1 cmp dh,13 je .start cmp dh,'S' jne .notstart .start call CheatCodeSearchInit ret .notstart ret .search cmp byte[CheatSrcSearchType],1 je .compare call InsertSearchCharacter jmp .nomovedown .compare cmp dh,',' je .lessthan cmp dh,'<' jne .notlessthan .lessthan mov byte[CheatCompareValue],0 .notlessthan cmp dh,'.' je .greaterthan cmp dh,'>' jne .notgreaterthan .greaterthan mov byte[CheatCompareValue],1 .notgreaterthan cmp dh,'=' je .equalthan cmp dh,'+' jne .notequalthan .equalthan mov byte[CheatCompareValue],2 .notequalthan cmp dh,'N' jne .notnotequalthan mov byte[CheatCompareValue],3 .notnotequalthan %ifdef __LINUX__ cmp al,90 je .yesmoveup cmp dword[numlockptr],1 je .nomoveup cmp al,72 jne .nomoveup .yesmoveup %else cmp al,72 jne .nomoveup %endif cmp byte[CheatCompareValue],0 je .nomoveup dec byte[CheatCompareValue] .nomoveup %ifdef __LINUX__ cmp al,96 je .yesmovedown cmp dword[numlockptr],1 je .nomovedown cmp al,80 jne .nomovedown .yesmovedown %else cmp al,80 jne .nomovedown %endif cmp byte[CheatCompareValue],3 je .nomovedown inc byte[CheatCompareValue] .nomovedown cmp dh,'R' jne .notrestart mov byte[CheatWinMode],0 mov byte[CheatSearchStatus],0 .notrestart cmp dh,'V' jne .notview mov byte[CheatWinMode],2 .notview cmp dh,13 je .searchprocess cmp dh,'S' jne .nosearchprocess .searchprocess cmp byte[CheatSearchStatus],1 je .nosearchprocess call CheatCodeSearchProcess .nosearchprocess ret .view cmp dword[NumCheatSrc],0 jne .nozero cmp dh,27 je .yesret cmp dh,'R' jne .notreturnb .yesret mov byte[CheatWinMode],1 .notreturnb ret .nozero %ifdef __LINUX__ cmp al,89 je .yeshome cmp dword[numlockptr],1 je .nohome cmp al,71 jne .nohome .yeshome %else cmp al,71 jne .nohome %endif mov dword[GUIcurrentchtsrccursloc],0 mov dword[GUIcurrentchtsrcviewloc],0 ret .nohome %ifdef __LINUX__ cmp al,95 je .yesendp cmp dword[numlockptr],1 je .noendp cmp al,79 jne .noendp .yesendp %else cmp al,79 jne .noendp %endif mov eax,[NumCheatSrc] dec eax mov dword[GUIcurrentchtsrccursloc],eax sub eax,11 mov dword[GUIcurrentchtsrcviewloc],eax test dword[GUIcurrentchtsrcviewloc],8000000h jz .posve mov dword[GUIcurrentchtsrcviewloc],0 .posve ret .noendp %ifdef __LINUX__ cmp al,90 je .up cmp dword[numlockptr],1 je .noup cmp al,72 jne .noup %else cmp al,72 jne .noup %endif .up cmp dword[GUIcurrentchtsrccursloc],0 je .noup mov ebx,[GUIcurrentchtsrccursloc] cmp [GUIcurrentchtsrcviewloc],ebx jne .noviewdec dec dword[GUIcurrentchtsrcviewloc] .noviewdec dec dword[GUIcurrentchtsrccursloc] .noup %ifdef __LINUX__ cmp al,96 je .yesdown cmp dword[numlockptr],1 je .nodown cmp al,80 jne .nodown .yesdown %else cmp al,80 jne .nodown %endif mov ebx,[GUIcurrentchtsrccursloc] inc ebx cmp ebx,[NumCheatSrc] jae .noviewinc inc dword[GUIcurrentchtsrccursloc] sub ebx,12 cmp ebx,[GUIcurrentchtsrcviewloc] jne .noviewinc inc dword[GUIcurrentchtsrcviewloc] .noviewinc .nodown %ifdef __LINUX__ cmp al,91 je .yespgup cmp dword[numlockptr],1 je .nopageup cmp al,73 jne .nopageup .yespgup %else cmp al,73 jne .nopageup %endif sub dword[GUIcurrentchtsrcviewloc],12 sub dword[GUIcurrentchtsrccursloc],12 test dword[GUIcurrentchtsrcviewloc],8000000h jz .posv mov dword[GUIcurrentchtsrcviewloc],0 .posv test dword[GUIcurrentchtsrccursloc],8000000h jz .posc mov dword[GUIcurrentchtsrccursloc],0 .posc .nopageup %ifdef __LINUX__ cmp al,97 je .yespgdn cmp dword[numlockptr],1 je .nopagedown cmp al,81 jne .nopagedown .yespgdn %else cmp al,81 jne .nopagedown %endif add dword[GUIcurrentchtsrcviewloc],12 add dword[GUIcurrentchtsrccursloc],12 mov ebx,[NumCheatSrc] dec ebx cmp dword[GUIcurrentchtsrccursloc],ebx jb .poscd mov dword[GUIcurrentchtsrccursloc],ebx .poscd sub ebx,11 cmp dword[GUIcurrentchtsrcviewloc],ebx jl .posvd test ebx,8000000h jz .noneg mov ebx,0 .noneg mov dword[GUIcurrentchtsrcviewloc],ebx .posvd .nopagedown cmp dh,27 je .yesretb cmp dh,'R' jne .notreturn .yesretb mov byte[CheatWinMode],1 .notreturn cmp dh,13 je .yesadd cmp dh,'A' jne .notadd .yesadd mov byte[CheatWinMode],3 mov byte[CurCStextpos],0 mov byte[CSInputDisplay],'_' mov byte[CSInputDisplay+1],0 mov byte[CSDescDisplay],0 .notadd ret .add cmp dh,27 je .yesretc cmp byte[CurCStextpos],1 je .notreturnc cmp dh,'R' jne .notreturnc .yesretc mov byte[CheatWinMode],2 .notreturnc cmp byte[CurCStextpos],0 jne near .nofirstbox cmp dh,9 je .yestab cmp byte[CSOverValue],1 je .noret cmp dh,13 jne .noret .yestab mov byte[CurCStextpos],1 .noret call InsertSearchCharacter ret .nofirstbox cmp byte[CurCStextpos],1 jne near .nosecondbox cmp dh,9 jne .notab mov byte[CurCStextpos],0 .notab cmp dh,13 jne .noenter jmp AddCSCheatCode .noenter call InsertSearchDescription ret .nosecondbox ret GUIStateSelKeys: cmp al,13 jne .noenter xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+2],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] mov al,[GUIpmenupos] mov [GUIcmenupos],al ret .noenter %ifdef __LINUX__ cmp al,92 je .yesleft cmp dword[numlockptr],1 je .noleft cmp al,75 jne .noleft .yesleft %else cmp al,75 jne .noleft %endif mov ebx,[statefileloc] mov cl,[fnamest+ebx] cmp cl,'t' jne .no1st mov cl,'4' jmp .done .no1st cmp cl,'1' jne .no2nd mov cl,'t' jmp .done .no2nd cmp cl,'5' jne .no5th mov cl,'9' jmp .done .no5th dec cl jmp .done .noleft %ifdef __LINUX__ cmp al,94 je .yesright cmp dword[numlockptr],1 je .noright cmp al,77 jne .noright .yesright %else cmp al,77 jne .noright %endif mov ebx,[statefileloc] mov cl,[fnamest+ebx] cmp cl,'t' jne .noT mov cl,'1' jmp .done .noT cmp cl,'4' jne .no4th mov cl,'t' jmp .done .no4th cmp cl,'9' jne .no9th mov cl,'5' jmp .done .no9th inc cl jmp .done .noright %ifdef __LINUX__ cmp al,90 je .vert cmp dword[numlockptr],1 je .novert %endif cmp al,72 je .vert %ifdef __LINUX__ cmp al,96 je .vert cmp dword[numlockptr],1 je .novert %endif cmp al,80 jne .novert .vert mov ebx,[statefileloc] mov cl,[fnamest+ebx] cmp cl,'t' jne .noTv mov cl,'5' jmp .done .noTv cmp cl,'5' jne .no5v mov cl,'t' jmp .done .no5v cmp cl,'5' jb .noabove sub cl,5 jmp .done .noabove add cl,5 jmp .done .novert ret .done mov [fnamest+ebx],cl ret GUIResetKeys: %ifdef __LINUX__ cmp al,92 je .yesleft cmp dword[numlockptr],1 je .noleft cmp al,75 jne .noleft .yesleft %else cmp al,75 jne .noleft %endif mov byte[GUICResetPos],0 .noleft %ifdef __LINUX__ cmp al,94 je .yesright cmp dword[numlockptr],1 je .noright cmp al,77 jne .noright .yesright %else cmp al,77 jne .noright %endif mov byte[GUICResetPos],1 .noright cmp al,13 jne .noconf cmp byte[GUICResetPos],0 je .yesreset jmp .noreset .noconf cmp dh,'Y' je .yesreset cmp dh,'y' jne .notyesreset .yesreset mov byte[GUICBHold],2 jmp GUIProcReset .notyesreset cmp dh,'N' je .noreset cmp dh,'n' jne .notnoreset .noreset xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+12],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] mov al,[GUIpmenupos] mov [GUIcmenupos],al .notnoreset ret GUIStateKeys: %ifdef __LINUX__ cmp al,92 je .yesleft cmp dword[numlockptr],1 je .noleft cmp al,75 jne .noleft .yesleft %else cmp al,75 jne .noleft %endif mov byte[GUICStatePos],0 .noleft %ifdef __LINUX__ cmp al,94 je .yesright cmp dword[numlockptr],1 je .noright cmp al,77 jne .noright .yesright %else cmp al,77 jne .noright %endif mov byte[GUICStatePos],1 .noright cmp al,13 jne .noconf cmp byte[GUICStatePos],0 je .yesreset jmp .noreset .noconf cmp dh,'Y' je .yesreset cmp dh,'y' jne .notyesreset .yesreset mov byte[GUICBHold],10 jmp GUIProcStates .notyesreset cmp dh,'N' je .noreset cmp dh,'n' jne .notnoreset .noreset xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+14],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] mov al,[GUIpmenupos] mov [GUIcmenupos],al .notnoreset ret GUILoadKeys: mov byte[ManualStatus],0 mov dword[ManualCPtr],GUILoadTextA cmp dword[GUIfileentries],0 je .noright cmp dword[GUIdirentries],0 je .noright %ifdef __LINUX__ cmp al,92 je .yesleft cmp dword[numlockptr],1 je .noleft cmp al,75 jne .noleft .yesleft %else cmp al,75 jne .noleft %endif mov byte[GUILoadPos],0 xor dword[GUIcurrentfilewin],1 .noleft %ifdef __LINUX__ cmp al,94 je .yesright cmp dword[numlockptr],1 je .noright cmp al,77 jne .noright .yesright %else cmp al,77 jne .noright %endif mov byte[GUILoadPos],0 xor dword[GUIcurrentfilewin],1 .noright cmp al,13 jne .noenter mov byte[GUILoadPos],0 mov ebx,GUILoadTextA .nextl cmp byte[ebx],':' je .donel %ifdef __LINUX__ cmp byte[ebx],'/' %else cmp byte[ebx],'\' %endif je .donel inc ebx cmp byte[ebx],0 je .nofnamel jmp .nextl .donel call GUILoadManualDir cmp byte[ManualStatus],2 je near .done ret .nofnamel mov ebx,GUILoadTextA cmp byte[ebx],0 je .nodirtry mov edx,ebx call Change_Single_Dir jc .nodirtry call GetLoadData.a ret .nodirtry call GUILoadData ret .noenter cmp dword[GUIcurrentfilewin],1 je near .dirwin %ifdef __LINUX__ cmp al,89 je .yeshome cmp dword[numlockptr],1 je .nohome cmp al,71 jne .nohome .yeshome %else cmp al,71 jne .nohome %endif mov byte[GUILoadPos],0 mov dword[GUIcurrentcursloc],0 mov dword[GUIcurrentviewloc],0 ret .nohome %ifdef __LINUX__ cmp al,95 je .yesendp cmp dword[numlockptr],1 je .noendp cmp al,79 jne .noendp .yesendp %else cmp al,79 jne .noendp %endif mov byte[GUILoadPos],0 mov eax,[GUIfileentries] dec eax mov dword[GUIcurrentcursloc],eax sub eax,14 mov dword[GUIcurrentviewloc],eax test dword[GUIcurrentviewloc],8000000h jz .posve mov dword[GUIcurrentviewloc],0 .posve ret .noendp %ifdef __LINUX__ cmp al,90 je .up cmp dword[numlockptr],1 je .noup cmp al,72 jne .noup %else cmp al,72 jne .noup %endif .up mov byte[GUILoadPos],0 cmp dword[GUIcurrentcursloc],0 je .noup mov ebx,[GUIcurrentcursloc] cmp [GUIcurrentviewloc],ebx jne .noviewdec dec dword[GUIcurrentviewloc] .noviewdec dec dword[GUIcurrentcursloc] .noup %ifdef __LINUX__ cmp al,96 je .yesdown cmp dword[numlockptr],1 je .nodown cmp al,80 jne .nodown .yesdown %else cmp al,80 jne .nodown %endif mov byte[GUILoadPos],0 mov ebx,[GUIcurrentcursloc] inc ebx cmp ebx,[GUIfileentries] je .noviewinc inc dword[GUIcurrentcursloc] sub ebx,15 cmp ebx,[GUIcurrentviewloc] jne .noviewinc inc dword[GUIcurrentviewloc] .noviewinc .nodown %ifdef __LINUX__ cmp al,91 je .yespageup cmp dword[numlockptr],1 je .nopageup cmp al,73 jne .nopageup .yespageup %else cmp al,73 jne .nopageup %endif mov byte[GUILoadPos],0 sub dword[GUIcurrentviewloc],15 sub dword[GUIcurrentcursloc],15 test dword[GUIcurrentviewloc],8000000h jz .posv mov dword[GUIcurrentviewloc],0 .posv test dword[GUIcurrentcursloc],8000000h jz .posc mov dword[GUIcurrentcursloc],0 .posc .nopageup %ifdef __LINUX__ cmp al,97 je .yespagedn cmp dword[numlockptr],1 je .nopagedown cmp al,81 jne .nopagedown .yespagedn %else cmp al,81 jne .nopagedown %endif mov byte[GUILoadPos],0 add dword[GUIcurrentviewloc],15 add dword[GUIcurrentcursloc],15 mov ebx,[GUIfileentries] dec ebx cmp dword[GUIcurrentcursloc],ebx jb .poscd mov dword[GUIcurrentcursloc],ebx .poscd sub ebx,14 cmp dword[GUIcurrentviewloc],ebx jl .posvd test ebx,8000000h jz .noneg mov ebx,0 .noneg mov dword[GUIcurrentviewloc],ebx .posvd .nopagedown .textboxa cmp byte[GUILoadPos],0 je near .nobacksp cmp dh,8 jne .nobacksp mov byte[GUILDFlash],0 dec byte[GUILoadPos] xor eax,eax mov al,[GUILoadPos] ret .nobacksp cmp dh,0 je near .posvl2 cmp dh,13 je near .posvl2 cmp dh,8 je near .posvl2 cmp dh,9 je near .posvl2 cmp byte[GUILoadPos],36 je near .posvl2 mov byte[GUILDFlash],0 xor eax,eax mov al,[GUILoadPos] mov byte[GUILoadTextA+eax],dh inc byte[GUILoadPos] ; Go to closest matching filename if there are no :, /, or \ in the filename mov ebx,[ManualCPtr] cmp byte[ebx],0 je near .posvl2 .next cmp byte[ebx],':' je near .posvl2 cmp byte[ebx],'/' je near .posvl2 cmp byte[ebx],'\' je near .posvl2 inc ebx cmp byte[ebx],0 je .done jmp .next .done mov ebx,[GUIfileentries] xor esi,esi cmp dword[GUIcurrentfilewin],1 jne near .notdir mov esi,[GUIfileentries] mov ebx,[GUIfileentries] add ebx,[GUIdirentries] .notdir mov ecx,esi mov dword[.foundval],esi mov dword[.maxfound],0 .loop2 mov dword[.numfound],0 cmp byte[GUIloadfntype],0 jne .nottype02 mov eax,[spcRamcmp+esi*4] jmp .type02 .nottype02 mov eax,esi shl eax,5 add eax,[spcBuffera] .type02 inc eax mov edi,[ManualCPtr] cmp byte[eax],'[' jne .nodrive inc eax .nodrive .loop3 mov dl,[eax] cmp dl,'a' jb .nolowerb2 cmp dl,'z' ja .nolowerb2 sub dl,'a'-'A' .nolowerb2 mov dh,[edi] cmp dh,'a' jb .nolowerb3 cmp dh,'z' ja .nolowerb3 sub dh,'a'-'A' .nolowerb3 cmp dl,dh jne .notfound cmp byte[ManualStatus],2 jne .notfullload or dh,dh jnz .notfullload or dl,dl jnz .notfullload mov byte[ManualStatus],3 .notfullload or dh,dh jz .notfound or dl,dl jz .notfound inc dword[.numfound] inc eax inc edi jmp .loop3 .notfound mov edx,[.numfound] cmp edx,[.maxfound] jbe .nfound mov [.maxfound],edx mov [.foundval],esi .nfound inc esi cmp esi,ebx jne .noend2 mov esi,[GUIfileentries] cmp dword[GUIcurrentfilewin],1 je .noend2 xor esi,esi .noend2 cmp esi,ecx jne near .loop2 .skipall mov esi,[.foundval] cmp dword[GUIcurrentfilewin],1 jne .notdir2 sub esi,[GUIfileentries] mov [GUIcurrentdircursloc],esi mov [GUIcurrentdirviewloc],esi mov ebx,[GUIdirentries] sub ebx,15 cmp dword[GUIcurrentdirviewloc],ebx jb .posvl2 mov dword[GUIcurrentdirviewloc],ebx jmp .posvl2 .notdir2 mov [GUIcurrentcursloc],esi mov [GUIcurrentviewloc],esi mov ebx,[GUIfileentries] sub ebx,15 cmp dword[GUIcurrentviewloc],ebx jb .posvl2 mov dword[GUIcurrentviewloc],ebx .posvl2 cmp byte[ManualStatus],3 jne .notdirectload call GUILoadData .notdirectload ret .foundval dd 0 .numfound dd 0 .maxfound dd 0 .dirwin %ifdef __LINUX__ cmp al,89 je .yeshome2 cmp dword[numlockptr],1 je .nohome2 cmp al,71 jne .nohome2 .yeshome2 %else cmp al,71 jne .nohome2 %endif mov byte[GUILoadPos],0 mov dword[GUIcurrentdircursloc],0 mov dword[GUIcurrentdirviewloc],0 ret .nohome2 %ifdef __LINUX__ cmp al,95 je .yesendp2 cmp dword[numlockptr],1 je .noendp2 cmp al,79 jne .noendp2 .yesendp2 %else cmp al,79 jne .noendp2 %endif mov byte[GUILoadPos],0 mov eax,[GUIdirentries] dec eax mov dword[GUIcurrentdircursloc],eax sub eax,14 mov dword[GUIcurrentdirviewloc],eax test dword[GUIcurrentdirviewloc],8000000h jz .posve2 mov dword[GUIcurrentdirviewloc],0 .posve2 ret .noendp2 %ifdef __LINUX__ cmp al,90 je .yesup2 cmp dword[numlockptr],1 je .noup2 cmp al,72 jne .noup2 .yesup2 %else cmp al,72 jne .noup2 %endif mov byte[GUILoadPos],0 cmp dword[GUIcurrentdircursloc],0 je .noup2 mov ebx,[GUIcurrentdircursloc] cmp [GUIcurrentdirviewloc],ebx jne .noviewdec2 dec dword[GUIcurrentdirviewloc] .noviewdec2 dec dword[GUIcurrentdircursloc] .noup2 %ifdef __LINUX__ cmp al,96 je .yesdown2 cmp dword[numlockptr],1 je .nodown2 cmp al,80 jne .nodown2 .yesdown2 %else cmp al,80 jne .nodown2 %endif mov byte[GUILoadPos],0 mov ebx,[GUIcurrentdircursloc] inc ebx cmp ebx,[GUIdirentries] je .noviewinc2 inc dword[GUIcurrentdircursloc] sub ebx,15 cmp ebx,[GUIcurrentdirviewloc] jne .noviewinc2 inc dword[GUIcurrentdirviewloc] .noviewinc2 .nodown2 %ifdef __LINUX__ cmp al,91 je .yespgup2 cmp dword[numlockptr],1 je .nopageup2 cmp al,73 jne .nopageup2 .yespgup2 %else cmp al,73 jne .nopageup2 %endif mov byte[GUILoadPos],0 sub dword[GUIcurrentdirviewloc],15 sub dword[GUIcurrentdircursloc],15 test dword[GUIcurrentdirviewloc],8000000h jz .posv2 mov dword[GUIcurrentdirviewloc],0 .posv2 test dword[GUIcurrentdircursloc],8000000h jz .posc2 mov dword[GUIcurrentdircursloc],0 .posc2 .nopageup2 %ifdef __LINUX__ cmp al,97 je .yespgdn2 cmp dword[numlockptr],1 je .nopagedown2 cmp al,81 jne .nopagedown2 .yespgdn2 %else cmp al,81 jne .nopagedown2 %endif mov byte[GUILoadPos],0 add dword[GUIcurrentdirviewloc],15 add dword[GUIcurrentdircursloc],15 mov ebx,[GUIdirentries] dec ebx cmp dword[GUIcurrentdircursloc],ebx jb .poscd2 mov dword[GUIcurrentdircursloc],ebx .poscd2 sub ebx,14 cmp dword[GUIcurrentdirviewloc],ebx jb .posvd2 test ebx,8000000h jz .noneg2 mov ebx,0 .noneg2 mov dword[GUIcurrentdirviewloc],ebx .posvd2 .nopagedown2 jmp .textboxa WaitForKey: .again3 mov edx,10 .again4 mov cx,1000 push edx call delay call JoyRead ; mov dword[pressed+0CCh],0 ; Up,Down,Left,Right, pl1 ; mov dword[pressed+0E8h],0 ; Up,Down,Left,Right, pl2 ; mov dword[pressed+14Ch],0 ; Up,Down,Left,Right, pl1 ; mov dword[pressed+168h],0 ; Up,Down,Left,Right, pl2 ; mov dword[pressed+080h],0 ; Button 7 ; mov dword[pressed+081h],0 ; Button 8 ; mov dword[pressed+086h],0 ; Button 5 ; mov dword[pressed+087h],0 ; Button 6 ; mov dword[pressed+100h],0 ; Button 7 ; mov dword[pressed+101h],0 ; Button 8 ; mov dword[pressed+106h],0 ; Button 5 ; mov dword[pressed+107h],0 ; Button 6 pop edx xor ebx,ebx mov ecx,256+128+64 .b2 cmp byte[pressed+ebx],0 jne near .again3 inc ebx dec ecx jnz .b2 dec edx jnz near .again4 .again call JoyRead ; mov dword[pressed+0CCh],0 ; Up,Down,Left,Right, pl1 ; mov dword[pressed+0E8h],0 ; Up,Down,Left,Right, pl2 ; mov dword[pressed+14Ch],0 ; Up,Down,Left,Right, pl1 ; mov dword[pressed+168h],0 ; Up,Down,Left,Right, pl2 ; mov dword[pressed+080h],0 ; Button 7 ; mov dword[pressed+081h],0 ; Button 8 ; mov dword[pressed+086h],0 ; Button 5 ; mov dword[pressed+087h],0 ; Button 6 ; mov dword[pressed+100h],0 ; Button 7 ; mov dword[pressed+101h],0 ; Button 8 ; mov dword[pressed+106h],0 ; Button 5 ; mov dword[pressed+107h],0 ; Button 6 xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp byte[MouseDis],1 je .mousedis2 push ebx ; mov eax,0Bh ; int 33h pop ebx .mousedis2 mov byte[GUIpclicked],1 ret zsnes-1.36/src/gui/guiload.inc0100644000175000017500000007306607505521472015701 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; GUI File (Game) Loader %macro GUIGetEntry 1 mov edx,%1 mov cx,20h call Get_First_Entry jc %%nomore %%moreentries test byte[DTALoc+15h],10h jnz %%nofile inc dword[GUInumentries] mov esi,DTALoc+1Eh mov byte[edi],0 inc edi mov ecx,13 %%nextchar mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz %%nextchar %%nofile call Get_Next_Entry jnc %%moreentries %%nomore %endmacro %macro GUIGetEntry2 1 mov edx,%1 mov cx,20h call Get_First_Entry jc %%nomore %%moreentries test byte[DTALoc+15h],10h jnz %%nofile mov eax,[GUInumentries] shl eax,2 add eax,spcRamcmp mov [eax],edi inc dword[GUInumentries] mov esi,DTALoc+1Eh mov byte[edi],0 inc edi %%nextchar mov al,[esi] mov [edi],al inc esi inc edi or al,al jnz %%nextchar %%nofile call Get_Next_Entry jnc %%moreentries %%nomore %endmacro %macro GUIGetDir2 0 mov edx,GUIfindDIR mov cx,10h call Get_First_Entry jc .nomore .moreentries test byte[DTALoc+15h],10h jz .nodir mov eax,[GUInumentries] shl eax,2 add eax,spcRamcmp mov [eax],edi inc dword[GUInumentries] inc dword[GUIdirentries] mov esi,DTALoc+1Eh mov byte[edi],1 inc edi .nextchar mov al,[esi] mov [edi],al inc esi inc edi or al,al jnz .nextchar .nodir call Get_Next_Entry jnc .moreentries .nomore %endmacro %macro GUIGetDir 0 mov edx,GUIfindDIR mov cx,10h call Get_First_Entry jc .nomore .moreentries test byte[DTALoc+15h],10h jz .nodir inc dword[GUInumentries] inc dword[GUIdirentries] mov esi,DTALoc+1Eh mov byte[edi],1 inc edi mov ecx,13 .nextchar mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .nextchar .nodir call Get_Next_Entry jnc .moreentries .nomore %endmacro %macro GUIPutDrive 0 mov byte[edi],2 inc edi mov byte[edi],'[' mov [edi+1],al mov byte[edi+2],':' mov byte[edi+3],']' mov byte[edi+4],0 add edi,13 mov byte[esi],2 inc esi mov byte[esi],'[' mov [esi+1],al mov byte[esi+2],':' mov byte[esi+3],']' mov byte[esi+4],0 add esi,31 inc dword[GUInumentries] inc dword[GUIdirentries] %endmacro %macro GUIPutDrive2 0 mov byte[edi],2 inc edi mov byte[edi],'[' mov [edi+1],al mov byte[edi+2],':' mov byte[edi+3],']' mov byte[edi+4],0 add edi,5 inc dword[GUInumentries] inc dword[GUIdirentries] %endmacro ;LGUI netlastloaded db 0 GUIloadfilename: cmp byte[CNetType],15 je .noload cmp byte[CNetType],12 je .noload cmp byte[CNetType],11 je .noload cmp byte[CNetType],10 je .noload cmp byte[CNetType],21 je .noload cmp byte[CNetType],22 jne .yesload .noload ret .yesload cmp byte[CNetType],20 jne near .nocnettype mov byte[netlastloaded],1 ; FileNameMod times 29 db 0 cmp byte[GUIcmenupos],1 jne .nomenuout mov byte[GUIcmenupos],0 .nomenuout mov esi,FileNameMod .nextfnc mov cl,[eax] mov [esi],cl inc eax inc esi cmp cl,0 jne .nextfnc mov byte[RemoteCommand],10 pushad call GUIQuickLoadUpdate popad ret .nocnettype cmp byte[CNetType],20 je .okay20 ; ret .okay20 mov esi,eax ; find length of string & copy filename xor cl,cl .findnext mov ch,[esi] cmp byte[esi],0 je .foundend inc esi inc cl jmp .findnext .foundend mov [fname],cl ; copy filename mov esi,eax mov edi,fname+1 .continuecopy mov al,[esi] mov [edi],al cmp al,0 je .foundzero inc esi inc edi jmp .continuecopy .foundzero ; get LoadDrive/LoadDir & SRAMDrive/SRAMDir mov ebx,LoadDir mov edx,LoadDrive call Get_Dir %ifndef __LINUX__ cmp byte[cfgloadsdir],0 jne .nosdrive mov ebx,SRAMDir mov edx,SRAMDrive call Get_Dir %endif .nosdrive ; create .srm header call makeextension ; clear memory mov edi,[sram] mov eax,0FFFFFFFFh mov ecx,8192 .n mov [edi],eax add edi,4 dec ecx jnz .n call clearmem2 mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov dword[nmirept],0 mov dword[nmiprevline],224 mov dword[nmistatus],0 mov byte[spcnumread],0 mov byte[NextLineCache],0 mov byte[curexecstate],1 ; load file call loadfileGUI cmp byte[ZipSupport],2 je near .noloader cmp byte[GUIloadfailed],1 je near .noloader mov byte[CheatOn],0 mov byte[NumCheats],0 ; mov byte[CheatSrcByteSize],0 ; mov byte[CheatSrcByteBase],0 ; mov byte[CheatSrcSearchType],0 mov byte[CheatWinMode],0 mov byte[CheatSearchStatus],0 call CheckROMType cmp byte[ROMTypeNOTFound],0 je .foundromtype mov byte[romtype],1 .foundromtype call SetIRQVectors call ClearScreen cmp byte[cbitmode],0 jne .nomakepal call makepal .nomakepal ; get sram size mov esi,[romdata] add esi,7FD8h cmp byte[romtype],2 jne .nohirom2 add esi,8000h .nohirom2 mov cl,[esi-1] mov [curromsize],cl mov cl,[esi] inc esi xor eax,eax mov al,1 shl al,cl cmp al,1 jne .yessram mov al,0 .yessram shl eax,10 cmp eax,65536 jbe .nosramc mov eax,65536 .nosramc mov [ramsize],eax dec eax mov [ramsizeand],eax ; get pal/ntsc mov al,[ForceROMTiming] mov byte[ForcePal],al xor al,al mov al,[esi] cmp byte[ForcePal],1 jne .nontsc mov al,0 .nontsc cmp byte[ForcePal],2 jne .nopal2 mov al,2 .nopal2 mov byte[romispal],0 mov word[totlines],263 mov dword[MsgCount],120 cmp al,1 jbe .nopal mov byte[romispal],1 mov word[totlines],313 mov dword[MsgCount],100 .nopal call showinfogui call initsnes mov byte[snesmouse],0 mov byte[sramsavedis],0 mov eax,regsbackup mov ebx,sndrot mov ecx,3019 .rbackupl mov dl,[eax] mov [ebx],dl inc ebx inc eax dec ecx jnz .rbackupl cmp byte[yesoutofmemory],1 jne .noout call outofmemfix .noout call GUIDoReset call GUIQuickLoadUpdate cmp byte[AutoLoadCht],0 je .nocheatload cmp byte[CNetType],20 je .nocheatload ; change dir to LoadDrive/LoadDir mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir call CheatCodeLoad .nocheatload cmp byte[AutoState],0 je .noloader call LoadSecondState .noloader cmp byte[GUIwinptr],1 jne .nowinopen mov al,[GUIpmenupos] mov [GUIcmenupos],al .nowinopen ; change dir to LoadDrive/LoadDir mov dl,[LoadDrive] mov ebx,LoadDir call Change_Dir ret GUILoadData: mov byte[GUICBHold],0 cmp byte[GUIcurrentfilewin],0 je near .loadfiles ; Change directory cmp byte[GUIloadfntype],0 jne .nottype0c mov eax,[GUIcurrentdircursloc] add eax,[GUIfileentries] mov eax,[spcRamcmp+eax*4] jmp .donetype0 .nottype0c mov eax,[GUIcurrentdircursloc] mov ebx,eax lea eax,[eax*8] add ebx,ebx add eax,ebx add ebx,ebx add eax,ebx add eax,[GUIdirStartLoc] .donetype0 inc eax cmp byte[eax+2],':' je .drive mov edx,eax call Change_Single_Dir jc .error call GetLoadData.a .error ret .drive ; Change Drive mov dl,[eax+1] sub dl,65 call Change_Drive call GetLoadData.a ret .unableload pop eax ret .loadfiles mov byte[LoadDuplicFound],0 cmp byte[prevlfreeze],0 jne near .frozen ; cmp byte[GUIloadfntype],0 ; je near .frozen ; check if a duplicate exists mov esi,prevloadnames .checkanother push esi mov edx,[GUIcurrentcursloc] shl edx,5 add edx,[spcBuffera] cmp byte[GUIloadfntype],0 jne .nottype0 mov edx,[GUIcurrentcursloc] mov edx,[spcRamcmp+edx*4] .nottype0 inc edx mov cl,16 .dloop mov al,[edx] cmp [esi],al jne .nomatch inc edx inc esi dec cl jz .matchfound cmp al,0 jne .dloop .matchfound pop esi mov byte[LoadDuplicFound],1 jmp .frozen .nomatch pop esi add esi,16 cmp esi,prevloadnames+10*16 jne near .checkanother ; copy game name ; shift names down mov esi,prevloadnames+16*9-1 mov ecx,16*9 .loop mov al,[esi] mov [esi+16],al dec esi dec edi dec ecx jnz .loop mov esi,prevloadfnamel+512*9-1 mov edi,prevloaddnamel+512*9-1 mov ecx,512*9 .loop2 mov al,[esi] mov [esi+512],al mov al,[edi] mov [edi+512],al dec esi dec edi dec ecx jnz .loop2 .skip ; copy game name mov edx,[GUIcurrentcursloc] shl edx,5 add edx,[spcBuffera] cmp byte[GUIloadfntype],0 jne .nottype0b mov edx,[GUIcurrentcursloc] mov edx,[spcRamcmp+edx*4] .nottype0b inc edx mov ebx,prevloadnames mov ecx,16 .loopfnc mov al,[edx] mov [ebx],al inc edx inc ebx dec ecx jnz .loopfnc ; get Drive/Dir mov ebx,prevloaddnamel+1 mov edx,prevloaddnamel call Get_Dir .frozen cmp byte[GUIloadfntype],0 jne .nottype0b2 mov eax,[GUIcurrentcursloc] mov eax,[spcRamcmp+eax*4] jmp .donetype0b .nottype0b2 mov eax,[GUIcurrentcursloc] mov ebx,eax lea eax,[eax*8] add ebx,ebx add eax,ebx add ebx,ebx add eax,ebx add eax,spcRamcmp .donetype0b inc eax cmp byte[prevlfreeze],0 jne .foundend cmp byte[LoadDuplicFound],0 jne .foundend mov esi,eax mov edi,prevloadfnamel ; copy filename .findnext mov ch,[esi] mov [edi],ch cmp ch,0 je .foundend inc esi inc edi jmp .findnext .foundend call GUIloadfilename xor eax,eax mov al,[GUIwinptr] dec eax mov byte[GUIwinactiv+1],0 mov byte[GUIwinorder+eax],0 dec byte[GUIwinptr] ret .drivefn db 'A:\temp.tmp',0 GetNormalEntries2: cmp byte[showallext],1 je near .guishowall GUIGetEntry2 GUIsmcfind GUIGetEntry2 GUIsfcfind GUIGetEntry2 GUIswcfind GUIGetEntry2 GUIfigfind %ifndef __MSDOS__ GUIGetEntry2 GUIfindGZIP %endif GUIGetEntry2 GUIfind058 GUIGetEntry2 GUIfind078 GUIGetEntry2 GUIfindUSA GUIGetEntry2 GUIfindJAP GUIGetEntry2 GUIfindBIN ; cmp byte[OSPort],1 ; je near .noasm GUIGetEntry2 GUIfindZIP ;.noasm GUIGetEntry2 GUIfind1 jmp .guiNext .guishowall GUIGetEntry2 GUIfindall .guiNext ret GetNormalEntries: cmp byte[showallext],1 je near .guishowall GUIGetEntry GUIsmcfind GUIGetEntry GUIsfcfind GUIGetEntry GUIswcfind GUIGetEntry GUIfigfind %ifndef __MSDOS__ GUIGetEntry GUIfindGZIP %endif GUIGetEntry GUIfind058 GUIGetEntry GUIfind078 GUIGetEntry GUIfindUSA GUIGetEntry GUIfindJAP GUIGetEntry GUIfindBIN ; cmp byte[OSPort],1 ; je near .noasm GUIGetEntry GUIfindZIP ;.noasm GUIGetEntry GUIfind1 jmp .guiNext .guishowall GUIGetEntry GUIfindall .guiNext ret GUIGetEntryLFNfunc: push es push edi mov eax,714Eh ; Findfirst mov cx,ds mov es,cx mov ch,0 mov cl,0 mov edi,LFNData mov si,0 int 21h mov [LFNHandle],ax pop edi pop es jc near .done .next mov esi,LFNData+44 mov ecx,23 .loop mov al,[esi] cmp al,'a' jb .nocap cmp al,'z' ja .nocap sub al,'a'-'A' .nocap cmp al,'%' jne .noperc cmp byte[esi+1],'0' jb .noperc cmp byte[esi+1],'F' ja .noperc cmp byte[esi+2],'0' jb .noperc cmp byte[esi+2],'F' ja .noperc mov al,[esi+2] sub al,'0' cmp al,9 jbe .nodec sub al,'A'-'0'-10 .nodec mov ah,[esi+1] sub ah,'0' cmp ah,9 jbe .nodecb sub ah,'A'-'0'-10 .nodecb shl ah,4 or al,ah add esi,2 .noperc mov [edi],al inc edi inc esi dec ecx jnz near .loop mov byte[edi],0 add edi,9 push es push edi mov bx,[LFNHandle] mov eax, 714Fh ; Findnext mov dx,ds mov es,dx mov edi,LFNData mov si,0 int 21h pop edi pop es jnc near .next .done mov eax,71A1h ;Filefind Close mov bx,[LFNHandle] int 21h ret GUIGetEntryLFNfuncdir: mov edx,GUIfindall push es push edi mov eax,714Eh ; Findfirst mov cx,ds mov es,cx mov ch,10h mov cl,10h mov edi,LFNData mov si,0 int 21h mov [LFNHandle],ax pop edi pop es jc near .done .next mov esi,LFNData+44 mov ecx,11 .loop mov al,[esi] cmp al,'a' jb .nocap cmp al,'z' ja .nocap sub al,'a'-'A' .nocap mov [edi],al inc edi inc esi dec ecx jnz .loop mov byte[edi],0 add edi,21 push es push edi mov bx,[LFNHandle] mov eax, 714Fh ; Findnext mov dx,ds mov es,dx mov edi,LFNData mov si,0 int 21h pop edi pop es jnc near .next .done mov eax,71A1h ;Filefind Close mov bx,[LFNHandle] int 21h ret %macro GUIGetEntryLFN 1 mov edx,%1 call GUIGetEntryLFNfunc %endmacro GetLoadLfn: call GetNormalEntries push edi mov edi,[spcBuffera] inc edi cmp byte[showallext],1 je near .guishowall GUIGetEntryLFN GUIsmcfind GUIGetEntryLFN GUIsfcfind GUIGetEntryLFN GUIswcfind GUIGetEntryLFN GUIfigfind %ifndef __MSDOS__ GUIGetEntryLFN GUIfindGZIP %endif GUIGetEntryLFN GUIfind058 GUIGetEntryLFN GUIfind078 GUIGetEntryLFN GUIfindUSA GUIGetEntryLFN GUIfindJAP GUIGetEntryLFN GUIfindBIN GUIGetEntryLFN GUIfindZIP GUIGetEntryLFN GUIfind1 jmp .guiNext .guishowall GUIGetEntryLFN GUIfindall .guiNext pop edi ret LFNData times 400 db 0 LFNHandle dw 0 GetLoadNormal: call GetNormalEntries2 ret GetLoadHeader: call GetNormalEntries push edi ; Copy every 14 bytes of spcRamcmp into every 32 bytes of spcBuffer mov ecx,[GUInumentries] mov esi,spcRamcmp+1 mov edi,[spcBuffera] inc edi cmp ecx,0 je near .none .loop ; open file at esi and store in edi push esi push ecx push edi ; check if .zip file mov eax,esi .zipdet cmp byte[eax],0 je near .skipcheck cmp byte[eax],'.' je .dotdetected inc eax jmp .zipdet .dotdetected cmp byte[eax+1],'z' je near .yeszipa cmp byte[eax+1],'Z' jne near .skipcheck .yeszipa cmp byte[eax+2],'i' je near .yeszipb cmp byte[eax+2],'I' jne near .skipcheck .yeszipb cmp byte[eax+3],'p' je near .yeszipc cmp byte[eax+3],'P' jne near .skipcheck .yeszipc ; move esi to edi .ziploop mov al,[esi] mov [edi],al inc esi inc edi or al,al jnz .ziploop jmp .doneall .skipcheck ; open file mov edx,esi call Open_File jc near .fileerror mov bx,ax ; Check filesize mov cx,0 mov dx,0 call File_Seek_End jc near .fileerror cmp dx,0 jne .locokay cmp ax,32768 jae .locokay jmp .fileerror .locokay ; Look for 512 byte header mov cx,0 mov dx,250 call File_Seek jc near .fileerror mov ecx,20 mov edx,fnameheadtemp call Read_File jc near .fileerror ; if 10 or more 0's, then header mov ecx,20 mov esi,fnameheadtemp xor eax,eax .loop2 cmp byte[esi],0 jne .notzero2 inc eax .notzero2 inc esi dec ecx jnz .loop2 cmp eax,10 ja near .yes512header mov cx,0 mov dx,32704 call File_Seek jc near .fileerror mov ecx,20 mov edx,edi call Read_File jc near .fileerror mov cx,0 mov dx,32704+32768 call File_Seek jc near .fileerror mov ecx,20 mov edx,fnameheadtemp call Read_File jc near .fileerror jmp .noheaderdone .yes512header mov cx,0 mov dx,32704+512 call File_Seek jc near .fileerror mov ecx,20 mov edx,edi call Read_File jc near .fileerror mov cx,1 mov dx,448 call File_Seek jc near .fileerror mov ecx,20 mov edx,fnameheadtemp call Read_File jc near .fileerror .noheaderdone mov ecx,20 .loops cmp byte[edi],0 jne .notzero mov byte[edi],32 .notzero inc edi dec ecx jnz .loops ; Check which header has more alphabets, then move sub edi,20 call .checkalpha push eax push edi mov edi,fnameheadtemp call .checkalpha pop edi mov ecx,eax pop eax cmp ecx,eax jb .noswaps mov ecx,20 sub edi,20 mov esi,fnameheadtemp .loops2 mov al,[esi] mov [edi],al inc edi inc esi dec ecx jnz .loops2 .noswaps jmp .fileokay .fileerror mov eax,[.invfile] mov [edi],eax mov eax,[.invfile+4] mov [edi+4],eax mov eax,[.invfile+8] mov [edi+8],eax mov eax,[.invfile+12] mov [edi+12],eax mov eax,[.invfile+16] mov [edi+16],eax .fileokay call Close_File .doneall pop edi pop ecx pop esi mov byte[edi+20],0 push edi push esi push ecx ; check if first 20 bytes are all equal or not mov al,[edi+1] mov ecx,19 .loopchk cmp byte[edi+1],al jne .notequal inc edi dec ecx jnz .loopchk sub edi,19 mov ecx,14 .loopcpy mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .loopcpy .notequal pop ecx pop esi pop edi ; Capitalize push edi push ecx mov ecx,20 .loop4 mov al,[edi] cmp al,'a' jb .nocap cmp al,'z' ja .nocap sub al,'a'-'A' .nocap mov [edi],al dec ecx jnz .loop4 pop ecx pop edi add esi,14 add edi,32 dec ecx jnz near .loop .none pop edi ret .checkalpha mov ecx,20 xor eax,eax .loop3 cmp byte[edi],32 je .alpha cmp byte[edi],'A' jb .noalpha cmp byte[edi],'Z' jbe .alpha cmp byte[edi],'a' jb .noalpha cmp byte[edi],'z' ja .noalpha .alpha inc eax .noalpha inc edi dec ecx jnz .loop3 ret .invfile db ' ** INVALID FILE **',0 fnameheadtemp times 22 db 0 GetNormalDirEntries2: GUIGetDir2 ret GetNormalDirEntries: GUIGetDir ret GetLoadDirNormal2: call GetNormalDirEntries2 ret GetLoadDirNormal: call GetNormalDirEntries push edi ; Copy every 14 bytes of spcRamcmp into every 32 bytes of spcBuffer mov ecx,[GUIdirentries] mov esi,[GUIdirStartLoc] mov edi,dword[GUIfileentries] shl edi,5 add edi,[spcBuffera] cmp ecx,0 je .none .loop mov eax,[esi] mov [edi],eax mov eax,[esi+4] mov [edi+4],eax mov eax,[esi+8] mov [edi+8],eax xor ax,ax mov [edi+12],ax add esi,14 add edi,32 dec ecx jnz .loop .none pop edi ret GetLoadDirNormallfn: call GetNormalDirEntries push edi ; Copy every 14 bytes of spcRamcmp into every 32 bytes of spcBuffer mov edi,dword[GUIfileentries] shl edi,5 add edi,[spcBuffera] inc edi call GUIGetEntryLFNfuncdir pop edi ret Win95Failed db 0 NEWSYM GetCurDir ; get Drive/Dir %ifndef __LINUX__ mov ebx,GUIcurrentdir+3 %else mov ebx,GUIcurrentdir %endif mov edx,GUIcurrentdir call Get_Dir %ifndef __LINUX__ add byte[GUIcurrentdir],65 mov byte[GUIcurrentdir+1],':' mov byte[GUIcurrentdir+2],'\' %endif cmp byte[GUIcurrentdir+35],0 je .nodotend mov byte[GUIcurrentdir+35],'.' mov byte[GUIcurrentdir+36],'.' mov byte[GUIcurrentdir+37],'.' mov byte[GUIcurrentdir+38],0 .nodotend ; Set DTA address call Set_DTA_Address ret GetLoadData: mov dword[GUIcurrentfilewin],0 .a call GetCurDir mov dword[GUInumentries],0 mov dword[GUIcurrentviewloc],0 mov dword[GUIcurrentcursloc],0 mov dword[GUIcurrentdirviewloc],0 mov dword[GUIcurrentdircursloc],0 mov edi,spcRamcmp mov byte[Win95Failed],0 ; cmp byte[OSPort],1 ; ja .notdos %ifdef __MSDOS__ cmp byte[GUIloadfntype],2 jne .nowin95lfn clc mov ax,7100h int 21h jc .nowin95lfn %endif ;.notdos mov byte[GUIloadfntype],0 .nowin95lfn cmp byte[GUIloadfntype],2 je .win95lfn cmp byte[GUIloadfntype],1 je .snesheader mov edi,[spcBuffera] call GetLoadNormal jmp .doneheader .snesheader mov byte[showallext],0 call GetLoadHeader jmp .doneheader .win95lfn call GetLoadLfn .doneheader cmp byte[Win95Failed],1 jne .notfailed mov byte[GUIloadfntype],0 jmp GetLoadData .notfailed mov eax,dword[GUInumentries] mov dword[GUIfileentries],eax cmp dword[GUIfileentries],0 jne .nonoentry mov dword[GUIcurrentfilewin],1 .nonoentry ; Sort List push edi ; compares string at esi to edi and returns 1 to al if esi is >, else 0 .sortagain mov byte[BubbleSorted],0 mov esi,[spcBuffera] inc esi mov edi,spcRamcmp+1 cmp dword[GUInumentries],1 jbe near .nosort cmp byte[GUIloadfntype],0 je near .sort2 mov ecx,[GUInumentries] dec ecx .nextentry push ecx ; check if esi > esi+32 call GUIStringGreater ; if it is, swap! cmp al,0 je near .noswap mov ecx,31 .nextswap mov al,[esi] mov bl,[esi+32] mov [esi],bl mov [esi+32],al inc esi dec ecx jnz .nextswap mov ecx,13 .nextswap2 mov al,[edi] mov bl,[edi+14] mov [edi],bl mov [edi+14],al inc edi dec ecx jnz .nextswap2 mov byte[BubbleSorted],1 sub esi,31 sub edi,13 .noswap add esi,32 add edi,14 pop ecx dec ecx jnz near .nextentry .nosort cmp byte[BubbleSorted],1 je near .sortagain jmp .donesort .sort2 mov esi,spcRamcmp mov ecx,[GUInumentries] dec ecx .nextentryb push ecx mov ebx,[esi] mov edx,[esi+4] inc ebx inc edx ; check if ebx > edx call GUIStringGreater2 ; if it is, swap! cmp al,0 je near .noswapb mov eax,[esi] mov ebx,[esi+4] mov [esi],ebx mov [esi+4],eax mov byte[BubbleSorted],1 .noswapb add esi,4 pop ecx dec ecx jnz near .nextentryb .nosortb cmp byte[BubbleSorted],1 je near .sortagain .donesort pop edi GUIGetDirs: mov dword[GUIdirentries],0 mov [GUIdirStartLoc],edi cmp byte[GUIloadfntype],0 jne near .loadtype0 mov eax,[GUInumentries] mov [GUIdirStartLoc],eax .loadtype0 cmp byte[GUIloadfntype],2 je .win95lfn cmp byte[GUIloadfntype],0 je .normaldir call GetLoadDirNormal jmp .nowin95 .normaldir call GetLoadDirNormal2 jmp .nowin95 .win95lfn call GetLoadDirNormallfn .nowin95 cmp dword[GUInumentries],0 je near .nodirs cmp dword[GUIdirentries],0 je near .nodirs ; Sort List ; copy from GUIdirStartLoc to spcBuffer+GUIdirentries*32 ; compares string at esi to edi and returns 1 to al if esi is >, else 0 push edi ; compares string at esi to edi and returns 1 to al if esi is >, else 0 .sortagain mov byte[BubbleSorted],0 mov esi,dword[GUIfileentries] shl esi,5 add esi,[spcBuffera] mov edi,[GUIdirStartLoc] inc esi inc edi cmp dword[GUIdirentries],1 jbe near .nosort mov ecx,[GUIdirentries] dec ecx cmp byte[GUIloadfntype],0 je near .sort2 .nextentry push ecx ; check if esi > esi+32 call GUIStringGreater ; if it is, swap! cmp al,0 je near .noswap mov ecx,31 .nextswap mov al,[esi] mov bl,[esi+32] mov [esi],bl mov [esi+32],al inc esi dec ecx jnz .nextswap mov ecx,13 .nextswap2 mov al,[edi] mov bl,[edi+14] mov [edi],bl mov [edi+14],al inc edi dec ecx jnz .nextswap2 mov byte[BubbleSorted],1 sub esi,31 sub edi,13 .noswap add esi,32 add edi,14 pop ecx dec ecx jnz near .nextentry .nosort cmp byte[BubbleSorted],1 je near .sortagain pop edi jmp .nodirs .sort2 mov esi,dword[GUIfileentries] shl esi,2 add esi,spcRamcmp .nextentryb push ecx mov ebx,[esi] mov edx,[esi+4] inc ebx inc edx ; check if ebx > edx call GUIStringGreater2 ; if it is, swap! cmp al,0 je near .noswapb mov eax,[esi] mov ebx,[esi+4] mov [esi],ebx mov [esi+4],eax mov byte[BubbleSorted],1 .noswapb add esi,4 pop ecx dec ecx jnz near .nextentryb .nosortb cmp byte[BubbleSorted],1 je near .sortagain pop edi .nodirs %ifndef __LINUX__ cmp byte[GUIloadfntype],0 je near .drive2 mov esi,[GUInumentries] shl esi,5 add esi,[spcBuffera] mov al,65 mov ecx,[numdrives] .nextdrive GUIPutDrive inc al dec ecx jnz .nextdrive jmp .nodrive .drive2 mov esi,[GUInumentries] shl esi,2 add esi,spcRamcmp mov al,65 mov ecx,[numdrives] .nextdriveb mov [esi],edi GUIPutDrive2 add esi,4 inc al dec ecx jnz .nextdriveb .nodrive %endif ret BubbleSorted db 0 GUIcurrentfilewin dd 0 GUIcurrentviewloc dd 0 GUIcurrentcursloc dd 0 GUIcurrentdirviewloc dd 0 GUIcurrentdircursloc dd 0 GUIdirStartLoc dd 0 GUInumentries dd 0 GUIdirentries dd 0 GUIfileentries dd 0 %ifdef __LINUX__ NEWSYM GUIsmcfind, db '*.[sS][mM][cC]',0 NEWSYM GUIsfcfind, db '*.[sS][fF][cC]',0 NEWSYM GUIswcfind, db '*.[sS][wW][cC]',0 NEWSYM GUIfigfind, db '*.[fF][iI][gG]',0 %else NEWSYM GUIsmcfind, db '*.SMC',0 NEWSYM GUIsfcfind, db '*.SFC',0 NEWSYM GUIswcfind, db '*.SWC',0 NEWSYM GUIfigfind, db '*.FIG',0 %endif NEWSYM GUIfind058, db '*.058',0 NEWSYM GUIfind078, db '*.078',0 %ifdef __LINUX__ NEWSYM GUIfindUSA, db '*.[uU][sS][aA]',0 NEWSYM GUIfindJAP, db '*.[jJ][aA][pP]',0 NEWSYM GUIfindBIN, db '*.[bB][iI][nN]',0 NEWSYM GUIfindZIP, db '*.[zZ][iI][pP]',0 NEWSYM GUIfindGZIP, db '*.[gG][zZ]',0 %else NEWSYM GUIfindUSA, db '*.USA',0 NEWSYM GUIfindJAP, db '*.JAP',0 NEWSYM GUIfindBIN, db '*.BIN',0 NEWSYM GUIfindZIP, db '*.ZIP',0 NEWSYM GUIfindGZIP, db '*.GZ',0 %endif NEWSYM GUIfind1, db '*.1',0 %ifdef __LINUX__ GUIfindDIR db '*',0 NEWSYM GUIfindall, db '*',0 %else GUIfindDIR db '*.*',0 NEWSYM GUIfindall, db '*.*',0 %endif NEWSYM DTALoc, times 2048+32 db 0 ; Routines to load from the Quick Menu loadquickfname: pushad .trynext cmp byte[GUIwinptr],0 je near .noclose xor eax,eax mov al,[GUIwinptr] dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] ; close window mov byte[GUIwinorder+eax],0 mov byte[GUIwinactiv+ebx],0 dec byte[GUIwinptr] cmp byte[GUIwinptr],0 jne .noclose mov al,[GUIpmenupos] mov [GUIcmenupos],al jmp .trynext .noclose popad ; move menuitem to top cmp ecx,0 je near .nomove cmp byte[prevlfreeze],0 jne near .nomove ; copy 16 bytes of ebx to pressed mov eax,[ebx] mov [pressed],eax mov eax,[ebx+4] mov [pressed+4],eax mov eax,[ebx+8] mov [pressed+8],eax mov eax,[ebx+12] mov [pressed+12],eax ; move each entry above ebx down .next2 mov eax,[ebx-16] mov [ebx],eax mov eax,[ebx+4-16] mov [ebx+4],eax mov eax,[ebx+8-16] mov [ebx+8],eax mov eax,[ebx+12-16] mov [ebx+12],eax sub ebx,16 cmp ebx,prevloadnames jne .next2 ; copy 16 bytes of pressed to top mov eax,[pressed] mov [ebx],eax mov eax,[pressed+4] mov [ebx+4],eax mov eax,[pressed+8] mov [ebx+8],eax mov eax,[pressed+12] mov [ebx+12],eax ; copy 512 bytes of edi to pressed mov ecx,128 xor ebx,ebx .loopb mov eax,[edi+ebx*4] mov [pressed+ebx*4],eax inc ebx dec ecx jnz .loopb ; move each entry above ebx down .next3b mov ecx,128 xor ebx,ebx .loop2b mov eax,[edi-512+ebx*4] mov [edi+ebx*4],eax inc ebx dec ecx jnz .loop2b sub edi,512 cmp edi,prevloadfnamel jne .next3b ; copy 512 bytes of pressed to top mov ecx,128 xor ebx,ebx .loop3b mov eax,[pressed+ebx*4] mov [edi+ebx*4],eax inc ebx dec ecx jnz .loop3b ; copy 512 bytes of esi to pressed mov ecx,128 xor ebx,ebx .loop mov eax,[esi+ebx*4] mov [pressed+ebx*4],eax inc ebx dec ecx jnz .loop ; move each entry above ebx down .next3 mov ecx,128 xor ebx,ebx .loop2 mov eax,[esi-512+ebx*4] mov [esi+ebx*4],eax inc ebx dec ecx jnz .loop2 sub esi,512 cmp esi,prevloaddnamel jne .next3 ; copy 512 bytes of pressed to top mov ecx,128 xor ebx,ebx .loop3 mov eax,[pressed+ebx*4] mov [esi+ebx*4],eax inc ebx dec ecx jnz .loop3 ; pushad ; mov ax,03h ; int 10h ; popad ; push edi ; mov edx,esi+1 ; call PrintStr ; pop edi ; mov edx,edi+1 ; call PrintStr ; jmp DosExit ; clear pressed mov eax,pressed mov ecx,128 .loop4 mov dword[eax],0 add eax,4 dec ecx jnz .loop4 .nomove ; change dir mov dl,[esi] mov ebx,esi inc ebx call Change_Dir call GetCurDir mov eax,edi push eax mov edx,edi call Open_File jc near .failed mov bx,ax mov edx,.temp mov ecx,1 call Read_File jc near .failed2 call Close_File jc near .failed pop eax pushad call GUIQuickLoadUpdate popad call GUIloadfilename ret .failed2 call Close_File .failed pop eax ret .temp times 256 dd 0 zsnes-1.36/src/gui/guimisc.inc0100644000175000017500000002522407440335075015706 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Movie, Joystick setting (display) routines, SNES Reset Function MovieRecord: mov byte[GUICBHold],0 mov dword[MovieCounter],0 cmp byte[MovieProcessing],0 jne near .dontrecord ; check if movie exists already mov ebx,[statefileloc] mov eax,[fnamest+ebx-3] push eax mov dword[fnamest+ebx-3],'.zmv' mov al,[CMovieExt] mov byte[fnamest+ebx],al ; check if file exists cmp byte[MovieRecordWinVal],1 je .nocheck mov edx,fnamest+1 call Open_File jc .nocheck mov bx,ax call Close_File mov byte[MovieRecordWinVal],1 jmp .skipstate .nocheck mov dword[CFWriteHead],0 mov dword[CReadHead],0 mov dword[ReadHead],0 mov dword[CFWriteStart],64 mov byte[MovieRecordWinVal],0 call ChangetoSRAMdir mov byte[NoPictureSave],1 call statesaver mov byte[NoPictureSave],0 mov edx,fnamest+1 call Open_File_Write mov bx,ax mov [MovieFileHand],bx mov cx,0 mov dx,0 call File_Seek_End mov al,[soundon] mov [RecData],al mov eax,[welcome+8] mov [RecData+1],eax mov byte[RecData+2],1 mov eax,[timer2upd] mov [RecData+3],eax mov eax,[curexecstate] mov [RecData+7],eax mov edx,RecData mov ecx,16 call Write_File cmp dword[ramsize],0 je .noram mov edx,[sram] mov ecx,[ramsize] call Write_File .noram mov byte[MovieProcessing],2 mov dword[MovieBuffSize],0 mov dword[MovieBuffFrame],0 mov byte[RepeatFrame],0 cmp byte[CNetType],20 je near .netstuff cmp byte[CNetType],21 je near .netstuff mov dword[nmiprevaddrl],0 mov dword[nmiprevaddrh],0 mov dword[nmirept],0 mov dword[nmiprevline],224 mov dword[nmistatus],0 mov byte[spcnumread],0 mov byte[NextLineCache],0 mov dword[PJoyAOrig],0 mov dword[PJoyBOrig],0 mov dword[PJoyCOrig],0 mov dword[PJoyDOrig],0 mov dword[PJoyEOrig],0 mov byte[DSPMem+08h],0 mov byte[DSPMem+18h],0 mov byte[DSPMem+28h],0 mov byte[DSPMem+38h],0 mov byte[DSPMem+48h],0 mov byte[DSPMem+58h],0 mov byte[DSPMem+68h],0 mov byte[DSPMem+78h],0 .netstuff call ChangetoLOADdir .skipstate pop eax mov ebx,[statefileloc] mov [fnamest+ebx-3],eax .dontrecord ret MovieRecordWinVal db 0 NEWSYM MovieProcessing, db 0 NEWSYM MovieFileHand, dw 0 NEWSYM RepeatFrame, db 0 NEWSYM RecData, times 16 db 0 NEWSYM NoPictureSave, db 0 SkipMovie: mov byte[MovieRecordWinVal],0 mov byte[GUICBHold],0 ret MovieStop: mov byte[GUICBHold],0 cmp byte[MovieProcessing],0 je .skipfileend mov bx,[MovieFileHand] mov byte[MovieProcessing],0 call Close_File .skipfileend ret CalibrateDispA: xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 75,103,192,135,160 GUIBox 75,103,192,103,162 GUIBox 75,103,75,135,161 GUIBox 192,103,192,135,159 GUIBox 75,135,192,135,158 GUIOuttext 81,109,guicalberror1,220-15 GUIOuttext 80,108,guicalberror1,220 GUIOuttext 81,117,guicalberror2,220-15 GUIOuttext 80,116,guicalberror2,220 GUIOuttext 81,125,guicalberror3,220-15 GUIOuttext 80,124,guicalberror3,220 call vidpastecopyscr call WaitForKey ret CalibrateDispB: xor ebx,ebx mov ecx,256 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 75,103,192,143,160 GUIBox 75,103,192,103,162 GUIBox 75,103,75,143,161 GUIBox 192,103,192,143,159 GUIBox 75,143,192,143,158 GUIOuttext 81,109,guicalberror4,220-15 GUIOuttext 80,108,guicalberror4,220 GUIOuttext 81,117,guicalberror5,220-15 GUIOuttext 80,116,guicalberror5,220 GUIOuttext 81,125,guicalberror6,220-15 GUIOuttext 80,124,guicalberror6,220 GUIOuttext 81,133,guicalberror7,220-15 GUIOuttext 80,132,guicalberror7,220 call vidpastecopyscr call WaitForKey ret guicalberror1 db 'PRESS THE TOP LEFT',0 guicalberror2 db 'CORNER AND PRESS A',0 guicalberror3 db 'BUTTON OR KEY',0 guicalberror4 db 'PRESS THE BOTTOM',0 guicalberror5 db 'RIGHT CORNER AND',0 guicalberror6 db 'PRESS A BUTTON OR',0 guicalberror7 db 'KEY',0 SetAllKeys: xor ebx,ebx mov ecx,256+128+64 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a mov byte[GUICBHold],0 mov edi,pl1selk cmp byte[cplayernum],1 jne .nopl2 mov edi,pl2selk .nopl2 cmp byte[cplayernum],2 jne .nopl3 mov edi,pl3selk .nopl3 cmp byte[cplayernum],3 jne .nopl4 mov edi,pl4selk .nopl4 cmp byte[cplayernum],4 jne .nopl5 mov edi,pl5selk .nopl5 mov dword[guicpressptr],edi xor ebx,ebx mov ecx,12 mov dword[guipressptr],guipresstext4b .loop mov eax,[.ordercalb+ebx*4] shl eax,2 add dword[guicpressptr],eax push ebx push ecx call guipresstestb pop ecx pop ebx add dword[guipressptr],21 mov eax,[.ordercalb+ebx*4] shl eax,2 sub dword[guicpressptr],eax inc ebx dec ecx jnz .loop ret .ordercalb dd 2,3,4,5,1,0,7,10,6,9,8,11 CalibrateDev1: xor eax,eax mov al,[cplayernum] mov ebx,[GUIInputRefP+eax*4] mov bl,[ebx] mov byte[GUICBHold],0 %ifdef __MSDOS__ cmp byte[pl1p209+eax],0 jne near .port209 %endif cmp bl,1 jbe .nojoy cmp bl,18 je near .6button cmp bl,5 je near .6button cmp bl,6 jae .nojoy mov dx,201h call GetCoords mov eax,[JoyX] mov [.joybcx],eax mov eax,[JoyY] mov [.joybcy],eax call CalibrateDispA mov dx,201h call GetCoords mov eax,[JoyX] mov [.joyblx],eax mov eax,[JoyY] mov [.joybly],eax call CalibrateDispB mov dx,201h call GetCoords jmp .procdir .nojoy ret .6button mov dx,201h call GetCoords3 mov eax,[JoyX] mov [.joybcx],eax mov eax,[JoyY] mov [.joybcy],eax call CalibrateDispA mov dx,201h call GetCoords3 mov eax,[JoyX] mov [.joyblx],eax mov eax,[JoyY] mov [.joybly],eax call CalibrateDispB mov dx,201h call GetCoords3 .procdir mov eax,[.joybcx] add eax,[.joyblx] shr eax,1 mov [JoyMinX],eax mov [CalibXmin],eax mov eax,[.joybcy] add eax,[.joybly] shr eax,1 mov [JoyMinY],eax mov [CalibYmin],eax mov eax,[.joybcx] add eax,[JoyX] shr eax,1 mov [JoyMaxX],eax mov [CalibXmax],eax mov eax,[.joybcy] add eax,[JoyY] shr eax,1 mov [JoyMaxY],eax mov [CalibYmax],eax ret .port209 cmp bl,1 jbe .nojoy209 cmp bl,18 je near .6button209 cmp bl,5 je near .6button209 cmp bl,6 jae .nojoy209 mov dx,209h call GetCoords mov eax,[JoyX] mov [.joybcx],eax mov eax,[JoyY] mov [.joybcy],eax call CalibrateDispA mov dx,209h call GetCoords mov eax,[JoyX] mov [.joyblx],eax mov eax,[JoyY] mov [.joybly],eax call CalibrateDispB mov dx,209h call GetCoords jmp .procdir209 .nojoy209 ret .6button209 mov dx,209h call GetCoords3 mov eax,[JoyX] mov [.joybcx],eax mov eax,[JoyY] mov [.joybcy],eax call CalibrateDispA mov dx,209h call GetCoords3 mov eax,[JoyX] mov [.joyblx],eax mov eax,[JoyY] mov [.joybly],eax call CalibrateDispB mov dx,209h call GetCoords3 .procdir209 mov eax,[.joybcx] add eax,[.joyblx] shr eax,1 mov [JoyMinX209],eax mov [CalibXmin209],eax mov eax,[.joybcy] add eax,[.joybly] shr eax,1 mov [JoyMinY209],eax mov [CalibYmin209],eax mov eax,[.joybcx] add eax,[JoyX] shr eax,1 mov [JoyMaxX209],eax mov [CalibXmax209],eax mov eax,[.joybcy] add eax,[JoyY] shr eax,1 mov [JoyMaxY209],eax mov [CalibYmax209],eax ret .joyblx dd 0 .joybly dd 0 .joybcx dd 0 .joybcy dd 0 SetDevice: mov byte[GUICBHold],0 xor eax,eax mov al,[cplayernum] ; cmp byte[OSPort],1 ; ja .notdos %ifdef __MSDOS__ cmp byte[pl1p209+eax],0 jne .port209 %endif ;.notdos mov dword[CalibXmin],0 mov ecx,[DevicePtr+eax*4] mov eax,[GUIInputRefP+eax*4] mov ebx,[GUIcurrentinputcursloc] mov bl,[GUIInputRefF+ebx] mov [eax],bl mov eax,ecx mov bh,[cplayernum] call SetInputDevice call UpdateDevices jmp .procmtap .port209 mov dword[CalibXmin209],0 mov ecx,[DevicePtr+eax*4] mov eax,[GUIInputRefP+eax*4] mov ebx,[GUIcurrentinputcursloc] mov bl,[GUIInputRefF+ebx] mov [eax],bl mov eax,ecx mov bh,[cplayernum] call SetInputDevice209 call UpdateDevices .procmtap mov byte[MultiTap],1 cmp byte[SFXEnable],1 je .dismtap cmp byte[pl3contrl],0 jne .mtap cmp byte[pl4contrl],0 jne .mtap cmp byte[pl5contrl],0 jne .mtap .dismtap mov byte[MultiTap],0 .mtap ret NEWSYM GUIDoReset call ClearScreen call Clear2xSaIBuffer ; mov byte[NetPlayNoMore],1 mov byte[RestoreValues],0 cmp byte[MovieProcessing],0 je .skipfileend mov bx,[MovieFileHand] mov byte[MovieProcessing],0 call Close_File .skipfileend call RestoreSystemVars ; clear spc700 ram mov al,0FFh mov edi,spcRam mov ecx,65472 rep stosb ; clear dsp ram xor al,al mov edi,DSPMem mov ecx,256 rep stosb ; reset the snes call init65816 call procexecloop mov eax,spcRam mov edx,0EFh .loop mov byte[eax],0 inc eax dec edx jnz .loop xor eax,eax mov edx,spcRam mov ax,0FFC9h add edx,eax mov [spcPCRam],edx mov dword [spcS],1EFh mov dword [spcRamDP],spcRam mov byte[spcA],0 mov byte[spcX],0 mov byte[spcY],0 mov byte[spcP],0 mov byte[spcNZ],0 mov byte[Voice0Status],0 mov byte[Voice1Status],0 mov byte[Voice2Status],0 mov byte[Voice3Status],0 mov byte[Voice4Status],0 mov byte[Voice5Status],0 mov byte[Voice6Status],0 mov byte[Voice7Status],0 mov byte[GUIQuit],2 ret zsnes-1.36/src/gui/guimouse.inc0100644000175000017500000021766207462663140016115 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %ifdef __WIN32__ EXTSYM CheckPriority EXTSYM CheckAlwaysOnTop EXTSYM CheckScreenSaver EXTSYM MinimizeWindow %endif lastmouseholded db 0 mousebuttonstat dw 0 MouseMoveOkay db 0 LastHoldEnable db 0 ProcessMouse: ; Process holds mov al,[GUIHold] cmp al,[LastHoldEnable] je near .noholdnecessary cmp byte[GUIHold],0 jne .noholda mov ecx,0 mov edx,255 call Set_MouseXMax mov ecx,0 mov edx,223 call Set_MouseYMax .noholda cmp byte[GUIHold],1 jne .nohold1 mov ecx,0 mov edx,255 call Set_MouseXMax mov ecx,16 mov edx,223 call Set_MouseYMax .nohold1 cmp byte[GUIHold],5 je .dohold5 cmp byte[GUIHold],2 jne .nohold2m .dohold5 mov ecx,[GUIHoldXlimL] mov edx,[GUIHoldXlimR] call Set_MouseXMax mov ecx,[GUIHoldYlim] mov edx,[GUIHoldYlim] call Set_MouseYMax .nohold2m cmp byte[GUIHold],3 jne .nohold3m mov ecx,[GUIHoldXlimL] mov edx,[GUIHoldXlimR] call Set_MouseXMax mov ecx,[GUIHoldYlim] mov edx,[GUIHoldYlimR] call Set_MouseYMax .nohold3m mov al,[GUIHold] mov [LastHoldEnable],al .noholdnecessary mov byte[MouseMoveOkay],0 call Get_MouseData mov [mousebuttonstat],bx cmp byte[lastmouseholded],0 je .noprevhold test bx,01h jnz .noprevhold mov byte[lastmouseholded],0 mov cx,[GUImouseposx] mov dx,[GUImouseposy] call Set_MousePosition .noprevhold cmp byte[mousewrap],1 je near ProcessMouseWrap call Get_MouseData cmp word[GUImouseposx],cx je .zero2 mov byte[MouseMoveOkay],1 .zero2 cmp word[GUImouseposy],dx je .zero3 mov byte[MouseMoveOkay],1 .zero3 mov word[GUImouseposx],cx test word[GUImouseposx],8000h jz .nowrapleft mov word[GUImouseposx],0 .nowrapleft cmp word[GUImouseposx],255 jbe .nowrapright mov word[GUImouseposx],255 .nowrapright mov word[GUImouseposy],dx test word[GUImouseposy],8000h jz .nowrapup mov word[GUImouseposy],0 .nowrapup cmp word[GUImouseposy],223 jbe .nowrapdown mov word[GUImouseposy],100 .nowrapdown jmp ProcessMouseButtons ProcessMouseWrap: call Get_MousePositionDisplacement add word[GUImouseposx],cx .again test word[GUImouseposx],8000h jz .nowrapleft add word[GUImouseposx],256 jmp .again .nowrapleft cmp word[GUImouseposx],255 jbe .nowrapright sub word[GUImouseposx],256 jmp .again .nowrapright add word[GUImouseposy],dx .again2 test word[GUImouseposy],8000h jz .nowrapup add word[GUImouseposy],224 jmp .again2 .nowrapup cmp word[GUImouseposy],223 jbe .nowrapdown cmp byte[GUIHold],1 jne .nohold sub word[GUImouseposy],224-16 jmp .again2 .nohold sub word[GUImouseposy],224 jmp .again2 .nowrapdown cmp dx,0 jne .nozero cmp cx,0 je .zero .nozero mov byte[MouseMoveOkay],1 .zero ProcessMouseButtons: cmp byte[MouseMoveOkay],1 jne .zero mov byte[GUIOnMenuItm],0 mov ax,[GUImouseposx] cmp ax,[GUIMenuL] jbe .zero cmp ax,[GUIMenuR] jae .zero mov ax,[GUImouseposy] cmp ax,18 jbe .zero cmp ax,[GUIMenuD] jae .zero ; Mouse Menu xor dx,dx sub ax,18 mov bx,10 div bx and eax,0FFh mov ebx,[GUICYLocPtr] mov byte[GUIOnMenuItm],2 cmp byte[eax+ebx+1],0 je .zero mov byte[GUIcrowpos],al mov byte[GUIOnMenuItm],1 .zero ; Check if mouse is clicked on menu mov bx,[mousebuttonstat] cmp byte[GUIClick],1 jne .norclick2 test bx,02h jz .norclick cmp byte[romloadskip],0 jne .norclick2 cmp byte[MousePRClick],0 jne .norclick2 mov byte[GUIQuit],2 .norclick mov byte[MousePRClick],0 .norclick2 test bx,01h jz near .notclicked cmp byte[GUIpclicked],1 je near .noclick cmp byte[GUIOnMenuItm],2 je near .noclick cmp byte[GUIOnMenuItm],1 jne .nomenuitem call GUITryMenuItem jmp .noclick .nomenuitem cmp word[GUImouseposy],3 jb near .noclickedw cmp word[GUImouseposy],14 ja near .noclickedw cmp word[GUImouseposx],230 jb near .noclickedw cmp word[GUImouseposx],233 jb near .noclickedw cmp word[GUImouseposx],242 ja .notfound7 %ifdef __LINUX__ jmp .clickawn %endif cmp word[GUImouseposy],8 jb .clickawn cmp word[GUImouseposy],8 ja .clickawn2 .clickawn mov byte[GUIcwinpress],1 jmp .noclick .clickawn2 mov byte[GUIcwinpress],3 jmp .noclick .notfound7 cmp word[GUImouseposx],244 jb near .noclickedw cmp word[GUImouseposx],253 ja .notfound8 mov byte[GUIcwinpress],2 jmp .noclick .notfound8 .noclickedw cmp word[GUImouseposy],15 ja near .nomenu cmp word[GUImouseposy],3 jb near .noclicked cmp word[GUImouseposy],13 ja near .noclicked ; GUIDMHelp 4,12,GUIMenuItem+6,1 cmp word[GUImouseposx],4 jb near .noclicked cmp word[GUImouseposx],12 ja .notfound mov byte[GUIcmenupos],1 mov byte[GUIcrowpos],0 jmp .noclick .notfound ; GUIDMHelp 17,47,GUIMenuItem,2 cmp word[GUImouseposx],17 jb near .noclicked cmp word[GUImouseposx],47 ja .notfound2 mov byte[GUIcmenupos],2 mov byte[GUIcrowpos],0 jmp .noclick .notfound2 ; GUIDMHelp 52,94,GUIMenuItem+7,3 cmp word[GUImouseposx],52 jb near .noclicked cmp word[GUImouseposx],94 ja .notfound3 mov byte[GUIcmenupos],3 mov byte[GUIcrowpos],0 jmp .noclick .notfound3 ; GUIDMHelp 99,135,GUIMenuItem+14,4 cmp word[GUImouseposx],99 jb near .noclicked cmp word[GUImouseposx],135 ja .notfound4 mov byte[GUIcmenupos],4 mov byte[GUIcrowpos],0 jmp .noclick .notfound4 ; GUIDMHelp 140,188,GUIMenuItem+21,5 cmp word[GUImouseposx],140 jb near .noclicked cmp word[GUImouseposx],188 ja .notfound5 mov byte[GUIcmenupos],5 mov byte[GUIcrowpos],0 jmp .noclick .notfound5 ; GUIDMHelp 193,223,GUIMenuItem+29,6 cmp word[GUImouseposx],193 jb near .noclicked cmp word[GUImouseposx],223 ja .notfound6 mov byte[GUIcmenupos],6 mov byte[GUIcrowpos],0 jmp .noclick .notfound6 jmp .noclick .noclicked ; cmp byte[OSPort],3 ; jne .noclick %ifdef __MSDOS__ jmp .noclick %else mov byte[GUIpclicked],1 mov byte[GUIHold],255 mov eax,[GUImouseposy] mov [GUIHoldYlim],eax mov eax,[GUImouseposx] mov [GUIHoldXlimL],eax call MouseWindow jmp .noclick %endif .nomenu cmp byte[GUIcmenupos],0 je near .checkmenuboxclick mov al,[GUIcmenupos] mov [GUIpmenupos],al mov byte[GUIcmenupos],0 .noclick mov byte[GUIpclicked],1 xor eax,eax mov al,[GUIwinptr] dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] cmp byte[GUIHold],2 je .hold2 cmp byte[GUIHold],3 je near .hold3 cmp byte[GUIHold],4 je near .hold4 cmp byte[GUIHold],5 je near .hold5 cmp byte[GUIHold],1 je near .hold cmp byte[GUIHold],255 je .holded mov byte[GUICHold],0 ret .holded mov eax,[GUIHoldYlim] mov [GUImouseposy],eax mov eax,[GUIHoldXlimL] mov [GUImouseposx],eax mov cx,[GUIHoldXlimL] mov dx,[GUIHoldYlim] call Set_MousePosition ret .hold2 ; Slide Bar Hold mov eax,[GUIHoldYlim] mov [GUImouseposy],eax mov ebx,[GUImouseposx] mov eax,[GUIHoldXlimL] cmp ebx,eax jnl .noless mov [GUImouseposx],eax .noless mov eax,[GUIHoldXlimR] cmp ebx,eax jng .nogreat mov [GUImouseposx],eax .nogreat mov byte[lastmouseholded],1 jmp DisplayGUIOptnsClick .hold3 ; Box Hold mov ebx,[GUIHoldYlim] cmp ebx,[GUImouseposy] jl .boxhold1 mov [GUImouseposy],ebx .boxhold1 mov ebx,[GUIHoldXlimL] cmp ebx,[GUImouseposx] jl .boxhold2 mov [GUImouseposx],ebx .boxhold2 mov ebx,[GUIHoldYlimR] cmp ebx,[GUImouseposy] jg .boxhold3 mov [GUImouseposy],ebx .boxhold3 mov ebx,[GUIHoldXlimR] cmp ebx,[GUImouseposx] jg .boxhold4 mov [GUImouseposx],ebx .boxhold4 mov byte[lastmouseholded],1 jmp GUIWindowMove .hold4 mov eax,[GUImouseposx] sub eax,[GUIwinposx+ebx*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+ebx*4] cmp eax,[GUIHoldXlimL] jl near .nobhold cmp edx,[GUIHoldYlim] jl near .nobhold cmp eax,[GUIHoldXlimR] jg near .nobhold cmp edx,[GUIHoldYlimR] jg near .nobhold mov al,[GUICBHold2] mov [GUICBHold],al ret .nobhold mov byte[GUICBHold],0 ret .hold5 ; Slide Bar Hold mov eax,[GUIHoldYlim] mov [GUImouseposy],eax mov ebx,[GUImouseposx] mov eax,[GUIHoldXlimL] cmp ebx,eax jnl .nolessa mov [GUImouseposx],eax .nolessa mov eax,[GUIHoldXlimR] cmp ebx,eax jng .nogreata mov [GUImouseposx],eax .nogreata mov byte[lastmouseholded],1 jmp DisplayGUISoundClick .hold cmp word[GUImouseposy],16 jge .noover test byte[mousewrap],1 jz .nomwrap add word[GUImouseposy],224-16 jmp .hold .nomwrap mov word[GUImouseposy],16 .noover mov cx,word[GUImouseposy] sub cx,[GUIHoldy] add cx,[GUIHoldym] movsx ecx,cx xor eax,eax mov al,[GUIwinptr] dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] mov [GUIwinposy+ebx*4],ecx mov cx,word[GUImouseposx] sub cx,[GUIHoldx] add cx,[GUIHoldxm] movsx ecx,cx mov [GUIwinposx+ebx*4],ecx ret .notclicked mov byte[GUICHold],0 mov byte[GUIpclicked],0 mov byte[GUIHold],0 ; cmp byte[OSPort],3 ; jne .notwinpressa %ifdef __LINUX__ cmp byte[GUIcwinpress],1 jne .notwinpressa mov byte[GUIcwinpress],0 cmp word[GUImouseposy],3 jb .notwinpressa cmp word[GUImouseposy],13 ja .notwinpressa cmp word[GUImouseposx],233 jb .notwinpressa cmp word[GUImouseposx],242 ja .notwinpressa call SwitchFullScreen ret %endif %ifdef __WIN32__ cmp byte[GUIcwinpress],1 jne .notwinpressa mov byte[GUIcwinpress],0 cmp word[GUImouseposy],3 jb .notwinpressa cmp word[GUImouseposy],7 ja .notwinpressa cmp word[GUImouseposx],233 jb .notwinpressa cmp word[GUImouseposx],242 ja .notwinpressa call SwitchFullScreen ret %endif .notwinpressa ; cmp byte[OSPort],3 ; jne .notwinpressb %ifndef __MSDOS__ cmp byte[GUIcwinpress],2 jne .notwinpressb mov byte[GUIcwinpress],0 cmp word[GUImouseposy],3 jb .notwinpressb cmp word[GUImouseposy],13 ja .notwinpressb cmp word[GUImouseposx],244 jb .notwinpressb cmp word[GUImouseposx],253 ja .notwinpressb mov byte[GUIQuit],1 ret .notwinpressb ;cmp byte[OSPort],3 ;jne .notwinpressc cmp byte[GUIcwinpress],3 jne .notwinpressc mov byte[GUIcwinpress],0 cmp word[GUImouseposy],9 jb .notwinpressc cmp word[GUImouseposy],13 ja .notwinpressc cmp word[GUImouseposx],233 jb .notwinpressc cmp word[GUImouseposx],242 ja .notwinpressc %endif %ifdef __WIN32__ pushad call MinimizeWindow popad %endif %ifndef __MSDOS__ ret %endif .notwinpressc ; ButtonProcess cmp byte[GUICBHold],1 je near GUILoadData cmp byte[GUICBHold],2 je near GUIProcReset cmp byte[GUICBHold],3 je near GUIProcReset cmp byte[GUICBHold],4 je near GUIProcVideo cmp byte[GUICBHold],10 je near GUIProcStates cmp byte[GUICBHold],11 je near GUIProcStates cmp byte[GUICBHold],5 je near CheatCodeRemove cmp byte[GUICBHold],6 je near CheatCodeToggle cmp byte[GUICBHold],7 je near CheatCodeSave cmp byte[GUICBHold],8 je near CheatCodeLoad cmp byte[GUICBHold],9 je near ProcessCheatCode cmp byte[GUICBHold],33 je near CheatCodeFix cmp byte[GUICBHold],14 je near SetDevice cmp byte[GUICBHold],15 je near CalibrateDev1 cmp byte[GUICBHold],16 je near MoviePlay cmp byte[GUICBHold],17 je near MovieRecord cmp byte[GUICBHold],18 je near MovieStop cmp byte[GUICBHold],19 je near MovieRecord cmp byte[GUICBHold],20 je near SkipMovie cmp byte[GUICBHold],40 je near SetAllKeys cmp byte[GUICBHold],50 jne .notstartcheat call CheatCodeSearchInit .notstartcheat cmp byte[GUICBHold],60 jne .nocombclear mov byte[GUIComboTextH],0 mov byte[GUINumCombo],0 mov dword[GUIComboKey],0 .nocombclear cmp byte[GUICBHold],61 jne .nocomboadd cmp byte[NumCombo],50 je .nocomboadd call ComboAdder .nocomboadd cmp byte[GUICBHold],62 jne .nocomboreplace cmp byte[NumCombo],0 je .nocomboreplace call ComboReplace .nocomboreplace cmp byte[GUICBHold],63 jne .nocomboremove cmp byte[NumCombo],0 je .nocomboremove call ComboRemoval .nocomboremove cmp byte[GUICBHold],51 jne .notrestartcheat mov byte[CheatWinMode],0 mov byte[CheatSearchStatus],0 .notrestartcheat cmp byte[GUICBHold],52 jne .notviewcheat mov byte[CheatWinMode],2 .notviewcheat cmp byte[GUICBHold],53 jne .notsearchprocess call CheatCodeSearchProcess .notsearchprocess cmp byte[GUICBHold],54 jne .notreturnview mov byte[CheatWinMode],1 .notreturnview cmp byte[GUICBHold],55 jne .notadd cmp dword[NumCheatSrc],0 je .notadd mov byte[CheatWinMode],3 mov byte[CurCStextpos],0 mov byte[CSInputDisplay],'_' mov byte[CSInputDisplay+1],0 mov byte[CSDescDisplay],0 .notadd cmp byte[GUICBHold],56 jne .notreturnadd mov byte[CheatWinMode],2 .notreturnadd cmp byte[GUICBHold],57 jne .noinsertscc call AddCSCheatCode ; call InsertSearchDescription .noinsertscc cmp byte[GUICBHold],21 jne .nomodem1 mov byte[CNetType],3 .nomodem1 cmp byte[GUICBHold],22 jne .nomodem2 mov byte[CNetType],10 mov byte[ModemProcess],0 .nomodem2 cmp byte[GUICBHold],23 jne .nomodem3 mov byte[CNetType],2 .nomodem3 cmp byte[GUICBHold],24 jne .nomodem4 mov byte[CNetType],12 mov byte[ModemProcess],0 .nomodem4 cmp byte[GUICBHold],25 jne .nomodem4b mov byte[CNetType],15 mov byte[ModemProcess],40 mov byte[WhichRemote],4 .nomodem4b cmp byte[GUICBHold],26 jne .nomodem4c mov byte[CNetType],15 mov byte[ModemProcess],41 mov byte[WhichRemote],4 .nomodem4c cmp byte[GUICBHold],27 jne .noinit cmp byte[CNetType],20 jne near .nostat20b2 call PreparePacket mov al,255 call RemoteSendChar call SendPacket call PreparePacket mov al,255 call RemoteSendChar call SendPacket call PreparePacket mov al,255 call RemoteSendChar call SendPacket cmp byte[NetQuitAfter],0 je .nostat20b2 mov byte[GUIQuit],1 .nostat20b2 call RemoteDeInit .noinit cmp byte[GUICBHold],28 jne .nomodem5 mov byte[CNetType],11 mov byte[ModemProcess],0 .nomodem5 cmp byte[GUICBHold],34 jne .noipx1 mov byte[WhichRemote],2 mov byte[ModemProcess],30 mov byte[CNetType],15 .noipx1 cmp byte[GUICBHold],64 jne .nostatecancel mov byte[NetStateQuit],1 .nostatecancel %ifndef __LINUX__ cmp byte[GUICBHold],65 jne .nohomepage call GotoHomepage %endif .nohomepage mov byte[GUICBHold],0 ret .checkmenuboxclick mov byte[GUIpclicked],1 xor eax,eax mov al,[GUIwinptr] or eax,eax jz near .nomore dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] mov ecx,[GUIwinposx+ebx*4] cmp ecx,[GUImouseposx] jge .noinsdwin mov ecx,[GUIwinposy+ebx*4] cmp ecx,[GUImouseposy] jge .noinsdwin mov ecx,[GUIwinposx+ebx*4] add ecx,[GUIwinsizex+ebx*4] cmp ecx,[GUImouseposx] jle .noinsdwin mov ecx,[GUIwinposy+ebx*4] add ecx,[GUIwinsizey+ebx*4] add ecx,10 cmp ecx,[GUImouseposy] jle .noinsdwin jmp GUIWinClicked .noinsdwin .nextwindowfind or eax,eax jz near .nomore dec eax mov bl,[GUIwinorder+eax] mov ecx,[GUIwinposx+ebx*4] cmp ecx,[GUImouseposx] jge .nextwindowfind mov ecx,[GUIwinposy+ebx*4] cmp ecx,[GUImouseposy] jge .nextwindowfind mov ecx,[GUIwinposx+ebx*4] add ecx,[GUIwinsizex+ebx*4] cmp ecx,[GUImouseposx] jle .nextwindowfind mov ecx,[GUIwinposy+ebx*4] add ecx,[GUIwinsizey+ebx*4] add ecx,10 cmp ecx,[GUImouseposy] jle .nextwindowfind ; Shift all following windows downwards by 1 .nextfind inc eax cmp al,[GUIwinptr] je .foundend mov cl,[GUIwinorder+eax] mov [GUIwinorder+eax-1],cl jmp .nextfind .foundend mov byte[GUIpclicked],0 mov [GUIwinorder+eax-1],bl ret .nomore cmp dword[SantaPos],272 je .nosanta cmp byte[ShowTimer],0 jne .nosanta mov dword[MsgGiftLeft],36*4 mov byte[ShowTimer],1 .nosanta ret GUIProcVideo: mov al,[GUIcurrentvideocursloc] ; cmp byte[OSPort],2 ; jae .yes16b %ifdef __MSDOS__ cmp al,3 je .yes16b cmp al,5 je .yes16b cmp al,7 je .yes16b cmp al,10 je .yes16b cmp al,8 jne .no16b %endif .yes16b ; mov byte[newengen],0 ; mov byte[cfgnewgfx],0 ; jmp .skipno16b .no16b mov byte[newengen],1 mov byte[cfgnewgfx],1 .skipno16b mov byte[GUICBHold],0 call guiprevideo mov al,[cvidmode] mov [.prevvid],al mov al,[GUIcurrentvideocursloc] mov [cvidmode],al mov byte[ExitFromGUI],1 call initvideo cmp byte[videotroub],1 je .failed call GUISetPal mov al,[cvidmode] mov [cfgcvidmode],al call guipostvideo cmp dword[GUIkeydelay],0 je .failed2 mov dword[GUIkeydelay],0 ret .failed mov byte[videotroub],0 mov al,[.prevvid] mov [cvidmode],al mov [cfgcvidmode],al call initvideo call GUISetPal call guipostvideofail mov dword[GUIkeydelay],0 ret .failed2 mov byte[videotroub],0 mov al,[.prevvid] mov [cvidmode],al mov [cfgcvidmode],al call initvideo call GUISetPal mov dword[GUIkeydelay],0 ret .prevvid db 0 NEWSYM SwitchFullScreen pushad mov ecx,255*296 mov eax,[vidbufferofsb] .loop mov dword[eax],0FEFEFEFEh add eax,4 dec ecx jnz .loop xor eax,eax mov al,[cvidmode] cmp byte[GUIWFVID+eax],0 je .fullsc mov al,[PrevWinMode] mov [cvidmode],al mov [cfgcvidmode],al call initvideo popad ret .fullsc mov al,[PrevFSMode] mov [cvidmode],al mov [cfgcvidmode],al call initvideo popad ret GUIWindowMove: xor eax,eax mov al,[GUIwinptr] dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] mov eax,[GUImouseposx] sub eax,[GUIwinposx+ebx*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+ebx*4] cmp ebx,13 je near DisplayGUICheatSearchClick2 cmp ebx,7 je near DisplayGUICheatClick2 cmp ebx,5 je near DisplayGUIVideoClick2 cmp ebx,3 je near DisplayGUIInputClick2 cmp ebx,16 je near DisplayGUIComboClick2 jmp DisplayGUIConfirmClick2 GUIWinClicked: mov ecx,[GUImouseposx] sub ecx,[GUIwinposx+ebx*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+ebx*4] mov esi,ecx sub esi,[GUIwinsizex+ebx*4] add esi,10 cmp esi,-1 jle .noclose cmp esi,10 jge .noclose cmp edx,0 jle .noclose cmp edx,10 jge .noclose mov byte[GUIwinorder+eax],0 mov byte[GUIwinactiv+ebx],0 dec byte[GUIwinptr] ret .noclose cmp edx,10 jge .nomove mov byte[GUIHold],1 mov ax,[GUIwinposx+ebx*4] movsx eax,ax mov [GUIHoldxm],eax mov ax,[GUIwinposy+ebx*4] movsx eax,ax mov [GUIHoldym],eax xor eax,eax mov ax,[GUImouseposx] mov [GUIHoldx],eax mov ax,[GUImouseposy] mov [GUIHoldy],eax ret .nomove mov eax,[GUImouseposx] sub eax,[GUIwinposx+ebx*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+ebx*4] cmp ebx,1 je near DisplayGUIConfirmClick cmp ebx,2 je near DisplayGUIChoseSaveClick cmp ebx,3 je near DisplayGUIInputClick cmp ebx,4 je near DisplayGUIOptionClick cmp ebx,5 je near DisplayGUIVideoClick cmp ebx,6 je near DisplayGUISoundClick cmp ebx,7 je near DisplayGUICheatClick cmp ebx,8 je near DisplayNetOptnsClick cmp ebx,9 je near DisplayGameOptnsClick cmp ebx,10 je near DisplayGUIOptnsClick cmp ebx,11 je near DisplayGUIAboutClick cmp ebx,12 je near DisplayGUIResetClick cmp ebx,13 je near DisplayGUICheatSearchClick cmp ebx,14 je near DisplayGUIStatesClick cmp ebx,15 je near DisplayGUIMovieClick cmp ebx,16 je near DisplayGUIComboClick cmp ebx,17 je near DisplayGUIAddOnClick ret %macro GUIClickCButton 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 %%noclick %endmacro %macro GUIClickCButtonat 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 call guimustrestartmsg %%noclick %endmacro %macro GUIClickCButtonC 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 mov dword[GUIccombviewloc],0 mov dword[GUIccombcursloc],0 mov dword[GUIccomblcursloc],0 %%noclick %endmacro %macro GUIClickCButtonN 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick mov %3,%4 %%noclick %endmacro %macro GUIClickCButtonO 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick push eax xor %3,1 mov al,%3 mov [bgfixer],al pop eax %%noclick %endmacro %macro GUIClickCButtonM 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 mov byte[MultiTap],1 cmp byte[pl12s34],1 je .nomtap cmp byte[pl3contrl],0 jne .mtap cmp byte[pl4contrl],0 jne .mtap cmp byte[pl5contrl],0 jne .mtap .nomtap mov byte[MultiTap],0 .mtap %%noclick %endmacro %macro GUIClickCButtonID 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 call SetDevice %%noclick %endmacro %macro GUIClickCButton2 5 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,%5 mov al,%3 mov %4,al ret %%noclick %endmacro %macro GUIClickCButton3 5 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,%5 mov al,%3 mov %4,al call ClearScreen push eax push ecx mov eax,[vidbufferofsb] mov ecx,288*128 %%loop mov dword[eax],0 add eax,4 ; loop %%loop dec ecx jnz %%loop pop ecx pop eax ret %%noclick %endmacro %macro GUIClickCButton5 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick cmp %3,%4 jne %%set xor %3,%4 jmp %%clear %%set mov %3,%4 %%clear ret %%noclick %endmacro %macro GUIClickCButton6 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick cmp %3,%4 jne %%set xor %3,%4 jmp %%clear %%set mov %3,%4 push eax push ecx mov eax,[vidbufferofsb] mov ecx,288*128 %%loop mov dword[eax],0 add eax,4 ; loop %%loop dec ecx jnz %%loop pop ecx pop eax %%clear ret %%noclick %endmacro %macro GUIClickCButton4 5 cmp eax,%1+1 jl near %%noclick cmp edx,%2+3 jl near %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick cmp %3,%5 jne %%set xor %3,%5 jmp %%done %%set mov %3,%5 %%done mov al,%3 mov %4,al call ClearScreen %ifdef __MSDOS__ cmp byte[En2xSaI],0 jne %%nomodeq ; cmp byte[OSPort],2 ; jae %%nomodeq cmp byte[cvidmode],2 jne %%nomodeq jmp %%refresh %%nomodeq cmp byte[cvidmode],5 jne %%nomodex %%refresh mov byte[cbitmode],1 call initvideo2 mov byte[cbitmode],0 call GUISetPal %endif %%nomodex ret %%noclick %endmacro %macro GUIClickCButtonfr 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick mov byte[FPSOn],0 cmp %3,0 je %%zero mov %3,0 jmp %%notzero %%zero mov %3,2 %%notzero %%noclick %endmacro %macro GUIClickCButtonL 2 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor byte[showallext],1 xor byte[GUIshowallext],1 call GetLoadData ret %%noclick %endmacro %macro GUIClickCButtonW 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 %%noclick %ifdef __WIN32__ pushad call CheckPriority call CheckScreenSaver popad %endif %endmacro %macro GUIClickCButtonI 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 call Clear2xSaIBuffer %%noclick %endmacro %macro GUIClickCButtonAS 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 mov byte[firstsaveinc],1 %%noclick %endmacro %macro GUIClickCButtonT 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 mov %4,0 %%noclick %endmacro %macro GUIClickCButtonMMX 3 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick xor %3,1 call MMXCheck %%noclick %endmacro %macro GUIClickCButton5MMXC 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+3 jl %%noclick cmp eax,%1+6 jg %%noclick cmp edx,%2+8 jg %%noclick cmp byte[MMXSupport],0 je %%clear cmp %3,%4 jne %%set xor %3,%4 jmp %%clear %%set mov %3,%4 %%clear ret %%noclick %endmacro %macro GUISlidebarPostImpl 13 ; x1,y1,x2,y2,upjump,downjump,holdpos,scsize,view,cur,listsize cmp dword[%11],0 je near %%nolower cmp dword[GUIdispmode],1 je near %%slidebar cmp eax,%1 jl near %%noupper cmp edx,%2-7 jl near %%noupper cmp eax,%3 jg near %%noupper cmp edx,%2-1 jg near %%noupper mov byte[%12],%13 mov byte[GUICHold],%7 jmp %5 %%noupper cmp eax,%1 jl near %%nolower cmp edx,%4+1 jl near %%nolower cmp eax,%3 jg near %%nolower cmp edx,%4+7 jg near %%nolower mov byte[%12],%13 mov byte[GUICHold],%7+1 jmp %6 %%slidebar cmp eax,%1 jl near %%nolower cmp edx,%2 jl near %%nolower cmp eax,%3 jg near %%nolower cmp edx,%4 jg near %%nolower mov byte[%12],%13 ; displacement = (GUIdispmode * pixeldisp. / (listsize-scsize)) mov eax,[%11] sub eax,%8 mov ebx,edx sub ebx,[GUIlastypos] imul ebx mov ebx,[GUIlastdispval] or ebx,ebx jz near %%zerodiv test ebx,80000000h jnz near %%zerodiv idiv ebx mov ebx,[GUIlastvpos] add ebx,eax mov [%9],ebx mov ebx,[GUIlastcpos] add ebx,eax mov [%10],ebx test dword[%9],8000000h jz %%noneg mov dword[%9],0 %%noneg test dword[%10],8000000h jz %%noneg2 mov dword[%10],0 %%noneg2 mov eax,[%11] dec eax cmp [%10],eax jb %%notover mov [%10],eax %%notover sub eax,%8-1 cmp [%9],eax jb %%notover2 mov [%9],eax %%notover2 %%zerodiv ret %%nolower %endmacro GUIlastdispval dd 0 GUIdispmode dd 0 GUIlastypos dd 0 GUIlastcpos dd 0 GUIlastvpos dd 0 %macro GUISlidebarImpl 10 ; x1,y1,x2,y2,GUI?StA,ScrnSize,ViewLoc,CursLoc,Entries,win# mov dword[GUIdispmode],0 cmp eax,%1 jl near %%nobar cmp edx,%2 jl near %%nobar cmp eax,%3 jg near %%nobar cmp edx,%4 jg near %%nobar sub edx,%2 cmp [%5+4],edx ja near %%above cmp [%5+8],edx jb near %%below add edx,%2 mov [GUIlastypos],edx mov dword[GUIdispmode],1 mov eax,[GUIwinposy+%10*4] add eax,%2 mov [GUIHoldYlim],eax mov eax,[GUIwinposy+%10*4] add eax,%4 mov [GUIHoldYlimR],eax mov eax,[GUIwinposx+%10*4] add eax,%1 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+%10*4] add eax,%3 mov [GUIHoldXlimR],eax mov eax,[%5] mov [GUIlastdispval],eax mov eax,dword[%8] mov [GUIlastcpos],eax mov eax,dword[%7] mov [GUIlastvpos],eax mov byte[GUIHold],3 ret %%above sub dword[%7],%6 sub dword[%8],%6 test dword[%7],8000000h jz %%noneg mov dword[%7],0 mov dword[%8],0 %%noneg ret %%below add dword[%7],%6 add dword[%8],%6 mov ebx,[%9] dec ebx cmp [%8],ebx jb %%notoverflow mov [%8],ebx sub ebx,%6-1 mov [%7],ebx %%notoverflow mov ebx,[%9] sub ebx,%6 cmp [%7],ebx jb %%notoverflow2 mov [%7],ebx %%notoverflow2 ret %%nobar ; upper arrow cmp eax,%1 jl near %%noupper cmp edx,%2-7 jl near %%noupper cmp eax,%3 jg near %%noupper cmp edx,%2-1 jg near %%noupper mov eax,[GUIwinposy+%10*4] add eax,%2-7 mov [GUIHoldYlim],eax mov eax,[GUIwinposy+%10*4] add eax,%2-1 mov [GUIHoldYlimR],eax mov eax,[GUIwinposx+%10*4] add eax,%1 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+%10*4] add eax,%3 mov [GUIHoldXlimR],eax mov byte[GUIHold],3 ret %%noupper ; lower arrow cmp eax,%1 jl near %%nolower cmp edx,%4+1 jl near %%nolower cmp eax,%3 jg near %%nolower cmp edx,%4+7 jg near %%nolower mov eax,[GUIwinposy+%10*4] add eax,%4+1 mov [GUIHoldYlim],eax mov eax,[GUIwinposy+%10*4] add eax,%4+7 mov [GUIHoldYlimR],eax mov eax,[GUIwinposx+%10*4] add eax,%1 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+%10*4] add eax,%3 mov [GUIHoldXlimR],eax mov byte[GUIHold],3 ret %%nolower %endmacro %macro GUIPostWinBoxMove 11 ;x1,y1,x2,y2,view,curs,num,.scru,.scrd,jumpto,sizeofscreen cmp eax,%1 jl near %%noload cmp eax,%3 jg near %%noload cmp edx,%2 je near %%scrollup cmp edx,%4 jne near %%noload ; Scroll Down cmp dword[%7],%11 jbe %9 mov ebx,[%5] add ebx,%11-1 mov [%6],ebx %9 cmp dword[GUIScrolTim1],0 jne near %%donescrol mov ebx,[%7] dec ebx cmp ebx,[%6] jbe %%donescrolldown inc dword[%6] cmp dword[%7],%11 jbe near %%donescrol inc dword[%5] mov ebx,[%7] sub ebx,%11 cmp ebx,[%5] ja near %%donescrolldown mov [%5],ebx jmp %%donescrolldown %%scrollup mov ebx,[%5] mov [%6],ebx %8 cmp dword[GUIScrolTim1],0 jne near %%donescrol cmp dword[%6],0 je %%donescrolldown dec dword[%6] cmp dword[%5],0 je %%donescrolldown dec dword[%5] %%donescrolldown mov dword[GUIScrolTim1],1 cmp dword[GUIScrolTim2],4 jb %%noscrol1 inc dword[GUIScrolTim1] %%noscrol1 cmp dword[GUIScrolTim2],0 je %%noscrol2 inc dword[GUIScrolTim1] dec dword[GUIScrolTim2] %%noscrol2 %%donescrol jmp %10 %%noload %endmacro %macro GUIPHoldbutton 5 cmp eax,%1 jl near %%nohold cmp edx,%2 jl near %%nohold cmp eax,%3 jg near %%nohold cmp edx,%4 jg near %%nohold mov dword[GUIHoldXlimL],%1 mov dword[GUIHoldXlimR],%3 mov dword[GUIHoldYlim],%2 mov dword[GUIHoldYlimR],%4 mov byte[GUICBHold2],%5 mov byte[GUIHold],4 %%nohold %endmacro %macro GUIPHoldbutton2 8 cmp eax,%1 jl near %%nohold cmp edx,%2 jl near %%nohold cmp eax,%3 jg near %%nohold cmp edx,%4 jg near %%nohold cmp byte[GUIHold],0 jne %%nohold mov dword[GUIHoldXlimL],%1 mov dword[GUIHoldXlimR],%3 mov dword[GUIHoldYlim],%2 mov dword[GUIHoldYlimR],%4 mov byte[GUICBHold2],%5 mov byte[GUIHold],4 cmp %6,%8 je %%nohold add %6,%7 %%nohold %endmacro %macro GUITextBoxInput 6 cmp eax,%1 jl %%noclick cmp edx,%2 jl %%noclick cmp eax,%3 jg %%noclick cmp edx,%4 jg %%noclick mov dword[GUIEditString],%5 mov dword[GUIEditStringmLen],%6 mov dword[GUIEditStringLTxt],0 mov dword[GUIEditStringcWin],1 %%noclick %endmacro %macro GUITextBoxInputB 5 cmp eax,%1 jl %%noclick cmp edx,%2 jl %%noclick cmp eax,%3 jg %%noclick cmp edx,%4 jg %%noclick mov byte[GUINetTextm2],%5 %%noclick %endmacro %macro GUIPButtonHole 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+1 jl %%noclick cmp eax,%1+7 jg %%noclick cmp edx,%2+7 jg %%noclick mov %3,%4 %%noclick %endmacro %macro GUIPButtonHole2 6 cmp eax,%1+1 jl %%noclick cmp edx,%2+1 jl %%noclick cmp eax,%1+7 jg %%noclick cmp edx,%2+7 jg %%noclick mov %3,%4 mov %5,%6 %%noclick %endmacro %macro GUIPButtonHoleLoad 4 cmp eax,%1+1 jl %%noclick cmp edx,%2+1 jl %%noclick cmp eax,%1+7 jg %%noclick cmp edx,%2+7 jg %%noclick mov %3,%4 call GetLoadData ret %%noclick %endmacro %macro GUIWinControl 13 ;x,y,x2,y2,currentwin,vpos,#entries,starty,y/entry,cpos,winval,win#,dclicktick# cmp eax,%1 jl near %%noload cmp edx,%2 jl near %%noload cmp eax,%3 jg near %%noload cmp edx,%4 jg near %%noload cmp dword[%7],0 je near %%noload mov dword[%5],%11 mov eax,edx sub eax,%8 xor edx,edx mov ebx,%9 div ebx add eax,[%6] mov ebx,[%7] dec ebx cmp eax,ebx jg %%nomod mov [%10],eax %%nomod cmp byte[GUIHold],0 jne %%held cmp dword[GUIDClickTL],0 je %%noprevhold cmp byte[GUIDClCWin],%11 jne %%noprevhold cmp [GUIDClCEntry],eax jne %%noprevhold mov dword[GUIDClickTL],0 mov eax,%12 cmp eax,1 jne %%cheat call GUILoadData ret %%cheat call CheatCodeToggle ret %%noprevhold mov dword[GUIDClickTL],%13 mov byte[GUIDClCWin],%11 mov [GUIDClCEntry],eax %%held mov eax,[GUIwinposy+%12*4] add eax,%2-1 mov [GUIHoldYlim],eax mov eax,[GUIwinposy+%12*4] add eax,%4+1 mov [GUIHoldYlimR],eax mov eax,[GUIwinposx+%12*4] add eax,%1 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+%12*4] add eax,%3 mov [GUIHoldXlimR],eax mov byte[GUIHold],3 ret %%noload %endmacro %macro GUIWinControl2 13 ;Key Combination Editor Exclusive cmp eax,%1 jl near %%noload cmp edx,%2 jl near %%noload cmp eax,%3 jg near %%noload cmp edx,%4 jg near %%noload cmp dword[%7],0 je near %%noload mov dword[GUIccomblcursloc],0FFFFFFFFh mov dword[%5],%11 mov eax,edx sub eax,%8 xor edx,edx mov ebx,%9 div ebx add eax,[%6] mov ebx,[%7] dec ebx cmp eax,ebx jg %%nomod mov [%10],eax %%nomod cmp byte[GUIHold],0 jne %%held cmp dword[GUIDClickTL],0 je %%noprevhold cmp byte[GUIDClCWin],%11 jne %%noprevhold cmp [GUIDClCEntry],eax jne %%noprevhold mov dword[GUIDClickTL],0 mov eax,%12 cmp eax,1 jne %%cheat call GUILoadData ret %%cheat call CheatCodeToggle ret %%noprevhold mov dword[GUIDClickTL],%13 mov byte[GUIDClCWin],%11 mov [GUIDClCEntry],eax %%held mov eax,[GUIwinposy+%12*4] add eax,%2-1 mov [GUIHoldYlim],eax mov eax,[GUIwinposy+%12*4] add eax,%4+1 mov [GUIHoldYlimR],eax mov eax,[GUIwinposx+%12*4] add eax,%1 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+%12*4] add eax,%3 mov [GUIHoldXlimR],eax mov byte[GUIHold],3 ret %%noload %endmacro ; Mouseimplementation DisplayGUIConfirmClick2: cmp dword[GUIfileentries],1 jbe near .noload2 GUISlidebarPostImpl 146,33,153,33+93,.scrollupsl,.scrolldownsl,1,15,GUIcurrentviewloc,GUIcurrentcursloc,GUIfileentries,GUIcurrentfilewin,0 GUIPostWinBoxMove 5,26,144,27+15*7,GUIcurrentviewloc,GUIcurrentcursloc,GUIfileentries,.scrollupsl,.scrolldownsl,DisplayGUIConfirmClick.skipscrol,15 .noload2 cmp dword[GUIdirentries],1 jbe near .noload3 GUISlidebarPostImpl 230,33,237,33+93,.scrollupsld,.scrolldownsld,3,15,GUIcurrentdirviewloc,GUIcurrentdircursloc,GUIdirentries,GUIcurrentfilewin,1 GUIPostWinBoxMove 160,26,228,27+15*7,GUIcurrentdirviewloc,GUIcurrentdircursloc,GUIdirentries,.scrollupsld,.scrolldownsld,DisplayGUIConfirmClick.skipscrol,15 .noload3 DisplayGUIConfirmClick: ;DrawSlideBarWin 1,133,43,[GUIcurrentviewloc],[GUIfileentries],15,94,[GUILStA] ; offset 0 = (ysize-(yend-ystart+1)), offset 1 = starty, offset 2 = endy ; SlideBar Implementation GUISlidebarImpl 146,33,153,33+93,GUILStA,15,GUIcurrentviewloc,GUIcurrentcursloc,GUIfileentries,1 GUISlidebarImpl 230,33,237,33+93,GUILStB,15,GUIcurrentdirviewloc,GUIcurrentdircursloc,GUIdirentries,1 mov dword[GUIScrolTim1],0 mov dword[GUIScrolTim2],6 .skipscrol GUIClickCButtonL 10,187 GUIWinControl 5,27,144,26+15*7,GUIcurrentfilewin,GUIcurrentviewloc,GUIfileentries,27,7,GUIcurrentcursloc,0,1,30 GUIWinControl 160,27,228,26+15*7,GUIcurrentfilewin,GUIcurrentdirviewloc,GUIdirentries,27,7,GUIcurrentdircursloc,1,1,30 GUIPHoldbutton 186,165,228,176,1 GUIPButtonHoleLoad 9,163,byte[GUIloadfntype],0 GUIPButtonHoleLoad 9,171,byte[GUIloadfntype],1 GUIPButtonHoleLoad 9,179,byte[GUIloadfntype],2 GUIClickCButton5 144,177,byte[ForceROMTiming],1 GUIClickCButton5 144,187,byte[ForceROMTiming],2 GUIClickCButton5 184,177,byte[ForceHiLoROM],1 GUIClickCButton5 184,187,byte[ForceHiLoROM],2 ret DisplayGUIChoseSaveClick: GUIPButtonHole 10,28,byte[GUIChoseSaveText2],'t' GUIPButtonHole 30,28,byte[GUIChoseSaveText2],'1' GUIPButtonHole 50,28,byte[GUIChoseSaveText2],'2' GUIPButtonHole 70,28,byte[GUIChoseSaveText2],'3' GUIPButtonHole 90,28,byte[GUIChoseSaveText2],'4' GUIPButtonHole 10,43,byte[GUIChoseSaveText2],'5' GUIPButtonHole 30,43,byte[GUIChoseSaveText2],'6' GUIPButtonHole 50,43,byte[GUIChoseSaveText2],'7' GUIPButtonHole 70,43,byte[GUIChoseSaveText2],'8' GUIPButtonHole 90,43,byte[GUIChoseSaveText2],'9' mov ebx,[statefileloc] mov al,[GUIChoseSaveText2] mov [fnamest+ebx],al ret DisplayGUIMovieClick: cmp byte[MovieRecordWinVal],0 je near .displayboxa GUIPHoldbutton 17,55,59,66,19 GUIPHoldbutton 70,55,112,66,20 ret .displayboxa GUIPHoldbutton 7,17,49,28,16 GUIPHoldbutton 7,33,49,44,17 GUIPHoldbutton 7,49,49,60,18 GUIPButtonHole 60,25,byte[CMovieExt],'v' GUIPButtonHole 80,25,byte[CMovieExt],'1' GUIPButtonHole 100,25,byte[CMovieExt],'2' GUIPButtonHole 120,25,byte[CMovieExt],'3' GUIPButtonHole 60,40,byte[CMovieExt],'4' GUIPButtonHole 80,40,byte[CMovieExt],'5' GUIPButtonHole 100,40,byte[CMovieExt],'6' GUIPButtonHole 120,40,byte[CMovieExt],'7' GUIPButtonHole 60,55,byte[CMovieExt],'8' GUIPButtonHole 80,55,byte[CMovieExt],'9' ret %macro DGOptnsProcBox 3 cmp eax,%1 jl %%skip cmp edx,%2 jl %%skip cmp eax,%1+19 jg %%skip cmp edx,%2+6 jg %%skip push edi call guipresstest pop edi cmp ebx,1 je %%cancelkey cmp ebx,3Bh je %%cancelkey mov %3,ebx ; cmp byte[OSPort],3 ; jne %%notwin32 %ifndef __MSDOS__ cmp dword[keycontrolval],0 je %%notwin32 push ebx mov ebx,[keycontrolval] mov byte[ebx],1 pop ebx %endif %%notwin32 ret %%cancelkey xor ebx,ebx mov %3,ebx ret %%skip %endmacro %macro DGOptnsProcBoxc 5 cmp eax,%1 jl %%skip cmp edx,%2 jl %%skip cmp eax,%3 jg %%skip cmp edx,%4 jg %%skip push edi call guipresstest pop edi cmp ebx,1 je %%cancelkey cmp ebx,3Bh je %%cancelkey mov %5,ebx ret %%cancelkey cmp ebx,1 jne %%noesc mov byte[pressed+1],2 %%noesc xor ebx,ebx mov %5,ebx ret %%skip %endmacro %macro DGOptnsProcBoxb 3 cmp eax,%1 jl near %%skip cmp edx,%2 jl near %%skip cmp eax,%1+19 jg near %%skip cmp edx,%2+6 jg near %%skip push edi call guipresstest pop edi cmp ebx,1 je %%cancelkey cmp ebx,3Bh je %%cancelkey mov %3,ebx jmp %%donekey %%cancelkey cmp ebx,1 jne %%noesc mov byte[pressed+1],2 %%noesc xor ebx,ebx mov %3,ebx %%donekey xor ecx,ecx %%joysloop cmp dword[pl1ULk+ecx*4],80h jbe %%nojoystick mov dword[pl1ULk+ecx*4],0 %%nojoystick inc ecx cmp ecx,16 jne %%joysloop ret %%skip %endmacro DisplayGUIInputClick2: push eax mov eax,[NumInputDevices] mov dword[GUINumValue],eax pop eax GUISlidebarPostImpl 109,42,116,69,.scrollup,.scrolldown,9,5,GUIcurrentinputviewloc,GUIcurrentinputcursloc,GUINumValue,GUIBlankVar,1 GUIPostWinBoxMove 5,35,107,35+5*8,GUIcurrentinputviewloc,GUIcurrentinputcursloc,GUINumValue,.scrollup,.scrolldown,DisplayGUIInputClick.skipscrol,5 DisplayGUIInputClick: ; SlideBar Implementation push eax mov eax,[NumInputDevices] mov dword[GUINumValue],eax pop eax GUISlidebarImpl 109,42,116,69,GUIIStA,5,GUIcurrentinputviewloc,GUIcurrentinputcursloc,GUINumValue,3 .skipscrol ;x,y,x2,y2,currentwin,vpos,#entries,starty,y/entry,cpos,winval,win#,dclicktick# GUIWinControl 5,36,107,34+5*8,GUIBlankVar,GUIcurrentinputviewloc,GUINumValue,35,8,GUIcurrentinputcursloc,4,3,0 GUIPHoldbutton 125,34,155,45,14 ; cmp byte[OSPort],3 ; je near .win32 %ifdef __MSDOS__ GUIPHoldbutton 125,50,185,61,15 %endif ;.win32 GUIPHoldbutton 125,66,185,77,40 mov edi,pl1selk mov dword[keycontrolval],pl1contrl cmp byte[cplayernum],1 jne .nopl2 mov edi,pl2selk mov dword[keycontrolval],pl2contrl .nopl2 cmp byte[cplayernum],2 jne .nopl3 mov edi,pl3selk mov dword[keycontrolval],pl3contrl .nopl3 cmp byte[cplayernum],3 jne .nopl4 mov edi,pl4selk mov dword[keycontrolval],pl4contrl .nopl4 cmp byte[cplayernum],4 jne .nopl5 mov edi,pl5selk mov dword[keycontrolval],pl5contrl .nopl5 DGOptnsProcBox 45,150,[edi] DGOptnsProcBox 45,140,[edi+4] DGOptnsProcBox 45,100,[edi+8] DGOptnsProcBox 45,110,[edi+12] DGOptnsProcBox 45,120,[edi+16] DGOptnsProcBox 45,130,[edi+20] DGOptnsProcBox 85,120,[edi+24] DGOptnsProcBox 85,100,[edi+28] DGOptnsProcBox 85,140,[edi+32] DGOptnsProcBox 85,130,[edi+36] DGOptnsProcBox 85,110,[edi+40] DGOptnsProcBox 85,150,[edi+44] mov edi,pl1Atk cmp byte[cplayernum],1 jne .nopl2t mov edi,pl2Atk .nopl2t cmp byte[cplayernum],2 jne .nopl3t mov edi,pl3Atk .nopl3t cmp byte[cplayernum],3 jne .nopl4t mov edi,pl4Atk .nopl4t cmp byte[cplayernum],4 jne .nopl5t mov edi,pl5Atk .nopl5t DGOptnsProcBox 165,100,[edi] ; A Turbo DGOptnsProcBox 165,110,[edi+4] ; B Turbo DGOptnsProcBox 125,100,[edi+8] ; X Turbo DGOptnsProcBox 125,110,[edi+12] ; Y Turbo mov edi,pl1Ltk cmp byte[cplayernum],1 jne .nopl2tl mov edi,pl2Ltk .nopl2tl cmp byte[cplayernum],2 jne .nopl3tl mov edi,pl3Ltk .nopl3tl cmp byte[cplayernum],3 jne .nopl4tl mov edi,pl4Ltk .nopl4tl cmp byte[cplayernum],4 jne .nopl5tl mov edi,pl5Ltk .nopl5tl DGOptnsProcBox 125,120,[edi] ; L Turbo DGOptnsProcBox 165,120,[edi+4] ; R Turbo mov edi,pl1ULk cmp byte[cplayernum],1 jne .nopl2tb mov edi,pl2ULk .nopl2tb cmp byte[cplayernum],2 jne .nopl3tb mov edi,pl3ULk .nopl3tb cmp byte[cplayernum],3 jne .nopl4tb mov edi,pl4ULk .nopl4tb cmp byte[cplayernum],4 jne .nopl5tb mov edi,pl5ULk .nopl5tb DGOptnsProcBoxb 165,140,[edi] DGOptnsProcBoxb 165,150,[edi+4] DGOptnsProcBoxb 125,140,[edi+8] DGOptnsProcBoxb 125,150,[edi+12] %ifdef __MSDOS__ xor ebx,ebx mov bl,[cplayernum] GUIClickCButtonID 5,162,byte[pl1p209+ebx] %endif ret DisplayGUIOptionClick: GUIClickCButtonfr 11,26,byte[frameskip] xor ebx,ebx mov bl,[cvidmode] cmp byte[GUINGVID+ebx],1 jne near .invalidng GUIClickCButton2 11,36,byte[newengen],byte[cfgnewgfx],1 .invalidng GUIClickCButtonAS 11,46,byte[AutoIncSaveSlot] GUIClickCButtonMMX 11,56,byte[MMXSupport] GUIClickCButtonM 11,66,byte[pl12s34] %ifdef __MSDOS__ GUIClickCButton 11,76,byte[SidewinderFix] %endif %ifdef __WIN32__ GUIClickCButtonW 11,76,byte[HighPriority] %endif GUIClickCButton 11,86,byte[FPSAtStart] GUIClickCButton 11,96,byte[Turbo30hz] GUIClickCButton 11,106,byte[TimerEnable] GUIClickCButton 11,116,byte[FastFwdToggle] GUIClickCButton 11,126,byte[SRAMSave5Sec] GUIClickCButtonO 11,136,byte[OldGfxMode2] GUIClickCButton 11,146,byte[LatestSave] GUIClickCButton 11,156,byte[AutoState] GUIClickCButton 11,166,byte[DontSavePath] %ifdef __WIN32__ GUIClickCButtonW 11,176,byte[DisableScreenSaver] GUIClickCButtonat 11,186,byte[AlternateTimer] %endif ; Frameskip = 0 cmp byte[frameskip],0 je near .autopress GUIPHoldbutton2 97,12,105,22,12,byte[frameskip],1,10 GUIPHoldbutton2 108,12,116,22,13,byte[frameskip],-1,1 ret .autopress GUIPHoldbutton2 118,12,126,22,12,byte[maxskip],1,9 GUIPHoldbutton2 129,12,137,22,13,byte[maxskip],-1,0 ret DisplayGUIVideoClick2: push eax mov eax,[NumVideoModes] mov dword[GUINumValue],eax pop eax GUISlidebarPostImpl 117,33,124,62,.scrollup,.scrolldown,5,5,GUIcurrentvideoviewloc,GUIcurrentvideocursloc,GUINumValue,GUIBlankVar,1 GUIPostWinBoxMove 5,27,115,27+5*8,GUIcurrentvideoviewloc,GUIcurrentvideocursloc,GUINumValue,.scrollup,.scrolldown,DisplayGUIVideoClick.skipscrol,5 DisplayGUIVideoClick: ; SlideBar Implementation push eax mov eax,[NumVideoModes] mov dword[GUINumValue],eax pop eax GUISlidebarImpl 117,33,124,62,GUIVStA,5,GUIcurrentvideoviewloc,GUIcurrentvideocursloc,GUINumValue,5 .skipscrol GUIWinControl 5,28,115,26+5*8,GUIBlankVar,GUIcurrentvideoviewloc,GUINumValue,27,8,GUIcurrentvideocursloc,2,5,0 xor ebx,ebx mov bl,[cvidmode] cmp byte[GUISLVID+ebx],0 GUIClickCButton4 21,114,byte[scanlines],byte[cfgscanline],1 je near .nocheckboxb .nocheckboxb xor ebx,ebx mov bl,[cvidmode] cmp byte[GUITBVID+ebx],0 je .nocheckboxttb GUIClickCButtonT 11,163,byte[Triplebufen],byte[vsyncon] .nocheckboxttb GUIClickCButton 11,183,byte[GrayscaleMode] %ifdef __WIN32__ GUIClickCButtonT 115,183,byte[vsyncon],byte[TripleBufferWin] %endif %ifdef __MSDOS__ GUIClickCButtonT 115,183,byte[vsyncon],byte[Triplebufen] %endif xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIM7VID+ebx],0 je .nocheckboxtm7 GUIClickCButton5 11,173,byte[Mode7HiRes16b],1 .nocheckboxtm7 xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIHSVID+ebx],0 je near .nohsline GUIClickCButton4 61,114,byte[scanlines],byte[cfgscanline],3 GUIClickCButton4 101,114,byte[scanlines],byte[cfgscanline],2 .nohsline %ifdef __WIN32__ xor ebx,ebx mov bl,[cvidmode] cmp byte[GUITBWVID+ebx],0 je near .notriplebufferwin GUIClickCButtonT 11,123,byte[TripleBufferWin],byte[vsyncon] .notriplebufferwin %endif xor ebx,ebx mov bl,[cvidmode] cmp byte[GUI2xVID+ebx],0 je near .no2xSaI GUIClickCButton6 11,133,byte[En2xSaI],1 GUIClickCButton6 11,143,byte[En2xSaI],2 GUIClickCButton6 11,153,byte[En2xSaI],3 .no2xSaI xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIIEVID+ebx],0 je .nocheckbox1b GUIClickCButton3 11,78,byte[antienab],byte[cfginterp],1 .nocheckbox1b xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIBIFIL+ebx],0 je .nocheckbox1bf GUIClickCButton 11,163,byte[BilinearFilter] .nocheckbox1bf xor ebx,ebx mov bl,[cvidmode] cmp byte[GUIFSVID+ebx],0 je .nocheckbox2b GUIClickCButton3 11,88,byte[ScreenScale],byte[GUIScreenScale],1 .nocheckbox2b xor ebx,ebx mov bl,[cvidmode] cmp byte[GUISSVID+ebx],0 je .nocheckbox3b GUIClickCButton3 11,98,byte[smallscreenon],byte[GUIsmallscreenon],1 .nocheckbox3b xor ebx,ebx mov bl,[cvidmode] cmp byte[GUII2VID+ebx],0 je .nocheckboxi2 GUIClickCButton3 11,163,byte[antienab],byte[cfginterp],1 .nocheckboxi2 GUIPHoldbutton 128,60,164,71,4 mov al,[vsyncon] mov byte[cfgvsync],al xor al,al ret GUINumValue dd 0 GUIBlankVar dd 0 DisplayGUISoundClick: mov eax,[GUImouseposx] sub eax,[GUIwinposx+6*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+6*4] GUIClickCButton 11,21,byte[cfgsoundon] %ifdef __MSDOS__ GUIClickCButton 102,21,byte[cfgforce8b] %endif GUIClickCButton 11,30,byte[cfgStereoSound] GUIClickCButton 11,39,byte[RaisePitch] GUIClickCButton 11,101,byte[SoundNoiseDis] GUIClickCButton 11,111,byte[RevStereo] ; cmp byte[OSPort],3 ; je near .win32sound GUIClickCButton 11,121,byte[Surround] ;.win32sound GUIClickCButton 11,131,byte[SoundBufEn] GUIClickCButton 11,141,byte[SPCDisable] GUIClickCButton5 11,163,byte[SoundInterpType],1 GUIClickCButton5 11,173,byte[SoundInterpType],2 %ifndef __MSDOS__ GUIClickCButton5MMXC 11,183,byte[SoundInterpType],3 %endif GUIClickCButton5 111,163,byte[LowPassFilterType],1 GUIClickCButton5 111,173,byte[LowPassFilterType],2 %ifndef __MSDOS__ GUIClickCButton5MMXC 111,183,byte[LowPassFilterType],3 %endif cmp eax,15 jl near .nosrate cmp edx,61 jl near .nosrate cmp eax,69 jg near .nosrate cmp edx,69 jg near .nosrate xor eax,eax mov al,[cfgSoundQuality] mov al,[sampratenext+eax] mov [cfgSoundQuality],al .nosrate cmp eax,15 jl near .nomovebar cmp eax,15+100 jg near .nomovebar cmp edx,89 jl near .nomovebar cmp edx,93 jg near .nomovebar sub eax,15 mov [MusicRelVol],al mov [cfgvolume],al mov byte[GUIHold],5 mov eax,[GUIwinposy+6*4] add eax,91 mov [GUIHoldYlim],eax xor eax,eax xor edx,edx mov al,[MusicRelVol] shl eax,7 mov ebx,100 div ebx cmp al,127 jb .noof mov al,127 .noof mov [MusicVol],al mov al,[DSPMem+0Ch] call WDSPReg0C mov al,[DSPMem+1Ch] call WDSPReg1C mov eax,[GUIwinposx+6*4] add eax,15 mov [GUIHoldXlimL],eax add eax,100 mov [GUIHoldXlimR],eax .nomovebar ret sampratenext db 1,4,5,6,2,3,0,0,0,0 %macro GUIBoxVar 6 cmp eax,%1 jl %%nope cmp edx,%2 jl %%nope cmp eax,%3 jg %%nope cmp edx,%4 jg %%nope mov dword[%5],%6 %%nope %endmacro DisplayGUICheatClick2: GUISlidebarPostImpl 231,28,238,100,.scrollup,.scrolldown,7,12,GUIcurrentcheatviewloc,GUIcurrentcheatcursloc,NumCheats,GUIBlankVar,1 GUIPostWinBoxMove 5,22,229,22+12*7,GUIcurrentcheatviewloc,GUIcurrentcheatcursloc,NumCheats,.scrollup,.scrolldown,DisplayGUICheatClick.skipscrol,12 DisplayGUICheatClick: GUIBoxVar 5,20,181,110,GUIcurrentcheatwin,0 GUIBoxVar 82,129,173,136,GUIcurrentcheatwin,1 GUIBoxVar 82,140,196,147,GUIcurrentcheatwin,2 ; SlideBar Implementation GUISlidebarImpl 231,28,238,100,GUICStA,12,GUIcurrentcheatviewloc,GUIcurrentcheatcursloc,NumCheats,7 .skipscrol cmp byte[GUIcurrentcheatwin],0 jne near .nowin GUIWinControl 5,23,229,21+12*7,GUIBlankVar,GUIcurrentcheatviewloc,NumCheats,22,7,GUIcurrentcheatcursloc,3,7,30 .nowin GUIPHoldbutton 5,113,47,124,5 GUIPHoldbutton 52,113,94,124,6 GUIPHoldbutton 99,113,141,124,7 GUIPHoldbutton 146,113,188,124,8 GUIPHoldbutton 212,134,236,145,9 GUIPHoldbutton 193,113,235,124,33 GUIClickCButton5 11,186,byte[AutoLoadCht],1 ret DisplayNetOptnsClick: cmp byte[CNetType],1 jne near .nomodem GUIPHoldbutton 5,15,89,26,21 GUIPHoldbutton 5,30,89,41,22 GUIPHoldbutton 5,45,89,56,23 GUIPHoldbutton 5,60,89,71,24 .nomodem cmp byte[CNetType],2 jne near .nomodemc GUIPButtonHole2 9,25,byte[ComNum],1,byte[ComIRQ],4 GUIPButtonHole2 9,35,byte[ComNum],2,byte[ComIRQ],3 GUIPButtonHole2 9,45,byte[ComNum],3,byte[ComIRQ],4 GUIPButtonHole2 9,55,byte[ComNum],4,byte[ComIRQ],3 GUIPButtonHole 94,25,byte[BaudRate],0 GUIPButtonHole 94,35,byte[BaudRate],1 GUIPButtonHole 94,45,byte[BaudRate],2 GUIPButtonHole 94,55,byte[BaudRate],3 GUIPButtonHole 94,65,byte[BaudRate],4 GUIPButtonHole 94,75,byte[BaudRate],5 GUIPButtonHole 94,85,byte[BaudRate],6 GUIPButtonHole 9,85,byte[GUIDialSt+3],'T' GUIPButtonHole 9,95,byte[GUIDialSt+3],'P' GUIPHoldbutton2 55,69,63,79,25,byte[ComIRQ],1,15 GUIPHoldbutton2 66,69,74,79,26,byte[ComIRQ],-1,2 GUITextBoxInput 21,125,175,133,GUIInitSt1,24 GUITextBoxInput 21,136,175,144,GUIInitSt2,24 GUIClickCButton 12,147,byte[FossilUse] .nomodemc cmp byte[CNetType],3 jne near .nomodemd GUIPHoldbutton 141,38,175,49,28 .nomodemd cmp byte[CNetType],4 jne near .notcpip cmp byte[NetPlayNoMore],1 je near .notcpip GUIPHoldbutton 5,35,129,46,25 GUIPHoldbutton 5,70,129,81,26 GUITextBoxInputB 55,13,95,21,1 GUITextBoxInputB 26,58,191,66,0 GUITextBoxInputB 55,23,119,31,2 GUIClickCButton 5,93,byte[UDPConfig] .notcpip cmp byte[CNetType],10 je .init cmp byte[CNetType],11 je .init cmp byte[CNetType],15 je .init cmp byte[CNetType],12 jne near .noinit .init GUIPHoldbutton 120,135,181,146,27 .noinit cmp byte[CNetType],7 jne near .noipx GUIPHoldbutton 53,48,87,59,34 .noipx cmp byte[CNetType],20 jne near .nochat GUIPHoldbutton 111,169,181,180,27 GUIClickCButtonN 7,135,byte[RemoteCommand],3 GUIClickCButtonN 32,135,byte[RemoteCommand],4 GUIClickCButtonN 57,135,byte[RemoteCommand],5 GUIClickCButtonN 7,145,byte[RemoteCommand],6 GUIClickCButtonN 32,145,byte[RemoteCommand],7 GUIClickCButtonN 7,175,byte[RemoteCommand],8 GUIClickCButtonN 111,135,byte[RemoteCommand],50 GUIClickCButtonN 111,145,byte[RemoteCommand],41 GUIClickCButtonN 111,155,byte[RemoteCommand],42 GUIPHoldbutton2 79,156,87,166,29,byte[Latencytochange],1,19 GUIPHoldbutton2 90,156,98,166,30,byte[Latencytochange],-1,1 ; DrawSlideBarWin 8,181,15,[GUIcurrentvideoviewloc],[TViewLoc],12,97,GUINCStA ; GUISlidebarImpl 181,15,188,112,GUINCStA,12,GUIcurrentcheatviewloc,TViewCLoc,TViewLoc,12 mov al,[Latency] cmp byte[Latencytochange],al je .nochat mov byte[RemoteCommand],20 .nochat cmp byte[CNetType],22 je .yesstate cmp byte[CNetType],21 jne near .nostate .yesstate GUIPHoldbutton 73,48,127,59,64 .nostate ret guipresstest: xor ebx,ebx mov ecx,256+128+64 .a mov byte[pressed+ebx],0 inc ebx dec ecx jnz .a call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 75,95,180,131,160 GUIBox 75,95,180,95,162 GUIBox 75,95,75,131,161 GUIBox 180,95,180,131,159 GUIBox 75,131,180,131,158 GUIOuttext 81,101,guipresstext1,220-15 GUIOuttext 80,100,guipresstext1,220 GUIOuttext 81,111,guipresstext2,220-15 GUIOuttext 80,110,guipresstext2,220 GUIOuttext 81,121,guipresstext3,220-15 GUIOuttext 80,120,guipresstext3,220 call vidpastecopyscr .again call JoyRead ; mov dword[pressed+0CCh],0 ; mov dword[pressed+0CCh+80h],0 ; mov dword[pressed+0E8h],0 ; mov dword[pressed+0E8h+80h],0 xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b jmp .again .pressedokay push ebx xor ebx,ebx mov ecx,256+128+64 .a2 cmp byte[pressed+ebx],0 je .pressedokayb mov byte[pressed+ebx],2 .pressedokayb inc ebx dec ecx jnz .a2 pop ebx .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey ; push ebx ; mov eax,0Bh ; int 33h ; pop ebx ret guipresstext1 db 'ENTER THE KEY',0 guipresstext2 db 'OR BUTTON TO USE',0 guipresstext3 db '(ESC TO CLEAR)',0 guipresstestb: call GUIUnBuffer call DisplayBoxes call DisplayMenu GUIBox 65,80,194,126,160 GUIBox 65,80,194,80,162 GUIBox 65,80,65,126,161 GUIBox 194,80,194,126,159 GUIBox 65,126,194,126,158 GUIOuttext 71,86,guipresstext1,220-15 GUIOuttext 70,85,guipresstext1,220 GUIOuttext 71,96,guipresstext2,220-15 GUIOuttext 70,95,guipresstext2,220 GUIOuttext 71,116,guipresstext3b,220-15 GUIOuttext 70,115,guipresstext3b,220 mov eax,[guipressptr] GUIOuttext 71,106,eax,220-15 mov eax,[guipressptr] GUIOuttext 70,105,eax,220 call vidpastecopyscr mov ecx,8192 call delay .tryagain call JoyRead xor ebx,ebx mov ecx,256+128+64 .b2 cmp byte[pressed+ebx],0 jne .tryagain inc ebx dec ecx jnz .b2 .again call JoyRead ; mov dword[pressed+0CCh],0 ; mov dword[pressed+0CCh+80h],0 ; mov dword[pressed+0E8h],0 ; mov dword[pressed+0E8h+80h],0 xor ebx,ebx mov ecx,256+128+64 .b cmp byte[pressed+ebx],0 jne .pressedokay inc ebx dec ecx jnz .b jmp .again .pressedokay .again2 call Check_Key or al,al jz .nokey call Get_Key jmp .again2 .nokey cmp ebx,1 je .skip cmp ebx,3Bh je .skip mov eax,[guicpressptr] mov [eax],ebx .skip ; push ebx ; mov eax,0Bh ; int 33h ; pop ebx ret guipresstext3b db '(ESC TO SKIP)',0 guipresstext4b db 'FOR UP ',0 db 'FOR DOWN ',0 db 'FOR LEFT ',0 db 'FOR RIGHT ',0 db 'FOR START ',0 db 'FOR SELECT ',0 db 'FOR A (RIGHT BUTTON)',0 db 'FOR B (DOWN BUTTON) ',0 db 'FOR X (TOP BUTTON) ',0 db 'FOR Y (LEFT BUTTON) ',0 db 'FOR THE L BUTTON ',0 db 'FOR THE R BUTTON ',0 guipressptr dd 0 guicpressptr dd 0 DisplayGameOptnsClick: ; Process boxes mov dword[keycontrolval],0 DGOptnsProcBox 27,24,[KeyBGDisble0] DGOptnsProcBox 27+45,24,[KeyBGDisble1] DGOptnsProcBox 27+45*2,24,[KeyBGDisble2] DGOptnsProcBox 27+45*3,24,[KeyBGDisble3] DGOptnsProcBox 27,32,[KeySprDisble] DGOptnsProcBox 78,52,[KeyResetAll] DGOptnsProcBox 78,60,[KeyExtraEnab] DGOptnsProcBox 78,68,[KeyNewGfxSwt] DGOptnsProcBox 78,76,[KeyWinDisble] DGOptnsProcBox 78,84,[KeyOffsetMSw] DGOptnsProcBox 78,92,[KeySlowDown] DGOptnsProcBox 178,60,[KeyVolUp] DGOptnsProcBox 178,68,[KeyVolDown] DGOptnsProcBox 178,76,[KeyFRateUp] DGOptnsProcBox 178,84,[KeyFRateDown] DGOptnsProcBox 178,92,[KeyDisplayFPS] ; cmp byte[OSPort],3 ; jne near .notwin32 %ifndef __MSDOS__ DGOptnsProcBox 178,44,[KeyRewind] %endif ;.notwin32 DGOptnsProcBox 178,52,[KeyFastFrwrd] DGOptnsProcBox 27,112,[KeyDisableSC0] DGOptnsProcBox 27+45,112,[KeyDisableSC1] DGOptnsProcBox 27+45*2,112,[KeyDisableSC2] DGOptnsProcBox 27+45*3,112,[KeyDisableSC3] DGOptnsProcBox 27,120,[KeyDisableSC4] DGOptnsProcBox 27+45,120,[KeyDisableSC5] DGOptnsProcBox 27+45*2,120,[KeyDisableSC6] DGOptnsProcBox 27+45*3,120,[KeyDisableSC7] DGOptnsProcBox 27+45*2,132,[KeyStateSlc0] DGOptnsProcBox 27+45*3,132,[KeyStateSlc1] DGOptnsProcBox 27+45*4,132,[KeyIncStateSlot] DGOptnsProcBox 27,140,[KeyStateSlc2] DGOptnsProcBox 27+45,140,[KeyStateSlc3] DGOptnsProcBox 27+45*2,140,[KeyStateSlc4] DGOptnsProcBox 27+45*3,140,[KeyStateSlc5] DGOptnsProcBox 27+45*4,140,[KeyDecStateSlot] DGOptnsProcBox 27,148,[KeyStateSlc6] DGOptnsProcBox 27+45,148,[KeyStateSlc7] DGOptnsProcBox 27+45*2,148,[KeyStateSlc8] DGOptnsProcBox 27+45*3,148,[KeyStateSlc9] DGOptnsProcBox 8+25,158,[KeySaveState] DGOptnsProcBox 8+57+25,158,[KeyLoadState] DGOptnsProcBox 8+114+25,158,[KeyStateSelct] DGOptnsProcBox 8+25,178,[KeyQuickLoad] DGOptnsProcBox 8+57+26,178,[KeyQuickRst] DGOptnsProcBox 8+114+20,178,[KeyQuickExit] DGOptnsProcBox 8+114+78,178,[KeyQuickClock] DGOptnsProcBox 8+25,188,[KeyQuickChat] DGOptnsProcBox 8+57+45,188,[KeyQuickSnapShot] DGOptnsProcBox 8+108+70,188,[KeyQuickSaveSPC] ret DisplayGUIOptnsClick: mov eax,[GUImouseposx] sub eax,[GUIwinposx+10*4] mov edx,[GUImouseposy] sub edx,[GUIwinposy+10*4] GUIClickCButton 12,23,byte[mousewrap] GUIClickCButton 12,33,byte[mouseshad] GUIClickCButton 12,43,byte[lastcursres] GUIClickCButton 12,53,byte[resetposn] GUIClickCButton 12,63,byte[GUIClick] GUIClickCButton 12,73,byte[JoyPad1Move] GUIClickCButton6 12,83,byte[GUIEffect],1 GUIClickCButton6 124,83,byte[GUIEffect],4 GUIClickCButton6 12,93,byte[GUIEffect],2 GUIClickCButton6 124,93,byte[GUIEffect],3 GUIClickCButton 124,23,byte[GUIEnableTransp] %ifdef __WIN32__ GUIClickCButton 12,168,byte[AlwaysOnTop] GUIClickCButton 12,178,byte[SaveMainWindowPos] GUIClickCButton 12,188,byte[AllowMultipleInst] GUIClickCButton 124,33,byte[MouseWheel] GUIClickCButton 124,53,byte[TrapMouseCursor] %endif GUIClickCButtonI 124,43,byte[FilteredGUI] GUIPButtonHole 48,108,byte[CurPalSelect],0 GUIPButtonHole 88,108,byte[CurPalSelect],1 GUIPButtonHole 135,108,byte[CurPalSelect],2 push eax cmp byte[CurPalSelect],1 je .yespal2b cmp byte[CurPalSelect],2 je .yespal3b mov al,[GUIRAdd] mov [TRVal2],al mov al,[GUIGAdd] mov [TGVal2],al mov al,[GUIBAdd] mov [TBVal2],al jmp .nopal1b .yespal2b mov al,[GUITRAdd] mov [TRVal2],al mov al,[GUITGAdd] mov [TGVal2],al mov al,[GUITBAdd] mov [TBVal2],al jmp .nopal1b .yespal3b mov al,[GUIWRAdd] mov [TRVal2],al mov al,[GUIWGAdd] mov [TGVal2],al mov al,[GUIWBAdd] mov [TBVal2],al .nopal1b pop eax cmp eax,25 jl near .nomovebar cmp eax,25+32*4-1 jg near .nomovebar sub eax,25 shr eax,2 cmp edx,122 jl .nomovebar1 cmp edx,126 jg .nomovebar1 cmp byte[TRVal2],al je .nomovebar1b mov byte[TRVal2],al mov byte[TRVal2+1],1 .nomovebar1b mov byte[GUIHold],2 mov eax,[GUIwinposy+10*4] add eax,124 mov [GUIHoldYlim],eax jmp .nomovebar .nomovebar1 cmp edx,134 jl .nomovebar2 cmp edx,138 jg .nomovebar2 cmp byte[TGVal2],al je .nomovebar2b mov byte[TGVal2],al mov byte[TRVal2+1],1 .nomovebar2b mov byte[GUIHold],2 mov eax,[GUIwinposy+10*4] add eax,136 mov [GUIHoldYlim],eax jmp .nomovebar .nomovebar2 cmp edx,146 jl .nomovebar3 cmp edx,150 jg .nomovebar3 cmp byte[TBVal2],al je .nomovebar3b mov byte[TBVal2],al mov byte[TRVal2+1],1 .nomovebar3b mov byte[GUIHold],2 mov eax,[GUIwinposy+10*4] add eax,148 mov [GUIHoldYlim],eax .nomovebar3 .nomovebar push eax cmp byte[CurPalSelect],1 je .yespal2 cmp byte[CurPalSelect],2 je .yespal3 mov al,[TRVal2] mov [GUIRAdd],al mov al,[TGVal2] mov [GUIGAdd],al mov al,[TBVal2] mov [GUIBAdd],al jmp .nopal1 .yespal2 mov al,[TRVal2] mov [GUITRAdd],al mov al,[TGVal2] mov [GUITGAdd],al mov al,[TBVal2] mov [GUITBAdd],al jmp .nopal1 .yespal3 mov al,[TRVal2] mov [GUIWRAdd],al mov al,[TGVal2] mov [GUIWGAdd],al mov al,[TBVal2] mov [GUIWBAdd],al .nopal1 pop eax cmp byte[TRVal2+1],1 jne .nopalchange call GUISetPal mov byte[TRVal2+1],0 .nopalchange cmp byte[GUIHold],2 jne .nohold mov eax,[GUIwinposx+10*4] add eax,25 mov [GUIHoldXlimL],eax mov eax,[GUIwinposx+10*4] add eax,25+32*4-1 mov [GUIHoldXlimR],eax .nohold ret DisplayGUIAboutClick: ; cmp byte[OSPort],3 ; jne near .nowin32 %ifndef __MSDOS__ GUIPHoldbutton 90,50,175,60,65 %endif ;.nowin32 ret %macro ComboBoxProc 5 cmp eax,%1 jl %%nope cmp edx,%2 jl %%nope cmp eax,%3 jg %%nope cmp edx,%4 jg %%nope cmp byte[GUINumCombo],42 je %%nope xor ebx,ebx mov bl,[GUINumCombo] mov byte[GUIComboData+ebx],%5 inc byte[GUINumCombo] %%nope %endmacro %macro ComboBoxProcD 4 cmp eax,%1 jl %%nope cmp edx,%2 jl %%nope cmp eax,%3 jg %%nope cmp edx,%4 jg %%nope cmp byte[GUINumCombo],0 je %%nope dec byte[GUINumCombo] %%nope %endmacro ; DrawSlideBar 16,192,20,[GUIccombviewloc],[NumCombo],8,61,GUICSStC,13,14 ; DrawBorderedBox 16,10,20,190,80,19 ; DrawGUIWinBox 3,5,34,107,77,167 ; DrawSlideBarWin 3,109,42,[GUIcurrentinputviewloc],16,5,28,GUIIStA DisplayGUIComboClick2: mov dword[keycontrolval],0 ; x1,y1,x2,y2,upjump,downjump,holdpos,scsize,view,cur,listsize GUISlidebarPostImpl 192,28,199,72,.scrollup,.scrolldown,13,8,GUIccombviewloc,GUIccombcursloc,NumCombo,GUIBlankVar,1 ;x1,y1,x2,y2,view,curs,num,.scru,.scrd,jumpto,sizeofscreen GUIPostWinBoxMove 10,22,190,23+8*7,GUIccombviewloc,GUIccombcursloc,NumCombo,.scrollup,.scrolldown,DisplayGUIComboClick.skipscrol,8 DisplayGUIComboClick: ; SlideBar Implementation ; x1,y1,x2,y2,GUI?StA,ScrnSize,ViewLoc,CursLoc,Entries,win# GUISlidebarImpl 192,28,199,72,GUICSStC,8,GUIccombviewloc,GUIccombviewloc,NumCombo,16 .skipscrol ;x,y,x2,y2,currentwin,vpos,#entries,starty,y/entry,cpos,winval,win#,dclicktick# GUIWinControl2 10,23,190,22+8*7,GUIBlankVar,GUIccombviewloc,NumCombo,23,7,GUIccombcursloc,6,16,0 GUIPButtonHole 178,82,byte[GUIComboPNum],0 GUIPButtonHole 196,82,byte[GUIComboPNum],1 GUIPButtonHole 214,82,byte[GUIComboPNum],2 GUIPButtonHole 232,82,byte[GUIComboPNum],3 GUIClickCButton 163,88,byte[GUIComboLHorz] GUIClickCButtonC 163,96,byte[GUIComboGameSpec] GUIPHoldbutton 202,20,246,31,60 GUIPHoldbutton 202,35,246,46,61 GUIPHoldbutton 202,50,246,61,62 GUIPHoldbutton 202,65,246,76,63 DGOptnsProcBoxc 135,91,157,99,[GUIComboKey] ComboBoxProc 75,150,85,157,1 ComboBoxProc 89,150,99,157,2 ComboBoxProc 103,150,113,157,3 ComboBoxProc 117,150,127,157,4 ComboBoxProc 131,150,141,157,5 ComboBoxProc 145,150,155,157,6 ComboBoxProc 159,150,169,157,7 ComboBoxProc 173,150,183,157,8 ComboBoxProc 187,150,197,157,9 ComboBoxProc 201,150,211,157,10 ComboBoxProc 215,150,227,157,11 ComboBoxProc 231,150,243,157,12 ComboBoxProc 75,160,85,167,13 ComboBoxProc 89,160,99,167,14 ComboBoxProc 103,160,113,167,15 ComboBoxProc 117,160,127,167,16 ComboBoxProc 131,160,141,167,17 ComboBoxProc 145,160,155,167,18 ComboBoxProc 159,160,169,167,19 ComboBoxProc 173,160,183,167,20 ComboBoxProc 187,160,197,167,21 ComboBoxProc 201,160,211,167,22 ComboBoxProc 215,160,227,167,23 ComboBoxProc 231,160,243,167,24 ComboBoxProc 75,170,85,177,25 ComboBoxProc 89,170,99,177,26 ComboBoxProc 103,170,113,177,27 ComboBoxProc 117,170,127,177,28 ComboBoxProc 131,170,141,177,29 ComboBoxProc 145,170,155,177,30 ComboBoxProc 159,170,169,177,31 ComboBoxProc 173,170,183,177,32 ComboBoxProc 187,170,197,177,33 ComboBoxProc 201,170,211,177,34 ComboBoxProc 215,170,227,177,35 ComboBoxProc 231,170,243,177,36 ComboBoxProc 10,189,20,196,37 ComboBoxProc 24,189,34,196,38 ComboBoxProc 38,189,48,196,39 ComboBoxProc 52,189,62,196,40 ComboBoxProc 66,189,76,196,41 ComboBoxProc 80,189,90,196,42 ComboBoxProc 107,189,117,196,43 ComboBoxProc 121,189,131,196,44 ComboBoxProc 135,189,145,196,45 ComboBoxProc 149,189,159,196,46 ComboBoxProc 163,189,173,196,47 ComboBoxProc 177,189,187,196,48 ComboBoxProcD 204,189,218,196 mov ebx,[NumComboLocl] cmp byte[GUIComboGameSpec],0 jne .local mov ebx,[NumComboGlob] .local mov [NumCombo],ebx xor ebx,ebx ret DisplayGUIResetClick: GUIPHoldbutton 20,30,56,41,2 GUIPHoldbutton 80,30,116,41,3 ret DisplayGUIStatesClick: GUIPHoldbutton 20,30,56,41,10 GUIPHoldbutton 80,30,116,41,11 ret DisplayGUICheatSearchClick2: cmp byte[CheatWinMode],2 je near DisplayGUICheatSearchClick.preview DisplayGUICheatSearchClick: cmp byte[CheatWinMode],1 je near .incheatmode cmp byte[CheatWinMode],2 je near .view cmp byte[CheatWinMode],3 je near .add GUIPHoldbutton 95,140,140,152,50 GUIPButtonHole 11,28,byte[CheatSrcByteSize],0 GUIPButtonHole 11,38,byte[CheatSrcByteSize],1 GUIPButtonHole 11,48,byte[CheatSrcByteSize],2 GUIPButtonHole 11,58,byte[CheatSrcByteSize],3 GUIPButtonHole 11,73,byte[CheatSrcByteBase],0 GUIPButtonHole 11,83,byte[CheatSrcByteBase],1 GUIPButtonHole 11,113,byte[CheatSrcSearchType],0 GUIPButtonHole 11,123,byte[CheatSrcSearchType],1 ret .incheatmode GUIPHoldbutton 30,140,80,152,51 cmp byte[CheatSearchStatus],1 jne near .cheatsearching jmp .nosearch .cheatsearching cmp byte[CheatSrcSearchType],1 je near .cheatsearchingcomp jmp .searched .cheatsearchingcomp GUIPButtonHole 11,33,byte[CheatCompareValue],0 GUIPButtonHole 11,43,byte[CheatCompareValue],1 GUIPButtonHole 11,53,byte[CheatCompareValue],2 GUIPButtonHole 11,63,byte[CheatCompareValue],3 .searched GUIPHoldbutton 120,140,170,152,53 .nosearch GUIPHoldbutton 10,140,60,152,51 GUIPHoldbutton 70,140,110,152,52 ret .preview ; x1,y1,x2,y2,upjump,downjump,holdpos,scsize,view,cur,listsize GUISlidebarPostImpl 173,28,180,100,.scrollup,.scrolldown,11,12,GUIcurrentchtsrcviewloc,GUIcurrentchtsrccursloc,NumCheatSrc,GUIBlankVar,1 ;x1,y1,x2,y2,view,curs,num,.scru,.scrd,jumpto,sizeofscreen GUIPostWinBoxMove 5,22,171,22+12*7,GUIcurrentchtsrcviewloc,GUIcurrentchtsrccursloc,NumCheatSrc,.scrollup,.scrolldown,DisplayGUICheatSearchClick.skipscrol,12 .view ; x1,y1,x2,y2,GUI?StA,ScrnSize,ViewLoc,CursLoc,Entries,win# GUISlidebarImpl 173,28,180,100,GUICSStA,12,GUIcurrentchtsrcviewloc,GUIcurrentchtsrccursloc,NumCheatSrc,13 .skipscrol ; x,y,x2,y2,currentwin,vpos,#entries,starty,y/entry,cpos,winval,win#,dclicktick# GUIWinControl 5,23,171,21+12*7,GUIBlankVar,GUIcurrentchtsrcviewloc,NumCheatSrc,22,7,GUIcurrentchtsrccursloc,5,13,30 GUIPHoldbutton 70,140,130,152,54 GUIPHoldbutton 140,140,180,152,55 ret ; DrawSlideBarWin 13,173,28,[GUIcurrentchtsrcviewloc],[NumCheatSrc],12,73,GUICSStA ; DrawGUIWinBox 13,5,20,171,108,167 .add GUIPHoldbutton 60,155,120,167,56 GUIPHoldbutton 130,155,160,167,57 GUIClickCButton 8,139,byte[CheatUpperByteOnly] GUIBoxVar 10,30,80,37,CurCStextpos,0 GUIBoxVar 10,55,126,62,CurCStextpos,1 ret DisplayGUIAddOnClick: GUIPButtonHole 9,15,byte[snesmouse],0 GUIPButtonHole 9,25,byte[snesmouse],1 GUIPButtonHole 9,35,byte[snesmouse],2 GUIPButtonHole 9,45,byte[snesmouse],3 GUIPButtonHole 9,55,byte[snesmouse],4 GUIClickCButton 9,83,byte[nssdip1] GUIClickCButton 59,83,byte[nssdip2] GUIClickCButton 109,83,byte[nssdip3] GUIClickCButton 9,93,byte[nssdip4] GUIClickCButton 59,93,byte[nssdip5] GUIClickCButton 109,93,byte[nssdip6] ret DrawMouse: mov edi,[vidbuffer] add edi,16 add edi,[GUImouseposx] mov eax,[GUImouseposy] shl eax,8 mov ebx,[GUImouseposy] shl ebx,5 add eax,ebx add edi,eax mov esi,GUIMousePtr mov edx,8 .next2 mov ecx,8 .next mov al,[esi] or al,al jz near .nodraw test byte[mouseshad],1 jz near .finishadow mov bl,[edi+288*10+8] cmp bl,32 jae .noprimshad add byte[edi+288*10+8],96 jmp .finishadow .noprimshad mov bl,[edi+288*4+3] cmp bl,32 jb .nogray cmp bl,63 ja .nogray sub bl,32 shr bl,1 add bl,32 mov [edi+288*4+3],bl jmp .finishadow .nogray and bl,11110000b cmp bl,64 jne .nomidshad2 add byte[edi+288*4+3],16 jmp .finishadow .nomidshad2 mov bl,[edi+288*7+5] cmp bl,148 jb .nomidshad cmp bl,167 ja .mid2 add byte[edi+288*7+5],20 jmp .finishadow .mid2 cmp bl,189 jb .nomidshad cmp bl,220 ja .nomidshad sub bl,189 ; test bl,01h ; jnz .nomidshad shr bl,1 add bl,189 mov byte[edi+288*7+5],bl jmp .finishadow .nomidshad .finishadow mov [edi],al .nodraw inc esi inc edi dec ecx jnz near .next add edi,288-8 dec edx jnz near .next2 ret zsnes-1.36/src/gui/guinetpl.inc0100644000175000017500000010521207432621316016066 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; GUI NetPlay Routines (Modem,IPX,UDP+TCP/IP) ProcessModem: cmp byte[ModemProcess],40 jne near .noprocess40 cmp byte[maxskip],3 jae .okaymf mov byte[maxskip],3 .okaymf mov byte[frameskip],0 mov byte[Latencytochange],3 mov byte[Latency],3 mov byte[IPXSearchval],0 mov byte[RemoteDisconnect],0 mov byte[HoldCommand],1 mov byte[RemoteCommand],1 ; Clear Screen Buffer mov eax,ViewBuffer mov ecx,50*32 .clooptcpip mov byte[eax],0 inc eax dec ecx jnz .clooptcpip mov dword[CCursLoc],0 mov dword[CViewLoc],0 mov dword[NViewLoc],0 mov esi,.tcpipinit call .writestr mov esi,.tcpipport call .writestr mov esi,GUINetTextl2 call .writestr mov esi,.tcpipret call .writestr mov esi,.tcpipportt cmp byte[UDPConfig],0 je .notudp mov esi,.tcpipportu .notudp call .writestr mov esi,.tcpipret call .writestr mov esi,.tcpipserv call .writestr mov byte[ModemProcess],42 ret .tcpipdones db 'DONE',13,10,13,10,'WAITING FOR CLIENT...',0 .tcpipdonec db 'DONE',13,10,13,10,'CONNECTING TO SERVER...',0 .tcpipdones2 db 13,10,13,10,'FOUND CLIENT.',0 .tcpipdonec2 db 13,10,13,10,'CONNECTION SUCCESSFUL.',0 .tcpiperror db 'FAILED',13,10,13,10,'ERROR: ',0 .tcpipip db 'IP : ',0 .tcpipip2 db 'SIP : ',0 .tcpipport db 'PORT : ',0 .tcpipportu db 'PROTOCOL: UDP',13,10,0 .tcpipportt db 'PROTOCOL: TCP/IP',13,10,0 .tcpipret db 13,10,0 .errorinit db 'FAILED NET INIT',0 .errorinit2 db 'CANNOT START SERVER',0 .errorinit3 db 'CANNOT CONNECT',0 .noprocess40 cmp byte[ModemProcess],41 jne near .noprocess41 cmp byte[maxskip],3 jae .okaymf2 mov byte[maxskip],3 .okaymf2 mov byte[frameskip],0 mov byte[Latencytochange],3 mov byte[Latency],3 mov byte[IPXSearchval],0 mov byte[RemoteDisconnect],0 mov byte[HoldCommand],1 mov byte[RemoteCommand],1 ; Clear Screen Buffer mov eax,ViewBuffer mov ecx,50*32 .clooptcpip2 mov byte[eax],0 inc eax dec ecx jnz .clooptcpip2 mov dword[CCursLoc],0 mov dword[CViewLoc],0 mov dword[NViewLoc],0 mov esi,.tcpipinit call .writestr mov esi,.tcpipport call .writestr mov esi,GUINetTextl2 call .writestr mov esi,.tcpipret call .writestr mov esi,.tcpipportt cmp byte[UDPConfig],0 je .notudp2 mov esi,.tcpipportu .notudp2 call .writestr mov esi,.tcpipip2 call .writestr mov esi,TCPIPAddress call .writestr mov esi,.tcpipret call .writestr mov esi,.tcpipret call .writestr mov esi,.tcpipclie call .writestr mov byte[ModemProcess],43 ret .noprocess41 cmp byte[ModemProcess],42 jne near .noprocess42 call TCPIPStartServer or eax,eax jnz .tcpfailed mov esi,.tcpipdones call .writestr mov byte[ModemProcess],44 ret .tcpfailed mov esi,.tcpiperror call .writestr mov esi,.errorinit call .writestr mov byte[ModemProcess],255 ret .noprocess42 cmp byte[ModemProcess],43 jne near .noprocess43 call TCPIPInitConnectToServer or eax,eax jnz .tcpfailed2 mov esi,.tcpipdonec call .writestr mov byte[ModemProcess],45 ret .tcpfailed2 mov esi,.tcpiperror call .writestr mov esi,.errorinit call .writestr mov byte[ModemProcess],255 ret .noprocess43 cmp byte[ModemProcess],44 jne near .noprocess44 call TCPIPWaitForConnection cmp eax,1 je .successb or eax,eax jnz .tcpfailed3 ret .successb mov esi,.tcpipdones2 call .writestr mov byte[ModemProcess],46 ret .tcpfailed3 ; add al,'Z' ; mov byte[.tcpiperror],al mov esi,.tcpiperror call .writestr mov esi,.errorinit2 call .writestr mov byte[ModemProcess],255 ret .noprocess44 cmp byte[ModemProcess],45 jne near .noprocess45 call TCPIPConnectToServer or eax,eax jnz .tcpfailed4 mov byte[ModemProcess],47 ret .tcpfailed4 ; add al,'Z' ; mov [.errorinit3],al mov esi,.tcpiperror call .writestr mov esi,.errorinit3 call .writestr mov byte[ModemProcess],255 ret .noprocess45 cmp byte[ModemProcess],46 jne near .noprocess46 mov byte[pl2neten],2 mov byte[pl1neten],1 mov byte[UseRemoteSRAMData],1 mov byte[ModemProcess],66 ret .noprocess46 cmp byte[ModemProcess],47 jne near .noprocess47 call TCPIPConnectToServerW or eax,eax jnz .connected ret .connected mov esi,.tcpipdonec2 call .writestr mov byte[pl2neten],1 mov byte[pl1neten],2 mov byte[UseRemoteSRAMData],2 mov byte[ModemProcess],66 ret .noprocess47 cmp byte[ModemProcess],30 jne near .noprocess30 mov byte[Latencytochange],2 mov byte[Latency],2 mov byte[IPXSearchval],0 ; Clear Screen Buffer mov eax,ViewBuffer mov ecx,50*32 .cloopipx mov byte[eax],0 inc eax dec ecx jnz .cloopipx mov dword[CCursLoc],0 mov dword[CViewLoc],0 mov dword[NViewLoc],0 mov esi,.initc call .writestr mov esi,.localid call .writestr push es mov es,[selc0040] mov ax,[es:108] mov [IPXInfoStr],ax pop es call .writehex ; ipx ; cmp byte[OSPort],1 ; je .noinitipx call initipx .noinitipx cmp ax,0 je .success mov byte[ModemProcess],255 mov esi,.noipx call .writestr ret .success mov byte[ModemProcess],31 mov dword[ModemPTimer],36 mov esi,.yesipx call .writestr ret .noprocess30 cmp byte[ModemProcess],31 jne .noprocess31 ; Wait for remote cmp dword[ModemPTimer],0 jne .nolookforconnect mov dword[ModemPTimer],36 ; cmp byte[OSPort],1 ; je .noipxlook call ipxlookforconnect .noipxlook cmp byte[IPXSearchval],0 je .nolookforconnect mov esi,.connectest call .writestr mov esi,.remoteid call .writestr mov ax,[IPXInfoStrR] call .writehex mov byte[ModemProcess],64 mov byte[Connected],1 mov byte[WhichRemote],2 .nolookforconnect ret .noprocess31 cmp byte[ModemProcess],0 jne near .noprocess0 mov byte[Latencytochange],2 mov byte[Latency],2 cmp byte[ModemInitStat],1 je .nomodeminit call InitModem mov byte[ModemInitStat],1 .nomodeminit mov byte[Connected],0 ; Clear Screen Buffer mov eax,ViewBuffer mov ecx,50*32 .cloop mov byte[eax],0 inc eax dec ecx jnz .cloop mov dword[CCursLoc],0 mov dword[CViewLoc],0 mov dword[NViewLoc],0 mov esi,.init call .writestr mov esi,.uart0 cmp byte[UartType],0 je .nouart0 mov esi,.uart1 cmp byte[UartType],1 je .nouart0 mov esi,.uart2 .nouart0 call .writestr mov esi,.initb call .writestr mov byte[ModemProcess],8 mov dword[ModemPTimer],36 mov byte[InitStr1Done],0 mov byte[ModemOKStat],0 cmp byte[cantinitmodem],0 je .okayinit mov esi,.unableinit call .writestr mov byte[ModemProcess],255 .okayinit ret .noprocess0 cmp byte[ModemProcess],8 jne .noprocess8 cmp dword[ModemPTimer],0 jne .skipnext8 mov dword[ModemPTimer],18 mov byte[ModemProcess],1 cmp byte[CNetType],12 jne .nomanual mov byte[ModemProcess],7 mov dword[ModemPTimer],0 .nomanual mov al,13 call ModemSendChar mov al,13 call ModemSendChar .skipnext8 ret .noprocess8 cmp byte[ModemProcess],1 jne .noprocess1 cmp dword[ModemPTimer],0 jne .skipnext mov byte[ModemProcess],2 call ModemClearBuffer .skipnext ret .noprocess1 cmp byte[ModemProcess],2 jne .noprocess2 mov byte[ModemProcess],3 mov dword[ModemPTimer],36*5 mov esi,GUIInitSt1 cmp byte[InitStr1Done],0 je .notinit2 mov esi,GUIInitSt2 .notinit2 call ModemSendStr mov al,13 call ModemSendChar ret .noprocess2 cmp byte[ModemProcess],3 jne .noprocess3 cmp byte[ModemOKStat],0 je .norecv mov byte[ModemProcess],9 .norecv cmp dword[ModemPTimer],0 jne .notimeout mov esi,.tout call .writestr mov byte[ModemProcess],255 .notimeout ret .noprocess3 cmp byte[ModemProcess],9 jne .noprocess9 cmp dword[ModemPTimer],0 je .timeout cmp byte[ModemOKStat],4 jne .notcomplete .timeout mov byte[ModemProcess],4 .notcomplete ret .noprocess9 cmp byte[ModemProcess],4 jne .noprocess4 inc byte[InitStr1Done] cmp byte[InitStr1Done],2 je .noinit2 cmp byte[GUIInitSt2],0 je .noinit2 mov byte[ModemProcess],1 mov dword[ModemPTimer],18 mov byte[ModemOKStat],0 ret .noinit2 mov byte[ModemProcess],5 mov dword[ModemPTimer],18 ret .noprocess4 cmp byte[ModemProcess],5 jne .noprocess5 cmp dword[ModemPTimer],0 jne .finishtimer ; ***** - Comment the following 4 lines ; mov byte[ModemProcess],64 ; mov byte[Connected],1 ; mov byte[WhichRemote],1 ; ret ; dial, wait for ring, etc. cmp byte[CNetType],11 ; dial jne .nodial mov esi,GUIDialSt call ModemSendStr mov esi,DialNumber call ModemSendStr mov al,13 call ModemSendChar mov byte[ModemProcess],7 ret .nodial cmp byte[CNetType],10 ; wait for ring jne .noanswer mov esi,.rdet call .writestr mov byte[ModemProcess],6 ret .noanswer mov byte[ModemProcess],7 ret .finishtimer .noprocess5 cmp byte[ModemProcess],6 jne .noprocess6 call ModemCheckRing cmp al,1 jne .noprocess6 mov esi,.ata call ModemSendStr mov byte[ModemProcess],7 .noprocess6 cmp byte[ModemProcess],7 jne .noprocess7 call ModemCheckDCD cmp al,1 jne .nocdc7 mov esi,.cdet call .writestr mov byte[ModemProcess],64 mov byte[WhichRemote],1 .nocdc7 ret .noprocess7 ; Connect initialization cmp byte[ModemProcess],64 jne .noprocess64 mov dword[ModemPTimer],72 ;36 mov byte[ModemProcess],65 mov byte[Connected],1 ret .noprocess64 cmp byte[ModemProcess],65 jne .noprocess65 cmp dword[ModemPTimer],0 je .okay65 ret .okay65 mov byte[ModemProcess],66 ret .noprocess65 cmp byte[ModemProcess],69 jne .noprocess69 cmp dword[ModemPTimer],0 jne .notimer69 mov dword[ModemPTimer],90 ; 2.5s call PreparePacket mov al,228 call RemoteSendChar call SendPacket .notimer69 call RemoteGetChar cmp dh,0 je .doneprocess69 cmp dl,228 jne .doneprocess69 mov byte[ModemProcess],66 .doneprocess69 ret .noprocess69 cmp byte[ModemProcess],66 jne .noprocess66 ; Send ID and version # call PreparePacket mov al,'I' call RemoteSendChar mov al,'D' call RemoteSendChar mov al,222 call RemoteSendChar mov al,[welcome+7] call RemoteSendChar mov al,[welcome+9] call RemoteSendChar mov al,[welcome+10] call RemoteSendChar mov al,[welcome+11] call RemoteSendChar mov al,[soundon] call RemoteSendChar cmp al,byte[CNetType] call RemoteSendChar call SendPacket mov byte[ModemProcess],67 mov byte[IDCheckPos],0 ret ; Check if versions are the same .noprocess66 cmp byte[ModemProcess],67 jne near .noprocess67 call RemoteGetChar cmp dh,0 je near .doneprocess cmp dl,'I' jne .noI mov byte[IDCheckPos],1 ret .noI cmp byte[IDCheckPos],1 jne .nocheck2 cmp dl,'D' jne .noD mov byte[IDCheckPos],2 ret .noD mov byte[IDCheckPos],0 ret .nocheck2 cmp byte[IDCheckPos],2 jne .nocheck3 cmp dl,222 jne .no222 mov byte[IDCheckPos],3 ret .no222 mov byte[IDCheckPos],0 ret .nocheck3 cmp byte[IDCheckPos],3 jne .nocheck4 cmp dl,[welcome+7] jne near .invversion mov byte[IDCheckPos],4 ret .nocheck4 cmp byte[IDCheckPos],4 jne .nocheck5 cmp dl,[welcome+9] jne near .invversion mov byte[IDCheckPos],5 ret .nocheck5 cmp byte[IDCheckPos],5 jne .nocheck6 cmp dl,[welcome+10] jne .invversion mov byte[IDCheckPos],6 ret .nocheck6 cmp byte[IDCheckPos],6 jne .nocheck7 cmp dl,[welcome+11] jne .invversion mov byte[IDCheckPos],9 ret .nocheck7 cmp byte[IDCheckPos],9 jne .nocheck10 cmp dl,[soundon] jne .invsound mov byte[IDCheckPos],7 ret .nocheck10 cmp byte[IDCheckPos],7 jne .nocheck8 mov [RemCNetType],dl mov byte[IDCheckPos],0 mov byte[ModemProcess],80 cmp byte[WhichRemote],4 jne .nocheck8 mov byte[ModemProcess],81 .nocheck8 ret .invversion mov esi,.invver call .writestr mov byte[IDCheckPos],8 ret .invsound mov esi,.invsnd call .writestr mov byte[IDCheckPos],8 ret .doneprocess ret .noprocess67 cmp byte[ModemProcess],81 je near .nonetpl cmp byte[ModemProcess],80 jne near .noprocess80 mov dword[pl1neten],0 mov byte[pl5neten],0 mov byte[UseRemoteSRAMData],0 cmp byte[CNetType],10 jne .noans mov byte[pl2neten],2 mov byte[pl1neten],1 .noans cmp byte[RemCNetType],10 jne .noans2 mov byte[pl2neten],1 mov byte[pl1neten],2 .noans2 cmp byte[CNetType],11 jne .noans3 mov byte[pl2neten],1 mov byte[pl1neten],2 .noans3 cmp byte[RemCNetType],11 jne .noans4 mov byte[pl2neten],2 mov byte[pl1neten],1 .noans4 cmp byte[CNetType],15 jne near .nonetpl mov bx,[IPXInfoStr] mov ax,[IPXInfoStrR] .nextpldet push eax push ebx xor ax,bx test ax,1 jz .nochipx test bx,1 jz .pl2 mov byte[pl2neten],2 mov byte[pl1neten],1 jmp .skipipxpl .pl2 mov byte[pl2neten],1 mov byte[pl1neten],2 jmp .skipipxpl .nochipx pop ebx pop eax shr eax,1 shr ebx,1 jmp .nextpldet .skipipxpl pop ebx pop eax mov byte[UseRemoteSRAMData],0 .nonetpl mov eax,ViewBuffer mov ecx,50*32 .cloop2 mov byte[eax],0 inc eax dec ecx jnz .cloop2 mov dword[CCursLoc],0 mov dword[CViewLoc],0 mov dword[NViewLoc],0 mov byte[CNetType],20 mov dword[ChatString],0 mov byte[RemoteCommand],1 mov byte[romloadskip],1 call LoadDetermine call PreparePacket mov al,1 call RemoteSendChar call SendPacket .noprocess80 ret .writestr mov dh,1 .loop mov dl,[esi] or dl,dl jz .nomore call NetAddChar inc esi jmp .loop .nomore ret .writehex mov dx,ax shr dx,12 and edx,0Fh mov dl,[.hexval+edx] push eax call NetAddChar pop eax mov dx,ax shr dx,8 and edx,0Fh mov dl,[.hexval+edx] push eax call NetAddChar pop eax mov dx,ax shr dx,4 and edx,0Fh mov dl,[.hexval+edx] push eax call NetAddChar pop eax mov dx,ax and edx,0Fh mov dl,[.hexval+edx] call NetAddChar ret .hexval db '0123456789ABCDEF' .unableinit db 'CANNOT INIT DRIVER!',13,10,0 .init db 'ZSNES MODEM TERMINAL',13,10,0 .initb db 13,10,'INITIALIZING MODEM :',13,10,13,10,0 .initc db 'ZSNES IPX TERMINAL',13,10,13,10,0 .uart0 db 'USING 8250 UART',13,10,0 .uart1 db 'USING 16550A UART',13,10,0 .uart2 db 'USING FOSSIL DRIVER',13,10,0 .tout db 'MODEM RESPONSE TIMEOUT',13,10,0 .ata db 'ATA',13,0 .cdet db 'CARRIER DETECTED',13,10,0 .invver db 13,10,'INCOMPATIBLE VERSION!',13,10,0 .rdet db 'WAITING FOR RING...',13,10,0 .invsnd db 'INVALID SOUND SETTING!',13,10,0 .noipx db 13,10,13,10,'UNABLE TO INIT IPX!',13,10,0 .yesipx db 13,10,13,10,'IPX INITIALIZED.',13,10,13,10,'WAITING FOR REMOTE',13,10,0 .localid db 'LOCAL ID : ',0 .remoteid db 'REMOTE ID : ',0 .connectest db 'CONNECTION ESTABLISHED',13,10,0 .tcpipinit db 'ZSNES NET INTERFACE',13,10,13,10,0 .tcpipserv db 'INIT SERVER ... ',0 .tcpipclie db 'INIT CLIENT ... ',0 InitStr1Done db 0 NEWSYM PreparePacket call PreparePacketIPX cmp byte[WhichRemote],4 jne .nottcpip call TCPIPPreparePacket .nottcpip ret NEWSYM SendPacket call SendPacketIPX cmp byte[WhichRemote],4 jne .nottcpip call TCPIPSendPacket .nottcpip ret NEWSYM SendPacketUDP call SendPacketIPX cmp byte[WhichRemote],4 jne .nottcpip call TCPIPSendPacketUDP .nottcpip ret NEWSYM WritetochatBuffer ; 28 characters mov dh,1 .loop mov dl,[esi] or dl,dl jz .nomore call NetAddChar inc esi jmp .loop .nomore ret NEWSYM RemoteCommand, db 0 HoldCommand db 0 RemoteDeInit: cmp byte[ModemInitStat],0 je .nodeinitmodem call DeInitModemC mov byte[ModemInitStat],0 .nodeinitmodem mov byte[CNetType],1 cmp byte[WhichRemote],2 jne .noipx mov byte[CNetType],0 .noipx cmp byte[WhichRemote],4 jne .notcpip cmp byte[TCPIPStatus],0 je .nottcpipinit call TCPIPDisconnect mov byte[TCPIPStatus],0 .nottcpipinit mov byte[CNetType],4 .notcpip ret Checkfileexist: mov edx,FileNameMod call Open_File jc .failed mov bx,ax mov ecx,1 mov edx,.temp call Read_File jc .failed2 call Close_File jc .failed xor eax,eax ret .failed2 call Close_File .failed mov eax,1 ret .temp db 0 ProcessRemoteCommand: cmp byte[WhichRemote],1 jne .notmodem push edx call ModemCheckDCD pop edx cmp al,1 jne near .nomulti .notmodem cmp byte[RemoteDisconnect],1 je near .nomulti call ProcRewind ; 1 = Idle, 2 = Chat String, 3..7 = Player Select ; 10 = Load Game, 11 = Proceed Load, 12 = Load failed, 13 = File not Found ; 20 = Send Controls cmp dl,1 je near .finish cmp dl,2 je near .chatstr cmp dl,10 je near .loadstr cmp dl,11 je near .startloading cmp dl,12 je near .loadfail ; *************************** cmp dl,13 je near .loadfnf cmp dl,14 je near .loadstate cmp dl,15 je near .skipstate cmp dl,20 je near .latencychange cmp dl,30 je near .quitgui cmp dl,40 je near .guireset cmp dl,8 ja near .nomulti cmp [HoldCommand],dl je near .forgetcommand cmp dl,3 jne .nopl1 cmp byte[pl1neten],1 je .nopl1 xor byte[pl1neten],2 .nopl1 cmp dl,4 jne .nopl2 cmp byte[pl2neten],1 je .nopl2 xor byte[pl2neten],2 .nopl2 cmp dl,5 jne .nopl3 cmp byte[pl3neten],1 je .nopl3 xor byte[pl3neten],2 .nopl3 cmp dl,6 jne .nopl4 cmp byte[pl4neten],1 je .nopl4 xor byte[pl4neten],2 .nopl4 cmp dl,7 jne .nopl5 cmp byte[pl5neten],1 je .nopl5 xor byte[pl5neten],2 .nopl5 cmp dl,8 jne .nobackstate xor byte[BackState],1 cmp byte[BackState],0 jne .notbstate0 mov byte[Latency],10 mov byte[Latencytochange],10 .notbstate0 cmp byte[BackState],1 jne .notbstate1 mov byte[Latency],3 mov byte[Latencytochange],3 .notbstate1 .nobackstate jmp .finish .forgetcommand mov byte[HoldCommand],1 jmp .finish .nomulti cmp dl,50 jne .nosramnone cmp byte[HoldCommand],41 je .forgetcommand cmp byte[HoldCommand],42 je .forgetcommand mov byte[UseRemoteSRAMData],0 jmp .finish .nosramnone cmp dl,41 jne .nosramlocal cmp byte[HoldCommand],40 je .forgetcommand cmp byte[HoldCommand],41 je .forgetcommand mov byte[UseRemoteSRAMData],2 jmp .finish .nosramlocal cmp dl,42 jne .nosramremote cmp byte[HoldCommand],40 je .forgetcommand cmp byte[HoldCommand],42 je .forgetcommand mov byte[UseRemoteSRAMData],1 jmp .finish .nosramremote cmp byte[NetQuitAfter],0 je .noguiquit mov byte[GUIQuit],1 .noguiquit ; error call RemoteDeInit ret .loadfail cmp dword[TCPIPAddress],'127.' jne .nonum cmp dword[TCPIPAddress+4],'0.0.' jne .nonum cmp byte[TCPIPAddress+8],'1' je near .startloadingb .nonum mov esi,.filenotu call ProcessModem.writestr jmp .finish .startloadingb mov byte[UseRemoteSRAMData],0 jmp .startloading .loadfnf mov esi,.filenotfr call ProcessModem.writestr jmp .finish .loadstate mov byte[CNetType],22 call loadstaterecvinit .skipstate jmp .finish .latencychange cmp [HoldCommand],dl je near .invlatencych .keepgoinglc call RemoteGetChar cmp dh,0 je .keepgoinglc mov [Latency],dl mov [Latencytochange],dl jmp .finish .quitgui mov byte[GUIQuit],2 jmp .finsend .guireset call GUIDoReset jmp .finsend .invlatencych mov al,[Latency] mov [Latencytochange],al jmp .finsend .loadstr push edx mov esi,.loading call ProcessModem.writestr xor ebx,ebx .keepgoing2 push ebx call RemoteGetChar pop ebx cmp dh,0 je .keepgoing2 mov [FileNameMod+ebx],dl inc ebx or dl,dl je .doneload jmp .keepgoing2 .doneload mov esi,FileNameMod call ProcessModem.writestr mov dl,13 call NetAddChar mov dl,10 call NetAddChar pop edx cmp byte[HoldCommand],11 je .loadfailed cmp [HoldCommand],dl jne .okayload ; ***** - Add comment ; jmp .okayload ; ************ .loadfailed ; load failed mov esi,.filenotu call ProcessModem.writestr mov byte[RemoteCommand],12 jmp .finish .loadfailednf ; File Not Found mov esi,.filenotf call ProcessModem.writestr mov byte[RemoteCommand],13 jmp .finish .okayload call Checkfileexist cmp eax,0 jne .loadfailednf mov byte[RemoteCommand],11 .trynext cmp byte[GUIwinptr],0 je near .noclose xor eax,eax mov al,[GUIwinptr] dec eax xor ebx,ebx mov bl,[GUIwinorder+eax] ; close window mov byte[GUIwinorder+eax],0 mov byte[GUIwinactiv+ebx],0 dec byte[GUIwinptr] cmp byte[GUIwinptr],0 jne .noclose mov al,[GUIpmenupos] mov [GUIcmenupos],al jmp .trynext .noclose jmp .finish .chatstr ; Keep receiving and printing characters until 0 is found ; mov dl,'R' ; call NetAddChar ; mov dl,'>' ; call NetAddChar .keepgoing call RemoteGetChar cmp dh,0 je .keepgoing or dl,dl je .finishst call NetAddChar jmp .keepgoing .finishst mov dl,13 call NetAddChar mov dl,10 call NetAddChar .finish mov al,[HoldCommand] cmp al,2 jne .noprintst mov dl,'L' ; call NetAddChar mov dl,'>' ; call NetAddChar xor ebx,ebx .next mov dl,[ChatString+ebx] cmp dl,0 je .donenac push ebx ; call NetAddChar pop ebx inc ebx jmp .next .donenac mov dl,13 ; call NetAddChar mov dl,10 ; call NetAddChar mov dword[ChatString],0 jmp .skipcommand .noprintst cmp al,20 jne .nolatencyc mov al,[Latencytochange] mov [Latency],al jmp .skipcommand .nolatencyc cmp al,3 jne .nopl1b cmp byte[pl1neten],2 je .nopl1b xor byte[pl1neten],1 .nopl1b cmp al,4 jne .nopl2b cmp byte[pl2neten],2 je .nopl2b xor byte[pl2neten],1 .nopl2b cmp al,5 jne .nopl3b cmp byte[pl3neten],2 je .nopl3b xor byte[pl3neten],1 .nopl3b cmp al,6 jne .nopl4b cmp byte[pl4neten],2 je .nopl4b xor byte[pl4neten],1 .nopl4b cmp al,7 jne .nopl5b cmp byte[pl5neten],2 je .nopl5b xor byte[pl5neten],1 .nopl5b cmp al,8 jne .nobackstateb xor byte[BackState],1 cmp byte[BackState],0 jne .notbstate0b mov byte[Latency],10 mov byte[Latencytochange],10 .notbstate0b cmp byte[BackState],1 jne .notbstate1b mov byte[Latency],3 mov byte[Latencytochange],3 .notbstate1b .nobackstateb cmp al,50 jne .nosramnoneb mov byte[UseRemoteSRAMData],0 .nosramnoneb cmp al,41 jne .nosramlocalb mov byte[UseRemoteSRAMData],1 .nosramlocalb cmp al,42 jne .nosramremoteb mov byte[UseRemoteSRAMData],2 .nosramremoteb cmp al,11 jne .noload .startloading mov byte[HoldCommand],1 mov byte[RemoteCommand],1 mov eax,FileNameMod call GUIloadfilename.nocnettype mov byte[sramsavedis],1 call transfersram ret .noload .skipcommand mov al,[RemoteCommand] mov [HoldCommand],al cmp al,2 jne near .nosendstcheck cmp byte[ChatString],0 jne .nosendstcheck mov byte[RemoteCommand],1 mov byte[HoldCommand],1 mov al,1 .nosendstcheck cmp al,1 je near .finsend call PreparePacket call RemoteSendChar .nosend mov al,[RemoteCommand] cmp al,2 jne near .nosendst push eax ; Capitalize ChatString mov eax,ChatString .nextletter cmp byte[eax],0 je .doneletter cmp byte[eax],'a' jb .noletter cmp byte[eax],'z' jb .noletter sub byte[eax],'a'-'A' .noletter inc eax jmp .nextletter .doneletter cmp dword[ChatString],'/ME ' je .action cmp dword[ChatString],'/NIC' jne .notaction cmp word[ChatString+4],'K ' je near .nickchange .notaction mov eax,.chatinitial mov ebx,ChatString call ConcatString mov eax,ChatNick mov ebx,ChatString call ConcatString jmp .noaction .action mov eax,ChatString mov ebx,4 call ClipString mov eax,.actinitial2 mov ebx,ChatString call ConcatString mov eax,ChatNick mov ebx,ChatString call ConcatString mov eax,.actinitial mov ebx,ChatString call ConcatString jmp .noaction .nickchange mov eax,ChatString mov ebx,6 call ClipString ; Valid String? mov eax,ChatString xor ebx,ebx .loopnickcheck cmp byte[eax],0 je .donestcheck cmp byte[eax],'-' je .okaystring cmp byte[eax],'_' je .okaystring cmp byte[eax],'^' je .okaystring cmp byte[eax],'=' je .okaystring cmp byte[eax],'+' je .okaystring cmp byte[eax],'[' je .okaystring cmp byte[eax],']' je .okaystring cmp byte[eax],'0' jb .notokaystring cmp byte[eax],'9' jbe .okaystring cmp byte[eax],'A' jb .notokaystring cmp byte[eax],'Z' jbe .okaystring jmp .notokaystring .okaystring inc eax inc ebx jmp .loopnickcheck .donestcheck cmp ebx,9 ja .notokaystringb mov eax,ChatString mov ebx,.tempnick call CopyString mov eax,.nickchangeb mov ebx,ChatString call ConcatString mov eax,ChatNick mov ebx,ChatString call ConcatString mov eax,.tempnick mov ebx,ChatNick call CopyString jmp .noaction .notokaystring mov esi,.strinvalid call WritetochatBuffer pop eax jmp .finsend .notokaystringb mov esi,.strtoolong call WritetochatBuffer pop eax jmp .finsend .noaction pop eax xor ebx,ebx .next2 mov al,[ChatString+ebx] push ebx push eax call RemoteSendChar pop eax pop ebx inc ebx cmp al,0 jne .next2 mov esi,ChatString call WritetochatBuffer mov dl,13 call NetAddChar mov dl,10 call NetAddChar jmp .finsend2 .nosendst cmp al,20 jne .nolatencych mov al,[Latencytochange] call RemoteSendChar jmp .finsend2 .nolatencych ; FileNameMod times 29 db 0 cmp al,10 jne .nosendfn xor ebx,ebx .next3 mov al,[FileNameMod+ebx] push ebx push eax call RemoteSendChar pop eax pop ebx inc ebx cmp al,0 jne .next3 jmp .finsend2 .nosendfn .finsend2 call SendPacket .finsend mov byte[RemoteCommand],1 ret .chatinitial db '>',0 .actinitial db '*',0 .actinitial2 db ' ',0 .loading db 'LOADING ',0 .filenotf db 'FILE NOT FOUND!',13,10,0 .filenotfr db 'FILE NOT FOUND AT REMOTE!',13,10,0 .filenotu db 'UNABLE TO LOAD!',13,10,0 .tempnick times 16 db 0 .strinvalid db '** INVALID NICK **',13,10,0 .strtoolong db '** NICK IS TOO LONG **',13,10,0 .nickchangeb db ' IS NOW KNOWN AS ',0 transfersram: cmp byte[SFXSRAM],0 jne .nosram cmp byte[SA1Enable],1 je .nosram cmp dword[ramsize],0 je .nosram cmp byte[UseRemoteSRAMData],1 je .uselocal cmp byte[UseRemoteSRAMData],2 je near .useremote .nosram call clearsram ret .uselocal call PreparePacket mov al,233 call RemoteSendChar call SendPacket .notimer pushad call JoyRead popad call RemoteGetChar cmp dh,0 je .notimer cmp dl,234 jne .notimer ; send sram mov ecx,[ramsize] mov ebx,[sram] xor esi,esi .loop push ebx push ecx mov ebx,esi and ebx,0FFh cmp ebx,0 jne .notzero call PreparePacket .notzero pop ecx pop ebx mov al,[ebx] push ebx push ecx call RemoteSendChar pop ecx mov ebx,esi and ebx,0FFh cmp ebx,0FFh jne .notsend call SendPacket .notsend pop ebx inc esi inc ebx dec ecx jnz .loop mov byte[sramsavedis],0 ret .useremote call PreparePacket mov al,234 call RemoteSendChar call SendPacket .notimerb pushad call JoyRead popad call RemoteGetChar cmp dh,0 je .notimerb cmp dl,233 jne .notimerb ; receive sram mov ecx,[ramsize] mov ebx,[sram] .loopb .getnext pushad call JoyRead popad call RemoteGetChar cmp dh,0 je .getnext mov [ebx],dl inc ebx dec ecx jnz .loopb ret NEWSYM RemoteSendEAX ; call RemoteSendChar shr eax,8 call RemoteSendChar shr eax,8 call RemoteSendChar shr eax,8 call RemoteSendChar ret NEWSYM RemoteGetEAX ;.getnext ; call RemoteGetChar ; cmp dh,0 ; je .getnext ; mov bl,dl xor ebx,ebx ; shl ebx,8 .getnext2 call RemoteGetChar cmp dh,0 je .getnext2 mov bl,dl shl ebx,8 .getnext3 call RemoteGetChar cmp dh,0 je .getnext3 mov bl,dl shl ebx,8 .getnext4 call RemoteGetChar cmp dh,0 je .getnext4 mov bl,dl bswap ebx mov eax,ebx ret NEWSYM RemoteSendChar cmp byte[WhichRemote],1 jne .nomodem call ModemSendChar .nomodem cmp byte[WhichRemote],2 jne .noipx call ipxsendchar .noipx cmp byte[WhichRemote],4 jne .notcpip call TCPIPStoreByte .notcpip ret NEWSYM RemoteGetChar cmp byte[WhichRemote],1 jne .nomodem call ModemGetChar .nomodem cmp byte[WhichRemote],2 jne .noipx call ipxgetchar .noipx cmp byte[WhichRemote],4 jne .notcpip call TCPIPGetByte .notcpip ret ModemSendStr: .loop mov al,[esi] or al,al jz .nomore call ModemSendChar inc esi jmp .loop .nomore ret NetLoadHandle dw 0 NetStateSize dd 0 NetStateTotal dd 0 NetStateQuit db 0 NetStateBuffer times 2048 db 0 Netfname db 'nettemp.zst',0 NetLoadStuff: call loadnetopen mov byte[NetStateQuit],0 mov edx,fnamest+1 call Open_File jc .nostate mov bx,ax mov cx,0 mov dx,0 call File_Seek_End shl edx,16 mov dx,ax mov [NetStateSize],edx mov [NetStateTotal],edx call Close_File mov byte[CNetType],21 call PreparePacket mov al,14 call RemoteSendChar mov al,[NetStateSize] call RemoteSendChar mov al,[NetStateSize+1] call RemoteSendChar mov al,[NetStateSize+2] call RemoteSendChar call SendPacket call ChangetoSRAMdir mov edx,fnamest+1 call Open_File mov [NetLoadHandle],ax call ChangetoLOADdir .nostate ret loadstaterecvinit: mov byte[NetStateQuit],0 mov dword[NetStateSize],0 .noreceive pushad call JoyRead popad call RemoteGetChar cmp dh,0 je .noreceive mov [NetStateSize],dl .noreceive1 call RemoteGetChar cmp dh,0 je .noreceive1 mov [NetStateSize+1],dl .noreceive2 call RemoteGetChar cmp dh,0 je .noreceive2 mov [NetStateSize+2],dl call ChangetoSRAMdir mov edx,Netfname call Create_File mov edx,[NetStateSize] mov [NetStateTotal],edx mov [NetLoadHandle],ax call ChangetoLOADdir ret loadstatesend: call RemoteGetChar cmp dh,0 je .noreceived cmp dl,15 je .finished call ProcessRemoteCommand .noreceived cmp byte[NetStateQuit],0 je .noquit .finished call PreparePacket mov al,15 call RemoteSendChar call SendPacket mov byte[CNetType],20 mov esi,StateLoadedFail call ProcessModem.writestr mov bx,[NetLoadHandle] call Close_File cmp byte[NetLoadState],0 je .norun mov byte[GUIQuit],2 .norun ret .noquit call PreparePacket mov al,1 call RemoteSendChar mov ecx,[NetStateSize] cmp ecx,2047 jbe .notsmaller mov ecx,2047 .notsmaller sub [NetStateSize],ecx mov bx,[NetLoadHandle] mov edx,NetStateBuffer push ecx call Read_File pop ecx mov edx,NetStateBuffer .loop mov al,[edx] push edx push ecx call RemoteSendChar pop ecx pop edx inc edx dec ecx jnz .loop call SendPacket cmp dword[NetStateSize],0 jne .notzero pushad call loadstate2 mov byte[RestoreValues],0 mov bx,[NetLoadHandle] call Close_File mov byte[CNetType],20 mov esi,StateLoadedOk call ProcessModem.writestr cmp byte[NetLoadState],0 je .norun2 mov byte[GUIQuit],2 .norun2 popad .notzero ret loadstaterecv: cmp byte[NetStateQuit],0 je .noquit2 mov byte[NetStateQuit],0 call PreparePacket mov al,15 call RemoteSendChar call SendPacket .noquit2 call RemoteGetChar cmp dh,0 jne .received ret .received cmp dl,1 je .noquit mov byte[CNetType],20 mov esi,StateLoadedFail call ProcessModem.writestr cmp byte[NetLoadState],0 je .norun mov byte[GUIQuit],2 .norun mov bx,[NetLoadHandle] call Close_File ret .noquit mov ecx,[NetStateSize] cmp ecx,2047 jbe .notsmaller mov ecx,2047 .notsmaller sub [NetStateSize],ecx mov edx,NetStateBuffer push ecx .loop push edx push ecx .notrecv call RemoteGetChar cmp dh,0 je .notrecv mov al,dl pop ecx pop edx mov [edx],al inc edx dec ecx jnz .loop pop ecx mov bx,[NetLoadHandle] mov edx,NetStateBuffer call Write_File cmp dword[NetStateSize],0 jne .notzero pushad mov bx,[NetLoadHandle] call Close_File call ChangetoSRAMdir mov edx,Netfname mov byte[RestoreValues],0 call loadstate3 call ChangetoLOADdir cmp byte[NetLoadState],0 je .norun2 mov byte[GUIQuit],2 .norun2 mov byte[CNetType],20 mov esi,StateLoadedOk call ProcessModem.writestr popad .notzero ret StateLoadedOk db 10,13,'STATE LOADED.',10,13,10,13,0 StateLoadedFail db 10,13,'LOAD FAILED.',10,13,10,13,0 zsnes-1.36/src/gui/guitools.inc0100644000175000017500000003170007275537627016124 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Tools for the GUI (string functions are also used elsewhere) NEWSYM CopyString push eax .again mov dl,[eax] mov [ebx],dl inc eax inc ebx or dl,dl jnz .again pop eax ret NEWSYM StringLength xor ecx,ecx push eax .loop cmp byte[eax],0 je .done inc eax inc ecx jmp .loop .done pop eax ret NEWSYM ClipString ; clip string eax by bl characters .next push eax .again mov dl,[eax+1] mov [eax],dl inc eax or dl,dl jnz .again pop eax dec bl jnz .next ret NEWSYM ConcatString ; concat eax in front of ebx, store in ebx ; move string forward by length of eax pushad mov esi,eax cmp byte[esi],0 je near .nomore3 .next inc esi cmp byte[esi],0 jne .next dec esi .again mov dl,[esi] push ebx xor ecx,ecx .loop cmp byte[ebx],0 je .nomore inc ebx inc ecx jmp .loop .nomore inc ebx inc ecx .loop2 or ecx,ecx jz .nomore2 mov dh,[ebx-1] mov [ebx],dh dec ebx dec ecx jmp .loop2 .nomore2 pop ebx mov [ebx],dl cmp eax,esi je .nomore3 dec esi jmp .again .nomore3 popad ret GUIoutputchar: push edi push esi push eax xor ebx,ebx mov bl,al mov edi,GUIFontData lea ebx,[ebx*5] add edi,ebx mov cl,5 .loopa mov ah,[edi] mov ch,6 .loopb test ah,80h jz .nowrite mov al,[GUItextcolor] sub al,cl sub al,ch inc al mov byte[esi],al .nowrite shl ah,1 inc esi dec ch jnz .loopb add esi,282 inc edi dec cl jnz .loopa pop eax pop esi pop edi ret GUIOutputString: xor eax,eax .more mov al,[edi] or al,al jz .nomore mov al,[ASCII2Font+eax] call GUIoutputchar add esi,6 inc edi jmp .more .nomore ret %macro GUIOuttext 4 mov edi,%2 mov esi,edi shl esi,8 shl edi,5 add esi,edi add esi,[vidbuffer] add esi,%1 add esi,16 mov edi,%3 mov byte[GUItextcolor],%4 call GUIOutputString %endmacro GUIDrawBox: .loop push edi push ecx rep stosb pop ecx pop edi add edi,288 dec edx jnz .loop ret %macro GUIBox 5 mov edi,[vidbuffer] add edi,%1 mov edx,%2 mov ecx,edx shl edx,8 shl ecx,5 add edx,ecx add edi,edx add edi,16 mov ecx,%3 sub ecx,%1 inc ecx mov edx,%4 sub edx,%2 inc edx mov al,%5 call GUIDrawBox %endmacro GUIHLines: cmp ecx,0 jl near .nodraw cmp eax,255 jg near .nodraw cmp eax,0 jnl .noofx mov eax,0 .noofx cmp ecx,255 jng .noofx2 mov ecx,255 .noofx2 cmp ebx,0 jl .nodraw cmp ebx,223 jg .nodraw sub ecx,eax inc ecx mov edi,[vidbuffer] add edi,eax add edi,16 mov eax,ebx shl eax,8 add edi,eax mov eax,ebx shl eax,5 add edi,eax mov eax,edx .loop mov [edi],ah add eax,[GUIcolscaleval] inc edi dec ecx jnz .loop .nodraw ret GUIHLine: cmp ecx,0 jl near .nodraw cmp eax,255 jg near .nodraw cmp eax,0 jnl .noofx mov eax,0 .noofx cmp ecx,255 jng .noofx2 mov ecx,255 .noofx2 cmp ebx,0 jl .nodraw cmp ebx,223 jg .nodraw sub ecx,eax inc ecx mov edi,[vidbuffer] add edi,eax add edi,16 mov eax,ebx shl eax,8 add edi,eax mov eax,ebx shl eax,5 add edi,eax mov eax,edx rep stosb .nodraw ret %macro GUIPal 4 mov dx,03C8h mov al,%1 out dx,al inc dx mov al,%2 out dx,al mov al,%3 out dx,al mov al,%4 out dx,al %endmacro GUIDrawShadow: .loop push edi push ecx .loop2 mov al,[edi-3*288-3] cmp al,148 jb .nomidshad cmp al,167 ja .mid2 add byte[edi-3*288-3],20 jmp .noshadow .mid2 cmp al,189 jb .nomidshad cmp al,220 ja .nomidshad sub al,189 shr al,1 add al,189 mov byte[edi-288*3-3],al jmp .noshadow .nomidshad mov al,[edi] cmp al,32 jae .noshadow add al,96 mov [edi],al .noshadow inc edi dec ecx jnz .loop2 pop ecx pop edi add edi,288 dec edx jnz near .loop ret %macro GUIShadow 4 mov edi,[vidbuffer] add edi,%1+%2*288+16 mov ecx,%3-%1+1 mov edx,%4-%2+1 call GUIDrawShadow %endmacro GUIDrawShadow2: .loop push edi push ecx .loop2 mov al,[edi] cmp al,32 jae .noshadow add al,96 mov [edi],al .noshadow inc edi dec ecx jnz .loop2 pop ecx pop edi add edi,288 dec ebx jnz .loop ret GUIoutputcharwin: push edi push esi push eax xor ebx,ebx mov bl,al mov edi,GUIFontData lea ebx,[ebx*5] add edi,ebx mov cl,5 .loopa mov ah,[edi] mov ch,5 cmp esi,[vidbuffer] jb .below mov edx,[vidbuffer] add edx,224*288 cmp esi,edx jb .loopb .below add esi,5 jmp .nowrite2 .loopb test ah,80h jz .nowrite mov al,[GUItextcolor] mov byte[esi],al .nowrite shl ah,1 inc esi dec ch jnz .loopb .nowrite2 add esi,283 inc edi dec cl jnz .loopa pop eax pop esi pop edi ret GUIOutputStringwin: xor eax,eax .more mov al,[edi] or al,al jz .nomore mov al,[ASCII2Font+eax] cmp edx,-8 jl .nodraw cmp edx,255 jg .nodraw push esi push edx add esi,edx call GUIoutputcharwin pop edx pop esi .nodraw add edx,6 inc edi jmp .more .nomore ret GUIOutputStringwinl: xor eax,eax mov ecx,[cloadmaxlen] .more mov al,[edi] ; cmp byte[OSPort],1 ; jbe .noperc %ifndef __MSDOS__ cmp al,'%' jne .noperc call ConvertPercValue %endif .noperc or al,al jz .nomore mov al,[ASCII2Font+eax] cmp edx,-8 jl .nodraw cmp edx,255 jg .nodraw push esi push edx push ecx add esi,edx call GUIoutputcharwin pop ecx pop edx pop esi .nodraw add edx,6 inc edi dec ecx jz .nomore jmp .more .nomore ret ConvertPercValue: mov al,[edi+2] cmp al,'a' jb .notlower cmp al,'z' ja .notlower sub al,'a'-'A' .notlower mov ah,[edi+1] cmp ah,'a' jb .notlowerb cmp ah,'z' ja .notlowerb sub ah,'a'-'A' .notlowerb cmp al,'0' jb .noperc cmp al,'9' jbe .yesperc cmp al,'F' ja .noperc cmp al,'A' jb .noperc .yesperc cmp ah,'0' jb .noperc cmp ah,'9' jbe .yesperc2 cmp ah,'F' ja .noperc cmp ah,'A' jb .noperc .yesperc2 sub al,'0' cmp al,9 jbe .nodec sub al,'A'-'0'-10 .nodec sub ah,'0' cmp ah,9 jbe .nodecb sub ah,'A'-'0'-10 .nodecb shl ah,4 or al,ah add edi,2 and eax,0FFh ret .noperc xor eax,eax mov al,[edi] ret OutputUnder: cmp edx,-8 jl .nodraw cmp edx,255 jg .nodraw mov dword[esi+edx+5*288-1],0E8E8E8E8h mov byte[esi+edx+5*288+3],0E8h .nodraw ret %macro GUIOuttextwin 1 mov esi,ebx mov eax,ebx shl esi,8 shl eax,5 add esi,eax add esi,16 add esi,[vidbuffer] mov edi,%1 call GUIOutputStringwin %endmacro %macro GUIOuttextwin2 4 mov edx,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add edx,%2 add ebx,%3 mov esi,ebx mov eax,ebx shl esi,8 shl eax,5 add esi,eax add esi,16 add esi,[vidbuffer] mov edi,%4 call GUIOutputStringwin %endmacro %macro GUIOuttextwin2l 4 mov edx,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add edx,%2 add ebx,%3 mov esi,ebx mov eax,ebx shl esi,8 shl eax,5 add esi,eax add esi,16 add esi,[vidbuffer] mov edi,%4 call GUIOutputStringwinl %endmacro %macro GUIOuttextwin2u 5 mov edx,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add edx,%2 add ebx,%3 mov esi,ebx mov eax,ebx shl esi,8 shl eax,5 add esi,eax add esi,16 add esi,[vidbuffer] mov edi,%4 add edx,%5*6 call OutputUnder sub edx,%5*6 call GUIOutputStringwin %endmacro GUIoutputiconwin: cmp eax,-9 jl .nodraw cmp eax,256 jl .draw .nodraw ret .draw mov esi,ebx mov ecx,ebx shl esi,8 shl ecx,5 add esi,ecx add esi,16 add esi,[vidbuffer] add esi,eax mov cl,10 .loopa mov ch,10 cmp esi,[vidbuffer] jb .below mov edx,[vidbuffer] add edx,224*288 cmp esi,edx jb .loopb .below add esi,10 jmp .nowrite2 .loopb mov al,[edi] or al,al jz .transp cmp al,189 ja .col2 cmp byte[GUIWincoladd],0 je .col3 inc al jmp .col3 .col2 sub al,[GUIWincoladd] dec al .col3 mov [esi],al .transp inc edi inc esi dec ch jnz .loopb .nowrite2 add esi,278 dec cl jnz .loopa ret %macro GUIDisplayIcon 1 mov edi,%1 call GUIoutputiconwin %endmacro %macro GUIDisplayIconWin 4 mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add eax,%2 add ebx,%3 mov edi,%4 call GUIoutputiconwin %endmacro GUIDrawSlideBar: cmp eax,-10 jl .ret cmp eax,256 jg .ret jmp .noret .ret ret .noret mov edi,[vidbuffer] mov [vbuflimtop],edi mov edi,[vidbuffer] add edi,288*224 sub edi,16 mov [vbuflimbot],edi mov edi,eax mov eax,ebx shl ebx,8 shl eax,5 add edi,ebx add edi,eax add edi,[vidbuffer] add edi,16 xor eax,eax dec ecx .loop cmp edx,0 je near .toparea cmp ecx,0 je near .bottomarea cmp ah,1 je .filleddisp cmp edi,[vbuflimtop] jb near .nodraw cmp edi,[vbuflimbot] ja near .nodraw mov al,197 sub al,byte[GUIWincoladd] mov [edi],al sub al,2 mov [edi+1],al dec al mov [edi+2],al dec al mov [edi+3],al mov [edi+4],al inc al mov [edi+5],al inc al mov [edi+6],al add al,2 mov [edi+7],al jmp .fin .filleddisp cmp edi,[vbuflimtop] jb near .nodraw cmp edi,[vbuflimbot] ja near .nodraw mov al,202 sub al,byte[GUIWincoladd] mov [edi],al sub al,2 mov [edi+1],al mov [edi+2],al mov [edi+3],al mov [edi+4],al mov [edi+5],al mov [edi+6],al sub al,2 mov [edi+7],al jmp .fin .toparea cmp edi,[vbuflimtop] jb near .nodraw cmp edi,[vbuflimbot] ja near .nodraw mov al,202 sub al,byte[GUIWincoladd] mov [edi],al add al,2 mov [edi+1],al mov [edi+2],al mov [edi+3],al mov [edi+4],al mov [edi+5],al mov [edi+6],al mov [edi+7],al mov ah,1 jmp .fin .bottomarea cmp edi,[vbuflimtop] jb near .nodraw cmp edi,[vbuflimbot] ja near .nodraw mov al,6 mov al,196 sub al,byte[GUIWincoladd] mov [edi],al mov [edi+1],al mov [edi+2],al mov [edi+3],al mov [edi+4],al mov [edi+5],al mov [edi+6],al add al,2 mov [edi+7],al mov ah,0 .fin .nodraw add edi,288 dec ecx dec edx dec esi jnz near .loop ret %macro DrawSlideBarWin 8 ; win#,X,Y start, %4-List Loc, %5-List size, %6-Screen size, %7-Bar Size mov ebx,%5 mov ecx,%4 ; if (Screen Size > List Size) List Size = Screen Size cmp ebx,%6 jae %%noscrbig mov ebx,%6 %%noscrbig ; If (ListLoc + ScreenSize > ListSize) ListLoc = ListSize - ScreenSize mov eax,ecx add eax,%6 cmp eax,ebx jbe %%nosetlloc mov ecx,ebx sub ecx,%6 %%nosetlloc ; Scrollbarsize = (Screen Size/List size)*Bar Size push ebx mov eax,%6 mov ebx,%7 mul ebx pop ebx div ebx ; If (Scrollbarsize < 5) Scrollbarsize = 5 cmp eax,5 jae %%validscroll mov eax,5 %%validscroll ; StartY = (Bar Size-Scrollbarsize)*(List Loc/(List size-ScreenSize)) push eax sub eax,%7 neg eax mul ecx sub ebx,%6 cmp ebx,0 je %%zero div ebx jmp %%notzero %%zero xor eax,eax %%notzero mov edx,eax pop eax mov ecx,eax add ecx,edx ; ecx = endy, edx = starty mov esi,%7 sub esi,ecx add esi,edx dec esi mov [%8],esi mov [%8+4],edx mov [%8+8],ecx mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add eax,%2 add ebx,%3 mov esi,%7 call GUIDrawSlideBar %endmacro zsnes-1.36/src/gui/guiwindp.inc0100644000175000017500000051077607473170547016116 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Window Display Routines ; Last button value used = 65 GUIStringGreater: ; compares string at esi to edi and returns 1 to al if esi is >, else 0 push esi cmp word[esi],'.' je .less cmp word[esi+32],'.' je .greater cmp word[esi],'..' je .less cmp word[esi+32],'..' je .greater .nextchar cmp byte[esi],0 je .less cmp byte[esi+32],0 je .greater mov al,[esi] mov cl,[esi+32] cmp al,'a' jb .noucase1 cmp al,'z' ja .noucase1 sub al,'z'-'Z' .noucase1 cmp cl,'a' jb .noucase2 cmp cl,'z' ja .noucase2 sub cl,'z'-'Z' .noucase2 cmp al,cl jb .less ja .greater inc esi jmp .nextchar .less mov al,0 jmp .skip .greater mov al,1 .skip pop esi ret GUIStringGreater2: ; compares string at ebx to edx and returns 1 to al if esi is >, else 0 push edx push ebx cmp word[ebx],'.' je .less cmp word[edx],'.' je .greater cmp word[ebx],'..' je .less cmp word[ebx],'..' je .greater .nextchar cmp byte[ebx],0 je .less cmp byte[edx],0 je .greater mov al,[ebx] mov cl,[edx] cmp al,'a' jb .noucase1 cmp al,'z' ja .noucase1 sub al,'z'-'Z' .noucase1 cmp cl,'a' jb .noucase2 cmp cl,'z' ja .noucase2 sub cl,'z'-'Z' .noucase2 cmp al,cl jb .less ja .greater inc ebx inc edx jmp .nextchar .less mov al,0 jmp .skip .greater mov al,1 .skip pop ebx pop edx ret %Macro DrawGUILineSc 2 mov dword[GUIcolscaleval],%2 mov edx,%1 push eax push ecx call GUIHLines pop ecx pop eax inc ebx %Endmacro %Macro DrawGUILine 0 push eax push ecx call GUIHLine pop ecx pop eax inc ebx %Endmacro %macro DrawTitleBar 0 mov edx,46+157+6 sub edx,[GUIWincoladd] DrawGUILine mov edx,42+157+4+4 sub edx,[GUIWincoladd] DrawGUILine dec edx DrawGUILine dec edx DrawGUILine dec edx DrawGUILine dec edx DrawGUILine dec edx DrawGUILine dec edx DrawGUILine dec edx DrawGUILine mov edx,38+157+4 sub edx,[GUIWincoladd] DrawGUILine sub ebx,10 mov edx,44+157+4 sub edx,[GUIWincoladd] mov esi,9 push ecx mov ecx,eax %%loop2 DrawGUILine dec esi jnz %%loop2 pop ecx sub ebx,8 mov edx,40+157+4 sub edx,[GUIWincoladd] mov esi,9 push eax mov eax,ecx %%loop3 DrawGUILine dec esi jnz %%loop3 pop eax %endmacro %macro drawshadow2 3 mov edx,[GUIwinposy+%1*4] cmp edx,223 jg near .noshadow cmp edx,0 jge .noshadclip mov edx,0 .noshadclip mov ebx,edx add ebx,%3 add ebx,9 cmp ebx,0 jl near .noshadow cmp ebx,223 jng .noshadclip2 mov ebx,223 .noshadclip2 sub ebx,edx inc ebx mov edi,edx shl edi,8 mov eax,edx shl eax,5 add edi,eax mov edx,[GUIwinposx+%1*4] mov ecx,edx cmp edx,255 jg .noshadow cmp edx,-3 jnl .noshadclip3 mov edx,-3 .noshadclip3 add ecx,%2 cmp ecx,0 jl .noshadow cmp ecx,255 jng .noshadclip4 mov ecx,255 .noshadclip4 sub ecx,edx inc ecx add edi,edx add edi,[vidbuffer] add edi,288*3+3+16 call GUIDrawShadow2 .noshadow %endmacro %macro GUIDrawWindowBox 2 mov dword[GUIWincoladd],4 mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone mov dword[GUIWincol],148+5 .noone cmp byte[cwindrawn],0 jne .nozero mov dword[GUIWincoladd],0 mov dword[GUIWincol],148 .nozero drawshadow2 %1,dword[GUIwinsizex+%1*4],dword[GUIwinsizey+%1*4] mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] mov ecx,eax add ecx,dword[GUIwinsizex+%1*4] DrawTitleBar mov esi,dword[GUIwinsizey+%1*4] dec esi mov edx,dword[GUIWincol] add edx,2 .loop DrawGUILine dec esi jnz .loop mov edx,dword[GUIWincol] DrawGUILine mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add ebx,10 mov ecx,eax mov esi,dword[GUIwinsizey+%1*4] mov edx,dword[GUIWincol] add edx,3 dec esi .loop2 DrawGUILine dec esi jnz .loop2 mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add ebx,10 add eax,dword[GUIwinsizex+%1*4] mov ecx,eax mov esi,dword[GUIwinsizey+%1*4] mov edx,dword[GUIWincol] add edx,1 .loop3 DrawGUILine dec esi jnz .loop3 mov ebx,dword[GUIwinposy+%1*4] add ebx,3 mov edx,dword[GUIwinposx+%1*4] add edx,3 mov byte[GUItextcolor],184 GUIOuttextwin %2 mov ebx,dword[GUIwinposy+%1*4] add ebx,2 mov edx,dword[GUIwinposx+%1*4] add edx,2 mov byte[GUItextcolor],220 cmp byte[GUIWincoladd],0 je .zero2 sub byte[GUItextcolor],6 .zero2 GUIOuttextwin %2 mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add eax,dword[GUIwinsizex+%1*4] sub eax,10 GUIDisplayIcon GUIIconDataClose %endmacro %macro DrawGUIWinBox 6 mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add eax,%2 add ebx,%3 mov ecx,eax add ecx,%4-%2+1 mov dl,%6 mov esi,%5-%3+1 %%loop DrawGUILine dec esi jnz %%loop %endmacro %macro DrawGUIWinBox2 5 mov eax,dword[GUIwinposx+%1*4] add eax,%2 mov ecx,eax add ecx,%3-%2+1 mov dl,%5 cmp byte[GUIWincoladd],0 je %%zero inc dl %%zero mov esi,%4 add ebx,dword[GUIwinposy+%1*4] %%loop DrawGUILine dec esi jnz %%loop %endmacro %macro DrawGUIWinBox3 6 mov ecx,%4 mov eax,dword[GUIwinposx+%1*4] mov ebx,dword[GUIwinposy+%1*4] add eax,%2 add ebx,%3 add ecx,eax sub ecx,%2 inc ecx mov dl,%6 mov esi,%5-%3+1 %%loop DrawGUILine dec esi jnz %%loop %endmacro %macro DrawGUIButton 9 mov dl,byte[GUItextcolor] sub dl,5 cmp byte[GUICBHold],%7 jne %%noa sub dl,13 %%noa DrawGUIWinBox %1,%2,%3,%4,%3,dl sub dl,3 cmp byte[GUICBHold],%7 jne %%nob add dl,5 %%nob DrawGUIWinBox %1,%2,%3,%2,%5,dl sub dl,3 cmp byte[GUICBHold],%7 jne %%noc add dl,5 %%noc DrawGUIWinBox %1,%2+1,%3+1,%4-2,%5-2,dl sub dl,3 cmp byte[GUICBHold],%7 jne %%nod add dl,5 %%nod DrawGUIWinBox %1,%4+1,%3+1,%4-2,%5-2,dl sub dl,3 cmp byte[GUICBHold],%7 jne %%noe add dl,5 %%noe DrawGUIWinBox %1,%2,%5,%4-1,%5,dl cmp byte[GUICBHold],%7 je near %%no2 sub byte[GUItextcolor],15 GUIOuttextwin2 %1,%2+5+%8,%3+4+%9,%6 add byte[GUItextcolor],15 GUIOuttextwin2 %1,%2+4+%8,%3+3+%9,%6 jmp %%yes %%no2 sub byte[GUItextcolor],18 GUIOuttextwin2 %1,%2+6+%8,%3+5+%9,%6 add byte[GUItextcolor],15 GUIOuttextwin2 %1,%2+5+%8,%3+4+%9,%6 add byte[GUItextcolor],3 %%yes %endmacro %macro GUIOuttextwin2load 3 test dword[cloadnleft],80000000h jnz %%skip cmp byte[GUIloadfntype],0 jne %%nottype0 mov eax,[cloadnposb] mov eax,[spcRamcmp+eax*4] inc eax mov [cloadnpos],eax inc dword[cloadnposb] %%nottype0 GUIOuttextwin2l %1,%2,%3,[cloadnpos] add dword[cloadnpos],32 dec dword[cloadnleft] %%skip %endmacro %macro GUIDisplayButtonHole 5 mov dword[GUITemp],GUIIconDataButtonHole cmp %4,%5 jne %%nofill mov dword[GUITemp],GUIIconDataButtonFill %%nofill GUIDisplayIconWin %1,%2,%3,[GUITemp] %endmacro ; DGUIDisplay DisplayGUILoad: GUIDrawWindowBox 1,GUILoadDisp cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 ; cmp byte[OSPort],2 ; jae near .noloadtypeb %ifdef __MSDOS__ GUIOuttextwin2 1,21,166,GUILoadText3 GUIOuttextwin2 1,21,174,GUILoadText4 GUIOuttextwin2 1,21,182,GUILoadText5 %endif .noloadtypeb GUIOuttextwin2 1,21,192,GUILoadText6 GUIOuttextwin2 1,6,16,GUILoadText7 GUIOuttextwin2 1,161,16,GUILoadText8 GUIOuttextwin2 1,6,138,GUIcurrentdir GUIOuttextwin2 1,146,172,GUILoadTextB GUIOuttextwin2 1,155,182,GUILoadTextC GUIOuttextwin2 1,155,192,GUILoadTextD GUIOuttextwin2 1,195,182,GUILoadTextE GUIOuttextwin2 1,195,192,GUILoadTextF mov dword[cloadmaxlen],39 cmp dword[GUIcurrentfilewin],0 jne .nofiles ; cmp byte[OSPort],2 ; jb .nofiles %ifndef __MSDOS__ mov eax,[GUIcurrentcursloc] mov eax,[spcRamcmp+eax*4] inc eax mov [cloadnpos],eax GUIOuttextwin2l 1,6,158,[cloadnpos] %endif .nofiles add byte[GUItextcolor],15 ; cmp byte[OSPort],2 ; jae near .noloadtypec %ifdef __MSDOS__ GUIOuttextwin2 1,20,165,GUILoadText3 GUIOuttextwin2 1,20,173,GUILoadText4 GUIOuttextwin2 1,20,181,GUILoadText5 %endif .noloadtypec GUIOuttextwin2 1,20,191,GUILoadText6 GUIOuttextwin2 1,5,15,GUILoadText7 GUIOuttextwin2 1,160,15,GUILoadText8 GUIOuttextwin2 1,5,137,GUIcurrentdir GUIOuttextwin2 1,145,171,GUILoadTextB GUIOuttextwin2 1,154,181,GUILoadTextC GUIOuttextwin2 1,154,191,GUILoadTextD GUIOuttextwin2 1,194,181,GUILoadTextE GUIOuttextwin2 1,194,191,GUILoadTextF mov dword[cloadmaxlen],39 cmp dword[GUIcurrentfilewin],0 jne .nofilesb ; cmp byte[OSPort],2 ; jb .nofilesb %ifndef __MSDOS__ mov eax,[GUIcurrentcursloc] mov eax,[spcRamcmp+eax*4] inc eax mov [cloadnpos],eax GUIOuttextwin2l 1,5,157,[cloadnpos] %endif .nofilesb DrawGUIButton 1,186,165,228,176,GUILoadText9,1,0,0 mov al,[GUIWincol] mov byte[GUItextcolor],al ; GUIOuttextwin2 1,6,16,GUILoadText1 ; cmp byte[OSPort],2 ; jae near .noloadtypee %ifdef __MSDOS__ GUIOuttextwin2 1,6,157,GUILoadText2 %endif .noloadtypee mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 ; GUIOuttextwin2 1,5,15,GUILoadText1 ; cmp byte[OSPort],2 ; jae near .noloadtyped %ifdef __MSDOS__ GUIOuttextwin2 1,5,156,GUILoadText2 %endif .noloadtyped DrawGUIWinBox 1,5,25,144,134,167 ; 126 = 6 * 21, 112 = 7 * 16 DrawGUIWinBox 1,160,25,228,134,167 ; 78 = 6 * 13 DrawGUIWinBox 1,5,145,228,152,167 ; 126 = 6 * 21, 112 = 7 * 16 xor ebx,ebx mov bl,[GUILoadPos] mov byte[GUILoadTextA+ebx],0 test byte[GUILDFlash],8 jnz .nound mov byte[GUILoadTextA+ebx],'_' mov byte[GUILoadTextA+ebx+1],0 .nound mov ebx,[GUIcurrentcursloc] sub ebx,[GUIcurrentviewloc] cmp dword[GUIcurrentfilewin],0 je .files mov ebx,[GUIcurrentdircursloc] sub ebx,[GUIcurrentdirviewloc] .files mov eax,ebx lea ebx,[ebx*4] add ebx,eax add ebx,eax add ebx,eax add ebx,27 cmp dword[GUIcurrentfilewin],0 jne .dir DrawGUIWinBox2 1,5,144,7,224 jmp .files2 .dir DrawGUIWinBox2 1,160,228,7,224 .files2 mov byte[GUItextcolor],223 GUIOuttextwin2 1,8,148, GUILoadTextA mov eax,[spcBuffera] inc eax mov dword[cloadnpos],eax mov eax,[GUIfileentries] sub eax,[GUIcurrentviewloc] dec eax mov dword[cloadnleft],eax mov eax,[GUIcurrentviewloc] mov [cloadnposb],eax shl eax,5 add [cloadnpos],eax mov dword[cloadmaxlen],23 GUIOuttextwin2load 1,8,29 GUIOuttextwin2load 1,8,29+7 GUIOuttextwin2load 1,8,29+7*2 GUIOuttextwin2load 1,8,29+7*3 GUIOuttextwin2load 1,8,29+7*4 GUIOuttextwin2load 1,8,29+7*5 GUIOuttextwin2load 1,8,29+7*6 GUIOuttextwin2load 1,8,29+7*7 GUIOuttextwin2load 1,8,29+7*8 GUIOuttextwin2load 1,8,29+7*9 GUIOuttextwin2load 1,8,29+7*10 GUIOuttextwin2load 1,8,29+7*11 GUIOuttextwin2load 1,8,29+7*12 GUIOuttextwin2load 1,8,29+7*13 GUIOuttextwin2load 1,8,29+7*14 mov eax,[spcBuffera] inc eax mov dword[cloadnpos],eax mov eax,[GUIdirentries] sub eax,[GUIcurrentdirviewloc] dec eax mov dword[cloadnleft],eax mov eax,[GUIcurrentdirviewloc] add eax,[GUIfileentries] mov [cloadnposb],eax shl eax,5 add [cloadnpos],eax mov dword[cloadmaxlen],11 GUIOuttextwin2load 1,164,29 GUIOuttextwin2load 1,164,29+7 GUIOuttextwin2load 1,164,29+7*2 GUIOuttextwin2load 1,164,29+7*3 GUIOuttextwin2load 1,164,29+7*4 GUIOuttextwin2load 1,164,29+7*5 GUIOuttextwin2load 1,164,29+7*6 GUIOuttextwin2load 1,164,29+7*7 GUIOuttextwin2load 1,164,29+7*8 GUIOuttextwin2load 1,164,29+7*9 GUIOuttextwin2load 1,164,29+7*10 GUIOuttextwin2load 1,164,29+7*11 GUIOuttextwin2load 1,164,29+7*12 GUIOuttextwin2load 1,164,29+7*13 GUIOuttextwin2load 1,164,29+7*14 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 GUIOuttextwin2 1,7,147, GUILoadTextA mov eax,[spcBuffera] inc eax mov dword[cloadnpos],eax mov eax,[GUIfileentries] sub eax,[GUIcurrentviewloc] dec eax mov dword[cloadnleft],eax mov eax,[GUIcurrentviewloc] mov [cloadnposb],eax shl eax,5 add [cloadnpos],eax mov dword[cloadmaxlen],23 GUIOuttextwin2load 1,7,28 GUIOuttextwin2load 1,7,28+7 GUIOuttextwin2load 1,7,28+7*2 GUIOuttextwin2load 1,7,28+7*3 GUIOuttextwin2load 1,7,28+7*4 GUIOuttextwin2load 1,7,28+7*5 GUIOuttextwin2load 1,7,28+7*6 GUIOuttextwin2load 1,7,28+7*7 GUIOuttextwin2load 1,7,28+7*8 GUIOuttextwin2load 1,7,28+7*9 GUIOuttextwin2load 1,7,28+7*10 GUIOuttextwin2load 1,7,28+7*11 GUIOuttextwin2load 1,7,28+7*12 GUIOuttextwin2load 1,7,28+7*13 GUIOuttextwin2load 1,7,28+7*14 mov eax,[spcBuffera] inc eax mov dword[cloadnpos],eax mov eax,[GUIdirentries] sub eax,[GUIcurrentdirviewloc] dec eax mov dword[cloadnleft],eax mov eax,[GUIcurrentdirviewloc] add eax,[GUIfileentries] mov [cloadnposb],eax shl eax,5 add [cloadnpos],eax mov dword[cloadmaxlen],11 GUIOuttextwin2load 1,163,28 GUIOuttextwin2load 1,163,28+7 GUIOuttextwin2load 1,163,28+7*2 GUIOuttextwin2load 1,163,28+7*3 GUIOuttextwin2load 1,163,28+7*4 GUIOuttextwin2load 1,163,28+7*5 GUIOuttextwin2load 1,163,28+7*6 GUIOuttextwin2load 1,163,28+7*7 GUIOuttextwin2load 1,163,28+7*8 GUIOuttextwin2load 1,163,28+7*9 GUIOuttextwin2load 1,163,28+7*10 GUIOuttextwin2load 1,163,28+7*11 GUIOuttextwin2load 1,163,28+7*12 GUIOuttextwin2load 1,163,28+7*13 GUIOuttextwin2load 1,163,28+7*14 xor ebx,ebx mov bl,[GUILoadPos] mov byte[GUILoadTextA+ebx],0 ; cmp byte[OSPort],2 ; jae near .noloadtype %ifdef __MSDOS__ GUIDisplayButtonHole 1,9,163,byte[GUIloadfntype],0 GUIDisplayButtonHole 1,9,171,byte[GUIloadfntype],1 GUIDisplayButtonHole 1,9,179,byte[GUIloadfntype],2 %endif .noloadtype mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[showallext],1 jne .noshowallext mov dword[GUITemp],GUIIconDataCheckBoxC .noshowallext GUIDisplayIconWin 1,10,187,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[ForceROMTiming],1 jne .noforcentsc mov dword[GUITemp],GUIIconDataCheckBoxC .noforcentsc GUIDisplayIconWin 1,144,177,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[ForceROMTiming],2 jne .noforcepal mov dword[GUITemp],GUIIconDataCheckBoxC .noforcepal GUIDisplayIconWin 1,144,187,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[ForceHiLoROM],1 jne .noforcelorom mov dword[GUITemp],GUIIconDataCheckBoxC .noforcelorom GUIDisplayIconWin 1,184,177,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[ForceHiLoROM],2 jne .noforcehirom mov dword[GUITemp],GUIIconDataCheckBoxC .noforcehirom GUIDisplayIconWin 1,184,187,[GUITemp] ; win#,X,Y start, %4-List Loc, %5-List size, %6-Screen size, %7-Bar Size DrawSlideBarWin 1,146,33,[GUIcurrentviewloc],[GUIfileentries],15,94,GUILStA cmp byte[GUICHold],1 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin 1,146,25,GUIIconDataUpArrow cmp byte[GUICHold],1 jne .noholda2 sub byte[GUIWincoladd],3 .noholda2 cmp byte[GUICHold],2 jne .noholdb add byte[GUIWincoladd],3 .noholdb GUIDisplayIconWin 1,146,127,GUIIconDataDownArrow cmp byte[GUICHold],2 jne .noholdb2 sub byte[GUIWincoladd],3 .noholdb2 DrawSlideBarWin 1,230,33,[GUIcurrentdirviewloc],[GUIdirentries],15,94,GUILStB cmp byte[GUICHold],3 jne .noholdc add byte[GUIWincoladd],3 .noholdc GUIDisplayIconWin 1,230,25,GUIIconDataUpArrow cmp byte[GUICHold],3 jne .noholdc2 sub byte[GUIWincoladd],3 .noholdc2 cmp byte[GUICHold],4 jne .noholdd add byte[GUIWincoladd],3 .noholdd GUIDisplayIconWin 1,230,127,GUIIconDataDownArrow cmp byte[GUICHold],4 jne .noholdd2 sub byte[GUIWincoladd],3 .noholdd2 ; Draw borders mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 1,5,24,144,24,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 1,4,25,3,134,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 1,5,135,144,135,dl mov dl,[GUIWincol] DrawGUIWinBox 1,160,24,228,24,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 1,159,25,158,134,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 1,160,135,228,135,dl mov dl,[GUIWincol] DrawGUIWinBox 1,5,144,228,144,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 1,4,144,3,152,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 1,5,153,228,153,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 1,229,144,228,152,dl ret GUILoadText1 db 'SELECT FILE TO LOAD :',0 GUILoadText2 db 'DISPLAY TYPE :',0 GUILoadText3 db 'NORMAL 8.3 FORMAT',0 GUILoadText4 db 'SNES HEADER NAME',0 GUILoadText5 db 'WIN95 LONG FILENAME',0 GUILoadText6 db 'SHOW ALL EXTENSIONS',0 GUILoadText7 db 'FILENAME',0 GUILoadText8 db 'DIRECTORY',0 GUILoadText9 db 'LOAD',0 GUILoadTextA times 40 db 0 GUILoadTextB db 'FORCE',0 GUILoadTextC db 'NTSC',0 GUILoadTextD db 'PAL',0 GUILoadTextE db 'LOROM',0 GUILoadTextF db 'HIROM',0 GUILStA dd 0,0,0 GUILStB dd 0,0,0 GUILoadPos db 0 DisplayGUIReset: GUIDrawWindowBox 12,GUIResetDisp cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero mov dl,224 cmp byte[GUIWincoladd],0 je .zero4 inc dl .zero4 cmp byte[GUICResetPos],0 je near .resetboxa DrawGUIWinBox 12,79,29,117,42,dl jmp .resetboxb .resetboxa DrawGUIWinBox 12,19,29,57,42,dl .resetboxb DrawGUIButton 12,20,30,56,41,GUIResetText2,2,0,0 DrawGUIButton 12,80,30,116,41,GUIResetText3,3,0,0 mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 12,6,16,GUIResetText1 mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 12,5,15,GUIResetText1 ret GUIResetText1 db 'RESET : ARE YOU SURE ?',0 GUIResetText2 db 'YES',0 GUIResetText3 db 'NO',0 DisplayGUIStates: GUIDrawWindowBox 14,GUIStatesDisp cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero mov dl,224 cmp byte[GUIWincoladd],0 je .zero4 inc dl .zero4 cmp byte[GUICStatePos],0 je near .resetboxa DrawGUIWinBox 14,79,29,117,42,dl jmp .resetboxb .resetboxa DrawGUIWinBox 14,19,29,57,42,dl .resetboxb DrawGUIButton 14,20,30,56,41,GUIStatesText3,10,0,0 DrawGUIButton 14,80,30,116,41,GUIStatesText4,11,0,0 mov al,[GUIWincol] mov byte[GUItextcolor],al cmp byte[GUIStatesText5],1 je .load GUIOuttextwin2 14,6,16,GUIStatesText1 jmp .save .load GUIOuttextwin2 14,6,16,GUIStatesText2 .save mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 cmp byte[GUIStatesText5],1 je .load2 GUIOuttextwin2 14,5,15,GUIStatesText1 jmp .save2 .load2 GUIOuttextwin2 14,5,15,GUIStatesText2 .save2 ret GUIStatesText1 db 'OKAY TO SAVE STATE?',0 GUIStatesText2 db 'OKAY TO LOAD STATE?',0 GUIStatesText3 db 'YES',0 GUIStatesText4 db 'NO',0 GUIStatesText5 db 0 DisplayGUIChoseSave: GUIDrawWindowBox 2,GUIStateSelDisp cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 mov byte[GUIChoseSaveText2],'0' GUIOuttextwin2 2,21,31,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'1' GUIOuttextwin2 2,41,31,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'2' GUIOuttextwin2 2,61,31,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'3' GUIOuttextwin2 2,81,31,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'4' GUIOuttextwin2 2,101,31,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'5' GUIOuttextwin2 2,21,46,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'6' GUIOuttextwin2 2,41,46,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'7' GUIOuttextwin2 2,61,46,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'8' GUIOuttextwin2 2,81,46,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'9' GUIOuttextwin2 2,101,46,GUIChoseSaveText2 add byte[GUItextcolor],15 mov byte[GUIChoseSaveText2],'0' GUIOuttextwin2 2,20,30,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'1' GUIOuttextwin2 2,40,30,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'2' GUIOuttextwin2 2,60,30,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'3' GUIOuttextwin2 2,80,30,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'4' GUIOuttextwin2 2,100,30,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'5' GUIOuttextwin2 2,20,45,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'6' GUIOuttextwin2 2,40,45,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'7' GUIOuttextwin2 2,60,45,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'8' GUIOuttextwin2 2,80,45,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'9' GUIOuttextwin2 2,100,45,GUIChoseSaveText2 mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 2,6,16,GUIChoseSaveText1 mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 2,5,15,GUIChoseSaveText1 mov dword[GUITemp],GUIIconDataButtonHole mov ebx,[statefileloc] mov al,byte[fnamest+ebx] mov [GUIChoseSaveText2],al GUIDisplayButtonHole 2,10,28,byte[GUIChoseSaveText2],'t' GUIDisplayButtonHole 2,30,28,byte[GUIChoseSaveText2],'1' GUIDisplayButtonHole 2,50,28,byte[GUIChoseSaveText2],'2' GUIDisplayButtonHole 2,70,28,byte[GUIChoseSaveText2],'3' GUIDisplayButtonHole 2,90,28,byte[GUIChoseSaveText2],'4' GUIDisplayButtonHole 2,10,43,byte[GUIChoseSaveText2],'5' GUIDisplayButtonHole 2,30,43,byte[GUIChoseSaveText2],'6' GUIDisplayButtonHole 2,50,43,byte[GUIChoseSaveText2],'7' GUIDisplayButtonHole 2,70,43,byte[GUIChoseSaveText2],'8' GUIDisplayButtonHole 2,90,43,byte[GUIChoseSaveText2],'9' ret GUIChoseSaveText1 db 'SELECT SAVE SLOT :',0 GUIChoseSaveText2 db '-',0 %macro DGOptnsDrawBox 3 mov eax,dword[GUIwinposx+9*4] mov ebx,dword[GUIwinposy+9*4] add eax,%1 add ebx,%2 mov ecx,eax add ecx,20 mov dl,167 mov esi,7 %%loop DrawGUILine dec esi jnz %%loop mov eax,%3 mov ebx,[ScanCodeListing+eax*3] mov [GUIGameDisplayKy],ebx mov byte[GUIGameDisplayKy+3],0 mov byte[GUItextcolor],223 GUIOuttextwin2 9,%1+3,%2+2,GUIGameDisplayKy mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je %%zero mov byte[GUItextcolor],222 %%zero GUIOuttextwin2 9,%1+2,%2+1,GUIGameDisplayKy %endmacro %macro DGOptnsDrawBox2 3 mov eax,dword[GUIwinposx+3*4] mov ebx,dword[GUIwinposy+3*4] add eax,%1 add ebx,%2 mov ecx,eax add ecx,20 mov dl,167 mov esi,7 %%loop DrawGUILine dec esi jnz %%loop mov eax,%3 mov ebx,[ScanCodeListing+eax*3] mov [GUIGameDisplayKy],ebx mov byte[GUIGameDisplayKy+3],0 mov byte[GUItextcolor],223 GUIOuttextwin2 3,%1+3,%2+2,GUIGameDisplayKy mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je %%zero mov byte[GUItextcolor],222 %%zero GUIOuttextwin2 3,%1+2,%2+1,GUIGameDisplayKy %endmacro %macro GUIInputDispKey 2 mov eax,[edi] mov [GUIInputTextQ],eax push edi DGOptnsDrawBox2 %1,%2,[GUIInputTextQ] pop edi add edi,4 %endmacro DisplayGUIInput: ; Player Select, Joystick/keyboard Type List, Button Assignments GUIDrawWindowBox 3,GUIInputDisp cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 GUIOuttextwin2 3,6,102,GUIInputText3 GUIOuttextwin2 3,6,112,GUIInputText4 GUIOuttextwin2 3,6,122,GUIInputText5 GUIOuttextwin2 3,6,132,GUIInputText6 GUIOuttextwin2 3,6,142,GUIInputTextD GUIOuttextwin2 3,6,152,GUIInputTextE GUIOuttextwin2 3,76,102,GUIInputText7 GUIOuttextwin2 3,76,112,GUIInputText8 GUIOuttextwin2 3,76,122,GUIInputText9 GUIOuttextwin2 3,76,132,GUIInputTextA GUIOuttextwin2 3,76,142,GUIInputTextB GUIOuttextwin2 3,76,152,GUIInputTextC %ifdef __MSDOS__ GUIOuttextwin2 3,20,167,GUIInputTextW %endif GUIOuttextwin2 3,156,102,GUIInputText7 GUIOuttextwin2 3,156,112,GUIInputText8 GUIOuttextwin2 3,156,122,GUIInputTextC GUIOuttextwin2 3,116,102,GUIInputText9 GUIOuttextwin2 3,116,112,GUIInputTextA GUIOuttextwin2 3,116,122,GUIInputTextB GUIOuttextwin2 3,153,142,GUIInputTextd GUIOuttextwin2 3,153,152,GUIInputTexte GUIOuttextwin2 3,113,142,GUIInputTextf GUIOuttextwin2 3,113,152,GUIInputTextg add byte[GUItextcolor],15 GUIOuttextwin2 3,5,101,GUIInputText3 GUIOuttextwin2 3,5,111,GUIInputText4 GUIOuttextwin2 3,5,121,GUIInputText5 GUIOuttextwin2 3,5,131,GUIInputText6 GUIOuttextwin2 3,5,141,GUIInputTextD GUIOuttextwin2 3,5,151,GUIInputTextE GUIOuttextwin2 3,75,101,GUIInputText7 GUIOuttextwin2 3,75,111,GUIInputText8 GUIOuttextwin2 3,75,121,GUIInputText9 GUIOuttextwin2 3,75,131,GUIInputTextA GUIOuttextwin2 3,75,141,GUIInputTextB GUIOuttextwin2 3,75,151,GUIInputTextC %ifdef __MSDOS__ GUIOuttextwin2 3,19,166,GUIInputTextW %endif GUIOuttextwin2 3,155,101,GUIInputText7 GUIOuttextwin2 3,155,111,GUIInputText8 GUIOuttextwin2 3,155,121,GUIInputTextC GUIOuttextwin2 3,115,101,GUIInputText9 GUIOuttextwin2 3,115,111,GUIInputTextA GUIOuttextwin2 3,115,121,GUIInputTextB GUIOuttextwin2 3,152,141,GUIInputTextd GUIOuttextwin2 3,152,151,GUIInputTexte GUIOuttextwin2 3,112,141,GUIInputTextf GUIOuttextwin2 3,112,151,GUIInputTextg %ifdef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC xor eax,eax mov al,[cplayernum] cmp byte[pl1p209+eax],0 je .nocheckbox2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox2 GUIDisplayIconWin 3,5,162,[GUITemp] %endif DrawGUIButton 3,125,34,155,45,GUIInputTextV,14,0,0 ; cmp byte[OSPort],3 ; je near .win32 %ifdef __MSDOS__ DrawGUIButton 3,125,50,185,61,GUIInputTexta,15,0,0 %endif .win32 DrawGUIButton 3,125,66,179,77,GUIInputTexta2,15,0,0 mov al,[GUIWincol] mov byte[GUItextcolor],al mov al,[cplayernum] add al,'1' mov [GUIInputText1+8],al GUIOuttextwin2 3,6,16,GUIInputText1 GUIOuttextwin2 3,6,26,GUIInputText2 GUIOuttextwin2 3,6,92,GUIInputTextP GUIOuttextwin2 3,116,92,GUIInputTextb GUIOuttextwin2 3,116,131,GUIInputTextc xor eax,eax mov al,[cplayernum] mov ebx,[GUIInputRefP+eax*4] mov al,[ebx] mov al,[GUIInputRefB+eax] mov ebx,eax shl eax,4 add eax,ebx add eax,GUIInputNames mov dword[GUITemp],eax GUIOuttextwin2 3,7+24,83,[GUITemp] GUIOuttextwin2 3,7,83,GUIInputTextT mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 3,5,15,GUIInputText1 GUIOuttextwin2 3,5,25,GUIInputText2 GUIOuttextwin2 3,5,91,GUIInputTextP GUIOuttextwin2 3,115,91,GUIInputTextb GUIOuttextwin2 3,115,130,GUIInputTextc GUIOuttextwin2 3,6+24,82,[GUITemp] GUIOuttextwin2 3,6,82,GUIInputTextT DrawGUIWinBox 3,5,34,107,77,167 mov ebx,[GUIcurrentinputcursloc] sub ebx,[GUIcurrentinputviewloc] mov eax,ebx lea ebx,[ebx*8] add ebx,36 DrawGUIWinBox2 3,5,107,7,224 mov edi,pl1selk cmp byte[cplayernum],1 jne .nopl2 mov edi,pl2selk .nopl2 cmp byte[cplayernum],2 jne .nopl3 mov edi,pl3selk .nopl3 cmp byte[cplayernum],3 jne .nopl4 mov edi,pl4selk .nopl4 cmp byte[cplayernum],4 jne .nopl5 mov edi,pl5selk .nopl5 GUIInputDispKey 45,150 ; Select GUIInputDispKey 45,140 ; Start GUIInputDispKey 45,100 ; Up GUIInputDispKey 45,110 ; Down GUIInputDispKey 45,120 ; Left GUIInputDispKey 45,130 ; Right GUIInputDispKey 85,120 ; X GUIInputDispKey 85,100 ; A GUIInputDispKey 85,140 ; L GUIInputDispKey 85,130 ; Y GUIInputDispKey 85,110 ; B GUIInputDispKey 85,150 ; R mov edi,pl1Atk cmp byte[cplayernum],1 jne .nopl2t mov edi,pl2Atk .nopl2t cmp byte[cplayernum],2 jne .nopl3t mov edi,pl3Atk .nopl3t cmp byte[cplayernum],3 jne .nopl4t mov edi,pl4Atk .nopl4t cmp byte[cplayernum],4 jne .nopl5t mov edi,pl5Atk .nopl5t GUIInputDispKey 165,100 ; A Turbo GUIInputDispKey 165,110 ; B Turbo GUIInputDispKey 125,100 ; X Turbo GUIInputDispKey 125,110 ; Y Turbo mov edi,pl1Ltk cmp byte[cplayernum],1 jne .nopl2tl mov edi,pl2Ltk .nopl2tl cmp byte[cplayernum],2 jne .nopl3tl mov edi,pl3Ltk .nopl3tl cmp byte[cplayernum],3 jne .nopl4tl mov edi,pl4Ltk .nopl4tl cmp byte[cplayernum],4 jne .nopl5tl mov edi,pl5Ltk .nopl5tl GUIInputDispKey 125,120 ; L Turbo GUIInputDispKey 165,120 ; R Turbo mov edi,pl1ULk cmp byte[cplayernum],1 jne .nopl2tb mov edi,pl2ULk .nopl2tb cmp byte[cplayernum],2 jne .nopl3tb mov edi,pl3ULk .nopl3tb cmp byte[cplayernum],3 jne .nopl4tb mov edi,pl4ULk .nopl4tb cmp byte[cplayernum],4 jne .nopl5tb mov edi,pl5ULk .nopl5tb GUIInputDispKey 165,140 ; Up-Left GUIInputDispKey 165,150 ; Up-Right GUIInputDispKey 125,140 ; Down-Left GUIInputDispKey 125,150 ; Down-Right mov byte[GUItextcolor],223 mov eax,[GUIcurrentinputviewloc] shl eax,4 add eax,[GUIcurrentinputviewloc] add eax,GUIInputNames mov dword[GUITemp],eax GUIOuttextwin2 3,11,38,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,11,38+8,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,11,38+8*2,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,11,38+8*3,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,11,38+8*4,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],222 .zero5 mov eax,[GUIcurrentinputviewloc] shl eax,4 add eax,[GUIcurrentinputviewloc] add eax,GUIInputNames mov dword[GUITemp],eax GUIOuttextwin2 3,10,37,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,10,37+8,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,10,37+8*2,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,10,37+8*3,[GUITemp] add dword[GUITemp],17 GUIOuttextwin2 3,10,37+8*4,[GUITemp] DrawSlideBarWin 3,109,42,[GUIcurrentinputviewloc],[NumInputDevices],5,28,GUIIStA cmp byte[GUICHold],9 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin 3,109,34,GUIIconDataUpArrow cmp byte[GUICHold],9 jne .noholda2 sub byte[GUIWincoladd],3 .noholda2 cmp byte[GUICHold],10 jne .noholdb add byte[GUIWincoladd],3 .noholdb GUIDisplayIconWin 3,109,70,GUIIconDataDownArrow cmp byte[GUICHold],10 jne .noholdb2 sub byte[GUIWincoladd],3 .noholdb2 ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 3,5,33,107,33,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 3,4,34,3,77,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 3,5,78,107,78,dl ret GUIInputRefF db 0,1,2,3,5,18,6,7,8,9,10,11,14,15,16,17 GUIInputRefB db 0,1,2,3,3,4,6,7,8,9,10,11,11,11,12,13,14,15,5 GUIInputRefP dd pl1contrl,pl2contrl,pl3contrl,pl4contrl,pl5contrl GUIInputText1 db 'PLAYER # CONTROL :',0 GUIInputText2 db 'DEVICE :',0 GUIInputText3 db ' UP',0 GUIInputText4 db ' DOWN',0 GUIInputText5 db ' LEFT',0 GUIInputText6 db ' RIGHT',0 GUIInputText7 db 'A',0 GUIInputText8 db 'B',0 GUIInputText9 db 'X',0 GUIInputTextA db 'Y',0 GUIInputTextB db 'L',0 GUIInputTextC db 'R',0 GUIInputTextD db ' START',0 GUIInputTextE db 'SELECT',0 GUIInputTextP db 'KEYS :',0 GUIInputTextQ dd 0 GUIInputTextT db 'CDV:',0 GUIInputTextV db 'SET',0 GUIInputTextW db 'USE JOYSTICK PORT 209H',0 GUIInputTexta db 'CALIBRATE',0 GUIInputTexta2 db 'SET KEYS',0 GUIInputTextb db 'TURBO :',0 GUIInputTextc db 'DIAGONALS :',0 GUIInputTextd db 'UL',0 GUIInputTexte db 'UR',0 GUIInputTextf db 'DL',0 GUIInputTextg db 'DR',0 GUIIStA dd 0,0,0 GUIcurrentinputviewloc dd 0 GUIcurrentinputcursloc dd 0 DisplayGUIOption: ; Frame Rate/Auto Frame Rate/Max Frame Skip/New Gfx Engine/Save Confirm GUIDrawWindowBox 4,GUIOptionDisp mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 mov dword[GUITemp],GUIOptionText1 cmp byte[frameskip],0 jne .noauto mov dword[GUITemp],GUIOptionText3 .noauto GUIOuttextwin2 4,6,16,[GUITemp] GUIOuttextwin2u 4,26,31,GUIOptionText2,0 GUIOuttextwin2u 4,26,41,GUIOptionText4,0 GUIOuttextwin2u 4,26,51,GUIOptionText5,2 GUIOuttextwin2u 4,26,61,GUIOptionText6,0 GUIOuttextwin2u 4,26,71,GUIOptionText7,0 %ifdef __MSDOS__ GUIOuttextwin2u 4,26,81,GUIOptionTextA,0 %endif %ifdef __WIN32__ GUIOuttextwin2u 4,26,81,GUIOptionTextAb,0 %endif GUIOuttextwin2u 4,26,91,GUIOptionTextB,0 GUIOuttextwin2u 4,26,101,GUIOptionTextC,2 GUIOuttextwin2u 4,26,111,GUIOptionTextD,12 GUIOuttextwin2u 4,26,121,GUIOptionTextE,2 GUIOuttextwin2u 4,26,131,GUIOptionTextF,1 GUIOuttextwin2u 4,26,141,GUIOptionTextG,0 GUIOuttextwin2u 4,26,151,GUIOptionTextH,9 GUIOuttextwin2u 4,26,161,GUIOptionTextI,15 GUIOuttextwin2u 4,26,171,GUIOptionTextJ,0 %ifdef __WIN32__ GUIOuttextwin2u 4,26,181,GUIOptionTextK,1 GUIOuttextwin2u 4,26,191,GUIOptionTextL,1 %endif add byte[GUItextcolor],15 GUIOuttextwin2 4,5,15,[GUITemp] GUIOuttextwin2 4,25,30,GUIOptionText2 GUIOuttextwin2 4,25,40,GUIOptionText4 GUIOuttextwin2 4,25,50,GUIOptionText5 GUIOuttextwin2 4,25,60,GUIOptionText6 GUIOuttextwin2 4,25,70,GUIOptionText7 %ifdef __MSDOS__ GUIOuttextwin2 4,25,80,GUIOptionTextA %endif %ifdef __WIN32__ GUIOuttextwin2 4,25,80,GUIOptionTextAb %endif GUIOuttextwin2 4,25,90,GUIOptionTextB GUIOuttextwin2 4,25,100,GUIOptionTextC GUIOuttextwin2 4,25,120,GUIOptionTextE GUIOuttextwin2 4,25,110,GUIOptionTextD GUIOuttextwin2 4,25,130,GUIOptionTextF GUIOuttextwin2 4,25,140,GUIOptionTextG GUIOuttextwin2 4,25,150,GUIOptionTextH GUIOuttextwin2 4,25,160,GUIOptionTextI GUIOuttextwin2 4,25,170,GUIOptionTextJ %ifdef __WIN32__ GUIOuttextwin2 4,25,180,GUIOptionTextK GUIOuttextwin2 4,25,190,GUIOptionTextL %endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[frameskip],0 jne .nocheckbox mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox GUIDisplayIconWin 4,11,26,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[newengen],0 je .nocheckbox1 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1 GUIDisplayIconWin 4,11,36,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AutoIncSaveSlot],0 je .nocheckbox2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox2 GUIDisplayIconWin 4,11,46,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[MMXSupport],1 jne .nocheckbox3 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox3 GUIDisplayIconWin 4,11,56,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[pl12s34],0 je .nocheckbox4 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox4 GUIDisplayIconWin 4,11,66,[GUITemp] %ifdef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SidewinderFix],0 je .nocheckbox5 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox5 GUIDisplayIconWin 4,11,76,[GUITemp] %endif %ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[HighPriority],0 je .nocheckbox5 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox5 GUIDisplayIconWin 4,11,76,[GUITemp] %endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[FPSAtStart],0 je .nocheckbox6 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox6 GUIDisplayIconWin 4,11,86,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[Turbo30hz],0 je .nocheckbox7 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox7 GUIDisplayIconWin 4,11,96,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[TimerEnable],0 je .nocheckbox8 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox8 GUIDisplayIconWin 4,11,106,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[FastFwdToggle],0 je .nocheckbox9 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox9 GUIDisplayIconWin 4,11,116,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SRAMSave5Sec],0 je .nocheckbox10 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox10 GUIDisplayIconWin 4,11,126,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[OldGfxMode2],0 je .nocheckbox11 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox11 GUIDisplayIconWin 4,11,136,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[LatestSave],0 je .nocheckbox12 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox12 GUIDisplayIconWin 4,11,146,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AutoState],0 je .nocheckbox13 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox13 GUIDisplayIconWin 4,11,156,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[DontSavePath],0 je .nocheckbox14 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox14 GUIDisplayIconWin 4,11,166,[GUITemp] %ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[DisableScreenSaver],0 je .nocheckbox15 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox15 GUIDisplayIconWin 4,11,176,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AlternateTimer],0 je .nocheckbox16 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox16 GUIDisplayIconWin 4,11,186,[GUITemp] %endif cmp byte[frameskip],0 je near .auto DrawGUIWinBox 4,75,13,93,21,167 mov al,[frameskip] add al,47 mov [GUIOptionText8],al mov byte[GUItextcolor],223 GUIOuttextwin2 4,85,16,GUIOptionText8 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 GUIOuttextwin2 4,84,15,GUIOptionText8 mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero6 mov byte[GUItextcolor],211 .zero6 DrawGUIButton 4,97,12,105,22,GUIOptionText9,12,-2,0 DrawGUIButton 4,108,12,116,22,GUIOptionText10,13,-2,0 ret .auto DrawGUIWinBox 4,96,13,114,21,167 mov al,[maxskip] add al,48 mov [GUIOptionText8],al mov byte[GUItextcolor],223 GUIOuttextwin2 4,107,16,GUIOptionText8 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],222 .zero5 GUIOuttextwin2 4,106,15,GUIOptionText8 mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero7 mov byte[GUItextcolor],211 .zero7 DrawGUIButton 4,118,12,126,22,GUIOptionText9,12,-2,0 DrawGUIButton 4,129,12,137,22,GUIOptionText10,13,-2,0 ret GUIOptionText1 db 'FRAME RATE',0 GUIOptionText2 db 'AUTO FRAME RATE',0 GUIOptionText3 db 'MAX FRAME SKIP',0 GUIOptionText4 db 'NEW GFX ENGINE',0 GUIOptionText5 db 'AUTO INCRMNT SAVE SLOT',0 GUIOptionText6 db 'MMX SUPPORT',0 GUIOptionText7 db 'USE PL3/4 AS PL1/2',0 GUIOptionTextA db 'SIDEWINDER FIX',0 GUIOptionTextAb db 'HIGH PRIORITY MODE',0 GUIOptionTextB db 'FPS AT PROGRAM START',0 GUIOptionTextC db 'USE 30HZ FOR TURBO',0 GUIOptionTextD db 'ENABLE GAME CLOCK',0 GUIOptionTextE db 'TOGGLED FAST FWD/SLWDWN',0 GUIOptionTextF db 'SRAM CHECK+SAVE',0 GUIOptionTextG db 'OLD GFX MODE 2',0 GUIOptionTextH db 'START AT LATEST SAVE',0 GUIOptionTextI db 'AUTO STATE SAVE/LOAD',0 GUIOptionTextJ db 'DON',39,'T SAVE CUR PATH',0 GUIOptionTextK db 'DISABLE SCREENSAVER',0 GUIOptionTextL db 'USE ALTERNATE TIMER',0 GUIOptionText8 db '-',0 GUIOptionText9 db '+',0 GUIOptionText10 db '-',0 DisplayGUIVideo: cmp byte[TripBufAvail],0 jne .notexttb mov byte[Triplebufen],0 .notexttb cmp byte[MMXSupport],1 jne .2xSaIdis cmp byte[newgfx16b],0 je .2xSaIdis jmp .no2xSaIdis .2xSaIdis mov byte[En2xSaI],0 .no2xSaIdis cmp byte[En2xSaI],0 je .no2xsaidis mov byte[Triplebufen],0 .no2xsaidis cmp byte[En2xSaI],0 je .no2xsaien mov byte[scanlines],0 mov byte[antienab],0 .no2xsaien ; Video Modes List/Scanlines/Interpolation/Full(Small) Screen GUIDrawWindowBox 5,GUIVideoDisp mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 ; cmp byte[OSPort],3 ; jne near .nowin32pt2 %ifndef __MSDOS__ GUIOuttextwin2 5,12,76,GUIVideoTextw0 GUIOuttextwin2 5,12,83,GUIVideoTextw1 GUIOuttextwin2 5,12,90,GUIVideoTextw2 GUIOuttextwin2 5,12,97,GUIVideoTextw3 %endif ;.nowin32pt2 xor eax,eax mov al,[cvidmode] cmp byte[GUISLVID+eax],0 je near .notext2 GUIOuttextwin2 5,13,111,GUIVideoTextb GUIOuttextwin2u 5,36,119,GUIVideoTexta,0 .notext2 xor eax,eax mov al,[cvidmode] cmp byte[GUIHSVID+eax],0 je near .notexta GUIOuttextwin2 5,13,111,GUIVideoTextb GUIOuttextwin2u 5,76,119,GUIVideoTexta2,0 GUIOuttextwin2u 5,116,119,GUIVideoTexta3,0 .notexta xor eax,eax mov al,[cvidmode] cmp byte[GUITBWVID+eax],0 je near .nottbw GUIOuttextwin2u 5,26,128,GUIVideoText7,0 .nottbw xor eax,eax mov al,[cvidmode] cmp byte[GUI2xVID+eax],0 je near .notextb GUIOuttextwin2u 5,26,138,GUIVideoTextc,1 GUIOuttextwin2u 5,26,148,GUIVideoTextd,6 GUIOuttextwin2u 5,26,158,GUIVideoTextd2,0 .notextb xor eax,eax mov al,[cvidmode] cmp byte[GUII2VID+eax],0 je near .notextb2 GUIOuttextwin2u 5,26,168,GUIVideoText3,0 .notextb2 xor eax,eax mov al,[cvidmode] cmp byte[GUIBIFIL+eax],0 je near .notextbf2 GUIOuttextwin2u 5,26,168,GUIVideoTextbf,0 .notextbf2 xor eax,eax mov al,[cvidmode] cmp byte[GUIINVID+eax],0 je .notext3 GUIOuttextwin2u 5,26,83,GUIVideoText3,0 .notext3 xor eax,eax mov al,[cvidmode] cmp byte[GUIEAVID+eax],0 je .notext4 GUIOuttextwin2u 5,26,83,GUIVideoText4,1 .notext4 xor eax,eax mov al,[cvidmode] cmp byte[GUIFSVID+eax],0 je near .notext5 cmp byte[GUIWSVID+eax],0 je .notext4a GUIOuttextwin2u 5,26,93,GUIVideoText5b,1 jmp .notext5 .notext4a GUIOuttextwin2u 5,26,93,GUIVideoText5,1 .notext5 xor eax,eax mov al,[cvidmode] cmp byte[GUISSVID+eax],0 je .notext6 GUIOuttextwin2u 5,26,103,GUIVideoText6,1 .notext6 xor eax,eax mov al,[cvidmode] cmp byte[TripBufAvail],0 je near .notext7 cmp byte[GUITBVID+eax],0 je .notext7 GUIOuttextwin2u 5,26,168,GUIVideoText7,0 .notext7 xor eax,eax mov al,[cvidmode] cmp byte[GUIM7VID+eax],0 je .notext8 cmp byte[newengen],0 je .notext8 GUIOuttextwin2u 5,26,178,GUIVideoText8b,0 .notext8 GUIOuttextwin2u 5,26,188,GUIVideoText8c,0 %ifndef __LINUX__ GUIOuttextwin2u 5,130,188,GUIVideoText9,0 %endif add byte[GUItextcolor],15 ; cmp byte[OSPort],3 ; jne near .nowin32pt %ifndef __MSDOS__ GUIOuttextwin2 5,11,75,GUIVideoTextw0 GUIOuttextwin2 5,11,82,GUIVideoTextw1 GUIOuttextwin2 5,11,89,GUIVideoTextw2 GUIOuttextwin2 5,11,96,GUIVideoTextw3 %endif ;.nowin32pt xor eax,eax mov al,[cvidmode] cmp byte[GUISLVID+eax],0 je .notext2b GUIOuttextwin2 5,12,110,GUIVideoTextb GUIOuttextwin2 5,35,118,GUIVideoTexta .notext2b xor eax,eax mov al,[cvidmode] cmp byte[GUIHSVID+eax],0 je near .notextab GUIOuttextwin2 5,12,110,GUIVideoTextb GUIOuttextwin2 5,75,118,GUIVideoTexta2 GUIOuttextwin2 5,115,118,GUIVideoTexta3 .notextab xor eax,eax mov al,[cvidmode] cmp byte[GUITBWVID+eax],0 je near .nottbwb GUIOuttextwin2 5,25,127,GUIVideoText7 .nottbwb xor eax,eax mov al,[cvidmode] cmp byte[GUI2xVID+eax],0 je near .notextbb GUIOuttextwin2 5,25,137,GUIVideoTextc GUIOuttextwin2 5,25,147,GUIVideoTextd GUIOuttextwin2 5,25,157,GUIVideoTextd2 .notextbb xor eax,eax mov al,[cvidmode] cmp byte[GUII2VID+eax],0 je near .notextb2b GUIOuttextwin2 5,25,167,GUIVideoText3 .notextb2b xor eax,eax mov al,[cvidmode] cmp byte[GUIBIFIL+eax],0 je near .notextb2bf GUIOuttextwin2 5,25,167,GUIVideoTextbf .notextb2bf xor eax,eax mov al,[cvidmode] cmp byte[GUIINVID+eax],0 je .notext3b GUIOuttextwin2 5,25,82,GUIVideoText3 .notext3b xor eax,eax mov al,[cvidmode] cmp byte[GUIEAVID+eax],0 je .notext4b GUIOuttextwin2 5,25,82,GUIVideoText4 .notext4b xor eax,eax mov al,[cvidmode] cmp byte[GUIFSVID+eax],0 je near .notext5b cmp byte[GUIWSVID+eax],0 je .notext4ba GUIOuttextwin2 5,25,92,GUIVideoText5b jmp .notext5b .notext4ba GUIOuttextwin2 5,25,92,GUIVideoText5 .notext5b xor eax,eax mov al,[cvidmode] cmp byte[GUISSVID+eax],0 je .notext6b GUIOuttextwin2 5,25,102,GUIVideoText6 .notext6b xor eax,eax mov al,[cvidmode] cmp byte[TripBufAvail],0 je near .notext7b cmp byte[GUITBVID+eax],0 je .notext7b GUIOuttextwin2 5,25,167,GUIVideoText7 .notext7b xor eax,eax mov al,[cvidmode] cmp byte[GUIM7VID+eax],0 je .notext8b cmp byte[newengen],0 je .notext8b GUIOuttextwin2 5,25,177,GUIVideoText8b .notext8b GUIOuttextwin2 5,25,187,GUIVideoText8c %ifndef __LINUX__ GUIOuttextwin2 5,129,187,GUIVideoText9 %endif DrawGUIButton 5,128,60,164,71,GUIVideoText8,4,0,0 mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 5,6,16,GUIVideoText1 mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 5,5,15,GUIVideoText1 xor eax,eax mov al,[cvidmode] cmp byte[GUISLVID+eax],0 je near .nocheckboxb mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[scanlines],1 jne .nocheckbox mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox GUIDisplayIconWin 5,21,114,[GUITemp] .nocheckboxb xor eax,eax mov al,[cvidmode] cmp byte[GUIHSVID+eax],0 je .nocheckboxw mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[scanlines],3 jne .nocheckboxv mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxv GUIDisplayIconWin 5,61,114,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[scanlines],2 jne .nocheckboxv2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxv2 GUIDisplayIconWin 5,101,114,[GUITemp] .nocheckboxw xor eax,eax mov al,[cvidmode] cmp byte[GUITBWVID+eax],0 je near .nocheckboxslw2 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[TripleBufferWin],1 jne .nocheckboxslw mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxslw GUIDisplayIconWin 5,11,123,[GUITemp] .nocheckboxslw2 xor eax,eax mov al,[cvidmode] cmp byte[GUI2xVID+eax],0 je near .nocheckboxx mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[En2xSaI],1 jne .nocheckboxx2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxx2 GUIDisplayIconWin 5,11,133,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[En2xSaI],2 jne .nocheckboxx3 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxx3 GUIDisplayIconWin 5,11,143,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[En2xSaI],3 jne .nocheckboxx4 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxx4 GUIDisplayIconWin 5,11,153,[GUITemp] .nocheckboxx xor eax,eax mov al,[cvidmode] cmp byte[GUII2VID+eax],0 je near .nocheckboxi2 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[antienab],0 je .nocheckbox1i2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1i2 GUIDisplayIconWin 5,11,163,[GUITemp] .nocheckboxi2 xor eax,eax mov al,[cvidmode] cmp byte[GUIBIFIL+eax],0 je near .nocheckboxbf mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[BilinearFilter],0 je .nocheckbox1bf mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1bf GUIDisplayIconWin 5,11,163,[GUITemp] .nocheckboxbf xor eax,eax mov al,[cvidmode] cmp byte[GUITBVID+eax],0 je .nocheckboxtbb cmp byte[TripBufAvail],0 je near .nocheckboxtbb mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[Triplebufen],1 jne .nocheckboxtb mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxtb GUIDisplayIconWin 5,11,163,[GUITemp] .nocheckboxtbb xor eax,eax mov al,[cvidmode] cmp byte[GUIM7VID+eax],0 je near .nocheckboxm72 cmp byte[newengen],0 je near .nocheckboxm72 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[Mode7HiRes16b],0 je .nocheckbox1m72 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1m72 GUIDisplayIconWin 5,11,173,[GUITemp] .nocheckboxm72 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GrayscaleMode],0 je .nocheckboxm73 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxm73 GUIDisplayIconWin 5,11,183,[GUITemp] %ifndef __LINUX__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[vsyncon],0 je .nocheckboxm74 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckboxm74 GUIDisplayIconWin 5,115,183,[GUITemp] %endif xor eax,eax mov al,[cvidmode] cmp byte[GUIIEVID+eax],0 je .nocheckbox1b mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[antienab],0 je .nocheckbox1 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1 GUIDisplayIconWin 5,11,78,[GUITemp] .nocheckbox1b xor eax,eax mov al,[cvidmode] cmp byte[GUIFSVID+eax],0 je .nocheckbox2b mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[ScreenScale],0 je .nocheckbox2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox2 GUIDisplayIconWin 5,11,88,[GUITemp] .nocheckbox2b xor eax,eax mov al,[cvidmode] cmp byte[GUISSVID+eax],0 je .nocheckbox3b mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[smallscreenon],0 je .nocheckbox3 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox3 GUIDisplayIconWin 5,11,98,[GUITemp] .nocheckbox3b DrawGUIWinBox 5,5,26,115,69,167 DrawSlideBarWin 5,117,34,[GUIcurrentvideoviewloc],[NumVideoModes],5,28,GUIVStA cmp byte[GUICHold],5 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin 5,117,26,GUIIconDataUpArrow cmp byte[GUICHold],5 jne .noholdb sub byte[GUIWincoladd],3 .noholdb cmp byte[GUICHold],6 jne .noholdc add byte[GUIWincoladd],3 .noholdc GUIDisplayIconWin 5,117,62,GUIIconDataDownArrow cmp byte[GUICHold],6 jne .noholdd sub byte[GUIWincoladd],3 .noholdd mov ebx,[GUIcurrentvideocursloc] sub ebx,[GUIcurrentvideoviewloc] lea ebx,[ebx*8] add ebx,28 DrawGUIWinBox2 5,5,115,7,224 mov byte[GUItextcolor],223 mov eax,[GUIcurrentvideoviewloc] mov ebx,eax shl eax,4 add eax,ebx add eax,ebx add eax,GUIVideoModeNames mov dword[GUITemp],eax GUIOuttextwin2 5,11,30,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,11,30+8,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,11,30+8*2,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,11,30+8*3,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,11,30+8*4,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],222 .zero5 mov eax,[GUIcurrentvideoviewloc] mov ebx,eax shl eax,4 add eax,ebx add eax,ebx add eax,GUIVideoModeNames mov dword[GUITemp],eax GUIOuttextwin2 5,10,29,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,10,29+8,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,10,29+8*2,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,10,29+8*3,[GUITemp] add dword[GUITemp],18 GUIOuttextwin2 5,10,29+8*4,[GUITemp] ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 5,5,25,115,25,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 5,4,26,3,69,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 5,5,70,115,70,dl xor eax,eax mov al,[cvidmode] mov ebx,eax shl eax,4 add eax,ebx add eax,ebx add eax,GUIVideoModeNames mov dword[GUITemp],eax mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 5,7,196,GUIVideoTextH GUIOuttextwin2 5,49,196,[GUITemp] mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero6 mov byte[GUItextcolor],164 .zero6 GUIOuttextwin2 5,6,195,GUIVideoTextH GUIOuttextwin2 5,48,195,[GUITemp] ret GUIVideoText1 db 'VIDEO MODES :',0 GUIVideoText2 db 'FULL SCANLINES',0 GUIVideoTextb db 'SCANLINES:',0 GUIVideoTexta db 'FULL',0 GUIVideoTexta2 db '50%',0 GUIVideoTexta3 db '25%',0 GUIVideoTextc db '2XSAI ENGINE',0 GUIVideoTextd db 'SUPER EAGLE ENGINE',0 GUIVideoTextd2 db 'SUPER 2XSAI ENGINE',0 GUIVideoTextbf db 'BILINEAR FILTER',0 GUIVideoText3 db 'INTERPOLATION',0 ; -y GUIVideoText4 db 'EAGLE ENGINE',0 ; -y GUIVideoText5 db 'FULL SCREEN',0 ; -c GUIVideoText5b db 'WIDE SCREEN',0 ; -c GUIVideoText6 db 'SMALL SCREEN',0 ; -c GUIVideoText7 db 'TRIPLE BUFFERING',0 ; -c GUIVideoText8b db 'HI-RESOLUTION MODE7',0 ; -c GUIVideoText8c db 'GRAYSCALE MODE',0 ; -c GUIVideoText8 db 'SET',0 ; set button GUIVideoText9 db 'VSYNC',0 ; -c GUIVideoTextH db 'MODE : ',0 GUIVideoTextw0 db 'LEGEND:',0 GUIVideoTextw1 db ' S = SCALED TO FIT SCREEN',0 GUIVideoTextw2 db ' R = MATCHED SCREEN RATIO',0 GUIVideoTextw3 db ' D = ALLOW 2XSAI,HIRES,ETC',0 GUIVStA dd 0,0,0 GUIcurrentvideoviewloc dd 0 GUIcurrentvideocursloc dd 0 DisplayGUISound: ; Enable Sound/Sampling Rate/Stereo/Sound Buffering/Volume GUIDrawWindowBox 6,GUISoundDisp mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 ; E = Enable Sound, S = Stereo Sound, B = Sound Buffering ; R = Sample Rate GUIOuttextwin2u 6,26,26,GUISoundText1,0 GUIOuttextwin2u 6,26,35,GUISoundText3,0 ; cmp byte[OSPort],3 ; je near .win32b %ifdef __MSDOS__ GUIOuttextwin2u 6,116,26,GUISoundText1b,0 GUIOuttextwin2u 6,26,44,GUISoundText2b,1 %endif ;.win32b GUIOuttextwin2u 6,26,106,GUISoundText4,8 GUIOuttextwin2u 6,26,116,GUISoundTextH,2 ; cmp byte[OSPort],3 ; je near .win32s2 GUIOuttextwin2u 6,26,126,GUISoundTextI,1 ;.win32s2 GUIOuttextwin2u 6,26,136,GUISoundTextJ,6 GUIOuttextwin2u 6,26,146,GUISoundTextK,0 GUIOuttextwin2u 6,26,168,GUISoundTextQ,0 GUIOuttextwin2u 6,26,178,GUISoundTextR,0 %ifndef __MSDOS__ GUIOuttextwin2u 6,26,188,GUISoundTextS,0 %endif GUIOuttextwin2u 6,126,168,GUISoundTextU,1 GUIOuttextwin2u 6,126,178,GUISoundTextV,1 %ifndef __MSDOS__ GUIOuttextwin2u 6,126,188,GUISoundTextW,0 %endif add byte[GUItextcolor],15 GUIOuttextwin2 6,25,25,GUISoundText1 GUIOuttextwin2 6,25,34,GUISoundText3 ; cmp byte[OSPort],3 ; je near .win32c %ifdef __MSDOS__ GUIOuttextwin2 6,115,25,GUISoundText1b GUIOuttextwin2 6,25,43,GUISoundText2b %endif ;.win32c GUIOuttextwin2 6,25,105,GUISoundText4 GUIOuttextwin2 6,25,115,GUISoundTextH ; cmp byte[OSPort],3 ; je near .win32s GUIOuttextwin2 6,25,125,GUISoundTextI ;.win32s GUIOuttextwin2 6,25,135,GUISoundTextJ GUIOuttextwin2 6,25,145,GUISoundTextK GUIOuttextwin2 6,25,167,GUISoundTextQ GUIOuttextwin2 6,25,177,GUISoundTextR %ifndef __MSDOS__ GUIOuttextwin2 6,25,187,GUISoundTextS %endif GUIOuttextwin2 6,125,167,GUISoundTextU GUIOuttextwin2 6,125,177,GUISoundTextV %ifndef __MSDOS__ GUIOuttextwin2 6,125,187,GUISoundTextW %endif mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 6,6,16,GUISoundText6 GUIOuttextwin2u 6,6,53,GUISoundText2,9 GUIOuttextwin2 6,6,76,GUISoundText5 GUIOuttextwin2 6,6,158,GUISoundTextP GUIOuttextwin2 6,106,158,GUISoundTextT mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 6,5,15,GUISoundText6 GUIOuttextwin2 6,5,52,GUISoundText2 GUIOuttextwin2 6,5,75,GUISoundText5 GUIOuttextwin2 6,5,157,GUISoundTextP GUIOuttextwin2 6,105,157,GUISoundTextT mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[cfgsoundon],0 je .nocheckbox mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox GUIDisplayIconWin 6,11,21,[GUITemp] %ifdef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[cfgforce8b],0 je .nocheckbox0 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox0 GUIDisplayIconWin 6,102,21,[GUITemp] %endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[cfgStereoSound],0 je .nocheckbox1 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1 GUIDisplayIconWin 6,11,30,[GUITemp] %ifdef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[RaisePitch],0 je .nocheckbox1b mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox1b ; cmp byte[OSPort],3 ; je near .win32 GUIDisplayIconWin 6,11,39,[GUITemp] %endif ;.win32 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SoundNoiseDis],0 je .nocheckbox2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox2 GUIDisplayIconWin 6,11,101,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[RevStereo],0 je .nocheckbox3 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox3 GUIDisplayIconWin 6,11,111,[GUITemp] ; cmp byte[OSPort],3 ; je near .nocheckbox42 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[Surround],0 je .nocheckbox4 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox4 GUIDisplayIconWin 6,11,121,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SoundBufEn],0 je .nocheckbox5 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox5 GUIDisplayIconWin 6,11,131,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SPCDisable],0 je .nocheckbox6 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox6 GUIDisplayIconWin 6,11,141,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SoundInterpType],1 jne .nocheckbox7 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox7 GUIDisplayIconWin 6,11,163,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SoundInterpType],2 jne .nocheckbox8 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox8 GUIDisplayIconWin 6,11,173,[GUITemp] %ifndef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SoundInterpType],3 jne .nocheckbox9 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox9 GUIDisplayIconWin 6,11,183,[GUITemp] %endif mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[LowPassFilterType],1 jne .nocheckbox10 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox10 GUIDisplayIconWin 6,111,163,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[LowPassFilterType],2 jne .nocheckbox11 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox11 GUIDisplayIconWin 6,111,173,[GUITemp] %ifndef __MSDOS__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[LowPassFilterType],3 jne .nocheckbox12 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox12 GUIDisplayIconWin 6,111,183,[GUITemp] %endif DrawGUIWinBox 6,15,61,69,69,167 mov dword[GUITemp],GUISoundText7 xor eax,eax mov al,[cfgSoundQuality] shl eax,3 add [GUITemp],eax mov byte[GUItextcolor],223 GUIOuttextwin2 6,23,64,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 GUIOuttextwin2 6,22,63,[GUITemp] mov eax,dword[GUIwinposx+6*4] mov ebx,dword[GUIwinposy+6*4] mov ecx,eax add eax,15 add ecx,15+100 add ebx,91 xor edx,edx mov dl,215 sub dl,[GUIWincoladd] DrawGUILine inc ecx inc eax sub dl,13 DrawGUILine xor eax,eax mov al,[MusicRelVol] mov dword[GUITemp],11 add [GUITemp],eax GUIDisplayIconWin 6,[GUITemp],87,GUIIconDataSlideBar mov dword[GUISoundTextD],' ' mov byte[GUISoundTextD+3],'%' mov esi,GUISoundTextD+2 xor eax,eax mov al,[MusicRelVol] mov ebx,10 div bl add ah,48 mov [esi],ah cmp al,0 je .nomore dec esi xor ah,ah div bl add ah,48 mov [esi],ah cmp al,0 je .nomore dec esi xor ah,ah div bl add ah,48 mov [esi],ah .nomore mov [GUITemp],esi mov byte[GUItextcolor],223 GUIOuttextwin2 6,119,89,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],222 .zero5 GUIOuttextwin2 6,118,88,[GUITemp] ret GUISoundText1 db 'ENABLE SOUND',0 GUISoundText1b db 'FORCE 8-BIT',0 GUISoundText2 db 'SAMPLING RATE :',0 GUISoundText2b db 'RAISE PITCH LEVEL',0 GUISoundText3 db 'STEREO SOUND',0 GUISoundText4 db 'DISABLE NOISE SIMULATION',0 GUISoundText5 db 'VOLUME LEVEL :',0 GUISoundText6 db 'SOUND SWITCHES :',0 GUISoundText7 db ' 8000HZ',0 GUISoundText8 db '11025HZ',0 GUISoundText9 db '22050HZ',0 GUISoundTextA db '44100HZ',0 GUISoundTextB db '16000HZ',0 GUISoundTextC db '32000HZ',0 GUISoundTextCb db '48000HZ',0 GUISoundTextD db '---%',0 GUISoundTextH db 'REVERSE STEREO',0 GUISoundTextI db 'SURROUND SOUND',0 GUISoundTextJ db 'SOUND BUFFERING',0 GUISoundTextK db 'DISABLE SPC EMULATION',0 GUISoundTextP db 'INTERPOLATION :',0 GUISoundTextQ db 'GAUSSIAN',0 GUISoundTextR db 'CUBIC SPLINE',0 GUISoundTextS db '8-POINT',0 GUISoundTextT db 'LOWPASS :',0 GUISoundTextU db 'SIMPLE',0 GUISoundTextV db 'DYNAMIC',0 GUISoundTextW db 'HI QUALITY',0 DisplayGUICheatConv: mov eax,[ccheatnpos] add eax,4 xor ebx,ebx mov ecx,3 mov edx,GUICheatTextB .loop mov bl,[eax] and bl,0Fh mov bl,[GUICheatTextC+ebx] mov [edx+1],bl mov bl,[eax] and bl,0F0h shr bl,4 mov bl,[GUICheatTextC+ebx] mov [edx],bl add edx,2 dec eax dec ecx jnz .loop mov eax,[ccheatnpos] inc eax mov edx,GUICheatTextB+7 mov bl,[eax] and bl,0Fh mov bl,[GUICheatTextC+ebx] mov [edx+1],bl mov bl,[eax] and bl,0F0h shr bl,4 mov bl,[GUICheatTextC+ebx] mov [edx],bl mov eax,[ccheatnpos] add eax,5 mov edx,GUICheatTextB+10 mov bl,[eax] and bl,0Fh mov bl,[GUICheatTextC+ebx] mov [edx+1],bl mov bl,[eax] and bl,0F0h shr bl,4 mov bl,[GUICheatTextC+ebx] mov [edx],bl mov eax,[ccheatnpos] test byte[eax-28],80h jnz .src test byte[eax],04h jz .on mov byte[GUICheatTextB+13],'O' mov byte[GUICheatTextB+14],'F' mov byte[GUICheatTextB+15],'F' jmp .off .on test byte[eax],80h jnz .repl mov byte[GUICheatTextB+13],'O' mov byte[GUICheatTextB+14],'N' mov byte[GUICheatTextB+15],' ' jmp .off .repl mov byte[GUICheatTextB+13],'R' mov byte[GUICheatTextB+14],'P' mov byte[GUICheatTextB+15],'L' jmp .off .src mov byte[GUICheatTextB+13],'S' mov byte[GUICheatTextB+14],'R' mov byte[GUICheatTextB+15],'C' .off mov ecx,20 add eax,8 mov edx,GUICheatTextB+17 .loop2 mov bl,[eax] mov [edx],bl inc eax inc edx dec ecx jnz .loop2 ret %macro GUIOuttextwin2cheat 2 test dword[ccheatnleft],80000000h jnz %%skip call DisplayGUICheatConv GUIOuttextwin2 7,%1,%2,GUICheatTextB add dword[ccheatnpos],28 dec dword[ccheatnleft] %%skip %endmacro DisplayGUICheat: GUIDrawWindowBox 7,GUICheatDisp mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 GUIOuttextwin2 7,6,132,GUICheatText1 GUIOuttextwin2 7,6,143,GUICheatText2 GUIOuttextwin2 7,6,13,GUICheatText3 GUIOuttextwin2 7,11,154,GUICheatTextD GUIOuttextwin2 7,11,164,GUICheatTextE GUIOuttextwin2 7,11,172,GUICheatTextF GUIOuttextwin2 7,11,180,GUICheatTextG GUIOuttextwin2 7,26,191,GUICheatTextJ add byte[GUItextcolor],15 GUIOuttextwin2 7,5,131,GUICheatText1 GUIOuttextwin2 7,5,142,GUICheatText2 GUIOuttextwin2 7,5,12,GUICheatText3 GUIOuttextwin2 7,10,153,GUICheatTextD GUIOuttextwin2 7,10,163,GUICheatTextE GUIOuttextwin2 7,10,171,GUICheatTextF GUIOuttextwin2 7,10,179,GUICheatTextG GUIOuttextwin2 7,25,190,GUICheatTextJ DrawGUIWinBox 7,5,20,229,108,167 DrawGUIButton 7,5,113,47,124,GUICheatText4,5,0,0 DrawGUIButton 7,52,113,94,124,GUICheatText5,6,0,0 DrawGUIButton 7,99,113,141,124,GUICheatText7,7,0,0 DrawGUIButton 7,146,113,188,124,GUICheatText8,8,0,0 DrawGUIButton 7,212,134,236,145,GUICheatText6,9,0,0 DrawGUIButton 7,193,113,235,124,GUICheatTextI,33,0,0 cmp dword[GUIcurrentcheatwin],0 jne near .nowinbox mov ebx,[GUIcurrentcheatcursloc] sub ebx,[GUIcurrentcheatviewloc] mov eax,ebx lea ebx,[ebx*8] sub ebx,eax add ebx,22 DrawGUIWinBox2 7,5,229,7,224 .nowinbox mov byte[GUItextcolor],223 mov dword[ccheatnpos],cheatdata mov eax,[NumCheats] sub eax,[GUIcurrentcheatviewloc] dec eax mov dword[ccheatnleft],eax mov eax,[GUIcurrentcheatviewloc] mov ebx,eax shl eax,5 sub eax,ebx sub eax,ebx sub eax,ebx sub eax,ebx add [ccheatnpos],eax GUIOuttextwin2cheat 12,24 GUIOuttextwin2cheat 12,24+7 GUIOuttextwin2cheat 12,24+7*2 GUIOuttextwin2cheat 12,24+7*3 GUIOuttextwin2cheat 12,24+7*4 GUIOuttextwin2cheat 12,24+7*5 GUIOuttextwin2cheat 12,24+7*6 GUIOuttextwin2cheat 12,24+7*7 GUIOuttextwin2cheat 12,24+7*8 GUIOuttextwin2cheat 12,24+7*9 GUIOuttextwin2cheat 12,24+7*10 GUIOuttextwin2cheat 12,24+7*11 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 mov dword[ccheatnpos],cheatdata mov eax,[NumCheats] sub eax,[GUIcurrentcheatviewloc] dec eax mov dword[ccheatnleft],eax mov eax,[GUIcurrentcheatviewloc] mov ebx,eax shl eax,5 sub eax,ebx sub eax,ebx sub eax,ebx sub eax,ebx add [ccheatnpos],eax GUIOuttextwin2cheat 11,23 GUIOuttextwin2cheat 11,23+7 GUIOuttextwin2cheat 11,23+7*2 GUIOuttextwin2cheat 11,23+7*3 GUIOuttextwin2cheat 11,23+7*4 GUIOuttextwin2cheat 11,23+7*5 GUIOuttextwin2cheat 11,23+7*6 GUIOuttextwin2cheat 11,23+7*7 GUIOuttextwin2cheat 11,23+7*8 GUIOuttextwin2cheat 11,23+7*9 GUIOuttextwin2cheat 11,23+7*10 GUIOuttextwin2cheat 11,23+7*11 DrawSlideBarWin 7,231,28,[GUIcurrentcheatviewloc],[NumCheats],12,73,GUICStA cmp byte[GUICHold],7 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin 7,231,20,GUIIconDataUpArrow cmp byte[GUICHold],7 jne .noholda2 sub byte[GUIWincoladd],3 .noholda2 cmp byte[GUICHold],8 jne .noholdb add byte[GUIWincoladd],3 .noholdb GUIDisplayIconWin 7,231,101,GUIIconDataDownArrow cmp byte[GUICHold],8 jne .noholdb2 sub byte[GUIWincoladd],3 .noholdb2 ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 7,5,19,229,19,dl DrawGUIWinBox 7,82,128,172,128,dl DrawGUIWinBox 7,82,139,196,139,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 7,4,20,3,108,dl DrawGUIWinBox 7,81,129,80,136,dl DrawGUIWinBox 7,81,140,80,147,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 7,5,109,229,109,dl DrawGUIWinBox 7,82,137,172,137,dl DrawGUIWinBox 7,82,148,196,148,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 7,174,129,173,136,dl DrawGUIWinBox 7,156,140,197,147,dl ; Draw boxes mov ebx,[GUIcurrentcheatcursloc] sub ebx,[GUIcurrentcheatviewloc] mov eax,ebx lea ebx,[ebx*4] add ebx,eax add ebx,eax add ebx,eax add ebx,22 mov dl,167 cmp dword[GUIcurrentcheatwin],1 jne .notopibox mov dl,226 cmp byte[GUIWincoladd],0 je .nocoladd inc dl .nocoladd .notopibox DrawGUIWinBox 7,82,129,172,136,dl mov dl,167 cmp dword[GUIcurrentcheatwin],2 jne .nobotibox mov dl,226 cmp byte[GUIWincoladd],0 je .nocoladd2 inc dl .nocoladd2 .nobotibox DrawGUIWinBox 7,82,140,196,147,dl mov byte[GUItextcolor],223 GUIOuttextwin2 7,84,132,GUICheatText9 GUIOuttextwin2 7,84,143,GUICheatTextA mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],222 .zero3 GUIOuttextwin2 7,83,131,GUICheatText9 GUIOuttextwin2 7,83,142,GUICheatTextA xor eax,eax mov al,[GUICheatPosA] mov byte[GUICheatText9+eax],0 xor ebx,ebx mov bl,[GUICheatPosB] mov byte[GUICheatTextA+ebx],0 test byte[GUICCFlash],8 jnz .nound cmp dword[GUIcurrentcheatwin],1 je .win1 cmp dword[GUIcurrentcheatwin],2 je .win2 jmp .nound .win1 mov byte[GUICheatText9+eax],'_' jmp .nound .win2 mov byte[GUICheatTextA+ebx],'_' .nound mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AutoLoadCht],1 jne .nocheckbox mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckbox GUIDisplayIconWin 7,11,186,[GUITemp] ret GUICheatText1 db 'ENTER CODE :',0 GUICheatText2 db 'DESCRIPTION:',0 GUICheatText3 db 'ADDRESS CV PV TGL DESCRIPTION',0 GUICheatText4 db 'REMOVE',0 GUICheatText5 db 'TOGGLE',0 GUICheatText6 db 'ADD',0 GUICheatText7 db 'SAVE',0 GUICheatText8 db 'LOAD',0 GUICheatTextI db 'FIX',0 GUICheatText9 db '_',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; 14 digits GUICheatTextA db '_',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; 11 digits GUICheatTextB db '000000 00 00 OFF BLAHBLAH---',0,0,0,0,0,0,0,0,0,0,0,0 GUICheatTextC db '0123456789ABCDEF' GUICheatTextD db 'VALID CODES : GAME GENIE, PAR, AND GF',0 GUICheatTextE db 'NOTE : YOU MAY HAVE TO RESET THE GAME',0 GUICheatTextF db ' AFTER ENTERING THE CODE. REMEMBER TO',0 GUICheatTextG db ' INSERT THE "-" FOR GAME GENIE CODES',0 GUICheatTextJ db 'AUTO-LOAD .CHT FILE AT GAME LOAD',0 GUICheatPosA db 0 GUICheatPosB db 0 GUICStA dd 0,0,0 GUIcurrentcheatviewloc dd 0 GUIcurrentcheatcursloc dd 0 GUIcurrentcheatwin dd 0 ccheatnpos dd 0 ccheatnleft dd 0 DrawWindowSearch: GUIDrawWindowBox 13,GUISearchDisp ret %macro TextWindowMacro 4 sub byte[GUItextcolor],15 GUIOuttextwin2 %1,%2+1,%3+1,%4 add byte[GUItextcolor],15 GUIOuttextwin2 %1,%2,%3,%4 %endmacro CSRemoveFlash: .loop cmp byte[esi],'_' je .flash cmp byte[esi],0 je .notflash inc esi jmp .loop .flash mov byte[esi],0 .notflash ret CSAddFlash: .loop cmp byte[esi],'_' je .flash cmp byte[esi],0 je .notflash inc esi jmp .loop .notflash mov byte[esi],'_' mov byte[esi+1],0 .flash ret DisplayGUISearch: jmp .startcheat call DrawWindowSearch mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 GUIOuttextwin2 13,6,16,GUISrcText1 GUIOuttextwin2 13,6,26,GUISrcText2 GUIOuttextwin2 13,6,36,GUISrcText3 add byte[GUItextcolor],15 GUIOuttextwin2 13,5,15,GUISrcText1 GUIOuttextwin2 13,5,25,GUISrcText2 GUIOuttextwin2 13,5,35,GUISrcText3 ret ; DrawGUIButton 13,197,30,239,41,GUICSrcText8+2,40,0,0 ret .startcheat cmp byte[CheatWinMode],1 je near Incheatmode cmp byte[CheatWinMode],2 je near Cheatmodeview cmp byte[CheatWinMode],3 je near Cheatmodeadd mov dword[GUIwinsizex+13*4],170 mov dword[GUIwinsizey+13*4],150 call DrawWindowSearch mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 13,6,16,GUICSrcText1 GUIOuttextwin2 13,6,101,GUICSrcText8 mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 13,5,15,GUICSrcText1 GUIOuttextwin2 13,5,100,GUICSrcText8 mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero2 mov byte[GUItextcolor],211 .zero2 TextWindowMacro 13,25,30,GUICSrcText2 TextWindowMacro 13,25,40,GUICSrcText3 TextWindowMacro 13,25,50,GUICSrcText4 TextWindowMacro 13,25,60,GUICSrcText5 TextWindowMacro 13,25,75,GUICSrcText6 TextWindowMacro 13,25,85,GUICSrcText7 TextWindowMacro 13,25,115,GUICSrcText9 TextWindowMacro 13,25,125,GUICSrcTextA DrawGUIButton 13,95,140,140,152,GUICSrcTextB,50,0,1 GUIDisplayButtonHole 13,11,28,byte[CheatSrcByteSize],0 GUIDisplayButtonHole 13,11,38,byte[CheatSrcByteSize],1 GUIDisplayButtonHole 13,11,48,byte[CheatSrcByteSize],2 GUIDisplayButtonHole 13,11,58,byte[CheatSrcByteSize],3 GUIDisplayButtonHole 13,11,73,byte[CheatSrcByteBase],0 GUIDisplayButtonHole 13,11,83,byte[CheatSrcByteBase],1 GUIDisplayButtonHole 13,11,113,byte[CheatSrcSearchType],0 GUIDisplayButtonHole 13,11,123,byte[CheatSrcSearchType],1 ret Incheatmode: mov dword[GUIwinsizex+13*4],180 mov dword[GUIwinsizey+13*4],150 call DrawWindowSearch mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero2 mov byte[GUItextcolor],211 .zero2 cmp byte[CheatSearchStatus],1 jne near CheatSearching TextWindowMacro 13,5,20,GUICSrcTextM TextWindowMacro 13,5,30,GUICSrcTextN TextWindowMacro 13,5,40,GUICSrcTextO TextWindowMacro 13,5,50,GUICSrcTextP jmp DisplayChtSrcRes.nosearch CheatSearching: cmp byte[CheatSrcSearchType],1 je near CheatSearchingComp ; Exact Value Search TextWindowMacro 13,5,20,GUICSrcTextD DrawGUIWinBox 13,10,40,80,47,167 ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 13,10,39,80,39,dl ; 0,-1,0,-1 mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 13,9,40,8,47,dl ; -1,0,-2,0 mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 13,10,48,80,48,dl ; 0,1,0,1 mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 13,82,40,81,47,dl ; 2,0,1,0 test byte[GUICCFlash],8 jnz .nound mov esi,CSInputDisplay call CSRemoveFlash .nound mov byte[GUItextcolor],223 cmp byte[CSOverValue],1 jne .notdark mov byte[GUItextcolor],202 .notdark GUIOuttextwin2 13,13,42,CSInputDisplay mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 cmp byte[CSOverValue],1 jne .notdark2 mov byte[GUItextcolor],207 .notdark2 GUIOuttextwin2 13,12,41,CSInputDisplay mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero2 mov byte[GUItextcolor],211 .zero2 TextWindowMacro 13,5,65,GUICSrcTextT mov esi,CSInputDisplay call CSAddFlash xor eax,eax mov al,[CheatSrcByteSize] mov eax,[SrcMask+eax*4] mov esi,GUICSrcTextQ cmp byte[CheatSrcByteBase],1 je .hex call convertnum jmp .dec .hex xor ecx,ecx mov cl,[CheatSrcByteSize] inc ecx call converthex .dec TextWindowMacro 13,71,65,GUICSrcTextQ jmp DisplayChtSrcRes CheatSearchingComp: ; Comparative search mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 13,6,16,GUICSrcTextE mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],164 .zero3 GUIOuttextwin2 13,5,15,GUICSrcTextE mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero2 mov byte[GUItextcolor],211 .zero2 TextWindowMacro 13,25,35,GUICSrcTextF TextWindowMacro 13,25,45,GUICSrcTextG TextWindowMacro 13,25,55,GUICSrcTextH TextWindowMacro 13,25,65,GUICSrcTextHb GUIDisplayButtonHole 13,11,33,byte[CheatCompareValue],0 GUIDisplayButtonHole 13,11,43,byte[CheatCompareValue],1 GUIDisplayButtonHole 13,11,53,byte[CheatCompareValue],2 GUIDisplayButtonHole 13,11,63,byte[CheatCompareValue],3 jmp DisplayChtSrcRes FindChtSrcRes: inc edi ; Calculate search results mov eax,dword[vidbuffer] add eax,129600+65536*2 mov ecx,16384 xor esi,esi xor ebx,ebx .searchloop mov dl,[eax] mov dh,8 .sloop2 test dl,1 jz .notset inc ebx dec edi jz .found .notset inc esi shr dl,1 dec dh jnz .sloop2 inc eax dec ecx jnz .searchloop mov eax,ebx ret .found mov [CSStartEntry],esi jmp .notset DisplayChtSrcRes: DrawGUIButton 13,120,140,170,152,GUICSrcTextI,53,0,1 .nosearch DrawGUIButton 13,10,140,60,152,GUICSrcTextJ,51,0,1 DrawGUIButton 13,70,140,110,152,GUICSrcTextL,52,0,1 xor edi,edi call FindChtSrcRes mov esi,GUICSrcTextQ call convertnum TextWindowMacro 13,12,125,GUICSrcTextK TextWindowMacro 13,97,125,GUICSrcTextQ mov dword[GUIcurrentchtsrcviewloc],0 mov dword[GUIcurrentchtsrccursloc],0 ret Cheatmodeview: mov byte[GUICSrcTextS+12],32 cmp byte[CheatSrcByteSize],3 jne .yesprev cmp byte[CheatSrcByteBase],0 jne .yesprev mov byte[GUICSrcTextS+12],0 .yesprev mov dword[GUIwinsizex+13*4],185 mov dword[GUIwinsizey+13*4],150 call DrawWindowSearch mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero TextWindowMacro 13,10,12,GUICSrcTextS DrawGUIWinBox 13,5,20,171,108,167 ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 13,5,19,171,19,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 13,4,20,3,108,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 13,5,109,171,109,dl mov edi,[GUIcurrentchtsrcviewloc] call FindChtSrcRes mov [NumCheatSrc],eax mov dword[ccheatnpos],esi ; Display Window Contents mov byte[GUItextcolor],223 mov eax,[NumCheatSrc] sub eax,[GUIcurrentchtsrcviewloc] cmp eax,12 jbe .notof mov eax,12 .notof mov dword[ccheatnleft],eax mov dword[ccheatnleftb],eax mov dword[CheatSearchYPos],24 mov dword[CheatSearchXPos],10 mov eax,[CSStartEntry] mov [CSCurEntry],eax cmp dword[ccheatnleft],0 je near .noentry mov byte[CheatLooped],0 mov ebx,[GUIcurrentchtsrccursloc] sub ebx,[GUIcurrentchtsrcviewloc] mov [curentryleft],ebx mov eax,ebx lea ebx,[ebx*8] sub ebx,eax add ebx,22 DrawGUIWinBox2 13,5,171,7,224 .nextdisplay cmp dword[curentryleft],0 jne .notzero mov eax,[CSCurEntry] mov [curentryval],eax .notzero dec dword[curentryleft] mov esi,GUICSrcTextQ mov ecx,3 mov eax,[CSCurEntry] add eax,7E0000h call converthex GUIOuttextwin2 13,[CheatSearchXPos],[CheatSearchYPos],GUICSrcTextQ mov esi,GUICSrcTextQ mov ebx,[wramdata] add ebx,[CSCurEntry] mov eax,[ebx] cmp byte[CheatSrcByteBase],0 je .dec xor ecx,ecx mov cl,[CheatSrcByteSize] inc ecx call converthex jmp .hex .dec xor ebx,ebx mov bl,[CheatSrcByteSize] and eax,[SrcMask+ebx*4] call convertnum .hex add dword[CheatSearchXPos],42 GUIOuttextwin2 13,[CheatSearchXPos],[CheatSearchYPos],GUICSrcTextQ add dword[CheatSearchXPos],60 cmp byte[GUICSrcTextS+12],0 je near .noprevious mov esi,GUICSrcTextQ mov ebx,dword[vidbuffer] add ebx,129600 add ebx,[CSCurEntry] mov eax,[ebx] cmp byte[CheatSrcByteBase],0 je .decb xor ecx,ecx mov cl,[CheatSrcByteSize] inc ecx call converthex jmp .hexb .decb xor ebx,ebx mov bl,[CheatSrcByteSize] and eax,[SrcMask+ebx*4] call convertnum .hexb GUIOuttextwin2 13,[CheatSearchXPos],[CheatSearchYPos],GUICSrcTextQ .noprevious sub dword[CheatSearchXPos],102 add dword[CheatSearchYPos],7 ; Search for next entry .nextentry inc dword[CSCurEntry] mov eax,[CSCurEntry] mov ecx,eax and ecx,7 mov edx,1 shr eax,3 shl edx,cl add eax,dword[vidbuffer] add eax,129600+65536*2 test byte[eax],dl jz .nextentry dec dword[ccheatnleft] jnz near .nextdisplay mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 mov dword[CheatSearchYPos],23 mov dword[CheatSearchXPos],11 mov eax,[CSStartEntry] mov [CSCurEntry],eax mov eax,dword[ccheatnleftb] mov dword[ccheatnleft],eax inc byte[CheatLooped] cmp byte[CheatLooped],2 jne near .nextdisplay .noentry ; win#,X,Y start, %4-List Loc, %5-List size, %6-Screen size, %7-Bar Size DrawSlideBarWin 13,173,28,[GUIcurrentchtsrcviewloc],[NumCheatSrc],12,73,GUICSStA cmp byte[GUICHold],11 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin 13,173,20,GUIIconDataUpArrow cmp byte[GUICHold],11 jne .noholda2 sub byte[GUIWincoladd],3 .noholda2 cmp byte[GUICHold],12 jne .noholdb add byte[GUIWincoladd],3 .noholdb GUIDisplayIconWin 13,173,101,GUIIconDataDownArrow cmp byte[GUICHold],12 jne .noholdb2 sub byte[GUIWincoladd],3 .noholdb2 mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],211 .zero3 DrawGUIButton 13,70,140,130,152,GUICSrcTextR,54,0,1 DrawGUIButton 13,140,140,180,152,GUICSrcTextU,55,0,1 ret Cheatmodeadd: mov dword[GUIwinsizex+13*4],170 mov dword[GUIwinsizey+13*4],165 call DrawWindowSearch mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],211 .zero3 TextWindowMacro 13,5,20,GUICSrcTextV TextWindowMacro 13,5,45,GUICSrcTextW TextWindowMacro 13,5,70,GUICSrcTextX TextWindowMacro 13,22,143,GUICSrcTextY mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[CheatUpperByteOnly],1 jne .nocheck mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck GUIDisplayIconWin 13,8,139,[GUITemp] DrawGUIWinBox 13,10,30,80,37,167 DrawGUIWinBox 13,10,55,126,62,167 DrawGUIWinBox 13,10,80,80,120,167 ; Draw border mov dword[GUIWincol],148+10 cmp byte[cwindrawn],1 jne .noone2 mov dword[GUIWincol],148+5 .noone2 cmp byte[cwindrawn],0 jne .nozero2 mov dword[GUIWincol],148 .nozero2 mov dl,[GUIWincol] DrawGUIWinBox 13,10,29,80,29,dl ; 0,-1,0,-1 DrawGUIWinBox 13,10,54,126,54,dl ; 0,-1,0,-1 DrawGUIWinBox 13,10,79,80,79,dl ; 0,-1,0,-1 mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 13,9,30,8,37,dl ; -1,0,-2,0 DrawGUIWinBox 13,9,55,8,62,dl ; -1,0,-2,0 DrawGUIWinBox 13,9,80,8,120,dl ; -1,0,-2,0 mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 13,10,38,80,38,dl ; 0,1,0,1 DrawGUIWinBox 13,10,63,126,63,dl ; 0,1,0,1 DrawGUIWinBox 13,10,121,80,121,dl ; 0,1,0,1 mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 13,82,30,81,37,dl ; 2,0,1,0 DrawGUIWinBox 13,128,55,127,62,dl ; 2,0,1,0 DrawGUIWinBox 13,82,80,81,120,dl ; 2,0,1,0 DrawGUIButton 13,60,155,120,167,GUICSrcTextR,56,0,1 DrawGUIButton 13,130,155,160,167,GUICSrcTextU,57,0,1 TextWindowMacro 13,5,130,GUICSrcTextT xor eax,eax mov al,[CheatSrcByteSize] mov eax,[SrcMask+eax*4] mov esi,GUICSrcTextQ cmp byte[CheatSrcByteBase],1 je .hex call convertnum jmp .dec .hex xor ecx,ecx mov cl,[CheatSrcByteSize] inc ecx call converthex .dec TextWindowMacro 13,71,130,GUICSrcTextQ cmp byte[CurCStextpos],0 jne near .nofirstbox test byte[GUICCFlash],8 jnz .nound .nofirstbox mov esi,CSInputDisplay call CSRemoveFlash .nound mov byte[GUItextcolor],223 cmp byte[CSOverValue],1 jne .notdark mov byte[GUItextcolor],202 .notdark GUIOuttextwin2 13,13,32,CSInputDisplay mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],222 .zero4 cmp byte[CSOverValue],1 jne .notdark2 mov byte[GUItextcolor],207 .notdark2 GUIOuttextwin2 13,12,31,CSInputDisplay mov esi,CSInputDisplay call CSAddFlash cmp byte[CurCStextpos],1 jne .noundb test byte[GUICCFlash],8 jnz .noundb mov esi,CSDescDisplay call CSAddFlash .noundb mov byte[GUItextcolor],223 GUIOuttextwin2 13,13,57,CSDescDisplay mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4b mov byte[GUItextcolor],222 .zero4b GUIOuttextwin2 13,12,56,CSDescDisplay mov esi,CSDescDisplay call CSRemoveFlash cmp byte[CSOverValue],1 je near .nodisplay cmp byte[CSInputDisplay],'_' je near .nodisplay mov dword[CheatSearchYPos],83 mov eax,[curentryval] mov [curaddrvalcs],eax mov eax,[CSCurValue] mov [curvaluecs],eax xor ecx,ecx mov cl,[CheatSrcByteSize] inc cl cmp byte[CheatUpperByteOnly],0 je .cspardisploop mov cl,1 .cspardispagain cmp dword[curvaluecs],0FFh jbe .cspardisploop shr dword[curvaluecs],8 inc dword[curaddrvalcs] jmp .cspardispagain .cspardisploop push ecx mov esi,GUICSrcTextQ mov ecx,3 mov eax,[curaddrvalcs] add eax,7E0000h call converthex mov esi,GUICSrcTextQ+6 mov ecx,1 mov al,[curvaluecs] call converthex shr dword[curvaluecs],8 mov byte[GUItextcolor],223 inc dword[CheatSearchYPos] GUIOuttextwin2 13,13,[CheatSearchYPos],GUICSrcTextQ dec dword[CheatSearchYPos] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero4c mov byte[GUItextcolor],222 .zero4c GUIOuttextwin2 13,12,[CheatSearchYPos],GUICSrcTextQ add dword[CheatSearchYPos],10 inc dword[curaddrvalcs] pop ecx dec ecx jnz near .cspardisploop .nodisplay ret ;CheatSrcByteSize db 0 ;CheatSrcByteBase db 0 ;CheatSrcSearchType db 0 CheatWinMode db 0 CheatSearchStatus db 0 CheatCompareValue dd 0 NumCheatSrc dd 0 GUIcurrentchtsrcviewloc dd 0 GUIcurrentchtsrccursloc dd 0 CSStartEntry dd 0 CSCurEntry dd 0 CheatSearchXPos dd 0 CheatSearchYPos dd 0 CheatLooped dd 0 ccheatnleftb dd 0 CurCStextpos dd 0 SrcMask dd 0FFh,0FFFFh,0FFFFFFh,0FFFFFFFFh CSInputDisplay db '_',0,' ',0 CSDescDisplay db ' ',0,0 curentryval dd 0 curentryleft dd 0 curaddrvalcs dd 0 curvaluecs dd 0 GUICSStA dd 0,0,0 GUISrcText1 db 'CHEAT SEARCH',0 GUISrcText2 db 'HAS NOT BEEN',0 GUISrcText3 db 'IMPLEMENTED YET',0 GUICSrcText1 db 'SELECT SIZE AND FORMAT:',0 GUICSrcText2 db '1 BYTE [0..255]',0 GUICSrcText3 db '2 BYTES [0..65535]',0 GUICSrcText4 db '3 BYTES [0..16777215]',0 GUICSrcText5 db '4 BYTES [0..4294967295]',0 GUICSrcText6 db 'DEC (BASE 10)',0 GUICSrcText7 db 'HEX (BASE 16)',0 GUICSrcText8 db 'SELECT SEARCH TYPE:',0 GUICSrcText9 db 'EXACT VALUE SEARCH',0 GUICSrcTextA db 'COMPARATIVE SEARCH',0 GUICSrcTextB db 'START',0 GUICSrcTextD db 'ENTER VALUE:',0 GUICSrcTextE db 'SELECT COMPARISON:',0 GUICSrcTextF db 'NEW VALUE IS > OLD VALUE',0 GUICSrcTextG db 'NEW VALUE IS < OLD VALUE',0 GUICSrcTextH db 'NEW VALUE IS = OLD VALUE',0 GUICSrcTextHb db 'NEW VALUE IS != OLD VALUE',0 GUICSrcTextI db 'SEARCH',0 GUICSrcTextJ db 'RESTART',0 GUICSrcTextK db '# OF RESULTS:',0 GUICSrcTextL db 'VIEW',0 GUICSrcTextQ db ' ',0 GUICSrcTextM db 'NOW RETURN TO YOUR GAME',0 GUICSrcTextN db 'AND COME BACK WHEN ',0 GUICSrcTextO db 'THE NEXT SEARCH',0 GUICSrcTextP db 'SHOULD BE PROCESSED',0 GUICSrcTextR db 'RETURN',0 GUICSrcTextS db 'ADDR VALUE PVALUE',0 GUICSrcTextT db 'MAX VALUE:',0 GUICSrcTextU db 'ADD',0 GUICSrcTextV db 'ENTER NEW VALUE:',0 GUICSrcTextW db 'ENTER CHEAT DESCRIPTION:',0 GUICSrcTextX db 'PAR CODE EQUIVALENT:',0 GUICSrcTextY db 'USE ONLY UPPER BYTE',0 NEWSYM NetAddChar ; dl = color, dh = char mov eax,ViewBuffer add eax,[CCursLoc] mov ebx,[CCursLoc] sub ebx,[CViewLoc] cmp ebx,32*12 jbe .okay mov ebx,[CCursLoc] sub ebx,32*11 and ebx,0FFE0h mov [CViewLoc],ebx .okay cmp dword[CCursLoc],32*48 jb .notbottom call .movelistup mov ebx,[CCursLoc] sub ebx,32*12 and ebx,0FFE0h mov [CViewLoc],ebx jmp NetAddChar .notbottom test dword[CCursLoc],1Fh jnz .nobeginning cmp dl,' ' je near .skipaddchar mov byte[eax],dh inc dword[CCursLoc] inc eax .nobeginning mov ebx,[CCursLoc] and ebx,1Fh cmp ebx,1Eh jne near .noend add dword[CCursLoc],2 cmp dword[CCursLoc],32*48 jb .notbottom2 call .movelistup .notbottom2 mov ebx,[CCursLoc] add ebx,ViewBuffer sub ebx,3 mov eax,12 cmp byte[ebx],' ' je .notfoundspace .loop3 cmp byte[ebx],' ' je .foundspace dec ebx dec eax jnz .loop3 jmp .notfoundspace .foundspace mov ecx,[CCursLoc] add ecx,ViewBuffer inc ebx cmp byte[ebx],0 je .notfoundspace mov [ecx],dh inc ecx mov byte[ecx],' ' inc ecx add dword[CCursLoc],2 .loop2 cmp byte[ebx],0 je .skipaddingspace mov al,[ebx] mov [ecx],al mov byte[ecx+1],0 mov byte[ebx],' ' inc ebx inc ecx inc dword[CCursLoc] jmp .loop2 jmp .skipaddingspace .notfoundspace mov ecx,[CCursLoc] add ecx,ViewBuffer mov [ecx],dh inc ecx mov byte[ecx],' ' inc ecx add dword[CCursLoc],2 .skipaddingspace jmp NetAddChar .noend cmp dl,13 je .ret cmp dl,10 je .next mov byte[eax],dl mov byte[eax+1],0 inc dword[CCursLoc] ret .next add dword[CCursLoc],32 .ret and dword[CCursLoc],0FFE0h .skipaddchar mov ebx,[CViewLoc] shr ebx,5 mov [NViewLoc],ebx ret .movelistup ; move list up by 32 spaces mov ebx,ViewBuffer mov ecx,32*47 .loop mov al,[ebx+32] mov [ebx],al inc ebx dec ecx jnz .loop and dword[CCursLoc],0FFE0h mov dword[ViewBuffer+32*47],0 sub dword[CCursLoc],32 ret CCursLoc dd 0 CViewLoc dd 0 NViewLoc dd 0 TViewLoc dd 0 DisplayNetOptns: mov dword[GUIwinsizex+8*4],7*16 mov dword[GUIwinsizey+8*4],57 mov dword[GUINetDisp],'IPX ' mov dword[GUINetDisp+4],' ' mov byte[GUINetDisp+8],0 cmp byte[per2exec],99 je .netokay mov dword[GUIwinsizex+8*4],7*16 mov dword[GUIwinsizey+8*4],40 mov dword[GUINetDisp],'ERRO' mov dword[GUINetDisp+4],'R! ' jmp .nomodem .netokay cmp byte[CNetType],8 jne .noipxinvalid mov dword[GUIwinsizex+8*4],7*16 mov dword[GUIwinsizey+8*4],30 mov dword[GUINetDisp],'ERRO' mov dword[GUINetDisp+4],'R! ' .noipxinvalid cmp byte[CNetType],22 je .yesstate cmp byte[CNetType],21 jne .nostate .yesstate mov dword[GUIwinsizex+8*4],150 mov dword[GUIwinsizey+8*4],59 mov dword[GUINetDisp],'STAT' mov dword[GUINetDisp+4],'E TR' mov dword[GUINetDisp+8],'ANSF' mov dword[GUINetDisp+12],'ER ' mov dword[GUINetDisp+14],0 .nostate cmp byte[CNetType],20 jne .nochat mov dword[GUIwinsizex+8*4],188 mov dword[GUIwinsizey+8*4],179 mov dword[GUINetDisp],'CHAT' mov dword[GUINetDisp+4],0 .nochat cmp byte[CNetType],15 je .yesterm cmp byte[CNetType],12 je .yesterm cmp byte[CNetType],11 je .yesterm cmp byte[CNetType],10 jne .noterm .yesterm mov dword[GUIwinsizex+8*4],188 mov dword[GUIwinsizey+8*4],144 mov dword[GUINetDisp],'TERM' mov dword[GUINetDisp+4],'INAL' mov byte[GUINetDisp+8],0 .noterm cmp byte[CNetType],4 jne .notcpip ; Your IP: ; Start as Server ; Client Options: ; IP : ; Port: ; Connect mov dword[GUIwinsizex+8*4],201 mov dword[GUIwinsizey+8*4],98 mov dword[GUINetDisp],'INTE' mov dword[GUINetDisp+4],'RNET' mov byte[GUINetDisp+8],0 cmp byte[NetPlayNoMore],1 jne .notcpip mov dword[GUIwinsizex+8*4],201 mov dword[GUIwinsizey+8*4],48 .notcpip cmp byte[CNetType],3 je .yesmodem cmp byte[CNetType],1 jne .nomodem2 jmp .skipmodem3 .yesmodem mov dword[GUIwinsizex+8*4],188 mov dword[GUIwinsizey+8*4],45 jmp .skipmodem2 .skipmodem3 mov dword[GUIwinsizex+8*4],95 mov dword[GUIwinsizey+8*4],70 .skipmodem2 mov dword[GUINetDisp],'MODE' mov dword[GUINetDisp+4],'M ' mov byte[GUINetDisp+8],0 .nomodem2 cmp byte[CNetType],2 jne .nomodem mov dword[GUIwinsizex+8*4],188 mov dword[GUIwinsizey+8*4],154 mov dword[GUINetDisp],'MODE' mov dword[GUINetDisp+4],'M SE' mov dword[GUINetDisp+8],'TTIN' mov word[GUINetDisp+12],'GS' mov byte[GUINetDisp+14],0 .nomodem GUIDrawWindowBox 8,GUINetDisp cmp byte[per2exec],99 jne near DisplayNetOptnsInvalid cmp byte[CNetType],22 je near DisplayNetTCPIPState cmp byte[CNetType],21 je near DisplayNetTCPIPState cmp byte[CNetType],1 je near DisplayNetOptnsModem cmp byte[CNetType],2 je near DisplayNetOptnsModemConfig cmp byte[CNetType],3 je near DisplayNetOptnsModemDial cmp byte[CNetType],4 je near DisplayNetOptnsTCPIP cmp byte[CNetType],10 je near DisplayNetOptnsModemTerm cmp byte[CNetType],11 je near DisplayNetOptnsModemTerm cmp byte[CNetType],12 je near DisplayNetOptnsModemTerm cmp byte[CNetType],15 je near DisplayNetOptnsModemTerm cmp byte[CNetType],20 je near DisplayNetOptnsChatWindow cmp byte[CNetType],7 je near DisplayNetIPXStart cmp byte[CNetType],8 je near DisplayNetIPXInvalid jmp DisplayNetIPXStart cmp ax,0 je .ipxokay mov byte[CNetType],8 jmp DisplayNetIPXInvalid .ipxokay cmp byte[CNetType],7 jmp DisplayNetIPXStart mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero mov dword[GUIEditStringcWin],0 sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,16,GUINetText1 GUIOuttextwin2 8,6,26,GUINetText2 add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUINetText1 GUIOuttextwin2 8,5,25,GUINetText2 ret DisplayNetTCPIPState: DrawGUIButton 8,73,48,127,59,GUITCPStateText3,64,0,0 cmp byte[CNetType],22 je near .receive sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,16,GUITCPStateText1 add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUITCPStateText1 jmp .send .receive sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,16,GUITCPStateText2 add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUITCPStateText2 .send DrawGUIWinBox 8,10,30,120,40,167 cmp dword[NetStateTotal],0 je near .nobox mov eax,[NetStateTotal] sub eax,[NetStateSize] mov ebx,110 mul ebx mov ebx,[NetStateTotal] div ebx add eax,10 cmp eax,10 je near .nobox push eax inc eax DrawGUIWinBox3 8,10,30,eax,40,226 pop eax DrawGUIWinBox3 8,10,30,eax,40,224 .nobox mov dl,[GUIWincol] DrawGUIWinBox 8,10,29,120,29,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 8,9,30,8,40,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 8,10,41,120,41,dl ; 0,1,0,1 mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 8,122,30,121,40,dl ; 2,0,1,0 ret GUITCPStateText1 db 'SENDING STATUS',0 GUITCPStateText2 db 'RECEIVING STATUS',0 GUITCPStateText3 db 'CANCEL',0 DisplayNetIPXStart: DrawGUIButton 8,53,48,87,59,GUINetTextZ,34,0,0 sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,16,GUINetText1c GUIOuttextwin2 8,6,26,GUINetText2c GUIOuttextwin2 8,6,36,GUINetText3c add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUINetText1c GUIOuttextwin2 8,5,25,GUINetText2c GUIOuttextwin2 8,5,35,GUINetText3c ret DisplayNetIPXInvalid: ret DisplayNetOptnsTCPIP: ; Your IP: ; Port: ; Start as Server ; Client Options: ; IP : ; Connect mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 cmp byte[NetPlayNoMore],1 jne near .tcpip GUIOuttextwin2 8,6,16,GUINetTextr1 GUIOuttextwin2 8,6,36,GUINetTextr2 GUIOuttextwin2 8,6,46,GUINetTextr3 add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUINetTextr1 GUIOuttextwin2 8,5,35,GUINetTextr2 GUIOuttextwin2 8,5,45,GUINetTextr3 ret .tcpip GUIOuttextwin2 8,6,16,GUINetTextf2 GUIOuttextwin2 8,6,26,GUINetTextf3 GUIOuttextwin2 8,6,51,GUINetTexth2 GUIOuttextwin2 8,6,61,GUINetTexti2 GUIOuttextwin2 8,18,98,GUINetTextp2 GUIOuttextwin2 8,6,88,hostname add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUINetTextf2 GUIOuttextwin2 8,5,25,GUINetTextf3 DrawGUIButton 8,5,35,129,46,GUINetTextg2,25,0,0 GUIOuttextwin2 8,5,50,GUINetTexth2 GUIOuttextwin2 8,5,60,GUINetTexti2 DrawGUIButton 8,5,70,129,81,GUINetTextj2,26,0,0 DrawGUIWinBox 8,55,13,95,21,167 DrawGUIWinBox 8,55,23,119,31,167 DrawGUIWinBox 8,26,58,191,66,167 GUIOuttextwin2 8,17,97,GUINetTextp2 GUIOuttextwin2 8,5,87,hostname mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero2 mov byte[GUItextcolor],222 .zero2 GUIOuttextwin2 8,59,15,GUINetTextl2 GUIOuttextwin2 8,30,60,TCPIPAddress GUIOuttextwin2 8,59,25,ChatNick mov byte[GUINetTextn2],'_' test byte[GUINetTextm2+2],8 jz .yesus mov byte[GUINetTextn2],' ' .yesus xor eax,eax mov al,[GUINetTextm2+1] mov ebx,6 mul ebx cmp byte[GUINetTextm2],1 je near .cursor2 cmp byte[GUINetTextm2],2 je near .cursor3 add eax,30 GUIOuttextwin2 8,eax,61,GUINetTextn2 jmp .cursor1 .cursor2 xor eax,eax mov ebx,GUINetTextl2 .loopc cmp byte[ebx],0 je .donec inc ebx add eax,6 jmp .loopc .donec add eax,59 GUIOuttextwin2 8,eax,15,GUINetTextn2 jmp .cursor1 .cursor3 xor eax,eax mov ebx,ChatNick .loopc2 cmp byte[ebx],0 je .donec2 inc ebx add eax,6 jmp .loopc2 .donec2 add eax,59 GUIOuttextwin2 8,eax,25,GUINetTextn2 .cursor1 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[UDPConfig],1 jne .nocheckm mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckm GUIDisplayIconWin 8,5,93,[GUITemp] ret DisplayNetOptnsInvalid: mov byte[CNetType],255 mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero mov dword[GUIEditStringcWin],0 sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,16,GUINetText1b GUIOuttextwin2 8,6,26,GUINetText2b GUIOuttextwin2 8,6,36,GUINetText3b add byte[GUItextcolor],15 GUIOuttextwin2 8,5,15,GUINetText1b GUIOuttextwin2 8,5,25,GUINetText2b GUIOuttextwin2 8,5,35,GUINetText3b ret DisplayNetOptnsModem: mov dword[GUIEditStringcWin],0 DrawGUIButton 8,5,15,89,26,GUINetTextG,21,0,0 DrawGUIButton 8,5,30,89,41,GUINetTextH,22,0,0 DrawGUIButton 8,5,45,89,56,GUINetTexth,23,0,0 DrawGUIButton 8,5,60,89,71,GUINetTextI,24,0,0 ret DisplayNetOptnsModemConfig: cmp byte[ModemInitStat],0 je .nodeinitmodem ; call DeInitModem mov byte[ModemInitStat],0 .nodeinitmodem DrawGUIWinBox 8,31,70,50,78,167 DrawGUIWinBox 8,21,125,175,133,167 DrawGUIWinBox 8,21,136,175,144,167 mov byte[GUINetText8],'0' mov al,[ComIRQ] cmp byte[ComIRQ],10 jb .no10 mov byte[GUINetText8],'1' sub al,10 .no10 add al,'0' mov [GUINetText8+1],al sub byte[GUItextcolor],15 GUIOuttextwin2 8,21,28,GUINetText3 GUIOuttextwin2 8,21,38,GUINetText4 GUIOuttextwin2 8,21,48,GUINetText5 GUIOuttextwin2 8,21,58,GUINetText6 GUIOuttextwin2 8,6,73,GUINetText7 GUIOuttextwin2 8,21,88,GUINetTextC GUIOuttextwin2 8,21,98,GUINetTextD GUIOuttextwin2 8,106,28,GUINetTextJ GUIOuttextwin2 8,106,38,GUINetTextK GUIOuttextwin2 8,106,48,GUINetTextL GUIOuttextwin2 8,106,58,GUINetTextM GUIOuttextwin2 8,106,68,GUINetTextN GUIOuttextwin2 8,106,78,GUINetTextO GUIOuttextwin2 8,106,88,GUINetTextP GUIOuttextwin2 8,6,128,GUINetTexte GUIOuttextwin2 8,6,139,GUINetTextf GUIOuttextwin2 8,26,152,GUINetTextX add byte[GUItextcolor],15 GUIOuttextwin2 8,20,27,GUINetText3 GUIOuttextwin2 8,20,37,GUINetText4 GUIOuttextwin2 8,20,47,GUINetText5 GUIOuttextwin2 8,20,57,GUINetText6 GUIOuttextwin2 8,5,72,GUINetText7 GUIOuttextwin2 8,20,87,GUINetTextC GUIOuttextwin2 8,20,97,GUINetTextD GUIOuttextwin2 8,105,27,GUINetTextJ GUIOuttextwin2 8,105,37,GUINetTextK GUIOuttextwin2 8,105,47,GUINetTextL GUIOuttextwin2 8,105,57,GUINetTextM GUIOuttextwin2 8,105,67,GUINetTextN GUIOuttextwin2 8,105,77,GUINetTextO GUIOuttextwin2 8,105,87,GUINetTextP GUIOuttextwin2 8,5,127,GUINetTexte GUIOuttextwin2 8,5,138,GUINetTextf GUIOuttextwin2 8,25,151,GUINetTextX DrawGUIButton 8,55,69,63,79,GUINetText9,25,-2,0 DrawGUIButton 8,66,69,74,79,GUINetTextA,26,-2,0 mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 8,6,16,GUINetTextR GUIOuttextwin2 8,6,113,GUINetTextE GUIOuttextwin2 8,91,16,GUINetTextQ mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],164 .zero GUIOuttextwin2 8,5,15,GUINetTextR GUIOuttextwin2 8,5,112,GUINetTextE GUIOuttextwin2 8,90,15,GUINetTextQ mov byte[GUItextcolor],223 GUIOuttextwin2 8,36,73,GUINetText8 GUIOuttextwin2 8,25,128,GUIInitSt1 GUIOuttextwin2 8,25,139,GUIInitSt2 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],222 .zero3 GUIOuttextwin2 8,35,72,GUINetText8 GUIOuttextwin2 8,24,127,GUIInitSt1 GUIOuttextwin2 8,24,138,GUIInitSt2 GUIDisplayButtonHole 8,9,25,byte[ComNum],1 GUIDisplayButtonHole 8,9,35,byte[ComNum],2 GUIDisplayButtonHole 8,9,45,byte[ComNum],3 GUIDisplayButtonHole 8,9,55,byte[ComNum],4 GUIDisplayButtonHole 8,94,25,byte[BaudRate],0 GUIDisplayButtonHole 8,94,35,byte[BaudRate],1 GUIDisplayButtonHole 8,94,45,byte[BaudRate],2 GUIDisplayButtonHole 8,94,55,byte[BaudRate],3 GUIDisplayButtonHole 8,94,65,byte[BaudRate],4 GUIDisplayButtonHole 8,94,75,byte[BaudRate],5 GUIDisplayButtonHole 8,94,85,byte[BaudRate],6 GUIDisplayButtonHole 8,9,85,byte[GUIDialSt+3],'T' GUIDisplayButtonHole 8,9,95,byte[GUIDialSt+3],'P' mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[FossilUse],1 jne .nocheckm mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckm GUIDisplayIconWin 8,12,147,[GUITemp] ret DisplayNetOptnsModemDial: DrawGUIWinBox 8,5,25,175,33,167 DrawGUIButton 8,141,38,175,49,GUINetTextT,28,0,0 sub byte[GUItextcolor],15 GUIOuttextwin2 8,6,14,GUINetTextF add byte[GUItextcolor],15 GUIOuttextwin2 8,5,13,GUINetTextF mov byte[GUItextcolor],223 GUIOuttextwin2 8,9,28,DialNumber mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],222 .zero3 GUIOuttextwin2 8,8,27,DialNumber mov dword[GUIEditString],DialNumber mov dword[GUIEditStringmLen],27 ; mov dword[GUIEditStringmLenM],27 mov dword[GUIEditStringcWin],1 ret DisplayNetOptnsModemTerm: DrawGUIWinBox 8,6,15,181,127,167 ; draw borders mov dl,[GUIWincol] DrawGUIWinBox 8,6,14,181,14,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 8,5,15,4,127,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 8,6,128,181,128,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 8,183,15,182,127,dl ; cancel button DrawGUIButton 8,120,135,181,146,GUINetTextS,27,0,0 ; draw text mov dword[CurCStringPos],ViewBuffer+1 mov ebx,[CViewLoc] add dword[CurCStringPos],ebx mov byte[GUItextcolor],223 GUIOuttextwin2 8,9,28-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,36-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,44-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,52-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,60-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,68-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,76-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,84-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,92-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,100-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,108-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,116-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,124-5,[CurCStringPos] add dword[CurCStringPos],32 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],222 .zero3 mov dword[CurCStringPos],ViewBuffer+1 mov ebx,[CViewLoc] add dword[CurCStringPos],ebx GUIOuttextwin2 8,8,27-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,35-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,43-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,51-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,59-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,67-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,75-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,83-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,91-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,99-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,107-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,115-5,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,123-5,[CurCStringPos] add dword[CurCStringPos],32 ret %macro NetChatWindowHelp 3 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[%3],1 jne %%nocheck mov dword[GUITemp],GUIIconDataCheckBoxC %%nocheck cmp byte[%3],2 jne %%nocheckb mov dword[GUITemp],GUIIconDataCheckBoxX %%nocheckb GUIDisplayIconWin 8,%1,%2,[GUITemp] %endmacro DisplayNetOptnsChatWindow: mov byte[GUINetText8],'0' mov al,[Latency] cmp byte[Latency],10 jb .no10b mov byte[GUINetText8],'1' sub al,10 .no10b add al,'0' mov [GUINetText8+1],al DrawGUIWinBox 8,55,157,74,165,167 GUIDisplayButtonHole 8,111,137,byte[UseRemoteSRAMData],0 GUIDisplayButtonHole 8,111,147,byte[UseRemoteSRAMData],1 GUIDisplayButtonHole 8,111,157,byte[UseRemoteSRAMData],2 NetChatWindowHelp 7,135,pl1neten NetChatWindowHelp 32,135,pl2neten NetChatWindowHelp 57,135,pl3neten NetChatWindowHelp 7,145,pl4neten NetChatWindowHelp 32,145,pl5neten NetChatWindowHelp 7,175,BackState sub byte[GUItextcolor],15 GUIOuttextwin2 8,21,140,GUINetTextW GUIOuttextwin2 8,46,140,GUINetTextW+2 GUIOuttextwin2 8,71,140,GUINetTextW+4 GUIOuttextwin2 8,21,150,GUINetTextW+6 GUIOuttextwin2 8,46,150,GUINetTextW+8 GUIOuttextwin2 8,10,160,GUINetTextY GUIOuttextwin2 8,124,140,GUINetTextb GUIOuttextwin2 8,124,150,GUINetTextc GUIOuttextwin2 8,124,160,GUINetTextd GUIOuttextwin2 8,21,180,GUINetTexto2 add byte[GUItextcolor],15 GUIOuttextwin2 8,20,139,GUINetTextW GUIOuttextwin2 8,45,139,GUINetTextW+2 GUIOuttextwin2 8,70,139,GUINetTextW+4 GUIOuttextwin2 8,20,149,GUINetTextW+6 GUIOuttextwin2 8,45,149,GUINetTextW+8 GUIOuttextwin2 8,9,159,GUINetTextY GUIOuttextwin2 8,123,139,GUINetTextb GUIOuttextwin2 8,123,149,GUINetTextc GUIOuttextwin2 8,123,159,GUINetTextd GUIOuttextwin2 8,20,179,GUINetTexto2 DrawGUIWinBox 8,6,15,181,112,167 ; draw borders mov dl,[GUIWincol] DrawGUIWinBox 8,6,14,181,14,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox 8,5,15,4,112,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox 8,6,113,181,113,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox 8,183,15,182,112,dl DrawGUIWinBox 8,6,117,181,125,167 ; disconnect button DrawGUIButton 8,111,169,181,180,GUINetTextU,27,0,0 DrawGUIButton 8,79,156,87,166,GUINetText9,29,-2,0 DrawGUIButton 8,90,156,98,166,GUINetTextA,30,-2,0 mov byte[GUItextcolor],223 mov dword[CurCStringPos],ViewBuffer+1 mov ebx,[CViewLoc] add dword[CurCStringPos],ebx GUIOuttextwin2 8,9,36-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,44-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,52-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,60-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,68-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,76-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,84-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,92-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,100-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,108-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,116-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,9,124-18,[CurCStringPos] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3b mov byte[GUItextcolor],222 .zero3b mov dword[CurCStringPos],ViewBuffer+1 mov ebx,[CViewLoc] add dword[CurCStringPos],ebx GUIOuttextwin2 8,8,35-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,43-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,51-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,59-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,67-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,75-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,83-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,91-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,99-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,107-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,115-18,[CurCStringPos] add dword[CurCStringPos],32 GUIOuttextwin2 8,8,123-18,[CurCStringPos] ; Determine ChatString Position push ecx mov ebx,ChatString mov ecx,[GUIEditStringcLen] sub ecx,ebx cmp ecx,26 jb .nostring cmp ecx,255 ja .nostring sub ecx,26 add ebx,ecx .nostring mov [CurCStringPos],ebx pop ecx mov byte[GUItextcolor],223 GUIOuttextwin2 8,10,120,[CurCStringPos] GUIOuttextwin2 8,60,160,GUINetText8 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],222 .zero3 GUIOuttextwin2 8,9,119,[CurCStringPos] GUIOuttextwin2 8,59,159,GUINetText8 mov dword[GUIEditString],ChatString mov dword[GUIEditStringmLen],200 ; mov dword[GUIEditStringmLenM],26 mov dword[GUIEditStringcWin],1 mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 8,7,131,GUINetTextV GUIOuttextwin2 8,111,131,GUINetTexta mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],164 .zero GUIOuttextwin2 8,6,130,GUINetTextV GUIOuttextwin2 8,110,130,GUINetTexta ; ############# ; mov eax,[CViewLoc] ; shr eax,5 ; add eax,12 ; mov [TViewLoc],eax ; 181,112,167 ;CViewLoc dd 0 ;NViewLoc dd 0 ;TViewLoc dd 0 ; 15,181,112 ; DrawSlideBarWin 8,181,15,[NViewLoc],[TViewLoc],12,97,GUINCStA ret NEWSYM GUINCStA, dd 0,0,0 NEWSYM CNetType, db 0 NEWSYM Latency, db 2 NEWSYM Latencytochange, db 2 NEWSYM LatencyLeft, db 2 NEWSYM NetSwap, db 0 RemCNetType db 0 UseRemoteSRAMData db 0 ChatString times 276 db 0 FileNameMod times 512 db 0 CurCStringPos dd 0 GUINetText1 db 'IPX HAS NOT BEEN',0 GUINetText2 db 'IMPLEMENTED YET',0 GUINetText1b db 'PLEASE SET THE',0 GUINetText2b db 'PERCENTAGE OF',0 GUINetText3b db 'EXECUTION TO 100',0 GUINetText1c db 'IPX IS IN BETA',0 GUINetText2c db 'STAGES. IT MAY',0 GUINetText3c db 'NOT WORK RIGHT!',0 GUINetText3 db 'COM1 (3F8)',0 GUINetText4 db 'COM2 (2F8)',0 GUINetText5 db 'COM3 (3E8)',0 GUINetText6 db 'COM4 (2E8)',0 GUINetText7 db 'IRQ ',0 GUINetText8 db '00',0 GUINetText9 db '+',0 GUINetTextA db '-',0 GUINetTextC db 'TONE (ATDT)',0 GUINetTextD db 'PULSE (ATDP)',0 GUINetTextE db 'INIT STRINGS :',0 GUINetTexte db '1.',0 GUINetTextf db '2.',0 GUINetTextF db 'ENTER NUMBER TO DIAL :',0 GUINetTextG db 'DIAL NUMBER',0 GUINetTextH db 'WAIT FOR RING',0 GUINetTexth db 'CONFIG MODEM',0 GUINetTextI db 'MANUAL',0 GUINetTextJ db '9600',0 GUINetTextK db '14400',0 GUINetTextL db '19200',0 GUINetTextM db '28800',0 GUINetTextN db '38400',0 GUINetTextO db '57600',0 GUINetTextP db '115200',0 GUINetTextQ db 'BAUDRATE (BPS) :',0 GUINetTextR db 'COMPORT :',0 GUINetTextS db 'CANCEL',0 GUINetTextT db 'DIAL',0 GUINetTextU db 'DISCONNECT',0 GUINetTextV db 'PLAYER SELECT :',0 GUINetTextW db '1',0,'2',0,'3',0,'4',0,'5',0 GUINetTextX db 'USE FOSSIL DRIVER',0 GUINetTextY db 'LATENCY',0 GUINetTextZ db 'OKAY',0 GUINetTexta db 'SAVE DATA :',0 GUINetTextb db 'NONE',0 GUINetTextc db 'LOCAL',0 GUINetTextd db 'REMOTE',0 GUINetTexte2 db 'YOUR IP:',0 GUINetTextf2 db 'PORT',0 GUINetTextf3 db 'NICKNAME',0 GUINetTextg2 db 'START AS SERVER',0 GUINetTexth2 db 'CLIENT OPTIONS:',0 GUINetTexti2 db 'IP:',0 GUINetTextj2 db 'CONNECT TO SERVER',0 GUINetTextl2 db '7845',0,0,0 GUINetTextm2 db 0,0,0 GUINetTextn2 db '_',0 GUINetTexto2 db 'BACK BUFFER',0 GUINetTextp2 db 'ALLOW UDP CONNECTION',0 GUINetTextr1 db 'PLEASE RESTART ZSNESW',0 GUINetTextr2 db 'BEFORE STARTING A NEW',0 GUINetTextr3 db 'NETPLAY SESSION',0 BaudVal dd 9600,14400,19200,28800,38400,57600,115200 DisplayGameOptns: ; Key redefinition for : ; Sound Channels 0 .. 7, Save/Select/Load States, Fast Forward ; State Selection 0 .. 9 ; Exit, Load, Reset, BG Disables, Reset, Windowing, New Gfx, OffsetMode GUIDrawWindowBox 9,GUIGameDisp ; Draw Shadows mov al,[GUIWincol] mov [GUIGameOptnsColA],al mov byte[GUIGameOptnsColB],202 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUIGameOptnsColB],196 .zero3 mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,6,16,GUIGameOptnsText3 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText4+2],'1' GUIOuttextwin2 9,9,26,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'2' GUIOuttextwin2 9,9+45,26,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'3' GUIOuttextwin2 9,9+90,26,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'4' GUIOuttextwin2 9,9+135,26,GUIGameOptnsText4 GUIOuttextwin2 9,9,34,GUIGameOptnsText5 mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,6,44,GUIGameOptnsTextC mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al GUIOuttextwin2 9,9,54,GUIGameOptnsTextD GUIOuttextwin2 9,9,62,GUIGameOptnsTextL GUIOuttextwin2 9,9,70,GUIGameOptnsTextE GUIOuttextwin2 9,9,78,GUIGameOptnsTextF GUIOuttextwin2 9,9,86,GUIGameOptnsTextG GUIOuttextwin2 9,9,94,GUIGameOptnsTextT ; cmp byte[OSPort],3 ; jne near .notwin32 %ifndef __MSDOS__ GUIOuttextwin2 9,109,46,GUIGameOptnsTextS %endif ;.notwin32 GUIOuttextwin2 9,109,54,GUIGameOptnsTextH GUIOuttextwin2 9,109,62,GUIGameOptnsTextM GUIOuttextwin2 9,109,70,GUIGameOptnsTextN GUIOuttextwin2 9,109,78,GUIGameOptnsTextO GUIOuttextwin2 9,109,86,GUIGameOptnsTextP GUIOuttextwin2 9,109,94,GUIGameOptnsTextX mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,6,104,GUIGameOptnsText1 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText2+2],'1' GUIOuttextwin2 9,9,114,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'2' GUIOuttextwin2 9,9+45,114,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'3' GUIOuttextwin2 9,9+45*2,114,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'4' GUIOuttextwin2 9,9+45*3,114,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'5' GUIOuttextwin2 9,9,122,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'6' GUIOuttextwin2 9,9+45,122,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'7' GUIOuttextwin2 9,9+45*2,122,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'8' GUIOuttextwin2 9,9+45*3,122,GUIGameOptnsText2 mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,6,132,GUIGameOptnsText6 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText7+2],'0' GUIOuttextwin2 9,9+45*2,134,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'1' GUIOuttextwin2 9,9+45*3,134,GUIGameOptnsText7 GUIOuttextwin2 9,9+45*4,134,GUIGameOptnsTextY mov byte[GUIGameOptnsText7+2],'2' GUIOuttextwin2 9,9,141,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'3' GUIOuttextwin2 9,9+45,142,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'4' GUIOuttextwin2 9,9+45*2,142,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'5' GUIOuttextwin2 9,9+45*3,142,GUIGameOptnsText7 GUIOuttextwin2 9,9+45*4,142,GUIGameOptnsTextZ mov byte[GUIGameOptnsText7+2],'6' GUIOuttextwin2 9,9,150,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'7' GUIOuttextwin2 9,9+45,150,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'8' GUIOuttextwin2 9,9+45*2,150,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'9' GUIOuttextwin2 9,9+45*3,150,GUIGameOptnsText7 GUIOuttextwin2 9,9,160,GUIGameOptnsTextI GUIOuttextwin2 9,9+57,160,GUIGameOptnsTextJ GUIOuttextwin2 9,9+114,160,GUIGameOptnsTextK mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,6,170,GUIGameOptnsText8 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al GUIOuttextwin2 9,9,180,GUIGameOptnsText9 GUIOuttextwin2 9,9+52,180,GUIGameOptnsTextA GUIOuttextwin2 9,9+109,180,GUIGameOptnsTextB GUIOuttextwin2 9,9,190,GUIGameOptnsTextQ GUIOuttextwin2 9,9+52,190,GUIGameOptnsTextR GUIOuttextwin2 9,9+160,180,GUIGameOptnsTextU GUIOuttextwin2 9,137,190,GUIGameOptnsTextV mov byte[GUIGameOptnsColA],163 mov byte[GUIGameOptnsColB],217 cmp byte[GUIWincoladd],0 je .zero mov byte[GUIGameOptnsColA],164 mov byte[GUIGameOptnsColB],211 .zero mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,5,15,GUIGameOptnsText3 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText4+2],'1' GUIOuttextwin2 9,8,25,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'2' GUIOuttextwin2 9,8+45,25,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'3' GUIOuttextwin2 9,8+90,25,GUIGameOptnsText4 mov byte[GUIGameOptnsText4+2],'4' GUIOuttextwin2 9,8+135,25,GUIGameOptnsText4 GUIOuttextwin2 9,8,33,GUIGameOptnsText5 mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,5,43,GUIGameOptnsTextC mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al GUIOuttextwin2 9,8,53,GUIGameOptnsTextD GUIOuttextwin2 9,8,61,GUIGameOptnsTextL GUIOuttextwin2 9,8,69,GUIGameOptnsTextE GUIOuttextwin2 9,8,77,GUIGameOptnsTextF GUIOuttextwin2 9,8,85,GUIGameOptnsTextG GUIOuttextwin2 9,8,93,GUIGameOptnsTextT ; cmp byte[OSPort],3 ; jne near .notwin32b %ifndef __MSDOS__ GUIOuttextwin2 9,108,45,GUIGameOptnsTextS %endif ;.notwin32b GUIOuttextwin2 9,108,53,GUIGameOptnsTextH GUIOuttextwin2 9,108,61,GUIGameOptnsTextM GUIOuttextwin2 9,108,69,GUIGameOptnsTextN GUIOuttextwin2 9,108,77,GUIGameOptnsTextO GUIOuttextwin2 9,108,85,GUIGameOptnsTextP GUIOuttextwin2 9,108,93,GUIGameOptnsTextX mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,5,103,GUIGameOptnsText1 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText2+2],'1' GUIOuttextwin2 9,8,113,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'2' GUIOuttextwin2 9,8+45,113,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'3' GUIOuttextwin2 9,8+45*2,113,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'4' GUIOuttextwin2 9,8+45*3,113,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'5' GUIOuttextwin2 9,8,121,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'6' GUIOuttextwin2 9,8+45,121,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'7' GUIOuttextwin2 9,8+45*2,121,GUIGameOptnsText2 mov byte[GUIGameOptnsText2+2],'8' GUIOuttextwin2 9,8+45*3,121,GUIGameOptnsText2 mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,5,131,GUIGameOptnsText6 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al mov byte[GUIGameOptnsText7+2],'0' GUIOuttextwin2 9,8+45*2,133,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'1' GUIOuttextwin2 9,8+45*3,133,GUIGameOptnsText7 GUIOuttextwin2 9,8+45*4,133,GUIGameOptnsTextY mov byte[GUIGameOptnsText7+2],'2' GUIOuttextwin2 9,8,141,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'3' GUIOuttextwin2 9,8+45,141,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'4' GUIOuttextwin2 9,8+45*2,141,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'5' GUIOuttextwin2 9,8+45*3,141,GUIGameOptnsText7 GUIOuttextwin2 9,8+45*4,141,GUIGameOptnsTextZ mov byte[GUIGameOptnsText7+2],'6' GUIOuttextwin2 9,8,149,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'7' GUIOuttextwin2 9,8+45,149,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'8' GUIOuttextwin2 9,8+45*2,149,GUIGameOptnsText7 mov byte[GUIGameOptnsText7+2],'9' GUIOuttextwin2 9,8+45*3,149,GUIGameOptnsText7 GUIOuttextwin2 9,8,159,GUIGameOptnsTextI GUIOuttextwin2 9,8+57,159,GUIGameOptnsTextJ GUIOuttextwin2 9,8+114,159,GUIGameOptnsTextK mov al,byte[GUIGameOptnsColA] mov byte[GUItextcolor],al GUIOuttextwin2 9,5,169,GUIGameOptnsText8 mov al,byte[GUIGameOptnsColB] mov byte[GUItextcolor],al GUIOuttextwin2 9,8,179,GUIGameOptnsText9 GUIOuttextwin2 9,8+52,179,GUIGameOptnsTextA GUIOuttextwin2 9,8+109,179,GUIGameOptnsTextB GUIOuttextwin2 9,8,189,GUIGameOptnsTextQ GUIOuttextwin2 9,8+52,189,GUIGameOptnsTextR GUIOuttextwin2 9,8+160,179,GUIGameOptnsTextU GUIOuttextwin2 9,136,189,GUIGameOptnsTextV ; Draw black boxes DGOptnsDrawBox 27,24,[KeyBGDisble0] DGOptnsDrawBox 27+45,24,[KeyBGDisble1] DGOptnsDrawBox 27+45*2,24,[KeyBGDisble2] DGOptnsDrawBox 27+45*3,24,[KeyBGDisble3] DGOptnsDrawBox 27,32,[KeySprDisble] DGOptnsDrawBox 78,52,[KeyResetAll] DGOptnsDrawBox 78,60,[KeyExtraEnab] DGOptnsDrawBox 78,68,[KeyNewGfxSwt] DGOptnsDrawBox 78,76,[KeyWinDisble] DGOptnsDrawBox 78,84,[KeyOffsetMSw] DGOptnsDrawBox 78,92,[KeySlowDown] ; cmp byte[OSPort],3 ; jne near .notwin32c %ifndef __MSDOS__ DGOptnsDrawBox 178,44,[KeyRewind] %endif ;.notwin32c DGOptnsDrawBox 178,52,[KeyFastFrwrd] DGOptnsDrawBox 178,60,[KeyVolUp] DGOptnsDrawBox 178,68,[KeyVolDown] DGOptnsDrawBox 178,76,[KeyFRateUp] DGOptnsDrawBox 178,84,[KeyFRateDown] DGOptnsDrawBox 178,92,[KeyDisplayFPS] DGOptnsDrawBox 27,112,[KeyDisableSC0] DGOptnsDrawBox 27+45,112,[KeyDisableSC1] DGOptnsDrawBox 27+45*2,112,[KeyDisableSC2] DGOptnsDrawBox 27+45*3,112,[KeyDisableSC3] DGOptnsDrawBox 27,120,[KeyDisableSC4] DGOptnsDrawBox 27+45,120,[KeyDisableSC5] DGOptnsDrawBox 27+45*2,120,[KeyDisableSC6] DGOptnsDrawBox 27+45*3,120,[KeyDisableSC7] DGOptnsDrawBox 27+45*2,132,[KeyStateSlc0] DGOptnsDrawBox 27+45*3,132,[KeyStateSlc1] DGOptnsDrawBox 27+45*4,132,[KeyIncStateSlot] DGOptnsDrawBox 27,140,[KeyStateSlc2] DGOptnsDrawBox 27+45,140,[KeyStateSlc3] DGOptnsDrawBox 27+45*2,140,[KeyStateSlc4] DGOptnsDrawBox 27+45*3,140,[KeyStateSlc5] DGOptnsDrawBox 27+45*4,140,[KeyDecStateSlot] DGOptnsDrawBox 27,148,[KeyStateSlc6] DGOptnsDrawBox 27+45,148,[KeyStateSlc7] DGOptnsDrawBox 27+45*2,148,[KeyStateSlc8] DGOptnsDrawBox 27+45*3,148,[KeyStateSlc9] DGOptnsDrawBox 8+25,158,[KeySaveState] DGOptnsDrawBox 8+57+25,158,[KeyLoadState] DGOptnsDrawBox 8+114+25,158,[KeyStateSelct] DGOptnsDrawBox 8+25,178,[KeyQuickLoad] DGOptnsDrawBox 8+57+26,178,[KeyQuickRst] DGOptnsDrawBox 8+114+20,178,[KeyQuickExit] DGOptnsDrawBox 8+114+78,178,[KeyQuickClock] DGOptnsDrawBox 8+25,188,[KeyQuickChat] DGOptnsDrawBox 8+57+45,188,[KeyQuickSnapShot] DGOptnsDrawBox 8+108+70,188,[KeyQuickSaveSPC] ret GUIGameOptnsColA db 0 GUIGameOptnsColB db 0 GUIGameDisplayKy dd 0 GUIGameOptnsText1 db 'SOUND DISABLES :',0 GUIGameOptnsText2 db 'CH#',0 GUIGameOptnsText3 db 'BG DISABLES :',0 GUIGameOptnsText4 db 'BG#',0 GUIGameOptnsText5 db 'OBJ ',0 GUIGameOptnsText6 db 'STATE SELECTS :',0 GUIGameOptnsText7 db 'ST#',0 GUIGameOptnsText8 db 'QUICK KEYS :',0 GUIGameOptnsText9 db 'LOAD',0 GUIGameOptnsTextA db 'RESET',0 GUIGameOptnsTextB db 'EXIT',0 GUIGameOptnsTextC db 'MISC TOGGLES :',0 GUIGameOptnsTextD db 'CLRSWITCHES',0 GUIGameOptnsTextE db 'NEW GFX ENG',0 GUIGameOptnsTextF db 'BG WINDOW',0 GUIGameOptnsTextG db 'OFFSET MODE',0 GUIGameOptnsTextH db 'FASTFWD KEY',0 GUIGameOptnsTextI db 'SAVE',0 GUIGameOptnsTextJ db 'LOAD',0 GUIGameOptnsTextK db 'PICK',0 GUIGameOptnsTextL db 'EXTRADEVICE',0 GUIGameOptnsTextM db '+VOL',0 GUIGameOptnsTextN db '-VOL',0 GUIGameOptnsTextO db '+FRAME RATE',0 GUIGameOptnsTextP db '-FRAME RATE',0 GUIGameOptnsTextQ db 'CHAT',0 GUIGameOptnsTextR db 'SNAPSHOT',0 GUIGameOptnsTextS db 'REWIND KEY',0 GUIGameOptnsTextT db 'SLOWDWN KEY',0 GUIGameOptnsTextU db 'CLOCK',0 GUIGameOptnsTextV db 'SAVE SPC',0 GUIGameOptnsTextX db 'DISPLAY FPS',0 GUIGameOptnsTextY db 'ST+',0 GUIGameOptnsTextZ db 'ST-',0 DisplayGUIOptns: %ifdef __WIN32__ mov dword[GUIwinsizey+10*4],192 %endif GUIDrawWindowBox 10,GUIGUIDisp push eax cmp byte[CurPalSelect],1 je .yespal2b cmp byte[CurPalSelect],2 je .yespal3b mov al,[GUIRAdd] mov [TRVal2],al mov al,[GUIGAdd] mov [TGVal2],al mov al,[GUIBAdd] mov [TBVal2],al jmp .nopal1b .yespal2b mov al,[GUITRAdd] mov [TRVal2],al mov al,[GUITGAdd] mov [TGVal2],al mov al,[GUITBAdd] mov [TBVal2],al jmp .nopal1b .yespal3b mov al,[GUIWRAdd] mov [TRVal2],al mov al,[GUIWGAdd] mov [TGVal2],al mov al,[GUIWBAdd] mov [TBVal2],al .nopal1b pop eax mov eax,dword[GUIwinposx+10*4] mov ebx,dword[GUIwinposy+10*4] mov ecx,eax add eax,25 add ecx,25+32*4 add ebx,124 xor edx,edx mov dl,215 sub dl,[GUIWincoladd] DrawGUILine add ebx,11 DrawGUILine add ebx,11 DrawGUILine inc ecx mov ebx,dword[GUIwinposy+10*4] inc eax add ebx,125 sub dl,13 DrawGUILine add ebx,11 DrawGUILine add ebx,11 DrawGUILine xor eax,eax mov al,[TRVal2] shl eax,2 mov dword[GUITemp],22 add [GUITemp],eax GUIDisplayIconWin 10,[GUITemp],120,GUIIconDataSlideBar xor eax,eax mov al,[TGVal2] shl eax,2 mov dword[GUITemp],22 add [GUITemp],eax GUIDisplayIconWin 10,[GUITemp],132,GUIIconDataSlideBar xor eax,eax mov al,[TBVal2] shl eax,2 mov dword[GUITemp],22 add [GUITemp],eax GUIDisplayIconWin 10,[GUITemp],144,GUIIconDataSlideBar mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIEnableTransp],1 jne .nocheckt mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckt GUIDisplayIconWin 10,124,23,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[FilteredGUI],1 jne .nocheckfg mov dword[GUITemp],GUIIconDataCheckBoxC .nocheckfg GUIDisplayIconWin 10,124,43,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[mousewrap],1 jne .nocheck mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck GUIDisplayIconWin 10,12,23,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[mouseshad],1 jne .nocheck2 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck2 GUIDisplayIconWin 10,12,33,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[lastcursres],1 jne .nocheck3 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck3 GUIDisplayIconWin 10,12,43,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[resetposn],1 je .nocheck4 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck4 GUIDisplayIconWin 10,12,53,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIClick],1 jne .nocheck5 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck5 GUIDisplayIconWin 10,12,63,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[JoyPad1Move],1 jne .nocheck6 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck6 GUIDisplayIconWin 10,12,73,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIEffect],1 jne .nocheck6b mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck6b GUIDisplayIconWin 10,12,83,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIEffect],4 jne .nocheck7 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck7 GUIDisplayIconWin 10,124,83,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIEffect],2 jne .nocheck7b mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck7b GUIDisplayIconWin 10,12,93,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[GUIEffect],3 jne .nocheck8 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck8 GUIDisplayIconWin 10,124,93,[GUITemp] %ifdef __WIN32__ mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[MouseWheel],1 jne .nocheck9 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck9 GUIDisplayIconWin 10,124,33,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AlwaysOnTop],1 jne .nocheck10 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck10 GUIDisplayIconWin 10,12,168,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[SaveMainWindowPos],1 jne .nocheck11 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck11 GUIDisplayIconWin 10,12,178,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[AllowMultipleInst],1 jne .nocheck12 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck12 GUIDisplayIconWin 10,12,188,[GUITemp] %endif mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 10,6,111,GUIGUIOptnsText1 GUIOuttextwin2 10,6,16,GUIGUIOptnsText5 %ifdef __WIN32__ GUIOuttextwin2 10,6,160,GUIGUIOptnsTextD mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[TrapMouseCursor],1 jne .nocheck13 mov dword[GUITemp],GUIIconDataCheckBoxC .nocheck13 GUIDisplayIconWin 10,124,53,[GUITemp] %endif mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],164 .zero GUIOuttextwin2 10,5,110,GUIGUIOptnsText1 GUIOuttextwin2 10,5,15,GUIGUIOptnsText5 %ifdef __WIN32__ GUIOuttextwin2 10,5,160,GUIGUIOptnsTextD %endif mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],211 .zero3 sub byte[GUItextcolor],15 GUIOuttextwin2u 10,26,28,GUIGUIOptnsText2,0 GUIOuttextwin2u 10,26,38,GUIGUIOptnsText3,6 GUIOuttextwin2u 10,26,48,GUIGUIOptnsText4,0 GUIOuttextwin2u 10,26,58,GUIGUIOptnsText7,5 GUIOuttextwin2u 10,26,68,GUIGUIOptnsText8,0 GUIOuttextwin2u 10,26,78,GUIGUIOptnsTextA,0 GUIOuttextwin2 10,60,111,GUIGUIOptnsTextG GUIOuttextwin2 10,100,111,GUIGUIOptnsTextH GUIOuttextwin2 10,147,111,GUIGUIOptnsTextI GUIOuttextwin2u 10,26,88,GUIGUIOptnsTextB,1 GUIOuttextwin2u 10,138,88,GUIGUIOptnsTextBb,2 GUIOuttextwin2u 10,26,98,GUIGUIOptnsTextC,3 GUIOuttextwin2u 10,138,98,GUIGUIOptnsTextCb,13 GUIOuttextwin2u 10,138,28,GUIGUIOptnsTextJ,0 GUIOuttextwin2u 10,138,48,GUIGUIOptnsTextM,0 %ifdef __WIN32__ GUIOuttextwin2u 10,26,173,GUIGUIOptnsTextE,0 GUIOuttextwin2u 10,26,183,GUIGUIOptnsTextF,2 GUIOuttextwin2u 10,138,38,GUIGUIOptnsTextK,1 GUIOuttextwin2u 10,26,193,GUIGUIOptnsTextL,1 GUIOuttextwin2u 10,138,58,GUIGUIOptnsTextN,1 %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,16,123,GUIGUIOptnsText6 mov byte[GUIGUIOptnsText6],'G' GUIOuttextwin2 10,16,135,GUIGUIOptnsText6 mov byte[GUIGUIOptnsText6],'B' GUIOuttextwin2 10,16,147,GUIGUIOptnsText6 add byte[GUItextcolor],15 GUIOuttextwin2 10,25,27,GUIGUIOptnsText2 GUIOuttextwin2 10,25,37,GUIGUIOptnsText3 GUIOuttextwin2 10,25,47,GUIGUIOptnsText4 GUIOuttextwin2 10,25,57,GUIGUIOptnsText7 GUIOuttextwin2 10,25,67,GUIGUIOptnsText8 GUIOuttextwin2 10,25,77,GUIGUIOptnsTextA GUIOuttextwin2 10,59,110,GUIGUIOptnsTextG GUIOuttextwin2 10,99,110,GUIGUIOptnsTextH GUIOuttextwin2 10,146,110,GUIGUIOptnsTextI GUIOuttextwin2 10,25,87,GUIGUIOptnsTextB GUIOuttextwin2 10,137,87,GUIGUIOptnsTextBb GUIOuttextwin2 10,25,97,GUIGUIOptnsTextC GUIOuttextwin2 10,137,97,GUIGUIOptnsTextCb GUIOuttextwin2 10,137,27,GUIGUIOptnsTextJ GUIOuttextwin2 10,137,47,GUIGUIOptnsTextM %ifdef __WIN32__ GUIOuttextwin2 10,25,172,GUIGUIOptnsTextE GUIOuttextwin2 10,25,182,GUIGUIOptnsTextF GUIOuttextwin2 10,137,37,GUIGUIOptnsTextK GUIOuttextwin2 10,25,192,GUIGUIOptnsTextL GUIOuttextwin2 10,137,57,GUIGUIOptnsTextN %endif mov byte[GUIGUIOptnsText6],'R' GUIOuttextwin2 10,15,122,GUIGUIOptnsText6 mov byte[GUIGUIOptnsText6],'G' GUIOuttextwin2 10,15,134,GUIGUIOptnsText6 mov byte[GUIGUIOptnsText6],'B' GUIOuttextwin2 10,15,146,GUIGUIOptnsText6 GUIDisplayButtonHole 10,48,108,byte[CurPalSelect],0 GUIDisplayButtonHole 10,88,108,byte[CurPalSelect],1 GUIDisplayButtonHole 10,135,108,byte[CurPalSelect],2 mov dword[GUIGUIOptnsText9],0 mov esi,GUIGUIOptnsText9+2 xor eax,eax mov al,[TRVal2] call .processnum GUIOuttextwin2 10,160,123,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],222 .zero5 GUIOuttextwin2 10,159,122,[GUITemp] mov dword[GUIGUIOptnsText9],0 mov esi,GUIGUIOptnsText9+2 xor eax,eax mov al,[TGVal2] call .processnum GUIOuttextwin2 10,160,135,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero6 mov byte[GUItextcolor],222 .zero6 GUIOuttextwin2 10,159,134,[GUITemp] mov dword[GUIGUIOptnsText9],0 mov esi,GUIGUIOptnsText9+2 xor eax,eax mov al,[TBVal2] call .processnum GUIOuttextwin2 10,160,147,[GUITemp] mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zero7 mov byte[GUItextcolor],222 .zero7 GUIOuttextwin2 10,159,146,[GUITemp] ret .processnum mov ebx,10 div bl add ah,48 mov [esi],ah cmp al,0 je .nomore dec esi xor ah,ah div bl add ah,48 mov [esi],ah .nomore mov [GUITemp],esi mov byte[GUItextcolor],223 ret ;mousewrap db 0 ; 0 = mouse boundries, 1 = mouse wrap ;mouseshad db 1 ; 0 = no mouse shadow, 1 = mouse shadow ;lastcursres db 0 ; 0 = go to load, 1 = go to previous menu, 2 = no menu ;resetposn db 1 ; 0 = no window reset, 1 = window reset GUIGUIOptnsText1 db 'COLOR:',0 GUIGUIOptnsText2 db 'MOUSE WRAP',0 GUIGUIOptnsText3 db 'MOUSE SHADOW',0 GUIGUIOptnsText4 db 'KEEP MENU POSITN',0 GUIGUIOptnsText5 db 'GUI SWITCHES :',0 GUIGUIOptnsText6 db '@',0 GUIGUIOptnsText7 db 'SAVE WIN POSITNS',0 GUIGUIOptnsText8 db 'CLICK ENTERS GUI',0 GUIGUIOptnsText9 dd 0 GUIGUIOptnsTextA db 'USE JOYPAD1',0 GUIGUIOptnsTextB dd 'SNOW EFFECT',0 GUIGUIOptnsTextBb dd 'SMOKE EFFECT',0 GUIGUIOptnsTextC dd 'WATER EFFECT A',0 GUIGUIOptnsTextCb dd 'WATER EFFECT B',0 GUIGUIOptnsTextD dd 'MAIN WINDOW OPTIONS :',0 GUIGUIOptnsTextE dd 'ALWAYS ON TOP',0 GUIGUIOptnsTextF db 'SAVE MAIN WINDOW POSITION',0 GUIGUIOptnsTextG db 'BACK',0 GUIGUIOptnsTextH db 'TITLE',0 GUIGUIOptnsTextI db 'WIN',0 GUIGUIOptnsTextJ db 'TRANSPARENT MSGS',0 GUIGUIOptnsTextK db 'WHEEL MOUSE',0 GUIGUIOptnsTextL db 'ALLOW MULTIPLE INSTANCES',0 GUIGUIOptnsTextM db 'FILTERED GUI',0 GUIGUIOptnsTextN db 'TRAP MOUSE CURSOR',0 DisplayGUIAbout: GUIDrawWindowBox 11,GUIAboutDisp mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero3 mov byte[GUItextcolor],211 .zero3 %ifndef __LINUX__ DrawGUIButton 11,90,50,175,60,GUIGUIAboutText8,65,0,0 %endif sub byte[GUItextcolor],15 GUIOuttextwin2 11,6,16,GUIGUIAboutText1 GUIOuttextwin2 11,6,26,GUIGUIAboutText7 GUIOuttextwin2 11,6,46,GUIGUIAboutText3 GUIOuttextwin2 11,6,56,GUIGUIAboutText4 GUIOuttextwin2 11,6,66,GUIGUIAboutText6c GUIOuttextwin2 11,6,86,GUIGUIAboutText6 GUIOuttextwin2 11,6,96,GUIGUIAboutText6b GUIOuttextwin2 11,6,106,GUIGUIAboutText6d GUIOuttextwin2 11,6,116,GUIGUIAboutText6e GUIOuttextwin2 11,6,131,GUIGUIAboutTextA GUIOuttextwin2 11,6,141,GUIGUIAboutTextB GUIOuttextwin2 11,6,151,GUIGUIAboutTextC GUIOuttextwin2 11,6,161,GUIGUIAboutTextD GUIOuttextwin2 11,6,171,GUIGUIAboutTextE GUIOuttextwin2 11,6,181,GUIGUIAboutTextF GUIOuttextwin2 11,6,191,GUIGUIAboutTextG add byte[GUItextcolor],15 GUIOuttextwin2 11,5,15,GUIGUIAboutText1 GUIOuttextwin2 11,5,25,GUIGUIAboutText7 GUIOuttextwin2 11,5,45,GUIGUIAboutText3 GUIOuttextwin2 11,5,55,GUIGUIAboutText4 GUIOuttextwin2 11,5,65,GUIGUIAboutText6c GUIOuttextwin2 11,5,85,GUIGUIAboutText6 GUIOuttextwin2 11,5,95,GUIGUIAboutText6b GUIOuttextwin2 11,5,105,GUIGUIAboutText6d GUIOuttextwin2 11,5,115,GUIGUIAboutText6e GUIOuttextwin2 11,5,130,GUIGUIAboutTextA GUIOuttextwin2 11,5,140,GUIGUIAboutTextB GUIOuttextwin2 11,5,150,GUIGUIAboutTextC GUIOuttextwin2 11,5,160,GUIGUIAboutTextD GUIOuttextwin2 11,5,170,GUIGUIAboutTextE GUIOuttextwin2 11,5,180,GUIGUIAboutTextF GUIOuttextwin2 11,5,190,GUIGUIAboutTextG mov al,[GUIWincol] mov byte[GUItextcolor],al GUIOuttextwin2 11,6,36,GUIGUIAboutText2 GUIOuttextwin2 11,6,76,GUIGUIAboutText5 mov byte[GUItextcolor],163 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],164 .zero GUIOuttextwin2 11,5,35,GUIGUIAboutText2 GUIOuttextwin2 11,5,75,GUIGUIAboutText5 ret GUIGUIAboutText1 db 'ZSNES V',ZVERSION,0 GUIGUIAboutText2 db 'CODED BY : ',0 GUIGUIAboutText3 db ' ZSKNIGHT',0 GUIGUIAboutText4 db ' _DEMO_',0 GUIGUIAboutText6c db ' PAGEFAULT',0 GUIGUIAboutText5 db 'ASSISTANT CODERS : ',0 GUIGUIAboutText6 db ' PHAROS',0 GUIGUIAboutText6b db ' TEUF',0 GUIGUIAboutText6d db ' THEODDONE33',0 GUIGUIAboutText6e db ' STAINLESS',0 %ifdef __MSDOS__ GUIGUIAboutText7 db 'DOS VERSION',0 %elifdef __WIN32__ GUIGUIAboutText7 db 'WIN VERSION',0 %elifdef __LINUX__ GUIGUIAboutText7 db 'LINUX VERSION',0 %endif GUIGUIAboutText8 db 'WWW.ZSNES.COM',0 GUIGUIAboutTextA db 'ZSNES comes with ABSOLUTELY',0 GUIGUIAboutTextB db 'NO WARRANTY. This is free',0 GUIGUIAboutTextC db 'software, and you are welcome',0 GUIGUIAboutTextD db 'to redistribute it under',0 GUIGUIAboutTextE db 'certain conditions; please',0 GUIGUIAboutTextF db 'please read ',39,'LICENSE',39,0 GUIGUIAboutTextG db 'thoroughly before using it.',0 DisplayGUIMovies: GUIDrawWindowBox 15,GUIMovieDisp cmp byte[MovieRecordWinVal],0 je near .displayboxa cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],211 .zero4 sub byte[GUItextcolor],15 GUIOuttextwin2 15,9,16,GUIMovieText5 GUIOuttextwin2 15,9,26,GUIMovieText6 GUIOuttextwin2 15,9,41,GUIMovieText7 add byte[GUItextcolor],15 GUIOuttextwin2 15,8,15,GUIMovieText5 GUIOuttextwin2 15,8,25,GUIMovieText6 GUIOuttextwin2 15,8,40,GUIMovieText7 DrawGUIButton 15,17,55,59,66,GUIMovieText8,19,0,0 DrawGUIButton 15,70,55,112,66,GUIMovieText9,20,0,0 ret .displayboxa mov dword[GUIMovieTextA+9],'INAC' mov dword[GUIMovieTextA+13],'TIVE' mov byte[GUIMovieTextA+17],' ' cmp byte[MovieProcessing],1 jne .noplay mov dword[GUIMovieTextA+9],'PLAY' mov dword[GUIMovieTextA+13],'ING ' mov byte[GUIMovieTextA+17],' ' .noplay cmp byte[MovieProcessing],2 jne .norec mov dword[GUIMovieTextA+9],'RECO' mov dword[GUIMovieTextA+13],'RDIN' mov byte[GUIMovieTextA+17],'G' .norec DrawGUIButton 15,7,17,49,28,GUIMovieText1,16,0,0 DrawGUIButton 15,7,33,49,44,GUIMovieText2,17,0,0 DrawGUIButton 15,7,49,49,60,GUIMovieText3,18,0,0 cmp byte[GUIWincoladd],0 je .zero mov byte[GUItextcolor],211 .zero sub byte[GUItextcolor],15 GUIOuttextwin2 15,61,16,GUIMovieText4 GUIOuttextwin2 15,7,70,GUIMovieTextA mov byte[GUIChoseSaveText2],'0' GUIOuttextwin2 15,71,28,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'1' GUIOuttextwin2 15,91,28,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'2' GUIOuttextwin2 15,111,28,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'3' GUIOuttextwin2 15,131,28,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'4' GUIOuttextwin2 15,71,43,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'5' GUIOuttextwin2 15,91,43,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'6' GUIOuttextwin2 15,111,43,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'7' GUIOuttextwin2 15,131,43,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'8' GUIOuttextwin2 15,71,58,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'9' GUIOuttextwin2 15,91,58,GUIChoseSaveText2 add byte[GUItextcolor],15 GUIOuttextwin2 15,60,15,GUIMovieText4 GUIOuttextwin2 15,6,69,GUIMovieTextA mov byte[GUIChoseSaveText2],'0' GUIOuttextwin2 15,70,27,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'1' GUIOuttextwin2 15,90,27,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'2' GUIOuttextwin2 15,110,27,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'3' GUIOuttextwin2 15,130,27,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'4' GUIOuttextwin2 15,70,42,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'5' GUIOuttextwin2 15,90,42,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'6' GUIOuttextwin2 15,110,42,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'7' GUIOuttextwin2 15,130,42,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'8' GUIOuttextwin2 15,70,57,GUIChoseSaveText2 mov byte[GUIChoseSaveText2],'9' GUIOuttextwin2 15,90,57,GUIChoseSaveText2 GUIDisplayButtonHole 15,60,25,byte[CMovieExt],'v' GUIDisplayButtonHole 15,80,25,byte[CMovieExt],'1' GUIDisplayButtonHole 15,100,25,byte[CMovieExt],'2' GUIDisplayButtonHole 15,120,25,byte[CMovieExt],'3' GUIDisplayButtonHole 15,60,40,byte[CMovieExt],'4' GUIDisplayButtonHole 15,80,40,byte[CMovieExt],'5' GUIDisplayButtonHole 15,100,40,byte[CMovieExt],'6' GUIDisplayButtonHole 15,120,40,byte[CMovieExt],'7' GUIDisplayButtonHole 15,60,55,byte[CMovieExt],'8' GUIDisplayButtonHole 15,80,55,byte[CMovieExt],'9' ret GUIMovieText1 db 'PLAY',0 GUIMovieText2 db 'RECORD',0 GUIMovieText3 db 'STOP',0 GUIMovieText4 db 'SELECT :',0 GUIMovieText5 db 'WARNING : THIS MOVIE',0 GUIMovieText6 db ' FILE ALREADY EXISTS',0 GUIMovieText7 db 'OKAY TO OVERWRITE?',0 GUIMovieText8 db 'YES',0 GUIMovieText9 db 'NO',0 GUIMovieTextA db 'STATUS : ',0 CMovieExt db 'v' ; Key types: Up, Down, Left, Right, A, B, X, Y, L, R (Press/Relase/P+R) ; Frame delays: 1 frame, 2, 3, 4, 5, 1 sec., 2, 3 ,4 ,5 %macro DrawBorderedBox 6 ; draw borders mov dl,[GUIWincol] DrawGUIWinBox %1,%2,%6,%4,%3,dl ; For some reason, this freezes if I ; replace %6 with %3-1 mov dl,[GUIWincol] add dl,1 DrawGUIWinBox %1,%2-1,%3,%2,%5,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox %1,%2,%5,%4,%5+1,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox %1,%4,%3,%4+1,%5,dl DrawGUIWinBox %1,%2,%3,%4,%5,167 %endmacro %macro DrawBorderedBoxB 7 ; Special function for combo displays ; draw borders mov dl,[GUIWincol] DrawGUIWinBox %1,%2,%6,%4,%3,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox %1,%2-1,%3,%2,%5,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox %1,%2,%5,%4,%5+1,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox %1,%4,%3,%4+1,%5,dl DrawGUIWinBox %1,%2,%3,%4,%5,167 mov byte[GUIComboText3],%7 mov byte[GUItextcolor],223 GUIOuttextwin2 %1,%2+5,%3+2,GUIComboText3 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je %%zero mov byte[GUItextcolor],222 %%zero GUIOuttextwin2 %1,%2+4,%3+1,GUIComboText3 %endmacro %macro DrawBorderedBoxB2 7 ; Special function for combo displays ; draw borders mov dl,[GUIWincol] DrawGUIWinBox %1,%2,%6,%4,%3,dl mov dl,[GUIWincol] add dl,1 DrawGUIWinBox %1,%2-1,%3,%2,%5,dl mov dl,[GUIWincol] add dl,4 DrawGUIWinBox %1,%2,%5,%4,%5+1,dl mov dl,[GUIWincol] add dl,3 DrawGUIWinBox %1,%4,%3,%4+1,%5,dl DrawGUIWinBox %1,%2,%3,%4,%5,167 mov byte[GUIComboText3b+1],%7 mov byte[GUItextcolor],223 GUIOuttextwin2 %1,%2+2,%3+2,GUIComboText3b mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je %%zero mov byte[GUItextcolor],222 %%zero GUIOuttextwin2 %1,%2+1,%3+1,GUIComboText3b %endmacro %macro InitTextColor 0 mov al,217 cmp byte[GUIWincoladd],0 je .zero3 mov al,211 .zero3 sub al,15 mov byte[TextColorSp+2],al mov al,[GUIWincol] mov byte[TextColorSp],al mov al,163 cmp byte[GUIWincoladd],0 je .zero mov al,164 mov byte[GUItextcolor],164 .zero mov byte[TextColorSp+1],al %endmacro %macro GUIOuttextwin2b 4 ; Special, yellow text mov al,[TextColorSp] mov byte[GUItextcolor],al GUIOuttextwin2 %1,%2,%3,%4 mov al,[TextColorSp+1] mov byte[GUItextcolor],al GUIOuttextwin2 %1,%2-1,%3-1,%4 %endmacro %macro GUIOuttextwin2c 4 ; Boxed, green text mov byte[GUItextcolor],223 GUIOuttextwin2 %1,%2,%3,%4 mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je %%zero mov byte[GUItextcolor],222 %%zero GUIOuttextwin2 %1,%2-1,%3-1,%4 %endmacro %macro DrawSlideBar 10 DrawSlideBarWin %1,%2,%3+8,%4,%5,%6,%7-16,%8 mov al,[TextColorSp+2] mov byte[GUItextcolor],al cmp byte[GUICHold],%9 jne .noholda add byte[GUIWincoladd],3 .noholda GUIDisplayIconWin %1,%2,%3,GUIIconDataUpArrow cmp byte[GUICHold],%9 jne .noholda2 sub byte[GUIWincoladd],3 .noholda2 mov al,[TextColorSp+2] mov byte[GUItextcolor],al cmp byte[GUICHold],%10 jne .noholdb add byte[GUIWincoladd],3 .noholdb GUIDisplayIconWin %1,%2,%3+%7-8,GUIIconDataDownArrow cmp byte[GUICHold],%10 jne .noholdb2 sub byte[GUIWincoladd],3 .noholdb2 %endmacro %macro DrawCheckBox 4 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[%4],0 je %%nocheck4 mov dword[GUITemp],GUIIconDataCheckBoxC %%nocheck4 GUIDisplayIconWin %1,%2,%3,[GUITemp] %endmacro %macro DetermineChar 2 cmp al,%1 jne %%control mov al,%2 %%control %endmacro DisplayGUICombo: mov eax,[GUIccombcursloc] cmp [GUIccomblcursloc],eax je .nolastcurschange mov [GUIccomblcursloc],eax ; copy contents into temporary variables mov esi,[GUIccombcursloc] shl esi,6 add esi,[GUIccombcursloc] add esi,[GUIccombcursloc] add esi,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespecb sub esi,CombinDataGlob add esi,CombinDataLocl .nogamespecb ; copy 20 bytes to GUIComboTextH mov ecx,20 mov edi,GUIComboTextH rep movsb ; copy 42 bytes to GUIComboData mov ecx,42 mov edi,GUIComboData rep movsb mov ax,[esi] mov [GUIComboKey],ax mov al,[esi+2] mov [GUIComboPNum],al mov al,[esi+3] mov [GUIComboLHorz],al ; determine length of combo data mov eax,GUIComboData xor ecx,ecx .notfin cmp byte[eax],0 je .fin inc eax inc ecx jmp .notfin .fin mov [GUINumCombo],cl .nolastcurschange ; copy into data if description equal mov esi,[GUIccombcursloc] shl esi,6 add esi,[GUIccombcursloc] add esi,[GUIccombcursloc] add esi,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespecc sub esi,CombinDataGlob add esi,CombinDataLocl .nogamespecc mov ecx,20 mov edi,GUIComboTextH .comploop mov al,[esi] cmp al,[edi] jne near .notequal or al,al jz .donecomp inc esi inc edi dec ecx jnz .comploop .donecomp call ComboClip mov edi,[GUIccombcursloc] shl edi,6 add edi,[GUIccombcursloc] add edi,[GUIccombcursloc] add edi,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespecd sub edi,CombinDataGlob add edi,CombinDataLocl .nogamespecd mov ecx,20 mov esi,GUIComboTextH rep movsb ; copy 42 bytes to GUIComboData mov ecx,42 mov esi,GUIComboData rep movsb mov ax,[GUIComboKey] mov [edi],ax mov al,[GUIComboPNum] mov [edi+2],al mov al,[GUIComboLHorz] mov [edi+3],al .notequal InitTextColor cmp byte[GUIWincoladd],0 je .zero4 mov byte[GUItextcolor],211 .zero4 GUIDrawWindowBox 16,GUIComboDisp DrawBorderedBox 16,10,20,190,80,19 DrawBorderedBox 16,10,91,130,99,90 DrawBorderedBox 16,135,91,157,99,90 DrawBorderedBox 16,10,110,220,146,109 ; Draw SlideBar ; win#,X,Y start,List Loc,List size,# Lines,Bar Size(Y),UpArrowResource#,DownArrowRes# DrawSlideBar 16,192,20,[GUIccombviewloc],[NumCombo],8,61,GUICSStC,13,14 ; Draw control boxes DrawBorderedBoxB 16,75,150,85,157,149,251 DrawBorderedBoxB 16,89,150,99,157,149,252 DrawBorderedBoxB 16,103,150,113,157,149,253 DrawBorderedBoxB 16,117,150,127,157,149,254 DrawBorderedBoxB 16,131,150,141,157,149,'A' DrawBorderedBoxB 16,145,150,155,157,149,'B' DrawBorderedBoxB 16,159,150,169,157,149,'X' DrawBorderedBoxB 16,173,150,183,157,149,'Y' DrawBorderedBoxB 16,187,150,197,157,149,'L' DrawBorderedBoxB 16,201,150,211,157,149,'R' DrawBorderedBoxB2 16,215,150,227,157,149,'T' DrawBorderedBoxB2 16,231,150,243,157,149,'L' DrawBorderedBoxB 16,75,160,85,167,159,251 DrawBorderedBoxB 16,89,160,99,167,159,252 DrawBorderedBoxB 16,103,160,113,167,159,253 DrawBorderedBoxB 16,117,160,127,167,159,254 DrawBorderedBoxB 16,131,160,141,167,159,'A' DrawBorderedBoxB 16,145,160,155,167,159,'B' DrawBorderedBoxB 16,159,160,169,167,159,'X' DrawBorderedBoxB 16,173,160,183,167,159,'Y' DrawBorderedBoxB 16,187,160,197,167,159,'L' DrawBorderedBoxB 16,201,160,211,167,159,'R' DrawBorderedBoxB2 16,215,160,227,167,159,'T' DrawBorderedBoxB2 16,231,160,243,167,159,'L' DrawBorderedBoxB 16,75,170,85,177,169,251 DrawBorderedBoxB 16,89,170,99,177,169,252 DrawBorderedBoxB 16,103,170,113,177,169,253 DrawBorderedBoxB 16,117,170,127,177,169,254 DrawBorderedBoxB 16,131,170,141,177,169,'A' DrawBorderedBoxB 16,145,170,155,177,169,'B' DrawBorderedBoxB 16,159,170,169,177,169,'X' DrawBorderedBoxB 16,173,170,183,177,169,'Y' DrawBorderedBoxB 16,187,170,197,177,169,'L' DrawBorderedBoxB 16,201,170,211,177,169,'R' DrawBorderedBoxB2 16,215,170,227,177,169,'T' DrawBorderedBoxB2 16,231,170,243,177,169,'L' DrawBorderedBoxB 16,10,189,20,196,188,'1' DrawBorderedBoxB 16,24,189,34,196,188,'2' DrawBorderedBoxB 16,38,189,48,196,188,'3' DrawBorderedBoxB 16,52,189,62,196,188,'4' DrawBorderedBoxB 16,66,189,76,196,188,'5' DrawBorderedBoxB 16,80,189,90,196,188,'9' DrawBorderedBoxB 16,107,189,117,196,188,250 DrawBorderedBoxB 16,121,189,131,196,188,'1' DrawBorderedBoxB 16,135,189,145,196,188,'2' DrawBorderedBoxB 16,149,189,159,196,188,'3' DrawBorderedBoxB 16,163,189,173,196,188,'4' DrawBorderedBoxB 16,177,189,187,196,188,'5' DrawBorderedBoxB 16,204,189,218,196,188,255 ; Normal Text mov byte[GUItextcolor],217 cmp byte[GUIWincoladd],0 je .zero5 mov byte[GUItextcolor],211 .zero5 sub byte[GUItextcolor],15 GUIOuttextwin2 16,10,13,GUIComboText1 GUIOuttextwin2 16,138,13,GUIComboText2 GUIOuttextwin2 16,10,84,GUIComboTextE GUIOuttextwin2 16,138,84,GUIComboTextF GUIOuttextwin2 16,10,103,GUIComboText4 GUIOuttextwin2 16,10,152,GUIComboText5 GUIOuttextwin2 16,10,162,GUIComboText6 GUIOuttextwin2 16,10,172,GUIComboText7 GUIOuttextwin2 16,10,182,GUIComboText8 GUIOuttextwin2 16,114,182,GUIComboText9 GUIOuttextwin2 16,204,182,GUIComboTextG GUIOuttextwin2 16,165,85,GUIComboTextI GUIOuttextwin2 16,176,93,GUIComboTextJ GUIOuttextwin2 16,176,101,GUIComboTextK add byte[GUItextcolor],15 GUIOuttextwin2 16,9,12,GUIComboText1 GUIOuttextwin2 16,137,12,GUIComboText2 GUIOuttextwin2 16,9,83,GUIComboTextE GUIOuttextwin2 16,137,83,GUIComboTextF GUIOuttextwin2 16,9,102,GUIComboText4 GUIOuttextwin2 16,9,151,GUIComboText5 GUIOuttextwin2 16,9,161,GUIComboText6 GUIOuttextwin2 16,9,171,GUIComboText7 GUIOuttextwin2 16,9,181,GUIComboText8 GUIOuttextwin2 16,113,181,GUIComboText9 GUIOuttextwin2 16,203,181,GUIComboTextG GUIOuttextwin2 16,164,84,GUIComboTextI GUIOuttextwin2 16,175,92,GUIComboTextJ GUIOuttextwin2 16,175,100,GUIComboTextK ; Buttons DrawGUIButton 16,202,20,246,31,GUIComboTextA,60,-1,0 DrawGUIButton 16,202,35,246,46,GUIComboTextB,61,-1,0 DrawGUIButton 16,202,50,246,61,GUIComboTextC,62,-1,0 DrawGUIButton 16,202,65,246,76,GUIComboTextD,63,-1,0 ; Calculate Text Cursor Position / Draw Box Text xor eax,eax .nozerocp cmp byte[GUIComboTextH+eax],0 je .zerocp inc eax jmp .nozerocp .zerocp mov [GUIComboPos],al test byte[GUICCFlash],8 jnz .nound mov byte[GUIComboTextH+eax],'_' mov byte[GUIComboTextH+eax+1],0 .nound GUIOuttextwin2c 16,12,94,GUIComboTextH xor eax,eax mov al,[GUIComboPos] mov byte[GUIComboTextH+eax],0 ; Display Current Combo Key mov eax,[GUIComboKey] mov ebx,[ScanCodeListing+eax*3] mov [GUIGameDisplayKy],ebx mov byte[GUIGameDisplayKy+3],0 GUIOuttextwin2c 16,139,94,GUIGameDisplayKy ; Hole Switches GUIDisplayButtonHole 16,178,82,byte[GUIComboPNum],0 GUIDisplayButtonHole 16,196,82,byte[GUIComboPNum],1 GUIDisplayButtonHole 16,214,82,byte[GUIComboPNum],2 GUIDisplayButtonHole 16,232,82,byte[GUIComboPNum],3 ; Check Box DrawCheckBox 16,163,88,GUIComboLHorz DrawCheckBox 16,163,96,GUIComboGameSpec ; Draw Combination Keys (Each 15x11 -> 210x36) xor eax,eax mov al,[GUINumCombo] or eax,eax jz near .comboend xor ebx,ebx mov ecx,11 mov edx,112 .comboiconloop push eax mov al,[GUIComboData+ebx] dec al mov esi,GUIIconDataComboPressRelease cmp al,12 jb .doneicon mov esi,GUIIconDataComboPress sub al,12 cmp al,12 jb .doneicon mov esi,GUIIconDataComboRelease sub al,12 cmp al,12 jb .doneicon mov esi,GUIIconDataComboFrame cmp al,17 jne .not9 mov al,20 jmp .doneicon .not9 cmp al,18 jb .doneicon sub al,7 mov esi,GUIIconDataComboSecond cmp al,11 jne .notback mov al,250-37 jmp .doneicon .notback .doneicon cmp al,11 jbe .control add al,37 .control DetermineChar 0,251 DetermineChar 1,252 DetermineChar 2,253 DetermineChar 3,254 DetermineChar 4,'A' DetermineChar 5,'B' DetermineChar 6,'X' DetermineChar 7,'Y' DetermineChar 8,'L' DetermineChar 9,'R' DetermineChar 10,'T' DetermineChar 11,'E' mov [GUIComboText3],al pushad mov eax,edx add ecx,8 add eax,5 mov byte[GUItextcolor],223 push ecx push eax GUIOuttextwin2 16,ecx,eax,GUIComboText3 pop eax pop ecx mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zerocol mov byte[GUItextcolor],222 .zerocol dec ecx dec eax GUIOuttextwin2 16,ecx,eax,GUIComboText3 popad push ecx push edx push ebx GUIDisplayIconWin 16,ecx,edx,esi pop ebx pop edx pop ecx pop eax add ecx,15 cmp ecx,11+15*14 jne .notoverflowx sub ecx,15*14 add edx,11 .notoverflowx inc ebx dec eax jnz near .comboiconloop .comboend ; Display Bordered Box cmp dword[NumCombo],0 je near .nowinbox mov ebx,[GUIccombcursloc] sub ebx,[GUIccombviewloc] mov eax,ebx lea ebx,[ebx*8] sub ebx,eax add ebx,23 DrawGUIWinBox2 16,10,190,7,224 .nowinbox ; Display Scroll Lines ; Copy Description to GUIScrolBufA, Others to GUIScrolBufB mov edi,[GUIccombviewloc] shl edi,6 add edi,[GUIccombviewloc] add edi,[GUIccombviewloc] add edi,CombinDataGlob cmp byte[GUIComboGameSpec],0 je .nogamespec sub edi,CombinDataGlob add edi,CombinDataLocl .nogamespec mov ecx,12 mov eax,25 mov ebx,[NumCombo] sub ebx,[GUIccombviewloc] cmp ebx,0 jle near .noscrolldisplay cmp ebx,8 jbe .scrolloop mov ebx,8 .scrolloop push ebx push edi push eax xor eax,eax mov ax,[edi+62] mov eax,[ScanCodeListing+eax*3] mov [GUIScrolBufB],eax mov byte[GUIScrolBufB+3],32 mov dword[GUIScrolBufB+4],20202020h mov al,[edi+64] add al,49 mov [GUIScrolBufB+4],al mov byte[GUIScrolBufB+7],'N' cmp byte[edi+65],0 je .yesnoff mov byte[GUIScrolBufB+7],'Y' .yesnoff mov bl,20 mov eax,GUIScrolBufA .scloopb mov bh,[edi] mov [eax],bh inc edi inc eax dec bl jnz .scloopb pop eax mov byte[GUItextcolor],223 push ecx push eax GUIOuttextwin2 16,ecx,eax,GUIScrolBufA pop eax pop ecx push ecx push eax add ecx,128 GUIOuttextwin2 16,ecx,eax,GUIScrolBufB pop eax pop ecx mov byte[GUItextcolor],221 cmp byte[GUIWincoladd],0 je .zerocolb mov byte[GUItextcolor],222 .zerocolb push ecx push eax dec ecx dec eax push ecx push eax GUIOuttextwin2 16,ecx,eax,GUIScrolBufA pop eax pop ecx add ecx,128 GUIOuttextwin2 16,ecx,eax,GUIScrolBufB pop eax pop ecx pop edi pop ebx add eax,7 add edi,66 dec ebx jnz near .scrolloop .noscrolldisplay ret GUIccombviewloc dd 0 GUIccombcursloc dd 0 GUIccomblcursloc dd 0 NEWSYM NumCombo, dd 0 NumComboGlob dd 0 NEWSYM NumComboLocl, dd 0 GUICSStC dd 0,0,0 GUIComboKey dd 0 GUIComboPos db 0 GUIComboPNum db 0 GUIComboLHorz db 0 NEWSYM GUINumCombo, db 0 GUIComboData times 50 db 0 GUIScrolBufA times 21 db 0 GUIScrolBufB times 10 db 0 ;CombinDataGlob times 3300 db 0 ; 20-name, 42-combo, 2-key#, 1-P#, 1-ff ;CombinDataLocl times 3300 db 0 GUIComboText1 db 'DESCRIPTION',0 GUIComboText2 db 'KEY P# LH',0 GUIComboText3 db ' ',0 GUIComboText3b db 'S ',0 GUIComboText4 db 'COMBINATION KEYS:',0 GUIComboText5 db 'PRESS+REL',0 GUIComboText6 db 'PRESS ONLY',0 GUIComboText7 db 'REL ONLY',0 GUIComboText8 db 'FRAME DELAY',0 GUIComboText9 db 'SECOND DELAY',0 GUIComboTextA db 'CLEAR',0 GUIComboTextB db 'ADD',0 GUIComboTextC db 'REPLACE',0 GUIComboTextD db 'DELETE',0 GUIComboTextE db 'DESCRIPTION:',0 GUIComboTextF db 'KEY:',0 GUIComboTextG db 'DEL',0 GUIComboTextH db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 GUIComboTextI db 'P# 1 2 3 4',0 GUIComboTextJ db 254,' = LAST ',253,'/',254,0 GUIComboTextK db 'GAME SPECFIC',0 GUIIconDataComboPressRelease: db 0 ,166,0 ,0 ,166,0 ,0 ,0 ,0 ,0 db 0 ,166,0 ,166,166,166,0 ,0 ,0 ,0 db 0 ,166,0 ,0 ,166,0 ,0 ,0 ,0 ,0 db 166,166,166,0 ,166,0 ,0 ,0 ,0 ,0 db 0 ,166,0 ,0 ,166,0 ,0 ,0 ,0 ,0 db 0 ,234,234,234,234,0 ,0 ,0 ,0 ,0 db 234,234,234,234,234,234,0 ,0 ,0 ,0 db 234,234,234,234,234,234,0 ,0 ,0 ,0 db 235,234,234,234,234,235,0 ,0 ,0 ,0 db 0 ,235,235,235,235,0 ,0 ,0 ,0 ,0 GUIIconDataComboPress: db 0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,166,166,166,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,236,236,236,236,0 ,0 ,0 ,0 ,0 db 236,236,236,236,236,236,0 ,0 ,0 ,0 db 236,236,236,236,236,236,0 ,0 ,0 ,0 db 237,236,236,236,236,237,0 ,0 ,0 ,0 db 0 ,237,237,237,237,0 ,0 ,0 ,0 ,0 GUIIconDataComboRelease: db 0 ,0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,166,166,166,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,166,0 ,0 ,0 ,0 ,0 ,0 db 0 ,238,238,238,238,0 ,0 ,0 ,0 ,0 db 238,238,238,238,238,238,0 ,0 ,0 ,0 db 238,238,238,238,238,238,0 ,0 ,0 ,0 db 239,238,238,238,238,239,0 ,0 ,0 ,0 db 0 ,239,239,239,239,0 ,0 ,0 ,0 ,0 GUIIconDataComboFrame: db 0 ,0 ,0 ,0 ,58 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,56 ,46 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,54 ,44 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,52 ,0 ,42 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,50 ,40 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,48 ,38 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,46 ,36 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,44 ,0 ,34 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,42 ,32 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,40 ,32 ,0 ,0 ,0 ,0 ,0 ,0 GUIIconDataComboSecond: db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,51 ,45 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,51 ,45 ,0 ,0 ,0 ,0 ,0 ,0 db 0 ,54 ,52 ,48 ,46 ,0 ,0 ,0 ,0 ,0 db 53 ,46 ,50 ,50 ,48 ,45 ,0 ,0 ,0 ,0 db 52 ,50 ,45 ,48 ,46 ,44 ,0 ,0 ,0 ,0 db 51 ,50 ,50 ,46 ,50 ,43 ,0 ,0 ,0 ,0 db 50 ,50 ,50 ,50 ,50 ,42 ,0 ,0 ,0 ,0 db 0 ,48 ,46 ,44 ,42 ,0 ,0 ,0 ,0 ,0 db 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 DisplayGUIAddOns: GUIDrawWindowBox 17,GUIAddOnsDisp sub byte[GUItextcolor],15 GUIOuttextwin2 17,21,18,GUIAddOnText1 GUIOuttextwin2 17,21,28,GUIAddOnText2 GUIOuttextwin2 17,21,38,GUIAddOnText3 GUIOuttextwin2 17,21,48,GUIAddOnText4 GUIOuttextwin2 17,21,58,GUIAddOnText5 GUIOuttextwin2 17,10,78,GUIAddOnText6 GUIOuttextwin2 17,21,88,GUIAddOnText7 GUIOuttextwin2 17,71,88,GUIAddOnText8 GUIOuttextwin2 17,121,88,GUIAddOnText9 GUIOuttextwin2 17,21,98,GUIAddOnTextA GUIOuttextwin2 17,71,98,GUIAddOnTextB GUIOuttextwin2 17,121,98,GUIAddOnTextC add byte[GUItextcolor],15 GUIOuttextwin2 17,20,17,GUIAddOnText1 GUIOuttextwin2 17,20,27,GUIAddOnText2 GUIOuttextwin2 17,20,37,GUIAddOnText3 GUIOuttextwin2 17,20,47,GUIAddOnText4 GUIOuttextwin2 17,20,57,GUIAddOnText5 GUIOuttextwin2 17,9,77,GUIAddOnText6 GUIOuttextwin2 17,20,87,GUIAddOnText7 GUIOuttextwin2 17,70,87,GUIAddOnText8 GUIOuttextwin2 17,120,87,GUIAddOnText9 GUIOuttextwin2 17,20,97,GUIAddOnTextA GUIOuttextwin2 17,70,97,GUIAddOnTextB GUIOuttextwin2 17,120,97,GUIAddOnTextC GUIDisplayButtonHole 17,9,15,byte[snesmouse],0 GUIDisplayButtonHole 17,9,25,byte[snesmouse],1 GUIDisplayButtonHole 17,9,35,byte[snesmouse],2 GUIDisplayButtonHole 17,9,45,byte[snesmouse],3 GUIDisplayButtonHole 17,9,55,byte[snesmouse],4 mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip1],0 je .nodip1 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip1 GUIDisplayIconWin 17,9,83,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip2],0 je .nodip2 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip2 GUIDisplayIconWin 17,59,83,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip3],0 je .nodip3 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip3 GUIDisplayIconWin 17,109,83,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip4],0 je .nodip4 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip4 GUIDisplayIconWin 17,9,93,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip5],0 je .nodip5 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip5 GUIDisplayIconWin 17,59,93,[GUITemp] mov dword[GUITemp],GUIIconDataCheckBoxUC cmp byte[nssdip6],0 je .nodip6 mov dword[GUITemp],GUIIconDataCheckBoxC .nodip6 GUIDisplayIconWin 17,109,93,[GUITemp] ret GUIAddOnText1 db 'NONE',0 GUIAddOnText2 db 'SNES MOUSE AT PORT #1',0 GUIAddOnText3 db 'SNES MOUSE AT PORT #2',0 GUIAddOnText4 db 'SUPER SCOPE',0 GUIAddOnText5 db 'LETHAL ENFORCER GUN',0 GUIAddOnText6 db 'SUPER SYSTEM',0 GUIAddOnText7 db 'DIP 1',0 GUIAddOnText8 db 'DIP 2',0 GUIAddOnText9 db 'DIP 3',0 GUIAddOnTextA db 'DIP 4',0 GUIAddOnTextB db 'DIP 5',0 GUIAddOnTextC db 'DIP 6',0 GUILoadDisp db 'LOAD GAME',0 GUIResetDisp db 'RESET GAME',0 GUIStateSelDisp db 'STATE SELECT',0 GUIInputDisp db 'INPUT DEVICE',0 GUIOptionDisp db 'OPTIONS',0 GUISoundDisp db 'SOUND CONFIG',0 GUIVideoDisp db 'VIDEO CONFIG',0 GUICheatDisp db 'CHEAT',0 GUISearchDisp db 'CHEAT SEARCH',0 GUINetDisp db 'REMOTE',0,0,0,0,0,0,0,0,0 GUIGameDisp db 'GAME KEYS',0 GUIGUIDisp db 'GUI OPTIONS',0 GUIAboutDisp db 'ABOUT',0 GUIMovieDisp db 'MOVIE OPTIONS',0 GUIStatesDisp db 'STATE CONFIRM',0 GUIComboDisp db 'KEY COMBINATION EDITOR',0 GUIAddOnsDisp db 'ADD-ON SELECTOR',0 GUIItemBoxColor dd 0 TextColorSp dd 0 NEWSYM GUIMenuItem, db 'GAME ',0 db 'CONFIG',0 db 'CHEAT ',0 db 'NETPLAY',0 db 'MISC ',0 db 25,0 zsnes-1.36/src/gui/menu.asm0100644000175000017500000007712307470246047015231 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %include "macros.mac" EXTSYM DSPMem,FPSOn,Makemode7Table,MessageOn,vesa2red10,scanlines,smallscreenon EXTSYM MsgCount,Msgptr,OutputGraphicString,OutputGraphicString16b EXTSYM PrepareSaveState,ResetState,breakatsignb,breakatsignc,cvidmode EXTSYM cbitmode,copyvid,curblank,drawhline,drawhline16b,drawvline EXTSYM drawvline16b,fnames,frameskip,mode7tab,pressed,spcA EXTSYM spcBuffera,spcNZ,spcP,spcPCRam,spcRam,spcRamDP,spcS,spcX,spcY EXTSYM spcon,vesa2_bpos,vesa2_clbit,vesa2_gpos,vesa2_rpos,vesa2selec EXTSYM vidbuffer,spritetablea,sprlefttot,newengen,spcextraram,resolutn EXTSYM Open_File,Close_File,Read_File,Write_File,Create_File,Get_Key,Get_Date EXTSYM continueprognokeys,ForceNonTransp,GUIOn,Check_Key,JoyRead EXTSYM GetScreen,SSKeyPressed,SPCKeyPressed,StopSound,StartSound EXTSYM ExecExitOkay,t1cc EXTSYM Clear2xSaIBuffer EXTSYM romdata,romtype,ScreenShotFormat EXTSYM Voice0Disable,Voice1Disable,Voice2Disable,Voice3Disable EXTSYM Voice4Disable,Voice5Disable,Voice6Disable,Voice7Disable %ifndef NO_PNG EXTSYM Grab_PNG_Data %endif NEWSYM MenuAsmStart GUIBufferData: mov ecx,16384 cmp byte[cbitmode],1 jne near .16b add ecx,16384 .16b ; copy to spritetable mov esi,[vidbuffer] mov edi,[spritetablea] .loop mov eax,[esi] mov [edi],eax add esi,4 add edi,4 dec ecx jnz .loop mov edi,sprlefttot mov ecx,64*5 .a mov dword[edi],0 add edi,4 dec ecx jnz .a ret GUIUnBuffer: mov ecx,16384 cmp byte[cbitmode],1 jne near .16b add ecx,16384 .16b ; copy from spritetable mov esi,[vidbuffer] mov edi,[spritetablea] .loop mov eax,[edi] mov [esi],eax add esi,4 add edi,4 dec ecx jnz .loop ret NEWSYM nextmenupopup, db 0 NEWSYM NoInputRead, db 0 NEWSYM PrevMenuPos, db 0 NEWSYM MenuDisplace, dd 0 NEWSYM MenuDisplace16, dd 0 NEWSYM MenuNoExit, db 0 NEWSYM SPCSave, db 0 NEWSYM showmenu mov byte[ForceNonTransp],1 cmp byte[cbitmode],1 je near .nopalread mov edi,[vidbuffer] add edi,100000 mov dx,03C7h mov al,0 out dx,al mov dx,03C9h mov ecx,768 mov byte[edi],12 inc edi .b in al,dx shl al,2 mov [edi],al inc edi dec ecx jnz .b .nopalread cmp byte[cbitmode],1 je near .nopal16b ; set palette of colors 128,144, and 160 to white, blue, and red mov al,128 mov dx,03C8h out dx,al inc dx mov al,63 out dx,al out dx,al out dx,al mov al,144 mov dx,03C8h out dx,al inc dx xor al,al out dx,al out dx,al mov al,50 out dx,al mov al,160 mov dx,03C8h out dx,al inc dx mov al,45 out dx,al xor al,al out dx,al out dx,al .nopal16b mov byte[NoInputRead],0 cmp byte[newengen],0 je .nong16b cmp byte[cbitmode],0 je .nong16b call GetScreen .nong16b cmp byte[SSKeyPressed],1 jne .nosskey mov byte[SSKeyPressed],0 call savepcx jmp .nopalwrite .nosskey cmp byte[SPCKeyPressed],1 je near .savespckey test byte[pressed+14],1 jz .nof12 call savepcx jmp .nopalwrite .nof12 mov dword[menucloc],0 cmp byte[nextmenupopup],0 je .nomenuinc2 mov byte[pressed+1Ch],0 mov dword[menucloc],40*288 cmp byte[PrevMenuPos],1 jne .nomenuinc mov dword[menucloc],50*288 .nomenuinc cmp byte[PrevMenuPos],2 jne .nomenuinc2 mov dword[menucloc],60*288 .nomenuinc2 cmp byte[PrevMenuPos],3 jne .nomenuinc3 mov dword[menucloc],70*288 .nomenuinc3 mov dword[menudrawbox8b.stringi+13],' BMP' %ifndef NO_PNG cmp byte[ScreenShotFormat],0 je .normalscrn mov dword[menudrawbox8b.stringi+13],' PNG' %endif .normalscrn cmp byte[cbitmode],1 je near .nopcx mov dword[menudrawbox8b.stringi+13],' PCX' .nopcx mov byte[nextmenupopup],0 mov byte[menu16btrans],0 mov byte[pressed+1],0 mov byte[pressed+59],0 mov byte[curblank],00h call GUIBufferData ; Draw box call menudrawbox8b call menudrawbox8b cmp byte[newengen],0 je .notng mov byte[GUIOn],1 .notng pushad call copyvid popad call StopSound .nextkey call GUIUnBuffer call menudrawbox8b push eax call copyvid pop eax call JoyRead call Check_Key or al,al jz .nextkey call Get_Key cmp al,0 jne near .processextend call Get_Key cmp al,72 jne .noup cmp dword[menucloc],0 jne .nogoup add dword[menucloc],80*288 .nogoup sub dword[menucloc],10*288 call menudrawbox8b mov al,[newengen] mov byte[newengen],0 mov [newengen],al jmp .nextkey .noup cmp al,80 jne .nodown cmp dword[menucloc],70*288 jne .nogodown sub dword[menucloc],80*288 .nogodown add dword[menucloc],10*288 call menudrawbox8b mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al jmp .nextkey .nodown jmp .nextkey .processextend cmp al,27 je near .exitloop cmp al,13 je .done jmp .nextkey .done call GUIUnBuffer mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al cmp dword[menucloc],0 jne .nosavepcx call savepcx .nosavepcx cmp dword[menucloc],40*288 jne .nosavepcx2 call savepcx mov byte[ExecExitOkay],0 mov byte[nextmenupopup],3 mov byte[NoInputRead],1 mov byte[t1cc],0 mov byte[PrevMenuPos],0 .nosavepcx2 cmp dword[menucloc],50*288 jne .noskipframe mov byte[ExecExitOkay],0 mov byte[nextmenupopup],3 mov byte[NoInputRead],1 mov byte[t1cc],0 mov byte[PrevMenuPos],1 .noskipframe cmp dword[menucloc],70*288 jne .noimagechange cmp byte[cbitmode],0 je .noimagechange xor byte[ScreenShotFormat],1 mov byte[MenuNoExit],1 mov byte[ExecExitOkay],0 mov byte[nextmenupopup],1 mov byte[NoInputRead],1 mov byte[t1cc],0 mov byte[PrevMenuPos],3 .noimagechange cmp dword[menucloc],60*288 jne .nomovewin mov byte[MenuNoExit],1 mov byte[ExecExitOkay],0 mov byte[nextmenupopup],1 mov byte[NoInputRead],1 mov byte[t1cc],0 mov byte[PrevMenuPos],2 cmp dword[MenuDisplace],0 je .movewin mov dword[MenuDisplace],0 mov dword[MenuDisplace16],0 jmp .nomovewin .movewin mov dword[MenuDisplace],90*288 mov dword[MenuDisplace16],90*288*2 .nomovewin cmp dword[menucloc],10*288 jne .nofps cmp byte[frameskip],0 je .yesfs mov dword[Msgptr],.unablefps mov eax,[MsgCount] mov [MessageOn],eax jmp .nofps .yesfs xor byte[FPSOn],1 .nofps cmp dword[menucloc],20*288 jne near .nospcsave .savespckey cmp byte[spcon],0 je .nospc cmp byte[newengen],1 ; je .unablespc mov dword[Msgptr],.search mov eax,[MsgCount] mov [MessageOn],eax mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al ; call breakatsignc ; cmp byte[prbreak],1 ; je .yesesc mov byte[SPCSave],1 call breakatsignb mov byte[SPCSave],0 ; cmp byte[prbreak],1 ; je .yesesc call savespcdata mov byte[curblank],40h mov dword[Msgptr],.saved mov eax,[MsgCount] mov [MessageOn],eax jmp .nospcsave .nospc mov dword[Msgptr],.nosound mov eax,[MsgCount] mov [MessageOn],eax jmp .nospcsave .unablespc mov dword[Msgptr],.unable mov eax,[MsgCount] mov [MessageOn],eax jmp .nospcsave .yesesc mov dword[Msgptr],.escpress mov eax,[MsgCount] mov [MessageOn],eax .nospcsave cmp dword[menucloc],30*288 jne .nosnddmp call dumpsound mov dword[Msgptr],.sndbufsav mov eax,[MsgCount] mov [MessageOn],eax .nosnddmp cmp byte[SPCKeyPressed],1 jne .exitloop mov byte[SPCKeyPressed],0 jmp .nopalwrite .exitloop call GUIUnBuffer mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al cmp byte[cbitmode],1 je near .nopalwrite mov edi,[vidbuffer] add edi,100000 mov dx,03C8h mov al,0 out dx,al mov dx,03C9h mov ecx,768 inc edi .c mov al,[edi] shr al,2 out dx,al inc edi dec ecx jnz .c .nopalwrite mov eax,pressed mov ecx,256 .looppr cmp byte[eax],1 jne .notpr mov byte[eax],2 .notpr inc eax dec ecx jnz .looppr ; mov byte[pressed+1],2 ; cmp byte[pressed+59],1 ; jne .not59 ; mov byte[pressed+59],2 ;.not59 ; cmp byte[pressed+28],1 ; jne .not28 ; mov byte[pressed+28],2 ;.not28 call StartSound mov byte[ForceNonTransp],0 mov byte[GUIOn],0 call Clear2xSaIBuffer cmp byte[MenuNoExit],1 je .noexitmenu jmp continueprognokeys .noexitmenu mov byte[MenuNoExit],0 jmp showmenu .unablefps db 'NEED AUTO FRAMERATE ON',0 .sndbufsav db 'BUFFER SAVED AS SOUNDDMP.RAW',0 .search db 'SEARCHING FOR SONG START.',0 .nosound db 'SOUND MUST BE ENABLED.',0 .unable db 'CANNOT USE IN NEW GFX ENGINE.',0 .escpress db 'ESC TERMINATED SEARCH.',0 .saved db '.SPC FILE SAVED.',0 NEWSYM menudrawbox8b cmp byte[cbitmode],1 je near menudrawbox16b ; draw a small blue box with a white border mov esi,40+20*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,150 mov al,95 .loop mov byte[esi],144 inc esi dec ecx jnz .loop add esi,288-150 dec al mov ecx,150 jnz .loop mov al,128 ; Draw lines mov esi,40+20*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,150 call drawhline mov esi,40+20*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,95 call drawvline mov esi,40+114*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,150 call drawhline mov esi,40+32*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,150 call drawhline mov esi,189+20*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,95 call drawvline call menudrawcursor8b mov esi,45+23*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.string call OutputGraphicString mov esi,45+35*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringa call OutputGraphicString mov esi,45+45*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringb test byte[FPSOn],1 jz .nofps mov edi,.stringc .nofps call OutputGraphicString mov esi,45+55*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringd call OutputGraphicString mov esi,45+65*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringe call OutputGraphicString mov esi,45+75*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringf call OutputGraphicString mov esi,45+85*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringg call OutputGraphicString mov esi,45+95*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringh call OutputGraphicString mov esi,45+105*288 add esi,[vidbuffer] add esi,[MenuDisplace] mov edi,.stringi call OutputGraphicString mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al ret .string db 'MISC OPTIONS',0 .stringa db 'SAVE SNAPSHOT',0 .stringb db 'SHOW FPS',0 .stringc db 'HIDE FPS',0 .stringd db 'SAVE SPC DATA',0 .stringe db 'SOUND BUFFER DUMP',0 .stringf db 'SNAPSHOT/INCR FRM',0 .stringg db 'INCR FRAME ONLY',0 .stringh db 'MOVE THIS WINDOW',0 .stringi db 'IMAGE FORMAT: ---',0 NEWSYM menudrawcursor8b cmp byte[cbitmode],1 je near menudrawcursor16b ; draw a small red box mov esi,41+34*288 add esi,[menucloc] add esi,[vidbuffer] add esi,[MenuDisplace] mov ecx,148 mov al,9 .loop mov byte[esi],160 inc esi dec ecx jnz .loop add esi,288-148 dec al mov ecx,148 jnz .loop mov al,128 ret NEWSYM menucloc, dd 0 NEWSYM menudrawbox16b ; draw shadow behind box cmp byte[menu16btrans],0 jne .noshadow mov byte[menu16btrans],1 mov esi,50*2+30*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,150 mov al,85 mov ah,5 .loop16b2 mov dx,[esi] and dx,[vesa2_clbit] shr dx,1 mov [esi],dx add esi,2 dec ecx jnz .loop16b2 add esi,288*2-150*2 dec al mov ecx,150 jnz .loop16b2 .noshadow mov ax,01Fh mov cl,[vesa2_rpos] shl ax,cl mov [.allred],ax mov ax,012h mov cl,[vesa2_bpos] shl ax,cl mov dx,ax mov ax,01h mov cl,[vesa2_gpos] shl ax,cl mov bx,ax mov ax,01h mov cl,[vesa2_rpos] shl ax,cl or bx,ax ; draw a small blue box with a white border mov esi,40*2+20*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,150 mov al,95 mov ah,5 .loop16b mov [esi],dx add esi,2 dec ecx jnz .loop16b add esi,288*2-150*2 dec ah jnz .nocolinc16b add dx,bx mov ah,5 .nocolinc16b dec al mov ecx,150 jnz .loop16b ; Draw lines mov ax,0FFFFh mov esi,40*2+20*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,150 call drawhline16b mov esi,40*2+20*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,95 call drawvline16b mov esi,40*2+114*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,150 call drawhline16b mov esi,40*2+32*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,150 call drawhline16b mov esi,189*2+20*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,95 call drawvline16b call menudrawcursor16b mov esi,45*2+23*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.string call OutputGraphicString16b mov esi,45*2+35*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringa call OutputGraphicString16b mov esi,45*2+45*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringb test byte[FPSOn],1 jz .nofps mov edi,menudrawbox8b.stringc .nofps call OutputGraphicString16b mov esi,45*2+55*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringd call OutputGraphicString16b mov esi,45*2+65*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringe call OutputGraphicString16b mov esi,45*2+75*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringf call OutputGraphicString16b mov esi,45*2+85*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringg call OutputGraphicString16b mov esi,45*2+95*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringh call OutputGraphicString16b mov esi,45*2+105*288*2 add esi,[vidbuffer] add esi,[MenuDisplace16] mov edi,menudrawbox8b.stringi call OutputGraphicString16b mov al,[newengen] mov byte[newengen],0 push eax call copyvid pop eax mov [newengen],al ret .allred dw 0 .blue dw 0 .stepb dw 0 NEWSYM menu16btrans, db 0 NEWSYM menudrawcursor16b ; draw a small red box mov esi,41*2+34*288*2 add esi,[menucloc] add esi,[menucloc] add esi,[vidbuffer] add esi,[MenuDisplace16] mov ecx,148 mov al,9 mov bx,[menudrawbox16b.allred] .loop mov [esi],bx add esi,2 dec ecx jnz .loop add esi,288*2-148*2 dec al mov ecx,148 jnz .loop mov al,128 ret NEWSYM savespcdata sub dword[spcPCRam],spcRam ; Assemble N/Z flags into P and byte[spcP],0FDh test byte[spcNZ],0FFh jnz .nozero or byte[spcP],02h .nozero and byte[spcP],07Fh test byte[spcNZ],80h jz .noneg or byte[spcP],80h .noneg mov ax,[spcPCRam] mov [ssdatst+37],ax mov al,[spcA] mov [ssdatst+39],al mov al,[spcX] mov [ssdatst+40],al mov al,[spcY] mov [ssdatst+41],al mov al,[spcP] mov [ssdatst+42],al mov al,[spcS] mov [ssdatst+43],al add dword[spcPCRam],spcRam .savestuff sub dword[spcPCRam],spcRam sub dword[spcRamDP],spcRam call PrepareSaveState ; Copy from fnames to .spcfname, replacing .srm with .spc mov esi,fnames+1 mov edi,.spcfname .next mov al,[esi] mov [edi],al inc esi inc edi cmp al,'.' jne .next ; Save stuff mov byte[edi],'s' mov byte[edi+1],'p' mov byte[edi+2],'c' mov byte[edi+3],0 ; Find an unoccupied file .tryagainspc mov edx,.spcfname call Open_File jc .nofileopen mov bx,ax call Close_File cmp byte[edi+2],'c' jne .notc mov byte[edi+2],'1' jmp .tryagainspc .notc cmp byte[edi+2],'9' je .donext10 inc byte[edi+2] jmp .tryagainspc .donext10 mov al,[edi+1] cmp al,[edi+2] je .nofileopen cmp byte[edi+1],'p' jne .notp mov byte[edi+1],'0' .notp inc byte[edi+1] mov byte[edi+2],'0' jmp .tryagainspc .nofileopen xor al,al mov al,[edi+1] mov [showmenu.saved+2],al mov al,[edi+2] mov [showmenu.saved+3],al ; copy spcextra ram to dspmem+192 mov esi,spcextraram mov edi,DSPMem+192 mov ecx,64 .loop mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .loop ; Copy Game Title mov esi,[romdata] add esi,7FC0h cmp byte[romtype],2 jne .nohirom2 add esi,8000h .nohirom2 mov ecx,20 mov edi,ssdatst+46+32 .romloop mov al,[esi] mov [edi],al inc esi inc edi dec ecx jnz .romloop ; Copy Date of spc dumped call Get_Date mov [ssdatst+09Eh],dl mov [ssdatst+09Fh],dh mov [ssdatst+0A0h],cx ; Set Channel Disables mov byte[ssdatst+0D0h],0 cmp byte[Voice0Disable],1 je .enable0 or byte[ssdatst+0D0h],1 .enable0 cmp byte[Voice1Disable],1 je .enable1 or byte[ssdatst+0D0h],2 .enable1 cmp byte[Voice2Disable],1 je .enable2 or byte[ssdatst+0D0h],4 .enable2 cmp byte[Voice3Disable],1 je .enable3 or byte[ssdatst+0D0h],8 .enable3 cmp byte[Voice4Disable],1 je .enable4 or byte[ssdatst+0D0h],16 .enable4 cmp byte[Voice5Disable],1 je .enable5 or byte[ssdatst+0D0h],32 .enable5 cmp byte[Voice6Disable],1 je .enable6 or byte[ssdatst+0D0h],64 .enable6 cmp byte[Voice7Disable],1 je .enable7 or byte[ssdatst+0D0h],128 .enable7 ; times 32 db 0 ; Title of game (Offset 48) ; times 32 db 0 ; Song Name ; times 32 db 0 ; Author of Song ; times 32 db 0 ; Name of dumper ; times 32 db 0 ; Comments ; times 4 db 0 ; date of spc dumped ; times 4 db 0 ; time in milliseconds before fading out ; times 2 db 0 ; fade-out length in milliseconds ; db 0 ; default channel enables mov edx,.spcfname call Create_File mov bx,ax mov ecx,256 mov edx,ssdatst call Write_File ; Save SPC stuff mov ecx,65536 mov edx,spcRam call Write_File mov ecx,256 mov edx,DSPMem call Write_File call Close_File add dword[spcPCRam],spcRam add dword[spcRamDP],spcRam call ResetState ret .spcfname times 128 db 0 ;.SPC File Format ;Offset 00000h - File Header : SNES-SPC700 Sound File Data v0.10 ;Offset 00021h - 0x26,0x26,0x26 ;Offset 00024h - Version #(/100) ;Offset 00025h - PC Register value (1 Word) ;Offset 00027h - A Register Value (1 byte) ;Offset 00028h - X Register Value (1 byte) ;Offset 00029h - Y Register Value (1 byte) ;Offset 0002Ah - Status Flags Value (1 byte) ;Offset 0002Bh - Stack Register Value (1 byte) ;Offset 0002Ch-000FFh - Reserved For Future Use ;Offset 00100h-100FFh - SPCRam ;Offset 10100h-101FFh - DSPRam ;Offset 0002Eh-0004Dh - SubTitle/Song Name ;Offset 0004Eh-0006Dh - Title of Game ;Offset 0006Eh-0007Dh - Name of Dumper ;Offset 0007Eh-0009Dh - Comments ;Offset 0009Eh-000A4h - Date of SPC Dumped in decimal (DD/MM/YYYY) ;Offset 000A9h-000ABh - Time in seconds for the spc to play before fading ;Offset 000ACh-000AFh - Fade out time in milliseconds ;Offset 000B0h-000CFh - Author of Song ;Offset 000D0h - Default Channel Disables (0 = enable, 1 = disable) ;Offset 000D1h - Emulator used to dump .spc file ; (0 = UNKNOWN, 1 = ZSNES, 2 = SNES9X) ; (Note : Contact the authors if you're an snes emu ; author with an .spc capture in order to assign ; you a number) ;Offset 0002Eh-0004Dh - Name of SPC (32 bytes) ;Offset 0004Eh-0005Dh - Name of Game (16 bytes) ;Offset 0006Eh-0007Dh - Name of SPC dumper (16 bytes) ;Offset 0007Eh-0009Dh - Comments (32 bytes) ;Offset 0009Eh-000A8h - Date the SPC was Dumped (10 bytes) ;Offset 000A9h-000ABh - Internal SPC timer (3 bytes) NEWSYM ssdatst db 'SNES-SPC700 Sound File Data v0.30',26,26,26 ; offset 0 db 10 ; Version #(/100), offset 36 ; SPC Registers dw 0 ; PC, offset 37 db 0 ; A, offset 39 db 0 ; X, offset 40 db 0 ; Y, offset 41 db 0 ; P, offset 42 db 0 ; S, offset 43 db 0,0 ; offset 44 (reserved) times 32 db 0 ; Title of game (Offset 46) times 32 db 0 ; Song Name times 16 db 0 ; Name of dumper times 32 db 0 ; Comments times 10 db 0 ; date of spc dumped times 4 db 0 ; time in seconds before fading out times 4 db 0 ; fade-out length in milliseconds times 32 db 0 ; Author of Song db 0 ; default channel enables db 1 ; emulator used to dump .spc files ; 32*5+20 = 180 times 48 db 0 ;(reserved), offset 224 ; SPCRAM (offset 256), 64k ; DSPRAM (offset 256+65536), 256 bytes NEWSYM dumpsound mov cx,0 mov edx,.filename call Create_File ; Process sound data mov bx,ax xor ecx,ecx xor esi,esi .loop push eax mov eax,[spcBuffera] mov edx,dword[eax+ecx*4] pop eax cmp edx,0 je .nowrite mov [mode7tab+esi],edx add esi,4 cmp esi,65536 je .savenow .return .nowrite inc cx jnz .loop cmp esi,0 je .nosave mov ecx,esi mov edx,mode7tab call Write_File .nosave call Close_File call Makemode7Table ret .savenow push ecx mov ecx,65536 mov edx,mode7tab call Write_File pop ecx xor esi,esi jmp .return .filename db 'SOUNDDMP.RAW',0 NEWSYM pcxheader db 10,5,1,8 dw 0,0,255,223 dw 256,224 times 48 db 0 db 0,1 .bpline dw 256 times 128-68 db 0 NEWSYM picnum, dw 0 NEWSYM savepcx %ifndef NO_PNG cmp byte[ScreenShotFormat],1 jne .notpng call Grab_PNG_Data ret .notpng %endif mov byte[pressed+1],0 mov byte[pressed+59],0 cmp byte[cbitmode],1 je near .save16b mov edi,pcxheader mov ecx,128 .clearhead mov byte[edi],0 inc edi dec ecx jnz .clearhead mov byte[pcxheader+0],10 mov byte[pcxheader+1],5 mov byte[pcxheader+2],1 mov byte[pcxheader+3],8 mov word[pcxheader+8],255 mov word[pcxheader+10],222 mov byte[pcxheader.bpline-1],1 mov word[pcxheader.bpline],256 cmp byte[resolutn],224 je .res224ph mov word[pcxheader+10],237 .res224ph ; get unused filename mov byte[.filename+5],'.' mov byte[.filename+6],'p' mov byte[.filename+7],'c' mov byte[.filename+8],'x' mov byte[.filename+9],0 mov word[picnum],1 .findagain mov edx,.filename call Open_File jc near .nofile mov bx,ax call Close_File inc word[picnum] cmp word[picnum],1000 je .nofile mov ax,[picnum] xor edx,edx mov bx,100 div bx mov cl,al mov ax,dx xor edx,edx mov bx,10 div bx mov esi,.filename+5 add cl,48 add al,48 add dl,48 cmp cl,48 je .nohund mov byte[esi],cl mov byte[esi+1],al mov byte[esi+2],dl add esi,3 jmp .finproc .nohund cmp al,48 je .noten mov byte[esi],al mov byte[esi+1],dl add esi,2 jmp .finproc .noten mov byte[esi],dl inc esi .finproc mov byte[esi],'.' mov byte[esi+1],'p' mov byte[esi+2],'c' mov byte[esi+3],'x' mov byte[esi+4],0 jmp .findagain .nofile mov edx,.filename call Create_File ; Save header mov bx,ax mov ecx,128 mov edx,pcxheader call Write_File ; Save picture Data mov byte[.rowsleft],223 cmp byte[resolutn],224 je .res224p mov byte[.rowsleft],238 .res224p mov ecx,256 mov edx,[vidbuffer] add edx,16+288 .a xor ecx,ecx mov esi,edx mov edi,mode7tab push ebx mov ebx,256 .loopp mov al,[esi] mov [edi],al mov ah,al and ah,0C0h cmp ah,0C0h jne .norep mov byte[edi],0C1h inc edi inc ecx mov byte[edi],al .norep inc ecx inc esi inc edi dec ebx jnz .loopp pop ebx xor al,al push edx mov edx,mode7tab call Write_File pop edx add edx,288 dec byte[.rowsleft] jnz .a ; Save Palette mov ecx,769 mov edx,[vidbuffer] add edx,100000 call Write_File call Makemode7Table call Close_File ; mov dword[Msgptr],.pcxsaved ; mov eax,[MsgCount] ; mov [MessageOn],eax ret .save16b test byte[pressed+14],1 jnz near save16b2 call prepare16b mov edi,pcxheader mov ecx,128 .clearhead2 mov byte[edi],0 inc edi dec ecx jnz .clearhead2 ; Initial header = 14 bytes mov byte[pcxheader],'B' mov byte[pcxheader+1],'M' mov dword[pcxheader+2],02A01Ah-768 mov dword[pcxheader+10],26 mov dword[pcxheader+14],12 mov word[pcxheader+18],256 mov word[pcxheader+20],223 mov word[pcxheader+22],1 mov word[pcxheader+24],24 cmp byte[resolutn],224 je .res224b add dword[pcxheader+2],768*15 mov word[pcxheader+20],238 .res224b ; get unused filename mov byte[.filename2+5],'.' mov byte[.filename2+6],'b' mov byte[.filename2+7],'m' mov byte[.filename2+8],'p' mov byte[.filename2+9],0 mov word[picnum],1 .findagain2 mov edx,.filename2 call Open_File jc near .nofile2 mov bx,ax call Close_File inc word[picnum] cmp word[picnum],1000 je near .nofile2 mov ax,[picnum] xor edx,edx mov bx,100 div bx mov cl,al mov ax,dx xor edx,edx mov bx,10 div bx mov esi,.filename2+5 add cl,48 add al,48 add dl,48 cmp cl,48 je .nohund2 mov byte[esi],cl mov byte[esi+1],al mov byte[esi+2],dl add esi,3 jmp .finproc2 .nohund2 cmp al,48 je .noten2 mov byte[esi],al mov byte[esi+1],dl add esi,2 jmp .finproc2 .noten2 mov byte[esi],dl inc esi .finproc2 mov byte[esi],'.' mov byte[esi+1],'b' mov byte[esi+2],'m' mov byte[esi+3],'p' mov byte[esi+4],0 jmp .findagain2 .nofile2 mov edx,.filename2 call Create_File ; Save header mov bx,ax mov ecx,26 mov edx,pcxheader call Write_File ; Save picture Data mov byte[.rowsleft],223 mov esi,[vidbuffer] add esi,32+288*2*223 cmp byte[resolutn],224 je .res224b2 mov byte[.rowsleft],238 add esi,288*2*15 .res224b2 mov [.curdptr],esi .a2 mov ecx,256 mov edi,mode7tab mov esi,[.curdptr] sub dword[.curdptr],288*2 .b2 push ecx mov ax,[esi] mov cl,[vesa2_bpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi],al mov ax,[esi] mov cl,[vesa2_gpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi+1],al mov ax,[esi] mov cl,[vesa2_rpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi+2],al pop ecx add edi,3 add esi,2 dec ecx jnz .b2 push edx mov ecx,768 mov edx,mode7tab call Write_File pop edx add edx,288*2 dec byte[.rowsleft] jnz near .a2 call Makemode7Table call Close_File ; mov dword[Msgptr],.rawsaved ; mov eax,[MsgCount] ; mov [MessageOn],eax call restore16b ret .pcxsaved db 'SNAPSHOT SAVED TO ' .filename db 'image.pcx',0,0,0,0 .rawsaved db 'SNAPSHOT SAVED TO ' .filename2 db 'image.bmp',0,0,0,0 .rowsleft db 0 .curdptr dd 0 NEWSYM save16b2 call prepare16b mov byte[pressed+14],2 push es mov edi,pcxheader mov ecx,128 .clearhead2 mov byte[edi],0 inc edi dec ecx jnz .clearhead2 ; Initial header = 14 bytes mov byte[pcxheader],'B' mov byte[pcxheader+1],'M' mov dword[pcxheader+2],02A01Ah-256*224*3+512*448*3 mov dword[pcxheader+10],26 mov dword[pcxheader+14],12 mov word[pcxheader+18],512 mov word[pcxheader+20],448 mov word[pcxheader+22],1 mov word[pcxheader+24],24 ; get unused filename mov byte[.filename2+5],'.' mov byte[.filename2+6],'b' mov byte[.filename2+7],'m' mov byte[.filename2+8],'p' mov byte[.filename2+9],0 mov word[picnum],1 .findagain2 mov edx,.filename2 call Open_File jc near .nofile2 mov bx,ax call Close_File inc word[picnum] cmp word[picnum],1000 je near .nofile2 mov ax,[picnum] xor edx,edx mov bx,100 div bx mov cl,al mov ax,dx xor edx,edx mov bx,10 div bx mov esi,.filename2+5 add cl,48 add al,48 add dl,48 cmp cl,48 je .nohund2 mov byte[esi],cl mov byte[esi+1],al mov byte[esi+2],dl add esi,3 jmp .finproc2 .nohund2 cmp al,48 je .noten2 mov byte[esi],al mov byte[esi+1],dl add esi,2 jmp .finproc2 .noten2 mov byte[esi],dl inc esi .finproc2 mov byte[esi],'.' mov byte[esi+1],'b' mov byte[esi+2],'m' mov byte[esi+3],'p' mov byte[esi+4],0 jmp .findagain2 .nofile2 mov cx,0 mov edx,.filename2 call Create_File ; Save header mov bx,ax mov ecx,26 mov edx,pcxheader call Write_File ; Save picture Data mov dword[.rowsleft],448 mov ax,[vesa2selec] mov es,ax mov esi,32*2+640*2*223*2+640*2 mov [.curdptr],esi .a2 mov ecx,512 mov edi,mode7tab mov esi,[.curdptr] sub dword[.curdptr],640*2 .b2 push ecx mov ax,[es:esi] mov cl,[vesa2_bpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi],al mov ax,[es:esi] mov cl,[vesa2_gpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi+1],al mov ax,[es:esi] mov cl,[vesa2_rpos] shr ax,cl and ax,1Fh shl al,3 mov byte[edi+2],al pop ecx add edi,3 add esi,2 dec ecx jnz .b2 push edx mov ecx,768*2 mov edx,mode7tab call Write_File pop edx add edx,288*2 dec dword[.rowsleft] jnz near .a2 call Makemode7Table call Close_File ; mov dword[Msgptr],.rawsaved ; mov eax,[MsgCount] ; mov [MessageOn],eax pop es call restore16b ret .rawsaved db 'SNAPSHOT SAVED TO ' .filename2 db 'image.bmp',0,0,0,0 .rowsleft dd 0 .curdptr dd 0 prepare16b: cmp byte[vesa2red10],1 jne .nored cmp byte[cvidmode],5 jne .nored cmp byte[scanlines],1 je .nored cmp byte[smallscreenon],1 je .nored mov byte[vesa2_rpos],10 mov byte[vesa2_gpos],5 .nored ret restore16b: cmp byte[vesa2red10],1 jne .nored mov byte[vesa2_rpos],11 mov byte[vesa2_gpos],6 .nored ret NEWSYM MenuAsmEnd zsnes-1.36/src/gui/gui.asm.old0100644000175000017500000036323307473163313015623 0ustar dolsondolson;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either ;version 2 of the License, or (at your option) any later ;version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Sorry. The GUI code is a total mess. One problem I encountered is that ; there seems to be a bug in nasm with using math calculations combined ; with macros within macros, so in some macro definitions, I had to ; add/subtract extra values in certain macros to get the GUI to align ; correctly. ; The GUI is drawn is mostly manually. What I mean is such as ; coding 5 boxes to represent a shaded box for each box. Although that ; can be simplified using macros to draw 5 boxes, that unknown bug in nasm ; showed up which prevented me from using macros extensively. I was ; thinking of changing it to an object-based GUI for easier coding, ; but that was decided far into the development of the GUI itself ; and that I also never expected this code to become open-source, so I ; decided not to proceed with it. ; Routine StartGUI is the function called to start the GUI and also ; contains the execution main loop of the GUI. If you want to completely ; replace the GUI, just add a function call from that function, then ; jump to endprog to exit ZSNES or continueprog to continue with the ; gameplay. Do not replace StartGUI with a function since it is not ; a function, but rather a label that is being jumped to. ; ************************************** ; GUI.ASM ; ************************************** ; ; Associated files : ; GUIWinDp.inc - Window Display Routines ; GUITools.inc - Misc routines for the GUI ; Quick Searches : ; DisplayMenu - routines to display top menu bar ; Incomp - Search for start of modem processing ; ProcessModem ; GUIgetcurrentinput ; GUITryMenuItem - Processes the menu item when user clicks item ; Mouseimplementation ; DGUIDisplayer ; LGUILoadData ; SetInputDevice ; CalibrateDev1 ; ButtonProcess - routines that processes boxed buttons ; CheatCodeSearchInit ; guiwincontrol %include "macros.mac" EXTSYM dssel, curblank, vidpastecopyscr, frameskip, newengen, vsyncon, cantinitmodem EXTSYM cvidmode, antienab, smallscreenon, smallscreence,NetQuit EXTSYM soundon, StereoSound, SoundCompD, SoundQuality, MusicRelVol,UartType EXTSYM endprog, continueprog, spcBuffera, spcRamcmp, cbitmode, makepal EXTSYM t1cc, LoadDir, SRAMDir, LoadDrive,SRAMDrive, initsnes, romloadskip EXTSYM fname, makeextension, sram, clearmem2, loadfileGUI, GUIloadfailed EXTSYM CheckROMType, romdata, ForcePal, ramsize, ramsizeand, curromsize EXTSYM romispal, totlines, cfgloadsdir, init65816, procexecloop EXTSYM spcRam, spcPCRam, spcS, spcRamDP, spcA, spcX, spcY, spcP, spcNZ EXTSYM Voice0Status, Voice1Status, Voice2Status, Voice3Status, Voice4Status EXTSYM Voice5Status, Voice6Status, Voice7Status, romtype, SetIRQVectors EXTSYM ClearScreen, statesaver, loadstate2, vidbuffer, ASCII2Font, hirestiledat EXTSYM showallext, ROMTypeNOTFound, scanlines,statefileloc,pl1selk,pl2selk EXTSYM fnamest,sprlefttot,spritetablea,fnames,SFXSRAM,sfxramdata,cgram,srama EXTSYM tempco0,prevbright,maxbr,prevpal,coladdr,coladdg,coladdb EXTSYM scaddtype,ScreenScale,vesa2red10,initvideo2,initvideo,pressed,UpdateDevices EXTSYM memtabler8,memtablew8,writeon,pl1contrl,pl2contrl,JoyRead,SetInputDevice EXTSYM SetInputDevice209,FPSOn,RevStereo,WDSPReg0C,WDSPReg1C,WDSPReg2C EXTSYM WDSPReg3C,pl12s34,resolutn,delay,chaton,chatstrL,chatLpos,chatstrR,chatRTL EXTSYM InitDrive,InitDir,createnewcfg,Makemode7Table,SnowOn,MovieBuffSize EXTSYM MovieBuffFrame,vidbufferofsb,ZipSupport,wramdata,bgfixer,cfgnewgfx EXTSYM cfgdontsave,videotroub,Open_File,Read_File,Close_File,Write_File,Create_File EXTSYM File_Seek,File_Seek_End,Open_File_Write,Get_Date,Check_Key,Get_Key EXTSYM Change_Drive,Change_Single_Dir,Change_Dir,Get_Dir,Get_First_Entry EXTSYM Get_Next_Entry,Set_DTA_Address,timer2upd,curexecstate,TripBufAvail EXTSYM nmiprevaddrl,nmiprevaddrh,nmirept,nmiprevline,nmistatus,spcnumread EXTSYM NextLineCache,VidStartDraw,ResetTripleBuf,GUINGVID EXTSYM ScanCodeListing,AdjustFrequency,GUISaveVars,Init_Mouse EXTSYM Get_MouseData,Set_MouseXMax,Set_MouseYMax,Set_MousePosition,Get_MousePositionDisplacement EXTSYM GUIInit,GUIDeInit,SpecialLine EXTSYM DrawWater,DrawSmoke,RemoteDisconnect,loadstate3 EXTSYM ModemClearBuffer,IPXSearchval EXTSYM ipxlookforconnect EXTSYM SA1Enable,SA1RAMArea EXTSYM GUIFName,GUICName EXTSYM printnum EXTSYM MMXCheck EXTSYM SaveCombFile EXTSYM NetSent,valuea EXTSYM welcome EXTSYM showinfogui EXTSYM BackupCVFrame EXTSYM Wait1SecWin,ClearUDPStuff EXTSYM DisableSUDPPacket,EnableSUDPPacket EXTSYM ModemGetChar EXTSYM BackStateSize EXTSYM ResetExecStuff EXTSYM RestoreCVFrame EXTSYM CurRecv,BackState,CBackupPos,PBackupPos,PPValue,DPValue,NetQuitter EXTSYM LatencyV EXTSYM LatencyRecvPtr,LatencySendPtr EXTSYM NumofBanks EXTSYM WinErrorA,WinErrorB,WinErrorC EXTSYM ErrorPointer EXTSYM MessageOn,Msgptr,MsgCount EXTSYM PJoyAOrig,PJoyBOrig,PJoyCOrig,PJoyDOrig,PJoyEOrig EXTSYM GetHostName EXTSYM vramaddr,curypos,ClearRegs,vram,sndrot,regsbackup EXTSYM GetScreen,GUITBWVID EXTSYM Clear2xSaIBuffer EXTSYM MouseWindow EXTSYM GotoHomepage EXTSYM cfgcvidmode, ExitFromGUI EXTSYM GUIWFVID EXTSYM cfgvsync,newgfx16b EXTSYM cfgscanline,cfginterp EXTSYM NumVideoModes EXTSYM cfgvolume, MusicVol, DSPMem EXTSYM NumInputDevices,GUIInputNames EXTSYM GUIVideoModeNames EXTSYM GUISLVID,GUIINVID,GUIEAVID,GUIIEVID,GUIFSVID,GUIWSVID EXTSYM GUISSVID,GUITBVID,GUIHSVID,GUI2xVID,GUII2VID,GUIM7VID EXTSYM cfgsoundon,cfgSoundQuality,cfgStereoSound,cfgforce8b EXTSYM Force8b,convertnum,converthex EXTSYM per2exec EXTSYM hostname EXTSYM UDPConfig EXTSYM DeInitModem EXTSYM snesmouse EXTSYM pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Lk,pl1Rk,pl1Ak,pl1Bk EXTSYM deinitipx EXTSYM InitModem EXTSYM outofmemfix,yesoutofmemory EXTSYM CReadHead,ReadHead,CFWriteHead,CFWriteStart EXTSYM JoyX,JoyY,JoyMinX,JoyMinY,JoyMaxX,JoyMaxY,JoyMinX209,JoyMaxX209 EXTSYM JoyMinY209,JoyMaxY209,GetCoords,GetCoords3 EXTSYM MultiTap,SFXEnable EXTSYM RestoreSystemVars EXTSYM TCPIPStartServer EXTSYM TCPIPInitConnectToServer EXTSYM TCPIPWaitForConnection EXTSYM tcperr EXTSYM TCPIPConnectToServer EXTSYM TCPIPConnectToServerW EXTSYM initipx EXTSYM selc0040 EXTSYM ModemCheckRing EXTSYM ModemCheckDCD EXTSYM PreparePacketIPX,TCPIPPreparePacket EXTSYM SendPacketIPX,TCPIPSendPacket,TCPIPSendPacketUDP EXTSYM TCPIPDisconnect,TCPIPStatus EXTSYM DeInitModemC EXTSYM ipxgetchar,ipxsendchar,TCPIPStoreByte EXTSYM TCPIPGetByte,GUIBIFIL EXTSYM ModemSendChar EXTSYM firstsaveinc EXTSYM nssdip1,nssdip2,nssdip3,nssdip4,nssdip5,nssdip6 %ifdef __LINUX__ EXTSYM numlockptr %endif %include "gui/guitools.inc" %include "gui/guimisc.inc" %include "gui/guimouse.inc" %include "gui/guiwindp.inc" %include "gui/guinetpl.inc" %include "gui/guikeys.inc" %include "gui/guicheat.inc" %include "gui/guicombo.inc" %include "gui/guiload.inc" section .data ; ProcessRemoteCommand ; NetLoadStuff ; Send 14 to initiate, Send 15 to cancel (either way) ; call PreparePacket ; mov al,253 ; call RemoteSendChar ; call SendPacket ; NetAddChar NEWSYM WaterOn, db 1 ; Things to do : ; ; .checkmenuboxclick ; gray scale = 32 .. 63 ; shadow = 96 .. 127 ; blue scale = 148 .. 167, 168 .. 187 ; gray scale = 189 .. 220 (32+137) ; | Game Config Cheat MultiPlay Misc ;------------------------------------------------------- ; Load Input#1 Add Code Modem Game Keys ; Run Input#2 Browse IPX GUI Opns ; Reset Input#3 Search About ; ----- Input#4 ; Save State ------- ; Load State Options ; Chose State Video ; ----- Sound ; Quit ; Windows : 1 = Save/Load Confirmation ; 2 = Chose State ; 3 = Input Device Window ; 4 = Options ; 5 = Video ; 6 = Sound ; 7 = Cheat ; 8 = IPX/Modem ; 9 = GameOptions ; 10 = GUI Options ; 11 = About MenuDat1 db 12,3,1,1,1,1,1,1,1,1,1,0,1,2,0 MenuDat2 db 8, 3,1,1,0,1,1,1,0,2,0,0 MenuDat3 db 10, 3,1,1,1,1,0,1,0,1,1,2,0 MenuDat4 db 2, 3,1,2,0 MenuDat5 db 1, 3,2,0 MenuDat6 db 6, 3,1,1,1,1,0,2,0 GUIPrevMenuData db 1,'1. ',0 db 1,'2. ',0 db 1,'3. ',0 db 1,'4. ',0 db 1,'5. ',0 db 1,'6. ',0 db 1,'7. ',0 db 1,'8. ',0 db 1,'9. ',0 db 1,'0. ',0 db 0,'------------',0 .onoff db 1,'FREEZE DATA : OFF ',0 db 1,'CLEAR ALL DATA ',0 GUIGameMenuData db 1,'LOAD ',0 db 1,'RUN [ESC] ',0 db 1,'RESET ',0 db 0,'------------',0 db 1,'SAVE STATE ',0 db 1,'OPEN STATE ',0 db 1,'PICK STATE ',0 db 0,'------------',0 db 1,'QUIT ',0 GUIConfigMenuData db 1,'INPUT #1 ',0 db 1,'INPUT #2 ',0 db 1,'INPUT #3 ',0 db 1,'INPUT #4 ',0 db 1,'INPUT #5 ',0 db 0,'------------',0 db 1,'ADD-ONS ',0 db 0,'------------',0 db 1,'OPTIONS ',0 db 1,'VIDEO ',0 db 1,'SOUND ',0 GUICheatMenuData db 1,'ADD CODE ',0 db 1,'BROWSE ',0 db 1,'SEARCH ',0 GUINetPlayMenuData db 1,'MODEM ',0 db 1,'IPX ',0 GUIMiscMenuData db 1,'GAME KEYS ',0 db 1,'GUI OPNS ',0 db 1,'MOVIE OPN ',0 db 1,'KEY COMB. ',0 db 1,'SAVE CFG ',0 db 0,'------------',0 db 1,'ABOUT ',0 ; Config, Options -> New Gfx Engine, Frame Rate, Fast Forward FrameRate, etc. ; Config, Video -> Video Mode, Interpolation, etc. ; Config, Options -> Set up Save and/or Load State Confirmation ; Select Different game key assignments ; If menu should go to Load or last position when ESC ; is pressed from game GUIRAdd db 15 GUIGAdd db 10 GUIBAdd db 31 mousewrap db 0 ; 0 = mouse boundries, 1 = mouse wrap mouseshad db 1 ; 0 = no mouse shadow, 1 = mouse shadow lastcursres db 0 ; 0 = go to load, 1 = go to previous menu, 2 = no menu resetposn db 1 ; 0 = no window reset, 1 = window reset NEWSYM GUIClick, db 0 ; 1 = mouse click enters/exits gui GUIwinposx2 dd 0,5 ,60 ,30 ,55 ,50 ,65 ,5 ,30 ,20 ,10 ,80 ,65 ,20 ,70 ,50 ,3 ,0 GUIwinposy2 dd 0,20 ,70 ,30 ,20 ,22 ,36 ,20 ,30 ,20 ,40 ,70 ,60 ,30 ,65 ,50 ,22 ,0 ; Default keys ; Sound Channels 0 .. 7, Save/Select/Load States, Fast Forward ; Exit, Load, Reset, BG Disables, Reset, Windowing, New Gfx, OffsetMode ; State Selection 0 .. 9 NEWSYM KeyDisableSC0, dd 63 NEWSYM KeyDisableSC1, dd 64 NEWSYM KeyDisableSC2, dd 65 NEWSYM KeyDisableSC3, dd 66 NEWSYM KeyDisableSC4, dd 67 NEWSYM KeyDisableSC5, dd 68 NEWSYM KeyDisableSC6, dd 87 NEWSYM KeyDisableSC7, dd 88 NEWSYM KeySaveState, dd 60 NEWSYM KeyStateSelct, dd 61 NEWSYM KeyLoadState, dd 62 NEWSYM KeyFastFrwrd, dd 41 NEWSYM KeyQuickExit, dd 0 NEWSYM KeyQuickLoad, dd 0 NEWSYM KeyQuickRst, dd 0 NEWSYM KeyBGDisble0, dd 2 NEWSYM KeyBGDisble1, dd 3 NEWSYM KeyBGDisble2, dd 4 NEWSYM KeyBGDisble3, dd 5 NEWSYM KeySprDisble, dd 6 NEWSYM KeyResetAll, dd 7 NEWSYM KeyExtraEnab, dd 8 NEWSYM KeyNewGfxSwt, dd 9 NEWSYM KeyWinDisble, dd 10 NEWSYM KeyOffsetMSw, dd 11 NEWSYM KeyStateSlc0, dd 0 NEWSYM KeyStateSlc1, dd 0 NEWSYM KeyStateSlc2, dd 0 NEWSYM KeyStateSlc3, dd 0 NEWSYM KeyStateSlc4, dd 0 NEWSYM KeyStateSlc5, dd 0 NEWSYM KeyStateSlc6, dd 0 NEWSYM KeyStateSlc7, dd 0 NEWSYM KeyStateSlc8, dd 0 NEWSYM KeyStateSlc9, dd 0 GUIshowallext db 0 GUIloadfntype db 0 NEWSYM pl3selk, dd 0 ; 3SELECT = SHIFT NEWSYM pl3startk, dd 0 ; 3START = ENTER NEWSYM pl3upk, dd 0 ; 3UP = up NEWSYM pl3downk, dd 0 ; 3