1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Xodnizel
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.
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.
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
24 #define AK2(x,y) ( (FKB_##x) | (FKB_##y <<8) )
27 static uint8 bufit[0x49];
32 static uint16 matrix[9][2][4]=
34 {{AK(F8),AK(RETURN),AK(BRACKETLEFT),AK(BRACKETRIGHT)},
35 {AK(KANA),AK(RIGHTSHIFT),AK(BACKSLASH),AK(STOP)}},
36 {{AK(F7),AK(AT),AK(COLON),AK(SEMICOLON)},
37 {AK(UNDERSCORE),AK(SLASH),AK(MINUS),AK(CARET)}},
38 {{AK(F6),AK(O),AK(L),AK(K)},
39 {AK(PERIOD),AK(COMMA),AK(P),AK(0)}},
40 {{AK(F5),AK(I),AK(U),AK(J)},
41 {AK(M),AK(N),AK(9),AK(8)}},
42 {{AK(F4),AK(Y),AK(G),AK(H)},
43 {AK(B),AK(V),AK(7),AK(6)}},
44 {{AK(F3),AK(T),AK(R),AK(D)},
45 {AK(F),AK(C),AK(5),AK(4)}},
46 {{AK(F2),AK(W),AK(S),AK(A)},
47 {AK(X),AK(Z),AK(E),AK(3)}},
48 {{AK(F1),AK(ESCAPE),AK(Q),AK(CONTROL)},
49 {AK(LEFTSHIFT),AK(GRAPH),AK(1),AK(2)}},
50 {{AK(CLEAR),AK(UP),AK(RIGHT),AK(LEFT)},
51 {AK(DOWN),AK(SPACE),AK(DELETE),AK(INSERT)}},
54 static void FP_FASTAPASS(1) FKB_Write(uint8 v)
59 if((ksmode&1) && !(v&1))
60 ksindex=(ksindex+1)%9;
65 static uint8 FP_FASTAPASS(2) FKB_Read(int w, uint8 ret)
67 //printf("$%04x, %d, %d\n",w+0x4016,ksindex,ksmode&1);
74 if(bufit[ matrix[ksindex][ksmode&1][x]&0xFF ] || bufit[ matrix[ksindex][ksmode&1][x]>>8])
83 static void FKB_Strobe(void)
90 static void FP_FASTAPASS(2) FKB_Update(void *data, int arg)
92 memcpy(bufit+1,data,0x48);
95 static INPUTCFC FKB={FKB_Read,FKB_Write,FKB_Strobe,FKB_Update,0,0};
97 INPUTCFC *FCEU_InitFKB(void)
99 memset(bufit,0,sizeof(bufit));