<commit_before>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 <NAME>. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include <xenia/kernel/xam_msg.h>

#include <xenia/kernel/kernel_state.h>
#include <xenia/kernel/xam_private.h>
#include <xenia/kernel/util/shim_utils.h>


using namespace xe;
using namespace xe::kernel;
using namespace xe::kernel::xam;


namespace xe {
namespace kernel {


SHIM_CALL XMsgInProcessCall_shim(
    PPCContext* ppc_state, KernelState* state) {
  uint32_t app = SHIM_GET_ARG_32(0);
  uint32_t message = SHIM_GET_ARG_32(1);
  uint32_t arg1 = SHIM_GET_ARG_32(2);
  uint32_t arg2 = SHIM_GET_ARG_32(3);

  XELOGD(
      "XMsgInProcessCall(%.8X, %.8X, %.8X, %.8X)",
      app, message, arg1, arg2);

  bool handled = false;

  // TODO(benvanik): build XMsg pump? async/sync/etc
  if (app == 0xFA) {
    // XMP = music
    // http://freestyledash.googlecode.com/svn-history/r1/trunk/Freestyle/Scenes/Media/Music/ScnMusic.cpp
    if (message == 0x00070009) {
      uint32_t a = SHIM_MEM_32(arg1 + 0); // 0x00000002
      uint32_t b = SHIM_MEM_32(arg1 + 4); // out ptr to 4b - expect 0
      XELOGD("XMPGetStatusEx(%.8X, %.8X)", a, b);
      XEASSERTZERO(arg2);
      XEASSERT(a == 2);
      SHIM_SET_MEM_32(b, 0);
      handled = true;
    } else if (message == 0x0007001A) {
      // dcz
      // arg1 = ?
      // arg2 = 0
    } else if (message == 0x0007001B) {
      uint32_t a = SHIM_MEM_32(arg1 + 0); // 0x00000002<commit_msg>Calm some games down that hammer XMPGetStatus.<commit_after>/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 <NAME>. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#include <xenia/kernel/xam_msg.h>

#include <xenia/kernel/kernel_state.h>
#include <xenia/kernel/xam_private.h>
#include <xenia/kernel/util/shim_utils.h>


using namespace xe;
using namespace xe::kernel;
using namespace xe::kernel::xam;


namespace xe {
namespace kernel {


SHIM_CALL XMsgInProcessCall_shim(
    PPCContext* ppc_state, KernelState* state) {
  uint32_t app = SHIM_GET_ARG_32(0);
  uint32_t message = SHIM_GET_ARG_32(1);
  uint32_t arg1 = SHIM_GET_ARG_32(2);
  uint32_t arg2 = SHIM_GET_ARG_32(3);

  XELOGD(
      "XMsgInProcessCall(%.8X, %.8X, %.8X, %.8X)",
      app, message, arg1, arg2);

  bool handled = false;

  // TODO(benvanik): build XMsg pump? async/sync/etc
  if (app == 0xFA) {
    // XMP = music
    // http://freestyledash.googlecode.com/svn-history/r1/trunk/Freestyle/Scenes/Media/Music/ScnMusic.cpp
    if (message == 0x00070009) {
      uint32_t a = SHIM_MEM_32(arg1 + 0); // 0x00000002
      uint32_t b = SHIM_MEM_32(arg1 + 4); // out ptr to 4b - expect 0
      XELOGD("XMPGetStatusEx(%.8X, %.8X)", a, b);
      XEASSERTZERO(arg2);
      XEASSERT(a == 2);
      SHIM_SET_MEM_32(b, 0);
      handled = true;
    } else if (message == 0x0007001A) {
      // dcz
      // arg1 = ?
      // arg2 = 0
    } else if (message == 0x0007001B) {
      // Some stupid games will hammer this on a thread - induce a delay
      // here to keep from starving real threads.
      Sleep(1);
      uint32_t a = SHIM_MEM_32(arg1 + 0); // 0x00000002
{'fraction_non_alphanumeric': 0.2342857142857143, 'fraction_numerical': 0.0574025974025974, 'mean_word_length': 3.1099252934898614, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6786564', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1277, 'n_words': 293}