MiSTer PCXT

User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

I have not yet been able to continue development, but I take all comments into account. If I have any problems, I will comment here.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

I am reading BIOS.ASM.

I think BIOS is missing a write to the ICW register.

For example, the following:

Code: Select all

; ICW1
; 7:
; 6:
; 5:
; 4: 1
; 3: Edge toriggered mode
; 2: 
; 1: Single
; 0: ICW4 NEEDED
mov al, 13h
out 20h, al

; ICW2
; 7: T7
; 6: T6
; 5: T5
; 4: T4
; 3: T3
; 2: 0
; 1: 0
; 0: 0
mov al, ??h ; Set top 5 bits of vector Address
out 21h, al

; ICW4
; 7: 0
; 6: 0
; 5: 0
; 4: Not special fully nested mode
; 3: bufferd mode
; 2: /master
; 1: Normal EOI
; 0: 8086/8088 mode
mov al, 0dh
out 21h, al
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kitune-san wrote: Sat May 21, 2022 5:34 pm I am reading BIOS.ASM.

I think BIOS is missing a write to the ICW register.

For example, the following:

Code: Select all

; ICW1
; 7:
; 6:
; 5:
; 4: 1
; 3: Edge toriggered mode
; 2: 
; 1: Single
; 0: ICW4 NEEDED
mov al, 13h
out 20h, al

; ICW2
; 7: T7
; 6: T6
; 5: T5
; 4: T4
; 3: T3
; 2: 0
; 1: 0
; 0: 0
mov al, ??h ; Set top 5 bits of vector Address
out 21h, al

; ICW4
; 7: 0
; 6: 0
; 5: 0
; 4: Not special fully nested mode
; 3: bufferd mode
; 2: /master
; 1: Normal EOI
; 0: 8086/8088 mode
mov al, 0dh
out 21h, al
It is possible that it is not complete, after all, this BIOS belongs to the Next186 core, which has its particularities.

My final idea is to use an original BIOS, like the IBM 5150, and the BIOS sources are published here:

http://bitsavers.org/pdf/ibm/pc/pc/1502 ... _Apr83.pdf

So far I have not been able to install it because we did not have such a complete implementation as the one offered by KFPC-XT, because if you look at this original BIOS, there are multiple checks of the different systems, such as DMA, etc...

Another option is to use the sources used by Sergey Kiselev's PCXT clone:

https://github.com/skiselev/8088_bios

These are all options that will have to be analysed in depth.
User avatar
pgimeno
Top Contributor
Posts: 710
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 277 times
Been thanked: 226 times

Re: MiSTer PCXT

Unread post by pgimeno »

kitune-san wrote: Sat May 21, 2022 3:12 pm If XT code is required, conversion on the BIOS side is necessary.
MiSTer sends set 2 codes. Are you saying that the BIOS should translate set 2 to set 1?

That sounds wrong.

"Set 1 contains the values that the XT keyboard (with only one set of scancodes) produced, with extensions for new keys. Someone decided that another numbering was more logical and invented scancode Set 2. However, it was realized that new scancodes would break old programs, so the keyboard output was fed to a 8042 microprocessor on the motherboard that could translate Set 2 back into Set 1. Indeed a smart construction. This is the default today. Finally there is the PS/2 version, Set 3, more regular, but used by almost nobody."

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html

The set 2 codes sent by Main must be translated to set 1 codes by the keyboard controller, not by the BIOS. The PC AT incorporated a microcontroller just for that purpose (and a few others); in the MiSTer the core also needs to translate set 2 codes to set 1, because many games bypass the BIOS and read directly from the keyboard controller, and of course they expect set 1 codes. That's just inherent to how the MiSTer interfaces with the keyboard. The Amiga core has a keyboard in Main made specifically for it, but that's an exception and I think it should be removed; the translation for the XT core should be done in the core. Not in Main, not in the BIOS.

See the translation table of ao486: https://github.com/MiSTer-devel/ao486_M ... ps2.v#L514 - the code is BSD licensed, so it shouldn't be a problem to grab the table.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

pgimeno wrote: Sat May 21, 2022 8:24 pm
kitune-san wrote: Sat May 21, 2022 3:12 pm If XT code is required, conversion on the BIOS side is necessary.
MiSTer sends set 2 codes. Are you saying that the BIOS should translate set 2 to set 1?

That sounds wrong.

"Set 1 contains the values that the XT keyboard (with only one set of scancodes) produced, with extensions for new keys. Someone decided that another numbering was more logical and invented scancode Set 2. However, it was realized that new scancodes would break old programs, so the keyboard output was fed to a 8042 microprocessor on the motherboard that could translate Set 2 back into Set 1. Indeed a smart construction. This is the default today. Finally there is the PS/2 version, Set 3, more regular, but used by almost nobody."

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html

The set 2 codes sent by Main must be translated to set 1 codes by the keyboard controller, not by the BIOS. The PC AT incorporated a microcontroller just for that purpose (and a few others); in the MiSTer the core also needs to translate set 2 codes to set 1, because many games bypass the BIOS and read directly from the keyboard controller, and of course they expect set 1 codes. That's just inherent to how the MiSTer interfaces with the keyboard. The Amiga core has a keyboard in Main made specifically for it, but that's an exception and I think it should be removed; the translation for the XT core should be done in the core. Not in Main, not in the BIOS.

See the translation table of ao486: https://github.com/MiSTer-devel/ao486_M ... ps2.v#L514 - the code is BSD licensed, so it shouldn't be a problem to grab the table.
Okay.
I will try to create a converter between KF8255 and KFPS2KB.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

kitune-san wrote: Sat May 21, 2022 10:33 pm Okay.
I will try to create a converter between KF8255 and KFPS2KB.
Beta version.
https://github.com/kitune-san/KFPS2KB/b ... PS2toXT.sv

I am debugging in my own environment.
User avatar
pgimeno
Top Contributor
Posts: 710
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 277 times
Been thanked: 226 times

Re: MiSTer PCXT

Unread post by pgimeno »

Thank you very much! By the way, the cores don't receive some Japanese keyboard keys; if you want Mister to support Japanese keyboards please check this thread: viewtopic.php?t=4477
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

I merged converter into KFPS2KB.sv.

https://github.com/kitune-san/KFPS2KB/b ... KFPS2KB.sv

Please replace KFPS2KB.sv in MisterPCXT.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

Great, I'll use it. I've enabled the keyboard clock and data signals, and also the BIOS code that the Next186 uses for its initialization and interrupt enablement... I haven't looked at it much yet but at some point it gets stuck, because the BIOS messages don't appear and the BASIC ROM doesn't start... I can debug it but I'll probably start debugging with the original IBM BIOS, which is the one I'd definitely like to use... I'll keep you informed as I see problems.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

I would like to know a few things.

Does the problem occur without keyboard action?

Does the problem occur when all interrupt except the keyboard are masked?

What is the ICW register setting?
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kitune-san wrote: Sun May 22, 2022 2:12 pm I would like to know a few things.

Does the problem occur without keyboard action?

Does the problem occur when all interrupt except the keyboard are masked?

What is the ICW register setting?
I have not been able to look at it in detail, but I can tell you that the problem is generated by the following instructions that I highlight in red:
Enable PIC.png
Enable PIC.png (11.65 KiB) Viewed 19748 times
Here you would have to see if the PIC module is jumping to the int08 and int09 interrupts respectively, or if the code of these functions (specific to the Next186 core) are not the most suitable for a real XT. For that reason, if the latter is the reason, it would be more appropriate to directly debug a BIOS of a real PCXT, such as that of an IBM 5150.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

At least, the 8088 mode and vector must be set to 8259 to work properly.
Could you add the setting to ICW to the current BIOS?
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

I have setting the ICW:
Setting ICW.png
Setting ICW.png (7.48 KiB) Viewed 19644 times
Now it doesn't crash, however I'm not getting the keyboard working, but I'll look into it, because I haven't yet applied the latest changes you've made in this regard.

However, I have decided to cut all ties with the Next186 BIOS, and have migrated to Sergey Kiselev's PCXT BIOS, which is also Open Source :D :

Image

As I have time, I will continue testing and add the latest implementations that have been made to the KFPC-XT keyboard module... I will keep you posted.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

Are ps2_clock and ps2_data wired in PCXT.sv?
I don't know, because I don't have the latest.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kitune-san wrote: Mon May 23, 2022 6:56 am Are ps2_clock and ps2_data wired in PCXT.sv?
I don't know, because I don't have the latest.
Yes they are connected, sorry for not making it public yet. I have to do some code cleanup first... as soon as I can I'll post it and let you know.
jordi
Posts: 282
Joined: Thu Jun 11, 2020 10:11 am
Has thanked: 112 times
Been thanked: 87 times

Re: MiSTer PCXT

Unread post by jordi »

for future: USB -> LPT for connecting real OPL devices (OPL3LPT) (even older printers) does it makes sense?
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

jordi wrote: Mon May 23, 2022 7:37 am for future: USB -> LPT for connecting real OPL devices (OPL3LPT) (even older printers) does it makes sense?
I don't know if that makes much sense, it would be better to support adding MT32 externally, like on ao486, but more on that later.

What I will have before all that is @jotego's JTOPL2, which I will add when I have the rest of the problems solved.
User avatar
kathleen
Top Contributor
Posts: 421
Joined: Fri Jun 26, 2020 4:23 am
Location: Belgium
Has thanked: 243 times
Been thanked: 138 times

Re: MiSTer PCXT

Unread post by kathleen »

jordi wrote: Mon May 23, 2022 7:37 am for future: USB -> LPT for connecting real OPL devices (OPL3LPT) (even older printers) does it makes sense?
You mean an external adaptor like this ?

https://www.amazon.co.uk/dp/B00EXK9CWU/

If yes, I guess that firstly it will have to be recognized by Linux right ?

@spark2k06,

Don't know if this could be doable, but a snac2ide would be amazing. Like the one which exists for the C64 core (snac2iec), I've got mine this week-end, and having the possibility to connect a real floppy to the mister and get it working like on the real hardware for me is really the cherry on the cake.

I'm wondering then if this will be possible also for the PC-XT to connect a real floppy drive 3.5" and/or 5.25".

Again, this is my point of view, but any of the "old" device which can be controlled by the Mister males sense.

かすりん

kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

spark2k06 wrote: Mon May 23, 2022 7:00 am
kitune-san wrote: Mon May 23, 2022 6:56 am Are ps2_clock and ps2_data wired in PCXT.sv?
I don't know, because I don't have the latest.
Yes they are connected, sorry for not making it public yet. I have to do some code cleanup first... as soon as I can I'll post it and let you know.
Thank you for information.

Perhaps the KFPS2KB input may have timing issues.
You may need a buffer as in lines 54-86 of https://github.com/kitune-san/KFPS2KB/b ... EMO/top.sv.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kathleen wrote: Mon May 23, 2022 10:13 am
jordi wrote: Mon May 23, 2022 7:37 am for future: USB -> LPT for connecting real OPL devices (OPL3LPT) (even older printers) does it makes sense?
You mean an external adaptor like this ?

https://www.amazon.co.uk/dp/B00EXK9CWU/

If yes, I guess that firstly it will have to be recognized by Linux right ?

@spark2k06,

Don't know if this could be doable, but a snac2ide would be amazing. Like the one which exists for the C64 core (snac2iec), I've got mine this week-end, and having the possibility to connect a real floppy to the mister and get it working like on the real hardware for me is really the cherry on the cake.

I'm wondering then if this will be possible also for the PC-XT to connect a real floppy drive 3.5" and/or 5.25".

Again, this is my point of view, but any of the "old" device which can be controlled by the Mister males sense.
I'm sure there will be this and many other interesting proposals... I myself have some ideas to add, such as:

* JTOPL2 and other sound cards
* EMS memory
* MT32 support like in ao486
* Others...

But first we will try to get this working, because there is still some work to do to get the OS bootable ;)
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kitune-san wrote: Mon May 23, 2022 10:23 am
spark2k06 wrote: Mon May 23, 2022 7:00 am
kitune-san wrote: Mon May 23, 2022 6:56 am Are ps2_clock and ps2_data wired in PCXT.sv?
I don't know, because I don't have the latest.
Yes they are connected, sorry for not making it public yet. I have to do some code cleanup first... as soon as I can I'll post it and let you know.
Thank you for information.

Perhaps the KFPS2KB input may have timing issues.
You may need a buffer as in lines 54-86 of https://github.com/kitune-san/KFPS2KB/b ... EMO/top.sv.
I've added it, but it doesn't seem to work either... I'll have to investigate further. For the moment, I've already made the code public, updating the master branch:

https://github.com/spark2k06/PCXT_MiSTer

In the changes you will also see this last proposal.
JasonA
Core Developer
Posts: 40
Joined: Fri Mar 11, 2022 9:46 am
Has thanked: 14 times
Been thanked: 104 times

Re: MiSTer PCXT

Unread post by JasonA »

Great work.

Is it in a state for me to look at using verilator?
Buy me a coffee https://Ko-fi.com/jasona
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

Thank you!

in PCXT.sv 285-288

Code: Select all

    .ps2_kbd_clk_in		(ps2_kbd_clk_out),
	.ps2_kbd_data_in	(ps2_kbd_data_out),
	.ps2_kbd_clk_out	(ps2_kbd_clk_in),
	.ps2_kbd_data_out	(ps2_kbd_data_in),
wire ps2_kbd_clk_out
and
wire ps2_kbd_data_out
are probably unuse. floating now.

Shouldn't it be set to 1 or 0?
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

Maybe it's like this.

Code: Select all

hps_io #(.CONF_STR(CONF_STR), .PS2DIV(2000), .PS2WE(1)) hps_io
(
…
	.ps2_kbd_clk_in		(1'b1),
	.ps2_kbd_data_in	(1'b1),
	.ps2_kbd_clk_out	(ps2_kbd_clk_in),
	.ps2_kbd_data_out	(ps2_kbd_data_in),
…
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

kitune-san wrote: Mon May 23, 2022 2:20 pm Maybe it's like this.

Code: Select all

hps_io #(.CONF_STR(CONF_STR), .PS2DIV(2000), .PS2WE(1)) hps_io
(
…
	.ps2_kbd_clk_in		(1'b1),
	.ps2_kbd_data_in	(1'b1),
	.ps2_kbd_clk_out	(ps2_kbd_clk_in),
	.ps2_kbd_data_out	(ps2_kbd_data_in),
…
That was the problem!

Thank you very much :-)
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

JasonA wrote: Mon May 23, 2022 1:10 pm Great work.

Is it in a state for me to look at using verilator?
To be honest, I don't know. I have no knowledge about that tool... :|, Maybe one day I will give it a chance.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: MiSTer PCXT

Unread post by spark2k06 »

It's time to get the OS to load. I'm not familiar with VHD file support in MiSTer... and I suppose I could somehow take advantage of the IDE module of the ao486 project:

https://github.com/MiSTer-devel/ao486_M ... /soc/ide.v

Any help or ideas here would be most welcome.
Bas
Top Contributor
Posts: 623
Joined: Fri Jan 22, 2021 4:36 pm
Has thanked: 80 times
Been thanked: 324 times

Re: MiSTer PCXT

Unread post by Bas »

AO486 uses raw disk images. For a fixed-size VHD the only difference is in the last 512 bytes anyway and they don't get used at all. Just don't clobber the final 512 bytes if you ever want to open the file in anything that does expect a valid VHD. The VHD spec also prescribes how to deal with CHS geometry versus different disk sizes. AO486 also doesn't honour those limitations either. So for all intents and purposes the AO486 uses simple, flat, raw disk images.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: MiSTer PCXT

Unread post by kitune-san »

spark2k06 wrote: Mon May 23, 2022 2:40 pm
kitune-san wrote: Mon May 23, 2022 2:20 pm Maybe it's like this.

Code: Select all

hps_io #(.CONF_STR(CONF_STR), .PS2DIV(2000), .PS2WE(1)) hps_io
(
…
	.ps2_kbd_clk_in		(1'b1),
	.ps2_kbd_data_in	(1'b1),
	.ps2_kbd_clk_out	(ps2_kbd_clk_in),
	.ps2_kbd_data_out	(ps2_kbd_data_in),
…
That was the problem!

Thank you very much :-)
Great! :D

If data readout cannot keep up, try connecting ~interrupt_request[1] to ps2_kbd_clk_in in hps_io.
jordi
Posts: 282
Joined: Thu Jun 11, 2020 10:11 am
Has thanked: 112 times
Been thanked: 87 times

Re: MiSTer PCXT

Unread post by jordi »

kathleen wrote: Mon May 23, 2022 10:13 am
jordi wrote: Mon May 23, 2022 7:37 am for future: USB -> LPT for connecting real OPL devices (OPL3LPT) (even older printers) does it makes sense?
You mean an external adaptor like this ? https://www.amazon.co.uk/rhinocables%C2 ... 2153&psc=1

If yes, I guess that firstly it will have to be recognized by Linux right ?

@spark2k06,

Don't know if this could be doable, but a snac2ide would be amazing. Like the one which exists for the C64 core (snac2iec), I've got mine this week-end, and having the possibility to connect a real floppy to the mister and get it working like on the real hardware for me is really the cherry on the cake.

I'm wondering then if this will be possible also for the PC-XT to connect a real floppy drive 3.5" and/or 5.25".

Again, this is my point of view, but any of the "old" device which can be controlled by the Mister males sense.
I guess most of these usb to lpt will be simple for linux, althought they need supporting low level features for /dev/parport

I do have this inexpensive "adlib card", which does a very good job:
https://www.serdashop.com/OPL3LPT

and LPT is pretty flexible: networking, printers, adlib cards, cdroms, even some cheap covox.
Post Reply