├── .gitignore
├── .travis.yml
├── LICENSE
├── Makefile
├── README.md
├── VDP.h
├── hqx
├── common.h
├── hq2x.c
├── hq3x.c
├── hq4x.c
├── hqx.h
└── init.c
├── images
├── kiwi.gif
├── pad.png
├── pad2.png
└── pad_big.png
├── input.c
├── input.h
├── kiwi.py
├── m68k
├── history.txt
├── m68k.h
├── m68k_in.c
├── m68kconf.h
├── m68kcpu.c
├── m68kcpu.h
├── m68kdasm.c
├── m68kmake.c
├── m68kopac.c
├── m68kopdm.c
├── m68kopnz.c
├── m68kops.c
├── m68kops.h
└── readme.txt
├── macos_app.py
├── megadrive.c
├── scale.c
├── tests
├── __init__.py
├── ristar
│ ├── Ristar (UE) [!].zip
│ ├── __init__.py
│ ├── debug-output.txt
│ ├── ristar-screenshot-1x-epx.bmp
│ ├── ristar-screenshot-1x-hqx.bmp
│ ├── ristar-screenshot-1x-none.bmp
│ ├── ristar-screenshot-2x-epx.bmp
│ ├── ristar-screenshot-2x-hqx.bmp
│ ├── ristar-screenshot-2x-none.bmp
│ ├── ristar-screenshot-3x-epx.bmp
│ ├── ristar-screenshot-3x-hqx.bmp
│ ├── ristar-screenshot-3x-none.bmp
│ ├── ristar-screenshot-4x-epx.bmp
│ ├── ristar-screenshot-4x-hqx.bmp
│ ├── ristar-screenshot-4x-none.bmp
│ └── test_ristar.py
└── test_gui.py
├── vdp.c
├── z80.c
└── z80.h
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.sw?
3 | *.o
4 | *.so
5 | *.pyc
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | cache: pip
3 | python:
4 | - "2.7"
5 | before_install:
6 | - pip install cpp-coveralls # has to be installed before coveralls because of binary shadowing
7 | - pip install coveralls
8 | - "export DISPLAY=:99.0"
9 | - "sh -e /etc/init.d/xvfb start"
10 | - sleep 3 # sleep so xvfb can start
11 | install:
12 | - pip install PySide pytest-qt pytest-mock
13 | - make COVERAGE=1
14 | script: coverage run --source . -m py.test
15 | after_success:
16 | - cpp-coveralls --exclude m68k --exclude hqx --gcov-options '\-lp' --dump cpp.json
17 | - coveralls --merge=cpp.json
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2012 Luke Zapart
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
9 |
10 |
11 | The hqx library.
12 |
13 | Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
14 | Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net)
15 |
16 | See hqx/hqx.h for license details (GPL 2.1)
17 |
18 |
19 | The Musashi library.
20 |
21 | The Musashi M680x0 emulator is copyright 1998-2001 Karl Stenerud.
22 |
23 | See m68k/readme.txt for license details (a simple attribution non-commercial license).
24 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | OS := $(shell uname)
2 |
3 | CC = cc
4 | WARNINGS = -Wall -pedantic -Wno-unused-function
5 | CFLAGS = $(WARNINGS) -c -Im68k -I. -O2 --std=c99 -fPIC
6 | CFLAGS_M68K = $(WARNINGS) -c -Im68k -I. -O2 --std=c99 -fPIC
7 | LDFLAGS = -shared
8 |
9 | ifdef COVERAGE
10 | ifeq ($(OS),Darwin)
11 | CFLAGS += -fprofile-instr-generate -fcoverage-mapping
12 | LDFLAGS += -fprofile-instr-generate
13 | else
14 | CFLAGS += -fprofile-arcs -ftest-coverage
15 | LDFLAGS += -lgcov
16 | endif
17 | endif
18 |
19 | all: megadrive.so
20 |
21 | clean:
22 | rm megadrive.so *.o m68k/*.o hqx/*.o m68k/m68kops.h m68k/m68kmake
23 |
24 | megadrive.so: m68k/m68kcpu.o m68k/m68kops.o m68k/m68kopac.o m68k/m68kopdm.o m68k/m68kopnz.o m68k/m68kdasm.o megadrive.o vdp.o input.o scale.o z80.o hqx/init.o hqx/hq2x.o hqx/hq3x.o hqx/hq4x.o
25 | @echo "Linking megadrive.so"
26 | @$(CC) m68k/m68kcpu.o m68k/m68kops.o m68k/m68kopac.o m68k/m68kopdm.o m68k/m68kopnz.o m68k/m68kdasm.o megadrive.o vdp.o input.o scale.o z80.o hqx/init.o hqx/hq2x.o hqx/hq3x.o hqx/hq4x.o $(LDFLAGS) -o megadrive.so
27 |
28 | %.o: %.c
29 | @echo "Compiling $<"
30 | $(CC) $(CFLAGS) $^ -std=c99 -o $@
31 |
32 | m68k/m68kcpu.o: m68k/m68kops.h m68k/m68k.h m68k/m68kconf.h m68k/m68kcpu.c
33 | @echo "Compiling m68k/m68kcpu.c"
34 | $(CC) $(CFLAGS_M68K) m68k/m68kcpu.c -o m68k/m68kcpu.o
35 |
36 | m68k/m68kdasm.o: m68k/m68kdasm.c m68k/m68k.h m68k/m68kconf.h
37 | @echo "Compiling m68k/m68kdasm.c"
38 | @$(CC) $(CFLAGS_M68K) m68k/m68kdasm.c -o m68k/m68kdasm.o
39 |
40 | m68k/m68kops.o: m68k/m68kmake m68k/m68kops.h m68k/m68kops.c m68k/m68k.h m68k/m68kconf.h
41 | @echo "Compiling m68k/m68kops.c"
42 | @$(CC) $(CFLAGS_M68K) m68k/m68kops.c -o m68k/m68kops.o
43 |
44 | m68k/m68kopac.o: m68k/m68kmake m68k/m68kops.h m68k/m68kopac.c m68k/m68k.h m68k/m68kconf.h
45 | @echo "Compiling m68k/m68kopac.c"
46 | @$(CC) $(CFLAGS_M68K) m68k/m68kopac.c -o m68k/m68kopac.o
47 |
48 | m68k/m68kopdm.o: m68k/m68kmake m68k/m68kops.h m68k/m68kopdm.c m68k/m68k.h m68k/m68kconf.h
49 | @echo "Compiling m68k/m68kopdm.c"
50 | @$(CC) $(CFLAGS_M68K) m68k/m68kopdm.c -o m68k/m68kopdm.o
51 |
52 | m68k/m68kopnz.o: m68k/m68kmake m68k/m68kops.h m68k/m68kopnz.c m68k/m68k.h m68k/m68kconf.h
53 | @echo "Compiling m68k/m68kopnz.c"
54 | @$(CC) $(CFLAGS_M68K) m68k/m68kopnz.c -o m68k/m68kopnz.o
55 |
56 | m68k/m68kops.h: m68k/m68kmake
57 | @echo "Generating m68k/m68kops.h"
58 | @m68k/m68kmake m68k m68k/m68k_in.c >/dev/null
59 |
60 | m68k/m68kmake: m68k/m68kmake.c m68k/m68k_in.c
61 | @echo "Compiling m68k/m68kmake"
62 | @$(CC) $(WARNINGS) m68k/m68kmake.c -o m68k/m68kmake
63 |
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Kiwi [](https://coveralls.io/github/drx/kiwi)
2 |
3 | Kiwi is a simple Sega Genesis emulator.
4 |
5 |
 Kiwi in action |
6 |
7 | ### Quick start
8 |
9 | #### Binary
10 | * [macOS app](https://github.com/drx/kiwi/releases/download/v0.1-alpha/kiwi-v0.1-alpha-macos.zip)
11 |
12 | #### Running from source
13 | 1. `$ git clone git://github.com/drx/kiwi.git` or [download the latest version](https://github.com/drx/kiwi/zipball/master)
14 | 2. `$ brew install qt@4` (macOS)
`$ sudo apt-get install libqt4-dev` (Linux)
15 | 2. `$ pip install PySide`
16 | 2. `$ make`
17 | 3. `$ ./kiwi.py`
18 |
19 | ### Requirements
20 |
21 | * clang/gcc, make, Python 2.7
22 | * Qt 4, PySide
23 |
24 | ### Acknowledgements
25 |
26 | * The [hqx library](http://code.google.com/p/hqx/) is by Maxim Stepin and Cameron Zemek
27 | * The Musashi library is by Karl Stenerud
28 |
29 | ### Notes
30 |
31 | * Kiwi was written in 2013, with some bugs fixed and tests added more recently.
32 | * There is no sound support. The Z80 processor is handled by dummy code. Some games do not work at all because of this.
33 | * Tested on Linux and macOS.
34 | * The bundled macOS doesn't work on some machines, in which case you have to run from source.
35 |
--------------------------------------------------------------------------------
/VDP.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Megadrive VDP emulation
3 | */
4 |
5 | void draw_cell_pixel(unsigned int cell, int cell_x, int cell_y, int x, int y);
6 | void vdp_render_bg(int line, int priority);
7 | void vdp_render_sprite(int sprite_index, int line);
8 | void vdp_render_sprites(int line, int priority);
9 | void vdp_render_line(int line);
10 |
11 | void vdp_set_buffers(unsigned char *screen_buffer, unsigned char *scaled_buffer);
12 | void vdp_debug_status(char *s);
13 |
14 | enum ram_type {
15 | T_VRAM,
16 | T_CRAM,
17 | T_VSRAM
18 | };
19 |
20 | void vdp_data_write(unsigned int value, enum ram_type type, int dma);
21 | void vdp_data_port_write(unsigned int value);
22 | void vdp_set_reg(int reg, unsigned char value);
23 | unsigned int vdp_get_reg(int reg);
24 | void vdp_control_write(unsigned int value);
25 | void vdp_write(unsigned int address, unsigned int value);
26 | unsigned int vdp_read(unsigned int address);
27 |
28 | unsigned int vdp_get_status();
29 | unsigned short vdp_get_cram(int index);
30 |
31 | void vdp_set_hblank();
32 | void vdp_clear_hblank();
33 | void vdp_set_vblank();
34 | void vdp_clear_vblank();
35 |
--------------------------------------------------------------------------------
/hqx/common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
3 | *
4 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net)
5 | * Copyright (C) 2011 Francois Gannaz
6 | *
7 | * This program is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 | */
21 |
22 | #ifndef __HQX_COMMON_H_
23 | #define __HQX_COMMON_H_
24 |
25 | #include
26 | #include
27 |
28 | #define MASK_2 0x0000FF00
29 | #define MASK_13 0x00FF00FF
30 | #define MASK_RGB 0x00FFFFFF
31 | #define MASK_ALPHA 0xFF000000
32 |
33 | #define Ymask 0x00FF0000
34 | #define Umask 0x0000FF00
35 | #define Vmask 0x000000FF
36 | #define trY 0x00300000
37 | #define trU 0x00000700
38 | #define trV 0x00000006
39 |
40 | /* RGB to YUV lookup table */
41 | extern uint32_t RGBtoYUV[16777216];
42 |
43 | static inline uint32_t rgb_to_yuv(uint32_t c)
44 | {
45 | // Mask against MASK_RGB to discard the alpha channel
46 | return RGBtoYUV[MASK_RGB & c];
47 | }
48 |
49 | /* Test if there is difference in color */
50 | static inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) {
51 | return (( abs((yuv1 & Ymask) - (yuv2 & Ymask)) > trY ) ||
52 | ( abs((yuv1 & Umask) - (yuv2 & Umask)) > trU ) ||
53 | ( abs((yuv1 & Vmask) - (yuv2 & Vmask)) > trV ) );
54 | }
55 |
56 | static inline int Diff(uint32_t c1, uint32_t c2)
57 | {
58 | return yuv_diff(rgb_to_yuv(c1), rgb_to_yuv(c2));
59 | }
60 |
61 | /* Interpolate functions */
62 | static inline uint32_t Interpolate_2(uint32_t c1, int w1, uint32_t c2, int w2, int s)
63 | {
64 | if (c1 == c2) {
65 | return c1;
66 | }
67 | return
68 | (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24-s)) & MASK_ALPHA) +
69 | ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> s) & MASK_2) +
70 | ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> s) & MASK_13);
71 | }
72 |
73 | static inline uint32_t Interpolate_3(uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s)
74 | {
75 | return
76 | (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24-s)) & MASK_ALPHA) +
77 | ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> s) & MASK_2) +
78 | ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> s) & MASK_13);
79 | }
80 |
81 | static inline void Interp1(uint32_t * pc, uint32_t c1, uint32_t c2)
82 | {
83 | //*pc = (c1*3+c2) >> 2;
84 | *pc = Interpolate_2(c1, 3, c2, 1, 2);
85 | }
86 |
87 | static inline void Interp2(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
88 | {
89 | //*pc = (c1*2+c2+c3) >> 2;
90 | *pc = Interpolate_3(c1, 2, c2, 1, c3, 1, 2);
91 | }
92 |
93 | static inline void Interp3(uint32_t * pc, uint32_t c1, uint32_t c2)
94 | {
95 | //*pc = (c1*7+c2)/8;
96 | *pc = Interpolate_2(c1, 7, c2, 1, 3);
97 | }
98 |
99 | static inline void Interp4(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
100 | {
101 | //*pc = (c1*2+(c2+c3)*7)/16;
102 | *pc = Interpolate_3(c1, 2, c2, 7, c3, 7, 4);
103 | }
104 |
105 | static inline void Interp5(uint32_t * pc, uint32_t c1, uint32_t c2)
106 | {
107 | //*pc = (c1+c2) >> 1;
108 | *pc = Interpolate_2(c1, 1, c2, 1, 1);
109 | }
110 |
111 | static inline void Interp6(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
112 | {
113 | //*pc = (c1*5+c2*2+c3)/8;
114 | *pc = Interpolate_3(c1, 5, c2, 2, c3, 1, 3);
115 | }
116 |
117 | static inline void Interp7(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
118 | {
119 | //*pc = (c1*6+c2+c3)/8;
120 | *pc = Interpolate_3(c1, 6, c2, 1, c3, 1, 3);
121 | }
122 |
123 | static inline void Interp8(uint32_t * pc, uint32_t c1, uint32_t c2)
124 | {
125 | //*pc = (c1*5+c2*3)/8;
126 | *pc = Interpolate_2(c1, 5, c2, 3, 3);
127 | }
128 |
129 | static inline void Interp9(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
130 | {
131 | //*pc = (c1*2+(c2+c3)*3)/8;
132 | *pc = Interpolate_3(c1, 2, c2, 3, c3, 3, 3);
133 | }
134 |
135 | static inline void Interp10(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3)
136 | {
137 | //*pc = (c1*14+c2+c3)/16;
138 | *pc = Interpolate_3(c1, 14, c2, 1, c3, 1, 4);
139 | }
140 |
141 | #endif
142 |
--------------------------------------------------------------------------------
/hqx/hqx.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
3 | *
4 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net)
5 | *
6 | * This program is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (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 GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License 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 | #ifndef __HQX_H_
22 | #define __HQX_H_
23 |
24 | #include
25 |
26 | #if defined( __GNUC__ )
27 | #ifdef __MINGW32__
28 | #define HQX_CALLCONV __stdcall
29 | #else
30 | #define HQX_CALLCONV
31 | #endif
32 | #else
33 | #define HQX_CALLCONV
34 | #endif
35 |
36 | #if defined(_WIN32)
37 | #ifdef DLL_EXPORT
38 | #define HQX_API __declspec(dllexport)
39 | #else
40 | #define HQX_API __declspec(dllimport)
41 | #endif
42 | #else
43 | #define HQX_API
44 | #endif
45 |
46 | HQX_API void HQX_CALLCONV hqxInit(void);
47 | HQX_API void HQX_CALLCONV hq2x_32( uint32_t * src, uint32_t * dest, int width, int height );
48 | HQX_API void HQX_CALLCONV hq3x_32( uint32_t * src, uint32_t * dest, int width, int height );
49 | HQX_API void HQX_CALLCONV hq4x_32( uint32_t * src, uint32_t * dest, int width, int height );
50 |
51 | HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height );
52 | HQX_API void HQX_CALLCONV hq3x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height );
53 | HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height );
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/hqx/init.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net)
3 | *
4 | * This program is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 | */
18 |
19 | #include
20 | #include "hqx.h"
21 |
22 | uint32_t RGBtoYUV[16777216];
23 | uint32_t YUV1, YUV2;
24 |
25 | HQX_API void HQX_CALLCONV hqxInit(void)
26 | {
27 | /* Initalize RGB to YUV lookup table */
28 | uint32_t c, r, g, b, y, u, v;
29 | for (c = 0; c < 16777215; c++) {
30 | r = (c & 0xFF0000) >> 16;
31 | g = (c & 0x00FF00) >> 8;
32 | b = c & 0x0000FF;
33 | y = (uint32_t)(0.299*r + 0.587*g + 0.114*b);
34 | u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128;
35 | v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128;
36 | RGBtoYUV[c] = (y << 16) + (u << 8) + v;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/images/kiwi.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drx/kiwi/85ec7e005f9a88175b5f3236ff0d4d7268e4fefd/images/kiwi.gif
--------------------------------------------------------------------------------
/images/pad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drx/kiwi/85ec7e005f9a88175b5f3236ff0d4d7268e4fefd/images/pad.png
--------------------------------------------------------------------------------
/images/pad2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drx/kiwi/85ec7e005f9a88175b5f3236ff0d4d7268e4fefd/images/pad2.png
--------------------------------------------------------------------------------
/images/pad_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drx/kiwi/85ec7e005f9a88175b5f3236ff0d4d7268e4fefd/images/pad_big.png
--------------------------------------------------------------------------------
/input.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "input.h"
3 |
4 | /*
5 | * Sega Megadrive joypad support
6 | */
7 |
8 | enum pad_button
9 | {
10 | PAD_UP,
11 | PAD_DOWN,
12 | PAD_LEFT,
13 | PAD_RIGHT,
14 | PAD_B,
15 | PAD_C,
16 | PAD_A,
17 | PAD_S
18 | };
19 |
20 | unsigned short button_state[3];
21 | unsigned short pad_state[3];
22 | unsigned char io_reg[16] = {0xa0, 0x7f, 0x7f, 0x7f, 0, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0}; /* initial state */
23 |
24 | void pad_press_button(int pad, int button)
25 | {
26 | button_state[pad] |= (1<