how would you tell if, for example, left was being held?
If you're going to program in assembly-language, then at this time, you've really got 4 different sources for assembly-language code that you can pull from.
1) Chris Covell's excellent projects
here, a lot of which come with source-code. Those projects tend to use the old MagicKit libraries (v2.51 or earlier).
2) The MagicKit v2.51 library source code itself.
3) The HuC library source code, which is mainly MagicKit v2.51, but with a number of speed and capability improvements. The big thing here is that HuC's startup.asm seems to be currently broken for assembly-language use, but you may be able to use the startup.asm from MagicKit v2.51.
4) My assembly language examples in
huc/examples/asm/elmer/. These are a (still expanding) bunch of projects and library code in there that show how to get started on the PCE. This code doesn't use anything from the old MagicKit libraries. A simple HuCARD ROM project can be built with the initialization stubs in
bare-startup.asm, plus whatever parts of the library you wish to include (or ignore!).
You can use the huc fonction for that, it's in the include\pce directory.You have a file called joypad.asm
That's certainly one option!
I will point out that HuC and MagicKit's joypad code isn't particularly fast, and that it confuses a mouse for a 6-button joypad.
Actually most existing PCE games don't respond well to a mouse being present in the MultiTap.
Anyway, here's a timing comarison of HuC's
include/huc/joypad.asm my joypad and mouse code in
examples/asm/elmer/include/joypad.asm ...
With SUPPORT_MOUSE ..... 2602 cycles to read 5 ports with 5 mice
With HuC library code .. 2442 cycles to read 5 ports with 5 pads (2-button)
With HuC library code .. 2442 cycles to read 5 ports with 5 pads (6-button)
With SUPPORT_MOUSE .... 2016 cycles to read 5 ports with 5 pads (2-button)
With SUPPORT_MOUSE ..... 1976 cycles to read 5 ports with 5 pads (6-button)
With SUPPORT_MOUSE .... 1618 cycles to read 3 ports with 3 mice
With SUPPORT_MOUSE ..... 1462 cycles to read 3 ports with 2 mice
With SUPPORT_MOUSE ..... 1306 cycles to read 3 ports with 1 mouse
With SUPPORT_6BUTTON ... 1235 cycles to read 5 ports with 5 pads (2-button)
With SUPPORT_6BUTTON ... 1215 cycles to read 5 ports with 5 pads (6-button)
With SUPPORT_MOUSE ..... 1126 cycles to read 2 ports with 2 mice
With SUPPORT_MOUSE ...... 970 cycles to read 2 ports with 1 mouse
Only SUPPORT_2BUTTON .... 971 cycles to read 5 ports with 5 pads (2-button)
Only SUPPORT_2BUTTON .... 861 cycles to read 5 ports with 5 pads (6-button)
With SUPPORT_MOUSE ...... 634 cycles to read 1 port with 1 mouse
Note that unlike HuC's code, my code with the SUPPORT_6BUTTON option selected actually does detect and ignore mice that are attached.
Note that unlike Hudson's original joypad code, my code with the SUPPORT_2BUTTON option selected does not get confused by a 6-button joypad in 6-button mode.
Another thing that the timings show is *why* a lot of existing games that either support a mouse, or support 6-button joypads, only support them in the first few ports of the multitap.
I'd generally recommend that games that wish to support either a 6-button joypad or a mouse, limit themselves to just reading the first 3 ports on the multitap.
The number of ports to read is a selectable option in my library.