X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fdos_gfx.cpp;h=360137edaa436ca905a306b68281dec220c0bee3;hb=de087a68310f656a0d2317065eedc49cea9280b3;hp=e5e4c6ed237822777572bfde8f84b8acc5bc3616;hpb=1d9ef1e5f31fdf05a9a617e838d6956dd2d04e2f;p=16.git diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index e5e4c6ed..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,79 +287,148 @@ void set320x240x256_X(void) } +/*-----------XXXX-------------*/ /*tile*/ -// This is Bresenham's Line Drawing Algorithm -void drawline(int x1, int y1, int x2, int y2, char col) -{ - int d, x, y, ax, ay, sx, sy, dx, dy; - - dx = x2-x1; - ax = ABS(dx) << 1; - sx = SGN(dx); - dy = y2-y1; - ay = ABS(dy) << 1; - sy = SGN(dy); - - x = x1; - y = y1; - if( ax > ay ) - { - d = ay - (ax >> 1); - while( x != x2 ) - { - putPixel_X( x, y, col ); - if( d >= 0 ) - { - y += sy; - d -= ax; - } - x += sx; - d += ay; - } - } - else - { - d = ax - (ay >> 1); - while( y != y2 ) - { - putPixel_X( x, y, col ); - if( d >= 0 ) - { - x += sx; - d -= ay; - } - y += sy; - d += ax; - } +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) @@ -553,10 +677,14 @@ int ding(int q){ // plot the pixel //---- ppf(xx, yy, coor, vga); -//++++0000 putPixel_X(xx, yy, coor); - }else drawrect(xx, yy, xx+TILEWH-1, yy+TILEWH-1, coor); + }else /*if(xx>=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||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) @@ -615,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); } @@ -652,7 +780,9 @@ int main(void) // puts("Press a key when ready..."); // getch(); +//++++0000 setvideo(1); +//mxInit(); // screen savers /*while(d!=0){ // on! @@ -669,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; }