Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
702B

  1. ; Font management
  2. ;
  3. ; There can only ever be one active font.
  4. ;
  5. ; *** Defines ***
  6. ; FNT_DATA: Pointer to the beginning of the binary font data to work with.
  7. ; FNT_WIDTH: Width of the font.
  8. ; FNT_HEIGHT: Height of the font.
  9. ;
  10. ; *** Code ***
  11. ; If A is in the range 0x20-0x7e, make HL point to the beginning of the
  12. ; corresponding glyph and set Z to indicate success.
  13. ; If A isn't in the range, do nothing and unset Z.
  14. fntGet:
  15. cp 0x20
  16. ret c ; A < 0x20. Z was unset by cp
  17. cp 0x7f
  18. jp nc, unsetZ ; A >= 0x7f. Z might be set
  19. push af ; --> lvl 1
  20. push bc ; --> lvl 2
  21. sub 0x20
  22. ld hl, FNT_DATA
  23. ld b, FNT_HEIGHT
  24. .loop:
  25. call addHL
  26. djnz .loop
  27. pop bc ; <-- lvl 2
  28. pop af ; <-- lvl 1
  29. cp a ; set Z
  30. ret