Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;UNSC Text Edit V: 0.3.2
- ;This line enables program to be run standalone
- ;Usually the OS would set the PC to text edit via its menu or something similar
- SET PC, textedit
- ;this section may not be needed. Purely enables program to run standalone
- ;Replace the JSR command to reach here (ln 19) with the command to run the OS clear function
- :textclear
- SET [0x8000+A], 0
- ADD A, 1
- IFG A, 0x200
- SET PC, POP
- SET PC, textclear
- :textedit
- SET PUSH, A
- SET PUSH, B
- SET PUSH, C
- JSR textclear;replace this line with the relevant OS function to clear screen
- ;Draw header
- SET [0x8000],0x0F55;U
- SET [0x8001],0x0F4E;N
- SET [0x8002],0x0F53;S
- SET [0x8003],0x0F43;C
- SET [0x8004],0x0F20;
- SET [0x8005],0x0F54;T
- SET [0x8006],0x0F65;e
- SET [0x8007],0x0F78;x
- SET [0x8008],0x0F74;t
- SET [0x8009],0x0F20;
- SET [0x800A],0x0F45;E
- SET [0x800B],0x0F64;d
- SET [0x800C],0x0F69;i
- SET [0x800D],0x0F74;t
- SET [0x800E],0x0F20;
- SET [0x800F],0x0F56;V
- SET [0x8010],0x0F3A;:
- SET [0x8011],0x0F20;
- SET [0x8012],0x0F30;0 < Major version, 1 on full V1 OS release
- SET [0x8013],0x0F2E;.
- SET [0x8014],0x0F33;3 < Minor Version
- SET [0x8015],0x0F2E;.
- SET [0x8016],0x0F32;2 < Patch version, increment by 1 for each patch release
- SET [0x8020], 0xF0DF;Sets the blinking cursor for typing with
- SET B, 0 ;DO NOT CHANGE, unless you know how to fix the endless bugs it causes
- :textedit_loop
- SET A, [0x9000]
- IFE A, 0x0
- SET PC, textedit_loop
- IFE A, 0x1B
- SET PC, textedit_exit
- IFE A, 0xA
- SET PC, textedit_newline
- IFE A, 8
- SET PC, textedit_backspace
- IFE A, 1
- SET PC, textedit_left
- IFE A, 2
- SET PC, textedit_right
- IFE A, 3
- SET PC, textedit_up
- IFE A, 4
- SET PC, textedit_down
- ADD A, 0xF000
- SET [0x8020 + B], A
- SET [0x9000], 0x0
- SET C, A
- SET PC, textedit_right
- :textedit_newline
- SET [0x9000], 0x0
- IFG B, 0x1BF
- SET PC, textedit_loop
- SET [0x8020+B], C
- SHR B, 5
- SHL B, 5
- ADD B, 31
- SET C, [0x8020+B]
- SET PC, textedit_right
- :textedit_backspace
- SET [0x9000], 0x0
- IFN B, 0x0
- SET [0x801F + B], 0x0
- SET PC, textedit_left
- :textedit_down
- SET [0x9000], 0x0
- IFG B, 0x1BF
- SET PC, textedit_loop
- IFN [0x8020+B], C
- SET [0x8020+B], C
- ADD B, 32
- SET C, [0x8020 + B]
- IFN [0x8020+B], 0x0
- SET PC, textedit_not
- IFE [0x8020+B], 0x0
- SET PC, textedit_equal
- :textedit_up
- SET [0x9000], 0x0
- IFG 0x20, B
- SET PC, textedit_loop
- IFN [0x8020+B],C
- SET [0x8020+B],C
- SUB B, 32
- SET C, [0x8020+B]
- IFN [0x8020+B], 0x0
- SET PC, textedit_not
- IFE [0x8020+B], 0x0
- SET PC, textedit_equal
- :textedit_left
- SET [0x9000], 0x0
- IFE B, 0
- SET PC, textedit_loop
- IFN [0x8020+B],C
- SET [0x8020+B],C
- SUB B, 1
- SET C, [0x8020+B]
- IFN [0x8020+B], 0x0
- SET PC, textedit_not
- IFE [0x8020+B], 0x0
- SET PC, textedit_equal
- :textedit_right
- SET [0x9000], 0x0
- IFE B, 0x1FF
- SET PC, textedit_loop
- IFN [0x8020+B], C
- SET [0x8020+B], C
- ADD B, 1
- SET C, [0x8020 + B]
- IFN [0x8020+B], 0x0
- SET PC, textedit_not
- IFE [0x8020+B], 0x0
- SET PC, textedit_equal
- :textedit_not
- SUB [0x8020+B],0xE100
- SET PC, textedit_loop
- :textedit_equal
- SET [0x8020+B],0xF0DF
- SET PC, textedit_loop
- :textedit_exit
- SET C, POP
- SET B, POP
- SET A, POP
- ;The registers had to go home ):
- :texteditend
- ;debug
- SET PC, texteditend
Advertisement
Add Comment
Please, Sign In to add comment