[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apple II Graphics Programming (Assembly)
On Jul 8, 9:46 am, Calibrator <calibra...@freenet.de> wrote:
> On 8 Jul., 17:14, BLuRry <brendan.rob...@gmail.com> wrote:
>
>
>
> > Very nice unrolling, Paul! That must be pretty speedy! Is it
> > possible to avoid screen holes without losing too much performance?
>
> Insert "CPY #$F8" directly after the INY and you should be done.
>
> The memory gain is negligible (unless you absolutely want to
> preserve the screen holes) but it's infact a bit speedier!
>
> While you need additional cycles for the comparison:
>
> (CPY #)= 2 cycles x 248 runs = 496 cycles
>
> you save more cycles because you avoid eight index runs:
>
> (STA $aaaa,Y) = 5 cycles x 32 instructions x 8 runs = 1280 cycles
> (INY) = 2 cycles x 8 runs = 16 cycles
> (BNE with branch) = 3 cycles x 8 runs = 24 cycles
> total = 1320
>
> Cycles gained: 1320 - 496 = 824
>
> Branches over page boundaries ignored in both cases and the
> final BNE with no branch (2 cycles) happens in both variants.
>
> bye
> Marcus
The "CPY #F8" does not work because screen holes only happen only once
every $400 bytes so the program needs a little more coding. Screen
holes are from
$23F8 - $23FF
$27F8 - $27FF
$2BF8 - $2BFF
$2FF8 - $2FFF
$33F8 - $33FF
$37F8 - $37FF
$3BF8 - $3BFF
$3FF8 - $3FFF
here is a program that I use to save the screen holes
LDY #PAGE ;PAGE=$20, $40, or $60
STY PTR+1
LDY #0
STY PTR
LDX #$20
a LDA #0
b STA (PTR),Y
INY
BNE b
INC PTR+1
DEX
BEQ d
TXA
AND #3
CMP #3
BNE a
LDA #0
c STA (PTR),Y
INY
CPY #F8
BCC c
INC PTR+1
DEX
BNE b
d RTS
As you can see, only the one page out of 4 would get slowed down due
to the comparison.
Rob