joypad.cpp 653 B

12345678910111213141516171819202122232425262728
  1. #ifdef SCPU_CPP
  2. void sCPU::run_auto_joypad_poll() {
  3. uint16 joy1 = 0, joy2 = 0, joy3 = 0, joy4 = 0;
  4. for(unsigned i = 0; i < 16; i++) {
  5. uint8 port0 = snes.input.port_read(0);
  6. uint8 port1 = snes.input.port_read(1);
  7. joy1 |= (port0 & 1) ? (0x8000 >> i) : 0;
  8. joy2 |= (port1 & 1) ? (0x8000 >> i) : 0;
  9. joy3 |= (port0 & 2) ? (0x8000 >> i) : 0;
  10. joy4 |= (port1 & 2) ? (0x8000 >> i) : 0;
  11. }
  12. status.joy1l = joy1;
  13. status.joy1h = joy1 >> 8;
  14. status.joy2l = joy2;
  15. status.joy2h = joy2 >> 8;
  16. status.joy3l = joy3;
  17. status.joy3h = joy3 >> 8;
  18. status.joy4l = joy4;
  19. status.joy4h = joy4 >> 8;
  20. }
  21. #endif