Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - MrD

Pages: [1]
General chat / Request: Built-in Yabasic Programs
« on: July 09, 2015 »
Does anybody have text file copies of the programs that are built into PS2 Yabasic: the cube, fractal, blobs, worms, etc?


    Wotcher folks!

I've reimplemented the PS2 Yabasic environment in JavaScript.

Tokeniser, parser, lexer, compiler and runtime all written from the ground up. Uses HTML5 canvas, but has a super special (terrible) low-level graphics engine with all the commands written from scratch, so there's no horrible HTML5 antialiased lines ruining your nice demos. The graphics pane is 640x512, so everything should look as good as it can. You'll need a fairly beefy computer to run this. Doesn't require WebGL.

It's more accurate than the Win32 one in some respects, and less accurate than others. Text alignment works in mine, doesn't in Win32, so games/xalthorn/gemocide.txt's tips screen looks better on mine.

It doesn't play very nice with programs that draw to the active display buffer, as it uses double buffering by default. You shouldn't be doing that anyway, right? :)

The menu on the left contains all the sample programs from the archive on the YABASIC Source Code Resource Page ( ), as well as a couple of special guest programs by fizzer of TITAN. You can click any of them to magically AJAXily load them into the editor. Alternatively, the Open and Save buttons let you load/save .txt files from your local computer.

Runs best in Chrome-based browsers.

Things it does do:
  • Keyboard input pretending to be port0 PS2 pad.
  • Run pretty much everything!
  • It compiles complex expressions containing only constants and non-symbol-table-interacting-functions into single values!
  • INKEY$ works, but it returns a strange tangle of the controller mapped onto the keyboard as well as the 'character you would have typed' behaviour of the USB keyboard.
  • Has that weird behaviour where PI and EULER are treated as predefined constants until you over-assign them and then they take on your values.
  • INPUT and INPUT$ are in, and have the strange behaviour where they store up a buffer of characters and eat them up on each variable request. So if you have INPUT a$,b$ : INPUT c,d$,e$ and type in "I want 3 cats please" on the first prompt, the variables all land in their correct places without any further prompts.
  • BEEP (only if you put ?beep in the query string)
  • By complete coincidence, both my MJSYabasic and the original Yabasic sources both compile the program to a weird and compact stack machine representation. You can see a printable ASMlike representation of your program with the Disassemble program, just for kicks. (This is for debugging if you're feeling bonkers. I intended it to allow you to copy and paste it into a separate runtime, so you can use my opcode splatter as input to your own Yabasic runtime outside of JS. (If you're mad.))

Things it doesn't do:
  • Scoped arrays. All arrays are global.
  • Work in the PS3 built-in NetFront browser. BOO! It probably works in any newish Chromium or Firefox in OtherOS, but I don't own a PS3 to see.
  • There aren't any key bindings for port1. Sorry, player two.
  • No HTML5 Gamepad API. I could put it in, but all pads are different (don't believe Ondore's/MDNs lies), so it means making a button selection/calibration screen and all the rest.
  • I don't know if real Yabasic lets you have array references in your own SUBs, but in my one you can't. The only two Yabasic library functions that use array references are TOKEN and SPLIT, which are implemented in my page as special cases of the expression system. This means that apps/xalthorn/clock.txt works!
  • The text slicing functions are not leftvalues. Only one program, games/peterstock/ps2tris.txt, does this, to assign to RIGHT$("Player x", 1) = str$(playerno) to replace the x with the player number. A whole load of work for something you shouldnae be doing, so I didn't implement it. The version of ps2tris.txt in my samples pane is modified to use "Player " + str$(playerno) instead.
  • INPUT and PRINT are lousy. I've found that most existing programs only used those for debugging anyway. Stick to PRINT [single argument] for best results.
  • INKEY$, INKEY$() and INKEY$(n) all return "" instantly, because I haven't done that yet.
  • FOR loops assume that the step and limit values are constant. I've just found a program which DOESN'T assume that, which is a bugger. (for x = 1 to 32 step x : print x : next x should print ascending powers of two, but mine doesn't yet) Fixed the FOR loops so that their starting value, limit and step are always evaluated every loop (even though obviously the start value isn't used). This fixes

Most modern tablets and phones will run the page wonderfully, but there's the problem of requiring a keyboard for input. You can focus the textbox to bring it up, but aaah, yeah. Bluetooth ones might work! Haven't got one to try.

ESC/CTRL/RETURN/SPACE/[END Yabasic command] exits the fullscreen view.

Pass on the word to Parabellum, Doc, Jimshaw, Xalthorn, Shockwave and all the rest of the Yabasic gang for a nostalgia rush!

- MrD

yabasic@mrdic [...] .net[/list]

Pages: [1]