forked from len0rd/rockbox
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
59 changed files with 24428 additions and 24428 deletions
|
@ -1,20 +1,20 @@
|
||||||
/* YM2413 tone by okazaki@angel.ne.jp */
|
/* YM2413 tone by okazaki@angel.ne.jp */
|
||||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,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,
|
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,
|
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,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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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
|
0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* YMF281B tone by Chabin */
|
/* YMF281B tone by Chabin */
|
||||||
0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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
|
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.
|
// Library configuration. Modify this file as necessary.
|
||||||
|
|
||||||
#ifndef BLARGG_CONFIG_H
|
#ifndef BLARGG_CONFIG_H
|
||||||
#define BLARGG_CONFIG_H
|
#define BLARGG_CONFIG_H
|
||||||
|
|
||||||
// Uncomment to enable platform-specific optimizations
|
// Uncomment to enable platform-specific optimizations
|
||||||
//#define BLARGG_NONPORTABLE 1
|
//#define BLARGG_NONPORTABLE 1
|
||||||
|
|
||||||
// Uncomment if automatic byte-order determination doesn't work
|
// Uncomment if automatic byte-order determination doesn't work
|
||||||
#ifdef ROCKBOX_BIG_ENDIAN
|
#ifdef ROCKBOX_BIG_ENDIAN
|
||||||
#define BLARGG_BIG_ENDIAN 1
|
#define BLARGG_BIG_ENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Uncomment if you get errors in the bool section of blargg_common.h
|
// Uncomment if you get errors in the bool section of blargg_common.h
|
||||||
#define BLARGG_COMPILER_HAS_BOOL 1
|
#define BLARGG_COMPILER_HAS_BOOL 1
|
||||||
|
|
||||||
// Uncomment to use fast gb apu implementation
|
// Uncomment to use fast gb apu implementation
|
||||||
// #define GB_APU_FAST 1
|
// #define GB_APU_FAST 1
|
||||||
|
|
||||||
// Uncomment to remove agb emulation support
|
// Uncomment to remove agb emulation support
|
||||||
// #define GB_APU_NO_AGB 1
|
// #define GB_APU_NO_AGB 1
|
||||||
|
|
||||||
// Uncomment to emulate only nes apu
|
// Uncomment to emulate only nes apu
|
||||||
// #define NSF_EMU_APU_ONLY 1
|
// #define NSF_EMU_APU_ONLY 1
|
||||||
|
|
||||||
// Uncomment to remove vrc7 apu support
|
// Uncomment to remove vrc7 apu support
|
||||||
// #define NSF_EMU_NO_VRC7 1
|
// #define NSF_EMU_NO_VRC7 1
|
||||||
|
|
||||||
// Uncomment to remove fmopl apu support
|
// Uncomment to remove fmopl apu support
|
||||||
// #define KSS_EMU_NO_FMOPL 1
|
// #define KSS_EMU_NO_FMOPL 1
|
||||||
|
|
||||||
// To handle undefined reference to assert
|
// To handle undefined reference to assert
|
||||||
#define NDEBUG 1
|
#define NDEBUG 1
|
||||||
|
|
||||||
// Use standard config.h if present
|
// Use standard config.h if present
|
||||||
#define HAVE_CONFIG_H 1
|
#define HAVE_CONFIG_H 1
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,164 +1,164 @@
|
||||||
#ifndef _EMU2413_H_
|
#ifndef _EMU2413_H_
|
||||||
#define _EMU2413_H_
|
#define _EMU2413_H_
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
#include "emutypes.h"
|
#include "emutypes.h"
|
||||||
|
|
||||||
#ifdef EMU2413_DLL_EXPORTS
|
#ifdef EMU2413_DLL_EXPORTS
|
||||||
#define EMU2413_API __declspec(dllexport)
|
#define EMU2413_API __declspec(dllexport)
|
||||||
#elif defined(EMU2413_DLL_IMPORTS)
|
#elif defined(EMU2413_DLL_IMPORTS)
|
||||||
#define EMU2413_API __declspec(dllimport)
|
#define EMU2413_API __declspec(dllimport)
|
||||||
#else
|
#else
|
||||||
#define EMU2413_API
|
#define EMU2413_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AUDIO_MONO_BUFFER_SIZE 1024
|
#define AUDIO_MONO_BUFFER_SIZE 1024
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
#define PI 3.14159265358979323846
|
||||||
|
|
||||||
enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ;
|
enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ;
|
||||||
|
|
||||||
/* voice data */
|
/* voice data */
|
||||||
typedef struct __OPLL_PATCH {
|
typedef struct __OPLL_PATCH {
|
||||||
e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
|
e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ;
|
||||||
} OPLL_PATCH ;
|
} OPLL_PATCH ;
|
||||||
|
|
||||||
/* slot */
|
/* slot */
|
||||||
typedef struct __OPLL_SLOT {
|
typedef struct __OPLL_SLOT {
|
||||||
|
|
||||||
OPLL_PATCH *patch;
|
OPLL_PATCH *patch;
|
||||||
|
|
||||||
e_int32 type ; /* 0 : modulator 1 : carrier */
|
e_int32 type ; /* 0 : modulator 1 : carrier */
|
||||||
|
|
||||||
/* OUTPUT */
|
/* OUTPUT */
|
||||||
e_int32 feedback ;
|
e_int32 feedback ;
|
||||||
e_int32 output[2] ; /* Output value of slot */
|
e_int32 output[2] ; /* Output value of slot */
|
||||||
|
|
||||||
/* for Phase Generator (PG) */
|
/* for Phase Generator (PG) */
|
||||||
e_uint16 *sintbl ; /* Wavetable */
|
e_uint16 *sintbl ; /* Wavetable */
|
||||||
e_uint32 phase ; /* Phase */
|
e_uint32 phase ; /* Phase */
|
||||||
e_uint32 dphase ; /* Phase increment amount */
|
e_uint32 dphase ; /* Phase increment amount */
|
||||||
e_uint32 pgout ; /* output */
|
e_uint32 pgout ; /* output */
|
||||||
|
|
||||||
/* for Envelope Generator (EG) */
|
/* for Envelope Generator (EG) */
|
||||||
e_int32 fnum ; /* F-Number */
|
e_int32 fnum ; /* F-Number */
|
||||||
e_int32 block ; /* Block */
|
e_int32 block ; /* Block */
|
||||||
e_int32 volume ; /* Current volume */
|
e_int32 volume ; /* Current volume */
|
||||||
e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */
|
e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */
|
||||||
e_uint32 tll ; /* Total Level + Key scale level*/
|
e_uint32 tll ; /* Total Level + Key scale level*/
|
||||||
e_uint32 rks ; /* Key scale offset (Rks) */
|
e_uint32 rks ; /* Key scale offset (Rks) */
|
||||||
e_int32 eg_mode ; /* Current state */
|
e_int32 eg_mode ; /* Current state */
|
||||||
e_uint32 eg_phase ; /* Phase */
|
e_uint32 eg_phase ; /* Phase */
|
||||||
e_uint32 eg_dphase ; /* Phase increment amount */
|
e_uint32 eg_dphase ; /* Phase increment amount */
|
||||||
e_uint32 egout ; /* output */
|
e_uint32 egout ; /* output */
|
||||||
|
|
||||||
} OPLL_SLOT ;
|
} OPLL_SLOT ;
|
||||||
|
|
||||||
/* Mask */
|
/* Mask */
|
||||||
#define OPLL_MASK_CH(x) (1<<(x))
|
#define OPLL_MASK_CH(x) (1<<(x))
|
||||||
#define OPLL_MASK_HH (1<<(9))
|
#define OPLL_MASK_HH (1<<(9))
|
||||||
#define OPLL_MASK_CYM (1<<(10))
|
#define OPLL_MASK_CYM (1<<(10))
|
||||||
#define OPLL_MASK_TOM (1<<(11))
|
#define OPLL_MASK_TOM (1<<(11))
|
||||||
#define OPLL_MASK_SD (1<<(12))
|
#define OPLL_MASK_SD (1<<(12))
|
||||||
#define OPLL_MASK_BD (1<<(13))
|
#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 )
|
#define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD )
|
||||||
|
|
||||||
/* opll */
|
/* opll */
|
||||||
typedef struct __OPLL {
|
typedef struct __OPLL {
|
||||||
|
|
||||||
e_uint32 adr ;
|
e_uint32 adr ;
|
||||||
e_int32 out ;
|
e_int32 out ;
|
||||||
|
|
||||||
#ifndef EMU2413_COMPACTION
|
#ifndef EMU2413_COMPACTION
|
||||||
e_uint32 realstep ;
|
e_uint32 realstep ;
|
||||||
e_uint32 oplltime ;
|
e_uint32 oplltime ;
|
||||||
e_uint32 opllstep ;
|
e_uint32 opllstep ;
|
||||||
e_int32 prev, next ;
|
e_int32 prev, next ;
|
||||||
e_int32 sprev[2],snext[2];
|
e_int32 sprev[2],snext[2];
|
||||||
e_uint32 pan[16];
|
e_uint32 pan[16];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Register */
|
/* Register */
|
||||||
e_uint8 reg[0x40] ;
|
e_uint8 reg[0x40] ;
|
||||||
e_int32 slot_on_flag[18] ;
|
e_int32 slot_on_flag[18] ;
|
||||||
|
|
||||||
/* Pitch Modulator */
|
/* Pitch Modulator */
|
||||||
e_uint32 pm_phase ;
|
e_uint32 pm_phase ;
|
||||||
e_int32 lfo_pm ;
|
e_int32 lfo_pm ;
|
||||||
|
|
||||||
/* Amp Modulator */
|
/* Amp Modulator */
|
||||||
e_int32 am_phase ;
|
e_int32 am_phase ;
|
||||||
e_int32 lfo_am ;
|
e_int32 lfo_am ;
|
||||||
|
|
||||||
e_uint32 quality;
|
e_uint32 quality;
|
||||||
|
|
||||||
/* Noise Generator */
|
/* Noise Generator */
|
||||||
e_uint32 noise_seed ;
|
e_uint32 noise_seed ;
|
||||||
|
|
||||||
/* Channel Data */
|
/* Channel Data */
|
||||||
e_int32 patch_number[9];
|
e_int32 patch_number[9];
|
||||||
e_int32 key_status[9] ;
|
e_int32 key_status[9] ;
|
||||||
|
|
||||||
/* Slot */
|
/* Slot */
|
||||||
OPLL_SLOT slot[18] ;
|
OPLL_SLOT slot[18] ;
|
||||||
|
|
||||||
/* Voice Data */
|
/* Voice Data */
|
||||||
OPLL_PATCH patch[19*2] ;
|
OPLL_PATCH patch[19*2] ;
|
||||||
e_int32 patch_update[2] ; /* flag for check patch update */
|
e_int32 patch_update[2] ; /* flag for check patch update */
|
||||||
|
|
||||||
e_uint32 mask ;
|
e_uint32 mask ;
|
||||||
e_uint32 current_mask;
|
e_uint32 current_mask;
|
||||||
e_uint32 status;
|
e_uint32 status;
|
||||||
|
|
||||||
e_uint32 internal_mute;
|
e_uint32 internal_mute;
|
||||||
e_int16 buffer[AUDIO_MONO_BUFFER_SIZE];
|
e_int16 buffer[AUDIO_MONO_BUFFER_SIZE];
|
||||||
} OPLL ;
|
} OPLL ;
|
||||||
|
|
||||||
/* Create Object */
|
/* Create Object */
|
||||||
EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ;
|
EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ;
|
||||||
EMU2413_API void OPLL_delete(OPLL *) ;
|
EMU2413_API void OPLL_delete(OPLL *) ;
|
||||||
|
|
||||||
/* Setup */
|
/* Setup */
|
||||||
EMU2413_API void OPLL_reset(OPLL *) ;
|
EMU2413_API void OPLL_reset(OPLL *) ;
|
||||||
EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ;
|
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_rate(OPLL *opll, e_uint32 r) ;
|
||||||
EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ;
|
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_pan(OPLL *, e_uint32 ch, e_uint32 pan);
|
||||||
EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute);
|
EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute);
|
||||||
EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *);
|
EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *);
|
||||||
|
|
||||||
/* Port/Register access */
|
/* Port/Register access */
|
||||||
EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val);
|
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 void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val);
|
||||||
EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port);
|
EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port);
|
||||||
|
|
||||||
/* Synthsize */
|
/* Synthsize */
|
||||||
EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE;
|
EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE;
|
||||||
EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ;
|
EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ;
|
||||||
EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ;
|
EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ;
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ;
|
EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ;
|
||||||
EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ;
|
EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ;
|
||||||
EMU2413_API void OPLL_forceRefresh(OPLL *) ;
|
EMU2413_API void OPLL_forceRefresh(OPLL *) ;
|
||||||
/* Utility */
|
/* Utility */
|
||||||
EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ;
|
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_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ;
|
||||||
EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ;
|
EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ;
|
||||||
|
|
||||||
/* Channel Mask */
|
/* Channel Mask */
|
||||||
EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
|
EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ;
|
||||||
EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
|
EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ;
|
||||||
|
|
||||||
#define dump2patch OPLL_dump2patch
|
#define dump2patch OPLL_dump2patch
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,210 +1,210 @@
|
||||||
#ifndef _EMUTABLES_H_
|
#ifndef _EMUTABLES_H_
|
||||||
#define _EMUTABLES_H_
|
#define _EMUTABLES_H_
|
||||||
|
|
||||||
/* Precalculated emu2413 tables for use in Rockbox,
|
/* Precalculated emu2413 tables for use in Rockbox,
|
||||||
Calculated for 44Khz sampling rate */
|
Calculated for 44Khz sampling rate */
|
||||||
|
|
||||||
#include "emutypes.h"
|
#include "emutypes.h"
|
||||||
|
|
||||||
static const e_uint16 sin_coeff[] = {
|
static const e_uint16 sin_coeff[] = {
|
||||||
255, 203, 171, 152, 139, 129, 120,
|
255, 203, 171, 152, 139, 129, 120,
|
||||||
113, 107, 102, 97, 92, 88, 85,
|
113, 107, 102, 97, 92, 88, 85,
|
||||||
81, 78, 75, 72, 70, 67, 65,
|
81, 78, 75, 72, 70, 67, 65,
|
||||||
63, 61, 59, 57, 55, 53, 52,
|
63, 61, 59, 57, 55, 53, 52,
|
||||||
50, 48, 47, 45, 44, 43, 41,
|
50, 48, 47, 45, 44, 43, 41,
|
||||||
40, 39, 38, 37, 35, 34, 33,
|
40, 39, 38, 37, 35, 34, 33,
|
||||||
32, 31, 30, 29, 28, 28, 27,
|
32, 31, 30, 29, 28, 28, 27,
|
||||||
26, 25, 24, 23, 23, 22, 21,
|
26, 25, 24, 23, 23, 22, 21,
|
||||||
21, 20, 19, 19, 18, 17, 17,
|
21, 20, 19, 19, 18, 17, 17,
|
||||||
16, 16, 15, 14, 14, 13, 13,
|
16, 16, 15, 14, 14, 13, 13,
|
||||||
12, 12, 11, 11, 11, 10, 10,
|
12, 12, 11, 11, 11, 10, 10,
|
||||||
9, 9, 8, 8, 8, 7, 7,
|
9, 9, 8, 8, 8, 7, 7,
|
||||||
7, 6, 6, 6, 5, 5, 5,
|
7, 6, 6, 6, 5, 5, 5,
|
||||||
4, 4, 4, 4, 3, 3, 3,
|
4, 4, 4, 4, 3, 3, 3,
|
||||||
3, 2, 2, 2, 2, 2, 2,
|
3, 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,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const e_int16 pm_coeff[] = {
|
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, 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,
|
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, 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,
|
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, 257, 257, 257, 257,
|
257, 257, 257, 257, 257, 257, 257,
|
||||||
257, 257, 257, 257, 257, 257, 256,
|
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,
|
||||||
256, 256, 256, 255, 255, 255, 255,
|
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, 254,
|
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, 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, 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, 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,
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const e_int8 am_coeff[] = {
|
static const e_int8 am_coeff[] = {
|
||||||
13, 13, 13, 13, 13, 14, 14,
|
13, 13, 13, 13, 13, 14, 14,
|
||||||
14, 14, 14, 15, 15, 15, 15,
|
14, 14, 14, 15, 15, 15, 15,
|
||||||
15, 16, 16, 16, 16, 16, 17,
|
15, 16, 16, 16, 16, 16, 17,
|
||||||
17, 17, 17, 17, 18, 18, 18,
|
17, 17, 17, 17, 18, 18, 18,
|
||||||
18, 18, 19, 19, 19, 19, 19,
|
18, 18, 19, 19, 19, 19, 19,
|
||||||
20, 20, 20, 20, 20, 21, 21,
|
20, 20, 20, 20, 20, 21, 21,
|
||||||
21, 21, 21, 22, 22, 22, 22,
|
21, 21, 21, 22, 22, 22, 22,
|
||||||
22, 23, 23, 23, 23, 23, 24,
|
22, 23, 23, 23, 23, 23, 24,
|
||||||
24, 24, 24, 24, 25, 25, 25,
|
24, 24, 24, 24, 25, 25, 25,
|
||||||
25, 26, 25, 25, 25, 25, 24,
|
25, 26, 25, 25, 25, 25, 24,
|
||||||
24, 24, 24, 24, 23, 23, 23,
|
24, 24, 24, 24, 23, 23, 23,
|
||||||
23, 23, 22, 22, 22, 22, 22,
|
23, 23, 22, 22, 22, 22, 22,
|
||||||
21, 21, 21, 21, 21, 20, 20,
|
21, 21, 21, 21, 21, 20, 20,
|
||||||
20, 20, 20, 19, 19, 19, 19,
|
20, 20, 20, 19, 19, 19, 19,
|
||||||
19, 18, 18, 18, 18, 18, 17,
|
19, 18, 18, 18, 18, 18, 17,
|
||||||
17, 17, 17, 17, 16, 16, 16,
|
17, 17, 17, 17, 16, 16, 16,
|
||||||
16, 16, 15, 15, 15, 15, 15,
|
16, 16, 15, 15, 15, 15, 15,
|
||||||
14, 14, 14, 14, 14, 13, 13,
|
14, 14, 14, 14, 14, 13, 13,
|
||||||
13, 13, 13, 12, 12, 12, 12,
|
13, 13, 13, 12, 12, 12, 12,
|
||||||
11, 11, 11, 11, 11, 10, 10,
|
11, 11, 11, 11, 11, 10, 10,
|
||||||
10, 10, 10, 9, 9, 9, 9,
|
10, 10, 10, 9, 9, 9, 9,
|
||||||
9, 8, 8, 8, 8, 8, 7,
|
9, 8, 8, 8, 8, 8, 7,
|
||||||
7, 7, 7, 7, 6, 6, 6,
|
7, 7, 7, 7, 6, 6, 6,
|
||||||
6, 6, 5, 5, 5, 5, 5,
|
6, 6, 5, 5, 5, 5, 5,
|
||||||
4, 4, 4, 4, 4, 3, 3,
|
4, 4, 4, 4, 4, 3, 3,
|
||||||
3, 3, 3, 2, 2, 2, 2,
|
3, 3, 3, 2, 2, 2, 2,
|
||||||
2, 1, 1, 1, 1, 1, 0,
|
2, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 1, 1, 1, 1, 1, 2,
|
0, 1, 1, 1, 1, 1, 2,
|
||||||
2, 2, 2, 2, 3, 3, 3,
|
2, 2, 2, 2, 3, 3, 3,
|
||||||
3, 3, 4, 4, 4, 4, 4,
|
3, 3, 4, 4, 4, 4, 4,
|
||||||
5, 5, 5, 5, 5, 6, 6,
|
5, 5, 5, 5, 5, 6, 6,
|
||||||
6, 6, 6, 7, 7, 7, 7,
|
6, 6, 6, 7, 7, 7, 7,
|
||||||
7, 8, 8, 8, 8, 8, 9,
|
7, 8, 8, 8, 8, 8, 9,
|
||||||
9, 9, 9, 9, 10, 10, 10,
|
9, 9, 9, 9, 10, 10, 10,
|
||||||
10, 10, 11, 11, 11, 11, 11,
|
10, 10, 11, 11, 11, 11, 11,
|
||||||
12, 12, 12, 12,
|
12, 12, 12, 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const e_int16 db2lin_coeff[] = {
|
static const e_int16 db2lin_coeff[] = {
|
||||||
255, 249, 244, 239, 233, 228, 224,
|
255, 249, 244, 239, 233, 228, 224,
|
||||||
219, 214, 209, 205, 201, 196, 192,
|
219, 214, 209, 205, 201, 196, 192,
|
||||||
188, 184, 180, 176, 172, 169, 165,
|
188, 184, 180, 176, 172, 169, 165,
|
||||||
162, 158, 155, 151, 148, 145, 142,
|
162, 158, 155, 151, 148, 145, 142,
|
||||||
139, 136, 133, 130, 127, 125, 122,
|
139, 136, 133, 130, 127, 125, 122,
|
||||||
119, 117, 114, 112, 109, 107, 105,
|
119, 117, 114, 112, 109, 107, 105,
|
||||||
102, 100, 98, 96, 94, 92, 90,
|
102, 100, 98, 96, 94, 92, 90,
|
||||||
88, 86, 84, 82, 81, 79, 77,
|
88, 86, 84, 82, 81, 79, 77,
|
||||||
76, 74, 72, 71, 69, 68, 66,
|
76, 74, 72, 71, 69, 68, 66,
|
||||||
65, 64, 62, 61, 60, 58, 57,
|
65, 64, 62, 61, 60, 58, 57,
|
||||||
56, 55, 53, 52, 51, 50, 49,
|
56, 55, 53, 52, 51, 50, 49,
|
||||||
48, 47, 46, 45, 44, 43, 42,
|
48, 47, 46, 45, 44, 43, 42,
|
||||||
41, 40, 39, 38, 38, 37, 36,
|
41, 40, 39, 38, 38, 37, 36,
|
||||||
35, 34, 34, 33, 32, 32, 31,
|
35, 34, 34, 33, 32, 32, 31,
|
||||||
30, 30, 29, 28, 28, 27, 27,
|
30, 30, 29, 28, 28, 27, 27,
|
||||||
26, 25, 25, 24, 24, 23, 23,
|
26, 25, 25, 24, 24, 23, 23,
|
||||||
22, 22, 21, 21, 20, 20, 19,
|
22, 22, 21, 21, 20, 20, 19,
|
||||||
19, 19, 18, 18, 17, 17, 17,
|
19, 19, 18, 18, 17, 17, 17,
|
||||||
16, 16, 16, 15, 15, 15, 14,
|
16, 16, 16, 15, 15, 15, 14,
|
||||||
14, 14, 13, 13, 13, 12, 12,
|
14, 14, 13, 13, 13, 12, 12,
|
||||||
12, 12, 11, 11, 11, 11, 10,
|
12, 12, 11, 11, 11, 11, 10,
|
||||||
10, 10, 10, 10, 9, 9, 9,
|
10, 10, 10, 10, 9, 9, 9,
|
||||||
9, 8, 8, 8, 8, 8, 8,
|
9, 8, 8, 8, 8, 8, 8,
|
||||||
7, 7, 7, 7, 7, 7, 6,
|
7, 7, 7, 7, 7, 7, 6,
|
||||||
6, 6, 6, 6, 6, 6, 5,
|
6, 6, 6, 6, 6, 6, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 4, 4, 4, 4, 4, 4,
|
5, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 3, 3, 3,
|
4, 4, 4, 4, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 2, 2, 2, 2,
|
3, 3, 3, 2, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 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,
|
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, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 0, 0,
|
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, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 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[] = {
|
static const e_uint16 ar_adjust_coeff[] = {
|
||||||
127, 108, 98, 90, 84, 80, 75,
|
127, 108, 98, 90, 84, 80, 75,
|
||||||
72, 69, 66, 64, 61, 59, 57,
|
72, 69, 66, 64, 61, 59, 57,
|
||||||
56, 54, 52, 51, 49, 48, 47,
|
56, 54, 52, 51, 49, 48, 47,
|
||||||
45, 44, 43, 42, 41, 40, 39,
|
45, 44, 43, 42, 41, 40, 39,
|
||||||
38, 37, 36, 36, 35, 34, 33,
|
38, 37, 36, 36, 35, 34, 33,
|
||||||
33, 32, 31, 30, 30, 29, 29,
|
33, 32, 31, 30, 30, 29, 29,
|
||||||
28, 27, 27, 26, 26, 25, 24,
|
28, 27, 27, 26, 26, 25, 24,
|
||||||
24, 23, 23, 22, 22, 21, 21,
|
24, 23, 23, 22, 22, 21, 21,
|
||||||
21, 20, 20, 19, 19, 18, 18,
|
21, 20, 20, 19, 19, 18, 18,
|
||||||
17, 17, 17, 16, 16, 15, 15,
|
17, 17, 17, 16, 16, 15, 15,
|
||||||
15, 14, 14, 14, 13, 13, 13,
|
15, 14, 14, 14, 13, 13, 13,
|
||||||
12, 12, 12, 11, 11, 11, 10,
|
12, 12, 12, 11, 11, 11, 10,
|
||||||
10, 10, 9, 9, 9, 9, 8,
|
10, 10, 9, 9, 9, 9, 8,
|
||||||
8, 8, 7, 7, 7, 7, 6,
|
8, 8, 7, 7, 7, 7, 6,
|
||||||
6, 6, 6, 5, 5, 5, 4,
|
6, 6, 6, 5, 5, 5, 4,
|
||||||
4, 4, 4, 4, 3, 3, 3,
|
4, 4, 4, 4, 3, 3, 3,
|
||||||
3, 2, 2, 2, 2, 1, 1,
|
3, 2, 2, 2, 2, 1, 1,
|
||||||
1, 1, 1, 0, 0, 0, 0,
|
1, 1, 1, 0, 0, 0, 0,
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
#ifndef _EMUTYPES_H_
|
#ifndef _EMUTYPES_H_
|
||||||
#define _EMUTYPES_H_
|
#define _EMUTYPES_H_
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define INLINE __forceinline
|
#define INLINE __forceinline
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define INLINE __inline__
|
#define INLINE __inline__
|
||||||
#elif defined(_MWERKS_)
|
#elif defined(_MWERKS_)
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
#else
|
#else
|
||||||
#define INLINE
|
#define INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EMU_DLL_IMPORTS)
|
#if defined(EMU_DLL_IMPORTS)
|
||||||
#define EMU2149_DLL_IMPORTS
|
#define EMU2149_DLL_IMPORTS
|
||||||
#define EMU2212_DLL_IMPORTS
|
#define EMU2212_DLL_IMPORTS
|
||||||
#define EMU2413_DLL_IMPORTS
|
#define EMU2413_DLL_IMPORTS
|
||||||
#define EMU8950_DLL_IMPORTS
|
#define EMU8950_DLL_IMPORTS
|
||||||
#define EMU76489_DLL_IMPORTS
|
#define EMU76489_DLL_IMPORTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned int e_uint;
|
typedef unsigned int e_uint;
|
||||||
typedef signed int e_int;
|
typedef signed int e_int;
|
||||||
|
|
||||||
typedef unsigned char e_uint8 ;
|
typedef unsigned char e_uint8 ;
|
||||||
typedef signed char e_int8 ;
|
typedef signed char e_int8 ;
|
||||||
|
|
||||||
typedef unsigned short e_uint16 ;
|
typedef unsigned short e_uint16 ;
|
||||||
typedef signed short e_int16 ;
|
typedef signed short e_int16 ;
|
||||||
|
|
||||||
typedef unsigned int e_uint32 ;
|
typedef unsigned int e_uint32 ;
|
||||||
typedef signed int e_int32 ;
|
typedef signed int e_int32 ;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,297 +1,297 @@
|
||||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "hes_apu_adpcm.h"
|
#include "hes_apu_adpcm.h"
|
||||||
|
|
||||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
/* 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
|
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
|
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
|
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
|
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
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
|
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,
|
License along with this module; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
|
|
||||||
void Adpcm_init( struct Hes_Apu_Adpcm* this )
|
void Adpcm_init( struct Hes_Apu_Adpcm* this )
|
||||||
{
|
{
|
||||||
this->output = NULL;
|
this->output = NULL;
|
||||||
memset( &this->state, 0, sizeof( this->state ) );
|
memset( &this->state, 0, sizeof( this->state ) );
|
||||||
Adpcm_reset( this );
|
Adpcm_reset( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adpcm_reset( struct Hes_Apu_Adpcm* this )
|
void Adpcm_reset( struct Hes_Apu_Adpcm* this )
|
||||||
{
|
{
|
||||||
this->last_time = 0;
|
this->last_time = 0;
|
||||||
this->next_timer = 0;
|
this->next_timer = 0;
|
||||||
this->last_amp = 0;
|
this->last_amp = 0;
|
||||||
|
|
||||||
memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) );
|
memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) );
|
||||||
memset( &this->state.port, 0, sizeof(this->state.port) );
|
memset( &this->state.port, 0, sizeof(this->state.port) );
|
||||||
|
|
||||||
this->state.ad_sample = 0;
|
this->state.ad_sample = 0;
|
||||||
this->state.ad_ref_index = 0;
|
this->state.ad_ref_index = 0;
|
||||||
|
|
||||||
this->state.addr = 0;
|
this->state.addr = 0;
|
||||||
this->state.freq = 0;
|
this->state.freq = 0;
|
||||||
this->state.writeptr = 0;
|
this->state.writeptr = 0;
|
||||||
this->state.readptr = 0;
|
this->state.readptr = 0;
|
||||||
this->state.playflag = 0;
|
this->state.playflag = 0;
|
||||||
this->state.repeatflag = 0;
|
this->state.repeatflag = 0;
|
||||||
this->state.length = 0;
|
this->state.length = 0;
|
||||||
this->state.volume = 0xFF;
|
this->state.volume = 0xFF;
|
||||||
this->state.fadetimer = 0;
|
this->state.fadetimer = 0;
|
||||||
this->state.fadecount = 0;
|
this->state.fadecount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static short stepsize[49] = {
|
static short stepsize[49] = {
|
||||||
16, 17, 19, 21, 23, 25, 28,
|
16, 17, 19, 21, 23, 25, 28,
|
||||||
31, 34, 37, 41, 45, 50, 55,
|
31, 34, 37, 41, 45, 50, 55,
|
||||||
60, 66, 73, 80, 88, 97, 107,
|
60, 66, 73, 80, 88, 97, 107,
|
||||||
118, 130, 143, 157, 173, 190, 209,
|
118, 130, 143, 157, 173, 190, 209,
|
||||||
230, 253, 279, 307, 337, 371, 408,
|
230, 253, 279, 307, 337, 371, 408,
|
||||||
449, 494, 544, 598, 658, 724, 796,
|
449, 494, 544, 598, 658, 724, 796,
|
||||||
876, 963,1060,1166,1282,1411,1552
|
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 );
|
||||||
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;
|
struct State* state = &this->state;
|
||||||
int step = stepsize[state->ad_ref_index];
|
int step = stepsize[state->ad_ref_index];
|
||||||
int delta;
|
int delta;
|
||||||
int c = code & 7;
|
int c = code & 7;
|
||||||
#if 1
|
#if 1
|
||||||
delta = 0;
|
delta = 0;
|
||||||
if ( c & 4 ) delta += step;
|
if ( c & 4 ) delta += step;
|
||||||
step >>= 1;
|
step >>= 1;
|
||||||
if ( c & 2 ) delta += step;
|
if ( c & 2 ) delta += step;
|
||||||
step >>= 1;
|
step >>= 1;
|
||||||
if ( c & 1 ) delta += step;
|
if ( c & 1 ) delta += step;
|
||||||
step >>= 1;
|
step >>= 1;
|
||||||
delta += step;
|
delta += step;
|
||||||
#else
|
#else
|
||||||
delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding
|
delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding
|
||||||
#endif
|
#endif
|
||||||
if ( c != code )
|
if ( c != code )
|
||||||
{
|
{
|
||||||
state->ad_sample -= delta;
|
state->ad_sample -= delta;
|
||||||
if ( state->ad_sample < -2048 )
|
if ( state->ad_sample < -2048 )
|
||||||
state->ad_sample = -2048;
|
state->ad_sample = -2048;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state->ad_sample += delta;
|
state->ad_sample += delta;
|
||||||
if ( state->ad_sample > 2047 )
|
if ( state->ad_sample > 2047 )
|
||||||
state->ad_sample = 2047;
|
state->ad_sample = 2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int const steps [8] = {
|
static int const steps [8] = {
|
||||||
-1, -1, -1, -1, 2, 4, 6, 8
|
-1, -1, -1, -1, 2, 4, 6, 8
|
||||||
};
|
};
|
||||||
state->ad_ref_index += steps [c];
|
state->ad_ref_index += steps [c];
|
||||||
if ( state->ad_ref_index < 0 )
|
if ( state->ad_ref_index < 0 )
|
||||||
state->ad_ref_index = 0;
|
state->ad_ref_index = 0;
|
||||||
else if ( state->ad_ref_index > 48 )
|
else if ( state->ad_ref_index > 48 )
|
||||||
state->ad_ref_index = 48;
|
state->ad_ref_index = 48;
|
||||||
|
|
||||||
return state->ad_sample;
|
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 );
|
||||||
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;
|
struct State* state = &this->state;
|
||||||
int volume = state->volume;
|
int volume = state->volume;
|
||||||
int fadetimer = state->fadetimer;
|
int fadetimer = state->fadetimer;
|
||||||
int fadecount = state->fadecount;
|
int fadecount = state->fadecount;
|
||||||
int last_time = this->last_time;
|
int last_time = this->last_time;
|
||||||
int next_timer = this->next_timer;
|
int next_timer = this->next_timer;
|
||||||
int last_amp = this->last_amp;
|
int last_amp = this->last_amp;
|
||||||
|
|
||||||
struct Blip_Buffer* output = this->output; // cache often-used values
|
struct Blip_Buffer* output = this->output; // cache often-used values
|
||||||
|
|
||||||
while ( state->playflag && last_time < end_time )
|
while ( state->playflag && last_time < end_time )
|
||||||
{
|
{
|
||||||
while ( last_time >= next_timer )
|
while ( last_time >= next_timer )
|
||||||
{
|
{
|
||||||
if ( fadetimer )
|
if ( fadetimer )
|
||||||
{
|
{
|
||||||
if ( fadecount > 0 )
|
if ( fadecount > 0 )
|
||||||
{
|
{
|
||||||
fadecount--;
|
fadecount--;
|
||||||
volume = 0xFF * fadecount / fadetimer;
|
volume = 0xFF * fadecount / fadetimer;
|
||||||
}
|
}
|
||||||
else if ( fadecount < 0 )
|
else if ( fadecount < 0 )
|
||||||
{
|
{
|
||||||
fadecount++;
|
fadecount++;
|
||||||
volume = 0xFF - ( 0xFF * fadecount / fadetimer );
|
volume = 0xFF - ( 0xFF * fadecount / fadetimer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next_timer += 7159; // 7159091/1000;
|
next_timer += 7159; // 7159091/1000;
|
||||||
}
|
}
|
||||||
int amp;
|
int amp;
|
||||||
if ( state->ad_low_nibble )
|
if ( state->ad_low_nibble )
|
||||||
{
|
{
|
||||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F );
|
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F );
|
||||||
state->ad_low_nibble = false;
|
state->ad_low_nibble = false;
|
||||||
state->playptr++;
|
state->playptr++;
|
||||||
state->playedsamplecount++;
|
state->playedsamplecount++;
|
||||||
if ( state->playedsamplecount == state->playlength )
|
if ( state->playedsamplecount == state->playlength )
|
||||||
{
|
{
|
||||||
state->playflag = 0;
|
state->playflag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 );
|
amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 );
|
||||||
state->ad_low_nibble = true;
|
state->ad_low_nibble = true;
|
||||||
}
|
}
|
||||||
amp = amp * volume / 0xFF;
|
amp = amp * volume / 0xFF;
|
||||||
int delta = amp - last_amp;
|
int delta = amp - last_amp;
|
||||||
if ( output && delta )
|
if ( output && delta )
|
||||||
{
|
{
|
||||||
last_amp = amp;
|
last_amp = amp;
|
||||||
Synth_offset_inline( &this->synth, last_time, delta, output );
|
Synth_offset_inline( &this->synth, last_time, delta, output );
|
||||||
}
|
}
|
||||||
last_time += state->freq;
|
last_time += state->freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !state->playflag )
|
if ( !state->playflag )
|
||||||
{
|
{
|
||||||
while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000
|
while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000
|
||||||
last_time = end_time;
|
last_time = end_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->last_time = last_time;
|
this->last_time = last_time;
|
||||||
this->next_timer = next_timer;
|
this->next_timer = next_timer;
|
||||||
this->last_amp = last_amp;
|
this->last_amp = last_amp;
|
||||||
state->volume = volume;
|
state->volume = volume;
|
||||||
state->fadetimer = fadetimer;
|
state->fadetimer = fadetimer;
|
||||||
state->fadecount = fadecount;
|
state->fadecount = fadecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr, int data )
|
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 );
|
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||||
struct State* state = &this->state;
|
struct State* state = &this->state;
|
||||||
|
|
||||||
data &= 0xFF;
|
data &= 0xFF;
|
||||||
state->port[ addr & 15 ] = data;
|
state->port[ addr & 15 ] = data;
|
||||||
switch ( addr & 15 )
|
switch ( addr & 15 )
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
state->addr &= 0xFF00;
|
state->addr &= 0xFF00;
|
||||||
state->addr |= data;
|
state->addr |= data;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
state->addr &= 0xFF;
|
state->addr &= 0xFF;
|
||||||
state->addr |= data << 8;
|
state->addr |= data << 8;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
state->pcmbuf[ state->writeptr++ ] = data;
|
state->pcmbuf[ state->writeptr++ ] = data;
|
||||||
state->playlength ++;
|
state->playlength ++;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
dprintf("ADPCM DMA 0x%02X", data);
|
dprintf("ADPCM DMA 0x%02X", data);
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if ( data & 0x80 )
|
if ( data & 0x80 )
|
||||||
{
|
{
|
||||||
state->addr = 0;
|
state->addr = 0;
|
||||||
state->freq = 0;
|
state->freq = 0;
|
||||||
state->writeptr = 0;
|
state->writeptr = 0;
|
||||||
state->readptr = 0;
|
state->readptr = 0;
|
||||||
state->playflag = 0;
|
state->playflag = 0;
|
||||||
state->repeatflag = 0;
|
state->repeatflag = 0;
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->volume = 0xFF;
|
state->volume = 0xFF;
|
||||||
}
|
}
|
||||||
if ( ( data & 3 ) == 3 )
|
if ( ( data & 3 ) == 3 )
|
||||||
{
|
{
|
||||||
state->writeptr = state->addr;
|
state->writeptr = state->addr;
|
||||||
}
|
}
|
||||||
if ( data & 8 )
|
if ( data & 8 )
|
||||||
{
|
{
|
||||||
state->readptr = state->addr ? state->addr - 1 : state->addr;
|
state->readptr = state->addr ? state->addr - 1 : state->addr;
|
||||||
}
|
}
|
||||||
if ( data & 0x10 )
|
if ( data & 0x10 )
|
||||||
{
|
{
|
||||||
state->length = state->addr;
|
state->length = state->addr;
|
||||||
}
|
}
|
||||||
state->repeatflag = data & 0x20;
|
state->repeatflag = data & 0x20;
|
||||||
state->playflag = data & 0x40;
|
state->playflag = data & 0x40;
|
||||||
if ( state->playflag )
|
if ( state->playflag )
|
||||||
{
|
{
|
||||||
state->playptr = state->readptr;
|
state->playptr = state->readptr;
|
||||||
state->playlength = state->length + 1;
|
state->playlength = state->length + 1;
|
||||||
state->playedsamplecount = 0;
|
state->playedsamplecount = 0;
|
||||||
state->ad_sample = 0;
|
state->ad_sample = 0;
|
||||||
state->ad_low_nibble = false;
|
state->ad_low_nibble = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) );
|
state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) );
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
switch ( data & 15 )
|
switch ( data & 15 )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 8:
|
case 8:
|
||||||
case 12:
|
case 12:
|
||||||
state->fadetimer = -100;
|
state->fadetimer = -100;
|
||||||
state->fadecount = state->fadetimer;
|
state->fadecount = state->fadetimer;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
state->fadetimer = 5000;
|
state->fadetimer = 5000;
|
||||||
state->fadecount = state->fadetimer;
|
state->fadecount = state->fadetimer;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
state->fadetimer = 1500;
|
state->fadetimer = 1500;
|
||||||
state->fadecount = state->fadetimer;
|
state->fadecount = state->fadetimer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr )
|
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 );
|
if ( time > this->last_time ) Adpcm_run_until( this, time );
|
||||||
|
|
||||||
struct State* state = &this->state;
|
struct State* state = &this->state;
|
||||||
switch ( addr & 15 )
|
switch ( addr & 15 )
|
||||||
{
|
{
|
||||||
case 10:
|
case 10:
|
||||||
return state->pcmbuf [state->readptr++];
|
return state->pcmbuf [state->readptr++];
|
||||||
case 11:
|
case 11:
|
||||||
return state->port [11] & ~1;
|
return state->port [11] & ~1;
|
||||||
case 12:
|
case 12:
|
||||||
if (!state->playflag)
|
if (!state->playflag)
|
||||||
{
|
{
|
||||||
state->port [12] |= 1;
|
state->port [12] |= 1;
|
||||||
state->port [12] &= ~8;
|
state->port [12] &= ~8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state->port [12] &= ~1;
|
state->port [12] &= ~1;
|
||||||
state->port [12] |= 8;
|
state->port [12] |= 8;
|
||||||
}
|
}
|
||||||
return state->port [12];
|
return state->port [12];
|
||||||
case 13:
|
case 13:
|
||||||
return state->port [13];
|
return state->port [13];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time )
|
||||||
{
|
{
|
||||||
Adpcm_run_until( this, end_time );
|
Adpcm_run_until( this, end_time );
|
||||||
this->last_time -= end_time;
|
this->last_time -= end_time;
|
||||||
this->next_timer -= end_time;
|
this->next_timer -= end_time;
|
||||||
check( last_time >= 0 );
|
check( last_time >= 0 );
|
||||||
if ( this->output )
|
if ( this->output )
|
||||||
Blip_set_modified( this->output );
|
Blip_set_modified( this->output );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
/* Memory buffer reader, simulates file read
|
/* Memory buffer reader, simulates file read
|
||||||
@ gama
|
@ gama
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mbreader.h"
|
#include "mbreader.h"
|
||||||
|
|
||||||
int mbread(struct mbreader_t *md, void *buf, size_t n)
|
int mbread(struct mbreader_t *md, void *buf, size_t n)
|
||||||
{
|
{
|
||||||
if (!md) return -1;
|
if (!md) return -1;
|
||||||
size_t read_bytes = (md->offset+n) > md->size ?
|
size_t read_bytes = (md->offset+n) > md->size ?
|
||||||
md->size-md->offset : n;
|
md->size-md->offset : n;
|
||||||
memcpy(buf,md->ptr + md->offset,read_bytes);
|
memcpy(buf,md->ptr + md->offset,read_bytes);
|
||||||
md->offset += read_bytes;
|
md->offset += read_bytes;
|
||||||
return read_bytes;
|
return read_bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
|
|
||||||
#ifndef MBREADER_H
|
#ifndef MBREADER_H
|
||||||
#define MBREADER_H
|
#define MBREADER_H
|
||||||
|
|
||||||
#include "codeclib.h"
|
#include "codeclib.h"
|
||||||
|
|
||||||
struct mbreader_t {
|
struct mbreader_t {
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
int mbread(struct mbreader_t *md, void *buf, size_t n);
|
int mbread(struct mbreader_t *md, void *buf, size_t n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "kss_emu.h"
|
#include "kss_emu.h"
|
||||||
|
|
||||||
#include "blargg_endian.h"
|
#include "blargg_endian.h"
|
||||||
//#include "z80_cpu_log.h"
|
//#include "z80_cpu_log.h"
|
||||||
|
|
||||||
/* Copyright (C) 2006-2008 Shay Green. This module is free software; you
|
/* 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
|
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
|
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
|
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
|
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
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
|
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,
|
License along with this module; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||||
#define IN_PORT( addr ) cpu_in( this, TIME(), addr )
|
#define IN_PORT( addr ) cpu_in( this, TIME(), addr )
|
||||||
#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );}
|
#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );}
|
||||||
#define IDLE_ADDR idle_addr
|
#define IDLE_ADDR idle_addr
|
||||||
|
|
||||||
#define CPU_BEGIN \
|
#define CPU_BEGIN \
|
||||||
bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\
|
bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\
|
||||||
{\
|
{\
|
||||||
struct Z80_Cpu *cpu = &this->cpu; \
|
struct Z80_Cpu *cpu = &this->cpu; \
|
||||||
Z80_set_end_time( cpu, end_time );
|
Z80_set_end_time( cpu, end_time );
|
||||||
|
|
||||||
#include "z80_cpu_run.h"
|
#include "z80_cpu_run.h"
|
||||||
|
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,88 +1,88 @@
|
||||||
|
|
||||||
#include "nes_vrc7_apu.h"
|
#include "nes_vrc7_apu.h"
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
int const period = 36; // NES CPU clocks per FM clock
|
int const period = 36; // NES CPU clocks per FM clock
|
||||||
|
|
||||||
void Vrc7_init( struct Nes_Vrc7_Apu* this )
|
void Vrc7_init( struct Nes_Vrc7_Apu* this )
|
||||||
{
|
{
|
||||||
Synth_init( &this->synth );
|
Synth_init( &this->synth );
|
||||||
|
|
||||||
OPLL_new ( &this->opll, 3579545, 3579545 / 72 );
|
OPLL_new ( &this->opll, 3579545, 3579545 / 72 );
|
||||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||||
|
|
||||||
this->osc.output = 0;
|
this->osc.output = 0;
|
||||||
this->osc.last_amp = 0;
|
this->osc.last_amp = 0;
|
||||||
this->mask = 0;
|
this->mask = 0;
|
||||||
|
|
||||||
Vrc7_volume( this, (int)FP_ONE_VOLUME );
|
Vrc7_volume( this, (int)FP_ONE_VOLUME );
|
||||||
Vrc7_reset( this );
|
Vrc7_reset( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_reset( struct Nes_Vrc7_Apu* this )
|
void Vrc7_reset( struct Nes_Vrc7_Apu* this )
|
||||||
{
|
{
|
||||||
this->addr = 0;
|
this->addr = 0;
|
||||||
this->next_time = 0;
|
this->next_time = 0;
|
||||||
this->osc.last_amp = 0;
|
this->osc.last_amp = 0;
|
||||||
|
|
||||||
OPLL_reset (&this->opll);
|
OPLL_reset (&this->opll);
|
||||||
OPLL_setMask(&this->opll, this->mask);
|
OPLL_setMask(&this->opll, this->mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r )
|
void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r )
|
||||||
{
|
{
|
||||||
OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 );
|
OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data )
|
void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data )
|
||||||
{
|
{
|
||||||
this->addr = data;
|
this->addr = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time );
|
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 )
|
void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t time, int data )
|
||||||
{
|
{
|
||||||
if ( time > this->next_time )
|
if ( time > this->next_time )
|
||||||
Vrc7_run_until( this, time );
|
Vrc7_run_until( this, time );
|
||||||
|
|
||||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||||
OPLL_writeIO( &this->opll, 1, data );
|
OPLL_writeIO( &this->opll, 1, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time )
|
void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time )
|
||||||
{
|
{
|
||||||
if ( time > this->next_time )
|
if ( time > this->next_time )
|
||||||
Vrc7_run_until( this, time );
|
Vrc7_run_until( this, time );
|
||||||
|
|
||||||
this->next_time -= time;
|
this->next_time -= time;
|
||||||
assert( this->next_time >= 0 );
|
assert( this->next_time >= 0 );
|
||||||
|
|
||||||
if ( this->osc.output )
|
if ( this->osc.output )
|
||||||
Blip_set_modified( this->osc.output );
|
Blip_set_modified( this->osc.output );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time )
|
void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time )
|
||||||
{
|
{
|
||||||
require( end_time > this->next_time );
|
require( end_time > this->next_time );
|
||||||
|
|
||||||
blip_time_t time = this->next_time;
|
blip_time_t time = this->next_time;
|
||||||
OPLL* opll = &this->opll; // cache
|
OPLL* opll = &this->opll; // cache
|
||||||
struct Blip_Buffer* const output = this-> osc.output;
|
struct Blip_Buffer* const output = this-> osc.output;
|
||||||
if ( output )
|
if ( output )
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int amp = OPLL_calc( opll ) << 1;
|
int amp = OPLL_calc( opll ) << 1;
|
||||||
int delta = amp - this->osc.last_amp;
|
int delta = amp - this->osc.last_amp;
|
||||||
if ( delta )
|
if ( delta )
|
||||||
{
|
{
|
||||||
this->osc.last_amp = amp;
|
this->osc.last_amp = amp;
|
||||||
Synth_offset_inline( &this->synth, time, delta, output );
|
Synth_offset_inline( &this->synth, time, delta, output );
|
||||||
}
|
}
|
||||||
time += period;
|
time += period;
|
||||||
}
|
}
|
||||||
while ( time < end_time );
|
while ( time < end_time );
|
||||||
}
|
}
|
||||||
|
|
||||||
this->next_time = time;
|
this->next_time = time;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,198 +1,198 @@
|
||||||
#include "opl_apu.h"
|
#include "opl_apu.h"
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
/* NOTE: Removed unused chips ~ gama */
|
/* 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 )
|
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 );
|
Synth_init( &this->synth );
|
||||||
|
|
||||||
this->type_ = type;
|
this->type_ = type;
|
||||||
this->clock_ = clock;
|
this->clock_ = clock;
|
||||||
this->rate_ = rate;
|
this->rate_ = rate;
|
||||||
this->period_ = period;
|
this->period_ = period;
|
||||||
Opl_set_output( this, 0 );
|
Opl_set_output( this, 0 );
|
||||||
Opl_volume( this, (int)FP_ONE_VOLUME );
|
Opl_volume( this, (int)FP_ONE_VOLUME );
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
OPLL_new ( &this->opll, clock, rate );
|
OPLL_new ( &this->opll, clock, rate );
|
||||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||||
break;
|
break;
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
OPLL_new ( &this->opll, clock, rate );
|
OPLL_new ( &this->opll, clock, rate );
|
||||||
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE );
|
||||||
break;
|
break;
|
||||||
case type_msxaudio:
|
case type_msxaudio:
|
||||||
OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory );
|
OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory );
|
||||||
OPL_setSampleRate( &this->opl, rate, clock );
|
OPL_setSampleRate( &this->opl, rate, clock );
|
||||||
OPL_setInternalVolume(&this->opl, 1 << 13);
|
OPL_setInternalVolume(&this->opl, 1 << 13);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Opl_reset( this );
|
Opl_reset( this );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Opl_shutdown( struct Opl_Apu* this )
|
void Opl_shutdown( struct Opl_Apu* this )
|
||||||
{
|
{
|
||||||
switch (this->type_)
|
switch (this->type_)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
OPLL_delete( &this->opll );
|
OPLL_delete( &this->opll );
|
||||||
break;
|
break;
|
||||||
case type_msxaudio: break;
|
case type_msxaudio: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Opl_reset( struct Opl_Apu* this )
|
void Opl_reset( struct Opl_Apu* this )
|
||||||
{
|
{
|
||||||
this->addr = 0;
|
this->addr = 0;
|
||||||
this->next_time = 0;
|
this->next_time = 0;
|
||||||
this->last_amp = 0;
|
this->last_amp = 0;
|
||||||
|
|
||||||
switch (this->type_)
|
switch (this->type_)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
OPLL_reset( &this->opll );
|
OPLL_reset( &this->opll );
|
||||||
OPLL_setMask( &this->opll, 0 );
|
OPLL_setMask( &this->opll, 0 );
|
||||||
break;
|
break;
|
||||||
case type_msxaudio:
|
case type_msxaudio:
|
||||||
OPL_reset( &this->opl );
|
OPL_reset( &this->opl );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time );
|
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 )
|
void Opl_write_data( struct Opl_Apu* this, blip_time_t time, int data )
|
||||||
{
|
{
|
||||||
run_until( this, time );
|
run_until( this, time );
|
||||||
switch (this->type_)
|
switch (this->type_)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
OPLL_writeIO( &this->opll, 0, this->addr );
|
OPLL_writeIO( &this->opll, 0, this->addr );
|
||||||
OPLL_writeIO( &this->opll, 1, data );
|
OPLL_writeIO( &this->opll, 1, data );
|
||||||
break;
|
break;
|
||||||
case type_msxaudio:
|
case type_msxaudio:
|
||||||
OPL_writeReg( &this->opl, this->addr, data );
|
OPL_writeReg( &this->opl, this->addr, data );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Opl_read( struct Opl_Apu* this, blip_time_t time, int port )
|
int Opl_read( struct Opl_Apu* this, blip_time_t time, int port )
|
||||||
{
|
{
|
||||||
run_until( this, time );
|
run_until( this, time );
|
||||||
switch (this->type_)
|
switch (this->type_)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
return OPLL_read( &this->opll, port );
|
return OPLL_read( &this->opll, port );
|
||||||
case type_msxaudio:
|
case type_msxaudio:
|
||||||
return OPL_readStatus( &this->opl );
|
return OPL_readStatus( &this->opl );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Opl_end_frame( struct Opl_Apu* this, blip_time_t time )
|
void Opl_end_frame( struct Opl_Apu* this, blip_time_t time )
|
||||||
{
|
{
|
||||||
run_until( this, time );
|
run_until( this, time );
|
||||||
this->next_time -= time;
|
this->next_time -= time;
|
||||||
|
|
||||||
if ( this->output_ )
|
if ( this->output_ )
|
||||||
Blip_set_modified( this->output_ );
|
Blip_set_modified( this->output_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_until( struct Opl_Apu* this, blip_time_t end_time )
|
static void run_until( struct Opl_Apu* this, blip_time_t end_time )
|
||||||
{
|
{
|
||||||
if ( end_time > this->next_time )
|
if ( end_time > this->next_time )
|
||||||
{
|
{
|
||||||
blip_time_t time_delta = end_time - this->next_time;
|
blip_time_t time_delta = end_time - this->next_time;
|
||||||
blip_time_t time = this->next_time;
|
blip_time_t time = this->next_time;
|
||||||
unsigned count = time_delta / this->period_ + 1;
|
unsigned count = time_delta / this->period_ + 1;
|
||||||
switch (this->type_)
|
switch (this->type_)
|
||||||
{
|
{
|
||||||
case type_opll:
|
case type_opll:
|
||||||
case type_msxmusic:
|
case type_msxmusic:
|
||||||
case type_smsfmunit:
|
case type_smsfmunit:
|
||||||
case type_vrc7:
|
case type_vrc7:
|
||||||
{
|
{
|
||||||
OPLL* opll = &this->opll; // cache
|
OPLL* opll = &this->opll; // cache
|
||||||
struct Blip_Buffer* const output = this->output_;
|
struct Blip_Buffer* const output = this->output_;
|
||||||
while ( count > 0 )
|
while ( count > 0 )
|
||||||
{
|
{
|
||||||
unsigned todo = count;
|
unsigned todo = count;
|
||||||
if ( todo > 1024 ) todo = 1024;
|
if ( todo > 1024 ) todo = 1024;
|
||||||
short *buffer = OPLL_update_buffer(opll, todo);
|
short *buffer = OPLL_update_buffer(opll, todo);
|
||||||
|
|
||||||
if ( output && buffer )
|
if ( output && buffer )
|
||||||
{
|
{
|
||||||
int last_amp = this->last_amp;
|
int last_amp = this->last_amp;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for ( i = 0; i < todo; i++ )
|
for ( i = 0; i < todo; i++ )
|
||||||
{
|
{
|
||||||
int amp = buffer [i];
|
int amp = buffer [i];
|
||||||
int delta = amp - last_amp;
|
int delta = amp - last_amp;
|
||||||
if ( delta )
|
if ( delta )
|
||||||
{
|
{
|
||||||
last_amp = amp;
|
last_amp = amp;
|
||||||
Synth_offset_inline( &this->synth, time, delta, output );
|
Synth_offset_inline( &this->synth, time, delta, output );
|
||||||
}
|
}
|
||||||
time += this->period_;
|
time += this->period_;
|
||||||
}
|
}
|
||||||
this->last_amp = last_amp;
|
this->last_amp = last_amp;
|
||||||
}
|
}
|
||||||
count -= todo;
|
count -= todo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case type_msxaudio:
|
case type_msxaudio:
|
||||||
{
|
{
|
||||||
struct Y8950* opl = &this->opl;
|
struct Y8950* opl = &this->opl;
|
||||||
struct Blip_Buffer* const output = this->output_;
|
struct Blip_Buffer* const output = this->output_;
|
||||||
while ( count > 0 )
|
while ( count > 0 )
|
||||||
{
|
{
|
||||||
unsigned todo = count;
|
unsigned todo = count;
|
||||||
if ( todo > 1024 ) todo = 1024;
|
if ( todo > 1024 ) todo = 1024;
|
||||||
int *buffer = OPL_updateBuffer(opl, todo);
|
int *buffer = OPL_updateBuffer(opl, todo);
|
||||||
|
|
||||||
if ( output && buffer )
|
if ( output && buffer )
|
||||||
{
|
{
|
||||||
int last_amp = this->last_amp;
|
int last_amp = this->last_amp;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for ( i = 0; i < todo; i++ )
|
for ( i = 0; i < todo; i++ )
|
||||||
{
|
{
|
||||||
int amp = buffer [i];
|
int amp = buffer [i];
|
||||||
int delta = amp - last_amp;
|
int delta = amp - last_amp;
|
||||||
if ( delta )
|
if ( delta )
|
||||||
{
|
{
|
||||||
last_amp = amp;
|
last_amp = amp;
|
||||||
Synth_offset_inline( &this->synth, time, delta, output );
|
Synth_offset_inline( &this->synth, time, delta, output );
|
||||||
}
|
}
|
||||||
time += this->period_;
|
time += this->period_;
|
||||||
}
|
}
|
||||||
this->last_amp = last_amp;
|
this->last_amp = last_amp;
|
||||||
}
|
}
|
||||||
count -= todo;
|
count -= todo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->next_time = time;
|
this->next_time = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
#ifndef OPL_APU_H
|
#ifndef OPL_APU_H
|
||||||
#define OPL_APU_H
|
#define OPL_APU_H
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
#include "blip_buffer.h"
|
#include "blip_buffer.h"
|
||||||
|
|
||||||
#include "emu8950.h"
|
#include "emu8950.h"
|
||||||
#include "emu2413.h"
|
#include "emu2413.h"
|
||||||
|
|
||||||
enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12,
|
enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12,
|
||||||
type_vrc7 = 0x13, type_msxaudio = 0x21 };
|
type_vrc7 = 0x13, type_msxaudio = 0x21 };
|
||||||
|
|
||||||
enum { opl_osc_count = 1 };
|
enum { opl_osc_count = 1 };
|
||||||
|
|
||||||
struct Opl_Apu {
|
struct Opl_Apu {
|
||||||
struct Blip_Buffer* output_;
|
struct Blip_Buffer* output_;
|
||||||
enum opl_type_t type_;
|
enum opl_type_t type_;
|
||||||
|
|
||||||
blip_time_t next_time;
|
blip_time_t next_time;
|
||||||
int last_amp;
|
int last_amp;
|
||||||
int addr;
|
int addr;
|
||||||
|
|
||||||
long clock_;
|
long clock_;
|
||||||
long rate_;
|
long rate_;
|
||||||
blip_time_t period_;
|
blip_time_t period_;
|
||||||
|
|
||||||
struct Blip_Synth synth;
|
struct Blip_Synth synth;
|
||||||
|
|
||||||
// OPL chips
|
// OPL chips
|
||||||
struct Y8950 opl;
|
struct Y8950 opl;
|
||||||
OPLL opll;
|
OPLL opll;
|
||||||
|
|
||||||
unsigned char regs[ 0x100 ];
|
unsigned char regs[ 0x100 ];
|
||||||
unsigned char opl_memory[ 32768 ];
|
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 );
|
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_shutdown( struct Opl_Apu* this );
|
||||||
|
|
||||||
void Opl_reset( 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_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 )
|
static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf )
|
||||||
{
|
{
|
||||||
#if defined(ROCKBOX)
|
#if defined(ROCKBOX)
|
||||||
(void) i;
|
(void) i;
|
||||||
#endif
|
#endif
|
||||||
assert( (unsigned) i < opl_osc_count );
|
assert( (unsigned) i < opl_osc_count );
|
||||||
this->output_ = buf;
|
this->output_ = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, 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 );
|
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; }
|
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 );
|
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 );
|
int Opl_read( struct Opl_Apu* this, blip_time_t, int port );
|
||||||
|
|
||||||
static inline bool Opl_supported( void ) { return true; }
|
static inline bool Opl_supported( void ) { return true; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,242 +1,242 @@
|
||||||
#ifndef _OPLTABLES_H_
|
#ifndef _OPLTABLES_H_
|
||||||
#define _OPLTABLES_H_
|
#define _OPLTABLES_H_
|
||||||
|
|
||||||
/* Precalculated emu8950 tables for use in Rockbox,
|
/* Precalculated emu8950 tables for use in Rockbox,
|
||||||
Calculated for 44Khz sampling rate */
|
Calculated for 44Khz sampling rate */
|
||||||
|
|
||||||
static const short ar_adjust_coeff[] = {
|
static const short ar_adjust_coeff[] = {
|
||||||
255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157,
|
255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157,
|
||||||
153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128,
|
153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128,
|
||||||
126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112,
|
126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112,
|
||||||
110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100,
|
110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100,
|
||||||
99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91,
|
99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91,
|
||||||
90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83,
|
90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83,
|
||||||
82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77,
|
82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77,
|
||||||
76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71,
|
76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71,
|
||||||
71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66,
|
71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66,
|
||||||
66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62,
|
66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62,
|
||||||
62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58,
|
62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58,
|
||||||
58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55,
|
58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55,
|
||||||
54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51,
|
54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51,
|
||||||
51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48,
|
51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48,
|
||||||
48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45,
|
48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45,
|
||||||
45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43,
|
45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43,
|
||||||
43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40,
|
43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40,
|
||||||
40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38,
|
40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38,
|
||||||
38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36,
|
38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36,
|
||||||
36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34,
|
36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34,
|
||||||
33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
|
33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
|
||||||
31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
|
31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
|
||||||
30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
|
30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
|
||||||
28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26,
|
28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26,
|
||||||
26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25,
|
26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25,
|
||||||
24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23,
|
24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23,
|
||||||
23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21,
|
23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21,
|
||||||
21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20,
|
21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20,
|
||||||
20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18,
|
20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18,
|
||||||
18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17,
|
18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17,
|
||||||
17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16,
|
17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16,
|
||||||
16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14,
|
16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14,
|
||||||
14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13,
|
14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13,
|
||||||
13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
|
13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12,
|
||||||
12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
|
12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||||
11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
|
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
|
||||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
|
8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
|
||||||
7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
|
7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
|
||||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
|
5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
|
4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
|
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
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
|
||||||
};
|
};
|
||||||
|
|
||||||
static const short db2lin_coeff[] = {
|
static const short db2lin_coeff[] = {
|
||||||
2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649,
|
2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649,
|
||||||
1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300,
|
1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300,
|
||||||
1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025,
|
1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025,
|
||||||
1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809,
|
1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809,
|
||||||
791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638,
|
791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638,
|
||||||
624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503,
|
624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503,
|
||||||
492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396,
|
492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396,
|
||||||
388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312,
|
388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312,
|
||||||
306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246,
|
306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246,
|
||||||
241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194,
|
241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194,
|
||||||
190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153,
|
190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153,
|
||||||
150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121,
|
150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121,
|
||||||
118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95,
|
118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95,
|
||||||
93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75,
|
93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75,
|
||||||
73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59,
|
73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59,
|
||||||
58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46,
|
58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46,
|
||||||
45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36,
|
45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36,
|
||||||
36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29,
|
36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29,
|
||||||
28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22,
|
28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22,
|
||||||
22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18,
|
22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18,
|
||||||
17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14,
|
17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14,
|
||||||
13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11,
|
13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11,
|
||||||
11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8,
|
11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8,
|
||||||
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
|
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
|
||||||
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
|
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, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
|
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, 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,
|
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, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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[] = {
|
static const short sin_coeff[] = {
|
||||||
511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129,
|
511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129,
|
||||||
124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95,
|
124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95,
|
||||||
92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75,
|
92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75,
|
||||||
74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62,
|
74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62,
|
||||||
61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52,
|
61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52,
|
||||||
51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43,
|
51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43,
|
||||||
43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37,
|
43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37,
|
||||||
36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31,
|
36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31,
|
||||||
30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26,
|
30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26,
|
||||||
25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22,
|
25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22,
|
||||||
21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18,
|
21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18,
|
||||||
18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
|
18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
|
||||||
14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
|
14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
|
||||||
12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9,
|
12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9,
|
||||||
9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7,
|
9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7,
|
||||||
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
|
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
|
||||||
5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4,
|
5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
|
4, 4, 4, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0,
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const short pm0_coeff[] = {
|
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, 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,
|
256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||||
257, 257, 257, 257, 257, 257, 256, 256, 256, 256, 256,
|
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, 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,
|
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, 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,
|
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, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
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, 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[] = {
|
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, 256,
|
||||||
256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 257,
|
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, 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,
|
257, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||||
258, 258, 258, 258, 258, 258, 258, 257, 257, 257, 257,
|
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, 257, 257,
|
257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
|
||||||
257, 257, 257, 257, 257, 257, 257, 257, 257, 256, 256,
|
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,
|
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,
|
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, 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, 253,
|
||||||
253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
|
253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253,
|
||||||
253, 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,
|
||||||
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,
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const short am0_coeff[] = {
|
static const short am0_coeff[] = {
|
||||||
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
|
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 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,
|
||||||
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, 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,
|
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, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3,
|
4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 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,
|
3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
|
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, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
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, 1, 1,
|
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, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2,
|
2, 2, 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const short am1_coeff[] = {
|
static const short am1_coeff[] = {
|
||||||
12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
|
12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15,
|
||||||
16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
||||||
19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||||
22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
|
22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25,
|
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,
|
||||||
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,
|
24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23,
|
||||||
23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
|
23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
|
||||||
21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18,
|
21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18,
|
||||||
18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15,
|
18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15,
|
||||||
14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11,
|
14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11,
|
||||||
11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8,
|
11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8,
|
||||||
8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5,
|
8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5,
|
||||||
5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2,
|
5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2,
|
||||||
2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
|
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,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 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,
|
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||||
2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5,
|
2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5,
|
||||||
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8,
|
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8,
|
||||||
8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11,
|
8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11,
|
||||||
11, 12, 12,
|
11, 12, 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "sgc_emu.h"
|
#include "sgc_emu.h"
|
||||||
|
|
||||||
#include "blargg_endian.h"
|
#include "blargg_endian.h"
|
||||||
//#include "z80_cpu_log.h"
|
//#include "z80_cpu_log.h"
|
||||||
|
|
||||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
/* 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
|
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
|
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
|
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
|
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
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
|
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,
|
License along with this module; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data )
|
||||||
#define IN_PORT( addr ) 0 // cpu in
|
#define IN_PORT( addr ) 0 // cpu in
|
||||||
#define WRITE_MEM( addr, data ) cpu_write( this, addr, data )
|
#define WRITE_MEM( addr, data ) cpu_write( this, addr, data )
|
||||||
#define IDLE_ADDR this->idle_addr
|
#define IDLE_ADDR this->idle_addr
|
||||||
#define RST_BASE this->vectors_addr
|
#define RST_BASE this->vectors_addr
|
||||||
|
|
||||||
#define CPU_BEGIN \
|
#define CPU_BEGIN \
|
||||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\
|
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\
|
||||||
{\
|
{\
|
||||||
Sgc_Cpu* cpu = &this->cpu; \
|
Sgc_Cpu* cpu = &this->cpu; \
|
||||||
Z80_set_end_time( cpu, end_time );
|
Z80_set_end_time( cpu, end_time );
|
||||||
|
|
||||||
#include "z80_cpu_run.h"
|
#include "z80_cpu_run.h"
|
||||||
|
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,480 +1,480 @@
|
||||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "sgc_emu.h"
|
#include "sgc_emu.h"
|
||||||
|
|
||||||
/* Copyright (C) 2009 Shay Green. This module is free software; you
|
/* 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
|
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
|
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
|
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
|
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
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
|
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,
|
License aint with this module; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
int const osc_count = sms_osc_count + fm_apu_osc_count;
|
int const osc_count = sms_osc_count + fm_apu_osc_count;
|
||||||
|
|
||||||
const char gme_wrong_file_type [] = "Wrong file type for this emulator";
|
const char gme_wrong_file_type [] = "Wrong file type for this emulator";
|
||||||
|
|
||||||
static void clear_track_vars( struct Sgc_Emu* this )
|
static void clear_track_vars( struct Sgc_Emu* this )
|
||||||
{
|
{
|
||||||
this->current_track = -1;
|
this->current_track = -1;
|
||||||
track_stop( &this->track_filter );
|
track_stop( &this->track_filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sgc_init( struct Sgc_Emu* this )
|
void Sgc_init( struct Sgc_Emu* this )
|
||||||
{
|
{
|
||||||
assert( offsetof (struct header_t,copyright [32]) == header_size );
|
assert( offsetof (struct header_t,copyright [32]) == header_size );
|
||||||
|
|
||||||
this->sample_rate = 0;
|
this->sample_rate = 0;
|
||||||
this->mute_mask_ = 0;
|
this->mute_mask_ = 0;
|
||||||
this->tempo = (int)FP_ONE_TEMPO;
|
this->tempo = (int)FP_ONE_TEMPO;
|
||||||
this->gain = (int)FP_ONE_GAIN;
|
this->gain = (int)FP_ONE_GAIN;
|
||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
this->tfilter = *track_get_setup( &this->track_filter );
|
this->tfilter = *track_get_setup( &this->track_filter );
|
||||||
this->tfilter.max_initial = 2;
|
this->tfilter.max_initial = 2;
|
||||||
this->tfilter.lookahead = 6;
|
this->tfilter.lookahead = 6;
|
||||||
this->track_filter.silence_ignored_ = false;
|
this->track_filter.silence_ignored_ = false;
|
||||||
|
|
||||||
Sms_apu_init( &this->apu );
|
Sms_apu_init( &this->apu );
|
||||||
Fm_apu_create( &this->fm_apu );
|
Fm_apu_create( &this->fm_apu );
|
||||||
|
|
||||||
Rom_init( &this->rom, 0x4000 );
|
Rom_init( &this->rom, 0x4000 );
|
||||||
Z80_init( &this->cpu );
|
Z80_init( &this->cpu );
|
||||||
|
|
||||||
Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) );
|
Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) );
|
||||||
|
|
||||||
// Unload
|
// Unload
|
||||||
this->voice_count = 0;
|
this->voice_count = 0;
|
||||||
this->voice_types = 0;
|
this->voice_types = 0;
|
||||||
clear_track_vars( this );
|
clear_track_vars( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
|
|
||||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size )
|
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 ) );
|
RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) );
|
||||||
|
|
||||||
if ( !valid_tag( &this->header ) )
|
if ( !valid_tag( &this->header ) )
|
||||||
return gme_wrong_file_type;
|
return gme_wrong_file_type;
|
||||||
|
|
||||||
/* if ( header.vers != 1 )
|
/* if ( header.vers != 1 )
|
||||||
warning( "Unknown file version" ); */
|
warning( "Unknown file version" ); */
|
||||||
|
|
||||||
/* if ( header.system > 2 )
|
/* if ( header.system > 2 )
|
||||||
warning( "Unknown system" ); */
|
warning( "Unknown system" ); */
|
||||||
|
|
||||||
addr_t load_addr = get_le16( this->header.load_addr );
|
addr_t load_addr = get_le16( this->header.load_addr );
|
||||||
/* if ( load_addr < 0x400 )
|
/* if ( load_addr < 0x400 )
|
||||||
set_warning( "Invalid load address" ); */
|
set_warning( "Invalid load address" ); */
|
||||||
|
|
||||||
Rom_set_addr( &this->rom, load_addr );
|
Rom_set_addr( &this->rom, load_addr );
|
||||||
this->play_period = clock_rate( this ) / 60;
|
this->play_period = clock_rate( this ) / 60;
|
||||||
|
|
||||||
if ( sega_mapping( this ) && Fm_apu_supported() )
|
if ( sega_mapping( this ) && Fm_apu_supported() )
|
||||||
RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) );
|
RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) );
|
||||||
|
|
||||||
this->m3u.size = 0;
|
this->m3u.size = 0;
|
||||||
this->track_count = this->header.song_count;
|
this->track_count = this->header.song_count;
|
||||||
this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count;
|
this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count;
|
||||||
static int const types [sms_osc_count + fm_apu_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
|
wave_type+1, wave_type+2, wave_type+3, mixed_type+1, mixed_type+2
|
||||||
};
|
};
|
||||||
this->voice_types = types;
|
this->voice_types = types;
|
||||||
|
|
||||||
Sms_apu_volume( &this->apu, this->gain );
|
Sms_apu_volume( &this->apu, this->gain );
|
||||||
Fm_apu_volume( &this->fm_apu, this->gain );
|
Fm_apu_volume( &this->fm_apu, this->gain );
|
||||||
|
|
||||||
// Setup buffer
|
// Setup buffer
|
||||||
this->clock_rate_ = clock_rate( this );
|
this->clock_rate_ = clock_rate( this );
|
||||||
Buffer_clock_rate( &this->stereo_buf, 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 ) );
|
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 );
|
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||||
|
|
||||||
Sound_set_tempo( this, this->tempo );
|
Sound_set_tempo( this, this->tempo );
|
||||||
Sound_mute_voices( this, this->mute_mask_ );
|
Sound_mute_voices( this, this->mute_mask_ );
|
||||||
return 0;
|
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 )
|
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 )
|
if ( i < sms_osc_count )
|
||||||
Sms_apu_set_output( &this->apu, i, c, l, r );
|
Sms_apu_set_output( &this->apu, i, c, l, r );
|
||||||
else
|
else
|
||||||
Fm_apu_set_output( &this->fm_apu, c );
|
Fm_apu_set_output( &this->fm_apu, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec )
|
static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec )
|
||||||
{
|
{
|
||||||
#if defined(ROCKBOX)
|
#if defined(ROCKBOX)
|
||||||
(void) msec;
|
(void) msec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cpu_time_t t = *duration;
|
cpu_time_t t = *duration;
|
||||||
while ( Z80_time( &this->cpu ) < t )
|
while ( Z80_time( &this->cpu ) < t )
|
||||||
{
|
{
|
||||||
cpu_time_t next = min( t, this->next_play );
|
cpu_time_t next = min( t, this->next_play );
|
||||||
if ( run_cpu( this, next ) )
|
if ( run_cpu( this, next ) )
|
||||||
{
|
{
|
||||||
/* warning( "Unsupported CPU instruction" ); */
|
/* warning( "Unsupported CPU instruction" ); */
|
||||||
Z80_set_time( &this->cpu, next );
|
Z80_set_time( &this->cpu, next );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this->cpu.r.pc == this->idle_addr )
|
if ( this->cpu.r.pc == this->idle_addr )
|
||||||
Z80_set_time( &this->cpu, next );
|
Z80_set_time( &this->cpu, next );
|
||||||
|
|
||||||
if ( Z80_time( &this->cpu ) >= this->next_play )
|
if ( Z80_time( &this->cpu ) >= this->next_play )
|
||||||
{
|
{
|
||||||
this->next_play += this->play_period;
|
this->next_play += this->play_period;
|
||||||
if ( this->cpu.r.pc == this->idle_addr )
|
if ( this->cpu.r.pc == this->idle_addr )
|
||||||
jsr( this, this->header.play_addr );
|
jsr( this, this->header.play_addr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->next_play -= t;
|
this->next_play -= t;
|
||||||
check( this->next_play >= 0 );
|
check( this->next_play >= 0 );
|
||||||
Z80_adjust_time( &this->cpu, -t );
|
Z80_adjust_time( &this->cpu, -t );
|
||||||
|
|
||||||
Sms_apu_end_frame( &this->apu, t );
|
Sms_apu_end_frame( &this->apu, t );
|
||||||
if ( sega_mapping( this ) && this->fm_accessed )
|
if ( sega_mapping( this ) && this->fm_accessed )
|
||||||
{
|
{
|
||||||
if ( Fm_apu_supported() )
|
if ( Fm_apu_supported() )
|
||||||
Fm_apu_end_frame( &this->fm_apu, t );
|
Fm_apu_end_frame( &this->fm_apu, t );
|
||||||
/* else
|
/* else
|
||||||
warning( "FM sound not supported" ); */
|
warning( "FM sound not supported" ); */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
|
|
||||||
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data )
|
void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data )
|
||||||
{
|
{
|
||||||
int port = addr & 0xFF;
|
int port = addr & 0xFF;
|
||||||
|
|
||||||
if ( sega_mapping( this ) )
|
if ( sega_mapping( this ) )
|
||||||
{
|
{
|
||||||
switch ( port )
|
switch ( port )
|
||||||
{
|
{
|
||||||
case 0x06:
|
case 0x06:
|
||||||
Sms_apu_write_ggstereo( &this->apu, time, data );
|
Sms_apu_write_ggstereo( &this->apu, time, data );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x7E:
|
case 0x7E:
|
||||||
case 0x7F:
|
case 0x7F:
|
||||||
Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */
|
Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0xF0:
|
case 0xF0:
|
||||||
this->fm_accessed = true;
|
this->fm_accessed = true;
|
||||||
if ( Fm_apu_supported() )
|
if ( Fm_apu_supported() )
|
||||||
Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data );
|
Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0xF1:
|
case 0xF1:
|
||||||
this->fm_accessed = true;
|
this->fm_accessed = true;
|
||||||
if ( Fm_apu_supported() )
|
if ( Fm_apu_supported() )
|
||||||
Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data );
|
Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( port >= 0xE0 )
|
else if ( port >= 0xE0 )
|
||||||
{
|
{
|
||||||
Sms_apu_write_data( &this->apu, time, data );
|
Sms_apu_write_data( &this->apu, time, data );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void jsr( struct Sgc_Emu* this, byte addr [2] )
|
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 >> 8;
|
||||||
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF;
|
*Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF;
|
||||||
this->cpu.r.pc = get_le16( addr );
|
this->cpu.r.pc = get_le16( addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_bank( struct Sgc_Emu* this, int bank, void const* data )
|
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 ) );
|
//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 );
|
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 )
|
void cpu_write( struct Sgc_Emu* this, addr_t addr, int data )
|
||||||
{
|
{
|
||||||
if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) )
|
if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) )
|
||||||
{
|
{
|
||||||
*Z80_write( &this->cpu, addr ) = data;
|
*Z80_write( &this->cpu, addr ) = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( addr )
|
switch ( addr )
|
||||||
{
|
{
|
||||||
case 0xFFFC:
|
case 0xFFFC:
|
||||||
Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 );
|
Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 );
|
||||||
if ( data & 0x08 )
|
if ( data & 0x08 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
this->bank2 = this->ram2;
|
this->bank2 = this->ram2;
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
|
|
||||||
case 0xFFFF: {
|
case 0xFFFF: {
|
||||||
bool rom_mapped = (Z80_read( &this->cpu, 2 * this->rom.bank_size ) == this->bank2);
|
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 );
|
this->bank2 = Rom_at_addr( &this->rom, data * this->rom.bank_size );
|
||||||
if ( rom_mapped )
|
if ( rom_mapped )
|
||||||
set_bank( this, 2, this->bank2 );
|
set_bank( this, 2, this->bank2 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xFFFD:
|
case 0xFFFD:
|
||||||
set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFFFE:
|
case 0xFFFE:
|
||||||
set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int rate )
|
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
|
require( !this->sample_rate ); // sample rate can't be changed once set
|
||||||
Buffer_init( &this->stereo_buf );
|
Buffer_init( &this->stereo_buf );
|
||||||
Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 );
|
Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 );
|
||||||
|
|
||||||
// Set buffer bass
|
// Set buffer bass
|
||||||
Buffer_bass_freq( &this->stereo_buf, 80 );
|
Buffer_bass_freq( &this->stereo_buf, 80 );
|
||||||
|
|
||||||
this->sample_rate = rate;
|
this->sample_rate = rate;
|
||||||
RETURN_ERR( track_init( &this->track_filter, this ) );
|
RETURN_ERR( track_init( &this->track_filter, this ) );
|
||||||
this->tfilter.max_silence = 6 * stereo * this->sample_rate;
|
this->tfilter.max_silence = 6 * stereo * this->sample_rate;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute )
|
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute )
|
||||||
{
|
{
|
||||||
require( (unsigned) index < (unsigned) this->voice_count );
|
require( (unsigned) index < (unsigned) this->voice_count );
|
||||||
int bit = 1 << index;
|
int bit = 1 << index;
|
||||||
int mask = this->mute_mask_ | bit;
|
int mask = this->mute_mask_ | bit;
|
||||||
if ( !mute )
|
if ( !mute )
|
||||||
mask ^= bit;
|
mask ^= bit;
|
||||||
Sound_mute_voices( this, mask );
|
Sound_mute_voices( this, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask )
|
void Sound_mute_voices( struct Sgc_Emu* this, int mask )
|
||||||
{
|
{
|
||||||
require( this->sample_rate ); // sample rate must be set first
|
require( this->sample_rate ); // sample rate must be set first
|
||||||
this->mute_mask_ = mask;
|
this->mute_mask_ = mask;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for ( i = this->voice_count; i--; )
|
for ( i = this->voice_count; i--; )
|
||||||
{
|
{
|
||||||
if ( mask & (1 << i) )
|
if ( mask & (1 << i) )
|
||||||
{
|
{
|
||||||
Sound_set_voice( this, i, 0, 0, 0 );
|
Sound_set_voice( this, i, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct channel_t ch = Buffer_channel( &this->stereo_buf, i );
|
struct channel_t ch = Buffer_channel( &this->stereo_buf, i );
|
||||||
assert( (ch.center && ch.left && ch.right) ||
|
assert( (ch.center && ch.left && ch.right) ||
|
||||||
(!ch.center && !ch.left && !ch.right) ); // all or nothing
|
(!ch.center && !ch.left && !ch.right) ); // all or nothing
|
||||||
Sound_set_voice( this, i, ch.center, ch.left, ch.right );
|
Sound_set_voice( this, i, ch.center, ch.left, ch.right );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound_set_tempo( struct Sgc_Emu* this, int t )
|
void Sound_set_tempo( struct Sgc_Emu* this, int t )
|
||||||
{
|
{
|
||||||
require( this->sample_rate ); // sample rate must be set first
|
require( this->sample_rate ); // sample rate must be set first
|
||||||
int const min = (int)(FP_ONE_TEMPO*0.02);
|
int const min = (int)(FP_ONE_TEMPO*0.02);
|
||||||
int const max = (int)(FP_ONE_TEMPO*4.00);
|
int const max = (int)(FP_ONE_TEMPO*4.00);
|
||||||
if ( t < min ) t = min;
|
if ( t < min ) t = min;
|
||||||
if ( t > max ) t = max;
|
if ( t > max ) t = max;
|
||||||
this->tempo = t;
|
this->tempo = t;
|
||||||
|
|
||||||
this->play_period = (int) ((clock_rate( this ) * FP_ONE_TEMPO) / (this->header.rate ? 50 : 60) / 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 )
|
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track )
|
||||||
{
|
{
|
||||||
clear_track_vars( this );
|
clear_track_vars( this );
|
||||||
|
|
||||||
// Remap track if playlist available
|
// Remap track if playlist available
|
||||||
if ( this->m3u.size > 0 ) {
|
if ( this->m3u.size > 0 ) {
|
||||||
struct entry_t* e = &this->m3u.entries[track];
|
struct entry_t* e = &this->m3u.entries[track];
|
||||||
track = e->track;
|
track = e->track;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->current_track = track;
|
this->current_track = track;
|
||||||
|
|
||||||
if ( sega_mapping( this ) )
|
if ( sega_mapping( this ) )
|
||||||
{
|
{
|
||||||
Sms_apu_reset( &this->apu, 0, 0 );
|
Sms_apu_reset( &this->apu, 0, 0 );
|
||||||
Fm_apu_reset( &this->fm_apu );
|
Fm_apu_reset( &this->fm_apu );
|
||||||
this->fm_accessed = false;
|
this->fm_accessed = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Sms_apu_reset( &this->apu, 0x0003, 15 );
|
Sms_apu_reset( &this->apu, 0x0003, 15 );
|
||||||
}
|
}
|
||||||
|
|
||||||
memset( this->ram , 0, sizeof this->ram );
|
memset( this->ram , 0, sizeof this->ram );
|
||||||
memset( this->ram2, 0, sizeof this->ram2 );
|
memset( this->ram2, 0, sizeof this->ram2 );
|
||||||
memset( this->vectors, 0xFF, sizeof this->vectors );
|
memset( this->vectors, 0xFF, sizeof this->vectors );
|
||||||
Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped );
|
Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped );
|
||||||
|
|
||||||
if ( sega_mapping( this ) )
|
if ( sega_mapping( this ) )
|
||||||
{
|
{
|
||||||
this->vectors_addr = 0x10000 - page_size;
|
this->vectors_addr = 0x10000 - page_size;
|
||||||
this->idle_addr = this->vectors_addr;
|
this->idle_addr = this->vectors_addr;
|
||||||
int i;
|
int i;
|
||||||
for ( i = 1; i < 8; ++i )
|
for ( i = 1; i < 8; ++i )
|
||||||
{
|
{
|
||||||
this->vectors [i*8 + 0] = 0xC3; // JP addr
|
this->vectors [i*8 + 0] = 0xC3; // JP addr
|
||||||
this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff;
|
this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff;
|
||||||
this->vectors [i*8 + 2] = this->header.rst_addrs [i - 1] >> 8;
|
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_rw( &this->cpu, 0xC000, 0x2000, this->ram );
|
||||||
Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors );
|
Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors );
|
||||||
|
|
||||||
this->bank2 = NULL;
|
this->bank2 = NULL;
|
||||||
for ( i = 0; i < 4; ++i )
|
for ( i = 0; i < 4; ++i )
|
||||||
cpu_write( this, 0xFFFC + i, this->header.mapping [i] );
|
cpu_write( this, 0xFFFC + i, this->header.mapping [i] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !this->coleco_bios )
|
if ( !this->coleco_bios )
|
||||||
return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */
|
return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */
|
||||||
|
|
||||||
this->vectors_addr = 0;
|
this->vectors_addr = 0;
|
||||||
Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios );
|
Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios );
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < 8; ++i )
|
for ( i = 0; i < 8; ++i )
|
||||||
Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram );
|
Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram );
|
||||||
|
|
||||||
this->idle_addr = 0x2000;
|
this->idle_addr = 0x2000;
|
||||||
Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors );
|
Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors );
|
||||||
|
|
||||||
for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i )
|
for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i )
|
||||||
{
|
{
|
||||||
int addr = 0x8000 + i*this->rom.bank_size;
|
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 ) );
|
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.sp = get_le16( this->header.stack_ptr );
|
||||||
this->cpu.r.b.a = track;
|
this->cpu.r.b.a = track;
|
||||||
this->next_play = this->play_period;
|
this->next_play = this->play_period;
|
||||||
|
|
||||||
jsr( this, this->header.init_addr );
|
jsr( this, this->header.init_addr );
|
||||||
|
|
||||||
Buffer_clear( &this->stereo_buf );
|
Buffer_clear( &this->stereo_buf );
|
||||||
|
|
||||||
// convert filter times to samples
|
// convert filter times to samples
|
||||||
struct setup_t s = this->tfilter;
|
struct setup_t s = this->tfilter;
|
||||||
s.max_initial *= this->sample_rate * stereo;
|
s.max_initial *= this->sample_rate * stereo;
|
||||||
#ifdef GME_DISABLE_SILENCE_LOOKAHEAD
|
#ifdef GME_DISABLE_SILENCE_LOOKAHEAD
|
||||||
s.lookahead = 1;
|
s.lookahead = 1;
|
||||||
#endif
|
#endif
|
||||||
track_setup( &this->track_filter, &s );
|
track_setup( &this->track_filter, &s );
|
||||||
|
|
||||||
return track_start( &this->track_filter );
|
return track_start( &this->track_filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell/Seek
|
// Tell/Seek
|
||||||
|
|
||||||
static int msec_to_samples( int msec, int sample_rate )
|
static int msec_to_samples( int msec, int sample_rate )
|
||||||
{
|
{
|
||||||
int sec = msec / 1000;
|
int sec = msec / 1000;
|
||||||
msec -= sec * 1000;
|
msec -= sec * 1000;
|
||||||
return (sec * sample_rate + msec * sample_rate / 1000) * stereo;
|
return (sec * sample_rate + msec * sample_rate / 1000) * stereo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Track_tell( struct Sgc_Emu* this )
|
int Track_tell( struct Sgc_Emu* this )
|
||||||
{
|
{
|
||||||
int rate = this->sample_rate * stereo;
|
int rate = this->sample_rate * stereo;
|
||||||
int sec = track_sample_count( &this->track_filter ) / rate;
|
int sec = track_sample_count( &this->track_filter ) / rate;
|
||||||
return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / 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 )
|
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec )
|
||||||
{
|
{
|
||||||
int time = msec_to_samples( msec, this->sample_rate );
|
int time = msec_to_samples( msec, this->sample_rate );
|
||||||
if ( time < track_sample_count( &this->track_filter ) )
|
if ( time < track_sample_count( &this->track_filter ) )
|
||||||
RETURN_ERR( Sgc_start_track( this, this->current_track ) );
|
RETURN_ERR( Sgc_start_track( this, this->current_track ) );
|
||||||
return Track_skip( this, time - track_sample_count( &this->track_filter ) );
|
return Track_skip( this, time - track_sample_count( &this->track_filter ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int count )
|
blargg_err_t Track_skip( struct Sgc_Emu* this, int count )
|
||||||
{
|
{
|
||||||
require( this->current_track >= 0 ); // start_track() must have been called already
|
require( this->current_track >= 0 ); // start_track() must have been called already
|
||||||
return track_skip( &this->track_filter, count );
|
return track_skip( &this->track_filter, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t skip_( void* emu, int count )
|
blargg_err_t skip_( void* emu, int count )
|
||||||
{
|
{
|
||||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||||
|
|
||||||
// for long skip, mute sound
|
// for long skip, mute sound
|
||||||
const int threshold = 32768;
|
const int threshold = 32768;
|
||||||
if ( count > threshold )
|
if ( count > threshold )
|
||||||
{
|
{
|
||||||
int saved_mute = this->mute_mask_;
|
int saved_mute = this->mute_mask_;
|
||||||
Sound_mute_voices( this, ~0 );
|
Sound_mute_voices( this, ~0 );
|
||||||
|
|
||||||
int n = count - threshold/2;
|
int n = count - threshold/2;
|
||||||
n &= ~(2048-1); // round to multiple of 2048
|
n &= ~(2048-1); // round to multiple of 2048
|
||||||
count -= n;
|
count -= n;
|
||||||
RETURN_ERR( skippy_( &this->track_filter, n ) );
|
RETURN_ERR( skippy_( &this->track_filter, n ) );
|
||||||
|
|
||||||
Sound_mute_voices( this, saved_mute );
|
Sound_mute_voices( this, saved_mute );
|
||||||
}
|
}
|
||||||
|
|
||||||
return skippy_( &this->track_filter, count );
|
return skippy_( &this->track_filter, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec )
|
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 ),
|
track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ),
|
||||||
length_msec * this->sample_rate / (1000 / stereo) );
|
length_msec * this->sample_rate / (1000 / stereo) );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out )
|
blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out )
|
||||||
{
|
{
|
||||||
require( this->current_track >= 0 );
|
require( this->current_track >= 0 );
|
||||||
require( out_count % stereo == 0 );
|
require( out_count % stereo == 0 );
|
||||||
return track_play( &this->track_filter, out_count, out );
|
return track_play( &this->track_filter, out_count, out );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t play_( void* emu, int count, sample_t out [] )
|
blargg_err_t play_( void* emu, int count, sample_t out [] )
|
||||||
{
|
{
|
||||||
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
struct Sgc_Emu* this = (struct Sgc_Emu*) emu;
|
||||||
|
|
||||||
int remain = count;
|
int remain = count;
|
||||||
while ( remain )
|
while ( remain )
|
||||||
{
|
{
|
||||||
Buffer_disable_immediate_removal( &this->stereo_buf );
|
Buffer_disable_immediate_removal( &this->stereo_buf );
|
||||||
remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain );
|
remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain );
|
||||||
if ( remain )
|
if ( remain )
|
||||||
{
|
{
|
||||||
if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) )
|
if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) )
|
||||||
{
|
{
|
||||||
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
|
||||||
|
|
||||||
// Remute voices
|
// Remute voices
|
||||||
Sound_mute_voices( this, this->mute_mask_ );
|
Sound_mute_voices( this, this->mute_mask_ );
|
||||||
}
|
}
|
||||||
int msec = Buffer_length( &this->stereo_buf );
|
int msec = Buffer_length( &this->stereo_buf );
|
||||||
blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100;
|
blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100;
|
||||||
RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) );
|
RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) );
|
||||||
assert( clocks_emulated );
|
assert( clocks_emulated );
|
||||||
Buffer_end_frame( &this->stereo_buf, clocks_emulated );
|
Buffer_end_frame( &this->stereo_buf, clocks_emulated );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,195 +1,195 @@
|
||||||
// Sega/Game Gear/Coleco SGC music file emulator
|
// Sega/Game Gear/Coleco SGC music file emulator
|
||||||
|
|
||||||
// Game_Music_Emu 0.6-pre
|
// Game_Music_Emu 0.6-pre
|
||||||
#ifndef SGC_EMU_H
|
#ifndef SGC_EMU_H
|
||||||
#define SGC_EMU_H
|
#define SGC_EMU_H
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
#include "multi_buffer.h"
|
#include "multi_buffer.h"
|
||||||
|
|
||||||
#include "rom_data.h"
|
#include "rom_data.h"
|
||||||
#include "z80_cpu.h"
|
#include "z80_cpu.h"
|
||||||
#include "sms_fm_apu.h"
|
#include "sms_fm_apu.h"
|
||||||
#include "sms_apu.h"
|
#include "sms_apu.h"
|
||||||
#include "m3u_playlist.h"
|
#include "m3u_playlist.h"
|
||||||
#include "track_filter.h"
|
#include "track_filter.h"
|
||||||
|
|
||||||
typedef struct Z80_Cpu Sgc_Cpu;
|
typedef struct Z80_Cpu Sgc_Cpu;
|
||||||
|
|
||||||
// SGC file header
|
// SGC file header
|
||||||
enum { header_size = 0xA0 };
|
enum { header_size = 0xA0 };
|
||||||
struct header_t
|
struct header_t
|
||||||
{
|
{
|
||||||
char tag [4]; // "SGC\x1A"
|
char tag [4]; // "SGC\x1A"
|
||||||
byte vers; // 0x01
|
byte vers; // 0x01
|
||||||
byte rate; // 0=NTSC 1=PAL
|
byte rate; // 0=NTSC 1=PAL
|
||||||
byte reserved1 [2];
|
byte reserved1 [2];
|
||||||
byte load_addr [2];
|
byte load_addr [2];
|
||||||
byte init_addr [2];
|
byte init_addr [2];
|
||||||
byte play_addr [2];
|
byte play_addr [2];
|
||||||
byte stack_ptr [2];
|
byte stack_ptr [2];
|
||||||
byte reserved2 [2];
|
byte reserved2 [2];
|
||||||
byte rst_addrs [7*2];
|
byte rst_addrs [7*2];
|
||||||
byte mapping [4]; // Used by Sega only
|
byte mapping [4]; // Used by Sega only
|
||||||
byte first_song; // Song to start playing first
|
byte first_song; // Song to start playing first
|
||||||
byte song_count;
|
byte song_count;
|
||||||
byte first_effect;
|
byte first_effect;
|
||||||
byte last_effect;
|
byte last_effect;
|
||||||
byte system; // 0=Master System 1=Game Gear 2=Colecovision
|
byte system; // 0=Master System 1=Game Gear 2=Colecovision
|
||||||
byte reserved3 [23];
|
byte reserved3 [23];
|
||||||
char game [32]; // strings can be 32 chars, NOT terminated
|
char game [32]; // strings can be 32 chars, NOT terminated
|
||||||
char author [32];
|
char author [32];
|
||||||
char copyright [32];
|
char copyright [32];
|
||||||
};
|
};
|
||||||
|
|
||||||
// True if header has valid file signature
|
// True if header has valid file signature
|
||||||
static inline bool valid_tag( struct header_t* h )
|
static inline bool valid_tag( struct header_t* h )
|
||||||
{
|
{
|
||||||
return 0 == memcmp( h->tag, "SGC\x1A", 4 );
|
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; }
|
static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; }
|
||||||
|
|
||||||
struct Sgc_Emu {
|
struct Sgc_Emu {
|
||||||
bool fm_accessed;
|
bool fm_accessed;
|
||||||
|
|
||||||
cpu_time_t play_period;
|
cpu_time_t play_period;
|
||||||
cpu_time_t next_play;
|
cpu_time_t next_play;
|
||||||
void const* bank2; // ROM selected for bank 2, in case RAM is currently hiding it
|
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 vectors_addr; // RST vectors start here
|
||||||
addr_t idle_addr; // return address for init/play routines
|
addr_t idle_addr; // return address for init/play routines
|
||||||
void* coleco_bios;
|
void* coleco_bios;
|
||||||
|
|
||||||
// general
|
// general
|
||||||
int voice_count;
|
int voice_count;
|
||||||
int const* voice_types;
|
int const* voice_types;
|
||||||
int mute_mask_;
|
int mute_mask_;
|
||||||
int tempo;
|
int tempo;
|
||||||
int gain;
|
int gain;
|
||||||
|
|
||||||
int sample_rate;
|
int sample_rate;
|
||||||
|
|
||||||
// track-specific
|
// track-specific
|
||||||
int current_track;
|
int current_track;
|
||||||
int track_count;
|
int track_count;
|
||||||
|
|
||||||
int clock_rate_;
|
int clock_rate_;
|
||||||
unsigned buf_changed_count;
|
unsigned buf_changed_count;
|
||||||
|
|
||||||
// M3u Playlist
|
// M3u Playlist
|
||||||
struct M3u_Playlist m3u;
|
struct M3u_Playlist m3u;
|
||||||
struct header_t header;
|
struct header_t header;
|
||||||
|
|
||||||
struct setup_t tfilter;
|
struct setup_t tfilter;
|
||||||
struct Track_Filter track_filter;
|
struct Track_Filter track_filter;
|
||||||
|
|
||||||
struct Multi_Buffer stereo_buf;
|
struct Multi_Buffer stereo_buf;
|
||||||
|
|
||||||
struct Sms_Apu apu;
|
struct Sms_Apu apu;
|
||||||
struct Sms_Fm_Apu fm_apu;
|
struct Sms_Fm_Apu fm_apu;
|
||||||
|
|
||||||
Sgc_Cpu cpu;
|
Sgc_Cpu cpu;
|
||||||
|
|
||||||
// large items
|
// large items
|
||||||
struct Rom_Data rom;
|
struct Rom_Data rom;
|
||||||
byte vectors [page_size + page_padding];
|
byte vectors [page_size + page_padding];
|
||||||
byte unmapped_write [0x4000];
|
byte unmapped_write [0x4000];
|
||||||
byte ram [0x2000 + page_padding];
|
byte ram [0x2000 + page_padding];
|
||||||
byte ram2 [0x4000 + page_padding];
|
byte ram2 [0x4000 + page_padding];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic functionality (see Gme_File.h for file loading/track info functions)
|
// Basic functionality (see Gme_File.h for file loading/track info functions)
|
||||||
|
|
||||||
void Sgc_init( struct Sgc_Emu* this );
|
void Sgc_init( struct Sgc_Emu* this );
|
||||||
|
|
||||||
blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size );
|
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; }
|
static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; }
|
||||||
|
|
||||||
// 0x2000 bytes
|
// 0x2000 bytes
|
||||||
static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; }
|
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.
|
// 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 );
|
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.
|
// 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 );
|
blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track );
|
||||||
|
|
||||||
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
|
// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation
|
||||||
// errors set warning string, and major errors also end track.
|
// errors set warning string, and major errors also end track.
|
||||||
blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf );
|
blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf );
|
||||||
|
|
||||||
// Track status/control
|
// Track status/control
|
||||||
|
|
||||||
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
|
// Number of milliseconds (1000 msec = 1 second) played since beginning of track
|
||||||
int Track_tell( struct Sgc_Emu* this );
|
int Track_tell( struct Sgc_Emu* this );
|
||||||
|
|
||||||
// Seek to new time in track. Seeking backwards or far forward can take a while.
|
// 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 );
|
blargg_err_t Track_seek( struct Sgc_Emu* this, int msec );
|
||||||
|
|
||||||
// Skip n samples
|
// Skip n samples
|
||||||
blargg_err_t Track_skip( struct Sgc_Emu* this, int n );
|
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
|
// 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.
|
// true. Fade time can be changed while track is playing.
|
||||||
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec );
|
void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec );
|
||||||
|
|
||||||
// True if a track has reached its end
|
// True if a track has reached its end
|
||||||
static inline bool Track_ended( struct Sgc_Emu* this )
|
static inline bool Track_ended( struct Sgc_Emu* this )
|
||||||
{
|
{
|
||||||
return track_ended( &this->track_filter );
|
return track_ended( &this->track_filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disables automatic end-of-track detection and skipping of silence at beginning
|
// Disables automatic end-of-track detection and skipping of silence at beginning
|
||||||
static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable )
|
static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable )
|
||||||
{
|
{
|
||||||
this->track_filter.silence_ignored_ = disable;
|
this->track_filter.silence_ignored_ = disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get track length in milliseconds
|
// Get track length in milliseconds
|
||||||
static inline int Track_get_length( struct Sgc_Emu* this, int n )
|
static inline int Track_get_length( struct Sgc_Emu* this, int n )
|
||||||
{
|
{
|
||||||
int length = 120 * 1000; /* 2 minutes */
|
int length = 120 * 1000; /* 2 minutes */
|
||||||
if ( (this->m3u.size > 0) && (n < this->m3u.size) ) {
|
if ( (this->m3u.size > 0) && (n < this->m3u.size) ) {
|
||||||
struct entry_t* entry = &this->m3u.entries [n];
|
struct entry_t* entry = &this->m3u.entries [n];
|
||||||
length = entry->length;
|
length = entry->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sound customization
|
// Sound customization
|
||||||
|
|
||||||
// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed.
|
// 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.
|
// Track length as returned by track_info() assumes a tempo of 1.0.
|
||||||
void Sound_set_tempo( struct Sgc_Emu* this, int t );
|
void Sound_set_tempo( struct Sgc_Emu* this, int t );
|
||||||
|
|
||||||
// Mute/unmute voice i, where voice 0 is first voice
|
// Mute/unmute voice i, where voice 0 is first voice
|
||||||
void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute );
|
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,
|
// 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.
|
// 0 unmutes them all, 0x01 mutes just the first voice, etc.
|
||||||
void Sound_mute_voices( struct Sgc_Emu* this, int mask );
|
void Sound_mute_voices( struct Sgc_Emu* this, int mask );
|
||||||
|
|
||||||
// Change overall output amplitude, where 1.0 results in minimal clamping.
|
// Change overall output amplitude, where 1.0 results in minimal clamping.
|
||||||
// Must be called before set_sample_rate().
|
// Must be called before set_sample_rate().
|
||||||
static inline void Sound_set_gain( struct Sgc_Emu* this, int g )
|
static inline void Sound_set_gain( struct Sgc_Emu* this, int g )
|
||||||
{
|
{
|
||||||
assert( !this->sample_rate ); // you must set gain before setting sample rate
|
assert( !this->sample_rate ); // you must set gain before setting sample rate
|
||||||
this->gain = g;
|
this->gain = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if Master System or Game Gear
|
// True if Master System or Game Gear
|
||||||
static inline bool sega_mapping( struct Sgc_Emu* this )
|
static inline bool sega_mapping( struct Sgc_Emu* this )
|
||||||
{
|
{
|
||||||
return this->header.system <= 1;
|
return this->header.system <= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emulation (You shouldn't touch these)
|
// Emulation (You shouldn't touch these)
|
||||||
|
|
||||||
bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time );
|
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_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 cpu_write( struct Sgc_Emu* this, addr_t addr, int data );
|
||||||
void jsr( struct Sgc_Emu* this, byte addr [2] );
|
void jsr( struct Sgc_Emu* this, byte addr [2] );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,82 +1,82 @@
|
||||||
#include "sms_fm_apu.h"
|
#include "sms_fm_apu.h"
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
void Fm_apu_create( struct Sms_Fm_Apu* this )
|
void Fm_apu_create( struct Sms_Fm_Apu* this )
|
||||||
{
|
{
|
||||||
Synth_init( &this->synth );
|
Synth_init( &this->synth );
|
||||||
Ym2413_init( &this->apu );
|
Ym2413_init( &this->apu );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate )
|
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);
|
this->period_ = (blip_time_t) (clock_rate / sample_rate);
|
||||||
CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) );
|
CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) );
|
||||||
|
|
||||||
Fm_apu_set_output( this, 0 );
|
Fm_apu_set_output( this, 0 );
|
||||||
Fm_apu_volume( this, (int)FP_ONE_VOLUME );
|
Fm_apu_volume( this, (int)FP_ONE_VOLUME );
|
||||||
Fm_apu_reset( this );
|
Fm_apu_reset( this );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fm_apu_reset( struct Sms_Fm_Apu* this )
|
void Fm_apu_reset( struct Sms_Fm_Apu* this )
|
||||||
{
|
{
|
||||||
this->addr = 0;
|
this->addr = 0;
|
||||||
this->next_time = 0;
|
this->next_time = 0;
|
||||||
this->last_amp = 0;
|
this->last_amp = 0;
|
||||||
|
|
||||||
Ym2413_reset( &this->apu );
|
Ym2413_reset( &this->apu );
|
||||||
}
|
}
|
||||||
|
|
||||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time );
|
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 )
|
void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t time, int data )
|
||||||
{
|
{
|
||||||
if ( time > this->next_time )
|
if ( time > this->next_time )
|
||||||
fm_run_until( this, time );
|
fm_run_until( this, time );
|
||||||
|
|
||||||
Ym2413_write( &this->apu, this->addr, data );
|
Ym2413_write( &this->apu, this->addr, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time )
|
void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time )
|
||||||
{
|
{
|
||||||
assert( end_time > this->next_time );
|
assert( end_time > this->next_time );
|
||||||
|
|
||||||
struct Blip_Buffer* const output = this->output_;
|
struct Blip_Buffer* const output = this->output_;
|
||||||
if ( !output )
|
if ( !output )
|
||||||
{
|
{
|
||||||
this->next_time = end_time;
|
this->next_time = end_time;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blip_time_t time = this->next_time;
|
blip_time_t time = this->next_time;
|
||||||
struct Ym2413_Emu* emu = &this->apu;
|
struct Ym2413_Emu* emu = &this->apu;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
short samples [2];
|
short samples [2];
|
||||||
Ym2413_run( emu, 1, samples );
|
Ym2413_run( emu, 1, samples );
|
||||||
int amp = (samples [0] + samples [1]) >> 1;
|
int amp = (samples [0] + samples [1]) >> 1;
|
||||||
|
|
||||||
int delta = amp - this->last_amp;
|
int delta = amp - this->last_amp;
|
||||||
if ( delta )
|
if ( delta )
|
||||||
{
|
{
|
||||||
this->last_amp = amp;
|
this->last_amp = amp;
|
||||||
Synth_offset_inline( &this->synth, time, delta, output );
|
Synth_offset_inline( &this->synth, time, delta, output );
|
||||||
}
|
}
|
||||||
time += this->period_;
|
time += this->period_;
|
||||||
}
|
}
|
||||||
while ( time < end_time );
|
while ( time < end_time );
|
||||||
|
|
||||||
this->next_time = time;
|
this->next_time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time )
|
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time )
|
||||||
{
|
{
|
||||||
if ( time > this->next_time )
|
if ( time > this->next_time )
|
||||||
fm_run_until( this, time );
|
fm_run_until( this, time );
|
||||||
|
|
||||||
this->next_time -= time;
|
this->next_time -= time;
|
||||||
assert( this->next_time >= 0 );
|
assert( this->next_time >= 0 );
|
||||||
|
|
||||||
if ( this->output_ )
|
if ( this->output_ )
|
||||||
Blip_set_modified( this->output_ );
|
Blip_set_modified( this->output_ );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,43 @@
|
||||||
#ifndef SMS_FM_APU_H
|
#ifndef SMS_FM_APU_H
|
||||||
#define SMS_FM_APU_H
|
#define SMS_FM_APU_H
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
#include "blip_buffer.h"
|
#include "blip_buffer.h"
|
||||||
#include "ym2413_emu.h"
|
#include "ym2413_emu.h"
|
||||||
|
|
||||||
enum { fm_apu_osc_count = 1 };
|
enum { fm_apu_osc_count = 1 };
|
||||||
|
|
||||||
struct Sms_Fm_Apu {
|
struct Sms_Fm_Apu {
|
||||||
struct Blip_Buffer* output_;
|
struct Blip_Buffer* output_;
|
||||||
blip_time_t next_time;
|
blip_time_t next_time;
|
||||||
int last_amp;
|
int last_amp;
|
||||||
int addr;
|
int addr;
|
||||||
|
|
||||||
int clock_;
|
int clock_;
|
||||||
int rate_;
|
int rate_;
|
||||||
blip_time_t period_;
|
blip_time_t period_;
|
||||||
|
|
||||||
struct Blip_Synth synth;
|
struct Blip_Synth synth;
|
||||||
struct Ym2413_Emu apu;
|
struct Ym2413_Emu apu;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Fm_apu_create( struct Sms_Fm_Apu* this );
|
void Fm_apu_create( struct Sms_Fm_Apu* this );
|
||||||
|
|
||||||
static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); }
|
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 );
|
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 )
|
static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b )
|
||||||
{
|
{
|
||||||
this->output_ = 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 ); }
|
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 );
|
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; }
|
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_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 );
|
void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t t );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,294 +1,294 @@
|
||||||
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "track_filter.h"
|
#include "track_filter.h"
|
||||||
|
|
||||||
/* Copyright (C) 2003-2008 Shay Green. This module is free software; you
|
/* 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
|
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
|
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
|
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
|
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
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
|
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,
|
License along with this module; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
|
|
||||||
int const fade_block_size = 512;
|
int const fade_block_size = 512;
|
||||||
int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift)
|
int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift)
|
||||||
int const silence_threshold = 8;
|
int const silence_threshold = 8;
|
||||||
|
|
||||||
void track_create( struct Track_Filter* this )
|
void track_create( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
this->emu_ = NULL;
|
this->emu_ = NULL;
|
||||||
this->setup_.max_initial = 0;
|
this->setup_.max_initial = 0;
|
||||||
this->setup_.lookahead = 0;
|
this->setup_.lookahead = 0;
|
||||||
this->setup_.max_silence = indefinite_count;
|
this->setup_.max_silence = indefinite_count;
|
||||||
this->silence_ignored_ = false;
|
this->silence_ignored_ = false;
|
||||||
track_stop( this );
|
track_stop( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t track_init( struct Track_Filter* this, void* emu )
|
blargg_err_t track_init( struct Track_Filter* this, void* emu )
|
||||||
{
|
{
|
||||||
this->emu_ = emu;
|
this->emu_ = emu;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_time_vars( struct Track_Filter* this )
|
static void clear_time_vars( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
this->emu_time = this->buf_remain;
|
this->emu_time = this->buf_remain;
|
||||||
this->out_time = 0;
|
this->out_time = 0;
|
||||||
this->silence_time = 0;
|
this->silence_time = 0;
|
||||||
this->silence_count = 0;
|
this->silence_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void track_stop( struct Track_Filter* this )
|
void track_stop( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
this->emu_track_ended_ = true;
|
this->emu_track_ended_ = true;
|
||||||
this->track_ended_ = true;
|
this->track_ended_ = true;
|
||||||
this->fade_start = indefinite_count;
|
this->fade_start = indefinite_count;
|
||||||
this->fade_step = 1;
|
this->fade_step = 1;
|
||||||
this->buf_remain = 0;
|
this->buf_remain = 0;
|
||||||
this->emu_error = NULL;
|
this->emu_error = NULL;
|
||||||
clear_time_vars( this );
|
clear_time_vars( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t track_start( struct Track_Filter* this )
|
blargg_err_t track_start( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
this->emu_error = NULL;
|
this->emu_error = NULL;
|
||||||
track_stop( this );
|
track_stop( this );
|
||||||
|
|
||||||
this->emu_track_ended_ = false;
|
this->emu_track_ended_ = false;
|
||||||
this->track_ended_ = false;
|
this->track_ended_ = false;
|
||||||
|
|
||||||
if ( !this->silence_ignored_ )
|
if ( !this->silence_ignored_ )
|
||||||
{
|
{
|
||||||
// play until non-silence or end of track
|
// play until non-silence or end of track
|
||||||
while ( this->emu_time < this->setup_.max_initial )
|
while ( this->emu_time < this->setup_.max_initial )
|
||||||
{
|
{
|
||||||
fill_buf( this );
|
fill_buf( this );
|
||||||
if ( this->buf_remain | this->emu_track_ended_ )
|
if ( this->buf_remain | this->emu_track_ended_ )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_time_vars( this );
|
clear_time_vars( this );
|
||||||
return this->emu_error;
|
return this->emu_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_track_if_error( struct Track_Filter* this, blargg_err_t err )
|
static void end_track_if_error( struct Track_Filter* this, blargg_err_t err )
|
||||||
{
|
{
|
||||||
if ( err )
|
if ( err )
|
||||||
{
|
{
|
||||||
this->emu_error = err;
|
this->emu_error = err;
|
||||||
this->emu_track_ended_ = true;
|
this->emu_track_ended_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t track_skip( struct Track_Filter* this, int count )
|
blargg_err_t track_skip( struct Track_Filter* this, int count )
|
||||||
{
|
{
|
||||||
this->emu_error = NULL;
|
this->emu_error = NULL;
|
||||||
this->out_time += count;
|
this->out_time += count;
|
||||||
|
|
||||||
// remove from silence and buf first
|
// remove from silence and buf first
|
||||||
{
|
{
|
||||||
int n = min( count, this->silence_count );
|
int n = min( count, this->silence_count );
|
||||||
this->silence_count -= n;
|
this->silence_count -= n;
|
||||||
count -= n;
|
count -= n;
|
||||||
|
|
||||||
n = min( count, this->buf_remain );
|
n = min( count, this->buf_remain );
|
||||||
this->buf_remain -= n;
|
this->buf_remain -= n;
|
||||||
count -= n;
|
count -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count && !this->emu_track_ended_ )
|
if ( count && !this->emu_track_ended_ )
|
||||||
{
|
{
|
||||||
this->emu_time += count;
|
this->emu_time += count;
|
||||||
this->silence_time = this->emu_time; // would otherwise be invalid
|
this->silence_time = this->emu_time; // would otherwise be invalid
|
||||||
end_track_if_error( this, skip_( this->emu_, count ) );
|
end_track_if_error( this, skip_( this->emu_, count ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended
|
if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended
|
||||||
this->track_ended_ |= this->emu_track_ended_;
|
this->track_ended_ |= this->emu_track_ended_;
|
||||||
|
|
||||||
return this->emu_error;
|
return this->emu_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t skippy_( struct Track_Filter* this, int count )
|
blargg_err_t skippy_( struct Track_Filter* this, int count )
|
||||||
{
|
{
|
||||||
while ( count && !this->emu_track_ended_ )
|
while ( count && !this->emu_track_ended_ )
|
||||||
{
|
{
|
||||||
int n = buf_size;
|
int n = buf_size;
|
||||||
if ( n > count )
|
if ( n > count )
|
||||||
n = count;
|
n = count;
|
||||||
count -= n;
|
count -= n;
|
||||||
RETURN_ERR( play_( this->emu_, n, this->buf ) );
|
RETURN_ERR( play_( this->emu_, n, this->buf ) );
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fading
|
// Fading
|
||||||
|
|
||||||
void track_set_fade( struct Track_Filter* this, int start, int length )
|
void track_set_fade( struct Track_Filter* this, int start, int length )
|
||||||
{
|
{
|
||||||
this->fade_start = start;
|
this->fade_start = start;
|
||||||
this->fade_step = length / (fade_block_size * fade_shift);
|
this->fade_step = length / (fade_block_size * fade_shift);
|
||||||
if ( this->fade_step < 1 )
|
if ( this->fade_step < 1 )
|
||||||
this->fade_step = 1;
|
this->fade_step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_fading( struct Track_Filter* this )
|
static bool is_fading( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
return this->out_time >= this->fade_start && this->fade_start != indefinite_count;
|
return this->out_time >= this->fade_start && this->fade_start != indefinite_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unit / pow( 2.0, (double) x / step )
|
// unit / pow( 2.0, (double) x / step )
|
||||||
static int int_log( int x, int step, int unit )
|
static int int_log( int x, int step, int unit )
|
||||||
{
|
{
|
||||||
int shift = x / step;
|
int shift = x / step;
|
||||||
int fraction = (x - shift * step) * unit / step;
|
int fraction = (x - shift * step) * unit / step;
|
||||||
return ((unit - fraction) + (fraction >> 1)) >> shift;
|
return ((unit - fraction) + (fraction >> 1)) >> shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count )
|
static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < out_count; i += fade_block_size )
|
for ( i = 0; i < out_count; i += fade_block_size )
|
||||||
{
|
{
|
||||||
int const shift = 14;
|
int const shift = 14;
|
||||||
int const unit = 1 << shift;
|
int const unit = 1 << shift;
|
||||||
int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size,
|
int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size,
|
||||||
this->fade_step, unit );
|
this->fade_step, unit );
|
||||||
if ( gain < (unit >> fade_shift) )
|
if ( gain < (unit >> fade_shift) )
|
||||||
this->track_ended_ = this->emu_track_ended_ = true;
|
this->track_ended_ = this->emu_track_ended_ = true;
|
||||||
|
|
||||||
sample_t* io = &out [i];
|
sample_t* io = &out [i];
|
||||||
for ( int count = min( fade_block_size, out_count - i ); count; --count )
|
for ( int count = min( fade_block_size, out_count - i ); count; --count )
|
||||||
{
|
{
|
||||||
*io = (sample_t) ((*io * gain) >> shift);
|
*io = (sample_t) ((*io * gain) >> shift);
|
||||||
++io;
|
++io;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silence detection
|
// Silence detection
|
||||||
|
|
||||||
static void emu_play( struct Track_Filter* this, sample_t out [], int count )
|
static void emu_play( struct Track_Filter* this, sample_t out [], int count )
|
||||||
{
|
{
|
||||||
this->emu_time += count;
|
this->emu_time += count;
|
||||||
if ( !this->emu_track_ended_ )
|
if ( !this->emu_track_ended_ )
|
||||||
end_track_if_error( this, play_( this->emu_, count, out ) );
|
end_track_if_error( this, play_( this->emu_, count, out ) );
|
||||||
else
|
else
|
||||||
memset( out, 0, count * sizeof *out );
|
memset( out, 0, count * sizeof *out );
|
||||||
}
|
}
|
||||||
|
|
||||||
// number of consecutive silent samples at end
|
// number of consecutive silent samples at end
|
||||||
static int count_silence( sample_t begin [], int size )
|
static int count_silence( sample_t begin [], int size )
|
||||||
{
|
{
|
||||||
sample_t first = *begin;
|
sample_t first = *begin;
|
||||||
*begin = silence_threshold * 2; // sentinel
|
*begin = silence_threshold * 2; // sentinel
|
||||||
sample_t* p = begin + size;
|
sample_t* p = begin + size;
|
||||||
while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { }
|
while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { }
|
||||||
*begin = first;
|
*begin = first;
|
||||||
return size - (p - begin);
|
return size - (p - begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill internal buffer and check it for silence
|
// fill internal buffer and check it for silence
|
||||||
void fill_buf( struct Track_Filter* this )
|
void fill_buf( struct Track_Filter* this )
|
||||||
{
|
{
|
||||||
assert( !this->buf_remain );
|
assert( !this->buf_remain );
|
||||||
if ( !this->emu_track_ended_ )
|
if ( !this->emu_track_ended_ )
|
||||||
{
|
{
|
||||||
emu_play( this, this->buf, buf_size );
|
emu_play( this, this->buf, buf_size );
|
||||||
int silence = count_silence( this->buf, buf_size );
|
int silence = count_silence( this->buf, buf_size );
|
||||||
if ( silence < buf_size )
|
if ( silence < buf_size )
|
||||||
{
|
{
|
||||||
this->silence_time = this->emu_time - silence;
|
this->silence_time = this->emu_time - silence;
|
||||||
this->buf_remain = buf_size;
|
this->buf_remain = buf_size;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->silence_count += buf_size;
|
this->silence_count += buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] )
|
blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] )
|
||||||
{
|
{
|
||||||
this->emu_error = NULL;
|
this->emu_error = NULL;
|
||||||
if ( this->track_ended_ )
|
if ( this->track_ended_ )
|
||||||
{
|
{
|
||||||
memset( out, 0, out_count * sizeof *out );
|
memset( out, 0, out_count * sizeof *out );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert( this->emu_time >= this->out_time );
|
assert( this->emu_time >= this->out_time );
|
||||||
|
|
||||||
// prints nifty graph of how far ahead we are when searching for silence
|
// prints nifty graph of how far ahead we are when searching for silence
|
||||||
//dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" );
|
//dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" );
|
||||||
|
|
||||||
// use any remaining silence samples
|
// use any remaining silence samples
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if ( this->silence_count )
|
if ( this->silence_count )
|
||||||
{
|
{
|
||||||
if ( !this->silence_ignored_ )
|
if ( !this->silence_ignored_ )
|
||||||
{
|
{
|
||||||
// during a run of silence, run emulator at >=2x speed so it gets ahead
|
// 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) +
|
int ahead_time = this->setup_.lookahead * (this->out_time + out_count - this->silence_time) +
|
||||||
this->silence_time;
|
this->silence_time;
|
||||||
while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) )
|
while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) )
|
||||||
fill_buf( this );
|
fill_buf( this );
|
||||||
|
|
||||||
// end track if sufficient silence has been found
|
// end track if sufficient silence has been found
|
||||||
if ( this->emu_time - this->silence_time > this->setup_.max_silence )
|
if ( this->emu_time - this->silence_time > this->setup_.max_silence )
|
||||||
{
|
{
|
||||||
this->track_ended_ = this->emu_track_ended_ = true;
|
this->track_ended_ = this->emu_track_ended_ = true;
|
||||||
this->silence_count = out_count;
|
this->silence_count = out_count;
|
||||||
this->buf_remain = 0;
|
this->buf_remain = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill from remaining silence
|
// fill from remaining silence
|
||||||
pos = min( this->silence_count, out_count );
|
pos = min( this->silence_count, out_count );
|
||||||
memset( out, 0, pos * sizeof *out );
|
memset( out, 0, pos * sizeof *out );
|
||||||
this->silence_count -= pos;
|
this->silence_count -= pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use any remaining samples from buffer
|
// use any remaining samples from buffer
|
||||||
if ( this->buf_remain )
|
if ( this->buf_remain )
|
||||||
{
|
{
|
||||||
int n = min( this->buf_remain, (int) (out_count - pos) );
|
int n = min( this->buf_remain, (int) (out_count - pos) );
|
||||||
memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out );
|
memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out );
|
||||||
this->buf_remain -= n;
|
this->buf_remain -= n;
|
||||||
pos += n;
|
pos += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate remaining samples normally
|
// generate remaining samples normally
|
||||||
int remain = out_count - pos;
|
int remain = out_count - pos;
|
||||||
if ( remain )
|
if ( remain )
|
||||||
{
|
{
|
||||||
emu_play( this, out + pos, remain );
|
emu_play( this, out + pos, remain );
|
||||||
this->track_ended_ |= this->emu_track_ended_;
|
this->track_ended_ |= this->emu_track_ended_;
|
||||||
|
|
||||||
if ( this->silence_ignored_ && !is_fading( this ) )
|
if ( this->silence_ignored_ && !is_fading( this ) )
|
||||||
{
|
{
|
||||||
// if left unupdated, ahead_time could become too large
|
// if left unupdated, ahead_time could become too large
|
||||||
this->silence_time = this->emu_time;
|
this->silence_time = this->emu_time;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check end for a new run of silence
|
// check end for a new run of silence
|
||||||
int silence = count_silence( out + pos, remain );
|
int silence = count_silence( out + pos, remain );
|
||||||
if ( silence < remain )
|
if ( silence < remain )
|
||||||
this->silence_time = this->emu_time - silence;
|
this->silence_time = this->emu_time - silence;
|
||||||
|
|
||||||
if ( this->emu_time - this->silence_time >= buf_size )
|
if ( this->emu_time - this->silence_time >= buf_size )
|
||||||
fill_buf( this ); // cause silence detection on next play()
|
fill_buf( this ); // cause silence detection on next play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_fading( this ) )
|
if ( is_fading( this ) )
|
||||||
handle_fade( this, out, out_count );
|
handle_fade( this, out, out_count );
|
||||||
}
|
}
|
||||||
this->out_time += out_count;
|
this->out_time += out_count;
|
||||||
return this->emu_error;
|
return this->emu_error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,90 @@
|
||||||
// Removes silence from beginning of track, fades end of track. Also looks ahead
|
// Removes silence from beginning of track, fades end of track. Also looks ahead
|
||||||
// for excessive silence, and if found, ends track.
|
// for excessive silence, and if found, ends track.
|
||||||
|
|
||||||
// Game_Music_Emu 0.6-pre
|
// Game_Music_Emu 0.6-pre
|
||||||
#ifndef TRACK_FILTER_H
|
#ifndef TRACK_FILTER_H
|
||||||
#define TRACK_FILTER_H
|
#define TRACK_FILTER_H
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
|
|
||||||
typedef short sample_t;
|
typedef short sample_t;
|
||||||
typedef int sample_count_t;
|
typedef int sample_count_t;
|
||||||
|
|
||||||
enum { indefinite_count = INT_MAX/2 + 1 };
|
enum { indefinite_count = INT_MAX/2 + 1 };
|
||||||
enum { buf_size = 2048 };
|
enum { buf_size = 2048 };
|
||||||
|
|
||||||
struct setup_t {
|
struct setup_t {
|
||||||
sample_count_t max_initial; // maximum silence to strip from beginning of track
|
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
|
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.)
|
int lookahead; // internal speed when looking ahead for silence (2=200% etc.)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Track_Filter {
|
struct Track_Filter {
|
||||||
void* emu_;
|
void* emu_;
|
||||||
struct setup_t setup_;
|
struct setup_t setup_;
|
||||||
const char* emu_error;
|
const char* emu_error;
|
||||||
bool silence_ignored_;
|
bool silence_ignored_;
|
||||||
|
|
||||||
// Timing
|
// Timing
|
||||||
int out_time; // number of samples played since start of track
|
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_time; // number of samples emulator has generated since start of track
|
||||||
int emu_track_ended_; // emulator has reached end of track
|
int emu_track_ended_; // emulator has reached end of track
|
||||||
volatile int track_ended_;
|
volatile int track_ended_;
|
||||||
|
|
||||||
// Fading
|
// Fading
|
||||||
int fade_start;
|
int fade_start;
|
||||||
int fade_step;
|
int fade_step;
|
||||||
|
|
||||||
// Silence detection
|
// Silence detection
|
||||||
int silence_time; // absolute number of samples where most recent silence began
|
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 silence_count; // number of samples of silence to play before using buf
|
||||||
int buf_remain; // number of samples left in silence buffer
|
int buf_remain; // number of samples left in silence buffer
|
||||||
sample_t buf [buf_size];
|
sample_t buf [buf_size];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initializes filter. Must be done once before using object.
|
// Initializes filter. Must be done once before using object.
|
||||||
blargg_err_t track_init( struct Track_Filter* this, void* );
|
blargg_err_t track_init( struct Track_Filter* this, void* );
|
||||||
void track_create( struct Track_Filter* this );
|
void track_create( struct Track_Filter* this );
|
||||||
|
|
||||||
// Gets/sets setup
|
// Gets/sets setup
|
||||||
static inline struct setup_t const* track_get_setup( struct Track_Filter* this ) { return &this->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; }
|
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
|
// 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; }
|
static inline void track_ignore_silence( struct Track_Filter* this, bool disable ) { this->silence_ignored_ = disable; }
|
||||||
|
|
||||||
// Clears state and skips initial silence in track
|
// Clears state and skips initial silence in track
|
||||||
blargg_err_t track_start( struct Track_Filter* this );
|
blargg_err_t track_start( struct Track_Filter* this );
|
||||||
|
|
||||||
// Sets time that fade starts, and how long until track ends.
|
// 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 );
|
void track_set_fade( struct Track_Filter* this, sample_count_t start, sample_count_t length );
|
||||||
|
|
||||||
// Generates n samples into buf
|
// Generates n samples into buf
|
||||||
blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] );
|
blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] );
|
||||||
|
|
||||||
// Skips n samples
|
// Skips n samples
|
||||||
blargg_err_t track_skip( struct Track_Filter* this, int n );
|
blargg_err_t track_skip( struct Track_Filter* this, int n );
|
||||||
|
|
||||||
// Number of samples played/skipped since start_track()
|
// Number of samples played/skipped since start_track()
|
||||||
static inline int track_sample_count( struct Track_Filter* this ) { return this->out_time; }
|
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,
|
// True if track ended. Causes are end of source samples, end of fade,
|
||||||
// or excessive silence.
|
// or excessive silence.
|
||||||
static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; }
|
static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; }
|
||||||
|
|
||||||
// Clears state
|
// Clears state
|
||||||
void track_stop( struct Track_Filter* this );
|
void track_stop( struct Track_Filter* this );
|
||||||
|
|
||||||
// For use by callbacks
|
// For use by callbacks
|
||||||
|
|
||||||
// Sets internal "track ended" flag and stops generation of further source samples
|
// 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; }
|
static inline void track_set_end( struct Track_Filter* this ) { this->emu_track_ended_ = true; }
|
||||||
|
|
||||||
// For use by skip_() callback
|
// For use by skip_() callback
|
||||||
blargg_err_t skippy_( struct Track_Filter* this, int count );
|
blargg_err_t skippy_( struct Track_Filter* this, int count );
|
||||||
void fill_buf( struct Track_Filter* this );
|
void fill_buf( struct Track_Filter* this );
|
||||||
|
|
||||||
// Skip and play callbacks
|
// Skip and play callbacks
|
||||||
blargg_err_t skip_( void* emu, int count );
|
blargg_err_t skip_( void* emu, int count );
|
||||||
blargg_err_t play_( void* emu, int count, sample_t out [] );
|
blargg_err_t play_( void* emu, int count, sample_t out [] );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* VRC7 TONES by okazaki@angel.ne.jp */
|
/* VRC7 TONES by okazaki@angel.ne.jp */
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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
|
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/
|
// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/
|
||||||
|
|
||||||
#include "ym2413_emu.h"
|
#include "ym2413_emu.h"
|
||||||
|
|
||||||
void Ym2413_init( struct Ym2413_Emu* this )
|
void Ym2413_init( struct Ym2413_Emu* this )
|
||||||
{
|
{
|
||||||
this->last_time = disabled_time; this->out = 0;
|
this->last_time = disabled_time; this->out = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate )
|
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate )
|
||||||
{
|
{
|
||||||
OPLL_new ( &this->opll, clock_rate, sample_rate );
|
OPLL_new ( &this->opll, clock_rate, sample_rate );
|
||||||
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
|
||||||
|
|
||||||
Ym2413_reset( this );
|
Ym2413_reset( this );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ym2413_reset( struct Ym2413_Emu* this )
|
void Ym2413_reset( struct Ym2413_Emu* this )
|
||||||
{
|
{
|
||||||
OPLL_reset( &this->opll );
|
OPLL_reset( &this->opll );
|
||||||
OPLL_setMask( &this->opll, 0 );
|
OPLL_setMask( &this->opll, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data )
|
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data )
|
||||||
{
|
{
|
||||||
OPLL_writeIO( &this->opll, 0, addr );
|
OPLL_writeIO( &this->opll, 0, addr );
|
||||||
OPLL_writeIO( &this->opll, 1, data );
|
OPLL_writeIO( &this->opll, 1, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask )
|
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask )
|
||||||
{
|
{
|
||||||
OPLL_setMask( &this->opll, mask );
|
OPLL_setMask( &this->opll, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out )
|
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out )
|
||||||
{
|
{
|
||||||
while ( pair_count-- )
|
while ( pair_count-- )
|
||||||
{
|
{
|
||||||
int s = OPLL_calc( &this->opll ) << 1;
|
int s = OPLL_calc( &this->opll ) << 1;
|
||||||
out [0] = s;
|
out [0] = s;
|
||||||
out [1] = s;
|
out [1] = s;
|
||||||
out += 2;
|
out += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +1,61 @@
|
||||||
// YM2413 FM sound chip emulator interface
|
// YM2413 FM sound chip emulator interface
|
||||||
|
|
||||||
// Game_Music_Emu 0.6-pre
|
// Game_Music_Emu 0.6-pre
|
||||||
#ifndef YM2413_EMU_H
|
#ifndef YM2413_EMU_H
|
||||||
#define YM2413_EMU_H
|
#define YM2413_EMU_H
|
||||||
|
|
||||||
#include "blargg_common.h"
|
#include "blargg_common.h"
|
||||||
#include "emu2413.h"
|
#include "emu2413.h"
|
||||||
|
|
||||||
enum { out_chan_count = 2 }; // stereo
|
enum { out_chan_count = 2 }; // stereo
|
||||||
enum { channel_count = 14 };
|
enum { channel_count = 14 };
|
||||||
enum { disabled_time = -1 };
|
enum { disabled_time = -1 };
|
||||||
|
|
||||||
struct Ym2413_Emu {
|
struct Ym2413_Emu {
|
||||||
OPLL opll;
|
OPLL opll;
|
||||||
|
|
||||||
// Impl
|
// Impl
|
||||||
int last_time;
|
int last_time;
|
||||||
short* out;
|
short* out;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Ym2413_init( struct Ym2413_Emu* this );
|
void Ym2413_init( struct Ym2413_Emu* this );
|
||||||
|
|
||||||
static inline bool Ym2413_supported( void ) { return true; }
|
static inline bool Ym2413_supported( void ) { return true; }
|
||||||
|
|
||||||
// Sets output sample rate and chip clock rates, in Hz. Returns non-zero
|
// Sets output sample rate and chip clock rates, in Hz. Returns non-zero
|
||||||
// if error.
|
// if error.
|
||||||
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate );
|
int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate );
|
||||||
|
|
||||||
// Resets to power-up state
|
// Resets to power-up state
|
||||||
void Ym2413_reset( struct Ym2413_Emu* this );
|
void Ym2413_reset( struct Ym2413_Emu* this );
|
||||||
|
|
||||||
// Mutes voice n if bit n (1 << n) of mask is set
|
// Mutes voice n if bit n (1 << n) of mask is set
|
||||||
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask );
|
void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask );
|
||||||
|
|
||||||
// Writes data to addr
|
// Writes data to addr
|
||||||
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data );
|
void Ym2413_write( struct Ym2413_Emu* this, int addr, int data );
|
||||||
|
|
||||||
// Runs and writes pair_count*2 samples to output
|
// Runs and writes pair_count*2 samples to output
|
||||||
void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out );
|
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 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 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 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 )
|
static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time )
|
||||||
{
|
{
|
||||||
int count = time - this->last_time;
|
int count = time - this->last_time;
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
if ( this->last_time < 0 )
|
if ( this->last_time < 0 )
|
||||||
return false;
|
return false;
|
||||||
this->last_time = time;
|
this->last_time = time;
|
||||||
short* p = this->out;
|
short* p = this->out;
|
||||||
this->out += count * out_chan_count;
|
this->out += count * out_chan_count;
|
||||||
Ym2413_run( this, count, p );
|
Ym2413_run( this, count, p );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,116 +1,116 @@
|
||||||
// Z80 CPU emulator
|
// Z80 CPU emulator
|
||||||
|
|
||||||
// Game_Music_Emu 0.6-pre
|
// Game_Music_Emu 0.6-pre
|
||||||
#ifndef Z80_CPU_H
|
#ifndef Z80_CPU_H
|
||||||
#define Z80_CPU_H
|
#define Z80_CPU_H
|
||||||
|
|
||||||
#include "blargg_source.h"
|
#include "blargg_source.h"
|
||||||
#include "blargg_endian.h"
|
#include "blargg_endian.h"
|
||||||
|
|
||||||
typedef int cpu_time_t;
|
typedef int cpu_time_t;
|
||||||
typedef int addr_t;
|
typedef int addr_t;
|
||||||
|
|
||||||
enum { page_bits = 10 };
|
enum { page_bits = 10 };
|
||||||
enum { page_size = 1 << page_bits };
|
enum { page_size = 1 << page_bits };
|
||||||
enum { page_count = 0x10000 / page_size };
|
enum { page_count = 0x10000 / page_size };
|
||||||
|
|
||||||
// Can read this far past end of memory
|
// Can read this far past end of memory
|
||||||
enum { cpu_padding = 0x100 };
|
enum { cpu_padding = 0x100 };
|
||||||
|
|
||||||
// Can read this many bytes past end of a page
|
// Can read this many bytes past end of a page
|
||||||
enum { page_padding = 4 };
|
enum { page_padding = 4 };
|
||||||
|
|
||||||
#ifdef BLARGG_BIG_ENDIAN
|
#ifdef BLARGG_BIG_ENDIAN
|
||||||
struct regs_t { byte b,c, d,e, h,l, flags,a; };
|
struct regs_t { byte b,c, d,e, h,l, flags,a; };
|
||||||
#else
|
#else
|
||||||
struct regs_t { byte c,b, e,d, l,h, a,flags; };
|
struct regs_t { byte c,b, e,d, l,h, a,flags; };
|
||||||
#endif
|
#endif
|
||||||
// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 );
|
// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 );
|
||||||
|
|
||||||
struct pairs_t { uint16_t bc, de, hl, fa; };
|
struct pairs_t { uint16_t bc, de, hl, fa; };
|
||||||
|
|
||||||
// Registers are not updated until run() returns
|
// Registers are not updated until run() returns
|
||||||
struct registers_t {
|
struct registers_t {
|
||||||
uint16_t pc;
|
uint16_t pc;
|
||||||
uint16_t sp;
|
uint16_t sp;
|
||||||
uint16_t ix;
|
uint16_t ix;
|
||||||
uint16_t iy;
|
uint16_t iy;
|
||||||
union {
|
union {
|
||||||
struct regs_t b; // b.b, b.c, b.d, b.e, b.h, b.l, b.flags, b.a
|
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
|
struct pairs_t w; // w.bc, w.de, w.hl. w.fa
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
struct regs_t b;
|
struct regs_t b;
|
||||||
struct pairs_t w;
|
struct pairs_t w;
|
||||||
} alt;
|
} alt;
|
||||||
byte iff1;
|
byte iff1;
|
||||||
byte iff2;
|
byte iff2;
|
||||||
byte r;
|
byte r;
|
||||||
byte i;
|
byte i;
|
||||||
byte im;
|
byte im;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cpu_state_t {
|
struct cpu_state_t {
|
||||||
byte const* read [page_count + 1];
|
byte const* read [page_count + 1];
|
||||||
byte * write [page_count + 1];
|
byte * write [page_count + 1];
|
||||||
cpu_time_t base;
|
cpu_time_t base;
|
||||||
cpu_time_t time;
|
cpu_time_t time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Z80_Cpu {
|
struct Z80_Cpu {
|
||||||
byte szpc [0x200];
|
byte szpc [0x200];
|
||||||
cpu_time_t end_time_;
|
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; // points to cpu_state_ or a local copy within run()
|
||||||
struct cpu_state_t cpu_state_;
|
struct cpu_state_t cpu_state_;
|
||||||
|
|
||||||
struct registers_t r;
|
struct registers_t r;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Z80_init( struct Z80_Cpu* this );
|
void Z80_init( struct Z80_Cpu* this );
|
||||||
|
|
||||||
// Clears registers and maps all pages to unmapped
|
// Clears registers and maps all pages to unmapped
|
||||||
void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read );
|
void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read );
|
||||||
|
|
||||||
// TODO: split mapping out of CPU
|
// TODO: split mapping out of CPU
|
||||||
|
|
||||||
// Maps memory. Start and size must be multiple of page_size.
|
// 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 );
|
void Z80_map_mem( struct Z80_Cpu* this, addr_t addr, int size, void* write, void const* read );
|
||||||
|
|
||||||
// Time of beginning of next instruction
|
// 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; }
|
static inline cpu_time_t Z80_time( struct Z80_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; }
|
||||||
|
|
||||||
// Alter current time
|
// 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_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; }
|
static inline void Z80_adjust_time( struct Z80_Cpu* this, int delta ) { this->cpu_state->time += delta; }
|
||||||
|
|
||||||
#ifdef BLARGG_NONPORTABLE
|
#ifdef BLARGG_NONPORTABLE
|
||||||
#define Z80_CPU_OFFSET( addr ) (addr)
|
#define Z80_CPU_OFFSET( addr ) (addr)
|
||||||
#else
|
#else
|
||||||
#define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1))
|
#define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Maps address to pointer to that byte
|
// Maps address to pointer to that byte
|
||||||
static inline byte* Z80_write( struct Z80_Cpu* this, addr_t addr )
|
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 );
|
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 )
|
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 );
|
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 )
|
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 );
|
Z80_map_mem( this, addr, size, p, p );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t )
|
static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t )
|
||||||
{
|
{
|
||||||
cpu_time_t delta = this->cpu_state->base - t;
|
cpu_time_t delta = this->cpu_state->base - t;
|
||||||
this->cpu_state->base = t;
|
this->cpu_state->base = t;
|
||||||
this->cpu_state->time += delta;
|
this->cpu_state->time += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7010,17 +7010,17 @@
|
||||||
radio: "قائمة اذاعة اف ام"
|
radio: "قائمة اذاعة اف ام"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
<phrase>
|
<phrase>
|
||||||
id: LANG_FILESIZE
|
id: LANG_FILESIZE
|
||||||
desc: in record timesplit options and in track information viewer
|
desc: in record timesplit options and in track information viewer
|
||||||
user: core
|
user: core
|
||||||
<source>
|
<source>
|
||||||
*: "Filesize"
|
*: "Filesize"
|
||||||
</source>
|
</source>
|
||||||
<dest>
|
<dest>
|
||||||
*: "حجم الملف"
|
*: "حجم الملف"
|
||||||
</dest>
|
</dest>
|
||||||
<voice>
|
<voice>
|
||||||
*: "حجم الملف"
|
*: "حجم الملف"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</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 \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: wm8975.c 28572 2010-11-13 11:38:38Z theseven $
|
* $Id: wm8975.c 28572 2010-11-13 11:38:38Z theseven $
|
||||||
*
|
*
|
||||||
* Driver for Cirrus Logic CS42L55 audio codec
|
* Driver for Cirrus Logic CS42L55 audio codec
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 Michael Sparmann
|
* Copyright (c) 2010 Michael Sparmann
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "audiohw.h"
|
#include "audiohw.h"
|
||||||
#include "cscodec.h"
|
#include "cscodec.h"
|
||||||
#include "cs42l55.h"
|
#include "cs42l55.h"
|
||||||
|
|
||||||
const struct sound_settings_info audiohw_settings[] = {
|
const struct sound_settings_info audiohw_settings[] = {
|
||||||
[SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25},
|
[SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25},
|
||||||
[SOUND_BASS] = {"dB", 1, 15,-105, 120, 0},
|
[SOUND_BASS] = {"dB", 1, 15,-105, 120, 0},
|
||||||
[SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0},
|
[SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0},
|
||||||
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
||||||
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
|
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
|
||||||
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
|
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
|
||||||
[SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 2},
|
[SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 2},
|
||||||
[SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
|
[SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bass, treble;
|
static int bass, treble;
|
||||||
|
|
||||||
/* convert tenth of dB volume (-600..120) to master volume register value */
|
/* convert tenth of dB volume (-600..120) to master volume register value */
|
||||||
int tenthdb2master(int db)
|
int tenthdb2master(int db)
|
||||||
{
|
{
|
||||||
/* -60dB to +12dB in 1dB steps */
|
/* -60dB to +12dB in 1dB steps */
|
||||||
/* 0001100 == +12dB (0xc) */
|
/* 0001100 == +12dB (0xc) */
|
||||||
/* 0000000 == 0dB (0x0) */
|
/* 0000000 == 0dB (0x0) */
|
||||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||||
|
|
||||||
if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
|
if (db < VOLUME_MIN) return HPACTL_HPAMUTE;
|
||||||
return (db / 10) & HPACTL_HPAVOL_MASK;
|
return (db / 10) & HPACTL_HPAVOL_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cscodec_setbits(int reg, unsigned char off, unsigned char on)
|
static void cscodec_setbits(int reg, unsigned char off, unsigned char on)
|
||||||
{
|
{
|
||||||
unsigned char data = (cscodec_read(reg) & ~off) | on;
|
unsigned char data = (cscodec_read(reg) & ~off) | on;
|
||||||
cscodec_write(reg, data);
|
cscodec_write(reg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audiohw_mute(bool mute)
|
static void audiohw_mute(bool mute)
|
||||||
{
|
{
|
||||||
if (mute) cscodec_setbits(PLAYCTL, 0, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
if (mute) cscodec_setbits(PLAYCTL, 0, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||||
else cscodec_setbits(PLAYCTL, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE, 0);
|
else cscodec_setbits(PLAYCTL, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_preinit(void)
|
void audiohw_preinit(void)
|
||||||
{
|
{
|
||||||
cscodec_power(true);
|
cscodec_power(true);
|
||||||
cscodec_clock(true);
|
cscodec_clock(true);
|
||||||
cscodec_reset(true);
|
cscodec_reset(true);
|
||||||
sleep(HZ / 100);
|
sleep(HZ / 100);
|
||||||
cscodec_reset(false);
|
cscodec_reset(false);
|
||||||
|
|
||||||
bass = 0;
|
bass = 0;
|
||||||
treble = 0;
|
treble = 0;
|
||||||
|
|
||||||
/* Ask Cirrus or maybe Apple what the hell this means */
|
/* Ask Cirrus or maybe Apple what the hell this means */
|
||||||
cscodec_write(HIDDENCTL, HIDDENCTL_UNLOCK);
|
cscodec_write(HIDDENCTL, HIDDENCTL_UNLOCK);
|
||||||
cscodec_write(HIDDEN2E, HIDDEN2E_DEFAULT);
|
cscodec_write(HIDDEN2E, HIDDEN2E_DEFAULT);
|
||||||
cscodec_write(HIDDEN32, HIDDEN32_DEFAULT);
|
cscodec_write(HIDDEN32, HIDDEN32_DEFAULT);
|
||||||
cscodec_write(HIDDEN33, HIDDEN33_DEFAULT);
|
cscodec_write(HIDDEN33, HIDDEN33_DEFAULT);
|
||||||
cscodec_write(HIDDEN34, HIDDEN34_DEFAULT);
|
cscodec_write(HIDDEN34, HIDDEN34_DEFAULT);
|
||||||
cscodec_write(HIDDEN35, HIDDEN35_DEFAULT);
|
cscodec_write(HIDDEN35, HIDDEN35_DEFAULT);
|
||||||
cscodec_write(HIDDEN36, HIDDEN36_DEFAULT);
|
cscodec_write(HIDDEN36, HIDDEN36_DEFAULT);
|
||||||
cscodec_write(HIDDEN37, HIDDEN37_DEFAULT);
|
cscodec_write(HIDDEN37, HIDDEN37_DEFAULT);
|
||||||
cscodec_write(HIDDEN3A, HIDDEN3A_DEFAULT);
|
cscodec_write(HIDDEN3A, HIDDEN3A_DEFAULT);
|
||||||
cscodec_write(HIDDEN3C, HIDDEN3C_DEFAULT);
|
cscodec_write(HIDDEN3C, HIDDEN3C_DEFAULT);
|
||||||
cscodec_write(HIDDEN3D, HIDDEN3D_DEFAULT);
|
cscodec_write(HIDDEN3D, HIDDEN3D_DEFAULT);
|
||||||
cscodec_write(HIDDEN3E, HIDDEN3E_DEFAULT);
|
cscodec_write(HIDDEN3E, HIDDEN3E_DEFAULT);
|
||||||
cscodec_write(HIDDEN3F, HIDDEN3F_DEFAULT);
|
cscodec_write(HIDDEN3F, HIDDEN3F_DEFAULT);
|
||||||
cscodec_write(HIDDENCTL, HIDDENCTL_LOCK);
|
cscodec_write(HIDDENCTL, HIDDENCTL_LOCK);
|
||||||
|
|
||||||
cscodec_write(PWRCTL2, PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS
|
cscodec_write(PWRCTL2, PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS
|
||||||
| PWRCTL2_PDN_HPA_NEVER | PWRCTL2_PDN_HPB_NEVER);
|
| PWRCTL2_PDN_HPA_NEVER | PWRCTL2_PDN_HPB_NEVER);
|
||||||
cscodec_write(CLKCTL1, CLKCTL1_MASTER | CLKCTL1_SCLKMCLK_BEFORE
|
cscodec_write(CLKCTL1, CLKCTL1_MASTER | CLKCTL1_SCLKMCLK_BEFORE
|
||||||
| CLKCTL1_MCLKDIV2);
|
| CLKCTL1_MCLKDIV2);
|
||||||
cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||||
cscodec_write(MISCCTL, MISCCTL_UNDOC4 | MISCCTL_ANLGZC | MISCCTL_DIGSFT);
|
cscodec_write(MISCCTL, MISCCTL_UNDOC4 | MISCCTL_ANLGZC | MISCCTL_DIGSFT);
|
||||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||||
cscodec_write(PLAYCTL, PLAYCTL_PDN_DSP
|
cscodec_write(PLAYCTL, PLAYCTL_PDN_DSP
|
||||||
| PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
| PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
|
||||||
cscodec_write(PGAACTL, 0);
|
cscodec_write(PGAACTL, 0);
|
||||||
cscodec_write(PGABCTL, 0);
|
cscodec_write(PGABCTL, 0);
|
||||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||||
| PWRCTL1_PDN_ADCB);
|
| PWRCTL1_PDN_ADCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
{
|
{
|
||||||
cscodec_write(HPACTL, 0);
|
cscodec_write(HPACTL, 0);
|
||||||
cscodec_write(HPBCTL, 0);
|
cscodec_write(HPBCTL, 0);
|
||||||
cscodec_write(LINEACTL, 0);
|
cscodec_write(LINEACTL, 0);
|
||||||
cscodec_write(LINEBCTL, 0);
|
cscodec_write(LINEBCTL, 0);
|
||||||
cscodec_write(CLSHCTL, CLSHCTL_ADPTPWR_SIGNAL);
|
cscodec_write(CLSHCTL, CLSHCTL_ADPTPWR_SIGNAL);
|
||||||
audiohw_mute(false);
|
audiohw_mute(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_master_vol(int vol_l, int vol_r)
|
void audiohw_set_master_vol(int vol_l, int vol_r)
|
||||||
{
|
{
|
||||||
/* -60dB to +12dB in 1dB steps */
|
/* -60dB to +12dB in 1dB steps */
|
||||||
/* 0001100 == +12dB (0xc) */
|
/* 0001100 == +12dB (0xc) */
|
||||||
/* 0000000 == 0dB (0x0) */
|
/* 0000000 == 0dB (0x0) */
|
||||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||||
|
|
||||||
cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
|
cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
|
||||||
vol_l << HPACTL_HPAVOL_SHIFT);
|
vol_l << HPACTL_HPAVOL_SHIFT);
|
||||||
cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
|
cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
|
||||||
vol_r << HPBCTL_HPBVOL_SHIFT);
|
vol_r << HPBCTL_HPBVOL_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
||||||
{
|
{
|
||||||
/* -60dB to +12dB in 1dB steps */
|
/* -60dB to +12dB in 1dB steps */
|
||||||
/* 0001100 == +12dB (0xc) */
|
/* 0001100 == +12dB (0xc) */
|
||||||
/* 0000000 == 0dB (0x0) */
|
/* 0000000 == 0dB (0x0) */
|
||||||
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
/* 1000100 == -60dB (0x44, this is actually -58dB) */
|
||||||
|
|
||||||
cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
|
cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
|
||||||
vol_l << LINEACTL_LINEAVOL_SHIFT);
|
vol_l << LINEACTL_LINEAVOL_SHIFT);
|
||||||
cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,
|
cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,
|
||||||
vol_r << LINEBCTL_LINEBVOL_SHIFT);
|
vol_r << LINEBCTL_LINEBVOL_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_enable_lineout(bool enable)
|
void audiohw_enable_lineout(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||||
PWRCTL2_PDN_LINA_NEVER | PWRCTL2_PDN_LINB_NEVER);
|
PWRCTL2_PDN_LINA_NEVER | PWRCTL2_PDN_LINB_NEVER);
|
||||||
else
|
else
|
||||||
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
|
||||||
PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS);
|
PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_dsp_power(void)
|
static void handle_dsp_power(void)
|
||||||
{
|
{
|
||||||
if (bass || treble)
|
if (bass || treble)
|
||||||
{
|
{
|
||||||
cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
|
cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
|
||||||
cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
|
cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
|
cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
|
||||||
cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
|
cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_bass(int value)
|
void audiohw_set_bass(int value)
|
||||||
{
|
{
|
||||||
bass = value;
|
bass = value;
|
||||||
handle_dsp_power();
|
handle_dsp_power();
|
||||||
if (value >= -105 && value <= 120)
|
if (value >= -105 && value <= 120)
|
||||||
cscodec_setbits(TONECTL, TONECTL_BASS_MASK,
|
cscodec_setbits(TONECTL, TONECTL_BASS_MASK,
|
||||||
(8 - value / 15) << TONECTL_BASS_SHIFT);
|
(8 - value / 15) << TONECTL_BASS_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_treble(int value)
|
void audiohw_set_treble(int value)
|
||||||
{
|
{
|
||||||
treble = value;
|
treble = value;
|
||||||
handle_dsp_power();
|
handle_dsp_power();
|
||||||
if (value >= -105 && value <= 120)
|
if (value >= -105 && value <= 120)
|
||||||
cscodec_setbits(TONECTL, TONECTL_TREB_MASK,
|
cscodec_setbits(TONECTL, TONECTL_TREB_MASK,
|
||||||
(8 - value / 15) << TONECTL_TREB_SHIFT);
|
(8 - value / 15) << TONECTL_TREB_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_bass_cutoff(int value)
|
void audiohw_set_bass_cutoff(int value)
|
||||||
{
|
{
|
||||||
cscodec_setbits(BTCTL, BTCTL_BASSCF_MASK,
|
cscodec_setbits(BTCTL, BTCTL_BASSCF_MASK,
|
||||||
(value - 1) << BTCTL_BASSCF_SHIFT);
|
(value - 1) << BTCTL_BASSCF_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_treble_cutoff(int value)
|
void audiohw_set_treble_cutoff(int value)
|
||||||
{
|
{
|
||||||
cscodec_setbits(BTCTL, BTCTL_TREBCF_MASK,
|
cscodec_setbits(BTCTL, BTCTL_TREBCF_MASK,
|
||||||
(value - 1) << BTCTL_TREBCF_SHIFT);
|
(value - 1) << BTCTL_TREBCF_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_set_prescaler(int value)
|
void audiohw_set_prescaler(int value)
|
||||||
{
|
{
|
||||||
cscodec_setbits(MSTAVOL, MSTAVOL_VOLUME_MASK,
|
cscodec_setbits(MSTAVOL, MSTAVOL_VOLUME_MASK,
|
||||||
(-value / 5) << MSTAVOL_VOLUME_SHIFT);
|
(-value / 5) << MSTAVOL_VOLUME_SHIFT);
|
||||||
cscodec_setbits(MSTBVOL, MSTBVOL_VOLUME_MASK,
|
cscodec_setbits(MSTBVOL, MSTBVOL_VOLUME_MASK,
|
||||||
(-value / 5) << MSTBVOL_VOLUME_SHIFT);
|
(-value / 5) << MSTBVOL_VOLUME_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nice shutdown of CS42L55 codec */
|
/* Nice shutdown of CS42L55 codec */
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
{
|
{
|
||||||
audiohw_mute(true);
|
audiohw_mute(true);
|
||||||
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
cscodec_write(HPACTL, HPACTL_HPAMUTE);
|
||||||
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
|
||||||
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
|
||||||
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
|
||||||
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
|
||||||
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
| PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
|
||||||
cscodec_reset(true);
|
cscodec_reset(true);
|
||||||
cscodec_clock(false);
|
cscodec_clock(false);
|
||||||
cscodec_power(false);
|
cscodec_power(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: Disable output before calling this function */
|
/* Note: Disable output before calling this function */
|
||||||
void audiohw_set_frequency(int fsel)
|
void audiohw_set_frequency(int fsel)
|
||||||
{
|
{
|
||||||
if (fsel == HW_FREQ_8) cscodec_write(CLKCTL2, CLKCTL2_8000HZ);
|
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_11) cscodec_write(CLKCTL2, CLKCTL2_11025HZ);
|
||||||
else if (fsel == HW_FREQ_12) cscodec_write(CLKCTL2, CLKCTL2_12000HZ);
|
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_16) cscodec_write(CLKCTL2, CLKCTL2_16000HZ);
|
||||||
else if (fsel == HW_FREQ_22) cscodec_write(CLKCTL2, CLKCTL2_22050HZ);
|
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_24) cscodec_write(CLKCTL2, CLKCTL2_24000HZ);
|
||||||
else if (fsel == HW_FREQ_32) cscodec_write(CLKCTL2, CLKCTL2_32000HZ);
|
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_44) cscodec_write(CLKCTL2, CLKCTL2_44100HZ);
|
||||||
else if (fsel == HW_FREQ_48) cscodec_write(CLKCTL2, CLKCTL2_48000HZ);
|
else if (fsel == HW_FREQ_48) cscodec_write(CLKCTL2, CLKCTL2_48000HZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef HAVE_RECORDING
|
||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: dac.c 17847 2008-06-28 18:10:04Z bagder $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: ata.h 28951 2011-01-02 23:02:55Z theseven $
|
* $Id: ata.h 28951 2011-01-02 23:02:55Z theseven $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 by Michael Sparmann
|
* Copyright (C) 2011 by Michael Sparmann
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef __ATA_DEFINES_H__
|
#ifndef __ATA_DEFINES_H__
|
||||||
#define __ATA_DEFINES_H__
|
#define __ATA_DEFINES_H__
|
||||||
|
|
||||||
#ifndef ATA_OUT8
|
#ifndef ATA_OUT8
|
||||||
#define ATA_OUT8(reg, data) (reg) = (data)
|
#define ATA_OUT8(reg, data) (reg) = (data)
|
||||||
#endif
|
#endif
|
||||||
#ifndef ATA_OUT16
|
#ifndef ATA_OUT16
|
||||||
#define ATA_OUT16(reg, data) (reg) = (data)
|
#define ATA_OUT16(reg, data) (reg) = (data)
|
||||||
#endif
|
#endif
|
||||||
#ifndef ATA_IN8
|
#ifndef ATA_IN8
|
||||||
#define ATA_IN8(reg) (reg)
|
#define ATA_IN8(reg) (reg)
|
||||||
#endif
|
#endif
|
||||||
#ifndef ATA_IN16
|
#ifndef ATA_IN16
|
||||||
#define ATA_IN16(reg) (reg)
|
#define ATA_IN16(reg) (reg)
|
||||||
#endif
|
#endif
|
||||||
#ifndef ATA_SWAP_IDENTIFY
|
#ifndef ATA_SWAP_IDENTIFY
|
||||||
#define ATA_SWAP_IDENTIFY(word) (word)
|
#define ATA_SWAP_IDENTIFY(word) (word)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STATUS_BSY 0x80
|
#define STATUS_BSY 0x80
|
||||||
#define STATUS_RDY 0x40
|
#define STATUS_RDY 0x40
|
||||||
#define STATUS_DRQ 0x08
|
#define STATUS_DRQ 0x08
|
||||||
#define STATUS_ERR 0x01
|
#define STATUS_ERR 0x01
|
||||||
#define STATUS_DF 0x20
|
#define STATUS_DF 0x20
|
||||||
#define ERROR_IDNF 0x10
|
#define ERROR_IDNF 0x10
|
||||||
#define ERROR_ABRT 0x04
|
#define ERROR_ABRT 0x04
|
||||||
|
|
||||||
#define TEST_PATTERN1 0xa5
|
#define TEST_PATTERN1 0xa5
|
||||||
#define TEST_PATTERN2 0x5a
|
#define TEST_PATTERN2 0x5a
|
||||||
#define TEST_PATTERN3 0xaa
|
#define TEST_PATTERN3 0xaa
|
||||||
#define TEST_PATTERN4 0x55
|
#define TEST_PATTERN4 0x55
|
||||||
|
|
||||||
#define ATA_FEATURE ATA_ERROR
|
#define ATA_FEATURE ATA_ERROR
|
||||||
|
|
||||||
#define ATA_STATUS ATA_COMMAND
|
#define ATA_STATUS ATA_COMMAND
|
||||||
#define ATA_ALT_STATUS ATA_CONTROL
|
#define ATA_ALT_STATUS ATA_CONTROL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,189 +1,189 @@
|
||||||
/*
|
/*
|
||||||
* This config file is for Rockchip rk27xx reference design
|
* This config file is for Rockchip rk27xx reference design
|
||||||
*/
|
*/
|
||||||
#define TARGET_TREE /* this target is using the target tree system */
|
#define TARGET_TREE /* this target is using the target tree system */
|
||||||
|
|
||||||
/* For Rolo and boot loader */
|
/* For Rolo and boot loader */
|
||||||
#define MODEL_NUMBER 78
|
#define MODEL_NUMBER 78
|
||||||
|
|
||||||
#define MODEL_NAME "Rockchip 27xx generic"
|
#define MODEL_NAME "Rockchip 27xx generic"
|
||||||
|
|
||||||
/* define this if you have recording possibility */
|
/* define this if you have recording possibility */
|
||||||
/* #define HAVE_RECORDING */
|
/* #define HAVE_RECORDING */
|
||||||
|
|
||||||
/* Define bitmask of input sources - recordable bitmask can be defined
|
/* Define bitmask of input sources - recordable bitmask can be defined
|
||||||
explicitly if different */
|
explicitly if different */
|
||||||
/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
|
/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
|
||||||
|
|
||||||
/* define the bitmask of hardware sample rates */
|
/* define the bitmask of hardware sample rates */
|
||||||
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||||
|
|
||||||
/* define the bitmask of recording sample rates */
|
/* define the bitmask of recording sample rates */
|
||||||
#define REC_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
#define REC_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||||
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
| SAMPR_CAP_48 | SAMPR_CAP_24 | SAMPR_CAP_12 \
|
||||||
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
| SAMPR_CAP_32 | SAMPR_CAP_16 | SAMPR_CAP_8)
|
||||||
|
|
||||||
/* define this if you have a bitmap LCD display */
|
/* define this if you have a bitmap LCD display */
|
||||||
#define HAVE_LCD_BITMAP
|
#define HAVE_LCD_BITMAP
|
||||||
|
|
||||||
/* define this if you can flip your LCD */
|
/* define this if you can flip your LCD */
|
||||||
/* #define HAVE_LCD_FLIP */
|
/* #define HAVE_LCD_FLIP */
|
||||||
|
|
||||||
/* define this if you have a colour LCD */
|
/* define this if you have a colour LCD */
|
||||||
#define HAVE_LCD_COLOR
|
#define HAVE_LCD_COLOR
|
||||||
|
|
||||||
/* define this if you want album art for this target */
|
/* define this if you want album art for this target */
|
||||||
#define HAVE_ALBUMART
|
#define HAVE_ALBUMART
|
||||||
|
|
||||||
/* define this to enable bitmap scaling */
|
/* define this to enable bitmap scaling */
|
||||||
#define HAVE_BMP_SCALING
|
#define HAVE_BMP_SCALING
|
||||||
|
|
||||||
/* define this to enable JPEG decoding */
|
/* define this to enable JPEG decoding */
|
||||||
#define HAVE_JPEG
|
#define HAVE_JPEG
|
||||||
|
|
||||||
/* define this if you can invert the colours on your LCD */
|
/* define this if you can invert the colours on your LCD */
|
||||||
/* #define HAVE_LCD_INVERT */
|
/* #define HAVE_LCD_INVERT */
|
||||||
|
|
||||||
/* define this if you have access to the quickscreen */
|
/* define this if you have access to the quickscreen */
|
||||||
#define HAVE_QUICKSCREEN
|
#define HAVE_QUICKSCREEN
|
||||||
|
|
||||||
/* define this if you have access to the pitchscreen */
|
/* define this if you have access to the pitchscreen */
|
||||||
#define HAVE_PITCHSCREEN
|
#define HAVE_PITCHSCREEN
|
||||||
|
|
||||||
/* define this if you would like tagcache to build on this target */
|
/* define this if you would like tagcache to build on this target */
|
||||||
#define HAVE_TAGCACHE
|
#define HAVE_TAGCACHE
|
||||||
|
|
||||||
/* define this if you have a flash memory storage */
|
/* define this if you have a flash memory storage */
|
||||||
#define HAVE_FLASH_STORAGE
|
#define HAVE_FLASH_STORAGE
|
||||||
|
|
||||||
#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
|
#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
|
||||||
|
|
||||||
#define CONFIG_NAND NAND_RK27XX
|
#define CONFIG_NAND NAND_RK27XX
|
||||||
#define HAVE_SW_TONE_CONTROLS
|
#define HAVE_SW_TONE_CONTROLS
|
||||||
|
|
||||||
/* commented for now */
|
/* commented for now */
|
||||||
/* #define HAVE_HOTSWAP */
|
/* #define HAVE_HOTSWAP */
|
||||||
|
|
||||||
#define NUM_DRIVES 2
|
#define NUM_DRIVES 2
|
||||||
#define SECTOR_SIZE 512
|
#define SECTOR_SIZE 512
|
||||||
|
|
||||||
/* for small(ish) SD cards */
|
/* for small(ish) SD cards */
|
||||||
#define HAVE_FAT16SUPPORT
|
#define HAVE_FAT16SUPPORT
|
||||||
|
|
||||||
/* LCD dimensions */
|
/* LCD dimensions */
|
||||||
#define LCD_WIDTH 400
|
#define LCD_WIDTH 400
|
||||||
#define LCD_HEIGHT 240
|
#define LCD_HEIGHT 240
|
||||||
#define LCD_DEPTH 16 /* pseudo 262.144 colors */
|
#define LCD_DEPTH 16 /* pseudo 262.144 colors */
|
||||||
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
||||||
|
|
||||||
/* Define this if the LCD can shut down */
|
/* Define this if the LCD can shut down */
|
||||||
/* #define HAVE_LCD_SHUTDOWN */
|
/* #define HAVE_LCD_SHUTDOWN */
|
||||||
|
|
||||||
/* Define this if your LCD can be enabled/disabled */
|
/* Define this if your LCD can be enabled/disabled */
|
||||||
/* #define HAVE_LCD_ENABLE */
|
/* #define HAVE_LCD_ENABLE */
|
||||||
|
|
||||||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||||
should be defined as well. */
|
should be defined as well. */
|
||||||
#ifndef BOOTLOADER
|
#ifndef BOOTLOADER
|
||||||
/* TODO: #define HAVE_LCD_SLEEP */
|
/* TODO: #define HAVE_LCD_SLEEP */
|
||||||
/* TODO: #define HAVE_LCD_SLEEP_SETTING */
|
/* TODO: #define HAVE_LCD_SLEEP_SETTING */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIG_KEYPAD RK27XX_GENERIC_PAD
|
#define CONFIG_KEYPAD RK27XX_GENERIC_PAD
|
||||||
|
|
||||||
/* Define this to enable morse code input */
|
/* Define this to enable morse code input */
|
||||||
#define HAVE_MORSE_INPUT
|
#define HAVE_MORSE_INPUT
|
||||||
|
|
||||||
/* Define this if you do software codec */
|
/* Define this if you do software codec */
|
||||||
#define CONFIG_CODEC SWCODEC
|
#define CONFIG_CODEC SWCODEC
|
||||||
|
|
||||||
/* define this if you have a real-time clock */
|
/* define this if you have a real-time clock */
|
||||||
/* #define CONFIG_RTC RTC_NANO2G */
|
/* #define CONFIG_RTC RTC_NANO2G */
|
||||||
|
|
||||||
/* Define if the device can wake from an RTC alarm */
|
/* Define if the device can wake from an RTC alarm */
|
||||||
/* #define HAVE_RTC_ALARM */
|
/* #define HAVE_RTC_ALARM */
|
||||||
|
|
||||||
#define CONFIG_LCD LCD_SPFD5420A
|
#define CONFIG_LCD LCD_SPFD5420A
|
||||||
|
|
||||||
/* Define the type of audio codec */
|
/* Define the type of audio codec */
|
||||||
#define HAVE_RK27XX_CODEC
|
#define HAVE_RK27XX_CODEC
|
||||||
|
|
||||||
/* #define HAVE_PCM_DMA_ADDRESS */
|
/* #define HAVE_PCM_DMA_ADDRESS */
|
||||||
|
|
||||||
/* Define this for LCD backlight available */
|
/* Define this for LCD backlight available */
|
||||||
#define HAVE_BACKLIGHT
|
#define HAVE_BACKLIGHT
|
||||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||||
#define MIN_BRIGHTNESS_SETTING 0
|
#define MIN_BRIGHTNESS_SETTING 0
|
||||||
#define MAX_BRIGHTNESS_SETTING 31
|
#define MAX_BRIGHTNESS_SETTING 31
|
||||||
#define DEFAULT_BRIGHTNESS_SETTING 20
|
#define DEFAULT_BRIGHTNESS_SETTING 20
|
||||||
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
|
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
|
||||||
|
|
||||||
/* Define this if you have a software controlled poweroff */
|
/* Define this if you have a software controlled poweroff */
|
||||||
#define HAVE_SW_POWEROFF
|
#define HAVE_SW_POWEROFF
|
||||||
|
|
||||||
/* The number of bytes reserved for loadable codecs */
|
/* The number of bytes reserved for loadable codecs */
|
||||||
#define CODEC_SIZE 0x100000
|
#define CODEC_SIZE 0x100000
|
||||||
|
|
||||||
/* The number of bytes reserved for loadable plugins */
|
/* The number of bytes reserved for loadable plugins */
|
||||||
#define PLUGIN_BUFFER_SIZE 0x80000
|
#define PLUGIN_BUFFER_SIZE 0x80000
|
||||||
|
|
||||||
/* TODO: Figure out real values */
|
/* TODO: Figure out real values */
|
||||||
#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
|
#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
|
||||||
#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
|
#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
|
||||||
#define BATTERY_CAPACITY_MAX 500 /* max. capacity selectable */
|
#define BATTERY_CAPACITY_MAX 500 /* max. capacity selectable */
|
||||||
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
|
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
|
||||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||||
|
|
||||||
/* Hardware controlled charging with monitoring */
|
/* Hardware controlled charging with monitoring */
|
||||||
#define CONFIG_CHARGING CHARGING_MONITOR
|
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||||
|
|
||||||
/* define current usage levels */
|
/* define current usage levels */
|
||||||
/* TODO: #define CURRENT_NORMAL
|
/* TODO: #define CURRENT_NORMAL
|
||||||
* TODO: #define CURRENT_BACKLIGHT 23
|
* TODO: #define CURRENT_BACKLIGHT 23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* define this if the unit can be powered or charged via USB */
|
/* define this if the unit can be powered or charged via USB */
|
||||||
#define HAVE_USB_POWER
|
#define HAVE_USB_POWER
|
||||||
|
|
||||||
/* USB On-the-go */
|
/* USB On-the-go */
|
||||||
#define CONFIG_USBOTG USBOTG_RK27XX
|
#define CONFIG_USBOTG USBOTG_RK27XX
|
||||||
|
|
||||||
/* enable these for the experimental usb stack */
|
/* enable these for the experimental usb stack */
|
||||||
#define HAVE_USBSTACK
|
#define HAVE_USBSTACK
|
||||||
|
|
||||||
#define USE_ROCKBOX_USB
|
#define USE_ROCKBOX_USB
|
||||||
#define USB_VENDOR_ID 0x071b
|
#define USB_VENDOR_ID 0x071b
|
||||||
#define USB_PRODUCT_ID 0x3202
|
#define USB_PRODUCT_ID 0x3202
|
||||||
#define HAVE_BOOTLOADER_USB_MODE
|
#define HAVE_BOOTLOADER_USB_MODE
|
||||||
|
|
||||||
/* Define this if your LCD can set contrast */
|
/* Define this if your LCD can set contrast */
|
||||||
/* #define HAVE_LCD_CONTRAST */
|
/* #define HAVE_LCD_CONTRAST */
|
||||||
|
|
||||||
/* The exact type of CPU */
|
/* The exact type of CPU */
|
||||||
#define CONFIG_CPU RK27XX
|
#define CONFIG_CPU RK27XX
|
||||||
|
|
||||||
/* I2C interface */
|
/* I2C interface */
|
||||||
#define CONFIG_I2C I2C_RK27XX
|
#define CONFIG_I2C I2C_RK27XX
|
||||||
|
|
||||||
/* Define this to the CPU frequency */
|
/* Define this to the CPU frequency */
|
||||||
#define CPU_FREQ 200000000
|
#define CPU_FREQ 200000000
|
||||||
|
|
||||||
/* define this if the hardware can be powered off while charging */
|
/* define this if the hardware can be powered off while charging */
|
||||||
/* #define HAVE_POWEROFF_WHILE_CHARGING */
|
/* #define HAVE_POWEROFF_WHILE_CHARGING */
|
||||||
|
|
||||||
/* Offset ( in the firmware file's header ) to the file CRC */
|
/* Offset ( in the firmware file's header ) to the file CRC */
|
||||||
#define FIRMWARE_OFFSET_FILE_CRC 0
|
#define FIRMWARE_OFFSET_FILE_CRC 0
|
||||||
|
|
||||||
/* Offset ( in the firmware file's header ) to the real data */
|
/* Offset ( in the firmware file's header ) to the real data */
|
||||||
#define FIRMWARE_OFFSET_FILE_DATA 8
|
#define FIRMWARE_OFFSET_FILE_DATA 8
|
||||||
|
|
||||||
#define STORAGE_NEEDS_ALIGN
|
#define STORAGE_NEEDS_ALIGN
|
||||||
|
|
||||||
/* Define this if you have adjustable CPU frequency */
|
/* Define this if you have adjustable CPU frequency */
|
||||||
/* #define HAVE_ADJUSTABLE_CPU_FREQ */
|
/* #define HAVE_ADJUSTABLE_CPU_FREQ */
|
||||||
|
|
||||||
#define BOOTFILE_EXT "rk27"
|
#define BOOTFILE_EXT "rk27"
|
||||||
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
#define BOOTFILE "rockbox." BOOTFILE_EXT
|
||||||
#define BOOTDIR "/.rockbox"
|
#define BOOTDIR "/.rockbox"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: dac.h 24158 2010-01-03 11:31:14Z Buschel $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: mas.h 24154 2010-01-03 10:27:43Z Buschel $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
||||||
*
|
*
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: lcd-clipzip.c 30465 2011-09-06 16:55:52Z bertrik $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Bertrik Sikken
|
* Copyright (C) 2011 Bertrik Sikken
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,308 +1,308 @@
|
||||||
.section .text.post_mortem_stub, "ax", %progbits
|
.section .text.post_mortem_stub, "ax", %progbits
|
||||||
.align 4
|
.align 4
|
||||||
.global post_mortem_stub
|
.global post_mortem_stub
|
||||||
.type post_mortem_stub, %function
|
.type post_mortem_stub, %function
|
||||||
post_mortem_stub:
|
post_mortem_stub:
|
||||||
MSR CPSR_c, #0xD3 @ Supervisor mode, no IRQs, no FIQs
|
MSR CPSR_c, #0xD3 @ Supervisor mode, no IRQs, no FIQs
|
||||||
MRC p15, 0, R0,c1,c0
|
MRC p15, 0, R0,c1,c0
|
||||||
BIC R0, R0, #5
|
BIC R0, R0, #5
|
||||||
MCR p15, 0, R0,c1,c0 @ Disable the Protection Unit and DCache
|
MCR p15, 0, R0,c1,c0 @ Disable the Protection Unit and DCache
|
||||||
MOV R13, #0
|
MOV R13, #0
|
||||||
pms_flushcache_loop:
|
pms_flushcache_loop:
|
||||||
MCR p15, 0, R13,c7,c14,2
|
MCR p15, 0, R13,c7,c14,2
|
||||||
ADD R0, R13, #0x10
|
ADD R0, R13, #0x10
|
||||||
MCR p15, 0, R0,c7,c14,2
|
MCR p15, 0, R0,c7,c14,2
|
||||||
ADD R0, R0, #0x10
|
ADD R0, R0, #0x10
|
||||||
MCR p15, 0, R0,c7,c14,2
|
MCR p15, 0, R0,c7,c14,2
|
||||||
ADD R0, R0, #0x10
|
ADD R0, R0, #0x10
|
||||||
MCR p15, 0, R0,c7,c14,2
|
MCR p15, 0, R0,c7,c14,2
|
||||||
ADDS R13, R13, #0x04000000
|
ADDS R13, R13, #0x04000000
|
||||||
BNE pms_flushcache_loop
|
BNE pms_flushcache_loop
|
||||||
MCR p15, 0, R13,c7,c10,4
|
MCR p15, 0, R13,c7,c10,4
|
||||||
|
|
||||||
LDR R7, pms_00080200
|
LDR R7, pms_00080200
|
||||||
ORR R8, R7, #0x8000
|
ORR R8, R7, #0x8000
|
||||||
ADR R9, pms_recvbuf
|
ADR R9, pms_recvbuf
|
||||||
LDR R10, pms_20080040
|
LDR R10, pms_20080040
|
||||||
MOV R11, #0x38800000
|
MOV R11, #0x38800000
|
||||||
MOV R12, #1
|
MOV R12, #1
|
||||||
|
|
||||||
MOV R2, #0x3C400000
|
MOV R2, #0x3C400000
|
||||||
ADD R1, R2, #0x00100000 @ Enable USB clocks
|
ADD R1, R2, #0x00100000 @ Enable USB clocks
|
||||||
LDR R0, [R1,#0x28]
|
LDR R0, [R1,#0x28]
|
||||||
BIC R0, R0, #0x4000
|
BIC R0, R0, #0x4000
|
||||||
STR R0, [R1,#0x28]
|
STR R0, [R1,#0x28]
|
||||||
LDR R0, [R1,#0x40]
|
LDR R0, [R1,#0x40]
|
||||||
BIC R0, R0, #0x800
|
BIC R0, R0, #0x800
|
||||||
STR R0, [R1,#0x40]
|
STR R0, [R1,#0x40]
|
||||||
LDR R0, pms_20803180 @ Clocking config
|
LDR R0, pms_20803180 @ Clocking config
|
||||||
STR R0, [R1]
|
STR R0, [R1]
|
||||||
MOV R0, #0x280
|
MOV R0, #0x280
|
||||||
STR R0, [R1,#0x3C]
|
STR R0, [R1,#0x3C]
|
||||||
MRC p15, 0, R0,c1,c0
|
MRC p15, 0, R0,c1,c0
|
||||||
ORR R0, R0, #0xc0000000
|
ORR R0, R0, #0xc0000000
|
||||||
MCR p15, 0, R0,c1,c0 @ Asynchronous mode
|
MCR p15, 0, R0,c1,c0 @ Asynchronous mode
|
||||||
|
|
||||||
STR R13, [R11,#0xE00] @ PHY clock enable
|
STR R13, [R11,#0xE00] @ PHY clock enable
|
||||||
|
|
||||||
MOV R1, #0x800
|
MOV R1, #0x800
|
||||||
ORR R0, R2, #2
|
ORR R0, R2, #2
|
||||||
STR R0, [R11,#0x804] @ USB2 Gadget: Soft disconnect
|
STR R0, [R11,#0x804] @ USB2 Gadget: Soft disconnect
|
||||||
|
|
||||||
STR R13, [R2] @ USB2 PHY: Power on
|
STR R13, [R2] @ USB2 PHY: Power on
|
||||||
STR R12, [R2,#0x08] @ USB2 PHY: Assert Software Reset
|
STR R12, [R2,#0x08] @ USB2 PHY: Assert Software Reset
|
||||||
MOV R0, #0x10000
|
MOV R0, #0x10000
|
||||||
pms_wait:
|
pms_wait:
|
||||||
SUBS R0, R0, #1
|
SUBS R0, R0, #1
|
||||||
BNE pms_wait
|
BNE pms_wait
|
||||||
STR R13, [R2,#0x08] @ USB2 PHY: Deassert Software Reset
|
STR R13, [R2,#0x08] @ USB2 PHY: Deassert Software Reset
|
||||||
STR R13, [R2,#0x04] @ USB2 PHY: Clock is 48MHz
|
STR R13, [R2,#0x04] @ USB2 PHY: Clock is 48MHz
|
||||||
|
|
||||||
STR R12, [R11,#0x10] @ USB2 Gadget: Assert Core Software Reset
|
STR R12, [R11,#0x10] @ USB2 Gadget: Assert Core Software Reset
|
||||||
pms_waitcorereset:
|
pms_waitcorereset:
|
||||||
LDR R0, [R11,#0x10] @ USB2 Gadget: Wait for Core to reset
|
LDR R0, [R11,#0x10] @ USB2 Gadget: Wait for Core to reset
|
||||||
TST R0, #1
|
TST R0, #1
|
||||||
BNE pms_waitcorereset
|
BNE pms_waitcorereset
|
||||||
TST R0, #0x80000000 @ USB2 Gadget: Wait for AHB IDLE
|
TST R0, #0x80000000 @ USB2 Gadget: Wait for AHB IDLE
|
||||||
BEQ pms_waitcorereset
|
BEQ pms_waitcorereset
|
||||||
|
|
||||||
MOV R0, #0x200
|
MOV R0, #0x200
|
||||||
STR R0, [R11,#0x24] @ USB2 Gadget: RX FIFO size: 512 bytes
|
STR R0, [R11,#0x24] @ USB2 Gadget: RX FIFO size: 512 bytes
|
||||||
ORR R0, R0, #0x2000000
|
ORR R0, R0, #0x2000000
|
||||||
STR R0, [R11,#0x28] @ USB2 Gadget: Non-periodic TX FIFO size: 512 bytes
|
STR R0, [R11,#0x28] @ USB2 Gadget: Non-periodic TX FIFO size: 512 bytes
|
||||||
MOV R0, #0x26
|
MOV R0, #0x26
|
||||||
STR R0, [R11,#0x08] @ USB2 Gadget: DMA Enable, Burst Length: 4, Mask Interrupts
|
STR R0, [R11,#0x08] @ USB2 Gadget: DMA Enable, Burst Length: 4, Mask Interrupts
|
||||||
MOV R0, #0x1400
|
MOV R0, #0x1400
|
||||||
ADD R0, R0, #8
|
ADD R0, R0, #8
|
||||||
STR R0, [R11,#0x0C] @ USB2 Gadget: PHY IF is 16bit, Turnaround 5
|
STR R0, [R11,#0x0C] @ USB2 Gadget: PHY IF is 16bit, Turnaround 5
|
||||||
STR R1, [R11,#0x804] @ USB2 Gadget: Soft reconnect
|
STR R1, [R11,#0x804] @ USB2 Gadget: Soft reconnect
|
||||||
|
|
||||||
ADR R14, pms_ctrlbuf
|
ADR R14, pms_ctrlbuf
|
||||||
ORR R5, R8, #0x84000000
|
ORR R5, R8, #0x84000000
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_mainloop:
|
pms_mainloop:
|
||||||
LDR R3, [R11,#0x14] @ Global USB interrupts
|
LDR R3, [R11,#0x14] @ Global USB interrupts
|
||||||
TST R3, #0x00001000 @ BUS reset
|
TST R3, #0x00001000 @ BUS reset
|
||||||
BEQ pms_noreset
|
BEQ pms_noreset
|
||||||
MOV R0, #0x500
|
MOV R0, #0x500
|
||||||
STR R0, [R11,#0x804]
|
STR R0, [R11,#0x804]
|
||||||
MOV R0, #4
|
MOV R0, #4
|
||||||
STR R0, [R11,#0x800] @ USB2 Gadget: Device Address 0, STALL on non-zero length status stage
|
STR R0, [R11,#0x800] @ USB2 Gadget: Device Address 0, STALL on non-zero length status stage
|
||||||
MOV R0, #0x8000
|
MOV R0, #0x8000
|
||||||
STR R0, [R11,#0x900] @ USB2 Gadget: Endpoint 0 IN Control: ACTIVE
|
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 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
|
STR R14, [R11,#0xB14] @ USB2 Gadget: Endpoint 0 OUT DMA Address: pms_ctrlbuf
|
||||||
ORR R6, R0, #0x84000000
|
ORR R6, R0, #0x84000000
|
||||||
STR R6, [R11,#0xB00] @ USB2 Gadget: Endpoint 0 OUT Control: ENABLE CLEARNAK
|
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,#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 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 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
|
STR R9, [R11,#0xB94] @ USB2 Gadget: Endpoint 4 OUT DMA Address: pms_recvbuf
|
||||||
ORR R4, R5, #0x10000000
|
ORR R4, R5, #0x10000000
|
||||||
STR R4, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ENABLE CLEARNAK DATA0
|
STR R4, [R11,#0xB80] @ USB2 Gadget: Endpoint 4 OUT Control: ENABLE CLEARNAK DATA0
|
||||||
pms_noreset:
|
pms_noreset:
|
||||||
LDR R0, [R11,#0x908] @ Just ACK all IN events...
|
LDR R0, [R11,#0x908] @ Just ACK all IN events...
|
||||||
STR R0, [R11,#0x908]
|
STR R0, [R11,#0x908]
|
||||||
LDR R0, [R11,#0x968]
|
LDR R0, [R11,#0x968]
|
||||||
STR R0, [R11,#0x968]
|
STR R0, [R11,#0x968]
|
||||||
LDR R2, [R11,#0xB08]
|
LDR R2, [R11,#0xB08]
|
||||||
MOVS R2, R2 @ Event on OUT EP0
|
MOVS R2, R2 @ Event on OUT EP0
|
||||||
BEQ pms_noep0out
|
BEQ pms_noep0out
|
||||||
TST R2, #8 @ SETUP phase done
|
TST R2, #8 @ SETUP phase done
|
||||||
BEQ pms_controldone
|
BEQ pms_controldone
|
||||||
LDRB R0, [R14,#1] @ Get request type
|
LDRB R0, [R14,#1] @ Get request type
|
||||||
CMP R0, #0
|
CMP R0, #0
|
||||||
BEQ pms_GET_STATUS
|
BEQ pms_GET_STATUS
|
||||||
CMP R0, #1
|
CMP R0, #1
|
||||||
BEQ pms_CLEAR_FEATURE
|
BEQ pms_CLEAR_FEATURE
|
||||||
CMP R0, #3
|
CMP R0, #3
|
||||||
BEQ pms_SET_FEATURE
|
BEQ pms_SET_FEATURE
|
||||||
CMP R0, #5
|
CMP R0, #5
|
||||||
BEQ pms_SET_ADDRESS
|
BEQ pms_SET_ADDRESS
|
||||||
CMP R0, #6
|
CMP R0, #6
|
||||||
BEQ pms_GET_DESCRIPTOR
|
BEQ pms_GET_DESCRIPTOR
|
||||||
CMP R0, #8
|
CMP R0, #8
|
||||||
BEQ pms_GET_CONFIGURATION
|
BEQ pms_GET_CONFIGURATION
|
||||||
CMP R0, #9
|
CMP R0, #9
|
||||||
BEQ pms_SET_CONFIGURATION
|
BEQ pms_SET_CONFIGURATION
|
||||||
pms_ctrlstall:
|
pms_ctrlstall:
|
||||||
LDR R0, [R11,#0x900]
|
LDR R0, [R11,#0x900]
|
||||||
ORR R0, R0, #0x00200000
|
ORR R0, R0, #0x00200000
|
||||||
STR R0, [R11,#0x900] @ Stall IN EP0
|
STR R0, [R11,#0x900] @ Stall IN EP0
|
||||||
LDR R0, [R11,#0xB00]
|
LDR R0, [R11,#0xB00]
|
||||||
ORR R0, R0, #0x00200000
|
ORR R0, R0, #0x00200000
|
||||||
STR R0, [R11,#0xB00] @ Stall OUT EP0
|
STR R0, [R11,#0xB00] @ Stall OUT EP0
|
||||||
pms_controldone:
|
pms_controldone:
|
||||||
STR R10, [R11,#0xB10] @ OUT EP0: 64 Bytes, 1 Packet, 1 Setup Packet
|
STR R10, [R11,#0xB10] @ OUT EP0: 64 Bytes, 1 Packet, 1 Setup Packet
|
||||||
STR R14, [R11,#0xB14] @ OUT EP0: DMA address
|
STR R14, [R11,#0xB14] @ OUT EP0: DMA address
|
||||||
STR R6, [R11,#0xB00] @ OUT EP0: Enable ClearNAK
|
STR R6, [R11,#0xB00] @ OUT EP0: Enable ClearNAK
|
||||||
pms_noep0out:
|
pms_noep0out:
|
||||||
STR R2, [R11,#0xB08] @ ACK it, whatever it was...
|
STR R2, [R11,#0xB08] @ ACK it, whatever it was...
|
||||||
LDR R2, [R11,#0xB88]
|
LDR R2, [R11,#0xB88]
|
||||||
MOVS R2, R2 @ Event on OUT EP4
|
MOVS R2, R2 @ Event on OUT EP4
|
||||||
BEQ pms_noep1out
|
BEQ pms_noep1out
|
||||||
TST R2, #1 @ XFER complete
|
TST R2, #1 @ XFER complete
|
||||||
BEQ pms_datadone
|
BEQ pms_datadone
|
||||||
LDR R0, pms_000001FF
|
LDR R0, pms_000001FF
|
||||||
LDR R1, pms_recvbuf+4
|
LDR R1, pms_recvbuf+4
|
||||||
ADD R0, R0, R1
|
ADD R0, R0, R1
|
||||||
MOV R0, R0,LSR#9
|
MOV R0, R0,LSR#9
|
||||||
ORR R1, R1, R0,LSL#19 @ Number of packets
|
ORR R1, R1, R0,LSL#19 @ Number of packets
|
||||||
LDR R0, pms_recvbuf
|
LDR R0, pms_recvbuf
|
||||||
STR R1, [R11,#0x970] @ EP3 IN: Number of packets, size
|
STR R1, [R11,#0x970] @ EP3 IN: Number of packets, size
|
||||||
STR R0, [R11,#0x974] @ EP3 IN: DMA address
|
STR R0, [R11,#0x974] @ EP3 IN: DMA address
|
||||||
STR R5, [R11,#0x960] @ EP3 IN: Enable ClearNAK
|
STR R5, [R11,#0x960] @ EP3 IN: Enable ClearNAK
|
||||||
pms_datadone:
|
pms_datadone:
|
||||||
STR R7, [R11,#0xB90] @ OUT EP4: 512 Bytes, 1 Packet
|
STR R7, [R11,#0xB90] @ OUT EP4: 512 Bytes, 1 Packet
|
||||||
STR R9, [R11,#0xB94] @ Out EP4: DMA address
|
STR R9, [R11,#0xB94] @ Out EP4: DMA address
|
||||||
STR R5, [R11,#0xB80] @ Out EP4: Enable ClearNAK
|
STR R5, [R11,#0xB80] @ Out EP4: Enable ClearNAK
|
||||||
pms_noep1out:
|
pms_noep1out:
|
||||||
STR R2, [R11,#0xB88] @ ACK it, whatever it was...
|
STR R2, [R11,#0xB88] @ ACK it, whatever it was...
|
||||||
STR R3, [R11,#0x14] @ ACK global ints
|
STR R3, [R11,#0x14] @ ACK global ints
|
||||||
B pms_mainloop
|
B pms_mainloop
|
||||||
|
|
||||||
pms_CLEAR_FEATURE:
|
pms_CLEAR_FEATURE:
|
||||||
LDRB R0, [R14]
|
LDRB R0, [R14]
|
||||||
CMP R0, #2
|
CMP R0, #2
|
||||||
LDREQ R0, [R14,#2]
|
LDREQ R0, [R14,#2]
|
||||||
BICEQ R0, R0, #0x00800000
|
BICEQ R0, R0, #0x00800000
|
||||||
CMPEQ R0, #0x00010000
|
CMPEQ R0, #0x00010000
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_SET_CONFIGURATION:
|
pms_SET_CONFIGURATION:
|
||||||
ORREQ R0, R8, #0x10000000
|
ORREQ R0, R8, #0x10000000
|
||||||
STREQ R0, [R11,#0x960] @ EP3 IN: Set DATA0 PID
|
STREQ R0, [R11,#0x960] @ EP3 IN: Set DATA0 PID
|
||||||
STREQ R4, [R11,#0xB80] @ EP4 OUT: Set DATA0 PID
|
STREQ R4, [R11,#0xB80] @ EP4 OUT: Set DATA0 PID
|
||||||
B pms_SET_FEATURE @ zero-length ACK
|
B pms_SET_FEATURE @ zero-length ACK
|
||||||
|
|
||||||
pms_GET_CONFIGURATION:
|
pms_GET_CONFIGURATION:
|
||||||
MOV R1, #1
|
MOV R1, #1
|
||||||
STR R1, [R14]
|
STR R1, [R14]
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_ctrlsend:
|
pms_ctrlsend:
|
||||||
ORR R0, R1, #0x00080000 @ 1 Packet
|
ORR R0, R1, #0x00080000 @ 1 Packet
|
||||||
STR R0, [R11,#0x910] @ EP0 IN: 1 Packet, Size as in R1
|
STR R0, [R11,#0x910] @ EP0 IN: 1 Packet, Size as in R1
|
||||||
STR R14, [R11,#0x914] @ EP0 IN: DMA address
|
STR R14, [R11,#0x914] @ EP0 IN: DMA address
|
||||||
ORR R0, R6, #0x1800
|
ORR R0, R6, #0x1800
|
||||||
STR R0, [R11,#0x900] @ EP0 IN: Enable ClearNAK
|
STR R0, [R11,#0x900] @ EP0 IN: Enable ClearNAK
|
||||||
ADR R14, pms_ctrlbuf
|
ADR R14, pms_ctrlbuf
|
||||||
B pms_controldone
|
B pms_controldone
|
||||||
|
|
||||||
pms_GET_DESCRIPTOR:
|
pms_GET_DESCRIPTOR:
|
||||||
LDRB R0, [R14,#3] @ Descriptor type
|
LDRB R0, [R14,#3] @ Descriptor type
|
||||||
CMP R0, #1
|
CMP R0, #1
|
||||||
ADREQ R14, pms_devicedescriptor
|
ADREQ R14, pms_devicedescriptor
|
||||||
BEQ pms_senddescriptor
|
BEQ pms_senddescriptor
|
||||||
CMP R0, #2
|
CMP R0, #2
|
||||||
ADREQ R14, pms_configurationdescriptor
|
ADREQ R14, pms_configurationdescriptor
|
||||||
MOVEQ R1, #0x20
|
MOVEQ R1, #0x20
|
||||||
BEQ pms_senddescriptorcustomsize
|
BEQ pms_senddescriptorcustomsize
|
||||||
CMP R0, #3
|
CMP R0, #3
|
||||||
BNE pms_ctrlstall
|
BNE pms_ctrlstall
|
||||||
LDRB R0, [R14,#2] @ String descriptor index
|
LDRB R0, [R14,#2] @ String descriptor index
|
||||||
CMP R0, #0
|
CMP R0, #0
|
||||||
LDREQ R0, pms_langstringdescriptor
|
LDREQ R0, pms_langstringdescriptor
|
||||||
STREQ R0, [R14]
|
STREQ R0, [R14]
|
||||||
BEQ pms_senddescriptor
|
BEQ pms_senddescriptor
|
||||||
CMP R0, #1
|
CMP R0, #1
|
||||||
CMPNE R0, #2
|
CMPNE R0, #2
|
||||||
ADREQ R14, pms_devnamestringdescriptor
|
ADREQ R14, pms_devnamestringdescriptor
|
||||||
BNE pms_ctrlstall
|
BNE pms_ctrlstall
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_senddescriptor:
|
pms_senddescriptor:
|
||||||
LDRB R1, [R14] @ Descriptor length
|
LDRB R1, [R14] @ Descriptor length
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_senddescriptorcustomsize:
|
pms_senddescriptorcustomsize:
|
||||||
LDRH R0, pms_ctrlbuf+6 @ Requested length
|
LDRH R0, pms_ctrlbuf+6 @ Requested length
|
||||||
CMP R0, R1
|
CMP R0, R1
|
||||||
MOVLO R1, R0
|
MOVLO R1, R0
|
||||||
B pms_ctrlsend
|
B pms_ctrlsend
|
||||||
|
|
||||||
pms_SET_ADDRESS:
|
pms_SET_ADDRESS:
|
||||||
LDRH R1, [R14,#2] @ new address
|
LDRH R1, [R14,#2] @ new address
|
||||||
LDR R0, [R11,#0x800]
|
LDR R0, [R11,#0x800]
|
||||||
BIC R0, R0, #0x000007F0
|
BIC R0, R0, #0x000007F0
|
||||||
ORR R0, R0, R1,LSL#4
|
ORR R0, R0, R1,LSL#4
|
||||||
STR R0, [R11,#0x800] @ set new address
|
STR R0, [R11,#0x800] @ set new address
|
||||||
@ fallthrough
|
@ fallthrough
|
||||||
|
|
||||||
pms_SET_FEATURE:
|
pms_SET_FEATURE:
|
||||||
MOV R1, #0 @ zero-length ACK
|
MOV R1, #0 @ zero-length ACK
|
||||||
B pms_ctrlsend
|
B pms_ctrlsend
|
||||||
|
|
||||||
pms_20803180:
|
pms_20803180:
|
||||||
.word 0x20803180
|
.word 0x20803180
|
||||||
|
|
||||||
.ltorg
|
.ltorg
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
|
|
||||||
pms_configurationdescriptor:
|
pms_configurationdescriptor:
|
||||||
.word 0x00200209
|
.word 0x00200209
|
||||||
.word 0xC0000101
|
.word 0xC0000101
|
||||||
.word 0x00040932
|
.word 0x00040932
|
||||||
.word 0xFFFF0200
|
.word 0xFFFF0200
|
||||||
.word 0x050700FF
|
.word 0x050700FF
|
||||||
.word 0x02000204
|
.word 0x02000204
|
||||||
.word 0x83050701
|
.word 0x83050701
|
||||||
.word 0x01020002
|
.word 0x01020002
|
||||||
|
|
||||||
pms_devicedescriptor:
|
pms_devicedescriptor:
|
||||||
.word 0x02000112
|
.word 0x02000112
|
||||||
.word 0x40FFFFFF
|
.word 0x40FFFFFF
|
||||||
.word 0xA112FFFF
|
.word 0xA112FFFF
|
||||||
.word 0x02010001
|
.word 0x02010001
|
||||||
.word 0x00010100
|
.word 0x00010100
|
||||||
|
|
||||||
pms_00080200:
|
pms_00080200:
|
||||||
.word 0x00080200
|
.word 0x00080200
|
||||||
|
|
||||||
pms_20080040:
|
pms_20080040:
|
||||||
.word 0x20080040
|
.word 0x20080040
|
||||||
|
|
||||||
pms_000001FF:
|
pms_000001FF:
|
||||||
.word 0x000001FF
|
.word 0x000001FF
|
||||||
|
|
||||||
pms_devnamestringdescriptor:
|
pms_devnamestringdescriptor:
|
||||||
.word 0x0052030C
|
.word 0x0052030C
|
||||||
.word 0x00500042
|
.word 0x00500042
|
||||||
.word 0x0053004D
|
.word 0x0053004D
|
||||||
|
|
||||||
pms_langstringdescriptor:
|
pms_langstringdescriptor:
|
||||||
.word 0x04090304
|
.word 0x04090304
|
||||||
|
|
||||||
pms_ctrlbuf:
|
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
|
||||||
.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:
|
pms_recvbuf:
|
||||||
.word 0
|
.word 0
|
||||||
.word 0
|
.word 0
|
||||||
|
|
||||||
pms_GET_STATUS:
|
pms_GET_STATUS:
|
||||||
LDRB R0, [R14]
|
LDRB R0, [R14]
|
||||||
CMP R0, #0x80
|
CMP R0, #0x80
|
||||||
STREQ R12, [R14]
|
STREQ R12, [R14]
|
||||||
STRNE R13, [R14]
|
STRNE R13, [R14]
|
||||||
MOV R1, #2
|
MOV R1, #2
|
||||||
B pms_ctrlsend
|
B pms_ctrlsend
|
||||||
|
|
||||||
.size post_mortem_stub, .-post_mortem_stub
|
.size post_mortem_stub, .-post_mortem_stub
|
||||||
|
|
|
@ -1,166 +1,166 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: debug-s5l8700.c 28719 2010-12-01 18:35:01Z Buschel $
|
* $Id: debug-s5l8700.c 28719 2010-12-01 18:35:01Z Buschel $
|
||||||
*
|
*
|
||||||
* Copyright © 2008 Rafaël Carré
|
* Copyright © 2008 Rafaël Carré
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "debug-target.h"
|
#include "debug-target.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "pmu-target.h"
|
#include "pmu-target.h"
|
||||||
#include "pcm-target.h"
|
#include "pcm-target.h"
|
||||||
|
|
||||||
/* Skeleton for adding target specific debug info to the debug menu
|
/* Skeleton for adding target specific debug info to the debug menu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEBUG_PRINTF(a, varargs...) lcd_putsf(0, line++, (a), ##varargs);
|
#define _DEBUG_PRINTF(a, varargs...) lcd_putsf(0, line++, (a), ##varargs);
|
||||||
|
|
||||||
extern int lcd_type;
|
extern int lcd_type;
|
||||||
bool dbg_hw_info(void)
|
bool dbg_hw_info(void)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
int i;
|
int i;
|
||||||
unsigned int state = 0;
|
unsigned int state = 0;
|
||||||
const unsigned int max_states=3;
|
const unsigned int max_states=3;
|
||||||
|
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
state=0;
|
state=0;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
line = 0;
|
line = 0;
|
||||||
|
|
||||||
if(state == 0)
|
if(state == 0)
|
||||||
{
|
{
|
||||||
_DEBUG_PRINTF("CPU:");
|
_DEBUG_PRINTF("CPU:");
|
||||||
_DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
|
_DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
_DEBUG_PRINTF("LCD type: %d", lcd_type);
|
_DEBUG_PRINTF("LCD type: %d", lcd_type);
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
else if(state==1)
|
else if(state==1)
|
||||||
{
|
{
|
||||||
_DEBUG_PRINTF("PMU:");
|
_DEBUG_PRINTF("PMU:");
|
||||||
for(i=0;i<7;i++)
|
for(i=0;i<7;i++)
|
||||||
{
|
{
|
||||||
char *device[] = {"(unknown)",
|
char *device[] = {"(unknown)",
|
||||||
"(unknown)",
|
"(unknown)",
|
||||||
"(unknown)",
|
"(unknown)",
|
||||||
"(unknown)",
|
"(unknown)",
|
||||||
"(unknown)",
|
"(unknown)",
|
||||||
"(unknown)",
|
"(unknown)",
|
||||||
"(unknown)"};
|
"(unknown)"};
|
||||||
_DEBUG_PRINTF("ldo%d %s: %dmV %s",i,
|
_DEBUG_PRINTF("ldo%d %s: %dmV %s",i,
|
||||||
pmu_read(0x2e + (i << 1))?" on":"off",
|
pmu_read(0x2e + (i << 1))?" on":"off",
|
||||||
900 + pmu_read(0x2d + (i << 1))*100,
|
900 + pmu_read(0x2d + (i << 1))*100,
|
||||||
device[i]);
|
device[i]);
|
||||||
}
|
}
|
||||||
_DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
|
_DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
|
||||||
_DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
|
_DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
|
||||||
line++;
|
line++;
|
||||||
_DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
|
_DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
|
||||||
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
||||||
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
||||||
}
|
}
|
||||||
else if(state==2)
|
else if(state==2)
|
||||||
{
|
{
|
||||||
_DEBUG_PRINTF("Audio DMA:");
|
_DEBUG_PRINTF("Audio DMA:");
|
||||||
_DEBUG_PRINTF(">%08X %08X %08X %08X %08X", DMAC0C0CONFIG, DMAC0C0SRCADDR,
|
_DEBUG_PRINTF(">%08X %08X %08X %08X %08X", DMAC0C0CONFIG, DMAC0C0SRCADDR,
|
||||||
DMAC0C0DESTADDR, DMAC0C0NEXTLLI, DMAC0C0CONTROL);
|
DMAC0C0DESTADDR, DMAC0C0NEXTLLI, DMAC0C0CONTROL);
|
||||||
for(i = 0; i < PCM_LLICOUNT; i++)
|
for(i = 0; i < PCM_LLICOUNT; i++)
|
||||||
_DEBUG_PRINTF("%08X: %08X %08X %08X %08X", &pcm_lli[i], pcm_lli[i].srcaddr,
|
_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);
|
pcm_lli[i].dstaddr, pcm_lli[i].nextlli, pcm_lli[i].control);
|
||||||
_DEBUG_PRINTF("chunk: %08X %08X", pcm_chunksize, pcm_remaining);
|
_DEBUG_PRINTF("chunk: %08X %08X", pcm_chunksize, pcm_remaining);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state=0;
|
state=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
switch(button_get_w_tmo(HZ/20))
|
switch(button_get_w_tmo(HZ/20))
|
||||||
{
|
{
|
||||||
case BUTTON_SCROLL_BACK:
|
case BUTTON_SCROLL_BACK:
|
||||||
if(state!=0) state--;
|
if(state!=0) state--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTTON_SCROLL_FWD:
|
case BUTTON_SCROLL_FWD:
|
||||||
if(state!=max_states-1)
|
if(state!=max_states-1)
|
||||||
{
|
{
|
||||||
state++;
|
state++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_CANCEL:
|
case DEBUG_CANCEL:
|
||||||
case BUTTON_REL:
|
case BUTTON_REL:
|
||||||
lcd_setfont(FONT_UI);
|
lcd_setfont(FONT_UI);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_setfont(FONT_UI);
|
lcd_setfont(FONT_UI);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dbg_ports(void)
|
bool dbg_ports(void)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
line = 0;
|
line = 0;
|
||||||
|
|
||||||
_DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT(0));
|
_DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT(0));
|
||||||
_DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT(1));
|
_DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT(1));
|
||||||
_DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT(2));
|
_DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT(2));
|
||||||
_DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT(3));
|
_DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT(3));
|
||||||
_DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT(4));
|
_DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT(4));
|
||||||
_DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT(5));
|
_DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT(5));
|
||||||
_DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT(6));
|
_DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT(6));
|
||||||
_DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT(7));
|
_DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT(7));
|
||||||
_DEBUG_PRINTF("GPIO 8: %08x",(unsigned int)PDAT(8));
|
_DEBUG_PRINTF("GPIO 8: %08x",(unsigned int)PDAT(8));
|
||||||
_DEBUG_PRINTF("GPIO 9: %08x",(unsigned int)PDAT(9));
|
_DEBUG_PRINTF("GPIO 9: %08x",(unsigned int)PDAT(9));
|
||||||
_DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT(10));
|
_DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT(10));
|
||||||
_DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT(11));
|
_DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT(11));
|
||||||
_DEBUG_PRINTF("GPIO 12: %08x",(unsigned int)PDAT(12));
|
_DEBUG_PRINTF("GPIO 12: %08x",(unsigned int)PDAT(12));
|
||||||
_DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT(13));
|
_DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT(13));
|
||||||
_DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT(14));
|
_DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT(14));
|
||||||
_DEBUG_PRINTF("GPIO 15: %08x",(unsigned int)PDAT(15));
|
_DEBUG_PRINTF("GPIO 15: %08x",(unsigned int)PDAT(15));
|
||||||
_DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
|
_DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
|
||||||
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lcd_setfont(FONT_UI);
|
lcd_setfont(FONT_UI);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: debug-target.h 28522 2010-11-06 14:24:25Z wodz $
|
* $Id: debug-target.h 28522 2010-11-06 14:24:25Z wodz $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 by Karl Kurbjun
|
* Copyright (C) 2007 by Karl Kurbjun
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _DEBUG_TARGET_H_
|
#ifndef _DEBUG_TARGET_H_
|
||||||
#define _DEBUG_TARGET_H_
|
#define _DEBUG_TARGET_H_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define DEBUG_CANCEL BUTTON_MENU
|
#define DEBUG_CANCEL BUTTON_MENU
|
||||||
|
|
||||||
bool dbg_hw_info(void);
|
bool dbg_hw_info(void);
|
||||||
bool dbg_ports(void);
|
bool dbg_ports(void);
|
||||||
|
|
||||||
#endif /* _DEBUG_TARGET_H_ */
|
#endif /* _DEBUG_TARGET_H_ */
|
||||||
|
|
||||||
|
|
|
@ -1,196 +1,196 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: i2c-s5l8700.c 28589 2010-11-14 15:19:30Z theseven $
|
* $Id: i2c-s5l8700.c 28589 2010-11-14 15:19:30Z theseven $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 by Bertrik Sikken
|
* Copyright (C) 2009 by Bertrik Sikken
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "i2c-s5l8702.h"
|
#include "i2c-s5l8702.h"
|
||||||
|
|
||||||
/* Driver for the s5l8700 built-in I2C controller in master mode
|
/* Driver for the s5l8700 built-in I2C controller in master mode
|
||||||
|
|
||||||
Both the i2c_read and i2c_write function take the following arguments:
|
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
|
* slave, the address of the i2c slave device to read from / write to
|
||||||
* address, optional sub-address in the i2c slave (unused if -1)
|
* address, optional sub-address in the i2c slave (unused if -1)
|
||||||
* len, number of bytes to be transfered
|
* len, number of bytes to be transfered
|
||||||
* data, pointer to data to be transfered
|
* data, pointer to data to be transfered
|
||||||
A return value < 0 indicates an error.
|
A return value < 0 indicates an error.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
* blocks the calling thread for the entire duraton of the i2c transfer but
|
* blocks the calling thread for the entire duraton of the i2c transfer but
|
||||||
uses wakeup_wait/wakeup_signal to allow other threads to run.
|
uses wakeup_wait/wakeup_signal to allow other threads to run.
|
||||||
* ACK from slave is not checked, so functions never return an error
|
* ACK from slave is not checked, so functions never return an error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct mutex i2c_mtx[2];
|
static struct mutex i2c_mtx[2];
|
||||||
|
|
||||||
static void i2c_on(int bus)
|
static void i2c_on(int bus)
|
||||||
{
|
{
|
||||||
/* enable I2C clock */
|
/* enable I2C clock */
|
||||||
PWRCON(1) &= ~(1 << 4);
|
PWRCON(1) &= ~(1 << 4);
|
||||||
|
|
||||||
IICCON(bus) = (1 << 7) | /* ACK_GEN */
|
IICCON(bus) = (1 << 7) | /* ACK_GEN */
|
||||||
(0 << 6) | /* CLKSEL = PCLK/16 */
|
(0 << 6) | /* CLKSEL = PCLK/16 */
|
||||||
(1 << 5) | /* INT_EN */
|
(1 << 5) | /* INT_EN */
|
||||||
(1 << 4) | /* IRQ clear */
|
(1 << 4) | /* IRQ clear */
|
||||||
(7 << 0); /* CK_REG */
|
(7 << 0); /* CK_REG */
|
||||||
|
|
||||||
/* serial output on */
|
/* serial output on */
|
||||||
IICSTAT(bus) = (1 << 4);
|
IICSTAT(bus) = (1 << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_off(int bus)
|
static void i2c_off(int bus)
|
||||||
{
|
{
|
||||||
/* serial output off */
|
/* serial output off */
|
||||||
IICSTAT(bus) = 0;
|
IICSTAT(bus) = 0;
|
||||||
|
|
||||||
/* disable I2C clock */
|
/* disable I2C clock */
|
||||||
PWRCON(1) |= (1 << 4);
|
PWRCON(1) |= (1 << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2c_init()
|
void i2c_init()
|
||||||
{
|
{
|
||||||
mutex_init(&i2c_mtx[0]);
|
mutex_init(&i2c_mtx[0]);
|
||||||
mutex_init(&i2c_mtx[1]);
|
mutex_init(&i2c_mtx[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data)
|
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data)
|
||||||
{
|
{
|
||||||
mutex_lock(&i2c_mtx[bus]);
|
mutex_lock(&i2c_mtx[bus]);
|
||||||
i2c_on(bus);
|
i2c_on(bus);
|
||||||
long timeout = current_tick + HZ / 50;
|
long timeout = current_tick + HZ / 50;
|
||||||
|
|
||||||
/* START */
|
/* START */
|
||||||
IICDS(bus) = slave & ~1;
|
IICDS(bus) = slave & ~1;
|
||||||
IICSTAT(bus) = 0xF0;
|
IICSTAT(bus) = 0xF0;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (address >= 0) {
|
if (address >= 0) {
|
||||||
/* write address */
|
/* write address */
|
||||||
IICDS(bus) = address;
|
IICDS(bus) = address;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write data */
|
/* write data */
|
||||||
while (len--) {
|
while (len--) {
|
||||||
IICDS(bus) = *data++;
|
IICDS(bus) = *data++;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* STOP */
|
/* STOP */
|
||||||
IICSTAT(bus) = 0xD0;
|
IICSTAT(bus) = 0xD0;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_off(bus);
|
i2c_off(bus);
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data)
|
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data)
|
||||||
{
|
{
|
||||||
mutex_lock(&i2c_mtx[bus]);
|
mutex_lock(&i2c_mtx[bus]);
|
||||||
i2c_on(bus);
|
i2c_on(bus);
|
||||||
long timeout = current_tick + HZ / 50;
|
long timeout = current_tick + HZ / 50;
|
||||||
|
|
||||||
if (address >= 0) {
|
if (address >= 0) {
|
||||||
/* START */
|
/* START */
|
||||||
IICDS(bus) = slave & ~1;
|
IICDS(bus) = slave & ~1;
|
||||||
IICSTAT(bus) = 0xF0;
|
IICSTAT(bus) = 0xF0;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write address */
|
/* write address */
|
||||||
IICDS(bus) = address;
|
IICDS(bus) = address;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (repeated) START */
|
/* (repeated) START */
|
||||||
IICDS(bus) = slave | 1;
|
IICDS(bus) = slave | 1;
|
||||||
IICSTAT(bus) = 0xB0;
|
IICSTAT(bus) = 0xB0;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
IICCON(bus) = (len == 0) ? 0x33 : 0xB3; /* NAK or ACK */
|
IICCON(bus) = (len == 0) ? 0x33 : 0xB3; /* NAK or ACK */
|
||||||
while ((IICCON(bus) & 0x10) == 0)
|
while ((IICCON(bus) & 0x10) == 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
*data++ = IICDS(bus);
|
*data++ = IICDS(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* STOP */
|
/* STOP */
|
||||||
IICSTAT(bus) = 0x90;
|
IICSTAT(bus) = 0x90;
|
||||||
IICCON(bus) = 0xB3;
|
IICCON(bus) = 0xB3;
|
||||||
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
while ((IICSTAT(bus) & (1 << 5)) != 0)
|
||||||
if (TIME_AFTER(current_tick, timeout))
|
if (TIME_AFTER(current_tick, timeout))
|
||||||
{
|
{
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_off(bus);
|
i2c_off(bus);
|
||||||
mutex_unlock(&i2c_mtx[bus]);
|
mutex_unlock(&i2c_mtx[bus]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: kernel-s5l8700.c 28795 2010-12-11 17:52:52Z Buschel $
|
* $Id: kernel-s5l8700.c 28795 2010-12-11 17:52:52Z Buschel $
|
||||||
*
|
*
|
||||||
* Copyright © 2009 Bertrik Sikken
|
* Copyright © 2009 Bertrik Sikken
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
/* S5L8702 driver for the kernel timer
|
/* S5L8702 driver for the kernel timer
|
||||||
|
|
||||||
Timer B is configured as a 10 kHz timer
|
Timer B is configured as a 10 kHz timer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void INT_TIMERB(void)
|
void INT_TIMERB(void)
|
||||||
{
|
{
|
||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
TBCON = TBCON;
|
TBCON = TBCON;
|
||||||
|
|
||||||
call_tick_tasks(); /* Run through the list of tick tasks */
|
call_tick_tasks(); /* Run through the list of tick tasks */
|
||||||
}
|
}
|
||||||
|
|
||||||
void tick_start(unsigned int interval_in_ms)
|
void tick_start(unsigned int interval_in_ms)
|
||||||
{
|
{
|
||||||
int cycles = 10 * interval_in_ms;
|
int cycles = 10 * interval_in_ms;
|
||||||
|
|
||||||
/* configure timer for 10 kHz */
|
/* configure timer for 10 kHz */
|
||||||
TBCMD = (1 << 1); /* TB_CLR */
|
TBCMD = (1 << 1); /* TB_CLR */
|
||||||
TBPRE = 337 - 1; /* prescaler */
|
TBPRE = 337 - 1; /* prescaler */
|
||||||
TBCON = (0 << 13) | /* TB_INT1_EN */
|
TBCON = (0 << 13) | /* TB_INT1_EN */
|
||||||
(1 << 12) | /* TB_INT0_EN */
|
(1 << 12) | /* TB_INT0_EN */
|
||||||
(0 << 11) | /* TB_START */
|
(0 << 11) | /* TB_START */
|
||||||
(2 << 8) | /* TB_CS = PCLK / 16 */
|
(2 << 8) | /* TB_CS = PCLK / 16 */
|
||||||
(0 << 4); /* TB_MODE_SEL = interval mode */
|
(0 << 4); /* TB_MODE_SEL = interval mode */
|
||||||
TBDATA0 = cycles; /* set interval period */
|
TBDATA0 = cycles; /* set interval period */
|
||||||
TBCMD = (1 << 0); /* TB_EN */
|
TBCMD = (1 << 0); /* TB_EN */
|
||||||
|
|
||||||
/* enable timer interrupt */
|
/* enable timer interrupt */
|
||||||
VIC0INTENABLE = 1 << IRQ_TIMER;
|
VIC0INTENABLE = 1 << IRQ_TIMER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,228 +1,228 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: pcm-s5l8700.c 28600 2010-11-14 19:49:20Z Buschel $
|
* $Id: pcm-s5l8700.c 28600 2010-11-14 19:49:20Z Buschel $
|
||||||
*
|
*
|
||||||
* Copyright © 2011 Michael Sparmann
|
* Copyright © 2011 Michael Sparmann
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "s5l8702.h"
|
#include "s5l8702.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "audiohw.h"
|
#include "audiohw.h"
|
||||||
#include "pcm.h"
|
#include "pcm.h"
|
||||||
#include "pcm-internal.h"
|
#include "pcm-internal.h"
|
||||||
#include "pcm_sampr.h"
|
#include "pcm_sampr.h"
|
||||||
#include "mmu-arm.h"
|
#include "mmu-arm.h"
|
||||||
#include "pcm-target.h"
|
#include "pcm-target.h"
|
||||||
|
|
||||||
static volatile int locked = 0;
|
static volatile int locked = 0;
|
||||||
static const int zerosample = 0;
|
static const int zerosample = 0;
|
||||||
static unsigned char dblbuf[2][PCM_WATERMARK * 4];
|
static unsigned char dblbuf[2][PCM_WATERMARK * 4];
|
||||||
static int active_dblbuf;
|
static int active_dblbuf;
|
||||||
struct dma_lli pcm_lli[PCM_LLICOUNT] __attribute__((aligned(16)));
|
struct dma_lli pcm_lli[PCM_LLICOUNT] __attribute__((aligned(16)));
|
||||||
static struct dma_lli* lastlli;
|
static struct dma_lli* lastlli;
|
||||||
static const unsigned char* dataptr;
|
static const unsigned char* dataptr;
|
||||||
size_t pcm_remaining;
|
size_t pcm_remaining;
|
||||||
size_t pcm_chunksize;
|
size_t pcm_chunksize;
|
||||||
|
|
||||||
/* Mask the DMA interrupt */
|
/* Mask the DMA interrupt */
|
||||||
void pcm_play_lock(void)
|
void pcm_play_lock(void)
|
||||||
{
|
{
|
||||||
if (locked++ == 0) {
|
if (locked++ == 0) {
|
||||||
//TODO: Urgh, I don't like that at all...
|
//TODO: Urgh, I don't like that at all...
|
||||||
VIC0INTENCLEAR = 1 << IRQ_DMAC0;
|
VIC0INTENCLEAR = 1 << IRQ_DMAC0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unmask the DMA interrupt if enabled */
|
/* Unmask the DMA interrupt if enabled */
|
||||||
void pcm_play_unlock(void)
|
void pcm_play_unlock(void)
|
||||||
{
|
{
|
||||||
if (--locked == 0) {
|
if (--locked == 0) {
|
||||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void INT_DMAC0C0(void) ICODE_ATTR;
|
void INT_DMAC0C0(void) ICODE_ATTR;
|
||||||
void INT_DMAC0C0(void)
|
void INT_DMAC0C0(void)
|
||||||
{
|
{
|
||||||
DMAC0INTTCCLR = 1;
|
DMAC0INTTCCLR = 1;
|
||||||
if (!pcm_remaining)
|
if (!pcm_remaining)
|
||||||
{
|
{
|
||||||
pcm_play_get_more_callback((void**)&dataptr, &pcm_remaining);
|
pcm_play_get_more_callback((void**)&dataptr, &pcm_remaining);
|
||||||
pcm_chunksize = pcm_remaining;
|
pcm_chunksize = pcm_remaining;
|
||||||
}
|
}
|
||||||
if (!pcm_remaining)
|
if (!pcm_remaining)
|
||||||
{
|
{
|
||||||
pcm_lli->nextlli = NULL;
|
pcm_lli->nextlli = NULL;
|
||||||
pcm_lli->control = 0x75249000;
|
pcm_lli->control = 0x75249000;
|
||||||
clean_dcache();
|
clean_dcache();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t lastsize = MIN(PCM_WATERMARK * 4, pcm_remaining / 2 + 1) & ~1;
|
uint32_t lastsize = MIN(PCM_WATERMARK * 4, pcm_remaining / 2 + 1) & ~1;
|
||||||
pcm_remaining -= lastsize;
|
pcm_remaining -= lastsize;
|
||||||
if (pcm_remaining) lastlli = &pcm_lli[ARRAYLEN(pcm_lli) - 1];
|
if (pcm_remaining) lastlli = &pcm_lli[ARRAYLEN(pcm_lli) - 1];
|
||||||
else lastlli = pcm_lli;
|
else lastlli = pcm_lli;
|
||||||
uint32_t chunksize = MIN(PCM_CHUNKSIZE * 4 - lastsize, pcm_remaining);
|
uint32_t chunksize = MIN(PCM_CHUNKSIZE * 4 - lastsize, pcm_remaining);
|
||||||
if (pcm_remaining > chunksize && chunksize > pcm_remaining - PCM_WATERMARK * 8)
|
if (pcm_remaining > chunksize && chunksize > pcm_remaining - PCM_WATERMARK * 8)
|
||||||
chunksize = pcm_remaining - PCM_WATERMARK * 8;
|
chunksize = pcm_remaining - PCM_WATERMARK * 8;
|
||||||
pcm_remaining -= chunksize;
|
pcm_remaining -= chunksize;
|
||||||
bool last = !chunksize;
|
bool last = !chunksize;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (chunksize)
|
while (chunksize)
|
||||||
{
|
{
|
||||||
uint32_t thislli = MIN(PCM_LLIMAX * 4, chunksize);
|
uint32_t thislli = MIN(PCM_LLIMAX * 4, chunksize);
|
||||||
chunksize -= thislli;
|
chunksize -= thislli;
|
||||||
pcm_lli[i].srcaddr = (void*)dataptr;
|
pcm_lli[i].srcaddr = (void*)dataptr;
|
||||||
pcm_lli[i].dstaddr = (void*)((int)&I2STXDB0);
|
pcm_lli[i].dstaddr = (void*)((int)&I2STXDB0);
|
||||||
pcm_lli[i].nextlli = chunksize ? &pcm_lli[i + 1] : lastlli;
|
pcm_lli[i].nextlli = chunksize ? &pcm_lli[i + 1] : lastlli;
|
||||||
pcm_lli[i].control = (chunksize ? 0x75249000 : 0xf5249000) | (thislli / 2);
|
pcm_lli[i].control = (chunksize ? 0x75249000 : 0xf5249000) | (thislli / 2);
|
||||||
dataptr += thislli;
|
dataptr += thislli;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (!pcm_remaining)
|
if (!pcm_remaining)
|
||||||
{
|
{
|
||||||
memcpy(dblbuf[active_dblbuf], dataptr, lastsize);
|
memcpy(dblbuf[active_dblbuf], dataptr, lastsize);
|
||||||
lastlli->srcaddr = dblbuf[active_dblbuf];
|
lastlli->srcaddr = dblbuf[active_dblbuf];
|
||||||
active_dblbuf ^= 1;
|
active_dblbuf ^= 1;
|
||||||
}
|
}
|
||||||
else lastlli->srcaddr = dataptr;
|
else lastlli->srcaddr = dataptr;
|
||||||
lastlli->dstaddr = (void*)((int)&I2STXDB0);
|
lastlli->dstaddr = (void*)((int)&I2STXDB0);
|
||||||
lastlli->nextlli = last ? NULL : pcm_lli;
|
lastlli->nextlli = last ? NULL : pcm_lli;
|
||||||
lastlli->control = (last ? 0xf5249000 : 0x75249000) | (lastsize / 2);
|
lastlli->control = (last ? 0xf5249000 : 0x75249000) | (lastsize / 2);
|
||||||
dataptr += lastsize;
|
dataptr += lastsize;
|
||||||
clean_dcache();
|
clean_dcache();
|
||||||
if (!(DMAC0C0CONFIG & 1) && (pcm_lli[0].control & 0xfff))
|
if (!(DMAC0C0CONFIG & 1) && (pcm_lli[0].control & 0xfff))
|
||||||
{
|
{
|
||||||
DMAC0C0LLI = pcm_lli[0];
|
DMAC0C0LLI = pcm_lli[0];
|
||||||
DMAC0C0CONFIG = 0x8a81;
|
DMAC0C0CONFIG = 0x8a81;
|
||||||
}
|
}
|
||||||
else DMAC0C0NEXTLLI = pcm_lli;
|
else DMAC0C0NEXTLLI = pcm_lli;
|
||||||
|
|
||||||
pcm_play_dma_started_callback();
|
pcm_play_dma_started_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_play_dma_start(const void* addr, size_t size)
|
void pcm_play_dma_start(const void* addr, size_t size)
|
||||||
{
|
{
|
||||||
dataptr = (const unsigned char*)addr;
|
dataptr = (const unsigned char*)addr;
|
||||||
pcm_remaining = size;
|
pcm_remaining = size;
|
||||||
I2STXCOM = 0xe;
|
I2STXCOM = 0xe;
|
||||||
DMAC0CONFIG |= 4;
|
DMAC0CONFIG |= 4;
|
||||||
INT_DMAC0C0();
|
INT_DMAC0C0();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_play_dma_stop(void)
|
void pcm_play_dma_stop(void)
|
||||||
{
|
{
|
||||||
DMAC0C0CONFIG = 0x8a80;
|
DMAC0C0CONFIG = 0x8a80;
|
||||||
I2STXCOM = 0xa;
|
I2STXCOM = 0xa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pause playback by disabling LRCK */
|
/* pause playback by disabling LRCK */
|
||||||
void pcm_play_dma_pause(bool pause)
|
void pcm_play_dma_pause(bool pause)
|
||||||
{
|
{
|
||||||
if (pause) I2STXCOM |= 1;
|
if (pause) I2STXCOM |= 1;
|
||||||
else I2STXCOM &= ~1;
|
else I2STXCOM &= ~1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_play_dma_init(void)
|
void pcm_play_dma_init(void)
|
||||||
{
|
{
|
||||||
PWRCON(0) &= ~(1 << 4);
|
PWRCON(0) &= ~(1 << 4);
|
||||||
PWRCON(1) &= ~(1 << 7);
|
PWRCON(1) &= ~(1 << 7);
|
||||||
I2S40 = 0x110;
|
I2S40 = 0x110;
|
||||||
I2STXCON = 0xb100059;
|
I2STXCON = 0xb100059;
|
||||||
I2SCLKCON = 1;
|
I2SCLKCON = 1;
|
||||||
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
VIC0INTENABLE = 1 << IRQ_DMAC0;
|
||||||
|
|
||||||
audiohw_preinit();
|
audiohw_preinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_play_dma_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_dma_apply_settings(void)
|
void pcm_dma_apply_settings(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pcm_get_bytes_waiting(void)
|
size_t pcm_get_bytes_waiting(void)
|
||||||
{
|
{
|
||||||
int bytes = pcm_remaining;
|
int bytes = pcm_remaining;
|
||||||
const struct dma_lli* lli = (const struct dma_lli*)((int)&DMAC0C0LLI);
|
const struct dma_lli* lli = (const struct dma_lli*)((int)&DMAC0C0LLI);
|
||||||
while (lli)
|
while (lli)
|
||||||
{
|
{
|
||||||
bytes += (lli->control & 0xfff) * 2;
|
bytes += (lli->control & 0xfff) * 2;
|
||||||
if (lli == lastlli) break;
|
if (lli == lastlli) break;
|
||||||
lli = lli->nextlli;
|
lli = lli->nextlli;
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* pcm_play_dma_get_peak_buffer(int *count)
|
const void* pcm_play_dma_get_peak_buffer(int *count)
|
||||||
{
|
{
|
||||||
*count = (DMAC0C0LLI.control & 0xfff) * 2;
|
*count = (DMAC0C0LLI.control & 0xfff) * 2;
|
||||||
return (void*)(((uint32_t)DMAC0C0LLI.srcaddr) & ~3);
|
return (void*)(((uint32_t)DMAC0C0LLI.srcaddr) & ~3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PCM_DMA_ADDRESS
|
#ifdef HAVE_PCM_DMA_ADDRESS
|
||||||
void * pcm_dma_addr(void *addr)
|
void * pcm_dma_addr(void *addr)
|
||||||
{
|
{
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Recording DMA transfer
|
** Recording DMA transfer
|
||||||
**/
|
**/
|
||||||
#ifdef HAVE_RECORDING
|
#ifdef HAVE_RECORDING
|
||||||
void pcm_rec_lock(void)
|
void pcm_rec_lock(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_rec_unlock(void)
|
void pcm_rec_unlock(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_rec_dma_stop(void)
|
void pcm_rec_dma_stop(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_rec_dma_start(void *addr, size_t size)
|
void pcm_rec_dma_start(void *addr, size_t size)
|
||||||
{
|
{
|
||||||
(void)addr;
|
(void)addr;
|
||||||
(void)size;
|
(void)size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_rec_dma_close(void)
|
void pcm_rec_dma_close(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pcm_rec_dma_init(void)
|
void pcm_rec_dma_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const void * pcm_rec_dma_get_peak_buffer(void)
|
const void * pcm_rec_dma_get_peak_buffer(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_RECORDING */
|
#endif /* HAVE_RECORDING */
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 by Michael Sparmann
|
* Copyright (C) 2010 by Michael Sparmann
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef __PCM_TARGET_H__
|
#ifndef __PCM_TARGET_H__
|
||||||
#define __PCM_TARGET_H__
|
#define __PCM_TARGET_H__
|
||||||
|
|
||||||
|
|
||||||
/* S5L8702 PCM driver tunables: */
|
/* S5L8702 PCM driver tunables: */
|
||||||
#define PCM_LLIMAX (2047) /* Maximum number of samples per LLI */
|
#define PCM_LLIMAX (2047) /* Maximum number of samples per LLI */
|
||||||
#define PCM_CHUNKSIZE (10747) /* Maximum number of samples to handle with one IRQ */
|
#define PCM_CHUNKSIZE (10747) /* Maximum number of samples to handle with one IRQ */
|
||||||
/* (bigger chunks will be segmented internally) */
|
/* (bigger chunks will be segmented internally) */
|
||||||
#define PCM_WATERMARK (512) /* Number of remaining samples to schedule IRQ at */
|
#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)
|
#define PCM_LLICOUNT ((PCM_CHUNKSIZE - PCM_WATERMARK + PCM_LLIMAX - 1) / PCM_LLIMAX + 1)
|
||||||
|
|
||||||
|
|
||||||
extern struct dma_lli pcm_lli[PCM_LLICOUNT];
|
extern struct dma_lli pcm_lli[PCM_LLICOUNT];
|
||||||
extern size_t pcm_remaining;
|
extern size_t pcm_remaining;
|
||||||
extern size_t pcm_chunksize;
|
extern size_t pcm_chunksize;
|
||||||
|
|
||||||
|
|
||||||
#endif /* __PCM_TARGET_H__ */
|
#endif /* __PCM_TARGET_H__ */
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
* $Id: system-target.h 28791 2010-12-11 09:39:33Z Buschel $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 by Dave Chapman
|
* Copyright (C) 2007 by Dave Chapman
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef SYSTEM_TARGET_H
|
#ifndef SYSTEM_TARGET_H
|
||||||
#define SYSTEM_TARGET_H
|
#define SYSTEM_TARGET_H
|
||||||
|
|
||||||
#include "system-arm.h"
|
#include "system-arm.h"
|
||||||
#include "mmu-arm.h"
|
#include "mmu-arm.h"
|
||||||
|
|
||||||
#define CPUFREQ_SLEEP 32768
|
#define CPUFREQ_SLEEP 32768
|
||||||
#define CPUFREQ_MAX 216000000
|
#define CPUFREQ_MAX 216000000
|
||||||
#define CPUFREQ_DEFAULT 108000000
|
#define CPUFREQ_DEFAULT 108000000
|
||||||
#define CPUFREQ_NORMAL 108000000
|
#define CPUFREQ_NORMAL 108000000
|
||||||
|
|
||||||
#define STORAGE_WANTS_ALIGN
|
#define STORAGE_WANTS_ALIGN
|
||||||
|
|
||||||
#define inl(a) (*(volatile unsigned long *) (a))
|
#define inl(a) (*(volatile unsigned long *) (a))
|
||||||
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
|
||||||
#define inb(a) (*(volatile unsigned char *) (a))
|
#define inb(a) (*(volatile unsigned char *) (a))
|
||||||
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
|
||||||
#define inw(a) (*(volatile unsigned short*) (a))
|
#define inw(a) (*(volatile unsigned short*) (a))
|
||||||
#define outw(a,b) (*(volatile unsigned short*) (b) = (a))
|
#define outw(a,b) (*(volatile unsigned short*) (b) = (a))
|
||||||
|
|
||||||
static inline void udelay(unsigned usecs)
|
static inline void udelay(unsigned usecs)
|
||||||
{
|
{
|
||||||
unsigned stop = USEC_TIMER + usecs;
|
unsigned stop = USEC_TIMER + usecs;
|
||||||
while (TIME_BEFORE(USEC_TIMER, stop));
|
while (TIME_BEFORE(USEC_TIMER, stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SYSTEM_TARGET_H */
|
#endif /* SYSTEM_TARGET_H */
|
||||||
|
|
|
@ -1,94 +1,94 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* __________ __ ___.
|
* __________ __ ___.
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: timer-s5l8700.c 23103 2009-10-11 11:35:14Z theseven $
|
* $Id: timer-s5l8700.c 23103 2009-10-11 11:35:14Z theseven $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Bertrik Sikken
|
* Copyright (C) 2009 Bertrik Sikken
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
#include "s5l8702.h"
|
#include "s5l8702.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
//TODO: This needs calibration once we figure out the clocking
|
//TODO: This needs calibration once we figure out the clocking
|
||||||
|
|
||||||
void INT_TIMERC(void)
|
void INT_TIMERC(void)
|
||||||
{
|
{
|
||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
TCCON = TCCON;
|
TCCON = TCCON;
|
||||||
|
|
||||||
if (pfn_timer != NULL) {
|
if (pfn_timer != NULL) {
|
||||||
pfn_timer();
|
pfn_timer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool timer_set(long cycles, bool start)
|
bool timer_set(long cycles, bool start)
|
||||||
{
|
{
|
||||||
static const int cs_table[] = {1, 2, 4, 6};
|
static const int cs_table[] = {1, 2, 4, 6};
|
||||||
int prescale, cs;
|
int prescale, cs;
|
||||||
long count;
|
long count;
|
||||||
|
|
||||||
/* stop and clear timer */
|
/* stop and clear timer */
|
||||||
TCCMD = (1 << 1); /* TD_CLR */
|
TCCMD = (1 << 1); /* TD_CLR */
|
||||||
|
|
||||||
/* optionally unregister any previously registered timer user */
|
/* optionally unregister any previously registered timer user */
|
||||||
if (start) {
|
if (start) {
|
||||||
if (pfn_unregister != NULL) {
|
if (pfn_unregister != NULL) {
|
||||||
pfn_unregister();
|
pfn_unregister();
|
||||||
pfn_unregister = NULL;
|
pfn_unregister = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale the count down with the clock select */
|
/* scale the count down with the clock select */
|
||||||
for (cs = 0; cs < 4; cs++) {
|
for (cs = 0; cs < 4; cs++) {
|
||||||
count = cycles >> cs_table[cs];
|
count = cycles >> cs_table[cs];
|
||||||
if ((count < 65536) || (cs == 3)) {
|
if ((count < 65536) || (cs == 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale the count down with the prescaler */
|
/* scale the count down with the prescaler */
|
||||||
prescale = 1;
|
prescale = 1;
|
||||||
while (count >= 65536) {
|
while (count >= 65536) {
|
||||||
count >>= 1;
|
count >>= 1;
|
||||||
prescale <<= 1;
|
prescale <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* configure timer */
|
/* configure timer */
|
||||||
TCCON = (1 << 12) | /* TD_INT0_EN */
|
TCCON = (1 << 12) | /* TD_INT0_EN */
|
||||||
(cs << 8) | /* TS_CS */
|
(cs << 8) | /* TS_CS */
|
||||||
(0 << 4); /* TD_MODE_SEL, 0 = interval mode */
|
(0 << 4); /* TD_MODE_SEL, 0 = interval mode */
|
||||||
TCPRE = prescale - 1;
|
TCPRE = prescale - 1;
|
||||||
TCDATA0 = count;
|
TCDATA0 = count;
|
||||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool timer_start(void)
|
bool timer_start(void)
|
||||||
{
|
{
|
||||||
TCCMD = (1 << 0); /* TD_ENABLE */
|
TCCMD = (1 << 0); /* TD_ENABLE */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_stop(void)
|
void timer_stop(void)
|
||||||
{
|
{
|
||||||
TCCMD = (0 << 0); /* TD_ENABLE */
|
TCCMD = (0 << 0); /* TD_ENABLE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: mas.c 18807 2008-10-14 11:12:20Z zagor $
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
* 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'?>
|
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
|
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
tcctool for Windows
|
tcctool for Windows
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
When you first attach your device in USB boot mode to your computer,
|
When you first attach your device in USB boot mode to your computer,
|
||||||
Windows should display the Found New Hardware Wizard.
|
Windows should display the Found New Hardware Wizard.
|
||||||
|
|
||||||
If this doesn't appear, and if you have previously used a firmware
|
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
|
recovery tool with your device, you will need to uninstall the USB
|
||||||
driver used by that application.
|
driver used by that application.
|
||||||
|
|
||||||
Go into Control Panel -> System -> Hardware -> Device Manager, then
|
Go into Control Panel -> System -> Hardware -> Device Manager, then
|
||||||
click on Universal Serial Bus Controllers, look for something like
|
click on Universal Serial Bus Controllers, look for something like
|
||||||
"Telechips TCC77x VTC USB Driver", right-click on it and select
|
"Telechips TCC77x VTC USB Driver", right-click on it and select
|
||||||
Uninstall.
|
Uninstall.
|
||||||
|
|
||||||
After doing this, disconnect and reconnect your device and the Found
|
After doing this, disconnect and reconnect your device and the Found
|
||||||
New Hardware Wizard should appear.
|
New Hardware Wizard should appear.
|
||||||
|
|
||||||
Select "No, not this time" to the question about connecting to Windows
|
Select "No, not this time" to the question about connecting to Windows
|
||||||
Update, and select "Install from a list or specific location
|
Update, and select "Install from a list or specific location
|
||||||
(Advanced)" on the next screen.
|
(Advanced)" on the next screen.
|
||||||
|
|
||||||
On the next screen, select "Search for the best driver in these
|
On the next screen, select "Search for the best driver in these
|
||||||
locations", unselect "Search removable media", select "Include this
|
locations", unselect "Search removable media", select "Include this
|
||||||
location in the search:" and browse to the tcctool-driver-win32
|
location in the search:" and browse to the tcctool-driver-win32
|
||||||
folder.
|
folder.
|
||||||
|
|
||||||
You should now be able to run tcctool.exe
|
You should now be able to run tcctool.exe
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
|
* Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
|
||||||
* See COPYING file that comes with this distribution
|
* See COPYING file that comes with this distribution
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FINDREPLACE_GLOBAL_H
|
#ifndef FINDREPLACE_GLOBAL_H
|
||||||
#define FINDREPLACE_GLOBAL_H
|
#define FINDREPLACE_GLOBAL_H
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
#ifndef FINDREPLACE_NOLIB
|
#ifndef FINDREPLACE_NOLIB
|
||||||
#if defined(FINDREPLACE_LIBRARY)
|
#if defined(FINDREPLACE_LIBRARY)
|
||||||
# define FINDREPLACESHARED_EXPORT Q_DECL_EXPORT
|
# define FINDREPLACESHARED_EXPORT Q_DECL_EXPORT
|
||||||
#else
|
#else
|
||||||
# define FINDREPLACESHARED_EXPORT Q_DECL_IMPORT
|
# define FINDREPLACESHARED_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define FINDREPLACESHARED_EXPORT
|
#define FINDREPLACESHARED_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // FINDREPLACE_GLOBAL_H
|
#endif // FINDREPLACE_GLOBAL_H
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>FindReplaceDialog</class>
|
<class>FindReplaceDialog</class>
|
||||||
<widget class="QDialog" name="FindReplaceDialog">
|
<widget class="QDialog" name="FindReplaceDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>342</width>
|
<width>342</width>
|
||||||
<height>140</height>
|
<height>140</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Find/Replace</string>
|
<string>Find/Replace</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
|
<widget class="FindReplaceForm" name="findReplaceForm" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>FindReplaceForm</class>
|
<class>FindReplaceForm</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header location="global">findreplaceform.h</header>
|
<header location="global">findreplaceform.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -1,204 +1,204 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>FindReplaceForm</class>
|
<class>FindReplaceForm</class>
|
||||||
<widget class="QWidget" name="FindReplaceForm">
|
<widget class="QWidget" name="FindReplaceForm">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>483</width>
|
<width>483</width>
|
||||||
<height>288</height>
|
<height>288</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Find:</string>
|
<string>&Find:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>textToFind</cstring>
|
<cstring>textToFind</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="textToFind"/>
|
<widget class="QLineEdit" name="textToFind"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="replaceLabel">
|
<widget class="QLabel" name="replaceLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>R&eplace with:</string>
|
<string>R&eplace with:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>textToReplace</cstring>
|
<cstring>textToReplace</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="textToReplace"/>
|
<widget class="QLineEdit" name="textToReplace"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="errorLabel">
|
<widget class="QLabel" name="errorLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>errorLabel</string>
|
<string>errorLabel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>D&irection</string>
|
<string>D&irection</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="downRadioButton">
|
<widget class="QRadioButton" name="downRadioButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Down</string>
|
<string>&Down</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="upRadioButton">
|
<widget class="QRadioButton" name="upRadioButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Up</string>
|
<string>&Up</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Options</string>
|
<string>&Options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="caseCheckBox">
|
<widget class="QCheckBox" name="caseCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Case sensitive</string>
|
<string>&Case sensitive</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="wholeCheckBox">
|
<widget class="QCheckBox" name="wholeCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Whole words only</string>
|
<string>&Whole words only</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="regexCheckBox">
|
<widget class="QCheckBox" name="regexCheckBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<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">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
</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=" 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="-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;">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>
|
<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>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>R&egular Expression</string>
|
<string>R&egular Expression</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="findButton">
|
<widget class="QPushButton" name="findButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Find</string>
|
<string>&Find</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Close</string>
|
<string>&Close</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="replaceButton">
|
<widget class="QPushButton" name="replaceButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Replace</string>
|
<string>&Replace</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="replaceAllButton">
|
<widget class="QPushButton" name="replaceAllButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Replace &All</string>
|
<string>Replace &All</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>textToFind</tabstop>
|
<tabstop>textToFind</tabstop>
|
||||||
<tabstop>textToReplace</tabstop>
|
<tabstop>textToReplace</tabstop>
|
||||||
<tabstop>downRadioButton</tabstop>
|
<tabstop>downRadioButton</tabstop>
|
||||||
<tabstop>upRadioButton</tabstop>
|
<tabstop>upRadioButton</tabstop>
|
||||||
<tabstop>caseCheckBox</tabstop>
|
<tabstop>caseCheckBox</tabstop>
|
||||||
<tabstop>wholeCheckBox</tabstop>
|
<tabstop>wholeCheckBox</tabstop>
|
||||||
<tabstop>regexCheckBox</tabstop>
|
<tabstop>regexCheckBox</tabstop>
|
||||||
<tabstop>findButton</tabstop>
|
<tabstop>findButton</tabstop>
|
||||||
<tabstop>closeButton</tabstop>
|
<tabstop>closeButton</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
EDITOR_ICON ICON DISCARDABLE "resources/windowicon.ico"
|
EDITOR_ICON ICON DISCARDABLE "resources/windowicon.ico"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue