SPC music playback tools for real snes apu

Dependencies:   mbed

Committer:
akkera102
Date:
Thu Jan 19 04:51:28 2017 +0000
Revision:
8:072621697467
Parent:
2:62e6e22f8be2
fifth

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akkera102 2:62e6e22f8be2 1 #ifndef __apu2_h__
akkera102 2:62e6e22f8be2 2 #define __apu2_h__
akkera102 2:62e6e22f8be2 3
akkera102 2:62e6e22f8be2 4
akkera102 2:62e6e22f8be2 5 #include <stdio.h>
akkera102 2:62e6e22f8be2 6
akkera102 2:62e6e22f8be2 7 // offset in a .spc file
akkera102 2:62e6e22f8be2 8 #define OFFSET_SPCDATA 0x100
akkera102 2:62e6e22f8be2 9 #define OFFSET_DSPDATA 0x10100
akkera102 2:62e6e22f8be2 10 #define OFFSET_SPCRAM 0x101c0
akkera102 2:62e6e22f8be2 11
akkera102 2:62e6e22f8be2 12 // Some SPC registers
akkera102 2:62e6e22f8be2 13 #define SPC_PORT0 0xf4
akkera102 2:62e6e22f8be2 14 #define SPC_PORT1 0xf5
akkera102 2:62e6e22f8be2 15 #define SPC_PORT2 0xf6
akkera102 2:62e6e22f8be2 16 #define SPC_PORT3 0xf7
akkera102 2:62e6e22f8be2 17 #define SPC_TIMER0 0xfa
akkera102 2:62e6e22f8be2 18 #define SPC_TIMER1 0xfb
akkera102 2:62e6e22f8be2 19 #define SPC_TIMER2 0xfc
akkera102 2:62e6e22f8be2 20 #define SPC_CONTROL 0xf1
akkera102 2:62e6e22f8be2 21 #define SPC_REGADD 0xf2
akkera102 2:62e6e22f8be2 22
akkera102 2:62e6e22f8be2 23 // some Dsp registers address and bits
akkera102 2:62e6e22f8be2 24 #define DSP_FLG 0x6C
akkera102 2:62e6e22f8be2 25 #define DSP_FLG_RES 0x80
akkera102 2:62e6e22f8be2 26 #define DSP_FLG_MUTE 0x40
akkera102 2:62e6e22f8be2 27 #define DSP_FLG_ECEN 0x20
akkera102 2:62e6e22f8be2 28 #define DSP_ESA 0x6D
akkera102 2:62e6e22f8be2 29 #define DSP_EDL 0x7D
akkera102 2:62e6e22f8be2 30 #define DSP_KON 0x4C
akkera102 2:62e6e22f8be2 31
akkera102 2:62e6e22f8be2 32 #define BOOT_SPC_PORT0 0x19
akkera102 2:62e6e22f8be2 33 #define BOOT_SPC_PORT1 0x1f
akkera102 2:62e6e22f8be2 34 #define BOOT_SPC_PORT2 0x25
akkera102 2:62e6e22f8be2 35 #define BOOT_SPC_PORT3 0x2b
akkera102 2:62e6e22f8be2 36 #define BOOT_SPC_TIMER2 0x07
akkera102 2:62e6e22f8be2 37 #define BOOT_SPC_TIMER1 0x0a
akkera102 2:62e6e22f8be2 38 #define BOOT_SPC_TIMER0 0x0d
akkera102 2:62e6e22f8be2 39 #define BOOT_SPC_CONTROL 0x10
akkera102 2:62e6e22f8be2 40 #define BOOT_DSP_FLG 0x38
akkera102 2:62e6e22f8be2 41 #define BOOT_DSP_KON 0x3e
akkera102 2:62e6e22f8be2 42 #define BOOT_SPC_REGADD 0x41
akkera102 2:62e6e22f8be2 43 #define BOOT_A 0x47
akkera102 2:62e6e22f8be2 44 #define BOOT_Y 0x49
akkera102 2:62e6e22f8be2 45 #define BOOT_X 0x4b
akkera102 2:62e6e22f8be2 46 #define BOOT_SP 0x44
akkera102 2:62e6e22f8be2 47
akkera102 2:62e6e22f8be2 48 int LoadAPU_embedded(FILE *fp);
akkera102 2:62e6e22f8be2 49
akkera102 2:62e6e22f8be2 50
akkera102 2:62e6e22f8be2 51 #endif
akkera102 2:62e6e22f8be2 52
akkera102 2:62e6e22f8be2 53
akkera102 2:62e6e22f8be2 54 /*
akkera102 2:62e6e22f8be2 55
akkera102 2:62e6e22f8be2 56
akkera102 2:62e6e22f8be2 57 ; Disassembled with spcdasm
akkera102 3:b845c0cf715a 58 ; Source filename: ../DSPcode.bin
akkera102 3:b845c0cf715a 59 ; Origin: $0002
akkera102 3:b845c0cf715a 60 ; Input length: 16
akkera102 3:b845c0cf715a 61 p0002: MOV $f2 , A ; choose dsp register address (A)
akkera102 3:b845c0cf715a 62 p0004: CMP A , $f4
akkera102 3:b845c0cf715a 63 p0006: BNE p0004 ; wait until Port0 equals A
akkera102 3:b845c0cf715a 64 p0008: MOV $f3 , $f5 ; now we can copy the value in Port1
akkera102 3:b845c0cf715a 65 ; to the selected dsp address
akkera102 3:b845c0cf715a 66 p000b: MOV $f4 , A ; say it's done by setting Port0 to the
akkera102 3:b845c0cf715a 67 ; dsp address
akkera102 3:b845c0cf715a 68 p000d: INC A ; increment A so we will expect the next address
akkera102 3:b845c0cf715a 69 p000e: BPL p0002 ; while < 128, jump to p0002
akkera102 3:b845c0cf715a 70
akkera102 3:b845c0cf715a 71 ; Jumps right after init code in rom, by underflowing
akkera102 3:b845c0cf715a 72 ; the 16 bit program counter
akkera102 3:b845c0cf715a 73 p0010: BRA pffc9 ; 2fb7
akkera102 3:b845c0cf715a 74
akkera102 3:b845c0cf715a 75
akkera102 3:b845c0cf715a 76
akkera102 3:b845c0cf715a 77
akkera102 3:b845c0cf715a 78 ; Disassembled with spcdasm
akkera102 2:62e6e22f8be2 79 ; Source filename: ../Bootcode.bin
akkera102 2:62e6e22f8be2 80 ; Origin: $0000
akkera102 2:62e6e22f8be2 81 ; Input length: 77
akkera102 2:62e6e22f8be2 82 p0000: MOV $0 , #$0 ; $0001: ram $0000
akkera102 2:62e6e22f8be2 83 p0003: MOV $1 , #$0 ; $0004: ram $0001
akkera102 2:62e6e22f8be2 84 p0006: MOV $fc , #$ff ; $0007: Timer2
akkera102 2:62e6e22f8be2 85 p0009: MOV $fb , #$ff ; $000a: Timer1
akkera102 2:62e6e22f8be2 86 p000c: MOV $fa , #$4f ; $000d: Timer0
akkera102 2:62e6e22f8be2 87 p000f: MOV $f1 , #$31 ; $0010: SPC Control reg
akkera102 2:62e6e22f8be2 88 p0012: MOV X , #$53 ;
akkera102 2:62e6e22f8be2 89 p0014: MOV $f4 , X ;
akkera102 2:62e6e22f8be2 90 p0016: MOV A , $f4 ;
akkera102 2:62e6e22f8be2 91 p0018: CMP A , #$0 ; $0019: Port0
akkera102 2:62e6e22f8be2 92 p001a: BNE p0016 ;
akkera102 2:62e6e22f8be2 93 p001c: MOV A , $f5 ;
akkera102 2:62e6e22f8be2 94 p001e: CMP A , #$0 ; $001f: Port1
akkera102 2:62e6e22f8be2 95 p0020: BNE p001c ;
akkera102 2:62e6e22f8be2 96 p0022: MOV A , $f6 ;
akkera102 2:62e6e22f8be2 97 p0024: CMP A , #$0 ; $0024: Port2
akkera102 2:62e6e22f8be2 98 p0026: BNE p0022 ;
akkera102 2:62e6e22f8be2 99 p0028: MOV A , $f7 ;
akkera102 2:62e6e22f8be2 100 p002a: CMP A , #$0 ; $002b: Port3
akkera102 2:62e6e22f8be2 101 p002c: BNE p0028 ;
akkera102 2:62e6e22f8be2 102 p002e: MOV A , $fd ;
akkera102 2:62e6e22f8be2 103 p0030: MOV A , $fe ;
akkera102 2:62e6e22f8be2 104 p0032: MOV A , $ff ;
akkera102 2:62e6e22f8be2 105 p0034: MOV $f2 , #$6c ; point to flg register
akkera102 2:62e6e22f8be2 106 p0037: MOV $f3 , #$0 ; $0038: DSP FLG register
akkera102 2:62e6e22f8be2 107 p003a: MOV $f2 , #$4c ; point to kon register
akkera102 2:62e6e22f8be2 108 p003d: MOV $f3 , #$0 ; $003e: DSP KON register
akkera102 2:62e6e22f8be2 109 p0040: MOV $f2 , #$7f ; $0041: SPC dsp reg addr.
akkera102 2:62e6e22f8be2 110 p0043: MOV X , #$f5 ; $0044: SPC stack pointer
akkera102 2:62e6e22f8be2 111 p0045: MOV SP , X ;
akkera102 2:62e6e22f8be2 112 p0046: MOV A , #$ff ; $0047: SPC A register
akkera102 2:62e6e22f8be2 113 p0048: MOV Y , #$0 ; $0049: SPC Y register
akkera102 2:62e6e22f8be2 114 p004a: MOV X , #$0 ; $004b: SPC X register
akkera102 2:62e6e22f8be2 115 p004c: RETI ;
akkera102 2:62e6e22f8be2 116
akkera102 2:62e6e22f8be2 117
akkera102 2:62e6e22f8be2 118 */