Ejemplo n.º 1
0
Archivo: fputc.c Proyecto: TC01/gcc4ti
__ATTR_TIOS_CALLBACK__ short fputc(short c, FILE *f)
{
  short tmode=!(f->flags&_F_BIN);
  unsigned short minalloc;
  char *base=f->base,*oldbase=base;
  if(f->flags&_F_ERR) return EOF;
  if(!(f->flags&_F_WRIT)) __FERROR(f);
  minalloc=peek_w(base)+3;
  if(minalloc>65520u) __FERROR(f);
  if(minalloc>f->alloc)
    {
      HeapUnlock(f->handle);
      if(f->alloc<=65520u-f->buffincrement) f->alloc+=f->buffincrement;
      else f->alloc=65520u;
      if(!HeapRealloc(f->handle,f->alloc)) __FERROR(f);
      base=f->base=HLock(f->handle);
      f->fpos+=base-oldbase;
      oldbase=base;
    }
  if(feof(f)) (*(short*)base)++;
  if(c=='\n'&&tmode) c='\r';
  poke(f->fpos++,c);
  if(c=='\r'&&tmode) fputc(' ',f);
  if(base+peek_w(base)+(tmode?0:2)==f->fpos)
    {
      f->flags|=_F_EOF;
      if(tmode)
        {
          poke(f->fpos,0);
          poke(f->fpos+1,0xE0);
        }
    }
  return c;
}
Ejemplo n.º 2
0
Archivo: dll.c Proyecto: TC01/gcc4ti
__ATTR_LIB_C__ short LoadDLL(const char *DLL_name, long ID, short major, short minor)
{
  SYM_ENTRY *entry;
  HANDLE h;
  unsigned char *bptr,*sptr;
  unsigned short len,offset=0,wrongver=0;
  unsigned long pc;
  unsigned long signature[]={__DLL_SIGNATURE,ID};
  asm volatile("bsr 0f; 0:move.l (%%sp)+,%0":"=g"(pc));
  if(HW_VERSION==2 && pc<0x40000) return DLL_NOTINGHOSTSPACE;
  if(__DLL_body_ptr) return DLL_ALREADYLOADED;
  entry=SymFindFirst(NULL,2);
  do
    {
      if(!strcmp(entry->name,DLL_name)&&entry->handle&&!entry->flags.bits.twin
        &&(entry->flags.bits.archived||!HeapGetLock(entry->handle)))
          {
            len=peek_w(bptr=HeapDeref(entry->handle))+2;
            if(!memcmp(bptr+len-5,"DLL\x00\xF8",5))
              {
                offset=0;
                for(sptr=bptr+2;(sptr<bptr+len-1)&&!offset;sptr+=2)
                  if(!memcmp(sptr,signature,8))
                    {
                      if((unsigned short)major!=((__DLL_interface_struct*)sptr)->major
                        ||(unsigned short)minor>((__DLL_interface_struct*)sptr)->minor)
                          wrongver=1;
                      else
                        offset=sptr-bptr,wrongver=0;
                    }
                  if(offset) break;
                }
          }
    } while((entry=SymFindNext()));
  if(wrongver) return DLL_WRONGVERSION;
  if(!entry) return DLL_NOTFOUND;
  if(!HeapLock(h=entry->handle)) return DLL_LOCKFAILED;
  if(!(__DLL_body_ptr=malloc(len=peek_w(bptr=HeapDeref(h)+2)+2))) 
    {
      HeapUnlock(h);
      return DLL_OUTOFMEM;
    }
  memcpy(__DLL_body_ptr,bptr,len);
  EX_patch((char*)__DLL_body_ptr+(HW_VERSION==2?0x40000:0)+2,(char*)__DLL_body_ptr+(HW_VERSION==2?0x40000:0)+len-1);
  __DLL_interface_ptr=(__DLL_interface_struct*)((char*)__DLL_body_ptr+offset-2);
  HeapUnlock(h);
  return DLL_OK;
}
Ejemplo n.º 3
0
Archivo: fseek.c Proyecto: TC01/gcc4ti
__ATTR_LIB_C__ short fseek(FILE *f, long offset, short wh)
{
  short bmode=f->flags&_F_BIN;
  char *start=(char*)f->base+(bmode?2:5);
  char *end=(char*)f->base+peek_w(f->base)+(bmode?2:0);
  char *pos=((wh==SEEK_SET)?start:((wh==SEEK_CUR)?(f->fpos):end))+offset;
  if(f->flags&_F_ERR) return EOF;
  if(pos<start||pos>end||(unsigned short)wh>SEEK_END) __FERROR(f);
  f->fpos=pos;
  f->unget=0;
  if(pos==end) f->flags|=_F_EOF;
  else f->flags&=~_F_EOF;
  return 0;
}
Ejemplo n.º 4
0
WORD peek_screen(int x, int y)
{
	return peek_w(SCREEN_BASE_ADDR + y * SCREEN_WIDTH * 2 + x * 2);
}
Ejemplo n.º 5
0
Archivo: window.c Proyecto: pmk2429/_OS
WORD peek_screen(int x, int y)
{
    return peek_w(DISP_START_ADDR + y * DISP_WIDTH * 2 + x * 2);
}