Skip to content

Commit 5eacc33

Browse files
fixup! fixup! fixup! fixup! fixup! feat: split the functionality into a lib
Signed-off-by: Harikrishnan Balagopal <[email protected]>
1 parent b2ecbb1 commit 5eacc33

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

docs/assets/js/main.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const COLUMN_LEVEL = `
2-
# include<stdio.h>// .IOCCC Fluid- #
1+
const COLUMN_LEVEL = `# include<stdio.h>// .IOCCC Fluid- #
32
# include <unistd.h> //2012 _Sim!_ #
43
# include<complex.h> //|||| ,____. IOCCC- #
54
# define h for( x=011; 2012/* #
@@ -21,8 +20,7 @@ const COLUMN_LEVEL = `
2120
## */%80- 9?x[b] :16];;usleep( 12321) ;}return 0;}/* ##
2221
#### ####
2322
###############################################################################
24-
**###########################################################################*/
25-
`;
23+
**###########################################################################*/`;
2624

2725
async function main() {
2826
const CONSOLE_WIDTH = 80;
@@ -51,7 +49,6 @@ async function main() {
5149
console.log('input_mem before', input_mem);
5250
for(let i = 0; i < COLUMN_LEVEL.length; i++) {
5351
input_mem[i] = COLUMN_LEVEL.charCodeAt(i);
54-
// mem[i] = COLUMN_LEVEL.charCodeAt(i);
5552
}
5653
console.log('input_mem after', input_mem);
5754

@@ -85,7 +82,26 @@ async function main() {
8582
if (PAUSED) {
8683
PAUSED = false;
8784
play_pause_button.textContent = '⏸ Pause';
88-
fluid_output.removeAttribute('contenteditable');
85+
if(fluid_output.getAttribute('contenteditable')) {
86+
fluid_output.removeAttribute('contenteditable');
87+
const new_level = fluid_output.textContent;
88+
console.log('new_level', new_level, new_level.length);
89+
90+
const input_address = module.instance.exports.allocate_memory_for_file(COLUMN_LEVEL.length);
91+
console.log('input_address', input_address);
92+
const input_mem = new Uint8Array(module.instance.exports.memory.buffer, input_address, COLUMN_LEVEL.length);
93+
console.log('input_mem before', input_mem);
94+
for(let i = 0; i < new_level.length; i++) {
95+
input_mem[i] = new_level.charCodeAt(i);
96+
}
97+
console.log('input_mem after', input_mem);
98+
for(let i = 0; i < mem.length; i++) {
99+
mem[i] = 0;
100+
}
101+
// module.instance.exports.initialize_global(input_address);
102+
const total_particles = module.instance.exports.initialize_global(input_address);
103+
console.log('total_particles', total_particles);
104+
}
89105
requestAnimationFrame(draw);
90106
} else {
91107
PAUSED = true;

0 commit comments

Comments
 (0)