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.s99
1 files changed, 80 insertions, 19 deletions
diff --git a/programs/sub-suite/utils.s b/programs/sub-suite/utils.s
index 3ab948b..7e7469c 100644
--- a/programs/sub-suite/utils.s
+++ b/programs/sub-suite/utils.s
@@ -3,8 +3,9 @@
print_hi:
and #0 ; Reset A.
sta idx3 ; Clear the string index.
+ tax ; Reset X.
lda #'$' ; Print the hex delimiter.
- jsr charcpy ;
+ sta strbuf, x ; Save it in the string buffer.
lda.q idx0 ; Get the masked address.
ldx #$10 ; Set digit count to 16.
jsr print_hex ; Print the address.
@@ -14,23 +15,27 @@ print_hi:
sta.q strbuf+9 ; Save it in the string buffer.
ldx #$11 ; Add 16 to the index.
stx idx3 ;
- lda #':' ; Print a colon.
- jsr charcpy ;
- lda # ' ' ; Print a space.
- jsr charcpy ;
+ lda.w #': ' ; Print a space.
+ sta.w strbuf, x ; Save it in the string buffer.
+ inc idx3 ; Increment the string index twice.
+ inc idx3 ;
+ and #0 ; Reset A.
rts ; End of print_hi.
+
print_lo:
- lda #0 ; Reset A.
+ and #0 ; Reset A.
sta idx3 ; Clear the string index.
@loop:
ldx #2 ; Set digit count to 2.
pha ; Preserve the nibble offset.
jsr print_hex ; Print the low nibble offset.
lda.w (ptr3) ; Get the two digits.
- jsr charcpy ; Copy the first digit.
- lsr #8 ; Copy the next digit.
- jsr charcpy ;
+ ldx idx3 ; Get the string index.
+ sta.w strbuf, x ; Save it in the string buffer.
+ inc idx3 ; Increment the string index twice.
+ inc idx3 ;
+ ldx idx3 ; Get the string index.
pla ; Get the nibble offset back.
inc ; Increment the offset.
cmp #$10 ; Are we at the last offset?
@@ -38,11 +43,11 @@ print_lo:
@loop1:
pha ; No, so preserve the nibble offset.
lda #' ' ; Add a space to the string buffer.
- jsr charcpy ;
+ sta strbuf, x ; Save it in the string buffer.
+ inc idx3 ; Increment the string index.
pla ; Get the nibble offset back.
bra @loop ; Keep looping.
@end:
- inx ; Increment the index by one.
lda #0 ; Null terminate the string buffer.
sta strbuf, x ;
tax ; Reset X.
@@ -50,6 +55,7 @@ print_lo:
jsr print_str ;
rts ; End of print_lo.
+
print_chunk:
ldx #0 ; Reset X.
phy.w ; Preserve the screen buffer index.
@@ -60,14 +66,17 @@ print_chunk:
lda (idx0), y ; Get the byte at that address.
jsr print_hex ; Print the byte.
lda.w (ptr3) ; Get the two digits.
- jsr charcpy ; Copy the first digit.
- lsr #8 ; Copy the next digit.
- jsr charcpy ;
+ ldx idx3 ; Get the string index.
+ sta.w strbuf, x ; Save it in the string buffer.
+ inc idx3 ; Increment the string index twice.
+ inc idx3 ;
+ ldx idx3 ; Get the string index.
iny ; Increment the byte index.
cpy #$10 ; Have we read 16 bytes?
beq @end ; Yes, so we're done.
lda #' ' ; No, so add a soace to the string buffer.
- jsr charcpy ;
+ sta strbuf, x ; Save it in the string buffer.
+ inc idx3 ; Increment the string index.
bra @loop ; Keep looping.
@end:
ply.w ; Get the screen buffer index back.
@@ -202,7 +211,6 @@ isdelm2:
isdelm:
ldx #0 ; Reset X.
- stx rega ; Reset the shift value.
@loop:
ldb dtab, x ; Get the compare value.
beq @other ; We hit the end of the table, so check for the others.
@@ -222,13 +230,47 @@ isdelm:
lda #0 ; Return 0.
rts ; End of isdelm.
@rshft:
- stx rega ; Save the shift value.
- ldx #0 ; Reset X.
lda #1 ; Set up the bitshift.
- lsl rega ; Return 1 << X.
+ phx ; Push the shift value to stack.
+ lsl sp+1 ; Return 1 << X.
+ plx ; Pull the shift value off the stack.
+ ldx #0 ; Reset X.
rts ; End of isdelm.
+isesc:
+ ldy.w idx0 ; Get the string index.
+ lda (ptr), y ; Get the current character.
+ cmp #'\\' ; Is it a backslash?
+ bne @false ; No, so return false.
+@dec:
+ dey ; Decrement the string index.
+ lda (ptr), y ; Get the current character.
+ iny ; Set the string index back.
+ cmp #'\\' ; Is it a backslash?
+ beq @false ; Yes, so return false.
+ lda #1 ; No, so return true.
+ rts ; End of isesc.
+@false:
+ and #0 ; Return false.
+ rts ; End of isesc.
+
+
+is_altok:
+ sec ; Do a non borrowing subtract.
+ sbc #12 ; Subtract 12 from the token.
+ and #$FF ; Make sure the value is 8 bits.
+ cmp #4 ; Is the token in between PTOK_B, and PTOK_P?
+ bcc @r1 ; Yes, so return 1.
+ beq @r1 ;
+@r0:
+ lda #0 ; Return 0.
+ rts ; End of is_altok.
+@r1:
+ lda #1 ; Return 1.
+ rts ; End of is_altok.
+
+
get_ptok:
ldx #0 ; Reset X.
jsr tolower ; Conver the character to lowercase.
@@ -257,3 +299,22 @@ get_ptok:
@ralph:
lda #PTOK_ALPH ; Return PTOK_ALPH.
rts ; End of 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.
+ 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.
+ rts ; End of get_ctrlidx.