Guest User

Untitled

a guest
Nov 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. /**
  2. * screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
  3. */
  4. void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
  5. {
  6.  
  7. short offset; /* due to negative offsets */
  8. unsigned short x; /* Current X and Y coordinates */
  9. unsigned short y;
  10. unsigned short* px; /* Pointers to X and Y coordinates used for actual plotting */
  11. unsigned short* py;
  12. unsigned char i; /* current character counter */
  13. unsigned char a; /* current character byte */
  14. unsigned char j,k; /* loop counters */
  15. char b; /* current character row bit signed */
  16. unsigned char width=FONT_SIZE_X;
  17. unsigned char height=FONT_SIZE_Y;
  18. unsigned short deltaX=1;
  19. unsigned short deltaY=1;
  20. unsigned char mainColor=current_foreground;
  21. unsigned char altColor=current_background;
  22. unsigned char *p;
  23. unsigned char* curfont;
  24.  
  25. switch(CurMem)
  26. {
  27. case M0:
  28. curfont=font;
  29. offset=-32;
  30. break;
  31. case M1:
  32. curfont=font;
  33. offset=64;
  34. break;
  35. case M2:
  36. curfont=fontm23;
  37. offset=-32;
  38. break;
  39. case M3:
  40. curfont=fontm23;
  41. offset=32;
  42. break;
  43. }
  44.  
  45. if (CurMode==ModeRewrite)
  46. {
  47. altColor=current_background;
  48. }
  49. else if (CurMode==ModeInverse)
  50. {
  51. altColor=current_foreground;
  52. }
  53.  
  54. if (CurMode==ModeErase || CurMode==ModeInverse)
  55. mainColor=current_background;
  56. else
  57. mainColor=current_foreground;
  58.  
  59. SetAPen(myWindow->RPort,mainColor);
  60.  
  61. x=scalex[(Coord->x&0x1FF)];
  62. y=scaley[(Coord->y)+15&0x1FF];
  63.  
  64. if (FastText==padF)
  65. {
  66. goto chardraw_with_fries;
  67. }
  68.  
  69. /* the diet chardraw routine - fast text output. */
  70.  
  71. for (i=0;i<count;++i)
  72. {
  73. a=*ch;
  74. ++ch;
  75. a+=offset;
  76. p=&curfont[fontptr[a]];
  77.  
  78. for (j=0;j<FONT_SIZE_Y;++j)
  79. {
  80. b=*p;
  81.  
  82. for (k=0;k<FONT_SIZE_X;++k)
  83. {
  84. if (b&0x80) /* check sign bit. */
  85. {
  86. SetAPen(myWindow->RPort,mainColor);
  87. WritePixel(myWindow->RPort,x,y);
  88. }
  89.  
  90. ++x;
  91. b<<=1;
  92. }
  93.  
  94. ++y;
  95. x-=width;
  96. ++p;
  97. }
  98.  
  99. x+=width;
  100. y-=height;
  101. }
  102.  
  103. return;
  104.  
  105. chardraw_with_fries:
  106. if (Rotate)
  107. {
  108. deltaX=-abs(deltaX);
  109. width=-abs(width);
  110. px=&y;
  111. py=&x;
  112. }
  113. else
  114. {
  115. px=&x;
  116. py=&y;
  117. }
  118.  
  119. if (ModeBold)
  120. {
  121. deltaX = deltaY = 2;
  122. width<<=1;
  123. height<<=1;
  124. }
  125.  
  126. for (i=0;i<count;++i)
  127. {
  128. a=*ch;
  129. ++ch;
  130. a+=offset;
  131. p=&curfont[fontptr[a]];
  132. for (j=0;j<FONT_SIZE_Y;++j)
  133. {
  134. b=*p;
  135.  
  136. if (Rotate)
  137. {
  138. px=&y;
  139. py=&x;
  140. }
  141. else
  142. {
  143. px=&x;
  144. py=&y;
  145. }
  146.  
  147. for (k=0;k<FONT_SIZE_X;++k)
  148. {
  149. if (b&0x80) /* check sign bit. */
  150. {
  151. SetAPen(myWindow->RPort,mainColor);
  152. if (ModeBold)
  153. {
  154. WritePixel(myWindow->RPort,*px+1,*py);
  155. WritePixel(myWindow->RPort,*px,*py+1);
  156. WritePixel(myWindow->RPort,*px+1,*py+1);
  157. }
  158. WritePixel(myWindow->RPort,*px,*py);
  159. }
  160. else
  161. {
  162. if (CurMode==ModeInverse || CurMode==ModeRewrite)
  163. {
  164. SetAPen(myWindow->RPort,altColor);
  165. if (ModeBold)
  166. {
  167. WritePixel(myWindow->RPort,*px+1,*py);
  168. WritePixel(myWindow->RPort,*px,*py+1);
  169. WritePixel(myWindow->RPort,*px+1,*py+1);
  170. }
  171. WritePixel(myWindow->RPort,*px,*py);
  172. }
  173. }
  174.  
  175. x += deltaX;
  176. b<<=1;
  177. }
  178.  
  179. y+=deltaY;
  180. x-=width;
  181. ++p;
  182. }
  183.  
  184. Coord->x+=width;
  185. x+=width;
  186. y-=height;
  187. }
  188.  
  189. return;
  190. }
Add Comment
Please, Sign In to add comment