Commit 7023e49a authored by Stephen Kitt's avatar Stephen Kitt

Imported Upstream version 3.9.1

parent c3e7ebdb
......@@ -9,7 +9,7 @@
SSSS ttt eeeee llll llll aaaaa
===========================================================================
Release 3.9 for Linux, MacOSX and Windows
Release 3.9.1 for Linux, MacOSX and Windows
===========================================================================
The Atari 2600 Video Computer System (VCS), introduced in 1977, was the
......@@ -21,28 +21,28 @@ all of your favourite Atari 2600 games again! Stella was originally
developed for Linux by Bradford W. Mott, however, it has been ported to a
number of other platforms and is currently maintained by Stephen Anthony.
This is the 3.9 release of Stella for Linux, Mac OSX and Windows. The
This is the 3.9.1 release of Stella for Linux, Mac OSX and Windows. The
distributions currently available are:
* Binaries for Windows XP/Vista/7/8 :
Stella-3.9-win32.exe (32-bit EXE installer)
Stella-3.9-x64.exe (64-bit EXE installer)
Stella-3.9-windows.zip (32/64 bit versions)
Stella-3.9.1-win32.exe (32-bit EXE installer)
Stella-3.9.1-x64.exe (64-bit EXE installer)
Stella-3.9.1-windows.zip (32/64 bit versions)
* Binary distribution for MacOS X 32-bit & 64-bit :
Stella-3.9-macosx.dmg (32-bit Universal Binary)
Stella-3.9_intel-macosx.dmg (32/64-bit Intel/OSX 10.6+)
Stella-3.9.1-macosx.dmg (32-bit Universal Binary)
Stella-3.9.1_intel-macosx.dmg (32/64-bit Intel/OSX 10.6+)
* Binary distribution in 32-bit & 64-bit Ubuntu DEB format :
stella_3.9-1_i386.deb
stella_3.9-1_amd64.deb
stella_3.9.1-1_i386.deb
stella_3.9.1-1_amd64.deb
* Binary distribution in 32-bit & 64-bit RPM format :
stella-3.9-2.i386.rpm
stella-3.9-2.x86_64.rpm
stella-3.9.1-2.i386.rpm
stella-3.9.1-2.x86_64.rpm
* Source code distribution for all platforms :
stella-3.9-src.tar.gz
stella-3.9.1-src.tar.gz
Distribution Site
......
......@@ -12,6 +12,108 @@
Release History
===========================================================================
3.9 to 3.9.1: (August 21, 2013)
* Note: because of TIA/6502 changes, the state file format has changed
again, and old state files will not work with this release.
* Several bugfixes and improvements to the debugger:
- Improved display of debugger when using larger video modes. There
are now three font sizes, which are automatically selected when
the debugger is sized accordingly. When using larger fonts, the
extra space is now used more efficiently.
- Fixed bug in disassembly when the mirror used for the current
PC didn't match the mirror for the current bank. In this case,
the disassembler became confused and didn't properly track the
PC address.
- Fixed bug in display of current TIA frame number in the UI;
depending on how breakpoints were set, it was sometimes off by
one.
- Fixed RAM widget Search/Compare textboxes; entering any data and
then pressing 'Enter' / clicking 'OK' locked the UI until exiting
and re-entering the debugger.
- Changed display for various TIA position counters to decimal
(from hex) in the TIA tab. Related to this, all data input
widgets in the UI now have the ability to enter binary,
decimal or hex values by using the proper leading character
(\, #, $, respectively).
- Added 'INTIM Clks' to the 'I/O' tab. which shows the number of
clocks between each 'step' of the INTIM timer.
- Added ability to modify 'tiadriven' commandline argument to the
'TIA' tab, and 'ramrandom' to the 'I/O' tab. These options were
available for quite some time, but they weren't exposed in the UI.
- Added 'cpurandom' commandline argument, and associated UI item
to the 'I/O' tab. This works similar to 'ramrandom', and
randomizes the contents of the CPU registers on ROM startup.
- Added 'uhex' debugger prompt command, which toggles all
hexadecimal display between upper/lower case. This setting is
also saved in the settings file as argument 'dbg.uhex'.
- Removed 'loadsym' command from the debugger prompt, since the
DASM symbol file is always loaded anyway, making the command
redundant. Related to this, fixed loading symbols with
###.name convention; the leading number is now stripped.
- Added support for DASM lst files (created with the -l option).
For now, the contents are only partially used, to detect
constants vs. symbolic addresses in the symbol file. Eventually,
further information from the lst file may be used.
- The GRPx and PFx registers in the TIA output now show inactive
background pixels as either blanked or with the underlying object
colour, instead of always being black. This gives a more accurate
representation of how the registers are actually drawn onscreen.
Thanks to Tjoppen of AtariAge for this idea and sample code.
- The 'Source Address' locations for the CPU registers now show
labels where appropriate.
* Renamed 'Override properties' dialog (accessible from the ROM
launcher by a right-mouse-button click) to 'Power-on options', with
the following new options:
- Set start-up state for both joysticks as well as console select/
reset buttons. Related to this, added 'holdjoy01' and 'holdjoy1'
commandline arguments, and removed 'holdbutton0' argument.
- The ability to load the ROM directly from this dialog, after
changing any settings, and also to start in the debugger.
- Added more detailed information as to how to use this
functionality to the UI.
- Buttons held down are reset approx. 0.5 seconds after starting
the ROM, to simulate pressing and releasing the buttons on a
real console.
* Fixed bug when using event remapping; changes were being saved only
when launching a ROM from the launcher, not in standalone mode.
* Improved bankswitch autodetection for newer EF and EFSC ROMs
generated by batari Basic, thanks to RevEng of AtariAge.
* Added properties database info for "Princess Rescue" ROM.
* For the Linux/UNIX port:
- Fixed bug whereby a maximize button was always present in the
window title bar. Stella could not be expanded in this way,
so the button was removed.
- Added Startup notification protocol patch to the .desktop
file from Dan Fandrich.
* Updated included PNG library to latest stable version.
-Have fun!
3.8.1 to 3.9: (June 27, 2013)
* Greatly extended functionality of the debugger disassembly:
......@@ -94,8 +196,6 @@
* Updated included PNG and ZLIB libraries to latest stable version.
-Have fun!
3.8 to 3.8.1: (March 3, 2013)
......
stella (3.9.1-1) stable; urgency=high
* Version 3.9.1 release
-- Stephen Anthony <stephena@users.sf.net> Wed, 21 Aug 2013 15:47:29 -0230
stella (3.9-1) stable; urgency=high
* Version 3.9 release
......
......@@ -62,6 +62,10 @@ feature that no other 2600 debugger has; it's <b>completely</b> cross-platform.<
including automatically loading symbol files if they're named
romname.sym</li>
<li>Support for DASM list files (created with DASM's -l option),
including automatically loading list files if they're named
romname.lst</li>
<li>Built-in VCS.H symbols, if no symbol file is loaded.</li>
<li>Symbolic names in disassembly.</li>
......@@ -143,11 +147,12 @@ or right arrow keys cycles between tabs from right-to-left and left-to-right,
respectively. Pressing Tab cycles between widgets in the current tab (except
for in the Prompt area, where 'tab' is used for something else).</p>
<p>You can also enter the debugger at emulator startup by giving a breakpoint on the command line:
<p>You can also enter the debugger at emulator startup by use the 'debug' command on the command line, or alternatively within the ROM launcher in 'Power-on options':
<pre>
; will enter the debugger the first time the instruction at "kernel" runs
stella -break kernel mygame.bin
; will enter the debugger before any instructions run
stella -debug mygame.bin
; alternatively, you can use 'break' to accomplish the same thing
; $fffc is the 6502/6507 init vector. This command will break and enter the
; debugger before the first 6507 instruction runs, so you can debug the
; startup code:
......@@ -343,8 +348,7 @@ to change the meaning of an expression. The prefixes are:</p>
the section on "Startup").</p>
<p>Remember, you can use arbitrarily complex expressions with any
command that takes arguments (except the ones that take filenames,
like "loadsym").</p>
command that takes arguments.</p>
</li>
</ul>
......@@ -653,7 +657,6 @@ listfunctions - List user-defined functions
listtraps - List traps
loadconfig - Load Distella config file
loadstate - Load emulator state xx (0-9)
loadsym - Load symbol file
n - Negative Flag: set (0 or 1), or toggle (no arg)
pc - Set Program Counter to address xx
pgfx - Mark 'PGFX' range in disassembly
......@@ -682,6 +685,7 @@ listfunctions - List user-defined functions
trapread - Trap read access to address(es) xx [to yy]
trapwrite - Trap write access to address(es) xx [to yy]
type - Show disassembly type for address xx [to yy]
uhex - Toggle upper/lowercase HEX display
undef - Undefine label xx (if defined)
v - Overflow Flag: set (0 or 1), or toggle (no arg)
watch - Print contents of address xx before every prompt
......@@ -700,8 +704,7 @@ listfunctions - List user-defined functions
<p><img src="graphics/debugger_tiatab.png"></p>
<p>Most of the values on the TIA tab will be self-explanatory to a 2600
programmer. The top line (with all the hex values) displays the raw
values read from the TIA locations, as they would be seen by the CPU.<p>
programmer.<p>
<p>Many of the variables inside the TIA can only be written to by the
6502. The debugger lets you get inside the TIA and see the contents
......@@ -799,13 +802,13 @@ as illustrated:</p>
<p><img src="graphics/debugger_tiainfo.png"></p>
<p>The indicators are as follows:</p>
<ul>
<li><b>Frame</b>: The current frame number, since this ROM was loaded or reset.</li>
<li><b>F. Cyc</b>: The number of CPU cycles that have been executed this frame, since
<li><b>Frame Count</b>: The current frame number, since this ROM was loaded or reset.</li>
<li><b>Frame Cycle</b>: The number of CPU cycles that have been executed this frame, since
VSYNC was cleared at scanline 0.</li>
<li><b>Scanline</b>: The scanline that's currently being drawn. Scanline 0 is the one
on which VSYNC is cleared (after being set for 3 scanlines, as per the Stella
Programmer's Guide)</li>
<li><b>S. Cyc</b>: The number of CPU cycles that have been executed since the beginning
<li><b>Scan Cycle</b>: The number of CPU cycles that have been executed since the beginning
of the current scanline.</li>
<li><b>VSYNC &amp; VBLANK</b>: Self explanatory.</li>
<li><b>Pixel Pos</b>: The current number of visible color clocks that have been displayed on
......@@ -813,7 +816,7 @@ the current scanline, starting from the beginning of the Horizontal Blank period
During HBLANK, this value will be negative (representing the number of clocks
until the first visible one). Since there are 68 color clocks per HBLANK and
160 visible clocks per scanline, the Pixel Position will range from -68 to 159.</li>
<li><b>Color Clk</b>: The current number of total color clocks since the beginning of this
<li><b>Color Clock</b>: The current number of total color clocks since the beginning of this
scanline's HBLANK. This counter starts at zero, but otherwise displays the same
information as the Pixel Position (so Color Clock will always be 68 more than Pixel
Position, and will range from 0 to 228).</li>
......
docs/graphics/debugger_bankcomplex.png

8.87 KB | W: | H:

docs/graphics/debugger_bankcomplex.png

10.7 KB | W: | H:

docs/graphics/debugger_bankcomplex.png
docs/graphics/debugger_bankcomplex.png
docs/graphics/debugger_bankcomplex.png
docs/graphics/debugger_bankcomplex.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_banksimple.png

3.29 KB | W: | H:

docs/graphics/debugger_banksimple.png

3.54 KB | W: | H:

docs/graphics/debugger_banksimple.png
docs/graphics/debugger_banksimple.png
docs/graphics/debugger_banksimple.png
docs/graphics/debugger_banksimple.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_bpstatus.png

282 Bytes | W: | H:

docs/graphics/debugger_bpstatus.png

430 Bytes | W: | H:

docs/graphics/debugger_bpstatus.png
docs/graphics/debugger_bpstatus.png
docs/graphics/debugger_bpstatus.png
docs/graphics/debugger_bpstatus.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_cpuregs.png

2.09 KB | W: | H:

docs/graphics/debugger_cpuregs.png

2.36 KB | W: | H:

docs/graphics/debugger_cpuregs.png
docs/graphics/debugger_cpuregs.png
docs/graphics/debugger_cpuregs.png
docs/graphics/debugger_cpuregs.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_dataops.png

476 Bytes | W: | H:

docs/graphics/debugger_dataops.png

784 Bytes | W: | H:

docs/graphics/debugger_dataops.png
docs/graphics/debugger_dataops.png
docs/graphics/debugger_dataops.png
docs/graphics/debugger_dataops.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_globalbuttons.png

860 Bytes | W: | H:

docs/graphics/debugger_globalbuttons.png

1.06 KB | W: | H:

docs/graphics/debugger_globalbuttons.png
docs/graphics/debugger_globalbuttons.png
docs/graphics/debugger_globalbuttons.png
docs/graphics/debugger_globalbuttons.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_iotab.png

8.35 KB | W: | H:

docs/graphics/debugger_iotab.png

10.5 KB | W: | H:

docs/graphics/debugger_iotab.png
docs/graphics/debugger_iotab.png
docs/graphics/debugger_iotab.png
docs/graphics/debugger_iotab.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_main.png

31 KB | W: | H:

docs/graphics/debugger_main.png

42.8 KB | W: | H:

docs/graphics/debugger_main.png
docs/graphics/debugger_main.png
docs/graphics/debugger_main.png
docs/graphics/debugger_main.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_ram.png

5.91 KB | W: | H:

docs/graphics/debugger_ram.png

6.24 KB | W: | H:

docs/graphics/debugger_ram.png
docs/graphics/debugger_ram.png
docs/graphics/debugger_ram.png
docs/graphics/debugger_ram.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_ramsearch.png

5.56 KB | W: | H:

docs/graphics/debugger_ramsearch.png

5.92 KB | W: | H:

docs/graphics/debugger_ramsearch.png
docs/graphics/debugger_ramsearch.png
docs/graphics/debugger_ramsearch.png
docs/graphics/debugger_ramsearch.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_rom.png

9.16 KB | W: | H:

docs/graphics/debugger_rom.png

12.5 KB | W: | H:

docs/graphics/debugger_rom.png
docs/graphics/debugger_rom.png
docs/graphics/debugger_rom.png
docs/graphics/debugger_rom.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_romcmenu.png

9.94 KB | W: | H:

docs/graphics/debugger_romcmenu.png

13.5 KB | W: | H:

docs/graphics/debugger_romcmenu.png
docs/graphics/debugger_romcmenu.png
docs/graphics/debugger_romcmenu.png
docs/graphics/debugger_romcmenu.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_tiainfo.png

1.7 KB | W: | H:

docs/graphics/debugger_tiainfo.png

1.86 KB | W: | H:

docs/graphics/debugger_tiainfo.png
docs/graphics/debugger_tiainfo.png
docs/graphics/debugger_tiainfo.png
docs/graphics/debugger_tiainfo.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_tiaoutcmenu.png

2.65 KB | W: | H:

docs/graphics/debugger_tiaoutcmenu.png

2.82 KB | W: | H:

docs/graphics/debugger_tiaoutcmenu.png
docs/graphics/debugger_tiaoutcmenu.png
docs/graphics/debugger_tiaoutcmenu.png
docs/graphics/debugger_tiaoutcmenu.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_tiatab.png

9.19 KB | W: | H:

docs/graphics/debugger_tiatab.png

11.1 KB | W: | H:

docs/graphics/debugger_tiatab.png
docs/graphics/debugger_tiatab.png
docs/graphics/debugger_tiatab.png
docs/graphics/debugger_tiatab.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/debugger_tiazoomcmenu.png

1.18 KB | W: | H:

docs/graphics/debugger_tiazoomcmenu.png

1.28 KB | W: | H:

docs/graphics/debugger_tiazoomcmenu.png
docs/graphics/debugger_tiazoomcmenu.png
docs/graphics/debugger_tiazoomcmenu.png
docs/graphics/debugger_tiazoomcmenu.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/launcher_override.png

4.92 KB | W: | H:

docs/graphics/launcher_override.png

8.04 KB | W: | H:

docs/graphics/launcher_override.png
docs/graphics/launcher_override.png
docs/graphics/launcher_override.png
docs/graphics/launcher_override.png
  • 2-up
  • Swipe
  • Onion skin
docs/graphics/options_debugger.png

3.06 KB | W: | H:

docs/graphics/options_debugger.png

4.17 KB | W: | H:

docs/graphics/options_debugger.png
docs/graphics/options_debugger.png
docs/graphics/options_debugger.png
docs/graphics/options_debugger.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -10,7 +10,7 @@
<br><br>
<center><h2><b>A multi-platform Atari 2600 VCS emulator</b></h2></center>
<center><h4><b>Release 3.9</b></h4></center>
<center><h4><b>Release 3.9.1</b></h4></center>
<br><br>
<center><h2><b>User's Guide</b></h2></center>
......@@ -54,7 +54,7 @@
<br><br><br>
<center><b>February 1999 - June 2013</b></center>
<center><b>February 1999 - August 2013</b></center>
<center><b>The Stella Team</b></center>
<center><b><a href="http://stella.sourceforge.net">Stella Homepage</a></b></center>
......@@ -2230,8 +2230,15 @@
</tr>
<tr>
<td><pre>-holdreset</pre></td>
<td>Start the emulator with the Game Reset switch held down.</td>
<td><pre>-holdjoy0 &lt;U,D,L,R,F&gt;</pre></td>
<td>Start the emulator with the left joystick direction/button held down
(ie, use 'UF' for up and fire).</td>
</tr>
<tr>
<td><pre>-holdjoy1 &lt;U,D,L,R,F&gt;</pre></td>
<td>Start the emulator with the right joystick direction/button held down
(ie, use 'UF' for up and fire).</td>
</tr>
<tr>
......@@ -2240,8 +2247,8 @@
</tr>
<tr>
<td><pre>-holdbutton0</pre></td>
<td>Start the emulator with the left joystick button held down.</td>
<td><pre>-holdreset</pre></td>
<td>Start the emulator with the Game Reset switch held down.</td>
</tr>
<tr>
......@@ -2673,11 +2680,11 @@
contains the following items:</p>
<p><ol>
<li><p><b>Override properties</b>: Selecting this option shows a dialog whereby
ROM properties can be temporarily overriden. Selecting options from this
dialog will cause all ROMs launched after that to use those properties
you specify. Clicking <b>Default</b> will disable its functionality,
and use ROM properties as defined by the ROM itself. The dialog is as
<li><p><b>Power-on options</b>: Selecting this option shows a dialog whereby
ROM properties can be temporarily overriden, and joystick/console buttons can be
temporarily held down. Selecting options from this dialog will cause all ROMs launched
after that to use those properties you specify. Clicking <b>Defaults</b> will disable
its functionality, and use ROM properties as defined by the ROM itself. The dialog is as
follows (See <b>Advanced Configuration - <a href="#Properties">Game Properties</a></b>
for more information concerning ROM properties):</p>
<table border="5" cellpadding="2" frame="box" rules="none">
......@@ -2691,9 +2698,11 @@
<tr><td>Left Difficulty</td><td>-ld</td></tr>
<tr><td>Right Difficulty</td><td>-rd</td></tr>
<tr><td>TV Type</td><td>-tv</td></tr>
<tr><td>Hold Select down</td><td>-holdselect</td></tr>
<tr><td>Hold Reset down</td><td>-holdreset</td></tr>
<tr><td>Hold Button 0 down</td><td>-holdbutton0</td></tr>
<tr><td>Startup Mode</td><td>-debug</td></tr>
<tr><td>Left joy items</td><td>-holdjoy0</td></tr>
<tr><td>Right joy items</td><td>-holdjoy1</td></tr>
<tr><td>Console: Select</td><td>-holdselect</td></tr>
<tr><td>Console: Reset</td><td>-holdreset</td></tr>
</table>
<p></p>
</td>
......
......@@ -14,10 +14,7 @@
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.cxx 2743 2013-05-29 16:27:12Z stephena $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
// $Id: CheatCodeDialog.cxx 2763 2013-06-29 00:02:49Z stephena $
//============================================================================
#include <sstream>
......
......@@ -14,10 +14,7 @@
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.hxx 2579 2013-01-04 19:49:01Z stephena $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
// $Id: CheatCodeDialog.hxx 2763 2013-06-29 00:02:49Z stephena $
//============================================================================
#ifndef CHEAT_CODE_DIALOG_HXX
......
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2013 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Base.cxx 2790 2013-08-11 23:16:08Z stephena $
//============================================================================
#include "Base.hxx"
namespace Common {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Base::setHexUppercase(bool enable)
{
if(enable)
{
myHexflags |= std::ios_base::uppercase;
myFmt = Base::myUpperFmt;
}
else
{
myHexflags &= ~std::ios_base::uppercase;
myFmt = Base::myLowerFmt;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Base::toString(int value, Common::Base::Format outputBase)
{
static char vToS_buf[32];
if(outputBase == Base::F_DEFAULT)
outputBase = myDefaultBase;
switch(outputBase)
{
case Base::F_2: // base 2: 8 or 16 bits (depending on value)
case Base::F_2_8: // base 2: 1 byte (8 bits) wide
case Base::F_2_16: // base 2: 2 bytes (16 bits) wide
{
int places = (outputBase == Base::F_2_8 ||
(outputBase == Base::F_2 && value < 0x100)) ? 8 : 16;
vToS_buf[places] = '\0';
int bit = 1;
while(--places >= 0) {
if(value & bit) vToS_buf[places] = '1';
else vToS_buf[places] = '0';
bit <<= 1;
}
break;
}
case Base::F_10: // base 10: 3 or 5 bytes (depending on value)
if(value < 0x100)
BSPF_snprintf(vToS_buf, 4, "%3d", value);
else
BSPF_snprintf(vToS_buf, 6, "%5d", value);
break;
case Base::F_16_1: // base 16: 1 byte wide
BSPF_snprintf(vToS_buf, 2, myFmt[0], value);
break;
case Base::F_16_2: // base 16: 2 bytes wide
BSPF_snprintf(vToS_buf, 3, myFmt[1], value);
break;
case Base::F_16_4: // base 16: 4 bytes wide
BSPF_snprintf(vToS_buf, 5, myFmt[2], value);
break;
case Base::F_16_8: // base 16: 8 bytes wide
BSPF_snprintf(vToS_buf, 9, myFmt[3], value);
break;
case Base::F_16: // base 16: 2, 4, 8 bytes (depending on value)
default:
if(value < 0x100)
BSPF_snprintf(vToS_buf, 3, myFmt[1], value);
else if(value < 0x10000)
BSPF_snprintf(vToS_buf, 5, myFmt[2], value);
else
BSPF_snprintf(vToS_buf, 9, myFmt[3], value);
break;
}
return string(vToS_buf);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base::Format Base::myDefaultBase = Base::F_16;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Base::myLowerFmt[4] = {
"%1x", "%02x", "%04x", "%08x"
};
const char* Base::myUpperFmt[4] = {
"%1X", "%02X", "%04X", "%08X"
};
const char** Base::myFmt = Base::myLowerFmt;
} // Namespace Common
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2013 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Base.hxx 2770 2013-07-27 22:28:41Z stephena $
//============================================================================
#ifndef BASE_HXX
#define BASE_HXX
#include <iostream>
#include <iomanip>
#include "bspf.hxx"
namespace Common {
/**
This class implements several functions for converting integer data
into strings in multiple bases, with different formats (# of characters,
upper/lower-case, etc).
@author Stephen Anthony
*/
class Base
{
public:
// The base to use for conversion from integers to strings
// Note that the actual number of places will be determined by
// the magnitude of the value itself in the general case
enum Format {
F_16, // base 16: 2, 4, 8 bytes (depending on value)
F_16_1, // base 16: 1 byte wide
F_16_2, // base 16: 2 bytes wide
F_16_4, // base 16: 4 bytes wide
F_16_8, // base 16: 8 bytes wide
F_10, // base 10: 3 or 5 bytes (depending on value)
F_2, // base 2: 8 or 16 bits (depending on value)
F_2_8, // base 2: 1 byte (8 bits) wide
F_2_16, // base 2: 2 bytes (16 bits) wide
F_DEFAULT
};
public:
/** Get/set the number base when parsing numeric values */
static void setFormat(Base::Format base) { myDefaultBase = base; }
static Base::Format format() { return myDefaultBase; }
/** Get/set HEX output to be upper/lower case */
static void setHexUppercase(bool enable);
static bool hexUppercase() { return myHexflags & std::ios_base::uppercase; }
/** Output HEX digits in 1/2/4 byte format */
static inline std::ostream& HEX2(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(2) << std::setfill('0');
}
static inline std::ostream& HEX4(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(4) << std::setfill('0');
}
static inline std::ostream& HEX8(std::ostream& os) {
os.flags(myHexflags);
return os << std::setw(8) << std::setfill('0');
}
/** Convert integer to a string in the given base format */
static string toString(int value,
Common::Base::Format outputBase = Common::Base::F_DEFAULT);
private: // Make sure this class is never instantiated
Base() { }
private:
// Default format to use when none is specified
static Format myDefaultBase;
// Upper or lower case for HEX digits
static std::ios_base::fmtflags myHexflags;
// Format specifiers to use for sprintf (eventually we may convert
// to C++ streams
static const char* myLowerFmt[4];
static const char* myUpperFmt[4];
static const char** myFmt;
};