X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fmodex16%2Fscroll.c;h=89a06aeb5a670ed19d1d8b92d5dbc74bfa621b7d;hb=33c9df2b46a82c4ba3f8219e5eb0454e71bf97ec;hp=43edbcd589949a3f8c9ff53a7357ec85abea6084;hpb=27b190bc76b1f75811d6686daf3fde0167e10704;p=16.git diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c index 43edbcd5..89a06aeb 100644 --- a/16/modex16/scroll.c +++ b/16/modex16/scroll.c @@ -1,6 +1,6 @@ #include "modex16.h" #include -#include +#include #include "dos_kb.h" //word far *clock= (word far*) 0x046C; /* 18.2hz clock */ @@ -45,24 +45,25 @@ void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); void mapDrawRow(map_view_t *mv, int tx, int ty, word y); void mapDrawCol(map_view_t *mv, int tx, int ty, word x); +#define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { int show1=1; int tx, ty; - int x, y; - //int ch=0x0; - byte ch; + int x, y; + //int ch=0x0; + byte ch; int q=0; - page_t screen; + page_t screen,screen2; map_t map; - map_view_t mv; - byte *ptr; - - setkb(1); - + map_view_t mv, mv2; + map_view_t *draw, *show, *tmp; + byte *ptr; + /* create the map */ map = allocMap(40,30); initMap(&map); mv.map = ↦ + mv2.map = ↦ /* draw the tiles */ ptr = map.data; @@ -70,64 +71,57 @@ void main() { screen = modexDefaultPage(); screen.width = 352; mv.page = &screen; + screen2=modexNextPage(mv.page); + mv2.page = &screen2; mapGoTo(&mv, 0, 0); + mapGoTo(&mv2, 0, 0); modexShowPage(mv.page); - - while(!keyp(1)) - { - // scroll all the way to the right - //for(x=0; x<(map.width*16-SCREEN_WIDTH); x++) { - //if(ch==0x4d){ - if(keyp(77)){ - for(q=0; q<16; q++) { - mapScrollRight(&mv, 1); - modexShowPage(mv.page); + + /* set up paging */ + show = &mv; + draw = &mv2; + + while(!keyp(1)) { + if(keyp(77)){ + for(q=0; q<16; q++) { + mapScrollRight(draw, 1); + modexShowPage(draw->page); + SWAP(draw, show); + } } - } - // scroll all the way to the left - //for(; x>0; x--) { - //if(ch==0x4b){ - if(keyp(75)){ - for(q=0; q<16; q++) { - mapScrollLeft(&mv, 1); - modexShowPage(mv.page); + if(keyp(75)){ + for(q=0; q<16; q++) { + mapScrollLeft(draw, 1); + modexShowPage(draw->page); + SWAP(draw, show); + } } - } - // scroll all the way down - //for(y=0; y<(map.height*16-SCREEN_HEIGHT); y++) { - //if(ch==0x50){ - if(keyp(80)){ - for(q=0; q<16; q++) { - mapScrollDown(&mv, 1); - modexShowPage(mv.page); - } - } + if(keyp(80)){ + for(q=0; q<16; q++) { + mapScrollDown(draw, 1); + modexShowPage(draw->page); + SWAP(draw, show); + } + } + + + if(keyp(72)){ + for(q=0; q<16; q++) { + mapScrollUp(draw, 1); + modexShowPage(draw->page); + SWAP(draw, show); - // scroll all the way up - //for(; y>0; y--) { - //if(ch==0x48){ - if(keyp(72)){ - for(q=0; q<16; q++) { - mapScrollUp(&mv, 1); - modexShowPage(mv.page); + } } + + keyp(ch); + } - // spin for a time - /*for(x=0; x<500; x++) { - modexWaitBorder(); - }*/ - //while(1){ -// ch=getch(); - //printf("0x%02x\n", ch); - keyp(ch); -// if(ch==0x71)break; // 'q' -// if(ch==0x1b)break; // 'ESC' -} - modexLeave(); - setkb(0); + modexLeave(); + setkb(0); }