From: sparky4 Date: Fri, 17 Feb 2017 14:50:11 +0000 (-0600) Subject: palette is now arrays X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=0fafba3a1ca84e8bb74c995cc42e397131f2bcd6;p=16.git palette is now arrays --- diff --git a/src/lib/ems.c b/16/othersrc/lib/ems.c similarity index 100% rename from src/lib/ems.c rename to 16/othersrc/lib/ems.c diff --git a/src/lib/ems.h b/16/othersrc/lib/ems.h similarity index 100% rename from src/lib/ems.h rename to 16/othersrc/lib/ems.h diff --git a/src/lib/midi.c b/16/othersrc/lib/midi.c similarity index 100% rename from src/lib/midi.c rename to 16/othersrc/lib/midi.c diff --git a/src/lib/midi.h b/16/othersrc/lib/midi.h similarity index 100% rename from src/lib/midi.h rename to 16/othersrc/lib/midi.h diff --git a/src/lib/tst.c b/16/othersrc/lib/tst.c similarity index 100% rename from src/lib/tst.c rename to 16/othersrc/lib/tst.c diff --git a/src/lib/xms.c b/16/othersrc/lib/xms.c similarity index 100% rename from src/lib/xms.c rename to 16/othersrc/lib/xms.c diff --git a/src/lib/xms.h b/16/othersrc/lib/xms.h similarity index 100% rename from src/lib/xms.h rename to 16/othersrc/lib/xms.h diff --git a/src/midi.c b/16/othersrc/midi.c similarity index 100% rename from src/midi.c rename to 16/othersrc/midi.c diff --git a/src/testemm.c b/16/othersrc/testemm.c similarity index 100% rename from src/testemm.c rename to 16/othersrc/testemm.c diff --git a/src/testemm0.c b/16/othersrc/testemm0.c similarity index 100% rename from src/testemm0.c rename to 16/othersrc/testemm0.c diff --git a/src/tsthimem.c b/16/othersrc/tsthimem.c similarity index 100% rename from src/tsthimem.c rename to 16/othersrc/tsthimem.c diff --git a/makefile b/makefile index 9440b2da..5ebf3d5c 100755 --- a/makefile +++ b/makefile @@ -123,7 +123,7 @@ LIBFLAGS=$(WLIBQ) -b -n # objects # VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) -OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) +#OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) GFXLIBOBJS = 16_vl.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS) 16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) 16_enti.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) @@ -182,13 +182,13 @@ TESTEXEC = & 0.exe & exmmtest.exe & vgmtest.exe & - scroll.exe & zcroll.exe & inputest.exe & - pcxtest.exe & vrstest.exe & maptest.exe TESTEXEC2 = & + pcxtest.exe & + scroll.exe & fmemtest.exe & fonttest.exe & fontgfx.exe & diff --git a/src/16.c b/src/16.c index d2072fcb..9877b7df 100755 --- a/src/16.c +++ b/src/16.c @@ -23,7 +23,6 @@ #include "src/16.h" engi_stat_t engi_stat; -byte *dpal, *gpal; player_t player[MaxPlayers]; void @@ -35,12 +34,10 @@ main(int argc, char *argv[]) engi_stat = ENGI_RUN; /* save the palette */ - dpal = modexNewPal(); - modexPalSave(dpal); - modexFadeOff(4, dpal); - gpal = modexNewPal(); - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); + modexPalSave(gvar.video.dpal); + modexFadeOff(4, gvar.video.dpal); + modexPalSave(gvar.video.palette); + modexSavePalFile("data/g.pal", gvar.video.palette); VGAmodeX(1, 1, &gvar); // modexPalBlack(); //so player will not see loadings~ IN_Default(0,&player,ctrl_Joystick); @@ -57,5 +54,5 @@ main(int argc, char *argv[]) printf("Project 16 16.exe. This is supposed to be the actual finished game executable!\n"); printf("version %s\n", VERSION); WCPU_cpufpumesg(); - modexFadeOn(4, dpal); + modexFadeOn(4, gvar.video.dpal); } diff --git a/src/fontgfx.c b/src/fontgfx.c index 1fc19b24..98639c33 100755 --- a/src/fontgfx.c +++ b/src/fontgfx.c @@ -128,8 +128,6 @@ IIIIIII BBBBBBBBB MMMM M MMMM\n\ // modexprint(0, 0, 1, 0, colpee, ROSE); //++++ getch(); VGAmodeX(0, 1, &gvar); -// rosa=malloc(sizeof(ROSE)); -// (*rosa)=(byte)ROSE; printf("\n%s\n", rose); //printf("\nh=%d\n", '8'); // printf("\n%c\n", e); diff --git a/src/lib/16_map.c b/src/lib/16_map.c index e6a5a1d1..3b1d7d72 100755 --- a/src/lib/16_map.c +++ b/src/lib/16_map.c @@ -223,7 +223,7 @@ int CA_loadmap(char *mn, map_t *map, global_game_variables_t *gvar) file_s = filesize(fh); CA_LoadFile(mn, &MAPBUFINLM, gvar); tokcount = jsmn_parse(&p, MAPBUFINLM, file_s, NULL, 0); - tok = malloc(tokcount*sizeof(jsmntok_t));//TODO: USE MM_ CA_ AND PM_ + tok = malloc(tokcount*sizeof(jsmntok_t)); // printf("Allocated %d tokens", tokcount); jsmn_init(&p); if((status = jsmn_parse(&p, MAPBUFINLM, file_s, tok, tokcount)) < 0) diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index b30f9df8..51e1ee13 100755 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -22,7 +22,6 @@ #define __16_MM__ #include -#include #include "src/lib/16_head.h" #include "src/lib/16_hc.h" #include "src/lib/16_tail.h" diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index af4b0d7e..447bfbf6 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -91,7 +91,7 @@ typedef struct sprite //TODO: 16_mm and 16_ca must handle this typedef struct { - bitmap_t far *pcximg; // old +// bitmap_t far *pcximg; // old #ifdef __WATCOMC__ sprite_t *spri; // I will probibaly use this --sparky4 #endif @@ -141,9 +141,9 @@ typedef struct { word sh; /* screen heigth */ /* resolution */ word width; /* virtual width of the page */ word height; /* virtual height of the page */ - word stridew; /* width/4 */ /* VGA */ - word pagesize; /* page size */ - word pi; /* increment page by this much to preserve location */ + word stridew; /* width/4 */ /* VGA */ + word pagesize; /* page size */ + word pi; /* increment page by this much to preserve location */ int tlx,tly; //newer vars //TODO: find where they are used @@ -237,8 +237,8 @@ typedef struct //struct sprite *spri; //supposively the sprite sheet data memptr gr; #endif - bitmap_t *data; //supposively the sprite sheet data//old format - bitmap_t bmp; +// bitmap_t *data; //supposively the sprite sheet data//old format +// bitmap_t bmp; //input byte near pdir; //previous direction~ used in IN_16 in IN_ReadControl() @@ -268,18 +268,20 @@ typedef struct nibble wcpu; //stored value of cpu type } kurokku_t; +//===================================// +#define PALSIZE 768 +#define NUMCHUNKS 416 //keen //video typedef struct { unsigned int offscreen_ofs; unsigned int pattern_ofs; -} ofs_t; -#define NUMCHUNKS 416 //keen +} ofs_t; //unfinished typedef struct { char old_mode; //old video mode before game! - byte palette[768]; //palette array + byte palette[PALSIZE], dpal[PALSIZE]; //palette array 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 diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index f241fb6e..2e5fa42e 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -644,41 +644,39 @@ modexPalSave(byte *palette) { } -byte * +/*byte * modexNewPal() { byte *ptr; - ptr = malloc(PAL_SIZE); + ptr = m a l l o c(PAL_SIZE); - /* handle errors */ + // handle errors if(!ptr) { printf("Could not allocate palette.\n"); } return ptr; -} +}*/ void -modexLoadPalFile(byte *filename, byte **palette) { +modexLoadPalFile(byte *filename, byte *palette) { FILE *file; byte *ptr; - /* free the palette if it exists */ - if(*palette) { - free(*palette); - } + // free the palette if it exists + //if(*palette) { free(*palette); } - /* allocate the new palette */ - *palette = modexNewPal(); + // allocate the new palette + //*palette = modexNewPal(); - /* open the file */ + // open the file file = fopen(filename, "rb"); if(!file) { - printf("Could not open palette file: %s\n", filename); + printf("Could not open palette file: %s\n", filename); } /* read the file */ - ptr = *palette; + ptr = palette; while(!feof(file)) { *ptr++ = fgetc(file); } diff --git a/src/lib/16_vl.h b/src/lib/16_vl.h index 93780c51..d113825e 100755 --- a/src/lib/16_vl.h +++ b/src/lib/16_vl.h @@ -58,7 +58,6 @@ #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2)) #define PLANE(x) (1 << ((x) & 3)) #define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02) -#define PALSIZE 768 typedef union { @@ -122,8 +121,8 @@ void modexFlashOff(word fade, byte *palette); /* palette loading and saving */ void modexPalSave(byte *palette); -byte *modexNewPal(); -void modexLoadPalFile(char *filename, byte **palette); +//byte *modexNewPal(); +void modexLoadPalFile(char *filename, byte *palette); void VL_LoadPalFile(const char *filename, byte *palette); void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o); void VL_UpdatePaletteWrite(byte *palette, word o); diff --git a/src/lib/16_vlpal.c b/src/lib/16_vlpal.c index 2f155f03..032f2b7a 100755 --- a/src/lib/16_vlpal.c +++ b/src/lib/16_vlpal.c @@ -24,12 +24,12 @@ //color checker~ //i want to make another vesion that checks the palette when the palette is being appened~ -void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/) +void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/, global_game_variables_t *gv) { - byte *pal; + byte *pal=&(gv->video.palette); word zz=0; - pal = modexNewPal(); - modexPalSave(pal); + //pal = modexNewPal(); +// modexPalSave(pal); CHKCOLDBGOUT1 //check palette for dups for(; (*z)palette; word w=0; @@ -179,7 +179,7 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset) printf("1(*i)=%02d\n", (*i)/3);// printf("1z=%02d\n", z/3);// #endif - modexchkcolor(bmp, &q, &a, &aa, &z, i); + modexchkcolor(bmp, &q, &a, &aa, &z, i, gv); #ifdef BEVERBOSEPALCHECK printf("2(*i)=%02d\n", (*i)/3); printf("2z=%02d\n", z/3); @@ -253,7 +253,7 @@ printf(" aq=%02d\n", aq);// printf(" aa=%02d\n", aa);// #endif //update the palette~ - VL_palette(bmp, p, &pp, aq, aqoffset); + VL_palette(bmp, p, &pp, aq, aqoffset, gv); (*i)=pp; if(aq= page->width - t->tileWidth) printf("\n"); switch(i) { @@ -578,8 +576,8 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color! break; default: - rx = (((i-1) % ((t->pcximg->width)/t->tileWidth)) * t->tileWidth); - ry = (((i-1) / ((t->pcximg->height)/t->tileHeight)) * t->tileHeight); + rx = (((i-1) % ((t->spri->sprite_vrl_cont->vrl_header->width)/t->tileWidth)) * t->tileWidth); + ry = (((i-1) / ((t->spri->sprite_vrl_cont->vrl_header->height)/t->tileHeight)) * t->tileHeight); #ifndef TILERENDER if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1); #else diff --git a/src/palettec.c b/src/palettec.c index 3864b677..8f1ed3e7 100755 --- a/src/palettec.c +++ b/src/palettec.c @@ -26,8 +26,7 @@ void main(int argc, char *argv[]) { static global_game_variables_t gvar; - byte *pal; - byte *bakapee; + char *bakapee; bakapee = malloc(64); if(argv[1]) bakapee = argv[1]; @@ -35,11 +34,11 @@ main(int argc, char *argv[]) VGAmodeX(1, 1, &gvar); - pal = modexNewPal(); - modexPalSave(pal); + modexPalSave(&(gvar.video.palette)); - modexSavePalFile(bakapee, pal); + modexSavePalFile(bakapee, &(gvar.video.palette)); VGAmodeX(0, 1, &gvar); + free(bakapee); } diff --git a/src/palettel.c b/src/palettel.c index e7f2ace0..1a487bab 100755 --- a/src/palettel.c +++ b/src/palettel.c @@ -23,7 +23,6 @@ #include "src/lib/16_vl.h" #include "src/lib/bakapee.h" -byte *pal; char *bakapee; word i; @@ -31,26 +30,24 @@ void main(int argc, char *argv[]) { static global_game_variables_t gvar; - //page.width += 32; - //page.height += 32; - pal = modexNewPal(); bakapee = malloc(64); if(argv[1]) bakapee = argv[1]; else bakapee = "data/default.pal"; -// modexPalSave(pal); + modexPalSave(&(gvar.video.palette)); VGAmodeX(1, 1, &gvar); gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); modexPalBlack(); - modexLoadPalFile(bakapee, &pal); - modexPalUpdate(pal); - modexFadeOn(1, pal); + modexLoadPalFile(bakapee, &(gvar.video.palette)); + modexPalUpdate(&(gvar.video.palette)); + modexFadeOn(1, &(gvar.video.palette)); modexpdump(&gvar.video.page[0]); getch(); VGAmodeX(0, 0, &gvar); - modexPalUpdate(pal); + modexPalUpdate(&(gvar.video.palette)); /*for(i=0;i<768;i++) { printf("%02X ", pal[i]); }*/ + free(bakapee); } diff --git a/src/scroll.c b/src/scroll.c index 61668d6c..36a7370c 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -38,9 +38,8 @@ extern boolean pagenorendermap; unsigned int i; //#ifdef FADE static word paloffset=0; - byte *dpal; + byte *gvar.video.dpal; //#endif - byte *gpal; // byte *ptr; byte *mappalptr; @@ -75,9 +74,9 @@ void main(int argc, char *argv[]) /* save the palette */ #ifdef MODEX #ifdef FADE - dpal = modexNewPal(); - modexPalSave(dpal); - modexFadeOff(4, dpal); + gvar.video.dpal = modexNewPal(); + modexPalSave(gvar.video.dpal); + modexFadeOff(4, gvar.video.dpal); #endif VGAmodeX(bakapee, 1, &gvar); @@ -100,9 +99,9 @@ void main(int argc, char *argv[]) // printf("====\n\n"); #ifdef MODEX #ifdef FADE - gpal = modexNewPal(); - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); + &gvar.video.palette = modexNewPal(); + modexPalSave(&gvar.video.palette); + modexSavePalFile("data/g.pal", &gvar.video.palette); modexPalBlack(); //so player will not see loadings~ #endif #endif @@ -123,11 +122,11 @@ void main(int argc, char *argv[]) if (gvar.video.sprifilei == -1) { #ifdef FADE - modexFadeOff(4, gpal); + modexFadeOff(4, &gvar.video.palette); #endif Quit(&gvar, "Wrong"); #ifdef FADE - modexFadeOn(4, dpal); + modexFadeOn(4, gvar.video.dpal); #endif } @@ -159,7 +158,7 @@ void main(int argc, char *argv[]) #ifdef MODEX #ifdef FADE - modexFadeOn(4, gpal); + modexFadeOn(4, &gvar.video.palette); #endif #endif while(!IN_KeyDown(sc_Escape) && player[0].enti.hp>0) @@ -193,7 +192,7 @@ void main(int argc, char *argv[]) //debugging binds! #ifdef MODEX #ifdef FADE - if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1,1); } //p + if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1,1); } //p /*if(IN_KeyDown(22)){ paloffset=0; modexPalBlack(); modexPalUpdate(PCXBMPVAR, &paloffset, 0, 0); printf("1paloffset = %d\n", paloffset/3); @@ -220,7 +219,7 @@ void main(int argc, char *argv[]) //9 #ifdef FADE - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(dpal); IN_UserInput(1,1); } + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1,1); } #endif if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r @@ -231,9 +230,9 @@ void main(int argc, char *argv[]) /* but 1st lets save the game palette~ */ #ifdef MODEX #ifdef FADE - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); - modexFadeOff(4, gpal); + modexPalSave(&gvar.video.palette); + modexSavePalFile("data/g.pal", &gvar.video.palette); + modexFadeOff(4, &gvar.video.palette); #endif VGAmodeX(0, 1, &gvar); #endif @@ -244,7 +243,7 @@ void main(int argc, char *argv[]) WCPU_cpufpumesg(); #ifdef MODEX #ifdef FADE - modexFadeOn(4, dpal); + modexFadeOn(4, gvar.video.dpal); #endif #endif } diff --git a/src/test.c b/src/test.c index 6d130170..2885dc46 100755 --- a/src/test.c +++ b/src/test.c @@ -30,7 +30,6 @@ #define HGQ 55 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ -static byte *palette;//[PAL_SIZE]; void main(int argc, char *argv[]) { @@ -84,7 +83,6 @@ void main(int argc, char *argv[]) Startup16(&gvar); /* save the palette */ - palette = modexNewPal(); //====modexPalSave(pal); //====modexFadeOff(1, pal); //====modexPalBlack(); @@ -99,12 +97,12 @@ void main(int argc, char *argv[]) /* load our palette */ VL_LoadPalFile("data/16.pal", &gvar.video.palette); bmp1.offset=(paloffset/3); - VL_palette(&bmp1, &gvar.video.palette, &paloffset, 0, 0); + VL_palette(&bmp1, &gvar.video.palette, &paloffset, 0, 0, &gvar); //VL_LoadPalFilewithoffset("data/default.pal", &palette, paloffset); - modexLoadPalFile("data/16t.pal", &palette); + modexLoadPalFile("data/16t.pal", &gvar.video.dpal); bmp2.offset=(paloffset/3); - VL_palette(&bmp2, palette, &paloffset, 0, 0); + VL_palette(&bmp2, &gvar.video.dpal, &paloffset, 0, 0, &gvar); //====modexLoadPalFile("data/default.pal", &pal2); /* overscan show */ diff --git a/src/zcroll.c b/src/zcroll.c index 015493e3..6d38a789 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -39,9 +39,7 @@ unsigned int i; #ifdef FADE //static word paloffset=0; -byte *dpal; #endif -byte *gpal; byte *ptr; memptr pal; @@ -96,9 +94,8 @@ void main(int argc, char *argv[]) // save the palette #ifdef FADE - dpal = modexNewPal(); - modexPalSave(dpal); - modexFadeOff(4, dpal); + modexPalSave(&gvar.video.dpal); + modexFadeOff(4, &gvar.video.dpal); modexPalBlack(); #endif @@ -116,9 +113,8 @@ void main(int argc, char *argv[]) //VL_LoadPalFile("data/default.pal", &gvar.video.palette); #ifdef FADE - gpal = modexNewPal(); - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); + modexPalSave(&gvar.video.palette); + modexSavePalFile("data/g.pal", &gvar.video.palette); modexPalBlack(); //so player will not see loadings~ #endif @@ -136,11 +132,11 @@ void main(int argc, char *argv[]) if (gvar.video.sprifilei == -1) { #ifdef FADE - modexFadeOff(4, gpal); + modexFadeOff(4, &gvar.video.palette); #endif Quit(&gvar, "Wrong ID for sprite"); #ifdef FADE - modexFadeOn(4, dpal); + modexFadeOn(4, &gvar.video.dpal); #endif } @@ -150,7 +146,7 @@ void main(int argc, char *argv[]) shinku(&gvar); //modexpdump(mv[0].page); #ifdef FADE - modexFadeOn(4, gpal); + modexFadeOn(4, &gvar.video.palette); #endif while(!IN_KeyDown(sc_Escape) && player[0].enti.hp>0) { @@ -210,7 +206,7 @@ void main(int argc, char *argv[]) VL_LoadPalFile(bakapee1p, &gvar.video.palette); }//JK #ifdef FADE - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(dpal); IN_UserInput(1,1); } + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1,1); } #endif if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r @@ -220,9 +216,9 @@ void main(int argc, char *argv[]) /* fade back to text mode */ /* but 1st lets save the game palette~ */ #ifdef FADE - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); - modexFadeOff(4, gpal); + modexPalSave(&gvar.video.palette); + modexSavePalFile("data/g.pal", &gvar.video.palette); + modexFadeOff(4, &gvar.video.palette); #endif Shutdown16(&gvar); printf("\nProject 16 zcroll.exe. This is just a test file!\n"); @@ -230,6 +226,6 @@ void main(int argc, char *argv[]) SCROLLEXITMESG; WCPU_cpufpumesg(); #ifdef FADE - modexFadeOn(4, dpal); + modexFadeOn(4, gvar.video.dpal); #endif }