text_x32.c

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
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;       /* the id of the texture starts at 16        */
00036  long frame;     /* the frame of the animation                */
00037  double alpha,   /* position of surface point relative to the */
00038         beta,    /* shader axes alpha/beta in plane of axes   */
00039         gamma;   /* gamma at right angles to plane            */
00040  double x,y;     /* the surface mapping coords - if available */
00041  double   R,G,B; /* returned RGB colours on scale if 0-255.0  */
00042  unsigned char fc[3], /* original colour of face              */
00043                sc[3]; /* secondary (shader) colour for face   */
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";  /* unique string*/
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 // peek(0x0,INTNO*4,&oldinterrupt,4);
00084  int_intercept(INTNO,tsr_new_interrupt,1500);
00085 // regs.x.dx=_datapar;
00086 // regs.x.dx=regs.x.dx+_progpar;
00087  regs.h.ah=0x31;
00088  intdos(&regs,&regs);
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 }
Generated on Tue Jan 28 06:18:32 2014 for OpenFX by  doxygen 1.6.3