mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
micro tweaks adpcm.p8
This commit is contained in:
parent
f75fd0811e
commit
68539d6cc9
@ -135,7 +135,7 @@ io_error:
|
||||
|
||||
sub list_filenames(uword pattern_ptr, uword filenames_buffer, uword filenames_buf_size) -> ubyte {
|
||||
; -- fill the provided buffer with the names of the files on the disk (until buffer is full).
|
||||
; Files in the buffer are separeted by a 0 byte. You can provide an optional pattern to match against.
|
||||
; Files in the buffer are separated by a 0 byte. You can provide an optional pattern to match against.
|
||||
; After the last filename one additional 0 byte is placed to indicate the end of the list.
|
||||
; Returns number of files (it skips 'dir' entries i.e. subdirectories).
|
||||
; Also sets carry on exit: Carry clear = all files returned, Carry set = directory has more files that didn't fit in the buffer.
|
||||
|
@ -23,6 +23,8 @@ emudbg {
|
||||
&ubyte EMU_EMU_DETECT2 = EMU_BASE + 15
|
||||
|
||||
sub is_emulator() -> bool {
|
||||
; Test for emulator presence.
|
||||
; It is recommended to only use the other debug routines if this returns true.
|
||||
return EMU_EMU_DETECT1=='1' and EMU_EMU_DETECT2=='6'
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ gfx2 {
|
||||
pop_stack()
|
||||
xx = x1
|
||||
while xx >= 0 and pget(xx as uword, yy as uword) == cx16.r11L {
|
||||
plot(xx as uword, yy as uword, cx16.r10L)
|
||||
plot(xx as uword, yy as uword, cx16.r10L) ; TODO use vera auto decrement
|
||||
xx--
|
||||
}
|
||||
if xx >= x1
|
||||
@ -588,7 +588,7 @@ gfx2 {
|
||||
|
||||
do {
|
||||
while xx <= width-1 and pget(xx as uword, yy as uword) == cx16.r11L {
|
||||
plot(xx as uword, yy as uword, cx16.r10L)
|
||||
plot(xx as uword, yy as uword, cx16.r10L) ; TODO use vera auto increment
|
||||
xx++
|
||||
}
|
||||
push_stack(left, xx - 1, yy, dy)
|
||||
|
@ -137,7 +137,7 @@ io_error:
|
||||
|
||||
sub list_filenames(uword pattern_ptr, uword filenames_buffer, uword filenames_buf_size) -> ubyte {
|
||||
; -- fill the provided buffer with the names of the files on the disk (until buffer is full).
|
||||
; Files in the buffer are separeted by a 0 byte. You can provide an optional pattern to match against.
|
||||
; Files in the buffer are separated by a 0 byte. You can provide an optional pattern to match against.
|
||||
; After the last filename one additional 0 byte is placed to indicate the end of the list.
|
||||
; Returns number of files (it skips 'dir' entries i.e. subdirectories).
|
||||
; Also sets carry on exit: Carry clear = all files returned, Carry set = directory has more files that didn't fit in the buffer.
|
||||
|
@ -1,6 +1,16 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- optimize word array assignment to not use tax/tay etc but simply lda+ldx: (note: with and without @split!)
|
||||
uword pstep = w_array[index] ->
|
||||
ldy p8_index
|
||||
lda p8_w_array,y
|
||||
ldx p8_w_array+1,y
|
||||
sta p8_pstep
|
||||
stx p8_pstep+1
|
||||
|
||||
- gfx2: use vera auto in/decrement in the flood fill routine
|
||||
|
||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||
- [on branch: ir-less-branch-opcodes] IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
||||
|
@ -47,8 +47,8 @@ adpcm {
|
||||
uword @requirezp predict_2 ; decoded 16 bit pcm sample for second channel.
|
||||
ubyte @requirezp index
|
||||
ubyte @requirezp index_2
|
||||
uword @zp pstep
|
||||
uword @zp pstep_2
|
||||
uword @requirezp pstep
|
||||
uword @requirezp pstep_2
|
||||
|
||||
sub init(uword startPredict, ubyte startIndex) {
|
||||
; initialize first decoding channel.
|
||||
@ -65,8 +65,10 @@ adpcm {
|
||||
}
|
||||
|
||||
sub decode_nibble(ubyte nibble) {
|
||||
; decoder for nibbles for the first channel.
|
||||
; Decoder for nibbles for the first channel.
|
||||
; this is the hotspot of the decoder algorithm!
|
||||
; Note that the generated assembly from this is pretty efficient,
|
||||
; rewriting it by hand in asm seems to improve it only 5-10%
|
||||
cx16.r0s = 0 ; difference
|
||||
if nibble & %0100
|
||||
cx16.r0s += pstep
|
||||
@ -91,28 +93,30 @@ adpcm {
|
||||
; predicted = - 32767
|
||||
|
||||
index += t_index[nibble]
|
||||
if_neg ; was: if index & 128
|
||||
if_neg
|
||||
index = 0
|
||||
else if index > len(t_step)-1
|
||||
else if index >= len(t_step)-1
|
||||
index = len(t_step)-1
|
||||
pstep = t_step[index]
|
||||
}
|
||||
|
||||
sub decode_nibble_second(ubyte nibble_2) {
|
||||
; decoder for nibbles for the second channel.
|
||||
sub decode_nibble_second(ubyte nibble) {
|
||||
; Decoder for nibbles for the second channel.
|
||||
; this is the hotspot of the decoder algorithm!
|
||||
; Note that the generated assembly from this is pretty efficient,
|
||||
; rewriting it by hand in asm seems to improve it only 5-10%
|
||||
cx16.r0s = 0 ; difference
|
||||
if nibble_2 & %0100
|
||||
if nibble & %0100
|
||||
cx16.r0s += pstep_2
|
||||
pstep_2 >>= 1
|
||||
if nibble_2 & %0010
|
||||
if nibble & %0010
|
||||
cx16.r0s += pstep_2
|
||||
pstep_2 >>= 1
|
||||
if nibble_2 & %0001
|
||||
if nibble & %0001
|
||||
cx16.r0s += pstep_2
|
||||
pstep_2 >>= 1
|
||||
cx16.r0s += pstep_2
|
||||
if nibble_2 & %1000
|
||||
if nibble & %1000
|
||||
predict_2 -= cx16.r0s
|
||||
else
|
||||
predict_2 += cx16.r0s
|
||||
@ -124,10 +128,10 @@ adpcm {
|
||||
; elif predicted < -32767:
|
||||
; predicted = - 32767
|
||||
|
||||
index_2 += t_index[nibble_2]
|
||||
if_neg ; was: if index & 128
|
||||
index_2 += t_index[nibble]
|
||||
if_neg
|
||||
index_2 = 0
|
||||
else if index_2 > len(t_step)-1
|
||||
else if index_2 >= len(t_step)-1
|
||||
index_2 = len(t_step)-1
|
||||
pstep_2 = t_step[index_2]
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ main {
|
||||
}
|
||||
}
|
||||
|
||||
txt.print("\ngood file! playback starts!\n")
|
||||
txt.print("\ngood file! playback starts! ")
|
||||
cx16.rombank(0) ; activate kernal bank for faster calls
|
||||
cx16.VERA_AUDIO_RATE = 0 ; halt playback
|
||||
cx16.VERA_AUDIO_CTRL = %10101011 ; mono 16 bit, volume 11
|
||||
@ -100,6 +100,9 @@ main {
|
||||
cx16.VERA_IEN = %00001000 ; enable AFLOW only for now
|
||||
sys.clear_irqd()
|
||||
|
||||
str progress_chars = "-\\|/-\\|/"
|
||||
ubyte progress = 0
|
||||
|
||||
if diskio.f_open(MUSIC_FILENAME) {
|
||||
uword block_size = 1024
|
||||
if wavfile.wavefmt==wavfile.WAVE_FORMAT_DVI_ADPCM
|
||||
@ -114,7 +117,9 @@ main {
|
||||
;; cx16.vpoke(1,$fa00, $00) ; paint a screen color
|
||||
if size<block_size
|
||||
break
|
||||
txt.chrout('.')
|
||||
txt.chrout(progress_chars[progress/2 & 7])
|
||||
txt.chrout($9d) ; cursor left
|
||||
progress++
|
||||
}
|
||||
diskio.f_close()
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user