ppera wrote:Poor coding is reason, for sure. Even on Falcon it slowdowns sometimes too much (at 16MHz), although on that is unplayable fast in most of time, so need to start it at 8MHz, cache off.
Really should not slowdown at all, considering small part od screen moving.
Making it better would be nice thing, no doubt. Who is experienced here in game programming? Nyh ?

Well there is poor coding involved indeed! Just out of interest I looked at the sample play routine:
Code: Select all
sample_end:
move sr,-(a7)
ori.w #$700,sr
clr.b $FFFFFA19.w
bclr #5,$FFFFFA07.w
bclr #5,$FFFFFA13.w
bclr #5,$FFFFFA0B.w
bclr #5,$FFFFFA0F.w
move.w (a7)+,sr
rts
Sample_play:
movem.l d0-d1/a0,-(a7)
movea.l l47FE0,a0 ; sample pointer
cmpa.l l47FE4,a0 ; sample end
bcs.s play_sample ; play sample
tst.w l47FE8 ; repeat?
bne.s reset_sample_p ; yep
bsr.s sample_end
bra.s Sample_play_end
reset_sample_p:
movea.l l47FDC,a0 ; reset sample pointer
play_sample:
moveq #0,d0
move.b (a0)+,d0
addi.b #$80,d0 ; convert signed/unsigned sample (!!!!)
move.l a0,l47FE0
lsl.w #3,d0
lea digi_tab(pc),a0
adda.w d0,a0
move.l (a0)+,d0
move.w (a0)+,d1
movea.w #$8800,a0
movep.l d0,0(a0)
movep.w d1,0(a0)
bclr #5,$FFFFFA0F.w
Sample_play_end:
movem.l (a7)+,d0-d1/a0
rte
I am not 100% sure whether this is the main sample play routine because the digi_tab is used at multiple places but there is some room to optimize. First rearrange the memory a bit so important stuff becomes local. Swap the digi_tab so the sign is fixed in the table instead of calculating it during replay, try to use registers a bit more efficient and rearrange some instructions and you get something like this:
Code: Select all
sample_end:
move sr,-(a7)
ori.w #$700,sr
clr.b $FFFFFA19.w
bclr #5,$FFFFFA07.w
bclr #5,$FFFFFA13.w
bclr #5,$FFFFFA0B.w
bclr #5,$FFFFFA0F.w
move.w (a7)+,sr
move.l (a7)+,a0
rte
Sample_play:
move.l a0,-(a7) ; save a0
movea.l sample_ptr(pc),a0 ; sample pointer
cmpa.l sample_ptr_end(pc),a0 ; sample end?
bcs.s play_sample ; play sample
tst.w sample_repeat(pc) ; repeat?
beq.s sample_end ; nope
reset_sample_p:
movea.l sample_start(pc),a0 ; reset sample pointer
play_sample:
move.l d0,-(a7) ; save d0 and d1
move.w d1,-(a7)
moveq #0,d0
move.b (a0)+,d0
move.l a0,sample_ptr ; save updated sample ptr
lsl.w #3,d0
lea digi_tab(d0.w,pc),a0
move.l (a0)+,d0
move.w (a0)+,d1
lea $FFFFFA0F.w,a0
movep.l d0,-$720F(a0)
movep.w d1,-$720F(a0)
bclr #5,(a0)
move.w (a7)+,d1
move.l (a7)+,d0
move.l (a7)+,a0
rte
sample_start:
DC.B 0,0,0,0
sample_ptr:
DC.B 0,0,0,0
sample_ptr_end:
DC.B 0,0,0,0
sample_repeat:
DC.B 0,0,0,0,0,0
digi_tab:
DC.B 8,$E,9,$D,$A,$C,0,0
DC.B 8,$F,9,3,$A,0,0,0
.....
I didn't try to compile it but is should work more or less. If the other routines use nonsigned samples just duplicate the digi_tab for the sake of speed.
Usually you can better rewrite a game then try to patch it to make it faster. But stupid sample play routines are fixable.
Hans Wessels