X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2F0.c;h=ae51d0582567000e69f387bae1740df8d9378c8c;hb=888e2c276b5ee54772919b0590c3865bedc42dc9;hp=d4f671b317636d4d5180a366bd98b90209d13c50;hpb=f316394371b48430c9e1b375640b87f1d6f267ab;p=16.git diff --git a/src/0.c b/src/0.c index d4f671b3..ae51d058 100755 --- a/src/0.c +++ b/src/0.c @@ -10,6 +10,7 @@ static unsigned char palette[768]; global_game_variables_t gvar; +player_t player[1]; int main(int argc,char **argv) { struct vrl1_vgax_header *vrl_header; @@ -22,6 +23,10 @@ int main(int argc,char **argv) { bakapee1=malloc(64); bakapee2=malloc(1024); + IN_Startup(); + IN_Default(0,&player,ctrl_Joystick); + IN_initplayer(&player, 0); + if (argc < 3) { fprintf(stderr,"drawvrl \n"); bakapee1 = FILENAME_1;//"data/aconita.vrl"; @@ -60,30 +65,6 @@ int main(int argc,char **argv) { printf("VGA probe failed\n"); return 1; } -// int10_setmode(19); -// update_state_from_vga(); -// vga_enable_256color_modex(); // VGA mode X -// gvar.video.page[0].width = 320; // VGA lib currently does not update this -// gvar.video.page[0].height = 240; // VGA lib currently does not update this -// -// //#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case -// { -// struct vga_mode_params cm; -// -// vga_read_crtc_mode(&cm); -// -// // 320x240 mode 60Hz -// cm.vertical_total = 525; -// cm.vertical_start_retrace = 0x1EA; -// cm.vertical_end_retrace = 0x1EC; -// cm.vertical_display_end = 480; -// cm.vertical_blank_start = 489; -// cm.vertical_blank_end = 517; -// -// vga_write_crtc_mode(&cm,0); -// } -// gvar.video.page[0].height = 240; // VGA lib currently does not update this -//#endif VGAmodeX(1, 1, &gvar); /* load color palette */ @@ -108,27 +89,26 @@ int main(int argc,char **argv) { gvar.video.page[1].dy=gvar.video.page[0].dy=16; modexShowPage(&(gvar.video.page[0])); + #define VMEMHEIGHT gvar.video.page[0].height+gvar.video.page[1].height + //4 this dose the screen { unsigned int i,j,o; - /* fill screen with a distinctive pattern */ for (i=0;i < gvar.video.page[0].width;i++) { o = i >> 2; vga_write_sequencer(0x02/*map mask*/,1 << (i&3)); - for (j=0;j < gvar.video.page[0].height;j++,o += gvar.video.page[0].stridew) + for (j=0;j < VMEMHEIGHT;j++,o += gvar.video.page[0].stridew) vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15! } } - //draw_vrl1_vgax_modex(0/*x-rx*/,0/*y-ry*/,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + //while (getch() != 13); /* make distinctive pattern offscreen, render sprite, copy onscreen. * this time, we render the distinctive pattern to another offscreen location and just copy. * note this version is much faster too! */ { - const unsigned int offscreen_ofs = (gvar.video.page[0].stridew * gvar.video.page[0].height); - const unsigned int pattern_ofs = 0x10000UL - (gvar.video.page[0].stridew * gvar.video.page[0].height); unsigned int i,j,o,o2; int x,y,rx,ry,w,h; unsigned int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. @@ -139,9 +119,9 @@ int main(int argc,char **argv) { //4 this dose the sprite? wwww /* fill pattern offset with a distinctive pattern */ for (i=0;i < gvar.video.page[0].width;i++) { - o = (i >> 2) + pattern_ofs; + o = (i >> 2) + (0x10000UL - (uint16_t)gvar.video.page[1].data); vga_write_sequencer(0x02/*map mask*/,1 << (i&3)); - for (j=0;j < gvar.video.page[0].height;j++,o += gvar.video.page[0].stridew) + for (j=0;j < VMEMHEIGHT;j++,o += gvar.video.page[0].stridew) vga_state.vga_graphics_ram[o] = (i^j)&15; // VRL samples put all colors in first 15! } @@ -151,10 +131,16 @@ int main(int argc,char **argv) { /* do it */ omemptr = vga_state.vga_graphics_ram; // save original mem ptr - while (1) { - /* stop animating if the user hits ENTER */ - if (kbhit()) { - if (getch() == 13) break; + + while(!IN_KeyDown(sc_Escape)) + { + IN_ReadControl(0,&player); + if(IN_KeyDown(2)) modexShowPage(&(gvar.video.page[0])); + if(IN_KeyDown(3)) modexShowPage(&(gvar.video.page[1])); + if(IN_KeyDown(68)) //f10 + { + //gvar.kurokku.fpscap=!gvar.kurokku.fpscap; + IN_UserInput(1,1); } /* render box bounds. y does not need modification, but x and width must be multiple of 4 */ @@ -165,12 +151,12 @@ int main(int argc,char **argv) { 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; + 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 = offscreen_ofs; - o = pattern_ofs + (ry * gvar.video.page[0].stridew) + (rx >> 2); // source offscreen + 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(); @@ -178,7 +164,7 @@ int main(int argc,char **argv) { /* 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 + offscreen_ofs; + 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)); @@ -188,7 +174,7 @@ int main(int argc,char **argv) { /* block copy to visible RAM from offscreen */ vga_setup_wm1_block_copy(); - o = offscreen_ofs; // source offscreen + 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 */ @@ -198,17 +184,24 @@ int main(int argc,char **argv) { vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gvar.video.page[0].stridew; /* step */ - x += xdir; - y += ydir; - if (x >= (gvar.video.page[0].width - 1) || x == 0) + 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 >= (gvar.video.page[0].height - 1) || y == 0) + 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); } } - modexShowPage(&(gvar.video.page[1])); + 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])); + } + + modexShowPage(&(gvar.video.page[0])); /* 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. */ { @@ -289,10 +282,13 @@ int main(int argc,char **argv) { } } + IN_Shutdown(); VGAmodeX(0, 1, &gvar); free(vrl_lineoffs); buffer = NULL; free(buffer); bufsz = 0; + free(bakapee1); + free(bakapee2); return 0; }