-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdipsw.c
115 lines (99 loc) · 2 KB
/
dipsw.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "compiler.h"
#include "sysmng.h"
#include "cpucore.h"
#include "pccore.h"
#include "iocore.h"
#include "sound.h"
#include "beep.h"
void IOOUTCALL dipsw_w8(UINT port, REG8 value) {
UINT8 set;
switch(port & 0x0f00) {
case 0x0400:
if (!(iflags[value] & 0x04)) {
set = value & 0xfc;
if ((pccore.dipsw[0] ^ set) & 0xfc) {
pccore.dipsw[0] &= ~(0xfc);
pccore.dipsw[0] |= set;
}
}
break;
case 0x0500:
if (!(iflags[value] & 0x04)) {
set = value & 0xef;
if ((pccore.dipsw[1] ^ set) & 0xef) {
pccore.dipsw[1] &= ~(0xef);
pccore.dipsw[1] |= set;
}
}
break;
case 0x0600:
if (!(iflags[value] & 0x04)) {
set = value & 0x7f;
if ((pccore.dipsw[2] ^ set) & 0x7f) {
pccore.dipsw[2] &= ~(0x7f);
pccore.dipsw[2] |= set;
}
}
break;
case 0x0700:
if (!(iflags[value] & 0x04)) {
set = (value & 0x20) >> 1;
if ((pccore.dipsw[1] ^ set) & 0x10) {
pccore.dipsw[1] ^= 0x10;
}
set = (value >> 2) & 0x03;
if (np2cfg.BEEP_VOL != set) {
np2cfg.BEEP_VOL = set;
beep_setvol(set);
sysmng_update(SYS_UPDATECFG);
}
}
break;
case 0x0e00:
if (!(iflags[value] & 0x04)) {
set = (value & 0x10) << 3;
if ((pccore.dipsw[2] ^ set) & 0x80) {
pccore.dipsw[2] ^= 0x80;
}
}
break;
}
}
REG8 IOINPCALL dipsw_r8(UINT port) {
REG8 ret;
ret = 0xff;
switch(port & 0x0f00) {
case 0x0400:
ret = pccore.dipsw[0] & 0xfc;
if (iflags[ret] & 0x04) {
ret |= 0x01;
}
break;
case 0x0500:
ret = pccore.dipsw[1] & 0xef;
if (iflags[ret] & 0x04) {
ret |= 0x10;
}
break;
case 0x0600:
ret = pccore.dipsw[2] & 0x7f;
if (iflags[ret] & 0x04) {
ret |= 0x80;
}
break;
case 0x0700:
ret = ((pccore.dipsw[1] & 0x10) << 1) |
((np2cfg.BEEP_VOL & 0x03) << 2);
if (iflags[ret] & 0x04) {
ret |= 0x80;
}
break;
case 0x0e00:
ret = (pccore.dipsw[2] & 0x80) >> 3;
if (iflags[ret] & 0x04) {
ret |= 0x80;
}
break;
}
return(ret);
}