Skip to content

Commit a28f89c

Browse files
committed
Update README to reflect modulepack.lua changes
1 parent 420d62f commit a28f89c

2 files changed

Lines changed: 42 additions & 57 deletions

File tree

.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ computers with this one instead.
2929

3030
## How?
3131

32-
[Click here](#tldr) for steps to take if you have no idea what's going on and
33-
just want to finally program a computer.
34-
3532
You can run the assembler from TPT or really in any environment that's
3633
compatible with Lua 5.1. Running it from TPT has the benefit of actually
3734
allowing you to program computers.
@@ -91,40 +88,68 @@ make all this clear.
9188

9289
### Inside TPT
9390

91+
Install the [Script Manager](https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=19400),
92+
then install [TPTASM](https://starcatcher.us/scripts?view=316) with it. Once done, usage is as simple as:
93+
9494
```lua
95-
tptasm = loadfile("main.lua") -- load tptasm into memory as a function
96-
-- (this assumes you saved it in the same directory TPT is in)
95+
-- install TPTASM with the script manager
96+
-- see https://starcatcher.us/scripts?view=316
9797
tptasm("/path/to/source.asm") -- assemble source
9898
tptasm("/path/to/source.asm", 0xDEAD) -- specify target CPU
9999
tptasm("/path/to/source.asm", nil, "log.log") -- specify file to log output to
100100
tptasm("/path/to/source.asm", nil, nil, "R3") -- specify model name
101101
```
102102

103-
#### Complete example
104-
105-
Assuming this repository has been cloned to `~/Development/tptasm`, navigate to
103+
For example, download [micro21/demo.asm](examples/micro21/demo.asm), navigate to
106104
[save id:1599945](https://powdertoy.co.uk/Browse/View.html?ID=1599945) and
107105
execute this:
108106

109107
```lua
110-
loadfile("~/Development/tptasm/src/main.lua")("~/Development/tptasm/examples/micro21/demo.asm")
108+
tptasm("/path/to/downloads/micro21/demo.asm") -- adjust /path/to/downloads to match your system
111109
```
112110

113-
### Somewhere else
114-
115-
```sh
116-
# currently quite pointless to do but possible nonetheless
117-
$ ./main.lua /path/to/source.asm model=R3
118-
```
111+
Advanced functionality example:
119112

120113
```lua
121-
-- let's say this is not TPT's console
122-
tptasm = loadfile("main.lua")
114+
-- let's say this is not TPT's console but some script executed in TPT by some other means
123115
opcodes = {}
124116
tptasm({ source = "/path/to/source.asm", target = opcodes, model = "R3" })
125117
print(opcodes[0x1337]:dump())
126118
```
127119

120+
### Somewhere else, for normal usage
121+
122+
Download the latest release and use `loadfile` to get access to the `tptasm`
123+
function in any Lua environment:
124+
125+
```lua
126+
tptasm = loadfile("/path/to/tptasm.lua")
127+
```
128+
129+
Releases from this repo are also what get published on the Script Manager, so
130+
if you have already installed TPTASM with the Script Manager, you can just use
131+
it directly from TPT's data folder.
132+
133+
Command line usage is also possible:
134+
135+
```
136+
$ luajit /path/to/tptasm.lua ...
137+
```
138+
139+
### Somewhere else, for development purposes
140+
141+
Assuming the current directory is this repo, submodules have been fetched with
142+
`git submodule update --init`, and [LuaJIT](https://luajit.org/) or some other
143+
Lua 5.x version has been installed:
144+
145+
```sh
146+
# currently quite pointless to do but possible nonetheless
147+
$ luajit TPT-Script-Manager/modulepack.lua modulepack.conf run /path/to/source.asm model=R3
148+
```
149+
150+
TPTASM can be run from other current directories by passing modulepack.lua and
151+
modulepack.conf with appropriately relative or absolute paths.
152+
128153
### Exporting labels
129154

130155
The file referred to by `export_labels` will look something like this
@@ -144,43 +169,6 @@ demo_odds.count_odds 0x3B
144169
That is, it'll have one fully qualified label and the corresponding address
145170
in hexadecimal per line, separated by one space character.
146171

147-
### TL;DR
148-
149-
1. find the green button on this page which looks like it might let you
150-
download something; clicking it gives you a popup with an option somewhere
151-
to download a ZIP
152-
1. download said ZIP and extract it somewhere, then find the src folder inside
153-
and rename it to tptasm
154-
1. open the settings menu in TPT, scroll down and click Open Data Folder;
155-
move the tptasm folder from earlier to the one that TPT just opened
156-
1. have the code you want to assemble saved to a file (say, `code.asm`) and
157-
move said file, once again, to the folder TPT just opened
158-
1. open the save in TPT with the computer you want to program
159-
1. if there are multiple computers in the save, find the one and only QRTZ
160-
particle in the computer you want to program (possibly with the Find mode,
161-
`Ctrl+F`) and move your cursor over it (use a `1x1` brush)
162-
1. open the console (with `~` or the `[C]` button on the right side of the
163-
window) and execute the following:
164-
165-
```lua
166-
loadfile("tptasm/main.lua")("code.asm")
167-
```
168-
169-
1. if `[tptasm] done` is the only thing you see, your code assembled
170-
and you're done!
171-
1. if `[tptasm] done` is not the only thing you see, you may want to save the
172-
log to a file for inspection; you can do this by executing this instead:
173-
174-
```lua
175-
loadfile("tptasm/main.lua")("code.asm", nil, "log.log")
176-
```
177-
178-
... which will create a file named log.log in the folder TPT opened; open
179-
this file in a text editor to see why your code didn't assemble
180-
1. if the file shows something like "this is an error, tell LBPHacker", then
181-
tell me!
182-
183-
184172
## Then?
185173

186174
Things I still want to do but don't know when I'll have the time:

0 commit comments

Comments
 (0)