text_x32.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #include <int.h>
00028 #include <dos.h>
00029 #include "\x-32vm\include\x32.h"
00030
00031 #define INTNO 0x60
00032 #define _FAR
00033
00034 typedef struct tfxinfo_tag{
00035 long tid;
00036 long frame;
00037 double alpha,
00038 beta,
00039 gamma;
00040 double x,y;
00041 double R,G,B;
00042 unsigned char fc[3],
00043 sc[3];
00044 unsigned char pad1,pad2;
00045 } tfxinfo;
00046
00047 ExternalTextureProcedure(unsigned short tid, tfxinfo _FAR *TFXinfo);
00048
00049 int cdecl tsr_install (void);
00050 int cdecl tsr_remove (void);
00051
00052 main(int argc, char **argv){
00053 int i;
00054 i=tsr_install();
00055 if(i==1){
00056 printf("Program already loaded! - unloading\n");
00057 i=tsr_uninstall();
00058 if(i==0)printf("Program removed\n");
00059 else if(i==2)printf("Can not remove, Program not loaded!\n");
00060 else if(i==3)printf("Can not remove, Another program loaded above\n");
00061 exit(0);
00062 }
00063 else printf("Failed to install, error %i\n",i);
00064 }
00065
00066 int cdecl tsr_test_vect ( unsigned vno , unsigned dataseg );
00067 int cdecl tsr_already_in ( void );
00068 int cdecl tsr_new_interrupt ( struct INT_DATA* );
00069
00070 char tsr_fprint[20] = "tsrclock.v1";
00071 volatile int cdecl tsr_running;
00072 volatile char cdecl oldinterrupt[4];
00073 volatile int cdecl oldpsp;
00074 int cdecl tsr_vect_changed;
00075 unsigned cdecl tsr_codeseg;
00076 struct SREGS segregs;
00077 union REGS regs;
00078
00079 tsr_install(void){
00080 unsigned code,data,stack,extra;
00081 if(tsr_already_in() !=0)return 1;
00082 oldpsp=_psp;
00083
00084 int_intercept(INTNO,tsr_new_interrupt,1500);
00085
00086
00087 regs.h.ah=0x31;
00088 intdos(®s,®s);
00089 }
00090
00091 tsr_uninstall(void){
00092 return 0;
00093 }
00094
00095 tsr_test_vect(unsigned vno, unsigned dataseg){
00096 #if 0
00097 unsigned lseg,loff;
00098 segread(&segregs);
00099 tsr_codeseg=dataseg-(segregs.ds-segregs.cs);
00100 int_getvector(vno,&loff,&lseg);
00101 if((lseg == tsr_codeseg) || (lseg == dataseg)) return;
00102 else tsr_vect_changed+=1;
00103 #endif
00104 }
00105
00106 tsr_already_in(void){
00107 return 0;
00108 }
00109
00110 tsr_new_interrupt(struct INT_DATA *p){
00111 tfxinfo *TFXinfo;
00112 unsigned short off,seg,tid;
00113 if(tsr_running)return 0;
00114 tsr_running=1;
00115 off=p->regs.x.ax;
00116 seg=p->regs.x.bx;
00117 tid=p->regs.x.cx;
00118 printf("External procedure called for texture %ld off=%lx seg=lx\n",tid,off,seg);
00119 TFXinfo=(tfxinfo *)((unsigned int)_x32_zero_base_ptr + ((long)seg << 4) + (long)off);
00120 printf("texture %ld\n",TFXinfo->tid);
00121 printf("frame %ld\n",TFXinfo->frame);
00122 printf("x-y %lf %lf\n",TFXinfo->x,TFXinfo->y);
00123 printf("color %ld %ld %ld\n",TFXinfo->fc[0],TFXinfo->fc[1],TFXinfo->fc[2]);
00124 ExternalTextureProcedure(tid,TFXinfo);
00125 tsr_running=0;
00126 return 1;
00127 }
00128
00129 ExternalTextureProcedure(unsigned short tid, tfxinfo _FAR *TFXinfo){
00130 TFXinfo->R=0.0;
00131 TFXinfo->G=255.0;
00132 TFXinfo->B=0.0;
00133 }