From 60484e959995accd95933e7f119fafe3a42897c5 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Wed, 5 Apr 2017 14:23:12 -0500 Subject: [PATCH] p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] MM_ShowMemory is buggy on real machines. i need to debug it and fix added a struct printer[i need to get a reliable palette manager and checkers in the video system\!] --- data/16.pal | Bin 768 -> 768 bytes data/default.pal | Bin 768 -> 768 bytes data/vga.pal | Bin 0 -> 768 bytes makefile | 9 +- src/lib/16_head.c | 2 +- src/lib/16_tail.c | 1 + src/lib/16_tdef.h | 4 +- src/lib/16_us.c | 165 +++++--- src/lib/16_us.c_ | 969 ++++++++++++++++++++++++++++++++++++++++++++++ src/lib/16_us.h_ | 126 ++++++ src/palbomb.c | 42 ++ src/palettec.c | 29 +- src/palettel.c | 41 +- 13 files changed, 1283 insertions(+), 105 deletions(-) create mode 100755 data/vga.pal create mode 100755 src/lib/16_us.c_ create mode 100755 src/lib/16_us.h_ create mode 100755 src/palbomb.c diff --git a/data/16.pal b/data/16.pal index eaf5208550ce2b2d7a255488e2de6b8d22afb6c8..f05da004cad15f399871fc26601235b9c128263a 100755 GIT binary patch literal 768 ccmZQ%Wc<$n1ph%0gg^v{H3~*UU<8B!06Du0_y7O^ literal 768 ccmZQzVEE4f1ph%0gg^v{H3~*UU<8B!05HA_^#A|> diff --git a/data/default.pal b/data/default.pal index e98ae60e3d21a9409f12ef6b1f2ad3625750e734..db7cd033a49a21d9c111a6e74e65735939169672 100755 GIT binary patch literal 768 zcmV~$hk`>e002<2N6^@#R@I?MP+MF7|5x{(78!^tRSrNRbsML$-}#)oXd@r!mquQc zZ%L1Iqfe@izbc)WzdQ#YJi(C_9%6UPB1`Y`8NOH6JV4yz+fcXT>j#}I8y~`KT8bnF zIWDqy0WBpYw*{Y4YnH%OTq!YwjlA zC((9yt!|7ZT2V7;T0p68VUPRs>s>c9qRzL@`_#)rHfZmU`spgAEMI}Tc;%k0^_E7C zT+4)W9HMQv!OVh0>p`*y(Fc7yOD%{H26T{+4{4xMd={u5dFNn?X~FNcZfSZ9e9GJx z$~}l2c{oso@5g!kXyZDo*U;1w%S80T_|$xILzJBZwu(*1Cdmwk;X25w%0aKhd zwyNxcNv)>rLP_G2PD>qN8|htXC)gr|^F6&t{%8Uu%qliYor?{ElLU*6U4Up$W4Av* zeAA9yTyY~%?GD|t$rL6TM|hg!yiDm~)c2yj4mA{ESl`i4plm7@g7h%6ZdSIk2nCxX zUh(W+;%%N}%HK!kev8_+50B)_%f$IRmry9G%iaz2SsV$V+)lGKdumoKZOjk-LBE>& zeE+r-q)GCZICL^L8W0~wA?U6aS1sLLxP5>8_jxxwzUhsX)@lHdg_OfQ*akk8y_~nX hI;}&G!(|Z1-A2`=wd5O`F1{u$$UMJ!dWf*U_#bUsS}Onm literal 768 zcmZva!3shl5JhKEB>9@=fri8dTLeWQk6P5D&HVpg<+M_8JdASB=t`nmkGkmbuvWKd z$7rQ>MOAD6tsd+2cDr@XdGDEdp63ukN(sQ_a=Biw_xrt+@_N12b^Xt)kY>__>gCF! zl$E4D)QTn@i=6eAb;Vn2qWPx1XwtDLMW03AMZZPW_-c7;d1^13bS#LlBQPNn zU_=mucIZWujs-JjMr0%gj0BG08NF!Iu?PXDfD~{JfN@4h2q*NSNymanHYAQ@A`xQ} zazY#FMU#$&bFz0bIbkPau((OwUV71_W8u9_UJhQ4Uc@+xKZu{C7fm`A_RUB218>tx AO#lD@ diff --git a/data/vga.pal b/data/vga.pal new file mode 100755 index 0000000000000000000000000000000000000000..0ecbac33f44529d9701eae8c9b262c7da0f50416 GIT binary patch literal 768 QcmZQz7zLvtFmgix00RI30RR91 literal 0 HcmV?d00001 diff --git a/makefile b/makefile index cb9839b1..58c4aa71 100755 --- 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 diff --git a/src/lib/16_head.c b/src/lib/16_head.c index 5764183b..f0175d43 100755 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -182,7 +182,7 @@ void print_mem(void const *vp, size_t n) { printf("%02x", p[i]); //printf("%c", p[i]); - if(!((i)%16)) printf("\n"); + if((!(i%16)) && i) printf("\n"); else printf(" "); //printf("%u%%40=%u\n", i, i%40); } diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index c0d6d89f..2e045c58 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -134,6 +134,7 @@ void TL_VidInit(global_game_variables_t *gvar) #else gvar->video.old_mode = 3; #endif + gvar->video.VL_Initiated = 1; } diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index fac2ba26..c5775387 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -385,10 +385,9 @@ typedef struct typedef struct { - boolean VL_Started; + boolean VL_Started,VL_Initiated; char old_mode; //old video mode before game! byte palette[PALSIZE], dpal[PALSIZE]; //palette array - byte far palette1[256][3],far palette2[256][3]; page_t page[MAXPAGE]; //can be used as a pointer to root page[0] word vmem_remain; //remaining video memory byte num_of_pages; //number of actual pages @@ -408,6 +407,7 @@ typedef struct boolean screenfaded; word bordercolor; boolean fastpalette; + byte far palette1[256][3],far palette2[256][3]; } video_t; //from scroll16 diff --git a/src/lib/16_us.c b/src/lib/16_us.c index ec2b3b28..ffd4d8ad 100755 --- a/src/lib/16_us.c +++ b/src/lib/16_us.c @@ -1,57 +1,70 @@ -/*#include "src/lib/16_in.h" +#include "src/lib/16_us.h" + +word px,py; +word PrintX,PrintY; +word WindowX,WindowY,WindowW,WindowH; + static word far* clockw= (word far*) 0x046C; // 18.2hz clock -#define CtlPanelSX 1 -#define CtlPanelSY 1 -#define CtlPanelEX 1 -#define CtlPanelEY 1 -#define TickBase 1 - -#define PaddleMinX (CtlPanelSX + 3) -#define PaddleMaxX (CtlPanelEX - 15) -#define BallMinX (CtlPanelSX + 2) -#define BallMinY (CtlPanelSY + 12 + 2) -#define BallMaxX (CtlPanelEX - 6) -#define BallMaxY (CtlPanelEY - 13) -#define CPaddleY (BallMinY + 4) -#define KPaddleY (BallMaxY - 2) +// Control panel data + +#define CtlPanelSX 74 +#define CtlPanelSY 48 +#define CtlPanelEX 234 +#define CtlPanelEY 150 +#define CtlPanelW (CtlPanelEX - CtlPanelSX) +#define CtlPanelH (CtlPanelEY - CtlPanelSY) + +#define TickBase 70 // 70Hz per tick - used as a base for timer 0 + +#define PaddleMinX (CtlPanelSX + 3) +#define PaddleMaxX (CtlPanelEX - 15) +#define BallMinX (CtlPanelSX + 2) +#define BallMinY (CtlPanelSY + 12 + 2) +#define BallMaxX (CtlPanelEX - 6) +#define BallMaxY (CtlPanelEY - 13) +#define CPaddleY (BallMinY + 4) +#define KPaddleY (BallMaxY - 2) void -USL_DrawPongScore(word k,word c) +USL_DrawPongScore(word k,word c, global_game_variables_t *gvar) { //++++fontcolor = HiliteColor; - //++++PrintY = py = CtlPanelSY + 4; - //++++px = CtlPanelSX + 6; - //++++VWB_Bar(px,py,42,6,BackColor); + PrintY = py = CtlPanelSY + 4; + px = CtlPanelSX + 6; + VLB_Bar(px,py,42,6,3/*BackColor*/, &gvar->video.ofs); //++++USL_DrawString("YOU:"); - //++++PrintX = px; +// modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str) + modexprint(gvar->video.page, px, py, 1, 0, 4, 8, 1, "YOU:"); + PrintX = px; //++++US_PrintUnsigned(k); - //++++px = CtlPanelSX + 108; - //++++VWB_Bar(px,py,50,6,BackColor); + px = CtlPanelSX + 108; + VLB_Bar(px,py,50,6,3/*BackColor*/, &gvar->video.ofs); //++++USL_DrawString("COMP:"); - //++++PrintX = px; + modexprint(gvar->video.page, px, py, 1, 0, 4, 8, 1, "COMP:"); + PrintX = px; //++++US_PrintUnsigned(c); } void -USL_PlayPong(void) +USL_PlayPong(global_game_variables_t *gvar) { - boolean ball,killball,revdir,done,lastscore; - word cycle, + boolean ball,killball,revdir,done,lastscore; + word cycle, x,y, kx,cx, rx, bx,by, kscore,cscore, speedup; - int bdx,bdy; - word balltime,waittime; - CursorInfo cursorinfo; + int bdx,bdy; + word balltime,waittime; + CursorInfo cursorinfo; word TimeCount = *clockw; kx = cx = PaddleMinX + ((PaddleMaxX - PaddleMinX) / 2); bx = by = bdx = bdy = 0; kscore = cscore = 0; - USL_DrawPongScore(0,0); + USL_DrawPongScore(0,0, gvar); cycle = 0; revdir = false; killball = true; @@ -61,7 +74,7 @@ USL_PlayPong(void) { waittime = TimeCount; - IN_ReadCursor(&cursorinfo); + IN_ReadCursor(&cursorinfo, gvar); if (((cursorinfo.x < 0) || IN_KeyDown(sc_LeftArrow)) && (kx > PaddleMinX)) kx -= 2; else if (((cursorinfo.x > 0) || IN_KeyDown(sc_RightArrow)) && (kx < PaddleMaxX)) @@ -87,20 +100,28 @@ USL_PlayPong(void) cx -= 1; } - //++++VWB_Bar(BallMinX,BallMinY - 1, - // BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7, - // BackColor); - //++++VWB_DrawSprite(cx,CPaddleY,PADDLESPR); - //++++VWB_DrawSprite(kx,KPaddleY,PADDLESPR); +//++++ +//#if 1 + VLB_Bar(BallMinX,BallMinY - 1, + BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7, + 3/*BackColor*/, &gvar->video.ofs); +#if 0 + VWB_DrawSprite(cx,CPaddleY,PADDLESPR); + VWB_DrawSprite(kx,KPaddleY,PADDLESPR); + + modexputPixel(gvar->video.page, BallMinX, BallMinY, 3); +#endif + modexputPixel(gvar->video.page, cx, CPaddleY, 3); + modexputPixel(gvar->video.page, kx, KPaddleY, 3); if (ball) { if ( (((bx + bdx) >> 2) > BallMaxX) - || (((bx + bdx) >> 2) < BallMinX) + || (((bx + bdx) >> 2) < BallMinX) ) { - //++++SD__PlaySound(BALLBOUNCESND); +//++++ SD__PlaySound(BALLBOUNCESND); bdx = -bdx; } bx += bdx; @@ -110,11 +131,11 @@ USL_PlayPong(void) killball = true; lastscore = false; cscore++; - //++++SD__PlaySound(COMPSCOREDSND); - USL_DrawPongScore(kscore,cscore); +//++++ SD__PlaySound(COMPSCOREDSND); + USL_DrawPongScore(kscore,cscore, gvar); if (cscore == 21) { - USL_CtlDialog("You lost!","Press any key",nil); +//++++ USL_CtlDialog("You lost!","Press any key",nil); done = true; continue; } @@ -124,11 +145,11 @@ USL_PlayPong(void) killball = true; lastscore = true; kscore++; - //++++SD__PlaySound(KEENSCOREDSND); - USL_DrawPongScore(kscore,cscore); +//++++ SD__PlaySound(KEENSCOREDSND); + USL_DrawPongScore(kscore,cscore, gvar); if (kscore == 21) { - USL_CtlDialog("You won!","Press any key",nil); +//++++ USL_CtlDialog("You won!","Press any key",nil); done = true; continue; } @@ -142,19 +163,19 @@ USL_PlayPong(void) if ( (bdy < 0) - && ((y >= CPaddleY) && (y < CPaddleY + 3)) - && ((x >= (cx - 5)) && (x < (cx + 11))) + && ((y >= CPaddleY) && (y < CPaddleY + 3)) + && ((x >= (cx - 5)) && (x < (cx + 11))) ) { rx = cx; revdir = true; - //++++SD__PlaySound(COMPPADDLESND); +//++++ SD__PlaySound(COMPPADDLESND); } else if ( (bdy > 0) - && ((y >= (KPaddleY - 3)) && (y < KPaddleY)) - && ((x >= (kx - 5)) && (x < (kx + 11))) + && ((y >= (KPaddleY - 3)) && (y < KPaddleY)) + && ((x >= (kx - 5)) && (x < (kx + 11))) ) { if (((bdy >> 2) < 3) && !(--speedup)) @@ -164,7 +185,7 @@ USL_PlayPong(void) } rx = kx; revdir = true; - //++++SD__PlaySound(KEENPADDLESND); +//++++ SD__PlaySound(KEENPADDLESND); } if (revdir) { @@ -175,7 +196,7 @@ USL_PlayPong(void) revdir = false; } } - //++++VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR); +//++++ VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR); } else if (TimeCount >= balltime) { @@ -187,13 +208,13 @@ USL_PlayPong(void) bx = (BallMinX + ((BallMaxX - BallMinX) / 2)) << 2; by = (BallMinY + ((BallMaxY - BallMinY) / 2)) << 2; } - //++++VW_UpdateScreen(); - while (waittime == TimeCount) - ; // DEBUG - do adaptiveness - } while ((inpu.LastScan != sc_Escape) && !done); +//++++ VW_UpdateScreen(); + while (waittime == TimeCount){} + //; // DEBUG - do adaptiveness + } while ((gvar->in.inst->LastScan != sc_Escape) && !done); IN_ClearKeysDown(); } - +/* #pragma argsused static boolean USL_PongCustom(UserCall call,struct UserItem far *item) @@ -210,3 +231,35 @@ USL_PongCustom(UserCall call,struct UserItem far *item) return(true); } */ +/////////////////////////////////////////////////////////////////////////// +// +// US_RndT - Returns the next 8-bit pseudo random number +// +/////////////////////////////////////////////////////////////////////////// +int US_RndT() +{ + int rndindex = 0; + + byte rndtable[] = { + 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, + 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36, + 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188, + 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224, + 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242, + 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0, + 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235, + 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113, + 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75, + 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196, + 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113, + 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241, + 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224, + 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, + 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226, + 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, + 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, + 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136, + 120, 163, 236, 249 }; + rndindex = (rndindex+1)&0xff; + return rndtable[rndindex]; +} diff --git a/src/lib/16_us.c_ b/src/lib/16_us.c_ new file mode 100755 index 00000000..47034db1 --- /dev/null +++ b/src/lib/16_us.c_ @@ -0,0 +1,969 @@ +// +// ID Engine +// ID_US_1.c - User Manager - General routines +// v1.1d1w +// By Jason Blochowiak +// Hacked up for Catacomb 3D +// Open Watcom port by sparky4 +// + +// +// This module handles dealing with user input & feedback +// +// Depends on: Input Mgr, View Mgr, some variables from the Sound, Caching, +// and Refresh Mgrs, Memory Mgr for background save/restore +// +// Globals: +// ingame - Flag set by game indicating if a game is in progress +// abortgame - Flag set if the current game should be aborted (if a load +// game fails) +// loadedgame - Flag set if a game was loaded +// abortprogram - Normally nil, this points to a terminal error message +// if the program needs to abort +// restartgame - Normally set to gd_Continue, this is set to one of the +// difficulty levels if a new game should be started +// PrintX, PrintY - Where the User Mgr will print (global coords) +// WindowX,WindowY,WindowW,WindowH - The dimensions of the current +// window +// + +#include "src/lib/16_us.h" + +#pragma hdrstop + +#pragma warn -pia + +static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ + +//undeced vars +boolean compatability; word px,py; + +// Global variables + char *abortprogram; + boolean NoWait; + word PrintX,PrintY; + word WindowX,WindowY,WindowW,WindowH; + +// Internal variables +#define ConfigVersion 1 + +static char *ParmStrings[] = {"TEDLEVEL","NOWAIT"}, + *ParmStrings2[] = {"COMP","NOCOMP"}; +static boolean US_Started; + + boolean Button0,Button1, + CursorBad; + int CursorX,CursorY; + + void (*USL_MeasureString)(char far *,word *,word *) = VW_MeasurePropString, + (*USL_DrawString)(char far *) = VWB_DrawPropString; + + SaveGame Games[MaxSaveGames]; + HighScore Scores[MaxScores] = + { + {"id software-'92",10000,1}, + {"Adrian Carmack",10000,1}, + {"John Carmack",10000,1}, + {"Kevin Cloud",10000,1}, + {"Tom Hall",10000,1}, + {"John Romero",10000,1}, + {"Jay Wilbur",10000,1}, + }; + +// Internal routines + +// Public routines + +/////////////////////////////////////////////////////////////////////////// +// +// USL_HardError() - Handles the Abort/Retry/Fail sort of errors passed +// from DOS. +// +/////////////////////////////////////////////////////////////////////////// +#pragma warn -par +#pragma warn -rch +int +USL_HardError(word errval,int ax,int bp,int si) +{ +#define IGNORE 0 +#define RETRY 1 +#define ABORT 2 +extern void ShutdownId(void); + +static char buf[32]; +static WindowRec wr; + int dival=0; + char c,*s,*t; + + __asm { + mov [dival],di + } + //dival = _DI; + + if (ax < 0) + s = "Device Error"; + else + { + if ((dival & 0x00ff) == 0) + s = "Drive ~ is Write Protected"; + else + s = "Error on Drive ~"; + for (t = buf;*s;s++,t++) // Can't use sprintf() + if ((*t = *s) == '~') + *t = (ax & 0x00ff) + 'A'; + *t = '\0'; + s = buf; + } + + c = peekb(0x40,0x49); // Get the current screen mode + if ((c < 4) || (c == 7)) + goto oh_kill_me; + + // DEBUG - handle screen cleanup + + US_SaveWindow(&wr); + US_CenterWindow(30,3); + US_CPrint(s); + US_CPrint("(R)etry or (A)bort?"); + //++++VW_UpdateScreen(); + IN_ClearKeysDown(); + +__asm sti // Let the keyboard interrupts come through + + while (true) + { + switch (IN_WaitForASCII()) + { + case key_Escape: + case 'a': + case 'A': + goto oh_kill_me; + break; + case key_Return: + case key_Space: + case 'r': + case 'R': + US_ClearWindow(); + //++++VW_UpdateScreen(); + US_RestoreWindow(&wr); + return(RETRY); + break; + } + } + +oh_kill_me: + abortprogram = s; + ShutdownId(); + fprintf(stderr,"Terminal Error: %s\n",s); + if (tedlevel) + fprintf(stderr,"You launched from TED. I suggest that you reboot...\n"); + + return(ABORT); +#undef IGNORE +#undef RETRY +#undef ABORT +} +#pragma warn +par +#pragma warn +rch + + +/////////////////////////////////////////////////////////////////////////// +// +// US_Startup() - Starts the User Mgr +// +/////////////////////////////////////////////////////////////////////////// +void +US_Startup(void) +{ + int i,n; + + if (US_Started) + return; + + //++++_harderr(USL_HardError); // Install the fatal error handler + + US_InitRndT(true); // Initialize the random number generator + + for (i = 1;i < _argc;i++) + { + switch (US_CheckParm(_argv[i],ParmStrings2)) + { + case 0: + compatability = true; + break; + case 1: + compatability = false; + break; + } + } + + // Check for TED launching here + for (i = 1;i < _argc;i++) + { + n = US_CheckParm(_argv[i],ParmStrings); + switch(n) + { + case 0: + tedlevelnum = atoi(_argv[i + 1]); + if (tedlevelnum >= 0) + tedlevel = true; + break; + + case 1: + NoWait = true; + break; + } + } + + US_Started = true; +} + + +/////////////////////////////////////////////////////////////////////////// +// +// US_Shutdown() - Shuts down the User Mgr +// +/////////////////////////////////////////////////////////////////////////// +void +US_Shutdown(void) +{ + if (!US_Started) + return; + + US_Started = false; +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_CheckParm() - checks to see if a string matches one of a set of +// strings. The check is case insensitive. The routine returns the +// index of the string that matched, or -1 if no matches were found +// +/////////////////////////////////////////////////////////////////////////// +int +US_CheckParm(char *parm,char **strings) +{ + char cp,cs, + *p,*s; + int i; + + while (!isalpha(*parm)) // Skip non-alphas + parm++; + + for (i = 0;*strings && **strings;i++) + { + for (s = *strings++,p = parm,cs = cp = 0;cs == cp;) + { + cs = *s++; + if (!cs) + return(i); + cp = *p++; + + if (isupper(cs)) + cs = tolower(cs); + if (isupper(cp)) + cp = tolower(cp); + } + } + return(-1); +} + + +// Window/Printing routines + +/////////////////////////////////////////////////////////////////////////// +// +// US_SetPrintRoutines() - Sets the routines used to measure and print +// from within the User Mgr. Primarily provided to allow switching +// between masked and non-masked fonts +// +/////////////////////////////////////////////////////////////////////////// +void +US_SetPrintRoutines(void (*measure)(char far *,word *,word *),void (*print)(char far *)) +{ + USL_MeasureString = measure; + USL_DrawString = print; +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_Print() - Prints a string in the current window. Newlines are +// supported. +// +/////////////////////////////////////////////////////////////////////////// +void +US_Print(char far *s) +{ + char c,far *se; + word w,h; + + while (*s) + { + se = s; + while ((c = *se) && (c != '\n')) + se++; + *se = '\0'; + + USL_MeasureString(s,&w,&h); + px = PrintX; + py = PrintY; + USL_DrawString(s); + + s = se; + if (c) + { + *se = c; + s++; + + PrintX = WindowX; + PrintY += h; + } + else + PrintX += w; + } +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_PrintUnsigned() - Prints an unsigned long +// +/////////////////////////////////////////////////////////////////////////// +void +US_PrintUnsigned(word n) +{ + char buffer[32]; + + US_Print(ultoa(n,buffer,10)); +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_PrintSigned() - Prints a signed long +// +/////////////////////////////////////////////////////////////////////////// +void +US_PrintSigned(long n) +{ + char buffer[32]; + + US_Print(ltoa(n,buffer,10)); +} + +/////////////////////////////////////////////////////////////////////////// +// +// USL_PrintInCenter() - Prints a string in the center of the given rect +// +/////////////////////////////////////////////////////////////////////////// +void +USL_PrintInCenter(char far *s,Rect r) +{ + word w,h, + rw,rh; + + USL_MeasureString(s,&w,&h); + rw = r.lr.x - r.ul.x; + rh = r.lr.y - r.ul.y; + + px = r.ul.x + ((rw - w) / 2); + py = r.ul.y + ((rh - h) / 2); + USL_DrawString(s); +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_PrintCentered() - Prints a string centered in the current window. +// +/////////////////////////////////////////////////////////////////////////// +void +US_PrintCentered(char far *s) +{ + Rect r; + + r.ul.x = WindowX; + r.ul.y = WindowY; + r.lr.x = r.ul.x + WindowW; + r.lr.y = r.ul.y + WindowH; + + USL_PrintInCenter(s,r); +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_CPrintLine() - Prints a string centered on the current line and +// advances to the next line. Newlines are not supported. +// +/////////////////////////////////////////////////////////////////////////// +void +US_CPrintLine(char far *s) +{ + word w,h; + + USL_MeasureString(s,&w,&h); + + if (w > WindowW) + Quit("US_CPrintLine() - String exceeds width"); + px = WindowX + ((WindowW - w) / 2); + py = PrintY; + USL_DrawString(s); + PrintY += h; +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_CPrint() - Prints a string in the current window. Newlines are +// supported. +// +/////////////////////////////////////////////////////////////////////////// +void +US_CPrint(char far *s) +{ + char c,far *se; + + while (*s) + { + se = s; + while ((c = *se) && (c != '\n')) + se++; + *se = '\0'; + + US_CPrintLine(s); + + s = se; + if (c) + { + *se = c; + s++; + } + } +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_ClearWindow() - Clears the current window to white and homes the +// cursor +// +/////////////////////////////////////////////////////////////////////////// +void +US_ClearWindow(void) +{ + VWB_Bar(WindowX,WindowY,WindowW,WindowH,WHITE); + PrintX = WindowX; + PrintY = WindowY; +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_DrawWindow() - Draws a frame and sets the current window parms +// +/////////////////////////////////////////////////////////////////////////// +void +US_DrawWindow(word x,word y,word w,word h) +{ + word i, + sx,sy,sw,sh; + + WindowX = x * 8; + WindowY = y * 8; + WindowW = w * 8; + WindowH = h * 8; + + PrintX = WindowX; + PrintY = WindowY; + + sx = (x - 1) * 8; + sy = (y - 1) * 8; + sw = (w + 1) * 8; + sh = (h + 1) * 8; + + US_ClearWindow(); + + VWB_DrawTile8(sx,sy,0),VWB_DrawTile8(sx,sy + sh,5); + for (i = sx + 8;i <= sx + sw - 8;i += 8) + VWB_DrawTile8(i,sy,1),VWB_DrawTile8(i,sy + sh,6); + VWB_DrawTile8(i,sy,2),VWB_DrawTile8(i,sy + sh,7); + + for (i = sy + 8;i <= sy + sh - 8;i += 8) + VWB_DrawTile8(sx,i,3),VWB_DrawTile8(sx + sw,i,4); +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_CenterWindow() - Generates a window of a given width & height in the +// middle of the screen +// +/////////////////////////////////////////////////////////////////////////// +void +US_CenterWindow(word w,word h) +{ + US_DrawWindow(((MaxX / 8) - w) / 2,((MaxY / 8) - h) / 2,w,h); +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_SaveWindow() - Saves the current window parms into a record for +// later restoration +// +/////////////////////////////////////////////////////////////////////////// +void +US_SaveWindow(WindowRec *win) +{ + win->x = WindowX; + win->y = WindowY; + win->w = WindowW; + win->h = WindowH; + + win->px = PrintX; + win->py = PrintY; +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_RestoreWindow() - Sets the current window parms to those held in the +// record +// +/////////////////////////////////////////////////////////////////////////// +void +US_RestoreWindow(WindowRec *win) +{ + WindowX = win->x; + WindowY = win->y; + WindowW = win->w; + WindowH = win->h; + + PrintX = win->px; + PrintY = win->py; +} + +// Input routines + +/////////////////////////////////////////////////////////////////////////// +// +// USL_XORICursor() - XORs the I-bar text cursor. Used by US_LineInput() +// +/////////////////////////////////////////////////////////////////////////// +static void +USL_XORICursor(int x,int y,char *s,word cursor) +{ + static boolean status; // VGA doesn't XOR... + char buf[MaxString]; + int temp; + word w,h; + + strcpy(buf,s); + buf[cursor] = '\0'; + USL_MeasureString(buf,&w,&h); + + px = x + w - 1; + py = y; + if (status^=1) + USL_DrawString("\x80"); + else + { + temp = fontcolor; + fontcolor = backcolor; + USL_DrawString("\x80"); + fontcolor = temp; + } + +} + +/////////////////////////////////////////////////////////////////////////// +// +// US_LineInput() - Gets a line of user input at (x,y), the string defaults +// to whatever is pointed at by def. Input is restricted to maxchars +// chars or maxwidth pixels wide. If the user hits escape (and escok is +// true), nothing is copied into buf, and false is returned. If the +// user hits return, the current string is copied into buf, and true is +// returned +// +/////////////////////////////////////////////////////////////////////////// +boolean +US_LineInput(int x,int y,char *buf,char *def,boolean escok, + int maxchars,int maxwidth) +{ + boolean redraw, + cursorvis,cursormoved, + done,result; + ScanCode sc; + char c, + s[MaxString],olds[MaxString]; + word i, + cursor, + w,h, + len,temp; + word lasttime; + word TimeCount = *clockw; + + if (def) + strcpy(s,def); + else + *s = '\0'; + *olds = '\0'; + cursor = strlen(s); + cursormoved = redraw = true; + + cursorvis = done = false; + lasttime = TimeCount; + LastASCII = key_None; + LastScan = sc_None; + + while (!done) + { + if (cursorvis) + USL_XORICursor(x,y,s,cursor); + + asm pushf + asm cli + + sc = LastScan; + LastScan = sc_None; + c = LastASCII; + LastASCII = key_None; + + asm popf + + switch (sc) + { + case sc_LeftArrow: + if (cursor) + cursor--; + c = key_None; + cursormoved = true; + break; + case sc_RightArrow: + if (s[cursor]) + cursor++; + c = key_None; + cursormoved = true; + break; + case sc_Home: + cursor = 0; + c = key_None; + cursormoved = true; + break; + case sc_End: + cursor = strlen(s); + c = key_None; + cursormoved = true; + break; + + case sc_Return: + strcpy(buf,s); + done = true; + result = true; + c = key_None; + break; + case sc_Escape: + if (escok) + { + done = true; + result = false; + } + c = key_None; + break; + + case sc_BackSpace: + if (cursor) + { + strcpy(s + cursor - 1,s + cursor); + cursor--; + redraw = true; + } + c = key_None; + cursormoved = true; + break; + case sc_Delete: + if (s[cursor]) + { + strcpy(s + cursor,s + cursor + 1); + redraw = true; + } + c = key_None; + cursormoved = true; + break; + + case 0x4c: // Keypad 5 + case sc_UpArrow: + case sc_DownArrow: + case sc_PgUp: + case sc_PgDn: + case sc_Insert: + c = key_None; + break; + } + + if (c) + { + len = strlen(s); + USL_MeasureString(s,&w,&h); + + if + ( + isprint(c) + && (len < MaxString - 1) + && ((!maxchars) || (len < maxchars)) + && ((!maxwidth) || (w < maxwidth)) + ) + { + for (i = len + 1;i > cursor;i--) + s[i] = s[i - 1]; + s[cursor++] = c; + redraw = true; + } + } + + if (redraw) + { + px = x; + py = y; + temp = fontcolor; + fontcolor = backcolor; + USL_DrawString(olds); + fontcolor = temp; + strcpy(olds,s); + + px = x; + py = y; + USL_DrawString(s); + + redraw = false; + } + + if (cursormoved) + { + cursorvis = false; + lasttime = TimeCount - TickBase; + + cursormoved = false; + } + if (TimeCount - lasttime > TickBase / 2) + { + lasttime = TimeCount; + + cursorvis ^= true; + } + if (cursorvis) + USL_XORICursor(x,y,s,cursor); + + //++++VW_UpdateScreen(); + } + + if (cursorvis) + USL_XORICursor(x,y,s,cursor); + if (!result) + { + px = x; + py = y; + USL_DrawString(olds); + } + //++++VW_UpdateScreen(); + + IN_ClearKeysDown(); + return(result); +} + +#if 0 + +#define PaddleMinX (CtlPanelSX + 3) +#define PaddleMaxX (CtlPanelEX - 15) +#define BallMinX (CtlPanelSX + 2) +#define BallMinY (CtlPanelSY + 12 + 2) +#define BallMaxX (CtlPanelEX - 6) +#define BallMaxY (CtlPanelEY - 13) +#define CPaddleY (BallMinY + 4) +#define KPaddleY (BallMaxY - 2) +void +USL_DrawPongScore(word k,word c) +{ + fontcolor = HiliteColor; + PrintY = py = CtlPanelSY + 4; + px = CtlPanelSX + 6; + VWB_Bar(px,py,42,6,BackColor); + USL_DrawString("YOU:"); + PrintX = px; + US_PrintUnsigned(k); + px = CtlPanelSX + 108; + VWB_Bar(px,py,50,6,BackColor); + USL_DrawString("COMP:"); + PrintX = px; + US_PrintUnsigned(c); +} + +void +USL_PlayPong(void) +{ + boolean ball,killball,revdir,done,lastscore; + word cycle, + x,y, + kx,cx, + rx, + bx,by, + kscore,cscore, + speedup; + int bdx,bdy; + word balltime,waittime; + CursorInfo cursorinfo; + + kx = cx = PaddleMinX + ((PaddleMaxX - PaddleMinX) / 2); + bx = by = bdx = bdy = 0; + kscore = cscore = 0; + USL_DrawPongScore(0,0); + cycle = 0; + revdir = false; + killball = true; + done = false; + lastscore = false; + do + { + waittime = TimeCount; + + IN_ReadCursor(&cursorinfo); + if (((cursorinfo.x < 0) || IN_KeyDown(sc_LeftArrow)) && (kx > PaddleMinX)) + kx -= 2; + else if (((cursorinfo.x > 0) || IN_KeyDown(sc_RightArrow)) && (kx < PaddleMaxX)) + kx += 2; + + if (killball) + { + ball = false; + balltime = TimeCount + TickBase; + speedup = 10; + killball = false; + } + + if (ball && (cycle++ % 3)) + { + x = (bx >> 2); + if (!(x & 1)) + x += (US_RndT() & 1); + + if ((cx + 6 < x) && (cx < PaddleMaxX)) + cx += 1; + else if ((cx + 6 > x) && (cx > PaddleMinX)) + cx -= 1; + } + + VWB_Bar(BallMinX,BallMinY - 1, + BallMaxX - BallMinX + 5,BallMaxY - BallMinY + 7, + BackColor); + VWB_DrawSprite(cx,CPaddleY,PADDLESPR); + VWB_DrawSprite(kx,KPaddleY,PADDLESPR); + if (ball) + { + if + ( + (((bx + bdx) >> 2) > BallMaxX) + || (((bx + bdx) >> 2) < BallMinX) + ) + { + SD_PlaySound(BALLBOUNCESND); + bdx = -bdx; + } + bx += bdx; + + if (((by + bdy) >> 2) > BallMaxY) + { + killball = true; + lastscore = false; + cscore++; + SD_PlaySound(COMPSCOREDSND); + USL_DrawPongScore(kscore,cscore); + if (cscore == 21) + { + USL_CtlDialog("You lost!","Press any key",nil); + done = true; + continue; + } + } + else if (((by + bdy) >> 2) < BallMinY) + { + killball = true; + lastscore = true; + kscore++; + SD_PlaySound(KEENSCOREDSND); + USL_DrawPongScore(kscore,cscore); + if (kscore == 21) + { + USL_CtlDialog("You won!","Press any key",nil); + done = true; + continue; + } + } + by += bdy; + + x = bx >> 2; + y = by >> 2; + if (!killball) + { + if + ( + (bdy < 0) + && ((y >= CPaddleY) && (y < CPaddleY + 3)) + && ((x >= (cx - 5)) && (x < (cx + 11))) + ) + { + rx = cx; + revdir = true; + SD_PlaySound(COMPPADDLESND); + } + else if + ( + (bdy > 0) + && ((y >= (KPaddleY - 3)) && (y < KPaddleY)) + && ((x >= (kx - 5)) && (x < (kx + 11))) + ) + { + if (((bdy >> 2) < 3) && !(--speedup)) + { + bdy++; + speedup = 10; + } + rx = kx; + revdir = true; + SD_PlaySound(KEENPADDLESND); + } + if (revdir) + { + bdy = -bdy; + bdx = ((x + 5 - rx) >> 1) - (1 << 2); + if (!bdx) + bdx--; + revdir = false; + } + } + VWB_DrawSprite(x,y,(x & 1)? BALL1PIXELTOTHERIGHTSPR : BALLSPR); + } + else if (TimeCount >= balltime) + { + ball = true; + bdx = 1 - (US_RndT() % 3); + bdy = 2; + if (lastscore) + bdy = -bdy; + bx = (BallMinX + ((BallMaxX - BallMinX) / 2)) << 2; + by = (BallMinY + ((BallMaxY - BallMinY) / 2)) << 2; + } + //++++VW_UpdateScreen(); + while (waittime == TimeCount) + ; // DEBUG - do adaptiveness + } while ((LastScan != sc_Escape) && !done); + IN_ClearKeysDown(); +} + +#pragma argsused +static boolean +USL_PongCustom(UserCall call,struct UserItem far *item) +{ + if (call != uic_SetupCard) + return(false); + + VWB_DrawPic(0,0,CP_MENUSCREENPIC); + VWB_DrawPic(CtlPanelSX + 56,CtlPanelSY,CP_PADDLEWARPIC); + VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelSY + 12,HiliteColor ^ BackColor); + VWB_Hlin(CtlPanelSX + 3,CtlPanelEX - 3,CtlPanelEY - 7,HiliteColor ^ BackColor); + USL_PlayPong(); + + return(true); +} + +#endif diff --git a/src/lib/16_us.h_ b/src/lib/16_us.h_ new file mode 100755 index 00000000..50918844 --- /dev/null +++ b/src/lib/16_us.h_ @@ -0,0 +1,126 @@ +// +// ID Engine +// ID_US.h - Header file for the User Manager +// v1.0d1w +// By Jason Blochowiak +// Open Watcom port by sparky4 +// + +#ifndef __16_US__ +#define __16_US__ + +#include "src/lib/16_head.h" + +#ifdef __DEBUG__ +#define __DEBUG_UserMgr__ +#endif + +//#define HELPTEXTLINKED + +#define MaxX 320 +#define MaxY 200 + +#define MaxHelpLines 500 + +#define MaxHighName 57 +#define MaxScores 7 +typedef struct + { + char name[MaxHighName + 1]; + long score; + word completed,episode; + } HighScore; + +#define MaxGameName 32 +#define MaxSaveGames 6 +typedef struct + { + char signature[4]; + word *oldtest; + boolean present; + char name[MaxGameName + 1]; + } SaveGame; + +#define MaxString 128 // Maximum input string size + +typedef struct + { + int x,y, + w,h, + px,py; + } WindowRec; // Record used to save & restore screen windows + +typedef enum + { + gd_Continue, + gd_Easy, + gd_Normal, + gd_Hard + } GameDiff; + +// Hack import for TED launch support +extern boolean tedlevel; +extern int tedlevelnum; +extern void TEDDeath(void); + +extern boolean ingame, // Set by game code if a game is in progress + abortgame, // Set if a game load failed + loadedgame, // Set if the current game was loaded + NoWait, + HighScoresDirty; +extern char *abortprogram; // Set to error msg if program is dying +extern GameDiff restartgame; // Normally gd_Continue, else starts game +extern word PrintX,PrintY; // Current printing location in the window +extern word WindowX,WindowY,// Current location of window + WindowW,WindowH;// Current size of window + +extern boolean Button0,Button1, + CursorBad; +extern int CursorX,CursorY; + +extern void (*USL_MeasureString)(char far *,word *,word *), + (*USL_DrawString)(char far *); + +extern boolean (*USL_SaveGame)(int),(*USL_LoadGame)(int); +extern void (*USL_ResetGame)(void); +extern SaveGame Games[MaxSaveGames]; +extern HighScore Scores[]; + +#define US_HomeWindow() {PrintX = WindowX; PrintY = WindowY;} + +extern void US_Startup(void), + US_Setup(void), + US_Shutdown(void), + US_InitRndT(boolean randomize), + US_SetLoadSaveHooks(boolean (*load)(int), + boolean (*save)(int), + void (*reset)(void)), + US_TextScreen(void), + US_UpdateTextScreen(void), + US_FinishTextScreen(void), + US_DrawWindow(word x,word y,word w,word h), + US_CenterWindow(word,word), + US_SaveWindow(WindowRec *win), + US_RestoreWindow(WindowRec *win), + US_ClearWindow(void), + US_SetPrintRoutines(void (*measure)(char far *,word *,word *), + void (*print)(char far *)), + US_PrintCentered(char far *s), + US_CPrint(char far *s), + US_CPrintLine(char far *s), + US_Print(char far *s), + US_PrintUnsigned(word n), + US_PrintSigned(long n), + US_StartCursor(void), + US_ShutCursor(void), + US_CheckHighScore(long score,word other), + US_DisplayHighScores(int which); +extern boolean US_UpdateCursor(void), + US_LineInput(int x,int y,char *buf,char *def,boolean escok, + int maxchars,int maxwidth); +extern int US_CheckParm(char *parm,char **strings), + US_RndT(void); + + void USL_PrintInCenter(char far *s,Rect r); + char *USL_GiveSaveName(word game); +#endif diff --git a/src/palbomb.c b/src/palbomb.c new file mode 100755 index 00000000..80b9a9f5 --- /dev/null +++ b/src/palbomb.c @@ -0,0 +1,42 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +#include "src/lib/16_vl.h" +void main(int argc, char *argv[]) { + static global_game_variables_t gvar; word i; + + + TL_VidInit(&gvar); VGAmodeX(1, 0, &gvar); + + gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); + VL_ShowPage(&gvar.video.page[0], 1, 0); + modexpdump(&gvar.video.page[0]); + while(!kbhit()){ VL_modexPalScramble(&gvar.video.palette); } + modexPalSave(&gvar.video.palette); + VGAmodeX(0, 0, &gvar); + for(i=0;i<16;i++) + { + printf("%02x", gvar.video.palette[i]); + if((!(i%16)) && i) printf("\n"); + else printf(" "); + } + modexPalUpdate(&gvar.video.palette); +} diff --git a/src/palettec.c b/src/palettec.c index 2935ad26..f221d837 100755 --- a/src/palettec.c +++ b/src/palettec.c @@ -19,22 +19,17 @@ * Fifth Floor, Boston, MA 02110-1301 USA. * */ - #include "src/lib/16_vl.h" - -void main(int argc, char *argv[]) -{ - static global_game_variables_t gvar; - char bakapee[64] = "data\default.pal"; - - if(argv[1]) strcpy(bakapee, argv[1]); - - - VGAmodeX(1, 1, &gvar); - - modexPalSave(&(gvar.video.palette)); - - modexSavePalFile(bakapee, &(gvar.video.palette)); - - VGAmodeX(0, 1, &gvar); +void main(int argc, char *argv[]) { + static global_game_variables_t gvar; char bakapee[64] = "data/default.pal"; + if(argv[1]) strcpy(bakapee, argv[1]); modexPalSave(&gvar.video.palette);// modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); modexPalBlack(); + + TL_VidInit(&gvar); VGAmodeX(1, 0, &gvar); + modexSavePalFile(bakapee, &gvar.video.palette); + gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);// modexFadeOn(4, &gvar.video.palette); + VL_ShowPage(&gvar.video.page[0], 1, 0); + modexpdump(&gvar.video.page[0]); + while(!kbhit()){ /*VL_modexPalScramble(&gvar.video.palette);*/ } +// modexPalSave(&gvar.video.palette); + VGAmodeX(0, 0, &gvar); } diff --git a/src/palettel.c b/src/palettel.c index 9249e540..6b6840a7 100755 --- a/src/palettel.c +++ b/src/palettel.c @@ -19,35 +19,24 @@ * Fifth Floor, Boston, MA 02110-1301 USA. * */ - #include "src/lib/16_vl.h" -#include "src/lib/bakapee.h" - -word i; - -void main(int argc, char *argv[]) -{ - static global_game_variables_t gvar; - char bakapee[64] = "data\default.pal"; - - if(argv[1]) strcpy(bakapee, argv[1]); - - - modexPalSave(&(gvar.video.palette)); - VL_modexPalScramble(&(gvar.video.palette)); - VGAmodeX(1, 1, &gvar); - gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); - modexPalBlack(); +void main(int argc, char *argv[]) { + static global_game_variables_t gvar; word i; char bakapee[64] = "data/16.pal"; + if(argv[1]) strcpy(bakapee, argv[1]);// modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); modexPalBlack(); - modexLoadPalFile(bakapee, &(gvar.video.palette)); - modexPalUpdate(&(gvar.video.palette)); - modexFadeOn(1, &(gvar.video.palette)); + TL_VidInit(&gvar); VGAmodeX(1, 0, &gvar); + VL_LoadPalFile(bakapee, &gvar.video.palette); //modexLoadPalFile(bakapee, &(gvar.video.palette)); + gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);// modexFadeOn(4, &gvar.video.palette); + VL_ShowPage(&gvar.video.page[0], 1, 0); modexpdump(&gvar.video.page[0]); -// getch(); + while(!kbhit()){ /*VL_modexPalScramble(&gvar.video.palette);*/ } + modexPalSave(&gvar.video.palette); VGAmodeX(0, 0, &gvar); - modexPalUpdate(&(gvar.video.palette)); - /*for(i=0;i<768;i++) + for(i=0;i<16;i++) { - printf("%02X ", pal[i]); - }*/ + printf("%02x", gvar.video.palette[i]); + if((!(i%16)) && i) printf("\n"); + else printf(" "); + } + modexPalUpdate(&gvar.video.palette); } -- 2.39.5