aboutsummaryrefslogtreecommitdiff
path: root/examples/io
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2022-09-26 16:49:56 +0800
committerGitHub <noreply@github.com>2022-09-26 16:49:56 +0800
commitc4a2533d21dfd05cde841ea48c67b05e0e6a853f (patch)
treec7ef61653b157b69fb0956709366996ddbc4ecfa /examples/io
parenta8b404b3400c3ebd8e0b923dcaefcc49ea563e36 (diff)
parent86f0064afb8200e60dd80827535cac30d0eab028 (diff)
downloadpsn00bsdk-c4a2533d21dfd05cde841ea48c67b05e0e6a853f.tar.gz
Merge pull request #55 from spicyjpeg/psxmdec
Full MDEC support, C library refactors, cleanups and bugfixes (v0.20)
Diffstat (limited to 'examples/io')
-rw-r--r--examples/io/system573/k573io.c7
-rw-r--r--examples/io/system573/k573io.h64
-rw-r--r--examples/io/system573/main.c2
3 files changed, 41 insertions, 32 deletions
diff --git a/examples/io/system573/k573io.c b/examples/io/system573/k573io.c
index bc13852..53c109f 100644
--- a/examples/io/system573/k573io.c
+++ b/examples/io/system573/k573io.c
@@ -75,7 +75,7 @@ uint32_t K573_GetJAMMAInputs(void) {
inputs |= ((K573_IO_CHIP[IO_REG_IN1_HIGH] >> 8) & 0x1f) << 24;
inputs |= (K573_IO_CHIP[IO_REG_IN1_LOW] & 0x07) << 29;
- return inputs;
+ return ~inputs;
}
void K573_SetLights(uint32_t lights) {
@@ -120,5 +120,10 @@ void K573_Init(void) {
EXP1_ADDR = 0x1f000000;
EXP1_DELAY_SIZE = 0x24173f47; // 573 BIOS uses this value
+ // Bit 6 of this register controls the audio DAC and must be set, otherwise
+ // no sound will be output. Most of the other bits are data clocks/strobes
+ // and should be pulled high when not in use.
+ K573_IO_CHIP[IO_REG_OUT0] = 0x01e7;
+
K573_RESET_WATCHDOG();
}
diff --git a/examples/io/system573/k573io.h b/examples/io/system573/k573io.h
index 7095a7c..8655237 100644
--- a/examples/io/system573/k573io.h
+++ b/examples/io/system573/k573io.h
@@ -10,21 +10,22 @@
/* Register definitions */
-#define K573_BANK_SWITCH *((volatile uint16_t *) 0x1f500000)
-#define K573_IDE_RESET *((volatile uint16_t *) 0x1f560000)
-#define K573_WATCHDOG *((volatile uint16_t *) 0x1f5c0000)
-#define K573_EXT_OUT *((volatile uint16_t *) 0x1f600000)
-#define K573_JVS_INPUT *((volatile uint16_t *) 0x1f680000)
-#define K573_SECURITY_OUT *((volatile uint16_t *) 0x1f6a0000)
-
-#define K573_FLASH ((volatile uint16_t *) 0x1f000000)
-#define K573_IO_CHIP ((volatile uint16_t *) 0x1f400000)
-#define K573_IDE_CS0 ((volatile uint16_t *) 0x1f480000)
-#define K573_IDE_CS1 ((volatile uint16_t *) 0x1f4c0000)
-#define K573_RTC ((volatile uint16_t *) 0x1f620000)
-#define K573_IO_BOARD ((volatile uint16_t *) 0x1f640000)
+#define K573_BANK_SWITCH *((volatile uint16_t *) 0xbf500000)
+#define K573_IDE_RESET *((volatile uint16_t *) 0xbf560000)
+#define K573_WATCHDOG *((volatile uint16_t *) 0xbf5c0000)
+#define K573_EXT_OUT *((volatile uint16_t *) 0xbf600000)
+#define K573_JVS_INPUT *((volatile uint16_t *) 0xbf680000)
+#define K573_SECURITY_OUT *((volatile uint16_t *) 0xbf6a0000)
+
+#define K573_FLASH ((volatile uint16_t *) 0xbf000000)
+#define K573_IO_CHIP ((volatile uint16_t *) 0xbf400000)
+#define K573_IDE_CS0 ((volatile uint16_t *) 0xbf480000)
+#define K573_IDE_CS1 ((volatile uint16_t *) 0xbf4c0000)
+#define K573_RTC ((volatile uint16_t *) 0xbf620000)
+#define K573_IO_BOARD ((volatile uint16_t *) 0xbf640000)
typedef enum _K573_IOChipRegister {
+ IO_REG_OUT0 = 0x0,
IO_REG_IN0 = 0x0,
IO_REG_IN1_LOW = 0x2,
IO_REG_IN1_HIGH = 0x3,
@@ -34,26 +35,29 @@ typedef enum _K573_IOChipRegister {
} K573_IOChipRegister;
typedef enum _K573_IOBoardRegister {
- ANALOG_IO_REG_LIGHTS0 = 0x40,
- ANALOG_IO_REG_LIGHTS1 = 0x44,
- ANALOG_IO_REG_LIGHTS2 = 0x48,
- ANALOG_IO_REG_LIGHTS3 = 0x4c,
+ ANALOG_IO_REG_LIGHTS0 = 0x40,
+ ANALOG_IO_REG_LIGHTS1 = 0x44,
+ ANALOG_IO_REG_LIGHTS2 = 0x48,
+ ANALOG_IO_REG_LIGHTS3 = 0x4c,
// The digital I/O board has a lot more registers than these, but there
// seems to be no DIGITAL_IO_LIGHTS6 register. WTF
- DIGITAL_IO_REG_LIGHTS1 = 0x70,
- DIGITAL_IO_REG_LIGHTS0 = 0x71,
- DIGITAL_IO_REG_LIGHTS3 = 0x72,
- DIGITAL_IO_REG_LIGHTS7 = 0x73,
- DIGITAL_IO_REG_LIGHTS4 = 0x7d,
- DIGITAL_IO_REG_LIGHTS5 = 0x7e,
- DIGITAL_IO_REG_LIGHTS2 = 0x7f,
-
- FISHBAIT_IO_REG_UNKNOWN = 0x08,
- FISHBAIT_IO_REG_MOTOR = 0x40,
- FISHBAIT_IO_REG_BRAKE = 0x44,
- FISHBAIT_IO_REG_ENCODER = 0x4c,
- FISHBAIT_IO_REG_RESET_Y = 0x50
+ DIGITAL_IO_REG_LIGHTS1 = 0x70,
+ DIGITAL_IO_REG_LIGHTS0 = 0x71,
+ DIGITAL_IO_REG_LIGHTS3 = 0x72,
+ DIGITAL_IO_REG_LIGHTS7 = 0x73,
+ DIGITAL_IO_REG_DS2401 = 0x77,
+ DIGITAL_IO_REG_FPGA_STATUS = 0x7b,
+ DIGITAL_IO_REG_FPGA_UPLOAD = 0x7c,
+ DIGITAL_IO_REG_LIGHTS4 = 0x7d,
+ DIGITAL_IO_REG_LIGHTS5 = 0x7e,
+ DIGITAL_IO_REG_LIGHTS2 = 0x7f,
+
+ FISHBAIT_IO_REG_UNKNOWN = 0x08,
+ FISHBAIT_IO_REG_MOTOR = 0x40,
+ FISHBAIT_IO_REG_BRAKE = 0x44,
+ FISHBAIT_IO_REG_ENCODER = 0x4c,
+ FISHBAIT_IO_REG_RESET_Y = 0x50
} K573_IOBoardRegister;
// The 573's real-time clock chip is an M48T58, which behaves like a standard
diff --git a/examples/io/system573/main.c b/examples/io/system573/main.c
index 64722d7..3404ee4 100644
--- a/examples/io/system573/main.c
+++ b/examples/io/system573/main.c
@@ -207,7 +207,7 @@ int main(int argc, const char* argv[]) {
// Change the currently active light if the test button on the 573's
// front panel is pressed. DDR non-light outputs are skipped.
- if ((last_inputs & JAMMA_TEST) && !(inputs & JAMMA_TEST)) {
+ if (!(last_inputs & JAMMA_TEST) && (inputs & JAMMA_TEST)) {
current_light++;
if (
(current_light == 4) || // DDR_LIGHT_P1_MUX_DATA