chardim.z80 760 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. dec a
  9. jr z,var_width_size
  10. dec a
  11. jr z,OS_large_size
  12. dec a
  13. jr z,grammer_small_size
  14. dec a
  15. jr z,OS_small_size
  16. OS_large_size:
  17. ld bc,$0608
  18. ret
  19. grammer_small_size:
  20. ld bc,$0406
  21. ret
  22. OS_small_size:
  23. call os_char_ptr
  24. ld a,3
  25. ld de,lfont_record
  26. ld bc,1
  27. call readarc
  28. ld bc,(lFont_record-1)
  29. ld c,6
  30. ret
  31. var_width_size:
  32. push hl
  33. push de
  34. ld hl,(FontPointer)
  35. ld d,a
  36. .db $C2 ;start of `jp nz,*`
  37. _:
  38. add a,2
  39. ld e,a
  40. add hl,de
  41. ld a,(hl)
  42. ;a is w,h in nibbles
  43. and 15
  44. djnz -_
  45. ld c,a
  46. xor (hl)
  47. rrca
  48. rrca
  49. rrca
  50. rrca
  51. ld b,a
  52. pop de
  53. pop hl
  54. ret