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

« back to all changes in this revision

Viewing changes to fceu/src/boards/3d-block.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) 2007 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
 
 
21
#include "mapinc.h"
 
22
 
 
23
static uint8 reg[4], IRQa;
 
24
static int16 IRQCount, IRQPause;
 
25
 
 
26
static int16 Count = 0x0000;
 
27
 
 
28
static SFORMAT StateRegs[]=
 
29
{
 
30
  {reg, 4, "REGS"},
 
31
  {&IRQa, 1, "IRQA"},
 
32
  {&IRQCount, 2, "IRQC"},
 
33
  {0}
 
34
};
 
35
 
 
36
static void Sync(void)
 
37
{
 
38
  setprg32(0x8000,0);
 
39
  setchr8(0);
 
40
}
 
41
 
 
42
//#define Count 0x1800
 
43
#define Pause 0x010
 
44
 
 
45
static DECLFW(UNL3DBlockWrite)
 
46
{
 
47
  switch(A)
 
48
  {
 
49
//4800 32
 
50
//4900 37
 
51
//4a00 01
 
52
//4e00 18
 
53
    case 0x4800: reg[0]=V; break;
 
54
    case 0x4900: reg[1]=V; break;
 
55
    case 0x4a00: reg[2]=V; break;
 
56
    case 0x4e00: reg[3]=V; IRQCount=Count; IRQPause=Pause; IRQa=1; X6502_IRQEnd(FCEU_IQEXT); break;
 
57
  } 
 
58
}
 
59
 
 
60
static void UNL3DBlockPower(void)
 
61
{
 
62
  Sync();
 
63
  SetReadHandler(0x8000,0xFFFF,CartBR);
 
64
  SetWriteHandler(0x4800,0x4E00,UNL3DBlockWrite);
 
65
}
 
66
 
 
67
static void UNL3DBlockReset(void)
 
68
{
 
69
  Count+=0x10;
 
70
  FCEU_printf("Count=%04x\n",Count);
 
71
}
 
72
 
 
73
static void UNL3DBlockIRQHook(int a)
 
74
{
 
75
  if(IRQa)
 
76
  {
 
77
    if(IRQCount>0)
 
78
    {
 
79
      IRQCount-=a;
 
80
    }
 
81
    else
 
82
    {
 
83
      if(IRQPause>0)
 
84
      {
 
85
        IRQPause-=a;
 
86
        X6502_IRQBegin(FCEU_IQEXT);
 
87
      }
 
88
      else
 
89
      {
 
90
        IRQCount=Count; 
 
91
        IRQPause=Pause;
 
92
        X6502_IRQEnd(FCEU_IQEXT);
 
93
      }
 
94
    }
 
95
  }
 
96
}
 
97
 
 
98
static void StateRestore(int version)
 
99
{
 
100
  Sync();
 
101
}
 
102
 
 
103
void UNL3DBlock_Init(CartInfo *info)
 
104
{
 
105
  info->Power=UNL3DBlockPower;
 
106
  info->Reset=UNL3DBlockReset;
 
107
  MapIRQHook=UNL3DBlockIRQHook;
 
108
  GameStateRestore=StateRestore;
 
109
  AddExState(&StateRegs, ~0, 0, 0);
 
110
}