/* ** BETATRON high level library for platform and action arcade games. ** Copyright (C) 1997 Liouros Thanasis, liouros@hotmail.com ** ** PLVGA.CC: This file is part of the BETATRON library and can be used ** and/or distributed only under the terms of the GNU Library ** General Public License. See doc/readme.1st for details. */ #include #include #include #include // pl_setstartadr, pl_retrace, pl_sethorpel // pl_rawto4planes,pl_getRGBcolor,pl_isvga,pl_setpal,pl_setvideomode,pl_line // pl_tiletoraw2, pl_raw2rle void pl_setstartadr(long adrs) { asm(" \ movw %0,%%ebx \n \ movw $0x03d4,%%dx \n \ movb $0x0c,%%al \n \ movb %%bh,%%ah \n \ outw %%ax,%%dx \n \ movb $0x0d,%%al \n \ movb %%bl,%%ah \n \ outw %%ax,%%dx \n \ ": : "m" (adrs): "ebx","eax","edx"); } void pl_retrace() { asm(" pushw %dx;pushw %ax; pushfl \n \ wait1: \n \ movw $0x3da,%dx \n \ inb %dx,%al \n \ testb $8,%al \n \ jnz wait1 \n \ wait2: \n \ inb %dx,%al \n \ testb $8,%al \n \ jz wait2 \n \ popfl; popw %ax;popw %dx "); } void pl_sethorpel(unsigned char value) { asm(" \ movw $0x3da,%%dx \n \ inb %%dx,%%al \n \ movw $0x3c0,%%dx \n \ movb $0x33,%%al \n \ outb %%al,%%dx \n \ movb %0,%%al \n \ outb %%al,%%dx \n \ " : : "m" (value): "edx" ,"eax"); } char *pl_tilerawto4planes(char *intile,char * &outtile) { register char *pin; register char *pout; register short i; if (!outtile) if ( !(outtile=(char *)malloc(256)) ) return NULL; pout=outtile; pin=intile; for (i=0; i<64; i++,pout++) { *pout = *pin++; *(pout+64) = *pin++; *(pout+128) = *pin++; *(pout+192) = *pin++; } return outtile; } char *pl_tile4planes2raw(char *intile,char * &outtile) { register char *t,*ot; register short i; if (!outtile) if ( !(outtile=(char *)malloc(256)) ) return NULL; t=intile; ot=outtile; for (i=0;i<64;i++,t++) { *ot++ = *t; *ot++ = *(t+64); *ot++ = *(t+128); *ot++ = *(t+192); } return outtile; } char *pl_4planes2raw(char *map,unsigned short len,unsigned short hei) { char *out; unsigned long plen; register char *pout,*pout2; register char *pin; register unsigned short i,j; if ( !(out=(char *)malloc(len*hei)) ) return NULL; // apotixia desmeusis mnimis plen=len >> 2; if (len & 3) plen++; pin=map; pout=out; for (j=0;j> 2; if ( (len-1) & 3) plen++; pout=out+1; for (j=0;j> 2; if ( (len-2) & 3) plen++; pout=out+2; for (j=0;j> 2; if ( (len-3) & 3) plen++; pout=out+3; for (j=0;j>2; if (len & 03) l++; plane1= l*hei; // pou arxizei to deutero bitplane if (len<1) plane2=plane1; else { l=(len-1)>>2; if ((len-1) & 03) l++; plane2=plane1+ l*hei; } if (len<2) plane3=plane2; else { l=(len-2)>>2; if ((len-2) & 03) l++; plane3=plane2+ l*hei; } pin=inmap; pout=outmap; for (j=0;j=l) || (j-d>=127) ) break; // an iparxoun midenika bytes prepei na ftiaksoume paketo if (j-d) { ch= (1 << 7)+ j-d; // 01.(j-d) tmpbuf[tmpcount]=ch; packetsno++;tmpcount++; } // ---------------- vres an iparxei paketo copycount if (j=l) ||(j-d>=127)) break; if ( (*p)==0) break; } if (j-d) { tmpbuf[tmpcount++]=j-d; // paketo copy count p2=p-(j-d); for (k=0;k= deltay) { // { x is independent variable } numpixels = deltax + 1; d = (deltay<<1) - deltax; dinc1 = deltay << 1; dinc2 = (deltay - deltax) << 1; xinc1 = 1; xinc2 = 1; yinc1 = 0; yinc2 = 1; } else { // { y is independent variable } numpixels = deltay + 1; d = (deltax<<1) - deltay; dinc1 = deltax << 1; dinc2 = (deltax - deltay) << 1; xinc1 = 0; xinc2 = 1; yinc1 = 1; yinc2 = 1; }; // { Make sure x and y move in the right directions } if (x1 > x2) { xinc1 = - xinc1; xinc2 = - xinc2; }; if (y1 > y2) { yinc1 = - yinc1; yinc2 = - yinc2; }; // { Start drawing at } x = x1; y = y1; // { Start drawing at } screen = ((long)y1) * buflen + x1; screeninc1 = (long)yinc1 * (long)buflen + xinc1; screeninc2 = (long)yinc2 * (long)buflen + xinc2; // { Draw the pixels } asm (" \n\ movl %0,%%edi \n \ addl %1,%%edi \n \ movl %2,%%edx \n \ movb %3,%%al \n \ movl %4,%%ecx \n \ movl %5,%%ebx \n \ bres1: \n \ movb %%al,(%%edi)\n \ testw %%dx, %%dx \n \ jnl bres2 \n \ addw %%bx,%%dx \n \ addl %6,%%edi \n \ jmp bres3 \n \ bres2: \n \ \n \ addw %7, %%dx \n \ addl %8, %%edi \n \ bres3: \n \ decl %%ecx \n \ jnz bres1 \n": : "m" (buf), "m" (screen), "m" (d),"m" (color), "m" (numpixels), "m" (dinc1),"m" (screeninc1), "m" (dinc2), "m" (screeninc2) : "%edi","%edx","%eax","%ebx","%ecx","cc","memory"); // o djgpp exei bug tou eipa na valei to buf ston edi kai to evale // ston edx };