X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fscroll.c;h=dd2db336a03f7457967c519b40f49f179dc0a540;hb=de41863a916d793f03f7dba0d5a85bb8c325accc;hp=6f2b78012fab9894730ff5e7358fb76f211dba07;hpb=7ce5762d7a6a9636ec65da629b1835fbd9794a0d;p=16.git
diff --git a/src/scroll.c b/src/scroll.c
old mode 100644
new mode 100755
index 6f2b7801..dd2db336
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -1,422 +1,369 @@
-/* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
- *
- * 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 "src/lib/scroll16.h"
-#include "src/lib/mapread.h"
-#include "src/lib/wcpu/wcpu.h"
-//====#include "src\lib\ems.c"
-
-//word far *clock= (word far*) 0x046C; /* 18.2hz clock */
-
-void main()
-{
-// word panswitch=0, panq=1, pand=0;
- word panpagenum=0; //for panning!
- int i;
- static word paloffset=0;
- planar_buf_t *p;
- const char *cpus;
- //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
- page_t screen, screen2, screen3;
- static map_t map;
- map_view_t mv[3];
- map_view_t *bg, *spri, *mask;//, *tmp;
- //map_view_db_t pgid[4];
- byte *dpal, *gpal;
- byte *ptr;
- byte *mappalptr;
- player_t player[MaxPlayers];
-
- player[0].persist_aniframe=0;
- player[0].speed=4;
- //extern struct inconfig inpu;
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2016 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.
+ *
+ */
- //player_t npc0;
-
-// atexit(qclean());
- /*if(!emmtest())
- {
- printf("Expanded memory is not present\n");
- exit(0);
- }
-
- if(!emmok())
- {
- printf("Expanded memory manager is not present\n");
- exit(0);
- }
-
- emsavail = emmavail();
- if(emsavail == -1)
- {
- printf("Expanded memory manager error\n");
- exit(0);
- }
- printf("There are %ld pages available\n",emsavail);
-
- if((emmhandle = emmalloc(emsavail)) < 0)
- {
- printf("Insufficient pages available\n");
- exit(0);
- }*/
-
- /* create the map */
- //printf("Total used @ before map load: %zu\n", oldfreemem-GetFreeSize());
- printf("Total free @ before map load: %zu\n", GetFreeSize());
- printf("Total far free @ before map load: %zu\n", GetFarFreeSize());
- getch();
-//0000 fprintf(stderr, "testing~\n");
-// loadmap("data/test.map", &map);
-//0000 fprintf(stderr, "yay map loaded~~\n");
-//---- map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly
- //if(isEMS()) printf("%d tesuto\n", coretotalEMS());
-//---- initMap(&map);
- mv[0].map = ↦
- mv[1].map = ↦
- mv[2].map = ↦
-
- /* draw the tiles */
- ptr = map.data;
- mappalptr = map.tiles->data->palette;
- /* data */
-//0000 printf("Total used @ before image loading: %zu\n", oldfreemem-GetFreeSize());
- player[0].data = bitmapLoadPcx("data/ptmp.pcx"); // load sprite
- //npctmp = bitmapLoadPcx("ptmp1.pcx"); // load sprite
-
- /* create the planar buffer */
-//0000 printf("Total used @ before planar buffer creation: %zu\n", oldfreemem-GetFreeSize());
- p = planar_buf_from_bitmap(&player[0].data);
-//0000 printf("Total used @ after planar buffer creation: %zu\n", oldfreemem-GetFreeSize());
-
- /*if(isEMS())
- {
- XMOVE mm;
- mm.length=sizeof(map);
- mm.sourceH=0;
- mm.sourceOff=(long)↦
- mm.destH=emmhandle;
- mm.destOff=1;
- //halp!
- ist = move_emem(&mm);
- printf("%d\n", coretotalEMS());
- if(!ist){ dealloc_emem(emmhandle); exit(5); }
- //printf("%d\n", emmhandle);
- }
-
- if(isEMS())
- {
- XMOVE mm;
- mm.length=emmhandle;
- mm.sourceH=0;
- mm.sourceOff=(long)&ptmp;
- mm.destH=emmhandle;
- mm.destOff=0;
- //halp!
- ist = move_emem(&mm);
- printf("%d\n", coretotalEMS());
- if(!ist){ dealloc_emem(emmhandle); exit(5); }
- //printf("%d\n", emmhandle);
- }
-*/
-
- /* input! */
- IN_Startup();
- IN_Default(0,&player,ctrl_Joystick);
-
- /* save the palette */
- dpal = modexNewPal();
- modexPalSave(dpal);
- modexFadeOff(4, dpal);
-
- VGAmodeX(1);
- modexPalBlack(); //reset the palette~
-// printf("Total used @ before palette initiation: %zu\n", oldfreemem-GetFreeSize());
- player[0].data.offset=(paloffset/3);
- modexPalUpdate(&player[0].data, &paloffset, 0, 0);
- //printf(" %d\n", sizeof(ptmp->data));
- //printf("1: %d\n", paloffset);
- map.tiles->data->offset=(paloffset/3);
- //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0);
- printf("\n====\n");
- printf("0 paloffset= %d\n", paloffset/3);
- printf("====\n\n");
- gpal = modexNewPal();
- modexPalSave(gpal);
- modexSavePalFile("data/g.pal", gpal);
- modexPalBlack(); //so player will not see loadings~
-
- /* setup camera and screen~ */
- screen = modexDefaultPage();
- screen.width += (TILEWH*2);
- screen.height += (TILEWH*2);//+QUADWH;
- mv[0].page = &screen;
- screen2 = modexNextPage(mv[0].page);
- mv[1].page = &screen2;
- screen3 = modexNextPage0(mv[1].page, 320, 240); //(352*176)+1024 is the remaining amount of memory left wwww
- //screen3 = modexNextPage0(mv2.page, 320, 192); //(352*176)+1024 is the remaining amount of memory left wwww
- mv[2].page = &screen3;
-
- /* set up paging */
- bg = &mv[0];
- spri = &mv[1];
- mask = &mv[2];
-
-//TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
- mapGoTo(bg, 0, 0);
- mapGoTo(spri, 0, 0);
- //mapGoTo(mask, 0, 0);
-
- //TODO: put player in starting position of spot
- //default player position on the viewable map
- player[0].tx = bg->tx + 10;
- player[0].ty = bg->ty + 8;
- player[0].x = player[0].tx*TILEWH;
- player[0].y = player[0].ty*TILEWH;
- player[0].triggerx = player[0].tx;
- player[0].triggery = player[0].ty+1;
- player[0].q=1;
- player[0].info.dir=2;
- player[0].hp=4;
- //npc
- /*npc0.tx = bg->tx + 1;
- npc0.ty = bg->ty + 1;
- npc0.x = npc0.tx*TILEWH;
- npc0.y = npc0.ty*TILEWH;
- npc0.triggerx = npc0.tx;
- npc0.triggery = npc0.ty+1;
- npc0.q=1;
- npc0.d=0;
- modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 64, 24, 32, &npctmp);*/
- modexDrawSpriteRegion(spri->page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, &player[0].data);
-
- modexShowPage(spri->page);
-// printf("Total used @ before loop: %zu\n", oldfreemem-GetFreeSize());
- modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 1);
- modexFadeOn(4, gpal);
+#include "src/lib/scroll16.h"
+#include "src/lib/16_timer.h"
+#include "src/lib/wcpu/wcpu.h"
+#include "src/lib/mapread.h"
+
+//#define FADE
+#define MODEX //this is for mode x initiating
+
+//word far *clock= (word far*) 0x046C; /* 18.2hz clock */
+//bitmap_t *p;
+global_game_variables_t gvar;
+static map_t map;
+player_t player[MaxPlayers];
+map_view_t mv[4];
+//word pn=0; //i forgot ww
+float t;
+sword bakapee;
+pan_t pan;
+//debugswitches
+boolean panswitch=0;
+//extern boolean pageflipflop=1;
+ unsigned int i;
+ const char *cpus;
+ //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
+
+ //map_view_db_t pgid[4];
+ word pg;
+//#ifdef FADE
+ //static word paloffset=0;
+ byte *dpal;
+//#endif
+ byte *gpal;
+ byte *ptr;
+ byte *mappalptr;
+
+void main(int argc, char *argv[])
+{
+ //byte *mesg=malloc(sizeof(dword));
+
+ if(argv[1]) bakapee = atoi(argv[1]);
+ else bakapee = 1;
+
+ // DOSLIB: check our environment
+ probe_dos();
+
+ // DOSLIB: what CPU are we using?
+ // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
+ // So this code by itself shouldn't care too much what CPU it's running on. Except that other
+ // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
+ // the CPU to carry out tasks. --J.C.
+ cpu_probe();
+
+ // DOSLIB: check for VGA
+ if (!probe_vga()) {
+ printf("VGA probe failed\n");
+ return;
+ }
+ // hardware must be VGA or higher!
+ if (!(vga_state.vga_flags & VGA_IS_VGA)) {
+ printf("This program requires VGA or higher graphics hardware\n");
+ return;
+ }
+
+ if (_DEBUG_INIT() == 0) {
+#ifdef DEBUGSERIAL
+ printf("WARNING: Failed to initialize DEBUG output\n");
+#endif
+ }
+ _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log
+ _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U);
+
+ pan.pn=1;
+
+ start_timer(&gvar);
+
+ /* create the map */
+ fprintf(stderr, "testing map load~ ");
+ loadmap("data/test.map", &map);
+ chkmap(&map, 0);
+ printf("chkmap ok ");
+ fprintf(stderr, "yay map loaded~~\n");
+
+ /* draw the tiles */
+#ifdef MODEX
+ ptr = map.data;
+ //mappalptr = map.tiles->btdata->palette;
+
+ /* data */
+ player[0].data = malloc(48*128); //TODO use exmm
+ *player[0].data = bitmapLoadPcx("data/chikyuu.pcx"); // load sprite
+
+ /* create the planar buffer */
+////++++ (player[0].data) = *planar_buf_from_bitmap(&p);
+ /*++++printf("load pee!! ");
+ pp = planar_buf_from_bitmap(&p);
+ printf("done!\n");*/
+
+#endif
+ /* input! */
+ IN_Startup();
+ IN_Default(0,&player,ctrl_Joystick);
+ //IN_Default(1,&player,ctrl_Joystick);
+
+ /* save the palette */
+#ifdef MODEX
+#ifdef FADE
+ dpal = modexNewPal();
+ modexPalSave(dpal);
+ modexFadeOff(4, dpal);
+#endif
+
+ textInit();
+ VGAmodeX(bakapee, 1, &gvar);
+// printf("%dx%d\n", gvar.video.page[0].sw, gvar.video.page[0].sh);
+#ifdef FADE
+ modexPalBlack(); //reset the palette~
+#endif
+#endif
+// printf("Total used @ before palette initiation: %zu\n", oldfreemem-GetFreeSize());
+//++++ player[0].data.offset=(paloffset/3);
+//++++ modexPalUpdate1(&player[0].data, &paloffset, 0, 0);
+ modexPalUpdate1(player[0].data->palette);
+//++++0000 modexPalUpdate1(map.tiles->btdata->palette);
+ //printf(" %d\n", sizeof(ptmp->data));
+ //printf("1: %d\n", paloffset);
+//++++ map.tiles->data->offset=(paloffset/3);
+ //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0);
+// printf("\n====\n");
+// printf("0 paloffset= %d\n", paloffset/3);
+// printf("====\n\n");
+#ifdef MODEX
+#ifdef FADE
+ gpal = modexNewPal();
+ modexPalSave(gpal);
+ modexSavePalFile("data/g.pal", gpal);
+ modexPalBlack(); //so player will not see loadings~
+#endif
+#endif
+
+ /* setup camera and screen~ */
+ modexHiganbanaPageSetup(&gvar.video);
+ for(i=0;idata, mv[0].page->data, mv[0].page->pagesize);
+
+ //TODO: put player in starting position of spot
+ //default player position on the viewable map
+ player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx;
+ player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny;
+ IN_initplayer(&player);//, 0);
+ //IN_initplayer(&player, 1);
+
+#ifndef SPRITE
+ modexClearRegion(mv[0].page, player[0].x, player[0].y-TILEWH, 16, 32, 15);
+ //modexClearRegion(mv[1].page, player[0].x, player[0].y-TILEWH, 16, 32, 15);
+#else
+ //PBUFSFUN(mv[1].page, player[0].x, player[0].y-TILEWH, 16, 64, 24, 32, PLAYERBMPDATA);
+ PBUFSFUN(mv[0].page, player[0].x, player[0].y-TILEWH, 16, 64, 16, 32, player[0].data);
+#endif
+
+ if(!pageflipflop) modexShowPage(mv[1].page);
+ else modexShowPage(mv[0].page);//!(gvar.video.p)
+ shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible.
+
+ /* buffer pages */
+// modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 47);
+// modexClearRegion(mv[3].page, 0, 0, mv[3].page->width, mv[3].page->height, 45);
+// {
+// 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 < vga_state.vga_height;j++,o += vga_state.vga_stride)
+// vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
+// }
+// }
+ modexClearRegion(mv[3].page, 0, 128, 24, 36, 15);
+
+#ifdef MODEX
+#ifdef FADE
+ modexFadeOn(4, gpal);
+#endif
+#endif
while(!IN_KeyDown(sc_Escape) && player[0].hp>0)
- {
- IN_ReadControl(0,&player);
- //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 player position data move to the edge of the screen with respect to the direction
- //when player[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map
-
- //player movement
- //if(!panswitch){
- walk(mv, player, 0);
- /*}else{
-//88 switch!
- //right movement
- if((IN_KeyDown(77) && !IN_KeyDown(75) && pand == 0) || pand == 2)
- {
- if(pand == 0){ pand = 2; }
- if(panq<=(TILEWH/(player[0].speed)))
- {
- switch(panpagenum)
- {
- case 0:
- //bg
- bg->page->dx++;
- modexShowPage(bg->page);
- break;
- case 1:
- //spri
- spri->page->dx++;
- modexShowPage(spri->page);
- break;
- case 2:
- //fg
- mask->page->dx++;
- modexShowPage(mask->page);
- break;
- }
- panq++;
- } else { panq = 1; pand = 0; }
- }
- //left movement
- if((IN_KeyDown(75) && !IN_KeyDown(77) && pand == 0) || pand == 4)
- {
- if(pand == 0){ pand = 4; }
- if(panq<=(TILEWH/(player[0].speed)))
- {
- switch(panpagenum)
- {
- case 0:
- //bg
- bg->page->dx--;
- modexShowPage(bg->page);
- break;
- case 1:
- //spri
- spri->page->dx--;
- modexShowPage(spri->page);
- break;
- case 2:
- //fg
- mask->page->dx--;
- modexShowPage(mask->page);
- break;
- }
- panq++;
- } else { panq = 1; pand = 0; }
- }
- //down movement
- if((IN_KeyDown(72) && !IN_KeyDown(80) && pand == 0) || pand == 3)
- {
- if(pand == 0){ pand = 3; }
- if(panq<=(TILEWH/(player[0].speed)))
- {
- switch(panpagenum)
- {
- case 0:
- //bg
- bg->page->dy--;
- modexShowPage(bg->page);
- break;
- case 1:
- //spri
- spri->page->dy--;
- modexShowPage(spri->page);
- break;
- case 2:
- //fg
- mask->page->dy--;
- modexShowPage(mask->page);
- break;
- }
- panq++;
- } else { panq = 1; pand = 0; }
- }
- //up movement
- if((IN_KeyDown(80) && !IN_KeyDown(72) && pand == 0) || pand == 1)
- {
- if(pand == 0){ pand = 1; }
- if(panq<=(TILEWH/(player[0].speed)))
- {
- switch(panpagenum)
- {
- case 0:
- //bg
- bg->page->dy++;
- modexShowPage(bg->page);
- break;
- case 1:
- //spri
- spri->page->dy++;
- modexShowPage(spri->page);
- break;
- case 2:
- //fg
- mask->page->dy++;
- modexShowPage(mask->page);
- break;
- }
- panq++;
- } else { panq = 1; pand = 0; }
- }
-}*/
-
-
- //the scripting stuf....
-
- //if(((player[0].triggerx == TRIGGX && player[0].triggery == TRIGGY) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5))
- if(((bg->map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5))
- {
- short i;
- for(i=800; i>=400; i--)
- {
- sound(i);
- }
- nosound();
- }
- if(player[0].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; }
- //debugging binds!
- //if(IN_KeyDown(0x0E)) while(1){ if(xmsmalloc(24)) break; }
- if(IN_KeyDown(2)){ modexShowPage(bg->page); panpagenum=0; }
- if(IN_KeyDown(3)){ modexShowPage(spri->page); panpagenum=1; }
- if(IN_KeyDown(4)){ modexShowPage(mask->page); panpagenum=2; }
- if(IN_KeyDown(25)){ pdump(bg->page); pdump(spri->page); } //p
- if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; pdump(bg->page); pdump(spri->page); }
- if(IN_KeyDown(22)){
- paloffset=0; modexPalBlack(); modexPalUpdate(&player[0].data, &paloffset, 0, 0);
- printf("1paloffset = %d\n", paloffset/3);
- modexPalUpdate(map.tiles->data, &paloffset, 0, 0);
- printf("2paloffset = %d\n", paloffset/3);
- pdump(bg->page); pdump(spri->page); }
- //pan switch
- //if(IN_KeyDown(88)){if(!panswitch) panswitch++; else panswitch--; } //f12
- //TSR
- if(IN_KeyDown(87)) //f11
- {
- VGAmodeX(0);
- IN_Shutdown();
- __asm
- {
- mov ah,31h
- int 21h
- }
- }
-
- if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync!
-
- }
-
- /* fade back to text mode */
- /* but 1st lets save the game palette~ */
- modexPalSave(gpal);
- modexSavePalFile("data/g.pal", gpal);
- modexFadeOff(4, gpal);
- VGAmodeX(0);
- IN_Shutdown();
- printf("Project 16 scroll.exe\n");
- printf("tx: %d\n", bg->tx);
- printf("ty: %d\n", bg->ty);
- printf("player[0].x: %d", player[0].x); printf(" player[0].y: %d\n", player[0].y);
- //if(player[0].hp==0) printf("%d wwww\n", player[0].y+8);
- //else printf("\nplayer[0].y: %d\n", player[0].y);
- printf("player[0].tx: %d", player[0].tx); printf(" player[0].ty: %d\n", player[0].ty);
- printf("player[0].triggx: %d", player[0].triggerx); printf(" player[0].triggy: %d\n", player[0].triggery);
- printf("player[0].hp: %d", (player[0].hp)); printf(" player[0].q: %d", player[0].q); printf(" player[0].info.dir: %d\n", player[0].info.dir);
- printf("tile data value at player trigger position: %d\n", bg->map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]);
- printf("palette offset: %d\n", paloffset/3);
-//++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize());
-//++++ printf("Total free: %zu\n", GetFreeSize());
- printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");
- printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");
- printf("Screen: %dx", screen.width); printf("%d\n", screen.height);
- printf("Screen2: %dx", screen2.width); printf("%d\n", screen2.height);
- //printf("map.width=%d map.height=%d map.data[0]=%d\n", bg->map->width, bg->map->height, bg->map->data[0]);
- //xmsfree(&map);
- //xmsfree(bg);
- //xmsfree(spri);
- //xmsfree(mask);
- //xmsreport();
- //emmclose(emmhandle);
- switch(detectcpu())
- {
- case 0: cpus = "8086/8088 or 186/88"; break;
- case 1: cpus = "286"; break;
- case 2: cpus = "386 or newer"; break;
- default: cpus = "internal error"; break;
- }
- printf("detected CPU type: %s\n", cpus);
- modexFadeOn(4, dpal);
-}
+ {
+ 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 player position data move to the edge of the screen with respect to the direction
+ //when player[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map
+
+ //player movement
+ IN_ReadControl(/*0,*/&player);
+ if(!panswitch){
+ walk(mv, player, 0);
+ }else{
+ panpagemanual(mv, player, 0);
+ //printf(" player[0].q: %d", player[0].q); printf(" player[0].d: %d\n", player[0].d);
+ }
+
+ //the scripting stuff....
+ //if(((player[0].triggerx == TRIGGX && player[0].triggery == TRIGGY) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5))
+ if(((mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5))
+ {
+ short i;
+ for(i=800; i>=400; i--)
+ {
+ sound(i);
+ }
+ nosound();
+ }
+ if(player[0].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; }
+ //debugging binds!
+ if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; }
+ if(IN_KeyDown(3)){ modexShowPage(mv[1].page); pan.pn=1; }
+ if(IN_KeyDown(4)){ modexShowPage(mv[2].page); pan.pn=2; }
+ if(IN_KeyDown(4+1)){ modexShowPage(mv[3].page); pan.pn=3; }
+ if(IN_KeyDown(25)){ modexpdump(mv[0].page); modexpdump(mv[1].page);
+ IN_UserInput(1,1);
+ } //p
+#ifdef MODEX
+#ifdef FADE
+ if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1,1); }
+ if(IN_KeyDown(22)){
+ paloffset=0; modexPalBlack(); modexPalUpdate(player[0].data, &paloffset, 0, 0);
+ printf("1paloffset = %d\n", paloffset/3);
+ modexPalUpdate(map.tiles->data, &paloffset, 0, 0);
+ printf("2paloffset = %d\n", paloffset/3);
+ modexpdump(mv[0].page); modexpdump(mv[1].page);
+ IN_UserInput(1,1);
+ }
+#endif
+#endif
+ //pan switch
+ if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12
+ if(IN_KeyDown(87)) //f11
+ {
+ pageflipflop=!pageflipflop;
+ IN_UserInput(1,1);
+// VGAmodeX(0, 0, &gvar);
+// IN_Shutdown();
+// __asm
+// {
+// mov ah,31h
+// int 21h
+// }
+ }
+ if(IN_KeyDown(68)) //f10
+ {
+ gvar.kurokku.fpscap=!gvar.kurokku.fpscap;
+ IN_UserInput(1,1);
+ }
+ if(IN_KeyDown(67)) //f9
+ {
+ modexClearRegion(mv[1].page, 0, 0, mv[1].page->width, mv[1].page->height, 2);
+ modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 3);
+ modexClearRegion(mv[3].page, 0, 0, mv[3].page->width, mv[3].page->height, 4);
+ modexClearRegion(mv[3].page, 0, 0, 20, 36, 15);
+ //IN_UserInput(1,1);
+ }
+ if(IN_KeyDown(66)) //f8
+ {
+// modexDrawSprite(mv[0].page, 16, 16, p);
+ modexDrawSprite(mv[0].page, 32+48, 16, (player[0].data));
+ }
+ //TODO fmemtest into page
+ /*if(IN_KeyDown(4+1)) //4
+ {
+ pg=1;
+ SELECT_ALL_PLANES();
+ _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);
+ }*/
+
+ //9
+ if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }
+ //if(IN_KeyDown(11)){ modexPalOverscan(15); }
+ if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync!
+ }
+
+ /* fade back to text mode */
+ /* but 1st lets save the game palette~ */
+#ifdef MODEX
+#ifdef FADE
+ modexPalSave(gpal);
+ modexSavePalFile("data/g.pal", gpal);
+ modexFadeOff(4, gpal);
+#endif
+ VGAmodeX(0, 1, &gvar);
+#endif
+ IN_Shutdown();
+ printf("\nProject 16 scroll.exe. This is just a test file!\n");
+ printf("version %s\n", VERSION);
+ printf("tx: %d ", mv[0].tx);
+ printf("ty: %d\n", mv[0].ty);
+ printf("\n");
+ printf("player vars:\n");
+ printf(" x: %d", player[0].x); printf(" y: %d\n", player[0].y);
+ //if(player[0].hp==0) printf("%d wwww\n", player[0].y+8);
+ //else printf("\nplayer[0].y: %d\n", player[0].y);
+ printf(" tx: %d", player[0].tx); printf(" ty: %d\n", player[0].ty);
+ printf(" triggx: %d", player[0].triggerx); printf(" triggy: %d\n", player[0].triggery);
+ printf(" hp: %d", (player[0].hp)); printf(" q: %d", player[0].q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].d);
+ printf(" pdir=%d\n", player[0].pdir);
+ printf(" tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]);
+// printf("palette offset: %d\n", paloffset/3);
+//++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize());
+//++++ printf("Total free: %zu\n", GetFreeSize());
+//not used now printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");
+//not used now printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");
+ printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height);
+ printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh);
+ printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw); printf("%d ", gvar.video.page[0].tilesh);
+ printf("tile resolution: %dx", gvar.video.page[0].tw); printf("%d\n", gvar.video.page[0].th);
+ printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny);
+ modexprintmeminfo(&gvar.video);
+ //printf("mv[%u].tx: %d", pan.pn, mv[pan.pn].tx); printf(" mv[%u].ty: %d ", pan.pn, mv[pan.pn].ty);
+ printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r);
+ printf("pageflipflop=%u\n", pageflipflop);
+ //0000printf("\ngvar.video.tickclk=%f\n", gvar.video.tickclk);
+ //0000printf("gvar.video.clk=%f", gvar.video.clk);
+ printf("\n");
+ //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]);
+
+ printf("\n");
+ switch(detectcpu())
+ {
+ case 0: cpus = "8086/8088 or 186/88"; break;
+ case 1: cpus = "286"; break;
+ case 2: cpus = "386 or newer"; break;
+ default: cpus = "internal error"; break;
+ }
+ printf("detected CPU type: %s\n", cpus);
+#ifdef MODEX
+#ifdef FADE
+ modexFadeOn(4, dpal);
+#endif
+#endif
+}