Elmer's PC Engine Programming Resource Links
May 30, 2018 1:33:28 GMT
roflmao, Mathius, and 3 more like this
Post by elmer on May 30, 2018 1:33:28 GMT
2016-11-30 Modified this message to be a "sticky" for the all sorts of PCE & PC-FX tools and information.
2016-12-23 Updated the version of HuC.
2017-05-15 Updated the version of HuC, fix links to Charles MacDonald's docs.
2018-05-29 Copied from PCEFX and edited so that folks here can use the links.
2018-05-30 Added links to the official Hudson docs, and Bonknuts' Arcade Card info.
2018-07-07 Updated the version of HuC.
2018-12-10 Updated the version of Mednafen to 1.21.3.
2019-02-08 Added links to Emanuele Bettidi's and Raphaël Assénat's joypad info.
2019-02-10 Added Turbo Everdrive V2 documentation.
2019-02-15 Updated TED2 documentation with the latest TED_REG_MAP information.
2019-11-10 Provide alternate links to Emanuele Bettidi's joypad schematics.
2019-11-28 Updated the version of Mednafen to 1.22.2.
2021-10-04 Direct HuC users to Turboxray's github project for the latest version.
2021-10-04 Updated the version of Mednafen to 1.27.1.
2021-10-12 Add information about new ISOlink CD-ROM directory.
2021-10-27 Add link to OKI MSM5205 datasheet.
2022-01-20 Change ISOlink CD-ROM directory to 2nd sector.
2022-02-02 Slight change to ISOlink directory format.
2022-06-07 Add link to github automated HuC build.
2022-07-12 Add links to HuVideo documentation and Mooz's HuVideo github projects.
******************************************************************************
******************************************************************************
Here are some links to programming information for the PC Engine.
Hudson's Official PCE Docs
Charles MacDonald's PC Engine Hardware Notes
Charles MacDonald's SuperGrafx Hardware Notes
Charles MacDonald's PC Engine Hardware Notes (original but dead link)
Charles MacDonald's SuperGrafx Hardware Notes (original but dead link)
Tomaitheous (Bonknuts) Arcade Card Hardware Notes
Tomaitheous (Bonknuts) Downloads and Blog
Archaic Pixels HuC & PCE documentation
The Old Rover's HuC Tutorials
Emanuele Bettidi's Turbo Pad schematic
Emanuele Bettidi's Avenue Pad 3 schematic
Emanuele Bettidi's Avenue Pad 6 schematic
Emanuele Bettidi's Turbo Pad schematic (original but dead link)
Emanuele Bettidi's Avenue Pad 3 schematic (original but dead link)
Emanuele Bettidi's Avenue Pad 6 schematic (original but dead link)
Raphaël Assénat's XHE-3 adapter information
OKI MSM5205 datasheet, as used in the PCE's IFU, Super CDROM2, DUO, etc
Silent Debuggers' wiki documentation about the HuVideo format
Mooz's HuVideo extractor for Power Golf 2 - Golfer (HCD4056) and John Madden Duo CD football (TGXCD1045)
Mooz's HuVideo extractor for Ginga Ojousama Densetsu Yuna HuVIDEO CD (HCD5078) and Kuusou Kagaku Sekai Gulliver Boy (HCD5076)
******************************************************************************
******************************************************************************
The "offical" HuC build and source is now available on the github group PCE-DEVEL ...
github.com/pce-devel/huc
Github now makes automated Windows, Mac and Linux builds of the latest changes to HuC (and PCEAS) available here ...
github.com/pce-devel/huc/releases/tag/current
My ancient 2018 HuC build for 32-bit Windows is here ...
www.dropbox.com/s/of3t5vkb3mvvm1s/huc-2018-07-07.zip?dl=1
And this is the change-log for recent versions ...
******************************************************************************
******************************************************************************
Here is my customized "no-eyestrain" version of the Mednafen emulator for the PC Engine, PC-FX, VirtualBoy, PlayStation and WonderSwan.
It increases the size of Mednafen's debugging displays and fonts so that they are more pleasant to use while developing homebrew or translation patches.
The result looks something like this ...
Rather than the headache-inducing original ...
In addition, the PCE emulation has 448KB of SCD RAM (banks $50-$7F), plus the 2MB ACD RAM (banks $40-$43), and the PC-FX emulation has 8MB RAM.
The extra RAM can be useful during homebrew development as a place to store debugging-info.
It might also be useful for someone that needs some extra memory for a translation, especially since the Turbo Everdrive2 provides that extra memory.
Mednafen General Documentation
mednafen.fobby.net/documentation/
Mednafen Debugger Documentation
mednafen.fobby.net/documentation/debugger.html
You may wish to edit the mednafen.cfg configuration file to change the following settings ...
There is a prebuilt version of v1.27.1 for Windows (64-bit only) that can be downloaded here ...
Win64
This latest version updates to the current release-version of Mednafen, and includes the more-accurate PCE palette from this thread. In technical terms, it has been cross-compiled on linux, just like the official versions of Mednafen, and so it probably runs a little faster than previous versions.
There are prebuilt versions of v1.22.2 for Windows (both 32-bit and 64-bit) that can be downloaded here ...
Win32 or Win64
This latest version adds a few new features ...
*) 'D' in the debugger window dissassembles memory to a file.
*) 'H' in the memory window dumps memory to a file in hex (text) format.
*) The HuC6280 disassembler has been re-written, and provides a slightly-nicer (IMHO) output.
*) The entire 1MB cartridge space can be made writable to emulate a Turbo Everdrive 2.
The previous v1.21.3 versions for Windows (both 32-bit and 64-bit) that can be downloaded here ...
Win32 or Win64
A linux version can be built from the source code, and I've confirmed that it all works correctly on Debian.
The patches and build script themselves can be found on github here ...
github.com/jbrandwood/mednafen-happyeyes
******************************************************************************
******************************************************************************
ISOlink CD-ROM File Directory
Recent versions of ISOlink and PCEAS store a directory of the files that are in the CD-ROM's ISO track.
This directory is stored in the previously unused 515-byte space at the end of the second sector of the ISO, which contains the IPL's boot information.
As long as the game developer loads their initial boot program at memory location $3800 or higher, then when the boot program starts to execute, memory locations $35FD-$37FF will hold a copy of the directory information.
The format of the directory is shown below ...
******************************************************************************
******************************************************************************
I've created a patch for the US Turbo Grafx Super System Card so that it will safely run on the Turbo Everdrive 2.
As a by-product, this also allows the TED2 to act as a replacement for the crazily-expensive US Super System Card.
It also gives 512KB of RAM out-of-the-box for translations/homebrew.
Well ... actually it gives 768KB if you really need it, or even a full 1MB if you want to write a program that overwrites the entire System Card image, but I believe that 512KB should be enough for most people.
The new System Card image has a header so that it can be detected, and it has backup copies of the first-and-last 16 bytes of the System Card so that they can be restored if a programmer wants to enable/use any of the other TED2 hardware that's on the card.
The Street Fighter II mapper is NOT enabled, because there are some programming "gotchas" when using it, and so it was safer to disable it "by default".
To use the patch, just apply the xdelta patch to a US Super System Card image and then copy the newly patched image to your TED2's SD card.
You should see the old System Card version number replace with "TED2" and the new patch version number.
Current Patch Version 3.01 - Initial version
Patch file for USA System Card 3.0 (in xdelta3 format) ...
www.dropbox.com/s/zcz384fj47xu84u/TED2%20System%20Card%203.01%20USA.xdelta?dl=1
Patch file for JPN System Card 3.0 (in xdelta3 format) ...
www.dropbox.com/s/nuctz90ra9aoo3k/TED2%20System%20Card%203.01%20JPN.xdelta?dl=1
An xdelta3 patching utility from romhacking.net that is know to work and be easy to use ...
www.romhacking.net/utilities/704/
Source code file (for pceas assembler) ...
www.dropbox.com/s/6ufsomh9z683xwb/syscard3-ted2.asm?dl=1
******************************************************************************
******************************************************************************
Here is my programming documentation (header-file) for the Turbo Everdrive V2
2016-12-23 Updated the version of HuC.
2017-05-15 Updated the version of HuC, fix links to Charles MacDonald's docs.
2018-05-29 Copied from PCEFX and edited so that folks here can use the links.
2018-05-30 Added links to the official Hudson docs, and Bonknuts' Arcade Card info.
2018-07-07 Updated the version of HuC.
2018-12-10 Updated the version of Mednafen to 1.21.3.
2019-02-08 Added links to Emanuele Bettidi's and Raphaël Assénat's joypad info.
2019-02-10 Added Turbo Everdrive V2 documentation.
2019-02-15 Updated TED2 documentation with the latest TED_REG_MAP information.
2019-11-10 Provide alternate links to Emanuele Bettidi's joypad schematics.
2019-11-28 Updated the version of Mednafen to 1.22.2.
2021-10-04 Direct HuC users to Turboxray's github project for the latest version.
2021-10-04 Updated the version of Mednafen to 1.27.1.
2021-10-12 Add information about new ISOlink CD-ROM directory.
2021-10-27 Add link to OKI MSM5205 datasheet.
2022-01-20 Change ISOlink CD-ROM directory to 2nd sector.
2022-02-02 Slight change to ISOlink directory format.
2022-06-07 Add link to github automated HuC build.
2022-07-12 Add links to HuVideo documentation and Mooz's HuVideo github projects.
******************************************************************************
******************************************************************************
Here are some links to programming information for the PC Engine.
Hudson's Official PCE Docs
Charles MacDonald's PC Engine Hardware Notes
Charles MacDonald's SuperGrafx Hardware Notes
Charles MacDonald's PC Engine Hardware Notes (original but dead link)
Charles MacDonald's SuperGrafx Hardware Notes (original but dead link)
Tomaitheous (Bonknuts) Arcade Card Hardware Notes
Tomaitheous (Bonknuts) Downloads and Blog
Archaic Pixels HuC & PCE documentation
The Old Rover's HuC Tutorials
Emanuele Bettidi's Turbo Pad schematic
Emanuele Bettidi's Avenue Pad 3 schematic
Emanuele Bettidi's Avenue Pad 6 schematic
Emanuele Bettidi's Turbo Pad schematic (original but dead link)
Emanuele Bettidi's Avenue Pad 3 schematic (original but dead link)
Emanuele Bettidi's Avenue Pad 6 schematic (original but dead link)
Raphaël Assénat's XHE-3 adapter information
OKI MSM5205 datasheet, as used in the PCE's IFU, Super CDROM2, DUO, etc
Silent Debuggers' wiki documentation about the HuVideo format
Mooz's HuVideo extractor for Power Golf 2 - Golfer (HCD4056) and John Madden Duo CD football (TGXCD1045)
Mooz's HuVideo extractor for Ginga Ojousama Densetsu Yuna HuVIDEO CD (HCD5078) and Kuusou Kagaku Sekai Gulliver Boy (HCD5076)
******************************************************************************
******************************************************************************
The "offical" HuC build and source is now available on the github group PCE-DEVEL ...
github.com/pce-devel/huc
Github now makes automated Windows, Mac and Linux builds of the latest changes to HuC (and PCEAS) available here ...
github.com/pce-devel/huc/releases/tag/current
My ancient 2018 HuC build for 32-bit Windows is here ...
www.dropbox.com/s/of3t5vkb3mvvm1s/huc-2018-07-07.zip?dl=1
And this is the change-log for recent versions ...
All HuC project tools ...
-------------------------
- Add new "hulz" tool to compress/decompress Hudson's common LZSS data formats.
- Change "sym2inc" tool to include bank information in the output equates.
PCEAS changes ...
-----------------
- Add support for generating HuCARD ROMs up to 8MByte using the StreetFighterII
mapper. Use "-sf2" on the command line to select this.
- Add the "overlay(label_name)" operator to get the StreetFighterII mapper addr
register to write to select the correct set of 64 banks to map into $40..$7F.
For example, "stz $FFF0 + overlay( my_data )" if HuCARD bank $00 is in MPR7.
- Allow .EQU and .RSSET values to use "$x:xx:xxxx" to specify the overlay, bank
and addr.
- Allow C-style "&&" and "||" in expressions.
- Change .BANK to give an error if undefined symbols are used.
- Allow .BANK/.PAGE/.ORG within a .PROC if not in a .CODE section.
New in version 4.00:
--------------------
2022-11-09:
-----------
All HuC project tools ...
-------------------------
- Bump all HuC programs up to verion number 4.00.xx after the changes.
The version number now comes from tags in the GIT repository, rather
than being defined in each individual program.
HuC changes ...
---------------
- Change the "include/pce" directory name to "include/huc" in order to
differentiate it from the old MagicKit library name, because the HuC
libraries are not compatible with pure assembly-language development.
- Change "-v" argument to behave like HuC v3.21, which means that HuC always
asks PCEAS to generate a list file by default, and "-v" will output extra
information.
- Change "-t" argument to warn that outputting C source to the listing file
will disable some code opimizations which can then cause huge C functions
to break because they exceed 8KBytes in length.
- Add "-O" to the PCEAS command line to enable procedure-packing.
- Change startup.asm to boot CD programs at $4000 (instead of $4070), and
add a "HuC" string into the programs so that overlays can be identified.
- Remove HuC's 2nd (and never used) library font in order to save space.
- Change ac_cd_xfer() to use ISOlink's file# instead of sector numbers.
- Add lib_exclude.asm to allow a HuC project to customize library settings.
- Add Dave Shadoff's old example project that shows how to use CD overlays.
- Fix startup.asm when running an SCD program on System Card 2 (or lower).
- Fix satb_update() bug.
ISOlink changes ...
-------------------
- Add "-sgx" CLI parameter to put a SuperGRAFX string into CD-ROM projects.
- Slight changes to the CLI format to allow HuC users to name CD projects.
- Change sector location and format of the directory information.
- Change HuC location for patching directory info into HuC projects.
- Change default startup location for HuC projects.
- Add support for creating bootable PC-FX CD-ROMs.
PCEAS changes ...
-----------------
- Add a list of procedure sizes to the listing file if list_level >= 2.
- Fix PCEAS crash when it processes a .DS with a negative value.
- Improve the error messages and information dumps when there isn't enough
ROM space for all of the user's HuC or ASM procedures.
- Allow KickC to run multiple passes to resolve forward-referenced symbols.
- Fix some data directives not expanding the ROM size during early passes.
- Enable JMP from one procedure to another to allow tail-call optimization.
- Enable expression evaluation to be used in CALL pseudo-op.
- Change default procedure packing to match PCEAS v3.21, use "-O" for enable
the newer optimized procedure packing.
- Fix procedure relocation from breaking some code declared after procedures.
- Support more C escape-code sequences in strings and char constants.
- Add "-sgx" CLI parameter to put a SuperGRAFX string into CD-ROM projects.
- Fix 6502 undocumented "lax abs,y" instruction.
- Allow .EQU and .RSSET values to use "$xx:xxxx" to specify bank and addr.
- Fix zero-byte procedure relocation when at the end of a bank.
- Fix operator precedence of unary "<" and ">".
- Add "linear(label_name)" operator to get the label's 32-bit address-offset
from the start of the ROM/SCD/CD memory.
New in version 3.99:
--------------------
2021-12-31:
-----------
PCEAS changes ...
-----------------
- Bump version number to 3.25 (see ./doc/pce/usage-3.25.txt)
- Add "!" multi-labels, which are a form of "nameless" labels.
- Add label-scopes, which add a base-name to every label inside the scope.
- Add ".align", ".const", ".cpu", ".dword", ".encoding", ".ends", ".fill",
".label", ".segment", ".set", ".struct", ".text", ".var", "*="
- Allow section changes in ".proc" and ".struct", but restore original
section at ".endp" and ".ends".
- Add "{}" in ".kickc" mode, which acts as both a ".proc" and a ".struct",
and also changes the handling of JSR and RTS instructions.
- Fix broken ".opt" processing, enabling "l,m,o" options.
NB: ".opt l+" is the same as ".list"
NB: ".opt m+" is the same as ".mlist"
NB: ".opt o+" is OPT_OPTIMIZE, which does nothing.
- Add ".opt a+" to automatically use ZP addressing when labels are known.
- Add ".opt b+" to convert out-of-range branches to long-branches.
- Add ".opt c+" to allow C-style comments in source.
- Add ".opt i+" to use "()" for traditional 6502 indirect-addressing.
- Add ".opt w+" for optional warnings, i.e. when a long-branch is generated.
- Add "-kc" flag for assembling KickC-generated code.
NB: Sets ".opt c+"
- Add ".pceas" and ".kickc" to set current compatibility-mode.
NB: ".pceas" mode also sets ".opt a-,b-,i-" (default)
NB: ".kickc" mode also sets ".opt a+,b+,i+"
- Add '>' to force absolute addressing mode and match existing '<'.
- Add ".a" and ".z" instruction suffixes to force addressing mode.
- The 'A' operand in ASL/DEC/INC/LSR/ROL/ROR is now optional.
- Allow ".db/.dw/.dd" in ZP and BSS sections, but only if data is zero.
2021-11-16:
-----------
HuC changes ...
---------------
- Allow the initial SCD overlay program to be larger than 192KB.
PCEAS changes ...
-----------------
- Local labels can now start with a '@'.
- Add the ability to read graphic files in ".BMP" format.
- Add ".dd" for generating 32-bit data values.
- Only include each ".include" file once per pass, no matter how many times
that same file is included from different source files.
- Allow procedure relocation to use unused memory at the top of existing banks
and not just allocate new banks, in order to reduce overall ROM size.
- Keep _bank_base (the ASM symbol for the starting bank) the same during
both assembly passes, which makes "bank(my_symbol)" work reliably.
- Add the ability to use "bank(*)" and "page(*)" in expressions.
- Allow C-style "==" as an alternative to "=" as a comparison operator.
- The bank/page/offset of the procedure trampolines can now be set during
assembly, although changing the MPR that the procedures run in can still
only be set on the command-line (i.e. with "-newproc").
- Allow an optional expression after ".else" and ".endif" which, when present,
is checked to make sure that it matches the previous ".if".
- Allow more data, and/or a comment, to appear after a string on a ".db" line.
- Add "-newproc" to run ".proc" code in MPR6 instead of MPR5.
- Add "-strip" to remove ".proc" code that is defined by not referenced.
- Add "-ipl" option to pre-fill PCEAS memory with the 4KB of a CD-ROM IPL.
- Add "-trim" option to strip off the unused head and tail of a ROM.
ISOlink changes ...
-------------------
- Add a directory of the CD-ROM contents into the ".ISO" file's IPL sectors.
- Add the ability to use a customized IPL file on the ".ISO", or to specify
new IPL boot parameters that replace HuC's normal boot parameters.
- Add the "-asm" option to stop ISOlink from patching ".OVL" files on the CD
with HuC-specific data.
New tools ...
-------------
- Add "sym2inc" tool so that symbol files can be parsed to make include files.
- Add "wav2vox" tool for ADPCM compressing audio files to use on a PCE CD-ROM.
2020-04-14:
-----------
- Added support for "macro" append option for pragma fastcalls. The output
of the corresponding macro name is used in place of "call". It equates
to in-lining the asm code. Note: arguments are not passed to the macro.
2018-07-07:
-----------
- Fix potential buffer overrun in optimize.c that GCC7 complains about.
- Increase switch label stack size from 100 to 256.
- Allow a zero rows and/or columns size in .incchr, .inctile, etc to
autosize from the image itself.
- When using .inctile, tile #256 now wraps around onto tile #0 (with a
warning message), so that ProMotion tilemaps can use all 256 tiles.
- Add .incchrpal, .incsprpal, and .inctilepal commands to PCEAS so that
the user can create palette lookup tables for HuC maps directly from
the character, sprite and tile graphics.
- Add #incchrpal, #incsprpal, and #inctilepal commands to HuC so that
the user can create palette lookup tables for HuC maps directly from
the character, sprite and tile graphics.
- Add new example project that shows using ProMotion to create HuC maps.
- Update PCEAS documentation with latest features.
2017-02-21:
-----------
- Imported Uli's v3.98 version of HuC (https://github.com/uli/huc)
See README for all the changes that Uli made
- Applied changes from Artemio Urbina's fork of HuC
- Applied changes from Markus Buretorp's fork of HuC
- Fixed compilation on Windows with mingw-w64
- Fixed a few bugs related to Uli's improvements
- Changed System Card parameter equates to have a "__" prefix
- Changed startup.asm to allow a sound driver to use macros to integrate
- Removed Uli's support for interrupt handlers in HuC (they're too slow)
- New str/mem package to replace the old code
Note 1 : Strings are 255 bytes maximum (+ trailing null)
Note 2 : When a ptr is returned, it points to the end of the str/mem
This breaks ANSI/ISO compatibility, but is more useful
Note 3 : strncpy handing of the 'length' is the same as strncat
This breaks ANSI/ISO compatibility, but reduces code size
- Bumping version number for all the current changes
- Stop HuC adding an extra ".dw" to usage of .incchr/.incspr/.incpal/etc
- Add extra parameter to set_tile_data() to set the tile type (8 or 16)
set_tile_data(char *tile, int nb_tile, char *ptable, char type);
- Rewrite load_vram to use 32-byte TIA instructions (3x speed improvement)
- Fix writing of instructions/data that cross a bank boundary.
- Add "-pad" to PCEAS to pad out HuCard ROM images to next power-of-2 size.
- Change HuC to use "-raw" and "-pad" options to avoid 384KB HuCard problem.
- Add warning whenever a 384KB HuCard image is created to highlight problem.
******************************************************************************
******************************************************************************
Here is my customized "no-eyestrain" version of the Mednafen emulator for the PC Engine, PC-FX, VirtualBoy, PlayStation and WonderSwan.
It increases the size of Mednafen's debugging displays and fonts so that they are more pleasant to use while developing homebrew or translation patches.
The result looks something like this ...
Rather than the headache-inducing original ...
In addition, the PCE emulation has 448KB of SCD RAM (banks $50-$7F), plus the 2MB ACD RAM (banks $40-$43), and the PC-FX emulation has 8MB RAM.
The extra RAM can be useful during homebrew development as a place to store debugging-info.
It might also be useful for someone that needs some extra memory for a translation, especially since the Turbo Everdrive2 provides that extra memory.
Mednafen General Documentation
mednafen.fobby.net/documentation/
Mednafen Debugger Documentation
mednafen.fobby.net/documentation/debugger.html
You may wish to edit the mednafen.cfg configuration file to change the following settings ...
; Automatically go into the debugger's step mode after a game is loaded (this is now the default).
debugger.autostepmode 1
; Force SuperGrafx emulation.
pce.forcesgx 1
; Treat the fast-forward button as a toggle.
fftoggle 1
There is a prebuilt version of v1.27.1 for Windows (64-bit only) that can be downloaded here ...
Win64
This latest version updates to the current release-version of Mednafen, and includes the more-accurate PCE palette from this thread. In technical terms, it has been cross-compiled on linux, just like the official versions of Mednafen, and so it probably runs a little faster than previous versions.
There are prebuilt versions of v1.22.2 for Windows (both 32-bit and 64-bit) that can be downloaded here ...
Win32 or Win64
This latest version adds a few new features ...
*) 'D' in the debugger window dissassembles memory to a file.
*) 'H' in the memory window dumps memory to a file in hex (text) format.
*) The HuC6280 disassembler has been re-written, and provides a slightly-nicer (IMHO) output.
*) The entire 1MB cartridge space can be made writable to emulate a Turbo Everdrive 2.
The previous v1.21.3 versions for Windows (both 32-bit and 64-bit) that can be downloaded here ...
Win32 or Win64
A linux version can be built from the source code, and I've confirmed that it all works correctly on Debian.
The patches and build script themselves can be found on github here ...
github.com/jbrandwood/mednafen-happyeyes
******************************************************************************
******************************************************************************
ISOlink CD-ROM File Directory
Recent versions of ISOlink and PCEAS store a directory of the files that are in the CD-ROM's ISO track.
This directory is stored in the previously unused 515-byte space at the end of the second sector of the ISO, which contains the IPL's boot information.
As long as the game developer loads their initial boot program at memory location $3800 or higher, then when the boot program starts to execute, memory locations $35FD-$37FF will hold a copy of the directory information.
The format of the directory is shown below ...
$35FF: index # of CDERR file
$3600-$36FF: lo-byte of sector # of start of file (255 files max)
$3700-$37FF: hi-byte of sector # of start of file (255 files max)
$3600: # of files stored on CD-ROM
$3700: index # of 1st file beyond 128MB
File 0 is the IPL (starts at sector 0, length 2 sectors)
File 1 is the game's boot file (starts at sector 2, length ? sectors)
File 2+ are the other files that are specified on the ISOlink command line
There is space for up to 255 files (including the IPL), and the ISO track can be a maximum size of 256MB.
In order to allow for files that start beyond the 16-bit limit of the sector number, the directory stores the index of the first file that starts beyond that boundary.
Because file 0 (the IPL) always starts at LBA 0, its directory entry is used to hold the #-of-files and index-beyond-128MB instead.
Note that file 1 does not always have to start at sector 2, because a custom IPL file can be any size.
******************************************************************************
******************************************************************************
I've created a patch for the US Turbo Grafx Super System Card so that it will safely run on the Turbo Everdrive 2.
As a by-product, this also allows the TED2 to act as a replacement for the crazily-expensive US Super System Card.
It also gives 512KB of RAM out-of-the-box for translations/homebrew.
Well ... actually it gives 768KB if you really need it, or even a full 1MB if you want to write a program that overwrites the entire System Card image, but I believe that 512KB should be enough for most people.
The new System Card image has a header so that it can be detected, and it has backup copies of the first-and-last 16 bytes of the System Card so that they can be restored if a programmer wants to enable/use any of the other TED2 hardware that's on the card.
The Street Fighter II mapper is NOT enabled, because there are some programming "gotchas" when using it, and so it was safer to disable it "by default".
To use the patch, just apply the xdelta patch to a US Super System Card image and then copy the newly patched image to your TED2's SD card.
You should see the old System Card version number replace with "TED2" and the new patch version number.
Current Patch Version 3.01 - Initial version
Patch file for USA System Card 3.0 (in xdelta3 format) ...
www.dropbox.com/s/zcz384fj47xu84u/TED2%20System%20Card%203.01%20USA.xdelta?dl=1
Patch file for JPN System Card 3.0 (in xdelta3 format) ...
www.dropbox.com/s/nuctz90ra9aoo3k/TED2%20System%20Card%203.01%20JPN.xdelta?dl=1
An xdelta3 patching utility from romhacking.net that is know to work and be easy to use ...
www.romhacking.net/utilities/704/
Source code file (for pceas assembler) ...
www.dropbox.com/s/6ufsomh9z683xwb/syscard3-ted2.asm?dl=1
******************************************************************************
******************************************************************************
Here is my programming documentation (header-file) for the Turbo Everdrive V2
; ***************************************************************************
;
; Turbo Everdrive V2 Programming Notes (2019-02-15)
;
; ***************************************************************************
;
; The TED v2 contains 4MB of RAM, which it maps into the PCE's 1MB of HuCard
; address space (banks 0-127).
;
; The TED v2 maps either RAM or its FPGA into bank 0 of HuCard address space.
;
; When the TED is reset, TED_REG_CFG is set to 0 and the FPGA is mapped
; into bank 0, which the CPU reset maps into $E000-$FFFF ... and so the
; TED boots into it's firmware using the normal reset vector contained
; in the FPGA firmware ROM.
;
; In order to read/write the TED's registers you've got to map out the
; entire bank 0 of HuCard address space ... which means that you can't
; do it if your code is located in HuCard RAM bank 0, and you usually
; can't do it with interrupts enabled, either.
;
; The TED v1 only mapped 256 bytes of registers into HuCard address space,
; but the TED v2 maps the entire 8KB (you can read the TED boot code).
;
; The TED's registers are normally left "locked" to prevent problems.
;
; In order to make an changes to the registers, you must first unlock
; them by writing $A5 to TED_REG_KEY1 and $56 to TED_REG_KEY2.
;
; The registers can then be "locked" again when you're finished by
; setting a bit in the TED_REG_CFG register.
;
; It is technically possible to leave them "writable" while the RAM bank
; is selected ... but I can't think of a time that this would actually
; be useful.
;
; ***************************************************************************
;
; TED_REG_CFG Bit Settings - (N.B. The register is read-write)
;
; Bit 0 : cfg_regs_oe_off : Bank 0 mapping (0=FPGA, 1=RAM)
; Bit 1 : cfg_regs_we_off : FPGA Registers (0=access, 1=locked)
; Bit 2 : cfg_usb_boot : unknown (leave zero)
; Bit 3 : cfg_skip_eep : Normally set by KRIKzz : unknown (set to 1)
; Bit 4 : cfg_ram_we_off : RAM Read-Only? (0=writable, 1=read-only)
; Bit 5 : : SF2 2MB mapper (0=disabled, 1=enabled) Only $1ff0-$1ff3.
; Bit 6 : : unknown (leave zero)
; Bit 7 : : unknown (leave zero)
;
; ***************************************************************************
;
; TED_REG_STATE Bit Settings - (N.B. The register is read-only)
;
; Bit 0 : st_spi :
; Bit 1 : : unused (leave zero)
; Bit 2 : st_usb_wr : USB write FIFO
; Bit 3 : st_usb_rd : USB read FIFO
; Bit 4 : : unused (leave zero)
; Bit 5 : : unused (leave zero)
; Bit 6 : : unused (leave zero)
; Bit 7 : : unused (leave zero)
;
TED_FLG_SPI = 0
TED_FLG_USB_WR = 2
TED_FLG_USB_RD = 3
; ***************************************************************************
;
; TED1_REG_SPI_CFG Bit Settings - (N.B. The register is read-write)
; TED2_REG_SPI_CFG Bit Settings - (N.B. The register is read-write)
;
TED_SPI_CS = 0 ; Card Select (0=selected)
TED_SPI_SPEED = 1 ; Card Speed (0=high)
TED_SPI_AREAD = 2 ; Accelerated Read (0=off)
; ***************************************************************************
;
; TED_REG_MAP Bit Settings - (N.B. The register is write-only)
;
; Bit 0 : Low 512KB bank bit 0
; Bit 1 : Low 512KB bank bit 1
; Bit 2 : Low 512KB bank bit 2
; Bit 3 : Low 512KB bank bit 3 (ignored)
; Bit 4 : Top 512KB bank bit 0
; Bit 5 : Top 512KB bank bit 1
; Bit 6 : Top 512KB bank bit 2
; Bit 7 : Top 512KB bank bit 3 (ignored)
;
; The 4MB RAM in the TED2 is split into 8x512KB banks ...
;
; Bank 0 : Used as Top 512KB : Used for SF2 mapper $1FF0
; Bank 1 : : Used for SF2 mapper $1FF1
; Bank 2 : : Used for SF2 mapper $1FF2
; Bank 3 : : Used for SF2 mapper $1FF3
; Bank 4 : Used as Low 512KB
; Bank 5 :
; Bank 6 :
; Bank 7 : Used for TED OS
;
; The TED2 runs a HuCard image with TED_REG_MAP set to $04.
;
; !!! WARNING !!!
;
; Writing to the SF2 mapper registers only changes the bottom 2 bits
; of the 512KB bank number, so you should set the mapper to bank 0
; before enabling/using the SF2 mapper, or you'll get weird results.
;
TED_MAP_BANK0 = $04
TED_MAP_BANK1 = $14
TED_MAP_BANK2 = $24
TED_MAP_BANK3 = $34
TED_MAP_BANK4 = $44
TED_MAP_BANK5 = $54
TED_MAP_BANK6 = $64
TED_MAP_BANK7 = $74
; ***************************************************************************
;
; When TED is mapped into CPU space at $4000-$5FFF (as the TED2 OS does).
;
TED_BASE_ADDR = $4000 ; SPI registers base address
;
; TED registers that are the same for TED v1 and TED v2.
;
TED_REG_SPI = 0
TED_REG_SPI2 = 1
TED_REG_FIFO = 3
TED_REG_STATE = 4
TED_REG_KEY1 = 5
TED_REG_CFG = 6
TED_REG_MAP = 7
TED_REG_KEY2 = 10
;
; TED v1 (From KRIKzz's edio.c sample code)
;
if 0
TED_REG_SPI_CFG = 8
TED_REG_VERSION = 9
endif
;
; TED v2 (From KRIKzz's bios.s source code)
;
TED_REG_SPI_CFG = 2
TED_REG_VERSION = 8
TED_REG_I2C = 9
; ***************************************************************************
;
; Example macros in PCEAS format.
;
; This works on both TED1 and TED2.
;
; N.B. The 2nd write is only needed on the TED1.
TED_UNLOCK .macro
lda #$A5
sta TED_BASE_ADDR + TED_REG_KEY1
lda #$56
sta TED_BASE_ADDR + TED_REG_KEY2
.endm
; This works on both TED1 and TED2.
TED_CFG_FPGA .macro
sei
TED_UNLOCK
stz TED_BASE_ADDR + TED_REG_CFG
.endm
;
; TED2-only macros.
;
TED_CFG_1MB_RAM .macro
lda #%00001011
sta TED_BASE_ADDR + TED_REG_CFG
cli
.endm
TED_CFG_SF2_RAM .macro
lda #%00101011
sta TED_BASE_ADDR + TED_REG_CFG
cli
.endm
TED_CFG_1MB_ROM .macro
lda #%00011011
sta TED_BASE_ADDR + TED_REG_CFG
cli
.endm
TED_CFG_SF2_ROM .macro
lda #%00111011
sta TED_BASE_ADDR + TED_REG_CFG
cli
.endm
;
; These USB macros should work on both TED1 and TED2.
;
TED_USB_RD_TEST .macro
tst #(1 << TED_FLG_USB_RD), TED_BASE_ADDR + TED_REG_STATE
.endm
TED_USB_WR_TEST .macro
tst #(1 << TED_FLG_USB_WR), TED_BASE_ADDR + TED_REG_STATE
.endm
TED_USB_RD_WAIT .macro
.wait\@: TED_USB_RD_TEST
beq .wait\@
.endm
TED_USB_WR_WAIT .macro
.wait\@: TED_USB_WR_TEST
beq .wait\@
.endm
TED_USB_RD_BYTE .macro
TED_USB_RD_WAIT
lda TED_BASE_ADDR + TED_REG_FIFO
.endm
TED_USB_WR_BYTE .macro
TED_USB_WR_WAIT
sta TED_BASE_ADDR + TED_REG_FIFO
.endm
;
; These SPI macros would work on both TED1 and TED2,
; but the addresses of the registers are different.
;
TED_SPI_CS_OFF .macro
lda #(1 << TED_SPI_CS)
tsb TED_BASE_ADDR + TED_REG_SPI_CFG
.endm
TED_SPI_CS_ON .macro
lda #(1 << TED_SPI_CS)
trb TED_BASE_ADDR + TED_REG_SPI_CFG
.endm
TED_SPI_SPD_LO .macro
lda #(1 << TED_SPI_SPEED)
tsb TED_BASE_ADDR + TED_REG_SPI_CFG
.endm
TED_SPI_SPD_HI .macro
lda #(1 << TED_SPI_SPEED)
trb TED_BASE_ADDR + TED_REG_SPI_CFG
.endm
TED_SPI_ARD_ON .macro
lda #(1 << TED_SPI_AREAD)
tsb TED_BASE_ADDR + TED_REG_SPI_CFG
.endm
TED_SPI_ARD_OFF .macro
lda #(1 << TED_SPI_AREAD)
trb TED_BASE_ADDR + TED_REG_SPI_CFG
endm
TED_SPI_WAIT .macro
.wait\@: tst #(1 << TED_FLG_SPI), TED_BASE_ADDR + TED_REG_STATE
beq .wait\@
.endm