Skip to content

Commit

Permalink
Electron: Add electron support
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMo1 committed Jun 25, 2023
1 parent 0140c06 commit 7b68b15
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/

*.lock
out/
71 changes: 58 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,52 @@ This project is a software emulator for Zeal 8-bit Computer: a homebrew 8-bit co

## Why this project?

The goal of this project is to reproduce the exact same behavior of the real machine, in order to be able to execute and mainly **debug** the programs written for it directly from a host computer, without the need to flash any EEPROM or NOR Flash in order to test it. This makes development and test cycles much faster and more convenient.
The goal of this project is to reproduce the exact same behavior of the real machine, in order to be able to execute and mainly **debug** the programs written for it directly from a host computer, without the need to flash any EEPROM or NOR Flash in order to test it. This makes development and test cycles much faster and more convenient.

## How to start it with electron?

##### Import

Use electron import script:

Yarn:

```
yarn add --dev @electron-forge/cli
yarn electron-forge import
```

Npm:

```
cd my-app
npm install --save-dev @electron-forge/cli
npm exec --package=@electron-forge/cli -c "electron-forge import"
```

If it doesn't work, you can find some information at [here.](https://www.electronforge.io/import-existing-project)

##### Run

Yarn:

```
Yarn start
```

Npm:

```
npm start
```

For more informations, check for [Get Started - Electron forge](https://www.electronforge.io/).

## Why a web-based emulator ? (HTML/CSS/JavaScript)

The main goal is to integrate this emulator as part of [zeal8bit.com](https://zeal8bit.com) website. Thus, choosing HTML/CSS and Javascript was a bit obvious on this side.

On the other side, another goal of this project is also to let anybody test or write programs for Zeal 8-bit Computer on any platform (Linux/Windows/Mac OS X) without the need of a toolchain installed.
On the other side, another goal of this project is also to let anybody test or write programs for Zeal 8-bit Computer on any platform (Linux/Windows/Mac OS X) without the need of a toolchain installed.

The emulator has been tested on Opera and Google Chrome.

Expand All @@ -28,11 +67,12 @@ The emulator is slower than the real hardware, even though the real hardware is

Moreover, the emulator is not really accurate it terms of timings, more details below, in the *features* section.

Writing a native emulator in **C** (w/ SDL) would cover the requirement of a full-speed emulator, which would be more accurate in terms of timings. However, this needs some time investment. Feel free to contact me or contribute if such project interest you.
Writing a native emulator in **C** (w/ SDL) would cover the requirement of a full-speed emulator, which would be more accurate in terms of timings. However, this needs some time investment. Feel free to contact me or contribute if such project interest you.

## Features

Currently, the following features from Zeal 8-bit Computer are emulated:

* Z80 CPU ([thanks to *Molly Howell*](https://github.com/DrGoldfire/Z80.js))
* Z80 PIO: all modes supported, both port A and B. Implementation is independent from connected devices.
* 22-bit MMU
Expand All @@ -45,6 +85,7 @@ Currently, the following features from Zeal 8-bit Computer are emulated:
* I2C RTC: always returns the current date

Features of the emulator itself implemented:

* Debugger: breakpoints, step, step over instruction, continue until next breakpoint
* Load a binary file, loaded into ROM directly
* Load a dump file generated from `z88dk-dis` to view assembly code while doing step by step debugging
Expand All @@ -55,10 +96,11 @@ Features of the emulator itself implemented:
## TODO

Of course a lot of things are still remaining to do. On the emulation side:
* <s>PIO: complete the implementation for the user port (A) to act as a regular GPIO, and system port (port B) to activate/deactivate the interrupts, the H-blank, V-blank, I2C, UART, etc...</s> (Done, PIO is now a regular GPIO component, separated from connected components)
* <s>UART emulation (needs PIO port B)</s> (<s>Done, it is possible to read and write characters, baudrates are hardcoded at the moment. Would be interesting to be able to send a file through UART</s> Done)
* <s>I2C RTC (needs PIO port B)</s> (Partially implemented: it always returns the current browser date, so writing to it will have no effect)
* I2C 32KB EEPROM emulation <s>(needs PIO port B)</s>

* `<s>`PIO: complete the implementation for the user port (A) to act as a regular GPIO, and system port (port B) to activate/deactivate the interrupts, the H-blank, V-blank, I2C, UART, etc...`</s>` (Done, PIO is now a regular GPIO component, separated from connected components)
* `<s>`UART emulation (needs PIO port B)`</s>` (`<s>`Done, it is possible to read and write characters, baudrates are hardcoded at the moment. Would be interesting to be able to send a file through UART`</s>` Done)
* `<s>`I2C RTC (needs PIO port B)`</s>` (Partially implemented: it always returns the current browser date, so writing to it will have no effect)
* I2C 32KB EEPROM emulation `<s>`(needs PIO port B)`</s>`
* Sound support¹
* SD Card emulation²
* Video chip: 320x240 text mode, 320x240 graphic mode², sprites², 4-bit palettes², etc...
Expand All @@ -67,8 +109,8 @@ Of course a lot of things are still remaining to do. On the emulation side:

²: features **not** in high priority as they have not been implemented on real hardware yet.


On the project/debugger side itself:

* A better **interface** for the debugger's buttons, with some shortcuts
* A better way to **parse breakpoint input**. A know bug is providing a label starting hex letters would be interpreted as a PC value instead of a label. For example, inputting *date_routine* as a label to break in would result in the addition of a breakpoint at address 0xda instead of the address of label *date_routine* (because *date* starts with hex letters *da*)
* **Refactoring**. Some part of the code, mainly in `zeal.js` are a bit dirty in the sense that several different things are managed by this file: breakpoints, disassembly view, memory viewer, Zeal emulation, etc... It should be cleaned and split up between multiple files.
Expand All @@ -82,20 +124,23 @@ Anyone can contribute to this project, contributions are welcome!
Feel free to fix any bug that you may see or encounter, implement any feature that is present in the TODO list or a new one that you find useful or important.

To contribute:
* Fork the Project
* Create your feature Branch (*optional*)
* Commit your changes. Please make a clear and concise commit message (*)
* Push to the branch
* Open a Pull Request

* Fork the Project
* Create your feature Branch (*optional*)
* Commit your changes. Please make a clear and concise commit message (*)
* Push to the branch
* Open a Pull Request

(*) A good commit message is as follow:

```
Module: add/fix/remove a from b
Explanation on what/how/why
```

For example:

```
Video chip: implement 320x240 text-mode
Expand Down
30 changes: 30 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
],
};
47 changes: 47 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}

const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
});

// and load the index.html of the app.
mainWindow.loadFile(path.join(__dirname, 'index.html'));

};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "zealwebemulator",
"productName": "Zeal-WebEmulator",
"version": "1.0.0",
"description": "A emulator for Zeal 8-bit Computer based on electron",
"main": "index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "Zeal8bit",
"email": "[email protected]"
},
"license": "Apache",
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.2.1",
"@electron-forge/maker-deb": "^6.2.1",
"@electron-forge/maker-rpm": "^6.2.1",
"@electron-forge/maker-squirrel": "^6.2.1",
"@electron-forge/maker-zip": "^6.2.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"electron": "25.2.0",
"electron-squirrel-startup": "^1.0.0"
}
}
Empty file added preload.js
Empty file.

0 comments on commit 7b68b15

Please sign in to comment.