sdcc is beginning to support C Embedded, which is a C language extension for embedded systems. C Embedded specifies how to deal with bankswitched memory and sdcc is starting to do that but I haven't looked in detail at it yet. sccz80 does have 3-byte far pointers but again it's preliminary. This is on my to-do list so once I've studied it I will include it in the crts. I don't think it needs more than providing a subroutine in page-0 (the 'HOME' bank) to perform bankswitching and maybe provide some trampoline code.
So page-0 is always "fixed" and not "mapped out" ever. That's a good thing, especially if you plan to use EXOS calls, and of course because interrupts, etc.
So for now, it's left to the user program to handle bankswitched memory intelligently. What we can do with the crt, for the ep, is make sure all the video-related stuff, some key functions like memcpy, and interrupt related handlers are in page-0 so that user code can be free to place two 16k pages in page-2/3 to copy or operate on data in different banks. The ep will be the first target that needs a special memory map for this sort of thing
I see.
Heh yeah That's what I want to do: tell EXOS that the program is CODE+DATA+BSS bytes in size and have it allocate the pages but only load CODE+DATA bytes. But because of the 48k limit it might be better just to do the BSS allocation at runtime so that it is possible to go beyond 48k.
Well, you define the length of the loaded program in the type-5 EXOS header (contains CODE+DATA, so the "pre-defined" areas unlike BSS). Then you may need to check that if BSS size in addition to that size (CODE+DATA) would span into a new segment(s?). If yes, you need to allocate another segment(s). And then you fill the BSS area with zeroes (regardless you needed to allocate segments or not, because BSS could fit into the already used segments for the loaded program). Getting beyond 48K is interesting, but also problematic: if CODE+DATA+BSS bypasses 48K boundary you need modify segment mapping (port $B3) all the time between video RAM and "tail" of the BSS, especially if the program needs frequent access of screen routines, thus a video RAM segment. But if you really need to have more code+data+bss than 48K than you can't do too much. Well, maybe one thing: if you need direct VRAM access and you allocated a VRAM segment for page-3 (C000-FFFF) and it's not used fully, you can use VRAM to store eg BSS data as well. Yes, VRAM is slower, but maybe it's still faster if you can avoid memory paging all the time! It depends on the exact situation though.
For example EXOS uses a segment (or more segments, but by default one) in VRAM (segment $FF) as its own RAM area also called "system segment". It's a VRAM segment because it's also used to store LPTs, video RAM, etc, not just EXOS variables and similar things. Though it can be faster to use VRAM only for video purpose data, and "normal RAM" for other EXOS data, it would fragment the available memory map, and also the situation would be more complicated because of the needed mapping changes all the time. That system segment btw grows downwards, eg if you open an EXOS channel (let it be a file, or DISPLAY:, etc) EXOS need some RAM, and system segment usage is maintained (the lowest used address) in the form of "EXOS boundary" (technically you - as user app - can even allocate segment when all segments are used, then EXOS will provide the system segment as "shared segment" providing EXOS boundary is the address you should not use beyond).
The BSS segment has to be zero according to the C standard but the crt takes care of all initialization details so the loader doesn't have to worry about it.
Well, yes, it's only me that I hate to rely on initialized BSS, eg a variable in the global scope "int a;" should be zero according to the C standard, but the same "int a;" will not within a function (since it will be allocated on the stack). And some compilers will complain about "uninitialized variable" even if it's in the global scope, so it's initialized to zero according to the C standard anyway, if I am right ... Anyway, just ignore my comment, of course it is almost nothing to fill the BSS area with zero bytes and it seems it is expected by standards.
I've given the ep's different video modes my own names (I don't know if something better already exists) and I'm measuring characters as 8x8 pixels:
* p2 (pixel 2 colour mode) 80x25 characters full screen
* p4 (pixel 4 colour mode) 40x25 characters full screen
* p16 (pixel 16 colour mode) 20x25 characters full screen
* a8 (attr 8 scan lines tall) 40x25 characters full screen, 40x25 attributes
* c128 (hardware characters)
You can do this, but please note that EXOS usually refers vertical resolution in units of 9 pixels instead of 8. Of course if you plan to have your own routines to set up video modes (so: defining LPT) that it's your business to use 8 pixel tail characters, etc, whatever. But eg the character set definition for hardware character mode is also 8*9 pixels by EXOS (though of course, you can embed your own charset to the binary, but it also enlarges your binary of course). By the way, Nick allows any tail of characters in hardware character mode, also the definition of characters has the layout to support this (that is, eg in ch128 mode, 128 bytes for the first rasterline of the 128 characters, than again 128 bytes for the second, etc, unlike other schemes eg with Commodore 64 where the first 8 bytes are for the first character of the charset for all rasters, etc). And if you are in doubt: Nick can access the VRAM _only_ so even character set must be stored there. Of course EXOS ROM contains the charset, but it's copied into the VRAM to be used by Nick then. "Software character mode" is of course a simple gfx mode at the other hand (the "80 column text mode" is that, in contrast of "40 column text mode" which is really a text mode!). In this case the "charset definition itself" is only used by software to "draw" characters thus - of course - it's not compulsory to store it in VRAM to be able to accessible by Nick.
I'm going to write the p4 primitives first and possibly the p2, c128 and a8 modes later. Ultimately all of them should be there but I think it will be up to the EP community if they are interested in it. I'm picking on the a8 mode specifically because this is compatible with the zx spectrum and the zx spectrum has a sprite library that has been used by many games which could easily use this mode on the EP. That sprite library is intended to support many video modes so it could be modified for other of the EP's modes but that is also a lot of work.
Yes, but Spectrum compatibility is limited because of the different attribute by "layout". Though it's a minor point.
Does this sound like a good method to deal with the EP's flexibility?
I think, other people should answer too. To be honest, I never had EP till 2002 or so, I get to know it as its "retro computing" state already, unlike more people here who were active even in the age of the EP. I still feel sometimes that I can't "beat" others' experience and knowledge originated from the "golden age" and not only "recently"
For file i/o, the clib in z88dk has not finalized it yet -- all the code is present for file systems but the drivers have not been written to do file i/o yet. The design is object oriented and operates like a stack where you would inject the target's native system at the level it can support. If the target does not supply any disk device the idea is we will supply the entire stack including a fat driver. But that's a long time for now.
Well, in case of EP it is not needed and probably you can't do it either (because of the different used hw solutions, I've already written about). Internally EXDOS uses FAT12 btw, but you don't need to know that too much, if you want to use only the "file level" functions. It's interesting to hear what z88dk plans, FAT driver etc, huh. I mean it's almost an OS then, and not only a compiler with its standard library too much
But EP has its own OS already, and not even a bad one! I don't know the goals of z88dk etc, but for me, I would vote for an ANSI-C like library eg usage of open() fopen() etc, so code can be portable between different systems at source code level, let it be an EP, or a modern PC ... But I know, it can be only *one* goal, the other can be - for example - to be able to exploit the target machine's abilities using the C language which may need its own "standard" suitable for the purpose. So it's really hard to judge, what would be better, at least it's hard for me ... Since you seem to know a way much on sdcc/z88dk etc, I wouldn't even dare to write on these too much more
For the first pass, I'll ignore file i/o (and don't forget you can always call EXOS directly from within C) and then second pass maybe look at connecting stdio to any sort of streaming that EXOS can support. At the lowest level, stdio generates about a dozen messages for i/o and if those messages can be satisfied by EXOS, it can be plugged in. I think things like the printer, serial i/o, built-in EXOS video drivers can probably plug into stdio but EXDOS (disk i/o) doesn't seem to be a candidate. It looks like it performs one whole read.write operation and then closes the channel. So in order to use it like a streaming device, the z88dk driver would have to cache disk blocks in ram for stdio to access.
I still think that for _EP_ C coders they would welcome EXOS-specific API as well, besided ANSI-C/z88dk/anything else. That would be a quite small and simple "glue" to call EXOS functions for the (for example) exos_CALLNAME() functions. Of course C code which use these are not so much portable anymore, but we shouldn't forget that 8 bit micros are not power machines, and often the best performing code can be written using platform specific own solutions instead of "abstraction layers" (in the form of APIs) providing cross-platform compatibility. Yes, that sounds the reverse of my previous thoughts that I would welcome ANSI-C like stuffs. Well, hard question, and both scenarios can be useful in some situations, I think!
I thought left, right, up, down (and space for fire) were the built in joystick.
Yes, they are.
But then I saw mention of port $b6 in connections with the joystick... how do I read the joystick directly? There's also mention of external joysticks in the EP tech docs -- is there a standard way to directly read that hw?
The _internal joystick_ is just like other keys on the keyboard, even the same membrane is used. The only difference, that other keys uses buttons to be able to be operated, while up/down/left/right keys use mechanically different solution and the designers used a joystick handle to be able to use them instead of buttons. So, yes, the internal joystick can be interpreted as other keys, keyboard matrix contains them. For the _external_ joysticks, the situation is different, they are handled differently, as you mentioned with the $b6 port, they are not part of the keyboard matrix. That also mean that a software want to use internal _and_ external joystick they must use separated routine for that purposes.
You can also think about mouse, which is a "hot" topic recently, especially because software like SymbOS makes it almost "a must", and it seems many people interested in this topic anyway. You should check other topics on the forum about this
But btw the keyboard matrix: do you plan to use your own keyboard scanning routine instead of EXOS' one? Well, it can cause some problems at least since there is eg UK and BRD (and HUN) layouts defined in software, and layout can be changed. Also, there were some projects to interface with an external keyboard without the hardware level compatibility (though to be honest, it can cause problems with many EP software as well, since many of them doing direct hw access), and only on software level the compatibility is provided. I'm really unsure here what can be the best solution, in some situation there can be a significant overhead to allow EXOS interrupt, keyboard scan, than doing EXOS calls to check keyboard etc ...
* sound. The sound library is 1-bit oriented but it contains some really good music synthesis routines. It should be compatible with Dave.
Btw, Dave supports 6 bit D/A too. And "of course" it has got oscillators with some modulation/distortion/etc settings which are more like digital implementation (unlike with C64 SID, where there are analogue filters for example). Dave is stereo btw.
EXOS here is quite elegant btw, it again uses the channel notion, so you can open a channel (with "file name" of SOUND:). You can write quite "complex" sound definition "control codes" there, and EXOS within the EXOS interrupt will "play it" in the "background". Or something like that, honestly I have never used these ...
http://ep.homeserver.hu/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/exos/sound/Ch2.htmlBut in general, you can see how advanced EXOS is
I was really surprised that a "8 bit micro" uses an OS like EXOS (biut . I don't want to say that you "must" use EXOS for SOUND at any price, just I mentioned it here for the completeness.
And feel free to write me "you're too much with those novels", I know I can write just too much
Hopefully my long posts are not only for enlarge the database of the forum