#include #include #include #include #include /*****************************************\ |* TextFX (c) 1997 Jari Komppa *\ |* *\ |* Textmode low-level functions (80x43,nb) *| \********************************************/ /********************/ /* Data & variables */ /********************/ char palette[16*3]={ /* IBM basic palette, 16c, for calcpal */ 0, 0, 0, 0, 0,42, 0,42, 0, 0,42,42, 42, 0, 0, 42, 0,42, 42,21, 0, 42,42,42, 21,21,21, 21,21,63, 21,63,21, 21,63,63, 63,21,21, 63,21,63, 63,63,21, 63,63,63}; /**************/ /* Prototypes */ /**************/ void set80x43(void); /* Sets up 80x43, no blink, no cursor. */ void set80x25(void); /* Resets 80x25, blink, cursor. */ short int calcpal(float red, float green, float blue); /* Finds the closest color/char combo for any 0:63,0:63,0:63 value. NOT MEANT FOR REALTIME USE! */ void border(char color); /* _ONLY_ for debugging! */ void vrc(void); /* Although most if not all should be timer-synced.. */ /*************/ /* Functions */ /*************/ void vrc(void) { while ((inp(0x3da)&8)==0) {} while ((inp(0x3da)&8)!=0) {} } void border(char color) { inp(0x3da); outp(0x3c0,17+32); outp(0x3c0,color); } #define EXP(a) ((a)*(a)) short int calcpal(float red, float green, float blue) { /* Slight changes from last version.. */ int b,c,ch,co; double lastdist,dist,c1,c2,c3; c1=red; c2=green; c3=blue; lastdist=100000000; for (c=0;c<16;c++) for (b=0;b<16;b++) { dist=EXP((float)palette[b*3+0]-c1)+ EXP((float)palette[b*3+1]-c2)+ EXP((float)palette[b*3+2]-c3); if (dist