couple of months smile~ that's why i'm writing all these tutorials (teaching is the best way of learning etc)

hi, if anyone is interested in writing a c64 music engine

i will get you started

enjoy!

/*
ant1's guide to programming the SID  
this is kick assembler source-code
made in 2012
*/

.pc=$801
:BasicUpstart($810)
.pc=$810

  // clear all sid registers to 0
  ldx #$00
  lda #$00
clearsidloop:
  // SID registers start at $d400
  sta $d400
  inc clearsidloop+1 
  inx
  cpx #$29 // and there are 29 of them
  bne clearsidloop

  // set master volume and turn filter off
  lda #%00001111 
  sta filtermode_volume

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

mainloop:

  // check if rasterline is #$ff 
  // which happens every 20ms
  // do nothing and jump back to mainloop if not
  lda $d012 
  cmp #$ff
  bne mainloop

  // play a single frame of music (if there are any notes to play this frame)
  jsr music

  // loop forever
  jmp mainloop

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

music:

  // tickcounter counts the number of 20ms frames
  inc tickcounter

  // speed is the number of 20ms frames that will happen before the slowtable advances one position
  lda tickcounter
  cmp speed
  beq playnote
  jmp endmusic
  
playnote:

  // flash border and background
  inc $d020
  dec $d021
  
  // reset gatebit/waveform
  lda #%00000000
  sta $d404

  // reset tickcounter as we have got to the next row of the slowtable and we want to start counting towards the next note
  lda #$00
  sta tickcounter
  
  // add slowtablepos to slowtable to get the current position in the slowtable
  ldx slowtablepos
  lda slowtable, x
  
  // get low byte of frequency from slowtable
  sta frequency
  
  // get high byte of frequency from slowtable
  inx
  lda slowtable, x
  sta frequency+1
  
freqcheck1:

  // check if low byte of frequency is #$00, if not, continue to play note
  lda frequency
  cmp #$00
  bne playnote2
  
  // check if high byte of frequency is #$00 (frequency is #$0000), if not, continue to next check
  lda frequency+1
  cmp #$00
  bne freqcheck2
  
  // if it is, reset slowtablepos and start again
  lda #$00
  sta slowtablepos
  jmp playnote  
  
freqcheck2:

  // check if high byte of frequency is #$01 (frequency is #$0001), if not continue to play note
  lda frequency+1
  cmp #$01
  bne playnote2
  
  // if it is, increment slowtablepos to continue moving through the table, but jump back to the start without playing a note
  inc slowtablepos
  inc slowtablepos
  jmp music
    
playnote2:

  // set attack to 0, decay to 6
  lda #$06
  sta attack_decay
  
  // set sustain and release to 0
  lda #$00
  sta sustain_release
  
  // move frequency from frequency variable to sid buffer
  lda frequency
  sta freq_lowbyte
  lda frequency+1
  sta freq_highbyte
  
  // set waveform to saw and turn gatebit on
  lda #%00100001
  sta control

  // increment the slowtablepos twice (twice because there are two bytes for each note in the table)
  inc slowtablepos
  inc slowtablepos

  // write data from the sid buffer to the sid chip
  lda freq_lowbyte
  sta $d400
  lda freq_highbyte
  sta $d401
  lda control
  sta $d404
  lda attack_decay
  sta $d405
  lda sustain_release
  sta $d406
  lda filtermode_volume
  sta $d418

endmusic:

  // back to mainloop
  rts


// variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// the number of frames to wait before advancing the slowtable, you can set this to anything
speed:
  .byte $1f

// stores the tick (frame) counter
tickcounter:
  .byte $00

// stores the position in the slowtable  
slowtablepos:
  .byte $00

// temporarily stores the frequency of the next note  
frequency:
  .byte $00
  .byte $00

// music data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// the slowtable is where the note data is stored
slowtable:

  // frequency is a sixteen bit number, a higher number is a higher pitch
  .byte $b1, $25
  .byte $30, $40
  .byte $b1, $25
  
  // a frequency of #$0001 tells the player to play no note on this row
  .byte $00, $01
  
  .byte $b1, $25
  .byte $30, $40
  .byte $b1, $15
  .byte $00, $01
  
  .byte $b1, $25
  .byte $30, $40
  .byte $b1, $25
  .byte $00, $01
  
  .byte $b1, $25
  .byte $30, $40
  .byte $b1, $65
  .byte $00, $01
  
  // a frequency of #$0000 tells the player to loop back to the start of the slowtable
  .byte $00, $00
  
// sid buffer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// values that are going to be written to the sid are stored here and then written in one go

// freq_lowbyte is the low byte of the frequency
// on the SID this is $d400 
freq_lowbyte:
  .byte $00
  
// freq_highbyte is the high byte of the frequency
// on the SID this is $d401
freq_highbyte:  
  .byte $00

// control sets the waveform and gatebit
// on the SID this is $d404
control:
  .byte $00
  
// the first nybble of attack_decay is attack, the second nybble is decay
// on the SID this is $d405
attack_decay:
  .byte $00
  
// the first nybble of sustain_release is sustain, the second nybble is release
// on the SID this is $d406
sustain_release:
  .byte $00
  
// bits 7-4 of filtermode_volume control the filter, bits 3-1 control the master volume
// on the SID this is $d418
filtermode_volume:
  .byte $00

edit:
if you've never done any c64 programming before then you will need, to follow this guide,

something that tells you what all the opcodes do
something that tells you what all the sid registers do
kick assembler

the lsdj website used to recommend kigb didn't it? http://www.bannister.org/software/kigb.htm

EXCITING:

zan-zan-zawa-veia's "mist goat" 2 song single. two of the best zan-zan-zawa-veia songs to download
http://aanaaanaaanaaana.net/singles/mist-goat.zip

LESS EXCITING:

i redesigned our website
http://aanaaanaaanaaana.net/

341

(7 replies, posted in Collaborations)

i think the idea this time around was to focus on the underappreciated formats that didn't get a lot of entries in winterchips of the past


hence no NSF which has always been inundated with entries

well i love pamplemousse so my debt is paid smile))~~

edit: sorry i'll let you get back on topic now

J. Arthur Keenes wrote:

Thanks for all the nice comments everyone, the GB is still there, he just doesn't sound like himself sometimes.  Hpizzle: thanks, home recorded, mixed and "mastered".  Ant1: Your comment dismays me, explain?

it's hard to explain, hrm. i liked pamplemousse a lot but i can't really get into this at all sad sorry

maybe take out the "-Werror" switch to stop warnings being treated as errors

it should at least build then but i dunno if it will work

345

(39 replies, posted in Commodore Computers)

that'd be cool! i don't think i have the web skills for it though

i hate this sad

347

(39 replies, posted in Commodore Computers)

put the up value, the down value twice, and then the up value again, and it will vibratre around the start point (if that's what you want), eg

84 00
10 10
10 F0
10 F0
10 10
FE 01

thanks jellica smile
i updated to include the amiga format octamed tutorial smile

349

(39 replies, posted in Commodore Computers)

sid_fanatic if you build from source you can edit "settings.cfg" the lines

playbarcol=6   ;(default:6) colour of single-speed rasterbar
jambarcol=11   ;(default:11) colour of jamming-mode rasterbar
multibarcol=6  ;(default:6) colour of player-indicator multispeed rasterbars (0 to disable)
multilincol=14 ;(default:14) colour of line before multispeed player-rasterbars

hope that helps

what a bout a quite a simple hardware with a simple api that connects to usb to the computer and can be told to read or write anything to/from any pin? does it exist? would it be useful?

351

(617 replies, posted in Releases)

SketchMan3 wrote:
George wrote:

BUMP due to awesome collabs on PEEL SESSIONS with:

Ant1
4mat
XC3N
RAPTOR KHARLAN

AND MORE TO BE ANNOUNCED (Hopefully)

Are you excited?
My nipples are so hard I can't even wear a bra at the moment!

This is BIIIG News! I can't wait to hear what your music sounds like once you finally learn how to make some big_smile
If any other Release hype was made without the artist having any knowledge of composing yet, nobody would ever miss it when it finally came out.

I hope this is real. I'd love to hear what kind of music George has floating around in her head.

it's real !

animalstyle do you think the powerpoint will make sense without you talking over it?


Chainsaw Police:
can i just save the web page? or you can send it to me if you want. i'll add this tutorial yes
thanks smile