forked from ilyakurdyukov/fpdoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doom.patch
3142 lines (2766 loc) · 77.3 KB
/
doom.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/am_map.c b/am_map.c
index 999e455..4be1e68 100644
--- a/am_map.c
+++ b/am_map.c
@@ -783,7 +783,7 @@ void AM_doFollowPlayer(void)
//
void AM_updateLightLev(void)
{
- static nexttic = 0;
+ static int nexttic = 0;
//static int litelevels[] = { 0, 3, 5, 6, 6, 7, 7, 7 };
static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 };
static int litelevelscnt = 0;
@@ -856,9 +856,9 @@ AM_clipMline
TOP =8
};
- register outcode1 = 0;
- register outcode2 = 0;
- register outside;
+ register int outcode1 = 0;
+ register int outcode2 = 0;
+ register int outside;
fpoint_t tmp;
int dx;
@@ -989,7 +989,7 @@ AM_drawFline
register int ay;
register int d;
- static fuck = 0;
+ static int fuck = 0;
// For debugging only
if ( fl->a.x < 0 || fl->a.x >= f_w
diff --git a/d_main.c b/d_main.c
index 23427e8..7ccda3d 100644
--- a/d_main.c
+++ b/d_main.c
@@ -32,12 +32,9 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
#ifdef NORMALUNIX
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#endif
@@ -119,13 +116,6 @@ FILE* debugfile;
boolean advancedemo;
-
-
-char wadfile[1024]; // primary wad file
-char mapdir[1024]; // directory of development maps
-char basedefault[1024]; // default file
-
-
void D_CheckNetGame (void);
void D_ProcessEvents (void);
void G_BuildTiccmd (ticcmd_t* cmd);
@@ -150,7 +140,7 @@ int eventtail;
void D_PostEvent (event_t* ev)
{
events[eventhead] = *ev;
- eventhead = (++eventhead)&(MAXEVENTS-1);
+ eventhead = (eventhead+1)&(MAXEVENTS-1);
}
@@ -167,7 +157,7 @@ void D_ProcessEvents (void)
&& (W_CheckNumForName("map01")<0) )
return;
- for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
+ for ( ; eventtail != eventhead ; eventtail = (eventtail+1)&(MAXEVENTS-1) )
{
ev = &events[eventtail];
if (M_Responder (ev))
@@ -529,18 +519,10 @@ void D_StartTitle (void)
D_AdvanceDemo ();
}
-
-
-
-// print title for every printed line
-char title[128];
-
-
-
//
// D_AddFile
//
-void D_AddFile (char *file)
+void D_AddFile (const char *file)
{
int numwadfiles;
char *newfile;
@@ -554,6 +536,9 @@ void D_AddFile (char *file)
wadfiles[numwadfiles] = newfile;
}
+int gameversion = 109;
+static const char *title = "Public DOOM";
+
//
// IdentifyVersion
// Checks availability of IWAD files by name,
@@ -563,6 +548,34 @@ void D_AddFile (char *file)
void IdentifyVersion (void)
{
+#if 1
+ int i; FILE* file;
+ static const struct {
+ const char *name, *title;
+ int gamemode, language;
+ } list[] = {
+ { "doom2f.wad", "DOOM 2: Hell on Earth", commercial, french },
+ { "doom2.wad", "DOOM 2: Hell on Earth", commercial, english },
+ { "plutonia.wad", "DOOM 2: Plutonia Experiment", commercial, english },
+ { "tnt.wad", "DOOM 2: TNT - Evilution", commercial, english },
+ { "doomu.wad", "The Ultimate DOOM Startup", retail, english },
+ { "doom.wad", "DOOM Registered Startup", registered, english },
+ { "doom1.wad", "DOOM Shareware Startup", shareware, english },
+ { NULL } };
+
+ for (i = 0; list[i].name; i++) {
+ const char *fn = list[i].name;
+ file = fopen(fn, "rb");
+ if (file) {
+ fclose(file);
+ language = list[i].language;
+ gamemode = list[i].gamemode;
+ title = list[i].title;
+ D_AddFile(fn);
+ return;
+ }
+ }
+#else
char* doom1wad;
char* doomwad;
char* doomuwad;
@@ -707,6 +720,7 @@ void IdentifyVersion (void)
D_AddFile (doom1wad);
return;
}
+#endif
printf("Game mode indeterminate.\n");
gamemode = indetermined;
@@ -814,6 +828,9 @@ void D_DoomMain (void)
else if (M_CheckParm ("-deathmatch"))
deathmatch = 1;
+#if 1
+ printf ("%s - v%i.%i\n", title, VERSION/100,VERSION%100);
+#else
switch ( gamemode )
{
case retail:
@@ -870,17 +887,11 @@ void D_DoomMain (void)
}
printf ("%s\n",title);
+#endif
if (devparm)
printf(D_DEVSTR);
- if (M_CheckParm("-cdrom"))
- {
- printf(D_CDROM);
- mkdir("c:\\doomdata",0);
- strcpy (basedefault,"c:/doomdata/default.cfg");
- }
-
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
{
@@ -1091,7 +1102,7 @@ void D_DoomMain (void)
printf ("M_Init: Init miscellaneous info.\n");
M_Init ();
- printf ("R_Init: Init DOOM refresh daemon - ");
+ printf ("R_Init: Init DOOM refresh daemon");
R_Init ();
printf ("\nP_Init: Init Playloop state.\n");
@@ -1112,17 +1123,6 @@ void D_DoomMain (void)
printf ("ST_Init: Init status bar.\n");
ST_Init ();
- // check for a driver that wants intermission stats
- p = M_CheckParm ("-statcopy");
- if (p && p<myargc-1)
- {
- // for statistics driver
- extern void* statcopy;
-
- statcopy = (void*)atoi(myargv[p+1]);
- printf ("External statistics registered.\n");
- }
-
// start the apropriate game based on parms
p = M_CheckParm ("-record");
@@ -1150,10 +1150,7 @@ void D_DoomMain (void)
p = M_CheckParm ("-loadgame");
if (p && p < myargc-1)
{
- if (M_CheckParm("-cdrom"))
- sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
- else
- sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
+ sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
G_LoadGame (file);
}
diff --git a/d_main.h b/d_main.h
index 7763e13..8b02a08 100644
--- a/d_main.h
+++ b/d_main.h
@@ -36,7 +36,7 @@
#define MAXWADFILES 20
extern char* wadfiles[MAXWADFILES];
-void D_AddFile (char *file);
+void D_AddFile (const char *file);
diff --git a/d_net.c b/d_net.c
index 75b5436..e56c8cd 100644
--- a/d_net.c
+++ b/d_net.c
@@ -89,7 +89,7 @@ doomdata_t reboundstore;
//
int NetbufferSize (void)
{
- return (int)&(((doomdata_t *)0)->cmds[netbuffer->numtics]);
+ return (intptr_t)&(((doomdata_t *)0)->cmds[netbuffer->numtics]);
}
//
@@ -97,21 +97,21 @@ int NetbufferSize (void)
//
unsigned NetbufferChecksum (void)
{
+#ifdef NORMALUNIX
+ // FIXME -endianess?
+ return 0; // byte order problems
+#else
unsigned c;
int i,l;
c = 0x1234567;
- // FIXME -endianess?
-#ifdef NORMALUNIX
- return 0; // byte order problems
-#endif
-
- l = (NetbufferSize () - (int)&(((doomdata_t *)0)->retransmitfrom))/4;
+ l = (NetbufferSize () - (intptr_t)&(((doomdata_t *)0)->retransmitfrom))/4;
for (i=0 ; i<l ; i++)
c += ((unsigned *)&netbuffer->retransmitfrom)[i] * (i+1);
return c & NCMD_CHECKSUM;
+#endif
}
//
@@ -461,7 +461,7 @@ void CheckAbort (void)
I_StartTic ();
for ( ; eventtail != eventhead
- ; eventtail = (++eventtail)&(MAXEVENTS-1) )
+ ; eventtail = (eventtail+1)&(MAXEVENTS-1) )
{
ev = &events[eventtail];
if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE)
diff --git a/d_player.h b/d_player.h
index 0a4d887..d65e274 100644
--- a/d_player.h
+++ b/d_player.h
@@ -106,8 +106,8 @@ typedef struct player_s
// Power ups. invinc and invis are tic counters.
int powers[NUMPOWERS];
- boolean cards[NUMCARDS];
- boolean backpack;
+ savebool_t cards[NUMCARDS];
+ savebool_t backpack;
// Frags, kills of other players.
int frags[MAXPLAYERS];
@@ -116,7 +116,7 @@ typedef struct player_s
// Is wp_nochange if not changing.
weapontype_t pendingweapon;
- boolean weaponowned[NUMWEAPONS];
+ savebool_t weaponowned[NUMWEAPONS];
int ammo[NUMAMMO];
int maxammo[NUMAMMO];
@@ -161,7 +161,7 @@ typedef struct player_s
pspdef_t psprites[NUMPSPRITES];
// True if secret level has been done.
- boolean didsecret;
+ savebool_t didsecret;
} player_t;
diff --git a/d_ticcmd.h b/d_ticcmd.h
index 5817989..516ea1d 100644
--- a/d_ticcmd.h
+++ b/d_ticcmd.h
@@ -35,8 +35,8 @@
// plus a checksum for internal state consistency.
typedef struct
{
- char forwardmove; // *2048 for move
- char sidemove; // *2048 for move
+ signed char forwardmove; // *2048 for move
+ signed char sidemove; // *2048 for move
short angleturn; // <<16 for angle delta
short consistancy; // checks for net game
byte chatchar;
diff --git a/doomdata.h b/doomdata.h
index bab5e00..f9b3926 100644
--- a/doomdata.h
+++ b/doomdata.h
@@ -61,7 +61,7 @@ typedef struct
{
short x;
short y;
-} mapvertex_t;
+} PACKED mapvertex_t;
// A SideDef, defining the visual appearance of a wall,
@@ -75,7 +75,7 @@ typedef struct
char midtexture[8];
// Front sector, towards viewer.
short sector;
-} mapsidedef_t;
+} PACKED mapsidedef_t;
@@ -90,7 +90,7 @@ typedef struct
short tag;
// sidenum[1] will be -1 if one sided
short sidenum[2];
-} maplinedef_t;
+} PACKED maplinedef_t;
//
@@ -147,7 +147,7 @@ typedef struct
short lightlevel;
short special;
short tag;
-} mapsector_t;
+} PACKED mapsector_t;
// SubSector, as generated by BSP.
typedef struct
@@ -155,7 +155,7 @@ typedef struct
short numsegs;
// Index of first one, segs are stored sequentially.
short firstseg;
-} mapsubsector_t;
+} PACKED mapsubsector_t;
// LineSeg, generated by splitting LineDefs
@@ -168,7 +168,7 @@ typedef struct
short linedef;
short side;
short offset;
-} mapseg_t;
+} PACKED mapseg_t;
@@ -193,7 +193,7 @@ typedef struct
// else it's a node of another subtree.
unsigned short children[2];
-} mapnode_t;
+} PACKED mapnode_t;
@@ -207,7 +207,7 @@ typedef struct
short angle;
short type;
short options;
-} mapthing_t;
+} PACKED mapthing_t;
diff --git a/doomdef.h b/doomdef.h
index 1850477..5571030 100644
--- a/doomdef.h
+++ b/doomdef.h
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdint.h>
//
// Global parameters/defines.
@@ -81,7 +82,7 @@ typedef enum
// and unfinished. Default is synchronous.
// Experimental asynchronous timer based is
// handled by SNDINTR.
-#define SNDSERV 1
+//#define SNDSERV 1
//#define SNDINTR 1
diff --git a/doomstat.h b/doomstat.h
index 65f5225..40faa77 100644
--- a/doomstat.h
+++ b/doomstat.h
@@ -241,7 +241,6 @@ extern int maxammo[NUMAMMO];
//
// File handling stuff.
-extern char basedefault[1024];
extern FILE* debugfile;
// if true, load all graphics at level load
diff --git a/doomtype.h b/doomtype.h
index e89a7a6..97a7685 100644
--- a/doomtype.h
+++ b/doomtype.h
@@ -56,7 +56,14 @@ typedef unsigned char byte;
#endif
+#ifdef __GNUC__
+#define PACKED __attribute__((packed))
+#else
+#define PACKED
+#endif
+// for compatible savegames
+typedef int savebool_t;
#endif
//-----------------------------------------------------------------------------
diff --git a/dstrings.c b/dstrings.c
index e6abe88..bc1e5b2 100644
--- a/dstrings.c
+++ b/dstrings.c
@@ -42,7 +42,7 @@ char* endmsg[NUM_QUITMESSAGES+1]=
"you're trying to say you like dos\nbetter than me, right?",
"don't leave yet -- there's a\ndemon around that corner!",
"ya know, next time you come in here\ni'm gonna toast ya.",
- "go ahead and leave. see if i care."
+ "go ahead and leave. see if i care.",
// QuitDOOM II messages
"you want to quit?\nthen, thou hast lost an eighth!",
@@ -51,7 +51,7 @@ char* endmsg[NUM_QUITMESSAGES+1]=
"if i were your boss, i'd \n deathmatch ya in a minute!",
"look, bud. you leave now\nand you forfeit your body count!",
"just leave. when you come\nback, i'll be waiting with a bat.",
- "you're lucky i don't smack\nyou for thinking about leaving."
+ "you're lucky i don't smack\nyou for thinking about leaving.",
// FinalDOOM?
"fuck you, pussy!\nget the fuck out!",
diff --git a/f_wipe.c b/f_wipe.c
index e8596f3..2ebcb10 100644
--- a/f_wipe.c
+++ b/f_wipe.c
@@ -57,7 +57,7 @@ wipe_shittyColMajorXform
int y;
short* dest;
- dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0);
+ dest = (short*) Z_Malloc(width*height*sizeof(*dest), PU_STATIC, 0);
for(y=0;y<height;y++)
for(x=0;x<width;x++)
@@ -155,7 +155,7 @@ wipe_initMelt
// setup initial column positions
// (y<0 => not ready to scroll yet)
- y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0);
+ y = (int *) Z_Malloc(width*sizeof(*y), PU_STATIC, 0);
y[0] = -(M_Random()%16);
for (i=1;i<width;i++)
{
diff --git a/g_game.c b/g_game.c
index 30ac33c..fada899 100644
--- a/g_game.c
+++ b/g_game.c
@@ -24,6 +24,7 @@
static const char
rcsid[] = "$Id: g_game.c,v 1.8 1997/02/03 22:45:09 b1 Exp $";
+#include <ctype.h>
#include <string.h>
#include <stdlib.h>
@@ -180,7 +181,7 @@ fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn
#define NUMKEYS 256
-boolean gamekeydown[NUMKEYS];
+char gamekeydown[NUMKEYS];
int turnheld; // for accelerative turning
boolean mousearray[4];
@@ -212,7 +213,6 @@ char savedescription[32];
mobj_t* bodyque[BODYQUESIZE];
int bodyqueslot;
-void* statcopy; // for statistics driver
@@ -492,8 +492,8 @@ void G_DoLoadLevel (void)
joyxmove = joyymove = 0;
mousex = mousey = 0;
sendpause = sendsave = paused = false;
- memset (mousebuttons, 0, sizeof(mousebuttons));
- memset (joybuttons, 0, sizeof(joybuttons));
+ memset (mousearray, 0, sizeof(mousearray));
+ memset (joyarray, 0, sizeof(joyarray));
}
@@ -1133,9 +1133,6 @@ void G_DoCompleted (void)
gamestate = GS_INTERMISSION;
viewactive = false;
automapactive = false;
-
- if (statcopy)
- memcpy (statcopy, &wminfo, sizeof(wminfo));
WI_Start (&wminfo);
}
@@ -1197,13 +1194,13 @@ void G_LoadGame (char* name)
#define VERSIONSIZE 16
+extern int gameversion;
void G_DoLoadGame (void)
{
int length;
int i;
int a,b,c;
- char vcheck[VERSIONSIZE];
gameaction = ga_nothing;
@@ -1211,10 +1208,8 @@ void G_DoLoadGame (void)
save_p = savebuffer + SAVESTRINGSIZE;
// skip the description field
- memset (vcheck,0,sizeof(vcheck));
- sprintf (vcheck,"version %i",VERSION);
- if (strcmp (save_p, vcheck))
- return; // bad version
+ if (save_p[11] || memcmp(save_p, "version ", 8)) return;
+ if (atoi((char*)&save_p[8]) != gameversion) return;
save_p += VERSIONSIZE;
gameskill = *save_p++;
@@ -1266,6 +1261,7 @@ G_SaveGame
strcpy (savedescription, description);
sendsave = true;
}
+
void G_DoSaveGame (void)
{
@@ -1275,10 +1271,7 @@ void G_DoSaveGame (void)
int length;
int i;
- if (M_CheckParm("-cdrom"))
- sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot);
- else
- sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
+ sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
description = savedescription;
save_p = savebuffer = screens[1]+0x4000;
@@ -1286,7 +1279,7 @@ void G_DoSaveGame (void)
memcpy (save_p, description, SAVESTRINGSIZE);
save_p += SAVESTRINGSIZE;
memset (name2,0,sizeof(name2));
- sprintf (name2,"version %i",VERSION);
+ sprintf (name2,"version %i",gameversion);
memcpy (save_p, name2, VERSIONSIZE);
save_p += VERSIONSIZE;
@@ -1586,9 +1579,10 @@ void G_DoPlayDemo (void)
gameaction = ga_nothing;
demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC);
- if ( *demo_p++ != VERSION)
+ if ( *demo_p++ != gameversion)
{
- fprintf( stderr, "Demo is from a different game version!\n");
+ fprintf( stderr, "Demo is from a different game version!"
+ " (v%d.%02d)\n", demo_p[-1] / 100, demo_p[-1] % 100);
gameaction = ga_nothing;
return;
}
diff --git a/i_net.c b/i_net.c
index 557f417..773bca7 100644
--- a/i_net.c
+++ b/i_net.c
@@ -27,6 +27,7 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <string.h>
#include <stdio.h>
+#if 0
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -34,6 +35,7 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <unistd.h>
#include <netdb.h>
#include <sys/ioctl.h>
+#endif
#include "i_system.h"
#include "d_event.h"
@@ -47,6 +49,21 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#endif
#include "i_net.h"
+#if 1
+void I_InitNetwork (void) {
+ doomcom = malloc (sizeof (*doomcom) );
+ memset (doomcom, 0, sizeof(*doomcom) );
+
+ doomcom-> ticdup = 1;
+
+ doomcom->id = DOOMCOM_ID;
+ doomcom->numplayers = doomcom->numnodes = 1;
+ doomcom->deathmatch = false;
+ doomcom->consoleplayer = 0;
+}
+
+void I_NetCmd (void) { }
+#else
@@ -345,4 +362,5 @@ void I_NetCmd (void)
else
I_Error ("Bad net cmd: %i\n",doomcom->command);
}
+#endif
diff --git a/i_sound.c b/i_sound.c
index a327bfa..89ae9a0 100644
--- a/i_sound.c
+++ b/i_sound.c
@@ -26,6 +26,48 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
#include <stdio.h>
#include <stdlib.h>
+#if 1
+#include "z_zone.h"
+
+#include "i_system.h"
+#include "i_sound.h"
+#include "m_argv.h"
+#include "m_misc.h"
+#include "w_wad.h"
+
+#include "doomdef.h"
+
+void I_SetChannels() { }
+void I_SetSfxVolume(int volume) { }
+void I_SetMusicVolume(int volume) { }
+
+int I_GetSfxLumpNum(sfxinfo_t* sfx) {
+ char namebuf[9];
+ sprintf(namebuf, "ds%s", sfx->name);
+ return W_GetNumForName(namebuf);
+}
+
+int I_StartSound(int id, int vol, int sep, int pitch, int priority) { return id; }
+void I_StopSound (int handle) { }
+int I_SoundIsPlaying(int handle) { return 0; }
+void I_UpdateSound(void) { }
+void I_SubmitSound(void) { }
+void I_UpdateSoundParams(int handle, int vol, int sep, int pitch) { }
+void I_ShutdownSound(void) { }
+void I_InitSound() { }
+void I_InitMusic(void) { }
+void I_ShutdownMusic(void) { }
+void I_PlaySong(int handle, int looping) { }
+void I_PauseSong (int handle) { }
+void I_ResumeSong (int handle) { }
+void I_StopSong(int handle) { }
+void I_UnRegisterSong(int handle) { }
+int I_RegisterSong(void* data) { return 1; }
+int I_QrySongPlaying(int handle) { return 0; }
+void I_HandleSoundTimer(int ignore ) { }
+int I_SoundSetTimer(int duration_of_tick ) { return 0; }
+void I_SoundDelTimer() { }
+#else
#include <stdarg.h>
#include <math.h>
@@ -983,3 +1025,4 @@ void I_SoundDelTimer()
if ( I_SoundSetTimer( 0 ) == -1)
fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n");
}
+#endif
diff --git a/i_system.c b/i_system.c
index 1b67d51..dd9d5d1 100644
--- a/i_system.c
+++ b/i_system.c
@@ -30,7 +30,11 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <stdarg.h>
#include <sys/time.h>
+#if defined(EMBEDDED)
+#include "../syscode.h"
+#else
#include <unistd.h>
+#endif
#include "doomdef.h"
#include "m_misc.h"
@@ -48,7 +52,11 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
+#ifdef EMBEDDED
+int mb_used = 3;
+#else
int mb_used = 6;
+#endif
void
@@ -87,16 +95,41 @@ byte* I_ZoneBase (int* size)
//
int I_GetTime (void)
{
+#ifdef EMBEDDED
+ static unsigned last1 = 0, last2 = 0;
+ unsigned t1 = sys_timer_ms();
+ unsigned t2, t3, t4 = last2;
+
+ t2 = t1 - last1;
+ if (t2 >= 1000) {
+ if (t2 < 2000) {
+ t2 -= 1000;
+ t4 += TICRATE;
+ } else {
+ // slow path
+ t3 = t2 / 1000;
+ t2 -= t3 * 1000;
+ t4 += t3 * TICRATE;
+ }
+ last2 = t4;
+ last1 = t1 - t2;
+ }
+#if TICRATE == 35
+ return t4 + (t2 * 0x11eb9 >> 21);
+#else
+ return t4 + (t2 * TICRATE) / 1000;
+#endif
+#else
struct timeval tp;
- struct timezone tzp;
int newtics;
static int basetime=0;
- gettimeofday(&tp, &tzp);
+ gettimeofday(&tp, NULL);
if (!basetime)
basetime = tp.tv_sec;
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
return newtics;
+#endif
}
@@ -125,15 +158,11 @@ void I_Quit (void)
void I_WaitVBL(int count)
{
-#ifdef SGI
- sginap(1);
-#else
-#ifdef SUN
- sleep(0);
+#if defined(EMBEDDED)
+ sys_wait_ms(count*1000/70);
#else
usleep (count * (1000000/70) );
#endif
-#endif
}
void I_BeginRead(void)
diff --git a/i_system.h b/i_system.h
index 8954140..d814a9f 100644
--- a/i_system.h
+++ b/i_system.h
@@ -86,6 +86,7 @@ byte* I_AllocLow (int length);
void I_Tactile (int on, int off, int total);
+__attribute__((noreturn))
void I_Error (char *error, ...);
diff --git a/i_video.c b/i_video.c
index 9b311b3..a8b4fcd 100644
--- a/i_video.c
+++ b/i_video.c
@@ -25,6 +25,7 @@ static const char
rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h>
+#ifndef EMBEDDED
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
@@ -47,6 +48,7 @@ int XShmGetEventBase( Display* dpy ); // problems with g++?
#include <netinet/in.h>
#include <errnos.h>
+#endif
#include <signal.h>
#include "doomstat.h"
@@ -59,6 +61,11 @@ int XShmGetEventBase( Display* dpy ); // problems with g++?
#define POINTER_WARP_COUNTDOWN 1
+#ifdef EMBEDDED
+#include "../syscode.h"
+
+byte* imagedata=NULL;
+#else
Display* X_display=0;
Window X_mainWindow;
Colormap X_cmap;
@@ -82,6 +89,7 @@ int X_shmeventtype;
// Needs an invisible mouse cursor at least.
boolean grabMouse;
int doPointerWarp = POINTER_WARP_COUNTDOWN;
+#endif
// Blocky mode,
// replace each 320x200 pixel with multiply*multiply pixels.
@@ -89,6 +97,89 @@ int doPointerWarp = POINTER_WARP_COUNTDOWN;
// to use ....
static int multiply=1;
+#ifdef EMBEDDED
+int I_CycleWeapon(int dir) {
+ player_t* p = &players[consoleplayer];
+ weapontype_t cur = p->readyweapon, next = cur;
+ static const char cycle[2][NUMWEAPONS] = { {
+ /* wp_fist */ wp_bfg,
+ /* wp_pistol */ wp_chainsaw,
+ /* wp_shotgun */ wp_pistol,
+ /* wp_chaingun */ wp_supershotgun,
+ /* wp_missile */ wp_chaingun,
+ /* wp_plasma */ wp_missile,
+ /* wp_bfg */ wp_plasma,
+ /* wp_chainsaw */ wp_fist,
+ /* wp_supershotgun */ wp_shotgun
+ }, {
+ /* wp_fist */ wp_chainsaw,
+ /* wp_pistol */ wp_shotgun,
+ /* wp_shotgun */ wp_supershotgun,
+ /* wp_chaingun */ wp_missile,
+ /* wp_missile */ wp_plasma,
+ /* wp_plasma */ wp_bfg,
+ /* wp_bfg */ wp_fist,
+ /* wp_chainsaw */ wp_pistol,
+ /* wp_supershotgun */ wp_chaingun
+ } };
+ do {
+ next = cycle[dir][next];
+ if (p->weaponowned[next]) {
+#if 0
+ if (1) {
+#else
+ ammotype_t ammo = weaponinfo[next].ammo;
+ if (ammo == am_noammo || p->ammo[ammo] > 0) {
+#endif
+ // p->pendingweapon = next;
+ return "123456713"[next];
+ }
+ }
+ } while (next != cur);
+ return 0x8000;
+}
+
+#define KEY_RSHIFT (0x80+0x36)
+extern char gamekeydown[256];
+
+void I_ShutdownGraphics() { }
+void I_StartFrame() { }
+void I_StartTic() {
+ static int keyup = 0;
+ int type, key;
+ event_t event;
+ if (keyup) {
+ event.type = ev_keyup;
+ event.data1 = keyup;
+ D_PostEvent(&event);
+ keyup = 0;
+ }
+ for (;;) {
+ type = CHIP_FN2(sys_event)(&key);
+ switch (type) {
+ case EVENT_KEYDOWN:
+ if (key == KEY_ENTER && !menuactive) key = ' ';
+ if (key == KEY_RSHIFT && gamekeydown[KEY_RSHIFT]) goto keyup;
+ if (keyup);
+ else if (key == '[') keyup = key = I_CycleWeapon(0);
+ else if (key == ']') keyup = key = I_CycleWeapon(1);
+ event.type = ev_keydown;
+ event.data1 = key;
+ D_PostEvent(&event);
+ break;
+ case EVENT_KEYUP:
+ if (key == KEY_ENTER && !menuactive) key = ' ';
+ if (key == KEY_RSHIFT) break;
+keyup: event.type = ev_keyup;
+ event.data1 = key;
+ D_PostEvent(&event);
+ break;
+ case EVENT_END: return;
+ case EVENT_QUIT: I_Quit();
+ }
+ }
+}
+#else
//
// Translates the key currently in X_event
@@ -272,7 +363,7 @@ void I_GetEvent(void)
break;
default:
- if (doShm && X_event.type == X_shmeventtype) shmFinished = true;
+ if (doShm && X_event.type == X_shmeventtype) shmFinished = true;
break;
}
@@ -336,6 +427,7 @@ void I_StartTic (void)
mousemoved = false;
}
+#endif
//
@@ -373,6 +465,11 @@ void I_FinishUpdate (void)
}
+#ifdef EMBEDDED
+ CHIP_FN2(sys_wait_refresh)();
+ app_scr_update(screens[0], imagedata);
+ CHIP_FN2(sys_start_refresh)();
+#else
// scales the screen size before blitting it
if (multiply == 2)
{
@@ -518,6 +615,7 @@ void I_FinishUpdate (void)
}