Skip to content

Commit

Permalink
Log2 table generation for pitchbends
Browse files Browse the repository at this point in the history
  • Loading branch information
ADM228 committed Jan 12, 2024
1 parent 5974b4e commit a36f892
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 47 additions & 1 deletion source/sound/SNESFM.asm
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Configuration:

;================ 5. Song playback options ================

!SNESFM_CFG_PITCHBEND = 1

!SNESFM_CFG_VIRTUAL_CHANNELS = 1

endif
Expand All @@ -116,7 +118,8 @@ Documentation:
; $02 _ _ _ _ Sample Directory
; $03 $00 - $7F: Effect IDs
; |__ _ _ _ _ $80 - $FF: Basic effect time counters
; $04-$07 _ _ Effect q
; $04-$06 _ _ Effect q
; $07 _ _ _ _ Log table for pitchbends
; $08 _ _ _ _ Permanent storage of flags, counters and pointers for note stuff for "real" channels
; $09 _ _ _ _ Same but for virtual channels
; $0A _ _ _ _ Low bytes of instrument data pointers
Expand Down Expand Up @@ -239,6 +242,8 @@ InternalDefines:
!SNESFM_CFG_INSGEN_REPEAT_AMOUNT ?= 0
!SNESFM_CFG_INSGEN_ARITHMETIC_AMOUNT ?= 0

!SNESFM_CFG_PITCHBEND ?= 0

!SNESFM_CFG_VIRTUAL_CHANNELS ?= 0

if !SNESFM_CFG_VIRTUAL_CHANNELS > 0
Expand Down Expand Up @@ -373,6 +378,8 @@ if !SNESFM_CFG_PITCHTABLE_GEN >= 1
CALL GeneratePitchTable_Start
endif

CALL Log2Generate

SineSetup:

; Setting up the sine table
Expand Down Expand Up @@ -2735,6 +2742,45 @@ Includes:
org $0F00
SineTable:
incbin "quartersinetable.bin"
if !SNESFM_CFG_PITCHBEND
Log2Generate:
MOV X, #$00
MOV A, #(256-115)
MOV Y, #$00
.LoopPart1:
PUSH A
MOV A, LogTableTable+X
INC X
MOV $00, A
POP A
.LoopPart2:
CMP Y, $00
BEQ +
MOV LogTable+Y, A
INC A
INC Y
BNE Log2Generate_LoopPart2
MOV Y, #$80
.InvertLoop:
MOV A, LogTable-1+Y
EOR A, #$FF
INC A
MOV LogTable-1+Y, A
DBNZ Y, Log2Generate_InvertLoop
RET

+:
MOV LogTable+Y, A
INC Y
BRA Log2Generate_LoopPart1

org $0800-19 ; Log2 table for pitchbends
LogTableTable:
db 4, 12, 20, 29, 37, 46, 56, 65, 76, 86, 97, 109, 121, 134, 149, 164, 182, 203, 229
LogTable = $0700

endif

org $FFC0 ;For TCALLs
dw IndexToSamplePointer
Expand Down
2 changes: 2 additions & 0 deletions source/sound/demoConfig.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

!SNESFM_CFG_PITCHTABLE_GEN = 1

!SNESFM_CFG_PITCHBEND = 1

!SNESFM_CFG_VIRTUAL_CHANNELS = 1

incsrc "SNESFM.asm"
Expand Down

0 comments on commit a36f892

Please sign in to comment.