нŒ}Œõ—Õ
Common Source Code Project

This is the common source code archive of my works: This archive is under GNU GENERAL PUBLIC LICENSE.

Download
Note: Windows CE port binaries are discontinued.
Plase build them by yourself if you need them.


The target platforms are Windows 9x/NT4.0/2000/XP and Windows CE.NET 4.x.
This archive includes the device classes listed below:

5/25/2009
[VM/UPD7220] fix initial vect params
[VM/Z80CTC] support different sysclock from cpu clock
5/20/2009
[VM/MSM5832] fix build error
5/17/2009
[VM/I386] support 80386
[VM/LS393] refine implements of output signal
[VM/MSM5832] support MSM5832
[VM/SN76489AN] support cs/we/data signal to be controlled without i/o bus
[VM/Z80CTC] refine implements of output signal
4/9/2009
[COMMON] modify definition of uint64 and int64
[VM/DEVICE] support 32bit i/o bus
[VM/IO] support 32bit i/o bus
4/5/2009
[VM/I8155] fix build error
[VM/UPD1990A] fix shift register
4/1/2009
[COMMON] define uint64 and int64
[EMU/WIN32] support 1024x768 and 1280x1024 full-screen mode

[VM/DEVICE] support 32bit memory bus
[VM/DISK] detect disk is changed
[VM/EVENT] remove hsync event
[VM/EVENT] initialize sound buffer before reset
[VM/EVENT] multi instance free
[VM/HD46505] support vblank signal
[VM/HD63484] support HD63484 (based on MAME HD63484 core)
[VM/HUC6260] support HuC6260 (based on Ootake cpu core)
[VM/I8155] add mask bit for output signal
[VM/I8253] add mask bit for output signal
[VM/I86] fix to refer 16bit i/o bus
[VM/UPD1990A] support TP signal
[VM/YM2151] support YM2151 (use fmgen core by Mr.CISC)
2/8/2009
[EMU/WIN32] support window minimize button
1/16/2009
[EMU/WIN32] change screen buffer type from uint16 to user-defined type
[EMU/WIN32] change screen buffer depth from RGB555 to RGB888 on windows pc

[VM/I8155] support i8155

*) change the compiler from vs2005 to vs2008
1/2/2009
[EMU/WIN32] support power off requested by vm

[VM/I8237] support external bank register
[VM/I8251] support txrdy/txempty/dsr/dtr signals
[VM/I8251] support loop back
[VM/I8251] don't reset dsr bit of status register
[VM/I8253] don't latch count before previously latched count is not read
[VM/I8254] support i8254 based on i8253
[VM/I86] fix push sp in 8086 mode
[VM/I86] fix a20 line in fetch functions
[VM/IO] change class name from IO8 to IO
[VM/IO] support 16bit i/o bus
12/26/2008
[EMU/WIN32] support kana-characters on auto key function

[VM/DISK] support ImageDisk floppy disk image
[VM/I8085] support 8080/8085 (based on MAME 8080/8085 core)
[VM/I86] change class name from X86 to I86
10/17/2008
[EMU/WIN32] fix key notification for caps/kana/kanji

[VM/X86] optimize the pseudo bios call by interrupt
10/6/2008
[EMU/WIN32] fix the problem when new file path is specified
[EMU/WIN32] support 96khz sound

[VM/DATAREC] support trigger signal
[VM/DATAREC] output remote signal
[VM/I8253] fix mode3 output signal
[VM/PCM1BIT] support LPF
[VM/UPD765A] fix AT bit in the result of seek command
[VM/X86] support pseudo bios call
8/27/2008
[EMU/WIN32] fix build problem for Windows CE

[VM/I8255] support mode1
[VM/I8259] clear irr bit if the request signal is changed to low level
[VM/UPD1990A] support i/o coonection interface
[VM/X86] fix interrup status
[VM/X86] fix pop es on 80286
8/19/2008
[VM/UPD765A] fix the problem that data lost occurs after the result phase
[VM/UPD765A] fix CB bit in the status register in sence intstat command
[VM/UPD765A] fix AT bit in the result of seek command
8/16/2008
[EMU/WIN32] support rotate screen
[EMU/WIN32] fix build problem for Windows CE

[VM/BEEP] more clear beep generation for the constant frequency
[VM/BEEP] fix mute logic
[VM/DEVICE] return address for unassigned I/O port
[VM/EVENT] fix crash problem in the initialization
[VM/I8251] fix PE bit in the status register
[VM/I8253] check edge of the input signal
[VM/I8253] fix gate signal
[VM/RTC58321] support i/o coonection interface
[VM/UPD4991A] modify i/o connection interface
[VM/UPD4991A] fix year data
[VM/UPD765A] support drq line delay
6/11/2008
[EMU/WIN32] open command line as cart or disk file path
[EMU/WIN32] convert file path to full and long file path

[VM/AND/OR/NAND/NOR] support and/or/nand/nor gates
[VM/DATAREC] output low signal when the tape is closed
[VM/MB8876] support motor on/off signal
[VM/PCM1BIT] support on/off signal
[VM/PCM1BIT] support high quality sound
[VM/RTC58321] support RTC58321
[VM/UPD4991A] support uPD4991A
[VM/UPD765A] fdc status patch for MZ-3500
[VM/X86] fix freeze problem that some opecodes did not decrease the clock
[VM/Z80] return busack signal whe busreq occurs
4/22/2008
[VM/LS244] support 74LS244/245
[VM/UPD1990AC] support uPD1990AC
[VM/X86] fix hlt
[VM/X86] support busreq
[VM/Z80] don't reset busreq in reset()
4/16/2008
[VM/UPD7220] support pitch command
[VM/UPD7220] fix vecte command in the case R=C=T=L=0 (pset)
[VM/UPD765A] fix read id command
4/12/2008
[VM/LS393] support 74LS393
[VM/RP5C01] support RP-5C01
[VM/UPD7220] fix pset function
[VM/UPD7220] notify vsync
[VM/UPD765A] check sector id strictly
4/8/2008
Windows CE port binaries are discontinued because of the user-support difficulties.
Plase build them by yourself if you need them.
4/7/2008
[EMU/WIN32] support the screen size changing requested by the virtual machine
4/3/2008
[VM/I8259] fix the cascade mode condition
[VM/UPD7220] fix low/high byte condition in dma commands
[VM/UPD7220] check the param count in fifo buffer in sync/vectw commands
[VM/UPD7220] get mod param in write command with no params
[VM/UPD7220] check mod param in vect/char drawing commands
[VM/UPD7220] check dir param in read/write command
[VM/UPD7220] support line drawing in vecte command
[VM/UPD7220] update ead/dad after drawing commands
[VM/UPD7220] fix lsb/msb order in pset function
3/22/2008
[VM/I8251] notify rxrdy is changed
[VM/TF20] fix the error result of read command
3/20/2008
[EMU/WIN32] set DirectX9 graphics params on the screen menu
3/2/2008
[EMU/WIN32] support DirectX9 graphics
[EMU/WIN32] fix the window size problem of eHC-40


Blit screen by regacy GDI and D3D9
2/29/2008
[EMU/WIN32] more quick stretch screen
[EMU/CONFIG] divide the config version to the file version and the virtual machine version
[VM/TF20] support EPSON TF-20 terminal floppy drives
2/27/2008
[EMU/WIN32] Windows CE.NET binaries for GAPI are no longer supported
[EMU/WIN32] Don't use StretchBlt
2/20/2008
[VM/HD146818P] support sqw and periodic interrupt
[VM/HD146818P] clear IRQF/PF/AF/UF in the reg $0c when it is read
[VM/I8237] fix the build error
[VM/I8237] reimplement based on uPD71071
[VM/UPD7220] fix the build error
[VM/UPD7220] modify hblank/vsync event
[VM/UPD765A] lost data event occurs soon if dma request is not accepted
[VM/Z80SIO] change uPD7201 fifo buffer size
2/11/2008
The interrupt logics are largely modified and are now very close to the real circuits.

In the older versions:
This is because let CPU not to monitor the int-line in every opecodes.
But it causes some problems for example:
In this release:
[VM/DEVICE] modify virtual functions for interrupts
[VM/I8259] support the new interrupt logic
[VM/I8259] fix the crash problem
[VM/UPD7201] support uPD7201 (combined to Z80SIO class)
[VM/X86] support the new interrupt logic
[VM/Z80] support the new interrupt logic
[VM/Z80CTC] support the new interrupt logic
[VM/Z80PIO] support the new interrupt logic
[VM/Z80SIO] support the new interrupt logic
[VM/Z80SIO] support the End of Interrupt command
[VM/Z80SIO] fix the status register #0 (interrupt pending bit)
[VM/Z80SIO] fix the status register #2 (vector)
[VM/Z80PIC] removed
1/5/2008
[VM/BEEP] fix the crash problem when the frequency is constant
[VM/BEEP] support the interface to change the frequency
12/31/2007
[VM/FIFO] support read_not_remove()
[VM/NSC800] fix NSC800
8/24/2007
[EMU/WIN32] check the status of both left and right ALT/CTRL/SHIFT keys
8/22/2007
[VM/RP5C15] fix the initial 12H/24H setting
8/19/2007
[VM/MB8877] fix the status for type4 command
[VM/UPD71071] support the base registers
[VM/X86] fix rep never to exit and re-fetch the opecode in the loop
[VM/X86] fix the modrm table
8/16/2007
[VM/DEVICE] add the virtual functions for dma access
[VM/I8237] fix the typo
[VM/I8259] support the special fully nest mode
[VM/I8259] support the rotation of priorities
[VM/I8259] support the intrrupt request from Z80 family devices
[VM/IO8] support 16bit i/o adrress
[VM/MB8877] support the dma access
[VM/MB8877] support the irq and drq signals
[VM/RP5C15] support reading the values of banks #13/#14/#15
[VM/UPD71071] support uPD71071
[VM/X86] support 8086/V30/80286
[VM/YM2203] support the irq signal
7/23/2007
[VM/DATAREC] modify the frame skip condition (skip when the signal is changed)
[VM/TMS9918A] reimplement based on MAME 0.116
[VM/UPD7801] support the memory access wait
7/16/2007
[VM/TMS9995] support TMS9995
2/11/2007
[COMMON] support auto key hitting from the clipboard
[COMMON] save and restore the window mode when the emulator is restarted
[VM/DEVICE] modify memory access wait
[VM/DEVICE] support i/o access wait
[VM/DISK] fix the crash problem when the invalid track number is set
[VM/HD46505] support HD46505
[VM/HD46505] fix the display/vsync/hsync signals timing
[VM/I8253] more precise signal timing in mode #2, #4 and #5
[VM/MB8877] support the access led status
[VM/PICM1BIT] support 1bit pcm
[VM/UPD765A] support the acces led status
[VM/YM2203] support the volume adjustment
[VM/Z80] modify memory access wait
[VM/Z80] support i/o access wait
[VM/Z80SIO] fix the recv and under-run interrupt flags
[VM/Z80SIO] fix the status affect vector
[VM/Z80SIO] cancel the interrupt request when read the recv buffer
[VM/Z80SIO] support the i/f to clear the recv buffer
2/1/2007
[COMMON] ignore some warnings on Visual Studio 2005
[WIN32/SCREEN] support video recording
[WIN32/SOUND] record wave as 16bit, stereo
[WIN32/SOUND] dont use multi threading to recieve MM_WOM_DONE event
[WIN32/WCE] build 4 binaries (use GAPI or GDI, DirectSound or waveOut)
[VM/BEEP] modify beep sound generator for more stable frequency
[VM/DATAREC] auto stop at the end of tape image
[VM/DEVICE] add virtual functions to get the memory wait and passed clocks in cpu class
[VM/EVENT] more precise event timing refering the passed clock in cpu class
[VM/I8253] drive counter when it reaches the terminal count or read the count registers
[VM/I8253] more precise output signal timing
[VM/NSC800] suppor NSC800
[VM/Z80] fix the clocks for opecodes DD-CB-** and FD-CB-**
[VM/Z80CTC] drive counter when it reaches the terminal count or read the count registers
[VM/Z80PIC] accept the interrupt request when it is running
12/31/2006
[WIN32] support DirectShow video capture devices (DX8 or later is required)
[WIN32] support Windows CE.Net 4.x devices (use GAPI and waveOut APIs)
[VM] each device can get the cpu time
[VM/BEEP] modify beep sound generator for more stable frequency
[VM/Z80] support BUSREQ
[VM/Z80PIC] call do_reti() in the device that requested the interrupt
[VM/Z80SIO] suppor Z80SIO
[VM/DISK] support TeleDisk floppy disk image
[VM/EVENT] fix the problem in the case that the new event is registered in the event callback routine
[VM/I8253] drive the counter more accurate and less power
12/7/2006
Initial release



Purpose

I had developed 11 emulaters in these years and implemented many devices.
There are many devices that are commonly used for exmaple i8255. I can divert their souce codes but I cannot use common one source code for each devices.
Becase the device class includes the codes for the unique circuit for each machine, for example i8255 class includes the codes for the keyboard.

I have started this common source code project to settle this problem.
I also aim to convine the win32 source codes for each works.

Description

For the purpose, I implement the devices under the rule listed below:

  1. Implement the device base class. This base class has the interface method connected to the memory bus, I/O bus, and other devices.
  2. Implement the every device classes as the superclass of the device base class.
  3. Register the destination device class connected to the output port as the pointer of device base class and also register the input port id.
  4. The device base class also has the event callback method. Every devices can register their own pointer to the event manager class.
You may feel that the purpose is similar to MAME/MESS project. The difference is that the pointer of interface function is registered in MAME/MESS, but the pointer of device class is registered in my project. And I dont aim to convine to one binary like MAME/MESS.

Example 1) dma

MEMORY* memory; // this is the unique hardware
UPD765A* fdc;
I8237* dma;

dma->set_context(0, memory);
dma->set_context(1, fdc);

The device base class has the common memory bus interface write_data8(addr, data) and read_data8(addr). I8237 has MEMORY and UPD765A pointer as the device base class pointer and he can read and write their data with these interface.

Exmaple 2) keyboard with i8255

I8255* pio;
KEYBOARD* key; // this is the unique hardware

pio->set_context_port_a(key, SIG_KEYBOARD_COLUMN);
key->set_context(pio, SIG_I8255_PORT_B);

In this case, we write the key matrix column to i8255 Port A and read the key stats from i8255 Port B.
The device base class has the common input interface write_signal(id, data, mask).
When we write the column to i8255 Port A, I8255 class write the data as key->write_signal(SIG_KEYBOARD_COLUMN, data, 0xff).
In KEYBOARD class's write_signal(), create the key status for the given column and return it to i8255 Port B like pio->write_signal(SIG_I8255_PORT_B, data, 0xff).

Example 3) i8253 timer

I8253* pit;

pit->set_context_ch0(pit, SIG_I8253_CLOCK_1);
pit->set_context_ch1(pit, SIG_I8253_CLOCK_2);

In this case, OUT#0 is connected to CLK#1, and OUT#1 is connected to CLK#2.

Example 4) TMS9918 vsync event

void TMS9918::initialize() {
vm->regist_vsync_event(this);
}
void TMS9981::vsync_event(int v, int clock) {
// event manager call this function in every vsync
}