amigent 1.3.0__tar.gz → 1.4.0__tar.gz

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.
Files changed (134) hide show
  1. {amigent-1.3.0/src/amigent.egg-info → amigent-1.4.0}/PKG-INFO +50 -2
  2. {amigent-1.3.0 → amigent-1.4.0}/README.md +48 -1
  3. {amigent-1.3.0 → amigent-1.4.0}/pyproject.toml +2 -2
  4. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/__init__.py +1 -1
  5. amigent-1.4.0/src/amigent/alerts.py +154 -0
  6. amigent-1.4.0/src/amigent/amiga/Amigent.guide.info +0 -0
  7. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/amigent-update.rexx +2 -1
  8. amigent-1.4.0/src/amigent/amiga/bin/amigent-monitor +0 -0
  9. amigent-1.4.0/src/amigent/amiga/bin/amigentd +0 -0
  10. amigent-1.4.0/src/amigent/amiga/bin/amigentd.000 +0 -0
  11. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amigentd.py +62 -19
  12. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/channel.py +96 -2
  13. amigent-1.4.0/src/amigent/chipset.py +86 -0
  14. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/doctor.py +35 -0
  15. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/fleet.py +47 -0
  16. amigent-1.4.0/src/amigent/gdb.py +218 -0
  17. amigent-1.4.0/src/amigent/journal.py +64 -0
  18. amigent-1.4.0/src/amigent/lvo.json +1 -0
  19. amigent-1.4.0/src/amigent/memory.py +520 -0
  20. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/others.py +15 -1
  21. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/pack.py +98 -18
  22. amigent-1.4.0/src/amigent/probes.py +102 -0
  23. amigent-1.4.0/src/amigent/project.py +115 -0
  24. amigent-1.4.0/src/amigent/screendiff.py +57 -0
  25. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/server.py +1022 -33
  26. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/setup.py +3 -1
  27. amigent-1.4.0/src/amigent/states.py +80 -0
  28. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/system.py +11 -0
  29. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/uptime.py +28 -5
  30. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/viewer.py +46 -4
  31. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/index.html +1 -1
  32. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/viewer.css +2 -0
  33. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/viewer.js +8 -0
  34. {amigent-1.3.0 → amigent-1.4.0/src/amigent.egg-info}/PKG-INFO +50 -2
  35. {amigent-1.3.0 → amigent-1.4.0}/src/amigent.egg-info/SOURCES.txt +13 -0
  36. {amigent-1.3.0 → amigent-1.4.0}/src/amigent.egg-info/requires.txt +1 -0
  37. {amigent-1.3.0 → amigent-1.4.0}/tests/test_others.py +17 -1
  38. {amigent-1.3.0 → amigent-1.4.0}/tests/test_screenfeed.py +9 -1
  39. {amigent-1.3.0 → amigent-1.4.0}/tests/test_v13.py +113 -0
  40. amigent-1.4.0/tests/test_v14.py +389 -0
  41. amigent-1.4.0/tests/test_v14_probes.py +112 -0
  42. {amigent-1.3.0 → amigent-1.4.0}/tests/test_viewer.py +88 -1
  43. amigent-1.3.0/src/amigent/amiga/bin/amigent-monitor +0 -0
  44. amigent-1.3.0/src/amigent/amiga/bin/amigentd +0 -0
  45. amigent-1.3.0/src/amigent/amiga/bin/amigentd.000 +0 -0
  46. {amigent-1.3.0 → amigent-1.4.0}/LICENSE +0 -0
  47. {amigent-1.3.0 → amigent-1.4.0}/setup.cfg +0 -0
  48. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/adf.py +0 -0
  49. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/Amigent-Update +0 -0
  50. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/Amigent-Update.info +0 -0
  51. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/amigent-repair +0 -0
  52. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/amigent-repair.info +0 -0
  53. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/amigent-scan +0 -0
  54. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/bin/Amigent.info +0 -0
  55. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/bin/amigent-monitor.info +0 -0
  56. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/bin/amigent-status +0 -0
  57. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/bin/amigent-status.info +0 -0
  58. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/bin/amigentd.info +0 -0
  59. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amiga/menu-add.rexx +0 -0
  60. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/amigactl.py +0 -0
  61. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/aminet.py +0 -0
  62. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/client.py +0 -0
  63. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/desktop.py +0 -0
  64. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/errors.py +0 -0
  65. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/files.py +0 -0
  66. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/follow.py +0 -0
  67. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/install.py +0 -0
  68. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/inventory.py +0 -0
  69. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/legacy.py +0 -0
  70. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/locks.py +0 -0
  71. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/lzh.py +0 -0
  72. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/machines.py +0 -0
  73. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/macos/Amigent.swift +0 -0
  74. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/macos/Amigent.zip +0 -0
  75. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/net.py +0 -0
  76. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/notes.py +0 -0
  77. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/paths.py +0 -0
  78. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/pictures.py +0 -0
  79. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/planar.py +0 -0
  80. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/platform_util.py +0 -0
  81. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/power.py +0 -0
  82. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/roster.py +0 -0
  83. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/screenfeed.py +0 -0
  84. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/screentext.py +0 -0
  85. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/secret.py +0 -0
  86. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/serve.py +0 -0
  87. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/tls.py +0 -0
  88. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/transfer.py +0 -0
  89. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/watch.py +0 -0
  90. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/amigent.icns +0 -0
  91. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/amigent.ico +0 -0
  92. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/fleet.css +0 -0
  93. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/fleet.html +0 -0
  94. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/fleet.js +0 -0
  95. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/icon.png +0 -0
  96. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/icon.svg +0 -0
  97. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/cs.json +0 -0
  98. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/da.json +0 -0
  99. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/de.json +0 -0
  100. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/en.json +0 -0
  101. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/es.json +0 -0
  102. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/fi.json +0 -0
  103. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/fr.json +0 -0
  104. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/hu.json +0 -0
  105. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/it.json +0 -0
  106. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/pl.json +0 -0
  107. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/sk.json +0 -0
  108. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/web/locales/sv.json +0 -0
  109. {amigent-1.3.0 → amigent-1.4.0}/src/amigent/webserver.py +0 -0
  110. {amigent-1.3.0 → amigent-1.4.0}/src/amigent.egg-info/dependency_links.txt +0 -0
  111. {amigent-1.3.0 → amigent-1.4.0}/src/amigent.egg-info/entry_points.txt +0 -0
  112. {amigent-1.3.0 → amigent-1.4.0}/src/amigent.egg-info/top_level.txt +0 -0
  113. {amigent-1.3.0 → amigent-1.4.0}/tests/test_adf.py +0 -0
  114. {amigent-1.3.0 → amigent-1.4.0}/tests/test_amigactl.py +0 -0
  115. {amigent-1.3.0 → amigent-1.4.0}/tests/test_amigentd.py +0 -0
  116. {amigent-1.3.0 → amigent-1.4.0}/tests/test_channel.py +0 -0
  117. {amigent-1.3.0 → amigent-1.4.0}/tests/test_deflate_c.py +0 -0
  118. {amigent-1.3.0 → amigent-1.4.0}/tests/test_errors.py +0 -0
  119. {amigent-1.3.0 → amigent-1.4.0}/tests/test_fast.py +0 -0
  120. {amigent-1.3.0 → amigent-1.4.0}/tests/test_fleet.py +0 -0
  121. {amigent-1.3.0 → amigent-1.4.0}/tests/test_follow.py +0 -0
  122. {amigent-1.3.0 → amigent-1.4.0}/tests/test_hold.py +0 -0
  123. {amigent-1.3.0 → amigent-1.4.0}/tests/test_inventory.py +0 -0
  124. {amigent-1.3.0 → amigent-1.4.0}/tests/test_lzh.py +0 -0
  125. {amigent-1.3.0 → amigent-1.4.0}/tests/test_machines.py +0 -0
  126. {amigent-1.3.0 → amigent-1.4.0}/tests/test_net.py +0 -0
  127. {amigent-1.3.0 → amigent-1.4.0}/tests/test_outdated_pc.py +0 -0
  128. {amigent-1.3.0 → amigent-1.4.0}/tests/test_pause.py +0 -0
  129. {amigent-1.3.0 → amigent-1.4.0}/tests/test_planar.py +0 -0
  130. {amigent-1.3.0 → amigent-1.4.0}/tests/test_power.py +0 -0
  131. {amigent-1.3.0 → amigent-1.4.0}/tests/test_protocol2.py +0 -0
  132. {amigent-1.3.0 → amigent-1.4.0}/tests/test_secret.py +0 -0
  133. {amigent-1.3.0 → amigent-1.4.0}/tests/test_unpack_safety.py +0 -0
  134. {amigent-1.3.0 → amigent-1.4.0}/tests/test_update.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amigent
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Complete remote control for a real Amiga, by AI or manually, tuned for slow Amigas and slow networks
5
5
  Author: Andreas Wendorf (Akustikrausch)
6
6
  License-Expression: MIT
@@ -24,6 +24,7 @@ Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: mcp<2,>=1.2
26
26
  Requires-Dist: pillow>=10
27
+ Requires-Dist: capstone>=5
27
28
  Dynamic: license-file
28
29
 
29
30
  ```
@@ -40,7 +41,27 @@ Dynamic: license-file
40
41
 
41
42
  <p align="center"><img src="https://raw.githubusercontent.com/akustikrausch/amigent/main/src/amigent/web/icon.png" width="96" alt="Amigent icon"></p>
42
43
 
43
- Amigent connects your PC or Mac to your real Amiga over the home network. Then you can:
44
+ Amigent connects your PC or Mac to your real Amiga over the home network.
45
+
46
+ ## Set up in three steps
47
+
48
+ **1. On the Amiga:** copy [`amigentd`](https://github.com/akustikrausch/amigent/blob/main/src/amigent/amiga/bin/amigentd)
49
+ over (`amigentd.000` on a 68000) and start it with `amigentd SETUP` in a Shell.
50
+
51
+ **2. On the PC or Mac:** paste this into your AI agent:
52
+
53
+ Install Amigent for me: run "pipx install amigent", then amigent-setup,
54
+ register the MCP server "amigent" with the command amigent-server, and
55
+ run amigent-viewer --install.
56
+
57
+ **3. Ask for something:** "Open the remote desktop", or "Install the newest
58
+ HippoPlayer from Aminet".
59
+
60
+ The details, and the way without an AI agent, are under [Installation](#installation).
61
+
62
+ ## What it does
63
+
64
+ Once connected, you can:
44
65
 
45
66
  - **let an AI agent do the work**, for example Claude Code or Codex: install
46
67
  software, update programs, change settings, copy files, click through
@@ -64,6 +85,27 @@ screen to the front, from the PC.
64
85
 
65
86
  ![SysInfo on its own chipset screen in the remote desktop, with the screen list at the top](https://raw.githubusercontent.com/akustikrausch/amigent/main/docs/screenshots/screens.png)
66
87
 
88
+ ## How it fits together
89
+
90
+ ```mermaid
91
+ flowchart LR
92
+ subgraph PC["PC or Mac"]
93
+ agent["AI agent<br/>(Claude Code, Codex, ...)"] -- MCP --> server["amigent-server"]
94
+ you["you"] --> viewer["remote desktop<br/>amigent-viewer"]
95
+ end
96
+ subgraph Amiga["Amiga"]
97
+ daemon["amigentd"] --> os["screen, mouse and keys,<br/>files, Shell, ARexx"]
98
+ daemon --> monitor["amigent-monitor<br/>(what the agent does)"]
99
+ end
100
+ server -- "home network<br/>key, TLS" --> daemon
101
+ viewer -- "home network" --> daemon
102
+ ```
103
+
104
+ One small program on the Amiga, `amigentd`, does what the PC asks: it sends
105
+ the screen, moves the mouse, types, runs commands and copies files. On the PC,
106
+ `amigent-server` gives an AI agent its tools, and the remote desktop shows the
107
+ screen to you. Both can work at once.
108
+
67
109
  ## Installation
68
110
 
69
111
  ### On the Amiga
@@ -141,6 +183,10 @@ working as before; the new features need both.
141
183
  "Open the remote desktop."
142
184
  "Install the newest HippoPlayer from Aminet, so I can take it back if it doesn't work."
143
185
  "Build my program, run it on the Amiga and show me its debug output."
186
+ "The Amiga froze. What was it?"
187
+ "Which AHI driver is really loaded?"
188
+ "Find out whether my program leaks memory."
189
+ "Windows stutter when I drag them. Find out what holds things up."
144
190
 
145
191
  ## Made for slow machines and slow wires
146
192
 
@@ -193,6 +239,8 @@ All numbers, how they were taken and how to repeat them are in
193
239
  - **Developing for the Amiga?** The agent builds and runs your program and
194
240
  reads its kprintf and Enforcer output, and keeps a copy of a growing log on
195
241
  the PC that survives a crash.
242
+ - **A hang, a stutter, a guru?** The agent tells what a task waits for, who
243
+ holds a lock, how much CPU each task takes, and what a guru code means.
196
244
  - **Running a test or a benchmark?** *Pause the picture* in the remote desktop
197
245
  (or `PAUSE` by ARexx) gives the Amiga's CPU back to it for a while; mouse,
198
246
  keys and files keep working.
@@ -12,7 +12,27 @@
12
12
 
13
13
  <p align="center"><img src="https://raw.githubusercontent.com/akustikrausch/amigent/main/src/amigent/web/icon.png" width="96" alt="Amigent icon"></p>
14
14
 
15
- Amigent connects your PC or Mac to your real Amiga over the home network. Then you can:
15
+ Amigent connects your PC or Mac to your real Amiga over the home network.
16
+
17
+ ## Set up in three steps
18
+
19
+ **1. On the Amiga:** copy [`amigentd`](https://github.com/akustikrausch/amigent/blob/main/src/amigent/amiga/bin/amigentd)
20
+ over (`amigentd.000` on a 68000) and start it with `amigentd SETUP` in a Shell.
21
+
22
+ **2. On the PC or Mac:** paste this into your AI agent:
23
+
24
+ Install Amigent for me: run "pipx install amigent", then amigent-setup,
25
+ register the MCP server "amigent" with the command amigent-server, and
26
+ run amigent-viewer --install.
27
+
28
+ **3. Ask for something:** "Open the remote desktop", or "Install the newest
29
+ HippoPlayer from Aminet".
30
+
31
+ The details, and the way without an AI agent, are under [Installation](#installation).
32
+
33
+ ## What it does
34
+
35
+ Once connected, you can:
16
36
 
17
37
  - **let an AI agent do the work**, for example Claude Code or Codex: install
18
38
  software, update programs, change settings, copy files, click through
@@ -36,6 +56,27 @@ screen to the front, from the PC.
36
56
 
37
57
  ![SysInfo on its own chipset screen in the remote desktop, with the screen list at the top](https://raw.githubusercontent.com/akustikrausch/amigent/main/docs/screenshots/screens.png)
38
58
 
59
+ ## How it fits together
60
+
61
+ ```mermaid
62
+ flowchart LR
63
+ subgraph PC["PC or Mac"]
64
+ agent["AI agent<br/>(Claude Code, Codex, ...)"] -- MCP --> server["amigent-server"]
65
+ you["you"] --> viewer["remote desktop<br/>amigent-viewer"]
66
+ end
67
+ subgraph Amiga["Amiga"]
68
+ daemon["amigentd"] --> os["screen, mouse and keys,<br/>files, Shell, ARexx"]
69
+ daemon --> monitor["amigent-monitor<br/>(what the agent does)"]
70
+ end
71
+ server -- "home network<br/>key, TLS" --> daemon
72
+ viewer -- "home network" --> daemon
73
+ ```
74
+
75
+ One small program on the Amiga, `amigentd`, does what the PC asks: it sends
76
+ the screen, moves the mouse, types, runs commands and copies files. On the PC,
77
+ `amigent-server` gives an AI agent its tools, and the remote desktop shows the
78
+ screen to you. Both can work at once.
79
+
39
80
  ## Installation
40
81
 
41
82
  ### On the Amiga
@@ -113,6 +154,10 @@ working as before; the new features need both.
113
154
  "Open the remote desktop."
114
155
  "Install the newest HippoPlayer from Aminet, so I can take it back if it doesn't work."
115
156
  "Build my program, run it on the Amiga and show me its debug output."
157
+ "The Amiga froze. What was it?"
158
+ "Which AHI driver is really loaded?"
159
+ "Find out whether my program leaks memory."
160
+ "Windows stutter when I drag them. Find out what holds things up."
116
161
 
117
162
  ## Made for slow machines and slow wires
118
163
 
@@ -165,6 +210,8 @@ All numbers, how they were taken and how to repeat them are in
165
210
  - **Developing for the Amiga?** The agent builds and runs your program and
166
211
  reads its kprintf and Enforcer output, and keeps a copy of a growing log on
167
212
  the PC that survives a crash.
213
+ - **A hang, a stutter, a guru?** The agent tells what a task waits for, who
214
+ holds a lock, how much CPU each task takes, and what a guru code means.
168
215
  - **Running a test or a benchmark?** *Pause the picture* in the remote desktop
169
216
  (or `PAUSE` by ARexx) gives the Amiga's CPU back to it for a while; mouse,
170
217
  keys and files keep working.
@@ -20,7 +20,7 @@ classifiers = [
20
20
  "Topic :: System :: Emulators",
21
21
  "Topic :: System :: Networking",
22
22
  ]
23
- dependencies = ["mcp>=1.2,<2", "pillow>=10"]
23
+ dependencies = ["mcp>=1.2,<2", "pillow>=10", "capstone>=5"]
24
24
 
25
25
  [project.urls]
26
26
  Homepage = "https://github.com/akustikrausch/amigent"
@@ -46,7 +46,7 @@ where = ["src"]
46
46
  version = { attr = "amigent.__version__" }
47
47
 
48
48
  [tool.setuptools.package-data]
49
- amigent = ["web/*", "web/locales/*", "macos/*", "amiga/*", "amiga/bin/*"]
49
+ amigent = ["*.json", "web/*", "web/locales/*", "macos/*", "amiga/*", "amiga/bin/*"]
50
50
 
51
51
  [tool.setuptools.exclude-package-data]
52
52
  amigent = ["amiga/bin/amigentd.080"] # untested without Vampire hardware; a 68080 runs amigentd
@@ -1,3 +1,3 @@
1
1
  """Amigent: complete remote control for a real Amiga, by AI or manually, tuned for slow Amigas and slow networks."""
2
2
 
3
- __version__ = "1.3.0"
3
+ __version__ = "1.4.0"
@@ -0,0 +1,154 @@
1
+ """Guru meditation codes in words, after exec/alerts.h.
2
+
3
+ An alert is 32 bits: the top bit says the Amiga could not go on (dead end), the
4
+ next seven name the part of the system, the next byte a general kind of error,
5
+ and the low 16 bits the specific one. Codes from CPU exceptions have no part
6
+ and are just the exception number. The second number of a guru is the task or
7
+ the address that caused it.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ DEADEND = 0x80000000
13
+
14
+ SUBSYSTEMS = {
15
+ 0x01: "exec.library", 0x02: "graphics.library", 0x03: "layers.library",
16
+ 0x04: "intuition.library", 0x05: "math libraries", 0x07: "dos.library",
17
+ 0x08: "ramlib", 0x09: "icon.library", 0x0A: "expansion.library",
18
+ 0x0B: "diskfont.library", 0x0C: "utility.library", 0x0D: "keymap.library",
19
+ 0x10: "audio.device", 0x11: "console.device", 0x12: "gameport.device",
20
+ 0x13: "keyboard.device", 0x14: "trackdisk.device", 0x15: "timer.device",
21
+ 0x20: "cia.resource", 0x21: "disk.resource", 0x22: "misc.resource",
22
+ 0x30: "bootstrap", 0x31: "Workbench", 0x32: "DiskCopy", 0x33: "gadtools.library",
23
+ 0x34: "utility.library", 0x35: "an unknown part",
24
+ }
25
+
26
+ GENERAL = {
27
+ 0x01: "out of memory", 0x02: "MakeLibrary() failed", 0x03: "a library did not open",
28
+ 0x04: "a device did not open", 0x05: "a resource did not open", 0x06: "I/O error",
29
+ 0x07: "no free signal", 0x08: "bad parameter", 0x09: "a library closed twice or wrongly",
30
+ 0x0A: "a device closed twice or wrongly", 0x0B: "a process could not be created",
31
+ }
32
+
33
+ # Only the specific codes a user meets in practice; the rest gets its part and kind.
34
+ SPECIFIC = {
35
+ 0x01000001: "an exception vector's checksum is wrong",
36
+ 0x01000002: "ExecBase's checksum is wrong",
37
+ 0x01000003: "a library's checksum is wrong",
38
+ 0x01000005: "the memory list is corrupt (a program wrote over memory it did not own)",
39
+ 0x01000006: "no memory for interrupt servers",
40
+ 0x01000007: "InitStruct() of an APTR source",
41
+ 0x01000008: "a semaphore is in an illegal state",
42
+ 0x01000009: "memory was freed twice",
43
+ 0x0100000A: "an exception without a handler (often a crashed program)",
44
+ 0x0100000B: "an IORequest was used twice",
45
+ 0x0100000C: "the memory list is insane",
46
+ 0x0100000D: "an IORequest was used after its device was closed",
47
+ 0x0100000E: "a stack ran out of its bounds (stack overflow)",
48
+ 0x0100000F: "FreeMem() of an address that was never allocated",
49
+ 0x01000010: "a bad semaphore",
50
+ 0x02010000: "graphics ran out of memory",
51
+ 0x04000001: "a gadget of unknown type",
52
+ 0x04010002: "intuition could not create a message port",
53
+ 0x04010007: "a screen could not be opened",
54
+ 0x0401000B: "a window could not be opened",
55
+ 0x0400000C: "intuition is in a bad state",
56
+ 0x0400000D: "intuition got an unknown message",
57
+ 0x0400000F: "intuition could not open console.device",
58
+ 0x07010001: "no memory when dos started",
59
+ 0x07000002: "EndTask() did not end the task",
60
+ 0x07000003: "a DOS packet did not get through",
61
+ 0x07000004: "an unexpected packet",
62
+ 0x07000005: "FreeVec() of something that was not AllocVec()ed",
63
+ 0x07000006: "a disk block is out of sequence",
64
+ 0x07000007: "a disk's bitmap is corrupt",
65
+ 0x07000008: "a disk key is already free",
66
+ 0x07000009: "a disk block's checksum is wrong",
67
+ 0x0700000A: "a disk error",
68
+ 0x0700000B: "a disk key is out of range",
69
+ 0x0700000C: "a bad overlay",
70
+ 0x0700000D: "a bad init function in a resident module",
71
+ 0x0700000E: "a file was closed twice",
72
+ 0x14000001: "trackdisk: seek error during calibration",
73
+ 0x15000001: "timer: bad request",
74
+ }
75
+
76
+ CPU = {
77
+ 0x02: "bus error (access to an address nothing answers)",
78
+ 0x03: "address error (a word or long at an odd address on a 68000)",
79
+ 0x04: "illegal instruction (the CPU ran into data, or a CPU too old for the program)",
80
+ 0x05: "division by zero",
81
+ 0x06: "CHK instruction",
82
+ 0x07: "TRAPV instruction",
83
+ 0x08: "privilege violation (a user program used a supervisor instruction)",
84
+ 0x09: "trace",
85
+ 0x0A: "line A emulator (unimplemented instruction)",
86
+ 0x0B: "line F emulator (an FPU or MMU instruction the CPU does not have)",
87
+ 0x0E: "format error",
88
+ 0x0F: "uninitialized interrupt",
89
+ 0x18: "spurious interrupt",
90
+ }
91
+
92
+
93
+ def describe(code: int | str, where: int | str | None = None) -> str:
94
+ """'8100000C' -> 'exec.library: the memory list is insane; dead end (the Amiga had to stop)'."""
95
+ if isinstance(code, str):
96
+ code = int(code.strip().lstrip("#$").split(".")[0], 16)
97
+ if isinstance(where, str):
98
+ try:
99
+ where = int(where.strip().lstrip("#$"), 16)
100
+ except ValueError:
101
+ where = None
102
+ deadend = bool(code & DEADEND)
103
+ sub = (code >> 24) & 0x7F
104
+ general = (code >> 16) & 0xFF
105
+ plain = code & 0x7FFFFFFF
106
+ if sub == 0 and general == 0 and (code & 0xFFFF) in CPU:
107
+ text = "CPU exception: " + CPU[code & 0xFFFF]
108
+ deadend = True # a CPU guru always stops the Amiga
109
+ else:
110
+ part = SUBSYSTEMS.get(sub, f"part {sub:02X}")
111
+ if plain in SPECIFIC:
112
+ text = f"{part}: {SPECIFIC[plain]}"
113
+ elif general in GENERAL:
114
+ text = f"{part}: {GENERAL[general]}"
115
+ elif general & 0x80 == 0 and general:
116
+ text = f"{part}: error {general:02X}.{code & 0xFFFF:04X}"
117
+ else:
118
+ text = f"{part}: error {code & 0xFFFF:04X}"
119
+ # AG_OpenLib and friends name what did not open: AO_xxx = $8000 + its part
120
+ if general in (0x03, 0x04, 0x05) and code & 0xFF00 == 0x8000 and code & 0x7F in SUBSYSTEMS:
121
+ text += f" ({SUBSYSTEMS[code & 0x7F]})"
122
+ text += "; dead end (the Amiga had to stop)" if deadend else "; recoverable"
123
+ if where:
124
+ text += f"; caused by the task or at the address {where:08X}"
125
+ return text
126
+
127
+
128
+ def gurudat(text: str) -> dict[int, str]:
129
+ """MCP's S:MCP.gurudat: 'XXXXXXXX description' per line."""
130
+ out = {}
131
+ for line in text.splitlines():
132
+ parts = line.split(None, 1)
133
+ if len(parts) == 2 and len(parts[0]) == 8:
134
+ try:
135
+ out[int(parts[0], 16)] = parts[1].strip()
136
+ except ValueError:
137
+ pass
138
+ return out
139
+
140
+
141
+ def history(text: str, extra: dict[int, str] | None = None) -> list[str]:
142
+ """Each line of a guru log that holds a guru code, with the code in words."""
143
+ import re
144
+
145
+ out = []
146
+ for line in text.splitlines():
147
+ m = re.search(r"\b([0-9A-Fa-f]{8})(?:\.([0-9A-Fa-f]{8}))?\b", line)
148
+ if not m:
149
+ continue
150
+ code = int(m.group(1), 16)
151
+ words = describe(code, m.group(2))
152
+ known = (extra or {}).get(code) or (extra or {}).get(code & 0x7FFFFFFF)
153
+ out.append(f"{line.strip()} -> {words}" + (f" (MCP: {known})" if known else ""))
154
+ return out
@@ -38,7 +38,8 @@ if show('P', 'AMIGENT') then call finish 'busy', 'The running amigentd did not s
38
38
  call swap
39
39
  say 'Starting the new amigentd...'
40
40
  address command line
41
- do 15 until show('P', 'AMIGENT'); address command 'Wait 1'; end
41
+ /* the old one's port can stay taken for a minute; the new one tries for 90 s */
42
+ do 100 until show('P', 'AMIGENT'); address command 'Wait 1'; end
42
43
  if ~show('P', 'AMIGENT') then do
43
44
  address command 'Copy C:amigentd.old C:amigentd QUIET'
44
45
  address command line
@@ -34,11 +34,29 @@ RAWKEYS = {
34
34
  "space": 0x40, "backspace": 0x41, "tab": 0x42, "enter": 0x43, "return": 0x44,
35
35
  "esc": 0x45, "escape": 0x45, "delete": 0x46, "up": 0x4C, "down": 0x4D,
36
36
  "right": 0x4E, "left": 0x4F, "help": 0x5F,
37
+ "ctrl": 0x63, "lamiga": 0x66, "ramiga": 0x67,
37
38
  **{f"f{i}": 0x50 + i - 1 for i in range(1, 11)},
38
39
  }
39
40
  QUALIFIERS = {
40
41
  "shift": 0x01, "ctrl": 0x08, "alt": 0x10, "lamiga": 0x40, "ramiga": 0x80,
41
42
  }
43
+
44
+
45
+ def reset_chord() -> list[dict]:
46
+ """Ctrl, then Left Amiga, then Right Amiga, each left down.
47
+
48
+ Together those keys are the Amiga's reset. There is no key-up: the
49
+ machine goes away while they are held. The qualifier on each key is
50
+ every chord key already down, as a real keyboard reports it.
51
+ """
52
+ qualifier = 0
53
+ ops = []
54
+ for name in ("ctrl", "lamiga", "ramiga"):
55
+ qualifier |= QUALIFIERS[name]
56
+ ops.append({"t": "key", "code": RAWKEYS[name], "down": True, "q": qualifier})
57
+ return ops
58
+
59
+
42
60
  BUTTONS = {"left": 1, "right": 2, "middle": 4}
43
61
 
44
62
  _LUT = {
@@ -296,21 +314,25 @@ class Amigentd:
296
314
  return None
297
315
  return self._chunky().image(PALETTE)
298
316
 
299
- def _frame_reply(self, take, planar: bool = False):
317
+ def _frame_reply(self, take, planar: bool = False, packed: bool | None = None, timing=None):
300
318
  """Parser for one FRAME answer: yields bytes wanted, gets them sent in.
301
319
 
302
320
  take(tile) gets each tile the moment it is complete, as RGB332 for the
303
321
  chunky formats. Returns the tile count, the bytes and the seconds from
304
322
  header to last byte. With planar the format byte says what follows.
323
+ packed: whether the frame was asked for packed, for the policy to time;
324
+ timing: (since, now), two clocks: when the Amiga could start on the frame
325
+ and when its bytes came. The Amiga may pack a small frame whole before
326
+ it sends the header, so the header is no start.
305
327
  """
306
328
  kind = (yield 1)[0] if planar else 0
307
- return (yield from self._format_reply(kind, take))
329
+ return (yield from self._format_reply(kind, take, packed, timing))
308
330
 
309
- def _format_reply(self, kind: int, take):
331
+ def _format_reply(self, kind: int, take, packed: bool | None = None, timing=None):
310
332
  if kind == 1:
311
- return (yield from self._planar_reply(take))
333
+ return (yield from self._planar_reply(take, packed, timing))
312
334
  if kind == 2:
313
- return (yield from self._chunky_reply(take))
335
+ return (yield from self._chunky_reply(take, packed, timing))
314
336
  if kind != 0:
315
337
  raise AmigentdError(f"unknown frame format {kind}")
316
338
  if self._planes is not None:
@@ -327,18 +349,18 @@ class Amigentd:
327
349
  self.received += size
328
350
  return count, size, time.perf_counter() - start
329
351
 
330
- def _tiles_into(self, surface, take, size: int):
352
+ def _tiles_into(self, surface, take, size: int, packed: bool | None = None, timing=None):
331
353
  """The tile list of format 1 and 2: each one through the pipeline at once,
332
354
  its partners are the picture as it was before this frame."""
333
355
  surface.begin_frame()
334
356
  start = time.perf_counter()
357
+ since = timing[0]() if timing else None
335
358
  count = struct.unpack(">I", (yield 4))[0]
336
359
  size += 4
337
- deflated = False
360
+ raw = size # as it would have come unpacked
338
361
  for _ in range(count):
339
362
  x, y, w, h, method, n = struct.unpack(">HHHHBI", (yield 13))
340
363
  data = yield n
341
- deflated = deflated or bool(method & DEFLATED)
342
364
  if method & DEFLATED:
343
365
  try:
344
366
  data = zlib.decompress(data, -15)
@@ -350,14 +372,15 @@ class Amigentd:
350
372
  except PlanarError as e:
351
373
  raise AmigentdError(str(e)) from e
352
374
  size += 13 + n
375
+ raw += 13 + len(data)
353
376
  take((x, y, w, h, surface.tile(x, y, w, h) if isinstance(surface, Chunky) else data))
354
377
  self.received += size
355
378
  elapsed = time.perf_counter() - start
356
- if not deflated and self.policy: # the line itself, not the Amiga's packing
357
- self.policy.note(size, elapsed)
379
+ if self.policy and packed is not None and since is not None:
380
+ self.policy.note_frame(raw, timing[1]() - since, packed)
358
381
  return count, size, elapsed
359
382
 
360
- def _planar_reply(self, take):
383
+ def _planar_reply(self, take, packed: bool | None = None, timing=None):
361
384
  """Format 1: the planes, maybe a palette, then tiles."""
362
385
  depth, flags, width, height = planar_header((yield 7))
363
386
  size = 8
@@ -376,14 +399,14 @@ class Amigentd:
376
399
  if planes.set_palette((yield 3 * count)) and not fresh:
377
400
  planes.repaint = True
378
401
  size += 2 + 3 * count
379
- return (yield from self._tiles_into(planes, take, size))
402
+ return (yield from self._tiles_into(planes, take, size, packed, timing))
380
403
 
381
- def _chunky_reply(self, take):
404
+ def _chunky_reply(self, take, packed: bool | None = None, timing=None):
382
405
  """Format 2: RGB332 tiles for graphics cards, sharing the classic picture."""
383
406
  _, _, _, width, height = struct.unpack(">BBBHH", (yield 7))
384
407
  if (width, height) != (self.width, self.height):
385
408
  self._apply_size(width, height)
386
- return (yield from self._tiles_into(self._chunky(), take, 8))
409
+ return (yield from self._tiles_into(self._chunky(), take, 8, packed, timing))
387
410
 
388
411
  def _screens_reply(self):
389
412
  found = []
@@ -513,8 +536,11 @@ class Amigentd:
513
536
  region = (0, 0, self.width, self.height) # a new picture needs everything
514
537
  tiles: list = []
515
538
  try:
516
- self._send(CMD_FRAME, self.frame_arg(force), *region)
517
- self._drive(self._frame_reply(tiles.append, self.planar))
539
+ arg = self.frame_arg(force)
540
+ asked = time.perf_counter() # nothing else in flight: the Amiga starts now
541
+ self._send(CMD_FRAME, arg, *region)
542
+ timing = (lambda: asked, time.perf_counter)
543
+ self._drive(self._frame_reply(tiles.append, self.planar, self.frame_packed(arg), timing))
518
544
  except (OSError, AmigentdError):
519
545
  self.drop_picture() # the service has moved on, ours is incomplete
520
546
  raise
@@ -526,9 +552,15 @@ class Amigentd:
526
552
  def frame_arg(self, force: bool) -> int:
527
553
  arg = int(force) | (FRAME_PLANAR if self.planar else 0)
528
554
  if self.planar and self.protocol >= PACK_PROTOCOL:
529
- arg |= FRAME_DEFLATE.get(self.packing().level(), 0)
555
+ arg |= FRAME_DEFLATE.get(self.packing().frame_level(), 0)
530
556
  return arg
531
557
 
558
+ def frame_packed(self, arg: int) -> bool | None:
559
+ """Whether a frame asked with arg comes packed; None when packing is not in play."""
560
+ if not (self.planar and self.protocol >= PACK_PROTOCOL):
561
+ return None
562
+ return any(arg & bit for bit in FRAME_DEFLATE.values())
563
+
532
564
  def packing(self) -> pack.Policy:
533
565
  """The Amiga's packing policy, shared with the command channel that learns its rates."""
534
566
  if self.policy is None:
@@ -883,6 +915,10 @@ class Pipeline:
883
915
  self.waiting: deque = deque() # [parser, bytes wanted, kind]
884
916
  self.frames = self.inputs = self.moves = 0
885
917
  self.heard = time.monotonic()
918
+ # perf_counter of the last bytes read, and of the read that ended the last
919
+ # answer: the Amiga works through requests in order, so the next one can't
920
+ # have started before that answer was out
921
+ self.got_at = self.done_at = time.perf_counter()
886
922
  self._tiles: list = []
887
923
  self.sock.settimeout(0.0)
888
924
 
@@ -928,12 +964,17 @@ class Pipeline:
928
964
 
929
965
  def frame(self, x: int, y: int, w: int, h: int, force: bool = False, on_done=None) -> None:
930
966
  """Ask for a region; tiles reach the picture as each one lands."""
967
+ arg = self.screen.frame_arg(force)
968
+ packed = self.screen.frame_packed(arg)
969
+ asked = time.perf_counter()
970
+ timing = (lambda: max(asked, self.done_at), lambda: self.got_at)
971
+
931
972
  def parse():
932
- result = yield from self.screen._frame_reply(self._landed, self.screen.planar)
973
+ result = yield from self.screen._frame_reply(self._landed, self.screen.planar, packed, timing)
933
974
  if on_done:
934
975
  on_done(*result)
935
976
 
936
- self._ask("frame", parse(), CMD_FRAME, self.screen.frame_arg(force), x, y, w, h)
977
+ self._ask("frame", parse(), CMD_FRAME, arg, x, y, w, h)
937
978
 
938
979
  def _landed(self, tile) -> None:
939
980
  self._tiles.append(tile) # the list is swapped per round, so no bound .append
@@ -960,6 +1001,7 @@ class Pipeline:
960
1001
  raise AmigentdError("connection closed by amigentd")
961
1002
  if data:
962
1003
  self.heard = time.monotonic()
1004
+ self.got_at = time.perf_counter()
963
1005
  self.inbuf += data
964
1006
  self._parse()
965
1007
  if self.waiting and time.monotonic() - self.heard > self.screen.timeout:
@@ -990,6 +1032,7 @@ class Pipeline:
990
1032
  try:
991
1033
  entry[1] = entry[0].send(chunk)
992
1034
  except StopIteration:
1035
+ self.done_at = self.got_at
993
1036
  self.waiting.popleft()
994
1037
  kind = entry[2]
995
1038
  if kind == "frame":