• Please review our updated Terms and Rules here

Introducing LokiOS. A new version of CP/M, written from Scratch, Compatible with CP/M2.2 Programs.

...Experience in programming (if I remember correctly, that was a study by FreeBSD) has shown that the number of bugs in source code goes up significantly as soon as the relevant code block (function) exceeds the length of the screen. Any additional line will improve quality of life for text editing work.
...
Interesting. IIRC, Forth has screens (routines/modules/etc) of 1024 bytes/words. This was perfectly matched by the TRS-80's 16x64 screen. That may be one reason that Forth seems so efficient (coding-wise) - each module is "limited" to only a single screen. Thus (according to the FreeBSD study) cutting down on the coding errors.
I've never been a real Forth programmer, but it is a pretty interesting/fun language.
 
I found some bugs due to long code.. I originally wrote for a single FDD to keep it simple while I was learning more about CP/M. Retofitting the code to support multiple drives and simultaneously support the Memory as Disk and external drives, with limited AV tables, turned out to be a long problem, but finally got it cleaned up, then deduplicated a lot of routine elements between read and write by making common sections of code as subroutines and calling them from both routines... The routines are a bit messy due to how CP/M has single or double allocations, and implementing it is kind of clunky, as it limits the size of routines that can support discrete elements of the function.

As a result, I ended up with some bugs. That an my testing was fairly limited, and the bugs were ones that slipped through my testing regime, so I was about 50 or so revisions of code since I last tested a particular function and somewhere a code change had screwed up something that was previously working. Turns out I was relying on early choices to not use IX/IY much as GP registers, so I wasn't reloading them before use, since in a single long routine, there is no point. As I added smaller functions to remove redundant code, then began modifying the code to do more, I ended up calling other routines that corrupted these registers where before the code was purely linear.

Fixed it in one place, then discovered the fix wasn't working in another... looked deeper, and it seems that my "boot" disk that was constructed by a different program written in basic had a bug, and wasn't reducing the record counter correctly when writing multiple extents, and as the disk it was on was tiny ( 64k ) and is intended to be a ROM disk with the CCP installed ( it can also load a CCP from other disks, etc, if it finds them first ) so I had never checked any larger extents, and it took ages to track down a buggy code element to the corrupt extent in the disk image generator code... Worse, it somehow caused my emulator to crash, so in the end I had to make checkpoints and distribute them throughout the code step by step, and wait until it crashed to determine that the fault was weird behaviour by the disk read routines, working across multiple disks simultaneously, when copying files with more than one extent, and only on an internal memory disk ( not floppies, or the MAD disk )....

Those kinds of bugs are pretty frustrating. And yeah, I ended up tracking code through multiple screens. In the end I began making block diagrams to figure out how the code was supposed to run, because I had already forgotten what I did and while the documentation in the right column was helpful, I had to go through it step by step and then track operation to figure out the problem was caused by corrupt extent data from an external application.

:(

But breaking the routine down into small modules, then documenting them in a block diagram did the trick - :) The above suggestion came in handy.
 
cj7hawk, will it allow the creation of named directories, instead of the numbered USER directories?


See, and stuff like this is why I call serious BS on people who claim that BASIC is a terrible language and you cannot do anything with it.
I think it's more like "BASIC is very limited and there are better tools to accomplish the goal faster and easier."
Obviously, much good software has been written in BASIC; cleverness can overcome almost any limitation.
But for purposes other than the thrill of the puzzle, there are better, faster, more versatile languages than BASIC...and interpreted languages naturally incur a performance overhead no matter how good the code is.
 
Hi @oktology , it already supports subdirectories - but they are fully conforming CP/M subdirectories at present - ie, I use the offset index in the DPB and they show up as a file in the local directory and are preallocated in terms of size and are mounted as a drive via the BIOS system as their own disk, even though they are part of an existing disk- It will support non-CP/M subdirectories ( ie, No allocation vector ) but I am working to make it more compatible with CP/M presently before I start diverting from there. The failure point in supporting CP/M subdirectories is the CP/M file system that requires allocation vectors and extents to locate the files in physical space as well as DPH, DPB etc.

Because I use a memory-as-disk architecture, all memory can be accessed as disk space, so memory management is fairly easy and external drives can be treated as a different kind of memory and all get mapped into physical space. So hard drives will probably start at $100000 just above the 1mb mark, and it supports up to 256Mb of total space.

Because of the driver structure within the hardware architecture, there is no problem with code size, and I'll probably end up making a single drive that can traverse directory structures over a network subsystem, since directories can be mostly omitted on smaller systems, and because native CP/M applications don't support directories either, I'll need to come up with a clever way to make sure any logged directory looks like a normal CP/M directory -

I still have some thinking to do about what an effective strategy to implement directories like that though, and will end up having to extend the FDOS to support it, so I'll almost certainly end up supporting it via other calls in the zero page rather than the one at 0005 since I don't want to contaminate the defacto CP/M calls.

That way it will happen transparently to the OS, in case someone drops in a real CP/M over the top -

What I will probably need is a way to have a "pop up" type window that allows me to mount a directory and traverse a directory structure and then present a flat single-directory file view of that directory to the OS - then it will work with other apps, eg, Wordstar, etc. Also, I'm planning on mixing graphics and text on the screen in the long run to allow graphics windows to be superimposed on the terminal background - and a mouse as well.

But the mechanics of that are still a way off and I haven't thought too much about it presently while I'm still working on fixing compatability issues. And I'm planning on building the hardware over the Christmas break if I get time.

As for the basic thing, well, BASIC is really just a syntax. The underlying language is what does the work, and to be honest, I'd love it if I could write something like, "Open "10.10.10.10:8080" for random as #2" to open TCP streams with it rather than having to use the converted C libraries... But the language itself is not really any less powerful than any other third generation language. It's just that it became the pariah from the 80s, because people liked to bag it, and very few people stayed with it, yet Freebasic is a very advanced language. It abstracts far more than is apparent and is approaching 4th generation, yet still has the comfortable syntax and feel that BASIC users know and love. It even accepts good-old QBASIC (MS_BASIC) format code if you like, though does ask you to let it know you're using a deprecated syntax. And it's not that hard to translate it up to the newer syntax and runs on all major platforms.

You can write Windows apps in it, and I've started using it's graphics routines to simulate a graphics display, and it was close enough that I can get an idea what the real display should be like - as well as letting me write code to support it before the hardware is finished. I write all my Linux code in basic too, and it performs almost as well as C and far better than any other linux based language I've tried.

David
 
Though I can't promise my code is all that great ;) It assembles correctly. Most of the time. ( I still find the odd bug in it )

And the emulator works pretty well... At least for documented codes.
Is there any place/URL where we can download/test LokiOS? Sounds - for me - very interesting ;)
 
Not yet - Well, kind of but I should put it up on github and include some instructions. At the moment it uses an assembler and emulator written in freebasic as mentioned, but they compile and work under Windows 11 and it's pretty easy to compile things under freebasic.

I'll try to get it up there in the next week or so - I'm not familiar with using it that much so need to spend some time working out how to put it up.
 
Is there any place/URL where we can download/test LokiOS? Sounds - for me - very interesting ;)
Hi @guidol ,

I've finally uploaded it to Github in case you were still interested.


I've never used Github for posting code before, but it should be everything needed to produce the Loki2.EXE executable, which should run on most PCs and create a virtual CP/M machine with 512x192 graphics....
It's still very rough, but the graphics driver works, and most of the hardware architectural support works... And the base BIOS, BDOS and CCP are all functional.

David.
 
Is there any chance of you writing/modifying a version of LokiOS for the Aussie Microbee 128k. Would love to see it working on a real Vintage computer. Native graphics is 512 x 256 on a 80x24 screen.
 
Hi @ChickenMan

I keep looking for a reasonable price microbee to add to my collection but am yet to find one. I am still surprised to this day that they are so hard to find here given how many were thrown away a few years back. I even know someone who personally threw out a pallet of several hundred he bought for about $20 about 20 years ago.

I used a microbee in my first job, writing z80 assembly for Leisure and Allied Industries / Timezone ( the video arcade franchise ) back in the 80s, so I remember them fondly now, although I disliked them at school because of computer factualisation. Even the nerds used to argue about their computers like they were football teams back then.

IIRC, the Microbee already uses CP/M so LokiOS at the most basic level would look and feel much the same, and do the same things. And the anticipated extra functions for network and video (including hardware vector graphics) would all have to be adapted as they are very hardware architecture dependent. The main feature is that it sees all memory as disk space, which means the BIOS has to be rewritten to gain that advantage also - though of course it would also work like normal CP/M with an unmodified BIOS and given all the necessary files are present, it would form a reasonable base to convert.

I'd probably need some assistance to convert it, but I assume the Microbee already has a working BIOS - if it runs CP/M 2.2, it can run LokiOS.

A better question would be what would you add to the architecture? I'd need to know more about the Microbee hardware design and what the objective was to convert it, and whether the intent was to keep the existing MMU or replace it with the Loki Architecture which supports Memory As Disk (ie, The entire memory space is a big DISK file ) and will support hardware vector graphics - though that's purely architectural - the BIOS/BDOS don't have any idea it exists and are pretty close to CP/M and the CCP only minimally supports it. As I add graphical elements, that would theoretically also be supported.

Most of the tools that are needed are already written ( eg, the z80 cross-assembler ) - happy to discuss the possibility. Having a z80 based CP/M source would certainly make it easier for most Microbee programmers, who, IIRC, were often z80 trained rather than 808x - though that might be just my view from remembering it back in the 80s. Converting the base OS to work shouldn't be too complex. Also, it's designed to boot off of a ROM rather than a Disk, at least enough to load the BIOS/BDOS into place.

Happy to discuss if you're interested or can provide more information?

Thanks
David.
 
Hi @guidol ,
I've finally uploaded it to Github in case you were still interested.
@cj7hawk Many Thanks for uploading LOKI2 ;)
I "compiled" LOKI2 (with the 32Bit version of FBC on a 64Bit Windows) with your make.bat and did get
a second ouput-windows (in a very small fontsize), but dont know how to start there an CP/M-application :(
Did I miss the magic secret? :)

LOKI2_Start.jpg

Then I tried it with the 64Bit Version of FBC on my 64Bit Windows and got it further:

LOKI2_Start_64Bit.jpg

BTW: with a DIR at A: and C: I do get a output loop (not formatted?)
Dribe L: and N: can be used with DIT, but N: is empty.
 

Attachments

  • LOKI2_compile_Log.txt
    21.8 KB · Views: 1
  • LOKI2_compile_64Bit_Log.txt
    21.8 KB · Views: 0
Last edited:
Hi Guidol,

It's still very much at 0.9 beta, but you can load up to 256K of files into the NVM space ( 512K to 768K ) via the LOKINVM.BAS program to try it with real CP/M applications.

A: through H: all reflect a single amstrad style of DSK format and I haven't included any tools there yet since I only just got a working revision up.
I: Is not yet written ( it's for mounting CP/M images over IP ).
J: and K: are network and video drivers.
O: and P: are reserved for User cards when the hardware gets built.

That leaves N: (NVM) and L: (BOOT) that you can presently put files on.

M: is reserved for memory operations.

Anyway, how to get files on N:....

Open LOKINVM.BAS and scroll down to a lot of lines that say something like
TRANSFER ("WS.COM","WS COM")
Some are REM'ed out. Some are there, but the files clearly are not.

The first field (WS.COM) is the local filename in the local directory.
The second field is the CP/M filename without a dot and with space padding (so count the characters to make sure it's 11 characters long ).

It's easy to change these to any files you want as long as they are in the local directory.

LOKIDISK.BAS does the same for L: but needs to not exceed 64K, and the first 4K is the boot sector ( BIOS and BDOS ). Also, you need to make sure the LOKI.COM (Startup.asm) and BOOT.BIN (boot.asm) are there, or it won't boot. It doesn't matter what order the files are loaded in, or where they are on the disk.

Then recompile just LOKINVM.BAS with the command FBC LOKINVM.BAS
The run it, and it will build the "NVM" image for N: drive and give you a report on how much disk was used. It doesn't have error trapping yet, so you won't see an error if you go more than 256K, but generally it's easy enough to see and I haven't modified it to be easy to use under Windows yet. It's just a simple emulator so I can work on the code while I get around to building the hardware. So far, I've designed the video card and tested it, and it produces graphics OK.

Later I'll write some tools, and use configuration files for the L: and N: drives to make it easy to set them up. For the moment, it needs this workaround.

Some programs don't exit nice - stuff I still have to address, but most I've tried will run correctly (eg, the Infocom games ).

The character set is 5x7 - Same as the ADM-3A terminals, but less spacing around the character.

David
 
Back
Top