Dark Bit Factory & Gravity
GENERAL => General chat => Topic started by: MrD on May 31, 2015
-
Wotcher folks!
http://www.mrdictionary.net/yabasic/
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 yabfiles.zip archive on the YABASIC Source Code Resource Page ( http://members.iinet.net.au/~jimshaw/Yabasic/yabres/yabres.html ), 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 http://www.dbfinteractive.com/forum/index.php?topic=5944.0
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 (https://www.youtube.com/watch?v=5_YFkUfOy4s). 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!
Cheers
- MrD
yabasic@mrdic [...] .net[/list]
-
WOW! This sounds great! I'll have to try this out.
If it supports GTriangles without too much slowdown, I'll be able to improve my glowb program.
-
Thanks for the warm welcome :)
If you find a program that doesn't work, let me know and I'll try to kick my page into shape.
Now supports dots in identifier names (SERIOUSLY? dots in identifiers, but no objects. what.) so now Tetra Card Game ( http://www.dbfinteractive.com/forum/index.php?topic=2388.0 ) runs. :)
Now supports numeric RESTORE labels, so the triangle game by Tappi ( http://www.dbfinteractive.com/forum/index.php?topic=1284.0 ) works.
-
I think in rain_storms raycaster http://www.dbfinteractive.com/forum/index.php?topic=1163.0 there are some labels which are supposed to be subroutine-local (the labels 01 and 02 are used in two different situations), but I don't acknowledge duplicate labels in my version.
If you take out the label problem (replace with other labels) and inkey$, rain_storms raycaster works!
This also revealed that I had a serious oversight where all arrays were forced local scope instead of forced global scope, oops. All arrays are supposed to be global in my version.
Becauase JavaScript needs to return fully to update the user interface, here's something you might find interesting:
I need to fully return from everything and schedule another function in order to pretend to be constantly running. For double buffered programs, I can return fully when a setdispbuf changes the visible screen (you'd want that aligned with the vblank so that's great). I can't do that for programs which don't use the double buffers, so I've had to make a decision to abort after N opcodes or M drawing operations (this is quite a small number). This means that demos/balroq/cavefly.txt now has an extra cool looking sequence where the first frame is drawn a triangle at a time, due to it not setting the draw and disp buffers apart until the end of the first frame. :)
-
Matt you are a legend. This is beyond cool.
Love the whole thing but especially that you can load up all of the files from Jim's archive.
It is 2AM right now but this is amazing and I'll be playing some of the old games (Shockwave's Tank Zone is 13 years old!) all week.
-
Wow, awesome work, MrD!
K+ :cheers:
I watched a number of demo's from shockwave, jim and xalthorn, excellent stuff! :clap:
I'm going to take a look at tank zone now. :)
-
WOW What a Amazing Work you have done :clap:
-
Now supports dots in identifier names (SERIOUSLY? dots in identifiers, but no objects. what.) so now Tetra Card Game ( http://www.dbfinteractive.com/forum/index.php?topic=2388.0 ) runs. :)
Haha, that's my dot notation. How embarrassing. That was done long ago - and it was done with no real intention of ever being objects (obviously), I just liked the look of it (call my ignorance).
As to the JS compiler - holy! Great work. That's intense to get it working in a browser. Runs quite smoothly in Firefox 38.0.1 on my PC.
Karma+
-
That was a poke at Yabasic, not you. :) I'm just surprised that it treats the character as if it were any other character, like an underscore. You're the only person to have tried it!
-
A mighty welcome, and wow!!
welldone!! :)
-
I just updated the online version to remove runtime arity awareness.
Up until now, every time any EVAL ran (any Yabasic command or symbolic maths operation), it would check the arity of the call (stored in the opcode) to make sure you were calling it right. But now that's the compiler's job, and there's one less parameter flying around every single tick. Yay.
-
Fixed some bugs. Made the editor visible in IE. Added an optional compatibility mode that forces all 'visible buffer' draws to flush to screen immediately instead of waiting for 20 writes.
This means that games that draw static screens to the visible buffer than enter a loop to draw their title screen will work instead of showing a black screen (games/doctor/... does this a lot). It'll slow down any graphical effects that draw to visible (Paccy's loading screen will be horribly slow as it'll wait vblank for every one of the 400 1-pixel-wide lines it draws as part of its progress bars.) but at least everything works now!
-
Sounds like I have something to do when I get home from work tonight! 😊
-
I've got the syntax for the INKEY$ call down now. It's really a function call that happens to have three different ways of invocation: INKEY$ without brackets waits indefinitely for key, INKEY$() same, INKEY$(n) has a timeout of n before returning "". But all three handle -held- keys a little differently. Which is nice. I don't think any other Yabasic returny-type function can be invoked without brackets. I've treated TIME$ and DATE$ as special cases of missing variables like PI and EULER so they can be over-assigned (for whatever crazy reason you want to do that for). It doesn't seem accurate, come to think of it, but the over-assigning behaviour I already had works, so there's no reason to make TIME$ and DATE$ functionlike keywords instead of magic variables now.
Making the big array of 200 values for unshifted and shifted INKEY$ values is a job for another time.
-
Fine. INKEY$ is done!
-
I've had an evening of pure fun with this and in some respects I think that the emulator has actually improved the way that some of the more intensive programs run, I especially enjoyed watching Fryer's stuff running at 50fps and tankzone in full frame rate, I never thought I'd see the day :)
Thanks for this emulator!
-
You're welcome. :P
-
INPUT is in, which makes demos/jinx/prismdmo.txt work!
I think that about wraps it up for Yabasic. :)
-
I don't know if any of the yabasic versions did this, but how about being able to play music / sound effects?
btw, the rafryer/fastz.txt demo doesn't run.
-
btw, the rafryer/fastz.txt demo doesn't run.
Yes, it does.
-
Great stuff! Bringing it to Apple and tablet users everywhere :)
Jim
-
Glad you like it, Jim. :)
If somebody has an Apple/Android tablet with a bluetooth keyboard, could you please give it a go? I'm curious if the browser still gets keystrokes even if the input box isn't selected. I've been told that for tablet browsers, the text area has to be focused for the page to receive keystrokes even when you're using a physical keyboard (which sounds daft to me).
-
Latest modifications:
I've made the string literal recognition more lenient to allow accented characters through. This is part of my attempt to get YA-GOLF below working. I foolishly assumed that the JavaScript \w word character symbol in a regex would catch accented characters. Big load of nope.
As a consequence, you should now be able to write Japanese characters directly into a Yabasic program, if that floats your boat. Bear in mind that Unicode JS is SERIOUSLY FLAWED (https://mathiasbynens.be/notes/javascript-unicode)here (http://www.dbfinteractive.com/forum/index.php?topic=5801.5), but it's the last big thing I've got to get working, so I'm putting here as a reminder to myself.
It compiles, runs and gets to the language select! :D
It goes haywire if you press F1/F2. (Actually these are the default mappings for L3 and R3 in Jim Shaw's PS2Yabasic, so the game is very emulator-targeted... (It even starts with a warning screen telling you how to configure the emulator correctly.) I was going a bit crazy looking for an INKEY that wasn't there for a while.)
-
You gotta change a var from 0 to 1 near the top to make the F1 game playable. It looks great!
-
Did anyone ever find a method to ( easily ) transfer Yabasic projects from the PS2 to PC ( and vice versa )?
-
There was a cheat disk you could buy (Action Replay 2) which came with a usb transfer cable and disk so you could transfer saves/new cheats back and forth between console and pc. I discovered this a few years after spending a summer typing in code by hand, naturally :P
-
Great! I'm glad to see people still interested in yabasic.
You have done a really good work!
I've read you want to make yabasic games get working, including my game' ya-golf'... hope you can do it!
I tried several of my demos and games and unfortunatelly, most of them don't work, specially the
newest ones, when i'm using some DATA lines containing bitmaps and personalized fonts compressed
using characters from the original Ps2 YABASIC ASCII CHARACTERS TABLE that are MISSING.
I guess is a tough work to do but hang on it!
If i can help you anyway don'd doubt write me.
I'll be around posting more yabasic games and demos and trying to make it run in your page.
Maybe source code games should have an option to use EMU controls or WEB controls
since may be a port/keyboard input strings conflict.
So excited, anybody could play a yabasic game from the web.
GRET WORK, keep on goin'!
-
Great job! :clap: :clap: :clap:
If, in addition, you could add 2.763 Yabasic features and other capabilities (sound, image file manipulation ...) Yabasic could continue to evolve to a more complete and fun BASIC dialect.
-
Hi Sergio, Galileo, glad you like it!
Sergio: I'm afraid I don't know why your code isn't working in my system. It's hard for me to fix the problem as your golf game is quite a big program :) If you can make a small example program (just 150 lines maybe) that my code doesn't run correctly, then I can fix the problems one by one.
-
Hi mrD! I've been looking at your source, it's a great job you've done! My game yagolf is certanly a big (and very crappy) source code. In fact, i think the best i can do is re-write all from the beginning. There are lots of errors not only in this game but also in most of my demos. Most of them because of my crappy code im afraid. I guess i could start coding short demos for your emu especifically (inkey$ conflicts with peek("port1") ) and see what happens. Anyway, thanks for your big job! See you around!
-
I think Jim's yabasic version is based some of the same source code as the PS2 version. If your code does different things on Windows and on the browser, I think my code is wrong.
I used all of the old Yabasic programs to test my code - if one of the demos didn't run, something was definitely wrong with my code and I could fix it. My Javascript version is far from perfect! So don't be discouraged! :) That's why I need more test programs.
You're right about inkey$ and peek("port1") not being nice together... I would need to write a game pad layer to have it working accurately. (HTML5 can do this!)
Have fun programming :D
-
-
1) You can write a condition 'IF' without ENDIF. This is legal and if condition matches,the rest of the line is executed, but you can leave it blank or just add some remark.
This is perfectly legal in ps2 and jim's emu:
IF condition=matches:REM ! TO DO SOME STUFF...LATER!
In the js it's an error. Usually nobody writes a condition and leaves it blank... but in a
crappy code of 10000 lines it may happen... of course, just deleting that line or comment it
will solve problem.
I'll have to check that out!
In my code, IF tries to attach itself to the next command that comes after it. It's not an error to have 'IF condition' by itself on a line.
print "type in a value"
input x
if x > 3
print "big x"
print "end of program"
end
But it looks like in your example yabasic should treat REM as a command even though it doesn't do anything.
My compiler removes all REMs from the source in the first pass.
I've never heard of LINE INPUT before. Yikes!
-
Well now I'm just plain confused.
I put in the IF behaviour I just described because I was sure that certain programs needed it, but looking at two other implementation of Yabasic neither of them consider the 'big x' line to be contained within the IF.
Which basically means I need to go back and rethink how I parse conditionals entirely.
How on earth did that happen?
-
SO
The sticky IF never progresses beyond the current line!
"big x" is always printed! An IF on a line by itself conditionally executes the nothing that succeeds it!
And none of the demos I currently have rely on this behaviour!
Weird as hell.
Gotta fix that for sure.
-
I've fixed the strange IF behaviour, and decided against getting the undocumented token$() working. I put in a replacement, so now we can play two new /games/! tonironkko/freecell.txt and tonironkko/potris.txt are now working!
TOKEN$(string_variable, separator)
returns contents of string_variable up to separator or end of string if it isn't present
sets string_variable to what is left after what was returned with the trailing separator replaced
It's one of the few functions that deals in references to variables so I don't bother. Don't use token$()!
-
;D
-
Did anyone ever find a method to ( easily ) transfer Yabasic projects from the PS2 to PC ( and vice versa )?
You can read Yabasic files from PS2 memory card with PS2 Linux Kit. The file has a checksum which needs to be removed in a text editor to make the code is usable in an emulator. You can write files back to PS2 memory card with yabwrite http://softagalleria.net/yabwrite.php
The process is fairly easy but getting PS2 Linux kit may be a challenge. Mine broke down years ago. Might have the dvd lying around somewhere...
-
-
I see! Thank you Sergio! That explains a lot. :)
Yes, because I'm just using ordinary Javascript strings, everything is encoded using unicode values, so if you type in a non a-z, A-Z character, the ASC values will be completely different! I think I'll have to re-make strings completely so that they use the exact same values as proper Yabasic. (This means you won't be able to use characters outside of Yabasic's set though.)
And the formatting stuff is familiar to me from other languages. :) I didn't know yabasic could do that!
-
mrD, well, i guess i'm just giving you headaches...
I have to say that i've started to code for another languajes like PUREBASIC, so i'm not using yabasic too much at this point, but still have lots of great stuff: A point and click game that looks amazing for yabasic (needs translation to english) an adictive hovercraft racer game with IA, a sokoban with thousands levels... and everything with a nice zooming and scrolling graphic engine... yeahh.. great stuff... and it will be so good if it can be played someday in the MJS!
And if it can't be done, don't worry, it's so hard to do that in a browser, where most of the controls of the game can cause brower to perform some unwanted action... not to talk about all that unicode mess... yeah! once more,thanks for your work, i appreciate so much and will keep an eye to MJS from time to time. :cheers:
-
Don't worry about it. :) Good luck with your programming!
I fixed the ASC problem, and the STR$ %f formatting (mostly)
All I need to do is fix LINE INPUT (which I've got to figure out)
-
Graet work fixing those ASC values and string frormats MrD!
I've also readed and replyed your another 2 post related to me.
In this times when everybody is sayin' not too much is happenning here, i hope nobody will care if i'm posting too much...
The MJS is a good project for a good languaje that many people love, but not too many people is using it right now...due to very important limitations and no languaje development. I'ts a shame for a languaje that many of us have been using end like this.
I first learned locomotive BASIC (for AMSTRAD CPC) at the 8 bit era... when i saw "ps2 yabasic" in a playstation 2 demo disc and try it... i thought it was really a powerfull BASIC then start learn yabasic.
As the time pass by... i realiced that by the time i started to code some interesting stuff... languaje was already totally dead.. so sad.
The MJS keeps illusion for yabasic alive!
Made it in a browser is a tough work i guess!
Controls for MJS are really a problem... when u press ARROW and, instead of move a character, you SCROLL THE PAGE! :D or... pressing [BACKSPACE] to do some action in the game, then the browser switches BACK to previous WEB PAGE! wow! So many troubles...
But i said so many times i love yabasic. As you work for mjs yabasic, i'll still do.
See ya!
-
Controls for MJS are really a problem... when u press ARROW and, instead of move a character, you SCROLL THE PAGE! :D or... pressing [BACKSPACE] to do some action in the game, then the browser switches BACK to previous WEB PAGE! wow! So many troubles...
That's why the gamepad is emulated with the letter keys. :)
I treat keyboards as a special thing that few Yabasic users would have - it's all about the fake pad with Mjsyabasic :)