2018-12-17 16:18:29 +00:00
|
|
|
// standard joystick driver for NES
|
|
|
|
|
|
|
|
import joy
|
|
|
|
import nes_hardware
|
|
|
|
|
|
|
|
alias input_a = input_btn
|
|
|
|
byte input_b
|
|
|
|
byte input_select
|
|
|
|
byte input_start
|
|
|
|
|
|
|
|
macro void read_joy1() {
|
|
|
|
nes_reset_joy()
|
2019-01-13 18:43:37 +00:00
|
|
|
read_also_joy1()
|
2018-12-17 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro void read_joy2() {
|
|
|
|
nes_reset_joy()
|
2019-01-13 18:43:37 +00:00
|
|
|
read_also_joy2()
|
2018-12-17 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nes_reset_joy() {
|
|
|
|
input_b = 0
|
|
|
|
input_select = 0
|
|
|
|
input_start = 0
|
|
|
|
reset_joy()
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void read_also_joy1() {
|
|
|
|
strobe_joypad()
|
2019-06-28 14:26:05 +00:00
|
|
|
__parse_nes_joypad1()
|
2018-12-17 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void read_also_joy2() {
|
|
|
|
strobe_joypad()
|
2019-06-28 14:26:05 +00:00
|
|
|
__parse_nes_joypad2()
|
2018-12-17 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 14:26:05 +00:00
|
|
|
void __parse_nes_joypad1() {
|
2018-12-17 16:18:29 +00:00
|
|
|
if read_joypad1() & 1 != 0 { input_a += 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_b += 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_select += 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_start += 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_dy -= 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_dy += 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_dx -= 1 }
|
|
|
|
if read_joypad1() & 1 != 0 { input_dx += 1 }
|
2019-06-28 14:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __parse_nes_joypad2() {
|
|
|
|
if read_joypad2() & 1 != 0 { input_a += 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_b += 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_select += 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_start += 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_dy -= 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_dy += 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_dx -= 1 }
|
|
|
|
if read_joypad2() & 1 != 0 { input_dx += 1 }
|
|
|
|
}
|