Shop OBEX P1 Docs P2 Docs Learn Events
Has anyone gotten the AYcog demo to work with the C3? — Parallax Forums

Has anyone gotten the AYcog demo to work with the C3?

cbmeekscbmeeks Posts: 634
edited 2015-04-20 01:29 in Propeller 1
Just got my C3 today.

I copied the cybernet.ym file to a microSD card and tried to modify the ExampleAyDumpPlay.spin demo to work with the C3.

I have verified that the SD card is working as I can list the contents of the card. Plus, it correctly identifies the size of the file.

The only audio I hear is what sounds like a constant thrashing sound. Oh, I have copied the relevant C3 source files over to the same directory.

Here is what I am using:
'
' A minimalistic AY/YM dump player.

CON _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000
    
    playRate = 50'Hz 
    rightPin = 24
    leftPin  = 24
                       
VAR
    byte  buffer[100]
    
    long filehandle[4] ' generic file handle first_cluster, file_length, curr_pos, directory_entry
    byte filename[16]
    
    long diskbuff_ptr ' generic disk sector buffer, initialized by call to SD driver's Start
    long mbrbuff_ptr  ' master boot record buffer , initialized by call to SD driver's Start
    long pbrbuff_ptr  ' partition boot record     , initialized by call to SD driver's Start

OBJ
    AY : "AYcog"
    SD : "c3_sd_drv_010" 
                                                      
PUB Main | bytes_read, display_bytes, index

    ay.start(rightPin, leftPin)           ' Start the emulated AY/YM in a cog

    sd.Start(@diskbuff_ptr)
    sd.tvt_pstring(STRING("AY Music Demo"))
    sd.tvt_out($0D)
    sd.tvt_out($0D)
    
    sd.Set_Debug_Level (sd#DEBUG_OFF)
    sd.tvt_pstring(STRING("Initializing SPI interface..."))
    sd.tvt_out($0D)
    sd.tvt_out($0D)
    
    sd.SPI_Init(0)
    sd.SD_Mount
    sd.FAT_Read_MBR(mbrbuff_ptr)
    sd.FAT_Load_Partition_Entry(0, mbrbuff_ptr)
    sd.FAT_Load_Partition_Boot_Rec(pbrbuff_ptr)
    
'    sd.FAT_Print_Directory

    sd.tvt_out($0D)
    sd.tvt_out($0D)
    sd.tvt_pstring(string("Playing music..."))
    
    if ( sd.FAT_File_Open( string("cybernet.ym"), @filehandle) <> -1)
        repeat index from 0 to (filehandle[1]-1) step 16
            waitcnt(cnt + (clkfreq/playRate))   ' Wait one VBL
            bytes_read := sd.FAT_File_Read(@filehandle, diskbuff_ptr, 16)
            ay.updateRegisters(@bytes_read)     ' Write 16 byte to AYcog

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2015-04-18 03:36
    Shouldn't that be ay.updateRegisters(diskbuff_ptr)? Also, the update is better placed directly after the waitcnt (file read before).
  • cbmeekscbmeeks Posts: 634
    edited 2015-04-19 12:43
    Hmm. Still no luck.

    I have changed the code to:
    '
    ' A minimalistic AY/YM dump player.
    
    CON _clkmode = xtal1 + pll16x
        _xinfreq = 5_000_000
        
        playRate = 50'Hz 
        rightPin = 24
        leftPin  = 24
                           
    VAR
        byte  buffer[100]
        
        long filehandle[4] ' generic file handle first_cluster, file_length, curr_pos, directory_entry
        byte filename[16]
        
        long diskbuff_ptr ' generic disk sector buffer, initialized by call to SD driver's Start
        long mbrbuff_ptr  ' master boot record buffer , initialized by call to SD driver's Start
        long pbrbuff_ptr  ' partition boot record     , initialized by call to SD driver's Start
    
    OBJ
        AY : "AYcog"
        SD : "c3_sd_drv_010" 
                                                          
    PUB Main | bytes_read, display_bytes, index
    
        ay.start(rightPin, leftPin)           ' Start the emulated AY/YM in a cog
    
        sd.Start(@diskbuff_ptr)
        sd.tvt_pstring(STRING("AY Music Demo"))
        sd.tvt_out($0D)
        sd.tvt_out($0D)
        
        sd.Set_Debug_Level (sd#DEBUG_OFF)
        sd.tvt_pstring(STRING("Initializing SPI interface..."))
        sd.tvt_out($0D)
        sd.tvt_out($0D)
        
        sd.SPI_Init(0)
        sd.SD_Mount
        sd.FAT_Read_MBR(mbrbuff_ptr)
        sd.FAT_Load_Partition_Entry(0, mbrbuff_ptr)
        sd.FAT_Load_Partition_Boot_Rec(pbrbuff_ptr)
        
    '    sd.FAT_Print_Directory
    
        sd.tvt_out($0D)
        sd.tvt_out($0D)
        sd.tvt_pstring(string("Playing music..."))
        
        if ( sd.FAT_File_Open( string("cybernet.ym"), @filehandle) <> -1)
            repeat index from 62 to (filehandle[1]-1) step 16
                bytes_read := sd.FAT_File_Read(@filehandle, diskbuff_ptr, 16)
                waitcnt(cnt + (clkfreq/playRate))   ' Wait one VBL
                ay.updateRegisters(diskbuff_ptr)    ' Write 16 byte to AYcog
    

    But all I get is silence.
  • kuronekokuroneko Posts: 3,623
    edited 2015-04-20 01:29
    Well, the update method expects the buffer address (pointing at a buffer of size 16). I guess it's time to dump the buffer returned from FAT_File_Read to eliminate that as the culprit.

    Based on the original demo (OBEX) the dump file has its header skipped (62 bytes). Where does this happen in your code (I'd expect it after the open call)?
Sign In or Register to comment.