a2-memory-map 1.0.2

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/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "a2-memory-map",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/dfgordon/a2-memory-map.git"
6
+ },
7
+ "version": "1.0.2",
8
+ "description": "Database of Apple II memory addresses",
9
+ "main": "build/index.js",
10
+ "types": "build/index.d.ts",
11
+ "scripts": {
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "prepublish": "tsc"
14
+ },
15
+ "keywords": [
16
+ "retro",
17
+ "apple"
18
+ ],
19
+ "author": "Daniel Gordon",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/dfgordon/a2-memory-map/issues"
23
+ },
24
+ "homepage": "https://github.com/dfgordon/a2-memory-map#readme",
25
+ "devDependencies": {
26
+ "@types/node": "^18.16.3",
27
+ "rimraf": "^5.0.0",
28
+ "typescript": "^5.0.4"
29
+ },
30
+ "build": "rimraf ./build && tsc"
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ import * as memmap from "./map.json"
2
+
3
+ export interface AddressInfo {
4
+ brief: string | undefined,
5
+ ctx: string | undefined,
6
+ desc: string,
7
+ label: string | undefined,
8
+ note: string | undefined,
9
+ subctx: string | undefined,
10
+ type: string
11
+ }
12
+
13
+ export function get_all(): Map<string, AddressInfo> {
14
+ let m = new Map<string, AddressInfo>();
15
+ for (const [key, obj] of Object.entries(memmap)) {
16
+ m.set(key, {
17
+ brief: 'brief' in obj ? obj.brief : undefined,
18
+ ctx: 'ctx' in obj ? obj.ctx : undefined,
19
+ desc: obj.desc,
20
+ label: 'label' in obj ? obj.label : undefined,
21
+ note: 'note' in obj ? obj.note : undefined,
22
+ subctx: 'subctx' in obj ? obj.subctx : undefined,
23
+ type: obj.type
24
+ });
25
+ }
26
+ return m;
27
+ }
28
+
29
+ export function get_one(addr: number): AddressInfo | undefined {
30
+ let pos_addr = addr < 0 ? addr + 2 ** 16 : addr;
31
+ const hex = '0x' + pos_addr.toString(16).padStart(4, '0');
32
+ return Object(memmap)[hex];
33
+ }