From: sparky4 Date: Wed, 12 Apr 2017 18:20:47 +0000 (-0500) Subject: p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I... X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=cecbe84f7c61a26fa2285fc125839b2ff50a7f51;p=16.git p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] MM_ShowMemory is quite buggy on real machines. i need to debug it and fix added a struct printer[gvar.mm is FUCKING HUGE 14402 bytes FAT\!]16_rf now compiles BT UNKNOWN ON WHAT IT DOSE\! text box done --- diff --git a/1croll.exe b/1croll.exe new file mode 100755 index 00000000..beb750e1 Binary files /dev/null and b/1croll.exe differ diff --git a/data/G.PAL b/data/G.PAL index 8092380a..eb359e82 100755 Binary files a/data/G.PAL and b/data/G.PAL differ diff --git a/makefile b/makefile index 9be1782e..e8658adb 100755 --- a/makefile +++ b/makefile @@ -137,7 +137,7 @@ LIBFLAGS=$(WLIBQ) -b -n # VGMSNDOBJ = vgmSnd.$(OBJ) #OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) -GFXLIBOBJS = 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS) +GFXLIBOBJS = 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16_vl_2.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS) 16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_head.$(OBJ) 16_enti.$(OBJ) 16_dbg.$(OBJ) 16_in.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) 16_sd.$(OBJ) 16_tail_.$(OBJ) 16_dbg_1.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 diff --git a/ptmp.pcx b/ptmp.pcx new file mode 100755 index 00000000..3b956313 Binary files /dev/null and b/ptmp.pcx differ diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index a782a303..28864242 100755 --- a/src/lib/16_tail.h +++ b/src/lib/16_tail.h @@ -83,6 +83,7 @@ if(gvar.in.inst->Keyboard[sc_T]){ gvar.video.vga_state.rss=!gvar.video.vga_state.rss; IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_P]){ modexpdump(&gvar.video.page[0]); IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_Y]){ dbg_delayanimation=!dbg_delayanimation; IN_UserInput(1, &gvar); } \ + if(gvar.in.inst->Keyboard[sc_Q]){ VL_modexPrintTextBox(&gvar); IN_UserInput(1, &gvar); } \ RFDEBUGFUNCTIONS //FIZZLEFADEFUNCTION @@ -111,13 +112,13 @@ if(gvar.in.inst->Keyboard[sc_X]){ TESTBG12 } \ if(gvar.in.inst->Keyboard[sc_C]){ TESTBG34 } \ if(gvar.in.inst->Keyboard[sc_V]){ VL_PatternDraw(&gvar.video, 0, 1, 1); } \ - if(gvar.in.inst->Keyboard[sc_I]){ dbg_maptext=!dbg_maptext; IN_UserInput(1, &gvar); } -/* if(gvar.in.inst->Keyboard[sc_PgDn]){ \ + if(gvar.in.inst->Keyboard[sc_I]){ dbg_maptext=!dbg_maptext; IN_UserInput(1, &gvar); } \ + if(gvar.in.inst->Keyboard[sc_PgDn]){ \ rotateR(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1, &gvar); } \ if(gvar.in.inst->Keyboard[sc_PgUp]){ \ rotateL(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ - VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1, &gvar); }*/ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1, &gvar); } #ifdef __BORLANDC__ #define PAL_WRITE_REG 0x03C8 /* Color register, write address */ #define PAL_DATA_REG 0x03C9 /* Color register, data port */ diff --git a/src/lib/16_tail_.c b/src/lib/16_tail_.c index 10ef7395..a21780c0 100755 --- a/src/lib/16_tail_.c +++ b/src/lib/16_tail_.c @@ -39,5 +39,6 @@ void TL_VidInit(global_game_variables_t *gvar) //in.h.ah = 0xf; //int86(0x10, &in, &out); if(!gvar->video.old_mode) gvar->video.old_mode = vgaGetMode();//out.h.al; + VL_LoadPalFileCore(gvar->video.palette); gvar->video.VL_Initiated = 1; } diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 6321841d..341ada31 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -430,6 +430,7 @@ typedef struct int tx,ty; //appears to be the top left tile position on the viewable screen map word dxThresh,dyThresh; //Threshold for physical tile switch video_t *video; //pointer to game variables of the video + kurokku_t *kurokku; //pointer to game variables of the kurokku nibble __near *p; // pointer to video's render page num nibble __near *sp; // pointer to video's show page num int dx, dy; // draw row and col var diff --git a/src/lib/16_timer.c b/src/lib/16_timer.c index a9dba5d5..c5aae485 100755 --- a/src/lib/16_timer.c +++ b/src/lib/16_timer.c @@ -65,10 +65,6 @@ double time_in_seconds(global_game_variables_t *gv) return (gv->kurokku.t) / CLOCKS_PER_SEC; } -// big global status text buffer -char global_temp_status_text[512]; -char global_temp_status_text2[512]; - /*double time_in_seconds(time_t in_t) { return (in_t) / CLOCKS_PER_SEC; diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 91776466..24e3342e 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -364,7 +364,8 @@ modexShowPage(page_t *page) { //args: page, vertical sync switch, screen resolution switch, page0 switch void -VL_ShowPage(page_t *page, boolean vsync, boolean sr) { +VL_ShowPage(page_t *page, boolean vsync, boolean sr) +{ word high_address, low_address, offset; byte crtcOffset; @@ -402,6 +403,7 @@ VL_ShowPage(page_t *page, boolean vsync, boolean sr) { outp(AC_INDEX, 0x33); outp(AC_INDEX, (page->dx & 0x03) << 1); vga_state.vga_graphics_ram = (VGA_RAM_PTR)page->data; + vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = page->stridew; } //============================================================================= @@ -694,10 +696,15 @@ modexLoadPalFile(byte *filename, byte *palette) { fclose(file); } - void VL_LoadPalFile(const char *filename, byte *palette) { - VL_LoadPalFilewithoffset(filename, palette, 0); + VL_LoadPalFilewithoffset(filename, palette, 8); + VL_LoadPalFileCore(palette); +} + +void VL_LoadPalFileCore(byte *palette) +{ + VL_LoadPalFilewithoffset("data/16.pal", palette, 0); } void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) diff --git a/src/lib/16_vl.h b/src/lib/16_vl.h index 962593c7..3cfa4347 100755 --- a/src/lib/16_vl.h +++ b/src/lib/16_vl.h @@ -193,6 +193,7 @@ void modexPalSave(byte *palette); //byte *modexNewPal(); void modexLoadPalFile(char *filename, byte *palette); void VL_LoadPalFile(const char *filename, byte *palette); +void VL_LoadPalFileCore(byte *palette); void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o); void VL_UpdatePaletteWrite(byte *palette, word o); void modexSavePalFile(char *filename, byte *palette); @@ -242,6 +243,7 @@ static inline byte modexreadPixel(page_t *page, int x, int y, word addr) void modexDrawChar(page_t *page, int x/*for planar selection only*/, word t, word col, word bgcol, word addr); void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str); void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str); +void VL_modexPrintTextBox(global_game_variables_t *gvar); void modexpdump(page_t *pee); void modexcls(page_t *page, byte color, byte *Where); void VL_PatternDraw(video_t *video, word pn, boolean sw, boolean allsw); diff --git a/src/lib/16_vl_2.c b/src/lib/16_vl_2.c new file mode 100755 index 00000000..68bbe443 --- /dev/null +++ b/src/lib/16_vl_2.c @@ -0,0 +1,118 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include "src/lib/16_vl.h" + +// big global status text buffer +char global_temp_status_text[512]; +char global_temp_status_text2[512]; + +#define PRINTTEXTBOXSTABLE + +void VL_modexPrintTextBox(global_game_variables_t *gvar) +{ +#define PRINTTEXTBOXW gvar->video.page[0].width +#define PRINTTEXTBOXH 160 +#define PRINTTEXTBOXHLINE 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD//, 0xCD, 0xCD, 0xCD, 0xCD +#define PRINTTEXTBOXHLINETOP 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCB, 0xCD, PRINTTEXTBOXHLINE +#define PRINTTEXTBOXHLINEBOTTOM 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCA, 0xCD, PRINTTEXTBOXHLINE +#define PRINTTEXTBOXSLINE 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20//, 0x20, 0x20, 0x20, 0x20 +#define PRINTTEXTBOXSTRA2CHAR 0x20//07 +#define PRINTTEXTBOXSTRA2STR PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR, PRINTTEXTBOXSTRA2CHAR + byte str1[41] = { 0xC9, PRINTTEXTBOXHLINETOP, 0xBB, 0x00 }; +#ifdef PRINTTEXTBOXSTABLE + byte str2[41] = { 0xBA, PRINTTEXTBOXSTRA2STR, 0xBA, PRINTTEXTBOXSLINE, 0xBA, 0x00 }; +#else + byte str2[2] = { 0xBA, 0x00 }, + stra2[7] = { PRINTTEXTBOXSTRA2STR, 0x00 }, + strb2[] = { 0xBA, PRINTTEXTBOXSLINE, 0xBA, 0x00 }; +#endif + byte str3[41] = { 0xC8, PRINTTEXTBOXHLINEBOTTOM, 0xBC, 0x00 }; + word x = gvar->video.page[/*!*/(gvar->video.p)].dx; //(gv->video.page[(gv->video.p)].tlx) - // follow the screen + word y = gvar->video.page[/*!*/(gvar->video.p)].dy; //(gv->video.page[(gv->video.p)].tly) - // follow the screen + word col = 3, bgcol = 0, type = 1;//w = 64, h = 8, + word v = gvar->video.page[0].height-PRINTTEXTBOXH; //vertical offset + nibble i; + boolean done; + ScanCode scan; +#ifndef PRINTTEXTBOXSTABLE + word q; +#endif + //backuppart + modexCopyPageRegion(&gvar->video.page[0], &gvar->video.page[2], + 0, + 0, + x, + PRINTTEXTBOXH, + PRINTTEXTBOXW, PRINTTEXTBOXH); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================"); + + //modexprint(*page, x, y, type, tlsw, color, bgcolor, sw, *str) + sprintf(global_temp_status_text, "%s", str1); + modexprint(&(gvar->video.page[(gvar->video.p)]), x, y+gvar->video.page[0].height-v, type, 1, col, bgcol, 1, global_temp_status_text); v-=8; +#ifdef PRINTTEXTBOXSTABLE + sprintf(global_temp_status_text, "%s", str2); for(i=0;i<8;i++) +{ modexprint(&(gvar->video.page[(gvar->video.p)]), x, y+gvar->video.page[0].height-v, type, 1, col, bgcol, 1, global_temp_status_text); v-=8; } +#else + for(i=0;i<8;i++) + { + q=0; + sprintf(global_temp_status_text, "%s", str2); modexprint(&(gvar->video.page[(gvar->video.p)]), x, y+gvar->video.page[0].height-v, type, 1, col, bgcol, 1, global_temp_status_text); q+=8; + sprintf(global_temp_status_text, "%s", stra2); modexprint(&(gvar->video.page[(gvar->video.p)]), x+q, y+gvar->video.page[0].height-v, type, 1, col, 3, 1, global_temp_status_text); q+=40; + sprintf(global_temp_status_text, "%s", strb2); modexprint(&(gvar->video.page[(gvar->video.p)]), x+q-8, y+gvar->video.page[0].height-v, type, 1, col, bgcol, 1, global_temp_status_text); + v-=8; + } +#endif + sprintf(global_temp_status_text, "%s", str3); + modexprint(&(gvar->video.page[(gvar->video.p)]), x, y+gvar->video.page[0].height-v, type, 1, col, bgcol, 1, global_temp_status_text); + for (i = 0,done = false;!done;) + { + while (!(scan = gvar->in.inst->LastScan)) + {} +// SD_Poll(); + + IN_ClearKey(scan); + switch (scan) + { + default: + case sc_Escape: + done = true; + break; + case sc_Enter: + //PM_GetPage(i, gvar); + break; + } + } + modexCopyPageRegion(&gvar->video.page[2], &gvar->video.page[0], + x, + PRINTTEXTBOXH, + 0, + 0, + PRINTTEXTBOXW, PRINTTEXTBOXH); +} diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 249d0b3d..94338ab7 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -24,7 +24,111 @@ */ #include "src/lib/scroll16.h" +//check map edge +boolean ZCL_mapEdgeChk(map_view_t *map_v, nibble dir, int tx, int ty, boolean pansw, boolean noscrollsw) +{ + int w,h; + + switch (pansw) + { + case 0: + w = map_v[0].map->width; + h = map_v[0].map->height; + break; + case 1: + w = map_v[0].page->ti.tilesw; + h = map_v[0].page->ti.tilesh; + break; + } + + switch(dir) + { + default://no direction + case 2: + //0000pip[0].video->startclk = (*clockw); + return false; + break; + //right movement + case 3: + if(noscrollsw) return tx < map_v[0].map->width; + else return (map_v[0].tx >= 0 && map_v[0].tx+map_v[0].page->ti.tw < w); + break; + //left movement + case 1: + if(noscrollsw) return tx > 1; + else return (map_v[0].tx > 0 && map_v[0].tx+map_v[0].page->ti.tw <= w); + break; + //down movement + case 4: + if(noscrollsw) return ty < map_v[0].map->height; + else return (map_v[0].ty >= 0 && map_v[0].ty+map_v[0].page->ti.th < h); + break; + //up movement + case 0: + if(noscrollsw) return ty > 1; + else return (map_v[0].ty > 0 && map_v[0].ty+map_v[0].page->ti.th <= h); + break; + } + return false; +} + +boolean ZCL_CollCheck(map_view_t *map_v, nibble dir, int tx, int ty) +{ + switch (dir) + { + default://no direction + case 2: + break; + case 3://right + return !(map_v[0].map->layerdata[0].data[(tx)+(map_v[0].map->width*(ty-1))] == 0); + break; + case 1://left + return !(map_v[0].map->layerdata[0].data[(tx-2)+(map_v[0].map->width*(ty-1))] == 0); + break; + case 4://down + return !(map_v[0].map->layerdata[0].data[(tx-1)+(map_v[0].map->width*(ty))] == 0); + break; + case 0://up + return !(map_v[0].map->layerdata[0].data[(tx-1)+(map_v[0].map->width*(ty-2))] == 0); + break; + } + return false; +} + +boolean ZCL_ScreenMidPosChk(map_view_t *map_v, nibble dir, int tx, int ty) +{ + if(ZCL_mapEdgeChk(map_v, dir, 0, 0, 0, 0)) + switch(dir) + { + default://no direction + case 2: + //0000map_v[0].video->startclk = (*clockw); + return false; + break; + //right movement + case 3: + return tx == map_v[0].tx+map_v[0].page->ti.tilemidposscreenx; + break; + //left movement + case 1: + return tx == map_v[0].tx+map_v[0].page->ti.tilemidposscreenx; + break; + //down movement + case 4: + return ty == map_v[0].ty+map_v[0].page->ti.tilemidposscreeny; + break; + //up movement + case 0: + return ty == map_v[0].ty+map_v[0].page->ti.tilemidposscreeny; + break; + } + return false; +} + //#define INC_PER_FRAME if(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1; +#ifdef OLDWALKSHOWPAGESTUFF +#define SHOWMVFUN__ ZC_ShowMV(pip, 1, 0); +#endif void ZC_walk(map_view_t *pip, player_t *player, word pn) { @@ -36,8 +140,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //right movement case 3: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx && - !(pip[0].map->layerdata[0].data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! + if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { player[pn].walktype=2; if(player[pn].enti.q<=player[pn].enti.spt) @@ -46,9 +150,13 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ZC_mapScroll(pip, player, pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } - else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->layerdata[0].data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) + else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) { player[pn].walktype=1; if(player[pn].enti.q<=player[pn].enti.spt) @@ -56,6 +164,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.x+=(player[pn].enti.speed); ZC_animatePlayer(pip, player, pn); player[pn].enti.q++; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else @@ -63,14 +174,17 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].walktype=0; ZC_animatePlayer(pip, player, pn); player[pn].enti.d = 2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } player[pn].enti.triggerx = player[pn].enti.tx+1; player[pn].enti.triggery = player[pn].enti.ty; break; //left movement case 1: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx && - !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! + if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { player[pn].walktype=2; if(player[pn].enti.q<=player[pn].enti.spt) @@ -79,9 +193,13 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ZC_mapScroll(pip, player, pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } - else if(player[pn].enti.tx > 1 && !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) + else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) { player[pn].walktype=1; if(player[pn].enti.q<=player[pn].enti.spt) @@ -89,6 +207,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.x-=(player[pn].enti.speed); ZC_animatePlayer(pip, player, pn); player[pn].enti.q++; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else @@ -96,14 +217,17 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].walktype=0; ZC_animatePlayer(pip, player, pn); player[pn].enti.d = 2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } player[pn].enti.triggerx = player[pn].enti.tx-1; player[pn].enti.triggery = player[pn].enti.ty; break; //down movement case 4: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny && - !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection! + if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection! { player[pn].walktype=2; if(player[pn].enti.q<=player[pn].enti.spt) @@ -112,9 +236,13 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ZC_mapScroll(pip, player, pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } - else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) + else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) { player[pn].walktype=1; if(player[pn].enti.q<=player[pn].enti.spt) @@ -122,6 +250,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.y+=(player[pn].enti.speed); ZC_animatePlayer(pip, player, pn); player[pn].enti.q++; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else @@ -129,14 +260,17 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].walktype=0; ZC_animatePlayer(pip, player, pn); player[pn].enti.d = 2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } player[pn].enti.triggerx = player[pn].enti.tx; player[pn].enti.triggery = player[pn].enti.ty+1; break; //up movement case 0: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 0) && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny && - !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection! + if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection! { player[pn].walktype=2; if(player[pn].enti.q<=player[pn].enti.spt) @@ -145,9 +279,13 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ZC_mapScroll(pip, player, pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } - else if(player[pn].enti.ty > 1 && !(pip[0].map->layerdata[0].data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) + else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) && + ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) { player[pn].walktype=1; if(player[pn].enti.q<=player[pn].enti.spt) @@ -155,6 +293,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.y-=(player[pn].enti.speed); ZC_animatePlayer(pip, player, pn); player[pn].enti.q++; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else @@ -162,6 +303,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].walktype=0; ZC_animatePlayer(pip, player, pn); player[pn].enti.d = 2; +#ifdef OLDWALKSHOWPAGESTUFF + SHOWMVFUN__ +#endif } player[pn].enti.triggerx = player[pn].enti.tx; player[pn].enti.triggery = player[pn].enti.ty-1; @@ -178,7 +322,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) { //right movement case 3: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1)) + if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0)) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -191,7 +335,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //left movement case 1: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1)) + if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0)) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -204,7 +348,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //down movement case 4: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1)) + if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0)) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -217,7 +361,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //up movement case 0: - if(ZC_mapEdgeChk(pip, player[pn].enti.d, 1)) + if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0)) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -238,11 +382,12 @@ void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv) #define ZC_MVI 1 nibble i; // 1st page - pip[0].page = &gv->video.page[0]; - pip[0].map = map; - pip[0].video = &gv->video; - pip[0].p = &gv->video.p; - pip[0].sp = &gv->video.sp; + pip[0].page = &gv->video.page[0]; + pip[0].map = map; + pip[0].video = &gv->video; + pip[0].kurokku = &gv->kurokku; + pip[0].p = &gv->video.p; + pip[0].sp = &gv->video.sp; ZC_MVInit(pip, 1, 1); for(i=ZC_MVI;ivideo.num_of_pages;i++) @@ -269,43 +414,7 @@ void ZC_MVInit(map_view_t *pip, int tx, int ty) void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr) { - word high_address, low_address, offset; - byte crtcOffset; - - // calculate offset - offset = (word) moo[moo[0].video->sp].page->data; - offset += moo[0].page->dy * (moo[0].page->width >> 2 ); - offset += moo[0].page->dx >> 2; - - // calculate crtcOffset according to virtual width - switch(sr) - { - case 1: - crtcOffset = moo[moo[0].video->sp].page->sw >> 3; - break; - default: - case 0: - crtcOffset = moo[0].page->width >> 3; - break; - } - - high_address = HIGH_ADDRESS | (offset & 0xff00); - low_address = LOW_ADDRESS | (offset << 8); - - // wait for appropriate timing and then program CRTC - if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); - outpw(CRTC_INDEX, high_address); - outpw(CRTC_INDEX, low_address); - outp(CRTC_INDEX, 0x13); - outp(CRTC_DATA, crtcOffset); - - // wait for one retrace - if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE)); - - // do PEL panning here - outp(AC_INDEX, 0x33); - outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1); - vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = moo[0].page->stridew; + VL_ShowPage(moo[0].page, vsync, sr); } #if 0 @@ -384,7 +493,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) /* draw the next column */ x= mv[0].page->sw + mv[0].map->tiles->tileWidth; - if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0)) + if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0)) #ifndef FULLRCREND if(player[plid].enti.q%4) #else @@ -407,7 +516,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) /* draw the next column */ x= 0; - if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0)) + if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0)) #ifndef FULLRCREND if(player[plid].enti.q%4) #else @@ -430,7 +539,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) /* draw the next row */ y= 0; - if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0)) + if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0)) #ifndef FULLRCREND if(player[plid].enti.q%3) #else @@ -453,7 +562,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) /* draw the next row */ y= mv[0].page->sh + mv[0].map->tiles->tileHeight; - if(ZC_mapEdgeChk(mv, player[plid].enti.d, 0)) + if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0)) #ifndef FULLRCREND if(player[plid].enti.q%3) #else @@ -776,22 +885,8 @@ void shinku(global_game_variables_t *gv) }else //copy dat sheet gv->kurokku.tiku++; - switch(gv->kurokku.fpscap) - { - case 0: //turn this off if XT - //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!"); - gv->kurokku.frames_per_second=1; - break; - case 1: - //modexWaitBorder(); - //modexWaitBorder_start(); - //vga_wait_for_vsync(); - vga_wait_for_vsync_end(); - gv->kurokku.frames_per_second=60; - break; - } //render!! - if(gv->video.dorender ) + if(gv->video.dorender) {//r=1 /*if(video->bgp s) { @@ -799,10 +894,30 @@ void shinku(global_game_variables_t *gv) }else{ //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32); }*/ +#ifndef OLDWALKSHOWPAGESTUFF VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0); +#endif gv->video.dorender =!gv->video.dorender; //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2; } + + switch(gv->kurokku.fpscap) + { + case 0: //turn this off if XT + //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!"); + gv->kurokku.frames_per_second=1; + break; + case 1: +#ifdef OLDWALKSHOWPAGESTUFF + //modexWaitBorder(); + //modexWaitBorder_start(); +#else + vga_wait_for_vsync(); + //vga_wait_for_vsync_end(); +#endif + gv->kurokku.frames_per_second=60; + break; + } PM_NextFrame(gv); } @@ -942,6 +1057,8 @@ void player_walk(player_t *player, map_view_t *map_v){ * end */ + + void mapScroll(map_view_t *mv, player_t *player) { //word x, y; /* coordinate for drawing */ diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index f7887686..546fbe29 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -42,6 +42,8 @@ #define SPRITE //#define TILERENDER +#define SHOWFPS +//#define OLDWALKSHOWPAGESTUFF #define PLAYERBMPDATAVAR gvar.player[pn].data #define PLAYERBMPDATA *PLAYERBMPDATAVAR @@ -204,51 +206,6 @@ boolean ZC_walk2(entity_t *ent, map_view_t *map_v); // Move gvar.player around and call map scrolling if required/possible void walk_player(player_t *player, map_view_t *map_v); -//check map edge -inline boolean ZC_mapEdgeChk(map_view_t *map_v, nibble dir, boolean pansw) -{ - int w,h; - - switch (pansw) - { - case 0: - w = map_v[0].map->width; - h = map_v[0].map->height; - break; - case 1: - w = map_v[0].page->ti.tilesw; - h = map_v[0].page->ti.tilesh; - break; - } - - switch(dir) - { - //no direction - default: - case 2: - //0000pip[0].video->startclk = (*clockw); - return false; - break; - //right movement - case 3: - if(map_v[0].tx >= 0 && map_v[0].tx+map_v[0].page->ti.tw < w) return true; - break; - //left movement - case 1: - if(map_v[0].tx > 0 && map_v[0].tx+map_v[0].page->ti.tw <= w) return true; - break; - //down movement - case 4: - if(map_v[0].ty >= 0 && map_v[0].ty+map_v[0].page->ti.th < h) return true; - break; - //up movement - case 0: - if(map_v[0].ty > 0 && map_v[0].ty+map_v[0].page->ti.th <= h) return true; - break; - } - return false; -} - // Scroll map in one direction (assumed from gvar.player's movement) void mapScroll(map_view_t *mv, player_t *player); diff --git a/src/xcroll.c b/src/xcroll.c index bbfe552d..2fd95869 100755 --- a/src/xcroll.c +++ b/src/xcroll.c @@ -26,7 +26,7 @@ #include "src/lib/16_dbg.h" #define FADE -#define NOMAPLOAD +//#define NOMAPLOAD //map_view_t mv[4]; static map_t map; @@ -161,6 +161,7 @@ void main(int argc, char *argv[]) { gvar.video.page[0].tlx=gvar.mv[0].tx*TILEWH; gvar.video.page[0].tly=gvar.mv[0].ty*TILEWH; + modexWaitBorder(); shinku(&gvar); //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square //to stop scrolling and have the gvar.player position data move to the edge of the screen with respect to the direction