Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include the header and declare the I/O unit's handle pointer.
- #include "libjvs/jvs.h"
- static JVS_IO* jvs_io;
- // Opening the JVS communication and getting the handle for the first I/O unit.
- if(!jvs_setup(jvs_port_name))
- return 0;
- if(jvs_io_count() < 1) // Check if we have at least 1 I/O unit.
- return 0;
- jvs_io = jvs_io_get(1); // Get handle for I/O unit 1.
- //..........
- // Closing the JVS communication.
- jvs_shutdown();
- //..........
- // Typical per-frame update function.
- if(!jvs_io_update(jvs_io->node, jvs_io)) // Update the I/O unit handle structure.
- return 0;
- if(!jvs_io->sw.has) // Check that the I/O unit has player input switches
- return 0;
- if(jvs_io->sw.buttons < 10) // Check that the I/O unit gives each player at least 10 switches (1 lever + 4 buttons + start + service)
- return 0;
- int j = 0;
- if(jvs_io->sw.data[j] & 0x80) {
- // ADD CODE: Handle test button
- }
- j++;
- for(int i = 0; i < jvs_io->sw.players; i++) {
- for(int l = 0; l < 10; l++) {
- if(l >= jvs_io->sw.buttons)
- break;
- if(jvs_io->sw.data[j + (l >> 3)] & (0x80 >> (l & 7))) {
- // ADD CODE: Handle switch l from player i
- }
- }
- j += (jvs_io->sw.buttons + 7) >> 3;
- }
- if(jvs_io->coin.has) {
- for(int i = 0; i < jvs_io->coin.slots; i++) {
- if(jvs_io->coin.count[i] & 0xC000) // Coin slot is not functional
- continue;
- // ADD CODE: Add (jvs_io->coin.count[i] & 0x3FFF) coins
- jvs_io->coin.subtract[i] = jvs_io->coin.count[i] & 0x3FFF; // Remove coins that were processed.
- }
- }
- //..........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement