A PCEngine emulator forked from Hu-Go!
C C++ Other
Latest commit 648caad Sep 9, 2015 @kallisti5 HuExpress: Release 3.0.3
* Add basic Mac OS X support


         _______         _______
        |   |   |.--.--.|    ___|.--.--.-----.----.-----.-----.-----.
        |       ||  |  ||    ___||_   _|  _  |   _|  -__|__ --|__ --|
        |___|___||_____||_______||__.__|   __|__| |_____|_____|_____|

                CoreGrafx / PC Engine / TurboGrafx-16 Emulator
                               Version 3.0.3
                            September 9th, 2015

--[ DISCLAIMER ]-------------------------------------------------------------

    I can't be held responsible for any misuse of this software, it comes
    with absolutely no warranty. Use it at your own risk.

    The developer of HuExpress does *NOT* condone piracy. Please only
    use HuExpress to play PC Engine games and backups you legally own.

--[ INTRODUCTION ]-----------------------------------------------------------

    This is the first release of HuExpress, a multi-platform PC Engine

    Bugs are expected as this is all new code. Please report any
    bugs to the issue tracker at https://github.com/kallisti5/huexpress

    If you are looking for the original Hu-Go! PC Engine emulator
    see zeograd.com

--[ FORK ]-------------------------------------------------------------------

    HuExpress is a fork of the great Hu-Go! machine emulator by
    zeograd which is based on a PC Engine emulator produced by
    "Bero" (http://www.geocities.co.jp/Playtown/2004/)
    Plus improvements at Hmmx's Homepage
    (formerly, http://www.geocities.co.jp/SiliconValley/7052/).

--[ HOW TO INSTALL IT ? ]----------------------------------------------------

    Check the INSTALL file for further instructions on compiling the source
    distribution under Haiku.
--[ HOW TO USE IT ? ]--------------------------------------------------------

    You can use hugo by just typing
	huexpress [ROM] [BACKUPMEM] [OPTION]
    where ROM is the name of the ROM, ISO, ISQ, ZIP, or HCD.

    Check out the HCD section later for details.
    If ROM has no extension, HuExpress! will look for ROM.PCE then ROM.ZIP.

    ISO games must be specified with ISO extension to be recognized.

    For OPTIONS, see below...

    BACKUPMEM is the name of the file containing the backup RAM.
    These two last are optionals. The order shouldn't import but the ROM name
    must be before the name of backup RAM.

--[ HOW TO CONFIGURE HuExpress FOR PLAYING CDS ? ]------------------------------

    Under linux, you first have to configure the cd path
    (ie /dev/cdrom or such) either on the command line (-i <path>),
    or in the .ini file (variable cd_path).

    FreeBSD doesn't have yet the CD support.
    For any platform, choose the system card rom location. It's the
    rom which actually boots the CD, and it's called syscard.pce
    or such. As for all commercial roms, you can only use it if you've
    bought a system card hucard or an hardware containing it
    (Any duo for instance).

--[ SYSTEM REQUIREMENTS ]----------------------------------------------------

    -- SDL 2.0 or later

    -- SDL Mixer 2.0 or later

    -- libzip

    -- A graphics card that supports OpenGL (or software OpenGL)

    -- A sound card (only if you want to hear sound, of course).

    -- A supported platform

       -- Linux
       -- FreeBSD (untested, patches welcome)
       -- Haiku
       -- Mac OS X (homebrew)

--[ KNOWN ISSUES / BUGS ] ---------------------------------------------------

    -- Fullscreen mode is currently broken (doesn't scale)

    -- Netplay is not non-tested / functional

    -- Game state save is known to crash

--[ KEYBOARD CONTROLS ]------------------------------------------------------

    Cursor keys          Direction
    z                    Button 1
    x                    Button 2
    Tab                  Select key
    Enter                Start key
    a                    Toggle Autofire 1
    s                    Toggle autofire 2

    (These are default keys for all players)
    You can edit yours using the huexpress.ini file

    Special keys:

    Can't be changed (you can always assign these keys to "normal" ones,
    it will mostly have the "special" effects, eventually followed by the
    "normal" ones)

    tilde key (under ESC key)   Display the number of frame elapsed
             since the beginning of the track (to create subtitles)
    1 on alpha pad   Toggle the sprites display
    2 on alpha pad   Toggle the background display

-- alpha keys --
   3,4,5,6,7 and 8 on alpha pad
                     May unblock some isos
-- alpha keys --

    - on alpha pad   Lower the sound level
    = on alpha pad   Raise the sound level
    9 on alpha pad   Lower the sound quality
    0 on alpha pad   Raise the sound quality
    F1               Enter a value to search for (See details later)
    F2               Set a value in RAM (See details later)
    F3               Freeze a value in RAM (See details later)
    F4               Test purpose key, now display the draft gui
    F5               Save ScreenShot (named pict????.pcx) (disabled right now)
	F9				 Toggle full screen mode
    ESC, F12         Exit (not really useful)
    F6               Save game progression (named ROM.SAV where ROM is the
                     ROM name, Also work for iso file in file names ISO.SVI,
                     For games on CD, only 1 saved game is allowed, whatever the CD)
    F7               Load game progression
    'Num Lock'       Toggle sound dumping mode

    Keys Used on Numeric Keypad
    /                Toggle image dumping mode (in VIDEO/*.PCX)
    +                Skip one more frame per sec.
    -                Skip one less frame per sec.

--[ OPTIONS ]----------------------------------------------------------------

    There are two kinds of options. Command line or huexpress.cfg options. The
    emu first reads in the INI file then the command line, so you can
    over-ride general options.

    ** Command line options
    Can be either -FV or -F V where F is the flag and V the value

   -- c : CD emulation (This way of emulating ISO is no more compulsory
		but still works, is compulsory for using CDs)
        0 -> Only Hu-card emulation (Default)
        1 -> CD emulation on
        2 -> ISO file emulation on
        3 -> ISQ file emulation on
        4 -> BIN file emulation on (it's a raw full dump, only 1 track supported
             right now, and only if <280 Mb)
	-- f : Fullscreen model
		0 -> Start in window mode
		1 -> Start in fullscreen mode

    -- m : No bios mode
        0 -> Use bios as much as possible (Default, faster but sometime less
        1 -> Use no bios at all as possible (slower but make more game works)

    -- u : US encoded rom
        0 -> Normal rom (Default)
        1 -> US encoded rom, with invertion of bits
        HuExpress should automaticaly recognize such rom but if not (i.e.
       it works only is -u1 is specified) tell me so that I can add it
       to the database.
	-- w : Window size multiplier
		1 -> normal window size (Default)
		2 -> doubled window size
		3 -> tripled window size
		4 -> the meaning of this option is let to the reader's attention		

    ** Initialisation file options
    This file accepts comments in lines beginning with a #, the form is
    F=V where F the name of the option and V the value.

    --KEYS : it's a bit long to explain in details but I'll explain the
    method. Each function is represented by a string ("UP","DOWN","LEFT",
    "RIGHT","I","II","SELECT","START","AUTOI","AUTOII") immediately followed
    by the number of the contoller. The value is then the scancode as you
    can find it in the SCANCODE.TXT.
    When mapping a joypad related configuration, you can also use "PI","PII",
   "PSELECT", "PSTART", "PAUTOI", "PAUTOII" to map button I, II, Select, Start
    and autoI, autoII. The given value of the right being the number of the
    button on your pad, of course.
    Now, you can create up to 15 different configs by using sections like
    [config5]. These sections must be at the end of the INI files. They
    contain key definitions as explained above but also info on controllers
    e.g. putting input2=key3 will make the 2nd pad of the PC Engine to be
    controlled by the 3rd keyboard mapping (UP3, LEFT3,...). As valid strings
    you have 'input1' to 'input5' for the 5 PC Engine Gamepads (only 4
    emulated so far), and 'key1' to 'key5' for 5 key mappings, 'joy1' to
    'joy4' for 4 different joypads, 'mouse1' and 'mouse2' for 2 mice (not yet
    implemented) and 'synaplink' for a direct synaptic link (also not
    implemented ;)

    E.G. :
    Setting in the INI file






    This will change direction keys for the first player to 'u','h','j','k'
    while the second player will play with the first joypad. Note that when
    you specify a joy input, only the directions and the 2 buttons are
    remapped so you can still choose keys for select, start, autoI and
    autoII. As an example, the config1 is just a standard input with 1 player
    using a joypad so if you want to play with a joypad just uncomment the
    line with config=1. It's not very clear but the built-in menu allows easier

    -- rom_dir : Directory of your roms. It's the default directory the
    fileselector will look in. Use either '/' or '\'.
    (If no value given, current path is assumed)

    -- snd_freq : Frequency of the PCM sound output. The higher, the best
    quality but the slower. Use 11025 on slow machines and 22050 or 44100
    on fast machines. You can also give intermediate values.
       22050 Hz is default

    -- buffer_size : Size of the buffer used for PCM sound output. the best
    I can tell you here is to make tests. All depends of the frequency you use
    and your machine speed. 256 bytes is the default (Fine for XP1900+) you can
	also try 512 or 1024 if you got sound which stops at times.
	-- cd_path : Device name of the cd drive under UN*X systems.
	   /dev/cdrom is default
	-- window_size : Zoom factor when in windowed mode
	   1 to 4 are valid zoom factor (1 being the default)

--[ HCD ]--------------------------------------------------------------------

    HCD is a definition file included with TurboGrafx and PC Engine CD games.

    The HCD contains information on the game, as well as information on the
    audio CD tracks included.

    HCDFormat in doc/ documents the current HCD format for HuExpress.

    HuExpress uses a new 1.1 revision format, but should be backwards
    compatible with the old HuGO 1.0 revision.

--[ CHEATING ]---------------------------------------------------------------

    Cheating is very primitive and there is no visual help so you
    can't see what you type...


    It works! If you want to cheat with the number of lives in a game,
    first you run your game, then you type F1, the game stops. This is
    normal. It's waiting for the value to search. Then you enter the number
    of lives you actually have (In fact, it only considers the lower byte of
    the value you entered), then it makes a search and shows you the result.
    Play around and lose a life, repeat the same as above, pressing F1 and
    entering the current value. Repeat it again and again until the search
    only finds one value..
    Note carefully this value, it's the offset in RAM of a variable that
    contains the value you've entered. Is it the correct value? Easy, press
    F2, the game stops then enter the offset noted before and the new value.
    Normally you should have as many lives as you want.
    If you got a 'SEARCH FAILED' then ... it failed, see below for help.
    Using this method, the value is only changed once, but if you press F3
    then enter the offset and the value, it will be changed to the specified
    value 60 times per sec., so it looks like it is frozen. Pressing F3 then
    the address will unfreeze the value.
    Now, you can research value using a relative method. that's to say that
    instead of searching exact values, you can simply tell hu-go! to search
    for variation of the variable. e.g. each time you lose a life, you can
    make a research on -1, i.e. the variable you're looking for have been
    decreased by 1. With this method, you don't have to worry about the base
    value used to represent the variable (see hints concerning this).
    When you want to make a relative research, you have to use F1 as
    previously but instead of typing the plain number, you must prefix it
    with '+' or '-'. For the first research, you don't have to worry about
    the value you're giving, it's simply used to initialize the temporary
    file containing all the possible variables with all the current values.
    Once done, you can press F1 then '+1' or '-3' and such. From a technical
    point of view, it's possible to mix normal and relative research but if
    you do absolute research, there's no point on doing relative one.

--[ CHEATING HINTS ]---------------------------------------------------------

    -- Be careful, you may think the cheat didn't work, in fact, some
    variables aren't updated each frame so try to lose a life or if you
    modified money try to buy something... then you may see the difference.
    -- You aren't obliged to search for altered values, you can make a
    search for 2 lifes then 5 sec. later you search for 2 lifes again,...
    I suggest you search for the same value twice very quickly. If you look
    twice for the same value with only a half a sec. interval, you will
    certainly eliminate a good amount of 'bad' variables.
    -- Once a search is complete and you no longer get a lot values each
    time you search, you may stay stuck because two variables have the same
    value at the same moment (often for core and screen purposes). If that
    is the case go and check the file named ROM.FP0 (where ROM is the name
    of the rom), this contains the different possible offsets. It's up to
    -- Sessions of research are kept between two launches of the emulator.
    -- If you want to start a new session, just make a 'SEARCH FAILED'
    (Search for 25 then 6 then 79 in a very reduced interval, if you can't
    get an 'SEARCH FAILED' then you will be the next on my guinea pig list
    for trying the direct synaptic link ;).
    -- Sometimes, the value on screen isn't stored like shown, e.g. if you
    have 5 lives, maybe the variable 'LIFE' is set at 4 or 6, try to search
    for 'value'+1 or 'value'-1, it may work... (like the number of balls in
    Devil Cr*sh).
    The best to avoid this kind of problem is using relative value research.
    -- The search only works on bytes but a variable may take 2, 3 or more
    bytes. In this case try modifying the byte just 1 byte above or below
    the one you found (e.g. if you've found that putting a value at address
    X would change the money a bit, putting a value at address X+1 will
    certainly change the money a lot).

--[ DEVELOPERS CORNER ]------------------------------------------------------

    HuExpress exposes a large part of the current game internal variables
    via shared memory (only linux/freebsd for now, soon windows too).
    You can use the shared memory of identifier 25679. It contains a structure
    of type struct_hard_pce as defined in shared_memory.h (you should grab the
    source archive of course). You can then alter or read all the quite self
    explanatory variables out there. As for controlling the cpu, you can use
    the s_external_control_cpu field.
         -1  => Full speed
          0  => Emulation paused
         >0  => Number of opcodes to run before pausing

--[ FREQUENTLY ASKED QUESTIONS ]---------------------------------------------

    -Q Where is the Windows version?
    -A I honestly lack the time and interest. You *may* be
       able to compile HuExpress with mingw.  No clue how though.

    -Q Where is the Mac OS X version?
    -A If an SDL version could be easily created for OS X, patches welcome.
       No coca or XCode crap will be accepted however.

    -Q Where can I obtain games to play?
    -A Ebay, Pawn shops, Japan. Anywhere except the author.

    -Q Why would you fork Hu-GO?
    -A I decided to fork Hu-Go! because the Hu-Go! project seemed to be
       abandoned (no updates since 2005), in addition to this the BeOS
       support has been slowly breaking since 2.10.

--[ ORIGINAL HU-GO AUTHORS ]-------------------------------------------------

The following people helped out with Hu-GO.  I don't want to omit them
as they helped Zeograd write Hu-GO. (Even though I've rewritten a lot of
their code ^_^)

- David Shadoff (new kernel code, ideas, ...)
- Nyef (cd emulation, ...)
- Ixion (linux coding, sdl joypad, cd emulation, sound emulation, ...)
- Black- (gfx bug fixes, gp32 port, ...)
- Cleaner (freeBSD port fixes)
- Laurent Desnogues (cpu coding, ps2 port, ...)
- Erich Kitzmuller (sound improvement, dma bug fixes)
- Pit (gfx)
- David Michel (ideas, ...)
- Lester Barrow (linux coding, joypad support, ...)
- Mooz (ideas, ...)
- Bt Garner (ideas, ...)
- Littletux (mandrake packages, ...)
- Zoop & his gf (gfx bug fixes)

Tests by :
- Raph
- Fagemul
- NaMco
- Fixo
- Gato
- Nostromo
- Cissou
- Leeloo
- Sir Jaguar