+++ /dev/null
-/* Project 16 Source Code~\r
- * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669\r
- *\r
- * This file is part of Project 16.\r
- *\r
- * Project 16 is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either verson 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Project 16 is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
- * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
- * Fifth Floor, Boston, MA 02110-1301 USA.\r
- *\r
- */\r
-\r
-#include <conio.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include "src/lib/modex16.h"\r
-\r
-byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */\r
-\r
-static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);\r
-static byte tmppal[PAL_SIZE];\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// //\r
-// setvideo() - This function Manages the video modes //\r
-// //\r
-/////////////////////////////////////////////////////////////////////////////\r
-void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)\r
-{\r
- union REGS in, out;\r
-\r
- switch (vq)\r
- {\r
- case 0: // deinit the video\r
- // change to the video mode we were in before we switched to mode 13h\r
- modexLeave();\r
- in.h.ah = 0x00;\r
- in.h.al = gv->video.old_mode;\r
- int86(0x10, &in, &out);\r
- break;\r
- default: // init the video\r
- // get old video mode\r
- //in.h.ah = 0xf;\r
- //int86(0x10, &in, &out);\r
- gv->video.old_mode = vgaGetMode();//out.h.al;\r
- // enter mode\r
- modexEnter(vq, cmem, gv);\r
- break;\r
- }\r
-}\r
-\r
-static void\r
-vgaSetMode(byte mode)\r
-{\r
- union REGS regs;\r
-\r
- regs.h.ah = SET_MODE;\r
- regs.h.al = mode;\r
- int86(VIDEO_INT, ®s, ®s);\r
- //int10_setmode(mode);\r
-}\r
-\r
-//---------------------------------------------------\r
-//\r
-// Use the bios to get the current video mode\r
-//\r
-\r
-byte/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */\r
-vgaGetMode()\r
-{\r
- return int10_getmode();\r
-}\r
-\r
-/* -========================= Entry Points ==========================- */\r
-void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)\r
-{\r
- word i;\r
- struct vga_mode_params cm;\r
- int CRTParmCount;\r
-\r
- vgaSetMode(VGA_256_COLOR_MODE);\r
- vga_enable_256color_modex();\r
-\r
- update_state_from_vga_();\r
- vga_read_crtc_mode(&cm);\r
-\r
- /* reprogram the CRT controller */\r
- //outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */\r
- //outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */\r
-\r
- switch(vq)\r
- {\r
- case 1:\r
- //CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]);\r
- /*for(i=0; i<CRTParmCount; i++) {\r
- outpw(CRTC_INDEX, ModeX_320x240regs[i]);\r
- }*/\r
- /* width and height */\r
- gv->video.page[0].sw = vga_state.vga_width = 320; // VGA lib currently does not update this\r
- gv->video.page[0].sh = vga_state.vga_height = 240; // VGA lib currently does not update this\r
- /* virtual width and height. match screen, at first */\r
- gv->video.page[0].height = gv->video.page[0].sh;\r
- gv->video.page[0].width = gv->video.page[0].sw;\r
-\r
- // mode X BYTE mode\r
- cm.word_mode = 0;\r
- cm.dword_mode = 0;\r
- // 320x240 mode 60Hz\r
- cm.horizontal_total=0x5f + 5; /* CRTC[0] -5 */\r
- cm.horizontal_display_end=0x4f + 1; /* CRTC[1] -1 */\r
- cm.horizontal_blank_start=0x50 + 1; /* CRTC[2] */\r
-// cm.horizontal_blank_end=0x82 + 1; /* CRTC[3] bit 0-4 & CRTC[5] bit 7 *///skewing ^^;\r
- cm.horizontal_start_retrace=0x54;/* CRTC[4] */\r
- cm.horizontal_end_retrace=0x80; /* CRTC[5] bit 0-4 */\r
- //cm.horizontal_start_delay_after_total=0x3e; /* CRTC[3] bit 5-6 */\r
- //cm.horizontal_start_delay_after_retrace=0x41; /* CRTC[5] bit 5-6 */\r
- cm.vertical_total = 0x20D + 2;\r
- cm.vertical_start_retrace = 0x1EA;\r
- cm.vertical_end_retrace = 0x1EC;\r
- cm.vertical_display_end = 480;\r
- cm.vertical_blank_start = 0x1E7 + 1;\r
- cm.vertical_blank_end = 0x206 + 1;\r
- cm.clock_select = 0; /* misc register = 0xE3 25MHz */\r
- cm.vsync_neg = 1;\r
- cm.hsync_neg = 1;\r
- cm.offset = (vga_state.vga_width / (4 * 2)); // 320 wide (40 x 4 pixel groups x 2)\r
- break;\r
- case 2: // TODO: 160x120 according to ModeX_160x120regs\r
- return;\r
- case 3: // TODO: 160x120 according to ModeX_320x200regs\r
- return;\r
- case 4: // TODO: 160x120 according to ModeX_192x144regs\r
- return;\r
- case 5: // TODO: 160x120 according to ModeX_256x192regs\r
- return;\r
- default:\r
- return;\r
- }\r
-\r
- vga_state.vga_stride = cm.offset * 2;\r
- vga_write_crtc_mode(&cm,0);\r
-\r
- /* clear video memory */\r
- switch (cmem)\r
- {\r
- case 1: {\r
- /* clear video memory */\r
- dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA; /* used for faster screen clearing */\r
- vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/);\r
- for(i = 0;i < 0x4000; i++) ptr[i] = 0x0000; // 0x4000 x dword = 64KB\r
- }\r
- break;\r
- }\r
-\r
-// gv->video.page[0].tw = gv->video.page[0].sw/TILEWH;\r
-// gv->video.page[0].th = gv->video.page[0].sh/TILEWH;\r
-\r
- //TODO MAKE FLEXIBLE~\r
-// gv->video.page[0].tilemidposscreenx = gv->video.page[0].tilesw;\r
-// gv->video.page[0].tilemidposscreeny = (gv->video.page[0].tilesh/2)+1;\r
-}\r
-\r
-void\r
-modexLeave() {\r
- /* VGAmodeX restores original mode and palette */\r
- vgaSetMode(TEXT_MODE);\r
-}\r
-\r
-page_t\r
-modexDefaultPage(page_t *p)\r
-{\r
- page_t page;\r
-\r
- /* default page values */\r
- //page.data = VGA;\r
- //page.data = (byte far *)(vga_state.vga_graphics_ram);\r
- page.data = (vga_state.vga_graphics_ram);\r
- page.dx = 0;\r
- page.dy = 0;\r
- page.sw = p->sw;\r
- page.sh = p->sh;\r
- page.width = p->sw+TILEWHD;\r
- page.height = p->sh+TILEWHD;\r
- page.tw = page.sw/TILEWH;\r
- page.th = page.sh/TILEWH;\r
- page.tilesw=page.width/TILEWH;\r
- page.tilesh=page.height/TILEWH;\r
- page.tilemidposscreenx = page.tw/2;\r
- page.tilemidposscreeny = (page.th/2)+1;\r
- page.stridew=page.width/4;\r
- page.pagesize = (word)(page.width/4)*page.height;\r
- page.id = 0;\r
-\r
- return page;\r
-}\r
-\r
-/* returns the next page in contiguous memory\r
- * the next page will be the same size as p, by default\r
- */\r
-page_t\r
-modexNextPage(page_t *p) {\r
- page_t result;\r
-\r
- result.data = p->data + (p->pagesize);\r
- result.dx = 0;\r
- result.dy = 0;\r
- result.sw = p->sw;\r
- result.sh = p->sh;\r
- result.width = p->width;\r
- result.height = p->height;\r
- result.tw = p->tw;\r
- result.th = p->th;\r
- result.tilesw = p->tilesw;\r
- result.tilesh = p->tilesh;\r
- result.id = p->id+1;\r
- result.stridew=p->stridew;\r
- result.pagesize = p->pagesize;\r
-\r
- return result;\r
-}\r
-\r
-//next page with defined dimentions~\r
-page_t\r
-modexNextPageFlexibleSize(page_t *p, word x, word y)\r
-{\r
- page_t result;\r
-\r
- result.data = p->data + (p->pagesize); /* compute the offset */\r
- result.dx = 0;\r
- result.dy = 0;\r
- result.sw = x;\r
- result.sh = y;\r
- result.width = x;\r
- result.height = y;\r
- result.tw = result.sw/TILEWH;\r
- result.th = result.sh/TILEWH;\r
- result.tilesw=result.width/TILEWH;\r
- result.tilesh=result.height/TILEWH;\r
- result.id = p->id+1;\r
- result.stridew=result.width/4;\r
- result.pagesize = (word)(result.width/4)*result.height;\r
-\r
- return result;\r
-}\r
-\r
-void modexCalcVmemRemain(video_t *video)\r
-{\r
- byte i;\r
- //printf("\n\n 1st vmem_remain=%u\n", video->vmem_remain);\r
- for(i=0; i<video->num_of_pages; i++)\r
- {\r
- video->vmem_remain-=video->page[i].pagesize;\r
- //printf(" [%u], video->page[%u].pagesize=%u\n", i, i, video->page[i].pagesize);\r
- //printf(" [%u], vmem_remain=%u\n", i, video->vmem_remain);\r
- }\r
-}\r
-\r
-void modexHiganbanaPageSetup(video_t *video)\r
-{\r
- video->vmem_remain=65535U;\r
- video->num_of_pages=0;\r
- (video->page[0]) = modexDefaultPage(&(video->page[0])); video->num_of_pages++; //video->page[0].width += (TILEWHD); video->page[0].height += (TILEWHD);\r
- (video->page[1]) = modexNextPage(&(video->page[0])); video->num_of_pages++;\r
- (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), TILEWH*4, TILEWH*4); video->num_of_pages++;\r
- (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), video->page[0].sw, 208); video->num_of_pages++;\r
-// (video->page[2]) = modexNextPageFlexibleSize(&(video->page[1]), video->page[0].width, 172); video->num_of_pages++;\r
-// (video->page[3]) = modexNextPageFlexibleSize(&(video->page[2]), 72, 128); video->num_of_pages++;\r
- modexCalcVmemRemain(video);\r
- video->p=0;\r
- video->r=1;\r
-}\r
-\r
-void\r
-modexShowPage(page_t *page) {\r
- word high_address;\r
- word low_address;\r
- word offset;\r
- byte crtcOffset;\r
-\r
- /* calculate offset */\r
- offset = (word) page->data;\r
- offset += page->dy * (page->width >> 2 );\r
- offset += page->dx >> 2;\r
-\r
- /* calculate crtcOffset according to virtual width */\r
- crtcOffset = page->width >> 3;\r
-\r
- high_address = HIGH_ADDRESS | (offset & 0xff00);\r
- low_address = LOW_ADDRESS | (offset << 8);\r
-\r
- /* wait for appropriate timing and then program CRTC */\r
- while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));\r
- outpw(CRTC_INDEX, high_address);\r
- outpw(CRTC_INDEX, low_address);\r
- outp(CRTC_INDEX, 0x13);\r
- outp(CRTC_DATA, crtcOffset);\r
-\r
- /* wait for one retrace */\r
- while (!(inp(INPUT_STATUS_1) & VRETRACE));\r
-\r
- /* do PEL panning here */\r
- outp(AC_INDEX, 0x33);\r
- outp(AC_INDEX, (page->dx & 0x03) << 1);\r
-}\r
-\r
-void\r
-modexPanPage(page_t *page, int dx, int dy) {\r
- page->dx = dx;\r
- page->dy = dy;\r
-}\r
-\r
-void\r
-modexSelectPlane(byte plane) {\r
- outp(SC_INDEX, MAP_MASK); /* select plane */\r
- outp(SC_DATA, plane);\r
-}\r
-\r
-void\r
-modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) {\r
- word pageOff = (word) page->data;\r
- word xoff=x/4; /* xoffset that begins each row */\r
- word scanCount=w/4; /* number of iterations per row (excluding right clip)*/\r
- word poffset = pageOff + y*(page->stridew) + xoff; /* starting offset */\r
- word nextRow = page->stridew-scanCount-1; /* loc of next row */\r
- byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */\r
- byte rclip[] = {0x00, 0x01, 0x03, 0x07};\r
- byte left = lclip[x&0x03];\r
- byte right = rclip[(x+w)&0x03];\r
-\r
- /* handle the case which requires an extra group */\r
- if((x & 0x03) && !((x+w) & 0x03)) {\r
- right=0x0f;\r
- }\r
-\r
- __asm {\r
- PUSHF\r
- PUSH ES\r
- PUSH AX\r
- PUSH BX\r
- PUSH CX\r
- PUSH DX\r
- PUSH SI\r
- PUSH DI\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
- MOV DI, poffset ; go to the first pixel\r
- MOV DX, SC_INDEX ; point to the map mask\r
- MOV AL, MAP_MASK\r
- OUT DX, AL\r
- INC DX\r
- MOV AL, color ; get ready to write colors\r
- SCAN_START:\r
- MOV CX, scanCount ; count the line\r
- MOV BL, AL ; remember color\r
- MOV AL, left ; do the left clip\r
- OUT DX, AL ; set the left clip\r
- MOV AL, BL ; restore color\r
- STOSB ; write the color\r
- DEC CX\r
- JZ SCAN_DONE ; handle 1 group stuff\r
-\r
- ;-- write the main body of the scanline\r
- MOV BL, AL ; remember color\r
- MOV AL, 0x0f ; write to all pixels\r
- OUT DX, AL\r
- MOV AL, BL ; restore color\r
- REP STOSB ; write the color\r
- SCAN_DONE:\r
- MOV BL, AL ; remeber color\r
- MOV AL, right\r
- OUT DX, AL ; do the right clip\r
- MOV AL, BL ; restore color\r
- STOSB ; write pixel\r
- ADD DI, nextRow ; go to the next row\r
- DEC h\r
- JNZ SCAN_START\r
- POP DI\r
- POP SI\r
- POP DX\r
- POP CX\r
- POP BX\r
- POP AX\r
- POP ES\r
- POPF\r
- }\r
-}\r
-\r
-/* moved to src/lib/modex16/16render.c */\r
-\r
-/* copy a region of video memory from one page to another.\r
- * It assumes that the left edge of the tile is the same on both\r
- * regions and the memory areas do not overlap.\r
- */\r
-void\r
-modexCopyPageRegion(page_t *dest, page_t *src,\r
- word sx, word sy,\r
- word dx, word dy,\r
- word width, word height)\r
-{\r
- word doffset = (word)dest->data + dy*(dest->stridew) + dx/4;\r
- word soffset = (word)src->data + sy*(src->stridew) + sx/4;\r
- word scans = vga_state.vga_stride;\r
- word nextSrcRow = src->stridew - scans - 1;\r
- word nextDestRow = dest->stridew - scans - 1;\r
- byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */\r
- byte rclip[] = {0x0f, 0x01, 0x03, 0x07};\r
- byte left = lclip[sx&0x03];\r
- byte right = rclip[(sx+width)&0x03];\r
-\r
- __asm {\r
- PUSHF\r
- PUSH ES\r
- PUSH AX\r
- PUSH BX\r
- PUSH CX\r
- PUSH DX\r
- PUSH SI\r
- PUSH DI\r
-\r
- MOV AX, SCREEN_SEG ; work in the vga space\r
- MOV ES, AX ;\r
- MOV DI, doffset ;\r
- MOV SI, soffset ;\r
-\r
- MOV DX, GC_INDEX ; turn off cpu bits\r
- MOV AX, 0008h ;\r
- OUT DX, AX\r
-\r
- MOV AX, SC_INDEX ; point to the mask register\r
- MOV DX, AX ;\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
- INC DX ;\r
-\r
- ROW_START:\r
- PUSH DS\r
- MOV AX, ES\r
- MOV DS, AX\r
- MOV CX, scans ; the number of latches\r
-\r
- MOV AL, left ; do the left column\r
- OUT DX, AL ;\r
- MOVSB ;\r
- DEC CX ;\r
-\r
- MOV AL, 0fh ; do the inner columns\r
- OUT DX, AL\r
- REP MOVSB ; copy the pixels\r
-\r
- MOV AL, right ; do the right column\r
- OUT DX, AL\r
- MOVSB\r
- POP DS\r
-\r
- MOV AX, SI ; go the start of the next row\r
- ADD AX, nextSrcRow ;\r
- MOV SI, AX ;\r
- MOV AX, DI ;\r
- ADD AX, nextDestRow ;\r
- MOV DI, AX ;\r
-\r
- DEC height ; do the rest of the actions\r
- JNZ ROW_START ;\r
-\r
- MOV DX, GC_INDEX+1 ; go back to CPU data\r
- MOV AL, 0ffh ; none from latches\r
- OUT DX, AL ;\r
-\r
- POP DI\r
- POP SI\r
- POP DX\r
- POP CX\r
- POP BX\r
- POP AX\r
- POP ES\r
- POPF\r
- }\r
-}\r
-\r
-\r
-/* fade and flash */\r
-void\r
-modexFadeOn(word fade, byte *palette) {\r
- fadePalette(-fade, 64, 64/fade+1, palette);\r
-}\r
-\r
-\r
-void\r
-modexFadeOff(word fade, byte *palette) {\r
- fadePalette(fade, 0, 64/fade+1, palette);\r
-}\r
-\r
-\r
-void\r
-modexFlashOn(word fade, byte *palette) {\r
- fadePalette(fade, -64, 64/fade+1, palette);\r
-}\r
-\r
-\r
-void\r
-modexFlashOff(word fade, byte *palette) {\r
- fadePalette(-fade, 0, 64/fade+1, palette);\r
-}\r
-\r
-\r
-static void\r
-fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {\r
- word i;\r
- byte dim = start;\r
-\r
- /* handle the case where we just update */\r
- if(iter == 0) {\r
- modexPalUpdate1(palette);\r
- return;\r
- }\r
-\r
- while(iter > 0) { /* FadeLoop */\r
- for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */\r
- tmppal[i] = palette[i] - dim;\r
- if(tmppal[i] > 127) {\r
- tmppal[i] = 0;\r
- } else if(tmppal[i] > 63) {\r
- tmppal[i] = 63;\r
- }\r
- }\r
- modexPalUpdate1(tmppal);\r
- iter--;\r
- dim += fade;\r
- }\r
-}\r
-\r
-\r
-/* save and load */\r
-void\r
-modexPalSave(byte *palette) {\r
- int i;\r
-\r
- outp(PAL_READ_REG, 0); /* start at palette entry 0 */\r
- for(i=0; i<PAL_SIZE; i++) {\r
- palette[i] = inp(PAL_DATA_REG); /* read the palette data */\r
- }\r
-}\r
-\r
-\r
-byte *\r
-modexNewPal() {\r
- byte *ptr;\r
- ptr = malloc(PAL_SIZE);\r
-\r
- /* handle errors */\r
- if(!ptr) {\r
- printf("Could not allocate palette.\n");\r
- exit(-1);\r
- }\r
-\r
- return ptr;\r
-}\r
-\r
-\r
-void\r
-modexLoadPalFile(byte *filename, byte **palette) {\r
- FILE *file;\r
- byte *ptr;\r
-\r
- /* free the palette if it exists */\r
- if(*palette) {\r
- free(*palette);\r
- }\r
-\r
- /* allocate the new palette */\r
- *palette = modexNewPal();\r
-\r
- /* open the file */\r
- file = fopen(filename, "rb");\r
- if(!file) {\r
- printf("Could not open palette file: %s\n", filename);\r
- exit(-2);\r
- }\r
-\r
- /* read the file */\r
- ptr = *palette;\r
- while(!feof(file)) {\r
- *ptr++ = fgetc(file);\r
- }\r
-\r
- fclose(file);\r
-}\r
-\r
-\r
-void\r
-modexSavePalFile(char *filename, byte *pal) {\r
- unsigned int i;\r
- FILE *file;\r
-\r
- /* open the file for writing */\r
- file = fopen(filename, "wb");\r
- if(!file) {\r
- printf("Could not open %s for writing\n", filename);\r
- exit(-2);\r
- }\r
-\r
- /* write the data to the file */\r
- fwrite(pal, 1, PAL_SIZE, file);\r
- fclose(file);\r
-}\r
-\r
-\r
-/* blanking */\r
-void\r
-modexPalBlack() {\r
- fadePalette(-1, 64, 1, tmppal);\r
-}\r
-\r
-\r
-void\r
-modexPalWhite() {\r
- fadePalette(-1, -64, 1, tmppal);\r
-}\r
-\r
-\r
-/* utility */\r
-void\r
-modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)\r
-{\r
- byte *p = bmp->palette;\r
- word w=0;\r
- word q=0;\r
- word qq=0;\r
- static word a[PAL_SIZE]; //palette array of change values!\r
- word z=0, aq=0, aa=0, pp=0;\r
-\r
- //modexWaitBorder();\r
- vga_wait_for_vsync();\r
- if((*i)==0)\r
- {\r
- memset(a, -1, sizeof(a));\r
- outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */\r
- }\r
- else if(qp==0)\r
- {\r
- q=(*i);\r
- }\r
- else\r
- {\r
- q=(*i);\r
- qq=(*i)/3;\r
-// printf("q: %02d\n", (q));\r
-// printf("qq: %02d\n", (qq));\r
- //printf(" (*i)-q=%02d\n", (*i)-q);\r
- outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */\r
- }\r
- if((*i)<PAL_SIZE/2 && w==0)\r
- {\r
- for(; (*i)<PAL_SIZE/2; (*i)++)\r
- {\r
- //if(i%3==0 && (p[i+5]==p[i+4] && p[i+4]==p[i+3] && p[i+3]==p[i+2] && p[i+2]==p[i+1] && p[i+1]==p[i] && p[i+5]==p[i]))\r
-//____ if((qp>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\r
- 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]))\r
- {\r
- w++;\r
- break;\r
- }\r
- else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))\r
- {\r
- //printf("qp=%d\n", qp);\r
- //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);\r
- printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);\r
- //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!\r
- if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }\r
- }\r
- else\r
- {\r
- if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);\r
- else\r
- if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);\r
- else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);\r
- printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }\r
- }\r
- }\r
- //if(qp>0) printf("qp=%d\n", qp);\r
- //if(qp>0) printf(" (*i)=%d\n", (*i)/3);\r
- }\r
- //modexWaitBorder(); /* waits one retrace -- less flicker */\r
- vga_wait_for_vsync();\r
- if((*i)>=PAL_SIZE/2 && w==0)\r
- {\r
- for(; (*i)<PAL_SIZE; (*i)++)\r
- {\r
-//____ if((qp>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\r
- 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]))\r
- {\r
- w++;\r
- break;\r
- }\r
- else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))\r
- {\r
- //printf("qp=%d\n", qp);\r
- //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);\r
- printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));\r
- //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!\r
- if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }\r
- }\r
- else\r
- {\r
- if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);\r
- else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);\r
- printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }\r
- }\r
- }\r
- //printf(" (*i)=%d\n", (*i)/3);\r
- }\r
-\r
-printf("\nqqqqqqqq\n\n");\r
-\r
- //palette checker~\r
- if(q>0 && qp==0)\r
- {\r
- long lq;\r
- long bufSize = (bmp->width * bmp->height);\r
- pp = q;\r
- //printf("1(*i)=%02d\n", (*i)/3);\r
- //printf("1z=%02d\n", z/3);\r
- modexchkcolor(bmp, &q, &a, &aa, &z, i);\r
- //printf("2(*i)=%02d\n", (*i)/3);\r
- //printf("2z=%02d\n", z/3);\r
- aq=0;\r
-aqpee:\r
- while(aq<=aa)\r
- {\r
-// printf("a[%02d]=(%d)\n", aq, a[aq]);\r
- if(a[aq]==-1) aq++;\r
- else { aqoffset++; break; }\r
- }\r
-//update the image data here!\r
- for(lq=0; lq<bufSize; lq++)\r
- {\r
- /*\r
- note to self\r
- use a[qp] instead of bmp->offset for this spot!\r
- NO! wwww\r
- */\r
-\r
- /*\r
- Facking bloody point the values of the changed palette to correct values.... major confusion! wwww\r
- */\r
-\r
- //(offset/bmp->offset)*bmp->offset\r
-\r
-\r
- //printf("%02d ",bmp->data[lq]+bmp->offset);\r
- //if(lq > 0 && lq%bmp->width==0) printf("\n");\r
- //printf("%02d_", bmp->data[lq]+bmp->offset);\r
- /*if(bmp->data[lq]+bmp->offset==aq)\r
- {\r
- //printf("%02d", bmp->data[lq]);\r
- //printf("\n%02d\n", bmp->offset);\r
- printf("aq=%02d ", aq);\r
- printf("a[aq]=%02d ", a[aq]);\r
- printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);\r
- printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);\r
- //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);\r
-//++++ bmp->data[lq]=a[aq]-aqpp;\r
-// printf("_%d ", bmp->data[lq]);\r
- //if(lq > 0 && lq%bmp->width==0) printf("\n");\r
- }\r
- else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)\r
- {\r
- if(bmp->data[lq]+bmp->offset >= aq)\r
- {\r
- bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);\r
- //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);\r
- }\r
- else bmp->data[lq]+=(bmp->offset-aqpp);\r
- }*/\r
-\r
- //printf("%02d`", bmp->data[lq]);\r
- //if(lq > 0 && lq%bmp->width==0) printf("\n");\r
- }\r
-\r
-//printf(" aq=%02d\n", aq);\r
-//printf(" aa=%02d\n", aa);\r
-\r
- //update the palette~\r
- modexPalUpdate(bmp, &pp, aq, aqoffset);\r
- (*i)=pp;\r
-\r
- if(aq<aa){ pp=q; aq++; goto aqpee; }\r
- }\r
-}\r
-\r
-void\r
-modexPalUpdate1(byte *p)\r
-{\r
- int i;\r
- //modexWaitBorder();\r
- vga_wait_for_vsync();\r
- outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */\r
- for(i=0; i<PAL_SIZE/2; i++)\r
- {\r
- outp(PAL_DATA_REG, p[i]);\r
- }\r
- //modexWaitBorder(); /* waits one retrace -- less flicker */\r
- vga_wait_for_vsync();\r
- for(; i<PAL_SIZE; i++)\r
- {\r
- outp(PAL_DATA_REG, p[(i)]);\r
- }\r
-}\r
-\r
-void\r
-modexPalUpdate0(byte *p)\r
-{\r
- int i;\r
- //modexWaitBorder();\r
- vga_wait_for_vsync();\r
- outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */\r
- for(i=0; i<PAL_SIZE/2; i++)\r
- {\r
- outp(PAL_DATA_REG, rand());\r
- }\r
- //modexWaitBorder(); /* waits one retrace -- less flicker */\r
- vga_wait_for_vsync();\r
- for(; i<PAL_SIZE; i++)\r
- {\r
- outp(PAL_DATA_REG, rand());\r
- }\r
-}\r
-\r
-void\r
-modexPalOverscan(word col)\r
-{\r
- //modexWaitBorder();\r
- vga_wait_for_vsync();\r
- outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */\r
- outp(PAL_DATA_REG, col);\r
-}\r
-\r
-//color checker~\r
-//i want to make another vesion that checks the palette when the palette is being appened~\r
-void modexchkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)\r
-{\r
- byte *pal;\r
- word zz=0;\r
- pal = modexNewPal();\r
- modexPalSave(pal);\r
- //printf("q: %02d\n", (*q));\r
- printf("chkcolor start~\n");\r
- printf("1 (*z): %d\n", (*z)/3);\r
- printf("1 (*i): %d\n", (*i)/3);\r
-// printf("1 offset of color in palette (*q): %d\n", (*q)/3);\r
- printf("wwwwwwwwwwwwwwww\n");\r
- //check palette for dups\r
- for(; (*z)<PAL_SIZE; (*z)+=3)\r
- {\r
- //printf("\n z: %d\n", (*z));\r
- //printf(" q: %d\n", (*q));\r
- //printf(" z+q: %d\n\n", ((*z)+(*q)));\r
- //if((*z)%3==0)\r
- //{\r
-//---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])\r
- if((*z)==(*i))\r
- {\r
-// printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);\r
-// printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);\r
-//0000 (*z)-=3;\r
- break;\r
- }\r
- else for(zz=0; zz<(*q); zz+=3)\r
- {\r
- //printf("zz: %02d\n", zz/3);\r
- if(zz%3==0)\r
- {\r
- if(pal[((*z)+(*q))]==pal[((*z)+(*q))+3] && pal[((*z)+(*q))+1]==pal[((*z)+(*q))+4] && pal[((*z)+(*q))+2]==pal[((*z)+(*q))+5]) //break if duplicate colors found in palette because it have reached the end of the current data of the palette\r
- {\r
-// (*z)-=3;\r
-// (*i)-=3;\r
-// printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);\r
-// printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);\r
- break;\r
- }\r
- else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])\r
- {\r
-// printf("\n\nwwwwwwwwwwwwwwww\n");\r
-// printf(" zq: %d [%02d][%02d][%02d] value that is needing to be changed~\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);\r
-// printf(" zz: %d [%02d][%02d][%02d] value that the previous value is going to change to~\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);\r
-// //printf(" zv: %d [%02d][%02d][%02d] wwww\n", (zz-z+q)/3, pal[(zz-z+q)], pal[(zz-z+q)+1], pal[(zz-z+q)+2]);\r
-// printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);\r
-//++++ (*i)--;\r
-// (*z)--;\r
- //expand dong here\r
-/*\r
-planned features that i plan to implement~\r
-image that has values on the pallete list!\r
-wwww\r
-no... wait.... no wwww\r
-*/\r
- //for(zzii=0; zzii<3; zzii++)\r
- //{\r
- //printf("z+q: %d\n\n", ((*z)+(*q)));\r
- a[(((*z)+(*q)))]=zz;\r
- //}\r
- (*aa)=(((*z)+(*q)));\r
- printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);\r
-// printf("\n aa: %d\n\n", (*aa));\r
-// printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);\r
-// printf("wwwwwwwwwwwwwwww\n\n");\r
- }\r
- /*else\r
- {\r
- printf("================\n");\r
- printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);\r
- printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);\r
- printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);\r
- printf("================\n");\r
- }*/\r
- //printf("[%d]", (zz+q));\r
- }\r
- }\r
- }\r
- printf("wwwwwwwwwwwwwwww\n");\r
- printf("2 (*z): %d\n", (*z)/3);\r
- printf("2 (*i): %d\n", (*i)/3);\r
-// printf("2 offset of color in palette (*q): %d\n", (*q)/3);\r
- printf("chkcolor end~\n");\r
- free(pal);\r
-}\r
-\r
-void modexputPixel(page_t *page, int x, int y, byte color)\r
-{\r
- word pageOff = (word) page->data;\r
- /* Each address accesses four neighboring pixels, so set\r
- Write Plane Enable according to which pixel we want\r
- to modify. The plane is determined by the two least\r
- significant bits of the x-coordinate: */\r
- modexSelectPlane(PLANE(x));\r
- //outp(SC_INDEX, 0x02);\r
- //outp(SC_DATA, 0x01 << (x & 3));\r
-\r
- /* The offset of the pixel into the video segment is\r
- offset = (width * y + x) / 4, and write the given\r
- color to the plane we selected above. Heed the active\r
- page start selection. */\r
- VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff] = color;\r
-\r
-}\r
-\r
-byte modexgetPixel(page_t *page, int x, int y)\r
-{\r
- word pageOff = (word) page->data;\r
- /* Select the plane from which we must read the pixel color: */\r
- outpw(GC_INDEX, 0x04);\r
- outpw(GC_INDEX+1, x & 3);\r
-\r
- return VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff];\r
-\r
-}\r
-\r
-void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str)\r
-{\r
- word s, o, w;\r
- word x_draw = x;\r
- word addr = (word) romFontsData.l;\r
- word addrq = (page->width/4) * y + (x / 4) + ((word)page->data);\r
- word addrr = addrq;\r
- byte c;\r
-\r
- s=romFonts[t].seg;\r
- o=romFonts[t].off;\r
- w=romFonts[t].charSize;\r
- romFontsData.chw=0;\r
-\r
- for(; *str != '\0'; str++)\r
- {\r
- c = (*str);\r
- if(c=='\n')\r
- {\r
- x = x_draw;\r
- romFontsData.chw = 0;\r
- addrq += (page->width / 4) * 8;\r
- addrr = addrq;\r
- y += 8;\r
- continue;\r
- }\r
-\r
- // load the character into romFontsData.l\r
- // no need for inline assembly!\r
- // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C.\r
- _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/);\r
- modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr);\r
- x_draw += 8; /* track X for edge of screen */\r
- addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */\r
- }\r
-}\r
-\r
-void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str)\r
-{\r
- word i, s, o, w, j, xp;\r
- byte l[1024];\r
- word addr = (word) l;\r
- word chw=0;\r
- byte c;\r
-\r
- switch(t)\r
- {\r
- case 0:\r
- w=14;\r
- break;\r
- case 1:\r
- w=8;\r
- break;\r
- case 2:\r
- w=8;\r
- break;\r
- case 3:\r
- w=16;\r
- break;\r
- default:\r
- t=3;\r
- w=16;\r
- break;\r
- }\r
-\r
- s=romFonts[t].seg;\r
- o=romFonts[t].off;\r
-\r
- for(; *str != '\0'; str++)\r
- {\r
- c = (*str);\r
- if((c=='\n'/* || c=="\\r
-"*/)/* || chw>=page->width*/)\r
- {\r
- chw=0;\r
- y+=w;\r
- continue;\r
- }\r
- //load the letter 'A'\r
- __asm {\r
- PUSHF\r
- PUSH ES\r
- PUSH AX\r
- PUSH BX\r
- PUSH CX\r
- PUSH DX\r
- PUSH SI\r
- PUSH DI\r
-\r
- MOV DI, addr\r
- MOV SI, o\r
- MOV ES, s\r
- SUB AH, AH\r
- MOV AL, c ; the letter\r
- MOV CX, w\r
- MUL CX\r
- ADD SI, AX ;the address of charcter\r
- L1: MOV AX, ES:SI\r
- MOV DS:DI, AX\r
- INC SI\r
- INC DI\r
- DEC CX\r
- JNZ L1\r
-\r
- POP DI\r
- POP SI\r
- POP DX\r
- POP CX\r
- POP BX\r
- POP AX\r
- POP ES\r
- POPF\r
- }\r
-\r
- for(i=0; i<w; i++)\r
- {\r
- j=1<<8;\r
- xp=0;\r
- while(j)\r
- {\r
- //modexputPixel(page, x+xp+chw, y+i, l[i] & j ? col:bgcol);\r
- modexClearRegion(page, (x+xp+chw)*8, (y+i)*8, 8, 8, l[i] & j ? col:bgcol);\r
- xp++;\r
- j>>=1;\r
- }\r
- }\r
- chw += xp;\r
- }\r
-}\r
-\r
-/* palette dump on display! */\r
-void modexpdump(page_t *pee)\r
-{\r
- int mult=(QUADWH);\r
- int palq=(mult)*TILEWH;\r
- int palcol=0;\r
- int palx, paly;\r
- for(paly=0; paly<palq; paly+=mult){\r
- for(palx=0; palx<palq; palx+=mult){\r
- modexClearRegion(pee, palx+TILEWH, paly+TILEWH, mult, mult, palcol);\r
- palcol++;\r
- }\r
- }\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// //\r
-// cls() - This clears the screen to the specified color, on the VGA or on //\r
-// the Virtual screen. //\r
-// //\r
-/////////////////////////////////////////////////////////////////////////////\r
-void modexcls(page_t *page, byte color, byte *Where)\r
-{\r
- //modexClearRegion(page, 0, 0, page->width, page->height, color);\r
- /* set map mask to all 4 planes */\r
- outpw(SC_INDEX, 0xff02);\r
- //_fmemset(VGA, color, 16000);\r
- _fmemset(Where, color, page->width*(page->height)/4);\r
-}\r
-\r
-void\r
-modexWaitBorder() {\r
- while(inp(INPUT_STATUS_1) & 8) {\r
- // spin\r
- }\r
-\r
- while(!(inp(INPUT_STATUS_1) & 8)) {\r
- //spin\r
- }\r
-}\r
-\r
-void bios_cls() {\r
- VGA_ALPHA_PTR ap;\r
- VGA_RAM_PTR rp;\r
- unsigned char m;\r
-\r
- m = int10_getmode();\r
- if ((rp=vga_state.vga_graphics_ram) != NULL && !(m <= 3 || m == 7)) {\r
- unsigned int i,im;\r
-\r
- im = (FP_SEG(vga_state.vga_graphics_ram_fence) - FP_SEG(vga_state.vga_graphics_ram));\r
- if (im > 0xFFE) im = 0xFFE;\r
- im <<= 4;\r
- for (i=0;i < im;i++) vga_state.vga_graphics_ram[i] = 0;\r
- }\r
- else if ((ap=vga_state.vga_alpha_ram) != NULL) {\r
- unsigned int i,im;\r
-\r
- im = (FP_SEG(vga_state.vga_alpha_ram_fence) - FP_SEG(vga_state.vga_alpha_ram));\r
- if (im > 0x7FE) im = 0x7FE;\r
- im <<= 4 - 1; /* because ptr is type uint16_t */\r
- for (i=0;i < im;i++) vga_state.vga_alpha_ram[i] = 0x0720;\r
- }\r
- else {\r
- printf("WARNING: bios cls no ptr\n");\r
- }\r
-}\r
-\r
-void modexprintmeminfo(video_t *v)\r
-{\r
- byte i;\r
- printf("video memory remaining: %u\n", v->vmem_remain);\r
- printf("page ");\r
- for(i=0; i<v->num_of_pages;i++)\r
- {\r
- printf(" [%u]=", i);\r
- printf("(%Fp)", (v->page[i].data));\r
- printf(" size=%u", v->page[i].pagesize);\r
- printf(" sw=%lu sh=%lu ", (unsigned long)v->page[i].sw, (unsigned long)v->page[i].sh);\r
- printf(" width=%lu height=%lu", (unsigned long)v->page[i].width, (unsigned long)v->page[i].height);\r
- printf("\n");\r
- }\r
-}\r
-\r
-void update_state_from_vga_() {\r
- unsigned char c;\r
-\r
- vga_state.vga_pos_x = 0;\r
- vga_state.vga_pos_y = 0;\r
- vga_state.vga_stride = 80;\r
- vga_state.vga_height = 25;\r
- vga_state.vga_width = 80;\r
- vga_state.vga_9wide = 1;\r
-\r
- if (vga_state.vga_flags & VGA_IS_VGA) { /* VGA only. EGA cards DO have the misc. output reg but it's write-only */\r
- /* update state from H/W which I/O port */\r
- c = inp(0x3CC);\r
- if (c & 1) {\r
- vga_state.vga_base_3x0 = 0x3D0;\r
- }\r
- else {\r
- vga_state.vga_base_3x0 = 0x3B0;\r
- }\r
-\r
- /* now ask the graphics controller where/how VGA memory is mapped */\r
- c = vga_read_GC(6);\r
- /* bit 0 = alpha disable (if set, graphics) */\r
- vga_state.vga_alpha_mode = ((c & 1) == 0);\r
- /* bits 2-3 memory map select */\r
- update_state_vga_memory_map_select((c>>2)&3);\r
-\r
- /* read the sequencer: are we in 8 or 9 dot mode? */\r
- c = vga_read_sequencer(0x1);\r
- vga_state.vga_9wide = (c & 1) == 0;\r
-\r
- /* read from the CRTC controller the stride, width, and height */\r
- vga_state.vga_stride = vga_read_CRTC(0x13) * 2; /* "offset" register */\r
- if (vga_state.vga_alpha_mode) {\r
- vga_state.vga_width = vga_state.vga_stride;\r
- vga_sync_hw_cursor();\r
- /* TODO: read vertical blank values and calculate active area, then divide by scan line height, to get alpha height */\r
- /* TODO: read horizontal blank values to calculate active area, then visible width */\r
- }\r
- else {\r
- /* TODO: similar semantics for graphics mode */\r
- }\r
- }\r
- else if (vga_state.vga_flags & VGA_IS_EGA) {\r
- /* Well the EGA has similar registers BUT they aren't readable. So we have to\r
- * guess based on other information handed to us */\r
-\r
- /* reading the misc. output register doesn't work, use BIOS data area */\r
- c = *((unsigned char far*)MK_FP(0x40,0x63));\r
- if ((c&0xF0) == 0xD0)\r
- vga_state.vga_base_3x0 = 0x3D0;\r
- else if ((c&0xF0) == 0xB0)\r
- vga_state.vga_base_3x0 = 0x3B0;\r
- else {\r
- vga_state.vga_base_3x0 = 0x3D0;\r
- }\r
-\r
- /* reading from the graphics controller (0x3CE) doesn't work, deduce from BIOS mode */\r
- c = int10_getmode();\r
- switch (c) {\r
- case 0: case 1: case 2: case 3: case 7:\r
- vga_state.vga_alpha_mode = 1;\r
-\r
- /* 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 */\r
- if (vga_state.vga_base_3x0 == 0x3B0)\r
- update_state_vga_memory_map_select(2);\r
- else\r
- update_state_vga_memory_map_select(3);\r
- break;\r
- case 4: case 5: case 6:\r
- vga_state.vga_alpha_mode = 0;\r
- update_state_vga_memory_map_select(3);\r
- break;\r
- case 13: case 14: case 15: case 16: case 17: case 18: default:\r
- vga_state.vga_alpha_mode = 0;\r
- update_state_vga_memory_map_select(1);\r
- break;\r
- }\r
-\r
- /* read from the CRTC controller the stride, width, and height */\r
- vga_state.vga_stride = vga_read_CRTC(0x13) * 2; /* "offset" register */\r
- if (vga_state.vga_alpha_mode) {\r
- vga_state.vga_width = vga_state.vga_stride;\r
- vga_sync_hw_cursor();\r
- /* TODO: read vertical blank values and calculate active area, then divide by scan line height, to get alpha height */\r
- /* TODO: read horizontal blank values to calculate active area, then visible width */\r
- }\r
- else {\r
- /* TODO: similar semantics for graphics mode */\r
- }\r
- }\r
- else if (vga_state.vga_flags & VGA_IS_CGA) {\r
- vga_state.vga_base_3x0 = 0x3D0; /* always at 0x3Dx */\r
-\r
- /* TODO: If Tandy, detect state */\r
-\r
- /* read the status register to determine the state of the CGA... oh wait... we can't.\r
- * fine. deduce it from the BIOS video mode. */\r
- c = int10_getmode();\r
- switch (c) {\r
- case 0: case 1: case 2: case 3: case 7:\r
- vga_state.vga_alpha_mode = 1;\r
- break;\r
- default:\r
- vga_state.vga_alpha_mode = 0;\r
- break;\r
- }\r
-\r
- if (c <= 1) {\r
- vga_state.vga_stride = 40;\r
- vga_state.vga_width = 40;\r
- }\r
-\r
- update_state_vga_memory_map_select(3); /* 0xB8000 */\r
- }\r
- else if (vga_state.vga_flags & VGA_IS_MDA) {\r
- vga_state.vga_base_3x0 = 0x3B0; /* always at 0x3Bx */\r
- vga_state.vga_alpha_mode = 1; /* stock MDA doesn't have graphics */\r
-\r
- /* Hercules MDA: It would be nice to be able to read bit 2 of the display control,\r
- * except that the port is write-only. Thanks >:( */\r
- update_state_vga_memory_map_select(2); /* 0xB0000 */\r
- }\r
-\r
- vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = vga_state.vga_stride;\r
-}\r
+++ /dev/null
-/* 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 <http://www.gnu.org/licenses/>, 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; y<map->height; y++) {
- //for(x=0; x<map->width; x++) {
- i=0;
- for(yy=0; yy<TILEWH; yy++) {
- for(xx=0; xx<(TILEWH); xx++) {
- //if(x<TILEWH){
- map->tiles->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; y<map->height; y++) {
- for(x=0; x<map->width; 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; x<mv->page->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; y<mv->page->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);
-}