Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned char ai( unsigned char turn )
- {
- int status;
- unsigned char position; /* pac-mans current position */
- unsigned char level = ram_[0x4E13]; /* current game level */
- /* AI cannot start in middle of a level */
- if( turn > 200)
- {
- rb->splash(HZ/2, "AI will engage at next level start");
- return 0;
- }
- if( turn == 0)
- {
- if( ram_[0x4E0E] == 0)
- {
- turn++;
- }
- }
- if(turn != 0)
- {
- /* set which axis to look for pac-man along */
- position = ram_[0x4D3A];
- if( ai_direction[level][turn-1] < 2)
- {
- position = ram_[0x4D39];
- }
- /*move joystick if necessary */
- if( position == ai_location[level][turn] )
- {
- switch(ai_direction[level][turn])
- {
- case 0:
- clear_joystick();
- setDeviceMode( Joy1_Up, DeviceOn);
- break;
- case 1:
- clear_joystick();
- setDeviceMode( Joy1_Down, DeviceOn);
- break;
- case 2:
- clear_joystick();
- setDeviceMode( Joy1_Right, DeviceOn);
- break;
- case 3:
- clear_joystick();
- setDeviceMode( Joy1_Left, DeviceOn);
- break;
- }
- turn++;
- }
- }
- /* reset turn counter on level end */
- if(ram_[0x4E0E] == 254)
- {
- return 1;
- }
- /* Check the button status */
- status = rb->button_status();
- rb->button_clear_queue();
- /*handle buttons if AI is off */
- if(!turn || (turn == 1))
- {
- #ifdef PACMAN_HAS_REMOTE
- setDeviceMode( Joy1_Left, (status & PACMAN_LEFT || status == PACMAN_RC_LEFT) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT || status == PACMAN_RC_RIGHT) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Up, (status & PACMAN_UP || status == PACMAN_RC_UP) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Down, (status & PACMAN_DOWN || status == PACMAN_RC_DOWN) ? DeviceOn : DeviceOff);
- setDeviceMode( CoinSlot_1, (status & PACMAN_COIN || status == PACMAN_RC_COIN) ? DeviceOn : DeviceOff);
- setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP || status == PACMAN_RC_1UP) ? DeviceOn : DeviceOff);
- setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP || status == PACMAN_RC_2UP) ? DeviceOn : DeviceOff);
- #else
- setDeviceMode( Joy1_Left, (status & PACMAN_LEFT) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Up, (status & PACMAN_UP) ? DeviceOn : DeviceOff);
- setDeviceMode( Joy1_Down, (status & PACMAN_DOWN) ? DeviceOn : DeviceOff);
- setDeviceMode( CoinSlot_1, (status & PACMAN_COIN) ? DeviceOn : DeviceOff);
- setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP) ? DeviceOn : DeviceOff);
- #ifdef PACMAN_2UP
- setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP) ? DeviceOn : DeviceOff);
- #endif
- #endif
- }//else
- //hack();
- /* rb->logf("level = %d", level);*/
- /* rb->logf("turn point = %d",ai_location[level][turn]);*/
- /* rb->logf("turn = %d",turn);*/
- /* rb->logf("x = %d",ram_[0x4D3A]);*/
- /* rb->logf("y = %d",ram_[0x4D39]);*/
- return turn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement