~ubuntu-branches/ubuntu/utopic/fceux/utopic-proposed

« back to all changes in this revision

Viewing changes to src/nsf.cpp

  • Committer: Package Import Robot
  • Author(s): Joe Nahmias
  • Date: 2014-03-02 19:22:04 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140302192204-9f0aehi5stfnhn7d
Tags: 2.2.2+dfsg0-1
* Imported Upstream version 2.2.2
  + remove patches merged upstream; refresh remaining
  + remove windows compiled help files and non-free Visual C files
* Use C++11 standard static assertion functionality
* fix upstream installation of support files
* New patch 0004-ignore-missing-windows-help-CHM-file.patch
* update d/copyright for new, renamed, deleted files
* d/control: bump std-ver to 3.9.5, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
/// \file
22
22
/// \brief implements a built-in NSF player.  This is a perk--not a part of the emu core
23
23
 
24
 
#include <stdio.h>
25
 
#include <stdlib.h>
26
 
#include <string.h>
27
 
#include <math.h>
28
 
 
29
24
#include "types.h"
30
25
#include "x6502.h"
31
26
#include "fceu.h"
38
33
#include "fds.h"
39
34
#include "cart.h"
40
35
#include "input.h"
 
36
#include "state.h"
41
37
#include "driver.h"
42
38
#ifdef _S9XLUA_H
43
39
#include "fceulua.h"
47
43
#define M_PI 3.14159265358979323846
48
44
#endif
49
45
 
 
46
#include <cstdio>
 
47
#include <cstdlib>
 
48
#include <cstring>
 
49
#include <cmath>
 
50
 
 
51
static const int FIXED_EXWRAM_SIZE = 32768+8192;
 
52
 
50
53
static uint8 SongReload;
51
 
static int CurrentSong;
 
54
static int32 CurrentSong;
52
55
 
53
56
static DECLFW(NSF_write);
54
57
static DECLFR(NSF_read);
55
58
 
56
 
static int vismode=1;
 
59
static int vismode=1; //we cant consider this state, because the UI may be controlling it and wouldnt know we loadstated it
57
60
 
58
61
//mbg 7/31/06 todo - no reason this couldnt be assembled on the fly from actual asm source code. thatd be less obscure.
59
62
//here it is disassembled, for reference
107
110
        return (NSFROM-0x3800)[A];
108
111
}
109
112
 
110
 
static int doreset=0;
111
 
static int NSFNMIFlags;
112
 
uint8 *NSFDATA=0;
113
 
int NSFMaxBank;
114
 
 
115
 
static int NSFSize;
116
 
static uint8 BSon;
117
 
static uint8 BankCounter;
118
 
 
119
 
static uint16 PlayAddr;
120
 
static uint16 InitAddr;
121
 
static uint16 LoadAddr;
 
113
static uint8 doreset=0; //state
 
114
static uint8 NSFNMIFlags; //state
 
115
uint8 *NSFDATA=0; //configration, loaded from rom?
 
116
int NSFMaxBank; //configuration
 
117
 
 
118
static int32 NSFSize; //configuration
 
119
static uint8 BSon; //configuration
 
120
static uint8 BankCounter; //configuration
 
121
 
 
122
static uint16 PlayAddr; //configuration
 
123
static uint16 InitAddr; //configuration
 
124
static uint16 LoadAddr; //configuration
122
125
 
123
126
extern char LoadedRomFName[2048];
124
127
 
275
278
        FCEU_printf(" %s\n",(NSFHeader.VideoSystem&1)?"PAL":"NTSC");
276
279
        FCEU_printf(" Starting song:  %d / %d\n\n",NSFHeader.StartingSong,NSFHeader.TotalSongs);
277
280
 
 
281
        //choose exwram size and allocate
 
282
        int exwram_size = 8192;
278
283
        if(NSFHeader.SoundChip&4)
279
 
                ExWRAM=(uint8*)FCEU_gmalloc(32768+8192); //mbg merge 7/17/06 added cast
280
 
        else
281
 
                ExWRAM=(uint8*)FCEU_gmalloc(8192); //mbg merge 7/17/06 added cast
 
284
                exwram_size = 32768+8192;
 
285
        //lets just always use this size, for savestate simplicity
 
286
        exwram_size = FIXED_EXWRAM_SIZE;
 
287
        ExWRAM=(uint8*)FCEU_gmalloc(exwram_size);
282
288
 
283
289
        FCEUI_SetVidSystem(NSFHeader.VideoSystem);
284
290
 
305
311
void NSFN106_Init(void);
306
312
void NSFAY_Init(void);
307
313
 
 
314
//zero 17-apr-2013 - added
 
315
static SFORMAT StateRegs[] = {
 
316
        {&SongReload, 1, "SREL"},
 
317
        {&CurrentSong, 4 | FCEUSTATE_RLSB, "CURS"},
 
318
        {&doreset, 1, "DORE"},
 
319
        {&NSFNMIFlags, 1, "NMIF"},
 
320
        { 0 }
 
321
};
 
322
 
308
323
void NSF_init(void)
309
324
{
310
325
        doreset=1;
376
391
        CurrentSong=NSFHeader.StartingSong;
377
392
        SongReload=0xFF;
378
393
        NSFNMIFlags=0;
 
394
 
 
395
        //zero 17-apr-2013 - added
 
396
        AddExState(StateRegs, ~0, 0, 0);
 
397
        AddExState(ExWRAM, FIXED_EXWRAM_SIZE, 0, "ERAM");
379
398
}
380
399
 
381
400
static DECLFW(NSF_write)