]> 4ch.mooo.com Git - 16.git/blobdiff - src/scroll.c
i want to make an FPS system
[16.git] / src / scroll.c
index c262ec5e7e62c47b38fae02b5a419a3a85b53920..b8065566da84a69c686a407149fd9540e49111cf 100644 (file)
 #include "src/lib/mapread.h"
 #include "src/lib/wcpu/wcpu.h"
 
+//#define FADE
+//#define SPRITE
+
 //word far *clock= (word far*) 0x046C; /* 18.2hz clock */
 
 void main()
 {
-       dword tiku = 0;
 //     word panswitch=0, panq=1, pand=0;
        global_game_variables_t gvar;
        word panpagenum=0; //for panning!
@@ -42,7 +44,9 @@ void main()
        map_view_t mv[3];
        map_view_t *bg, *spri, *mask;//, *tmp;
        //map_view_db_t pgid[4];
+#ifdef FADE
        byte *dpal, *gpal;
+#endif
        byte *ptr;
        byte *mappalptr;
        byte *mesg=malloc(sizeof(dword));
@@ -94,27 +98,33 @@ void main()
        IN_Default(0,&player,ctrl_Joystick);
 
        /* save the palette */
+#ifdef FADE
        dpal = modexNewPal();
        modexPalSave(dpal);
        modexFadeOff(4, dpal);
+#endif
 
        textInit();
        VGAmodeX(1);
+#ifdef FADE
        modexPalBlack();        //reset the palette~
+#endif
 //     printf("Total used @ before palette initiation:         %zu\n", oldfreemem-GetFreeSize());
-       player[0].data.offset=(paloffset/3);
-       modexPalUpdate(&player[0].data, &paloffset, 0, 0);
+//++++ player[0].data.offset=(paloffset/3);
+//++++ modexPalUpdate(&player[0].data, &paloffset, 0, 0);
        //printf("      %d\n", sizeof(ptmp->data));
        //printf("1:    %d\n", paloffset);
-       map.tiles->data->offset=(paloffset/3);
+//++++ map.tiles->data->offset=(paloffset/3);
        //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0);
 //     printf("\n====\n");
 //     printf("0       paloffset=      %d\n", paloffset/3);
 //     printf("====\n\n");
+#ifdef FADE
        gpal = modexNewPal();
        modexPalSave(gpal);
        modexSavePalFile("data/g.pal", gpal);
        modexPalBlack();        //so player will not see loadings~
+#endif
 
        /* setup camera and screen~ */
        screen = modexDefaultPage();
@@ -145,9 +155,14 @@ void main()
        player[0].y = player[0].ty*TILEWH;
        player[0].triggerx = player[0].tx;
        player[0].triggery = player[0].ty+1;
+/*     player[0].info.x = player[0].tx;
+       player[0].info.xaxis = player[0].tx*TILEWH;
+       player[0].info.y = player[0].ty;
+       player[0].info.yaxis = player[0].ty*TILEWH;*/
        player[0].q=1;
-       player[0].info.dir=2;
+       player[0].d=2;
        player[0].hp=4;
+//     player[0].persist_aniframe=0;
        //npc
        /*npc0.tx = bg->tx + 1;
        npc0.ty = bg->ty + 1;
@@ -158,16 +173,22 @@ void main()
        npc0.q=1;
        npc0.d=0;
        modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 64, 24, 32, &npctmp);*/
+#ifdef SPRITE
        modexDrawSpriteRegion(spri->page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, &player[0].data);
+#else
+       modexClearRegion(mv[1].page, player[0].x-4, player[0].y-TILEWH, 24, 32, 15);
+#endif
 
        modexShowPage(spri->page);
 //     printf("Total used @ before loop:                       %zu\n", oldfreemem-GetFreeSize());
        modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 1);
+#ifdef FADE
        modexFadeOn(4, gpal);
+#endif
        while(!IN_KeyDown(sc_Escape) && player[0].hp>0)
        {
-               sprintf(mesg, "%lu", tiku);
-               modexprint(mv[1].page, 0, 0, 1, 15, 0, mesg);
+               sprintf(mesg, "%lu", gvar.tiku);
+               modexprint(mv[1].page, 16, 16, 1, 15, 0, mesg);
                shinku(mv[1].page, &gvar);
                IN_ReadControl(0,&player);
        //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
@@ -309,6 +330,7 @@ void main()
        if(IN_KeyDown(3)){ modexShowPage(spri->page); panpagenum=1; }
        if(IN_KeyDown(4)){ modexShowPage(mask->page); panpagenum=2; }
        if(IN_KeyDown(25)){ pdump(bg->page); pdump(spri->page); }       //p
+#ifdef FADE
        if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; pdump(bg->page); pdump(spri->page); }
        if(IN_KeyDown(22)){
        paloffset=0; modexPalBlack(); modexPalUpdate(&player[0].data, &paloffset, 0, 0);
@@ -316,6 +338,7 @@ void main()
         modexPalUpdate(map.tiles->data, &paloffset, 0, 0);
        printf("2paloffset      =       %d\n", paloffset/3);
         pdump(bg->page); pdump(spri->page); }
+#endif
        //pan switch
        //if(IN_KeyDown(88)){if(!panswitch) panswitch++; else panswitch--; }    //f12
        //TSR
@@ -332,14 +355,16 @@ void main()
 
        if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break;        //incase things go out of sync!
 
-       tiku++;
+       gvar.tiku++;
        }
 
        /* fade back to text mode */
        /* but 1st lets save the game palette~ */
+#ifdef FADE
        modexPalSave(gpal);
        modexSavePalFile("data/g.pal", gpal);
        modexFadeOff(4, gpal);
+#endif
        VGAmodeX(0);
        IN_Shutdown();
        printf("Project 16 scroll.exe\n");
@@ -350,7 +375,7 @@ void main()
        //else printf("\nplayer[0].y: %d\n", player[0].y);
        printf("player[0].tx: %d", player[0].tx); printf("              player[0].ty: %d\n", player[0].ty);
        printf("player[0].triggx: %d", player[0].triggerx); printf("    player[0].triggy: %d\n", player[0].triggery);
-       printf("player[0].hp: %d", (player[0].hp));     printf("        player[0].q: %d", player[0].q); printf("        player[0].info.dir: %d\n", player[0].info.dir);
+       printf("player[0].hp: %d", (player[0].hp));     printf("        player[0].q: %d", player[0].q); printf("        player[0].info.dir: %d", player[0].info.dir);   printf("        player[0].d: %d\n", player[0].d);
        printf("tile data value at player trigger position: %d\n", bg->map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]);
        printf("palette offset: %d\n", paloffset/3);
 //++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize());
@@ -360,6 +385,10 @@ void main()
        printf("Screen: %dx", screen.width);    printf("%d\n", screen.height);
        printf("Screen2: %dx", screen2.width);  printf("%d\n", screen2.height);
        printf("map: %dx%d\n", map.width, map.height);
+       printf("\n");
+       printf("player[0].persist_aniframe: %d\n", player[0].persist_aniframe);
+//     printf("player[0].info.x: %d", player[0].info.xaxis); printf("          player[0].info.y: %d\n", player[0].info.yaxis);
+//     printf("player[0].info.tx: %d", player[0].info.x); printf("             player[0].info.ty: %d\n", player[0].info.y);
        //printf("map.width=%d  map.height=%d   map.data[0]=%d\n", bg->map->width, bg->map->height, bg->map->data[0]);
        //xmsfree(&map);
        //xmsfree(bg);
@@ -375,5 +404,7 @@ void main()
                default: cpus = "internal error"; break;
        }
        printf("detected CPU type: %s\n", cpus);
+#ifdef FADE
        modexFadeOn(4, dpal);
+#endif
 }