]> 4ch.mooo.com Git - 16.git/commitdiff
p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I...
authorsparky4 <sparky4@cock.li>
Wed, 5 Apr 2017 19:23:12 +0000 (14:23 -0500)
committersparky4 <sparky4@cock.li>
Wed, 5 Apr 2017 19:23:12 +0000 (14:23 -0500)
13 files changed:
data/16.pal
data/default.pal
data/vga.pal [new file with mode: 0755]
makefile
src/lib/16_head.c
src/lib/16_tail.c
src/lib/16_tdef.h
src/lib/16_us.c
src/lib/16_us.c_ [new file with mode: 0755]
src/lib/16_us.h_ [new file with mode: 0755]
src/palbomb.c [new file with mode: 0755]
src/palettec.c
src/palettel.c

index eaf5208550ce2b2d7a255488e2de6b8d22afb6c8..f05da004cad15f399871fc26601235b9c128263a 100755 (executable)
Binary files a/data/16.pal and b/data/16.pal differ
index e98ae60e3d21a9409f12ef6b1f2ad3625750e734..db7cd033a49a21d9c111a6e74e65735939169672 100755 (executable)
Binary files a/data/default.pal and b/data/default.pal differ
diff --git a/data/vga.pal b/data/vga.pal
new file mode 100755 (executable)
index 0000000..0ecbac3
Binary files /dev/null and b/data/vga.pal differ
index cb9839b122160c6744c5681fb9ba35fbb702720b..58c4aa71153557acbbef204001a309d37183d016 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -210,6 +210,7 @@ TESTEXEC3= &
 UTILEXEC = &
        palettel.exe &
        palllist.exe &
+       palbomb.exe &
        palettec.exe
 !ifdef __LINUX__
 SPRIUTILEXEC = &
@@ -270,9 +271,10 @@ inputest.exe:       inputest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib
 pcxtest.exe:   pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
 vrstest.exe:   vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
 #vgacamm.exe:  vgacamm.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
-palettec.exe:  palettec.$(OBJ) gfx.lib $(DOSLIB)
-palettel.exe:          palettel.$(OBJ) gfx.lib $(DOSLIB)
-palllist.exe:          palllist.$(OBJ) gfx.lib $(DOSLIB) ll.$(OBJ)
+palettec.exe:  palettec.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
+palettel.exe:          palettel.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
+palbomb.exe:   palbomb.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
+palllist.exe:          palllist.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) ll.$(OBJ)
 pcxtest2.exe:   pcxtest2.$(OBJ) gfx.lib $(DOSLIB)
 #planrpcx.exe: planrpcx.$(OBJ) gfx.lib
 maptest.exe:   maptest.$(OBJ) 16_map.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIB) $(16LIB)
@@ -298,6 +300,7 @@ vrstest.$(OBJ):$(SRC)/vrstest.c $(SRCLIB)/16_vl.h
 pcxtest2.$(OBJ):$(SRC)/pcxtest2.c $(SRCLIB)/16_vl.h
 palettec.$(OBJ):       $(SRC)/palettec.c
 palettel.$(OBJ):       $(SRC)/palettel.c
+palbomb.$(OBJ):        $(SRC)/palbomb.c
 palllist.$(OBJ):       $(SRC)/palllist.c
 maptest.$(OBJ):$(SRC)/maptest.c $(SRCLIB)/16_vl.h
 #emmtest.$(OBJ):$(SRC)/emmtest.c
index 5764183bf8dad641d6e9b97d8ecfc3ed7cd53bc7..f0175d435001a5bda0f7004f38fcd70518085a29 100755 (executable)
@@ -182,7 +182,7 @@ void print_mem(void const *vp, size_t n)
        {\r
                printf("%02x", p[i]);\r
                //printf("%c", p[i]);\r
-               if(!((i)%16)) printf("\n");\r
+               if((!(i%16)) && i) printf("\n");\r
                else printf(" ");\r
                //printf("%u%%40=%u\n", i, i%40);\r
        }\r
index c0d6d89fdee243505a3ce0ed990b0d2d39117771..2e045c58ebd2ae354972ec65347fa87308b1d7c6 100755 (executable)
@@ -134,6 +134,7 @@ void        TL_VidInit(global_game_variables_t *gvar)
 #else\r
        gvar->video.old_mode = 3;\r
 #endif\r
+       gvar->video.VL_Initiated = 1;\r
 }\r
 \r
 \r
index fac2ba26fab254d9ff33b935a0d66a864c9d1d31..c57753875ecfbcb88264be8f60fef0fb41948aa6 100755 (executable)
@@ -385,10 +385,9 @@ typedef struct
 \r
 typedef struct\r
 {\r
-       boolean VL_Started;\r
+       boolean VL_Started,VL_Initiated;\r
        char old_mode;          //old video mode before game!\r
        byte palette[PALSIZE], dpal[PALSIZE];   //palette array\r
-       byte            far     palette1[256][3],far palette2[256][3];\r
        page_t page[MAXPAGE];   //can be used as a pointer to root page[0]\r
        word vmem_remain;       //remaining video memory\r
        byte num_of_pages;      //number of actual pages\r
@@ -408,6 +407,7 @@ typedef struct
        boolean screenfaded;\r
        word            bordercolor;\r
        boolean fastpalette;\r
+       byte            far     palette1[256][3],far palette2[256][3];\r
 } video_t;\r
 \r
 //from scroll16\r
index ec2b3b28cd5e8aaba2300d51acdd22c03e93dac5..ffd4d8ad8b0f2b4ba35138402e6c6bf94bd91ce4 100755 (executable)
@@ -1,57 +1,70 @@
-/*#include "src/lib/16_in.h"\r
+#include "src/lib/16_us.h"\r
+\r
+word px,py;\r
+word PrintX,PrintY;\r
+word WindowX,WindowY,WindowW,WindowH;\r
+\r
 static word far* clockw= (word far*) 0x046C; // 18.2hz clock\r
 \r
-#define CtlPanelSX     1\r
-#define CtlPanelSY     1\r
-#define CtlPanelEX     1\r
-#define CtlPanelEY     1\r
-#define TickBase               1\r
-\r
-#define PaddleMinX      (CtlPanelSX + 3)\r
-#define PaddleMaxX      (CtlPanelEX - 15)\r
-#define BallMinX        (CtlPanelSX + 2)\r
-#define BallMinY        (CtlPanelSY + 12 + 2)\r
-#define BallMaxX        (CtlPanelEX - 6)\r
-#define BallMaxY        (CtlPanelEY - 13)\r
-#define CPaddleY        (BallMinY + 4)\r
-#define KPaddleY        (BallMaxY - 2)\r
+//      Control panel data\r
+\r
+#define CtlPanelSX     74\r
+#define CtlPanelSY     48\r
+#define CtlPanelEX     234\r
+#define CtlPanelEY     150\r
+#define CtlPanelW      (CtlPanelEX - CtlPanelSX)\r
+#define CtlPanelH      (CtlPanelEY - CtlPanelSY)\r
+\r
+#define        TickBase        70              // 70Hz per tick - used as a base for timer 0\r
+\r
+#define PaddleMinX     (CtlPanelSX + 3)\r
+#define PaddleMaxX     (CtlPanelEX - 15)\r
+#define BallMinX               (CtlPanelSX + 2)\r
+#define BallMinY               (CtlPanelSY + 12 + 2)\r
+#define BallMaxX               (CtlPanelEX - 6)\r
+#define BallMaxY               (CtlPanelEY - 13)\r
+#define CPaddleY               (BallMinY + 4)\r
+#define KPaddleY               (BallMaxY - 2)\r
 void\r
-USL_DrawPongScore(word k,word c)\r
+USL_DrawPongScore(word k,word c, global_game_variables_t *gvar)\r
 {\r
        //++++fontcolor = HiliteColor;\r
-       //++++PrintY = py = CtlPanelSY + 4;\r
-       //++++px = CtlPanelSX + 6;\r
-       //++++VWB_Bar(px,py,42,6,BackColor);\r
+       PrintY = py = CtlPanelSY + 4;\r
+       px = CtlPanelSX + 6;\r
+       VLB_Bar(px,py,42,6,3/*BackColor*/, &gvar->video.ofs);\r
        //++++USL_DrawString("YOU:");\r
-       //++++PrintX = px;\r
+//     modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str)\r
+       modexprint(gvar->video.page, px, py, 1, 0, 4, 8, 1, "YOU:");\r
+       PrintX = px;\r
        //++++US_PrintUnsigned(k);\r
-       //++++px = CtlPanelSX + 108;\r
-       //++++VWB_Bar(px,py,50,6,BackColor);\r
+       px = CtlPanelSX + 108;\r
+       VLB_Bar(px,py,50,6,3/*BackColor*/, &gvar->video.ofs);\r
        //++++USL_DrawString("COMP:");\r
-       //++++PrintX = px;\r
+       modexprint(gvar->video.page, px, py, 1, 0, 4, 8, 1, "COMP:");\r
+       PrintX = px;\r
        //++++US_PrintUnsigned(c);\r
 }\r
 \r
 void\r
-USL_PlayPong(void)\r
+USL_PlayPong(global_game_variables_t *gvar)\r
 {\r
-       boolean         ball,killball,revdir,done,lastscore;\r
-       word            cycle,\r
+       boolean         ball,killball,revdir,done,lastscore;\r
+       word                    cycle,\r
                                x,y,\r
                                kx,cx,\r
                                rx,\r
                                bx,by,\r
                                kscore,cscore,\r
                                speedup;\r
-       int                     bdx,bdy;\r
-       word        balltime,waittime;\r
-       CursorInfo      cursorinfo;\r
+       int                     bdx,bdy;\r
+       word                    balltime,waittime;\r
+       CursorInfo              cursorinfo;\r
        word TimeCount = *clockw;\r
 \r
        kx = cx = PaddleMinX + ((PaddleMaxX - PaddleMinX) / 2);\r
        bx = by = bdx = bdy = 0;\r
        kscore = cscore = 0;\r
-       USL_DrawPongScore(0,0);\r
+       USL_DrawPongScore(0,0, gvar);\r
        cycle = 0;\r
        revdir = false;\r
        killball = true;\r
@@ -61,7 +74,7 @@ USL_PlayPong(void)
        {\r
                waittime = TimeCount;\r
 \r
-               IN_ReadCursor(&cursorinfo);\r
+               IN_ReadCursor(&cursorinfo, gvar);\r
                if (((cursorinfo.x < 0) || IN_KeyDown(sc_LeftArrow)) && (kx > PaddleMinX))\r
                        kx -= 2;\r
                else if (((cursorinfo.x > 0) || IN_KeyDown(sc_RightArrow)) && (kx < PaddleMaxX))\r
@@ -87,20 +100,28 @@ USL_PlayPong(void)
                                cx -= 1;\r
                }\r
 \r
-               //++++VWB_Bar(BallMinX,BallMinY - 1,\r
-               //              BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7,\r
-               //              BackColor);\r
-               //++++VWB_DrawSprite(cx,CPaddleY,PADDLESPR);\r
-               //++++VWB_DrawSprite(kx,KPaddleY,PADDLESPR);\r
+//++++\r
+//#if 1\r
+               VLB_Bar(BallMinX,BallMinY - 1,\r
+                               BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7,\r
+                               3/*BackColor*/, &gvar->video.ofs);\r
+#if 0\r
+               VWB_DrawSprite(cx,CPaddleY,PADDLESPR);\r
+               VWB_DrawSprite(kx,KPaddleY,PADDLESPR);\r
+\r
+               modexputPixel(gvar->video.page, BallMinX, BallMinY, 3);\r
+#endif\r
+               modexputPixel(gvar->video.page, cx, CPaddleY, 3);\r
+               modexputPixel(gvar->video.page, kx, KPaddleY, 3);\r
                if (ball)\r
                {\r
                        if\r
                        (\r
                                (((bx + bdx) >> 2) > BallMaxX)\r
-                       ||      (((bx + bdx) >> 2) < BallMinX)\r
+                       ||      (((bx + bdx) >> 2) < BallMinX)\r
                        )\r
                        {\r
-                               //++++SD__PlaySound(BALLBOUNCESND);\r
+//++++                         SD__PlaySound(BALLBOUNCESND);\r
                                bdx = -bdx;\r
                        }\r
                        bx += bdx;\r
@@ -110,11 +131,11 @@ USL_PlayPong(void)
                                killball = true;\r
                                lastscore = false;\r
                                cscore++;\r
-                               //++++SD__PlaySound(COMPSCOREDSND);\r
-                               USL_DrawPongScore(kscore,cscore);\r
+//++++                         SD__PlaySound(COMPSCOREDSND);\r
+                               USL_DrawPongScore(kscore,cscore, gvar);\r
                                if (cscore == 21)\r
                                {\r
-                                       USL_CtlDialog("You lost!","Press any key",nil);\r
+//++++                                 USL_CtlDialog("You lost!","Press any key",nil);\r
                                        done = true;\r
                                        continue;\r
                                }\r
@@ -124,11 +145,11 @@ USL_PlayPong(void)
                                killball = true;\r
                                lastscore = true;\r
                                kscore++;\r
-                               //++++SD__PlaySound(KEENSCOREDSND);\r
-                               USL_DrawPongScore(kscore,cscore);\r
+//++++                         SD__PlaySound(KEENSCOREDSND);\r
+                               USL_DrawPongScore(kscore,cscore, gvar);\r
                                if (kscore == 21)\r
                                {\r
-                                       USL_CtlDialog("You won!","Press any key",nil);\r
+//++++                                 USL_CtlDialog("You won!","Press any key",nil);\r
                                        done = true;\r
                                        continue;\r
                                }\r
@@ -142,19 +163,19 @@ USL_PlayPong(void)
                                if\r
                                (\r
                                        (bdy < 0)\r
-                               &&      ((y >= CPaddleY) && (y < CPaddleY + 3))\r
-                               &&      ((x >= (cx - 5)) && (x < (cx + 11)))\r
+                               &&      ((y >= CPaddleY) && (y < CPaddleY + 3))\r
+                               &&      ((x >= (cx - 5)) && (x < (cx + 11)))\r
                                )\r
                                {\r
                                        rx = cx;\r
                                        revdir = true;\r
-                                       //++++SD__PlaySound(COMPPADDLESND);\r
+//++++                         SD__PlaySound(COMPPADDLESND);\r
                                }\r
                                else if\r
                                (\r
                                        (bdy > 0)\r
-                               &&      ((y >= (KPaddleY - 3)) && (y < KPaddleY))\r
-                               &&      ((x >= (kx - 5)) && (x < (kx + 11)))\r
+                               &&      ((y >= (KPaddleY - 3)) && (y < KPaddleY))\r
+                               &&      ((x >= (kx - 5)) && (x < (kx + 11)))\r
                                )\r
                                {\r
                                        if (((bdy >> 2) < 3) && !(--speedup))\r
@@ -164,7 +185,7 @@ USL_PlayPong(void)
                                        }\r
                                        rx = kx;\r
                                        revdir = true;\r
-                                       //++++SD__PlaySound(KEENPADDLESND);\r
+//++++                                 SD__PlaySound(KEENPADDLESND);\r
                                }\r
                                if (revdir)\r
                                {\r
@@ -175,7 +196,7 @@ USL_PlayPong(void)
                                        revdir = false;\r
                                }\r
                        }\r
-                       //++++VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR);\r
+//++++                 VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR);\r
                }\r
                else if (TimeCount >= balltime)\r
                {\r
@@ -187,13 +208,13 @@ USL_PlayPong(void)
                        bx = (BallMinX + ((BallMaxX - BallMinX) / 2)) << 2;\r
                        by = (BallMinY + ((BallMaxY - BallMinY) / 2)) << 2;\r
                }\r
-               //++++VW_UpdateScreen();\r
-               while (waittime == TimeCount)\r
-                       ;       // DEBUG - do adaptiveness\r
-       } while ((inpu.LastScan != sc_Escape) && !done);\r
+//++++         VW_UpdateScreen();\r
+               while (waittime == TimeCount){}\r
+                       //;       // DEBUG - do adaptiveness\r
+       } while ((gvar->in.inst->LastScan != sc_Escape) && !done);\r
        IN_ClearKeysDown();\r
 }\r
-\r
+/*\r
 #pragma argsused\r
 static boolean\r
 USL_PongCustom(UserCall call,struct UserItem far *item)\r
@@ -210,3 +231,35 @@ USL_PongCustom(UserCall call,struct UserItem far *item)
        return(true);\r
 }\r
 */\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+// US_RndT - Returns the next 8-bit pseudo random number\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+int US_RndT()\r
+{\r
+       int rndindex = 0;\r
+\r
+       byte rndtable[] = {\r
+       0,   8, 109, 220, 222, 241, 149, 107,  75, 248, 254, 140,  16,  66,\r
+       74,  21, 211,  47,  80, 242, 154,  27, 205, 128, 161,  89,  77,  36,\r
+       95, 110,  85,  48, 212, 140, 211, 249,  22,  79, 200,  50,  28, 188,\r
+       52, 140, 202, 120,  68, 145,  62,  70, 184, 190,  91, 197, 152, 224,\r
+       149, 104,  25, 178, 252, 182, 202, 182, 141, 197,   4,  81, 181, 242,\r
+       145,  42,  39, 227, 156, 198, 225, 193, 219,  93, 122, 175, 249,   0,\r
+       175, 143,  70, 239,  46, 246, 163,  53, 163, 109, 168, 135,   2, 235,\r
+       25,  92,  20, 145, 138,  77,  69, 166,  78, 176, 173, 212, 166, 113,\r
+       94, 161,  41,  50, 239,  49, 111, 164,  70,  60,   2,  37, 171,  75,\r
+       136, 156,  11,  56,  42, 146, 138, 229,  73, 146,  77,  61,  98, 196,\r
+       135, 106,  63, 197, 195,  86,  96, 203, 113, 101, 170, 247, 181, 113,\r
+       80, 250, 108,   7, 255, 237, 129, 226,  79, 107, 112, 166, 103, 241,\r
+       24, 223, 239, 120, 198,  58,  60,  82, 128,   3, 184,  66, 143, 224,\r
+       145, 224,  81, 206, 163,  45,  63,  90, 168, 114,  59,  33, 159,  95,\r
+       28, 139, 123,  98, 125, 196,  15,  70, 194, 253,  54,  14, 109, 226,\r
+       71,  17, 161,  93, 186,  87, 244, 138,  20,  52, 123, 251,  26,  36,\r
+       17,  46,  52, 231, 232,  76,  31, 221,  84,  37, 216, 165, 212, 106,\r
+       197, 242,  98,  43,  39, 175, 254, 145, 190,  84, 118, 222, 187, 136,\r
+       120, 163, 236, 249 };\r
+       rndindex = (rndindex+1)&0xff;\r
+       return rndtable[rndindex];\r
+}\r
diff --git a/src/lib/16_us.c_ b/src/lib/16_us.c_
new file mode 100755 (executable)
index 0000000..47034db
--- /dev/null
@@ -0,0 +1,969 @@
+//\r
+//     ID Engine\r
+//     ID_US_1.c - User Manager - General routines\r
+//     v1.1d1w\r
+//     By Jason Blochowiak\r
+//     Hacked up for Catacomb 3D\r
+//     Open Watcom port by sparky4\r
+//\r
+\r
+//\r
+//     This module handles dealing with user input & feedback\r
+//\r
+//     Depends on: Input Mgr, View Mgr, some variables from the Sound, Caching,\r
+//             and Refresh Mgrs, Memory Mgr for background save/restore\r
+//\r
+//     Globals:\r
+//             ingame - Flag set by game indicating if a game is in progress\r
+//      abortgame - Flag set if the current game should be aborted (if a load\r
+//                     game fails)\r
+//             loadedgame - Flag set if a game was loaded\r
+//             abortprogram - Normally nil, this points to a terminal error message\r
+//                     if the program needs to abort\r
+//             restartgame - Normally set to gd_Continue, this is set to one of the\r
+//                     difficulty levels if a new game should be started\r
+//             PrintX, PrintY - Where the User Mgr will print (global coords)\r
+//             WindowX,WindowY,WindowW,WindowH - The dimensions of the current\r
+//                     window\r
+//\r
+\r
+#include "src/lib/16_us.h"\r
+\r
+#pragma        hdrstop\r
+\r
+#pragma        warn    -pia\r
+\r
+static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
+\r
+//undeced vars\r
+boolean compatability; word px,py;\r
+\r
+//     Global variables\r
+               char            *abortprogram;\r
+               boolean         NoWait;\r
+               word            PrintX,PrintY;\r
+               word            WindowX,WindowY,WindowW,WindowH;\r
+\r
+//     Internal variables\r
+#define        ConfigVersion   1\r
+\r
+static char            *ParmStrings[] = {"TEDLEVEL","NOWAIT"},\r
+                                       *ParmStrings2[] = {"COMP","NOCOMP"};\r
+static boolean         US_Started;\r
+\r
+               boolean         Button0,Button1,\r
+                                       CursorBad;\r
+               int                     CursorX,CursorY;\r
+\r
+               void            (*USL_MeasureString)(char far *,word *,word *) = VW_MeasurePropString,\r
+                                       (*USL_DrawString)(char far *) = VWB_DrawPropString;\r
+\r
+               SaveGame        Games[MaxSaveGames];\r
+               HighScore       Scores[MaxScores] =\r
+                                       {\r
+                                               {"id software-'92",10000,1},\r
+                                               {"Adrian Carmack",10000,1},\r
+                                               {"John Carmack",10000,1},\r
+                                               {"Kevin Cloud",10000,1},\r
+                                               {"Tom Hall",10000,1},\r
+                                               {"John Romero",10000,1},\r
+                                               {"Jay Wilbur",10000,1},\r
+                                       };\r
+\r
+//     Internal routines\r
+\r
+//     Public routines\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     USL_HardError() - Handles the Abort/Retry/Fail sort of errors passed\r
+//                     from DOS.\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+#pragma        warn    -par\r
+#pragma        warn    -rch\r
+int\r
+USL_HardError(word errval,int ax,int bp,int si)\r
+{\r
+#define IGNORE  0\r
+#define RETRY   1\r
+#define        ABORT   2\r
+extern void    ShutdownId(void);\r
+\r
+static char            buf[32];\r
+static WindowRec       wr;\r
+               int                     dival=0;\r
+               char            c,*s,*t;\r
+\r
+       __asm {\r
+               mov     [dival],di\r
+       }\r
+       //dival = _DI;\r
+\r
+       if (ax < 0)\r
+               s = "Device Error";\r
+       else\r
+       {\r
+               if ((dival & 0x00ff) == 0)\r
+                       s = "Drive ~ is Write Protected";\r
+               else\r
+                       s = "Error on Drive ~";\r
+               for (t = buf;*s;s++,t++)        // Can't use sprintf()\r
+                       if ((*t = *s) == '~')\r
+                               *t = (ax & 0x00ff) + 'A';\r
+               *t = '\0';\r
+               s = buf;\r
+       }\r
+\r
+       c = peekb(0x40,0x49);   // Get the current screen mode\r
+       if ((c < 4) || (c == 7))\r
+               goto oh_kill_me;\r
+\r
+       // DEBUG - handle screen cleanup\r
+\r
+       US_SaveWindow(&wr);\r
+       US_CenterWindow(30,3);\r
+       US_CPrint(s);\r
+       US_CPrint("(R)etry or (A)bort?");\r
+       //++++VW_UpdateScreen();\r
+       IN_ClearKeysDown();\r
+\r
+__asm  sti     // Let the keyboard interrupts come through\r
+\r
+       while (true)\r
+       {\r
+               switch (IN_WaitForASCII())\r
+               {\r
+               case key_Escape:\r
+               case 'a':\r
+               case 'A':\r
+                       goto oh_kill_me;\r
+                       break;\r
+               case key_Return:\r
+               case key_Space:\r
+               case 'r':\r
+               case 'R':\r
+                       US_ClearWindow();\r
+                       //++++VW_UpdateScreen();\r
+                       US_RestoreWindow(&wr);\r
+                       return(RETRY);\r
+                       break;\r
+               }\r
+       }\r
+\r
+oh_kill_me:\r
+       abortprogram = s;\r
+       ShutdownId();\r
+       fprintf(stderr,"Terminal Error: %s\n",s);\r
+       if (tedlevel)\r
+               fprintf(stderr,"You launched from TED. I suggest that you reboot...\n");\r
+\r
+       return(ABORT);\r
+#undef IGNORE\r
+#undef RETRY\r
+#undef ABORT\r
+}\r
+#pragma        warn    +par\r
+#pragma        warn    +rch\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_Startup() - Starts the User Mgr\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_Startup(void)\r
+{\r
+       int     i,n;\r
+\r
+       if (US_Started)\r
+               return;\r
+\r
+       //++++_harderr(USL_HardError);  // Install the fatal error handler\r
+\r
+       US_InitRndT(true);              // Initialize the random number generator\r
+\r
+       for (i = 1;i < _argc;i++)\r
+       {\r
+               switch (US_CheckParm(_argv[i],ParmStrings2))\r
+               {\r
+               case 0:\r
+                       compatability = true;\r
+                       break;\r
+               case 1:\r
+                       compatability = false;\r
+                       break;\r
+               }\r
+       }\r
+\r
+       // Check for TED launching here\r
+       for (i = 1;i < _argc;i++)\r
+       {\r
+               n = US_CheckParm(_argv[i],ParmStrings);\r
+               switch(n)\r
+               {\r
+                case 0:\r
+                  tedlevelnum = atoi(_argv[i + 1]);\r
+                  if (tedlevelnum >= 0)\r
+                    tedlevel = true;\r
+                  break;\r
+\r
+                case 1:\r
+                  NoWait = true;\r
+                  break;\r
+               }\r
+       }\r
+\r
+       US_Started = true;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_Shutdown() - Shuts down the User Mgr\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_Shutdown(void)\r
+{\r
+       if (!US_Started)\r
+               return;\r
+\r
+       US_Started = false;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_CheckParm() - checks to see if a string matches one of a set of\r
+//             strings. The check is case insensitive. The routine returns the\r
+//             index of the string that matched, or -1 if no matches were found\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+int\r
+US_CheckParm(char *parm,char **strings)\r
+{\r
+       char    cp,cs,\r
+                       *p,*s;\r
+       int             i;\r
+\r
+       while (!isalpha(*parm)) // Skip non-alphas\r
+               parm++;\r
+\r
+       for (i = 0;*strings && **strings;i++)\r
+       {\r
+               for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)\r
+               {\r
+                       cs = *s++;\r
+                       if (!cs)\r
+                               return(i);\r
+                       cp = *p++;\r
+\r
+                       if (isupper(cs))\r
+                               cs = tolower(cs);\r
+                       if (isupper(cp))\r
+                               cp = tolower(cp);\r
+               }\r
+       }\r
+       return(-1);\r
+}\r
+\r
+\r
+//     Window/Printing routines\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_SetPrintRoutines() - Sets the routines used to measure and print\r
+//             from within the User Mgr. Primarily provided to allow switching\r
+//             between masked and non-masked fonts\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_SetPrintRoutines(void (*measure)(char far *,word *,word *),void (*print)(char far *))\r
+{\r
+       USL_MeasureString = measure;\r
+       USL_DrawString = print;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_Print() - Prints a string in the current window. Newlines are\r
+//             supported.\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_Print(char far *s)\r
+{\r
+       char    c,far *se;\r
+       word    w,h;\r
+\r
+       while (*s)\r
+       {\r
+               se = s;\r
+               while ((c = *se) && (c != '\n'))\r
+                       se++;\r
+               *se = '\0';\r
+\r
+               USL_MeasureString(s,&w,&h);\r
+               px = PrintX;\r
+               py = PrintY;\r
+               USL_DrawString(s);\r
+\r
+               s = se;\r
+               if (c)\r
+               {\r
+                       *se = c;\r
+                       s++;\r
+\r
+                       PrintX = WindowX;\r
+                       PrintY += h;\r
+               }\r
+               else\r
+                       PrintX += w;\r
+       }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_PrintUnsigned() - Prints an unsigned long\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_PrintUnsigned(word n)\r
+{\r
+       char    buffer[32];\r
+\r
+       US_Print(ultoa(n,buffer,10));\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_PrintSigned() - Prints a signed long\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_PrintSigned(long n)\r
+{\r
+       char    buffer[32];\r
+\r
+       US_Print(ltoa(n,buffer,10));\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     USL_PrintInCenter() - Prints a string in the center of the given rect\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+USL_PrintInCenter(char far *s,Rect r)\r
+{\r
+       word    w,h,\r
+                       rw,rh;\r
+\r
+       USL_MeasureString(s,&w,&h);\r
+       rw = r.lr.x - r.ul.x;\r
+       rh = r.lr.y - r.ul.y;\r
+\r
+       px = r.ul.x + ((rw - w) / 2);\r
+       py = r.ul.y + ((rh - h) / 2);\r
+       USL_DrawString(s);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_PrintCentered() - Prints a string centered in the current window.\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_PrintCentered(char far *s)\r
+{\r
+       Rect    r;\r
+\r
+       r.ul.x = WindowX;\r
+       r.ul.y = WindowY;\r
+       r.lr.x = r.ul.x + WindowW;\r
+       r.lr.y = r.ul.y + WindowH;\r
+\r
+       USL_PrintInCenter(s,r);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_CPrintLine() - Prints a string centered on the current line and\r
+//             advances to the next line. Newlines are not supported.\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_CPrintLine(char far *s)\r
+{\r
+       word    w,h;\r
+\r
+       USL_MeasureString(s,&w,&h);\r
+\r
+       if (w > WindowW)\r
+               Quit("US_CPrintLine() - String exceeds width");\r
+       px = WindowX + ((WindowW - w) / 2);\r
+       py = PrintY;\r
+       USL_DrawString(s);\r
+       PrintY += h;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_CPrint() - Prints a string in the current window. Newlines are\r
+//             supported.\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_CPrint(char far *s)\r
+{\r
+       char    c,far *se;\r
+\r
+       while (*s)\r
+       {\r
+               se = s;\r
+               while ((c = *se) && (c != '\n'))\r
+                       se++;\r
+               *se = '\0';\r
+\r
+               US_CPrintLine(s);\r
+\r
+               s = se;\r
+               if (c)\r
+               {\r
+                       *se = c;\r
+                       s++;\r
+               }\r
+       }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_ClearWindow() - Clears the current window to white and homes the\r
+//             cursor\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_ClearWindow(void)\r
+{\r
+       VWB_Bar(WindowX,WindowY,WindowW,WindowH,WHITE);\r
+       PrintX = WindowX;\r
+       PrintY = WindowY;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_DrawWindow() - Draws a frame and sets the current window parms\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_DrawWindow(word x,word y,word w,word h)\r
+{\r
+       word    i,\r
+                       sx,sy,sw,sh;\r
+\r
+       WindowX = x * 8;\r
+       WindowY = y * 8;\r
+       WindowW = w * 8;\r
+       WindowH = h * 8;\r
+\r
+       PrintX = WindowX;\r
+       PrintY = WindowY;\r
+\r
+       sx = (x - 1) * 8;\r
+       sy = (y - 1) * 8;\r
+       sw = (w + 1) * 8;\r
+       sh = (h + 1) * 8;\r
+\r
+       US_ClearWindow();\r
+\r
+       VWB_DrawTile8(sx,sy,0),VWB_DrawTile8(sx,sy + sh,5);\r
+       for (i = sx + 8;i <= sx + sw - 8;i += 8)\r
+               VWB_DrawTile8(i,sy,1),VWB_DrawTile8(i,sy + sh,6);\r
+       VWB_DrawTile8(i,sy,2),VWB_DrawTile8(i,sy + sh,7);\r
+\r
+       for (i = sy + 8;i <= sy + sh - 8;i += 8)\r
+               VWB_DrawTile8(sx,i,3),VWB_DrawTile8(sx + sw,i,4);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_CenterWindow() - Generates a window of a given width & height in the\r
+//             middle of the screen\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_CenterWindow(word w,word h)\r
+{\r
+       US_DrawWindow(((MaxX / 8) - w) / 2,((MaxY / 8) - h) / 2,w,h);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_SaveWindow() - Saves the current window parms into a record for\r
+//             later restoration\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_SaveWindow(WindowRec *win)\r
+{\r
+       win->x = WindowX;\r
+       win->y = WindowY;\r
+       win->w = WindowW;\r
+       win->h = WindowH;\r
+\r
+       win->px = PrintX;\r
+       win->py = PrintY;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_RestoreWindow() - Sets the current window parms to those held in the\r
+//             record\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+US_RestoreWindow(WindowRec *win)\r
+{\r
+       WindowX = win->x;\r
+       WindowY = win->y;\r
+       WindowW = win->w;\r
+       WindowH = win->h;\r
+\r
+       PrintX = win->px;\r
+       PrintY = win->py;\r
+}\r
+\r
+//     Input routines\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     USL_XORICursor() - XORs the I-bar text cursor. Used by US_LineInput()\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+static void\r
+USL_XORICursor(int x,int y,char *s,word cursor)\r
+{\r
+       static  boolean status;         // VGA doesn't XOR...\r
+       char    buf[MaxString];\r
+       int             temp;\r
+       word    w,h;\r
+\r
+       strcpy(buf,s);\r
+       buf[cursor] = '\0';\r
+       USL_MeasureString(buf,&w,&h);\r
+\r
+       px = x + w - 1;\r
+       py = y;\r
+       if (status^=1)\r
+               USL_DrawString("\x80");\r
+       else\r
+       {\r
+               temp = fontcolor;\r
+               fontcolor = backcolor;\r
+               USL_DrawString("\x80");\r
+               fontcolor = temp;\r
+       }\r
+\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     US_LineInput() - Gets a line of user input at (x,y), the string defaults\r
+//             to whatever is pointed at by def. Input is restricted to maxchars\r
+//             chars or maxwidth pixels wide. If the user hits escape (and escok is\r
+//             true), nothing is copied into buf, and false is returned. If the\r
+//             user hits return, the current string is copied into buf, and true is\r
+//             returned\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+boolean\r
+US_LineInput(int x,int y,char *buf,char *def,boolean escok,\r
+                               int maxchars,int maxwidth)\r
+{\r
+       boolean         redraw,\r
+                               cursorvis,cursormoved,\r
+                               done,result;\r
+       ScanCode        sc;\r
+       char            c,\r
+                               s[MaxString],olds[MaxString];\r
+       word            i,\r
+                               cursor,\r
+                               w,h,\r
+                               len,temp;\r
+       word    lasttime;\r
+       word TimeCount = *clockw;\r
+\r
+       if (def)\r
+               strcpy(s,def);\r
+       else\r
+               *s = '\0';\r
+       *olds = '\0';\r
+       cursor = strlen(s);\r
+       cursormoved = redraw = true;\r
+\r
+       cursorvis = done = false;\r
+       lasttime = TimeCount;\r
+       LastASCII = key_None;\r
+       LastScan = sc_None;\r
+\r
+       while (!done)\r
+       {\r
+               if (cursorvis)\r
+                       USL_XORICursor(x,y,s,cursor);\r
+\r
+       asm     pushf\r
+       asm     cli\r
+\r
+               sc = LastScan;\r
+               LastScan = sc_None;\r
+               c = LastASCII;\r
+               LastASCII = key_None;\r
+\r
+       asm     popf\r
+\r
+               switch (sc)\r
+               {\r
+               case sc_LeftArrow:\r
+                       if (cursor)\r
+                               cursor--;\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+               case sc_RightArrow:\r
+                       if (s[cursor])\r
+                               cursor++;\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+               case sc_Home:\r
+                       cursor = 0;\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+               case sc_End:\r
+                       cursor = strlen(s);\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+\r
+               case sc_Return:\r
+                       strcpy(buf,s);\r
+                       done = true;\r
+                       result = true;\r
+                       c = key_None;\r
+                       break;\r
+               case sc_Escape:\r
+                       if (escok)\r
+                       {\r
+                               done = true;\r
+                               result = false;\r
+                       }\r
+                       c = key_None;\r
+                       break;\r
+\r
+               case sc_BackSpace:\r
+                       if (cursor)\r
+                       {\r
+                               strcpy(s + cursor - 1,s + cursor);\r
+                               cursor--;\r
+                               redraw = true;\r
+                       }\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+               case sc_Delete:\r
+                       if (s[cursor])\r
+                       {\r
+                               strcpy(s + cursor,s + cursor + 1);\r
+                               redraw = true;\r
+                       }\r
+                       c = key_None;\r
+                       cursormoved = true;\r
+                       break;\r
+\r
+               case 0x4c:      // Keypad 5\r
+               case sc_UpArrow:\r
+               case sc_DownArrow:\r
+               case sc_PgUp:\r
+               case sc_PgDn:\r
+               case sc_Insert:\r
+                       c = key_None;\r
+                       break;\r
+               }\r
+\r
+               if (c)\r
+               {\r
+                       len = strlen(s);\r
+                       USL_MeasureString(s,&w,&h);\r
+\r
+                       if\r
+                       (\r
+                               isprint(c)\r
+                       &&      (len < MaxString - 1)\r
+                       &&      ((!maxchars) || (len < maxchars))\r
+                       &&      ((!maxwidth) || (w < maxwidth))\r
+                       )\r
+                       {\r
+                               for (i = len + 1;i > cursor;i--)\r
+                                       s[i] = s[i - 1];\r
+                               s[cursor++] = c;\r
+                               redraw = true;\r
+                       }\r
+               }\r
+\r
+               if (redraw)\r
+               {\r
+                       px = x;\r
+                       py = y;\r
+                       temp = fontcolor;\r
+                       fontcolor = backcolor;\r
+                       USL_DrawString(olds);\r
+                       fontcolor = temp;\r
+                       strcpy(olds,s);\r
+\r
+                       px = x;\r
+                       py = y;\r
+                       USL_DrawString(s);\r
+\r
+                       redraw = false;\r
+               }\r
+\r
+               if (cursormoved)\r
+               {\r
+                       cursorvis = false;\r
+                       lasttime = TimeCount - TickBase;\r
+\r
+                       cursormoved = false;\r
+               }\r
+               if (TimeCount - lasttime > TickBase / 2)\r
+               {\r
+                       lasttime = TimeCount;\r
+\r
+                       cursorvis ^= true;\r
+               }\r
+               if (cursorvis)\r
+                       USL_XORICursor(x,y,s,cursor);\r
+\r
+               //++++VW_UpdateScreen();\r
+       }\r
+\r
+       if (cursorvis)\r
+               USL_XORICursor(x,y,s,cursor);\r
+       if (!result)\r
+       {\r
+               px = x;\r
+               py = y;\r
+               USL_DrawString(olds);\r
+       }\r
+       //++++VW_UpdateScreen();\r
+\r
+       IN_ClearKeysDown();\r
+       return(result);\r
+}\r
+\r
+#if 0\r
+\r
+#define PaddleMinX      (CtlPanelSX + 3)\r
+#define PaddleMaxX      (CtlPanelEX - 15)\r
+#define BallMinX        (CtlPanelSX + 2)\r
+#define BallMinY        (CtlPanelSY + 12 + 2)\r
+#define BallMaxX        (CtlPanelEX - 6)\r
+#define BallMaxY        (CtlPanelEY - 13)\r
+#define CPaddleY        (BallMinY + 4)\r
+#define KPaddleY        (BallMaxY - 2)\r
+void\r
+USL_DrawPongScore(word k,word c)\r
+{\r
+       fontcolor = HiliteColor;\r
+       PrintY = py = CtlPanelSY + 4;\r
+       px = CtlPanelSX + 6;\r
+       VWB_Bar(px,py,42,6,BackColor);\r
+       USL_DrawString("YOU:");\r
+       PrintX = px;\r
+       US_PrintUnsigned(k);\r
+       px = CtlPanelSX + 108;\r
+       VWB_Bar(px,py,50,6,BackColor);\r
+       USL_DrawString("COMP:");\r
+       PrintX = px;\r
+       US_PrintUnsigned(c);\r
+}\r
+\r
+void\r
+USL_PlayPong(void)\r
+{\r
+       boolean         ball,killball,revdir,done,lastscore;\r
+       word            cycle,\r
+                               x,y,\r
+                               kx,cx,\r
+                               rx,\r
+                               bx,by,\r
+                               kscore,cscore,\r
+                               speedup;\r
+       int                     bdx,bdy;\r
+       word        balltime,waittime;\r
+       CursorInfo      cursorinfo;\r
+\r
+       kx = cx = PaddleMinX + ((PaddleMaxX - PaddleMinX) / 2);\r
+       bx = by = bdx = bdy = 0;\r
+       kscore = cscore = 0;\r
+       USL_DrawPongScore(0,0);\r
+       cycle = 0;\r
+       revdir = false;\r
+       killball = true;\r
+       done = false;\r
+       lastscore = false;\r
+       do\r
+       {\r
+               waittime = TimeCount;\r
+\r
+               IN_ReadCursor(&cursorinfo);\r
+               if (((cursorinfo.x < 0) || IN_KeyDown(sc_LeftArrow)) && (kx > PaddleMinX))\r
+                       kx -= 2;\r
+               else if (((cursorinfo.x > 0) || IN_KeyDown(sc_RightArrow)) && (kx < PaddleMaxX))\r
+                       kx += 2;\r
+\r
+               if (killball)\r
+               {\r
+                       ball = false;\r
+                       balltime = TimeCount + TickBase;\r
+                       speedup = 10;\r
+                       killball = false;\r
+               }\r
+\r
+               if (ball && (cycle++ % 3))\r
+               {\r
+                       x = (bx >> 2);\r
+                       if (!(x & 1))\r
+                               x += (US_RndT() & 1);\r
+\r
+                       if ((cx + 6 < x) && (cx < PaddleMaxX))\r
+                               cx += 1;\r
+                       else if ((cx + 6 > x) && (cx > PaddleMinX))\r
+                               cx -= 1;\r
+               }\r
+\r
+               VWB_Bar(BallMinX,BallMinY - 1,\r
+                               BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7,\r
+                               BackColor);\r
+               VWB_DrawSprite(cx,CPaddleY,PADDLESPR);\r
+               VWB_DrawSprite(kx,KPaddleY,PADDLESPR);\r
+               if (ball)\r
+               {\r
+                       if\r
+                       (\r
+                               (((bx + bdx) >> 2) > BallMaxX)\r
+                       ||      (((bx + bdx) >> 2) < BallMinX)\r
+                       )\r
+                       {\r
+                               SD_PlaySound(BALLBOUNCESND);\r
+                               bdx = -bdx;\r
+                       }\r
+                       bx += bdx;\r
+\r
+                       if (((by + bdy) >> 2) > BallMaxY)\r
+                       {\r
+                               killball = true;\r
+                               lastscore = false;\r
+                               cscore++;\r
+                               SD_PlaySound(COMPSCOREDSND);\r
+                               USL_DrawPongScore(kscore,cscore);\r
+                               if (cscore == 21)\r
+                               {\r
+                                       USL_CtlDialog("You lost!","Press any key",nil);\r
+                                       done = true;\r
+                                       continue;\r
+                               }\r
+                       }\r
+                       else if (((by + bdy) >> 2) < BallMinY)\r
+                       {\r
+                               killball = true;\r
+                               lastscore = true;\r
+                               kscore++;\r
+                               SD_PlaySound(KEENSCOREDSND);\r
+                               USL_DrawPongScore(kscore,cscore);\r
+                               if (kscore == 21)\r
+                               {\r
+                                       USL_CtlDialog("You won!","Press any key",nil);\r
+                                       done = true;\r
+                                       continue;\r
+                               }\r
+                       }\r
+                       by += bdy;\r
+\r
+                       x = bx >> 2;\r
+                       y = by >> 2;\r
+                       if (!killball)\r
+                       {\r
+                               if\r
+                               (\r
+                                       (bdy < 0)\r
+                               &&      ((y >= CPaddleY) && (y < CPaddleY + 3))\r
+                               &&      ((x >= (cx - 5)) && (x < (cx + 11)))\r
+                               )\r
+                               {\r
+                                       rx = cx;\r
+                                       revdir = true;\r
+                                       SD_PlaySound(COMPPADDLESND);\r
+                               }\r
+                               else if\r
+                               (\r
+                                       (bdy > 0)\r
+                               &&      ((y >= (KPaddleY - 3)) && (y < KPaddleY))\r
+                               &&      ((x >= (kx - 5)) && (x < (kx + 11)))\r
+                               )\r
+                               {\r
+                                       if (((bdy >> 2) < 3) && !(--speedup))\r
+                                       {\r
+                                               bdy++;\r
+                                               speedup = 10;\r
+                                       }\r
+                                       rx = kx;\r
+                                       revdir = true;\r
+                                       SD_PlaySound(KEENPADDLESND);\r
+                               }\r
+                               if (revdir)\r
+                               {\r
+                                       bdy = -bdy;\r
+                                       bdx = ((x + 5 - rx) >> 1) - (1 << 2);\r
+                                       if (!bdx)\r
+                                               bdx--;\r
+                                       revdir = false;\r
+                               }\r
+                       }\r
+                       VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR);\r
+               }\r
+               else if (TimeCount >= balltime)\r
+               {\r
+                       ball = true;\r
+                       bdx = 1 - (US_RndT() % 3);\r
+                       bdy = 2;\r
+                       if (lastscore)\r
+                               bdy = -bdy;\r
+                       bx = (BallMinX + ((BallMaxX - BallMinX) / 2)) << 2;\r
+                       by = (BallMinY + ((BallMaxY - BallMinY) / 2)) << 2;\r
+               }\r
+               //++++VW_UpdateScreen();\r
+               while (waittime == TimeCount)\r
+                       ;       // DEBUG - do adaptiveness\r
+       } while ((LastScan != sc_Escape) && !done);\r
+       IN_ClearKeysDown();\r
+}\r
+\r
+#pragma argsused\r
+static boolean\r
+USL_PongCustom(UserCall call,struct UserItem far *item)\r
+{\r
+       if (call != uic_SetupCard)\r
+               return(false);\r
+\r
+       VWB_DrawPic(0,0,CP_MENUSCREENPIC);\r
+       VWB_DrawPic(CtlPanelSX + 56,CtlPanelSY,CP_PADDLEWARPIC);\r
+       VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelSY + 12,HiliteColor ^ BackColor);\r
+       VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelEY - 7,HiliteColor ^ BackColor);\r
+       USL_PlayPong();\r
+\r
+       return(true);\r
+}\r
+\r
+#endif\r
diff --git a/src/lib/16_us.h_ b/src/lib/16_us.h_
new file mode 100755 (executable)
index 0000000..5091884
--- /dev/null
@@ -0,0 +1,126 @@
+//\r
+//     ID Engine\r
+//     ID_US.h - Header file for the User Manager\r
+//     v1.0d1w\r
+//     By Jason Blochowiak\r
+//     Open Watcom port by sparky4\r
+//\r
+\r
+#ifndef        __16_US__\r
+#define        __16_US__\r
+\r
+#include "src/lib/16_head.h"\r
+\r
+#ifdef __DEBUG__\r
+#define        __DEBUG_UserMgr__\r
+#endif\r
+\r
+//#define      HELPTEXTLINKED\r
+\r
+#define        MaxX    320\r
+#define        MaxY    200\r
+\r
+#define        MaxHelpLines    500\r
+\r
+#define        MaxHighName     57\r
+#define        MaxScores       7\r
+typedef        struct\r
+               {\r
+                       char    name[MaxHighName + 1];\r
+                       long    score;\r
+                       word    completed,episode;\r
+               } HighScore;\r
+\r
+#define        MaxGameName             32\r
+#define        MaxSaveGames    6\r
+typedef        struct\r
+               {\r
+                       char    signature[4];\r
+                       word    *oldtest;\r
+                       boolean present;\r
+                       char    name[MaxGameName + 1];\r
+               } SaveGame;\r
+\r
+#define        MaxString       128     // Maximum input string size\r
+\r
+typedef        struct\r
+               {\r
+                       int     x,y,\r
+                               w,h,\r
+                               px,py;\r
+               } WindowRec;    // Record used to save & restore screen windows\r
+\r
+typedef        enum\r
+               {\r
+                       gd_Continue,\r
+                       gd_Easy,\r
+                       gd_Normal,\r
+                       gd_Hard\r
+               } GameDiff;\r
+\r
+//     Hack import for TED launch support\r
+extern boolean         tedlevel;\r
+extern int                     tedlevelnum;\r
+extern void            TEDDeath(void);\r
+\r
+extern boolean         ingame,         // Set by game code if a game is in progress\r
+                                       abortgame,      // Set if a game load failed\r
+                                       loadedgame,     // Set if the current game was loaded\r
+                                       NoWait,\r
+                                       HighScoresDirty;\r
+extern char            *abortprogram;  // Set to error msg if program is dying\r
+extern GameDiff        restartgame;    // Normally gd_Continue, else starts game\r
+extern word            PrintX,PrintY;  // Current printing location in the window\r
+extern word            WindowX,WindowY,// Current location of window\r
+                                       WindowW,WindowH;// Current size of window\r
+\r
+extern boolean         Button0,Button1,\r
+                                       CursorBad;\r
+extern int                     CursorX,CursorY;\r
+\r
+extern void            (*USL_MeasureString)(char far *,word *,word *),\r
+                                       (*USL_DrawString)(char far *);\r
+\r
+extern boolean         (*USL_SaveGame)(int),(*USL_LoadGame)(int);\r
+extern void            (*USL_ResetGame)(void);\r
+extern SaveGame        Games[MaxSaveGames];\r
+extern HighScore       Scores[];\r
+\r
+#define        US_HomeWindow() {PrintX = WindowX; PrintY = WindowY;}\r
+\r
+extern void    US_Startup(void),\r
+                               US_Setup(void),\r
+                               US_Shutdown(void),\r
+                               US_InitRndT(boolean randomize),\r
+                               US_SetLoadSaveHooks(boolean (*load)(int),\r
+                                                                       boolean (*save)(int),\r
+                                                                       void (*reset)(void)),\r
+                               US_TextScreen(void),\r
+                               US_UpdateTextScreen(void),\r
+                               US_FinishTextScreen(void),\r
+                               US_DrawWindow(word x,word y,word w,word h),\r
+                               US_CenterWindow(word,word),\r
+                               US_SaveWindow(WindowRec *win),\r
+                               US_RestoreWindow(WindowRec *win),\r
+                               US_ClearWindow(void),\r
+                               US_SetPrintRoutines(void (*measure)(char far *,word *,word *),\r
+                                                                       void (*print)(char far *)),\r
+                               US_PrintCentered(char far *s),\r
+                               US_CPrint(char far *s),\r
+                               US_CPrintLine(char far *s),\r
+                               US_Print(char far *s),\r
+                               US_PrintUnsigned(word n),\r
+                               US_PrintSigned(long n),\r
+                               US_StartCursor(void),\r
+                               US_ShutCursor(void),\r
+                               US_CheckHighScore(long score,word other),\r
+                               US_DisplayHighScores(int which);\r
+extern boolean US_UpdateCursor(void),\r
+                               US_LineInput(int x,int y,char *buf,char *def,boolean escok,\r
+                                                               int maxchars,int maxwidth);\r
+extern int             US_CheckParm(char *parm,char **strings),\r
+                               US_RndT(void);\r
+\r
+               void    USL_PrintInCenter(char far *s,Rect r);\r
+               char    *USL_GiveSaveName(word game);\r
+#endif\r
diff --git a/src/palbomb.c b/src/palbomb.c
new file mode 100755 (executable)
index 0000000..80b9a9f
--- /dev/null
@@ -0,0 +1,42 @@
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+#include "src/lib/16_vl.h"\r
+void main(int argc, char *argv[]) {\r
+       static global_game_variables_t gvar; word i;\r
+\r
+\r
+       TL_VidInit(&gvar);      VGAmodeX(1, 0, &gvar);\r
+\r
+       gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);\r
+       VL_ShowPage(&gvar.video.page[0], 1, 0);\r
+       modexpdump(&gvar.video.page[0]);\r
+       while(!kbhit()){ VL_modexPalScramble(&gvar.video.palette); }\r
+       modexPalSave(&gvar.video.palette);\r
+       VGAmodeX(0, 0, &gvar);\r
+       for(i=0;i<16;i++)\r
+       {\r
+               printf("%02x", gvar.video.palette[i]);\r
+               if((!(i%16)) && i) printf("\n");\r
+               else printf(" ");\r
+       }\r
+       modexPalUpdate(&gvar.video.palette);\r
+}\r
index 2935ad2654ce64b7371bb7071dccd06f0205a465..f221d837f2be2f92ee2b422d9a1efaa0af55edb8 100755 (executable)
  * Fifth Floor, Boston, MA 02110-1301 USA.\r
  *\r
  */\r
-\r
 #include "src/lib/16_vl.h"\r
-\r
-void main(int argc, char *argv[])\r
-{\r
-       static global_game_variables_t gvar;\r
-       char bakapee[64] = "data\default.pal";\r
-\r
-       if(argv[1]) strcpy(bakapee, argv[1]);\r
-\r
-\r
-       VGAmodeX(1, 1, &gvar);\r
-\r
-       modexPalSave(&(gvar.video.palette));\r
-\r
-       modexSavePalFile(bakapee, &(gvar.video.palette));\r
-\r
-       VGAmodeX(0, 1, &gvar);\r
+void main(int argc, char *argv[]) {\r
+       static global_game_variables_t gvar;                    char bakapee[64] = "data/default.pal";\r
+       if(argv[1]) strcpy(bakapee, argv[1]); modexPalSave(&gvar.video.palette);// modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); modexPalBlack();\r
+\r
+       TL_VidInit(&gvar);      VGAmodeX(1, 0, &gvar);\r
+       modexSavePalFile(bakapee, &gvar.video.palette);\r
+       gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);// modexFadeOn(4, &gvar.video.palette);\r
+       VL_ShowPage(&gvar.video.page[0], 1, 0);\r
+       modexpdump(&gvar.video.page[0]);\r
+       while(!kbhit()){ /*VL_modexPalScramble(&gvar.video.palette);*/ }\r
+//     modexPalSave(&gvar.video.palette);\r
+       VGAmodeX(0, 0, &gvar);\r
 }\r
index 9249e540d96f7efbe501ea33bb267f31720a8b2b..6b6840a707a8d92e1d3142d11b25b35ad80419e0 100755 (executable)
  * Fifth Floor, Boston, MA 02110-1301 USA.\r
  *\r
  */\r
-\r
 #include "src/lib/16_vl.h"\r
-#include "src/lib/bakapee.h"\r
-\r
-word i;\r
-\r
-void main(int argc, char *argv[])\r
-{\r
-       static global_game_variables_t gvar;\r
-       char bakapee[64] = "data\default.pal";\r
-\r
-       if(argv[1]) strcpy(bakapee, argv[1]);\r
-\r
-\r
-       modexPalSave(&(gvar.video.palette));\r
-       VL_modexPalScramble(&(gvar.video.palette));\r
-       VGAmodeX(1, 1, &gvar);\r
-       gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);\r
-       modexPalBlack();\r
+void main(int argc, char *argv[]) {\r
+       static global_game_variables_t gvar; word i;    char bakapee[64] = "data/16.pal";\r
+       if(argv[1]) strcpy(bakapee, argv[1]);// modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); modexPalBlack();\r
 \r
-       modexLoadPalFile(bakapee, &(gvar.video.palette));\r
-       modexPalUpdate(&(gvar.video.palette));\r
-       modexFadeOn(1, &(gvar.video.palette));\r
+       TL_VidInit(&gvar);      VGAmodeX(1, 0, &gvar);\r
+       VL_LoadPalFile(bakapee, &gvar.video.palette);           //modexLoadPalFile(bakapee, &(gvar.video.palette));\r
+       gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);// modexFadeOn(4, &gvar.video.palette);\r
+       VL_ShowPage(&gvar.video.page[0], 1, 0);\r
        modexpdump(&gvar.video.page[0]);\r
-//     getch();\r
+       while(!kbhit()){ /*VL_modexPalScramble(&gvar.video.palette);*/ }\r
+       modexPalSave(&gvar.video.palette);\r
        VGAmodeX(0, 0, &gvar);\r
-       modexPalUpdate(&(gvar.video.palette));\r
-       /*for(i=0;i<768;i++)\r
+       for(i=0;i<16;i++)\r
        {\r
-               printf("%02X ", pal[i]);\r
-       }*/\r
+               printf("%02x", gvar.video.palette[i]);\r
+               if((!(i%16)) && i) printf("\n");\r
+               else printf(" ");\r
+       }\r
+       modexPalUpdate(&gvar.video.palette);\r
 }\r