Programming ObsoNET

Page 1/2
| 2

By aoineko

Paladin (810)

aoineko's picture

27-10-2022, 20:15

Hello,
Reading the technical documentation of the ObsoNET cartridge, it makes me want to develop an ethernet module for MSXgl that uses it.
Even if it only supports the ethernet layer, it still allows you to easily make games for a local network (with a simple arbitration's gameplay).
The interface with the cartridge's BIOS is very simple, but there is one point that is not clear for me.
In documentation part 4.1, we are asked to select segment 0 in the cartridge mapper.
Do we have to do it every time we want to access a BIOS function or just once at the beginning?
In other words, are there mechanisms that automatically change the selected segment or is it safe to consider that only the user can change it?

Disclaimer: Yes, I know that Gr8net is a "better" network cartridge and yes I know that it is recommended to use these devices via unAPI, but first things first. I first wish to play with the direct access to the ObsoNET.

Login or register to post comments

By aoineko

Paladin (810)

aoineko's picture

27-10-2022, 23:29

I pushed a first version of the ObsoNET module and sample on MSXgl's GitHub.

It seem to works fine under BlueMSX emulation:

Can anyone with this cartridge please test this ROM and tell what is displayed?
https://github.com/aoineko-fr/MSXgl/raw/main/projects/sample...

By gdx

Enlighted (6005)

gdx's picture

28-10-2022, 02:58

Without giving your Mac address of course. Wink

By aoineko

Paladin (810)

aoineko's picture

28-10-2022, 08:10

I just need to know if you got something else than 00.00.00.00.00.00.

By ducasp

Paladin (669)

ducasp's picture

28-10-2022, 16:29

Hi aoineko,

Why not use the Ethernet UNAPI that the device adheres to?

https://github.com/Konamiman/MSX-UNAPI-specification/blob/ma...

It will make your life a lot easier and if in the future another different interface using Ethernet UNAPI is made, no need to change code as you are not using it directly...

There is even a quite nice example using sdcc available:

https://github.com/Konamiman/MSX-UNAPI-specification/blob/ma...

If you do that, you will be accessing the UNAPI via EXTBIO and not needing to worry with a lot of details....

Nestor has already made a library to make easier to call UNAPI functions:

https://www.konamiman.com/msx/sdcc/asmlib.zip

I would recommend going through that route, it would save you quite a lot of time. For a ROM, you would need to change it a little to at start-up hook to H_STKE, and when your hook is called, you take control and start your ROM (then all slots will have been initialized, disk rom as well, etc) so you wouldn't depend on the obsonet being on a lower slot to use its UNAPI. ;)

By ducasp

Paladin (669)

ducasp's picture

28-10-2022, 16:49

By the way, running your rom in my BlueMSX emulated environment (I believe you are using it as well right?) I got the same results as you with your rom, but ETH.COM shows different:

Perhaps you are missing some initialization that needs to be done, or the BIOS not being initialized is causing the MAC to not be seen

By ducasp

Paladin (669)

ducasp's picture

28-10-2022, 17:07

I can confirm that the issue is that the rom loads before the BIOS initialize Obsonet, changing the machine layout so slot 2 is in 2-3 and obsonet is in 2-0 (being initialized before your rom) make it works:

Try this machine definition:

https://drive.google.com/file/d/11a5YFvjEovG-PTeBNPWltOklW8S...

You can unzip it to Program Files(x86)\BlueMSX\Machines

And then select the Other Slot version and insert your rom on slot 2, should work.

So, you need your rom to hook to H_STKE when it is first called and then exit, and your H_STKE hook should be the real start of your rom, so no matter what slot it is, the real ROM start will be only after all slots and devices have been initialized, should solve your issues ;)

By ducasp

Paladin (669)

ducasp's picture

28-10-2022, 18:17

Looking at your code, if your idea is to use the obsonet functions only, not the ethernet UNAPI, you might be able to skip the H_STKE hooking need if you call

* ONET_RESET (#7FCD): Initializes the ObsoNET card
Input: -
Output: -

After you return from call SRCHOBSO and found out that obsonet is installed and placed it in the memory so you can call that function Smile

Per Nestor's documentation, that function will initialize the card like boot does, so it is a work-around, maybe simpler to use than hooking to H_STKE Wink

By aoineko

Paladin (810)

aoineko's picture

28-10-2022, 21:22

You were right Ducasp, the MAC address is well initialized if I plug the program startup on the H_STKE hook (it was easy to test because MSXgl already have on option to force a delayed startup using this hook).

And according to the documentation, you are also right, calling the ONET_RESET function should retrieve the MAC address without going through the startup hook. The problem is that the program hangs if I call this function. I will try to understand why...

As for UNAPI, as I said in my initial disclaimer, just because I want to try direct control of ObsoNET, doesn't mean I won't add UNAPI support. I like to do things step by step starting from the low level.

By aoineko

Paladin (810)

aoineko's picture

28-10-2022, 22:23

I traced the code of ONET_RESET and it crashes deep in the code because of uninitialized value.
In my opinion, it is mandatory to execute the ObsoNET cartridge startup code before using it.
In fact, ONET_RESET works just fine if I delay the start of my program with the H_STKE hook.

An alternative would be to make a call on the address which is in the ROM header of the ObsoNET cartridge slot. But it seems cleaner to let the card initialize itself.

By ducasp

Paladin (669)

ducasp's picture

28-10-2022, 22:47

aoineko wrote:

You were right Ducasp, the MAC address is well initialized if I plug the program startup on the H_STKE hook (it was easy to test because MSXgl already have on option to force a delayed startup using this hook).

And according to the documentation, you are also right, calling the ONET_RESET function should retrieve the MAC address without going through the startup hook. The problem is that the program hangs if I call this function. I will try to understand why...

As for UNAPI, as I said in my initial disclaimer, just because I want to try direct control of ObsoNET, doesn't mean I won't add UNAPI support. I like to do things step by step starting from the low level.

When we talk about UNAPI, remember we have two types, Ethernet (which Obsonet supports out of the box with its bios, so no need to run ram drivers / not working with ROM applications unless they could be called after DOS is loaded) and TCP-IP (which Obsonet needs Internestor Lite to be loaded in RAM to implement it over the Ethernet UNAPI). What I was talking is that if you use Ethernet UNAPI you have the same simple functions you have calling the Obsonet bios directly, but working through UNAPI and not through calling fixed addresses on the cartridge that must be selected on slot / etc...

Advantage of doing this is twofold:

  1. You get experience calling UNAPI functions, which you will need for TCP-IP later
  2. If someone comes with a different Ethernet adapter supporting Ethernet UNAPI, your library would work just fine

But I understand advantage #2 might not be a real advantage... I really don't think at this point in time anyone would do an Ethernet / not TCP-IP accelerated adapter for MSX, makes no sense, so probably Obsonet probably will be the only adapter ever produced to support Ethernet UNAPI Tongue

But, anyway, just thinking out loud, do not worry too much about this if you think your current route is the best way to your goals Cool

Page 1/2
| 2