X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fdos_gfx.cpp;h=360137edaa436ca905a306b68281dec220c0bee3;hb=de087a68310f656a0d2317065eedc49cea9280b3;hp=e11055f036e2118de56626db33b40355074a43c4;hpb=d9b4c65a44fa017633ddbd622fd7d980bb7da609;p=16.git diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index e11055f0..360137ed 100644 --- a/16/dos_gfx.cpp +++ b/16/dos_gfx.cpp @@ -32,7 +32,7 @@ * Thanks go out to various helpful netters who spotted the 0xE7 bug * in the set320x240x256() function! * - * modified by sparky4 so it can be compiled in open watcom ^^ + * Modified by sparky4 so it can be compiled in open watcom ^^ */ @@ -45,7 +45,7 @@ #if !defined(__COMPACT__) # if !defined(__LARGE__) # if !defined(__HUGE__) -# error Large data model required! Try compiling with 'bcc -ml lib.c'. +# error Large data model required! Try compiling with 'wcc -0 -ml lib.c'. # endif # endif #endif @@ -57,6 +57,7 @@ //code from old library! /*src\lib\*/ #include "dos_gfx.h" +#include "lib\x\modex.h" int old_mode; //color ‚Ä‚·‚Æ @@ -144,7 +145,49 @@ void set320x200x256_X(void) /* By default we want screen refreshing and drawing operations to be based at offset 0 in the video segment. */ - actStart = visStart = 0; + actStart = visStart = 0; + + /* +-------------------- +HORIZONTAL SCROLLING +-------------------- +Horizontal scrolling is essentially the same as vertical scrolling, all +you do is increment or decrement the VGA offset register by 1 instead of +80 as with vertical scrolling. + +However, horizontal scrolling is complicated by two things + + 1. Incrementing the offset register by one actually scrolls by FOUR + pixels (and there are FOUR planes on the VGA, what a coincidence) + + 2. You can't draw the image off the screen and then scroll it on + because of the way the VGA wraps to the next row every 80 bytes + (80 bytes * 4 planes = 320 pixels), if you tried it, you would + actually be drawing to the other side of the screen (which is + entirely visible) + +I'll solve these problems one at a time. + +Firstly, to get the VGA to scroll by only one pixel you use the horizontal +pixel panning (HPP) register. This register resides at + + PORT: 3C0H + INDEX: 13h + +and in real life, you use it like this + +----------------- Pixel Panning --------------- +IN PORT 3DAH (this clears an internal + flip-flop of the VGA) +OUT 13H TO PORT 3C0H +OUT value TO PORT 3C0H (where "value" is the + number of pixels to offset) +----------------------------------------------- +*/ + inp(0x3DA) + outpw(0x3C0, 0x13); + outpw(0x3C0, 0x58); + } /* @@ -235,8 +278,8 @@ void set320x240x256_X(void) 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 */ - + outpw(0x3D4, 0x0616); /* end vertical blanking */ + /* Update mode info, so future operations are aware of the resolution */ height = 240; @@ -244,40 +287,140 @@ void set320x240x256_X(void) } -/*-----------XXXX-------------*/ +/*-----------XXXX-------------*/ /*tile*/ -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; cury= (200 * 80) THEN OFFSET = 0 - DRAW TO ROW 200 - SET VGA OFFSET = OFFSET - DRAW TO ROW -1 (was row 0 before scroll) -END WHILE*//* -void scrolly(){ - int OFFSET = 0 - WHILE NOT FINISHED DO - OFFSET = OFFSET + 80 - IF OFFSET >= (240 * 80) THEN OFFSET = 0 - RAW TO ROW 240 - SET VGA OFFSET = OFFSET - DRAW TO ROW -1 (was row 0 before scroll) - } +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) + boing=1; + else break; + + for(int i=0;iwidth) xx=0; - if(yy>height) yy=0; - //} + if(yy>(height*3)) yy=0; +// } //interesting effects if(q==16) @@ -522,14 +677,14 @@ int ding(int q){ // plot the pixel //---- ppf(xx, yy, coor, vga); - }else if(xx>=0 && xx=0 && PixelY=0 && xx=0 && yy<(height*3))*/{ + putColorBox_X(xx, yy, TILEWH, TILEWH, coor); +//++++0000 putPixel_X(xx, yy, coor); + } + //---- if(q==2) ppf(rand()%, rand()%height, 0, vga); - if(q==2) putColorBox_X(rand()%width, rand()%height, TILEWH, TILEWH, 0); - if(q==16) putPixel_X(rand()%width, rand()%height, 0); + if(q==2) putColorBox_X(rand()%width, rand()%(height*3), TILEWH, TILEWH, 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>240) @@ -588,7 +743,7 @@ void doTest(void) putPixel_X(x+(p+2)*16, y+(p+2)*16, x + y*16); //} - drawText(0, 0, 15, p); +// drawText(0, 0, 15, p); } @@ -625,7 +780,9 @@ int main(void) // puts("Press a key when ready..."); // getch(); +//++++0000 setvideo(1); +//mxInit(); // screen savers /*while(d!=0){ // on! @@ -642,13 +799,20 @@ int main(void) } }*/ // else off while(!kbhit()){ // conditions of screen saver - ding(4); + ding(4); } //end of screen savers doTest(); + + while(!kbhit()){ // conditions of screen saver + vScroll(-1); + } +//++++0000 setvideo(0); +//mxTerm(); +//mxGetVersion(); puts("Where to next? It's your move! wwww"); - printf("bakapi ver. 1.04.09a\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); + printf("bakapi ver. 1.04.09.02\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); return 0; }