From: sparky4 Date: Thu, 22 May 2014 16:50:45 +0000 (-0500) Subject: modified: 16/DOS_GFX.OBJ X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=118896f74475eb26539f1b32923d58f24f0f162f;p=16.git modified: 16/DOS_GFX.OBJ modified: 16/Project 16.bfproject modified: 16/dos_gfx.cpp modified: 16/lib/x/MODEX.BAK modified: 16/lib/x/MODEX.H --- diff --git a/16/DOS_GFX.OBJ b/16/DOS_GFX.OBJ index dd4ed8e3..d5b35927 100644 Binary files a/16/DOS_GFX.OBJ and b/16/DOS_GFX.OBJ differ diff --git a/16/Project 16.bfproject b/16/Project 16.bfproject index e04b651f..af88c95d 100644 --- a/16/Project 16.bfproject +++ b/16/Project 16.bfproject @@ -1,6 +1,6 @@ c2e.convert_special: 0 e2c.convert_num: 0 -openfiles: /dos/z/16/16/dos_gfx.cpp:11047:10691:1: +openfiles: /dos/z/16/16/dos_gfx.cpp:38508:37505:1: openfiles: /dos/z/16/16/dos_gfx.h:607:0:0: openfiles: /dos/z/16/16/dos_kb.c:892:395:0: openfiles: /dos/z/16/16/dos_kb.h:60:0:0: @@ -9,7 +9,6 @@ openfiles: /dos/z/16/16/lib/lib_com.h:2553:1575:0: openfiles: /dos/z/16/16/scroll.txt:5307:5103:0: openfiles: /dos/z/16/16/project16.txt:1675:950:0: openfiles: /dos/z/16/16/16.txt:0:0:0: -openfiles: /dos/z/16/16/lib/x/MODEX.DEF:1385:1054:0: snr_recursion_level: 0 convertcolumn_horizontally: 0 adv_open_matchname: 0 @@ -21,7 +20,7 @@ view_left_panel: 0 default_mime_type: text/plain e2c.convert_xml: 1 c2e.convert_iso: 0 -opendir: file:///dos/z/16/16 +opendir: file:///dos/z/16/16/lib/x wrap_text_default: 0 bookmarks_filename_mode: 1 ssearch_text: mxpan @@ -69,15 +68,15 @@ recent_files: file:///dos/z/16/16/w_modex/XPRIM.CPP recent_files: file:///dos/z/16/16/w_modex/MODEX.CPP recent_files: file:///dos/z/16/16/w_modex/TEST.CPP recent_files: file:///dos/z/16/16/x.bat +recent_files: file:///dos/z/16/16/lib/x/MODEX.DEF +recent_files: file:///dos/z/16/16/Project%2016.bfproject +recent_files: file:///dos/z/16/16/dos_gfx.cpp recent_files: file:///dos/z/16/16/dos_gfx.h -recent_files: file:///dos/z/16/16/dos_kb.c recent_files: file:///dos/z/16/16/lib/lib_com.h -recent_files: file:///dos/z/16/16/dos_kb.h recent_files: file:///dos/z/16/16/lib/lib_com.cpp -recent_files: file:///dos/z/16/16/dos_gfx.cpp -recent_files: file:///dos/z/16/16/lib/x/MODEX.DEF -recent_files: file:///dos/z/16/16/Project%2016.bfproject +recent_files: file:///dos/z/16/16/dos_kb.c recent_files: file:///dos/z/16/16/project16.txt +recent_files: file:///dos/z/16/16/dos_kb.h recent_files: file:///dos/z/16/16/16.txt recent_files: file:///dos/z/16/16/scroll.txt snr_replacetype: 0 @@ -97,7 +96,7 @@ searchlist: ding searchlist: font searchlist: wi searchlist: waiyt -searchlist: ENDP +searchlist: ENDP searchlist: mss searchlist: mxset searchlist: mspai diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index 1f238513..b3bd3155 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,18 +76,18 @@ 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]; unsigned char write_plane, read_plane; unsigned short text_mask[16] = { 0x0002, 0x0102, 0x0202, 0x0302, - 0x0402, 0x0502, 0x0602, 0x0702, - 0x0802, 0x0902, 0x0A02, 0x0B02, - 0x0C02, 0x0D02, 0x0E02, 0x0F02 }; + 0x0402, 0x0502, 0x0602, 0x0702, + 0x0802, 0x0902, 0x0A02, 0x0B02, + 0x0C02, 0x0D02, 0x0E02, 0x0F02 }; /* @@ -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,16 +191,16 @@ OUT value TO PORT 3C0H (where "value" is the ----------------------------------------------- */ - } + } /* * 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 @@ -211,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 @@ -226,78 +226,78 @@ 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); - } +//mxSetVirtualScreen(480,360); + } /*-----------XXXX-------------*/ ///////////////////////////////////////////////////////////////////////////// -// // -// WaitRetrace() - This waits until you are in a Verticle Retrace. // -// // +// // +// WaitRetrace() - This waits until you are in a Verticle Retrace. // +// // ///////////////////////////////////////////////////////////////////////////// void wait_for_retrace(void) { @@ -305,17 +305,17 @@ void wait_for_retrace(void) } ///////////////////////////////////////////////////////////////////////////// -// // -// MoveTo() - This moves to position X*4 on a chain 4 screen. // -// Note: As soon as I find documentation, this function // -// will be better documented. - Snowman // -// // +// // +// MoveTo() - This moves to position X*4 on a chain 4 screen. // +// Note: As soon as I find documentation, this function // +// will be better documented. - Snowman // +// // ///////////////////////////////////////////////////////////////////////////// /* 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] @@ -346,51 +346,51 @@ void MoveTo (word X, word Y) { "EXTRN mxWaitDisplay : FAR" \ "EXTRN mxStartAddress : FAR" \ -MX_TEXT SEGMENT USE16 PARA PUBLIC 'CODE' - ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING - -EXTRN mx_BytesPerLine : WORD - -;----------------------------------------------------------- -; -; Moves the screen. -; -; Input: -; X, Y = new X, Y coordinates of view screen -; Output: -; none -; -mxPan PROC FAR - ARG Y:WORD, \ - X:WORD = ARG_SIZE - ASSUME ds:NOTHING - .enter 0 - - mov ax, [Y] - mul [mx_BytesPerLine] - mov dx, [X] - shr dx, 1 - shr dx, 1 - add ax, dx - push ax ; Push the start address - call mxWaitDisplay - call mxStartAddress - - mov dx, 03DAh ; Set the pixel pan register - in al, dx - mov dx, 03C0h - mov al, 33h - out dx, al - mov al, BYTE PTR [X] - and al, 3 - shl al, 1 - out dx, al - - xor ax, ax - .leave ARG_SIZE -mxPan ENDP - -MX_TEXT ENDS +"MX_TEXT SEGMENT USE16 PARA PUBLIC 'CODE' + ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING" \ + +"EXTRN mx_BytesPerLine : WORD" \ + +//;----------------------------------------------------------- +//; +//; Moves the screen. +//; +//; Input: +//; X, Y = new X, Y coordinates of view screen +//; Output: +//; none +//; +mxPan PROC FAR + ARG Y:WORD, \ + X:WORD = ARG_SIZE + ASSUME ds:NOTHING + .enter 0 + + mov ax, [Y] + mul [mx_BytesPerLine] + mov dx, [X] + shr dx, 1 + shr dx, 1 + add ax, dx + push ax ; Push the start address + call mxWaitDisplay + call mxStartAddress + + mov dx, 03DAh ; Set the pixel pan register + in al, dx + mov dx, 03C0h + mov al, 33h + out dx, al + mov al, BYTE PTR [X] + and al, 3 + shl al, 1 + out dx, al + + xor ax, ax + .leave ARG_SIZE +mxPan ENDP + +MX_TEXT ENDS END @@ -409,14 +409,14 @@ void Play() // for(loop1=0;loop1<=3;loop1++) // for(loop2=0;loop2<=5;loop2++) -// Putpic (loop1*160,loop2*66); // { This places the picture all over the - // chain-4 screen } +// Putpic (loop1*160,loop2*66); // { This places the picture all over the + // chain-4 screen } // getch(); // 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) @@ -427,61 +427,61 @@ void Play() ypos=ypos+ydir; if( (xpos>79) || (xpos<1))xdir=-xdir; if( (ypos>199) || (ypos<1))ydir=-ydir; // { Hit a boundry, change - // direction! } + // 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: @@ -525,29 +525,29 @@ so we can draw off the edge of the screen. Perhaps a little diagram will clarify it. The following picture is of a standard X-mode addressing scheme with the OFFSET register set to 80. - ROW OFFSET - 0 0 ======================== - 1 80 [ ] - 2 160 [ ] - .. .. [ VISIBLE ] - [ SCREEN ] - [ ] - [ ] - .. .. [ ] - 199 15920 ======================== + ROW OFFSET + 0 0 ======================== + 1 80 [ ] + 2 160 [ ] + .. .. [ VISIBLE ] + [ SCREEN ] + [ ] + [ ] + .. .. [ ] + 199 15920 ======================== and the next diagram is of a modified addressing scheme with the OFFSET register set to 82 (to give us 4 extra pixels on each side of the screen) ROW OFFSET -0 0 ------========================------ -1 82 | V [ ] V | -2 164 | I [ ] I | -.. .. | N S [ VISIBLE ] N S | - | O I [ SCREEN ] O I | - | T B [ ] T B | - | L [ ] L | -.. .. | E [ ] E | +0 0 ------========================------ +1 82 | V [ ] V | +2 164 | I [ ] I | +.. .. | N S [ VISIBLE ] N S | + | O I [ SCREEN ] O I | + | T B [ ] T B | + | L [ ] L | +.. .. | E [ ] E | 199 16318 ------========================------ Beautiful!!! @@ -581,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; } @@ -886,123 +886,125 @@ 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("Resolution:\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 sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); - return 0; - } +//mxGetVersion(); + + printf("[%d]\n", mxGetVersion()); + puts("where to next? It's your move! wwww"); + printf("bakapi ver. 1.04.09.03\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); + return 0; + } #endif diff --git a/16/dos_gfx.h b/16/dos_gfx.h index 7a0b100e..d7fb0474 100644 --- a/16/dos_gfx.h +++ b/16/dos_gfx.h @@ -5,17 +5,17 @@ #include "lib\lib_com.h" #include "lib\x\modex.h" -#define NUM_COLORS 256 // number of colors in vga mode +#define NUM_COLORS 256 // number of colors in vga mode //static lgq=NUM_COLORS/(1/8) //static hgq=NUM_COLORS/(1/8) -#define BONK 400 -#define LGQ 32 -#define HGQ 56 -#define TILEWH 16 -/*byte SIZE = 80; // Size = 40 = 1 across, 4 down - // Size = 80 = 2 across, 2 down - // Size = 160 = 4 across, 1 down*/ -//#define VMEM 0xA000 // = vga +#define BONK 400 +#define LGQ 32 +#define HGQ 56 +#define TILEWH 16 +/*byte SIZE = 80; // Size = 40 = 1 across, 4 down + // Size = 80 = 2 across, 2 down + // Size = 160 = 4 across, 1 down*/ +//#define VMEM 0xA000 // = vga byte Xfont[2048]; void drawChar(int x, int y, int color, byte c); diff --git a/16/dos_kb.c b/16/dos_kb.c index 9e813b89..74f5a48a 100644 --- a/16/dos_kb.c +++ b/16/dos_kb.c @@ -28,11 +28,11 @@ void interrupt newkb(void){ kee = inp(0x60); /* Read the keyboard scan code */ /* Clear keyboard controller on XT machines */ - qx = inp(0x61); /* Get keyboard control register */ + qx = inp(0x61); /* Get keyboard control register */ qx |= 0x82; - outp(0x61, qx); /* Toggle acknowledge bit high */ + outp(0x61, qx); /* Toggle acknowledge bit high */ qx &= 0x7F; - outp(0x61, qx); /* Toggle acknowledge bit low */ + outp(0x61, qx); /* Toggle acknowledge bit low */ /* Interpret the scan code and set our flags */ #ifdef TESTING @@ -93,11 +93,11 @@ void setkb(int vq){ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * keyp * - * * - * Returns the status of the key requested. * + * keyp * + * * + * Returns the status of the key requested. * * The status is 1 if the key is pressed or has been pressed since the * - * last call to this function for that particular key. * + * last call to this function for that particular key. * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int keyp(byte c){ register char retVal; diff --git a/16/lib/x/MODEX.BAK b/16/lib/x/MODEX.BAK index 0069d2e6..5916999f 100644 Binary files a/16/lib/x/MODEX.BAK and b/16/lib/x/MODEX.BAK differ diff --git a/16/lib/x/MODEX.H b/16/lib/x/MODEX.H index 2c1f1ebe..4952856a 100644 --- a/16/lib/x/MODEX.H +++ b/16/lib/x/MODEX.H @@ -48,7 +48,7 @@ #define MXBOOL short int #define MXSINT short int #define MXUINT unsigned short int -#define MXAPI far pascal +#define MXAPI //far pascal #define MXPTR void far * // Functions diff --git a/16/scroll.txt b/16/scroll.txt index 89127e89..04f4acc0 100644 --- a/16/scroll.txt +++ b/16/scroll.txt @@ -5,12 +5,12 @@ SS SS CC CC RR RR OO OO LL LL II NNN NN GG GG SS CC RR RR OO OO LL LL II NNNN NN GG SSSSS CC RR RR OO OO LL LL II NN NN NN GG - SS CC RRRRR OO OO LL LL II NN NNNN GG GGG + SS CC RRRRR OO OO LL LL II NN NNNN GG GGG SS SS CC CC RR RR OO OO LL LL II NN NNN GG GG SSSSS CCCCC RR RR OOOOO LLLLL LLLLL IIIIII NN NN GGGGG - by Alec Thomas (Kestrel) of FORGE Software Australia - (c9223826@cs.newcastle.edu.au) + by Alec Thomas (Kestrel) of FORGE Software Australia + (c9223826@cs.newcastle.edu.au) ------------ @@ -36,7 +36,7 @@ on with the STUFF!!! the same with columns (except 0-319), etc. unless otherwise stated) ******************************************************************************** -* X-MODE SCROLLING * +* X-MODE SCROLLING * ******************************************************************************** ------------------ VERTICAL SCROLLING @@ -174,28 +174,28 @@ Perhaps a little diagram will clarify it. The following picture is of a standard X-mode addressing scheme with the OFFSET register set to 80. ROW OFFSET - 0 0 ======================== - 1 80 [ ] - 2 160 [ ] - .. .. [ VISIBLE ] - [ SCREEN ] - [ ] - [ ] - .. .. [ ] + 0 0 ======================== + 1 80 [ ] + 2 160 [ ] + .. .. [ VISIBLE ] + [ SCREEN ] + [ ] + [ ] + .. .. [ ] 199 15920 ======================== and the next diagram is of a modified addressing scheme with the OFFSET register set to 82 (to give us 4 extra pixels on each side of the screen) ROW OFFSET -0 0 ------========================------ -1 82 | V [ ] V | -2 164 | I [ ] I | -.. .. | N S [ VISIBLE ] N S | - | O I [ SCREEN ] O I | - | T B [ ] T B | - | L [ ] L | -.. .. | E [ ] E | +0 0 ------========================------ +1 82 | V [ ] V | +2 164 | I [ ] I | +.. .. | N S [ VISIBLE ] N S | + | O I [ SCREEN ] O I | + | T B [ ] T B | + | L [ ] L | +.. .. | E [ ] E | 199 16318 ------========================------ Beautiful!!! @@ -230,7 +230,7 @@ I'm sorry about this being so confusing but it's a bit difficult to explain. ******************************************************************************** -* STANDARD VGA SCROLLING * +* STANDARD VGA SCROLLING * ******************************************************************************** Without X-mode, there is no easy way to do scrolling using the VGA hardware. So basically, you have to resort to redrawing the entire screen for every @@ -258,7 +258,7 @@ END WHILE ******************************************************************************** -* PARALLAX SCROLLING * +* PARALLAX SCROLLING * ******************************************************************************** Parallax scrolling is when the "world" appears to have different levels of perspective. That is, images further away from the viewer move @@ -291,7 +291,7 @@ colour to what was there previously). ******************************************************************************** -* DISCLAIMER * +* DISCLAIMER * ******************************************************************************** I'm sorry if any of this is confusing, but hey that's half the fun of it - figuring out what the hell I'm raving on about :)