6677

UNSC Text 0.3.2

Apr 19th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 3.14 KB | None | 0 0
  1. ;UNSC Text Edit V: 0.3.2
  2.  
  3.  
  4. ;This line enables program to be run standalone
  5. ;Usually the OS would set the PC to text edit via its menu or something similar
  6. SET PC, textedit
  7.  
  8. ;this section may not be needed. Purely enables program to run standalone
  9. ;Replace the JSR command to reach here (ln 19) with the command to run the OS clear function
  10. :textclear
  11. SET [0x8000+A], 0
  12. ADD A, 1
  13. IFG A, 0x200
  14. SET PC, POP
  15. SET PC, textclear
  16.  
  17. :textedit
  18. SET PUSH, A
  19. SET PUSH, B
  20. SET PUSH, C
  21. JSR textclear;replace this line with the relevant OS function to clear screen
  22.  
  23. ;Draw header
  24. SET [0x8000],0x0F55;U
  25. SET [0x8001],0x0F4E;N
  26. SET [0x8002],0x0F53;S
  27. SET [0x8003],0x0F43;C
  28. SET [0x8004],0x0F20;
  29. SET [0x8005],0x0F54;T
  30. SET [0x8006],0x0F65;e
  31. SET [0x8007],0x0F78;x
  32. SET [0x8008],0x0F74;t
  33. SET [0x8009],0x0F20;
  34. SET [0x800A],0x0F45;E
  35. SET [0x800B],0x0F64;d
  36. SET [0x800C],0x0F69;i
  37. SET [0x800D],0x0F74;t
  38. SET [0x800E],0x0F20;
  39. SET [0x800F],0x0F56;V
  40. SET [0x8010],0x0F3A;:
  41. SET [0x8011],0x0F20;
  42. SET [0x8012],0x0F30;0  < Major version, 1 on full V1 OS release
  43. SET [0x8013],0x0F2E;.
  44. SET [0x8014],0x0F33;3  < Minor Version
  45. SET [0x8015],0x0F2E;.
  46. SET [0x8016],0x0F32;2  < Patch version, increment by 1 for each patch release
  47.  
  48.  
  49. SET [0x8020], 0xF0DF;Sets the blinking cursor for typing with
  50. SET B, 0 ;DO NOT CHANGE, unless you know how to fix the endless bugs it causes
  51.  
  52. :textedit_loop
  53. SET A, [0x9000]
  54. IFE A, 0x0
  55. SET PC, textedit_loop
  56. IFE A, 0x1B
  57. SET PC, textedit_exit
  58. IFE A, 0xA
  59. SET PC, textedit_newline
  60. IFE A, 8
  61. SET PC, textedit_backspace
  62. IFE A, 1
  63. SET PC, textedit_left
  64. IFE A, 2
  65. SET PC, textedit_right
  66. IFE A, 3
  67. SET PC, textedit_up
  68. IFE A, 4
  69. SET PC, textedit_down
  70. ADD A, 0xF000
  71. SET [0x8020 + B], A
  72. SET [0x9000], 0x0
  73. SET C, A
  74. SET PC, textedit_right
  75.  
  76. :textedit_newline
  77. SET [0x9000], 0x0
  78. IFG B, 0x1BF
  79. SET PC, textedit_loop
  80. SET [0x8020+B], C
  81. SHR B, 5
  82. SHL B, 5
  83. ADD B, 31
  84. SET C, [0x8020+B]
  85. SET PC, textedit_right
  86.  
  87. :textedit_backspace
  88. SET [0x9000], 0x0
  89. IFN B, 0x0
  90. SET [0x801F + B], 0x0
  91. SET PC, textedit_left
  92.  
  93. :textedit_down
  94. SET [0x9000], 0x0
  95. IFG B, 0x1BF
  96. SET PC, textedit_loop
  97. IFN [0x8020+B], C
  98. SET [0x8020+B], C
  99. ADD B, 32
  100. SET C, [0x8020 + B]
  101. IFN [0x8020+B], 0x0
  102. SET PC, textedit_not
  103. IFE [0x8020+B], 0x0
  104. SET PC, textedit_equal
  105.  
  106. :textedit_up
  107. SET [0x9000], 0x0
  108. IFG 0x20, B
  109. SET PC, textedit_loop
  110. IFN [0x8020+B],C
  111. SET [0x8020+B],C
  112. SUB B, 32
  113. SET C, [0x8020+B]
  114. IFN [0x8020+B], 0x0
  115. SET PC, textedit_not
  116. IFE [0x8020+B], 0x0
  117. SET PC, textedit_equal
  118.  
  119. :textedit_left
  120. SET [0x9000], 0x0
  121. IFE B, 0
  122. SET PC, textedit_loop
  123. IFN [0x8020+B],C
  124. SET [0x8020+B],C
  125. SUB B, 1
  126. SET C, [0x8020+B]
  127. IFN [0x8020+B], 0x0
  128. SET PC, textedit_not
  129. IFE [0x8020+B], 0x0
  130. SET PC, textedit_equal
  131.  
  132. :textedit_right
  133. SET [0x9000], 0x0
  134. IFE B, 0x1FF
  135. SET PC, textedit_loop
  136. IFN [0x8020+B], C
  137. SET [0x8020+B], C
  138. ADD B, 1
  139. SET C, [0x8020 + B]
  140. IFN [0x8020+B], 0x0
  141. SET PC, textedit_not
  142. IFE [0x8020+B], 0x0
  143. SET PC, textedit_equal
  144.  
  145. :textedit_not
  146. SUB [0x8020+B],0xE100
  147. SET PC, textedit_loop
  148.  
  149. :textedit_equal
  150. SET [0x8020+B],0xF0DF
  151. SET PC, textedit_loop
  152.  
  153. :textedit_exit
  154. SET C, POP
  155. SET B, POP
  156. SET A, POP
  157. ;The registers had to go home ):
  158. :texteditend
  159.  
  160. ;debug
  161. SET PC, texteditend
Advertisement
Add Comment
Please, Sign In to add comment