RedC in development

bahstrike

New Member
Jul 29, 2019
16
0
0
I have not made a satisfactory workaround to the SBC problem yet.
If one has the ability to modify RedPower then I highly suggest implementing the solution indicated previously.
I am curious if, but don't believe this should, break any existing FORTH or MS-BASIC.
Here's the redpower CPU's SBC implementation:
int v = ((regA - val) + (flagC ? 1 : 0)) - 1;
flagC = (v & 0x100) == 0;
flagO = ((v ^ regA) & (v ^ -val) & 0x80) > 0;
regA = v & 0xff;

This would all work :( if the first line were rewritten to:
if(!flagC) val++;
int v = regA - val;

You can find the project here:
http://bahproductions.com/RedC-9-21-2014.rar

./dist/ Precompiled binaries, config files, etc. Output destination for included code projects.
./RedC/ The RedC project files itself.
./rpc8e/ The 6502 C compiler source and redpower CRT

Just using the project:
1) Run the precompiled project ./dist/bin/RedC.exe

Setting up the development environment:
1) Run ./rpc8e/BUILD.bat and wait for it to finish- takes a while. You can check the readme.txt file here for some more information.
2) Open ./RedC/RedC.sln in Visual Studio 2010 or later. To make debugging work properly, go to the Debug tab in the project settings and set your working directory to C:\[wherever you unpacked the rar]\dist\bin\. Note that RedC.exe and the BUILD batch file are already set to output to this \dist\bin\ path.

This package includes everything up to and including the simulator breakpoints feature, but just prior to any work on the SBC problem.
Note any capitalized code comments are from the Scintilla.NET sample- my comments are generally all lowercase.

Please note that the "Build & Inject" feature (which puts your IMG data directly to a floppy disk in your inventory) is unfinished.
In MainForm.buildAndInjectToolStripMenuItem_Click() you will find hardcoded player name and FTB directories from testing purposes.

Please reply here if you want to discuss the state of any unfinished or planned features, the state of the CRT, or the SBC problem.
I would prefer to have any reasonably complex discussion via voice chat, eg. steam, skype or teamspeak.
 

FyberOptic

New Member
Jul 29, 2019
524
0
0
Did you ever try another emulator to confirm the behavior of the flag? Specifically ones like Atari 2600, NES, or Apple II emulators where there's a good chance they're accurately represented, otherwise I doubt most of the games would work properly.

I was working on a Z80 device simulator once and kept having a problem that I just couldn't wrap my head around. After quite a bit of tracing through a debugger I eventually found that my assembler was actually at fault, not the CPU emulation core or any of my device simulation code, and had to contact the developer about it. Certainly not the first time a tool has been the culprit, which is why it's always good to check other sources.

If it really is still in RedPower then you can write a coremod to tweak the class at startup. That was possible in 1.4.x
 

UberFoX

New Member
Jul 29, 2019
5
0
0
Since my mod incorporates RedPower itself I can apply any fix to the CPU code you require to make your program work better we aren't exactly limited by what RedPower 1.4.7 was using.

My mod is a bit of a merger of a few mods + my own personal mods I make many fixes, tweaks to the other mods for example I have added new stuff to Redpower, gui stuff, new machines , new frame type and so on and so forth.

I am more than willing to include anything you desire to help make RedC work good on it.

I can apply fixes to the CPU code that you deem are necessary.

You have Skype ? we should discuss these things in a more real time manner. (I also have STEAM but I prefer Skype let me know...)

My mod works on Minecraft 1.5.2 and 1.6.4 with partial support for 1.7.10 (I have not fully finished the 1.7.10 version yet).

Here is a video of my progress on the RedPower part of my mod:

And here is a video showing my newly made Peripheral for ComputerCraft to interface with bundled cables once again!
(its worth noting for the sake of the video I hide the 40+ pages of microblocks and only show a few)

I have done a lot of work so far in bringing RedPower back to life and I hope you can see that and decide that RedC could make use of my work.

I will admit it would be easier for me to just include an *interperated* computer but I feel I will leave that to ComputerCraft and instead focus on a *real* OS which the RedPower computers allow us to do.

OH also as you may notice from the video my mod incorporates EE2 (equivalent exchange 2).

So you may find it odd to see EE2 morning star, transmutation stuff along side RedPower computers hehehe.

I changed this:
private void i_sbc(int val)
{
int v;
if (flagM)
{
if (flagD)
{
v = (regA & 15) - (val & 15) + (flagC ? 1 : 0) - 1;

to:
private void i_sbc(int val)
{
int v;
if (flagM)
{
if (flagD)
{
if(!flagC)
val++;
v = regA - val;

will that suffice?

Here is the original CPU instruction
http://pastebin.com/zngLRwFi

Heres the one I changed it to
http://pastebin.com/H309PqgT

Would you say this is correct? If not make changes and send me what you think is best.
 
Last edited:

bahstrike

New Member
Jul 29, 2019
16
0
0
Did you ever try another emulator to confirm the behavior of the flag? Specifically ones like Atari 2600, NES, or Apple II emulators...
Hi FyberOptic- yes, a screenshot in previous post shows an emulator 6502µP producing a different overflow flag result than bigfoot's simulator (which I presume is directly derived from the RP implementation). I can only trust that the compiler is working correctly- cc65 is an open source project that is contributed to and used by a fair user base, and undoubtedly been used for real&simulated systems alike.

It's not so surprising if MS-BASIC or FORTH have not had any issue. This scenario seems like a niche utilization of SBC's impact on register flags.
It is probably an exploit of minutia, as part of an optimization in cc65 compiler (although unfortunately it seems hardcoded- turning off optimizations doesn't produce any different code here for the less-equal operation).


If it really is still in RedPower then you can write a coremod to tweak the class at startup. That was possible in 1.4.x
I am not a Java dev or an MC modder, but I would like to learn how to do this. Any starting advice is appreciated


Since my mod incorporates RedPower itself I can apply any fix to the CPU code you require to make your program work better we aren't exactly limited by what RedPower 1.4.7 was using.

My mod is a bit of a merger of a few mods + my own personal mods I make many fixes, tweaks to the other mods for example I have added new stuff to Redpower, gui stuff, new machines , new frame type and so on and so forth.

I am more than willing to include anything you desire to help make RedC work good on it.

I can apply fixes to the CPU code that you deem are necessary.

You have Skype ? we should discuss these things in a more real time manner. (I also have STEAM but I prefer Skype let me know...)

My mod works on Minecraft 1.5.2 and 1.6.4 with partial support for 1.7.10 (I have not fully finished the 1.7.10 version yet).
Hi UberFox- My personal game is still Ultimate (1.4.7). If you can provide me a fixed RP, or a coremod patch like FyberOptic mentioned, for this version then I would very much like to test for myself.

So far this is the only (presumed) bug that I have found in RP. I don't really expect to find any others.
If I remember right, the RP code actually looks like it -should- handle the scenario correctly, but there was some order of operations or over/underflow happening (due to type or etc).

I'll send you a PM with my email for skype. I'd like to continue the work on RedC as there is still much to do.


Here is the original CPU instruction
http://pastebin.com/zngLRwFi

Heres the one I changed it to
http://pastebin.com/H309PqgT

Would you say this is correct? If not make changes and send me what you think is best.
Yes- originally, I used an online Java decompiler to find the SBC implementation and tested it in C with a for() loop going through all values 0-255. The original RP implementation failed on the 0 and 127 cases. The modification I made passed the test in C. I don't remember the exact detail of what was wrong with the ternary operator there, as this was several months ago, but I'm confident that the change restores correct behavior.

EDIT: Wait no- that is not correct. I didn't read the full pastebin sorry.
Please remove the patch from the if(flagD) case.
Add it to the statement following the else (the !flagD case).
The patch belongs only there.

flagD = Decimal mode. This might be why FORTH or BASIC is working btw- if they are running the 6502 in decimal mode. Our compiler uses standard 2's compliment which is the !flagD case.
 
Last edited:

UberFoX

New Member
Jul 29, 2019
5
0
0
Ok I will await your PM and yes I believe I can provide you with a fixed class for RedPower that changes the CPU instructions however you desire for your 1.4.7 game.

You do not need to update to my personal RedPower version but we should at least be in sync regarding CPU.
 

UberFoX

New Member
Jul 29, 2019
5
0
0
As a side note I have abandoned everything to do with this CPU fix and RedC in general and will not be returning to this topic ever again.

Bye.
 

UberFoX

New Member
Jul 29, 2019
5
0
0
I advise people to be careful when dealing with "bahstrike" he has a tendency go mental and start insulting you with such profanity just posting the chat log itself got me *warnings* 5 minutes ago that's how bad it was.

He really said a lot of nasty things to me and probably will to you too if you try help him.

You have been warned.
 

bahstrike

New Member
Jul 29, 2019
16
0
0
My experience with UberFoX's interest in the project was the following:

1) Convincing me to join his personal MC server, where he proceeded to show me his own mods for 85 minutes
2) Convincing me to download his preference of minecraft launcher
3) Convincing me to download his personal chat&file transfer client, of which I was a bit hesitant
4) Proceeding to explain to me how cool his scripting language "Sputnik" was
5) More how cool his scripting language "Sputnik" was
6) He mods the game per my suggestion- we try it- it works
7) I ask for assistance modding the game to fix the RP glitch in versions including past versions.. unwilling to help, yet I got more "Sputnik"
8) I got a proof of concept that I was correct that RP has a glitch. I wanted to find someone to put out a patch- you are capable- but too conceited to even provide the finder-of-the-bug a fixed binary. Indeed I am finished with UberFoX.
 
Last edited by a moderator:

Padfoote

Brick Thrower
Forum Moderator
Dec 11, 2013
5,140
5,898
563
This thread has proven to be nothing but hatred and excessive language for the last few posts. If I see another post like that this will be getting permanently locked.

Play nice.
 
  • Like
Reactions: Qazplm601