+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+\r
#include <hw/cpu/cpu.h>\r
#include <hw/dos/dos.h>\r
#include <hw/vga/vga.h>\r
#define FILENAME_1 "data/spri/chikyuu.vrl"\r
#define FILENAME_2 "data/spri/chikyuu.pal"\r
\r
-#define PATTERN\r
#define INITTNUM 1\r
\r
-static unsigned char palette[768];\r
player_t player[MaxPlayers];\r
map_view_t mv[4];\r
-pan_t pan;\r
+\r
+map_t map;//junk var\r
\r
int main(int argc,char **argv)\r
{\r
vrl1_vgax_offset_t *vrl_lineoffs;\r
unsigned char *buffer;\r
unsigned int bufsz;\r
- int fd, i;\r
+ int fd;\r
+ //nibble i;\r
char *bakapee1,*bakapee2;\r
\r
- boolean anim=1,noanim=1;\r
-\r
- pan.pn=0;\r
+ boolean anim=1,noanim=0,zerostoppause=1;\r
\r
bakapee1=malloc(64);\r
- bakapee2=malloc(1024);\r
+ bakapee2=malloc(64);\r
\r
if (argc < 2) {\r
//fprintf(stderr,"drawvrl <VRL file> <palette file>\n palette file optional\n");\r
return 1;\r
}\r
VGAmodeX(1, 1, &gvar);\r
+ modexPalUpdate0(gvar.video.palette);\r
\r
/* load color palette */\r
- fd = open(bakapee2,O_RDONLY|O_BINARY);\r
- if (fd >= 0) {\r
- unsigned int i;\r
-\r
- read(fd,palette,768);\r
- close(fd);\r
-\r
- vga_palette_lseek(0);\r
- for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);\r
- }\r
+ VL_LoadPalFile(bakapee2, &gvar.video.palette);\r
\r
/* preprocess the sprite to generate line offsets */\r
vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
\r
IN_Startup();\r
IN_Default(0,&player,ctrl_Keyboard1);\r
- IN_initplayer(&player, 0);\r
+ EN_initplayer(&player, 0, &gvar.video);\r
\r
/* setup camera and screen~ */\r
modexHiganbanaPageSetup(&gvar.video);\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 = INITTNUM;\r
- mv[i].ty = INITTNUM;\r
- }\r
- //player[0].tx = INITTNUM; player[0].ty = INITTNUM;\r
- //mapinitmapview(mv, player[0].tx, player[0].tx);\r
-\r
+ ZC_MVSetup(&mv, &map, &gvar);\r
+ ZC_ShowMV(&mv, gvar.video.sp, 0);\r
\r
- #define VMEMHEIGHT gvar.video.page[0].height+gvar.video.page[1].height\r
-\r
- //4 this draws that pattern on the screen\r
-#ifdef PATTERN\r
- {\r
- unsigned int i,j,o;\r
- /* fill screen with a distinctive pattern */\r
- for (i=0;i < gvar.video.page[0].width;i++) {\r
- o = i >> 2;\r
- vga_write_sequencer(0x02/*map mask*/,1 << (i&3));\r
- for (j=0;j < VMEMHEIGHT;j++,o += gvar.video.page[0].stridew)\r
- vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15!\r
- }\r
- }\r
-#else\r
- TESTBG;\r
-#endif\r
-\r
- DRAWCORNERBOXES;\r
+// VL_PatternDraw(video_t *video, word pn, boolean sw, boolean allsw);\r
+ VL_PatternDraw(&gvar.video, 0/*gvar.video.sp*/, 0, 1);\r
+ TESTBG34\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
VGA_RAM_PTR omemptr;\r
int xdir=1,ydir=1;\r
\r
-#ifdef PATTERN\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_write_sequencer(0x02/*map mask*/,1 << (i&3));\r
- for (j=0;j < VMEMHEIGHT;j++,o += gvar.video.page[0].stridew)\r
- vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15!\r
- }\r
-#else\r
- TESTBG;\r
-#endif\r
- DRAWCORNERBOXES;\r
+// VL_PatternDraw(video_t *video, word pn, boolean sw, boolean allsw);\r
+// VL_PatternDraw(&gvar.video, 0, 1, 1);\r
+// TESTBG;\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
while(!IN_KeyDown(sc_Escape))\r
{\r
IN_ReadControl(0,&player);\r
- PANKEY0EXE;\r
- if(IN_KeyDown(68) || IN_KeyDown(sc_Space)) //f10 and space\r
+ if(IN_KeyDown(68)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap; IN_UserInput(1,1); } //f10\r
+ PANKEYFUN;\r
+ if(IN_KeyDown(sc_Space) || zerostoppause) //space\r
{\r
- //gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
anim=!anim;\r
DRAWCORNERBOXES;\r
- IN_UserInput(1,1);\r
+ if(!zerostoppause) IN_UserInput(1,1); else zerostoppause=0;\r
}\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
mv[0].tx = mv[0].ty = mv[1].tx = mv[1].ty = INITTNUM;\r
- modexShowPage(&(gvar.video.page[pan.pn]));\r
- player[0].q = 1; player[0].d = 2;\r
+ VL_ShowPage(&gvar.video.page[gvar.video.sp], 1, 0);\r
+ player[0].enti.q = 1; player[0].enti.d = 2;\r
x=y=0;\r
xdir=ydir=1;\r
- TESTBG;\r
- DRAWCORNERBOXES;\r
} //R\r
FUNCTIONKEYFUNCTIONS0EXE;\r
\r
- if(anim/* && !noanim*/)\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
\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
+ o2 = gvar.video.page[0].pagesize+gvar.video.page[1].pagesize;\r
+ o = ((uint16_t)gvar.video.page[2].data) + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen 0x10000UL -\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
/* 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
+ vga_state.vga_graphics_ram = omemptr + gvar.video.page[0].pagesize + gvar.video.page[1].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
+//printf("x=%d y=%d rx=%d ry=%d\n", x, y, rx, ry);\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
+ o = gvar.video.page[0].pagesize+gvar.video.page[1].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
\r
IN_UserInput(1,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
+ ZC_ShowMV(&mv, 0, 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
\r
/* wait for vsync end */\r
+ if(gvar.kurokku.fpscap)\r
vga_wait_for_vsync_end();\r
\r
/* what scalefactor to use for stretching? */\r
vga_restore_rm0wm0();\r
\r
/* wait for vsync */\r
+ if(gvar.kurokku.fpscap)\r
vga_wait_for_vsync();\r
\r
/* make it shrink */\r
bufsz = 0;\r
free(bakapee1);\r
free(bakapee2);\r
- //printf("mv 0\n tx=%d ty=%d\n\n", mv[0].tx, mv[0].tx);\r
- //printf("mv 1\n tx=%d ty=%d\n", mv[1].tx, mv[1].tx);\r
+ printf("\nProject 16 0.exe. This is just a test file!\n");\r
+ printf("version %s\n", VERSION);\r
+ //SCROLLEXITMESG;\r
+ printf("mv 0\n- tx=%d ty=%d dx=%d dy=%d\n", mv[0].tx, mv[0].ty, gvar.video.page[0].dx, gvar.video.page[0].dy);\r
+ printf("mv 1\n- tx=%d ty=%d dx=%d dy=%d\n", mv[1].tx, mv[1].ty, gvar.video.page[1].dx, gvar.video.page[1].dy);\r
return 0;\r
}\r