summaryrefslogtreecommitdiff
path: root/programs/sub-suite
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-12-08 10:42:10 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-12-08 10:42:10 -0500
commita769f65a13db5546e427989d85f9646303f4fa32 (patch)
treef3a23002ce67bf022bc2893684cbfb85c5f2df83 /programs/sub-suite
parent83ce1151ee1f06ae6b1c5c1018cc2489494e5ea4 (diff)
- Implemented support for the Orthogonal extension into
both the assembler, and the emulator. I finally figured out how I could get support for the Ortho extension implemented into the old assembler. The only reason for doing this, is to buy me some while I start work on the new assembler, and to help me get an idea for how to do the same in the new assembler.
Diffstat (limited to 'programs/sub-suite')
-rw-r--r--programs/sub-suite/declare.s6
-rw-r--r--programs/sub-suite/lexer.s2
-rw-r--r--programs/sub-suite/libc.s81
-rw-r--r--programs/sub-suite/shift_line.c79
-rw-r--r--programs/sub-suite/subasm.s69
-rw-r--r--programs/sub-suite/subeditor.s158
-rw-r--r--programs/sub-suite/subsuite.s1
-rw-r--r--programs/sub-suite/utils.s105
8 files changed, 301 insertions, 200 deletions
diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s
index 5828fdb..550228d 100644
--- a/programs/sub-suite/declare.s
+++ b/programs/sub-suite/declare.s
@@ -769,7 +769,7 @@ inst:
.byte $81
; Mnemonic Table.
-mne:
+mnem:
.byte "ADC"
.byte "AND"
.byte "ASR"
@@ -852,9 +852,9 @@ cmd_srt:
.word list
.word asm
.word help
- .word ins
+ .word inst
.word run
- .word set
+ .word set_val
; Return table used by get_ctrlidx.
ct_rtb:
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index 9c3cb87..b2850aa 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -434,7 +434,7 @@ ptok_alph:
ldb idx1 ; Get the instruction ID.
cpb #OPNUM ; Have we reached the end of the mnemonic table?
beq @end ; Yes, so we're done.
- lda.w #mne ; No, so get the start of the mnemonic table.
+ lda.w #mnem ; No, so get the start of the mnemonic table.
clc ; Prepare for a non carrying add.
adc.w idx2 ; Offset the pointer, by the length of the previous string.
pha.q ; Preserve the mnemonic string pointer.
diff --git a/programs/sub-suite/libc.s b/programs/sub-suite/libc.s
index 74ad654..ae35146 100644
--- a/programs/sub-suite/libc.s
+++ b/programs/sub-suite/libc.s
@@ -126,53 +126,49 @@ isdigit:
sbc #'0' ; Subtract $30 from the passed character.
and #$FF ; Make sure that we have only one byte.
cmp #10 ; Is the subtracted value, less than 10?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
-@end:
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false.
+; bcs @false ; No, so return false.
+;@true:
+; lda #1 ; Yes, so return true.
+; bra @end ; We are done.
+;@false:
+; lda #0 ; Return false.
+;@end:
rts ; End of isdigit.
isxdigit:
pha ; Preserve the character.
jsr isdigit ; Is this character, a decimal digit?
pla ; Get the character back.
- bne @true ; Yes, so return true.
+ bne @end ; Yes, so return true.
@alpha:
- sec ; No, so prepare for a non carrying subtract.
- ora #$20 ; Convert it to lowercase.
- sbc #'a' ; Subtract $61 from the character.
+ ora #$20 ; No, so convert it to lowercase.
+ sub #'a' ; Subtract $61 from the character.
and #$FF ; Make sure that we have only one byte.
cmp #6 ; Is the subtracted value, less than 6?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false.
+; bcs @false ; No, so return false.
+;@true:
+; lda #1 ; Yes, so return true.
+; bra @end ; We are done.
+;@false:
+; lda #0 ; Return false.
@end:
rts ; End of isxdigit.
isupper:
- sec ; Prepare for a non carrying subtraction.
- sbc #'A' ; Subtract $41 from the passed character.
+ sub #'A' ; Subtract $41 from the passed character.
bra isletter ; Check if it's less than 26.
islower:
- sec ; Prepare for a non carrying subtraction.
- sbc #'a' ; Subtract $61 from the passed character.
+ sub #'a' ; Subtract $61 from the passed character.
isletter:
and #$FF ; Make sure that we have only one byte.
cmp #26 ; Is the subtracted value, less than 26?
- bcs @false ; No, so return false.
-@true:
- lda #1 ; Yes, so return true.
- bra @end ; We are done.
-@false:
- lda #0 ; Return false.
-@end:
+ lcc #1 ; Yes, so return true.
+ lcs #0 ; No, so return false
rts ; End of isletter.
@@ -209,8 +205,7 @@ malloc:
pha.q ; Preserve the size.
and #0 ; Reset A.
tay ; Reset Y.
- pha.q ; Create two more local variables.
- pha.q ;
+ sbs #$10 ; Allocate 2 local variables onto the stack.
lda.q sp+17 ; Get the size.
ora.d sp+21 ; Is the size zero?
beq @end ; Yes, so we're done.
@@ -282,7 +277,7 @@ malloc:
bra @retptr ; Return the pointer.
@sliceblk:
ldy #fblk.size ; Get the size of the current block.
- lda.q (sp+9). y ;
+ lda.q (sp+9), y ;
sec ; Prepare for a non borrowing subtract.
sbc.q sp+17 ; Subtract the current block's size from the passed size.
sta.q (sp+9), y ; Set the current block's size to the subtracted size.
@@ -300,9 +295,7 @@ malloc:
clc ; Prepare for a non carrying add.
adc #ublk ; Return the pointer to the real memory block.
@end:
- ply.q ; Clean up the stack frame.
- ply.q ;
- ply.q ;
+ ads #$18 ; Clean up the stack frame.
ply.q ; Restore Y.
rts ; End of malloc.
@@ -320,9 +313,7 @@ free:
pha.q ; Push the pointer argument to the stack.
and #0 ; Reset A.
tay ; Reset Y.
- pha.q ; Add 3 more local variables.
- pha.q ;
- pha.q ;
+ sbs #$18 ; Allocate 3 local variables onto the stack.
lda.q sp+25 ; Get the passed pointer.
ora.d sp+29 ; Is the passed pointer NULL?
bne @getrealblk ; No, so get the real block.
@@ -373,10 +364,7 @@ free:
ldy #fblk.next ; Delete the next block.
sta.q (sp+25), y;
@end:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
- pla.q ;
+ ads #$20 ; Clean up the stack frame.
ply.q ; Restore Y.
plb.q ; Restore B.
pla.q ; Restore A.
@@ -424,7 +412,7 @@ free:
cmp.q sp+9 ; Is the right pointer NULL?
bne @normerge ; No, so don't merge the right block.
@rmerge:
- ldy #fblk.size : Get the size of the right pointer.
+ ldy #fblk.size ; Get the size of the right pointer.
lda.q sp+17 ; Get the size of the current block.
clc ; Prepare for a non carrying add.
adc.q (sp+9), y ; Add the size of the current block, with the size of the right pointer.
@@ -500,10 +488,7 @@ free:
ldy #fblk.prev ; Set the previous block, to the left pointer.
sta.q (sp+25), y;
@end2:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
- pla.q ;
+ ads #$20 ; Clean up the stack frame.
ply.q ; Restore Y.
plb.q ; Restore B.
pla.q ; Restore A.
@@ -534,8 +519,6 @@ memcpy:
beq @end ; The size is zero, so we're done.
bra @loop ; Keep looping.
@end:
- pla.q ; Clean up the stack frame.
- pla.q ;
- pla.q ;
+ ads #$18 ; Clean up the stack frame.
pla.q ; Restore the return value.
rts ; End of memcpy.
diff --git a/programs/sub-suite/shift_line.c b/programs/sub-suite/shift_line.c
new file mode 100644
index 0000000..255d21b
--- /dev/null
+++ b/programs/sub-suite/shift_line.c
@@ -0,0 +1,79 @@
+#include <stdint.h>
+
+const uint8_t bits[8] = {
+ 0x80,
+ 0x40,
+ 0x20,
+ 0x10,
+ 0x08,
+ 0x04,
+ 0x02,
+ 0x01
+};
+
+int maxcol = 80;
+int scr_str = 0;
+int scr_row = 0;
+int scr_col = 0;
+uint8_t bitabl[16];
+
+uint8_t bitpos(unsigned int row, uint8_t *mask) {
+ uint8_t bit = row & 7;
+ *mask = bits[bit];
+ return row >> 3;
+
+}
+
+void setbit(unsigned int row) {
+ uint8_t mask;
+ uint8_t byte = bitpos(row, &mask);
+ bitabl[byte] |= mask;
+}
+
+void clrbit(unsigned int row) {
+ uint8_t mask;
+ uint8_t byte = bitpos(row, &mask);
+ bitabl[byte] &= ~mask;
+}
+
+int find_end(char *str, int start) {
+ int i;
+ for (i = start; str[i]; i++);
+ return i;
+}
+
+void shift_line(char *str, int cursor, int left) {
+ /*int cursor = ((scr_row+scr_str)*maxcol)+scr_col;*/
+ int end = find_end(str, cursor);
+ if (left) {
+ int i = end-1;
+ int j = end;
+ for (; i > cursor; i--, j--) {
+ if (i < 0) {
+ i = 0;
+ str[i] = 0;
+ break;
+ }
+ str[j] = str[i];
+ str[i] = 0;
+
+ }
+ /*str[i+1] = (!str[i+1]) ? ' ' : str[i+1];*/
+ end = find_end(str, i+2);
+ /*str[i+1] = (str[i+1] == ' ') ? 0 : str[i+1];*/
+ if ((end/maxcol) > scr_row) {
+ setbit(end/maxcol);
+ }
+ } else {
+ int i = cursor;
+ int j = cursor-1;
+ for (; str[i]; i++, j++) {
+ str[j] = str[i];
+ str[i] = 0;
+ }
+ end = find_end(str, i);
+ if ((end % maxcol) == 0 && (end/maxcol) > scr_row) {
+ clrbit(end/maxcol);
+ }
+ }
+}
diff --git a/programs/sub-suite/subasm.s b/programs/sub-suite/subasm.s
index 0a3ee80..80aaa47 100644
--- a/programs/sub-suite/subasm.s
+++ b/programs/sub-suite/subasm.s
@@ -16,21 +16,17 @@ subasm:
jsr lex ; No, so start lexing this line.
bra @end ; We are done.
@cmd:
- ldb #1 ; Set the second pointer
- lda.d #cmd_srt ; to the command subroutine table.
- jsr set_ptr ;
- deb ; Reset B.
- tba ; Reset A.
lda regf ; Get the command ID.
cmp #8 ; Is the command ID greater than the command count?
bcs @end ; Yes, so we're done.
lsl #1 ; No, so multiply the command ID by two.
- tay ; Set the index to the offset that we just calculated.
- lda.w (ptr2), y ; Get the command subroutine, from the command subroutine table.
- ldb #2 ; Save it in the third pointer.
- jsr set_ptr ;
- ldb #0 ; Reset B.
- jsr (ptr3) ; Run the command's subroutine.
+ phx.q ; Preserve X.
+ tax ; Set the index to the offset that we just calculated.
+ lea.w (cmd_srt, x); Get the pointer, from the command subroutine table.
+ plx.q ; Restore X.
+ and #0 ; Reset A.
+ tab ; Reset B.
+ jsr (e) ; Run the command's subroutine.
@end:
and #0 ; Reset A.
jsr update_ptr ; Get the screen buffer index.
@@ -39,12 +35,14 @@ subasm:
rts ; End of subasm.
chk_shcmd:
- tba ; Reset A.
- inb ; Set the second pointer
- lda.w #sh_cmds ; to the shortend command table.
- jsr set_ptr ;
- deb ; Reset B.
- tba ; Reset A.
+ and #0 ; Reset A.
+ tab ; Reset B.
+; inb ; Set the second pointer
+; lda.w #sh_cmds ; to the shortend command table.
+; jsr set_ptr ;
+; deb ; Reset B.
+; tba ; Reset A.
+ lea sh_cmds ; Get the address of the short command table.
phy.w ; Preserve the screen buffer position.
txy ; Set our index to zero.
lda (ptr), y ; Is there nothing in the command buffer?
@@ -53,27 +51,31 @@ chk_shcmd:
beq @false ; Yes, so return that we failed.
jsr tolower ; No, so convert it to lowercase.
@loop:
- ldb (ptr2), y ; Are we at the end of the table?
+; ldb (ptr2), y ; Are we at the end of the table?
+ ldb (e) ; Are we at the end of the table?
beq @false ; Yes, so return that we failed.
cmp b ; No, so did the character match?
beq @found ; Yes, so check if there are any arguments.
- iny ; No, so check the next command.
+ ine ; No, so check the next command.
+ iny ;
bra @loop ; Keep looping.
@found:
sty regf ; Save the command ID.
- ldy #1 ; Check the next character in the command buffer.
- lda (ptr), y ; Is this the end of the buffer?
- beq @true ; Yes, so return that we succeded.
+ lea (ptr) ; Get the address of the next character.
+ ine ;
+; ldy #1 ; Check the next character in the command buffer.
+; lda (ptr), y ; Is this the end of the buffer?
+ lda (e) ; Is this the end of the buffer?
+ beq @true ; Yes, so return true.
cmp #' ' ; No, but is this a space?
- beq @true ; Yes, so return that we succeded.
- bra @false ; No, so return that we failed.
-@true:
- lda #1 ; Return true.
- bra @end ; We are done.
+ beq @true ; Yes, so return true.
@false:
ldb #0 ; Reset B.
tba ; Return false.
tax ; Reset X.
+ bra @end ; We are done.
+@true:
+ lda #1 ; Return true.
@end:
ply.w ; Get back the screen buffer position.
rts ; End of chk_shcmd.
@@ -130,8 +132,9 @@ viewmem:
jsr print_char ;
jsr print_hi ; Place the address in the string buffer.
jsr print_chunk ; Place the next 16 bytes in the string buffer.
- lda.d #strbuf ; Print the string buffer.
- jsr print_str ;
+ lea strbuf ; Print the string buffer.
+; jsr print_str ;
+ jsr print_sfast ;
inc idx1 ; Increment the chunk count.
ldb idx1 ; Get the chunk count.
cpb #$10 ; Did we print 16 chunks?
@@ -161,15 +164,15 @@ help:
nop ;
@end:
rts ; End of help.
-ins:
+inst:
nop ;
@end:
- rts ; End of ins.
+ rts ; End of inst.
run:
nop ;
@end:
rts ; End of run.
-set:
+set_val:
nop ;
@end:
- rts ; End of set.
+ rts ; End of set_val.
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 ;
diff --git a/programs/sub-suite/subsuite.s b/programs/sub-suite/subsuite.s
index d28b4f2..7b31c31 100644
--- a/programs/sub-suite/subsuite.s
+++ b/programs/sub-suite/subsuite.s
@@ -19,5 +19,6 @@ a
;l a
;.org reset
;v
+;f "subsuite.bin" $8000
;q
d
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.