summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9cdcaa1)
raw | patch | inline | side by side (parent: 9cdcaa1)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 8 Feb 2019 16:26:06 +0000 (19:26 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 10 Feb 2019 10:05:11 +0000 (13:05 +0300) |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_main.pas | patch | blob | history | |
src/lib/enet/enet.pp | patch | blob | history | |
src/lib/watt32/watt32.pp | [new file with mode: 0644] | patch | blob |
src/wrappers/sdl2/sdl2allegro.inc | patch | blob | history |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index a897aea46837941e4faa6ab7ced11b7f938b79c9..53020f419c5a1886f69eb0167ca032fb43cde9e2 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
ENet in '../wrappers/enet/enet.pas',
{$ELSE}
ENet in '../lib/enet/enet.pp',
+ {$IFDEF GO32V2}
+ Watt32 in '../lib/watt32/watt32.pp',
+ {$ENDIF}
+{$ENDIF}
+{$IFDEF USE_SDL2ALLEGRO}
+ Allegro in '../lib/allegro4/allegro.pas',
{$ENDIF}
e_graphics in '../engine/e_graphics.pas',
e_input in '../engine/e_input.pas',
else if ParamStr(f) = '--log' then conbufDumpToStdOut := true
else if ParamStr(f) = '--safe-log' then e_SetSafeSlowLog(true);
end;
+
if noct then
begin
Main()
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index c789caf7785c74a09a79e9e691f62b6277898551..4e38444dcb9c78e5ce6a3e0c0e04ab14ba9923f5 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
uses
{$INCLUDE ../nogl/noGLuses.inc}
+{$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ Watt32,
+{$ENDIF}
{$IFDEF ENABLE_HOLMES}
g_holmes, fui_wadread, fui_style, fui_gfx_gl,
{$ENDIF}
TMsgType.Notify
);
+{$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ sdlflags := sock_init;
+ {$IFDEF USE_SDL2ALLEGRO}
+ hires_timer(0);
+ init_userSuppliedTimerTick;
+ {$ENDIF}
+ e_WriteLog('Wattcp Init: (' + IntToStr(sdlflags) + ') ' + sock_init_err, TMsgType.Notify);
+ e_WriteLog('Wattcp Version: ' + wattcpVersion, TMsgType.Notify);
+ e_WriteLog('Wattcp Capabilities: ' + wattcpCapabilities, TMsgType.Notify);
+ e_WriteLog('Wattcp IP: ' +
+ IntToStr(my_ip_addr div 16777216 mod 256) + '.' +
+ IntToStr(my_ip_addr div 65536 mod 256) + '.' +
+ IntToStr(my_ip_addr div 256 mod 256) + '.' +
+ IntToStr(my_ip_addr mod 256),
+ TMsgType.Notify
+ );
+{$ENDIF}
+
{$IFDEF HEADLESS}
conbufDumpToStdOut := true;
{$ENDIF}
diff --git a/src/lib/enet/enet.pp b/src/lib/enet/enet.pp
index e50109f641ab696c3bb3128688d20e17ef5c1b13..4aa383d2e55e254715ddba63a570cbbdeea0182c 100644 (file)
--- a/src/lib/enet/enet.pp
+++ b/src/lib/enet/enet.pp
{$Z4} // Force four-byte enums
-{$IFDEF MSWINDOWS}
+{$IF DEFINED(MSWINDOWS)}
{$IFDEF LIBENET_WINDOZE_STATIC}
{$LINKLIB libenet.a}
{$LINKLIB libwinmm.a}
// external LIBNAME name 'var_name' would've been more correct here
// because just external is case insensitive, but fuck it
{$ENDIF}
+{$ELSEIF DEFINED(GO32V2)}
+ {$LINKLIB libenet.a}
+ {$DEFINE libraryLibENetDecl := cdecl}
+ {$DEFINE libraryLibENetImp := cdecl; external}
+ {$DEFINE libraryLibENetVar := cvar; external}
{$ELSE}
{$DEFINE libraryLibENetDecl := cdecl}
{$DEFINE libraryLibENetImp := cdecl; external 'enet'}
uses
ctypes,
-{$IFDEF WINDOWS}
+{$IF DEFINED(WINDOWS)}
WinSock2;
+{$ELSEIF DEFINED(GO32V2)}
+ Watt32;
{$ELSE}
BaseUnix, Sockets;
{$ENDIF}
diff --git a/src/lib/watt32/watt32.pp b/src/lib/watt32/watt32.pp
--- /dev/null
+++ b/src/lib/watt32/watt32.pp
@@ -0,0 +1,118 @@
+{$MODE OBJFPC}
+{$PACKRECORDS C}
+
+{$MODESWITCH OUT}
+{$LONGSTRINGS ON}
+{$MACRO ON}
+
+{$IF DEFINED(GO32V2)}
+ {$LINKLIB libwatt.a}
+ {$DEFINE LibraryLibWattDecl := cdecl}
+ {$DEFINE LibraryLibWattImp := cdecl; external}
+ {$DEFINE LibraryLibWattVar := cvar; external}
+{$ELSE}
+ {$ERROR what?}
+{$ENDIF}
+
+unit watt32;
+
+interface
+
+ uses ctypes;
+
+ const
+ FD_MAXFDSET = 512; (* FD_SETSIZE *)
+
+ type
+ (* Watt32 -> sys/wtypes.h -> fd_set *)
+ TFDSet = record
+ fd_bits: array [0..63] of cuchar;
+ end;
+
+ tcp_Socket = record
+ undoc: array [0..4469] of cuchar;
+ end;
+
+ udp_Socket = record
+ undoc: array [0..1739] of cuchar;
+ end;
+
+ Psock_type = Pointer;
+
+ var
+ my_ip_addr: culong; external name '__w32_my_ip_addr';
+
+ function wattcpCopyright: PChar; LibraryLibWattImp;
+ function wattcpVersion: PChar; LibraryLibWattImp;
+ function wattcpCapabilities: PChar; LibraryLibWattImp;
+
+ function watt_sock_init (tcp, udp: csize_t): cint; LibraryLibWattImp;
+ function sock_init_err: PChar; LibraryLibWattImp;
+ procedure sock_exit; LibraryLibWattImp;
+ procedure dbug_init; LibraryLibWattImp;
+ procedure init_misc; LibraryLibWattImp;
+ procedure sock_sig_exit (const msg: PChar; sigint: cint); LibraryLibWattImp;
+
+ function hires_timer (on: cint): cint; LibraryLibWattImp name '_w32_hires_timer';
+ procedure init_userSuppliedTimerTick; LibraryLibWattImp;
+ procedure userTimerTick (elapsed_time_msec: culong); LibraryLibWattImp;
+ procedure init_timer_isr; LibraryLibWattImp name '_w32_init_timer_isr';
+ procedure exit_timer_isr; LibraryLibWattImp name '_w32_exit_timer_isr';
+
+ function tcp_tick (s: Psock_type): culong; LibraryLibWattImp;
+
+
+ function htons (hostshort: cuint16): cuint16; LibraryLibWattImp;
+ function htonl (hostlong: cuint32): cuint32; LibraryLibWattImp;
+ function ntohs (netshort: cuint16): cuint16; LibraryLibWattImp;
+ function ntohl (netlong: cuint32): cuint32; LibraryLibWattImp;
+
+ (* MACRO *)
+ function sock_init: cint;
+ function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
+ function fpFD_CLR (fdno:cint; var nset: TFDSet): cint;
+ function fpFD_ZERO (out nset: TFDSet): cint;
+ function fpFD_ISSET (fdno: cint;const nset: TFDSet): cint;
+
+implementation
+
+ function sock_init: cint;
+ begin
+ sock_init := watt_sock_init(sizeof(tcp_Socket), sizeof(udp_Socket))
+ end;
+
+ function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) then
+ exit(-1);
+ nset.fd_bits[fdno div 8] := nset.fd_bits[fdno div 8] OR (culong(1) shl (fdno and 7));
+ fpFD_SET := 0
+ end;
+
+ function fpFD_CLR (fdno: cint; var nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) Then
+ exit(-1);
+ nset.fd_bits[fdno div 8] := nset.fd_bits[fdno div 8] AND Cardinal(NOT (culong(1) shl (fdno and 7)));
+ fpFD_CLR := 0
+ end;
+
+ function fpFD_ZERO (out nset: TFDSet): cint;
+ var i :longint;
+ begin
+ for i := 0 to (512 + 7) div 8 DO
+ nset.fd_bits[i] := 0;
+ fpFD_ZERO := 0
+ end;
+
+ function fpFD_ISSET (fdno: cint; const nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) Then
+ exit(-1);
+ if ((nset.fd_bits[fdno div 8]) and (culong(1) shl (fdno and 7))) > 0 then
+ fpFD_ISSET := 1
+ else
+ fpFD_ISSET := 0
+ end;
+
+end.
index a5de6da8d5ad15f3f407d13b8c4aca4570fdb319..fedd18bed2f73dfdd54b1655db1ad8bc9620d796 100644 (file)
uses
{$IFDEF GO32V2}
+ {$IFNDEF USE_ENETWRAP}
+ Watt32,
+ {$ENDIF}
go32,
{$ENDIF}
e_Log, g_options, SysUtils, Math, Classes, ctypes;
procedure AllegroTimerCallback; cdecl;
begin
- inc(ticks)
+ inc(ticks);
+ {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ userTimerTick(1);
+ {$ENDIF}
end;
procedure AllegroTimerCallbackEND; begin end;
release_screen;
if useVsync then
vsync;
+
+ {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ tcp_tick(nil);
+ {$ENDIF}
end;
(********** EVENTS **********)
event.key.keysym._mod := 0; (* df not use it? *)
result := 1;
Exit
- end
+ end;
+
+ {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ tcp_tick(nil);
+ {$ENDIF}
end;
(********** MOUSE **********)