From 40e0a339b2d6e79ace05d43dd9d44b21b23244b1 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Tue, 14 Feb 2017 11:41:14 -0600 Subject: [PATCH] Revert "too tired to continue" #Please enter the commit message for your changes. Lines starting #with '' will be ignored, and an empty message aborts the commit. #On branch master #Your branch is up-to-date with 'origin/master'. Changes to be committed: modified: data/16.pal modified: data/G.PAL modified: src/lib/16_map.c modified: src/lib/16_tdef.h modified: src/lib/16_vl.c modified: src/lib/16_vlpal.c modified: src/lib/bitmap.c modified: src/lib/scroll16.c modified: src/maptest.c #Changes not staged for commit: Untracked files: 0.exe 0.lnk 16.exe 16.lnk bakapi.exe bakapi.lnk db.lnk exmmtest.exe exmmtest.lnk inputest.exe inputest.lnk maptest.exe maptest.lnk palettec.exe palettec.lnk palettel.exe palettel.lnk palllist.exe palllist.lnk pcxtest.exe pcxtest.lnk scroll.exe scroll.lnk test.exe test.lnk tesuto.exe tesuto.lnk vgmtest.exe vgmtest.lnk vrstest.exe vrstest.lnk wcpu.lnk zcroll.exe zcroll.lnk --- data/16.pal | Bin 768 -> 768 bytes data/G.PAL | Bin 768 -> 768 bytes src/lib/16_map.c | 2 +- src/lib/16_tdef.h | 92 ++++++++++++++++++++++----------------------- src/lib/16_vl.c | 17 +++++++-- src/lib/16_vlpal.c | 10 ++--- src/lib/bitmap.c | 13 +++---- src/lib/scroll16.c | 43 +++++++++++---------- src/maptest.c | 20 ++++------ 9 files changed, 100 insertions(+), 97 deletions(-) diff --git a/data/16.pal b/data/16.pal index cb6f0aef37b2280a7cac68a10dc99108348f0789..eaf5208550ce2b2d7a255488e2de6b8d22afb6c8 100755 GIT binary patch delta 13 UcmZo*Yharou~G3p(?kPK03Lk=G5`Po delta 17 YcmZo*Yharo!OY0WxKZ&w(?kO{040h9H2?qr diff --git a/data/G.PAL b/data/G.PAL index 07edf768ed7f6efd53e88d7cc113aba28ab309f6..8092380af954e11b165eae773d83f03429619756 100755 GIT binary patch delta 12 TcmZo*Yhc^R{FjNDfq?-47bOD2 delta 11 ScmZo*YhYt$U|`trmk9t4m;%25 diff --git a/src/lib/16_map.c b/src/lib/16_map.c index b17eb932..37179ab7 100755 --- a/src/lib/16_map.c +++ b/src/lib/16_map.c @@ -296,7 +296,7 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) { if(jsoneq(js, &(t[i]), "image") == 0) { map->MAPTILESPTK = malloc(sizeof(tiles_t)); s = remove_ext((char *)js+t[i+1].start, '.', '/'); - strcpy(map->MAPTILESPTK->tileset.imgname, s); + strcpy(map->MAPTILESPTK->imgname, s); //And move to vrs, probably // bp = bitmapLoadPcx("data/ed.pcx"); // map->MAPTILESPTK->btdata = &bp; diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 4700625e..38fd2260 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -48,44 +48,14 @@ typedef struct { word offset; } bitmap_t; -//from 16_sprit.h -#ifdef __WATCOMC__ -typedef struct sprite -{ - // VRS container from which we will extract animation and image data - struct vrs_container *spritesheet; - // Container for a vrl sprite - struct vrl_container *sprite_vrl_cont; - // Current sprite id - int curr_spri_id; - // Index of a current sprite in an animation sequence - int curr_anim_spri; - // Current animation sequence - struct vrs_animation_list_entry_t *curr_anim_list; - // Index of current animation in relevant VRS offsets table - int curr_anim; - // Delay in time units untill we should change sprite - int delay; - // Position of sprite on screen - int x, y; -} sprite_t; -#endif - typedef struct { - //byte far **data; -//#ifdef __WATCOMC__ - //sprite_t *spri; -//#endif - bitmap_t far *data; // actual tileset info -//in the bitmap_t -// byte *palette; // palette for the tile set - word ntiles; // the number of tiles - word twidth; // width of the tiles - word theight; // height of the tiles - byte imgname[8]; // image filename of tileset + byte far **data; + word ntiles; /* the number of tiles */ + word twidth; /* width of the tiles */ + word theight; /* height of the tiles */ + byte *palette; /* palette for the tile set */ } tileset_t; -//not currently using typedef struct { byte far *plane[4]; // 4 planes of image data word width; // width of the image (spread across 4 planes) @@ -94,20 +64,25 @@ typedef struct { byte *palette; } planar_buf_t; -//tile properties +//TODO: 16_mm and 16_ca must handle this typedef struct { - //bitmap_t far *btdata; //old - tileset_t tileset; //new + bitmap_t far *data; //old + //planar_buf_t far *data; //old word tileHeight, tileWidth; - word rows, cols; + unsigned int rows, cols; +// #ifdef __DEBUG__ +// boolean debug_text; //show the value of the tile! wwww +// byte *debug_data; +// #endif + byte imgname[8]; //image file of tileset } tiles_t; //TODO: 16_mm and 16_ca must handle this //TODO: add variables from 16_ca -#define MAPLAYERS 4 //#define __NEWMAPTILEDATAVARS__ #ifdef __NEWMAPTILEDATAVARS__ +#define MAPLAYERS 4 #define MAPTILESPTR layertile[0] #define MAPTILESPTK layertile[k] #define MAPDATAPTR layerdata[0] @@ -122,14 +97,14 @@ typedef struct { //long planestart[3]; //unsigned planelength[3]; #ifndef __NEWMAPTILEDATAVARS__ - byte *data; //TODO: 16_mm and 16_ca must handle this - tiles_t *tiles; //TODO: 16_mm and 16_ca must handle this + byte *data; //TODO: 16_mm and 16_ca must handle this + tiles_t *tiles; //TODO: 16_mm and 16_ca must handle this #else - byte far *layerdata[MAPLAYERS]; //mapindex for specific layer - tiles_t far *layertile[MAPLAYERS]; + byte * far *layerdata; //TODO: 16_mm and 16_ca must handle this + tiles_t far *layertile[MAPLAYERS]; //TODO: 16_mm and 16_ca must handle this #endif int width, height; //this has to be signed! - byte name[16]; //mapname/maptitle + byte name[16]; } map_t; typedef struct{ @@ -141,12 +116,12 @@ typedef struct{ sword tilemidposscreeny; /* middle tile y position */ /* needed for scroll system to work accordingly */ sword tileplayerposscreenx; /* player position on screen */ /* needed for scroll and map system to work accordingly */ sword tileplayerposscreeny; /* player position on screen */ /* needed for scroll and map system to work accordingly */ -} pagetileinfo_t; +} tileinfo_t; typedef struct { nibble/*word*/ id; /* the Identification number of the page~ For layering~ */ byte far* data; /* the data for the page */ - pagetileinfo_t ti; + tileinfo_t ti; word dx; /* col we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the left size */ word dy; /* row we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the top size */ word sw; /* screen width */ /* resolution */ @@ -162,6 +137,29 @@ typedef struct { sword delta; // How much should we shift the page for smooth scrolling } page_t; +//from 16_sprit.h +#ifdef __WATCOMC__ +typedef struct sprite +{ + // VRS container from which we will extract animation and image data + struct vrs_container *spritesheet; + // Container for a vrl sprite + struct vrl_container *sprite_vrl_cont; + // Current sprite id + int curr_spri_id; + // Index of a current sprite in an animation sequence + int curr_anim_spri; + // Current animation sequence + struct vrs_animation_list_entry_t *curr_anim_list; + // Index of current animation in relevant VRS offsets table + int curr_anim; + // Delay in time units untill we should change sprite + int delay; + // Position of sprite on screen + int x, y; +} sprite_t; +#endif + //newer structs typedef struct { diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 71c5667d..881239de 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -689,7 +689,18 @@ modexLoadPalFile(byte *filename, byte **palette) { void VL_LoadPalFile(const char *filename, byte *palette) { - VL_LoadPalFilewithoffset(filename, palette, 0); + int fd; + + fd = open(filename,O_RDONLY|O_BINARY); + if (fd >= 0) { + word i; + + read(fd,palette, PAL_SIZE); + close(fd); + + vga_palette_lseek(0); + for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + } } void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) @@ -703,8 +714,8 @@ void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) read(fd,palette, PAL_SIZE); close(fd); - vga_palette_lseek(1+o); - for (i=o;i < 255-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + vga_palette_lseek(o); + for (i=o;i < 256-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); } } diff --git a/src/lib/16_vlpal.c b/src/lib/16_vlpal.c index db0f19d6..2f155f03 100755 --- a/src/lib/16_vlpal.c +++ b/src/lib/16_vlpal.c @@ -32,7 +32,7 @@ void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word modexPalSave(pal); CHKCOLDBGOUT1 //check palette for dups - for(; (*z)0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index b42204aa..22bad981 100755 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -160,7 +160,6 @@ bitmapLoadPcx(char *filename, global_game_variables_t *gv) { } //TODO: update!! -/* tileset_t bitmapLoadPcxTiles(char *filename, word twidth, word theight) { tileset_t ts; @@ -168,33 +167,33 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) { bitmap_t result; int i; - // open the PCX file for reading + /* open the PCX file for reading */ file = fopen(filename, "rb"); if(!file) { printf("Could not open %s for reading.\n", filename); exit(-2); } - // load the first part of the pcx file + /* load the first part of the pcx file */ loadPcxStage1(file, &result); - // get the number of tiles and set up the result structure + /* get the number of tiles and set up the result structure */ ts.twidth = twidth; ts.theight = theight; ts.ntiles = (result.width/twidth) * (result.height/theight); ts.palette = result.palette; - // allocate the pixel storage for the tiles + /* allocate the pixel storage for the tiles */ ts.data = _fmalloc(sizeof(byte*) * ts.ntiles); //ts.data[0] = malloc(sizeof(byte) * ts.ntiles * twidth * theight); for(i=1; i < ts.ntiles; i++) { ts.data[i] = ts.data[i-1] + twidth * theight; } - // finish off the file + /* finish off the file */ loadPcxPalette(file, &result); fclose(file); return ts; -}*/ +} diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index e60a8b97..9a4708ab 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -563,43 +563,42 @@ void ZC_mapredraw(map_view_t *mv, int tx, int ty) void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) { - word rx, ry; + word rx; + word ry; //word textx=0, texty=0; //if(i==0) i=2; - switch(i) + if(i==0) { - case 0: //wwww - modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color! - break; - case 1: - rx = (((i-1) % ((t->tileset.data->width)/t->tileWidth)) * t->tileWidth); - ry = (((i-1) / ((t->tileset.data->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); + modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color! + } + else + { + rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth); + ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight); ////0000printf("i=%d\n", i); -#ifndef TILERENDER - if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1); -#else - //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i); - /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ - //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); - //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); - //drawmap here -#endif #ifdef __DEBUG_MAP__ switch(dbg_maptext) { case 0: - +#endif +#ifndef TILERENDER + if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1); +#else + modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i); + /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ + //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); +#endif +#ifdef __DEBUG_MAP__ break; case 1: + if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i); sprintf(global_temp_status_text2, "%d", i); - modexprint(page, x+8, y+8, 1, 1, 2, global_temp_status_text2); + modexprint(page, x, y, 1, 1, 2, global_temp_status_text2); break; } #endif - break; } } diff --git a/src/maptest.c b/src/maptest.c index 696f9b73..f426b2c6 100755 --- a/src/maptest.c +++ b/src/maptest.c @@ -31,7 +31,7 @@ main(int argc, char *argv[]) map_t map; #ifdef DUMP #ifdef DUMP_MAP - short i,k; + short i; #endif #endif char *fmt = "Memory available = %u\n"; @@ -58,19 +58,15 @@ main(int argc, char *argv[]) fprintf(stdout, "map.height= %d\n", map.height); #ifdef DUMP_MAP //if(map.width*map.height != 1200) - for(k=0;k