CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
Display.txt123 linesDownload Raw Back to Kernel
1 2U0 RawPutChar(I64 ch)3{/*For RAW output during boot and in debugger.4 5See GrUpdateTextFG for6the normal scrn text output routine.7 8See also GrUpdateScrn().9*/10  I64 i,row,col;11  U8 *ptr,*ptr1,*ptr2;12 13  if (!(text.raw_flags&RWF_SHOW_DOLLAR)) {14    if (ch=='$') {15      if (text.raw_flags&RWF_IN_DOLLAR) {16        text.raw_flags&=~RWF_IN_DOLLAR;17        if (!(text.raw_flags & RWF_LAST_DOLLAR)) {18          text.raw_flags&=~RWF_LAST_DOLLAR;19          return;20        }21      } else {22        text.raw_flags|=RWF_IN_DOLLAR|RWF_LAST_DOLLAR;23        return;24      }25    }26    text.raw_flags&=~RWF_LAST_DOLLAR;27    if (text.raw_flags&RWF_IN_DOLLAR)28      return;29  }30  if (ch=='\t') {31    RawPutChar(CH_SPACE);32    while (text.raw_col & 7)33      RawPutChar(CH_SPACE);34  } else if (ch==CH_BACKSPACE) {35    text.raw_col--;36    RawPutChar(CH_SPACE);37    text.raw_col--;38  } else if (ch=='\n') {39    RawPutChar(CH_SPACE);40    while (text.raw_col % text.cols)41      RawPutChar(CH_SPACE);42 43  } else if (Bt(char_bmp_displayable,ch)) {44    row=text.raw_col/text.cols%text.rows;45    col=text.raw_col%text.cols;46    if (!Bt(&sys_run_level,RLf_VGA)) { //if text mode47      if (text.raw_flags&RWF_SCROLL && text.raw_col && !row && !col) {48        MemCpy(text.vga_text_alias,text.vga_text_alias+text.cols*2,49              text.cols*(text.rows-1)*2);50        MemSet(text.vga_text_alias+text.cols*(text.rows-1)*2,0,text.cols*2);51        text.raw_col-=text.cols;52        row=text.rows-1;53      }54      ptr=text.vga_text_alias+(row*text.cols+col)*2;55      ptr[0]=ch;56      ptr[1]=BLACK<<4+WHITE;57    } else {58      OutU8(VGAP_IDX,VGAR_MAP_MASK);59      OutU8(VGAP_DATA,0x0F); //All planes -- WHITE60      if (text.raw_flags&RWF_SCROLL && text.raw_col && !row && !col) {61//Scroll cached image62        MemCpy(text.raw_scrn_image,63              text.raw_scrn_image+GR_WIDTH*FONT_HEIGHT>>3,64              GR_WIDTH*(GR_HEIGHT-FONT_HEIGHT)>>3);65        MemSet(text.raw_scrn_image+GR_WIDTH*(GR_HEIGHT-FONT_HEIGHT)>>3,0,66              GR_WIDTH*FONT_HEIGHT>>3);67 68        MemCpy(text.vga_alias,text.raw_scrn_image,GR_WIDTH*GR_HEIGHT>>3);69        text.raw_col-=text.cols;70        row=text.rows-1;71      }72      PUSHFD73      CLI74      ptr=ptr1=col+row*GR_WIDTH*FONT_HEIGHT>>3;75      ptr+=text.vga_alias;76      ptr1+=text.raw_scrn_image; //Write to cached image as well77      ptr2=&text.font[ch&255];78      for (i=0;i<FONT_HEIGHT;i++) {79        *ptr=*ptr1=rev_bits_table[*ptr2++];80        ptr+=GR_WIDTH>>3;81        ptr1+=GR_WIDTH>>3;82      }83      POPFD84    }85    text.raw_col++;86  }87}88 89U0 VGAFlush()90{//Flush winmgr vga cache, so updates whole scrn.91  LBts(&sys_semas[SEMA_FLUSH_VGA_IMAGE],0);92}93 94U0 WinDerivedValsUpdate(CTask *task)95{//Those things calculated from other variables.96  if (!task) task=Fs;97  //Assert: This is called with TASKf_TASK_LOCK set98  PUSHFD99  CLI100  task->win_width =task->win_right-task->win_left+1;101  task->win_height=task->win_bottom-task->win_top+1;102  task->pix_left        =FONT_WIDTH*task->win_left;103  task->pix_right       =FONT_WIDTH*(task->win_right+1)-1;104  task->pix_width       =task->pix_right-task->pix_left+1;105  task->pix_top         =FONT_HEIGHT*task->win_top;106  task->pix_bottom      =FONT_HEIGHT*(task->win_bottom+1)-1;107  task->pix_height      =task->pix_bottom-task->pix_top+1;108  POPFD109}110 111Bool WinInside(I64 x,I64 y,CTask *task=NULL,I64 border=0)112{//Is pixel (x,y) inside task's win? Border to FONT_WIDTH.113  if (!task) task=Fs;114  if (TaskValidate(task) && Bt(&task->display_flags,DISPLAYf_SHOW)) {115    if (Bt(&task->display_flags,DISPLAYf_NO_BORDER))116      border=0;117    if (task->pix_left-border<=x<=task->pix_right+border &&118          task->pix_top-border<=y<=task->pix_bottom+border)119      return TRUE;120  }121  return FALSE;122}123