e328100e |
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 uint8 OKValR,LastWR; |
25 | static uint32 OKData; |
26 | static uint32 OKX,OKY,OKB; |
27 | |
28 | static uint8 FP_FASTAPASS(2) OK_Read(int w, uint8 ret) |
29 | { |
30 | if(w) |
31 | { |
32 | ret|=OKValR; |
33 | } |
34 | return(ret); |
35 | } |
36 | |
37 | static void FP_FASTAPASS(1) OK_Write(uint8 V) |
38 | { |
39 | if(!(V&0x1)) |
40 | { |
41 | int32 vx,vy; |
42 | |
43 | //puts("Redo"); |
44 | OKValR=OKData=0; |
45 | |
46 | if(OKB) OKData|=1; |
47 | |
48 | if(OKY >= 48) |
49 | OKData|=2; |
50 | else if(OKB) OKData|=3; |
51 | |
52 | vx=OKX*240/256+8; |
53 | vy=OKY*256/240-12; |
54 | if(vy<0) vy=0; |
55 | if(vy>255) vy=255; |
56 | if(vx<0) vx=0; |
57 | if(vx>255) vx=255; |
58 | OKData |= (vx<<10) | (vy<<2); |
59 | } |
60 | else |
61 | { |
62 | if((~LastWR)&V&0x02) |
63 | OKData<<=1; |
64 | |
65 | if(!(V&0x2)) OKValR=0x4; |
66 | else |
67 | { |
68 | if(OKData&0x40000) OKValR=0; |
69 | else OKValR=0x8; |
70 | } |
71 | } |
72 | LastWR=V; |
73 | } |
74 | |
75 | static void FP_FASTAPASS(2) OK_Update(void *data, int arg) |
76 | { |
77 | //puts("Sync"); |
78 | OKX=((uint32*)data)[0]; |
79 | OKY=((uint32*)data)[1]; |
80 | OKB=((uint32*)data)[2]; |
81 | } |
82 | |
83 | static void FP_FASTAPASS(2) DrawOeka(uint8 *buf, int arg) |
84 | { |
85 | if(arg && OKY<44) |
86 | FCEU_DrawCursor(buf, OKX, OKY); |
87 | } |
88 | |
89 | static INPUTCFC OekaKids={OK_Read,OK_Write,0,OK_Update,0,DrawOeka}; |
90 | |
91 | INPUTCFC *FCEU_InitOekaKids(void) |
92 | { |
93 | OKValR=0; |
94 | return(&OekaKids); |
95 | } |