From e35dbd4c98f6b142b171d57297ca998957482fcf Mon Sep 17 00:00:00 2001 From: sparky4 Date: Sun, 21 Aug 2016 12:52:56 -0500 Subject: [PATCH] boink ok done~ --- makefile | 12 +- src/_scroll.c | 401 ++++++++++++++++++++ src/lib/_16_in.h | 310 +++++++++++++++ src/lib/_croll16.c | 925 +++++++++++++++++++++++++++++++++++++++++++++ swapbranchcode.sh | 12 + 5 files changed, 1655 insertions(+), 5 deletions(-) create mode 100755 src/_scroll.c create mode 100755 src/lib/_16_in.h create mode 100755 src/lib/_croll16.c create mode 100755 swapbranchcode.sh diff --git a/makefile b/makefile index ec647d0f..45b51334 100755 --- a/makefile +++ b/makefile @@ -91,9 +91,8 @@ FLAGS=$(CFLAGS) $(OFLAGS) $(DFLAGS) $(ZFLAGS) # VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) -16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_timer.$(OBJ) -GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) $(DOSLIBLIBS) -#16_vrs.$(OBJ) +16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_timer.$(OBJ) +GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) $(DOSLIBLIBS) 16_vrs.$(OBJ) 16_sprite.$(OBJ) #planar.$(OBJ) 16planar.$(OBJ) DOSLIBLIBS=$(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)cpu$(DIRSEP)dos86h$(DIRSEP)cpu.lib $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)dos$(DIRSEP)dos86h$(DIRSEP)dos.lib $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga$(DIRSEP)dos86h$(DIRSEP)vga.lib @@ -337,8 +336,11 @@ bakapee.$(OBJ): $(SRCLIB)bakapee.h $(SRCLIB)bakapee.c ##16planar.$(OBJ): $(MODEXLIB)16planar.h $(MODEXLIB)16planar.c ## wcl $(FLAGS) -c $(MODEXLIB)16planar.c -16_vrs.$(OBJ): $(SRCLIB)16_vrs.h $(SRCLIB)16_vrs.c - wcl $(FLAGS) -c $(SRCLIB)16_vrs.c +16_vrs.$(OBJ): $(SRCLIB)16_vrs.h $(SRCLIB)16_vrs.c $(DOSLIBLIBS) + wcl $(FLAGS) -c $(SRCLIB)16_vrs.c $(DOSLIBLIBS) +16_sprite.$(OBJ): $(SRCLIB)16_sprite.h $(SRCLIB)16_sprite.c + wcl $(FLAGS) -c $(SRCLIB)16_sprite.c + bitmap.$(OBJ): $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c wcl $(FLAGS) -c $(SRCLIB)bitmap.c diff --git a/src/_scroll.c b/src/_scroll.c new file mode 100755 index 00000000..7ad68101 --- /dev/null +++ b/src/_scroll.c @@ -0,0 +1,401 @@ +/* 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. + * + */ + +#include "src/lib/scroll16.h" +#include "src/lib/16_timer.h" +#include "src/lib/wcpu/wcpu.h" +#include "src/lib/16_sprite.h" +#include "src/lib/16_head.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]; +static unsigned char palette[768]; +int fd; +//word pn=0; //i forgot ww +//static planar_buf_t huge *pp; +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, *default_pal; +//#endif + byte *gpal; + byte *ptr; + byte *mappalptr; + +void main(int argc, char *argv[]) +{ + mminfo_t mm; mminfotype mmi; + struct sprite sp; + + byte *mesg=malloc(sizeof(dword)); + int i; + + if(argv[1]) bakapee = atoi(argv[1]); + else bakapee = 1; + +/* mm.mmstarted = 0; + + MM_Startup(&mm, &mmi); + CA_Startup(&gvar);*/ + // 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; + + /* data */ + i = read_vrs(&gvar, "data/spri/chikyuu.vrs", sp.spritesheet); + if (i) + { + puts("Error! Did not load sprite!"); + return; + } + puts("Sprite should be loaded now"); + putch('q'); + print_anim_ids(&sp); + putch('r'); + i = set_anim_by_id(&sp, 10); + if (i == -1) + { + printf("Anim id not found!"); + return; + } +/* player[0].spri = malloc(...) + * read_vrs(&gvar, "data/spri/chikyuu.vrs", player[0].spri->spritesheet); // load sprite + putch('s'); + print_anim_ids(player[0].spri); + putch('t'); + i = set_anim_by_id(player[0].spri, 10); + if (i == -1) + { + printf("Anim id not found!"); + return; + }*/ + player[0].spri = &sp; + + fd = open("data/spri/chikyuu.pal",O_RDONLY|O_BINARY); + if (fd >= 0) { + unsigned int i; + + read(fd,palette,768); + close(fd); + + vga_palette_lseek(0); + for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + } + +#endif + /* input! */ + IN_Startup(); + IN_Default(0,&player,ctrl_Joystick); + + /* save the palette */ +#ifdef MODEX +#ifdef FADE + dpal = modexNewPal(); + default_pal = modexNewPal(); + *default_pal = *dpal; + modexPalSave(dpal); + modexFadeOff(4, dpal); +#endif + + textInit(); + VGAmodeX(bakapee, 1, &gvar); +#ifdef FADE + modexPalBlack(); //reset the palette~ +#endif +#endif + modexPalUpdate1(palette); +#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); + animate_spri(player[0].spri); +#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) + { + 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(default_pal); 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 +} diff --git a/src/lib/_16_in.h b/src/lib/_16_in.h new file mode 100755 index 00000000..8ffd3dc8 --- /dev/null +++ b/src/lib/_16_in.h @@ -0,0 +1,310 @@ +/* Catacomb Apocalypse Source Code + * Copyright (C) 1993-2014 Flat Rock Software + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +// +// ID Engine +// ID_IN.h - Header file for Input Manager +// v1.0d1w +// By Jason Blochowiak +// Open Watcom port by sparky4 +// + +#ifndef __16_IN__ +#define __16_IN__ + +#include +#include "src/lib/16_head.h" +#include "src/lib/16_timer.h" +#include "src/lib/16_sprite.h" +#ifdef __WATCOMC__ +#include "src/lib/16_dbg.h" +#endif +#ifdef __DEBUG__ +//#define __DEBUG_InputMgr__ +#endif + +#ifdef __DEBUG_InputMgr__ +//#define TESTKEYIN +//#define TESTCONTROLNOISY +#endif + +extern boolean testkeyin,testcontrolnoisy; + +//if else for gfxtesting and direction +//player[pn].d == 2 || +//player[pn].d != 2 || +#define DIRECTIONIFELSE (player[pn].info.dir == 2) +//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) + +#define KeyInt 9 // The keyboard ISR number + +// Stuff for the joystick +#define JoyScaleMax 32768 +#define JoyScaleShift 8 +#define MaxJoyValue 5000 + +#define MaxPlayers 4 +#define MaxKbds 2 +#define MaxJoys 2 +#define MaxPads 2 +#define NumCodes 128 + +typedef byte ScanCode; +#define sc_None 0 +#define sc_Bad 0xff +#define sc_Return 0x1c +#define sc_Enter sc_Return +#define sc_Escape 0x01 +#define sc_Space 0x39 +#define sc_BackSpace 0x0e +#define sc_Tab 0x0f +#define sc_Alt 0x38 +#define sc_Control 0x1d +#define sc_CapsLock 0x3a +#define sc_LShift 0x2a +#define sc_RShift 0x36 +#define sc_UpArrow 0x48 +#define sc_DownArrow 0x50 +#define sc_LeftArrow 0x4b +#define sc_RightArrow 0x4d +#define sc_Insert 0x52 +#define sc_Delete 0x53 +#define sc_Home 0x47 +#define sc_End 0x4f +#define sc_PgUp 0x49 +#define sc_PgDn 0x51 +#define sc_F1 0x3b +#define sc_F2 0x3c +#define sc_F3 0x3d +#define sc_F4 0x3e +#define sc_F5 0x3f +#define sc_F6 0x40 +#define sc_F7 0x41 +#define sc_F8 0x42 +#define sc_F9 0x43 +#define sc_F10 0x44 +#define sc_F11 0x57 +#define sc_F12 0x59 + +#define sc_1 0x02 +#define sc_2 0x03 +#define sc_3 0x04 +#define sc_4 0x05 +#define sc_5 0x06 +#define sc_6 0x07 +#define sc_7 0x08 +#define sc_8 0x09 +#define sc_9 0x0a +#define sc_0 0x0b + +#define sc_A 0x1e +#define sc_B 0x30 +#define sc_C 0x2e +#define sc_D 0x20 +#define sc_E 0x12 +#define sc_F 0x21 +#define sc_G 0x22 +#define sc_H 0x23 +#define sc_I 0x17 +#define sc_J 0x24 +#define sc_K 0x25 +#define sc_L 0x26 +#define sc_M 0x32 +#define sc_N 0x31 +#define sc_O 0x18 +#define sc_P 0x19 +#define sc_Q 0x10 +#define sc_R 0x13 +#define sc_S 0x1f +#define sc_T 0x14 +#define sc_U 0x16 +#define sc_V 0x2f +#define sc_W 0x11 +#define sc_X 0x2d +#define sc_Y 0x15 +#define sc_Z 0x2c + +#define key_None 0 +#define key_Return 0x0d +#define key_Enter key_Return +#define key_Escape 0x1b +#define key_Space 0x20 +#define key_BackSpace 0x08 +#define key_Tab 0x09 +#define key_Delete 0x7f + +#define key_LSuper 0x5b +#define key_RSuper 0x5c +#define key_Menu 0x5d + +// Stuff for the mouse +#define MReset 0 +#define MButtons 3 +#define MDelta 11 + +#define MouseInt 0x33 +#ifdef DEMO0 +typedef enum { + demo_Off,demo_Record,demo_Playback,demo_PlayDone + } Demo; +#endif +typedef enum { + //ctrl_None, // MDM (GAMERS EDGE) - added + ctrl_Keyboard, + ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, + ctrl_Joystick, + ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, + ctrl_Mouse, + } ControlType; +typedef enum { + motion_Left = -1,motion_Up = -1, + motion_None = 0, + motion_Right = 1,motion_Down = 1 + } Motion; +typedef enum { + dir_North,//dir_NorthEast, + dir_West,//dir_Nortinest, + dir_None, + dir_East,//,dir_SouthEast, + dir_South,//dir_Soutinest, + } Direction; +typedef struct { + boolean near button0,button1,button2,button3; + int near x,y; + Motion near xaxis,yaxis; + Direction near dir; + } CursorInfo; + +typedef struct { + ScanCode near button0,button1, + //upleft, + up, + down, + left, + right + //upright, + //downleft, + //,downright + ; + } KeyboardDef; +typedef struct { + word near joyMinX,joyMinY, + threshMinX,threshMinY, + threshMaxX,threshMaxY, + joyMaxX,joyMaxY, + joyMultXL,joyMultYL, + joyMultXH,joyMultYH; + } JoystickDef; + +typedef struct +{ + int x; //player exact position on the viewable map + int y; //player exact position on the viewable map + int tx; //player tile position on the viewable map + int ty; //player tile position on the viewable map + int triggerx; //player's trigger box tile position on the viewable map + int triggery; //player's trigger box tile position on the viewable map + int sheetsetx; //NOT USED YET! player sprite sheet set on the image x + int sheetsety; //NOT USED YET! player sprite sheet set on the image y + byte d; //direction to render sprite!! wwww + byte q; //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www + byte near pdir; //previous direction~ + //byte near kd[2]; //array of arrow key pressed + word speed; //player speed! + word spt; //speed per tile +//0000 planar_buf_t huge *data; //supposively the sprite sheet data +// planar_buf_t data; //supposively the sprite sheet data +////0000---- + struct sprite *spri; //supposively the sprite sheet data + sword hp; //hitpoints of the player + int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ + CursorInfo info; + ControlType Controls; +} player_t; + +/* +============================================================================= + + GLOBAL VARIABLES + +============================================================================= +*/ +/*extern struct inconfig +{ + boolean MousePresent; + boolean JoysPresent[MaxJoys]; + boolean Keyboard[NumCodes]; + boolean Paused; + char LastASCII; + ScanCode LastScan; + + KeyboardDef KbdDefs[MaxKbds]; + JoystickDef JoyDefs[MaxJoys]; +} inpu;*/ + +#ifdef DEMO0 + static Demo DemoMode = demo_Off; + static byte /*_seg*/ *DemoBuffer; + static word DemoOffset,DemoSize; +#endif + +// Internal routines +extern void interrupt INL_KeyService(); +extern void Mouse(int x); +//static void INL_GetMouseDelta(int *x,int *y); +//static word INL_GetMouseButtons(void); +extern void IN_GetJoyAbs(word joy,word *xp,word *yp); +//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive); +//static word INL_GetJoyButtons(word joy); +extern word IN_GetJoyButtonsDB(word joy); +//static void INL_StartKbd(void); +//static void INL_ShutKbd(void); +//static boolean INL_StartMouse(void); +//static void INL_ShutMouse(void); +//static void INL_SetJoyScale(word joy); +extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy); +//static boolean INL_StartJoy(word joy); +//static void INL_ShutJoy(word joy); +extern void IN_Startup(); +extern void IN_Default(boolean gotit,player_t *player,ControlType nt); +extern void IN_Shutdown(); +extern void IN_SetKeyHook(void (*hook)()); +extern void IN_ClearKeysDown(); +//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); +extern void IN_ReadCursor(CursorInfo *info); +extern void near IN_ReadControl(int pn,player_t *player); +extern void IN_SetControlType(word pn,player_t *player,ControlType type); +#if DEMO0 +extern boolean IN_StartDemoRecord(word bufsize); +extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); +extern void IN_StopDemo(void); +extern void IN_FreeDemoBuffer(void); +#endif +extern byte *IN_GetScanName(ScanCode scan); +extern ScanCode IN_WaitForKey(); +extern char IN_WaitForASCII(); +extern void IN_AckBack(); +extern void IN_Ack(); +extern boolean IN_IsUserInput(); +extern boolean IN_UserInput(dword delay,boolean clear); +extern boolean IN_KeyDown(byte code); +extern void IN_ClearKey(byte code); +extern boolean IN_qb(byte kee); +void IN_initplayer(player_t *player, word pn); + +#endif diff --git a/src/lib/_croll16.c b/src/lib/_croll16.c new file mode 100755 index 00000000..2dc6f5aa --- /dev/null +++ b/src/lib/_croll16.c @@ -0,0 +1,925 @@ +/* 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. + * + */ +/* + scroll16 library~ +*/ +#include "src/lib/scroll16.h" +#include "src/lib/16_sprite.h" + +void walk(map_view_t *pip, player_t *player, word pn) +{ + #define INC_PER_FRAME if(player[pn].q&1) player[pn].persist_aniframe++; if(player[pn].persist_aniframe>4) player[pn].persist_aniframe = 1; + //printf("player[%d].d=%d\n", pn, player[pn].d); + switch(player[pn].d) + { + //no direction + case 2: + //0000pip[0].video->startclk = (*clockw); + break; + //right movement + case 3: + //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw); + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection! + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + animatePlayer(pip, player, pn, 1); + ScrollRight(pip, player, 3, pn); + ScrollRight(pip, player, 2, pn); + mapScrollRight(pip, player, !(pip[0].video->p), pn); + mapScrollRight(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; } + } + else if(player[pn].tx < pip[0].map->width && !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY)) + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + player[pn].x+=(player[pn].speed); + animatePlayer(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; } + } + else + { + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 16, 32); +#ifdef SPRITE + //PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 16, 32, 16, 32, PLAYERBMPDATA); + animate_spri(player[pn].spri); +#else + modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 16, 32, 14); +#endif + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].d = 2; + } + player[pn].triggerx = player[pn].tx+1; + player[pn].triggery = player[pn].ty; + break; + + //left movement + case 1: + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection! + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + animatePlayer(pip, player, pn, 1); + ScrollLeft(pip, player, 3, pn); + ScrollLeft(pip, player, 2, pn); + mapScrollLeft(pip, player, !(pip[0].video->p), pn); + mapScrollLeft(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; } + } + else if(player[pn].tx > 1 && !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY)) + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + player[pn].x-=(player[pn].speed); + animatePlayer(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; } + } + else + { + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 16, 32); +#ifdef SPRITE + //PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 16, 96, 16, 32, PLAYERBMPDATA); + animate_spri(player[pn].spri); +#else + modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 16, 32, 10); +#endif + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].d = 2; + } + player[pn].triggerx = player[pn].tx-1; + player[pn].triggery = player[pn].ty; + break; + + //down movement + case 4: + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY)) //collision detection! + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + animatePlayer(pip, player, pn, 1); + ScrollDown(pip, player, 3, pn); + ScrollDown(pip, player, 2, pn); + mapScrollDown(pip, player, !(pip[0].video->p), pn); + mapScrollDown(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; } + } + else if(player[pn].ty < pip[0].map->height && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY)) + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + player[pn].y+=(player[pn].speed); + animatePlayer(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; } + } + else + { + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 16, 32); +#ifdef SPRITE + //PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 16, 64, 16, 32, PLAYERBMPDATA); + animate_spri(player[pn].spri); +#else + modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 16, 32, 9); +#endif + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].d = 2; + } + player[pn].triggerx = player[pn].tx; + player[pn].triggery = player[pn].ty+1; + break; + + //up movement + case 0: + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY)) //collision detection! + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + animatePlayer(pip, player, pn, 1); + ScrollUp(pip, player, 3, pn); + ScrollUp(pip, player, 2, pn); + mapScrollUp(pip, player, !(pip[0].video->p), pn); + mapScrollUp(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; } + } + else if(player[pn].ty > 1 && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY)) + { + if(player[pn].q<=player[pn].spt) + { + INC_PER_FRAME; + player[pn].y-=(player[pn].speed); + animatePlayer(pip, player, 0, pn); + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; } + } + else + { + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 16, 32); +#ifdef SPRITE + //PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 16, 0, 16, 32, PLAYERBMPDATA); + animate_spri(player[pn].spri); +#else + modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 16, 32, 12); +#endif + if(!pageflipflop) modexShowPage(pip[1].page); + player[pn].d = 2; + } + player[pn].triggerx = player[pn].tx; + player[pn].triggery = player[pn].ty-1; + break; + } +} + +//panning page +void panpagemanual(map_view_t *pip, player_t *player, word pn) +{ + switch(player[pn].d) + { + //right movement + case 3: + if(pip[pip[0].pan->pn].tx >= 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw < pip[pip[0].pan->pn].page->tilesw) + { + if(player[pn].q<=player[pn].spt) + { + pip[pip[0].pan->pn].page->dx+=4; + modexShowPage(pip[pip[0].pan->pn].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; } + } + break; + + //left movement + case 1: + if(pip[pip[0].pan->pn].tx > 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw <= pip[pip[0].pan->pn].page->tilesw) + { + if(player[pn].q<=player[pn].spt) + { + pip[pip[0].pan->pn].page->dx-=4; + modexShowPage(pip[pip[0].pan->pn].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; } + } + break; + + //down movement + case 4: + if(pip[pip[0].pan->pn].ty >= 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th < pip[pip[0].pan->pn].page->tilesh) + { + if(player[pn].q<=player[pn].spt) + { + pip[pip[0].pan->pn].page->dy+=4; + modexShowPage(pip[pip[0].pan->pn].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; } + } + break; + + //up movement + case 0: + if(pip[pip[0].pan->pn].ty > 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th <= pip[pip[0].pan->pn].page->tilesh) + { + if(player[pn].q<=player[pn].spt) + { + pip[pip[0].pan->pn].page->dy-=4; + modexShowPage(pip[pip[0].pan->pn].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; } + } + break; + } + //if (player[pn].d!=2) printf("player[%u].d=%u player[%u].q=%u\n", pn, player[pn].d, pn, player[pn].q); +} + +/*map_t +allocMap(int w, int h) { + map_t result; + + result.width =w; + result.height=h; + result.data = malloc(sizeof(byte) * w * h); + //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024); + if(isEMS() || checkEMS()) + { + XMOVE mm; + //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map)) + mm.length=sizeof(result); + mm.sourceH=0; + mm.sourceOff=ptr2long(&result); + mm.destH=emmhandle; + mm.destOff=0; + ist = move_emem(&mm); + if(!ist){ dealloc_emem(emmhandle); exit(5); } + printf("%d\n", coretotalEMS()); + } + + return result; +}*/ + +/*void +initMap(map_t *map) { + // just a place holder to fill out an alternating pattern + int x, y, xx, yy; + int i, q; +// int tile = 1; + //if(!isEMS() || !checkEMS()) +// map->tiles = malloc(sizeof(tiles_t)); + //else + // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t)); + + //create the tile set + //if(!isEMS() || !checkEMS()) +// map->tiles->data = malloc(sizeof(bitmap_t)); + //else + // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t)); +// map->tiles->data->width = (TILEWH); +// map->tiles->data->height= TILEWH; + //if(!isEMS() || !checkEMS()) +// map->tiles->data->data = malloc((TILEWH*2)*TILEWH); + //else + // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH); +// map->tiles->tileHeight = TILEWH; +// map->tiles->tileWidth =TILEWH; +// map->tiles->rows = 1; +// map->tiles->cols = 1;//2; + + q=0; + //for(y=0; yheight; y++) { + //for(x=0; xwidth; x++) { + i=0; + for(yy=0; yytiles->data->data[i+1] = map->data[q];//28;//0x24; +// printf("[%d]", map->tiles->data->data[i]); + //}else{ + //map->tiles->data->data[i] = map->data[q];//0;//0x34; + //printf("]%d[==[%d]", i, map->tiles->data->data[i]); + //} + i++; + } +// printf("\n"); + } +// printf("[%d]", map->data[q]); + q++; +// } + //printf("\n\n"); +// } + + i=0; + for(y=0; yheight; y++) { + for(x=0; xwidth; x++) { +// map->data[i]=255; + printf("[%d]", map->data[i]); + //tile = tile ? 0 : 1; + i++; + } + //tile = tile ? 0 : 1; + } +}*/ + +void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) +{ + word x, y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv[id].page->dx += player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx >= mv[id].dxThresh ) + { + /* go forward one tile */ + mv[id].tx++; + /* Snap the origin forward */ + mv[id].page->data += 4; + + mv[id].page->dx = mv[id].map->tiles->tileWidth; + } + + /* draw the next column */ + x= mv[0].page->sw + mv[id].map->tiles->tileWidth; + if(player[plid].q%4) + if(id==0) + mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page->dx); + else + if(!pageflipflop && !pageploop) + modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); + mv[0].video->r=1; +} + + +void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) +{ + word x, y; /* coordinate for drawing */ + + /* decrement the pixel position and update the page */ + mv[id].page->dx -= player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx == 0) + { + /* go backward one tile */ + mv[id].tx--; + /* Snap the origin backward */ + mv[id].page->data -= 4; + + mv[id].page->dx = mv[id].map->tiles->tileWidth; + } + + /* draw the next column */ + x= 0; + if(player[plid].q%4) + if(id==0) + mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx); + else + if(!pageflipflop && !pageploop) + modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); + mv[0].video->r=1; +} + + +void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) +{ + word x, y; /* coordinate for drawing */ + + /* decrement the pixel position and update the page */ + mv[id].page->dy -= player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy == 0 ) + { + /* go down one tile */ + mv[id].ty--; + /* Snap the origin downward */ + mv[id].page->data -= mv[id].page->pi; + + mv[id].page->dy = mv[id].map->tiles->tileHeight; + } + + /* draw the next row */ + y= 0; + if(player[plid].q%3) + if(id==0) + mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy); + else + if(!pageflipflop && !pageploop) + modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); + mv[0].video->r=1; +} + +void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) +{ + word x, y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv[id].page->dy += player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy >= mv[id].dyThresh ) + { + /* go down one tile */ + mv[id].ty++; + /* Snap the origin downward */ + mv[id].page->data += mv[id].page->pi; + + mv[id].page->dy = mv[id].map->tiles->tileHeight; + } + + /* draw the next row */ + y= mv[0].page->sh + mv[id].map->tiles->tileHeight; + if(player[plid].q%3) + if(id==0) + mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page->dy); + else + if(!pageflipflop && !pageploop) + modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); + mv[0].video->r=1; +} + + +//TODO finish this wwww +void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid) +{ + /* increment the pixel position and update the page */ + mv[id].page->dx += player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx >= mv[0].dxThresh ) + { +// vga_setup_wm1_block_copy(); +// _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize); +// vga_restore_rm0wm0(); + /* Snap the origin forward */ + mv[id].page->data += 4; + mv[id].page->dx = mv[0].map->tiles->tileWidth; + } +} + +void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid) +{ + /* decrement the pixel position and update the page */ + mv[id].page->dx -= player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx == 0) + { +// vga_setup_wm1_block_copy(); +// _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize); +// vga_restore_rm0wm0(); + /* Snap the origin backward */ + mv[id].page->data -= 4; + mv[id].page->dx = mv[0].map->tiles->tileWidth; + } +} + +void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid) +{ + /* decrement the pixel position and update the page */ + mv[id].page->dy -= player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy == 0) + { +// vga_setup_wm1_block_copy(); +// _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize); +// vga_restore_rm0wm0(); + /* Snap the origin backward */ + mv[id].page->data -= mv[id].page->pi; + mv[id].page->dy = mv[0].map->tiles->tileWidth; + } +} + +void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid) +{ + /* increment the pixel position and update the page */ + mv[id].page->dy += player[plid].speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy >= mv[0].dxThresh ) + { +// vga_setup_wm1_block_copy(); +// _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize); +// vga_restore_rm0wm0(); + /* Snap the origin forward */ + mv[id].page->data += mv[id].page->pi; + mv[id].page->dy = mv[0].map->tiles->tileWidth; + } +} + +sword chkmap(map_t *map, word q) +{ +// bitmap_t bp; + static byte x[(MAPW*MAPH)+1] = +{ 1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 5, 6, 7, 8, 6, 6, 6, 6, 6, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 9, 10, 11, 12, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 13, 14, 15, 16, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10 }; +/*1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, \ +5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, \ +0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ +1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/ + //check for failed to load map + if((map->width == map->height == 0) && (q>0)) + { + //initiate a null map! + map->width=MAPW;///2; + map->height=MAPH;///2; +// map->data = malloc(((map->width*map->height)+1)*sizeof(byte)); + map->data = &x; + map->tiles = malloc(sizeof(tiles_t)); + //fix this to be far~ +// bp = bitmapLoadPcx("data/ed.pcx"); +// map->tiles->data = &bp; + map->tiles->debug_data = map->data; + map->tiles->tileHeight = 16; + map->tiles->tileWidth = 16; + map->tiles->rows = 1; + map->tiles->cols = 1; + map->tiles->debug_text = true; + } + else map->tiles->debug_text = false; + return 0; +} + +//TODO: player position here +void mapGoTo(map_view_t *mv, int tx, int ty) +{ + int px, py; + unsigned int i; + + /* set up the coordinates */ + mv[0].tx = mv[1].tx = tx; + mv[0].ty = mv[1].ty = ty; + mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth; + mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight; + + /* set up the thresholds */ + mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2; + mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2; + + /* draw the tiles */ + modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0); + py=0; + i=mv[0].ty * mv[0].map->width + mv[0].tx; + 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) { + mapDrawWRow(&mv[0], tx-1, ty, py); + i+=mv->map->width - tx; + } + if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); +// { +// 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 < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride) +// vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15! +// } +// } + modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 16, 32); +} + +void near +mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) +{ + word rx; + word ry; + word textx=0; + word texty=0; + //if(i==0) i=2; + if(i==0) + { + //wwww + modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color! + } + else + { + rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth); + ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight); +////0000printf("i=%d\n", i); + switch(t->debug_text) + { + case 0: +#ifndef TILERENDER + modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1)); + //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i])); +#else + PBUFBFUN (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); + /* 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)); + //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); +#endif + break; + case 1: + modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (t->debug_data[i])+1); + //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data)); + /*for(texty=0; texty<2; texty++) + { + for(textx=0; textx<2; textx++) + {*/ +// modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data)); +/* } + }*/ + break; + } + } +} + +void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset) +{ + word x; + int i; + poopoffset%=p[0].speed; +//printf("y: %d\n", poopoffset); + /* the position within the map array */ + i=ty * mv->map->width + tx; + for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) { + if(i>=0) { + /* we are in the map, so copy! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i++; /* next! */ + } +} + +void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset) +{ + int y; + int i; + poopoffset%=p[0].speed; +//printf("x: %d\n", poopoffset); + /* location in the map array */ + i=ty * mv->map->width + tx; + + /* We'll copy all of the columns in the screen, + i + 1 row above and one below */ + for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) { + if(i>=0) { + /* we are in the map, so copy away! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i += mv->map->width; + } +} + +void mapDrawWRow(map_view_t *mv, int tx, int ty, word y) +{ + word x; + int i; + + /* the position within the map array */ + i=ty * mv->map->width + tx; + for(x=0; xpage->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) { + if(i>=0) { + /* we are in the map, so copy! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i++; /* next! */ + } +} + +void mapDrawWCol(map_view_t *mv, int tx, int ty, word x) +{ + int y; + int i; + + /* location in the map array */ + i=ty * mv->map->width + tx; + + /* We'll copy all of the columns in the screen, + i + 1 row above and one below */ + for(y=0; ypage->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) { + if(i>=0) { + /* we are in the map, so copy away! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i += mv->map->width; + } +} + +/*void qclean() +{ + //setkb(0); +}*/ + +unsigned char shinku_fps_indicator_page = 2; +boolean pageflipflop = 1; +boolean pageploop = 1; + +/* sync */ +void shinku(global_game_variables_t *gv) +{ + word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen + word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen + word w = 64, h = 8, col = 7, bgcol = 0, type = 1; + byte o,o2,i; + //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4); + /* block copy to visible RAM from offscreen */ +// vga_setup_wm1_block_copy(); +// modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x+w, 0, w, h); +// o = *(gv->video.page[2].data); // source offscreen +// o2 = *(gv->video.page[shinku_fps_indicator_page].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride) +// for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) 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(); + if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second)) + { + sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv)); + //modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45); + modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, gv->pee); + gv->kurokku.tiku=0; + /* block copy to visible RAM from offscreen */ +// vga_setup_wm1_block_copy(); +// o = *(gv->video.page[shinku_fps_indicator_page].data); // source offscreen +// o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride) +// for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2); +// modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x, 0, w, h); + /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ +// vga_restore_rm0wm0(); + }else //copy dat sheet + gv->kurokku.tiku++; + + switch(gv->kurokku.fpscap) + { + case 0: + //modexprint(&(gv->video.page[shinku_fps_indicator_page]), x, y+8, type, col, bgcol, "sanic!"); + gv->kurokku.frames_per_second=1; + break; + case 1: + //turn this off if XT + //modexWaitBorder(); + vga_wait_for_vsync(); + gv->kurokku.frames_per_second=60; + break; + } + if(pageflipflop){ + if(gv->video.r){ + //vga_setup_wm1_block_copy(); + //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize); + //vga_restore_rm0wm0(); + if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height); + modexShowPage(&(gv->video.page[gv->video.p])); + if(!pageploop) gv->video.p=!gv->video.p; + gv->video.r=!gv->video.r; + //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2; + } + } +} + +void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) +{ + sword x = player[pn].x; + sword y = player[pn].y; + sword bx = x+16; //buffer's x + sword by = y+16; //buffer's y + word dire=32; //direction + sword qq; //scroll offset + word ls = player[pn].persist_aniframe; + + switch(scrollswitch) + { + case 0: + qq = 0; + break; + default: + qq = ((player[pn].q)*(player[pn].speed)); + break; + } + //x-=4; + y-=pip[0].map->tiles->tileHeight; + switch (player[pn].d) + { + case 0: + //up + dire*=player[pn].d; + y-=qq; + by-=4; + break; + case 3: + // right + dire*=(player[pn].d-2); + x+=qq; + bx+=4; + break; + case 2: + break; + case 4: + //down + dire*=(player[pn].d-2); + y+=qq; + by+=4; + break; + case 1: + //left + dire*=(player[pn].d+2); + x-=qq; + bx-=4; + break; + } + +#ifdef SPRITE +//#define FRAME1 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 32, dire, 16, 32, PLAYERBMPDATA); +//#define FRAME2 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 16, dire, 16, 32, PLAYERBMPDATA); +//#define FRAME3 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 16, 32, PLAYERBMPDATA); +//#define FRAME4 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 16, dire, 16, 32, PLAYERBMPDATA); +#define FRAME1 animate_spri(player[pn].spri); +#define FRAME2 animate_spri(player[pn].spri); +#define FRAME3 animate_spri(player[pn].spri); +#define FRAME4 animate_spri(player[pn].spri); +#else +#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire); +#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); +#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire); +#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); +#endif + if(!pageflipflop) + modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36); + else{ + //copy old bg to page0 + //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36); + //update buffer + //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36); + } +//modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height); + //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36); + /*modexCopyPageRegion(pip[pip->video->p].page, + pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/ +// else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40); + switch(ls) + { + case 1: + FRAME1 + break; + case 2: + FRAME2 + break; + case 3: + FRAME3 + break; + case 4: + FRAME4 + break; + } +// if(2>ls && ls>=1) { FRAME1 }else +// if(3>ls && ls>=2) { FRAME2 }else +// if(4>ls && ls>=3) { FRAME3 }else +// if(5>ls && ls>=4) { FRAME4 } + //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 16, 32); + //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by); + pip->video->r=1; +} diff --git a/swapbranchcode.sh b/swapbranchcode.sh new file mode 100755 index 00000000..6e635763 --- /dev/null +++ b/swapbranchcode.sh @@ -0,0 +1,12 @@ +#!/bin/bash +mv src/scroll.c src/scroll_.c +mv src/_scroll.c src/scroll.c +mv src/scroll_.c src/_scroll.c + +mv src/lib/16_in.h src/lib/16_in_.h +mv src/lib/_16_in.h src/lib/16_in.h +mv src/lib/16_in_.h src/lib/_16_in.h + +mv src/lib/scroll16.c src/lib/scroll1_.c +mv src/lib/_croll16.c src/lib/scroll16.c +mv src/lib/scroll1_.c src/lib/_croll16.c -- 2.39.5