OSDN Git Service

no idea how to get joy buttons 2 and 3 to function.
[proj16/16.git] / src / pcxtest.c
old mode 100644 (file)
new mode 100755 (executable)
index 7efc3fa..07e8dfd
-#include <stdio.h>
-#include <dos.h>
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2021 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <dos.h>\r
 #include <string.h>\r
-#include "src\lib\modex16.h"\r
-#include "src\lib\bitmap.h"
-#include "src\lib\planar.c"\r
-\r
-word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
-\r
-void\r
-oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite) {\r
-    byte plane;\r
-    word px, py;\r
-    word offset;\r
-\r
-    /* TODO Make this fast.  It's SLOOOOOOW */\r
-    for(plane=0; plane < 4; plane++) {\r
-       modexSelectPlane(PLANE(plane+x));\r
-       for(px = plane; px < bmp->width; px+=4) {\r
-           offset=px;\r
-           for(py=0; py<bmp->height; py++) {\r
-               if(!sprite || bmp->data[offset])\r
-                 page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];\r
-               offset+=bmp->width;\r
-           }\r
+#include "src/lib/16_vl.h"\r
+#include "src/lib/bitmap.h"\r
+#include "16/src/lib/16render.h"\r
+#include "src/lib/16_in.h"\r
+\r
+#include "src/lib/16_tail.h"\r
+\r
+static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
+\r
+#define PCXBMPVAR              gvar.player[0].data\r
+#define PCXBMP                 *PCXBMPVAR\r
+#define PCXBMPPTR              PCXBMPVAR\r
+\r
+void main() {\r
+       static global_game_variables_t gvar;\r
+//---- planar_buf_t *p;\r
+       word start;\r
+       float t1, t2;\r
+\r
+       // DOSLIB: check our environment\r
+       probe_dos();\r
+\r
+       // DOSLIB: what CPU are we using?\r
+       // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
+       //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
+       //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
+       //      the CPU to carry out tasks. --J.C.\r
+       cpu_probe();\r
+\r
+       // DOSLIB: check for VGA\r
+       if (!probe_vga()) {\r
+               printf("VGA probe failed\n");\r
+               return;\r
        }\r
-    }\r
-}
-\r
-/*
-void\r
-DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)
-{\r
-    byte plane;\r
-    word px, py;\r
-    word offset;\r
-\r
-    // TODO Make this fast.  It's SLOOOOOOW\r
-    for(plane=0; plane < 4; plane++) {\r
-       modexSelectPlane(PLANE(plane+x));\r
-       for(px = plane; px < p->width; px+=4) {\r
-           offset=px;\r
-           for(py=0; py<p->height/2; py++) {
-               SELECT_ALL_PLANES();\r
-               if(!sprite || p->plane[offset])\r
-                       page->data = p->plane;\r
-               //offset+=p->width;
-               //offset++;\r
-           }\r
+       // hardware must be VGA or higher!\r
+       if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
+               printf("This program requires VGA or higher graphics hardware\n");\r
+               return;\r
        }\r
-    }\r
-}\r
-*/
 \r
-void main() {\r
-    bitmap_t bmp;
-    planar_buf_t *p;\r
-    int i;\r
-    page_t page;\r
-    word start;
-    int plane;\r
-    float t1, t2;\r
-\r
-    page=modexDefaultPage();\r
-\r
-    bmp = bitmapLoadPcx("data/koishi~~.pcx");
-    p = planar_buf_from_bitmap(&bmp);\r
-    modexEnter();\r
-\r
-    /* fix up the palette and everything */\r
-    modexPalUpdate(&bmp, 0, 0/*, 0*/);\r
-\r
-    /* clear and draw one sprite and one bitmap */\r
-    modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);\r
-\r
-    /* non sprite comparison */
-    start = *clock;\r
-    for(i=0; i<100 ;i++) {\r
-      oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
-    }\r
-\r
-    start = *clock;\r
-    for(i=0; i<100 ;i++) {\r
-      modexDrawBmp(&page, 20, 20, &bmp);\r
-    }\r
-    t1 = (*clock-start) /18.2;\r
-\r
-    start = *clock;\r
-    for(i=0; i<100; i++) {\r
-       modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);\r
-    }\r
-    t2 = (*clock-start)/18.2;\r
-\r
-\r
-    start = *clock;\r
-    for(i=0; i<100 ;i++) {\r
-      oldDrawBmp(VGA, 20, 20, &bmp, 1);\r
-    }\r
-\r
-\r
-    start = *clock;\r
-    for(i=0; i<100 ;i++) {\r
-      modexDrawSprite(&page, 20, 20, &bmp);\r
-    }
-    //_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));
-       while(!kbhit())
-       {
-               //DrawPBuf(&page, 0, 0, p, 0);
-       }
-    modexLeave();\r
-
-       printf("\n%d\n", sizeof(p->plane));
-       printf("%d\n", sizeof(bmp));\r
-    printf("CPU to VGA: %f\n", t1);\r
-    printf("VGA to VGA: %f\n", t2);\r
-    return;\r
+//0000 PCXBMP = bitmapLoadPcx("data/koishi~~.pcx");\r
+       PCXBMP = bitmapLoadPcx("data/chikyuu.pcx", &gvar);\r
+//     PCXBMP = bitmapLoadPcx("data/koishi^^.pcx");\r
+//     PCXBMP = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
+//---- p = planar_buf_from_bitmap(PCXBMPPTR);\r
+\r
+       VGAmodeX(1, 1, &gvar);\r
+       gvar.video.page[0]=modexDefaultPage(&gvar.video.page[0]);\r
+\r
+       /* fix up the palette and everything */\r
+       modexPalUpdate(&PCXBMP->palette);\r
+\r
+       /* clear and draw one sprite and one bitmap */\r
+       modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 1);\r
+\r
+       /* non sprite comparison */\r
+       /*start = *clockw;\r
+       //for(i=0; i<100 ;i++) {\r
+               oldDrawBmp(VGA, 0, 0, PCXBMPPTR, 0);\r
+       //}\r
+\r
+       start = *clockw;\r
+       //for(i=0; i<100 ;i++) {\r
+//0000         modexDrawBmp(&gvar.video.page[0], 20, 20, PCXBMPPTR);\r
+               modexDrawBmp(&gvar.video.page[0], 160, 120, PCXBMPPTR);\r
+       //}\r
+       t1 = (*clockw-start) /18.2;\r
+\r
+       start = *clockw;\r
+       //for(i=0; i<100; i++) {\r
+//0000         modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 20, 20, 128, 20, 64, 64);\r
+               modexCopyPageRegion(&gvar.video.page[0], &gvar.video.page[0], 0, 0, 0, 0, 320, 240);\r
+       //}\r
+       t2 = (*clockw-start)/18.2;*/\r
+\r
+\r
+       start = *clockw;\r
+       //for(i=0; i<100 ;i++) {\r
+               oldDrawBmp(VGA, 0, 0, PCXBMPPTR, 1);\r
+       //}\r
+       t1 = (*clockw-start) /18.2;\r
+\r
+\r
+       start = *clockw;\r
+       //for(i=0; i<100 ;i++) {\r
+//0000         modexDrawSprite(&gvar.video.page[0], 20, 20, PCXBMPPTR);\r
+               modexDrawSprite(&(gvar.video.page[0]), 160, 120, PCXBMPPTR);\r
+               modexDrawBmp(&gvar.video.page[0], 0, 128, PCXBMPPTR);\r
+       //}\r
+       t2 = (*clockw-start)/18.2;\r
+       //_fmemset(MK_FP(0xA000, 0), (int)p->plane, gvar.video.page[0].sw*(gvar.video.page[0].sh*2));\r
+       //modexDrawBmp(&gvar.video.page[0], 0, 0, PCXBMPPTR);\r
+       while(!kbhit())\r
+       {\r
+               //DrawPBuf(&gvar.video.page[0], 0, 0, p, 0);\r
+       }\r
+       VGAmodeX(0, 1, &gvar);\r
+       /*printf("\nmain=%Fp\n\n", &i);\r
+       printf("PCXBMP.data=%Fp\n", PCXBMP.data);\r
+       printf("*PCXBMP.data=%Fp\n", *(PCXBMP.data));\r
+       printf("PCXBMPPTR.data=%Fp\n", &(PCXBMP.data));\r
+\r
+       printf("\n%d\n", sizeof(p->plane));\r
+       printf("%d\n", sizeof(PCXBMP));*/\r
+\r
+       /*for(i=0; i<(320*240); i++)\r
+       {\r
+               fprintf(stdout, "%d", PCXBMP.data[i]);\r
+               if(i%PCXBMP.width==0) fprintf(stdout, "\n");\r
+       }*/\r
+       printf("CPU to VGA: %f\n", t1);\r
+       printf("VGA to VGA: %f\n", t2);\r
+       printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width);\r
+       printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height);\r
+       return;\r
 }\r