VOGONS


First post, by xor2003

User metadata
Rank Newbie
Rank
Newbie

I'm developing tool to simplify porting of DOS assembler code (including games) to modern platforms: https://github.com/xor2003/masm2c
(But I was not very succesful to implementing all the DOS INTs and hardware.)

So I tryed to use DOSBOX as a library. I mean real hardware is executing the game code https://github.com/xor2003/Bright-Eyes/blob/m … c/snake.cpp#L87, but when it needs DOS ints or some hardware like sound it will call dosbox.

So I used approach which I saw in another project:
I placed hook to dosbox after program is loaded into memory and before it actually starts: https://github.com/xor2003/Bright-Eyes/blob/m … xecute.cpp#L509

So DOSBox does not do instruction emulation of the game.
I faced the following issue:
The test game switched to CGA text mode 3. It prints characters directly to 0xB800 memory.
But I don't see anything. The screen is black.
I'm not good at DOSBox source code. I understand I should call some screen update periodically.
Looks like the
GFX_Events();
TIMER_AddTick();
is not enough.
Normal_Loop() is not called. Should I call it in separate thread?

Thank you in advance for pointing the problem.

Reply 1 of 10, by llm

User metadata
Rank Member
Rank
Member

do you want to run the program inside dosbox like Bright-Eyes so parts of the game is still emulated and other parts are running on the real hardware using your assembler like functions/macros?
why not keep it running in Dosbox completely - dosbox as runtime not as a library?

can you interchange rewritten code and emulated code? that would be a super mega feature

another nice project with equal target but different emulator: https://www.reddit.com/r/REGames/comments/qmq … er_and_rewrite/

Reply 2 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

I just used brighteyes as an starting point.
I think I will be able to run any dos source code without any modification after I will translate assembly source using my tool into c++.
1. get source code in assembler.
². you translate it with my tool into C++.
3. you build it with dosbox as Library
4. It starts on morden system without manual work.
5. source code is ready for rewrite or enhance. you can use modern development tools. you can instrument each instruction. For example propagate run-time information about value which is in fact is an offset and which segment it belongs too. Which is not available to static analisis using disasembler

Reply 3 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

Yes, the tool you mentioned is similar.

Spice86 is like DOSBox without full emulation: soundblaster, etc.
masm2c is additionally supports instruction conversion with high accuracity.

Yes, I think it is possible to use together original and rewritten code.
But I'm not sure it will still make sense to use original code since I'm trying to translate it with 100% accuracity.
It is possible since each instruction is translated with 100% accuracity and data offsets are unchanged.

I wish I could fix this graphics missing issue and go further

Reply 4 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

The problem was: to access video memory I should use page aware memory acces functions like real_writeb(es,di,bl);

Reply 5 of 10, by llm

User metadata
Rank Member
Rank
Member
xor2003 wrote on 2021-11-09, 21:14:

The problem was: to access video memory I should use page aware memory acces functions like real_writeb(es,di,bl);

the generated code is a little bit hard to read - but still nice because it works

cs=0x1b2;eip=0x000021; 	R(MOV(ah, 7));	// 153 mov     ah, 7 

is there a real need for also having simple register values assign like this - couldn't that be replace with a simple

cs=0x1b2;eip=0x000021; 	R(ah = 7);

or something?

i really hope that using dosbox as backend for your tool will ease the porting for many more 16bit DOS games

Reply 6 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

Yes, for release MOV can be replaced with only =. Since flags are not affecting.
For testing it is easier to instrument such code.
For example I can make register to be object and trace where value was first assigned and which segment offset belongs to.
For all other instructions I'm doing benchmarking with real CPU results including flags: https://github.com/xor2003/masm2c/blob/master … s/test-i386.txt

Reply 7 of 10, by llm

User metadata
Rank Member
Rank
Member
xor2003 wrote on 2021-11-10, 09:55:

For example I can make register to be object and trace where value was first assigned and which segment offset belongs to.

good idea - tracing memory accesses while reversing is very helpfull - and even what bit-width the access is

xor2003 wrote on 2021-11-10, 09:55:

For all other instructions I'm doing benchmarking with real CPU results including flags: https://github.com/xor2003/masm2c/blob/master … s/test-i386.txt

very good testing environment - seems to be very complete

Reply 8 of 10, by llm

User metadata
Rank Member
Rank
Member
llm wrote on 2021-11-10, 09:25:
[…]
Show full quote
cs=0x1b2;eip=0x000021; 	R(MOV(ah, 7));	// 153 mov     ah, 7 

could you add cs and ip to the R macro so it looks like this

R(0x1b2, 0x000021, MOV(ah,7));

would reduce the visual turbulence a little bit

is there a way to define that some blocks(functions) are not interruptable/inner jumped - so no need to add this cs/eip thing in front - leave it untrackable

Reply 9 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

Probably can leave it only for something like "call" and "int" or where cs/ip mentioned.
Probably right now you can delete it with regular expression.
I'm currenly trying to migrate to dosbox as execution platform.
Will make "MOV" to work with DOSBox paged memory.
"Snake" game example working. WIll try to run something with graphics, sound and make DOSBox use interrupts from my code.

Reply 10 of 10, by xor2003

User metadata
Rank Newbie
Rank
Newbie

INT 8 and other interrupts are called from Normal_loop().
But I just executing the masm2c instructions and using INT 21h.
I don't understand how and when should I call it...

Where can I ask about Dosbox internal behaviour?