[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scrolling HGR Screen Up 8 Lines
In article <1e7m1xy.1xt42n21usiwsgN%dempson@actrix.gen.nz>,
dempson@actrix.gen.nz (David Empson) wrote:
> Jon Bettencourt <jonINTERNETrelayCHAT@napaVALLEYnet.CLARInet> wrote:
>
> > Does anybody have an assembly language routine for such a thing?
>
> Not handy, but I should be able to construct one from first principles.
For a routine like this, you *really* want it to be as fast as
possible. This basically means unrolling it the whole way,
writing it like so:
LDY #$27
.loop LDA $2080,Y ; row 8 to row 0
STA $2000,Y
LDA $2480,Y ; row 9 to row 1
STA $2400,Y
...
repeat for all 192-8 lines
...
DEY
BMI .skip
JMP .loop
.skip
> COPY8
> ; Subroutine to copy 8 lines.
> ; On exit, the source and destination addresses will have
> ; been incremented by $1C00.
> 0390: A2 08 LDX #$08 ; Number of lines to copy
> C8LOOP
> 0392: A0 00 LDY #$00
> LINELOOP
> 0394: B1 3C LDA ($3C),Y
> 0396: 91 42 STA ($42),Y
> 0398: C8 INY
> 0399: C0 28 CPY #$28
> 039B: 90 F7 BCC LINELOOP ; Repeat until we've copied 40 bytes
> 039D: CA DEX ; Count off a line
> 039E: F0 C8 BEQ ANYRTS
You definitely do *not* want to do it this way!
Indirect-comma-Y addressing is the slowest addressing mode.
If you don't want to unroll over the full range as I suggested
above, at the very least you want to use self-modifying code
for the copying part so you can use absolute-comma-X/Y addressing
instead.
Your loop above uses 5+6+2+2+3=18 cycles to copy just one
byte. The fully unrolled code uses 4+5+(2+2+3)/(192-8)=9.04 cycles
to copy one byte, so it's basically twice as fast.
Christer Ericson
989 Studios/SCEA, Santa Monica