BambooBasic

Version History, and general rambling! ;)

v1_2f (Big'un)

	- New: a second web target, Web (WebGL2), in the Target menu beside Web (WebGPU). WebGPU
	  still isn't in every browser (Linux ones especially) or on older graphics, and WebGL2
	  is in practically all of them - so a game for a casual, wide audience can now run
	  anywhere. Import BBRuntimeWebGL2.decls instead of BBRuntimeWeb.decls: the same
	  functions, the same behaviour and the same pictures (checked pixel for pixel against
	  WebGPU), only what draws them differs. Which one runs is your choice when you build;
	  the page never swaps on its own. Shaders for it are GLSL (.glsl) instead of WGSL. See
	  "Building for the Web" in the docs, which now has a section on choosing between them.
	- Web examples ending _wgl are for Web (WebGL2), as _web ones are for Web (WebGPU). A set
	  of them is in the examples, and 9 - Shaders\ScreenShader_wgl.bam is the first web
	  shader example (a CRT effect).
	- Moving a web program between WebGPU and WebGL2 (by its Import line) keeps your
	  customised HTML page: only its <script> line for the runtime changes. If the Target
	  menu doesn't match the program's Import, the editor offers to switch it, as it does
	  between desktop and web.
	- When the graphics card stops responding (Windows resets the driver and the game stops
	  with "The graphics device was lost"), device_lost.txt beside the game now says more:
	  the GPU work that hadn't finished, the operation it stopped on (a draw, a copy...),
	  and, if it read memory it shouldn't have, where. Desktop only.
	- Web games no longer fail to start now and then with "Your graphics hardware can't run
	  this game in the browser" (the console said "No available adapters"). The browser can
	  have no WebGPU adapter for a moment (its GPU process starting or restarting), so the
	  runtime now asks again a few times over about 4 seconds, with each power preference,
	  before giving that message. The message now also says what fixes it when it has worked
	  before: close every window of the browser and start it again (reloading isn't enough).
	- Fixed adding a string function's result onto a String variable not compiling when the
	  function takes a number: s = s & strMid(t, i, 2) (or strLeft, strRight...) stopped with
	  "Type mismatch: Cannot assign int to std::string". The number inside the brackets was
	  mistaken for the type of the whole thing.
	- Fixed Return with an = comparison doing an assignment instead: Return a[x] = 0 now gives
	  True or False like an If would, and no longer overwrites a[x]. Desktop and web.
	- Fixed Asc() not going into an Int: b = Asc(t) (or Asc(t) + 1) stopped with "Type
	  mismatch: Cannot assign std::string to int".
	- Fixed passing a string function with sums in its brackets to your own function or
	  method: Show(strMid(t, i + 1, 1)) stopped with "expects type std::string but got int".
	  Desktop and web.
	- Asc() on the desktop now gives 128-255 for characters above 127 (accented letters, the
	  bytes of a UTF-8 £, binary data), the same as the web and strAsc. It used to give
	  negative numbers. If you added BitAnd $FF to work round it, that still works.
	- Fixed flag = b = 7 (and Local flag:Int = b = 7) changing b instead of comparing it: the
	  second = is now a comparison, so flag is True or False and b is left alone. Desktop and
	  web.
	- Numbers in scientific notation work: 2.0e-11, 1.5E+3, 1e6. The sign after the e used to
	  be split off as a minus or plus, so they wouldn't compile. Desktop and web.
	- b2dGetFPS() works on the web too (it was missing from the web runtime): frames shown
	  in the last second, the same as the desktop.
	- New: a built-in profiler. b2dShowProfiler(True) shows a panel with FPS, frame times and a
	  graph of them (stutters show as spikes), the CPU time your code used, the GPU time, the
	  number of draw calls, and your own sections: wrap code in sysProfileStart("Name") and
	  sysProfileEnd("Name") and it appears with its time and share of the frame. The figures can
	  also be read in code: b2dGetFrameTime, b2dGetGPUTime, b2dGetDrawCalls, sysProfileTime.
	  Desktop and web (on the web the GPU time is an estimate). See examples/BambooRuntime/
	  28 - Profiler.
	- Fixed the web runtime stopping when a frame drew more than about 8,000 rectangles, images
	  or text characters ("writeBuffer ... too large"): the vertex buffers now grow as needed.
	- Building a program for the wrong target is caught. If the program is a web one (it
	  imports BBRuntimeWeb.decls) but the Target menu is on Desktop, or the other way round,
	  the editor now asks before building: switch to the right target and build, build anyway,
	  or cancel. The transpilers also stop with a clear message instead of making a program
	  that crashes on start ("Failed to load BBRuntimeWeb.js" / "Bad Image").
	- Web: an Int divided by an Int is now a whole number, as on the desktop (7 / 2 = 3). It
	  used to give 3.5 in the browser, so an Int could hold a fraction and an array index
	  could miss - Local gx:Int = i / cells, garr[a / b], Print a / b. Divisions with a
	  Double in them (7.0 / 2, x / 2 where x is a Double) still give 3.5.
	- Web: ToInt() now cuts towards zero like the desktop: ToInt(-2.5) is -2 (it was -3),
	  and a tiny number such as 0.0000003 gives 0 (it could give 3).
	- New: b2dNoRuntimeSplash() starts a compiled program without the BambooBasic splash
	  screen. Call it before b2dGraphics. If the graphics can't start, a message box says why.
	- Programs that don't use AutoCall run their loops and function calls much faster. The
	  AutoCall timer check ran on every pass of every loop and read the clock each time; it's
	  now left out unless the program uses AutoCall, and skipped while no timers are set.
	  A tight loop of simple sums ran up to 28 times faster. Desktop and web.
	- New operator ShrU, a shift right that fills with zeros: -1 ShrU 28 is 15, where
	  -1 Shr 28 is -1 (Shr keeps the sign). Handy for pulling apart colours and other packed
	  32-bit values. Desktop and web., there is a point to this.
	- Fixed Print with a shift or a comparison in it not compiling: Print a Shr 1 and
	  Print "x=" & a Shr 1 now work.
	- Web: Print 1 & 2 now prints 12, as on the desktop (it added them and printed 3).
	- Hex numbers from $80000000 to $FFFFFFFF are now negative Ints, as they should be:
	  Print $FFFFFFFF gives -1 (it gave 4294967295), and comparing an Int with one works
	  properly - If x < $80000000 used to be true for x = 1. Smaller hex numbers are
	  unchanged. Desktop and web.
	- Fixed passing a global array to your own function in some places: with Global buf:Byte[8],
	  Local n:Int = Total(buf) stopped with "expects type uint8_t* but got uint8_t". Desktop
	  and web.
	- New: b2dSetImagePixels(image, pixels, width, height) fills a whole image from an Int
	  array in one call, one $AARRGGBB colour per pixel. Far quicker than b2dSetPixel for every
	  pixel, so you can draw your own pixels each frame (software rendering, plasma effects,
	  emulators). Desktop and web.
	- New: b2dSetImageSmooth(image, False) keeps an image's pixels sharp when it's drawn
	  bigger or smaller, for pixel art and retro screens. True puts the smoothing back.
	  Desktop and web.
	- New: fileReadBytes and fileWriteBytes read or write a block of bytes between a file and
	  a Byte array in one call, much quicker than a byte at a time. Desktop and web.
	- New: sound streams, for sound your program makes as it runs (a synth, a tracker
	  player, a *cough* emulator). audCreateStream(rate, channels) starts one, audQueueStream sends
	  it 16-bit samples from a Short array, audStreamQueued says how much is still waiting,
	  and audFreeStream stops it. If you fall behind it plays silence instead of stopping.
	  Desktop for now.
	- Fixed Return with an = comparison after a one-line If: If a > 0 Then Return a = b
	  assigned b to a instead of comparing them (Return on its own line was already fixed).
	  Desktop and web.
	- Byte (0 to 255) and Short (-32768 to 32767) are now documented and highlighted, with
	  three fixes: sums go back into them (b = b + 1 wouldn't compile, and nor would putting
	  a Byte array element straight into an Int); Print of a Byte shows the number instead
	  of a character on the desktop; and on the web they now wrap like the desktop's do
	  (300 in a Byte is 44, 40000 in a Short is -25536). Desktop and web.
	- New: sysArgCount(), sysArg(i) and sysCommandLine() read the command line a program
	  was started with: sysArg(1) is the first argument (quoted paths kept whole, quotes
	  taken off), sysArg(0) the program itself. On the web they read the page address's
	  ?query instead: game.html?level=3&mute gives level=3 and mute.
	- New: audSetReverb(preset, volume) puts reverb on the sound effects you play from then
	  on (not music): 1 room, 2-4 studio small/medium/large, 5 hall, 6 half echo, 7 space
	  echo, 8 chaos echo, 9 delay, 0 off. They are the PlayStation's own reverb presets,
	  worked out the same way, so a sound has the same reverb on desktop and web.
	- Fixed + with a string and a number: "Score: " + score printed part of the text or
	  garbage (Print "loaded " + 1 printed "oaded "), and "Speed " + 2.5 wouldn't compile.
	  + now joins whenever either side is a string, left to right like the web always did:
	  "a" + 1 + 2 is "a12", 1 + 2 + "a" is "3a". The same goes for & chains: "a" & n & 1
	  joins n and 1 instead of trying to OR them.
	- Fixed "Volume " & ToInt(v * 100) on the desktop: the number came out as one odd
	  character (or, with more after it, didn't compile). ToInt and ToDouble now join as
	  numbers. The web was already right.
	- New example: BambooRuntime\2 - Audio\Reverb.bam (and Reverb_web.bam) to try each
	  reverb preset and volume on a pistol shot.
	- Building is much faster. The transpiler turns big programs into C++ several times
	  quicker, and a program split into Include files is now built a file at a time: each
	  .bam becomes its own C++ file, and only the files you changed (and anything that
	  depends on them) are compiled again, several at once. Drifter Wings, a 12,000 line
	  game split into 52 files, went from 33 seconds a build to 5.5 for a full build and
	  under 2 seconds after editing a function. Desktop only (the web doesn't compile).
	  See examples/Language/20 - Multi-file
	- Build > Quick Build Mode now decides this: ticked, only what changed is built again;
	  unticked, everything is built from scratch.
	- Fixed reading a field straight off a function's result in a sum or a Print:
	  Print FurthestRight()\name stopped with a type error. Desktop and web.
	- Fixed debug builds stopping when an Element Local was declared inside a loop.
	- Fixed = inside brackets being taken as an assignment instead of a comparison:
	  b2dSetImageSmooth(img, mode = 2) set mode to 2, Show(a = 2) changed a, and
	  arr[i = 1] = 9 assigned i. An = inside brackets (a function's arguments, a
	  sub-expression, an array index) now always compares.
	- Fixed comparisons in Print: Print a = 2 assigned 2 to a (it now prints whether a is
	  2: 1 or 0, or true / false in a web browser), and
	  Print a <> 2 wouldn't compile. Desktop and web.

v1_2e

	- BGI works on the web! GUI programs now build for the Web target too. Windows, buttons,
	  lists, menus, tabs, tree and list views, toolbars, date/time pickers, rich text boxes,
	  canvases and the rest are drawn inside the page's canvas, in the same classic Windows
	  look, using Dear ImGui (built into the runtime, nothing extra to install). The same bgi
	  calls, handles and events work, so most GUI programs carry over as they are - the loop
	  body moves into WebLoop() like any web program. Designer (.bgi) files are built into the
	  program, so bgiLoadGizmos works straight away. See docs/web.html (BGI section), and the
	  *_web examples in examples/BambooRuntime/11 - BGI and 13 - Designer.
	- A browser can't stop and wait, so on the web message boxes and the open, save, colour
	  and font dialogs return at once and the answer arrives as an event - see the new
	  BGI_EVENT_ID_DIALOG, _FILEDIALOG, _COLORDIALOG and _FONTDIALOG in BBR_INCLUDE.bam. A web
	  page can't close itself either, so the main window's X folds it up to a little title
	  bar (X or a double-click opens it again); other windows close as normal.
	- The web RichTextBox does real formatting: bold, italic, underline, sizes and colours,
	  mouse selection, copy/paste and undo, and it reads and writes RTF, so files go back and
	  forth with the desktop version.
	- Added IGI, the Immediate Gizmo Interface: an in-game GUI built on Dear ImGui, for menus,
	  HUDs, debug panels and editors drawn over your game. Call the igi functions every frame
	  (values go in, new values come out: volume = igiSliderInt("Volume", volume, 0, 100)) -
	  windows, buttons, sliders, text boxes, drop-downs, lists, trees, tabs, menus, pop-ups,
	  images and more, 69 functions. Unlike BGI it's fully styleable: themes, all of ImGui's
	  colours (with ImGui's names, so shared ImGui themes copy across), roundings, sizes and
	  your own fonts. Same on desktop and web. See docs/igi.html and examples/BambooRuntime/27 - IGI.
	- IGI has a code editor: syntax colouring, line numbers, undo, marked lines with tooltips
	  (for errors), read-only and more. Languages are .lang text files you can write yourself;
	  BambooBasic (coloured like the IDE), C++, Lua, WGSL and HLSL come in userlibs\languages.
	  See the code editor section of docs/igi.html and example 05_CodeEditor.
	- Fixed strInstr on the web: it now counts from 1 and returns 0 when not found, like the
	  desktop and the docs (it used to return 0-based positions and -1).
	- Fixed a screen shader on the desktop leaving trails in 2D programs: b2dCls now clears to
	  the b2dSetClsColor colour under a screen shader too.
	- Fixed ToDouble / ToInt of a String array element (ToDouble(words[1])) not compiling on
	  the desktop, in a Print as well as anywhere else.
	- Game controllers work on the web! The same inpCreateController, button, D-pad, trigger,
	  stick and vibration calls as desktop, with the same XINPUT_GAMEPAD_* constants, using
	  the browser's Gamepad API. A browser only shows a pad once a button has been pressed on
	  it, so wait for that rather than quitting when none is found. Rumble works in Edge and
	  Chrome. See Controller_Down_web and Controller_Hit_web in examples/BambooRuntime/3 - Input.
	- Added fileExportWeb(), fileImportWeb() and fileImportWebResult() (web only), for any web
	  program: export downloads a file from the browser's storage to the user's computer, import
	  lets them pick a file to bring in (check fileImportWebResult each frame for its name).
	- Added bgiExportFileWeb() and bgiImportFileWeb() (web only): the same for BGI programs, with
	  the import's answer arriving as a BGI event. The RichTextBox web example has Export RTF
	  and Import RTF buttons to show them off.
	- File -> New -> BGI Application now asks Desktop or Web, and writes the right template
	  for each (the web one also switches the build target to Web). The designer keeps its
	  event dispatcher up to date wherever it lives, WebLoop() included.
	- Fixed the New BGI Application template using old calls that no longer exist, and the
	  designer's generated onSelect handlers calling a missing Str().
	- Designer fixes: switching tabs now saves the dialog to the right .bam.bgi, text with
	  quotes or < > & in it saves and loads properly, and nested submenus load correctly.
	- bgiProcessGizmoEvents: menu items now fire their own onClick, and list and combo boxes
	  fire onSelect. bgiLoadGizmos: empty tab controls, list views and toolbars load, and
	  nested submenus keep their items.
	- b2dSetMaxFPS now really caps the frame rate when vsync is off.
	- Tree view: renaming a node updates its text. Spinners take the full 32-bit range.
	- The b2d file dialogs could hand back a garbled file name; fixed.
	- Web target: s = s & Chr(13) (a string added to with &) no longer gets mistaken for a
	  number.
	- Web target: the right and middle mouse buttons were swapped (VMOUSE_RBUTTON read the
	  middle button and VMOUSE_MBUTTON the right); fixed.
	- The web server could randomly fail to send a script, so a page sometimes didn't start;
	  fixed.
	- Fixed small bugs in the Trigonometry, BackupRestore, Controller_Hit and TCP/UDP
	  transfer examples.
	- Docs: the designer page is rewritten, and docs/web.html has the new BGI section. The BGI
	  reference pages note where the web behaves differently.

v1_2d (Release was skipped as other things cropped up)

	- Movies are real video files now! b2dLoadMovie takes an .mp4, .mkv, .webm and so on
	  directly - the old .bbv format and its converter are gone. Same calls as before (play,
	  pause, resume, stop, loop, volume, draw, draw scaled), and the picture keeps time with a
	  real clock, so a slow frame skips rather than slowing the film down. The soundtrack plays
	  through the same audio engine as everything else. Decoding is done by Windows' own Media
	  Foundation on desktop, and by HTML5 video on the web. See examples/BambooRuntime/1 - Graphics (DrawMovie...).
	- Added b2dLoadMesh(), which loads 3D models baked to .bb3d, animated ones included. The
	  runtime stores the model and blends its animation frames; your program turns and
	  projects the points and draws the faces, the 3D-in-2D way. b2dMeshAnimate will blend ANY
	  two frames, so if a model's animation clips are rubbish (some exporters make every clip
	  the whole animation) you can still loop just the frames you want. Models with no texture
	  carry their own face colours - b2dMeshFaceR/G/B. Animation frames are compressed in the
	  file, so animated models stay small. Desktop + Web. See examples/BambooRuntime/26 - 3D in 2D (Mesh...),
	  and docs/3d_in_2d.html.
	- Added b2dFreeMesh(), to free a loaded mesh (and its texture) when you're done with it.
	  Desktop + Web.
	- Added Tools -> GLB to .bb3d Mesh Converter to the IDE, to make those models. Point it at a
	  .glb, pick a folder and a name, and it writes the .bb3d plus the texture as a .png. Skeletal
	  animation is baked to frames at the rate you choose. Afterwards it offers a preview you can
	  scrub through frame by frame, which is the way to find out which frame numbers are which
	  movement when a model's clips are no help.
	- Added b2dDrawImageQuad(), which stretches an image over any four corners, and
	  b2dDrawImageQuadDepth(), the same with a depth per corner so textured faces hide each
	  other properly without sorting. The UV versions, b2dDrawImageQuadUV and
	  b2dDrawImageQuadDepthUV, let each corner show a chosen part of the image - atlases, or
	  a model's own texture mapping. Desktop + Web. See examples/BambooRuntime/26 - 3D in 2D (ImageQuad...).
	- Added b2dLoadTTF(), which loads a .ttf/.otf font and gives back a normal font handle, so
	  every text command works with it. Glyphs are drawn as they're needed, so proper Unicode
	  works too - accents, Cyrillic, Greek, even CJK. Desktop + Web.
	- b2dDrawQuadDepth now works on the web target too.
	- Debug builds of big programs compile MUCH faster. The debugger used to send every
	  global and constant after every single line, which made the generated code enormous
	  (27 MB for Anti-Tetrafied); it now sends them only when you are actually paused, which
	  took that down to 556 KB. As a bonus, globals now show in the variables panel while you
	  are paused inside a function too, not just in Main.
	- Fixed building a string with & that includes a function returning a number, like
	  s = "Score: " & GetScore(). It would not compile unless you Printed it directly. Same
	  for a plain number (s = "Lives: " & 3).
	- Fixed & inside brackets in a Print, like Print strUpper("Lives: " & lives), which came
	  out as a bitwise OR and wouldn't compile. Also Chr() and Asc() in a Print, two string
	  literals joined with & ("a" & "b"), and & with numbers on the web target.
	- Sprite sheets (b2dLoadAnimImage) and fonts (b2dLoadFont) no longer bleed into the
	  neighbouring frame or letter when drawn small.
	- Two or more movies playing at once now all move - before, only the last one played did.
	- b2dLoadMesh returns 0 for a damaged or cut-short .bb3d file instead of crashing.
	- Mesh examples no longer draw the model tinted by the help text colour.
	- Fixed the clean-up of old build files being able to delete files OUTSIDE your project,
	  if a project folder had been copied or moved. It now only touches files inside the
	  build folders, and never a .bam.
	- Web target: True/False now come out as 1/0, like desktop, so an Int flag survives being
	  turned into a string and back.
	- Builds work with Windows 11's Smart App Control switched on. It blocks MinGW's linker
	  helper (collect2.exe), which made every desktop build fail at the link step; the IDE now
	  spots this and links with ld.exe directly instead, with the exact same settings.
	- The web server no longer gives up if another program is already using port 8000 - it
	  moves on to the next free port (8001, 8002...) and shows the real address in its window.
	  It also takes the port for itself only, so it can't end up sharing one with another
	  program, and its status now says when it fails instead of always saying "Running".
	- Added the AI Assistant (View -> AI Assistant, Ctrl+Shift+A): a Claude chat window in the
	  IDE, using your own Anthropic API key. Attach your code and it can explain it, fix build
	  errors and edit attached files for you (Ctrl+Z undoes). See docs/ai_assistant.html.

v1_2c

	- Added b2dDrawQuadDepth - like b2dDrawQuad but each corner takes its own depth
	  (0..1), interpolated per-pixel by the GPU. This is what proper "3D in 2D" wants:
	  interpenetrating and steeply-tilted faces now resolve correctly per pixel, so
	  you can draw everything in any order with no backface culling. (b2dSetDepth gives
	  a whole quad ONE flat depth, which can't separate a solid's own overlapping
	  faces - that's what this fixes.) Desktop + Web; see the "3D in 2D" doc.
	  NOTE: feed perspective-correct corner depths (a + b/z), not raw view-z.
	- New examples: "26 - 3D in 2D Stress" (rotating-cube benchmark) and
	  "27 - Quad Depth" (flat vs per-corner depth toggle), desktop + web.

v1_2b

	- Big one: the runtime is now 2D across the board. The 3D (b3d*) engine has been
	  retired so every target (Windows, Web, Linux) sits on the same 2D runtime and
	  the same API. The old 3D runtime stays available but won't be updated.
	- The handful of functions worth keeping have been renamed from b3d* to b2d*
	  (display setup, cls, flip, the frame loop, and the full-screen shaders).
	- 3D-in-2D! A few small 2D additions make real 3D possible with 2D commands:
		- b2dDrawQuad - draw an arbitrary 4-point polygon (not just rectangles)
		- b2dSetDepth - a proper per-pixel GPU depth buffer for 2D primitives, so you
		  can draw in any order and let the hardware sort out what's in front (see docs
		  + the new "3D in 2D" tutorial)
	- b2dSetClipRect / b2dClearClipRect - 2D scissor clipping.
	- Indexed images now build a full mipmap chain (no more shimmer when scaled down)
	  and the 2D texture limit is up from 256 to 512.
	- BGI canvases are now 2D-only (bgiCreateCanvas).
	- Removed the 3D tools from the IDE's Tools menu.
	- Fixes: palette-cycling text draw order, F1 detailed-help lookup, and web
	  key-repeat firing key-hits every frame.

v1_2
	
	- Another one for the codgers amongst us; Palette Cycling & Indexed Colour functions (see docs)
	- Fixed a few editor loose ends
	- Fixed FileCopy bug that would always return 0, even if the file was copied successfully
	- Added "PreCalc" block, this runs at build time, inside the transpiler, and bakes its 
	  results into your program as an array literal. (See docs) 
	- Added "AutoCall", which calls a function once/every specified amount of milliseconds... Think
	  Amstrad CPC's software interrupt mechanism... Sorry, I had to do it! ;)
	- Added With...EndWith block, for adding data to type and element fields (syntax sugar really),
	  again, see docs.
	- Added string interpolation for string variables/objects fields e.g. 
		
		Local age:Int = 49
		Print "My age is {%age}"
		
		Output: My age is 49
		
	- Added "Sequence"'s, which are BambooBasic's version of proper list containers (See docs)
	- Added Elements, which can we used with Sequence lists (Like Types, but not, again, see docs) 
	- Hopefully fixed intergrated/discrete combo GPU device crashes (and stop Window
	  updates breaking settings), also, a fall back to WARP, so the app shouldnt die when opened
	  on less-spec'd machines, though, it will probably run like shit! :D

v1_1
	
	- Added "Experimental" web target
	- Fixed screen shader code as I had hardcoded values in them when testing with the CRT shader
	- Fixed mid-frame GPU buffer resizing when dynamically adding entities.
	- Transpiler fix, detects unclosed blocks (If, Select etc etc)
	- Fixed type iteration crash when removing objects from the internal list in a For Each loop
	- Fixed jsonGetArrayCount returning the wrong value.
	- Added b3dCenterMesh(), b3dOpenFileDialog(), b3dSaveFileDialog and b3dOpenFolderDialog.
	- Fixed b3dCountTriangles for GPU meshes
	- Fixed DXGI shutdown crash (Cheers Amon)
	- Fixed b3dLoadBRSFile() function in regards to rotation.

v1_0

	- Full release... To much to add since I added 3D stuff, but, this IS the baseline now!