From: sparky4 Date: Thu, 15 Jun 2017 23:27:18 +0000 (-0500) Subject: 16_ca needs huge amounts of work and I should remember what needs to be done soon... X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=ccbcf911d8e66a85004d95856b717038666fb77d;p=16.git 16_ca needs huge amounts of work and I should remember what needs to be done soon[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] added 1st scroll back [i work on CA] palette debug show values added wwww and i need to know how to see vrs/vrl imaage data palette index numbers [i am trying to find out how the hell you get the index number values of VRL/VRS] [CA_CacheMap added seems to be used in start a new game] what is mapsegs? bcexmm reports normally again... it acts funny with a unsigned long being assigned coreleft()'s value[vrldbg.exe added for a dirivative of vrldbg thanks johncampbell321\!] --- diff --git a/makefile b/makefile index 75c1241f..e8313efe 100755 --- a/makefile +++ b/makefile @@ -210,7 +210,8 @@ TESTEXEC = & tesuto.exe & 0tesuto.exe & maptest.exe & - imfplay.exe + imfplay.exe & + vrldbg.exe #zcroll.exe & TESTEXEC2 = & pcxtest.exe & @@ -232,7 +233,8 @@ SPRIUTILEXEC = & pcx2vrl & pcxsscut & vrl2vrs & - vrsdump + vrsdump & + vrldbg #UTILEXEC += $(SPRIUTILEXEC) !endif @@ -285,6 +287,7 @@ inputest.exe: inputest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib #inntest.exe: inntest.$(OBJ) $(16LIBNOINOBJS) 16_in_1.$(OBJ) $(DOSLIB) gfx.lib sountest.exe: sountest.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib imfplay.exe: imfplay.$(OBJ) $(16LIB) $(DOSLIB) gfx.lib +vrldbg.exe: vrldbg.$(OBJ) #gfx.lib $(DOSLIB) pcxtest.exe: pcxtest.$(OBJ) gfx.lib $(DOSLIB) $(16LIB) vrstest.exe: vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) #vgacamm.exe: vgacamm.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) @@ -332,6 +335,7 @@ inputest.$(OBJ):$(SRC)/inputest.c #inntest.$(OBJ):$(SRC)/inntest.c sountest.$(OBJ): $(SRC)/sountest.c imfplay.$(OBJ): $(SRC)/imfplay.c +vrldbg.$(OBJ): $(SRC)/vrldbg.c #miditest.$(OBJ): $(SRC)/miditest.c #testemm.$(OBJ):$(SRC)/testemm.c #testemm0.$(OBJ): $(SRC)/testemm0.c diff --git a/src/lib/doslib b/src/lib/doslib index 2849e7c5..970fddf7 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit 2849e7c5cd4c6647f57445b5f9cfa48c403077e6 +Subproject commit 970fddf745e08149bf4625052c4ea1e6dc42909e diff --git a/src/vrldbg.c b/src/vrldbg.c new file mode 100755 index 00000000..e6a409fc --- /dev/null +++ b/src/vrldbg.c @@ -0,0 +1,169 @@ +/* VRL run-length debugging tool. + * + * For sparky4 / Project 16 and anyone else needing to debug the VRL structure */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/lib/doslib/hw/vga/vrl.h" +#include "src/lib/doslib/hw/vga/vrs.h" +#include "src/lib/doslib/hw/vga/pcxfmt.h" +#include "src/lib/doslib/hw/vga/comshtps.h" + +#ifndef O_BINARY +#define O_BINARY (0) +#endif + +static void help() { + fprintf(stderr,"VRLDBG (C) 2016 Jonathan Campbell\n"); + fprintf(stderr,"\n"); + fprintf(stderr,"vrldbg file\n"); +} + +int main(int argc,char **argv) { + unsigned char *base,*raw,*fence; + struct vrl1_vgax_header *hdr; + unsigned int x,y,cc; + size_t rawlen; + long l; + int fd; + + if (argc < 2) { + help(); + return 1; + } + + fd = open(argv[1],O_RDONLY|O_BINARY); + if (fd < 0) return 1; + l = (long)lseek(fd,0,SEEK_END); + if (l < 16 || l > VRL_MAX_SIZE) return 1; + rawlen = (size_t)l; + + base = raw = malloc(rawlen); + if (raw == NULL) return 1; + if (lseek(fd,0,SEEK_SET) != 0) return 1; + if (read(fd,raw,rawlen) != rawlen) return 1; + close(fd); + fence = raw + rawlen; + + hdr = (struct vrl1_vgax_header*)raw; + if (memcmp(hdr->vrl_sig,"VRL1",4)) return 1; + if (memcmp(hdr->fmt_sig,"VGAX",4)) return 1; + +#if 0 +#pragma pack(push,1) +struct vrl1_vgax_header { + uint8_t vrl_sig[4]; // +0x00 "VRL1" + uint8_t fmt_sig[4]; // +0x04 "VGAX" + uint16_t height; // +0x08 Sprite height + uint16_t width; // +0x0A Sprite width + int16_t hotspot_x; // +0x0C Hotspot offset (X) for programmer's reference + int16_t hotspot_y; // +0x0E Hotspot offset (Y) for programmer's reference +}; // =0x10 +#pragma pack(pop) +#endif + printf("VRL header:\n"); + printf(" vrl_sig: \"VRL1\"\n"); // already validated + printf(" fmt_sig: \"VGAX\"\n"); // already validated + printf(" height: %u pixels\n",hdr->height); + printf(" width: %u pixels\n",hdr->width); + printf(" hotspot_x: %d pixels\n",hdr->hotspot_x); + printf(" hotspot_y: %d pixels\n",hdr->hotspot_y); + + /* strips are encoded in column order, top to bottom. + * each column ends with a special code, which is a cue to begin the next column and decode more. + * each strip has a length and a skip count. the skip count is there to allow for sprite + * transparency by skipping pixels. + * + * the organization of this format is optimized for display on VGA hardware in "mode x" + * unchained 256-color mode (where the planar memory organization of the VGA is exposed) */ + raw = base + sizeof(*hdr); + for (x=0;x < hdr->width;x++) {/* for each column */ + printf("Begin column x=%u\n",x); + y=0; + + if (raw >= fence) { + printf("* unexpected end of data\n"); + break; + } + + /* each column is a series of vertical strips with a two byte header, until + * the first occurrence where the first byte is 0xFF. */ + do { + if (raw >= fence) { + printf("* unexpected end of data in column x=%u at y=%u\n",x,y); + break; + } + + if (*raw == 0xFF) {/* end of column */ + raw++; + break; + } + + if (*raw >= 0x80) { /* single-color run */ + if ((raw+3) > fence) { + printf("* unexpected end of data in column x=%u at y=%u with %u byte(s) left\n",x,y,(unsigned int)(fence-raw)); + break; + } + + { + /* */ + unsigned char strip_len = (*raw++) - 0x80; + unsigned char skip_len = (*raw++); + unsigned char color = (*raw++); + + printf(" y=%u. after skip, y=%u. single-color strip length=%u + skip=%u with color=0x%02x\n", + y,y+skip_len,strip_len,skip_len,color); + + y += strip_len + skip_len; + } + } + else { /* copy strip */ + if ((raw+2) > fence) { + printf("* unexpected end of data in column x=%u at y=%u with %u byte(s) left\n",x,y,(unsigned int)(fence-raw)); + break; + } + + { + /* [strip of pixels] */ + unsigned char strip_len = (*raw++); + unsigned char skip_len = (*raw++); + + printf(" y=%u. after skip, y=%u. strip length=%u + skip=%u\n", + y,y+skip_len,strip_len,skip_len); + + if ((raw+strip_len) > fence) { + printf("* unexpected end of data in strip x=%u at y=%u with %u byte(s) left\n",x,y,(unsigned int)(fence-raw)); + break; + } + + if (strip_len != 0) { + printf(" pixels: "); + for (cc=0;cc < strip_len;cc++) printf("0x%02x ",raw[cc]); + printf("\n"); + } + + y += strip_len + skip_len; + raw += strip_len; + } + } + } while(1); + + if (y > hdr->height) + printf("* warning: y coordinate y=%u overruns height of VRL height=%u\n",(unsigned int)y,(unsigned int)hdr->height); + } + + if (raw < fence) { + printf("* warning: %u bytes remain after decoding\n",(unsigned int)(fence-raw)); + } + + free(base); + return 0; +} diff --git a/vrldbg b/vrldbg new file mode 100755 index 00000000..770288d0 Binary files /dev/null and b/vrldbg differ