diff options
Diffstat (limited to 'apps/plugins/sdl/progs/duke3d/Engine/src/multi.c')
-rw-r--r-- | apps/plugins/sdl/progs/duke3d/Engine/src/multi.c | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c b/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c index c2ded00914..b23481bc08 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c | |||
@@ -46,39 +46,9 @@ long crctable[256]; | |||
46 | 46 | ||
47 | //COM ONLY variables | 47 | //COM ONLY variables |
48 | long comnum, comvect, comspeed, comtemp, comi, comescape, comreset; | 48 | long comnum, comvect, comspeed, comtemp, comi, comescape, comreset; |
49 | #ifdef PLATFORM_DOS // !!! this is a real mess. --ryan. | ||
50 | static void interrupt far comhandler(void); | ||
51 | static unsigned short orig_pm_sel, orig_rm_seg, orig_rm_off; | ||
52 | static unsigned long orig_pm_off; | ||
53 | #endif | ||
54 | volatile unsigned char *inbuf, *outbuf, *comerror, *incnt, *comtype; | 49 | volatile unsigned char *inbuf, *outbuf, *comerror, *incnt, *comtype; |
55 | volatile unsigned char *comresend; | 50 | volatile unsigned char *comresend; |
56 | volatile short *inbufplc, *inbufend, *outbufplc, *outbufend, *comport; | 51 | volatile short *inbufplc, *inbufend, *outbufplc, *outbufend, *comport; |
57 | #ifdef PLATFORM_DOS // !!! this is a real mess. --ryan. | ||
58 | static char rmbuffer[COMCODEBYTES] = //See realcom.asm | ||
59 | { | ||
60 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
61 | 0x00,0x00,0x00,0x00,0x50,0x53,0x66,0x51,0x52,0x2e, | ||
62 | 0x8b,0x16,0x08,0x00,0x83,0xc2,0x02,0xec,0x24,0x07, | ||
63 | 0x8a,0xe0,0x80,0xfc,0x02,0x74,0x08,0x80,0xfc,0x04, | ||
64 | 0x74,0x62,0xe9,0x89,0x00,0x2e,0x8b,0x16,0x08,0x00, | ||
65 | 0x2e,0x8a,0x0e,0x0a,0x00,0x80,0xe9,0x01,0x78,0x7a, | ||
66 | 0x2e,0x80,0x3e,0x0c,0x00,0x01,0x7c,0x10,0x74,0x04, | ||
67 | 0xb0,0x83,0xeb,0x02,0xb0,0x8f,0xee,0x2e,0xfe,0x0e, | ||
68 | 0x0c,0x00,0xeb,0xe3,0x2e,0x80,0x3e,0x0b,0x00,0x01, | ||
69 | 0x7c,0x12,0x74,0x04,0xb0,0x83,0xeb,0x04,0x2e,0xa0, | ||
70 | 0x0d,0x00,0xee,0x2e,0xfe,0x0e,0x0b,0x00,0xeb,0xc9, | ||
71 | 0x2e,0x8b,0x1e,0x04,0x00,0x2e,0x3b,0x1e,0x06,0x00, | ||
72 | 0x74,0x3c,0x2e,0x8a,0x87,0x80,0x41,0xee,0x43,0x81, | ||
73 | 0xe3,0xff,0x3f,0x2e,0x89,0x1e,0x04,0x00,0xeb,0xab, | ||
74 | 0x2e,0x8b,0x16,0x08,0x00,0xec,0x2e,0x8b,0x1e,0x02, | ||
75 | 0x00,0x2e,0x88,0x87,0x80,0x01,0x43,0x81,0xe3,0xff, | ||
76 | 0x3f,0x2e,0x89,0x1e,0x02,0x00,0x2e,0x80,0x3e,0x0a, | ||
77 | 0x00,0x10,0x75,0x08,0x83,0xc2,0x05,0xec,0xa8,0x01, | ||
78 | 0x75,0xd6,0xf6,0xc4,0x01,0x0f,0x84,0x56,0xff,0xb0, | ||
79 | 0x20,0xe6,0x20,0x5a,0x66,0x59,0x5b,0x58,0xcf, | ||
80 | }; | ||
81 | #endif | ||
82 | 52 | ||
83 | //NET ONLY variables | 53 | //NET ONLY variables |
84 | short socket = 0x4949; | 54 | short socket = 0x4949; |
@@ -106,80 +76,17 @@ static char rmnetbuffer[NETCODEBYTES] = | |||
106 | }; | 76 | }; |
107 | static long my7a = 0; | 77 | static long my7a = 0; |
108 | 78 | ||
109 | #ifdef PLATFORM_DOS | ||
110 | #pragma aux koutp =\ | ||
111 | "out dx, al",\ | ||
112 | parm [edx][eax]\ | ||
113 | |||
114 | #pragma aux kinp =\ | ||
115 | "in al, dx",\ | ||
116 | parm [edx] | ||
117 | #endif | ||
118 | |||
119 | long convalloc32 (long size) | 79 | long convalloc32 (long size) |
120 | { | 80 | { |
121 | #ifdef PLATFORM_DOS | ||
122 | union REGS r; | ||
123 | |||
124 | r.x.eax = 0x0100; //DPMI allocate DOS memory | ||
125 | r.x.ebx = ((size+15)>>4); //Number of paragraphs requested | ||
126 | int386(0x31,&r,&r); | ||
127 | |||
128 | if (r.x.cflag != 0) return ((long)0); //Failed | ||
129 | return ((long)((r.x.eax&0xffff)<<4)); //Returns full 32-bit offset | ||
130 | #else | ||
131 | fprintf (stderr, "%s, line %d; convalloc32() called\n", __FILE__, | 81 | fprintf (stderr, "%s, line %d; convalloc32() called\n", __FILE__, |
132 | __LINE__); | 82 | __LINE__); |
133 | return 0; | 83 | return 0; |
134 | #endif | ||
135 | } | 84 | } |
136 | 85 | ||
137 | #ifdef PLATFORM_DOS | ||
138 | #pragma aux fixregistersaftersimulate =\ | ||
139 | "cld",\ | ||
140 | "push ds",\ | ||
141 | "pop es",\ | ||
142 | |||
143 | static struct rminfo | ||
144 | { | ||
145 | long EDI, ESI, EBP, ESP, EBX, EDX, ECX, EAX; | ||
146 | short flags, ES, DS, FS, GS, IP, CS, SP, SS; | ||
147 | } RMI; | ||
148 | #endif | ||
149 | |||
150 | long simulateint(char intnum, long daeax, long daebx, long daecx, long daedx, long daesi, long daedi) | 86 | long simulateint(char intnum, long daeax, long daebx, long daecx, long daedx, long daesi, long daedi) |
151 | { | 87 | { |
152 | #ifdef PLATFORM_DOS | ||
153 | union REGS regs; | ||
154 | struct SREGS sregs; | ||
155 | |||
156 | memset(&RMI,0,sizeof(RMI)); // Set up real-mode call structure | ||
157 | memset(&sregs,0,sizeof(sregs)); | ||
158 | |||
159 | RMI.EAX = daeax; | ||
160 | RMI.EBX = daebx; | ||
161 | RMI.ECX = daecx; | ||
162 | RMI.EDX = daedx; | ||
163 | RMI.ESI = daesi-rmoffset32; | ||
164 | RMI.EDI = daedi-rmoffset32; | ||
165 | RMI.DS = rmsegment16; | ||
166 | RMI.ES = rmsegment16; | ||
167 | |||
168 | regs.w.ax = 0x0300; // Use DMPI call 300h to issue the DOS interrupt | ||
169 | regs.h.bl = intnum; | ||
170 | regs.h.bh = 0; | ||
171 | regs.w.cx = 0; | ||
172 | sregs.es = FP_SEG(&RMI); | ||
173 | regs.x.edi = FP_OFF(&RMI); | ||
174 | int386x(0x31,®s,®s,&sregs); | ||
175 | |||
176 | fixregistersaftersimulate(); | ||
177 | |||
178 | return(RMI.EAX); | ||
179 | #else | ||
180 | fprintf(stderr, "%s line %d; simulateint() called\n",__FILE__,__LINE__); | 88 | fprintf(stderr, "%s line %d; simulateint() called\n",__FILE__,__LINE__); |
181 | return 0; | 89 | return 0; |
182 | #endif | ||
183 | } | 90 | } |
184 | 91 | ||
185 | void initmultiplayers(char damultioption, char dacomrateoption, char dapriority) | 92 | void initmultiplayers(char damultioption, char dacomrateoption, char dapriority) |
@@ -237,22 +144,6 @@ int neton(void) | |||
237 | long i, j; | 144 | long i, j; |
238 | 145 | ||
239 | if ((simulateint(0x2f,(long)0x7a00,0L,0L,0L,0L,0L)&255) != 255) return(-1); | 146 | if ((simulateint(0x2f,(long)0x7a00,0L,0L,0L,0L,0L)&255) != 255) return(-1); |
240 | if (*(long *)(0x7a<<2) == 0) | ||
241 | { | ||
242 | #ifdef PLATFORM_DOS | ||
243 | printf("Faking int 0x7a to call IPX entry at: %4x:%4x\n",RMI.ES,RMI.EDI&65535); | ||
244 | my7a = convalloc32(16L); | ||
245 | *(short *)((0x7a<<2)+0) = (my7a&15); | ||
246 | *(short *)((0x7a<<2)+2) = (my7a>>4); | ||
247 | |||
248 | *(char *)(my7a+0) = 0x2e; //call far ptr [L1] | ||
249 | *(char *)(my7a+1) = 0x9a; | ||
250 | *(long *)(my7a+2) = 7L; | ||
251 | *(char *)(my7a+6) = 0xcf; //iret | ||
252 | *(short *)(my7a+7) = (RMI.EDI&65535); //L1: ipxoff | ||
253 | *(short *)(my7a+9) = RMI.ES; // ipxseg | ||
254 | #endif | ||
255 | } | ||
256 | 147 | ||
257 | //Special stuff for WATCOM C | 148 | //Special stuff for WATCOM C |
258 | if ((rmoffset32 = convalloc32(1380L+NETCODEBYTES+COMBUFSIZ)) == 0) | 149 | if ((rmoffset32 = convalloc32(1380L+NETCODEBYTES+COMBUFSIZ)) == 0) |
@@ -349,9 +240,6 @@ int comon() | |||
349 | // Baud-Setting,?,?,Parity O/E,Parity Off/On, Stop-1/2,Bits-5/6/7/8 | 240 | // Baud-Setting,?,?,Parity O/E,Parity Off/On, Stop-1/2,Bits-5/6/7/8 |
350 | // 0x0b is odd parity,1 stop bit, 8 bits | 241 | // 0x0b is odd parity,1 stop bit, 8 bits |
351 | 242 | ||
352 | #ifdef PLATFORM_DOS | ||
353 | _disable(); | ||
354 | #endif | ||
355 | koutp((*comport)+3,0x80); //enable latch registers | 243 | koutp((*comport)+3,0x80); //enable latch registers |
356 | divisor = 115200 / comspeed; | 244 | divisor = 115200 / comspeed; |
357 | koutp((*comport)+0,divisor&255); //# = 115200 / bps | 245 | koutp((*comport)+0,divisor&255); //# = 115200 / bps |
@@ -384,9 +272,6 @@ int comon() | |||
384 | 272 | ||
385 | comescape = 0; comreset = 0; | 273 | comescape = 0; comreset = 0; |
386 | *comerror = 0; *comresend = 0; | 274 | *comerror = 0; *comresend = 0; |
387 | #ifdef PLATFORM_DOS | ||
388 | _enable(); | ||
389 | #endif | ||
390 | 275 | ||
391 | syncbufleng = 0; | 276 | syncbufleng = 0; |
392 | 277 | ||
@@ -410,18 +295,12 @@ void comoff() | |||
410 | i--; | 295 | i--; |
411 | } | 296 | } |
412 | 297 | ||
413 | #ifdef PLATFORM_DOS | ||
414 | _disable(); | ||
415 | #endif | ||
416 | koutp(0x21,kinp(0x21)|(1<<(comvect&7))); //Mask vector | 298 | koutp(0x21,kinp(0x21)|(1<<(comvect&7))); //Mask vector |
417 | if (hangup != 0) | 299 | if (hangup != 0) |
418 | { | 300 | { |
419 | koutp((*comport)+1,0); | 301 | koutp((*comport)+1,0); |
420 | koutp((*comport)+4,0); | 302 | koutp((*comport)+4,0); |
421 | } | 303 | } |
422 | #ifdef PLATFORM_DOS | ||
423 | _enable(); | ||
424 | #endif | ||
425 | uninstallbicomhandlers(); | 304 | uninstallbicomhandlers(); |
426 | } | 305 | } |
427 | 306 | ||
@@ -921,87 +800,14 @@ long getcrc(char *buffer, short bufleng) | |||
921 | 800 | ||
922 | void installbicomhandlers(void) | 801 | void installbicomhandlers(void) |
923 | { | 802 | { |
924 | #ifdef PLATFORM_DOS | ||
925 | union REGS r; | ||
926 | struct SREGS sr; | ||
927 | long lowp; | ||
928 | void far *fh; | ||
929 | |||
930 | //Get old protected mode handler | ||
931 | r.x.eax = 0x3500+comvect; /* DOS get vector (INT 0Ch) */ | ||
932 | sr.ds = sr.es = 0; | ||
933 | int386x(0x21,&r,&r,&sr); | ||
934 | orig_pm_sel = (unsigned short)sr.es; | ||
935 | orig_pm_off = r.x.ebx; | ||
936 | |||
937 | //Get old real mode handler | ||
938 | r.x.eax = 0x0200; /* DPMI get real mode vector */ | ||
939 | r.h.bl = comvect; | ||
940 | int386(0x31,&r,&r); | ||
941 | orig_rm_seg = (unsigned short)r.x.ecx; | ||
942 | orig_rm_off = (unsigned short)r.x.edx; | ||
943 | |||
944 | //Allocate memory in low memory to store real mode handler | ||
945 | if ((lowp = convalloc32(COMCODEBYTES+(COMBUFSIZ<<1))) == 0) | ||
946 | { printf("Can't allocate conventional memory.\n"); exit; } | ||
947 | |||
948 | inbufplc = (short *)(lowp+0); | ||
949 | inbufend = (short *)(lowp+2); | ||
950 | outbufplc = (short *)(lowp+4); | ||
951 | outbufend = (short *)(lowp+6); | ||
952 | comport = (short *)(lowp+8); | ||
953 | comtype = (char *)(lowp+10); | ||
954 | comerror = (char *)(lowp+11); | ||
955 | comresend = (char *)(lowp+12); | ||
956 | incnt = (char *)(lowp+13); | ||
957 | inbuf = (char *)(lowp+COMCODEBYTES); | ||
958 | outbuf = (char *)(lowp+COMCODEBYTES+COMBUFSIZ); | ||
959 | |||
960 | memcpy((void *)lowp,(void *)rmbuffer,COMCODEBYTES); | ||
961 | |||
962 | //Set new protected mode handler | ||
963 | r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */ | ||
964 | fh = (void far *)comhandler; | ||
965 | r.x.edx = FP_OFF(fh); | ||
966 | sr.ds = FP_SEG(fh); //DS:EDX == &handler | ||
967 | sr.es = 0; | ||
968 | int386x(0x21,&r,&r,&sr); | ||
969 | |||
970 | //Set new real mode handler (must be after setting protected mode) | ||
971 | r.x.eax = 0x0201; | ||
972 | r.h.bl = comvect; //CX:DX == real mode &handler | ||
973 | r.x.ecx = ((lowp>>4)&0xffff); //D32realseg | ||
974 | r.x.edx = COMCODEOFFS; //D32realoff | ||
975 | int386(0x31,&r,&r); | ||
976 | #else | ||
977 | fprintf (stderr,"%s, line %d; installbicomhandlers() called\n", | 803 | fprintf (stderr,"%s, line %d; installbicomhandlers() called\n", |
978 | __FILE__, __LINE__); | 804 | __FILE__, __LINE__); |
979 | #endif | ||
980 | } | 805 | } |
981 | 806 | ||
982 | void uninstallbicomhandlers(void) | 807 | void uninstallbicomhandlers(void) |
983 | { | 808 | { |
984 | #ifdef PLATFORM_DOS | ||
985 | union REGS r; | ||
986 | struct SREGS sr; | ||
987 | |||
988 | //restore old protected mode handler | ||
989 | r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */ | ||
990 | r.x.edx = orig_pm_off; | ||
991 | sr.ds = orig_pm_sel; /* DS:EDX == &handler */ | ||
992 | sr.es = 0; | ||
993 | int386x(0x21,&r,&r,&sr); | ||
994 | |||
995 | //restore old real mode handler | ||
996 | r.x.eax = 0x0201; /* DPMI set real mode vector */ | ||
997 | r.h.bl = comvect; | ||
998 | r.x.ecx = (unsigned long)orig_rm_seg; //CX:DX == real mode &handler | ||
999 | r.x.edx = (unsigned long)orig_rm_off; | ||
1000 | int386(0x31,&r,&r); | ||
1001 | #else | ||
1002 | fprintf (stderr, "%s line %d; uninstallbicomhandlers() called\n", | 809 | fprintf (stderr, "%s line %d; uninstallbicomhandlers() called\n", |
1003 | __FILE__, __LINE__); | 810 | __FILE__, __LINE__); |
1004 | #endif | ||
1005 | } | 811 | } |
1006 | 812 | ||
1007 | void processreservedmessage(short tempbufleng, char *datempbuf) | 813 | void processreservedmessage(short tempbufleng, char *datempbuf) |