I’ve been working on improving my Apple IIe TTY emulation application. One of the major limitations with it, is the amount of time it takes to scroll the Apple IIe’s screen, especially when in 80 column mode. In order to improve this function, I wrote my own fast scroll routine. Kind of interesting how close it turned out to a comment I received to a previous post, even though I forgot about that comment by the time I did this.

;

; Fast Screen Scroll Routine

;

LINE1 EQU $400

LINE2 EQU $480

LINE3 EQU $500

LINE4 EQU $580

LINE5 EQU $600

LINE6 EQU $680

LINE7 EQU $700

LINE8 EQU $780

LINE9 EQU $428

LINE10 EQU $4A8

LINE11 EQU $528

LINE12 EQU $5A8

LINE13 EQU $628

LINE14 EQU $6A8

LINE15 EQU $728

LINE16 EQU $7A8

LINE17 EQU $450

LINE18 EQU $4D0

LINE19 EQU $550

LINE20 EQU $5D0

LINE21 EQU $650

LINE22 EQU $6D0

LINE23 EQU $750

LINE24 EQU $7D0

FAST_SCROLL

STA STORE80 ; enable aux mem

STA PAGE2OF ; page 1 first

JSR FS_DOIT

STA PAGE2ON ; now do aux mem

FS_DOIT:

LDX #39

FS_L1:

LDA LINE2,X

STA LINE1,X

LDA LINE3,X

STA LINE2,X

LDA LINE4,X

STA LINE3,X

LDA LINE5,X

STA LINE4,X

LDA LINE6,X

STA LINE5,X

LDA LINE7,X

STA LINE6,X

LDA LINE8,X

STA LINE7,X

LDA LINE9,X

STA LINE8,X

LDA LINE10,X

STA LINE9,X

LDA LINE11,X

STA LINE10,X

LDA LINE12,X

STA LINE11,X

LDA LINE13,X

STA LINE12,X

DEX

BPL FS_L1

LDX #39

FS_L13:

LDA LINE14,X

STA LINE13,X

LDA LINE15,X

STA LINE14,X

LDA LINE16,X

STA LINE15,X

LDA LINE17,X

STA LINE16,X

LDA LINE18,X

STA LINE17,X

LDA LINE19,X

STA LINE18,X

LDA LINE20,X

STA LINE19,X

LDA LINE21,X

STA LINE20,X

LDA LINE22,X

STA LINE21,X

LDA LINE23,X

STA LINE22,X

LDA LINE24,X

STA LINE23,X

LDA #$A0 ; clear last line

STA LINE24,X

DEX

BPL FS_L13

RTS

This routine takes about 18 milliseconds to run on a 1 MHz Apple IIe, compared to the standard monitor scroll routine which takes 34 milliseconds. Other than unrolling the loops, which would greatly expand the size of the function for a minimal speed increase, I think this is about as fast as it’s going to get.

18 milliseconds is still not fast enough for my TTY emulation package, so I’m going to have split it up into several segments and check for input events between segments. However, now that I have my own version of the scroll code, I’ll be able to split it up relatively easily.

There are some other issues with the standard monitor COUT routines for this TTY application, so it’s very possible that I’ll end up customizing all the COUT routines. For instance, I’ve already customized the “BELL” function for performance reasons. The Carriage Return function also had to be customized, because on a teletype, CR does not force a line feed.