]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/bakapee.c
p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I...
[16.git] / src / lib / bakapee.c
index cf1dd90403c0aaa74af0520248c3f184a71bc216..0174d3c3bbf56007b70eb9f1b2955426c76fb46b 100755 (executable)
@@ -43,28 +43,42 @@ char global_temp_status_text2[512];
 #define PIXPOSX                        gvar->video.page[0].sw/2\r
 #define PIXPOSY                        gvar->video.page[0].sh/2\r
 \r
-boolean baka_FizzleFade (page_t *source, page_t *dest, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
+/*\r
+===================\r
+=\r
+= FizzleFade\r
+=\r
+= returns true if aborted\r
+=\r
+===================\r
+*/\r
+\r
+//extern       ControlInfo     c;\r
+#define PIXPOSX                        gvar->video.page[0].sw/2\r
+#define PIXPOSY                        gvar->video.page[0].sh/2\r
+\r
+boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
 {\r
-       dword           p,pixperframe;\r
+       word            p,pixperframe;\r
        unsigned        drawofs,pagedelta;\r
        byte            mask,maskb[8] = {1,2,4,8};\r
-       unsigned        x,y,frame               ,esorig;\r
+       unsigned        x,y,frame               ,esorig,q;\r
        dword           rndval;\r
-//     word TimeCount = *clockw;\r
        word screenseg = SCREENSEG;\r
 \r
-       pagedelta = (word)dest->sw*dest->sh;//(word)(source->data - dest->data);//(dest->data - source->data)\r
-       rndval = 1;     esorig = 0;\r
-       x = y = dest->dx;\r
-       pixperframe = 76800/(dword)frames;\r
+       pagedelta = dest-source;\r
+       rndval = 1;     esorig = 0; q = 16;\r
+       x = y = 0;//destpage->dx;\r
+       pixperframe = /*76800*/64000/(dword)frames;\r
 \r
 //     IN_StartAck ();\r
 \r
-//     VL_ShowPage(dest, 1, 0);\r
-//     VL_ShowPage(source, 1, 0);\r
+//     VL_ShowPage(&(gvar->video.page[0]), 1, 0);\r
+//     VL_ShowPage(&(gvar->video.page[1]), 1, 0);\r
 \r
-//     modexClearRegion(dest, 0, 0, (dest->width), (dest->height), 12);\r
-       modexClearRegion(source, 0, 0, (source->width), (source->height), 64);\r
+//     modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0);\r
+//     modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15);\r
+//     VL_SetLineWidth(80, gvar);\r
 \r
        __asm {\r
                mov     [esorig],es\r
@@ -74,7 +88,7 @@ boolean baka_FizzleFade (page_t *source, page_t *dest, unsigned frames, boolean
        do      // while (1)\r
        {\r
 sprintf(global_temp_status_text, "%u", frame);\r
-modexprint(dest, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
+modexprint(&(gvar->video.page[0]), PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
                if (abortable && kbhit())//IN_CheckAck () )\r
                        return true;\r
 \r
@@ -116,25 +130,31 @@ noxor:
                                mov     [WORD PTR rndval+2],dx\r
                        }\r
 \r
-                       if (x>dest->sw || y>dest->sh)\r
+//                     if (x>destpage->width || y>destpage->height)\r
+//                     if (x<destpage->sw || y<destpage->sh)\r
+                       if ((x>width || y>height) && (x<width*2 && y<height*2))\r
                                continue;\r
-                       drawofs = (word)(source->data)+gvar->video.ofs.ylookup[y] + (x>>2);\r
+                       drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);\r
 sprintf(global_temp_status_text, "draw - %Fp", drawofs);\r
-modexprint(dest, PIXPOSX, 16+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
+modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);\r
-modexprint(dest, PIXPOSX, 24+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
-sprintf(global_temp_status_text, "srce - %Fp", source->data);\r
-modexprint(dest, PIXPOSX, 32+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
-sprintf(global_temp_status_text, "dest - %Fp", dest->data);\r
-modexprint(dest, PIXPOSX, 40+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
+modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "srce - %Fp", source);\r
+modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "dest - %Fp", dest);\r
+modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;\r
 \r
                        //\r
                        // copy one pixel\r
                        //\r
+//*\r
                        mask = x&3;\r
                        VGAREADMAP(mask);\r
                        mask = maskb[mask];\r
                        VGAMAPMASK(mask);\r
+//*/\r
+//                     modexputPixel(&(gvar->video.page[0]), x, y, rand());\r
+//                     VL_Plot (x, y, 15, &(gvar->video.ofs));\r
 \r
                        __asm {\r
                                mov     di,[drawofs]\r
@@ -154,31 +174,43 @@ modexprint(dest, PIXPOSX, 40+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
        }\r
        return false;\r
 }\r
+\r
 #if 0\r
-boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width,unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
+boolean baka_FizzleFade (page_t *sourcepage, page_t *destpage, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
 {\r
-       int                     pixperframe;\r
+       word            p,pixperframe;\r
        unsigned        drawofs,pagedelta;\r
        byte            mask,maskb[8] = {1,2,4,8};\r
-       unsigned        x,y,p,frame;\r
+       unsigned        x,y,frame               ,esorig,q;\r
        dword           rndval;\r
-       word TimeCount = *clockw;\r
+       unsigned        source,dest;\r
+//     word TimeCount = *clockw;\r
        word screenseg = SCREENSEG;\r
+       source = ((word)sourcepage->data); dest = ((word)destpage->data);\r
 \r
-       pagedelta = dest-source;\r
-       rndval = 1;\r
-       x = y = 0;\r
-       pixperframe = 64000/frames;\r
+       pagedelta = dest-source;//(word)(source->data - dest->data);//(dest->data - source->data)\r
+       rndval = 1;     esorig = 0; q = 16;\r
+       x = y = destpage->dx;\r
+       pixperframe = /*76800*/64000/(dword)frames;\r
 \r
-       VGAmodeX(0, 0, gvar);\r
 //     IN_StartAck ();\r
-//     VL_ShowPage((page_t *)dest, 1, 0);\r
-       VGAmodeX(1, 0, gvar);\r
 \r
-       TimeCount=frame=0;\r
+//     VL_ShowPage(destpage, 1, 0);\r
+//     VL_ShowPage(sourcepage, 1, 0);\r
+\r
+//     modexClearRegion(destpage, 0, 0, (destpage->width), (destpage->height), 12);\r
+       modexClearRegion(sourcepage, 0, 0, (sourcepage->width), (sourcepage->height), 64);\r
+\r
+       __asm {\r
+               mov     [esorig],es\r
+       }\r
+//     TimeCount=\r
+       frame=0;\r
        do      // while (1)\r
        {\r
-               if (abortable && !kbhit())//IN_CheckAck () )\r
+sprintf(global_temp_status_text, "%u", frame);\r
+modexprint(destpage, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
+               if (abortable && kbhit())//IN_CheckAck () )\r
                        return true;\r
 \r
                __asm {\r
@@ -191,31 +223,51 @@ boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width,unsigned
                                //\r
                                // seperate random value into x/y pair\r
                                //\r
-                                       mov     ax,[WORD PTR rndval]\r
-                                       mov     dx,[WORD PTR rndval+2]\r
-                                       mov     bx,ax\r
-                                       dec     bl\r
-                                       mov     [BYTE PTR y],bl                 // low 8 bits - 1 = y xoordinate\r
-                                       mov     bx,ax\r
-                                       mov     cx,dx\r
-                                       mov     [BYTE PTR x],ah                 // next 9 bits = x xoordinate\r
-                                       mov     [BYTE PTR x+1],dl\r
+                               mov     ax,[WORD PTR rndval]\r
+                               mov     dx,[WORD PTR rndval+2]\r
+                               mov     bx,ax\r
+                               dec     bl\r
+                               mov     [BYTE PTR y],bl                 // low 8 bits - 1 = y xoordinate\r
+                               mov     bx,ax\r
+                               mov     cx,dx\r
+                               mov     [BYTE PTR x],ah                 // next 9 bits = x xoordinate\r
+                               mov     [BYTE PTR x+1],dl\r
                                //\r
                                // advance to next random element\r
                                //\r
-                                       shr     dx,1\r
-                                       rcr     ax,1\r
-                                       jnc     noxor\r
-                                       xor     dx,0x0001\r
-                                       xor     ax,0x2000\r
+                               shr     dx,1\r
+                               rcr     ax,1\r
+                               jnc     noxor\r
+                               xor     dx,0x0001\r
+                               xor     ax,0x2000\r
+#ifdef __BORLANDC__\r
+                       }\r
+#endif\r
 noxor:\r
-                                       mov     [WORD PTR rndval],ax\r
-                                       mov     [WORD PTR rndval+2],dx\r
+#ifdef __BORLANDC__\r
+                       __asm {\r
+#endif\r
+                               mov     [WORD PTR rndval],ax\r
+                               mov     [WORD PTR rndval+2],dx\r
                        }\r
 \r
+//                     if (x>destpage->width || y>destpage->height)\r
+//                     if (x<destpage->sw || y<destpage->sh)\r
                        if (x>width || y>height)\r
                                continue;\r
-                       drawofs = source+gvar->video.ofs.ylookup[y] + (x>>2);\r
+                       drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);\r
+sprintf(global_temp_status_text, "draw - %Fp", drawofs);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "srcp - %Fp", sourcepage->data);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "desp - %Fp", destpage->data);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "srce - %Fp", source);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
+sprintf(global_temp_status_text, "dest - %Fp", dest);\r
+modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;\r
 \r
                        //\r
                        // copy one pixel\r
@@ -236,8 +288,11 @@ noxor:
                                return false;\r
                }\r
                frame++;\r
-//             while (TimeCount<frame){}//;            // don't go too fast\r
+//--           while (TimeCount<frame){}//;            // don't go too fast\r
        } while (1);\r
+       __asm {\r
+               mov     es,[esorig]\r
+       }\r
        return false;\r
 }\r
 #endif\r
@@ -518,7 +573,7 @@ void ding(page_t *page, bakapee_t *pee, word q)
                        modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");\r
                break;\r
                case 9:\r
-                       //baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, page->sw, page->sh, false, ggvv);\r
+                       baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, vga_state.vga_width, vga_state.vga_height, 70, true, ggvv);\r
 //                     modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi start");\r
 //                     if(!baka_FizzleFade ((unsigned)page, (unsigned)page, page->width, page->height, 70, false, ggvv))\r
                break;\r