Skip to content

Commit

Permalink
Implemented enough of the Presentation Manager API to draw a blank wi…
Browse files Browse the repository at this point in the history
…ndow.
  • Loading branch information
icculus committed Jan 15, 2018
1 parent 40b9b9e commit b6c47ee
Show file tree
Hide file tree
Showing 12 changed files with 2,638 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -64,6 +64,9 @@ elseif(CURSES_HAVE_CURSES_H)
add_definitions(-DHAVE_CURSES_H)
endif()

# !!! FIXME
include_directories("/usr/local/include/SDL2")

foreach(_I doscalls;msg;nls;quecalls;viocalls;kbdcalls;sesmgr;som;pmwin;pmshapi;pmgpi;tcpip32)
add_library(${_I} SHARED "native/${_I}.c")
set_target_properties(${_I} PROPERTIES COMPILE_FLAGS "-m32")
Expand All @@ -73,6 +76,7 @@ endforeach()
target_link_libraries(doscalls "pthread")
# FIXME target_link_libraries(viocalls ${CURSES_LIBRARIES})
target_link_libraries(viocalls ncursesw)
target_link_libraries(pmwin "${CMAKE_CURRENT_SOURCE_DIR}/libSDL2-2.0.so.0")

add_executable(lx_dump lx_dump.c)

Expand Down
Binary file added libSDL2-2.0.so.0
Binary file not shown.
8 changes: 7 additions & 1 deletion lx_loader.c
Expand Up @@ -2046,7 +2046,10 @@ static __attribute__((noreturn)) void handleThreadLocalStorageAccess(const int s
: "=a" (ptib2)
: "eax" (gregs[REG_FS])
);
uint32 *tls = (uint32 *) (ptib2 + 1); // The thread's TLS data is stored right after its TIB2 struct.

// The thread's TLS data is stored in LxPostTIB, right after its TIB2 struct.
LxPostTIB *posttib = (LxPostTIB *) (ptib2 + 1);
uint32 *tls = posttib->tls;
tls += slot;

//printf("We wanted to access thread %p TLS slot %d (currently holds %u)\n", tls - slot, slot, (uint) *tls);
Expand Down Expand Up @@ -2151,6 +2154,9 @@ int main(int argc, char **argv, char **envp)
if (getenv("TRACE_NATIVE"))
GLoaderState->trace_native = 1;

if (getenv("TRACE_EVENTS"))
GLoaderState->trace_events = 1;

unsigned int segment = 0;
__asm__ __volatile__ ( "movw %%cs, %%ax \n\t" : "=a" (segment) );
GLoaderState->original_cs = segment;
Expand Down
11 changes: 9 additions & 2 deletions lx_loader.h
Expand Up @@ -202,8 +202,14 @@ typedef struct LxPIB

#pragma pack(pop)

// We put the 128 bytes of TLS slots after the TIB structs.
#define LXTIBSIZE (sizeof (LxTIB) + sizeof (LxTIB2) + 128)
// We put the 128 bytes of TLS slots (etc) after the TIB structs.
typedef struct LxPostTIB
{
uint32 tls[32];
void *anchor_block;
} LxPostTIB;

#define LXTIBSIZE (sizeof (LxTIB) + sizeof (LxTIB2) + sizeof (LxPostTIB))

typedef struct LxLoaderState
{
Expand All @@ -214,6 +220,7 @@ typedef struct LxLoaderState
int subprocess;
int running;
int trace_native;
int trace_events;
uint16 original_cs;
uint16 original_ds;
uint16 original_es;
Expand Down
6 changes: 6 additions & 0 deletions native/os2native.h
Expand Up @@ -25,6 +25,12 @@ static LxLoaderState *GLoaderState = NULL;
#define TRACE_NATIVE(...) do {} while (0)
#endif

#if 1
#define TRACE_EVENT(...) do { if (GLoaderState->trace_events) { fprintf(stderr, "2INE TRACE [%lu]: ", (unsigned long) pthread_self()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); } } while (0)
#else
#define TRACE_EVENT(...) do {} while (0)
#endif

OS2EXPORT const LxExport * lxNativeModuleInit(LxLoaderState *lx_state, uint32 *lx_num_exports);
void OS2EXPORT lxNativeModuleDeinit(void);

Expand Down
8 changes: 8 additions & 0 deletions native/os2types.h
Expand Up @@ -57,6 +57,7 @@ typedef uint8_t BYTE, *PBYTE;
// !!! FIXME: refactor and mutex a bunch of stuff...if it has to be a 32-bit
// !!! FIXME: int, it needs to be an index into a resizable array, but at the
// !!! FIXME: native word size, these handles can just be pointers cast to ints.
// !!! FIXME: alternately: guarantee all handles are in the bottom 4 gigabytes?
typedef uint16_t SHANDLE, *PSHANDLE;
typedef uint32_t LHANDLE, *PLHANDLE;
typedef LHANDLE HANDLE, *PHANDLE;
Expand All @@ -71,11 +72,18 @@ typedef HANDLE PID, *PPID;
typedef HANDLE TID, *PTID;
typedef SHANDLE HVIO, *PHVIO;
typedef SHANDLE HKBD, *PHKBD;

typedef PCHAR PSZ;
typedef PCHAR PCH;

typedef int (APIENTRY *PFN)(void);

typedef ULONG ERRORID;

#define NULLHANDLE 0
#define TRUE 1
#define FALSE 0

#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 1 addition & 6 deletions native/pmgpi.h
Expand Up @@ -2,17 +2,12 @@
#define _INCL_PMGPI_H_

#include "os2types.h"
#include "pmwin.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct
{
int32_t x;
int32_t y;
} POINTL, *PPOINTL;

OS2EXPORT BOOL OS2API GpiQueryTextBox(HPS hps, LONG lCount1, PCH pchString, LONG lCount2, PPOINTL aptlPoints);

#ifdef __cplusplus
Expand Down

0 comments on commit b6c47ee

Please sign in to comment.