mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-11 14:12:26 -05:00
Initial commit of zxbox - a ZX Spectrum emulator ported by Anton Romanov. It theoretically runs on all targets, but I have not included it in the Archos builds because it is just too slow to be usable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10950 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1350d57751
commit
05a7f14f8d
88 changed files with 19624 additions and 0 deletions
|
|
@ -19,6 +19,11 @@ chessbox
|
|||
sudoku
|
||||
#endif
|
||||
|
||||
/* For all 2bpp and colour targets */
|
||||
#if (LCD_DEPTH >= 2)
|
||||
zxbox
|
||||
#endif
|
||||
|
||||
/* For all the colour targets and iriver H1x0 */
|
||||
#if defined(HAVE_LCD_COLOR) || defined(IRIVER_H100_SERIES)
|
||||
pacbox
|
||||
|
|
|
|||
|
|
@ -23,3 +23,7 @@ wav,viewers/wavplay,60 7F 05 35 3F 00
|
|||
bmp,rocks/rockpaint, 01 10 01 10 01 10
|
||||
m2v,viewers/mpegplayer,5D 7F 5D 7F 5D 7F
|
||||
iriver,viewers/iriver_flash,2A 7F 41 41 7F 2A
|
||||
tap,viewers/zxbox,66 52 4A 66 52 4A
|
||||
sna,viewers/zxbox,66 52 4A 66 52 4A
|
||||
tzx,viewers/zxbox,66 52 4A 66 52 4A
|
||||
z80,viewers/zxbox,66 52 4A 66 52 4A
|
||||
|
|
|
|||
31
apps/plugins/zxbox.c
Normal file
31
apps/plugins/zxbox.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Overlay loader stub plugin for zxbox on Archos
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
#if MEM <= 8 && !defined(SIMULATOR)
|
||||
|
||||
#include "overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||
{
|
||||
return run_overlay(api, parameter, "/.rockbox/viewers/zxbox.ovl", "ZXBox");
|
||||
}
|
||||
#endif
|
||||
339
apps/plugins/zxbox/COPYING
Normal file
339
apps/plugins/zxbox/COPYING
Normal file
|
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, 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) 19yy <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., 675 Mass Ave, Cambridge, MA 02139, 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) 19yy 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.
|
||||
193
apps/plugins/zxbox/ChangeLog
Normal file
193
apps/plugins/zxbox/ChangeLog
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
04.09.2006 code cleanup; now using IRAM correctly (i hope)
|
||||
|
||||
31.08.2006 far better sound, volume option is working now
|
||||
|
||||
29.08.2006 predefined keymaps, menu reworking, volume settings
|
||||
|
||||
28.08.2006 more options : frame-skipping, sound on/off, toggle 'fast' mode
|
||||
28.08.2006 output actual speed of emulation in percent rather than number of rendered frames
|
||||
28.08.2006 timing implementation (no >100 % speed in sims)
|
||||
|
||||
|
||||
15.08.2006 output FPS on screen when in buffered and into logf when in unbuffered mode (grayscale)
|
||||
|
||||
|
||||
15.08.2006 buffered mode when in grayscale mode
|
||||
|
||||
11.08.2006 support for grayscale lib
|
||||
|
||||
05/2006 - edited by Anton Romanov for
|
||||
RockBox - http://www.rockbox.org
|
||||
with the help of Dave Chapman and Szeredi Miklos
|
||||
|
||||
|
||||
98/05/18 Version 0.94 released
|
||||
===============================
|
||||
|
||||
98/05/18 Updated the man page (a more complete man-page is still needed!)
|
||||
98/05/15 Some bugs fixed
|
||||
|
||||
98/05/14 Version 0.93.4 released
|
||||
--------------------------------
|
||||
|
||||
98/05/14 Small additions:
|
||||
- Keyboard matrix is emulated (only 1 level, I hope this is enough)
|
||||
- "color refreshing" (maybe some other aplications could do it!)
|
||||
- Keyboard configuration is now fully implemented
|
||||
|
||||
98/05/11 Added DOS timer support with Allegro library
|
||||
|
||||
98/05/08 Version 0.93.3 released
|
||||
---------------------------------
|
||||
|
||||
98/05/08 Created README.Z80 to describe how to use Z80 emulation
|
||||
98/05/06 Small new features + bugfixes
|
||||
- Function keys for commonly used functions
|
||||
- Keyboard config: (extended, spectrum, compat) and (shifted, raw)
|
||||
are now working. No custom keyboard or joystick yet
|
||||
- Small modifications to make z80 emulation separate
|
||||
|
||||
98/04/30 Version 0.93.2 released
|
||||
---------------------------------
|
||||
|
||||
98/04/30 I've removed the BROKEN_VGAKEYBOARD part from vgakey.c.
|
||||
I hope nobody's using SVGALIB version smaller than 1.2.11.
|
||||
|
||||
98/04/29 Some small new features: (see example.cfg for a complete list)
|
||||
- different icon when the emulator is paused
|
||||
- optional private colormap
|
||||
- configurable colours (grayscale looks better on
|
||||
monochrome displays)
|
||||
- filetype can be given on the command line (tapefiles too)
|
||||
- optional immediate loading of tapes (-load-immed)
|
||||
|
||||
98/04/27 Added configurability to spectemu:
|
||||
- global config file (($prefix)/share/spectemu/spectemu.cfg)
|
||||
- user's config file (~/.spectemurc)
|
||||
- X resource database
|
||||
- command line
|
||||
|
||||
98/04/23 Mode 320x240 is used in vgaspect (if available)
|
||||
|
||||
98/04/22 Version 0.93.1 released
|
||||
---------------------------------
|
||||
|
||||
98/04/21 Handle "extra" ascii keys: []{}|\~
|
||||
98/04/19 Added Spectrum keyboard picture, which shows pressed keys, and
|
||||
keys can be pressed with mouse.
|
||||
98/04/16 Rewrite keyboard handling:
|
||||
- Fixes keyboard bug in X (key remained pressed)
|
||||
- Better configurability: spectrum key definitions are in spkey.c
|
||||
instead of xkey.c and vgakey.c
|
||||
|
||||
98/04/07 Added readline support by Christian Sievers <sievers@cip.rz.tu-bs.de>
|
||||
|
||||
98/03/24 Version 0.92 released
|
||||
===============================
|
||||
|
||||
98/03/23 Last minute bugfixes
|
||||
|
||||
98/03/20 Version 0.92p3 released
|
||||
98/03/20 Eliminated all sorts of minor bugs
|
||||
98/03/19 Implement LOOP/CALL/RETURN blocks in TZX handling
|
||||
98/03/17 Fixed (hopefully all) bugs in TZX handling:
|
||||
- There must be a 1ms pause at end of tape.
|
||||
- Pausing after data blocks fixed.
|
||||
- Made tape I/O timing ultra precise (e.g. see Flashpoint)
|
||||
|
||||
98/03/14 Fixed small bug in quick load
|
||||
98/03/13 Sound of tape is now fixed (not perfect, but good enough)
|
||||
Created simple man page
|
||||
|
||||
98/03/11 Version 0.92pre2 released
|
||||
98/03/10 Fixed quick load of tapefiles
|
||||
98/03/10 Fixed resize bugs
|
||||
|
||||
98/03/09 Version 0.92pre1 released
|
||||
98/03/08 C-version now handles bits 3 and 5 of the Flag register
|
||||
(I hope I didn't break anything with this).
|
||||
98/03/08 Wrote 'tapeout' utility to save tapefiles to real tape (via
|
||||
soundcard).
|
||||
|
||||
98/03/06 Implemented emulator pause.
|
||||
98/03/06 Added ability to display spectrum keyboard layout on text
|
||||
console (Radovan.Garabik@fmph.uniba.sk).
|
||||
|
||||
98/03/05 Rewrite of snapshot handeling:
|
||||
- All versions of Z80 snapshots can now be loaded.
|
||||
- Loading and saving of SNA snapshot format is supported.
|
||||
- Quick loading and saving of temporary snapshot.
|
||||
|
||||
98/03/03 Rewrite of tapefile handeling:
|
||||
- Support for most TZX blocks (recognise length of all v1.11
|
||||
blocks)
|
||||
- SPT tapefiles are no longer supported
|
||||
- Added quick loading of tapefiles
|
||||
- Timing in tape emulation is very exact now, but this makes
|
||||
tape sound ugly (this will be fixed).
|
||||
|
||||
98/01/28 Version 0.91a released
|
||||
98/01/26 Added detection for underlines in asm names to configure
|
||||
|
||||
98/01/12 Version 0.91 released
|
||||
===============================
|
||||
|
||||
98/01/08 Changes to configure to detect X libraries better
|
||||
|
||||
97/11/29 Use XSetWMProperties instead of XmbSetWMProperties
|
||||
97/11/26 Created icon for xspect
|
||||
97/11/20 IO and memory timing are improved (ULA / CPU clash)
|
||||
|
||||
97/11/18 Fixed 0xfe port problems
|
||||
97/11/17 Input from unused ports (others than 0xFE) result in 0xFF, not 0x00
|
||||
|
||||
97/11/12 8000 sample/sec sound on SUN
|
||||
97/11/12 Fixed screen bugs
|
||||
|
||||
97/11/11 Window resizing in X (thanks to Egmont)
|
||||
97/11/11 Fixed FocusIn/FocusOut bug (twm, olwm, ...)
|
||||
97/11/11 Small changes and bugfixes
|
||||
|
||||
97/11/09 Sound on SUN (sample rate 16000, but 8000 is coming for older
|
||||
SUNs.
|
||||
|
||||
97/10/26 'Interrupted system call' is not an error on sound device
|
||||
97/10/26 Fixed screen scramble bug in console background running
|
||||
|
||||
97/10/20 Version 0.90pre1 released
|
||||
|
||||
97/10/20 Tested on the following Machines/Operating systems/Compilers:
|
||||
o Intel/Linux/gcc (assembly)
|
||||
o Sparc/Solaris/gcc (C)
|
||||
o Alpha/OSF1/cc (C)
|
||||
o Sequent(i486)/Dynix-Ptx/gcc (assembly)
|
||||
|
||||
97/10/20 Automatic configuration with 'configure' script
|
||||
97/10/20 Bugfixes and cleanups
|
||||
97/10/20 Experimental DOS support with DJGPP (timer missing)
|
||||
97/10/20 Added emulation in C
|
||||
97/05/22 Background running for svgalib added (Needs svgalib >= 1.2.11)
|
||||
|
||||
97/04/17 Version 0.84 released
|
||||
===============================
|
||||
|
||||
97/04/17 Added SLL to the emulated instructions
|
||||
|
||||
97/04/12 The following changes were inspired by Egmont Koblinger:
|
||||
- Resize bug fixed
|
||||
- Implemented tape file pause
|
||||
- Implemented saving to tape file
|
||||
- Snapshot loading from command line
|
||||
- Other small changes
|
||||
|
||||
97/04/03 Bug fix in tape handling (thanks to Egmont Koblinger)
|
||||
97/03/26 Speeded up border drawing in X
|
||||
97/03/26 Added .TAP support
|
||||
|
||||
97/03/10 Version 0.81 released
|
||||
===============================
|
||||
|
||||
97/03/10 Bug fixes and minor changes (thanks to Tamas Meszaros)
|
||||
|
||||
97/01/21 Version 0.8: First public release
|
||||
===========================================
|
||||
89
apps/plugins/zxbox/Makefile
Normal file
89
apps/plugins/zxbox/Makefile
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# __________ __ ___.
|
||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
# \/ \/ \/ \/ \/
|
||||
#
|
||||
|
||||
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
|
||||
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -I. $(TARGET_INC)
|
||||
CFLAGS = $(INCLUDES) $(GCCOPTS) -O2 $(TARGET) $(EXTRA_DEFINES) \
|
||||
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
|
||||
|
||||
|
||||
ifdef APPEXTRA
|
||||
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
|
||||
endif
|
||||
|
||||
LINKFILE := $(OBJDIR)/link.lds
|
||||
DEPFILE = $(OBJDIR)/dep-zxbox
|
||||
|
||||
# This sets up 'SRC' based on the files mentioned in SOURCES
|
||||
include $(TOOLSDIR)/makesrc.inc
|
||||
|
||||
SOURCES = $(SRC)
|
||||
OBJS2 := $(SRC:%.c=$(OBJDIR)/%.o)
|
||||
OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2))
|
||||
DIRS = .
|
||||
|
||||
ifndef SIMVER
|
||||
ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET)))))
|
||||
LDS := archos.lds
|
||||
OUTPUT = $(OUTDIR)/zxbox.ovl
|
||||
else ## iRiver/iPod/... targets
|
||||
LDS := ../plugin.lds
|
||||
OUTPUT = $(OUTDIR)/zxbox.rock
|
||||
endif
|
||||
else ## simulators
|
||||
OUTPUT = $(OUTDIR)/zxbox.rock
|
||||
endif
|
||||
|
||||
all: $(OUTPUT)
|
||||
|
||||
ifndef SIMVER
|
||||
$(OBJDIR)/zxbox.elf: $(OBJS) $(LINKFILE)
|
||||
@echo "LD "`basename $@`
|
||||
@$(CC) $(GCCOPTS) -O -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \
|
||||
-T$(LINKFILE) -Wl,-Map,$(OBJDIR)/zxbox.map
|
||||
|
||||
$(OUTPUT): $(OBJDIR)/zxbox.elf
|
||||
@echo "OBJCOPY "`basename $@`
|
||||
@$(OC) -O binary $< $@
|
||||
else
|
||||
|
||||
ifeq ($(SIMVER), sdl)
|
||||
###################################################
|
||||
# This is the SDL simulator version
|
||||
|
||||
$(OUTPUT): $(OBJS)
|
||||
@echo "LD $<"
|
||||
@$(CC) $(CFLAGS) -shared $(OBJS) -L$(BUILDDIR) -lplugin -o $@
|
||||
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
|
||||
# 'x' must be kept or you'll have "Win32 error 5"
|
||||
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
|
||||
# #define ERROR_ACCESS_DENIED 5L
|
||||
else
|
||||
@chmod -x $@
|
||||
endif
|
||||
|
||||
endif
|
||||
endif # end of simulator section
|
||||
|
||||
|
||||
include $(TOOLSDIR)/make.inc
|
||||
|
||||
# MEMORYSIZE should be passed on to this makefile with the chosen memory size
|
||||
# given in number of MB
|
||||
$(LINKFILE): $(LDS)
|
||||
@echo "build "`basename $@`
|
||||
@cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) \
|
||||
$(DEFINES) -E -P - >$@
|
||||
|
||||
clean:
|
||||
@echo "cleaning zxbox"
|
||||
@rm -rf $(OBJDIR)/zxbox
|
||||
@rm -f $(OBJDIR)/zxbox.* $(DEPFILE)
|
||||
|
||||
-include $(DEPFILE)
|
||||
|
||||
770
apps/plugins/zxbox/README
Normal file
770
apps/plugins/zxbox/README
Normal file
|
|
@ -0,0 +1,770 @@
|
|||
|
||||
* * * * * * * * * * * * * * *
|
||||
* *
|
||||
* S P E C T E M U *
|
||||
* *
|
||||
* Version 0.94 *
|
||||
* *
|
||||
* * * * * * * * * * * * * * *
|
||||
|
||||
|
||||
This package contains a 48k ZX-Spectrum emulator for Linux and other
|
||||
UNIX operating systems, with full Z80 instruction set, comprehensive
|
||||
screen, sound and tape emulation, and snapshot file saving and
|
||||
loading. It can run on a Linux console, or in an X11 window.
|
||||
|
||||
The program is free software and is copyrighted under the GNU General
|
||||
Public License. It comes with absolutely no warranty. See the file
|
||||
COPYING for details.
|
||||
|
||||
Written by Miklos Szeredi
|
||||
Email: mszeredi@inf.bme.hu
|
||||
|
||||
It can be downloaded by FTP from:
|
||||
tsx-11.mit.edu:/pub/linux/ALPHA/spectemu/spectemu-0.94.tar.gz
|
||||
or
|
||||
sunsite.unc.edu:/pub/Linux/system/emulators/zx/spectemu-0.94.tar.gz
|
||||
|
||||
For news and updates have a look at the Spectemu Page:
|
||||
http://www.inf.bme.hu/~mszeredi/spectemu/
|
||||
|
||||
|
||||
You can also join a mailing list (at the Spectemu Page), to receive a
|
||||
notice when new versions of spectemu are available.
|
||||
|
||||
|
||||
Table of contents
|
||||
=================
|
||||
|
||||
1. Requirements
|
||||
|
||||
2. Recommended
|
||||
|
||||
3. Features
|
||||
|
||||
4. Drawbacks
|
||||
|
||||
5. Compiling and installation
|
||||
|
||||
6. Using the emulator
|
||||
|
||||
6.1 Command line arguments and configuration files (NEW)
|
||||
|
||||
6.2 Using the Spectrum keyboard
|
||||
|
||||
6.3 Keys that control the emulator
|
||||
|
||||
6.4 Effects of changing frame frequency and sound buffer size
|
||||
|
||||
7. Where can I get ZX Spectrum games for this emulator
|
||||
|
||||
8. Tape files
|
||||
|
||||
8.1 Loading a tape file
|
||||
|
||||
8.2 Quick loading of tape files
|
||||
|
||||
8.3 Saving to a tape file
|
||||
|
||||
8.4 Saving a tape file to real tape
|
||||
|
||||
8.5 Making a tape file from a real tape
|
||||
|
||||
9. Bug reports
|
||||
|
||||
10. Credits
|
||||
|
||||
|
||||
1. Requirements
|
||||
===============
|
||||
|
||||
Linux or other UNIX OS.
|
||||
Color X11 server (depths 8, 16 and 32 bits are supported)
|
||||
and/or
|
||||
SVGALIB console graphics library on Linux.
|
||||
|
||||
2. Recommended
|
||||
==============
|
||||
|
||||
A sound-card on Linux for wonderful spectrum 1-bit sound. And well, a
|
||||
fast enough processor... (Especially for the X11 version.)
|
||||
|
||||
3. Features
|
||||
===========
|
||||
|
||||
- Very fast because of assembly code in emulation (only on Intel
|
||||
processors).
|
||||
|
||||
- Emulation also in C, which is slower, but supports any processor.
|
||||
|
||||
- X support (with MITSHM if available, optionally double size window)
|
||||
|
||||
- Linux console graphics (with SVGALIB)
|
||||
|
||||
- Sound support (through Linux kernel sound-card driver,
|
||||
or SUN sound drivers)
|
||||
|
||||
- Snapshot saving and loading (.Z80 and .SNA format)
|
||||
|
||||
- Tape emulation: loading from tape files (.TAP and .TZX format)
|
||||
|
||||
- Optional quick loading of tapes.
|
||||
|
||||
- Saving to tape files.
|
||||
|
||||
- Separate utility to save tape files to real tape
|
||||
|
||||
- Configurable with config files and from command line
|
||||
|
||||
4. Drawbacks
|
||||
============
|
||||
|
||||
- Poor user interface
|
||||
|
||||
See the file TODO for a list of things which still need to be done (Maybe
|
||||
by YOU)
|
||||
|
||||
5. Compiling and installation
|
||||
=============================
|
||||
|
||||
To install the precompiled Linux executables just run 'make install'
|
||||
as root.
|
||||
|
||||
To recompile the programs on other platforms first type
|
||||
|
||||
./configure
|
||||
|
||||
This tries to determine the system type and parameters. Probably you
|
||||
won't have to give any options to configure, but here is the list of
|
||||
the most important options:
|
||||
|
||||
--help Print a full list of options
|
||||
|
||||
--prefix=PREFIX Install files under PREFIX (default is /usr/local)
|
||||
Executables go under PREFIX/bin, ...
|
||||
|
||||
--without-readline Do not use the readline library (default is to
|
||||
use it if it's available on your system)
|
||||
|
||||
--without-i386asm Do not use the Intel assembly code (default is
|
||||
to use it, if your system is Intel based)
|
||||
|
||||
You may want to have a look at the produced `Makefile' and `config.h'.
|
||||
Then just type
|
||||
|
||||
make clean
|
||||
make
|
||||
|
||||
Then to install the program, login as root, and run
|
||||
|
||||
make install
|
||||
|
||||
(If you want to compile on another machine be sure to `make realclean'
|
||||
before re-configuring and re-making the program!)
|
||||
|
||||
At the moment, there are two executable programs for running the emulator:
|
||||
|
||||
xspect the X11 version
|
||||
vgaspect the Linux console version
|
||||
|
||||
'vgaspect' uses the SVGALIB library. If you do not have this installed
|
||||
on your system 'vgaspect' cannot be started. You _MUST_ have SVGALIB
|
||||
version 1.2.10 or greater installed, and it is STRONGLY recommended,
|
||||
that you get version 1.2.11 or later!
|
||||
|
||||
SVGALIB is available at:
|
||||
sunsite.unc.edu:/pub/Linux/libs/graphics/
|
||||
|
||||
If you have SVGALIB version 1.2.11 or later, the emulator can run in
|
||||
background when you switch virtual consoles.
|
||||
|
||||
6. Using the emulator
|
||||
=====================
|
||||
|
||||
After starting 'xspect' or 'vgaspect' you should get the '(C) 1982 Sinclair
|
||||
Research Ltd' message, and after pressing a key, the flashing cursor. If
|
||||
not, then all I can say, is hard luck to you (if you are ambitious, compile
|
||||
the programs with debug information, and try to figure out what is causing
|
||||
the problem). Do not start the emulator processes in the background, the
|
||||
terminal is needed when loading or saving files.
|
||||
|
||||
To load a snapshot immediately after the start of the emulator, you
|
||||
can enter the name of the snapshot file on the command line. (Also see
|
||||
section 6.1)
|
||||
|
||||
E.g.
|
||||
|
||||
xspect snap/chuckie2
|
||||
|
||||
In X you can resize the window. Window size can only be a multiple of
|
||||
the smallest window size (320x256). Smaller window means faster
|
||||
emulation, so if emulation doesn't run at full speed, try making the
|
||||
window smaller.
|
||||
|
||||
6.1 Command line arguments and configuration files
|
||||
--------------------------------------------------
|
||||
|
||||
You can give options to Spectemu in three different ways:
|
||||
|
||||
1) In a configuration file (either ~/.spectemurc, or
|
||||
/usr/local/share/spectemu/spectemu.cfg)
|
||||
|
||||
2) With the X Resource Database (.Xdefaults), this applies only to 'xspect'
|
||||
|
||||
3) On the command line
|
||||
|
||||
Most of the options are common to all three methods, only the syntax
|
||||
differs slightly. Here are examples of the different syntax:
|
||||
|
||||
Config File:
|
||||
scale = 1
|
||||
private-map = true
|
||||
sound = false
|
||||
color-type = grayscale
|
||||
|
||||
.Xdefaults:
|
||||
xspect.scale: 1
|
||||
xspect.privateMap: true
|
||||
xspect.sound: false
|
||||
xspect.colorType: grayscale
|
||||
|
||||
Command line:
|
||||
xspect -scale 1 -private-map -no-sound -color-type grayscale
|
||||
|
||||
List of common options:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
NAME RANGE DEFAULT DESCRIPTION
|
||||
---- ----- ------- -----------
|
||||
|
||||
frame-skip 1... 2 The smaller this is, the more
|
||||
often the screen is updatated
|
||||
|
||||
scale 1..4 2 Window size of 'xspect'
|
||||
|
||||
private-map yes/no no Use private colormap in 'xspect'
|
||||
|
||||
mit-shm yes/no yes Use MIT-SHM extension in X server
|
||||
if available
|
||||
|
||||
vga-mode 320x200 320x240 Resolution to use in 'vgaspect',
|
||||
320x240 320x200 is faster (but not so nice)
|
||||
|
||||
sound yes/no yes Spectrum sound, if availble
|
||||
|
||||
sound-delay 1... 4 The amount of frames (1/50 seconds)
|
||||
to delay sound. See section 6.4
|
||||
|
||||
sound-device filename (system The name of the sound device
|
||||
dependent)
|
||||
|
||||
sound-sample-rate 4000... ~15625 Sample rate of sound device
|
||||
|
||||
sound-autoclose yes/no yes Whether to close sound device when
|
||||
unused (so other programs can use it)
|
||||
|
||||
sound-dsp-setfrag yes/no yes Set this to 'no' if you use PCSND
|
||||
sound driver
|
||||
|
||||
keyboard-type extended extended Specifies the mapping of the keys,
|
||||
spectrum from the PC keyboard to the spectrum
|
||||
compat keys. See section 6.2
|
||||
custom
|
||||
|
||||
cursor-type shifted shifted How to use the arrow keys on the
|
||||
raw PC keyboard. See section 6.2
|
||||
joystick
|
||||
|
||||
allow-ascii yes/no yes Interpret other keys on the PC
|
||||
keyboard. See section 6.2
|
||||
|
||||
true-shift <modif>* alt Modifier to get shifted symbol
|
||||
as on the PC.
|
||||
|
||||
func_shift <modif>* control Modifier to get control functions.
|
||||
|
||||
color-type normal normal What type of colors to use. Gray-
|
||||
grayscale scale looks better on monochrome
|
||||
custom displays.
|
||||
|
||||
pause-on-iconify yes/no no Whether to pause emulator, when it
|
||||
is iconified ('xspect' only)
|
||||
|
||||
vga-pause-bg yes/no no Whether to pasue emulator, when you
|
||||
switch to a different console
|
||||
|
||||
quick-load yes/no no Use built in (quick) loader for
|
||||
tapefiles.
|
||||
|
||||
auto-stop yes/no no Pause tape after each segment when
|
||||
quick loading.
|
||||
|
||||
load-immed yes/no no Load tapefile immediately (as if
|
||||
you typed LOAD "" / ENTER)
|
||||
|
||||
pause yes/no no Pause the emulator on startup
|
||||
|
||||
|
||||
* <modif> can be one of: none, shift, lock, control, alt,
|
||||
mod2, mod3, mod4, mod5
|
||||
|
||||
Extra command line parameters:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
On the command line you may also use the following options:
|
||||
|
||||
-help Prints usage information, and a list of available
|
||||
options
|
||||
|
||||
-version Prints out the version
|
||||
|
||||
|
||||
Also on the command line, a snapshot file and/or a tapefile can be
|
||||
specified. Spectemu figures out the type of file from the extension.
|
||||
You can omit the extension, e.g. you have a snapshot file 'snap.z80'
|
||||
and you start spectemu with 'xspect snap', then it will add the '.z80'
|
||||
extension.
|
||||
|
||||
You can specify what type is the file by preceding it with one of
|
||||
'-z80', '-sna', '-tap' or '-tzx' options. This is useful for cases,
|
||||
when the filename does not have an extension (e.g. automatic starting
|
||||
with the midnight commander).
|
||||
|
||||
Extra config file options:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Color configuration
|
||||
'''''''''''''''''''
|
||||
You can configure the custom colors in the config files (and the X
|
||||
Resource Database) with:
|
||||
|
||||
color[0..15] = R G B
|
||||
|
||||
e.g.
|
||||
|
||||
color-type = custom
|
||||
|
||||
color0 = 10 20 30
|
||||
color7 = 40 50 60
|
||||
|
||||
changes the 0-th (black) and the 7-th (white) colors.
|
||||
|
||||
Keyboard configuration
|
||||
''''''''''''''''''''''
|
||||
You can set custom key bindings in the config file:
|
||||
|
||||
Key_<keysym_name> = K ...
|
||||
...
|
||||
|
||||
Or in the X resource database:
|
||||
|
||||
xspect.keys: <keysym_name> = K ...; ...
|
||||
|
||||
|
||||
The <keysym_name> can be set to any keysym (defined in 'spkey_p.h').
|
||||
The K arguments are the spectrum keys to be assigned to the given PC
|
||||
key. K can be any letter, number (a..z, 0..9) or the following:
|
||||
|
||||
none, space, enter, capsshift, symbolshift,
|
||||
kempston_up, kempston_down, kempston_left, kempston_right, kempston_fire
|
||||
|
||||
e.g.
|
||||
|
||||
keyboard-type = custom
|
||||
true-shift = none
|
||||
|
||||
Key_Insert = capsshift 9
|
||||
Key_Tab = capsshift symbolshift
|
||||
Key_Shift_R = kempston_fire
|
||||
Key_Alt_L = symbolshift
|
||||
Key_Alt_R = symbolshift
|
||||
|
||||
or as it would appear in a .Xdefaults file:
|
||||
|
||||
xspect.keyboardType: custom
|
||||
xspect.trueShift: none
|
||||
|
||||
xspect.keys: Insert = capsshift 9; \
|
||||
Tab = capsshift symbolshift; \
|
||||
Shift_R = kempston_fire; \
|
||||
Alt_L = symbolshift; Alt_R = symbolshift
|
||||
|
||||
6.2 Using the Spectrum keyboard
|
||||
-------------------------------
|
||||
|
||||
Those of you that have at some time used a Spectrum know, that the keyboard
|
||||
of this little computer is something very strange, with a LOT of keywords
|
||||
and symbols on and around each key. If you have not seen this keyboard (or
|
||||
have somehow managed to forget some bit of information that is on it) we
|
||||
produced quite a good copy of it, found in the 'spectkey.gif' file.
|
||||
|
||||
If you are using 'xspect' than pressing 'Ctrl-k' brings up the picture
|
||||
of the spectrum keyboard. You can press keys with the mouse (even more
|
||||
than one if you like), and it also shows which keys are pressed. (You
|
||||
can see what the emulator does when, for example you press 'BackSpace'
|
||||
or a '[' key on the PC keyboard).
|
||||
|
||||
The default mapping of the spectrum's keyboard to the PC's is the
|
||||
following:
|
||||
|
||||
The numbers, the letters, Enter and Space are the same. The left Shift on
|
||||
the PC corresponds to the CAPS SHIFT key of the Spectrum, and the right
|
||||
Shift corresponds to the SYMBOL SHIFT. This is quite simple and with these
|
||||
keys you can get all the functionality of the original Spectrum (assuming
|
||||
of course, you know how).
|
||||
|
||||
But...
|
||||
|
||||
To make life a bit easier, you can also use the Backspace, the arrow
|
||||
keys, and the following symbols as on a PC keyboard: ,./;'-=<>?:"_+[]{}\|~
|
||||
(unless you turn the 'allow-ascii' option off)
|
||||
|
||||
To get a symbol which is written above the numbers on the PC, and not
|
||||
the function or symbol that is on the Spectrum, press Alt (actually
|
||||
the value of the 'true-shift' option) instead of Shift.
|
||||
|
||||
You can slightly modify the mapping with the 'keyboard-type' and
|
||||
'cursor-type' options. Every mapping includes the basic keys (letters,
|
||||
numbers, Space and Enter). Here are the mappings special to each
|
||||
keyboard type and cursor type:
|
||||
|
||||
PC Key Spectrum Key
|
||||
------ ------------
|
||||
|
||||
(Keyboard Types)
|
||||
|
||||
extended: (default)
|
||||
Left Shift -> Caps Shift
|
||||
Right Shift -> Symbol Shift
|
||||
Back Space -> Caps Shift + '0'
|
||||
Escape -> Caps Shift + '1'
|
||||
|
||||
spectrum: (spectrum-like layout, useful for some games, e.g. Jumping Jack)
|
||||
< same as extended, plus: >
|
||||
Comma (,) -> Symbol Shift
|
||||
Period (.) -> Space
|
||||
Semicolon (;) -> Enter
|
||||
|
||||
compat: (similar to other emulators' layouts, e.g. Z80, X128, XZX ...)
|
||||
Shift (both) -> Caps Shift
|
||||
Alt -> Symbol Shift
|
||||
Back Space -> Caps Shift + '0'
|
||||
Escape -> Caps Shift + '1'
|
||||
|
||||
custom:
|
||||
Use key bindings specified in the config file (see section 6.1)
|
||||
|
||||
(Cursor Types)
|
||||
|
||||
shifted: (default)
|
||||
Left Arrow -> Caps Shift + '5'
|
||||
Down Arrow -> Caps Shift + '6'
|
||||
Up Arrow -> Caps Shift + '7'
|
||||
Right Arrow -> Caps Shift + '8'
|
||||
|
||||
raw:
|
||||
Left Arrow -> '5'
|
||||
Down Arrow -> '6'
|
||||
Up Arrow -> '7'
|
||||
Right Arrow -> '8'
|
||||
|
||||
|
||||
joystick:
|
||||
Left Arrow -> Kempston Left
|
||||
Down Arrow -> Kempston Down
|
||||
Up Arrow -> Kempston Up
|
||||
Right Arrow -> Kempston Right
|
||||
Keypad Ins -> Kempston Fire
|
||||
Keypad Del -> Kempston Fire
|
||||
Keypad Home -> Kempston Up + Left
|
||||
Keypad PgUp -> Kempston Up + Right
|
||||
Keypad End -> Kempston Down + Left
|
||||
Keypad PgDn -> Kempston Down + Right
|
||||
|
||||
|
||||
6.3 Keys that control the emulator
|
||||
----------------------------------
|
||||
|
||||
All control keys are produced by pressing the Ctrl key and another key.
|
||||
|
||||
Ctrl-c, F10 Quit the emulator immediately
|
||||
|
||||
Ctrl-l, F3 Load a snapshot file; you must type the path and
|
||||
filename on the terminal where you started the emulator,
|
||||
e.g. 'snap/chuckie2'. The type and extension of the
|
||||
file is determined automatically (.z80 or .sna).
|
||||
|
||||
Ctrl-t, F2 Save the current state of the emulator in a snapshot file.
|
||||
Format depends on the extension (.z80 or .sna). If no
|
||||
extension is given, .z80 is appended.
|
||||
|
||||
Ctrl-w, Ctrl-F2 Save a snapshot to a temporary file
|
||||
|
||||
Ctrl-e, Ctrl-F3 Restore last temporary snapshot saved with 'Ctrl-w'
|
||||
|
||||
Ctrl-q, F5 Reset the Spectrum
|
||||
|
||||
Ctrl-f Fast mode
|
||||
|
||||
Ctrl-n Normal speed mode
|
||||
|
||||
Ctrl-b Pause/Unpause emulator (you can do operations like loading
|
||||
a snapshot file, etc... in paused mode too)
|
||||
|
||||
Ctrl-m Toggle sound on/off
|
||||
|
||||
Ctrl-h, F1 Print help
|
||||
|
||||
Ctrl-k Display (undisplay) keyboard of spectrum. See section 6.2.
|
||||
|
||||
Ctrl-p, F4 Play tape. Tape file must be entered on the terminal.
|
||||
Optionally the starting segment can be entered;
|
||||
e.g. 'tape/tape1.tap' or 'tape/tape1.tzx 13'
|
||||
|
||||
Ctrl-s, F7 Stop tape
|
||||
|
||||
Ctrl-y Toggle quick loading
|
||||
|
||||
Ctrl-o, F6 Pause and unpause during tapefile playing (restarts the
|
||||
current segment).
|
||||
|
||||
Ctrl-r Record to tape file. See section 8.3.
|
||||
|
||||
Ctrl-\, F9 Refresh screen, reset keyboard state and
|
||||
refresh colors.
|
||||
|
||||
Ctrl-j Toggle private colormap mode (only X)
|
||||
|
||||
Ctrl-comma Decrease window size (only X)
|
||||
|
||||
Ctrl-dot Increase window size (only X)
|
||||
|
||||
Ctrl-equals Skip more screen frames
|
||||
|
||||
Ctrl-minus Skip less screen frames
|
||||
|
||||
Ctrl-] Increase sound buffer size
|
||||
|
||||
Ctrl-[ Decrease sound buffer size
|
||||
|
||||
|
||||
6.4 Effects of changing frame frequency and sound buffer size
|
||||
-------------------------------------------------------------
|
||||
|
||||
ONLY READ THIS IF YOU ARE NOT TOTALLY SATISFIED WITH THE EMULATOR'S
|
||||
PERFORMANCE
|
||||
|
||||
This should be totally automatic, so I'm now programming you to do what
|
||||
the emulator should. (Luckily you are much easier to program)
|
||||
|
||||
Frame skipping determines, after how many frames the emulator displays one
|
||||
on the screen. There are 50 frames in one second, and normally every other
|
||||
frame is displayed (25 per second). If the emulator is too slow under X,
|
||||
increasing frame skipping can have a good effect on performance, but at the
|
||||
cost of poorer quality. But the interesting thing is, that increasing frame
|
||||
skipping may cause a worsening of both performance and of picture quality
|
||||
(I will not explain it here why).
|
||||
|
||||
Decreasing frame skipping has the opposite effect of the above.
|
||||
|
||||
If the emulator uses sound, but sound is not continuous, then experiment
|
||||
with increasing sound buffer size, and increasing frame skipping. If you
|
||||
are lucky you can make things a bit better. Increasing sound buffer size
|
||||
has also the negative effect of delaying more the sound effects.
|
||||
|
||||
7. Where can I get ZX Spectrum games for this emulator
|
||||
======================================================
|
||||
|
||||
On the Spectemu homepage (http://www.inf.bme.hu/~mszeredi/spectemu/)
|
||||
you can find a list of sites worth checking. Here are some:
|
||||
|
||||
http://www.void.demon.nl/spectrum.html
|
||||
http://www.nvg.unit.no/sinclair/planet/
|
||||
|
||||
The fact is, that there were a lot of Spectrum games around on audio tapes,
|
||||
and some of them are really good. There were always cracked and copyable
|
||||
versions around, and nobody was interested in copyrights. Unfortunately the
|
||||
big FTP archives do not allow non free software on their servers, so I
|
||||
can't include any games in this distribution.
|
||||
|
||||
(Because Spectrums have died out, and perhaps some of the software
|
||||
companies do not exist any more, probably some games could be distributed
|
||||
freely. But I will not check on those things.)
|
||||
|
||||
I've included a program named 'spconv', written by Henk de Groot
|
||||
(hegr@ensae.ericsson.se) which can convert between snapshot file formats.
|
||||
|
||||
Alternatively if you have some old spectrum tapes laying around, and you
|
||||
are very brave, you can check out section 8.5.
|
||||
|
||||
8. Tape files
|
||||
=============
|
||||
|
||||
8.1 Loading a tape file
|
||||
-----------------------
|
||||
|
||||
The emulator now supports G.A. Lunter's .TAP and Tomaz Kac's .TZX tape
|
||||
files. To load a file, enter
|
||||
|
||||
LOAD ""
|
||||
|
||||
to the spectrum (by pressing keys j""), then press 'Ctrl-p'.
|
||||
On the terminal enter the name of the tape file to load, e.g.
|
||||
|
||||
tape/cnamemat
|
||||
|
||||
The emulator will now load from the tape file 'tape/cnamemat.tzx' or
|
||||
'tape/cnamemat.tap' whichever exists. Playing automatically stops at
|
||||
the end of the tape file. To stop loading before this press Ctrl-s.
|
||||
|
||||
The default extensions are '.tap' / '.tzx' or '.TAP' / '.TZX' depending
|
||||
on whether the entered tape file is upper or lower case.
|
||||
|
||||
While loading try pressing Ctrl-f, which can speed things up. After loading
|
||||
the file press press Ctrl-n to restore normal speed.
|
||||
|
||||
8.2 Quick loading of tape files
|
||||
-------------------------------
|
||||
|
||||
Quick loading means bypassing of the tape loading routine in the
|
||||
spectrum ROM, and loading of tape blocks directly into the memory.
|
||||
Some programs use their own tape loading routines, and in that case
|
||||
the tape blocks are always "slow loaded" (see above section).
|
||||
|
||||
Quick loading is optional and can be toggled with the 'Ctrl-y' key.
|
||||
|
||||
When quick loading is on, after entering 'LOAD ""' you are immediately
|
||||
prompted for a tapefile. If the tapefile can't be loaded, the quick
|
||||
loading of the first header block is cancelled, but you can still load
|
||||
the rest of tape by pressing 'Ctrl-p' and entering the tapefile name.
|
||||
|
||||
Even in quick load mode, the playing of tapes is not automatically
|
||||
paused, when the program doesn't load more blocks, so with '.tap'
|
||||
files containing multipart games, you have to pause the tape at the
|
||||
end of each part with 'Ctrl-o' ('.tzx' tapefiles can contain a
|
||||
"Stop the Tape" mark, to automatically pause playing).
|
||||
|
||||
8.3 Saving to a tape file
|
||||
-------------------------
|
||||
|
||||
If you want to save something to a tape file using the spectrum's "SAVE"
|
||||
command, do the following:
|
||||
|
||||
1) Enter 'SAVE "file"' on the spectrum
|
||||
2) press Ctrl-r to start the recording
|
||||
3) on the terminal enter the name of the tapefile to use
|
||||
4) press a key on the spectrum
|
||||
5) wait for the recording to stop
|
||||
6) press Ctrl-s to stop recording
|
||||
|
||||
If the specified tape file already exists, the newly saved segments are
|
||||
appended to the old tapefile.
|
||||
|
||||
|
||||
8.4 Saving a tape file to real tape
|
||||
-----------------------------------
|
||||
|
||||
The utility 'tapeout' enables you to save tape files (.tap and .tzx)
|
||||
to real tape via the soundcard. At the moment it only works on Linux,
|
||||
because it uses the OSS sound driver. (You can compile it for non
|
||||
linux systems, by adding -DNO_SOUNDCARD to CFLAGS in Makefile. Then
|
||||
instead of writing to the sound device, the program writes to a
|
||||
headerless wav file (bits: 8, sample rate: what you've given).)
|
||||
|
||||
You can compile 'tapeout' by entering
|
||||
|
||||
make tapeout
|
||||
|
||||
in the main directory of spectemu. The command line parameters are:
|
||||
|
||||
tapeout sample_rate tapefile [start_block [output_file]]
|
||||
|
||||
The default value for start_block is 0, for output_file it is "/dev/dsp"
|
||||
(or if compiled -DNO_SOUNDCARD it is "tape.out").
|
||||
|
||||
You can stop recording to the tape by pressing Ctrl-C.
|
||||
|
||||
8.5 Making a tape file from a real tape
|
||||
---------------------------------------
|
||||
|
||||
WARNING, ONLY TRY THIS IF YOU REALLY-REALLY WANT TO!
|
||||
|
||||
Well it's not so bad as that, I've digitized a lot Spectrum tapes with
|
||||
ease, but I have the advantage of having played with tapes a lot on the
|
||||
real Spectrum, and of being able to modify the code which does the
|
||||
digitization.
|
||||
|
||||
First of all you must have a sound-card to do this. If you've got it, then
|
||||
you have a small chance of succeeding.
|
||||
|
||||
First get the cassette player which you used to play Spectrum tapes. Then
|
||||
plug it in your sound-card's 'line-in' or 'mic' inputs. Then somehow set the
|
||||
sound driver so that it reads things form the input in which you plugged
|
||||
your cassette (I use 'xmmix' the 'Motif Audio Mixer' to do this). And if
|
||||
you've managed to get this far, go to the directory where you want to store
|
||||
the tape files (remember, there will be a lot of little files: one for each
|
||||
little segment!), and enter the following command:
|
||||
|
||||
recs - 32000 | filt | spload tapefile
|
||||
|
||||
or
|
||||
|
||||
recs - 32000 | spload tapefile
|
||||
|
||||
(The first type worked better for me)
|
||||
|
||||
Where 'recs', 'filt' and 'spload' are programs found in the utils
|
||||
directory, and 'tapefile' is the name of the tape file without the '.spt'
|
||||
extension.
|
||||
|
||||
'.spt' tape files only exist because of historical reasons (the tape
|
||||
digitizing program preceeded the emulator, and also at that time I didn't
|
||||
know of the '.TAP' format), and now it isn't suppurted by the emulator
|
||||
any more. So you must convert '.spt' files to '.tap' with the utility
|
||||
spt2tap (in the utils directory) to use it with the emulator.
|
||||
|
||||
(The contents of the utils directory can be remade by changing to that
|
||||
directory and entering the command: 'make realclean; make')
|
||||
|
||||
Now you can put your favorite Spectrum cassette in the cassette player, and
|
||||
press the Play button.
|
||||
|
||||
'spload' will write a lot of information on the terminal, of which you
|
||||
might try to make some sense. Also you can do a 'tail -f tapefile.spt' in
|
||||
another terminal, to see what is happening. Again if nothing happens, then
|
||||
you are on your own (and most probably at first nothing will happen).
|
||||
|
||||
And remember that this digitizer is not better than the real Spectrum, so
|
||||
if you cannot load a program with a Spectrum, you'll most probably will not
|
||||
be able to load it with 'spload'.
|
||||
|
||||
Good Luck!
|
||||
|
||||
9. Bug reports
|
||||
==============
|
||||
|
||||
Please send bug reports to:
|
||||
|
||||
mszeredi@inf.bme.hu
|
||||
|
||||
If you make any changes to the source, please mail me the 'diff -u' of the
|
||||
file(s) changed, and also why were the changes needed.
|
||||
|
||||
Please also tell me if you would like to maintain, or to continue
|
||||
developing spectemu.
|
||||
|
||||
10. Credits
|
||||
===========
|
||||
|
||||
Szeredi Tamas, for testing the emulator, and for helping with the
|
||||
'spectkey.gif'.
|
||||
|
||||
Egmont Koblinger for helping to write some parts of the emulator, and for
|
||||
a lot of useful suggestions.
|
||||
|
||||
Dani Nagy and Zsazsa for helping to test the emulator.
|
||||
|
||||
G.A. Lunter for a very good description of the Spectrum, the undocumented
|
||||
features of Z80, and the '.z80' snapshot file format.
|
||||
|
||||
And lots of others, who sent me good ideas and modifications.
|
||||
33
apps/plugins/zxbox/README.DOS
Normal file
33
apps/plugins/zxbox/README.DOS
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
Spectemu is now basically usable under DOS.
|
||||
|
||||
Still missing:
|
||||
|
||||
1) Sound
|
||||
2) Decent GUI
|
||||
|
||||
How to compile:
|
||||
---------------
|
||||
|
||||
- You will need DJGPP version 2, libkb, and the allegro game library.
|
||||
You can get these at:
|
||||
|
||||
To get DJGPP, read:
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/00README.TXT
|
||||
|
||||
Libkb is at:
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/libkb100.zip
|
||||
|
||||
Allegro is at:
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/allegro/alleg30.zip
|
||||
|
||||
|
||||
- Not all files are needed (no long named files are needed, you can
|
||||
try to get rid of them, but they cause no harm)
|
||||
|
||||
- copy 'Makefile.dos' to 'Makefile', and 'config.dos' to 'config.h'
|
||||
|
||||
- type 'make'
|
||||
|
||||
It should compile without warnings. To start it, enter 'vgaspect'.
|
||||
|
||||
See also README, for what can be done with the emulator.
|
||||
182
apps/plugins/zxbox/README.Z80
Normal file
182
apps/plugins/zxbox/README.Z80
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
This file describes how to use the Z80 processor emulation as a
|
||||
standalone module (without the ZX Spectrum emulation).
|
||||
|
||||
===========================================================================
|
||||
You will need the following files:
|
||||
|
||||
For the 'intel x86' assembly version:
|
||||
-------------------------------------
|
||||
|
||||
z80.c z80.h z80_type.h i386step.S i386def.S i386op1.S i386op1x.S
|
||||
i386op2.S i386op2x.S i386op3.S i386op3x.S i386op4.S i386op5.S i386op6.S
|
||||
sp_to_s.c
|
||||
|
||||
For the 'C' version:
|
||||
--------------------
|
||||
|
||||
z80.c z80.h z80_type.h z80_step.c z80_def.h z80_ari.h z80optab.c z80optab.h
|
||||
z80_op1.c z80_op1x.c z80_op1.h z80_op2.c z80_op2x.c z80_op2.h
|
||||
z80_op3.c z80_op3x.c z80_op3.h z80_op4.c z80_op4x.c z80_op4.h
|
||||
z80_op5.c z80_op5.h z80_op6.c z80_op6.h
|
||||
|
||||
===========================================================================
|
||||
Makefile rules:
|
||||
|
||||
For the 'intel x86' assembly version:
|
||||
-------------------------------------
|
||||
|
||||
CC = gcc
|
||||
AR = ar
|
||||
CPPFLAGS =
|
||||
CFLAGS = -Wall -O3
|
||||
CPP = $(CC) -E
|
||||
|
||||
z80_i386_objs = z80.o i386emul.o
|
||||
|
||||
libz80.a: $(z80_i386_objs)
|
||||
$(AR) cr libz80.a $(z80_i386_objs)
|
||||
|
||||
i386emul.o: i386emul.s
|
||||
$(CC) -c $(CFLAGS) i386emul.s
|
||||
|
||||
i386emul.s: i386emul.sp sp_to_s
|
||||
./sp_to_s < i386emul.sp > i386emul.s
|
||||
|
||||
i386emul.sp: i386step.S
|
||||
$(CPP) $(CPPFLAGS) i386step.S > i386emul.sp
|
||||
|
||||
sp_to_s: sp_to_s.o
|
||||
$(CC) -o sp_to_s $(LDFLAGS) sp_to_s.o
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
|
||||
|
||||
|
||||
For 'C' version:
|
||||
----------------
|
||||
|
||||
CC = gcc
|
||||
AR = ar
|
||||
CPPFLAGS = -DZ80C
|
||||
CFLAGS = -Wall -O3 -fomit-frame-pointer -funroll-loops
|
||||
|
||||
z80_c_objs = z80.o z80_step.o z80optab.o z80_op1.o z80_op2.o z80_op3.o \
|
||||
z80_op4.o z80_op5.o z80_op6.o
|
||||
|
||||
libz80.a: $(z80_c_objs)
|
||||
$(AR) cr libz80.a $(z80_c_objs)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
|
||||
|
||||
===========================================================================
|
||||
The following functions are defined by libz80.a:
|
||||
|
||||
void z80_init()
|
||||
---------------
|
||||
|
||||
This function initializes the processor emulation. This must be called
|
||||
only once at the beginning of the program.
|
||||
|
||||
int z80_step(int ticknum)
|
||||
-------------------------
|
||||
|
||||
This function executes z80 instructions for 'ticknum' number of clock
|
||||
cycles. It returns the remaining number of ticks.
|
||||
|
||||
NOTE: the remaining number of ticks is always zero or negative,
|
||||
meaning that exactly, or more than the given 'ticknum' clock cycles
|
||||
were executed. This is because WHOLE instructions are executed at a
|
||||
time.
|
||||
|
||||
NOTE: HALT, LDDR, etc... do not count as one instruction, but as a
|
||||
series of instructions (e.g. HALT is a series of NOPs).
|
||||
|
||||
void z80_reset()
|
||||
----------------
|
||||
|
||||
This function resets the Z80 processor. This has the same effect as
|
||||
applying a pulse to the RESET input of the processor.
|
||||
|
||||
NOTE: z80_init() does not reset the Z80, z80_reset() should be called
|
||||
after it.
|
||||
|
||||
void z80_interrupt(int data)
|
||||
-----------------------------
|
||||
|
||||
Causes a Maskable Interrupt. Interrupt mode 1 and 2 are emulated
|
||||
correctly, in interrupt mode 2 'data' is used in the address
|
||||
calculation. In interrupt mode 0, it is assumed (as on the ZX
|
||||
Spectrum) that 0xFF is on the data bus, and always RST 38 is
|
||||
generated.
|
||||
|
||||
NOTE: It is not emulated, that in the instruction after EI no
|
||||
interrupt can be generated.
|
||||
|
||||
void z80_nmi()
|
||||
--------------
|
||||
|
||||
Causes a Non Maskable Interrupt.
|
||||
|
||||
===========================================================================
|
||||
Accessing the memory, the I/O ports and the Z80 processor's state
|
||||
(i.e. registers, etc...)
|
||||
|
||||
To use the functions above and the variables below, include the
|
||||
"z80.h" include file.
|
||||
|
||||
Memory
|
||||
------
|
||||
|
||||
The memory is stored in the z80_proc.mem[] byte array, which has a
|
||||
size of 65536. By default it is all RAM. To make parts of it read
|
||||
only, you have to redefine the appropriate macros in i386step.S and/or
|
||||
z80_def.h. (These macros are sorounded by #ifdef SPECT_MEM, #else,
|
||||
#endif statements.)
|
||||
|
||||
The memory is initialised to random data. You must fill it in before
|
||||
starting the emulation, but AFTER the call to z80_init().
|
||||
|
||||
I/O
|
||||
---
|
||||
|
||||
The input port values are stored in z80_inports[] array, which has a
|
||||
size of 256. The IN instruction will use the appropriate element of
|
||||
this array. This array is initialised to all zeroes.
|
||||
|
||||
The output port values can be queried from the z80_outports[] array,
|
||||
which has also a size of 256. The OUT instruction will store the value
|
||||
in the element addressed by the instruction.
|
||||
|
||||
If you need more complex behaviour of the I/O, you must redefine the
|
||||
appropriate macros in i386step.S and z80_def.h.
|
||||
|
||||
Processor state
|
||||
---------------
|
||||
|
||||
You can access the processor's state with the following variables and
|
||||
macros defined in "z80.h".
|
||||
|
||||
Registers:
|
||||
|
||||
Double registers:
|
||||
normal: BC, DE, HL, AF, IR, IX, IY, PC, SP,
|
||||
aux: BCBK, DEBK, HLBK, AFBK
|
||||
|
||||
Single registers:
|
||||
RB, RC, RD, RE, RH, RL, RA, RF, RI, RR, XH, XL, YH, YL, PCH, PCL, SPH, SPL
|
||||
|
||||
Misc state:
|
||||
z80_proc.haltstate (1: processor is in halt mode, 0: processor is runnig)
|
||||
z80_proc.it_mode (interrupt mode 0, 1 or 2)
|
||||
z80_proc.iff1 (interrupt flip-flop 1)
|
||||
z80_proc.iff2 (interrupt flip-flop 2)
|
||||
|
||||
You need not access the other parts of z80_proc, they are meaningless
|
||||
outside the z80_step() function.
|
||||
33
apps/plugins/zxbox/SOURCES
Normal file
33
apps/plugins/zxbox/SOURCES
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
compr.c
|
||||
helpers.c
|
||||
interf.c
|
||||
keynames.c
|
||||
loadim.c
|
||||
misc.c
|
||||
rom_imag.c
|
||||
snapshot.c
|
||||
spconf.c
|
||||
spect.c
|
||||
spectkey.c
|
||||
spkey.c
|
||||
spmain.c
|
||||
spperif.c
|
||||
spscr.c
|
||||
spsound.c
|
||||
sptape.c
|
||||
sptiming.c
|
||||
tapefile.c
|
||||
z80.c
|
||||
z80_op1.c
|
||||
z80_op2.c
|
||||
z80_op3.c
|
||||
z80_op4.c
|
||||
z80_op5.c
|
||||
z80_op6.c
|
||||
z80_step.c
|
||||
z80optab.c
|
||||
zxbox.c
|
||||
zxbox_keyb.c
|
||||
zxvid_16bpp.c
|
||||
zxvid_4bpp.c
|
||||
zxvid_grey.c
|
||||
43
apps/plugins/zxbox/acconfig.h
Normal file
43
apps/plugins/zxbox/acconfig.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
/* Define this on i386 architectures if the C compiler generates symbols
|
||||
beginning with underscores, eg. on old aout versions of Linux */
|
||||
#undef AOUT_FORMAT
|
||||
|
||||
/* Define this to enable running in background on the Linux console.
|
||||
Works only with SVGALIB 1.2.11 or newer */
|
||||
#undef RUN_IN_BACKGROUND
|
||||
|
||||
/* Define this if Xlib has the MITSHM extension */
|
||||
#undef HAVE_MITSHM
|
||||
|
||||
/* Define this if program can query MITSHM extension */
|
||||
#undef HAVE_SHMQUERY
|
||||
|
||||
/* Define this if you have the readline library */
|
||||
#undef HAVE_READLINE
|
||||
|
||||
/* Define this to use the C version of the program insead of the
|
||||
i386 assembly. Define this on non intel machines */
|
||||
#undef Z80C
|
||||
|
||||
/* Always define this for the spectrum emulator. */
|
||||
#undef SPECT_MEM
|
||||
|
||||
/* Define if sound driver is available. */
|
||||
#undef HAVE_SOUND
|
||||
|
||||
/* Define if sound driver is Open Sound System (OSS) */
|
||||
#undef OSS_SOUND
|
||||
|
||||
/* Define if sound driver is SUN */
|
||||
#undef SUN_SOUND
|
||||
|
||||
/* Define this to use the inline intel assembly sections */
|
||||
#undef I386_ASM
|
||||
|
||||
/* Define this to use an alternative way of passing the z80 processor
|
||||
data to the z80 instruction emulation functions. May make emulation
|
||||
faster on some machines, but not on intel, and sparc. */
|
||||
#undef PROCP
|
||||
|
||||
@TOP@
|
||||
111
apps/plugins/zxbox/akey.h
Normal file
111
apps/plugins/zxbox/akey.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* akey.h
|
||||
*
|
||||
* Header of the AKEY module
|
||||
*
|
||||
* Keyboard handeling routines and key identification labels
|
||||
*
|
||||
* Created: 92/12/01 Szeredi Miklos
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _AKEY_H
|
||||
#define _AKEY_H
|
||||
|
||||
|
||||
#define NOKEY -1
|
||||
#define UNKNOWNKEY -2
|
||||
#define ERRKEY -3
|
||||
#define MOUSEKEY -256
|
||||
|
||||
#define UPKEY (256 + 1)
|
||||
#define DOWNKEY (256 + 2)
|
||||
#define RIGHTKEY (256 + 3)
|
||||
#define LEFTKEY (256 + 4)
|
||||
#define INSKEY (256 + 5)
|
||||
#define DELKEY (256 + 6)
|
||||
#define HOMEKEY (256 + 7)
|
||||
#define ENDKEY (256 + 8)
|
||||
#define PUKEY (256 + 9)
|
||||
#define PDKEY (256 + 10)
|
||||
#define BSKEY (256 + 16)
|
||||
|
||||
#define FKEYOFFS (256 + 128)
|
||||
#define FKEYFIRST (FKEYOFFS + 1)
|
||||
#define FKEYLAST (FKEYOFFS + 12)
|
||||
#define FKEY(num) (FKEYOFFS + num)
|
||||
|
||||
#define ALTKEY (1 << 11)
|
||||
#define CTRKEY (1 << 10)
|
||||
#define SHKEY (1 << 9)
|
||||
|
||||
#define BKTABKEY (TABKEY | SHKEY)
|
||||
|
||||
#define CTL(ch) ((ch) - 96)
|
||||
#define META(ch) ((ch) | ALTKEY)
|
||||
|
||||
#define TABKEY 9
|
||||
#define LFKEY 13
|
||||
#define CRKEY 10
|
||||
#define ENTERKEY LFKEY
|
||||
#define ESCKEY 27
|
||||
|
||||
#define lastakey() __lastakey
|
||||
#define waitakey() ((void)readakey())
|
||||
#define setakey(key) ((void)(__lastakey = (key)))
|
||||
#define setakeydo(todo) (__atodo = (todo))
|
||||
|
||||
|
||||
typedef int keytype;
|
||||
typedef void (*__atodotype)(void);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern __atodotype __atodo;
|
||||
|
||||
extern keytype __lastakey;
|
||||
|
||||
extern keytype getakey(void);
|
||||
/* extern void setakey(keytype); */ /* MACRO */
|
||||
extern keytype readakey(void);
|
||||
/* extern keytype lastakey(void); */ /* MACRO */
|
||||
/* extern void waitakey(void); */ /* MACRO */
|
||||
extern int pressedakey(void);
|
||||
extern void clearakeybuff(void);
|
||||
/* extern void setakeydo(dofn __atodotype); */ /* MACRO */
|
||||
extern void ungetakey(void);
|
||||
extern int insertakey(keytype key);
|
||||
extern void setasmalldelay(int delay);
|
||||
|
||||
extern int initakey(void);
|
||||
extern void closeakey(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _AKEY_H */
|
||||
|
||||
/* End of akey.h */
|
||||
|
||||
47
apps/plugins/zxbox/archos.lds
Normal file
47
apps/plugins/zxbox/archos.lds
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "config.h"
|
||||
|
||||
/* linker script for chessbox as an overlay,
|
||||
* only used/ necessary for SH-based archos targets */
|
||||
|
||||
OUTPUT_FORMAT(elf32-sh)
|
||||
|
||||
#define DRAMORIG 0x09000000
|
||||
#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE
|
||||
|
||||
#define OVERLAY_LENGTH 0x80000
|
||||
#define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
OVERLAY_RAM : ORIGIN = OVERLAY_ORIGIN, LENGTH = OVERLAY_LENGTH
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.header : {
|
||||
_plugin_start_addr = .;
|
||||
*(.header)
|
||||
} > OVERLAY_RAM
|
||||
|
||||
.text : {
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
} > OVERLAY_RAM
|
||||
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
} > OVERLAY_RAM
|
||||
|
||||
.data : {
|
||||
*(.data)
|
||||
} > OVERLAY_RAM
|
||||
|
||||
.bss : {
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4);
|
||||
_plugin_end_addr = .;
|
||||
} > OVERLAY_RAM
|
||||
}
|
||||
815
apps/plugins/zxbox/ax.c
Normal file
815
apps/plugins/zxbox/ax.c
Normal file
|
|
@ -0,0 +1,815 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* ax.c
|
||||
*
|
||||
*
|
||||
*
|
||||
* Created: 94/11/11 Szeredi Miklos
|
||||
*
|
||||
* Version: 0.1 94/11/11
|
||||
* 0.2 95/06/12
|
||||
*
|
||||
*/
|
||||
|
||||
/* #define DEBUG_EVENTS */
|
||||
|
||||
#include "ax.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
typedef int boolean;
|
||||
#define max(x, y) ((x) < (y) ? (y) : (x))
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define minmax(a, l, u) ((a) < (l) ? (l) : ((a) > (u) ? (u) : (a)))
|
||||
|
||||
#define MAX_PROG_NAME_LEN 128
|
||||
#define MAX_CLASS_NAME_LEN MAX_PROG_NAME_LEN
|
||||
#define MAX_PRES_LEN 256
|
||||
#define MAX_FILENAME_LEN 1024
|
||||
|
||||
static const char *empty_str = "";
|
||||
|
||||
typedef void (*eventproc_t)(XEvent *, void *);
|
||||
|
||||
typedef struct _event_proc_struct {
|
||||
eventproc_t event_proc;
|
||||
unsigned long event_mask;
|
||||
Display *disp;
|
||||
void *ptr;
|
||||
Window event_win;
|
||||
boolean done_proc;
|
||||
struct _event_proc_struct *next_proc;
|
||||
} event_proc_struct;
|
||||
|
||||
typedef struct {
|
||||
const char *event_name;
|
||||
boolean win_given;
|
||||
event_proc_struct *next_proc;
|
||||
} event_struct;
|
||||
|
||||
typedef struct _disp_struct{
|
||||
Display *disp;
|
||||
XFontStruct *font;
|
||||
struct _disp_struct *next_disp;
|
||||
} disp_struct;
|
||||
|
||||
|
||||
#define EVENT_NUM LASTEvent
|
||||
|
||||
static event_struct event_info[EVENT_NUM];
|
||||
|
||||
static disp_struct disp_start = {NULL, NULL, NULL};
|
||||
|
||||
static boolean disp_chain_modified;
|
||||
|
||||
static char prog_name[MAX_PROG_NAME_LEN + 1];
|
||||
static char class_name[MAX_CLASS_NAME_LEN + 1];
|
||||
|
||||
static XrmDatabase rDB = NULL; /* Has to be global otherwise Xlib hangs */
|
||||
|
||||
static int opTableEntries = 19;
|
||||
static aX_options opTable[] = {
|
||||
{"-display", ".display", XrmoptionSepArg, NULL},
|
||||
{"-geometry", ".geometry", XrmoptionSepArg, NULL},
|
||||
{"-bg", ".background", XrmoptionSepArg, NULL},
|
||||
{"-background", ".background", XrmoptionSepArg, NULL},
|
||||
{"-bd", ".borderColor", XrmoptionSepArg, NULL},
|
||||
{"-bordercolor", ".borderColor", XrmoptionSepArg, NULL},
|
||||
{"-bw", ".borderWidth", XrmoptionSepArg, NULL},
|
||||
{"-borderwidth", ".borderWidth", XrmoptionSepArg, NULL},
|
||||
{"-fg", ".foreground", XrmoptionSepArg, NULL},
|
||||
{"-foreground", ".foreground", XrmoptionSepArg, NULL},
|
||||
{"-fn", ".font", XrmoptionSepArg, NULL},
|
||||
{"-font", ".font", XrmoptionSepArg, NULL},
|
||||
{"-name", ".name", XrmoptionSepArg, NULL},
|
||||
{"-rv", ".reverseVideo", XrmoptionNoArg, "on"},
|
||||
{"-reverse", ".reverseVideo", XrmoptionNoArg, "on"},
|
||||
{"+rv", ".reverseVideo", XrmoptionNoArg, "off"},
|
||||
{"-bg", ".background", XrmoptionSepArg, NULL},
|
||||
{"-title", ".title", XrmoptionSepArg, NULL},
|
||||
{"-xrm", NULL, XrmoptionResArg, NULL}
|
||||
};
|
||||
|
||||
static char *addstr(const char str1[], const char str2[], char str12[],
|
||||
unsigned int str12len)
|
||||
{
|
||||
unsigned int i, j, k;
|
||||
|
||||
str12[str12len-1] = '\0';
|
||||
|
||||
for(i=0, j=0, k=0; i + 1 < str12len; ) {
|
||||
if(str1[j]) str12[i] = str1[j++];
|
||||
else str12[i] = str2[k++];
|
||||
if(! str12[i++]) break;
|
||||
}
|
||||
return str12;
|
||||
}
|
||||
|
||||
|
||||
static char *pname(const char *resource) {
|
||||
static char pnameres[MAX_PRES_LEN];
|
||||
|
||||
return addstr(prog_name, resource, pnameres, MAX_PRES_LEN);
|
||||
}
|
||||
|
||||
static char *pclass(const char *resource) {
|
||||
static char pclassres[MAX_PRES_LEN];
|
||||
|
||||
return addstr(class_name, resource, pclassres, MAX_PRES_LEN);
|
||||
}
|
||||
|
||||
|
||||
static void fill_event_info(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < EVENT_NUM; i++) {
|
||||
event_info[i].event_name = empty_str;
|
||||
event_info[i].win_given = TRUE;
|
||||
event_info[i].next_proc = NULL;
|
||||
}
|
||||
|
||||
event_info[MappingNotify].win_given = FALSE;
|
||||
|
||||
event_info[ButtonPress].event_name = "ButtonPress";
|
||||
event_info[ButtonRelease].event_name = "ButtonRelease";
|
||||
event_info[CirculateNotify].event_name = "CirculateNotify";
|
||||
event_info[CirculateRequest].event_name = "CirculateRequest";
|
||||
event_info[ClientMessage].event_name = "ClientMessage";
|
||||
event_info[ColormapNotify].event_name = "ColormapNotify";
|
||||
event_info[ConfigureNotify].event_name = "ConfigureNotify";
|
||||
event_info[ConfigureRequest].event_name = "ConfigureRequest";
|
||||
event_info[CreateNotify].event_name = "CreateNotify";
|
||||
event_info[DestroyNotify].event_name = "DestroyNotify";
|
||||
event_info[EnterNotify].event_name = "EnterNotify";
|
||||
event_info[LeaveNotify].event_name = "LeaveNotify";
|
||||
event_info[Expose].event_name = "Expose";
|
||||
event_info[FocusIn].event_name = "FocusIn";
|
||||
event_info[FocusOut].event_name = "FocusOut";
|
||||
event_info[GraphicsExpose].event_name = "GraphicsExpose";
|
||||
event_info[NoExpose].event_name = "NoExpose";
|
||||
event_info[GravityNotify].event_name = "GravityNotify";
|
||||
event_info[KeymapNotify].event_name = "KeymapNotify";
|
||||
event_info[KeyPress].event_name = "KeyPress";
|
||||
event_info[KeyRelease].event_name = "KeyRelease";
|
||||
event_info[MapNotify].event_name = "MapNotify";
|
||||
event_info[UnmapNotify].event_name = "UnmapNotify";
|
||||
event_info[MappingNotify].event_name = "MappingNotify";
|
||||
event_info[MapRequest].event_name = "MapRequest";
|
||||
event_info[MotionNotify].event_name = "MotionNotify";
|
||||
event_info[PropertyNotify].event_name = "PropertyNotify";
|
||||
event_info[ReparentNotify].event_name = "ReparentNotify";
|
||||
event_info[ResizeRequest].event_name = "ResizeRequest";
|
||||
event_info[SelectionClear].event_name = "SelectionClear";
|
||||
event_info[SelectionNotify].event_name = "SelectionNotify";
|
||||
event_info[SelectionRequest].event_name = "SelectionRequest";
|
||||
event_info[VisibilityNotify].event_name = "VisibilityNotify";
|
||||
|
||||
}
|
||||
|
||||
static void get_def_res(aX_default_resources *defres)
|
||||
{
|
||||
XrmValue value;
|
||||
char *str_type;
|
||||
int flags;
|
||||
XColor color_def;
|
||||
unsigned long tmp_pixel;
|
||||
Colormap def_map;
|
||||
int font_spec;
|
||||
|
||||
|
||||
defres->window_name = prog_name;
|
||||
defres->icon_name = prog_name;
|
||||
|
||||
|
||||
defres->scr = DefaultScreen(defres->disp);
|
||||
defres->scr_ptr = ScreenOfDisplay(defres->disp, defres->scr);
|
||||
def_map = DefaultColormapOfScreen(defres->scr_ptr);
|
||||
|
||||
|
||||
if(XrmGetResource(rDB, pname(".title"), pclass(".Title"),
|
||||
&str_type, &value))
|
||||
defres->window_name = (char *) value.addr;
|
||||
|
||||
defres->sflags = PSize;
|
||||
if(XrmGetResource(rDB, pname(".geometry"), pclass(".Geometry"),
|
||||
&str_type, &value)) {
|
||||
flags = XParseGeometry((char *) value.addr, &(defres->x), &(defres->y),
|
||||
&(defres->width), &(defres->height));
|
||||
if((XValue | YValue) & flags) defres->sflags |= USPosition;
|
||||
if((WidthValue | HeightValue) & flags)
|
||||
defres->sflags = (defres->sflags & ~PSize) | USSize;
|
||||
}
|
||||
|
||||
defres->background = defres->background ?
|
||||
WhitePixel(defres->disp, defres->scr) :
|
||||
BlackPixel(defres->disp, defres->scr);
|
||||
|
||||
if(XrmGetResource(rDB, pname(".background"), pclass(".Background"),
|
||||
&str_type, &value)) {
|
||||
if(XParseColor(defres->disp, def_map, value.addr, &color_def)) {
|
||||
if(XAllocColor(defres->disp, def_map, &color_def))
|
||||
defres->background = color_def.pixel;
|
||||
}
|
||||
else fprintf(stderr, "%s: aX: warning: Invalid color specification %s\n",
|
||||
prog_name, value.addr);
|
||||
}
|
||||
|
||||
defres->foreground = defres->foreground ?
|
||||
WhitePixel(defres->disp, defres->scr) :
|
||||
BlackPixel(defres->disp, defres->scr);
|
||||
|
||||
if(XrmGetResource(rDB, pname(".foreground"), pclass(".Foreground"),
|
||||
&str_type, &value)) {
|
||||
if(XParseColor(defres->disp, def_map, value.addr, &color_def)) {
|
||||
if(XAllocColor(defres->disp, def_map, &color_def))
|
||||
defres->foreground = color_def.pixel;
|
||||
}
|
||||
else fprintf(stderr, "%s: aX: warning: Invalid color specification %s\n",
|
||||
prog_name, value.addr);
|
||||
}
|
||||
|
||||
if(XrmGetResource(rDB, pname(".borderWidth"), pclass(".BorderWidth"),
|
||||
&str_type, &value)) {
|
||||
defres->border_width = atoi(value.addr);
|
||||
}
|
||||
|
||||
defres->border_color = defres->foreground;
|
||||
if(XrmGetResource(rDB, pname(".borderColor"), pclass(".BorderColor"),
|
||||
&str_type, &value)) {
|
||||
if(XParseColor(defres->disp, def_map, value.addr, &color_def)) {
|
||||
if(XAllocColor(defres->disp, def_map, &color_def))
|
||||
defres->border_color = color_def.pixel;
|
||||
}
|
||||
else fprintf(stderr, "%s: aX: warning: Invalid color specification %s\n",
|
||||
prog_name, value.addr);
|
||||
}
|
||||
|
||||
font_spec = 0;
|
||||
if(XrmGetResource(rDB, pname(".font"), pclass(".Font"),
|
||||
&str_type, &value)) {
|
||||
defres->font_name = value.addr;
|
||||
if(defres->font_name != NULL) font_spec = 1;
|
||||
|
||||
}
|
||||
|
||||
if(XrmGetResource(rDB, pname(".fallbackFont"), pclass(".Font"),
|
||||
&str_type, &value))
|
||||
defres->fallback_font_name = value.addr;
|
||||
|
||||
if(defres->font_name == NULL ||
|
||||
(defres->font = XLoadQueryFont(defres->disp, defres->font_name))
|
||||
== NULL) {
|
||||
|
||||
if(font_spec)
|
||||
fprintf(stderr, "%s: aX: warning: cannot open %s font, ",
|
||||
prog_name, defres->font_name);
|
||||
|
||||
defres->font_name = defres->fallback_font_name;
|
||||
|
||||
if(font_spec && defres->font_name != NULL)
|
||||
fprintf(stderr, "trying %s...\n",defres->font_name);
|
||||
|
||||
if(defres->font_name == NULL ||
|
||||
(defres->font =
|
||||
XLoadQueryFont(defres->disp, defres->fallback_font_name)) == NULL) {
|
||||
|
||||
if(defres->font_name != NULL) {
|
||||
|
||||
fprintf(stderr, "%s: aX: warning: cannot open %s font, ",
|
||||
prog_name, defres->font_name);
|
||||
}
|
||||
|
||||
defres->font_name = "fixed";
|
||||
|
||||
fprintf(stderr, "trying %s...\n",defres->font_name);
|
||||
|
||||
if((defres->font = XLoadQueryFont(defres->disp, defres->font_name))
|
||||
== NULL) {
|
||||
|
||||
fprintf(stderr, "%s: aX: warning: cannot open %s font\n",
|
||||
prog_name, defres->font_name);
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else defres->font_name = defres->fallback_font_name;
|
||||
}
|
||||
|
||||
if(XrmGetResource(rDB, pname(".reverseVideo"), pclass(".ReverseVideo"),
|
||||
&str_type, &value))
|
||||
if(strcmp(value.addr, "on") == 0) {
|
||||
tmp_pixel = defres->foreground;
|
||||
defres->foreground = defres->background;
|
||||
defres->background = tmp_pixel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void add_disp(aX_default_resources *defres)
|
||||
{
|
||||
disp_struct *last;
|
||||
|
||||
for(last = &disp_start; last->next_disp != NULL; last = last->next_disp);
|
||||
|
||||
if((last->next_disp = malloc(sizeof(disp_struct))) == NULL) {
|
||||
fprintf(stderr, "%s: aX: Not enough memory.\n", prog_name);
|
||||
exit(-1);
|
||||
};
|
||||
|
||||
last = last->next_disp;
|
||||
|
||||
last->disp = defres->disp;
|
||||
last->font = defres->font;
|
||||
last->next_disp = NULL;
|
||||
|
||||
|
||||
disp_chain_modified = TRUE;
|
||||
}
|
||||
|
||||
void aX_open_disp(aX_options *useropt, int useroptlen,
|
||||
int *argcp, char *argv[],
|
||||
aX_default_resources *defres)
|
||||
{
|
||||
|
||||
XrmValue value;
|
||||
char *str_type;
|
||||
char *disp_res;
|
||||
char *environment;
|
||||
char *display_name = NULL;
|
||||
char filename[MAX_FILENAME_LEN];
|
||||
int i;
|
||||
XrmDatabase commandlineDB = NULL, usercommandlineDB = NULL;
|
||||
XrmDatabase homeDB, serverDB, applicationDB;
|
||||
|
||||
/*
|
||||
if(disp_start.next_disp != NULL) {
|
||||
fprintf(stderr, "aX_open_disp: Cannot open first display twice.\n");
|
||||
exit(-1);
|
||||
}
|
||||
*/
|
||||
|
||||
XrmInitialize();
|
||||
|
||||
class_name[0] = '\0';
|
||||
class_name[MAX_CLASS_NAME_LEN] = '\0';
|
||||
if(defres->class_name != NULL)
|
||||
strncpy(class_name, defres->class_name, MAX_CLASS_NAME_LEN);
|
||||
|
||||
|
||||
fill_event_info();
|
||||
|
||||
for(i = 1; i < *argcp; i++)
|
||||
if(strcmp(argv[i], "-name") == 0 && ++i < *argcp){
|
||||
defres->prog_name = argv[i];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
prog_name[0] = '\0';
|
||||
prog_name[MAX_PROG_NAME_LEN] = '\0';
|
||||
if(defres->prog_name != NULL)
|
||||
strncpy(prog_name, defres->prog_name, MAX_PROG_NAME_LEN);
|
||||
else
|
||||
strncpy(prog_name, argv[0], MAX_PROG_NAME_LEN);
|
||||
|
||||
defres->prog_name = prog_name;
|
||||
|
||||
XrmParseCommand(&commandlineDB, (XrmOptionDescRec *) opTable,
|
||||
opTableEntries, prog_name, argcp, argv);
|
||||
|
||||
if(useropt != NULL)
|
||||
XrmParseCommand(&usercommandlineDB, (XrmOptionDescRec *) useropt,
|
||||
useroptlen, prog_name, argcp, argv);
|
||||
else usercommandlineDB = NULL;
|
||||
|
||||
/*
|
||||
if(*argcp != 1) {
|
||||
fprintf(stderr,
|
||||
"%s: aX_open_disp: Unrecognised options in command line!\n",
|
||||
prog_name);
|
||||
exit(-1);
|
||||
}
|
||||
*/
|
||||
|
||||
if(XrmGetResource(commandlineDB, pname(".display"), pclass(".Display"),
|
||||
&str_type, &value)) display_name = (char *) value.addr;
|
||||
|
||||
if((defres->disp = XOpenDisplay(display_name)) == NULL) {
|
||||
fprintf(stderr, "%s: aX_open_disp: cannot connect to X server %s\n",
|
||||
prog_name, XDisplayName(display_name));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
applicationDB = XrmGetFileDatabase(
|
||||
addstr("/usr/lib/X11/app-defaults/",
|
||||
class_name,
|
||||
filename,
|
||||
MAX_FILENAME_LEN));
|
||||
/*
|
||||
if(defres->disp->xdefaults)
|
||||
serverDB = XrmGetStringDatabase(defres->disp->xdefaults);
|
||||
else serverDB = NULL;
|
||||
*/
|
||||
|
||||
|
||||
disp_res = XResourceManagerString(defres->disp);
|
||||
|
||||
if(disp_res) serverDB = XrmGetStringDatabase(disp_res);
|
||||
else serverDB = NULL;
|
||||
|
||||
|
||||
if((environment = getenv("XENVIRONMENT")) != NULL)
|
||||
homeDB = XrmGetFileDatabase(environment);
|
||||
else homeDB = NULL;
|
||||
|
||||
|
||||
XrmMergeDatabases(applicationDB, &rDB);
|
||||
XrmMergeDatabases(serverDB, &rDB);
|
||||
XrmMergeDatabases(homeDB, &rDB);
|
||||
XrmMergeDatabases(commandlineDB, &rDB);
|
||||
XrmMergeDatabases(usercommandlineDB, &rDB);
|
||||
|
||||
get_def_res(defres);
|
||||
|
||||
add_disp(defres);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void aX_open_second_disp(char *display_name,
|
||||
aX_default_resources *defres)
|
||||
{
|
||||
char *disp_res;
|
||||
|
||||
XrmDatabase serverDB;
|
||||
|
||||
|
||||
if((defres->disp = XOpenDisplay(display_name)) == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: aX_open_second_disp: cannot connect to X server %s\n",
|
||||
prog_name, XDisplayName(display_name));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
disp_res = XResourceManagerString(defres->disp);
|
||||
|
||||
if(disp_res) serverDB = XrmGetStringDatabase(disp_res);
|
||||
else serverDB = NULL;
|
||||
|
||||
|
||||
XrmMergeDatabases(serverDB, &rDB);
|
||||
|
||||
get_def_res(defres);
|
||||
|
||||
add_disp(defres);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void smallwait(boolean event_prev)
|
||||
{
|
||||
event_prev = event_prev;
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
static void sigalrm_handler(int i)
|
||||
{
|
||||
i = i;
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
}
|
||||
|
||||
|
||||
static void smallwait(boolean event_prev)
|
||||
{
|
||||
struct itimerval value;
|
||||
|
||||
signal(SIGALRM, sigalrm_handler);
|
||||
|
||||
event_prev = event_prev;
|
||||
|
||||
value.it_interval.tv_sec = 0L;
|
||||
value.it_interval.tv_usec = 0L;
|
||||
value.it_value.tv_sec = 0L;
|
||||
value.it_value.tv_usec = 100000L;
|
||||
setitimer(ITIMER_REAL, &value, NULL);
|
||||
|
||||
pause();
|
||||
}
|
||||
|
||||
/* This aX_wait_all_muck needs to be cleared out! */
|
||||
|
||||
void aX_wait_event(int eventtype)
|
||||
{
|
||||
XEvent ev;
|
||||
event_proc_struct **curr;
|
||||
int i;
|
||||
disp_struct *dsp, *dsp1;
|
||||
|
||||
boolean event_prev;
|
||||
|
||||
|
||||
start:;
|
||||
|
||||
if(disp_start.next_disp == NULL) {
|
||||
fprintf(stderr, "%s: aX_wait_event: No connection to any display\n",
|
||||
prog_name);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
dsp = disp_start.next_disp;
|
||||
|
||||
|
||||
do {
|
||||
event_prev = TRUE;
|
||||
|
||||
dsp1 = dsp;
|
||||
if((disp_start.next_disp)->next_disp != NULL ||
|
||||
eventtype == AX_LOOK_EVENTS)
|
||||
while(XPending(dsp->disp) == 0) {
|
||||
dsp = dsp->next_disp;
|
||||
if(dsp == NULL) dsp = disp_start.next_disp;
|
||||
|
||||
if(dsp == dsp1) {
|
||||
if(eventtype == AX_LOOK_EVENTS) return;
|
||||
|
||||
smallwait(event_prev);
|
||||
event_prev = FALSE;
|
||||
dsp = dsp1 = disp_start.next_disp;
|
||||
}
|
||||
}
|
||||
|
||||
XNextEvent(dsp->disp, &ev);
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"Event: %s (%i) in win: %li)\n",
|
||||
event_info[ev.type].event_name,
|
||||
ev.type,
|
||||
ev.xany.window);
|
||||
#endif
|
||||
|
||||
|
||||
if(dsp->disp != ev.xany.display)
|
||||
fprintf(stderr, "Ha! Event read from wrong display! Stupid XLib!!!\n");
|
||||
|
||||
curr = &(event_info[ev.type].next_proc);
|
||||
i = 0;
|
||||
while(*curr != NULL) {
|
||||
if((*curr)->disp == dsp->disp &&
|
||||
(!event_info[ev.type].win_given ||
|
||||
ev.xany.window == (*curr)->event_win) &&
|
||||
!(*curr)->done_proc) {
|
||||
i++;
|
||||
(*curr)->done_proc = TRUE;
|
||||
disp_chain_modified = FALSE;
|
||||
|
||||
if((*curr)->event_proc != NULL) {
|
||||
(*((*curr)->event_proc))(&ev, (*curr)->ptr);
|
||||
}
|
||||
|
||||
if(disp_chain_modified) goto start;
|
||||
curr = &(event_info[ev.type].next_proc);
|
||||
}
|
||||
else curr = &((*curr)->next_proc);
|
||||
}
|
||||
curr = &(event_info[ev.type].next_proc);
|
||||
while(*curr != NULL) {
|
||||
(*curr)->done_proc = FALSE;
|
||||
curr = &((*curr)->next_proc);
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
fprintf(stderr, "%s: aX_wait_event: warning: "
|
||||
"Unexpected event: %s (%i) in win: %li)\n",
|
||||
prog_name,
|
||||
event_info[ev.type].event_name,
|
||||
ev.type,
|
||||
ev.xany.window);
|
||||
|
||||
} while(eventtype != ev.type && eventtype != AX_ANY_EVENT);
|
||||
}
|
||||
|
||||
|
||||
void aX_look_events(void)
|
||||
{
|
||||
aX_wait_event(AX_LOOK_EVENTS);
|
||||
}
|
||||
|
||||
char *aX_get_prog_res(const char *resname, const char* resclass)
|
||||
{
|
||||
XrmValue value;
|
||||
char *str_type;
|
||||
|
||||
if(XrmGetResource(rDB, pname(resname), pclass(resclass),
|
||||
&str_type, &value))
|
||||
return (char *)value.addr;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
char *aX_get_resource(const char *resname, const char* resclass)
|
||||
{
|
||||
XrmValue value;
|
||||
char *str_type;
|
||||
|
||||
if(XrmGetResource(rDB, resname, resclass,
|
||||
&str_type, &value))
|
||||
return (char *)value.addr;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
static long get_win_mask(Display *disp, Window win)
|
||||
{
|
||||
int evt;
|
||||
event_proc_struct *ep;
|
||||
long winmask;
|
||||
|
||||
for(evt = 0, winmask = 0; evt < EVENT_NUM; evt++) {
|
||||
ep = event_info[evt].next_proc;
|
||||
while(ep != NULL) {
|
||||
if(ep->event_win == win && ep->disp == disp) winmask |= ep->event_mask;
|
||||
ep = ep->next_proc;
|
||||
}
|
||||
}
|
||||
return winmask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void aX_add_event_proc(Display *disp,
|
||||
Window win,
|
||||
int eventtype,
|
||||
void (*eventproc)(XEvent *, void *),
|
||||
unsigned long eventmask,
|
||||
void *ptr)
|
||||
{
|
||||
event_proc_struct **epp;
|
||||
long winmask;
|
||||
|
||||
epp = &(event_info[eventtype].next_proc);
|
||||
while(*epp != NULL) epp = &((*epp)->next_proc);
|
||||
|
||||
if((*epp = (event_proc_struct *)
|
||||
malloc((size_t) sizeof(event_proc_struct))) == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: aX_add_event_proc_disp: Not enough memory.\n", prog_name);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
(*epp)->event_proc = eventproc;
|
||||
(*epp)->ptr = ptr;
|
||||
(*epp)->event_mask = eventmask;
|
||||
(*epp)->disp = disp;
|
||||
(*epp)->event_win = win;
|
||||
(*epp)->done_proc = FALSE;
|
||||
(*epp)->next_proc = NULL;
|
||||
|
||||
if(win) {
|
||||
winmask = get_win_mask(disp, win);
|
||||
XSelectInput(disp, win, winmask);
|
||||
}
|
||||
}
|
||||
|
||||
void aX_remove_event_proc(Display *disp,
|
||||
Window win,
|
||||
int eventtype,
|
||||
void (*eventproc)(XEvent *, void *))
|
||||
{
|
||||
event_proc_struct **epp;
|
||||
event_proc_struct *tmp;
|
||||
long winmask;
|
||||
|
||||
epp = &(event_info[eventtype].next_proc);
|
||||
while(*epp != NULL) {
|
||||
if((*epp)->disp == disp &&
|
||||
(*epp)->event_win == win &&
|
||||
(*epp)->event_proc == eventproc) {
|
||||
tmp = (*epp)->next_proc;
|
||||
free(*epp);
|
||||
*epp = tmp;
|
||||
if(win) {
|
||||
winmask = get_win_mask(disp, win);
|
||||
XSelectInput(disp, win, winmask);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else epp = &((*epp)->next_proc);
|
||||
}
|
||||
fprintf(stderr, "%s: aX_remove_event_proc_disp: warning: "
|
||||
"Could not remove event proc (event: %s (%i), window: %lX)\n",
|
||||
prog_name, event_info[eventtype].event_name, eventtype, win);
|
||||
|
||||
}
|
||||
|
||||
void aX_close_one_disp(Display *disp)
|
||||
{
|
||||
/* int evt;
|
||||
event_proc_struct **curr; */
|
||||
disp_struct *dsp, *dsp_tmp;
|
||||
|
||||
/*
|
||||
for(evt = 0; evt < EVENT_NUM; evt++) {
|
||||
curr = &(event_info[evt].next_proc);
|
||||
while(*curr != NULL) {
|
||||
if(disp == (*curr)->disp) {
|
||||
aX_remove_event_proc_disp((*curr)->disp, (*curr)->event_win,
|
||||
evt, (*curr)->event_proc);
|
||||
curr = &(event_info[evt].next_proc);
|
||||
}
|
||||
else curr = &((*curr)->next_proc);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
for(dsp = &disp_start; dsp->next_disp->disp != disp; dsp = dsp->next_disp)
|
||||
if(dsp->next_disp == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: aX_close_one_disp: warning: Trying to close unopened display.\n",
|
||||
prog_name);
|
||||
return;
|
||||
}
|
||||
|
||||
XUnloadFont(dsp->next_disp->disp, dsp->next_disp->font->fid);
|
||||
XCloseDisplay(dsp->next_disp->disp);
|
||||
|
||||
dsp_tmp = dsp->next_disp;
|
||||
dsp->next_disp = dsp->next_disp->next_disp;
|
||||
free(dsp_tmp);
|
||||
|
||||
disp_chain_modified = TRUE;
|
||||
|
||||
}
|
||||
|
||||
void aX_close_disp(void)
|
||||
{
|
||||
|
||||
while(disp_start.next_disp != NULL)
|
||||
aX_close_one_disp(disp_start.next_disp->disp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned long aX_get_color(Display *disp, int scr, unsigned long def_col,
|
||||
const char *color_name)
|
||||
{
|
||||
XColor color_def;
|
||||
Colormap def_map;
|
||||
Screen *scr_ptr;
|
||||
|
||||
|
||||
if(color_name == NULL) return def_col;
|
||||
|
||||
scr_ptr = ScreenOfDisplay(disp, scr);
|
||||
def_map = DefaultColormapOfScreen(scr_ptr);
|
||||
|
||||
if(XParseColor(disp, def_map, color_name, &color_def)) {
|
||||
if(XAllocColor(disp, def_map, &color_def))
|
||||
return color_def.pixel;
|
||||
}
|
||||
else fprintf(stderr,
|
||||
"%s: aX_get_color: warning: Invalid color specification %s\n",
|
||||
prog_name, color_name);
|
||||
|
||||
return def_col;
|
||||
|
||||
}
|
||||
114
apps/plugins/zxbox/ax.h
Normal file
114
apps/plugins/zxbox/ax.h
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ax.h
|
||||
*
|
||||
* Header of the AX module
|
||||
*
|
||||
*
|
||||
* Created: 94/11/11 Szeredi Miklos
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _AX_H
|
||||
#define _AX_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
/*typedef XrmOptionDescRec aX_options; */
|
||||
|
||||
typedef struct {
|
||||
const char *option; /* Option abbreviation in argv */
|
||||
const char *specifier; /* Resource specifier */
|
||||
XrmOptionKind argKind; /* Which style of option it is */
|
||||
const char *value; /* Value to provide if XrmoptionNoArg */
|
||||
} aX_options;
|
||||
|
||||
|
||||
#define AX_NO_EVENT LASTEvent
|
||||
#define AX_ANY_EVENT 0
|
||||
#define AX_LOOK_EVENTS -1
|
||||
|
||||
typedef struct{
|
||||
Display *disp;
|
||||
int scr;
|
||||
Screen *scr_ptr;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
int x;
|
||||
int y;
|
||||
unsigned int border_width;
|
||||
unsigned long foreground;
|
||||
unsigned long background;
|
||||
unsigned long border_color;
|
||||
const char *font_name;
|
||||
const char *fallback_font_name;
|
||||
XFontStruct *font;
|
||||
long sflags;
|
||||
const char *prog_name;
|
||||
const char *class_name;
|
||||
char *window_name;
|
||||
char *icon_name;
|
||||
} aX_default_resources;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern void aX_open_disp(aX_options *useropt, int useroptlen,
|
||||
int *argcp, char *argv[],
|
||||
aX_default_resources *defres);
|
||||
extern void aX_open_second_disp(char *display_name,
|
||||
aX_default_resources *defres);
|
||||
extern void aX_wait_event(int eventtype);
|
||||
extern void aX_look_events(void);
|
||||
extern char *aX_get_prog_res(const char *resname, const char* resclass);
|
||||
extern char *aX_get_resource(const char *resname, const char* resclass);
|
||||
|
||||
extern void aX_add_event_proc(Display *disp,
|
||||
Window win,
|
||||
int eventtype,
|
||||
void (*eventproc)(XEvent *, void *),
|
||||
unsigned long eventmask,
|
||||
void *ptr);
|
||||
|
||||
extern void aX_remove_event_proc(Display *disp,
|
||||
Window win,
|
||||
int eventtype,
|
||||
void (*eventproc)(XEvent *, void *));
|
||||
|
||||
extern void aX_close_one_disp(Display *disp);
|
||||
extern void aX_close_disp(void);
|
||||
extern unsigned long aX_get_color(Display *disp, int scr,
|
||||
unsigned long def_col, const char *color_name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _AX_H */
|
||||
|
||||
/* End of ax.h */
|
||||
|
||||
67
apps/plugins/zxbox/compr.c
Normal file
67
apps/plugins/zxbox/compr.c
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "compr.h"
|
||||
|
||||
void compr(void)
|
||||
{
|
||||
int j, c, lc, lled, rep, num;
|
||||
|
||||
rep = 0;
|
||||
|
||||
c = compr_read_byte();
|
||||
lc = 0;
|
||||
num = 0;
|
||||
|
||||
while(c >= 0) {
|
||||
if(lc == 0xED) lled = 1;
|
||||
else lled = 0;
|
||||
|
||||
lc = c;
|
||||
c = compr_read_byte();
|
||||
if(c == lc && num != 255 && (!lled || rep)) {
|
||||
if(!rep) {
|
||||
num = 1;
|
||||
rep = 1;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
else {
|
||||
if(rep) {
|
||||
if(num < 5 && lc != 0xED) for(j = 0; j < num; j++) compr_put_byte(lc);
|
||||
else{
|
||||
compr_put_byte(0xED);
|
||||
compr_put_byte(0xED);
|
||||
compr_put_byte(num);
|
||||
compr_put_byte(lc);
|
||||
num = 0;
|
||||
}
|
||||
rep = 0;
|
||||
}
|
||||
else compr_put_byte(lc);
|
||||
}
|
||||
}
|
||||
|
||||
compr_put_byte(0x00);
|
||||
compr_put_byte(0xED);
|
||||
compr_put_byte(0xED);
|
||||
compr_put_byte(0x00);
|
||||
}
|
||||
|
||||
28
apps/plugins/zxbox/compr.h
Normal file
28
apps/plugins/zxbox/compr.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COMPR_H
|
||||
#define COMPR_H
|
||||
|
||||
extern void compr(void);
|
||||
extern int compr_read_byte(void);
|
||||
extern void compr_put_byte(int i);
|
||||
|
||||
#endif /* COMPR_H */
|
||||
55
apps/plugins/zxbox/helpers.c
Normal file
55
apps/plugins/zxbox/helpers.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include "zxconfig.h"
|
||||
|
||||
int my_getc(int fd){
|
||||
unsigned char c;
|
||||
if ( rb->read(fd, &c, 1) )
|
||||
return c;
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
|
||||
off_t my_ftell(int fd){
|
||||
return rb->lseek(fd, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
int my_putc(char c , int fd){
|
||||
return rb->write(fd,&c,1);
|
||||
}
|
||||
|
||||
void *my_malloc(size_t size)
|
||||
{
|
||||
static char *offset = NULL;
|
||||
static int totalSize = 0;
|
||||
char *ret;
|
||||
|
||||
int remainder = size % 4;
|
||||
|
||||
size = size + 4-remainder;
|
||||
|
||||
if (offset == NULL)
|
||||
{
|
||||
offset = rb->plugin_get_audio_buffer(&totalSize);
|
||||
}
|
||||
|
||||
if (size + 4 > abs(totalSize) )
|
||||
{
|
||||
/* printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");
|
||||
printf("\nMALLOC BARF");*/
|
||||
/* We've made our point. */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = offset + 4;
|
||||
*((unsigned int *)offset) = size;
|
||||
|
||||
offset += size + 4;
|
||||
totalSize -= size + 4;
|
||||
return ret;
|
||||
|
||||
}
|
||||
15
apps/plugins/zxbox/helpers.h
Normal file
15
apps/plugins/zxbox/helpers.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef HELPERS_H
|
||||
#define HELPERS_H
|
||||
|
||||
extern int my_getc(int);
|
||||
extern int my_putc(char,int);
|
||||
extern off_t my_ftell(int);
|
||||
extern void *my_malloc(size_t size);
|
||||
|
||||
|
||||
#define getc my_getc
|
||||
#define malloc my_malloc
|
||||
#define ftell my_ftell
|
||||
#define putc my_putc
|
||||
|
||||
#endif /* HELPERS_H */
|
||||
108
apps/plugins/zxbox/interf.c
Normal file
108
apps/plugins/zxbox/interf.c
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "zxconfig.h"
|
||||
#include "interf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAXMSGLEN 2048
|
||||
|
||||
char filenamebuf[MAXFILENAME];
|
||||
char msgbuf[MAXMSGLEN];
|
||||
|
||||
char *spif_get_filename(void)
|
||||
{
|
||||
char *name=NULL;
|
||||
/* char *name, *s;
|
||||
|
||||
s = get_filename_line();
|
||||
for(; *s && isspace((int) *s); s++);
|
||||
name = s;
|
||||
for(; *s && isgraph((int) *s); s++);
|
||||
*s = '\0';
|
||||
|
||||
if(name == s) {
|
||||
printf("Canceled!\n");
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
return name;
|
||||
}
|
||||
|
||||
char *spif_get_tape_fileinfo(int *startp, int *nump)
|
||||
{
|
||||
*startp=*nump=0;
|
||||
char *name=NULL;
|
||||
/* char *name, *s;
|
||||
int res;
|
||||
|
||||
s = get_filename_line();
|
||||
for(; *s && isspace((int) *s); s++);
|
||||
name = s;
|
||||
for(; *s && isgraph((int) *s); s++);
|
||||
|
||||
if(name != s) res = 1;
|
||||
else res = 0;
|
||||
|
||||
if(*s) {
|
||||
*s = '\0';
|
||||
s++;
|
||||
if(*s) {
|
||||
int r1;
|
||||
|
||||
r1 = sscanf(s, "%d %d", startp, nump);
|
||||
if(r1 > 0) res += r1;
|
||||
}
|
||||
}
|
||||
|
||||
if(res < 1) {
|
||||
printf("Canceled!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(res < 2) *startp = -1;
|
||||
if(res < 3) *nump = -1;
|
||||
*/
|
||||
return name;
|
||||
}
|
||||
|
||||
void put_msg(const char *msg)
|
||||
{
|
||||
#ifndef USE_GRAY
|
||||
rb->splash (HZ/10,true , msg );
|
||||
#else
|
||||
LOGF(msg);
|
||||
(void)msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void put_tmp_msg(const char *msg)
|
||||
{
|
||||
#ifndef USE_GRAY
|
||||
rb->splash (HZ/10,true , msg );
|
||||
#else
|
||||
LOGF(msg);
|
||||
(void)msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
32
apps/plugins/zxbox/interf.h
Normal file
32
apps/plugins/zxbox/interf.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INTERF_H
|
||||
#define INTERF_H
|
||||
|
||||
#define MAXFILENAME 1024
|
||||
|
||||
extern char filenamebuf[];
|
||||
extern char msgbuf[];
|
||||
extern char *spif_get_filename(void);
|
||||
extern void put_msg(const char *msg);
|
||||
extern void put_tmp_msg(const char *msg);
|
||||
|
||||
#endif /* INTERF_H */
|
||||
82
apps/plugins/zxbox/keymaps.h
Normal file
82
apps/plugins/zxbox/keymaps.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#ifndef KEYMAPS_H
|
||||
#define KEYMAPS_H
|
||||
|
||||
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
||||
(CONFIG_KEYPAD == IPOD_3G_PAD)
|
||||
|
||||
#define ZX_UP BUTTON_MENU
|
||||
#define ZX_DOWN BUTTON_PLAY
|
||||
#define ZX_SELECT BUTTON_SELECT
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
|
||||
#elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD
|
||||
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_SELECT BUTTON_SELECT
|
||||
#define ZX_MENU BUTTON_MODE
|
||||
|
||||
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
||||
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_SELECT BUTTON_SELECT
|
||||
#define ZX_MENU BUTTON_MENU
|
||||
|
||||
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
|
||||
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
#define ZX_SELECT BUTTON_SELECT
|
||||
#define ZX_MENU BUTTON_PLAY
|
||||
|
||||
#elif CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define ZX_SELECT BUTTON_PLAY
|
||||
#define ZX_MENU BUTTON_OFF
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
||||
#define ZX_SELECT BUTTON_MENU
|
||||
#define ZX_MENU BUTTON_OFF
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == GMINI100_PAD
|
||||
#define ZX_SELECT BUTTON_PLAY
|
||||
#define ZX_MENU BUTTON_OFF
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
||||
#define ZX_SELECT BUTTON_SELECT
|
||||
#define ZX_MENU BUTTON_PLAY
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_UP BUTTON_UP
|
||||
#define ZX_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
||||
#define ZX_SELECT BUTTON_REW
|
||||
#define ZX_MENU BUTTON_FF
|
||||
#define ZX_LEFT BUTTON_LEFT
|
||||
#define ZX_RIGHT BUTTON_RIGHT
|
||||
#define ZX_UP BUTTON_SCROLL_UP
|
||||
#define ZX_DOWN BUTTON_SCROLL_DOWN
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
201
apps/plugins/zxbox/keynames.c
Normal file
201
apps/plugins/zxbox/keynames.c
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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>
|
||||
|
||||
const char *spcf_keynames_ascii[95] = {
|
||||
"space",
|
||||
"exclam",
|
||||
"quotedbl",
|
||||
"numbersign",
|
||||
"dollar",
|
||||
"percent",
|
||||
"ampersand",
|
||||
"apostrophe",
|
||||
"parenleft",
|
||||
"parenright",
|
||||
"asterisk",
|
||||
"plus",
|
||||
"comma",
|
||||
"minus",
|
||||
"period",
|
||||
"slash",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"colon",
|
||||
"semicolon",
|
||||
"less",
|
||||
"equal",
|
||||
"greater",
|
||||
"question",
|
||||
"at",
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"I",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"O",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"bracketleft",
|
||||
"backslash",
|
||||
"bracketright",
|
||||
"asciicircum",
|
||||
"underscore",
|
||||
"grave",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"f",
|
||||
"g",
|
||||
"h",
|
||||
"i",
|
||||
"j",
|
||||
"k",
|
||||
"l",
|
||||
"m",
|
||||
"n",
|
||||
"o",
|
||||
"p",
|
||||
"q",
|
||||
"r",
|
||||
"s",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"braceleft",
|
||||
"bar",
|
||||
"braceright",
|
||||
"asciitilde"
|
||||
};
|
||||
|
||||
const char *spcf_keynames_misc[256] = {
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
"BackSpace", "Tab", "Linefeed", "Clear",
|
||||
NULL, "Return", NULL, NULL,
|
||||
|
||||
NULL, NULL, NULL, "Pause",
|
||||
"Scroll_Lock", "Sys_Req", NULL, NULL,
|
||||
NULL, NULL, NULL, "Escape",
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
"Multi_key", NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
"Home", "Left", "Up", "Right",
|
||||
"Down", "Page_Up", "Page_Down", "End",
|
||||
"Begin", NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
"Select", "Print", "Execute", "Insert",
|
||||
NULL, "Undo", "Redo", "Menu",
|
||||
"Find", "Cancel", "Help", "Break",
|
||||
NULL, NULL, NULL, NULL,
|
||||
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, "Mode_switch", "Num_Lock",
|
||||
|
||||
"KP_Space", NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
"KP_Tab", NULL, NULL, NULL,
|
||||
NULL, "KP_Enter", NULL, NULL,
|
||||
|
||||
NULL, "KP_F1", "KP_F2", "KP_F3",
|
||||
"KP_F4", "KP_Home", "KP_Left", "KP_Up",
|
||||
"KP_Right", "KP_Down", "KP_Page_Up", "KP_Page_Down",
|
||||
"KP_End", "KP_Begin", "KP_Insert", "KP_Delete",
|
||||
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, "KP_Multiply", "KP_Add",
|
||||
"KP_Separator", "KP_Subtract", "KP_Decimal", "KP_Divide",
|
||||
|
||||
"KP_0", "KP_1", "KP_2", "KP_3",
|
||||
"KP_4", "KP_5", "KP_6", "KP_7",
|
||||
"KP_8", "KP_9", NULL, NULL,
|
||||
NULL, "KP_Equal", "F1", "F2",
|
||||
|
||||
"F3", "F4", "F5", "F6",
|
||||
"F7", "F8", "F9", "F10",
|
||||
"F11", "F12", "F13", "F14",
|
||||
"F15", "F16", "F17", "F18",
|
||||
|
||||
"F19", "F20", "F21", "F22",
|
||||
"F23", "F24", "F25", "F26",
|
||||
"F27", "F28", "F29", "F30",
|
||||
"F31", "F32", "F33", "F34",
|
||||
|
||||
"F35", "Shift_L", "Shift_R", "Control_L",
|
||||
"Control_R", "Caps_Lock", "Shift_Lock", "Meta_L",
|
||||
"Meta_R", "Alt_L", "Alt_R", "Super_L",
|
||||
"Super_R", "Hyper_L", "Hyper_R", NULL,
|
||||
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, "Delete"
|
||||
};
|
||||
134
apps/plugins/zxbox/loadim.c
Normal file
134
apps/plugins/zxbox/loadim.c
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/* loadim.c */
|
||||
|
||||
/*
|
||||
This file was generated by ./bin_to_c from binary image
|
||||
file `loadim.z80'
|
||||
*/
|
||||
|
||||
unsigned char loadim[] = {
|
||||
0x00, 0x40, 0x11, 0x00, 0xCB, 0x5C, 0x59, 0x05, 0x4C, 0xFF,
|
||||
0x3F, 0x57, 0x2E, 0x11, 0x00, 0x21, 0x17, 0x9B, 0x36, 0xBC,
|
||||
0x7E, 0x00, 0x01, 0x3A, 0x5C, 0xE2, 0x5C, 0x01, 0x01, 0x61,
|
||||
0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED,
|
||||
0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00,
|
||||
0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED,
|
||||
0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00,
|
||||
0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED,
|
||||
0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00,
|
||||
0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED,
|
||||
0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00,
|
||||
0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED,
|
||||
0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0x18, 0x00,
|
||||
0xED, 0xED, 0xFF, 0x38, 0xED, 0xED, 0xFF, 0x38, 0xED, 0xED,
|
||||
0xFF, 0x38, 0x38, 0x38, 0x38, 0xED, 0xED, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0x00, 0x0D, 0x05, 0x23, 0x0D, 0x0D, 0x23,
|
||||
0x05, 0xED, 0xED, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x0B,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x06, 0x00, 0x10, 0xED, 0xED,
|
||||
0x1A, 0x00, 0x3C, 0x40, 0x00, 0xFF, 0x8C, 0x01, 0x54, 0xFF,
|
||||
0xED, 0xED, 0x05, 0x00, 0xFF, 0xFE, 0xFF, 0x01, 0x38, 0x00,
|
||||
0x00, 0xCB, 0x5C, 0x00, 0x00, 0xB6, 0x5C, 0xB6, 0x5C, 0xCB,
|
||||
0x5C, 0xD0, 0x5C, 0xCA, 0x5C, 0xCC, 0x5C, 0xCF, 0x5C, 0xCF,
|
||||
0x5C, 0x00, 0x00, 0xD1, 0x5C, 0xF3, 0x5C, 0xF3, 0x5C, 0x1B,
|
||||
0x92, 0x5C, 0x10, 0x02, 0xED, 0xED, 0x08, 0x00, 0x01, 0x1A,
|
||||
0x00, 0x00, 0x93, 0x00, 0x00, 0x58, 0xFF, 0x00, 0x00, 0x21,
|
||||
0x00, 0x5B, 0x21, 0x17, 0x00, 0x40, 0xE0, 0x50, 0x21, 0x18,
|
||||
0x21, 0x17, 0x01, 0x38, 0x00, 0x38, 0xED, 0xED, 0x22, 0x00,
|
||||
0x57, 0xFF, 0xFF, 0xFF, 0xF4, 0x09, 0xA8, 0x10, 0x4B, 0xF4,
|
||||
0x09, 0xC4, 0x15, 0x53, 0x81, 0x0F, 0xC4, 0x15, 0x52, 0xF4,
|
||||
0x09, 0xC4, 0x15, 0x50, 0x80, 0x80, 0xEF, 0x22, 0x22, 0x0D,
|
||||
0x80, 0x00, 0xFF, 0xED, 0xED, 0x09, 0x20, 0x00, 0x00, 0x00,
|
||||
0x80, 0xED, 0xED, 0x12, 0x00, 0x80, 0x0D, 0xCE, 0x5C, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF,
|
||||
0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED,
|
||||
0xED, 0xFF, 0x00, 0xED, 0xED, 0xFF, 0x00, 0xED, 0xED, 0xC4,
|
||||
0x00, 0xF3, 0x0D, 0xCE, 0x0B, 0xE3, 0x50, 0xCE, 0x0B, 0xE4,
|
||||
0x50, 0x1D, 0x17, 0xDC, 0x0A, 0xCE, 0x0B, 0xE7, 0x50, 0x1A,
|
||||
0x17, 0xDC, 0x0A, 0xD7, 0x18, 0x38, 0x00, 0x38, 0x00, 0x0D,
|
||||
0x19, 0xCF, 0x5C, 0xA9, 0x18, 0x06, 0x03, 0x07, 0x5C, 0xB1,
|
||||
0x33, 0xB1, 0x33, 0xD6, 0x5C, 0xD0, 0x5C, 0x13, 0x01, 0x5D,
|
||||
0x16, 0xA5, 0x16, 0x71, 0x07, 0xE2, 0x5C, 0xCB, 0x5C, 0x76,
|
||||
0x1B, 0x03, 0x13, 0x00, 0x3E, 0x00, 0x3C, 0x42, 0x42, 0x7E,
|
||||
0x42, 0x42, 0x00, 0x00, 0x7C, 0x42, 0x7C, 0x42, 0x42, 0x7C,
|
||||
0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00,
|
||||
0x78, 0x44, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00, 0x7E, 0x40,
|
||||
0x7C, 0x40, 0x40, 0x7E, 0x00, 0x00, 0x7E, 0x40, 0x7C, 0x40,
|
||||
0x40, 0x40, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x4E, 0x42, 0x3C,
|
||||
0x00, 0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00, 0x00,
|
||||
0x3E, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x02, 0x02,
|
||||
0x02, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x44, 0x48, 0x70, 0x48,
|
||||
0x44, 0x42, 0x00, 0x00, 0xED, 0xED, 0x05, 0x40, 0x7E, 0x00,
|
||||
0x00, 0x42, 0x66, 0x5A, 0x42, 0x42, 0x42, 0x00, 0x00, 0x42,
|
||||
0x62, 0x52, 0x4A, 0x46, 0x42, 0x00, 0x00, 0x3C, 0x42, 0x42,
|
||||
0x42, 0x42, 0x3C, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x40,
|
||||
0x40, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x52, 0x4A, 0x3C, 0x00,
|
||||
0x00, 0x7C, 0x42, 0x42, 0x7C, 0x44, 0x42, 0x00, 0x00, 0x3C,
|
||||
0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00, 0x00, 0xFE, 0xED, 0xED,
|
||||
0x05, 0x10, 0x00, 0x00, 0xED, 0xED, 0x05, 0x42, 0x3C, 0x00,
|
||||
0x00, 0xED, 0xED, 0x00
|
||||
};
|
||||
|
||||
const unsigned long loadim_size = 1204;
|
||||
|
||||
/* End of loadim.c */
|
||||
1
apps/plugins/zxbox/menu.h
Normal file
1
apps/plugins/zxbox/menu.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
extern bool zxbox_menu(void);
|
||||
140
apps/plugins/zxbox/misc.c
Normal file
140
apps/plugins/zxbox/misc.c
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "misc.h"
|
||||
#include "zxconfig.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "helpers.h"
|
||||
/*#include <errno.h>*/
|
||||
#include "zxconfig.h"
|
||||
#define DIR_SEP_CHAR '/'
|
||||
|
||||
char *get_base_name(char *fname)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = fname;
|
||||
for(; *p; p++);
|
||||
for(; p >= fname && *p != DIR_SEP_CHAR; p--);
|
||||
return ++p;
|
||||
}
|
||||
|
||||
|
||||
int check_ext(const char *filename, const char *ext)
|
||||
{
|
||||
int flen, elen;
|
||||
int i;
|
||||
|
||||
flen = (int) rb->strlen(filename);
|
||||
elen = (int) rb->strlen(ext);
|
||||
|
||||
if(flen <= elen + 1) return 0;
|
||||
|
||||
if(filename[flen-elen-1] != '.') return 0;
|
||||
for(i = 0; i < elen; i++) if(filename[flen-elen+i] != toupper(ext[i])) break;
|
||||
if(i == elen) return 1;
|
||||
for(i = 0; i < elen; i++) if(filename[flen-elen+i] != tolower(ext[i])) break;
|
||||
if(i == elen) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void add_extension(char *filename, const char *ext)
|
||||
{
|
||||
int i;
|
||||
int upper;
|
||||
|
||||
i = (int) rb->strlen(filename);
|
||||
if(filename[i] > 64 && filename[i] < 96) upper = 1;
|
||||
else upper = 0;
|
||||
|
||||
filename[i++] = '.';
|
||||
if(upper)
|
||||
for(; *ext; i++, ext++) filename[i] = toupper(*ext);
|
||||
else
|
||||
for(; *ext; i++, ext++) filename[i] = tolower(*ext);
|
||||
}
|
||||
|
||||
int file_exist(const char *filename)
|
||||
{
|
||||
/*FILE *fp;*/
|
||||
int fd;
|
||||
|
||||
fd = rb->open(filename, O_RDONLY);
|
||||
if(fd != NULL) {
|
||||
rb->close(fd);
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
/* if(errno == ENOENT) return 0;
|
||||
return 1;*/
|
||||
}
|
||||
|
||||
int try_extension(char *filename, const char *ext)
|
||||
{
|
||||
int tend;
|
||||
|
||||
tend = (int) rb->strlen(filename);
|
||||
add_extension(filename, ext);
|
||||
if(file_exist(filename)) return 1;
|
||||
|
||||
filename[tend] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *malloc_err(size_t size)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = (char *) my_malloc(size);
|
||||
if(p == NULL) {
|
||||
// fprintf(stderr, "Out of memory!\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
return (void *) p;
|
||||
}
|
||||
|
||||
char *make_string(char *ostr, const char *nstr)
|
||||
{
|
||||
if(ostr != NULL) /*free(ostr)*/ostr=0;
|
||||
ostr = malloc_err(rb->strlen(nstr) + 1);
|
||||
rb->strcpy(ostr, nstr);
|
||||
return ostr;
|
||||
}
|
||||
|
||||
void free_string(char *ostr)
|
||||
{
|
||||
if(ostr != NULL) /*free(ostr)*/ostr=0;
|
||||
}
|
||||
|
||||
int mis_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
for(;; s1++, s2++) {
|
||||
c1 = tolower(*s1);
|
||||
c2 = tolower(*s2);
|
||||
|
||||
if(!c1 || c1 != c2) break;
|
||||
}
|
||||
return c1-c2;
|
||||
}
|
||||
38
apps/plugins/zxbox/misc.h
Normal file
38
apps/plugins/zxbox/misc.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
extern char *get_base_name(char *fname);
|
||||
extern int check_ext(const char *filename, const char *ext);
|
||||
extern void add_extension(char *filename, const char *ext);
|
||||
extern int file_exist(const char *filename);
|
||||
extern int try_extension(char *filename, const char *ext);
|
||||
extern char *spif_get_tape_fileinfo(int *startp, int *nump);
|
||||
extern void *malloc_err(size_t size);
|
||||
extern char *make_string(char *ostr, const char *nstr);
|
||||
extern void free_string(char *ostr);
|
||||
|
||||
extern int mis_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
#endif /* MISC_H */
|
||||
1652
apps/plugins/zxbox/rom_imag.c
Normal file
1652
apps/plugins/zxbox/rom_imag.c
Normal file
File diff suppressed because it is too large
Load diff
727
apps/plugins/zxbox/snapshot.c
Normal file
727
apps/plugins/zxbox/snapshot.c
Normal file
|
|
@ -0,0 +1,727 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "misc.h"
|
||||
#include "helpers.h"
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
|
||||
#include "snapshot.h"
|
||||
#include "compr.h"
|
||||
#include "interf.h"
|
||||
|
||||
#include "spconf.h"
|
||||
|
||||
#include "interf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*#include <errno.h>*/
|
||||
/*#include "string.h"*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#define COMPRESS_SAVE 1
|
||||
|
||||
static char quick_snap_file[MAXFILENAME];
|
||||
static int qsnap_created = 0;
|
||||
typedef struct {
|
||||
int isfile;
|
||||
/*FILE *fp;*/
|
||||
int fd;
|
||||
|
||||
unsigned len;
|
||||
byte *at;
|
||||
} SNFILE;
|
||||
|
||||
|
||||
#define sngetc(snfp) ((snfp)->isfile ? getc((snfp)->fd) : snmgetc(snfp))
|
||||
|
||||
static int snmgetc(SNFILE *snfp)
|
||||
{
|
||||
if(!snfp->len) return EOF;
|
||||
snfp->len--;
|
||||
return *snfp->at++;
|
||||
}
|
||||
|
||||
static int snread(void *ptr, int size, SNFILE *snfp)
|
||||
{
|
||||
int i;
|
||||
byte *dest;
|
||||
|
||||
if(snfp->isfile) /*return (int) fread(ptr, 1, (size_t) size, snfp->fp);*/
|
||||
return (int) rb->read( snfp->fd,ptr, (size_t) size);
|
||||
|
||||
dest = (byte *) ptr;
|
||||
for(i = 0; snfp->len && size; i++, snfp->len--, size--)
|
||||
*dest++ = *snfp->at++;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* These structures are taken from 'spconv' by Henk de Groot */
|
||||
|
||||
struct sna_s {
|
||||
byte i;
|
||||
byte lbk;
|
||||
byte hbk;
|
||||
byte ebk;
|
||||
byte dbk;
|
||||
byte cbk;
|
||||
byte bbk;
|
||||
byte fbk;
|
||||
byte abk;
|
||||
byte l;
|
||||
byte h;
|
||||
byte e;
|
||||
byte d;
|
||||
byte c;
|
||||
byte b;
|
||||
byte iyl;
|
||||
byte iyh;
|
||||
byte ixl;
|
||||
byte ixh;
|
||||
byte iff2;
|
||||
byte r;
|
||||
byte f;
|
||||
byte a;
|
||||
byte spl;
|
||||
byte sph;
|
||||
byte im;
|
||||
byte border;
|
||||
};
|
||||
|
||||
#define sna_size 27 /* sizeof(struct sna_s)=27 */
|
||||
|
||||
|
||||
struct z80_1_s {
|
||||
byte a; /*00*/
|
||||
byte f; /*01*/
|
||||
byte c; /*02*/
|
||||
byte b; /*03*/
|
||||
byte l; /*04*/
|
||||
byte h; /*05*/
|
||||
byte pcl; /*06*/
|
||||
byte pch; /*07*/
|
||||
byte spl; /*08*/
|
||||
byte sph; /*09*/
|
||||
byte i; /*0A*/
|
||||
byte r; /*0B*/
|
||||
byte data; /*0C*/
|
||||
byte e; /*0D*/
|
||||
byte d; /*0E*/
|
||||
byte cbk; /*0F*/
|
||||
byte bbk; /*10*/
|
||||
byte ebk; /*11*/
|
||||
byte dbk; /*12*/
|
||||
byte lbk; /*13*/
|
||||
byte hbk; /*14*/
|
||||
byte abk; /*15*/
|
||||
byte fbk; /*16*/
|
||||
byte iyl; /*17*/
|
||||
byte iyh; /*18*/
|
||||
byte ixl; /*19*/
|
||||
byte ixh; /*1A*/
|
||||
byte iff1; /*1B*/
|
||||
byte iff2; /*1C*/
|
||||
byte im; /*1D*/
|
||||
};
|
||||
|
||||
#define z80_145_size 0x1e /* length of z80 V1.45 header */
|
||||
|
||||
|
||||
struct z80_2_s {
|
||||
/* Extended 2.01 and 3.0 header, flagged with PC=0 */
|
||||
byte h2_len_l; /*1E*/
|
||||
byte h2_len_h; /*1F*/
|
||||
byte n_pcl; /*20*/
|
||||
byte n_pch; /*21*/
|
||||
byte hardware; /*22*/
|
||||
byte samram; /*23*/
|
||||
byte if1_paged; /*24*/
|
||||
byte r_ldir_emu; /*25*/
|
||||
byte last_out; /*26*/
|
||||
byte sound_reg[16]; /*27*/
|
||||
|
||||
/* Continues with extended 3.0 header, but this part is not used anyway */
|
||||
};
|
||||
|
||||
#define z80_201_ext_size 23 /* length of extended z80 V2.01 header */
|
||||
#define z80_300_ext_size 54 /* length of extended z80 V3.0 header */
|
||||
|
||||
|
||||
struct z80_page_s {
|
||||
byte blklen_l; /*00*/
|
||||
byte blklen_h; /*01*/
|
||||
byte page_num; /*02*/
|
||||
};
|
||||
|
||||
#define z80_pg_size 3 /* sizeof(struct z80_page_s)=3 */
|
||||
|
||||
|
||||
/*static FILE *savfp;*/
|
||||
static int savfd;
|
||||
static int memptr;
|
||||
|
||||
int compr_read_byte(void)
|
||||
{
|
||||
if(memptr < 0x10000) return z80_proc.mem[memptr++];
|
||||
else return -1;
|
||||
}
|
||||
|
||||
void compr_put_byte(int i)
|
||||
{
|
||||
putc(i, savfd);
|
||||
}
|
||||
|
||||
|
||||
#define STORE_NORMAL_REGS(head) \
|
||||
head.f = RF; /* F reg */ \
|
||||
head.a = RA; /* A reg */ \
|
||||
head.b = RB; /* B reg */ \
|
||||
head.c = RC; /* C reg */ \
|
||||
head.d = RD; /* D reg */ \
|
||||
head.e = RE; /* E reg */ \
|
||||
head.h = RH; /* H reg */ \
|
||||
head.l = RL; /* L reg */ \
|
||||
head.fbk = FBK; /* F' reg */ \
|
||||
head.abk = ABK; /* A' reg */ \
|
||||
head.bbk = BBK; /* B' reg */ \
|
||||
head.cbk = CBK; /* C' reg */ \
|
||||
head.dbk = DBK; /* D' reg */ \
|
||||
head.ebk = EBK; /* E' reg */ \
|
||||
head.hbk = HBK; /* H' reg */ \
|
||||
head.lbk = LBK; /* L' reg */ \
|
||||
head.iyh = YH; /* IY reg */ \
|
||||
head.iyl = YL; \
|
||||
head.ixh = XH; /* IX reg */ \
|
||||
head.ixl = XL
|
||||
|
||||
|
||||
#define LOAD_NORMAL_REGS(head) \
|
||||
RF = head.f; /* F reg */ \
|
||||
RA = head.a; /* A reg */ \
|
||||
RB = head.b; /* B reg */ \
|
||||
RC = head.c; /* C reg */ \
|
||||
RD = head.d; /* D reg */ \
|
||||
RE = head.e; /* E reg */ \
|
||||
RH = head.h; /* H reg */ \
|
||||
RL = head.l; /* L reg */ \
|
||||
FBK = head.fbk; /* F' reg */ \
|
||||
ABK = head.abk; /* A' reg */ \
|
||||
BBK = head.bbk; /* B' reg */ \
|
||||
CBK = head.cbk; /* C' reg */ \
|
||||
DBK = head.dbk; /* D' reg */ \
|
||||
EBK = head.ebk; /* E' reg */ \
|
||||
HBK = head.hbk; /* H' reg */ \
|
||||
LBK = head.lbk; /* L' reg */ \
|
||||
YH = head.iyh; /* IY reg */ \
|
||||
YL = head.iyl; \
|
||||
XH = head.ixh; /* IX reg */ \
|
||||
XL = head.ixl
|
||||
|
||||
|
||||
static void snsh_z80_save(int fd)
|
||||
{
|
||||
struct z80_1_s z80;
|
||||
|
||||
int to_comp = COMPRESS_SAVE;
|
||||
|
||||
STORE_NORMAL_REGS(z80);
|
||||
|
||||
z80.i = RI; /* I reg */
|
||||
z80.r = RR; /* R reg */
|
||||
|
||||
z80.sph = SPH; /* SP reg */
|
||||
z80.spl = SPL;
|
||||
z80.pch = PCH; /* PC reg */
|
||||
z80.pcl = PCL;
|
||||
|
||||
z80.iff1 = z80_proc.iff1; /* iff1 */
|
||||
z80.iff2 = z80_proc.iff2; /* iff2 */
|
||||
|
||||
z80.im = (z80_proc.it_mode & 0x03) | 0x60;
|
||||
/*
|
||||
Bit 0-1: Interrupt mode (0, 1 or 2)
|
||||
Bit 2 : 1=Issue 2 emulation
|
||||
Bit 3 : 1=Double interrupt frequency
|
||||
Bit 4-5: 1=High video synchronisation
|
||||
3=Low video synchronisation
|
||||
0,2=Normal
|
||||
Bit 6-7: 0=Cursor/Protek/AGF joystick
|
||||
1=Kempston joystick
|
||||
2=Sinclair 1 joystick
|
||||
3=Sinclair 2 joystick
|
||||
*/
|
||||
|
||||
z80.data = ((RR >> 7) & 0x01) |
|
||||
((z80_proc.ula_outport & 0x07) << 1) |
|
||||
(to_comp ? 0x20 : 0);
|
||||
/*
|
||||
Bit 0 : Bit 7 of the R-register
|
||||
Bit 1-3: Border colour
|
||||
Bit 4 : 1=Basic SamRom switched in
|
||||
Bit 5 : 1=Block of data is compressed
|
||||
Bit 6-7: No meaning
|
||||
*/
|
||||
|
||||
|
||||
/*fwrite(&z80, z80_145_size, 1, fp);*/
|
||||
rb->write(fd,&z80,z80_145_size);
|
||||
|
||||
if(!to_comp)
|
||||
/*fwrite(z80_proc.mem + 0x4000, 0xC000, 1, fp);*/
|
||||
rb->write(fd,z80_proc.mem + 0x4000,0xC000);
|
||||
else {
|
||||
memptr = 0x4000;
|
||||
savfd = fd;
|
||||
compr();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void snsh_sna_save(int fd)
|
||||
{
|
||||
struct sna_s sna;
|
||||
byte saves1, saves2;
|
||||
|
||||
STORE_NORMAL_REGS(sna);
|
||||
|
||||
sna.i = RI; /* I reg */
|
||||
sna.r = RR; /* R reg */
|
||||
|
||||
sna.border = z80_proc.ula_outport & 0x07;
|
||||
|
||||
SP -= 2;
|
||||
|
||||
sna.sph = SPH; /* SP reg */
|
||||
sna.spl = SPL;
|
||||
|
||||
saves1 = z80_proc.mem[SP];
|
||||
saves2 = z80_proc.mem[(dbyte)(SP+1)];
|
||||
if(SP >= 0x4000) {
|
||||
z80_proc.mem[SP] = PCL;
|
||||
if(SP < 0xFFFF) z80_proc.mem[SP+1] = PCH;
|
||||
}
|
||||
|
||||
sna.iff2 = z80_proc.iff2 ? 0xff : 0x00; /* iff2 */
|
||||
|
||||
sna.im = z80_proc.it_mode & 0x03;
|
||||
|
||||
/*fwrite(&sna, sna_size, 1, fp);
|
||||
fwrite(z80_proc.mem + 0x4000, 0xC000, 1, fp);*/
|
||||
rb->write(fd,&sna, sna_size);
|
||||
rb->write(fd,z80_proc.mem + 0x4000, 0xC000);
|
||||
|
||||
if(SP > 0x4000) {
|
||||
z80_proc.mem[SP] = saves1;
|
||||
if(SP < 0xFFFF) z80_proc.mem[SP+1] = saves2;
|
||||
}
|
||||
|
||||
SP += 2;
|
||||
}
|
||||
|
||||
#define GET_DATA(c) { \
|
||||
if(!datalen) break; \
|
||||
c = sngetc(fp); \
|
||||
if(c == EOF) break; \
|
||||
if(datalen > 0) datalen--; \
|
||||
}
|
||||
|
||||
|
||||
static void read_compressed_data(SNFILE *fp, byte *start, unsigned size,
|
||||
long datalen)
|
||||
{
|
||||
int j;
|
||||
int times, last_ed, ch;
|
||||
byte *p, *end;
|
||||
|
||||
p = start;
|
||||
end = start+size;
|
||||
last_ed = 0;
|
||||
while(p < end) {
|
||||
GET_DATA(ch);
|
||||
if(ch != 0xED) {
|
||||
last_ed = 0;
|
||||
*p++ = ch;
|
||||
}
|
||||
else {
|
||||
if(last_ed) {
|
||||
last_ed = 0;
|
||||
p--;
|
||||
GET_DATA(times);
|
||||
if(times == 0) break;
|
||||
|
||||
GET_DATA(ch);
|
||||
if(p + times > end) {
|
||||
put_msg("Warning: Repeat parameter too large in snapshot");
|
||||
times = (int) ((long) end - (long) p);
|
||||
}
|
||||
for(j = 0; j < times; j++) *p++ = ch;
|
||||
}
|
||||
else {
|
||||
last_ed = 1;
|
||||
*p++ = 0xED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(datalen < 0) {
|
||||
if(sngetc(fp) != 0 || sngetc(fp) != 0xED ||
|
||||
sngetc(fp) != 0xED || sngetc(fp) != 0)
|
||||
put_msg("Warning: Illegal ending of snapshot");
|
||||
}
|
||||
|
||||
if(datalen > 0) {
|
||||
while(datalen) {
|
||||
if(sngetc(fp) == EOF) break;
|
||||
datalen--;
|
||||
}
|
||||
put_msg("Warning: Page too long in snapshot");
|
||||
}
|
||||
|
||||
if(p < end) put_msg("Warning: Page too short in snapshot");
|
||||
}
|
||||
|
||||
static int read_header(void *p, int size, SNFILE *fp)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = snread(p, size, fp);
|
||||
if(res != size) {
|
||||
put_msg("Error, End Of File in snapshot header");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int read_z80_page(SNFILE *fp)
|
||||
{
|
||||
struct z80_page_s page;
|
||||
unsigned datalen;
|
||||
unsigned pos = 0;
|
||||
int validpage;
|
||||
|
||||
int res;
|
||||
|
||||
res = snread(&page, z80_pg_size, fp);
|
||||
if(res == 0) return 0;
|
||||
if(res != z80_pg_size) {
|
||||
put_msg("Error, End Of File in page header");
|
||||
return 0;
|
||||
}
|
||||
|
||||
datalen = (page.blklen_h << 8) | page.blklen_l;
|
||||
|
||||
validpage = 1;
|
||||
switch(page.page_num) {
|
||||
case 4:
|
||||
pos = 0x8000;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
pos = 0xC000;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
pos = 0x4000;
|
||||
break;
|
||||
|
||||
default:
|
||||
validpage = 0;
|
||||
while(datalen) {
|
||||
if(sngetc(fp) == EOF) {
|
||||
put_msg("Warning: Page too short in snapshot");
|
||||
break;
|
||||
}
|
||||
datalen--;
|
||||
}
|
||||
}
|
||||
|
||||
if(validpage) read_compressed_data(fp, z80_proc.mem+pos, 0x4000,
|
||||
(long) datalen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void snsh_z80_load(SNFILE *fp)
|
||||
{
|
||||
struct z80_1_s z80;
|
||||
|
||||
if(!read_header(&z80, z80_145_size, fp)) return;
|
||||
if(z80.pch == 0 && z80.pcl == 0) {
|
||||
struct z80_2_s z80_2;
|
||||
int ext_size, rem;
|
||||
if(!read_header(&z80_2, 2, fp)) return;
|
||||
ext_size = z80_2.h2_len_l | (z80_2.h2_len_h << 8);
|
||||
if(ext_size < z80_201_ext_size) {
|
||||
put_msg("Error in Z80 header");
|
||||
return;
|
||||
}
|
||||
if(!read_header(&z80_2.n_pcl, z80_201_ext_size, fp)) return;
|
||||
rem = ext_size - z80_201_ext_size;
|
||||
for(; rem; rem--) sngetc(fp);
|
||||
|
||||
if(z80_2.hardware >= 3 && (ext_size == z80_201_ext_size ||
|
||||
z80_2.hardware >= 4)) {
|
||||
put_msg("Can't load non 48k snapshot");
|
||||
return;
|
||||
}
|
||||
if(z80_2.if1_paged) {
|
||||
put_msg("Can't load snapshot: IF1 roma paged in");
|
||||
return;
|
||||
}
|
||||
|
||||
PCH = z80_2.n_pch;
|
||||
PCL = z80_2.n_pcl;
|
||||
|
||||
while(read_z80_page(fp));
|
||||
}
|
||||
else {
|
||||
if(z80.data == 0xFF) z80.data = 1;
|
||||
if(z80.data & 0x20)
|
||||
read_compressed_data(fp, z80_proc.mem + 0x4000, 0xC000, -1);
|
||||
else {
|
||||
if(snread(z80_proc.mem + 0x4000, 0xC000, fp) != 0xC000)
|
||||
put_msg("Warning: Snapshot file too short (z80)");
|
||||
else if(sngetc(fp) != EOF)
|
||||
put_msg("Warning: Snapshot file too long");
|
||||
}
|
||||
|
||||
PCH = z80.pch;
|
||||
PCL = z80.pcl;
|
||||
}
|
||||
|
||||
|
||||
LOAD_NORMAL_REGS(z80);
|
||||
|
||||
RI = z80.i; /* I reg */
|
||||
RR = (z80.r & 0x7F) | ((z80.data & 0x01) << 7); /* R reg */
|
||||
|
||||
SPH = z80.sph; /* SP reg */
|
||||
SPL = z80.spl;
|
||||
|
||||
z80_proc.ula_outport = (z80_proc.ula_outport & ~(0x07)) |
|
||||
((z80.data >> 1) & 0x07);
|
||||
|
||||
/*
|
||||
Bit 0 : Bit 7 of the R-register
|
||||
Bit 1-3: Border colour
|
||||
Bit 4 : 1=Basic SamRom switched in
|
||||
Bit 5 : 1=Block of data is compressed
|
||||
Bit 6-7: No meaning
|
||||
*/
|
||||
|
||||
z80_proc.iff1 = z80.iff1 ? 1 : 0;
|
||||
z80_proc.iff2 = z80.iff2 ? 1 : 0;
|
||||
|
||||
z80_proc.it_mode = z80.im & 0x03;
|
||||
|
||||
/*
|
||||
Bit 0-1: Interrupt mode (0, 1 or 2)
|
||||
Bit 2 : 1=Issue 2 emulation
|
||||
Bit 3 : 1=Double interrupt frequency
|
||||
Bit 4-5: 1=High video synchronisation
|
||||
3=Low video synchronisation
|
||||
0,2=Normal
|
||||
Bit 6-7: 0=Cursor/Protek/AGF joystick
|
||||
1=Kempston joystick
|
||||
2=Sinclair 1 joystick
|
||||
3=Sinclair 2 joystick
|
||||
*/
|
||||
|
||||
z80_proc.haltstate = 0;
|
||||
|
||||
sp_init_screen_mark();
|
||||
}
|
||||
|
||||
static void snsh_sna_load(SNFILE *fp)
|
||||
{
|
||||
struct sna_s sna;
|
||||
|
||||
if(!read_header(&sna, sna_size, fp)) return;
|
||||
|
||||
if(snread(z80_proc.mem+0x4000, 0xC000, fp) != 0xC000)
|
||||
put_msg("Warning: Snapshot file too short (sna)");
|
||||
else if(sngetc(fp) != EOF)
|
||||
put_msg("Warning: Snapshot file too long");
|
||||
|
||||
LOAD_NORMAL_REGS(sna);
|
||||
|
||||
RI = sna.i; /* I reg */
|
||||
RR = sna.r; /* R reg */
|
||||
|
||||
z80_proc.ula_outport = (z80_proc.ula_outport & ~(0x07)) |
|
||||
(sna.border & 0x07);
|
||||
|
||||
SPH = sna.sph; /* SP reg */
|
||||
SPL = sna.spl;
|
||||
|
||||
PCL = z80_proc.mem[SP];
|
||||
if(SP >= 0x4000) z80_proc.mem[SP] = 0;
|
||||
SP++;
|
||||
PCH = z80_proc.mem[SP];
|
||||
if(SP >= 0x4000) z80_proc.mem[SP] = 0;
|
||||
SP++;
|
||||
|
||||
z80_proc.iff1 = z80_proc.iff2 = sna.iff2 ? 1 : 0;
|
||||
z80_proc.it_mode = sna.im & 0x03;
|
||||
|
||||
z80_proc.haltstate = 0;
|
||||
|
||||
sp_init_screen_mark();
|
||||
}
|
||||
/*
|
||||
static void cleanup_qsnap(void)
|
||||
{
|
||||
if(qsnap_created) rb->remove(quick_snap_file);
|
||||
}
|
||||
*/
|
||||
static void save_snapshot_file_type(char *name, int type)
|
||||
{
|
||||
/*FILE *snsh;*/
|
||||
int snsh;
|
||||
snsh = rb->open(name, O_WRONLY);
|
||||
if(snsh < 0) {
|
||||
snsh = rb->creat(name, O_WRONLY);
|
||||
/* sprintf(msgbuf, "Could not open snapshot file `%s', %s",
|
||||
name, strerror(errno));*/
|
||||
if(snsh < 0) {
|
||||
put_msg("Could not create snapshot file");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(type == SN_SNA) snsh_sna_save(snsh);
|
||||
else if(type == SN_Z80) snsh_z80_save(snsh);
|
||||
|
||||
rb->close(snsh);
|
||||
}
|
||||
|
||||
void save_snapshot_file(char *name)
|
||||
{
|
||||
int type;
|
||||
|
||||
rb->strncpy(filenamebuf, name, MAXFILENAME-10);
|
||||
filenamebuf[MAXFILENAME-10] = '\0';
|
||||
|
||||
type = SN_Z80;
|
||||
if(check_ext(filenamebuf, "z80")) type = SN_Z80;
|
||||
else if(check_ext(filenamebuf, "sna")) type = SN_SNA;
|
||||
else {
|
||||
add_extension(filenamebuf, "z80");
|
||||
type = SN_Z80;
|
||||
}
|
||||
|
||||
save_snapshot_file_type(filenamebuf, type);
|
||||
|
||||
/* sprintf(msgbuf, "Saved snapshot to file %s", filenamebuf);
|
||||
put_msg(msgbuf);*/
|
||||
}
|
||||
|
||||
void save_quick_snapshot(void)
|
||||
{
|
||||
/* if(!qsnap_created) {
|
||||
if(tmpnam(quick_snap_file) == NULL) {
|
||||
put_msg("Could not create temporary file for quick snapshot");
|
||||
return;
|
||||
}
|
||||
qsnap_created = 1;
|
||||
atexit(cleanup_qsnap);
|
||||
}
|
||||
save_snapshot_file_type(quick_snap_file, SN_Z80);*/
|
||||
}
|
||||
|
||||
void save_snapshot(void)
|
||||
{
|
||||
char name[MAXFILENAME];
|
||||
name[0]='/';
|
||||
name[1]='\0';
|
||||
put_msg("Enter name of snapshot file to save:");
|
||||
if (!rb->kbd_input((char*)&name, sizeof name))
|
||||
save_snapshot_file(&name[0]);
|
||||
}
|
||||
|
||||
|
||||
void load_snapshot_file_type(char *name, int type)
|
||||
{
|
||||
int filetype = FT_SNAPSHOT;
|
||||
/*FILE *snsh;*/
|
||||
int snsh;
|
||||
SNFILE snfil;
|
||||
|
||||
rb->strncpy(filenamebuf, name, MAXFILENAME-10);
|
||||
filenamebuf[MAXFILENAME-10] = '\0';
|
||||
|
||||
spcf_find_file_type(filenamebuf, &filetype, &type);
|
||||
if(type < 0) type = SN_Z80;
|
||||
|
||||
snsh = rb->open(filenamebuf, O_RDONLY);
|
||||
if(snsh < 0) {
|
||||
#ifndef USE_GRAY
|
||||
rb->splash(HZ,true, "Could not open snapshot file `%s'",filenamebuf);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
snfil.isfile = 1;
|
||||
snfil.fd = snsh;
|
||||
|
||||
if(type == SN_SNA) snsh_sna_load(&snfil);
|
||||
else if(type == SN_Z80) snsh_z80_load(&snfil);
|
||||
|
||||
rb->close(snsh);
|
||||
}
|
||||
|
||||
void snsh_z80_load_intern(byte *p, unsigned len)
|
||||
{
|
||||
SNFILE snfil;
|
||||
|
||||
snfil.isfile = 0;
|
||||
snfil.at = p;
|
||||
snfil.len = len;
|
||||
|
||||
snsh_z80_load(&snfil);
|
||||
}
|
||||
|
||||
void load_quick_snapshot(void)
|
||||
{
|
||||
if(!qsnap_created) {
|
||||
put_msg("No quick snapshot saved yet");
|
||||
return;
|
||||
}
|
||||
load_snapshot_file_type(quick_snap_file, SN_Z80);
|
||||
}
|
||||
|
||||
|
||||
void load_snapshot(void)
|
||||
{
|
||||
char *name;
|
||||
|
||||
put_msg("Enter name of snapshot file to load:");
|
||||
|
||||
name = spif_get_filename();
|
||||
if(name == NULL) return;
|
||||
|
||||
load_snapshot_file_type(name, -1);
|
||||
}
|
||||
|
||||
37
apps/plugins/zxbox/snapshot.h
Normal file
37
apps/plugins/zxbox/snapshot.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SNAPSHOT_H
|
||||
#define SNAPSHOT_H
|
||||
|
||||
#define SN_SNA 0
|
||||
#define SN_Z80 1
|
||||
|
||||
extern void save_snapshot_file(char *snsh_name);
|
||||
extern void load_snapshot_file_type(char *snsh_name, int type);
|
||||
extern void snsh_z80_load_intern(unsigned char *p, unsigned len);
|
||||
|
||||
extern void save_snapshot(void);
|
||||
extern void load_snapshot(void);
|
||||
|
||||
extern void save_quick_snapshot(void);
|
||||
extern void load_quick_snapshot(void);
|
||||
|
||||
#endif /* SNAPSHOT_H */
|
||||
84
apps/plugins/zxbox/sp_def.h
Normal file
84
apps/plugins/zxbox/sp_def.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "spperif.h"
|
||||
|
||||
#define MARK_SCR(addr) SPNM(scr_mark)[(addr) >> 5] |= 1 << ((addr) & 0x1F)
|
||||
|
||||
#define PUTMEM(addr, ptr, val) \
|
||||
{ \
|
||||
register byte addrhi; \
|
||||
addrhi = (dbyte) (addr) >> 8; \
|
||||
if(addrhi >= 0x5B) *(ptr) = (val); \
|
||||
else if(addrhi & 0x40) { \
|
||||
*(ptr) = (val); \
|
||||
MARK_SCR((dbyte) (addr)); \
|
||||
if(DANM(next_scri) >= 0 && DANM(tc) > 86) \
|
||||
DANM(tc) -= 2; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SOUNDPORT 0x10
|
||||
|
||||
/* TODO: attribute or pixel byte is present on unused ports? */
|
||||
|
||||
|
||||
#define IN(porth, portl, dest) \
|
||||
{ \
|
||||
if(!((portl) & DANM(inport_mask))) { \
|
||||
dest = PORT(inports)[portl]; \
|
||||
} \
|
||||
else if(!((portl) & 1)) { \
|
||||
if(DANM(imp_change) > DANM(tc)) { \
|
||||
DANM(imp_change) = 0; \
|
||||
DANM(ula_inport) ^= 0x40; \
|
||||
} \
|
||||
dest = SPECP(fe_inport_high)[porth] & DANM(ula_inport); \
|
||||
DANM(tc) -= 1; \
|
||||
} \
|
||||
else { \
|
||||
register int scri; \
|
||||
scri = DANM(next_scri); \
|
||||
dest = (scri < 0 || DANM(tc) <= 96) \
|
||||
? 0xFF : DANM(mem)[(scri<<5)+((224-DANM(tc))>>2)]; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define OUT(porth, portl, source) \
|
||||
{ \
|
||||
if(!((portl) & 1)) { \
|
||||
if((DANM(ula_outport) ^ (source)) & SOUNDPORT) { \
|
||||
DANM(sound_change) = 1; \
|
||||
if((source) & SOUNDPORT) DANM(sound_sam) += DANM(tc); \
|
||||
else DANM(sound_sam) -= DANM(tc); \
|
||||
} \
|
||||
DANM(ula_outport) = (source); \
|
||||
DANM(tc) -= 1; \
|
||||
} \
|
||||
PORT(outports)[portl] = (source); \
|
||||
}
|
||||
|
||||
#define DI_CHECK \
|
||||
if(PC == LOAD_DI+1 && SPNM(quick_load)) \
|
||||
SPNM(load_trapped) = 1, \
|
||||
DANM(haltstate) = 1, \
|
||||
DANM(tc) = 0;
|
||||
|
||||
141
apps/plugins/zxbox/spconf.c
Normal file
141
apps/plugins/zxbox/spconf.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "misc.h"
|
||||
#include "spconf_p.h"
|
||||
#include "spver.h"
|
||||
#include "interf.h"
|
||||
#include "spscr_p.h"
|
||||
#include "spkey.h"
|
||||
|
||||
#include "snapshot.h" /* for SN_Z80 and SN_SNA */
|
||||
#include "tapefile.h" /* for TAP_TAP and TAP_TZX */
|
||||
#include "zxconfig.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
/*#include <errno.h>*/
|
||||
#include "sys/types.h"
|
||||
#include "helpers.h"
|
||||
#include "ctype.h"
|
||||
|
||||
|
||||
extern const char *spcf_keynames_ascii[];
|
||||
extern const char *spcf_keynames_misc[];
|
||||
|
||||
char *spcf_init_snapshot = NULL;
|
||||
int spcf_init_snapshot_type;
|
||||
char *spcf_init_tapefile = NULL;
|
||||
int spcf_init_tapefile_type;
|
||||
#ifndef USE_GRAY
|
||||
#define exit(i) rb->splash(HZ*1,true,"Exit: %d",i)
|
||||
#else
|
||||
#define exit(i) i=i
|
||||
#endif
|
||||
#define MAXLINELEN 512
|
||||
/*static int linectr;
|
||||
static FILE *conffp;
|
||||
static int conffd;
|
||||
static const char *conffile;
|
||||
*/
|
||||
|
||||
static int file_type = -1;
|
||||
static int file_subtype;
|
||||
|
||||
struct ext_type {
|
||||
const char *ext;
|
||||
int type;
|
||||
int subtype;
|
||||
};
|
||||
|
||||
static struct ext_type extensions[] = {
|
||||
{"z80", FT_SNAPSHOT, SN_Z80},
|
||||
{"sna", FT_SNAPSHOT, SN_SNA},
|
||||
{"tzx", FT_TAPEFILE, TAP_TZX},
|
||||
{"tap", FT_TAPEFILE, TAP_TAP},
|
||||
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
int spcf_find_file_type(char *filename, int *ftp, int *ftsubp)
|
||||
{
|
||||
int i;
|
||||
int found;
|
||||
|
||||
if(*ftp >= 0 && *ftsubp >= 0) return 1;
|
||||
|
||||
found = 0;
|
||||
|
||||
for(i = 0; extensions[i].ext != NULL; i++)
|
||||
if((*ftp < 0 || *ftp == extensions[i].type) &&
|
||||
(*ftsubp < 0 || *ftsubp == extensions[i].subtype) &&
|
||||
check_ext(filename, extensions[i].ext)) {
|
||||
found = 1;
|
||||
*ftp = extensions[i].type;
|
||||
*ftsubp = extensions[i].subtype;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!found) for(i = 0; extensions[i].ext != NULL; i++)
|
||||
if((*ftp < 0 || *ftp == extensions[i].type) &&
|
||||
(*ftsubp < 0 || *ftsubp == extensions[i].subtype) &&
|
||||
try_extension(filename, extensions[i].ext)) {
|
||||
found = 1;
|
||||
*ftp = extensions[i].type;
|
||||
*ftsubp = extensions[i].subtype;
|
||||
break;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static int find_extension(const char *ext)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; extensions[i].ext != NULL; i++)
|
||||
if(rb->strcasecmp(extensions[i].ext, ext) == 0) return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* now actually a snapshot/tape loader*/
|
||||
void spcf_read_command_line(void* parameter)
|
||||
{
|
||||
int ix;
|
||||
|
||||
ix = find_extension( parameter - 3 + rb->strlen (parameter) );
|
||||
|
||||
file_type = extensions[ix].type;
|
||||
file_subtype = extensions[ix].subtype;
|
||||
rb->strncpy(filenamebuf, parameter, MAXFILENAME - 10);
|
||||
filenamebuf[MAXFILENAME-10] = '\0';
|
||||
if(file_type < 0) file_subtype = -1;
|
||||
if(!spcf_find_file_type(filenamebuf, &file_type, &file_subtype))
|
||||
return;
|
||||
|
||||
if(file_type == FT_SNAPSHOT) {
|
||||
spcf_init_snapshot = make_string(spcf_init_snapshot, filenamebuf);
|
||||
spcf_init_snapshot_type = file_subtype;
|
||||
}
|
||||
else if(file_type == FT_TAPEFILE) {
|
||||
spcf_init_tapefile = make_string(spcf_init_tapefile, filenamebuf);
|
||||
spcf_init_tapefile_type = file_subtype;
|
||||
}
|
||||
}
|
||||
|
||||
39
apps/plugins/zxbox/spconf.h
Normal file
39
apps/plugins/zxbox/spconf.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPCONF_H
|
||||
#define SPCONF_H
|
||||
|
||||
#define FT_SNAPSHOT 0
|
||||
#define FT_TAPEFILE 1
|
||||
|
||||
extern char *spcf_init_snapshot;
|
||||
extern int spcf_init_snapshot_type;
|
||||
extern char *spcf_init_tapefile;
|
||||
extern int spcf_init_tapefile_type;
|
||||
|
||||
|
||||
/*extern int spcf_read_conf_file(const char *filename);*/
|
||||
extern void spcf_read_command_line(void* parameter);
|
||||
extern void spcf_read_xresources(void);
|
||||
extern int spcf_find_file_type(char *filename, int *ftp, int *ftsubp);
|
||||
|
||||
|
||||
#endif /* SPCONF_H */
|
||||
81
apps/plugins/zxbox/spconf_p.h
Normal file
81
apps/plugins/zxbox/spconf_p.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPCONF_P_H
|
||||
#define SPCONF_P_H
|
||||
|
||||
#include "spconf.h"
|
||||
|
||||
struct sp_options {
|
||||
const char *option;
|
||||
|
||||
int argtype;
|
||||
void *argvalp;
|
||||
const char **enums;
|
||||
int disp;
|
||||
};
|
||||
|
||||
extern struct sp_options spcf_options[];
|
||||
|
||||
#define SA_BOOL 1
|
||||
#define SA_INT 2
|
||||
#define SA_STR 3
|
||||
#define SA_ENUM 4
|
||||
|
||||
|
||||
extern int showframe;
|
||||
extern int scrmul;
|
||||
extern int privatemap;
|
||||
extern int use_shm;
|
||||
|
||||
extern int small_screen;
|
||||
|
||||
extern int sound_on;
|
||||
extern int bufframes;
|
||||
extern const char *sound_dev_name;
|
||||
extern int sound_sample_rate;
|
||||
extern int sound_to_autoclose;
|
||||
extern int sound_dsp_setfrag;
|
||||
|
||||
extern int keyboard_type;
|
||||
extern int cursor_type;
|
||||
extern int color_type;
|
||||
extern int pause_on_iconify;
|
||||
extern int vga_pause_bg;
|
||||
extern int sp_quick_load;
|
||||
extern int sp_paused;
|
||||
extern int load_immed;
|
||||
extern int spt_auto_stop;
|
||||
extern int spkb_allow_ascii;
|
||||
extern int spkb_trueshift;
|
||||
extern int spkb_funcshift;
|
||||
|
||||
extern void spcf_set_val(int ix, const char *val, const char *name,
|
||||
int ctr, int fatal);
|
||||
|
||||
extern void spcf_set_color(int ix, const char *val, const char *name,
|
||||
int ctr, int fatal);
|
||||
extern void spcf_set_key(int ix, const char *val, const char *name,
|
||||
int ctr, int fatal);
|
||||
extern int spcf_match_keydef(const char *attr, const char *beg);
|
||||
extern int spcf_parse_conf_line(char *line, char **attrp, char **valp);
|
||||
|
||||
|
||||
#endif /* SPCONF_P_H */
|
||||
75
apps/plugins/zxbox/spect.c
Normal file
75
apps/plugins/zxbox/spect.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "z80.h"
|
||||
#include "spperif.h"
|
||||
#include "spscr.h"
|
||||
|
||||
#define SOUNDPORT 0x10
|
||||
|
||||
int SPNM(halfframe)(int firsttick, int numlines)
|
||||
{
|
||||
|
||||
int tc, linesleft;
|
||||
int feport, scline, border;
|
||||
byte *scrptr;
|
||||
qbyte cmark = 0;
|
||||
|
||||
scrptr = (byte *) SPNM(image);
|
||||
|
||||
tc = firsttick - CHKTICK;
|
||||
|
||||
for(linesleft = numlines; linesleft; linesleft--) {
|
||||
DANM(next_scri) = SPNM(scri)[SPNM(scline)];
|
||||
tc += CHKTICK;
|
||||
|
||||
tc = PRNM(step)(tc);
|
||||
|
||||
scline = SPNM(scline);
|
||||
|
||||
/* store sound */
|
||||
SPNM(sound_buf)[scline] = DANM(sound_sam);
|
||||
feport = DANM(ula_outport);
|
||||
|
||||
if(feport & SOUNDPORT) DANM(sound_sam) = 240;
|
||||
else DANM(sound_sam) = 16;
|
||||
|
||||
/* change EAR bit, store MIC bit*/
|
||||
|
||||
SPNM(fe_outport_time)[scline] = feport;
|
||||
if(DANM(imp_change)) DANM(ula_inport) ^= 0x40;
|
||||
DANM(imp_change) = SPNM(tape_impinfo)[scline];
|
||||
|
||||
/* Check if updating screen */
|
||||
|
||||
if(SPNM(updating)) {
|
||||
border = SPNM(lastborder);
|
||||
if((feport & 0x07) != border) {
|
||||
SPNM(border_update) = 2;
|
||||
SPNM(lastborder) = feport & 0x07;
|
||||
}
|
||||
scrptr = update_screen_line(scrptr, SPNM(coli)[scline], DANM(next_scri),
|
||||
border, &cmark);
|
||||
|
||||
}
|
||||
SPNM(scline)++;
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
1602
apps/plugins/zxbox/spectkey.c
Normal file
1602
apps/plugins/zxbox/spectkey.c
Normal file
File diff suppressed because it is too large
Load diff
983
apps/plugins/zxbox/spkey.c
Normal file
983
apps/plugins/zxbox/spkey.c
Normal file
|
|
@ -0,0 +1,983 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 DEBUG_KEYS */
|
||||
#include "misc.h"
|
||||
|
||||
#include "spkey.h"
|
||||
#include "spkey_p.h"
|
||||
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
|
||||
#include "sptape.h"
|
||||
#include "snapshot.h"
|
||||
#include "spsound.h"
|
||||
#include "spscr.h"
|
||||
|
||||
#include "interf.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int keyboard_type = 0;
|
||||
|
||||
/* for kempston support via SK_KP_Up and so on.... */
|
||||
int cursor_type = 2;
|
||||
|
||||
|
||||
int spkb_allow_ascii = 1;
|
||||
int spkb_trueshift = -1;
|
||||
int spkb_funcshift = -1;
|
||||
|
||||
static unsigned trueshift;
|
||||
static unsigned funcshift;
|
||||
|
||||
struct spkeydef {
|
||||
int type;
|
||||
spkeyboard kb;
|
||||
};
|
||||
|
||||
struct spbasekey {
|
||||
int index;
|
||||
spkeyboard kb;
|
||||
spkeyboard misc;
|
||||
};
|
||||
|
||||
struct spnamedkey {
|
||||
const char *name;
|
||||
spkeyboard kb;
|
||||
spkeyboard misc;
|
||||
};
|
||||
|
||||
extern int endofsingle;
|
||||
extern int sp_nosync;
|
||||
extern int showframe;
|
||||
extern int privatemap;
|
||||
|
||||
spkeyboard spkey_state;
|
||||
spkeyboard spmisc_state;
|
||||
|
||||
static spkeyboard oldstate = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
struct keystate spkb_kbstate[NR_SPKEYS];
|
||||
struct onekey spkb_last;
|
||||
|
||||
int spkb_state_changed;
|
||||
|
||||
#define SKE {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
|
||||
#define SKP(x) (1 << x)
|
||||
|
||||
#define SKN0(x) {SKP(x), 0, 0, 0, 0, 0, 0, 0}
|
||||
#define SKN1(x) {0, SKP(x), 0, 0, 0, 0, 0, 0}
|
||||
#define SKN2(x) {0, 0, SKP(x), 0, 0, 0, 0, 0}
|
||||
#define SKN3(x) {0, 0, 0, SKP(x), 0, 0, 0, 0}
|
||||
#define SKN4(x) {0, 0, 0, 0, SKP(x), 0, 0, 0}
|
||||
#define SKN5(x) {0, 0, 0, 0, 0, SKP(x), 0, 0}
|
||||
#define SKN6(x) {0, 0, 0, 0, 0, 0, SKP(x), 0}
|
||||
#define SKN7(x) {0, 0, 0, 0, 0, 0, 0, SKP(x)}
|
||||
|
||||
#define SKCS0(x) {SKP(0) | SKP(x), 0, 0, 0, 0, 0, 0, 0}
|
||||
#define SKCS1(x) {SKP(0), SKP(x), 0, 0, 0, 0, 0, 0}
|
||||
#define SKCS2(x) {SKP(0), 0, SKP(x), 0, 0, 0, 0, 0}
|
||||
#define SKCS3(x) {SKP(0), 0, 0, SKP(x), 0, 0, 0, 0}
|
||||
#define SKCS4(x) {SKP(0), 0, 0, 0, SKP(x), 0, 0, 0}
|
||||
#define SKCS5(x) {SKP(0), 0, 0, 0, 0, SKP(x), 0, 0}
|
||||
#define SKCS6(x) {SKP(0), 0, 0, 0, 0, 0, SKP(x), 0}
|
||||
#define SKCS7(x) {SKP(0), 0, 0, 0, 0, 0, 0, SKP(x)}
|
||||
|
||||
|
||||
#define SKSS0(x) {SKP(x), 0, 0, 0, 0, 0, 0, SKP(1)}
|
||||
#define SKSS1(x) {0, SKP(x), 0, 0, 0, 0, 0, SKP(1)}
|
||||
#define SKSS2(x) {0, 0, SKP(x), 0, 0, 0, 0, SKP(1)}
|
||||
#define SKSS3(x) {0, 0, 0, SKP(x), 0, 0, 0, SKP(1)}
|
||||
#define SKSS4(x) {0, 0, 0, 0, SKP(x), 0, 0, SKP(1)}
|
||||
#define SKSS5(x) {0, 0, 0, 0, 0, SKP(x), 0, SKP(1)}
|
||||
#define SKSS6(x) {0, 0, 0, 0, 0, 0, SKP(x), SKP(1)}
|
||||
#define SKSS7(x) {0, 0, 0, 0, 0, 0, 0, SKP(x) | SKP(1)}
|
||||
|
||||
|
||||
#define KEMP(x) {x, 0, 0, 0, 0, 0, 0, 0}
|
||||
|
||||
#define KEMPR 0x01
|
||||
#define KEMPL 0x02
|
||||
#define KEMPD 0x04
|
||||
#define KEMPU 0x08
|
||||
#define KEMPF 0x10
|
||||
|
||||
#define KEMP_PORT 0x1F
|
||||
|
||||
|
||||
#define T_MAIN 0
|
||||
#define T_CMPX 1
|
||||
#define T_EXTR 2
|
||||
|
||||
#define SPK_SPACE SKN7(0)
|
||||
|
||||
#define SPK_0 SKN4(0)
|
||||
#define SPK_1 SKN3(0)
|
||||
#define SPK_2 SKN3(1)
|
||||
#define SPK_3 SKN3(2)
|
||||
#define SPK_4 SKN3(3)
|
||||
#define SPK_5 SKN3(4)
|
||||
#define SPK_6 SKN4(4)
|
||||
#define SPK_7 SKN4(3)
|
||||
#define SPK_8 SKN4(2)
|
||||
#define SPK_9 SKN4(1)
|
||||
|
||||
#define SPK_A SKN1(0)
|
||||
#define SPK_B SKN7(4)
|
||||
#define SPK_C SKN0(3)
|
||||
#define SPK_D SKN1(2)
|
||||
#define SPK_E SKN2(2)
|
||||
#define SPK_F SKN1(3)
|
||||
#define SPK_G SKN1(4)
|
||||
#define SPK_H SKN6(4)
|
||||
#define SPK_I SKN5(2)
|
||||
#define SPK_J SKN6(3)
|
||||
#define SPK_K SKN6(2)
|
||||
#define SPK_L SKN6(1)
|
||||
#define SPK_M SKN7(2)
|
||||
#define SPK_N SKN7(3)
|
||||
#define SPK_O SKN5(1)
|
||||
#define SPK_P SKN5(0)
|
||||
#define SPK_Q SKN2(0)
|
||||
#define SPK_R SKN2(3)
|
||||
#define SPK_S SKN1(1)
|
||||
#define SPK_T SKN2(4)
|
||||
#define SPK_U SKN5(3)
|
||||
#define SPK_V SKN0(4)
|
||||
#define SPK_W SKN2(1)
|
||||
#define SPK_X SKN0(2)
|
||||
#define SPK_Y SKN5(4)
|
||||
#define SPK_Z SKN0(1)
|
||||
|
||||
#define SPK_ENTER SKN6(0)
|
||||
#define SPK_CAPSSHIFT SKN0(0)
|
||||
#define SPK_SYMBOLSHIFT SKN7(1)
|
||||
|
||||
#define SPK_BS SKCS4(0)
|
||||
#define SPK_UP SKCS4(3)
|
||||
#define SPK_DOWN SKCS4(4)
|
||||
#define SPK_LEFT SKCS3(4)
|
||||
#define SPK_RIGHT SKCS4(2)
|
||||
#define SPK_CAPSLOCK SKCS3(1)
|
||||
#define SPK_EXTRA SKCS7(1)
|
||||
#define SPK_EDIT SKCS3(0)
|
||||
|
||||
static spkeyboard spk_extra = SPK_EXTRA;
|
||||
|
||||
static struct spkeydef spkey_ascii[] = {
|
||||
{T_MAIN, SPK_SPACE}, /* space */
|
||||
{T_CMPX, SKSS3(0)}, /* ! */
|
||||
{T_CMPX, SKSS5(0)}, /* " */
|
||||
{T_CMPX, SKSS3(2)}, /* # */
|
||||
{T_CMPX, SKSS3(3)}, /* $ */
|
||||
{T_CMPX, SKSS3(4)}, /* % */
|
||||
{T_CMPX, SKSS4(4)}, /* & */
|
||||
{T_CMPX, SKSS4(3)}, /* ' */
|
||||
{T_CMPX, SKSS4(2)}, /* ( */
|
||||
{T_CMPX, SKSS4(1)}, /* ) */
|
||||
{T_CMPX, SKSS7(4)}, /* * */
|
||||
{T_CMPX, SKSS6(2)}, /* + */
|
||||
{T_CMPX, SKSS7(3)}, /* , */
|
||||
{T_CMPX, SKSS6(3)}, /* - */
|
||||
{T_CMPX, SKSS7(2)}, /* . */
|
||||
{T_CMPX, SKSS0(4)}, /* / */
|
||||
|
||||
{T_MAIN, SPK_0}, /* 0 */
|
||||
{T_MAIN, SPK_1}, /* 1 */
|
||||
{T_MAIN, SPK_2}, /* 2 */
|
||||
{T_MAIN, SPK_3}, /* 3 */
|
||||
{T_MAIN, SPK_4}, /* 4 */
|
||||
{T_MAIN, SPK_5}, /* 5 */
|
||||
{T_MAIN, SPK_6}, /* 6 */
|
||||
{T_MAIN, SPK_7}, /* 7 */
|
||||
{T_MAIN, SPK_8}, /* 8 */
|
||||
{T_MAIN, SPK_9}, /* 9 */
|
||||
|
||||
{T_CMPX, SKSS0(1)}, /* : */
|
||||
{T_CMPX, SKSS5(1)}, /* ; */
|
||||
{T_CMPX, SKSS2(3)}, /* < */
|
||||
{T_CMPX, SKSS6(1)}, /* = */
|
||||
{T_CMPX, SKSS2(4)}, /* > */
|
||||
{T_CMPX, SKSS0(3)}, /* ? */
|
||||
{T_CMPX, SKSS3(1)}, /* @ */
|
||||
|
||||
{T_CMPX, SKCS1(0)}, /* A */
|
||||
{T_CMPX, SKCS7(4)}, /* B */
|
||||
{T_CMPX, SKCS0(3)}, /* C */
|
||||
{T_CMPX, SKCS1(2)}, /* D */
|
||||
{T_CMPX, SKCS2(2)}, /* E */
|
||||
{T_CMPX, SKCS1(3)}, /* F */
|
||||
{T_CMPX, SKCS1(4)}, /* G */
|
||||
{T_CMPX, SKCS6(4)}, /* H */
|
||||
{T_CMPX, SKCS5(2)}, /* I */
|
||||
{T_CMPX, SKCS6(3)}, /* J */
|
||||
{T_CMPX, SKCS6(2)}, /* K */
|
||||
{T_CMPX, SKCS6(1)}, /* L */
|
||||
{T_CMPX, SKCS7(2)}, /* M */
|
||||
{T_CMPX, SKCS7(3)}, /* N */
|
||||
{T_CMPX, SKCS5(1)}, /* O */
|
||||
{T_CMPX, SKCS5(0)}, /* P */
|
||||
{T_CMPX, SKCS2(0)}, /* Q */
|
||||
{T_CMPX, SKCS2(3)}, /* R */
|
||||
{T_CMPX, SKCS1(1)}, /* S */
|
||||
{T_CMPX, SKCS2(4)}, /* T */
|
||||
{T_CMPX, SKCS5(3)}, /* U */
|
||||
{T_CMPX, SKCS0(4)}, /* V */
|
||||
{T_CMPX, SKCS2(1)}, /* W */
|
||||
{T_CMPX, SKCS0(2)}, /* X */
|
||||
{T_CMPX, SKCS5(4)}, /* Y */
|
||||
{T_CMPX, SKCS0(1)}, /* Z */
|
||||
|
||||
{T_EXTR, SKCS5(4)}, /* [ */
|
||||
{T_EXTR, SKCS1(2)}, /* backslash */
|
||||
{T_EXTR, SKCS5(3)}, /* ] */
|
||||
{T_CMPX, SKSS6(4)}, /* ^ */
|
||||
{T_CMPX, SKSS4(0)}, /* _ */
|
||||
{T_CMPX, SKSS0(2)}, /* ` */
|
||||
|
||||
{T_MAIN, SPK_A}, /* a */
|
||||
{T_MAIN, SPK_B}, /* b */
|
||||
{T_MAIN, SPK_C}, /* c */
|
||||
{T_MAIN, SPK_D}, /* d */
|
||||
{T_MAIN, SPK_E}, /* e */
|
||||
{T_MAIN, SPK_F}, /* f */
|
||||
{T_MAIN, SPK_G}, /* g */
|
||||
{T_MAIN, SPK_H}, /* h */
|
||||
{T_MAIN, SPK_I}, /* i */
|
||||
{T_MAIN, SPK_J}, /* j */
|
||||
{T_MAIN, SPK_K}, /* k */
|
||||
{T_MAIN, SPK_L}, /* l */
|
||||
{T_MAIN, SPK_M}, /* m */
|
||||
{T_MAIN, SPK_N}, /* n */
|
||||
{T_MAIN, SPK_O}, /* o */
|
||||
{T_MAIN, SPK_P}, /* p */
|
||||
{T_MAIN, SPK_Q}, /* q */
|
||||
{T_MAIN, SPK_R}, /* r */
|
||||
{T_MAIN, SPK_S}, /* s */
|
||||
{T_MAIN, SPK_T}, /* t */
|
||||
{T_MAIN, SPK_U}, /* u */
|
||||
{T_MAIN, SPK_V}, /* v */
|
||||
{T_MAIN, SPK_W}, /* w */
|
||||
{T_MAIN, SPK_X}, /* x */
|
||||
{T_MAIN, SPK_Y}, /* y */
|
||||
{T_MAIN, SPK_Z}, /* z */
|
||||
|
||||
{T_EXTR, SKCS1(3)}, /* { */
|
||||
{T_EXTR, SKCS1(1)}, /* | */
|
||||
{T_EXTR, SKCS1(4)}, /* } */
|
||||
{T_EXTR, SKCS1(0)}, /* ~ */
|
||||
};
|
||||
|
||||
static struct spnamedkey spkey_misc[] = {
|
||||
{"none", SKE, SKE},
|
||||
|
||||
{"space", SPK_SPACE, SKE},
|
||||
{"enter", SPK_ENTER, SKE},
|
||||
{"capsshift", SPK_CAPSSHIFT, SKE},
|
||||
{"symbolshift", SPK_SYMBOLSHIFT, SKE},
|
||||
|
||||
{"kempston_up", SKE, KEMP(KEMPU)},
|
||||
{"kempston_down", SKE, KEMP(KEMPD)},
|
||||
{"kempston_left", SKE, KEMP(KEMPL)},
|
||||
{"kempston_right", SKE, KEMP(KEMPR)},
|
||||
{"kempston_fire", SKE, KEMP(KEMPF)},
|
||||
|
||||
{NULL, SKE, SKE}
|
||||
};
|
||||
|
||||
#define MAXBASEKEYS 128
|
||||
|
||||
static struct spbasekey basekeys[MAXBASEKEYS];
|
||||
static int numbasekeys;
|
||||
|
||||
static struct spbasekey customkeys[MAXBASEKEYS];
|
||||
static int numcustomkeys = 0;
|
||||
|
||||
static struct spbasekey normalkeys[] = {
|
||||
{'0', SPK_0, SKE}, /* 0 */
|
||||
{'1', SPK_1, SKE}, /* 1 */
|
||||
{'2', SPK_2, SKE}, /* 2 */
|
||||
{'3', SPK_3, SKE}, /* 3 */
|
||||
{'4', SPK_4, SKE}, /* 4 */
|
||||
{'5', SPK_5, SKE}, /* 5 */
|
||||
{'6', SPK_6, SKE}, /* 6 */
|
||||
{'7', SPK_7, SKE}, /* 7 */
|
||||
{'8', SPK_8, SKE}, /* 8 */
|
||||
{'9', SPK_9, SKE}, /* 9 */
|
||||
|
||||
{'a', SPK_A, SKE}, /* a */
|
||||
{'b', SPK_B, SKE}, /* b */
|
||||
{'c', SPK_C, SKE}, /* c */
|
||||
{'d', SPK_D, SKE}, /* d */
|
||||
{'e', SPK_E, SKE}, /* e */
|
||||
{'f', SPK_F, SKE}, /* f */
|
||||
{'g', SPK_G, SKE}, /* g */
|
||||
{'h', SPK_H, SKE}, /* h */
|
||||
{'i', SPK_I, SKE}, /* i */
|
||||
{'j', SPK_J, SKE}, /* j */
|
||||
{'k', SPK_K, SKE}, /* k */
|
||||
{'l', SPK_L, SKE}, /* l */
|
||||
{'m', SPK_M, SKE}, /* m */
|
||||
{'n', SPK_N, SKE}, /* n */
|
||||
{'o', SPK_O, SKE}, /* o */
|
||||
{'p', SPK_P, SKE}, /* p */
|
||||
{'q', SPK_Q, SKE}, /* q */
|
||||
{'r', SPK_R, SKE}, /* r */
|
||||
{'s', SPK_S, SKE}, /* s */
|
||||
{'t', SPK_T, SKE}, /* t */
|
||||
{'u', SPK_U, SKE}, /* u */
|
||||
{'v', SPK_V, SKE}, /* v */
|
||||
{'w', SPK_W, SKE}, /* w */
|
||||
{'x', SPK_X, SKE}, /* x */
|
||||
{'y', SPK_Y, SKE}, /* y */
|
||||
{'z', SPK_Z, SKE}, /* z */
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
static struct spbasekey extendedkeys[] = {
|
||||
{' ', SPK_SPACE, SKE}, /* space */
|
||||
{TRKS(SK_Return), SPK_ENTER, SKE}, /* enter */
|
||||
{TRKS(SK_KP_Enter), SPK_ENTER, SKE},
|
||||
{TRKS(SK_Shift_L), SPK_CAPSSHIFT, SKE}, /* caps shift */
|
||||
{TRKS(SK_Shift_R), SPK_SYMBOLSHIFT, SKE}, /* symbol shift */
|
||||
{TRKS(SK_BackSpace), SPK_BS, SKE}, /* backspace */
|
||||
{TRKS(SK_Delete), SPK_BS, SKE},
|
||||
{TRKS(SK_KP_Delete), SPK_BS, SKE},
|
||||
{TRKS(SK_Escape), SPK_EDIT, SKE}, /* caps shift + '1' */
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
static struct spbasekey spectrumkeys[] = {
|
||||
{',', SPK_SYMBOLSHIFT, SKE},
|
||||
{'.', SPK_SPACE, SKE},
|
||||
{';', SPK_ENTER, SKE},
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
|
||||
static struct spbasekey compatkeys[] = {
|
||||
{TRKS(SK_Shift_L), SPK_CAPSSHIFT, SKE}, /* caps shift */
|
||||
{TRKS(SK_Shift_R), SPK_CAPSSHIFT, SKE},
|
||||
{TRKS(SK_Alt_L), SPK_SYMBOLSHIFT, SKE}, /* symbol shift */
|
||||
{TRKS(SK_Alt_R), SPK_SYMBOLSHIFT, SKE},
|
||||
{TRKS(SK_Meta_L), SPK_SYMBOLSHIFT, SKE},
|
||||
{TRKS(SK_Meta_R), SPK_SYMBOLSHIFT, SKE},
|
||||
#if TRUEKOMPAT
|
||||
{TRKS(SK_Control_L), SPK_EXTRA, SKE}, /* caps shift + symbol shift */
|
||||
{TRKS(SK_Control_R), SPK_EXTRA, SKE},
|
||||
#endif
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
static struct spbasekey shiftedcurs[] = {
|
||||
{TRKS(SK_Up), SPK_UP, SKE}, /* up */
|
||||
{TRKS(SK_KP_Up), SPK_UP, SKE},
|
||||
{TRKS(SK_Down), SPK_DOWN, SKE}, /* down */
|
||||
{TRKS(SK_KP_Down), SPK_DOWN, SKE},
|
||||
{TRKS(SK_Left), SPK_LEFT, SKE}, /* left */
|
||||
{TRKS(SK_KP_Left), SPK_LEFT, SKE},
|
||||
{TRKS(SK_Right), SPK_RIGHT, SKE}, /* right */
|
||||
{TRKS(SK_KP_Right), SPK_RIGHT, SKE},
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
static struct spbasekey rawcurs[] = {
|
||||
{TRKS(SK_Up), SPK_7, SKE}, /* up */
|
||||
{TRKS(SK_KP_Up), SPK_7, SKE},
|
||||
{TRKS(SK_Down), SPK_6, SKE}, /* down */
|
||||
{TRKS(SK_KP_Down), SPK_6, SKE},
|
||||
{TRKS(SK_Left), SPK_5, SKE}, /* left */
|
||||
{TRKS(SK_KP_Left), SPK_5, SKE},
|
||||
{TRKS(SK_Right), SPK_8, SKE}, /* right */
|
||||
{TRKS(SK_KP_Right), SPK_8, SKE},
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
static struct spbasekey joycurs[] = {
|
||||
{TRKS(SK_Up), SKE, KEMP(KEMPU)}, /* up */
|
||||
{TRKS(SK_KP_Up), SKE, KEMP(KEMPU)},
|
||||
{TRKS(SK_Down), SKE, KEMP(KEMPD)}, /* down */
|
||||
{TRKS(SK_KP_Down), SKE, KEMP(KEMPD)},
|
||||
{TRKS(SK_Left), SKE, KEMP(KEMPL)}, /* left */
|
||||
{TRKS(SK_KP_Left), SKE, KEMP(KEMPL)},
|
||||
{TRKS(SK_Right), SKE, KEMP(KEMPR)}, /* right */
|
||||
{TRKS(SK_KP_Right), SKE, KEMP(KEMPR)},
|
||||
{TRKS(SK_KP_Insert), SKE, KEMP(KEMPF)}, /* fire */
|
||||
{TRKS(SK_Insert), SKE, KEMP(KEMPF)},
|
||||
{TRKS(SK_KP_Delete), SKE, KEMP(KEMPF)},
|
||||
{TRKS(SK_KP_Home), SKE, KEMP(KEMPU | KEMPL)}, /* up + left*/
|
||||
{TRKS(SK_Home), SKE, KEMP(KEMPU | KEMPL)},
|
||||
{TRKS(SK_KP_Page_Up), SKE, KEMP(KEMPU | KEMPR)}, /* up + right*/
|
||||
{TRKS(SK_Page_Up), SKE, KEMP(KEMPU | KEMPR)},
|
||||
{TRKS(SK_KP_End), SKE, KEMP(KEMPD | KEMPL)}, /* down + left*/
|
||||
{TRKS(SK_End), SKE, KEMP(KEMPD | KEMPL)},
|
||||
{TRKS(SK_KP_Page_Down), SKE, KEMP(KEMPD | KEMPR)}, /* down + right*/
|
||||
{TRKS(SK_Page_Down), SKE, KEMP(KEMPD | KEMPR)},
|
||||
|
||||
{-1, SKE, SKE}
|
||||
};
|
||||
|
||||
int spkey_new_custom(int key)
|
||||
{
|
||||
if(numcustomkeys >= MAXBASEKEYS) return 0;
|
||||
|
||||
customkeys[numcustomkeys].index = key;
|
||||
SP_SETEMPTY(customkeys[numcustomkeys].kb);
|
||||
SP_SETEMPTY(customkeys[numcustomkeys].misc);
|
||||
numcustomkeys++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int spkey_add_custom(const char *name)
|
||||
{
|
||||
int curr;
|
||||
|
||||
curr = numcustomkeys - 1;
|
||||
|
||||
if(!name[1] && isalnum(name[0])) {
|
||||
int ai;
|
||||
ai = tolower(name[0])-32;
|
||||
SP_COMBINE(customkeys[curr].kb, spkey_ascii[ai].kb);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
|
||||
for(i = 0; spkey_misc[i].name != NULL; i++) {
|
||||
if(mis_strcasecmp(spkey_misc[i].name, name) == 0) {
|
||||
SP_COMBINE(customkeys[curr].kb, spkey_misc[i].kb);
|
||||
SP_COMBINE(customkeys[curr].misc, spkey_misc[i].misc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int key_reset(struct keystate *ck)
|
||||
{
|
||||
if(ck->state == 2 && sp_int_ctr >= ck->frame) {
|
||||
ck->state = 0;
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
void process_keys(void)
|
||||
{
|
||||
int i;
|
||||
struct keystate *ck;
|
||||
int tsh;
|
||||
int kalone;
|
||||
static int extrai = 0;
|
||||
static qbyte extraendframe;
|
||||
|
||||
if(extrai && !spkb_kbstate[extrai].state) extrai = 0;
|
||||
|
||||
if(!spkb_state_changed && (!extrai || !extraendframe)) return;
|
||||
|
||||
SP_SETEMPTY(spkey_state);
|
||||
SP_SETEMPTY(spmisc_state);
|
||||
|
||||
kalone = 0;
|
||||
ck = spkb_kbstate + spkb_last.index;
|
||||
tsh = spkb_last.modif & trueshift;
|
||||
key_reset(ck);
|
||||
|
||||
|
||||
if(spkb_allow_ascii && ck->state && (!ck->base || tsh)) {
|
||||
unsigned ks;
|
||||
ks = tsh ? spkb_last.shifted : spkb_last.keysym;
|
||||
if(ks >= 32 && ks < 127) {
|
||||
if(spkey_ascii[ks-32].type <= T_CMPX) {
|
||||
SP_COMBINE(spkey_state, spkey_ascii[ks-32].kb);
|
||||
kalone = 1;
|
||||
}
|
||||
else if(spkey_ascii[ks-32].type == T_EXTR) {
|
||||
if(!extrai || sp_int_ctr < extraendframe) {
|
||||
if(!extrai) {
|
||||
extrai = spkb_last.index;
|
||||
extraendframe = sp_int_ctr + 1;
|
||||
}
|
||||
SP_COMBINE(spkey_state, spk_extra);
|
||||
}
|
||||
else {
|
||||
SP_COMBINE(spkey_state, spkey_ascii[ks-32].kb);
|
||||
extraendframe = 0;
|
||||
}
|
||||
kalone = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!kalone) {
|
||||
for(i = 0; i < numbasekeys; i++) {
|
||||
ck = spkb_kbstate + basekeys[i].index;
|
||||
key_reset(ck);
|
||||
if(ck->state) {
|
||||
SP_COMBINE(spkey_state, basekeys[i].kb);
|
||||
SP_COMBINE(spmisc_state, basekeys[i].misc);
|
||||
}
|
||||
}
|
||||
}
|
||||
SP_COMBINE(spkey_state, kb_mkey);
|
||||
|
||||
spkb_refresh();
|
||||
spkb_state_changed = 0;
|
||||
}
|
||||
|
||||
void clear_keystates(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < NR_SPKEYS; i++) spkb_kbstate[i].state = 0;
|
||||
spkb_last.index = 0;
|
||||
SP_SETEMPTY(spkey_state);
|
||||
SP_SETEMPTY(kb_mkey);
|
||||
SP_SETEMPTY(spmisc_state);
|
||||
spkb_refresh();
|
||||
}
|
||||
|
||||
static void keycpy(struct spbasekey *to, struct spbasekey *from)
|
||||
{
|
||||
to->index = from->index;
|
||||
SP_COPY(to->kb, from->kb);
|
||||
SP_COPY(to->misc, from->misc);
|
||||
}
|
||||
|
||||
static void copy_key(struct spbasekey *addk)
|
||||
{
|
||||
int i;
|
||||
int nindex;
|
||||
|
||||
nindex = addk->index;
|
||||
|
||||
if(SP_NONEMPTY(addk->kb) || SP_NONEMPTY(addk->misc)) {
|
||||
for(i = 0; i < numbasekeys; i++) {
|
||||
if(basekeys[i].index == nindex) { /* Replace */
|
||||
keycpy(&basekeys[i], addk);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(numbasekeys < MAXBASEKEYS - 1) { /* Add */
|
||||
keycpy(&basekeys[numbasekeys], addk);
|
||||
spkb_kbstate[nindex].base = 1;
|
||||
numbasekeys++;
|
||||
}
|
||||
}
|
||||
else { /* Delete */
|
||||
for(i = 0; i < numbasekeys; i++) {
|
||||
if(basekeys[i].index == nindex) {
|
||||
i++;
|
||||
for(; i < numbasekeys; i++) keycpy(&basekeys[i-1], &basekeys[i]);
|
||||
spkb_kbstate[nindex].base = 0;
|
||||
numbasekeys--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_basekeys(struct spbasekey *addk)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; addk[i].index >= 0; i++) copy_key(&addk[i]);
|
||||
}
|
||||
|
||||
static unsigned transform_shift(int modif)
|
||||
{
|
||||
if(!modif) return 0;
|
||||
else return (1 << (modif - 1));
|
||||
}
|
||||
|
||||
|
||||
void init_basekeys(void)
|
||||
{
|
||||
int i;
|
||||
numbasekeys = 0;
|
||||
|
||||
for(i = 0; i < NR_SPKEYS; i++) spkb_kbstate[i].base = 0;
|
||||
|
||||
customkeys[numcustomkeys].index = -1;
|
||||
|
||||
copy_basekeys(normalkeys);
|
||||
copy_basekeys(extendedkeys);
|
||||
copy_basekeys(shiftedcurs);
|
||||
|
||||
switch(keyboard_type) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
copy_basekeys(spectrumkeys);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if(spkb_trueshift == -1) spkb_trueshift = 0;
|
||||
#if TRUEKOMPAT
|
||||
if(spkb_funcshift == -1) spkb_funcshift = 0;
|
||||
#endif
|
||||
|
||||
copy_basekeys(compatkeys);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
copy_basekeys(customkeys);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(cursor_type) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
copy_basekeys(rawcurs);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
copy_basekeys(joycurs);
|
||||
break;
|
||||
}
|
||||
|
||||
if(spkb_trueshift == -1) spkb_trueshift = 4; /* mod1 */
|
||||
if(spkb_funcshift == -1) spkb_funcshift = 3; /* control */
|
||||
|
||||
trueshift = transform_shift(spkb_trueshift);
|
||||
funcshift = transform_shift(spkb_funcshift);
|
||||
}
|
||||
|
||||
|
||||
void spkb_refresh(void)
|
||||
{
|
||||
int port, pb;
|
||||
int i, j, changed;
|
||||
byte *km, *kmo;
|
||||
byte mm;
|
||||
byte pv;
|
||||
spkeyboard statemx;
|
||||
|
||||
km = spkey_state;
|
||||
kmo = oldstate;
|
||||
changed = 0;
|
||||
for(i = 8; i; i--) {
|
||||
if(*km != *kmo) *kmo = *km, changed = 1;
|
||||
km++, kmo++;
|
||||
}
|
||||
|
||||
if(changed) {
|
||||
|
||||
/* Matrix behavior: ONLY 1 level, does anybody need more ? */
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
pv = spkey_state[i];
|
||||
mm = pv;
|
||||
if(pv) {
|
||||
km = spkey_state;
|
||||
for(j = 8; j; j--) {
|
||||
if((*km & pv) & 0x1F) mm |= *km;
|
||||
km++;
|
||||
}
|
||||
}
|
||||
statemx[i] = mm;
|
||||
}
|
||||
|
||||
for(port = 0; port < 256; port++) {
|
||||
km = statemx;
|
||||
pv = 0;
|
||||
pb = port;
|
||||
for(i = 8; i; i--) {
|
||||
if(!(pb & 1)) pv |= *km;
|
||||
pb >>= 1;
|
||||
km++;
|
||||
}
|
||||
sp_fe_inport_high[port] =
|
||||
(sp_fe_inport_high[port] | 0x1F) & ~(pv & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
pv = spmisc_state[0];
|
||||
|
||||
if((pv & KEMPR) && (pv & KEMPL)) pv &= ~(KEMPR | KEMPL);
|
||||
if((pv & KEMPU) && (pv & KEMPD)) pv &= ~(KEMPD | KEMPU);
|
||||
z80_inports[KEMP_PORT] = pv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
static void print_help(int lev)
|
||||
{
|
||||
lev=lev;
|
||||
#if 0
|
||||
switch(lev) {
|
||||
case 0:
|
||||
printf(" = ZX Spectrum Emulation (C) Szeredi Miklos 1996-98 = \n"
|
||||
" ----------------------------------------------------------\n"
|
||||
" Left Shift Spectrum - CAPS SHIFT \n"
|
||||
" Right Shift Spectrum - SYMBOL SHIFT \n"
|
||||
" Alt \"True\" Shift \n"
|
||||
" Ctrl Commands \n"
|
||||
" ----------------------------------------------------------\n"
|
||||
" Ctrl-c F10 Quit \n"
|
||||
" Ctrl-h F1 More help \n"
|
||||
" Ctrl-t F2 Save snapshot \n"
|
||||
" Ctrl-l F3 Load snapshot \n"
|
||||
" Ctrl-p F4 Play tape \n"
|
||||
" Ctrl-q F5 Reset \n"
|
||||
" Ctrl-o F6 Pause/unpause tape \n"
|
||||
" Ctrl-s F7 Stop tape \n"
|
||||
" Ctrl-f Fast \n"
|
||||
" Ctrl-n Normal speed \n"
|
||||
" Ctrl-b Pause/Unpause emulator \n"
|
||||
" Ctrl-m Toggle sound \n"
|
||||
" Ctrl-y Toggle quick loading of tapes \n"
|
||||
" Ctrl-\\ F9 Refresh screen / reset keyboard \n"
|
||||
" ==========================================================\n");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
printf(" = ZX Spectrum Emulation (C) Szeredi Miklos 1996-98 = \n"
|
||||
" ----------------------------------------------------------\n"
|
||||
" More help: \n"
|
||||
" ----------------------------------------------------------\n"
|
||||
" Ctrl-h F1 Normal help \n"
|
||||
" Ctrl-k Display (undisplay) keyboard \n"
|
||||
" Ctrl-w Ctrl-F2 Save temporary snapshot \n"
|
||||
" Ctrl-e Ctrl-F3 Load temporary snapshot \n"
|
||||
" Ctrl-r Save to tapefile \n"
|
||||
" Ctrl-, Reduce screen size (X only) \n"
|
||||
" Ctrl-. Increase screen size (X only) \n"
|
||||
" Ctrl-. Toggle private color-map (X only) \n"
|
||||
" Ctrl-= Decrease frame frequency \n"
|
||||
" Ctrl-- Increase frame frequency \n"
|
||||
" Ctrl-] Increase sound buffer size \n"
|
||||
" Ctrl-[ Decrease sound buffer size \n"
|
||||
" ==========================================================\n");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
printf(
|
||||
" --------------------------------------------------------------------- \n"
|
||||
"|BLUE |RED |MAGENT|GREEN |CYAN |YELLOW|WHITE | | |BLACK | \n"
|
||||
"| 1 ! | 2 @ | 3 # | 4 $ | 5 %% | 6 & | 7 ' | 8 ( | 9 ) | 0 _ | \n"
|
||||
"|EDIT |CAPS |TRU VD|INV VD| <- | v | ^ | -> |GRAPH |DELETE| \n"
|
||||
"|DEF FN|FN |LINE |OPEN# |CLOSE#|MOVE |ERASE |POINT |CAT |FORMAT| \n"
|
||||
" ------------------------------------------------------------------------ \n"
|
||||
" |SIN |COS |TAN |INT |RND |STR$ |CHR$ |CODE |PEEK |TAB | \n"
|
||||
" | Q <= | W <> | E >= | R < | T > | Y AND| U OR | I AT | O ; | P \" | \n"
|
||||
" |PLOT |DRAW |REM |RUN |RAND |RETURN|IF |INPUT |POKE |PRINT | \n"
|
||||
" |ASN |ACS |ATN |VERIFY|MERGE | [ | ] |IN |OUT |(C) | \n"
|
||||
" ------------------------------------------------------------------------ \n"
|
||||
" |READ |RESTOR|DATA |SGN |ABS |SQR |VAL |LEN |USR | |\n"
|
||||
" |A STOP| S NOT|D STEP| F TO |G THEN| H ^ | J - | K + | L = | |\n"
|
||||
" |NEW |SAVE |DIM |FOR |GO TO |GO SUB|LOAD |LIST |LET |ENTER|\n"
|
||||
" | ~ | | | \\ | { | } |CIRCLE|VAL$ |SCRN$ |ATTR | |\n"
|
||||
" -------------------------------------------------------------------------- \n"
|
||||
" | |LN |EXP |LPRINT|LLIST |BIN |INKEY$| PI | | | \n"
|
||||
" | CAPS | Z : | X GBP| C ? | V / | B * | N , | M . |SYMBOL| BREAK | \n"
|
||||
" | SHIFT |COPY |CLEAR |CONT |CLS |BORDER|NEXT |PAUSE |SHIFT | SPACE | \n"
|
||||
" | |BEEP |INK |PAPER |FLASH |BRIGHT|OVER |INVERS| | | \n"
|
||||
" ----------------------------------------------------------------------- \n"
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
/* if(need_switch_mode) {
|
||||
printf(" Press ENTER to continue! \n");
|
||||
while(getchar() != '\n');
|
||||
}*/
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG_Z80
|
||||
extern int deb_steps;
|
||||
#endif
|
||||
|
||||
#define CF(x) ((x) + 12)
|
||||
|
||||
int spkey_keyfuncs(void)
|
||||
{
|
||||
static int help_mode = 0;
|
||||
int lch;
|
||||
int new_help_mode;
|
||||
|
||||
lch = spkb_last.keysym;
|
||||
|
||||
if(!(spkb_last.modif & funcshift) &&
|
||||
(lch < SK_F1 || lch > SK_F12 ||
|
||||
(spkb_last.modif & SKMod1Mask))) return 0;
|
||||
|
||||
if(lch >= 'A' && lch <= 'Z') lch += 32;
|
||||
if((spkb_last.modif & funcshift) && lch >= SK_F1 && lch <= SK_F12)
|
||||
lch = CF(lch);
|
||||
|
||||
new_help_mode = 0;
|
||||
|
||||
switch(lch) {
|
||||
case 'c':
|
||||
/* case SK_F10:
|
||||
exit(0);*/
|
||||
case 'p':
|
||||
case SK_F4:
|
||||
spkey_textmode();
|
||||
start_play();
|
||||
spkey_screenmode();
|
||||
break;
|
||||
case 'r':
|
||||
spkey_textmode();
|
||||
start_rec();
|
||||
spkey_screenmode();
|
||||
break;
|
||||
case 'o':
|
||||
case SK_F6:
|
||||
pause_play();
|
||||
break;
|
||||
case 's':
|
||||
case SK_F7:
|
||||
stop_play();
|
||||
break;
|
||||
case 'f':
|
||||
sp_nosync = 1;
|
||||
sp_paused = 0;
|
||||
autoclose_sound();
|
||||
break;
|
||||
case 'n':
|
||||
sp_nosync = 0;
|
||||
sp_paused = 0;
|
||||
break;
|
||||
case 'b':
|
||||
sp_paused = !sp_paused;
|
||||
if(sp_paused) clear_keystates();
|
||||
/*sprintf(msgbuf, "%s emulator", sp_paused ? "Paused" : "Unpaused");
|
||||
put_msg(msgbuf);*/
|
||||
/* rb->splash (HZ*2, true,sp_paused ? "Paused" : "Unpaused");*/
|
||||
break;
|
||||
case 'q':
|
||||
case SK_F5:
|
||||
z80_reset();
|
||||
break;
|
||||
case 't':
|
||||
case SK_F2:
|
||||
spkey_textmode();
|
||||
save_snapshot();
|
||||
spkey_screenmode();
|
||||
break;
|
||||
case 'l':
|
||||
case SK_F3:
|
||||
spkey_textmode();
|
||||
load_snapshot();
|
||||
spkey_screenmode();
|
||||
break;
|
||||
#ifdef DEBUG_Z80
|
||||
case 'v':
|
||||
deb_steps = 0;
|
||||
break;
|
||||
#endif
|
||||
case '=':
|
||||
if(showframe < 10) showframe++;
|
||||
/* sprintf(msgbuf, "showframe: %i", showframe);
|
||||
put_msg(msgbuf);*/
|
||||
break;
|
||||
case '-':
|
||||
if(showframe > 1) showframe--;
|
||||
/* sprintf(msgbuf, "showframe: %i", showframe);
|
||||
put_msg(msgbuf);*/
|
||||
break;
|
||||
case ']':
|
||||
if(bufframes < 25) bufframes++;
|
||||
/* sprintf(msgbuf, "msgbuf, bufframes: %i", bufframes);
|
||||
put_msg(msgbuf);*/
|
||||
setbufsize();
|
||||
break;
|
||||
case '[':
|
||||
if(bufframes > 1) bufframes--;
|
||||
/* sprintf(msgbuf, "bufframes: %i", bufframes);
|
||||
put_msg(msgbuf);*/
|
||||
setbufsize();
|
||||
break;
|
||||
case 'm':
|
||||
sound_on = !sound_on;
|
||||
/* sprintf(msgbuf, "sound %s", sound_on ? "on" : "off");
|
||||
put_msg(msgbuf);*/
|
||||
break;
|
||||
case 'h':
|
||||
case SK_F1:
|
||||
/* case SK_Help:
|
||||
spkey_textmode();
|
||||
print_help(help_mode);
|
||||
spkey_screenmode();
|
||||
new_help_mode = 1 - help_mode;
|
||||
break;*/
|
||||
/* case 'k':
|
||||
spkey_textmode();
|
||||
if(!display_keyboard()) print_help(2);
|
||||
spkey_screenmode();
|
||||
break;*/
|
||||
case '\\':
|
||||
case SK_F9:
|
||||
spscr_refresh_colors();
|
||||
/* sp_init_screen_mark(); already donde in prev fn. */
|
||||
clear_keystates();
|
||||
break;
|
||||
case '.':
|
||||
resize_spect_scr(scrmul+1);
|
||||
break;
|
||||
case ',':
|
||||
resize_spect_scr(scrmul-1);
|
||||
break;
|
||||
case 'y':
|
||||
sp_quick_load = !sp_quick_load;
|
||||
/* sprintf(msgbuf, "Quick load %s", sp_quick_load ? "on" : "off");
|
||||
put_msg(msgbuf);*/
|
||||
break;
|
||||
case 'w':
|
||||
case CF(SK_F2):
|
||||
save_quick_snapshot();
|
||||
break;
|
||||
case 'e':
|
||||
case CF(SK_F3):
|
||||
load_quick_snapshot();
|
||||
break;
|
||||
case 'j':
|
||||
privatemap = !privatemap;
|
||||
/* sprintf(msgbuf, "Private colormap %s", privatemap ? "on" : "off");
|
||||
put_msg(msgbuf);*/
|
||||
spscr_refresh_colors();
|
||||
break;
|
||||
}
|
||||
|
||||
help_mode = new_help_mode;
|
||||
|
||||
return 1;
|
||||
}
|
||||
30
apps/plugins/zxbox/spkey.h
Normal file
30
apps/plugins/zxbox/spkey.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPKEY_H
|
||||
#define SPKEY_H
|
||||
|
||||
extern void spkb_process_events(int evenframe);
|
||||
extern void init_spect_key(void);
|
||||
|
||||
extern int spkey_new_custom(int key);
|
||||
extern int spkey_add_custom(const char *name);
|
||||
|
||||
#endif /* SPKEY_H */
|
||||
217
apps/plugins/zxbox/spkey_p.h
Normal file
217
apps/plugins/zxbox/spkey_p.h
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPKEY_P_H
|
||||
#define SPKEY_P_H
|
||||
|
||||
#include "z80_type.h"
|
||||
|
||||
struct keystate {
|
||||
dbyte press;
|
||||
byte state;
|
||||
byte base;
|
||||
qbyte frame;
|
||||
};
|
||||
|
||||
struct onekey {
|
||||
int index;
|
||||
unsigned keysym;
|
||||
unsigned shifted;
|
||||
unsigned modif;
|
||||
};
|
||||
|
||||
typedef byte spkeyboard[8];
|
||||
|
||||
#define SPIP(spk, h) (((qbyte *) (spk))[h])
|
||||
|
||||
#define SP_COMBINE(spk1, spk2) \
|
||||
SPIP(spk1, 0) |= SPIP(spk2, 0), \
|
||||
SPIP(spk1, 1) |= SPIP(spk2, 1)
|
||||
|
||||
|
||||
#define SP_SUBSTRACT(spk1, spk2) \
|
||||
SPIP(spk1, 0) &= ~SPIP(spk2, 0), \
|
||||
SPIP(spk1, 1) &= ~SPIP(spk2, 1)
|
||||
|
||||
|
||||
#define SP_NONEMPTY(spk) (SPIP(spk, 0) || SPIP(spk, 1))
|
||||
|
||||
#define SP_CONTAINS(spk1, spk2) \
|
||||
((SPIP(spk1, 0) & SPIP(spk2, 0)) || (SPIP(spk1, 1) & SPIP(spk2, 1)))
|
||||
|
||||
#define SP_SETEMPTY(spk) \
|
||||
SPIP(spk, 0) = 0, \
|
||||
SPIP(spk, 1) = 0
|
||||
|
||||
#define SP_COPY(spk1, spk2) \
|
||||
SPIP(spk1, 0) = SPIP(spk2, 0), \
|
||||
SPIP(spk1, 1) = SPIP(spk2, 1)
|
||||
|
||||
|
||||
#define TRKS(ks) ((ks) - 0xFF00 + 0x100)
|
||||
#define KS_TO_KEY(ks) \
|
||||
(((ks) >= 0x0000 && (ks) <= 0x00FF) ? (int) (ks) : \
|
||||
(((ks) >= 0xFF00 && (ks) <= 0xFFFF) ? (int) TRKS(ks) : -1))
|
||||
|
||||
|
||||
|
||||
/* These are _accidently_ the same as the XK_ counterparts */
|
||||
|
||||
#define SK_BackSpace 0xFF08 /* back space, back char */
|
||||
#define SK_Tab 0xFF09
|
||||
#define SK_Linefeed 0xFF0A /* Linefeed, LF */
|
||||
#define SK_Clear 0xFF0B
|
||||
#define SK_Return 0xFF0D /* Return, enter */
|
||||
#define SK_Pause 0xFF13 /* Pause, hold */
|
||||
#define SK_Scroll_Lock 0xFF14
|
||||
#define SK_Sys_Req 0xFF15
|
||||
#define SK_Escape 0xFF1B
|
||||
#define SK_Delete 0xFFFF /* Delete, rubout */
|
||||
|
||||
#define SK_Home 0xFF50
|
||||
#define SK_Left 0xFF51 /* Move left, left arrow */
|
||||
#define SK_Up 0xFF52 /* Move up, up arrow */
|
||||
#define SK_Right 0xFF53 /* Move right, right arrow */
|
||||
#define SK_Down 0xFF54 /* Move down, down arrow */
|
||||
#define SK_Page_Up 0xFF55 /* Prior, previous */
|
||||
#define SK_Page_Down 0xFF56 /* Next */
|
||||
#define SK_End 0xFF57 /* EOL */
|
||||
#define SK_Begin 0xFF58 /* BOL */
|
||||
|
||||
#define SK_Select 0xFF60 /* Select, mark */
|
||||
#define SK_Print 0xFF61
|
||||
#define SK_Execute 0xFF62 /* Execute, run, do */
|
||||
#define SK_Insert 0xFF63 /* Insert, insert here */
|
||||
#define SK_Undo 0xFF65 /* Undo, oops */
|
||||
#define SK_Redo 0xFF66 /* redo, again */
|
||||
#define SK_Menu 0xFF67
|
||||
#define SK_Find 0xFF68 /* Find, search */
|
||||
#define SK_Cancel 0xFF69 /* Cancel, stop, abort, exit */
|
||||
#define SK_Help 0xFF6A /* Help */
|
||||
#define SK_Break 0xFF6B
|
||||
#define SK_Mode_switch 0xFF7E /* Character set switch */
|
||||
#define SK_Num_Lock 0xFF7F
|
||||
|
||||
#define SK_KP_Space 0xFF80 /* space */
|
||||
#define SK_KP_Tab 0xFF89
|
||||
#define SK_KP_Enter 0xFF8D /* enter */
|
||||
#define SK_KP_F1 0xFF91 /* PF1, KP_A, ... */
|
||||
#define SK_KP_F2 0xFF92
|
||||
#define SK_KP_F3 0xFF93
|
||||
#define SK_KP_F4 0xFF94
|
||||
#define SK_KP_Home 0xFF95
|
||||
#define SK_KP_Left 0xFF96
|
||||
#define SK_KP_Up 0xFF97
|
||||
#define SK_KP_Right 0xFF98
|
||||
#define SK_KP_Down 0xFF99
|
||||
#define SK_KP_Page_Up 0xFF9A
|
||||
#define SK_KP_Page_Down 0xFF9B
|
||||
#define SK_KP_End 0xFF9C
|
||||
#define SK_KP_Begin 0xFF9D
|
||||
#define SK_KP_Insert 0xFF9E
|
||||
#define SK_KP_Delete 0xFF9F
|
||||
#define SK_KP_Equal 0xFFBD /* equals */
|
||||
#define SK_KP_Multiply 0xFFAA
|
||||
#define SK_KP_Add 0xFFAB
|
||||
#define SK_KP_Separator 0xFFAC /* separator, often comma */
|
||||
#define SK_KP_Subtract 0xFFAD
|
||||
#define SK_KP_Decimal 0xFFAE
|
||||
#define SK_KP_Divide 0xFFAF
|
||||
|
||||
#define SK_KP_0 0xFFB0
|
||||
#define SK_KP_1 0xFFB1
|
||||
#define SK_KP_2 0xFFB2
|
||||
#define SK_KP_3 0xFFB3
|
||||
#define SK_KP_4 0xFFB4
|
||||
#define SK_KP_5 0xFFB5
|
||||
#define SK_KP_6 0xFFB6
|
||||
#define SK_KP_7 0xFFB7
|
||||
#define SK_KP_8 0xFFB8
|
||||
#define SK_KP_9 0xFFB9
|
||||
|
||||
#define SK_F1 0xFFBE
|
||||
#define SK_F2 0xFFBF
|
||||
#define SK_F3 0xFFC0
|
||||
#define SK_F4 0xFFC1
|
||||
#define SK_F5 0xFFC2
|
||||
#define SK_F6 0xFFC3
|
||||
#define SK_F7 0xFFC4
|
||||
#define SK_F8 0xFFC5
|
||||
#define SK_F9 0xFFC6
|
||||
#define SK_F10 0xFFC7
|
||||
#define SK_F11 0xFFC8
|
||||
#define SK_F12 0xFFC9
|
||||
|
||||
#define SK_Shift_L 0xFFE1 /* Left shift */
|
||||
#define SK_Shift_R 0xFFE2 /* Right shift */
|
||||
#define SK_Control_L 0xFFE3 /* Left control */
|
||||
#define SK_Control_R 0xFFE4 /* Right control */
|
||||
#define SK_Caps_Lock 0xFFE5 /* Caps lock */
|
||||
#define SK_Shift_Lock 0xFFE6 /* Shift lock */
|
||||
|
||||
#define SK_Meta_L 0xFFE7 /* Left meta */
|
||||
#define SK_Meta_R 0xFFE8 /* Right meta */
|
||||
#define SK_Alt_L 0xFFE9 /* Left alt */
|
||||
#define SK_Alt_R 0xFFEA /* Right alt */
|
||||
#define SK_Super_L 0xFFEB /* Left super */
|
||||
#define SK_Super_R 0xFFEC /* Right super */
|
||||
#define SK_Hyper_L 0xFFED /* Left hyper */
|
||||
#define SK_Hyper_R 0xFFEE /* Right hyper */
|
||||
|
||||
/* Modifier masks */
|
||||
|
||||
#define SKShiftMask (1<<0)
|
||||
#define SKLockMask (1<<1)
|
||||
#define SKControlMask (1<<2)
|
||||
#define SKMod1Mask (1<<3)
|
||||
#define SKMod2Mask (1<<4)
|
||||
#define SKMod3Mask (1<<5)
|
||||
#define SKMod4Mask (1<<6)
|
||||
#define SKMod5Mask (1<<7)
|
||||
|
||||
|
||||
#define NR_SPKEYS 512
|
||||
|
||||
#define ISFKEY(ks) ((ks) >= SK_F1 && (ks) <= SK_F12)
|
||||
|
||||
extern volatile int accept_keys;
|
||||
|
||||
extern qbyte sp_int_ctr;
|
||||
extern struct keystate spkb_kbstate[];
|
||||
extern struct onekey spkb_last;
|
||||
|
||||
extern int spkb_state_changed;
|
||||
|
||||
extern spkeyboard spkey_state;
|
||||
extern spkeyboard kb_mkey;
|
||||
|
||||
extern void spkey_textmode(void);
|
||||
extern void spkey_screenmode(void);
|
||||
|
||||
extern const int need_switch_mode;
|
||||
|
||||
extern int spkey_keyfuncs(void);
|
||||
extern void spkb_refresh(void);
|
||||
extern void clear_keystates(void);
|
||||
extern int display_keyboard(void);
|
||||
extern void process_keys(void);
|
||||
extern void init_basekeys(void);
|
||||
|
||||
#endif /* SPKEY_P_H */
|
||||
567
apps/plugins/zxbox/spmain.c
Normal file
567
apps/plugins/zxbox/spmain.c
Normal file
|
|
@ -0,0 +1,567 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "misc.h"
|
||||
#include "zxconfig.h"
|
||||
#include "lib/configfile.h"
|
||||
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
#include "spmain.h"
|
||||
#include "sptiming.h"
|
||||
#include "spscr.h"
|
||||
#include "spkey_p.h"
|
||||
#include "spkey.h"
|
||||
#include "sptape.h"
|
||||
#include "spsound.h"
|
||||
#include "snapshot.h"
|
||||
#include "spver.h"
|
||||
|
||||
#include "spconf.h"
|
||||
|
||||
#include "interf.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#ifdef USE_GRAY
|
||||
#include "../lib/gray.h"
|
||||
#endif
|
||||
|
||||
#include "zxbox_keyb.h"
|
||||
|
||||
int endofsingle;
|
||||
|
||||
int sp_nosync = 0;
|
||||
|
||||
int showframe = 1;
|
||||
int load_immed = 1;
|
||||
|
||||
qbyte sp_int_ctr = 0;
|
||||
int intkeys[5];
|
||||
|
||||
#ifdef USE_DJGPP
|
||||
#define DOS
|
||||
#endif
|
||||
|
||||
#define GLOBALCFG "zxbox.cfg"
|
||||
|
||||
/* here goes settings hadling */
|
||||
|
||||
/*static struct zxbox_settings settings;*/
|
||||
static struct zxbox_settings old_settings;
|
||||
|
||||
static char* noyes_options[] = { "No", "Yes" };
|
||||
/*static char* kempston_options[] = { "No", "Yes" };
|
||||
static char* showfps_options[] = {"No", "Yes"};*/
|
||||
|
||||
static struct configdata config[] =
|
||||
{
|
||||
{TYPE_ENUM, 0, 2, &settings.invert_colors, "Invert Colors", noyes_options, NULL},
|
||||
{TYPE_ENUM, 0, 2, &settings.kempston, "Map keys to kempston", noyes_options, NULL},
|
||||
{TYPE_ENUM, 0, 2, &settings.showfps, "Show Speed", noyes_options, NULL},
|
||||
{TYPE_ENUM, 0, 2, &settings.sound, "Sound", noyes_options, NULL},
|
||||
{TYPE_INT, 0, 9, &settings.frameskip, "Frameskip", NULL, NULL},
|
||||
{TYPE_INT, 1, 10, &settings.volume, "Volume", NULL, NULL},
|
||||
{TYPE_STRING, 0, 5, NULL,"Key Mapping", NULL, (char*)&settings.keymap},
|
||||
};
|
||||
int spcf_read_conf_file(const char *filename)
|
||||
{
|
||||
settings.volume = 10;
|
||||
settings.showfps=1;
|
||||
settings.keymap[0]='2';
|
||||
settings.keymap[1]='w';
|
||||
settings.keymap[2]='9';
|
||||
settings.keymap[3]='0';
|
||||
settings.keymap[4]='z';
|
||||
settings.kempston = 1 ;
|
||||
settings.invert_colors=0;
|
||||
settings.sound = 0;
|
||||
settings.frameskip = 0;
|
||||
|
||||
|
||||
configfile_init(rb);
|
||||
if (configfile_load(filename, config,
|
||||
sizeof(config)/sizeof(*config),
|
||||
SETTINGS_MIN_VERSION
|
||||
) < 0)
|
||||
{
|
||||
/* If the loading failed, save a new config file (as the disk is
|
||||
already spinning) */
|
||||
configfile_save(filename, config,
|
||||
sizeof(config)/sizeof(*config),
|
||||
SETTINGS_VERSION);
|
||||
}
|
||||
/* Keep a copy of the saved version of the settings - so we can check if
|
||||
the settings have changed when we quit */
|
||||
old_settings = settings;
|
||||
sound_on = settings.sound;
|
||||
showframe = settings.frameskip+1;
|
||||
int i;
|
||||
for ( i=0 ; i<5 ; i++){
|
||||
if (settings.keymap[i] == 'E')
|
||||
intkeys[i]=SK_KP_Enter;
|
||||
else if ( settings.keymap[i] == 'S' )
|
||||
intkeys[i]=SK_KP_Space;
|
||||
else
|
||||
intkeys[i] = (unsigned) settings.keymap[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* and here it stops (settings loading ;) )*/
|
||||
|
||||
/* set keys */
|
||||
static void set_keys(void){
|
||||
int m;
|
||||
char c;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Map Up key", NULL },
|
||||
{ "Map Down key", NULL },
|
||||
{ "Map Left key", NULL },
|
||||
{ "Map Right key", NULL },
|
||||
{ "Map Fire/Jump key", NULL },
|
||||
};
|
||||
|
||||
m = rb->menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=rb->menu_show(m);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case 0:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
settings.keymap[0]=c;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
settings.keymap[1]=c;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
settings.keymap[2]=c;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
settings.keymap[3]=c;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
settings.keymap[4]=c;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
menu_quit=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rb->menu_exit(m);
|
||||
}
|
||||
|
||||
/* select predefined keymap */
|
||||
static void select_keymap(void){
|
||||
int m;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
static const struct menu_item items[] = {
|
||||
{ "2w90z", NULL },
|
||||
{ "qaopS", NULL },
|
||||
{ "7658S", NULL },
|
||||
};
|
||||
|
||||
m = rb->menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=rb->menu_show(m);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case 0:
|
||||
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[0].desc , sizeof(items[0].desc));
|
||||
menu_quit=1;
|
||||
break;
|
||||
case 1:
|
||||
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[1].desc , sizeof(items[1].desc));
|
||||
menu_quit=1;
|
||||
break;
|
||||
case 2:
|
||||
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[2].desc , sizeof(items[2].desc));
|
||||
menu_quit=1;
|
||||
break;
|
||||
default:
|
||||
menu_quit=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rb->menu_exit(m);
|
||||
}
|
||||
|
||||
/* options menu */
|
||||
static void options_menu(void){
|
||||
static const struct opt_items no_yes[2] = {
|
||||
{ "No", NULL },
|
||||
{ "Yes", NULL },
|
||||
};
|
||||
int m;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
int new_setting;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Map Keys to kempston", NULL },
|
||||
{ "Display Speed", NULL },
|
||||
{ "Invert Colors", NULL },
|
||||
{ "Frameskip", NULL },
|
||||
{ "Sound", NULL },
|
||||
{ "Volume", NULL },
|
||||
{ "Predefined keymap", NULL },
|
||||
{ "Custom keymap", NULL },
|
||||
};
|
||||
static struct opt_items frameskip_items[] = {
|
||||
{ "0", NULL },
|
||||
{ "1", NULL },
|
||||
{ "2", NULL },
|
||||
{ "3", NULL },
|
||||
{ "4", NULL },
|
||||
{ "5", NULL },
|
||||
{ "6", NULL },
|
||||
{ "7", NULL },
|
||||
{ "8", NULL },
|
||||
{ "9", NULL },
|
||||
};
|
||||
|
||||
|
||||
m = rb->menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=rb->menu_show(m);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case 0:
|
||||
new_setting=settings.kempston;
|
||||
rb->set_option("Map Keys to kempston",&new_setting,INT,
|
||||
no_yes, 2, NULL);
|
||||
if (new_setting != settings.kempston )
|
||||
settings.kempston=new_setting;
|
||||
break;
|
||||
case 1:
|
||||
new_setting = settings.showfps;
|
||||
rb->set_option("Display Speed",&new_setting,INT,
|
||||
no_yes, 2, NULL);
|
||||
if (new_setting != settings.showfps )
|
||||
settings.showfps=new_setting;
|
||||
break;
|
||||
case 2:
|
||||
new_setting = settings.invert_colors;
|
||||
rb->set_option("Invert Colors",&new_setting,INT,
|
||||
no_yes, 2, NULL);
|
||||
if (new_setting != settings.invert_colors )
|
||||
settings.invert_colors=new_setting;
|
||||
rb->splash(HZ, true , "Restart to see effect");
|
||||
break;
|
||||
case 3:
|
||||
new_setting = settings.frameskip;
|
||||
rb->set_option("Frameskip",&new_setting,INT,
|
||||
frameskip_items, 10, NULL);
|
||||
if (new_setting != settings.frameskip )
|
||||
settings.frameskip=new_setting;
|
||||
break;
|
||||
case 4:
|
||||
new_setting = settings.sound;
|
||||
rb->set_option("Sound",&new_setting,INT,
|
||||
no_yes, 2, NULL);
|
||||
if (new_setting != settings.sound )
|
||||
settings.sound=new_setting;
|
||||
#if CODEC == SWCODEC && !defined SIMULATOR
|
||||
rb->pcm_play_stop();
|
||||
#endif
|
||||
break;
|
||||
case 5:
|
||||
new_setting = 9 - settings.volume;
|
||||
rb->set_option("Volume",&new_setting,INT,
|
||||
frameskip_items, 10, NULL);
|
||||
new_setting = 9 - new_setting;
|
||||
if (new_setting != settings.volume )
|
||||
settings.volume=new_setting;
|
||||
break;
|
||||
case 6:
|
||||
select_keymap();
|
||||
break;
|
||||
case 7:
|
||||
set_keys();
|
||||
break;
|
||||
default:
|
||||
menu_quit=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rb->menu_exit(m);
|
||||
}
|
||||
|
||||
/* menu */
|
||||
static bool zxbox_menu(void)
|
||||
{
|
||||
#if CODEC == SWCODEC && !defined SIMULATOR
|
||||
rb->pcm_play_stop();
|
||||
#endif
|
||||
int m;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
int exit=0;
|
||||
char c;
|
||||
static const struct menu_item items[] = {
|
||||
{ "VKeyboard", NULL },
|
||||
{ "Play/Pause Tape", NULL },
|
||||
{ "Save Snapshot", NULL },
|
||||
{ "Toggle \"fast\" mode", NULL },
|
||||
{ "Options", NULL },
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
|
||||
m = rb->menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=rb->menu_show(m);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case 0:
|
||||
if (!zx_kbd_input((char*) &c))
|
||||
{
|
||||
press_key(c);
|
||||
}
|
||||
clear_kbd=1;
|
||||
menu_quit=1;
|
||||
break;
|
||||
case 1:
|
||||
pause_play();
|
||||
/* SPNM(load_trapped) = 1;
|
||||
DANM(haltstate) = 1;
|
||||
DANM(tc) = 0;*/
|
||||
menu_quit=1;
|
||||
break;
|
||||
case 2:
|
||||
save_snapshot();
|
||||
break;
|
||||
case 3:
|
||||
sp_nosync=!sp_nosync;
|
||||
menu_quit=1;
|
||||
break;
|
||||
case 4:
|
||||
options_menu();
|
||||
break;
|
||||
case 5:
|
||||
menu_quit=1;
|
||||
exit=1;
|
||||
break;
|
||||
default:
|
||||
menu_quit=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rb->menu_exit(m);
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
|
||||
int i;
|
||||
for ( i=0 ; i<5 ; i++){
|
||||
if (settings.keymap[i] == 'E')
|
||||
intkeys[i]=SK_KP_Enter;
|
||||
else if ( settings.keymap[i] == 'S' )
|
||||
intkeys[i]=SK_KP_Space;
|
||||
else
|
||||
intkeys[i] = (unsigned) settings.keymap[i];
|
||||
}
|
||||
#ifdef USE_GRAY
|
||||
gray_show(true);
|
||||
#endif
|
||||
return (exit);
|
||||
}
|
||||
|
||||
|
||||
/* */
|
||||
extern unsigned char loadim[];
|
||||
extern unsigned long loadim_size;
|
||||
|
||||
#define SHOW_OFFS 1
|
||||
|
||||
static void update(void)
|
||||
{
|
||||
update_screen();
|
||||
sp_border_update >>= 1;
|
||||
sp_imag_vert = sp_imag_horiz = 0;
|
||||
}
|
||||
|
||||
static void run_singlemode(void)
|
||||
{
|
||||
int t = 0;
|
||||
int evenframe, halfsec, updateframe;
|
||||
|
||||
sp_int_ctr = 0;
|
||||
endofsingle = 0;
|
||||
spti_reset();
|
||||
|
||||
while(!endofsingle) {
|
||||
video_frames++;
|
||||
if (clear_kbd){
|
||||
clear_keystates();
|
||||
clear_kbd=0;
|
||||
}
|
||||
if(exit_requested){
|
||||
if (zxbox_menu()){
|
||||
/* Save the user settings if they have changed */
|
||||
if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) {
|
||||
#ifdef USE_GRAY
|
||||
gray_show(false);
|
||||
#endif
|
||||
rb->splash(0,true,"Saving settings...");
|
||||
configfile_save(GLOBALCFG, config,sizeof(config)/sizeof(*config),SETTINGS_VERSION);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
exit_requested = 0;
|
||||
video_frames=-1;
|
||||
start_time = *rb->current_tick;
|
||||
sound_on = settings.sound;
|
||||
showframe = settings.frameskip+1;
|
||||
spti_reset();
|
||||
}
|
||||
if(sp_paused) {
|
||||
autoclose_sound();
|
||||
while(sp_paused) {
|
||||
spkb_process_events(1);
|
||||
spti_sleep(SKIPTICKS);
|
||||
translate_screen();
|
||||
update();
|
||||
}
|
||||
spti_reset();
|
||||
}
|
||||
halfsec = !(sp_int_ctr % 25);
|
||||
evenframe = !(sp_int_ctr & 1);
|
||||
|
||||
if(screen_visible) updateframe = sp_nosync ? halfsec :
|
||||
!((sp_int_ctr+SHOW_OFFS) % showframe);
|
||||
else updateframe = 0;
|
||||
if(halfsec) {
|
||||
sp_flash_state = ~sp_flash_state;
|
||||
flash_change();
|
||||
}
|
||||
if(evenframe) {
|
||||
play_tape();
|
||||
sp_scline = 0;
|
||||
}
|
||||
spkb_process_events(evenframe);
|
||||
sp_updating = updateframe;
|
||||
t += CHKTICK;
|
||||
t = sp_halfframe(t, evenframe ? EVENHF : ODDHF);
|
||||
if(SPNM(load_trapped)) {
|
||||
SPNM(load_trapped) = 0;
|
||||
DANM(haltstate) = 0;
|
||||
qload();
|
||||
}
|
||||
z80_interrupt(0xFF);
|
||||
sp_int_ctr++;
|
||||
if(!evenframe) rec_tape();
|
||||
if(!sp_nosync) {
|
||||
if(!sound_avail) spti_wait();
|
||||
|
||||
if(updateframe) update();
|
||||
play_sound(evenframe);
|
||||
}
|
||||
else if(updateframe) update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void check_params(void* parameter)
|
||||
{
|
||||
spcf_read_conf_file(GLOBALCFG);
|
||||
spcf_read_command_line(parameter);
|
||||
}
|
||||
|
||||
static void init_load(void *parameter)
|
||||
{
|
||||
if(load_immed) snsh_z80_load_intern(loadim, loadim_size);
|
||||
|
||||
check_params (parameter);
|
||||
if(spcf_init_snapshot != NULL) {
|
||||
#ifndef USE_GRAY
|
||||
rb->splash(HZ,true, "Loading snapshot '%s'", spcf_init_snapshot);
|
||||
#endif
|
||||
|
||||
load_snapshot_file_type(spcf_init_snapshot, spcf_init_snapshot_type);
|
||||
free_string(spcf_init_snapshot);
|
||||
}
|
||||
|
||||
if(spcf_init_tapefile != NULL) {
|
||||
/*sprintf(msgbuf, "Loading tape '%s'", spcf_init_tapefile);
|
||||
put_msg(msgbuf);*/
|
||||
start_play_file_type(spcf_init_tapefile, 0, spcf_init_tapefile_type);
|
||||
if(!load_immed) pause_play();
|
||||
free_string(spcf_init_tapefile);
|
||||
}
|
||||
}
|
||||
|
||||
void start_spectemu(void *parameter)
|
||||
{
|
||||
spti_init();
|
||||
init_load(parameter);
|
||||
init_spect_scr();
|
||||
init_spect_sound();
|
||||
init_spect_key();
|
||||
|
||||
run_singlemode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
37
apps/plugins/zxbox/spmain.h
Normal file
37
apps/plugins/zxbox/spmain.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPMAIN_H
|
||||
#define SPMAIN_H
|
||||
|
||||
extern void check_params(void* parameter);
|
||||
extern void start_spectemu(void* parameter);
|
||||
extern struct zxbox_settings settings;
|
||||
struct zxbox_settings {
|
||||
int invert_colors;
|
||||
int kempston;
|
||||
char keymap[5];
|
||||
int showfps;
|
||||
int volume;
|
||||
int sound;
|
||||
int frameskip;
|
||||
};
|
||||
|
||||
#endif /* SPMAIN_H */
|
||||
99
apps/plugins/zxbox/spperif.c
Normal file
99
apps/plugins/zxbox/spperif.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "spperif.h"
|
||||
#include "z80.h"
|
||||
|
||||
extern unsigned char rom_imag[];
|
||||
|
||||
int SPNM(quick_load) = 1;
|
||||
int SPNM(load_trapped);
|
||||
|
||||
qbyte SPNM(scr_mark)[SCRMARK_SIZE];
|
||||
byte SPNM(fe_inport_high)[256];
|
||||
|
||||
int SPNM(scline);
|
||||
|
||||
|
||||
unsigned char SPNM(colors)[16];
|
||||
|
||||
int SPNM(flash_state);
|
||||
|
||||
qbyte *SPNM(scr_f0_table);
|
||||
qbyte *SPNM(scr_f1_table);
|
||||
|
||||
byte SPNM(tape_impinfo)[PORT_TIME_NUM];
|
||||
byte SPNM(fe_inport_default);
|
||||
byte SPNM(fe_outport_time)[PORT_TIME_NUM];
|
||||
byte SPNM(sound_buf)[PORT_TIME_NUM];
|
||||
signed char SPNM(tape_sound)[TMNUM];
|
||||
int SPNM(scri)[PORT_TIME_NUM];
|
||||
int SPNM(coli)[PORT_TIME_NUM];
|
||||
|
||||
int SPNM(playing_tape) = 0;
|
||||
int SPNM(paused) = 0;
|
||||
|
||||
char *SPNM(image);
|
||||
int SPNM(updating);
|
||||
qbyte SPNM(imag_mark)[192];
|
||||
qbyte SPNM(imag_horiz);
|
||||
qbyte SPNM(imag_vert);
|
||||
int SPNM(border_update);
|
||||
int SPNM(lastborder);
|
||||
|
||||
void SPNM(init_screen_mark)(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0x200; i < 0x2D8; i++) SPNM(scr_mark)[i] = ~((qbyte) 0);
|
||||
|
||||
SPNM(border_update) = 1;
|
||||
}
|
||||
|
||||
void SPNM(init)(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
PRNM(init)();
|
||||
PRNM(reset)();
|
||||
|
||||
SPNM(load_trapped) = 0;
|
||||
|
||||
for(i = 0; i < PORTNUM; i++) PRNM(inports)[i] = 0x00;
|
||||
|
||||
DANM(inport_mask) = 0x20;
|
||||
/* TODO: Kempston is always present, this is not nice */
|
||||
|
||||
SPNM(fe_inport_default) = 0xBF; /* Issue 3 */
|
||||
|
||||
DANM(ula_outport) = 0xFF;
|
||||
|
||||
for(i = 0; i < 256; i++) SPNM(fe_inport_high)[i] = 0xFF;
|
||||
|
||||
for(i = 0; i < PORT_TIME_NUM; i++) SPNM(tape_impinfo)[i] = 0;
|
||||
DANM(imp_change) = 0;
|
||||
DANM(ula_inport) = SPNM(fe_inport_default);
|
||||
|
||||
SPNM(scline) = 0;
|
||||
|
||||
for(i = 0; i < 0x4000; i++) PRNM(proc).mem[i] = rom_imag[i];
|
||||
|
||||
SPNM(init_screen_mark)();
|
||||
}
|
||||
92
apps/plugins/zxbox/spperif.h
Normal file
92
apps/plugins/zxbox/spperif.h
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPPERIF_H
|
||||
#define SPPERIF_H
|
||||
|
||||
#ifndef COMPARISON
|
||||
#define SPNM(x) sp_ ## x
|
||||
#else
|
||||
#define SPNM(x) spx_ ## x
|
||||
#endif
|
||||
|
||||
#include "z80_type.h"
|
||||
|
||||
#define ST 140000
|
||||
#define CHKTICK 224
|
||||
|
||||
/* #define TMNUM (ST / CHKTICK) */
|
||||
|
||||
#if 0
|
||||
# define TMNUM 625
|
||||
# define EVENHF 313
|
||||
# define ODDHF 312
|
||||
#else
|
||||
# define TMNUM 624
|
||||
# define EVENHF 312
|
||||
# define ODDHF 312
|
||||
#endif
|
||||
|
||||
|
||||
#define LOAD_DI 0x0559
|
||||
#define SA_LD_RET 0x053F
|
||||
|
||||
extern int SPNM(quick_load);
|
||||
extern int SPNM(load_trapped);
|
||||
|
||||
#define SCRMARK_SIZE 2048
|
||||
extern qbyte SPNM(scr_mark)[];
|
||||
extern byte SPNM(fe_inport_high)[];
|
||||
extern int SPNM(playing_tape);
|
||||
extern int SPNM(paused);
|
||||
|
||||
extern int SPNM(scline);
|
||||
|
||||
extern unsigned char SPNM(colors)[];
|
||||
|
||||
extern int SPNM(flash_state);
|
||||
|
||||
extern qbyte *SPNM(scr_f0_table);
|
||||
extern qbyte *SPNM(scr_f1_table);
|
||||
|
||||
extern int SPNM(scri)[];
|
||||
extern int SPNM(coli)[];
|
||||
|
||||
#define PORT_TIME_NUM 1024
|
||||
extern byte SPNM(tape_impinfo)[];
|
||||
extern byte SPNM(fe_inport_default);
|
||||
extern byte SPNM(fe_outport_time)[];
|
||||
extern signed char SPNM(tape_sound)[];
|
||||
extern byte SPNM(sound_buf)[];
|
||||
|
||||
|
||||
extern char *SPNM(image);
|
||||
extern int SPNM(updating);
|
||||
extern qbyte SPNM(imag_mark)[];
|
||||
extern qbyte SPNM(imag_horiz);
|
||||
extern qbyte SPNM(imag_vert);
|
||||
extern int SPNM(border_update);
|
||||
extern int SPNM(lastborder);
|
||||
|
||||
extern void SPNM(init_screen_mark)(void);
|
||||
extern void SPNM(init)(void);
|
||||
extern int SPNM(halfframe)(int firsttick, int numlines);
|
||||
|
||||
#endif /* SPPERIF_H */
|
||||
270
apps/plugins/zxbox/spscr.c
Normal file
270
apps/plugins/zxbox/spscr.c
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "spscr_p.h"
|
||||
#include "spscr.h"
|
||||
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int color_type = 0;
|
||||
|
||||
#define N0 0x04
|
||||
#define N1 0x34
|
||||
|
||||
#define B0 0x08
|
||||
#define B1 0x3F
|
||||
|
||||
|
||||
struct rgb *spscr_crgb;
|
||||
|
||||
static struct rgb norm_colors[COLORNUM]={
|
||||
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
|
||||
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
|
||||
|
||||
{0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
|
||||
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
|
||||
};
|
||||
|
||||
static struct rgb gray_colors[COLORNUM]={
|
||||
{0,0,0},{20,20,20},{26,26,26},{32,32,32},
|
||||
{38,38,38},{44,44,44},{50,50,50},{56,56,56},
|
||||
|
||||
{16,16,16},{23,23,23},{30,30,30},{36,36,36},
|
||||
{43,43,43},{50,50,50},{56,56,56},{63,63,63}
|
||||
};
|
||||
|
||||
struct rgb custom_colors[COLORNUM]={
|
||||
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
|
||||
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
|
||||
|
||||
{0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
|
||||
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
|
||||
};
|
||||
|
||||
|
||||
#define TABOFFS 2
|
||||
|
||||
volatile int screen_visible = 1;
|
||||
volatile int accept_keys = 1;
|
||||
|
||||
|
||||
byte *update_screen_line(byte *scrp, int coli, int scri, int border,
|
||||
qbyte *cmarkp)
|
||||
{
|
||||
qbyte *scrptr;
|
||||
qbyte brd_color;
|
||||
int i;
|
||||
qbyte *tmptr, *mptr;
|
||||
qbyte mark, cmark;
|
||||
|
||||
cmark = *cmarkp;
|
||||
scrptr = (qbyte *) scrp;
|
||||
if(scri >= 0) { /* normal line */
|
||||
if(SPNM(border_update)) {
|
||||
brd_color = SPNM(colors)[border];
|
||||
brd_color |= brd_color << 8;
|
||||
brd_color |= brd_color << 16;
|
||||
for(i = 8; i; i--) *scrptr++ = brd_color;
|
||||
scrptr += 0x40;
|
||||
for(i = 8; i; i--) *scrptr++ = brd_color;
|
||||
scrptr -= 0x48;
|
||||
}
|
||||
else scrptr += 0x08;
|
||||
tmptr = SPNM(scr_mark) + 0x2C0 + (coli >> 3);
|
||||
mark = *tmptr;
|
||||
if(!(coli & 0x07)) {
|
||||
cmark = mark;
|
||||
*tmptr = 0;
|
||||
}
|
||||
else cmark |= mark;
|
||||
mptr = SPNM(scr_mark) + scri;
|
||||
|
||||
mark = *mptr | cmark;
|
||||
if(mark) {
|
||||
byte *spmp, *spcp;
|
||||
qbyte *scr_tab;
|
||||
|
||||
*mptr = 0;
|
||||
SPNM(imag_mark)[coli] |= mark;
|
||||
SPNM(imag_horiz) |= mark;
|
||||
coli >>= 3;
|
||||
SPNM(imag_vert) |= (1 << coli);
|
||||
|
||||
spmp = PRNM(proc).mem + (scri << 5);
|
||||
spcp = PRNM(proc).mem + 0x5800 + (coli << 5);
|
||||
|
||||
if(!SPNM(flash_state)) scr_tab = SPNM(scr_f0_table);
|
||||
else scr_tab = SPNM(scr_f1_table);
|
||||
for(i = 32; i; i--) {
|
||||
register dbyte spcx, spmx;
|
||||
spcx = (*spcp++) << 6;
|
||||
spmx = *spmp++;
|
||||
*scrptr++ = scr_tab[spcx|((spmx & 0xf0) >> 4)];
|
||||
*scrptr++ = scr_tab[spcx|((spmx & 0x0f))];
|
||||
}
|
||||
scrptr +=0x08;
|
||||
}
|
||||
else scrptr += 0x48;
|
||||
}
|
||||
else if(scri == -1) { /* only border */
|
||||
if(SPNM(border_update)) {
|
||||
brd_color = SPNM(colors)[border];
|
||||
brd_color |= brd_color << 8;
|
||||
brd_color |= brd_color << 16;
|
||||
for(i = 0x50; i; i--) *scrptr++ = brd_color;
|
||||
}
|
||||
else scrptr += 0x50;
|
||||
}
|
||||
|
||||
*cmarkp = cmark;
|
||||
return (byte *) scrptr;
|
||||
}
|
||||
|
||||
void translate_screen(void)
|
||||
{
|
||||
int border, scline;
|
||||
byte *scrptr;
|
||||
qbyte cmark = 0;
|
||||
|
||||
scrptr = (byte *) SPNM(image);
|
||||
|
||||
border = DANM(ula_outport) & 0x07;
|
||||
if(border != SPNM(lastborder)) {
|
||||
SPNM(border_update) = 2;
|
||||
SPNM(lastborder) = border;
|
||||
}
|
||||
|
||||
for(scline = 0; scline < (TMNUM / 2); scline++)
|
||||
scrptr = update_screen_line(scrptr, SPNM(coli)[scline], SPNM(scri)[scline],
|
||||
border, &cmark);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void spscr_init_mask_color(void)
|
||||
{
|
||||
int clb;
|
||||
int bwb;
|
||||
int hb;
|
||||
int ix, j;
|
||||
int bc, fc;
|
||||
byte *tab_f0, *tab_f1;
|
||||
|
||||
sp_scr_f0_table = (qbyte *) (PRNM(proc).mem + 0x10000);
|
||||
sp_scr_f1_table = (qbyte *) (PRNM(proc).mem + 0x20000);
|
||||
|
||||
sp_colors[8] = sp_colors[0];
|
||||
|
||||
for(clb = 0; clb < 256; clb++)
|
||||
for(hb = 0; hb < 16; hb++) {
|
||||
|
||||
bc = (clb & 0x38) >> 3;
|
||||
fc = clb & 0x07;
|
||||
|
||||
if(clb & 0x40) {
|
||||
fc |= 0x08;
|
||||
bc |= 0x08;
|
||||
}
|
||||
bwb = hb;
|
||||
|
||||
ix = (clb << 8) + (hb << TABOFFS);
|
||||
tab_f0 = ((byte *) sp_scr_f0_table) + ix + 3;
|
||||
tab_f1 = ((byte *) sp_scr_f1_table) + ix + 3;
|
||||
|
||||
for(j = 4; j; bwb >>= 1, j--) {
|
||||
*tab_f0-- = (byte) sp_colors[(bwb & 0x01) ? fc : bc];
|
||||
*tab_f1-- = (byte) sp_colors[(clb & 0x80) ?
|
||||
((bwb & 0x01) ? bc : fc) :
|
||||
((bwb & 0x01) ? fc : bc)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flash_change(void)
|
||||
{
|
||||
int i,j;
|
||||
byte *scp;
|
||||
qbyte *mcp;
|
||||
register unsigned int val;
|
||||
|
||||
mcp = sp_scr_mark + 0x2C0;
|
||||
scp = z80_proc.mem + 0x5800;
|
||||
|
||||
for(i = 24; i; mcp++, i--) {
|
||||
val = 0;
|
||||
for(j = 32; j; scp++, j--) {
|
||||
val >>= 1;
|
||||
if(*scp & 0x80) val |= (1 << 31);
|
||||
}
|
||||
*mcp |= val;
|
||||
}
|
||||
}
|
||||
|
||||
void spscr_init_line_pointers(int lines)
|
||||
{
|
||||
int i;
|
||||
int bs;
|
||||
int y;
|
||||
int scline;
|
||||
|
||||
bs = (lines - 192) / 2;
|
||||
|
||||
for(i = 0; i < PORT_TIME_NUM; i++) {
|
||||
|
||||
sp_scri[i] = -2;
|
||||
|
||||
if(i < ODDHF) scline = i;
|
||||
else scline = i - ODDHF;
|
||||
|
||||
if(scline >= 64-bs && scline < 256+bs) {
|
||||
if(scline >= 64 && scline < 256) {
|
||||
y = scline - 64;
|
||||
sp_coli[i] = y;
|
||||
sp_scri[i] = 0x200 +
|
||||
(y & 0xC0) + ((y & 0x07) << 3) + ((y & 0x38) >> 3);
|
||||
}
|
||||
else sp_scri[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void spscr_init_colors(void)
|
||||
{
|
||||
spscr_crgb = norm_colors;
|
||||
|
||||
switch(color_type) {
|
||||
case 0:
|
||||
spscr_crgb = norm_colors;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spscr_crgb = gray_colors;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
spscr_crgb = custom_colors;
|
||||
break;
|
||||
}
|
||||
}
|
||||
41
apps/plugins/zxbox/spscr.h
Normal file
41
apps/plugins/zxbox/spscr.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPSCR_H
|
||||
#define SPSCR_H
|
||||
|
||||
#include "z80_type.h"
|
||||
|
||||
extern int scrmul;
|
||||
extern volatile int screen_visible;
|
||||
|
||||
extern void init_spect_scr(void);
|
||||
extern void destroy_spect_scr(void);
|
||||
extern void resize_spect_scr(int newsize);
|
||||
extern void update_screen(void);
|
||||
extern void flash_change(void);
|
||||
extern void translate_screen(void);
|
||||
|
||||
extern byte *update_screen_line(byte *scrp, int coli, int scri, int border,
|
||||
qbyte *cmarkp);
|
||||
|
||||
extern void spscr_refresh_colors(void);
|
||||
|
||||
#endif /* SPSCR_H */
|
||||
40
apps/plugins/zxbox/spscr_p.h
Normal file
40
apps/plugins/zxbox/spscr_p.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPSCR_P_H
|
||||
#define SPSCR_P_H
|
||||
|
||||
#define COLORNUM 16
|
||||
|
||||
struct rgb {
|
||||
int r, g, b;
|
||||
};
|
||||
|
||||
#define SCRSIZE 6912
|
||||
#define COLORBEG 6144
|
||||
|
||||
extern struct rgb *spscr_crgb;
|
||||
extern struct rgb custom_colors[];
|
||||
|
||||
extern void spscr_init_mask_color(void);
|
||||
extern void spscr_init_line_pointers(int lines);
|
||||
extern void spscr_init_colors(void);
|
||||
|
||||
#endif /* SPSCR_P_H */
|
||||
288
apps/plugins/zxbox/spsound.c
Normal file
288
apps/plugins/zxbox/spsound.c
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos 2006 Anton Romanov
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 DEBUG_AUDIO */
|
||||
|
||||
#include "spsound.h"
|
||||
|
||||
#include "zxconfig.h"
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
#include "misc.h"
|
||||
#include "interf.h"
|
||||
#include "spmain.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int bufframes = 1;
|
||||
|
||||
int sound_avail = 0;
|
||||
int sound_on = 1;
|
||||
|
||||
int sound_to_autoclose = 0;
|
||||
int doneplay=0;
|
||||
|
||||
|
||||
#ifdef HAVE_SOUND
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "file.h"
|
||||
#include "time.h"
|
||||
#include "errno.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
|
||||
#define SKIPTIME 5000
|
||||
|
||||
static int last_not_played=0;
|
||||
|
||||
#define SPS_OPENED 0
|
||||
#define SPS_AUTOCLOSED -1
|
||||
#define SPS_BUSY -2
|
||||
#define SPS_CLOSED -3
|
||||
#define SPS_NONEXIST -4
|
||||
|
||||
static int sndstate = SPS_CLOSED;
|
||||
|
||||
static void close_snd(int normal);
|
||||
unsigned short my_buf[TMNUM*2*3*2] IBSS_ATTR;
|
||||
|
||||
|
||||
const byte lin8_ulaw[] = {
|
||||
31, 31, 31, 32, 32, 32, 32, 33,
|
||||
33, 33, 33, 34, 34, 34, 34, 35,
|
||||
35, 35, 35, 36, 36, 36, 36, 37,
|
||||
37, 37, 37, 38, 38, 38, 38, 39,
|
||||
39, 39, 39, 40, 40, 40, 40, 41,
|
||||
41, 41, 41, 42, 42, 42, 42, 43,
|
||||
43, 43, 43, 44, 44, 44, 44, 45,
|
||||
45, 45, 45, 46, 46, 46, 46, 47,
|
||||
47, 47, 47, 48, 48, 49, 49, 50,
|
||||
50, 51, 51, 52, 52, 53, 53, 54,
|
||||
54, 55, 55, 56, 56, 57, 57, 58,
|
||||
58, 59, 59, 60, 60, 61, 61, 62,
|
||||
62, 63, 63, 64, 65, 66, 67, 68,
|
||||
69, 70, 71, 72, 73, 74, 75, 76,
|
||||
77, 78, 79, 81, 83, 85, 87, 89,
|
||||
91, 93, 95, 99, 103, 107, 111, 119,
|
||||
255, 247, 239, 235, 231, 227, 223, 221,
|
||||
219, 217, 215, 213, 211, 209, 207, 206,
|
||||
205, 204, 203, 202, 201, 200, 199, 198,
|
||||
197, 196, 195, 194, 193, 192, 191, 191,
|
||||
190, 190, 189, 189, 188, 188, 187, 187,
|
||||
186, 186, 185, 185, 184, 184, 183, 183,
|
||||
182, 182, 181, 181, 180, 180, 179, 179,
|
||||
178, 178, 177, 177, 176, 176, 175, 175,
|
||||
175, 175, 174, 174, 174, 174, 173, 173,
|
||||
173, 173, 172, 172, 172, 172, 171, 171,
|
||||
171, 171, 170, 170, 170, 170, 169, 169,
|
||||
169, 169, 168, 168, 168, 168, 167, 167,
|
||||
167, 167, 166, 166, 166, 166, 165, 165,
|
||||
165, 165, 164, 164, 164, 164, 163, 163,
|
||||
163, 163, 162, 162, 162, 162, 161, 161,
|
||||
161, 161, 160, 160, 160, 160, 159, 159,
|
||||
};
|
||||
|
||||
static void open_snd(void)
|
||||
{
|
||||
sndstate = SPS_OPENED;
|
||||
sound_avail=1;
|
||||
rb->pcm_play_stop();
|
||||
rb->pcm_set_frequency(44100);
|
||||
|
||||
}
|
||||
|
||||
static void close_snd(int normal)
|
||||
{
|
||||
(void)normal;
|
||||
sound_avail = 0;
|
||||
rb->pcm_play_stop();
|
||||
rb->pcm_set_frequency(44100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void init_spect_sound(void)
|
||||
{
|
||||
#if 1 /* TODO: Is this OK? */
|
||||
open_snd();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//#define VOLREDUCE settings.volume
|
||||
//
|
||||
#ifndef VOLREDUCE
|
||||
#define VOLREDUCE 0
|
||||
#endif
|
||||
|
||||
#define CONVU8(x) ((byte) (((x) >> VOLREDUCE) + 128))
|
||||
|
||||
#ifdef CONVERT_TO_ULAW
|
||||
# define CONV(x) lin8_ulaw[(int) CONVU8(x)]
|
||||
#else
|
||||
# define CONV(x) CONVU8(x)
|
||||
#endif
|
||||
|
||||
#define HIGH_PASS(hp, sv) (((hp) * 15 + (sv)) >> 4)
|
||||
#define TAPESOUND(tsp) ((*tsp) >> 4)
|
||||
|
||||
static void process_sound(void)
|
||||
{
|
||||
static int soundhp;
|
||||
int i;
|
||||
byte *sb;
|
||||
register int sv;
|
||||
|
||||
sb = sp_sound_buf;
|
||||
if(last_not_played) {
|
||||
soundhp = *sb;
|
||||
last_not_played = 0;
|
||||
}
|
||||
|
||||
if(!sp_playing_tape) {
|
||||
for(i = TMNUM; i; sb++,i--) {
|
||||
sv = *sb;
|
||||
soundhp = HIGH_PASS(soundhp, sv);
|
||||
*sb = CONV(sv - soundhp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
signed char *tsp;
|
||||
|
||||
tsp = sp_tape_sound;
|
||||
for(i = TMNUM; i; sb++,tsp++,i--) {
|
||||
sv = *sb + TAPESOUND(tsp);
|
||||
soundhp = (soundhp * 15 + sv)>>4;
|
||||
*sb = CONV(sv - soundhp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void autoclose_sound(void)
|
||||
{
|
||||
/* do we have any reason to autoclose sound? */
|
||||
#if 0
|
||||
if(sound_on && sound_to_autoclose && sndstate >= SPS_CLOSED) {
|
||||
close_snd(1);
|
||||
sndstate = SPS_AUTOCLOSED;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void get_more(unsigned char** start, size_t* size)
|
||||
{
|
||||
doneplay = 1;
|
||||
*start = (unsigned char*)(my_buf);
|
||||
*size = TMNUM*4*3*2;
|
||||
}
|
||||
|
||||
/* sp_sound_buf is Unsigned 8 bit, Rate 8000 Hz, Mono */
|
||||
|
||||
void write_buf(void){
|
||||
int i,j;
|
||||
|
||||
/* still not sure what is the best way to do this */
|
||||
#if 0
|
||||
my_buf[i] = /*(sp_sound_buf[i]<<8)-0x8000*/sp_sound_buf[i]<<8;
|
||||
|
||||
|
||||
for (i = 0, j = 0; i<TMNUM; i++, j+=6)
|
||||
my_buf[j] = my_buf[j+1] = my_buf[j+2] = my_buf[j+3] = my_buf[j+4] = my_buf[j+5] = (((byte)sp_sound_buf[i])<<8) >> settings.volume;
|
||||
#endif
|
||||
|
||||
|
||||
for (i = 0, j = 0; i<TMNUM; i++, j+=12)
|
||||
my_buf[j] = my_buf[j+1] = my_buf[j+2] = my_buf[j+3]\
|
||||
= my_buf[j+4] = my_buf[j+5] = my_buf[j+6]\
|
||||
= my_buf[j+7] = my_buf[j+8] = my_buf[j+9] \
|
||||
= my_buf[j+10] = my_buf[j+11] \
|
||||
= (((byte)sp_sound_buf[i])<<8) >> settings.volume;
|
||||
|
||||
rb->pcm_play_data(&get_more,NULL,0);
|
||||
|
||||
#if 0
|
||||
/* can use to save and later analyze what we produce */
|
||||
i = rb->open ( "/sound.raw" , O_WRONLY | O_APPEND | O_CREAT );
|
||||
rb->write ( i , sp_sound_buf , TMNUM );
|
||||
rb->close (i);
|
||||
|
||||
|
||||
i = rb->open ( "/sound2.raw" , O_WRONLY | O_APPEND |O_CREAT);
|
||||
rb->write ( i , (unsigned char *)my_buf , TMNUM*4*3 );
|
||||
rb->close (i);
|
||||
#endif
|
||||
|
||||
|
||||
while(!doneplay)
|
||||
rb->yield();
|
||||
|
||||
}
|
||||
void play_sound(int evenframe)
|
||||
{
|
||||
if(evenframe) return;
|
||||
if(!sound_on) {
|
||||
if(sndstate <= SPS_CLOSED) return;
|
||||
if(sndstate < SPS_OPENED) {
|
||||
sndstate = SPS_CLOSED;
|
||||
return;
|
||||
}
|
||||
close_snd(1);
|
||||
return;
|
||||
}
|
||||
|
||||
z80_proc.sound_change = 0;
|
||||
|
||||
process_sound();
|
||||
|
||||
write_buf();
|
||||
}
|
||||
|
||||
|
||||
void setbufsize(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#else /* HAVE_SOUND */
|
||||
|
||||
/* Dummy functions */
|
||||
|
||||
void setbufsize(void)
|
||||
{
|
||||
}
|
||||
|
||||
void init_spect_sound(void)
|
||||
{
|
||||
}
|
||||
|
||||
void play_sound(int evenframe)
|
||||
{
|
||||
(void)evenframe;
|
||||
}
|
||||
|
||||
void autoclose_sound(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* NO_SOUND */
|
||||
|
||||
|
||||
34
apps/plugins/zxbox/spsound.h
Normal file
34
apps/plugins/zxbox/spsound.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPSOUND_H
|
||||
#define SPSOUND_H
|
||||
|
||||
extern int bufframes;
|
||||
extern int sound_avail;
|
||||
extern void setbufsize(void);
|
||||
|
||||
extern void autoclose_sound(void);
|
||||
extern void init_spect_sound(void);
|
||||
extern void play_sound(int evenframe);
|
||||
|
||||
extern int sound_on;
|
||||
|
||||
#endif /* SPSOUND_H */
|
||||
765
apps/plugins/zxbox/sptape.c
Normal file
765
apps/plugins/zxbox/sptape.c
Normal file
|
|
@ -0,0 +1,765 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "misc.h"
|
||||
|
||||
#include "sptape.h"
|
||||
#include "tapefile.h"
|
||||
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
#include "interf.h"
|
||||
#include "spconf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAXLINELEN 256
|
||||
|
||||
int spt_auto_stop = 1;
|
||||
|
||||
static int playing = 0;
|
||||
static int paused = 0;
|
||||
/*static FILE *tapefp;*/
|
||||
/*static int *tapefp;*/
|
||||
|
||||
static char tapename[MAXFILENAME];
|
||||
static int tapetype;
|
||||
|
||||
#define EARBIT 0x40
|
||||
|
||||
#define IMPBUFLEN 1024
|
||||
|
||||
static int ingroup;
|
||||
static int segtype;
|
||||
|
||||
static int lastdatak;
|
||||
|
||||
static int currseg;
|
||||
|
||||
static void stop_playing(void)
|
||||
{
|
||||
if(playing) close_tapefile();
|
||||
playing = 0;
|
||||
}
|
||||
|
||||
static void pause_playing(void)
|
||||
{
|
||||
if(playing) {
|
||||
paused = 1;
|
||||
playing = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void unpause_playing(void)
|
||||
{
|
||||
if(paused) {
|
||||
paused = 0;
|
||||
playing = 1;
|
||||
segtype = SEG_END;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAXDESCLEN 256
|
||||
|
||||
static void put_seg_desc(void)
|
||||
{
|
||||
if(segtype != SEG_VIRTUAL) {
|
||||
if(segtype > SEG_END) {
|
||||
if(!ingroup) {
|
||||
long len;
|
||||
int i, ml;
|
||||
char *me;
|
||||
|
||||
len = get_seglen();
|
||||
|
||||
me = msgbuf;
|
||||
rb->snprintf(me,MAXDESCLEN, "%4i: ", currseg);
|
||||
me = me+rb->strlen(me);
|
||||
if(segtype >= SEG_DATA && len) {
|
||||
rb->snprintf(me,MAXDESCLEN, "%5li bytes, ", len);
|
||||
me = me+rb->strlen(me);
|
||||
}
|
||||
|
||||
ml = 0;
|
||||
for(i = 0; seg_desc[i]; i++) {
|
||||
if(seg_desc[i] == '\n') {
|
||||
*me = '\0';
|
||||
put_msg(msgbuf);
|
||||
|
||||
me = msgbuf;
|
||||
rb->snprintf(me,MAXDESCLEN, " ");
|
||||
me = me+rb->strlen(me);
|
||||
ml = 0;
|
||||
}
|
||||
else {
|
||||
if(ml < MAXDESCLEN) *me++ = seg_desc[i];
|
||||
ml++;
|
||||
}
|
||||
}
|
||||
*me = '\0';
|
||||
put_msg(msgbuf);
|
||||
}
|
||||
else {
|
||||
rb->snprintf(msgbuf,MAXDESCLEN, "%4i:", currseg);
|
||||
put_tmp_msg(msgbuf);
|
||||
}
|
||||
}
|
||||
else put_msg(seg_desc);
|
||||
}
|
||||
#ifdef DEBUG_TAPE
|
||||
else fprintf(stderr, "virtual segment\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void get_next_segment(void)
|
||||
{
|
||||
int propseg;
|
||||
|
||||
do {
|
||||
propseg = 1;
|
||||
|
||||
segtype = next_segment();
|
||||
currseg = segment_pos();
|
||||
|
||||
put_seg_desc();
|
||||
|
||||
switch(segtype) {
|
||||
case SEG_ERROR:
|
||||
case SEG_END:
|
||||
stop_playing();
|
||||
break;
|
||||
|
||||
case SEG_STOP:
|
||||
pause_playing();
|
||||
put_msg(" * Tape paused; Press Ctrl-o to restart * ");
|
||||
break;
|
||||
|
||||
case SEG_SKIP:
|
||||
propseg = 0;
|
||||
break;
|
||||
|
||||
case SEG_GRP_BEG:
|
||||
ingroup = 1;
|
||||
propseg = 0;
|
||||
break;
|
||||
|
||||
case SEG_GRP_END:
|
||||
ingroup = 0;
|
||||
propseg = 0;
|
||||
break;
|
||||
}
|
||||
} while(!propseg);
|
||||
|
||||
lastdatak = 0;
|
||||
}
|
||||
|
||||
|
||||
void play_tape(void)
|
||||
{
|
||||
static dbyte impbuf[IMPBUFLEN];
|
||||
|
||||
static int clevel;
|
||||
static dbyte *impbufp;
|
||||
static int impbufrem;
|
||||
static long imprem;
|
||||
|
||||
static int cleared_buffers = 1;
|
||||
|
||||
int tsn;
|
||||
dbyte *ibp;
|
||||
byte *tsp;
|
||||
int ibr;
|
||||
long ir;
|
||||
int cl;
|
||||
signed char *op;
|
||||
int ov;
|
||||
int ca;
|
||||
|
||||
tsp = sp_tape_impinfo;
|
||||
op = sp_tape_sound;
|
||||
tsn = TMNUM;
|
||||
|
||||
if(!playing) {
|
||||
if(cleared_buffers) return;
|
||||
|
||||
sp_playing_tape = 0;
|
||||
|
||||
if(!clevel) {
|
||||
ca = CHKTICK;
|
||||
clevel = ~clevel;
|
||||
}
|
||||
else {
|
||||
ca = 0;
|
||||
cleared_buffers = 1;
|
||||
}
|
||||
imprem = CHKTICK * TMNUM;
|
||||
}
|
||||
else if(!sp_playing_tape) {
|
||||
sp_playing_tape = 1;
|
||||
cleared_buffers = 0;
|
||||
|
||||
impbufrem = 0;
|
||||
imprem = 0;
|
||||
clevel = get_level() ? ~(0) : 0;
|
||||
if(clevel) ca = 0;
|
||||
else ca = 1;
|
||||
}
|
||||
else ca = 0;
|
||||
|
||||
#ifdef DEBUG_TAPE
|
||||
if(((clevel ? 1 : 0) ^
|
||||
(DANM(ula_inport) & EARBIT ? 1 : 0) ^
|
||||
(DANM(imp_change) ? 1 : 0) ^
|
||||
(ca ? 1 : 0)) == 0)
|
||||
fprintf(stderr, "Levels don't match %i %i\n", imprem, impbufrem);
|
||||
#endif
|
||||
|
||||
cl = clevel;
|
||||
ibr = impbufrem;
|
||||
ir = imprem;
|
||||
ibp = impbufp;
|
||||
|
||||
if(cl) ov = CHKTICK/2;
|
||||
else ov = -(CHKTICK/2);
|
||||
|
||||
do {
|
||||
if(ir > 0) {
|
||||
*tsp++ = ca;
|
||||
*op++ = ov;
|
||||
ir -= CHKTICK;
|
||||
tsn--;
|
||||
if(!tsn) goto done;
|
||||
|
||||
if(cl) ov = CHKTICK/2;
|
||||
else ov = -(CHKTICK/2);
|
||||
|
||||
while(ir > 0) {
|
||||
*tsp++ = 0;
|
||||
*op++ = ov;
|
||||
ir -= CHKTICK;
|
||||
tsn--;
|
||||
if(!tsn) goto done;
|
||||
}
|
||||
ca = 0;
|
||||
}
|
||||
if(ibr) {
|
||||
if(!ca) {
|
||||
if(cl) {
|
||||
ov += ir;
|
||||
ca = (CHKTICK/2) - ov + 1;
|
||||
}
|
||||
else {
|
||||
ov -= ir;
|
||||
ca = ov + (CHKTICK/2) + 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ca = 0;
|
||||
if(cl) ov += ir;
|
||||
else ov -= ir;
|
||||
}
|
||||
ir += *ibp++;
|
||||
ibr--;
|
||||
cl = ~cl;
|
||||
}
|
||||
else {
|
||||
ibp = impbuf;
|
||||
do {
|
||||
ibr = next_imps(impbuf, IMPBUFLEN, CHKTICK * tsn);
|
||||
if(ibr) break;
|
||||
get_next_segment();
|
||||
if(!playing) {
|
||||
if(!cl) {
|
||||
if(ca) ca = 0;
|
||||
else ca = CHKTICK;
|
||||
cl = ~cl;
|
||||
}
|
||||
ir = tsn*CHKTICK;
|
||||
ov = -(CHKTICK/2);
|
||||
break;
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
|
||||
} while(1);
|
||||
|
||||
done:
|
||||
|
||||
clevel = cl;
|
||||
impbufrem = ibr;
|
||||
imprem = ir;
|
||||
impbufp = ibp;
|
||||
|
||||
if(segtype >= SEG_DATA) {
|
||||
int datak;
|
||||
|
||||
datak = (int) (get_segpos() / 1000);
|
||||
if(datak > lastdatak) {
|
||||
/* if(ingroup) sprintf(msgbuf, "%4i: ", currseg);
|
||||
else sprintf(msgbuf, " ");
|
||||
sprintf(msgbuf+strlen(msgbuf), "%3ik", datak);
|
||||
put_tmp_msg(msgbuf);
|
||||
*/
|
||||
lastdatak = datak;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
2168
|
||||
2168 (9-10)
|
||||
|
||||
667
|
||||
735 (2-4)
|
||||
|
||||
855
|
||||
855 (3-5)
|
||||
|
||||
1710
|
||||
1710 (7-9)
|
||||
|
||||
945 (4-5)
|
||||
|
||||
hosszu: 7..9
|
||||
rovid: 2..5
|
||||
|
||||
*/
|
||||
|
||||
#define MICBIT 0x08
|
||||
|
||||
|
||||
#define RC_NONE 0
|
||||
#define RC_LEADER 1
|
||||
#define RC_SYNC 2
|
||||
#define RC_DATA 3
|
||||
|
||||
#define MAXLEN TMNUM
|
||||
|
||||
#define LEADER_MIN 9
|
||||
#define LEADER_MAX 10
|
||||
#define SYNC_MIN 2
|
||||
#define SYNC_MAX 4
|
||||
|
||||
#define BIT0_MIN 3
|
||||
#define BIT0_MAX 5
|
||||
#define BIT1_MIN 7
|
||||
#define BIT1_MAX 9
|
||||
|
||||
#define LEADER_MIN_COUNT 512
|
||||
/*
|
||||
static int rec_segment;
|
||||
static int rec_state = RC_NONE;
|
||||
static byte *recbuf = NULL;
|
||||
static const char *waitchars = "-\\|/";
|
||||
*/
|
||||
static int recording = 0;
|
||||
|
||||
|
||||
|
||||
void rec_tape(void)
|
||||
{
|
||||
/* static byte lastmic = 0;
|
||||
static int lastlen = 0;
|
||||
static int whole;
|
||||
static int leadercount;
|
||||
static byte data;
|
||||
static byte parity;
|
||||
static int bitnum;
|
||||
static int bytecount;
|
||||
static int recbufsize;
|
||||
static int firsthalf;
|
||||
static int frameswait = 0;
|
||||
|
||||
int tsl;
|
||||
byte *fep;
|
||||
int thishalf;
|
||||
|
||||
|
||||
if(!recording) return;
|
||||
|
||||
for(fep = sp_fe_outport_time, tsl = TMNUM; tsl; fep++, tsl--) {
|
||||
lastlen++;
|
||||
if((*fep & MICBIT) == lastmic) {
|
||||
if(lastlen < MAXLEN) continue;
|
||||
}
|
||||
else lastmic = ~lastmic & MICBIT;
|
||||
|
||||
switch(rec_state) {
|
||||
case RC_NONE:
|
||||
if(lastlen >= LEADER_MIN && lastlen <= LEADER_MAX) {
|
||||
rec_state = RC_LEADER;
|
||||
|
||||
leadercount = 0;
|
||||
break;
|
||||
}
|
||||
if((frameswait++ & 15)) break;
|
||||
frameswait &= 0x3F;
|
||||
sprintf(msgbuf, " %s: WAITING %c",
|
||||
tapename, waitchars[(frameswait >> 4)]);
|
||||
put_tmp_msg(msgbuf);
|
||||
break;
|
||||
case RC_LEADER:
|
||||
if(lastlen >= LEADER_MIN && lastlen <= LEADER_MAX) {
|
||||
leadercount++;
|
||||
if(leadercount == LEADER_MIN_COUNT) {
|
||||
sprintf(msgbuf, " %s: LEADER", tapename);
|
||||
put_tmp_msg(msgbuf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(leadercount >= LEADER_MIN_COUNT &&
|
||||
lastlen >= SYNC_MIN && lastlen <= SYNC_MAX) rec_state = RC_SYNC;
|
||||
else rec_state = RC_NONE;
|
||||
break;
|
||||
case RC_SYNC:
|
||||
if(lastlen >= SYNC_MIN && lastlen <= SYNC_MAX) {
|
||||
rec_state = RC_DATA;
|
||||
whole = 0;
|
||||
data = 0;
|
||||
bitnum = 0;
|
||||
bytecount = 0;
|
||||
recbuf = NULL;
|
||||
recbufsize = 0;
|
||||
parity = 0;
|
||||
|
||||
sprintf(msgbuf, " %s: DATA", tapename);
|
||||
put_tmp_msg(msgbuf);
|
||||
}
|
||||
else rec_state = RC_NONE;
|
||||
break;
|
||||
case RC_DATA:
|
||||
thishalf = -1;
|
||||
if(lastlen >= BIT0_MIN && lastlen <= BIT0_MAX) thishalf = 0;
|
||||
else if(lastlen >= BIT1_MIN && lastlen <= BIT1_MAX) thishalf = 1;
|
||||
|
||||
if(thishalf < 0 || (whole && firsthalf != thishalf)) {
|
||||
char filename[11];
|
||||
int filesize;
|
||||
int filetype;
|
||||
|
||||
sprintf(msgbuf, "%s: %03d", tapename, rec_segment);
|
||||
if(bytecount >= 1) {
|
||||
sprintf(msgbuf+strlen(msgbuf),
|
||||
" %02X %5d %3s", recbuf[0], bytecount-2,
|
||||
parity == 0 ? "OK" : "ERR");
|
||||
if(recbuf[0] == 0 && bytecount - 2 >= 17) {
|
||||
filetype = recbuf[1];
|
||||
strncpy(filename, (char*) recbuf+2, 10);
|
||||
filename[10] = '\0';
|
||||
filesize = recbuf[12] + (recbuf[13] << 8);
|
||||
|
||||
sprintf(msgbuf+strlen(msgbuf),
|
||||
" %02X %10s %5i", filetype, filename, filesize);
|
||||
}
|
||||
}
|
||||
put_msg(msgbuf);
|
||||
|
||||
putc(bytecount & 0xFF, tapefp);
|
||||
putc((bytecount >> 8) & 0xFF, tapefp);
|
||||
|
||||
fwrite(recbuf, 1, (size_t) bytecount, tapefp);
|
||||
fflush(tapefp);
|
||||
|
||||
rec_segment++;
|
||||
free(recbuf);
|
||||
recbuf = NULL;
|
||||
rec_state = RC_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!whole) {
|
||||
whole = 1;
|
||||
firsthalf = thishalf;
|
||||
}
|
||||
else {
|
||||
whole = 0;
|
||||
data |= thishalf;
|
||||
bitnum++;
|
||||
|
||||
if(bitnum == 8) {
|
||||
bitnum = 0;
|
||||
if(recbufsize <= bytecount) {
|
||||
recbufsize += 1024;
|
||||
recbuf = realloc(recbuf, (size_t) recbufsize);
|
||||
if(recbuf == NULL) {
|
||||
//fprintf(stderr, "Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
recbuf[bytecount] = data;
|
||||
parity = parity ^ data;
|
||||
data = 0;
|
||||
bytecount++;
|
||||
|
||||
if(!(bytecount & 1023)) {
|
||||
sprintf(msgbuf, " %s: DATA %i kB",
|
||||
tapename, bytecount >> 10);
|
||||
put_tmp_msg(msgbuf);
|
||||
}
|
||||
}
|
||||
data <<= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
lastlen = 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
static void stop_recording(void)
|
||||
{
|
||||
/* if(recording) {
|
||||
recording = 0;
|
||||
free(recbuf);
|
||||
recbuf = NULL;
|
||||
|
||||
rb->close(tapefp);
|
||||
}*/
|
||||
}
|
||||
|
||||
static void restart_playing(void)
|
||||
{
|
||||
int res;
|
||||
struct tape_options tapeopt;
|
||||
|
||||
if(tapetype < 0) {
|
||||
tapetype = TAP_TZX;
|
||||
res = open_tapefile(tapename, tapetype);
|
||||
if(!res) {
|
||||
tapetype = TAP_TAP;
|
||||
res = open_tapefile(tapename, tapetype);
|
||||
}
|
||||
}
|
||||
else res = open_tapefile(tapename, tapetype);
|
||||
|
||||
if(!res) {
|
||||
put_msg(seg_desc);
|
||||
return;
|
||||
}
|
||||
|
||||
INITTAPEOPT(tapeopt);
|
||||
#ifndef DEBUG_Z80
|
||||
tapeopt.blanknoise = 1;
|
||||
#endif
|
||||
set_tapefile_options(&tapeopt);
|
||||
|
||||
if(currseg) {
|
||||
res = goto_segment(currseg);
|
||||
if(!res) {
|
||||
put_msg(seg_desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
playing = 1;
|
||||
segtype = SEG_END;
|
||||
}
|
||||
|
||||
|
||||
void pause_play(void)
|
||||
{
|
||||
if(playing) {
|
||||
pause_playing();
|
||||
put_msg(" * Tape paused * ");
|
||||
goto_segment(currseg);
|
||||
}
|
||||
else unpause_playing();
|
||||
}
|
||||
|
||||
|
||||
void start_play_file_type(char *name, int seg, int type)
|
||||
{
|
||||
int filetype = FT_TAPEFILE;
|
||||
|
||||
rb->strncpy(tapename, name, MAXFILENAME-10);
|
||||
tapename[MAXFILENAME-10] = '\0';
|
||||
|
||||
currseg = seg;
|
||||
tapetype = type;
|
||||
|
||||
spcf_find_file_type(tapename, &filetype, &tapetype);
|
||||
if(currseg < 0) currseg = 0;
|
||||
|
||||
ingroup = 0;
|
||||
restart_playing();
|
||||
}
|
||||
|
||||
void start_play(void)
|
||||
{
|
||||
char *name;
|
||||
int t;
|
||||
int seg;
|
||||
|
||||
if(playing || paused || recording) {
|
||||
put_msg(" * Stop the tape first! * ");
|
||||
return;
|
||||
}
|
||||
|
||||
put_msg("Enter tape file path:");
|
||||
name = spif_get_tape_fileinfo(&seg, &t);
|
||||
if(name == NULL) return;
|
||||
|
||||
start_play_file_type(name, seg, -1);
|
||||
}
|
||||
|
||||
|
||||
void stop_play(void)
|
||||
{
|
||||
|
||||
if(playing || paused) {
|
||||
put_msg(" * Stopped playing * ");
|
||||
|
||||
if(playing) stop_playing();
|
||||
if(paused) paused = 0;
|
||||
}
|
||||
else if(recording) {
|
||||
/* sprintf(msgbuf, " * Stopped recording tape `%s' * ", tapename);
|
||||
put_msg(msgbuf);*/
|
||||
stop_recording();
|
||||
}
|
||||
}
|
||||
|
||||
void start_rec(void)
|
||||
{
|
||||
#if 0
|
||||
char *name;
|
||||
|
||||
if(playing || paused || recording) return;
|
||||
|
||||
put_msg("Enter tape file to record (default: '.tap'):");
|
||||
|
||||
name = spif_get_filename();
|
||||
if(name == NULL) return;
|
||||
|
||||
strncpy(tapename, name, MAXFILENAME-10);
|
||||
tapename[MAXFILENAME-10] = '\0';
|
||||
|
||||
if(!check_ext(tapename, "tap")) add_extension(tapename, "tap");
|
||||
|
||||
tapefp = fopen(tapename, "ab");
|
||||
if(tapefp == NULL) {
|
||||
sprintf(msgbuf, "Could not open tape file `%s', %s",
|
||||
tapename, strerror(errno));
|
||||
put_msg(msgbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
recording = 1;
|
||||
rec_segment = 0;
|
||||
rec_state = RC_NONE;
|
||||
|
||||
sprintf(msgbuf,
|
||||
"Recordind tape file `%s'. To stop press Ctrl-s", tapename);
|
||||
put_msg(msgbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "spkey_p.h"
|
||||
|
||||
#define CF 0x01
|
||||
#define ZF 0x40
|
||||
|
||||
void qload(void)
|
||||
{
|
||||
byte type, parity;
|
||||
dbyte length, dest, dtmp;
|
||||
int verify, success, firstbyte;
|
||||
int nextdata;
|
||||
|
||||
if(recording) {
|
||||
put_msg("Can't quick load tape, because recording");
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
if(!playing) {
|
||||
if(paused) unpause_playing();
|
||||
else {
|
||||
spkey_textmode();
|
||||
start_play();
|
||||
spkey_screenmode();
|
||||
}
|
||||
}
|
||||
if(!playing) {
|
||||
put_msg("Not quick loading tape");
|
||||
return;
|
||||
}
|
||||
while(playing && (segtype != SEG_DATA || get_segpos() > 0))
|
||||
get_next_segment();
|
||||
|
||||
} while(!playing);
|
||||
|
||||
dtmp = AFBK;
|
||||
AFBK = AF;
|
||||
AF = dtmp;
|
||||
|
||||
type = RA;
|
||||
verify = !(RF & CF);
|
||||
length = DE;
|
||||
firstbyte = !(RF & ZF);
|
||||
dest = IX;
|
||||
|
||||
parity = 0;
|
||||
success = 0;
|
||||
|
||||
do {
|
||||
nextdata = next_byte();
|
||||
if(nextdata < 0) break;
|
||||
|
||||
parity ^= nextdata;
|
||||
|
||||
if(!length) {
|
||||
if(!parity) success = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(firstbyte) {
|
||||
firstbyte = 0;
|
||||
if(nextdata != type) break;
|
||||
}
|
||||
else {
|
||||
if(!verify) {
|
||||
if(dest >= 0x4000) DANM(mem)[dest] = nextdata;
|
||||
}
|
||||
else {
|
||||
if(DANM(mem)[dest] != nextdata) break;
|
||||
}
|
||||
dest++;
|
||||
length--;
|
||||
}
|
||||
} while(1);
|
||||
|
||||
if(success) RF |= (CF | ZF);
|
||||
else RF &= ~(CF | ZF);
|
||||
IX = dest;
|
||||
DE = length;
|
||||
|
||||
PC = SA_LD_RET;
|
||||
DANM(iff1) = DANM(iff2) = 1;
|
||||
DANM(haltstate) = 1;
|
||||
|
||||
sp_init_screen_mark();
|
||||
|
||||
if(spt_auto_stop) pause_playing();
|
||||
}
|
||||
36
apps/plugins/zxbox/sptape.h
Normal file
36
apps/plugins/zxbox/sptape.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPTAPE_H
|
||||
#define SPTAPE_H
|
||||
|
||||
extern void play_tape(void);
|
||||
extern void rec_tape(void);
|
||||
|
||||
extern void stop_play(void);
|
||||
extern void pause_play(void);
|
||||
|
||||
extern void start_play(void);
|
||||
extern void start_play_file_type(char *name, int seg, int type);
|
||||
|
||||
extern void start_rec(void);
|
||||
extern void qload(void);
|
||||
|
||||
#endif /* SPTAPE_H */
|
||||
55
apps/plugins/zxbox/sptiming.c
Normal file
55
apps/plugins/zxbox/sptiming.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos 2006 Anton Romanov
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "zxconfig.h"
|
||||
|
||||
#include "sptiming.h"
|
||||
#include "interf.h"
|
||||
/* not precise but .... anyway this is used only when not playing
|
||||
* sound ... */
|
||||
long shouldbe_tick;
|
||||
|
||||
void spti_init(void){
|
||||
spti_reset();
|
||||
}
|
||||
void spti_sleep(unsigned long usecs){
|
||||
/* unsigned long now,need;
|
||||
now = *rb->current_tick;
|
||||
need = now + usecs;
|
||||
rb -> sleep ( need - now );*/
|
||||
rb->sleep ( usecs );
|
||||
}
|
||||
void spti_reset(void){
|
||||
shouldbe_tick = *rb -> current_tick;
|
||||
}
|
||||
void spti_wait(void){
|
||||
long rem;
|
||||
long now;
|
||||
|
||||
now = *rb -> current_tick;
|
||||
shouldbe_tick+=SKIPTICKS;
|
||||
rem = shouldbe_tick - now;
|
||||
|
||||
if(rem > 0) {
|
||||
if(rem > SKIPTICKS) rem = SKIPTICKS;
|
||||
spti_sleep((unsigned long) rem);
|
||||
}
|
||||
if(rem == SKIPTICKS || rem < -10 * SKIPTIME) spti_reset();
|
||||
}
|
||||
33
apps/plugins/zxbox/sptiming.h
Normal file
33
apps/plugins/zxbox/sptiming.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPTIMING_H
|
||||
#define SPTIMING_H
|
||||
|
||||
#define SKIPMS 20
|
||||
#define SKIPTIME (SKIPMS * 1000)
|
||||
#define SKIPTICKS 20*HZ/1000
|
||||
|
||||
extern void spti_init(void);
|
||||
extern void spti_sleep(unsigned long usecs);
|
||||
extern void spti_reset(void);
|
||||
extern void spti_wait(void);
|
||||
|
||||
#endif /* SPTIMING_H */
|
||||
29
apps/plugins/zxbox/spver.h
Normal file
29
apps/plugins/zxbox/spver.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "config.h"
|
||||
|
||||
#define SPECTEMU_VERSION "0.94"
|
||||
|
||||
#ifdef Z80C
|
||||
#define SPECTEMU_TYPE "c"
|
||||
#else
|
||||
#define SPECTEMU_TYPE "i"
|
||||
#endif
|
||||
61
apps/plugins/zxbox/tapef_p.h
Normal file
61
apps/plugins/zxbox/tapef_p.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAPEF_P_H
|
||||
#define TAPEF_P_H
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short dbyte;
|
||||
typedef unsigned long qbyte;
|
||||
|
||||
#define BYTE(arr, i) (arr[i])
|
||||
#define DBYTE(arr, i) (arr[i] + (arr[(i)+1] << 8))
|
||||
|
||||
struct tapeinfo {
|
||||
int type;
|
||||
int tzxminver, tzxmajver;
|
||||
};
|
||||
|
||||
struct seginfo {
|
||||
int type;
|
||||
int segtype;
|
||||
|
||||
dbyte pulse;
|
||||
dbyte num;
|
||||
dbyte sync1p;
|
||||
dbyte sync2p;
|
||||
dbyte zerop;
|
||||
dbyte onep;
|
||||
|
||||
dbyte pause;
|
||||
|
||||
byte bused;
|
||||
|
||||
long len;
|
||||
long ptr;
|
||||
};
|
||||
|
||||
extern struct tapeinfo tf_tpi;
|
||||
extern struct seginfo tf_cseg;
|
||||
extern long tf_segoffs;
|
||||
|
||||
extern byte *tf_get_block(int i);
|
||||
|
||||
#endif /* TAPEF_P_H */
|
||||
1047
apps/plugins/zxbox/tapefile.c
Normal file
1047
apps/plugins/zxbox/tapefile.c
Normal file
File diff suppressed because it is too large
Load diff
85
apps/plugins/zxbox/tapefile.h
Normal file
85
apps/plugins/zxbox/tapefile.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAPEFILE_H
|
||||
#define TAPEFILE_H
|
||||
|
||||
#define DAT_ERR -2
|
||||
#define DAT_END -1
|
||||
|
||||
#define SEG_ERROR -1
|
||||
#define SEG_END 0 /* ^--- End of tape */
|
||||
|
||||
#define SEG_STOP 1
|
||||
#define SEG_SKIP 2
|
||||
#define SEG_GRP_BEG 3
|
||||
#define SEG_GRP_END 4
|
||||
|
||||
#define SEG_DATA 10
|
||||
#define SEG_DATA_TURBO 11
|
||||
#define SEG_DATA_PURE 12
|
||||
|
||||
#define SEG_PAUSE 20
|
||||
#define SEG_OTHER 21
|
||||
|
||||
#define SEG_VIRTUAL 30
|
||||
|
||||
#define TAP_TAP 0
|
||||
#define TAP_TZX 1
|
||||
|
||||
#define MACHINE_48 0
|
||||
#define MACHINE_128 1
|
||||
|
||||
struct tape_options {
|
||||
int blanknoise;
|
||||
int stoppause;
|
||||
int machine;
|
||||
};
|
||||
|
||||
#define INITTAPEOPT(to) \
|
||||
(to).blanknoise=0, \
|
||||
(to).stoppause=0, \
|
||||
(to).machine=MACHINE_48
|
||||
|
||||
extern char seg_desc[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int open_tapefile(char *name, int type);
|
||||
extern void close_tapefile(void);
|
||||
extern int goto_segment(int at_seg);
|
||||
extern int next_segment(void);
|
||||
extern int next_byte(void);
|
||||
extern int next_imps(unsigned short *impbuf, int buflen, long timelen);
|
||||
|
||||
extern void set_tapefile_options(struct tape_options *to);
|
||||
extern int get_level(void);
|
||||
|
||||
extern long get_seglen(void);
|
||||
extern long get_segpos(void);
|
||||
extern unsigned segment_pos(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TAPEFILE_H */
|
||||
132
apps/plugins/zxbox/z80.c
Normal file
132
apps/plugins/zxbox/z80.c
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "z80.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "zxconfig.h"
|
||||
#include "helpers.h"
|
||||
Z80 PRNM(proc);
|
||||
|
||||
byte PRNM(inports)[PORTNUM];
|
||||
byte PRNM(outports)[PORTNUM];
|
||||
|
||||
|
||||
#ifdef SPECT_MEM
|
||||
#define NUM64KSEGS 3
|
||||
#endif
|
||||
|
||||
#ifndef NUM64KSEGS
|
||||
#define NUM64KSEGS 1
|
||||
#endif
|
||||
|
||||
static byte *a64kmalloc(int num64ksegs)
|
||||
{
|
||||
byte *bigmem;
|
||||
|
||||
bigmem = (byte *) my_malloc((unsigned) (0x10000 * (num64ksegs + 1)));
|
||||
if(bigmem == NULL) {
|
||||
/*fprintf(stderr, "Out of memory!\n");*/
|
||||
/*exit(1);*/
|
||||
}
|
||||
|
||||
return (byte *) (( (long) bigmem & ~((long) 0xFFFF)) + 0x10000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PRNM(init)(void)
|
||||
{
|
||||
qbyte i;
|
||||
|
||||
DANM(mem) = a64kmalloc(NUM64KSEGS);
|
||||
|
||||
rb->srand((unsigned int)( rb->get_time()->tm_sec+rb->get_time()->tm_min*60 + rb->get_time()->tm_hour*3600));
|
||||
for(i = 0; i < 0x10000; i++) DANM(mem)[i] = (byte) rb->rand();
|
||||
|
||||
for(i = 0; i < NUMDREGS; i++) {
|
||||
DANM(nr)[i].p = DANM(mem);
|
||||
DANM(nr)[i].d.d = (dbyte) rb->rand();
|
||||
}
|
||||
|
||||
for(i = 0; i < BACKDREGS; i++) {
|
||||
DANM(br)[i].p = DANM(mem);
|
||||
DANM(br)[i].d.d = (dbyte) rb->rand();
|
||||
}
|
||||
|
||||
for(i = 0; i < PORTNUM; i++) PRNM(inports)[i] = PRNM(outports)[i] = 0;
|
||||
|
||||
PRNM(local_init)();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: no interrupt immediately afer EI (not important for spectrum) */
|
||||
|
||||
void PRNM(nmi)(void)
|
||||
{
|
||||
DANM(iff2) = DANM(iff1);
|
||||
DANM(iff1) = 0;
|
||||
|
||||
DANM(haltstate) = 0;
|
||||
PRNM(pushpc)();
|
||||
|
||||
PC = 0x0066;
|
||||
}
|
||||
|
||||
/* TODO: IM 0 emulation */
|
||||
|
||||
void PRNM(interrupt)(int data)
|
||||
{
|
||||
if(DANM(iff1)) {
|
||||
|
||||
DANM(haltstate) = 0;
|
||||
DANM(iff1) = DANM(iff2) = 0;
|
||||
|
||||
switch(DANM(it_mode)) {
|
||||
case 0:
|
||||
PRNM(pushpc)();
|
||||
PC = 0x0038;
|
||||
break;
|
||||
case 1:
|
||||
PRNM(pushpc)();
|
||||
PC = 0x0038;
|
||||
break;
|
||||
case 2:
|
||||
PRNM(pushpc)();
|
||||
PCL = DANM(mem)[(dbyte) (((int) RI << 8) + (data & 0xFF))];
|
||||
PCH = DANM(mem)[(dbyte) (((int) RI << 8) + (data & 0xFF) + 1)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PRNM(reset)(void)
|
||||
{
|
||||
DANM(haltstate) = 0;
|
||||
DANM(iff1) = DANM(iff2) = 0;
|
||||
DANM(it_mode) = 0;
|
||||
RI = 0;
|
||||
RR = 0;
|
||||
PC = 0;
|
||||
}
|
||||
193
apps/plugins/zxbox/z80.h
Normal file
193
apps/plugins/zxbox/z80.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Z80_H
|
||||
#define Z80_H
|
||||
|
||||
#include "zxconfig.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ROCKBOX_BIG_ENDIAN
|
||||
#define WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
#ifndef COMPARISON
|
||||
#define PRNM(x) z80_ ## x
|
||||
#else
|
||||
#define PRNM(x) z80x_ ## x
|
||||
#endif
|
||||
|
||||
#define DANM(x) PRNM(proc).x
|
||||
|
||||
#include "z80_type.h"
|
||||
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
union dregp {
|
||||
struct { byte l, h, _b2, _b3; } s;
|
||||
struct { dbyte d, _d1; } d;
|
||||
byte* p;
|
||||
};
|
||||
#else
|
||||
union dregp {
|
||||
struct { byte _b3, _b2, h, l; } s;
|
||||
struct { dbyte _d1, d; } d;
|
||||
byte* p;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define NUMDREGS 9
|
||||
#define BACKDREGS 4
|
||||
|
||||
#define PORTNUM 256
|
||||
|
||||
/* Do NOT change the order! */
|
||||
typedef struct {
|
||||
union dregp nr[NUMDREGS];
|
||||
union dregp br[BACKDREGS];
|
||||
|
||||
int haltstate;
|
||||
int it_mode;
|
||||
int iff1, iff2;
|
||||
|
||||
byte *mem;
|
||||
|
||||
int tc;
|
||||
int rl7;
|
||||
|
||||
#ifdef SPECT_MEM /* WARNING: Do NOT change the order!!! */
|
||||
int next_scri;
|
||||
int inport_mask;
|
||||
int ula_inport;
|
||||
int ula_outport;
|
||||
int sound_sam;
|
||||
int sound_change;
|
||||
int imp_change;
|
||||
#endif
|
||||
|
||||
#ifdef Z80C
|
||||
dbyte cbaddr;
|
||||
|
||||
#ifdef PROCP
|
||||
byte *incf_tbl;
|
||||
byte *decf_tbl;
|
||||
byte *addf_tbl;
|
||||
byte *subf_tbl;
|
||||
byte *orf_tbl;
|
||||
|
||||
byte *inports;
|
||||
byte *outports;
|
||||
#ifdef SPECT_MEM
|
||||
byte *fe_inport_high;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} Z80;
|
||||
|
||||
|
||||
extern Z80 PRNM(proc);
|
||||
|
||||
extern byte PRNM(inports)[];
|
||||
extern byte PRNM(outports)[];
|
||||
|
||||
#define ZI_BC 0
|
||||
#define ZI_DE 1
|
||||
#define ZI_HL 2
|
||||
#define ZI_AF 3
|
||||
#define ZI_IR 4
|
||||
#define ZI_IX 5
|
||||
#define ZI_IY 6
|
||||
#define ZI_PC 7
|
||||
#define ZI_SP 8
|
||||
|
||||
|
||||
#define BC (DANM(nr)[ZI_BC].d.d)
|
||||
#define DE (DANM(nr)[ZI_DE].d.d)
|
||||
#define HL (DANM(nr)[ZI_HL].d.d)
|
||||
#define AF (DANM(nr)[ZI_AF].d.d)
|
||||
#define IR (DANM(nr)[ZI_IR].d.d)
|
||||
#define IX (DANM(nr)[ZI_IX].d.d)
|
||||
#define IY (DANM(nr)[ZI_IY].d.d)
|
||||
#define PC (DANM(nr)[ZI_PC].d.d)
|
||||
#define SP (DANM(nr)[ZI_SP].d.d)
|
||||
|
||||
#define BCP (DANM(nr)[ZI_BC].p)
|
||||
#define DEP (DANM(nr)[ZI_DE].p)
|
||||
#define HLP (DANM(nr)[ZI_HL].p)
|
||||
#define PCP (DANM(nr)[ZI_PC].p)
|
||||
#define SPP (DANM(nr)[ZI_SP].p)
|
||||
#define IXP (DANM(nr)[ZI_IX].p)
|
||||
#define IYP (DANM(nr)[ZI_IY].p)
|
||||
|
||||
|
||||
#define RB (DANM(nr)[ZI_BC].s.h)
|
||||
#define RC (DANM(nr)[ZI_BC].s.l)
|
||||
#define RD (DANM(nr)[ZI_DE].s.h)
|
||||
#define RE (DANM(nr)[ZI_DE].s.l)
|
||||
#define RH (DANM(nr)[ZI_HL].s.h)
|
||||
#define RL (DANM(nr)[ZI_HL].s.l)
|
||||
#define RA (DANM(nr)[ZI_AF].s.h)
|
||||
#define RF (DANM(nr)[ZI_AF].s.l)
|
||||
#define RI (DANM(nr)[ZI_IR].s.h)
|
||||
#define RR (DANM(nr)[ZI_IR].s.l)
|
||||
#define XH (DANM(nr)[ZI_IX].s.h)
|
||||
#define XL (DANM(nr)[ZI_IX].s.l)
|
||||
#define YH (DANM(nr)[ZI_IY].s.h)
|
||||
#define YL (DANM(nr)[ZI_IY].s.l)
|
||||
#define PCH (DANM(nr)[ZI_PC].s.h)
|
||||
#define PCL (DANM(nr)[ZI_PC].s.l)
|
||||
#define SPH (DANM(nr)[ZI_SP].s.h)
|
||||
#define SPL (DANM(nr)[ZI_SP].s.l)
|
||||
|
||||
#define BCBK (DANM(br)[ZI_BC].d.d)
|
||||
#define DEBK (DANM(br)[ZI_DE].d.d)
|
||||
#define HLBK (DANM(br)[ZI_HL].d.d)
|
||||
#define AFBK (DANM(br)[ZI_AF].d.d)
|
||||
|
||||
#define BBK (DANM(br)[ZI_BC].s.h)
|
||||
#define CBK (DANM(br)[ZI_BC].s.l)
|
||||
#define DBK (DANM(br)[ZI_DE].s.h)
|
||||
#define EBK (DANM(br)[ZI_DE].s.l)
|
||||
#define HBK (DANM(br)[ZI_HL].s.h)
|
||||
#define LBK (DANM(br)[ZI_HL].s.l)
|
||||
#define ABK (DANM(br)[ZI_AF].s.h)
|
||||
#define FBK (DANM(br)[ZI_AF].s.l)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void PRNM(init)(void);
|
||||
extern int PRNM(step)(int ticknum);
|
||||
|
||||
extern void PRNM(interrupt)(int data);
|
||||
extern void PRNM(nmi)(void);
|
||||
extern void PRNM(reset)(void);
|
||||
|
||||
extern void PRNM(pushpc)(void);
|
||||
extern void PRNM(local_init)(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* Z80_H */
|
||||
88
apps/plugins/zxbox/z80_ari.h
Normal file
88
apps/plugins/zxbox/z80_ari.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 ADDSUB(r, op, tbl) \
|
||||
{ \
|
||||
register byte res; \
|
||||
register int idx; \
|
||||
register int flag; \
|
||||
res = RA op; \
|
||||
idx = IDXCALC(RA, r, res); \
|
||||
RA = res; \
|
||||
flag = (RF & ~(AALLF)) | \
|
||||
TAB(tbl)[idx]; \
|
||||
if(!res) flag |= ZF; \
|
||||
RF = flag; \
|
||||
}
|
||||
|
||||
|
||||
#define ADD(r) ADDSUB(r, + r, addf_tbl)
|
||||
#define ADC(r) ADDSUB(r, + r + (RF & CF), addf_tbl)
|
||||
#define SUB(r) ADDSUB(r, - r, subf_tbl)
|
||||
#define SBC(r) ADDSUB(r, - r - (RF & CF), subf_tbl)
|
||||
|
||||
#define AND(r) \
|
||||
{ \
|
||||
register byte res; \
|
||||
register byte flag; \
|
||||
res = RA & r; \
|
||||
RA = res; \
|
||||
flag = (RF & ~(AALLF)) | \
|
||||
TAB(orf_tbl)[res] | HF; \
|
||||
RF = flag; \
|
||||
}
|
||||
|
||||
|
||||
#define XOR(r) \
|
||||
{ \
|
||||
register byte res; \
|
||||
register byte flag; \
|
||||
res = RA ^ r; \
|
||||
RA = res; \
|
||||
flag = (RF & ~(AALLF)) | \
|
||||
TAB(orf_tbl)[res]; \
|
||||
RF = flag; \
|
||||
}
|
||||
|
||||
|
||||
#define OR(r) \
|
||||
{ \
|
||||
register byte res; \
|
||||
register byte flag; \
|
||||
res = RA | r; \
|
||||
RA = res; \
|
||||
flag = (RF & ~(AALLF)) | \
|
||||
TAB(orf_tbl)[res]; \
|
||||
RF = flag; \
|
||||
}
|
||||
|
||||
|
||||
#define CP(r) \
|
||||
{ \
|
||||
register byte res; \
|
||||
register int idx; \
|
||||
register int flag; \
|
||||
res = RA - r; \
|
||||
idx = IDXCALC(RA, r, res); \
|
||||
flag = (RF & ~(AALLF)) | \
|
||||
TAB(subf_tbl)[idx]; \
|
||||
if(!res) flag |= ZF; \
|
||||
RF = flag; \
|
||||
}
|
||||
165
apps/plugins/zxbox/z80_def.h
Normal file
165
apps/plugins/zxbox/z80_def.h
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "z80.h"
|
||||
|
||||
#ifdef PROCP
|
||||
|
||||
typedef Z80 *z80t;
|
||||
|
||||
#define OPDEF(name, num) z80t z80op_ ## name (z80t z80p)
|
||||
#define ENDOP() return z80p
|
||||
#undef DANM
|
||||
#define DANM(x) z80p->x
|
||||
|
||||
#define TAB(t) DANM(t)
|
||||
#define PORT(t) DANM(t)
|
||||
#define SPECP(t) DANM(t)
|
||||
|
||||
#else
|
||||
|
||||
typedef void z80t;
|
||||
|
||||
#define OPDEF(name, num) void z80op_ ## name (z80t)
|
||||
#define ENDOP()
|
||||
|
||||
#define TAB(t) z80c_ ## t
|
||||
#define PORT(t) PRNM(t)
|
||||
#define SPECP(t) SPNM(t)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef z80t (*op_f)(z80t);
|
||||
extern op_f z80c_op_tab[];
|
||||
extern op_f z80c_op_tab_cb[];
|
||||
extern op_f z80c_op_tab_dd[];
|
||||
extern op_f z80c_op_tab_ed[];
|
||||
extern op_f z80c_op_tab_fd[];
|
||||
|
||||
#define TIME(x) DANM(tc) -= (x)
|
||||
|
||||
#define ENTIME(x) { TIME(x); ENDOP(); }
|
||||
|
||||
#define READ(addr) (DANM(mem)[addr])
|
||||
#define WRITE(addr, val) PUTMEM(addr, DANM(mem) + (dbyte) (addr), val)
|
||||
|
||||
#define DREAD(addr) (DANM(mem)[addr] | (DANM(mem)[(dbyte)(addr+1)] << 8))
|
||||
#define DWRITE(addr, x) WRITE(addr, (byte) x); \
|
||||
WRITE((dbyte) (addr+1), (byte) (x >> 8))
|
||||
|
||||
#define IPCS ((sbyte) *PCP)
|
||||
|
||||
|
||||
#define MODMEM(func) \
|
||||
{ \
|
||||
register byte bdef; \
|
||||
bdef = *HLP; \
|
||||
func(bdef); \
|
||||
PUTMEM(HL, HLP, bdef); \
|
||||
}
|
||||
|
||||
#define MODMEMADDR(func, addr) \
|
||||
{ \
|
||||
register byte bdef; \
|
||||
bdef = READ(addr); \
|
||||
func(bdef); \
|
||||
WRITE(addr, bdef); \
|
||||
}
|
||||
|
||||
#define IXDGET(ixy, addr) addr = ((dbyte) (ixy + IPCS)), PC++
|
||||
|
||||
#define FETCHD(x) \
|
||||
{ \
|
||||
register dbyte ddef; \
|
||||
ddef = PC; \
|
||||
x = DREAD(ddef); \
|
||||
PC = ddef+2; \
|
||||
}
|
||||
|
||||
#define POP(x) \
|
||||
{ \
|
||||
register dbyte ddef; \
|
||||
ddef = SP; \
|
||||
x = DREAD(ddef); \
|
||||
SP = ddef+2; \
|
||||
}
|
||||
|
||||
#define PUSH(x) \
|
||||
{ \
|
||||
register dbyte ddef, dval; \
|
||||
dval = x; \
|
||||
ddef = SP-2; \
|
||||
DWRITE(ddef, dval); \
|
||||
SP = ddef; \
|
||||
}
|
||||
|
||||
#ifdef SPECT_MEM
|
||||
#include "sp_def.h"
|
||||
#else
|
||||
|
||||
#define PUTMEM(addr, ptr, val) *(ptr) = (val)
|
||||
#define IN(porth, portl, dest) dest = PORT(inports)[portl]
|
||||
#define OUT(porth, portl, source) PORT(outports)[portl] = (source)
|
||||
#define DI_CHECK
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define SF 0x80
|
||||
#define ZF 0x40
|
||||
#define B5F 0x20
|
||||
#define HF 0x10
|
||||
#define B3F 0x08
|
||||
#define PVF 0x04
|
||||
#define NF 0x02
|
||||
#define CF 0x01
|
||||
|
||||
#define ALLF (SF | ZF | HF | PVF | NF | CF)
|
||||
#define BUTCF (SF | ZF | HF | PVF | NF)
|
||||
|
||||
#define AALLF 0xff
|
||||
#define ABUTCF 0xfe
|
||||
|
||||
#define SETFLAGS(mask, val) (RF = (RF & ~(mask)) | (val))
|
||||
#define SET_FL(x) (RF |= (x))
|
||||
#define CLR_FL(x) (RF &= ~(x))
|
||||
|
||||
|
||||
#define TESTZF (RF & ZF)
|
||||
#define TESTCF (RF & CF)
|
||||
#define TESTSF (RF & SF)
|
||||
#define TESTPF (RF & PVF)
|
||||
#define TESTHF (RF & HF)
|
||||
#define TESTNF (RF & NF)
|
||||
|
||||
|
||||
#define IDXCALC(v1, v2, res) \
|
||||
((res & 0xA8) | ((v1 & 0x88) >> 1) | ((v2 & 0x88) >> 3))
|
||||
|
||||
#define DIDXCALC(v1, v2, res) \
|
||||
(((res & 0x8800) >> 8) | ((v1 & 0x8800) >> 9) | ((v2 & 0x8800) >> 11))
|
||||
|
||||
|
||||
extern byte z80c_incf_tbl[];
|
||||
extern byte z80c_decf_tbl[];
|
||||
extern byte z80c_addf_tbl[];
|
||||
extern byte z80c_subf_tbl[];
|
||||
extern byte z80c_orf_tbl[];
|
||||
376
apps/plugins/zxbox/z80_op1.c
Normal file
376
apps/plugins/zxbox/z80_op1.c
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op1.h"
|
||||
#endif
|
||||
|
||||
OPDEF(nop, 0x00)
|
||||
{
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(ex_af_afb, 0x08)
|
||||
{
|
||||
register byte *ptmp;
|
||||
|
||||
ptmp = DANM(br)[ZI_AF].p;
|
||||
DANM(br)[ZI_AF].p = DANM(nr)[ZI_AF].p;
|
||||
DANM(nr)[ZI_AF].p = ptmp;
|
||||
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(djnz_e, 0x10)
|
||||
{
|
||||
if(!--RB) {
|
||||
PC++;
|
||||
ENTIME(8);
|
||||
}
|
||||
else {
|
||||
PC += IPCS; PC++;
|
||||
ENTIME(13);
|
||||
}
|
||||
}
|
||||
|
||||
OPDEF(jr_e, 0x18)
|
||||
{
|
||||
PC += IPCS; PC++;
|
||||
ENTIME(12);
|
||||
}
|
||||
|
||||
#define JR_CC_E(ccn, cc, n) \
|
||||
OPDEF(jr_ ## ccn ## _e, 0x20+n*8) \
|
||||
{ \
|
||||
if(!(cc)) { \
|
||||
PC++; \
|
||||
ENTIME(7); \
|
||||
} \
|
||||
else { \
|
||||
PC += IPCS; PC++; \
|
||||
ENTIME(12); \
|
||||
} \
|
||||
}
|
||||
|
||||
JR_CC_E(nz, !TESTZF, 0)
|
||||
JR_CC_E(z, TESTZF, 1)
|
||||
JR_CC_E(nc, !TESTCF, 2)
|
||||
JR_CC_E(c, TESTCF, 3)
|
||||
|
||||
|
||||
#define LD_RR_NN(rrn, rr, n) \
|
||||
OPDEF(ld_ ## rrn ## _nn, 0x01+n*0x10) \
|
||||
{ \
|
||||
FETCHD(rr); \
|
||||
ENTIME(10); \
|
||||
}
|
||||
|
||||
LD_RR_NN(bc, BC, 0)
|
||||
LD_RR_NN(de, DE, 1)
|
||||
LD_RR_NN(hl, HL, 2)
|
||||
LD_RR_NN(sp, SP, 3)
|
||||
|
||||
#define DADD(rr1, rr2) \
|
||||
register dbyte dtmp; \
|
||||
register int idx; \
|
||||
dtmp = rr1; \
|
||||
rr1 = dtmp + rr2; \
|
||||
idx = DIDXCALC(dtmp, rr2, rr1); \
|
||||
SETFLAGS(CF | NF | HF, TAB(addf_tbl)[idx] & (CF | HF))
|
||||
|
||||
|
||||
#define ADD_RR_RR(rrn1, rr1, rrn2, rr2, n) \
|
||||
OPDEF(add_## rrn1 ## _ ## rrn2, 0x09+n*0x10) \
|
||||
{ \
|
||||
DADD(rr1, rr2); \
|
||||
ENTIME(11); \
|
||||
}
|
||||
|
||||
ADD_RR_RR(hl, HL, bc, BC, 0)
|
||||
ADD_RR_RR(hl, HL, de, DE, 1)
|
||||
ADD_RR_RR(hl, HL, hl, HL, 2)
|
||||
ADD_RR_RR(hl, HL, sp, SP, 3)
|
||||
|
||||
#define INC_RR(rrn, rr, n) \
|
||||
OPDEF(inc_ ## rrn, 0x03+n*0x10) \
|
||||
{ \
|
||||
rr++; \
|
||||
ENTIME(6); \
|
||||
}
|
||||
|
||||
INC_RR(bc, BC, 0)
|
||||
INC_RR(de, DE, 1)
|
||||
INC_RR(hl, HL, 2)
|
||||
INC_RR(sp, SP, 3)
|
||||
|
||||
#define DEC_RR(rrn, rr, n) \
|
||||
OPDEF(dec_ ## rrn, 0x0B+n*0x10) \
|
||||
{ \
|
||||
rr--; \
|
||||
ENTIME(6); \
|
||||
}
|
||||
|
||||
DEC_RR(bc, BC, 0)
|
||||
DEC_RR(de, DE, 1)
|
||||
DEC_RR(hl, HL, 2)
|
||||
DEC_RR(sp, SP, 3)
|
||||
|
||||
OPDEF(ld_ibc_a, 0x02)
|
||||
{
|
||||
PUTMEM(BC, BCP, RA);
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
OPDEF(ld_ide_a, 0x12)
|
||||
{
|
||||
PUTMEM(DE, DEP, RA);
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
#define LD_INN_RR(rrn, rr) \
|
||||
OPDEF(ld_inn_ ## rrn, 0x22) \
|
||||
{ \
|
||||
register dbyte dtmp; \
|
||||
FETCHD(dtmp); \
|
||||
DWRITE(dtmp, rr); \
|
||||
ENTIME(16); \
|
||||
}
|
||||
|
||||
LD_INN_RR(hl, HL)
|
||||
|
||||
|
||||
OPDEF(ld_inn_a, 0x32)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
FETCHD(dtmp);
|
||||
WRITE(dtmp, RA);
|
||||
ENTIME(13);
|
||||
}
|
||||
|
||||
OPDEF(ld_a_ibc, 0x0A)
|
||||
{
|
||||
RA = *BCP;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
OPDEF(ld_a_ide, 0x1A)
|
||||
{
|
||||
RA = *DEP;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
|
||||
#define LD_RR_INN(rrn, rr) \
|
||||
OPDEF(ld_ ## rrn ## _inn, 0x2A) \
|
||||
{ \
|
||||
register dbyte dtmp; \
|
||||
FETCHD(dtmp); \
|
||||
rr = DREAD(dtmp); \
|
||||
ENTIME(16); \
|
||||
}
|
||||
|
||||
LD_RR_INN(hl, HL)
|
||||
|
||||
|
||||
OPDEF(ld_a_inn, 0x3A)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
FETCHD(dtmp);
|
||||
RA = READ(dtmp);
|
||||
ENTIME(13);
|
||||
}
|
||||
|
||||
|
||||
#define INC(r) \
|
||||
r++; \
|
||||
SETFLAGS(SF | ZF | PVF | B3F | B5F, TAB(incf_tbl)[r])
|
||||
|
||||
|
||||
|
||||
#define INC_R(rn, r, n) \
|
||||
OPDEF(inc_ ## rn, 0x04+n*8) \
|
||||
{ \
|
||||
INC(r); \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
INC_R(b, RB, 0)
|
||||
INC_R(c, RC, 1)
|
||||
INC_R(d, RD, 2)
|
||||
INC_R(e, RE, 3)
|
||||
INC_R(h, RH, 4)
|
||||
INC_R(l, RL, 5)
|
||||
INC_R(a, RA, 7)
|
||||
|
||||
|
||||
OPDEF(inc_ihl, 0x34)
|
||||
{
|
||||
MODMEM(INC);
|
||||
ENTIME(11);
|
||||
}
|
||||
|
||||
|
||||
#define DEC(r) \
|
||||
r--; \
|
||||
SETFLAGS(SF | ZF | PVF | B3F | B5F, TAB(decf_tbl)[r])
|
||||
|
||||
|
||||
#define DEC_R(rn, r, n) \
|
||||
OPDEF(dec_ ## rn, 0x05+n*8) \
|
||||
{ \
|
||||
DEC(r); \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
DEC_R(b, RB, 0)
|
||||
DEC_R(c, RC, 1)
|
||||
DEC_R(d, RD, 2)
|
||||
DEC_R(e, RE, 3)
|
||||
DEC_R(h, RH, 4)
|
||||
DEC_R(l, RL, 5)
|
||||
DEC_R(a, RA, 7)
|
||||
|
||||
|
||||
OPDEF(dec_ihl, 0x35)
|
||||
{
|
||||
MODMEM(DEC);
|
||||
ENTIME(11);
|
||||
}
|
||||
|
||||
#define LD_R_N(rn, r, n) \
|
||||
OPDEF(ld_ ## rn ## _n, 0x06+n*8) \
|
||||
{ \
|
||||
r = *PCP; \
|
||||
PC++; \
|
||||
ENTIME(7); \
|
||||
}
|
||||
|
||||
LD_R_N(b, RB, 0)
|
||||
LD_R_N(c, RC, 1)
|
||||
LD_R_N(d, RD, 2)
|
||||
LD_R_N(e, RE, 3)
|
||||
LD_R_N(h, RH, 4)
|
||||
LD_R_N(l, RL, 5)
|
||||
LD_R_N(a, RA, 7)
|
||||
|
||||
|
||||
OPDEF(ld_ihl_n, 0x36)
|
||||
{
|
||||
PUTMEM(HL, HLP, *PCP);
|
||||
PC++;
|
||||
ENTIME(10);
|
||||
}
|
||||
|
||||
OPDEF(rlca, 0x07)
|
||||
{
|
||||
register byte btmp;
|
||||
btmp = (RA & 0x80) >> 7;
|
||||
SETFLAGS(HF | NF | CF, btmp);
|
||||
RA = (RA << 1) | btmp;
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(rrca, 0x0F)
|
||||
{
|
||||
register byte btmp;
|
||||
btmp = (RA & 0x01);
|
||||
SETFLAGS(HF | NF | CF, btmp);
|
||||
if(btmp) {
|
||||
RA = (RA >> 1) | 0x80;
|
||||
ENTIME(4);
|
||||
}
|
||||
else {
|
||||
RA >>= 1;
|
||||
ENTIME(4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OPDEF(rla, 0x17)
|
||||
{
|
||||
register byte btmp;
|
||||
btmp = RA & 0x80;
|
||||
RA = (RA << 1) | (RF & CF);
|
||||
SETFLAGS(HF | NF | CF, btmp >> 7);
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(rra, 0x1F)
|
||||
{
|
||||
register byte btmp;
|
||||
btmp = TESTCF;
|
||||
SETFLAGS(HF | NF | CF, RA & 0x01);
|
||||
if(btmp) {
|
||||
RA = (RA >> 1) | 0x80;
|
||||
ENTIME(4);
|
||||
}
|
||||
else {
|
||||
RA >>= 1;
|
||||
ENTIME(4);
|
||||
}
|
||||
}
|
||||
|
||||
OPDEF(daa, 0x27)
|
||||
{
|
||||
register int flag;
|
||||
flag = RF;
|
||||
|
||||
if(!TESTNF) {
|
||||
if(flag & CF) RA += 0x60;
|
||||
else if(RA > 0x99) RA += 0x60, flag |= CF;
|
||||
|
||||
if(flag & HF) RA += 0x06;
|
||||
else if((RA & 0x0F) > 9) RA += 0x06, flag |= HF;
|
||||
}
|
||||
else {
|
||||
if(flag & CF) RA -= 0x60;
|
||||
else if(RA > 0x99) RA -= 0x60, flag |= CF;
|
||||
|
||||
if(flag & HF) RA -= 0x06;
|
||||
else if((RA & 0x0F) > 9) RA -= 0x06, flag |= HF;
|
||||
}
|
||||
flag = (flag & ~(SF | ZF | PVF | B3F | B5F)) | TAB(orf_tbl)[RA];
|
||||
RF = flag;
|
||||
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(cpl, 0x2F)
|
||||
{
|
||||
RA = ~RA;
|
||||
SET_FL(HF | NF);
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(scf, 0x37)
|
||||
{
|
||||
SETFLAGS(HF | NF, CF);
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(ccf, 0x3F)
|
||||
{
|
||||
RF = (RF ^ CF) & ~(NF);
|
||||
/* HF undefined */
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
#include "z80_op1x.c"
|
||||
130
apps/plugins/zxbox/z80_op1.h
Normal file
130
apps/plugins/zxbox/z80_op1.h
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_nop(z80t);
|
||||
extern z80t z80op_ld_bc_nn(z80t);
|
||||
extern z80t z80op_ld_ibc_a(z80t);
|
||||
extern z80t z80op_inc_bc(z80t);
|
||||
extern z80t z80op_inc_b(z80t);
|
||||
extern z80t z80op_dec_b(z80t);
|
||||
extern z80t z80op_ld_b_n(z80t);
|
||||
extern z80t z80op_rlca(z80t);
|
||||
extern z80t z80op_ex_af_afb(z80t);
|
||||
extern z80t z80op_add_hl_bc(z80t);
|
||||
extern z80t z80op_ld_a_ibc(z80t);
|
||||
extern z80t z80op_dec_bc(z80t);
|
||||
extern z80t z80op_inc_c(z80t);
|
||||
extern z80t z80op_dec_c(z80t);
|
||||
extern z80t z80op_ld_c_n(z80t);
|
||||
extern z80t z80op_rrca(z80t);
|
||||
|
||||
extern z80t z80op_djnz_e(z80t);
|
||||
extern z80t z80op_ld_de_nn(z80t);
|
||||
extern z80t z80op_ld_ide_a(z80t);
|
||||
extern z80t z80op_inc_de(z80t);
|
||||
extern z80t z80op_inc_d(z80t);
|
||||
extern z80t z80op_dec_d(z80t);
|
||||
extern z80t z80op_ld_d_n(z80t);
|
||||
extern z80t z80op_rla(z80t);
|
||||
extern z80t z80op_jr_e(z80t);
|
||||
extern z80t z80op_add_hl_de(z80t);
|
||||
extern z80t z80op_ld_a_ide(z80t);
|
||||
extern z80t z80op_dec_de(z80t);
|
||||
extern z80t z80op_inc_e(z80t);
|
||||
extern z80t z80op_dec_e(z80t);
|
||||
extern z80t z80op_ld_e_n(z80t);
|
||||
extern z80t z80op_rra(z80t);
|
||||
|
||||
extern z80t z80op_jr_nz_e(z80t);
|
||||
extern z80t z80op_ld_hl_nn(z80t);
|
||||
extern z80t z80op_ld_inn_hl(z80t);
|
||||
extern z80t z80op_inc_hl(z80t);
|
||||
extern z80t z80op_inc_h(z80t);
|
||||
extern z80t z80op_dec_h(z80t);
|
||||
extern z80t z80op_ld_h_n(z80t);
|
||||
extern z80t z80op_daa(z80t);
|
||||
extern z80t z80op_jr_z_e(z80t);
|
||||
extern z80t z80op_add_hl_hl(z80t);
|
||||
extern z80t z80op_ld_hl_inn(z80t);
|
||||
extern z80t z80op_dec_hl(z80t);
|
||||
extern z80t z80op_inc_l(z80t);
|
||||
extern z80t z80op_dec_l(z80t);
|
||||
extern z80t z80op_ld_l_n(z80t);
|
||||
extern z80t z80op_cpl(z80t);
|
||||
|
||||
extern z80t z80op_jr_nc_e(z80t);
|
||||
extern z80t z80op_ld_sp_nn(z80t);
|
||||
extern z80t z80op_ld_inn_a(z80t);
|
||||
extern z80t z80op_inc_sp(z80t);
|
||||
extern z80t z80op_inc_ihl(z80t);
|
||||
extern z80t z80op_dec_ihl(z80t);
|
||||
extern z80t z80op_ld_ihl_n(z80t);
|
||||
extern z80t z80op_scf(z80t);
|
||||
extern z80t z80op_jr_c_e(z80t);
|
||||
extern z80t z80op_add_hl_sp(z80t);
|
||||
extern z80t z80op_ld_a_inn(z80t);
|
||||
extern z80t z80op_dec_sp(z80t);
|
||||
extern z80t z80op_inc_a(z80t);
|
||||
extern z80t z80op_dec_a(z80t);
|
||||
extern z80t z80op_ld_a_n(z80t);
|
||||
extern z80t z80op_ccf(z80t);
|
||||
|
||||
/* IX */
|
||||
|
||||
extern z80t z80op_add_ix_bc(z80t);
|
||||
extern z80t z80op_add_ix_de(z80t);
|
||||
extern z80t z80op_add_ix_ix(z80t);
|
||||
extern z80t z80op_add_ix_sp(z80t);
|
||||
extern z80t z80op_ld_ix_nn(z80t);
|
||||
extern z80t z80op_ld_inn_ix(z80t);
|
||||
extern z80t z80op_ld_ix_inn(z80t);
|
||||
extern z80t z80op_inc_ix(z80t);
|
||||
extern z80t z80op_dec_ix(z80t);
|
||||
extern z80t z80op_inc_ixh(z80t);
|
||||
extern z80t z80op_inc_ixl(z80t);
|
||||
extern z80t z80op_inc_iixd(z80t);
|
||||
extern z80t z80op_dec_ixh(z80t);
|
||||
extern z80t z80op_dec_ixl(z80t);
|
||||
extern z80t z80op_dec_iixd(z80t);
|
||||
extern z80t z80op_ld_ixh_n(z80t);
|
||||
extern z80t z80op_ld_ixl_n(z80t);
|
||||
extern z80t z80op_ld_iixd_n(z80t);
|
||||
|
||||
/* IY */
|
||||
|
||||
extern z80t z80op_add_iy_bc(z80t);
|
||||
extern z80t z80op_add_iy_de(z80t);
|
||||
extern z80t z80op_add_iy_iy(z80t);
|
||||
extern z80t z80op_add_iy_sp(z80t);
|
||||
extern z80t z80op_ld_iy_nn(z80t);
|
||||
extern z80t z80op_ld_inn_iy(z80t);
|
||||
extern z80t z80op_ld_iy_inn(z80t);
|
||||
extern z80t z80op_inc_iy(z80t);
|
||||
extern z80t z80op_dec_iy(z80t);
|
||||
extern z80t z80op_inc_iyh(z80t);
|
||||
extern z80t z80op_inc_iyl(z80t);
|
||||
extern z80t z80op_inc_iiyd(z80t);
|
||||
extern z80t z80op_dec_iyh(z80t);
|
||||
extern z80t z80op_dec_iyl(z80t);
|
||||
extern z80t z80op_dec_iiyd(z80t);
|
||||
extern z80t z80op_ld_iyh_n(z80t);
|
||||
extern z80t z80op_ld_iyl_n(z80t);
|
||||
extern z80t z80op_ld_iiyd_n(z80t);
|
||||
|
||||
125
apps/plugins/zxbox/z80_op1x.c
Normal file
125
apps/plugins/zxbox/z80_op1x.c
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* IX */
|
||||
|
||||
LD_RR_NN(ix, IX, 2)
|
||||
|
||||
ADD_RR_RR(ix, IX, bc, BC, 0)
|
||||
ADD_RR_RR(ix, IX, de, DE, 1)
|
||||
ADD_RR_RR(ix, IX, ix, IX, 2)
|
||||
ADD_RR_RR(ix, IX, sp, SP, 3)
|
||||
|
||||
INC_RR(ix, IX, 2)
|
||||
|
||||
DEC_RR(ix, IX, 2)
|
||||
|
||||
LD_INN_RR(ix, IX)
|
||||
|
||||
LD_RR_INN(ix, IX)
|
||||
|
||||
INC_R(ixh, XH, 4)
|
||||
INC_R(ixl, XL, 5)
|
||||
|
||||
OPDEF(inc_iixd, 0x34)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IX, addr);
|
||||
MODMEMADDR(INC, addr);
|
||||
ENTIME(19);
|
||||
}
|
||||
|
||||
DEC_R(ixh, XH, 4)
|
||||
DEC_R(ixl, XL, 5)
|
||||
|
||||
OPDEF(dec_iixd, 0x35)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IX, addr);
|
||||
MODMEMADDR(DEC, addr);
|
||||
ENTIME(19);
|
||||
}
|
||||
|
||||
|
||||
LD_R_N(ixh, XH, 4)
|
||||
LD_R_N(ixl, XL, 5)
|
||||
|
||||
OPDEF(ld_iixd_n, 0x36)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IX, addr);
|
||||
WRITE(addr, READ(PC));
|
||||
PC++;
|
||||
ENTIME(15);
|
||||
}
|
||||
|
||||
|
||||
/* IY */
|
||||
|
||||
LD_RR_NN(iy, IY, 2)
|
||||
|
||||
ADD_RR_RR(iy, IY, bc, BC, 0)
|
||||
ADD_RR_RR(iy, IY, de, DE, 1)
|
||||
ADD_RR_RR(iy, IY, iy, IY, 2)
|
||||
ADD_RR_RR(iy, IY, sp, SP, 3)
|
||||
|
||||
INC_RR(iy, IY, 2)
|
||||
|
||||
DEC_RR(iy, IY, 2)
|
||||
|
||||
LD_INN_RR(iy, IY)
|
||||
|
||||
LD_RR_INN(iy, IY)
|
||||
|
||||
INC_R(iyh, YH, 4)
|
||||
INC_R(iyl, YL, 5)
|
||||
|
||||
OPDEF(inc_iiyd, 0x34)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IY, addr);
|
||||
MODMEMADDR(INC, addr);
|
||||
ENTIME(19);
|
||||
}
|
||||
|
||||
DEC_R(iyh, YH, 4)
|
||||
DEC_R(iyl, YL, 5)
|
||||
|
||||
OPDEF(dec_iiyd, 0x35)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IY, addr);
|
||||
MODMEMADDR(DEC, addr);
|
||||
ENTIME(19);
|
||||
}
|
||||
|
||||
|
||||
LD_R_N(iyh, YH, 4)
|
||||
LD_R_N(iyl, YL, 5)
|
||||
|
||||
OPDEF(ld_iiyd_n, 0x36)
|
||||
{
|
||||
register dbyte addr;
|
||||
IXDGET(IY, addr);
|
||||
WRITE(addr, READ(PC));
|
||||
PC++;
|
||||
ENTIME(15);
|
||||
}
|
||||
|
||||
165
apps/plugins/zxbox/z80_op2.c
Normal file
165
apps/plugins/zxbox/z80_op2.c
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op2.h"
|
||||
#endif
|
||||
|
||||
OPDEF(halt, 0x76)
|
||||
{
|
||||
register int nn;
|
||||
|
||||
DANM(haltstate) = 1;
|
||||
nn = (DANM(tc) - 1) / 4 + 1;
|
||||
|
||||
DANM(tc) -= 4 * nn;
|
||||
RR += nn-1;
|
||||
ENDOP();
|
||||
}
|
||||
|
||||
#define LD_R_R(rdn, rsn, rd, rs, n1, n2) \
|
||||
OPDEF(ld_ ## rdn ## _ ## rsn, 0x40 + n1 * 8 + n2) \
|
||||
{ \
|
||||
rd = rs; \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#define LD_NOOP(rsd, n) \
|
||||
OPDEF(ld_ ## rsd ## _ ## rsd, 0x40 + n * 8 + n) \
|
||||
{ \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
LD_NOOP(b, 0)
|
||||
LD_NOOP(c, 1)
|
||||
LD_NOOP(d, 2)
|
||||
LD_NOOP(e, 3)
|
||||
LD_NOOP(h, 4)
|
||||
LD_NOOP(l, 5)
|
||||
LD_NOOP(a, 7)
|
||||
|
||||
#endif
|
||||
|
||||
LD_R_R(b, c, RB, RC, 0, 1)
|
||||
LD_R_R(b, d, RB, RD, 0, 2)
|
||||
LD_R_R(b, e, RB, RE, 0, 3)
|
||||
LD_R_R(b, h, RB, RH, 0, 4)
|
||||
LD_R_R(b, l, RB, RL, 0, 5)
|
||||
LD_R_R(b, a, RB, RA, 0, 7)
|
||||
|
||||
LD_R_R(c, b, RC, RB, 1, 0)
|
||||
LD_R_R(c, d, RC, RD, 1, 2)
|
||||
LD_R_R(c, e, RC, RE, 1, 3)
|
||||
LD_R_R(c, h, RC, RH, 1, 4)
|
||||
LD_R_R(c, l, RC, RL, 1, 5)
|
||||
LD_R_R(c, a, RC, RA, 1, 7)
|
||||
|
||||
LD_R_R(d, b, RD, RB, 2, 0)
|
||||
LD_R_R(d, c, RD, RC, 2, 1)
|
||||
LD_R_R(d, e, RD, RE, 2, 3)
|
||||
LD_R_R(d, h, RD, RH, 2, 4)
|
||||
LD_R_R(d, l, RD, RL, 2, 5)
|
||||
LD_R_R(d, a, RD, RA, 2, 7)
|
||||
|
||||
|
||||
LD_R_R(e, b, RE, RB, 3, 0)
|
||||
LD_R_R(e, c, RE, RC, 3, 1)
|
||||
LD_R_R(e, d, RE, RD, 3, 2)
|
||||
LD_R_R(e, h, RE, RH, 3, 4)
|
||||
LD_R_R(e, l, RE, RL, 3, 5)
|
||||
LD_R_R(e, a, RE, RA, 3, 7)
|
||||
|
||||
LD_R_R(h, b, RH, RB, 4, 0)
|
||||
LD_R_R(h, c, RH, RC, 4, 1)
|
||||
LD_R_R(h, d, RH, RD, 4, 2)
|
||||
LD_R_R(h, e, RH, RE, 4, 3)
|
||||
LD_R_R(h, l, RH, RL, 4, 5)
|
||||
LD_R_R(h, a, RH, RA, 4, 7)
|
||||
|
||||
LD_R_R(l, b, RL, RB, 5, 0)
|
||||
LD_R_R(l, c, RL, RC, 5, 1)
|
||||
LD_R_R(l, d, RL, RD, 5, 2)
|
||||
LD_R_R(l, e, RL, RE, 5, 3)
|
||||
LD_R_R(l, h, RL, RH, 5, 4)
|
||||
LD_R_R(l, a, RL, RA, 5, 7)
|
||||
|
||||
LD_R_R(a, b, RA, RB, 7, 0)
|
||||
LD_R_R(a, c, RA, RC, 7, 1)
|
||||
LD_R_R(a, d, RA, RD, 7, 2)
|
||||
LD_R_R(a, e, RA, RE, 7, 3)
|
||||
LD_R_R(a, h, RA, RH, 7, 4)
|
||||
LD_R_R(a, l, RA, RL, 7, 5)
|
||||
|
||||
|
||||
#define LD_R_IHL(rdn, rd, n) \
|
||||
OPDEF(ld_ ## rdn ## _ihl, 0x46+n*8) \
|
||||
{ \
|
||||
rd = *HLP; \
|
||||
ENTIME(7); \
|
||||
}
|
||||
|
||||
#define LD_R_ID(ixyn, ixy, rsn, rs, n) \
|
||||
OPDEF(ld_ ## rsn ## _i ## ixyn ## d, 0x46+n*8) \
|
||||
{ \
|
||||
register dbyte addr; \
|
||||
IXDGET(ixy, addr); \
|
||||
rs = READ(addr); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
|
||||
LD_R_IHL(b, RB, 0)
|
||||
LD_R_IHL(c, RC, 1)
|
||||
LD_R_IHL(d, RD, 2)
|
||||
LD_R_IHL(e, RE, 3)
|
||||
LD_R_IHL(h, RH, 4)
|
||||
LD_R_IHL(l, RL, 5)
|
||||
LD_R_IHL(a, RA, 7)
|
||||
|
||||
#define LD_IHL_R(rsn, rs, n) \
|
||||
OPDEF(ld_ihl_ ## rsn, 0x70+n) \
|
||||
{ \
|
||||
PUTMEM(HL, HLP, rs); \
|
||||
ENTIME(7); \
|
||||
}
|
||||
|
||||
#define LD_ID_R(ixyn, ixy, rsn, rs, n) \
|
||||
OPDEF(ld_i ## ixyn ## d_ ## rsn, 0x70+n) \
|
||||
{ \
|
||||
register dbyte addr; \
|
||||
IXDGET(ixy, addr); \
|
||||
WRITE(addr, rs); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
LD_IHL_R(b, RB, 0)
|
||||
LD_IHL_R(c, RC, 1)
|
||||
LD_IHL_R(d, RD, 2)
|
||||
LD_IHL_R(e, RE, 3)
|
||||
LD_IHL_R(h, RH, 4)
|
||||
LD_IHL_R(l, RL, 5)
|
||||
LD_IHL_R(a, RA, 7)
|
||||
|
||||
#include "z80_op2x.c"
|
||||
188
apps/plugins/zxbox/z80_op2.h
Normal file
188
apps/plugins/zxbox/z80_op2.h
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_b_c(z80t);
|
||||
extern z80t z80op_ld_b_d(z80t);
|
||||
extern z80t z80op_ld_b_e(z80t);
|
||||
extern z80t z80op_ld_b_h(z80t);
|
||||
extern z80t z80op_ld_b_l(z80t);
|
||||
extern z80t z80op_ld_b_ihl(z80t);
|
||||
extern z80t z80op_ld_b_a(z80t);
|
||||
extern z80t z80op_ld_c_b(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_c_d(z80t);
|
||||
extern z80t z80op_ld_c_e(z80t);
|
||||
extern z80t z80op_ld_c_h(z80t);
|
||||
extern z80t z80op_ld_c_l(z80t);
|
||||
extern z80t z80op_ld_c_ihl(z80t);
|
||||
extern z80t z80op_ld_c_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_d_b(z80t);
|
||||
extern z80t z80op_ld_d_c(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_d_e(z80t);
|
||||
extern z80t z80op_ld_d_h(z80t);
|
||||
extern z80t z80op_ld_d_l(z80t);
|
||||
extern z80t z80op_ld_d_ihl(z80t);
|
||||
extern z80t z80op_ld_d_a(z80t);
|
||||
extern z80t z80op_ld_e_b(z80t);
|
||||
extern z80t z80op_ld_e_c(z80t);
|
||||
extern z80t z80op_ld_e_d(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_e_h(z80t);
|
||||
extern z80t z80op_ld_e_l(z80t);
|
||||
extern z80t z80op_ld_e_ihl(z80t);
|
||||
extern z80t z80op_ld_e_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_h_b(z80t);
|
||||
extern z80t z80op_ld_h_c(z80t);
|
||||
extern z80t z80op_ld_h_d(z80t);
|
||||
extern z80t z80op_ld_h_e(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_h_l(z80t);
|
||||
extern z80t z80op_ld_h_ihl(z80t);
|
||||
extern z80t z80op_ld_h_a(z80t);
|
||||
extern z80t z80op_ld_l_b(z80t);
|
||||
extern z80t z80op_ld_l_c(z80t);
|
||||
extern z80t z80op_ld_l_d(z80t);
|
||||
extern z80t z80op_ld_l_e(z80t);
|
||||
extern z80t z80op_ld_l_h(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
extern z80t z80op_ld_l_ihl(z80t);
|
||||
extern z80t z80op_ld_l_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_ihl_b(z80t);
|
||||
extern z80t z80op_ld_ihl_c(z80t);
|
||||
extern z80t z80op_ld_ihl_d(z80t);
|
||||
extern z80t z80op_ld_ihl_e(z80t);
|
||||
extern z80t z80op_ld_ihl_h(z80t);
|
||||
extern z80t z80op_ld_ihl_l(z80t);
|
||||
extern z80t z80op_halt(z80t);
|
||||
extern z80t z80op_ld_ihl_a(z80t);
|
||||
extern z80t z80op_ld_a_b(z80t);
|
||||
extern z80t z80op_ld_a_c(z80t);
|
||||
extern z80t z80op_ld_a_d(z80t);
|
||||
extern z80t z80op_ld_a_e(z80t);
|
||||
extern z80t z80op_ld_a_h(z80t);
|
||||
extern z80t z80op_ld_a_l(z80t);
|
||||
extern z80t z80op_ld_a_ihl(z80t);
|
||||
/* extern z80t z80op_nop(z80t); */
|
||||
|
||||
|
||||
/* IX */
|
||||
|
||||
extern z80t z80op_ld_b_ixh(z80t);
|
||||
extern z80t z80op_ld_b_ixl(z80t);
|
||||
|
||||
extern z80t z80op_ld_c_ixh(z80t);
|
||||
extern z80t z80op_ld_c_ixl(z80t);
|
||||
|
||||
extern z80t z80op_ld_d_ixh(z80t);
|
||||
extern z80t z80op_ld_d_ixl(z80t);
|
||||
|
||||
extern z80t z80op_ld_e_ixh(z80t);
|
||||
extern z80t z80op_ld_e_ixl(z80t);
|
||||
|
||||
extern z80t z80op_ld_ixh_b(z80t);
|
||||
extern z80t z80op_ld_ixh_c(z80t);
|
||||
extern z80t z80op_ld_ixh_d(z80t);
|
||||
extern z80t z80op_ld_ixh_e(z80t);
|
||||
/* extern z80t z80op_ld_ixh_ixh(z80t); */
|
||||
extern z80t z80op_ld_ixh_ixl(z80t);
|
||||
extern z80t z80op_ld_ixh_a(z80t);
|
||||
|
||||
|
||||
extern z80t z80op_ld_ixl_b(z80t);
|
||||
extern z80t z80op_ld_ixl_c(z80t);
|
||||
extern z80t z80op_ld_ixl_d(z80t);
|
||||
extern z80t z80op_ld_ixl_e(z80t);
|
||||
extern z80t z80op_ld_ixl_ixh(z80t);
|
||||
/* extern z80t z80op_ld_ixl_ixl(z80t); */
|
||||
extern z80t z80op_ld_ixl_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_a_ixh(z80t);
|
||||
extern z80t z80op_ld_a_ixl(z80t);
|
||||
|
||||
extern z80t z80op_ld_iixd_b(z80t);
|
||||
extern z80t z80op_ld_iixd_c(z80t);
|
||||
extern z80t z80op_ld_iixd_d(z80t);
|
||||
extern z80t z80op_ld_iixd_e(z80t);
|
||||
extern z80t z80op_ld_iixd_h(z80t);
|
||||
extern z80t z80op_ld_iixd_l(z80t);
|
||||
extern z80t z80op_ld_iixd_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_b_iixd(z80t);
|
||||
extern z80t z80op_ld_c_iixd(z80t);
|
||||
extern z80t z80op_ld_d_iixd(z80t);
|
||||
extern z80t z80op_ld_e_iixd(z80t);
|
||||
extern z80t z80op_ld_h_iixd(z80t);
|
||||
extern z80t z80op_ld_l_iixd(z80t);
|
||||
extern z80t z80op_ld_a_iixd(z80t);
|
||||
|
||||
/* IY */
|
||||
|
||||
extern z80t z80op_ld_b_iyh(z80t);
|
||||
extern z80t z80op_ld_b_iyl(z80t);
|
||||
|
||||
extern z80t z80op_ld_c_iyh(z80t);
|
||||
extern z80t z80op_ld_c_iyl(z80t);
|
||||
|
||||
extern z80t z80op_ld_d_iyh(z80t);
|
||||
extern z80t z80op_ld_d_iyl(z80t);
|
||||
|
||||
extern z80t z80op_ld_e_iyh(z80t);
|
||||
extern z80t z80op_ld_e_iyl(z80t);
|
||||
|
||||
extern z80t z80op_ld_iyh_b(z80t);
|
||||
extern z80t z80op_ld_iyh_c(z80t);
|
||||
extern z80t z80op_ld_iyh_d(z80t);
|
||||
extern z80t z80op_ld_iyh_e(z80t);
|
||||
/* extern z80t z80op_ld_iyh_iyh(z80t); */
|
||||
extern z80t z80op_ld_iyh_iyl(z80t);
|
||||
extern z80t z80op_ld_iyh_a(z80t);
|
||||
|
||||
|
||||
extern z80t z80op_ld_iyl_b(z80t);
|
||||
extern z80t z80op_ld_iyl_c(z80t);
|
||||
extern z80t z80op_ld_iyl_d(z80t);
|
||||
extern z80t z80op_ld_iyl_e(z80t);
|
||||
extern z80t z80op_ld_iyl_iyh(z80t);
|
||||
/* extern z80t z80op_ld_iyl_iyl(z80t); */
|
||||
extern z80t z80op_ld_iyl_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_a_iyh(z80t);
|
||||
extern z80t z80op_ld_a_iyl(z80t);
|
||||
|
||||
extern z80t z80op_ld_iiyd_b(z80t);
|
||||
extern z80t z80op_ld_iiyd_c(z80t);
|
||||
extern z80t z80op_ld_iiyd_d(z80t);
|
||||
extern z80t z80op_ld_iiyd_e(z80t);
|
||||
extern z80t z80op_ld_iiyd_h(z80t);
|
||||
extern z80t z80op_ld_iiyd_l(z80t);
|
||||
extern z80t z80op_ld_iiyd_a(z80t);
|
||||
|
||||
extern z80t z80op_ld_b_iiyd(z80t);
|
||||
extern z80t z80op_ld_c_iiyd(z80t);
|
||||
extern z80t z80op_ld_d_iiyd(z80t);
|
||||
extern z80t z80op_ld_e_iiyd(z80t);
|
||||
extern z80t z80op_ld_h_iiyd(z80t);
|
||||
extern z80t z80op_ld_l_iiyd(z80t);
|
||||
extern z80t z80op_ld_a_iiyd(z80t);
|
||||
116
apps/plugins/zxbox/z80_op2x.c
Normal file
116
apps/plugins/zxbox/z80_op2x.c
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* IX */
|
||||
|
||||
LD_R_R(b, ixh, RB, XH, 0, 4)
|
||||
LD_R_R(b, ixl, RB, XL, 0, 5)
|
||||
|
||||
LD_R_R(c, ixh, RC, XH, 1, 4)
|
||||
LD_R_R(c, ixl, RC, XL, 1, 5)
|
||||
|
||||
LD_R_R(d, ixh, RD, XH, 2, 4)
|
||||
LD_R_R(d, ixl, RD, XL, 2, 5)
|
||||
|
||||
LD_R_R(e, ixh, RE, XH, 3, 4)
|
||||
LD_R_R(e, ixl, RE, XL, 3, 5)
|
||||
|
||||
LD_R_R(ixh, b, XH, RB, 4, 0)
|
||||
LD_R_R(ixh, c, XH, RC, 4, 1)
|
||||
LD_R_R(ixh, d, XH, RD, 4, 2)
|
||||
LD_R_R(ixh, e, XH, RE, 4, 3)
|
||||
LD_R_R(ixh, ixl, XH, XL, 4, 5)
|
||||
LD_R_R(ixh, a, XH, RA, 4, 7)
|
||||
|
||||
LD_R_R(ixl, b, XL, RB, 5, 0)
|
||||
LD_R_R(ixl, c, XL, RC, 5, 1)
|
||||
LD_R_R(ixl, d, XL, RD, 5, 2)
|
||||
LD_R_R(ixl, e, XL, RE, 5, 3)
|
||||
LD_R_R(ixl, ixh, XL, XH, 5, 4)
|
||||
LD_R_R(ixl, a, XL, RA, 5, 7)
|
||||
|
||||
|
||||
LD_R_R(a, ixh, RA, XH, 7, 4)
|
||||
LD_R_R(a, ixl, RA, XL, 7, 5)
|
||||
|
||||
LD_ID_R(ix, IX, b, RB, 0)
|
||||
LD_ID_R(ix, IX, c, RC, 1)
|
||||
LD_ID_R(ix, IX, d, RD, 2)
|
||||
LD_ID_R(ix, IX, e, RE, 3)
|
||||
LD_ID_R(ix, IX, h, RH, 4)
|
||||
LD_ID_R(ix, IX, l, RL, 5)
|
||||
LD_ID_R(ix, IX, a, RA, 6)
|
||||
|
||||
LD_R_ID(ix, IX, b, RB, 0)
|
||||
LD_R_ID(ix, IX, c, RC, 1)
|
||||
LD_R_ID(ix, IX, d, RD, 2)
|
||||
LD_R_ID(ix, IX, e, RE, 3)
|
||||
LD_R_ID(ix, IX, h, RH, 4)
|
||||
LD_R_ID(ix, IX, l, RL, 5)
|
||||
LD_R_ID(ix, IX, a, RA, 6)
|
||||
|
||||
|
||||
/* IY */
|
||||
|
||||
LD_R_R(b, iyh, RB, YH, 0, 4)
|
||||
LD_R_R(b, iyl, RB, YL, 0, 5)
|
||||
|
||||
LD_R_R(c, iyh, RC, YH, 1, 4)
|
||||
LD_R_R(c, iyl, RC, YL, 1, 5)
|
||||
|
||||
LD_R_R(d, iyh, RD, YH, 2, 4)
|
||||
LD_R_R(d, iyl, RD, YL, 2, 5)
|
||||
|
||||
LD_R_R(e, iyh, RE, YH, 3, 4)
|
||||
LD_R_R(e, iyl, RE, YL, 3, 5)
|
||||
|
||||
LD_R_R(iyh, b, YH, RB, 4, 0)
|
||||
LD_R_R(iyh, c, YH, RC, 4, 1)
|
||||
LD_R_R(iyh, d, YH, RD, 4, 2)
|
||||
LD_R_R(iyh, e, YH, RE, 4, 3)
|
||||
LD_R_R(iyh, iyl, YH, YL, 4, 5)
|
||||
LD_R_R(iyh, a, YH, RA, 4, 7)
|
||||
|
||||
LD_R_R(iyl, b, YL, RB, 5, 0)
|
||||
LD_R_R(iyl, c, YL, RC, 5, 1)
|
||||
LD_R_R(iyl, d, YL, RD, 5, 2)
|
||||
LD_R_R(iyl, e, YL, RE, 5, 3)
|
||||
LD_R_R(iyl, iyh, YL, YH, 5, 4)
|
||||
LD_R_R(iyl, a, YL, RA, 5, 7)
|
||||
|
||||
|
||||
LD_R_R(a, iyh, RA, YH, 7, 4)
|
||||
LD_R_R(a, iyl, RA, YL, 7, 5)
|
||||
|
||||
LD_ID_R(iy, IY, b, RB, 0)
|
||||
LD_ID_R(iy, IY, c, RC, 1)
|
||||
LD_ID_R(iy, IY, d, RD, 2)
|
||||
LD_ID_R(iy, IY, e, RE, 3)
|
||||
LD_ID_R(iy, IY, h, RH, 4)
|
||||
LD_ID_R(iy, IY, l, RL, 5)
|
||||
LD_ID_R(iy, IY, a, RA, 6)
|
||||
|
||||
LD_R_ID(iy, IY, b, RB, 0)
|
||||
LD_R_ID(iy, IY, c, RC, 1)
|
||||
LD_R_ID(iy, IY, d, RD, 2)
|
||||
LD_R_ID(iy, IY, e, RE, 3)
|
||||
LD_R_ID(iy, IY, h, RH, 4)
|
||||
LD_R_ID(iy, IY, l, RL, 5)
|
||||
LD_R_ID(iy, IY, a, RA, 6)
|
||||
142
apps/plugins/zxbox/z80_op3.c
Normal file
142
apps/plugins/zxbox/z80_op3.c
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op3.h"
|
||||
#include "z80_ari.h"
|
||||
#endif
|
||||
|
||||
#define ARIR(arin, func, an, rn, r, n) \
|
||||
OPDEF(arin ## _ ## rn, 0x80+an*8+n) \
|
||||
{ \
|
||||
func(r); \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
#define ARIIHL(arin, func, an) \
|
||||
OPDEF(arin ## _ihl, 0x86+an*8) \
|
||||
{ \
|
||||
func(*HLP); \
|
||||
ENTIME(7); \
|
||||
}
|
||||
|
||||
#define ARIID(arin, func, an, ixyn, ixy) \
|
||||
OPDEF(arin ## _i ## ixyn ## d, 0x86+an*8)\
|
||||
{ \
|
||||
register dbyte addr; \
|
||||
register byte val; \
|
||||
IXDGET(ixy, addr); \
|
||||
val = READ(addr); \
|
||||
func(val); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
|
||||
#define ADD_A_R(rn, r, n) ARIR(add_a, ADD, 0, rn, r, n)
|
||||
#define ADC_A_R(rn, r, n) ARIR(adc_a, ADC, 1, rn, r, n)
|
||||
#define SUB_R(rn, r, n) ARIR(sub, SUB, 2, rn, r, n)
|
||||
#define SBC_A_R(rn, r, n) ARIR(sbc_a, SBC, 3, rn, r, n)
|
||||
#define AND_R(rn, r, n) ARIR(and, AND, 4, rn, r, n)
|
||||
#define XOR_R(rn, r, n) ARIR(xor, XOR, 5, rn, r, n)
|
||||
#define OR_R(rn, r, n) ARIR(or, OR, 6, rn, r, n)
|
||||
#define CP_R(rn, r, n) ARIR(cp, CP, 7, rn, r, n)
|
||||
|
||||
ADD_A_R(b, RB, 0)
|
||||
ADD_A_R(c, RC, 1)
|
||||
ADD_A_R(d, RD, 2)
|
||||
ADD_A_R(e, RE, 3)
|
||||
ADD_A_R(h, RH, 4)
|
||||
ADD_A_R(l, RL, 5)
|
||||
ADD_A_R(a, RA, 7)
|
||||
|
||||
ADC_A_R(b, RB, 0)
|
||||
ADC_A_R(c, RC, 1)
|
||||
ADC_A_R(d, RD, 2)
|
||||
ADC_A_R(e, RE, 3)
|
||||
ADC_A_R(h, RH, 4)
|
||||
ADC_A_R(l, RL, 5)
|
||||
ADC_A_R(a, RA, 7)
|
||||
|
||||
SUB_R(b, RB, 0)
|
||||
SUB_R(c, RC, 1)
|
||||
SUB_R(d, RD, 2)
|
||||
SUB_R(e, RE, 3)
|
||||
SUB_R(h, RH, 4)
|
||||
SUB_R(l, RL, 5)
|
||||
SUB_R(a, RA, 7)
|
||||
|
||||
SBC_A_R(b, RB, 0)
|
||||
SBC_A_R(c, RC, 1)
|
||||
SBC_A_R(d, RD, 2)
|
||||
SBC_A_R(e, RE, 3)
|
||||
SBC_A_R(h, RH, 4)
|
||||
SBC_A_R(l, RL, 5)
|
||||
SBC_A_R(a, RA, 7)
|
||||
|
||||
AND_R(b, RB, 0)
|
||||
AND_R(c, RC, 1)
|
||||
AND_R(d, RD, 2)
|
||||
AND_R(e, RE, 3)
|
||||
AND_R(h, RH, 4)
|
||||
AND_R(l, RL, 5)
|
||||
AND_R(a, RA, 7)
|
||||
|
||||
XOR_R(b, RB, 0)
|
||||
XOR_R(c, RC, 1)
|
||||
XOR_R(d, RD, 2)
|
||||
XOR_R(e, RE, 3)
|
||||
XOR_R(h, RH, 4)
|
||||
XOR_R(l, RL, 5)
|
||||
/* XOR_R(a, RA, 7) */
|
||||
|
||||
OPDEF(xor_a, 0xAF)
|
||||
{
|
||||
RA = 0;
|
||||
RF = (RF & ~(ALLF)) | (ZF | PVF);
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OR_R(b, RB, 0)
|
||||
OR_R(c, RC, 1)
|
||||
OR_R(d, RD, 2)
|
||||
OR_R(e, RE, 3)
|
||||
OR_R(h, RH, 4)
|
||||
OR_R(l, RL, 5)
|
||||
OR_R(a, RA, 7)
|
||||
|
||||
CP_R(b, RB, 0)
|
||||
CP_R(c, RC, 1)
|
||||
CP_R(d, RD, 2)
|
||||
CP_R(e, RE, 3)
|
||||
CP_R(h, RH, 4)
|
||||
CP_R(l, RL, 5)
|
||||
CP_R(a, RA, 7)
|
||||
|
||||
ARIIHL(add_a, ADD, 0)
|
||||
ARIIHL(adc_a, ADC, 1)
|
||||
ARIIHL(sub, SUB, 2)
|
||||
ARIIHL(sbc_a, SBC, 3)
|
||||
ARIIHL(and, AND, 4)
|
||||
ARIIHL(xor, XOR, 5)
|
||||
ARIIHL(or, OR, 6)
|
||||
ARIIHL(cp, CP, 7)
|
||||
|
||||
#include "z80_op3x.c"
|
||||
157
apps/plugins/zxbox/z80_op3.h
Normal file
157
apps/plugins/zxbox/z80_op3.h
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_add_a_b(z80t);
|
||||
extern z80t z80op_add_a_c(z80t);
|
||||
extern z80t z80op_add_a_d(z80t);
|
||||
extern z80t z80op_add_a_e(z80t);
|
||||
extern z80t z80op_add_a_h(z80t);
|
||||
extern z80t z80op_add_a_l(z80t);
|
||||
extern z80t z80op_add_a_ihl(z80t);
|
||||
extern z80t z80op_add_a_a(z80t);
|
||||
extern z80t z80op_adc_a_b(z80t);
|
||||
extern z80t z80op_adc_a_c(z80t);
|
||||
extern z80t z80op_adc_a_d(z80t);
|
||||
extern z80t z80op_adc_a_e(z80t);
|
||||
extern z80t z80op_adc_a_h(z80t);
|
||||
extern z80t z80op_adc_a_l(z80t);
|
||||
extern z80t z80op_adc_a_ihl(z80t);
|
||||
extern z80t z80op_adc_a_a(z80t);
|
||||
|
||||
extern z80t z80op_sub_b(z80t);
|
||||
extern z80t z80op_sub_c(z80t);
|
||||
extern z80t z80op_sub_d(z80t);
|
||||
extern z80t z80op_sub_e(z80t);
|
||||
extern z80t z80op_sub_h(z80t);
|
||||
extern z80t z80op_sub_l(z80t);
|
||||
extern z80t z80op_sub_ihl(z80t);
|
||||
extern z80t z80op_sub_a(z80t);
|
||||
extern z80t z80op_sbc_a_b(z80t);
|
||||
extern z80t z80op_sbc_a_c(z80t);
|
||||
extern z80t z80op_sbc_a_d(z80t);
|
||||
extern z80t z80op_sbc_a_e(z80t);
|
||||
extern z80t z80op_sbc_a_h(z80t);
|
||||
extern z80t z80op_sbc_a_l(z80t);
|
||||
extern z80t z80op_sbc_a_ihl(z80t);
|
||||
extern z80t z80op_sbc_a_a(z80t);
|
||||
|
||||
extern z80t z80op_and_b(z80t);
|
||||
extern z80t z80op_and_c(z80t);
|
||||
extern z80t z80op_and_d(z80t);
|
||||
extern z80t z80op_and_e(z80t);
|
||||
extern z80t z80op_and_h(z80t);
|
||||
extern z80t z80op_and_l(z80t);
|
||||
extern z80t z80op_and_ihl(z80t);
|
||||
extern z80t z80op_and_a(z80t);
|
||||
extern z80t z80op_xor_b(z80t);
|
||||
extern z80t z80op_xor_c(z80t);
|
||||
extern z80t z80op_xor_d(z80t);
|
||||
extern z80t z80op_xor_e(z80t);
|
||||
extern z80t z80op_xor_h(z80t);
|
||||
extern z80t z80op_xor_l(z80t);
|
||||
extern z80t z80op_xor_ihl(z80t);
|
||||
extern z80t z80op_xor_a(z80t);
|
||||
|
||||
extern z80t z80op_or_b(z80t);
|
||||
extern z80t z80op_or_c(z80t);
|
||||
extern z80t z80op_or_d(z80t);
|
||||
extern z80t z80op_or_e(z80t);
|
||||
extern z80t z80op_or_h(z80t);
|
||||
extern z80t z80op_or_l(z80t);
|
||||
extern z80t z80op_or_ihl(z80t);
|
||||
extern z80t z80op_or_a(z80t);
|
||||
extern z80t z80op_cp_b(z80t);
|
||||
extern z80t z80op_cp_c(z80t);
|
||||
extern z80t z80op_cp_d(z80t);
|
||||
extern z80t z80op_cp_e(z80t);
|
||||
extern z80t z80op_cp_h(z80t);
|
||||
extern z80t z80op_cp_l(z80t);
|
||||
extern z80t z80op_cp_ihl(z80t);
|
||||
extern z80t z80op_cp_a(z80t);
|
||||
|
||||
|
||||
/* IX */
|
||||
|
||||
extern z80t z80op_add_a_ixh(z80t);
|
||||
extern z80t z80op_add_a_ixl(z80t);
|
||||
extern z80t z80op_add_a_iixd(z80t);
|
||||
|
||||
extern z80t z80op_adc_a_ixh(z80t);
|
||||
extern z80t z80op_adc_a_ixl(z80t);
|
||||
extern z80t z80op_adc_a_iixd(z80t);
|
||||
|
||||
extern z80t z80op_sub_ixh(z80t);
|
||||
extern z80t z80op_sub_ixl(z80t);
|
||||
extern z80t z80op_sub_iixd(z80t);
|
||||
|
||||
extern z80t z80op_sbc_a_ixh(z80t);
|
||||
extern z80t z80op_sbc_a_ixl(z80t);
|
||||
extern z80t z80op_sbc_a_iixd(z80t);
|
||||
|
||||
extern z80t z80op_and_ixh(z80t);
|
||||
extern z80t z80op_and_ixl(z80t);
|
||||
extern z80t z80op_and_iixd(z80t);
|
||||
|
||||
extern z80t z80op_xor_ixh(z80t);
|
||||
extern z80t z80op_xor_ixl(z80t);
|
||||
extern z80t z80op_xor_iixd(z80t);
|
||||
|
||||
extern z80t z80op_or_ixh(z80t);
|
||||
extern z80t z80op_or_ixl(z80t);
|
||||
extern z80t z80op_or_iixd(z80t);
|
||||
|
||||
extern z80t z80op_cp_ixh(z80t);
|
||||
extern z80t z80op_cp_ixl(z80t);
|
||||
extern z80t z80op_cp_iixd(z80t);
|
||||
|
||||
|
||||
/* IY */
|
||||
|
||||
extern z80t z80op_add_a_iyh(z80t);
|
||||
extern z80t z80op_add_a_iyl(z80t);
|
||||
extern z80t z80op_add_a_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_adc_a_iyh(z80t);
|
||||
extern z80t z80op_adc_a_iyl(z80t);
|
||||
extern z80t z80op_adc_a_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_sub_iyh(z80t);
|
||||
extern z80t z80op_sub_iyl(z80t);
|
||||
extern z80t z80op_sub_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_sbc_a_iyh(z80t);
|
||||
extern z80t z80op_sbc_a_iyl(z80t);
|
||||
extern z80t z80op_sbc_a_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_and_iyh(z80t);
|
||||
extern z80t z80op_and_iyl(z80t);
|
||||
extern z80t z80op_and_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_xor_iyh(z80t);
|
||||
extern z80t z80op_xor_iyl(z80t);
|
||||
extern z80t z80op_xor_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_or_iyh(z80t);
|
||||
extern z80t z80op_or_iyl(z80t);
|
||||
extern z80t z80op_or_iiyd(z80t);
|
||||
|
||||
extern z80t z80op_cp_iyh(z80t);
|
||||
extern z80t z80op_cp_iyl(z80t);
|
||||
extern z80t z80op_cp_iiyd(z80t);
|
||||
89
apps/plugins/zxbox/z80_op3x.c
Normal file
89
apps/plugins/zxbox/z80_op3x.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* IX */
|
||||
|
||||
ADD_A_R(ixh, XH, 4)
|
||||
ADD_A_R(ixl, XL, 5)
|
||||
|
||||
ADC_A_R(ixh, XH, 4)
|
||||
ADC_A_R(ixl, XL, 5)
|
||||
|
||||
SUB_R(ixh, XH, 4)
|
||||
SUB_R(ixl, XL, 5)
|
||||
|
||||
SBC_A_R(ixh, XH, 4)
|
||||
SBC_A_R(ixl, XL, 5)
|
||||
|
||||
AND_R(ixh, XH, 4)
|
||||
AND_R(ixl, XL, 5)
|
||||
|
||||
XOR_R(ixh, XH, 4)
|
||||
XOR_R(ixl, XL, 5)
|
||||
|
||||
OR_R(ixh, XH, 4)
|
||||
OR_R(ixl, XL, 5)
|
||||
|
||||
CP_R(ixh, XH, 4)
|
||||
CP_R(ixl, XL, 5)
|
||||
|
||||
ARIID(add_a, ADD, 0, ix, IX)
|
||||
ARIID(adc_a, ADC, 1, ix, IX)
|
||||
ARIID(sub, SUB, 2, ix, IX)
|
||||
ARIID(sbc_a, SBC, 3, ix, IX)
|
||||
ARIID(and, AND, 4, ix, IX)
|
||||
ARIID(xor, XOR, 5, ix, IX)
|
||||
ARIID(or, OR, 6, ix, IX)
|
||||
ARIID(cp, CP, 7, ix, IX)
|
||||
|
||||
/* IY */
|
||||
|
||||
ADD_A_R(iyh, YH, 4)
|
||||
ADD_A_R(iyl, YL, 5)
|
||||
|
||||
ADC_A_R(iyh, YH, 4)
|
||||
ADC_A_R(iyl, YL, 5)
|
||||
|
||||
SUB_R(iyh, YH, 4)
|
||||
SUB_R(iyl, YL, 5)
|
||||
|
||||
SBC_A_R(iyh, YH, 4)
|
||||
SBC_A_R(iyl, YL, 5)
|
||||
|
||||
AND_R(iyh, YH, 4)
|
||||
AND_R(iyl, YL, 5)
|
||||
|
||||
XOR_R(iyh, YH, 4)
|
||||
XOR_R(iyl, YL, 5)
|
||||
|
||||
OR_R(iyh, YH, 4)
|
||||
OR_R(iyl, YL, 5)
|
||||
|
||||
CP_R(iyh, YH, 4)
|
||||
CP_R(iyl, YL, 5)
|
||||
|
||||
ARIID(add_a, ADD, 0, iy, IY)
|
||||
ARIID(adc_a, ADC, 1, iy, IY)
|
||||
ARIID(sub, SUB, 2, iy, IY)
|
||||
ARIID(sbc_a, SBC, 3, iy, IY)
|
||||
ARIID(and, AND, 4, iy, IY)
|
||||
ARIID(xor, XOR, 5, iy, IY)
|
||||
ARIID(or, OR, 6, iy, IY)
|
||||
ARIID(cp, CP, 7, iy, IY)
|
||||
305
apps/plugins/zxbox/z80_op4.c
Normal file
305
apps/plugins/zxbox/z80_op4.c
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op4.h"
|
||||
#include "z80_ari.h"
|
||||
#endif
|
||||
|
||||
#define RET_CC(ccn, cc, n) \
|
||||
OPDEF(ret_ ## ccn, 0xC0+n*8) \
|
||||
{ \
|
||||
if(!(cc)) { \
|
||||
ENTIME(5); \
|
||||
} \
|
||||
else { \
|
||||
POP(PC); \
|
||||
ENTIME(11); \
|
||||
} \
|
||||
}
|
||||
|
||||
RET_CC(nz, !TESTZF, 0)
|
||||
RET_CC(z, TESTZF, 1)
|
||||
RET_CC(nc, !TESTCF, 2)
|
||||
RET_CC(c, TESTCF, 3)
|
||||
RET_CC(po, !TESTPF, 4)
|
||||
RET_CC(pe, TESTPF, 5)
|
||||
RET_CC(p, !TESTSF, 6)
|
||||
RET_CC(m, TESTSF, 7)
|
||||
|
||||
#define POP_RR(rrn, rr, n) \
|
||||
OPDEF(pop_ ## rrn, 0xC1+n*0x10) \
|
||||
{ \
|
||||
POP(rr); \
|
||||
ENTIME(10); \
|
||||
}
|
||||
|
||||
POP_RR(bc, BC, 0)
|
||||
POP_RR(de, DE, 1)
|
||||
POP_RR(hl, HL, 2)
|
||||
POP_RR(af, AF, 3)
|
||||
|
||||
OPDEF(ret, 0xC9)
|
||||
{
|
||||
POP(PC);
|
||||
ENTIME(10);
|
||||
}
|
||||
|
||||
OPDEF(exx, 0xD9)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
|
||||
dtmp = BCBK, BCBK = BC, BC = dtmp;
|
||||
dtmp = DEBK, DEBK = DE, DE = dtmp;
|
||||
dtmp = HLBK, HLBK = HL, HL = dtmp;
|
||||
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
#define JP_RR(rrn, rr) \
|
||||
OPDEF(jp_ ## rrn, 0xE9) \
|
||||
{ \
|
||||
PC = rr; \
|
||||
ENTIME(4); \
|
||||
}
|
||||
|
||||
JP_RR(hl, HL)
|
||||
|
||||
#define LD_SP_RR(rrn, rr) \
|
||||
OPDEF(ld_sp_ ## rrn, 0xF9) \
|
||||
{ \
|
||||
SP = rr; \
|
||||
ENTIME(6); \
|
||||
}
|
||||
|
||||
LD_SP_RR(hl, HL)
|
||||
|
||||
#define JP_CC(ccn, cc, n) \
|
||||
OPDEF(jp_ ## ccn ## _nn, 0xC2+n*8) \
|
||||
{ \
|
||||
if(!(cc)) { \
|
||||
PC+=2; \
|
||||
ENTIME(10); \
|
||||
} \
|
||||
else { \
|
||||
PC = DREAD(PC); \
|
||||
ENTIME(10); \
|
||||
} \
|
||||
}
|
||||
|
||||
JP_CC(nz, !TESTZF, 0)
|
||||
JP_CC(z, TESTZF, 1)
|
||||
JP_CC(nc, !TESTCF, 2)
|
||||
JP_CC(c, TESTCF, 3)
|
||||
JP_CC(po, !TESTPF, 4)
|
||||
JP_CC(pe, TESTPF, 5)
|
||||
JP_CC(p, !TESTSF, 6)
|
||||
JP_CC(m, TESTSF, 7)
|
||||
|
||||
OPDEF(jp_nn, 0xC3)
|
||||
{
|
||||
PC = DREAD(PC);
|
||||
ENTIME(10);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(out_in_a, 0xD3)
|
||||
{
|
||||
OUT(RA, *PCP, RA);
|
||||
PC++;
|
||||
ENTIME(11);
|
||||
}
|
||||
|
||||
OPDEF(in_a_in, 0xDB)
|
||||
{
|
||||
IN(RA, *PCP, RA);
|
||||
PC++;
|
||||
ENTIME(11);
|
||||
}
|
||||
|
||||
#define EX_ISP_RR(rrn, rr) \
|
||||
OPDEF(ex_isp_ ## rrn, 0xE3) \
|
||||
{ \
|
||||
register dbyte dtmp; \
|
||||
dtmp = DREAD(SP); \
|
||||
DWRITE(SP, rr); \
|
||||
rr = dtmp; \
|
||||
ENTIME(19); \
|
||||
}
|
||||
|
||||
EX_ISP_RR(hl, HL)
|
||||
|
||||
OPDEF(ex_de_hl, 0xEB)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
dtmp = DE;
|
||||
DE = HL;
|
||||
HL = dtmp;
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(di, 0xF3)
|
||||
{
|
||||
DANM(iff1) = 0;
|
||||
DANM(iff2) = 0;
|
||||
DI_CHECK
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
OPDEF(ei, 0xFB)
|
||||
{
|
||||
DANM(iff1) = 1;
|
||||
DANM(iff2) = 1;
|
||||
ENTIME(4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CALL_CC(ccn, cc, n) \
|
||||
OPDEF(call_ ## ccn ## _nn, 0xC4+n*8) \
|
||||
{ \
|
||||
if(!(cc)) { \
|
||||
PC+=2; \
|
||||
ENTIME(10); \
|
||||
} \
|
||||
else { \
|
||||
register dbyte dtmp; \
|
||||
dtmp = PC; \
|
||||
PC = DREAD(dtmp); \
|
||||
dtmp += 2; \
|
||||
PUSH(dtmp); \
|
||||
ENTIME(17); \
|
||||
} \
|
||||
}
|
||||
|
||||
CALL_CC(nz, !TESTZF, 0)
|
||||
CALL_CC(z, TESTZF, 1)
|
||||
CALL_CC(nc, !TESTCF, 2)
|
||||
CALL_CC(c, TESTCF, 3)
|
||||
CALL_CC(po, !TESTPF, 4)
|
||||
CALL_CC(pe, TESTPF, 5)
|
||||
CALL_CC(p, !TESTSF, 6)
|
||||
CALL_CC(m, TESTSF, 7)
|
||||
|
||||
|
||||
|
||||
#define PUSH_RR(rrn, rr, n) \
|
||||
OPDEF(push_ ## rrn, 0xC5+n*0x10) \
|
||||
{ \
|
||||
PUSH(rr); \
|
||||
ENTIME(11); \
|
||||
}
|
||||
|
||||
PUSH_RR(bc, BC, 0)
|
||||
PUSH_RR(de, DE, 1)
|
||||
PUSH_RR(hl, HL, 2)
|
||||
PUSH_RR(af, AF, 3)
|
||||
|
||||
|
||||
OPDEF(call_nn, 0xCD)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
dtmp = PC;
|
||||
PC = DREAD(dtmp);
|
||||
dtmp += 2;
|
||||
PUSH(dtmp);
|
||||
ENTIME(17);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(add_a_n, 0xC6)
|
||||
{
|
||||
ADD(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(adc_a_n, 0xCE)
|
||||
{
|
||||
ADC(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
OPDEF(sub_n, 0xD6)
|
||||
{
|
||||
SUB(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(sbc_a_n, 0xDE)
|
||||
{
|
||||
SBC(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
OPDEF(and_n, 0xE6)
|
||||
{
|
||||
AND(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(xor_n, 0xEE)
|
||||
{
|
||||
XOR(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
OPDEF(or_n, 0xF6)
|
||||
{
|
||||
OR(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(cp_n, 0xFE)
|
||||
{
|
||||
CP(*PCP);
|
||||
PC++;
|
||||
ENTIME(7);
|
||||
}
|
||||
|
||||
#define RST_NN(nnn, n) \
|
||||
OPDEF(rst_ ## nnn, 0xC7+n*8) \
|
||||
{ \
|
||||
PUSH(PC); \
|
||||
PC = n*8; \
|
||||
ENTIME(11); \
|
||||
}
|
||||
|
||||
RST_NN(00, 0)
|
||||
RST_NN(08, 1)
|
||||
RST_NN(10, 2)
|
||||
RST_NN(18, 3)
|
||||
RST_NN(20, 4)
|
||||
RST_NN(28, 5)
|
||||
RST_NN(30, 6)
|
||||
RST_NN(38, 7)
|
||||
|
||||
#include "z80_op4x.c"
|
||||
105
apps/plugins/zxbox/z80_op4.h
Normal file
105
apps/plugins/zxbox/z80_op4.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_ret_nz(z80t);
|
||||
extern z80t z80op_pop_bc(z80t);
|
||||
extern z80t z80op_jp_nz_nn(z80t);
|
||||
extern z80t z80op_jp_nn(z80t);
|
||||
extern z80t z80op_call_nz_nn(z80t);
|
||||
extern z80t z80op_push_bc(z80t);
|
||||
extern z80t z80op_add_a_n(z80t);
|
||||
extern z80t z80op_rst_00(z80t);
|
||||
extern z80t z80op_ret_z(z80t);
|
||||
extern z80t z80op_ret(z80t);
|
||||
extern z80t z80op_jp_z_nn(z80t);
|
||||
extern z80t z80op_special_cb(z80t);
|
||||
extern z80t z80op_call_z_nn(z80t);
|
||||
extern z80t z80op_call_nn(z80t);
|
||||
extern z80t z80op_adc_a_n(z80t);
|
||||
extern z80t z80op_rst_08(z80t);
|
||||
|
||||
extern z80t z80op_ret_nc(z80t);
|
||||
extern z80t z80op_pop_de(z80t);
|
||||
extern z80t z80op_jp_nc_nn(z80t);
|
||||
extern z80t z80op_out_in_a(z80t);
|
||||
extern z80t z80op_call_nc_nn(z80t);
|
||||
extern z80t z80op_push_de(z80t);
|
||||
extern z80t z80op_sub_n(z80t);
|
||||
extern z80t z80op_rst_10(z80t);
|
||||
extern z80t z80op_ret_c(z80t);
|
||||
extern z80t z80op_exx(z80t);
|
||||
extern z80t z80op_jp_c_nn(z80t);
|
||||
extern z80t z80op_in_a_in(z80t);
|
||||
extern z80t z80op_call_c_nn(z80t);
|
||||
extern z80t z80op_special_dd(z80t);
|
||||
extern z80t z80op_sbc_a_n(z80t);
|
||||
extern z80t z80op_rst_18(z80t);
|
||||
|
||||
extern z80t z80op_ret_po(z80t);
|
||||
extern z80t z80op_pop_hl(z80t);
|
||||
extern z80t z80op_jp_po_nn(z80t);
|
||||
extern z80t z80op_ex_isp_hl(z80t);
|
||||
extern z80t z80op_call_po_nn(z80t);
|
||||
extern z80t z80op_push_hl(z80t);
|
||||
extern z80t z80op_and_n(z80t);
|
||||
extern z80t z80op_rst_20(z80t);
|
||||
extern z80t z80op_ret_pe(z80t);
|
||||
extern z80t z80op_jp_hl(z80t);
|
||||
extern z80t z80op_jp_pe_nn(z80t);
|
||||
extern z80t z80op_ex_de_hl(z80t);
|
||||
extern z80t z80op_call_pe_nn(z80t);
|
||||
extern z80t z80op_special_ed(z80t);
|
||||
extern z80t z80op_xor_n(z80t);
|
||||
extern z80t z80op_rst_28(z80t);
|
||||
|
||||
extern z80t z80op_ret_p(z80t);
|
||||
extern z80t z80op_pop_af(z80t);
|
||||
extern z80t z80op_jp_p_nn(z80t);
|
||||
extern z80t z80op_di(z80t);
|
||||
extern z80t z80op_call_p_nn(z80t);
|
||||
extern z80t z80op_push_af(z80t);
|
||||
extern z80t z80op_or_n(z80t);
|
||||
extern z80t z80op_rst_30(z80t);
|
||||
extern z80t z80op_ret_m(z80t);
|
||||
extern z80t z80op_ld_sp_hl(z80t);
|
||||
extern z80t z80op_jp_m_nn(z80t);
|
||||
extern z80t z80op_ei(z80t);
|
||||
extern z80t z80op_call_m_nn(z80t);
|
||||
extern z80t z80op_special_fd(z80t);
|
||||
extern z80t z80op_cp_n(z80t);
|
||||
extern z80t z80op_rst_38(z80t);
|
||||
|
||||
/* IX */
|
||||
|
||||
extern z80t z80op_pop_ix(z80t);
|
||||
extern z80t z80op_push_ix(z80t);
|
||||
|
||||
extern z80t z80op_jp_ix(z80t);
|
||||
extern z80t z80op_ld_sp_ix(z80t);
|
||||
extern z80t z80op_ex_isp_ix(z80t);
|
||||
|
||||
/* IY */
|
||||
|
||||
extern z80t z80op_pop_iy(z80t);
|
||||
extern z80t z80op_push_iy(z80t);
|
||||
|
||||
extern z80t z80op_jp_iy(z80t);
|
||||
extern z80t z80op_ld_sp_iy(z80t);
|
||||
extern z80t z80op_ex_isp_iy(z80t);
|
||||
38
apps/plugins/zxbox/z80_op4x.c
Normal file
38
apps/plugins/zxbox/z80_op4x.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* IX */
|
||||
|
||||
POP_RR(ix, IX, 2)
|
||||
PUSH_RR(ix, IX, 2)
|
||||
|
||||
JP_RR(ix, IX)
|
||||
LD_SP_RR(ix, IX)
|
||||
EX_ISP_RR(ix, IX)
|
||||
|
||||
|
||||
/* IY */
|
||||
|
||||
POP_RR(iy, IY, 2)
|
||||
PUSH_RR(iy, IY, 2)
|
||||
|
||||
JP_RR(iy, IY)
|
||||
LD_SP_RR(iy, IY)
|
||||
EX_ISP_RR(iy, IY)
|
||||
449
apps/plugins/zxbox/z80_op5.c
Normal file
449
apps/plugins/zxbox/z80_op5.c
Normal file
|
|
@ -0,0 +1,449 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op5.h"
|
||||
#endif
|
||||
|
||||
OPDEF(ill_ed, 0x00)
|
||||
{
|
||||
#ifdef DEBUG_Z80
|
||||
printf("ILL_ED: %04X - %02X\n", (dbyte) (PC-1), DANM(mem)[(dbyte) (PC-1)]);
|
||||
#endif
|
||||
|
||||
ENTIME(8);
|
||||
}
|
||||
|
||||
#define IN_R_IC(rn, r, n) \
|
||||
OPDEF(in_ ## rn ## _ic, 0x40+8*n) \
|
||||
{ \
|
||||
register byte res, flag; \
|
||||
IN(RB, RC, res); \
|
||||
r = res; \
|
||||
flag = (RF & ~(ABUTCF)) | \
|
||||
TAB(orf_tbl)[res]; \
|
||||
RF = flag; \
|
||||
ENTIME(12); \
|
||||
}
|
||||
|
||||
IN_R_IC(b, RB, 0)
|
||||
IN_R_IC(c, RC, 1)
|
||||
IN_R_IC(d, RD, 2)
|
||||
IN_R_IC(e, RE, 3)
|
||||
IN_R_IC(h, RH, 4)
|
||||
IN_R_IC(l, RL, 5)
|
||||
IN_R_IC(f, res, 6)
|
||||
IN_R_IC(a, RA, 7)
|
||||
|
||||
|
||||
#define OUT_IC_R(rn, r, n) \
|
||||
OPDEF(out_ic_ ## rn, 0x41+8*n) \
|
||||
{ \
|
||||
OUT(RB, RC, r); \
|
||||
ENTIME(12); \
|
||||
}
|
||||
|
||||
OUT_IC_R(b, RB, 0)
|
||||
OUT_IC_R(c, RC, 1)
|
||||
OUT_IC_R(d, RD, 2)
|
||||
OUT_IC_R(e, RE, 3)
|
||||
OUT_IC_R(h, RH, 4)
|
||||
OUT_IC_R(l, RL, 5)
|
||||
OUT_IC_R(0, 0, 6)
|
||||
OUT_IC_R(a, RA, 7)
|
||||
|
||||
|
||||
|
||||
#define SBC_HL_RR(rrn, rr, n) \
|
||||
OPDEF(sbc_hl_ ## rrn, 0x42+0x10*n) \
|
||||
{ \
|
||||
register dbyte res; \
|
||||
register int idx, flag; \
|
||||
flag = RF; \
|
||||
res = HL - rr - (flag & CF); \
|
||||
idx = DIDXCALC(HL, rr, res); \
|
||||
HL = res; \
|
||||
flag = (RF & ~(ALLF)) | \
|
||||
(TAB(subf_tbl)[idx] & ALLF); \
|
||||
if(!res) flag |= ZF; \
|
||||
RF = flag; \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
SBC_HL_RR(bc, BC, 0)
|
||||
SBC_HL_RR(de, DE, 1)
|
||||
SBC_HL_RR(hl, HL, 2)
|
||||
SBC_HL_RR(sp, SP, 3)
|
||||
|
||||
#define ADC_HL_RR(rrn, rr, n) \
|
||||
OPDEF(adc_hl_ ## rrn, 0x4A+0x10*n) \
|
||||
{ \
|
||||
register dbyte res; \
|
||||
register int idx, flag; \
|
||||
flag = RF; \
|
||||
res = HL + rr + (flag & CF); \
|
||||
idx = DIDXCALC(HL, rr, res); \
|
||||
HL = res; \
|
||||
flag = (RF & ~(ALLF)) | \
|
||||
(TAB(addf_tbl)[idx] & ALLF); \
|
||||
if(!res) flag |= ZF; \
|
||||
RF = flag; \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
ADC_HL_RR(bc, BC, 0)
|
||||
ADC_HL_RR(de, DE, 1)
|
||||
ADC_HL_RR(hl, HL, 2)
|
||||
ADC_HL_RR(sp, SP, 3)
|
||||
|
||||
|
||||
|
||||
#define LD_INN_RR(rrn, pf, rr, n) \
|
||||
OPDEF(ld_inn_ ## rrn ## pf, 0x43+0x10*n) \
|
||||
{ \
|
||||
register dbyte dtmp; \
|
||||
FETCHD(dtmp); \
|
||||
DWRITE(dtmp, rr); \
|
||||
ENTIME(20); \
|
||||
}
|
||||
|
||||
|
||||
LD_INN_RR(bc, , BC, 0)
|
||||
LD_INN_RR(de, , DE, 1)
|
||||
LD_INN_RR(hl, _ed, HL, 2)
|
||||
LD_INN_RR(sp, , SP, 3)
|
||||
|
||||
|
||||
#define LD_RR_INN(rrn, pf, rr, n) \
|
||||
OPDEF(ld_## rrn ## _inn ## pf, 0x4B+0x10*n) \
|
||||
{ \
|
||||
register dbyte dtmp; \
|
||||
FETCHD(dtmp); \
|
||||
rr = DREAD(dtmp); \
|
||||
ENTIME(20); \
|
||||
}
|
||||
|
||||
|
||||
LD_RR_INN(bc, , BC, 0)
|
||||
LD_RR_INN(de, , DE, 1)
|
||||
LD_RR_INN(hl, _ed, HL, 2)
|
||||
LD_RR_INN(sp, , SP, 3)
|
||||
|
||||
OPDEF(neg, 0x44 0x4C 0x54 0x5C 0x64 0x6C 0x74 0x7C)
|
||||
{
|
||||
register byte res;
|
||||
register int idx;
|
||||
register int flag;
|
||||
|
||||
res = 0 - RA;
|
||||
idx = IDXCALC(0, RA, res);
|
||||
RA = res;
|
||||
flag = (RF & ~(AALLF)) | TAB(subf_tbl)[idx];
|
||||
if(!res) flag |= ZF;
|
||||
RF = flag;
|
||||
ENTIME(8);
|
||||
}
|
||||
|
||||
OPDEF(retn, 0x45 0x55 0x5D 0x65 0x6D 0x75 0x7D)
|
||||
{
|
||||
DANM(iff1) = DANM(iff2);
|
||||
POP(PC);
|
||||
ENTIME(14);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(reti, 0x4D)
|
||||
{
|
||||
POP(PC);
|
||||
ENTIME(14);
|
||||
}
|
||||
|
||||
OPDEF(im_0, 0x46 0x4E 0x56 0x5E)
|
||||
{
|
||||
DANM(it_mode) = 0;
|
||||
ENTIME(8);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(im_1, 0x56 0x76)
|
||||
{
|
||||
DANM(it_mode) = 1;
|
||||
ENTIME(8);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(im_2, 0x5E 0x7E)
|
||||
{
|
||||
DANM(it_mode) = 2;
|
||||
ENTIME(8);
|
||||
}
|
||||
|
||||
OPDEF(ld_i_a, 0x47)
|
||||
{
|
||||
RI = RA;
|
||||
ENTIME(9);
|
||||
}
|
||||
|
||||
OPDEF(ld_r_a, 0x4F)
|
||||
{
|
||||
DANM(rl7) = RA & 0x80;
|
||||
RR = RA;
|
||||
ENTIME(9);
|
||||
}
|
||||
|
||||
OPDEF(ld_a_i, 0x57)
|
||||
{
|
||||
register int flag;
|
||||
|
||||
RA = RI;
|
||||
flag = (RF & ~(BUTCF)) | (RA & SF);
|
||||
if(!RA) flag |= ZF;
|
||||
if(DANM(iff2)) flag |= PVF;
|
||||
RF = flag;
|
||||
|
||||
ENTIME(9);
|
||||
}
|
||||
|
||||
OPDEF(ld_a_r, 0x5F)
|
||||
{
|
||||
register int flag;
|
||||
|
||||
RA = (RR & 0x7F) | DANM(rl7);
|
||||
flag = (RF & ~(BUTCF)) | (RA & SF);
|
||||
if(!RA) flag |= ZF;
|
||||
if(DANM(iff2)) flag |= PVF;
|
||||
RF = flag;
|
||||
|
||||
ENTIME(9);
|
||||
}
|
||||
|
||||
OPDEF(rrd, 0x67)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
|
||||
dtmp = *HLP | (RA << 8);
|
||||
RA = (RA & 0xF0) | (dtmp & 0x0F);
|
||||
SETFLAGS(ABUTCF, TAB(orf_tbl)[RA]);
|
||||
dtmp >>= 4;
|
||||
PUTMEM(HL, HLP, (byte) dtmp);
|
||||
|
||||
ENTIME(18);
|
||||
}
|
||||
|
||||
OPDEF(rld, 0x6F)
|
||||
{
|
||||
register dbyte dtmp;
|
||||
|
||||
dtmp = (*HLP << 4) | (RA & 0x0F);
|
||||
RA = (RA & 0xF0) | ((dtmp >> 8) & 0x0F);
|
||||
SETFLAGS(ABUTCF, TAB(orf_tbl)[RA]);
|
||||
PUTMEM(HL, HLP, (byte) dtmp);
|
||||
|
||||
ENTIME(18);
|
||||
}
|
||||
|
||||
#define NOREPEAT() \
|
||||
if(BC) RF |= PVF; \
|
||||
ENTIME(16)
|
||||
|
||||
#define LDREPEAT() \
|
||||
if(BC) { \
|
||||
RF |= PVF; \
|
||||
PC-=2; \
|
||||
ENTIME(21); \
|
||||
} \
|
||||
else { \
|
||||
ENTIME(16); \
|
||||
}
|
||||
|
||||
|
||||
#define LDID(dir) \
|
||||
register byte res; \
|
||||
res = *HLP; \
|
||||
PUTMEM(DE, DEP, res); \
|
||||
DE dir, HL dir; \
|
||||
RF = RF & ~(HF | PVF | NF); \
|
||||
BC--
|
||||
|
||||
OPDEF(ldi, 0xA0)
|
||||
{
|
||||
LDID(++);
|
||||
NOREPEAT();
|
||||
}
|
||||
|
||||
OPDEF(ldd, 0xA8)
|
||||
{
|
||||
LDID(--);
|
||||
NOREPEAT();
|
||||
}
|
||||
|
||||
OPDEF(ldir, 0xB0)
|
||||
{
|
||||
LDID(++);
|
||||
LDREPEAT();
|
||||
}
|
||||
|
||||
|
||||
OPDEF(lddr, 0xB8)
|
||||
{
|
||||
LDID(--);
|
||||
LDREPEAT();
|
||||
}
|
||||
|
||||
#define CPREPEAT() \
|
||||
if(res && BC) { \
|
||||
RF |= PVF; \
|
||||
PC-=2; \
|
||||
ENTIME(21); \
|
||||
} \
|
||||
else { \
|
||||
ENTIME(16); \
|
||||
}
|
||||
|
||||
#define CPID(dir) \
|
||||
register byte res; \
|
||||
register int idx; \
|
||||
res = RA - *HLP; \
|
||||
idx = IDXCALC(RA, *HLP, res); \
|
||||
RF = (RF & ~BUTCF) | \
|
||||
(TAB(subf_tbl)[idx] & \
|
||||
(SF | HF | NF | B3F | B5F)); \
|
||||
if(!res) RF |= ZF; \
|
||||
HL dir; \
|
||||
BC--
|
||||
|
||||
|
||||
OPDEF(cpi, 0xA1)
|
||||
{
|
||||
CPID(++);
|
||||
NOREPEAT();
|
||||
}
|
||||
|
||||
|
||||
OPDEF(cpd, 0xA9)
|
||||
{
|
||||
CPID(--);
|
||||
NOREPEAT();
|
||||
}
|
||||
|
||||
|
||||
OPDEF(cpir, 0xB1)
|
||||
{
|
||||
CPID(++);
|
||||
CPREPEAT();
|
||||
}
|
||||
|
||||
OPDEF(cpdr, 0xB9)
|
||||
{
|
||||
CPID(--);
|
||||
CPREPEAT();
|
||||
}
|
||||
|
||||
#define IOREPEAT() \
|
||||
if(RB) { \
|
||||
PC-=2; \
|
||||
ENTIME(21); \
|
||||
} \
|
||||
else { \
|
||||
ENTIME(16); \
|
||||
}
|
||||
|
||||
|
||||
#define INID(dir) \
|
||||
register byte res; \
|
||||
register int idx; \
|
||||
res = RB - 1; \
|
||||
idx = IDXCALC(RB, 1, res); \
|
||||
RF = (RF & ~BUTCF) | \
|
||||
(TAB(subf_tbl)[idx] & \
|
||||
(SF | HF | PVF | NF | B3F | B5F)); \
|
||||
if(!res) RF |= ZF; \
|
||||
RB = res; \
|
||||
IN(RB, RC, res); \
|
||||
PUTMEM(HL, HLP, res); \
|
||||
HL dir
|
||||
|
||||
|
||||
OPDEF(ini, 0xA2)
|
||||
{
|
||||
INID(++);
|
||||
ENTIME(16);
|
||||
}
|
||||
|
||||
OPDEF(ind, 0xAA)
|
||||
{
|
||||
INID(--);
|
||||
ENTIME(16);
|
||||
}
|
||||
|
||||
OPDEF(inir, 0xB2)
|
||||
{
|
||||
INID(++);
|
||||
IOREPEAT();
|
||||
}
|
||||
|
||||
OPDEF(indr, 0xBA)
|
||||
{
|
||||
INID(--);
|
||||
IOREPEAT();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define OUTID(dir) \
|
||||
register byte res; \
|
||||
register int idx; \
|
||||
res = RB - 1; \
|
||||
idx = IDXCALC(RB, 1, res); \
|
||||
RF = (RF & ~BUTCF) | \
|
||||
(TAB(subf_tbl)[idx] & \
|
||||
(SF | HF | PVF | NF )); \
|
||||
if(!res) RF |= ZF; \
|
||||
RB = res; \
|
||||
OUT(RB, RC, *HLP); \
|
||||
HL dir
|
||||
|
||||
|
||||
|
||||
OPDEF(outi, 0xA3)
|
||||
{
|
||||
OUTID(++);
|
||||
ENTIME(16);
|
||||
}
|
||||
|
||||
OPDEF(outd, 0xAB)
|
||||
{
|
||||
OUTID(--);
|
||||
ENTIME(16);
|
||||
}
|
||||
|
||||
|
||||
OPDEF(otir, 0xB3)
|
||||
{
|
||||
OUTID(++);
|
||||
IOREPEAT();
|
||||
}
|
||||
|
||||
OPDEF(otdr, 0xBB)
|
||||
{
|
||||
OUTID(--);
|
||||
IOREPEAT();
|
||||
}
|
||||
109
apps/plugins/zxbox/z80_op5.h
Normal file
109
apps/plugins/zxbox/z80_op5.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_ill_ed(z80t);
|
||||
|
||||
extern z80t z80op_in_b_ic(z80t);
|
||||
extern z80t z80op_out_ic_b(z80t);
|
||||
extern z80t z80op_sbc_hl_bc(z80t);
|
||||
extern z80t z80op_ld_inn_bc(z80t);
|
||||
extern z80t z80op_neg(z80t);
|
||||
extern z80t z80op_retn(z80t);
|
||||
extern z80t z80op_im_0(z80t);
|
||||
extern z80t z80op_ld_i_a(z80t);
|
||||
extern z80t z80op_in_c_ic(z80t);
|
||||
extern z80t z80op_out_ic_c(z80t);
|
||||
extern z80t z80op_adc_hl_bc(z80t);
|
||||
extern z80t z80op_ld_bc_inn(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
extern z80t z80op_reti(z80t);
|
||||
/*extern z80t z80op_im_0(z80t); */
|
||||
extern z80t z80op_ld_r_a(z80t);
|
||||
|
||||
extern z80t z80op_in_d_ic(z80t);
|
||||
extern z80t z80op_out_ic_d(z80t);
|
||||
extern z80t z80op_sbc_hl_de(z80t);
|
||||
extern z80t z80op_ld_inn_de(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
extern z80t z80op_im_1(z80t);
|
||||
extern z80t z80op_ld_a_i(z80t);
|
||||
extern z80t z80op_in_e_ic(z80t);
|
||||
extern z80t z80op_out_ic_e(z80t);
|
||||
extern z80t z80op_adc_hl_de(z80t);
|
||||
extern z80t z80op_ld_de_inn(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
extern z80t z80op_im_2(z80t);
|
||||
extern z80t z80op_ld_a_r(z80t);
|
||||
|
||||
extern z80t z80op_in_h_ic(z80t);
|
||||
extern z80t z80op_out_ic_h(z80t);
|
||||
extern z80t z80op_sbc_hl_hl(z80t);
|
||||
extern z80t z80op_ld_inn_hl_ed(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
/* extern z80t z80op_im_0(z80t); */
|
||||
extern z80t z80op_rrd(z80t);
|
||||
extern z80t z80op_in_l_ic(z80t);
|
||||
extern z80t z80op_out_ic_l(z80t);
|
||||
extern z80t z80op_adc_hl_hl(z80t);
|
||||
extern z80t z80op_ld_hl_inn_ed(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
/* extern z80t z80op_im_0(z80t); */
|
||||
extern z80t z80op_rld(z80t);
|
||||
|
||||
extern z80t z80op_in_f_ic(z80t);
|
||||
extern z80t z80op_out_ic_0(z80t);
|
||||
extern z80t z80op_sbc_hl_sp(z80t);
|
||||
extern z80t z80op_ld_inn_sp(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
/* extern z80t z80op_im_1(z80t); */
|
||||
/* extern z80t z80op_ill_ed(z80t); */
|
||||
extern z80t z80op_in_a_ic(z80t);
|
||||
extern z80t z80op_out_ic_a(z80t);
|
||||
extern z80t z80op_adc_hl_sp(z80t);
|
||||
extern z80t z80op_ld_sp_inn(z80t);
|
||||
/* extern z80t z80op_neg(z80t); */
|
||||
/* extern z80t z80op_retn(z80t); */
|
||||
/* extern z80t z80op_im_2(z80t); */
|
||||
/* extern z80t z80op_ill_ed(z80t); */
|
||||
|
||||
extern z80t z80op_ldi(z80t);
|
||||
extern z80t z80op_cpi(z80t);
|
||||
extern z80t z80op_ini(z80t);
|
||||
extern z80t z80op_outi(z80t);
|
||||
|
||||
extern z80t z80op_ldd(z80t);
|
||||
extern z80t z80op_cpd(z80t);
|
||||
extern z80t z80op_ind(z80t);
|
||||
extern z80t z80op_outd(z80t);
|
||||
|
||||
extern z80t z80op_ldir(z80t);
|
||||
extern z80t z80op_cpir(z80t);
|
||||
extern z80t z80op_inir(z80t);
|
||||
extern z80t z80op_otir(z80t);
|
||||
|
||||
extern z80t z80op_lddr(z80t);
|
||||
extern z80t z80op_cpdr(z80t);
|
||||
extern z80t z80op_indr(z80t);
|
||||
extern z80t z80op_otdr(z80t);
|
||||
437
apps/plugins/zxbox/z80_op6.c
Normal file
437
apps/plugins/zxbox/z80_op6.c
Normal file
|
|
@ -0,0 +1,437 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_OPDEF
|
||||
#include "z80_def.h"
|
||||
#include "z80_op6.h"
|
||||
#endif
|
||||
|
||||
#define GHL DANM(cbaddr)
|
||||
|
||||
#define B7(r) (((r) & 0x80) >> 7)
|
||||
#define B0(r) ((r) & 0x01)
|
||||
|
||||
#define SHIFTROTL(r, mod) \
|
||||
{ \
|
||||
register int carry; \
|
||||
carry = B7(r); \
|
||||
r = mod; \
|
||||
RF = (RF & ~(AALLF)) | carry | \
|
||||
TAB(orf_tbl)[(byte) r]; \
|
||||
}
|
||||
|
||||
|
||||
#define SHIFTROTR(r, mod) \
|
||||
{ \
|
||||
register int carry; \
|
||||
carry = B0(r); \
|
||||
r = mod; \
|
||||
RF = (RF & ~(AALLF)) | carry | \
|
||||
TAB(orf_tbl)[(byte) r]; \
|
||||
}
|
||||
|
||||
|
||||
#define RLC(r) SHIFTROTL(r, (r << 1) | carry)
|
||||
#define RRC(r) SHIFTROTR(r, (r >> 1) | (carry << 7))
|
||||
#define RLN(r) SHIFTROTL(r, (r << 1) | (RF & CF))
|
||||
#define RRN(r) SHIFTROTR(r, (r >> 1) | ((RF & CF) << 7))
|
||||
#define SLA(r) SHIFTROTL(r, r << 1)
|
||||
#define SRA(r) SHIFTROTR(r, (byte) ((sbyte) r >> 1))
|
||||
#define SLL(r) SHIFTROTL(r, (r << 1) | 0x01)
|
||||
#define SRL(r) SHIFTROTR(r, r >> 1)
|
||||
|
||||
|
||||
#define SHRR(shrn, func, an, rn, r, n) \
|
||||
OPDEF(shrn ## _ ## rn, 0x00+an*8+n) \
|
||||
{ \
|
||||
func(r); \
|
||||
ENTIME(8); \
|
||||
}
|
||||
|
||||
#define SHRIHL(shrn, func, an) \
|
||||
OPDEF(shrn ## _ihl, 0x06+an*8) \
|
||||
{ \
|
||||
register byte btmp; \
|
||||
btmp = READ(GHL); \
|
||||
func(btmp); \
|
||||
WRITE(GHL, btmp); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
#define RLC_R(rn, r, n) SHRR(rlc, RLC, 0, rn, r, n)
|
||||
#define RRC_R(rn, r, n) SHRR(rrc, RRC, 1, rn, r, n)
|
||||
#define RL_R(rn, r, n) SHRR(rl, RLN, 2, rn, r, n)
|
||||
#define RR_R(rn, r, n) SHRR(rr, RRN, 3, rn, r, n)
|
||||
#define SLA_R(rn, r, n) SHRR(sla, SLA, 4, rn, r, n)
|
||||
#define SRA_R(rn, r, n) SHRR(sra, SRA, 5, rn, r, n)
|
||||
#define SLL_R(rn, r, n) SHRR(sll, SLL, 6, rn, r, n)
|
||||
#define SRL_R(rn, r, n) SHRR(srl, SRL, 7, rn, r, n)
|
||||
|
||||
RLC_R(b, RB, 0)
|
||||
RLC_R(c, RC, 1)
|
||||
RLC_R(d, RD, 2)
|
||||
RLC_R(e, RE, 3)
|
||||
RLC_R(h, RH, 4)
|
||||
RLC_R(l, RL, 5)
|
||||
RLC_R(a, RA, 7)
|
||||
|
||||
RRC_R(b, RB, 0)
|
||||
RRC_R(c, RC, 1)
|
||||
RRC_R(d, RD, 2)
|
||||
RRC_R(e, RE, 3)
|
||||
RRC_R(h, RH, 4)
|
||||
RRC_R(l, RL, 5)
|
||||
RRC_R(a, RA, 7)
|
||||
|
||||
RL_R(b, RB, 0)
|
||||
RL_R(c, RC, 1)
|
||||
RL_R(d, RD, 2)
|
||||
RL_R(e, RE, 3)
|
||||
RL_R(h, RH, 4)
|
||||
RL_R(l, RL, 5)
|
||||
RL_R(a, RA, 7)
|
||||
|
||||
RR_R(b, RB, 0)
|
||||
RR_R(c, RC, 1)
|
||||
RR_R(d, RD, 2)
|
||||
RR_R(e, RE, 3)
|
||||
RR_R(h, RH, 4)
|
||||
RR_R(l, RL, 5)
|
||||
RR_R(a, RA, 7)
|
||||
|
||||
SLA_R(b, RB, 0)
|
||||
SLA_R(c, RC, 1)
|
||||
SLA_R(d, RD, 2)
|
||||
SLA_R(e, RE, 3)
|
||||
SLA_R(h, RH, 4)
|
||||
SLA_R(l, RL, 5)
|
||||
SLA_R(a, RA, 7)
|
||||
|
||||
SRA_R(b, RB, 0)
|
||||
SRA_R(c, RC, 1)
|
||||
SRA_R(d, RD, 2)
|
||||
SRA_R(e, RE, 3)
|
||||
SRA_R(h, RH, 4)
|
||||
SRA_R(l, RL, 5)
|
||||
SRA_R(a, RA, 7)
|
||||
|
||||
SLL_R(b, RB, 0)
|
||||
SLL_R(c, RC, 1)
|
||||
SLL_R(d, RD, 2)
|
||||
SLL_R(e, RE, 3)
|
||||
SLL_R(h, RH, 4)
|
||||
SLL_R(l, RL, 5)
|
||||
SLL_R(a, RA, 7)
|
||||
|
||||
SRL_R(b, RB, 0)
|
||||
SRL_R(c, RC, 1)
|
||||
SRL_R(d, RD, 2)
|
||||
SRL_R(e, RE, 3)
|
||||
SRL_R(h, RH, 4)
|
||||
SRL_R(l, RL, 5)
|
||||
SRL_R(a, RA, 7)
|
||||
|
||||
SHRIHL(rlc, RLC, 0)
|
||||
SHRIHL(rrc, RRC, 1)
|
||||
SHRIHL(rl, RLN, 2)
|
||||
SHRIHL(rr, RRN, 3)
|
||||
SHRIHL(sla, SLA, 4)
|
||||
SHRIHL(sra, SRA, 5)
|
||||
SHRIHL(sll, SLL, 6)
|
||||
SHRIHL(srl, SRL, 7)
|
||||
|
||||
#define BIT(r, n) \
|
||||
RF = (RF & ~(SF | ZF | NF)) | (r & SF) | (((~r >> n) & 0x01) << 6)
|
||||
|
||||
#define BIT_N_R(bn, rn, r, n) \
|
||||
OPDEF(bit_ ## bn ## _ ## rn, 0x40+bn*8+n) \
|
||||
{ \
|
||||
BIT(r, bn); \
|
||||
ENTIME(8); \
|
||||
}
|
||||
|
||||
#define BIT_N_IHL(bn) \
|
||||
OPDEF(bit_ ## bn ## _ihl, 0x46+bn*8) \
|
||||
{ \
|
||||
register byte btmp; \
|
||||
btmp = READ(GHL); \
|
||||
BIT(btmp, bn); \
|
||||
ENTIME(12); \
|
||||
}
|
||||
|
||||
BIT_N_R(0, b, RB, 0)
|
||||
BIT_N_R(0, c, RC, 1)
|
||||
BIT_N_R(0, d, RD, 2)
|
||||
BIT_N_R(0, e, RE, 3)
|
||||
BIT_N_R(0, h, RH, 4)
|
||||
BIT_N_R(0, l, RL, 5)
|
||||
BIT_N_R(0, a, RA, 7)
|
||||
|
||||
BIT_N_R(1, b, RB, 0)
|
||||
BIT_N_R(1, c, RC, 1)
|
||||
BIT_N_R(1, d, RD, 2)
|
||||
BIT_N_R(1, e, RE, 3)
|
||||
BIT_N_R(1, h, RH, 4)
|
||||
BIT_N_R(1, l, RL, 5)
|
||||
BIT_N_R(1, a, RA, 7)
|
||||
|
||||
BIT_N_R(2, b, RB, 0)
|
||||
BIT_N_R(2, c, RC, 1)
|
||||
BIT_N_R(2, d, RD, 2)
|
||||
BIT_N_R(2, e, RE, 3)
|
||||
BIT_N_R(2, h, RH, 4)
|
||||
BIT_N_R(2, l, RL, 5)
|
||||
BIT_N_R(2, a, RA, 7)
|
||||
|
||||
BIT_N_R(3, b, RB, 0)
|
||||
BIT_N_R(3, c, RC, 1)
|
||||
BIT_N_R(3, d, RD, 2)
|
||||
BIT_N_R(3, e, RE, 3)
|
||||
BIT_N_R(3, h, RH, 4)
|
||||
BIT_N_R(3, l, RL, 5)
|
||||
BIT_N_R(3, a, RA, 7)
|
||||
|
||||
BIT_N_R(4, b, RB, 0)
|
||||
BIT_N_R(4, c, RC, 1)
|
||||
BIT_N_R(4, d, RD, 2)
|
||||
BIT_N_R(4, e, RE, 3)
|
||||
BIT_N_R(4, h, RH, 4)
|
||||
BIT_N_R(4, l, RL, 5)
|
||||
BIT_N_R(4, a, RA, 7)
|
||||
|
||||
BIT_N_R(5, b, RB, 0)
|
||||
BIT_N_R(5, c, RC, 1)
|
||||
BIT_N_R(5, d, RD, 2)
|
||||
BIT_N_R(5, e, RE, 3)
|
||||
BIT_N_R(5, h, RH, 4)
|
||||
BIT_N_R(5, l, RL, 5)
|
||||
BIT_N_R(5, a, RA, 7)
|
||||
|
||||
BIT_N_R(6, b, RB, 0)
|
||||
BIT_N_R(6, c, RC, 1)
|
||||
BIT_N_R(6, d, RD, 2)
|
||||
BIT_N_R(6, e, RE, 3)
|
||||
BIT_N_R(6, h, RH, 4)
|
||||
BIT_N_R(6, l, RL, 5)
|
||||
BIT_N_R(6, a, RA, 7)
|
||||
|
||||
BIT_N_R(7, b, RB, 0)
|
||||
BIT_N_R(7, c, RC, 1)
|
||||
BIT_N_R(7, d, RD, 2)
|
||||
BIT_N_R(7, e, RE, 3)
|
||||
BIT_N_R(7, h, RH, 4)
|
||||
BIT_N_R(7, l, RL, 5)
|
||||
BIT_N_R(7, a, RA, 7)
|
||||
|
||||
BIT_N_IHL(0)
|
||||
BIT_N_IHL(1)
|
||||
BIT_N_IHL(2)
|
||||
BIT_N_IHL(3)
|
||||
BIT_N_IHL(4)
|
||||
BIT_N_IHL(5)
|
||||
BIT_N_IHL(6)
|
||||
BIT_N_IHL(7)
|
||||
|
||||
#define RES(r, n) r &= ~(1 << n)
|
||||
|
||||
#define RES_N_R(bn, rn, r, n) \
|
||||
OPDEF(res_ ## bn ## _ ## rn, 0x80+bn*8+n) \
|
||||
{ \
|
||||
RES(r, bn); \
|
||||
ENTIME(8); \
|
||||
}
|
||||
|
||||
#define RES_N_IHL(bn) \
|
||||
OPDEF(res_ ## bn ## _ihl, 0x86+bn*8) \
|
||||
{ \
|
||||
register byte btmp; \
|
||||
btmp = READ(GHL); \
|
||||
RES(btmp, bn); \
|
||||
WRITE(GHL, btmp); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
|
||||
RES_N_R(0, b, RB, 0)
|
||||
RES_N_R(0, c, RC, 1)
|
||||
RES_N_R(0, d, RD, 2)
|
||||
RES_N_R(0, e, RE, 3)
|
||||
RES_N_R(0, h, RH, 4)
|
||||
RES_N_R(0, l, RL, 5)
|
||||
RES_N_R(0, a, RA, 7)
|
||||
|
||||
RES_N_R(1, b, RB, 0)
|
||||
RES_N_R(1, c, RC, 1)
|
||||
RES_N_R(1, d, RD, 2)
|
||||
RES_N_R(1, e, RE, 3)
|
||||
RES_N_R(1, h, RH, 4)
|
||||
RES_N_R(1, l, RL, 5)
|
||||
RES_N_R(1, a, RA, 7)
|
||||
|
||||
RES_N_R(2, b, RB, 0)
|
||||
RES_N_R(2, c, RC, 1)
|
||||
RES_N_R(2, d, RD, 2)
|
||||
RES_N_R(2, e, RE, 3)
|
||||
RES_N_R(2, h, RH, 4)
|
||||
RES_N_R(2, l, RL, 5)
|
||||
RES_N_R(2, a, RA, 7)
|
||||
|
||||
RES_N_R(3, b, RB, 0)
|
||||
RES_N_R(3, c, RC, 1)
|
||||
RES_N_R(3, d, RD, 2)
|
||||
RES_N_R(3, e, RE, 3)
|
||||
RES_N_R(3, h, RH, 4)
|
||||
RES_N_R(3, l, RL, 5)
|
||||
RES_N_R(3, a, RA, 7)
|
||||
|
||||
RES_N_R(4, b, RB, 0)
|
||||
RES_N_R(4, c, RC, 1)
|
||||
RES_N_R(4, d, RD, 2)
|
||||
RES_N_R(4, e, RE, 3)
|
||||
RES_N_R(4, h, RH, 4)
|
||||
RES_N_R(4, l, RL, 5)
|
||||
RES_N_R(4, a, RA, 7)
|
||||
|
||||
RES_N_R(5, b, RB, 0)
|
||||
RES_N_R(5, c, RC, 1)
|
||||
RES_N_R(5, d, RD, 2)
|
||||
RES_N_R(5, e, RE, 3)
|
||||
RES_N_R(5, h, RH, 4)
|
||||
RES_N_R(5, l, RL, 5)
|
||||
RES_N_R(5, a, RA, 7)
|
||||
|
||||
RES_N_R(6, b, RB, 0)
|
||||
RES_N_R(6, c, RC, 1)
|
||||
RES_N_R(6, d, RD, 2)
|
||||
RES_N_R(6, e, RE, 3)
|
||||
RES_N_R(6, h, RH, 4)
|
||||
RES_N_R(6, l, RL, 5)
|
||||
RES_N_R(6, a, RA, 7)
|
||||
|
||||
RES_N_R(7, b, RB, 0)
|
||||
RES_N_R(7, c, RC, 1)
|
||||
RES_N_R(7, d, RD, 2)
|
||||
RES_N_R(7, e, RE, 3)
|
||||
RES_N_R(7, h, RH, 4)
|
||||
RES_N_R(7, l, RL, 5)
|
||||
RES_N_R(7, a, RA, 7)
|
||||
|
||||
RES_N_IHL(0)
|
||||
RES_N_IHL(1)
|
||||
RES_N_IHL(2)
|
||||
RES_N_IHL(3)
|
||||
RES_N_IHL(4)
|
||||
RES_N_IHL(5)
|
||||
RES_N_IHL(6)
|
||||
RES_N_IHL(7)
|
||||
|
||||
|
||||
#define SET(r, n) r |= (1 << n)
|
||||
|
||||
#define SET_N_R(bn, rn, r, n) \
|
||||
OPDEF(set_ ## bn ## _ ## rn, 0xC0+bn*8+n) \
|
||||
{ \
|
||||
SET(r, bn); \
|
||||
ENTIME(8); \
|
||||
}
|
||||
|
||||
#define SET_N_IHL(bn) \
|
||||
OPDEF(set_ ## bn ## _ihl, 0x86+bn*8) \
|
||||
{ \
|
||||
register byte btmp; \
|
||||
btmp = READ(GHL); \
|
||||
SET(btmp, bn); \
|
||||
WRITE(GHL, btmp); \
|
||||
ENTIME(15); \
|
||||
}
|
||||
|
||||
|
||||
SET_N_R(0, b, RB, 0)
|
||||
SET_N_R(0, c, RC, 1)
|
||||
SET_N_R(0, d, RD, 2)
|
||||
SET_N_R(0, e, RE, 3)
|
||||
SET_N_R(0, h, RH, 4)
|
||||
SET_N_R(0, l, RL, 5)
|
||||
SET_N_R(0, a, RA, 7)
|
||||
|
||||
SET_N_R(1, b, RB, 0)
|
||||
SET_N_R(1, c, RC, 1)
|
||||
SET_N_R(1, d, RD, 2)
|
||||
SET_N_R(1, e, RE, 3)
|
||||
SET_N_R(1, h, RH, 4)
|
||||
SET_N_R(1, l, RL, 5)
|
||||
SET_N_R(1, a, RA, 7)
|
||||
|
||||
SET_N_R(2, b, RB, 0)
|
||||
SET_N_R(2, c, RC, 1)
|
||||
SET_N_R(2, d, RD, 2)
|
||||
SET_N_R(2, e, RE, 3)
|
||||
SET_N_R(2, h, RH, 4)
|
||||
SET_N_R(2, l, RL, 5)
|
||||
SET_N_R(2, a, RA, 7)
|
||||
|
||||
SET_N_R(3, b, RB, 0)
|
||||
SET_N_R(3, c, RC, 1)
|
||||
SET_N_R(3, d, RD, 2)
|
||||
SET_N_R(3, e, RE, 3)
|
||||
SET_N_R(3, h, RH, 4)
|
||||
SET_N_R(3, l, RL, 5)
|
||||
SET_N_R(3, a, RA, 7)
|
||||
|
||||
SET_N_R(4, b, RB, 0)
|
||||
SET_N_R(4, c, RC, 1)
|
||||
SET_N_R(4, d, RD, 2)
|
||||
SET_N_R(4, e, RE, 3)
|
||||
SET_N_R(4, h, RH, 4)
|
||||
SET_N_R(4, l, RL, 5)
|
||||
SET_N_R(4, a, RA, 7)
|
||||
|
||||
SET_N_R(5, b, RB, 0)
|
||||
SET_N_R(5, c, RC, 1)
|
||||
SET_N_R(5, d, RD, 2)
|
||||
SET_N_R(5, e, RE, 3)
|
||||
SET_N_R(5, h, RH, 4)
|
||||
SET_N_R(5, l, RL, 5)
|
||||
SET_N_R(5, a, RA, 7)
|
||||
|
||||
SET_N_R(6, b, RB, 0)
|
||||
SET_N_R(6, c, RC, 1)
|
||||
SET_N_R(6, d, RD, 2)
|
||||
SET_N_R(6, e, RE, 3)
|
||||
SET_N_R(6, h, RH, 4)
|
||||
SET_N_R(6, l, RL, 5)
|
||||
SET_N_R(6, a, RA, 7)
|
||||
|
||||
SET_N_R(7, b, RB, 0)
|
||||
SET_N_R(7, c, RC, 1)
|
||||
SET_N_R(7, d, RD, 2)
|
||||
SET_N_R(7, e, RE, 3)
|
||||
SET_N_R(7, h, RH, 4)
|
||||
SET_N_R(7, l, RL, 5)
|
||||
SET_N_R(7, a, RA, 7)
|
||||
|
||||
SET_N_IHL(0)
|
||||
SET_N_IHL(1)
|
||||
SET_N_IHL(2)
|
||||
SET_N_IHL(3)
|
||||
SET_N_IHL(4)
|
||||
SET_N_IHL(5)
|
||||
SET_N_IHL(6)
|
||||
SET_N_IHL(7)
|
||||
291
apps/plugins/zxbox/z80_op6.h
Normal file
291
apps/plugins/zxbox/z80_op6.h
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 z80t z80op_rlc_b(z80t);
|
||||
extern z80t z80op_rlc_c(z80t);
|
||||
extern z80t z80op_rlc_d(z80t);
|
||||
extern z80t z80op_rlc_e(z80t);
|
||||
extern z80t z80op_rlc_h(z80t);
|
||||
extern z80t z80op_rlc_l(z80t);
|
||||
extern z80t z80op_rlc_ihl(z80t);
|
||||
extern z80t z80op_rlc_a(z80t);
|
||||
extern z80t z80op_rrc_b(z80t);
|
||||
extern z80t z80op_rrc_c(z80t);
|
||||
extern z80t z80op_rrc_d(z80t);
|
||||
extern z80t z80op_rrc_e(z80t);
|
||||
extern z80t z80op_rrc_h(z80t);
|
||||
extern z80t z80op_rrc_l(z80t);
|
||||
extern z80t z80op_rrc_ihl(z80t);
|
||||
extern z80t z80op_rrc_a(z80t);
|
||||
|
||||
extern z80t z80op_rl_b(z80t);
|
||||
extern z80t z80op_rl_c(z80t);
|
||||
extern z80t z80op_rl_d(z80t);
|
||||
extern z80t z80op_rl_e(z80t);
|
||||
extern z80t z80op_rl_h(z80t);
|
||||
extern z80t z80op_rl_l(z80t);
|
||||
extern z80t z80op_rl_ihl(z80t);
|
||||
extern z80t z80op_rl_a(z80t);
|
||||
extern z80t z80op_rr_b(z80t);
|
||||
extern z80t z80op_rr_c(z80t);
|
||||
extern z80t z80op_rr_d(z80t);
|
||||
extern z80t z80op_rr_e(z80t);
|
||||
extern z80t z80op_rr_h(z80t);
|
||||
extern z80t z80op_rr_l(z80t);
|
||||
extern z80t z80op_rr_ihl(z80t);
|
||||
extern z80t z80op_rr_a(z80t);
|
||||
|
||||
extern z80t z80op_sla_b(z80t);
|
||||
extern z80t z80op_sla_c(z80t);
|
||||
extern z80t z80op_sla_d(z80t);
|
||||
extern z80t z80op_sla_e(z80t);
|
||||
extern z80t z80op_sla_h(z80t);
|
||||
extern z80t z80op_sla_l(z80t);
|
||||
extern z80t z80op_sla_ihl(z80t);
|
||||
extern z80t z80op_sla_a(z80t);
|
||||
extern z80t z80op_sra_b(z80t);
|
||||
extern z80t z80op_sra_c(z80t);
|
||||
extern z80t z80op_sra_d(z80t);
|
||||
extern z80t z80op_sra_e(z80t);
|
||||
extern z80t z80op_sra_h(z80t);
|
||||
extern z80t z80op_sra_l(z80t);
|
||||
extern z80t z80op_sra_ihl(z80t);
|
||||
extern z80t z80op_sra_a(z80t);
|
||||
|
||||
extern z80t z80op_sll_b(z80t);
|
||||
extern z80t z80op_sll_c(z80t);
|
||||
extern z80t z80op_sll_d(z80t);
|
||||
extern z80t z80op_sll_e(z80t);
|
||||
extern z80t z80op_sll_h(z80t);
|
||||
extern z80t z80op_sll_l(z80t);
|
||||
extern z80t z80op_sll_ihl(z80t);
|
||||
extern z80t z80op_sll_a(z80t);
|
||||
extern z80t z80op_srl_b(z80t);
|
||||
extern z80t z80op_srl_c(z80t);
|
||||
extern z80t z80op_srl_d(z80t);
|
||||
extern z80t z80op_srl_e(z80t);
|
||||
extern z80t z80op_srl_h(z80t);
|
||||
extern z80t z80op_srl_l(z80t);
|
||||
extern z80t z80op_srl_ihl(z80t);
|
||||
extern z80t z80op_srl_a(z80t);
|
||||
|
||||
extern z80t z80op_bit_0_b(z80t);
|
||||
extern z80t z80op_bit_0_c(z80t);
|
||||
extern z80t z80op_bit_0_d(z80t);
|
||||
extern z80t z80op_bit_0_e(z80t);
|
||||
extern z80t z80op_bit_0_h(z80t);
|
||||
extern z80t z80op_bit_0_l(z80t);
|
||||
extern z80t z80op_bit_0_ihl(z80t);
|
||||
extern z80t z80op_bit_0_a(z80t);
|
||||
extern z80t z80op_bit_1_b(z80t);
|
||||
extern z80t z80op_bit_1_c(z80t);
|
||||
extern z80t z80op_bit_1_d(z80t);
|
||||
extern z80t z80op_bit_1_e(z80t);
|
||||
extern z80t z80op_bit_1_h(z80t);
|
||||
extern z80t z80op_bit_1_l(z80t);
|
||||
extern z80t z80op_bit_1_ihl(z80t);
|
||||
extern z80t z80op_bit_1_a(z80t);
|
||||
|
||||
extern z80t z80op_bit_2_b(z80t);
|
||||
extern z80t z80op_bit_2_c(z80t);
|
||||
extern z80t z80op_bit_2_d(z80t);
|
||||
extern z80t z80op_bit_2_e(z80t);
|
||||
extern z80t z80op_bit_2_h(z80t);
|
||||
extern z80t z80op_bit_2_l(z80t);
|
||||
extern z80t z80op_bit_2_ihl(z80t);
|
||||
extern z80t z80op_bit_2_a(z80t);
|
||||
extern z80t z80op_bit_3_b(z80t);
|
||||
extern z80t z80op_bit_3_c(z80t);
|
||||
extern z80t z80op_bit_3_d(z80t);
|
||||
extern z80t z80op_bit_3_e(z80t);
|
||||
extern z80t z80op_bit_3_h(z80t);
|
||||
extern z80t z80op_bit_3_l(z80t);
|
||||
extern z80t z80op_bit_3_ihl(z80t);
|
||||
extern z80t z80op_bit_3_a(z80t);
|
||||
|
||||
extern z80t z80op_bit_4_b(z80t);
|
||||
extern z80t z80op_bit_4_c(z80t);
|
||||
extern z80t z80op_bit_4_d(z80t);
|
||||
extern z80t z80op_bit_4_e(z80t);
|
||||
extern z80t z80op_bit_4_h(z80t);
|
||||
extern z80t z80op_bit_4_l(z80t);
|
||||
extern z80t z80op_bit_4_ihl(z80t);
|
||||
extern z80t z80op_bit_4_a(z80t);
|
||||
extern z80t z80op_bit_5_b(z80t);
|
||||
extern z80t z80op_bit_5_c(z80t);
|
||||
extern z80t z80op_bit_5_d(z80t);
|
||||
extern z80t z80op_bit_5_e(z80t);
|
||||
extern z80t z80op_bit_5_h(z80t);
|
||||
extern z80t z80op_bit_5_l(z80t);
|
||||
extern z80t z80op_bit_5_ihl(z80t);
|
||||
extern z80t z80op_bit_5_a(z80t);
|
||||
|
||||
extern z80t z80op_bit_6_b(z80t);
|
||||
extern z80t z80op_bit_6_c(z80t);
|
||||
extern z80t z80op_bit_6_d(z80t);
|
||||
extern z80t z80op_bit_6_e(z80t);
|
||||
extern z80t z80op_bit_6_h(z80t);
|
||||
extern z80t z80op_bit_6_l(z80t);
|
||||
extern z80t z80op_bit_6_ihl(z80t);
|
||||
extern z80t z80op_bit_6_a(z80t);
|
||||
extern z80t z80op_bit_7_b(z80t);
|
||||
extern z80t z80op_bit_7_c(z80t);
|
||||
extern z80t z80op_bit_7_d(z80t);
|
||||
extern z80t z80op_bit_7_e(z80t);
|
||||
extern z80t z80op_bit_7_h(z80t);
|
||||
extern z80t z80op_bit_7_l(z80t);
|
||||
extern z80t z80op_bit_7_ihl(z80t);
|
||||
extern z80t z80op_bit_7_a(z80t);
|
||||
|
||||
extern z80t z80op_res_0_b(z80t);
|
||||
extern z80t z80op_res_0_c(z80t);
|
||||
extern z80t z80op_res_0_d(z80t);
|
||||
extern z80t z80op_res_0_e(z80t);
|
||||
extern z80t z80op_res_0_h(z80t);
|
||||
extern z80t z80op_res_0_l(z80t);
|
||||
extern z80t z80op_res_0_ihl(z80t);
|
||||
extern z80t z80op_res_0_a(z80t);
|
||||
extern z80t z80op_res_1_b(z80t);
|
||||
extern z80t z80op_res_1_c(z80t);
|
||||
extern z80t z80op_res_1_d(z80t);
|
||||
extern z80t z80op_res_1_e(z80t);
|
||||
extern z80t z80op_res_1_h(z80t);
|
||||
extern z80t z80op_res_1_l(z80t);
|
||||
extern z80t z80op_res_1_ihl(z80t);
|
||||
extern z80t z80op_res_1_a(z80t);
|
||||
|
||||
extern z80t z80op_res_2_b(z80t);
|
||||
extern z80t z80op_res_2_c(z80t);
|
||||
extern z80t z80op_res_2_d(z80t);
|
||||
extern z80t z80op_res_2_e(z80t);
|
||||
extern z80t z80op_res_2_h(z80t);
|
||||
extern z80t z80op_res_2_l(z80t);
|
||||
extern z80t z80op_res_2_ihl(z80t);
|
||||
extern z80t z80op_res_2_a(z80t);
|
||||
extern z80t z80op_res_3_b(z80t);
|
||||
extern z80t z80op_res_3_c(z80t);
|
||||
extern z80t z80op_res_3_d(z80t);
|
||||
extern z80t z80op_res_3_e(z80t);
|
||||
extern z80t z80op_res_3_h(z80t);
|
||||
extern z80t z80op_res_3_l(z80t);
|
||||
extern z80t z80op_res_3_ihl(z80t);
|
||||
extern z80t z80op_res_3_a(z80t);
|
||||
|
||||
extern z80t z80op_res_4_b(z80t);
|
||||
extern z80t z80op_res_4_c(z80t);
|
||||
extern z80t z80op_res_4_d(z80t);
|
||||
extern z80t z80op_res_4_e(z80t);
|
||||
extern z80t z80op_res_4_h(z80t);
|
||||
extern z80t z80op_res_4_l(z80t);
|
||||
extern z80t z80op_res_4_ihl(z80t);
|
||||
extern z80t z80op_res_4_a(z80t);
|
||||
extern z80t z80op_res_5_b(z80t);
|
||||
extern z80t z80op_res_5_c(z80t);
|
||||
extern z80t z80op_res_5_d(z80t);
|
||||
extern z80t z80op_res_5_e(z80t);
|
||||
extern z80t z80op_res_5_h(z80t);
|
||||
extern z80t z80op_res_5_l(z80t);
|
||||
extern z80t z80op_res_5_ihl(z80t);
|
||||
extern z80t z80op_res_5_a(z80t);
|
||||
|
||||
extern z80t z80op_res_6_b(z80t);
|
||||
extern z80t z80op_res_6_c(z80t);
|
||||
extern z80t z80op_res_6_d(z80t);
|
||||
extern z80t z80op_res_6_e(z80t);
|
||||
extern z80t z80op_res_6_h(z80t);
|
||||
extern z80t z80op_res_6_l(z80t);
|
||||
extern z80t z80op_res_6_ihl(z80t);
|
||||
extern z80t z80op_res_6_a(z80t);
|
||||
extern z80t z80op_res_7_b(z80t);
|
||||
extern z80t z80op_res_7_c(z80t);
|
||||
extern z80t z80op_res_7_d(z80t);
|
||||
extern z80t z80op_res_7_e(z80t);
|
||||
extern z80t z80op_res_7_h(z80t);
|
||||
extern z80t z80op_res_7_l(z80t);
|
||||
extern z80t z80op_res_7_ihl(z80t);
|
||||
extern z80t z80op_res_7_a(z80t);
|
||||
|
||||
extern z80t z80op_set_0_b(z80t);
|
||||
extern z80t z80op_set_0_c(z80t);
|
||||
extern z80t z80op_set_0_d(z80t);
|
||||
extern z80t z80op_set_0_e(z80t);
|
||||
extern z80t z80op_set_0_h(z80t);
|
||||
extern z80t z80op_set_0_l(z80t);
|
||||
extern z80t z80op_set_0_ihl(z80t);
|
||||
extern z80t z80op_set_0_a(z80t);
|
||||
extern z80t z80op_set_1_b(z80t);
|
||||
extern z80t z80op_set_1_c(z80t);
|
||||
extern z80t z80op_set_1_d(z80t);
|
||||
extern z80t z80op_set_1_e(z80t);
|
||||
extern z80t z80op_set_1_h(z80t);
|
||||
extern z80t z80op_set_1_l(z80t);
|
||||
extern z80t z80op_set_1_ihl(z80t);
|
||||
extern z80t z80op_set_1_a(z80t);
|
||||
|
||||
extern z80t z80op_set_2_b(z80t);
|
||||
extern z80t z80op_set_2_c(z80t);
|
||||
extern z80t z80op_set_2_d(z80t);
|
||||
extern z80t z80op_set_2_e(z80t);
|
||||
extern z80t z80op_set_2_h(z80t);
|
||||
extern z80t z80op_set_2_l(z80t);
|
||||
extern z80t z80op_set_2_ihl(z80t);
|
||||
extern z80t z80op_set_2_a(z80t);
|
||||
extern z80t z80op_set_3_b(z80t);
|
||||
extern z80t z80op_set_3_c(z80t);
|
||||
extern z80t z80op_set_3_d(z80t);
|
||||
extern z80t z80op_set_3_e(z80t);
|
||||
extern z80t z80op_set_3_h(z80t);
|
||||
extern z80t z80op_set_3_l(z80t);
|
||||
extern z80t z80op_set_3_ihl(z80t);
|
||||
extern z80t z80op_set_3_a(z80t);
|
||||
|
||||
extern z80t z80op_set_4_b(z80t);
|
||||
extern z80t z80op_set_4_c(z80t);
|
||||
extern z80t z80op_set_4_d(z80t);
|
||||
extern z80t z80op_set_4_e(z80t);
|
||||
extern z80t z80op_set_4_h(z80t);
|
||||
extern z80t z80op_set_4_l(z80t);
|
||||
extern z80t z80op_set_4_ihl(z80t);
|
||||
extern z80t z80op_set_4_a(z80t);
|
||||
extern z80t z80op_set_5_b(z80t);
|
||||
extern z80t z80op_set_5_c(z80t);
|
||||
extern z80t z80op_set_5_d(z80t);
|
||||
extern z80t z80op_set_5_e(z80t);
|
||||
extern z80t z80op_set_5_h(z80t);
|
||||
extern z80t z80op_set_5_l(z80t);
|
||||
extern z80t z80op_set_5_ihl(z80t);
|
||||
extern z80t z80op_set_5_a(z80t);
|
||||
|
||||
extern z80t z80op_set_6_b(z80t);
|
||||
extern z80t z80op_set_6_c(z80t);
|
||||
extern z80t z80op_set_6_d(z80t);
|
||||
extern z80t z80op_set_6_e(z80t);
|
||||
extern z80t z80op_set_6_h(z80t);
|
||||
extern z80t z80op_set_6_l(z80t);
|
||||
extern z80t z80op_set_6_ihl(z80t);
|
||||
extern z80t z80op_set_6_a(z80t);
|
||||
extern z80t z80op_set_7_b(z80t);
|
||||
extern z80t z80op_set_7_c(z80t);
|
||||
extern z80t z80op_set_7_d(z80t);
|
||||
extern z80t z80op_set_7_e(z80t);
|
||||
extern z80t z80op_set_7_h(z80t);
|
||||
extern z80t z80op_set_7_l(z80t);
|
||||
extern z80t z80op_set_7_ihl(z80t);
|
||||
extern z80t z80op_set_7_a(z80t);
|
||||
176
apps/plugins/zxbox/z80_step.c
Normal file
176
apps/plugins/zxbox/z80_step.c
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "z80_def.h"
|
||||
|
||||
byte z80c_incf_tbl[256];
|
||||
byte z80c_decf_tbl[256];
|
||||
byte z80c_addf_tbl[256];
|
||||
byte z80c_subf_tbl[256];
|
||||
byte z80c_orf_tbl[256];
|
||||
|
||||
|
||||
void PRNM(pushpc)(void)
|
||||
{
|
||||
#ifdef PROCP
|
||||
Z80 *z80p;
|
||||
z80p = &PRNM(proc);
|
||||
#endif
|
||||
|
||||
SP--;
|
||||
PUTMEM(SP, SPP, PCH);
|
||||
SP--;
|
||||
PUTMEM(SP, SPP, PCL);
|
||||
}
|
||||
|
||||
static int parity(int b)
|
||||
{
|
||||
int i;
|
||||
int par;
|
||||
|
||||
par = 0;
|
||||
for(i = 8; i; i--) par ^= (b & 1), b >>= 1;
|
||||
return par;
|
||||
}
|
||||
|
||||
void PRNM(local_init)(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef PROCP
|
||||
Z80 *z80p;
|
||||
z80p = &PRNM(proc);
|
||||
#endif
|
||||
|
||||
for(i = 0; i < 0x100; i++) {
|
||||
z80c_incf_tbl[i] = z80c_decf_tbl[i] = z80c_orf_tbl[i] = 0;
|
||||
|
||||
z80c_orf_tbl[i] |= i & (SF | B3F | B5F);
|
||||
z80c_incf_tbl[i] |= i & (SF | B3F | B5F);
|
||||
z80c_decf_tbl[i] |= i & (SF | B3F | B5F);
|
||||
|
||||
if(!parity(i)) z80c_orf_tbl[i] |= PVF;
|
||||
}
|
||||
|
||||
z80c_incf_tbl[0] |= ZF;
|
||||
z80c_decf_tbl[0] |= ZF;
|
||||
z80c_orf_tbl[0] |= ZF;
|
||||
|
||||
z80c_incf_tbl[0x80] |= PVF;
|
||||
z80c_decf_tbl[0x7F] |= PVF;
|
||||
|
||||
for(i = 0; i < 0x100; i++) {
|
||||
int cr, c1, c2;
|
||||
int hr, h1, h2;
|
||||
int b5r;
|
||||
|
||||
cr = i & 0x80;
|
||||
c1 = i & 0x40;
|
||||
b5r = i & 0x20;
|
||||
c2 = i & 0x10;
|
||||
|
||||
hr = i & 0x08;
|
||||
h1 = i & 0x04;
|
||||
h2 = i & 0x01;
|
||||
|
||||
z80c_addf_tbl[i] = 0;
|
||||
z80c_subf_tbl[i] = 0;
|
||||
if(cr) {
|
||||
z80c_addf_tbl[i] |= SF;
|
||||
z80c_subf_tbl[i] |= SF;
|
||||
}
|
||||
if(b5r) {
|
||||
z80c_addf_tbl[i] |= B5F;
|
||||
z80c_subf_tbl[i] |= B5F;
|
||||
}
|
||||
if(hr) {
|
||||
z80c_addf_tbl[i] |= B3F;
|
||||
z80c_subf_tbl[i] |= B3F;
|
||||
}
|
||||
|
||||
if((c1 && c2) || (!cr && (c1 || c2))) z80c_addf_tbl[i] |= CF;
|
||||
if((h1 && h2) || (!hr && (h1 || h2))) z80c_addf_tbl[i] |= HF;
|
||||
|
||||
if((!c1 && !c2 && cr) || (c1 && c2 && !cr)) z80c_addf_tbl[i] |= PVF;
|
||||
|
||||
|
||||
if((c2 && cr) || (!c1 && (c2 || cr))) z80c_subf_tbl[i] |= CF;
|
||||
if((h2 && hr) || (!h1 && (h2 || hr))) z80c_subf_tbl[i] |= HF;
|
||||
|
||||
if((!c2 && !cr && c1) || (c2 && cr && !c1)) z80c_subf_tbl[i] |= PVF;
|
||||
|
||||
|
||||
z80c_subf_tbl[i] |= NF;
|
||||
}
|
||||
|
||||
|
||||
#ifdef PROCP
|
||||
TAB(incf_tbl) = z80c_incf_tbl;
|
||||
TAB(decf_tbl) = z80c_decf_tbl;
|
||||
TAB(addf_tbl) = z80c_addf_tbl;
|
||||
TAB(subf_tbl) = z80c_subf_tbl;
|
||||
TAB(orf_tbl) = z80c_orf_tbl;
|
||||
|
||||
PORT(inports) = PRNM(inports);
|
||||
PORT(outports) = PRNM(outports);
|
||||
#ifdef SPECT_MEM
|
||||
SPECP(fe_inport_high) = SPNM(fe_inport_high);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int PRNM(step)(int tc)
|
||||
{
|
||||
#ifdef PROCP
|
||||
Z80 *z80p;
|
||||
z80p = &PRNM(proc);
|
||||
#endif
|
||||
|
||||
DANM(tc) = tc;
|
||||
DANM(rl7) = RR & 0x80;
|
||||
|
||||
if(DANM(haltstate)) {
|
||||
register int nn;
|
||||
nn = (DANM(tc) - 1) / 4 + 1;
|
||||
|
||||
DANM(tc) -= 4 * nn;
|
||||
RR += nn;
|
||||
}
|
||||
else do {
|
||||
register int nextop;
|
||||
|
||||
#ifdef DEBUG_Z80
|
||||
debug_z80();
|
||||
#endif
|
||||
nextop = *PCP;
|
||||
PC++;
|
||||
|
||||
#ifdef PROCP
|
||||
z80p = (*z80c_op_tab[nextop])(z80p);
|
||||
#else
|
||||
(*z80c_op_tab[nextop])();
|
||||
#endif
|
||||
RR++;
|
||||
} while(DANM(tc) > 0);
|
||||
|
||||
RR = (RR & 0x7F) | DANM(rl7);
|
||||
return DANM(tc);
|
||||
}
|
||||
33
apps/plugins/zxbox/z80_type.h
Normal file
33
apps/plugins/zxbox/z80_type.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Z80_TYPE_H
|
||||
#define Z80_TYPE_H
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef signed char sbyte;
|
||||
typedef unsigned short dbyte;
|
||||
typedef unsigned int qbyte;
|
||||
|
||||
typedef signed char gchar;
|
||||
typedef signed short gshort;
|
||||
typedef signed int gint;
|
||||
|
||||
#endif /* Z80_TYPE_H */
|
||||
1470
apps/plugins/zxbox/z80optab.c
Normal file
1470
apps/plugins/zxbox/z80optab.c
Normal file
File diff suppressed because it is too large
Load diff
31
apps/plugins/zxbox/z80optab.h
Normal file
31
apps/plugins/zxbox/z80optab.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 1996-1998 Szeredi Miklos
|
||||
* Email: mszeredi@inf.bme.hu
|
||||
*
|
||||
* 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. See the file COPYING.
|
||||
*
|
||||
* 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 "z80_op1.h"
|
||||
#include "z80_op2.h"
|
||||
#include "z80_op3.h"
|
||||
#include "z80_op4.h"
|
||||
|
||||
#include "z80_op5.h"
|
||||
#include "z80_op6.h"
|
||||
|
||||
extern z80t z80op_special_xx(z80t);
|
||||
extern z80t z80op_special_dd_cb(z80t);
|
||||
extern z80t z80op_special_fd_cb(z80t);
|
||||
293
apps/plugins/zxbox/zxbox.c
Normal file
293
apps/plugins/zxbox/zxbox.c
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2006 Anton Romanov
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "zxconfig.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
struct plugin_api* rb;
|
||||
|
||||
#include "spkey_p.h"
|
||||
|
||||
spkeyboard kb_mkey;
|
||||
bool exit_requested=false;
|
||||
bool clear_kbd=0;
|
||||
extern bool zxbox_menu(void);
|
||||
|
||||
/* DUMMIES ... to clean */
|
||||
unsigned int scrmul=0;
|
||||
int privatemap;
|
||||
int use_shm = 0;
|
||||
int small_screen,pause_on_iconify;
|
||||
int vga_pause_bg;
|
||||
|
||||
#ifdef USE_IRAM
|
||||
extern char iramcopy[];
|
||||
extern char iramstart[];
|
||||
extern char iramend[];
|
||||
extern char iedata[];
|
||||
extern char iend[];
|
||||
#endif
|
||||
|
||||
#include "keymaps.h"
|
||||
#include "zxvid_com.h"
|
||||
#include "spmain.h"
|
||||
#include "spperif.h"
|
||||
|
||||
struct zxbox_settings settings;
|
||||
|
||||
/* doesn't fit into .ibss */
|
||||
unsigned char image_array [ HEIGHT * WIDTH ];
|
||||
|
||||
static int previous_state;
|
||||
|
||||
#ifdef USE_GRAY
|
||||
static unsigned char *gbuf;
|
||||
static unsigned int gbuf_size = 0;
|
||||
#endif
|
||||
|
||||
long video_frames = 0;
|
||||
long start_time = 0;
|
||||
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||
{
|
||||
|
||||
rb = api;
|
||||
#if CODEC == SWCODEC && !defined SIMULATOR
|
||||
rb->pcm_play_stop();
|
||||
#endif
|
||||
rb->splash(HZ, true, "Welcome to ZXBox");
|
||||
sp_init();
|
||||
|
||||
#ifdef USE_IRAM
|
||||
/* We need to stop audio playback in order to use IRAM */
|
||||
rb->audio_stop();
|
||||
|
||||
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||
rb->memset(iedata, 0, iend - iedata);
|
||||
#endif
|
||||
|
||||
#ifdef USE_GRAY
|
||||
/* get the remainder of the plugin buffer */
|
||||
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
||||
#ifdef USE_BUFFERED_GRAY
|
||||
gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, LCD_HEIGHT, 15, 0, NULL);
|
||||
#else
|
||||
gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT, 15, 0, NULL);
|
||||
#endif /* USE_BUFFERED_GRAY */
|
||||
/* switch on grayscale overlay */
|
||||
gray_show(true);
|
||||
#endif /* USE_GRAY */
|
||||
|
||||
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
|
||||
start_time = *rb->current_tick;
|
||||
start_spectemu(parameter);
|
||||
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(false);
|
||||
#endif
|
||||
|
||||
#ifdef USE_GRAY
|
||||
gray_show(false);
|
||||
gray_release();
|
||||
#endif
|
||||
|
||||
#if CODEC == SWCODEC && !defined SIMULATOR
|
||||
rb->pcm_play_stop();
|
||||
#endif
|
||||
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
void init_spect_key(void)
|
||||
{
|
||||
clear_keystates();
|
||||
init_basekeys();
|
||||
}
|
||||
|
||||
void spkb_process_events( int evenframe )
|
||||
{
|
||||
|
||||
if(evenframe){
|
||||
int ki;
|
||||
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
||||
(CONFIG_KEYPAD == IPOD_3G_PAD)
|
||||
if (rb->button_hold())
|
||||
{
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(false);
|
||||
#endif
|
||||
exit_requested=1;
|
||||
#ifdef USE_GRAY
|
||||
gray_show(false);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int buttons = rb->button_status();
|
||||
if ( buttons == previous_state )
|
||||
return;
|
||||
previous_state = buttons;
|
||||
#if (CONFIG_KEYPAD != IPOD_4G_PAD) && \
|
||||
(CONFIG_KEYPAD != IPOD_3G_PAD)
|
||||
if (buttons & ZX_MENU)
|
||||
{
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(false);
|
||||
#endif
|
||||
exit_requested=1;
|
||||
#ifdef USE_GRAY
|
||||
gray_show(false);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
spkb_state_changed = 1;
|
||||
if (settings.kempston){
|
||||
if ( buttons & ZX_RIGHT ){
|
||||
ki = KS_TO_KEY(SK_KP_Right);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else if (buttons & ZX_LEFT){
|
||||
ki = KS_TO_KEY(SK_KP_Left);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(SK_KP_Right);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
ki = KS_TO_KEY(SK_KP_Left);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
|
||||
}
|
||||
if ( buttons & ZX_UP ){
|
||||
ki = KS_TO_KEY(SK_KP_Up);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else if (buttons & ZX_DOWN){
|
||||
ki = KS_TO_KEY(SK_KP_Down);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(SK_KP_Up);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
ki = KS_TO_KEY(SK_KP_Down);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
if ( buttons & ZX_SELECT ){
|
||||
ki = KS_TO_KEY(SK_KP_Insert);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(SK_KP_Insert);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if ( buttons & ZX_RIGHT ){
|
||||
ki = KS_TO_KEY(intkeys[3]);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(intkeys[3]);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
if ( buttons & ZX_LEFT ){
|
||||
ki = KS_TO_KEY(intkeys[2]);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(intkeys[2]);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
if ( buttons & ZX_UP ){
|
||||
ki = KS_TO_KEY(intkeys[0]);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(intkeys[0]);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
if ( buttons & ZX_DOWN ){
|
||||
ki = KS_TO_KEY(intkeys[1]);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(intkeys[1]);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
|
||||
if ( buttons & ZX_SELECT ){
|
||||
ki = KS_TO_KEY(intkeys[4]);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
}
|
||||
else{
|
||||
ki = KS_TO_KEY(intkeys[4]);
|
||||
spkb_kbstate[ki].state = 0;
|
||||
}
|
||||
}
|
||||
process_keys();
|
||||
}
|
||||
}
|
||||
|
||||
void press_key(int c){
|
||||
spkb_state_changed = 1;
|
||||
int ki;
|
||||
if ( c == 'E' )
|
||||
ki = KS_TO_KEY(SK_KP_Enter);
|
||||
else if (c == 'S' )
|
||||
ki = KS_TO_KEY(SK_KP_Space);
|
||||
else
|
||||
ki = KS_TO_KEY(c);
|
||||
spkb_kbstate[ki].state = 1;
|
||||
process_keys();
|
||||
}
|
||||
|
||||
void spkey_textmode(void)
|
||||
{
|
||||
}
|
||||
|
||||
void spkey_screenmode(void)
|
||||
{
|
||||
}
|
||||
|
||||
void spscr_refresh_colors(void)
|
||||
{
|
||||
}
|
||||
|
||||
void resize_spect_scr(int s)
|
||||
{
|
||||
/* just to disable warning */
|
||||
(void)s;
|
||||
}
|
||||
|
||||
int display_keyboard(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
497
apps/plugins/zxbox/zxbox_keyb.c
Normal file
497
apps/plugins/zxbox/zxbox_keyb.c
Normal file
|
|
@ -0,0 +1,497 @@
|
|||
#include "zxconfig.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define BUTTONBAR_HEIGHT 8
|
||||
#else
|
||||
#define BUTTONBAR_HEIGHT 0
|
||||
#endif
|
||||
|
||||
#define DEFAULT_MARGIN 6
|
||||
#define KBD_BUF_SIZE 500
|
||||
#define kbd_loaded false
|
||||
#define statusbar_size 0
|
||||
|
||||
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
||||
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||
#define KBD_SELECT BUTTON_SELECT
|
||||
#define KBD_ABORT BUTTON_OFF
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define KBD_SELECT BUTTON_PLAY
|
||||
#define KBD_ABORT BUTTON_OFF
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
|
||||
#define KBD_SELECT BUTTON_MENU
|
||||
#define KBD_ABORT BUTTON_OFF
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == GMINI100_PAD
|
||||
#define KBD_SELECT BUTTON_PLAY
|
||||
#define KBD_ABORT BUTTON_OFF
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD)
|
||||
|
||||
#define KBD_SELECT BUTTON_SELECT
|
||||
#define KBD_ABORT BUTTON_MENU
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_SCROLL_BACK
|
||||
#define KBD_DOWN BUTTON_SCROLL_FWD
|
||||
|
||||
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
||||
|
||||
/* TODO: Check keyboard mappings */
|
||||
|
||||
#define KBD_SELECT BUTTON_SELECT
|
||||
#define KBD_ABORT BUTTON_PLAY
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
|
||||
|
||||
/* TODO: Check keyboard mappings */
|
||||
|
||||
#define KBD_SELECT BUTTON_SELECT
|
||||
#define KBD_ABORT BUTTON_REC
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
||||
|
||||
#define KBD_SELECT BUTTON_SELECT
|
||||
#define KBD_ABORT BUTTON_A
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_UP
|
||||
#define KBD_DOWN BUTTON_DOWN
|
||||
|
||||
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
||||
|
||||
/* TODO: Check keyboard mappings */
|
||||
|
||||
#define KBD_SELECT BUTTON_REW
|
||||
#define KBD_ABORT BUTTON_FF
|
||||
#define KBD_LEFT BUTTON_LEFT
|
||||
#define KBD_RIGHT BUTTON_RIGHT
|
||||
#define KBD_UP BUTTON_SCROLL_UP
|
||||
#define KBD_DOWN BUTTON_SCROLL_DOWN
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct keyboard_parameters {
|
||||
const unsigned char* default_kbd;
|
||||
int DEFAULT_LINES;
|
||||
unsigned short kbd_buf[KBD_BUF_SIZE];
|
||||
int nchars;
|
||||
int font_w;
|
||||
int font_h;
|
||||
struct font* font;
|
||||
int curfont;
|
||||
int main_x;
|
||||
int main_y;
|
||||
int max_chars;
|
||||
int max_chars_text;
|
||||
int lines;
|
||||
int pages;
|
||||
int keyboard_margin;
|
||||
int old_main_y;
|
||||
int curpos;
|
||||
int leftpos;
|
||||
int page;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct keyboard_parameters param[NB_SCREENS];
|
||||
|
||||
int zx_kbd_input(char* text/*, int buflen*/)
|
||||
{
|
||||
bool done = false;
|
||||
int i, j, k, w, l;
|
||||
int text_w = 0;
|
||||
int len_utf8/*, c = 0*/;
|
||||
int editpos;
|
||||
/* int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;*/
|
||||
unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
|
||||
/*bool hangul = false;*/
|
||||
unsigned char *utf8;
|
||||
const unsigned char *p;
|
||||
bool cur_blink = true;
|
||||
int char_screen = 0;
|
||||
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
param[l].default_kbd =
|
||||
"1234567890\n"
|
||||
"qwertyuiop\n"
|
||||
"asdfghjkl\n"
|
||||
"zxcvbnm\n"
|
||||
"S\n"
|
||||
"E";
|
||||
|
||||
param[l].DEFAULT_LINES = 7;
|
||||
}
|
||||
|
||||
char outline[256];
|
||||
int button, lastbutton = 0;
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
/* Copy default keyboard to buffer */
|
||||
i = 0;
|
||||
param[l].curfont = FONT_SYSFIXED;
|
||||
p = param[l].default_kbd;
|
||||
while (*p != 0)
|
||||
p = rb->utf8decode(p, ¶m[l].kbd_buf[i++]);
|
||||
param[l].nchars = i;
|
||||
/* param[l].curfont = FONT_UI;*/
|
||||
}
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
param[l].font = rb->font_get(param[l].curfont);
|
||||
param[l].font_h = param[l].font->height;
|
||||
|
||||
/* check if FONT_UI fits the screen */
|
||||
if (2*param[l].font_h+3 + BUTTONBAR_HEIGHT > rb->screens[l]->height) {
|
||||
param[l].font = rb->font_get(FONT_SYSFIXED);
|
||||
param[l].font_h = param[l].font->height;
|
||||
param[l].curfont = FONT_SYSFIXED;
|
||||
}
|
||||
|
||||
rb->screens[l]->setfont(param[l].curfont);
|
||||
/* find max width of keyboard glyphs */
|
||||
for (i=0; i<param[l].nchars; i++) {
|
||||
w = rb->font_get_width(param[l].font, param[l].kbd_buf[i]);
|
||||
if (w > param[l].font_w)
|
||||
param[l].font_w = w;
|
||||
}
|
||||
/* Since we're going to be adding spaces, make sure that we check
|
||||
* their width too */
|
||||
w = rb->font_get_width( param[l].font, ' ' );
|
||||
if( w > param[l].font_w )
|
||||
param[l].font_w = w;
|
||||
}
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
i = 0;
|
||||
/* Pad lines with spaces */
|
||||
while( i < param[l].nchars )
|
||||
{
|
||||
if( param[l].kbd_buf[i] == '\n' )
|
||||
{
|
||||
k = ( rb->screens[l]->width / param[l].font_w )
|
||||
- i % ( rb->screens[l]->width / param[l].font_w ) - 1;
|
||||
if( k == ( rb->screens[l]->width / param[l].font_w ) - 1 )
|
||||
{
|
||||
param[l].nchars--;
|
||||
for( j = i; j < param[l].nchars; j++ )
|
||||
{
|
||||
param[l].kbd_buf[j] = param[l].kbd_buf[j+1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( param[l].nchars + k - 1 >= KBD_BUF_SIZE )
|
||||
{ /* We don't want to overflow the buffer */
|
||||
k = KBD_BUF_SIZE - param[l].nchars;
|
||||
}
|
||||
for( j = param[l].nchars + k - 1; j > i+k; j-- )
|
||||
{
|
||||
param[l].kbd_buf[j] = param[l].kbd_buf[j-k];
|
||||
}
|
||||
param[l].nchars += k;
|
||||
k++;
|
||||
while( k-- )
|
||||
{
|
||||
param[l].kbd_buf[i++] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* find max width for text string */
|
||||
utf8 = text;
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
text_w = param[l].font_w;
|
||||
while (*utf8) {
|
||||
utf8 = (unsigned char*)rb->utf8decode(utf8, &ch);
|
||||
w = rb->font_get_width(param[l].font, ch);
|
||||
if (w > text_w)
|
||||
text_w = w;
|
||||
}
|
||||
param[l].max_chars_text = rb->screens[l]->width / text_w - 2;
|
||||
|
||||
/* calculate keyboard grid size */
|
||||
param[l].max_chars = rb->screens[l]->width / param[l].font_w;
|
||||
if (!kbd_loaded) {
|
||||
param[l].lines = param[l].DEFAULT_LINES;
|
||||
param[l].keyboard_margin = DEFAULT_MARGIN;
|
||||
} else {
|
||||
param[l].lines = (rb->screens[l]->height - BUTTONBAR_HEIGHT - statusbar_size) / param[l].font_h - 1;
|
||||
param[l].keyboard_margin = rb->screens[l]->height - BUTTONBAR_HEIGHT -
|
||||
statusbar_size - (param[l].lines+1)*param[l].font_h;
|
||||
if (param[l].keyboard_margin < 3) {
|
||||
param[l].lines--;
|
||||
param[l].keyboard_margin += param[l].font_h;
|
||||
}
|
||||
if (param[l].keyboard_margin > 6)
|
||||
param[l].keyboard_margin = 6;
|
||||
}
|
||||
|
||||
param[l].pages = (param[l].nchars + (param[l].lines*param[l].max_chars-1))
|
||||
/(param[l].lines*param[l].max_chars);
|
||||
if (param[l].pages == 1 && kbd_loaded)
|
||||
param[l].lines = (param[l].nchars + param[l].max_chars - 1) / param[l].max_chars;
|
||||
|
||||
param[l].main_y = param[l].font_h*param[l].lines + param[l].keyboard_margin + statusbar_size;
|
||||
param[l].main_x = 0;
|
||||
param[l].keyboard_margin -= param[l].keyboard_margin/2;
|
||||
|
||||
}
|
||||
editpos = rb->utf8length(text);
|
||||
|
||||
|
||||
|
||||
while(!done)
|
||||
{
|
||||
len_utf8 = rb->utf8length(text);
|
||||
FOR_NB_SCREENS(l)
|
||||
rb->screens[l]->clear_display();
|
||||
|
||||
|
||||
/* draw page */
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
rb->screens[l]->setfont(param[l].curfont);
|
||||
k = param[l].page*param[l].max_chars*param[l].lines;
|
||||
for (i=j=0; j < param[l].lines && k < param[l].nchars; k++) {
|
||||
utf8 = rb->utf8encode(param[l].kbd_buf[k], outline);
|
||||
*utf8 = 0;
|
||||
rb->screens[l]->getstringsize(outline, &w, NULL);
|
||||
rb->screens[l]->putsxy(i*param[l].font_w + (param[l].font_w-w)/2, j*param[l].font_h
|
||||
+ statusbar_size, outline);
|
||||
if (++i == param[l].max_chars) {
|
||||
i = 0;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* separator */
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
rb->screens[l]->hline(0, rb->screens[l]->width - 1, param[l].main_y - param[l].keyboard_margin);
|
||||
|
||||
/* write out the text */
|
||||
#if 0
|
||||
rb->screens[l]->setfont(param[l].curfont);
|
||||
|
||||
i=j=0;
|
||||
param[l].curpos = MIN(editpos, param[l].max_chars_text
|
||||
- MIN(len_utf8 - editpos, 2));
|
||||
param[l].leftpos = editpos - param[l].curpos;
|
||||
utf8 = text + rb->utf8seek(text, param[l].leftpos);
|
||||
|
||||
text_w = param[l].font_w;
|
||||
while (*utf8 && i < param[l].max_chars_text) {
|
||||
outline[j++] = *utf8++;
|
||||
if ((*utf8 & MASK) != COMP) {
|
||||
outline[j] = 0;
|
||||
j=0;
|
||||
i++;
|
||||
rb->screens[l]->getstringsize(outline, &w, NULL);
|
||||
rb->screens[l]->putsxy(i*text_w + (text_w-w)/2, param[l].main_y, outline);
|
||||
}
|
||||
}
|
||||
|
||||
if (param[l].leftpos) {
|
||||
rb->screens[l]->getstringsize("<", &w, NULL);
|
||||
rb->screens[l]->putsxy(text_w - w, param[l].main_y, "<");
|
||||
}
|
||||
if (len_utf8 - param[l].leftpos > param[l].max_chars_text)
|
||||
rb->screens[l]->putsxy(rb->screens[l]->width - text_w, param[l].main_y, ">");
|
||||
|
||||
/* cursor */
|
||||
i = (param[l].curpos + 1) * text_w;
|
||||
if (cur_blink)
|
||||
rb->screens[l]->vline(i, param[l].main_y, param[l].main_y + param[l].font_h-1);
|
||||
|
||||
if (hangul) /* draw underbar */
|
||||
rb->screens[l]->hline(param[l].curpos*text_w, (param[l].curpos+1)*text_w,
|
||||
param[l].main_y+param[l].font_h-1);
|
||||
#endif
|
||||
}
|
||||
cur_blink = !cur_blink;
|
||||
|
||||
|
||||
/* highlight the key that has focus */
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
rb->screens[l]->set_drawmode(DRMODE_COMPLEMENT);
|
||||
rb->screens[l]->fillrect(param[l].font_w * param[l].x,
|
||||
statusbar_size + param[l].font_h * param[l].y,
|
||||
param[l].font_w, param[l].font_h);
|
||||
rb->screens[l]->set_drawmode(DRMODE_SOLID);
|
||||
}
|
||||
|
||||
|
||||
/* gui_syncstatusbar_draw(&statusbars, true);*/
|
||||
FOR_NB_SCREENS(l)
|
||||
rb->screens[l]->update();
|
||||
|
||||
button = rb->button_get_w_tmo(HZ/2);
|
||||
|
||||
switch ( button ) {
|
||||
|
||||
case KBD_ABORT:
|
||||
FOR_NB_SCREENS(l)
|
||||
rb->screens[l]->setfont(FONT_UI);
|
||||
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case KBD_RIGHT:
|
||||
case KBD_RIGHT | BUTTON_REPEAT:
|
||||
{
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
if (++param[l].x == param[l].max_chars) {
|
||||
param[l].x = 0;
|
||||
/* no dedicated flip key - flip page on wrap */
|
||||
if (++param[l].page == param[l].pages)
|
||||
param[l].page = 0;
|
||||
}
|
||||
k = (param[l].page*param[l].lines + param[l].y)*param[l].max_chars + param[l].x;
|
||||
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KBD_LEFT:
|
||||
case KBD_LEFT | BUTTON_REPEAT:
|
||||
{
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
if (param[l].x)
|
||||
param[l].x--;
|
||||
else
|
||||
{
|
||||
/* no dedicated flip key - flip page on wrap */
|
||||
if (--param[l].page < 0)
|
||||
param[l].page = (param[l].pages-1);
|
||||
param[l].x = param[l].max_chars - 1;
|
||||
}
|
||||
k = (param[l].page*param[l].lines +
|
||||
param[l].y)*param[l].max_chars + param[l].x;
|
||||
/* kbd_spellchar(param[l].kbd_buf[k]);*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case KBD_DOWN:
|
||||
case KBD_DOWN | BUTTON_REPEAT:
|
||||
{
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
if (param[l].y < param[l].lines - 1)
|
||||
param[l].y++;
|
||||
else
|
||||
param[l].y=0;
|
||||
}
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
k = (param[l].page*param[l].lines + param[l].y)*
|
||||
param[l].max_chars + param[l].x;
|
||||
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case KBD_UP:
|
||||
case KBD_UP | BUTTON_REPEAT:
|
||||
{
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
if (param[l].y)
|
||||
param[l].y--;
|
||||
else
|
||||
param[l].y = param[l].lines - 1;
|
||||
}
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
k = (param[l].page*param[l].lines + param[l].y)*
|
||||
param[l].max_chars + param[l].x;
|
||||
/*kbd_spellchar(param[l].kbd_buf[k]);*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case KBD_SELECT:
|
||||
{
|
||||
if (button == KBD_SELECT)
|
||||
char_screen = 0;
|
||||
|
||||
/* inserts the selected char */
|
||||
|
||||
/* find input char */
|
||||
k = (param[char_screen].page*param[char_screen].lines +
|
||||
param[char_screen].y)*param[char_screen].max_chars +
|
||||
param[char_screen].x;
|
||||
if (k < param[char_screen].nchars)
|
||||
ch = param[char_screen].kbd_buf[k];
|
||||
else
|
||||
ch = ' ';
|
||||
text[0]=ch;
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_NONE:
|
||||
/*gui_syncstatusbar_draw(&statusbars, false);*/
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||
FOR_NB_SCREENS(l)
|
||||
rb->screens[l]->setfont(FONT_SYSFIXED);
|
||||
break;
|
||||
|
||||
}
|
||||
if (button != BUTTON_NONE)
|
||||
{
|
||||
lastbutton = button;
|
||||
cur_blink = true;
|
||||
}
|
||||
}
|
||||
FOR_NB_SCREENS(l)
|
||||
rb->screens[l]->setfont(FONT_UI);
|
||||
return 0;
|
||||
}
|
||||
1
apps/plugins/zxbox/zxbox_keyb.h
Normal file
1
apps/plugins/zxbox/zxbox_keyb.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
int zx_kbd_input(char* text/*, int buflen*/);
|
||||
61
apps/plugins/zxbox/zxconfig.h
Normal file
61
apps/plugins/zxbox/zxconfig.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#ifndef ZXCONFIG_H
|
||||
#define ZXCONFIG_H
|
||||
|
||||
#include <plugin.h>
|
||||
extern int load_tap;
|
||||
extern bool clear_kbd;
|
||||
extern bool exit_requested;
|
||||
extern struct plugin_api* rb;
|
||||
extern void press_key(int c);
|
||||
extern long video_frames;
|
||||
extern long start_time;
|
||||
extern int intkeys[5];
|
||||
|
||||
#define ZX_WIDTH 256
|
||||
#define ZX_HEIGHT 192
|
||||
|
||||
#define SETTINGS_MIN_VERSION 2
|
||||
#define SETTINGS_VERSION 2
|
||||
|
||||
/* undef not to use grayscale lib */
|
||||
#if !defined HAVE_LCD_COLOR && LCD_PIXELFORMAT != HORIZONTAL_PACKING
|
||||
#define USE_GRAY
|
||||
#define USE_BUFFERED_GRAY
|
||||
#endif
|
||||
|
||||
|
||||
#define Z80C
|
||||
#define MULTIUSER 0
|
||||
#define DATADIR "."
|
||||
|
||||
/* Always define this for the spectrum emulator. */
|
||||
#define SPECT_MEM 1
|
||||
|
||||
/* Define if sound driver is available. */
|
||||
#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
|
||||
#define HAVE_SOUND
|
||||
#endif
|
||||
|
||||
/* Define this to use the inline intel assembly sections */
|
||||
#undef I386_ASM
|
||||
|
||||
/* Define this to use an alternative way of passing the z80 processor
|
||||
data to the z80 instruction emulation functions. May make emulation
|
||||
faster on some machines, but not on intel, and sparc. */
|
||||
#undef PROCP /* seems not to have effect on arm targets */
|
||||
/* #define PROCP */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
#endif
|
||||
99
apps/plugins/zxbox/zxvid_16bpp.c
Normal file
99
apps/plugins/zxbox/zxvid_16bpp.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#include "zxvid_com.h"
|
||||
|
||||
#if LCD_DEPTH > 4
|
||||
/* screen routines for color targets */
|
||||
|
||||
/*
|
||||
use for slightly different colors
|
||||
#define N0 0x04
|
||||
#define N1 0x34
|
||||
|
||||
#define B0 0x08
|
||||
#define B1 0x3F
|
||||
*/
|
||||
|
||||
#define N0 0x00
|
||||
#define N1 0xAA
|
||||
|
||||
#define B0 0x55
|
||||
#define B1 0xFF
|
||||
struct rgb norm_colors[COLORNUM]={
|
||||
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
|
||||
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
|
||||
|
||||
{0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
|
||||
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
|
||||
};
|
||||
|
||||
|
||||
/* since emulator uses array of bytes for screen representation
|
||||
* short 16b colors won't fit there */
|
||||
short _16bpp_colors[16] IBSS_ATTR;
|
||||
|
||||
void init_spect_scr(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 16; i++)
|
||||
sp_colors[i] = i;
|
||||
for(i = 0; i < 16; i++)
|
||||
_16bpp_colors[i] = LCD_RGBPACK(norm_colors[i].r,norm_colors[i].g,norm_colors[i].b);
|
||||
if ( settings.invert_colors ){
|
||||
for ( i = 0 ; i < 16 ; i++ )
|
||||
_16bpp_colors[i] = 0xFFFFFF - _16bpp_colors[i];
|
||||
}
|
||||
sp_image = (char *) &image_array;
|
||||
spscr_init_mask_color();
|
||||
spscr_init_line_pointers(HEIGHT);
|
||||
|
||||
}
|
||||
|
||||
void update_screen(void)
|
||||
{
|
||||
char str[80];
|
||||
fb_data *frameb;
|
||||
|
||||
int y=0;
|
||||
|
||||
#if LCD_HEIGHT >= ZX_HEIGHT && LCD_WIDTH >= ZX_WIDTH
|
||||
byte *scrptr;
|
||||
scrptr = (byte *) SPNM(image);
|
||||
frameb = rb->lcd_framebuffer;
|
||||
for ( y = 0 ; y < HEIGHT*WIDTH; y++ ){
|
||||
frameb[y] = _16bpp_colors[(unsigned)sp_image[y]];
|
||||
}
|
||||
|
||||
#else
|
||||
int x=0;
|
||||
int srcx, srcy=0; /* x / y coordinates in source image */
|
||||
unsigned char* image;
|
||||
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
|
||||
frameb = rb->lcd_framebuffer;
|
||||
for(y = 0; y < LCD_HEIGHT; y++)
|
||||
{
|
||||
srcx = 0; /* reset our x counter before each row... */
|
||||
for(x = 0; x < LCD_WIDTH; x++)
|
||||
{
|
||||
*frameb = _16bpp_colors[image[srcx>>16]];
|
||||
srcx += X_STEP; /* move through source image */
|
||||
frameb++;
|
||||
}
|
||||
srcy += Y_STEP; /* move through the source image... */
|
||||
image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
|
||||
srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
|
||||
}
|
||||
|
||||
#endif
|
||||
if ( settings.showfps ) {
|
||||
int percent=0;
|
||||
int TPF = HZ/50;/* ticks per frame */
|
||||
if ((*rb->current_tick-start_time) > TPF )
|
||||
percent = 100*video_frames/((*rb->current_tick-start_time)/TPF);
|
||||
rb->snprintf(str,sizeof(str),"%d %%",percent);
|
||||
rb->lcd_putsxy(0,0,str);
|
||||
}
|
||||
rb -> lcd_update();
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
81
apps/plugins/zxbox/zxvid_4bpp.c
Normal file
81
apps/plugins/zxbox/zxvid_4bpp.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#include "zxvid_com.h"
|
||||
|
||||
#if !defined USE_GRAY && LCD_PIXELFORMAT == HORIZONTAL_PACKING && LCD_DEPTH < 4
|
||||
/* screen routines for greyscale targets not using greyscale lib */
|
||||
#define FB_WIDTH ((LCD_WIDTH+3)/4)
|
||||
unsigned char pixmask[4] ICONST_ATTR = {
|
||||
0xC0, 0x30, 0x0C, 0x03
|
||||
};
|
||||
|
||||
void init_spect_scr(void)
|
||||
{
|
||||
sp_colors[0] = 0;/* BLACK ? */
|
||||
sp_colors[1] = 1;/* BLUE ? */
|
||||
sp_colors[2] = 1;/* RED ? */
|
||||
sp_colors[3] = 1;/* MAGENTA ? */
|
||||
sp_colors[4] = 2;/* GREEN ? */
|
||||
sp_colors[5] = 2;/* CYAN ? */
|
||||
sp_colors[6] = 3;/* YELLOW ? */
|
||||
sp_colors[7] = 3;/* WHITE ? */
|
||||
|
||||
/* same but 'light/bright' colors */
|
||||
sp_colors[8] = 1;
|
||||
sp_colors[9] = 1;
|
||||
sp_colors[10] = 1;
|
||||
sp_colors[11] = 1;
|
||||
sp_colors[12] = 2;
|
||||
sp_colors[13] = 2;
|
||||
sp_colors[14] = 3;
|
||||
sp_colors[15] = 3;
|
||||
|
||||
if ( !settings.invert_colors ){
|
||||
int i;
|
||||
for ( i = 0 ; i < 16 ; i++ )
|
||||
sp_colors[i] = 3 - sp_colors[i];
|
||||
}
|
||||
sp_image = (char *) &image_array;
|
||||
spscr_init_mask_color();
|
||||
spscr_init_line_pointers(HEIGHT);
|
||||
|
||||
}
|
||||
void update_screen(void)
|
||||
{
|
||||
char str[80];
|
||||
|
||||
fb_data *frameb;
|
||||
int y=0;
|
||||
int x=0;
|
||||
unsigned char* image;
|
||||
int srcx, srcy=0; /* x / y coordinates in source image */
|
||||
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
|
||||
unsigned mask;
|
||||
|
||||
for(y = 0; y < LCD_HEIGHT; y++)
|
||||
{
|
||||
frameb = rb->lcd_framebuffer + (y) * FB_WIDTH;
|
||||
srcx = 0; /* reset our x counter before each row... */
|
||||
for(x = 0; x < LCD_WIDTH; x++)
|
||||
{
|
||||
mask = pixmask[x & 3];
|
||||
frameb[x >> 2] = (frameb[x >> 2] & ~mask) | ((image[(srcx>>16)]&0x3) << ((3-(x & 3 )) * 2 ));
|
||||
srcx += X_STEP; /* move through source image */
|
||||
}
|
||||
srcy += Y_STEP; /* move through the source image... */
|
||||
image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
|
||||
srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
|
||||
}
|
||||
|
||||
if ( settings.showfps ) {
|
||||
int percent=0;
|
||||
int TPF = HZ/50;/* ticks per frame */
|
||||
if ((*rb->current_tick-start_time) > TPF )
|
||||
percent = 100*video_frames/((*rb->current_tick-start_time)/TPF);
|
||||
rb->snprintf(str,sizeof(str),"%d %%",percent);
|
||||
rb->lcd_putsxy(0,0,str);
|
||||
}
|
||||
|
||||
|
||||
rb -> lcd_update();
|
||||
}
|
||||
|
||||
#endif
|
||||
28
apps/plugins/zxbox/zxvid_com.h
Normal file
28
apps/plugins/zxbox/zxvid_com.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef ZXVIDCOMMON_H
|
||||
#define ZXVIDCOMMON_H
|
||||
#include "zxconfig.h"
|
||||
|
||||
#ifdef USE_GRAY
|
||||
#include "../lib/gray.h"
|
||||
#endif
|
||||
|
||||
#include "spscr_p.h"
|
||||
#include "spmain.h"
|
||||
#include "spperif.h"
|
||||
|
||||
#if LCD_HEIGHT >= ZX_HEIGHT && LCD_WIDTH >= ZX_WIDTH
|
||||
#define WIDTH LCD_WIDTH
|
||||
#define HEIGHT LCD_HEIGHT
|
||||
#else
|
||||
#define WIDTH 320 /* 256 */
|
||||
#define HEIGHT 200 /* 192 */
|
||||
#define X_OFF ( (WIDTH - ZX_WIDTH)/2)
|
||||
#define Y_OFF ( (HEIGHT - ZX_HEIGHT)/2)
|
||||
/* calculate distance (in source) between pixels*/
|
||||
#define X_STEP ((ZX_WIDTH<<16) / LCD_WIDTH)
|
||||
#define Y_STEP ((ZX_HEIGHT<<16) / LCD_HEIGHT)
|
||||
#endif
|
||||
|
||||
extern unsigned char image_array [ HEIGHT * WIDTH ];
|
||||
|
||||
#endif /* ZXVIDCOMMON_H */
|
||||
97
apps/plugins/zxbox/zxvid_grey.c
Normal file
97
apps/plugins/zxbox/zxvid_grey.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
#include "zxvid_com.h"
|
||||
#if !defined HAVE_LCD_COLOR && defined USE_GRAY
|
||||
/*
|
||||
use for slightly different colors
|
||||
#define N0 0x04
|
||||
#define N1 0x34
|
||||
|
||||
#define B0 0x08
|
||||
#define B1 0x3F
|
||||
*/
|
||||
|
||||
/* these ones are the same as for color targets ... may be tweak for greyscale? */
|
||||
#define N0 0x00
|
||||
#define N1 0xAA
|
||||
|
||||
#define B0 0x55
|
||||
#define B1 0xFF
|
||||
static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
|
||||
|
||||
struct rgb norm_colors[COLORNUM]={
|
||||
{0,0,0},{N0,N0,N1},{N1,N0,N0},{N1,N0,N1},
|
||||
{N0,N1,N0},{N0,N1,N1},{N1,N1,N0},{N1,N1,N1},
|
||||
|
||||
{0x15,0x15,0x15},{B0,B0,B1},{B1,B0,B0},{B1,B0,B1},
|
||||
{B0,B1,B0},{B0,B1,B1},{B1,B1,B0},{B1,B1,B1}
|
||||
};
|
||||
|
||||
void init_spect_scr(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++)
|
||||
sp_colors[i] = 0.3*norm_colors[i].r + 0.59*norm_colors[i].g + 0.11*norm_colors[i].b;
|
||||
if ( settings.invert_colors ){
|
||||
int i;
|
||||
for ( i = 0 ; i < 16 ; i++ )
|
||||
sp_colors[i] = 255 - sp_colors[i];
|
||||
}
|
||||
|
||||
sp_image = (char *) &image_array;
|
||||
spscr_init_mask_color();
|
||||
spscr_init_line_pointers(HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
void update_screen(void)
|
||||
{
|
||||
char str[80];
|
||||
|
||||
int y=0;
|
||||
int x=0;
|
||||
unsigned char* image;
|
||||
int srcx, srcy=0; /* x / y coordinates in source image */
|
||||
image = sp_image + ( (Y_OFF)*(WIDTH) ) + X_OFF;
|
||||
unsigned char* buf_ptr;
|
||||
buf_ptr = (unsigned char*) &graybuffer;
|
||||
for(y = 0; y < LCD_HEIGHT; y++)
|
||||
{
|
||||
srcx = 0; /* reset our x counter before each row... */
|
||||
for(x = 0; x < LCD_WIDTH; x++)
|
||||
{
|
||||
*buf_ptr=image[(srcx>>16)];
|
||||
srcx += X_STEP; /* move through source image */
|
||||
buf_ptr++;
|
||||
}
|
||||
srcy += Y_STEP; /* move through the source image... */
|
||||
image += (srcy>>16)*WIDTH; /* and possibly to the next row. */
|
||||
srcy &= 0xffff; /* set up the y-coordinate between 0 and 1 */
|
||||
}
|
||||
|
||||
#ifdef USE_BUFFERED_GRAY
|
||||
gray_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
#endif
|
||||
|
||||
if ( settings.showfps ) {
|
||||
int percent=0;
|
||||
int TPF = HZ/50;/* ticks per frame */
|
||||
if ((*rb->current_tick-start_time) > TPF )
|
||||
percent = 100*video_frames/((*rb->current_tick-start_time)/TPF);
|
||||
rb->snprintf(str,sizeof(str),"%d %%",percent);
|
||||
#if defined USE_BUFFERED_GRAY
|
||||
gray_putsxy(0,0,str);
|
||||
#else
|
||||
LOGF(str);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if defined USE_BUFFERED_GRAY
|
||||
gray_update();
|
||||
#else
|
||||
gray_ub_gray_bitmap(graybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue