diff --git a/src/api/forth.c b/src/api/forth.c index c10ad8783..2a6e9335d 100644 --- a/src/api/forth.c +++ b/src/api/forth.c @@ -964,6 +964,8 @@ Err CompileCustomFunctions(void) if(CreateGlueToC("FSET", i++, C_RETURNS_VOID, 0) < 0) return -1; if(CreateGlueToC("FFT", i++, C_RETURNS_VALUE, 0) < 0) return -1; if(CreateGlueToC("FFTS", i++, C_RETURNS_VALUE, 0) < 0) return -1; + if(CreateGlueToC("RRECT", i++, C_RETURNS_VOID, 0) < 0) return -1; + if(CreateGlueToC("RRECTB", i++, C_RETURNS_VOID, 0) < 0) return -1; return 0; } @@ -1384,6 +1386,8 @@ static const char* ForthAPIKeywords[] = { "FSET", "FFT", "FFTS", + "RRECT", + "RRECTB", }; // ============================================================================= diff --git a/tests/conformance/probes/forth.fth b/tests/conformance/probes/forth.fth new file mode 100644 index 000000000..c23c6f31b --- /dev/null +++ b/tests/conformance/probes/forth.fth @@ -0,0 +1,813 @@ +\ API conformance probes for forth — the same sections as lua.lua, in the +\ same order; that file is the reference and carries the protocol notes. +\ +\ PROBE traces the marker, then runs the probe word. forth's CATCH catches a +\ THROW, and what a binding refuses is not one — a pop past the empty stack +\ reads memory rather than raising — so the sections whose call the reference +\ refuses are not in this file. Neither are the sections whose argument is a +\ string, a float, or left out: a forth word takes what the stack holds, and +\ the stack holds integers. The coverage line is what says so. +\ +\ Generated by openspec/changes/conformance-forth-probes/generate.py, whose +\ table carries each word's stack shape as src/api/forth.c comments it. + +: PROBE ( xt c-addr u -- ) + 15 TRACE + CATCH IF S" !error" 15 TRACE THEN +; + +\ ---- cls + +: P_CLS_DEFAULT + 10 10 4 PIX! + 0 CLS + 10 10 PIX DROP +; + +: P_CLS_COLOR + 7 CLS + 4 4 PIX DROP + 235 131 PIX DROP +; + +\ cls/wrong-type: the argument is a string or a float, and forth's words take integers + +: P_CLS_OUT_OF_RANGE + 0 0 6 PIX! + 99 CLS + 0 0 PIX DROP +; + + +\ ---- print + +: P_PRINT_WIDTH + S" A" 5 5 15 FALSE 1 FALSE PRINT DROP +; + +: P_PRINT_DEFAULTS + S" A" 0 0 15 FALSE 1 FALSE PRINT DROP +; + +: P_PRINT_SCALE + S" A" 5 5 15 FALSE 2 FALSE PRINT DROP +; + +: P_PRINT_FIXED + S" ii" 0 0 15 TRUE 1 FALSE PRINT DROP + S" ww" 0 10 15 TRUE 1 FALSE PRINT DROP +; + +\ print/no-args: the reference makes no call here, and a forth word always does + +\ ---- pix + +: P_PIX_WRITE + 0 CLS + 10 10 4 PIX! + 10 10 PIX DROP +; + +: P_PIX_READ + 2 CLS + 3 4 PIX DROP +; + +\ pix/missing-y: the reference refuses the call and forth's stack cannot refuse one +\ pix/no-args: the reference refuses the call and forth's stack cannot refuse one +\ pix/float-coords: the argument is a string or a float, and forth's words take integers +\ pix/string-arg: the argument is a string or a float, and forth's words take integers + +: P_PIX_OUT_OF_BOUNDS + 300 300 4 PIX! + 300 300 PIX DROP +; + + +\ ---- line + +: P_LINE_DIAGONAL + 0 CLS + 0 0 5 5 6 LINE + 0 0 PIX DROP + 3 3 PIX DROP + 5 5 PIX DROP + 5 0 PIX DROP +; + +\ line/floats: the argument is a string or a float, and forth's words take integers +\ line/missing-color: the reference refuses the call and forth's stack cannot refuse one + +: P_LINE_ONE_POINT + 0 CLS + 3 3 3 3 6 LINE + 3 3 PIX DROP +; + + +\ ---- rect + +: P_RECT_FILL + 0 CLS + 1 1 3 3 6 RECT + 1 1 PIX DROP + 3 3 PIX DROP + 4 4 PIX DROP + 0 0 PIX DROP +; + +: P_RECT_ZERO_SIZE + 0 CLS + 5 5 0 0 6 RECT + 5 5 PIX DROP +; + +: P_RECT_NEGATIVE_SIZE + 0 CLS + 5 5 -2 -2 6 RECT + 5 5 PIX DROP + 4 4 PIX DROP + 3 3 PIX DROP +; + +\ rect/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- rectb + +: P_RECTB_BORDER + 0 CLS + 1 1 4 4 6 RECTB + 1 1 PIX DROP + 2 2 PIX DROP + 4 4 PIX DROP + 5 5 PIX DROP +; + +: P_RECTB_ZERO_SIZE + 0 CLS + 5 5 0 0 6 RECTB + 5 5 PIX DROP +; + +: P_RECTB_ONE_WIDE + 0 CLS + 2 2 1 1 6 RECTB + 2 2 PIX DROP + 3 3 PIX DROP +; + +\ rectb/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- rrect + +: P_RRECT_FILL + 0 CLS + 10 10 20 20 6 4 2 RRECT + 20 20 PIX DROP + 10 20 PIX DROP + 14 10 PIX DROP + 10 10 PIX DROP +; + +: P_RRECT_ZERO_RADIUS + 0 CLS + 10 10 20 20 6 0 2 RRECT + 10 10 PIX DROP + 29 29 PIX DROP + 30 30 PIX DROP +; + +: P_RRECT_EXPONENT + 0 CLS + 10 10 20 20 6 4 4 RRECT + 12 10 PIX DROP + 11 10 PIX DROP + 10 11 PIX DROP + 10 12 PIX DROP +; + +\ rrect/missing-radius: the reference refuses the call and forth's stack cannot refuse one + +\ ---- rrectb + +: P_RRECTB_BORDER + 0 CLS + 10 10 20 20 6 4 2 RRECTB + 10 20 PIX DROP + 20 10 PIX DROP + 20 20 PIX DROP + 10 10 PIX DROP +; + +: P_RRECTB_ZERO_RADIUS + 0 CLS + 10 10 20 20 6 0 2 RRECTB + 10 10 PIX DROP + 29 10 PIX DROP + 20 20 PIX DROP +; + +: P_RRECTB_EXPONENT + 0 CLS + 10 10 20 20 6 4 4 RRECTB + 11 10 PIX DROP + 12 11 PIX DROP + 10 11 PIX DROP + 12 10 PIX DROP +; + +\ rrectb/missing-radius: the reference refuses the call and forth's stack cannot refuse one + +\ ---- mget + +: P_MGET_ZERO + 0 0 MGET DROP +; + +\ mget/missing-y: the reference refuses the call and forth's stack cannot refuse one +\ mget/string-arg: the argument is a string or a float, and forth's words take integers + +\ ---- mset + +: P_MSET_BASIC + 1 2 7 MSET + 1 2 MGET DROP +; + +: P_MSET_OUT_OF_RANGE_TILE + 5 5 999 MSET + 5 5 MGET DROP +; + +\ mset/missing-tile: the reference refuses the call and forth's stack cannot refuse one + +\ ---- peek + +: P_PEEK_ZERO + 8 0 8 POKE + 8 8 PEEK DROP +; + +\ peek/missing-addr: the reference refuses the call and forth's stack cannot refuse one + +: P_PEEK_OUT_OF_BOUNDS + 1000000 8 PEEK DROP +; + +: P_PEEK_NEGATIVE_ADDR + -1 8 PEEK DROP +; + + +\ ---- poke + +: P_POKE_BYTE + 8 42 8 POKE + 8 8 PEEK DROP +; + +: P_POKE_NIBBLE + 32 9 4 POKE + 32 4 PEEK DROP +; + +\ poke/missing-value: the reference refuses the call and forth's stack cannot refuse one + +: P_POKE_OUT_OF_BOUNDS + 1000000 1 8 POKE +; + + +\ ---- trace + +: P_TRACE_BASIC + S" hello" 15 TRACE +; + +: P_TRACE_COLOR + S" hello" 5 TRACE +; + + +\ ---- spr + +: P_SPR_BASIC + 0 CLS + 1 10 10 -1 1 0 0 1 1 SPR + 10 10 PIX DROP +; + +: P_SPR_COLORKEY + 0 CLS + 1 20 20 4 1 0 0 1 1 SPR + 20 20 PIX DROP +; + +: P_SPR_SCALE + 0 CLS + 1 30 30 255 2 0 0 1 1 SPR + 30 30 PIX DROP +; + +: P_SPR_FLIP_ROTATE + 0 CLS + 1 40 40 255 1 3 2 1 1 SPR + 40 40 PIX DROP +; + + +\ ---- map + +: P_MAP_DEFAULTS + 0 CLS + 0 0 30 17 0 0 -1 1 MAP + 0 0 PIX DROP +; + +: P_MAP_SIZE + 0 CLS + 0 0 4 4 0 0 -1 1 MAP + 0 0 PIX DROP +; + +: P_MAP_SCALE + 0 CLS + 0 0 4 4 0 0 255 2 MAP + 0 0 PIX DROP +; + + +\ ---- btn + +: P_BTN_PRESSED + 0 BTN DROP + 4 BTN DROP +; + +: P_BTN_MISSING_ID + -1 BTN DROP +; + + +\ ---- btnp + +: P_BTNP_PRESSED + 0 -1 -1 BTNP DROP +; + +: P_BTNP_HOLD_PERIOD + 0 10 5 BTNP DROP +; + + +\ ---- key + +: P_KEY_NO_KEY + 0 KEYPRESSED DROP +; + +: P_KEY_CODE + 1 KEYPRESSED DROP +; + + +\ ---- keyp + +: P_KEYP_NO_KEY + 0 -1 -1 KEYP DROP +; + +: P_KEYP_HOLD_PERIOD + 1 10 5 KEYP DROP +; + + +\ ---- mouse + +: P_MOUSE_IDLE + MOUSE 2DROP 2DROP 2DROP DROP +; + + +\ ---- circ + +: P_CIRC_FILL + 0 CLS + 20 20 5 6 CIRC + 20 20 PIX DROP + 25 20 PIX DROP +; + +: P_CIRC_ZERO_RADIUS + 0 CLS + 30 30 0 6 CIRC + 30 30 PIX DROP +; + + +\ ---- circb + +: P_CIRCB_BORDER + 0 CLS + 20 20 5 6 CIRCB + 20 20 PIX DROP + 25 20 PIX DROP +; + +\ circb/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- elli + +: P_ELLI_FILL + 0 CLS + 40 40 6 3 6 ELLI + 40 40 PIX DROP + 46 40 PIX DROP +; + +: P_ELLI_ZERO_RADIUS + 0 CLS + 40 40 0 0 6 ELLI + 40 40 PIX DROP +; + + +\ ---- ellib + +: P_ELLIB_BORDER + 0 CLS + 40 40 6 3 6 ELLIB + 40 40 PIX DROP + 46 40 PIX DROP +; + +\ ellib/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- paint + +: P_PAINT_FILL + 0 CLS + 5 5 6 -1 PAINT + 0 0 PIX DROP + 239 135 PIX DROP +; + +\ paint/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- tri + +: P_TRI_FILL + 0 CLS + 0 0 10 0 0 10 6 TRI + 0 0 PIX DROP + 5 0 PIX DROP + 10 10 PIX DROP +; + +\ tri/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- trib + +: P_TRIB_BORDER + 0 CLS + 0 0 10 0 0 10 6 TRIB + 0 0 PIX DROP + 5 0 PIX DROP +; + +\ trib/missing-color: the reference refuses the call and forth's stack cannot refuse one + +\ ---- ttri + +: P_TTRI_BASIC + 0 CLS + 0 0 10 0 0 10 0 0 1 0 0 1 0 -1 0 0 0 FALSE TTRI + 0 0 PIX DROP + 5 0 PIX DROP +; + +: P_TTRI_CHROMAKEY + 0 CLS + 0 0 10 0 0 10 0 0 1 0 0 1 0 4 0 0 0 FALSE TTRI + 0 0 PIX DROP +; + + +\ ---- clip + +: P_CLIP_SET + 0 CLS + 2 2 5 5 CLIP + 0 0 10 10 6 RECT + 0 0 PIX DROP + 2 2 PIX DROP + CLIP0 +; + +: P_CLIP_RESET + 0 CLS + CLIP0 + 0 0 2 2 6 RECT + 0 0 PIX DROP +; + + +\ ---- font + +: P_FONT_TEXT + 0 CLS + S" ab" 0 0 -1 6 6 FALSE 1 FALSE FONT DROP + 0 0 PIX DROP +; + + +\ ---- sfx + +: P_SFX_BASIC + 0 0 0 -1 0 15 0 SFX +; + +: P_SFX_NOTE + 0 0 4 -1 0 15 0 SFX +; + +: P_SFX_CHANNEL + 0 0 4 -1 1 15 0 SFX +; + +\ sfx/missing-id: the reference refuses the call and forth's stack cannot refuse one + +\ ---- music + +: P_MUSIC_BASIC + -1 0 0 FALSE FALSE -1 -1 MUSIC + 0 -1 -1 TRUE FALSE -1 -1 MUSIC +; + +: P_MUSIC_FRAME + -1 0 0 FALSE FALSE -1 -1 MUSIC + 0 0 0 TRUE FALSE -1 -1 MUSIC +; + + +\ ---- fget + +: P_FGET_OUT_OF_RANGE + 500 0 FGET DROP +; + + +\ ---- fset + +: P_FSET_ROUNDTRIP + 0 0 TRUE FSET + 0 0 FGET DROP +; + +\ fset/missing-bool: the reference refuses the call and forth's stack cannot refuse one + +\ ---- peek1 + +: P_PEEK1_READ + 16 PEEK1 DROP +; + + +\ ---- poke1 + +: P_POKE1_ROUNDTRIP + 16 7 POKE1 + 16 PEEK1 DROP +; + + +\ ---- peek2 + +: P_PEEK2_READ + 24 PEEK2 DROP +; + + +\ ---- poke2 + +: P_POKE2_ROUNDTRIP + 24 300 POKE2 + 24 PEEK2 DROP +; + + +\ ---- peek4 + +: P_PEEK4_READ + 64 PEEK4 DROP +; + + +\ ---- poke4 + +: P_POKE4_ROUNDTRIP + 64 9 POKE4 + 64 PEEK4 DROP +; + + +\ ---- memset + +: P_MEMSET_BYTES + 48 7 2 MEMSET + 48 8 PEEK DROP + 49 8 PEEK DROP +; + + +\ ---- memcpy + +: P_MEMCPY_COPY + 56 1 8 POKE + 57 2 8 POKE + 60 56 2 MEMCPY + 60 8 PEEK DROP + 61 8 PEEK DROP +; + + +\ ---- pmem + +: P_PMEM_READ + 0 PMEM DROP +; + +: P_PMEM_WRITE_READ + 0 PMEM DROP + 42 0 PMEM! + 0 PMEM DROP +; + +\ pmem/out-of-range: the reference refuses the call and forth's stack cannot refuse one + +\ ---- time + +: P_TIME_STUB + TIME DROP +; + + +\ ---- tstamp + +: P_TSTAMP_STUB + TSTAMP DROP +; + + +\ ---- fft + +: P_FFT_SAMPLE + 0 -1 FFT DROP +; + + +\ ---- ffts + +: P_FFTS_SPECTRUM + 0 -1 FFTS DROP +; + +\ fftr/range: no word in src/api/forth.c +\ fftrs/range: no word in src/api/forth.c +\ vqt/read: no word in src/api/forth.c +\ vqts/read: no word in src/api/forth.c +\ vqtr/read: no word in src/api/forth.c +\ vqtrs/read: no word in src/api/forth.c +\ vqtw/read: no word in src/api/forth.c +\ vqtsw/read: no word in src/api/forth.c +\ vqtrw/read: no word in src/api/forth.c +\ vqtrsw/read: no word in src/api/forth.c + +\ ---- vbank + +: P_VBANK_SWITCH + 1 VBANK DROP + 0 VBANK DROP +; + +\ vbank/no-args: the reference makes no call here, and a forth word always does + +\ ---- sync + +: P_SYNC_DEFAULTS + 0 0 FALSE SYNC +; + +: P_SYNC_MASK + 32767 0 FALSE SYNC +; + + +\ ---- exit + +: P_EXIT_CALL + EXITGAME +; + + +\ ---- reset + +: P_RESET_CALL + RESET + S" done" 15 TRACE +; + + +: TIC + ['] P_CLS_DEFAULT S" #cls/default" PROBE + ['] P_CLS_COLOR S" #cls/color" PROBE + ['] P_CLS_OUT_OF_RANGE S" #cls/out-of-range" PROBE + ['] P_PRINT_WIDTH S" #print/width" PROBE + ['] P_PRINT_DEFAULTS S" #print/defaults" PROBE + ['] P_PRINT_SCALE S" #print/scale" PROBE + ['] P_PRINT_FIXED S" #print/fixed" PROBE + ['] P_PIX_WRITE S" #pix/write" PROBE + ['] P_PIX_READ S" #pix/read" PROBE + ['] P_PIX_OUT_OF_BOUNDS S" #pix/out-of-bounds" PROBE + ['] P_LINE_DIAGONAL S" #line/diagonal" PROBE + ['] P_LINE_ONE_POINT S" #line/one-point" PROBE + ['] P_RECT_FILL S" #rect/fill" PROBE + ['] P_RECT_ZERO_SIZE S" #rect/zero-size" PROBE + ['] P_RECT_NEGATIVE_SIZE S" #rect/negative-size" PROBE + ['] P_RECTB_BORDER S" #rectb/border" PROBE + ['] P_RECTB_ZERO_SIZE S" #rectb/zero-size" PROBE + ['] P_RECTB_ONE_WIDE S" #rectb/one-wide" PROBE + ['] P_RRECT_FILL S" #rrect/fill" PROBE + ['] P_RRECT_ZERO_RADIUS S" #rrect/zero-radius" PROBE + ['] P_RRECT_EXPONENT S" #rrect/exponent" PROBE + ['] P_RRECTB_BORDER S" #rrectb/border" PROBE + ['] P_RRECTB_ZERO_RADIUS S" #rrectb/zero-radius" PROBE + ['] P_RRECTB_EXPONENT S" #rrectb/exponent" PROBE + ['] P_MGET_ZERO S" #mget/zero" PROBE + ['] P_MSET_BASIC S" #mset/basic" PROBE + ['] P_MSET_OUT_OF_RANGE_TILE S" #mset/out-of-range-tile" PROBE + ['] P_PEEK_ZERO S" #peek/zero" PROBE + ['] P_PEEK_OUT_OF_BOUNDS S" #peek/out-of-bounds" PROBE + ['] P_PEEK_NEGATIVE_ADDR S" #peek/negative-addr" PROBE + ['] P_POKE_BYTE S" #poke/byte" PROBE + ['] P_POKE_NIBBLE S" #poke/nibble" PROBE + ['] P_POKE_OUT_OF_BOUNDS S" #poke/out-of-bounds" PROBE + ['] P_TRACE_BASIC S" #trace/basic" PROBE + ['] P_TRACE_COLOR S" #trace/color" PROBE + ['] P_SPR_BASIC S" #spr/basic" PROBE + ['] P_SPR_COLORKEY S" #spr/colorkey" PROBE + ['] P_SPR_SCALE S" #spr/scale" PROBE + ['] P_SPR_FLIP_ROTATE S" #spr/flip-rotate" PROBE + ['] P_MAP_DEFAULTS S" #map/defaults" PROBE + ['] P_MAP_SIZE S" #map/size" PROBE + ['] P_MAP_SCALE S" #map/scale" PROBE + ['] P_BTN_PRESSED S" #btn/pressed" PROBE + ['] P_BTN_MISSING_ID S" #btn/missing-id" PROBE + ['] P_BTNP_PRESSED S" #btnp/pressed" PROBE + ['] P_BTNP_HOLD_PERIOD S" #btnp/hold-period" PROBE + ['] P_KEY_NO_KEY S" #key/no-key" PROBE + ['] P_KEY_CODE S" #key/code" PROBE + ['] P_KEYP_NO_KEY S" #keyp/no-key" PROBE + ['] P_KEYP_HOLD_PERIOD S" #keyp/hold-period" PROBE + ['] P_MOUSE_IDLE S" #mouse/idle" PROBE + ['] P_CIRC_FILL S" #circ/fill" PROBE + ['] P_CIRC_ZERO_RADIUS S" #circ/zero-radius" PROBE + ['] P_CIRCB_BORDER S" #circb/border" PROBE + ['] P_ELLI_FILL S" #elli/fill" PROBE + ['] P_ELLI_ZERO_RADIUS S" #elli/zero-radius" PROBE + ['] P_ELLIB_BORDER S" #ellib/border" PROBE + ['] P_PAINT_FILL S" #paint/fill" PROBE + ['] P_TRI_FILL S" #tri/fill" PROBE + ['] P_TRIB_BORDER S" #trib/border" PROBE + ['] P_TTRI_BASIC S" #ttri/basic" PROBE + ['] P_TTRI_CHROMAKEY S" #ttri/chromakey" PROBE + ['] P_CLIP_SET S" #clip/set" PROBE + ['] P_CLIP_RESET S" #clip/reset" PROBE + ['] P_FONT_TEXT S" #font/text" PROBE + ['] P_SFX_BASIC S" #sfx/basic" PROBE + ['] P_SFX_NOTE S" #sfx/note" PROBE + ['] P_SFX_CHANNEL S" #sfx/channel" PROBE + ['] P_MUSIC_BASIC S" #music/basic" PROBE + ['] P_MUSIC_FRAME S" #music/frame" PROBE + ['] P_FGET_OUT_OF_RANGE S" #fget/out-of-range" PROBE + ['] P_FSET_ROUNDTRIP S" #fset/roundtrip" PROBE + ['] P_PEEK1_READ S" #peek1/read" PROBE + ['] P_POKE1_ROUNDTRIP S" #poke1/roundtrip" PROBE + ['] P_PEEK2_READ S" #peek2/read" PROBE + ['] P_POKE2_ROUNDTRIP S" #poke2/roundtrip" PROBE + ['] P_PEEK4_READ S" #peek4/read" PROBE + ['] P_POKE4_ROUNDTRIP S" #poke4/roundtrip" PROBE + ['] P_MEMSET_BYTES S" #memset/bytes" PROBE + ['] P_MEMCPY_COPY S" #memcpy/copy" PROBE + ['] P_PMEM_READ S" #pmem/read" PROBE + ['] P_PMEM_WRITE_READ S" #pmem/write-read" PROBE + ['] P_TIME_STUB S" #time/stub" PROBE + ['] P_TSTAMP_STUB S" #tstamp/stub" PROBE + ['] P_FFT_SAMPLE S" #fft/sample" PROBE + ['] P_FFTS_SPECTRUM S" #ffts/spectrum" PROBE + ['] P_VBANK_SWITCH S" #vbank/switch" PROBE + ['] P_SYNC_DEFAULTS S" #sync/defaults" PROBE + ['] P_SYNC_MASK S" #sync/mask" PROBE + ['] P_EXIT_CALL S" #exit/call" PROBE + ['] P_RESET_CALL S" #reset/call" PROBE +;