A side question, any recommendation on emulator and books if I want to replicate what Carmack did for Commander Keen? The keen dream source code uses C and assembly so I'll do the same.

I guess Dosbox is accurate enough for a 386dx with an ega card, and this book ( https://www.amazon.ca/Programmers-Guide-Ega-Vga-Cards/dp) is good enough for the guide?

For development tool I plan to use vscode with openwatcom C compiler.

Any other book I should take to learn assembly and DOS C? I already know some C but I guess it's a bit different than the old C.

I would check out the Andre Lamothe DOS game programming books

You will also want to start with a 16-bit C compiler like Borland Turbo C or Microsoft C, a lot of the code is very different from the 32 but protected mode versions

There's always DJGPP which Quake was written in, but again 16-bit DOS code isn't going to run as-is.

Thanks. I used to do some C++/sdl2 game programming just for fun but I think this project needs more study.

TBH I don't know if Commander Keen is using protected mode. I do not understand the code and I assume not. I need to know how to program and compile for DOS 16-bit, as you said, and how to inline assembly, and how to use assembly to put pixels on screen using a virtual ega card provided by dosbox.