Page 1 of 1

Problem with command Z in BabelFish

Posted: 25 Dec 2018, 16:09
by abc123
My gigatron works without problem when using Famicom, i can use the arrow keys and use [A] to select an application.

Now has I connected a Arduino Uno instead of Famicom with four wires and USB to a PC, and I have compiled and downloaded BabelFish to Arduino, it runs and it says ":Gigatron OK" in and the arrow keys works (ASDW) without problem: the ASDW moves on the arrow in the VGA-display.

The problem is that [A] to start an application does not work, the command for that shall be "Z" but nothing happens normally. I have debugged the program BabelFish.ino and the command is sent really to gigatron, but nothing normally happens.

But it works sometimes, i think it may be a timing problem. I have noticed in the code BabelFish.ino that the [A] / Z is a little special, the command for that is the only one with the highest bit cleared (~128), a bit that is specially treated in the code, line 1018.

I have ROM version 3, i use the latest github kervinck/gigatron-rom. Maybe is BabelFish not updated for version 3? Has anyone else used BabelFish.ino on ROM version 3 and everything works?

Re: Problem with command Z in BabelFish

Posted: 25 Dec 2018, 22:16
by marcelk
This could be a new bug indeed, but it is not immediately clear to me how. Bit 7, the first bit transmitted, is a special case, that's completely right. Line 1018 sends it ahead before the vertical blank begins because of tight timing. But this may also be a red herring, it can be something else. The typecast in 528 is a bit suspect as well. However, it's the same as 652 and that section is quite reliable for me (sendFile.py relies on line 652 and it has never failed for me). I can take a closer look at it when I return home this weekend.

If I have to make a random guess, I would replace

Code: Select all

  case 'Z': sendController((byte)~buttonA,2); break;
with

Code: Select all

  case 'Z': sendController((byte)~buttonA,3); break;
and see if it gets better. But it is a stab in the dark...

Re: Problem with command Z in BabelFish

Posted: 25 Dec 2018, 23:02
by abc123
I noticed the typecast in 528 also. In my experience all typecast is something strange and wrong, and i always try to avoid them. I guess it is there to remove sign extension (when bit 0x80 is set) but sign extension should not be any problem so it is a little bit strange why it is a typecast, so i don't fully understand it.

I checked to remove it but the situation was the same. I have tried to use send it 3 and up to 100 and 200 without any change. I have tried sendFile.py but it does not work, i guess it is the same problem.

If it works for you and everyone else and not for me it is probably some version problem with Arduino, ROM, gigatron or IDE for Arduion or BabelFish or any other version problem.

Re: Problem with command Z in BabelFish

Posted: 25 Dec 2018, 23:19
by marcelk
Then it can be Uno-specific. My most recent testing was always with the ATtiny85 (for pluggy) and the Arduino Micro. I might have inadvertently broken the Uno.

Re: Problem with command Z in BabelFish

Posted: 25 Dec 2018, 23:32
by abc123
I have the same thought, because as I understand it the same code is used in the the current and my pluggy, so it can be something Uno-specific.
I have tried the slightly different version of BabelFish made by gt67, the same situation.

I don't request that you should solve this, especially if it something only I get, then is it something that I may have caused. I will search further.

I don't really think a difference between different cpu:s itself will be the reason, they are really very similar, a more likely that it is the different defines for the different cpu:s in the c-file that is the problem.

Re: Problem with command Z in BabelFish

Posted: 26 Dec 2018, 00:00
by marcelk
BabelFish started out on the Arduino Uno. I solved a pretty deep USB issue with the Arduino Micro this summer. From there I just kept using the Arduino Micro, out of laziness of switching between these devices all the time. My Uno is at home, so I like to hook it up there and confirm it still works there. I have no idea.

Compilation warnings are definitely a sign of trouble, because I always resolve them. In fact, I'm pretty sure the typecast got there just to silence one as well. My current IDE is Arduino 1.8.1 for the Mac (High Sierra).

It is interesting that other similar commands work. sendFirstByte() is not really a tricky function, and those other commands also have a first bit to send as well...

Re: Problem with command Z in BabelFish

Posted: 26 Dec 2018, 00:10
by abc123
My version of Arduino is 1.8.5, so it is similar, but my version of gcc is unknown, but I don't think that is the reason.

I get a lot of warnings when a compile BabelFish but you don't, that is a little bit strange, but you are using MacOS and I Windows, I don't really think that is the reason for the problem. I think I have more restrict flags for the compilation, that is all, for some reason.

After some thinking, one very possible cause is the different frequency in uno 16 MHz compared with plugface lower frequency. I will lower the uno frequency and return, I can't check it now.

Re: Problem with command Z in BabelFish

Posted: 26 Dec 2018, 11:10
by marcelk
I just pushed a change that resolves the compilation warnings at the 'All' level.
For some reason my IDE preferences were stuck at 'None' (not even 'Default').

The "Low memory" message is still there:

Code: Select all

Sketch uses 28368 bytes (87%) of program storage space. Maximum is 32256 bytes.
Global variables use 1740 bytes (84%) of dynamic memory, leaving 308 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.
The changes are small enough that I feel confident to push them without hardware test:
just sprinkling some more 'const' keywords. [Famous last words of course, fingers crossed]
https://github.com/kervinck/gigatron-ro ... 56dec09b6b

[Edit] P.S.: I believe the Arduino Micro also runs at 16 MHz, and sendFile.py worked there last time I checked. It could also be a misdefined constant for the Uno, perhaps a little refactoring accident not reported earlier. But I don't see yet where...

Re: Problem with command Z in BabelFish

Posted: 29 Dec 2018, 10:54
by abc123
It suddenly started to work, I don't really know why. It may be that something was wrong with the wireing between gigatron and arduino uno. Now Z and sendFile.py works.

Re: Problem with command Z in BabelFish

Posted: 29 Dec 2018, 22:43
by abc123
Now is the next step is to compiler for vCPU language.
I would have liked destriction how to do this, but i will manage.
Maybe i will post a description when I am done.

I really like this gigatron!