Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[87e73d]: src / libxineadec / nosefart / nsf.h Maximize Restore History

Download this file

nsf.h    185 lines (157 with data), 5.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com)
**
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of version 2 of the GNU Library General
** Public License as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details. To obtain a
** copy of the GNU Library General Public License, write to the Free
** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** Any permitted reproduction of these routines, in whole or in part,
** must bear this legend.
**
**
** nsf.h
**
** NSF loading/saving related defines / prototypes
** $Id: nsf.h,v 1.3 2007/01/18 21:34:10 dgp85 Exp $
*/
#ifndef _NSF_H_
#define _NSF_H_
#include "osd.h"
#include "nes6502.h"
#include "nes_apu.h"
#define NSF_MAGIC "NESM\x1A"
#define NSF_DEDICATED_PAL 0x01
#define NSF_DUAL_PAL_NTSC 0x02
#define EXT_SOUND_NONE 0x00
#define EXT_SOUND_VRCVI 0x01
#define EXT_SOUND_VRCVII 0x02
#define EXT_SOUND_FDS 0x04
#define EXT_SOUND_MMC5 0x08
#define EXT_SOUND_NAMCO106 0x10
#define EXT_SOUND_SUNSOFT_FME07 0x20
/* bits 6,7: future expansion */
#define NSF_HEADER_SIZE 0x80
/* 60 Hertz refresh (NTSC) */
#define NES_MASTER_CLOCK 21477272.7272
#define NTSC_REFRESH 60
#define NTSC_SUBCARRIER_DIV 12
#define NTSC_SCANLINES 262
#define NES_FRAME_CYCLES ((NES_MASTER_CLOCK / NTSC_SUBCARRIER_DIV) / NTSC_REFRESH)
#define NES_SCANLINE_CYCLES (NES_FRAME_CYCLES / NTSC_SCANLINES)
/* filter levels */
enum
{
NSF_FILTER_NONE,
NSF_FILTER_LOWPASS,
NSF_FILTER_WEIGHTED,
NSF_FILTER_MAX, /* $$$ ben : add this one for range chacking */
};
typedef struct nsf_s
{
/* NESM header */
uint8 id[5]; /* NESM\x1A */
uint8 version; /* spec version */
uint8 num_songs; /* total num songs */
uint8 start_song; /* first song */
uint16 load_addr; /* loc to load code */
uint16 init_addr; /* init call address */
uint16 play_addr; /* play call address */
uint8 song_name[32]; /* name of song */
uint8 artist_name[32]; /* artist name */
uint8 copyright[32]; /* copyright info */
uint16 ntsc_speed; /* playback speed (if NTSC) */
uint8 bankswitch_info[8]; /* initial code banking */
uint16 pal_speed; /* playback speed (if PAL) */
uint8 pal_ntsc_bits; /* NTSC/PAL determination bits */
uint8 ext_sound_type; /* type of external sound gen. */
uint8 reserved[4]; /* reserved */
/* things that the NSF player needs */
uint8 *data; /* actual NSF data */
uint32 length; /* length of data */
uint32 playback_rate; /* current playback rate */
uint8 current_song; /* current song */
boolean bankswitched; /* is bankswitched? */
/* $$$ ben : Playing time ... */
uint32 cur_frame;
uint32 cur_frame_end;
uint32 * song_frames;
/* $$$ ben : Last error string */
const char * errstr;
/* CPU and APU contexts */
nes6502_context *cpu;
apu_t *apu;
/* our main processing routine, calls all external mixing routines */
void (*process)(void *buffer, int num_samples);
} __PACKED__ nsf_t;
/* $$$ ben : Generic loader struct */
struct nsf_loader_t {
/* Init and open. */
int (*open)(struct nsf_loader_t * loader);
/* Close and shutdown. */
void (*close) (struct nsf_loader_t * loader);
/* This function should return <0 on error, else the number of byte NOT read.
* that way a simple 0 test tell us if read was complete.
*/
int (*read) (struct nsf_loader_t * loader, void *data, int n);
/* Get file length. */
int (*length) (struct nsf_loader_t * loader);
/* Skip n bytes. */
int (*skip) (struct nsf_loader_t * loader,int n);
/* Get filename (for debug). */
const char * (*fname) (struct nsf_loader_t * loader);
};
/* Function prototypes */
extern int nsf_init(void);
extern nsf_t * nsf_load_extended(struct nsf_loader_t * loader);
extern nsf_t *nsf_load(const char *filename, void *source, int length);
extern void nsf_free(nsf_t **nsf_info);
extern int nsf_playtrack(nsf_t *nsf, int track, int sample_rate,
int sample_bits, boolean stereo);
extern void nsf_frame(nsf_t *nsf);
extern int nsf_setchan(nsf_t *nsf, int chan, boolean enabled);
extern int nsf_setfilter(nsf_t *nsf, int filter_type);
#endif /* _NSF_H_ */
/*
** $Log: nsf.h,v $
** Revision 1.3 2003/05/01 22:34:20 benjihan
** New NSF plugin
**
** Revision 1.2 2003/04/09 14:50:32 ben
** Clean NSF api.
**
** Revision 1.1 2003/04/08 20:53:00 ben
** Adding more files...
**
** Revision 1.11 2000/07/04 04:59:24 matt
** removed DOS-specific stuff
**
** Revision 1.10 2000/07/03 02:19:36 matt
** dynamic address range handlers, cleaner and faster
**
** Revision 1.9 2000/06/23 03:27:58 matt
** cleaned up external sound inteface
**
** Revision 1.8 2000/06/20 04:04:37 matt
** moved external soundchip struct to apu module
**
** Revision 1.7 2000/06/20 00:05:45 matt
** changed to driver-based external sound generation
**
** Revision 1.6 2000/06/13 03:51:54 matt
** update API to take freq/sample data on nsf_playtrack
**
** Revision 1.5 2000/06/12 01:13:00 matt
** added CPU/APU as members of the nsf struct
**
** Revision 1.4 2000/06/09 15:12:26 matt
** initial revision
**
*/