Image Map Image Map
Page 5 of 6 FirstFirst 123456 LastLast
Results 41 to 50 of 54

Thread: Adding NOPs

  1. #41

    Default

    One of the issue with expanding the size of your loops with loops or NOPs is that you run out of music for your song.
    You should be able to make a single loop so everything.
    I've not seen a easy way to do this but 6502 is not my best assembly.
    Anyway the way I thought that might work is to have a value on page zero that has the number 100 speas into the two locations ( I forget if it is 00 first or 1 first for an address on the 6502 )
    Anyway, at the beginning of each loop do a EOR of 3 on the location with the 1 in it wan write it back then use that location for an indirect operation. Each time it will change from 100 to 200 and back.
    Dwight

  2. #42
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,856
    Blog Entries
    3

    Default

    I took a break from wiring the 1702 differently for my Microkit and 'whipped' this up. I'm hoping I'm understanding enough. What I tried to do is get it to 'play' two 'notes'. So the idea was:

    1. Toggle the output latch (to create the square wave) by using delay loops instead of NOPs, each note having different length delay loops to change speed of toggling (pitch).
    2. Put a delay loop in between each note to space the two notes apart
    3. Loop back to beginning to play the two notes repeatedly.

    Let me know if this makes sense..

    Code:
    Location	OP Code	Mnemonic
    00		AD		LDA Oper (first note)
    01		00		Data
    02		02		Data
    03		A2		LDX Oper
    04		25		Data
    05		88		Decrement Register X
    06		F0		If Register X = 0 Skip 3
    07		03		Skip 3 locations
    08		4C		JMP Oper
    09		05		Memory Location
    10		00		Page Number
    11		4C	 	JMP Oper
    12		14   		Data
    13		00		Data	
    14		AD         LDA Oper
    15		00		Data
    16		01		Data
    17		A2		LDX Oper
    18		25		Data
    19		88		Decrement Register X
    20		F0		If Register X = 0 Skip 3
    21		03		Number to skip
    22		4C		JMP Oper
    23		19		Data
    24		00		Data
    25		A0		LDY Oper
    26		99		Data
    27		88		Decrement Register Y
    28		F0		If Register Y = 0 Skip 3
    29 		03		Data
    30		4C		JMP Oper
    31		27		Data
    32		00		Data
    33		A0		LDY Oper
    34		99		Data
    35		88		Decrement Register Y
    36		F0		If Register y = 0 skip 3
    37		03		Data
    38		4C		JMP Oper
    39		35		Data
    40		00		Data
    41		AD		LDA Oper (second note)
    42		00		Data
    43		02		Data
    44		A2		LDX Oper
    45		50		Data
    46		88		Decrement Register X
    47		F0		If Register X = 0 Skip 3
    48		03		Skip 3 locations
    49		4C		JMP Oper
    50		46		Memory Location
    51		00		Page Number
    52		4C	 	JMP Oper
    53		55   		Data
    54		00		Data	
    55		AD         LDA Oper
    56		00		Data
    57		01		Data
    58		A2		LDX Oper
    59		50		Data
    60		88		Decrement Register X
    61		F0		If Register X = 0 Skip 3
    62		03		Number to skip
    63		4C		JMP Oper
    64		60		Data
    65		00		Data
    66		A0		LDY Oper
    67		99		Data
    68		88		Decrement Register Y
    69		F0		If Register Y = 0 Skip 3
    70 		03		Data
    71		4C		JMP Oper
    72		68		Data
    73		00		Data
    74		A0		LDY Oper
    75		99		Data
    76		88		Decrement Register Y
    77		F0		If Register y = 0 skip 3
    78		03		Data
    79		4C		JMP Oper
    80		76		Data
    81		00		Data
    Last edited by falter; December 15th, 2019 at 09:31 PM.

  3. #43
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,856
    Blog Entries
    3

    Default

    And can I just say.. I have no idea how those of you who can program in assembly can do it. I found myself going cross eyed after 10 minutes. I have no idea how you develop something as complex as, say, a game, from something that arcane.

  4. #44
    Join Date
    Feb 2017
    Location
    Guildford, U.K.
    Posts
    338

    Default

    Fortunately for most of us, Macro Assemblers make the job easier, even if you have to write the macro yourself at first. I got my first taste in '73 on an IBM 360 Assembler course provided by my then employer. A world of opportunities was revealed, and it's the only true way to extract the full performance of critical routines. Just my 10p.

  5. #45
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,572

    Default

    Correct...

    Programmers use tools!

    I do feel a bit guilty about pointing out errors in your code though...

    The biggest issue is that it is all inline code. Eventually (after only a few notes) you will run out of memory on the OSI 300.

    Anyhow,

    There is a good online assembler at www.asm80.com. Contrary to the website address, it can assemble software for the 6502 (and other CPUs).

    Please see my code below that you should be able to copy and paste into the online assembler.

    Use the listing file to note down the data bytes and enter these into the OSI 300.

    I am sure you will have some comments on my code. I don't know whether it will work or not though.

    You will have to play with the definitions for the note frequencies and durations of course.

    Regards,

    Dave

    Code:
        ORG     0
        
    TUNE_END    EQU   0
    CROTCHET    EQU  16
    
    NOTE_REST   EQU   0
    NOTE_G      EQU   1
    NOTE_A      EQU   2
    NOTE_B      EQU   3
    NOTE_C      EQU   4
    
        ; Register X is used to index the tune located in page 0.
        ; Each note consists of two (2) consecutive bytes:
        ;    The duration of the note (or the length).
        ;    The pitch of the note (or the frequency).
        ; The tune is terminated by a duration/length of 0.
        
        LDX     #TUNE
        
    MORE_TUNE:
        LDA     0,X         ; Pickup the duration (or end of tune).
        STA     DURATION    ; Store it away for later use.
        CMP     #TUNE_END   ; Is it the end of tune sentinel?
    END_OF_GO:
        BEQ     END_OF_GO   ; If it is, just loop...
    
        INX                 ; Bump on to the frequency.
        
        ; Got a valid duration here.
        
        LDA     0,X         ; Pickup the frequency (or rest).
        STA     FREQUENCY   ; Store it away for later use.
        INX                 ; Bump on to the next duration.
        
        ; Got a valid duration and frequency here.
        
        LDA     FREQUENCY   ; What is the frequency?
        CMP     #NOTE_REST  ; Is it a rest?
        BEQ     NO_NOTE     ; If so, don't toggle the speaker...
        
        ; We have a valid frequency to output.
        
    MORE_WAVE:
    
        LDA SPEAKER_ON      ; Force the speaker.
        
        LDY FREQUENCY       ; Pickup the frequency.
    LOOP1:
        DEY                 ; Y = Y-1
        BNE LOOP1           ; Loop for first half of the cycle.
        
        LDA SPEAKER_OFF     ; Force the speaker.
    
        LDY FREQUENCY       ; Pickup the frequency.
    LOOP2:
        DEY                 ; Y = Y-1
        BNE LOOP2           ; Loop for second half of the cycle.
        
    NO_NOTE:
    
        ; Process the note duration...
        
        DEC     DURATION    ; Are there any more cycles to output?
        BNE     MORE_WAVE   ; More to do...
        
        JMP      MORE_TUNE  ; Keep repeating until done...
        
    DURATION    DB  0
    FREQUENCY   DB  0
    
    SPEAKER_ON  DW  $0100
    SPEAKER_OFF DW  $0200
    
    TUNE:
    
        ; This is the 'score' for Pease Pudding for a recorder.
        ; This was the first thing I played on the recorder when at primary school!
        ; See http://www.themusicjungle.co.uk/live...pease-pudding/
        
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_G
        DB  TUNE_END
        
        END

  6. #46
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,572

    Default

    Found (and fixed) an error. It wasn't working with the 16-bit addresses to set and reset the flip-flop...

    Code:
        ORG     0
        
    TUNE_END    EQU   0
    CROTCHET    EQU  16
    
    NOTE_REST   EQU   0
    NOTE_G      EQU   1
    NOTE_A      EQU   2
    NOTE_B      EQU   3
    NOTE_C      EQU   4
    
    SPEAKER_ON  EQU  $0100
    SPEAKER_OFF EQU  $0200
    
    
        ; Register X is used to index the tune located in page 0.
        ; Each note consists of two (2) consecutive bytes:
        ;    The duration of the note (or the length).
        ;    The pitch of the note (or the frequency).
        ; The tune is terminated by a duration/length of 0.
        
        LDX     #TUNE
        
    MORE_TUNE:
        LDA     0,X         ; Pickup the duration (or end of tune).
        STA     DURATION    ; Store it away for later use.
        CMP     #TUNE_END   ; Is it the end of tune sentinel?
    END_OF_GO:
        BEQ     END_OF_GO   ; If it is, just loop...
    
        INX                 ; Bump on to the frequency.
        
        ; Got a valid duration here.
        
        LDA     0,X         ; Pickup the frequency (or rest).
        STA     FREQUENCY   ; Store it away for later use.
        INX                 ; Bump on to the next duration.
        
        ; Got a valid duration and frequency here.
        
        LDA     FREQUENCY   ; What is the frequency?
        CMP     #NOTE_REST  ; Is it a rest?
        BEQ     NO_NOTE     ; If so, don't toggle the speaker...
        
        ; We have a valid frequency to output.
        
    MORE_WAVE:
    
        LDA SPEAKER_ON      ; Force the speaker.
        
        LDY FREQUENCY       ; Pickup the frequency.
    LOOP1:
        DEY                 ; Y = Y-1
        BNE LOOP1           ; Loop for first half of the cycle.
        
        LDA SPEAKER_OFF     ; Force the speaker.
    
        LDY FREQUENCY       ; Pickup the frequency.
    LOOP2:
        DEY                 ; Y = Y-1
        BNE LOOP2           ; Loop for second half of the cycle.
        
    NO_NOTE:
    
        ; Process the note duration...
        
        DEC     DURATION    ; Are there any more cycles to output?
        BNE     MORE_WAVE   ; More to do...
        
        JMP      MORE_TUNE  ; Keep repeating until done...
        
    DURATION    DB  0
    FREQUENCY   DB  0
    
    TUNE:
    
        ; This is the 'score' for Pease Pudding for a recorder.
        ; This was the first thing I played on the recorder when at primary school!
        ; See http://www.themusicjungle.co.uk/live/2012/04/27/issue-36-mini-beasts-in-the-pease-pudding/
        
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_C
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_G
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_B
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_A
        DB  CROTCHET
        DB  NOTE_G
        DB  TUNE_END
        
        END

  7. #47
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,572

    Default

    After the ‘BNE MORE_WAVE’ you may want to add a small loop delay between notes:

    Code:
    INTER_NOTE EQU 42
    
        LDY #INTER_NOTE
    LOOP3:
       DEY
       BNE LOOP3
    Of course, this code is still horrible, it suffers from the fact that the frequency will affect the note delay - but we have to start somewhere !

    Dave
    Last edited by daver2; December 16th, 2019 at 09:06 AM.

  8. #48
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,856
    Blog Entries
    3

    Default

    Thank you Dave. I will play with this tonight when I finish work. I am slogging it out today with that thanks to heavy snowfall.

    I'm curious - would my program have actually done what I intended it to do, even though it obviously isn't optimized for RAM? Did I understand the basic concept of loading registers, decrementing, branching, etc? I'm going to try getting yours to work, as I'd really like to push the limits with this thing, but I am trying to learn also, starting from pretty much zero knowledge.

    I'm almost done the adapter for the Microkit's 1702... just having some mechanical difficulties, so to speak, with making the adapter strong enough.

  9. #49
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,572

    Default

    No problem.

    Ah yes, snow...

    I think your program would work after a few crashes and sore fingers when you reentered it a few times!

    Here are some of the errors I could find:

    You appear to have used the same code (88) for decrement X and decrement Y. 88 is the code for decrement Y.

    Your ‘locations’ count in decimal and should count in hex (unless you are going to change from decimal to hex on the fly when you enter it)?

    What happens ‘at the end of the program’ when it gets to location 88? There doesn’t seem to be any instructions there for the CPU to execute. There is no HALT instruction in the 6502, so you normally ‘branch to yourself’.

    Dave

  10. #50
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,856
    Blog Entries
    3

    Default

    So I realized after doing the initial attempt that I forgot to set the reset vector to 0000 (doh!). So I reentered again, this time *with* the reset vector, but all I got was a solid tone. So I took the code as posted, ran it through asm80 again and compiled, and this time it was slightly different. It was fairly similar, but there were certain bytes changed -- like $0001 came out as 2F on the first compile and 31 on the second. Not sure which is right. This is the second compile attempt:

    Code:
    0000                          .ORG   0   
    0000                             ; 
    0000                TUNE_END:   EQU   0   
    0000                CROTCHET:   EQU   16   
    0000                             ; 
    0000                NOTE_REST:   EQU   0   
    0000                NOTE_G:   EQU   1   
    0000                NOTE_A:   EQU   2   
    0000                NOTE_B:   EQU   3   
    0000                NOTE_C:   EQU   4   
    0000                             ; 
    0000                             ; Register X is used to index the tune located in page 0.
    0000                             ; Each note consists of two (2) consecutive bytes:
    0000                             ;    The duration of the note (or the length).
    0000                             ;    The pitch of the note (or the frequency).
    0000                             ; The tune is terminated by a duration/length of 0.
    0000                             ; 
    0000   A2 31                  LDX   #TUNE   
    0002                             ; 
    0002                MORE_TUNE:      
    0002   B5 00                  LDA   0,X   ; Pickup the duration (or end of tune).
    0004   85 2B                  STA   DURATION   ; Store it away for later use.
    0006   C9 00                  CMP   #TUNE_END   ; Is it the end of tune sentinel?
    0008                END_OF_GO:      
    0008   F0 FE                  BEQ   END_OF_GO   ; If it is, just loop...
    000A                             ; 
    000A   E8                     INX      ; Bump on to the frequency.
    000B                             ; 
    000B                             ; Got a valid duration here.
    000B                             ; 
    000B   B5 00                  LDA   0,X   ; Pickup the frequency (or rest).
    000D   85 2C                  STA   FREQUENCY   ; Store it away for later use.
    000F   E8                     INX      ; Bump on to the next duration.
    0010                             ; 
    0010                             ; Got a valid duration and frequency here.
    0010                             ; 
    0010   A5 2C                  LDA   FREQUENCY   ; What is the frequency?
    0012   C9 00                  CMP   #NOTE_REST   ; Is it a rest?
    0014   F0 0E                  BEQ   NO_NOTE   ; If so, don't toggle the speaker...
    0016                             ; 
    0016                             ; We have a valid frequency to output.
    0016                             ; 
    0016                MORE_WAVE:      
    0016                             ; 
    0016   A5 2D                  LDA   SPEAKER_ON   ; Force the speaker.
    0018                             ; 
    0018   A4 2C                  LDY   FREQUENCY   ; Pickup the frequency.
    001A                LOOP1:       
    001A   88                     DEY      ; Y = Y-1
    001B   D0 FD                  BNE   LOOP1   ; Loop for first half of the cycle.
    001D                             ; 
    001D   A5 2F                  LDA   SPEAKER_OFF   ; Force the speaker.
    001F                             ; 
    001F   A4 2C                  LDY   FREQUENCY   ; Pickup the frequency.
    0021                LOOP2:       
    0021   88                     DEY      ; Y = Y-1
    0022   D0 FD                  BNE   LOOP2   ; Loop for second half of the cycle.
    0024                             ; 
    0024                NO_NOTE:      
    0024                             ; 
    0024                             ; Process the note duration...
    0024                             ; 
    0024   C6 2B                  DEC   DURATION   ; Are there any more cycles to output?
    0026   D0 EE                  BNE   MORE_WAVE   ; More to do...
    0028                             ; 
    0028   4C 02 00               JMP   MORE_TUNE   ; Keep repeating until done...
    002B                             ; 
    002B   00           DURATION:   DB   0   
    002C   00           FREQUENCY:   DB   0   
    002D                             ; 
    002D   00 01        SPEAKER_ON:   DW   $0100   
    002F   00 02        SPEAKER_OFF:   DW   $0200   
    0031                             ; 
    0031                TUNE:        
    0031                             ; 
    0031                             ; This is the "score" for Pease Pudding for a recorder.
    0031                             ; This was the first thing I played on the recorder when at primary school!
    0031                             ; See http://www.themusicjungle.co.uk/live...pease-pudding/
    0031                             ; 
    0031   10                     DB   CROTCHET   
    0032   01                     DB   NOTE_G   
    0033   10                     DB   CROTCHET   
    0034   01                     DB   NOTE_G   
    0035   10                     DB   CROTCHET   
    0036   02                     DB   NOTE_A   
    0037   10                     DB   CROTCHET   
    0038   03                     DB   NOTE_B   
    0039   10                     DB   CROTCHET   
    003A   04                     DB   NOTE_C   
    003B   10                     DB   CROTCHET   
    003C   04                     DB   NOTE_C   
    003D   10                     DB   CROTCHET   
    003E   04                     DB   NOTE_C   
    003F   10                     DB   CROTCHET   
    0040   03                     DB   NOTE_B   
    0041   10                     DB   CROTCHET   
    0042   01                     DB   NOTE_G   
    0043   10                     DB   CROTCHET   
    0044   01                     DB   NOTE_G   
    0045   10                     DB   CROTCHET   
    0046   02                     DB   NOTE_A   
    0047   10                     DB   CROTCHET   
    0048   03                     DB   NOTE_B   
    0049   10                     DB   CROTCHET   
    004A   03                     DB   NOTE_B   
    004B   10                     DB   CROTCHET   
    004C   03                     DB   NOTE_B   
    004D   10                     DB   CROTCHET   
    004E   02                     DB   NOTE_A   
    004F   10                     DB   CROTCHET   
    0050   02                     DB   NOTE_A   
    0051   10                     DB   CROTCHET   
    0052   01                     DB   NOTE_G   
    0053   00                     DB   TUNE_END   
    0054                             ; 
    0054                          END      
    
    
    TUNE_END:           0000 DEFINED AT LINE 3
                        > USED AT LINE 114
    CROTCHET:           0010 DEFINED AT LINE 4
                        > USED AT LINE 80
                        > USED AT LINE 82
                        > USED AT LINE 84
                        > USED AT LINE 86
                        > USED AT LINE 88
                        > USED AT LINE 90
                        > USED AT LINE 92
                        > USED AT LINE 94
                        > USED AT LINE 96
                        > USED AT LINE 98
                        > USED AT LINE 100
                        > USED AT LINE 102
                        > USED AT LINE 104
                        > USED AT LINE 106
                        > USED AT LINE 108
                        > USED AT LINE 110
                        > USED AT LINE 112
    NOTE_REST:          0000 DEFINED AT LINE 6
    NOTE_G:             0001 DEFINED AT LINE 7
                        > USED AT LINE 81
                        > USED AT LINE 83
                        > USED AT LINE 97
                        > USED AT LINE 99
                        > USED AT LINE 113
    NOTE_A:             0002 DEFINED AT LINE 8
                        > USED AT LINE 85
                        > USED AT LINE 101
                        > USED AT LINE 109
                        > USED AT LINE 111
    NOTE_B:             0003 DEFINED AT LINE 9
                        > USED AT LINE 87
                        > USED AT LINE 95
                        > USED AT LINE 103
                        > USED AT LINE 105
                        > USED AT LINE 107
    NOTE_C:             0004 DEFINED AT LINE 10
                        > USED AT LINE 89
                        > USED AT LINE 91
                        > USED AT LINE 93
    MORE_TUNE:          0002 DEFINED AT LINE 20
                        > USED AT LINE 66
    END_OF_GO:          0008 DEFINED AT LINE 24
                        > USED AT LINE 25
    MORE_WAVE:          0016 DEFINED AT LINE 43
                        > USED AT LINE 64
    LOOP1:              001A DEFINED AT LINE 48
                        > USED AT LINE 50
    LOOP2:              0021 DEFINED AT LINE 55
                        > USED AT LINE 57
    NO_NOTE:            0024 DEFINED AT LINE 59
                        > USED AT LINE 39
    DURATION:           002B DEFINED AT LINE 68
                        > USED AT LINE 22
                        > USED AT LINE 63
    FREQUENCY:          002C DEFINED AT LINE 69
                        > USED AT LINE 32
                        > USED AT LINE 37
                        > USED AT LINE 47
                        > USED AT LINE 54
    SPEAKER_ON:         002D DEFINED AT LINE 71
                        > USED AT LINE 45
    SPEAKER_OFF:        002F DEFINED AT LINE 72
                        > USED AT LINE 52
    TUNE:               0031 DEFINED AT LINE 74
    And this is the first one I tried:

    Code:
    0000                          .ORG   0   
    0000                             ; 
    0000                TUNE_END:   EQU   0   
    0000                CROTCHET:   EQU   16   
    0000                             ; 
    0000                NOTE_REST:   EQU   0   
    0000                NOTE_G:   EQU   1   
    0000                NOTE_A:   EQU   2   
    0000                NOTE_B:   EQU   3   
    0000                NOTE_C:   EQU   4   
    0000                             ; 
    0000                SPEAKER_ON:   EQU   $0100   
    0000                SPEAKER_OFF:   EQU   $0200   
    0000                             ; 
    0000                             ; 
    0000                             ; Register X is used to index the tune located in page 0.
    0000                             ; Each note consists of two (2) consecutive bytes:
    0000                             ;    The duration of the note (or the length).
    0000                             ;    The pitch of the note (or the frequency).
    0000                             ; The tune is terminated by a duration/length of 0.
    0000                             ; 
    0000   A2 2F                  LDX   #TUNE   
    0002                             ; 
    0002                MORE_TUNE:      
    0002   B5 00                  LDA   0,X   ; Pickup the duration (or end of tune).
    0004   85 2D                  STA   DURATION   ; Store it away for later use.
    0006   C9 00                  CMP   #TUNE_END   ; Is it the end of tune sentinel?
    0008                END_OF_GO:      
    0008   F0 FE                  BEQ   END_OF_GO   ; If it is, just loop...
    000A                             ; 
    000A   E8                     INX      ; Bump on to the frequency.
    000B                             ; 
    000B                             ; Got a valid duration here.
    000B                             ; 
    000B   B5 00                  LDA   0,X   ; Pickup the frequency (or rest).
    000D   85 2E                  STA   FREQUENCY   ; Store it away for later use.
    000F   E8                     INX      ; Bump on to the next duration.
    0010                             ; 
    0010                             ; Got a valid duration and frequency here.
    0010                             ; 
    0010   A5 2E                  LDA   FREQUENCY   ; What is the frequency?
    0012   C9 00                  CMP   #NOTE_REST   ; Is it a rest?
    0014   F0 10                  BEQ   NO_NOTE   ; If so, don't toggle the speaker...
    0016                             ; 
    0016                             ; We have a valid frequency to output.
    0016                             ; 
    0016                MORE_WAVE:      
    0016                             ; 
    0016   AD 00 01               LDA   SPEAKER_ON   ; Force the speaker.
    0019                             ; 
    0019   A4 2E                  LDY   FREQUENCY   ; Pickup the frequency.
    001B                LOOP1:       
    001B   88                     DEY      ; Y = Y-1
    001C   D0 FD                  BNE   LOOP1   ; Loop for first half of the cycle.
    001E                             ; 
    001E   AD 00 02               LDA   SPEAKER_OFF   ; Force the speaker.
    0021                             ; 
    0021   A4 2E                  LDY   FREQUENCY   ; Pickup the frequency.
    0023                LOOP2:       
    0023   88                     DEY      ; Y = Y-1
    0024   D0 FD                  BNE   LOOP2   ; Loop for second half of the cycle.
    0026                             ; 
    0026                NO_NOTE:      
    0026                             ; 
    0026                             ; Process the note duration...
    0026                             ; 
    0026   C6 2D                  DEC   DURATION   ; Are there any more cycles to output?
    0028   D0 EC                  BNE   MORE_WAVE   ; More to do...
    002A                             ; 
    002A   4C 02 00               JMP   MORE_TUNE   ; Keep repeating until done...
    002D                             ; 
    002D   00           DURATION:   DB   0   
    002E   00           FREQUENCY:   DB   0   
    002F                             ; 
    002F                TUNE:        
    002F                             ; 
    002F                             ; This is the "score" for Pease Pudding for a recorder.
    002F                             ; This was the first thing I played on the recorder when at primary school!
    002F                             ; See http://www.themusicjungle.co.uk/live/2012/04/27/issue-36-mini-beasts-in-the-pease-pudding/
    002F                             ; 
    002F   10                     DB   CROTCHET   
    0030   01                     DB   NOTE_G   
    0031   10                     DB   CROTCHET   
    0032   01                     DB   NOTE_G   
    0033   10                     DB   CROTCHET   
    0034   02                     DB   NOTE_A   
    0035   10                     DB   CROTCHET   
    0036   03                     DB   NOTE_B   
    0037   10                     DB   CROTCHET   
    0038   04                     DB   NOTE_C   
    0039   10                     DB   CROTCHET   
    003A   04                     DB   NOTE_C   
    003B   10                     DB   CROTCHET   
    003C   04                     DB   NOTE_C   
    003D   10                     DB   CROTCHET   
    003E   03                     DB   NOTE_B   
    003F   10                     DB   CROTCHET   
    0040   01                     DB   NOTE_G   
    0041   10                     DB   CROTCHET   
    0042   01                     DB   NOTE_G   
    0043   10                     DB   CROTCHET   
    0044   02                     DB   NOTE_A   
    0045   10                     DB   CROTCHET   
    0046   03                     DB   NOTE_B   
    0047   10                     DB   CROTCHET   
    0048   03                     DB   NOTE_B   
    0049   10                     DB   CROTCHET   
    004A   03                     DB   NOTE_B   
    004B   10                     DB   CROTCHET   
    004C   02                     DB   NOTE_A   
    004D   10                     DB   CROTCHET   
    004E   02                     DB   NOTE_A   
    004F   10                     DB   CROTCHET   
    0050   01                     DB   NOTE_G   
    0051   00                     DB   TUNE_END   
    0052                             ; 
    0052                          END      
    
    
    TUNE_END:           0000 DEFINED AT LINE 3
                        > USED AT LINE 115
    CROTCHET:           0010 DEFINED AT LINE 4
                        > USED AT LINE 81
                        > USED AT LINE 83
                        > USED AT LINE 85
                        > USED AT LINE 87
                        > USED AT LINE 89
                        > USED AT LINE 91
                        > USED AT LINE 93
                        > USED AT LINE 95
                        > USED AT LINE 97
                        > USED AT LINE 99
                        > USED AT LINE 101
                        > USED AT LINE 103
                        > USED AT LINE 105
                        > USED AT LINE 107
                        > USED AT LINE 109
                        > USED AT LINE 111
                        > USED AT LINE 113
    NOTE_REST:          0000 DEFINED AT LINE 6
    NOTE_G:             0001 DEFINED AT LINE 7
                        > USED AT LINE 82
                        > USED AT LINE 84
                        > USED AT LINE 98
                        > USED AT LINE 100
                        > USED AT LINE 114
    NOTE_A:             0002 DEFINED AT LINE 8
                        > USED AT LINE 86
                        > USED AT LINE 102
                        > USED AT LINE 110
                        > USED AT LINE 112
    NOTE_B:             0003 DEFINED AT LINE 9
                        > USED AT LINE 88
                        > USED AT LINE 96
                        > USED AT LINE 104
                        > USED AT LINE 106
                        > USED AT LINE 108
    NOTE_C:             0004 DEFINED AT LINE 10
                        > USED AT LINE 90
                        > USED AT LINE 92
                        > USED AT LINE 94
    SPEAKER_ON:         0100 DEFINED AT LINE 12
                        > USED AT LINE 49
    SPEAKER_OFF:        0200 DEFINED AT LINE 13
                        > USED AT LINE 56
    MORE_TUNE:          0002 DEFINED AT LINE 24
                        > USED AT LINE 70
    END_OF_GO:          0008 DEFINED AT LINE 28
                        > USED AT LINE 29
    MORE_WAVE:          0016 DEFINED AT LINE 47
                        > USED AT LINE 68
    LOOP1:              001B DEFINED AT LINE 52
                        > USED AT LINE 54
    LOOP2:              0023 DEFINED AT LINE 59
                        > USED AT LINE 61
    NO_NOTE:            0026 DEFINED AT LINE 63
                        > USED AT LINE 43
    DURATION:           002D DEFINED AT LINE 72
                        > USED AT LINE 26
                        > USED AT LINE 67
    FREQUENCY:          002E DEFINED AT LINE 73
                        > USED AT LINE 36
                        > USED AT LINE 41
                        > USED AT LINE 51
                        > USED AT LINE 58
    TUNE:               002F DEFINED AT LINE 75
    I don't know if I was slightly off on my pasting or if it's just generating something different each time. I'm going to read through the actual code again and see what makes sense.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •