• Welcome to Dark Bit Factory & Gravity.
 

PS2 Yabasic reimplemented in JavaScript

Started by MrD, May 31, 2015

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Jim

Great stuff!  Bringing it to Apple and tablet users everywhere :)

Jim
Challenge Trophies Won:

MrD

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).

MrD

#22
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 still.

I've changed the behaviour of RESTOREs in compilation (originally wrote the awesome freudian slip "complication" there) too: I had them as a compilation error, but some programs have RESTOREs to non-existent labels due to moving code about. (Lazy, but PS2 Yabasic has no search and replace, so I can't really blame 'em.) I've made my compile compile these RESTOREs into static runtime errors. (Literally RESTORE doesnt_lead_anywhere becomes PRINT "Error: RESTORE to nonexistent label" : END)

And also I finally implemented textual NOT operator. Not one of the archive programs used it until I found these! It just never came up...

-

Putting these progs here for safekeeping.

SIX BALL POOL, by CanardDeChien.

Works in MJS Yabasic! (The controls screen is awful because of the repeated PEEK loop used to check for the Select button... you can see it nicer if you turn on the compatibility mode.)


PS2 Yabasic F1 Game, by Stonemonkie.

Works in MJS Yabasic! Seems to be a running demo, but DAMN does it run!


YA-GOLF MINI Supper Challenge 0.5.2, by Sergio Baño Soeiro

I know this has already been posted on the forum here, 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.)

Yaloopy

You gotta change a var from 0 to 1 near the top to make the F1 game playable. It looks great!
Fuck L. Ron Hubbard and fuck all his clones.
Challenge Trophies Won:

moon

Did anyone ever find a method to ( easily ) transfer Yabasic projects from the PS2 to PC ( and vice versa )?

slinks

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
I love semi-colons way too much ^^;
Challenge Trophies Won:

SERGIO_ManOwaR_

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'!

Galileo

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.

MrD

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.

SERGIO_ManOwaR_

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!

MrD

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

SERGIO_ManOwaR_

I've catch a few errors running my codes, if you're interested:

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.
2) LINE not always spects x1,y1,x2,y2...  in fact, you can use command LINE INPUT to get user inputs...
Using INPUT will store user inputs CUTTED at the very first SPACE character, while LINE INPUT allows to input multiple words and store them. Again it's an unusual command, but i'm using it :D

The inkey$ command it's a little bit more complicated, i guess you know how it works:It stores in a buffer all keyboard strokes (only one key at same time) just as fast as your OS keyboard configuration goes. Keyboard delay and repetition are reflected. If the yabasic loop runs slower than your keyboard repetition, all the stored keystrokes will continue been returned by inkey$ just as much as they are stored. Sorry if i can explain it better.
Navigating slow menus may cause yabasic inkey$ doing some stuff seconds later you pressed keys, but this is how it works and when u get used to it, can take advantage of that, cos' no keypress is missing, while PEEK("port1") just stores keypress if detected at the momment it's called.
Also inkey$ allows to navigate menus... e.g. move UP/DOWN to select an option, since after your first keypress, there is a delay countdown before key repetition, and that gives you time to release key. inkey$ is very useful here.

Also i get errors in some of my codes with comparisons <>=  and calling arrays not yet dimmed... ¿? this will need a deep review of my code... I'm sure that with a good syntax and coding style those errors will dissapear...
Best to do is rewrite part by part and try it in your emu... the question is... does yabasic deserve so much work?
I love yabasic and still coding so much demos and games, most of them not yet published... that's why i'm happy somebody shows so much interest on yabasic to code a new emu... but thats it:lot of work for a languaje, sadly, almost dead.
Anyway... still havin fun! greets

MrD

Quote1) 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!

MrD

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?

MrD

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.

MrD

#35
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$()!


tronkko

Quote from: moon on July 16, 2015
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...

SERGIO_ManOwaR_

Hi mrd! I'm glad you fixed that 'if'
I've seen the yabasic docu and that "if" without "endif" is called 'The one-line-form' wich basically means that conditions will be executed JUST IN THAT LINE, so, any code placed later will be executed normally out of previus condition.

The line input is kinda weird..
in a sentence such as 'input "Name?"name$', if you type a single word, everything will be ok, and your input will be assigned to name$, BUT writing words separated by spaces will cause name$ be cutted at the first space character, so if you type "my name is fool" name$ will be :"my"
and this is the most surpresive... where are the other words you typed?... well..
on subscuents calls to input, remaining words (separated by spaces) will be automatically assigned to name$
:O
Thats why line input is needed to pass a whole line to a var via input.

I've catched another few errors... maybe you like to know about it.
a format string such as"%02.2f" gets an error. This is legal and even more very useful
to text numbers like scores or clocks in a format.
The standard format "##.##" causes values of ZERO to be NONPRINTED, and its ugly if you have a digital clock or a score you want to be fixed lenght and ZEROS displaying like:
SCORE: 0000198
You need the "%02.2f" format. You can find format strings at the docu. Sorry again cos' i can explain it very well.

Another error is related to ascii character set. I'm using several ascii characters for  bitmaps compression, and unfortunately, most of the characters are missing or bugged.
The worst it that not only are missing, but also when you try to get the ASC value of those characters, you get wrong values moreover 255

This code prints the ASC values of characters in var 'asciiLine$', that are chars from 128 to 255
If you run it in the emu, you'll see it work properly, But in the MJS gives strange values such as 402 or 8364..?¿
Since im using this characters to represent an encoded bitmap palette of 128 colors, when trying to decode, ASC(byteDecoded$)-128 causes a CRASH because exceeding the DIMmed palette of 128
---------------------------------------------------------------------------------
asciiLine$="€,ƒ,,...†‡ˆ‰Š‹ŒŽ''""•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"

FOR chekChr=1 TO LEN(asciiLine$)
chek=ASC(MID$(asciiLine$,chekChr,1))
PRINT "CHR(",CHR$(chek),") IS ASC(",chek,")"
INKEY$(1000)
NEXT
'
-----------------------------------------------------------------------------
Well, that's really tough work...

am...

Just say thanks for your work!

I understand how difficult must be to fix all this, don't really worry about yabasic!

Cheers and see you!



MrD

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!