\r
#define FILENAME_1 "data/aconita.vrl"\r
#define FILENAME_2 "data/aconita.pal"\r
+//#define FILENAME_2 "data/default.pal"\r
+\r
+//#define PATTERN\r
+#define DRAWCORNERBOXES \\r
+modexClearRegion(&gvar.video.page[0], 16, 16, 16, 16, 15); \\r
+modexClearRegion(&gvar.video.page[0], gvar.video.page[0].sw, gvar.video.page[0].sh, 16, 16, 15);\r
\r
static unsigned char palette[768];\r
-global_game_variables_t gvar;\r
player_t player[MaxPlayers];\r
+map_view_t mv[4];\r
+pan_t pan;\r
\r
-int main(int argc,char **argv) {\r
+int main(int argc,char **argv)\r
+{\r
+ static global_game_variables_t gvar;\r
struct vrl1_vgax_header *vrl_header;\r
vrl1_vgax_offset_t *vrl_lineoffs;\r
unsigned char *buffer;\r
unsigned int bufsz;\r
- int fd;\r
+ int fd, i;\r
char *bakapee1,*bakapee2;\r
- word pagenum=0;\r
+ boolean anim=1,noanim=1;\r
+ pan.pn=0;\r
\r
bakapee1=malloc(64);\r
bakapee2=malloc(1024);\r
\r
- IN_Startup();\r
- IN_Default(0,&player,ctrl_Keyboard1);\r
- IN_initplayer(&player, 0);\r
-\r
- if (argc < 3) {\r
- fprintf(stderr,"drawvrl <VRL file> <palette file>\n");\r
+ if (argc < 2) {\r
+ //fprintf(stderr,"drawvrl <VRL file> <palette file>\n palette file optional\n");\r
bakapee1 = FILENAME_1;//"data/aconita.vrl";\r
bakapee2 = FILENAME_2;//"data/aconita.pal";\r
+\r
}else{\r
if(argv[1]) bakapee1 = argv[1];\r
if(argv[2]) bakapee2 = argv[2];\r
vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
if (vrl_lineoffs == NULL) return 1;\r
\r
+ IN_Startup();\r
+ IN_Default(0,&player,ctrl_Keyboard1);\r
+ IN_initplayer(&player, 0);\r
+\r
/* setup camera and screen~ */\r
modexHiganbanaPageSetup(&gvar.video);\r
- modexShowPage(&(gvar.video.page[pagenum]));\r
+player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx;\r
+ player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny;\r
+ modexShowPage(&(gvar.video.page[pan.pn]));\r
+ for(i=0;i<gvar.video.num_of_pages;i++)\r
+ {\r
+ mv[i].page = &gvar.video.page[i];\r
+ mv[i].video = &gvar.video;\r
+ mv[i].pan = &pan;\r
+ mv[i].tx = 0;\r
+ mv[i].ty = 0;\r
+ }\r
\r
#define VMEMHEIGHT gvar.video.page[0].height+gvar.video.page[1].height\r
\r
- //4 this dose the screen\r
+ //4 this draws that pattern on the screen\r
{\r
unsigned int i,j,o;\r
/* fill screen with a distinctive pattern */\r
}\r
}\r
\r
+ DRAWCORNERBOXES;\r
\r
/* make distinctive pattern offscreen, render sprite, copy onscreen.\r
* this time, we render the distinctive pattern to another offscreen location and just copy.\r
* note this version is much faster too! */\r
{\r
- unsigned int i,j,o,o2;\r
+ unsigned int i,o,o2;\r
int x,y,rx,ry,w,h;\r
unsigned int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks.\r
// if the sprite's edge pixels are clear anyway, you can set this to 0.\r
VGA_RAM_PTR omemptr;\r
int xdir=1,ydir=1;\r
\r
+ int j;\r
/* fill pattern offset with a distinctive pattern */\r
for (i=0;i < gvar.video.page[0].width;i++) {\r
o = (i >> 2) + (0x10000UL - (uint16_t)gvar.video.page[1].data);\r
vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15!\r
}\r
\r
+ DRAWCORNERBOXES;\r
+\r
/* starting coords. note: this technique is limited to x coordinates of multiple of 4 */\r
x = -(gvar.video.page[0].dx);\r
y = -(gvar.video.page[0].dy);\r
while(!IN_KeyDown(sc_Escape))\r
{\r
IN_ReadControl(0,&player);\r
- if(IN_KeyDown(2)){ pagenum=0; modexShowPage(&(gvar.video.page[0])); }\r
- if(IN_KeyDown(3)){ pagenum=1; modexShowPage(&(gvar.video.page[1])); }\r
- if(IN_KeyDown(68)) //f10\r
+ PANKEY0EXE;\r
+ if(IN_KeyDown(68) || IN_KeyDown(sc_Space)) //f10 and space\r
{\r
//gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
+ anim=!anim;\r
IN_UserInput(1,1);\r
}\r
FUNCTIONKEYFUNCTIONS0EXE;\r
+ if(IN_KeyDown(sc_R)){\r
+ gvar.video.page[0].dx=gvar.video.page[0].dy=gvar.video.page[1].dx=gvar.video.page[1].dy=16;\r
+ modexShowPage(&(gvar.video.page[pan.pn]));\r
+ player[0].q = 1; player[0].d = 2;\r
+ } //R\r
\r
- /* render box bounds. y does not need modification, but x and width must be multiple of 4 */\r
- if (x >= overdraw) rx = (x - overdraw) & (~3);\r
- else rx = -(gvar.video.page[0].dx);\r
- if (y >= overdraw) ry = (y - overdraw);\r
- else ry = -(gvar.video.page[0].dy);\r
- h = vrl_header->height + overdraw + y - ry;\r
- w = (x + vrl_header->width + (overdraw*2) + 3/*round up*/ - rx) & (~3);\r
- if ((rx+w) > gvar.video.page[0].width) w = gvar.video.page[0].width-rx;\r
- if ((ry+h) > gvar.video.page[0].height) h = gvar.video.page[0].height-ry;\r
-\r
- /* block copy pattern to where we will draw the sprite */\r
- vga_setup_wm1_block_copy();\r
- o2 = gvar.video.page[0].pagesize;\r
- o = (0x10000UL - (uint16_t)gvar.video.page[1].data) + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen\r
- for (i=0;i < h;i++,o += gvar.video.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2);\r
- /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */\r
- vga_restore_rm0wm0();\r
-\r
- /* replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) */\r
- vga_state.vga_draw_stride_limit = (gvar.video.page[0].width + 3/*round up*/ - x) >> 2;\r
- vga_state.vga_draw_stride = w >> 2;\r
- vga_state.vga_graphics_ram = omemptr + gvar.video.page[0].pagesize;\r
-\r
- /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */\r
- draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
-\r
- /* restore ptr */\r
- vga_state.vga_graphics_ram = omemptr;\r
-\r
- /* block copy to visible RAM from offscreen */\r
- vga_setup_wm1_block_copy();\r
- o = gvar.video.page[0].pagesize; // source offscreen\r
- o2 = (ry * gvar.video.page[0].stridew) + (rx >> 2); // dest visible (original stride)\r
- 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);\r
- /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */\r
- vga_restore_rm0wm0();\r
-\r
- /* restore stride */\r
- vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gvar.video.page[0].stridew;\r
-\r
- /* step */\r
- x += xdir; y += ydir;\r
- if ((x + vrl_header->width) >= ((gvar.video.page[0].width + gvar.video.page[0].dx) - 1) || x == -(gvar.video.page[0].dx))\r
- xdir = -xdir;\r
- if ((y + vrl_header->height) >= ((gvar.video.page[0].height + gvar.video.page[0].dy) - 1) || y == -(gvar.video.page[0].dy))\r
- ydir = -ydir;\r
- //printf("[x%u y%u] [rx%u ry%u] [w%u h%u]\n", x, y, rx, ry, w, h);\r
+ if(anim && !noanim)\r
+ {\r
+ /* render box bounds. y does not need modification, but x and width must be multiple of 4 */\r
+ if (x >= overdraw) rx = (x - overdraw) & (~3);\r
+ else rx = -(gvar.video.page[0].dx);\r
+ if (y >= overdraw) ry = (y - overdraw);\r
+ else ry = -(gvar.video.page[0].dy);\r
+ h = vrl_header->height + overdraw + y - ry;\r
+ w = (x + vrl_header->width + (overdraw*2) + 3/*round up*/ - rx) & (~3);\r
+ if ((rx+w) > gvar.video.page[0].width) w = gvar.video.page[0].width-rx;\r
+ if ((ry+h) > gvar.video.page[0].height) h = gvar.video.page[0].height-ry;\r
+\r
+ /* block copy pattern to where we will draw the sprite */\r
+ vga_setup_wm1_block_copy();\r
+ o2 = gvar.video.page[0].pagesize;\r
+ o = (0x10000UL - (uint16_t)gvar.video.page[1].data) + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen\r
+ for (i=0;i < h;i++,o += gvar.video.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2);\r
+ /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */\r
+ vga_restore_rm0wm0();\r
+\r
+ /* replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) */\r
+ vga_state.vga_draw_stride_limit = (gvar.video.page[0].width + 3/*round up*/ - x) >> 2;\r
+ vga_state.vga_draw_stride = w >> 2;\r
+ vga_state.vga_graphics_ram = omemptr + gvar.video.page[0].pagesize;\r
+\r
+ /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */\r
+draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+\r
+ /* restore ptr */\r
+ vga_state.vga_graphics_ram = omemptr;\r
+\r
+ /* block copy to visible RAM from offscreen */\r
+ vga_setup_wm1_block_copy();\r
+ o = gvar.video.page[0].pagesize; // source offscreen\r
+ o2 = (ry * gvar.video.page[0].stridew) + (rx >> 2); // dest visible (original stride)\r
+ 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);\r
+ /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */\r
+ vga_restore_rm0wm0();\r
+\r
+ /* restore stride */\r
+ vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gvar.video.page[0].stridew;\r
+\r
+ /* step */\r
+ x += xdir; y += ydir;\r
+ if ((x + vrl_header->width) >= ((gvar.video.page[0].width + gvar.video.page[0].dx) - 1) || x == -(gvar.video.page[0].dx))\r
+ xdir = -xdir;\r
+ if ((y + vrl_header->height) >= ((gvar.video.page[0].height + gvar.video.page[0].dy) - 1) || y == -(gvar.video.page[0].dy))\r
+ ydir = -ydir;\r
+ //printf("[x%u y%u] [rx%u ry%u] [w%u h%u]\n", x, y, rx, ry, w, h);\r
+ }\r
}\r
}\r
\r
IN_UserInput(1,1);\r
\r
- while(!IN_KeyDown(sc_Escape))\r
- {\r
- if(IN_KeyDown(2)) modexShowPage(&(gvar.video.page[0]));\r
- if(IN_KeyDown(3)) modexShowPage(&(gvar.video.page[1]));\r
- }\r
+// while(!IN_KeyDown(sc_Escape))\r
+// {\r
+// IN_ReadControl(0,&player);\r
+// PANKEY0EXE;\r
+// }\r
+\r
+//===========================================================================//\r
\r
modexShowPage(&(gvar.video.page[0]));\r
+if(!noanim) {\r
/* another handy "demo" effect using VGA write mode 1.\r
* we can take what's on screen and vertically squash it like an old analog TV set turning off. */\r
{\r
if (dh < 40) dh_step = 1;\r
}\r
}\r
-\r
+}\r
IN_Shutdown();\r
VGAmodeX(0, 1, &gvar);\r
free(vrl_lineoffs);\r
bufsz = 0;\r
free(bakapee1);\r
free(bakapee2);\r
+ printf("mv 0\n tx=%u ty=%u\n\n", mv[0].tx, mv[0].tx);\r
+ printf("mv 1\n tx=%u ty=%u\n", mv[1].tx, mv[1].tx);\r
return 0;\r
}\r
modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);\r
}\r
\r
+void mapGoTo_(map_view_t *mv, int tx, int ty)\r
+{\r
+ int py;\r
+ unsigned int i;\r
+\r
+ /* set up the coordinates */\r
+ mv[0].tx = mv[1].tx = tx;\r
+ mv[0].ty = mv[1].ty = ty;\r
+ mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;\r
+ mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;\r
+\r
+ /* set up the thresholds */\r
+ mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;\r
+ mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;\r
+\r
+ /* draw the tiles */\r
+ modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);\r
+ py=0;\r
+ i=mv[0].ty * mv[0].map->width + mv[0].tx;\r
+ 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) {\r
+ mapDrawWRow(&mv[0], tx-1, ty, py);\r
+ i+=mv->map->width - tx;\r
+ }\r
+ if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);\r
+// {\r
+// unsigned int k,j,o;\r
+// /* fill screen with a distinctive pattern */\r
+// for (k=0;k < vga_state.vga_width;k++) {\r
+// o = k >> 2;\r
+// vga_write_sequencer(0x02/*map mask*/,1 << (k&3));\r
+// 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)\r
+// vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!\r
+// }\r
+// }\r
+ modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);\r
+}\r
+\r
void near\r
mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)\r
{\r
#include "src/lib/16_head.h"\r
#include "src/lib/16_vl.h"\r
#include "src/lib/16_in.h"\r
+#include "src/lib/scroll16.h"\r
#include <hw/cpu/cpu.h>\r
#include <hw/dos/dos.h>\r
#include <hw/vga/vga.h>\r
#include <hw/vga/vrl.h>\r
\r
+#define PANKEY0EXE \\r
+ panpagemanual(mv, player, 0); \\r
+ if(IN_KeyDown(1+1)){ pan.pn=0; modexShowPage(&(gvar.video.page[pan.pn])); } \\r
+ if(IN_KeyDown(2+1)){ pan.pn=1; modexShowPage(&(gvar.video.page[pan.pn])); } \\r
+ if(IN_KeyDown(3+1)){ pan.pn=2; modexShowPage(&(gvar.video.page[pan.pn])); } \\r
+ if(IN_KeyDown(4+1)){ pan.pn=3; modexShowPage(&(gvar.video.page[pan.pn])); }\r
+\r
+#define TESUTODRAWBOX \\r
+ modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 15);\\r
+ modexClearRegion(&gvar.video.page[0], 16, 16, gvar.video.page[0].sw, gvar.video.page[0].sh, 128);\\r
+ modexClearRegion(&gvar.video.page[0], 32, 32, gvar.video.page[0].sw-32, gvar.video.page[0].sh-32, 42);\\r
+ modexClearRegion(&gvar.video.page[0], 48, 48, gvar.video.page[0].sw-64, gvar.video.page[0].sh-64, 128);\\r
+ modexCopyPageRegion(&gvar.video.page[1], &gvar.video.page[0], 0, 0, 0, 0, gvar.video.page[0].width, gvar.video.page[0].height);\\r
+ modexClearRegion(&gvar.video.page[2], 0, 0, gvar.video.page[2].sw, gvar.video.page[2].sh, 47);\\r
+ modexClearRegion(&gvar.video.page[3], 0, 0, gvar.video.page[3].sw, gvar.video.page[3].sh, 45);\\r
+\r
typedef unsigned char far *VGA_RAM_PTR;\r
//VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000);\r
//unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes\r