voila le code executé dans la boucle principale
le code en interruption est très long ( i2S + timer 1 pour la gestion du module + timer 2 pour la gestion des pads )
edit : j'ai ajouté des or comme conseillé sur atariage mais je n'ai pas encore testé le résultat.
lz4_depack_smallest_DSP:
move R20,R24
add R5,R24 ; packed buffer end
moveq #0,R5
moveq #0,R2
moveq #$F,R4
movei #$FF,R12
.tokenLoop_smallest_DSP:
loadb (R20),R5
addq #1,R20
move R5,R6
shrq #4,R6
movei #.lenOffset_smallest_DSP,R10
cmpq #0,R6
jump eq,(R10)
nop
.readLen_smallest1_DSP:
movei #.readEnd_smallest1_DSP,R11
cmp R6,R4 ; cmp.B !!!!
jump ne,(R11)
nop
.readLoop_smallest1_DSP:
loadb (R20),R2
addq #1,R20
add R2,R6 ; final len could be > 64KiB
not R2
and R12,R2 ; not R2.b
movei #.readLoop_smallest1_DSP,R10
cmpq #0,R2
jump eq,(R10)
nop
.readEnd_smallest1_DSP:
.litcopy_smallest_DSP:
loadb (R20),R13
storeb R13,(R21)
addq #1,R20
addq #1,R21
movei #.litcopy_smallest_DSP,R10
subq #1,R6
cmpq #0,R6
jump ne,(R10)
nop
; end test is always done just after literals
movei #.readEnd_smallest_DSP,R11
cmp R20,R24
jump eq,(R11)
nop
.lenOffset_smallest_DSP:
loadb (R20),R6 ; read 16bits offset, little endian, unaligned
addq #1,R20
loadb (R20),R13
addq #1,R20
shlq #8,R13
add R13,R6
move R21,R23
sub R6,R23 ; R6/d1 bits 31..16 are always 0 here
moveq #$F,R6
and R5,R6 ; and.w d0,d1 .W !!!
.readLen_smallest2_DSP:
movei #.readEnd_smallest2_DSP,R11
cmp R6,R4 ; cmp.B !!!!
jump ne,(R11)
nop
.readLoop_smallest2_DSP:
loadb (R20),R2
addq #1,R20
add R2,R6 ; final len could be > 64KiB
not R2
and R12,R2 ; not R2.b
movei #.readLoop_smallest2_DSP,R10
cmpq #0,R2
jump eq,(R10)
nop
.readEnd_smallest2_DSP:
addq #4,R6
.copy_smallest_DSP:
loadb (R23),R13
storeb R13,(R21)
addq #1,R23
addq #1,R21
movei #.copy_smallest_DSP,R10
movei #.tokenLoop_smallest_DSP,R11
subq #1,R6
jump ne,(R10)
nop
jump (R11)
nop
.readLen_smallest_DSP:
movei #.readEnd_smallest_DSP,R11
cmp R6,R4 ; cmp.B !!!!
jump ne,(R11)
nop
.readLoop_smallest_DSP:
loadb (R20),R2
or R2,R2
addq #1,R20
add R2,R6 ; final len could be > 64KiB
or R2,R2
not R2
and R12,R2 ; not R2.b
or R2,R2
movei #.readLoop_smallest_DSP,R10
cmpq #0,R2
jump eq,(R10)
nop
.readEnd_smallest_DSP:
movei #LZ4_pointeur_sur_bloc_a_decompresser,R6
moveq #0,R23
movei #DSP_boucle_centrale,R4
store R23,(R6) ; mets a zero l'adresse du bloc a decompresser / decompression terminée
jump (R4)
nop