@andrivet/z80-assembler 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +13 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +35 -0
- package/.github/workflows/node.js.yml +47 -0
- package/.prettierignore +3 -0
- package/.prettierrc +3 -0
- package/.vscode/extensions.json +7 -0
- package/README.md +53 -27
- package/apps/.gitkeep +0 -0
- package/apps/z80-assembler-app/.eslintrc.json +18 -0
- package/apps/z80-assembler-app/index.html +16 -0
- package/apps/z80-assembler-app/postcss.config.js +24 -0
- package/apps/z80-assembler-app/project.json +70 -0
- package/apps/z80-assembler-app/public/favicon.ico +0 -0
- package/apps/z80-assembler-app/public/logo.png +0 -0
- package/apps/z80-assembler-app/public/logo192.png +0 -0
- package/apps/z80-assembler-app/public/logo512.png +0 -0
- package/apps/z80-assembler-app/public/manifest.json +25 -0
- package/apps/z80-assembler-app/public/robots.txt +3 -0
- package/apps/z80-assembler-app/src/app/app.module.css +0 -0
- package/apps/z80-assembler-app/src/app/app.tsx +122 -0
- package/apps/z80-assembler-app/src/app/binary.tsx +39 -0
- package/apps/z80-assembler-app/src/app/editor.tsx +228 -0
- package/apps/z80-assembler-app/src/app/errors.tsx +31 -0
- package/apps/z80-assembler-app/src/app/footer.tsx +20 -0
- package/apps/z80-assembler-app/src/app/header.tsx +57 -0
- package/apps/z80-assembler-app/src/app/misc.ts +13 -0
- package/apps/z80-assembler-app/src/app/opcodes.tsx +335 -0
- package/apps/z80-assembler-app/src/assets/.gitkeep +0 -0
- package/apps/z80-assembler-app/src/assets/images/logo192.png +0 -0
- package/apps/z80-assembler-app/src/main.tsx +22 -0
- package/apps/z80-assembler-app/src/styles.css +8 -0
- package/apps/z80-assembler-app/tailwind.config.js +28 -0
- package/apps/z80-assembler-app/tsconfig.app.json +22 -0
- package/apps/z80-assembler-app/tsconfig.json +21 -0
- package/apps/z80-assembler-app/tsconfig.spec.json +23 -0
- package/apps/z80-assembler-app/vite.config.ts +64 -0
- package/assets/images/compile.png +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/menu.png +0 -0
- package/assets/images/opcodes-load8.png +0 -0
- package/assets/images/opcodes.png +0 -0
- package/assets/images/open-dir.png +0 -0
- package/assets/images/z80-assembler-app.png +0 -0
- package/docs/assembly.md +551 -0
- package/docs/images/ZX81-0x00.png +0 -0
- package/docs/images/ZX81-0x0B.png +0 -0
- package/docs/images/ZX81-0x0C.png +0 -0
- package/docs/images/ZX81-0x0D.png +0 -0
- package/docs/images/ZX81-0x0E.png +0 -0
- package/docs/images/ZX81-0x0F.png +0 -0
- package/docs/images/ZX81-0x10.png +0 -0
- package/docs/images/ZX81-0x11.png +0 -0
- package/docs/images/ZX81-0x12.png +0 -0
- package/docs/images/ZX81-0x13.png +0 -0
- package/docs/images/ZX81-0x14.png +0 -0
- package/docs/images/ZX81-0x15.png +0 -0
- package/docs/images/ZX81-0x16.png +0 -0
- package/docs/images/ZX81-0x17.png +0 -0
- package/docs/images/ZX81-0x18.png +0 -0
- package/docs/images/ZX81-0x19.png +0 -0
- package/docs/images/ZX81-0x1A.png +0 -0
- package/docs/images/ZX81-0x1B.png +0 -0
- package/docs/images/ZX81-0x1C.png +0 -0
- package/docs/images/ZX81-0x1D.png +0 -0
- package/docs/images/ZX81-0x1E.png +0 -0
- package/docs/images/ZX81-0x1F.png +0 -0
- package/docs/images/ZX81-0x20.png +0 -0
- package/docs/images/ZX81-0x21.png +0 -0
- package/docs/images/ZX81-0x22.png +0 -0
- package/docs/images/ZX81-0x23.png +0 -0
- package/docs/images/ZX81-0x24.png +0 -0
- package/docs/images/ZX81-0x25.png +0 -0
- package/docs/images/ZX81-0x26.png +0 -0
- package/docs/images/ZX81-0x27.png +0 -0
- package/docs/images/ZX81-0x28.png +0 -0
- package/docs/images/ZX81-0x29.png +0 -0
- package/docs/images/ZX81-0x2A.png +0 -0
- package/docs/images/ZX81-0x2B.png +0 -0
- package/docs/images/ZX81-0x2C.png +0 -0
- package/docs/images/ZX81-0x2D.png +0 -0
- package/docs/images/ZX81-0x2E.png +0 -0
- package/docs/images/ZX81-0x2F.png +0 -0
- package/docs/images/ZX81-0x30.png +0 -0
- package/docs/images/ZX81-0x31.png +0 -0
- package/docs/images/ZX81-0x32.png +0 -0
- package/docs/images/ZX81-0x33.png +0 -0
- package/docs/images/ZX81-0x34.png +0 -0
- package/docs/images/ZX81-0x35.png +0 -0
- package/docs/images/ZX81-0x36.png +0 -0
- package/docs/images/ZX81-0x37.png +0 -0
- package/docs/images/ZX81-0x38.png +0 -0
- package/docs/images/ZX81-0x39.png +0 -0
- package/docs/images/ZX81-0x3A.png +0 -0
- package/docs/images/ZX81-0x3B.png +0 -0
- package/docs/images/ZX81-0x3C.png +0 -0
- package/docs/images/ZX81-0x3D.png +0 -0
- package/docs/images/ZX81-0x3E.png +0 -0
- package/docs/images/ZX81-0x3F.png +0 -0
- package/docs/images/ZX81-0x80.png +0 -0
- package/docs/images/ZX81-0x8B.png +0 -0
- package/docs/images/ZX81-0x8C.png +0 -0
- package/docs/images/ZX81-0x8D.png +0 -0
- package/docs/images/ZX81-0x8E.png +0 -0
- package/docs/images/ZX81-0x8F.png +0 -0
- package/docs/images/ZX81-0x90.png +0 -0
- package/docs/images/ZX81-0x91.png +0 -0
- package/docs/images/ZX81-0x92.png +0 -0
- package/docs/images/ZX81-0x93.png +0 -0
- package/docs/images/ZX81-0x94.png +0 -0
- package/docs/images/ZX81-0x95.png +0 -0
- package/docs/images/ZX81-0x96.png +0 -0
- package/docs/images/ZX81-0x97.png +0 -0
- package/docs/images/ZX81-0x98.png +0 -0
- package/docs/images/ZX81-0x99.png +0 -0
- package/docs/images/ZX81-0x9A.png +0 -0
- package/docs/images/ZX81-0x9B.png +0 -0
- package/docs/images/ZX81-0x9C.png +0 -0
- package/docs/images/ZX81-0x9D.png +0 -0
- package/docs/images/ZX81-0x9E.png +0 -0
- package/docs/images/ZX81-0x9F.png +0 -0
- package/docs/images/ZX81-0xA0.png +0 -0
- package/docs/images/ZX81-0xA1.png +0 -0
- package/docs/images/ZX81-0xA2.png +0 -0
- package/docs/images/ZX81-0xA3.png +0 -0
- package/docs/images/ZX81-0xA4.png +0 -0
- package/docs/images/ZX81-0xA5.png +0 -0
- package/docs/images/ZX81-0xA6.png +0 -0
- package/docs/images/ZX81-0xA7.png +0 -0
- package/docs/images/ZX81-0xA8.png +0 -0
- package/docs/images/ZX81-0xA9.png +0 -0
- package/docs/images/ZX81-0xAA.png +0 -0
- package/docs/images/ZX81-0xAB.png +0 -0
- package/docs/images/ZX81-0xAC.png +0 -0
- package/docs/images/ZX81-0xAD.png +0 -0
- package/docs/images/ZX81-0xAE.png +0 -0
- package/docs/images/ZX81-0xAF.png +0 -0
- package/docs/images/ZX81-0xB0.png +0 -0
- package/docs/images/ZX81-0xB1.png +0 -0
- package/docs/images/ZX81-0xB2.png +0 -0
- package/docs/images/ZX81-0xB3.png +0 -0
- package/docs/images/ZX81-0xB4.png +0 -0
- package/docs/images/ZX81-0xB5.png +0 -0
- package/docs/images/ZX81-0xB6.png +0 -0
- package/docs/images/ZX81-0xB7.png +0 -0
- package/docs/images/ZX81-0xB8.png +0 -0
- package/docs/images/ZX81-0xB9.png +0 -0
- package/docs/images/ZX81-0xBA.png +0 -0
- package/docs/images/ZX81-0xBB.png +0 -0
- package/docs/images/ZX81-0xBC.png +0 -0
- package/docs/images/ZX81-0xBD.png +0 -0
- package/docs/images/ZX81-0xBE.png +0 -0
- package/docs/images/ZX81-0xBF.png +0 -0
- package/libs/.gitkeep +0 -0
- package/libs/z80-assembler/.eslintrc.json +18 -0
- package/libs/z80-assembler/package.json +20 -0
- package/libs/z80-assembler/project.json +35 -0
- package/libs/z80-assembler/public/README.md +54 -0
- package/{index.d.ts → libs/z80-assembler/src/index.ts} +1 -1
- package/libs/z80-assembler/src/lib/assets/code/basic-end.zx81 +4 -0
- package/libs/z80-assembler/src/lib/assets/code/basic-line1.zx81 +4 -0
- package/libs/z80-assembler/src/lib/assets/code/basic-line2.zx81 +9 -0
- package/libs/z80-assembler/src/lib/assets/code/characters.zx81 +190 -0
- package/libs/z80-assembler/src/lib/assets/code/display.zx81 +50 -0
- package/libs/z80-assembler/src/lib/assets/code/system-variables.zx81 +46 -0
- package/{lib/compiler/Assets.d.ts → libs/z80-assembler/src/lib/compiler/Assets.ts} +6 -1
- package/libs/z80-assembler/src/lib/compiler/Ast.ts +545 -0
- package/libs/z80-assembler/src/lib/compiler/Compiler.test.ts +2141 -0
- package/libs/z80-assembler/src/lib/compiler/Compiler.ts +185 -0
- package/libs/z80-assembler/src/lib/compiler/Formatter.ts +43 -0
- package/libs/z80-assembler/src/lib/compiler/Generator.ts +255 -0
- package/libs/z80-assembler/src/lib/compiler/Labels.ts +165 -0
- package/libs/z80-assembler/src/lib/grammar/LowLevel.ts +163 -0
- package/libs/z80-assembler/src/lib/grammar/Parse.ts +128 -0
- package/libs/z80-assembler/src/lib/grammar/z80.peg +1252 -0
- package/libs/z80-assembler/src/lib/grammar/z80.ts +10649 -0
- package/libs/z80-assembler/src/lib/types/Error.ts +105 -0
- package/{lib/types/Types.d.ts → libs/z80-assembler/src/lib/types/Types.ts} +26 -11
- package/libs/z80-assembler/tsconfig.json +23 -0
- package/libs/z80-assembler/tsconfig.lib.json +10 -0
- package/libs/z80-assembler/tsconfig.spec.json +19 -0
- package/libs/z80-assembler/vite.config.ts +58 -0
- package/nx.json +57 -0
- package/package.json +52 -14
- package/tsconfig.base.json +22 -0
- package/index.js +0 -312
- package/index.mjs +0 -6441
- package/lib/compiler/Ast.d.ts +0 -210
- package/lib/compiler/Compiler.d.ts +0 -53
- package/lib/compiler/Formatter.d.ts +0 -23
- package/lib/compiler/Generator.d.ts +0 -40
- package/lib/compiler/Labels.d.ts +0 -47
- package/lib/grammar/LowLevel.d.ts +0 -68
- package/lib/grammar/Parse.d.ts +0 -48
- package/lib/grammar/z80.d.ts +0 -2938
- package/lib/types/Error.d.ts +0 -62
- /package/{CHANGELOG.md → libs/z80-assembler/public/CHANGELOG.md} +0 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Editor configuration, see http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
max_line_length = off
|
|
13
|
+
trim_trailing_whitespace = false
|
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"ignorePatterns": ["**/*"],
|
|
4
|
+
"plugins": ["@nx"],
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
8
|
+
"rules": {
|
|
9
|
+
"@nx/enforce-module-boundaries": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
"enforceBuildableLibDependency": true,
|
|
13
|
+
"allow": [],
|
|
14
|
+
"depConstraints": [
|
|
15
|
+
{
|
|
16
|
+
"sourceTag": "*",
|
|
17
|
+
"onlyDependOnLibsWithTags": ["*"]
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"files": ["*.ts", "*.tsx"],
|
|
26
|
+
"extends": ["plugin:@nx/typescript"],
|
|
27
|
+
"rules": {}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"files": ["*.js", "*.jsx"],
|
|
31
|
+
"extends": ["plugin:@nx/javascript"],
|
|
32
|
+
"rules": {}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: CD
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [16.x, 18.x, 20.x]
|
|
15
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
cache: 'npm'
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm ci --legacy-peer-deps
|
|
26
|
+
- name: Build
|
|
27
|
+
run: npx nx build z80-assembler-app --prod --baseHref=/z80-assembler/
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: npx nx test z80-assembler
|
|
30
|
+
- name: Upload artifact
|
|
31
|
+
uses: actions/upload-pages-artifact@v1
|
|
32
|
+
with:
|
|
33
|
+
path: dist/apps/z80-assembler-app
|
|
34
|
+
|
|
35
|
+
deploy:
|
|
36
|
+
needs: build
|
|
37
|
+
permissions:
|
|
38
|
+
pages: write
|
|
39
|
+
id-token: write
|
|
40
|
+
environment:
|
|
41
|
+
name: github-pages
|
|
42
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
steps:
|
|
45
|
+
- name: Deploy to GitHub Pages
|
|
46
|
+
id: deployment
|
|
47
|
+
uses: actions/deploy-pages@v2
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -1,53 +1,79 @@
|
|
|
1
1
|
# z80-assembler
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It optimized for the old ZX81 computer but can also be used with any other Z80 targets.
|
|
3
|
+

|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
A Z80 assembler entirely written in Typescript and derived from a PEG grammar.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Components
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
* The first component is the library itself, `z80-assembler` that can be used like any npm library.
|
|
10
|
+
* The second component is an application, `z80-assembler-app` that uses this library.
|
|
11
|
+
It can be used by itself or as an example of how to use the library. It is written in Typescript with React.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
This assembler is also used in the [ZX81 Debugger](https://github.com/andrivet/ZX81-Debugger).
|
|
16
|
+
|
|
17
|
+
## How to build from source
|
|
13
18
|
|
|
14
19
|
```
|
|
15
|
-
|
|
20
|
+
npm --legacy-peer-deps install
|
|
21
|
+
./node_modules/.bin/nx run z80-assembler-app:build:production
|
|
16
22
|
```
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
Notes:
|
|
19
25
|
|
|
20
|
-
* the
|
|
21
|
-
|
|
22
|
-
* a function used to return the content of included files
|
|
26
|
+
* For the moment, you have to use `--legacy-peer-deps` because react-daisyui is not yet updated for DaisyUI 3.
|
|
27
|
+
Once it is the case, this flag will no more be necessary.
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
* If you have installed NX globally, you do not need to specify its path.
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
* `bytes`: A array of numbers. Each element represents a byte of the generated machine code.
|
|
28
|
-
* `sld`: The Source Level Debugging data as a string. This is used in order to debug the code.
|
|
29
|
-
* `errs`: An array of errors
|
|
30
|
-
|
|
31
|
-
A typical way to use the function is:
|
|
31
|
+
## How to run the application
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
|
|
35
|
-
if(info.errs.length > 0)
|
|
36
|
-
displayErrors(info.errs);
|
|
37
|
-
else
|
|
38
|
-
saveOutput(info.outputName, info.bytes);
|
|
34
|
+
nx run z80-assembler-app:dev:production
|
|
39
35
|
```
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
Open a navigator at the URL http://localhost:4200/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Quick guide to use the application
|
|
41
|
+
|
|
42
|
+
Under the **File** menu, you find the following commands:
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
* **Open Code**: Open a Z80 source file.
|
|
47
|
+
* **Open Code Directory**: Open a directory with Z80 source files. This is especially useful if your source files contain includes.
|
|
48
|
+
* **Save Code**: Save the current code file.
|
|
49
|
+
* **Save Binary**: Save the compiled binary.
|
|
50
|
+
* **Save SLD File**: Save the Source Level Debugging data in text format.
|
|
51
|
+
* **Close Code**: Close the current code.
|
|
52
|
+
* **Close All**: Close all the open codes.
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
Once one or more files are open, click on Compile to compile the code.
|
|
57
|
+
The binary are displayed on the right side:
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
While writing your Z80 assembly code, you can display the list of Z80 opcodes by clicking on **Z80 Opcodes**:
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
Click on a category to see the corresponding opcodes:
|
|
66
|
+
|
|
67
|
+

|
|
42
68
|
|
|
69
|
+
## Z80 assembly
|
|
43
70
|
|
|
44
|
-
|
|
71
|
+
The format of assembly source file is described in [Z80 Assembly Source Code Format](./docs/assembly.md).
|
|
45
72
|
|
|
46
|
-
The source code is published on GitHub: https://github.com/andrivet/z80-assembler/.
|
|
47
73
|
|
|
48
74
|
## Licence
|
|
49
75
|
|
|
50
|
-
This library and
|
|
76
|
+
This library and application are released under GPLv3.
|
|
51
77
|
|
|
52
78
|
## Copyrights
|
|
53
79
|
|
package/apps/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Z80 Assembler in Typescript</title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
10
|
+
<link rel="stylesheet" href="/src/styles.css" />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div id="root"></div>
|
|
14
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z80 Assembler in Typescript
|
|
3
|
+
*
|
|
4
|
+
* File: postcss.config.js
|
|
5
|
+
* Description: Configuration for PostCSS
|
|
6
|
+
* Author: Sebastien Andrivet
|
|
7
|
+
* License: GPLv3
|
|
8
|
+
* Copyrights: Copyright (C) 2023 Sebastien Andrivet
|
|
9
|
+
*/
|
|
10
|
+
const { join } = require('path');
|
|
11
|
+
|
|
12
|
+
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
|
|
13
|
+
// option from your application's configuration (i.e. project.json).
|
|
14
|
+
//
|
|
15
|
+
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
plugins: {
|
|
19
|
+
tailwindcss: {
|
|
20
|
+
config: join(__dirname, 'tailwind.config.js'),
|
|
21
|
+
},
|
|
22
|
+
autoprefixer: {},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "z80-assembler-app",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "apps/z80-assembler-app/src",
|
|
5
|
+
"projectType": "application",
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "@nx/vite:build",
|
|
9
|
+
"outputs": ["{options.outputPath}"],
|
|
10
|
+
"defaultConfiguration": "production",
|
|
11
|
+
"options": {
|
|
12
|
+
"outputPath": "dist/apps/z80-assembler-app"
|
|
13
|
+
},
|
|
14
|
+
"configurations": {
|
|
15
|
+
"development": {
|
|
16
|
+
"mode": "development"
|
|
17
|
+
},
|
|
18
|
+
"production": {
|
|
19
|
+
"mode": "production"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"dev": {
|
|
24
|
+
"executor": "@nx/vite:dev-server",
|
|
25
|
+
"defaultConfiguration": "development",
|
|
26
|
+
"options": {
|
|
27
|
+
"buildTarget": "z80-assembler-app:build"
|
|
28
|
+
},
|
|
29
|
+
"configurations": {
|
|
30
|
+
"development": {
|
|
31
|
+
"buildTarget": "z80-assembler-app:build:development",
|
|
32
|
+
"hmr": true
|
|
33
|
+
},
|
|
34
|
+
"production": {
|
|
35
|
+
"buildTarget": "z80-assembler-app:build:production",
|
|
36
|
+
"hmr": false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"preview": {
|
|
41
|
+
"executor": "@nx/vite:preview-server",
|
|
42
|
+
"defaultConfiguration": "development",
|
|
43
|
+
"options": {
|
|
44
|
+
"buildTarget": "z80-assembler-app:build"
|
|
45
|
+
},
|
|
46
|
+
"configurations": {
|
|
47
|
+
"development": {
|
|
48
|
+
"buildTarget": "z80-assembler-app:build:development"
|
|
49
|
+
},
|
|
50
|
+
"production": {
|
|
51
|
+
"buildTarget": "z80-assembler-app:build:production"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"lint": {
|
|
56
|
+
"executor": "@nx/linter:eslint",
|
|
57
|
+
"outputs": ["{options.outputFile}"],
|
|
58
|
+
"options": {
|
|
59
|
+
"lintFilePatterns": ["apps/z80-assembler-app/**/*.{ts,tsx,js,jsx}"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"serve-static": {
|
|
63
|
+
"executor": "@nx/web:file-server",
|
|
64
|
+
"options": {
|
|
65
|
+
"buildTarget": "z80-assembler-app:build"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"tags": []
|
|
70
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z80 Assembler in Typescript
|
|
3
|
+
*
|
|
4
|
+
* File: app.tsx
|
|
5
|
+
* Description: Application view
|
|
6
|
+
* Author: Sebastien Andrivet
|
|
7
|
+
* License: GPLv3
|
|
8
|
+
* Copyrights: Copyright (C) 2023 Sebastien Andrivet
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
import styles from './app.module.css';
|
|
13
|
+
|
|
14
|
+
import React, {useRef, useState} from 'react';
|
|
15
|
+
import {AppOpcodes} from "./opcodes";
|
|
16
|
+
import {Chunk, CompilationError, compile, formatBytes} from "@andrivet/z80-assembler";
|
|
17
|
+
import AppFooter from "./footer";
|
|
18
|
+
import AppHeader from "./header";
|
|
19
|
+
import AppBinary from "./binary";
|
|
20
|
+
import AppEditor, {AppEditorHandlers} from "./editor";
|
|
21
|
+
import Errors from "./errors";
|
|
22
|
+
import {closeDropdown} from "./misc";
|
|
23
|
+
import {fileSave} from "browser-fs-access";
|
|
24
|
+
|
|
25
|
+
interface BinaryOrOpCodesProps {
|
|
26
|
+
showOpCodes: boolean,
|
|
27
|
+
chunks: Chunk[] | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function BinaryOrOpCodes({showOpCodes, chunks}: BinaryOrOpCodesProps) {
|
|
31
|
+
return showOpCodes ? <AppOpcodes /> : <AppBinary chunks={chunks} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function App() {
|
|
35
|
+
const [code, setCode] = useState<string>('');
|
|
36
|
+
const [filepath, setFilepath] = useState<string>('');
|
|
37
|
+
const [errors, setErrors] = useState<CompilationError[] | undefined>();
|
|
38
|
+
const [bytes, setBytes] = useState<number[] | undefined>();
|
|
39
|
+
const [sld, setSld] = useState<string>('');
|
|
40
|
+
const [chunks, setChunks] = useState<Chunk[] | undefined>();
|
|
41
|
+
const [showOpCodes, setShowOpCodes] = useState<boolean>(false);
|
|
42
|
+
const [outputName, setOutputName] = useState<string | undefined>(undefined);
|
|
43
|
+
const ref = useRef<AppEditorHandlers>(null);
|
|
44
|
+
|
|
45
|
+
function handleGetFileCode(filename: string): string {
|
|
46
|
+
if(ref.current == null) throw new Error(`Invalid reference to the editor`);
|
|
47
|
+
return ref.current.getCode(filename);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function handleCompile() {
|
|
51
|
+
const info = compile(filepath, code, handleGetFileCode);
|
|
52
|
+
if(info.errs.length > 0) {
|
|
53
|
+
setBytes([]);
|
|
54
|
+
setSld('');
|
|
55
|
+
setChunks([]);
|
|
56
|
+
setErrors(info.errs);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
setShowOpCodes(false);
|
|
60
|
+
setOutputName(info.outputName);
|
|
61
|
+
setBytes(info.bytes);
|
|
62
|
+
setSld(info.sld);
|
|
63
|
+
setChunks(formatBytes(info.bytes, 16));
|
|
64
|
+
setErrors([]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function handleSaveBinary() {
|
|
69
|
+
closeDropdown();
|
|
70
|
+
if (!bytes || !outputName) return;
|
|
71
|
+
const data = Uint8Array.from(bytes);
|
|
72
|
+
const blob = new Blob([data]);
|
|
73
|
+
await fileSave(blob, {
|
|
74
|
+
fileName: outputName,
|
|
75
|
+
extensions: ['.P']
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function handleSaveSld() {
|
|
80
|
+
closeDropdown();
|
|
81
|
+
if (sld.length <= 0 || !outputName) return;
|
|
82
|
+
const blob = new Blob([sld]);
|
|
83
|
+
await fileSave(blob, {
|
|
84
|
+
fileName: outputName.replace(/\.P$/, ''),
|
|
85
|
+
extensions: ['.sld']
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div className="flex flex-col h-screen bg-neutral-600">
|
|
91
|
+
<AppHeader
|
|
92
|
+
onOpenCode={() => ref.current?.openCode()}
|
|
93
|
+
onOpenCodeDirectory={() => ref.current?.openCodeDirectory()}
|
|
94
|
+
onSaveCode={() => ref.current?.saveCode()}
|
|
95
|
+
onSaveBinary={handleSaveBinary}
|
|
96
|
+
onSaveSld={handleSaveSld}
|
|
97
|
+
onClose={() => ref.current?.closeCode()}
|
|
98
|
+
onCloseAll={() => ref.current?.closeAll()}
|
|
99
|
+
onCompile={handleCompile}
|
|
100
|
+
onShowOpCodes={() => setShowOpCodes(true)}
|
|
101
|
+
/>
|
|
102
|
+
<div className="flex-1 flex m-4 gap-4">
|
|
103
|
+
<div className="flex flex-col w-2/3">
|
|
104
|
+
<AppEditor
|
|
105
|
+
ref={ref}
|
|
106
|
+
code={code}
|
|
107
|
+
setFilePath={setFilepath}
|
|
108
|
+
setCode={setCode}
|
|
109
|
+
errors={errors}
|
|
110
|
+
setErrors={setErrors} />
|
|
111
|
+
</div>
|
|
112
|
+
<div className="flex flex-col w-1/3 z-0">
|
|
113
|
+
<BinaryOrOpCodes showOpCodes={showOpCodes} chunks={chunks}/>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<Errors errors={errors} />
|
|
117
|
+
<AppFooter />
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default App;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z80 Assembler in Typescript
|
|
3
|
+
*
|
|
4
|
+
* File: binary,tsx
|
|
5
|
+
* Description: Binary view
|
|
6
|
+
* Author: Sebastien Andrivet
|
|
7
|
+
* License: GPLv3
|
|
8
|
+
* Copyrights: Copyright (C) 2023 Sebastien Andrivet
|
|
9
|
+
*/
|
|
10
|
+
import React from "react";
|
|
11
|
+
import {Table} from "react-daisyui";
|
|
12
|
+
import {Chunk} from "@andrivet/z80-assembler";
|
|
13
|
+
|
|
14
|
+
interface AppBinaryProps {
|
|
15
|
+
chunks: Chunk[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function AppBinary({chunks}: AppBinaryProps) {
|
|
19
|
+
return (chunks == null || chunks.length <= 0) ? null : (
|
|
20
|
+
<>
|
|
21
|
+
<h1 className="font-bold mb-2 text-orange-400">Machine Code</h1>
|
|
22
|
+
<div className="flex flex-auto h-full relative mt-0">
|
|
23
|
+
<div className="absolute top-0 bottom-0 left-0 right-0 overflow-auto">
|
|
24
|
+
<Table zebra={true}>
|
|
25
|
+
<Table.Head>{['Address', 'Bytes']}</Table.Head>
|
|
26
|
+
<Table.Body>
|
|
27
|
+
{chunks?.map((data, index) => (
|
|
28
|
+
<Table.Row key={data.address} className="font-mono">{[
|
|
29
|
+
<strong key={`addr-${data.address}`} className="text-orange-400">{data.address}</strong>,
|
|
30
|
+
<span key={`data-${data.address}`} >{data.bytes}</span>
|
|
31
|
+
]}</Table.Row>
|
|
32
|
+
))}
|
|
33
|
+
</Table.Body>
|
|
34
|
+
</Table>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|