MIST C64 core

https://github.com/mist-devel/mist-board/wiki

Moderators: Mug UK, Zorro 2, Greenious, spiny, Moderator Team

DanyPPC
Atari Super Hero
Atari Super Hero
Posts: 757
Joined: Tue Feb 21, 2017 7:02 am

Re: MIST C64 core

Postby DanyPPC » Thu Apr 11, 2019 6:01 am

I had no doubt that Slingshot would find a solution :cheers:

Many thanks for this C64 core update.

Lroby74
Captain Atari
Captain Atari
Posts: 156
Joined: Sun Sep 04, 2016 8:35 pm

Re: MIST C64 core

Postby Lroby74 » Thu Apr 11, 2019 6:51 am

DanyPPC wrote:I had no doubt that Slingshot would find a solution :cheers:

Many thanks for this C64 core update.


To be honest, the credit goes to 2 people, Slingshot and Darfpga, I am really grateful to both of them for what they did, and I apologize to them both for stressing them out for this function, but I really cared too much

DanyPPC
Atari Super Hero
Atari Super Hero
Posts: 757
Joined: Tue Feb 21, 2017 7:02 am

Re: MIST C64 core

Postby DanyPPC » Thu Apr 11, 2019 8:49 am

I'm in testing phase :)

For now two games have problems:

- Target Renegade (most times doesn't load)
- Gryzor (Loads on MiST but at the end only a grey screen)

On MiSTICA both don't load anyway.

Gehstock
Captain Atari
Captain Atari
Posts: 406
Joined: Wed Dec 21, 2016 7:18 pm
Location: EastGermany

Re: MIST C64 core

Postby Gehstock » Thu Apr 11, 2019 9:23 am

:cheers: Thank you both

nippur72
Atariator
Atariator
Posts: 19
Joined: Sat Mar 23, 2019 3:32 pm

Re: MIST C64 core

Postby nippur72 » Thu Apr 11, 2019 9:55 am

@slingshot: regarding the TAP loading, @Darfpga mentioned an IRQ problem in the CIA ("clear before catch status") he fixed before making it work correctly. I think we need that fix the Mist core too.

Previously I was experimenting with real tape loading from UART_RX (Mistica board) but it was always problematic with tons of a ?LOADING ERRORs. That was a puzzle to me because the same feature on the VIC20 worked flawlessly.

Now that you added the TAP loading feature, I compared the plot-scope of the same .TAP file in VICE and C64_MIST. They should be identical but instead they are quite different. On the FPGA one (on the left) the scope looks more "quantized" suggesting that IRQ tend to be triggered only on certain durations. On the right, VICE is more evenly distributed.

tap_loading_azimuth.jpg

My guess is that's caused by the issue mentioned by @Darfpga. Unfortunately my understanding of the CIA is nil, so I can't fix it and send a pull request :(
You do not have the required permissions to view the files attached to this post.

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Thu Apr 11, 2019 12:16 pm

I can think about one change in CIA, but AFAIK the serial port input works correctly on it, so was hesitant to apply.
If you can try this:

Code: Select all

// FLAG Input
always @(posedge clk) begin
  if (!res_n) icr[4] <= 1'b0;
  else begin
    if (phi2_p) begin
      flag_n_prev <= flag_n;
      if (int_reset) icr[4] <= 1'b0;
      if (!flag_n && flag_n_prev) icr[4] <= 1'b1;
    end
  end
end


(it's just about setting the interrupt flag in phi2_p). Unfortuantely I don't have any info, nor any tests which tells where the falling edge is caught, synchronously to a clock, or any time, when the interrupt is fired, so the only method to make it work is experimenting.
The difference above also can be the difference of the tap players (maybe there's some randomization in VICE). Or did you use VICE to play the TAP to MiST?
I don't quite understand that "clear before catch" problem, the irq flag is cleared upon read. So any read op must caught it's value before it's going to be cleared. The tape loading is just a very small part of the CIA (FLAG_N input and interrupt flags). Loaders are using the timers, too, but many tests show they're OK.

As I see, the VIA in VIC20 samples CA1 (tape input) at the 4x rate of the clock (which probably not what the original VIA does). But maybe sampling in
CIA should be done outside of the clock enable. This makes sense, since probably the original implementation has only an edge detector in the input. But after this change, would be good to test serial port, too.
That should look like this:

Code: Select all

// FLAG Input
always @(posedge clk) begin
  if (!res_n) icr[4] <= 1'b0;
  else begin
    if (phi2_p) begin
      if (int_reset) icr[4] <= 1'b0;
    end
    flag_n_prev <= flag_n;
    if (!flag_n && flag_n_prev) icr[4] <= 1'b1;
  end
end

Lroby74
Captain Atari
Captain Atari
Posts: 156
Joined: Sun Sep 04, 2016 8:35 pm

Re: MIST C64 core

Postby Lroby74 » Thu Apr 11, 2019 4:37 pm

I don't know if what I'm about to say has anything to do with the bug you're talking about, but I noticed that the menu item "Play / Stop TAP" works correctly if I'm in the first screen of the Basic editor, instead when I give the command LOAD + enter the item in the "Play / Stop TAP" menu executes the Play command the first time you choose it but then no longer allows you to do the Stop, the same thing during loading games, when a game like "Flimbo's Quest" asks to put side B, and to press Rewind & Play to continue, while both on the real C64 and in the Vice it is sufficient to press STOP & PLAY twice and the program continues loading the tape, here it does not continue because the STOP is not executed by the "Play / Stop TAP" item in the OSD menu.
Still in Basic, if after giving the command LOAD + enter, I execute a BREAK using the "Run / Stop" button, the "Play / Stop TAP" function in the menu returns to work correctly.
So IMHO may be present a bug in the "LOAD" subroutine, especially when you give the STOP command while LOAD is running, instead of stopping the tape, it begins to emit a very high-pitched hiss and then no longer loads

nippur72
Atariator
Atariator
Posts: 19
Joined: Sat Mar 23, 2019 3:32 pm

Re: MIST C64 core

Postby nippur72 » Thu Apr 11, 2019 5:52 pm

@slingshot I am reconsidering my previous statement about the issue in the CIA. It seems that the Mist is very close to the original hardware and it's VICE that is the inaccurate one.

I prepared a .TAP file with 9 pulses of different durations. Mist and real C64 are ver similar, VICE is not:

zzzareal.jpg


Still I don't know the reason of my problem with the UART_RX port, I need to investigate more.

P.S. I tried the fix you suggested but didn't change much (both graphically and in the outcome).
You do not have the required permissions to view the files attached to this post.

Darfpga
Atari maniac
Atari maniac
Posts: 76
Joined: Thu Feb 02, 2017 10:07 pm

Re: MIST C64 core

Postby Darfpga » Thu Apr 11, 2019 8:33 pm

slingshot wrote:At the end I was successful. I've restructured the code a bit, I wonder why didn't you use the fifo reset signals? Also added safety checks to not read if the FIFO is empty (maybe it's not needed, the DCFIFO can protect itself). And finally, it was more convenient to use a 8-bit interface on MiST. Didn't try Crazy Comets yet. Here the core runs in original frequency (CPU is main clock/32 in any case, and the main clock is reconfigured when NTSC/PAL mode is changing), so I've used /32. TAPs will be off a bit in NTSC mode of course.


Thanks slingshot for porting to MiST. I didn't use fifo reset because in the beginning I plan to do only tap mode with a very small fifo. As you can see I didn't develop host part to release rapidly the c1530 module. So I prefer to have as less as possible of signal count. Same reason for 8 bits against 32 bits. I use my host (zpu control module) file load code without absolutly no change between the file load code that I use the NES loader with my own DE10-Lite board.

slingshot wrote:I don't quite understand that "clear before catch" problem, the irq flag is cleared upon read. So any read op must caught it's value before it's going to be cleared.


As you see I still continue to use a big part of the original FPGA64 sources (I'am thinking to switch to MiST/MiSTer recent code but don't find time enough to do it). So with original cia sources some flag_n falling edge was not seen correctly, this drive to wrong bit value in the tape stream. The problem occur because certain loader doesnt use IRQ to detect flag_n falling edge. Instead they make a tight loop BIT DC0D, BEQ previous instruction. In that way the ICR register is read and clear within the same instruction. Depending on flag_n falling edge position during the instruction cycle the original cia can catch or miss the falling edge. In case the BIT instruction miss that falling edge the bit value is wrong and the whole loading will fail. Anyway this problem was present with the original cia. Maybe it doesn't exist with your new cia (I saw that you rewrite irq and timer part)

Darfpga
Atari maniac
Atari maniac
Posts: 76
Joined: Thu Feb 02, 2017 10:07 pm

Re: MIST C64 core

Postby Darfpga » Thu Apr 11, 2019 8:47 pm

slingshot wrote:Also added safety checks to not read if the FIFO is empty (maybe it's not needed, the DCFIFO can protect itself)


I understand you want to prevent reading empty fifo. But in any case reaching an empty fifo before end of tape will end at 99% to a load failure because the next timer timeout won't wait for fifo to be ready again. The loading stream must not break once started.

Darfpga
Atari maniac
Atari maniac
Posts: 76
Joined: Thu Feb 02, 2017 10:07 pm

Re: MIST C64 core

Postby Darfpga » Thu Apr 11, 2019 8:55 pm

Sorry for the lag time in reply. I've got one small single time slot a day to work on fpga stuff.

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Thu Apr 11, 2019 9:00 pm

@Darfpga Thanks for replying, yes, the new CIA (it was not written entirely by me) has no problems with Crazy Comets for example. But Gryzor doesn't load for some reason (actually it loaded once). Maybe can you try is it working with your version?
The empty fifo protection is just for preventing the corruption of the internal structure, it stops the playback if tap_fifo_error = '1'.

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Thu Apr 11, 2019 9:38 pm

Seems the general problem is with games using Ocean's FREELOAD loader.

Lroby74
Captain Atari
Captain Atari
Posts: 156
Joined: Sun Sep 04, 2016 8:35 pm

Re: MIST C64 core

Postby Lroby74 » Thu Apr 11, 2019 10:27 pm

@slingshot, What do you think about issue of "Play / STOP TAP" function when Datasette motor is on?

User avatar
DrOG
Atari Super Hero
Atari Super Hero
Posts: 660
Joined: Sun Jul 31, 2016 8:23 pm
Location: Gyula, Hungary

Re: MIST C64 core

Postby DrOG » Fri Apr 12, 2019 5:28 am

I suspect no real 'ear in' support so far...
Tried it with an ideal .wav (see attachent), generated from .prg file using wavprg & audiotap combo. But nothing happens after the 'press play on tape' message if I choose the 'Play/Stop TAP' menu option, I assume it would have effect only If I have been loaded previously a .tap file ('Load *.TAP' using the menu).
I don't know if it's possible at all to load from external audio device, but if it could be implemented, I would be glad to test it next week (I travel to countryside with my family this weekend).

Cheers: Gábor
You do not have the required permissions to view the files attached to this post.

Lroby74
Captain Atari
Captain Atari
Posts: 156
Joined: Sun Sep 04, 2016 8:35 pm

Re: MIST C64 core

Postby Lroby74 » Fri Apr 12, 2019 6:52 am

DrOG wrote:I suspect no real 'ear in' support so far...
Tried it with an ideal .wav (see attachent), generated from .prg file using wavprg & audiotap combo. But nothing happens after the 'press play on tape' message if I choose the 'Play/Stop TAP' menu option, I assume it would have effect only If I have been loaded previously a .tap file ('Load *.TAP' using the menu).
I don't know if it's possible at all to load from external audio device, but if it could be implemented, I would be glad to test it next week (I travel to countryside with my family this weekend).

Cheers: Gábor


Support to real EAR input has still to be implemented.. i am quite sure that it's matter of days :lol: :lol:

nippur72
Atariator
Atariator
Posts: 19
Joined: Sat Mar 23, 2019 3:32 pm

Re: MIST C64 core

Postby nippur72 » Fri Apr 12, 2019 7:44 am

@Drog loading from external audio is possible via UART_RX using a small external circuit (or internal if you have the "MiSTica" clone). But of course it needs to be supported by the cores. In Commodore 8 bit computers it's a bit difficult because the tape port is not just audio, there are also motor and tape buttons. The C64 is even more difficult because the motor is stopped when "FOUND" appears waiting for [spacebar] or [C=] key.

Anyway I was experimenting with that in the past days, VIC20 works nicely but on the C64 I was getting ?LOAD ERROR for some reason I still have to understand.

Here's a video (sorry it's in italian)


slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Fri Apr 12, 2019 11:16 am

Motor control can be the other UART port, but for the button sense input, there's not much option than a manual one, via OSD or a hotkey.

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Fri Apr 12, 2019 11:32 am

Lroby74 wrote:@slingshot, What do you think about issue of "Play / STOP TAP" function when Datasette motor is on?

AFAIK the motor can be on, even the stop button is pressed. When you stop the tape during LOAD, it'll finish before the datasette stops. However there's a bug with the fifo filling logic, will correct it. After I give up this Freeloader :) It's very strange: if it works once, then it'll work forever. But if it doesn't work after I turn on the MiST, it will never work.
Last edited by slingshot on Fri Apr 12, 2019 12:42 pm, edited 1 time in total.

User avatar
DrOG
Atari Super Hero
Atari Super Hero
Posts: 660
Joined: Sun Jul 31, 2016 8:23 pm
Location: Gyula, Hungary

Re: MIST C64 core

Postby DrOG » Fri Apr 12, 2019 12:36 pm

nippur72 wrote:@Drog loading from external audio is possible via UART_RX using a small external circuit (or internal if you have the "MiSTica" clone). But of course it needs to be supported by the cores....

I know that, I have built this circuit myself, and used with success in case of Spectrum and Amstrad cores, see my experiences in another topic: viewtopic.php?f=115&t=30124&start=25#p371237

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Fri Apr 12, 2019 1:46 pm

Ok, this works for me with Freeload games:
https://github.com/mist-devel/mist-bina ... 190412.rbf
Even with multi-load freeload games. Tried Operation Thunderbolt for that.

DanyPPC
Atari Super Hero
Atari Super Hero
Posts: 757
Joined: Tue Feb 21, 2017 7:02 am

Re: MIST C64 core

Postby DanyPPC » Fri Apr 12, 2019 1:52 pm

Thanks Slingshot, I'll have to test. Feedback to come :wink:

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Fri Apr 12, 2019 1:56 pm

nippur72 wrote:Anyway I was experimenting with that in the past days, VIC20 works nicely but on the C64 I was getting ?LOAD ERROR for some reason I still have to understand.

Maybe your problem is the signal phase. CIA acts only on negative edge of the incoming signal, but VIA can be programmed to either rising or falling edge. I remember the cassette player what we had for the ZX-Spectrum had a phase switch on it (but the Speccy wasn't sensitive to the polarity at all).

DanyPPC
Atari Super Hero
Atari Super Hero
Posts: 757
Joined: Tue Feb 21, 2017 7:02 am

Re: MIST C64 core

Postby DanyPPC » Fri Apr 12, 2019 3:34 pm

None of the following games load on MiST/MISTICA:

- Target Renegade (first release loads), Creatures, Creatures II, Gryzor, Operation Thunderbolt.

Only a little test.

slingshot
Atari God
Atari God
Posts: 1259
Joined: Mon Aug 06, 2018 3:05 pm

Re: MIST C64 core

Postby slingshot » Fri Apr 12, 2019 3:38 pm

Pulling out my hair - still buggy somewhere. Sometimes work, but then suddenly not.


Return to “MiST”

Who is online

Users browsing this forum: No registered users and 6 guests