summaryrefslogtreecommitdiff
path: root/programs/sub-suite/utils.s
diff options
context:
space:
mode:
Diffstat (limited to 'programs/sub-suite/utils.s')
-rw-r--r--programs/sub-suite/utils.s105
1 files changed, 70 insertions, 35 deletions
diff --git a/programs/sub-suite/utils.s b/programs/sub-suite/utils.s
index 21539eb..3813a05 100644
--- a/programs/sub-suite/utils.s
+++ b/programs/sub-suite/utils.s
@@ -48,12 +48,20 @@ print_lo:
pla ; Get the nibble offset back.
bra @loop ; Keep looping.
@end:
- lda #0 ; Null terminate the string buffer.
- sta strbuf, x ;
+ and #0 ; Reset A.
+ sta strbuf, x ; Null terminate the string buffer.
tax ; Reset X.
- lda.d #strbuf ; Print the string buffer.
- jsr print_str ;
+ lea strbuf ; Print the string buffer.
+; jsr print_str ;
+ jsr print_sfast ; Use the faster, but less robust print string routine.
rts ; End of print_lo.
+;@end:
+; lda #0 ; Null terminate the string buffer.
+; sta strbuf, x ;
+; tax ; Reset X.
+; lea strbuf ; Print the string buffer.
+; jsr print_str ;
+; rts ; End of print_lo.
print_chunk:
@@ -302,49 +310,76 @@ get_ptok:
get_ctrlidx:
- cmp #$7F ; Is this a delete character?
- beq @del ; Yes, so return the same value as backspace.
- sec ; Do a non borrowing subtract.
- sbc #8 ; Subtract 8 from the character, to get the index.
+; phe.q ; Preserve E.
+; cmp #$7F ; Is this a delete character?
+; beq @del ; Yes, so return the same value as backspace.
+; sec ; Do a non borrowing subtract.
+; sbc #8 ; Subtract 8 from the character, to get the index.
+ sub #8 ; Subtract 8 from the character, to get the index.
tax ; Copy the index to X.
and #0 ; Reset A.
- cpx #19 ; Are we less than, or equal to the max size of the table?
- bcc @get_rtval ; Yes, so get the return value from the table.
- beq @get_rtval ;
- rts ; End of get_ctrlidx.
-@get_rtval:
- lda ct_rtb, x ; Get the return value from the table.
- rts ; End of get_ctrlidx.
-@del:
- lda #2 ; Return 2.
+ cpx #19 ; Are we within the range of the table?
+ lea ct_rtb, x ; Get the address of the value to return.
+ lcc (e) ; Read from the table if we're within the range of the table.
+ leq (e) ;
+ cmp #$7F ; Is this a delete character?
+ leq #2 ; Return 2 if this is the delete character.
+; bcc @get_rtval ; Yes, so get the return value from the table.
+; beq @get_rtval ;
+; ple.q ; Restore E.
rts ; End of get_ctrlidx.
+;@get_rtval:
+; lda ct_rtb, x ; Get the return value from the table.
+; rts ; End of get_ctrlidx.
+;@del:
+; lda #2 ; Return 2.
+; rts ; End of get_ctrlidx.
findramend:
- pha.q ; Set the end of RAM pointer to the argument.
+ phx.q ; Preserve X.
and #0 ; Reset A.
- tab ; Reset B.
lda #MAGIC ; Set A to a magic number.
@loop:
- ldx (sp+1) ; Preserve the value.
- sta (sp+1) ; Write the magic number to the current end of RAM.
- cmp (sp+1) ; Is the value in RAM, the same as the magic number we wrote?
+ ldx (e) ; Preserve the value.
+ sta (e) ; Write the magic number to the current end of RAM.
+ cmp (e) ; Is the value in RAM, the same as the magic number we wrote?
bne @moveback ; No, so move back until we find the last writable memory location.
- stx (sp+1) ; Yes, so restore the previous value.
- pha.q ; Preserve the magic number.
- lda.q sp+9 ; Get the end of RAM pointer.
- clc ; Prepare for a non carrying add.
- adc.w #$4000 ; Increment the end of RAM pointer by 16K.
- sta.q sp+9 ; Save the new end of RAM pointer.
- pla.q ; Restore the magic number.
+ stx (e) ; Yes, so restore the previous value.
+ ade.w #$4000 ; Increment the end of RAM pointer by 16K.
bra @loop ; Keep looping.
@moveback:
- dec.q sp+1 ; Decrement the end of RAM pointer.
- ldx (sp+1) ; Preserve the value.
- sta (sp+1) ; Write the magic number to the current end of RAM.
- cmp (sp+1) ; Is the value in RAM, the same as the magic number we wrote?
+ dee ; Decrement the end of RAM pointer.
+ ldx (e) ; Preserve the value.
+ sta (e) ; Write the magic number to the current end of RAM.
+ cmp (e) ; Is the value in RAM, the same as the magic number we wrote?
bne @moveback ; No, so keep looping.
- stx (sp+1) ; Yes, so restore the previous value.
+ stx (e) ; Yes, so restore the previous value.
@end:
- pla.q ; Restore the argument.
+ phe.q ; Return the end of RAM pointer.
+ pla.q ;
+ plx.q ; Restore X.
rts ; End of findramend.
+
+
+print_sfast:
+; inc step ;
+ pea (buffer), y ; Push the address of the cursor's postion in the screen buffer to the stack.
+@loop:
+ lda (e) ; Get the character.
+ beq @end ; We've hit the end of the string, so we're done.
+ cmp #'\n' ; Did we get a newline?
+ beq @nl ; Yes, so move the cursor to the next line.
+ sta (sp+1) ; Print the character to the screen buffer.
+ sta scr ; Print the character to the screen.
+ inc scr_col ; Move the cursor left by one character.
+ ine ; Increment the string pointer.
+ inc.q sp+1 ; Increment the screen buffer pointer.
+ bra @loop ; Keep looping.
+@nl:
+ stz scr_col ; Move the cursor to the start of the line.
+ inc scr_row ; Move the cursor down by one line.
+ bra @loop ; Keep looping.
+@end:
+ ads #8 ; Cleanup the stack frame.
+ rts ; End of print_sfast.