From: sparky4 Date: Mon, 6 Jun 2016 16:42:00 +0000 (-0500) Subject: deleted: SCROLL.16L X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=4a30fbe923f9e7ef8f95ff7fa35553e1f015f8f3;p=16.git deleted: SCROLL.16L deleted: pcx2vrl deleted: pcxsscut deleted: scroll.smp deleted: src/lib/16_timer.c deleted: src/lib/modex16.c deleted: src/lib/modex16.h deleted: src/lib/scroll16.c deleted: src/lib/typdefst.h deleted: src/scroll.c deleted: vrl2vrs deleted: vrsdump --- diff --git a/SCROLL.16L b/SCROLL.16L deleted file mode 100755 index c1cf1cc5..00000000 --- a/SCROLL.16L +++ /dev/null @@ -1,24 +0,0 @@ -starting timer ok -index=4096 -chkmap ok Project 16 scroll.exe. This is just a test file! -version May 9 2016 02:45:56 -tx: 0 -ty: 0 -player.x: 160 player.y: 128 -player.tx: 10 player.ty: 8 -player.triggx: 10 player.triggy: 9 -player.hp: 4 player.q: 1 player.info.dir: 2 player.d: 2 pdir=0 -tile data value at player trigger position: 0 -Virtual Screen: 352x272 -Screen: 320x240 -virtual tile resolution: 22x17 -tile resolution: 20x15 -middle tile position: 10x8 -video memory remaining: 40447 -page [0]=(a000:0000) size=30208 sw=320 sh=240 width=352 height=272 - [1]=(a000:7600) size=30208 sw=320 sh=240 width=352 height=272 - [2]=(a000:ec00) size=30208 sw=320 sh=240 width=352 height=272 -mv[1].tx: 0 mv[1].ty: 0 panswitch=0 - - -detected CPU type: 386 or newer diff --git a/pcx2vrl b/pcx2vrl deleted file mode 100755 index 3d9ac6e6..00000000 Binary files a/pcx2vrl and /dev/null differ diff --git a/pcxsscut b/pcxsscut deleted file mode 100755 index d743ac3b..00000000 Binary files a/pcxsscut and /dev/null differ diff --git a/scroll.smp b/scroll.smp deleted file mode 100755 index 865f458d..00000000 Binary files a/scroll.smp and /dev/null differ diff --git a/src/lib/16_timer.c b/src/lib/16_timer.c deleted file mode 100755 index 0b5cf416..00000000 --- a/src/lib/16_timer.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 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/16_timer.h" - -clock_t start_timer(global_game_variables_t *gv) -{ - gv->kurokku.t = clock(); - gv->kurokku.tiku = 0; - gv->kurokku.clock_start = *clockw; - gv->kurokku.clock = clockw; - gv->kurokku.frames_per_second = 60; - gv->pee = _nmalloc(sizeof(byte)*16); - //turn this off if XT - switch(detectcpu()) - { - case 0: - gv->kurokku.fpscap=0; - break; - default: - gv->kurokku.fpscap=1; - break; - } - return gv->kurokku.t; -} - -double elapsed_timer(global_game_variables_t *gv) -{ - return (clock() - gv->kurokku.t) / CLOCKS_PER_SEC; -} - -double ticktock(global_game_variables_t *gv) -{ - double clocku; - clocku = (clock() - gv->kurokku.t) / CLOCKS_PER_SEC; - gv->kurokku.t = clock(); - return clocku; -} - -double time_in_seconds(global_game_variables_t *gv) -{ - return (gv->kurokku.t) / CLOCKS_PER_SEC; -} - -/*double time_in_seconds(time_t in_t) -{ - return (in_t) / CLOCKS_PER_SEC; -}*/ - -/* sync */ -void shinkutxt(global_game_variables_t *gv) -{ - //float t; - if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second)) - { - //t=(((*(gv->clock))-gv->clock_start) /18.2); - sprintf(gv->pee, "%f fps", (double)gv->kurokku.tiku/ticktock(gv)); - fprintf(stderr, "%s\n", gv->pee); - //(gv->clock_start)=*(gv->clock); - gv->kurokku.tiku=0; - } - gv->kurokku.tiku++; - switch(gv->kurokku.fpscap) - { - case 0: - gv->kurokku.frames_per_second=1; - break; - case 1: - //turn this off if XT - WaitPee(); - gv->kurokku.frames_per_second=60; - break; - } -} - -void WaitPee() -{ - while(inp(INPUT_STATUS_1) & 8) { - /* spin */ - } - - while(!(inp(INPUT_STATUS_1) & 8)) { - /* spin */ - } -} diff --git a/src/lib/modex16.c b/src/lib/modex16.c deleted file mode 100755 index 1f1e303b..00000000 --- a/src/lib/modex16.c +++ /dev/null @@ -1,1307 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 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 verson 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/modex16.h" - -byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */ - -static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette); -static byte tmppal[PAL_SIZE]; - -///////////////////////////////////////////////////////////////////////////// -// // -// setvideo() - This function Manages the video modes // -// // -///////////////////////////////////////////////////////////////////////////// -void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) -{ - union REGS in, out; - - switch (vq) - { - case 0: // deinit the video - // change to the video mode we were in before we switched to mode 13h - modexLeave(); - in.h.ah = 0x00; - in.h.al = gv->video.old_mode; - int86(0x10, &in, &out); - break; - default: // init the video - // get old video mode - //in.h.ah = 0xf; - //int86(0x10, &in, &out); - gv->video.old_mode = vgaGetMode();//out.h.al; - // enter mode - modexEnter(vq, cmem, gv); - break; - } -} - -static void -vgaSetMode(byte mode) -{ - union REGS regs; - - regs.h.ah = SET_MODE; - regs.h.al = mode; - int86(VIDEO_INT, ®s, ®s); - //int10_setmode(mode); -} - -//--------------------------------------------------- -// -// Use the bios to get the current video mode -// - -byte/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */ -vgaGetMode() -{ - return int10_getmode(); -} - -/* -========================= Entry Points ==========================- */ -void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) -{ - word i; - struct vga_mode_params cm; - int CRTParmCount; - - vgaSetMode(VGA_256_COLOR_MODE); - vga_enable_256color_modex(); - - update_state_from_vga_(); - vga_read_crtc_mode(&cm); - - /* reprogram the CRT controller */ - //outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */ - //outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ - - switch(vq) - { - case 1: - //CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); - /*for(i=0; ivideo.page[0].sw = vga_state.vga_width = 320; // VGA lib currently does not update this - gv->video.page[0].sh = vga_state.vga_height = 240; // VGA lib currently does not update this - /* virtual width and height. match screen, at first */ - gv->video.page[0].height = gv->video.page[0].sh; - gv->video.page[0].width = gv->video.page[0].sw; - - // mode X BYTE mode - cm.word_mode = 0; - cm.dword_mode = 0; - // 320x240 mode 60Hz - cm.horizontal_total=0x5f + 5; /* CRTC[0] -5 */ - cm.horizontal_display_end=0x4f + 1; /* CRTC[1] -1 */ - cm.horizontal_blank_start=0x50 + 1; /* CRTC[2] */ -// cm.horizontal_blank_end=0x82 + 1; /* CRTC[3] bit 0-4 & CRTC[5] bit 7 *///skewing ^^; - cm.horizontal_start_retrace=0x54;/* CRTC[4] */ - cm.horizontal_end_retrace=0x80; /* CRTC[5] bit 0-4 */ - //cm.horizontal_start_delay_after_total=0x3e; /* CRTC[3] bit 5-6 */ - //cm.horizontal_start_delay_after_retrace=0x41; /* CRTC[5] bit 5-6 */ - cm.vertical_total = 0x20D + 2; - cm.vertical_start_retrace = 0x1EA; - cm.vertical_end_retrace = 0x1EC; - cm.vertical_display_end = 480; - cm.vertical_blank_start = 0x1E7 + 1; - cm.vertical_blank_end = 0x206 + 1; - cm.clock_select = 0; /* misc register = 0xE3 25MHz */ - cm.vsync_neg = 1; - cm.hsync_neg = 1; - cm.offset = (vga_state.vga_width / (4 * 2)); // 320 wide (40 x 4 pixel groups x 2) - break; - case 2: // TODO: 160x120 according to ModeX_160x120regs - return; - case 3: // TODO: 160x120 according to ModeX_320x200regs - return; - case 4: // TODO: 160x120 according to ModeX_192x144regs - return; - case 5: // TODO: 160x120 according to ModeX_256x192regs - return; - default: - return; - } - - vga_state.vga_stride = cm.offset * 2; - vga_write_crtc_mode(&cm,0); - - /* clear video memory */ - switch (cmem) - { - case 1: { - /* clear video memory */ - dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA; /* used for faster screen clearing */ - vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/); - for(i = 0;i < 0x4000; i++) ptr[i] = 0x0000; // 0x4000 x dword = 64KB - } - break; - } - -// gv->video.page[0].tw = gv->video.page[0].sw/TILEWH; -// gv->video.page[0].th = gv->video.page[0].sh/TILEWH; - - //TODO MAKE FLEXIBLE~ -// gv->video.page[0].tilemidposscreenx = gv->video.page[0].tilesw; -// gv->video.page[0].tilemidposscreeny = (gv->video.page[0].tilesh/2)+1; -} - -void -modexLeave() { - /* VGAmodeX restores original mode and palette */ - vgaSetMode(TEXT_MODE); -} - -page_t -modexDefaultPage(page_t *p) -{ - page_t page; - - /* default page values */ - //page.data = VGA; - //page.data = (byte far *)(vga_state.vga_graphics_ram); - page.data = (vga_state.vga_graphics_ram); - page.dx = 0; - page.dy = 0; - page.sw = p->sw; - page.sh = p->sh; - page.width = p->sw+TILEWHD; - page.height = p->sh+TILEWHD; - page.tw = page.sw/TILEWH; - page.th = page.sh/TILEWH; - page.tilesw=page.width/TILEWH; - page.tilesh=page.height/TILEWH; - page.tilemidposscreenx = page.tw/2; - page.tilemidposscreeny = (page.th/2)+1; - page.stridew=page.width/4; - page.pagesize = (word)(page.width/4)*page.height; - page.id = 0; - - return page; -} - -/* returns the next page in contiguous memory - * the next page will be the same size as p, by default - */ -page_t -modexNextPage(page_t *p) { - page_t result; - - result.data = p->data + (p->pagesize); - result.dx = 0; - result.dy = 0; - result.sw = p->sw; - result.sh = p->sh; - result.width = p->width; - result.height = p->height; - result.tw = p->tw; - result.th = p->th; - result.tilesw = p->tilesw; - result.tilesh = p->tilesh; - result.id = p->id+1; - result.stridew=p->stridew; - result.pagesize = p->pagesize; - - return result; -} - -//next page with defined dimentions~ -page_t -modexNextPageFlexibleSize(page_t *p, word x, word y) -{ - page_t result; - - result.data = p->data + (p->pagesize); /* compute the offset */ - result.dx = 0; - result.dy = 0; - result.sw = x; - result.sh = y; - result.width = x; - result.height = y; - result.tw = result.sw/TILEWH; - result.th = result.sh/TILEWH; - result.tilesw=result.width/TILEWH; - result.tilesh=result.height/TILEWH; - result.id = p->id+1; - result.stridew=result.width/4; - result.pagesize = (word)(result.width/4)*result.height; - - return result; -} - -void modexCalcVmemRemain(video_t *video) -{ - byte i; - //printf("\n\n 1st vmem_remain=%u\n", video->vmem_remain); - for(i=0; inum_of_pages; i++) - { - video->vmem_remain-=video->page[i].pagesize; - //printf(" [%u], video->page[%u].pagesize=%u\n", i, i, video->page[i].pagesize); - //printf(" [%u], vmem_remain=%u\n", i, video->vmem_remain); - } -} - -void modexHiganbanaPageSetup(video_t *video) -{ - video->vmem_remain=65535U; - video->num_of_pages=0; - (video->page[0]) = modexDefaultPage(&(video->page[0])); video->num_of_pages++; //video->page[0].width += (TILEWHD); video->page[0].height += (TILEWHD); - (video->page[1]) = modexNextPage(&(video->page[0])); video->num_of_pages++; - (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), TILEWH*4, TILEWH*4); video->num_of_pages++; - (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].sw, 208); video->num_of_pages++; -// (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), video->page[0].width, 172); video->num_of_pages++; -// (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), 72, 128); video->num_of_pages++; - modexCalcVmemRemain(video); - video->p=0; - video->r=1; -} - -void -modexShowPage(page_t *page) { - word high_address; - word low_address; - word offset; - byte crtcOffset; - - /* calculate offset */ - offset = (word) page->data; - offset += page->dy * (page->width >> 2 ); - offset += page->dx >> 2; - - /* calculate crtcOffset according to virtual width */ - crtcOffset = page->width >> 3; - - high_address = HIGH_ADDRESS | (offset & 0xff00); - low_address = LOW_ADDRESS | (offset << 8); - - /* wait for appropriate timing and then program CRTC */ - 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 */ - while (!(inp(INPUT_STATUS_1) & VRETRACE)); - - /* do PEL panning here */ - outp(AC_INDEX, 0x33); - outp(AC_INDEX, (page->dx & 0x03) << 1); -} - -void -modexPanPage(page_t *page, int dx, int dy) { - page->dx = dx; - page->dy = dy; -} - -void -modexSelectPlane(byte plane) { - outp(SC_INDEX, MAP_MASK); /* select plane */ - outp(SC_DATA, plane); -} - -void -modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) { - word pageOff = (word) page->data; - word xoff=x/4; /* xoffset that begins each row */ - word scanCount=w/4; /* number of iterations per row (excluding right clip)*/ - word poffset = pageOff + y*(page->stridew) + xoff; /* starting offset */ - word nextRow = page->stridew-scanCount-1; /* loc of next row */ - byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */ - byte rclip[] = {0x00, 0x01, 0x03, 0x07}; - byte left = lclip[x&0x03]; - byte right = rclip[(x+w)&0x03]; - - /* handle the case which requires an extra group */ - if((x & 0x03) && !((x+w) & 0x03)) { - right=0x0f; - } - - __asm { - PUSHF - PUSH ES - PUSH AX - PUSH BX - PUSH CX - PUSH DX - PUSH SI - PUSH DI - MOV AX, SCREEN_SEG ; go to the VGA memory - MOV ES, AX - MOV DI, poffset ; go to the first pixel - MOV DX, SC_INDEX ; point to the map mask - MOV AL, MAP_MASK - OUT DX, AL - INC DX - MOV AL, color ; get ready to write colors - SCAN_START: - MOV CX, scanCount ; count the line - MOV BL, AL ; remember color - MOV AL, left ; do the left clip - OUT DX, AL ; set the left clip - MOV AL, BL ; restore color - STOSB ; write the color - DEC CX - JZ SCAN_DONE ; handle 1 group stuff - - ;-- write the main body of the scanline - MOV BL, AL ; remember color - MOV AL, 0x0f ; write to all pixels - OUT DX, AL - MOV AL, BL ; restore color - REP STOSB ; write the color - SCAN_DONE: - MOV BL, AL ; remeber color - MOV AL, right - OUT DX, AL ; do the right clip - MOV AL, BL ; restore color - STOSB ; write pixel - ADD DI, nextRow ; go to the next row - DEC h - JNZ SCAN_START - POP DI - POP SI - POP DX - POP CX - POP BX - POP AX - POP ES - POPF - } -} - -/* moved to src/lib/modex16/16render.c */ - -/* copy a region of video memory from one page to another. - * It assumes that the left edge of the tile is the same on both - * regions and the memory areas do not overlap. - */ -void -modexCopyPageRegion(page_t *dest, page_t *src, - word sx, word sy, - word dx, word dy, - word width, word height) -{ - word doffset = (word)dest->data + dy*(dest->stridew) + dx/4; - word soffset = (word)src->data + sy*(src->stridew) + sx/4; - word scans = vga_state.vga_stride; - word nextSrcRow = src->stridew - scans - 1; - word nextDestRow = dest->stridew - scans - 1; - byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */ - byte rclip[] = {0x0f, 0x01, 0x03, 0x07}; - byte left = lclip[sx&0x03]; - byte right = rclip[(sx+width)&0x03]; - - __asm { - PUSHF - PUSH ES - PUSH AX - PUSH BX - PUSH CX - PUSH DX - PUSH SI - PUSH DI - - MOV AX, SCREEN_SEG ; work in the vga space - MOV ES, AX ; - MOV DI, doffset ; - MOV SI, soffset ; - - MOV DX, GC_INDEX ; turn off cpu bits - MOV AX, 0008h ; - OUT DX, AX - - MOV AX, SC_INDEX ; point to the mask register - MOV DX, AX ; - MOV AL, MAP_MASK ; - OUT DX, AL ; - INC DX ; - - ROW_START: - PUSH DS - MOV AX, ES - MOV DS, AX - MOV CX, scans ; the number of latches - - MOV AL, left ; do the left column - OUT DX, AL ; - MOVSB ; - DEC CX ; - - MOV AL, 0fh ; do the inner columns - OUT DX, AL - REP MOVSB ; copy the pixels - - MOV AL, right ; do the right column - OUT DX, AL - MOVSB - POP DS - - MOV AX, SI ; go the start of the next row - ADD AX, nextSrcRow ; - MOV SI, AX ; - MOV AX, DI ; - ADD AX, nextDestRow ; - MOV DI, AX ; - - DEC height ; do the rest of the actions - JNZ ROW_START ; - - MOV DX, GC_INDEX+1 ; go back to CPU data - MOV AL, 0ffh ; none from latches - OUT DX, AL ; - - POP DI - POP SI - POP DX - POP CX - POP BX - POP AX - POP ES - POPF - } -} - - -/* fade and flash */ -void -modexFadeOn(word fade, byte *palette) { - fadePalette(-fade, 64, 64/fade+1, palette); -} - - -void -modexFadeOff(word fade, byte *palette) { - fadePalette(fade, 0, 64/fade+1, palette); -} - - -void -modexFlashOn(word fade, byte *palette) { - fadePalette(fade, -64, 64/fade+1, palette); -} - - -void -modexFlashOff(word fade, byte *palette) { - fadePalette(-fade, 0, 64/fade+1, palette); -} - - -static void -fadePalette(sbyte fade, sbyte start, word iter, byte *palette) { - word i; - byte dim = start; - - /* handle the case where we just update */ - if(iter == 0) { - modexPalUpdate1(palette); - return; - } - - while(iter > 0) { /* FadeLoop */ - for(i=0; i 127) { - tmppal[i] = 0; - } else if(tmppal[i] > 63) { - tmppal[i] = 63; - } - } - modexPalUpdate1(tmppal); - iter--; - dim += fade; - } -} - - -/* save and load */ -void -modexPalSave(byte *palette) { - int i; - - outp(PAL_READ_REG, 0); /* start at palette entry 0 */ - for(i=0; ipalette; - word w=0; - word q=0; - word qq=0; - static word a[PAL_SIZE]; //palette array of change values! - word z=0, aq=0, aa=0, pp=0; - - //modexWaitBorder(); - vga_wait_for_vsync(); - if((*i)==0) - { - memset(a, -1, sizeof(a)); - outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */ - } - else if(qp==0) - { - q=(*i); - } - else - { - q=(*i); - qq=(*i)/3; -// printf("q: %02d\n", (q)); -// printf("qq: %02d\n", (qq)); - //printf(" (*i)-q=%02d\n", (*i)-q); - outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */ - } - if((*i)0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else - if(((((*i)-q)%3==0)) && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) - { - w++; - break; - } - else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3)) - { - //printf("qp=%d\n", qp); - //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]); - printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp); - //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit! - if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; } - } - else - { - if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0); - else - if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]); - else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]); - printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); } - } - } - //if(qp>0) printf("qp=%d\n", qp); - //if(qp>0) printf(" (*i)=%d\n", (*i)/3); - } - //modexWaitBorder(); /* waits one retrace -- less flicker */ - vga_wait_for_vsync(); - if((*i)>=PAL_SIZE/2 && w==0) - { - for(; (*i)0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else - if(((((*i)-q)%3==0)) && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) - { - w++; - break; - } - else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3)) - { - //printf("qp=%d\n", qp); - //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]); - printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp)); - //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit! - if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; } - } - else - { - if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]); - else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]); - printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); } - } - } - //printf(" (*i)=%d\n", (*i)/3); - } - -printf("\nqqqqqqqq\n\n"); - - //palette checker~ - if(q>0 && qp==0) - { - long lq; - long bufSize = (bmp->width * bmp->height); - pp = q; - //printf("1(*i)=%02d\n", (*i)/3); - //printf("1z=%02d\n", z/3); - modexchkcolor(bmp, &q, &a, &aa, &z, i); - //printf("2(*i)=%02d\n", (*i)/3); - //printf("2z=%02d\n", z/3); - aq=0; -aqpee: - while(aq<=aa) - { -// printf("a[%02d]=(%d)\n", aq, a[aq]); - if(a[aq]==-1) aq++; - else { aqoffset++; break; } - } -//update the image data here! - for(lq=0; lqoffset for this spot! - NO! wwww - */ - - /* - Facking bloody point the values of the changed palette to correct values.... major confusion! wwww - */ - - //(offset/bmp->offset)*bmp->offset - - - //printf("%02d ",bmp->data[lq]+bmp->offset); - //if(lq > 0 && lq%bmp->width==0) printf("\n"); - //printf("%02d_", bmp->data[lq]+bmp->offset); - /*if(bmp->data[lq]+bmp->offset==aq) - { - //printf("%02d", bmp->data[lq]); - //printf("\n%02d\n", bmp->offset); - printf("aq=%02d ", aq); - printf("a[aq]=%02d ", a[aq]); - printf("a[aq]+aqpp=%02d ", a[aq]+aqpp); - printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp); - //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]); -//++++ bmp->data[lq]=a[aq]-aqpp; -// printf("_%d ", bmp->data[lq]); - //if(lq > 0 && lq%bmp->width==0) printf("\n"); - } - else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp) - { - if(bmp->data[lq]+bmp->offset >= aq) - { - bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3); - //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3); - } - else bmp->data[lq]+=(bmp->offset-aqpp); - }*/ - - //printf("%02d`", bmp->data[lq]); - //if(lq > 0 && lq%bmp->width==0) printf("\n"); - } - -//printf(" aq=%02d\n", aq); -//printf(" aa=%02d\n", aa); - - //update the palette~ - modexPalUpdate(bmp, &pp, aq, aqoffset); - (*i)=pp; - - if(aqdata; - /* Each address accesses four neighboring pixels, so set - Write Plane Enable according to which pixel we want - to modify. The plane is determined by the two least - significant bits of the x-coordinate: */ - modexSelectPlane(PLANE(x)); - //outp(SC_INDEX, 0x02); - //outp(SC_DATA, 0x01 << (x & 3)); - - /* The offset of the pixel into the video segment is - offset = (width * y + x) / 4, and write the given - color to the plane we selected above. Heed the active - page start selection. */ - VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff] = color; - -} - -byte modexgetPixel(page_t *page, int x, int y) -{ - word pageOff = (word) page->data; - /* Select the plane from which we must read the pixel color: */ - outpw(GC_INDEX, 0x04); - outpw(GC_INDEX+1, x & 3); - - return VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff]; - -} - -void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) -{ - word s, o, w; - word x_draw = x; - word addr = (word) romFontsData.l; - word addrq = (page->width/4) * y + (x / 4) + ((word)page->data); - word addrr = addrq; - byte c; - - s=romFonts[t].seg; - o=romFonts[t].off; - w=romFonts[t].charSize; - romFontsData.chw=0; - - for(; *str != '\0'; str++) - { - c = (*str); - if(c=='\n') - { - x = x_draw; - romFontsData.chw = 0; - addrq += (page->width / 4) * 8; - addrr = addrq; - y += 8; - continue; - } - - // load the character into romFontsData.l - // no need for inline assembly! - // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. - _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/); - modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); - x_draw += 8; /* track X for edge of screen */ - addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ - } -} - -void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) -{ - word i, s, o, w, j, xp; - byte l[1024]; - word addr = (word) l; - word chw=0; - byte c; - - switch(t) - { - case 0: - w=14; - break; - case 1: - w=8; - break; - case 2: - w=8; - break; - case 3: - w=16; - break; - default: - t=3; - w=16; - break; - } - - s=romFonts[t].seg; - o=romFonts[t].off; - - for(; *str != '\0'; str++) - { - c = (*str); - if((c=='\n'/* || c=="\ -"*/)/* || chw>=page->width*/) - { - chw=0; - y+=w; - continue; - } - //load the letter 'A' - __asm { - PUSHF - PUSH ES - PUSH AX - PUSH BX - PUSH CX - PUSH DX - PUSH SI - PUSH DI - - MOV DI, addr - MOV SI, o - MOV ES, s - SUB AH, AH - MOV AL, c ; the letter - MOV CX, w - MUL CX - ADD SI, AX ;the address of charcter - L1: MOV AX, ES:SI - MOV DS:DI, AX - INC SI - INC DI - DEC CX - JNZ L1 - - POP DI - POP SI - POP DX - POP CX - POP BX - POP AX - POP ES - POPF - } - - for(i=0; i>=1; - } - } - chw += xp; - } -} - -/* palette dump on display! */ -void modexpdump(page_t *pee) -{ - int mult=(QUADWH); - int palq=(mult)*TILEWH; - int palcol=0; - int palx, paly; - for(paly=0; palywidth, page->height, color); - /* set map mask to all 4 planes */ - outpw(SC_INDEX, 0xff02); - //_fmemset(VGA, color, 16000); - _fmemset(Where, color, page->width*(page->height)/4); -} - -void -modexWaitBorder() { - while(inp(INPUT_STATUS_1) & 8) { - // spin - } - - while(!(inp(INPUT_STATUS_1) & 8)) { - //spin - } -} - -void bios_cls() { - VGA_ALPHA_PTR ap; - VGA_RAM_PTR rp; - unsigned char m; - - m = int10_getmode(); - if ((rp=vga_state.vga_graphics_ram) != NULL && !(m <= 3 || m == 7)) { - unsigned int i,im; - - im = (FP_SEG(vga_state.vga_graphics_ram_fence) - FP_SEG(vga_state.vga_graphics_ram)); - if (im > 0xFFE) im = 0xFFE; - im <<= 4; - for (i=0;i < im;i++) vga_state.vga_graphics_ram[i] = 0; - } - else if ((ap=vga_state.vga_alpha_ram) != NULL) { - unsigned int i,im; - - im = (FP_SEG(vga_state.vga_alpha_ram_fence) - FP_SEG(vga_state.vga_alpha_ram)); - if (im > 0x7FE) im = 0x7FE; - im <<= 4 - 1; /* because ptr is type uint16_t */ - for (i=0;i < im;i++) vga_state.vga_alpha_ram[i] = 0x0720; - } - else { - printf("WARNING: bios cls no ptr\n"); - } -} - -void modexprintmeminfo(video_t *v) -{ - byte i; - printf("video memory remaining: %u\n", v->vmem_remain); - printf("page "); - for(i=0; inum_of_pages;i++) - { - printf(" [%u]=", i); - printf("(%Fp)", (v->page[i].data)); - printf(" size=%u", v->page[i].pagesize); - printf(" sw=%lu sh=%lu ", (unsigned long)v->page[i].sw, (unsigned long)v->page[i].sh); - printf(" width=%lu height=%lu", (unsigned long)v->page[i].width, (unsigned long)v->page[i].height); - printf("\n"); - } -} - -void update_state_from_vga_() { - unsigned char c; - - vga_state.vga_pos_x = 0; - vga_state.vga_pos_y = 0; - vga_state.vga_stride = 80; - vga_state.vga_height = 25; - vga_state.vga_width = 80; - vga_state.vga_9wide = 1; - - if (vga_state.vga_flags & VGA_IS_VGA) { /* VGA only. EGA cards DO have the misc. output reg but it's write-only */ - /* update state from H/W which I/O port */ - c = inp(0x3CC); - if (c & 1) { - vga_state.vga_base_3x0 = 0x3D0; - } - else { - vga_state.vga_base_3x0 = 0x3B0; - } - - /* now ask the graphics controller where/how VGA memory is mapped */ - c = vga_read_GC(6); - /* bit 0 = alpha disable (if set, graphics) */ - vga_state.vga_alpha_mode = ((c & 1) == 0); - /* bits 2-3 memory map select */ - update_state_vga_memory_map_select((c>>2)&3); - - /* read the sequencer: are we in 8 or 9 dot mode? */ - c = vga_read_sequencer(0x1); - vga_state.vga_9wide = (c & 1) == 0; - - /* read from the CRTC controller the stride, width, and height */ - vga_state.vga_stride = vga_read_CRTC(0x13) * 2; /* "offset" register */ - if (vga_state.vga_alpha_mode) { - vga_state.vga_width = vga_state.vga_stride; - vga_sync_hw_cursor(); - /* TODO: read vertical blank values and calculate active area, then divide by scan line height, to get alpha height */ - /* TODO: read horizontal blank values to calculate active area, then visible width */ - } - else { - /* TODO: similar semantics for graphics mode */ - } - } - else if (vga_state.vga_flags & VGA_IS_EGA) { - /* Well the EGA has similar registers BUT they aren't readable. So we have to - * guess based on other information handed to us */ - - /* reading the misc. output register doesn't work, use BIOS data area */ - c = *((unsigned char far*)MK_FP(0x40,0x63)); - if ((c&0xF0) == 0xD0) - vga_state.vga_base_3x0 = 0x3D0; - else if ((c&0xF0) == 0xB0) - vga_state.vga_base_3x0 = 0x3B0; - else { - vga_state.vga_base_3x0 = 0x3D0; - } - - /* reading from the graphics controller (0x3CE) doesn't work, deduce from BIOS mode */ - c = int10_getmode(); - switch (c) { - case 0: case 1: case 2: case 3: case 7: - vga_state.vga_alpha_mode = 1; - - /* the best we can do is assume B0000 if CRTC is at 3Bx or B8000 if at 3Dx even though it's possible to map at B8000 and 3Bx */ - if (vga_state.vga_base_3x0 == 0x3B0) - update_state_vga_memory_map_select(2); - else - update_state_vga_memory_map_select(3); - break; - case 4: case 5: case 6: - vga_state.vga_alpha_mode = 0; - update_state_vga_memory_map_select(3); - break; - case 13: case 14: case 15: case 16: case 17: case 18: default: - vga_state.vga_alpha_mode = 0; - update_state_vga_memory_map_select(1); - break; - } - - /* read from the CRTC controller the stride, width, and height */ - vga_state.vga_stride = vga_read_CRTC(0x13) * 2; /* "offset" register */ - if (vga_state.vga_alpha_mode) { - vga_state.vga_width = vga_state.vga_stride; - vga_sync_hw_cursor(); - /* TODO: read vertical blank values and calculate active area, then divide by scan line height, to get alpha height */ - /* TODO: read horizontal blank values to calculate active area, then visible width */ - } - else { - /* TODO: similar semantics for graphics mode */ - } - } - else if (vga_state.vga_flags & VGA_IS_CGA) { - vga_state.vga_base_3x0 = 0x3D0; /* always at 0x3Dx */ - - /* TODO: If Tandy, detect state */ - - /* read the status register to determine the state of the CGA... oh wait... we can't. - * fine. deduce it from the BIOS video mode. */ - c = int10_getmode(); - switch (c) { - case 0: case 1: case 2: case 3: case 7: - vga_state.vga_alpha_mode = 1; - break; - default: - vga_state.vga_alpha_mode = 0; - break; - } - - if (c <= 1) { - vga_state.vga_stride = 40; - vga_state.vga_width = 40; - } - - update_state_vga_memory_map_select(3); /* 0xB8000 */ - } - else if (vga_state.vga_flags & VGA_IS_MDA) { - vga_state.vga_base_3x0 = 0x3B0; /* always at 0x3Bx */ - vga_state.vga_alpha_mode = 1; /* stock MDA doesn't have graphics */ - - /* Hercules MDA: It would be nice to be able to read bit 2 of the display control, - * except that the port is write-only. Thanks >:( */ - update_state_vga_memory_map_select(2); /* 0xB0000 */ - } - - vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = vga_state.vga_stride; -} diff --git a/src/lib/modex16.h b/src/lib/modex16.h deleted file mode 100755 index 9ce226e1..00000000 --- a/src/lib/modex16.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 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. - * - */ -/* - * Functions for handling modex and doing other basic graphics stuff. - */ -#ifndef MODEX16_H -#define MODEX16_H - -#include "src/lib/16_head.h" -#include "src/lib/bitmap.h" -#include "src/lib/planar.h" -#include "src/lib/modex16/16planar.h" -#include "src/lib/16text.h" -#include "src/lib/modex16/16render.h" -#include "src/lib/modex16/320x240.h" -// #include "src/lib/modex16/320x200.h" -// #include "src/lib/modex16/256x192.h" -// #include "src/lib/modex16/192x144_.h" -// #include "src/lib/modex16/160x120.h" - -#include -#include -#include -#include - -static struct pcxHeader { - byte id; - byte version; - byte encoding; - byte bpp; - word xmin; - word ymin; - word xmax; - word ymax; - word hres; - word vres; - byte pal16[48]; - byte res1; - word bpplane; - word palType; - word hScreenSize; - word vScreenSize; - byte padding[54]; -} head; - -//320x240 = 20x15 -//192x144 = 12x9 - -//temp defines -#define TILEWH 16 -#define TILEWHD TILEWH*2 -#define QUADWH TILEWH/2 - -/* -========================== Types & Macros ==========================- */ -#define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2)) -#define PLANE(x) (1 << ((x) & 3)) -#define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02) -#define PALSIZE 768 - -typedef union -{ - byte red; - byte green; - byte blue; -} rgb_t; - -/* -======================= Constants & Vars ==========================- */ -extern byte far* VGA; /* The VGA Memory */ -#define SCREEN_SEG 0xa000 -#define VIDEO_INT 0x10 -#define SET_MODE 0x00 -#define VGA_256_COLOR_MODE 0x13 -#define TEXT_MODE 0x03 - -#define AC_INDEX 0x03c0 -#define SC_INDEX 0x03c4 -#define SC_DATA 0x03c5 -#define CRTC_INDEX 0x03d4 -#define CRTC_DATA 0x03d5 -#define GC_INDEX 0x03ce -#define MISC_OUTPUT 0x03c2 -#define HIGH_ADDRESS 0x0C -#define LOW_ADDRESS 0x0D -#define VRETRACE 0x08 -//#define INPUT_STATUS_1 0x03da defined in 16_head -#define DISPLAY_ENABLE 0x01 -#define MAP_MASK 0x02 -#define PAL_READ_REG 0x03C7 /* Color register, read address */ -#define PAL_WRITE_REG 0x03C8 /* Color register, write address */ -#define PAL_DATA_REG 0x03C9 /* Color register, data port */ -#define PAL_SIZE (256 * 3) - -/* -============================ Functions =============================- */ -/* mode switching, page, and plane functions */ -void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv); -void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv); -byte vgaGetMode(); -void modexLeave(); -void modexsetBaseXMode(); -page_t modexDefaultPage(page_t *p); -page_t modexNextPage(page_t *p); -page_t modexNextPageFlexibleSize(page_t *p, word x, word y); -void modexCalcVmemRemain(video_t *video); -void modexHiganbanaPageSetup(video_t *video); -void modexShowPage(page_t *page); -void modexPanPage(page_t *page, int dx, int dy); -void modexSelectPlane(byte plane); -void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color); -/* moved to src/lib/modex16/16render.c */ -void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height); - -/* Palette fade and flash effects */ -void modexFadeOn(word fade, byte *palette); -void modexFadeOff(word fade, byte *palette); -void modexFlashOn(word fade, byte *palette); -void modexFlashOff(word fade, byte *palette); - -/* palette loading and saving */ -void modexPalSave(byte *palette); -byte *modexNewPal(); -void modexLoadPalFile(char *filename, byte **palette); -void modexSavePalFile(char *filename, byte *palette); - -/* fixed palette functions */ -void modexPalBlack(); -void modexPalWhite(); - -/* utility functions */ -void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset); -void modexPalUpdate1(byte *p); -void modexPalUpdate0(byte *p); -void modexPalOverscan(word col); -void modexchkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/); -void modexputPixel(page_t *page, int x, int y, byte color); -byte modexgetPixel(page_t *page, int x, int y); - -#if 0 // not needed anymore. maybe good for reference purposes though. -static inline void modexwritepixel(page_t *page, int x, int y, word addr, byte color) -{ - /* Each address accesses four neighboring pixels, so set - Write Plane Enable according to which pixel we want - to modify. The plane is determined by the two least - significant bits of the x-coordinate: */ - modexSelectPlane(PLANE(x)); - //outp(SC_INDEX, 0x02); - //outp(SC_DATA, 0x01 << (x & 3)); - - /* The offset of the pixel into the video segment is - offset = (width * y + x) / 4, and write the given - color to the plane we selected above. Heed the active - page start selection. */ - vga_state.vga_graphics_ram[addr] = color; -} -static inline byte modexreadPixel(page_t *page, int x, int y, word addr) -{ - /* Select the plane from which we must read the pixel color: */ - outpw(GC_INDEX, 0x04); - outpw(GC_INDEX+1, x & 3); - return vga_state.vga_graphics_ram[addr]; -} -#endif - -void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str); -void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str); -void modexpdump(page_t *pee); -void modexcls(page_t *page, byte color, byte *Where); -void modexWaitBorder(); -void bios_cls(); -void modexprintmeminfo(video_t *v); -void update_state_from_vga_(); - -#endif diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c deleted file mode 100755 index 312a76e6..00000000 --- a/src/lib/scroll16.c +++ /dev/null @@ -1,864 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 - * - * 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" - -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) - { - //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); - if(!pageflipflop) mapScrollRight(pip, player, !(pip[0].video->p), pn); else{ - mapScrollRight(pip, player, 0, pn); - mapScrollRight(pip, player, 1, pn); - ScrollRight(pip, player, 2, pn); - ScrollRight(pip, player, 3, pn); } - if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } 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-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); -#ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATA); -#else - modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 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); - if(!pageflipflop) mapScrollLeft(pip, player, !(pip[0].video->p), pn); else{ - mapScrollLeft(pip, player, 0, pn); - mapScrollLeft(pip, player, 1, pn); - ScrollLeft(pip, player, 2, pn); - ScrollLeft(pip, player, 3, pn); } - if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } 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-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); -#ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATA); -#else - modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 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); - if(!pageflipflop) mapScrollDown(pip, player, !(pip[0].video->p), pn); else{ - mapScrollDown(pip, player, 0, pn); - mapScrollDown(pip, player, 1, pn); - ScrollDown(pip, player, 2, pn); - ScrollDown(pip, player, 3, pn); } - if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } 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-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); -#ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA); -#else - modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 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); - if(!pageflipflop) mapScrollUp(pip, player, !(pip[0].video->p), pn); else{ - mapScrollUp(pip, player, 0, pn); - mapScrollUp(pip, player, 1, pn); - ScrollUp(pip, player, 2, pn); - ScrollUp(pip, player, 3, pn); } - if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } 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-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); -#ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATA); -#else - modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 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(pageflipflop){ - if(id==0) - mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page->dx); - else - 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)); - }else mapDrawCol(&mv[(!mv[0].video->p)], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page->dx); -} - - -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(pageflipflop){ - if(id==0) - mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx); - else - 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)); - }else mapDrawCol(&mv[(!mv[0].video->p)], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx); -} - - -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->width*4; - mv[id].page->dy = mv[id].map->tiles->tileHeight; - } - - /* draw the next row */ - y= 0; - if(player[plid].q%3) - if(pageflipflop){ - if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy); - else - 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); - }else mapDrawRow(&mv[(!mv[0].video->p)], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy); -} - -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->width*4; - 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(pageflipflop){ - if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page->dy); - else - 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); - }else mapDrawRow(&mv[(!mv[0].video->p)], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page->dy); -} - - -//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[0].video->page[id].dx += player[plid].speed; - - /* check to see if this changes the tile */ - if(mv[0].video->page[id].dx >= mv[id].dxThresh ) - { - /* Snap the origin forward */ - mv[0].video->page[id].data += 4; - mv[0].video->page[id].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[0].video->page[id].dx -= player[plid].speed; - - /* check to see if this changes the tile */ - if(mv[0].video->page[id].dx == 0) - { - /* Snap the origin backward */ - mv[0].video->page[id].data -= 4; - mv[0].video->page[id].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[0].video->page[id].dy -= player[plid].speed; - - /* check to see if this changes the tile */ - if(mv[0].video->page[id].dy == 0) - { - /* Snap the origin backward */ - mv[0].video->page[id].data -= 4; - mv[0].video->page[id].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[0].video->page[id].dy += player[plid].speed; - - /* check to see if this changes the tile */ - if(mv[0].video->page[id].dy >= mv[id].dxThresh ) - { - /* Snap the origin forward */ - mv[0].video->page[id].data += 4; - mv[0].video->page[id].dy = mv[0].map->tiles->tileWidth; - } -// modexClearRegion(&(mv[0].video->page[id]), 0, 0, -// mv[0].video->page[id].width-1, -// mv[0].video->page[id].height-1, id*2); -} - -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; -} - -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->map->tiles->tileWidth; - mv[0].page->dy = mv[1].page->dy = mv->map->tiles->tileHeight; - - /* set up the thresholds */ - mv[0].dxThresh = mv[1].dxThresh = mv->map->tiles->tileWidth * 2; - mv[0].dyThresh = mv[1].dyThresh = 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; - } - modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); -} - - -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=0; -//gv->video.p - -/* 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; - word h = 8; - word col = 7; - word bgcol = 0; - word 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){ - 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])); //this is slow as fack too!! - gv->video.p=!gv->video.p; - gv->video.r=!gv->video.r; - } - } -} - -void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) -{ - sword x = player[pn].x; - sword y = player[pn].y; -#ifdef SPRITE - word dire=32; //direction -#else - word dire=8; //direction -#endif - sword qq; //scroll offset - word ls = player[pn].persist_aniframe; - - if(scrollswitch==0) qq = 0; - else qq = ((player[pn].q)*(player[pn].speed)); - x-=4; - y-=TILEWH; - switch (player[pn].d) - { - case 0: - //up - dire*=player[pn].d; - y-=qq; - break; - case 3: - // right - dire*=(player[pn].d-2); - x+=qq; - break; - case 2: - break; - case 4: - //down - dire*=(player[pn].d-2); - y+=qq; - break; - case 1: - //left - dire*=(player[pn].d+2); - x-=qq; - break; - } - -#ifdef SPRITE -// #define FRAME1 PBUFSFUN(pip[1].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA); -// #define FRAME2 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -// #define FRAME3 PBUFSFUN(pip[1].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA); -// #define FRAME4 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -#define FRAME1 PBUFSFUN(pip[!(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA); -#define FRAME2 PBUFSFUN(pip[!(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -#define FRAME3 PBUFSFUN(pip[!(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA); -#define FRAME4 PBUFSFUN(pip[!(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -#else -#define FRAME1 modexClearRegion(pip[!(pip->video->p)].page, x, y, 24, 32, 2+dire); -#define FRAME2 modexClearRegion(pip[!(pip->video->p)].page, x, y, 24, 32, 1+dire); -#define FRAME3 modexClearRegion(pip[!(pip->video->p)].page, x, y, 24, 32, dire); -#define FRAME4 modexClearRegion(pip[!(pip->video->p)].page, x, y, 24, 32, 1+dire); - #endif -// if(pageflipflop) -//modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height); - 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); - //modexCopyPageRegion(pip[2].page, pip[1].page, 16, 16, 16, 16, (14*8)+4, 8+4); - 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 } - pip->video->r=1; - //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40); - //modexClearRegion(top->page, 66, 66, 2, 40, 0); - //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40); -} diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h deleted file mode 100755 index 0f47b2b1..00000000 --- a/src/lib/typdefst.h +++ /dev/null @@ -1,130 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 - * - * 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. - * - */ - -#ifndef _TYPEDEFSTRUCT_H_ -#define _TYPEDEFSTRUCT_H_ - -#include "src/lib/types.h" - - -#define AARED "\x1b[41;31m" -#define AABLUE "\x1b[44;34m" -#define AAGREEN "\x1b[42;32m" -#define AAYELLOW "\x1b[43;33m" -#define AAGREY "\x1b[47;37m" -#define AABLACK "\x1b[40;30m" -#define AAWHITE "\x1b[47;37m" -#define AAMAGENTA "\x1b[45;35m" -#define AARESET "\x1b[0m" - -#define MAXPAGE 4 - -/* - * typedefs of the game variables! - */ -typedef struct { - byte huge *data; - word width; - word height; - byte *palette; - word offset; -} bitmap_t; - -typedef struct { - byte huge **data; - word ntiles; /* the number of tiles */ - word twidth; /* width of the tiles */ - word theight; /* height of the tiles */ - byte *palette; /* palette for the tile set */ -} tileset_t; - -typedef struct { - byte huge *plane[4]; /* 4 planes of image data */ - word width; /* width of the image (spread across 4 planes) */ - word height; /* height of the image (spread across 4 planes) */ - word pwidth; /* the number of bytes in each plane */ - byte *palette; -} planar_buf_t; - -typedef struct { - word id; /* the Identification number of the page~ For layering~ */ - byte far* data; /* the data for the page */ - word dx; /* col we are viewing on the virtual screen */ - word dy; /* row we are viewing on the virtual screen */ - word sw; /* screen width */ - word sh; /* screen heigth */ - word tw; /* screen width in tiles */ - word th; /* screen height in tiles */ - word width; /* virtual width of the page */ - word height; /* virtual height of the page */ - word tilesw; /* virtual screen width in tiles */ - word tilesh; /* virtual screen height in tiles */ - sword tilemidposscreenx; /* middle tile position */ - sword tilemidposscreeny; /* middle tile position */ - sword tileplayerposscreenx; /* player position on screen */ - sword tileplayerposscreeny; /* player position on screen */ - word stridew; /*width/4*/ - word pagesize; /* page size */ -} page_t; - -typedef struct -{ -// int showmemhandle; - int profilehandle,debughandle; - int heaphandle; -} handle_t; - -typedef struct -{ - word frames_per_second; - clock_t t; - dword tiku; //frames passed - word clock_start; //timer start - word *clock; //current time on clock - boolean fpscap; //cap the fps var -} kurokku_t; - -typedef struct -{ - word pn; -} pan_t; - -typedef struct -{ - char old_mode; //old video mode before game! - page_t page[MAXPAGE]; //pointer to root page[0] - word vmem_remain; //remaining video memory - byte num_of_pages; //number of actual pages - boolean __near p; //render page number - boolean __near r; //page flip if true - word pr[MAXPAGE][4]; //render sections of pages -} video_t; - -typedef struct -{ - video_t video; // video settings variable - byte *pee; // message for fps - handle_t handle; //handles for file logging - kurokku_t kurokku; //clock struct -} global_game_variables_t; - -#endif /* _TYPEDEFSTRUCT_H_ */ diff --git a/src/scroll.c b/src/scroll.c deleted file mode 100755 index 90a3ba3f..00000000 --- a/src/scroll.c +++ /dev/null @@ -1,344 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 - * - * 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" - -//#define FADE -#define MODEX //this is for mode x initiating - -//word far *clock= (word far*) 0x046C; /* 18.2hz clock */ - -global_game_variables_t gvar; -static map_t map; -player_t player[MaxPlayers]; -//page_t screen, gvar.video.page[1], gvar.video.page[2]; -map_view_t mv[4]; -bitmap_t p; -//word pn=0; //i forgot ww -static planar_buf_t huge *pp; -float t; -sword bakapee; -pan_t pan; -//debugswitches -boolean panswitch=0; -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[]) -{ - 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; - //player[0].data = &pp; - - printf("starting timer "); - start_timer(&gvar); - printf("ok\n"); - -// atexit(qclean()); - - /* 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 */ - //++++p = bitmapLoadPcx("data/ptmp.pcx"); // load sprite - //npctmp = bitmapLoadPcx("ptmp1.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(); - default_pal = modexNewPal(); - *default_pal = *dpal; - 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(p.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;iwidth, mv[1].page->height); - - //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[1].page, player[0].x-4, player[0].y-TILEWH, 24, 32, 15); -#else - //PBUFSFUN(mv[1].page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA); - PBUFSFUN(mv[1].page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, &pp); -#endif - - if(!pageflipflop) modexShowPage(mv[1].page); - else modexShowPage(mv[(gvar.video.p)].page); - shinku_fps_indicator_page = 1; // we're on page 1 now, shinku(). follow along please or it will not be visible. - //modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 1); -#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; IN_UserInput(1,1); } - if(IN_KeyDown(3)){ modexShowPage(mv[1].page); pan.pn=1; IN_UserInput(1,1); } - if(IN_KeyDown(4)){ modexShowPage(mv[2].page); pan.pn=2; IN_UserInput(1,1); } - if(IN_KeyDown(4+1)){ modexShowPage(mv[3].page); pan.pn=3; IN_UserInput(1,1); } - 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 - //TSR - 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)) //s - { - gvar.kurokku.fpscap=!gvar.kurokku.fpscap; - IN_UserInput(1,1); - } - //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("Project 16 scroll.exe. This is just a test file!\n"); - printf("version %s\n", VERSION); - printf("tx: %d\n", mv[0].tx); - printf("ty: %d\n", mv[0].ty); - printf("player.x: %d", player[0].x); printf(" player.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.tx: %d", player[0].tx); printf(" player.ty: %d\n", player[0].ty); - printf("player.triggx: %d", player[0].triggerx); printf(" player.triggy: %d\n", player[0].triggery); - printf("player.hp: %d", (player[0].hp)); printf(" player.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", 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\n", 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\n", 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\n", gvar.video.p); - //printf("player[1].q: %d", player[1].q); printf(" player[1].d: %d\n", player[1].d); - 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/vrl2vrs b/vrl2vrs deleted file mode 100755 index acdd4bda..00000000 Binary files a/vrl2vrs and /dev/null differ diff --git a/vrsdump b/vrsdump deleted file mode 100755 index 8ba0497d..00000000 Binary files a/vrsdump and /dev/null differ