Skip to content

Commit f9eff3a

Browse files
committed
InstructionParams -> arr lookup from obj
1 parent 614dc99 commit f9eff3a

File tree

1 file changed

+63
-61
lines changed

1 file changed

+63
-61
lines changed

IDGVM/Registers.ts

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -225,159 +225,161 @@ export enum ParameterFetchType {
225225
* Includes the list of parameters (types) that the generator should fetch.
226226
* NOTE: Does not include the instruction itself as that has already been fetched at the time of querying this object
227227
*/
228-
export const InstructionParams: Record<Instructions, ParameterFetchType[]> = {
228+
export const InstructionParams: ParameterFetchType[][] = [
229229
// TODO: fetch number from network instruction (this does not seem that problematic)
230-
[Instructions.PSH_IP]: [],
231-
[Instructions.PSH_IP_OFFSETTED]: [ParameterFetchType.unsignedINT32],
232-
[Instructions.DEBUG]: [ParameterFetchType.unsignedINT8],
233-
[Instructions.MOVE]: [
230+
[],
231+
/** [Instructions.MOVE]:*/ [
234232
ParameterFetchType.unsignedINT8,
235233
ParameterFetchType.unsignedINT32,
236234
ParameterFetchType.unsignedINT32,
237235
],
238-
[Instructions.MOVE_S]: [
236+
/** [Instructions.MOVE_S]:*/ [
239237
ParameterFetchType.unsignedINT8,
240238
ParameterFetchType.signedINT32, // TODO: consequence-> we can't fully address the entire memory space
241239
ParameterFetchType.unsignedINT32,
242-
], // TODO: test this by providing signed values and see if it retains its precision
243-
[Instructions.ADD]: [
240+
],
241+
/** [Instructions.ADD]:*/ [
244242
ParameterFetchType.unsignedINT8,
245243
ParameterFetchType.unsignedINT32,
246244
ParameterFetchType.unsignedINT32,
247245
],
248-
[Instructions.SUBTRACT]: [
246+
/** [Instructions.SUBTRACT]:*/ [
249247
ParameterFetchType.unsignedINT8,
250248
ParameterFetchType.unsignedINT32,
251249
ParameterFetchType.unsignedINT32,
252250
],
253-
[Instructions.INC_REG]: [ParameterFetchType.signedINT32],
254-
[Instructions.DEC_REG]: [ParameterFetchType.signedINT32],
255-
[Instructions.MULTIPLY]: [
251+
/** [Instructions.INC_REG]:*/ [ParameterFetchType.signedINT32],
252+
/** [Instructions.DEC_REG]:*/ [ParameterFetchType.signedINT32],
253+
/** [Instructions.MULTIPLY]:*/ [
256254
ParameterFetchType.unsignedINT8,
257255
ParameterFetchType.unsignedINT32,
258256
ParameterFetchType.unsignedINT32,
259257
],
260-
[Instructions.BITWISE_SHIFT]: [
258+
/** [Instructions.BITWISE_SHIFT]:*/ [
261259
ParameterFetchType.unsignedINT8,
262260
ParameterFetchType.unsignedINT32,
263261
ParameterFetchType.unsignedINT32,
264262
],
265-
[Instructions.BITWISE_AND]: [
263+
/** [Instructions.BITWISE_AND]:*/ [
266264
ParameterFetchType.unsignedINT8,
267265
ParameterFetchType.unsignedINT32,
268266
ParameterFetchType.unsignedINT32,
269267
],
270-
[Instructions.BITWISE_OR]: [
268+
/** [Instructions.BITWISE_OR]:*/ [
271269
ParameterFetchType.unsignedINT8,
272270
ParameterFetchType.unsignedINT32,
273271
ParameterFetchType.unsignedINT32,
274272
],
275-
[Instructions.NOT]: [ParameterFetchType.unsignedINT32],
276-
[Instructions.JMP_ACC]: [
273+
/** [Instructions.NOT]:*/ [ParameterFetchType.unsignedINT32],
274+
/** [Instructions.JMP_ACC]:*/ [
277275
ParameterFetchType.unsignedINT8,
278276
ParameterFetchType.unsignedINT32,
279277
ParameterFetchType.unsignedINT32,
280278
],
281-
[Instructions.GOTO]: [ParameterFetchType.unsignedINT32],
282-
[Instructions.PSH_LIT]: [ParameterFetchType.unsignedINT32],
283-
[Instructions.PSH_REG]: [ParameterFetchType.unsignedINT32],
284-
[Instructions.PSH_STATE]: [],
285-
[Instructions.POP]: [ParameterFetchType.unsignedINT32],
286-
[Instructions.CALL]: [
279+
/** [Instructions.GOTO]:*/ [ParameterFetchType.unsignedINT32],
280+
/** [Instructions.PSH_LIT]:*/ [ParameterFetchType.unsignedINT32],
281+
/** [Instructions.PSH_REG]:*/ [ParameterFetchType.unsignedINT32],
282+
/** [Instructions.PSH_STATE]:*/ [],
283+
/** [Instructions.POP]:*/ [ParameterFetchType.unsignedINT32],
284+
/** [Instructions.CALL]:*/ [
287285
ParameterFetchType.unsignedINT8,
288286
ParameterFetchType.unsignedINT32,
289287
],
290-
[Instructions.RET]: [],
291-
[Instructions.RET_TO_NEXT]: [],
292-
[Instructions.HLT]: [],
293-
[Instructions.RET_INT]: [],
294-
[Instructions.INT]: [ParameterFetchType.unsignedINT32],
295-
[Instructions.RAND]: [
288+
/** [Instructions.RET]:*/ [],
289+
/** [Instructions.RET_TO_NEXT]:*/ [],
290+
/** [Instructions.HLT]:*/ [],
291+
/** [Instructions.RET_INT]:*/ [],
292+
/** [Instructions.INT]:*/ [ParameterFetchType.unsignedINT32],
293+
/** [Instructions.PSH_IP]:*/ [],
294+
/** [Instructions.PSH_IP_OFFSETTED]:*/ [ParameterFetchType.unsignedINT32],
295+
/** [Instructions.RAND]:*/ [
296296
ParameterFetchType.unsignedINT8,
297297
ParameterFetchType.unsignedINT32,
298298
ParameterFetchType.unsignedINT32,
299299
],
300-
[Instructions.SKIP]: [ParameterFetchType.unsignedINT32],
301-
[Instructions.MODIFY_PIXEL_REG]: [], // takes all values from the register
302-
[Instructions.MODIFY_PIXEL]: [
300+
/** [Instructions.SKIP]:*/ [ParameterFetchType.unsignedINT32],
301+
/** [Instructions.INTERVAL]:*/ [
302+
ParameterFetchType.unsignedINT32,
303+
ParameterFetchType.unsignedINT32,
304+
],
305+
/** [Instructions.MODIFY_PIXEL_REG]:*/ [], // takes all values from the register
306+
/** [Instructions.MODIFY_PIXEL]:*/ [
303307
ParameterFetchType.unsignedINT8,
304308
ParameterFetchType.unsignedINT32,
305309
ParameterFetchType.unsignedINT32,
306310
ParameterFetchType.unsignedINT32,
307311
],
308-
[Instructions.RENDER]: [],
309-
[Instructions.FETCH_PIXEL_NEIGHBOR]: [
312+
/** [Instructions.RENDER]:*/ [],
313+
/** [Instructions.SLEEP]:*/ [ParameterFetchType.unsignedINT32],
314+
/** [Instructions.FETCH_IMAGE_INFO]:*/ [
315+
ParameterFetchType.unsignedINT8,
316+
ParameterFetchType.unsignedINT32,
317+
],
318+
/** [Instructions.FETCH_PIXEL_NEIGHBOR]:*/ [
310319
ParameterFetchType.unsignedINT8,
311320
ParameterFetchType.unsignedINT8,
312321
ParameterFetchType.unsignedINT32,
313322
ParameterFetchType.unsignedINT32,
314323
], // type, direction, where to check, where to put
315-
[Instructions.FETCH_PIXEL_COLOR_BY_INDEX]: [
324+
/** [Instructions.FETCH_PIXEL_COLOR_BY_INDEX]:*/ [
316325
ParameterFetchType.unsignedINT8,
317326
ParameterFetchType.unsignedINT32,
318327
ParameterFetchType.unsignedINT32,
319328
],
320-
[Instructions.FETCH_PIXEL_INDEX_BY_REG_COORDINATES]: [
329+
/** [Instructions.FETCH_PIXEL_INDEX_BY_REG_COORDINATES]:*/ [
321330
ParameterFetchType.unsignedINT32,
322331
],
323-
[Instructions.FETCH_PIXEL_INDEX]: [
332+
/** [Instructions.FETCH_PIXEL_INDEX]:*/ [
324333
ParameterFetchType.unsignedINT8,
325334
ParameterFetchType.unsignedINT32,
326335
ParameterFetchType.unsignedINT32,
327336
ParameterFetchType.unsignedINT32,
328337
],
329-
[Instructions.RGB_FROMREG_TO_COLOR]: [],
330-
[Instructions.RGB_TO_COLOR]: [ // TODO: make a literal version that takes 8bit vals instead
338+
/** [Instructions.RGB_FROMREG_TO_COLOR]:*/ [],
339+
/** [Instructions.RGB_TO_COLOR]:*/ [ // TODO: make a literal version that takes 8bit vals instead
331340
ParameterFetchType.unsignedINT8,
332341
ParameterFetchType.unsignedINT32, // TODO: this is wasteful as the RGB depth is only 8bits per channel.
333342
ParameterFetchType.unsignedINT32,
334343
ParameterFetchType.unsignedINT32,
335344
],
336-
[Instructions.COLOR_FROMREG_TO_RGB]: [],
337-
[Instructions.FETCH_IMAGE_INFO]: [
338-
ParameterFetchType.unsignedINT8,
339-
ParameterFetchType.unsignedINT32,
340-
],
341-
[Instructions.MODIFY_LUMINOSITY]: [
342-
ParameterFetchType.unsignedINT8,
343-
ParameterFetchType.signedINT32,
344-
],
345-
[Instructions.DRAW_BOX]: [
345+
/** [Instructions.COLOR_FROMREG_TO_RGB]:*/ [],
346+
/** [Instructions.DRAW_BOX]:*/ [
346347
ParameterFetchType.unsignedINT8,
347348
ParameterFetchType.unsignedINT16,
348349
ParameterFetchType.unsignedINT16,
349350
],
350-
[Instructions.DRAW_BOX_MANUAL]: [
351+
/** [Instructions.DRAW_BOX_MANUAL]:*/ [
351352
ParameterFetchType.unsignedINT8,
352353
ParameterFetchType.unsignedINT16,
353354
ParameterFetchType.unsignedINT16,
354355
ParameterFetchType.unsignedINT16,
355356
ParameterFetchType.unsignedINT16,
356357
ParameterFetchType.unsignedINT32,
357358
],
358-
[Instructions.DRAW_LINE_POINTS]: [
359+
/** [Instructions.DRAW_CIRCLE]:*/ [
359360
ParameterFetchType.unsignedINT8,
360361
ParameterFetchType.unsignedINT16,
362+
],
363+
/** [Instructions.DRAW_LINE_POINTS]:*/ [
364+
ParameterFetchType.unsignedINT8,
361365
ParameterFetchType.unsignedINT16,
362366
ParameterFetchType.unsignedINT16,
363367
ParameterFetchType.unsignedINT16,
364-
],
365-
[Instructions.DRAW_CIRCLE]: [
366-
ParameterFetchType.unsignedINT8,
367368
ParameterFetchType.unsignedINT16,
368369
],
369-
[Instructions.INTERVAL]: [
370-
ParameterFetchType.unsignedINT32,
371-
ParameterFetchType.unsignedINT32,
370+
/** [Instructions.MODIFY_LUMINOSITY]:*/ [
371+
ParameterFetchType.unsignedINT8,
372+
ParameterFetchType.signedINT32,
372373
],
373-
[Instructions.SLEEP]: [ParameterFetchType.unsignedINT32],
374-
[Instructions.LANGTONS_ANT]: [
374+
/** [Instructions.LANGTONS_ANT]:*/ [
375375
ParameterFetchType.unsignedINT32,
376376
ParameterFetchType.unsignedINT32,
377377
],
378-
[Instructions.SEEDS]: [
378+
/** [Instructions.SEEDS]:*/ [
379379
ParameterFetchType.unsignedINT32,
380380
ParameterFetchType.unsignedINT32,
381381
],
382+
/** [Instructions.DEBUG]:*/ [ParameterFetchType.unsignedINT8],
383+
382384
// TODO: SHAPE: [type, amountOfPointsToFetch].. the points need to be fetched dynamically so we can decide to do it with the fetch ins or inside our generator based on the amountOfPointsToFetch value
383-
};
385+
];

0 commit comments

Comments
 (0)