Skip to content

Commit b2ee3f8

Browse files
committed
Updated app to use PyQt5 and virtualenv
1 parent 1b71931 commit b2ee3f8

15 files changed

+425
-120
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ __pycache__/
66
# C extensions
77
*.so
88

9+
# VS Code
10+
.vscode
11+
912
# Distribution / packaging
1013
.Python
1114
env/

CONTRIBUTING.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Contributing to CHIP-8
2+
3+
CHIP-8 is an open source community project, and everyone is welcome to contribute. This short guide will assist you with the workflow required in successfully having your features and bug fixes merged into the project.
4+
5+
# Table of Contents
6+
7+
- [How to Contribute Code](#how-to-contribute-code)
8+
- [Creating a Fork](#creating-a-fork)
9+
- [Keeping Your Fork Up to Date](#keeping-your-fork-up-to-date)
10+
- [Creating a Development Branch](#creating-a-development-branch)
11+
- [Submitting a Pull Request](#submitting-a-pull-request)
12+
- [How to Submit a Bug Report](#how-to-submit-a-bug-report)
13+
14+
## How to Contribute Code
15+
16+
### Creating a Fork
17+
18+
The best approach to contribute code to CHIP-8 is to fork the [main repository](https://github.com/salindersidhu/CHIP8) on GitHub, then submit a pull request.
19+
20+
1. [Create an account](https://github.com/join) on GitHub if you do not have one.
21+
22+
2. Fork the repository by clicking on the 'Fork' button near the top-right section of the page. This creates a copy of the code under your account on GitHub.
23+
24+
3. Clone your fork to your local machine:
25+
26+
```bash
27+
git clone https://github.com/USERNAME/CHIP8.git
28+
29+
# If you have an SSH key setup with GitHub
30+
git clone git@github.com:USERNAME/CHIP8.git
31+
32+
# Navigate to your cloned fork
33+
cd CHIP8
34+
```
35+
36+
### Keeping Your Fork Up to Date
37+
38+
You will want to make sure you keep your fork synced with the original repository by tracking the original "upstream" repository that you forked.
39+
40+
1. Add "upstream" to the list of remotes:
41+
42+
```bash
43+
# You will only need to do this once
44+
git remote add upstream https://github.com/salindersidhu/CHIP8.git
45+
```
46+
47+
2. Fetch the upstream repository's latest commits and branches:
48+
49+
```bash
50+
git fetch upstream
51+
```
52+
53+
3. Checkout the master branch and merge in the changes from the upstream repository's master branch:
54+
55+
```bash
56+
git checkout master
57+
git merge upstream/master
58+
```
59+
60+
### Creating a Development Branch
61+
62+
A new branch is required when working on a new feature or bug fix. This ensures that your changes are kept seperate from the master branch making it easier to manage multiple pull requests for every task you complete.
63+
64+
1. Checkout the master branch as the starting point for the development branch:
65+
66+
```bash
67+
git checkout master
68+
```
69+
70+
2. Create a new development branch on your local machine and switch to it:
71+
72+
```bash
73+
git checkout -b {prefix}/branch-name origin/master
74+
```
75+
76+
_Prefix is either `hotfix`, `feature` or `experiment` depending on the type of development work._
77+
78+
### Submitting a Pull Request
79+
80+
Prior to submitting a pull request, you must ensure that you have rebased your
81+
development branch so that merging it into the original repository is a simple
82+
fast-forward free of merge conflicts.
83+
84+
1. [Ensure that your fork is up to date.](#keeping-your-fork-up-to-date)
85+
86+
2. Rebase your development branch:
87+
88+
```bash
89+
git checkout {prefix}/branch-name
90+
git rebase master
91+
```
92+
93+
Once you have committed and pushed all of your changes on your development branch to GitHub, go to the page for your fork on GitHub, select your development branch and click the pull request button. Once a pull request has been made, you can continue to make changes to the development branch and your pull request will automatically track the changes and update.
94+
95+
## How to Submit a Bug Report
96+
97+
If you find a bug in the code, please submit a ticket to the [Bug Tracker](https://github.com/salindersidhu/CHIP8/issues).
98+
99+
Before submitting your bug report, please ensure that your ticket contains the following:
100+
101+
- A short summary of the bug, typically a couple of sentences.
102+
- A screenshot showing the bug.
103+
- The version of CHIP-8 you are using.

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Salinder Sidhu
3+
Copyright (c) 2020 Salinder Sidhu
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+114-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,112 @@
11
# Python CHIP-8 Interpreter
22

3-
## Description:
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](/LICENSE.md)
4+
5+
# Table of Contents
6+
7+
- [Overview](#overview)
8+
- [Features](#features)
9+
- [Supported Platforms](#supported-platforms)
10+
- [ROMs](#roms)
11+
- [Development](#development)
12+
- [Prerequisites](#prerequisites)
13+
- [Setup](#setup)
14+
- [Running](#running)
15+
- [Controls](#controls)
16+
- [Contributing](#contributing)
17+
- [Codebase](#codebase)
18+
- [Structure](#structure)
19+
20+
## Overview:
21+
422
A Python based GUI implementation of the CHIP-8 system. A project I developed with the intention of gaining knowledge about emulators and cross platform GUI libraries.
523
For more specific information about the CHIP-8 system, please refer to the following technical reference article on [CHIP-8](http://devernay.free.fr/hacks/chip8/C8TECH10.HTM) and the [WIKI](https://en.wikipedia.org/wiki/CHIP-8).
624

7-
<p align='center'>
8-
<img src='https://user-images.githubusercontent.com/12175684/40276001-20feafdc-5bcd-11e8-9565-7f28666f3405.png' alt='Screenshot1'/>
9-
<img src='https://user-images.githubusercontent.com/12175684/40276004-232303ee-5bcd-11e8-89cc-40c9ddbd2e1f.png' alt='Screenshot3'/>
10-
</p>
11-
<p align='center'>
12-
<img src='https://user-images.githubusercontent.com/12175684/40276002-22096caa-5bcd-11e8-95a9-9354ef8b791f.png' alt='Screenshot2'/>
13-
<img src='https://user-images.githubusercontent.com/12175684/40276005-244b9c7c-5bcd-11e8-8d79-7fb4543b6182.png' alt='Screenshot4'/>
14-
</p>
15-
1625
## Features:
26+
1727
- Implementation of all 35 CHIP-8 opcodes
1828
- Custom pixel and background colour rendering
1929
- Saving and loading of emulation state
20-
- Sound effect support
30+
- Sound effects
31+
32+
## Supported Platforms:
2133

22-
## Supports:
23-
- Microsoft Windows 7, 8, 8.1, 10
24-
- Linux based distributions
25-
- Mac OS X
34+
- Windows 10, Mac OS X and Linux based distributions
2635

2736
## ROMs:
28-
ROMs for the CHIP-8 system can be downloaded for free at [Chip8.com](http://www.chip8.com/?page=84) and [Zophar's Domain](http://www.zophar.net/pdroms/chip8.html). In order to load these ROMs with the interpreter, the files must be renamed to have a `.c8` extension.
2937

30-
## Dependencies:
31-
- Python 3 [(Build 3.4)](https://www.python.org/downloads/)
32-
- PyQt 4 [(Build 4.11)](https://riverbankcomputing.com/software/pyqt/download)
38+
ROMs for the CHIP-8 system can be obtained online for free at [Internet Archive](https://archive.org/details/Chip-8RomsThatAreInThePublicDomain). In order to load these ROMs with the interpreter, the files must be renamed to have a `.c8` extension.
39+
40+
# Development
41+
42+
> Information describing how to install and configure all the required tools to begin development.
43+
44+
## Prerequisites:
45+
46+
Ensure that you have the following installed and configured any environment variables.
47+
48+
- **Python**
49+
- Version 3.7.5+
50+
51+
## Setup:
52+
53+
You will need to setup a python virtual environment and install the project's dependencies.
54+
55+
1. Skip this step if you're using Windows. If you're using Mac or Linux, you may need to install `pip` and `virtualenv` first:
3356

34-
## Running the Interpreter:
35-
1. Download and install Python 3
36-
+ Download and install PyQt 4
37-
+ To launch the interpreter, open a terminal or command prompt and type `python3 interpreterapp.py`
38-
+ To load a ROM, ensure that the ROM file has a `.c8` extension
57+
```bash
58+
sudo apt-get install python3-pip
59+
sudo pip3 install virtualenv
60+
```
61+
62+
2. Navigate to your CHIP-8 repo and create a new virtual environment with the following command:
63+
64+
```bash
65+
# Windows
66+
python -m venv venv
67+
68+
# Mac or Linux
69+
virtualenv venv
70+
```
71+
72+
3. Enable your virtual environment with the following command:
73+
74+
```bash
75+
# Windows
76+
source venv/Scripts/activate
77+
78+
# Mac or Linux
79+
source venv/bin/activate
80+
```
81+
82+
Your command line will be prefixed with `(venv)` which indicates that the virtual environment is enabled.
83+
84+
4. Install the project's dependencies with the following command:
85+
86+
```bash
87+
pip install -r requirements.txt
88+
```
89+
90+
## Running:
91+
92+
1. Enable your virtual environment with the following command:
93+
94+
```bash
95+
# Windows
96+
source venv/Scripts/activate
97+
98+
# Mac or Linux
99+
source venv/bin/activate
100+
```
101+
102+
2. Launch the CHIP-8 interpreter app with the following command:
103+
104+
```bash
105+
python interpreterapp.py
106+
```
39107

40108
## Controls:
109+
41110
The CHIP-8 system uses a `hexadecimal keyboard` that has 16 keys from 0 to 9 and A to F. Keys `2`, `4`, `6` and `8` are typically used for directional input.
42111

43112
The following keyboard layouts specify the `CHIP-8 Keyboard` and the `Interpreter KeyBoard` used in the application.
@@ -46,5 +115,24 @@ The following keyboard layouts specify the `CHIP-8 Keyboard` and the `Interprete
46115
<img src='https://user-images.githubusercontent.com/12175684/40276007-26e1efd6-5bcd-11e8-8e4b-b615659797ee.png' alt='Keyboard'/>
47116
</p>
48117

49-
## License:
50-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](/LICENSE.md)
118+
## Contributing
119+
120+
CHIP-8 welcomes contributions from anyone and everyone. Please see our [contributing guide](/CONTRIBUTING.md) for more info.
121+
122+
## Structure
123+
124+
.
125+
├── ...
126+
├── assets # Assets
127+
│ ├── icon.svg # CHIP-8 interpreter window icon
128+
│ └── ...
129+
├── chip8 # CHIP-8 Python package
130+
│ ├── __init__.py # Package init file
131+
│ ├── chip8.py # CHIP-8 CPU logic
132+
│ ├── stack.py # Stack data structure
133+
│ └── ...
134+
├── gridframe.py # PyQt5 frame for rending the CHIP-8 display
135+
├── guiwindow.py # PyQt5 GUI window setup and config
136+
├── interpreterapp.py # Main application
137+
├── requirements.txt # Dependencies to install with pip
138+
└── ...

Resources/icon.png

-20.5 KB
Binary file not shown.

Resources/beep.wav assets/beep.wav

File renamed without changes.

assets/icon.svg

+63
Loading

chip8/__init__.py

Whitespace-only changes.

chip8.py chip8/chip8.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from stack import Stack
1+
from .stack import Stack
22
from binascii import hexlify
33
from random import randint, seed
44

stack.py chip8/stack.py

File renamed without changes.

gridframe.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
from PyQt4 import QtGui, QtCore
1+
from PyQt5 import QtGui, QtCore, QtWidgets
22

33

4-
class GridFrame(QtGui.QFrame):
5-
'''GridFrame extends the QtGui.QFrame class. It is used to draw a custom
6-
grid of pixels to the screen. The pixels are specified in a 2D list where
7-
the active pixels are denoted by 1 and drawn in a specific colour while
8-
pixels denoted by 0 are drawn as the background with another colour.'''
4+
class GridFrame(QtWidgets.QFrame):
5+
'''GridFrame extends the QtWidgets.QFrame class. It is used to draw a
6+
custom grid of pixels to the screen. The pixels are specified in a 2D list
7+
where the active pixels are denoted by 1 and drawn in a specific colour
8+
while pixels denoted by 0 are drawn as the background with another
9+
colour.'''
910

10-
def __init__(self, parentWindow, width, height, pxSize, defaultbgColour,
11+
def __init__(self,
12+
parentWindow,
13+
width,
14+
height,
15+
pxSize,
16+
defaultbgColour,
1117
defaultpxColour):
1218
'''Create a new GridFrame with a specific width, height, pixel size and
1319
default colours used to draw the pixels and background.'''
@@ -70,5 +76,7 @@ def paintEvent(self, event):
7076
color = QtGui.QColor(self.__bgColour[0],
7177
self.__bgColour[1],
7278
self.__bgColour[2])
73-
painter.fillRect(x * self.__pxSize, y * self.__pxSize,
74-
self.__pxSize, self.__pxSize, color)
79+
painter.fillRect(x * self.__pxSize,
80+
y * self.__pxSize,
81+
self.__pxSize,
82+
self.__pxSize, color)

0 commit comments

Comments
 (0)