OneChipMSX Initial Program Loader

By robinsonb5

Supporter (10)

Аватар пользователя robinsonb5

10-08-2014, 12:54

Hi Smile

I've been looking at the DE1 port of the OneChipMSX over the last couple of days with a view to porting it to a couple of other FPGA boards, including the Turbo Chameleon 64. From what I've seen so far it won't be too much of a problem, the biggest complication is that there's no EPCS device on-board. There is a completely different flash chip, and some communication with an oboard µC is necessary to find the coorrect base address, so to get this working I'm going to need to rewrite the Initial Program Loader.

Therefore yesterday and today I've been mentally mapping out the project and figuring out what happens where, and started adding some detailed annotations to the only copy of the ipl.asm source I could find.
(This is actually my first exposure to Z80 assembler, and I have to say I'm blown away by the code density and elegance of the instruction set!)

Anyhow, I've just been reading the following code:


	PUSH	BC		; Save registers
	LD	B,51H		; Attempt a read
	LD	HL,4000H
	JR	C,XF137		; Read failed - reset card.

The first read to the card will fail because it hasn't been initialised yet, so the firmware then resets the card, but as far as I can see, doesn't then attempt the read again and falls back immediately to EPCS booting. So loading the BIOS from SD card will only work if the card's already initialised? Or have I misunderstood something here?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Guillian

Prophet (3457)

Аватар пользователя Guillian

11-08-2014, 10:09

Actually it tries to read again after initializing the card in SPI mode.
The "RET C" checks if there was an error in the initialization process (carry flag set) and returns or continues depending on that.

By robinsonb5

Supporter (10)

Аватар пользователя robinsonb5

11-08-2014, 13:28

Ah - thank you! I'd missed the fact that RET C was conditional - makes more sense now.

By robinsonb5

Supporter (10)

Аватар пользователя robinsonb5

22-09-2014, 19:43

I've had a lot of fun and learned a lot in the process, but I've now got a version of the OneChipMSX core working nicely on the Turbo Chameleon 64 - complete with an on-screen display menu to replace the DIP switches.

It runs on the DE1 too, and It should be a simple matter to port this to other comparable FPGA platforms (15,000-ish LEs, SDRAM, SD-card, PS/2 keyboard) since the dependency on the EPCS flash is removed, and the SD Bootstrap is now a bit more forgiving.

More information here:
Full source on github, here:

As an MSX newcomer, I'm finding it to be a really interesting platform!

By KdL

Paragon (1413)

Аватар пользователя KdL

22-09-2014, 21:40

hi robinsonb5, you can check my ocm-pld 3.2.2 for a commented variant of code:

website -->
folder --> 20140727 OCM-PLD v3.2.2 by KdL.7z\esemsx3\src\peripheral\asm_iplrom
file --> iplrom_320k.asm

By robinsonb5

Supporter (10)

Аватар пользователя robinsonb5

23-09-2014, 00:19

KdL wrote:

hi robinsonb5, you can check my ocm-pld 3.2.2 for a commented variant of code:

Thank you for that - most enlightening.

In my variant I've actually stripped the IPL down to the very bare minimum - it merely receives the BIOS from a newly-added control module which handles loading it from SD card. (This project has been an excuse to build that module - I plan to use it in other cores too!) This avoids the first-file-on-the-card limitation, and also means the BIOS can be loaded from SDHC and FAT32 cards - though obviously only booting into BASIC.

By _ThEcRoW

Expert (128)

Аватар пользователя _ThEcRoW

05-10-2014, 15:10

Is this core implementing a msx2+?