]> 4ch.mooo.com Git - 16.git/blobdiff - src/scroll.c
modified: makefile
[16.git] / src / scroll.c
index b91adf7db218ff5e583009d4e96c867808c92458..239883f678332a467dd92647881c71e3454df139 100644 (file)
@@ -1,16 +1,13 @@
-#include "src\lib\modex16.h"\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include "src\lib\dos_kb.h"\r
-#include "16\lib\x\modex.h"\r
+#include "src\lib\dos_kb.h"
+#include "src\lib\mapread.c"\r
+//#include "16\lib\x\modex.h"\r
 #include "src\lib\wtest\wtest.c"\r
-#include "src\lib\ems.c"\r
+#include "src\lib\planar.c"
+//====#include "src\lib\ems.c"\r
 \r
 //word far *clock= (word far*) 0x046C; /* 18.2hz clock */\r
 \r
-int emmhandle,ist;\r
-\r
-typedef struct {\r
+/*typedef struct {\r
        bitmap_t *data;\r
        word tileHeight;\r
        word tileWidth;\r
@@ -24,7 +21,7 @@ typedef struct {
        tiles_t *tiles;\r
        int width;\r
        int height;\r
-} map_t;\r
+} map_t;*/\r
 \r
 \r
 typedef struct {\r
@@ -61,6 +58,7 @@ void mapGoTo(map_view_t *mv, int tx, int ty);
 void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
 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
+void qclean();\r
 void animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */sword d, short scrolloffsetswitch, int x, int y, int ls, int lp, bitmap_t *bmp);\r
 \r
 #define TILEWH 16\r
@@ -69,13 +67,18 @@ void animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */sword
 //#define LOOPMAX (TILEWH/SPEED)\r
 \r
 //place holder definitions\r
-#define MAPX 200\r
-#define MAPY 150\r
+//#define MAPX 200\r
+//#define MAPY 150\r
 #define TRIGGX 10\r
 #define TRIGGY 9\r
 \r
 void main() {\r
+       long emmhandle;\r
+       long emsavail;\r
+       char teststr[80];\r
+       int i;\r
        bitmap_t ptmp;//, npctmp; // player sprite\r
+       planar_buf_t *p;\r
        const char *cpus;\r
        static int persist_aniframe = 0;    /* gonna be increased to 1 before being used, so 0 is ok for default */\r
        page_t screen, screen2, screen3;\r
@@ -87,10 +90,37 @@ void main() {
        actor_t player;\r
        //actor_t npc0;\r
 \r
-       if(isEMS() || checkEMS()){ printf("%d\n", coretotalEMS()); emmhandle = mallocEMS(coretotalEMS()); }\r
+//     atexit(qclean());\r
+       /*if(!emmtest())\r
+       {\r
+               printf("Expanded memory is not present\n");\r
+               exit(0);\r
+       }\r
+     \r
+       if(!emmok())\r
+       {\r
+               printf("Expanded memory manager is not present\n");\r
+               exit(0);\r
+       }\r
+     \r
+       emsavail = emmavail();\r
+       if(emsavail == -1)\r
+       {\r
+               printf("Expanded memory manager error\n");\r
+               exit(0);\r
+       }\r
+       printf("There are %ld pages available\n",emsavail);\r
+\r
+       if((emmhandle = emmalloc(emsavail)) < 0)\r
+       {\r
+               printf("Insufficient pages available\n");\r
+               exit(0);\r
+       }*/\r
 \r
-       /* create the map */\r
-       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\r
+       /* create the map */
+       loadmap("data/test.map", &map/*, 0*/);\r
+       map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly
+       //loadmap(NULL, &map, 1);\r
        //if(isEMS()) printf("%d tesuto\n", coretotalEMS());\r
        initMap(&map);\r
        mv.map = &map;\r
@@ -103,6 +133,9 @@ void main() {
        ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite\r
        //npctmp = bitmapLoadPcx("ptmp1.pcx"); // load sprite\r
 \r
+       /* create the planar buffer */\r
+       p = planar_buf_from_bitmap(&ptmp);\r
+\r
        /*if(isEMS())\r
        {\r
                XMOVE mm;\r
@@ -134,7 +167,7 @@ void main() {
        }\r
 */\r
        /* save the palette */\r
-       pal  = modexNewPal();\r
+       pal = modexNewPal();\r
        modexPalSave(pal);\r
        modexFadeOff(4, pal);\r
        modexPalBlack();\r
@@ -208,7 +241,7 @@ void main() {
        //right movement\r
        if(npc0.d == 2)\r
        {\r
-               if(npc0.tx < MAPX && !(npc0.tx+1 == TRIGGX && npc0.ty == TRIGGY) && !(npc0.tx+1 == player.tx && npc0.ty == player.ty))\r
+               if(npc0.tx < map.width && !(npc0.tx+1 == TRIGGX && npc0.ty == TRIGGY) && !(npc0.tx+1 == player.tx && npc0.ty == player.ty))\r
                {\r
                        if(npc0.q<=(TILEWH/SPEED))\r
                        {\r
@@ -260,7 +293,7 @@ void main() {
        //down movement\r
        if(npc0.d == 3)\r
        {\r
-               if(npc0.ty < MAPY && !(npc0.tx == TRIGGX && npc0.ty+1 == TRIGGY) && !(npc0.tx == player.tx && npc0.ty == player.ty+1))\r
+               if(npc0.ty < map.height && !(npc0.tx == TRIGGX && npc0.ty+1 == TRIGGY) && !(npc0.tx == player.tx && npc0.ty == player.ty+1))\r
                {\r
                        if(npc0.q<=(TILEWH/SPEED))\r
                        {\r
@@ -318,7 +351,7 @@ void main() {
        if((keyp(77) && !keyp(75) && player.d == 0) || player.d == 2)\r
        {\r
                if(player.d == 0){ player.d = 2; }\r
-               if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))\r
+               if(bg->tx >= 0 && bg->tx+20 < map.width && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -332,7 +365,7 @@ void main() {
                                player.q++;\r
                        } else { player.q = 1; player.d = 0; player.tx++; }\r
                }\r
-               else if(player.tx < MAPX && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))\r
+               else if(player.tx < map.width && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -359,7 +392,7 @@ void main() {
        if((keyp(75) && !keyp(77) && player.d == 0) || player.d == 4)\r
        {\r
                if(player.d == 0){ player.d = 4; }\r
-               if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))\r
+               if(bg->tx > 0 && bg->tx+20 <= map.width && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -400,7 +433,7 @@ void main() {
        if((keyp(80) && !keyp(72) && player.d == 0) || player.d == 3)\r
        {\r
                if(player.d == 0){ player.d = 3; }\r
-               if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))\r
+               if(bg->ty >= 0 && bg->ty+15 < map.height && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -414,7 +447,7 @@ void main() {
                                player.q++;\r
                        } else { player.q = 1; player.d = 0; player.ty++; }\r
                }\r
-               else if(player.ty < MAPY && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))\r
+               else if(player.ty < map.height && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -441,7 +474,7 @@ void main() {
        if((keyp(72) && !keyp(80) && player.d == 0) || player.d == 1)\r
        {\r
                if(player.d == 0){ player.d = 1; }\r
-               if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))\r
+               if(bg->ty > 0 && bg->ty+15 <= map.height && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))\r
                {\r
                        if(player.q<=(TILEWH/SPEED))\r
                        {\r
@@ -489,7 +522,17 @@ void main() {
                nosound();\r
        }\r
        if(player.q == (TILEWH/SPEED)+1 && player.d > 0 && (player.triggerx == 5 && player.triggery == 5)){ player.hp--; }\r
-       //if(keyp(0x0E)) while(1){ if(xmsmalloc(24)) break; }\r
+       //if(keyp(0x0E)) while(1){ if(xmsmalloc(24)) break; }
+       if(keyp(87))
+       {
+               modexLeave();\r
+               setkb(0);
+               __asm
+               {
+                       mov ah,31h
+                       int 21h
+               }
+       }\r
        }\r
 \r
        /* fade back to text mode */\r
@@ -519,13 +562,7 @@ void main() {
        //xmsfree(spri);\r
        //xmsfree(mask);\r
        //xmsreport();\r
-       if(isEMS())\r
-       {\r
-               printf("%d\n", get_emem());\r
-               printf("%d\n", coretotalEMS());\r
-               dealloc_emem(emmhandle);\r
-               printf("%d\n", coretotalEMS());\r
-       }\r
+       //emmclose(emmhandle);\r
        switch(detectcpu())\r
        {\r
                case 0: cpus = "8086/8088 or 186/88"; break;\r
@@ -591,7 +628,7 @@ initMap(map_t *map) {
        map->tiles->rows = 1;\r
        map->tiles->cols = 2;\r
 \r
-       i=0;\r
+       /*i=0;\r
        for(y=0; y<TILEWH; y++) {\r
        for(x=0; x<(TILEWH*2); x++) {\r
                if(x<TILEWH)\r
@@ -600,7 +637,7 @@ initMap(map_t *map) {
                  map->tiles->data->data[i] = 0;//0x34;\r
                i++;\r
        }\r
-       }\r
+       }*/\r
 \r
        i=0;\r
        for(y=0; y<map->height; y++) {\r
@@ -777,6 +814,13 @@ mapDrawCol(map_view_t *mv, int tx, int ty, word x) {
        i += mv->map->width;\r
        }\r
 }\r
+\r
+void qclean()\r
+{\r
+       modexLeave();\r
+       setkb(0);\r
+}\r
+\r
 void\r
 animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */sword d, short scrolloffsetswitch, int x, int y, int ls, int lp, bitmap_t *bmp)\r
 {\r