]> 4ch.mooo.com Git - 16.git/blobdiff - 16/modex16/scroll.c
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / 16 / modex16 / scroll.c
old mode 100644 (file)
new mode 100755 (executable)
index 4681cbb..8a960ee
@@ -11,6 +11,7 @@ typedef struct {
        word tileWidth;\r
        unsigned int rows;\r
        unsigned int cols;\r
+       unsigned int tilex,tiley; // tile position on the map\r
 } tiles_t;\r
 \r
 \r
@@ -25,13 +26,16 @@ typedef struct {
 typedef struct {\r
        map_t *map;\r
        page_t *page;\r
-       int tx;\r
-       int ty;\r
-       word dxThresh;\r
-       word dyThresh;\r
+       int tx; //???? appears to be the tile position on the viewable screen map\r
+       int ty; //???? appears to be the tile position on the viewable screen map\r
+       word dxThresh; //????\r
+       word dyThresh; //????\r
 } map_view_t;\r
 \r
-\r
+struct {\r
+       int tx; //player position on the viewable map\r
+       int ty; //player position on the viewable map\r
+} player;\r
 \r
 \r
 map_t allocMap(int w, int h);\r
@@ -45,82 +49,94 @@ 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);\r
 void mapDrawCol(map_view_t *mv, int tx, int ty, word x);\r
 \r
-#define SWAP(a, b) tmp=a; a=b; b=tmp;\r
+#define TILEWH 16\r
+#define QUADWH (TILEWH/4)\r
+//#define SWAP(a, b) tmp=a; a=b; b=tmp;\r
 void main() {\r
-       int show1=1;\r
+//     int show1=1;\r
        int tx, ty;\r
        int x, y;\r
        //int ch=0x0;\r
-       byte ch;\r
+//     byte ch;\r
        int q=0;\r
-       page_t screen,screen2;\r
+       page_t screen;//,screen2;\r
        map_t map;\r
-       map_view_t mv, mv2;\r
-       map_view_t *draw, *show, *tmp;\r
+       map_view_t mv;//, mv2;\r
+       map_view_t *draw;//, *show, *tmp;\r
        byte *ptr;\r
-       \r
+\r
+       //default player position on the viewable map\r
+       player.tx = 10;\r
+       player.ty = 8;\r
 \r
        setkb(1);\r
        /* create the map */\r
-       map = allocMap(40,30); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly\r
+       map = allocMap(160,120); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly\r
        initMap(&map);\r
        mv.map = ↦\r
-       mv2.map = ↦\r
+//     mv2.map = ↦\r
 \r
        /* draw the tiles */\r
        ptr = map.data;\r
        modexEnter();\r
        screen = modexDefaultPage();\r
-       screen.width = 352;\r
+       screen.width += (TILEWH*2);\r
        mv.page = &screen;\r
-       mapGoTo(&mv, 0, 0);\r
-       screen2=modexNextPage(mv.page);\r
-       mv2.page = &screen2;\r
-       mapGoTo(&mv2, 0, 0);\r
-       modexShowPage(mv.page);\r
+       mapGoTo(&mv, 16, 16);\r
+//     screen2=modexNextPage(mv.page);\r
+//     mv2.page = &screen2;\r
+//     mapGoTo(&mv2, 16, 16);\r
+//     modexShowPage(mv.page);\r
 \r
        /* set up paging */\r
-       show = &mv;\r
-       draw = &mv2;\r
+//     show = &mv;\r
+//     draw = &mv2;\r
+       draw = &mv;\r
+\r
+       //TODO: set player position data here according to the viewable map screen thingy\r
 \r
        while(!keyp(1)) {\r
+       //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
+       //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
+       //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\r
        if(keyp(77)){\r
-               for(q=0; q<16; q++) {\r
+//             for(q=0; q<TILEWH; q++) {\r
                mapScrollRight(draw, 1);\r
-               modexShowPage(draw->page);\r
+//             modexShowPage(draw->page);\r
 //             mapScrollRight(draw, 1);\r
 //             SWAP(draw, show);\r
-               }\r
-       }else\r
+//             }\r
+       }\r
 \r
        if(keyp(75)){\r
-               for(q=0; q<16; q++) {\r
+//             for(q=0; q<TILEWH; q++) {\r
                mapScrollLeft(draw, 1);\r
-               modexShowPage(draw->page);\r
+//             modexShowPage(draw->page);\r
 //             mapScrollLeft(show, 1);\r
 //             SWAP(draw, show);\r
-               }\r
+//             }\r
        }\r
 \r
        if(keyp(80)){\r
-               for(q=0; q<16; q++) {\r
+//             for(q=0; q<TILEWH; q++) {\r
                mapScrollDown(draw, 1);\r
-               modexShowPage(draw->page);\r
+//             modexShowPage(draw->page);\r
 //             mapScrollDown(show, 1);\r
 //             SWAP(draw, show);\r
-               }\r
-       }else\r
+//             }\r
+       }\r
 \r
        if(keyp(72)){\r
-               for(q=0; q<16; q++) {\r
+//             for(q=0; q<TILEWH; q++) {\r
                mapScrollUp(draw, 1);\r
-               modexShowPage(draw->page);\r
+//             modexShowPage(draw->page);\r
 //             mapScrollUp(show, 1);\r
 //             SWAP(draw, show);\r
-               }\r
+//             }\r
        }\r
 \r
        //keyp(ch);\r
+       modexShowPage(draw->page);\r
 \r
        }\r
 \r
@@ -151,18 +167,18 @@ initMap(map_t *map) {
 \r
        /* create the tile set */\r
        map->tiles->data = malloc(sizeof(bitmap_t));\r
-       map->tiles->data->width = 32;\r
-       map->tiles->data->height= 16;\r
-       map->tiles->data->data = malloc(32*16);\r
-       map->tiles->tileHeight = 16;\r
-       map->tiles->tileWidth = 16;\r
+       map->tiles->data->width = (TILEWH*2);\r
+       map->tiles->data->height= TILEWH;\r
+       map->tiles->data->data = malloc((TILEWH*2)*TILEWH);\r
+       map->tiles->tileHeight = TILEWH;\r
+       map->tiles->tileWidth =TILEWH;\r
        map->tiles->rows = 1;\r
        map->tiles->cols = 2;\r
 \r
        i=0;\r
-       for(y=0; y<16; y++) {\r
-       for(x=0; x<32; x++) {\r
-               if(x<16)\r
+       for(y=0; y<TILEWH; y++) {\r
+       for(x=0; x<(TILEWH*2); x++) {\r
+               if(x<TILEWH)\r
                  map->tiles->data->data[i] = 0x24;\r
                else\r
                  map->tiles->data->data[i] = 0x34;\r