Bulk convert all DOS line endings to UNIX.
For the git migration we want a nice clean repository with UNIX line endings. git does not use svn:eol-style, we just need the file contents to be sane. Sorry everybody. I know this messes up blame. Scumbag *NIX developer says migrating to git will make line ending issues go away; commits giant change to svn which changes line endings anyway. :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30924 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d9b7d58fa6
commit
569285794b
|
@ -1,20 +1,20 @@
|
|||
/* YM2413 tone by okazaki@angel.ne.jp */
|
||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x61,0x1e,0x17,0xf0,0x7f,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x13,0x41,0x16,0x0e,0xfd,0xf4,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x01,0x9a,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x11,0x61,0x0e,0x07,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x22,0x16,0x05,0xf0,0x71,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1d,0x07,0x82,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x21,0x2d,0x16,0x90,0x90,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x1b,0x06,0x64,0x65,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x0b,0x1a,0x85,0xa0,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x01,0x83,0x10,0xff,0xb4,0x10,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0xc1,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x00,0x0c,0x05,0xc2,0xf6,0x40,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x56,0x03,0x94,0xc2,0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
/* YM2413 tone by okazaki@angel.ne.jp */
|
||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x61,0x1e,0x17,0xf0,0x7f,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x13,0x41,0x16,0x0e,0xfd,0xf4,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x01,0x9a,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x11,0x61,0x0e,0x07,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x22,0x16,0x05,0xf0,0x71,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1d,0x07,0x82,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x21,0x2d,0x16,0x90,0x90,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x1b,0x06,0x64,0x65,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x0b,0x1a,0x85,0xa0,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x01,0x83,0x10,0xff,0xb4,0x10,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0xc1,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x00,0x0c,0x05,0xc2,0xf6,0x40,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x56,0x03,0x94,0xc2,0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
/* YMF281B tone by Chabin */
|
||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x62,0x21,0x1a,0x07,0xf0,0x6f,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x44,0x02,0xf6,0xf4,0x54,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x01,0x97,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x61,0x0a,0x0f,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x61,0x8a,0x0e,0xc0,0x61,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1b,0x07,0x84,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x37,0x32,0xc9,0x01,0x66,0x64,0x40,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x21,0x06,0x03,0xa5,0x71,0x51,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x06,0x11,0x5e,0x07,0xf3,0xf2,0xf6,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x18,0x06,0xf5,0xf3,0x20,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0x41,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x65,0x61,0x15,0x00,0xf7,0xf3,0x16,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x0e,0x07,0xfa,0xf3,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x48,0x61,0x09,0x07,0xf1,0x94,0xf0,0xf5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
/* YMF281B tone by Chabin */
|
||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x62,0x21,0x1a,0x07,0xf0,0x6f,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x44,0x02,0xf6,0xf4,0x54,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x03,0x01,0x97,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x61,0x0a,0x0f,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x61,0x8a,0x0e,0xc0,0x61,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1b,0x07,0x84,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x37,0x32,0xc9,0x01,0x66,0x64,0x40,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x21,0x06,0x03,0xa5,0x71,0x51,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x06,0x11,0x5e,0x07,0xf3,0xf2,0xf6,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x18,0x06,0xf5,0xf3,0x20,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0x41,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x65,0x61,0x15,0x00,0xf7,0xf3,0x16,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x0e,0x07,0xfa,0xf3,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x48,0x61,0x09,0x07,0xf1,0x94,0xf0,0xf5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,42 +1,42 @@
|
|||
// Library configuration. Modify this file as necessary.
|
||||
|
||||
#ifndef BLARGG_CONFIG_H
|
||||
#define BLARGG_CONFIG_H
|
||||
|
||||
// Uncomment to enable platform-specific optimizations
|
||||
//#define BLARGG_NONPORTABLE 1
|
||||
|
||||
// Uncomment if automatic byte-order determination doesn't work
|
||||
#ifdef ROCKBOX_BIG_ENDIAN
|
||||
#define BLARGG_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
// Uncomment if you get errors in the bool section of blargg_common.h
|
||||
#define BLARGG_COMPILER_HAS_BOOL 1
|
||||
|
||||
// Uncomment to use fast gb apu implementation
|
||||
// #define GB_APU_FAST 1
|
||||
|
||||
// Uncomment to remove agb emulation support
|
||||
// #define GB_APU_NO_AGB 1
|
||||
|
||||
// Uncomment to emulate only nes apu
|
||||
// #define NSF_EMU_APU_ONLY 1
|
||||
|
||||
// Uncomment to remove vrc7 apu support
|
||||
// #define NSF_EMU_NO_VRC7 1
|
||||
|
||||
// Uncomment to remove fmopl apu support
|
||||
// #define KSS_EMU_NO_FMOPL 1
|
||||
|
||||
// To handle undefined reference to assert
|
||||
#define NDEBUG 1
|
||||
|
||||
// Use standard config.h if present
|
||||
#define HAVE_CONFIG_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// Library configuration. Modify this file as necessary.
|
||||
|
||||
#ifndef BLARGG_CONFIG_H
|
||||
#define BLARGG_CONFIG_H
|
||||
|
||||
// Uncomment to enable platform-specific optimizations
|
||||
//#define BLARGG_NONPORTABLE 1
|
||||
|
||||
// Uncomment if automatic byte-order determination doesn't work
|
||||
#ifdef ROCKBOX_BIG_ENDIAN
|
||||
#define BLARGG_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
// Uncomment if you get errors in the bool section of blargg_common.h
|
||||
#define BLARGG_COMPILER_HAS_BOOL 1
|
||||
|
||||
// Uncomment to use fast gb apu implementation
|
||||
// #define GB_APU_FAST 1
|
||||
|
||||
// Uncomment to remove agb emulation support
|
||||
// #define GB_APU_NO_AGB 1
|
||||
|
||||
// Uncomment to emulate only nes apu
|
||||
// #define NSF_EMU_APU_ONLY 1
|
||||
|
||||
// Uncomment to remove vrc7 apu support
|
||||
// #define NSF_EMU_NO_VRC7 1
|
||||
|
||||
// Uncomment to remove fmopl apu support
|
||||
// #define KSS_EMU_NO_FMOPL 1
|
||||
|
||||
// To handle undefined reference to assert
|
||||
#define NDEBUG 1
|
||||
|
||||
// Use standard config.h if present
|
||||
#define HAVE_CONFIG_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,164 +1,164 @@
|
|||
#ifndef _EMU2413_H_
|
||||
#define _EMU2413_H_
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "emutypes.h"
|
||||
|
||||
#ifdef EMU2413_DLL_EXPORTS
|
||||
#define EMU2413_API __declspec(dllexport)
|
||||
#elif defined(EMU2413_DLL_IMPORTS)
|
||||
#define EMU2413_API __declspec(dllimport)
|
||||
#else
|
||||
#define EMU2413_API
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AUDIO_MONO_BUFFER_SIZE 1024
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ;
|
||||
|
||||
/* voice data */
|
||||
typedef struct __OPLL_PATCH {
|
||||
e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
|
||||
} OPLL_PATCH ;
|
||||
|
||||
/* slot */
|
||||
typedef struct __OPLL_SLOT {
|
||||
|
||||
OPLL_PATCH *patch;
|
||||
|
||||
e_int32 type ; /* 0 : modulator 1 : carrier */
|
||||
|
||||
/* OUTPUT */
|
||||
e_int32 feedback ;
|
||||
e_int32 output[2] ; /* Output value of slot */
|
||||
|
||||
/* for Phase Generator (PG) */
|
||||
e_uint16 *sintbl ; /* Wavetable */
|
||||
e_uint32 phase ; /* Phase */
|
||||
e_uint32 dphase ; /* Phase increment amount */
|
||||
e_uint32 pgout ; /* output */
|
||||
|
||||
/* for Envelope Generator (EG) */
|
||||
e_int32 fnum ; /* F-Number */
|
||||
e_int32 block ; /* Block */
|
||||
e_int32 volume ; /* Current volume */
|
||||
e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */
|
||||
e_uint32 tll ; /* Total Level + Key scale level*/
|
||||
e_uint32 rks ; /* Key scale offset (Rks) */
|
||||
e_int32 eg_mode ; /* Current state */
|
||||
e_uint32 eg_phase ; /* Phase */
|
||||
e_uint32 eg_dphase ; /* Phase increment amount */
|
||||
e_uint32 egout ; /* output */
|
||||
|
||||
} OPLL_SLOT ;
|
||||
|
||||
/* Mask */
|
||||
#define OPLL_MASK_CH(x) (1<<(x))
|
||||
#define OPLL_MASK_HH (1<<(9))
|
||||
#define OPLL_MASK_CYM (1<<(10))
|
||||
#define OPLL_MASK_TOM (1<<(11))
|
||||
#define OPLL_MASK_SD (1<<(12))
|
||||
#define OPLL_MASK_BD (1<<(13))
|
||||
#define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD )
|
||||
|
||||
/* opll */
|
||||
typedef struct __OPLL {
|
||||
|
||||
e_uint32 adr ;
|
||||
e_int32 out ;
|
||||
|
||||
#ifndef EMU2413_COMPACTION
|
||||
e_uint32 realstep ;
|
||||
e_uint32 oplltime ;
|
||||
e_uint32 opllstep ;
|
||||
e_int32 prev, next ;
|
||||
e_int32 sprev[2],snext[2];
|
||||
e_uint32 pan[16];
|
||||
#endif
|
||||
|
||||
/* Register */
|
||||
e_uint8 reg[0x40] ;
|
||||
e_int32 slot_on_flag[18] ;
|
||||
|
||||
/* Pitch Modulator */
|
||||
e_uint32 pm_phase ;
|
||||
e_int32 lfo_pm ;
|
||||
|
||||
/* Amp Modulator */
|
||||
e_int32 am_phase ;
|
||||
e_int32 lfo_am ;
|
||||
|
||||
e_uint32 quality;
|
||||
|
||||
/* Noise Generator */
|
||||
e_uint32 noise_seed ;
|
||||
|
||||
/* Channel Data */
|
||||
e_int32 patch_number[9];
|
||||
e_int32 key_status[9] ;
|
||||
|
||||
/* Slot */
|
||||
OPLL_SLOT slot[18] ;
|
||||
|
||||
/* Voice Data */
|
||||
OPLL_PATCH patch[19*2] ;
|
||||
e_int32 patch_update[2] ; /* flag for check patch update */
|
||||
|
||||
e_uint32 mask ;
|
||||
e_uint32 current_mask;
|
||||
e_uint32 status;
|
||||
|
||||
e_uint32 internal_mute;
|
||||
e_int16 buffer[AUDIO_MONO_BUFFER_SIZE];
|
||||
} OPLL ;
|
||||
|
||||
/* Create Object */
|
||||
EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ;
|
||||
EMU2413_API void OPLL_delete(OPLL *) ;
|
||||
|
||||
/* Setup */
|
||||
EMU2413_API void OPLL_reset(OPLL *) ;
|
||||
EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ;
|
||||
EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ;
|
||||
EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ;
|
||||
EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan);
|
||||
EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute);
|
||||
EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *);
|
||||
|
||||
/* Port/Register access */
|
||||
EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val);
|
||||
EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val);
|
||||
EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port);
|
||||
|
||||
/* Synthsize */
|
||||
EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE;
|
||||
EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ;
|
||||
EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ;
|
||||
|
||||
/* Misc */
|
||||
EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ;
|
||||
EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ;
|
||||
EMU2413_API void OPLL_forceRefresh(OPLL *) ;
|
||||
/* Utility */
|
||||
EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ;
|
||||
EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ;
|
||||
EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ;
|
||||
|
||||
/* Channel Mask */
|
||||
EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
|
||||
EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
|
||||
|
||||
#define dump2patch OPLL_dump2patch
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _EMU2413_H_
|
||||
#define _EMU2413_H_
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "emutypes.h"
|
||||
|
||||
#ifdef EMU2413_DLL_EXPORTS
|
||||
#define EMU2413_API __declspec(dllexport)
|
||||
#elif defined(EMU2413_DLL_IMPORTS)
|
||||
#define EMU2413_API __declspec(dllimport)
|
||||
#else
|
||||
#define EMU2413_API
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AUDIO_MONO_BUFFER_SIZE 1024
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ;
|
||||
|
||||
/* voice data */
|
||||
typedef struct __OPLL_PATCH {
|
||||
e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
|
||||
} OPLL_PATCH ;
|
||||
|
||||
/* slot */
|
||||
typedef struct __OPLL_SLOT {
|
||||
|
||||
OPLL_PATCH *patch;
|
||||
|
||||
e_int32 type ; /* 0 : modulator 1 : carrier */
|
||||
|
||||
/* OUTPUT */
|
||||
e_int32 feedback ;
|
||||
e_int32 output[2] ; /* Output value of slot */
|
||||
|
||||
/* for Phase Generator (PG) */
|
||||
e_uint16 *sintbl ; /* Wavetable */
|
||||
e_uint32 phase ; /* Phase */
|
||||
e_uint32 dphase ; /* Phase increment amount */
|
||||
e_uint32 pgout ; /* output */
|
||||
|
||||
/* for Envelope Generator (EG) */
|
||||
e_int32 fnum ; /* F-Number */
|
||||
e_int32 block ; /* Block */
|
||||
e_int32 volume ; /* Current volume */
|
||||
e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */
|
||||
e_uint32 tll ; /* Total Level + Key scale level*/
|
||||
e_uint32 rks ; /* Key scale offset (Rks) */
|
||||
e_int32 eg_mode ; /* Current state */
|
||||
e_uint32 eg_phase ; /* Phase */
|
||||
e_uint32 eg_dphase ; /* Phase increment amount */
|
||||
e_uint32 egout ; /* output */
|
||||
|
||||
} OPLL_SLOT ;
|
||||
|
||||
/* Mask */
|
||||
#define OPLL_MASK_CH(x) (1<<(x))
|
||||
#define OPLL_MASK_HH (1<<(9))
|
||||
#define OPLL_MASK_CYM (1<<(10))
|
||||
#define OPLL_MASK_TOM (1<<(11))
|
||||
#define OPLL_MASK_SD (1<<(12))
|
||||
#define OPLL_MASK_BD (1<<(13))
|
||||
#define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD )
|
||||
|
||||
/* opll */
|
||||
typedef struct __OPLL {
|
||||
|
||||
e_uint32 adr ;
|
||||
e_int32 out ;
|
||||
|
||||
#ifndef EMU2413_COMPACTION
|
||||
e_uint32 realstep ;
|
||||
e_uint32 oplltime ;
|
||||
e_uint32 opllstep ;
|
||||
e_int32 prev, next ;
|
||||
e_int32 sprev[2],snext[2];
|
||||
e_uint32 pan[16];
|
||||
#endif
|
||||
|
||||
/* Register */
|
||||
e_uint8 reg[0x40] ;
|
||||
e_int32 slot_on_flag[18] ;
|
||||
|
||||
/* Pitch Modulator */
|
||||
e_uint32 pm_phase ;
|
||||
e_int32 lfo_pm ;
|
||||
|
||||
/* Amp Modulator */
|
||||
e_int32 am_phase ;
|
||||
e_int32 lfo_am ;
|
||||
|
||||
e_uint32 quality;
|
||||
|
||||
/* Noise Generator */
|
||||
e_uint32 noise_seed ;
|
||||
|
||||
/* Channel Data */
|
||||
e_int32 patch_number[9];
|
||||
e_int32 key_status[9] ;
|
||||
|
||||
/* Slot */
|
||||
OPLL_SLOT slot[18] ;
|
||||
|
||||
/* Voice Data */
|
||||
OPLL_PATCH patch[19*2] ;
|
||||
e_int32 patch_update[2] ; /* flag for check patch update */
|
||||
|
||||
e_uint32 mask ;
|
||||
e_uint32 current_mask;
|
||||
e_uint32 status;
|
||||
|
||||
e_uint32 internal_mute;
|
||||
e_int16 buffer[AUDIO_MONO_BUFFER_SIZE];
|
||||
} OPLL ;
|
||||
|
||||
/* Create Object */
|
||||
EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ;
|
||||
EMU2413_API void OPLL_delete(OPLL *) ;
|
||||
|
||||
/* Setup */
|
||||
EMU2413_API void OPLL_reset(OPLL *) ;
|
||||
EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ;
|
||||
EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ;
|
||||
EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ;
|
||||
EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan);
|
||||
EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute);
|
||||
EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *);
|
||||
|
||||
/* Port/Register access */
|
||||
EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val);
|
||||
EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val);
|
||||
EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port);
|
||||
|
||||
/* Synthsize */
|
||||
EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE;
|
||||
EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ;
|
||||
EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ;
|
||||
|
||||
/* Misc */
|
||||
EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ;
|
||||
EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ;
|
||||
EMU2413_API void OPLL_forceRefresh(OPLL *) ;
|
||||
/* Utility */
|
||||
EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ;
|
||||
EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ;
|
||||
EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ;
|
||||
|
||||
/* Channel Mask */
|
||||
EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
|
||||
EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
|
||||
|
||||
#define dump2patch OPLL_dump2patch
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,210 +1,210 @@
|
|||
#ifndef _EMUTABLES_H_
|
||||
#define _EMUTABLES_H_
|
||||
|
||||
/* Precalculated emu2413 tables for use in Rockbox,
|
||||
Calculated for 44Khz sampling rate */
|
||||
|
||||
#include "emutypes.h"
|
||||
|
||||
static const e_uint16 sin_coeff[] = {
|
||||
255, 203, 171, 152, 139, 129, 120,
|
||||
113, 107, 102, 97, 92, 88, 85,
|
||||
81, 78, 75, 72, 70, 67, 65,
|
||||
63, 61, 59, 57, 55, 53, 52,
|
||||
50, 48, 47, 45, 44, 43, 41,
|
||||
40, 39, 38, 37, 35, 34, 33,
|
||||
32, 31, 30, 29, 28, 28, 27,
|
||||
26, 25, 24, 23, 23, 22, 21,
|
||||
21, 20, 19, 19, 18, 17, 17,
|
||||
16, 16, 15, 14, 14, 13, 13,
|
||||
12, 12, 11, 11, 11, 10, 10,
|
||||
9, 9, 8, 8, 8, 7, 7,
|
||||
7, 6, 6, 6, 5, 5, 5,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
};
|
||||
|
||||
static const e_int16 pm_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
258, 258, 258, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 253, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255,
|
||||
};
|
||||
|
||||
static const e_int8 am_coeff[] = {
|
||||
13, 13, 13, 13, 13, 14, 14,
|
||||
14, 14, 14, 15, 15, 15, 15,
|
||||
15, 16, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 18, 18, 18,
|
||||
18, 18, 19, 19, 19, 19, 19,
|
||||
20, 20, 20, 20, 20, 21, 21,
|
||||
21, 21, 21, 22, 22, 22, 22,
|
||||
22, 23, 23, 23, 23, 23, 24,
|
||||
24, 24, 24, 24, 25, 25, 25,
|
||||
25, 26, 25, 25, 25, 25, 24,
|
||||
24, 24, 24, 24, 23, 23, 23,
|
||||
23, 23, 22, 22, 22, 22, 22,
|
||||
21, 21, 21, 21, 21, 20, 20,
|
||||
20, 20, 20, 19, 19, 19, 19,
|
||||
19, 18, 18, 18, 18, 18, 17,
|
||||
17, 17, 17, 17, 16, 16, 16,
|
||||
16, 16, 15, 15, 15, 15, 15,
|
||||
14, 14, 14, 14, 14, 13, 13,
|
||||
13, 13, 13, 12, 12, 12, 12,
|
||||
11, 11, 11, 11, 11, 10, 10,
|
||||
10, 10, 10, 9, 9, 9, 9,
|
||||
9, 8, 8, 8, 8, 8, 7,
|
||||
7, 7, 7, 7, 6, 6, 6,
|
||||
6, 6, 5, 5, 5, 5, 5,
|
||||
4, 4, 4, 4, 4, 3, 3,
|
||||
3, 3, 3, 2, 2, 2, 2,
|
||||
2, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 2,
|
||||
2, 2, 2, 2, 3, 3, 3,
|
||||
3, 3, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 6, 6,
|
||||
6, 6, 6, 7, 7, 7, 7,
|
||||
7, 8, 8, 8, 8, 8, 9,
|
||||
9, 9, 9, 9, 10, 10, 10,
|
||||
10, 10, 11, 11, 11, 11, 11,
|
||||
12, 12, 12, 12,
|
||||
};
|
||||
|
||||
static const e_int16 db2lin_coeff[] = {
|
||||
255, 249, 244, 239, 233, 228, 224,
|
||||
219, 214, 209, 205, 201, 196, 192,
|
||||
188, 184, 180, 176, 172, 169, 165,
|
||||
162, 158, 155, 151, 148, 145, 142,
|
||||
139, 136, 133, 130, 127, 125, 122,
|
||||
119, 117, 114, 112, 109, 107, 105,
|
||||
102, 100, 98, 96, 94, 92, 90,
|
||||
88, 86, 84, 82, 81, 79, 77,
|
||||
76, 74, 72, 71, 69, 68, 66,
|
||||
65, 64, 62, 61, 60, 58, 57,
|
||||
56, 55, 53, 52, 51, 50, 49,
|
||||
48, 47, 46, 45, 44, 43, 42,
|
||||
41, 40, 39, 38, 38, 37, 36,
|
||||
35, 34, 34, 33, 32, 32, 31,
|
||||
30, 30, 29, 28, 28, 27, 27,
|
||||
26, 25, 25, 24, 24, 23, 23,
|
||||
22, 22, 21, 21, 20, 20, 19,
|
||||
19, 19, 18, 18, 17, 17, 17,
|
||||
16, 16, 16, 15, 15, 15, 14,
|
||||
14, 14, 13, 13, 13, 12, 12,
|
||||
12, 12, 11, 11, 11, 11, 10,
|
||||
10, 10, 10, 10, 9, 9, 9,
|
||||
9, 8, 8, 8, 8, 8, 8,
|
||||
7, 7, 7, 7, 7, 7, 6,
|
||||
6, 6, 6, 6, 6, 6, 5,
|
||||
5, 5, 5, 5, 5, 5, 5,
|
||||
5, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
2, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
};
|
||||
|
||||
static const e_uint16 ar_adjust_coeff[] = {
|
||||
127, 108, 98, 90, 84, 80, 75,
|
||||
72, 69, 66, 64, 61, 59, 57,
|
||||
56, 54, 52, 51, 49, 48, 47,
|
||||
45, 44, 43, 42, 41, 40, 39,
|
||||
38, 37, 36, 36, 35, 34, 33,
|
||||
33, 32, 31, 30, 30, 29, 29,
|
||||
28, 27, 27, 26, 26, 25, 24,
|
||||
24, 23, 23, 22, 22, 21, 21,
|
||||
21, 20, 20, 19, 19, 18, 18,
|
||||
17, 17, 17, 16, 16, 15, 15,
|
||||
15, 14, 14, 14, 13, 13, 13,
|
||||
12, 12, 12, 11, 11, 11, 10,
|
||||
10, 10, 9, 9, 9, 9, 8,
|
||||
8, 8, 7, 7, 7, 7, 6,
|
||||
6, 6, 6, 5, 5, 5, 4,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 0, 0, 0, 0,
|
||||
0,
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _EMUTABLES_H_
|
||||
#define _EMUTABLES_H_
|
||||
|
||||
/* Precalculated emu2413 tables for use in Rockbox,
|
||||
Calculated for 44Khz sampling rate */
|
||||
|
||||
#include "emutypes.h"
|
||||
|
||||
static const e_uint16 sin_coeff[] = {
|
||||
255, 203, 171, 152, 139, 129, 120,
|
||||
113, 107, 102, 97, 92, 88, 85,
|
||||
81, 78, 75, 72, 70, 67, 65,
|
||||
63, 61, 59, 57, 55, 53, 52,
|
||||
50, 48, 47, 45, 44, 43, 41,
|
||||
40, 39, 38, 37, 35, 34, 33,
|
||||
32, 31, 30, 29, 28, 28, 27,
|
||||
26, 25, 24, 23, 23, 22, 21,
|
||||
21, 20, 19, 19, 18, 17, 17,
|
||||
16, 16, 15, 14, 14, 13, 13,
|
||||
12, 12, 11, 11, 11, 10, 10,
|
||||
9, 9, 8, 8, 8, 7, 7,
|
||||
7, 6, 6, 6, 5, 5, 5,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
};
|
||||
|
||||
static const e_int16 pm_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
258, 258, 258, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 253, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254,
|
||||
254, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255,
|
||||
};
|
||||
|
||||
static const e_int8 am_coeff[] = {
|
||||
13, 13, 13, 13, 13, 14, 14,
|
||||
14, 14, 14, 15, 15, 15, 15,
|
||||
15, 16, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 18, 18, 18,
|
||||
18, 18, 19, 19, 19, 19, 19,
|
||||
20, 20, 20, 20, 20, 21, 21,
|
||||
21, 21, 21, 22, 22, 22, 22,
|
||||
22, 23, 23, 23, 23, 23, 24,
|
||||
24, 24, 24, 24, 25, 25, 25,
|
||||
25, 26, 25, 25, 25, 25, 24,
|
||||
24, 24, 24, 24, 23, 23, 23,
|
||||
23, 23, 22, 22, 22, 22, 22,
|
||||
21, 21, 21, 21, 21, 20, 20,
|
||||
20, 20, 20, 19, 19, 19, 19,
|
||||
19, 18, 18, 18, 18, 18, 17,
|
||||
17, 17, 17, 17, 16, 16, 16,
|
||||
16, 16, 15, 15, 15, 15, 15,
|
||||
14, 14, 14, 14, 14, 13, 13,
|
||||
13, 13, 13, 12, 12, 12, 12,
|
||||
11, 11, 11, 11, 11, 10, 10,
|
||||
10, 10, 10, 9, 9, 9, 9,
|
||||
9, 8, 8, 8, 8, 8, 7,
|
||||
7, 7, 7, 7, 6, 6, 6,
|
||||
6, 6, 5, 5, 5, 5, 5,
|
||||
4, 4, 4, 4, 4, 3, 3,
|
||||
3, 3, 3, 2, 2, 2, 2,
|
||||
2, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 2,
|
||||
2, 2, 2, 2, 3, 3, 3,
|
||||
3, 3, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 6, 6,
|
||||
6, 6, 6, 7, 7, 7, 7,
|
||||
7, 8, 8, 8, 8, 8, 9,
|
||||
9, 9, 9, 9, 10, 10, 10,
|
||||
10, 10, 11, 11, 11, 11, 11,
|
||||
12, 12, 12, 12,
|
||||
};
|
||||
|
||||
static const e_int16 db2lin_coeff[] = {
|
||||
255, 249, 244, 239, 233, 228, 224,
|
||||
219, 214, 209, 205, 201, 196, 192,
|
||||
188, 184, 180, 176, 172, 169, 165,
|
||||
162, 158, 155, 151, 148, 145, 142,
|
||||
139, 136, 133, 130, 127, 125, 122,
|
||||
119, 117, 114, 112, 109, 107, 105,
|
||||
102, 100, 98, 96, 94, 92, 90,
|
||||
88, 86, 84, 82, 81, 79, 77,
|
||||
76, 74, 72, 71, 69, 68, 66,
|
||||
65, 64, 62, 61, 60, 58, 57,
|
||||
56, 55, 53, 52, 51, 50, 49,
|
||||
48, 47, 46, 45, 44, 43, 42,
|
||||
41, 40, 39, 38, 38, 37, 36,
|
||||
35, 34, 34, 33, 32, 32, 31,
|
||||
30, 30, 29, 28, 28, 27, 27,
|
||||
26, 25, 25, 24, 24, 23, 23,
|
||||
22, 22, 21, 21, 20, 20, 19,
|
||||
19, 19, 18, 18, 17, 17, 17,
|
||||
16, 16, 16, 15, 15, 15, 14,
|
||||
14, 14, 13, 13, 13, 12, 12,
|
||||
12, 12, 11, 11, 11, 11, 10,
|
||||
10, 10, 10, 10, 9, 9, 9,
|
||||
9, 8, 8, 8, 8, 8, 8,
|
||||
7, 7, 7, 7, 7, 7, 6,
|
||||
6, 6, 6, 6, 6, 6, 5,
|
||||
5, 5, 5, 5, 5, 5, 5,
|
||||
5, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2,
|
||||
2, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
};
|
||||
|
||||
static const e_uint16 ar_adjust_coeff[] = {
|
||||
127, 108, 98, 90, 84, 80, 75,
|
||||
72, 69, 66, 64, 61, 59, 57,
|
||||
56, 54, 52, 51, 49, 48, 47,
|
||||
45, 44, 43, 42, 41, 40, 39,
|
||||
38, 37, 36, 36, 35, 34, 33,
|
||||
33, 32, 31, 30, 30, 29, 29,
|
||||
28, 27, 27, 26, 26, 25, 24,
|
||||
24, 23, 23, 22, 22, 21, 21,
|
||||
21, 20, 20, 19, 19, 18, 18,
|
||||
17, 17, 17, 16, 16, 15, 15,
|
||||
15, 14, 14, 14, 13, 13, 13,
|
||||
12, 12, 12, 11, 11, 11, 10,
|
||||
10, 10, 9, 9, 9, 9, 8,
|
||||
8, 8, 7, 7, 7, 7, 6,
|
||||
6, 6, 6, 5, 5, 5, 4,
|
||||
4, 4, 4, 4, 3, 3, 3,
|
||||
3, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 0, 0, 0, 0,
|
||||
0,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
#ifndef _EMUTYPES_H_
|
||||
#define _EMUTYPES_H_
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#elif defined(_MWERKS_)
|
||||
#define INLINE inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#if defined(EMU_DLL_IMPORTS)
|
||||
#define EMU2149_DLL_IMPORTS
|
||||
#define EMU2212_DLL_IMPORTS
|
||||
#define EMU2413_DLL_IMPORTS
|
||||
#define EMU8950_DLL_IMPORTS
|
||||
#define EMU76489_DLL_IMPORTS
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned int e_uint;
|
||||
typedef signed int e_int;
|
||||
|
||||
typedef unsigned char e_uint8 ;
|
||||
typedef signed char e_int8 ;
|
||||
|
||||
typedef unsigned short e_uint16 ;
|
||||
typedef signed short e_int16 ;
|
||||
|
||||
typedef unsigned int e_uint32 ;
|
||||
typedef signed int e_int32 ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _EMUTYPES_H_
|
||||
#define _EMUTYPES_H_
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#elif defined(_MWERKS_)
|
||||
#define INLINE inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#if defined(EMU_DLL_IMPORTS)
|
||||
#define EMU2149_DLL_IMPORTS
|
||||
#define EMU2212_DLL_IMPORTS
|
||||
#define EMU2413_DLL_IMPORTS
|
||||
#define EMU8950_DLL_IMPORTS
|
||||
#define EMU76489_DLL_IMPORTS
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned int e_uint;
|
||||
typedef signed int e_int;
|
||||
|
||||
typedef unsigned char e_uint8 ;
|
||||
typedef signed char e_int8 ;
|
||||
|
||||
typedef unsigned short e_uint16 ;
|
||||
typedef signed short e_int16 ;
|
||||
|
||||
typedef unsigned int e_uint32 ;
|
||||
typedef signed int e_int32 ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,297 +1,297 @@
|
|||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "hes_apu_adpcm.h"
|
||||
|
||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
void Adpcm_init( struct Hes_Apu_Adpcm* this )
|
||||
{
|
||||
this->output = NULL;
|
||||
memset( &this->state, 0, sizeof( this->state ) );
|
||||
Adpcm_reset( this );
|
||||
}
|
||||
|
||||
void Adpcm_reset( struct Hes_Apu_Adpcm* this )
|
||||
{
|
||||
this->last_time = 0;
|
||||
this->next_timer = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) );
|
||||
memset( &this->state.port, 0, sizeof(this->state.port) );
|
||||
|
||||
this->state.ad_sample = 0;
|
||||
this->state.ad_ref_index = 0;
|
||||
|
||||
this->state.addr = 0;
|
||||
this->state.freq = 0;
|
||||
this->state.writeptr = 0;
|
||||
this->state.readptr = 0;
|
||||
this->state.playflag = 0;
|
||||
this->state.repeatflag = 0;
|
||||
this->state.length = 0;
|
||||
this->state.volume = 0xFF;
|
||||
this->state.fadetimer = 0;
|
||||
this->state.fadecount = 0;
|
||||
}
|
||||
|
||||
static short stepsize[49] = {
|
||||
16, 17, 19, 21, 23, 25, 28,
|
||||
31, 34, 37, 41, 45, 50, 55,
|
||||
60, 66, 73, 80, 88, 97, 107,
|
||||
118, 130, 143, 157, 173, 190, 209,
|
||||
230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796,
|
||||
876, 963,1060,1166,1282,1411,1552
|
||||
};
|
||||
|
||||
static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code );
|
||||
static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code )
|
||||
{
|
||||
struct State* state = &this->state;
|
||||
int step = stepsize[state->ad_ref_index];
|
||||
int delta;
|
||||
int c = code & 7;
|
||||
#if 1
|
||||
delta = 0;
|
||||
if ( c & 4 ) delta += step;
|
||||
step >>= 1;
|
||||
if ( c & 2 ) delta += step;
|
||||
step >>= 1;
|
||||
if ( c & 1 ) delta += step;
|
||||
step >>= 1;
|
||||
delta += step;
|
||||
#else
|
||||
delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding
|
||||
#endif
|
||||
if ( c != code )
|
||||
{
|
||||
state->ad_sample -= delta;
|
||||
if ( state->ad_sample < -2048 )
|
||||
state->ad_sample = -2048;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->ad_sample += delta;
|
||||
if ( state->ad_sample > 2047 )
|
||||
state->ad_sample = 2047;
|
||||
}
|
||||
|
||||
static int const steps [8] = {
|
||||
-1, -1, -1, -1, 2, 4, 6, 8
|
||||
};
|
||||
state->ad_ref_index += steps [c];
|
||||
if ( state->ad_ref_index < 0 )
|
||||
state->ad_ref_index = 0;
|
||||
else if ( state->ad_ref_index > 48 )
|
||||
state->ad_ref_index = 48;
|
||||
|
||||
return state->ad_sample;
|
||||
}
|
||||
|
||||
static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time );
|
||||
static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
||||
{
|
||||
struct State* state = &this->state;
|
||||
int volume = state->volume;
|
||||
int fadetimer = state->fadetimer;
|
||||
int fadecount = state->fadecount;
|
||||
int last_time = this->last_time;
|
||||
int next_timer = this->next_timer;
|
||||
int last_amp = this->last_amp;
|
||||
|
||||
struct Blip_Buffer* output = this->output; // cache often-used values
|
||||
|
||||
while ( state->playflag && last_time < end_time )
|
||||
{
|
||||
while ( last_time >= next_timer )
|
||||
{
|
||||
if ( fadetimer )
|
||||
{
|
||||
if ( fadecount > 0 )
|
||||
{
|
||||
fadecount--;
|
||||
volume = 0xFF * fadecount / fadetimer;
|
||||
}
|
||||
else if ( fadecount < 0 )
|
||||
{
|
||||
fadecount++;
|
||||
volume = 0xFF - ( 0xFF * fadecount / fadetimer );
|
||||
}
|
||||
}
|
||||
next_timer += 7159; // 7159091/1000;
|
||||
}
|
||||
int amp;
|
||||
if ( state->ad_low_nibble )
|
||||
{
|
||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F );
|
||||
state->ad_low_nibble = false;
|
||||
state->playptr++;
|
||||
state->playedsamplecount++;
|
||||
if ( state->playedsamplecount == state->playlength )
|
||||
{
|
||||
state->playflag = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 );
|
||||
state->ad_low_nibble = true;
|
||||
}
|
||||
amp = amp * volume / 0xFF;
|
||||
int delta = amp - last_amp;
|
||||
if ( output && delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, last_time, delta, output );
|
||||
}
|
||||
last_time += state->freq;
|
||||
}
|
||||
|
||||
if ( !state->playflag )
|
||||
{
|
||||
while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000
|
||||
last_time = end_time;
|
||||
}
|
||||
|
||||
this->last_time = last_time;
|
||||
this->next_timer = next_timer;
|
||||
this->last_amp = last_amp;
|
||||
state->volume = volume;
|
||||
state->fadetimer = fadetimer;
|
||||
state->fadecount = fadecount;
|
||||
}
|
||||
|
||||
void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr, int data )
|
||||
{
|
||||
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||
struct State* state = &this->state;
|
||||
|
||||
data &= 0xFF;
|
||||
state->port[ addr & 15 ] = data;
|
||||
switch ( addr & 15 )
|
||||
{
|
||||
case 8:
|
||||
state->addr &= 0xFF00;
|
||||
state->addr |= data;
|
||||
break;
|
||||
case 9:
|
||||
state->addr &= 0xFF;
|
||||
state->addr |= data << 8;
|
||||
break;
|
||||
case 10:
|
||||
state->pcmbuf[ state->writeptr++ ] = data;
|
||||
state->playlength ++;
|
||||
break;
|
||||
case 11:
|
||||
dprintf("ADPCM DMA 0x%02X", data);
|
||||
break;
|
||||
case 13:
|
||||
if ( data & 0x80 )
|
||||
{
|
||||
state->addr = 0;
|
||||
state->freq = 0;
|
||||
state->writeptr = 0;
|
||||
state->readptr = 0;
|
||||
state->playflag = 0;
|
||||
state->repeatflag = 0;
|
||||
state->length = 0;
|
||||
state->volume = 0xFF;
|
||||
}
|
||||
if ( ( data & 3 ) == 3 )
|
||||
{
|
||||
state->writeptr = state->addr;
|
||||
}
|
||||
if ( data & 8 )
|
||||
{
|
||||
state->readptr = state->addr ? state->addr - 1 : state->addr;
|
||||
}
|
||||
if ( data & 0x10 )
|
||||
{
|
||||
state->length = state->addr;
|
||||
}
|
||||
state->repeatflag = data & 0x20;
|
||||
state->playflag = data & 0x40;
|
||||
if ( state->playflag )
|
||||
{
|
||||
state->playptr = state->readptr;
|
||||
state->playlength = state->length + 1;
|
||||
state->playedsamplecount = 0;
|
||||
state->ad_sample = 0;
|
||||
state->ad_low_nibble = false;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) );
|
||||
break;
|
||||
case 15:
|
||||
switch ( data & 15 )
|
||||
{
|
||||
case 0:
|
||||
case 8:
|
||||
case 12:
|
||||
state->fadetimer = -100;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
case 10:
|
||||
state->fadetimer = 5000;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
case 14:
|
||||
state->fadetimer = 1500;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr )
|
||||
{
|
||||
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||
|
||||
struct State* state = &this->state;
|
||||
switch ( addr & 15 )
|
||||
{
|
||||
case 10:
|
||||
return state->pcmbuf [state->readptr++];
|
||||
case 11:
|
||||
return state->port [11] & ~1;
|
||||
case 12:
|
||||
if (!state->playflag)
|
||||
{
|
||||
state->port [12] |= 1;
|
||||
state->port [12] &= ~8;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->port [12] &= ~1;
|
||||
state->port [12] |= 8;
|
||||
}
|
||||
return state->port [12];
|
||||
case 13:
|
||||
return state->port [13];
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
||||
{
|
||||
Adpcm_run_until( this, end_time );
|
||||
this->last_time -= end_time;
|
||||
this->next_timer -= end_time;
|
||||
check( last_time >= 0 );
|
||||
if ( this->output )
|
||||
Blip_set_modified( this->output );
|
||||
}
|
||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "hes_apu_adpcm.h"
|
||||
|
||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
void Adpcm_init( struct Hes_Apu_Adpcm* this )
|
||||
{
|
||||
this->output = NULL;
|
||||
memset( &this->state, 0, sizeof( this->state ) );
|
||||
Adpcm_reset( this );
|
||||
}
|
||||
|
||||
void Adpcm_reset( struct Hes_Apu_Adpcm* this )
|
||||
{
|
||||
this->last_time = 0;
|
||||
this->next_timer = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) );
|
||||
memset( &this->state.port, 0, sizeof(this->state.port) );
|
||||
|
||||
this->state.ad_sample = 0;
|
||||
this->state.ad_ref_index = 0;
|
||||
|
||||
this->state.addr = 0;
|
||||
this->state.freq = 0;
|
||||
this->state.writeptr = 0;
|
||||
this->state.readptr = 0;
|
||||
this->state.playflag = 0;
|
||||
this->state.repeatflag = 0;
|
||||
this->state.length = 0;
|
||||
this->state.volume = 0xFF;
|
||||
this->state.fadetimer = 0;
|
||||
this->state.fadecount = 0;
|
||||
}
|
||||
|
||||
static short stepsize[49] = {
|
||||
16, 17, 19, 21, 23, 25, 28,
|
||||
31, 34, 37, 41, 45, 50, 55,
|
||||
60, 66, 73, 80, 88, 97, 107,
|
||||
118, 130, 143, 157, 173, 190, 209,
|
||||
230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796,
|
||||
876, 963,1060,1166,1282,1411,1552
|
||||
};
|
||||
|
||||
static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code );
|
||||
static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code )
|
||||
{
|
||||
struct State* state = &this->state;
|
||||
int step = stepsize[state->ad_ref_index];
|
||||
int delta;
|
||||
int c = code & 7;
|
||||
#if 1
|
||||
delta = 0;
|
||||
if ( c & 4 ) delta += step;
|
||||
step >>= 1;
|
||||
if ( c & 2 ) delta += step;
|
||||
step >>= 1;
|
||||
if ( c & 1 ) delta += step;
|
||||
step >>= 1;
|
||||
delta += step;
|
||||
#else
|
||||
delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding
|
||||
#endif
|
||||
if ( c != code )
|
||||
{
|
||||
state->ad_sample -= delta;
|
||||
if ( state->ad_sample < -2048 )
|
||||
state->ad_sample = -2048;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->ad_sample += delta;
|
||||
if ( state->ad_sample > 2047 )
|
||||
state->ad_sample = 2047;
|
||||
}
|
||||
|
||||
static int const steps [8] = {
|
||||
-1, -1, -1, -1, 2, 4, 6, 8
|
||||
};
|
||||
state->ad_ref_index += steps [c];
|
||||
if ( state->ad_ref_index < 0 )
|
||||
state->ad_ref_index = 0;
|
||||
else if ( state->ad_ref_index > 48 )
|
||||
state->ad_ref_index = 48;
|
||||
|
||||
return state->ad_sample;
|
||||
}
|
||||
|
||||
static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time );
|
||||
static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
||||
{
|
||||
struct State* state = &this->state;
|
||||
int volume = state->volume;
|
||||
int fadetimer = state->fadetimer;
|
||||
int fadecount = state->fadecount;
|
||||
int last_time = this->last_time;
|
||||
int next_timer = this->next_timer;
|
||||
int last_amp = this->last_amp;
|
||||
|
||||
struct Blip_Buffer* output = this->output; // cache often-used values
|
||||
|
||||
while ( state->playflag && last_time < end_time )
|
||||
{
|
||||
while ( last_time >= next_timer )
|
||||
{
|
||||
if ( fadetimer )
|
||||
{
|
||||
if ( fadecount > 0 )
|
||||
{
|
||||
fadecount--;
|
||||
volume = 0xFF * fadecount / fadetimer;
|
||||
}
|
||||
else if ( fadecount < 0 )
|
||||
{
|
||||
fadecount++;
|
||||
volume = 0xFF - ( 0xFF * fadecount / fadetimer );
|
||||
}
|
||||
}
|
||||
next_timer += 7159; // 7159091/1000;
|
||||
}
|
||||
int amp;
|
||||
if ( state->ad_low_nibble )
|
||||
{
|
||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F );
|
||||
state->ad_low_nibble = false;
|
||||
state->playptr++;
|
||||
state->playedsamplecount++;
|
||||
if ( state->playedsamplecount == state->playlength )
|
||||
{
|
||||
state->playflag = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 );
|
||||
state->ad_low_nibble = true;
|
||||
}
|
||||
amp = amp * volume / 0xFF;
|
||||
int delta = amp - last_amp;
|
||||
if ( output && delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, last_time, delta, output );
|
||||
}
|
||||
last_time += state->freq;
|
||||
}
|
||||
|
||||
if ( !state->playflag )
|
||||
{
|
||||
while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000
|
||||
last_time = end_time;
|
||||
}
|
||||
|
||||
this->last_time = last_time;
|
||||
this->next_timer = next_timer;
|
||||
this->last_amp = last_amp;
|
||||
state->volume = volume;
|
||||
state->fadetimer = fadetimer;
|
||||
state->fadecount = fadecount;
|
||||
}
|
||||
|
||||
void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr, int data )
|
||||
{
|
||||
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||
struct State* state = &this->state;
|
||||
|
||||
data &= 0xFF;
|
||||
state->port[ addr & 15 ] = data;
|
||||
switch ( addr & 15 )
|
||||
{
|
||||
case 8:
|
||||
state->addr &= 0xFF00;
|
||||
state->addr |= data;
|
||||
break;
|
||||
case 9:
|
||||
state->addr &= 0xFF;
|
||||
state->addr |= data << 8;
|
||||
break;
|
||||
case 10:
|
||||
state->pcmbuf[ state->writeptr++ ] = data;
|
||||
state->playlength ++;
|
||||
break;
|
||||
case 11:
|
||||
dprintf("ADPCM DMA 0x%02X", data);
|
||||
break;
|
||||
case 13:
|
||||
if ( data & 0x80 )
|
||||
{
|
||||
state->addr = 0;
|
||||
state->freq = 0;
|
||||
state->writeptr = 0;
|
||||
state->readptr = 0;
|
||||
state->playflag = 0;
|
||||
state->repeatflag = 0;
|
||||
state->length = 0;
|
||||
state->volume = 0xFF;
|
||||
}
|
||||
if ( ( data & 3 ) == 3 )
|
||||
{
|
||||
state->writeptr = state->addr;
|
||||
}
|
||||
if ( data & 8 )
|
||||
{
|
||||
state->readptr = state->addr ? state->addr - 1 : state->addr;
|
||||
}
|
||||
if ( data & 0x10 )
|
||||
{
|
||||
state->length = state->addr;
|
||||
}
|
||||
state->repeatflag = data & 0x20;
|
||||
state->playflag = data & 0x40;
|
||||
if ( state->playflag )
|
||||
{
|
||||
state->playptr = state->readptr;
|
||||
state->playlength = state->length + 1;
|
||||
state->playedsamplecount = 0;
|
||||
state->ad_sample = 0;
|
||||
state->ad_low_nibble = false;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) );
|
||||
break;
|
||||
case 15:
|
||||
switch ( data & 15 )
|
||||
{
|
||||
case 0:
|
||||
case 8:
|
||||
case 12:
|
||||
state->fadetimer = -100;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
case 10:
|
||||
state->fadetimer = 5000;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
case 14:
|
||||
state->fadetimer = 1500;
|
||||
state->fadecount = state->fadetimer;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr )
|
||||
{
|
||||
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||
|
||||
struct State* state = &this->state;
|
||||
switch ( addr & 15 )
|
||||
{
|
||||
case 10:
|
||||
return state->pcmbuf [state->readptr++];
|
||||
case 11:
|
||||
return state->port [11] & ~1;
|
||||
case 12:
|
||||
if (!state->playflag)
|
||||
{
|
||||
state->port [12] |= 1;
|
||||
state->port [12] &= ~8;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->port [12] &= ~1;
|
||||
state->port [12] |= 8;
|
||||
}
|
||||
return state->port [12];
|
||||
case 13:
|
||||
return state->port [13];
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
||||
{
|
||||
Adpcm_run_until( this, end_time );
|
||||
this->last_time -= end_time;
|
||||
this->next_timer -= end_time;
|
||||
check( last_time >= 0 );
|
||||
if ( this->output )
|
||||
Blip_set_modified( this->output );
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
|
||||
/* Memory buffer reader, simulates file read
|
||||
@ gama
|
||||
*/
|
||||
|
||||
#include "mbreader.h"
|
||||
|
||||
int mbread(struct mbreader_t *md, void *buf, size_t n)
|
||||
{
|
||||
if (!md) return -1;
|
||||
size_t read_bytes = (md->offset+n) > md->size ?
|
||||
md->size-md->offset : n;
|
||||
memcpy(buf,md->ptr + md->offset,read_bytes);
|
||||
md->offset += read_bytes;
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
/* Memory buffer reader, simulates file read
|
||||
@ gama
|
||||
*/
|
||||
|
||||
#include "mbreader.h"
|
||||
|
||||
int mbread(struct mbreader_t *md, void *buf, size_t n)
|
||||
{
|
||||
if (!md) return -1;
|
||||
size_t read_bytes = (md->offset+n) > md->size ?
|
||||
md->size-md->offset : n;
|
||||
memcpy(buf,md->ptr + md->offset,read_bytes);
|
||||
md->offset += read_bytes;
|
||||
return read_bytes;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
|
||||
#ifndef MBREADER_H
|
||||
#define MBREADER_H
|
||||
|
||||
#include "codeclib.h"
|
||||
|
||||
struct mbreader_t {
|
||||
const char *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
int mbread(struct mbreader_t *md, void *buf, size_t n);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MBREADER_H
|
||||
#define MBREADER_H
|
||||
|
||||
#include "codeclib.h"
|
||||
|
||||
struct mbreader_t {
|
||||
const char *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
int mbread(struct mbreader_t *md, void *buf, size_t n);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "kss_emu.h"
|
||||
|
||||
#include "blargg_endian.h"
|
||||
//#include "z80_cpu_log.h"
|
||||
|
||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||
#define IN_PORT( addr ) cpu_in( this, TIME(), addr )
|
||||
#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );}
|
||||
#define IDLE_ADDR idle_addr
|
||||
|
||||
#define CPU_BEGIN \
|
||||
bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\
|
||||
{\
|
||||
struct Z80_Cpu *cpu = &this->cpu; \
|
||||
Z80_set_end_time( cpu, end_time );
|
||||
|
||||
#include "z80_cpu_run.h"
|
||||
|
||||
return warning;
|
||||
}
|
||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "kss_emu.h"
|
||||
|
||||
#include "blargg_endian.h"
|
||||
//#include "z80_cpu_log.h"
|
||||
|
||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||
#define IN_PORT( addr ) cpu_in( this, TIME(), addr )
|
||||
#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );}
|
||||
#define IDLE_ADDR idle_addr
|
||||
|
||||
#define CPU_BEGIN \
|
||||
bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\
|
||||
{\
|
||||
struct Z80_Cpu *cpu = &this->cpu; \
|
||||
Z80_set_end_time( cpu, end_time );
|
||||
|
||||
#include "z80_cpu_run.h"
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,88 +1,88 @@
|
|||
|
||||
#include "nes_vrc7_apu.h"
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const period = 36; // NES CPU clocks per FM clock
|
||||
|
||||
void Vrc7_init( struct Nes_Vrc7_Apu* this )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
|
||||
OPLL_new ( &this->opll, 3579545, 3579545 / 72 );
|
||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||
|
||||
this->osc.output = 0;
|
||||
this->osc.last_amp = 0;
|
||||
this->mask = 0;
|
||||
|
||||
Vrc7_volume( this, (int)FP_ONE_VOLUME );
|
||||
Vrc7_reset( this );
|
||||
}
|
||||
|
||||
void Vrc7_reset( struct Nes_Vrc7_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->osc.last_amp = 0;
|
||||
|
||||
OPLL_reset (&this->opll);
|
||||
OPLL_setMask(&this->opll, this->mask);
|
||||
}
|
||||
|
||||
void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r )
|
||||
{
|
||||
OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 );
|
||||
}
|
||||
|
||||
void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data )
|
||||
{
|
||||
this->addr = data;
|
||||
}
|
||||
|
||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time );
|
||||
void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
Vrc7_run_until( this, time );
|
||||
|
||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
}
|
||||
|
||||
void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
Vrc7_run_until( this, time );
|
||||
|
||||
this->next_time -= time;
|
||||
assert( this->next_time >= 0 );
|
||||
|
||||
if ( this->osc.output )
|
||||
Blip_set_modified( this->osc.output );
|
||||
}
|
||||
|
||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
require( end_time > this->next_time );
|
||||
|
||||
blip_time_t time = this->next_time;
|
||||
OPLL* opll = &this->opll; // cache
|
||||
struct Blip_Buffer* const output = this-> osc.output;
|
||||
if ( output )
|
||||
{
|
||||
do
|
||||
{
|
||||
int amp = OPLL_calc( opll ) << 1;
|
||||
int delta = amp - this->osc.last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
this->osc.last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += period;
|
||||
}
|
||||
while ( time < end_time );
|
||||
}
|
||||
|
||||
this->next_time = time;
|
||||
}
|
||||
|
||||
#include "nes_vrc7_apu.h"
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const period = 36; // NES CPU clocks per FM clock
|
||||
|
||||
void Vrc7_init( struct Nes_Vrc7_Apu* this )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
|
||||
OPLL_new ( &this->opll, 3579545, 3579545 / 72 );
|
||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||
|
||||
this->osc.output = 0;
|
||||
this->osc.last_amp = 0;
|
||||
this->mask = 0;
|
||||
|
||||
Vrc7_volume( this, (int)FP_ONE_VOLUME );
|
||||
Vrc7_reset( this );
|
||||
}
|
||||
|
||||
void Vrc7_reset( struct Nes_Vrc7_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->osc.last_amp = 0;
|
||||
|
||||
OPLL_reset (&this->opll);
|
||||
OPLL_setMask(&this->opll, this->mask);
|
||||
}
|
||||
|
||||
void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r )
|
||||
{
|
||||
OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 );
|
||||
}
|
||||
|
||||
void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data )
|
||||
{
|
||||
this->addr = data;
|
||||
}
|
||||
|
||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time );
|
||||
void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
Vrc7_run_until( this, time );
|
||||
|
||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
}
|
||||
|
||||
void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
Vrc7_run_until( this, time );
|
||||
|
||||
this->next_time -= time;
|
||||
assert( this->next_time >= 0 );
|
||||
|
||||
if ( this->osc.output )
|
||||
Blip_set_modified( this->osc.output );
|
||||
}
|
||||
|
||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
require( end_time > this->next_time );
|
||||
|
||||
blip_time_t time = this->next_time;
|
||||
OPLL* opll = &this->opll; // cache
|
||||
struct Blip_Buffer* const output = this-> osc.output;
|
||||
if ( output )
|
||||
{
|
||||
do
|
||||
{
|
||||
int amp = OPLL_calc( opll ) << 1;
|
||||
int delta = amp - this->osc.last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
this->osc.last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += period;
|
||||
}
|
||||
while ( time < end_time );
|
||||
}
|
||||
|
||||
this->next_time = time;
|
||||
}
|
||||
|
|
|
@ -1,198 +1,198 @@
|
|||
#include "opl_apu.h"
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
/* NOTE: Removed unused chips ~ gama */
|
||||
|
||||
blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
|
||||
this->type_ = type;
|
||||
this->clock_ = clock;
|
||||
this->rate_ = rate;
|
||||
this->period_ = period;
|
||||
Opl_set_output( this, 0 );
|
||||
Opl_volume( this, (int)FP_ONE_VOLUME );
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
OPLL_new ( &this->opll, clock, rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||
break;
|
||||
case type_vrc7:
|
||||
OPLL_new ( &this->opll, clock, rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory );
|
||||
OPL_setSampleRate( &this->opl, rate, clock );
|
||||
OPL_setInternalVolume(&this->opl, 1 << 13);
|
||||
break;
|
||||
}
|
||||
|
||||
Opl_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Opl_shutdown( struct Opl_Apu* this )
|
||||
{
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_delete( &this->opll );
|
||||
break;
|
||||
case type_msxaudio: break;
|
||||
}
|
||||
}
|
||||
|
||||
void Opl_reset( struct Opl_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_reset( &this->opll );
|
||||
OPLL_setMask( &this->opll, 0 );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_reset( &this->opl );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time );
|
||||
void Opl_write_data( struct Opl_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
run_until( this, time );
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_writeReg( &this->opl, this->addr, data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Opl_read( struct Opl_Apu* this, blip_time_t time, int port )
|
||||
{
|
||||
run_until( this, time );
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
return OPLL_read( &this->opll, port );
|
||||
case type_msxaudio:
|
||||
return OPL_readStatus( &this->opl );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Opl_end_frame( struct Opl_Apu* this, blip_time_t time )
|
||||
{
|
||||
run_until( this, time );
|
||||
this->next_time -= time;
|
||||
|
||||
if ( this->output_ )
|
||||
Blip_set_modified( this->output_ );
|
||||
}
|
||||
|
||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
if ( end_time > this->next_time )
|
||||
{
|
||||
blip_time_t time_delta = end_time - this->next_time;
|
||||
blip_time_t time = this->next_time;
|
||||
unsigned count = time_delta / this->period_ + 1;
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
{
|
||||
OPLL* opll = &this->opll; // cache
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
while ( count > 0 )
|
||||
{
|
||||
unsigned todo = count;
|
||||
if ( todo > 1024 ) todo = 1024;
|
||||
short *buffer = OPLL_update_buffer(opll, todo);
|
||||
|
||||
if ( output && buffer )
|
||||
{
|
||||
int last_amp = this->last_amp;
|
||||
unsigned i;
|
||||
for ( i = 0; i < todo; i++ )
|
||||
{
|
||||
int amp = buffer [i];
|
||||
int delta = amp - last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
this->last_amp = last_amp;
|
||||
}
|
||||
count -= todo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case type_msxaudio:
|
||||
{
|
||||
struct Y8950* opl = &this->opl;
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
while ( count > 0 )
|
||||
{
|
||||
unsigned todo = count;
|
||||
if ( todo > 1024 ) todo = 1024;
|
||||
int *buffer = OPL_updateBuffer(opl, todo);
|
||||
|
||||
if ( output && buffer )
|
||||
{
|
||||
int last_amp = this->last_amp;
|
||||
unsigned i;
|
||||
for ( i = 0; i < todo; i++ )
|
||||
{
|
||||
int amp = buffer [i];
|
||||
int delta = amp - last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
this->last_amp = last_amp;
|
||||
}
|
||||
count -= todo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
this->next_time = time;
|
||||
}
|
||||
}
|
||||
#include "opl_apu.h"
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
/* NOTE: Removed unused chips ~ gama */
|
||||
|
||||
blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
|
||||
this->type_ = type;
|
||||
this->clock_ = clock;
|
||||
this->rate_ = rate;
|
||||
this->period_ = period;
|
||||
Opl_set_output( this, 0 );
|
||||
Opl_volume( this, (int)FP_ONE_VOLUME );
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
OPLL_new ( &this->opll, clock, rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||
break;
|
||||
case type_vrc7:
|
||||
OPLL_new ( &this->opll, clock, rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory );
|
||||
OPL_setSampleRate( &this->opl, rate, clock );
|
||||
OPL_setInternalVolume(&this->opl, 1 << 13);
|
||||
break;
|
||||
}
|
||||
|
||||
Opl_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Opl_shutdown( struct Opl_Apu* this )
|
||||
{
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_delete( &this->opll );
|
||||
break;
|
||||
case type_msxaudio: break;
|
||||
}
|
||||
}
|
||||
|
||||
void Opl_reset( struct Opl_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_reset( &this->opll );
|
||||
OPLL_setMask( &this->opll, 0 );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_reset( &this->opl );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time );
|
||||
void Opl_write_data( struct Opl_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
run_until( this, time );
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
break;
|
||||
case type_msxaudio:
|
||||
OPL_writeReg( &this->opl, this->addr, data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Opl_read( struct Opl_Apu* this, blip_time_t time, int port )
|
||||
{
|
||||
run_until( this, time );
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
return OPLL_read( &this->opll, port );
|
||||
case type_msxaudio:
|
||||
return OPL_readStatus( &this->opl );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Opl_end_frame( struct Opl_Apu* this, blip_time_t time )
|
||||
{
|
||||
run_until( this, time );
|
||||
this->next_time -= time;
|
||||
|
||||
if ( this->output_ )
|
||||
Blip_set_modified( this->output_ );
|
||||
}
|
||||
|
||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
if ( end_time > this->next_time )
|
||||
{
|
||||
blip_time_t time_delta = end_time - this->next_time;
|
||||
blip_time_t time = this->next_time;
|
||||
unsigned count = time_delta / this->period_ + 1;
|
||||
switch (this->type_)
|
||||
{
|
||||
case type_opll:
|
||||
case type_msxmusic:
|
||||
case type_smsfmunit:
|
||||
case type_vrc7:
|
||||
{
|
||||
OPLL* opll = &this->opll; // cache
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
while ( count > 0 )
|
||||
{
|
||||
unsigned todo = count;
|
||||
if ( todo > 1024 ) todo = 1024;
|
||||
short *buffer = OPLL_update_buffer(opll, todo);
|
||||
|
||||
if ( output && buffer )
|
||||
{
|
||||
int last_amp = this->last_amp;
|
||||
unsigned i;
|
||||
for ( i = 0; i < todo; i++ )
|
||||
{
|
||||
int amp = buffer [i];
|
||||
int delta = amp - last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
this->last_amp = last_amp;
|
||||
}
|
||||
count -= todo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case type_msxaudio:
|
||||
{
|
||||
struct Y8950* opl = &this->opl;
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
while ( count > 0 )
|
||||
{
|
||||
unsigned todo = count;
|
||||
if ( todo > 1024 ) todo = 1024;
|
||||
int *buffer = OPL_updateBuffer(opl, todo);
|
||||
|
||||
if ( output && buffer )
|
||||
{
|
||||
int last_amp = this->last_amp;
|
||||
unsigned i;
|
||||
for ( i = 0; i < todo; i++ )
|
||||
{
|
||||
int amp = buffer [i];
|
||||
int delta = amp - last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
this->last_amp = last_amp;
|
||||
}
|
||||
count -= todo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
this->next_time = time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
#ifndef OPL_APU_H
|
||||
#define OPL_APU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "blargg_source.h"
|
||||
#include "blip_buffer.h"
|
||||
|
||||
#include "emu8950.h"
|
||||
#include "emu2413.h"
|
||||
|
||||
enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12,
|
||||
type_vrc7 = 0x13, type_msxaudio = 0x21 };
|
||||
|
||||
enum { opl_osc_count = 1 };
|
||||
|
||||
struct Opl_Apu {
|
||||
struct Blip_Buffer* output_;
|
||||
enum opl_type_t type_;
|
||||
|
||||
blip_time_t next_time;
|
||||
int last_amp;
|
||||
int addr;
|
||||
|
||||
long clock_;
|
||||
long rate_;
|
||||
blip_time_t period_;
|
||||
|
||||
struct Blip_Synth synth;
|
||||
|
||||
// OPL chips
|
||||
struct Y8950 opl;
|
||||
OPLL opll;
|
||||
|
||||
unsigned char regs[ 0x100 ];
|
||||
unsigned char opl_memory[ 32768 ];
|
||||
};
|
||||
|
||||
blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type );
|
||||
void Opl_shutdown( struct Opl_Apu* this );
|
||||
|
||||
void Opl_reset( struct Opl_Apu* this );
|
||||
static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); }
|
||||
|
||||
static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf )
|
||||
{
|
||||
#if defined(ROCKBOX)
|
||||
(void) i;
|
||||
#endif
|
||||
assert( (unsigned) i < opl_osc_count );
|
||||
this->output_ = buf;
|
||||
}
|
||||
|
||||
static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, buf ); }
|
||||
void Opl_end_frame( struct Opl_Apu* this, blip_time_t );
|
||||
|
||||
static inline void Opl_write_addr( struct Opl_Apu* this, int data ) { this->addr = data; }
|
||||
void Opl_write_data( struct Opl_Apu* this, blip_time_t, int data );
|
||||
|
||||
int Opl_read( struct Opl_Apu* this, blip_time_t, int port );
|
||||
|
||||
static inline bool Opl_supported( void ) { return true; }
|
||||
|
||||
#endif
|
||||
#ifndef OPL_APU_H
|
||||
#define OPL_APU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "blargg_source.h"
|
||||
#include "blip_buffer.h"
|
||||
|
||||
#include "emu8950.h"
|
||||
#include "emu2413.h"
|
||||
|
||||
enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12,
|
||||
type_vrc7 = 0x13, type_msxaudio = 0x21 };
|
||||
|
||||
enum { opl_osc_count = 1 };
|
||||
|
||||
struct Opl_Apu {
|
||||
struct Blip_Buffer* output_;
|
||||
enum opl_type_t type_;
|
||||
|
||||
blip_time_t next_time;
|
||||
int last_amp;
|
||||
int addr;
|
||||
|
||||
long clock_;
|
||||
long rate_;
|
||||
blip_time_t period_;
|
||||
|
||||
struct Blip_Synth synth;
|
||||
|
||||
// OPL chips
|
||||
struct Y8950 opl;
|
||||
OPLL opll;
|
||||
|
||||
unsigned char regs[ 0x100 ];
|
||||
unsigned char opl_memory[ 32768 ];
|
||||
};
|
||||
|
||||
blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type );
|
||||
void Opl_shutdown( struct Opl_Apu* this );
|
||||
|
||||
void Opl_reset( struct Opl_Apu* this );
|
||||
static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); }
|
||||
|
||||
static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf )
|
||||
{
|
||||
#if defined(ROCKBOX)
|
||||
(void) i;
|
||||
#endif
|
||||
assert( (unsigned) i < opl_osc_count );
|
||||
this->output_ = buf;
|
||||
}
|
||||
|
||||
static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, buf ); }
|
||||
void Opl_end_frame( struct Opl_Apu* this, blip_time_t );
|
||||
|
||||
static inline void Opl_write_addr( struct Opl_Apu* this, int data ) { this->addr = data; }
|
||||
void Opl_write_data( struct Opl_Apu* this, blip_time_t, int data );
|
||||
|
||||
int Opl_read( struct Opl_Apu* this, blip_time_t, int port );
|
||||
|
||||
static inline bool Opl_supported( void ) { return true; }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,242 +1,242 @@
|
|||
#ifndef _OPLTABLES_H_
|
||||
#define _OPLTABLES_H_
|
||||
|
||||
/* Precalculated emu8950 tables for use in Rockbox,
|
||||
Calculated for 44Khz sampling rate */
|
||||
|
||||
static const short ar_adjust_coeff[] = {
|
||||
255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157,
|
||||
153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128,
|
||||
126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112,
|
||||
110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100,
|
||||
99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91,
|
||||
90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83,
|
||||
82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77,
|
||||
76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71,
|
||||
71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66,
|
||||
66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62,
|
||||
62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58,
|
||||
58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55,
|
||||
54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51,
|
||||
51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48,
|
||||
48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45,
|
||||
45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43,
|
||||
43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40,
|
||||
40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38,
|
||||
38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36,
|
||||
36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34,
|
||||
33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
|
||||
31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
|
||||
30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
|
||||
28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26,
|
||||
26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25,
|
||||
24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23,
|
||||
23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21,
|
||||
21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20,
|
||||
20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18,
|
||||
18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17,
|
||||
17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const short db2lin_coeff[] = {
|
||||
2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649,
|
||||
1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300,
|
||||
1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025,
|
||||
1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809,
|
||||
791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638,
|
||||
624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503,
|
||||
492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396,
|
||||
388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312,
|
||||
306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246,
|
||||
241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194,
|
||||
190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153,
|
||||
150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121,
|
||||
118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95,
|
||||
93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75,
|
||||
73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59,
|
||||
58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46,
|
||||
45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36,
|
||||
36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29,
|
||||
28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22,
|
||||
22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18,
|
||||
17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14,
|
||||
13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11,
|
||||
11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8,
|
||||
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
|
||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const short sin_coeff[] = {
|
||||
511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129,
|
||||
124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95,
|
||||
92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75,
|
||||
74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62,
|
||||
61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52,
|
||||
51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43,
|
||||
43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37,
|
||||
36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31,
|
||||
30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26,
|
||||
25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22,
|
||||
21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18,
|
||||
18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
|
||||
14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
|
||||
12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9,
|
||||
9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7,
|
||||
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
|
||||
5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,
|
||||
};
|
||||
|
||||
static const short pm0_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255,
|
||||
};
|
||||
|
||||
static const short pm1_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
258, 258, 258, 258, 258, 258, 258, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253,
|
||||
253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
|
||||
253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255,
|
||||
};
|
||||
|
||||
static const short am0_coeff[] = {
|
||||
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2,
|
||||
};
|
||||
|
||||
static const short am1_coeff[] = {
|
||||
12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
|
||||
16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
||||
19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23,
|
||||
23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
|
||||
21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18,
|
||||
18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15,
|
||||
14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11,
|
||||
11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8,
|
||||
8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5,
|
||||
5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8,
|
||||
8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11,
|
||||
11, 12, 12,
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _OPLTABLES_H_
|
||||
#define _OPLTABLES_H_
|
||||
|
||||
/* Precalculated emu8950 tables for use in Rockbox,
|
||||
Calculated for 44Khz sampling rate */
|
||||
|
||||
static const short ar_adjust_coeff[] = {
|
||||
255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157,
|
||||
153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128,
|
||||
126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112,
|
||||
110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100,
|
||||
99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91,
|
||||
90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83,
|
||||
82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77,
|
||||
76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71,
|
||||
71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66,
|
||||
66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62,
|
||||
62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58,
|
||||
58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55,
|
||||
54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51,
|
||||
51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48,
|
||||
48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45,
|
||||
45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43,
|
||||
43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40,
|
||||
40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38,
|
||||
38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36,
|
||||
36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34,
|
||||
33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
|
||||
31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
|
||||
30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
|
||||
28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26,
|
||||
26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25,
|
||||
24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23,
|
||||
23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21,
|
||||
21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20,
|
||||
20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18,
|
||||
18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17,
|
||||
17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const short db2lin_coeff[] = {
|
||||
2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649,
|
||||
1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300,
|
||||
1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025,
|
||||
1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809,
|
||||
791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638,
|
||||
624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503,
|
||||
492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396,
|
||||
388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312,
|
||||
306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246,
|
||||
241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194,
|
||||
190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153,
|
||||
150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121,
|
||||
118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95,
|
||||
93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75,
|
||||
73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59,
|
||||
58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46,
|
||||
45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36,
|
||||
36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29,
|
||||
28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22,
|
||||
22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18,
|
||||
17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14,
|
||||
13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11,
|
||||
11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8,
|
||||
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
|
||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const short sin_coeff[] = {
|
||||
511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129,
|
||||
124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95,
|
||||
92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75,
|
||||
74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62,
|
||||
61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52,
|
||||
51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43,
|
||||
43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37,
|
||||
36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31,
|
||||
30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26,
|
||||
25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22,
|
||||
21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18,
|
||||
18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
|
||||
14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
|
||||
12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9,
|
||||
9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7,
|
||||
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
|
||||
5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,
|
||||
};
|
||||
|
||||
static const short pm0_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255,
|
||||
};
|
||||
|
||||
static const short pm1_coeff[] = {
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
258, 258, 258, 258, 258, 258, 258, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
|
||||
256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253,
|
||||
253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
|
||||
253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
|
||||
254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255,
|
||||
};
|
||||
|
||||
static const short am0_coeff[] = {
|
||||
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2,
|
||||
};
|
||||
|
||||
static const short am1_coeff[] = {
|
||||
12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
|
||||
16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
||||
19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23,
|
||||
23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
|
||||
21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18,
|
||||
18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15,
|
||||
14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11,
|
||||
11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8,
|
||||
8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5,
|
||||
5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8,
|
||||
8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11,
|
||||
11, 12, 12,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "sgc_emu.h"
|
||||
|
||||
#include "blargg_endian.h"
|
||||
//#include "z80_cpu_log.h"
|
||||
|
||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||
#define IN_PORT( addr ) 0 // cpu in
|
||||
#define WRITE_MEM( addr, data ) cpu_write( this, addr, data )
|
||||
#define IDLE_ADDR this->idle_addr
|
||||
#define RST_BASE this->vectors_addr
|
||||
|
||||
#define CPU_BEGIN \
|
||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\
|
||||
{\
|
||||
Sgc_Cpu* cpu = &this->cpu; \
|
||||
Z80_set_end_time( cpu, end_time );
|
||||
|
||||
#include "z80_cpu_run.h"
|
||||
|
||||
return warning;
|
||||
}
|
||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "sgc_emu.h"
|
||||
|
||||
#include "blargg_endian.h"
|
||||
//#include "z80_cpu_log.h"
|
||||
|
||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||
#define IN_PORT( addr ) 0 // cpu in
|
||||
#define WRITE_MEM( addr, data ) cpu_write( this, addr, data )
|
||||
#define IDLE_ADDR this->idle_addr
|
||||
#define RST_BASE this->vectors_addr
|
||||
|
||||
#define CPU_BEGIN \
|
||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\
|
||||
{\
|
||||
Sgc_Cpu* cpu = &this->cpu; \
|
||||
Z80_set_end_time( cpu, end_time );
|
||||
|
||||
#include "z80_cpu_run.h"
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
|
|
@ -1,480 +1,480 @@
|
|||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "sgc_emu.h"
|
||||
|
||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License aint with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const osc_count = sms_osc_count + fm_apu_osc_count;
|
||||
|
||||
const char gme_wrong_file_type [] = "Wrong file type for this emulator";
|
||||
|
||||
static void clear_track_vars( struct Sgc_Emu* this )
|
||||
{
|
||||
this->current_track = -1;
|
||||
track_stop( &this->track_filter );
|
||||
}
|
||||
|
||||
void Sgc_init( struct Sgc_Emu* this )
|
||||
{
|
||||
assert( offsetof (struct header_t,copyright [32]) == header_size );
|
||||
|
||||
this->sample_rate = 0;
|
||||
this->mute_mask_ = 0;
|
||||
this->tempo = (int)FP_ONE_TEMPO;
|
||||
this->gain = (int)FP_ONE_GAIN;
|
||||
|
||||
// defaults
|
||||
this->tfilter = *track_get_setup( &this->track_filter );
|
||||
this->tfilter.max_initial = 2;
|
||||
this->tfilter.lookahead = 6;
|
||||
this->track_filter.silence_ignored_ = false;
|
||||
|
||||
Sms_apu_init( &this->apu );
|
||||
Fm_apu_create( &this->fm_apu );
|
||||
|
||||
Rom_init( &this->rom, 0x4000 );
|
||||
Z80_init( &this->cpu );
|
||||
|
||||
Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) );
|
||||
|
||||
// Unload
|
||||
this->voice_count = 0;
|
||||
this->voice_types = 0;
|
||||
clear_track_vars( this );
|
||||
}
|
||||
|
||||
// Setup
|
||||
|
||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size )
|
||||
{
|
||||
RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) );
|
||||
|
||||
if ( !valid_tag( &this->header ) )
|
||||
return gme_wrong_file_type;
|
||||
|
||||
/* if ( header.vers != 1 )
|
||||
warning( "Unknown file version" ); */
|
||||
|
||||
/* if ( header.system > 2 )
|
||||
warning( "Unknown system" ); */
|
||||
|
||||
addr_t load_addr = get_le16( this->header.load_addr );
|
||||
/* if ( load_addr < 0x400 )
|
||||
set_warning( "Invalid load address" ); */
|
||||
|
||||
Rom_set_addr( &this->rom, load_addr );
|
||||
this->play_period = clock_rate( this ) / 60;
|
||||
|
||||
if ( sega_mapping( this ) && Fm_apu_supported() )
|
||||
RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) );
|
||||
|
||||
this->m3u.size = 0;
|
||||
this->track_count = this->header.song_count;
|
||||
this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count;
|
||||
static int const types [sms_osc_count + fm_apu_osc_count] = {
|
||||
wave_type+1, wave_type+2, wave_type+3, mixed_type+1, mixed_type+2
|
||||
};
|
||||
this->voice_types = types;
|
||||
|
||||
Sms_apu_volume( &this->apu, this->gain );
|
||||
Fm_apu_volume( &this->fm_apu, this->gain );
|
||||
|
||||
// Setup buffer
|
||||
this->clock_rate_ = clock_rate( this );
|
||||
Buffer_clock_rate( &this->stereo_buf, clock_rate( this ) );
|
||||
RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) );
|
||||
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||
|
||||
Sound_set_tempo( this, this->tempo );
|
||||
Sound_mute_voices( this, this->mute_mask_ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Sound_set_voice( struct Sgc_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r )
|
||||
{
|
||||
if ( i < sms_osc_count )
|
||||
Sms_apu_set_output( &this->apu, i, c, l, r );
|
||||
else
|
||||
Fm_apu_set_output( &this->fm_apu, c );
|
||||
}
|
||||
|
||||
static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec )
|
||||
{
|
||||
#if defined(ROCKBOX)
|
||||
(void) msec;
|
||||
#endif
|
||||
|
||||
cpu_time_t t = *duration;
|
||||
while ( Z80_time( &this->cpu ) < t )
|
||||
{
|
||||
cpu_time_t next = min( t, this->next_play );
|
||||
if ( run_cpu( this, next ) )
|
||||
{
|
||||
/* warning( "Unsupported CPU instruction" ); */
|
||||
Z80_set_time( &this->cpu, next );
|
||||
}
|
||||
|
||||
if ( this->cpu.r.pc == this->idle_addr )
|
||||
Z80_set_time( &this->cpu, next );
|
||||
|
||||
if ( Z80_time( &this->cpu ) >= this->next_play )
|
||||
{
|
||||
this->next_play += this->play_period;
|
||||
if ( this->cpu.r.pc == this->idle_addr )
|
||||
jsr( this, this->header.play_addr );
|
||||
}
|
||||
}
|
||||
|
||||
this->next_play -= t;
|
||||
check( this->next_play >= 0 );
|
||||
Z80_adjust_time( &this->cpu, -t );
|
||||
|
||||
Sms_apu_end_frame( &this->apu, t );
|
||||
if ( sega_mapping( this ) && this->fm_accessed )
|
||||
{
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_end_frame( &this->fm_apu, t );
|
||||
/* else
|
||||
warning( "FM sound not supported" ); */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Emulation
|
||||
|
||||
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data )
|
||||
{
|
||||
int port = addr & 0xFF;
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
switch ( port )
|
||||
{
|
||||
case 0x06:
|
||||
Sms_apu_write_ggstereo( &this->apu, time, data );
|
||||
return;
|
||||
|
||||
case 0x7E:
|
||||
case 0x7F:
|
||||
Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */
|
||||
return;
|
||||
|
||||
case 0xF0:
|
||||
this->fm_accessed = true;
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data );
|
||||
return;
|
||||
|
||||
case 0xF1:
|
||||
this->fm_accessed = true;
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( port >= 0xE0 )
|
||||
{
|
||||
Sms_apu_write_data( &this->apu, time, data );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void jsr( struct Sgc_Emu* this, byte addr [2] )
|
||||
{
|
||||
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr >> 8;
|
||||
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF;
|
||||
this->cpu.r.pc = get_le16( addr );
|
||||
}
|
||||
|
||||
static void set_bank( struct Sgc_Emu* this, int bank, void const* data )
|
||||
{
|
||||
//dprintf( "map bank %d to %p\n", bank, (byte*) data - rom.at_addr( 0 ) );
|
||||
Z80_map_mem( &this->cpu, bank * this->rom.bank_size, this->rom.bank_size, this->unmapped_write, data );
|
||||
}
|
||||
|
||||
void cpu_write( struct Sgc_Emu* this, addr_t addr, int data )
|
||||
{
|
||||
if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) )
|
||||
{
|
||||
*Z80_write( &this->cpu, addr ) = data;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( addr )
|
||||
{
|
||||
case 0xFFFC:
|
||||
Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 );
|
||||
if ( data & 0x08 )
|
||||
break;
|
||||
|
||||
this->bank2 = this->ram2;
|
||||
// FALL THROUGH
|
||||
|
||||
case 0xFFFF: {
|
||||
bool rom_mapped = (Z80_read( &this->cpu, 2 * this->rom.bank_size ) == this->bank2);
|
||||
this->bank2 = Rom_at_addr( &this->rom, data * this->rom.bank_size );
|
||||
if ( rom_mapped )
|
||||
set_bank( this, 2, this->bank2 );
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xFFFD:
|
||||
set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||
break;
|
||||
|
||||
case 0xFFFE:
|
||||
set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int rate )
|
||||
{
|
||||
require( !this->sample_rate ); // sample rate can't be changed once set
|
||||
Buffer_init( &this->stereo_buf );
|
||||
Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 );
|
||||
|
||||
// Set buffer bass
|
||||
Buffer_bass_freq( &this->stereo_buf, 80 );
|
||||
|
||||
this->sample_rate = rate;
|
||||
RETURN_ERR( track_init( &this->track_filter, this ) );
|
||||
this->tfilter.max_silence = 6 * stereo * this->sample_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute )
|
||||
{
|
||||
require( (unsigned) index < (unsigned) this->voice_count );
|
||||
int bit = 1 << index;
|
||||
int mask = this->mute_mask_ | bit;
|
||||
if ( !mute )
|
||||
mask ^= bit;
|
||||
Sound_mute_voices( this, mask );
|
||||
}
|
||||
|
||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask )
|
||||
{
|
||||
require( this->sample_rate ); // sample rate must be set first
|
||||
this->mute_mask_ = mask;
|
||||
|
||||
int i;
|
||||
for ( i = this->voice_count; i--; )
|
||||
{
|
||||
if ( mask & (1 << i) )
|
||||
{
|
||||
Sound_set_voice( this, i, 0, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
struct channel_t ch = Buffer_channel( &this->stereo_buf, i );
|
||||
assert( (ch.center && ch.left && ch.right) ||
|
||||
(!ch.center && !ch.left && !ch.right) ); // all or nothing
|
||||
Sound_set_voice( this, i, ch.center, ch.left, ch.right );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sound_set_tempo( struct Sgc_Emu* this, int t )
|
||||
{
|
||||
require( this->sample_rate ); // sample rate must be set first
|
||||
int const min = (int)(FP_ONE_TEMPO*0.02);
|
||||
int const max = (int)(FP_ONE_TEMPO*4.00);
|
||||
if ( t < min ) t = min;
|
||||
if ( t > max ) t = max;
|
||||
this->tempo = t;
|
||||
|
||||
this->play_period = (int) ((clock_rate( this ) * FP_ONE_TEMPO) / (this->header.rate ? 50 : 60) / t);
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track )
|
||||
{
|
||||
clear_track_vars( this );
|
||||
|
||||
// Remap track if playlist available
|
||||
if ( this->m3u.size > 0 ) {
|
||||
struct entry_t* e = &this->m3u.entries[track];
|
||||
track = e->track;
|
||||
}
|
||||
|
||||
this->current_track = track;
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
Sms_apu_reset( &this->apu, 0, 0 );
|
||||
Fm_apu_reset( &this->fm_apu );
|
||||
this->fm_accessed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Sms_apu_reset( &this->apu, 0x0003, 15 );
|
||||
}
|
||||
|
||||
memset( this->ram , 0, sizeof this->ram );
|
||||
memset( this->ram2, 0, sizeof this->ram2 );
|
||||
memset( this->vectors, 0xFF, sizeof this->vectors );
|
||||
Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped );
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
this->vectors_addr = 0x10000 - page_size;
|
||||
this->idle_addr = this->vectors_addr;
|
||||
int i;
|
||||
for ( i = 1; i < 8; ++i )
|
||||
{
|
||||
this->vectors [i*8 + 0] = 0xC3; // JP addr
|
||||
this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff;
|
||||
this->vectors [i*8 + 2] = this->header.rst_addrs [i - 1] >> 8;
|
||||
}
|
||||
|
||||
Z80_map_mem_rw( &this->cpu, 0xC000, 0x2000, this->ram );
|
||||
Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors );
|
||||
|
||||
this->bank2 = NULL;
|
||||
for ( i = 0; i < 4; ++i )
|
||||
cpu_write( this, 0xFFFC + i, this->header.mapping [i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !this->coleco_bios )
|
||||
return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */
|
||||
|
||||
this->vectors_addr = 0;
|
||||
Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios );
|
||||
int i;
|
||||
for ( i = 0; i < 8; ++i )
|
||||
Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram );
|
||||
|
||||
this->idle_addr = 0x2000;
|
||||
Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors );
|
||||
|
||||
for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i )
|
||||
{
|
||||
int addr = 0x8000 + i*this->rom.bank_size;
|
||||
Z80_map_mem( &this->cpu, addr, this->rom.bank_size, this->unmapped_write, Rom_at_addr( &this->rom, addr ) );
|
||||
}
|
||||
}
|
||||
|
||||
this->cpu.r.sp = get_le16( this->header.stack_ptr );
|
||||
this->cpu.r.b.a = track;
|
||||
this->next_play = this->play_period;
|
||||
|
||||
jsr( this, this->header.init_addr );
|
||||
|
||||
Buffer_clear( &this->stereo_buf );
|
||||
|
||||
// convert filter times to samples
|
||||
struct setup_t s = this->tfilter;
|
||||
s.max_initial *= this->sample_rate * stereo;
|
||||
#ifdef GME_DISABLE_SILENCE_LOOKAHEAD
|
||||
s.lookahead = 1;
|
||||
#endif
|
||||
track_setup( &this->track_filter, &s );
|
||||
|
||||
return track_start( &this->track_filter );
|
||||
}
|
||||
|
||||
// Tell/Seek
|
||||
|
||||
static int msec_to_samples( int msec, int sample_rate )
|
||||
{
|
||||
int sec = msec / 1000;
|
||||
msec -= sec * 1000;
|
||||
return (sec * sample_rate + msec * sample_rate / 1000) * stereo;
|
||||
}
|
||||
|
||||
int Track_tell( struct Sgc_Emu* this )
|
||||
{
|
||||
int rate = this->sample_rate * stereo;
|
||||
int sec = track_sample_count( &this->track_filter ) / rate;
|
||||
return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate;
|
||||
}
|
||||
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec )
|
||||
{
|
||||
int time = msec_to_samples( msec, this->sample_rate );
|
||||
if ( time < track_sample_count( &this->track_filter ) )
|
||||
RETURN_ERR( Sgc_start_track( this, this->current_track ) );
|
||||
return Track_skip( this, time - track_sample_count( &this->track_filter ) );
|
||||
}
|
||||
|
||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int count )
|
||||
{
|
||||
require( this->current_track >= 0 ); // start_track() must have been called already
|
||||
return track_skip( &this->track_filter, count );
|
||||
}
|
||||
|
||||
blargg_err_t skip_( void* emu, int count )
|
||||
{
|
||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||
|
||||
// for long skip, mute sound
|
||||
const int threshold = 32768;
|
||||
if ( count > threshold )
|
||||
{
|
||||
int saved_mute = this->mute_mask_;
|
||||
Sound_mute_voices( this, ~0 );
|
||||
|
||||
int n = count - threshold/2;
|
||||
n &= ~(2048-1); // round to multiple of 2048
|
||||
count -= n;
|
||||
RETURN_ERR( skippy_( &this->track_filter, n ) );
|
||||
|
||||
Sound_mute_voices( this, saved_mute );
|
||||
}
|
||||
|
||||
return skippy_( &this->track_filter, count );
|
||||
}
|
||||
|
||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec )
|
||||
{
|
||||
track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ),
|
||||
length_msec * this->sample_rate / (1000 / stereo) );
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out )
|
||||
{
|
||||
require( this->current_track >= 0 );
|
||||
require( out_count % stereo == 0 );
|
||||
return track_play( &this->track_filter, out_count, out );
|
||||
}
|
||||
|
||||
blargg_err_t play_( void* emu, int count, sample_t out [] )
|
||||
{
|
||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||
|
||||
int remain = count;
|
||||
while ( remain )
|
||||
{
|
||||
Buffer_disable_immediate_removal( &this->stereo_buf );
|
||||
remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain );
|
||||
if ( remain )
|
||||
{
|
||||
if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) )
|
||||
{
|
||||
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||
|
||||
// Remute voices
|
||||
Sound_mute_voices( this, this->mute_mask_ );
|
||||
}
|
||||
int msec = Buffer_length( &this->stereo_buf );
|
||||
blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100;
|
||||
RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) );
|
||||
assert( clocks_emulated );
|
||||
Buffer_end_frame( &this->stereo_buf, clocks_emulated );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "sgc_emu.h"
|
||||
|
||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License aint with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const osc_count = sms_osc_count + fm_apu_osc_count;
|
||||
|
||||
const char gme_wrong_file_type [] = "Wrong file type for this emulator";
|
||||
|
||||
static void clear_track_vars( struct Sgc_Emu* this )
|
||||
{
|
||||
this->current_track = -1;
|
||||
track_stop( &this->track_filter );
|
||||
}
|
||||
|
||||
void Sgc_init( struct Sgc_Emu* this )
|
||||
{
|
||||
assert( offsetof (struct header_t,copyright [32]) == header_size );
|
||||
|
||||
this->sample_rate = 0;
|
||||
this->mute_mask_ = 0;
|
||||
this->tempo = (int)FP_ONE_TEMPO;
|
||||
this->gain = (int)FP_ONE_GAIN;
|
||||
|
||||
// defaults
|
||||
this->tfilter = *track_get_setup( &this->track_filter );
|
||||
this->tfilter.max_initial = 2;
|
||||
this->tfilter.lookahead = 6;
|
||||
this->track_filter.silence_ignored_ = false;
|
||||
|
||||
Sms_apu_init( &this->apu );
|
||||
Fm_apu_create( &this->fm_apu );
|
||||
|
||||
Rom_init( &this->rom, 0x4000 );
|
||||
Z80_init( &this->cpu );
|
||||
|
||||
Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) );
|
||||
|
||||
// Unload
|
||||
this->voice_count = 0;
|
||||
this->voice_types = 0;
|
||||
clear_track_vars( this );
|
||||
}
|
||||
|
||||
// Setup
|
||||
|
||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size )
|
||||
{
|
||||
RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) );
|
||||
|
||||
if ( !valid_tag( &this->header ) )
|
||||
return gme_wrong_file_type;
|
||||
|
||||
/* if ( header.vers != 1 )
|
||||
warning( "Unknown file version" ); */
|
||||
|
||||
/* if ( header.system > 2 )
|
||||
warning( "Unknown system" ); */
|
||||
|
||||
addr_t load_addr = get_le16( this->header.load_addr );
|
||||
/* if ( load_addr < 0x400 )
|
||||
set_warning( "Invalid load address" ); */
|
||||
|
||||
Rom_set_addr( &this->rom, load_addr );
|
||||
this->play_period = clock_rate( this ) / 60;
|
||||
|
||||
if ( sega_mapping( this ) && Fm_apu_supported() )
|
||||
RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) );
|
||||
|
||||
this->m3u.size = 0;
|
||||
this->track_count = this->header.song_count;
|
||||
this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count;
|
||||
static int const types [sms_osc_count + fm_apu_osc_count] = {
|
||||
wave_type+1, wave_type+2, wave_type+3, mixed_type+1, mixed_type+2
|
||||
};
|
||||
this->voice_types = types;
|
||||
|
||||
Sms_apu_volume( &this->apu, this->gain );
|
||||
Fm_apu_volume( &this->fm_apu, this->gain );
|
||||
|
||||
// Setup buffer
|
||||
this->clock_rate_ = clock_rate( this );
|
||||
Buffer_clock_rate( &this->stereo_buf, clock_rate( this ) );
|
||||
RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) );
|
||||
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||
|
||||
Sound_set_tempo( this, this->tempo );
|
||||
Sound_mute_voices( this, this->mute_mask_ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Sound_set_voice( struct Sgc_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r )
|
||||
{
|
||||
if ( i < sms_osc_count )
|
||||
Sms_apu_set_output( &this->apu, i, c, l, r );
|
||||
else
|
||||
Fm_apu_set_output( &this->fm_apu, c );
|
||||
}
|
||||
|
||||
static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec )
|
||||
{
|
||||
#if defined(ROCKBOX)
|
||||
(void) msec;
|
||||
#endif
|
||||
|
||||
cpu_time_t t = *duration;
|
||||
while ( Z80_time( &this->cpu ) < t )
|
||||
{
|
||||
cpu_time_t next = min( t, this->next_play );
|
||||
if ( run_cpu( this, next ) )
|
||||
{
|
||||
/* warning( "Unsupported CPU instruction" ); */
|
||||
Z80_set_time( &this->cpu, next );
|
||||
}
|
||||
|
||||
if ( this->cpu.r.pc == this->idle_addr )
|
||||
Z80_set_time( &this->cpu, next );
|
||||
|
||||
if ( Z80_time( &this->cpu ) >= this->next_play )
|
||||
{
|
||||
this->next_play += this->play_period;
|
||||
if ( this->cpu.r.pc == this->idle_addr )
|
||||
jsr( this, this->header.play_addr );
|
||||
}
|
||||
}
|
||||
|
||||
this->next_play -= t;
|
||||
check( this->next_play >= 0 );
|
||||
Z80_adjust_time( &this->cpu, -t );
|
||||
|
||||
Sms_apu_end_frame( &this->apu, t );
|
||||
if ( sega_mapping( this ) && this->fm_accessed )
|
||||
{
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_end_frame( &this->fm_apu, t );
|
||||
/* else
|
||||
warning( "FM sound not supported" ); */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Emulation
|
||||
|
||||
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data )
|
||||
{
|
||||
int port = addr & 0xFF;
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
switch ( port )
|
||||
{
|
||||
case 0x06:
|
||||
Sms_apu_write_ggstereo( &this->apu, time, data );
|
||||
return;
|
||||
|
||||
case 0x7E:
|
||||
case 0x7F:
|
||||
Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */
|
||||
return;
|
||||
|
||||
case 0xF0:
|
||||
this->fm_accessed = true;
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data );
|
||||
return;
|
||||
|
||||
case 0xF1:
|
||||
this->fm_accessed = true;
|
||||
if ( Fm_apu_supported() )
|
||||
Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( port >= 0xE0 )
|
||||
{
|
||||
Sms_apu_write_data( &this->apu, time, data );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void jsr( struct Sgc_Emu* this, byte addr [2] )
|
||||
{
|
||||
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr >> 8;
|
||||
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF;
|
||||
this->cpu.r.pc = get_le16( addr );
|
||||
}
|
||||
|
||||
static void set_bank( struct Sgc_Emu* this, int bank, void const* data )
|
||||
{
|
||||
//dprintf( "map bank %d to %p\n", bank, (byte*) data - rom.at_addr( 0 ) );
|
||||
Z80_map_mem( &this->cpu, bank * this->rom.bank_size, this->rom.bank_size, this->unmapped_write, data );
|
||||
}
|
||||
|
||||
void cpu_write( struct Sgc_Emu* this, addr_t addr, int data )
|
||||
{
|
||||
if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) )
|
||||
{
|
||||
*Z80_write( &this->cpu, addr ) = data;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( addr )
|
||||
{
|
||||
case 0xFFFC:
|
||||
Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 );
|
||||
if ( data & 0x08 )
|
||||
break;
|
||||
|
||||
this->bank2 = this->ram2;
|
||||
// FALL THROUGH
|
||||
|
||||
case 0xFFFF: {
|
||||
bool rom_mapped = (Z80_read( &this->cpu, 2 * this->rom.bank_size ) == this->bank2);
|
||||
this->bank2 = Rom_at_addr( &this->rom, data * this->rom.bank_size );
|
||||
if ( rom_mapped )
|
||||
set_bank( this, 2, this->bank2 );
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xFFFD:
|
||||
set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||
break;
|
||||
|
||||
case 0xFFFE:
|
||||
set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int rate )
|
||||
{
|
||||
require( !this->sample_rate ); // sample rate can't be changed once set
|
||||
Buffer_init( &this->stereo_buf );
|
||||
Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 );
|
||||
|
||||
// Set buffer bass
|
||||
Buffer_bass_freq( &this->stereo_buf, 80 );
|
||||
|
||||
this->sample_rate = rate;
|
||||
RETURN_ERR( track_init( &this->track_filter, this ) );
|
||||
this->tfilter.max_silence = 6 * stereo * this->sample_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute )
|
||||
{
|
||||
require( (unsigned) index < (unsigned) this->voice_count );
|
||||
int bit = 1 << index;
|
||||
int mask = this->mute_mask_ | bit;
|
||||
if ( !mute )
|
||||
mask ^= bit;
|
||||
Sound_mute_voices( this, mask );
|
||||
}
|
||||
|
||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask )
|
||||
{
|
||||
require( this->sample_rate ); // sample rate must be set first
|
||||
this->mute_mask_ = mask;
|
||||
|
||||
int i;
|
||||
for ( i = this->voice_count; i--; )
|
||||
{
|
||||
if ( mask & (1 << i) )
|
||||
{
|
||||
Sound_set_voice( this, i, 0, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
struct channel_t ch = Buffer_channel( &this->stereo_buf, i );
|
||||
assert( (ch.center && ch.left && ch.right) ||
|
||||
(!ch.center && !ch.left && !ch.right) ); // all or nothing
|
||||
Sound_set_voice( this, i, ch.center, ch.left, ch.right );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sound_set_tempo( struct Sgc_Emu* this, int t )
|
||||
{
|
||||
require( this->sample_rate ); // sample rate must be set first
|
||||
int const min = (int)(FP_ONE_TEMPO*0.02);
|
||||
int const max = (int)(FP_ONE_TEMPO*4.00);
|
||||
if ( t < min ) t = min;
|
||||
if ( t > max ) t = max;
|
||||
this->tempo = t;
|
||||
|
||||
this->play_period = (int) ((clock_rate( this ) * FP_ONE_TEMPO) / (this->header.rate ? 50 : 60) / t);
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track )
|
||||
{
|
||||
clear_track_vars( this );
|
||||
|
||||
// Remap track if playlist available
|
||||
if ( this->m3u.size > 0 ) {
|
||||
struct entry_t* e = &this->m3u.entries[track];
|
||||
track = e->track;
|
||||
}
|
||||
|
||||
this->current_track = track;
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
Sms_apu_reset( &this->apu, 0, 0 );
|
||||
Fm_apu_reset( &this->fm_apu );
|
||||
this->fm_accessed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Sms_apu_reset( &this->apu, 0x0003, 15 );
|
||||
}
|
||||
|
||||
memset( this->ram , 0, sizeof this->ram );
|
||||
memset( this->ram2, 0, sizeof this->ram2 );
|
||||
memset( this->vectors, 0xFF, sizeof this->vectors );
|
||||
Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped );
|
||||
|
||||
if ( sega_mapping( this ) )
|
||||
{
|
||||
this->vectors_addr = 0x10000 - page_size;
|
||||
this->idle_addr = this->vectors_addr;
|
||||
int i;
|
||||
for ( i = 1; i < 8; ++i )
|
||||
{
|
||||
this->vectors [i*8 + 0] = 0xC3; // JP addr
|
||||
this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff;
|
||||
this->vectors [i*8 + 2] = this->header.rst_addrs [i - 1] >> 8;
|
||||
}
|
||||
|
||||
Z80_map_mem_rw( &this->cpu, 0xC000, 0x2000, this->ram );
|
||||
Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors );
|
||||
|
||||
this->bank2 = NULL;
|
||||
for ( i = 0; i < 4; ++i )
|
||||
cpu_write( this, 0xFFFC + i, this->header.mapping [i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !this->coleco_bios )
|
||||
return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */
|
||||
|
||||
this->vectors_addr = 0;
|
||||
Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios );
|
||||
int i;
|
||||
for ( i = 0; i < 8; ++i )
|
||||
Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram );
|
||||
|
||||
this->idle_addr = 0x2000;
|
||||
Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors );
|
||||
|
||||
for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i )
|
||||
{
|
||||
int addr = 0x8000 + i*this->rom.bank_size;
|
||||
Z80_map_mem( &this->cpu, addr, this->rom.bank_size, this->unmapped_write, Rom_at_addr( &this->rom, addr ) );
|
||||
}
|
||||
}
|
||||
|
||||
this->cpu.r.sp = get_le16( this->header.stack_ptr );
|
||||
this->cpu.r.b.a = track;
|
||||
this->next_play = this->play_period;
|
||||
|
||||
jsr( this, this->header.init_addr );
|
||||
|
||||
Buffer_clear( &this->stereo_buf );
|
||||
|
||||
// convert filter times to samples
|
||||
struct setup_t s = this->tfilter;
|
||||
s.max_initial *= this->sample_rate * stereo;
|
||||
#ifdef GME_DISABLE_SILENCE_LOOKAHEAD
|
||||
s.lookahead = 1;
|
||||
#endif
|
||||
track_setup( &this->track_filter, &s );
|
||||
|
||||
return track_start( &this->track_filter );
|
||||
}
|
||||
|
||||
// Tell/Seek
|
||||
|
||||
static int msec_to_samples( int msec, int sample_rate )
|
||||
{
|
||||
int sec = msec / 1000;
|
||||
msec -= sec * 1000;
|
||||
return (sec * sample_rate + msec * sample_rate / 1000) * stereo;
|
||||
}
|
||||
|
||||
int Track_tell( struct Sgc_Emu* this )
|
||||
{
|
||||
int rate = this->sample_rate * stereo;
|
||||
int sec = track_sample_count( &this->track_filter ) / rate;
|
||||
return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate;
|
||||
}
|
||||
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec )
|
||||
{
|
||||
int time = msec_to_samples( msec, this->sample_rate );
|
||||
if ( time < track_sample_count( &this->track_filter ) )
|
||||
RETURN_ERR( Sgc_start_track( this, this->current_track ) );
|
||||
return Track_skip( this, time - track_sample_count( &this->track_filter ) );
|
||||
}
|
||||
|
||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int count )
|
||||
{
|
||||
require( this->current_track >= 0 ); // start_track() must have been called already
|
||||
return track_skip( &this->track_filter, count );
|
||||
}
|
||||
|
||||
blargg_err_t skip_( void* emu, int count )
|
||||
{
|
||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||
|
||||
// for long skip, mute sound
|
||||
const int threshold = 32768;
|
||||
if ( count > threshold )
|
||||
{
|
||||
int saved_mute = this->mute_mask_;
|
||||
Sound_mute_voices( this, ~0 );
|
||||
|
||||
int n = count - threshold/2;
|
||||
n &= ~(2048-1); // round to multiple of 2048
|
||||
count -= n;
|
||||
RETURN_ERR( skippy_( &this->track_filter, n ) );
|
||||
|
||||
Sound_mute_voices( this, saved_mute );
|
||||
}
|
||||
|
||||
return skippy_( &this->track_filter, count );
|
||||
}
|
||||
|
||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec )
|
||||
{
|
||||
track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ),
|
||||
length_msec * this->sample_rate / (1000 / stereo) );
|
||||
}
|
||||
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out )
|
||||
{
|
||||
require( this->current_track >= 0 );
|
||||
require( out_count % stereo == 0 );
|
||||
return track_play( &this->track_filter, out_count, out );
|
||||
}
|
||||
|
||||
blargg_err_t play_( void* emu, int count, sample_t out [] )
|
||||
{
|
||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||
|
||||
int remain = count;
|
||||
while ( remain )
|
||||
{
|
||||
Buffer_disable_immediate_removal( &this->stereo_buf );
|
||||
remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain );
|
||||
if ( remain )
|
||||
{
|
||||
if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) )
|
||||
{
|
||||
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||
|
||||
// Remute voices
|
||||
Sound_mute_voices( this, this->mute_mask_ );
|
||||
}
|
||||
int msec = Buffer_length( &this->stereo_buf );
|
||||
blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100;
|
||||
RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) );
|
||||
assert( clocks_emulated );
|
||||
Buffer_end_frame( &this->stereo_buf, clocks_emulated );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,195 +1,195 @@
|
|||
// Sega/Game Gear/Coleco SGC music file emulator
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef SGC_EMU_H
|
||||
#define SGC_EMU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "multi_buffer.h"
|
||||
|
||||
#include "rom_data.h"
|
||||
#include "z80_cpu.h"
|
||||
#include "sms_fm_apu.h"
|
||||
#include "sms_apu.h"
|
||||
#include "m3u_playlist.h"
|
||||
#include "track_filter.h"
|
||||
|
||||
typedef struct Z80_Cpu Sgc_Cpu;
|
||||
|
||||
// SGC file header
|
||||
enum { header_size = 0xA0 };
|
||||
struct header_t
|
||||
{
|
||||
char tag [4]; // "SGC\x1A"
|
||||
byte vers; // 0x01
|
||||
byte rate; // 0=NTSC 1=PAL
|
||||
byte reserved1 [2];
|
||||
byte load_addr [2];
|
||||
byte init_addr [2];
|
||||
byte play_addr [2];
|
||||
byte stack_ptr [2];
|
||||
byte reserved2 [2];
|
||||
byte rst_addrs [7*2];
|
||||
byte mapping [4]; // Used by Sega only
|
||||
byte first_song; // Song to start playing first
|
||||
byte song_count;
|
||||
byte first_effect;
|
||||
byte last_effect;
|
||||
byte system; // 0=Master System 1=Game Gear 2=Colecovision
|
||||
byte reserved3 [23];
|
||||
char game [32]; // strings can be 32 chars, NOT terminated
|
||||
char author [32];
|
||||
char copyright [32];
|
||||
};
|
||||
|
||||
// True if header has valid file signature
|
||||
static inline bool valid_tag( struct header_t* h )
|
||||
{
|
||||
return 0 == memcmp( h->tag, "SGC\x1A", 4 );
|
||||
}
|
||||
|
||||
static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; }
|
||||
|
||||
struct Sgc_Emu {
|
||||
bool fm_accessed;
|
||||
|
||||
cpu_time_t play_period;
|
||||
cpu_time_t next_play;
|
||||
void const* bank2; // ROM selected for bank 2, in case RAM is currently hiding it
|
||||
addr_t vectors_addr; // RST vectors start here
|
||||
addr_t idle_addr; // return address for init/play routines
|
||||
void* coleco_bios;
|
||||
|
||||
// general
|
||||
int voice_count;
|
||||
int const* voice_types;
|
||||
int mute_mask_;
|
||||
int tempo;
|
||||
int gain;
|
||||
|
||||
int sample_rate;
|
||||
|
||||
// track-specific
|
||||
int current_track;
|
||||
int track_count;
|
||||
|
||||
int clock_rate_;
|
||||
unsigned buf_changed_count;
|
||||
|
||||
// M3u Playlist
|
||||
struct M3u_Playlist m3u;
|
||||
struct header_t header;
|
||||
|
||||
struct setup_t tfilter;
|
||||
struct Track_Filter track_filter;
|
||||
|
||||
struct Multi_Buffer stereo_buf;
|
||||
|
||||
struct Sms_Apu apu;
|
||||
struct Sms_Fm_Apu fm_apu;
|
||||
|
||||
Sgc_Cpu cpu;
|
||||
|
||||
// large items
|
||||
struct Rom_Data rom;
|
||||
byte vectors [page_size + page_padding];
|
||||
byte unmapped_write [0x4000];
|
||||
byte ram [0x2000 + page_padding];
|
||||
byte ram2 [0x4000 + page_padding];
|
||||
};
|
||||
|
||||
// Basic functionality (see Gme_File.h for file loading/track info functions)
|
||||
|
||||
void Sgc_init( struct Sgc_Emu* this );
|
||||
|
||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size );
|
||||
|
||||
static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; }
|
||||
|
||||
// 0x2000 bytes
|
||||
static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; }
|
||||
|
||||
// Set output sample rate. Must be called only once before loading file.
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int sample_rate );
|
||||
|
||||
// Start a track, where 0 is the first track. Also clears warning string.
|
||||
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track );
|
||||
|
||||
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
|
||||
// errors set warning string, and major errors also end track.
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf );
|
||||
|
||||
// Track status/control
|
||||
|
||||
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
|
||||
int Track_tell( struct Sgc_Emu* this );
|
||||
|
||||
// Seek to new time in track. Seeking backwards or far forward can take a while.
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec );
|
||||
|
||||
// Skip n samples
|
||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int n );
|
||||
|
||||
// Set start time and length of track fade out. Once fade ends track_ended() returns
|
||||
// true. Fade time can be changed while track is playing.
|
||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec );
|
||||
|
||||
// True if a track has reached its end
|
||||
static inline bool Track_ended( struct Sgc_Emu* this )
|
||||
{
|
||||
return track_ended( &this->track_filter );
|
||||
}
|
||||
|
||||
// Disables automatic end-of-track detection and skipping of silence at beginning
|
||||
static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable )
|
||||
{
|
||||
this->track_filter.silence_ignored_ = disable;
|
||||
}
|
||||
|
||||
// Get track length in milliseconds
|
||||
static inline int Track_get_length( struct Sgc_Emu* this, int n )
|
||||
{
|
||||
int length = 120 * 1000; /* 2 minutes */
|
||||
if ( (this->m3u.size > 0) && (n < this->m3u.size) ) {
|
||||
struct entry_t* entry = &this->m3u.entries [n];
|
||||
length = entry->length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
// Sound customization
|
||||
|
||||
// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed.
|
||||
// Track length as returned by track_info() assumes a tempo of 1.0.
|
||||
void Sound_set_tempo( struct Sgc_Emu* this, int t );
|
||||
|
||||
// Mute/unmute voice i, where voice 0 is first voice
|
||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute );
|
||||
|
||||
// Set muting state of all voices at once using a bit mask, where -1 mutes them all,
|
||||
// 0 unmutes them all, 0x01 mutes just the first voice, etc.
|
||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask );
|
||||
|
||||
// Change overall output amplitude, where 1.0 results in minimal clamping.
|
||||
// Must be called before set_sample_rate().
|
||||
static inline void Sound_set_gain( struct Sgc_Emu* this, int g )
|
||||
{
|
||||
assert( !this->sample_rate ); // you must set gain before setting sample rate
|
||||
this->gain = g;
|
||||
}
|
||||
|
||||
// True if Master System or Game Gear
|
||||
static inline bool sega_mapping( struct Sgc_Emu* this )
|
||||
{
|
||||
return this->header.system <= 1;
|
||||
}
|
||||
|
||||
// Emulation (You shouldn't touch these)
|
||||
|
||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time );
|
||||
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data );
|
||||
void cpu_write( struct Sgc_Emu* this, addr_t addr, int data );
|
||||
void jsr( struct Sgc_Emu* this, byte addr [2] );
|
||||
|
||||
#endif
|
||||
// Sega/Game Gear/Coleco SGC music file emulator
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef SGC_EMU_H
|
||||
#define SGC_EMU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "multi_buffer.h"
|
||||
|
||||
#include "rom_data.h"
|
||||
#include "z80_cpu.h"
|
||||
#include "sms_fm_apu.h"
|
||||
#include "sms_apu.h"
|
||||
#include "m3u_playlist.h"
|
||||
#include "track_filter.h"
|
||||
|
||||
typedef struct Z80_Cpu Sgc_Cpu;
|
||||
|
||||
// SGC file header
|
||||
enum { header_size = 0xA0 };
|
||||
struct header_t
|
||||
{
|
||||
char tag [4]; // "SGC\x1A"
|
||||
byte vers; // 0x01
|
||||
byte rate; // 0=NTSC 1=PAL
|
||||
byte reserved1 [2];
|
||||
byte load_addr [2];
|
||||
byte init_addr [2];
|
||||
byte play_addr [2];
|
||||
byte stack_ptr [2];
|
||||
byte reserved2 [2];
|
||||
byte rst_addrs [7*2];
|
||||
byte mapping [4]; // Used by Sega only
|
||||
byte first_song; // Song to start playing first
|
||||
byte song_count;
|
||||
byte first_effect;
|
||||
byte last_effect;
|
||||
byte system; // 0=Master System 1=Game Gear 2=Colecovision
|
||||
byte reserved3 [23];
|
||||
char game [32]; // strings can be 32 chars, NOT terminated
|
||||
char author [32];
|
||||
char copyright [32];
|
||||
};
|
||||
|
||||
// True if header has valid file signature
|
||||
static inline bool valid_tag( struct header_t* h )
|
||||
{
|
||||
return 0 == memcmp( h->tag, "SGC\x1A", 4 );
|
||||
}
|
||||
|
||||
static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; }
|
||||
|
||||
struct Sgc_Emu {
|
||||
bool fm_accessed;
|
||||
|
||||
cpu_time_t play_period;
|
||||
cpu_time_t next_play;
|
||||
void const* bank2; // ROM selected for bank 2, in case RAM is currently hiding it
|
||||
addr_t vectors_addr; // RST vectors start here
|
||||
addr_t idle_addr; // return address for init/play routines
|
||||
void* coleco_bios;
|
||||
|
||||
// general
|
||||
int voice_count;
|
||||
int const* voice_types;
|
||||
int mute_mask_;
|
||||
int tempo;
|
||||
int gain;
|
||||
|
||||
int sample_rate;
|
||||
|
||||
// track-specific
|
||||
int current_track;
|
||||
int track_count;
|
||||
|
||||
int clock_rate_;
|
||||
unsigned buf_changed_count;
|
||||
|
||||
// M3u Playlist
|
||||
struct M3u_Playlist m3u;
|
||||
struct header_t header;
|
||||
|
||||
struct setup_t tfilter;
|
||||
struct Track_Filter track_filter;
|
||||
|
||||
struct Multi_Buffer stereo_buf;
|
||||
|
||||
struct Sms_Apu apu;
|
||||
struct Sms_Fm_Apu fm_apu;
|
||||
|
||||
Sgc_Cpu cpu;
|
||||
|
||||
// large items
|
||||
struct Rom_Data rom;
|
||||
byte vectors [page_size + page_padding];
|
||||
byte unmapped_write [0x4000];
|
||||
byte ram [0x2000 + page_padding];
|
||||
byte ram2 [0x4000 + page_padding];
|
||||
};
|
||||
|
||||
// Basic functionality (see Gme_File.h for file loading/track info functions)
|
||||
|
||||
void Sgc_init( struct Sgc_Emu* this );
|
||||
|
||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size );
|
||||
|
||||
static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; }
|
||||
|
||||
// 0x2000 bytes
|
||||
static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; }
|
||||
|
||||
// Set output sample rate. Must be called only once before loading file.
|
||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int sample_rate );
|
||||
|
||||
// Start a track, where 0 is the first track. Also clears warning string.
|
||||
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track );
|
||||
|
||||
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
|
||||
// errors set warning string, and major errors also end track.
|
||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf );
|
||||
|
||||
// Track status/control
|
||||
|
||||
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
|
||||
int Track_tell( struct Sgc_Emu* this );
|
||||
|
||||
// Seek to new time in track. Seeking backwards or far forward can take a while.
|
||||
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec );
|
||||
|
||||
// Skip n samples
|
||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int n );
|
||||
|
||||
// Set start time and length of track fade out. Once fade ends track_ended() returns
|
||||
// true. Fade time can be changed while track is playing.
|
||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec );
|
||||
|
||||
// True if a track has reached its end
|
||||
static inline bool Track_ended( struct Sgc_Emu* this )
|
||||
{
|
||||
return track_ended( &this->track_filter );
|
||||
}
|
||||
|
||||
// Disables automatic end-of-track detection and skipping of silence at beginning
|
||||
static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable )
|
||||
{
|
||||
this->track_filter.silence_ignored_ = disable;
|
||||
}
|
||||
|
||||
// Get track length in milliseconds
|
||||
static inline int Track_get_length( struct Sgc_Emu* this, int n )
|
||||
{
|
||||
int length = 120 * 1000; /* 2 minutes */
|
||||
if ( (this->m3u.size > 0) && (n < this->m3u.size) ) {
|
||||
struct entry_t* entry = &this->m3u.entries [n];
|
||||
length = entry->length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
// Sound customization
|
||||
|
||||
// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed.
|
||||
// Track length as returned by track_info() assumes a tempo of 1.0.
|
||||
void Sound_set_tempo( struct Sgc_Emu* this, int t );
|
||||
|
||||
// Mute/unmute voice i, where voice 0 is first voice
|
||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute );
|
||||
|
||||
// Set muting state of all voices at once using a bit mask, where -1 mutes them all,
|
||||
// 0 unmutes them all, 0x01 mutes just the first voice, etc.
|
||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask );
|
||||
|
||||
// Change overall output amplitude, where 1.0 results in minimal clamping.
|
||||
// Must be called before set_sample_rate().
|
||||
static inline void Sound_set_gain( struct Sgc_Emu* this, int g )
|
||||
{
|
||||
assert( !this->sample_rate ); // you must set gain before setting sample rate
|
||||
this->gain = g;
|
||||
}
|
||||
|
||||
// True if Master System or Game Gear
|
||||
static inline bool sega_mapping( struct Sgc_Emu* this )
|
||||
{
|
||||
return this->header.system <= 1;
|
||||
}
|
||||
|
||||
// Emulation (You shouldn't touch these)
|
||||
|
||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time );
|
||||
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data );
|
||||
void cpu_write( struct Sgc_Emu* this, addr_t addr, int data );
|
||||
void jsr( struct Sgc_Emu* this, byte addr [2] );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,82 +1,82 @@
|
|||
#include "sms_fm_apu.h"
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
void Fm_apu_create( struct Sms_Fm_Apu* this )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
Ym2413_init( &this->apu );
|
||||
}
|
||||
|
||||
blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate )
|
||||
{
|
||||
this->period_ = (blip_time_t) (clock_rate / sample_rate);
|
||||
CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) );
|
||||
|
||||
Fm_apu_set_output( this, 0 );
|
||||
Fm_apu_volume( this, (int)FP_ONE_VOLUME );
|
||||
Fm_apu_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fm_apu_reset( struct Sms_Fm_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
Ym2413_reset( &this->apu );
|
||||
}
|
||||
|
||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time );
|
||||
void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
fm_run_until( this, time );
|
||||
|
||||
Ym2413_write( &this->apu, this->addr, data );
|
||||
}
|
||||
|
||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
assert( end_time > this->next_time );
|
||||
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
if ( !output )
|
||||
{
|
||||
this->next_time = end_time;
|
||||
return;
|
||||
}
|
||||
|
||||
blip_time_t time = this->next_time;
|
||||
struct Ym2413_Emu* emu = &this->apu;
|
||||
do
|
||||
{
|
||||
short samples [2];
|
||||
Ym2413_run( emu, 1, samples );
|
||||
int amp = (samples [0] + samples [1]) >> 1;
|
||||
|
||||
int delta = amp - this->last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
this->last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
while ( time < end_time );
|
||||
|
||||
this->next_time = time;
|
||||
}
|
||||
|
||||
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
fm_run_until( this, time );
|
||||
|
||||
this->next_time -= time;
|
||||
assert( this->next_time >= 0 );
|
||||
|
||||
if ( this->output_ )
|
||||
Blip_set_modified( this->output_ );
|
||||
}
|
||||
#include "sms_fm_apu.h"
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
void Fm_apu_create( struct Sms_Fm_Apu* this )
|
||||
{
|
||||
Synth_init( &this->synth );
|
||||
Ym2413_init( &this->apu );
|
||||
}
|
||||
|
||||
blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate )
|
||||
{
|
||||
this->period_ = (blip_time_t) (clock_rate / sample_rate);
|
||||
CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) );
|
||||
|
||||
Fm_apu_set_output( this, 0 );
|
||||
Fm_apu_volume( this, (int)FP_ONE_VOLUME );
|
||||
Fm_apu_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fm_apu_reset( struct Sms_Fm_Apu* this )
|
||||
{
|
||||
this->addr = 0;
|
||||
this->next_time = 0;
|
||||
this->last_amp = 0;
|
||||
|
||||
Ym2413_reset( &this->apu );
|
||||
}
|
||||
|
||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time );
|
||||
void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t time, int data )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
fm_run_until( this, time );
|
||||
|
||||
Ym2413_write( &this->apu, this->addr, data );
|
||||
}
|
||||
|
||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time )
|
||||
{
|
||||
assert( end_time > this->next_time );
|
||||
|
||||
struct Blip_Buffer* const output = this->output_;
|
||||
if ( !output )
|
||||
{
|
||||
this->next_time = end_time;
|
||||
return;
|
||||
}
|
||||
|
||||
blip_time_t time = this->next_time;
|
||||
struct Ym2413_Emu* emu = &this->apu;
|
||||
do
|
||||
{
|
||||
short samples [2];
|
||||
Ym2413_run( emu, 1, samples );
|
||||
int amp = (samples [0] + samples [1]) >> 1;
|
||||
|
||||
int delta = amp - this->last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
this->last_amp = amp;
|
||||
Synth_offset_inline( &this->synth, time, delta, output );
|
||||
}
|
||||
time += this->period_;
|
||||
}
|
||||
while ( time < end_time );
|
||||
|
||||
this->next_time = time;
|
||||
}
|
||||
|
||||
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time )
|
||||
{
|
||||
if ( time > this->next_time )
|
||||
fm_run_until( this, time );
|
||||
|
||||
this->next_time -= time;
|
||||
assert( this->next_time >= 0 );
|
||||
|
||||
if ( this->output_ )
|
||||
Blip_set_modified( this->output_ );
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
#ifndef SMS_FM_APU_H
|
||||
#define SMS_FM_APU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "blip_buffer.h"
|
||||
#include "ym2413_emu.h"
|
||||
|
||||
enum { fm_apu_osc_count = 1 };
|
||||
|
||||
struct Sms_Fm_Apu {
|
||||
struct Blip_Buffer* output_;
|
||||
blip_time_t next_time;
|
||||
int last_amp;
|
||||
int addr;
|
||||
|
||||
int clock_;
|
||||
int rate_;
|
||||
blip_time_t period_;
|
||||
|
||||
struct Blip_Synth synth;
|
||||
struct Ym2413_Emu apu;
|
||||
};
|
||||
|
||||
void Fm_apu_create( struct Sms_Fm_Apu* this );
|
||||
|
||||
static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); }
|
||||
blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate );
|
||||
|
||||
static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b )
|
||||
{
|
||||
this->output_ = b;
|
||||
}
|
||||
|
||||
static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); }
|
||||
|
||||
void Fm_apu_reset( struct Sms_Fm_Apu* this );
|
||||
|
||||
static inline void Fm_apu_write_addr( struct Sms_Fm_Apu* this, int data ) { this->addr = data; }
|
||||
void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t, int data );
|
||||
|
||||
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t t );
|
||||
|
||||
#endif
|
||||
#ifndef SMS_FM_APU_H
|
||||
#define SMS_FM_APU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "blip_buffer.h"
|
||||
#include "ym2413_emu.h"
|
||||
|
||||
enum { fm_apu_osc_count = 1 };
|
||||
|
||||
struct Sms_Fm_Apu {
|
||||
struct Blip_Buffer* output_;
|
||||
blip_time_t next_time;
|
||||
int last_amp;
|
||||
int addr;
|
||||
|
||||
int clock_;
|
||||
int rate_;
|
||||
blip_time_t period_;
|
||||
|
||||
struct Blip_Synth synth;
|
||||
struct Ym2413_Emu apu;
|
||||
};
|
||||
|
||||
void Fm_apu_create( struct Sms_Fm_Apu* this );
|
||||
|
||||
static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); }
|
||||
blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate );
|
||||
|
||||
static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b )
|
||||
{
|
||||
this->output_ = b;
|
||||
}
|
||||
|
||||
static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); }
|
||||
|
||||
void Fm_apu_reset( struct Sms_Fm_Apu* this );
|
||||
|
||||
static inline void Fm_apu_write_addr( struct Sms_Fm_Apu* this, int data ) { this->addr = data; }
|
||||
void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t, int data );
|
||||
|
||||
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t t );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,294 +1,294 @@
|
|||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "track_filter.h"
|
||||
|
||||
/* Copyright (C) 2003-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const fade_block_size = 512;
|
||||
int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift)
|
||||
int const silence_threshold = 8;
|
||||
|
||||
void track_create( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_ = NULL;
|
||||
this->setup_.max_initial = 0;
|
||||
this->setup_.lookahead = 0;
|
||||
this->setup_.max_silence = indefinite_count;
|
||||
this->silence_ignored_ = false;
|
||||
track_stop( this );
|
||||
}
|
||||
|
||||
blargg_err_t track_init( struct Track_Filter* this, void* emu )
|
||||
{
|
||||
this->emu_ = emu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clear_time_vars( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_time = this->buf_remain;
|
||||
this->out_time = 0;
|
||||
this->silence_time = 0;
|
||||
this->silence_count = 0;
|
||||
}
|
||||
|
||||
void track_stop( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_track_ended_ = true;
|
||||
this->track_ended_ = true;
|
||||
this->fade_start = indefinite_count;
|
||||
this->fade_step = 1;
|
||||
this->buf_remain = 0;
|
||||
this->emu_error = NULL;
|
||||
clear_time_vars( this );
|
||||
}
|
||||
|
||||
blargg_err_t track_start( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
track_stop( this );
|
||||
|
||||
this->emu_track_ended_ = false;
|
||||
this->track_ended_ = false;
|
||||
|
||||
if ( !this->silence_ignored_ )
|
||||
{
|
||||
// play until non-silence or end of track
|
||||
while ( this->emu_time < this->setup_.max_initial )
|
||||
{
|
||||
fill_buf( this );
|
||||
if ( this->buf_remain | this->emu_track_ended_ )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clear_time_vars( this );
|
||||
return this->emu_error;
|
||||
}
|
||||
|
||||
static void end_track_if_error( struct Track_Filter* this, blargg_err_t err )
|
||||
{
|
||||
if ( err )
|
||||
{
|
||||
this->emu_error = err;
|
||||
this->emu_track_ended_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
blargg_err_t track_skip( struct Track_Filter* this, int count )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
this->out_time += count;
|
||||
|
||||
// remove from silence and buf first
|
||||
{
|
||||
int n = min( count, this->silence_count );
|
||||
this->silence_count -= n;
|
||||
count -= n;
|
||||
|
||||
n = min( count, this->buf_remain );
|
||||
this->buf_remain -= n;
|
||||
count -= n;
|
||||
}
|
||||
|
||||
if ( count && !this->emu_track_ended_ )
|
||||
{
|
||||
this->emu_time += count;
|
||||
this->silence_time = this->emu_time; // would otherwise be invalid
|
||||
end_track_if_error( this, skip_( this->emu_, count ) );
|
||||
}
|
||||
|
||||
if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended
|
||||
this->track_ended_ |= this->emu_track_ended_;
|
||||
|
||||
return this->emu_error;
|
||||
}
|
||||
|
||||
blargg_err_t skippy_( struct Track_Filter* this, int count )
|
||||
{
|
||||
while ( count && !this->emu_track_ended_ )
|
||||
{
|
||||
int n = buf_size;
|
||||
if ( n > count )
|
||||
n = count;
|
||||
count -= n;
|
||||
RETURN_ERR( play_( this->emu_, n, this->buf ) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Fading
|
||||
|
||||
void track_set_fade( struct Track_Filter* this, int start, int length )
|
||||
{
|
||||
this->fade_start = start;
|
||||
this->fade_step = length / (fade_block_size * fade_shift);
|
||||
if ( this->fade_step < 1 )
|
||||
this->fade_step = 1;
|
||||
}
|
||||
|
||||
static bool is_fading( struct Track_Filter* this )
|
||||
{
|
||||
return this->out_time >= this->fade_start && this->fade_start != indefinite_count;
|
||||
}
|
||||
|
||||
// unit / pow( 2.0, (double) x / step )
|
||||
static int int_log( int x, int step, int unit )
|
||||
{
|
||||
int shift = x / step;
|
||||
int fraction = (x - shift * step) * unit / step;
|
||||
return ((unit - fraction) + (fraction >> 1)) >> shift;
|
||||
}
|
||||
|
||||
static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < out_count; i += fade_block_size )
|
||||
{
|
||||
int const shift = 14;
|
||||
int const unit = 1 << shift;
|
||||
int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size,
|
||||
this->fade_step, unit );
|
||||
if ( gain < (unit >> fade_shift) )
|
||||
this->track_ended_ = this->emu_track_ended_ = true;
|
||||
|
||||
sample_t* io = &out [i];
|
||||
for ( int count = min( fade_block_size, out_count - i ); count; --count )
|
||||
{
|
||||
*io = (sample_t) ((*io * gain) >> shift);
|
||||
++io;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Silence detection
|
||||
|
||||
static void emu_play( struct Track_Filter* this, sample_t out [], int count )
|
||||
{
|
||||
this->emu_time += count;
|
||||
if ( !this->emu_track_ended_ )
|
||||
end_track_if_error( this, play_( this->emu_, count, out ) );
|
||||
else
|
||||
memset( out, 0, count * sizeof *out );
|
||||
}
|
||||
|
||||
// number of consecutive silent samples at end
|
||||
static int count_silence( sample_t begin [], int size )
|
||||
{
|
||||
sample_t first = *begin;
|
||||
*begin = silence_threshold * 2; // sentinel
|
||||
sample_t* p = begin + size;
|
||||
while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { }
|
||||
*begin = first;
|
||||
return size - (p - begin);
|
||||
}
|
||||
|
||||
// fill internal buffer and check it for silence
|
||||
void fill_buf( struct Track_Filter* this )
|
||||
{
|
||||
assert( !this->buf_remain );
|
||||
if ( !this->emu_track_ended_ )
|
||||
{
|
||||
emu_play( this, this->buf, buf_size );
|
||||
int silence = count_silence( this->buf, buf_size );
|
||||
if ( silence < buf_size )
|
||||
{
|
||||
this->silence_time = this->emu_time - silence;
|
||||
this->buf_remain = buf_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->silence_count += buf_size;
|
||||
}
|
||||
|
||||
blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
if ( this->track_ended_ )
|
||||
{
|
||||
memset( out, 0, out_count * sizeof *out );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( this->emu_time >= this->out_time );
|
||||
|
||||
// prints nifty graph of how far ahead we are when searching for silence
|
||||
//dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" );
|
||||
|
||||
// use any remaining silence samples
|
||||
int pos = 0;
|
||||
if ( this->silence_count )
|
||||
{
|
||||
if ( !this->silence_ignored_ )
|
||||
{
|
||||
// during a run of silence, run emulator at >=2x speed so it gets ahead
|
||||
int ahead_time = this->setup_.lookahead * (this->out_time + out_count - this->silence_time) +
|
||||
this->silence_time;
|
||||
while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) )
|
||||
fill_buf( this );
|
||||
|
||||
// end track if sufficient silence has been found
|
||||
if ( this->emu_time - this->silence_time > this->setup_.max_silence )
|
||||
{
|
||||
this->track_ended_ = this->emu_track_ended_ = true;
|
||||
this->silence_count = out_count;
|
||||
this->buf_remain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// fill from remaining silence
|
||||
pos = min( this->silence_count, out_count );
|
||||
memset( out, 0, pos * sizeof *out );
|
||||
this->silence_count -= pos;
|
||||
}
|
||||
|
||||
// use any remaining samples from buffer
|
||||
if ( this->buf_remain )
|
||||
{
|
||||
int n = min( this->buf_remain, (int) (out_count - pos) );
|
||||
memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out );
|
||||
this->buf_remain -= n;
|
||||
pos += n;
|
||||
}
|
||||
|
||||
// generate remaining samples normally
|
||||
int remain = out_count - pos;
|
||||
if ( remain )
|
||||
{
|
||||
emu_play( this, out + pos, remain );
|
||||
this->track_ended_ |= this->emu_track_ended_;
|
||||
|
||||
if ( this->silence_ignored_ && !is_fading( this ) )
|
||||
{
|
||||
// if left unupdated, ahead_time could become too large
|
||||
this->silence_time = this->emu_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check end for a new run of silence
|
||||
int silence = count_silence( out + pos, remain );
|
||||
if ( silence < remain )
|
||||
this->silence_time = this->emu_time - silence;
|
||||
|
||||
if ( this->emu_time - this->silence_time >= buf_size )
|
||||
fill_buf( this ); // cause silence detection on next play()
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_fading( this ) )
|
||||
handle_fade( this, out, out_count );
|
||||
}
|
||||
this->out_time += out_count;
|
||||
return this->emu_error;
|
||||
}
|
||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||
|
||||
#include "track_filter.h"
|
||||
|
||||
/* Copyright (C) 2003-2008 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
int const fade_block_size = 512;
|
||||
int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift)
|
||||
int const silence_threshold = 8;
|
||||
|
||||
void track_create( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_ = NULL;
|
||||
this->setup_.max_initial = 0;
|
||||
this->setup_.lookahead = 0;
|
||||
this->setup_.max_silence = indefinite_count;
|
||||
this->silence_ignored_ = false;
|
||||
track_stop( this );
|
||||
}
|
||||
|
||||
blargg_err_t track_init( struct Track_Filter* this, void* emu )
|
||||
{
|
||||
this->emu_ = emu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clear_time_vars( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_time = this->buf_remain;
|
||||
this->out_time = 0;
|
||||
this->silence_time = 0;
|
||||
this->silence_count = 0;
|
||||
}
|
||||
|
||||
void track_stop( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_track_ended_ = true;
|
||||
this->track_ended_ = true;
|
||||
this->fade_start = indefinite_count;
|
||||
this->fade_step = 1;
|
||||
this->buf_remain = 0;
|
||||
this->emu_error = NULL;
|
||||
clear_time_vars( this );
|
||||
}
|
||||
|
||||
blargg_err_t track_start( struct Track_Filter* this )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
track_stop( this );
|
||||
|
||||
this->emu_track_ended_ = false;
|
||||
this->track_ended_ = false;
|
||||
|
||||
if ( !this->silence_ignored_ )
|
||||
{
|
||||
// play until non-silence or end of track
|
||||
while ( this->emu_time < this->setup_.max_initial )
|
||||
{
|
||||
fill_buf( this );
|
||||
if ( this->buf_remain | this->emu_track_ended_ )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clear_time_vars( this );
|
||||
return this->emu_error;
|
||||
}
|
||||
|
||||
static void end_track_if_error( struct Track_Filter* this, blargg_err_t err )
|
||||
{
|
||||
if ( err )
|
||||
{
|
||||
this->emu_error = err;
|
||||
this->emu_track_ended_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
blargg_err_t track_skip( struct Track_Filter* this, int count )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
this->out_time += count;
|
||||
|
||||
// remove from silence and buf first
|
||||
{
|
||||
int n = min( count, this->silence_count );
|
||||
this->silence_count -= n;
|
||||
count -= n;
|
||||
|
||||
n = min( count, this->buf_remain );
|
||||
this->buf_remain -= n;
|
||||
count -= n;
|
||||
}
|
||||
|
||||
if ( count && !this->emu_track_ended_ )
|
||||
{
|
||||
this->emu_time += count;
|
||||
this->silence_time = this->emu_time; // would otherwise be invalid
|
||||
end_track_if_error( this, skip_( this->emu_, count ) );
|
||||
}
|
||||
|
||||
if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended
|
||||
this->track_ended_ |= this->emu_track_ended_;
|
||||
|
||||
return this->emu_error;
|
||||
}
|
||||
|
||||
blargg_err_t skippy_( struct Track_Filter* this, int count )
|
||||
{
|
||||
while ( count && !this->emu_track_ended_ )
|
||||
{
|
||||
int n = buf_size;
|
||||
if ( n > count )
|
||||
n = count;
|
||||
count -= n;
|
||||
RETURN_ERR( play_( this->emu_, n, this->buf ) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Fading
|
||||
|
||||
void track_set_fade( struct Track_Filter* this, int start, int length )
|
||||
{
|
||||
this->fade_start = start;
|
||||
this->fade_step = length / (fade_block_size * fade_shift);
|
||||
if ( this->fade_step < 1 )
|
||||
this->fade_step = 1;
|
||||
}
|
||||
|
||||
static bool is_fading( struct Track_Filter* this )
|
||||
{
|
||||
return this->out_time >= this->fade_start && this->fade_start != indefinite_count;
|
||||
}
|
||||
|
||||
// unit / pow( 2.0, (double) x / step )
|
||||
static int int_log( int x, int step, int unit )
|
||||
{
|
||||
int shift = x / step;
|
||||
int fraction = (x - shift * step) * unit / step;
|
||||
return ((unit - fraction) + (fraction >> 1)) >> shift;
|
||||
}
|
||||
|
||||
static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < out_count; i += fade_block_size )
|
||||
{
|
||||
int const shift = 14;
|
||||
int const unit = 1 << shift;
|
||||
int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size,
|
||||
this->fade_step, unit );
|
||||
if ( gain < (unit >> fade_shift) )
|
||||
this->track_ended_ = this->emu_track_ended_ = true;
|
||||
|
||||
sample_t* io = &out [i];
|
||||
for ( int count = min( fade_block_size, out_count - i ); count; --count )
|
||||
{
|
||||
*io = (sample_t) ((*io * gain) >> shift);
|
||||
++io;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Silence detection
|
||||
|
||||
static void emu_play( struct Track_Filter* this, sample_t out [], int count )
|
||||
{
|
||||
this->emu_time += count;
|
||||
if ( !this->emu_track_ended_ )
|
||||
end_track_if_error( this, play_( this->emu_, count, out ) );
|
||||
else
|
||||
memset( out, 0, count * sizeof *out );
|
||||
}
|
||||
|
||||
// number of consecutive silent samples at end
|
||||
static int count_silence( sample_t begin [], int size )
|
||||
{
|
||||
sample_t first = *begin;
|
||||
*begin = silence_threshold * 2; // sentinel
|
||||
sample_t* p = begin + size;
|
||||
while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { }
|
||||
*begin = first;
|
||||
return size - (p - begin);
|
||||
}
|
||||
|
||||
// fill internal buffer and check it for silence
|
||||
void fill_buf( struct Track_Filter* this )
|
||||
{
|
||||
assert( !this->buf_remain );
|
||||
if ( !this->emu_track_ended_ )
|
||||
{
|
||||
emu_play( this, this->buf, buf_size );
|
||||
int silence = count_silence( this->buf, buf_size );
|
||||
if ( silence < buf_size )
|
||||
{
|
||||
this->silence_time = this->emu_time - silence;
|
||||
this->buf_remain = buf_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->silence_count += buf_size;
|
||||
}
|
||||
|
||||
blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] )
|
||||
{
|
||||
this->emu_error = NULL;
|
||||
if ( this->track_ended_ )
|
||||
{
|
||||
memset( out, 0, out_count * sizeof *out );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( this->emu_time >= this->out_time );
|
||||
|
||||
// prints nifty graph of how far ahead we are when searching for silence
|
||||
//dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" );
|
||||
|
||||
// use any remaining silence samples
|
||||
int pos = 0;
|
||||
if ( this->silence_count )
|
||||
{
|
||||
if ( !this->silence_ignored_ )
|
||||
{
|
||||
// during a run of silence, run emulator at >=2x speed so it gets ahead
|
||||
int ahead_time = this->setup_.lookahead * (this->out_time + out_count - this->silence_time) +
|
||||
this->silence_time;
|
||||
while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) )
|
||||
fill_buf( this );
|
||||
|
||||
// end track if sufficient silence has been found
|
||||
if ( this->emu_time - this->silence_time > this->setup_.max_silence )
|
||||
{
|
||||
this->track_ended_ = this->emu_track_ended_ = true;
|
||||
this->silence_count = out_count;
|
||||
this->buf_remain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// fill from remaining silence
|
||||
pos = min( this->silence_count, out_count );
|
||||
memset( out, 0, pos * sizeof *out );
|
||||
this->silence_count -= pos;
|
||||
}
|
||||
|
||||
// use any remaining samples from buffer
|
||||
if ( this->buf_remain )
|
||||
{
|
||||
int n = min( this->buf_remain, (int) (out_count - pos) );
|
||||
memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out );
|
||||
this->buf_remain -= n;
|
||||
pos += n;
|
||||
}
|
||||
|
||||
// generate remaining samples normally
|
||||
int remain = out_count - pos;
|
||||
if ( remain )
|
||||
{
|
||||
emu_play( this, out + pos, remain );
|
||||
this->track_ended_ |= this->emu_track_ended_;
|
||||
|
||||
if ( this->silence_ignored_ && !is_fading( this ) )
|
||||
{
|
||||
// if left unupdated, ahead_time could become too large
|
||||
this->silence_time = this->emu_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check end for a new run of silence
|
||||
int silence = count_silence( out + pos, remain );
|
||||
if ( silence < remain )
|
||||
this->silence_time = this->emu_time - silence;
|
||||
|
||||
if ( this->emu_time - this->silence_time >= buf_size )
|
||||
fill_buf( this ); // cause silence detection on next play()
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_fading( this ) )
|
||||
handle_fade( this, out, out_count );
|
||||
}
|
||||
this->out_time += out_count;
|
||||
return this->emu_error;
|
||||
}
|
||||
|
|
|
@ -1,90 +1,90 @@
|
|||
// Removes silence from beginning of track, fades end of track. Also looks ahead
|
||||
// for excessive silence, and if found, ends track.
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef TRACK_FILTER_H
|
||||
#define TRACK_FILTER_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
|
||||
typedef short sample_t;
|
||||
typedef int sample_count_t;
|
||||
|
||||
enum { indefinite_count = INT_MAX/2 + 1 };
|
||||
enum { buf_size = 2048 };
|
||||
|
||||
struct setup_t {
|
||||
sample_count_t max_initial; // maximum silence to strip from beginning of track
|
||||
sample_count_t max_silence; // maximum silence in middle of track without it ending
|
||||
int lookahead; // internal speed when looking ahead for silence (2=200% etc.)
|
||||
};
|
||||
|
||||
struct Track_Filter {
|
||||
void* emu_;
|
||||
struct setup_t setup_;
|
||||
const char* emu_error;
|
||||
bool silence_ignored_;
|
||||
|
||||
// Timing
|
||||
int out_time; // number of samples played since start of track
|
||||
int emu_time; // number of samples emulator has generated since start of track
|
||||
int emu_track_ended_; // emulator has reached end of track
|
||||
volatile int track_ended_;
|
||||
|
||||
// Fading
|
||||
int fade_start;
|
||||
int fade_step;
|
||||
|
||||
// Silence detection
|
||||
int silence_time; // absolute number of samples where most recent silence began
|
||||
int silence_count; // number of samples of silence to play before using buf
|
||||
int buf_remain; // number of samples left in silence buffer
|
||||
sample_t buf [buf_size];
|
||||
};
|
||||
|
||||
// Initializes filter. Must be done once before using object.
|
||||
blargg_err_t track_init( struct Track_Filter* this, void* );
|
||||
void track_create( struct Track_Filter* this );
|
||||
|
||||
// Gets/sets setup
|
||||
static inline struct setup_t const* track_get_setup( struct Track_Filter* this ) { return &this->setup_; }
|
||||
static inline void track_setup( struct Track_Filter* this, struct setup_t const* s ) { this->setup_ = *s; }
|
||||
|
||||
// Disables automatic end-of-track detection and skipping of silence at beginning
|
||||
static inline void track_ignore_silence( struct Track_Filter* this, bool disable ) { this->silence_ignored_ = disable; }
|
||||
|
||||
// Clears state and skips initial silence in track
|
||||
blargg_err_t track_start( struct Track_Filter* this );
|
||||
|
||||
// Sets time that fade starts, and how long until track ends.
|
||||
void track_set_fade( struct Track_Filter* this, sample_count_t start, sample_count_t length );
|
||||
|
||||
// Generates n samples into buf
|
||||
blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] );
|
||||
|
||||
// Skips n samples
|
||||
blargg_err_t track_skip( struct Track_Filter* this, int n );
|
||||
|
||||
// Number of samples played/skipped since start_track()
|
||||
static inline int track_sample_count( struct Track_Filter* this ) { return this->out_time; }
|
||||
|
||||
// True if track ended. Causes are end of source samples, end of fade,
|
||||
// or excessive silence.
|
||||
static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; }
|
||||
|
||||
// Clears state
|
||||
void track_stop( struct Track_Filter* this );
|
||||
|
||||
// For use by callbacks
|
||||
|
||||
// Sets internal "track ended" flag and stops generation of further source samples
|
||||
static inline void track_set_end( struct Track_Filter* this ) { this->emu_track_ended_ = true; }
|
||||
|
||||
// For use by skip_() callback
|
||||
blargg_err_t skippy_( struct Track_Filter* this, int count );
|
||||
void fill_buf( struct Track_Filter* this );
|
||||
|
||||
// Skip and play callbacks
|
||||
blargg_err_t skip_( void* emu, int count );
|
||||
blargg_err_t play_( void* emu, int count, sample_t out [] );
|
||||
#endif
|
||||
// Removes silence from beginning of track, fades end of track. Also looks ahead
|
||||
// for excessive silence, and if found, ends track.
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef TRACK_FILTER_H
|
||||
#define TRACK_FILTER_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
|
||||
typedef short sample_t;
|
||||
typedef int sample_count_t;
|
||||
|
||||
enum { indefinite_count = INT_MAX/2 + 1 };
|
||||
enum { buf_size = 2048 };
|
||||
|
||||
struct setup_t {
|
||||
sample_count_t max_initial; // maximum silence to strip from beginning of track
|
||||
sample_count_t max_silence; // maximum silence in middle of track without it ending
|
||||
int lookahead; // internal speed when looking ahead for silence (2=200% etc.)
|
||||
};
|
||||
|
||||
struct Track_Filter {
|
||||
void* emu_;
|
||||
struct setup_t setup_;
|
||||
const char* emu_error;
|
||||
bool silence_ignored_;
|
||||
|
||||
// Timing
|
||||
int out_time; // number of samples played since start of track
|
||||
int emu_time; // number of samples emulator has generated since start of track
|
||||
int emu_track_ended_; // emulator has reached end of track
|
||||
volatile int track_ended_;
|
||||
|
||||
// Fading
|
||||
int fade_start;
|
||||
int fade_step;
|
||||
|
||||
// Silence detection
|
||||
int silence_time; // absolute number of samples where most recent silence began
|
||||
int silence_count; // number of samples of silence to play before using buf
|
||||
int buf_remain; // number of samples left in silence buffer
|
||||
sample_t buf [buf_size];
|
||||
};
|
||||
|
||||
// Initializes filter. Must be done once before using object.
|
||||
blargg_err_t track_init( struct Track_Filter* this, void* );
|
||||
void track_create( struct Track_Filter* this );
|
||||
|
||||
// Gets/sets setup
|
||||
static inline struct setup_t const* track_get_setup( struct Track_Filter* this ) { return &this->setup_; }
|
||||
static inline void track_setup( struct Track_Filter* this, struct setup_t const* s ) { this->setup_ = *s; }
|
||||
|
||||
// Disables automatic end-of-track detection and skipping of silence at beginning
|
||||
static inline void track_ignore_silence( struct Track_Filter* this, bool disable ) { this->silence_ignored_ = disable; }
|
||||
|
||||
// Clears state and skips initial silence in track
|
||||
blargg_err_t track_start( struct Track_Filter* this );
|
||||
|
||||
// Sets time that fade starts, and how long until track ends.
|
||||
void track_set_fade( struct Track_Filter* this, sample_count_t start, sample_count_t length );
|
||||
|
||||
// Generates n samples into buf
|
||||
blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] );
|
||||
|
||||
// Skips n samples
|
||||
blargg_err_t track_skip( struct Track_Filter* this, int n );
|
||||
|
||||
// Number of samples played/skipped since start_track()
|
||||
static inline int track_sample_count( struct Track_Filter* this ) { return this->out_time; }
|
||||
|
||||
// True if track ended. Causes are end of source samples, end of fade,
|
||||
// or excessive silence.
|
||||
static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; }
|
||||
|
||||
// Clears state
|
||||
void track_stop( struct Track_Filter* this );
|
||||
|
||||
// For use by callbacks
|
||||
|
||||
// Sets internal "track ended" flag and stops generation of further source samples
|
||||
static inline void track_set_end( struct Track_Filter* this ) { this->emu_track_ended_ = true; }
|
||||
|
||||
// For use by skip_() callback
|
||||
blargg_err_t skippy_( struct Track_Filter* this, int count );
|
||||
void fill_buf( struct Track_Filter* this );
|
||||
|
||||
// Skip and play callbacks
|
||||
blargg_err_t skip_( void* emu, int count );
|
||||
blargg_err_t play_( void* emu, int count, sample_t out [] );
|
||||
#endif
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
/* VRC7 TONES by okazaki@angel.ne.jp */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x33,0x01,0x09,0x0e,0x94,0x90,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x13,0x41,0x0f,0x0d,0xce,0xd3,0x43,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x12,0x1b,0x06,0xff,0xd2,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x61,0x1b,0x07,0xaf,0x63,0x20,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x08,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x66,0x21,0x15,0x00,0x93,0x94,0x20,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1c,0x07,0x82,0x81,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x21,0x20,0x1f,0xc0,0x71,0x07,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x31,0x26,0x05,0x64,0x41,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x17,0x21,0x28,0x07,0xff,0x83,0x02,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0x81,0x25,0x07,0xcf,0xc8,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x54,0x0f,0x80,0x7f,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x56,0x03,0xd3,0xb2,0x43,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x31,0x21,0x0c,0x03,0x82,0xc0,0x40,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x01,0x0c,0x03,0xd4,0xd3,0x40,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
/* VRC7 TONES by okazaki@angel.ne.jp */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x33,0x01,0x09,0x0e,0x94,0x90,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x13,0x41,0x0f,0x0d,0xce,0xd3,0x43,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x12,0x1b,0x06,0xff,0xd2,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x61,0x1b,0x07,0xaf,0x63,0x20,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x21,0x1e,0x06,0xf0,0x76,0x08,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x66,0x21,0x15,0x00,0x93,0x94,0x20,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x61,0x1c,0x07,0x82,0x81,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x23,0x21,0x20,0x1f,0xc0,0x71,0x07,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x31,0x26,0x05,0x64,0x41,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x17,0x21,0x28,0x07,0xff,0x83,0x02,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x97,0x81,0x25,0x07,0xcf,0xc8,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x21,0x54,0x0f,0x80,0x7f,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x56,0x03,0xd3,0xb2,0x43,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x31,0x21,0x0c,0x03,0x82,0xc0,0x40,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x21,0x01,0x0c,0x03,0xd4,0xd3,0x40,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/
|
||||
|
||||
#include "ym2413_emu.h"
|
||||
|
||||
void Ym2413_init( struct Ym2413_Emu* this )
|
||||
{
|
||||
this->last_time = disabled_time; this->out = 0;
|
||||
}
|
||||
|
||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate )
|
||||
{
|
||||
OPLL_new ( &this->opll, clock_rate, sample_rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||
|
||||
Ym2413_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ym2413_reset( struct Ym2413_Emu* this )
|
||||
{
|
||||
OPLL_reset( &this->opll );
|
||||
OPLL_setMask( &this->opll, 0 );
|
||||
}
|
||||
|
||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data )
|
||||
{
|
||||
OPLL_writeIO( &this->opll, 0, addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
}
|
||||
|
||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask )
|
||||
{
|
||||
OPLL_setMask( &this->opll, mask );
|
||||
}
|
||||
|
||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out )
|
||||
{
|
||||
while ( pair_count-- )
|
||||
{
|
||||
int s = OPLL_calc( &this->opll ) << 1;
|
||||
out [0] = s;
|
||||
out [1] = s;
|
||||
out += 2;
|
||||
}
|
||||
}
|
||||
// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/
|
||||
|
||||
#include "ym2413_emu.h"
|
||||
|
||||
void Ym2413_init( struct Ym2413_Emu* this )
|
||||
{
|
||||
this->last_time = disabled_time; this->out = 0;
|
||||
}
|
||||
|
||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate )
|
||||
{
|
||||
OPLL_new ( &this->opll, clock_rate, sample_rate );
|
||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||
|
||||
Ym2413_reset( this );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ym2413_reset( struct Ym2413_Emu* this )
|
||||
{
|
||||
OPLL_reset( &this->opll );
|
||||
OPLL_setMask( &this->opll, 0 );
|
||||
}
|
||||
|
||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data )
|
||||
{
|
||||
OPLL_writeIO( &this->opll, 0, addr );
|
||||
OPLL_writeIO( &this->opll, 1, data );
|
||||
}
|
||||
|
||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask )
|
||||
{
|
||||
OPLL_setMask( &this->opll, mask );
|
||||
}
|
||||
|
||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out )
|
||||
{
|
||||
while ( pair_count-- )
|
||||
{
|
||||
int s = OPLL_calc( &this->opll ) << 1;
|
||||
out [0] = s;
|
||||
out [1] = s;
|
||||
out += 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
// YM2413 FM sound chip emulator interface
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef YM2413_EMU_H
|
||||
#define YM2413_EMU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "emu2413.h"
|
||||
|
||||
enum { out_chan_count = 2 }; // stereo
|
||||
enum { channel_count = 14 };
|
||||
enum { disabled_time = -1 };
|
||||
|
||||
struct Ym2413_Emu {
|
||||
OPLL opll;
|
||||
|
||||
// Impl
|
||||
int last_time;
|
||||
short* out;
|
||||
};
|
||||
|
||||
void Ym2413_init( struct Ym2413_Emu* this );
|
||||
|
||||
static inline bool Ym2413_supported( void ) { return true; }
|
||||
|
||||
// Sets output sample rate and chip clock rates, in Hz. Returns non-zero
|
||||
// if error.
|
||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate );
|
||||
|
||||
// Resets to power-up state
|
||||
void Ym2413_reset( struct Ym2413_Emu* this );
|
||||
|
||||
// Mutes voice n if bit n (1 << n) of mask is set
|
||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask );
|
||||
|
||||
// Writes data to addr
|
||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data );
|
||||
|
||||
// Runs and writes pair_count*2 samples to output
|
||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out );
|
||||
|
||||
static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; }
|
||||
static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; }
|
||||
static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; }
|
||||
|
||||
static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time )
|
||||
{
|
||||
int count = time - this->last_time;
|
||||
if ( count > 0 )
|
||||
{
|
||||
if ( this->last_time < 0 )
|
||||
return false;
|
||||
this->last_time = time;
|
||||
short* p = this->out;
|
||||
this->out += count * out_chan_count;
|
||||
Ym2413_run( this, count, p );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
// YM2413 FM sound chip emulator interface
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef YM2413_EMU_H
|
||||
#define YM2413_EMU_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
#include "emu2413.h"
|
||||
|
||||
enum { out_chan_count = 2 }; // stereo
|
||||
enum { channel_count = 14 };
|
||||
enum { disabled_time = -1 };
|
||||
|
||||
struct Ym2413_Emu {
|
||||
OPLL opll;
|
||||
|
||||
// Impl
|
||||
int last_time;
|
||||
short* out;
|
||||
};
|
||||
|
||||
void Ym2413_init( struct Ym2413_Emu* this );
|
||||
|
||||
static inline bool Ym2413_supported( void ) { return true; }
|
||||
|
||||
// Sets output sample rate and chip clock rates, in Hz. Returns non-zero
|
||||
// if error.
|
||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate );
|
||||
|
||||
// Resets to power-up state
|
||||
void Ym2413_reset( struct Ym2413_Emu* this );
|
||||
|
||||
// Mutes voice n if bit n (1 << n) of mask is set
|
||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask );
|
||||
|
||||
// Writes data to addr
|
||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data );
|
||||
|
||||
// Runs and writes pair_count*2 samples to output
|
||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out );
|
||||
|
||||
static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; }
|
||||
static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; }
|
||||
static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; }
|
||||
|
||||
static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time )
|
||||
{
|
||||
int count = time - this->last_time;
|
||||
if ( count > 0 )
|
||||
{
|
||||
if ( this->last_time < 0 )
|
||||
return false;
|
||||
this->last_time = time;
|
||||
short* p = this->out;
|
||||
this->out += count * out_chan_count;
|
||||
Ym2413_run( this, count, p );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,116 +1,116 @@
|
|||
// Z80 CPU emulator
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef Z80_CPU_H
|
||||
#define Z80_CPU_H
|
||||
|
||||
#include "blargg_source.h"
|
||||
#include "blargg_endian.h"
|
||||
|
||||
typedef int cpu_time_t;
|
||||
typedef int addr_t;
|
||||
|
||||
enum { page_bits = 10 };
|
||||
enum { page_size = 1 << page_bits };
|
||||
enum { page_count = 0x10000 / page_size };
|
||||
|
||||
// Can read this far past end of memory
|
||||
enum { cpu_padding = 0x100 };
|
||||
|
||||
// Can read this many bytes past end of a page
|
||||
enum { page_padding = 4 };
|
||||
|
||||
#ifdef BLARGG_BIG_ENDIAN
|
||||
struct regs_t { byte b,c, d,e, h,l, flags,a; };
|
||||
#else
|
||||
struct regs_t { byte c,b, e,d, l,h, a,flags; };
|
||||
#endif
|
||||
// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 );
|
||||
|
||||
struct pairs_t { uint16_t bc, de, hl, fa; };
|
||||
|
||||
// Registers are not updated until run() returns
|
||||
struct registers_t {
|
||||
uint16_t pc;
|
||||
uint16_t sp;
|
||||
uint16_t ix;
|
||||
uint16_t iy;
|
||||
union {
|
||||
struct regs_t b; // b.b, b.c, b.d, b.e, b.h, b.l, b.flags, b.a
|
||||
struct pairs_t w; // w.bc, w.de, w.hl. w.fa
|
||||
};
|
||||
union {
|
||||
struct regs_t b;
|
||||
struct pairs_t w;
|
||||
} alt;
|
||||
byte iff1;
|
||||
byte iff2;
|
||||
byte r;
|
||||
byte i;
|
||||
byte im;
|
||||
};
|
||||
|
||||
struct cpu_state_t {
|
||||
byte const* read [page_count + 1];
|
||||
byte * write [page_count + 1];
|
||||
cpu_time_t base;
|
||||
cpu_time_t time;
|
||||
};
|
||||
|
||||
struct Z80_Cpu {
|
||||
byte szpc [0x200];
|
||||
cpu_time_t end_time_;
|
||||
|
||||
struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy within run()
|
||||
struct cpu_state_t cpu_state_;
|
||||
|
||||
struct registers_t r;
|
||||
};
|
||||
|
||||
void Z80_init( struct Z80_Cpu* this );
|
||||
|
||||
// Clears registers and maps all pages to unmapped
|
||||
void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read );
|
||||
|
||||
// TODO: split mapping out of CPU
|
||||
|
||||
// Maps memory. Start and size must be multiple of page_size.
|
||||
void Z80_map_mem( struct Z80_Cpu* this, addr_t addr, int size, void* write, void const* read );
|
||||
|
||||
// Time of beginning of next instruction
|
||||
static inline cpu_time_t Z80_time( struct Z80_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; }
|
||||
|
||||
// Alter current time
|
||||
static inline void Z80_set_time( struct Z80_Cpu* this, cpu_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; }
|
||||
static inline void Z80_adjust_time( struct Z80_Cpu* this, int delta ) { this->cpu_state->time += delta; }
|
||||
|
||||
#ifdef BLARGG_NONPORTABLE
|
||||
#define Z80_CPU_OFFSET( addr ) (addr)
|
||||
#else
|
||||
#define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1))
|
||||
#endif
|
||||
|
||||
// Maps address to pointer to that byte
|
||||
static inline byte* Z80_write( struct Z80_Cpu* this, addr_t addr )
|
||||
{
|
||||
return this->cpu_state->write [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr );
|
||||
}
|
||||
|
||||
static inline byte const* Z80_read( struct Z80_Cpu* this, addr_t addr )
|
||||
{
|
||||
return this->cpu_state->read [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr );
|
||||
}
|
||||
|
||||
static inline void Z80_map_mem_rw( struct Z80_Cpu* this, addr_t addr, int size, void* p )
|
||||
{
|
||||
Z80_map_mem( this, addr, size, p, p );
|
||||
}
|
||||
|
||||
static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t )
|
||||
{
|
||||
cpu_time_t delta = this->cpu_state->base - t;
|
||||
this->cpu_state->base = t;
|
||||
this->cpu_state->time += delta;
|
||||
}
|
||||
|
||||
#endif
|
||||
// Z80 CPU emulator
|
||||
|
||||
// Game_Music_Emu 0.6-pre
|
||||
#ifndef Z80_CPU_H
|
||||
#define Z80_CPU_H
|
||||
|
||||
#include "blargg_source.h"
|
||||
#include "blargg_endian.h"
|
||||
|
||||
typedef int cpu_time_t;
|
||||
typedef int addr_t;
|
||||
|
||||
enum { page_bits = 10 };
|
||||
enum { page_size = 1 << page_bits };
|
||||
enum { page_count = 0x10000 / page_size };
|
||||
|
||||
// Can read this far past end of memory
|
||||
enum { cpu_padding = 0x100 };
|
||||
|
||||
// Can read this many bytes past end of a page
|
||||
enum { page_padding = 4 };
|
||||
|
||||
#ifdef BLARGG_BIG_ENDIAN
|
||||
struct regs_t { byte b,c, d,e, h,l, flags,a; };
|
||||
#else
|
||||
struct regs_t { byte c,b, e,d, l,h, a,flags; };
|
||||
#endif
|
||||
// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 );
|
||||
|
||||
struct pairs_t { uint16_t bc, de, hl, fa; };
|
||||
|
||||
// Registers are not updated until run() returns
|
||||
struct registers_t {
|
||||
uint16_t pc;
|
||||
uint16_t sp;
|
||||
uint16_t ix;
|
||||
uint16_t iy;
|
||||
union {
|
||||
struct regs_t b; // b.b, b.c, b.d, b.e, b.h, b.l, b.flags, b.a
|
||||
struct pairs_t w; // w.bc, w.de, w.hl. w.fa
|
||||
};
|
||||
union {
|
||||
struct regs_t b;
|
||||
struct pairs_t w;
|
||||
} alt;
|
||||
byte iff1;
|
||||
byte iff2;
|
||||
byte r;
|
||||
byte i;
|
||||
byte im;
|
||||
};
|
||||
|
||||
struct cpu_state_t {
|
||||
byte const* read [page_count + 1];
|
||||
byte * write [page_count + 1];
|
||||
cpu_time_t base;
|
||||
cpu_time_t time;
|
||||
};
|
||||
|
||||
struct Z80_Cpu {
|
||||
byte szpc [0x200];
|
||||
cpu_time_t end_time_;
|
||||
|
||||
struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy within run()
|
||||
struct cpu_state_t cpu_state_;
|
||||
|
||||
struct registers_t r;
|
||||
};
|
||||
|
||||
void Z80_init( struct Z80_Cpu* this );
|
||||
|
||||
// Clears registers and maps all pages to unmapped
|
||||
void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read );
|
||||
|
||||
// TODO: split mapping out of CPU
|
||||
|
||||
// Maps memory. Start and size must be multiple of page_size.
|
||||
void Z80_map_mem( struct Z80_Cpu* this, addr_t addr, int size, void* write, void const* read );
|
||||
|
||||
// Time of beginning of next instruction
|
||||
static inline cpu_time_t Z80_time( struct Z80_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; }
|
||||
|
||||
// Alter current time
|
||||
static inline void Z80_set_time( struct Z80_Cpu* this, cpu_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; }
|
||||
static inline void Z80_adjust_time( struct Z80_Cpu* this, int delta ) { this->cpu_state->time += delta; }
|
||||
|
||||
#ifdef BLARGG_NONPORTABLE
|
||||
#define Z80_CPU_OFFSET( addr ) (addr)
|
||||
#else
|
||||
#define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1))
|
||||
#endif
|
||||
|
||||
// Maps address to pointer to that byte
|
||||
static inline byte* Z80_write( struct Z80_Cpu* this, addr_t addr )
|
||||
{
|
||||
return this->cpu_state->write [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr );
|
||||
}
|
||||
|
||||
static inline byte const* Z80_read( struct Z80_Cpu* this, addr_t addr )
|
||||
{
|
||||
return this->cpu_state->read [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr );
|
||||
}
|
||||
|
||||
static inline void Z80_map_mem_rw( struct Z80_Cpu* this, addr_t addr, int size, void* p )
|
||||
{
|
||||
Z80_map_mem( this, addr, size, p, p );
|
||||
}
|
||||
|
||||
static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t )
|
||||
{
|
||||
cpu_time_t delta = this->cpu_state->base - t;
|
||||
this->cpu_state->base = t;
|
||||
this->cpu_state->time += delta;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7010,17 +7010,17 @@
|
|||
radio: "قائمة اذاعة اف ام"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_FILESIZE
|
||||
desc: in record timesplit options and in track information viewer
|
||||
user: core
|
||||
<source>
|
||||
*: "Filesize"
|
||||
</source>
|
||||
<dest>
|
||||
*: "حجم الملف"
|
||||
</dest>
|
||||
<voice>
|
||||
*: "حجم الملف"
|
||||
</voice>
|
||||
<phrase>
|
||||
id: LANG_FILESIZE
|
||||
desc: in record timesplit options and in track information viewer
|
||||
user: core
|
||||
<source>
|
||||
*: "Filesize"
|
||||
</source>
|
||||
<dest>
|
||||
*: "حجم الملف"
|
||||
</dest>
|
||||
<voice>
|
||||
*: "حجم الملف"
|
||||
</voice>
|
||||
</phrase>
|
||||
|
|
25500
apps/lang/latviesu.lang
25500
apps/lang/latviesu.lang
File diff suppressed because it is too large
Load Diff
|
@ -1,245 +1,245 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: wm8975.c 28572 2010-11-13 11:38:38Z theseven $
|
||||
*
|
||||
* Driver for Cirrus Logic CS42L55 audio codec
|
||||
*
|
||||
* Copyright (c) 2010 Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "logf.h"
|
||||
#include "system.h"
|
||||
#include "string.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "audiohw.h"
|
||||
#include "cscodec.h"
|
||||
#include "cs42l55.h"
|
||||
|
||||
const struct sound_settings_info audiohw_settings[] = {
|
||||
[SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25},
|
||||
[SOUND_BASS] = {"dB", 1, 15,-105, 120, 0},
|
||||
[SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0},
|
||||
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
||||
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
|
||||
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
|
||||
[SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 2},
|
||||
[SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
|
||||
};
|
||||
|
||||
static int bass, treble;
|
||||
|
||||
/* convert tenth of dB volume (-600..120) to master volume register value */
|
||||
int tenthdb2master(int db)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
|
||||
return (db / 10) & HPACTL_HPAVOL_MASK;
|
||||
}
|
||||
|
||||
static void cscodec_setbits(int reg, unsigned char off, unsigned char on)
|
||||
{
|
||||
unsigned char data = (cscodec_read(reg) & ~off) | on;
|
||||
cscodec_write(reg, data);
|
||||
}
|
||||
|
||||
static void audiohw_mute(bool mute)
|
||||
{
|
||||
if (mute) cscodec_setbits(PLAYCTL, 0, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||
else cscodec_setbits(PLAYCTL, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE, 0);
|
||||
}
|
||||
|
||||
void audiohw_preinit(void)
|
||||
{
|
||||
cscodec_power(true);
|
||||
cscodec_clock(true);
|
||||
cscodec_reset(true);
|
||||
sleep(HZ / 100);
|
||||
cscodec_reset(false);
|
||||
|
||||
bass = 0;
|
||||
treble = 0;
|
||||
|
||||
/* Ask Cirrus or maybe Apple what the hell this means */
|
||||
cscodec_write(HIDDENCTL, HIDDENCTL_UNLOCK);
|
||||
cscodec_write(HIDDEN2E, HIDDEN2E_DEFAULT);
|
||||
cscodec_write(HIDDEN32, HIDDEN32_DEFAULT);
|
||||
cscodec_write(HIDDEN33, HIDDEN33_DEFAULT);
|
||||
cscodec_write(HIDDEN34, HIDDEN34_DEFAULT);
|
||||
cscodec_write(HIDDEN35, HIDDEN35_DEFAULT);
|
||||
cscodec_write(HIDDEN36, HIDDEN36_DEFAULT);
|
||||
cscodec_write(HIDDEN37, HIDDEN37_DEFAULT);
|
||||
cscodec_write(HIDDEN3A, HIDDEN3A_DEFAULT);
|
||||
cscodec_write(HIDDEN3C, HIDDEN3C_DEFAULT);
|
||||
cscodec_write(HIDDEN3D, HIDDEN3D_DEFAULT);
|
||||
cscodec_write(HIDDEN3E, HIDDEN3E_DEFAULT);
|
||||
cscodec_write(HIDDEN3F, HIDDEN3F_DEFAULT);
|
||||
cscodec_write(HIDDENCTL, HIDDENCTL_LOCK);
|
||||
|
||||
cscodec_write(PWRCTL2, PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS
|
||||
| PWRCTL2_PDN_HPA_NEVER | PWRCTL2_PDN_HPB_NEVER);
|
||||
cscodec_write(CLKCTL1, CLKCTL1_MASTER | CLKCTL1_SCLKMCLK_BEFORE
|
||||
| CLKCTL1_MCLKDIV2);
|
||||
cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||
cscodec_write(MISCCTL, MISCCTL_UNDOC4 | MISCCTL_ANLGZC | MISCCTL_DIGSFT);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||
cscodec_write(PLAYCTL, PLAYCTL_PDN_DSP
|
||||
| PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||
cscodec_write(PGAACTL, 0);
|
||||
cscodec_write(PGABCTL, 0);
|
||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB);
|
||||
}
|
||||
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
cscodec_write(HPACTL, 0);
|
||||
cscodec_write(HPBCTL, 0);
|
||||
cscodec_write(LINEACTL, 0);
|
||||
cscodec_write(LINEBCTL, 0);
|
||||
cscodec_write(CLSHCTL, CLSHCTL_ADPTPWR_SIGNAL);
|
||||
audiohw_mute(false);
|
||||
}
|
||||
|
||||
void audiohw_set_master_vol(int vol_l, int vol_r)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
|
||||
vol_l << HPACTL_HPAVOL_SHIFT);
|
||||
cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
|
||||
vol_r << HPBCTL_HPBVOL_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
|
||||
vol_l << LINEACTL_LINEAVOL_SHIFT);
|
||||
cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,
|
||||
vol_r << LINEBCTL_LINEBVOL_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_enable_lineout(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||
PWRCTL2_PDN_LINA_NEVER | PWRCTL2_PDN_LINB_NEVER);
|
||||
else
|
||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||
PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS);
|
||||
}
|
||||
|
||||
static void handle_dsp_power(void)
|
||||
{
|
||||
if (bass || treble)
|
||||
{
|
||||
cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
|
||||
cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
|
||||
cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
|
||||
}
|
||||
}
|
||||
|
||||
void audiohw_set_bass(int value)
|
||||
{
|
||||
bass = value;
|
||||
handle_dsp_power();
|
||||
if (value >= -105 && value <= 120)
|
||||
cscodec_setbits(TONECTL, TONECTL_BASS_MASK,
|
||||
(8 - value / 15) << TONECTL_BASS_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_treble(int value)
|
||||
{
|
||||
treble = value;
|
||||
handle_dsp_power();
|
||||
if (value >= -105 && value <= 120)
|
||||
cscodec_setbits(TONECTL, TONECTL_TREB_MASK,
|
||||
(8 - value / 15) << TONECTL_TREB_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_bass_cutoff(int value)
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_BASSCF_MASK,
|
||||
(value - 1) << BTCTL_BASSCF_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_treble_cutoff(int value)
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_TREBCF_MASK,
|
||||
(value - 1) << BTCTL_TREBCF_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_prescaler(int value)
|
||||
{
|
||||
cscodec_setbits(MSTAVOL, MSTAVOL_VOLUME_MASK,
|
||||
(-value / 5) << MSTAVOL_VOLUME_SHIFT);
|
||||
cscodec_setbits(MSTBVOL, MSTBVOL_VOLUME_MASK,
|
||||
(-value / 5) << MSTBVOL_VOLUME_SHIFT);
|
||||
}
|
||||
|
||||
/* Nice shutdown of CS42L55 codec */
|
||||
void audiohw_close(void)
|
||||
{
|
||||
audiohw_mute(true);
|
||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||
cscodec_reset(true);
|
||||
cscodec_clock(false);
|
||||
cscodec_power(false);
|
||||
}
|
||||
|
||||
/* Note: Disable output before calling this function */
|
||||
void audiohw_set_frequency(int fsel)
|
||||
{
|
||||
if (fsel == HW_FREQ_8) cscodec_write(CLKCTL2, CLKCTL2_8000HZ);
|
||||
else if (fsel == HW_FREQ_11) cscodec_write(CLKCTL2, CLKCTL2_11025HZ);
|
||||
else if (fsel == HW_FREQ_12) cscodec_write(CLKCTL2, CLKCTL2_12000HZ);
|
||||
else if (fsel == HW_FREQ_16) cscodec_write(CLKCTL2, CLKCTL2_16000HZ);
|
||||
else if (fsel == HW_FREQ_22) cscodec_write(CLKCTL2, CLKCTL2_22050HZ);
|
||||
else if (fsel == HW_FREQ_24) cscodec_write(CLKCTL2, CLKCTL2_24000HZ);
|
||||
else if (fsel == HW_FREQ_32) cscodec_write(CLKCTL2, CLKCTL2_32000HZ);
|
||||
else if (fsel == HW_FREQ_44) cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||
else if (fsel == HW_FREQ_48) cscodec_write(CLKCTL2, CLKCTL2_48000HZ);
|
||||
}
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
//TODO: Implement
|
||||
#endif /* HAVE_RECORDING */
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: wm8975.c 28572 2010-11-13 11:38:38Z theseven $
|
||||
*
|
||||
* Driver for Cirrus Logic CS42L55 audio codec
|
||||
*
|
||||
* Copyright (c) 2010 Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "logf.h"
|
||||
#include "system.h"
|
||||
#include "string.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "audiohw.h"
|
||||
#include "cscodec.h"
|
||||
#include "cs42l55.h"
|
||||
|
||||
const struct sound_settings_info audiohw_settings[] = {
|
||||
[SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25},
|
||||
[SOUND_BASS] = {"dB", 1, 15,-105, 120, 0},
|
||||
[SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0},
|
||||
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
||||
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
|
||||
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
|
||||
[SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 2},
|
||||
[SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
|
||||
};
|
||||
|
||||
static int bass, treble;
|
||||
|
||||
/* convert tenth of dB volume (-600..120) to master volume register value */
|
||||
int tenthdb2master(int db)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
|
||||
return (db / 10) & HPACTL_HPAVOL_MASK;
|
||||
}
|
||||
|
||||
static void cscodec_setbits(int reg, unsigned char off, unsigned char on)
|
||||
{
|
||||
unsigned char data = (cscodec_read(reg) & ~off) | on;
|
||||
cscodec_write(reg, data);
|
||||
}
|
||||
|
||||
static void audiohw_mute(bool mute)
|
||||
{
|
||||
if (mute) cscodec_setbits(PLAYCTL, 0, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||
else cscodec_setbits(PLAYCTL, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE, 0);
|
||||
}
|
||||
|
||||
void audiohw_preinit(void)
|
||||
{
|
||||
cscodec_power(true);
|
||||
cscodec_clock(true);
|
||||
cscodec_reset(true);
|
||||
sleep(HZ / 100);
|
||||
cscodec_reset(false);
|
||||
|
||||
bass = 0;
|
||||
treble = 0;
|
||||
|
||||
/* Ask Cirrus or maybe Apple what the hell this means */
|
||||
cscodec_write(HIDDENCTL, HIDDENCTL_UNLOCK);
|
||||
cscodec_write(HIDDEN2E, HIDDEN2E_DEFAULT);
|
||||
cscodec_write(HIDDEN32, HIDDEN32_DEFAULT);
|
||||
cscodec_write(HIDDEN33, HIDDEN33_DEFAULT);
|
||||
cscodec_write(HIDDEN34, HIDDEN34_DEFAULT);
|
||||
cscodec_write(HIDDEN35, HIDDEN35_DEFAULT);
|
||||
cscodec_write(HIDDEN36, HIDDEN36_DEFAULT);
|
||||
cscodec_write(HIDDEN37, HIDDEN37_DEFAULT);
|
||||
cscodec_write(HIDDEN3A, HIDDEN3A_DEFAULT);
|
||||
cscodec_write(HIDDEN3C, HIDDEN3C_DEFAULT);
|
||||
cscodec_write(HIDDEN3D, HIDDEN3D_DEFAULT);
|
||||
cscodec_write(HIDDEN3E, HIDDEN3E_DEFAULT);
|
||||
cscodec_write(HIDDEN3F, HIDDEN3F_DEFAULT);
|
||||
cscodec_write(HIDDENCTL, HIDDENCTL_LOCK);
|
||||
|
||||
cscodec_write(PWRCTL2, PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS
|
||||
| PWRCTL2_PDN_HPA_NEVER | PWRCTL2_PDN_HPB_NEVER);
|
||||
cscodec_write(CLKCTL1, CLKCTL1_MASTER | CLKCTL1_SCLKMCLK_BEFORE
|
||||
| CLKCTL1_MCLKDIV2);
|
||||
cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||
cscodec_write(MISCCTL, MISCCTL_UNDOC4 | MISCCTL_ANLGZC | MISCCTL_DIGSFT);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||
cscodec_write(PLAYCTL, PLAYCTL_PDN_DSP
|
||||
| PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||
cscodec_write(PGAACTL, 0);
|
||||
cscodec_write(PGABCTL, 0);
|
||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB);
|
||||
}
|
||||
|
||||
void audiohw_postinit(void)
|
||||
{
|
||||
cscodec_write(HPACTL, 0);
|
||||
cscodec_write(HPBCTL, 0);
|
||||
cscodec_write(LINEACTL, 0);
|
||||
cscodec_write(LINEBCTL, 0);
|
||||
cscodec_write(CLSHCTL, CLSHCTL_ADPTPWR_SIGNAL);
|
||||
audiohw_mute(false);
|
||||
}
|
||||
|
||||
void audiohw_set_master_vol(int vol_l, int vol_r)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
|
||||
vol_l << HPACTL_HPAVOL_SHIFT);
|
||||
cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
|
||||
vol_r << HPBCTL_HPBVOL_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
||||
{
|
||||
/* -60dB to +12dB in 1dB steps */
|
||||
/* 0001100 == +12dB (0xc) */
|
||||
/* 0000000 == 0dB (0x0) */
|
||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||
|
||||
cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
|
||||
vol_l << LINEACTL_LINEAVOL_SHIFT);
|
||||
cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,
|
||||
vol_r << LINEBCTL_LINEBVOL_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_enable_lineout(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||
PWRCTL2_PDN_LINA_NEVER | PWRCTL2_PDN_LINB_NEVER);
|
||||
else
|
||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||
PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS);
|
||||
}
|
||||
|
||||
static void handle_dsp_power(void)
|
||||
{
|
||||
if (bass || treble)
|
||||
{
|
||||
cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
|
||||
cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
|
||||
cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
|
||||
}
|
||||
}
|
||||
|
||||
void audiohw_set_bass(int value)
|
||||
{
|
||||
bass = value;
|
||||
handle_dsp_power();
|
||||
if (value >= -105 && value <= 120)
|
||||
cscodec_setbits(TONECTL, TONECTL_BASS_MASK,
|
||||
(8 - value / 15) << TONECTL_BASS_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_treble(int value)
|
||||
{
|
||||
treble = value;
|
||||
handle_dsp_power();
|
||||
if (value >= -105 && value <= 120)
|
||||
cscodec_setbits(TONECTL, TONECTL_TREB_MASK,
|
||||
(8 - value / 15) << TONECTL_TREB_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_bass_cutoff(int value)
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_BASSCF_MASK,
|
||||
(value - 1) << BTCTL_BASSCF_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_treble_cutoff(int value)
|
||||
{
|
||||
cscodec_setbits(BTCTL, BTCTL_TREBCF_MASK,
|
||||
(value - 1) << BTCTL_TREBCF_SHIFT);
|
||||
}
|
||||
|
||||
void audiohw_set_prescaler(int value)
|
||||
{
|
||||
cscodec_setbits(MSTAVOL, MSTAVOL_VOLUME_MASK,
|
||||
(-value / 5) << MSTAVOL_VOLUME_SHIFT);
|
||||
cscodec_setbits(MSTBVOL, MSTBVOL_VOLUME_MASK,
|
||||
(-value / 5) << MSTBVOL_VOLUME_SHIFT);
|
||||
}
|
||||
|
||||
/* Nice shutdown of CS42L55 codec */
|
||||
void audiohw_close(void)
|
||||
{
|
||||
audiohw_mute(true);
|
||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||
cscodec_reset(true);
|
||||
cscodec_clock(false);
|
||||
cscodec_power(false);
|
||||
}
|
||||
|
||||
/* Note: Disable output before calling this function */
|
||||
void audiohw_set_frequency(int fsel)
|
||||
{
|
||||
if (fsel == HW_FREQ_8) cscodec_write(CLKCTL2, CLKCTL2_8000HZ);
|
||||
else if (fsel == HW_FREQ_11) cscodec_write(CLKCTL2, CLKCTL2_11025HZ);
|
||||
else if (fsel == HW_FREQ_12) cscodec_write(CLKCTL2, CLKCTL2_12000HZ);
|
||||
else if (fsel == HW_FREQ_16) cscodec_write(CLKCTL2, CLKCTL2_16000HZ);
|
||||
else if (fsel == HW_FREQ_22) cscodec_write(CLKCTL2, CLKCTL2_22050HZ);
|
||||
else if (fsel == HW_FREQ_24) cscodec_write(CLKCTL2, CLKCTL2_24000HZ);
|
||||
else if (fsel == HW_FREQ_32) cscodec_write(CLKCTL2, CLKCTL2_32000HZ);
|
||||
else if (fsel == HW_FREQ_44) cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||
else if (fsel == HW_FREQ_48) cscodec_write(CLKCTL2, CLKCTL2_48000HZ);
|
||||
}
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
//TODO: Implement
|
||||
#endif /* HAVE_RECORDING */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: dac.c 17847 2008-06-28 18:10:04Z bagder $
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||
*
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: ata.h 28951 2011-01-02 23:02:55Z theseven $
|
||||
*
|
||||
* Copyright (C) 2011 by Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __ATA_DEFINES_H__
|
||||
#define __ATA_DEFINES_H__
|
||||
|
||||
#ifndef ATA_OUT8
|
||||
#define ATA_OUT8(reg, data) (reg) = (data)
|
||||
#endif
|
||||
#ifndef ATA_OUT16
|
||||
#define ATA_OUT16(reg, data) (reg) = (data)
|
||||
#endif
|
||||
#ifndef ATA_IN8
|
||||
#define ATA_IN8(reg) (reg)
|
||||
#endif
|
||||
#ifndef ATA_IN16
|
||||
#define ATA_IN16(reg) (reg)
|
||||
#endif
|
||||
#ifndef ATA_SWAP_IDENTIFY
|
||||
#define ATA_SWAP_IDENTIFY(word) (word)
|
||||
#endif
|
||||
|
||||
#define STATUS_BSY 0x80
|
||||
#define STATUS_RDY 0x40
|
||||
#define STATUS_DRQ 0x08
|
||||
#define STATUS_ERR 0x01
|
||||
#define STATUS_DF 0x20
|
||||
#define ERROR_IDNF 0x10
|
||||
#define ERROR_ABRT 0x04
|
||||
|
||||
#define TEST_PATTERN1 0xa5
|
||||
#define TEST_PATTERN2 0x5a
|
||||
#define TEST_PATTERN3 0xaa
|
||||
#define TEST_PATTERN4 0x55
|
||||
|
||||
#define ATA_FEATURE ATA_ERROR
|
||||
|
||||
#define ATA_STATUS ATA_COMMAND
|
||||
#define ATA_ALT_STATUS ATA_CONTROL
|
||||
|
||||
#endif
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: ata.h 28951 2011-01-02 23:02:55Z theseven $
|
||||
*
|
||||
* Copyright (C) 2011 by Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __ATA_DEFINES_H__
|
||||
#define __ATA_DEFINES_H__
|
||||
|
||||
#ifndef ATA_OUT8
|
||||
#define ATA_OUT8(reg, data) (reg) = (data)
|
||||
#endif
|
||||
#ifndef ATA_OUT16
|
||||
#define ATA_OUT16(reg, data) (reg) = (data)
|
||||
#endif
|
||||
#ifndef ATA_IN8
|
||||
#define ATA_IN8(reg) (reg)
|
||||
#endif
|
||||
#ifndef ATA_IN16
|
||||
#define ATA_IN16(reg) (reg)
|
||||
#endif
|
||||
#ifndef ATA_SWAP_IDENTIFY
|
||||
#define ATA_SWAP_IDENTIFY(word) (word)
|
||||
#endif
|
||||
|
||||
#define STATUS_BSY 0x80
|
||||
#define STATUS_RDY 0x40
|
||||
#define STATUS_DRQ 0x08
|
||||
#define STATUS_ERR 0x01
|
||||
#define STATUS_DF 0x20
|
||||
#define ERROR_IDNF 0x10
|
||||
#define ERROR_ABRT 0x04
|
||||
|
||||
#define TEST_PATTERN1 0xa5
|
||||
#define TEST_PATTERN2 0x5a
|
||||
#define TEST_PATTERN3 0xaa
|
||||
#define TEST_PATTERN4 0x55
|
||||
|
||||
#define ATA_FEATURE ATA_ERROR
|
||||
|
||||
#define ATA_STATUS ATA_COMMAND
|
||||
#define ATA_ALT_STATUS ATA_CONTROL
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,189 +1,189 @@
|
|||
/*
|
||||
* This config file is for Rockchip rk27xx reference design
|
||||
*/
|
||||
#define TARGET_TREE /* this target is using the target tree system */
|
||||
|
||||
/* For Rolo and boot loader */
|
||||
#define MODEL_NUMBER 78
|
||||
|
||||
#define MODEL_NAME "Rockchip 27xx generic"
|
||||
|
||||
/* define this if you have recording possibility */
|
||||
/* #define HAVE_RECORDING */
|
||||
|
||||
/* Define bitmask of input sources - recordable bitmask can be defined
|
||||
explicitly if different */
|
||||
/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
|
||||
|
||||
/* define the bitmask of hardware sample rates */
|
||||
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||
|
||||
/* define the bitmask of recording sample rates */
|
||||
#define REC_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||
|
||||
/* define this if you have a bitmap LCD display */
|
||||
#define HAVE_LCD_BITMAP
|
||||
|
||||
/* define this if you can flip your LCD */
|
||||
/* #define HAVE_LCD_FLIP */
|
||||
|
||||
/* define this if you have a colour LCD */
|
||||
#define HAVE_LCD_COLOR
|
||||
|
||||
/* define this if you want album art for this target */
|
||||
#define HAVE_ALBUMART
|
||||
|
||||
/* define this to enable bitmap scaling */
|
||||
#define HAVE_BMP_SCALING
|
||||
|
||||
/* define this to enable JPEG decoding */
|
||||
#define HAVE_JPEG
|
||||
|
||||
/* define this if you can invert the colours on your LCD */
|
||||
/* #define HAVE_LCD_INVERT */
|
||||
|
||||
/* define this if you have access to the quickscreen */
|
||||
#define HAVE_QUICKSCREEN
|
||||
|
||||
/* define this if you have access to the pitchscreen */
|
||||
#define HAVE_PITCHSCREEN
|
||||
|
||||
/* define this if you would like tagcache to build on this target */
|
||||
#define HAVE_TAGCACHE
|
||||
|
||||
/* define this if you have a flash memory storage */
|
||||
#define HAVE_FLASH_STORAGE
|
||||
|
||||
#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
|
||||
|
||||
#define CONFIG_NAND NAND_RK27XX
|
||||
#define HAVE_SW_TONE_CONTROLS
|
||||
|
||||
/* commented for now */
|
||||
/* #define HAVE_HOTSWAP */
|
||||
|
||||
#define NUM_DRIVES 2
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
/* for small(ish) SD cards */
|
||||
#define HAVE_FAT16SUPPORT
|
||||
|
||||
/* LCD dimensions */
|
||||
#define LCD_WIDTH 400
|
||||
#define LCD_HEIGHT 240
|
||||
#define LCD_DEPTH 16 /* pseudo 262.144 colors */
|
||||
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
||||
|
||||
/* Define this if the LCD can shut down */
|
||||
/* #define HAVE_LCD_SHUTDOWN */
|
||||
|
||||
/* Define this if your LCD can be enabled/disabled */
|
||||
/* #define HAVE_LCD_ENABLE */
|
||||
|
||||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||
should be defined as well. */
|
||||
#ifndef BOOTLOADER
|
||||
/* TODO: #define HAVE_LCD_SLEEP */
|
||||
/* TODO: #define HAVE_LCD_SLEEP_SETTING */
|
||||
#endif
|
||||
|
||||
#define CONFIG_KEYPAD RK27XX_GENERIC_PAD
|
||||
|
||||
/* Define this to enable morse code input */
|
||||
#define HAVE_MORSE_INPUT
|
||||
|
||||
/* Define this if you do software codec */
|
||||
#define CONFIG_CODEC SWCODEC
|
||||
|
||||
/* define this if you have a real-time clock */
|
||||
/* #define CONFIG_RTC RTC_NANO2G */
|
||||
|
||||
/* Define if the device can wake from an RTC alarm */
|
||||
/* #define HAVE_RTC_ALARM */
|
||||
|
||||
#define CONFIG_LCD LCD_SPFD5420A
|
||||
|
||||
/* Define the type of audio codec */
|
||||
#define HAVE_RK27XX_CODEC
|
||||
|
||||
/* #define HAVE_PCM_DMA_ADDRESS */
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
#define MIN_BRIGHTNESS_SETTING 0
|
||||
#define MAX_BRIGHTNESS_SETTING 31
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 20
|
||||
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
||||
/* The number of bytes reserved for loadable codecs */
|
||||
#define CODEC_SIZE 0x100000
|
||||
|
||||
/* The number of bytes reserved for loadable plugins */
|
||||
#define PLUGIN_BUFFER_SIZE 0x80000
|
||||
|
||||
/* TODO: Figure out real values */
|
||||
#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
|
||||
#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
|
||||
#define BATTERY_CAPACITY_MAX 500 /* max. capacity selectable */
|
||||
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
|
||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||
|
||||
/* Hardware controlled charging with monitoring */
|
||||
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||
|
||||
/* define current usage levels */
|
||||
/* TODO: #define CURRENT_NORMAL
|
||||
* TODO: #define CURRENT_BACKLIGHT 23
|
||||
*/
|
||||
|
||||
/* define this if the unit can be powered or charged via USB */
|
||||
#define HAVE_USB_POWER
|
||||
|
||||
/* USB On-the-go */
|
||||
#define CONFIG_USBOTG USBOTG_RK27XX
|
||||
|
||||
/* enable these for the experimental usb stack */
|
||||
#define HAVE_USBSTACK
|
||||
|
||||
#define USE_ROCKBOX_USB
|
||||
#define USB_VENDOR_ID 0x071b
|
||||
#define USB_PRODUCT_ID 0x3202
|
||||
#define HAVE_BOOTLOADER_USB_MODE
|
||||
|
||||
/* Define this if your LCD can set contrast */
|
||||
/* #define HAVE_LCD_CONTRAST */
|
||||
|
||||
/* The exact type of CPU */
|
||||
#define CONFIG_CPU RK27XX
|
||||
|
||||
/* I2C interface */
|
||||
#define CONFIG_I2C I2C_RK27XX
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 200000000
|
||||
|
||||
/* define this if the hardware can be powered off while charging */
|
||||
/* #define HAVE_POWEROFF_WHILE_CHARGING */
|
||||
|
||||
/* Offset ( in the firmware file's header ) to the file CRC */
|
||||
#define FIRMWARE_OFFSET_FILE_CRC 0
|
||||
|
||||
/* Offset ( in the firmware file's header ) to the real data */
|
||||
#define FIRMWARE_OFFSET_FILE_DATA 8
|
||||
|
||||
#define STORAGE_NEEDS_ALIGN
|
||||
|
||||
/* Define this if you have adjustable CPU frequency */
|
||||
/* #define HAVE_ADJUSTABLE_CPU_FREQ */
|
||||
|
||||
#define BOOTFILE_EXT "rk27"
|
||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||
#define BOOTDIR "/.rockbox"
|
||||
/*
|
||||
* This config file is for Rockchip rk27xx reference design
|
||||
*/
|
||||
#define TARGET_TREE /* this target is using the target tree system */
|
||||
|
||||
/* For Rolo and boot loader */
|
||||
#define MODEL_NUMBER 78
|
||||
|
||||
#define MODEL_NAME "Rockchip 27xx generic"
|
||||
|
||||
/* define this if you have recording possibility */
|
||||
/* #define HAVE_RECORDING */
|
||||
|
||||
/* Define bitmask of input sources - recordable bitmask can be defined
|
||||
explicitly if different */
|
||||
/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
|
||||
|
||||
/* define the bitmask of hardware sample rates */
|
||||
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||
|
||||
/* define the bitmask of recording sample rates */
|
||||
#define REC_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||
|
||||
/* define this if you have a bitmap LCD display */
|
||||
#define HAVE_LCD_BITMAP
|
||||
|
||||
/* define this if you can flip your LCD */
|
||||
/* #define HAVE_LCD_FLIP */
|
||||
|
||||
/* define this if you have a colour LCD */
|
||||
#define HAVE_LCD_COLOR
|
||||
|
||||
/* define this if you want album art for this target */
|
||||
#define HAVE_ALBUMART
|
||||
|
||||
/* define this to enable bitmap scaling */
|
||||
#define HAVE_BMP_SCALING
|
||||
|
||||
/* define this to enable JPEG decoding */
|
||||
#define HAVE_JPEG
|
||||
|
||||
/* define this if you can invert the colours on your LCD */
|
||||
/* #define HAVE_LCD_INVERT */
|
||||
|
||||
/* define this if you have access to the quickscreen */
|
||||
#define HAVE_QUICKSCREEN
|
||||
|
||||
/* define this if you have access to the pitchscreen */
|
||||
#define HAVE_PITCHSCREEN
|
||||
|
||||
/* define this if you would like tagcache to build on this target */
|
||||
#define HAVE_TAGCACHE
|
||||
|
||||
/* define this if you have a flash memory storage */
|
||||
#define HAVE_FLASH_STORAGE
|
||||
|
||||
#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
|
||||
|
||||
#define CONFIG_NAND NAND_RK27XX
|
||||
#define HAVE_SW_TONE_CONTROLS
|
||||
|
||||
/* commented for now */
|
||||
/* #define HAVE_HOTSWAP */
|
||||
|
||||
#define NUM_DRIVES 2
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
/* for small(ish) SD cards */
|
||||
#define HAVE_FAT16SUPPORT
|
||||
|
||||
/* LCD dimensions */
|
||||
#define LCD_WIDTH 400
|
||||
#define LCD_HEIGHT 240
|
||||
#define LCD_DEPTH 16 /* pseudo 262.144 colors */
|
||||
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
||||
|
||||
/* Define this if the LCD can shut down */
|
||||
/* #define HAVE_LCD_SHUTDOWN */
|
||||
|
||||
/* Define this if your LCD can be enabled/disabled */
|
||||
/* #define HAVE_LCD_ENABLE */
|
||||
|
||||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||
should be defined as well. */
|
||||
#ifndef BOOTLOADER
|
||||
/* TODO: #define HAVE_LCD_SLEEP */
|
||||
/* TODO: #define HAVE_LCD_SLEEP_SETTING */
|
||||
#endif
|
||||
|
||||
#define CONFIG_KEYPAD RK27XX_GENERIC_PAD
|
||||
|
||||
/* Define this to enable morse code input */
|
||||
#define HAVE_MORSE_INPUT
|
||||
|
||||
/* Define this if you do software codec */
|
||||
#define CONFIG_CODEC SWCODEC
|
||||
|
||||
/* define this if you have a real-time clock */
|
||||
/* #define CONFIG_RTC RTC_NANO2G */
|
||||
|
||||
/* Define if the device can wake from an RTC alarm */
|
||||
/* #define HAVE_RTC_ALARM */
|
||||
|
||||
#define CONFIG_LCD LCD_SPFD5420A
|
||||
|
||||
/* Define the type of audio codec */
|
||||
#define HAVE_RK27XX_CODEC
|
||||
|
||||
/* #define HAVE_PCM_DMA_ADDRESS */
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
#define MIN_BRIGHTNESS_SETTING 0
|
||||
#define MAX_BRIGHTNESS_SETTING 31
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 20
|
||||
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
||||
/* The number of bytes reserved for loadable codecs */
|
||||
#define CODEC_SIZE 0x100000
|
||||
|
||||
/* The number of bytes reserved for loadable plugins */
|
||||
#define PLUGIN_BUFFER_SIZE 0x80000
|
||||
|
||||
/* TODO: Figure out real values */
|
||||
#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
|
||||
#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
|
||||
#define BATTERY_CAPACITY_MAX 500 /* max. capacity selectable */
|
||||
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
|
||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||
|
||||
/* Hardware controlled charging with monitoring */
|
||||
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||
|
||||
/* define current usage levels */
|
||||
/* TODO: #define CURRENT_NORMAL
|
||||
* TODO: #define CURRENT_BACKLIGHT 23
|
||||
*/
|
||||
|
||||
/* define this if the unit can be powered or charged via USB */
|
||||
#define HAVE_USB_POWER
|
||||
|
||||
/* USB On-the-go */
|
||||
#define CONFIG_USBOTG USBOTG_RK27XX
|
||||
|
||||
/* enable these for the experimental usb stack */
|
||||
#define HAVE_USBSTACK
|
||||
|
||||
#define USE_ROCKBOX_USB
|
||||
#define USB_VENDOR_ID 0x071b
|
||||
#define USB_PRODUCT_ID 0x3202
|
||||
#define HAVE_BOOTLOADER_USB_MODE
|
||||
|
||||
/* Define this if your LCD can set contrast */
|
||||
/* #define HAVE_LCD_CONTRAST */
|
||||
|
||||
/* The exact type of CPU */
|
||||
#define CONFIG_CPU RK27XX
|
||||
|
||||
/* I2C interface */
|
||||
#define CONFIG_I2C I2C_RK27XX
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 200000000
|
||||
|
||||
/* define this if the hardware can be powered off while charging */
|
||||
/* #define HAVE_POWEROFF_WHILE_CHARGING */
|
||||
|
||||
/* Offset ( in the firmware file's header ) to the file CRC */
|
||||
#define FIRMWARE_OFFSET_FILE_CRC 0
|
||||
|
||||
/* Offset ( in the firmware file's header ) to the real data */
|
||||
#define FIRMWARE_OFFSET_FILE_DATA 8
|
||||
|
||||
#define STORAGE_NEEDS_ALIGN
|
||||
|
||||
/* Define this if you have adjustable CPU frequency */
|
||||
/* #define HAVE_ADJUSTABLE_CPU_FREQ */
|
||||
|
||||
#define BOOTFILE_EXT "rk27"
|
||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||
#define BOOTDIR "/.rockbox"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: dac.h 24158 2010-01-03 11:31:14Z Buschel $
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: mas.h 24154 2010-01-03 10:27:43Z Buschel $
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: lcd-clipzip.c 30465 2011-09-06 16:55:52Z bertrik $
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2011 Bertrik Sikken
|
||||
*
|
||||
|
|
|
@ -1,308 +1,308 @@
|
|||
.section .text.post_mortem_stub, "ax", %progbits
|
||||
.align 4
|
||||
.global post_mortem_stub
|
||||
.type post_mortem_stub, %function
|
||||
post_mortem_stub:
|
||||
MSR CPSR_c, #0xD3 @ Supervisor mode, no IRQs, no FIQs
|
||||
MRC p15, 0, R0,c1,c0
|
||||
BIC R0, R0, #5
|
||||
MCR p15, 0, R0,c1,c0 @ Disable the Protection Unit and DCache
|
||||
MOV R13, #0
|
||||
pms_flushcache_loop:
|
||||
MCR p15, 0, R13,c7,c14,2
|
||||
ADD R0, R13, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADD R0, R0, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADD R0, R0, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADDS R13, R13, #0x04000000
|
||||
BNE pms_flushcache_loop
|
||||
MCR p15, 0, R13,c7,c10,4
|
||||
|
||||
LDR R7, pms_00080200
|
||||
ORR R8, R7, #0x8000
|
||||
ADR R9, pms_recvbuf
|
||||
LDR R10, pms_20080040
|
||||
MOV R11, #0x38800000
|
||||
MOV R12, #1
|
||||
|
||||
MOV R2, #0x3C400000
|
||||
ADD R1, R2, #0x00100000 @ Enable USB clocks
|
||||
LDR R0, [R1,#0x28]
|
||||
BIC R0, R0, #0x4000
|
||||
STR R0, [R1,#0x28]
|
||||
LDR R0, [R1,#0x40]
|
||||
BIC R0, R0, #0x800
|
||||
STR R0, [R1,#0x40]
|
||||
LDR R0, pms_20803180 @ Clocking config
|
||||
STR R0, [R1]
|
||||
MOV R0, #0x280
|
||||
STR R0, [R1,#0x3C]
|
||||
MRC p15, 0, R0,c1,c0
|
||||
ORR R0, R0, #0xc0000000
|
||||
MCR p15, 0, R0,c1,c0 @ Asynchronous mode
|
||||
|
||||
STR R13, [R11,#0xE00] @ PHY clock enable
|
||||
|
||||
MOV R1, #0x800
|
||||
ORR R0, R2, #2
|
||||
STR R0, [R11,#0x804] @ USB2 Gadget: Soft disconnect
|
||||
|
||||
STR R13, [R2] @ USB2 PHY: Power on
|
||||
STR R12, [R2,#0x08] @ USB2 PHY: Assert Software Reset
|
||||
MOV R0, #0x10000
|
||||
pms_wait:
|
||||
SUBS R0, R0, #1
|
||||
BNE pms_wait
|
||||
STR R13, [R2,#0x08] @ USB2 PHY: Deassert Software Reset
|
||||
STR R13, [R2,#0x04] @ USB2 PHY: Clock is 48MHz
|
||||
|
||||
STR R12, [R11,#0x10] @ USB2 Gadget: Assert Core Software Reset
|
||||
pms_waitcorereset:
|
||||
LDR R0, [R11,#0x10] @ USB2 Gadget: Wait for Core to reset
|
||||
TST R0, #1
|
||||
BNE pms_waitcorereset
|
||||
TST R0, #0x80000000 @ USB2 Gadget: Wait for AHB IDLE
|
||||
BEQ pms_waitcorereset
|
||||
|
||||
MOV R0, #0x200
|
||||
STR R0, [R11,#0x24] @ USB2 Gadget: RX FIFO size: 512 bytes
|
||||
ORR R0, R0, #0x2000000
|
||||
STR R0, [R11,#0x28] @ USB2 Gadget: Non-periodic TX FIFO size: 512 bytes
|
||||
MOV R0, #0x26
|
||||
STR R0, [R11,#0x08] @ USB2 Gadget: DMA Enable, Burst Length: 4, Mask Interrupts
|
||||
MOV R0, #0x1400
|
||||
ADD R0, R0, #8
|
||||
STR R0, [R11,#0x0C] @ USB2 Gadget: PHY IF is 16bit, Turnaround 5
|
||||
STR R1, [R11,#0x804] @ USB2 Gadget: Soft reconnect
|
||||
|
||||
ADR R14, pms_ctrlbuf
|
||||
ORR R5, R8, #0x84000000
|
||||
@ fallthrough
|
||||
|
||||
pms_mainloop:
|
||||
LDR R3, [R11,#0x14] @ Global USB interrupts
|
||||
TST R3, #0x00001000 @ BUS reset
|
||||
BEQ pms_noreset
|
||||
MOV R0, #0x500
|
||||
STR R0, [R11,#0x804]
|
||||
MOV R0, #4
|
||||
STR R0, [R11,#0x800] @ USB2 Gadget: Device Address 0, STALL on non-zero length status stage
|
||||
MOV R0, #0x8000
|
||||
STR R0, [R11,#0x900] @ USB2 Gadget: Endpoint 0 IN Control: ACTIVE
|
||||
STR R10, [R11,#0xB10] @ USB2 Gadget: Endpoint 0 OUT Transfer Size: 64 Bytes, 1 Packet, 1 Setup Packet
|
||||
STR R14, [R11,#0xB14] @ USB2 Gadget: Endpoint 0 OUT DMA Address: pms_ctrlbuf
|
||||
ORR R6, R0, #0x84000000
|
||||
STR R6, [R11,#0xB00] @ USB2 Gadget: Endpoint 0 OUT Control: ENABLE CLEARNAK
|
||||
STR R8, [R11,#0x960] @ USB2 Gadget: Endpoint 3 IN Control: ACTIVE BULK, 512 byte packets
|
||||
STR R8, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ACTIVE BULK, 512 byte packets
|
||||
STR R7, [R11,#0xB90] @ USB2 Gadget: Endpoint 4 OUT Transfer Size: 512 Bytes, 1 Packet
|
||||
STR R9, [R11,#0xB94] @ USB2 Gadget: Endpoint 4 OUT DMA Address: pms_recvbuf
|
||||
ORR R4, R5, #0x10000000
|
||||
STR R4, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ENABLE CLEARNAK DATA0
|
||||
pms_noreset:
|
||||
LDR R0, [R11,#0x908] @ Just ACK all IN events...
|
||||
STR R0, [R11,#0x908]
|
||||
LDR R0, [R11,#0x968]
|
||||
STR R0, [R11,#0x968]
|
||||
LDR R2, [R11,#0xB08]
|
||||
MOVS R2, R2 @ Event on OUT EP0
|
||||
BEQ pms_noep0out
|
||||
TST R2, #8 @ SETUP phase done
|
||||
BEQ pms_controldone
|
||||
LDRB R0, [R14,#1] @ Get request type
|
||||
CMP R0, #0
|
||||
BEQ pms_GET_STATUS
|
||||
CMP R0, #1
|
||||
BEQ pms_CLEAR_FEATURE
|
||||
CMP R0, #3
|
||||
BEQ pms_SET_FEATURE
|
||||
CMP R0, #5
|
||||
BEQ pms_SET_ADDRESS
|
||||
CMP R0, #6
|
||||
BEQ pms_GET_DESCRIPTOR
|
||||
CMP R0, #8
|
||||
BEQ pms_GET_CONFIGURATION
|
||||
CMP R0, #9
|
||||
BEQ pms_SET_CONFIGURATION
|
||||
pms_ctrlstall:
|
||||
LDR R0, [R11,#0x900]
|
||||
ORR R0, R0, #0x00200000
|
||||
STR R0, [R11,#0x900] @ Stall IN EP0
|
||||
LDR R0, [R11,#0xB00]
|
||||
ORR R0, R0, #0x00200000
|
||||
STR R0, [R11,#0xB00] @ Stall OUT EP0
|
||||
pms_controldone:
|
||||
STR R10, [R11,#0xB10] @ OUT EP0: 64 Bytes, 1 Packet, 1 Setup Packet
|
||||
STR R14, [R11,#0xB14] @ OUT EP0: DMA address
|
||||
STR R6, [R11,#0xB00] @ OUT EP0: Enable ClearNAK
|
||||
pms_noep0out:
|
||||
STR R2, [R11,#0xB08] @ ACK it, whatever it was...
|
||||
LDR R2, [R11,#0xB88]
|
||||
MOVS R2, R2 @ Event on OUT EP4
|
||||
BEQ pms_noep1out
|
||||
TST R2, #1 @ XFER complete
|
||||
BEQ pms_datadone
|
||||
LDR R0, pms_000001FF
|
||||
LDR R1, pms_recvbuf+4
|
||||
ADD R0, R0, R1
|
||||
MOV R0, R0,LSR#9
|
||||
ORR R1, R1, R0,LSL#19 @ Number of packets
|
||||
LDR R0, pms_recvbuf
|
||||
STR R1, [R11,#0x970] @ EP3 IN: Number of packets, size
|
||||
STR R0, [R11,#0x974] @ EP3 IN: DMA address
|
||||
STR R5, [R11,#0x960] @ EP3 IN: Enable ClearNAK
|
||||
pms_datadone:
|
||||
STR R7, [R11,#0xB90] @ OUT EP4: 512 Bytes, 1 Packet
|
||||
STR R9, [R11,#0xB94] @ Out EP4: DMA address
|
||||
STR R5, [R11,#0xB80] @ Out EP4: Enable ClearNAK
|
||||
pms_noep1out:
|
||||
STR R2, [R11,#0xB88] @ ACK it, whatever it was...
|
||||
STR R3, [R11,#0x14] @ ACK global ints
|
||||
B pms_mainloop
|
||||
|
||||
pms_CLEAR_FEATURE:
|
||||
LDRB R0, [R14]
|
||||
CMP R0, #2
|
||||
LDREQ R0, [R14,#2]
|
||||
BICEQ R0, R0, #0x00800000
|
||||
CMPEQ R0, #0x00010000
|
||||
@ fallthrough
|
||||
|
||||
pms_SET_CONFIGURATION:
|
||||
ORREQ R0, R8, #0x10000000
|
||||
STREQ R0, [R11,#0x960] @ EP3 IN: Set DATA0 PID
|
||||
STREQ R4, [R11,#0xB80] @ EP4 OUT: Set DATA0 PID
|
||||
B pms_SET_FEATURE @ zero-length ACK
|
||||
|
||||
pms_GET_CONFIGURATION:
|
||||
MOV R1, #1
|
||||
STR R1, [R14]
|
||||
@ fallthrough
|
||||
|
||||
pms_ctrlsend:
|
||||
ORR R0, R1, #0x00080000 @ 1 Packet
|
||||
STR R0, [R11,#0x910] @ EP0 IN: 1 Packet, Size as in R1
|
||||
STR R14, [R11,#0x914] @ EP0 IN: DMA address
|
||||
ORR R0, R6, #0x1800
|
||||
STR R0, [R11,#0x900] @ EP0 IN: Enable ClearNAK
|
||||
ADR R14, pms_ctrlbuf
|
||||
B pms_controldone
|
||||
|
||||
pms_GET_DESCRIPTOR:
|
||||
LDRB R0, [R14,#3] @ Descriptor type
|
||||
CMP R0, #1
|
||||
ADREQ R14, pms_devicedescriptor
|
||||
BEQ pms_senddescriptor
|
||||
CMP R0, #2
|
||||
ADREQ R14, pms_configurationdescriptor
|
||||
MOVEQ R1, #0x20
|
||||
BEQ pms_senddescriptorcustomsize
|
||||
CMP R0, #3
|
||||
BNE pms_ctrlstall
|
||||
LDRB R0, [R14,#2] @ String descriptor index
|
||||
CMP R0, #0
|
||||
LDREQ R0, pms_langstringdescriptor
|
||||
STREQ R0, [R14]
|
||||
BEQ pms_senddescriptor
|
||||
CMP R0, #1
|
||||
CMPNE R0, #2
|
||||
ADREQ R14, pms_devnamestringdescriptor
|
||||
BNE pms_ctrlstall
|
||||
@ fallthrough
|
||||
|
||||
pms_senddescriptor:
|
||||
LDRB R1, [R14] @ Descriptor length
|
||||
@ fallthrough
|
||||
|
||||
pms_senddescriptorcustomsize:
|
||||
LDRH R0, pms_ctrlbuf+6 @ Requested length
|
||||
CMP R0, R1
|
||||
MOVLO R1, R0
|
||||
B pms_ctrlsend
|
||||
|
||||
pms_SET_ADDRESS:
|
||||
LDRH R1, [R14,#2] @ new address
|
||||
LDR R0, [R11,#0x800]
|
||||
BIC R0, R0, #0x000007F0
|
||||
ORR R0, R0, R1,LSL#4
|
||||
STR R0, [R11,#0x800] @ set new address
|
||||
@ fallthrough
|
||||
|
||||
pms_SET_FEATURE:
|
||||
MOV R1, #0 @ zero-length ACK
|
||||
B pms_ctrlsend
|
||||
|
||||
pms_20803180:
|
||||
.word 0x20803180
|
||||
|
||||
.ltorg
|
||||
|
||||
.align 4
|
||||
|
||||
pms_configurationdescriptor:
|
||||
.word 0x00200209
|
||||
.word 0xC0000101
|
||||
.word 0x00040932
|
||||
.word 0xFFFF0200
|
||||
.word 0x050700FF
|
||||
.word 0x02000204
|
||||
.word 0x83050701
|
||||
.word 0x01020002
|
||||
|
||||
pms_devicedescriptor:
|
||||
.word 0x02000112
|
||||
.word 0x40FFFFFF
|
||||
.word 0xA112FFFF
|
||||
.word 0x02010001
|
||||
.word 0x00010100
|
||||
|
||||
pms_00080200:
|
||||
.word 0x00080200
|
||||
|
||||
pms_20080040:
|
||||
.word 0x20080040
|
||||
|
||||
pms_000001FF:
|
||||
.word 0x000001FF
|
||||
|
||||
pms_devnamestringdescriptor:
|
||||
.word 0x0052030C
|
||||
.word 0x00500042
|
||||
.word 0x0053004D
|
||||
|
||||
pms_langstringdescriptor:
|
||||
.word 0x04090304
|
||||
|
||||
pms_ctrlbuf:
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
|
||||
pms_recvbuf:
|
||||
.word 0
|
||||
.word 0
|
||||
|
||||
pms_GET_STATUS:
|
||||
LDRB R0, [R14]
|
||||
CMP R0, #0x80
|
||||
STREQ R12, [R14]
|
||||
STRNE R13, [R14]
|
||||
MOV R1, #2
|
||||
B pms_ctrlsend
|
||||
|
||||
.size post_mortem_stub, .-post_mortem_stub
|
||||
.section .text.post_mortem_stub, "ax", %progbits
|
||||
.align 4
|
||||
.global post_mortem_stub
|
||||
.type post_mortem_stub, %function
|
||||
post_mortem_stub:
|
||||
MSR CPSR_c, #0xD3 @ Supervisor mode, no IRQs, no FIQs
|
||||
MRC p15, 0, R0,c1,c0
|
||||
BIC R0, R0, #5
|
||||
MCR p15, 0, R0,c1,c0 @ Disable the Protection Unit and DCache
|
||||
MOV R13, #0
|
||||
pms_flushcache_loop:
|
||||
MCR p15, 0, R13,c7,c14,2
|
||||
ADD R0, R13, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADD R0, R0, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADD R0, R0, #0x10
|
||||
MCR p15, 0, R0,c7,c14,2
|
||||
ADDS R13, R13, #0x04000000
|
||||
BNE pms_flushcache_loop
|
||||
MCR p15, 0, R13,c7,c10,4
|
||||
|
||||
LDR R7, pms_00080200
|
||||
ORR R8, R7, #0x8000
|
||||
ADR R9, pms_recvbuf
|
||||
LDR R10, pms_20080040
|
||||
MOV R11, #0x38800000
|
||||
MOV R12, #1
|
||||
|
||||
MOV R2, #0x3C400000
|
||||
ADD R1, R2, #0x00100000 @ Enable USB clocks
|
||||
LDR R0, [R1,#0x28]
|
||||
BIC R0, R0, #0x4000
|
||||
STR R0, [R1,#0x28]
|
||||
LDR R0, [R1,#0x40]
|
||||
BIC R0, R0, #0x800
|
||||
STR R0, [R1,#0x40]
|
||||
LDR R0, pms_20803180 @ Clocking config
|
||||
STR R0, [R1]
|
||||
MOV R0, #0x280
|
||||
STR R0, [R1,#0x3C]
|
||||
MRC p15, 0, R0,c1,c0
|
||||
ORR R0, R0, #0xc0000000
|
||||
MCR p15, 0, R0,c1,c0 @ Asynchronous mode
|
||||
|
||||
STR R13, [R11,#0xE00] @ PHY clock enable
|
||||
|
||||
MOV R1, #0x800
|
||||
ORR R0, R2, #2
|
||||
STR R0, [R11,#0x804] @ USB2 Gadget: Soft disconnect
|
||||
|
||||
STR R13, [R2] @ USB2 PHY: Power on
|
||||
STR R12, [R2,#0x08] @ USB2 PHY: Assert Software Reset
|
||||
MOV R0, #0x10000
|
||||
pms_wait:
|
||||
SUBS R0, R0, #1
|
||||
BNE pms_wait
|
||||
STR R13, [R2,#0x08] @ USB2 PHY: Deassert Software Reset
|
||||
STR R13, [R2,#0x04] @ USB2 PHY: Clock is 48MHz
|
||||
|
||||
STR R12, [R11,#0x10] @ USB2 Gadget: Assert Core Software Reset
|
||||
pms_waitcorereset:
|
||||
LDR R0, [R11,#0x10] @ USB2 Gadget: Wait for Core to reset
|
||||
TST R0, #1
|
||||
BNE pms_waitcorereset
|
||||
TST R0, #0x80000000 @ USB2 Gadget: Wait for AHB IDLE
|
||||
BEQ pms_waitcorereset
|
||||
|
||||
MOV R0, #0x200
|
||||
STR R0, [R11,#0x24] @ USB2 Gadget: RX FIFO size: 512 bytes
|
||||
ORR R0, R0, #0x2000000
|
||||
STR R0, [R11,#0x28] @ USB2 Gadget: Non-periodic TX FIFO size: 512 bytes
|
||||
MOV R0, #0x26
|
||||
STR R0, [R11,#0x08] @ USB2 Gadget: DMA Enable, Burst Length: 4, Mask Interrupts
|
||||
MOV R0, #0x1400
|
||||
ADD R0, R0, #8
|
||||
STR R0, [R11,#0x0C] @ USB2 Gadget: PHY IF is 16bit, Turnaround 5
|
||||
STR R1, [R11,#0x804] @ USB2 Gadget: Soft reconnect
|
||||
|
||||
ADR R14, pms_ctrlbuf
|
||||
ORR R5, R8, #0x84000000
|
||||
@ fallthrough
|
||||
|
||||
pms_mainloop:
|
||||
LDR R3, [R11,#0x14] @ Global USB interrupts
|
||||
TST R3, #0x00001000 @ BUS reset
|
||||
BEQ pms_noreset
|
||||
MOV R0, #0x500
|
||||
STR R0, [R11,#0x804]
|
||||
MOV R0, #4
|
||||
STR R0, [R11,#0x800] @ USB2 Gadget: Device Address 0, STALL on non-zero length status stage
|
||||
MOV R0, #0x8000
|
||||
STR R0, [R11,#0x900] @ USB2 Gadget: Endpoint 0 IN Control: ACTIVE
|
||||
STR R10, [R11,#0xB10] @ USB2 Gadget: Endpoint 0 OUT Transfer Size: 64 Bytes, 1 Packet, 1 Setup Packet
|
||||
STR R14, [R11,#0xB14] @ USB2 Gadget: Endpoint 0 OUT DMA Address: pms_ctrlbuf
|
||||
ORR R6, R0, #0x84000000
|
||||
STR R6, [R11,#0xB00] @ USB2 Gadget: Endpoint 0 OUT Control: ENABLE CLEARNAK
|
||||
STR R8, [R11,#0x960] @ USB2 Gadget: Endpoint 3 IN Control: ACTIVE BULK, 512 byte packets
|
||||
STR R8, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ACTIVE BULK, 512 byte packets
|
||||
STR R7, [R11,#0xB90] @ USB2 Gadget: Endpoint 4 OUT Transfer Size: 512 Bytes, 1 Packet
|
||||
STR R9, [R11,#0xB94] @ USB2 Gadget: Endpoint 4 OUT DMA Address: pms_recvbuf
|
||||
ORR R4, R5, #0x10000000
|
||||
STR R4, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ENABLE CLEARNAK DATA0
|
||||
pms_noreset:
|
||||
LDR R0, [R11,#0x908] @ Just ACK all IN events...
|
||||
STR R0, [R11,#0x908]
|
||||
LDR R0, [R11,#0x968]
|
||||
STR R0, [R11,#0x968]
|
||||
LDR R2, [R11,#0xB08]
|
||||
MOVS R2, R2 @ Event on OUT EP0
|
||||
BEQ pms_noep0out
|
||||
TST R2, #8 @ SETUP phase done
|
||||
BEQ pms_controldone
|
||||
LDRB R0, [R14,#1] @ Get request type
|
||||
CMP R0, #0
|
||||
BEQ pms_GET_STATUS
|
||||
CMP R0, #1
|
||||
BEQ pms_CLEAR_FEATURE
|
||||
CMP R0, #3
|
||||
BEQ pms_SET_FEATURE
|
||||
CMP R0, #5
|
||||
BEQ pms_SET_ADDRESS
|
||||
CMP R0, #6
|
||||
BEQ pms_GET_DESCRIPTOR
|
||||
CMP R0, #8
|
||||
BEQ pms_GET_CONFIGURATION
|
||||
CMP R0, #9
|
||||
BEQ pms_SET_CONFIGURATION
|
||||
pms_ctrlstall:
|
||||
LDR R0, [R11,#0x900]
|
||||
ORR R0, R0, #0x00200000
|
||||
STR R0, [R11,#0x900] @ Stall IN EP0
|
||||
LDR R0, [R11,#0xB00]
|
||||
ORR R0, R0, #0x00200000
|
||||
STR R0, [R11,#0xB00] @ Stall OUT EP0
|
||||
pms_controldone:
|
||||
STR R10, [R11,#0xB10] @ OUT EP0: 64 Bytes, 1 Packet, 1 Setup Packet
|
||||
STR R14, [R11,#0xB14] @ OUT EP0: DMA address
|
||||
STR R6, [R11,#0xB00] @ OUT EP0: Enable ClearNAK
|
||||
pms_noep0out:
|
||||
STR R2, [R11,#0xB08] @ ACK it, whatever it was...
|
||||
LDR R2, [R11,#0xB88]
|
||||
MOVS R2, R2 @ Event on OUT EP4
|
||||
BEQ pms_noep1out
|
||||
TST R2, #1 @ XFER complete
|
||||
BEQ pms_datadone
|
||||
LDR R0, pms_000001FF
|
||||
LDR R1, pms_recvbuf+4
|
||||
ADD R0, R0, R1
|
||||
MOV R0, R0,LSR#9
|
||||
ORR R1, R1, R0,LSL#19 @ Number of packets
|
||||
LDR R0, pms_recvbuf
|
||||
STR R1, [R11,#0x970] @ EP3 IN: Number of packets, size
|
||||
STR R0, [R11,#0x974] @ EP3 IN: DMA address
|
||||
STR R5, [R11,#0x960] @ EP3 IN: Enable ClearNAK
|
||||
pms_datadone:
|
||||
STR R7, [R11,#0xB90] @ OUT EP4: 512 Bytes, 1 Packet
|
||||
STR R9, [R11,#0xB94] @ Out EP4: DMA address
|
||||
STR R5, [R11,#0xB80] @ Out EP4: Enable ClearNAK
|
||||
pms_noep1out:
|
||||
STR R2, [R11,#0xB88] @ ACK it, whatever it was...
|
||||
STR R3, [R11,#0x14] @ ACK global ints
|
||||
B pms_mainloop
|
||||
|
||||
pms_CLEAR_FEATURE:
|
||||
LDRB R0, [R14]
|
||||
CMP R0, #2
|
||||
LDREQ R0, [R14,#2]
|
||||
BICEQ R0, R0, #0x00800000
|
||||
CMPEQ R0, #0x00010000
|
||||
@ fallthrough
|
||||
|
||||
pms_SET_CONFIGURATION:
|
||||
ORREQ R0, R8, #0x10000000
|
||||
STREQ R0, [R11,#0x960] @ EP3 IN: Set DATA0 PID
|
||||
STREQ R4, [R11,#0xB80] @ EP4 OUT: Set DATA0 PID
|
||||
B pms_SET_FEATURE @ zero-length ACK
|
||||
|
||||
pms_GET_CONFIGURATION:
|
||||
MOV R1, #1
|
||||
STR R1, [R14]
|
||||
@ fallthrough
|
||||
|
||||
pms_ctrlsend:
|
||||
ORR R0, R1, #0x00080000 @ 1 Packet
|
||||
STR R0, [R11,#0x910] @ EP0 IN: 1 Packet, Size as in R1
|
||||
STR R14, [R11,#0x914] @ EP0 IN: DMA address
|
||||
ORR R0, R6, #0x1800
|
||||
STR R0, [R11,#0x900] @ EP0 IN: Enable ClearNAK
|
||||
ADR R14, pms_ctrlbuf
|
||||
B pms_controldone
|
||||
|
||||
pms_GET_DESCRIPTOR:
|
||||
LDRB R0, [R14,#3] @ Descriptor type
|
||||
CMP R0, #1
|
||||
ADREQ R14, pms_devicedescriptor
|
||||
BEQ pms_senddescriptor
|
||||
CMP R0, #2
|
||||
ADREQ R14, pms_configurationdescriptor
|
||||
MOVEQ R1, #0x20
|
||||
BEQ pms_senddescriptorcustomsize
|
||||
CMP R0, #3
|
||||
BNE pms_ctrlstall
|
||||
LDRB R0, [R14,#2] @ String descriptor index
|
||||
CMP R0, #0
|
||||
LDREQ R0, pms_langstringdescriptor
|
||||
STREQ R0, [R14]
|
||||
BEQ pms_senddescriptor
|
||||
CMP R0, #1
|
||||
CMPNE R0, #2
|
||||
ADREQ R14, pms_devnamestringdescriptor
|
||||
BNE pms_ctrlstall
|
||||
@ fallthrough
|
||||
|
||||
pms_senddescriptor:
|
||||
LDRB R1, [R14] @ Descriptor length
|
||||
@ fallthrough
|
||||
|
||||
pms_senddescriptorcustomsize:
|
||||
LDRH R0, pms_ctrlbuf+6 @ Requested length
|
||||
CMP R0, R1
|
||||
MOVLO R1, R0
|
||||
B pms_ctrlsend
|
||||
|
||||
pms_SET_ADDRESS:
|
||||
LDRH R1, [R14,#2] @ new address
|
||||
LDR R0, [R11,#0x800]
|
||||
BIC R0, R0, #0x000007F0
|
||||
ORR R0, R0, R1,LSL#4
|
||||
STR R0, [R11,#0x800] @ set new address
|
||||
@ fallthrough
|
||||
|
||||
pms_SET_FEATURE:
|
||||
MOV R1, #0 @ zero-length ACK
|
||||
B pms_ctrlsend
|
||||
|
||||
pms_20803180:
|
||||
.word 0x20803180
|
||||
|
||||
.ltorg
|
||||
|
||||
.align 4
|
||||
|
||||
pms_configurationdescriptor:
|
||||
.word 0x00200209
|
||||
.word 0xC0000101
|
||||
.word 0x00040932
|
||||
.word 0xFFFF0200
|
||||
.word 0x050700FF
|
||||
.word 0x02000204
|
||||
.word 0x83050701
|
||||
.word 0x01020002
|
||||
|
||||
pms_devicedescriptor:
|
||||
.word 0x02000112
|
||||
.word 0x40FFFFFF
|
||||
.word 0xA112FFFF
|
||||
.word 0x02010001
|
||||
.word 0x00010100
|
||||
|
||||
pms_00080200:
|
||||
.word 0x00080200
|
||||
|
||||
pms_20080040:
|
||||
.word 0x20080040
|
||||
|
||||
pms_000001FF:
|
||||
.word 0x000001FF
|
||||
|
||||
pms_devnamestringdescriptor:
|
||||
.word 0x0052030C
|
||||
.word 0x00500042
|
||||
.word 0x0053004D
|
||||
|
||||
pms_langstringdescriptor:
|
||||
.word 0x04090304
|
||||
|
||||
pms_ctrlbuf:
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
|
||||
pms_recvbuf:
|
||||
.word 0
|
||||
.word 0
|
||||
|
||||
pms_GET_STATUS:
|
||||
LDRB R0, [R14]
|
||||
CMP R0, #0x80
|
||||
STREQ R12, [R14]
|
||||
STRNE R13, [R14]
|
||||
MOV R1, #2
|
||||
B pms_ctrlsend
|
||||
|
||||
.size post_mortem_stub, .-post_mortem_stub
|
||||
|
|
|
@ -1,166 +1,166 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: debug-s5l8700.c 28719 2010-12-01 18:35:01Z Buschel $
|
||||
*
|
||||
* Copyright © 2008 Rafaël Carré
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "debug-target.h"
|
||||
#include "button.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "power.h"
|
||||
#include "pmu-target.h"
|
||||
#include "pcm-target.h"
|
||||
|
||||
/* Skeleton for adding target specific debug info to the debug menu
|
||||
*/
|
||||
|
||||
#define _DEBUG_PRINTF(a, varargs...) lcd_putsf(0, line++, (a), ##varargs);
|
||||
|
||||
extern int lcd_type;
|
||||
bool dbg_hw_info(void)
|
||||
{
|
||||
int line;
|
||||
int i;
|
||||
unsigned int state = 0;
|
||||
const unsigned int max_states=3;
|
||||
|
||||
lcd_clear_display();
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
state=0;
|
||||
while(1)
|
||||
{
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
|
||||
if(state == 0)
|
||||
{
|
||||
_DEBUG_PRINTF("CPU:");
|
||||
_DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
|
||||
line++;
|
||||
|
||||
_DEBUG_PRINTF("LCD type: %d", lcd_type);
|
||||
line++;
|
||||
}
|
||||
else if(state==1)
|
||||
{
|
||||
_DEBUG_PRINTF("PMU:");
|
||||
for(i=0;i<7;i++)
|
||||
{
|
||||
char *device[] = {"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)"};
|
||||
_DEBUG_PRINTF("ldo%d %s: %dmV %s",i,
|
||||
pmu_read(0x2e + (i << 1))?" on":"off",
|
||||
900 + pmu_read(0x2d + (i << 1))*100,
|
||||
device[i]);
|
||||
}
|
||||
_DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
|
||||
_DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
|
||||
line++;
|
||||
_DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
|
||||
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
||||
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
||||
}
|
||||
else if(state==2)
|
||||
{
|
||||
_DEBUG_PRINTF("Audio DMA:");
|
||||
_DEBUG_PRINTF(">%08X %08X %08X %08X %08X", DMAC0C0CONFIG, DMAC0C0SRCADDR,
|
||||
DMAC0C0DESTADDR, DMAC0C0NEXTLLI, DMAC0C0CONTROL);
|
||||
for(i = 0; i < PCM_LLICOUNT; i++)
|
||||
_DEBUG_PRINTF("%08X: %08X %08X %08X %08X", &pcm_lli[i], pcm_lli[i].srcaddr,
|
||||
pcm_lli[i].dstaddr, pcm_lli[i].nextlli, pcm_lli[i].control);
|
||||
_DEBUG_PRINTF("chunk: %08X %08X", pcm_chunksize, pcm_remaining);
|
||||
}
|
||||
else
|
||||
{
|
||||
state=0;
|
||||
}
|
||||
|
||||
|
||||
lcd_update();
|
||||
switch(button_get_w_tmo(HZ/20))
|
||||
{
|
||||
case BUTTON_SCROLL_BACK:
|
||||
if(state!=0) state--;
|
||||
break;
|
||||
|
||||
case BUTTON_SCROLL_FWD:
|
||||
if(state!=max_states-1)
|
||||
{
|
||||
state++;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEBUG_CANCEL:
|
||||
case BUTTON_REL:
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dbg_ports(void)
|
||||
{
|
||||
int line;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
while(1)
|
||||
{
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
|
||||
_DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT(0));
|
||||
_DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT(1));
|
||||
_DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT(2));
|
||||
_DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT(3));
|
||||
_DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT(4));
|
||||
_DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT(5));
|
||||
_DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT(6));
|
||||
_DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT(7));
|
||||
_DEBUG_PRINTF("GPIO 8: %08x",(unsigned int)PDAT(8));
|
||||
_DEBUG_PRINTF("GPIO 9: %08x",(unsigned int)PDAT(9));
|
||||
_DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT(10));
|
||||
_DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT(11));
|
||||
_DEBUG_PRINTF("GPIO 12: %08x",(unsigned int)PDAT(12));
|
||||
_DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT(13));
|
||||
_DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT(14));
|
||||
_DEBUG_PRINTF("GPIO 15: %08x",(unsigned int)PDAT(15));
|
||||
_DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
|
||||
|
||||
lcd_update();
|
||||
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
||||
break;
|
||||
}
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: debug-s5l8700.c 28719 2010-12-01 18:35:01Z Buschel $
|
||||
*
|
||||
* Copyright © 2008 Rafaël Carré
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
#include "debug-target.h"
|
||||
#include "button.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "storage.h"
|
||||
#include "power.h"
|
||||
#include "pmu-target.h"
|
||||
#include "pcm-target.h"
|
||||
|
||||
/* Skeleton for adding target specific debug info to the debug menu
|
||||
*/
|
||||
|
||||
#define _DEBUG_PRINTF(a, varargs...) lcd_putsf(0, line++, (a), ##varargs);
|
||||
|
||||
extern int lcd_type;
|
||||
bool dbg_hw_info(void)
|
||||
{
|
||||
int line;
|
||||
int i;
|
||||
unsigned int state = 0;
|
||||
const unsigned int max_states=3;
|
||||
|
||||
lcd_clear_display();
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
state=0;
|
||||
while(1)
|
||||
{
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
|
||||
if(state == 0)
|
||||
{
|
||||
_DEBUG_PRINTF("CPU:");
|
||||
_DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
|
||||
line++;
|
||||
|
||||
_DEBUG_PRINTF("LCD type: %d", lcd_type);
|
||||
line++;
|
||||
}
|
||||
else if(state==1)
|
||||
{
|
||||
_DEBUG_PRINTF("PMU:");
|
||||
for(i=0;i<7;i++)
|
||||
{
|
||||
char *device[] = {"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)",
|
||||
"(unknown)"};
|
||||
_DEBUG_PRINTF("ldo%d %s: %dmV %s",i,
|
||||
pmu_read(0x2e + (i << 1))?" on":"off",
|
||||
900 + pmu_read(0x2d + (i << 1))*100,
|
||||
device[i]);
|
||||
}
|
||||
_DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
|
||||
_DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
|
||||
line++;
|
||||
_DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
|
||||
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
||||
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
||||
}
|
||||
else if(state==2)
|
||||
{
|
||||
_DEBUG_PRINTF("Audio DMA:");
|
||||
_DEBUG_PRINTF(">%08X %08X %08X %08X %08X", DMAC0C0CONFIG, DMAC0C0SRCADDR,
|
||||
DMAC0C0DESTADDR, DMAC0C0NEXTLLI, DMAC0C0CONTROL);
|
||||
for(i = 0; i < PCM_LLICOUNT; i++)
|
||||
_DEBUG_PRINTF("%08X: %08X %08X %08X %08X", &pcm_lli[i], pcm_lli[i].srcaddr,
|
||||
pcm_lli[i].dstaddr, pcm_lli[i].nextlli, pcm_lli[i].control);
|
||||
_DEBUG_PRINTF("chunk: %08X %08X", pcm_chunksize, pcm_remaining);
|
||||
}
|
||||
else
|
||||
{
|
||||
state=0;
|
||||
}
|
||||
|
||||
|
||||
lcd_update();
|
||||
switch(button_get_w_tmo(HZ/20))
|
||||
{
|
||||
case BUTTON_SCROLL_BACK:
|
||||
if(state!=0) state--;
|
||||
break;
|
||||
|
||||
case BUTTON_SCROLL_FWD:
|
||||
if(state!=max_states-1)
|
||||
{
|
||||
state++;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEBUG_CANCEL:
|
||||
case BUTTON_REL:
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dbg_ports(void)
|
||||
{
|
||||
int line;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
while(1)
|
||||
{
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
|
||||
_DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT(0));
|
||||
_DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT(1));
|
||||
_DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT(2));
|
||||
_DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT(3));
|
||||
_DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT(4));
|
||||
_DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT(5));
|
||||
_DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT(6));
|
||||
_DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT(7));
|
||||
_DEBUG_PRINTF("GPIO 8: %08x",(unsigned int)PDAT(8));
|
||||
_DEBUG_PRINTF("GPIO 9: %08x",(unsigned int)PDAT(9));
|
||||
_DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT(10));
|
||||
_DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT(11));
|
||||
_DEBUG_PRINTF("GPIO 12: %08x",(unsigned int)PDAT(12));
|
||||
_DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT(13));
|
||||
_DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT(14));
|
||||
_DEBUG_PRINTF("GPIO 15: %08x",(unsigned int)PDAT(15));
|
||||
_DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
|
||||
|
||||
lcd_update();
|
||||
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
||||
break;
|
||||
}
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: debug-target.h 28522 2010-11-06 14:24:25Z wodz $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _DEBUG_TARGET_H_
|
||||
#define _DEBUG_TARGET_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define DEBUG_CANCEL BUTTON_MENU
|
||||
|
||||
bool dbg_hw_info(void);
|
||||
bool dbg_ports(void);
|
||||
|
||||
#endif /* _DEBUG_TARGET_H_ */
|
||||
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: debug-target.h 28522 2010-11-06 14:24:25Z wodz $
|
||||
*
|
||||
* Copyright (C) 2007 by Karl Kurbjun
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _DEBUG_TARGET_H_
|
||||
#define _DEBUG_TARGET_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define DEBUG_CANCEL BUTTON_MENU
|
||||
|
||||
bool dbg_hw_info(void);
|
||||
bool dbg_ports(void);
|
||||
|
||||
#endif /* _DEBUG_TARGET_H_ */
|
||||
|
||||
|
|
|
@ -1,196 +1,196 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: i2c-s5l8700.c 28589 2010-11-14 15:19:30Z theseven $
|
||||
*
|
||||
* Copyright (C) 2009 by Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "i2c-s5l8702.h"
|
||||
|
||||
/* Driver for the s5l8700 built-in I2C controller in master mode
|
||||
|
||||
Both the i2c_read and i2c_write function take the following arguments:
|
||||
* slave, the address of the i2c slave device to read from / write to
|
||||
* address, optional sub-address in the i2c slave (unused if -1)
|
||||
* len, number of bytes to be transfered
|
||||
* data, pointer to data to be transfered
|
||||
A return value < 0 indicates an error.
|
||||
|
||||
Note:
|
||||
* blocks the calling thread for the entire duraton of the i2c transfer but
|
||||
uses wakeup_wait/wakeup_signal to allow other threads to run.
|
||||
* ACK from slave is not checked, so functions never return an error
|
||||
*/
|
||||
|
||||
static struct mutex i2c_mtx[2];
|
||||
|
||||
static void i2c_on(int bus)
|
||||
{
|
||||
/* enable I2C clock */
|
||||
PWRCON(1) &= ~(1 << 4);
|
||||
|
||||
IICCON(bus) = (1 << 7) | /* ACK_GEN */
|
||||
(0 << 6) | /* CLKSEL = PCLK/16 */
|
||||
(1 << 5) | /* INT_EN */
|
||||
(1 << 4) | /* IRQ clear */
|
||||
(7 << 0); /* CK_REG */
|
||||
|
||||
/* serial output on */
|
||||
IICSTAT(bus) = (1 << 4);
|
||||
}
|
||||
|
||||
static void i2c_off(int bus)
|
||||
{
|
||||
/* serial output off */
|
||||
IICSTAT(bus) = 0;
|
||||
|
||||
/* disable I2C clock */
|
||||
PWRCON(1) |= (1 << 4);
|
||||
}
|
||||
|
||||
void i2c_init()
|
||||
{
|
||||
mutex_init(&i2c_mtx[0]);
|
||||
mutex_init(&i2c_mtx[1]);
|
||||
}
|
||||
|
||||
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data)
|
||||
{
|
||||
mutex_lock(&i2c_mtx[bus]);
|
||||
i2c_on(bus);
|
||||
long timeout = current_tick + HZ / 50;
|
||||
|
||||
/* START */
|
||||
IICDS(bus) = slave & ~1;
|
||||
IICSTAT(bus) = 0xF0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (address >= 0) {
|
||||
/* write address */
|
||||
IICDS(bus) = address;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* write data */
|
||||
while (len--) {
|
||||
IICDS(bus) = *data++;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* STOP */
|
||||
IICSTAT(bus) = 0xD0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 5;
|
||||
}
|
||||
|
||||
i2c_off(bus);
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data)
|
||||
{
|
||||
mutex_lock(&i2c_mtx[bus]);
|
||||
i2c_on(bus);
|
||||
long timeout = current_tick + HZ / 50;
|
||||
|
||||
if (address >= 0) {
|
||||
/* START */
|
||||
IICDS(bus) = slave & ~1;
|
||||
IICSTAT(bus) = 0xF0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* write address */
|
||||
IICDS(bus) = address;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* (repeated) START */
|
||||
IICDS(bus) = slave | 1;
|
||||
IICSTAT(bus) = 0xB0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
while (len--) {
|
||||
IICCON(bus) = (len == 0) ? 0x33 : 0xB3; /* NAK or ACK */
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 4;
|
||||
}
|
||||
*data++ = IICDS(bus);
|
||||
}
|
||||
|
||||
/* STOP */
|
||||
IICSTAT(bus) = 0x90;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 5;
|
||||
}
|
||||
|
||||
i2c_off(bus);
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: i2c-s5l8700.c 28589 2010-11-14 15:19:30Z theseven $
|
||||
*
|
||||
* Copyright (C) 2009 by Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "i2c-s5l8702.h"
|
||||
|
||||
/* Driver for the s5l8700 built-in I2C controller in master mode
|
||||
|
||||
Both the i2c_read and i2c_write function take the following arguments:
|
||||
* slave, the address of the i2c slave device to read from / write to
|
||||
* address, optional sub-address in the i2c slave (unused if -1)
|
||||
* len, number of bytes to be transfered
|
||||
* data, pointer to data to be transfered
|
||||
A return value < 0 indicates an error.
|
||||
|
||||
Note:
|
||||
* blocks the calling thread for the entire duraton of the i2c transfer but
|
||||
uses wakeup_wait/wakeup_signal to allow other threads to run.
|
||||
* ACK from slave is not checked, so functions never return an error
|
||||
*/
|
||||
|
||||
static struct mutex i2c_mtx[2];
|
||||
|
||||
static void i2c_on(int bus)
|
||||
{
|
||||
/* enable I2C clock */
|
||||
PWRCON(1) &= ~(1 << 4);
|
||||
|
||||
IICCON(bus) = (1 << 7) | /* ACK_GEN */
|
||||
(0 << 6) | /* CLKSEL = PCLK/16 */
|
||||
(1 << 5) | /* INT_EN */
|
||||
(1 << 4) | /* IRQ clear */
|
||||
(7 << 0); /* CK_REG */
|
||||
|
||||
/* serial output on */
|
||||
IICSTAT(bus) = (1 << 4);
|
||||
}
|
||||
|
||||
static void i2c_off(int bus)
|
||||
{
|
||||
/* serial output off */
|
||||
IICSTAT(bus) = 0;
|
||||
|
||||
/* disable I2C clock */
|
||||
PWRCON(1) |= (1 << 4);
|
||||
}
|
||||
|
||||
void i2c_init()
|
||||
{
|
||||
mutex_init(&i2c_mtx[0]);
|
||||
mutex_init(&i2c_mtx[1]);
|
||||
}
|
||||
|
||||
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data)
|
||||
{
|
||||
mutex_lock(&i2c_mtx[bus]);
|
||||
i2c_on(bus);
|
||||
long timeout = current_tick + HZ / 50;
|
||||
|
||||
/* START */
|
||||
IICDS(bus) = slave & ~1;
|
||||
IICSTAT(bus) = 0xF0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (address >= 0) {
|
||||
/* write address */
|
||||
IICDS(bus) = address;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* write data */
|
||||
while (len--) {
|
||||
IICDS(bus) = *data++;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* STOP */
|
||||
IICSTAT(bus) = 0xD0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 5;
|
||||
}
|
||||
|
||||
i2c_off(bus);
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data)
|
||||
{
|
||||
mutex_lock(&i2c_mtx[bus]);
|
||||
i2c_on(bus);
|
||||
long timeout = current_tick + HZ / 50;
|
||||
|
||||
if (address >= 0) {
|
||||
/* START */
|
||||
IICDS(bus) = slave & ~1;
|
||||
IICSTAT(bus) = 0xF0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* write address */
|
||||
IICDS(bus) = address;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* (repeated) START */
|
||||
IICDS(bus) = slave | 1;
|
||||
IICSTAT(bus) = 0xB0;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
while (len--) {
|
||||
IICCON(bus) = (len == 0) ? 0x33 : 0xB3; /* NAK or ACK */
|
||||
while ((IICCON(bus) & 0x10) == 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 4;
|
||||
}
|
||||
*data++ = IICDS(bus);
|
||||
}
|
||||
|
||||
/* STOP */
|
||||
IICSTAT(bus) = 0x90;
|
||||
IICCON(bus) = 0xB3;
|
||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||
if (TIME_AFTER(current_tick, timeout))
|
||||
{
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 5;
|
||||
}
|
||||
|
||||
i2c_off(bus);
|
||||
mutex_unlock(&i2c_mtx[bus]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: kernel-s5l8700.c 28795 2010-12-11 17:52:52Z Buschel $
|
||||
*
|
||||
* Copyright © 2009 Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* S5L8702 driver for the kernel timer
|
||||
|
||||
Timer B is configured as a 10 kHz timer
|
||||
*/
|
||||
|
||||
void INT_TIMERB(void)
|
||||
{
|
||||
/* clear interrupt */
|
||||
TBCON = TBCON;
|
||||
|
||||
call_tick_tasks(); /* Run through the list of tick tasks */
|
||||
}
|
||||
|
||||
void tick_start(unsigned int interval_in_ms)
|
||||
{
|
||||
int cycles = 10 * interval_in_ms;
|
||||
|
||||
/* configure timer for 10 kHz */
|
||||
TBCMD = (1 << 1); /* TB_CLR */
|
||||
TBPRE = 337 - 1; /* prescaler */
|
||||
TBCON = (0 << 13) | /* TB_INT1_EN */
|
||||
(1 << 12) | /* TB_INT0_EN */
|
||||
(0 << 11) | /* TB_START */
|
||||
(2 << 8) | /* TB_CS = PCLK / 16 */
|
||||
(0 << 4); /* TB_MODE_SEL = interval mode */
|
||||
TBDATA0 = cycles; /* set interval period */
|
||||
TBCMD = (1 << 0); /* TB_EN */
|
||||
|
||||
/* enable timer interrupt */
|
||||
VIC0INTENABLE = 1 << IRQ_TIMER;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: kernel-s5l8700.c 28795 2010-12-11 17:52:52Z Buschel $
|
||||
*
|
||||
* Copyright © 2009 Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* S5L8702 driver for the kernel timer
|
||||
|
||||
Timer B is configured as a 10 kHz timer
|
||||
*/
|
||||
|
||||
void INT_TIMERB(void)
|
||||
{
|
||||
/* clear interrupt */
|
||||
TBCON = TBCON;
|
||||
|
||||
call_tick_tasks(); /* Run through the list of tick tasks */
|
||||
}
|
||||
|
||||
void tick_start(unsigned int interval_in_ms)
|
||||
{
|
||||
int cycles = 10 * interval_in_ms;
|
||||
|
||||
/* configure timer for 10 kHz */
|
||||
TBCMD = (1 << 1); /* TB_CLR */
|
||||
TBPRE = 337 - 1; /* prescaler */
|
||||
TBCON = (0 << 13) | /* TB_INT1_EN */
|
||||
(1 << 12) | /* TB_INT0_EN */
|
||||
(0 << 11) | /* TB_START */
|
||||
(2 << 8) | /* TB_CS = PCLK / 16 */
|
||||
(0 << 4); /* TB_MODE_SEL = interval mode */
|
||||
TBDATA0 = cycles; /* set interval period */
|
||||
TBCMD = (1 << 0); /* TB_EN */
|
||||
|
||||
/* enable timer interrupt */
|
||||
VIC0INTENABLE = 1 << IRQ_TIMER;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,228 +1,228 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: pcm-s5l8700.c 28600 2010-11-14 19:49:20Z Buschel $
|
||||
*
|
||||
* Copyright © 2011 Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "audio.h"
|
||||
#include "s5l8702.h"
|
||||
#include "panic.h"
|
||||
#include "audiohw.h"
|
||||
#include "pcm.h"
|
||||
#include "pcm-internal.h"
|
||||
#include "pcm_sampr.h"
|
||||
#include "mmu-arm.h"
|
||||
#include "pcm-target.h"
|
||||
|
||||
static volatile int locked = 0;
|
||||
static const int zerosample = 0;
|
||||
static unsigned char dblbuf[2][PCM_WATERMARK * 4];
|
||||
static int active_dblbuf;
|
||||
struct dma_lli pcm_lli[PCM_LLICOUNT] __attribute__((aligned(16)));
|
||||
static struct dma_lli* lastlli;
|
||||
static const unsigned char* dataptr;
|
||||
size_t pcm_remaining;
|
||||
size_t pcm_chunksize;
|
||||
|
||||
/* Mask the DMA interrupt */
|
||||
void pcm_play_lock(void)
|
||||
{
|
||||
if (locked++ == 0) {
|
||||
//TODO: Urgh, I don't like that at all...
|
||||
VIC0INTENCLEAR = 1 << IRQ_DMAC0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unmask the DMA interrupt if enabled */
|
||||
void pcm_play_unlock(void)
|
||||
{
|
||||
if (--locked == 0) {
|
||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||
}
|
||||
}
|
||||
|
||||
void INT_DMAC0C0(void) ICODE_ATTR;
|
||||
void INT_DMAC0C0(void)
|
||||
{
|
||||
DMAC0INTTCCLR = 1;
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
pcm_play_get_more_callback((void**)&dataptr, &pcm_remaining);
|
||||
pcm_chunksize = pcm_remaining;
|
||||
}
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
pcm_lli->nextlli = NULL;
|
||||
pcm_lli->control = 0x75249000;
|
||||
clean_dcache();
|
||||
return;
|
||||
}
|
||||
uint32_t lastsize = MIN(PCM_WATERMARK * 4, pcm_remaining / 2 + 1) & ~1;
|
||||
pcm_remaining -= lastsize;
|
||||
if (pcm_remaining) lastlli = &pcm_lli[ARRAYLEN(pcm_lli) - 1];
|
||||
else lastlli = pcm_lli;
|
||||
uint32_t chunksize = MIN(PCM_CHUNKSIZE * 4 - lastsize, pcm_remaining);
|
||||
if (pcm_remaining > chunksize && chunksize > pcm_remaining - PCM_WATERMARK * 8)
|
||||
chunksize = pcm_remaining - PCM_WATERMARK * 8;
|
||||
pcm_remaining -= chunksize;
|
||||
bool last = !chunksize;
|
||||
int i = 0;
|
||||
while (chunksize)
|
||||
{
|
||||
uint32_t thislli = MIN(PCM_LLIMAX * 4, chunksize);
|
||||
chunksize -= thislli;
|
||||
pcm_lli[i].srcaddr = (void*)dataptr;
|
||||
pcm_lli[i].dstaddr = (void*)((int)&I2STXDB0);
|
||||
pcm_lli[i].nextlli = chunksize ? &pcm_lli[i + 1] : lastlli;
|
||||
pcm_lli[i].control = (chunksize ? 0x75249000 : 0xf5249000) | (thislli / 2);
|
||||
dataptr += thislli;
|
||||
i++;
|
||||
}
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
memcpy(dblbuf[active_dblbuf], dataptr, lastsize);
|
||||
lastlli->srcaddr = dblbuf[active_dblbuf];
|
||||
active_dblbuf ^= 1;
|
||||
}
|
||||
else lastlli->srcaddr = dataptr;
|
||||
lastlli->dstaddr = (void*)((int)&I2STXDB0);
|
||||
lastlli->nextlli = last ? NULL : pcm_lli;
|
||||
lastlli->control = (last ? 0xf5249000 : 0x75249000) | (lastsize / 2);
|
||||
dataptr += lastsize;
|
||||
clean_dcache();
|
||||
if (!(DMAC0C0CONFIG & 1) && (pcm_lli[0].control & 0xfff))
|
||||
{
|
||||
DMAC0C0LLI = pcm_lli[0];
|
||||
DMAC0C0CONFIG = 0x8a81;
|
||||
}
|
||||
else DMAC0C0NEXTLLI = pcm_lli;
|
||||
|
||||
pcm_play_dma_started_callback();
|
||||
}
|
||||
|
||||
void pcm_play_dma_start(const void* addr, size_t size)
|
||||
{
|
||||
dataptr = (const unsigned char*)addr;
|
||||
pcm_remaining = size;
|
||||
I2STXCOM = 0xe;
|
||||
DMAC0CONFIG |= 4;
|
||||
INT_DMAC0C0();
|
||||
}
|
||||
|
||||
void pcm_play_dma_stop(void)
|
||||
{
|
||||
DMAC0C0CONFIG = 0x8a80;
|
||||
I2STXCOM = 0xa;
|
||||
}
|
||||
|
||||
/* pause playback by disabling LRCK */
|
||||
void pcm_play_dma_pause(bool pause)
|
||||
{
|
||||
if (pause) I2STXCOM |= 1;
|
||||
else I2STXCOM &= ~1;
|
||||
}
|
||||
|
||||
void pcm_play_dma_init(void)
|
||||
{
|
||||
PWRCON(0) &= ~(1 << 4);
|
||||
PWRCON(1) &= ~(1 << 7);
|
||||
I2S40 = 0x110;
|
||||
I2STXCON = 0xb100059;
|
||||
I2SCLKCON = 1;
|
||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||
|
||||
audiohw_preinit();
|
||||
}
|
||||
|
||||
void pcm_play_dma_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
}
|
||||
|
||||
void pcm_dma_apply_settings(void)
|
||||
{
|
||||
}
|
||||
|
||||
size_t pcm_get_bytes_waiting(void)
|
||||
{
|
||||
int bytes = pcm_remaining;
|
||||
const struct dma_lli* lli = (const struct dma_lli*)((int)&DMAC0C0LLI);
|
||||
while (lli)
|
||||
{
|
||||
bytes += (lli->control & 0xfff) * 2;
|
||||
if (lli == lastlli) break;
|
||||
lli = lli->nextlli;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
const void* pcm_play_dma_get_peak_buffer(int *count)
|
||||
{
|
||||
*count = (DMAC0C0LLI.control & 0xfff) * 2;
|
||||
return (void*)(((uint32_t)DMAC0C0LLI.srcaddr) & ~3);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PCM_DMA_ADDRESS
|
||||
void * pcm_dma_addr(void *addr)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Recording DMA transfer
|
||||
**/
|
||||
#ifdef HAVE_RECORDING
|
||||
void pcm_rec_lock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_unlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_dma_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_dma_start(void *addr, size_t size)
|
||||
{
|
||||
(void)addr;
|
||||
(void)size;
|
||||
}
|
||||
|
||||
void pcm_rec_dma_close(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void pcm_rec_dma_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const void * pcm_rec_dma_get_peak_buffer(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_RECORDING */
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: pcm-s5l8700.c 28600 2010-11-14 19:49:20Z Buschel $
|
||||
*
|
||||
* Copyright © 2011 Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "audio.h"
|
||||
#include "s5l8702.h"
|
||||
#include "panic.h"
|
||||
#include "audiohw.h"
|
||||
#include "pcm.h"
|
||||
#include "pcm-internal.h"
|
||||
#include "pcm_sampr.h"
|
||||
#include "mmu-arm.h"
|
||||
#include "pcm-target.h"
|
||||
|
||||
static volatile int locked = 0;
|
||||
static const int zerosample = 0;
|
||||
static unsigned char dblbuf[2][PCM_WATERMARK * 4];
|
||||
static int active_dblbuf;
|
||||
struct dma_lli pcm_lli[PCM_LLICOUNT] __attribute__((aligned(16)));
|
||||
static struct dma_lli* lastlli;
|
||||
static const unsigned char* dataptr;
|
||||
size_t pcm_remaining;
|
||||
size_t pcm_chunksize;
|
||||
|
||||
/* Mask the DMA interrupt */
|
||||
void pcm_play_lock(void)
|
||||
{
|
||||
if (locked++ == 0) {
|
||||
//TODO: Urgh, I don't like that at all...
|
||||
VIC0INTENCLEAR = 1 << IRQ_DMAC0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unmask the DMA interrupt if enabled */
|
||||
void pcm_play_unlock(void)
|
||||
{
|
||||
if (--locked == 0) {
|
||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||
}
|
||||
}
|
||||
|
||||
void INT_DMAC0C0(void) ICODE_ATTR;
|
||||
void INT_DMAC0C0(void)
|
||||
{
|
||||
DMAC0INTTCCLR = 1;
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
pcm_play_get_more_callback((void**)&dataptr, &pcm_remaining);
|
||||
pcm_chunksize = pcm_remaining;
|
||||
}
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
pcm_lli->nextlli = NULL;
|
||||
pcm_lli->control = 0x75249000;
|
||||
clean_dcache();
|
||||
return;
|
||||
}
|
||||
uint32_t lastsize = MIN(PCM_WATERMARK * 4, pcm_remaining / 2 + 1) & ~1;
|
||||
pcm_remaining -= lastsize;
|
||||
if (pcm_remaining) lastlli = &pcm_lli[ARRAYLEN(pcm_lli) - 1];
|
||||
else lastlli = pcm_lli;
|
||||
uint32_t chunksize = MIN(PCM_CHUNKSIZE * 4 - lastsize, pcm_remaining);
|
||||
if (pcm_remaining > chunksize && chunksize > pcm_remaining - PCM_WATERMARK * 8)
|
||||
chunksize = pcm_remaining - PCM_WATERMARK * 8;
|
||||
pcm_remaining -= chunksize;
|
||||
bool last = !chunksize;
|
||||
int i = 0;
|
||||
while (chunksize)
|
||||
{
|
||||
uint32_t thislli = MIN(PCM_LLIMAX * 4, chunksize);
|
||||
chunksize -= thislli;
|
||||
pcm_lli[i].srcaddr = (void*)dataptr;
|
||||
pcm_lli[i].dstaddr = (void*)((int)&I2STXDB0);
|
||||
pcm_lli[i].nextlli = chunksize ? &pcm_lli[i + 1] : lastlli;
|
||||
pcm_lli[i].control = (chunksize ? 0x75249000 : 0xf5249000) | (thislli / 2);
|
||||
dataptr += thislli;
|
||||
i++;
|
||||
}
|
||||
if (!pcm_remaining)
|
||||
{
|
||||
memcpy(dblbuf[active_dblbuf], dataptr, lastsize);
|
||||
lastlli->srcaddr = dblbuf[active_dblbuf];
|
||||
active_dblbuf ^= 1;
|
||||
}
|
||||
else lastlli->srcaddr = dataptr;
|
||||
lastlli->dstaddr = (void*)((int)&I2STXDB0);
|
||||
lastlli->nextlli = last ? NULL : pcm_lli;
|
||||
lastlli->control = (last ? 0xf5249000 : 0x75249000) | (lastsize / 2);
|
||||
dataptr += lastsize;
|
||||
clean_dcache();
|
||||
if (!(DMAC0C0CONFIG & 1) && (pcm_lli[0].control & 0xfff))
|
||||
{
|
||||
DMAC0C0LLI = pcm_lli[0];
|
||||
DMAC0C0CONFIG = 0x8a81;
|
||||
}
|
||||
else DMAC0C0NEXTLLI = pcm_lli;
|
||||
|
||||
pcm_play_dma_started_callback();
|
||||
}
|
||||
|
||||
void pcm_play_dma_start(const void* addr, size_t size)
|
||||
{
|
||||
dataptr = (const unsigned char*)addr;
|
||||
pcm_remaining = size;
|
||||
I2STXCOM = 0xe;
|
||||
DMAC0CONFIG |= 4;
|
||||
INT_DMAC0C0();
|
||||
}
|
||||
|
||||
void pcm_play_dma_stop(void)
|
||||
{
|
||||
DMAC0C0CONFIG = 0x8a80;
|
||||
I2STXCOM = 0xa;
|
||||
}
|
||||
|
||||
/* pause playback by disabling LRCK */
|
||||
void pcm_play_dma_pause(bool pause)
|
||||
{
|
||||
if (pause) I2STXCOM |= 1;
|
||||
else I2STXCOM &= ~1;
|
||||
}
|
||||
|
||||
void pcm_play_dma_init(void)
|
||||
{
|
||||
PWRCON(0) &= ~(1 << 4);
|
||||
PWRCON(1) &= ~(1 << 7);
|
||||
I2S40 = 0x110;
|
||||
I2STXCON = 0xb100059;
|
||||
I2SCLKCON = 1;
|
||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||
|
||||
audiohw_preinit();
|
||||
}
|
||||
|
||||
void pcm_play_dma_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
}
|
||||
|
||||
void pcm_dma_apply_settings(void)
|
||||
{
|
||||
}
|
||||
|
||||
size_t pcm_get_bytes_waiting(void)
|
||||
{
|
||||
int bytes = pcm_remaining;
|
||||
const struct dma_lli* lli = (const struct dma_lli*)((int)&DMAC0C0LLI);
|
||||
while (lli)
|
||||
{
|
||||
bytes += (lli->control & 0xfff) * 2;
|
||||
if (lli == lastlli) break;
|
||||
lli = lli->nextlli;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
const void* pcm_play_dma_get_peak_buffer(int *count)
|
||||
{
|
||||
*count = (DMAC0C0LLI.control & 0xfff) * 2;
|
||||
return (void*)(((uint32_t)DMAC0C0LLI.srcaddr) & ~3);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PCM_DMA_ADDRESS
|
||||
void * pcm_dma_addr(void *addr)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Recording DMA transfer
|
||||
**/
|
||||
#ifdef HAVE_RECORDING
|
||||
void pcm_rec_lock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_unlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_dma_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pcm_rec_dma_start(void *addr, size_t size)
|
||||
{
|
||||
(void)addr;
|
||||
(void)size;
|
||||
}
|
||||
|
||||
void pcm_rec_dma_close(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void pcm_rec_dma_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const void * pcm_rec_dma_get_peak_buffer(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_RECORDING */
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||
*
|
||||
* Copyright (C) 2010 by Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __PCM_TARGET_H__
|
||||
#define __PCM_TARGET_H__
|
||||
|
||||
|
||||
/* S5L8702 PCM driver tunables: */
|
||||
#define PCM_LLIMAX (2047) /* Maximum number of samples per LLI */
|
||||
#define PCM_CHUNKSIZE (10747) /* Maximum number of samples to handle with one IRQ */
|
||||
/* (bigger chunks will be segmented internally) */
|
||||
#define PCM_WATERMARK (512) /* Number of remaining samples to schedule IRQ at */
|
||||
|
||||
|
||||
#define PCM_LLICOUNT ((PCM_CHUNKSIZE - PCM_WATERMARK + PCM_LLIMAX - 1) / PCM_LLIMAX + 1)
|
||||
|
||||
|
||||
extern struct dma_lli pcm_lli[PCM_LLICOUNT];
|
||||
extern size_t pcm_remaining;
|
||||
extern size_t pcm_chunksize;
|
||||
|
||||
|
||||
#endif /* __PCM_TARGET_H__ */
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||
*
|
||||
* Copyright (C) 2010 by Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __PCM_TARGET_H__
|
||||
#define __PCM_TARGET_H__
|
||||
|
||||
|
||||
/* S5L8702 PCM driver tunables: */
|
||||
#define PCM_LLIMAX (2047) /* Maximum number of samples per LLI */
|
||||
#define PCM_CHUNKSIZE (10747) /* Maximum number of samples to handle with one IRQ */
|
||||
/* (bigger chunks will be segmented internally) */
|
||||
#define PCM_WATERMARK (512) /* Number of remaining samples to schedule IRQ at */
|
||||
|
||||
|
||||
#define PCM_LLICOUNT ((PCM_CHUNKSIZE - PCM_WATERMARK + PCM_LLIMAX - 1) / PCM_LLIMAX + 1)
|
||||
|
||||
|
||||
extern struct dma_lli pcm_lli[PCM_LLICOUNT];
|
||||
extern size_t pcm_remaining;
|
||||
extern size_t pcm_chunksize;
|
||||
|
||||
|
||||
#endif /* __PCM_TARGET_H__ */
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||
*
|
||||
* Copyright (C) 2007 by Dave Chapman
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef SYSTEM_TARGET_H
|
||||
#define SYSTEM_TARGET_H
|
||||
|
||||
#include "system-arm.h"
|
||||
#include "mmu-arm.h"
|
||||
|
||||
#define CPUFREQ_SLEEP 32768
|
||||
#define CPUFREQ_MAX 216000000
|
||||
#define CPUFREQ_DEFAULT 108000000
|
||||
#define CPUFREQ_NORMAL 108000000
|
||||
|
||||
#define STORAGE_WANTS_ALIGN
|
||||
|
||||
#define inl(a) (*(volatile unsigned long *) (a))
|
||||
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
||||
#define inb(a) (*(volatile unsigned char *) (a))
|
||||
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
||||
#define inw(a) (*(volatile unsigned short*) (a))
|
||||
#define outw(a,b) (*(volatile unsigned short*) (b) = (a))
|
||||
|
||||
static inline void udelay(unsigned usecs)
|
||||
{
|
||||
unsigned stop = USEC_TIMER + usecs;
|
||||
while (TIME_BEFORE(USEC_TIMER, stop));
|
||||
}
|
||||
|
||||
#endif /* SYSTEM_TARGET_H */
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||
*
|
||||
* Copyright (C) 2007 by Dave Chapman
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef SYSTEM_TARGET_H
|
||||
#define SYSTEM_TARGET_H
|
||||
|
||||
#include "system-arm.h"
|
||||
#include "mmu-arm.h"
|
||||
|
||||
#define CPUFREQ_SLEEP 32768
|
||||
#define CPUFREQ_MAX 216000000
|
||||
#define CPUFREQ_DEFAULT 108000000
|
||||
#define CPUFREQ_NORMAL 108000000
|
||||
|
||||
#define STORAGE_WANTS_ALIGN
|
||||
|
||||
#define inl(a) (*(volatile unsigned long *) (a))
|
||||
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
||||
#define inb(a) (*(volatile unsigned char *) (a))
|
||||
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
||||
#define inw(a) (*(volatile unsigned short*) (a))
|
||||
#define outw(a,b) (*(volatile unsigned short*) (b) = (a))
|
||||
|
||||
static inline void udelay(unsigned usecs)
|
||||
{
|
||||
unsigned stop = USEC_TIMER + usecs;
|
||||
while (TIME_BEFORE(USEC_TIMER, stop));
|
||||
}
|
||||
|
||||
#endif /* SYSTEM_TARGET_H */
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: timer-s5l8700.c 23103 2009-10-11 11:35:14Z theseven $
|
||||
*
|
||||
* Copyright (C) 2009 Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "inttypes.h"
|
||||
#include "s5l8702.h"
|
||||
#include "system.h"
|
||||
#include "timer.h"
|
||||
|
||||
//TODO: This needs calibration once we figure out the clocking
|
||||
|
||||
void INT_TIMERC(void)
|
||||
{
|
||||
/* clear interrupt */
|
||||
TCCON = TCCON;
|
||||
|
||||
if (pfn_timer != NULL) {
|
||||
pfn_timer();
|
||||
}
|
||||
}
|
||||
|
||||
bool timer_set(long cycles, bool start)
|
||||
{
|
||||
static const int cs_table[] = {1, 2, 4, 6};
|
||||
int prescale, cs;
|
||||
long count;
|
||||
|
||||
/* stop and clear timer */
|
||||
TCCMD = (1 << 1); /* TD_CLR */
|
||||
|
||||
/* optionally unregister any previously registered timer user */
|
||||
if (start) {
|
||||
if (pfn_unregister != NULL) {
|
||||
pfn_unregister();
|
||||
pfn_unregister = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* scale the count down with the clock select */
|
||||
for (cs = 0; cs < 4; cs++) {
|
||||
count = cycles >> cs_table[cs];
|
||||
if ((count < 65536) || (cs == 3)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* scale the count down with the prescaler */
|
||||
prescale = 1;
|
||||
while (count >= 65536) {
|
||||
count >>= 1;
|
||||
prescale <<= 1;
|
||||
}
|
||||
|
||||
/* configure timer */
|
||||
TCCON = (1 << 12) | /* TD_INT0_EN */
|
||||
(cs << 8) | /* TS_CS */
|
||||
(0 << 4); /* TD_MODE_SEL, 0 = interval mode */
|
||||
TCPRE = prescale - 1;
|
||||
TCDATA0 = count;
|
||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool timer_start(void)
|
||||
{
|
||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||
return true;
|
||||
}
|
||||
|
||||
void timer_stop(void)
|
||||
{
|
||||
TCCMD = (0 << 0); /* TD_ENABLE */
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: timer-s5l8700.c 23103 2009-10-11 11:35:14Z theseven $
|
||||
*
|
||||
* Copyright (C) 2009 Bertrik Sikken
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "inttypes.h"
|
||||
#include "s5l8702.h"
|
||||
#include "system.h"
|
||||
#include "timer.h"
|
||||
|
||||
//TODO: This needs calibration once we figure out the clocking
|
||||
|
||||
void INT_TIMERC(void)
|
||||
{
|
||||
/* clear interrupt */
|
||||
TCCON = TCCON;
|
||||
|
||||
if (pfn_timer != NULL) {
|
||||
pfn_timer();
|
||||
}
|
||||
}
|
||||
|
||||
bool timer_set(long cycles, bool start)
|
||||
{
|
||||
static const int cs_table[] = {1, 2, 4, 6};
|
||||
int prescale, cs;
|
||||
long count;
|
||||
|
||||
/* stop and clear timer */
|
||||
TCCMD = (1 << 1); /* TD_CLR */
|
||||
|
||||
/* optionally unregister any previously registered timer user */
|
||||
if (start) {
|
||||
if (pfn_unregister != NULL) {
|
||||
pfn_unregister();
|
||||
pfn_unregister = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* scale the count down with the clock select */
|
||||
for (cs = 0; cs < 4; cs++) {
|
||||
count = cycles >> cs_table[cs];
|
||||
if ((count < 65536) || (cs == 3)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* scale the count down with the prescaler */
|
||||
prescale = 1;
|
||||
while (count >= 65536) {
|
||||
count >>= 1;
|
||||
prescale <<= 1;
|
||||
}
|
||||
|
||||
/* configure timer */
|
||||
TCCON = (1 << 12) | /* TD_INT0_EN */
|
||||
(cs << 8) | /* TS_CS */
|
||||
(0 << 4); /* TD_MODE_SEL, 0 = interval mode */
|
||||
TCPRE = prescale - 1;
|
||||
TCDATA0 = count;
|
||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool timer_start(void)
|
||||
{
|
||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||
return true;
|
||||
}
|
||||
|
||||
void timer_stop(void)
|
||||
{
|
||||
TCCMD = (0 << 0); /* TD_ENABLE */
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: mas.c 18807 2008-10-14 11:12:20Z zagor $
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||
*
|
||||
|
|
|
@ -1 +1 @@
|
|||
1 24 MOVEABLE PURE "e200rpatcher.manifest"
|
||||
1 24 MOVEABLE PURE "e200rpatcher.manifest"
|
||||
|
|
|
@ -1 +1 @@
|
|||
1 24 MOVEABLE PURE "ipodpatcher.manifest"
|
||||
1 24 MOVEABLE PURE "ipodpatcher.manifest"
|
||||
|
|
|
@ -1 +1 @@
|
|||
1 24 MOVEABLE PURE "sansapatcher.manifest"
|
||||
1 24 MOVEABLE PURE "sansapatcher.manifest"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
tcctool for Windows
|
||||
-------------------
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
When you first attach your device in USB boot mode to your computer,
|
||||
Windows should display the Found New Hardware Wizard.
|
||||
|
||||
If this doesn't appear, and if you have previously used a firmware
|
||||
recovery tool with your device, you will need to uninstall the USB
|
||||
driver used by that application.
|
||||
|
||||
Go into Control Panel -> System -> Hardware -> Device Manager, then
|
||||
click on Universal Serial Bus Controllers, look for something like
|
||||
"Telechips TCC77x VTC USB Driver", right-click on it and select
|
||||
Uninstall.
|
||||
|
||||
After doing this, disconnect and reconnect your device and the Found
|
||||
New Hardware Wizard should appear.
|
||||
|
||||
Select "No, not this time" to the question about connecting to Windows
|
||||
Update, and select "Install from a list or specific location
|
||||
(Advanced)" on the next screen.
|
||||
|
||||
On the next screen, select "Search for the best driver in these
|
||||
locations", unselect "Search removable media", select "Include this
|
||||
location in the search:" and browse to the tcctool-driver-win32
|
||||
folder.
|
||||
|
||||
You should now be able to run tcctool.exe
|
||||
tcctool for Windows
|
||||
-------------------
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
When you first attach your device in USB boot mode to your computer,
|
||||
Windows should display the Found New Hardware Wizard.
|
||||
|
||||
If this doesn't appear, and if you have previously used a firmware
|
||||
recovery tool with your device, you will need to uninstall the USB
|
||||
driver used by that application.
|
||||
|
||||
Go into Control Panel -> System -> Hardware -> Device Manager, then
|
||||
click on Universal Serial Bus Controllers, look for something like
|
||||
"Telechips TCC77x VTC USB Driver", right-click on it and select
|
||||
Uninstall.
|
||||
|
||||
After doing this, disconnect and reconnect your device and the Found
|
||||
New Hardware Wizard should appear.
|
||||
|
||||
Select "No, not this time" to the question about connecting to Windows
|
||||
Update, and select "Install from a list or specific location
|
||||
(Advanced)" on the next screen.
|
||||
|
||||
On the next screen, select "Search for the best driver in these
|
||||
locations", unselect "Search removable media", select "Include this
|
||||
location in the search:" and browse to the tcctool-driver-win32
|
||||
folder.
|
||||
|
||||
You should now be able to run tcctool.exe
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
|
||||
* See COPYING file that comes with this distribution
|
||||
*/
|
||||
|
||||
#ifndef FINDREPLACE_GLOBAL_H
|
||||
#define FINDREPLACE_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef FINDREPLACE_NOLIB
|
||||
#if defined(FINDREPLACE_LIBRARY)
|
||||
# define FINDREPLACESHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define FINDREPLACESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define FINDREPLACESHARED_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // FINDREPLACE_GLOBAL_H
|
||||
/*
|
||||
* Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
|
||||
* See COPYING file that comes with this distribution
|
||||
*/
|
||||
|
||||
#ifndef FINDREPLACE_GLOBAL_H
|
||||
#define FINDREPLACE_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef FINDREPLACE_NOLIB
|
||||
#if defined(FINDREPLACE_LIBRARY)
|
||||
# define FINDREPLACESHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define FINDREPLACESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define FINDREPLACESHARED_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // FINDREPLACE_GLOBAL_H
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindReplaceDialog</class>
|
||||
<widget class="QDialog" name="FindReplaceDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>342</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Find/Replace</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FindReplaceForm</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">findreplaceform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindReplaceDialog</class>
|
||||
<widget class="QDialog" name="FindReplaceDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>342</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Find/Replace</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FindReplaceForm</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">findreplaceform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -1,204 +1,204 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindReplaceForm</class>
|
||||
<widget class="QWidget" name="FindReplaceForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<height>288</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Find:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>textToFind</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="textToFind"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="replaceLabel">
|
||||
<property name="text">
|
||||
<string>R&eplace with:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>textToReplace</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="textToReplace"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="text">
|
||||
<string>errorLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>D&irection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="downRadioButton">
|
||||
<property name="text">
|
||||
<string>&Down</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="upRadioButton">
|
||||
<property name="text">
|
||||
<string>&Up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>&Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="caseCheckBox">
|
||||
<property name="text">
|
||||
<string>&Case sensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="wholeCheckBox">
|
||||
<property name="text">
|
||||
<string>&Whole words only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="regexCheckBox">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">whether the text to search should be interpreted as a regular expression.</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You may want to take a look at the syntax of regular expressions:</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://doc.trolltech.com/qregexp.html"><span style=" text-decoration: underline; color:#0000ff;">http://doc.trolltech.com/qregexp.html</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R&egular Expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="findButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="replaceButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Replace</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="replaceAllButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Replace &All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>textToFind</tabstop>
|
||||
<tabstop>textToReplace</tabstop>
|
||||
<tabstop>downRadioButton</tabstop>
|
||||
<tabstop>upRadioButton</tabstop>
|
||||
<tabstop>caseCheckBox</tabstop>
|
||||
<tabstop>wholeCheckBox</tabstop>
|
||||
<tabstop>regexCheckBox</tabstop>
|
||||
<tabstop>findButton</tabstop>
|
||||
<tabstop>closeButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindReplaceForm</class>
|
||||
<widget class="QWidget" name="FindReplaceForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<height>288</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Find:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>textToFind</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="textToFind"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="replaceLabel">
|
||||
<property name="text">
|
||||
<string>R&eplace with:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>textToReplace</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="textToReplace"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="text">
|
||||
<string>errorLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>D&irection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="downRadioButton">
|
||||
<property name="text">
|
||||
<string>&Down</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="upRadioButton">
|
||||
<property name="text">
|
||||
<string>&Up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>&Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="caseCheckBox">
|
||||
<property name="text">
|
||||
<string>&Case sensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="wholeCheckBox">
|
||||
<property name="text">
|
||||
<string>&Whole words only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="regexCheckBox">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">whether the text to search should be interpreted as a regular expression.</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You may want to take a look at the syntax of regular expressions:</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://doc.trolltech.com/qregexp.html"><span style=" text-decoration: underline; color:#0000ff;">http://doc.trolltech.com/qregexp.html</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R&egular Expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="findButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="replaceButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Replace</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="replaceAllButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Replace &All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>textToFind</tabstop>
|
||||
<tabstop>textToReplace</tabstop>
|
||||
<tabstop>downRadioButton</tabstop>
|
||||
<tabstop>upRadioButton</tabstop>
|
||||
<tabstop>caseCheckBox</tabstop>
|
||||
<tabstop>wholeCheckBox</tabstop>
|
||||
<tabstop>regexCheckBox</tabstop>
|
||||
<tabstop>findButton</tabstop>
|
||||
<tabstop>closeButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -1 +1 @@
|
|||
EDITOR_ICON ICON DISCARDABLE "resources/windowicon.ico"
|
||||
EDITOR_ICON ICON DISCARDABLE "resources/windowicon.ico"
|
||||
|
|
Loading…
Reference in New Issue