Skip to content

Commit

Permalink
Add auto formatting and reduce pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abaire authored and mborgerson committed Feb 24, 2022
1 parent 3afc220 commit 4f40021
Show file tree
Hide file tree
Showing 8 changed files with 1,591 additions and 1,238 deletions.
40 changes: 40 additions & 0 deletions KickFIFO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Manages the kick_fifo.asm patch."""

# pylint: disable=consider-using-f-string
# pylint: disable=too-few-public-methods

import struct
import XboxHelper


class _KickFIFO:
"""Manages the kick_fifo.asm patch."""

def __init__(self, verbose=True):
self.kick_fifo_addr = None
self.verbose = verbose

def _install_kicker(self, xbox):
if self.kick_fifo_addr is not None:
return

with open("kick_fifo", "rb") as patch_file:
data = patch_file.read()

self.kick_fifo_addr = XboxHelper.load_binary(xbox, data)
if self.verbose:
print("kick_fifo installed at 0x%08X" % self.kick_fifo_addr)

def call(self, xbox, expected_put):
"""Calls the kicker with the given argument."""
self._install_kicker(xbox)
eax = xbox.call(self.kick_fifo_addr, struct.pack("<L", expected_put))["eax"]
assert eax != 0xBADBAD


_kicker = _KickFIFO()


def kick(xbox, expected_put):
"""Calls the kicker with the given argument."""
_kicker.call(xbox, expected_put)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ It will automatically start tracing.
**This tool may also (temporarily) corrupt the state of your Xbox.**
If this tool does not work, please retry a couple of times.

### Contributing

This project uses [Black](https://pypi.org/project/black/) for automatic formatting.
You can use the pre-commit in the `githooks` directory to reformat any changes on commit
or run the tool manually prior to creating a PR. In cases where you feel readability is
significantly better with manual formatting, you may surround the code with
`# fmt: off` / `# fmt: on` comments, but this should be a rare exception.

---

**(C) 2018 XboxDev maintainers**
Expand Down
Loading

0 comments on commit 4f40021

Please sign in to comment.