~ubuntu-branches/ubuntu/lucid/fceux/lucid

« back to all changes in this revision

Viewing changes to fceu/src/boards/199.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-12-14 08:05:17 UTC
  • Revision ID: james.westby@ubuntu.com-20091214080517-abi5tj8avthfan7c
Tags: upstream-2.1.2+repack
ImportĀ upstreamĀ versionĀ 2.1.2+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* FCE Ultra - NES/Famicom Emulator
 
2
 *
 
3
 * Copyright notice for this file:
 
4
 *  Copyright (C) 2006 CaH4e3
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 *
 
20
 * Dragon Ball Z 2 - Gekishin Freeza! (C)
 
21
 * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C)
 
22
 * San Guo Zhi 2 (C)
 
23
 *
 
24
 */
 
25
 
 
26
#include "mapinc.h"
 
27
#include "mmc3.h"
 
28
 
 
29
static uint8 *CHRRAM=NULL; // and here too
 
30
 
 
31
static void M199PW(uint32 A, uint8 V)
 
32
{
 
33
  setprg8(A,V);
 
34
  setprg8(0xC000,EXPREGS[0]);
 
35
  setprg8(0xE000,EXPREGS[1]);
 
36
}
 
37
 
 
38
static void M199CW(uint32 A, uint8 V)
 
39
{
 
40
  setchr1r((V<8)?0x10:0x00,A,V);
 
41
  setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]);
 
42
  setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]);
 
43
  setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]);
 
44
  setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]);
 
45
}
 
46
 
 
47
static void M199MW(uint8 V)
 
48
{
 
49
//    FCEU_printf("%02x\n",V);
 
50
  switch(V&3)
 
51
  {
 
52
    case 0: setmirror(MI_V); break;
 
53
    case 1: setmirror(MI_H); break;
 
54
    case 2: setmirror(MI_0); break;
 
55
    case 3: setmirror(MI_1); break;
 
56
  }
 
57
}
 
58
 
 
59
static DECLFW(M199Write)
 
60
{
 
61
  if((A==0x8001)&&(MMC3_cmd&8))
 
62
  {
 
63
//    FCEU_printf("%02x=>%02x\n",MMC3_cmd,V);
 
64
    EXPREGS[MMC3_cmd&3]=V;
 
65
    FixMMC3PRG(MMC3_cmd);
 
66
    FixMMC3CHR(MMC3_cmd);
 
67
  }
 
68
  else    
 
69
    if(A<0xC000)
 
70
      MMC3_CMDWrite(A,V);
 
71
    else
 
72
      MMC3_IRQWrite(A,V);
 
73
}
 
74
 
 
75
static void M199Power(void)
 
76
{
 
77
  EXPREGS[0]=~1;
 
78
  EXPREGS[1]=~0;
 
79
  EXPREGS[2]=1;
 
80
  EXPREGS[3]=3;
 
81
  GenMMC3Power();
 
82
  SetWriteHandler(0x8000,0xFFFF,M199Write);
 
83
}
 
84
 
 
85
void Mapper199_Init(CartInfo *info)
 
86
{
 
87
  int CHRRAMSize=1024*8;
 
88
  GenMMC3_Init(info, 512, 256, 8, info->battery);
 
89
  cwrap=M199CW;
 
90
  pwrap=M199PW;
 
91
  mwrap=M199MW;
 
92
  info->Power=M199Power;
 
93
  CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize);
 
94
  SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1);
 
95
  AddExState(CHRRAM, CHRRAMSize, 0, "CHRR");
 
96
  AddExState(EXPREGS, 4, 0, "EXPR");
 
97
}