merged ppu code, added input+zapper, FDS/VS insert in menu
[fceu.git] / input / arkanoid.c
CommitLineData
c62d2810 1/* FCE Ultra - NES/Famicom Emulator
2 *
3 * Copyright notice for this file:
e328100e 4 * Copyright (C) 2002 Xodnizel
c62d2810 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>
e328100e 22#include <stdlib.h>
23#include "share.h"
c62d2810 24
25typedef struct {
26 uint32 mzx,mzb;
27 uint32 readbit;
28} ARK;
29
30static ARK NESArk[2];
31static ARK FCArk;
32
33static void StrobeARKFC(void)
34{
35 FCArk.readbit=0;
36}
37
38
39static uint8 FP_FASTAPASS(2) ReadARKFC(int w,uint8 ret)
40{
41 ret&=~2;
42
43 if(w)
44 {
45 if(FCArk.readbit>=8)
46 ret|=2;
47 else
48 {
49 ret|=((FCArk.mzx>>(7-FCArk.readbit))&1)<<1;
e328100e 50 if(!fceuindbg)
51 FCArk.readbit++;
c62d2810 52 }
53 }
54 else
55 ret|=FCArk.mzb<<1;
56 return(ret);
57}
58
59static uint32 FixX(uint32 x)
60{
61 x=98+x*144/240;
62 if(x>242) x=242;
63 x=~x;
64 return(x);
65}
66
67static void FP_FASTAPASS(2) UpdateARKFC(void *data, int arg)
68{
e328100e 69 uint32 *ptr=(uint32 *)data;
c62d2810 70 FCArk.mzx=FixX(ptr[0]);
71 FCArk.mzb=ptr[2]?1:0;
72}
73
74static INPUTCFC ARKCFC={ReadARKFC,0,StrobeARKFC,UpdateARKFC,0,0};
75
76INPUTCFC *FCEU_InitArkanoidFC(void)
77{
78 FCArk.mzx=98;
79 FCArk.mzb=0;
80 return(&ARKCFC);
81}
82
83static uint8 FP_FASTAPASS(1) ReadARK(int w)
84{
85 uint8 ret=0;
86
87 if(NESArk[w].readbit>=8)
88 ret|=1<<4;
89 else
90 {
91 ret|=((NESArk[w].mzx>>(7-NESArk[w].readbit))&1)<<4;
e328100e 92 if(!fceuindbg)
93 NESArk[w].readbit++;
c62d2810 94 }
95 ret|=(NESArk[w].mzb&1)<<3;
96 return(ret);
97}
98
99
100static void FP_FASTAPASS(1) StrobeARK(int w)
101{
102 NESArk[w].readbit=0;
103}
104
105static void FP_FASTAPASS(3) UpdateARK(int w, void *data, int arg)
106{
e328100e 107 uint32 *ptr=(uint32*)data;
c62d2810 108 NESArk[w].mzx=FixX(ptr[0]);
109 NESArk[w].mzb=ptr[2]?1:0;
110}
111
112static INPUTC ARKC={ReadARK, 0, StrobeARK, UpdateARK, 0, 0};
113
114INPUTC *FCEU_InitArkanoid(int w)
115{
116 NESArk[w].mzx=98;
117 NESArk[w].mzb=0;
118 return(&ARKC);
119}