diff options
Diffstat (limited to 'programs/sub-suite/subeditor.s')
-rw-r--r-- | programs/sub-suite/subeditor.s | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s index fdf1e4b..7e124a2 100644 --- a/programs/sub-suite/subeditor.s +++ b/programs/sub-suite/subeditor.s @@ -10,10 +10,44 @@ reset: txs ; ldy #0 ; Reset Y. tyx ; Reset X. + jsr init_heap ; Initialize the heap. + jsr init_tables ; Initialize the main tables. jsr clr_scr ; Clear the screen. jsr pnt_strt ; Print the starting message. bra start ; Goto the start of the main program. + +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. + jsr findramend ; Find the end of the heap. + plb.q ; Restore the value in B. + plx.q ; Restore the value in X. + sta.q heapend ; Save the end of the heap. + and #0 ; Reset A. + rts ; End of init_heap. + + +init_tables: + and #0 ; Reset A. + lda.w #SCRSIZE ; Allocate SCRSIZE bytes of RAM for the screen buffer. + jsr malloc ; + sta.q buffer ; + and #0 ; Reset A. + lda.w #CMDSIZE ; Allocate CMDSIZE bytes of RAM for the command buffer. + jsr malloc ; + sta.q cmd_buf ; + and #0 ; Reset A. + lda.w #LWSIZE ; Allocate LWSIZE bytes of RAM for the linewrap table. + jsr malloc ; + sta.q bitabl ; + and #0 ; Reset A. + rts ; End of init_tables. + + clr_arr: phb ; Preserve whatever was in B. ldb #0 ; Clear B. @@ -67,9 +101,9 @@ pnt_strt: clr_cmd: and #0 ; Reset A. tay ; Reset Y. - lda.w #$3FF ; Set the clear count to $3FF. + 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. + lda.q cmd_buf ; Set the array to be cleared to the command buffer. jsr clr_arr ; Clear the command buffer. rts ; End of clr_cmd. @@ -152,7 +186,7 @@ getbt0: getbt1: 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. + lda.q bitabl ; Set the second pointer to the linewrap table. jsr set_ptr ; lsr #$10 ; Clear the Accumulator. pla ; Get the return byte back. @@ -168,7 +202,7 @@ getbt1: clrbit: 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. + lda.q bitabl ; Set the second pointer to the linewrap table. jsr set_ptr ; and #0 ; Clear the Accumulator. pla ; Get the return byte back. @@ -188,7 +222,7 @@ bitout: setbit: 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. + lda.q bitabl ; Set the second pointer to the linewrap table. jsr set_ptr ; and #0 ; Clear the Accumulator. pla ; Get the return byte back. @@ -283,10 +317,10 @@ cmd_cpy: tay ; Place it into the index. ldx.w #0 ; Reset the X 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. + lda.q buffer ; Set the first pointer to the start of the screen buffer. jsr set_ptr ; inb ; Make sure that set_ptr sets the second pointer. - lda.d #cmd_buf ; Set the second pointer to the start of the command buffer. + lda.q cmd_buf ; Set the second pointer to the start of the command buffer. jsr set_ptr ; deb ; Set B back to zero. tba ; Set the accumulator to zero. @@ -344,7 +378,7 @@ findst: fndend: 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. + lda.q buffer ; Set the first pointer to the start of the screen buffer. jsr set_ptr ; tba ; Set the Accumulator to zero. plb ; Restore the contents of the B register. @@ -369,7 +403,7 @@ findend: print_char: sta rega ; Preserve the character. ldb #2 ; Make sure that set_ptr sets the third pointer. - lda.d #buffer ; Set the third pointer to the start of the screen buffer. + 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. @@ -504,12 +538,14 @@ clr_scr: sta scr_end ; lda #0 ; sta scr_str ; - sta.q bitabl ; - sta.q bitabl+8 ; tay ; - lda.w #$1FFF ; Set the clear count to $1FFF. + 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. + jsr clr_arr ; Clear the linewrap table. + lda.w #SCRSIZE ; Set the clear count to SCRSIZE. sta.w scr_ptr ; - lda.d #buffer ; Set the array to be cleared to the screen buffer. + lda.q buffer ; Set the array to be cleared to the screen buffer. jsr clr_arr ; Clear the screen buffer. ; tay ; ; lda.w #$3FF ; Set the clear count to $3FF. |