1

(27 replies, posted in Other Platforms)

Posting an update as I finally managed to get the Tritone engine working for the 6502.  Drums aren’t implemented, but sounds pretty good.

;Tritone beeper music engine
;Original Z80 code by Shiru 03'2011
;6502 engine port by utz 03'2024
;BBC Micro port by Negative Charge 01'2025

; Constants
OSBYTE                  = $FFF4
OSWRCH                  = $FFEE
OSNEWL                  = $FFE7
SHEILABASE              = $FE00
SYSVIA_DDRA             = SHEILABASE + $43
SYSVIA_ORAS             = SHEILABASE + $4F
SYSVIA_REGB             = SHEILABASE + $40

DISPLAY_START           = $7c00

; Zero Page
ORG     $60
GUARD   $90

.vars_start

.ch0_acc_lo         SKIP 1
.ch0_acc_hi         SKIP 1
.ch1_acc_lo         SKIP 1
.ch1_acc_hi         SKIP 1
.ch2_acc_lo         SKIP 1
.ch2_acc_hi         SKIP 1

.ch0_div_lo         SKIP 1
.ch0_div_hi         SKIP 1
.ch1_div_lo         SKIP 1
.ch1_div_hi         SKIP 1
.ch2_div_lo         SKIP 1
.ch2_div_hi         SKIP 1

.ch0_duty           SKIP 1
.ch1_duty           SKIP 1
.ch2_duty           SKIP 1

.temp_output        SKIP 1

.loop_ptr           SKIP 2
.pattern_ptr        SKIP 2
.order_ptr          SKIP 2
.drum               SKIP 1
.row_length         SKIP 2

.vars_end

ORG     &1900
GUARD   DISPLAY_START

.start

MACRO sound_write_slow
    sta     SYSVIA_ORAS
    lda     #%00000000
    sta     SYSVIA_REGB
    nop:nop:nop
    lda     #%00001000
    sta     SYSVIA_REGB
ENDMACRO

MACRO RESET_SOUND_CHIP
    lda     #%11111111
    sound_write_slow
    lda     #%11011111
    sound_write_slow
    lda     #%10111111
    sound_write_slow
    lda     #%10011111
    sound_write_slow
ENDMACRO

.init
    lda     #%11111111
    sta     SYSVIA_DDRA

    sei

    RESET_SOUND_CHIP

    lda     #%10000001
    sound_write_slow
    lda     #%00000000
    sound_write_slow
    
    lda     #%10100001
    sound_write_slow
    lda     #%00000000
    sound_write_slow
    
    lda     #%11000001
    sound_write_slow
    lda     #%00000000
    sound_write_slow

    lda     #%00000000
    sta     SYSVIA_REGB
    
    lda     #LO(music_data)
    ldx     #HI(music_data)

.play
    pha
    txa
    pha
    
    ; Clear ZP
    lda     #0
    ldx     #vars_end-vars_start
.clear_loop
    sta     vars_start,x
    dex
    bpl     clear_loop
    
    pla
    sta     pattern_ptr+1
    pla
    sta     pattern_ptr+0

    lda     pattern_ptr+0
    clc
    adc     #2
    sta     loop_ptr+0
    lda     pattern_ptr+1
    adc     #0
    sta     loop_ptr+1

.play_loop
    lda     pattern_ptr+0
    sta     order_ptr+0
    lda     pattern_ptr+1
    sta     order_ptr+1

    ldy     #0
    lda     (pattern_ptr),y
    tax
    iny
    lda     (pattern_ptr),y
    
    bne     no_loop
    cpx     #0
    bne     no_loop
    
.return_loop
    lda     loop_ptr+0
    sta     pattern_ptr+0
    lda     loop_ptr+1
    sta     pattern_ptr+1
    jmp     play_loop

.no_loop
    ; Set pattern_ptr to pattern data
    sta     pattern_ptr+1
    stx     pattern_ptr+0
    
    ; Read speed from pattern
    ldy     #0
    lda     (pattern_ptr),y
    sta     row_length+0
    iny
    lda     (pattern_ptr),y
    sta     row_length+1
    
    lda     pattern_ptr+0
    adc     #1
    sta     pattern_ptr+0
    bcc     row
    inc     pattern_ptr+1
    jmp     row

.pattern_end
    lda     order_ptr+0
    clc
    adc     #2
    sta     pattern_ptr+0
    lda     order_ptr+1
    adc     #0
    sta     pattern_ptr+1
    jmp     play_loop

.row
    ldy     #0
    lda     (pattern_ptr),y
    iny
    
    cmp     #255
    beq     pattern_end
    
    cmp     #128
    bcs     ch0
    
    cmp     #2
    bcc     ch0
    
    sta     drum
    lda     (pattern_ptr),y
    iny

.ch0
    cmp     #1
    beq     skip_ch0
    
    cmp     #2
    bcs     ch0_note
    
    sta     ch0_duty
    sta     ch0_div_lo
    sta     ch0_div_hi
    jmp     skip_ch0

.ch0_note
    tax
    and     #$0f
    sta     ch0_div_hi
    txa
    and     #$f0
    sta     ch0_duty
    lda     (pattern_ptr),y
    iny
    sta     ch0_div_lo

.skip_ch0
    lda     (pattern_ptr),y
    iny
    
    cmp     #1
    beq     skip_ch1
    
    cmp     #2
    bcs     ch1_note
    
    sta     ch1_duty
    sta     ch1_div_lo
    sta     ch1_div_hi
    jmp     skip_ch1

.ch1_note
    tax
    and     #$0f
    sta     ch1_div_hi
    txa
    and     #$f0
    sta     ch1_duty
    lda     (pattern_ptr),y
    iny
    sta     ch1_div_lo

.skip_ch1
    lda     (pattern_ptr),y
    iny
    
    cmp     #1
    beq     skip_ch2
    
    cmp     #2
    bcs     ch2_note
    
    sta     ch2_duty
    sta     ch2_div_lo
    sta     ch2_div_hi
    jmp     skip_ch2

.ch2_note
    tax
    and     #$0f
    sta     ch2_div_hi
    txa
    and     #$f0
    sta     ch2_duty
    lda     (pattern_ptr),y
    iny
    sta     ch2_div_lo

.skip_ch2
    tya
    clc
    adc     pattern_ptr+0
    sta     pattern_ptr+0
    bcc     setup_play_loop
    inc     pattern_ptr+1

.setup_play_loop
    lda     row_length+0
    ora     row_length+1
    beq     row_finished
    
    ldx     row_length+0
    ldy     row_length+1

.play_note
    ; CH0
    lda     ch0_acc_lo          ; 3
    adc     ch0_div_lo          ; 3
    sta     ch0_acc_lo          ; 3
    lda     ch0_acc_hi          ; 3
    adc     ch0_div_hi          ; 3
    sta     ch0_acc_hi          ; 3
    cmp     ch0_duty            ; 3 - carry set if acc_hi >= duty
    lda     #$00                ; 2
    sbc     #$00                ; 2 - A = $00 if carry, $FF if !carry
    sta     temp_output         ; 3
    
    ; CH1
    lda     ch1_acc_lo          ; 3
    adc     ch1_div_lo          ; 3
    sta     ch1_acc_lo          ; 3
    lda     ch1_acc_hi          ; 3
    adc     ch1_div_hi          ; 3
    sta     ch1_acc_hi          ; 3
    cmp     ch1_duty            ; 3
    lda     #$00                ; 2
    sbc     #$00                ; 2
    ora     temp_output         ; 3 - mix CH0 | CH1
    sta     temp_output         ; 3
    
    ; CH2
    lda     ch2_acc_lo          ; 3
    adc     ch2_div_lo          ; 3
    sta     ch2_acc_lo          ; 3
    lda     ch2_acc_hi          ; 3
    adc     ch2_div_hi          ; 3
    sta     ch2_acc_hi          ; 3
    cmp     ch2_duty            ; 3
    lda     #$00                ; 2
    sbc     #$00                ; 2
    ora     temp_output         ; 3 - final mix (A = CH0 | CH1 | CH2)
    
    bne     play_sound          ; 2/3
    lda     #$9F                ; 2 - silent
    bne     play_output         ; 3 (always branches)
.play_sound
    lda     #$90                ; 2 - sound
.play_output
    sta     SYSVIA_ORAS         ; 4
    dex                         ; 2
    bne     play_note           ; 3
    dey                         ; 2
    bne     play_note           ; 3
    
.row_finished
    jmp     row

INCLUDE "tracks\lb_zx_tritone.6502" 

.end

SAVE "MAIN",start,end,init

2

(1 replies, posted in Other Platforms)

I’ve been working on converting the Z80 Squeeker Plus engine by utz to the 6502.  A work in progress but getting reasonable results so far.

Drums are very off compared to the Z80, and the pitch still needs some work.

You can see the current progress here:

https://m.youtube.com/watch?v=W1Br7rr8cps

If you’re interested in the code (and can help eliminating bugs / inconsistencies / misinterpretations) this is what I have so far (BeebAsm format for the BBC Micro):

VIA_DDRA    = $FE43
VIA_DDRB    = $FE42
VIA_ORA     = $FE41
VIA_ORB     = $FE40
SN_LOUD     = $90
SN_MUTE     = $9F

SAMPLES_PER_FRAME = 260
SAMPLES_LO = SAMPLES_PER_FRAME AND 255
SAMPLES_HI = SAMPLES_PER_FRAME DIV 256

ORG 0

.seq_ptr        SKIP 2
.row_timer      SKIP 1
.sample_count   SKIP 2
.tmp_mix        SKIP 1
.ctrl_a         SKIP 1
.ctrl_b         SKIP 1
.pat_ptr        SKIP 2
.drum_flag      SKIP 1
.drum_index     SKIP 1
.drum_delay     SKIP 1
.drum_state     SKIP 1

.ch1_f          SKIP 2
.ch1_a          SKIP 2
.ch1_e          SKIP 2
.ch1_d          SKIP 1
.ch1_n          SKIP 1

.ch2_f          SKIP 2
.ch2_a          SKIP 2
.ch2_e          SKIP 2
.ch2_d          SKIP 1
.ch2_n          SKIP 1

.ch3_f          SKIP 2
.ch3_a          SKIP 2
.ch3_e          SKIP 2
.ch3_d          SKIP 1

.ch4_f          SKIP 2
.ch4_a          SKIP 2
.ch4_e          SKIP 2
.ch4_d          SKIP 1
.ch4_s          SKIP 1

ORG $1100
.start
    SEI
    JSR init_hw
    
    LDA #LO(music_data+2)
    STA seq_ptr
    LDA #HI(music_data+2)
    STA seq_ptr+1
    
    JSR fetch_new_pattern
    JMP check_row

.pattern_end 
    LDA seq_ptr
    CLC
    ADC #2
    STA seq_ptr
    BCC p_next
    INC seq_ptr+1
.p_next
    LDY #0
    LDA (seq_ptr),Y
    STA pat_ptr
    INY
    LDA (seq_ptr),Y
    STA pat_ptr+1
    
    LDA pat_ptr
    ORA pat_ptr+1
    BNE check_row
    
    LDA music_data
    STA seq_ptr
    LDA music_data+1
    STA seq_ptr+1
    JMP pattern_end

.check_row
    LDY #0
    LDA (pat_ptr),Y
    CMP #$40
    BEQ pattern_end

.rdseq
    LDA (pat_ptr),Y
    INY
    STA ctrl_a
    LDA (pat_ptr),Y
    INY
    STA row_timer
       
    LDA (pat_ptr),Y
    STA ch2_n
    INY
    LDA (pat_ptr),Y
    STA ch1_n
    INY

    LDA ctrl_a
    LSR A
    BCS ld2
    LDA (pat_ptr),Y
    STA ch1_f
    INY
    LDA (pat_ptr),Y
    STA ch1_f+1
    INY
    LDA (pat_ptr),Y
    STA ch1_e
    INY
    LDA (pat_ptr),Y
    STA ch1_e+1
    INY
    LDA #0
    STA ch1_a
    STA ch1_a+1
    STY tmp_mix
    LDY #0
    LDA (ch1_e),Y
    STA ch1_d
    LDY tmp_mix
.ld2
    LDA ctrl_a
    AND #4
    BNE ld3
    LDA (pat_ptr),Y
    STA ch2_f
    INY
    LDA (pat_ptr),Y
    STA ch2_f+1
    INY
    LDA (pat_ptr),Y
    STA ch2_e
    INY
    LDA (pat_ptr),Y
    STA ch2_e+1
    INY
    LDA #0
    STA ch2_a
    STA ch2_a+1
    STY tmp_mix
    LDY #0
    LDA (ch2_e),Y
    STA ch2_d
    LDY tmp_mix
.ld3
    BIT ctrl_a
    BMI ld4
    LDA (pat_ptr),Y
    STA ch3_f
    INY
    LDA (pat_ptr),Y
    STA ch3_f+1
    INY
    LDA (pat_ptr),Y
    STA ch3_e
    INY
    LDA (pat_ptr),Y
    STA ch3_e+1
    INY
    LDA #0
    STA ch3_a
    STA ch3_a+1
    STY tmp_mix
    LDY #0
    LDA (ch3_e),Y
    STA ch3_d
    LDY tmp_mix
.ld4
    LDA (pat_ptr),Y
    STA ctrl_b
    INY
    INY
    
    LDA #0
    STA drum_flag
    LDA ctrl_b
    AND #$04
    BEQ no_kick
    LDA #1
    STA drum_flag
    LDA #0
    STA drum_index
    STA drum_delay
    LDA #SN_MUTE
    STA drum_state
.no_kick
    LDA ctrl_b
    AND #$80
    BEQ no_hat
    LDA #2
    STA drum_flag
    LDA #0
    STA drum_index
    STA drum_delay
    LDA #SN_MUTE
    STA drum_state
.no_hat
    
    LDA ctrl_b
    AND #$40
    BNE skip4
    LDA (pat_ptr),Y
    STA ch4_f
    INY
    LDA (pat_ptr),Y
    STA ch4_f+1
    INY
    LDA (pat_ptr),Y
    STA ch4_e
    INY
    LDA (pat_ptr),Y
    STA ch4_e+1
    INY
    LDA #0
    STA ch4_a
    STA ch4_a+1
    STY tmp_mix
    LDY #0
    LDA (ch4_e),Y
    STA ch4_d
    LDY tmp_mix
.skip4
    LDA ctrl_b
    AND #1
    STA ch4_s

    TYA
    CLC
    ADC pat_ptr
    STA pat_ptr
    BCC p_adv
    INC pat_ptr+1
.p_adv
    LDA ch1_n
    BEQ ch1_no_noise_smc
    LDA #$6A
    STA ch1_noise_op
    LDA #$EA
    STA ch1_noise_op+1
    JMP ch2_smc
.ch1_no_noise_smc
    LDA #$EA
    STA ch1_noise_op
    STA ch1_noise_op+1
    
.ch2_smc
    LDA ch2_n
    BEQ ch2_no_noise_smc
    LDA #$6A
    STA ch2_noise_op
    LDA #$EA
    STA ch2_noise_op+1
    JMP start_synth
.ch2_no_noise_smc
    LDA #$EA
    STA ch2_noise_op
    STA ch2_noise_op+1
    
.start_synth
    LDA #SAMPLES_LO
    STA sample_count
    LDA #SAMPLES_HI
    STA sample_count+1
    CLC

.synth_loop
    LDA #0
    STA tmp_mix

    \ Channel 1
    LDA ch1_a
    ADC ch1_f
    STA ch1_a
    LDA ch1_a+1
    ADC ch1_f+1
    STA ch1_a+1
.ch1_noise_op
    NOP
    NOP
    ADC ch1_d
    ROL tmp_mix

    \ Channel 2
    LDA ch2_a
    ADC ch2_f
    STA ch2_a
    LDA ch2_a+1
    ADC ch2_f+1
    STA ch2_a+1
.ch2_noise_op
    NOP
    NOP
    ADC ch2_d
    ROL tmp_mix

    \ Channel 3
    LDA ch3_a
    ADC ch3_f
    STA ch3_a
    LDA ch3_a+1
    ADC ch3_f+1
    STA ch3_a+1
    ADC ch3_d
    ROL tmp_mix

    \ Channel 4
    LDA ch4_a
    ADC ch4_f
    STA ch4_a
    LDA ch4_a+1
    ADC ch4_f+1
    STA ch4_a+1
    ADC ch4_d
    ROL tmp_mix

    LDA tmp_mix
    ADC #$0F
    TAX

    CPX #$10
    LDA #SN_MUTE        
    BCS vol_set        
    LDA #SN_LOUD       
.vol_set
    TAY                

    LDX drum_flag
    BEQ output_no_drum 
    
    LDX drum_delay
    BEQ need_new_sample
    DEC drum_delay
    LDA drum_state
    JMP mix_tone_drum
    
.need_new_sample
    LDX drum_flag
    DEX
    BEQ need_load_kick
    DEX
    BEQ need_load_hat
    LDA drum_state
    JMP mix_tone_drum
    
.need_load_kick
    LDX drum_index
    CPX #20
    BCS need_kick_end
    LDA kick_data,X
    STA drum_delay
    INC drum_index
    LDA drum_state
    EOR #$0F
    STA drum_state
    JMP mix_tone_drum

.need_kick_end
    LDA #0
    STA drum_flag
    STA drum_delay
    LDA drum_state
    JMP mix_tone_drum

.need_load_hat
    LDX drum_index
    CPX #20
    BCS need_hat_end
    LDA hat_data,X
    STA drum_delay
    INC drum_index
    LDA drum_state
    EOR #$0F
    STA drum_state
    JMP mix_tone_drum

.need_hat_end
    LDA #0
    STA drum_flag
    STA drum_delay
    LDA drum_state
    JMP mix_tone_drum

.output_no_drum
    TYA                
    STA VIA_ORA
    LDA #0
    STA VIA_ORB
    LDA #8
    STA VIA_ORB
    JMP sample_decrement
    
\ Mix tone and drum
.mix_tone_drum
    STA ctrl_a         
    CPY #SN_LOUD
    BNE drum_only      
    CMP #SN_LOUD
    BNE tone_only       
    LDA #$98            
    JMP output_mixed
.drum_only
    LDA ctrl_a          
    JMP output_mixed
.tone_only
    TYA                 
.output_mixed
    STA VIA_ORA
    LDA #0
    STA VIA_ORB
    LDA #8
    STA VIA_ORB

.sample_decrement
    LDA sample_count
    BNE dec_lo
    DEC sample_count+1
.dec_lo
    DEC sample_count
    LDA sample_count
    ORA sample_count+1
    BEQ update_timer
    JMP synth_loop

.update_timer
    LDY #0
    INC ch1_e
    BNE e1
    INC ch1_e+1
.e1 
    LDA (ch1_e),Y
    CMP #$80
    BEQ e2
    STA ch1_d
.e2 
    INC ch2_e
    BNE e2_skip
    INC ch2_e+1
.e2_skip 
    LDA (ch2_e),Y
    CMP #$80
    BEQ e3
    STA ch2_d
.e3 
    INC ch3_e
    BNE e3_skip
    INC ch3_e+1
.e3_skip 
    LDA (ch3_e),Y
    CMP #$80
    BEQ e4
    STA ch3_d
.e4 
    INC ch4_e
    BNE e4_skip
    INC ch4_e+1
.e4_skip 
    LDA (ch4_e),Y
    CMP #$80
    BEQ slide_proc
    STA ch4_d

.slide_proc
    LDA ch4_s
    BEQ noslide
    LDA ch4_f+1
    LSR A
    TAX
    LDA ch4_f
    ROR A
    TAY
    SEC
    LDA ch4_f
    STY tmp_mix
    SBC tmp_mix
    STA ch4_f
    LDA ch4_f+1
    STX tmp_mix
    SBC tmp_mix
    STA ch4_f+1
.noslide
    DEC row_timer
    BNE play_same_row
    JMP check_row

.play_same_row
    LDA #SAMPLES_LO
    STA sample_count
    LDA #SAMPLES_HI
    STA sample_count+1
    CLC
    JMP synth_loop

.fetch_new_pattern
    LDY #0
    LDA (seq_ptr),Y
    STA pat_ptr
    INY
    LDA (seq_ptr),Y
    STA pat_ptr+1
    
    LDA pat_ptr
    ORA pat_ptr+1
    BNE fetch_done
    
    LDA music_data
    STA seq_ptr
    LDA music_data+1
    STA seq_ptr+1
    JMP fetch_new_pattern
.fetch_done
    RTS

.kick_data
    EQUB 1,1,1,1,2,2,2,2
    EQUB 3,3,3,4,4,4,5,5
    EQUB 6,6,7,7

.hat_data
    EQUB 16,3,12,6,9
    EQUB 20,4,8,2,14
    EQUB 9,17,5,8,12
    EQUB 4,7,16,13,22
    EQUB 5,3,16,3,12

.init_hw
    LDA #$9F
    JSR sn_w
    LDA #$BF
    JSR sn_w
    LDA #$DF
    JSR sn_w
    LDA #$FF
    JSR sn_w
    LDA #$FF
    STA VIA_DDRA
    LDA #$0F
    STA VIA_DDRB
    LDA #$81
    JSR sn_w
    LDA #$00
    JSR sn_w
    RTS
.sn_w
    STA VIA_ORA
    LDX #0
    STX VIA_ORB
    LDX #8
    STX VIA_ORB
    RTS

ORG $2000
    INCLUDE "tracks\Squeeker Plus\1-bit_high_and_rising.asm"
.end
SAVE "MAIN",start,end

Nice job!  Great to see more 6502 examples.  I made a couple of quick ports to the BBC Micro and Acorn Electron.  The timing adjustments probably aren’t correct, but they do play.

https://github.com/NegativeCharge/BBC-Micro-Star-Tip-2

https://github.com/NegativeCharge/Acorn … Star-Tip-2

4

(27 replies, posted in Other Platforms)

Unfortunately I don’t hear any difference.  However, I’ve now ported the code to the Acorn Electron which only has an on/off state for sound (no volume control) and I can hear a recognisable tune - it has a slower 1MHz processor so needs some adjustment.  Based on what I’m hearing there may still be some issues with the pattern parsing.  I’ll look through a disassembly of XXL’s Atari Tritone code to see if there’s anything obviously different.

5

(27 replies, posted in Other Platforms)

utz wrote:

Do you happen to know if setting the frequency of an SN channel will reset its phase?

I may be wrong, but I believe this is only true of the LFSR (which I’m not using here). However, noise phase is reset by frequency writes, volume writes have no effect.

6

(27 replies, posted in Other Platforms)

Thanks - I’ll try outputting to three channels simultaneously next.  I think some of the slowness is probably the values I’m using in the custom .1te engine to output the music data.  I’m not sure I have the right value for CPU time.

I’ve put the code I have so far on GitHub: https://github.com/NegativeCharge/Beeb-Tritone-Player

7

(27 replies, posted in Other Platforms)

A quick update - I’ve now got this partially working… it’s playing back too slow, is fairly quiet and there’s a high pitched whine in the background.  However, it’s making a recognisable sound now :-)  Thanks utz!

The issue was that the SN volume value needs to flip between 0x0 and 0xf rather than 0xff.  I added an AND 0xf before each ORA for each channel.

I now need to alter the speed and optimize the data read somehow.

8

(27 replies, posted in Other Platforms)

Thank you utz.  Once I have something working I may take another look at the data format.  Here's the revised code - I still suspect something wrong with the duty or frequency parsing

;Tritone beeper music engine
;Original Z80 code by Shiru 03'2011, released as Public Domain
;1tracker version by Shiru 03'2018
;6502 engine port by utz 03'2024
;Ported to the BBC Micro by Negative Charge 03'2024

; Constants
OSBYTE                  = $FFF4
OSWRCH                  = $FFEE
OSNEWL                  = $FFE7
SHEILABASE              = $FE00             ; System peripherals
SYSVIA_DDRA             = SHEILABASE + $43  ; Data direction register A
SYSVIA_ORAS             = SHEILABASE + $4F  ; Same as REGA but with no handshake I/O
SYSVIA_REGB             = SHEILABASE + $40  ; Port B I/O

DISPLAY_START           = $7c00
DEBUG                   = TRUE
ROW_DEBUG               = FALSE

OP_NOP                  = $EA
OP_ROL_A                = $2A

; Zero Page
ORG     $5f
GUARD   $8f

.vars_start

.loop_ptr           SKIP 2
.pattern_ptr        SKIP 2
.speed              SKIP 2

.drum               SKIP 1

.vars_end

ORG     &1100
GUARD   DISPLAY_START

.start

INCLUDE "lib\os.s.6502" 

; Write data to sound chip then add processing delay
MACRO sound_write_slow
    sta     SYSVIA_ORAS        ;4 Write reg/data to SN76489

    lda     #%00000000         ;2
    sta     SYSVIA_REGB        ;4 
    nop                        ;2
    nop                        ;2
    nop                        ;2
    lda     #%00001000         ;2
    sta     SYSVIA_REGB        ;4
ENDMACRO

MACRO RESET_SOUND_CHIP
    ; Zero volumes on all SN76489 channels, just in case anything already playing
    lda     #%11111111
    sound_write_slow                                ; Channel 3 (Noise)
    lda     #%11011111
    sound_write_slow                                ; Channel 2
    lda     #%10111111
    sound_write_slow                                ; Channel 1
    lda     #%10011111
    sound_write_slow                                ; Channel 0
ENDMACRO

.init
    ; Print Track Title
    ldx     #1
    ldy     #22
    jsr     moveTextCursor

    jsr     printString
    equs    "The Liberty Bell",0

    ; Print Track Artist
    ldx     #1
    ldy     #24
    jsr     moveTextCursor

    jsr     printString
    equs    "John Philip Sousa",0

    ; Set up audio
    
    ; System VIA port A to all outputs
    lda     #%11111111
    sta     SYSVIA_DDRA

    sei

    RESET_SOUND_CHIP

    ; Period to 1 on tone channel 0
    lda     #%10000001
    sound_write_slow                                ; Channel 0
    lda     #%00000000
    sound_write_slow

    ; System VIA Port A, place accumulator on wires, no handshake
    lda     #%00000000         
    sta     SYSVIA_REGB

    lda     #LO(music_data)
    ldx     #HI(music_data)

.play

    pha
    txa
    pha
    
    lda     #0
    tax
.zero_page_reset_loop
    sta     vars_start,x
    inx
    cpx     #vars_end-vars_start
    bne     zero_page_reset_loop
    
    pla
    sta     pattern_ptr+1
    pla
    sta     pattern_ptr+0

IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #1
        jsr     moveTextCursor
        jsr     printString
        equs    "Pattern Pointer: ",0

        lda     pattern_ptr+1
        jsr     s_print_hex
        lda     pattern_ptr+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

    ldy     #0
    lda     (pattern_ptr),y
    sta     loop_ptr+0

    iny
    lda     (pattern_ptr),y
    sta     loop_ptr+1
    
IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #2
        jsr     moveTextCursor

        jsr     printString
        equs    "Loop Pointer   : ",0

        lda     loop_ptr+1
        jsr     s_print_hex
        lda     loop_ptr+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

    lda     pattern_ptr+0
    clc
    adc     #6
    sta     pattern_ptr+0
    bcc     play_loop
    inc     pattern_ptr+1

.play_loop

    ldy     #1
    lda     (pattern_ptr),y
    bne     no_loop
    
.return_loop

    lda     loop_ptr+0
    sta     pattern_ptr+0
    lda     loop_ptr+1
    sta     pattern_ptr+1
    jmp     play_loop

.no_loop
    iny
    lda     (pattern_ptr),y
    iny
    sta     speed+0
    sta     row_length_lo
    lda     (pattern_ptr),y
    iny
    sta     speed+1
    sta     row_length_hi

IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #4
        jsr     moveTextCursor

        jsr     printString
        equs    "Speed          : ",0

        lda     speed+1
        jsr     s_print_hex
        lda     speed+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

jmp     row

.pattern_end
    cli                             ; Enable interrupts

    RESET_SOUND_CHIP

    rts

.row
    ldy     #0
    lda     (pattern_ptr),y
    bne     ch0

    sta     drum                    ; Silent
    sta     ch0_duty
    sta     ch0_div_lo
    sta     ch0_div_hi
    jmp     skip_ch0

.ch0
    cmp     #$ff
    beq     pattern_end
    cmp     #$01
    beq     skip_ch0                ; Same as previous ch0 entry
    cmp     #$80
    bcc     skip_drum
    sta     drum

    iny
    lda     (pattern_ptr),y

.skip_drum
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch0_duty
    pla

    ora     #%00001111
    sta     ch0_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch0_div_lo

.skip_ch0
    iny
    lda     (pattern_ptr),y
    bne     ch1             

    sta     ch1_duty
    sta     ch1_div_lo
    sta     ch1_div_hi
    jmp     skip_ch1

.ch1
    cmp     #$01
    beq     skip_ch1                ; Same as previous ch0 entry
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch1_duty
    pla

    ora     #%00001111
    sta     ch1_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch1_div_lo

.skip_ch1
    iny
    lda     (pattern_ptr),y
    bne     ch2
    
    sta     ch2_duty
    sta     ch2_div_lo
    sta     ch2_div_hi
    jmp     skip_ch2

.ch2
    cmp     #$01
    beq     skip_ch2                ; Same as previous ch0 entry
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch2_duty
    pla

    ora     #%00001111
    sta     ch2_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch2_div_lo

.skip_ch2
    tya

row_length_lo=*+1
    ldx     #0                     ;   reset row length counter lo byte
row_length_hi=*+1
    ldy     #0

IF ROW_DEBUG
    jsr     printRowInfo
ENDIF

    clc
    adc     pattern_ptr+0
    sta     pattern_ptr+0
    bcc     play_note
    inc     pattern_ptr+1

.play_note

    clc                             ;2  update osc

ch0_div_lo=*+1
    lda     #$0                     ;2
ch0_acc_lo=*+1
    adc     #$0                     ;2
    sta ch0_acc_lo                  ;4
ch0_div_hi=*+1
    lda     #$0                     ;2
ch0_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch0_acc_hi              ;4
ch0_duty=*+1
    cmp     #$0                     ;2  compare against duty threshold
    sbc     ch0_acc_hi              ;4  A = 0 on low half-cycle, FF on hi half-cycle
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;4

    clc                             ;2
ch1_div_lo=*+1
    lda     #$0                     ;2
ch1_acc_lo=*+1
    adc     #$0                     ;2
    sta     ch1_acc_lo              ;4
ch1_div_hi=*+1
    lda     #$0                     ;2
ch1_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch1_acc_hi              ;4
ch1_duty=*+1
    cmp     #$0                     ;2
    sbc     ch1_acc_hi              ;4
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;4

    clc                             ;2
ch2_div_lo=*+1
    lda     #$0                     ;2
ch2_acc_lo=*+1
    adc     #$0                     ;2
    sta     ch2_acc_lo              ;4
ch2_div_hi=*+1
    lda     #$0                     ;2
ch2_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch2_acc_hi              ;4
ch2_duty=*+1
    cmp     #$0                     ;2
    sbc     ch2_acc_hi              ;4
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;2

    dex                             ;2  row length low byte
    bne     play_note               ;3 -- 95 ~ 21053Hz (original is 22876Hz)

    dey                             ; row length hi byte
    bne     play_note

    jmp     row

.s_print_hex
        pha                            ; Save A
        lsr     a
        lsr     a
        lsr     a
        lsr     a                      ; Move top nybble to bottom nybble
        jsr     printNybble
        pla
        and     #&0f                   ; Mask out original bottom nybble
.printNybble
        sed
        clc
        adc     #&90                   ; Produce &90-&99 or &00-&05
        adc     #&40                   ; Produce &30-&39 or &41-&46
        cld
        jmp     OSWRCH                 ; Print it

.printRowInfo

        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #8
        jsr     moveTextCursor

        jsr     printString
        equs    "Row: ",0

        lda     ch0_div_hi
        jsr     s_print_hex
        lda     ch0_div_lo
        jsr     s_print_hex

        ldx     #11
        ldy     #8
        jsr     moveTextCursor
        
        lda     ch1_div_hi
        jsr     s_print_hex
        lda     ch1_div_lo
        jsr     s_print_hex
        
        ldx     #16
        ldy     #8
        jsr     moveTextCursor

        lda     ch2_div_hi
        jsr     s_print_hex
        lda     ch2_div_lo
        jsr     s_print_hex

        pla:tay:pla:tax:pla

        rts

INCLUDE "tracks\liberty_bell_tritone.6502" 

.end

SAVE "MAIN",start,end,init

\ ******************************************************************
\ *    Memory Info
\ ******************************************************************

PRINT "-----------------------"
PRINT " 1-BIT TRITONE PLAYER  "
PRINT "-----------------------"
PRINT "CODE size       = ", ~end-start
PRINT "-----------------------"
PRINT "HIGH WATERMARK  = ", ~P%
PRINT "FREE            = ", ~start+end
PRINT "-----------------------"

\ ******************************************************************
\ * Supporting Files
\ ******************************************************************

PUTBASIC "loader.bas","LOADER"
PUTFILE  "screens\title.bin","TITLE",DISPLAY_START
PUTFILE  "BOOT","!BOOT",$ffff

9

(27 replies, posted in Other Platforms)

For standard Tritone there only appears to be a global speed setting? - Tritone Digi has per-row.

Is the speed the value that should be plugged into the row length counter?… and if so should that be bne play_note rather than beq play_note?

I’ve tried this but still just getting a high pitched note currently.

Thanks

10

(27 replies, posted in Other Platforms)

utz wrote:

One thing I spotted skimming through quickly is that you're loading a drum marker per tone channel, but there's only one global drum channel in Tritone.

Thanks - I've corrected that.  I'm still getting the same high pitched output though.

11

(27 replies, posted in Other Platforms)

Hi utz,

I've given this a go, but I think I'm either doing something wrong iterating through the pattern data or I've messed up the play loop - all I'm getting is a high pitched squeal, and a few clicks.

I'm using Shiru's data export from 1tracker, so the format should be familiar.

I think (based on the tritone.1te) that I may be misinterpreting how the duty and frequency are being stored.

Is there anything obvious in the below code that jumps out at you as incorrect?

Thanks! 

;Tritone beeper music engine
;Original Z80 code by Shiru 03'2011, released as Public Domain
;1tracker version by Shiru 03'2018
;6502 engine port by utz 03'2024
;Ported to the BBC Micro by Negative Charge 03'2024

; Constants
OSBYTE                  = $FFF4
OSWRCH                  = $FFEE
OSNEWL                  = $FFE7
SHEILABASE              = $FE00             ; System peripherals
SYSVIA_DDRA             = SHEILABASE + $43  ; Data direction register A
SYSVIA_ORAS             = SHEILABASE + $4F  ; Same as REGA but with no handshake I/O
SYSVIA_REGB             = SHEILABASE + $40  ; Port B I/O

DISPLAY_START           = $7c00
DEBUG                   = TRUE

OP_NOP                  = $EA
OP_ROL_A                = $2A

; Zero Page
ORG     $5f
GUARD   $8f

.vars_start

.loop_ptr           SKIP 2
.pattern_ptr        SKIP 2
.speed              SKIP 2

.ch0_drum           SKIP 1
.ch1_drum           SKIP 1
.ch2_drum           SKIP 1

.vars_end

ORG     &1100
GUARD   DISPLAY_START

.start

INCLUDE "lib\os.s.6502" 

; Write data to sound chip then add processing delay
MACRO sound_write_slow
    sta     SYSVIA_ORAS        ;4 Write reg/data to SN76489

    lda     #%00000000         ;2
    sta     SYSVIA_REGB        ;4 
    nop                        ;2
    nop                        ;2
    nop                        ;2
    lda     #%00001000         ;2
    sta     SYSVIA_REGB        ;4
ENDMACRO

MACRO RESET_SOUND_CHIP
    ; Zero volumes on all SN76489 channels, just in case anything already playing
    lda     #%11111111
    sound_write_slow                                ; Channel 3 (Noise)
    lda     #%11011111
    sound_write_slow                                ; Channel 2
    lda     #%10111111
    sound_write_slow                                ; Channel 1
    lda     #%10011111
    sound_write_slow                                ; Channel 0
ENDMACRO

.init
    \ Print Track Title
    ldx     #1
    ldy     #22
    jsr     moveTextCursor

    jsr     printString
    equs    "The Liberty Bell",0

    \ Print Track Artist
    ldx     #1
    ldy     #24
    jsr     moveTextCursor

    jsr     printString
    equs    "John Philip Sousa",0

    ; Set up audio
    
    ; System VIA port A to all outputs
    lda     #%11111111
    sta     SYSVIA_DDRA

    sei

    RESET_SOUND_CHIP

    ; Period to 1 on tone channel 0
    lda     #%10000001
    sound_write_slow                                ; Channel 0
    lda     #%00000000
    sound_write_slow

    ; System VIA Port A, place accumulator on wires, no handshake
    lda     #%00000000         
    sta     SYSVIA_REGB

    lda     #LO(music_data)
    ldx     #HI(music_data)

.play

    pha
    txa
    pha
    
    lda     #0
    tax
.zero_page_reset_loop
    sta     vars_start,x
    inx
    cpx     #vars_end-vars_start
    bne     zero_page_reset_loop
    
    pla
    sta     pattern_ptr+1
    pla
    sta     pattern_ptr+0

IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #1
        jsr     moveTextCursor
        jsr     printString
        equs    "Pattern Pointer: ",0

        lda     pattern_ptr+1
        jsr     s_print_hex
        lda     pattern_ptr+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

    ldy     #0
    lda     (pattern_ptr),y
    sta     loop_ptr+0

    iny
    lda     (pattern_ptr),y
    sta     loop_ptr+1
    
IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #2
        jsr     moveTextCursor

        jsr     printString
        equs    "Loop Pointer   : ",0

        lda     loop_ptr+1
        jsr     s_print_hex
        lda     loop_ptr+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

    lda     pattern_ptr+0
    clc
    adc     #6
    sta     pattern_ptr+0
    bcc     play_loop
    inc     pattern_ptr+1

.play_loop

    ldy     #1
    lda     (pattern_ptr),y
    bne     no_loop
    
.return_loop

    lda     loop_ptr+0
    sta     pattern_ptr+0
    lda     loop_ptr+1
    sta     pattern_ptr+1
    jmp     play_loop

.no_loop
    iny
    lda     (pattern_ptr),y
    iny
    sta     speed+0
    lda     (pattern_ptr),y
    iny
    sta     speed+1

IF DEBUG
        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #4
        jsr     moveTextCursor

        jsr     printString
        equs    "Speed          : ",0

        lda     speed+1
        jsr     s_print_hex
        lda     speed+0
        jsr     s_print_hex
        jsr     OSNEWL

        pla:tay:pla:tax:pla
ENDIF

jmp     row

.pattern_end
    cli     ; Enable interrupts

    RESET_SOUND_CHIP

    rts

.row
    ldy     #0
    lda     (pattern_ptr),y
    bne     ch0

    sta     ch0_drum        ; Silent
    sta     ch0_duty
    sta     ch0_div_lo
    sta     ch0_div_hi
    jmp     skip_ch0

.ch0
    cmp     #$ff
    beq     pattern_end
    cmp     #$01
    beq     skip_ch0        ; Same as previous ch0 entry
    cmp     #$80
    bcc     skip_drum_0
    sta     ch0_drum

    iny
    lda     (pattern_ptr),y

.skip_drum_0
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch0_duty
    pla

    ora     #%00001111
    sta     ch0_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch0_div_lo

.skip_ch0
    iny
    lda     (pattern_ptr),y
    bne     ch1             

    sta     ch1_drum        ; Silent
    sta     ch1_duty
    sta     ch1_div_lo
    sta     ch1_div_hi
    jmp     skip_ch1

.ch1
    cmp     #$01
    beq     skip_ch1        ; Same as previous ch0 entry
    cmp     #$80
    bcc     skip_drum_1
    sta     ch1_drum

    iny
    lda     (pattern_ptr),y

.skip_drum_1
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch1_duty
    pla

    ora     #%00001111
    sta     ch1_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch1_div_lo

.skip_ch1
    iny
    lda     (pattern_ptr),y
    bne     ch2

    sta     ch2_drum        ; Silent
    sta     ch2_duty
    sta     ch2_div_lo
    sta     ch2_div_hi
    jmp     skip_ch2

.ch2
    cmp     #$01
    beq     skip_ch2        ; Same as previous ch0 entry
    cmp     #$80
    bcc     skip_drum_2
    sta     ch2_drum

    iny
    lda     (pattern_ptr),y

.skip_drum_2
    pha
    lsr     a
    lsr     a
    lsr     a
    lsr     a
    sta     ch2_duty
    pla

    ora     #%00001111
    sta     ch2_div_hi

    iny
    lda     (pattern_ptr),y
    sta     ch2_div_lo

.skip_ch2
    tya
    clc
    adc     pattern_ptr+0
    sta     pattern_ptr+0
    bcc     play_note
    inc     pattern_ptr+1

.play_note

IF DEBUG
    jsr     printRowInfo
ENDIF

    clc                             ;2  update osc

ch0_div_lo=*+1
    lda     #$0                     ;2
ch0_acc_lo=*+1
    adc     #$0                     ;2
    sta ch0_acc_lo                  ;4
ch0_div_hi=*+1
    lda     #$0                     ;2
ch0_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch0_acc_hi              ;4
ch0_duty=*+1
    cmp     #$0                     ;2  compare against duty threshold
    sbc     ch0_acc_hi              ;4  A = 0 on low half-cycle, FF on hi half-cycle
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;4

    clc                             ;2
ch1_div_lo=*+1
    lda     #$0                     ;2
ch1_acc_lo=*+1
    adc     #$0                     ;2
    sta     ch1_acc_lo              ;4
ch1_div_hi=*+1
    lda     #$0                     ;2
ch1_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch1_acc_hi              ;4
ch1_duty=*+1
    cmp     #$0                     ;2
    sbc     ch1_acc_hi              ;4
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;4

    clc                             ;2
ch2_div_lo=*+1
    lda     #$0                     ;2
ch2_acc_lo=*+1
    adc     #$0                     ;2
    sta     ch2_acc_lo              ;4
ch2_div_hi=*+1
    lda     #$0                     ;2
ch2_acc_hi=*+1
    adc     #$0                     ;2
    sta     ch2_acc_hi              ;4
ch2_duty=*+1
    cmp     #$0                     ;2
    sbc     ch2_acc_hi              ;4
    ora     #%10010000              ;2
    sta     SYSVIA_ORAS             ;2

    jmp     row

.s_print_hex
        pha                            ; Save A
        lsr     a
        lsr     a
        lsr     a
        lsr     a                      ; Move top nybble to bottom nybble
        jsr     printNybble
        pla
        and     #&0f                   ; Mask out original bottom nybble
.printNybble
        sed
        clc
        adc     #&90                   ; Produce &90-&99 or &00-&05
        adc     #&40                   ; Produce &30-&39 or &41-&46
        cld
        jmp     OSWRCH                 ; Print it

.printRowInfo

        pha:txa:pha:tya:pha

        ldx     #1
        ldy     #8
        jsr     moveTextCursor

        jsr     printString
        equs    "Row: ",0

        lda     ch0_div_hi
        jsr     s_print_hex
        lda     ch0_div_lo
        jsr     s_print_hex

        ldx     #11
        ldy     #8
        jsr     moveTextCursor
        
        lda     ch1_div_hi
        jsr     s_print_hex
        lda     ch1_div_lo
        jsr     s_print_hex
        
        ldx     #16
        ldy     #8
        jsr     moveTextCursor

        lda     ch2_div_hi
        jsr     s_print_hex
        lda     ch2_div_lo
        jsr     s_print_hex

        pla:tay:pla:tax:pla

        rts

INCLUDE "tracks\liberty_bell_tritone.6502" 

.end

SAVE "MAIN",start,end,init

\ ******************************************************************
\ *    Memory Info
\ ******************************************************************

PRINT "-----------------------"
PRINT " 1-BIT TRITONE PLAYER  "
PRINT "-----------------------"
PRINT "CODE size       = ", ~end-start
PRINT "-----------------------"
PRINT "HIGH WATERMARK  = ", ~P%
PRINT "FREE            = ", ~start+end
PRINT "-----------------------"

\ ******************************************************************
\ * Supporting Files
\ ******************************************************************

PUTBASIC "loader.bas","LOADER"
PUTFILE  "screens\title.bin","TITLE",DISPLAY_START
PUTFILE  "BOOT","!BOOT",$ffff

12

(27 replies, posted in Other Platforms)

Thanks utz!

That’s a great starting point.  I’ll try and find some time over the next few days to experiment with it.  I think I can use similar code to read the data as SquatM.

In the meantime I added some of your suggestions to the BBC Micro SquatM engine here: https://github.com/NegativeCharge/BBC-M … /main.6502

I couldn’t get it to work without the volume latch, but at least the high pitched noise has gone now.

I’ll let you know how I get on, and hopefully post a sample,

13

(27 replies, posted in Other Platforms)

utz wrote:

Sorry, I meant taking this even further: only ora #%10010000 at the beginning, and then just use the active latch to set the lower 4 bits, without needing to set channel and type again. Though considering how quiet the SN is at the 50% base volume we get by setting period to 1, it might be necessary to actually set multiple channels at once.

Ah, I see.  Yes, you can do that, and it does work - maybe some other adjustments need to be made as although the sound is less muffled, the noise appears to become high pitched.

14

(27 replies, posted in Other Platforms)

Hi utz,

utz wrote:

Ah, so we're targetting SN76489. I assumed there might be some sort of native device.

The BBC Micro uses an SN76489.  The Acorn Electron has no dedicated hardware for sound - it uses a ULA.  I can adapt the code for the Electron fairly easily once there's a working SN76489 version.

utz wrote:

Would it be acceptable to leave Port B I/O in WRITE mode and only switch to READing between pattern rows? That would speed up things quite a bit.

Yes!  I just tested that with the SquatM engine and it makes quite a difference.  Here's a video of the playback: https://youtu.be/sqFRGEz9g_U

utz wrote:

Also, am I correct in assuming that I could just keep pumping out DATA bytes (LATCH = 0) to set the volume of a given channel?

That's correct - it's pretty much what the SquatM engine is doing:

    ora     #%10010000         ; bit-7 (latch/data), bits-6/5 (channel - 0), bit 4 (type - latch volume)
    sound_write_slow             ; output sound bit

Thanks

15

(27 replies, posted in Other Platforms)

Thank you utz!  I’m fairly limited on memory (32kb) without using swram banks, but I can try decompressing at runtime.

With regards to how the BBC Micro disables interrupts and emits sound, here’s a port I made of Shiru’s SquatM engine:

https://github.com/NegativeCharge/BBC-M … /main.6502

ZP can start at zero, but is $5f to $8f in the above.  Code is normally compiled to $1100 to allow disk access, but can drop to $e00 depending on the file system.  The code above is in BeebAsm format but should be easy enough to switch to other compilers.

Thanks!

16

(27 replies, posted in Other Platforms)

utz wrote:

Eh, finally some good news. Yes, this can be done. If you can generate the bitstream from the LFSR, you can convert it to SquatM's PWM sample format, which is basically just a bitstream with run length encoding. So eg. %1111000000011000000111000011 becomes 2,4,3,6,2,7,4,0 - the final 0 is the end marker.

Thank you!  I'll investigate this.  For the fixed white noise there is info here I'll look into: https://www.smspower.org/Development/SN … ftRegister

For now, I've crudely mapped these to the SquatM Noise percussion, which works but doesn't give the same force that sampled drums would.

I've attached another example C64 SID conversion based on 4-Mat's Empty (512 bytes) track (Original here: https://deepsid.chordian.net/?file=/MUS … bytes.sid)

17

(27 replies, posted in Other Platforms)

bushy555 wrote:

Will the converter be released?  Would love to hear how "A Mind Is Born" comes out. I love that!

6502 : Look at the Peskysound engine within 1Tracker. For the PET which also runs the 6502.

Thanks - yes, I do plan on releasing the converters once I’ve finished a frontend for them.  At the moment it’s a manual workflow involving up to 10 scripts.

I tried “A Mind Is Born” but it seems to heavily rely upon filters, modulation and volume changes, so isn’t a great fit.  The first 30+ seconds translate to the same couple of notes playing without the filters.  I need to think about how to support them.

Thanks for the suggestion on the Peskysound engine. I’ll take a look.

18

(27 replies, posted in Other Platforms)

I've been experimenting with the SquatM engine on two reasonably popular 6502 8-bit systems in the UK in the 1980's.  I've built a number of converters from various PSG chips that I can then transform to the .1tm format.  To start with I took a simple C64 SID file (https://deepsid.chordian.net/?file=/MUS … af_Rag.sid) and transformed this into the attached .1tm file.

You can hear this playing back a BBC Micro emulator here: https://twitter.com/charge_negative/sta … 7711753485

I'm wondering if there are options to optimize this file automatically, as compiled with player is over 27kb (out of 32kb available)?

I'm also interested in whether any of the other engines have been ported to the 6502 (or variants) with source code available?  My Z80 knowledge to do this myself isn't up to the task.

Finally, a long shot but does anyone have ideas on how to convert SN76489 LFSR noise to SquatM noise/percussion? (fixed rather than tuned).

Thanks,

Negative Charge