On 31.07.24 21:32, magic-girl--- via Freedos-devel wrote:
i'm an autistic girl of 12 years old. I try to convert ancient 16 bit ms-dos code to modern C#. However there is not even docs anymore about old ms-dos functions and i don't have ms-dos specific C knowledge.

There is not really DOS specific knowledge needed. It is mostly C with standard functions. The only relevant non-standard header used by the code you want to port is `conio.h`. The functions are `gotoxy()` (placing the cursor at the given column and row), `wherey()` (get the current cursor column), and `getch()` (wait for a key pressed by the user and return the value). The formatting could have been done with `printf()` anyway and waiting for a key press isn't really necessary on modern systems which usually allow the user to scroll back in the terminal.

Regarding the documentation of DOS and/or Turbo C specific functions: Embarcadero offers free and legal Downloads of Turbo C 2.01 and Turbo C++ 1.01 for DOS. You just need to register for a free account on the download site:

C: https://cc.embarcadero.com/Item/25636
C++: https://cc.embarcadero.com/Item/26014

Both versions come with an IDE with integrated help which includes the documentation of the functions.

I need a C# program that can read the THF file: it must just tell me the information of the screenshot

The entry point for that program is the `main()` function of THFTOOL.C. It calls `thfOpenMainFile()` (THF.H/THF.C) and then `listArchive()`.

There is no forum or anything where a living soul still can read this code :)

I highly doubt that. As already said this is C. Even if you don't know the `conio.h` functions or the dos specific `_dos_creat()`, `_dos_write()`, and friends, you know what the program is supposed to do, so their meaning/semantics can be guessed.

It's just this tool in the screenshot, applied to a THF file. Basically the program must read the file and make this listing.

So what concrete problems do you have? You'll have to learn some basic C, which is syntactically quite similar to C#.

C allows treating the same memory region as being different types. C# doesn't. I would solve that with a `BinaryReader` while reading the data. So instead of reading 4 bytes into a memory region that is treated as an integer (`long`) in C, use the `ReadInt32()` method instead.

The `thfFile` structure is treated as an array of bytes for decrypting and as a structure with a string and two `long` values. Here I would read the byte array from the file, decrypt that, and then wrap the array into a `MemoryStream` and a `BinaryReader` to read the filename and the two integer numbers from the decrypted byte array.

A simple THF lister (without the last column in the example) in C# fits on a printed page (line printer, 6 lines per inch).

Ciao,
        Marc 'BlackJack' Rintsch
--
Tradition is just peer pressure from dead people.



_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to