Commit graph

53 commits

Author SHA1 Message Date
Aleksandar Andrejevic e5a9861dc9 [NTVDM]
Start implementing the BaseVDM interface.


svn path=/branches/ntvdm/; revision=62686
2014-04-08 00:28:49 +00:00
Hermès Bélusca-Maïto cab63e90c0 [NTVDM]
Definitively fix console resizing when exiting the VDM.

svn path=/branches/ntvdm/; revision=62379
2014-03-02 15:04:56 +00:00
Hermès Bélusca-Maïto e53f7b173c [NTVDM]
Use a helper function for stopping the VDM (in case we add other steps for that), instead of just setting the flag to TRUE.

svn path=/branches/ntvdm/; revision=62378
2014-03-02 14:37:51 +00:00
Hermès Bélusca-Maïto ab9978f190 [NTVDM]
- Finally get rid of console output handles in the BIOS.
- Move console text buffer copy from BIOS back into VGA memory (~= revert part of r61542), but do it ONLY when attaching the VGA emulation to the console.
- Fix cursor positioning in BIOS & VGA (work in progress).

- Initialize PS/2 after having setting basic console modes.
- Showing/hiding mouse cursor (see the option in the console menu) is done in while() loops to be sure the cursor is really shown/hidden (based on the return value of ShowConsoleCursor).

svn path=/branches/ntvdm/; revision=62373
2014-03-02 01:45:57 +00:00
Hermès Bélusca-Maïto 9e1ba5c534 [NTVDM]
Get rid of ConsoleInput handles in the BIOS; setting input console modes should be done in the emulator.c module itself (when setting user interface modes), and if a mouse is present, handle it in the ps2.c module.
Next step will be to get rid of ConsoleOutput handle in the BIOS.

svn path=/branches/ntvdm/; revision=62359
2014-02-28 21:21:41 +00:00
Hermès Bélusca-Maïto 5a3cc5df3c [NTVDM]
Start to implement EmulatorSimulate / EmulatorUnsimulate (used by VDDSimulate16 and VDDUnsimualte16). This piece of code can be better written, but it works for what I'm going to commit next.

svn path=/branches/ntvdm/; revision=62282
2014-02-21 19:27:27 +00:00
Hermès Bélusca-Maïto 574f922049 [NTVDM]
- Remove an unneeded assignment (cmos.c)
- Reorganize BIOS code: put our 32-bit bios in a dedicated directory; start to introduce a way to load other bioses (WIP).

svn path=/branches/ntvdm/; revision=62235
2014-02-17 22:20:03 +00:00
Hermès Bélusca-Maïto 105aff1c51 [NTVDM]
- Define and export VDDSimulate16 and host_simulate.
- Move the big emulation loop from ntvdm.c to clock.c, and the console input pump thread from ps2.c to ntvdm.c.
  Indeed:
  * Moving the emulation loop out of the main initialization function will be helpful if one wants to modify how emulation is done,
  * The console input pump thread deals also with console UI bits that have nothing to do with keyboard/mouse/ps-2. Instead, the pump thread will dispatch keyboard and mouse events to the ps/2 controller.
- Implement a custom menu in the console's system menu to be able to parametrize ROS VDM (work-in-progress); at the moment only a menu item to show/hide mouse pointer, and another one allowing us to quit properly the VDM are implemented. The menu code was taken from the GUI frontend in winsrv.dll. Only english and french translations available at the moment.

svn path=/branches/ntvdm/; revision=61902
2014-02-01 16:32:20 +00:00
Hermès Bélusca-Maïto d25d9ea618 [NTVDM]
- Enable experimental sound support (only PC speaker for the moment, aka. uses beep.sys).
- Introduce a #define WORKING_TIMER which aim is to disable the currently problematic approximate performance counter value calculation done in order not to call QueryPerformanceCounter each time.
  The problem is that we then compute a number of clock ticks for the PIT, which becomes negative, and therefore everything starts to hang.
  Disabling this code and calling each time QueryPerformanceCounter, fixes everything; we gain in precision but we loose in performance...
  A definitive fix must be found, [TheFlash] !!

This fixes sound (and hangs) in Advanced NetWars, Dangerous Dave, ElitePlus and Rescue Rover (the games that I've tested so far).

svn path=/branches/ntvdm/; revision=61875
2014-01-29 00:25:43 +00:00
Hermès Bélusca-Maïto f2a98176d6 [NTVDM]: Add debug print for timer ticks to try to find why the emulator sometimes hangs...
svn path=/branches/ntvdm/; revision=61867
2014-01-28 20:39:16 +00:00
Hermès Bélusca-Maïto 5dafb169e0 [NTVDM]: Replace my #if 0 by #ifdef IPS_DISPLAY for DPRINTing (or not) the no. of instructions per seconds.
svn path=/branches/ntvdm/; revision=61865
2014-01-28 20:18:52 +00:00
Hermès Bélusca-Maïto 0a46ec7a18 [NTVDM]
- Break the DOS source file into the "DOS BIOS" (also known in other places as ibmbio or io or...), which is in fact some kind of hardware abstraction layer, and the "DOS BDOS" kernel (also known in other places as ibmdos.com or msdos.sys or...).
- Add in DEM the possibility of loading the DOS from another files (WIP).

svn path=/branches/ntvdm/; revision=61846
2014-01-26 21:51:27 +00:00
Hermès Bélusca-Maïto c98977184f [NTVDM]
- Start to refactor the DOS sources:
  Introduce the DEM (DOS Emulation) support library that is used by our built-in DOS, and that is used (via BOPs) by windows NT DOS (files: ntio.sys and ntdos.sys).
- Export some of DEM functions; stub most of them and implement the remaining ones (with existing code that we had in dos.c before).

svn path=/branches/ntvdm/; revision=61838
2014-01-26 18:25:59 +00:00
Hermès Bélusca-Maïto 298e47dbaf [NTVDM]
- Shut up some DPRINTs in io.c and ntvdm.c
- I forgot to update the call to PitClock in the previous revision...

svn path=/branches/ntvdm/; revision=61816
2014-01-25 18:57:17 +00:00
Hermès Bélusca-Maïto 6ddfa7d2b8 [NTVDM]
- Move all the hardware initialization to EmulatorInitialize (since emulator.c can be viewed as support functions for emulating a PC motherboard) --> PS2 and VGA go there.
- Break bios.c into bios.c and kbdbios.c (the keyboard bios module) (according to the IBM documentation as well as other emulator sources or SeaBIOS or...).
- Move Exception handling from int32.c to emulator.c, because it's something tight to the emulator, not to the interrupt system by itself (yet it happens that INT 00h to 07h are commonly set to some exception handlers). In the bios.c, initialize those vectors with the default exception handler.
- Handling IRQs is done fully in bios.c now: introduce PicSetIRQMask and EnableHwIRQ helper functions (adapted from their equivalents from SeaBIOS) that allows the bios to set (and activate in the PIC) a given IRQ with its corresponding handler. Also introduce PicIRQComplete that serves as a PIC IRQ completer (i.e. sends the EOI to the right PIC(s)).
- Continuing on that, at the moment I set dumb default PIC IRQ handlers for IRQ 08h - 0Fh and IRQ 70h - 77h).
- By default I disable all the IRQs; there are then set on-demand with EnableHwIRQ.
- Rework the POST (aka. BiosInitialize function):
  * the memory size is now get from the CMOS (as well as the extended memory size via INT 12h, AH=88h),
  * then we initialize the interrupts,
  * then platform hardware (ie. the chips) are initialized,
  * and finally the keyboard and video bioses.
- As said before, move memory sizes into the CMOS.
- Simplify video bios initialization.

svn path=/branches/ntvdm/; revision=61796
2014-01-25 00:21:51 +00:00
Hermès Bélusca-Maïto 40f773b96b [DDK:NT_VDD]
Declare some VDM memory services.

[NTVDM]
- Almost all of the XXXInitialize functions just return TRUE always, so VOIDify them instead (since they always succeed).
- Move almost all of the hardware initialization inside EmulatorInitialize.
- Move pure console initialization/mode-saving/cleanup code into ConsoleInit/Cleanup functions in ntvdm.c instead of in bios.c.

svn path=/branches/ntvdm/; revision=61588
2014-01-11 20:59:27 +00:00
Hermès Bélusca-Maïto 3d36bf4451 [NTVDM]: Start to organize the code...
svn path=/branches/ntvdm/; revision=61583
2014-01-11 15:27:18 +00:00
Aleksandar Andrejevic 1b784a5b7b [NTVDM]
Improve the keyboard event handling.
Clean up the PS/2 code a bit.


svn path=/branches/ntvdm/; revision=61229
2013-12-06 04:35:58 +00:00
Aleksandar Andrejevic 73186a64bd [NTVDM]
Fix the VGA refresh rate.
Serialize access to the PS/2 keyboard queue.


svn path=/branches/ntvdm/; revision=61214
2013-12-04 00:38:52 +00:00
Hermès Bélusca-Maïto 4fb7f6e1d7 [NTVDM]
- Move some PS/2 initialization from bios.c to ps2.c
- NULLify interrupt entries which are in fact pointers to data tables.
- Add a framework for adding I/O port handlers.

svn path=/branches/ntvdm/; revision=61107
2013-11-26 20:20:51 +00:00
Hermès Bélusca-Maïto fb031ba118 [NTVDM]
Initialize LastClockUpdate, LastVerticalRefresh and LastCyclePrintout with the value of StartTickCount.

svn path=/branches/ntvdm/; revision=61021
2013-11-17 20:44:23 +00:00
Hermès Bélusca-Maïto bf2731fb9f [NTVDM]
- BIOS: Reorganize a bit the header, and close the input thread before closing the input handle (and not after).
- INT32: Fix a comment.
- CMOS: Put CMOS data into a structure called CMOS_MEMORY, introduce READ/WRITE_CMOS_DATA macros for simplifying code. Save CMOS memory into a file (à la Windows' NTVDM), which is loaded at startup.

svn path=/branches/ntvdm/; revision=60913
2013-11-10 13:12:02 +00:00
Hermès Bélusca-Maïto 592a3383e5 [NTVDM]: Improve DisplayMessage by also displaying the message in the debug log.
svn path=/branches/ntvdm/; revision=60898
2013-11-09 15:53:52 +00:00
Hermès Bélusca-Maïto b41ec9f332 [NTVDM]
- Add a missing "goto Cleanup;"
- Add DPRINT1s at the beginning and the end of ntvdm, so that one can easily localize in debug logs where one started it. Suggested by Vampyre ;)

svn path=/branches/ntvdm/; revision=60860
2013-11-04 00:22:29 +00:00
Aleksandar Andrejevic 3fbe4cb107 [NTVDM]
Use BiosConsoleInput instead of calling GetStdHandle in the keyboard input thread.


svn path=/branches/ntvdm/; revision=60855
2013-11-03 21:52:58 +00:00
Aleksandar Andrejevic 36afa0ea12 [NTVDM]
Implement the CMOS and Real Time Clock (RTC).
Improve the performance of the PIT and RTC (correctly this time).


svn path=/branches/ntvdm/; revision=60854
2013-11-03 21:33:22 +00:00
Hermès Bélusca-Maïto e9f8b230a6 [NTVDM]
Start to implement a basic emulated PC speaker, using the Beep driver.

svn path=/branches/ntvdm/; revision=60853
2013-11-03 20:31:19 +00:00
Aleksandar Andrejevic 90d7fbd4a8 [NTVDM]
Revert a previous incorrect fix for the PIT.
Modify the PitDecrementCount function to take a parameter instead
of it being called multiple times (which is slower).


svn path=/branches/ntvdm/; revision=60816
2013-11-01 01:57:40 +00:00
Hermès Bélusca-Maïto 39a527a21e [FAST486][NTVDM]
BOP numbers are 1 byte and map to a function (over 255). But one can pass additional "parameters" to those functions by adding extra bytes, however such functions must advance "by hand" the instruction pointer.

[NTVDM]
- Take into account our previous remark for the BIOS interrupt stubs, and comment them.
- Rework EmulatorBiosOperation (move almost all of its existing code into subfunctions in bop.c) so that one can call many other BOP functions in the future (WIP). The BOP number (still called) EMULATOR_INT_BOP (of value 0xFF) is used for internal 16 --> 32 bit switching for our 32bit bios.
- It appears that the IoRead/WriteCallback and IdleCallback must not be NULL for using fast486. I'm committing a temporary fix that I will definitely fix in a subsequent commit.

svn path=/branches/ntvdm/; revision=60812
2013-11-01 00:01:07 +00:00
Aleksandar Andrejevic 97acc35c7c [NTVDM]
Improve performance by computing the resolution required by the PIT,
and then using the standard tick count instead of performance counters
when that resolution is low.


svn path=/branches/ntvdm/; revision=60783
2013-10-28 02:25:54 +00:00
Aleksandar Andrejevic f5d3c9254c [FAST486]
Separate external interrupts from interrupt signals (which are
interrupts whose number is not known until they can be serviced,
just like hardware interrupts on a real CPU).
[NTVDM]
Improve the PIC emulation code (IRQ priorities, etc...).
Instead of checking for interrupts in the main loop, move the
PS/2 input parsing to a different thread.
Improve BIOS keyboard IRQ handling.


svn path=/branches/ntvdm/; revision=60761
2013-10-27 00:37:01 +00:00
Aleksandar Andrejevic b60ee76f22 [NTVDM]
Use DOS_CMDLINE_LENGTH instead of MAX_PATH.
Fix bug in DosInitializePsp which allowed writing past the end of the Program Segment Prefix (PSP).


svn path=/branches/ntvdm/; revision=59693
2013-08-10 21:41:20 +00:00
Hermès Bélusca-Maïto 2288b2c576 [NTVDM]
- Use up to 256 parameters for programs (as suggested by the parsing while loop), but don't hardcode this values in many other places.
- The passed command line to ntvdm should be as long as MAX_PATH.

svn path=/branches/ntvdm/; revision=59691
2013-08-10 20:50:37 +00:00
Aleksandar Andrejevic b62ad02740 [NTVDM]
- Enable TESTING by default until the correct way to load ntvdm is found.
- Calculate the character height instead of hardcoding in the BDA.


svn path=/branches/ntvdm/; revision=59678
2013-08-09 13:14:56 +00:00
Aleksandar Andrejevic b4ed87bb3a [NTVDM]
Fix coding style.
Fix initial cursor position bug.
Fix memory limit constant for VGA memory modes 0 and 1 (64 KB not 32 KB).


svn path=/branches/ntvdm/; revision=59669
2013-08-07 19:56:28 +00:00
Hermès Bélusca-Maïto 5bc19fdbfb [NTVDM]
- Don't leak console input/output handles when opening them in BiosInitialize.
- Deinitialize the emulator in the reverse order it was initialized.
- Simplify VgaGetVideoBaseAddress and VgaGetVideoLimitAddress and use the former one in VgaTranslate[Read-Write]Address.
- Use only unicode Win32 APIs where it's needed.

svn path=/branches/ntvdm/; revision=59659
2013-08-06 20:01:05 +00:00
Aleksandar Andrejevic 455deb3bde [NTVDM]
Implement Video Graphics Array (VGA) support.
Replace the old BIOS video code with new code that uses the VGA.


svn path=/branches/ntvdm/; revision=59648
2013-08-05 23:20:25 +00:00
Aleksandar Andrejevic c04b008f1f [NTVDM]
Add debug output.


svn path=/branches/ntvdm/; revision=59555
2013-07-22 13:51:26 +00:00
Hermès Bélusca-Maïto c5dad7aefe [NTVDM]
Fix the TESTING case, in case you run ntvdm without other parameters.

svn path=/branches/ntvdm/; revision=59498
2013-07-18 00:17:04 +00:00
Aleksandar Andrejevic bebaf9e812 [NTVDM]
Add a compile-time option (not default) to run ntvdm manually with the target executable as a parameter.
Fix screen clearing bug.
Rewrite several INT 10h functions to work for all video pages.


svn path=/branches/ntvdm/; revision=59497
2013-07-18 00:01:18 +00:00
Aleksandar Andrejevic 1f4d89e7d7 [NTVDM]
Improve vertical refresh performance.
Properly synchronize access to the framebuffer.


svn path=/branches/ntvdm/; revision=59425
2013-07-05 01:31:50 +00:00
Aleksandar Andrejevic 01fd2f9aa3 [NTVDM]
Implement BIOS video mode setting.
Fix bugs in video memory access emulation.


svn path=/branches/ntvdm/; revision=59424
2013-07-05 00:08:18 +00:00
Aleksandar Andrejevic c4ef9b6f44 [NTVDM]
Add more debug output.
[SOFTX86]
Properly set the carry and overflow flags.


svn path=/branches/ntvdm/; revision=59410
2013-07-02 21:40:11 +00:00
Aleksandar Andrejevic 4c4c69fc37 [NTVDM]
Clean up the code and properly separate different modules into different files.


svn path=/branches/ntvdm/; revision=59344
2013-06-26 22:58:41 +00:00
Aleksandar Andrejevic ca06374c9f [NTOSKRNL]
Check for old-style MZ executable in PeFmtCreateSection.
[NTVDM]
Fix bugs.
Implement MZ executable loading.


svn path=/branches/ntvdm/; revision=59328
2013-06-24 01:59:09 +00:00
Aleksandar Andrejevic 4c459af487 [KERNEL32]
Implement BasepCheckDosApp.
Enable NTVDM in CreateProcessInternalW.
[NTVDM]
Remove the old command line parser code. The entire command line is for the DOS application now.


svn path=/branches/ntvdm/; revision=59310
2013-06-23 12:33:13 +00:00
Aleksandar Andrejevic e7ce79fc05 [NTVDM]
Perform multiple CPU instructions in one emulator cycle.


svn path=/branches/ntvdm/; revision=59298
2013-06-23 00:20:24 +00:00
Hermès Bélusca-Maïto 2bd695b42e [NTVDM]
Use correctly NDEBUG, and use ReactOS macro: ASSERT, instead of the assert() CRT function.

svn path=/branches/ntvdm/; revision=59280
2013-06-22 01:48:28 +00:00
Aleksandar Andrejevic 6a3d90cf53 [NTVDM]
Improve keyboard IRQ performance.
Add debug output to measure number of instructions per second.


svn path=/branches/ntvdm/; revision=59279
2013-06-22 01:41:51 +00:00
Aleksandar Andrejevic fe6988cbdd [NTVDM]
Implement the keyboard IRQ.


svn path=/branches/ntvdm/; revision=59276
2013-06-21 21:25:01 +00:00