From: sparky4 Date: Thu, 26 Jan 2017 15:12:34 +0000 (-0600) Subject: proper sprite loading added wwwwwww X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=56710ee126bdba751512938e8c3ebce1cf34f746;p=16.git proper sprite loading added wwwwwww --- diff --git a/DEBUG.16W b/DEBUG.16W new file mode 100755 index 00000000..927f74dc --- /dev/null +++ b/DEBUG.16W @@ -0,0 +1,210 @@ +Seg:0 Size:9973 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0000 +Seg:27ba Size:36 Owner:0x0 ++ +Seg:27de Size:256 Owner:0x1984 +++++ +Seg:28de Size:256 Owner:0x1776 +++++ +Seg:29de Size:256 Owner:0x1778 ++++++ +Seg:2ade Size:256 Owner:0x177a +++++ +Seg:2bde Size:256 Owner:0x177c +++++ +Seg:2cde Size:256 Owner:0x177e +++++ +Seg:2dde Size:256 Owner:0x1780 +++++ +Seg:2ede Size:256 Owner:0x1782 ++++++ +Seg:2fde Size:256 Owner:0x1784 +++++ +Seg:30de Size:256 Owner:0x1786 +++++ +Seg:31de Size:256 Owner:0x1788 +++++ +Seg:32de Size:256 Owner:0x178a +++++ +Seg:33de Size:256 Owner:0x178c ++++++ +Seg:34de Size:256 Owner:0x178e +++++ +Seg:35de Size:256 Owner:0x1790 +++++ +Seg:36de Size:256 Owner:0x1792 +++++ +Seg:37de Size:256 Owner:0x1794 +++++ +Seg:38de Size:256 Owner:0x1796 ++++++ +Seg:39de Size:256 Owner:0x1798 +++++ +Seg:3ade Size:256 Owner:0x179a +++++ +Seg:3bde Size:256 Owner:0x179c +++++ +Seg:3cde Size:256 Owner:0x179e +++++ +Seg:3dde Size:256 Owner:0x17a0 ++++++ +Seg:3ede Size:256 Owner:0x17a2 +++++ +Seg:3fde Size:256 Owner:0x17a4 +++++ +Seg:40de Size:256 Owner:0x17a6 +++++ +Seg:41de Size:256 Owner:0x17a8 +++++ +Seg:42de Size:256 Owner:0x17aa ++++++ +Seg:43de Size:256 Owner:0x17ac +++++ +Seg:44de Size:256 Owner:0x17ae +++++ +Seg:45de Size:256 Owner:0x17b0 +++++ +Seg:46de Size:256 Owner:0x17b2 +++++ +Seg:47de Size:256 Owner:0x17b4 ++++++ +Seg:48de Size:256 Owner:0x17b6 +++++ +Seg:49de Size:256 Owner:0x17b8 +++++ +Seg:4ade Size:256 Owner:0x17ba +++++ +Seg:4bde Size:256 Owner:0x17bc +++++ +Seg:4cde Size:256 Owner:0x17be ++++++ +Seg:4dde Size:256 Owner:0x17c0 +++++ +Seg:4ede Size:256 Owner:0x17c2 +++++ +Seg:4fde Size:256 Owner:0x17c4 +++++ +Seg:50de Size:256 Owner:0x17c6 +++++ +Seg:51de Size:256 Owner:0x17c8 ++++++ +Seg:52de Size:256 Owner:0x17ca +++++ +Seg:53de Size:256 Owner:0x17cc +++++ +Seg:54de Size:256 Owner:0x17ce +++++ +Seg:55de Size:256 Owner:0x17d0 +++++ +Seg:56de Size:256 Owner:0x17d2 ++++++ +Seg:57de Size:256 Owner:0x17d4 +++++ +Seg:58de Size:256 Owner:0x17d6 +++++ +Seg:59de Size:256 Owner:0x17d8 +++++ +Seg:5ade Size:256 Owner:0x17da +++++ +Seg:5bde Size:256 Owner:0x17dc ++++++ +Seg:5cde Size:256 Owner:0x17de +++++ +Seg:5dde Size:256 Owner:0x17e0 +++++ +Seg:5ede Size:256 Owner:0x17e2 +++++ +Seg:5fde Size:256 Owner:0x17e4 +++++ +Seg:60de Size:256 Owner:0x17e6 ++++++ +Seg:61de Size:256 Owner:0x17e8 +++++ +Seg:62de Size:256 Owner:0x17ea +++++ +Seg:63de Size:256 Owner:0x17ec +++++ +Seg:64de Size:256 Owner:0x17ee +++++ +Seg:65de Size:256 Owner:0x17f0 ++++++ +Seg:66de Size:256 Owner:0x17f2 +++++ +Seg:67de Size:256 Owner:0x17f4 +++++ +Seg:68de Size:256 Owner:0x17f6 +++++ +Seg:69de Size:256 Owner:0x17f8 +++++ +Seg:6ade Size:256 Owner:0x17fa ++++++ +Seg:6bde Size:256 Owner:0x17fc +++++ +Seg:6cde Size:256 Owner:0x17fe +++++ +Seg:6dde Size:256 Owner:0x1800 +++++ +Seg:6ede Size:256 Owner:0x1802 +++++ +Seg:6fde Size:256 Owner:0x1804 ++++++ +Seg:70de Size:256 Owner:0x1806 +++++ +Seg:71de Size:256 Owner:0x1808 +++++ +Seg:72de Size:256 Owner:0x180a +++++ +Seg:73de Size:256 Owner:0x180c +++++ +Seg:74de Size:256 Owner:0x180e ++++++ +Seg:75de Size:256 Owner:0x1810 +++++ +Seg:76de Size:256 Owner:0x1812 +++++ +Seg:77de Size:256 Owner:0x1814 +++++ +Seg:78de Size:256 Owner:0x1816 +++++ +Seg:79de Size:256 Owner:0x1818 ++++++ +Seg:7ade Size:256 Owner:0x181a +++++ +Seg:7bde Size:256 Owner:0x181c +++++ +Seg:7cde Size:256 Owner:0x181e +++++ +Seg:7dde Size:256 Owner:0x1820 +++++ +Seg:7ede Size:256 Owner:0x1822 ++++++ +Seg:7fde Size:256 Owner:0x1824 +++++ +Seg:80de Size:256 Owner:0x1826 +++++ +Seg:81de Size:256 Owner:0x1828 +++++ +Seg:82de Size:256 Owner:0x182a +++++ +Seg:83de Size:256 Owner:0x182c ++++++ +Seg:84de Size:256 Owner:0x182e +++++ +Seg:85de Size:256 Owner:0x1830 +++++ +Seg:86de Size:256 Owner:0x1832 +++++ +Seg:87de Size:256 Owner:0x1834 +++++ +Seg:88de Size:256 Owner:0x1836 ++++++ +Seg:89de Size:256 Owner:0x1838 +++++ +Seg:8ade Size:256 Owner:0x183a +++++ +Seg:8bde Size:256 Owner:0x183c +++++ +Seg:8cde Size:401 Owner:0xef0c +++++++ +Seg:b7de Size:18465 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W new file mode 100755 index 00000000..21a34df4 --- /dev/null +++ b/HEAP.16W @@ -0,0 +1,69 @@ + + == default == + + FREE block at 27dc0016 of size 68 + USED block at 27dc005a of size 50 + USED block at 27dc008c of size 50 + USED block at 27dc00be of size 50 + USED block at 27dc00f0 of size 50 + USED block at 27dc0122 of size 50 + USED block at 27dc0154 of size 50 + USED block at 27dc0186 of size 50 + USED block at 27dc01b8 of size 50 + USED block at 27dc01ea of size 50 + USED block at 27dc021c of size 50 + USED block at 27dc024e of size 50 + USED block at 27dc0280 of size 50 + FREE block at 27dc02b2 of size 14 + USED block at 27dc02c0 of size 20 + USED block at 27dc02d4 of size 136 + FREE block at 27dc035c of size 7328 +OK - end of heap + + == near == + + USED block at 17dbefa6 of size 12 + USED block at 17dbefb2 of size 330 + USED block at 17dbf0fc of size 52 + USED block at 17dbf130 of size 20 + USED block at 17dbf144 of size 20 + USED block at 17dbf158 of size 20 + USED block at 17dbf16c of size 20 + USED block at 17dbf180 of size 20 + USED block at 17dbf194 of size 3688 +OK - end of heap + + == far == + + USED block at 27dc0016 of size 68 + USED block at 27dc005a of size 50 + USED block at 27dc008c of size 50 + USED block at 27dc00be of size 50 + USED block at 27dc00f0 of size 50 + USED block at 27dc0122 of size 50 + USED block at 27dc0154 of size 50 + USED block at 27dc0186 of size 50 + USED block at 27dc01b8 of size 50 + USED block at 27dc01ea of size 50 + USED block at 27dc021c of size 50 + USED block at 27dc024e of size 50 + USED block at 27dc0280 of size 50 + USED block at 27dc02b2 of size 14 + USED block at 27dc02c0 of size 20 + USED block at 27dc02d4 of size 136 + USED block at 27dc035c of size 7328 +OK - end of heap + +Memory Type Total Used Free +---------------- -------- -------- -------- +Default 8166 756 7410 +Near 4182 494 3688 +Far 8166 756 7410 +---------------- -------- -------- -------- +coreleft = 3686 +farcoreleft = 35502 +GetFreeSize = 31836 +GetNearFreeSize = 3688 +GetFarFreeSize = 31836 +memavl = 3686 +stackavail = 31557 diff --git a/MEMINFO.16W b/MEMINFO.16W new file mode 100755 index 00000000..e69de29b diff --git a/MMDUMP.16W b/MMDUMP.16W new file mode 100755 index 00000000..9793e6ef Binary files /dev/null and b/MMDUMP.16W differ diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 730e7f96..2021b877 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -471,6 +471,9 @@ typedef struct __SEGA *grsegs[NUMCHUNKS]; byte far grneeded[NUMCHUNKS]; huffnode huffnode; + + //TODO: extend! and learn from keen/wolf/catacomb's code wwww + memptr spribuff; } ca_t; //========================================================================== diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 63942a08..f22b7772 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -284,11 +284,10 @@ void modexHiganbanaPageSetup(video_t *video) (video->page[1]) = modexNextPage(&(video->page[0])); video->num_of_pages++; //0000 (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), (video->page[0]).width, TILEWH*4); video->num_of_pages++; //0000 (video->page[3]) = (video->page[2]); video->num_of_pages++; - (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), TILEWH*4, TILEWH*4); video->num_of_pages++; -// (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].width, 176); video->num_of_pages++; - (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].sw, 208); video->num_of_pages++; -// (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), video->page[0].width, 172); video->num_of_pages++; -// (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), 72, 128); video->num_of_pages++; +//// (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), TILEWH*4, TILEWH*4); video->num_of_pages++; +//// (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].sw, 208); video->num_of_pages++; + (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), video->page[0].width, 96); video->num_of_pages++; + (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].width, video->page[2].height); video->num_of_pages++; modexCalcVmemRemain(video); video->p=0; video->r=1; diff --git a/src/lib/16_vrs.c b/src/lib/16_vrs.c index f77119af..41ef537e 100755 --- a/src/lib/16_vrs.c +++ b/src/lib/16_vrs.c @@ -21,6 +21,63 @@ */ #include "src/lib/16_vrs.h" +void VRS_ReadVRS(char *filename, entity_t *enti, global_game_variables_t *gvar){ VRS_OpenVRS(filename, enti, 1, 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) +{ + //memptr big buffer; + static struct vrs_container vrs; + vrl1_vgax_offset_t **vrl_line_offsets; + uint16_t far *vrl_id_iter; + uint32_t far *vrl_headers_offsets; + struct vrl1_vgax_header far *curr_vrl; + uint32_t vrl_size; + int num_of_vrl,i; + int size=0; + + switch(rlsw) + { + case 1: + CA_ReadFile(filename, &gvar->ca.spribuff, gvar); + break; + case 0: + CA_LoadFile(filename, &gvar->ca.spribuff, gvar); + break; + } + + // Insert sanity cheks later + vrs.buffer = gvar->ca.spribuff; + vrs.data_size = size - sizeof(struct vrl1_vgax_header); + num_of_vrl = 0; + vrl_id_iter = (uint16_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]); + 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); + + vrl_headers_offsets = (uint32_t far *)(vrs.buffer + vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]); + // Calculate line offsets for each vrl + for(i = 0; i < num_of_vrl; i++){ + curr_vrl = (struct vrl1_vgax_header far *)(vrs.buffer + vrl_headers_offsets[i]); + + // Calc. vrl size as (next_offset - curr_offset) + if (i != num_of_vrl - 1){ + vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); + } + // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset) + else{ + vrl_size = vrs.vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header); + } + vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size); + } + vrs.vrl_line_offsets = vrl_line_offsets; + + enti->spri->spritesheet = &vrs; + enti->spri->sprite_vrl_cont = malloc(sizeof(struct vrl_container)); +} + // Read .vrs file into far memory int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container *vrs_cont){ int fd; diff --git a/src/lib/16_vrs.h b/src/lib/16_vrs.h index 054377b1..cb5495bb 100755 --- a/src/lib/16_vrs.h +++ b/src/lib/16_vrs.h @@ -61,7 +61,10 @@ struct vrl_container{ * Out: * + int - 0 on succes, 1 on failure */ -int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container *vrs_cont); +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); +void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_variables_t *gvar); +//int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container *vrs_cont); /* Seek and return a specified .vrl blob from .vrs blob in memory * In: diff --git a/src/lib/doslib b/src/lib/doslib index c87e1158..82810640 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit c87e11580abd698aa834d9ec65dee4ed47009f0a +Subproject commit 82810640576d089bbc4b382b3318a41679ff2817 diff --git a/src/vrstest.c b/src/vrstest.c index 18353afb..d879f659 100755 --- a/src/vrstest.c +++ b/src/vrstest.c @@ -44,20 +44,19 @@ void main() //boolean baka; entity_t enti; //vrl1_vgax_offset_t * off, *off1; - struct vrs_container vrs; - vrl1_vgax_offset_t **vrl_line_offsets; +/* struct vrs_container vrs; vrl1_vgax_offset_t **vrl_line_offsets; uint32_t far *vrl_headers_offsets; uint16_t far *vrl_id_iter; uint32_t vrl_size; int num_of_vrl; struct vrl1_vgax_header far *curr_vrl; int size=0; - dbg_nointest=0; +*/ + dbg_nointest=0; Startup16(&gvar); - // What should be done by read_vrs: - CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &gvar); +/* CA_LoadFile("data/spri/chikyuu.vrs", &bigbuffer, &gvar); // Insert sanity cheks later vrs.buffer = bigbuffer; @@ -93,7 +92,8 @@ void main() enti.spri->spritesheet = &vrs; - enti.spri->sprite_vrl_cont = malloc(sizeof(struct vrl_container)); + enti.spri->sprite_vrl_cont = malloc(sizeof(struct vrl_container));*/ + VRS_LoadVRS("data/spri/chikyuu.vrs", &enti, &gvar); i = set_anim_by_id((enti.spri), 31); if (i == -1) { @@ -155,7 +155,7 @@ void main() MM_Report_(&gvar); Shutdown16(&gvar); free(enti.spri->sprite_vrl_cont); - free(vrl_line_offsets); + free(enti.spri->spritesheet->vrl_line_offsets); MM_FreePtr(&bigbuffer, &gvar); //MM_FreePtr(&((void __based(sega)*)enti.spri->spritesheet->buffer), &mm); //printf("CPU to VGA: %f\n", t1); @@ -167,7 +167,7 @@ void main() printf("t2: %f\n", t2); //0000 printf("gvar.video.page[0].width: %u\n", gvar.video.page[0].width); //0000 printf("gvar.video.page[0].height: %u\n", gvar.video.page[0].height); - printf("Num %d", num_of_vrl); +// printf("Num %d", num_of_vrl); // if(baka) printf("\nyay!\n"); // else printf("\npoo!\n"); } diff --git a/src/zcroll.c b/src/zcroll.c index 10e098df..1667459f 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -90,7 +90,8 @@ void main(int argc, char *argv[]) // fprintf(stderr, "yay map loaded~~\n"); // data - read_vrs(&gvar, bakapee1, player[0].enti.spri->spritesheet); + //read_vrs(&gvar, , .spri->spritesheet); + VRS_LoadVRS(bakapee1, &player[0].enti, &gvar); // input! IN_Default(0, &player,ctrl_Keyboard1); @@ -223,7 +224,8 @@ void main(int argc, char *argv[]) bakapee1=FILENAME_2; bakapee1p=FILENAME_2P; } - read_vrs(&gvar, bakapee1, player[0].enti.spri->spritesheet); + //read_vrs(&gvar, bakapee1, player[0].enti.spri->spritesheet); + VRS_ReadVRS(bakapee1, &player[0].enti, &gvar); VL_LoadPalFile(bakapee1p, &gvar.video.palette); }//JK #ifdef FADE