X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fdos_gfx.cpp;h=360137edaa436ca905a306b68281dec220c0bee3;hb=de087a68310f656a0d2317065eedc49cea9280b3;hp=fcedc7c1de10ab395233ba38868b438baf7a88aa;hpb=54bce552ab1df8726450dce94ffeff37456f9566;p=16.git diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index fcedc7c1..360137ed 100644 --- a/16/dos_gfx.cpp +++ b/16/dos_gfx.cpp @@ -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 @@ -56,7 +56,7 @@ //code from old library! /*src\lib\*/ -#include "dos_gfx.h" +#include "dos_gfx.h" #include "lib\x\modex.h" int old_mode; @@ -145,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); + } /* @@ -236,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; @@ -261,24 +303,124 @@ void putColorBox_X(int x, int y, int w, int h, byte color) { } } } -/*OFFSET = 0 -WHILE NOT FINISHED DO - OFFSET = OFFSET + 80 - IF OFFSET >= (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 vScroll(int rows) +{ + // Scrolling = current start + (rows * bytes in a row) + setVisibleStart(visStart + (rows * width)); } + +void scrolly(int bong) +{ + int boing=0; + if(bong<0) + boing=-1; + else if(bong>0) + 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) @@ -523,14 +677,14 @@ int ding(int q){ // plot the pixel //---- ppf(xx, yy, coor, vga); - }else if(xx>=0 && xx=0 && yy=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) @@ -589,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); } @@ -626,8 +780,9 @@ int main(void) // puts("Press a key when ready..."); // getch(); -//++++0000 setvideo(1); -mxInit(); +//++++0000 + setvideo(1); +//mxInit(); // screen savers /*while(d!=0){ // on! @@ -644,15 +799,20 @@ mxInit(); } }*/ // else off while(!kbhit()){ // conditions of screen saver - ding(4); + ding(4); } //end of screen savers doTest(); -//++++0000 setvideo(0); -mxTerm(); -mxGetVersion(); + + 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.09.01\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; }