SID´s adventure in P2 land

2»

Comments

  • Good work :) Maybe later this year I will be able to try the P2...

    Using real MUL in P1V clocked at 114 MHz gave me 64 kHz sample rate for SIDCog. Here we have up to 300 (?) MHz and 2 cycles instead of 4 for an instruction... 250 MHz seems to be available even using the original code (minus mul procedure).

    I wrote a SIDCog inspired SID emulator for the Rasperry Pi (in a bare metal enviroment, without OS). My assembly code is not optimized and much more complex than the SIDCog; it uses about 30% of one ARM CPU core @ 1.2 GHz running SID at 960 kHz... maybe a full speed SID emulator wil be possible on a 300 MHz clocked P2 when optimized?...
  • I have already achieved 250 kHz @ 190 MHz. Mostly thanks to hardware mul and direct access of word, byte, nibble types in cog memory. (no more shifting, masking and juggling with bits). Still there are a lot of potential optmizations possible on the P2! 😀
    I Will upload a new version when I have cleaned the code up a little bit.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • samuellsamuell Posts: 261
    edited 2019-01-17 - 22:12:04
    Nicely done, Ahle2! However, some (or most) pins will just send noise. Edited code to use pins 32 and 34, since they are contiguous and near one of the ground pins. That way, I can easily connect the P2 to an ampifier.

    Anyways, is there any hardware limitation regarding the pins to be used? Or in theory, any pin should work and my P2 is defective?

    Kind regards, Samuel Lourenço
  • Ahle2 wrote: »
    I have already achieved 250 kHz @ 190 MHz. Mostly thanks to hardware mul and direct access of word, byte, nibble types in cog memory. (no more shifting, masking and juggling with bits). Still there are a lot of potential optmizations possible on the P2! 😀
    I Will upload a new version when I have cleaned the code up a little bit.

    So it seems 490 kHz is possible. 490 kHz is good enough (I tried this with RPi)

    We can build a lot of retroemulators with P2 :) It seems C64 and 8-bit Atari can be done with it.
  • samuell wrote: »
    Nicely done, Ahle2! However, some (or most) pins will just send noise. Edited code to use pins 32 and 34, since they are contiguous and near one of the ground pins. That way, I can easily connect the P2 to an ampifier.

    Anyways, is there any hardware limitation regarding the pins to be used? Or in theory, any pin should work and my P2 is defective?

    Kind regards, Samuel Lourenço

    Any pin should work, I don't know what you are seeing. Strange indeed!
    pik33 wrote: »
    Ahle2 wrote: »
    I have already achieved 250 kHz @ 190 MHz. Mostly thanks to hardware mul and direct access of word, byte, nibble types in cog memory. (no more shifting, masking and juggling with bits). Still there are a lot of potential optmizations possible on the P2! 😀
    I Will upload a new version when I have cleaned the code up a little bit.

    So it seems 490 kHz is possible. 490 kHz is good enough (I tried this with RPi)

    We can build a lot of retroemulators with P2 :) It seems C64 and 8-bit Atari can be done with it.

    Yes, the P2 is an amazing platform and I'm looking forward to do a lot of "retro" things with it. A lot more could have been done on the P1 regarding emulation and retro stuff if it just did have a little bit more memory. C64, NES and Atari 8 bit emulation, etc would have been possible with more memory. I'm sure!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Here is the 250 kHz version of SIDcog for the P2 and a 96 kHz wav sample for those who can't run it themselves.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Ahle2 wrote: »
    Here is the 250 kHz version of SIDcog for the P2 and a 96 kHz wav sample for those who can't run it themselves.
    That loads and works as well as before. Thanks!

    Kind regards, Samuel Lourenço
  • Samuel, did you find out what was wrong with the pin configuration? I have not tried a lot of different pins with my code.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • samuellsamuell Posts: 261
    edited 2019-01-26 - 13:53:07
    Ahle2 wrote: »
    Samuel, did you find out what was wrong with the pin configuration? I have not tried a lot of different pins with my code.
    No, I didn't. The only "breakthrough" is that I can't hear any noise if I change the supply to those pins from VIO to 3V3 (DC-DC to LDO, essentially). So, it seems that the pins produce no sound and the noise comes from the DC-DC. Haven't tried this with the new version, though.

    Kind regards, Samuel Lourenço
  • @samuel

    When connecting the new accessory AV board (and was forced to change the pin configuration) I discovered that the wait for selectable event mechanism locks up when using certain pins.... strange! I'm not sure whether it's my fault or the hardware. Probably mine!

    That's the reason why you couldn't get audio on certain pins!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Ahle2Ahle2 Posts: 945
    edited 2019-02-02 - 14:43:12
    Okay, I found the problem.... for some reason the event config looked like this.
    setse1  #%001_100000 '| L_PIN
    

    When it sould look like this.
    setse1  #%001_100000 | L_PIN
    

    So know the question is why it worked at all using pin 32?!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Ahle2 wrote: »
    Okay, I found the problem.... for some reason the event config looked like this.
    setse1  #%001_100000 '| L_PIN
    

    When it sould look like this.
    setse1  #%001_100000 | L_PIN
    

    So know the question is why it worked at all using pin 32?!

    I think it's because bit 5 of your SETSE1 value is always set, selecting pin 32+.
  • RaymanRayman Posts: 9,220
    edited 2019-02-02 - 22:13:56
    I just got it going on P9 and P10 using what you and Chip suggested:
    setse1  #%001_000000 | L_PIN                 ' Event triggered every new sample period (when "left in pin rises")
    

    Sounds really cool, BTW. Might be useful for a game I want to make...
    Prop Info and Apps: http://www.rayslogic.com/
  • Just got it working Ahle2! Sounds good.

    For those people who want to get this code to work with the cross platform p2asm/p2link tools etc and a P2-EVAL board but don't know how to do it (like me about 20 mins ago), this is the list of steps that you need to do...

    1) download the SIDcogP2 zip file posted above (250kHz)

    2) patch audio pins in SIDcogP2.spin2 file to suit. I fit the A/V accessory board to the P31-39 connector, so I had this:
    CON
      L_PIN = 38 ' left is lowest pin on the A/V accessory board
      R_PIN = 39
    

    3) Fix bug above for setsel instruction by removing comment before | L_PIN.
    setse1  #%001_100000 | L_PIN                 ' Event triggered every new sample period (when "left in pin rises")
    

    4) Patch the SIDcogP2.spin2 file to avoid this compiler error
    p2asm -o SIDcogP2.spin2 
    151: ERROR: Cannot mix float and fix
    CON  PAL = 985248.0, NTSC = 1022727.0, MAXF = 1031000.0, TRIANGLE = 16, SAW = 32, SQUARE = 64, NOISE = 128   
    151: ERROR: Cannot mix float and fix
    CON  PAL = 985248.0, NTSC = 1022727.0, MAXF = 1031000.0, TRIANGLE = 16, SAW = 32, SQUARE = 64, NOISE = 128   
    151: ERROR: Cannot mix float and fix
    CON  PAL = 985248.0, NTSC = 1022727.0, MAXF = 1031000.0, TRIANGLE = 16, SAW = 32, SQUARE = 64, NOISE = 128   
    151: ERROR: Cannot mix float and fix
    CON  PAL = 985248.0, NTSC = 10
    
    To fix it you just need to split up the float and fixed point constants defined onto separate lines:
    CON  PAL = 985248.0, NTSC = 1022727.0, MAXF = 1031000.0
    CON  TRIANGLE = 16, SAW = 32, SQUARE = 64, NOISE = 128   
    

    5) Then just assemble, link, download and enjoy! I do this...
    RLs-MacBook-Pro:SIDcogP2_v1 roger$ p2asm -o SIDcogP2.spin2
    RLs-MacBook-Pro:SIDcogP2_v1 roger$ p2link SIDcogP2.o
    RLs-MacBook-Pro:SIDcogP2_v1 roger$ loadp2 -t -l 115200 a.out -CHIP -p /dev/cu.usbserial-P23HPBP6 
    ( Entering terminal mode.  Press Ctrl-] to exit. )
    
  • Ahle2Ahle2 Posts: 945
    edited 2019-02-03 - 18:58:17
    cgracey wrote: »
    Ahle2 wrote: »
    Okay, I found the problem.... for some reason the event config looked like this.
    setse1  #%001_100000 '| L_PIN
    

    When it sould look like this.
    setse1  #%001_100000 | L_PIN
    

    So know the question is why it worked at all using pin 32?!

    I think it's because bit 5 of your SETSE1 value is always set, selecting pin 32+.

    Yes... that explains it all. When experimenting with getting SIDcog running on the P2 I "temporarily" hardcoded pin 32 and then forget about that little apostrophe. 🙄
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Ahle2Ahle2 Posts: 945
    edited 2019-02-04 - 10:30:29
    Rayman wrote: »
    I just got it going on P9 and P10 using what you and Chip suggested:
    setse1  #%001_000000 | L_PIN                 ' Event triggered every new sample period (when "left in pin rises")
    

    Sounds really cool, BTW. Might be useful for a game I want to make...

    Thanks Rayman... the SID was such an unique sound chip back in the 80's compared to the rest. Much more like a real subtractive synthesizer with features such as ring modulation, pulse width modulation, envelopes and a multi-mode resonant analog filter. Like a Moog in a chip. Too bad it took half a decade before any programmers started using these unique features. Most just made it do square waves without any modulation or filtering and the result was that people thought it was another Atari/Nintendo-style sound chip. Then came Rob Hubbard, Martin Galway, Jeroen Tel, Chris Huelsbeck etc. and changed that forever. Nowdays they make it do things that if played in 1982, would have made people shake their heads in disbelief.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
Sign In or Register to comment.