fgetchrc.s 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. |improved fgetchar()/gets()/getsn() implementation for TIGCCLIB - core routine
  2. |Copyright (C) Kevin Kofler, 2002-2003
  3. |Based on documentation examples and the original fgetchar implementation, both
  4. |by Zeljko Juric
  5. |Three fixes in 2010 by Lionel Debroux
  6. /* Prototype:
  7. short __fgetchar(void); */
  8. .xdef __ref_all___set_file_in_use_bit
  9. .text
  10. .xdef __fgetchar
  11. __fgetchar_CaptureHandler:
  12. move.l 4(%a7),%a0
  13. cmp.w #0x723,(%a0) | CM_PASTE_STRING
  14. bne.s 0f
  15. move.l 8(%a0),%a0
  16. lea.l __fgetchar_keycode+2(%pc),%a1
  17. clr.w %d0
  18. move.b (%a0),%d0
  19. move.w %d0,(%a1)
  20. 0:
  21. rts
  22. .equ __ngetchx,0x51 /* ngetchx */
  23. .equ __EV_captureEvents,0xc6 /* EV_captureEvents */
  24. .equ __EV_defaultHandler,0x157 /* EV_defaultHandler */
  25. __fgetchar:
  26. pea.l (%a2)
  27. 2:
  28. move.l 0xc8:w,%a2
  29. move.l __ngetchx*4(%a2),%a0
  30. jsr (%a0)
  31. cmp.w #4139,%d0 | KEY_CHAR
  32. bne.s 1f
  33. lea.l __fgetchar_keycode+2(%pc),%a0
  34. clr.w (%a0)
  35. pea.l __fgetchar_CaptureHandler(%pc)
  36. move.l __EV_captureEvents*4(%a2),%a2
  37. jsr (%a2)
  38. clr.w (%a7)
  39. pea 0x1000102B.l | Mod == 2nd, Code == KEY_CHAR
  40. subq.l #6,%a7
  41. move.w #0x710,-(%a7)
  42. pea.l (%a7)
  43. move.l 0xc8:w,%a0
  44. move.l __EV_defaultHandler*4(%a0),%a0
  45. jsr (%a0)
  46. clr.l (%a7)
  47. jsr (%a2)
  48. lea.l 20(%a7),%a7
  49. __fgetchar_keycode:
  50. move.w #0,%d0
  51. beq.s 2b
  52. 1:
  53. movea.l (%a7)+,%a2
  54. rts