X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fmodex16%2Fscroll.c;h=49130bfc0449c2ea4b829875a9b99512b27531be;hb=092df3c756423869db765af38bd0736a91f12ec1;hp=697f5f21576ee5a23da9a6ce926fe05655d54c30;hpb=cc80849f10a6b87b596d595d2c4b0cdb436bf48f;p=16.git diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c index 697f5f21..49130bfc 100644 --- a/16/modex16/scroll.c +++ b/16/modex16/scroll.c @@ -11,6 +11,7 @@ typedef struct { word tileWidth; unsigned int rows; unsigned int cols; + unsigned int tilex,tiley; // tile position on the map } tiles_t; @@ -25,13 +26,18 @@ typedef struct { typedef struct { map_t *map; page_t *page; - int tx; - int ty; - word dxThresh; - word dyThresh; + int tx; //appears to be the top left tile position on the viewable screen map + int ty; //appears to be the top left tile position on the viewable screen map +// int ttx; //bottem right tile +// int tty; //bottem left tile + word dxThresh; //???? + word dyThresh; //???? } map_view_t; - +struct { + int tx; //player position on the viewable map + int ty; //player position on the viewable map +} player; map_t allocMap(int w, int h); @@ -45,84 +51,123 @@ 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; +#define TILEWH 16 +#define QUADWH (TILEWH/4) +#define SPEED 1 + +//place holder definitions +#define MAPX 40 +#define MAPY 30 +//#define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { - int show1=1; +// int show1=1; int tx, ty; int x, y; //int ch=0x0; - byte ch; - int q=0; - setkb(1); - page_t screen,screen2; +// byte ch; + int q=0; + page_t screen;//,screen2; map_t map; - map_view_t mv, mv2; - map_view_t *draw, *show, *tmp; + map_view_t mv;//, mv2; + map_view_t *draw;//, *show, *tmp; byte *ptr; - + + //default player position on the viewable map + player.tx = 10; + player.ty = 8; + + setkb(1); /* create the map */ - map = allocMap(40,30); + map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly initMap(&map); - mv.map = ↦ - mv2.map = ↦ + mv.map = ↦ + + //initiate bottem right edge trigger +// mv.ttx = mv.tx + 20; +// mv.tty = mv.ty + 15; +// mv2.map = ↦ /* draw the tiles */ ptr = map.data; modexEnter(); screen = modexDefaultPage(); - screen.width = 352; + screen.width += (TILEWH*2); mv.page = &screen; - screen2=modexNextPage(mv.page); - mv2.page = &screen2; - mapGoTo(&mv, 0, 0); - mapGoTo(&mv2, 0, 0); - modexShowPage(mv.page); +// screen2=modexNextPage(mv.page); +// mv2.page = &screen2; +// mapGoTo(&mv2, 16, 16); +// modexShowPage(mv.page); /* set up paging */ - show = &mv; - draw = &mv2; - +// show = &mv; +// draw = &mv2; + draw = &mv; + + mapGoTo(draw, 0, 0); + + //TODO: set player position data here according to the viewable map screen thingy + + modexShowPage(draw->page); while(!keyp(1)) { - if(keyp(77)){ - for(q=0; q<16; q++) { - mapScrollRight(draw, 1); - modexShowPage(draw->page); - SWAP(draw, show); - } - } + //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square + //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction + //when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map + if(keyp(77)){ + if(draw->tx >= 0 && draw->tx+20 < MAPX) + for(q=0; qpage); +// mapScrollRight(draw, 1); +// SWAP(draw, show); + } - if(keyp(75)){ - for(q=0; q<16; q++) { - mapScrollLeft(draw, 1); - modexShowPage(draw->page); - SWAP(draw, show); - } } - if(keyp(80)){ - for(q=0; q<16; q++) { - mapScrollDown(draw, 1); - modexShowPage(draw->page); - SWAP(draw, show); - } + if(keyp(75)){ + if(draw->tx > 0 && draw->tx+20 <= MAPX) + for(q=0; qpage); +// mapScrollLeft(show, 1); +// SWAP(draw, show); + } + } + if(keyp(80)){ + if(draw->ty >= 0 && draw->ty+15 < MAPY) + for(q=0; qpage); +// mapScrollDown(show, 1); +// SWAP(draw, show); + } - if(keyp(72)){ - for(q=0; q<16; q++) { - mapScrollUp(draw, 1); - modexShowPage(draw->page); - SWAP(draw, show); + } + + if(keyp(72)){ + if(draw->ty > 0 && draw->ty+15 <= MAPY) + for(q=0; qpage); +// mapScrollUp(show, 1); +// SWAP(draw, show); + } - } } //keyp(ch); + //modexShowPage(draw->page); } - + modexLeave(); - setkb(0); + setkb(0); + printf("Project 16 scroll.exe\n"); + printf("tx: %d\n", draw->tx); + printf("ty: %d\n", draw->ty); + //printf("ttx: %d\n", draw->ttx); + //printf("tty: %d\n", draw->tty); } @@ -148,21 +193,21 @@ initMap(map_t *map) { /* create the tile set */ map->tiles->data = malloc(sizeof(bitmap_t)); - map->tiles->data->width = 32; - map->tiles->data->height= 16; - map->tiles->data->data = malloc(32*16); - map->tiles->tileHeight = 16; - map->tiles->tileWidth = 16; + map->tiles->data->width = (TILEWH*2); + map->tiles->data->height= TILEWH; + map->tiles->data->data = malloc((TILEWH*2)*TILEWH); + map->tiles->tileHeight = TILEWH; + map->tiles->tileWidth =TILEWH; map->tiles->rows = 1; map->tiles->cols = 2; i=0; - for(y=0; y<16; y++) { - for(x=0; x<32; x++) { - if(x<16) - map->tiles->data->data[i] = 0x00; + for(y=0; ytiles->data->data[i] = 0x24; else - map->tiles->data->data[i] = 0x47; + map->tiles->data->data[i] = 0x34; i++; } }