graphic.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of XNIX. */
  3. /*
  4. XNIX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. XNIX is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with XNIX. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #ifndef INCLUDED_GRAPHIC_H
  20. #define INCLUDED_GRAPHIC_H
  21. #include <kernel/types.h>
  22. void putblock(__uint8_t, int, int, int, int);
  23. void putc(char, __uint8_t, __uint8_t);
  24. void print(__uint8_t, __uint8_t, char *);
  25. /*
  26. * we supports PSF format in XNIX.
  27. * in linux, PSF fonts are in /usr/share/kbd/consolefonts, and they are always compressed.
  28. * */
  29. #define PSF_MAGIC 0x864ab572
  30. struct psf_header {
  31. __uint32_t magic;
  32. /* zero */
  33. __uint32_t version;
  34. __uint32_t header_size;
  35. /* zero if there's no unicode table */
  36. __uint32_t flags;
  37. /* in psf, a font calls glyph */
  38. __uint32_t glyphs_count;
  39. /* size of a glyph */
  40. __uint32_t glyph_size;
  41. __uint32_t height;
  42. __uint32_t width;
  43. };
  44. /* '__uint64_t * ' can change to other types */
  45. /* because they are all just lables with an address */
  46. extern __uint8_t *font_start;
  47. extern __uint8_t *font_end;
  48. /* but 'font_size' must be __uint64_t because it's a value */
  49. extern __uint64_t font_size;
  50. #define FB_ADDR ((char *) 0xa0000)
  51. /* x and y in this vga mode */
  52. #define VGA_X 320
  53. #define VGA_Y 200
  54. /* this is default value */
  55. #define CHAR_HEIGHT 8
  56. #define CHAR_WIDTH 16
  57. #define X_CHARS (VGA_X / CHAR_WIDTH)
  58. #define Y_LINES (VGA_Y / CHAR_HEIGHT)
  59. #endif