2019-03-18 22:15:05 +00:00
|
|
|
#if not(GAMEBOY)
|
2020-03-31 15:27:31 +00:00
|
|
|
#warn gb_joy module should be only used on Game Boy targets
|
2019-03-18 22:15:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
import gb_hardware
|
|
|
|
|
|
|
|
#pragma zilog_syntax
|
|
|
|
|
|
|
|
// standard joystick driver for Game Boy
|
|
|
|
|
|
|
|
import joy
|
|
|
|
|
|
|
|
alias input_a = input_btn
|
|
|
|
byte input_b
|
|
|
|
byte input_select
|
|
|
|
byte input_start
|
|
|
|
|
|
|
|
void read_joy() {
|
|
|
|
byte tmp
|
|
|
|
reg_joypad = $20
|
|
|
|
asm {
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
}
|
|
|
|
tmp = reg_joypad
|
|
|
|
input_dx = 0
|
|
|
|
input_dy = 0
|
|
|
|
if tmp & 1 == 0 { input_dx += 1 }
|
|
|
|
if tmp & 2 == 0 { input_dx -= 1 }
|
|
|
|
if tmp & 4 == 0 { input_dy -= 1 }
|
|
|
|
if tmp & 8 == 0 { input_dy += 1 }
|
|
|
|
reg_joypad = $10
|
|
|
|
asm {
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
ld a,(reg_joypad)
|
|
|
|
}
|
2021-07-11 22:15:39 +00:00
|
|
|
|
2019-03-18 22:15:05 +00:00
|
|
|
tmp = reg_joypad ^ $ff
|
2021-07-11 22:15:39 +00:00
|
|
|
input_a = (tmp & 1) // >> 0
|
2019-03-18 22:15:05 +00:00
|
|
|
input_b = (tmp & 2) >> 1
|
|
|
|
input_select = (tmp & 4) >> 2
|
|
|
|
input_start = (tmp & 8) >> 3
|
|
|
|
}
|