]> 4ch.mooo.com Git - 16.git/commitdiff
__seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd...
authorsparky4 <sparky4@cock.li>
Tue, 14 Mar 2017 22:24:34 +0000 (17:24 -0500)
committersparky4 <sparky4@cock.li>
Tue, 14 Mar 2017 22:24:34 +0000 (17:24 -0500)
src/lib/16_spri.c
src/lib/16_tdef.h
src/lib/16_vrs.c
src/lib/scroll16.c
src/vrstest.c

index cde64ac644a96ca318e0d296f53ba0017375e31a..063c2cd1f83f3ae42108c42b0ab3b1d46d69f7b1 100755 (executable)
 char* get_curr_anim_name(struct sprite *spri)\r
 {\r
        // Retrive animation name list\r
+#ifndef VRSVRLNONPTR\r
+       struct vrs_header far *vrs = spri->spritesheet->vrs_hdr;\r
+#else\r
        struct vrs_header far *vrs = spri->spritesheet.vrs_hdr;\r
+#endif\r
        uint32_t far *anim_names_offsets =      (uint32_t far *)\r
                                                ((byte far *)vrs +\r
                                                 vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_NAME_LIST]);\r
@@ -35,7 +39,11 @@ char* get_curr_anim_name(struct sprite *spri)
 \r
 void init_anim(struct sprite *spri, int anim_index)\r
 {\r
+#ifndef VRSVRLNONPTR\r
+       struct vrs_header far *vrs = spri->spritesheet->vrs_hdr;\r
+#else\r
        struct vrs_header far *vrs = spri->spritesheet.vrs_hdr;\r
+#endif\r
        uint32_t far *anim_lists_offsets =      (uint32_t far *)\r
                                                ((byte far *)vrs +\r
                                                 vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_LIST]);\r
@@ -56,7 +64,11 @@ int set_anim_by_id(struct sprite *spri, int anim_id)
 {\r
        int new_anim_index = 0;\r
        int iter_id;\r
+#ifndef VRSVRLNONPTR\r
+       struct vrs_header far *vrs = spri->spritesheet->vrs_hdr;\r
+#else\r
        struct vrs_header far *vrs = spri->spritesheet.vrs_hdr;\r
+#endif\r
        // Retruve animation ids list\r
         uint16_t far *anim_ids =       (uint16_t far *)\r
                                        ((byte far *)vrs +\r
@@ -80,7 +92,11 @@ void print_anim_ids(struct sprite *spri)
 {\r
        int new_anim_index = 0;\r
        int iter_id;\r
+#ifndef VRSVRLNONPTR\r
+       struct vrs_header far *vrs = spri->spritesheet->vrs_hdr;\r
+#else\r
        struct vrs_header far *vrs = spri->spritesheet.vrs_hdr;\r
+#endif\r
        // Retruve animation ids list\r
         uint16_t far *anim_ids =       (uint16_t far *)\r
                                        ((byte far *)vrs +\r
@@ -148,7 +164,11 @@ void animate_spri(entity_t *enti, video_t *video)
 \r
 \r
        // Draw sprite\r
+#ifndef VRSVRLNONPTR\r
+       j = get_vrl_by_id(enti->spri.spritesheet, enti->spri.curr_spri_id, enti->spri.sprite_vrl_cont);\r
+#else\r
        j = get_vrl_by_id(&enti->spri.spritesheet, enti->spri.curr_spri_id, &enti->spri.sprite_vrl_cont);\r
+#endif\r
        if(j < 0)\r
        {\r
                //Quit (gv, "Error retriving required sprite");\r
@@ -162,8 +182,13 @@ void animate_spri(entity_t *enti, video_t *video)
                        else rx = -(video->page[0].dx);\r
                if (y >= enti->overdrawh) ry = (y - enti->overdrawh);\r
                        else ry = -(video->page[0].dy);\r
+#ifndef VRSVRLNONPTR\r
+               h = enti->spri.sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry;\r
+               w = (x + enti->spri.sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up\r
+#else\r
                h = enti->spri.sprite_vrl_cont.vrl_header->height + enti->overdrawh + y - ry;\r
                w = (x + enti->spri.sprite_vrl_cont.vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up\r
+#endif\r
                if ((rx+w) > video->page[0].width) w = video->page[0].width-rx;\r
                if ((ry+h) > video->page[0].height) h = video->page[0].height-ry;\r
 \r
@@ -190,10 +215,17 @@ void animate_spri(entity_t *enti, video_t *video)
        draw_vrl1_vgax_modex(\r
                x-rx,\r
                y-ry,\r
+#ifndef VRSVRLNONPTR\r
+               enti->spri.sprite_vrl_cont->vrl_header,\r
+               enti->spri.sprite_vrl_cont->line_offsets,\r
+               enti->spri.sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header),\r
+               enti->spri.sprite_vrl_cont->data_size\r
+#else\r
                enti->spri.sprite_vrl_cont.vrl_header,\r
                enti->spri.sprite_vrl_cont.line_offsets,\r
                enti->spri.sprite_vrl_cont.buffer + sizeof(struct vrl1_vgax_header),\r
                enti->spri.sprite_vrl_cont.data_size\r
+#endif\r
        );\r
 #endif\r
        if(!video->rss)\r
index 2d027f613a2f9391aacf554eae5e0c59cf808620..f1de2a41fe3203b3f0a12fce2e308fb00b9aeb5b 100755 (executable)
@@ -67,6 +67,7 @@ typedef struct {
 //from 16_sprit.h\r
 #ifdef __WATCOMC__\r
 #include <hw/vga/vrl.h>\r
+#define VRSVRLNONPTR\r
 \r
 typedef struct vrs_container{\r
        // Size of a .vrs blob in memory\r
@@ -95,9 +96,17 @@ typedef struct vrl_container{
 typedef struct sprite\r
 {\r
        // VRS container from which we will extract animation and image data\r
+#ifndef VRSVRLNONPTR\r
+       vrs_container_t *spritesheet;\r
+#else\r
        vrs_container_t spritesheet;\r
+#endif\r
        // Container for a vrl sprite\r
+#ifndef VRSVRLNONPTR\r
+       vrl_container_t *sprite_vrl_cont;\r
+#else\r
        vrl_container_t sprite_vrl_cont;\r
+#endif\r
        // Current sprite id\r
        int curr_spri_id;\r
        // Index of a current sprite in an animation sequence\r
index 07c3bd5da2424efc53eeb19d89ae9cbc7c110df4..4b2243b1f6996013a6e24a48fe8c802ba60a67fc 100755 (executable)
@@ -25,6 +25,9 @@ void VRS_ReadVRS(char *filename, entity_t *enti, global_game_variables_t *gvar){
 void VRS_LoadVRS(char *filename, entity_t *enti, global_game_variables_t *gvar){       VRS_OpenVRS(filename, enti, 0, gvar);   }\r
 void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_variables_t *gvar)\r
 {\r
+#ifndef VRSVRLNONPTR\r
+       static struct vrs_container vrs;\r
+#endif\r
        vrl1_vgax_offset_t **vrl_line_offsets;\r
        uint16_t far *vrl_id_iter;\r
        uint32_t far *vrl_headers_offsets;\r
@@ -44,21 +47,37 @@ void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_varia
        }\r
 \r
        // Insert sanity cheks later\r
+#ifndef VRSVRLNONPTR\r
+       vrs.buffer = gvar->ca.spribuff;\r
+       vrs.data_size = size - sizeof(struct vrl1_vgax_header);\r
+#else\r
        enti->spri.spritesheet.buffer = gvar->ca.spribuff;\r
        enti->spri.spritesheet.data_size = size - sizeof(struct vrl1_vgax_header);\r
+#endif\r
        num_of_vrl = 0;\r
+#ifndef VRSVRLNONPTR\r
+       vrl_id_iter = (uint16_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
+#else\r
        vrl_id_iter = (uint16_t far *)(enti->spri.spritesheet.buffer + enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
+#endif\r
        while(vrl_id_iter[num_of_vrl]){\r
                num_of_vrl++;\r
        }\r
 \r
        // Allocate memory for vrl line offsets table\r
        vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);//TODO: USE MM_ CA_ AND PM_\r
-\r
+#ifndef VRSVRLNONPTR\r
+       vrl_headers_offsets = (uint32_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
+#else\r
        vrl_headers_offsets = (uint32_t far *)(enti->spri.spritesheet.buffer + enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
+#endif\r
        // Calculate line offsets for each vrl\r
        for(i = 0; i < num_of_vrl; i++){\r
+#ifndef VRSVRLNONPTR\r
+               curr_vrl = (struct vrl1_vgax_header far *)(vrs.buffer + vrl_headers_offsets[i]);\r
+#else\r
                curr_vrl = (struct vrl1_vgax_header far *)(enti->spri.spritesheet.buffer + vrl_headers_offsets[i]);\r
+#endif\r
 \r
                // Calc. vrl size as (next_offset - curr_offset)\r
                if (i != num_of_vrl - 1){\r
@@ -66,12 +85,22 @@ void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_varia
                }\r
                // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)\r
                else{\r
+#ifndef VRSVRLNONPTR\r
+                       vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
+#else\r
                        vrl_size = enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
+#endif\r
                }\r
                vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);\r
        }\r
+#ifndef VRSVRLNONPTR\r
+       vrs.vrl_line_offsets = vrl_line_offsets;\r
+\r
+       enti->spri.spritesheet = &vrs;\r
+       enti->spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));//TODO: USE MM_ CA_ AND PM_\r
+#else\r
        enti->spri.spritesheet.vrl_line_offsets = vrl_line_offsets;\r
-       free(vrl_line_offsets);//TODO: USE MM_ CA_ AND PM_\r
+#endif\r
 }\r
 \r
 // Seek and return a specified .vrl blob from .vrs blob in far memory\r
index 0e73d83b99492fb9eec83d1e8c5d7c8801fa6d82..952b0f423afd01b7c3e4db7a87cf9a458d4d5c05 100755 (executable)
@@ -576,8 +576,13 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
                        modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!\r
                break;\r
                default:\r
+#ifndef VRSVRLNONPTR\r
+                       rx = (((i-1) % ((t->spri->sprite_vrl_cont->vrl_header->width)/t->tileWidth)) * t->tileWidth);\r
+                       ry = (((i-1) / ((t->spri->sprite_vrl_cont->vrl_header->height)/t->tileHeight)) * t->tileHeight);\r
+#else\r
                        rx = (((i-1) % ((t->spri->sprite_vrl_cont.vrl_header->width)/t->tileWidth)) * t->tileWidth);\r
                        ry = (((i-1) / ((t->spri->sprite_vrl_cont.vrl_header->height)/t->tileHeight)) * t->tileHeight);\r
+#endif\r
 #ifndef TILERENDER\r
                        if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1);\r
 #else\r
index 69ee777aa07db73990e8dbf0e454509e8d24dc39..0e3378e6482016edcd0c3778de0775e0730c53b6 100755 (executable)
@@ -154,6 +154,10 @@ void main()
        MM_DumpData(&gvar);\r
        MM_Report_(&gvar);\r
        Shutdown16(&gvar);\r
+#ifndef VRSVRLNONPTR\r
+       free(enti.spri.sprite_vrl_cont);\r
+       free(enti.spri.spritesheet->vrl_line_offsets);\r
+#endif\r
        MM_FreePtr(&bigbuffer, &gvar);\r
        //MM_FreePtr(&((void __based(sega)*)enti.spri.spritesheet->buffer), &mm);\r
        //printf("CPU to VGA: %f\n", t1);\r