and so, I have coded this small routine, but the cycle counting that I get is far too big to do that ...
The cycles count obtained is that one:
- intro part = 40 cycles
- Loop part = 132 cycles
- final part = 29 cycles
Only the loop for the 156 lines needs: 132x156=20,592 cycles
But we have (in PAL machines) 70+50 lines after the FS at end of frame, so working at double speed, we have 120x47x2=13,680 cycles
but this is not enough to do the stackblast copy!
The code is shown at the end of the message
It seems that I have missed something, but cannot spot what!
Does anybody have any hint to copy the whole screen before the next frame begins?
Any ideas will be very appreciated
I know that ordering the origin in a special way, I could avoid re-positioning the stack 3 of the 4 times every line
but anyway it keeps being a too big total cyclecount.
regards
pere
Code: Select all
; --------------------------------------------------------------------------------------------------
; stack copier to move a screen 256x156 from $6700 to $c00
; --------------------------------------------------------------------------------------------------
stkBlst sync
opt cc ; init cyclecounting
sta $ffd9 ; double speed
sts stkF03+2 ; save stack
tfr dp,a ; get DP
tfr cc,b ; and CC
std stkF04+1 ; save both
orcc #$50 ; disable interrupts
lds #$6700+8 ; set origin pointer to get 8 bytes from source data
ldu #$c00 ; set destination to screen beginning
opt cc ; reset cyclecounting
stkF02 puls d,x,y,cc,dp ; get 8 bytes from origin
pshu d,x,y,cc,dp ; put them into destination
leas 16,s ; advance pointer to next 8 bytes block
puls d,x,y,cc,dp
pshu d,x,y,cc,dp
leas 16,s ; eight bytes more
puls d,x,y,cc,dp
pshu d,x,y,cc,dp
leas 16,s ; eight bytes more
puls d,x,y,cc,dp
pshu d,x,y,cc,dp
leas 16,s ; eight bytes more = 32 bytes -> one PM4 line
cmpu #$2000 ; end of screen to be filled?
blo stkF02 ; no, next file
opt cc ; reset cyclecounting
sta $ffd8 ; normal speed
stkF03 lds #$0000 ; restore stack pointer
stkF04 ldd #$0000 ; get DP, CC
tfr a,dp ; set DP
tfr b,cc ; and CC
rts ; return
; --------------------------------------------------------------------------------------------------