4230c4089e
With much help from upstream to get this compiling nicely on NetBSD. 2.2.0 - added (GB) --gp2bmp convert Game Boy Printer data (produced by --xmccl) to BMP (by dbjh; based on version of gblnk (by Chris McCormick) improved by Difegue. Many thanks to Difegue for providing me with Game Boy Printer data. Thanks to Martin Eyre for documenting his findings about Game Boy Printer commands) - added (SNES) --sminis=ID convert *.srm (SRAM) file to SNES/Super Famicom Classic Mini (hakchi2) format for game with identifier ID (by dbjh) - added (SNES) --smini2srm convert SNES/Super Famicom Classic Mini (hakchi2) SRAM data to *.srm (SRAM) file (by dbjh) - added support for NetBSD (by dbjh; thanks to Thomas Klausner for his help) - updated support for OpenBSD (64-bit) (by dbjh) - updated (all) made -o also work for --rrom, --r83 and --rjoliet, just like the other rename options (--rdat, --rl and --ru) (by dbjh) - updated (SNES) improved reliability of GDSF communication for PCs with a parallel port that supports ECP (built-in or PCIe parallel port card). At last. It is essential to correctly specify ecr_offset for this to work (by dbjh; many thanks to Mystic_Merlin for testing) - updated (SNES) improved --ufosd by adding specific support for 10 and 12 Mbit HiROMs and implementing a generic way to set the SRAM mapping bytes (by dbjh; thanks to Revenant for the information and Trenton_net for testing) - added (SNES) --xufosd send ROM to Super UFO Pro 8 SD. Be sure to use a tool like Zadig to add libusb-0.1 (libusb-win32) support (by dbjh; thanks to Revenant for the information and Trenton_net and Revenant for testing) - updated (SNES) added NTSC/PAL fix for Soul Blazer F/G and Super Metroid E (by dbjh; thanks to Mystic_Merlin) - added (SNES) work-around for using the Game Doctor SF6 protocol for parallel ports that do not support reading from the Control register. It is good enough to at least allow dumping saver data and SRAM. To enable the new functionality assign a value other than 0 to the variable gd6_send_byte_delay. See the FAQ question 55 for details (by dbjh; many thanks to NorQue and Mystic_Merlin for testing) - updated (SNES) made --gd3 specify a pass-through mapping for LoROM DSP games (by dbjh) - updated (SNES) added proper recognition of Pro Fighter headers of LoROM DSP games with 2, 8 or 32 kB SRAM (by dbjh) - updated (SNES) added interpretation of remaining part of GD3 header (DRAM and SRAM mapping) to --dbuh (by dbjh) - updated (SNES & Genesis) fixed split file detection for formats other than (M)GD and MGH which I broke in 2.1.0 (by dbjh) - added (all) --split=N split ROM in parts of N Bytes (including possible header). This is a generic file splitting option. Use -s, optionally in combination with --ssize=SIZE to split files for use with a specific console or backup unit (by dbjh) - added (SNES) support for Super Magicom/SMC IC2 file format. This format is used by several ancient backup units, including the Twin Supercom, Future Supercom Pro.9 and UFO Super Drive PRO 6 HYPER VERSION in order to run HiROM games up to 16 Mbit. Use --ic2 to convert a file to Super Magicom/SMC IC2 format (by dbjh; thanks to Mystic_Merlin for info and testing) - updated (SNES) fixed bug in --ufo that caused it to produce incorrect headers for games that do not use SRAM (by dbjh; thanks to Mystic_Merlin for feedback and testing) - updated (SNES) fixed bug in -j for files in UFO format smaller than or equal to 8 Mbit (by dbjh)
227 lines
6.5 KiB
C
227 lines
6.5 KiB
C
$NetBSD: patch-backup_libcd64_cd64io.c,v 1.2 2019/07/07 22:47:57 wiz Exp $
|
|
|
|
Patch from upstream to improve build on NetBSD.
|
|
|
|
--- backup/libcd64/cd64io.c.orig 2019-05-06 06:48:17.000000000 +0000
|
|
+++ backup/libcd64/cd64io.c
|
|
@@ -41,7 +41,20 @@
|
|
|
|
#ifdef CD64_USE_RAWIO
|
|
|
|
+static INLINE uint8_t inb2(uint16_t);
|
|
+static INLINE void outb2(uint8_t, uint16_t);
|
|
+
|
|
#if defined _WIN32 || defined __CYGWIN__
|
|
+#ifdef _MSC_VER
|
|
+#pragma warning(push)
|
|
+#pragma warning(disable: 4255) /* 'function' : no function prototype given: converting '()' to '(void)' */
|
|
+#pragma warning(disable: 4668) /* 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' */
|
|
+#pragma warning(disable: 4820) /* 'bytes' bytes padding added after construct 'member_name' */
|
|
+#endif
|
|
+#include <windows.h> /* defines _WIN32 (checks for */
|
|
+#ifdef _MSC_VER /* __CYGWIN__ must come first) */
|
|
+#pragma warning(pop)
|
|
+#endif
|
|
#ifdef __CYGWIN__
|
|
#include <dlfcn.h>
|
|
|
|
@@ -73,10 +86,8 @@ static short int (WINAPI *IsDriverInstal
|
|
static unsigned char (__stdcall *DlPortReadPortUchar)(unsigned short) = NULL;
|
|
static void (__stdcall *DlPortWritePortUchar)(unsigned short, unsigned char) = NULL;
|
|
|
|
-static INLINE uint8_t inb(uint16_t);
|
|
-static INLINE void outb(uint8_t, uint16_t);
|
|
-static uint8_t (*input_byte)(uint16_t) = inb;
|
|
-static void (*output_byte)(uint8_t, uint16_t) = outb;
|
|
+static uint8_t (*input_byte)(uint16_t) = inb2;
|
|
+static void (*output_byte)(uint8_t, uint16_t) = outb2;
|
|
#endif
|
|
|
|
#ifdef __BEOS__
|
|
@@ -774,9 +785,8 @@ static LONG new_exception_filter(LPEXCEP
|
|
#endif
|
|
#endif /* _WIN32 || __CYGWIN__ */
|
|
|
|
-#if ((defined _WIN32 || defined __CYGWIN__ || defined __BEOS__) && \
|
|
- (defined __i386__ || defined __x86_64__)) || defined _MSC_VER
|
|
-static INLINE uint8_t inb(uint16_t port) {
|
|
+#if defined __i386__ || defined __x86_64__ || defined _MSC_VER
|
|
+static INLINE uint8_t inb2(uint16_t port) {
|
|
|
|
#ifdef __BEOS__
|
|
st_ioport_t temp;
|
|
@@ -785,27 +795,30 @@ static INLINE uint8_t inb(uint16_t port)
|
|
ioctl(io_portfd, 'r', &temp, 0);
|
|
|
|
return temp.data8;
|
|
-#else /* Win32 */
|
|
+#elif defined _WIN32 || defined __CYGWIN__
|
|
if (io_driver_found) return input_byte(port);
|
|
- else {
|
|
+ else
|
|
#ifdef _MSC_VER
|
|
#ifdef _M_IX86
|
|
- return (unsigned char) _inp(port);
|
|
+ return (uint8_t) _inp(port);
|
|
#endif
|
|
-#else
|
|
- unsigned char byte;
|
|
+#endif
|
|
+#endif /* _WIN32 || __CYGWIN__ */
|
|
+#if defined __MINGW32__ || defined __CYGWIN__ || \
|
|
+ ((defined __i386__ || defined __x86_64__) && !defined __BEOS__)
|
|
+ {
|
|
+ uint8_t byte;
|
|
__asm__ __volatile__
|
|
("inb %1, %0"
|
|
: "=a" (byte)
|
|
: "d" (port)
|
|
);
|
|
return byte;
|
|
-#endif
|
|
}
|
|
#endif
|
|
}
|
|
|
|
-static INLINE void outb(uint8_t byte, uint16_t port) {
|
|
+static INLINE void outb2(uint8_t byte, uint16_t port) {
|
|
|
|
#ifdef __BEOS__
|
|
st_ioport_t temp;
|
|
@@ -813,24 +826,27 @@ static INLINE void outb(uint8_t byte, ui
|
|
temp.port = port;
|
|
temp.data8 = byte;
|
|
ioctl(io_portfd, 'w', &temp, 0);
|
|
-#else /* Win32 */
|
|
+#elif defined _WIN32 || defined __CYGWIN__
|
|
if (io_driver_found) output_byte(byte, port);
|
|
- else {
|
|
+ else
|
|
#ifdef _MSC_VER
|
|
#ifdef _M_IX86
|
|
_outp(port, byte);
|
|
#endif
|
|
-#else
|
|
+#endif
|
|
+#endif /* _WIN32 || __CYGWIN__ */
|
|
+#if defined __MINGW32__ || defined __CYGWIN__ || \
|
|
+ ((defined __i386__ || defined __x86_64__) && !defined __BEOS__)
|
|
+ {
|
|
__asm__ __volatile__
|
|
("outb %1, %0"
|
|
:
|
|
: "d" (port), "a" (byte)
|
|
);
|
|
-#endif
|
|
}
|
|
#endif
|
|
}
|
|
-#endif /* inb/outb defs */
|
|
+#endif /* inb2/outb2 defs */
|
|
|
|
int cd64_open_rawio(struct cd64_t *cd64) {
|
|
|
|
@@ -1112,8 +1128,8 @@ int cd64_close_rawio(struct cd64_t *cd64
|
|
close_module(io_driver, cd64);
|
|
io_driver = NULL;
|
|
io_driver_found = 0;
|
|
- input_byte = inb;
|
|
- output_byte = outb;
|
|
+ input_byte = inb2;
|
|
+ output_byte = outb2;
|
|
#endif
|
|
|
|
return 1;
|
|
@@ -1127,7 +1143,7 @@ static INLINE int cd64_wait_rawio(struct
|
|
i = 0;
|
|
|
|
if (cd64->using_ppa) {
|
|
- status = inb((uint16_t) (cd64->port+1));
|
|
+ status = inb2((uint16_t) (cd64->port+1));
|
|
|
|
while (status & 0x80) {
|
|
i++;
|
|
@@ -1136,15 +1152,15 @@ static INLINE int cd64_wait_rawio(struct
|
|
* Try to knock some sense into it. */
|
|
uint8_t dir = 1;
|
|
status = 0x06 | (dir << 5);
|
|
- outb(status, (uint16_t) (cd64->port+2));
|
|
+ outb2(status, (uint16_t) (cd64->port+2));
|
|
|
|
dir = 0;
|
|
status = 0x04 | (dir << 5);
|
|
- outb(status, (uint16_t) (cd64->port+2));
|
|
+ outb2(status, (uint16_t) (cd64->port+2));
|
|
status = 0x05 | (dir << 5);
|
|
- outb(status, (uint16_t) (cd64->port+2));
|
|
+ outb2(status, (uint16_t) (cd64->port+2));
|
|
status = 0x04 | (dir << 5);
|
|
- outb(status, (uint16_t) (cd64->port+2));
|
|
+ outb2(status, (uint16_t) (cd64->port+2));
|
|
|
|
reset_tries++;
|
|
i = 0;
|
|
@@ -1155,14 +1171,14 @@ static INLINE int cd64_wait_rawio(struct
|
|
break;
|
|
}
|
|
|
|
- status = inb((uint16_t) (cd64->port+1));
|
|
+ status = inb2((uint16_t) (cd64->port+1));
|
|
}
|
|
}
|
|
else { /* Comms link */
|
|
- status = inb((uint16_t) (cd64->port+2));
|
|
+ status = inb2((uint16_t) (cd64->port+2));
|
|
while (status & 1) {
|
|
/* Do we need to handle a stuck situation here? */
|
|
- status = inb((uint16_t) (cd64->port+2));
|
|
+ status = inb2((uint16_t) (cd64->port+2));
|
|
}
|
|
}
|
|
|
|
@@ -1181,10 +1197,10 @@ int cd64_xfer_rawio(struct cd64_t *cd64,
|
|
if (delayms) MSLEEP(delayms);
|
|
dir = 1;
|
|
ctl = 0x06 | (dir << 5);
|
|
- outb(ctl, (uint16_t) (cd64->port+2));
|
|
+ outb2(ctl, (uint16_t) (cd64->port+2));
|
|
if (delayms) MSLEEP(delayms);
|
|
if (rd) {
|
|
- *rd = inb((uint16_t) cd64->port);
|
|
+ *rd = inb2((uint16_t) cd64->port);
|
|
#if DEBUG_LOWLEVEL
|
|
printf("got %xh", *rd);
|
|
if (*rd > 0x20) printf(" (%c)", *rd);
|
|
@@ -1195,10 +1211,10 @@ int cd64_xfer_rawio(struct cd64_t *cd64,
|
|
if (delayms) MSLEEP(delayms);
|
|
dir = 0;
|
|
ctl = 0x04 | (dir << 5);
|
|
- outb(ctl, (uint16_t) (cd64->port+2));
|
|
+ outb2(ctl, (uint16_t) (cd64->port+2));
|
|
if (delayms) MSLEEP(delayms);
|
|
if (wr) {
|
|
- outb(*wr, (uint16_t) cd64->port);
|
|
+ outb2(*wr, (uint16_t) cd64->port);
|
|
#if DEBUG_LOWLEVEL
|
|
printf("put %xh", *wr);
|
|
if (*wr > 0x20) printf(" (%c)", *wr);
|
|
@@ -1207,15 +1223,15 @@ int cd64_xfer_rawio(struct cd64_t *cd64,
|
|
}
|
|
if (delayms) MSLEEP(delayms);
|
|
ctl = 0x05 | (dir << 5);
|
|
- outb(ctl, (uint16_t) (cd64->port+2));
|
|
+ outb2(ctl, (uint16_t) (cd64->port+2));
|
|
if (delayms) MSLEEP(delayms);
|
|
ctl = 0x04 | (dir << 5);
|
|
- outb(ctl, (uint16_t) (cd64->port+2));
|
|
+ outb2(ctl, (uint16_t) (cd64->port+2));
|
|
}
|
|
else { /* Comms link */
|
|
- outb(*wr, (uint16_t) cd64->port);
|
|
+ outb2(*wr, (uint16_t) cd64->port);
|
|
if (!cd64_wait_rawio(cd64)) { return 0; }
|
|
- *rd = inb((uint16_t) cd64->port);
|
|
+ *rd = inb2((uint16_t) cd64->port);
|
|
}
|
|
|
|
return 1;
|