I want to learn MSX-C, where do I start?

Page 9/12
2 | 3 | 4 | 5 | 6 | 7 | 8 | | 10 | 11 | 12

By anonymous

incognito ergo sum (116)

anonymous's picture

26-08-2015, 14:35

DarkSchneider wrote:

What about the IX register to call EXTROM?

There's another struct for this called XREG, defined in BDOSFUNC.H:

typedef struct {
    unsigned af;
    unsigned ix;
    unsigned iy;
    unsigned bc;
    unsigned de;
    unsigned hl;
} XREG;
DarkSchneider wrote:

OK, I found it, using calsub().

Where did you see this function, I can see the definition in MSXBIOS.H, but the manual doesn't mention it. The manual recommends using callxx() when you need to set IX and/or IY.

By AxelStone

Prophet (3023)

AxelStone's picture

26-08-2015, 14:53

JaviLM wrote:

Where did you see this function, I can see the definition in MSXBIOS.H, but the manual doesn't mention it. The manual recommends using callxx() when you need to set IX and/or IY.

http://www.fvue.nl/wiki/MSX-C_manual#BIOS_Library

Quote:
VOID calsub(adrs, reg)
NAT adrs;
REGS *reg;

Calls a routine from SUB-ROM whose address is 'adrs'. 'Reg' must point to a table with register values for F, A, BC, DE and HL.

There is really a lot of call functions in C :-?

By anonymous

incognito ergo sum (116)

anonymous's picture

26-08-2015, 14:57

AxelStone wrote:
JaviLM wrote:

Where did you see this function, I can see the definition in MSXBIOS.H, but the manual doesn't mention it. The manual recommends using callxx() when you need to set IX and/or IY.

http://www.fvue.nl/wiki/MSX-C_manual#BIOS_Library

Aha, I see. That's part of the MSX-C Library disk. In section 5.4.1 (page 62) it describes the functions to work with slots:

calbio(), calbas(), calsub(), calslt(), rdslt(), wrslt(), callx().

By The_Engineer

Master (177)

The_Engineer's picture

26-08-2015, 15:13

Hello JaviLM,
As MSX-DOS 2 supports the memory mapper, I wonder if ASCII had any ideas how to use it in MSX-C.
Any hints in the MSX-C v1.2 manuals how you should use the memory mapper in C?

By anonymous

incognito ergo sum (116)

anonymous's picture

26-08-2015, 15:22

The_Engineer wrote:

Hello JaviLM,
As MSX-DOS 2 supports the memory mapper, I wonder if ASCII had any ideas how to use it in MSX-C.
Any hints in the MSX-C v1.2 manuals how you should use the memory mapper in C?

I can't say whether ASCII had any plans to add mapper support under MSX-C because I don't know. MSX-C V1.2 does support MSX-DOS2 directories, but I can't see anything in the manual regarding using the memory mapper via the MSX-DOS2 mapper support routines. There's no need to look in the MSX-C Library manual either because it was released before MSX-DOS2.

In any case, adding a small library to support the MSX-DOS2 mapper should be simple enough.

By The_Engineer

Master (177)

The_Engineer's picture

26-08-2015, 16:08

Thanks for the clear answer: Agree that a small library would be possible, but the programmer still faces the challenge to make sure code, data, stack and mapper pages don't overlap. Effortless for a specialist, challenging for an MSX pro and not quite something for an MSX-C newbie Smile

By anonymous

incognito ergo sum (116)

anonymous's picture

26-08-2015, 16:22

It's true that writing a memory management library wouldn't be a trivial task, but that's not what I meant.

MSX-DOS2 already has those functions, so let's use them. The idea is to write a set of C functions that call the MSX-DOS2 mapper routines so they can be used from MSX-C.

That's basically what the MSX-C Standard Library and MSX-C Library are: mostly calls to existing MSX BIOS and MSX-DOS functions.

By AxelStone

Prophet (3023)

AxelStone's picture

26-08-2015, 17:44

Correct me if I'm wrong, but BIOS has functions to handle memory slots, right? This is, if you plan to use more than 64k you could do that using bios functions as rdslt and wrslt, both of them available in MSX-C.

If you insist in using MSX-DOS2 mapper functions, there is a mapper implementation of that made for Turbo Pascal by Kari Lamassari. They are all implemented using inline calls (ASM) so perhaps and experienced programmer could convert it to MSX-C functions.

By anonymous

incognito ergo sum (116)

anonymous's picture

26-08-2015, 17:52

AxelStone wrote:

Correct me if I'm wrong, but BIOS has functions to handle memory slots, right? This is, if you plan to use more than 64k you could do that using bios functions as rdslt and wrslt, both of them available in MSX-C.

These are used for different things. rdslt() and wrslt() are used to read and write single bytes from a different slot. Reading or writing each single byte requires a call to the function. This is ok if you just want to access that data without doing the slot switching yourself, but it would be terribly inefficient for transferring larger amounts of data.

The MSX-DOS2 mapper functions do more than that: they locate and number the available memory segments, allow you to map any memory segment to any page in the Z80's address space (making bulk data transfers very fast), etc. However, I'm not an expert on this.

AxelStone wrote:

If you insist in using MSX-DOS2 mapper functions, there is a mapper implementation of that made for Turbo Pascal by Kari Lamassari. They are all implemented using inline calls (ASM) so perhaps and experienced programmer could convert it to MSX-C functions.

No need to complicate things that much. The MSX-C manuals explains very well how to pass data to/from assembler routines (pages 54-59). It shouldn't be too much work to just wrap the MSX-DOS2 system calls in MSX-C functions.

I'll explain the process on my blog when we need that part. :-)

By Grauw

Ascended (10011)

Grauw's picture

26-08-2015, 18:31

Slot selection doesn't deal with memory mapper banks. Vice versa, DOS2 memory mapper support routines only deal with the mapper and don't do slot selection. They're two different things.

(Say a 1024K memory mapper is in slot 2, and you want to access the last 16K at address 8000H-BFFFH. You use the slot selection routines to make the RAM in slot 2 accessible at 8000H, and then use the mapper support routines to select bank 3FH, the final 16K.)

If you only deal with the primary mapper, in DOS you don't need to do slot selection at all because the primary RAM is already present in the entire address space by default.

For C, the core difficulty to use this memory remains the same though, with both slot and RAM (or ROM) bank selection: how to manage the swapping in and out of data from the address space. I don't know enough about C to answer this question. Probably you should only access it as plain byte arrays.

Page 9/12
2 | 3 | 4 | 5 | 6 | 7 | 8 | | 10 | 11 | 12