From 8c95ad6d75b37c4bc838d30d47a83d04f906feda Mon Sep 17 00:00:00 2001 From: sparky4 Date: Tue, 14 Mar 2017 17:24:34 -0500 Subject: [PATCH] __seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd.c ][ ca needs huge amounts of work and i should remember what needs to be done soon also i should reverify 16_in.c to make sure it can work with other code of id engine ] i hope you rest in pepperoni free(vrl_line_offsets); i cri ebrytiem --- src/lib/16_spri.c | 32 ++++++++++++++++++++++++++++++++ src/lib/16_tdef.h | 9 +++++++++ src/lib/16_vrs.c | 33 +++++++++++++++++++++++++++++++-- src/lib/scroll16.c | 5 +++++ src/vrstest.c | 4 ++++ 5 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/lib/16_spri.c b/src/lib/16_spri.c index cde64ac6..063c2cd1 100755 --- a/src/lib/16_spri.c +++ b/src/lib/16_spri.c @@ -25,7 +25,11 @@ char* get_curr_anim_name(struct sprite *spri) { // Retrive animation name list +#ifndef VRSVRLNONPTR + struct vrs_header far *vrs = spri->spritesheet->vrs_hdr; +#else struct vrs_header far *vrs = spri->spritesheet.vrs_hdr; +#endif uint32_t far *anim_names_offsets = (uint32_t far *) ((byte far *)vrs + vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_NAME_LIST]); @@ -35,7 +39,11 @@ char* get_curr_anim_name(struct sprite *spri) void init_anim(struct sprite *spri, int anim_index) { +#ifndef VRSVRLNONPTR + struct vrs_header far *vrs = spri->spritesheet->vrs_hdr; +#else struct vrs_header far *vrs = spri->spritesheet.vrs_hdr; +#endif uint32_t far *anim_lists_offsets = (uint32_t far *) ((byte far *)vrs + vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_LIST]); @@ -56,7 +64,11 @@ int set_anim_by_id(struct sprite *spri, int anim_id) { int new_anim_index = 0; int iter_id; +#ifndef VRSVRLNONPTR + struct vrs_header far *vrs = spri->spritesheet->vrs_hdr; +#else struct vrs_header far *vrs = spri->spritesheet.vrs_hdr; +#endif // Retruve animation ids list uint16_t far *anim_ids = (uint16_t far *) ((byte far *)vrs + @@ -80,7 +92,11 @@ void print_anim_ids(struct sprite *spri) { int new_anim_index = 0; int iter_id; +#ifndef VRSVRLNONPTR + struct vrs_header far *vrs = spri->spritesheet->vrs_hdr; +#else struct vrs_header far *vrs = spri->spritesheet.vrs_hdr; +#endif // Retruve animation ids list uint16_t far *anim_ids = (uint16_t far *) ((byte far *)vrs + @@ -148,7 +164,11 @@ void animate_spri(entity_t *enti, video_t *video) // Draw sprite +#ifndef VRSVRLNONPTR + j = get_vrl_by_id(enti->spri.spritesheet, enti->spri.curr_spri_id, enti->spri.sprite_vrl_cont); +#else j = get_vrl_by_id(&enti->spri.spritesheet, enti->spri.curr_spri_id, &enti->spri.sprite_vrl_cont); +#endif if(j < 0) { //Quit (gv, "Error retriving required sprite"); @@ -162,8 +182,13 @@ void animate_spri(entity_t *enti, video_t *video) else rx = -(video->page[0].dx); if (y >= enti->overdrawh) ry = (y - enti->overdrawh); else ry = -(video->page[0].dy); +#ifndef VRSVRLNONPTR + h = enti->spri.sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry; + w = (x + enti->spri.sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up +#else h = enti->spri.sprite_vrl_cont.vrl_header->height + enti->overdrawh + y - ry; w = (x + enti->spri.sprite_vrl_cont.vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up +#endif if ((rx+w) > video->page[0].width) w = video->page[0].width-rx; if ((ry+h) > video->page[0].height) h = video->page[0].height-ry; @@ -190,10 +215,17 @@ void animate_spri(entity_t *enti, video_t *video) draw_vrl1_vgax_modex( x-rx, y-ry, +#ifndef VRSVRLNONPTR + enti->spri.sprite_vrl_cont->vrl_header, + enti->spri.sprite_vrl_cont->line_offsets, + enti->spri.sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), + enti->spri.sprite_vrl_cont->data_size +#else enti->spri.sprite_vrl_cont.vrl_header, enti->spri.sprite_vrl_cont.line_offsets, enti->spri.sprite_vrl_cont.buffer + sizeof(struct vrl1_vgax_header), enti->spri.sprite_vrl_cont.data_size +#endif ); #endif if(!video->rss) diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 2d027f61..f1de2a41 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -67,6 +67,7 @@ typedef struct { //from 16_sprit.h #ifdef __WATCOMC__ #include +#define VRSVRLNONPTR typedef struct vrs_container{ // Size of a .vrs blob in memory @@ -95,9 +96,17 @@ typedef struct vrl_container{ typedef struct sprite { // VRS container from which we will extract animation and image data +#ifndef VRSVRLNONPTR + vrs_container_t *spritesheet; +#else vrs_container_t spritesheet; +#endif // Container for a vrl sprite +#ifndef VRSVRLNONPTR + vrl_container_t *sprite_vrl_cont; +#else vrl_container_t sprite_vrl_cont; +#endif // Current sprite id int curr_spri_id; // Index of a current sprite in an animation sequence diff --git a/src/lib/16_vrs.c b/src/lib/16_vrs.c index 07c3bd5d..4b2243b1 100755 --- a/src/lib/16_vrs.c +++ b/src/lib/16_vrs.c @@ -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); } void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_variables_t *gvar) { +#ifndef VRSVRLNONPTR + static struct vrs_container vrs; +#endif vrl1_vgax_offset_t **vrl_line_offsets; uint16_t far *vrl_id_iter; uint32_t far *vrl_headers_offsets; @@ -44,21 +47,37 @@ void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_varia } // Insert sanity cheks later +#ifndef VRSVRLNONPTR + vrs.buffer = gvar->ca.spribuff; + vrs.data_size = size - sizeof(struct vrl1_vgax_header); +#else enti->spri.spritesheet.buffer = gvar->ca.spribuff; enti->spri.spritesheet.data_size = size - sizeof(struct vrl1_vgax_header); +#endif num_of_vrl = 0; +#ifndef VRSVRLNONPTR + vrl_id_iter = (uint16_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); +#else vrl_id_iter = (uint16_t far *)(enti->spri.spritesheet.buffer + enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); +#endif while(vrl_id_iter[num_of_vrl]){ num_of_vrl++; } // Allocate memory for vrl line offsets table vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);//TODO: USE MM_ CA_ AND PM_ - +#ifndef VRSVRLNONPTR + vrl_headers_offsets = (uint32_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); +#else vrl_headers_offsets = (uint32_t far *)(enti->spri.spritesheet.buffer + enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); +#endif // Calculate line offsets for each vrl for(i = 0; i < num_of_vrl; i++){ +#ifndef VRSVRLNONPTR + curr_vrl = (struct vrl1_vgax_header far *)(vrs.buffer + vrl_headers_offsets[i]); +#else curr_vrl = (struct vrl1_vgax_header far *)(enti->spri.spritesheet.buffer + vrl_headers_offsets[i]); +#endif // Calc. vrl size as (next_offset - curr_offset) if (i != num_of_vrl - 1){ @@ -66,12 +85,22 @@ void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_varia } // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset) else{ +#ifndef VRSVRLNONPTR + vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); +#else vrl_size = enti->spri.spritesheet.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); +#endif } vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size); } +#ifndef VRSVRLNONPTR + vrs.vrl_line_offsets = vrl_line_offsets; + + enti->spri.spritesheet = &vrs; + enti->spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));//TODO: USE MM_ CA_ AND PM_ +#else enti->spri.spritesheet.vrl_line_offsets = vrl_line_offsets; - free(vrl_line_offsets);//TODO: USE MM_ CA_ AND PM_ +#endif } // Seek and return a specified .vrl blob from .vrs blob in far memory diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 0e73d83b..952b0f42 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -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! break; default: +#ifndef VRSVRLNONPTR + rx = (((i-1) % ((t->spri->sprite_vrl_cont->vrl_header->width)/t->tileWidth)) * t->tileWidth); + ry = (((i-1) / ((t->spri->sprite_vrl_cont->vrl_header->height)/t->tileHeight)) * t->tileHeight); +#else rx = (((i-1) % ((t->spri->sprite_vrl_cont.vrl_header->width)/t->tileWidth)) * t->tileWidth); ry = (((i-1) / ((t->spri->sprite_vrl_cont.vrl_header->height)/t->tileHeight)) * t->tileHeight); +#endif #ifndef TILERENDER if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1); #else diff --git a/src/vrstest.c b/src/vrstest.c index 69ee777a..0e3378e6 100755 --- a/src/vrstest.c +++ b/src/vrstest.c @@ -154,6 +154,10 @@ void main() MM_DumpData(&gvar); MM_Report_(&gvar); Shutdown16(&gvar); +#ifndef VRSVRLNONPTR + free(enti.spri.sprite_vrl_cont); + free(enti.spri.spritesheet->vrl_line_offsets); +#endif MM_FreePtr(&bigbuffer, &gvar); //MM_FreePtr(&((void __based(sega)*)enti.spri.spritesheet->buffer), &mm); //printf("CPU to VGA: %f\n", t1); -- 2.39.5