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.s405
1 files changed, 203 insertions, 202 deletions
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index 1768d62..cc18b4c 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -140,10 +140,12 @@ reset:
lda.d #buffer ; Set the array to be cleared to the screen buffer.
jsr clr_arr ; Clear the screen buffer.
jsr pnt_strt ; Print the starting message.
- jmp start ; Goto the start of the main program.
+ lda #$C ; Clear the screen.
+ sta scr ;
+ bra start ; Goto the start of the main program.
clr_arr:
- phb #1 ; Preserve whatever was in B.
+ 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.
@@ -166,10 +168,10 @@ clr_arr:
adc #$10 ;
tay ;
tba ;
- jmp @loop ; Keep looping.
+ bra @loop ; Keep looping.
@end:
ldy.w zero ; Set the index back to zero.
- plb #1 ; Get whatever was in the B register, back.
+ plb ; Get whatever was in the B register, back.
rts ; End of clr_arr.
pnt_strt:
@@ -195,16 +197,16 @@ start:
lda #0 ; TODO: Update this for the Super VIA.
sta status ; Clear the control register of the I/O adapter.
tax ; Reset X.
- phy #2 ; Save the cursor index for later.
+ phy.w ; Save the cursor index for later.
tay ; Reset the cursor index.
lda.w #$3FF ; Set the clear count to $3FF.
sta.w scr_ptr ;
lda.d #cmd_buf ; Set the array to be cleared to the command buffer.
jsr clr_arr ; Clear the command buffer.
- ply #2 ; Get back the cursor index.
+ ply.w ; Get back the cursor index.
and #0 ; Reset the Accumulator.
sta end ;
- jmp read ; Start reading the keyboard.
+ bra read ; Start reading the keyboard.
read:
lda #0 ; Reset the Accumulator.
@@ -214,7 +216,14 @@ read:
beq read ; No, so try again.
jsr getchar ; Yes, and was it a newline?
beq parse ; Yes, so start parsing the line.
- jmp read ; No, so keep looping.
+ bra read ; No, so keep looping.
+
+parse:
+ lda #0 ;
+ tax ;
+ jsr subasm ;
+ bra start ;
+
print_str:
ldx #0 ; Reset X.
@@ -231,14 +240,14 @@ print_str:
cmp.q end ; Did the pointer change?
bne @reset ; Yes, so set it back.
and #0 ; No, reset the accumulator.
- phy #2 ; Save the cursor index.
+ phy.w ; Save the cursor index.
txy ; Copy the string index into Y.
lda (ptr), y ; Are we at the end of the string?
- ply #2 ; Get the cursor index back.
+ ply.w ; Get the cursor index back.
beq @end ; Yes, so we're done.
inx ; No, so increment the string index.
jsr print_char ; Print the character.
- jmp @loop ; Keep looping.
+ bra @loop ; Keep looping.
@end:
ldb #0 ; Enable insert mode.
stb b ;
@@ -249,81 +258,81 @@ getbit:
lda scr_str ; Has the screen been scrolled?
bne getbt0 ; Yes, so add the screen offset to the current line number.
ldx scr_row ; No, so just use the current line number.
- jmp getbt1 ; Start getting the bit.
+ bra getbt1 ; Start getting the bit.
getbt0:
lda scr_row ; Get the current line number.
adc scr_str ; Add the screen offset to it.
tax ; Use it as the wrap index.
getbt1:
- pha #1 ; Save the parameter.
+ pha ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
jsr set_ptr ;
lsr #$10 ; Clear the Accumulator.
- pla #1 ; Get the return byte back.
+ pla ; Get the return byte back.
jsr bitpos ; Get the bit, and byte position.
- phy #2 ; Save the screen index.
+ phy.w ; Save the screen index.
txy ; Get the byte position.
ldb (ptr2), y ; Get one byte of the wrap table.
- ply #2 ; Get the screen index back.
+ ply.w ; Get the screen index back.
aba ; Mask out the bit of the current line number.
cmp #1 ; Set the carry flag, if true.
- jmp bitout ; We are done.
+ bra bitout ; We are done.
clrbit:
- pha #1 ; Save the parameter.
+ pha ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
jsr set_ptr ;
and #0 ; Clear the Accumulator.
- pla #1 ; Get the return byte back.
+ pla ; Get the return byte back.
jsr bitpos ; Get the bit, and byte position.
xor #$FF ; Invert the bitmask.
- phy #2 ; Save the screen index.
+ phy.w ; Save the screen index.
txy ; Get the byte position.
ldb (ptr2), y ; Get one byte of the wrap table.
aba ; Clear the bit of the current line number.
bitsav:
sta (ptr2), y ; Update the wrap table.
- ply #2 ; Get the screen index back.
+ ply.w ; Get the screen index back.
bitout:
ldx bitmask ; Return the bitmask.
rts ; We are done.
setbit:
- pha #1 ; Save the parameter.
+ pha ; Save the parameter.
ldb #1 ; Make sure that set_ptr sets the second pointer.
lda.d #bitabl ; Set the second pointer to the linewrap table.
jsr set_ptr ;
and #0 ; Clear the Accumulator.
- pla #1 ; Get the return byte back.
+ pla ; Get the return byte back.
jsr bitpos ; Get the bit, and byte position.
- phy #2 ; Save the screen index.
+ phy.w ; Save the screen index.
txy ; Get the byte position.
ldb (ptr2), y ; Get one byte of the wrap table.
oab ; Set the bit of the current line number.
- jmp bitsav ; Save the bit.
+ bra bitsav ; Save the bit.
bitpos:
- pha #1 ; Save the parameter.
+ pha ; Save the parameter.
ldb #0 ; Make sure that set_ptr sets the first pointer.
lda.w #bits ; Set the first pointer to the bitmask table.
jsr set_ptr ;
and #0 ; Clear the Accumulator.
- pla #1 ; Get the parameter back.
+ pla ; Get the parameter back.
stx bitmask ; Make the line number the bitmask.
txa ; Copy it to the Accumulator.
and #7 ; Get the bit position.
- phy #2 ; Save the cursor index.
+ phy.w ; Save the cursor index.
tay ; Use the bit position as the index.
tax ; Copy it into X.
lda (ptr), y ; Get the bitmask.
- ply #2 ; Get back the cursor index.
- pha #1 ; Save the bitmask.
+ ply.w ; Get back the cursor index.
+ pha ; Save the bitmask.
lda bitmask ; Get the line number.
lsr #3 ; Get the byte position.
tax ; Copy it into X.
- pla #1 ; Get back the bitmask.
+ pla ; Get back the bitmask.
rts ; End of bitpos.
getchar:
@@ -331,14 +340,14 @@ getchar:
ldb #0 ; Reset the B register.
stb e ; Set the temporary row position to zero, in case we get a newline.
stb b ; Enable insert mode.
- pha #1 ; Save the character.
- phy #2 ; Save the cursor index.
+ pha ; Save the character.
+ phy.w ; Save the cursor index.
cmp #'\n' ; Was the character that was typed, a newline?
bne @print ; No, so just print the character.
jsr cmd_cpy ; Yes, so start copying the line to the command buffer.
@print:
- ply #2 ; Get back the cursor index.
- pla #1 ; Get back the character.
+ ply.w ; Get back the cursor index.
+ pla ; Get back the character.
ldb e ; Is the temporary row position non zero?
bne @row ; Yes, so reset the row positon.
@print1:
@@ -346,21 +355,21 @@ getchar:
lda a ; Get the return value.
cmp #'\n' ; Is the return value, a newline?
beq @true ; Yes, so return true.
- jmp @false ; No, so return false.
+ bra @false ; No, so return false.
@row:
ldb e ; Get the temporary row position.
cpb #maxrow ; Is temporary row position, at, or above the bottom of the screen?
beq @row2 ; Yes, so leave it as is.
bcs @row1 ; No, so set it to the bottom of the screen.
- jmp @row2 ; Yes, so leave it as is.
+ bra @row2 ; Yes, so leave it as is.
@row1:
ldb #maxrow ; Set the row position to the bottom of the screen.
@row2:
stb scr_row ; Set the row position.
- jmp @print1 ; Print the character.
+ bra @print1 ; Print the character.
@true:
lda #0 ; Return true.
- jmp @end ; We are done.
+ bra @end ; We are done.
@false:
lda #1 ; Return false.
@end:
@@ -399,11 +408,11 @@ cmd_cpy:
ldb #0 ; Reset the B register.
lda.q (ptr), y ; Get eight bytes from the current line.
@loop1:
- phy #2 ; Save the screen index.
+ phy.w ; Save the screen index.
txy ; Get the command buffer index.
sta (ptr2), y ; Copy one byte from the screen buffer, to the command buffer.
inx ; Increment the command buffer index.
- ply #2 ; Get back the screen index.
+ ply.w ; Get back the screen index.
cpx.w #$3FF ; Are we at the end of the command buffer?
bcs @end ; Yes, so we're done.
iny ; No, so increment the screen index.
@@ -417,13 +426,13 @@ cmd_cpy:
ldb g ; Get back the byte count.
cpb #7 ; Did we shift in eight bytes?
beq @loop ; Yes, so get eight more bytes.
- jmp @loop1 ; No, so keep shifting in more bytes.
+ bra @loop1 ; No, so keep shifting in more bytes.
@end:
ldb #0 ; Reset B.
- phy #2 ; Save the screen index.
+ phy.w ; Save the screen index.
txy ; Get the command buffer index.
stb (ptr2), y ; Terminate the command buffer.
- ply #2 ; Get back the screen index.
+ ply.w ; Get back the screen index.
@end1:
tab ; The B register is zero, so clear the Accumulator.
rts ; End of cmd_cpy.
@@ -432,9 +441,9 @@ cmd_cpy:
findst:
lda #0 ; Reset A.
@loop:
- pha #1 ; Save the current line number.
+ pha ; Save the current line number.
jsr getbit ; Is this the start of the line?
- pla #1 ; Get the current line number back.
+ pla ; Get the current line number back.
bcc @end ; Yes, so we're done.
inc ; No, so check the next physical line.
dec scr_row ; Are we at the top of the screen?
@@ -447,21 +456,21 @@ findst:
fndend:
- phb #1 ; Save the contents of the B register.
+ phb ; Save the contents of the B register.
ldb #0 ; Make sure that set_ptr sets the first pointer.
lda.d #buffer ; Set the first pointer to the start of the screen buffer.
jsr set_ptr ;
tba ; Set the Accumulator to zero.
- plb #1 ; Restore the contents of the B register.
- phy #2 ;
+ plb ; Restore the contents of the B register.
+ phy.w ;
@loop:
lda (ptr), y ; Are we at the end of the string?
beq @end ; Yes, so we're done.
iny ; No, so increment the cursor index.
- jmp @loop ; Keep looping.
+ bra @loop ; Keep looping.
@end:
sty.w scr_ptr3 ;
- ply #2 ;
+ ply.w ;
rts ; End of fndend.
findend:
@@ -470,11 +479,6 @@ findend:
div #maxcol+1 ;
rts ;
-parse:
- lda #0 ;
- tax ;
- jsr subasm ;
- jmp start ;
print_char:
sta a ; Save the typed character for now.
@@ -507,7 +511,7 @@ printc:
bne @save ; Yes, so don't shift the line.
sty.w scr_ptr ; No, so save the cursor index for later.
jsr fndend ; Find the end of the line.
- jmp @shift ; Start shifting the line right.
+ bra @shift ; Start shifting the line right.
@update:
lda scr_col ; Save the current column position for later.
sta scr_tcol ;
@@ -526,7 +530,7 @@ printc:
sta scr_col ;
jsr update_pos ; Update the cursor's position.
dec d ;
- jmp @save1 ;
+ bra @save1 ;
@shift:
ldy.w scr_ptr3 ;
inc scr_ptr3 ;
@@ -541,7 +545,7 @@ printc:
sta (ptr3), y ; store typed character into the input buffer.
lda scr_row ;
sta scr_trow ;
- jmp @update ;
+ bra @update ;
@save:
ldb d ;
bne @update ;
@@ -561,7 +565,7 @@ printc:
sta scr ; Echo typed character.
ldb f ;
beq @wrap ;
- jmp printc_end ;
+ bra printc_end ;
@scrolled:
ldb scr_row ;
cpb #maxrow ;
@@ -569,7 +573,7 @@ printc:
@wrapped2:
ldb #0 ;
stb f ;
- jmp @print ;
+ bra @print ;
@scroll:
sta scr ; Echo typed character.
clc ;
@@ -585,13 +589,13 @@ printc:
@wrap1:
inc scr_row ;
@wrap2:
- phx #2 ;
+ phx.w ;
clc ;
lda scr_row ;
adc scr_str ;
tax ;
jsr setbit ;
- plx #2 ;
+ plx.w ;
jsr update_pos ;
printc_end:
rts ;
@@ -607,14 +611,15 @@ nl:
cmp #maxrow ; Are we at the bottom of the screen?
bcc @incr ; No, so move down one line.
jsr scrl_down ; Yes, so scroll down one line.
- jmp @end ; We are done.
+ bra @end ; We are done.
@incr:
inc scr_row ; Move the cursor down by one line.
jsr update_pos ; Update the cursor's position.
@end:
lda #'\n' ; Print the newline.
sta a ;
- jmp printc_end ;
+ rts ;
+
clr_scr:
lda #maxrow ;
@@ -638,26 +643,57 @@ clr_scr:
jsr update_pos ;
lda #$C ;
sta scr ;
- jmp printc_end ;
+ rts ;
en_step:
lda step ;
beq step_en ;
- jmp printc_end ;
+ rts ;
step_en:
lda #1 ;
sta step ;
- jmp printc_end ;
+ rts ;
dis_step:
lda step ;
bne step_dis ;
- jmp printc_end ;
+ rts ;
step_dis:
lda #0 ;
sta step ;
- jmp printc_end ;
+ rts ;
+
+bs:
+ lda scr_col ; Are we at the far left of the screen?
+ beq @wrap ; Yes, so check for a wrapped line.
+ bra back ; No, so add the backspace to the buffer.
+@wrap:
+ jsr getbit ; Is this line, a wrapped line?
+ bcs @wrap1 ; Yes, so check if the cursor is at the top.
+ rts ; No, so we're done.
+@wrap1:
+ lda scr_row ; Are we at the top of the screen?
+ beq @wrap2 ; Yes, so check if the screen is at the top of the buffer.
+ bra @wrap3 ; No, so start clearing the wrap bit.
+@wrap2:
+ lda scr_str ; Are we at the top of the buffer?
+ bne @scroll ; Yes, so scroll up.
+ rts ; No, so we're done.
+@scroll:
+ clc ; Clear the carry flag, so that we don't get odd behaviour.
+ jsr scrl_up ; Scroll up.
+ inc scr_row ; Move down by one row.
+@wrap3:
+ clc ; Clear the carry flag.
+ lda scr_row ; Add the cursor's row position,
+ adc scr_str ; and the screen's starting row.
+ tax ; Transfer that into X.
+@wrap4:
+ dec scr_row ; Move up by one row.
+ ldb #maxcol+1 ; Move the cursor to the absolute right of the screen.
+ stb scr_col ;
+ jsr update_pos ; Update the cursor's position.
back:
ldb #0 ; Reset B, and some flags.
stb e ;
@@ -698,54 +734,23 @@ back:
sta scr_row ;
dec scr_col ; Move the cursor back by one column,
jsr update_pos ; and update it's position.
- jmp printc_end ; We are done.
+ rts ; We are done.
@update:
lda scr_row ; Set the line to start redrawing, to the start of the line.
sta f ;
inc e ; Set the redraw flag to true.
- jmp @shift ; Start shifting the line back.
+ bra @shift ; Start shifting the line back.
-bs:
- lda scr_col ; Are we at the far left of the screen?
- beq @wrap ; Yes, so check for a wrapped line.
- jmp back ; No, so add the backspace to the buffer.
-@wrap:
- jsr getbit ; Is this line, a wrapped line?
- bcs @wrap1 ; Yes, so check if the cursor is at the top.
- jmp printc_end ; No, so we're done.
-@wrap1:
- lda scr_row ; Are we at the top of the screen?
- beq @wrap2 ; Yes, so check if the screen is at the top of the buffer.
- jmp @wrap3 ; No, so start clearing the wrap bit.
-@wrap2:
- lda scr_str ; Are we at the top of the buffer?
- bne @scroll ; Yes, so scroll up.
- jmp printc_end ; No, so we're done.
-@scroll:
- clc ; Clear the carry flag, so that we don't get odd behaviour.
- jsr scrl_up ; Scroll up.
- inc scr_row ; Move down by one row.
-@wrap3:
- clc ; Clear the carry flag.
- lda scr_row ; Add the cursor's row position,
- adc scr_str ; and the screen's starting row.
- tax ; Transfer that into X.
-@wrap4:
- dec scr_row ; Move up by one row.
- ldb #maxcol+1 ; Move the cursor to the absolute right of the screen.
- stb scr_col ;
- jsr update_pos ; Update the cursor's position.
- jmp back ; Delete the previous character.
shftln:
ldb d ; Is the flag not set?
beq @dec_loop ; Yes, so shift, and decrement.
ldb #0 ; Clear the B register.
- jmp @inc_loop ; No, so shift, and increment.
+ bra @inc_loop ; No, so shift, and increment.
@neg:
ldy.w zero ; Set the source poition to 0.
stb (ptr3), y ; Clear the character that is in the source.
- jmp @end ; We are done.
+ bra @end ; We are done.
@inc_loop:
sty.w scr_ptr2 ; Save the source position for later.
ldy.w scr_ptr ; Get the previous cursor index.
@@ -755,35 +760,35 @@ shftln:
@inc_loop1:
ldy.w scr_ptr2 ; Get the source position.
lda (ptr3), y ; Get the character from the source position.
- phy #2 ; Save the source position for later.
+ phy.w ; Save the source position for later.
txy ; Set our position to the destination.
sta (ptr3), y ; Place the character from the source position, to the destination position.
- ply #2 ; Set our position back to the source.
+ 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,
dey ; Decrement the source position.
dex ; Decrement the destination position.
- jmp @inc_loop ; Keep looping.
+ bra @inc_loop ; Keep looping.
@dec_loop:
stx.w scr_ptr2 ; Save the destination position for later.
lda (ptr3), y ; Is the character at the source position, a null terminator?
beq @end3 ; Yes, so we're done.
- phy #2 ; No, so save the source position for later.
+ phy.w ; No, so save the source position for later.
txy ; Set our position to the destination.
sta (ptr3), y ; Place the character from the source position, to the destination position.
inx ; Increment the destination position.
- ply #2 ; Set our position back to the source.
+ ply.w ; Set our position back to the source.
stb (ptr3), y ; Clear the character that is in the source.
iny ; Increment the source position.
- jmp @dec_loop ; Keep looping.
+ bra @dec_loop ; Keep looping.
@wrap:
tax ; Use the ending line as a parameter for setbit.
jsr setbit ; Set the wrap bit of the ending line.
- jmp @end5 ; We are done.
+ bra @end5 ; We are done.
@wrap1:
tax ; Use the ending line as a parameter for clrbit.
jsr clrbit ; Clear the wrap bit of the ending line.
- jmp @end5 ; We are done.
+ bra @end5 ; We are done.
@end:
lda (ptr3), y ; Is this character a null terminator?
bne @end1 ; No, so just find the end of the line.
@@ -802,12 +807,12 @@ shftln:
cmp scr_row ; Is the ending line greater than the starting line?
beq @end5 ; No, so we're done.
bcs @wrap ; Yes, so set the wrap bit.
- jmp @end5 ; No, so we're done.
+ bra @end5 ; No, so we're done.
@end3:
jsr findend ; Find the ending line.
cpb #0 ; Is the remainder zero?
beq @end4 ; Yes, so check if the ending line is greater than the starting line.
- jmp @end5 ; No, so we're done.
+ bra @end5 ; No, so we're done.
@end4:
cmp scr_row ; Is the ending line greater than the starting line?
beq @end5 ; No, so we're done.
@@ -821,44 +826,45 @@ esc:
cmp #$1B ; Is this character an escape character?
beq shftesc ; Yes, so check the other set of escape routines.
lda status ; No, so wait for the next character.
- beq printc_end ; We have an error, so discard it, and go back to getting user input.
+ beq @end ; We have an error, so discard it, and go back to getting user input.
lda kbd ; Get the escape code.
sta c ; Store the escape code, until we need it.
lda #0 ; Set the D pseudo register to zero.
sta d ;
jsr isup ; Check if the user pressed up.
lda d ; Did the user press up?
- bne esc_end ; Yes, so we're done.
+ bne @end ; Yes, so we're done.
jsr isdown ; No, so check if the user pressed down.
lda d ; Did the user press down?
- bne esc_end ; Yes, so we're done.
+ bne @end ; Yes, so we're done.
lda #0 ; No, so check if the user pressed left.
jsr isleft ;
lda d ; Did the user press left?
- bne esc_end ; Yes, so we're done.
+ bne @end ; Yes, so we're done.
jsr isright ; No, so check if the user pressed right.
-esc_end:
+@end:
lda #0 ; Clear the D pseudo register.
sta d ;
- jmp printc_end ; We are done.
+ rts ; We are done.
shftesc:
lda status ; Skip the '['.
lda kbd ;
lda status ; Wait for the next character.
- beq printc_end ; We have an error, so discard it, and go back to getting user input.
+ beq @end ; We have an error, so discard it, and go back to getting user input.
lda kbd ; Get the escape code.
sta c ; Store the escape code, until we need it.
lda #0 ; Use the D pseudo register as a skip flag.
sta d ;
jsr isshftup ; Check if the user pressed shift+up.
lda d ; Was it successful?
- bne shftesc_end ; Yes, so we're done.
+ bne @end ; Yes, so we're done.
jsr isshftdown ; No, so check if the user pressed shift+down.
-shftesc_end:
+@end:
lda #0 ; Clear the D pseudo register.
sta d ;
- jmp printc_end ; We are done.
+ rts ; We are done.
+
isup:
lda c ; Load the escape code into the accumulator.
@@ -869,8 +875,14 @@ isup:
@check2:
lda c ; No, so load the escape code back into the accumulator.
cmp #'A' ; Did the user press the up arrow key?
- beq up ; Yes, so move the cursor up.
- jmp @end ; No, so we're done.
+ beq @up ; Yes, so move the cursor up.
+ bra @end ; No, so we're done.
+@up:
+ dec scr_row ; Move the cursor up a line.
+ jsr update_pos ; Update it's position.
+ lda #1 ; Tell the escape routine that we succeded.
+ sta d ;
+ rts ; We are done.
@scroll:
lda scr_str ; Are we at the top of the screen buffer?
beq @end ; Yes, so we're done.
@@ -878,9 +890,9 @@ isup:
lda #1 ; Tell the escape routine that we were successful.
sta d ;
@end:
-isup_done:
rts ; End of isup.
+
isdown:
lda c ; Load the escape code into the accumulator.
cmp #'B' ; Did the user press the down arrow key?
@@ -890,8 +902,14 @@ isdown:
beq @scroll ; Yes, so scroll down.
lda c ; No, so load the escape code back into the accumulator.
cmp #'B' ; Did the user press the down arrow key?
- beq down ; Yes, so move the cursor down.
- jmp @end ; No, so we're done.
+ beq @down ; Yes, so move the cursor down.
+ bra @end ; No, so we're done.
+@down:
+ inc scr_row ; Move the cursor down a line.
+ jsr update_pos ; Update it's position.
+ lda #1 ; Tell the escape routine that we succeded.
+ sta d ;
+ rts ; We are done.
@scroll:
lda scr_row ; Save the cursor's row number.
sta scr_trow ;
@@ -905,9 +923,9 @@ isdown:
lda #1 ; Tell the escape routine that we were successful.
sta d ;
@end:
-isdown_done:
rts ; End of isdown.
+
isright:
lda c ; Load the escape code into the accumulator.
cmp #'C' ; Did the user press the right arrow key?
@@ -915,20 +933,20 @@ isright:
lda scr_col ; Yes, so start checking the x coordinate of the cursor.
cmp #maxcol ; Is the cursor at the far right of the screen?
beq @wrap ; Yes, so check if this is a wrapped line.
- jmp right ; No, so move the cursor right, like normal.
+ bra @right ; No, so move the cursor right, like normal.
@wrap:
inc scr_row ; Move down a row.
jsr getbit ; Is the current line, a wrapped line?
bcs @incr ; Yes, so leave the cursor where it is.
dec scr_row ; No, so move the cursor back up a row.
- jmp @end2 ; We are done.
+ bra @end2 ; We are done.
@scroll:
lda scr_str ; Are we at the top of the screen buffer?
beq @end ; Yes, so we're done.
lda #1 ; No, so scroll down.
sta wrapped ; Set the wrapped flag.
jsr scrl_down ; Scroll down.
- jmp @end ; We are done.
+ bra @end ; We are done.
@incr:
lda #0 ; Set the cursor to the far left of the screen.
sta scr_col ;
@@ -936,17 +954,21 @@ isright:
cmp #maxrow ; Are we at the bottom of the screen?
beq @end1 ; No, so we're done.
bcs @scroll ; Yes, so check if we are scrolling down.
- jmp @end1 ; No, so we're done.
+ bra @end1 ; No, so we're done.
+@right:
+ inc scr_col ; Move the cursor right by one character.
+ jsr update_pos ; Update it's position.
+ rts ; End of isright.
@end:
dec scr_row ; Move back up a row.
@end1:
jsr update_pos ; Update the cursor position.
@end2:
-isright_dne:
lda #0 ; Unset the wrapped flag.
sta wrapped ;
rts ; End of isright.
+
isleft:
lda c ; Load the escape code into the accumulator.
cmp #'C' ; Did the user press right?
@@ -955,12 +977,12 @@ isleft:
beq @wrap ; Yes, so start checking if this is a wrapped line.
lda c ; No, so load the escape code back into the accumulator.
cmp #'D' ; Did the user press the left arrow key?
- beq left ; Yes, so move the cursor left.
- jmp @end1 ; No, so we're done.
+ beq @left ; Yes, so move the cursor left.
+ bra @end1 ; No, so we're done.
@wrap:
jsr getbit ; Is the current line, a wrapped line?
bcs @decr ; Yes, so wrap back up a line.
- jmp @end1 ; No, so we're done.
+ bra @end1 ; No, so we're done.
@decr:
lda scr_row ; Is the cursor at the top of the screen?
beq @decr1 ; Yes, so don't move up a line.
@@ -974,81 +996,60 @@ isleft:
sta d ;
lda scr_row ; Are we at the top of the screen?
beq @scroll ; Yes, so check if we need to scroll.
- jmp @end ; No, so we're done.
+ bra @end ; No, so we're done.
@scroll:
lda wrapped ; Was the wrapped flag set somewhere else?
bne @end ; Yes so we're done.
lda scr_str ; No, but are we actually at the top of the screen buffer?
beq @end1 ; Yes, so we're done.
jsr scrl_up ; No, so scroll up.
- jmp @end1 ; We are done.
+ bra @end1 ; We are done.
+@left:
+ dec scr_col ; Move the cursor left a character.
+ jsr update_pos ; Update it's position.
+ lda #1 ; Tell the escape routine that we succeded.
+ sta d ;
+ rts ; We are done
@end:
jsr update_pos ; Update the cursor position.
@end1:
-isleft_done:
lda #0 ; Unset the wrapped flag.
sta wrapped ;
rts ; End of isleft.
-up:
- dec scr_row ; Move the cursor up a line.
- jsr update_pos ; Update it's position.
- lda #1 ; Tell the escape routine that we succeded.
- sta d ;
- jmp isup_done ; We are done.
-down:
- inc scr_row ; Move the cursor down a line.
- jsr update_pos ; Update it's position.
- lda #1 ; Tell the escape routine that we succeded.
- sta d ;
- jmp isdown_done ; We are done.
-right:
- inc scr_col ; Move the cursor right by one character.
- jsr update_pos ; Update it's position.
- jmp isright_dne ; We are done.
-left:
- dec scr_col ; Move the cursor left a character.
- jsr update_pos ; Update it's position.
- lda #1 ; Tell the escape routine that we succeded.
- sta d ;
- jmp isleft_done ; We are done
isshftup:
lda c ; Load the escape code back into the accumulator.
cmp #'A' ; Did the user press the up arrow key?
- bne shftup_done ;
+ bne @end ;
lda #1 ;
sta d ;
lda scr_str ;
- beq shftup_done ;
- jmp shftup ;
-shftup_done:
+ beq @end ;
+@shftup:
+ jsr scrl_up ;
+ lda #1 ;
+ sta d ;
+@end:
rts ;
+
isshftdown:
lda c ; Load the escape code back into the accumulator.
cmp #'B' ; Did the user press the down arrow key?
- bne shftdn_done ;
+ bne @end ;
lda #1 ;
sta d ;
lda scr_end ;
cmp #71 ;
- bcs shftdn_done ;
- jmp shftdown ;
-shftdn_done:
- rts ;
-
-shftup:
- jsr scrl_up ;
- lda #1 ;
- sta d ;
- jmp shftup_done ;
-
-shftdown:
+ bcs @end ;
+@shftdown:
jsr scrl_down ;
lda #1 ;
sta d ;
- jmp shftdn_done ;
+@end:
+ rts ;
+
update_pos:
ldb #1 ; Set the F pseudo register to one, to fix some bugs.
@@ -1074,7 +1075,7 @@ update_pos:
getrow:
lda scr_row ; Get the cursor's y coordinate.
- jmp bcd ; Convert it to BCD.
+ bra bcd ; Convert it to BCD.
getcol:
lda #';' ; Print ';'
sta scr ; to the screen.
@@ -1098,23 +1099,23 @@ scrl_down:
lda #'T' ; Print 'T'
sta scr ; to the screen, and end the escape sequence.
lda scr_row ; Get the cursor's line number.
- pha #1 ; Save it in the stack.
+ pha ; Save it in the stack.
lda wrapped ; Was the wrapped flag set?
beq @save ; Yes, so save the cursor position.
@redraw:
jsr rdrw_row ; No, so redraw this row.
lda wrapped ; Was the wrapped flag set?
beq @load ; Yes, so load the previous cursor position back.
- jmp @end ; No, so we're done.
+ bra @end ; No, so we're done.
@save:
lda scr_col ; Get the cursor's column number.
- pha #1 ; Save it in the stack.
- jmp @redraw ; Start redrawing the current row.
+ pha ; Save it in the stack.
+ bra @redraw ; Start redrawing the current row.
@load:
- pla #1 ; Get the cursor's previous column number back.
+ pla ; Get the cursor's previous column number back.
sta scr_col ;
@end:
- pla #1 ; Get the cursor's previous line number back.
+ pla ; Get the cursor's previous line number back.
sta scr_row ;
jsr update_pos ; Update the cursor's position.
lda #0 ; Clear the wrapped flag.
@@ -1132,15 +1133,15 @@ scrl_up:
lda #'S' ; Print 'S'
sta scr ; to the screen, and end the escape sequence.
lda scr_row ;
- pha #1 ;
+ pha ;
lda scr_col ;
- pha #1 ;
+ pha ;
lda #0 ;
sta scr_row ;
jsr rdrw_row ;
- pla #1 ;
+ pla ;
sta scr_col ;
- pla #1 ;
+ pla ;
sta scr_row ;
jsr update_pos ;
@end:
@@ -1164,11 +1165,11 @@ rdrw_row:
lda scr_col ;
cmp #maxcol+1 ;
bcs @end ;
- jmp @loop ;
+ bra @loop ;
@skip:
lda #' ' ;
sta scr ; to the screen.
- jmp @incr1 ;
+ bra @incr1 ;
@end:
lda #0 ;
sta scr_col ;
@@ -1178,11 +1179,11 @@ rdrw_row:
rdrw_ln:
lda scr_row ;
- pha #1 ;
+ pha ;
lda f ;
sta scr_row ;
lda scr_col ;
- pha #1 ;
+ pha ;
jsr update_pos ;
@loop:
lda scr_row ;
@@ -1193,11 +1194,11 @@ rdrw_ln:
jsr rdrw_row ;
@incr:
inc scr_row ;
- jmp @loop ;
+ bra @loop ;
@end:
- pla #1 ;
+ pla ;
sta scr_col ;
- pla #1 ;
+ pla ;
sta scr_row ;
jsr update_pos ;
lda #0 ;
@@ -1213,11 +1214,11 @@ set_ptr:
@ptr1:
stb.q ptr ; Reset the first pointer.
sta.q ptr ; No, so set the first pointer.
- jmp @end ; We are done.
+ bra @end ; We are done.
@ptr2:
stb.q ptr2 ; Reset the second pointer.
sta.q ptr2 ; Set the second pointer.
- jmp @end ; We are done.
+ bra @end ; We are done.
@ptr3:
stb.q ptr3 ; Reset the third pointer.
sta.q ptr3 ; Set the third pointer.