From 5f858c9e94fcb589ee0678ebb45fcccc3ff04c28 Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Sun, 18 Apr 2010 03:05:19 +0000 Subject: [PATCH] A start on an OS/2 port - a makefile for VAC++ and a few missing functions ported from VICE. --- src/arch/os2/Makefile | 52 +++++++++++++++++++++++ src/arch/os2/src/dirport.c | 64 ++++++++++++++++++++++++++++ src/arch/os2/src/dirport.h | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 src/arch/os2/Makefile create mode 100644 src/arch/os2/src/dirport.c create mode 100644 src/arch/os2/src/dirport.h diff --git a/src/arch/os2/Makefile b/src/arch/os2/Makefile new file mode 100644 index 0000000..f51c794 --- /dev/null +++ b/src/arch/os2/Makefile @@ -0,0 +1,52 @@ +# GSport OS/2 makefile + +OBJECTS1 = dirport.obj adb.obj clock.obj dis.obj engine_c.obj scc.obj \ + iwm.obj joystick_driver.obj moremem.obj paddles.obj \ + sim65816.obj smartport.obj sound.obj sound_driver.obj \ + video.obj os2driver.obj config.obj + +{..\..}.c.obj: + @echo " Compile::C++ Compiler " + icc.exe /DTCPV40HDRS /DBSD_SELECT /Dinline= /Q /Gm /Gd- /C %s + +{src\}.c.obj: + @echo " Compile::C++ Compiler " + icc.exe /DTCPV40HDRS /DBSD_SELECT /Dinline= /Q /Gm /Gd- /C %s + +gsport.exe: $(OBJECTS1) ../../os2driver.c + @echo " Link::Linker " + icc.exe @<< + /B" /pmtype:vio /st:196608 " + /FePrivoxy.exe + so32dll.lib + tcp32dll.lib + $(OBJECTS1) +<< + echo done + +clean: + - rm $(OBJECTS1) + +# dependency stuff +dirport.obj: src/dirport.c src/dirport.h +adb.obj: ../../adb.c ../../adb.h ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +engine_c.obj: ../../engine_c.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../protos_engine_c.h ../../size_c.h ../../op_routs.h ../../defs_instr.h ../../8inst_c.h ../../16inst_c.h +clock.obj: ..\..\clock.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +compile_time.obj: ../../compile_time.c +config.obj: ../../config.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../config.h +dis.obj: ../../dis.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../disas.h +scc.obj: ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../scc.h +scc_socket_driver.obj: ../../scc_socket_driver.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../scc.h +iwm.obj: ../../iwm.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../iwm_35_525.h +joystick_driver.obj: ../../joystick_driver.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +moremem.obj: ../../moremem.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +paddles.obj: ../../paddles.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +parallel.obj: ../../parallel.c ../../defc.h +printer.obj: ../../printer.cpp +sim65816.obj: ../../sim65816.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +smartport.obj: ../../smartport.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +sound.obj: ../../sound.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h +sound_driver.obj: ../../sound_driver.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../sound.h +video.obj: ../../video.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h ../../superhires.h ../../kegsfont.h +os2driver.obj: ../../os2driver.c ../../scc.c ../../defc.h ../../defcomm.h ../../iwm.h ../../protos.h + \ No newline at end of file diff --git a/src/arch/os2/src/dirport.c b/src/arch/os2/src/dirport.c new file mode 100644 index 0000000..7a43be6 --- /dev/null +++ b/src/arch/os2/src/dirport.c @@ -0,0 +1,64 @@ +/* + * This file is part of VICE, the Versatile Commodore Emulator. + * See README for copyright notice. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + * + */ + +#include +#include +#include "dirport.h" + +DIR *opendir (char *path) +{ + APIRET ulrc; + ULONG cnt = 1; + DIR *dir; + char *name; + + if (!(dir = (DIR*)calloc(1, sizeof(DIR)))) { + return NULL; + } + if (name = (char*)calloc(1, strlen(path) + 3)) { + strcat(strcpy(name, path),path[strlen(path) - 1] == '\\' ? "*" : "\\*"); + dir->handle = HDIR_CREATE; + ulrc = DosFindFirst(name, &(dir->handle), _A_ANY, &(dir->buffer), sizeof(struct _FILEFINDBUF3), &cnt, FIL_STANDARD); + lib_free(name); + } + if (!name || ulrc) { + DosFindClose (dir->handle); + lib_free(dir); + dir = NULL; + } + return dir; +} + +struct dirent *readdir (DIR *dir) +{ + ULONG cnt = 1; + + return DosFindNext (dir->handle, &(dir->buffer), sizeof(struct _FILEFINDBUF), &cnt) ? NULL : &(dir->buffer); +} + +int closedir (DIR *dir) +{ + APIRET ulrc = DosFindClose (dir->handle); + + lib_free(dir); + return (int)ulrc; +} + \ No newline at end of file diff --git a/src/arch/os2/src/dirport.h b/src/arch/os2/src/dirport.h new file mode 100644 index 0000000..617a41a --- /dev/null +++ b/src/arch/os2/src/dirport.h @@ -0,0 +1,85 @@ +/* + * This file is part of VICE, the Versatile Commodore Emulator. + * See README for copyright notice. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + * + */ + +#ifndef VICE_DIRPORT_H +#define VICE_DIRPORT_H + +#define INCL_DOS +#include +#include +#include + +#ifndef _A_VOLID +#define _A_VOLID 0 +#endif + +#ifndef _A_NORMAL +#define _A_NORMAL FILE_NORMAL +#endif + +#ifndef _A_RDONLY +#define _A_RDONLY FILE_READONLY +#endif + +#ifndef _A_HIDDEN +#define _A_HIDDEN FILE_HIDDEN +#endif + +#ifndef _A_SYSTEM +#define _A_SYSTEM FILE_SYSTEM +#endif + +#ifndef _A_SUBDIR +#define _A_SUBDIR FILE_DIRECTORY +#endif + +#ifndef _A_ARCH +#define _A_ARCH FILE_ARCHIVED +#endif + +#define _A_ANY FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED + +#ifndef EPERM +#define EPERM EDOM // Operation not permitted = Domain Error +#endif + +#define dirent _FILEFINDBUF3 +#define d_name achName /* For struct dirent portability */ +#define d_size cbFile + +#define mkdir(name, mode) mkdir(name) + +#ifndef WATCOM_COMPILE +#define S_ISDIR(mode) ((mode) & S_IFDIR) + +typedef struct _DIR { + struct dirent buffer; + HDIR handle; + APIRET ulrc; +} DIR; + +extern DIR *opendir(char *path); +extern struct dirent *readdir(DIR *dirp); +extern int closedir(DIR *dirp); +#endif + +#endif /* DIRPORT__H */ + \ No newline at end of file