chardim.z80 793 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. chardim:
  2. ;Get the height and width of a char in the current font.
  3. ;Input: A is the char
  4. ;Output: B is the width, C is height
  5. ;Destroys: A
  6. ld b,a
  7. ld a,(textmode)
  8. or a
  9. jr z,grammer_small_size
  10. dec a
  11. jr z,var_width_size
  12. dec a
  13. jr z,grammer_small_size
  14. dec a
  15. jr z,OS_large_size
  16. dec a
  17. jr z,OS_small_size
  18. OS_large_size:
  19. ld bc,$0608
  20. ret
  21. grammer_small_size:
  22. ld bc,$0406
  23. ret
  24. OS_small_size:
  25. call os_char_ptr
  26. ld a,3
  27. ld de,lfont_record
  28. ld bc,1
  29. call readarc
  30. ld bc,(lFont_record-1)
  31. ld c,6
  32. ret
  33. var_width_size:
  34. push hl
  35. push de
  36. ld hl,(FontPointer)
  37. ld d,a
  38. .db $C2 ;start of `jp nz,*`
  39. _:
  40. add a,2
  41. ld e,a
  42. add hl,de
  43. ld a,(hl)
  44. ;a is w,h in nibbles
  45. and 15
  46. djnz -_
  47. ld c,a
  48. xor (hl)
  49. rrca
  50. rrca
  51. rrca
  52. rrca
  53. ld b,a
  54. pop de
  55. pop hl
  56. ret