Arduino/ATmega328 C64 Emulator

janost:
i also tried using #IFDEF in the Arduino IDE.
A big joke. Must be some Italian thing but does not work for sure :frowning:

What about #ifdef (in lower case) ?

fungus:

janost:
i also tried using #IFDEF in the Arduino IDE.
A big joke. Must be some Italian thing but does not work for sure :frowning:

What about #ifdef (in lower case) ?

Nope, no difference.

I think there is a bug in the preprocessor for the 1.0 IDE.

janost:
I think there is a bug in the preprocessor for the 1.0 IDE.

It's probably something to do with "Transformations to the main sketch file". ( Redirecting )

The parser isn't very smart and looks inside conditional code.

Every library I add to the envoirement wants exclusive access to the CPU.
Is there anyone Writing librarys that can cooperate with others?

Mitt sätt att tacka forumet :slight_smile:

There's a tear across the line "GIVING SOMETHING BACK"...is that real or just the camera?

real.
I'm a forum person and I like the idea of giving back :slight_smile:

janost:
real.

Well, it's still in beta... :slight_smile:

No, its not the camera.
The sync is not perfect.

But its beta as you said :slight_smile:

No matter what I try, the Wire library will not run with my Timer0 interrupt.
I just don't get it.

Why does it fail?
Shouldnt it just be slowed up or is there some timeout?

Can't help without seeing code. After all Wire and Timer 0 interrupts work all the time, as Timer 0 is normally used for millis(), micros(), etc.

It should work.

Whenever I see something weird like this I think "Out of RAM?"

I have to give this up for a while.
It boots when the video is disabled but not with video on.

I'll write the emulator for serial ANSI VT-100.

Ok, It boots :slight_smile:
But the resources are so limited that its not useable.

With just 48bytes free RAM on the Nano and an external 64K EEPROM, it starts.
But its not useable, its like running with a CPU clock of 70KHz on the 6502.

I've proved my point and will leave this now.

But this has born the VideoBlaster.
And it makes a damn good platform for games and retrocomputing.

I will look into TinyBasic and make something usefull of it :slight_smile:

C64 Boot.jpg

I was never really going to emulate a C64, and there's far better BASICs if you want it for BASIC programming. :slight_smile:

The video signal generation is more interesting/useful.

I'm a bit worried about the tearing on the lines of text. I think it's because your interrupts aren't happening exactly on the right clock cycle on each line. There's ways around that but we need to do a little test first.

Put this code in your loop() function:

#define NOP __asm__("nop\n\t")
void loop()
{
  while (1) {
    NOP;NOP;NOP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;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
  }
}

This ensures that the CPU spends most of its time executing instructions that only take one clock cycle.

Does it improve the display?

The tearing comes from the LCD-display.

An LCD-TV display only got 960pixels across divided by the 3 primary colors.
That is 320pixels and I'm running at 512pixels across.

If I fill the screen with white blocks the borders are straight.

When I use a 4MHz pixelclock there is no tearing.
But then only a maximum of 22chars or 176 usefull pixels across.

It probably has a combfilter on the video input.

The code is the same, just a different pixelclock and less shifterloads per line.

My loop() function goes to sleep if the scanline is within scanline 56 to 255 with PAL.
So it only Draws pixels and then sleep on active lines.

Without it, all characters on the screen jitters.

I have a Due and was wondering if the 6502 emulator would run on it. With 512K Flash and 96K Ram it should have plenty of room to run programs. Also I was thinking of offloading the sound and video and keyboard onto a "co-processor" via SPI. The Parallax Propeller chip does video and a PS2 keyboard easily and someone has written code for SID emulation with is extremely good. If not SPI maybe by 8 bit buss instead since the Due has plenty of I/O and the Propeller should be able to read it in.

MicroNut:
I have a Due and was wondering if the 6502 emulator would run on it. With 512K Flash and 96K Ram it should have plenty of room to run programs. Also I was thinking of offloading the sound and video and keyboard onto a "co-processor" via SPI. The Parallax Propeller chip does video and a PS2 keyboard easily and someone has written code for SID emulation with is extremely good. If not SPI maybe by 8 bit buss instead since the Due has plenty of I/O and the Propeller should be able to read it in.

It will definitly run on a Due.
You can get the code from me to boot it.

I have a Due and it will for shure work.

But isnt that to easy and plain simple?

Also the sound should be run on a 328 with a SID emulator?

I have all of this in my new Bambino board.
ATmega1284 with an Uno footprint.

MicroNut:
I have a Due and was wondering if the 6502 emulator would run on it.

Sure, but what's the point?

Why not just get something cheaper with a TV output (eg. Raspberry Pi) and run a C64 emulator on it?