This commit was generated by cvs2svn to compensate for changes in r4, which

included commits to RCS files with non-trunk default branches.
This commit is contained in:
teuf
2001-04-02 22:30:58 +00:00
138 changed files with 186213 additions and 0 deletions

0
zsnes/ChangeLog Normal file
View File

57
zsnes/INSTALL.txt Normal file
View File

@@ -0,0 +1,57 @@
Compiling the Source Code:
--------------------------
Well, for the moment, zsnes sources 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
First, you need the following software:
Dos port :
- NASM v0.98 : http://www.cryogen.com/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
- 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
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.tsx.org), it will
divide its size by 10.
Windows port :
- GNU Make : it comes with djgpp
- NASM v0.98 : http://nasm.2y.net/ or http://www.cryogen.com/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)
- DX7.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). Name the static version zlib.lib and
put it somewhere where vc++ will find it (for example, the lib
directory in vc++ dir).
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.tsx.org), it will
divide its size by 10.

6
zsnes/authors.txt Normal file
View File

@@ -0,0 +1,6 @@
ZSNES Open Source Authors:
--------------------------
zsKnight <zsknight@zsnes.com>
_Demo_ <z_demo_z@users.sourceforge.net>


506
zsnes/dos/guinotes.txt Normal file
View File

@@ -0,0 +1,506 @@
Table 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


604
zsnes/dos/readme.txt Normal file
View File

@@ -0,0 +1,604 @@
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.
---------------------------------------------------------------------------
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 zsnes.faq 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 65536 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
- 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
(65536 colors). 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 0.
If -v 0 doesn't work, use -v 2 (vesa 2 required)
- 16 bit mode in ZSNES requires a Scitech Display Doctor (v5.3+) to provide
high color, low resolution modes. You can obtain this software at
www.scitechsoft.com. If your video card already supports lo-res,
hi-color, then don't worry about getting this driver.
- 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 <romname.smc/.sfc/.fig/.1>
To run it with sound, type ZSNES -s <romname.smc/.sfc/.fig/.1>
To run it in 16-bit mode (VESA2 w/ video card that supports 320x240x65536
required), type ZSNES -v 3 <romname.smc/.sfc/.fig/.1>
or with sound, type ZSNES -v 3 -s <romname.smc/.sfc/.fig/.1>
---------------------------------------------------------------------------
8.) Extra Pop-Up Menu (F1 Menu)
---------------------------------------------------------------------------
Save Snapshot - Saves a snapshot as either .PCX (8-bit color) or .BMP
(16-bit color)
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.
---------------------------------------------------------------------------
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 ZSNES.FAQ,
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, WDOSX, and 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!


527
zsnes/dos/zsnesfaq.txt Normal file
View File

@@ -0,0 +1,527 @@
================================================
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.
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ


343
zsnes/license.txt Normal file
View File

@@ -0,0 +1,343 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.


1
zsnes/news.txt Normal file
View File

@@ -0,0 +1 @@


5
zsnes/readme.txt Normal file
View File

@@ -0,0 +1,5 @@
If you need help to compile zsnes, read install.txt.
If you need help to browse the sources, read srcinfo.txt.
For more information about zsnes development, check http://zsnes.sourceforge.net
The official website is at http://www.zsnes.com

29
zsnes/src/betauser.mac Normal file
View File

@@ -0,0 +1,29 @@
;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.
%define USERNAMEN 'Public'
%define USERNAMEC 'P'^76,'b'^89,'-'^178,'|'^34,'-'^217
%define USERNAMEI 0 ; 1


1874
zsnes/src/cfgload.asm Normal file

File diff suppressed because it is too large Load Diff

953
zsnes/src/chips/dsp1emu.c Normal file
View File

@@ -0,0 +1,953 @@
//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 <stdio.h>
#include <stdarg.h>
#include <math.h>
#define DebugDSP1
// uncomment some lines to test
//#define printinfo
//#define debug02
//#define debug0A
//#define debug06
#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);
}
void Start_Log (void)
{
char LogFileName[255];
char *p;
strcpy(LogFileName,"dsp1emu.log\0");
LogFile = fopen(LogFileName,"wb");
}
void Stop_Log (void)
{
if (LogFile)
{
fclose(LogFile);
LogFile = NULL;
}
}
#endif
/***************************************************************************\
* Math tables *
\***************************************************************************/
int CosTable2[256]={65536,65516,65457,65358,65220,65043,64826,64571,64276,63943,63571,63161,62713,62227,61704,61144,60546,59912,59243,58537,57796,
57020,56210,55367,54489,53579,52637,51663,50658,49622,48556,47461,46338,45187,44008,42803,41572,
40316,39036,37732,36406,35057,33688,32298,30889,29461,28015,26553,25074,23581,22073,20552,19018,17473,15918,14353,12779,11198,9610,8016,6417,4814,
3209,1601,-6,-1615,-3222,-4828,-6430,-8029,-9623,-11211,-12792,-14366,-15931,-17486,-19031,-20565,-22086,-23593,-25087,-26565,-28028,-29473,
-30901,-32310,-33700,-35069,-36417,-37743,-39047,-40327,-41583,-42813,-44018,-45197,-46348,-47471,-48565,
-49631,-50666,-51671,-52645,-53587,-54497,-55374,-56217,-57027,-57802,-58543,-59248,-59918,-60551,-61148,
-61709,-62232,-62717,-63165,-63575,-63946,-64279,-64573,-64828,-65044,-65221,-65359,-65457,-65516,-65535,
-65515,-65456,-65357,-65219,-65041,-64824,-64568,-64273,-63940,-63568,-63158,-62709,-62223,-61699,-61139,
-60541,-59907,-59237,-58531,-57790,-57014,-56203,-55359,-54482,-53571,-52629,-51654,-50649,-49613,-48547,
-47452,-46328,-45177,-43998,-42793,-41562,-40306,-39025,-37721,-36395,-35046,-33676,-32286,-30877,-29449,
-28003,-26540,-25062,-23568,-22060,-20539,-19005,-17460,-15905,-14340,-12766,-11184,-9596,-8002,-6403,
-4801,-3195,-1588,20,1628,3236,4841,6444,8043,9636,11224,12806,14379,15944,17500,19044,20578,22099,
23606,25099,26578,28040,29485,30913,32322,33711,35080,36428,37754,39058,40338,41593,42824,44028,
45206,46357,47480,48575,49640,50675,51680,52653,53595,54504,55381,56224,57034,57809,58549,59254,
59923,60557,61153,61713,62236,62721,63168,63578,63949,64281,64575,64830,65046,65223,65360,65458,65516};
int SinTable2[256]={0,1608,3215,4821,6424,8022,9616,11204,12786,14359,15924,17480,19025,20558,22079,
23587,25081,26559,28021,29467,30895,32304,33694,35063,36411,37738,39041,40322,41577,42808,44013,
45192,46343,47466,48561,49626,50662,51667,52641,53583,54493,55370,56214,57024,57799,58540,59245,
59915,60549,61146,61706,62229,62715,63163,63573,63944,64277,64572,64827,65043,65221,65358,65457,
65516,65535,65516,65456,65357,65219,65042,64825,64569,64275,63941,63570,63159,62711,62225,61702,
61141,60544,59910,59240,58534,57793,57017,56207,55363,54486,53575,52633,51659,50653,49617,48552,
47457,46333,45182,44003,42798,41567,40311,39031,37727,36400,35052,33682,32292,30883,29455,28009,
26547,25068,23574,22067,20545,19012,17467,15911,14346,12772,11191,9603,8009,6410,4807,3202,1594,
-13,-1622,-3229,-4834,-6437,-8036,-9630,-11218,-12799,-14373,-15938,-17493,-19038,-20571,-22092,
-23600,-25093,-26571,-28034,-29479,-30907,-32316,-33705,-35075,-36423,-37749,-39052,-40332,-41588,-42818,-44023,-45201,-46352,-47476,-48570,-49635,-50671,-51675,-52649,-53591,-54501,-55377,-56221,-57030,-57806,-58546,-59251,-59921,-60554,-61151,-61711,
-62234,-62719,-63167,-63576,-63947,-64280,-64574,-64829,-65045,-65222,-65359,-65458,-65516,-65535,
-65515,-65456,-65356,-65218,-65040,-64823,-64567,-64272,-63938,-63566,-63156,-62707,-62221,-61697,
-61136,-60538,-59904,-59234,-58528,-57786,-57010,-56200,-55356,-54478,-53567,-52625,-51650,-50645,
-49609,-48543,-47447,-46324,-45172,-43993,-42788,-41556,-40300,-39020,-37716,-36389,-35040,-33670,
-32280,-30871,-29443,-27997,-26534,-25056,-23562,-22054,-20532,-18999,-17454,-15898,-14333,-12759,
-11178,-9589,-7995,-6397,-4794,-3188,-1581};
/***************************************************************************\
* 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;
C4TransfWireFrame()
{
c4x=(double)C4WFXVal;
c4y=(double)C4WFYVal;
c4z=(double)C4WFZVal-0x95;
// Rotate X
tanval=-(double)C4WFX2Val*3.14159265*2/128;
c4y2=c4y*cos(tanval)-c4z*sin(tanval);
c4z2=c4y*sin(tanval)+c4z*cos(tanval);
// Rotate Y
tanval=-(double)C4WFY2Val*3.14159265*2/128;
c4x2=c4x*cos(tanval)+c4z2*sin(tanval);
c4z=c4x*-sin(tanval)+c4z2*cos(tanval);
// Rotate Z
tanval=-(double)C4WFDist*3.14159265*2/128;
c4x=c4x2*cos(tanval)-c4y2*sin(tanval);
c4y=c4x2*sin(tanval)+c4y2*cos(tanval);
// Scale
C4WFXVal=c4x*(double)C4WFScale/(0x90*(c4z+0x95))*0x95;
C4WFYVal=c4y*(double)C4WFScale/(0x90*(c4z+0x95))*0x95;
}
C4TransfWireFrame2()
{
c4x=(double)C4WFXVal;
c4y=(double)C4WFYVal;
c4z=(double)C4WFZVal;
// Rotate X
tanval=-(double)C4WFX2Val*3.14159265*2/128;
c4y2=c4y*cos(tanval)-c4z*sin(tanval);
c4z2=c4y*sin(tanval)+c4z*cos(tanval);
// Rotate Y
tanval=-(double)C4WFY2Val*3.14159265*2/128;
c4x2=c4x*cos(tanval)+c4z2*sin(tanval);
c4z=c4x*-sin(tanval)+c4z2*cos(tanval);
// Rotate Z
tanval=-(double)C4WFDist*3.14159265*2/128;
c4x=c4x2*cos(tanval)-c4y2*sin(tanval);
c4y=c4x2*sin(tanval)+c4y2*cos(tanval);
// Scale
C4WFXVal=c4x*(double)C4WFScale/0x100;
C4WFYVal=c4y*(double)C4WFScale/0x100;
}
C4CalcWireFrame()
{
C4WFXVal=C4WFX2Val-C4WFXVal;
C4WFYVal=C4WFY2Val-C4WFYVal;
if (abs(C4WFXVal)>abs(C4WFYVal)){
C4WFDist=abs(C4WFXVal)+1;
C4WFYVal=256*(double)C4WFYVal/abs((double)C4WFXVal);
if (C4WFXVal<0) C4WFXVal=-256;
else C4WFXVal=256;
}
else
if (C4WFYVal!=0) {
C4WFDist=abs(C4WFYVal)+1;
C4WFXVal=256*(double)C4WFXVal/abs((double)C4WFYVal);
if (C4WFYVal<0) C4WFYVal=-256;
else C4WFYVal=256;
}
else C4WFDist=0;
}
short C41FXVal;
short C41FYVal;
short C41FAngleRes;
short C41FDist;
short C41FDistVal;
C4Op1F()
{
if (C41FXVal == 0) {
if (C41FYVal>0) C41FAngleRes=0x80;
else C41FAngleRes=0x180;
}
else {
tanval = ((double)C41FYVal)/((double)C41FXVal);
C41FAngleRes=atan(tanval)/(3.141592675*2)*512;
C41FAngleRes=C41FAngleRes;
if (C41FXVal<0) C41FAngleRes+=0x100;
C41FAngleRes&=0x1FF;
}
}
C4Op15()
{
tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)*
((double)C41FXVal));
C41FDist=tanval;
}
C4Op0D()
{
tanval=sqrt(((double)C41FYVal)*((double)C41FYVal)+((double)C41FXVal)*
((double)C41FXVal));
tanval=(double)C41FDistVal/tanval;
C41FYVal=((double)C41FYVal*tanval)*0.99;
C41FXVal=((double)C41FXVal*tanval)*0.98;
}
/***************************************************************************\
* DSP1 code *
\***************************************************************************/
void InitDSP(void)
{
#ifdef DebugDSP1
Start_Log();
#endif
}
short Op00Multiplicand;
short Op00Multiplier;
short Op00Result;
DSPOp00()
{
Op00Result=Op00Multiplicand*Op00Multiplier/32768;
#ifdef DebugDSP1
Log_Message("OP00 MULT %d*%d/32768=%d",Op00Multiplicand,Op00Multiplier,Op00Result);
#endif
}
short Op10Coefficient;
short Op10Exponent;
short Op10CoefficientR;
short Op10ExponentR;
// To fix...
DSPOp10()
{
#ifdef DebugDSP1
Log_Message("OP10 NOT IMPLEMENTED");
#endif
Op10ExponentR=-Op10Exponent;
Op10CoefficientR=1/Op10Coefficient;
}
short Op04Angle;
unsigned short Op04Radius;
short Op04Sin;
short Op04Cos;
DSPOp04()
{
Op04Sin=SinTable2[(Op04Angle/256)&255]*Op04Radius/65536;
Op04Cos=CosTable2[(Op04Angle/256)&255]*Op04Radius/65536;
#ifdef DebugDSP1
Log_Message("OP04 Angle:%d Radius:%d",(Op04Angle/256)&255,Op04Radius);
Log_Message("OP04 SIN:%d COS:%d",Op04Sin,Op04Cos);
#endif
}
short Op08X;
short Op08Y;
short Op08Z;
int Op08Size;
DSPOp08Radius()
{
Op08Size=(Op08X*Op08X+Op08Y*Op08Y+Op08Z*Op08Z)*2;
#ifdef DebugDSP1
Log_Message("OP08 %d,%d,%d",Op08X,Op08Y,Op08Z);
Log_Message("OP08 ((Op08X^2)+(Op08Y^2)+(Op08X^2))*2=%d",Op08Size );
#endif
}
short Op18X;
short Op18Y;
short Op18Z;
short Op18R;
short Op18Difference;
DSPOp18()
{
Op18Difference=((Op18X*Op18X+Op18Y*Op18Y+Op18Z*Op18Z-Op18R*Op18R)*2)/65536;
#ifdef DebugDSP1
Log_Message("OP18 DIFF %d",Op18Difference);
#endif
}
short Op28X;
short Op28Y;
short Op28Z;
short Op28R;
DSPOp28()
{
Op28R=sqrt(abs(Op28X*Op28X+Op28Y*Op28Y+Op28Z*Op28Z));
#ifdef DebugDSP1
Log_Message("OP28 X:%d Y:%d Z:%d",Op18X,Op18Y,Op18Z);
Log_Message("OP28 Vector Length %d",Op18R);
#endif
}
unsigned short Op0CA;
short Op0CX1;
short Op0CY1;
short Op0CX2;
short Op0CY2;
DSPOp0C()
{
Op0CX2=(Op0CX1*CosTable2[(Op0CA/256)&255]+Op0CY1*SinTable2[(Op0CA/256)&255])/65536;
Op0CY2=(Op0CX1*-SinTable2[(Op0CA/256)&255]+Op0CY1*CosTable2[(Op0CA/256)&255])/65536;
#ifdef DebugDSP1
Log_Message("OP0C Angle:%d X:%d Y:%d CX:%d CY:%d",(Op0CA/256)&255,Op0CX1,Op0CY1,Op0CX2,Op0CY2);
#endif
}
unsigned short Op1CAZ;
unsigned short Op1CAX;
unsigned short Op1CAY;
short Op1CX;
short Op1CY;
short Op1CZ;
short Op1CX1;
short Op1CY1;
short Op1CZ1;
short Op1CX2;
short Op1CY2;
short Op1CZ2;
short Op1CX3;
short Op1CY3;
short Op1CZ3;
DSPOp1C()
{
// rotate around Y
Op1CX1=(Op1CX*CosTable2[(Op1CAY/256)&255]+Op1CZ*SinTable2[(Op1CAY/256)&255])/65536;
Op1CY1=Op1CY;
Op1CZ1=(Op1CX*-SinTable2[(Op1CAY/256)&255]+Op1CZ*CosTable2[(Op1CAY/256)&255])/65536;
// rotate around X
Op1CX2=Op1CX1;
Op1CY2=(Op1CY1*CosTable2[(Op1CAX/256)&255]+Op1CZ1*-SinTable2[(Op1CAX/256)&255])/65536;
Op1CZ2=(Op1CY1*SinTable2[(Op1CAX/256)&255]+Op1CZ1*CosTable2[(Op1CAX/256)&255])/65536;
// rotate around Z
Op1CX3=(Op1CX2*CosTable2[(Op1CAZ/256)&255]+Op1CY2*-SinTable2[(Op1CAZ/256)&255])/65536;
Op1CY3=(Op1CX2*SinTable2[(Op1CAZ/256)&255]+Op1CY2*CosTable2[(Op1CAZ/256)&255])/65536;
Op1CZ3=Op1CZ2;
#ifdef DebugDSP1
Log_Message("OP1C Apply Matrix CX:%d CY:%d CZ",Op1CX3,Op1CY3,Op1CZ3);
#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;
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=ViewerX+ViewerX1*NumberOfSlope;
Op02CY=ViewerY+ViewerY1*NumberOfSlope;
Op02CXF=ViewerX+ViewerX1*NumberOfSlope;
Op02CYF=ViewerY+ViewerY1*NumberOfSlope;
Op02VOF=0x0000;
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);
#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;
DSPOp0A()
{
if(Op0AVS==0)Op0AVS++;
ScreenLZ1=-cos((Op02AZS-16384.0)*6.2832/65536.0); // -16384.0
ScreenLX1=sin((Op02AZS-16384.0)*6.2832/65536.0)*-sin(Op02AAS*6.2832/65536.0);
ScreenLY1=-sin((Op02AZS-16384.0)*6.2832/65536.0)*-cos(-Op02AAS*6.2832/65536.0);
RasterRX=RasterLX=ScreenX+(Op0AVS)*ScreenLX1;
RasterRY=RasterLY=ScreenY+(Op0AVS)*ScreenLY1;
RasterRZ=RasterLZ=ScreenZ+(Op0AVS)*ScreenLZ1;
ScreenLX1=sin((Op02AAS+16384.0)*6.2832/65536);
ScreenLY1=cos(-(Op02AAS+16384.0)*6.2832/65536);
RasterLX=RasterLX-128*ScreenLX1;
RasterLY=RasterLY-128*ScreenLY1;
RasterRX=RasterRX+128*ScreenLX1;
RasterRY=RasterRY+128*ScreenLY1;
Distance=Op02LFE;
if(Distance==0)Distance=1;
RasterLSlopeX=(RasterLX-ViewerX)/Distance;
RasterLSlopeY=(RasterLY-ViewerY)/Distance;
RasterLSlopeZ=(RasterLZ-ViewerZ)/Distance;
RasterRSlopeX=(RasterRX-ViewerX)/Distance;
RasterRSlopeY=(RasterRY-ViewerY)/Distance;
RasterRSlopeZ=(RasterRZ-ViewerZ)/Distance;
if(RasterLSlopeZ==0) RasterLSlopeZ++; // divide by 0
NumberOfSlope=ViewerZ/-RasterLSlopeZ;
GroundLX=ViewerX+RasterLSlopeX*NumberOfSlope;
GroundLY=ViewerY+RasterLSlopeY*NumberOfSlope;
if(RasterRSlopeZ==0) RasterRSlopeZ++; // divide by 0
NumberOfSlope=ViewerZ/-RasterRSlopeZ;
GroundRX=ViewerX+RasterRSlopeX*NumberOfSlope;
GroundRY=ViewerY+RasterRSlopeY*NumberOfSlope;
if(Op02LES==0)Op02LES=1;
Op0AA=(GroundRX-GroundLX);
Op0AB=(GroundRY-GroundLY); //0x300/Op02LES*2;
if(Op0AVS!=0)
{
Op0AC=(((Op02CXF)-((GroundRX+GroundLX)/2)))/Op0AVS;
Op0AD=(((Op02CYF)-((GroundRY+GroundLY)/2)))/Op0AVS*256;
}
else
{
Op0AC=0;
Op0AD=0;
}
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;
DSPOp06()
{
ObjPX=Op06X-Op02CXF;
ObjPY=Op06Y-Op02CYF;
ObjPZ=Op06Z;
// rotate around Z
ObjPX1=(ObjPX*cos((-Op02AAS+32768)/65536.0*6.2832)+ObjPY*-sin((-Op02AAS+32768)/65536.0*6.2832));
ObjPY1=(ObjPX*sin((-Op02AAS+32768)/65536.0*6.2832)+ObjPY*cos((-Op02AAS+32768)/65536.0*6.2832));
ObjPZ1=ObjPZ;
// rotate around X
ObjPX2=ObjPX1;
ObjPY2=(ObjPY1*cos((-Op02AZS)/65536.0*6.2832)+ObjPZ1*-sin((-Op02AZS)/65536.0*6.2832));
ObjPZ2=(ObjPY1*sin((-Op02AZS)/65536.0*6.2832)+ObjPZ1*cos((-Op02AZS)/65536.0*6.2832));
#ifdef debug06
printf("ObjPX2: %f ObjPY2: %f ObjPZ2: %f\n",ObjPX2,ObjPY2,ObjPZ2);
#endif
ObjPZ2=ObjPZ2-Op02LFE;
if (ObjPZ2<0)
{
Op06H=-ObjPX2*Op02LES/-(ObjPZ2); //-ObjPX2*256/-ObjPZ2;
Op06V=-ObjPY2*Op02LES/-(ObjPZ2); //-ObjPY2*256/-ObjPZ2;
Op06S=256*Op02LES/-ObjPZ2;
}
else
{
Op06H=0;
Op06V=14*16;
}
#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
}
double matrix[4][4];
double smat[4][4];
double tmat[4][4];
double xmat[4][4];
double ymat[4][4];
double zmat[4][4];
double matrix0[4][4];
double matrix1[4][4];
double matrix2[4][4];
double matrixI0[4][4];
double matrixI1[4][4];
double matrixI2[4][4];
void InitMatrix()
{
matrix[0][0]=1; matrix[0][1]=0; matrix[0][2]=0; matrix[0][3]=0;
matrix[1][0]=0; matrix[1][1]=1; matrix[1][2]=0; matrix[1][3]=0;
matrix[2][0]=0; matrix[2][1]=0; matrix[2][2]=1; matrix[2][3]=0;
matrix[3][0]=0; matrix[3][1]=0; matrix[3][2]=0; matrix[3][3]=1;
}
void MultMatrix(double result[4][4],double mat1[4][4],double mat2[4][4])
{
result[0][0]=0;
result[0][0]+=(mat1[0][0]*mat2[0][0]+mat1[0][1]*mat2[1][0]+mat1[0][2]*mat2[2][0]+mat1[0][3]*mat2[3][0]);
result[0][1]=0;
result[0][1]+=(mat1[0][0]*mat2[0][1]+mat1[0][1]*mat2[1][1]+mat1[0][2]*mat2[2][1]+mat1[0][3]*mat2[3][1]);
result[0][2]=0;
result[0][2]+=(mat1[0][0]*mat2[0][2]+mat1[0][1]*mat2[1][2]+mat1[0][2]*mat2[2][2]+mat1[0][3]*mat2[3][2]);
result[0][3]=0;
result[0][3]+=(mat1[0][0]*mat2[0][3]+mat1[0][1]*mat2[1][3]+mat1[0][2]*mat2[2][3]+mat1[0][3]*mat2[3][3]);
result[1][0]=0;
result[1][0]+=(mat1[1][0]*mat2[0][0]+mat1[1][1]*mat2[1][0]+mat1[1][2]*mat2[2][0]+mat1[1][3]*mat2[3][0]);
result[1][1]=0;
result[1][1]+=(mat1[1][0]*mat2[0][1]+mat1[1][1]*mat2[1][1]+mat1[1][2]*mat2[2][1]+mat1[1][3]*mat2[3][1]);
result[1][2]=0;
result[1][2]+=(mat1[1][0]*mat2[0][2]+mat1[1][1]*mat2[1][2]+mat1[1][2]*mat2[2][2]+mat1[1][3]*mat2[3][2]);
result[1][3]=0;
result[1][3]+=(mat1[1][0]*mat2[0][3]+mat1[1][1]*mat2[1][3]+mat1[1][2]*mat2[2][3]+mat1[1][3]*mat2[3][3]);
result[2][0]=0;
result[2][0]+=(mat1[2][0]*mat2[0][0]+mat1[2][1]*mat2[1][0]+mat1[2][2]*mat2[2][0]+mat1[2][3]*mat2[3][0]);
result[2][1]=0;
result[2][1]+=(mat1[2][0]*mat2[0][1]+mat1[2][1]*mat2[1][1]+mat1[2][2]*mat2[2][1]+mat1[2][3]*mat2[3][1]);
result[2][2]=0;
result[2][2]+=(mat1[2][0]*mat2[0][2]+mat1[2][1]*mat2[1][2]+mat1[2][2]*mat2[2][2]+mat1[2][3]*mat2[3][2]);
result[2][3]=0;
result[2][3]+=(mat1[2][0]*mat2[0][3]+mat1[2][1]*mat2[1][3]+mat1[2][2]*mat2[2][3]+mat1[2][3]*mat2[3][3]);
result[3][0]=0;
result[3][0]+=(mat1[3][0]*mat2[0][0]+mat1[3][1]*mat2[1][0]+mat1[3][2]*mat2[2][0]+mat1[3][3]*mat2[3][0]);
result[3][1]=0;
result[3][1]+=(mat1[3][0]*mat2[0][1]+mat1[3][1]*mat2[1][1]+mat1[3][2]*mat2[2][1]+mat1[3][3]*mat2[3][1]);
result[3][2]=0;
result[3][2]+=(mat1[3][0]*mat2[0][2]+mat1[3][1]*mat2[1][2]+mat1[3][2]*mat2[2][2]+mat1[3][3]*mat2[3][2]);
result[3][3]=0;
result[3][3]+=(mat1[3][0]*mat2[0][3]+mat1[3][1]*mat2[1][3]+mat1[3][2]*mat2[2][3]+mat1[3][3]*mat2[3][3]);
}
void CopyMatrix(double dest[4][4],double source[4][4])
{
dest[0][0]=source[0][0];
dest[0][1]=source[0][1];
dest[0][2]=source[0][2];
dest[0][3]=source[0][3];
dest[1][0]=source[1][0];
dest[1][1]=source[1][1];
dest[1][2]=source[1][2];
dest[1][3]=source[1][3];
dest[2][0]=source[2][0];
dest[2][1]=source[2][1];
dest[2][2]=source[2][2];
dest[2][3]=source[2][3];
dest[3][0]=source[3][0];
dest[3][1]=source[3][1];
dest[3][2]=source[3][2];
dest[3][3]=source[3][3];
}
void scale(double sf)
{
double mat[4][4];
smat[0][0]=sf; smat[0][1]=0; smat[0][2]=0; smat[0][3]=0;
smat[1][0]=0; smat[1][1]=sf; smat[1][2]=0; smat[1][3]=0;
smat[2][0]=0; smat[2][1]=0; smat[2][2]=sf; smat[2][3]=0;
smat[3][0]=0; smat[3][1]=0; smat[3][2]=0; smat[3][3]=1;
MultMatrix(mat,smat,matrix);
CopyMatrix(matrix,mat);
}
void translate(double xt,double yt,double zt)
{
double mat[4][4];
tmat[0][0]=1; tmat[0][1]=0; tmat[0][2]=0; tmat[0][3]=0;
tmat[1][0]=0; tmat[1][1]=1; tmat[1][2]=0; tmat[1][3]=0;
tmat[2][0]=0; tmat[2][1]=0; tmat[2][2]=1; tmat[2][3]=0;
tmat[3][0]=xt; tmat[3][1]=yt; tmat[3][2]=zt; tmat[3][3]=1;
MultMatrix(mat,matrix,tmat);
CopyMatrix(matrix,mat);
}
void rotate(double ax,double ay,double az)
{
double mat1[4][4];
double mat2[4][4];
xmat[0][0]=1; xmat[0][1]=0; xmat[0][2]=0; xmat[0][3]=0;
xmat[1][0]=0; xmat[1][1]=cos(ax); xmat[1][2]=sin(ax); xmat[1][3]=0;
xmat[2][0]=0; xmat[2][1]=-(sin(ax)); xmat[2][2]=cos(ax); xmat[2][3]=0;
xmat[3][0]=0; xmat[3][1]=0; xmat[3][2]=0; xmat[3][3]=1;
MultMatrix(mat1,xmat,matrix);
ymat[0][0]=cos(ay); ymat[0][1]=0; ymat[0][2]=-(sin(ay)); ymat[0][3]=0;
ymat[1][0]=0; ymat[1][1]=1; ymat[1][2]=0; ymat[1][3]=0;
ymat[2][0]=sin(ay); ymat[2][1]=0; ymat[2][2]=cos(ay); ymat[2][3]=0;
ymat[3][0]=0; ymat[3][1]=0; ymat[3][2]=0; ymat[3][3]=1;
MultMatrix(mat2,ymat,mat1);
zmat[0][0]=cos(az); zmat[0][1]=sin(az); zmat[0][2]=0; zmat[0][3]=0;
zmat[1][0]=-(sin(az)); zmat[1][1]=cos(az); zmat[1][2]=0; zmat[1][3]=0;
zmat[2][0]=0; zmat[2][1]=0; zmat[2][2]=1; zmat[2][3]=0;
zmat[3][0]=0; zmat[3][1]=0; zmat[3][2]=0; zmat[3][3]=1;
MultMatrix(matrix,zmat,mat2);
}
short Op01m;
short Op01Zr;
short Op01Xr;
short Op01Yr;
DSPOp01()
{
InitMatrix();
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
CopyMatrix(matrix0,matrix);
InitMatrix();
rotate(0,0,Op01Zr/65536.0*6.2832);
rotate(Op01Xr/65536.0*6.2832,0,0);
rotate(0,Op01Yr/65536.0*6.2832,0);
CopyMatrix(matrixI0,matrix);
#ifdef DebugDSP1
Log_Message("OP01");
#endif
}
DSPOp11()
{
InitMatrix();
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
CopyMatrix(matrix1,matrix);
InitMatrix();
rotate(0,0,Op01Zr/65536.0*6.2832);
rotate(Op01Xr/65536.0*6.2832,0,0);
rotate(0,Op01Yr/65536.0*6.2832,0);
CopyMatrix(matrixI1,matrix);
#ifdef DebugDSP1
Log_Message("OP11");
#endif
}
DSPOp21()
{
InitMatrix();
rotate(Op01Xr/65536.0*6.2832,Op01Yr/65536.0*6.2832,Op01Zr/65536.0*6.2832);
CopyMatrix(matrix2,matrix);
InitMatrix();
rotate(0,0,Op01Zr/65536.0*6.2832);
rotate(Op01Xr/65536.0*6.2832,0,0);
rotate(0,Op01Yr/65536.0*6.2832,0);
CopyMatrix(matrixI2,matrix);
#ifdef DebugDSP1
Log_Message("OP21");
#endif
}
short Op0DX;
short Op0DY;
short Op0DZ;
short Op0DF;
short Op0DL;
short Op0DU;
DSPOp0D()
{
Op0DF=(double)(Op0DX*matrixI0[0][0]+Op0DY*matrixI0[1][0]+Op0DZ*matrixI0[2][0]+matrixI0[3][0]);
Op0DL=(double)(Op0DX*matrixI0[0][1]+Op0DY*matrixI0[1][1]+Op0DZ*matrixI0[2][1]+matrixI0[3][1]);
Op0DU=(double)(Op0DX*matrixI0[0][2]+Op0DY*matrixI0[1][2]+Op0DZ*matrixI0[2][2]+matrixI0[3][2]);
#ifdef DebugDSP1
Log_Message("OP0D");
#endif
}
DSPOp1D()
{
Op0DF=(double)(Op0DX*matrixI1[0][0]+Op0DY*matrixI1[1][0]+Op0DZ*matrixI1[2][0]+matrixI1[3][0]);
Op0DL=(double)(Op0DX*matrixI1[0][1]+Op0DY*matrixI1[1][1]+Op0DZ*matrixI1[2][1]+matrixI1[3][1]);
Op0DU=(double)(Op0DX*matrixI1[0][2]+Op0DY*matrixI1[1][2]+Op0DZ*matrixI1[2][2]+matrixI1[3][2]);
#ifdef DebugDSP1
Log_Message("OP1D");
#endif
}
DSPOp2D()
{
Op0DF=(double)(Op0DX*matrixI2[0][0]+Op0DY*matrixI2[1][0]+Op0DZ*matrixI2[2][0]+matrixI2[3][0]);
Op0DL=(double)(Op0DX*matrixI2[0][1]+Op0DY*matrixI2[1][1]+Op0DZ*matrixI2[2][1]+matrixI2[3][1]);
Op0DU=(double)(Op0DX*matrixI2[0][2]+Op0DY*matrixI2[1][2]+Op0DZ*matrixI2[2][2]+matrixI2[3][2]);
#ifdef DebugDSP1
Log_Message("OP2D");
#endif
}
short Op03F;
short Op03L;
short Op03U;
short Op03X;
short Op03Y;
short Op03Z;
DSPOp03()
{
Op03X=(double)(Op03F*matrix0[0][0]+Op03L*matrix0[1][0]+Op03U*matrix0[2][0]+matrix0[3][0]);
Op03Y=(double)(Op03F*matrix0[0][1]+Op03L*matrix0[1][1]+Op03U*matrix0[2][1]+matrix0[3][1]);
Op03Z=(double)(Op03F*matrix0[0][2]+Op03L*matrix0[1][2]+Op03U*matrix0[2][2]+matrix0[3][2]);
#ifdef DebugDSP1
Log_Message("OP03");
#endif
}
DSPOp13()
{
Op03X=(double)(Op03F*matrix1[0][0]+Op03L*matrix1[1][0]+Op03U*matrix1[2][0]+matrix1[3][0]);
Op03Y=(double)(Op03F*matrix1[0][1]+Op03L*matrix1[1][1]+Op03U*matrix1[2][1]+matrix1[3][1]);
Op03Z=(double)(Op03F*matrix1[0][2]+Op03L*matrix1[1][2]+Op03U*matrix1[2][2]+matrix1[3][2]);
#ifdef DebugDSP1
Log_Message("OP13");
#endif
}
DSPOp23()
{
Op03X=(double)(Op03F*matrix2[0][0]+Op03L*matrix2[1][0]+Op03U*matrix2[2][0]+matrix2[3][0]);
Op03Y=(double)(Op03F*matrix2[0][1]+Op03L*matrix2[1][1]+Op03U*matrix2[2][1]+matrix2[3][1]);
Op03Z=(double)(Op03F*matrix2[0][2]+Op03L*matrix2[1][2]+Op03U*matrix2[2][2]+matrix2[3][2]);
#ifdef DebugDSP1
Log_Message("OP23");
#endif
}
short Op14Zr;
short Op14Xr;
short Op14Yr;
short Op14U;
short Op14F;
short Op14L;
short Op14Zrr;
short Op14Xrr;
short Op14Yrr;
double Op14Temp;
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=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=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=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;
DSPOp0E()
{
// screen Directions UP
ScreenLZ1=-cos((Op02AZS-16384.0)*6.2832/65536.0); // -16384.0
ScreenLX1=sin((Op02AZS-16384.0)*6.2832/65536.0)*-sin(Op02AAS*6.2832/65536.0);
ScreenLY1=-sin((Op02AZS-16384.0)*6.2832/65536.0)*-cos(-Op02AAS*6.2832/65536.0);
RasterLX=ScreenX+(Op0EV)*ScreenLX1;
RasterLY=ScreenY+(Op0EV)*ScreenLY1;
RasterLZ=ScreenZ+(Op0EV)*ScreenLZ1;
// screen direction right
ScreenLX1=sin((Op02AAS+16384.0)*6.2832/65536);
ScreenLY1=cos(-(Op02AAS+16384.0)*6.2832/65536);
RasterLX=RasterLX+Op0EH*ScreenLX1;
RasterLY=RasterLY+Op0EH*ScreenLY1;
Distance=Op02LFE;
if(Distance==0)Distance=1;
RasterLSlopeX=(RasterLX-ViewerX)/Distance;
RasterLSlopeY=(RasterLY-ViewerY)/Distance;
RasterLSlopeZ=(RasterLZ-ViewerZ)/Distance;
if(RasterLSlopeZ==0)RasterLSlopeZ++;
NumberOfSlope=ViewerZ/-RasterLSlopeZ;
GroundLX=ViewerX+RasterLSlopeX*NumberOfSlope;
GroundLY=ViewerY+RasterLSlopeY*NumberOfSlope;
Op0EX=GroundLX;
Op0EY=GroundLY;
#ifdef DebugDSP1
Log_Message("OP0E COORDINATE H:%d V:%d",Op0EH,Op0EV);
Log_Message(" X:%d Y:%d",Op0EX,Op0EY);
#endif
}


View File

@@ -0,0 +1,639 @@
;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
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 Op0DX, Op0DY, Op0DZ, Op0DF, Op0DL, Op0DU, DSPOp0D
EXTSYM Op03X, Op03Y, Op03Z, Op03F, Op03L, Op03U, DSPOp03
EXTSYM Op14Zr, Op14Xr, Op14Yr, Op14U, Op14F, Op14L
EXTSYM Op14Zrr,Op14Xrr,Op14Yrr, DSPOp14
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,08000h
ret
.doC000
mov ax,08000h
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
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, 4 ; 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
DSP1_10: ; Inverse
push eax
mov ax,[DSP1VARS]
; mov [Op10a],ax
mov ax,[DSP1VARS+2]
; mov [Op10b],ax
pushad
; call DSPOp10
popad
; mov ax,[Op10A]
mov [DSP1RET],ax
; mov ax,[Op10B]
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
ret
DSP1_18: ; Vector Size Comparison
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
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
ret
DSP1_21: ; Set Attitude Matrix C
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
ret
DSP1_2D: ; Convert from global to object coords Matrix C
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
ret
DSP1_23: ; Convert from object to global coords Matrix C
ret
DSP1_0B: ; Calculation of inner product Matrix A
ret
DSP1_1B: ; Calculation of inner product Matrix B
ret
DSP1_2B: ; Calculation of inner product Matrix C
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


2683
zsnes/src/chips/fxemu2.asm Normal file

File diff suppressed because it is too large Load Diff

835
zsnes/src/chips/fxemu2.mac Normal file
View File

@@ -0,0 +1,835 @@
;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


614
zsnes/src/chips/fxemu2b.asm Normal file
View File

@@ -0,0 +1,614 @@
;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
%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


View File

@@ -0,0 +1,89 @@
;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


2551
zsnes/src/chips/fxemu2c.asm Normal file

File diff suppressed because it is too large Load Diff

529
zsnes/src/chips/fxemu2c.mac Normal file
View File

@@ -0,0 +1,529 @@
;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


3546
zsnes/src/chips/fxtable.asm Normal file

File diff suppressed because it is too large Load Diff

365
zsnes/src/chips/sa1proc.asm Normal file
View File

@@ -0,0 +1,365 @@
;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
; 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


2577
zsnes/src/chips/sa1regs.asm Normal file

File diff suppressed because it is too large Load Diff

670
zsnes/src/chips/sfxproc.asm Normal file
View File

@@ -0,0 +1,670 @@
;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
%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


1623
zsnes/src/cpu/65816d.inc Normal file

File diff suppressed because it is too large Load Diff

1621
zsnes/src/cpu/65816db.inc Normal file

File diff suppressed because it is too large Load Diff

1631
zsnes/src/cpu/65816dc.inc Normal file

File diff suppressed because it is too large Load Diff

812
zsnes/src/cpu/address.inc Normal file
View File

@@ -0,0 +1,812 @@
;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


792
zsnes/src/cpu/address2.inc Normal file
View File

@@ -0,0 +1,792 @@
;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


409
zsnes/src/cpu/addrni.asm Normal file
View File

@@ -0,0 +1,409 @@
;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


405
zsnes/src/cpu/addrni.inc Normal file
View File

@@ -0,0 +1,405 @@
;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


1355
zsnes/src/cpu/dma.asm Normal file

File diff suppressed because it is too large Load Diff

3054
zsnes/src/cpu/dsp.asm Normal file

File diff suppressed because it is too large Load Diff

5698
zsnes/src/cpu/dspproc.asm Normal file

File diff suppressed because it is too large Load Diff

1995
zsnes/src/cpu/e65816.inc Normal file

File diff suppressed because it is too large Load Diff

1987
zsnes/src/cpu/e65816b.inc Normal file

File diff suppressed because it is too large Load Diff

1987
zsnes/src/cpu/e65816c.inc Normal file

File diff suppressed because it is too large Load Diff

4374
zsnes/src/cpu/execute.asm Normal file

File diff suppressed because it is too large Load Diff

524
zsnes/src/cpu/irq.asm Normal file
View File

@@ -0,0 +1,524 @@
;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
; 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 eax,[wramdata]
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,[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 eax,[wramdata]
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,[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
xor ebx,ebx
mov eax,[wramdata]
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,[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
xor ebx,ebx
mov eax,[wramdata]
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,[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 eax,[wramdata]
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,[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
xor ebx,ebx
mov eax,[wramdata]
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,[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 eax,[wramdata]
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,[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
xor ebx,ebx
mov eax,[wramdata]
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,[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 eax,[wramdata]
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,[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


4406
zsnes/src/cpu/memory.asm Normal file

File diff suppressed because it is too large Load Diff

1099
zsnes/src/cpu/regs.inc Normal file

File diff suppressed because it is too large Load Diff

101
zsnes/src/cpu/regs.mac Normal file
View File

@@ -0,0 +1,101 @@
;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


1772
zsnes/src/cpu/regsw.inc Normal file

File diff suppressed because it is too large Load Diff

52
zsnes/src/cpu/regsw.mac Normal file
View File

@@ -0,0 +1,52 @@
;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


1574
zsnes/src/cpu/s65816d.inc Normal file

File diff suppressed because it is too large Load Diff

812
zsnes/src/cpu/saddress.inc Normal file
View File

@@ -0,0 +1,812 @@
;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


404
zsnes/src/cpu/saddrni.inc Normal file
View File

@@ -0,0 +1,404 @@
;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


1990
zsnes/src/cpu/se65816.inc Normal file

File diff suppressed because it is too large Load Diff

2695
zsnes/src/cpu/spc700.asm Normal file

File diff suppressed because it is too large Load Diff

97
zsnes/src/cpu/spcaddr.inc Normal file
View File

@@ -0,0 +1,97 @@
;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.
; A,DP addressing mode
%macro SPCaddr_DP 0
mov bl,[ebp]
add ebx,[spcRamDP]
inc ebp
ReadByte
%endmacro
%macro SPCaddr_DP_X 0
mov bl,[ebp]
add bl,[spcX]
add ebx,[spcRamDP]
inc ebp
ReadByte
%endmacro
%macro SPCaddr_LABS 0
mov bx,[ebp]
add ebx,spcRam
ReadByte
add ebp,2
%endmacro
%macro SPCaddr_LABS_X 0
mov bl,[spcX]
add bx,[ebp]
add ebp,2
add ebx,spcRam
ReadByte
%endmacro
; A,(X)
%macro SPCaddr__X_ 0
mov bl,[spcX]
add ebx,[spcRamDP]
ReadByte
%endmacro
; A,labs+Y
%macro SPCaddr_LABS_Y 0
mov bl,[spcY]
add bx,[ebp]
add ebp,2
add ebx,spcRam
ReadByte
%endmacro
; A,(DP,X)
%macro SPCaddr_bDP_Xb 0
mov bl,[ebp]
add bl,[spcX]
xor eax,eax
add ebx,[spcRamDP]
inc ebp
mov ax, word [ebx]
mov ebx,eax
add ebx,spcRam
ReadByte
%endmacro
%macro SPCaddr_bDPb_Y 0
mov bl,[ebp]
xor eax,eax
add ebx,[spcRamDP]
inc ebp
mov ax,[ebx]
add ax,[spcY]
mov ebx,eax
add ebx,spcRam
ReadByte
%endmacro


168
zsnes/src/cpu/spcdef.inc Normal file
View File

@@ -0,0 +1,168 @@
;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.
; move al at address ebx
; branch instructions
%macro spcbrancher 0
inc ebp
ret
.branch
movsx ebx,byte [ebp]
inc ebp
add ebp,ebx
ret
%endmacro
; tcall instruction
%macro spctcall 1
mov ebx,ebp
sub ebx,spcRam
mov eax,[spcS]
mov [spcRam+eax],bh
dec byte [spcS]
mov eax,[spcS]
mov [spcRam+eax],bl
dec byte [spcS]
mov bx,[spcextraram+%1]
test byte[spcRam+0F1h],80h
jnz %%finished
mov bx,[spcRam+0FFC0h+%1]
%%finished
add ebx,spcRam
mov ebp,ebx
ret
%endmacro
; SET1 instruction
%macro set1 1
mov bl,[ebp]
add ebx,[spcRamDP]
inc ebp
push ebx
ReadByte
pop ebx
or al,%1
WriteByte
ret
%endmacro
; CLR1 instruction
%macro clr1 1
mov bl,[ebp]
add ebx,[spcRamDP]
inc ebp
push ebx
ReadByte
pop ebx
and al,%1
WriteByte
ret
%endmacro
; BBS instruction
%macro bbs 1
mov bl,[ebp]
add ebx,[spcRamDP]
ReadByte
test al,%1
jnz .dp0jump
add ebp,2
ret
.dp0jump
movsx ebx,byte [ebp+1]
add ebp,ebx
add ebp,2
ret
%endmacro
; BBC instruction
%macro bbc 1
mov bl,[ebp]
add ebx,[spcRamDP]
ReadByte
test al,%1
jz .dp0jump
add ebp,2
ret
.dp0jump
movsx ebx,byte [ebp+1]
add ebp,ebx
add ebp,2
ret
%endmacro
; OR A, instruction
%macro SPC_OR_A 0
or byte [spcA], al
mov al,[spcA]
mov [spcNZ],al
ret
%endmacro
; AND A, instruction
%macro SPC_AND_A 0
and byte [spcA], al
mov al,[spcA]
mov [spcNZ],al
ret
%endmacro
; EOR A, instruction
%macro SPC_EOR_A 0
xor byte [spcA], al
mov al,[spcA]
mov [spcNZ],al
ret
%endmacro
; CMP A, instruction
%macro SPC_CMP_A 0
cmp byte [spcA], al
cmc
SPCSetFlagnzc
%endmacro
%macro SPC_ADC_A 0
mov cl,[spcP]
shr cl,1
adc byte [spcA], al
SPCSetFlagnvhzc
%endmacro
%macro SPC_SBC_A 0
mov cl,[spcP]
xor cl,1
shr cl,1
sbb byte [spcA], al
cmc
SPCSetFlagnvhzc
%endmacro
%macro SPC_MOV_A 0
mov byte [spcA], al
mov [spcNZ],al
ret
%endmacro


699
zsnes/src/cpu/stable.asm Normal file
View File

@@ -0,0 +1,699 @@
;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 SA1tableA,SA1tableB,SA1tableC,SA1tableD,SA1tableE
EXTSYM SA1tableF,SA1tableG,SA1tableH,SA1tablead
EXTSYM cpucycle, SA1UpdateDPage, intrset
%include "cpu/s65816d.inc"
%include "cpu/saddress.inc"
%include "cpu/saddrni.inc"
%include "cpu/se65816.inc"
; global variables
;tableA times 256 dd 0 ; Table addresses (M:0,X:0,D:0)
;tableB times 256 dd 0 ; Table addresses (M:1,X:0,D:0)
;tableC times 256 dd 0 ; Table addresses (M:0,X:1,D:0)
;tableD times 256 dd 0 ; Table addresses (M:1,X:1,D:0)
;tableE times 256 dd 0 ; Table addresses (M:0,X:0,D:1)
;tableF times 256 dd 0 ; Table addresses (M:1,X:0,D:1)
;tableG times 256 dd 0 ; Table addresses (M:0,X:1,D:1)
;tableH times 256 dd 0 ; Table addresses (M:1,X:1,D:1)
;tablead times 256 dd 0 ; Table address location according to P
;memtabler8 times 256 dd 0 ; Memory Bank Locations for reading 8-bit
;memtablew8 times 256 dd 0 ; Memory Bank Locations for writing 8-bit
;memtabler16 times 256 dd 0 ; Memory Bank Locations for reading 16-bit
;memtablew16 times 256 dd 0 ; Memory Bank Locations for reading 16-bit
;*******************************************************
; Generate OpCode Table
;*******************************************************
NEWSYM SA1inittable
; set tablead (NVMXDIZC) ( MXD )
push es
xor ecx,ecx
xor al,al
mov cx,256
mov edi,SA1tablead
.loopa
test al,08h ; D flag
jnz .decon
test al,10h ; X flag
jnz .xon
test al,20h ; M flag
jnz .mon
mov esi,SA1tableA
jmp .done
.mon
mov esi,SA1tableB
jmp .done
.xon
test al,20h ; M flag
jnz .mon2
mov esi,SA1tableC
jmp .done
.mon2
mov esi,SA1tableD
jmp .done
.decon
test al,10h ; X flag
jnz .xon3
test al,20h ; M flag
jnz .mon3
mov esi,SA1tableE
jmp .done
.mon3
mov esi,SA1tableF
jmp .done
.xon3
test al,20h
jnz .mon4
mov esi,SA1tableG
jmp .done
.mon4
mov esi,SA1tableH
.done
inc al
push eax
mov eax,esi
stosd
pop eax
loop .loopa
; Set CPU addresses
mov edi,SA1tableA
call SA1settables
mov edi,SA1tableB
call SA1settables
mov edi,SA1tableC
call SA1settables
mov edi,SA1tableD
call SA1settables
mov edi,SA1tableE
call SA1settables
mov edi,SA1tableF
call SA1settables
mov edi,SA1tableG
call SA1settables
mov edi,SA1tableH
call SA1settables
; set proper functions
mov edi,SA1tableA ; Table addresses (M:0,X:0,D:0)
call SA1settablem16
mov edi,SA1tableA
call SA1settablex16
mov edi,SA1tableB ; Table addresses (M:1,X:0,D:0)
call SA1settablex16
mov edi,SA1tableC ; Table addresses (M:0,X:1,D:0)
call SA1settablem16
mov edi,SA1tableE ; Table addresses (M:0,X:0,D:1)
call SA1settablem16
mov edi,SA1tableE
call SA1settableDm16
mov edi,SA1tableE
call SA1settablex16
mov edi,SA1tableF ; Table addresses (M:1,X:0,D:1)
call SA1settablex16
mov edi,SA1tableF
call SA1settableDm8
mov edi,SA1tableG ; Table addresses (M:0,X:1,D:1)
call SA1settablem16
mov edi,SA1tableG
call SA1settableDm16
mov edi,SA1tableH ; Table addresses (M:1,X:1,D:1)
call SA1settableDm8
pop es
ret
;*******************************************************
; Set Tables Sets the opcode tables according to EDI
;*******************************************************
; This function sets all the non-multiple entries
NEWSYM SA1settables
;row 0
mov dword[edi+00h*4],SA1COp00
mov dword[edi+01h*4],SA1COp01m8
mov dword[edi+02h*4],SA1COp02
mov dword[edi+03h*4],SA1COp03m8
mov dword[edi+04h*4],SA1COp04m8
mov dword[edi+05h*4],SA1COp05m8
mov dword[edi+06h*4],SA1COp06m8
mov dword[edi+07h*4],SA1COp07m8
mov dword[edi+08h*4],SA1COp08
mov dword[edi+09h*4],SA1COp09m8
mov dword[edi+0Ah*4],SA1COp0Am8
mov dword[edi+0Bh*4],SA1COp0B
mov dword[edi+0Ch*4],SA1COp0Cm8
mov dword[edi+0Dh*4],SA1COp0Dm8
mov dword[edi+0Eh*4],SA1COp0Em8
mov dword[edi+0Fh*4],SA1COp0Fm8
mov dword[edi+10h*4],SA1COp10
mov dword[edi+11h*4],SA1COp11m8
mov dword[edi+12h*4],SA1COp12m8
mov dword[edi+13h*4],SA1COp13m8
mov dword[edi+14h*4],SA1COp14m8
mov dword[edi+15h*4],SA1COp15m8
mov dword[edi+16h*4],SA1COp16m8
mov dword[edi+17h*4],SA1COp17m8
mov dword[edi+18h*4],SA1COp18
mov dword[edi+19h*4],SA1COp19m8
mov dword[edi+1Ah*4],SA1COp1Am8
mov dword[edi+1Bh*4],SA1COp1B
mov dword[edi+1Ch*4],SA1COp1Cm8
mov dword[edi+1Dh*4],SA1COp1Dm8
mov dword[edi+1Eh*4],SA1COp1Em8
mov dword[edi+1Fh*4],SA1COp1Fm8
mov dword[edi+20h*4],SA1COp20
mov dword[edi+21h*4],SA1COp21m8
mov dword[edi+22h*4],SA1COp22
mov dword[edi+23h*4],SA1COp23m8
mov dword[edi+24h*4],SA1COp24m8
mov dword[edi+25h*4],SA1COp25m8
mov dword[edi+26h*4],SA1COp26m8
mov dword[edi+27h*4],SA1COp27m8
mov dword[edi+28h*4],SA1COp28
mov dword[edi+29h*4],SA1COp29m8
mov dword[edi+2Ah*4],SA1COp2Am8
mov dword[edi+2Bh*4],SA1COp2B
mov dword[edi+2Ch*4],SA1COp2Cm8
mov dword[edi+2Dh*4],SA1COp2Dm8
mov dword[edi+2Eh*4],SA1COp2Em8
mov dword[edi+2Fh*4],SA1COp2Fm8
mov dword[edi+30h*4],SA1COp30
mov dword[edi+31h*4],SA1COp31m8
mov dword[edi+32h*4],SA1COp32m8
mov dword[edi+33h*4],SA1COp33m8
mov dword[edi+34h*4],SA1COp34m8
mov dword[edi+35h*4],SA1COp35m8
mov dword[edi+36h*4],SA1COp36m8
mov dword[edi+37h*4],SA1COp37m8
mov dword[edi+38h*4],SA1COp38
mov dword[edi+39h*4],SA1COp39m8
mov dword[edi+3Ah*4],SA1COp3Am8
mov dword[edi+3Bh*4],SA1COp3B
mov dword[edi+3Ch*4],SA1COp3Cm8
mov dword[edi+3Dh*4],SA1COp3Dm8
mov dword[edi+3Eh*4],SA1COp3Em8
mov dword[edi+3Fh*4],SA1COp3Fm8
mov dword[edi+40h*4],SA1COp40
mov dword[edi+41h*4],SA1COp41m8
mov dword[edi+42h*4],SA1COp42
mov dword[edi+43h*4],SA1COp43m8
mov dword[edi+44h*4],SA1COp44
mov dword[edi+45h*4],SA1COp45m8
mov dword[edi+46h*4],SA1COp46m8
mov dword[edi+47h*4],SA1COp47m8
mov dword[edi+48h*4],SA1COp48m8
mov dword[edi+49h*4],SA1COp49m8
mov dword[edi+4Ah*4],SA1COp4Am8
mov dword[edi+4Bh*4],SA1COp4B
mov dword[edi+4Ch*4],SA1COp4C
mov dword[edi+4Dh*4],SA1COp4Dm8
mov dword[edi+4Eh*4],SA1COp4Em8
mov dword[edi+4Fh*4],SA1COp4Fm8
mov dword[edi+50h*4],SA1COp50
mov dword[edi+51h*4],SA1COp51m8
mov dword[edi+52h*4],SA1COp52m8
mov dword[edi+53h*4],SA1COp53m8
mov dword[edi+54h*4],SA1COp54
mov dword[edi+55h*4],SA1COp55m8
mov dword[edi+56h*4],SA1COp56m8
mov dword[edi+57h*4],SA1COp57m8
mov dword[edi+58h*4],SA1COp58
mov dword[edi+59h*4],SA1COp59m8
mov dword[edi+5Ah*4],SA1COp5Ax8
mov dword[edi+5Bh*4],SA1COp5B
mov dword[edi+5Ch*4],SA1COp5C
mov dword[edi+5Dh*4],SA1COp5Dm8
mov dword[edi+5Eh*4],SA1COp5Em8
mov dword[edi+5Fh*4],SA1COp5Fm8
mov dword[edi+60h*4],SA1COp60
mov dword[edi+61h*4],SA1COp61m8nd
mov dword[edi+62h*4],SA1COp62
mov dword[edi+63h*4],SA1COp63m8nd
mov dword[edi+64h*4],SA1COp64m8
mov dword[edi+65h*4],SA1COp65m8nd
mov dword[edi+66h*4],SA1COp66m8
mov dword[edi+67h*4],SA1COp67m8nd
mov dword[edi+68h*4],SA1COp68m8
mov dword[edi+69h*4],SA1COp69m8nd
mov dword[edi+6Ah*4],SA1COp6Am8
mov dword[edi+6Bh*4],SA1COp6B
mov dword[edi+6Ch*4],SA1COp6C
mov dword[edi+6Dh*4],SA1COp6Dm8nd
mov dword[edi+6Eh*4],SA1COp6Em8
mov dword[edi+6Fh*4],SA1COp6Fm8nd
mov dword[edi+70h*4],SA1COp70
mov dword[edi+71h*4],SA1COp71m8nd
mov dword[edi+72h*4],SA1COp72m8nd
mov dword[edi+73h*4],SA1COp73m8nd
mov dword[edi+74h*4],SA1COp74m8
mov dword[edi+75h*4],SA1COp75m8nd
mov dword[edi+76h*4],SA1COp76m8
mov dword[edi+77h*4],SA1COp77m8nd
mov dword[edi+78h*4],SA1COp78
mov dword[edi+79h*4],SA1COp79m8nd
mov dword[edi+7Ah*4],SA1COp7Ax8
mov dword[edi+7Bh*4],SA1COp7B
mov dword[edi+7Ch*4],SA1COp7C
mov dword[edi+7Dh*4],SA1COp7Dm8nd
mov dword[edi+7Eh*4],SA1COp7Em8
mov dword[edi+7Fh*4],SA1COp7Fm8nd
mov dword[edi+80h*4],SA1COp80
mov dword[edi+81h*4],SA1COp81m8
mov dword[edi+82h*4],SA1COp82
mov dword[edi+83h*4],SA1COp83m8
mov dword[edi+84h*4],SA1COp84x8
mov dword[edi+85h*4],SA1COp85m8
mov dword[edi+86h*4],SA1COp86x8
mov dword[edi+87h*4],SA1COp87m8
mov dword[edi+88h*4],SA1COp88x8
mov dword[edi+89h*4],SA1COp89m8
mov dword[edi+8Ah*4],SA1COp8Am8
mov dword[edi+8Bh*4],SA1COp8B
mov dword[edi+8Ch*4],SA1COp8Cx8
mov dword[edi+8Dh*4],SA1COp8Dm8
mov dword[edi+8Eh*4],SA1COp8Ex8
mov dword[edi+8Fh*4],SA1COp8Fm8
mov dword[edi+90h*4],SA1COp90
mov dword[edi+91h*4],SA1COp91m8
mov dword[edi+92h*4],SA1COp92m8
mov dword[edi+93h*4],SA1COp93m8
mov dword[edi+94h*4],SA1COp94x8
mov dword[edi+95h*4],SA1COp95m8
mov dword[edi+96h*4],SA1COp96x8
mov dword[edi+97h*4],SA1COp97m8
mov dword[edi+98h*4],SA1COp98m8
mov dword[edi+99h*4],SA1COp99m8
mov dword[edi+9Ah*4],SA1COp9A
mov dword[edi+9Bh*4],SA1COp9Bx8
mov dword[edi+9Ch*4],SA1COp9Cm8
mov dword[edi+9Dh*4],SA1COp9Dm8
mov dword[edi+9Eh*4],SA1COp9Em8
mov dword[edi+9Fh*4],SA1COp9Fm8
mov dword[edi+0A0h*4],SA1COpA0x8
mov dword[edi+0A1h*4],SA1COpA1m8
mov dword[edi+0A2h*4],SA1COpA2x8
mov dword[edi+0A3h*4],SA1COpA3m8
mov dword[edi+0A4h*4],SA1COpA4x8
mov dword[edi+0A5h*4],SA1COpA5m8
mov dword[edi+0A6h*4],SA1COpA6x8
mov dword[edi+0A7h*4],SA1COpA7m8
mov dword[edi+0A8h*4],SA1COpA8x8
mov dword[edi+0A9h*4],SA1COpA9m8
mov dword[edi+0AAh*4],SA1COpAAx8
mov dword[edi+0ABh*4],SA1COpAB
mov dword[edi+0ACh*4],SA1COpACx8
mov dword[edi+0ADh*4],SA1COpADm8
mov dword[edi+0AEh*4],SA1COpAEx8
mov dword[edi+0AFh*4],SA1COpAFm8
mov dword[edi+0B0h*4],SA1COpB0
mov dword[edi+0B1h*4],SA1COpB1m8
mov dword[edi+0B2h*4],SA1COpB2m8
mov dword[edi+0B3h*4],SA1COpB3m8
mov dword[edi+0B4h*4],SA1COpB4x8
mov dword[edi+0B5h*4],SA1COpB5m8
mov dword[edi+0B6h*4],SA1COpB6x8
mov dword[edi+0B7h*4],SA1COpB7m8
mov dword[edi+0B8h*4],SA1COpB8
mov dword[edi+0B9h*4],SA1COpB9m8
mov dword[edi+0BAh*4],SA1COpBAx8
mov dword[edi+0BBh*4],SA1COpBBx8
mov dword[edi+0BCh*4],SA1COpBCx8
mov dword[edi+0BDh*4],SA1COpBDm8
mov dword[edi+0BEh*4],SA1COpBEx8
mov dword[edi+0BFh*4],SA1COpBFm8
mov dword[edi+0C0h*4],SA1COpC0x8
mov dword[edi+0C1h*4],SA1COpC1m8
mov dword[edi+0C2h*4],SA1COpC2
mov dword[edi+0C3h*4],SA1COpC3m8
mov dword[edi+0C4h*4],SA1COpC4x8
mov dword[edi+0C5h*4],SA1COpC5m8
mov dword[edi+0C6h*4],SA1COpC6m8
mov dword[edi+0C7h*4],SA1COpC7m8
mov dword[edi+0C8h*4],SA1COpC8x8
mov dword[edi+0C9h*4],SA1COpC9m8
mov dword[edi+0CAh*4],SA1COpCAx8
mov dword[edi+0CBh*4],SA1COpCB
mov dword[edi+0CCh*4],SA1COpCCx8
mov dword[edi+0CDh*4],SA1COpCDm8
mov dword[edi+0CEh*4],SA1COpCEm8
mov dword[edi+0CFh*4],SA1COpCFm8
mov dword[edi+0D0h*4],SA1COpD0
mov dword[edi+0D1h*4],SA1COpD1m8
mov dword[edi+0D2h*4],SA1COpD2m8
mov dword[edi+0D3h*4],SA1COpD3m8
mov dword[edi+0D4h*4],SA1COpD4
mov dword[edi+0D5h*4],SA1COpD5m8
mov dword[edi+0D6h*4],SA1COpD6m8
mov dword[edi+0D7h*4],SA1COpD7m8
mov dword[edi+0D8h*4],SA1COpD8
mov dword[edi+0D9h*4],SA1COpD9m8
mov dword[edi+0DAh*4],SA1COpDAx8
mov dword[edi+0DBh*4],SA1COpDB
mov dword[edi+0DCh*4],SA1COpDC
mov dword[edi+0DDh*4],SA1COpDDm8
mov dword[edi+0DEh*4],SA1COpDEm8
mov dword[edi+0DFh*4],SA1COpDFm8
mov dword[edi+0E0h*4],SA1COpE0x8
mov dword[edi+0E1h*4],SA1COpE1m8nd
mov dword[edi+0E2h*4],SA1COpE2
mov dword[edi+0E3h*4],SA1COpE3m8nd
mov dword[edi+0E4h*4],SA1COpE4x8
mov dword[edi+0E5h*4],SA1COpE5m8nd
mov dword[edi+0E6h*4],SA1COpE6m8
mov dword[edi+0E7h*4],SA1COpE7m8nd
mov dword[edi+0E8h*4],SA1COpE8x8
mov dword[edi+0E9h*4],SA1COpE9m8nd
mov dword[edi+0EAh*4],SA1COpEA
mov dword[edi+0EBh*4],SA1COpEB
mov dword[edi+0ECh*4],SA1COpECx8
mov dword[edi+0EDh*4],SA1COpEDm8nd
mov dword[edi+0EEh*4],SA1COpEEm8
mov dword[edi+0EFh*4],SA1COpEFm8nd
mov dword[edi+0F0h*4],SA1COpF0
mov dword[edi+0F1h*4],SA1COpF1m8nd
mov dword[edi+0F2h*4],SA1COpF2m8nd
mov dword[edi+0F3h*4],SA1COpF3m8nd
mov dword[edi+0F4h*4],SA1COpF4
mov dword[edi+0F5h*4],SA1COpF5m8nd
mov dword[edi+0F6h*4],SA1COpF6m8
mov dword[edi+0F7h*4],SA1COpF7m8nd
mov dword[edi+0F8h*4],SA1COpF8
mov dword[edi+0F9h*4],SA1COpF9m8nd
mov dword[edi+0FAh*4],SA1COpFAx8
mov dword[edi+0FBh*4],SA1COpFB
mov dword[edi+0FCh*4],SA1COpFC
mov dword[edi+0FDh*4],SA1COpFDm8nd
mov dword[edi+0FEh*4],SA1COpFEm8
mov dword[edi+0FFh*4],SA1COpFFm8nd
ret
NEWSYM SA1settablem16
mov dword[edi+01h*4],SA1COp01m16
mov dword[edi+03h*4],SA1COp03m16
mov dword[edi+04h*4],SA1COp04m16
mov dword[edi+05h*4],SA1COp05m16
mov dword[edi+06h*4],SA1COp06m16
mov dword[edi+07h*4],SA1COp07m16
mov dword[edi+09h*4],SA1COp09m16
mov dword[edi+0Ah*4],SA1COp0Am16
mov dword[edi+0Ch*4],SA1COp0Cm16
mov dword[edi+0Dh*4],SA1COp0Dm16
mov dword[edi+0Eh*4],SA1COp0Em16
mov dword[edi+0Fh*4],SA1COp0Fm16
mov dword[edi+11h*4],SA1COp11m16
mov dword[edi+12h*4],SA1COp12m16
mov dword[edi+13h*4],SA1COp13m16
mov dword[edi+14h*4],SA1COp14m16
mov dword[edi+15h*4],SA1COp15m16
mov dword[edi+16h*4],SA1COp16m16
mov dword[edi+17h*4],SA1COp17m16
mov dword[edi+19h*4],SA1COp19m16
mov dword[edi+1Ah*4],SA1COp1Am16
mov dword[edi+1Ch*4],SA1COp1Cm16
mov dword[edi+1Dh*4],SA1COp1Dm16
mov dword[edi+1Eh*4],SA1COp1Em16
mov dword[edi+1Fh*4],SA1COp1Fm16
mov dword[edi+21h*4],SA1COp21m16
mov dword[edi+23h*4],SA1COp23m16
mov dword[edi+24h*4],SA1COp24m16
mov dword[edi+25h*4],SA1COp25m16
mov dword[edi+26h*4],SA1COp26m16
mov dword[edi+27h*4],SA1COp27m16
mov dword[edi+29h*4],SA1COp29m16
mov dword[edi+2Ah*4],SA1COp2Am16
mov dword[edi+2Ch*4],SA1COp2Cm16
mov dword[edi+2Dh*4],SA1COp2Dm16
mov dword[edi+2Eh*4],SA1COp2Em16
mov dword[edi+2Fh*4],SA1COp2Fm16
mov dword[edi+31h*4],SA1COp31m16
mov dword[edi+32h*4],SA1COp32m16
mov dword[edi+33h*4],SA1COp33m16
mov dword[edi+34h*4],SA1COp34m16
mov dword[edi+35h*4],SA1COp35m16
mov dword[edi+36h*4],SA1COp36m16
mov dword[edi+37h*4],SA1COp37m16
mov dword[edi+39h*4],SA1COp39m16
mov dword[edi+3Ah*4],SA1COp3Am16
mov dword[edi+3Ch*4],SA1COp3Cm16
mov dword[edi+3Dh*4],SA1COp3Dm16
mov dword[edi+3Eh*4],SA1COp3Em16
mov dword[edi+3Fh*4],SA1COp3Fm16
mov dword[edi+41h*4],SA1COp41m16
mov dword[edi+43h*4],SA1COp43m16
mov dword[edi+45h*4],SA1COp45m16
mov dword[edi+46h*4],SA1COp46m16
mov dword[edi+47h*4],SA1COp47m16
mov dword[edi+48h*4],SA1COp48m16
mov dword[edi+49h*4],SA1COp49m16
mov dword[edi+4Ah*4],SA1COp4Am16
mov dword[edi+4Dh*4],SA1COp4Dm16
mov dword[edi+4Eh*4],SA1COp4Em16
mov dword[edi+4Fh*4],SA1COp4Fm16
mov dword[edi+51h*4],SA1COp51m16
mov dword[edi+52h*4],SA1COp52m16
mov dword[edi+53h*4],SA1COp53m16
mov dword[edi+55h*4],SA1COp55m16
mov dword[edi+56h*4],SA1COp56m16
mov dword[edi+57h*4],SA1COp57m16
mov dword[edi+59h*4],SA1COp59m16
mov dword[edi+5Dh*4],SA1COp5Dm16
mov dword[edi+5Eh*4],SA1COp5Em16
mov dword[edi+5Fh*4],SA1COp5Fm16
mov dword[edi+61h*4],SA1COp61m16nd
mov dword[edi+63h*4],SA1COp63m16nd
mov dword[edi+64h*4],SA1COp64m16
mov dword[edi+65h*4],SA1COp65m16nd
mov dword[edi+66h*4],SA1COp66m16
mov dword[edi+67h*4],SA1COp67m16nd
mov dword[edi+68h*4],SA1COp68m16
mov dword[edi+69h*4],SA1COp69m16nd
mov dword[edi+6Ah*4],SA1COp6Am16
mov dword[edi+6Dh*4],SA1COp6Dm16nd
mov dword[edi+6Eh*4],SA1COp6Em16
mov dword[edi+6Fh*4],SA1COp6Fm16nd
mov dword[edi+71h*4],SA1COp71m16nd
mov dword[edi+72h*4],SA1COp72m16nd
mov dword[edi+73h*4],SA1COp73m16nd
mov dword[edi+74h*4],SA1COp74m16
mov dword[edi+75h*4],SA1COp75m16nd
mov dword[edi+76h*4],SA1COp76m16
mov dword[edi+77h*4],SA1COp77m16nd
mov dword[edi+79h*4],SA1COp79m16nd
mov dword[edi+7Dh*4],SA1COp7Dm16nd
mov dword[edi+7Eh*4],SA1COp7Em16
mov dword[edi+7Fh*4],SA1COp7Fm16nd
mov dword[edi+81h*4],SA1COp81m16
mov dword[edi+83h*4],SA1COp83m16
mov dword[edi+85h*4],SA1COp85m16
mov dword[edi+87h*4],SA1COp87m16
mov dword[edi+89h*4],SA1COp89m16
mov dword[edi+8Ah*4],SA1COp8Am16
mov dword[edi+8Dh*4],SA1COp8Dm16
mov dword[edi+8Fh*4],SA1COp8Fm16
mov dword[edi+91h*4],SA1COp91m16
mov dword[edi+92h*4],SA1COp92m16
mov dword[edi+93h*4],SA1COp93m16
mov dword[edi+95h*4],SA1COp95m16
mov dword[edi+97h*4],SA1COp97m16
mov dword[edi+98h*4],SA1COp98m16
mov dword[edi+99h*4],SA1COp99m16
mov dword[edi+9Ch*4],SA1COp9Cm16
mov dword[edi+9Dh*4],SA1COp9Dm16
mov dword[edi+9Eh*4],SA1COp9Em16
mov dword[edi+9Fh*4],SA1COp9Fm16
mov dword[edi+0A1h*4],SA1COpA1m16
mov dword[edi+0A3h*4],SA1COpA3m16
mov dword[edi+0A5h*4],SA1COpA5m16
mov dword[edi+0A7h*4],SA1COpA7m16
mov dword[edi+0A9h*4],SA1COpA9m16
mov dword[edi+0ADh*4],SA1COpADm16
mov dword[edi+0AFh*4],SA1COpAFm16
mov dword[edi+0B1h*4],SA1COpB1m16
mov dword[edi+0B2h*4],SA1COpB2m16
mov dword[edi+0B3h*4],SA1COpB3m16
mov dword[edi+0B5h*4],SA1COpB5m16
mov dword[edi+0B7h*4],SA1COpB7m16
mov dword[edi+0B9h*4],SA1COpB9m16
mov dword[edi+0BDh*4],SA1COpBDm16
mov dword[edi+0BFh*4],SA1COpBFm16
mov dword[edi+0C1h*4],SA1COpC1m16
mov dword[edi+0C3h*4],SA1COpC3m16
mov dword[edi+0C5h*4],SA1COpC5m16
mov dword[edi+0C6h*4],SA1COpC6m16
mov dword[edi+0C7h*4],SA1COpC7m16
mov dword[edi+0C9h*4],SA1COpC9m16
mov dword[edi+0CDh*4],SA1COpCDm16
mov dword[edi+0CEh*4],SA1COpCEm16
mov dword[edi+0CFh*4],SA1COpCFm16
mov dword[edi+0D1h*4],SA1COpD1m16
mov dword[edi+0D2h*4],SA1COpD2m16
mov dword[edi+0D3h*4],SA1COpD3m16
mov dword[edi+0D5h*4],SA1COpD5m16
mov dword[edi+0D6h*4],SA1COpD6m16
mov dword[edi+0D7h*4],SA1COpD7m16
mov dword[edi+0D9h*4],SA1COpD9m16
mov dword[edi+0DDh*4],SA1COpDDm16
mov dword[edi+0DEh*4],SA1COpDEm16
mov dword[edi+0DFh*4],SA1COpDFm16
mov dword[edi+0E1h*4],SA1COpE1m16nd
mov dword[edi+0E3h*4],SA1COpE3m16nd
mov dword[edi+0E5h*4],SA1COpE5m16nd
mov dword[edi+0E6h*4],SA1COpE6m16
mov dword[edi+0E7h*4],SA1COpE7m16nd
mov dword[edi+0E9h*4],SA1COpE9m16nd
mov dword[edi+0EDh*4],SA1COpEDm16nd
mov dword[edi+0EEh*4],SA1COpEEm16
mov dword[edi+0EFh*4],SA1COpEFm16nd
mov dword[edi+0F1h*4],SA1COpF1m16nd
mov dword[edi+0F2h*4],SA1COpF2m16nd
mov dword[edi+0F3h*4],SA1COpF3m16nd
mov dword[edi+0F5h*4],SA1COpF5m16nd
mov dword[edi+0F6h*4],SA1COpF6m16
mov dword[edi+0F7h*4],SA1COpF7m16nd
mov dword[edi+0F9h*4],SA1COpF9m16nd
mov dword[edi+0FDh*4],SA1COpFDm16nd
mov dword[edi+0FEh*4],SA1COpFEm16
mov dword[edi+0FFh*4],SA1COpFFm16nd
ret
NEWSYM SA1settablex16
mov dword[edi+5Ah*4],SA1COp5Ax16
mov dword[edi+7Ah*4],SA1COp7Ax16
mov dword[edi+84h*4],SA1COp84x16
mov dword[edi+86h*4],SA1COp86x16
mov dword[edi+88h*4],SA1COp88x16
mov dword[edi+8Ch*4],SA1COp8Cx16
mov dword[edi+8Eh*4],SA1COp8Ex16
mov dword[edi+94h*4],SA1COp94x16
mov dword[edi+96h*4],SA1COp96x16
mov dword[edi+9Bh*4],SA1COp9Bx16
mov dword[edi+0A0h*4],SA1COpA0x16
mov dword[edi+0A2h*4],SA1COpA2x16
mov dword[edi+0A4h*4],SA1COpA4x16
mov dword[edi+0A6h*4],SA1COpA6x16
mov dword[edi+0A8h*4],SA1COpA8x16
mov dword[edi+0AAh*4],SA1COpAAx16
mov dword[edi+0ACh*4],SA1COpACx16
mov dword[edi+0AEh*4],SA1COpAEx16
mov dword[edi+0B4h*4],SA1COpB4x16
mov dword[edi+0B6h*4],SA1COpB6x16
mov dword[edi+0BAh*4],SA1COpBAx16
mov dword[edi+0BBh*4],SA1COpBBx16
mov dword[edi+0BCh*4],SA1COpBCx16
mov dword[edi+0BEh*4],SA1COpBEx16
mov dword[edi+0C0h*4],SA1COpC0x16
mov dword[edi+0C4h*4],SA1COpC4x16
mov dword[edi+0C8h*4],SA1COpC8x16
mov dword[edi+0CAh*4],SA1COpCAx16
mov dword[edi+0CCh*4],SA1COpCCx16
mov dword[edi+0DAh*4],SA1COpDAx16
mov dword[edi+0E0h*4],SA1COpE0x16
mov dword[edi+0E4h*4],SA1COpE4x16
mov dword[edi+0E8h*4],SA1COpE8x16
mov dword[edi+0ECh*4],SA1COpECx16
mov dword[edi+0FAh*4],SA1COpFAx16
ret
NEWSYM SA1settableDm8
mov dword[edi+61h*4],SA1COp61m8d
mov dword[edi+63h*4],SA1COp63m8d
mov dword[edi+65h*4],SA1COp65m8d
mov dword[edi+67h*4],SA1COp67m8d
mov dword[edi+69h*4],SA1COp69m8d
mov dword[edi+6Dh*4],SA1COp6Dm8d
mov dword[edi+6Fh*4],SA1COp6Fm8d
mov dword[edi+71h*4],SA1COp71m8d
mov dword[edi+72h*4],SA1COp72m8d
mov dword[edi+73h*4],SA1COp73m8d
mov dword[edi+75h*4],SA1COp75m8d
mov dword[edi+77h*4],SA1COp77m8d
mov dword[edi+79h*4],SA1COp79m8d
mov dword[edi+7Dh*4],SA1COp7Dm8d
mov dword[edi+7Fh*4],SA1COp7Fm8d
mov dword[edi+0E1h*4],SA1COpE1m8d
mov dword[edi+0E3h*4],SA1COpE3m8d
mov dword[edi+0E5h*4],SA1COpE5m8d
mov dword[edi+0E7h*4],SA1COpE7m8d
mov dword[edi+0E9h*4],SA1COpE9m8d
mov dword[edi+0EDh*4],SA1COpEDm8d
mov dword[edi+0EFh*4],SA1COpEFm8d
mov dword[edi+0F1h*4],SA1COpF1m8d
mov dword[edi+0F2h*4],SA1COpF2m8d
mov dword[edi+0F3h*4],SA1COpF3m8d
mov dword[edi+0F5h*4],SA1COpF5m8d
mov dword[edi+0F7h*4],SA1COpF7m8d
mov dword[edi+0F9h*4],SA1COpF9m8d
mov dword[edi+0FDh*4],SA1COpFDm8d
mov dword[edi+0FFh*4],SA1COpFFm8d
ret
NEWSYM SA1settableDm16
mov dword[edi+61h*4],SA1COp61m16d
mov dword[edi+63h*4],SA1COp63m16d
mov dword[edi+65h*4],SA1COp65m16d
mov dword[edi+67h*4],SA1COp67m16d
mov dword[edi+69h*4],SA1COp69m16d
mov dword[edi+6Dh*4],SA1COp6Dm16d
mov dword[edi+6Fh*4],SA1COp6Fm16d
mov dword[edi+71h*4],SA1COp71m16d
mov dword[edi+72h*4],SA1COp72m16d
mov dword[edi+73h*4],SA1COp73m16d
mov dword[edi+75h*4],SA1COp75m16d
mov dword[edi+77h*4],SA1COp77m16d
mov dword[edi+79h*4],SA1COp79m16d
mov dword[edi+7Dh*4],SA1COp7Dm16d
mov dword[edi+7Fh*4],SA1COp7Fm16d
mov dword[edi+0E1h*4],SA1COpE1m16d
mov dword[edi+0E3h*4],SA1COpE3m16d
mov dword[edi+0E5h*4],SA1COpE5m16d
mov dword[edi+0E7h*4],SA1COpE7m16d
mov dword[edi+0E9h*4],SA1COpE9m16d
mov dword[edi+0EDh*4],SA1COpEDm16d
mov dword[edi+0EFh*4],SA1COpEFm16d
mov dword[edi+0F1h*4],SA1COpF1m16d
mov dword[edi+0F2h*4],SA1COpF2m16d
mov dword[edi+0F3h*4],SA1COpF3m16d
mov dword[edi+0F5h*4],SA1COpF5m16d
mov dword[edi+0F7h*4],SA1COpF7m16d
mov dword[edi+0F9h*4],SA1COpF9m16d
mov dword[edi+0FDh*4],SA1COpFDm16d
mov dword[edi+0FFh*4],SA1COpFFm16d
ret


1191
zsnes/src/cpu/table.asm Normal file

File diff suppressed because it is too large Load Diff

723
zsnes/src/cpu/tableb.asm Normal file
View File

@@ -0,0 +1,723 @@
;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 eramaccessbankr16,eramaccessbankr8,eramaccessbankw16
EXTSYM eramaccessbankw8,memaccessbankr16,memaccessbankr8
EXTSYM memaccessbankw16,memaccessbankw8
EXTSYM mosjmptab,mosdraw10,mosdraw11,mosdraw12,mosdraw13
EXTSYM mosdraw14,mosdraw15,mosdraw16,mosdraw2,mosdraw3
EXTSYM mosdraw4,mosdraw5,mosdraw6,mosdraw7,mosdraw8
EXTSYM mosdraw9,ngpalcon2b,ngpalcon4b
EXTSYM regaccessbankr16,regaccessbankw16,regaccessbankw8
EXTSYM sramaccessbankr16,sramaccessbankr8,sramaccessbankw16
EXTSYM sramaccessbankw8,tableAb,tableBb,tableCb,tableDb,tableEb
EXTSYM tableFb,tableGb,tableHb,wramaccessbankr16
EXTSYM wramaccessbankr8,wramaccessbankw16,wramaccessbankw8,tableadb
%include "cpu/65816db.inc"
%include "cpu/address.inc"
%include "cpu/addrni.inc"
%include "cpu/e65816b.inc"
; global variables
;*******************************************************
; Generate OpCode Table
;*******************************************************
NEWSYM inittableb
; set tablead (NVMXDIZC) ( MXD )
push es
xor ecx,ecx
xor al,al
mov cx,256
mov edi,tableadb
.loopa
test al,08h ; D flag
jnz .decon
test al,10h ; X flag
jnz .xon
test al,20h ; M flag
jnz .mon
mov esi,tableAb
jmp .done
.mon
mov esi,tableBb
jmp .done
.xon
test al,20h ; M flag
jnz .mon2
mov esi,tableCb
jmp .done
.mon2
mov esi,tableDb
jmp .done
.decon
test al,10h ; X flag
jnz .xon3
test al,20h ; M flag
jnz .mon3
mov esi,tableEb
jmp .done
.mon3
mov esi,tableFb
jmp .done
.xon3
test al,20h
jnz .mon4
mov esi,tableGb
jmp .done
.mon4
mov esi,tableHb
.done
inc al
push eax
mov eax,esi
stosd
pop eax
loop .loopa
; Set CPU addresses
; First, set all addresses to invalid
mov eax,eopINVALID
mov edi,tableAb
mov ecx,256
rep stosd
mov edi,tableBb
mov ecx,256
rep stosd
mov edi,tableCb
mov ecx,256
rep stosd
mov edi,tableDb
mov ecx,256
rep stosd
mov edi,tableEb
mov ecx,256
rep stosd
mov edi,tableFb
mov ecx,256
rep stosd
mov edi,tableGb
mov ecx,256
rep stosd
mov edi,tableHb
mov ecx,256
rep stosd
mov edi,tableAb
call settables
mov edi,tableBb
call settables
mov edi,tableCb
call settables
mov edi,tableDb
call settables
mov edi,tableEb
call settables
mov edi,tableFb
call settables
mov edi,tableGb
call settables
mov edi,tableHb
call settables
; set proper functions
mov edi,tableAb ; Table addresses (M:0,X:0,D:0)
call settablem16
mov edi,tableAb
call settablex16
mov edi,tableBb ; Table addresses (M:1,X:0,D:0)
call settablex16
mov edi,tableCb ; Table addresses (M:0,X:1,D:0)
call settablem16
mov edi,tableEb ; Table addresses (M:0,X:0,D:1)
call settablem16
mov edi,tableEb
call settableDm16
mov edi,tableEb
call settablex16
mov edi,tableFb ; Table addresses (M:1,X:0,D:1)
call settablex16
mov edi,tableFb
call settableDm8
mov edi,tableGb ; Table addresses (M:0,X:1,D:1)
call settablem16
mov edi,tableGb
call settableDm16
mov edi,tableHb ; Table addresses (M:1,X:1,D:1)
call settableDm8
pop es
ret
eopINVALID
ret
;*******************************************************
; Set Tables Sets the opcode tables according to EDI
;*******************************************************
; This function sets all the non-multiple entries
settables:
;row 0
mov dword[edi+00h*4],COp00
mov dword[edi+01h*4],COp01m8
mov dword[edi+02h*4],COp02
mov dword[edi+03h*4],COp03m8
mov dword[edi+04h*4],COp04m8
mov dword[edi+05h*4],COp05m8
mov dword[edi+06h*4],COp06m8
mov dword[edi+07h*4],COp07m8
mov dword[edi+08h*4],COp08
mov dword[edi+09h*4],COp09m8
mov dword[edi+0Ah*4],COp0Am8
mov dword[edi+0Bh*4],COp0B
mov dword[edi+0Ch*4],COp0Cm8
mov dword[edi+0Dh*4],COp0Dm8
mov dword[edi+0Eh*4],COp0Em8
mov dword[edi+0Fh*4],COp0Fm8
mov dword[edi+10h*4],COp10
mov dword[edi+11h*4],COp11m8
mov dword[edi+12h*4],COp12m8
mov dword[edi+13h*4],COp13m8
mov dword[edi+14h*4],COp14m8
mov dword[edi+15h*4],COp15m8
mov dword[edi+16h*4],COp16m8
mov dword[edi+17h*4],COp17m8
mov dword[edi+18h*4],COp18
mov dword[edi+19h*4],COp19m8
mov dword[edi+1Ah*4],COp1Am8
mov dword[edi+1Bh*4],COp1B
mov dword[edi+1Ch*4],COp1Cm8
mov dword[edi+1Dh*4],COp1Dm8
mov dword[edi+1Eh*4],COp1Em8
mov dword[edi+1Fh*4],COp1Fm8
mov dword[edi+20h*4],COp20
mov dword[edi+21h*4],COp21m8
mov dword[edi+22h*4],COp22
mov dword[edi+23h*4],COp23m8
mov dword[edi+24h*4],COp24m8
mov dword[edi+25h*4],COp25m8
mov dword[edi+26h*4],COp26m8
mov dword[edi+27h*4],COp27m8
mov dword[edi+28h*4],COp28
mov dword[edi+29h*4],COp29m8
mov dword[edi+2Ah*4],COp2Am8
mov dword[edi+2Bh*4],COp2B
mov dword[edi+2Ch*4],COp2Cm8
mov dword[edi+2Dh*4],COp2Dm8
mov dword[edi+2Eh*4],COp2Em8
mov dword[edi+2Fh*4],COp2Fm8
mov dword[edi+30h*4],COp30
mov dword[edi+31h*4],COp31m8
mov dword[edi+32h*4],COp32m8
mov dword[edi+33h*4],COp33m8
mov dword[edi+34h*4],COp34m8
mov dword[edi+35h*4],COp35m8
mov dword[edi+36h*4],COp36m8
mov dword[edi+37h*4],COp37m8
mov dword[edi+38h*4],COp38
mov dword[edi+39h*4],COp39m8
mov dword[edi+3Ah*4],COp3Am8
mov dword[edi+3Bh*4],COp3B
mov dword[edi+3Ch*4],COp3Cm8
mov dword[edi+3Dh*4],COp3Dm8
mov dword[edi+3Eh*4],COp3Em8
mov dword[edi+3Fh*4],COp3Fm8
mov dword[edi+40h*4],COp40
mov dword[edi+41h*4],COp41m8
mov dword[edi+42h*4],COp42
mov dword[edi+43h*4],COp43m8
mov dword[edi+44h*4],COp44
mov dword[edi+45h*4],COp45m8
mov dword[edi+46h*4],COp46m8
mov dword[edi+47h*4],COp47m8
mov dword[edi+48h*4],COp48m8
mov dword[edi+49h*4],COp49m8
mov dword[edi+4Ah*4],COp4Am8
mov dword[edi+4Bh*4],COp4B
mov dword[edi+4Ch*4],COp4C
mov dword[edi+4Dh*4],COp4Dm8
mov dword[edi+4Eh*4],COp4Em8
mov dword[edi+4Fh*4],COp4Fm8
mov dword[edi+50h*4],COp50
mov dword[edi+51h*4],COp51m8
mov dword[edi+52h*4],COp52m8
mov dword[edi+53h*4],COp53m8
mov dword[edi+54h*4],COp54
mov dword[edi+55h*4],COp55m8
mov dword[edi+56h*4],COp56m8
mov dword[edi+57h*4],COp57m8
mov dword[edi+58h*4],COp58
mov dword[edi+59h*4],COp59m8
mov dword[edi+5Ah*4],COp5Ax8
mov dword[edi+5Bh*4],COp5B
mov dword[edi+5Ch*4],COp5C
mov dword[edi+5Dh*4],COp5Dm8
mov dword[edi+5Eh*4],COp5Em8
mov dword[edi+5Fh*4],COp5Fm8
mov dword[edi+60h*4],COp60
mov dword[edi+61h*4],COp61m8nd
mov dword[edi+62h*4],COp62
mov dword[edi+63h*4],COp63m8nd
mov dword[edi+64h*4],COp64m8
mov dword[edi+65h*4],COp65m8nd
mov dword[edi+66h*4],COp66m8
mov dword[edi+67h*4],COp67m8nd
mov dword[edi+68h*4],COp68m8
mov dword[edi+69h*4],COp69m8nd
mov dword[edi+6Ah*4],COp6Am8
mov dword[edi+6Bh*4],COp6B
mov dword[edi+6Ch*4],COp6C
mov dword[edi+6Dh*4],COp6Dm8nd
mov dword[edi+6Eh*4],COp6Em8
mov dword[edi+6Fh*4],COp6Fm8nd
mov dword[edi+70h*4],COp70
mov dword[edi+71h*4],COp71m8nd
mov dword[edi+72h*4],COp72m8nd
mov dword[edi+73h*4],COp73m8nd
mov dword[edi+74h*4],COp74m8
mov dword[edi+75h*4],COp75m8nd
mov dword[edi+76h*4],COp76m8
mov dword[edi+77h*4],COp77m8nd
mov dword[edi+78h*4],COp78
mov dword[edi+79h*4],COp79m8nd
mov dword[edi+7Ah*4],COp7Ax8
mov dword[edi+7Bh*4],COp7B
mov dword[edi+7Ch*4],COp7C
mov dword[edi+7Dh*4],COp7Dm8nd
mov dword[edi+7Eh*4],COp7Em8
mov dword[edi+7Fh*4],COp7Fm8nd
mov dword[edi+80h*4],COp80
mov dword[edi+81h*4],COp81m8
mov dword[edi+82h*4],COp82
mov dword[edi+83h*4],COp83m8
mov dword[edi+84h*4],COp84x8
mov dword[edi+85h*4],COp85m8
mov dword[edi+86h*4],COp86x8
mov dword[edi+87h*4],COp87m8
mov dword[edi+88h*4],COp88x8
mov dword[edi+89h*4],COp89m8
mov dword[edi+8Ah*4],COp8Am8
mov dword[edi+8Bh*4],COp8B
mov dword[edi+8Ch*4],COp8Cx8
mov dword[edi+8Dh*4],COp8Dm8
mov dword[edi+8Eh*4],COp8Ex8
mov dword[edi+8Fh*4],COp8Fm8
mov dword[edi+90h*4],COp90
mov dword[edi+91h*4],COp91m8
mov dword[edi+92h*4],COp92m8
mov dword[edi+93h*4],COp93m8
mov dword[edi+94h*4],COp94x8
mov dword[edi+95h*4],COp95m8
mov dword[edi+96h*4],COp96x8
mov dword[edi+97h*4],COp97m8
mov dword[edi+98h*4],COp98m8
mov dword[edi+99h*4],COp99m8
mov dword[edi+9Ah*4],COp9A
mov dword[edi+9Bh*4],COp9Bx8
mov dword[edi+9Ch*4],COp9Cm8
mov dword[edi+9Dh*4],COp9Dm8
mov dword[edi+9Eh*4],COp9Em8
mov dword[edi+9Fh*4],COp9Fm8
mov dword[edi+0A0h*4],COpA0x8
mov dword[edi+0A1h*4],COpA1m8
mov dword[edi+0A2h*4],COpA2x8
mov dword[edi+0A3h*4],COpA3m8
mov dword[edi+0A4h*4],COpA4x8
mov dword[edi+0A5h*4],COpA5m8
mov dword[edi+0A6h*4],COpA6x8
mov dword[edi+0A7h*4],COpA7m8
mov dword[edi+0A8h*4],COpA8x8
mov dword[edi+0A9h*4],COpA9m8
mov dword[edi+0AAh*4],COpAAx8
mov dword[edi+0ABh*4],COpAB
mov dword[edi+0ACh*4],COpACx8
mov dword[edi+0ADh*4],COpADm8
mov dword[edi+0AEh*4],COpAEx8
mov dword[edi+0AFh*4],COpAFm8
mov dword[edi+0B0h*4],COpB0
mov dword[edi+0B1h*4],COpB1m8
mov dword[edi+0B2h*4],COpB2m8
mov dword[edi+0B3h*4],COpB3m8
mov dword[edi+0B4h*4],COpB4x8
mov dword[edi+0B5h*4],COpB5m8
mov dword[edi+0B6h*4],COpB6x8
mov dword[edi+0B7h*4],COpB7m8
mov dword[edi+0B8h*4],COpB8
mov dword[edi+0B9h*4],COpB9m8
mov dword[edi+0BAh*4],COpBAx8
mov dword[edi+0BBh*4],COpBBx8
mov dword[edi+0BCh*4],COpBCx8
mov dword[edi+0BDh*4],COpBDm8
mov dword[edi+0BEh*4],COpBEx8
mov dword[edi+0BFh*4],COpBFm8
mov dword[edi+0C0h*4],COpC0x8
mov dword[edi+0C1h*4],COpC1m8
mov dword[edi+0C2h*4],COpC2
mov dword[edi+0C3h*4],COpC3m8
mov dword[edi+0C4h*4],COpC4x8
mov dword[edi+0C5h*4],COpC5m8
mov dword[edi+0C6h*4],COpC6m8
mov dword[edi+0C7h*4],COpC7m8
mov dword[edi+0C8h*4],COpC8x8
mov dword[edi+0C9h*4],COpC9m8
mov dword[edi+0CAh*4],COpCAx8
mov dword[edi+0CBh*4],COpCB
mov dword[edi+0CCh*4],COpCCx8
mov dword[edi+0CDh*4],COpCDm8
mov dword[edi+0CEh*4],COpCEm8
mov dword[edi+0CFh*4],COpCFm8
mov dword[edi+0D0h*4],COpD0
mov dword[edi+0D1h*4],COpD1m8
mov dword[edi+0D2h*4],COpD2m8
mov dword[edi+0D3h*4],COpD3m8
mov dword[edi+0D4h*4],COpD4
mov dword[edi+0D5h*4],COpD5m8
mov dword[edi+0D6h*4],COpD6m8
mov dword[edi+0D7h*4],COpD7m8
mov dword[edi+0D8h*4],COpD8
mov dword[edi+0D9h*4],COpD9m8
mov dword[edi+0DAh*4],COpDAx8
mov dword[edi+0DBh*4],COpDB
mov dword[edi+0DCh*4],COpDC
mov dword[edi+0DDh*4],COpDDm8
mov dword[edi+0DEh*4],COpDEm8
mov dword[edi+0DFh*4],COpDFm8
mov dword[edi+0E0h*4],COpE0x8
mov dword[edi+0E1h*4],COpE1m8nd
mov dword[edi+0E2h*4],COpE2
mov dword[edi+0E3h*4],COpE3m8nd
mov dword[edi+0E4h*4],COpE4x8
mov dword[edi+0E5h*4],COpE5m8nd
mov dword[edi+0E6h*4],COpE6m8
mov dword[edi+0E7h*4],COpE7m8nd
mov dword[edi+0E8h*4],COpE8x8
mov dword[edi+0E9h*4],COpE9m8nd
mov dword[edi+0EAh*4],COpEA
mov dword[edi+0EBh*4],COpEB
mov dword[edi+0ECh*4],COpECx8
mov dword[edi+0EDh*4],COpEDm8nd
mov dword[edi+0EEh*4],COpEEm8
mov dword[edi+0EFh*4],COpEFm8nd
mov dword[edi+0F0h*4],COpF0
mov dword[edi+0F1h*4],COpF1m8nd
mov dword[edi+0F2h*4],COpF2m8nd
mov dword[edi+0F3h*4],COpF3m8nd
mov dword[edi+0F4h*4],COpF4
mov dword[edi+0F5h*4],COpF5m8nd
mov dword[edi+0F6h*4],COpF6m8
mov dword[edi+0F7h*4],COpF7m8nd
mov dword[edi+0F8h*4],COpF8
mov dword[edi+0F9h*4],COpF9m8nd
mov dword[edi+0FAh*4],COpFAx8
mov dword[edi+0FBh*4],COpFB
mov dword[edi+0FCh*4],COpFC
mov dword[edi+0FDh*4],COpFDm8nd
mov dword[edi+0FEh*4],COpFEm8
mov dword[edi+0FFh*4],COpFFm8nd
ret
settablem16:
mov dword[edi+01h*4],COp01m16
mov dword[edi+03h*4],COp03m16
mov dword[edi+04h*4],COp04m16
mov dword[edi+05h*4],COp05m16
mov dword[edi+06h*4],COp06m16
mov dword[edi+07h*4],COp07m16
mov dword[edi+09h*4],COp09m16
mov dword[edi+0Ah*4],COp0Am16
mov dword[edi+0Ch*4],COp0Cm16
mov dword[edi+0Dh*4],COp0Dm16
mov dword[edi+0Eh*4],COp0Em16
mov dword[edi+0Fh*4],COp0Fm16
mov dword[edi+11h*4],COp11m16
mov dword[edi+12h*4],COp12m16
mov dword[edi+13h*4],COp13m16
mov dword[edi+14h*4],COp14m16
mov dword[edi+15h*4],COp15m16
mov dword[edi+16h*4],COp16m16
mov dword[edi+17h*4],COp17m16
mov dword[edi+19h*4],COp19m16
mov dword[edi+1Ah*4],COp1Am16
mov dword[edi+1Ch*4],COp1Cm16
mov dword[edi+1Dh*4],COp1Dm16
mov dword[edi+1Eh*4],COp1Em16
mov dword[edi+1Fh*4],COp1Fm16
mov dword[edi+21h*4],COp21m16
mov dword[edi+23h*4],COp23m16
mov dword[edi+24h*4],COp24m16
mov dword[edi+25h*4],COp25m16
mov dword[edi+26h*4],COp26m16
mov dword[edi+27h*4],COp27m16
mov dword[edi+29h*4],COp29m16
mov dword[edi+2Ah*4],COp2Am16
mov dword[edi+2Ch*4],COp2Cm16
mov dword[edi+2Dh*4],COp2Dm16
mov dword[edi+2Eh*4],COp2Em16
mov dword[edi+2Fh*4],COp2Fm16
mov dword[edi+31h*4],COp31m16
mov dword[edi+32h*4],COp32m16
mov dword[edi+33h*4],COp33m16
mov dword[edi+34h*4],COp34m16
mov dword[edi+35h*4],COp35m16
mov dword[edi+36h*4],COp36m16
mov dword[edi+37h*4],COp37m16
mov dword[edi+39h*4],COp39m16
mov dword[edi+3Ah*4],COp3Am16
mov dword[edi+3Ch*4],COp3Cm16
mov dword[edi+3Dh*4],COp3Dm16
mov dword[edi+3Eh*4],COp3Em16
mov dword[edi+3Fh*4],COp3Fm16
mov dword[edi+41h*4],COp41m16
mov dword[edi+43h*4],COp43m16
mov dword[edi+45h*4],COp45m16
mov dword[edi+46h*4],COp46m16
mov dword[edi+47h*4],COp47m16
mov dword[edi+48h*4],COp48m16
mov dword[edi+49h*4],COp49m16
mov dword[edi+4Ah*4],COp4Am16
mov dword[edi+4Dh*4],COp4Dm16
mov dword[edi+4Eh*4],COp4Em16
mov dword[edi+4Fh*4],COp4Fm16
mov dword[edi+51h*4],COp51m16
mov dword[edi+52h*4],COp52m16
mov dword[edi+53h*4],COp53m16
mov dword[edi+55h*4],COp55m16
mov dword[edi+56h*4],COp56m16
mov dword[edi+57h*4],COp57m16
mov dword[edi+59h*4],COp59m16
mov dword[edi+5Dh*4],COp5Dm16
mov dword[edi+5Eh*4],COp5Em16
mov dword[edi+5Fh*4],COp5Fm16
mov dword[edi+61h*4],COp61m16nd
mov dword[edi+63h*4],COp63m16nd
mov dword[edi+64h*4],COp64m16
mov dword[edi+65h*4],COp65m16nd
mov dword[edi+66h*4],COp66m16
mov dword[edi+67h*4],COp67m16nd
mov dword[edi+68h*4],COp68m16
mov dword[edi+69h*4],COp69m16nd
mov dword[edi+6Ah*4],COp6Am16
mov dword[edi+6Dh*4],COp6Dm16nd
mov dword[edi+6Eh*4],COp6Em16
mov dword[edi+6Fh*4],COp6Fm16nd
mov dword[edi+71h*4],COp71m16nd
mov dword[edi+72h*4],COp72m16nd
mov dword[edi+73h*4],COp73m16nd
mov dword[edi+74h*4],COp74m16
mov dword[edi+75h*4],COp75m16nd
mov dword[edi+76h*4],COp76m16
mov dword[edi+77h*4],COp77m16nd
mov dword[edi+79h*4],COp79m16nd
mov dword[edi+7Dh*4],COp7Dm16nd
mov dword[edi+7Eh*4],COp7Em16
mov dword[edi+7Fh*4],COp7Fm16nd
mov dword[edi+81h*4],COp81m16
mov dword[edi+83h*4],COp83m16
mov dword[edi+85h*4],COp85m16
mov dword[edi+87h*4],COp87m16
mov dword[edi+89h*4],COp89m16
mov dword[edi+8Ah*4],COp8Am16
mov dword[edi+8Dh*4],COp8Dm16
mov dword[edi+8Fh*4],COp8Fm16
mov dword[edi+91h*4],COp91m16
mov dword[edi+92h*4],COp92m16
mov dword[edi+93h*4],COp93m16
mov dword[edi+95h*4],COp95m16
mov dword[edi+97h*4],COp97m16
mov dword[edi+98h*4],COp98m16
mov dword[edi+99h*4],COp99m16
mov dword[edi+9Ch*4],COp9Cm16
mov dword[edi+9Dh*4],COp9Dm16
mov dword[edi+9Eh*4],COp9Em16
mov dword[edi+9Fh*4],COp9Fm16
mov dword[edi+0A1h*4],COpA1m16
mov dword[edi+0A3h*4],COpA3m16
mov dword[edi+0A5h*4],COpA5m16
mov dword[edi+0A7h*4],COpA7m16
mov dword[edi+0A9h*4],COpA9m16
mov dword[edi+0ADh*4],COpADm16
mov dword[edi+0AFh*4],COpAFm16
mov dword[edi+0B1h*4],COpB1m16
mov dword[edi+0B2h*4],COpB2m16
mov dword[edi+0B3h*4],COpB3m16
mov dword[edi+0B5h*4],COpB5m16
mov dword[edi+0B7h*4],COpB7m16
mov dword[edi+0B9h*4],COpB9m16
mov dword[edi+0BDh*4],COpBDm16
mov dword[edi+0BFh*4],COpBFm16
mov dword[edi+0C1h*4],COpC1m16
mov dword[edi+0C3h*4],COpC3m16
mov dword[edi+0C5h*4],COpC5m16
mov dword[edi+0C6h*4],COpC6m16
mov dword[edi+0C7h*4],COpC7m16
mov dword[edi+0C9h*4],COpC9m16
mov dword[edi+0CDh*4],COpCDm16
mov dword[edi+0CEh*4],COpCEm16
mov dword[edi+0CFh*4],COpCFm16
mov dword[edi+0D1h*4],COpD1m16
mov dword[edi+0D2h*4],COpD2m16
mov dword[edi+0D3h*4],COpD3m16
mov dword[edi+0D5h*4],COpD5m16
mov dword[edi+0D6h*4],COpD6m16
mov dword[edi+0D7h*4],COpD7m16
mov dword[edi+0D9h*4],COpD9m16
mov dword[edi+0DDh*4],COpDDm16
mov dword[edi+0DEh*4],COpDEm16
mov dword[edi+0DFh*4],COpDFm16
mov dword[edi+0E1h*4],COpE1m16nd
mov dword[edi+0E3h*4],COpE3m16nd
mov dword[edi+0E5h*4],COpE5m16nd
mov dword[edi+0E6h*4],COpE6m16
mov dword[edi+0E7h*4],COpE7m16nd
mov dword[edi+0E9h*4],COpE9m16nd
mov dword[edi+0EDh*4],COpEDm16nd
mov dword[edi+0EEh*4],COpEEm16
mov dword[edi+0EFh*4],COpEFm16nd
mov dword[edi+0F1h*4],COpF1m16nd
mov dword[edi+0F2h*4],COpF2m16nd
mov dword[edi+0F3h*4],COpF3m16nd
mov dword[edi+0F5h*4],COpF5m16nd
mov dword[edi+0F6h*4],COpF6m16
mov dword[edi+0F7h*4],COpF7m16nd
mov dword[edi+0F9h*4],COpF9m16nd
mov dword[edi+0FDh*4],COpFDm16nd
mov dword[edi+0FEh*4],COpFEm16
mov dword[edi+0FFh*4],COpFFm16nd
ret
settablex16:
mov dword[edi+5Ah*4],COp5Ax16
mov dword[edi+7Ah*4],COp7Ax16
mov dword[edi+84h*4],COp84x16
mov dword[edi+86h*4],COp86x16
mov dword[edi+88h*4],COp88x16
mov dword[edi+8Ch*4],COp8Cx16
mov dword[edi+8Eh*4],COp8Ex16
mov dword[edi+94h*4],COp94x16
mov dword[edi+96h*4],COp96x16
mov dword[edi+9Bh*4],COp9Bx16
mov dword[edi+0A0h*4],COpA0x16
mov dword[edi+0A2h*4],COpA2x16
mov dword[edi+0A4h*4],COpA4x16
mov dword[edi+0A6h*4],COpA6x16
mov dword[edi+0A8h*4],COpA8x16
mov dword[edi+0AAh*4],COpAAx16
mov dword[edi+0ACh*4],COpACx16
mov dword[edi+0AEh*4],COpAEx16
mov dword[edi+0B4h*4],COpB4x16
mov dword[edi+0B6h*4],COpB6x16
mov dword[edi+0BAh*4],COpBAx16
mov dword[edi+0BBh*4],COpBBx16
mov dword[edi+0BCh*4],COpBCx16
mov dword[edi+0BEh*4],COpBEx16
mov dword[edi+0C0h*4],COpC0x16
mov dword[edi+0C4h*4],COpC4x16
mov dword[edi+0C8h*4],COpC8x16
mov dword[edi+0CAh*4],COpCAx16
mov dword[edi+0CCh*4],COpCCx16
mov dword[edi+0DAh*4],COpDAx16
mov dword[edi+0E0h*4],COpE0x16
mov dword[edi+0E4h*4],COpE4x16
mov dword[edi+0E8h*4],COpE8x16
mov dword[edi+0ECh*4],COpECx16
mov dword[edi+0FAh*4],COpFAx16
ret
settableDm8:
mov dword[edi+61h*4],COp61m8d
mov dword[edi+63h*4],COp63m8d
mov dword[edi+65h*4],COp65m8d
mov dword[edi+67h*4],COp67m8d
mov dword[edi+69h*4],COp69m8d
mov dword[edi+6Dh*4],COp6Dm8d
mov dword[edi+6Fh*4],COp6Fm8d
mov dword[edi+71h*4],COp71m8d
mov dword[edi+72h*4],COp72m8d
mov dword[edi+73h*4],COp73m8d
mov dword[edi+75h*4],COp75m8d
mov dword[edi+77h*4],COp77m8d
mov dword[edi+79h*4],COp79m8d
mov dword[edi+7Dh*4],COp7Dm8d
mov dword[edi+7Fh*4],COp7Fm8d
mov dword[edi+0E1h*4],COpE1m8d
mov dword[edi+0E3h*4],COpE3m8d
mov dword[edi+0E5h*4],COpE5m8d
mov dword[edi+0E7h*4],COpE7m8d
mov dword[edi+0E9h*4],COpE9m8d
mov dword[edi+0EDh*4],COpEDm8d
mov dword[edi+0EFh*4],COpEFm8d
mov dword[edi+0F1h*4],COpF1m8d
mov dword[edi+0F2h*4],COpF2m8d
mov dword[edi+0F3h*4],COpF3m8d
mov dword[edi+0F5h*4],COpF5m8d
mov dword[edi+0F7h*4],COpF7m8d
mov dword[edi+0F9h*4],COpF9m8d
mov dword[edi+0FDh*4],COpFDm8d
mov dword[edi+0FFh*4],COpFFm8d
ret
settableDm16:
mov dword[edi+61h*4],COp61m16d
mov dword[edi+63h*4],COp63m16d
mov dword[edi+65h*4],COp65m16d
mov dword[edi+67h*4],COp67m16d
mov dword[edi+69h*4],COp69m16d
mov dword[edi+6Dh*4],COp6Dm16d
mov dword[edi+6Fh*4],COp6Fm16d
mov dword[edi+71h*4],COp71m16d
mov dword[edi+72h*4],COp72m16d
mov dword[edi+73h*4],COp73m16d
mov dword[edi+75h*4],COp75m16d
mov dword[edi+77h*4],COp77m16d
mov dword[edi+79h*4],COp79m16d
mov dword[edi+7Dh*4],COp7Dm16d
mov dword[edi+7Fh*4],COp7Fm16d
mov dword[edi+0E1h*4],COpE1m16d
mov dword[edi+0E3h*4],COpE3m16d
mov dword[edi+0E5h*4],COpE5m16d
mov dword[edi+0E7h*4],COpE7m16d
mov dword[edi+0E9h*4],COpE9m16d
mov dword[edi+0EDh*4],COpEDm16d
mov dword[edi+0EFh*4],COpEFm16d
mov dword[edi+0F1h*4],COpF1m16d
mov dword[edi+0F2h*4],COpF2m16d
mov dword[edi+0F3h*4],COpF3m16d
mov dword[edi+0F5h*4],COpF5m16d
mov dword[edi+0F7h*4],COpF7m16d
mov dword[edi+0F9h*4],COpF9m16d
mov dword[edi+0FDh*4],COpFDm16d
mov dword[edi+0FFh*4],COpFFm16d
ret


723
zsnes/src/cpu/tablec.asm Normal file
View File

@@ -0,0 +1,723 @@
;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 eramaccessbankr16,eramaccessbankr8,eramaccessbankw16
EXTSYM eramaccessbankw8,memaccessbankr16,memaccessbankr8
EXTSYM memaccessbankw16,memaccessbankw8
EXTSYM mosjmptab,mosdraw10,mosdraw11,mosdraw12,mosdraw13
EXTSYM mosdraw14,mosdraw15,mosdraw16,mosdraw2,mosdraw3
EXTSYM mosdraw4,mosdraw5,mosdraw6,mosdraw7,mosdraw8
EXTSYM mosdraw9,ngpalcon2b,ngpalcon4b
EXTSYM regaccessbankr16,regaccessbankw16,regaccessbankw8
EXTSYM sramaccessbankr16,sramaccessbankr8,sramaccessbankw16
EXTSYM sramaccessbankw8,tableAc,tableBc,tableCc,tableDc,tableEc
EXTSYM tableFc,tableGc,tableHc,wramaccessbankr16
EXTSYM wramaccessbankr8,wramaccessbankw16,wramaccessbankw8,tableadc
%include "cpu/65816dc.inc"
%include "cpu/address.inc"
%include "cpu/addrni.inc"
%include "cpu/e65816c.inc"
; global variables
;*******************************************************
; Generate OpCode Table
;*******************************************************
NEWSYM inittablec
; set tablead (NVMXDIZC) ( MXD )
push es
xor ecx,ecx
xor al,al
mov cx,256
mov edi,tableadc
.loopa
test al,08h ; D flag
jnz .decon
test al,10h ; X flag
jnz .xon
test al,20h ; M flag
jnz .mon
mov esi,tableAc
jmp .done
.mon
mov esi,tableBc
jmp .done
.xon
test al,20h ; M flag
jnz .mon2
mov esi,tableCc
jmp .done
.mon2
mov esi,tableDc
jmp .done
.decon
test al,10h ; X flag
jnz .xon3
test al,20h ; M flag
jnz .mon3
mov esi,tableEc
jmp .done
.mon3
mov esi,tableFc
jmp .done
.xon3
test al,20h
jnz .mon4
mov esi,tableGc
jmp .done
.mon4
mov esi,tableHc
.done
inc al
push eax
mov eax,esi
stosd
pop eax
loop .loopa
; Set CPU addresses
; First, set all addresses to invalid
mov eax,eopINVALID
mov edi,tableAc
mov ecx,256
rep stosd
mov edi,tableBc
mov ecx,256
rep stosd
mov edi,tableCc
mov ecx,256
rep stosd
mov edi,tableDc
mov ecx,256
rep stosd
mov edi,tableEc
mov ecx,256
rep stosd
mov edi,tableFc
mov ecx,256
rep stosd
mov edi,tableGc
mov ecx,256
rep stosd
mov edi,tableHc
mov ecx,256
rep stosd
mov edi,tableAc
call settables
mov edi,tableBc
call settables
mov edi,tableCc
call settables
mov edi,tableDc
call settables
mov edi,tableEc
call settables
mov edi,tableFc
call settables
mov edi,tableGc
call settables
mov edi,tableHc
call settables
; set proper functions
mov edi,tableAc ; Table addresses (M:0,X:0,D:0)
call settablem16
mov edi,tableAc
call settablex16
mov edi,tableBc ; Table addresses (M:1,X:0,D:0)
call settablex16
mov edi,tableCc ; Table addresses (M:0,X:1,D:0)
call settablem16
mov edi,tableEc ; Table addresses (M:0,X:0,D:1)
call settablem16
mov edi,tableEc
call settableDm16
mov edi,tableEc
call settablex16
mov edi,tableFc ; Table addresses (M:1,X:0,D:1)
call settablex16
mov edi,tableFc
call settableDm8
mov edi,tableGc ; Table addresses (M:0,X:1,D:1)
call settablem16
mov edi,tableGc
call settableDm16
mov edi,tableHc ; Table addresses (M:1,X:1,D:1)
call settableDm8
pop es
ret
eopINVALID
ret
;*******************************************************
; Set Tables Sets the opcode tables according to EDI
;*******************************************************
; This function sets all the non-multiple entries
settables:
;row 0
mov dword[edi+00h*4],COp00
mov dword[edi+01h*4],COp01m8
mov dword[edi+02h*4],COp02
mov dword[edi+03h*4],COp03m8
mov dword[edi+04h*4],COp04m8
mov dword[edi+05h*4],COp05m8
mov dword[edi+06h*4],COp06m8
mov dword[edi+07h*4],COp07m8
mov dword[edi+08h*4],COp08
mov dword[edi+09h*4],COp09m8
mov dword[edi+0Ah*4],COp0Am8
mov dword[edi+0Bh*4],COp0B
mov dword[edi+0Ch*4],COp0Cm8
mov dword[edi+0Dh*4],COp0Dm8
mov dword[edi+0Eh*4],COp0Em8
mov dword[edi+0Fh*4],COp0Fm8
mov dword[edi+10h*4],COp10
mov dword[edi+11h*4],COp11m8
mov dword[edi+12h*4],COp12m8
mov dword[edi+13h*4],COp13m8
mov dword[edi+14h*4],COp14m8
mov dword[edi+15h*4],COp15m8
mov dword[edi+16h*4],COp16m8
mov dword[edi+17h*4],COp17m8
mov dword[edi+18h*4],COp18
mov dword[edi+19h*4],COp19m8
mov dword[edi+1Ah*4],COp1Am8
mov dword[edi+1Bh*4],COp1B
mov dword[edi+1Ch*4],COp1Cm8
mov dword[edi+1Dh*4],COp1Dm8
mov dword[edi+1Eh*4],COp1Em8
mov dword[edi+1Fh*4],COp1Fm8
mov dword[edi+20h*4],COp20
mov dword[edi+21h*4],COp21m8
mov dword[edi+22h*4],COp22
mov dword[edi+23h*4],COp23m8
mov dword[edi+24h*4],COp24m8
mov dword[edi+25h*4],COp25m8
mov dword[edi+26h*4],COp26m8
mov dword[edi+27h*4],COp27m8
mov dword[edi+28h*4],COp28
mov dword[edi+29h*4],COp29m8
mov dword[edi+2Ah*4],COp2Am8
mov dword[edi+2Bh*4],COp2B
mov dword[edi+2Ch*4],COp2Cm8
mov dword[edi+2Dh*4],COp2Dm8
mov dword[edi+2Eh*4],COp2Em8
mov dword[edi+2Fh*4],COp2Fm8
mov dword[edi+30h*4],COp30
mov dword[edi+31h*4],COp31m8
mov dword[edi+32h*4],COp32m8
mov dword[edi+33h*4],COp33m8
mov dword[edi+34h*4],COp34m8
mov dword[edi+35h*4],COp35m8
mov dword[edi+36h*4],COp36m8
mov dword[edi+37h*4],COp37m8
mov dword[edi+38h*4],COp38
mov dword[edi+39h*4],COp39m8
mov dword[edi+3Ah*4],COp3Am8
mov dword[edi+3Bh*4],COp3B
mov dword[edi+3Ch*4],COp3Cm8
mov dword[edi+3Dh*4],COp3Dm8
mov dword[edi+3Eh*4],COp3Em8
mov dword[edi+3Fh*4],COp3Fm8
mov dword[edi+40h*4],COp40
mov dword[edi+41h*4],COp41m8
mov dword[edi+42h*4],COp42
mov dword[edi+43h*4],COp43m8
mov dword[edi+44h*4],COp44
mov dword[edi+45h*4],COp45m8
mov dword[edi+46h*4],COp46m8
mov dword[edi+47h*4],COp47m8
mov dword[edi+48h*4],COp48m8
mov dword[edi+49h*4],COp49m8
mov dword[edi+4Ah*4],COp4Am8
mov dword[edi+4Bh*4],COp4B
mov dword[edi+4Ch*4],COp4C
mov dword[edi+4Dh*4],COp4Dm8
mov dword[edi+4Eh*4],COp4Em8
mov dword[edi+4Fh*4],COp4Fm8
mov dword[edi+50h*4],COp50
mov dword[edi+51h*4],COp51m8
mov dword[edi+52h*4],COp52m8
mov dword[edi+53h*4],COp53m8
mov dword[edi+54h*4],COp54
mov dword[edi+55h*4],COp55m8
mov dword[edi+56h*4],COp56m8
mov dword[edi+57h*4],COp57m8
mov dword[edi+58h*4],COp58
mov dword[edi+59h*4],COp59m8
mov dword[edi+5Ah*4],COp5Ax8
mov dword[edi+5Bh*4],COp5B
mov dword[edi+5Ch*4],COp5C
mov dword[edi+5Dh*4],COp5Dm8
mov dword[edi+5Eh*4],COp5Em8
mov dword[edi+5Fh*4],COp5Fm8
mov dword[edi+60h*4],COp60
mov dword[edi+61h*4],COp61m8nd
mov dword[edi+62h*4],COp62
mov dword[edi+63h*4],COp63m8nd
mov dword[edi+64h*4],COp64m8
mov dword[edi+65h*4],COp65m8nd
mov dword[edi+66h*4],COp66m8
mov dword[edi+67h*4],COp67m8nd
mov dword[edi+68h*4],COp68m8
mov dword[edi+69h*4],COp69m8nd
mov dword[edi+6Ah*4],COp6Am8
mov dword[edi+6Bh*4],COp6B
mov dword[edi+6Ch*4],COp6C
mov dword[edi+6Dh*4],COp6Dm8nd
mov dword[edi+6Eh*4],COp6Em8
mov dword[edi+6Fh*4],COp6Fm8nd
mov dword[edi+70h*4],COp70
mov dword[edi+71h*4],COp71m8nd
mov dword[edi+72h*4],COp72m8nd
mov dword[edi+73h*4],COp73m8nd
mov dword[edi+74h*4],COp74m8
mov dword[edi+75h*4],COp75m8nd
mov dword[edi+76h*4],COp76m8
mov dword[edi+77h*4],COp77m8nd
mov dword[edi+78h*4],COp78
mov dword[edi+79h*4],COp79m8nd
mov dword[edi+7Ah*4],COp7Ax8
mov dword[edi+7Bh*4],COp7B
mov dword[edi+7Ch*4],COp7C
mov dword[edi+7Dh*4],COp7Dm8nd
mov dword[edi+7Eh*4],COp7Em8
mov dword[edi+7Fh*4],COp7Fm8nd
mov dword[edi+80h*4],COp80
mov dword[edi+81h*4],COp81m8
mov dword[edi+82h*4],COp82
mov dword[edi+83h*4],COp83m8
mov dword[edi+84h*4],COp84x8
mov dword[edi+85h*4],COp85m8
mov dword[edi+86h*4],COp86x8
mov dword[edi+87h*4],COp87m8
mov dword[edi+88h*4],COp88x8
mov dword[edi+89h*4],COp89m8
mov dword[edi+8Ah*4],COp8Am8
mov dword[edi+8Bh*4],COp8B
mov dword[edi+8Ch*4],COp8Cx8
mov dword[edi+8Dh*4],COp8Dm8
mov dword[edi+8Eh*4],COp8Ex8
mov dword[edi+8Fh*4],COp8Fm8
mov dword[edi+90h*4],COp90
mov dword[edi+91h*4],COp91m8
mov dword[edi+92h*4],COp92m8
mov dword[edi+93h*4],COp93m8
mov dword[edi+94h*4],COp94x8
mov dword[edi+95h*4],COp95m8
mov dword[edi+96h*4],COp96x8
mov dword[edi+97h*4],COp97m8
mov dword[edi+98h*4],COp98m8
mov dword[edi+99h*4],COp99m8
mov dword[edi+9Ah*4],COp9A
mov dword[edi+9Bh*4],COp9Bx8
mov dword[edi+9Ch*4],COp9Cm8
mov dword[edi+9Dh*4],COp9Dm8
mov dword[edi+9Eh*4],COp9Em8
mov dword[edi+9Fh*4],COp9Fm8
mov dword[edi+0A0h*4],COpA0x8
mov dword[edi+0A1h*4],COpA1m8
mov dword[edi+0A2h*4],COpA2x8
mov dword[edi+0A3h*4],COpA3m8
mov dword[edi+0A4h*4],COpA4x8
mov dword[edi+0A5h*4],COpA5m8
mov dword[edi+0A6h*4],COpA6x8
mov dword[edi+0A7h*4],COpA7m8
mov dword[edi+0A8h*4],COpA8x8
mov dword[edi+0A9h*4],COpA9m8
mov dword[edi+0AAh*4],COpAAx8
mov dword[edi+0ABh*4],COpAB
mov dword[edi+0ACh*4],COpACx8
mov dword[edi+0ADh*4],COpADm8
mov dword[edi+0AEh*4],COpAEx8
mov dword[edi+0AFh*4],COpAFm8
mov dword[edi+0B0h*4],COpB0
mov dword[edi+0B1h*4],COpB1m8
mov dword[edi+0B2h*4],COpB2m8
mov dword[edi+0B3h*4],COpB3m8
mov dword[edi+0B4h*4],COpB4x8
mov dword[edi+0B5h*4],COpB5m8
mov dword[edi+0B6h*4],COpB6x8
mov dword[edi+0B7h*4],COpB7m8
mov dword[edi+0B8h*4],COpB8
mov dword[edi+0B9h*4],COpB9m8
mov dword[edi+0BAh*4],COpBAx8
mov dword[edi+0BBh*4],COpBBx8
mov dword[edi+0BCh*4],COpBCx8
mov dword[edi+0BDh*4],COpBDm8
mov dword[edi+0BEh*4],COpBEx8
mov dword[edi+0BFh*4],COpBFm8
mov dword[edi+0C0h*4],COpC0x8
mov dword[edi+0C1h*4],COpC1m8
mov dword[edi+0C2h*4],COpC2
mov dword[edi+0C3h*4],COpC3m8
mov dword[edi+0C4h*4],COpC4x8
mov dword[edi+0C5h*4],COpC5m8
mov dword[edi+0C6h*4],COpC6m8
mov dword[edi+0C7h*4],COpC7m8
mov dword[edi+0C8h*4],COpC8x8
mov dword[edi+0C9h*4],COpC9m8
mov dword[edi+0CAh*4],COpCAx8
mov dword[edi+0CBh*4],COpCB
mov dword[edi+0CCh*4],COpCCx8
mov dword[edi+0CDh*4],COpCDm8
mov dword[edi+0CEh*4],COpCEm8
mov dword[edi+0CFh*4],COpCFm8
mov dword[edi+0D0h*4],COpD0
mov dword[edi+0D1h*4],COpD1m8
mov dword[edi+0D2h*4],COpD2m8
mov dword[edi+0D3h*4],COpD3m8
mov dword[edi+0D4h*4],COpD4
mov dword[edi+0D5h*4],COpD5m8
mov dword[edi+0D6h*4],COpD6m8
mov dword[edi+0D7h*4],COpD7m8
mov dword[edi+0D8h*4],COpD8
mov dword[edi+0D9h*4],COpD9m8
mov dword[edi+0DAh*4],COpDAx8
mov dword[edi+0DBh*4],COpDB
mov dword[edi+0DCh*4],COpDC
mov dword[edi+0DDh*4],COpDDm8
mov dword[edi+0DEh*4],COpDEm8
mov dword[edi+0DFh*4],COpDFm8
mov dword[edi+0E0h*4],COpE0x8
mov dword[edi+0E1h*4],COpE1m8nd
mov dword[edi+0E2h*4],COpE2
mov dword[edi+0E3h*4],COpE3m8nd
mov dword[edi+0E4h*4],COpE4x8
mov dword[edi+0E5h*4],COpE5m8nd
mov dword[edi+0E6h*4],COpE6m8
mov dword[edi+0E7h*4],COpE7m8nd
mov dword[edi+0E8h*4],COpE8x8
mov dword[edi+0E9h*4],COpE9m8nd
mov dword[edi+0EAh*4],COpEA
mov dword[edi+0EBh*4],COpEB
mov dword[edi+0ECh*4],COpECx8
mov dword[edi+0EDh*4],COpEDm8nd
mov dword[edi+0EEh*4],COpEEm8
mov dword[edi+0EFh*4],COpEFm8nd
mov dword[edi+0F0h*4],COpF0
mov dword[edi+0F1h*4],COpF1m8nd
mov dword[edi+0F2h*4],COpF2m8nd
mov dword[edi+0F3h*4],COpF3m8nd
mov dword[edi+0F4h*4],COpF4
mov dword[edi+0F5h*4],COpF5m8nd
mov dword[edi+0F6h*4],COpF6m8
mov dword[edi+0F7h*4],COpF7m8nd
mov dword[edi+0F8h*4],COpF8
mov dword[edi+0F9h*4],COpF9m8nd
mov dword[edi+0FAh*4],COpFAx8
mov dword[edi+0FBh*4],COpFB
mov dword[edi+0FCh*4],COpFC
mov dword[edi+0FDh*4],COpFDm8nd
mov dword[edi+0FEh*4],COpFEm8
mov dword[edi+0FFh*4],COpFFm8nd
ret
settablem16:
mov dword[edi+01h*4],COp01m16
mov dword[edi+03h*4],COp03m16
mov dword[edi+04h*4],COp04m16
mov dword[edi+05h*4],COp05m16
mov dword[edi+06h*4],COp06m16
mov dword[edi+07h*4],COp07m16
mov dword[edi+09h*4],COp09m16
mov dword[edi+0Ah*4],COp0Am16
mov dword[edi+0Ch*4],COp0Cm16
mov dword[edi+0Dh*4],COp0Dm16
mov dword[edi+0Eh*4],COp0Em16
mov dword[edi+0Fh*4],COp0Fm16
mov dword[edi+11h*4],COp11m16
mov dword[edi+12h*4],COp12m16
mov dword[edi+13h*4],COp13m16
mov dword[edi+14h*4],COp14m16
mov dword[edi+15h*4],COp15m16
mov dword[edi+16h*4],COp16m16
mov dword[edi+17h*4],COp17m16
mov dword[edi+19h*4],COp19m16
mov dword[edi+1Ah*4],COp1Am16
mov dword[edi+1Ch*4],COp1Cm16
mov dword[edi+1Dh*4],COp1Dm16
mov dword[edi+1Eh*4],COp1Em16
mov dword[edi+1Fh*4],COp1Fm16
mov dword[edi+21h*4],COp21m16
mov dword[edi+23h*4],COp23m16
mov dword[edi+24h*4],COp24m16
mov dword[edi+25h*4],COp25m16
mov dword[edi+26h*4],COp26m16
mov dword[edi+27h*4],COp27m16
mov dword[edi+29h*4],COp29m16
mov dword[edi+2Ah*4],COp2Am16
mov dword[edi+2Ch*4],COp2Cm16
mov dword[edi+2Dh*4],COp2Dm16
mov dword[edi+2Eh*4],COp2Em16
mov dword[edi+2Fh*4],COp2Fm16
mov dword[edi+31h*4],COp31m16
mov dword[edi+32h*4],COp32m16
mov dword[edi+33h*4],COp33m16
mov dword[edi+34h*4],COp34m16
mov dword[edi+35h*4],COp35m16
mov dword[edi+36h*4],COp36m16
mov dword[edi+37h*4],COp37m16
mov dword[edi+39h*4],COp39m16
mov dword[edi+3Ah*4],COp3Am16
mov dword[edi+3Ch*4],COp3Cm16
mov dword[edi+3Dh*4],COp3Dm16
mov dword[edi+3Eh*4],COp3Em16
mov dword[edi+3Fh*4],COp3Fm16
mov dword[edi+41h*4],COp41m16
mov dword[edi+43h*4],COp43m16
mov dword[edi+45h*4],COp45m16
mov dword[edi+46h*4],COp46m16
mov dword[edi+47h*4],COp47m16
mov dword[edi+48h*4],COp48m16
mov dword[edi+49h*4],COp49m16
mov dword[edi+4Ah*4],COp4Am16
mov dword[edi+4Dh*4],COp4Dm16
mov dword[edi+4Eh*4],COp4Em16
mov dword[edi+4Fh*4],COp4Fm16
mov dword[edi+51h*4],COp51m16
mov dword[edi+52h*4],COp52m16
mov dword[edi+53h*4],COp53m16
mov dword[edi+55h*4],COp55m16
mov dword[edi+56h*4],COp56m16
mov dword[edi+57h*4],COp57m16
mov dword[edi+59h*4],COp59m16
mov dword[edi+5Dh*4],COp5Dm16
mov dword[edi+5Eh*4],COp5Em16
mov dword[edi+5Fh*4],COp5Fm16
mov dword[edi+61h*4],COp61m16nd
mov dword[edi+63h*4],COp63m16nd
mov dword[edi+64h*4],COp64m16
mov dword[edi+65h*4],COp65m16nd
mov dword[edi+66h*4],COp66m16
mov dword[edi+67h*4],COp67m16nd
mov dword[edi+68h*4],COp68m16
mov dword[edi+69h*4],COp69m16nd
mov dword[edi+6Ah*4],COp6Am16
mov dword[edi+6Dh*4],COp6Dm16nd
mov dword[edi+6Eh*4],COp6Em16
mov dword[edi+6Fh*4],COp6Fm16nd
mov dword[edi+71h*4],COp71m16nd
mov dword[edi+72h*4],COp72m16nd
mov dword[edi+73h*4],COp73m16nd
mov dword[edi+74h*4],COp74m16
mov dword[edi+75h*4],COp75m16nd
mov dword[edi+76h*4],COp76m16
mov dword[edi+77h*4],COp77m16nd
mov dword[edi+79h*4],COp79m16nd
mov dword[edi+7Dh*4],COp7Dm16nd
mov dword[edi+7Eh*4],COp7Em16
mov dword[edi+7Fh*4],COp7Fm16nd
mov dword[edi+81h*4],COp81m16
mov dword[edi+83h*4],COp83m16
mov dword[edi+85h*4],COp85m16
mov dword[edi+87h*4],COp87m16
mov dword[edi+89h*4],COp89m16
mov dword[edi+8Ah*4],COp8Am16
mov dword[edi+8Dh*4],COp8Dm16
mov dword[edi+8Fh*4],COp8Fm16
mov dword[edi+91h*4],COp91m16
mov dword[edi+92h*4],COp92m16
mov dword[edi+93h*4],COp93m16
mov dword[edi+95h*4],COp95m16
mov dword[edi+97h*4],COp97m16
mov dword[edi+98h*4],COp98m16
mov dword[edi+99h*4],COp99m16
mov dword[edi+9Ch*4],COp9Cm16
mov dword[edi+9Dh*4],COp9Dm16
mov dword[edi+9Eh*4],COp9Em16
mov dword[edi+9Fh*4],COp9Fm16
mov dword[edi+0A1h*4],COpA1m16
mov dword[edi+0A3h*4],COpA3m16
mov dword[edi+0A5h*4],COpA5m16
mov dword[edi+0A7h*4],COpA7m16
mov dword[edi+0A9h*4],COpA9m16
mov dword[edi+0ADh*4],COpADm16
mov dword[edi+0AFh*4],COpAFm16
mov dword[edi+0B1h*4],COpB1m16
mov dword[edi+0B2h*4],COpB2m16
mov dword[edi+0B3h*4],COpB3m16
mov dword[edi+0B5h*4],COpB5m16
mov dword[edi+0B7h*4],COpB7m16
mov dword[edi+0B9h*4],COpB9m16
mov dword[edi+0BDh*4],COpBDm16
mov dword[edi+0BFh*4],COpBFm16
mov dword[edi+0C1h*4],COpC1m16
mov dword[edi+0C3h*4],COpC3m16
mov dword[edi+0C5h*4],COpC5m16
mov dword[edi+0C6h*4],COpC6m16
mov dword[edi+0C7h*4],COpC7m16
mov dword[edi+0C9h*4],COpC9m16
mov dword[edi+0CDh*4],COpCDm16
mov dword[edi+0CEh*4],COpCEm16
mov dword[edi+0CFh*4],COpCFm16
mov dword[edi+0D1h*4],COpD1m16
mov dword[edi+0D2h*4],COpD2m16
mov dword[edi+0D3h*4],COpD3m16
mov dword[edi+0D5h*4],COpD5m16
mov dword[edi+0D6h*4],COpD6m16
mov dword[edi+0D7h*4],COpD7m16
mov dword[edi+0D9h*4],COpD9m16
mov dword[edi+0DDh*4],COpDDm16
mov dword[edi+0DEh*4],COpDEm16
mov dword[edi+0DFh*4],COpDFm16
mov dword[edi+0E1h*4],COpE1m16nd
mov dword[edi+0E3h*4],COpE3m16nd
mov dword[edi+0E5h*4],COpE5m16nd
mov dword[edi+0E6h*4],COpE6m16
mov dword[edi+0E7h*4],COpE7m16nd
mov dword[edi+0E9h*4],COpE9m16nd
mov dword[edi+0EDh*4],COpEDm16nd
mov dword[edi+0EEh*4],COpEEm16
mov dword[edi+0EFh*4],COpEFm16nd
mov dword[edi+0F1h*4],COpF1m16nd
mov dword[edi+0F2h*4],COpF2m16nd
mov dword[edi+0F3h*4],COpF3m16nd
mov dword[edi+0F5h*4],COpF5m16nd
mov dword[edi+0F6h*4],COpF6m16
mov dword[edi+0F7h*4],COpF7m16nd
mov dword[edi+0F9h*4],COpF9m16nd
mov dword[edi+0FDh*4],COpFDm16nd
mov dword[edi+0FEh*4],COpFEm16
mov dword[edi+0FFh*4],COpFFm16nd
ret
settablex16:
mov dword[edi+5Ah*4],COp5Ax16
mov dword[edi+7Ah*4],COp7Ax16
mov dword[edi+84h*4],COp84x16
mov dword[edi+86h*4],COp86x16
mov dword[edi+88h*4],COp88x16
mov dword[edi+8Ch*4],COp8Cx16
mov dword[edi+8Eh*4],COp8Ex16
mov dword[edi+94h*4],COp94x16
mov dword[edi+96h*4],COp96x16
mov dword[edi+9Bh*4],COp9Bx16
mov dword[edi+0A0h*4],COpA0x16
mov dword[edi+0A2h*4],COpA2x16
mov dword[edi+0A4h*4],COpA4x16
mov dword[edi+0A6h*4],COpA6x16
mov dword[edi+0A8h*4],COpA8x16
mov dword[edi+0AAh*4],COpAAx16
mov dword[edi+0ACh*4],COpACx16
mov dword[edi+0AEh*4],COpAEx16
mov dword[edi+0B4h*4],COpB4x16
mov dword[edi+0B6h*4],COpB6x16
mov dword[edi+0BAh*4],COpBAx16
mov dword[edi+0BBh*4],COpBBx16
mov dword[edi+0BCh*4],COpBCx16
mov dword[edi+0BEh*4],COpBEx16
mov dword[edi+0C0h*4],COpC0x16
mov dword[edi+0C4h*4],COpC4x16
mov dword[edi+0C8h*4],COpC8x16
mov dword[edi+0CAh*4],COpCAx16
mov dword[edi+0CCh*4],COpCCx16
mov dword[edi+0DAh*4],COpDAx16
mov dword[edi+0E0h*4],COpE0x16
mov dword[edi+0E4h*4],COpE4x16
mov dword[edi+0E8h*4],COpE8x16
mov dword[edi+0ECh*4],COpECx16
mov dword[edi+0FAh*4],COpFAx16
ret
settableDm8:
mov dword[edi+61h*4],COp61m8d
mov dword[edi+63h*4],COp63m8d
mov dword[edi+65h*4],COp65m8d
mov dword[edi+67h*4],COp67m8d
mov dword[edi+69h*4],COp69m8d
mov dword[edi+6Dh*4],COp6Dm8d
mov dword[edi+6Fh*4],COp6Fm8d
mov dword[edi+71h*4],COp71m8d
mov dword[edi+72h*4],COp72m8d
mov dword[edi+73h*4],COp73m8d
mov dword[edi+75h*4],COp75m8d
mov dword[edi+77h*4],COp77m8d
mov dword[edi+79h*4],COp79m8d
mov dword[edi+7Dh*4],COp7Dm8d
mov dword[edi+7Fh*4],COp7Fm8d
mov dword[edi+0E1h*4],COpE1m8d
mov dword[edi+0E3h*4],COpE3m8d
mov dword[edi+0E5h*4],COpE5m8d
mov dword[edi+0E7h*4],COpE7m8d
mov dword[edi+0E9h*4],COpE9m8d
mov dword[edi+0EDh*4],COpEDm8d
mov dword[edi+0EFh*4],COpEFm8d
mov dword[edi+0F1h*4],COpF1m8d
mov dword[edi+0F2h*4],COpF2m8d
mov dword[edi+0F3h*4],COpF3m8d
mov dword[edi+0F5h*4],COpF5m8d
mov dword[edi+0F7h*4],COpF7m8d
mov dword[edi+0F9h*4],COpF9m8d
mov dword[edi+0FDh*4],COpFDm8d
mov dword[edi+0FFh*4],COpFFm8d
ret
settableDm16:
mov dword[edi+61h*4],COp61m16d
mov dword[edi+63h*4],COp63m16d
mov dword[edi+65h*4],COp65m16d
mov dword[edi+67h*4],COp67m16d
mov dword[edi+69h*4],COp69m16d
mov dword[edi+6Dh*4],COp6Dm16d
mov dword[edi+6Fh*4],COp6Fm16d
mov dword[edi+71h*4],COp71m16d
mov dword[edi+72h*4],COp72m16d
mov dword[edi+73h*4],COp73m16d
mov dword[edi+75h*4],COp75m16d
mov dword[edi+77h*4],COp77m16d
mov dword[edi+79h*4],COp79m16d
mov dword[edi+7Dh*4],COp7Dm16d
mov dword[edi+7Fh*4],COp7Fm16d
mov dword[edi+0E1h*4],COpE1m16d
mov dword[edi+0E3h*4],COpE3m16d
mov dword[edi+0E5h*4],COpE5m16d
mov dword[edi+0E7h*4],COpE7m16d
mov dword[edi+0E9h*4],COpE9m16d
mov dword[edi+0EDh*4],COpEDm16d
mov dword[edi+0EFh*4],COpEFm16d
mov dword[edi+0F1h*4],COpF1m16d
mov dword[edi+0F2h*4],COpF2m16d
mov dword[edi+0F3h*4],COpF3m16d
mov dword[edi+0F5h*4],COpF5m16d
mov dword[edi+0F7h*4],COpF7m16d
mov dword[edi+0F9h*4],COpF9m16d
mov dword[edi+0FDh*4],COpFDm16d
mov dword[edi+0FFh*4],COpFFm16d
ret


3849
zsnes/src/dos/debug.asm Normal file

File diff suppressed because it is too large Load Diff

1821
zsnes/src/dos/dosintrf.asm Normal file

File diff suppressed because it is too large Load Diff

156
zsnes/src/dos/gppro.asm Normal file
View File

@@ -0,0 +1,156 @@
;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"
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


621
zsnes/src/dos/initvid.asm Normal file
View File

@@ -0,0 +1,621 @@
;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
NEWSYM clearfilter, dw 0
NEWSYM res640, db 0
NEWSYM res480, db 0
NEWSYM dosinitvideo2
jmp dosinitvideo.noaddsub
;*******************************************************
; InitVideo
;*******************************************************
NEWSYM dosinitvideo
mov byte[cbitmode],0
mov byte[res640],0
mov byte[res480],0
cmp byte[cvidmode],0
je near .initmodex
cmp byte[cvidmode],1
je near .initmodeq
cmp byte[cvidmode],2
je near .initvesa2320x240x8
cmp byte[cvidmode],3
je near .initvesa2320x240x16
cmp byte[cvidmode],4
je near .initvesa2640x480x8
cmp byte[cvidmode],5
je near .initvesa2640x480x16
cmp byte[cvidmode],6
je near .initvesa2512x384x8
cmp byte[cvidmode],7
je near .initvesa2512x384x16
cmp byte[cvidmode],8
je near .initvesa12640x480x16
cmp byte[cvidmode],9
je near .initvesa2320x480x8
cmp byte[cvidmode],10
je near .initvesa2320x480x16
ret
;*******************************************************
; InitModeX Sets up 320x240 unchained mode
;*******************************************************
.initmodex
mov byte[cbitmode],0
mov ax,0013h
int 10h
mov dx,03C4h
mov ax,0604h
out dx,ax
mov dx,03D4h
mov ax,0E317h
out dx,ax
mov ax,0014h
out dx,ax
mov dx,03C4h
mov ax,0F02h
out dx,ax
mov dx,03C2h
mov al,0E3h
out dx,al
mov dx,03D4h
mov ax,2C11h
out dx,ax
mov ax,0D06h
out dx,ax
mov ax,3E07h
out dx,ax
mov ax,0EA10h
out dx,ax
mov ax,0AC11h
out dx,ax
mov ax,0DF12h
out dx,ax
mov ax,0E715h
out dx,ax
mov ax,0616h
out dx,ax
mov dx,03C6h
mov al,0FFh
out dx,al
mov dx,03C4h
; select all 4 planes and clear
mov ax,0F02h
out dx,ax
push es
mov ax,[selcA000]
mov es,ax
xor edi,edi
mov ecx,65536/4
xor eax,eax
rep stosd
pop es
call makepal
ret
;*******************************************************
; InitModeQ Sets up 256x256 chained mode
;*******************************************************
.initmodeq
mov byte[cbitmode],0
cmp byte[AddSub256],1
jne .noaddsub
mov byte[cbitmode],1
.noaddsub
mov byte[vesa2_rpos],11 ; Red bit position 128,256,512,1024,2048
mov byte[vesa2_gpos],6 ; Green bit position 2^6 = 64
mov byte[vesa2_bpos],0 ; Blue bit position
mov word[vesa2_usbit],0020h ; Unused bit in proper bit location
mov word[vesa2_clbit],0F7DFh ; clear all bit 0's if AND is used
mov word[clearfilter],0F7DFh ; Filter out unnecessary bits
cmp byte[scanlines],1
je near .scanlines
mov ax,0013h
int 10h
mov dx,03D4h
mov al,11h
out dx,al
inc dx
in al,dx
and al,7Fh
mov ah,al
dec dx
mov al,11h
out dx,al
inc dx
mov al,ah
out dx,al
mov dx,03C2h
mov al,0E3h
out dx,al
mov dx,03D4h
mov ax,5F00h
out dx,ax
mov ax,3F01h
out dx,ax
mov ax,4002h
out dx,ax
mov ax,8203h
out dx,ax
mov ax,4A04h
out dx,ax
mov ax,9A05h
out dx,ax
mov ax,2306h
out dx,ax
mov ax,0B207h
out dx,ax
mov ax,0008h
out dx,ax
mov ax,6109h
out dx,ax
mov ax,0A10h
out dx,ax
mov ax,0AC11h
out dx,ax
mov ax,0FF12h
out dx,ax
mov ax,2013h
out dx,ax
mov ax,4014h
out dx,ax
mov ax,0715h
out dx,ax
mov ax,1A16h
out dx,ax
mov ax,0A317h
out dx,ax
mov dx,03C4h
mov ax,0101h
out dx,ax
mov ax,0E04h
out dx,ax
mov dx,03CEh
mov ax,4005h
out dx,ax
mov ax,0506h
out dx,ax
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,30h
out dx,al
mov al,41h
out dx,al
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,33h
out dx,al
mov al,0h
out dx,al
mov dx,03C6h
mov al,0FFh
out dx,al
cmp byte[cbitmode],1
je .nopal
call makepal
.nopal
; clear screen
push es
mov ax,[selcA000]
mov es,ax
xor edi,edi
mov ecx,256*64
xor eax,eax
rep stosd
pop es
ret
.scanlines
mov ax,0013h
int 10h
mov dx,03D4h
mov al,11h
out dx,al
inc dx
in al,dx
and al,7Fh
mov ah,al
dec dx
mov al,11h
out dx,al
inc dx
mov al,ah
out dx,al
mov dx,03C2h
mov al,0E3h
out dx,al
mov dx,03D4h
mov ax,5F00h
out dx,ax
mov ax,3F01h
out dx,ax
mov ax,4002h
out dx,ax
mov ax,8203h
out dx,ax
mov ax,4A04h
out dx,ax
mov ax,9A05h
out dx,ax
mov ax,2306h
out dx,ax
mov ax,01D07h
out dx,ax
mov ax,0008h
out dx,ax
mov ax,6009h
out dx,ax
mov ax,0A10h
out dx,ax
mov ax,0AC11h
out dx,ax
mov ax,0FF12h
out dx,ax
mov ax,2013h
out dx,ax
mov ax,4014h
out dx,ax
mov ax,0715h
out dx,ax
mov ax,1A16h
out dx,ax
mov ax,0A317h
out dx,ax
mov dx,03C4h
mov ax,0101h
out dx,ax
mov ax,0E04h
out dx,ax
mov dx,03CEh
mov ax,4005h
out dx,ax
mov ax,0506h
out dx,ax
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,30h
out dx,al
mov al,41h
out dx,al
mov dx,03DAh
in al,dx
mov dx,03C0h
mov al,33h
out dx,al
mov al,0h
out dx,al
mov dx,03C6h
mov al,0FFh
out dx,al
cmp byte[cbitmode],1
je .nopalb
call makepal
.nopalb
; clear screen
push es
mov ax,[selcA000]
mov es,ax
xor edi,edi
mov ecx,256*64
xor eax,eax
rep stosd
pop es
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 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 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
;*******************************************************
; 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
.loopg
mov byte[es:edi],0
inc edi
dec ecx
jnz .loopg
dec ebx
jnz .loopbanks
mov ecx,6144
pop es
ret


1617
zsnes/src/dos/joy.asm Normal file

File diff suppressed because it is too large Load Diff

437
zsnes/src/dos/modemrtn.asm Normal file
View File

@@ -0,0 +1,437 @@
;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 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
loop .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


226
zsnes/src/dos/sw.asm Normal file
View File

@@ -0,0 +1,226 @@
;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
%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


330
zsnes/src/dos/sw32.asm Normal file
View File

@@ -0,0 +1,330 @@
;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


555
zsnes/src/dos/vesa12.asm Normal file
View File

@@ -0,0 +1,555 @@
;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
; add 0214h video mode
NEWSYM granularity, dw 0
NEWSYM granadd, dd 0
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


802
zsnes/src/dos/vesa2.asm Normal file
View File

@@ -0,0 +1,802 @@
;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,Init_2xSaI
; 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
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
call Init_2xSaI
pop eax
ret
NEWSYM LFBpointer
dd 0
NEWSYM noblocks
dw 0
NEWSYM bytesperscanline
dw 0
NEWSYM vesamode
dw 0
;----------------------------------------------------------------------
NEWSYM VESAmodelist
times 512 dw 0
;----------------------------------------------------------------------
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
;----------------------------------------------------------------------


267
zsnes/src/dos/zfile.c Normal file
View File

@@ -0,0 +1,267 @@
//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 <stdio.h>
#include <time.h>
#ifdef ZDOS
#include <dos.h>
#endif
#define DWORD unsigned int
#define BYTE unsigned char
FILE *FILEHANDLE[16];
DWORD CurrentHandle=0;
// 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()
{
CurrentHandle=0;
return(0);
}
DWORD ZOpenFile()
{
if(ZOpenMode==0)
{
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"))!=NULL)
{
CurrentHandle+=1;
return(CurrentHandle-1);
}
return(0xFFFFFFFF);
}
if(ZOpenMode==1)
{
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"))!=NULL)
{
CurrentHandle+=1;
return(CurrentHandle-1);
}
return(0xFFFFFFFF);
}
if(ZOpenMode==2)
{
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"))!=NULL)
{
CurrentHandle+=1;
return(CurrentHandle-1);
}
return(0xFFFFFFFF);
}
return(0xFFFFFFFF);
}
DWORD ZCloseFile()
{
fclose(FILEHANDLE[ZCloseFileHandle]);
CurrentHandle-=1;
return(0);
}
DWORD ZFileSeek()
{
if(ZFileSeekMode==0)
{
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_SET);
return(0);
}
if(ZFileSeekMode==1)
{
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_END);
return(0);
}
return(0xFFFFFFFF);
}
DWORD ZFileRead()
{
return(fread(ZFileReadBlock,1,ZFileReadSize,FILEHANDLE[ZFileReadHandle]));
}
DWORD ZFileWrite()
{
if((fwrite(ZFileWriteBlock,1,ZFileWriteSize,FILEHANDLE[ZFileWriteHandle]))!=ZFileWriteSize) return(0xFFFFFFFF);
return(0);
}
DWORD ZFileTell()
{
return(ftell(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));
}
DWORD ZFileCHDir()
{
return(chdir(CHPath));
}
DWORD ZFileRMDir()
{
return(rmdir(RMPath));
}
DWORD ZFileGetDir()
{
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));
}
DWORD ZFileFindNext()
{
return(_dos_findnext(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);
}

396
zsnes/src/dos/zloader.c Normal file
View File

@@ -0,0 +1,396 @@
//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 <stdio.h>
#include <ctype.h>
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,
FPUCopy, 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;
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 5!\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();
}
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<argc;p++)
{
/*
printf("(%i/%i): %s\n",p,argc,argv[p]);
*/
if(argv[p][0] == '-')
{
int hasroom=0;
int pp=1;
int cp=p;
int nn='_';
for(pp=1;argv[cp][pp];pp++)
{
if( (p+1) < argc) hasroom=1;
nn=tolower(argv[cp][pp+1]);
switch(tolower(argv[cp][pp]))
{
case '1': /* Player 1 Input */
{
if(!hasroom) return 4;
pl1contrl=my_atoi(argv[p+1]);
if(pl1contrl > 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 'f':
{
if(!hasroom) return 4;
frameskip=my_atoi(argv[p+1]);
if(frameskip > 9) return 10;
p++;
break;
}
case 'g':
{
if(!hasroom) return 4;
gammalevel=my_atoi(argv[p+1]);
if(gammalevel > 5) 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 > 10) 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':
{
scanlines=1;
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':
{
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')
{
FPUCopy=2;
pp++;
}
else
{
FPUCopy=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;
}


212
zsnes/src/dos/zsipx.asm Normal file
View File

@@ -0,0 +1,212 @@
;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


250
zsnes/src/endmem.asm Normal file
View File

@@ -0,0 +1,250 @@
;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 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?.??? / Freeware, programmed by zsKnight, _Demo_, and Pharos',13,10,0
ALIGN32
NEWSYM wramdataa, times 65536 db 0
NEWSYM ram7fa, times 65536 db 0
NEWSYM Inbetweendat, dd 0,0,0,0
NEWSYM opcjmptab, times 256 dd 0
NEWSYM Bank0datr8 ,times 256 dd 0
NEWSYM Bank0datr16,times 256 dd 0
NEWSYM Bank0datw8 ,times 256 dd 0
NEWSYM Bank0datw16,times 256 dd 0
NEWSYM tableA, times 256 dd 0
NEWSYM tableB, times 256 dd 0
NEWSYM tableC, times 256 dd 0
NEWSYM tableD, times 256 dd 0
NEWSYM tableE, times 256 dd 0
NEWSYM tableF, times 256 dd 0
NEWSYM tableG, times 256 dd 0
NEWSYM tableH, times 256 dd 0
NEWSYM tableAb, times 256 dd 0
NEWSYM tableBb, times 256 dd 0
NEWSYM tableCb, times 256 dd 0
NEWSYM tableDb, times 256 dd 0
NEWSYM tableEb, times 256 dd 0
NEWSYM tableFb, times 256 dd 0
NEWSYM tableGb, times 256 dd 0
NEWSYM tableHb, times 256 dd 0
NEWSYM tableAc, times 256 dd 0
NEWSYM tableBc, times 256 dd 0
NEWSYM tableCc, times 256 dd 0
NEWSYM tableDc, times 256 dd 0
NEWSYM tableEc, times 256 dd 0
NEWSYM tableFc, times 256 dd 0
NEWSYM tableGc, times 256 dd 0
NEWSYM tableHc, times 256 dd 0
NEWSYM SA1tableA, times 256 dd 0
NEWSYM SA1tableB, times 256 dd 0
NEWSYM SA1tableC, times 256 dd 0
NEWSYM SA1tableD, times 256 dd 0
NEWSYM SA1tableE, times 256 dd 0
NEWSYM SA1tableF, times 256 dd 0
NEWSYM SA1tableG, times 256 dd 0
NEWSYM SA1tableH, times 256 dd 0
NEWSYM tablead, times 256 dd 0
NEWSYM tableadb, times 256 dd 0
NEWSYM tableadc, times 256 dd 0
NEWSYM SA1tablead, times 256 dd 0
NEWSYM memtabler8, times 256 dd 0
NEWSYM memtablew8, times 256 dd 0
NEWSYM memtabler16, times 256 dd 0
NEWSYM memtablew16, times 256 dd 0
NEWSYM vidmemch2, times 4096 db 0
NEWSYM vidmemch4, times 4096 db 0
NEWSYM vidmemch8, times 4096 db 0
NEWSYM snesmmap, times 256 dd 0
NEWSYM snesmap2, times 256 dd 0
NEWSYM cachebg1, times 64 db 0
NEWSYM cachebg2, times 64 db 0
NEWSYM cachebg3, times 64 db 0
NEWSYM cachebg4, times 64 db 0
NEWSYM sprlefttot, times 256 db 0
NEWSYM sprleftpr, times 256 db 0
NEWSYM sprleftpr1, times 256 db 0
NEWSYM sprleftpr2, times 256 db 0
NEWSYM sprleftpr3, times 256 db 0
NEWSYM sprpriodata, times 288 db 0
NEWSYM sprprtabc, times 64 db 0
NEWSYM sprprtabu, times 64 db 0
NEWSYM prevpal, times 256 dw 0 ; previous palette buffer
NEWSYM winbgdata, times 288 db 0 ; window buffer for backgrounds
NEWSYM winspdata, times 288 db 0 ; window buffer for sprites
NEWSYM FxTable, times 256 dd 0
NEWSYM FxTableA1, times 256 dd 0
NEWSYM FxTableA2, times 256 dd 0
NEWSYM FxTableA3, times 256 dd 0
NEWSYM FxTableb, times 256 dd 0
NEWSYM FxTablebA1, times 256 dd 0
NEWSYM FxTablebA2, times 256 dd 0
NEWSYM FxTablebA3, times 256 dd 0
NEWSYM FxTablec, times 256 dd 0
NEWSYM FxTablecA1, times 256 dd 0
NEWSYM FxTablecA2, times 256 dd 0
NEWSYM FxTablecA3, times 256 dd 0
NEWSYM FxTabled, times 256 dd 0
NEWSYM FxTabledA1, times 256 dd 0
NEWSYM FxTabledA2, times 256 dd 0
NEWSYM FxTabledA3, times 256 dd 0
NEWSYM SfxMemTable, times 256 dd 0
NEWSYM fxxand, times 256 dd 0
NEWSYM fxbit01, times 256 dd 0
NEWSYM fxbit23, times 256 dd 0
NEWSYM fxbit45, times 256 dd 0
NEWSYM fxbit67, times 256 dd 0
NEWSYM PLOTJmpa, times 64 dd 0
NEWSYM PLOTJmpb, times 64 dd 0
NEWSYM pal16b, times 256 dd 0
NEWSYM pal16bcl, times 256 dd 0
NEWSYM pal16bclha, times 256 dd 0
NEWSYM pal16bxcl, times 256 dd 0
NEWSYM xtravbuf, times 576 db 0
NEWSYM BG1SXl, times 256 dw 0
NEWSYM BG2SXl, times 256 dw 0
NEWSYM BG3SXl, times 256 dw 0
NEWSYM BG4SXl, times 256 dw 0
NEWSYM BG1SYl, times 256 dw 0
NEWSYM BG2SYl, times 256 dw 0
NEWSYM BG3SYl, times 256 dw 0
NEWSYM BG4SYl, times 256 dw 0
NEWSYM BGMA, times 256 db 0
NEWSYM BGFB, times 256 db 0
NEWSYM BG3PRI, times 256 db 0
NEWSYM BGOPT1, times 256 dw 0
NEWSYM BGOPT2, times 256 dw 0
NEWSYM BGOPT3, times 256 dw 0
NEWSYM BGOPT4, times 256 dw 0
NEWSYM BGPT1, times 256 dw 0
NEWSYM BGPT2, times 256 dw 0
NEWSYM BGPT3, times 256 dw 0
NEWSYM BGPT4, times 256 dw 0
NEWSYM BGPT1X, times 256 dw 0
NEWSYM BGPT2X, times 256 dw 0
NEWSYM BGPT3X, times 256 dw 0
NEWSYM BGPT4X, times 256 dw 0
NEWSYM BGPT1Y, times 256 dw 0
NEWSYM BGPT2Y, times 256 dw 0
NEWSYM BGPT3Y, times 256 dw 0
NEWSYM BGPT4Y, times 256 dw 0
NEWSYM BGMS1, times 1024 dw 0
NEWSYM prdata, times 256 db 0
NEWSYM prdatb, times 256 db 0
NEWSYM prdatc, times 256 db 0
NEWSYM ngpalcon2b, times 20h dd 0
NEWSYM ngpalcon4b, times 20h dd 0
NEWSYM ngpalcon8b, times 20h dd 0
NEWSYM tltype2b, times 4096 db 0
NEWSYM tltype4b, times 2048 db 0
NEWSYM tltype8b, times 1024 db 0
NEWSYM ngptrdat, times 1024 dd 0
NEWSYM ngceax, times 1024 dd 0
NEWSYM ngcedi, times 1024 dd 0
NEWSYM bgtxad, times 1024 dw 0
NEWSYM sprtbng, times 256 dd 0
NEWSYM sprtlng, times 256 db 0
NEWSYM mosszng, times 256 db 0
NEWSYM mosenng, times 256 db 0
NEWSYM vidmemch2s, times 4096 db 0FFh
NEWSYM vidmemch4s, times 2048 db 0FFh
NEWSYM vidmemch8s, times 1024 db 0FFh
NEWSYM mode7ab, times 256 dd 0
NEWSYM mode7cd, times 256 dd 0
NEWSYM mode7xy, times 256 dd 0
NEWSYM mode7st, times 256 db 0
NEWSYM t16x161, times 256 db 0
NEWSYM t16x162, times 256 db 0
NEWSYM t16x163, times 256 db 0
NEWSYM t16x164, times 256 db 0
NEWSYM intrlng, times 256 db 0
NEWSYM mode7hr, times 256 db 0
NEWSYM scadsng, times 256 db 0
NEWSYM scadtng, times 256 db 0
NEWSYM scbcong, times 256 dw 0
NEWSYM cpalval, times 256 dd 0
NEWSYM cgfxmod, times 256 db 0
NEWSYM winboundary, times 256 dd 0
NEWSYM winbg1enval, times 256 db 0
NEWSYM winbg2enval, times 256 db 0
NEWSYM winbg3enval, times 256 db 0
NEWSYM winbg4enval, times 256 db 0
NEWSYM winbgobjenval, times 256 db 0
NEWSYM winbgbackenval, times 256 db 0
NEWSYM winlogicaval, times 256 dw 0
NEWSYM winbg1envals, times 256 db 0
NEWSYM winbg2envals, times 256 db 0
NEWSYM winbg3envals, times 256 db 0
NEWSYM winbg4envals, times 256 db 0
NEWSYM winbgobjenvals, times 256 db 0
NEWSYM winbgbackenvals, times 256 db 0
NEWSYM winbg1envalm, times 256 db 0
NEWSYM winbg2envalm, times 256 db 0
NEWSYM winbg3envalm, times 256 db 0
NEWSYM winbg4envalm, times 256 db 0
NEWSYM winbgobjenvalm, times 256 db 0
NEWSYM winbgbackenvalm, times 256 db 0
NEWSYM FillSubScr, times 256 db 0
NEWSYM objclineptr, times 256 dd 0 ; l1,r1,l2,r2,en,log,ptr
NEWSYM objwlrpos , times 256 dd 0FFFFFFFFh
NEWSYM objwen , times 256 dw 0FFFFh ; en,log
NEWSYM SpecialLine, times 256 db 0
NEWSYM bgallchange, times 256 db 0
NEWSYM bg1change, times 256 db 0
NEWSYM bg2change, times 256 db 0
NEWSYM bg3change, times 256 db 0
NEWSYM bg4change, times 256 db 0
NEWSYM bgwinchange, times 256 db 0
NEWSYM PrevPicture, times 64*56*2 db 0


411
zsnes/src/fixsin.c Normal file
View File

@@ -0,0 +1,411 @@
//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
};


25
zsnes/src/fixsin.h Normal file
View File

@@ -0,0 +1,25 @@
//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]


4898
zsnes/src/gui/gui.asm Normal file

File diff suppressed because it is too large Load Diff

1340
zsnes/src/gui/guicheat.inc Normal file

File diff suppressed because it is too large Load Diff

190
zsnes/src/gui/guicombo.inc Normal file
View File

@@ -0,0 +1,190 @@
;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
loop .loop
mov ecx,42 ; copy combination code
mov ebx,GUIComboData
.loop2
mov dl,[ebx]
mov [eax],dl
inc ebx
inc eax
loop .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
loop .loop
mov ecx,42 ; copy combination code
mov ebx,GUIComboData
.loop2
mov dl,[ebx]
mov [eax],dl
inc ebx
inc eax
loop .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
loop .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


2186
zsnes/src/gui/guikeys.inc Normal file

File diff suppressed because it is too large Load Diff

1555
zsnes/src/gui/guiload.inc Normal file

File diff suppressed because it is too large Load Diff

499
zsnes/src/gui/guimisc.inc Normal file
View File

@@ -0,0 +1,499 @@
;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
loop .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
loop .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
loop .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
cmp byte[pl1p209+eax],0
jne near .port209
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
cmp byte[pl1p209+eax],0
jne .port209
.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
; 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


2861
zsnes/src/gui/guimouse.inc Normal file

File diff suppressed because it is too large Load Diff

1780
zsnes/src/gui/guinetpl.inc Normal file

File diff suppressed because it is too large Load Diff

836
zsnes/src/gui/guitools.inc Normal file
View File

@@ -0,0 +1,836 @@
;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,5
.loopb
test ah,80h
jz .nowrite
mov al,[GUItextcolor]
sub al,cl
sub al,ch
mov byte[esi],al
.nowrite
shl ah,1
inc esi
dec ch
jnz .loopb
add esi,283
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
cmp al,'%'
jne .noperc
call ConvertPercValue
.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


5622
zsnes/src/gui/guiwindp.inc Normal file

File diff suppressed because it is too large Load Diff

1437
zsnes/src/gui/menu.asm Normal file

File diff suppressed because it is too large Load Diff

5327
zsnes/src/init.asm Normal file

File diff suppressed because it is too large Load Diff

2
zsnes/src/link.win32 Normal file
View File

@@ -0,0 +1,2 @@
/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 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 video\2xsai.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 obj\unzip.obj obj\zzip.obj zlib.lib wsock32.lib user32.lib gdi32.lib shell32.lib ddraw.lib dsound.lib dinput.lib d3dx.lib /link /section:.text,erw


48
zsnes/src/macros.mac Normal file
View File

@@ -0,0 +1,48 @@
;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
%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

185
zsnes/src/makefile.dos Normal file
View File

@@ -0,0 +1,185 @@
#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
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}/2xsai.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}/unzip.o\
${OBJDIR}/zipx.o ${OBJDIR}/zzip.o
MAINOBJ=cfgload.o endmem.o fixsin.o init.o ui.o vcache.o water.o
OBJS=${CHIPSOBJ} ${CPUOBJ} ${DOSOBJ} ${GUIOBJ} ${VIDEOBJ} ${PREOBJ} ${MAINOBJ}
LIBS=-lz -lgcc -lm
CFLAGS=
ASM=nasm
ASMFLAGS=-f coff
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
zsnes.exe: ${OBJS}
${CC} -Ws -s -o zsnes.exe ${OBJS} ${LIBS}
${DOSDIR}/zloader.o: ${DOSDIR}/zloader.c
fixsin.o: fixsin.c
water.o: water.c
${DOSDIR}/zfile.o: ${DOSDIR}/zfile.c
${VIDEODIR}/2xsai.o: ${VIDEODIR}/2xsai.cpp
${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 betauser.mac
ui.o: ui.asm macros.mac betauser.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
${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 zsnes.exe


212
zsnes/src/makefile.win Normal file
View File

@@ -0,0 +1,212 @@
#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=f:\mssdk
CHIPDIR=chips
CPUDIR=cpu
DOSDIR=dos
GUIDIR=gui
VIDEODIR=video
WINDIR=win
OBJDIR=obj
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}/2xsai.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
PREOBJ=${OBJDIR}/unzip.obj ${OBJDIR}/zzip.obj ${DOSDIR}/zsipx.obj
MAINOBJ=cfgload.obj endmem.obj fixsin.obj init.obj ui.obj vcache.obj water.obj
OBJS=${CHIPSOBJ} ${CPUOBJ} ${WINOBJ} ${GUIOBJ} ${VIDEOBJ} ${PREOBJ} ${MAINOBJ} ${WINDOSOBJ}
LIBS=
CFLAGS=/c
ASM=nasm
ASMFLAGS=-f 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
${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
${VIDEODIR}/2xsaiw.obj: ${VIDEODIR}/2xsaiw.asm macros.mac
${VIDEODIR}/2xsai.obj: ${VIDEODIR}/2xsai.cpp
${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 betauser.mac
${CHIPDIR}/dsp1proc.obj: ${CHIPDIR}/dsp1proc.asm macros.mac
ui.obj: ui.asm macros.mac betauser.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 ${DOSDIR}\*.obj
del zsnesw.exe


1330
zsnes/src/ui.asm Normal file

File diff suppressed because it is too large Load Diff

3765
zsnes/src/vcache.asm Normal file

File diff suppressed because it is too large Load Diff

289
zsnes/src/video/2xsai.cpp Normal file
View File

@@ -0,0 +1,289 @@
//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.
//#define MMX
#define uint32 unsigned long
#define uint16 unsigned short
#define uint8 unsigned char
static uint32 colorMask = 0xF7DEF7DE;
static uint32 lowPixelMask = 0x08210821;
static uint32 qcolorMask = 0xE79CE79C;
static uint32 qlowpixelMask = 0x18631863;
static uint32 redblueMask = 0xF81F;
static uint32 greenMask = 0x7E0;
extern "C" void Init_2xSaI(uint32 BitFormat)
{
if (BitFormat == 565)
{
colorMask = 0xF7DEF7DE;
lowPixelMask = 0x08210821;
qcolorMask = 0xE79CE79C;
qlowpixelMask = 0x18631863;
redblueMask = 0xF81F;
greenMask = 0x7E0;
}
else
if (BitFormat == 555)
{
colorMask = 0x7BDE7BDE;
lowPixelMask = 0x04210421;
qcolorMask = 0x739C739C;
qlowpixelMask = 0x0C630C63;
redblueMask = 0x7C1F;
greenMask = 0x3E0;
}
else
{
return;
}
#ifdef MMX
Init_2xSaIMMX(BitFormat);
#endif
return;
}
static inline int GetResult1(uint32 A, uint32 B, uint32 C, uint32 D, uint32 E)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C) x+=1; else if (B == C) y+=1;
if (A == D) x+=1; else if (B == D) y+=1;
if (x <= 1) r+=1;
if (y <= 1) r-=1;
return r;
}
static inline int GetResult2(uint32 A, uint32 B, uint32 C, uint32 D, uint32 E)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C) x+=1; else if (B == C) y+=1;
if (A == D) x+=1; else if (B == D) y+=1;
if (x <= 1) r-=1;
if (y <= 1) r+=1;
return r;
}
static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C) x+=1; else if (B == C) y+=1;
if (A == D) x+=1; else if (B == D) y+=1;
if (x <= 1) r+=1;
if (y <= 1) r-=1;
return r;
}
static inline uint32 INTERPOLATE(uint32 A, uint32 B)
{
if (A !=B)
{
return ( ((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask) );
}
else return A;
}
static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D)
{
register uint32 x = ((A & qcolorMask) >> 2) +
((B & qcolorMask) >> 2) +
((C & qcolorMask) >> 2) +
((D & qcolorMask) >> 2);
register uint32 y = (A & qlowpixelMask) +
(B & qlowpixelMask) +
(C & qlowpixelMask) +
(D & qlowpixelMask);
y = (y>>2) & qlowpixelMask;
return x+y;
}
#define BLUE_MASK565 0x001F001F
#define RED_MASK565 0xF800F800
#define GREEN_MASK565 0x07E007E0
#define BLUE_MASK555 0x001F001F
#define RED_MASK555 0x7C007C00
#define GREEN_MASK555 0x03E003E0
//srcPtr equ 8
//deltaPtr equ 12
//srcPitch equ 16
//width equ 20
//dstOffset equ 24
//dstPitch equ 28
//dstSegment equ 32
extern "C" void Super2xSaI(uint8 *srcPtr, uint8 *deltaPtr, uint32 srcPitch,
int width, uint8 *dstPtr , uint32 dstPitch)
{
uint16 *dP;
uint16 *bP;
uint32 inc_bP;
int height = 1;
uint32 dPitch = dstPitch >> 1;
uint32 Nextline = srcPitch >> 1;
{
inc_bP = 1;
// for (height; height; height-=1)
{
bP = (uint16 *) srcPtr;
dP = (uint16 *) dstPtr;
for (uint32 finish = width; finish; finish -= inc_bP )
{
uint32 color4, color5, color6;
uint32 color1, color2, color3;
uint32 colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3,
colorS1, colorS2;
uint32 product1a, product1b,
product2a, product2b;
//--------------------------------------- B1 B2
// 4 5 6 S2
// 1 2 3 S1
// A1 A2
colorB0 = *(bP- Nextline - 1);
colorB1 = *(bP- Nextline);
colorB2 = *(bP- Nextline + 1);
colorB3 = *(bP- Nextline + 2);
color4 = *(bP - 1);
color5 = *(bP);
color6 = *(bP + 1);
colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2);
colorA0 = *(bP + Nextline + Nextline - 1);
colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1);
colorA3 = *(bP + Nextline + Nextline + 2);
//--------------------------------------
if (color2 == color6 && color5 != color3)
{
product2b = product1b = color2;
}
else
if (color5 == color3 && color2 != color6)
{
product2b = product1b = color5;
}
else
if (color5 == color3 && color2 == color6)
{
register int r = 0;
r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0)
product2b = product1b = color6;
else
if (r < 0)
product2b = product1b = color5;
else
{
product2b = product1b = INTERPOLATE (color5, color6);
}
}
else
{
if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0)
product2b = Q_INTERPOLATE (color3, color3, color3, color2);
else
if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3)
product2b = Q_INTERPOLATE (color2, color2, color2, color3);
else
product2b = INTERPOLATE (color2, color3);
if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0)
product1b = Q_INTERPOLATE (color6, color6, color6, color5);
else
if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3)
product1b = Q_INTERPOLATE (color6, color5, color5, color5);
else
product1b = INTERPOLATE (color5, color6);
}
if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2)
product2a = INTERPOLATE (color2, color5);
else
if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0)
product2a = INTERPOLATE(color2, color5);
else
product2a = color2;
if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2)
product1a = INTERPOLATE (color2, color5);
else
if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0)
product1a = INTERPOLATE(color2, color5);
else
product1a = color5;
product1a = product1a | (product1b << 16);
product2a = product2a | (product2b << 16);
*dP = product1a;
*(dP + 1) = product1b;
*(dP + dPitch) = product2a;
*(dP + dPitch + 1) = product2b;
bP ++;
dP += 2;
}//end of for ( finish= width etc..)
srcPtr += srcPitch;
deltaPtr += srcPitch << 1;
}; //endof: for (height; height; height--)
}
}


1358
zsnes/src/video/2xsaimmx.inc Normal file

File diff suppressed because it is too large Load Diff

1345
zsnes/src/video/2xsaiw.asm Normal file

File diff suppressed because it is too large Load Diff

1375
zsnes/src/video/2xsaiw.inc Normal file

File diff suppressed because it is too large Load Diff

5698
zsnes/src/video/copyvid.inc Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,994 @@
;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 coladdr,curmosaicsz,curvidoffset,domosaic16b,mode7A,drawmode7dcolor
EXTSYM mode7B,mode7C,mode7D,mode7X0,mode7Y0,mode7set,mode7tab
EXTSYM pal16b,pal16bcl,pal16bxcl,scaddtype,scrnon,transpbuf
EXTSYM vesa2_clbit,vram,vrama,winon,xtravbuf,winptrref,scaddset
EXTSYM fulladdtab
EXTSYM cwinptr
;*******************************************************
; Processes & Draws Mode 7
;*******************************************************
%macro mode7halfadd 0
mov [esi+288*2],dl
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bcl+edx*4]
cmp cx,0
je %%noadd
and ebx,[vesa2_clbit]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
%%noadd
mov [esi],bx
xor ecx,ecx
%%nodraw
%endmacro
%macro mode7fulladd 0
mov [esi+288*2],dl
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bcl+edx*4]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
mov [esi],bx
%%nodraw
%endmacro
%macro mode7fullsub 0
mov [esi+288*2],dl
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bxcl+edx*4]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
xor ebx,0FFFFh
mov [esi],bx
%%nodraw
%endmacro
%macro mode7mainsub 0
mov [esi+288*2],dl
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
mov ecx,[pal16b+edx*4]
mov [esi],cx
mov [ebp],cx
%%nodraw
%endmacro
%macro mode7halfaddwinon 0
mov [esi+288*2],dl
mov eax,[cwinptr]
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
test byte[eax],0FFh
jnz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bcl+edx*4]
cmp cx,0
je %%noadd
and ebx,[vesa2_clbit]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
%%noadd
mov [esi],bx
xor ecx,ecx
%%nodraw
inc dword[cwinptr]
%endmacro
%macro mode7fulladdwinon 0
mov [esi+288*2],dl
mov eax,[cwinptr]
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
test byte[eax],0FFh
jnz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bcl+edx*4]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
mov [esi],bx
%%nodraw
inc dword[cwinptr]
%endmacro
%macro mode7fullsubwinon 0
mov [esi+288*2],dl
mov eax,[cwinptr]
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
test byte[eax],0FFh
jnz %%nodraw
mov ecx,[ebp]
mov ebx,[pal16bxcl+edx*4]
and ecx,[vesa2_clbit]
add ebx,ecx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
xor ebx,0FFFFh
mov [esi],bx
%%nodraw
inc dword[cwinptr]
%endmacro
%macro mode7mainsubwinon 0
mov [esi+288*2],dl
mov eax,[cwinptr]
test dl,80h
jnz %%nodraw
or dl,dl
jz %%nodraw
test byte[eax],0FFh
jnz %%nodraw
mov ecx,[pal16b+edx*4]
mov [esi],cx
mov [ebp],cx
%%nodraw
inc dword[cwinptr]
%endmacro
%macro mode716tmacro 1
; mode 7, ax = curyposition, dx = curxposition (left side)
; draw center map coordinates at (X0-bg1scrolx,Y0-bg1scroly) on screen
; center map coordinates = (X0,Y0)
; 1.) cx=X0-bg1scrolx, cy =Y0-ax
mov bx,[mode7X0]
and bx,0001111111111111b ; 13 -> 16 bit signed value
test bx,0001000000000000b
jz .nonega
or bx,1110000000000000b
.nonega
mov [.cxloc],bx
mov bx,dx
and bx,0001111111111111b ; 13 -> 16 bit signed value
test bx,0001000000000000b
jz .nonegb
or bx,1110000000000000b
.nonegb
sub [.cxloc],bx
mov bx,ax
and bx,0001111111111111b ; 13 -> 16 bit signed value
test bx,0001000000000000b
jz .nonegc
or bx,1110000000000000b
.nonegc
mov [.cyloc],bx
mov bx,[mode7Y0]
and bx,0001111111111111b ; 13 -> 16 bit signed value
test bx,0001000000000000b
jz .nonegd
or bx,1110000000000000b
.nonegd
sub word[.cyloc],bx
; 2.) Find position at scaled y, centered x at SCX=X0-(cy*C),SCY=Y0-(cy*D)
movsx ebx,word[.cyloc]
movsx eax,word[mode7C]
imul eax,ebx
neg eax
mov [.mode7xpos],eax
mov bx,word[mode7X0]
add [.mode7xpos+1],bx
movsx ebx,word[.cyloc]
movsx eax,word[mode7D]
imul eax,ebx
; neg ax
mov [.mode7ypos],eax
mov bx,word[mode7Y0]
add [.mode7ypos+1],bx
; 3.) Find left scaled location : SCX=SCX-(cx*A),SCY=SCY-(cx*B)
movsx ebx,word[.cxloc]
movsx eax,word[mode7A]
mov [.mode7xadder],eax
imul eax,ebx
neg eax
add [.mode7xpos],eax
movsx ebx,word[.cxloc]
movsx eax,word[mode7B]
mov [.mode7yadder],eax
imul eax,ebx
add [.mode7ypos],eax
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov edi,[vram]
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+32
mov ecx,128
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+32
.nomosaic
mov ebp,transpbuf+32
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
mov byte[.temp],0
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
test byte[mode7set],80h
jnz near .norep2
mov eax,[.mode7xpos]
and eax,7FFh
mov [.mode7xrpos],eax
mov eax,[.mode7ypos]
and eax,7FFh
mov [.mode7yrpos],eax
; get tile data offset into edi
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
shl ebx,5
shr eax,3
and ebx,07FF8h
shl al,1
mov bl,al
mov edi,[vram]
xor ch,ch
mov [.mode7ptr],ebx
mov cl,[edi+ebx]
shl ecx,7
add edi,ecx
.nextval
test byte[.mode7xrpos+1],08h
jnz near .rposoffx
.nextposx
test byte[.mode7yrpos+1],08h
jnz near .rposoffy
.nextposy
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov dl,[edi+edx]
sub [.mode7yrpos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextval
jmp .finishmode7
.rposoffx
mov al,[.mode7xinc]
mov edi,[vram]
add [.mode7ptr],al
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7xadd2]
shl ecx,7
sub [.mode7xrpos],eax
add edi,ecx
jmp .nextposx
.rposoffy
mov al,[.mode7yinc]
mov edi,[vram]
sub [.mode7ptr+1],al
and byte[.mode7ptr+1],7Fh
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7yadd2]
shl ecx,7
add [.mode7yrpos],eax
add edi,ecx
jmp .nextposy
.finishmode7
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
;**********************************************************
; Mode 7, no repetition mode
;**********************************************************
.norep2
test byte[mode7set],40h
jnz .tilerep2
.nextvalb2
cmp byte[.mode7ypos+2],3
ja .offscr2
cmp byte[.mode7xpos+2],3
jbe near .offscr3
.offscr2
mov eax,[.mode7xadder]
mov ebx,[.mode7yadder]
add [.mode7xpos],eax
sub [.mode7ypos],ebx
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextvalb2
jmp .finishmode7
.tilerep2
.nextvalb3
cmp byte[.mode7ypos+2],3
ja .offscr2b
cmp byte[.mode7xpos+2],3
jbe near .offscr3
.offscr2b
mov ch,[.mode7xpos+1]
mov eax,[.mode7xadder]
mov cl,[.mode7ypos+1]
mov ebx,[.mode7yadder]
mov dl,[mode7tab+ecx]
add [.mode7xpos],eax
mov dl,[vrama+edx]
sub [.mode7ypos],ebx
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextvalb3
jmp .finishmode7
.offscr3
mov eax,[.mode7xpos]
and eax,7FFh
mov [.mode7xrpos],eax
mov eax,[.mode7ypos]
and eax,7FFh
mov [.mode7yrpos],eax
; get tile data offset into edi
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
shl ebx,5
shr eax,3
and ebx,07FF8h
shl al,1
mov bl,al
mov edi,[vram]
xor ch,ch
mov [.mode7ptr],ebx
mov cl,[edi+ebx]
shl ecx,7
add edi,ecx
.nextvalr
test byte[.mode7xrpos+1],08h
jnz near .rposoffxr
.nextposxr
test byte[.mode7yrpos+1],08h
jnz near .rposoffyr
.nextposyr
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov dl,[edi+edx]
sub [.mode7yrpos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextvalr
jmp .finishmode7
.rposoffxr
mov al,[.mode7xinc]
mov edi,[vram]
add [.mode7ptr],al
jz .roff
cmp byte[.mode7ptr],0FEh
je .roff
.roffxretb
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7xadd2]
shl ecx,7
sub [.mode7xrpos],eax
add edi,ecx
jmp .nextposxr
.rposoffyr
mov al,[.mode7yinc]
mov edi,[vram]
sub [.mode7ptr+1],al
js .roff
.roffyretb
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7yadd2]
shl ecx,7
add [.mode7yrpos],eax
add edi,ecx
jmp .nextposyr
.roff
test byte[mode7set],40h
jnz .tilerep3
jmp .finishmode7
.tilerep3
and byte[.mode7yrpos+1],07h
and byte[.mode7xrpos+1],07h
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov dl,[vrama+edx]
sub [.mode7yrpos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .tilerep3
jmp .finishmode7
;**********************************************************
; Mode 7, old routines
;**********************************************************
.nextval3
test byte[mode7set],80h
jnz near .norep
.nextval2
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov dl,[edi+ecx]
sub [.mode7ypos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextval2
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
; Color repetition
.norep
test byte[mode7set],40h
jnz near .tilerep
.nextvalb
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
cmp byte[.mode7ypos+2],3
ja near .offscr
cmp byte[.mode7xpos+2],3
ja near .offscr
.offscrb
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov dl,[edi+ecx]
sub [.mode7ypos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextvalb
jmp .goon
.offscrc
cmp byte[.mode7ypos+2],3
ja .offscr
cmp byte[.mode7xpos+2],3
jbe near .offscrb
.offscr
mov eax,[.mode7xadder]
mov ebx,[.mode7yadder]
add [.mode7xpos],eax
sub [.mode7ypos],ebx
add esi,2
add ebp,2
dec byte[.temp]
jnz .offscrc
.goon
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
.tilerep
.nextvalbtr
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
cmp byte[.mode7ypos+2],3
ja near .offscrtr
cmp byte[.mode7xpos+2],3
ja near .offscrtr
.offscrtrb
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov dl,[edi+ecx]
sub [.mode7ypos],eax
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .nextvalbtr
jmp .goon
.offscrtrc
cmp byte[.mode7ypos+2],3
ja .offscrtr
cmp byte[.mode7xpos+2],3
jbe near .offscrtrb
.offscrtr
mov ch,[.mode7xpos+1]
mov eax,[.mode7xadder]
mov cl,[.mode7ypos+1]
mov ebx,[.mode7yadder]
mov dl,[mode7tab+ecx]
add [.mode7xpos],eax
mov dl,[vrama+edx]
sub [.mode7ypos],ebx
%1
add esi,2
add ebp,2
dec byte[.temp]
jnz near .offscrtrc
jmp .goon
ALIGN32
.temp dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dd 0 ; cx location
.cyloc dd 0 ; cy location
%endmacro
;*******************************************************
; Processes & Draws Mode 7 half Addition
;*******************************************************
NEWSYM drawmode716textbg
; test byte[scaddset],1
; jnz near drawmode7dcolor
mov esi,[cwinptr]
mov [winptrref],esi
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near drawmode716twinonextbg
.domosaic
test byte[scaddtype],80h
jnz near drawmode716tsubextbg
test byte[scaddtype],40h
jz near drawmode716tfulladdextbg
cmp byte[scrnon+1],0
je near drawmode716tfulladdextbg
cmp dword[coladdr],0
jnz near drawmode716tfulladdextbg
mode716tmacro mode7halfadd
;*******************************************************
; Processes & Draws Mode 7 Full Addition
;*******************************************************
NEWSYM drawmode716tfulladdextbg
mode716tmacro mode7fulladd
;**********************************************************
; Processes and draws Mode 7 subtract
;**********************************************************
drawmode716tsubextbg:
mode716tmacro mode7fullsub
;**********************************************************
; Mode 7, main & sub mode
;**********************************************************
NEWSYM drawmode716tbextbg
mode716tmacro mode7mainsub
;*******************************************************
; Processes & Draws Mode 7 half Addition, Window on
;*******************************************************
NEWSYM drawmode716twinonextbg
test byte[scaddtype],80h
jnz near drawmode716tsubwinonextbg
test byte[scaddtype],40h
jz near drawmode716tfulladdwinonextbg
cmp byte[scrnon+1],0
je near drawmode716tfulladdwinonextbg
cmp dword[coladdr],0
jnz near drawmode716tfulladdwinonextbg
mode716tmacro mode7halfaddwinon
;*******************************************************
; Processes & Draws Mode 7 Full Addition, Window on
;*******************************************************
NEWSYM drawmode716tfulladdwinonextbg
mode716tmacro mode7fulladdwinon
;**********************************************************
; Processes and draws Mode 7 subtract, Window on
;**********************************************************
NEWSYM drawmode716tsubwinonextbg
mode716tmacro mode7fullsubwinon
;**********************************************************
; Mode 7, main & sub mode, Window on
;**********************************************************
NEWSYM drawmode716tbwinonextbg
mode716tmacro mode7mainsubwinon
NEWSYM drawmode716textbg2
mov esi,[cwinptr]
mov [winptrref],esi
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov edi,[vram]
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+32
mov ecx,128
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+32
.nomosaic
mov edi,transpbuf+32
test byte[scaddtype],80h
jnz near extbg2sub
test byte[scaddtype],40h
jz near extbg2add
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near .drawwin
.domosaic
mov ecx,256
xor eax,eax
.loop
mov al,[esi+288*2]
test al,80h
jz .nopr2
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bcl+eax*4]
cmp dx,0
je .noadd
and ebx,[vesa2_clbit]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
.noadd
mov [esi],bx
.nopr2
add esi,2
add edi,2
loop .loop
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
.drawwin
mov ebp,[cwinptr]
mov byte[esi],cl
.nodrawbw
mov ecx,256
xor eax,eax
.loop2
mov al,[esi+288*2]
test byte[ebp],0FFh
jnz .nopr2b
test al,80h
jz .nopr2b
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bcl+eax*4]
cmp dx,0
je .noadd2
and ebx,[vesa2_clbit]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
.noadd2
mov [esi],bx
.nopr2b
add esi,2
add edi,2
inc ebp
loop .loop2
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
extbg2add:
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near .drawwin
.domosaic
mov ecx,256
xor eax,eax
.loop
mov al,[esi+288*2]
test al,80h
jz .nopr2
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bcl+eax*4]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
mov [esi],bx
.nopr2
add esi,2
add edi,2
loop .loop
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
.drawwin
mov ebp,[cwinptr]
mov byte[esi],cl
.nodrawbw
mov ecx,256
xor eax,eax
.loop2
mov al,[esi+288*2]
test byte[ebp],0FFh
jnz .nopr2b
test al,80h
jz .nopr2b
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bcl+eax*4]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
mov [esi],bx
.nopr2b
add esi,2
add edi,2
inc ebp
loop .loop2
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
extbg2sub:
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near .drawwin
.domosaic
mov ecx,256
xor eax,eax
.loop
mov al,[esi+288*2]
test al,80h
jz .nopr2
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bxcl+eax*4]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
xor ebx,0FFFFh
mov [esi],bx
.nopr2
add esi,2
add edi,2
loop .loop
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret
.drawwin
mov ebp,[cwinptr]
mov byte[esi],cl
.nodrawbw
mov ecx,256
xor eax,eax
.loop2
mov al,[esi+288*2]
test byte[ebp],0FFh
jnz .nopr2b
test al,80h
jz .nopr2b
and al,7Fh
mov edx,[edi]
mov ebx,[pal16bxcl+eax*4]
and edx,[vesa2_clbit]
add ebx,edx
shr ebx,1
mov ebx,[fulladdtab+ebx*2]
xor ebx,0FFFFh
mov [esi],bx
.nopr2b
add esi,2
add edi,2
inc ebp
loop .loop2
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic16b
ret


3085
zsnes/src/video/makev16b.asm Normal file

File diff suppressed because it is too large Load Diff

5313
zsnes/src/video/makev16t.asm Normal file

File diff suppressed because it is too large Load Diff

4386
zsnes/src/video/makevid.asm Normal file

File diff suppressed because it is too large Load Diff

818
zsnes/src/video/mode7.asm Normal file
View File

@@ -0,0 +1,818 @@
;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 mode7tab,winptrref,nglogicval,winlogicaval
EXTSYM curmosaicsz,curvidoffset,cwinptr,domosaic,mode7A,mode7B
EXTSYM mode7C,mode7D,mode7X0,mode7Y0,mode7set,vram,vrama,winon,xtravbuf
EXTSYM ngwinen, winbg1enval, BuildWindow, ngwintable, ngcwinptr, domosaicng
EXTSYM pesimpng
EXTSYM mode7hr
EXTSYM BGMA, mode7ab, mode7cd, BG1SYl, BG1SXl, mosenng, mosszng
%include "video/mode7.mac"
;*******************************************************
; Processes & Draws Mode 7
;*******************************************************
%macro Mode7Normal 0
or dl,dl
jz %%nodrawb
mov byte[esi],dl
%%nodrawb
inc esi
%endmacro
%macro Mode7Window 0
or dl,dl
jz %%nodrawbw
test byte[ebp],0FFh
jnz %%nodrawbw
mov byte[esi],dl
%%nodrawbw
inc esi
inc ebp
%endmacro
NEWSYM Makemode7Table
xor eax,eax
.nextentry
mov cl,al
mov dl,ah
and cl,07h
and dl,07h
shl cl,4
shl dl,1
inc dl
add dl,cl
mov [mode7tab+eax],dl
dec ax
jnz .nextentry
ret
;mode7tab times 65536 db 0
; backup mode7X0, mode7Y0, Mode7A, and Mode7B
NEWSYM drawmode7
mov esi,[cwinptr]
mov [winptrref],esi
Mode7Calculate
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near .drawmode7win
.domosaic
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Process Mode7Normal, domosaic, 1
.nextval3
Mode7ProcessB Mode7Normal, domosaic, 1
ALIGN32
.temp dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
.drawmode7win
.domosaicw
mov ebp,[cwinptr]
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3w
cmp dword[.mode7xadder],-7F0h
jl near .nextval3w
cmp dword[.mode7yadder],7F0h
jg near .nextval3w
cmp dword[.mode7yadder],-7F0h
jl near .nextval3w
Mode7Process Mode7Window, domosaic, 1
.nextval3w
Mode7ProcessB Mode7Window, domosaic, 1
NEWSYM drawmode7win
cmp byte[mode7hr+ebx],1
je near drawmode7winhr
ProcessBuildWindow 0
.nohr
mov esi,[cwinptr]
mov [winptrref],esi
Mode7Calculate
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov [pesimpng],esi
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
cmp byte[ngwinen],1
je near .drawmode7win
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Process Mode7Normal, domosaicng, 1
.nextval3
Mode7ProcessB Mode7Normal, domosaicng, 1
ALIGN32
.temp dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
.drawmode7win
.domosaicw
mov ebx,[.mode7xrpos]
mov [mode7xrpos],ebx
mov ebx,[.mode7yrpos]
mov [mode7yrpos],ebx
mov ebx,[.mode7xadder]
mov [mode7xadder],ebx
mov ebx,[.mode7yadder]
mov [mode7yadder],ebx
mov ebx,[.mode7xpos]
mov [mode7xpos],ebx
mov ebx,[.mode7ypos]
mov [mode7ypos],ebx
mov edi,[vram]
Mode7Processngw Mode7Normal, domosaicng, 1
NEWSYM drawmode7winB
cmp byte[mode7hr+ebx],1
je near drawmode7winBhr
ProcessBuildWindow 0
.nohr
mov esi,[cwinptr]
mov [winptrref],esi
Mode7CalculateB
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
cmp byte[ngwinen],1
je near .drawmode7win
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Process Mode7Normal, domosaic, 1
.nextval3
Mode7ProcessB Mode7Normal, domosaic, 1
ALIGN32
.temp dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
.drawmode7win
.domosaicw
mov ebx,[.mode7xrpos]
mov [mode7xrpos],ebx
mov ebx,[.mode7yrpos]
mov [mode7yrpos],ebx
mov ebx,[.mode7xpos]
mov [mode7xpos],ebx
mov ebx,[.mode7ypos]
mov [mode7ypos],ebx
mov ebx,[.mode7xadder]
mov [mode7xadder],ebx
mov ebx,[.mode7yadder]
mov [mode7yadder],ebx
mov edi,[vram]
Mode7Processngw Mode7Normal, domosaic, 1
NEWSYM drawmode7winhr
ProcessBuildWindow 0
cmp byte[ngwinen],1
jne .notwinen
mov byte[mode7hr+ebx],0
jmp drawmode7win.nohr
.notwinen
mov esi,[cwinptr]
mov [winptrref],esi
Mode7Calculate
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov [pesimpng],esi
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
sar dword[.mode7xadder],1
sar dword[.mode7yadder],1
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Processhr Mode7Normal, domosaicng, 1
.nextval3
Mode7ProcessBhr Mode7Normal, domosaicng, 1
ALIGN32
.temp dd 0 ; for byte move left
.temp2 dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
NEWSYM drawmode7winBhr
ProcessBuildWindow 0
cmp byte[ngwinen],1
jne .notwinen
mov byte[mode7hr+ebx],0
jmp drawmode7winB.nohr
.notwinen
mov esi,[cwinptr]
mov [winptrref],esi
Mode7CalculateB
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
sar dword[.mode7xadder],1
sar dword[.mode7yadder],1
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Processhr Mode7Normal, domosaic, 1
.nextval3
Mode7ProcessBhr Mode7Normal, domosaic, 1
ALIGN32
.temp dd 0 ; for byte move left
.temp2 dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
ALIGN32
NEWSYM ngwleft, dd 0 ; for byte move left
NEWSYM ngwleftb, dd 0 ; for byte move left
NEWSYM mode7xpos, dd 0,0 ; x position
NEWSYM mode7ypos, dd 0,0 ; x position
NEWSYM mode7xrpos, dd 0,0 ; x position, relative
NEWSYM mode7yrpos, dd 0,0 ; y position, relative
NEWSYM mode7xadder, dd 0,0 ; number to add for x
NEWSYM mode7yadder, dd 0,0 ; number to add for y
NEWSYM ProcessMode7ngwin
mov ecx,[ngcwinptr]
mov ecx,[ecx]
or ecx,ecx
jz near .winb
cmp ecx,[ngwleft]
jae .alldisplay
sub [ngwleft],ecx
mov dword[ngwleftb],ecx
xor ecx,ecx
mov eax,[mode7xrpos]
ret
.alldisplay
mov ecx,[ngwleft]
mov dword[ngwleftb],ecx
mov dword[ngwleft],0
xor ecx,ecx
mov eax,[mode7xrpos]
ret
.winb
NEWSYM ProcessMode7ngwinB
add dword[ngcwinptr],4
mov ecx,[ngcwinptr]
mov ecx,[ecx]
cmp ecx,[ngwleft]
jae near .finishmode7
sub [ngwleft],ecx
or ecx,ecx
jz .noclip
.nextvalngw
mov eax,[mode7xadder]
add [mode7xrpos],eax
mov eax,[mode7yadder]
sub [mode7yrpos],eax
inc esi
dec ecx
jnz near .nextvalngw
.noclip
add dword[ngcwinptr],4
jmp ProcessMode7ngwin
.finishmode7
mov dword[ngwleft],0
mov dword[ngwleftb],0
ret
NEWSYM ProcessMode7ngwinC
mov ecx,[ngcwinptr]
mov ecx,[ecx]
or ecx,ecx
jz near .winb
cmp ecx,[ngwleft]
jae .alldisplay
sub [ngwleft],ecx
mov dword[ngwleftb],ecx
xor ecx,ecx
mov eax,[mode7xpos]
ret
.alldisplay
mov ecx,[ngwleft]
mov dword[ngwleftb],ecx
mov dword[ngwleft],0
xor ecx,ecx
mov eax,[mode7xpos]
ret
.winb
NEWSYM ProcessMode7ngwinD
add dword[ngcwinptr],4
mov ecx,[ngcwinptr]
mov ecx,[ecx]
cmp ecx,[ngwleft]
jae near .finishmode7
sub [ngwleft],ecx
or ecx,ecx
jz .noclip
.nextvalngw
mov eax,[mode7xadder]
add [mode7xpos],eax
mov eax,[mode7yadder]
sub [mode7ypos],eax
inc esi
dec ecx
jnz near .nextvalngw
.noclip
add dword[ngcwinptr],4
jmp ProcessMode7ngwin
.finishmode7
mov dword[ngwleft],0
mov dword[ngwleftb],0
ret
%macro newvaluepred 2
mov dx,word[%1+ebx*4+8]
cmp dx,word[%1+ebx*4]
je %%nodivide
cmp byte[BGMA+ebx+2],7
je %%mode7scaleb
%%nodivide
movsx edx,word[%1+ebx*4+4]
movsx ecx,word[%1+ebx*4]
add ecx,edx
sar ecx,1
mov [%2],cx
jmp %%mode7scalend
%%mode7scaleb
mov esi,ebx
movsx ebx,word[%1+esi*4+8]
movsx edx,word[%1+esi*4]
sub ebx,edx
movsx ecx,word[%1+esi*4+4]
sub ecx,edx
mov eax,ecx
imul ecx
idiv ebx
add ax,word[%1+esi*4]
mov ebx,esi
mov [%2],ax
%%mode7scalend
%endmacro
NEWSYM processmode7hires
cmp byte[BGMA+ebx+1],7
jne near .nogo
push esi
push ebx
; predict new values
push eax
push edx
push ebx
push esi
newvaluepred mode7ab,mode7A
newvaluepred mode7ab+2,mode7B
newvaluepred mode7cd,mode7C
newvaluepred mode7cd+2,mode7D
pop esi
pop ebx
pop edx
pop eax
mov ecx,edx
xor edx,edx
mov dx,[BG1SXl+ebx*2+2]
add edx,ecx
shr edx,1
mov ecx,eax
mov eax,ebx
inc eax
test byte[mode7set],02h
jz .noflip
mov eax,261
sub eax,ebx
.noflip
add ax,[BG1SYl+ebx*2+2]
add eax,ecx
add esi,75036
mov [curvidoffset],esi
call drawmode7winB
pop ebx
pop esi
.nogo
ret


1563
zsnes/src/video/mode7.mac Normal file

File diff suppressed because it is too large Load Diff

687
zsnes/src/video/mode716.asm Normal file
View File

@@ -0,0 +1,687 @@
;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 mode7tab,winptrref,nglogicval,winlogicaval
EXTSYM curmosaicsz,curvidoffset,cwinptr,domosaic,mode7A,mode7B
EXTSYM mode7C,mode7D,mode7X0,mode7Y0,mode7set,vram,vrama,winon,xtravbuf
EXTSYM ngwleft,ngwleftb,mode7xpos,mode7ypos,mode7xrpos,mode7yrpos
EXTSYM mode7xadder,mode7yadder,mode7hr,drawmode7winhr,dcolortab
EXTSYM UnusedBitXor,UnusedBit
EXTSYM scrndis
EXTSYM vidbright,prevbrightdc,Gendcolortable
EXTSYM mode7ab,mode7cd,BGMA
EXTSYM BG1SXl,BG1SYl
EXTSYM processmode7hires
%include "video/mode716.mac"
;*******************************************************
; Processes & Draws Mode 7
;*******************************************************
%macro Mode7Normal 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalnt 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalt 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2+512]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalmsnt 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalmst 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2+512]
mov [esi],dx
and dx,[UnusedBitXor]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalsnt 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Normalst 0
or dl,dl
jz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Direct 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directnt 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directt 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
or dx,[UnusedBit]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directmsnt 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi],dx
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directmst 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi+75036*2],dx
or dx,[UnusedBit]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directsnt 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7Directst 0
or dl,dl
jz %%nodrawb
mov dx,[dcolortab+edx*4]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBG 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGnt 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGt 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2+512]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGmsnt 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi],dx
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGmst 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2+512]
mov [esi+75036*2],dx
or dx,[UnusedBit]
mov [esi],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGsnt 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
%macro Mode7ExtBGst 0
mov [esi+75036*8],dl
or dl,dl
jz %%nodrawb
test dl,80h
jnz %%nodrawb
mov dx,[ebp+edx*2]
mov [esi+75036*2],dx
xor edx,edx
%%nodrawb
add esi,2
%endmacro
NEWSYM drawmode7win16b
test byte[scrndis],1
jz .notdisabled
ret
.notdisabled
CheckTransparency 01h,drawmode7win16bt
normal
Mode7NonMainSub Mode7Normal
drawmode7win16bt
test byte[scadtng+ebx],1h
jz near drawmode7win16bnt
test byte[BGMS1+ebx*2+1],1h
jnz near drawmode716bmst
Mode7NonMainSub Mode7Normalt
drawmode716bmst:
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmt
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bst
drawmode7w16bmst
Mode7NonMainSub Mode7Normalmst
drawmode7w16bmt
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmst
Mode7MainSub Mode7Normalmst,Mode7Normalst
drawmode7w16bst
Mode7MainSub Mode7Normalmst,Mode7Normalt
drawmode7win16bnt:
test byte[BGMS1+ebx*2+1],1h
jnz near drawsprngm716bmsnt
Mode7NonMainSub Mode7Normalnt
drawsprngm716bmsnt:
cmp dword[ngwinen],0
je drawmode7w16bmsnt
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmnt
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bsnt
drawmode7w16bmsnt
Mode7NonMainSub Mode7Normalmsnt
drawmode7w16bmnt
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmsnt
Mode7MainSub Mode7Normalmsnt,Mode7Normalsnt
drawmode7w16bsnt
Mode7MainSub Mode7Normalmsnt,Mode7Normalnt
NEWSYM drawmode7win16bd
test byte[scrndis],1
jz .notdisabled
ret
.notdisabled
mov bl,[vidbright]
cmp bl,[prevbrightdc]
je .nodcchange
mov [prevbrightdc],bl
call Gendcolortable
.nodcchange
CheckTransparency 01h,drawmode7win16btd
Mode7NonMainSub Mode7Direct
drawmode7win16btd
test byte[scadtng+ebx],1h
jz near drawmode7win16bntd
test byte[BGMS1+ebx*2+1],1h
jnz near drawmode716bmstd
Mode7NonMainSub Mode7Directt
drawmode716bmstd:
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmtd
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bstd
drawmode7w16bmstd
Mode7NonMainSub Mode7Directmst
drawmode7w16bmtd
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmstd
Mode7MainSub Mode7Directmst,Mode7Directst
drawmode7w16bstd
Mode7MainSub Mode7Directmst,Mode7Directt
drawmode7win16bntd:
test byte[BGMS1+ebx*2+1],1h
jnz near drawsprngm716bmsntd
Mode7NonMainSub Mode7Directnt
drawsprngm716bmsntd:
cmp dword[ngwinen],0
je drawmode7w16bmsntd
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmntd
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bsntd
drawmode7w16bmsntd
Mode7NonMainSub Mode7Directmsnt
drawmode7w16bmntd
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmsntd
Mode7MainSub Mode7Directmsnt,Mode7Directsnt
drawmode7w16bsntd
Mode7MainSub Mode7Directmsnt,Mode7Directnt
NEWSYM drawmode7ngextbg16b
test byte[scrndis],1
jz .notdisabled
ret
.notdisabled
mov byte[curmosaicsz],1
push ecx
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov ecx,256
.loop
mov byte[esi+75036*8],0
add esi,2
loop .loop
pop ecx
cmp byte[mode7hr+ebx],1
; je near drawmode7winextbghr16e
CheckTransparency 02h,drawmode7win16bte
mov esi,[cwinptr]
mov [winptrref],esi
mov esi,[curvidoffset]
Mode7NonMainSube Mode7ExtBG
drawmode7win16bte
test byte[scadtng+ebx],1h
jz near drawmode7win16bnte
test byte[BGMS1+ebx*2+1],1h
jnz near drawmode716bmste
Mode7NonMainSube Mode7ExtBGt
drawmode716bmste:
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmte
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bste
drawmode7w16bmste
Mode7NonMainSube Mode7ExtBGmst
drawmode7w16bmte
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmste
Mode7MainSube Mode7ExtBGmst,Mode7ExtBGst
drawmode7w16bste
Mode7MainSube Mode7ExtBGmst,Mode7ExtBGt
drawmode7win16bnte:
test byte[BGMS1+ebx*2+1],1h
jnz near drawsprngm716bmsnte
Mode7NonMainSube Mode7ExtBGnt
drawsprngm716bmsnte:
cmp dword[ngwinen],0
je drawmode7w16bmsnte
mov edi,[CMainWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmnte
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bsnte
drawmode7w16bmsnte
Mode7NonMainSube Mode7ExtBGmsnt
drawmode7w16bmnte
mov edi,[CSubWinScr]
cmp byte[edi+ebx],0
jne near drawmode7w16bmsnte
Mode7MainSube Mode7ExtBGmsnt,Mode7ExtBGsnt
drawmode7w16bsnte
Mode7MainSube Mode7ExtBGmsnt,Mode7ExtBGnt
%macro ExtBG2 1
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
mov ecx,256
xor eax,eax
.loop
mov al,[esi+75036*8]
test al,80h
jz .nopr2
and al,7Fh
%1
.nopr2
add esi,2
loop .loop
xor eax,eax
ret
%endmacro
%macro ExtBGNormal 0
mov dx,[ebp+eax*2]
mov [esi],dx
%endmacro
%macro ExtBGNormalt 0
mov dx,[ebp+eax*2+512]
mov [esi],dx
%endmacro
%macro ExtBGNormalnt 0
mov dx,[ebp+eax*2]
mov [esi],dx
%endmacro
%macro ExtBGNormalst 0
mov dx,[ebp+eax*2]
mov [esi+75036*2],dx
%endmacro
%macro ExtBGNormalsnt 0
mov dx,[ebp+eax*2]
mov [esi+75036*2],dx
%endmacro
%macro ExtBGNormalmst 0
mov dx,[ebp+eax*2+512]
mov [esi],dx
and dx,[UnusedBitXor]
mov [esi+75036*2],dx
%endmacro
%macro ExtBGNormalmsnt 0
mov dx,[ebp+eax*2]
mov [esi],dx
mov [esi+75036*2],dx
%endmacro
NEWSYM drawmode7ngextbg216b
test byte[scrndis],1
jz .notdisabled
ret
.notdisabled
cmp byte[mode7hr+ebx],1
; je near drawmode7winextbg2hr16b
; esi = pointer to video buffer
CheckTransparency 01h,drawmode7ngextbg216bt
test byte[FillSubScr+ebx],1
jz .main
test byte[BGMS1+ebx*2],01h
jnz .main
add esi,75036*2
.main
ExtBG2 ExtBGNormal
drawmode7ngextbg216bt:
test byte[scadtng+ebx],1h
jz near drawmode7ngextbg216bnt
test byte[BGMS1+ebx*2+1],1h
jnz near drawmode7ngextbg216bmst
ExtBG2 ExtBGNormalt
drawmode7ngextbg216bmst
test byte[BGMS1+ebx*2],1h
jz near drawmode7ngextbg216bst
ExtBG2 ExtBGNormalmst
drawmode7ngextbg216bst:
ExtBG2 ExtBGNormalst
drawmode7ngextbg216bnt:
test byte[BGMS1+ebx*2+1],1h
jnz near drawmode7ngextbg216bmsnt
ExtBG2 ExtBGNormalnt
drawmode7ngextbg216bmsnt
test byte[BGMS1+ebx*2],1h
jz near drawmode7ngextbg216bsnt
ExtBG2 ExtBGNormalmsnt
drawmode7ngextbg216bsnt:
ExtBG2 ExtBGNormalsnt
ALIGN32
mtemp dd 0 ; for byte move left
mmode7xpos dd 0 ; x position
mtempa2 dd 0 ; keep this blank!
mmode7xrpos dd 0 ; x position
mtempa dd 0 ; keep this blank!
mmode7ypos dd 0 ; y position
mtempb2 dd 0 ; keep this blank!
mmode7yrpos dd 0 ; y position
mtempb dd 0 ; keep this blank!
mmode7xadder dd 0 ; number to add for x
mtempc2 dd 0 ; keep this blank!
mmode7xadd2 dd 0 ; number to add for x
mtempc dd 0 ; keep this blank!
mmode7yadder dd 0 ; number to add for y
mtempd2 dd 0 ; keep this blank!
mmode7yadd2 dd 0 ; number to add for y
mtempd dd 0 ; keep this blank!
mmode7ptr dd 0 ; pointer value
mmode7xinc dd 0 ; number to add for x
mmode7xincc dd 0 ; range check for x
mmode7yinc dd 0 ; number to add for y
mmode7xsloc dd 0 ; which screen x
mmode7ysloc dd 0 ; which screen y
mmode7xsrl dd 0 ; which relative screen x
mmode7ysrl dd 0 ; which relative screen y
mcxloc dw 0 ; cx location
mcyloc dw 0 ; cy location
M7HROn dd 0 ; High Resolution On
switchtorep3 dd 0
m7xaddof dd 0
m7xaddof2 dd 0
m7yaddof dd 0
m7yaddof2 dd 0
pixelsleft dd 0
mm7xaddof dd 0
mm7xaddof2 dd 0
mm7yaddof dd 0
mm7yaddof2 dd 0
%macro newvaluepred 2
mov dx,word[%1+ebx*4+8]
cmp dx,word[%1+ebx*4]
je %%nodivide
cmp byte[BGMA+ebx+2],7
je %%mode7scaleb
%%nodivide
movsx edx,word[%1+ebx*4+4]
movsx ecx,word[%1+ebx*4]
add ecx,edx
sar ecx,1
mov [%2],cx
jmp %%mode7scalend
%%mode7scaleb
mov esi,ebx
movsx ebx,word[%1+esi*4+8]
movsx edx,word[%1+esi*4]
sub ebx,edx
movsx ecx,word[%1+esi*4+4]
sub ecx,edx
mov eax,ecx
imul ecx
idiv ebx
add ax,word[%1+esi*4]
mov ebx,esi
mov [%2],ax
%%mode7scalend
%endmacro
CalculateNewValues:
; predict new values
push eax
push edx
push ebx
push esi
newvaluepred mode7ab,mode7A
newvaluepred mode7ab+2,mode7B
newvaluepred mode7cd,mode7C
newvaluepred mode7cd+2,mode7D
pop esi
pop ebx
pop edx
pop eax
mov ecx,edx
xor edx,edx
mov dx,[BG1SXl+ebx*2+2]
add edx,ecx
shr edx,1
mov ecx,eax
mov eax,ebx
inc eax
test byte[mode7set],02h
jz .noflip
mov eax,261
sub eax,ebx
.noflip
add ax,[BG1SYl+ebx*2+2]
add eax,ecx
ret
NEWSYM processmode7hires16b
cmp byte[BGMA+ebx+1],7
jne near .nogo
push esi
push ebx
call CalculateNewValues
add esi,75036*4
mov [curvidoffset],esi
mov dword[M7HROn],1
call drawmode7win16b
mov dword[M7HROn],0
pop ebx
pop esi
.nogo
ret
NEWSYM processmode7hires16bd
cmp byte[BGMA+ebx+1],7
jne near .nogo
push esi
push ebx
call CalculateNewValues
add esi,75036*4
mov [curvidoffset],esi
mov dword[M7HROn],1
call drawmode7win16bd
mov dword[M7HROn],0
pop ebx
pop esi
.nogo
ret


Some files were not shown because too many files have changed in this diff Show More