fgetchrc.s 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /* Prototype:
  6. short __fgetchar(void); */
  7. .xdef __ref_all___set_file_in_use_bit
  8. .text
  9. .xdef __fgetchar
  10. __fgetchar_CaptureHandler:
  11. move.l 4(%a7),%a0
  12. cmp.w #0x723,(%a0)
  13. bne.s 0f
  14. move.l 8(%a0),%a0
  15. lea.l __fgetchar_keycode+2(%pc),%a1
  16. clr.w %d0
  17. move.b (%a0),%d0
  18. move.w %d0,(%a1)
  19. 0:
  20. rts
  21. .equ __ngetchx,0x51 /* ngetchx */
  22. .equ __EV_captureEvents,0xc6 /* EV_captureEvents */
  23. .equ __EV_defaultHandler,0x157 /* EV_defaultHandler */
  24. __fgetchar:
  25. pea.l (%a2)
  26. 2:
  27. move.l 0xc8:w,%a2
  28. move.l __ngetchx*4(%a2),%a0
  29. jsr (%a0)
  30. cmp.w #4139,%d0
  31. bne.s 1f
  32. lea.l __fgetchar_keycode+2(%pc),%a0
  33. clr.w (%a0)
  34. pea.l __fgetchar_CaptureHandler(%pc)
  35. move.l __EV_captureEvents*4(%a2),%a2
  36. jsr (%a2)
  37. clr.w (%a7)
  38. move.w %d3,-(%a7)
  39. move.w #4096,-(%a7)
  40. subq.l #6,%a7
  41. move.w #0x710,-(%a7)
  42. pea.l (%a7)
  43. move.l __EV_defaultHandler*4(%a2),%a0
  44. jsr (%a0)
  45. clr.l (%a7)
  46. jsr (%a2)
  47. lea.l 16(%a7),%a7
  48. __fgetchar_keycode:
  49. move.w #0,%d0
  50. beq.s 2b
  51. 1:
  52. movea.l (%a7)+,%a2
  53. rts