retro.c: start work on the internal cleanups

FossilOrigin-Name: 62f85ac1f648c3cfdb75969af594c3a10f1dba33829dbc4ecce3a9a218f8f83a
This commit is contained in:
crc 2021-07-30 14:39:29 +00:00
parent 21eb0704c7
commit 7574bd59d1
5 changed files with 47 additions and 42 deletions

View file

@ -15,6 +15,7 @@ ENABLED += -DENABLE_CLOCK
ENABLED += -DENABLE_SCRIPTING
ENABLED += -DENABLE_SIGNALS
ENABLED += -DENABLE_MULTICORE
ENABLED += -DENABLE_FFI
all: build

View file

@ -5,3 +5,12 @@
- new words
h:fetch h:store w:fetch w:store
# VM
## nga-c: retro.c
- added optional support for multiple virtual processor cores
- added optional ffi
- work on internal cleanups

View file

@ -15,10 +15,10 @@ Testing for multiple core support.
~~~
'Done var
:a [ @Done #100000 lt? 0; drop &Done v:inc $a c:put ] forever ;
:a [ @Done #100000 gt? [ core:pause-current ] if &Done v:inc $a c:put ] forever ;
:b [ $b c:put ] forever ;
:c [ $c c:put ] forever ;
:d [ $d c:put ] forever ;
:d [ @Done #50000 gt? [ core:pause-current ] if $d c:put ] forever ;
#1 core:init &a #1 core:start
#2 core:init &b #2 core:start

View file

@ -10,8 +10,8 @@
#define CELL_MAX LLONG_MAX - 1
#endif
#endif
CELL ngaImageCells = 17239;
CELL ngaImage[] = { 1793,15137,17221,17238,202110,400,372,1069,1535,0,10,1,10,2,10,3,10,4,10,
CELL ngaImageCells = 16545;
CELL ngaImage[] = { 1793,15137,16527,16544,202110,400,372,1069,1535,0,10,1,10,2,10,3,10,4,10,
5,10,6,10,7,10,8,10,11,10,12,10,13,10,14,10,15,10,16,10,
17,10,18,10,19,10,20,10,21,10,22,10,23,10,24,10,25,68223234,1,2575,
85000450,1,656912,161,178,268505089,63,62,285281281,0,63,2063,10,101384453,0,9,10,68485378,255,18350338,
@ -162,7 +162,7 @@ CELL ngaImage[] = { 1793,15137,17221,17238,202110,400,372,1069,1535,0,10,1,10,2,
2967,166,110,58,105,110,99,0,659713,1,10,2958,2979,166,110,58,100,101,99,0,
659969,1,10,2970,2996,166,110,58,98,101,116,119,101,101,110,63,0,67503109,1793,3004,
67503109,67503109,2049,2950,10,1,2999,2049,2165,11,10,2982,3023,166,83,99,111,112,101,76,
105,115,116,0,16916,16968,10,3010,3032,166,123,123,0,2049,1570,2,1,3023,2049,59,
105,115,116,0,16222,16274,10,3010,3032,166,123,123,0,2049,1570,2,1,3023,2049,59,
16,10,3026,3057,166,45,45,45,114,101,118,101,97,108,45,45,45,0,2049,1570,
1,3023,2049,2967,16,10,3041,3071,166,125,125,0,1,3023,2049,56,4,15,11,1793,
3085,3841,3023,4097,2,10,1,3080,1793,3111,3841,3023,1793,3106,1,2,983567,1,3023,2049,
@ -208,7 +208,7 @@ CELL ngaImage[] = { 1793,15137,17221,17238,202110,400,372,1069,1535,0,10,1,10,2,
10,1,3873,2049,2155,4097,3680,10,3848,3902,154,84,101,109,112,83,116,114,105,110,
103,115,0,32,3887,3920,154,84,101,109,112,83,116,114,105,110,103,77,97,120,
0,512,3903,3932,166,83,84,82,73,78,71,83,0,2049,1543,3841,3902,3841,3920,19,
18,10,3921,3952,154,67,117,114,114,101,110,116,0,17,10,3941,3967,166,115,58,
18,10,3921,3952,154,67,117,114,114,101,110,116,0,29,10,3941,3967,166,115,58,
112,111,105,110,116,101,114,0,3841,3952,3841,3920,19,2049,3932,17,10,3954,3986,166,
115,58,110,101,120,116,0,1,3952,2049,3509,3841,3952,3841,3902,11,1793,4002,1,0,
4097,3952,10,1,3997,9,10,3921,4016,166,115,58,116,101,109,112,0,2,2049,102,
@ -479,7 +479,7 @@ CELL ngaImage[] = { 1793,15137,17221,17238,202110,400,372,1069,1535,0,10,1,10,2,
9312,2,2049,102,2049,2620,1,400,1,15,2049,64,10,1,9300,2049,2155,2049,2967,10,
1,9293,2049,2353,2049,400,10,9185,9340,166,115,58,101,118,97,108,117,97,116,101,
0,2049,9238,2049,5061,2049,9238,2,2049,9260,2049,9291,10,9326,9358,154,76,80,0,0,
9352,9368,154,73,110,100,101,120,0,0,10,0,0,0,0,0,0,0,0,0,
9352,9368,154,73,110,100,101,120,0,0,11,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,9359,9408,166,110,101,120,116,0,3841,9358,1,9368,17,2049,3509,10,9400,9424,166,
112,114,101,112,0,1,9358,2049,3509,1,0,3841,9358,1,9368,17,16,10,9416,9445,
@ -838,38 +838,4 @@ CELL ngaImage[] = { 1793,15137,17221,17238,202110,400,372,1069,1535,0,10,1,10,2,
45,111,102,0,2049,8676,10,16469,16507,166,97,58,105,110,100,101,120,45,111,102,
45,115,116,114,105,110,103,0,2049,8712,10,16486,16524,166,115,58,105,110,100,101,
120,45,111,102,0,2049,4320,10,16510,16541,166,115,58,105,110,100,101,120,45,111,
102,0,2049,4789,10,16527,16555,166,100,58,119,111,114,100,115,0,1793,16564,2049,184,
2049,9746,2049,9720,10,1,16557,2049,7965,10,16544,16585,166,100,58,119,111,114,100,115,
45,119,105,116,104,0,2049,1929,2049,5061,1793,16616,2049,184,2,2049,1929,2049,4578,1793,
16605,2049,9746,2049,9720,10,1,16600,1793,16611,3,10,1,16609,2049,64,10,1,16591,2049,
7965,10,16569,16640,166,100,105,115,112,108,97,121,45,105,102,45,108,101,102,116,
0,2,2049,1929,2049,5011,1793,16652,2049,9746,2049,9720,10,1,16647,1793,16658,3,10,1,
16656,2049,64,10,16569,16689,166,100,58,119,111,114,100,115,45,98,101,103,105,110,
110,105,110,103,45,119,105,116,104,0,2049,1929,2049,5061,1793,16700,2049,184,2049,16640,
10,1,16695,2049,7965,10,16663,16716,166,115,58,115,112,108,105,116,0,2049,6526,10,
16705,16740,166,115,58,115,112,108,105,116,45,111,110,45,115,116,114,105,110,103,
0,2049,6558,10,16719,16763,166,115,58,99,111,110,116,97,105,110,115,45,99,104,
97,114,63,0,2049,4386,10,16743,16788,166,115,58,99,111,110,116,97,105,110,115,
45,115,116,114,105,110,103,63,0,2049,4578,10,16766,16813,166,97,58,99,111,110,
116,97,105,110,115,45,115,116,114,105,110,103,63,0,2049,4578,10,16791,16830,166,
97,58,105,110,100,101,120,45,111,102,0,2049,8676,10,16816,16854,166,97,58,105,
110,100,101,120,45,111,102,45,115,116,114,105,110,103,0,2049,8712,10,16833,16871,
166,115,58,105,110,100,101,120,45,111,102,0,2049,4320,10,16857,16888,166,115,58,
105,110,100,101,120,45,111,102,0,2049,4789,10,16874,16902,166,100,58,119,111,114,
100,115,0,1793,16911,2049,184,2049,9746,2049,9720,10,1,16904,2049,7965,10,16891,16932,166,
100,58,119,111,114,100,115,45,119,105,116,104,0,2049,1929,2049,5061,1793,16963,2049,
184,2,2049,1929,2049,4578,1793,16952,2049,9746,2049,9720,10,1,16947,1793,16958,3,10,1,
16956,2049,64,10,1,16938,2049,7965,10,16916,16987,166,100,105,115,112,108,97,121,45,
105,102,45,108,101,102,116,0,2,2049,1929,2049,5011,1793,16999,2049,9746,2049,9720,10,
1,16994,1793,17005,3,10,1,17003,2049,64,10,16916,17036,166,100,58,119,111,114,100,
115,45,98,101,103,105,110,110,105,110,103,45,119,105,116,104,0,2049,1929,2049,
5061,1793,17047,2049,184,2049,16987,10,1,17042,2049,7965,10,17010,17063,166,115,58,115,112,
108,105,116,0,2049,6526,10,17052,17087,166,115,58,115,112,108,105,116,45,111,110,
45,115,116,114,105,110,103,0,2049,6558,10,17066,17110,166,115,58,99,111,110,116,
97,105,110,115,45,99,104,97,114,63,0,2049,4386,10,17090,17135,166,115,58,99,
111,110,116,97,105,110,115,45,115,116,114,105,110,103,63,0,2049,4578,10,17113,
17160,166,97,58,99,111,110,116,97,105,110,115,45,115,116,114,105,110,103,63,
0,2049,4578,10,17138,17177,166,97,58,105,110,100,101,120,45,111,102,0,2049,8676,
10,17163,17201,166,97,58,105,110,100,101,120,45,111,102,45,115,116,114,105,110,
103,0,2049,8712,10,17180,17218,166,115,58,105,110,100,101,120,45,111,102,0,2049,
4320,10,17204,17235,166,115,58,105,110,100,101,120,45,111,102,0,2049,4789,10,0 };
102,0,2049,4789,10,0 };

View file

@ -192,6 +192,35 @@ char scripting_sources[64][8192];
int current_source;
int perform_abort;
struct NgaState {
/* System Memory */
CELL memory[IMAGE_SIZE + 1];
/* CPU Cores */
struct NgaCore cpu[CORES];
int active;
/* I/O Devices */
int devices;
Handler IO_deviceHandlers[MAX_DEVICES];
Handler IO_queryHandlers[MAX_DEVICES];
/* Interfacing */
CELL Dictionary, NotFound, interpret;
char string_data[8192];
/* Floating Point */
double Floats[256], AFloats[256];
CELL fsp, afsp;
/* Scripting */
char **sys_argv;
int sys_argc;
char scripting_sources[64][8192];
int current_source;
int perform_abort;
};
/* Multi Core Support ------------------------------------------------ */
#ifdef ENABLE_MULTICORE
void init_core(CELL x) {