summaryrefslogtreecommitdiff
path: root/programs/sub-suite/subeditor.s
diff options
context:
space:
mode:
Diffstat (limited to 'programs/sub-suite/subeditor.s')
-rw-r--r--programs/sub-suite/subeditor.s158
1 files changed, 79 insertions, 79 deletions
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index bec3f41..387b5db 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -6,18 +6,18 @@
.org $8000
reset:
cps ; Reset the processor status register.
- ldx.d #$2FFFF ; Reset the stack pointer.
- txs ;
+ lds.d #$2FFFF ; Reset the stack pointer.
+ lea 0 ; Reset E.
ldy #0 ; Reset Y.
tyx ; Reset X.
jsr init_heap ; Initialize the heap.
tax ; Set the stack pointer to the end of RAM.
txs ;
- sec ; Prepare for a non borrowing subtract.
- sbc.d #STKSIZE ; Subtract the stack size, from the end of RAM.
+ sub.d #STKSIZE ; Subtract the stack size, from the end of RAM.
sta.q heapend ; Save the end of the heap.
and #0 ; Reset A.
tax ; Reset X.
+ clc ; Reset the carry flag, just in case.
jsr init_tables ; Initialize the main tables.
; jsr test_free ;
jsr clr_scr ; Clear the screen.
@@ -26,14 +26,9 @@ reset:
init_heap:
- and #0 ; Reset A.
- lda.d #HEAPORG ; Get the heap's starting point.
- sta.q heapptr ;
- phb.q ; Preserve the value in B.
- phx.q ; Preserve the value in X.
+ lea HEAPORG ; Get the heap's starting point.
+ ste.q heapptr ;
jsr findramend ; Find the end of the heap.
- plb.q ; Restore the value in B.
- plx.q ; Restore the value in X.
rts ; End of init_heap.
@@ -79,50 +74,32 @@ init_tables:
clr_arr:
- phb ; Preserve whatever was in B.
- ldb #0 ; Clear B.
- jsr set_ptr ; Set the first pointer to the parameter.
- adc #8 ; Set the second pointer to the parameter, plus eight.
- inb ; Tell set_ptr to set the second pointer.
- jsr set_ptr ;
- deb ; Set B back to zero.
- tba ;
-@loop:
- cpy.w scr_ptr ; Did we clear all of the array?
- bcs @end ; Yes, so we're done.
- sta.q (ptr), y ; No, so clear eight bytes.
- sta.q (ptr2), y ; Clear eight more bytes.
- tya ; Copy the array index.
- adc #$10 ; Increment the index by 16.
- tay ; Update the index.
- tba ; Reset the Accumulator.
- sta.q (ptr), y ; Do this one more time, to clear 32 bytes.
- sta.q (ptr2), y ;
- tya ;
- adc #$10 ;
- tay ;
- tba ;
- bra @loop ; Keep looping.
+ stz.q (e) ; Clear eight bytes.
+ ade #8 ; Increment the pointer by 8.
+ stz.q (e) ; Clear eight bytes.
+ ade #8 ; Increment the pointer by 8.
+ sub #$10 ; Subtract 16 from the size.
+ bcc @end ; We've reached the end of the array, so we're done.
+ beq @end ;
+ bra clr_arr ; Keep looping.
@end:
- ldy.w zero ; Set the index back to zero.
- plb ; Get whatever was in the B register, back.
rts ; End of clr_arr.
pnt_strt:
- lda.w #ed_name ; Print the name of the editor.
+ lea ed_name ; Print the name of the editor.
jsr print_str ;
- lda.w #ver_str ; Print the version text.
+ lea ver_str ; Print the version text.
jsr print_str ;
- lda.w #ed_ver ; Print the version number.
+ lea ed_ver ; Print the version number.
jsr print_str ;
- lda.w #ed_sver ; Print the sub version number.
+ lea ed_sver ; Print the sub version number.
jsr print_str ;
lda #'\n' ; Print a newline.
jsr print_char ;
- lda.w #made ; Print the "Created by" text.
+ lea made ; Print the "Created by" text.
jsr print_str ;
- lda.w #author ; Print the name of the author.
+ lea author ; Print the name of the author.
jsr print_str ;
lda #'\n' ; Print a newline.
jsr print_char ;
@@ -133,8 +110,7 @@ clr_cmd:
and #0 ; Reset A.
tay ; Reset Y.
lda.w #CMDSIZE ; Set the clear count to CMDSIZE.
- sta.w scr_ptr ;
- lda.q cmd_buf ; Set the array to be cleared to the command buffer.
+ lea (cmd_buf) ; Set the array to be cleared to the command buffer.
jsr clr_arr ; Clear the command buffer.
rts ; End of clr_cmd.
@@ -173,37 +149,59 @@ getchar:
print_str:
- ldx #0 ; Reset X.
- sta.q end ; Save the parameter.
-@reset:
- lda.q end ; Get the parameter.
- ldb #0 ; Clear the B register.
- jsr set_ptr ; Set the first pointer to the parameter.
- tba ; Clear the Accumulator.
+ and #0 ; Reset A.
+ tba ; Reset B.
@loop:
ldb #1 ; Enable replace mode.
stb regb ;
- lda.q ptr ; Get the first pointer.
- cmp.q end ; Did the pointer change?
- bne @reset ; Yes, so set it back.
and #0 ; No, reset the accumulator.
- txy ; Copy the string index into Y.
- ldb (ptr), y ; Are we at the end of the string?
+ ldb (e) ; Are we at the end of the string?
beq @end ; Yes, so we're done.
jsr update_ptr ; No, so get the screen buffer index.
tay ; Save it in Y.
tba ; Get the character back.
- inx ; Increment the string index.
- phx ; Preserve the string index.
+ ine ; Increment the string pointer.
jsr print_char ; Print the character.
- plx ; Get the string index back.
bra @loop ; Keep looping.
@end:
- ldb #0 ; Enable insert mode.
- stb regb ;
- tba ; Reset A.
+ stz regb ; Enable insert mode.
+ and #0 ; Reset A.
+ tab ; Reset B.
rts ; End of print_str.
+
+;print_str:
+; ldx #0 ; Reset X.
+; sta.q end ; Save the parameter.
+;@reset:
+; lda.q end ; Get the parameter.
+; ldb #0 ; Clear the B register.
+; jsr set_ptr ; Set the first pointer to the parameter.
+; tba ; Clear the Accumulator.
+;@loop:
+; ldb #1 ; Enable replace mode.
+; stb regb ;
+; lda.q ptr ; Get the first pointer.
+; cmp.q end ; Did the pointer change?
+; bne @reset ; Yes, so set it back.
+; and #0 ; No, reset the accumulator.
+; txy ; Copy the string index into Y.
+; ldb (ptr), y ; Are we at the end of the string?
+; beq @end ; Yes, so we're done.
+; jsr update_ptr ; No, so get the screen buffer index.
+; tay ; Save it in Y.
+; tba ; Get the character back.
+; inx ; Increment the string index.
+; phx ; Preserve the string index.
+; jsr print_char ; Print the character.
+; plx ; Get the string index back.
+; bra @loop ; Keep looping.
+;@end:
+; stz regb ; Enable insert mode.
+; and #0 ; Reset A.
+; tab ; Reset B.
+; rts ; End of print_str.
+
getbit:
clc ; Clear the carry flag.
lda scr_str ; Has the screen been scrolled?
@@ -432,21 +430,27 @@ findend:
print_char:
+ phe.q ; Preserve E.
sta rega ; Preserve the character.
ldb #2 ; Make sure that set_ptr sets the third pointer.
lda.q buffer ; Set the third pointer to the start of the screen buffer.
jsr set_ptr ;
deb ; Set B to one.
tba ; Reset A.
+; inc step ;
lda rega ; Get the character back.
jsr get_ctrlidx ; Get the control code jump table index.
lsl #1 ; Multiply the return value by two, to get the index.
tax ;
- lda.w ct_jtb, x ; Get the address of the control code handler.
- jsr set_ptr ; Set the second pointer to the control code handler.
+ lea.w (ct_jtb, x); Get the address of the control code handler.
+; pha.q ;
+; ple.q ;
+; jsr set_ptr ; Set the second pointer to the control code handler.
deb ; Reset B.
tba ; Reset A.
- jmp (ptr2) ; Jump to the handler for that control code.
+ jsr (e) ; Jump to the handler for that control code.
+ ple.q ; Restore E.
+ rts
printc:
lda #0 ; start trying to print a character.
sta regd ;
@@ -567,24 +571,19 @@ nl:
clr_scr:
lda #maxrow ;
sta scr_end ;
- lda #0 ;
- sta scr_str ;
+ stz scr_str ;
tay ;
lda.w #LWSIZE ; Set the clear count to LWSIZE.
- sta.w scr_ptr ;
- lda.q bitabl ; Set the array to be cleared to the linewrap table.
+ lea (bitabl) ; Set the array to be cleared to the linewrap table.
jsr clr_arr ; Clear the linewrap table.
lda.w #SCRSIZE ; Set the clear count to SCRSIZE.
- sta.w scr_ptr ;
- lda.q buffer ; Set the array to be cleared to the screen buffer.
+ lea (buffer) ; Set the array to be cleared to the screen buffer.
jsr clr_arr ; Clear the screen buffer.
-; tay ;
; lda.w #CMDSIZE ; Set the clear count to CMDSIZE.
-; sta.w scr_ptr ;
-; lda.d #cmd_buf ; Set the array to be cleared to the command buffer.
+; lea (cmd_buf) ; Set the array to be cleared to the command buffer.
; jsr clr_arr ; Clear the screen buffer.
- sta scr_col ;
- sta scr_row ;
+ stz scr_col ;
+ stz scr_row ;
jsr update_pos ;
lda #$C ;
sta scr ;
@@ -694,7 +693,7 @@ shftln:
beq @dec_loop ; Yes, so shift, and decrement.
ldb #0 ; Clear the B register.
bra @inc_loop ; No, so shift, and increment.
-@neg:
+@minus:
ldy.w zero ; Set the source poition to 0.
stb (ptr3), y ; Clear the character that is in the source.
bra @end ; We are done.
@@ -712,7 +711,7 @@ shftln:
sta (ptr3), y ; Place the character from the source position, to the destination position.
ply.w ; Set our position back to the source.
stb (ptr3), y ; Clear the character that is in the source.
- bng @neg ; The source underflowed, so set it back to zero,
+ bng @minus ; The source underflowed, so set it back to zero,
dey ; Decrement the source position.
dex ; Decrement the destination position.
bra @inc_loop ; Keep looping.
@@ -767,6 +766,7 @@ shftln:
@end5:
rts ; End of shftln.
+
esc:
lda status ; Get the next character.
lda kbd ;