PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/0.3/video.c

https://github.com/ice799/rr0d
C | 1070 lines | 676 code | 251 blank | 143 comment | 69 complexity | 9cb96505ef39cd2737c1d1fa0529748d MD5 | raw file
  1. /*
  2. * This file is part of the Rasta Ring 0 debug
  3. *
  4. * Copyright (C) 2004 Droids Corporation.
  5. * based on Deblin debuger
  6. *
  7. * $Id: video.c,v 1.46 2006-07-11 07:09:30 serpilliere Exp $
  8. *
  9. */
  10. #include "vars.h"
  11. #include "utils.h"
  12. #include "page.h"
  13. #include "video.h"
  14. //unsigned int need_
  15. unsigned int rasta_mode=0;
  16. unsigned int fOOl_mode = 0;
  17. unsigned int fOOl_mode_color_shift=0;
  18. unsigned int cursor_X=0;
  19. unsigned int cursor_Y=0;
  20. unsigned int cursor_old_color=0;
  21. unsigned int cursor_color='0';
  22. #define COLORSET1 0x12
  23. #define COLORSET2 0x50
  24. char COLOR=COLORSET1;
  25. int insline=40;
  26. unsigned int data_win_y;
  27. unsigned int data_win_dim;
  28. unsigned int code_win_y;
  29. unsigned int code_win_dim;
  30. unsigned int buff_win_y;
  31. unsigned int buff_win_dim;
  32. unsigned int cmd_win_y;
  33. unsigned int cmd_win_dim;
  34. unsigned int screen_offset_x;
  35. unsigned int screen_offset_y;
  36. unsigned int screen_bpp;
  37. unsigned int code_dim_line[10];
  38. unsigned int font_width;
  39. unsigned int font_height;
  40. unsigned int font_x;
  41. unsigned int font_y;
  42. unsigned int font_bpp;
  43. unsigned int screen_adresse ;
  44. unsigned char dump_screen_data[dump_screen_size];
  45. char screen_line0[80];
  46. char screen_line1[80];
  47. char screen_line2[80];
  48. char screen_line3[80];
  49. char screen_line4[80];
  50. char screen_line5[80];
  51. char screen_line6[80];
  52. char screen_line7[80];
  53. char screen_line8[80];
  54. char screen_line9[80];
  55. char screen_line10[80];
  56. char screen_line11[80];
  57. char screen_line12[80];
  58. char screen_line13[80];
  59. char screen_line14[80];
  60. char screen_line15[80];
  61. char screen_line16[80];
  62. char screen_line17[80];
  63. char screen_line18[80];
  64. char screen_line19[80];
  65. char screen_line20[80];
  66. char screen_line21[80];
  67. char screen_line22[80];
  68. char screen_line23[80];
  69. char screen_line24[80];
  70. char screen_line25[80];
  71. char screen_line26[80];
  72. char screen_line27[80];
  73. char screen_line28[80];
  74. char screen_line29[80];
  75. char screen_line30[80];
  76. char screen_line31[80];
  77. char screen_line32[80];
  78. char screen_line33[80];
  79. char screen_line34[80];
  80. char screen_line35[80];
  81. char screen_line36[80];
  82. char screen_line37[80];
  83. char screen_line38[80];
  84. char screen_line39[80];
  85. char *table[]={&screen_line0[0],&screen_line1[0],&screen_line2[0],&screen_line3[0],&screen_line4[0],
  86. &screen_line5[0],&screen_line6[0],&screen_line7[0],&screen_line8[0],&screen_line9[0],
  87. &screen_line10[0],&screen_line11[0],&screen_line12[0],&screen_line13[0],&screen_line14[0],
  88. &screen_line15[0],&screen_line16[0],&screen_line17[0],&screen_line18[0],&screen_line19[0],
  89. &screen_line20[0],&screen_line21[0],&screen_line22[0],&screen_line23[0],&screen_line24[0],
  90. &screen_line25[0],&screen_line26[0],&screen_line27[0],&screen_line28[0],&screen_line29[0],
  91. &screen_line30[0],&screen_line31[0],&screen_line32[0],&screen_line33[0],&screen_line34[0],
  92. &screen_line35[0],&screen_line36[0],&screen_line37[0],&screen_line38[0],&screen_line39[0],
  93. };
  94. char screen_color0[80];
  95. char screen_color1[80];
  96. char screen_color2[80];
  97. char screen_color3[80];
  98. char screen_color4[80];
  99. char screen_color5[80];
  100. char screen_color6[80];
  101. char screen_color7[80];
  102. char screen_color8[80];
  103. char screen_color9[80];
  104. char screen_color10[80];
  105. char screen_color11[80];
  106. char screen_color12[80];
  107. char screen_color13[80];
  108. char screen_color14[80];
  109. char screen_color15[80];
  110. char screen_color16[80];
  111. char screen_color17[80];
  112. char screen_color18[80];
  113. char screen_color19[80];
  114. char screen_color20[80];
  115. char screen_color21[80];
  116. char screen_color22[80];
  117. char screen_color23[80];
  118. char screen_color24[80];
  119. char screen_color25[80];
  120. char screen_color26[80];
  121. char screen_color27[80];
  122. char screen_color28[80];
  123. char screen_color29[80];
  124. char screen_color30[80];
  125. char screen_color31[80];
  126. char screen_color32[80];
  127. char screen_color33[80];
  128. char screen_color34[80];
  129. char screen_color35[80];
  130. char screen_color36[80];
  131. char screen_color37[80];
  132. char screen_color38[80];
  133. char screen_color39[80];
  134. char *table_color[]={
  135. &screen_color0[0],&screen_color1[0],&screen_color2[0],&screen_color3[0],&screen_color4[0],
  136. &screen_color5[0],&screen_color6[0],&screen_color7[0],&screen_color8[0],&screen_color9[0],
  137. &screen_color10[0],&screen_color11[0],&screen_color12[0],&screen_color13[0],&screen_color14[0],
  138. &screen_color15[0],&screen_color16[0],&screen_color17[0],&screen_color18[0],&screen_color19[0],
  139. &screen_color20[0],&screen_color21[0],&screen_color22[0],&screen_color23[0],&screen_color24[0],
  140. &screen_color25[0],&screen_color26[0],&screen_color27[0],&screen_color28[0],&screen_color29[0],
  141. &screen_color30[0],&screen_color31[0],&screen_color32[0],&screen_color33[0],&screen_color34[0],
  142. &screen_color35[0],&screen_color36[0],&screen_color37[0],&screen_color38[0],&screen_color39[0],
  143. };
  144. int accessline[SCREEN_LINE];
  145. int CommandLength=0;
  146. char Command[256];
  147. int test()
  148. {
  149. // Out_Debug_String("(_.-POUET-._)!\n\r");
  150. return 0;
  151. }
  152. void prepare_screen(void)
  153. {
  154. unsigned int i, ii;
  155. for (i=0;i<cmd_win_y+cmd_win_dim;i++)
  156. for (ii=0;ii<80;ii++)
  157. {
  158. table[i][ii]=' ';
  159. table_color[i][ii]=' ';
  160. }
  161. for (i=0;i<cmd_win_y/*+cmd_win_dim*/;i++)
  162. {
  163. table[i][0] = '³'; table_color[i][0] = '1';
  164. table[i][79] = '³'; table_color[i][79] = '1';
  165. }
  166. for (i=0;i<80;i++)
  167. {
  168. table[0][i] = 'Ä';
  169. table_color[0][i] = '1';
  170. table[data_win_y-1][i] = 'Ä';
  171. table_color[data_win_y-1][i] = '1';
  172. table[code_win_y-1][i] = 'Ä';
  173. table_color[code_win_y-1][i] = '1';
  174. table[buff_win_y-1][i] = 'Ä';
  175. table_color[buff_win_y-1][i] = '1';
  176. table[cmd_win_y-1][i] = 'Ä';
  177. table_color[cmd_win_y-1][i] = '1';
  178. }
  179. table[0][0] = 'Ú';
  180. table[0][79] = '¿';
  181. table[data_win_y-1][0] = 'Ã';
  182. table[data_win_y-1][79] = '´';
  183. table[code_win_y-1][0] = 'Ã';
  184. table[code_win_y-1][79] = '´';
  185. table[buff_win_y-1][0] = 'Ã';
  186. table[buff_win_y-1][79] = '´';
  187. table[cmd_win_y-1][0] = 'À';//'Ã';
  188. table[cmd_win_y-1][79] = 'Ù';//'´';
  189. rr0d_memcpy(&table[1][1], "EAX=", 4);
  190. rr0d_memcpy(&table[1][14], "EBX=", 4);
  191. rr0d_memcpy(&table[1][27], "ECX=", 4);
  192. rr0d_memcpy(&table[1][40], "EDX=", 4);
  193. rr0d_memcpy(&table[1][53], "EDI=", 4);
  194. rr0d_memcpy(&table[2][1], "ESI=", 4);
  195. rr0d_memcpy(&table[2][14], "EBP=", 4);
  196. rr0d_memcpy(&table[2][27], "ESP=", 4);
  197. rr0d_memcpy(&table[2][40], "EIP=", 4);
  198. rr0d_memcpy(&table[3][1], "CS =", 4);
  199. rr0d_memcpy(&table[3][14], "DS =", 4);
  200. rr0d_memcpy(&table[3][27], "ES =", 4);
  201. rr0d_memcpy(&table[3][40], "SS =", 4);
  202. rr0d_memcpy(&table[3][53], "FS =", 4);
  203. rr0d_memcpy(&table[3][66], "GS =", 4);
  204. for (i=1;i<14;i++)
  205. {
  206. for (ii=0;ii<data_win_dim;ii++)
  207. table_color[data_win_y+ii][i] = '2';
  208. for (ii=0;ii<code_win_dim;ii++)
  209. table_color[code_win_y+ii][i] = '2';
  210. if (i==4)
  211. i++;
  212. }
  213. for (i=0;i<6;i++)
  214. {
  215. for (ii=1;ii<4;ii++)
  216. {
  217. table_color[1][13*i+ii] = '8';
  218. table_color[2][13*i+ii] = '8';
  219. table_color[3][13*i+ii] = '8';
  220. }
  221. }
  222. }
  223. /*
  224. *------------------------------------------------------------------
  225. *- bool LoadBMP(char*, GLfloat, GLfloat) --------------------------
  226. *------------------------------------------------------------------
  227. *- Description: This function loads a Windows Bitmap into the -
  228. *- TEXTURE class object that it represents. -
  229. *------------------------------------------------------------------
  230. *- Big thanks to NeHe for this one -
  231. *------------------------------------------------------------------
  232. */
  233. int LoadBMP(char* file_data, unsigned int* width, unsigned int* height, unsigned int *font_bpp, unsigned char *data)
  234. {
  235. *width = 2048;
  236. *height = 12;
  237. *font_bpp = 8;
  238. // Out_Debug_String("Loaded correctly \n\r");
  239. return 1;
  240. }
  241. /*affiche un caractere a l'ecran a la position */
  242. /*x y (unité: le caractere) */
  243. /*si ca déborde, ben ca débordera. */
  244. /*les couleur sont gérées la aussi */
  245. #ifdef VIDEO_FB
  246. void print_char(unsigned char a, unsigned int x, unsigned int y)
  247. {
  248. unsigned int x_pix, y_pix, x1, y1;
  249. int char_font_x, char_screen_x;
  250. int font_next_line = 256 * font_x;
  251. unsigned int color;
  252. unsigned int byte_per_pixel = font_bpp>>3;
  253. int tmp_decal_font_x=0;
  254. int tmp_decal_screen_x=0;
  255. int tmp_font_y_m_y=0;
  256. //unsigned char debug[80];
  257. x1 = x - screen_offset_x;
  258. y1 = y - screen_offset_y;
  259. //__asm{int 3};
  260. // font_x = 8;
  261. /*
  262. Sprintf(debug, "%.8X %.8X %.8X\n\r", font_x, x1, y1);
  263. Out_Debug_String(debug);
  264. */
  265. char_font_x = font_x * (int)a;
  266. char_screen_x = font_x * x + font_y * y * SCREEN_MAX_X;
  267. //__asm{int 3};
  268. // Sprintf(debug, "->%X %X \n\r", font_x, font_y);
  269. // Out_Debug_String(debug);
  270. for (x_pix = 0; x_pix < font_x; x_pix++)
  271. {
  272. tmp_decal_font_x = char_font_x + x_pix;
  273. tmp_decal_screen_x = char_screen_x + x_pix;
  274. for (y_pix = 0; y_pix < font_y; y_pix++)
  275. {
  276. tmp_font_y_m_y = (font_y-y_pix)*SCREEN_MAX_X;
  277. color = (font_data[(tmp_decal_font_x + y_pix*font_next_line)*byte_per_pixel+0]>>3);
  278. // Sprintf(debug, "mode %.8X %.8X \n\r", rasta_mode, fOOl_mode);
  279. // Out_Debug_String(debug);
  280. if (rasta_mode)
  281. {
  282. /*Rasta Mode*/
  283. switch(color)
  284. {
  285. case 0:
  286. break;
  287. default:
  288. switch (x%3)
  289. {
  290. case 0: color = 0x0780; break;
  291. case 1: color = 0xf800; break;
  292. case 2: color = 0xffe0; break;
  293. }
  294. break;
  295. }
  296. }
  297. if (fOOl_mode)
  298. {
  299. /*f001 Mode*/
  300. /* 0 blk, 1 darkbl, 2 darkgr, 3 cyan, 4 red, 5 purpur, 6 orange, 7 lgray, 8 dgray,
  301. 9 lblue, 10 lgrn, 11 lblu, 12 lred, 13 lping, 14 yell, 15 white */
  302. switch ( ((x+fOOl_mode_color_shift)>>2)%8)
  303. {
  304. case 0: color = 0x1; break;
  305. case 1: color = 0x9; break;
  306. case 2: color = 0x3; break;
  307. case 3: color = 0xb; break;
  308. case 4: color = 0xf; break;
  309. case 5: color = 0xb; break;
  310. case 6: color = 0x3; break;
  311. case 7: color = 0x9; break;
  312. }
  313. }
  314. if (!rasta_mode && !fOOl_mode)
  315. {
  316. // Sprintf(debug, "normal mode %.8X %.8X %.8X %X\n\r", a, x1, y1, color);
  317. //Out_Debug_String(debug);
  318. /*Normal mode*/
  319. if ((x1<80) && (y1<40))
  320. {
  321. if (!color)
  322. {
  323. if (x1 == cursor_X && y1 == cursor_Y)
  324. color = 0xc618;
  325. }
  326. else
  327. {
  328. switch(table_color[y1][x1])
  329. {
  330. case 0:
  331. break;
  332. case ' ': color = 0xc618; break;
  333. case '1': color = 0x0780; break;
  334. case '2': color = 0x9CD3; break;
  335. case '8': color = 0x44b0; break;
  336. default:
  337. break;
  338. }
  339. }
  340. }
  341. }
  342. /*
  343. #ifdef BYTE_PER_PIXEL_HALF
  344. *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff;
  345. #endif
  346. #ifdef BYTE_PER_PIXEL_ONE
  347. *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff;
  348. #endif
  349. #ifdef BYTE_PER_PIXEL_TWO
  350. *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color;
  351. #endif
  352. #ifdef BYTE_PER_PIXEL_THREE
  353. *((char*)screen_adresse+0+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff;
  354. #endif
  355. */
  356. //__asm{int 3};
  357. #ifdef BYTE_PER_PIXEL_FOUR
  358. #ifdef HW_FB
  359. poked1(screen_adresse+4*(tmp_decal_screen_x + (tmp_font_y_m_y)) , color);
  360. #else
  361. *((int*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color;
  362. #endif
  363. #endif
  364. /*
  365. switch(screen_bpp)
  366. {
  367. case 1:
  368. *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff;
  369. break;
  370. case 2:
  371. *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color;
  372. break;
  373. case 3:
  374. *((char*)screen_adresse+0+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff;
  375. *((char*)screen_adresse+1+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=(color>>8)&0xff;
  376. break;
  377. case 4:
  378. *((int*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color;
  379. break;
  380. default:
  381. *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color;
  382. break;
  383. }
  384. */
  385. }
  386. }
  387. }
  388. #endif
  389. #ifdef VIDEO_AA
  390. #define TEXT_MODE_ADDRESS 0xC00B8000
  391. unsigned char videobaselow;
  392. unsigned char videobasehigh;
  393. void read_mem_base(void)
  394. {
  395. #ifdef ATT_ASM
  396. __asm("\n\t"
  397. "movw $0x3d4,%dx\n\t"
  398. "movb $0x0c,%al\n\t"
  399. "outb %al,%dx\n\t"
  400. "movw $0x3d5,%dx\n\t"
  401. "inb %dx,%al\n\t"
  402. "movb %al,(videobasehigh); \n\t"
  403. "movw $0x3d4,%dx\n\t"
  404. "movb $0x0d,%al\n\t"
  405. "outb %al,%dx\n\t"
  406. "movw $0x3d5,%dx\n\t"
  407. "inb %dx,%al\n\t"
  408. "movb %al,(videobaselow);\n\t"
  409. );
  410. #endif
  411. };
  412. void restore_mem_base(void)
  413. {
  414. #ifdef ATT_ASM
  415. __asm("\n\t"
  416. "movw $0x3d4,%dx\n\t"
  417. "movb $0x0c,%al\n\t"
  418. "outb %al,%dx\n\t"
  419. "movw $0x3d5,%dx\n\t"
  420. "movb (videobasehigh),%al \n\t"
  421. "outb %al,%dx\n\t"
  422. "movw $0x3d4,%dx\n\t"
  423. "movb $0x0d,%al\n\t"
  424. "outb %al,%dx\n\t"
  425. "movw $0x3d5,%dx\n\t"
  426. "movb (videobaselow),%al \n\t"
  427. "outb %al,%dx\n\t"
  428. );
  429. #endif
  430. };
  431. void reset_mem_to_0(void)
  432. {
  433. #ifdef ATT_ASM
  434. __asm("\n\t"
  435. "movw $0x3d4,%dx\n\t"
  436. "movw $0x000c,%ax\n\t"
  437. "outw %ax,%dx\n\t"
  438. "movw $0x000d,%ax\n\t"
  439. "outw %ax,%dx\n\t"
  440. );
  441. #endif
  442. };
  443. void Start_Display(void)
  444. {
  445. //printk("read...");
  446. read_mem_base();
  447. //printk("mem to 0...");
  448. reset_mem_to_0();
  449. };
  450. void End_Display(void)
  451. {
  452. //printk("mem base...");
  453. restore_mem_base();
  454. };
  455. void print_char(unsigned char a, unsigned int x, unsigned int y)
  456. {
  457. char *ptr=(char *) TEXT_MODE_ADDRESS/*+80*10*2*/;
  458. int color=0;
  459. if ((y>25)||(x>80))
  460. return;
  461. //Start_Display();
  462. ptr=ptr+(2*80*y);
  463. ptr=ptr+(x*2);
  464. *ptr=a;
  465. ptr++;
  466. if (rasta_mode)
  467. {
  468. /*Rasta Mode*/
  469. switch (x%3)
  470. {
  471. case 0: color = 0x4; break;
  472. case 1: color = 0xE; break;
  473. case 2: color = 0xA; break;
  474. }
  475. }
  476. if (fOOl_mode)
  477. {
  478. /*f001 Mode*/
  479. /* 0 blk, 1 darkbl, 2 darkgr, 3 cyan, 4 red, 5 purpur, 6 orange, 7 lgray, 8 dgray,
  480. 9 lblue, 10 lgrn, 11 lblu, 12 lred, 13 lping, 14 yell, 15 white */
  481. switch ( ((x+fOOl_mode_color_shift)>>2)%8)
  482. {
  483. case 0: color = 0x1; break;
  484. case 1: color = 0x9; break;
  485. case 2: color = 0x3; break;
  486. case 3: color = 0xb; break;
  487. case 4: color = 0xf; break;
  488. case 5: color = 0xb; break;
  489. case 6: color = 0x3; break;
  490. case 7: color = 0x9; break;
  491. }
  492. }
  493. if (!rasta_mode && !fOOl_mode)
  494. {
  495. /*Normal mode*/
  496. if ((x<80) && (y<40) )
  497. {
  498. switch(table_color[y][x])
  499. {
  500. case 0:
  501. break;
  502. case ' ': color = 0x7; break;
  503. case '0': color = 0xc7; break;
  504. case '1': color = 0x3; break;
  505. case '2': color = 0x8; break;
  506. case '8': color = 0x2; break;
  507. default:
  508. break;
  509. }
  510. }
  511. }
  512. *ptr=(char)color;
  513. }
  514. /*
  515. void Clear_VHAL(void)
  516. {
  517. int x,y;
  518. for (x=0;x<27;x++)
  519. for (y=0;y<80;y++)
  520. print_char('A', x, y);
  521. // PutChar(x,y,' ',COLORSET1);
  522. };
  523. */
  524. #endif /* VIDEO_AA */
  525. /*affiche une chaine de char a la pos x y */
  526. /* */
  527. /* */
  528. void Put_String(char* string, unsigned int x, unsigned int y)
  529. {
  530. unsigned int i;
  531. for (i=0;i<rr0d_strlen(string);i++)
  532. {
  533. /*
  534. if (x+i>=80)
  535. break;*/
  536. print_char(string[i], x+i,y);
  537. }
  538. }
  539. /*surcouche englobant le décalage de l'ecran */
  540. /* */
  541. void PutString(unsigned long y,unsigned long x,char *ptr,char attrib)
  542. {
  543. #ifdef VIDEO_FB
  544. Put_String(ptr, x+screen_offset_x, y+screen_offset_y);
  545. #endif
  546. #ifdef VIDEO_AA
  547. Put_String(ptr, x, y);
  548. #endif
  549. }
  550. /*dump les pixel de l'ecran pour plus tard quand */
  551. /*voudra remettre les pixel ecrasés */
  552. void dump_screen(void)
  553. {
  554. /* int i;*/
  555. /*
  556. for (i=0;i<SCREEN_MAX_X*SCREEN_MAX_Y*BYTE_PER_PIXEL/4;i++)
  557. *(((unsigned int*)screen_data)+i)=((unsigned int*)screen_adresse)[i];
  558. */
  559. #ifdef VIDEO_AA
  560. int i;
  561. unsigned int *ptr=(unsigned int *) TEXT_MODE_ADDRESS;
  562. for (i=0;i<dump_screen_size/sizeof(unsigned int);i++)
  563. {
  564. dump_screen_data[i] = ptr[i];
  565. }
  566. #endif
  567. }
  568. /*l'inverse */
  569. /* */
  570. void restore_screen(int do_work)
  571. {
  572. /* int i;*/
  573. /*
  574. for (i=0;i<SCREEN_MAX_X*SCREEN_MAX_Y*BYTE_PER_PIXEL/4;i++)
  575. ((unsigned int*)screen_adresse)[i]=*(((unsigned int*)screen_data)+i);
  576. */
  577. #ifdef VIDEO_AA
  578. int i;
  579. unsigned int *ptr=(unsigned int *) TEXT_MODE_ADDRESS;
  580. if (!do_work)
  581. return;
  582. for (i=0;i<dump_screen_size/sizeof(unsigned int);i++)
  583. {
  584. ptr[i] = dump_screen_data[i];
  585. }
  586. #endif
  587. }
  588. void put_XY_char(int x, int y, unsigned char a)
  589. {
  590. table[y][x]=a;
  591. }
  592. void displaymessage(char *ptr) /* Display a message */
  593. {
  594. int x=1;
  595. accessline[cmd_win_y+1]=1;
  596. while (*ptr!=0)
  597. {
  598. accessline[x]=1;
  599. /* screen_line24[x]=*ptr; */
  600. table[cmd_win_y+1][x]=*ptr;
  601. x++;
  602. ptr++;
  603. };
  604. }
  605. void WriteVCon(unsigned int x,unsigned y,char *ptr)
  606. {
  607. if ((x<SCREEN_LINE) && (y<80) && ((rr0d_strlen(ptr)+y)<80))
  608. {
  609. strcpy(&table[x][y], ptr);
  610. accessline[x]=1;
  611. };
  612. }
  613. void delline(int screen_line) /* Clear a buffer line */
  614. {
  615. int x;
  616. char *ptr;
  617. accessline[screen_line]=1;
  618. ptr=&table[screen_line][0];
  619. for (x=0;x<80;x++)
  620. {
  621. *ptr=' ';
  622. ptr++;
  623. };
  624. }
  625. void ClearAW() /* Clear A window */
  626. {
  627. unsigned int x;
  628. for (x=buff_win_y;x<=buff_win_y + buff_win_dim;x++)
  629. delline(x);
  630. }
  631. void ClearDW() /* Clear dump window */
  632. {
  633. unsigned int x;
  634. for (x=data_win_y;x<=data_win_y + data_win_dim;x++)
  635. delline(x);
  636. }
  637. void ClearCW() /* Clear dump window */
  638. {
  639. unsigned int x;
  640. for (x=code_win_y;x<=code_win_y + code_win_dim;x++)
  641. delline(x);
  642. }
  643. void cls() /* Clear Screen */
  644. {
  645. insline=40;
  646. ClearAW();
  647. ClearDW();
  648. }
  649. void DisplayText(int x,int y,char *texto) /* Display text in a x,y position in Console */
  650. {
  651. char *buf=(char *) &table[y][x];
  652. char *tmp=texto;
  653. accessline[y]=1;
  654. while (*tmp!=0)
  655. {
  656. *buf=*tmp;
  657. buf++;tmp++;
  658. x++;
  659. if (x>78)
  660. break;
  661. };
  662. }
  663. void print_AW(char* ptr, int ligne)
  664. {
  665. DisplayText(1,buff_win_y+ligne,ptr);
  666. }
  667. void print_DW(char* ptr, int ligne)
  668. {
  669. DisplayText(1,data_win_y+ligne,ptr);
  670. }
  671. void print_CW(char* ptr, int ligne)
  672. {
  673. DisplayText(1,code_win_y+ligne,ptr);
  674. }
  675. /*rafraichi la fenetre de log */
  676. /* */
  677. void Refresh_AW()
  678. {
  679. unsigned int i;
  680. for (i=buff_win_y;i<=buff_win_y + buff_win_dim;i++)
  681. accessline[i]=1;
  682. }
  683. /*rafraichi la fenetre de data */
  684. /* */
  685. void Refresh_DW()
  686. {
  687. unsigned int i;
  688. for (i=data_win_y;i<data_win_y + data_win_dim;i++)
  689. accessline[i]=1;
  690. }
  691. /*rafraichi la fenetre de code */
  692. /* */
  693. void Refresh_CW()
  694. {
  695. unsigned int i;
  696. for (i=code_win_y;i<code_win_y + code_win_dim;i++)
  697. accessline[i]=1;
  698. }
  699. /*rafraichi tout */
  700. /* */
  701. void Refresh_ALL()
  702. {
  703. unsigned int i;
  704. for (i=0;i<SCREEN_LINE;i++)
  705. accessline[i]=1;
  706. }
  707. void cursor_top_right(void)
  708. {
  709. rr0d_outb(0xC, 0x3d4);
  710. rr0d_outb(0x0, 0x3d5);
  711. rr0d_outb(0xd, 0x3d4);
  712. rr0d_outb(0x0, 0x3d5);
  713. }
  714. /*end test :)*/
  715. /*re affiche les lignes qui ont besoin d'etre */
  716. /*rafraichies */
  717. void Refresh_Display() /* look for a modified lines and rewrite them */
  718. {
  719. unsigned long screen_line;
  720. screen_line=0;
  721. #ifdef VIDEO_AA
  722. cursor_top_right();
  723. Start_Display();
  724. #endif /* VIDEO_AA */
  725. for(screen_line=0;screen_line<SCREEN_LINE;screen_line++)
  726. {
  727. if (accessline[screen_line]){
  728. if (insline!=screen_line) PutString(screen_line,0,&table[screen_line][0],COLOR);
  729. else PutString(screen_line,0,&table[screen_line][0],COLORSET2);
  730. };
  731. accessline[screen_line]=0;
  732. };
  733. #ifdef VIDEO_AA
  734. End_Display();
  735. #endif /* VIDEO_AA */
  736. }
  737. /* ajoute un caractere a la commande courante */
  738. void InsertCommandKey(char car) /* A new key is pressed and is added to the command */
  739. {
  740. accessline[cmd_win_y]=1;
  741. Command[CommandLength]=car;
  742. table[cmd_win_y][1+CommandLength]=car;
  743. CommandLength++;
  744. Command[CommandLength]=0x0;
  745. }
  746. /*efface la commande courante */
  747. /* */
  748. void ClearCommand() /* Clear Command line */
  749. {
  750. delline(cmd_win_y);
  751. CommandLength=0;
  752. }
  753. /*efface un car de la commande courante */
  754. /*(bacjspace) */
  755. void DeleteCommandKey()
  756. {
  757. accessline[cmd_win_y]=1;
  758. if (CommandLength) {
  759. table[cmd_win_y][CommandLength]=' ';
  760. CommandLength--;
  761. Command[CommandLength]=0x0;
  762. };
  763. }
  764. void deblin_change_color(char *object,char *val)
  765. {
  766. }
  767. void deblin_console_off()
  768. {
  769. }
  770. void deblin_console_on()
  771. {
  772. int x;
  773. for (x=0;x<SCREEN_LINE;x++) accessline[x]=1; /* We want to modify all lines */
  774. Refresh_Display();
  775. }
  776. void test_scr()
  777. {
  778. int i;
  779. for (i=0;i<28;i++)
  780. Put_String(&table[i][0], 60, 70+i);
  781. }
  782. void update_cursor(unsigned int x, unsigned int y)
  783. {
  784. if (y<data_win_y)
  785. y = data_win_y;
  786. if (x<15)
  787. x = 15;
  788. if (y>data_win_y + data_win_dim-1)
  789. y = (unsigned int )(data_win_y + data_win_dim-1);
  790. if (x>80-1)
  791. x = 80-1;
  792. if ((x<80) && (y<40) )
  793. {
  794. accessline[y]=1;
  795. accessline[cursor_Y]=1;
  796. table_color[cursor_Y][cursor_X] = (char)cursor_old_color;
  797. if (x<63)
  798. if (!((x+1)%3))
  799. x = x>cursor_X?x+1:x-1;
  800. cursor_old_color = table_color[y][x];
  801. table_color[y][x] = (char)cursor_color;
  802. cursor_X = x;
  803. cursor_Y = y;
  804. }
  805. Refresh_Display();
  806. }
  807. void erase_cursor()
  808. {
  809. if ((cursor_X<80) && (cursor_Y<40) )
  810. {
  811. accessline[cursor_Y]=1;
  812. table_color[cursor_Y][cursor_X] = (char)cursor_old_color;
  813. }
  814. Refresh_Display();
  815. }