1
- const COLUMN_LEVEL = `
2
- # include<stdio.h>// .IOCCC Fluid- #
1
+ const COLUMN_LEVEL = `# include<stdio.h>// .IOCCC Fluid- #
3
2
# include <unistd.h> //2012 _Sim!_ #
4
3
# include<complex.h> //|||| ,____. IOCCC- #
5
4
# define h for( x=011; 2012/* #
@@ -21,8 +20,7 @@ const COLUMN_LEVEL = `
21
20
## */%80- 9?x[b] :16];;usleep( 12321) ;}return 0;}/* ##
22
21
#### ####
23
22
###############################################################################
24
- **###########################################################################*/
25
- ` ;
23
+ **###########################################################################*/` ;
26
24
27
25
async function main ( ) {
28
26
const CONSOLE_WIDTH = 80 ;
@@ -51,7 +49,6 @@ async function main() {
51
49
console . log ( 'input_mem before' , input_mem ) ;
52
50
for ( let i = 0 ; i < COLUMN_LEVEL . length ; i ++ ) {
53
51
input_mem [ i ] = COLUMN_LEVEL . charCodeAt ( i ) ;
54
- // mem[i] = COLUMN_LEVEL.charCodeAt(i);
55
52
}
56
53
console . log ( 'input_mem after' , input_mem ) ;
57
54
@@ -85,7 +82,26 @@ async function main() {
85
82
if ( PAUSED ) {
86
83
PAUSED = false ;
87
84
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
+ }
89
105
requestAnimationFrame ( draw ) ;
90
106
} else {
91
107
PAUSED = true ;
0 commit comments