From 5b6e4fff08f6adb8700ca2b76679bb36974a7316 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Wed, 21 May 2014 15:12:40 -0500 Subject: [PATCH] modified: 16/DOS_GFX.OBJ modified: 16/dos_gfx.cpp deleted: 16/error new file: 16/error.txt modified: 16/lib/x/MAKEFILE modified: 16/lib/x/MODEX.OBJ new file: 16/lib/x/modex.BAK new file: 16/lib/x/modex.lib new file: 16/q.bat new file: 16/readme.txt modified: 16/x.bat new file: 16/xx.bat --- 16/DOS_GFX.OBJ | Bin 8277 -> 8305 bytes 16/dos_gfx.cpp | 965 +++++++++++++++++++++++---------------------- 16/error | 1 - 16/error.txt | 3 + 16/lib/x/MAKEFILE | 2 +- 16/lib/x/MODEX.OBJ | Bin 31 -> 31 bytes 16/lib/x/modex.BAK | Bin 0 -> 3072 bytes 16/lib/x/modex.lib | Bin 0 -> 3072 bytes 16/q.bat | 5 + 16/readme.txt | 8 + 16/x.bat | 4 +- 16/xx.bat | 6 + 12 files changed, 508 insertions(+), 486 deletions(-) delete mode 100644 16/error create mode 100644 16/error.txt create mode 100644 16/lib/x/modex.BAK create mode 100644 16/lib/x/modex.lib create mode 100644 16/q.bat create mode 100644 16/readme.txt create mode 100644 16/xx.bat diff --git a/16/DOS_GFX.OBJ b/16/DOS_GFX.OBJ index fcb1a7ed572ef0bf8307aa48fc13a700efcd5b7b..dd4ed8e32bf240aa5ec9841d2fcf10878baf6d13 100644 GIT binary patch delta 3390 zcmZWr30zfW7XQ9;?(*(?4`dTi5Dgc^ofO=~QYmvoz)wT?y<`!dqNwl?mwYNulL1S+ zmgbOYj+RzaE-9Ls<~1#^Yngjv%cw{?W{Zs(%(;*1*UY>hhjZ@#`|i2lS-x}5*}>lp zUXc*9G3VW(kwf}rWo9KLS${?DoUHP!X~lW@<=qOmt{n4N^fS5d4h{d)j=bU$SHa}+ zZn-mNEL*ufQCZ+rfp1!Q>wu!OWU*Tuy~_?R{1W$a_UTu(hjA^V-<6ti%;W+Ln+P<6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>H8H}*kV1oAzX1HkZfbR{SU{JguO7Ve-iZ48@_(7`TZ-;ax5Hgh@ zn4<(kw$cxBlyE3i`h!)8fKp`ulq&Mk%Bm{PCEx1LB&U(|)y&p=_uX0H zj&xUFRt<26Ja@soC!TC`hN?S5Viw{3_7%7EXXGcn=q&fKXFDm;m$*Nw^ou+Itr^Or@iI3$#`9=LHBvo~ z!M8yIz6+S+AWy`X+o+C)C}Pe|F2tVUZbeqTM-*0M71^rrJEn$+*lTRLq;g+^`n0MGn_JM`gL1(9AbZqgOJcXuWcQ+PKUxrJG}T9d=HIsMDRdIG*8rq zVZR=MPK@W4kH?@x$D=%v$KO#Gga_KKBJs{nE-1C>9j>6VSnpu2KCGg&Vo}wv##y~2 z-P!^jTdG@YO_PWTTdS?meU_S4(*K?uo05W)+Jz4_b}(h2S!l zzP~piRLfCV*Uz}&3}hf v^SAJrr@0f-%{Sl)^G&dtBh}^o?|3v2g^)%0B&yIzveh*at7xez4S41ki$593 diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index 2a4170a2..631e72c6 100644 --- a/16/dos_gfx.cpp +++ b/16/dos_gfx.cpp @@ -6,20 +6,20 @@ * * Simple graphics library to accompany the article * - * INTRODUCTION TO MODE X. + * INTRODUCTION TO MODE X. * * This library provides the basic functions for initializing and using * unchained (planar) 256-color VGA modes. Currently supported are: * - * - 320x200 - * - 320x240 + * - 320x200 + * - 320x240 * * Functions are provided for: * - * - initializing one of the available modes - * - setting the start address of the VGA refresh data - * - setting active and visible display pages - * - writing and reading a single pixel to/from video memory + * - initializing one of the available modes + * - setting the start address of the VGA refresh data + * - setting active and visible display pages + * - writing and reading a single pixel to/from video memory * * The library is provided as a demonstration only, and is not claimed * to be particularly efficient or suited for any purpose. It has only @@ -76,10 +76,10 @@ byte coor; /* * Define the port addresses of some VGA registers. */ -#define CRTC_ADDR 0x3d4 /* Base port of the CRT Controller (color) */ +#define CRTC_ADDR 0x3d4 /* Base port of the CRT Controller (color) */ -#define SEQU_ADDR 0x3c4 /* Base port of the Sequencer */ -#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */ +#define SEQU_ADDR 0x3c4 /* Base port of the Sequencer */ +#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */ #define STATUS_ADDR 0x3DA unsigned char *RowsX[600]; @@ -112,48 +112,48 @@ unsigned actStart, visStart; /* * set320x200x256_X() - * sets mode 13h, then turns it into an unchained (planar), 4-page - * 320x200x256 mode. + * sets mode 13h, then turns it into an unchained (planar), 4-page + * 320x200x256 mode. */ void set320x200x256_X(void) - { - union REGS r; + { + union REGS r; - /* Set VGA BIOS mode 13h: */ - r.x.ax = 0x0013; - int86(0x10, &r, &r); + /* Set VGA BIOS mode 13h: */ + r.x.ax = 0x0013; + int86(0x10, &r, &r); - /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */ - outpw(SEQU_ADDR, 0x0604); + /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */ + outpw(SEQU_ADDR, 0x0604); - /* Turn off word mode, by setting the Mode Control register - of the CRT Controller (index 0x17, port 0x3d4): */ - outpw(CRTC_ADDR, 0xE317); + /* Turn off word mode, by setting the Mode Control register + of the CRT Controller (index 0x17, port 0x3d4): */ + outpw(CRTC_ADDR, 0xE317); - /* Turn off doubleword mode, by setting the Underline Location - register (index 0x14, port 0x3d4): */ - outpw(CRTC_ADDR, 0x0014); + /* Turn off doubleword mode, by setting the Underline Location + register (index 0x14, port 0x3d4): */ + outpw(CRTC_ADDR, 0x0014); - /* Clear entire video memory, by selecting all four planes, then - writing 0 to entire segment. */ - outpw(SEQU_ADDR, 0x0F02); - memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */ - vga[0] = 0; + /* Clear entire video memory, by selecting all four planes, then + writing 0 to entire segment. */ + outpw(SEQU_ADDR, 0x0F02); + memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */ + vga[0] = 0; - /* Update the global variables to reflect dimensions of this - mode. This is needed by most future drawing operations. */ - width = 320; - height = 200; + /* Update the global variables to reflect dimensions of this + mode. This is needed by most future drawing operations. */ + width = 320; + height = 200; - /* Each byte addresses four pixels, so the width of a scan line - in *bytes* is one fourth of the number of pixels on a line. */ - widthBytes = width / 4; + /* Each byte addresses four pixels, so the width of a scan line + in *bytes* is one fourth of the number of pixels on a line. */ + widthBytes = width / 4; - /* By default we want screen refreshing and drawing operations - to be based at offset 0 in the video segment. */ - actStart = visStart = 0; + /* By default we want screen refreshing and drawing operations + to be based at offset 0 in the video segment. */ + actStart = visStart = 0; - /* + /* -------------------- HORIZONTAL SCROLLING -------------------- @@ -191,17 +191,16 @@ OUT value TO PORT 3C0H (where "value" is the ----------------------------------------------- */ -//mxSetVirtualScreen(480,360); - } + } /* * setActiveStart() tells our graphics operations which address in video * memory should be considered the top left corner. */ void setActiveStart(unsigned offset) - { - actStart = offset; - } + { + actStart = offset; + } /* * setVisibleStart() tells the VGA from which byte to fetch the first @@ -212,13 +211,13 @@ void setActiveStart(unsigned offset) * set, but before the low byte is set, which produces a bad flicker. */ void setVisibleStart(unsigned offset) - { - visStart = offset; - outpw(CRTC_ADDR, 0x0C); /* set high byte */ - outpw(CRTC_ADDR+1, visStart >> 8); - outpw(CRTC_ADDR, 0x0D); /* set low byte */ - outpw(CRTC_ADDR+1, visStart & 0xff); - } + { + visStart = offset; + outpw(CRTC_ADDR, 0x0C); /* set high byte */ + outpw(CRTC_ADDR+1, visStart >> 8); + outpw(CRTC_ADDR, 0x0D); /* set low byte */ + outpw(CRTC_ADDR+1, visStart & 0xff); + } /* * setXXXPage() sets the specified page by multiplying the page number @@ -227,68 +226,70 @@ void setVisibleStart(unsigned offset) * function. The first page is number 0. */ void setActivePage(int page) - { - setActiveStart(page * widthBytes * height); - } + { + setActiveStart(page * widthBytes * height); + } void setVisiblePage(int page) - { - setVisibleStart(page * widthBytes * height); - } + { + setVisibleStart(page * widthBytes * height); + } void putPixel_X(int x, int y, byte color) - { - /* Each address accesses four neighboring pixels, so set - Write Plane Enable according to which pixel we want - to modify. The plane is determined by the two least - significant bits of the x-coordinate: */ - outp(0x3c4, 0x02); - outp(0x3c5, 0x01 << (x & 3)); - - /* The offset of the pixel into the video segment is - offset = (width * y + x) / 4, and write the given - color to the plane we selected above. Heed the active - page start selection. */ - vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color; - - } + { + /* Each address accesses four neighboring pixels, so set + Write Plane Enable according to which pixel we want + to modify. The plane is determined by the two least + significant bits of the x-coordinate: */ + outp(0x3c4, 0x02); + outp(0x3c5, 0x01 << (x & 3)); + + /* The offset of the pixel into the video segment is + offset = (width * y + x) / 4, and write the given + color to the plane we selected above. Heed the active + page start selection. */ + vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color; + + } byte getPixel_X(int x, int y) - { - /* Select the plane from which we must read the pixel color: */ - outpw(GRAC_ADDR, 0x04); - outpw(GRAC_ADDR+1, x & 3); + { + /* Select the plane from which we must read the pixel color: */ + outpw(GRAC_ADDR, 0x04); + outpw(GRAC_ADDR+1, x & 3); - return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart]; + return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart]; - } + } void set320x240x256_X(void) - { - /* Set the unchained version of mode 13h: */ - set320x200x256_X(); - - /* Modify the vertical sync polarity bits in the Misc. Output - Register to achieve square aspect ratio: */ - outp(0x3C2, 0xE3); - - /* Modify the vertical timing registers to reflect the increased - vertical resolution, and to center the image as good as - possible: */ - outpw(0x3D4, 0x2C11); /* turn off write protect */ - outpw(0x3D4, 0x0D06); /* vertical total */ - outpw(0x3D4, 0x3E07); /* overflow register */ - outpw(0x3D4, 0xEA10); /* vertical retrace start */ - outpw(0x3D4, 0xAC11); /* vertical retrace end AND wr.prot */ - outpw(0x3D4, 0xDF12); /* vertical display enable end */ - outpw(0x3D4, 0xE715); /* start vertical blanking */ - outpw(0x3D4, 0x0616); /* end vertical blanking */ - - /* Update mode info, so future operations are aware of the - resolution */ - height = 240; - - } + { + /* Set the unchained version of mode 13h: */ + set320x200x256_X(); + + /* Modify the vertical sync polarity bits in the Misc. Output + Register to achieve square aspect ratio: */ + outp(0x3C2, 0xE3); + + /* Modify the vertical timing registers to reflect the increased + vertical resolution, and to center the image as good as + possible: */ + outpw(0x3D4, 0x2C11); /* turn off write protect */ + outpw(0x3D4, 0x0D06); /* vertical total */ + outpw(0x3D4, 0x3E07); /* overflow register */ + outpw(0x3D4, 0xEA10); /* vertical retrace start */ + outpw(0x3D4, 0xAC11); /* vertical retrace end AND wr.prot */ + outpw(0x3D4, 0xDF12); /* vertical display enable end */ + outpw(0x3D4, 0xE715); /* start vertical blanking */ + outpw(0x3D4, 0x0616); /* end vertical blanking */ + + /* Update mode info, so future operations are aware of the + resolution */ + height = 240; + +*$pragma aux mxSetVirtualScreen "MXSETVIRTUALSCREEN" +mxSetVirtualScreen(480,360); + } /*-----------XXXX-------------*/ @@ -313,8 +314,8 @@ void wait_for_retrace(void) /* void MoveTo (word X, word Y) { -// word O = Y*SIZE*2+X; - word O = Y*widthBytes*2+X; +// word O = Y*SIZE*2+X; + word O = Y*widthBytes*2+X; asm { mov bx, [O] @@ -414,8 +415,8 @@ void Play() // ch=0x0; // xpos=rand (78)+1; // ypos=rand (198)+1; // { Random start positions for the view } - xpos=0; - ypos=0; + xpos=0; + ypos=0; xdir=1; ydir=1; // while(1) @@ -428,59 +429,59 @@ void Play() if( (ypos>199) || (ypos<1))ydir=-ydir; // { Hit a boundry, change // direction! } // if(_bios_keybrd(_KEYBRD_READY))ch=getch(); -// if(ch==0x71)break; // 'q' -// if(ch==0x1b)break; // 'ESC' +// if(ch==0x71)break; // 'q' +// if(ch==0x1b)break; // 'ESC' // } } */ /*tile*/ //king_crimson's code void putColorBox_X(int x, int y, int w, int h, byte color) { - outp(0x3c4, 0x02); - - int curx, cury; - unsigned drawptr; - for (curx=x; curx<(x+w); curx++) { - outp(0x3c5, 0x01 << (curx & 3)); - drawptr = (unsigned)(widthBytes * y) + (curx / 4) + actStart; - for (cury=0; cury0) - boingy=1; - - for(int ti=0;ti0) + boingy=1; + + for(int ti=0;ti> 2); - outp(0x3D4, Cols); - //setVisibleStart(visStart + (Cols * height)); - setVisibleStart(visStart + (Cols * width)); + wait_for_retrace(); + outp(0x3C0, 0x13); + outp(0x3C0, Cols & 3); + outp(0x3D4, 0x13); + outp(0x3D5, Cols >> 2); + outp(0x3D4, Cols); + //setVisibleStart(visStart + (Cols * height)); + setVisibleStart(visStart + (Cols * width)); } /*To implement smooth horizontal scrolling, you would do the following: @@ -580,297 +581,297 @@ I'm sorry about this being so confusing but it's a bit difficult to explain. */ int loadfontX(char *fname) { - FILE *fp; + FILE *fp; - fp = fopen(fname, "rb"); + fp = fopen(fname, "rb"); - if (fp == NULL) { - return 0; - } else { - fread(Xfont, 8, 256, fp); - fclose(fp); - return 1; - } + if (fp == NULL) { + return 0; + } else { + fread(Xfont, 8, 256, fp); + fclose(fp); + return 1; + } } void putchX(cord x, cord y, char c, byte color) { - int i; - byte *vga_ptr; - byte *font_ptr; - byte temp; - - // 8x8 font - vga_ptr = RowsX[y << 3] + (x << 1) + actStart; - write_plane = -1; - - font_ptr = Xfont + (c << 3); - - i=8; - while (i--) { - temp = *font_ptr++; - outpw(SEQU_ADDR, text_mask[temp & 0x0F]); - *vga_ptr++ = color; - - outpw(SEQU_ADDR, text_mask[temp >> 4]); - *vga_ptr-- = color; - vga_ptr += widthBytes; - } + int i; + byte *vga_ptr; + byte *font_ptr; + byte temp; + + // 8x8 font + vga_ptr = RowsX[y << 3] + (x << 1) + actStart; + write_plane = -1; + + font_ptr = Xfont + (c << 3); + + i=8; + while (i--) { + temp = *font_ptr++; + outpw(SEQU_ADDR, text_mask[temp & 0x0F]); + *vga_ptr++ = color; + + outpw(SEQU_ADDR, text_mask[temp >> 4]); + *vga_ptr-- = color; + vga_ptr += widthBytes; + } } void putstringX(cord x, cord y, char *str, byte color) { - int i, skip; - byte *vga_ptr; - byte *font_ptr; - byte c, temp; + int i, skip; + byte *vga_ptr; + byte *font_ptr; + byte c, temp; - // 8x8 font - vga_ptr = RowsX[y << 3] + (x << 1) + actStart; - write_plane = -1; + // 8x8 font + vga_ptr = RowsX[y << 3] + (x << 1) + actStart; + write_plane = -1; - skip = 2 - (widthBytes << 3); + skip = 2 - (widthBytes << 3); - while (c = *str++) { - font_ptr = Xfont + (c << 3); + while (c = *str++) { + font_ptr = Xfont + (c << 3); - i=8; - while (i--) { - temp = *font_ptr++; - outpw(SEQU_ADDR, text_mask[temp & 0x0F]); - *vga_ptr++ = color; + i=8; + while (i--) { + temp = *font_ptr++; + outpw(SEQU_ADDR, text_mask[temp & 0x0F]); + *vga_ptr++ = color; - outpw(SEQU_ADDR, text_mask[temp >> 4]); - *vga_ptr-- = color; - vga_ptr += widthBytes; - } + outpw(SEQU_ADDR, text_mask[temp >> 4]); + *vga_ptr-- = color; + vga_ptr += widthBytes; + } - vga_ptr += skip; - } + vga_ptr += skip; + } } ///////////////////////////////////////////////////////////////////////////// // // -// setvideo() - This function Manages the video modes // +// setvideo() - This function Manages the video modes // // // ///////////////////////////////////////////////////////////////////////////// void setvideo(/*byte mode, */int vq){ - union REGS in, out; - - if(!vq){ // deinit the video - // change to the video mode we were in before we switched to mode 13h - in.h.ah = 0x00; - in.h.al = old_mode; - int86(0x10, &in, &out); - - }else if(vq == 1){ // init the video - // get old video mode - in.h.ah = 0xf; - int86(0x10, &in, &out); - old_mode = out.h.al; - - // enter mode - set320x240x256_X(); - } + union REGS in, out; + + if(!vq){ // deinit the video + // change to the video mode we were in before we switched to mode 13h + in.h.ah = 0x00; + in.h.al = old_mode; + int86(0x10, &in, &out); + + }else if(vq == 1){ // init the video + // get old video mode + in.h.ah = 0xf; + int86(0x10, &in, &out); + old_mode = out.h.al; + + // enter mode + set320x240x256_X(); + } } ///////////////////////////////////////////////////////////////////////////// -// // +// // // cls() - This clears the screen to the specified color, on the VGA or on // -// the Virtual screen. // -// // +// the Virtual screen. // +// // ///////////////////////////////////////////////////////////////////////////// void cls(byte color, byte *Where){ - _fmemset(Where, color, width*(height*17)); + _fmemset(Where, color, width*(height*17)); } //color ‚Ä‚·‚Æ int colortest(){ - if(gq < NUM_COLORS){ - cls(gq, vga); - gq++; - }else gq = 0; - return gq; + if(gq < NUM_COLORS){ + cls(gq, vga); + gq++; + }else gq = 0; + return gq; } //color ‚Ä‚·‚Æ int colorz(){ - if(gq < HGQ){ -//---- cls(gq, vaddr); - cls(gq, vga); - gq++; - }else gq = LGQ; - return gq; + if(gq < HGQ){ +//---- cls(gq, vaddr); + cls(gq, vga); + gq++; + }else gq = LGQ; + return gq; } //slow spectrum down void ssd(int svq){ - if(sy < height+1){ - if(sx < width+1){ - //plotpixel(xx, yy, coor, vga); - //ppf(sx, sy, coor, vga); - putPixel_X(sx, sy, coor); - //printf("%d %d %d %d\n", sx, sy, svq, coor); - sx++; - }else sx = 0; - if(sx == width){ - sy++; - if(svq == 7) coor++; - if(sy == height && svq == 8) coor = rand()%NUM_COLORS; - } - }else sy = 0; + if(sy < height+1){ + if(sx < width+1){ + //plotpixel(xx, yy, coor, vga); + //ppf(sx, sy, coor, vga); + putPixel_X(sx, sy, coor); + //printf("%d %d %d %d\n", sx, sy, svq, coor); + sx++; + }else sx = 0; + if(sx == width){ + sy++; + if(svq == 7) coor++; + if(sy == height && svq == 8) coor = rand()%NUM_COLORS; + } + }else sy = 0; } /*-----------ding-------------*/ int ding(int q){ -// if(yy0){ - yy++; - d3y--; - } - } - if(bakax<0){ - xx--; - }else - if(bakax>0){ - xx++; - } - }else{ - if(q==16) - { - if(!bakax){ - xx--;//=TILEWH; - }else if(bakax>0){ - xx++;//=TILEWH; - } - if(!bakay){ - yy--;//=TILEWH; - }else if(bakay>0){ - yy++;//=TILEWH; - } - }else{ - if(!bakax){ -// xx-=TILEWH; - xx--; - }else if(bakax>1){ -// xx+=TILEWH; - xx++; - } - if(!bakay){ -// yy-=TILEWH; - yy--; - }else if(bakay>1){ -// yy+=TILEWH; - yy++; - } - } - } - // fixer -// if(q!=16){ + if((q == 2 + ||q==4 + ||q==16 + ) && gq == BONK){ + if(coor < HGQ && coor < LGQ) coor = LGQ; + if(coor < HGQ-1){ + coor++; + }else{ coor = LGQ; + bakax = rand()%3; bakay = rand()%3; + } + } + + if(q==8){ colorz(); return gq; }else + if(q==10){ ssd(q); /*printf("%d\n", coor);*/ }else + if(q==5){ colortest(); return gq; }else + if(q==11){ colorz(); delay(100); return gq; } + if(q==6){ + coor = rand()%NUM_COLORS; +//---- cls(coor, vaddr); + cls(coor, vga); + //updatevbuff(); + } + + if(q==7||q==9){ + if(gq < HGQ){ + if(q == 7) ssd(q); + if(q == 9){ ssd(q); coor++; } + gq++; + }else gq = LGQ; + } + if((q<5 && gq0){ + yy++; + d3y--; + } + } + if(bakax<0){ + xx--; + }else + if(bakax>0){ + xx++; + } + }else{ + if(q==16) + { + if(!bakax){ + xx--;//=TILEWH; + }else if(bakax>0){ + xx++;//=TILEWH; + } + if(!bakay){ + yy--;//=TILEWH; + }else if(bakay>0){ + yy++;//=TILEWH; + } + }else{ + if(!bakax){ +// xx-=TILEWH; + xx--; + }else if(bakax>1){ +// xx+=TILEWH; + xx++; + } + if(!bakay){ +// yy-=TILEWH; + yy--; + }else if(bakay>1){ +// yy+=TILEWH; + yy++; + } + } + } + // fixer +// if(q!=16){ //if(q!=16) -// if(xx<(0/*-(TILEWH/2)*/)) xx=(width/*+(TILEWH)*/); - if(yy<0) yy=(height*3); -// if(xx>(width/*+(TILEWH)*/)) xx=(0/*-(TILEWH/2)*/); - if(yy>(height*3)) yy=0; -// } +// if(xx<(0/*-(TILEWH/2)*/)) xx=(width/*+(TILEWH)*/); + if(yy<0) yy=(height*3); +// if(xx>(width/*+(TILEWH)*/)) xx=(0/*-(TILEWH/2)*/); + if(yy>(height*3)) yy=0; +// } //interesting effects - if(q==16) - { - int tx=0,ty=0; - tx+=xx+16; - ty+=yy+16; - putPixel_X(tx, ty, coor); - //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor); - //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH); - - // plot the pixel -//---- ppf(xx, yy, coor, vga); - }else /*if(xx>=0 && xx=0 && yy<(height*3))*/{ -// putColorBox_X(xx, yy, TILEWH, TILEWH, coor); + if(q==16) + { + int tx=0,ty=0; + tx+=xx+16; + ty+=yy+16; + putPixel_X(tx, ty, coor); + //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor); + //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH); + + // plot the pixel +//---- ppf(xx, yy, coor, vga); + }else /*if(xx>=0 && xx=0 && yy<(height*3))*/{ +// putColorBox_X(xx, yy, TILEWH, TILEWH, coor); //++++0000 - putPixel_X(xx, yy, coor); - } + putPixel_X(xx, yy, coor); + } -//---- if(q==2) ppf(rand()%, rand()%height, 0, vga); -// if(q==2) putColorBox_X(rand()%width, rand()%(height*3), TILEWH, TILEWH, 0); +//---- if(q==2) ppf(rand()%, rand()%height, 0, vga); +// if(q==2) putColorBox_X(rand()%width, rand()%(height*3), TILEWH, TILEWH, 0); //++++0000 - if(q==2) putPixel_X(rand()%width, rand()%(height*3), 0); - if(q==16) putPixel_X(rand()%width, rand()%(height*3), 0); - if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; } - gq++; + if(q==2) putPixel_X(rand()%width, rand()%(height*3), 0); + if(q==16) putPixel_X(rand()%width, rand()%(height*3), 0); + if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; } + gq++; //if(xx<0||xx>320||yy<0||yy>(height*3)) -// printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy)); -// printf("%d\n", getPixel_X(xx,yy)); +// printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy)); +// printf("%d\n", getPixel_X(xx,yy)); //0000 -// drawText(0, 0, 15, getPixel_X(xx,yy)); - }else gq = LGQ; - return gq; +// drawText(0, 0, 15, getPixel_X(xx,yy)); + }else gq = LGQ; + return gq; } @@ -885,123 +886,123 @@ int ding(int q){ #include void doTest(void) - { - int p, x, y, pages; - - /* This is the way to calculate the number of pages available. */ - pages = 65536L/(widthBytes*height); // apparently this takes the A000 address -// if(height==240) pages++; - -// printf("%d\n", pages); - - for (p = 0; p <= pages; ++p) - { - setActivePage(p); - - /* On each page draw a single colored border, and dump the palette - onto a small square about the middle of the page. */ - - //{ - for (x = 0; x <= width; ++x) - { - putPixel_X(x, 0, p+1); - if(p!=pages) putPixel_X(x, height-1, p+1); - else if(height==240) putPixel_X(x, 99-1, p+1); - } - - for (y = 0; y <= height; ++y) - { - putPixel_X(0, y, p+1); - if(p!=pages) putPixel_X(width-1, y, p+1); - else if(height==240) putPixel_X(width-1, y, p+1); - } - - for (x = 0; x < TILEWH; ++x) - for (y = 0; y < TILEWH; ++y) - putPixel_X(x+(p+2)*16, y+(p+2)*TILEWH, x + y*TILEWH); - //} - - } - - /* Each pages will now contain a different image. Let the user cycle - through all the pages by pressing a key. */ - for (p = 0; p < pages; ++p) - { - setVisiblePage(p); - getch(); - } - - } + { + int p, x, y, pages; + + /* This is the way to calculate the number of pages available. */ + pages = 65536L/(widthBytes*height); // apparently this takes the A000 address +// if(height==240) pages++; + +// printf("%d\n", pages); + + for (p = 0; p <= pages; ++p) + { + setActivePage(p); + + /* On each page draw a single colored border, and dump the palette + onto a small square about the middle of the page. */ + + //{ + for (x = 0; x <= width; ++x) + { + putPixel_X(x, 0, p+1); + if(p!=pages) putPixel_X(x, height-1, p+1); + else if(height==240) putPixel_X(x, 99-1, p+1); + } + + for (y = 0; y <= height; ++y) + { + putPixel_X(0, y, p+1); + if(p!=pages) putPixel_X(width-1, y, p+1); + else if(height==240) putPixel_X(width-1, y, p+1); + } + + for (x = 0; x < TILEWH; ++x) + for (y = 0; y < TILEWH; ++y) + putPixel_X(x+(p+2)*16, y+(p+2)*TILEWH, x + y*TILEWH); + //} + + } + + /* Each pages will now contain a different image. Let the user cycle + through all the pages by pressing a key. */ + for (p = 0; p < pages; ++p) + { + setVisiblePage(p); + getch(); + } + + } /* * Library test (program) entry point. */ int main(void) - { - int key,d; - //short int temp; - // main variables - d=1; // switch variable - key=4; // default screensaver number -// puts("First, have a look at the 320x200 mode. I will draw some rubbish"); -// puts("on all of the four pages, then let you cycle through them by"); -// puts("hitting a key on each page."); -// puts("Press a key when ready..."); -// getch(); - -// doTest(); - -// puts("Then, check out Mode X, 320x240 with 3 (and a half) pages."); -// puts("Press a key when ready..."); -// getch(); + { + int key,d; + //short int temp; + // main variables + d=1; // switch variable + key=4; // default screensaver number +// puts("First, have a look at the 320x200 mode. I will draw some rubbish"); +// puts("on all of the four pages, then let you cycle through them by"); +// puts("hitting a key on each page."); +// puts("Press a key when ready..."); +// getch(); + +// doTest(); + +// puts("Then, check out Mode X, 320x240 with 3 (and a half) pages."); +// puts("Press a key when ready..."); +// getch(); //++++0000 - setvideo(1); - /*temp = loadfontX("vga8x8.fnt"); + setvideo(1); + /*temp = loadfontX("vga8x8.fnt"); - if (temp) { - putstringX(0, 0, "bakapi!", 2); - } - getch();*/ + if (temp) { + putstringX(0, 0, "bakapi!", 2); + } + getch();*/ // screen savers /*while(d!=0){ // on! - if(!kbhit()){ // conditions of screen saver - ding(key); - }else{ - setvideo(0); - // user imput switch - printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch()); // prompt the user - scanf("%d", &key); - //if(key==3){xx=yy=0;} // crazy screen saver wwww - if(key==5) d=0; - setvideo(1); - } - }*/ // else off - while(!kbhit()){ // conditions of screen saver - ding(4); - } - //end of screen savers - doTest(); -// getch(); - - while(!kbhit()){ // conditions of screen saver -// hScroll(1); -// scrolly(1); - vScroll(1); -// delay(100); -// Play(); - } + if(!kbhit()){ // conditions of screen saver + ding(key); + }else{ + setvideo(0); + // user imput switch + printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch()); // prompt the user + scanf("%d", &key); + //if(key==3){xx=yy=0;} // crazy screen saver wwww + if(key==5) d=0; + setvideo(1); + } + }*/ // else off + while(!kbhit()){ // conditions of screen saver + ding(4); + } + //end of screen savers + doTest(); +// getch(); + + while(!kbhit()){ // conditions of screen saver +// hScroll(1); +// scrolly(1); + vScroll(1); +// delay(100); +// Play(); + } //++++0000 - setvideo(0); - printf("wwww\n[%d][%d]\n", width,height); -// setvideo(0); + setvideo(0); + printf("wwww\n[%d][%d]\n", width,height); +// setvideo(0); //mxTerm(); //mxGetVersion(); - puts("where to next? It's your move! wwww"); - printf("bakapi ver. 1.04.09.03\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); - return 0; - } + puts("where to next? It's your move! wwww"); + printf("bakapi ver. 1.04.09.03\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); + return 0; + } #endif diff --git a/16/error b/16/error deleted file mode 100644 index 589f3249..00000000 --- a/16/error +++ /dev/null @@ -1 +0,0 @@ -file dos_gfx.obj(C:\Z\16\16\dos_gfx.cpp): undefined symbol diff --git a/16/error.txt b/16/error.txt new file mode 100644 index 00000000..a4f9aca1 --- /dev/null +++ b/16/error.txt @@ -0,0 +1,3 @@ +Error! E2028: MXSETVIRTUALSCREEN is an undefined reference +creating a DOS executable +file dos_gfx.obj(C:\Z\16\16\dos_gfx.cpp): undefined symbol MXSETVIRTUALSCREEN \ No newline at end of file diff --git a/16/lib/x/MAKEFILE b/16/lib/x/MAKEFILE index 19175b7a..a84d9a4b 100644 --- a/16/lib/x/MAKEFILE +++ b/16/lib/x/MAKEFILE @@ -27,7 +27,7 @@ LIBOBJS = MXBB.OBJ \ MXPI.OBJ \ MXPN.OBJ \ MXPP.OBJ \ - MXPT.OBJ \ + MXPT.OBJ \ MXRA.OBJ \ MXRP.OBJ \ MXSA.OBJ \ diff --git a/16/lib/x/MODEX.OBJ b/16/lib/x/MODEX.OBJ index 7b72fdba8b4d249dbe38efb07ea6a051cbb62dc7..91289955c58314f116d178524cfc372cec7f7830 100644 GIT binary patch literal 31 lcmZqRX5jSocX5r-a}4%wUYA)|wZfngEj#V#Pb1OR_U2mt^9 diff --git a/16/lib/x/modex.BAK b/16/lib/x/modex.BAK new file mode 100644 index 0000000000000000000000000000000000000000..0069d2e6cabd41c7fdba764cdfe2a5f913c339f1 GIT binary patch literal 3072 zcmeH}&1w`u6opSTF)fmOGv3$l>wQo-KLH#3LBsZ+P;`Y{HK0N3E3ccU2T9JSk9E!}y1 zVgC6xXusmKQM|Yq1ilV@|6us_6@3(0{Z6HiB1xZE{llP7BzwP+?3a?xi{kmAkVl#y#r-S`wcs!HQ}X*Iy;=Xx&rh|(`dggfJtE-C_SxkzP8%uCdriFA1J?0z*W3Yy>>YpxcnOB1j7D+Y ze6yU>7|gxEa@?i~40%>m!wtuYq6S7i_h|*U93Nz~j@ypYf;M3;Bi1L&sEIqCyR?OI z$Gw8KG2vLXX$O;@W7@@C&s}XQ_|I?4zc%X4?*R)$p(F2;NhU+Id#I}JwoY{SjXb^S+EGIO~ zS4P80MAH~{zb7fx?QPO(k`684rel@R6VyDXw1+9jd5coaI@T@fVa{_zIp#g5bchAd e9XiI6XH6$qcHGx=iWSFYht9BO`2X`K4g3NWB*Iz% literal 0 HcmV?d00001 diff --git a/16/lib/x/modex.lib b/16/lib/x/modex.lib new file mode 100644 index 0000000000000000000000000000000000000000..0069d2e6cabd41c7fdba764cdfe2a5f913c339f1 GIT binary patch literal 3072 zcmeH}&1w`u6opSTF)fmOGv3$l>wQo-KLH#3LBsZ+P;`Y{HK0N3E3ccU2T9JSk9E!}y1 zVgC6xXusmKQM|Yq1ilV@|6us_6@3(0{Z6HiB1xZE{llP7BzwP+?3a?xi{kmAkVl#y#r-S`wcs!HQ}X*Iy;=Xx&rh|(`dggfJtE-C_SxkzP8%uCdriFA1J?0z*W3Yy>>YpxcnOB1j7D+Y ze6yU>7|gxEa@?i~40%>m!wtuYq6S7i_h|*U93Nz~j@ypYf;M3;Bi1L&sEIqCyR?OI z$Gw8KG2vLXX$O;@W7@@C&s}XQ_|I?4zc%X4?*R)$p(F2;NhU+Id#I}JwoY{SjXb^S+EGIO~ zS4P80MAH~{zb7fx?QPO(k`684rel@R6VyDXw1+9jd5coaI@T@fVa{_zIp#g5bchAd e9XiI6XH6$qcHGx=iWSFYht9BO`2X`K4g3NWB*Iz% literal 0 HcmV?d00001 diff --git a/16/q.bat b/16/q.bat new file mode 100644 index 00000000..5d1b5845 --- /dev/null +++ b/16/q.bat @@ -0,0 +1,5 @@ +call hres +vi dos_gfx.cpp +call x +pause +dos_gfx.exe diff --git a/16/readme.txt b/16/readme.txt new file mode 100644 index 00000000..306e8b9a --- /dev/null +++ b/16/readme.txt @@ -0,0 +1,8 @@ +ModeX - A graphical library for DOS programs +Copyright (c) 1993-1994 Alessandro Scotti +http://www.ascotti.org/ + +Please look at the above site in the "Art of..." and +then in the "Old programs" section for more information. + + diff --git a/16/x.bat b/16/x.bat index a6310e93..ccfde166 100644 --- a/16/x.bat +++ b/16/x.bat @@ -1,3 +1,3 @@ wpp /d1 /0 /ml dos_gfx -wlink file dos_gfx,lib\x\*.obj name dos_gfx -copy /y dos_gfx.exe c:\z\bakapi.exe +wlink file dos_gfx,lib\x\*.obj LIBP lib\x LIBFILE modex name dos_gfx +copy /y dos_gfx.exe c:\z\bakapi.exe diff --git a/16/xx.bat b/16/xx.bat new file mode 100644 index 00000000..b828bf1b --- /dev/null +++ b/16/xx.bat @@ -0,0 +1,6 @@ +cd lib\x +call compile +call make +cd .. +cd .. +call x \ No newline at end of file -- 2.39.5