From 116122d95c9946631ef52326f0d412ec5772bf20 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Mon, 9 Jan 2017 09:14:11 -0600 Subject: [PATCH] wwww --- MEMINFO.16W | 0 src/0.c | 176 +++++++++++++++++++++++++++------------------ src/lib/16_tail.h | 4 +- src/lib/scroll16.c | 37 ++++++++++ src/lib/scroll16.h | 1 + src/tesuto.h | 17 +++++ 6 files changed, 164 insertions(+), 71 deletions(-) create mode 100755 MEMINFO.16W diff --git a/MEMINFO.16W b/MEMINFO.16W new file mode 100755 index 00000000..e69de29b diff --git a/src/0.c b/src/0.c index c57cf799..8f18cd8d 100755 --- a/src/0.c +++ b/src/0.c @@ -7,31 +7,38 @@ #define FILENAME_1 "data/aconita.vrl" #define FILENAME_2 "data/aconita.pal" +//#define FILENAME_2 "data/default.pal" + +//#define PATTERN +#define DRAWCORNERBOXES \ +modexClearRegion(&gvar.video.page[0], 16, 16, 16, 16, 15); \ +modexClearRegion(&gvar.video.page[0], gvar.video.page[0].sw, gvar.video.page[0].sh, 16, 16, 15); static unsigned char palette[768]; -global_game_variables_t gvar; player_t player[MaxPlayers]; +map_view_t mv[4]; +pan_t pan; -int main(int argc,char **argv) { +int main(int argc,char **argv) +{ + static global_game_variables_t gvar; struct vrl1_vgax_header *vrl_header; vrl1_vgax_offset_t *vrl_lineoffs; unsigned char *buffer; unsigned int bufsz; - int fd; + int fd, i; char *bakapee1,*bakapee2; - word pagenum=0; + boolean anim=1,noanim=1; + pan.pn=0; bakapee1=malloc(64); bakapee2=malloc(1024); - IN_Startup(); - IN_Default(0,&player,ctrl_Keyboard1); - IN_initplayer(&player, 0); - - if (argc < 3) { - fprintf(stderr,"drawvrl \n"); + if (argc < 2) { + //fprintf(stderr,"drawvrl \n palette file optional\n"); bakapee1 = FILENAME_1;//"data/aconita.vrl"; bakapee2 = FILENAME_2;//"data/aconita.pal"; + }else{ if(argv[1]) bakapee1 = argv[1]; if(argv[2]) bakapee2 = argv[2]; @@ -83,13 +90,27 @@ int main(int argc,char **argv) { vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); if (vrl_lineoffs == NULL) return 1; + IN_Startup(); + IN_Default(0,&player,ctrl_Keyboard1); + IN_initplayer(&player, 0); + /* setup camera and screen~ */ modexHiganbanaPageSetup(&gvar.video); - modexShowPage(&(gvar.video.page[pagenum])); +player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx; + player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny; + modexShowPage(&(gvar.video.page[pan.pn])); + for(i=0;i> 2) + (0x10000UL - (uint16_t)gvar.video.page[1].data); @@ -121,6 +144,8 @@ int main(int argc,char **argv) { vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15! } + DRAWCORNERBOXES; + /* starting coords. note: this technique is limited to x coordinates of multiple of 4 */ x = -(gvar.video.page[0].dx); y = -(gvar.video.page[0].dy); @@ -131,74 +156,85 @@ int main(int argc,char **argv) { while(!IN_KeyDown(sc_Escape)) { IN_ReadControl(0,&player); - if(IN_KeyDown(2)){ pagenum=0; modexShowPage(&(gvar.video.page[0])); } - if(IN_KeyDown(3)){ pagenum=1; modexShowPage(&(gvar.video.page[1])); } - if(IN_KeyDown(68)) //f10 + PANKEY0EXE; + if(IN_KeyDown(68) || IN_KeyDown(sc_Space)) //f10 and space { //gvar.kurokku.fpscap=!gvar.kurokku.fpscap; + anim=!anim; IN_UserInput(1,1); } FUNCTIONKEYFUNCTIONS0EXE; + if(IN_KeyDown(sc_R)){ + gvar.video.page[0].dx=gvar.video.page[0].dy=gvar.video.page[1].dx=gvar.video.page[1].dy=16; + modexShowPage(&(gvar.video.page[pan.pn])); + player[0].q = 1; player[0].d = 2; + } //R - /* render box bounds. y does not need modification, but x and width must be multiple of 4 */ - if (x >= overdraw) rx = (x - overdraw) & (~3); - else rx = -(gvar.video.page[0].dx); - if (y >= overdraw) ry = (y - overdraw); - else ry = -(gvar.video.page[0].dy); - h = vrl_header->height + overdraw + y - ry; - w = (x + vrl_header->width + (overdraw*2) + 3/*round up*/ - rx) & (~3); - if ((rx+w) > gvar.video.page[0].width) w = gvar.video.page[0].width-rx; - if ((ry+h) > gvar.video.page[0].height) h = gvar.video.page[0].height-ry; - - /* block copy pattern to where we will draw the sprite */ - vga_setup_wm1_block_copy(); - o2 = gvar.video.page[0].pagesize; - o = (0x10000UL - (uint16_t)gvar.video.page[1].data) + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen - for (i=0;i < h;i++,o += gvar.video.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2); - /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ - vga_restore_rm0wm0(); - - /* replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) */ - vga_state.vga_draw_stride_limit = (gvar.video.page[0].width + 3/*round up*/ - x) >> 2; - vga_state.vga_draw_stride = w >> 2; - vga_state.vga_graphics_ram = omemptr + gvar.video.page[0].pagesize; - - /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ - draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); - - /* restore ptr */ - vga_state.vga_graphics_ram = omemptr; - - /* block copy to visible RAM from offscreen */ - vga_setup_wm1_block_copy(); - o = gvar.video.page[0].pagesize; // source offscreen - o2 = (ry * gvar.video.page[0].stridew) + (rx >> 2); // dest visible (original stride) - for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += gvar.video.page[0].stridew) vga_wm1_mem_block_copy(o2,o,w >> 2); - /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ - vga_restore_rm0wm0(); - - /* restore stride */ - vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gvar.video.page[0].stridew; - - /* step */ - x += xdir; y += ydir; - if ((x + vrl_header->width) >= ((gvar.video.page[0].width + gvar.video.page[0].dx) - 1) || x == -(gvar.video.page[0].dx)) - xdir = -xdir; - if ((y + vrl_header->height) >= ((gvar.video.page[0].height + gvar.video.page[0].dy) - 1) || y == -(gvar.video.page[0].dy)) - ydir = -ydir; - //printf("[x%u y%u] [rx%u ry%u] [w%u h%u]\n", x, y, rx, ry, w, h); + if(anim && !noanim) + { + /* render box bounds. y does not need modification, but x and width must be multiple of 4 */ + if (x >= overdraw) rx = (x - overdraw) & (~3); + else rx = -(gvar.video.page[0].dx); + if (y >= overdraw) ry = (y - overdraw); + else ry = -(gvar.video.page[0].dy); + h = vrl_header->height + overdraw + y - ry; + w = (x + vrl_header->width + (overdraw*2) + 3/*round up*/ - rx) & (~3); + if ((rx+w) > gvar.video.page[0].width) w = gvar.video.page[0].width-rx; + if ((ry+h) > gvar.video.page[0].height) h = gvar.video.page[0].height-ry; + + /* block copy pattern to where we will draw the sprite */ + vga_setup_wm1_block_copy(); + o2 = gvar.video.page[0].pagesize; + o = (0x10000UL - (uint16_t)gvar.video.page[1].data) + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen + for (i=0;i < h;i++,o += gvar.video.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2); + /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ + vga_restore_rm0wm0(); + + /* replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) */ + vga_state.vga_draw_stride_limit = (gvar.video.page[0].width + 3/*round up*/ - x) >> 2; + vga_state.vga_draw_stride = w >> 2; + vga_state.vga_graphics_ram = omemptr + gvar.video.page[0].pagesize; + + /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ +draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + + /* restore ptr */ + vga_state.vga_graphics_ram = omemptr; + + /* block copy to visible RAM from offscreen */ + vga_setup_wm1_block_copy(); + o = gvar.video.page[0].pagesize; // source offscreen + o2 = (ry * gvar.video.page[0].stridew) + (rx >> 2); // dest visible (original stride) + for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += gvar.video.page[0].stridew) vga_wm1_mem_block_copy(o2,o,w >> 2); + /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ + vga_restore_rm0wm0(); + + /* restore stride */ + vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gvar.video.page[0].stridew; + + /* step */ + x += xdir; y += ydir; + if ((x + vrl_header->width) >= ((gvar.video.page[0].width + gvar.video.page[0].dx) - 1) || x == -(gvar.video.page[0].dx)) + xdir = -xdir; + if ((y + vrl_header->height) >= ((gvar.video.page[0].height + gvar.video.page[0].dy) - 1) || y == -(gvar.video.page[0].dy)) + ydir = -ydir; + //printf("[x%u y%u] [rx%u ry%u] [w%u h%u]\n", x, y, rx, ry, w, h); + } } } IN_UserInput(1,1); - while(!IN_KeyDown(sc_Escape)) - { - if(IN_KeyDown(2)) modexShowPage(&(gvar.video.page[0])); - if(IN_KeyDown(3)) modexShowPage(&(gvar.video.page[1])); - } +// while(!IN_KeyDown(sc_Escape)) +// { +// IN_ReadControl(0,&player); +// PANKEY0EXE; +// } + +//===========================================================================// modexShowPage(&(gvar.video.page[0])); +if(!noanim) { /* another handy "demo" effect using VGA write mode 1. * we can take what's on screen and vertically squash it like an old analog TV set turning off. */ { @@ -278,7 +314,7 @@ int main(int argc,char **argv) { if (dh < 40) dh_step = 1; } } - +} IN_Shutdown(); VGAmodeX(0, 1, &gvar); free(vrl_lineoffs); @@ -287,5 +323,7 @@ int main(int argc,char **argv) { bufsz = 0; free(bakapee1); free(bakapee2); + printf("mv 0\n tx=%u ty=%u\n\n", mv[0].tx, mv[0].tx); + printf("mv 1\n tx=%u ty=%u\n", mv[1].tx, mv[1].tx); return 0; } diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index 3183cb52..e9cba2ad 100755 --- a/src/lib/16_tail.h +++ b/src/lib/16_tail.h @@ -34,8 +34,8 @@ if(IN_KeyDown(sc_F6)){ modexShowPage(&gvar.video.page[0]); IN_UserInput(1,1); } \ if(IN_KeyDown(sc_F7)){ modexShowPage_(&gvar.video.page[0]); IN_UserInput(1,1); } #define FUNCTIONKEYFUNCTIONS0EXE \ - if(IN_KeyDown(sc_F6)){ modexShowPage(&gvar.video.page[pagenum]); IN_UserInput(1,1); } \ - if(IN_KeyDown(sc_F7)){ modexShowPage_(&gvar.video.page[pagenum]); IN_UserInput(1,1); } + if(IN_KeyDown(sc_F6)){ modexShowPage(&gvar.video.page[pan.pn]); IN_UserInput(1,1); } \ + if(IN_KeyDown(sc_F7)){ modexShowPage_(&gvar.video.page[pan.pn]); IN_UserInput(1,1); } void DebugMemory_(global_game_variables_t *gvar, boolean q); void Shutdown16(global_game_variables_t *gvar); diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index b0c9d3c7..b8ef8520 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -629,6 +629,43 @@ void mapGoTo(map_view_t *mv, int tx, int ty) modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32); } +void mapGoTo_(map_view_t *mv, int tx, int ty) +{ + int py; + unsigned int i; + + /* set up the coordinates */ + mv[0].tx = mv[1].tx = tx; + mv[0].ty = mv[1].ty = ty; + mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth; + mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight; + + /* set up the thresholds */ + mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2; + mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2; + + /* draw the tiles */ + modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0); + py=0; + i=mv[0].ty * mv[0].map->width + mv[0].tx; + for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->tiles->tileHeight) { + mapDrawWRow(&mv[0], tx-1, ty, py); + i+=mv->map->width - tx; + } + if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); +// { +// unsigned int k,j,o; +// /* fill screen with a distinctive pattern */ +// for (k=0;k < vga_state.vga_width;k++) { +// o = k >> 2; +// vga_write_sequencer(0x02/*map mask*/,1 << (k&3)); +// for (j=0;j < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride) +// vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15! +// } +// } + modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32); +} + void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) { diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index c8ccab49..32d3987f 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -137,6 +137,7 @@ void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid); void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid); sword chkmap(map_t *map, word q); void mapGoTo(map_view_t *mv, int tx, int ty); +void mapGoTo_(map_view_t *mv, int tx, int ty); void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset); void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset); diff --git a/src/tesuto.h b/src/tesuto.h index 7578e4ab..1a045a80 100755 --- a/src/tesuto.h +++ b/src/tesuto.h @@ -4,11 +4,28 @@ #include "src/lib/16_head.h" #include "src/lib/16_vl.h" #include "src/lib/16_in.h" +#include "src/lib/scroll16.h" #include #include #include #include +#define PANKEY0EXE \ + panpagemanual(mv, player, 0); \ + if(IN_KeyDown(1+1)){ pan.pn=0; modexShowPage(&(gvar.video.page[pan.pn])); } \ + if(IN_KeyDown(2+1)){ pan.pn=1; modexShowPage(&(gvar.video.page[pan.pn])); } \ + if(IN_KeyDown(3+1)){ pan.pn=2; modexShowPage(&(gvar.video.page[pan.pn])); } \ + if(IN_KeyDown(4+1)){ pan.pn=3; modexShowPage(&(gvar.video.page[pan.pn])); } + +#define TESUTODRAWBOX \ + modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 15);\ + modexClearRegion(&gvar.video.page[0], 16, 16, gvar.video.page[0].sw, gvar.video.page[0].sh, 128);\ + modexClearRegion(&gvar.video.page[0], 32, 32, gvar.video.page[0].sw-32, gvar.video.page[0].sh-32, 42);\ + modexClearRegion(&gvar.video.page[0], 48, 48, gvar.video.page[0].sw-64, gvar.video.page[0].sh-64, 128);\ + modexCopyPageRegion(&gvar.video.page[1], &gvar.video.page[0], 0, 0, 0, 0, gvar.video.page[0].width, gvar.video.page[0].height);\ + modexClearRegion(&gvar.video.page[2], 0, 0, gvar.video.page[2].sw, gvar.video.page[2].sh, 47);\ + modexClearRegion(&gvar.video.page[3], 0, 0, gvar.video.page[3].sw, gvar.video.page[3].sh, 45);\ + typedef unsigned char far *VGA_RAM_PTR; //VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000); //unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes -- 2.39.5