Skip to content

Commit 8a687c8

Browse files
committed
trying to fix input_c (not loading images)
1 parent 4fd946a commit 8a687c8

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

host/src/host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define PNTR_ENABLE_UTF8
1111
#define PNTR_ENABLE_MATH
1212
#define PNTR_ENABLE_JPEG
13+
#define PNTR_CUTE_PNG
1314
#define PNTR_PIXELFORMAT_RGBA
1415
#define PNTR_LOAD_FILE fs_load_file
1516
#define PNTR_SAVE_FILE fs_save_file

tools/docker/build_c.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ mkdir -p "/tmp/${CART_NAME}"
2222

2323
cp -R /src/* /src/.* "/tmp/${CART_NAME}/" 2>/dev/null
2424
cd "/tmp/${CART_NAME}/"
25-
clang -I /usr/local/include/ -o main.wasm main.c
25+
clang -I /usr/local/include/ -Wl,--initial-memory=67108864,--max-memory=67108864,-z,stack-size=8388608 -o main.wasm main.c
2626

2727
/usr/local/bin/zipcart.sh "${CART_NAME}" "/tmp/${CART_NAME}/" /out

webroot/fflatefs.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ const FILETYPE_REGULAR_FILE = 4
77
const FILETYPE_DIRECTORY = 3
88

99
export default async function fflatefs(cartUrl) {
10+
const zipBytes = new Uint8Array(await fetch(cartUrl).then((r) => r.arrayBuffer()))
11+
1012
const info = {}
1113
let ino = 4
1214

13-
const data = fflate.unzipSync(new Uint8Array(await fetch(cartUrl).then((r) => r.arrayBuffer())), {
15+
const data = fflate.unzipSync(zipBytes, {
1416
filter: (file) => {
15-
if (file.name != 'main.wasm' && !file.name.endsWith('.DS_Store')) {
16-
info[file.name] = file
17-
info[file.name].type = file.name.endsWith('/') ? FILETYPE_DIRECTORY : FILETYPE_REGULAR_FILE
18-
info[file.name].ino = ino++
19-
return true
20-
}
17+
info[file.name] = file
18+
info[file.name].type = file.name.endsWith('/') ? FILETYPE_DIRECTORY : FILETYPE_REGULAR_FILE
19+
info[file.name].ino = ino++
20+
return true // you can filter here
2121
}
2222
})
2323

webroot/index.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
font-family: sans-serif;
1616
background: black;
1717
color: white;
18-
padding:20px;
18+
padding: 20px;
1919
}
20-
20+
2121
#demos {
2222
display: flex;
2323
flex-wrap: wrap;
@@ -51,25 +51,26 @@
5151
</style>
5252
</head>
5353
<body>
54-
<!-- instead of my demo code, you could just do something like this: -->
54+
<!-- instead of my demo code, you could just do something like this: -->
5555
<!-- <null0-cart src="carts/colorbars_c.null0"></null0-cart> -->
56-
<div id="demos">
57-
</div>
56+
<div id="demos"></div>
5857
</body>
5958
<script type="module">
6059
// this is more wonky than you need to do, but I want to automate loading whatever carts were built
61-
// I also wanted to handle URL hash, so I can just show 1 (better for testing a single problem)
60+
// I also wanted to handle URL hash, so I can just show 1 (better for testing a single problem)
6261

6362
let carts = []
6463

6564
// handle #cart URL
6665
if (document.location.hash) {
6766
carts = [document.location.hash.slice(1) + '.null0']
68-
}else {
67+
} else {
6968
// get list of carts (specific to my demo)
70-
carts = await fetch('carts/list.txt').then(r => r.text()).then(t => t.trim().split('\n'))
69+
carts = await fetch('carts/list.txt')
70+
.then((r) => r.text())
71+
.then((t) => t.trim().split('\n'))
7172
}
72-
73+
7374
window.addEventListener('hashchange', () => {
7475
// reload is required to clear it out
7576
document.location.reload()

0 commit comments

Comments
 (0)