merged ppu code, added input+zapper, FDS/VS insert in menu
[fceu.git] / input / mahjong.c
1 /* FCE Ultra - NES/Famicom Emulator
2  *
3  * Copyright notice for this file:
4  *  Copyright (C) 2003 Xodnizel
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 <string.h>
22 #include "share.h"
23
24 static uint32 MReal,MRet;
25
26 static uint8 FP_FASTAPASS(2) MJ_Read(int w, uint8 ret)
27 {
28  if(w) 
29  {
30 //  ret|=(MRet&1)<<1;
31   ret|=((MRet&0x80)>>6)&2;
32 //  MRet>>=1;
33  if(!fceuindbg)
34   MRet<<=1;
35  }
36  return(ret);
37 }
38
39 static void FP_FASTAPASS(1) MJ_Write(uint8 v)
40 {
41  /* 1: I-D7, J-D6, K-D5, L-D4, M-D3, Big Red-D2
42     2: A-D7, B-D6, C-D5, D-D4, E-D3, F-D2, G-D1, H-D0
43     3: Sel-D6, Start-D7, D5, D4, D3, D2, D1
44  */
45  MRet=0;
46
47  v>>=1;
48  v&=3;
49
50  if(v==3)
51  {
52   MRet=(MReal>>14)&0x7F;
53   //MRet=((MRet&0x1F) |((MRet&0x40)>>1)|((MRet&0x20)<<1)) <<1; //(MReal>>13)&0x7F;
54  }
55  else if(v==2)
56  {
57   MRet=MReal&0xFF;
58  }
59  else if(v==1)
60  {
61   MRet=(MReal>>8)&0x3F;
62  }
63 // HSValR=HSVal<<1;
64 }
65
66 static void FP_FASTAPASS(2) MJ_Update(void *data, int arg)
67 {
68  MReal=*(uint32*)data;
69  //printf("%08x\n",MReal>>13);
70  //HSVal=*(uint8*)data;
71 }
72
73 static INPUTCFC Mahjong={MJ_Read,MJ_Write,0,MJ_Update,0,0};
74
75 INPUTCFC *FCEU_InitMahjong(void)
76 {
77  MReal=MRet=0;
78  return(&Mahjong);
79 }