• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisão6b3e6fc721c95cc9e7f8eb941f9139f711a2205e (tree)
Hora2017-05-24 23:03:34
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Mensagem de Log

[VM][COMMON_VM] Move I8237, I8253, I8255, I8259, UPD7220 and Z80SIO to common dll.

Mudança Sumário

Diff

--- a/source/build-cmake/cmake/config_emufmr50.cmake
+++ b/source/build-cmake/cmake/config_emufmr50.cmake
@@ -13,10 +13,8 @@ set(WITH_MOUSE ON)
1313
1414 set(VMFILES
1515 #
16- i8253.cpp
17- i8259.cpp
18- msm58321.cpp
1916 # mb8877.cpp
17+ msm58321.cpp
2018 scsi_dev.cpp
2119 scsi_host.cpp
2220 scsi_hdd.cpp
@@ -34,8 +32,12 @@ set(VMFILES_LIB
3432 upd71071.cpp
3533
3634 i8251.cpp
35+ i8253.cpp
36+ i8259.cpp
37+ msm58321_base.cpp
38+
3739 hd63484.cpp
38- i386.cpp
40+# i386.cpp
3941 disk.cpp
4042 )
4143
@@ -97,7 +99,7 @@ elseif(BUILD_FMR60)
9799 add_definitions(-DHAS_I286)
98100 set(FLAG_USE_I386_VARIANTS OFF)
99101 set(FLAG_USE_I286 ON)
100- set(VMFILES ${VMFILES} hd63484.cpp)
102+ set(VMFILES_LIB ${VMFILES_LIB} hd63484.cpp)
101103 set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/fmr60.qrc)
102104 elseif(BUILD_FMR70)
103105 set(EXEC_TARGET emufmr70)
--- a/source/build-cmake/cmake/config_emupc9801.cmake
+++ b/source/build-cmake/cmake/config_emupc9801.cmake
@@ -6,10 +6,6 @@ set(WITH_MOUSE ON)
66
77 set(VMFILES
88 i8237.cpp
9- i8253.cpp
10- i8255.cpp
11- i8259.cpp
12-
139 upd1990a.cpp
1410 upd7220.cpp
1511
@@ -18,13 +14,18 @@ set(VMFILES
1814 memory.cpp
1915 )
2016 set(VMFILES_LIB
17+ i8237_base.cpp
18+ i8251.cpp
19+ i8253.cpp
20+ i8255.cpp
21+ i8259.cpp
22+ ls244.cpp
2123 pc80s31k.cpp
24+ upd7220_base.cpp
2225 upd765a.cpp
23- disk.cpp
2426 ym2203.cpp
25- i8251.cpp
26- ls244.cpp
2727 prnfile.cpp
28+ disk.cpp
2829 )
2930
3031 set(BUILD_SHARED_LIBS OFF)
--- a/source/build-cmake/cmake/config_mz2500.cmake
+++ b/source/build-cmake/cmake/config_mz2500.cmake
@@ -12,22 +12,18 @@ set(WITH_JOYSTICK ON)
1212 set(WITH_MOUSE ON)
1313 set(FLAG_USE_Z80 ON)
1414 set(VMFILES_2500
15- z80sio.cpp
16-
1715 w3100a.cpp
1816 rp5c01.cpp
1917
2018 )
2119 set(VMFILES_LIB_2500
20+ z80sio.cpp
2221 ls393.cpp
2322 ym2203.cpp
2423 )
2524
2625 set(VMFILES_BASE
2726 datarec.cpp
28- i8253.cpp
29- i8255.cpp
30-
3127 mz1p17.cpp
3228
3329 event.cpp
@@ -36,6 +32,9 @@ set(VMFILES_BASE
3632
3733 )
3834 set(VMFILES_LIB
35+ i8253.cpp
36+ i8255.cpp
37+
3938 pcm1bit.cpp
4039 z80pio.cpp
4140 mb8877.cpp
@@ -43,15 +42,18 @@ set(VMFILES_LIB
4342 prnfile.cpp
4443 )
4544 set(VMFILES_QD
46- z80sio.cpp
4745 mz700/quickdisk.cpp
48- )
46+)
47+set(VMFILES_LIB_QD
48+ z80sio.cpp
49+)
4950
5051 set(VMFILES_16BIT
5152 i286.cpp
52- i8259.cpp
5353 )
54-
54+set(VMFILES_LIB_16BIT
55+ i8259.cpp
56+)
5557
5658 set(BUILD_MZ2500 OFF CACHE BOOL "Build EMU-MZ2500")
5759 set(BUILD_MZ2200 OFF CACHE BOOL "Build EMU-MZ2200")
@@ -82,6 +84,7 @@ set(USE_FMGEN ON)
8284
8385 elseif(BUILD_MZ2000)
8486 set(VMFILES ${VMFILES_BASE} ${VMFILES_QD} ${VMFILES_16BIT})
87+set(VMFILES_LIB ${VMFILES_LIB_BASE} ${VMFILES_LIB_QD} ${VMFILES_LIB_16BIT})
8588 add_definitions(-D_MZ2000)
8689 set(EXEC_TARGET emumz2000)
8790 set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/mz2000.qrc)
@@ -89,6 +92,7 @@ set(USE_FMGEN OFF)
8992
9093 elseif(BUILD_MZ2200)
9194 set(VMFILES ${VMFILES_BASE} ${VMFILES_QD} ${VMFILES_16BIT})
95+set(VMFILES_LIB ${VMFILES_LIB_BASE} ${VMFILES_LIB_QD} ${VMFILES_LIB_16BIT})
9296 set(LOCAL_LIBS ${LOCAL_LIBS})
9397 add_definitions(-D_MZ2200)
9498 set(EXEC_TARGET emumz2200)
--- a/source/build-cmake/cmake/config_mz5500.cmake
+++ b/source/build-cmake/cmake/config_mz5500.cmake
@@ -10,13 +10,10 @@ set(VMFILES
1010 # i286.cpp
1111
1212 i8237.cpp
13- i8255.cpp
14- i8259.cpp
1513 rp5c01.cpp
1614
1715 upd7220.cpp
1816 z80ctc.cpp
19- z80sio.cpp
2017 mz1p17.cpp
2118
2219 event.cpp
@@ -24,12 +21,19 @@ set(VMFILES
2421 )
2522
2623 set(VMFILES_LIB
27- prnfile.cpp
24+ i8237_base.cpp
25+ upd7220_base.cpp
26+ i8255.cpp
27+ i8259.cpp
2828 ls393.cpp
2929 not.cpp
30+
31+ prnfile.cpp
3032 upd765a.cpp
31- disk.cpp
3233 ym2203.cpp
34+ z80sio.cpp
35+
36+ disk.cpp
3337 )
3438 set(BUILD_SHARED_LIBS OFF)
3539 set(USE_OPENMP ON CACHE BOOL "Build using OpenMP")
--- a/source/build-cmake/cmake/config_mz700.cmake
+++ b/source/build-cmake/cmake/config_mz700.cmake
@@ -11,9 +11,6 @@ set(WITH_MOUSE ON)
1111
1212 set(FLAG_USE_Z80 ON)
1313 set(VMFILES_BASE
14- i8255.cpp
15- i8253.cpp
16-
1714 datarec.cpp
1815
1916 event.cpp
@@ -22,7 +19,6 @@ set(VMFILES_BASE
2219 )
2320
2421 set(VMFILES_MZ800 ${VMFILES_BASE}
25- z80sio.cpp
2622 )
2723
2824
@@ -32,11 +28,15 @@ set(VMFILES_MZ1500 ${VMFILES_MZ800}
3228 )
3329
3430 set(VMFILES_LIB
31+ i8255.cpp
32+ i8253.cpp
33+
3534 beep.cpp
3635 pcm1bit.cpp
3736 and.cpp
3837 )
3938 set(VMFILES_LIB_MZ800
39+ z80sio.cpp
4040 mb8877.cpp
4141 disk.cpp
4242 not.cpp
--- a/source/build-cmake/cmake/config_pc8801.cmake
+++ b/source/build-cmake/cmake/config_pc8801.cmake
@@ -15,9 +15,6 @@ set(VMFILES
1515
1616
1717 z80ctc.cpp
18- z80sio.cpp
19- i8255.cpp
20-
2118 datarec.cpp
2219 event.cpp
2320 io.cpp
@@ -25,6 +22,8 @@ set(VMFILES
2522 )
2623 set(VMFILES_LIB
2724 z80dma.cpp
25+ z80sio.cpp
26+
2827 pc80s31k.cpp
2928 upd765a.cpp
3029 beep.cpp
@@ -34,6 +33,7 @@ set(VMFILES_LIB
3433 prnfile.cpp
3534 ym2203.cpp
3635 i8251.cpp
36+ i8255.cpp
3737 )
3838 set(FLAG_USE_Z80 ON)
3939
--- a/source/build-cmake/cmake/config_pc98ha.cmake
+++ b/source/build-cmake/cmake/config_pc98ha.cmake
@@ -5,20 +5,20 @@ set(WITH_JOYSTICK ON)
55 set(WITH_MOUSE ON)
66
77 set(VMFILES
8- i8253.cpp
9- i8259.cpp
10- i8255.cpp
11-
128 event.cpp
139 io.cpp
1410 memory.cpp
1511 )
1612 set(VMFILES_LIB
17- upd71071.cpp
1813 beep.cpp
14+ i8251.cpp
15+ i8253.cpp
16+ i8255.cpp
17+ i8259.cpp
1918 ls244.cpp
2019 not.cpp
21- i8251.cpp
20+
21+ upd71071.cpp
2222 upd765a.cpp
2323 disk.cpp
2424 prnfile.cpp
--- a/source/build-cmake/cmake/config_qc10.cmake
+++ b/source/build-cmake/cmake/config_qc10.cmake
@@ -5,24 +5,25 @@ set(WITH_MOUSE OFF)
55
66 set(FLAG_USE_Z80 ON)
77 set(VMFILES
8- #
9- z80sio.cpp
10-
118 i8237.cpp
12- i8253.cpp
13- i8255.cpp
14- i8259.cpp
159 upd7220.cpp
16- upd765a.cpp
1710
1811 io.cpp
1912
20- disk.cpp
2113 event.cpp
2214 )
2315 set(VMFILES_LIB
24- hd146818p.cpp
25- pcm1bit.cpp
16+ i8237_base.cpp
17+ i8253.cpp
18+ i8255.cpp
19+ i8259.cpp
20+ upd7220_base.cpp
21+ hd146818p.cpp
22+ pcm1bit.cpp
23+ upd765a.cpp
24+ z80sio.cpp
25+
26+ disk.cpp
2627 )
2728
2829 set(BUILD_SHARED_LIBS OFF)
--- a/source/build-cmake/cmake/config_tk80.cmake
+++ b/source/build-cmake/cmake/config_tk80.cmake
@@ -18,11 +18,11 @@ set(WITH_MOUSE ON)
1818
1919 set(VMFILES_BASE
2020 i8080.cpp
21- i8255.cpp
2221 memory.cpp
2322 event.cpp
2423 )
2524 set(VMFILES_LIB
25+ i8255.cpp
2626 pcm1bit.cpp
2727 )
2828
--- a/source/build-cmake/cmake/config_x1.cmake
+++ b/source/build-cmake/cmake/config_x1.cmake
@@ -13,14 +13,9 @@ set(USE_FMGEN ON)
1313 set(WITH_JOYSTICK ON)
1414 set(WITH_MOUSE ON)
1515 set(VMFILES
16-
17-# hd46505.cpp
18- i8255.cpp
1916 upd1990a.cpp
2017 z80ctc.cpp
2118
22- z80sio.cpp
23-
2419 datarec.cpp
2520 event.cpp
2621
@@ -28,10 +23,13 @@ set(VMFILES
2823 mz1p17.cpp
2924 )
3025 set(VMFILES_LIB
26+ z80sio.cpp
27+ z80pio.cpp
28+
29+ i8255.cpp
3130 hd46505.cpp
3231 mcs48.cpp
3332 beep.cpp
34- z80pio.cpp
3533 ym2151.cpp
3634 ym2203.cpp
3735 ay_3_891x.cpp
--- a/source/build-cmake/fm16pi/CMakeLists.txt
+++ b/source/build-cmake/fm16pi/CMakeLists.txt
@@ -22,14 +22,7 @@ set(WITH_MOUSE ON)
2222
2323 set(VMFILES
2424 # i286.cpp
25-#
26- i8253.cpp
27- i8255.cpp
28- i8259.cpp
2925 msm58321.cpp
30-
31- ym2203.cpp
32-
3326 # datarec.cpp
3427 event.cpp
3528 io.cpp
@@ -37,6 +30,11 @@ set(VMFILES
3730 )
3831
3932 set(VMFILES_LIB
33+ i8253.cpp
34+ i8255.cpp
35+ i8259.cpp
36+ ym2203.cpp
37+ msm58321_base.cpp
4038 pcm1bit.cpp
4139 i8251.cpp
4240 not.cpp
--- a/source/build-cmake/fmr30_i286/CMakeLists.txt
+++ b/source/build-cmake/fmr30_i286/CMakeLists.txt
@@ -16,10 +16,8 @@ project (emufmr30)
1616 set(VM_NAME fmr30)
1717 set(USE_FMGEN OFF)
1818 set(VMFILES
19-# i286.cpp
19+# i286.cpp
2020 i8237.cpp
21- i8253.cpp
22- i8259.cpp
2321 fmr50/bios.cpp
2422
2523 scsi_dev.cpp
@@ -33,6 +31,9 @@ set(VMFILES
3331 set(VMFILES_LIB
3432 pcm1bit.cpp
3533 i8251.cpp
34+ i8253.cpp
35+ i8259.cpp
36+ i8237_base.cpp
3637 sn76489an.cpp
3738 mb8877.cpp
3839 disk.cpp
--- a/source/build-cmake/fmr30_i86/CMakeLists.txt
+++ b/source/build-cmake/fmr30_i86/CMakeLists.txt
@@ -18,8 +18,6 @@ set(USE_FMGEN OFF)
1818 set(VMFILES
1919 # i286.cpp
2020 i8237.cpp
21- i8253.cpp
22- i8259.cpp
2321 fmr50/bios.cpp
2422
2523 scsi_dev.cpp
@@ -33,6 +31,9 @@ set(VMFILES
3331 set(VMFILES_LIB
3432 pcm1bit.cpp
3533 i8251.cpp
34+ i8253.cpp
35+ i8259.cpp
36+ i8237_base.cpp
3637 sn76489an.cpp
3738 mb8877.cpp
3839 disk.cpp
--- a/source/build-cmake/hc20/CMakeLists.txt
+++ b/source/build-cmake/hc20/CMakeLists.txt
@@ -20,25 +20,23 @@ set(VM_NAME hc20)
2020 set(USE_FMGEN OFF)
2121 set(WITH_JOYSTICK OFF)
2222 set(WITH_MOUSE OFF)
23+set(FLAG_USE_Z80 ON)
2324
2425 set(VMFILES_BASE
2526 mc6800.cpp
26-# tf20.cpp
27-
28- z80.cpp
29- z80sio.cpp
30- i8255.cpp
31-
3227 datarec.cpp
3328 event.cpp
3429 io.cpp
3530 memory.cpp
3631 )
3732 set(VMFILES_LIB
38- upd765a.cpp
39- hd146818p.cpp
4033 beep.cpp
34+ i8255.cpp
35+ hd146818p.cpp
36+
4137 tf20.cpp
38+ upd765a.cpp
39+ z80sio.cpp
4240 disk.cpp
4341 )
4442
--- a/source/build-cmake/hc40/CMakeLists.txt
+++ b/source/build-cmake/hc40/CMakeLists.txt
@@ -23,14 +23,14 @@ set(WITH_MOUSE OFF)
2323
2424 set(FLAG_USE_Z80 ON)
2525 set(VMFILES_BASE
26- ptf20.cpp
27- disk.cpp
28-
2926 datarec.cpp
3027 event.cpp
3128 )
3229 set(VMFILES_LIB
3330 beep.cpp
31+ ptf20.cpp
32+ disk.cpp
33+
3434 )
3535 set(USE_OPENMP ON CACHE BOOL "Build using OpenMP")
3636 set(USE_OPENGL ON CACHE BOOL "Build using OpenGL")
--- a/source/build-cmake/hc80/CMakeLists.txt
+++ b/source/build-cmake/hc80/CMakeLists.txt
@@ -23,14 +23,13 @@ set(WITH_MOUSE OFF)
2323
2424 set(FLAG_USE_Z80 ON)
2525 set(VMFILES_BASE
26- ptf20.cpp
27- disk.cpp
28- i8251.cpp
29-
3026 event.cpp
3127 )
3228 set(VMFILES_LIB
3329 beep.cpp
30+ i8251.cpp
31+ ptf20.cpp
32+ disk.cpp
3433 )
3534
3635 set(USE_OPENMP ON CACHE BOOL "Build using OpenMP")
--- a/source/build-cmake/j3100gt/CMakeLists.txt
+++ b/source/build-cmake/j3100gt/CMakeLists.txt
@@ -21,12 +21,13 @@ set(WITH_MOUSE ON)
2121
2222 set(VMFILES
2323 i8237.cpp
24- i8253.cpp
25- i8259.cpp
2624 io.cpp
2725 event.cpp
2826 )
2927 set(VMFILES_LIB
28+ i8237_base.cpp
29+ i8253.cpp
30+ i8259.cpp
3031 hd46505.cpp
3132 pcm1bit.cpp
3233 upd765a.cpp
--- a/source/build-cmake/j3100sl/CMakeLists.txt
+++ b/source/build-cmake/j3100sl/CMakeLists.txt
@@ -21,14 +21,14 @@ set(WITH_MOUSE ON)
2121
2222 set(VMFILES
2323 i8237.cpp
24- i8253.cpp
25- i8259.cpp
26-
2724 io.cpp
2825 event.cpp
2926 )
3027
3128 set(VMFILES_LIB
29+ i8237_base.cpp
30+ i8253.cpp
31+ i8259.cpp
3232 hd46505.cpp
3333 pcm1bit.cpp
3434 upd765a.cpp
--- a/source/build-cmake/jx/CMakeLists.txt
+++ b/source/build-cmake/jx/CMakeLists.txt
@@ -24,15 +24,16 @@ set(WITH_MOUSE ON)
2424 set(VMFILES_BASE
2525 # i86.cpp
2626
27- i8253.cpp
28- i8255.cpp
29- i8259.cpp
3027 io.cpp
3128 memory.cpp
3229 event.cpp
3330 )
3431 set(VMFILES_LIB
3532 i8251.cpp
33+ i8253.cpp
34+ i8255.cpp
35+ i8259.cpp
36+
3637 hd46505.cpp
3738 pcm1bit.cpp
3839 not.cpp
--- a/source/build-cmake/multi8/CMakeLists.txt
+++ b/source/build-cmake/multi8/CMakeLists.txt
@@ -17,23 +17,21 @@ set(USE_FMGEN ON)
1717 set(EXEC_TARGET emumulti8)
1818 set(FLAG_USE_Z80 ON)
1919 set(VMFILES_BASE
20-
21- hd46505.cpp
22- i8253.cpp
23- i8255.cpp
24- i8259.cpp
25-
2620 io.cpp
2721 datarec.cpp
2822
2923 event.cpp
3024 )
3125 set(VMFILES_LIB
32- ym2203.cpp
33- i8251.cpp
34- beep.cpp
35- upd765a.cpp
36- disk.cpp
26+ hd46505.cpp
27+ i8251.cpp
28+ i8253.cpp
29+ i8255.cpp
30+ i8259.cpp
31+ beep.cpp
32+ upd765a.cpp
33+ ym2203.cpp
34+ disk.cpp
3735 )
3836 set(USE_OPENMP ON CACHE BOOL "Build using OpenMP")
3937 set(USE_OPENGL ON CACHE BOOL "Build using OpenGL")
--- a/source/build-cmake/mz2800/CMakeLists.txt
+++ b/source/build-cmake/mz2800/CMakeLists.txt
@@ -19,27 +19,27 @@ set(WITH_JOYSTICK ON)
1919 set(WITH_MOUSE ON)
2020
2121 set(VMFILES
22- i8253.cpp
23- i8255.cpp
24- i8259.cpp
2522 rp5c01.cpp
2623
27- z80sio.cpp
2824 mz1p17.cpp
2925
3026 event.cpp
3127 io.cpp
3228 )
3329 set(VMFILES_LIB
34- z80pio.cpp
35- prnfile.cpp
36-# i286.cpp
37- upd71071.cpp
38- mb8877.cpp
39- not.cpp
40- pcm1bit.cpp
41- ym2203.cpp
42- disk.cpp
30+ i8253.cpp
31+ i8255.cpp
32+ i8259.cpp
33+ z80sio.cpp
34+ z80pio.cpp
35+ prnfile.cpp
36+ # i286.cpp
37+ upd71071.cpp
38+ mb8877.cpp
39+ not.cpp
40+ pcm1bit.cpp
41+ ym2203.cpp
42+ disk.cpp
4343 )
4444 set(FLAG_USE_I286 ON)
4545
--- a/source/build-cmake/mz3500/CMakeLists.txt
+++ b/source/build-cmake/mz3500/CMakeLists.txt
@@ -21,9 +21,6 @@ set(WITH_MOUSE ON)
2121 set(VMFILES
2222 # z80.cpp
2323
24- i8253.cpp
25- i8255.cpp
26-
2724 upd1990a.cpp
2825 upd7220.cpp
2926
@@ -33,10 +30,14 @@ set(VMFILES
3330 )
3431 set(VMFILES_LIB
3532 i8251.cpp
33+ i8253.cpp
34+ i8255.cpp
35+
3636 ls244.cpp
3737 not.cpp
3838 pcm1bit.cpp
3939 upd765a.cpp
40+ upd7220_base.cpp
4041
4142 prnfile.cpp
4243
--- a/source/build-cmake/n5200/CMakeLists.txt
+++ b/source/build-cmake/n5200/CMakeLists.txt
@@ -23,11 +23,7 @@ set(WITH_MOUSE ON)
2323
2424 set(VMFILES_BASE
2525 # i386.cpp
26-
2726 i8237.cpp
28- i8253.cpp
29- i8255.cpp
30- i8259.cpp
3127
3228 upd1990a.cpp
3329 upd7220.cpp
@@ -37,7 +33,12 @@ set(VMFILES_BASE
3733 )
3834 set(VMFILES_LIB
3935 beep.cpp
36+ i8237_base.cpp
4037 i8251.cpp
38+ i8253.cpp
39+ i8255.cpp
40+ i8259.cpp
41+ upd7220_base.cpp
4142 upd765a.cpp
4243 disk.cpp
4344 )
--- a/source/build-cmake/pc100/CMakeLists.txt
+++ b/source/build-cmake/pc100/CMakeLists.txt
@@ -20,10 +20,6 @@ set(WITH_MOUSE ON)
2020
2121 set(VMFILES
2222 # i286.cpp
23-
24- i8255.cpp
25- i8259.cpp
26-
2723 msm58321.cpp
2824
2925 memory.cpp
@@ -31,9 +27,13 @@ set(VMFILES
3127 io.cpp
3228 )
3329 set(VMFILES_LIB
30+ beep.cpp
3431 and.cpp
3532 i8251.cpp
36- beep.cpp
33+ i8255.cpp
34+ i8259.cpp
35+ msm58321_base.cpp
36+
3737 pcm1bit.cpp
3838 upd765a.cpp
3939 disk.cpp
--- a/source/src/vm/common_vm/CMakeLists.txt
+++ b/source/src/vm/common_vm/CMakeLists.txt
@@ -19,11 +19,11 @@ set(s_vm_common_vm_srcs
1919 # ../i8080.cpp
2020
2121 ../i8155.cpp
22-# ../i8237.cpp
22+ ../i8237_base.cpp
2323 ../i8251.cpp
24-# ../i8253.cpp
25-# ../i8255.cpp
26-# ../i8259.cpp
24+ ../i8253.cpp
25+ ../i8255.cpp
26+ ../i8259.cpp
2727 # ../i86.cpp
2828 # ../io.cpp
2929 # ../ld700.cpp
@@ -71,7 +71,7 @@ set(s_vm_common_vm_srcs
7171 # ../upd1990a.cpp
7272 ../upd4991a.cpp
7373 ../upd71071.cpp
74-# ../upd7220.cpp
74+ ../upd7220_base.cpp
7575 ../upd765a.cpp
7676 ../upd7752.cpp
7777 # ../upd7801.cpp
@@ -87,7 +87,7 @@ set(s_vm_common_vm_srcs
8787 # ../z80ctc.cpp
8888 ../z80dma.cpp
8989 ../z80pio.cpp
90-# ../z80sio.cpp
90+ ../z80sio.cpp
9191
9292
9393 ../libcpu_newdev/mcs48_base.cpp
@@ -120,8 +120,8 @@ else()
120120 ${s_vm_common_vm_srcs}
121121 )
122122 set_target_properties(CSPcommon_vm PROPERTIES
123- SOVERSION 1.1.6
124- VERSION 1.1.6
123+ SOVERSION 1.1.7
124+ VERSION 1.1.7
125125 )
126126 INSTALL(TARGETS CSPcommon_vm DESTINATION ${LIBCSP_INSTALL_DIR})
127127 endif()
--- a/source/src/vm/fmr30/memory.cpp
+++ b/source/src/vm/fmr30/memory.cpp
@@ -7,6 +7,8 @@
77 [ memory and crtc ]
88 */
99
10+#include "../vm.h"
11+#include "../../emu.h"
1012 #include "memory.h"
1113 #include "../i8237.h"
1214 #include "../i286.h"
--- a/source/src/vm/fmr30/scsi.cpp
+++ b/source/src/vm/fmr30/scsi.cpp
@@ -7,6 +7,8 @@
77 [ scsi ]
88 */
99
10+#include "../vm.h"
11+#include "../../emu.h"
1012 #include "scsi.h"
1113 #include "../i8237.h"
1214 #include "../i8259.h"
--- a/source/src/vm/i8237.cpp
+++ b/source/src/vm/i8237.cpp
@@ -8,13 +8,23 @@
88 [ i8237 ]
99 */
1010
11+#include "vm.h"
12+#include "../emu.h"
1113 #include "i8237.h"
1214
13-void I8237::reset()
15+
16+I8237::I8237(VM* parent_vm, EMU* parent_emu) : I8237_BASE(parent_vm, parent_emu)
17+{
18+ for(int i = 0; i < 4; i++) {
19+ dma[i].dev = vm->dummy;
20+ }
21+#ifdef SINGLE_MODE_DMA
22+ d_dma = NULL;
23+#endif
24+}
25+
26+I8237::~I8237()
1427 {
15- low_high = false;
16- cmd = req = tc = 0;
17- mask = 0xff;
1828 }
1929
2030 void I8237::write_io8(uint32_t addr, uint32_t data)
@@ -88,40 +98,6 @@ void I8237::write_io8(uint32_t addr, uint32_t data)
8898 }
8999 }
90100
91-uint32_t I8237::read_io8(uint32_t addr)
92-{
93- int ch = (addr >> 1) & 3;
94- uint32_t val = 0xff;
95-
96- switch(addr & 0x0f) {
97- case 0x00: case 0x02: case 0x04: case 0x06:
98- if(low_high) {
99- val = dma[ch].areg >> 8;
100- } else {
101- val = dma[ch].areg & 0xff;
102- }
103- low_high = !low_high;
104- return val;
105- case 0x01: case 0x03: case 0x05: case 0x07:
106- if(low_high) {
107- val = dma[ch].creg >> 8;
108- } else {
109- val = dma[ch].creg & 0xff;
110- }
111- low_high = !low_high;
112- return val;
113- case 0x08:
114- // status register
115- val = (req << 4) | tc;
116- tc = 0;
117- return val;
118- case 0x0d:
119- // temporary register
120- return tmp & 0xff;
121- }
122- return 0xff;
123-}
124-
125101 void I8237::write_signal(int id, uint32_t data, uint32_t mask)
126102 {
127103 if(SIG_I8237_CH0 <= id && id <= SIG_I8237_CH3) {
@@ -207,42 +183,6 @@ void I8237::do_dma()
207183 #endif
208184 }
209185
210-void I8237::write_mem(uint32_t addr, uint32_t data)
211-{
212- if(mode_word) {
213- d_mem->write_dma_data16(addr << 1, data);
214- } else {
215- d_mem->write_dma_data8(addr, data);
216- }
217-}
218-
219-uint32_t I8237::read_mem(uint32_t addr)
220-{
221- if(mode_word) {
222- return d_mem->read_dma_data16(addr << 1);
223- } else {
224- return d_mem->read_dma_data8(addr);
225- }
226-}
227-
228-void I8237::write_io(int ch, uint32_t data)
229-{
230- if(mode_word) {
231- dma[ch].dev->write_dma_io16(0, data);
232- } else {
233- dma[ch].dev->write_dma_io8(0, data);
234- }
235-}
236-
237-uint32_t I8237::read_io(int ch)
238-{
239- if(mode_word) {
240- return dma[ch].dev->read_dma_io16(0);
241- } else {
242- return dma[ch].dev->read_dma_io8(0);
243- }
244-}
245-
246186 #define STATE_VERSION 1
247187
248188 void I8237::save_state(FILEIO* state_fio)
--- a/source/src/vm/i8237.h
+++ b/source/src/vm/i8237.h
@@ -11,8 +11,8 @@
1111 #ifndef _I8237_H_
1212 #define _I8237_H_
1313
14-#include "vm.h"
15-#include "../emu.h"
14+//#include "vm.h"
15+//#include "../emu.h"
1616 #include "device.h"
1717
1818 #define SIG_I8237_CH0 0
@@ -28,13 +28,11 @@
2828 #define SIG_I8237_MASK2 10
2929 #define SIG_I8237_MASK3 11
3030
31-class I8237 : public DEVICE
31+
32+class I8237_BASE : public DEVICE
3233 {
33-private:
34+protected:
3435 DEVICE* d_mem;
35-#ifdef SINGLE_MODE_DMA
36- DEVICE* d_dma;
37-#endif
3836
3937 struct {
4038 DEVICE* dev;
@@ -57,36 +55,35 @@ private:
5755 uint8_t tc;
5856 uint32_t tmp;
5957 bool mode_word;
60-
58+
6159 void write_mem(uint32_t addr, uint32_t data);
6260 uint32_t read_mem(uint32_t addr);
6361 void write_io(int ch, uint32_t data);
6462 uint32_t read_io(int ch);
6563
6664 public:
67- I8237(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
65+ I8237_BASE(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
6866 {
6967 for(int i = 0; i < 4; i++) {
70- dma[i].dev = vm->dummy;
68+ //dma[i].dev = vm->dummy;
69+ dma[i].dev = NULL;
7170 dma[i].bankreg = dma[i].incmask = 0;
7271 initialize_output_signals(&dma[i].outputs_tc);
7372 }
74-#ifdef SINGLE_MODE_DMA
75- d_dma = NULL;
76-#endif
7773 mode_word = false;
7874 set_device_name(_T("i8237 DMAC"));
7975 }
80- ~I8237() {}
76+ ~I8237_BASE() {}
8177
8278 // common functions
79+ void initialize();
8380 void reset();
84- void write_io8(uint32_t addr, uint32_t data);
81+ virtual void write_io8(uint32_t addr, uint32_t data);
8582 uint32_t read_io8(uint32_t addr);
86- void write_signal(int id, uint32_t data, uint32_t mask);
87- void do_dma();
88- void save_state(FILEIO* state_fio);
89- bool load_state(FILEIO* state_fio);
83+ virtual void write_signal(int id, uint32_t data, uint32_t mask);
84+ virtual void do_dma();
85+ virtual void save_state(FILEIO* state_fio) {};
86+ virtual bool load_state(FILEIO* state_fio) { return false;}
9087
9188 // unique functions
9289 void set_context_memory(DEVICE* device)
@@ -125,16 +122,32 @@ public:
125122 {
126123 register_output_signal(&dma[0].outputs_tc, device, id, mask);
127124 }
125+ void set_mode_word(bool val)
126+ {
127+ mode_word = val;
128+ }
129+};
130+
131+class I8237 : public I8237_BASE {
132+private:
133+#ifdef SINGLE_MODE_DMA
134+ DEVICE* d_dma;
135+#endif
136+public:
137+ I8237(VM* parent_vm, EMU* parent_emu);
138+ ~I8237();
139+
140+ virtual void write_io8(uint32_t addr, uint32_t data);
141+ void write_signal(int id, uint32_t data, uint32_t mask);
142+ void do_dma();
143+ void save_state(FILEIO* state_fio);
144+ bool load_state(FILEIO* state_fio);
128145 #ifdef SINGLE_MODE_DMA
129146 void set_context_child_dma(DEVICE* device)
130147 {
131148 d_dma = device;
132149 }
133150 #endif
134- void set_mode_word(bool val)
135- {
136- mode_word = val;
137- }
138151 };
139152
140153 #endif
--- /dev/null
+++ b/source/src/vm/i8237_base.cpp
@@ -0,0 +1,111 @@
1+/*
2+ Skelton for retropc emulator
3+
4+ Origin : MESS
5+ Author : Takeda.Toshiya
6+ Date : 2006.12.06 -
7+
8+ [ i8237 ]
9+*/
10+
11+#include "i8237.h"
12+
13+void I8237_BASE::initialize()
14+{
15+ DEVICE::initialize();
16+}
17+
18+void I8237_BASE::reset()
19+{
20+ low_high = false;
21+ cmd = req = tc = 0;
22+ mask = 0xff;
23+}
24+
25+void I8237_BASE::write_io8(uint32_t addr, uint32_t data)
26+{
27+ // Dummy function
28+}
29+
30+uint32_t I8237_BASE::read_io8(uint32_t addr)
31+{
32+ int ch = (addr >> 1) & 3;
33+ uint32_t val = 0xff;
34+
35+ switch(addr & 0x0f) {
36+ case 0x00: case 0x02: case 0x04: case 0x06:
37+ if(low_high) {
38+ val = dma[ch].areg >> 8;
39+ } else {
40+ val = dma[ch].areg & 0xff;
41+ }
42+ low_high = !low_high;
43+ return val;
44+ case 0x01: case 0x03: case 0x05: case 0x07:
45+ if(low_high) {
46+ val = dma[ch].creg >> 8;
47+ } else {
48+ val = dma[ch].creg & 0xff;
49+ }
50+ low_high = !low_high;
51+ return val;
52+ case 0x08:
53+ // status register
54+ val = (req << 4) | tc;
55+ tc = 0;
56+ return val;
57+ case 0x0d:
58+ // temporary register
59+ return tmp & 0xff;
60+ }
61+ return 0xff;
62+}
63+
64+void I8237_BASE::write_signal(int id, uint32_t data, uint32_t mask)
65+{
66+ // Dummy function
67+}
68+
69+// note: if SINGLE_MODE_DMA is defined, do_dma() is called in every machine cycle
70+
71+void I8237_BASE::do_dma()
72+{
73+ // Dummy function
74+}
75+
76+void I8237_BASE::write_mem(uint32_t addr, uint32_t data)
77+{
78+ if(mode_word) {
79+ d_mem->write_dma_data16(addr << 1, data);
80+ } else {
81+ d_mem->write_dma_data8(addr, data);
82+ }
83+}
84+
85+uint32_t I8237_BASE::read_mem(uint32_t addr)
86+{
87+ if(mode_word) {
88+ return d_mem->read_dma_data16(addr << 1);
89+ } else {
90+ return d_mem->read_dma_data8(addr);
91+ }
92+}
93+
94+void I8237_BASE::write_io(int ch, uint32_t data)
95+{
96+ if(mode_word) {
97+ dma[ch].dev->write_dma_io16(0, data);
98+ } else {
99+ dma[ch].dev->write_dma_io8(0, data);
100+ }
101+}
102+
103+uint32_t I8237_BASE::read_io(int ch)
104+{
105+ if(mode_word) {
106+ return dma[ch].dev->read_dma_io16(0);
107+ } else {
108+ return dma[ch].dev->read_dma_io8(0);
109+ }
110+}
111+
--- a/source/src/vm/i8253.cpp
+++ b/source/src/vm/i8253.cpp
@@ -12,6 +12,7 @@
1212 void I8253::initialize()
1313 {
1414 DEVICE::initialize();
15+ __HAS_I8254 = osd->check_feature(_T("HAS_I8254"));
1516 for(int ch = 0; ch < 3; ch++) {
1617 counter[ch].prev_out = true;
1718 counter[ch].prev_in = false;
@@ -25,11 +26,16 @@ void I8253::initialize()
2526 counter[ch].low_write = counter[ch].high_write = false;
2627 counter[ch].delay = false;
2728 counter[ch].start = false;
28-#ifdef HAS_I8254
29- // 8254 read-back command
30- counter[ch].null_count = true;
31- counter[ch].status_latched = false;
32-#endif
29+//#ifdef HAS_I8254
30+ if(__HAS_I8254) {
31+ // 8254 read-back command
32+ counter[ch].null_count = true;
33+ counter[ch].status_latched = false;
34+ } else {
35+ counter[ch].null_count = false;
36+ counter[ch].status_latched = false;
37+ }
38+//#endif
3339 }
3440 }
3541
@@ -70,9 +76,9 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
7076 }
7177 counter[ch].high_write = false;
7278 }
73-#ifdef HAS_I8254
74- counter[ch].null_count = true;
75-#endif
79+//#ifdef HAS_I8254
80+ if(__HAS_I8254) counter[ch].null_count = true;
81+//#endif
7682 // set signal
7783 if(counter[ch].mode == 0) {
7884 set_signal(ch, false);
@@ -96,7 +102,8 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
96102
97103 case 3: // ctrl reg
98104 if((data & 0xc0) == 0xc0) {
99-#ifdef HAS_I8254
105+//#ifdef HAS_I8254
106+ if(!__HAS_I8254) break;
100107 // i8254 read-back command
101108 for(ch = 0; ch < 3; ch++) {
102109 uint8_t bit = 2 << ch;
@@ -114,7 +121,7 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
114121 latch_count(ch);
115122 }
116123 }
117-#endif
124+//#endif
118125 break;
119126 }
120127 ch = (data >> 6) & 3;
@@ -138,9 +145,9 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
138145 stop_count(ch);
139146 counter[ch].count_reg = 0;
140147 // }
141-#ifdef HAS_I8254
142- counter[ch].null_count = true;
143-#endif
148+//#ifdef HAS_I8254
149+ if(__HAS_I8254) counter[ch].null_count = true;
150+//#endif
144151 } else if(!counter[ch].count_latched) {
145152 latch_count(ch);
146153 }
@@ -156,12 +163,12 @@ uint32_t I8253::read_io8(uint32_t addr)
156163 case 0:
157164 case 1:
158165 case 2:
159-#ifdef HAS_I8254
160- if(counter[ch].status_latched) {
166+//#ifdef HAS_I8254
167+ if((__HAS_I8254) && (counter[ch].status_latched)) {
161168 counter[ch].status_latched = false;
162169 return counter[ch].status;
163170 }
164-#endif
171+//#endif
165172 // if not latched, through current count
166173 if(!counter[ch].count_latched) {
167174 if(!counter[ch].low_read && !counter[ch].high_read) {
@@ -243,9 +250,9 @@ void I8253::input_clock(int ch, int clock)
243250 clock -= 1;
244251 counter[ch].delay = false;
245252 counter[ch].count = COUNT_VALUE(ch);
246-#ifdef HAS_I8254
247- counter[ch].null_count = false;
248-#endif
253+//#ifdef HAS_I8254
254+ if(__HAS_I8254) counter[ch].null_count = false;
255+//#endif
249256 }
250257
251258 // update counter
@@ -268,9 +275,9 @@ loop:
268275 if(counter[ch].count <= 0) {
269276 if(counter[ch].mode == 0 || counter[ch].mode == 2 || counter[ch].mode == 3) {
270277 counter[ch].count += tmp;
271-#ifdef HAS_I8254
272- counter[ch].null_count = false;
273-#endif
278+//#ifdef HAS_I8254
279+ if(__HAS_I8254) counter[ch].null_count = false;
280+//#endif
274281 goto loop;
275282 } else {
276283 counter[ch].start = false;
@@ -430,11 +437,13 @@ void I8253::save_state(FILEIO* state_fio)
430437 state_fio->FputInt32(counter[i].mode);
431438 state_fio->FputBool(counter[i].delay);
432439 state_fio->FputBool(counter[i].start);
433-#ifdef HAS_I8254
434- state_fio->FputBool(counter[i].null_count);
435- state_fio->FputBool(counter[i].status_latched);
436- state_fio->FputUint8(counter[i].status);
437-#endif
440+//#ifdef HAS_I8254
441+ if(__HAS_I8254) {
442+ state_fio->FputBool(counter[i].null_count);
443+ state_fio->FputBool(counter[i].status_latched);
444+ state_fio->FputUint8(counter[i].status);
445+ }
446+//#endif
438447 state_fio->FputUint64(counter[i].freq);
439448 state_fio->FputInt32(counter[i].register_id);
440449 state_fio->FputUint32(counter[i].input_clk);
@@ -468,11 +477,13 @@ bool I8253::load_state(FILEIO* state_fio)
468477 counter[i].mode = state_fio->FgetInt32();
469478 counter[i].delay = state_fio->FgetBool();
470479 counter[i].start = state_fio->FgetBool();
471-#ifdef HAS_I8254
472- counter[i].null_count = state_fio->FgetBool();
473- counter[i].status_latched = state_fio->FgetBool();
474- counter[i].status = state_fio->FgetUint8();
475-#endif
480+//#ifdef HAS_I8254
481+ if(__HAS_I8254) {
482+ counter[i].null_count = state_fio->FgetBool();
483+ counter[i].status_latched = state_fio->FgetBool();
484+ counter[i].status = state_fio->FgetUint8();
485+ }
486+//#endif
476487 counter[i].freq = state_fio->FgetUint64();
477488 counter[i].register_id = state_fio->FgetInt32();
478489 counter[i].input_clk = state_fio->FgetUint32();
--- a/source/src/vm/i8253.h
+++ b/source/src/vm/i8253.h
@@ -10,8 +10,8 @@
1010 #ifndef _I8253_H_
1111 #define _I8253_H_
1212
13-#include "vm.h"
14-#include "../emu.h"
13+//#include "vm.h"
14+//#include "../emu.h"
1515 #include "device.h"
1616
1717 #define SIG_I8253_CLOCK_0 0
@@ -38,11 +38,11 @@ private:
3838 int mode;
3939 bool delay;
4040 bool start;
41-#ifdef HAS_I8254
41+//#ifdef HAS_I8254
4242 bool null_count;
4343 bool status_latched;
4444 uint8_t status;
45-#endif
45+//#endif
4646 // constant clock
4747 uint64_t freq;
4848 int register_id;
@@ -53,6 +53,8 @@ private:
5353 outputs_t outputs;
5454 } counter[3];
5555 uint64_t cpu_clocks;
56+
57+ bool __HAS_I8254;
5658
5759 void input_clock(int ch, int clock);
5860 void input_gate(int ch, bool signal);
--- a/source/src/vm/i8255.cpp
+++ b/source/src/vm/i8255.cpp
@@ -23,6 +23,12 @@
2323 #define BIT_INTR_A 0x08 // PC3
2424 #define BIT_INTR_B 0x01 // PC0
2525
26+void I8255::initialize()
27+{
28+ DEVICE::initialize();
29+ __I8255_AUTO_HAND_SHAKE = osd->check_feature(_T("I8255_AUTO_HAND_SHAKE"));
30+}
31+
2632 void I8255::reset()
2733 {
2834 for(int i = 0; i < 3; i++) {
@@ -44,7 +50,8 @@ void I8255::write_io8(uint32_t addr, uint32_t data)
4450 write_signals(&port[ch].outputs, port[ch].wreg = data);
4551 port[ch].first = false;
4652 }
47-#ifndef I8255_AUTO_HAND_SHAKE
53+//#ifndef I8255_AUTO_HAND_SHAKE
54+ if(__I8255_AUTO_HAND_SHAKE) break;
4855 if(ch == 0) {
4956 if(port[0].mode == 1 || port[0].mode == 2) {
5057 uint32_t val = port[2].wreg & ~BIT_OBF_A;
@@ -62,7 +69,7 @@ void I8255::write_io8(uint32_t addr, uint32_t data)
6269 write_io8(2, val);
6370 }
6471 }
65-#endif
72+//#endif
6673 break;
6774 case 3:
6875 if(data & 0x80) {
@@ -144,7 +151,8 @@ void I8255::write_signal(int id, uint32_t data, uint32_t mask)
144151 switch(id) {
145152 case SIG_I8255_PORT_A:
146153 port[0].rreg = (port[0].rreg & ~mask) | (data & mask);
147-#ifdef I8255_AUTO_HAND_SHAKE
154+//#ifdef I8255_AUTO_HAND_SHAKE
155+ if(!__I8255_AUTO_HAND_SHAKE) break;
148156 if(port[0].mode == 1 || port[0].mode == 2) {
149157 uint32_t val = port[2].wreg | BIT_IBF_A;
150158 if(port[2].wreg & BIT_STB_A) {
@@ -152,11 +160,12 @@ void I8255::write_signal(int id, uint32_t data, uint32_t mask)
152160 }
153161 write_io8(2, val);
154162 }
155-#endif
163+//#endif
156164 break;
157165 case SIG_I8255_PORT_B:
158166 port[1].rreg = (port[1].rreg & ~mask) | (data & mask);
159-#ifdef I8255_AUTO_HAND_SHAKE
167+//#ifdef I8255_AUTO_HAND_SHAKE
168+ if(!__I8255_AUTO_HAND_SHAKE) break;
160169 if(port[1].mode == 1) {
161170 uint32_t val = port[2].wreg | BIT_IBF_B;
162171 if(port[2].wreg & BIT_STB_B) {
@@ -164,54 +173,56 @@ void I8255::write_signal(int id, uint32_t data, uint32_t mask)
164173 }
165174 write_io8(2, val);
166175 }
167-#endif
176+//#endif
168177 break;
169178 case SIG_I8255_PORT_C:
170-#ifndef I8255_AUTO_HAND_SHAKE
171- if(port[0].mode == 1 || port[0].mode == 2) {
172- if(mask & BIT_STB_A) {
173- if((port[2].rreg & BIT_STB_A) && !(data & BIT_STB_A)) {
174- write_io8(2, port[2].wreg | BIT_IBF_A);
175- } else if(!(port[2].rreg & BIT_STB_A) && (data & BIT_STB_A)) {
176- if(port[2].wreg & BIT_STB_A) {
177- write_io8(2, port[2].wreg | BIT_INTR_A);
179+//#ifndef I8255_AUTO_HAND_SHAKE
180+ if(!__I8255_AUTO_HAND_SHAKE) {
181+ if(port[0].mode == 1 || port[0].mode == 2) {
182+ if(mask & BIT_STB_A) {
183+ if((port[2].rreg & BIT_STB_A) && !(data & BIT_STB_A)) {
184+ write_io8(2, port[2].wreg | BIT_IBF_A);
185+ } else if(!(port[2].rreg & BIT_STB_A) && (data & BIT_STB_A)) {
186+ if(port[2].wreg & BIT_STB_A) {
187+ write_io8(2, port[2].wreg | BIT_INTR_A);
188+ }
178189 }
179190 }
180- }
181- if(mask & BIT_ACK_A) {
182- if((port[2].rreg & BIT_ACK_A) && !(data & BIT_ACK_A)) {
183- write_io8(2, port[2].wreg | BIT_OBF_A);
184- } else if(!(port[2].rreg & BIT_ACK_A) && (data & BIT_ACK_A)) {
185- if(port[2].wreg & BIT_ACK_A) {
186- write_io8(2, port[2].wreg | BIT_INTR_A);
191+ if(mask & BIT_ACK_A) {
192+ if((port[2].rreg & BIT_ACK_A) && !(data & BIT_ACK_A)) {
193+ write_io8(2, port[2].wreg | BIT_OBF_A);
194+ } else if(!(port[2].rreg & BIT_ACK_A) && (data & BIT_ACK_A)) {
195+ if(port[2].wreg & BIT_ACK_A) {
196+ write_io8(2, port[2].wreg | BIT_INTR_A);
197+ }
187198 }
188199 }
189200 }
190- }
191- if(port[1].mode == 1) {
192- if(port[0].rmask == 0xff) {
193- if(mask & BIT_STB_B) {
194- if((port[2].rreg & BIT_STB_B) && !(data & BIT_STB_B)) {
195- write_io8(2, port[2].wreg | BIT_IBF_B);
196- } else if(!(port[2].rreg & BIT_STB_B) && (data & BIT_STB_B)) {
197- if(port[2].wreg & BIT_STB_B) {
198- write_io8(2, port[2].wreg | BIT_INTR_B);
201+ if(port[1].mode == 1) {
202+ if(port[0].rmask == 0xff) {
203+ if(mask & BIT_STB_B) {
204+ if((port[2].rreg & BIT_STB_B) && !(data & BIT_STB_B)) {
205+ write_io8(2, port[2].wreg | BIT_IBF_B);
206+ } else if(!(port[2].rreg & BIT_STB_B) && (data & BIT_STB_B)) {
207+ if(port[2].wreg & BIT_STB_B) {
208+ write_io8(2, port[2].wreg | BIT_INTR_B);
209+ }
199210 }
200211 }
201- }
202- } else {
203- if(mask & BIT_ACK_B) {
204- if((port[2].rreg & BIT_ACK_B) && !(data & BIT_ACK_B)) {
205- write_io8(2, port[2].wreg | BIT_OBF_B);
206- } else if(!(port[2].rreg & BIT_ACK_B) && (data & BIT_ACK_B)) {
207- if(port[2].wreg & BIT_ACK_B) {
208- write_io8(2, port[2].wreg | BIT_INTR_B);
212+ } else {
213+ if(mask & BIT_ACK_B) {
214+ if((port[2].rreg & BIT_ACK_B) && !(data & BIT_ACK_B)) {
215+ write_io8(2, port[2].wreg | BIT_OBF_B);
216+ } else if(!(port[2].rreg & BIT_ACK_B) && (data & BIT_ACK_B)) {
217+ if(port[2].wreg & BIT_ACK_B) {
218+ write_io8(2, port[2].wreg | BIT_INTR_B);
219+ }
209220 }
210221 }
211222 }
212223 }
213224 }
214-#endif
225+//#endif
215226 port[2].rreg = (port[2].rreg & ~mask) | (data & mask);
216227 break;
217228 }
--- a/source/src/vm/i8255.h
+++ b/source/src/vm/i8255.h
@@ -10,8 +10,8 @@
1010 #ifndef _I8255_H_
1111 #define _I8255_H_
1212
13-#include "vm.h"
14-#include "../emu.h"
13+//#include "vm.h"
14+//#include "../emu.h"
1515 #include "device.h"
1616
1717 #define SIG_I8255_PORT_A 0
@@ -30,6 +30,7 @@ private:
3030 // output signals
3131 outputs_t outputs;
3232 } port[3];
33+ bool __I8255_AUTO_HAND_SHAKE;
3334
3435 public:
3536 I8255(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
@@ -39,11 +40,13 @@ public:
3940 port[i].wreg = port[i].rreg = 0;//0xff;
4041 }
4142 clear_ports_by_cmdreg = false;
43+ __I8255_AUTO_HAND_SHAKE = false;
4244 set_device_name(_T("i8255 PIO"));
4345 }
4446 ~I8255() {}
4547
4648 // common functions
49+ void initialize();
4750 void reset();
4851 void write_io8(uint32_t addr, uint32_t data);
4952 uint32_t read_io8(uint32_t addr);
--- a/source/src/vm/i8259.cpp
+++ b/source/src/vm/i8259.cpp
@@ -9,12 +9,15 @@
99
1010 #include "i8259.h"
1111
12-#define CHIP_MASK (I8259_MAX_CHIPS - 1)
12+//#define CHIP_MASK (I8259_MAX_CHIPS - 1)
1313
1414 void I8259::initialize()
1515 {
1616 DEVICE::initialize();
17- for(int c = 0; c < I8259_MAX_CHIPS; c++) {
17+ __I8259_MAX_CHIPS = osd->get_feature_uint32_value(_T("I8259_MAX_CHIPS"));
18+ if(__I8259_MAX_CHIPS >= 2) __I8259_MAX_CHIPS = 2;
19+ __CHIP_MASK = __I8259_MAX_CHIPS - 1;
20+ for(int c = 0; c < __I8259_MAX_CHIPS; c++) {
1821 pic[c].imr = 0xff;
1922 pic[c].irr = pic[c].isr = pic[c].prio = 0;
2023 pic[c].icw1 = pic[c].icw2 = pic[c].icw3 = pic[c].icw4 = 0;
@@ -25,7 +28,7 @@ void I8259::initialize()
2528
2629 void I8259::reset()
2730 {
28- for(int c = 0; c < I8259_MAX_CHIPS; c++) {
31+ for(int c = 0; c < __I8259_MAX_CHIPS; c++) {
2932 pic[c].irr_tmp = 0;
3033 pic[c].irr_tmp_id = -1;
3134 }
@@ -33,7 +36,7 @@ void I8259::reset()
3336
3437 void I8259::write_io8(uint32_t addr, uint32_t data)
3538 {
36- int c = (addr >> 1) & CHIP_MASK;
39+ int c = (addr >> 1) & __CHIP_MASK;
3740
3841 if(addr & 1) {
3942 if(pic[c].icw2_r) {
@@ -141,7 +144,7 @@ void I8259::write_io8(uint32_t addr, uint32_t data)
141144
142145 uint32_t I8259::read_io8(uint32_t addr)
143146 {
144- int c = (addr >> 1) & CHIP_MASK;
147+ int c = (addr >> 1) & __CHIP_MASK;
145148
146149 if(addr & 1) {
147150 return pic[c].imr;
@@ -178,7 +181,7 @@ void I8259::write_signal(int id, uint32_t data, uint32_t mask)
178181
179182 void I8259::event_callback(int event_id, int err)
180183 {
181- int c = event_id & CHIP_MASK;
184+ int c = event_id & __CHIP_MASK;
182185 uint8_t irr = pic[c].irr;
183186
184187 pic[c].irr |= pic[c].irr_tmp;
@@ -199,9 +202,9 @@ void I8259::update_intr()
199202 {
200203 bool intr = false;
201204
202- for(int c = 0; c < I8259_MAX_CHIPS; c++) {
205+ for(int c = 0; c < __I8259_MAX_CHIPS; c++) {
203206 uint8_t irr = pic[c].irr;
204- if(c + 1 < I8259_MAX_CHIPS) {
207+ if(c + 1 < __I8259_MAX_CHIPS) {
205208 // this is master
206209 if(pic[c + 1].irr & (~pic[c + 1].imr)) {
207210 // request from slave
@@ -221,7 +224,7 @@ void I8259::update_intr()
221224 level = (level + 1) & 7;
222225 bit = 1 << level;
223226 }
224- if((c + 1 < I8259_MAX_CHIPS) && (pic[c].icw3 & bit)) {
227+ if((c + 1 < __I8259_MAX_CHIPS) && (pic[c].icw3 & bit)) {
225228 // check slave
226229 continue;
227230 }
@@ -281,7 +284,7 @@ void I8259::save_state(FILEIO* state_fio)
281284 state_fio->FputUint32(STATE_VERSION);
282285 state_fio->FputInt32(this_device_id);
283286
284- state_fio->Fwrite(pic, sizeof(pic), 1);
287+ for(int i = 0; i < __I8259_MAX_CHIPS; i++) state_fio->Fwrite(&pic[i], sizeof(struct i8259_pic_t), 1);
285288 state_fio->FputInt32(req_chip);
286289 state_fio->FputInt32(req_level);
287290 state_fio->FputUint8(req_bit);
@@ -295,7 +298,7 @@ bool I8259::load_state(FILEIO* state_fio)
295298 if(state_fio->FgetInt32() != this_device_id) {
296299 return false;
297300 }
298- state_fio->Fread(pic, sizeof(pic), 1);
301+ for(int i = 0; i < __I8259_MAX_CHIPS; i++) state_fio->Fread(&pic[i], sizeof(struct i8259_pic_t), 1);
299302 req_chip = state_fio->FgetInt32();
300303 req_level = state_fio->FgetInt32();
301304 req_bit = state_fio->FgetUint8();
--- a/source/src/vm/i8259.h
+++ b/source/src/vm/i8259.h
@@ -10,8 +10,8 @@
1010 #ifndef _I8259_H_
1111 #define _I8259_H_
1212
13-#include "vm.h"
14-#include "../emu.h"
13+//#include "vm.h"
14+//#include "../emu.h"
1515 #include "device.h"
1616
1717 /*
@@ -36,19 +36,23 @@
3636 //#define I8259_ADDR_CHIP2 4
3737 //#define I8259_ADDR_CHIP3 6
3838
39+struct i8259_pic_t {
40+ uint8_t imr, isr, irr, irr_tmp, prio;
41+ uint8_t icw1, icw2, icw3, icw4, ocw3;
42+ uint8_t icw2_r, icw3_r, icw4_r;
43+ int irr_tmp_id;
44+};
45+
3946 class I8259 : public DEVICE
4047 {
4148 private:
4249 DEVICE* d_cpu;
43-
44- struct {
45- uint8_t imr, isr, irr, irr_tmp, prio;
46- uint8_t icw1, icw2, icw3, icw4, ocw3;
47- uint8_t icw2_r, icw3_r, icw4_r;
48- int irr_tmp_id;
49- } pic[I8259_MAX_CHIPS];
50+
51+ struct i8259_pic_t pic[2];
5052 int req_chip, req_level;
5153 uint8_t req_bit;
54+ uint32_t __I8259_MAX_CHIPS;
55+ uint32_t __CHIP_MASK;
5256
5357 void update_intr();
5458
@@ -56,6 +60,8 @@ public:
5660 I8259(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
5761 {
5862 d_cpu = NULL;
63+ __I8259_MAX_CHIPS = 0;
64+ __CHIP_MASK = 0xffffffff;
5965 set_device_name(_T("i8259 PIC"));
6066 }
6167 ~I8259() {}
--- a/source/src/vm/j3100/dmareg.cpp
+++ b/source/src/vm/j3100/dmareg.cpp
@@ -8,6 +8,8 @@
88 [ dma bank register ]
99 */
1010
11+#include "../vm.h"
12+#include "../../emu.h"
1113 #include "dmareg.h"
1214 #include "../i8237.h"
1315
--- a/source/src/vm/memory.h
+++ b/source/src/vm/memory.h
@@ -10,8 +10,8 @@
1010 #ifndef _MEMORY_H_
1111 #define _MEMORY_H_
1212
13-//#include "vm.h"
14-//#include "../emu.h"
13+#include "vm.h"
14+#include "../emu.h"
1515 #include "device.h"
1616
1717 #ifndef MEMORY_ADDR_MAX
--- a/source/src/vm/n5200/floppy.cpp
+++ b/source/src/vm/n5200/floppy.cpp
@@ -7,6 +7,8 @@
77 [ floppy ]
88 */
99
10+#include "../vm.h"
11+#include "../../emu.h"
1012 #include "floppy.h"
1113 #include "../i8237.h"
1214
--- a/source/src/vm/n5200/system.cpp
+++ b/source/src/vm/n5200/system.cpp
@@ -7,6 +7,8 @@
77 [ system i/o ]
88 */
99
10+#include "../vm.h"
11+#include "../../emu.h"
1012 #include "system.h"
1113 #include "../i8237.h"
1214
--- a/source/src/vm/upd7220.cpp
+++ b/source/src/vm/upd7220.cpp
@@ -9,9 +9,12 @@
99 */
1010
1111 #include <math.h>
12+#include "vm.h"
13+#include "../emu.h"
1214 #include "upd7220.h"
1315 #include "../fifo.h"
1416
17+// -> See also: upd7220_base.cpp .
1518 enum {
1619 CMD_RESET = 0x00,
1720 CMD_SYNC = 0x0e,
@@ -38,7 +41,6 @@ enum {
3841 /* unknown command (3 params) */
3942 CMD_UNK_5A = 0x5a,
4043 };
41-
4244 enum {
4345 STAT_DRDY = 0x01,
4446 STAT_FULL = 0x02,
@@ -50,25 +52,9 @@ enum {
5052 STAT_LPEN = 0x80,
5153 };
5254
53-static const int vectdir[16][4] = {
54- { 0, 1, 1, 0}, { 1, 1, 1,-1}, { 1, 0, 0,-1}, { 1,-1,-1,-1},
55- { 0,-1,-1, 0}, {-1,-1,-1, 1}, {-1, 0, 0, 1}, {-1, 1, 1, 1},
56- { 0, 1, 1, 1}, { 1, 1, 1, 0}, { 1, 0, 1,-1}, { 1,-1, 0,-1},
57- { 0,-1,-1,-1}, {-1,-1,-1, 0}, {-1, 0,-1, 1}, {-1, 1, 0, 1}
58-};
59-
6055 void UPD7220::initialize()
6156 {
62- DEVICE::initialize();
63- for(int i = 0; i <= RT_TABLEMAX; i++) {
64- rt[i] = (int)((double)(1 << RT_MULBIT) * (1 - sqrt(1 - pow((0.70710678118654 * i) / RT_TABLEMAX, 2))));
65- }
66- fo = new FIFO(0x10000);
67-
68- vsync = hblank = false;
69- master = false;
70- pitch = 40; // 640dot
71-
57+ UPD7220_BASE::initialize();
7258 // initial settings for 1st frame
7359 vtotal = LINES_PER_FRAME;
7460 v1 = 16;
@@ -80,10 +66,8 @@ void UPD7220::initialize()
8066 h1 = 80;
8167 h2 = 29;
8268 #endif
83-
8469 sync_changed = false;
8570 vs = hc = 0;
86-
8771 #ifdef UPD7220_HORIZ_FREQ
8872 horiz_freq = 0;
8973 next_horiz_freq = UPD7220_HORIZ_FREQ;
@@ -94,125 +78,6 @@ void UPD7220::initialize()
9478 register_vline_event(this);
9579 }
9680
97-void UPD7220::release()
98-{
99- fo->release();
100- delete fo;
101-}
102-
103-void UPD7220::reset()
104-{
105- cmd_reset();
106-}
107-
108-void UPD7220::write_dma_io8(uint32_t addr, uint32_t data)
109-{
110- // for dma access
111- switch(cmdreg & 0x18) {
112- case 0x00: // low and high
113- if(low_high) {
114- cmd_write_sub(ead * 2 + 1, data & maskh);
115- ead += dif;
116- } else {
117- cmd_write_sub(ead * 2 + 0, data & maskl);
118- }
119- low_high = !low_high;
120- break;
121- case 0x10: // low byte
122- cmd_write_sub(ead * 2 + 0, data & maskl);
123- ead += dif;
124- break;
125- case 0x18: // high byte
126- cmd_write_sub(ead * 2 + 1, data & maskh);
127- ead += dif;
128- break;
129- }
130-}
131-
132-uint32_t UPD7220::read_dma_io8(uint32_t addr)
133-{
134- uint32_t val = 0xff;
135-
136- // for dma access
137- switch(cmdreg & 0x18) {
138- case 0x00: // low and high
139- if(low_high) {
140- val = read_vram(ead * 2 + 1);
141- ead += dif;
142- } else {
143- val = read_vram(ead * 2 + 0);
144- }
145- low_high = !low_high;
146- break;
147- case 0x10: // low byte
148- val = read_vram(ead * 2 + 0);
149- ead += dif;
150- break;
151- case 0x18: // high byte
152- val = read_vram(ead * 2 + 1);
153- ead += dif;
154- break;
155- }
156- return val;
157-}
158-
159-void UPD7220::write_io8(uint32_t addr, uint32_t data)
160-{
161- switch(addr & 3) {
162- case 0: // set parameter
163-// this->out_debug_log(_T("\tPARAM = %2x\n"), data);
164- if(cmdreg != -1) {
165- if(params_count < 16) {
166- params[params_count++] = (uint8_t)(data & 0xff);
167- }
168- check_cmd();
169- if(cmdreg == -1) {
170- params_count = 0;
171- }
172- }
173- break;
174- case 1: // process prev command if not finished
175- if(cmdreg != -1) {
176- process_cmd();
177- }
178- // set new command
179- cmdreg = (uint8_t)(data & 0xff);
180-// this->out_debug_log(_T("CMDREG = %2x\n"), cmdreg);
181- params_count = 0;
182- check_cmd();
183- break;
184- case 2: // set zoom
185- zoom = data;
186- break;
187- case 3: // light pen request
188- break;
189- }
190-}
191-
192-uint32_t UPD7220::read_io8(uint32_t addr)
193-{
194- uint32_t val;
195-
196- switch(addr & 3) {
197- case 0: // status
198- val = statreg;
199- val |= hblank ? STAT_HBLANK : 0;
200- val |= vsync ? STAT_VSYNC : 0;
201-// val |= (params_count == 0) ? STAT_EMPTY : 0;
202- val |= STAT_EMPTY;
203- val |= (params_count == 16) ? STAT_FULL : 0;
204- val |= fo->count() ? STAT_DRDY : 0;
205- // clear busy stat
206- statreg &= ~(STAT_DMA | STAT_DRAW);
207- return val;
208- case 1: // data
209- if(fo->count()) {
210- return fo->read();
211- }
212- return 0xff;
213- }
214- return 0xff;
215-}
21681
21782 void UPD7220::event_pre_frame()
21883 {
@@ -250,66 +115,6 @@ void UPD7220::event_pre_frame()
250115 }
251116 }
252117
253-void UPD7220::update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame)
254-{
255- cpu_clocks = new_clocks;
256- frames_per_sec = new_frames_per_sec; // note: refer these params given from the event manager
257- lines_per_frame = new_lines_per_frame; // because this device may be slave gdc
258-
259- // update event clocks
260- vs = hc = 0;
261-}
262-
263-void UPD7220::event_frame()
264-{
265- if(vs == 0) {
266- vs = (int)((double)lines_per_frame * (double)v1 / (double)(v1 + v2) + 0.5);
267- hc = (int)((double)cpu_clocks * (double)h2 / frames_per_sec / (double)lines_per_frame / (double)(h1 + h2) + 0.5);
268- }
269- if(++blink_cursor >= blink_rate * 4) {
270- blink_cursor = 0;
271- }
272- if(++blink_attr >= blink_rate * 2) {
273- blink_attr = 0;
274- }
275-}
276-
277-void UPD7220::event_vline(int v, int clock)
278-{
279- bool next = (v < vs);
280- if(vsync != next) {
281- write_signals(&outputs_vsync, next ? 0xffffffff : 0);
282- vsync = next;
283- }
284- hblank = true;
285- register_event_by_clock(this, 0, hc, false, NULL);
286-}
287-
288-void UPD7220::event_callback(int event_id, int err)
289-{
290- hblank = false;
291-}
292-
293-uint32_t UPD7220::cursor_addr(uint32_t mask)
294-{
295- if((cs[0] & 0x80) && ((cs[1] & 0x20) || (blink_cursor < blink_rate * 2))) {
296- return (ead << 1) & mask;
297- }
298- return -1;
299-}
300-
301-int UPD7220::cursor_top()
302-{
303- return cs[1] & 0x1f;
304-}
305-
306-int UPD7220::cursor_bottom()
307-{
308- return cs[2] >> 3;
309-}
310-
311-// command process
312-
313118 void UPD7220::check_cmd()
314119 {
315120 // check fifo buffer and process command if enough params in fifo
@@ -525,131 +330,6 @@ void UPD7220::process_cmd()
525330 }
526331 }
527332
528-void UPD7220::cmd_reset()
529-{
530- // init gdc params
531- sync[6] = 0x90;
532- sync[7] = 0x01;
533- zoom = zr = zw = 0;
534- ra[0] = ra[1] = ra[2] = 0;
535- ra[3] = 0x1e; /*0x19;*/
536- cs[0] = cs[1] = cs[2] = 0;
537- ead = dad = 0;
538- maskl = maskh = 0xff;
539- mod = 0;
540- blink_cursor = 0;
541- blink_attr = 0;
542- blink_rate = 16;
543-
544- // init fifo
545- params_count = 0;
546- fo->clear();
547-
548- // stop display and drawing
549- start = false;
550- statreg = 0;
551- cmdreg = -1;
552- cmd_write_done = false;
553-}
554-
555-void UPD7220::cmd_sync()
556-{
557- start = ((cmdreg & 1) != 0);
558- for(int i = 0; i < 8 && i < params_count; i++) {
559- if(sync[i] != params[i]) {
560- sync[i] = params[i];
561- sync_changed = true;
562- }
563- }
564- cmdreg = -1;
565-}
566-
567-void UPD7220::cmd_master()
568-{
569- master = true;
570- cmdreg = -1;
571-}
572-
573-void UPD7220::cmd_slave()
574-{
575- master = false;
576- cmdreg = -1;
577-}
578-
579-void UPD7220::cmd_start()
580-{
581- start = true;
582- cmdreg = -1;
583-}
584-
585-void UPD7220::cmd_stop()
586-{
587- start = false;
588- cmdreg = -1;
589-}
590-
591-void UPD7220::cmd_zoom()
592-{
593- if(params_count > 0) {
594- uint8_t tmp = params[0];
595- zr = tmp >> 4;
596- zw = tmp & 0x0f;
597- cmdreg = -1;
598- }
599-}
600-
601-void UPD7220::cmd_scroll()
602-{
603- if(params_count > 0) {
604- ra[cmdreg & 0x0f] = params[0];
605- if(cmdreg < 0x7f) {
606- cmdreg++;
607- params_count = 0;
608- } else {
609- cmdreg = -1;
610- }
611- }
612-}
613-
614-void UPD7220::cmd_csrform()
615-{
616- for(int i = 0; i < params_count; i++) {
617- cs[i] = params[i];
618- }
619- if(params_count > 2) {
620- cmdreg = -1;
621- }
622- blink_rate = (cs[1] >> 6) | ((cs[2] & 7) << 2);
623-}
624-
625-void UPD7220::cmd_pitch()
626-{
627- if(params_count > 0) {
628-#ifndef UPD7220_FIXED_PITCH
629- pitch = params[0];
630-#endif
631- cmdreg = -1;
632- }
633-}
634-
635-void UPD7220::cmd_lpen()
636-{
637- fo->write(lad & 0xff);
638- fo->write((lad >> 8) & 0xff);
639- fo->write((lad >> 16) & 0xff);
640- cmdreg = -1;
641-}
642-
643-void UPD7220::cmd_vectw()
644-{
645- for(int i = 0; i < 11 && i < params_count; i++) {
646- vect[i] = params[i];
647-// this->out_debug_log(_T("\tVECT[%d] = %2x\n"), i, vect[i]);
648- }
649- update_vect();
650- cmdreg = -1;
651-}
652-
653333 void UPD7220::cmd_vecte()
654334 {
655335 dx = ((ead % pitch) << 4) | (dad & 0x0f);
@@ -704,204 +384,118 @@ void UPD7220::cmd_texte()
704384 cmdreg = -1;
705385 }
706386
707-void UPD7220::cmd_csrw()
387+void UPD7220::cmd_pitch()
708388 {
709389 if(params_count > 0) {
710- ead = params[0];
711- if(params_count > 1) {
712- ead |= params[1] << 8;
713- if(params_count > 2) {
714- ead |= params[2] << 16;
715- cmdreg = -1;
716- }
717- }
718- dad = (ead >> 20) & 0x0f;
719- ead &= 0x3ffff;
720- }
721-}
722-
723-void UPD7220::cmd_csrr()
724-{
725- fo->write(ead & 0xff);
726- fo->write((ead >> 8) & 0xff);
727- fo->write((ead >> 16) & 0x03);
728- fo->write(dad & 0xff);
729- fo->write((dad >> 8) & 0xff);
730- cmdreg = -1;
731-}
732-
733-void UPD7220::cmd_mask()
734-{
735- if(params_count > 1) {
736- maskl = params[0];
737- maskh = params[1];
390+#ifndef UPD7220_FIXED_PITCH
391+ pitch = params[0];
392+#endif
738393 cmdreg = -1;
739394 }
740395 }
741396
742-void UPD7220::cmd_write()
397+void UPD7220::draw_text()
743398 {
744- mod = cmdreg & 3;
745- switch(cmdreg & 0x18) {
746- case 0x00: // low and high
747- if(params_count > 1) {
748- uint8_t l = params[0] & maskl;
749- uint8_t h = params[1] & maskh;
750- for(int i = 0; i < dc + 1; i++) {
751- cmd_write_sub(ead * 2 + 0, l);
752- cmd_write_sub(ead * 2 + 1, h);
753- ead += dif;
754- }
755- cmd_write_done = true;
756- params_count = 0;
757- }
758- break;
759- case 0x10: // low byte
760- if(params_count > 0) {
761- uint8_t l = params[0] & maskl;
762- for(int i = 0; i < dc + 1; i++) {
763- cmd_write_sub(ead * 2 + 0, l);
764- ead += dif;
765- }
766- cmd_write_done = true;
767- params_count = 0;
768- }
769- break;
770- case 0x18: // high byte
771- if(params_count > 0) {
772- uint8_t h = params[0] & maskh;
773- for(int i = 0; i < dc + 1; i++) {
774- cmd_write_sub(ead * 2 + 1, h);
775- ead += dif;
776- }
777- cmd_write_done = true;
778- params_count = 0;
779- }
780- break;
781- default: // invalid
782- cmdreg = -1;
783- break;
399+ int dir2 = dir + (sl ? 8 : 0);
400+ int vx1 = vectdir[dir2][0];
401+ int vy1 = vectdir[dir2][1];
402+ int vx2 = vectdir[dir2][2];
403+ int vy2 = vectdir[dir2][3];
404+ int sx = d;
405+ int sy = dc + 1;
406+#ifdef _QC10
407+ if(dir == 0 && sy == 40) {
408+ sy = 640; // ugly patch
784409 }
785-}
786-
787-void UPD7220::cmd_read()
788-{
789- mod = cmdreg & 3;
790- switch(cmdreg & 0x18) {
791- case 0x00: // low and high
792- for(int i = 0; i < dc; i++) {
793- fo->write(read_vram(ead * 2 + 0));
794- fo->write(read_vram(ead * 2 + 1));
795- ead += dif;
796- }
797- break;
798- case 0x10: // low byte
799- for(int i = 0; i < dc; i++) {
800- fo->write(read_vram(ead * 2 + 0));
801- ead += dif;
802- }
803- break;
804- case 0x18: // high byte
805- for(int i = 0; i < dc; i++) {
806- fo->write(read_vram(ead * 2 + 1));
807- ead += dif;
410+#endif
411+// this->out_debug_log(_T("\tTEXT: dx=%d,dy=%d,sx=%d,sy=%d\n"), dx, dy, sx, sy);
412+ int index = 15;
413+
414+ while(sy--) {
415+ int muly = zw + 1;
416+ while(muly--) {
417+ int cx = dx;
418+ int cy = dy;
419+ uint8_t bit = ra[index];
420+ int xrem = sx;
421+ while(xrem--) {
422+ pattern = (bit & 1) ? 0xffff : 0;
423+ bit = (bit >> 1) | ((bit & 1) ? 0x80 : 0);
424+ int mulx = zw + 1;
425+ while(mulx--) {
426+ draw_pset(cx, cy);
427+ cx += vx1;
428+ cy += vy1;
429+ }
430+ }
431+ dx += vx2;
432+ dy += vy2;
808433 }
809- break;
810- default: // invalid
811- break;
812- }
813- reset_vect();
814- cmdreg = -1;
815-}
816-
817-void UPD7220::cmd_dmaw()
818-{
819- mod = cmdreg & 3;
820- low_high = false;
821- write_signals(&outputs_drq, 0xffffffff);
822- reset_vect();
823-// statreg |= STAT_DMA;
824- cmdreg = -1;
825-}
826-
827-void UPD7220::cmd_dmar()
828-{
829- mod = cmdreg & 3;
830- low_high = false;
831- write_signals(&outputs_drq, 0xffffffff);
832- reset_vect();
833-// statreg |= STAT_DMA;
834- cmdreg = -1;
835-}
836-
837-void UPD7220::cmd_unk_5a()
838-{
839- if(params_count > 2) {
840- cmdreg = -1;
434+ index = ((index - 1) & 7) | 8;
841435 }
436+ ead = (dx >> 4) + dy * pitch;
437+ dad = dx & 0x0f;
842438 }
843439
844-// command sub
845-
846-void UPD7220::cmd_write_sub(uint32_t addr, uint8_t data)
440+void UPD7220::draw_pset(int x, int y)
847441 {
442+ uint16_t dot = pattern & 1;
443+ pattern = (pattern >> 1) | (dot << 15);
444+ uint32_t addr = y * 80 + (x >> 3);
445+#ifdef UPD7220_MSB_FIRST
446+ uint8_t bit = 0x80 >> (x & 7);
447+#else
448+ uint8_t bit = 1 << (x & 7);
449+#endif
450+ uint8_t cur = read_vram(addr);
451+
848452 switch(mod) {
849453 case 0: // replace
850- write_vram(addr, data);
454+ write_vram(addr, (cur & ~bit) | (dot ? bit : 0));
851455 break;
852456 case 1: // complement
853- write_vram(addr, read_vram(addr) ^ data);
457+ write_vram(addr, (cur & ~bit) | ((cur ^ (dot ? 0xff : 0)) & bit));
854458 break;
855459 case 2: // reset
856- write_vram(addr, read_vram(addr) & ~data);
460+ write_vram(addr, cur & (dot ? ~bit : 0xff));
857461 break;
858462 case 3: // set
859- write_vram(addr, read_vram(addr) | data);
463+ write_vram(addr, cur | (dot ? bit : 0));
860464 break;
861465 }
862466 }
863467
864-void UPD7220::write_vram(uint32_t addr, uint8_t data)
865-{
866- if(vram != NULL && addr < vram_size) {
867- vram[addr] = data;
868- }
869-}
870-
871-uint8_t UPD7220::read_vram(uint32_t addr)
468+void UPD7220::write_io8(uint32_t addr, uint32_t data)
872469 {
873- if(vram != NULL && addr < vram_size) {
874- uint8_t mask = (addr & 1) ? (vram_data_mask >> 8) : (vram_data_mask & 0xff);
875- return (vram[addr] & mask) | ~mask;
470+ switch(addr & 3) {
471+ case 0: // set parameter
472+// this->out_debug_log(_T("\tPARAM = %2x\n"), data);
473+ if(cmdreg != -1) {
474+ if(params_count < 16) {
475+ params[params_count++] = (uint8_t)(data & 0xff);
476+ }
477+ check_cmd();
478+ if(cmdreg == -1) {
479+ params_count = 0;
480+ }
481+ }
482+ break;
483+ case 1: // process prev command if not finished
484+ if(cmdreg != -1) {
485+ process_cmd();
486+ }
487+ // set new command
488+ cmdreg = (uint8_t)(data & 0xff);
489+// this->out_debug_log(_T("CMDREG = %2x\n"), cmdreg);
490+ params_count = 0;
491+ check_cmd();
492+ break;
493+ case 2: // set zoom
494+ zoom = data;
495+ break;
496+ case 3: // light pen request
497+ break;
876498 }
877- return 0xff;
878-}
879-
880-void UPD7220::update_vect()
881-{
882- dir = vect[0] & 7;
883- dif = vectdir[dir][0] + vectdir[dir][1] * pitch;
884- sl = vect[0] & 0x80;
885- dc = (vect[1] | (vect[ 2] << 8)) & 0x3fff;
886- d = (vect[3] | (vect[ 4] << 8)) & 0x3fff;
887- d2 = (vect[5] | (vect[ 6] << 8)) & 0x3fff;
888- d1 = (vect[7] | (vect[ 8] << 8)) & 0x3fff;
889- dm = (vect[9] | (vect[10] << 8)) & 0x3fff;
890-}
891-
892-void UPD7220::reset_vect()
893-{
894- vect[ 1] = 0x00;
895- vect[ 2] = 0x00;
896- vect[ 3] = 0x08;
897- vect[ 4] = 0x00;
898- vect[ 5] = 0x08;
899- vect[ 6] = 0x00;
900- vect[ 7] = 0x00;
901- vect[ 8] = 0x00;
902- vect[ 9] = 0x00;
903- vect[10] = 0x00;
904- update_vect();
905499 }
906500
907501 // draw
@@ -1121,77 +715,6 @@ void UPD7220::draw_vectr()
1121715 dad = dx & 0x0f;
1122716 }
1123717
1124-void UPD7220::draw_text()
1125-{
1126- int dir2 = dir + (sl ? 8 : 0);
1127- int vx1 = vectdir[dir2][0];
1128- int vy1 = vectdir[dir2][1];
1129- int vx2 = vectdir[dir2][2];
1130- int vy2 = vectdir[dir2][3];
1131- int sx = d;
1132- int sy = dc + 1;
1133-#ifdef _QC10
1134- if(dir == 0 && sy == 40) {
1135- sy = 640; // ugly patch
1136- }
1137-#endif
1138-// this->out_debug_log(_T("\tTEXT: dx=%d,dy=%d,sx=%d,sy=%d\n"), dx, dy, sx, sy);
1139- int index = 15;
1140-
1141- while(sy--) {
1142- int muly = zw + 1;
1143- while(muly--) {
1144- int cx = dx;
1145- int cy = dy;
1146- uint8_t bit = ra[index];
1147- int xrem = sx;
1148- while(xrem--) {
1149- pattern = (bit & 1) ? 0xffff : 0;
1150- bit = (bit >> 1) | ((bit & 1) ? 0x80 : 0);
1151- int mulx = zw + 1;
1152- while(mulx--) {
1153- draw_pset(cx, cy);
1154- cx += vx1;
1155- cy += vy1;
1156- }
1157- }
1158- dx += vx2;
1159- dy += vy2;
1160- }
1161- index = ((index - 1) & 7) | 8;
1162- }
1163- ead = (dx >> 4) + dy * pitch;
1164- dad = dx & 0x0f;
1165-}
1166-
1167-void UPD7220::draw_pset(int x, int y)
1168-{
1169- uint16_t dot = pattern & 1;
1170- pattern = (pattern >> 1) | (dot << 15);
1171- uint32_t addr = y * 80 + (x >> 3);
1172-#ifdef UPD7220_MSB_FIRST
1173- uint8_t bit = 0x80 >> (x & 7);
1174-#else
1175- uint8_t bit = 1 << (x & 7);
1176-#endif
1177- uint8_t cur = read_vram(addr);
1178-
1179- switch(mod) {
1180- case 0: // replace
1181- write_vram(addr, (cur & ~bit) | (dot ? bit : 0));
1182- break;
1183- case 1: // complement
1184- write_vram(addr, (cur & ~bit) | ((cur ^ (dot ? 0xff : 0)) & bit));
1185- break;
1186- case 2: // reset
1187- write_vram(addr, cur & (dot ? ~bit : 0xff));
1188- break;
1189- case 3: // set
1190- write_vram(addr, cur | (dot ? bit : 0));
1191- break;
1192- }
1193-}
1194-
1195718 #define STATE_VERSION 1
1196719
1197720 void UPD7220::save_state(FILEIO* state_fio)
--- a/source/src/vm/upd7220.h
+++ b/source/src/vm/upd7220.h
@@ -11,8 +11,8 @@
1111 #ifndef _UPD7220_H_
1212 #define _UPD7220_H_
1313
14-#include "vm.h"
15-#include "../emu.h"
14+//#include "vm.h"
15+//#include "../emu.h"
1616 #include "device.h"
1717
1818 #define MODE_MIX ((sync[0] & 0x22) == 0x00)
@@ -25,9 +25,9 @@
2525
2626 class FIFO;
2727
28-class UPD7220 : public DEVICE
28+class UPD7220_BASE : public DEVICE
2929 {
30-private:
30+protected:
3131 // output signals
3232 outputs_t outputs_drq;
3333 outputs_t outputs_vsync;
@@ -64,9 +64,6 @@ private:
6464 bool cmd_write_done;
6565
6666 int cpu_clocks;
67-#ifdef UPD7220_HORIZ_FREQ
68- int horiz_freq, next_horiz_freq;
69-#endif
7067 double frames_per_sec;
7168 int lines_per_frame;
7269
@@ -80,10 +77,16 @@ private:
8077 int dx, dy; // from ead, dad
8178 int dir, dif, sl, dc, d, d2, d1, dm;
8279 uint16_t pattern;
80+ const int vectdir[16][4] = {
81+ { 0, 1, 1, 0}, { 1, 1, 1,-1}, { 1, 0, 0,-1}, { 1,-1,-1,-1},
82+ { 0,-1,-1, 0}, {-1,-1,-1, 1}, {-1, 0, 0, 1}, {-1, 1, 1, 1},
83+ { 0, 1, 1, 1}, { 1, 1, 1, 0}, { 1, 0, 1,-1}, { 1,-1, 0,-1},
84+ { 0,-1,-1,-1}, {-1,-1,-1, 0}, {-1, 0,-1, 1}, {-1, 1, 0, 1}
85+ };
8386
8487 // command
85- void check_cmd();
86- void process_cmd();
88+ //void check_cmd();
89+ //void process_cmd();
8790
8891 void cmd_reset();
8992 void cmd_sync();
@@ -94,11 +97,11 @@ private:
9497 void cmd_zoom();
9598 void cmd_scroll();
9699 void cmd_csrform();
97- void cmd_pitch();
100+ //void cmd_pitch();
98101 void cmd_lpen();
99102 void cmd_vectw();
100- void cmd_vecte();
101- void cmd_texte();
103+ //void cmd_vecte();
104+ //void cmd_texte();
102105 void cmd_csrw();
103106 void cmd_csrr();
104107 void cmd_mask();
@@ -114,15 +117,10 @@ private:
114117 void update_vect();
115118 void reset_vect();
116119
117- void draw_vectl();
118- void draw_vectt();
119- void draw_vectc();
120- void draw_vectr();
121- void draw_text();
122- void draw_pset(int x, int y);
123-
120+ //virtual void draw_text();
121+ //virtual void draw_pset(int x, int y);
124122 public:
125- UPD7220(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
123+ UPD7220_BASE(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
126124 {
127125 initialize_output_signals(&outputs_drq);
128126 initialize_output_signals(&outputs_vsync);
@@ -131,23 +129,23 @@ public:
131129 vram_data_mask = 0xffff;
132130 set_device_name(_T("uPD7220 GDC"));
133131 }
134- ~UPD7220() {}
132+ ~UPD7220_BASE() {}
135133
136134 // common functions
137- void initialize();
135+ virtual void initialize();
138136 void release();
139137 void reset();
140138 void write_dma_io8(uint32_t addr, uint32_t data);
141139 uint32_t read_dma_io8(uint32_t addr);
142- void write_io8(uint32_t addr, uint32_t data);
140+ virtual void write_io8(uint32_t addr, uint32_t data);
143141 uint32_t read_io8(uint32_t addr);
144- void event_pre_frame();
142+ virtual void event_pre_frame();
145143 void event_frame();
146144 void event_vline(int v, int clock);
147145 void event_callback(int event_id, int err);
148146 void update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame);
149- void save_state(FILEIO* state_fio);
150- bool load_state(FILEIO* state_fio);
147+ virtual void save_state(FILEIO* state_fio) {}
148+ virtual bool load_state(FILEIO* state_fio) { return false; }
151149
152150 // unique functions
153151 void set_context_drq(DEVICE* device, int id, uint32_t mask)
@@ -169,12 +167,6 @@ public:
169167 vram_size = size;
170168 vram_data_mask = mask;
171169 }
172-#ifdef UPD7220_HORIZ_FREQ
173- void set_horiz_freq(int freq)
174- {
175- next_horiz_freq = freq;
176- }
177-#endif
178170 uint8_t* get_sync()
179171 {
180172 return sync;
@@ -208,5 +200,47 @@ public:
208200 }
209201 };
210202
203+
204+class UPD7220 : public UPD7220_BASE
205+{
206+private:
207+#ifdef UPD7220_HORIZ_FREQ
208+ int horiz_freq, next_horiz_freq;
209+#endif
210+private:
211+ void check_cmd();
212+ void process_cmd();
213+
214+ void draw_vectl();
215+ void draw_vectt();
216+ void draw_vectc();
217+ void draw_vectr();
218+
219+ void cmd_vecte();
220+ void cmd_texte();
221+ void cmd_pitch();
222+
223+ void draw_text();
224+ void draw_pset(int x, int y);
225+public:
226+ UPD7220(VM* parent_vm, EMU* parent_emu) : UPD7220_BASE(parent_vm, parent_emu)
227+ {
228+ }
229+ ~UPD7220() {}
230+ void initialize();
231+ void event_pre_frame();
232+ virtual void write_io8(uint32_t addr, uint32_t data);
233+
234+ void save_state(FILEIO* state_fio);
235+ bool load_state(FILEIO* state_fio);
236+
237+#ifdef UPD7220_HORIZ_FREQ
238+ void set_horiz_freq(int freq)
239+ {
240+ next_horiz_freq = freq;
241+ }
242+#endif
243+};
244+
211245 #endif
212246
--- /dev/null
+++ b/source/src/vm/upd7220_base.cpp
@@ -0,0 +1,518 @@
1+/*
2+ Skelton for retropc emulator
3+
4+ Origin : Neko Project 2
5+ Author : Takeda.Toshiya
6+ Date : 2006.12.06 -
7+
8+ [ uPD7220 ]
9+*/
10+
11+#include <math.h>
12+#include "upd7220.h"
13+#include "../fifo.h"
14+// -> See also: upd7220_base.cpp .
15+
16+
17+enum {
18+ STAT_DRDY = 0x01,
19+ STAT_FULL = 0x02,
20+ STAT_EMPTY = 0x04,
21+ STAT_DRAW = 0x08,
22+ STAT_DMA = 0x10,
23+ STAT_VSYNC = 0x20,
24+ STAT_HBLANK = 0x40,
25+ STAT_LPEN = 0x80,
26+};
27+
28+
29+void UPD7220_BASE::initialize()
30+{
31+ DEVICE::initialize();
32+ for(int i = 0; i <= RT_TABLEMAX; i++) {
33+ rt[i] = (int)((double)(1 << RT_MULBIT) * (1 - sqrt(1 - pow((0.70710678118654 * i) / RT_TABLEMAX, 2))));
34+ }
35+ fo = new FIFO(0x10000);
36+
37+ vsync = hblank = false;
38+ master = false;
39+ pitch = 40; // 640dot
40+
41+ // -> upd7220.cpp
42+}
43+
44+void UPD7220_BASE::release()
45+{
46+ fo->release();
47+ delete fo;
48+}
49+
50+void UPD7220_BASE::reset()
51+{
52+ cmd_reset();
53+}
54+
55+void UPD7220_BASE::write_dma_io8(uint32_t addr, uint32_t data)
56+{
57+ // for dma access
58+ switch(cmdreg & 0x18) {
59+ case 0x00: // low and high
60+ if(low_high) {
61+ cmd_write_sub(ead * 2 + 1, data & maskh);
62+ ead += dif;
63+ } else {
64+ cmd_write_sub(ead * 2 + 0, data & maskl);
65+ }
66+ low_high = !low_high;
67+ break;
68+ case 0x10: // low byte
69+ cmd_write_sub(ead * 2 + 0, data & maskl);
70+ ead += dif;
71+ break;
72+ case 0x18: // high byte
73+ cmd_write_sub(ead * 2 + 1, data & maskh);
74+ ead += dif;
75+ break;
76+ }
77+}
78+
79+uint32_t UPD7220_BASE::read_dma_io8(uint32_t addr)
80+{
81+ uint32_t val = 0xff;
82+
83+ // for dma access
84+ switch(cmdreg & 0x18) {
85+ case 0x00: // low and high
86+ if(low_high) {
87+ val = read_vram(ead * 2 + 1);
88+ ead += dif;
89+ } else {
90+ val = read_vram(ead * 2 + 0);
91+ }
92+ low_high = !low_high;
93+ break;
94+ case 0x10: // low byte
95+ val = read_vram(ead * 2 + 0);
96+ ead += dif;
97+ break;
98+ case 0x18: // high byte
99+ val = read_vram(ead * 2 + 1);
100+ ead += dif;
101+ break;
102+ }
103+ return val;
104+}
105+
106+void UPD7220_BASE::write_io8(uint32_t addr, uint32_t data)
107+{
108+ // Dummy function
109+}
110+
111+uint32_t UPD7220_BASE::read_io8(uint32_t addr)
112+{
113+ uint32_t val;
114+
115+ switch(addr & 3) {
116+ case 0: // status
117+ val = statreg;
118+ val |= hblank ? STAT_HBLANK : 0;
119+ val |= vsync ? STAT_VSYNC : 0;
120+// val |= (params_count == 0) ? STAT_EMPTY : 0;
121+ val |= STAT_EMPTY;
122+ val |= (params_count == 16) ? STAT_FULL : 0;
123+ val |= fo->count() ? STAT_DRDY : 0;
124+ // clear busy stat
125+ statreg &= ~(STAT_DMA | STAT_DRAW);
126+ return val;
127+ case 1: // data
128+ if(fo->count()) {
129+ return fo->read();
130+ }
131+ return 0xff;
132+ }
133+ return 0xff;
134+}
135+
136+void UPD7220_BASE::event_pre_frame()
137+{
138+ // Dummy func.
139+}
140+
141+void UPD7220_BASE::update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame)
142+{
143+ cpu_clocks = new_clocks;
144+ frames_per_sec = new_frames_per_sec; // note: refer these params given from the event manager
145+ lines_per_frame = new_lines_per_frame; // because this device may be slave gdc
146+
147+ // update event clocks
148+ vs = hc = 0;
149+}
150+
151+void UPD7220_BASE::event_frame()
152+{
153+ if(vs == 0) {
154+ vs = (int)((double)lines_per_frame * (double)v1 / (double)(v1 + v2) + 0.5);
155+ hc = (int)((double)cpu_clocks * (double)h2 / frames_per_sec / (double)lines_per_frame / (double)(h1 + h2) + 0.5);
156+ }
157+ if(++blink_cursor >= blink_rate * 4) {
158+ blink_cursor = 0;
159+ }
160+ if(++blink_attr >= blink_rate * 2) {
161+ blink_attr = 0;
162+ }
163+}
164+
165+void UPD7220_BASE::event_vline(int v, int clock)
166+{
167+ bool next = (v < vs);
168+ if(vsync != next) {
169+ write_signals(&outputs_vsync, next ? 0xffffffff : 0);
170+ vsync = next;
171+ }
172+ hblank = true;
173+ register_event_by_clock(this, 0, hc, false, NULL);
174+}
175+
176+void UPD7220_BASE::event_callback(int event_id, int err)
177+{
178+ hblank = false;
179+}
180+
181+uint32_t UPD7220_BASE::cursor_addr(uint32_t mask)
182+{
183+ if((cs[0] & 0x80) && ((cs[1] & 0x20) || (blink_cursor < blink_rate * 2))) {
184+ return (ead << 1) & mask;
185+ }
186+ return -1;
187+}
188+
189+int UPD7220_BASE::cursor_top()
190+{
191+ return cs[1] & 0x1f;
192+}
193+
194+int UPD7220_BASE::cursor_bottom()
195+{
196+ return cs[2] >> 3;
197+}
198+
199+// command process
200+
201+void UPD7220_BASE::cmd_reset()
202+{
203+ // init gdc params
204+ sync[6] = 0x90;
205+ sync[7] = 0x01;
206+ zoom = zr = zw = 0;
207+ ra[0] = ra[1] = ra[2] = 0;
208+ ra[3] = 0x1e; /*0x19;*/
209+ cs[0] = cs[1] = cs[2] = 0;
210+ ead = dad = 0;
211+ maskl = maskh = 0xff;
212+ mod = 0;
213+ blink_cursor = 0;
214+ blink_attr = 0;
215+ blink_rate = 16;
216+
217+ // init fifo
218+ params_count = 0;
219+ fo->clear();
220+
221+ // stop display and drawing
222+ start = false;
223+ statreg = 0;
224+ cmdreg = -1;
225+ cmd_write_done = false;
226+}
227+
228+void UPD7220_BASE::cmd_sync()
229+{
230+ start = ((cmdreg & 1) != 0);
231+ for(int i = 0; i < 8 && i < params_count; i++) {
232+ if(sync[i] != params[i]) {
233+ sync[i] = params[i];
234+ sync_changed = true;
235+ }
236+ }
237+ cmdreg = -1;
238+}
239+
240+void UPD7220_BASE::cmd_master()
241+{
242+ master = true;
243+ cmdreg = -1;
244+}
245+
246+void UPD7220_BASE::cmd_slave()
247+{
248+ master = false;
249+ cmdreg = -1;
250+}
251+
252+void UPD7220_BASE::cmd_start()
253+{
254+ start = true;
255+ cmdreg = -1;
256+}
257+
258+void UPD7220_BASE::cmd_stop()
259+{
260+ start = false;
261+ cmdreg = -1;
262+}
263+
264+void UPD7220_BASE::cmd_zoom()
265+{
266+ if(params_count > 0) {
267+ uint8_t tmp = params[0];
268+ zr = tmp >> 4;
269+ zw = tmp & 0x0f;
270+ cmdreg = -1;
271+ }
272+}
273+
274+void UPD7220_BASE::cmd_scroll()
275+{
276+ if(params_count > 0) {
277+ ra[cmdreg & 0x0f] = params[0];
278+ if(cmdreg < 0x7f) {
279+ cmdreg++;
280+ params_count = 0;
281+ } else {
282+ cmdreg = -1;
283+ }
284+ }
285+}
286+
287+void UPD7220_BASE::cmd_csrform()
288+{
289+ for(int i = 0; i < params_count; i++) {
290+ cs[i] = params[i];
291+ }
292+ if(params_count > 2) {
293+ cmdreg = -1;
294+ }
295+ blink_rate = (cs[1] >> 6) | ((cs[2] & 7) << 2);
296+}
297+
298+void UPD7220_BASE::cmd_lpen()
299+{
300+ fo->write(lad & 0xff);
301+ fo->write((lad >> 8) & 0xff);
302+ fo->write((lad >> 16) & 0xff);
303+ cmdreg = -1;
304+}
305+
306+void UPD7220_BASE::cmd_vectw()
307+{
308+ for(int i = 0; i < 11 && i < params_count; i++) {
309+ vect[i] = params[i];
310+// this->out_debug_log(_T("\tVECT[%d] = %2x\n"), i, vect[i]);
311+ }
312+ update_vect();
313+ cmdreg = -1;
314+}
315+
316+
317+void UPD7220_BASE::cmd_csrw()
318+{
319+ if(params_count > 0) {
320+ ead = params[0];
321+ if(params_count > 1) {
322+ ead |= params[1] << 8;
323+ if(params_count > 2) {
324+ ead |= params[2] << 16;
325+ cmdreg = -1;
326+ }
327+ }
328+ dad = (ead >> 20) & 0x0f;
329+ ead &= 0x3ffff;
330+ }
331+}
332+
333+void UPD7220_BASE::cmd_csrr()
334+{
335+ fo->write(ead & 0xff);
336+ fo->write((ead >> 8) & 0xff);
337+ fo->write((ead >> 16) & 0x03);
338+ fo->write(dad & 0xff);
339+ fo->write((dad >> 8) & 0xff);
340+ cmdreg = -1;
341+}
342+
343+void UPD7220_BASE::cmd_mask()
344+{
345+ if(params_count > 1) {
346+ maskl = params[0];
347+ maskh = params[1];
348+ cmdreg = -1;
349+ }
350+}
351+
352+void UPD7220_BASE::cmd_write()
353+{
354+ mod = cmdreg & 3;
355+ switch(cmdreg & 0x18) {
356+ case 0x00: // low and high
357+ if(params_count > 1) {
358+ uint8_t l = params[0] & maskl;
359+ uint8_t h = params[1] & maskh;
360+ for(int i = 0; i < dc + 1; i++) {
361+ cmd_write_sub(ead * 2 + 0, l);
362+ cmd_write_sub(ead * 2 + 1, h);
363+ ead += dif;
364+ }
365+ cmd_write_done = true;
366+ params_count = 0;
367+ }
368+ break;
369+ case 0x10: // low byte
370+ if(params_count > 0) {
371+ uint8_t l = params[0] & maskl;
372+ for(int i = 0; i < dc + 1; i++) {
373+ cmd_write_sub(ead * 2 + 0, l);
374+ ead += dif;
375+ }
376+ cmd_write_done = true;
377+ params_count = 0;
378+ }
379+ break;
380+ case 0x18: // high byte
381+ if(params_count > 0) {
382+ uint8_t h = params[0] & maskh;
383+ for(int i = 0; i < dc + 1; i++) {
384+ cmd_write_sub(ead * 2 + 1, h);
385+ ead += dif;
386+ }
387+ cmd_write_done = true;
388+ params_count = 0;
389+ }
390+ break;
391+ default: // invalid
392+ cmdreg = -1;
393+ break;
394+ }
395+}
396+
397+void UPD7220_BASE::cmd_read()
398+{
399+ mod = cmdreg & 3;
400+ switch(cmdreg & 0x18) {
401+ case 0x00: // low and high
402+ for(int i = 0; i < dc; i++) {
403+ fo->write(read_vram(ead * 2 + 0));
404+ fo->write(read_vram(ead * 2 + 1));
405+ ead += dif;
406+ }
407+ break;
408+ case 0x10: // low byte
409+ for(int i = 0; i < dc; i++) {
410+ fo->write(read_vram(ead * 2 + 0));
411+ ead += dif;
412+ }
413+ break;
414+ case 0x18: // high byte
415+ for(int i = 0; i < dc; i++) {
416+ fo->write(read_vram(ead * 2 + 1));
417+ ead += dif;
418+ }
419+ break;
420+ default: // invalid
421+ break;
422+ }
423+ reset_vect();
424+ cmdreg = -1;
425+}
426+
427+void UPD7220_BASE::cmd_dmaw()
428+{
429+ mod = cmdreg & 3;
430+ low_high = false;
431+ write_signals(&outputs_drq, 0xffffffff);
432+ reset_vect();
433+// statreg |= STAT_DMA;
434+ cmdreg = -1;
435+}
436+
437+void UPD7220_BASE::cmd_dmar()
438+{
439+ mod = cmdreg & 3;
440+ low_high = false;
441+ write_signals(&outputs_drq, 0xffffffff);
442+ reset_vect();
443+// statreg |= STAT_DMA;
444+ cmdreg = -1;
445+}
446+
447+void UPD7220_BASE::cmd_unk_5a()
448+{
449+ if(params_count > 2) {
450+ cmdreg = -1;
451+ }
452+}
453+
454+// command sub
455+
456+void UPD7220_BASE::cmd_write_sub(uint32_t addr, uint8_t data)
457+{
458+ switch(mod) {
459+ case 0: // replace
460+ write_vram(addr, data);
461+ break;
462+ case 1: // complement
463+ write_vram(addr, read_vram(addr) ^ data);
464+ break;
465+ case 2: // reset
466+ write_vram(addr, read_vram(addr) & ~data);
467+ break;
468+ case 3: // set
469+ write_vram(addr, read_vram(addr) | data);
470+ break;
471+ }
472+}
473+
474+void UPD7220_BASE::write_vram(uint32_t addr, uint8_t data)
475+{
476+ if(vram != NULL && addr < vram_size) {
477+ vram[addr] = data;
478+ }
479+}
480+
481+uint8_t UPD7220_BASE::read_vram(uint32_t addr)
482+{
483+ if(vram != NULL && addr < vram_size) {
484+ uint8_t mask = (addr & 1) ? (vram_data_mask >> 8) : (vram_data_mask & 0xff);
485+ return (vram[addr] & mask) | ~mask;
486+ }
487+ return 0xff;
488+}
489+
490+void UPD7220_BASE::update_vect()
491+{
492+ dir = vect[0] & 7;
493+ dif = vectdir[dir][0] + vectdir[dir][1] * pitch;
494+ sl = vect[0] & 0x80;
495+ dc = (vect[1] | (vect[ 2] << 8)) & 0x3fff;
496+ d = (vect[3] | (vect[ 4] << 8)) & 0x3fff;
497+ d2 = (vect[5] | (vect[ 6] << 8)) & 0x3fff;
498+ d1 = (vect[7] | (vect[ 8] << 8)) & 0x3fff;
499+ dm = (vect[9] | (vect[10] << 8)) & 0x3fff;
500+}
501+
502+void UPD7220_BASE::reset_vect()
503+{
504+ vect[ 1] = 0x00;
505+ vect[ 2] = 0x00;
506+ vect[ 3] = 0x08;
507+ vect[ 4] = 0x00;
508+ vect[ 5] = 0x08;
509+ vect[ 6] = 0x00;
510+ vect[ 7] = 0x00;
511+ vect[ 8] = 0x00;
512+ vect[ 9] = 0x00;
513+ vect[10] = 0x00;
514+ update_vect();
515+}
516+
517+
518+
--- a/source/src/vm/z80sio.cpp
+++ b/source/src/vm/z80sio.cpp
@@ -85,16 +85,23 @@
8585 void Z80SIO::initialize()
8686 {
8787 DEVICE::initialize();
88+ __HAS_UPD7201 = osd->check_feature(_T("HAS_UPD7201"));
89+ __SIO_DEBUG = osd->check_feature(_T("SIO_DEBUG"));
90+
8891 for(int ch = 0; ch < 2; ch++) {
89-#ifdef HAS_UPD7201
90- port[ch].send = new FIFO(16);
91- port[ch].recv = new FIFO(16);
92- port[ch].rtmp = new FIFO(16);
93-#else
94- port[ch].send = new FIFO(1);
95- port[ch].recv = new FIFO(4);
96- port[ch].rtmp = new FIFO(8);
97-#endif
92+//#ifdef HAS_UPD7201
93+ if(__HAS_UPD7201) {
94+ port[ch].send = new FIFO(16);
95+ port[ch].recv = new FIFO(16);
96+ port[ch].rtmp = new FIFO(16);
97+ } else {
98+//#else
99+ port[ch].send = new FIFO(1);
100+ port[ch].recv = new FIFO(4);
101+ port[ch].rtmp = new FIFO(8);
102+ port[ch].tx_count_hi = 0;
103+ }
104+//#endif
98105 // input signals
99106 port[ch].dcd = true;
100107 port[ch].cts = true;
@@ -112,9 +119,9 @@ void Z80SIO::reset()
112119 port[ch].over_flow = false;
113120 port[ch].under_run = false;
114121 port[ch].abort = false;
115-#ifdef HAS_UPD7201
122+//#ifdef HAS_UPD7201
116123 port[ch].tx_count = 0;
117-#endif
124+//#endif
118125 port[ch].send->clear();
119126 port[ch].recv->clear();
120127 port[ch].rtmp->clear();
@@ -201,20 +208,20 @@ void Z80SIO::write_io8(uint32_t addr, uint32_t data)
201208 } else {
202209 CANCEL_SEND_EVENT(ch);
203210 }
204-#ifndef HAS_UPD7201
205- port[ch].send->clear();
206-#endif
211+//#ifndef HAS_UPD7201
212+ if(!__HAS_UPD7201) port[ch].send->clear();
213+//#endif
207214 port[ch].send->write(data);
208-#ifdef HAS_UPD7201
209- port[ch].tx_count++;
210-#endif
215+//#ifdef HAS_UPD7201
216+ if(__HAS_UPD7201) port[ch].tx_count++;
217+//#endif
211218 break;
212219 case 1:
213220 case 3:
214221 // control
215-#ifdef SIO_DEBUG
216-// this->out_debug_log(_T("Z80SIO: ch=%d WR[%d]=%2x\n"), ch, port[ch].pointer, data);
217-#endif
222+//#ifdef SIO_DEBUG
223+// if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d WR[%d]=%2x\n"), ch, port[ch].pointer, data);
224+//#endif
218225 switch(port[ch].pointer) {
219226 case 0:
220227 switch(data & 0x38) {
@@ -231,9 +238,9 @@ void Z80SIO::write_io8(uint32_t addr, uint32_t data)
231238 port[ch].nextrecv_intr = false;
232239 port[ch].first_data = false;
233240 port[ch].over_flow = false;
234-#ifdef HAS_UPD7201
235- port[ch].tx_count = 0; // is this correct ???
236-#endif
241+//#ifdef HAS_UPD7201
242+ if(__HAS_UPD7201) port[ch].tx_count = 0; // is this correct ???
243+//#endif
237244 port[ch].send->clear();
238245 port[ch].recv->clear();
239246 port[ch].rtmp->clear();
@@ -316,14 +323,14 @@ void Z80SIO::write_io8(uint32_t addr, uint32_t data)
316323 if((data & 0x11) == 0x11) {
317324 // enter hunt/sync phase
318325 if(MONOSYNC(ch)) {
319-#ifdef SIO_DEBUG
320- this->out_debug_log(_T("Z80SIO: ch=%d enter hunt/sync phase (monosync)\n"), ch);
321-#endif
326+//#ifdef SIO_DEBUG
327+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d enter hunt/sync phase (monosync)\n"), ch);
328+//#endif
322329 port[ch].sync_bit = BIT_SYNC1;
323330 } else if(BISYNC(ch)) {
324-#ifdef SIO_DEBUG
325- this->out_debug_log(_T("Z80SIO: ch=%d enter hunt/sync phase (bisync)\n"), ch);
326-#endif
331+//#ifdef SIO_DEBUG
332+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d enter hunt/sync phase (bisync)\n"), ch);
333+//#endif
327334 port[ch].sync_bit = BIT_SYNC1 | BIT_SYNC2;
328335 }
329336 port[ch].sync = false;
@@ -434,14 +441,18 @@ uint32_t Z80SIO::read_io8(uint32_t addr)
434441 }
435442 } else if(port[ch].pointer == 2) {
436443 val = port[ch].vector;
437-#ifdef HAS_UPD7201
444+//#ifdef HAS_UPD7201
438445 } else if(port[ch].pointer == 3) {
439- val = port[ch].tx_count & 0xff;
440- port[ch].tx_count_hi = port[ch].tx_count >> 8;
446+ if(__HAS_UPD7201) {
447+ val = port[ch].tx_count & 0xff;
448+ port[ch].tx_count_hi = port[ch].tx_count >> 8;
449+ }
441450 } else if(port[ch].pointer == 4) {
451+ if(__HAS_UPD7201) {
442452 // val = (port[ch].tx_count >> 8) & 0xff;
443- val = port[ch].tx_count_hi;
444-#endif
453+ val = port[ch].tx_count_hi;
454+ }
455+//#endif
445456 }
446457 port[ch].pointer = 0;
447458 return val;
@@ -624,24 +635,24 @@ void Z80SIO::event_callback(int event_id, int err)
624635 if(data != port[ch].wr[6]) {
625636 goto request_next_data;
626637 }
627-#ifdef SIO_DEBUG
628- this->out_debug_log(_T("Z80SIO: ch=%d recv sync1\n"), ch);
629-#endif
638+//#ifdef SIO_DEBUG
639+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d recv sync1\n"), ch);
640+//#endif
630641 port[ch].sync_bit &= ~BIT_SYNC1;
631642 } else if(port[ch].sync_bit & BIT_SYNC2) {
632643 if(data != port[ch].wr[7]) {
633644 port[ch].sync_bit |= BIT_SYNC1;
634645 goto request_next_data;
635646 }
636-#ifdef SIO_DEBUG
637- this->out_debug_log(_T("Z80SIO: ch=%d recv sync2\n"), ch);
638-#endif
647+//#ifdef SIO_DEBUG
648+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d recv sync2\n"), ch);
649+//#endif
639650 port[ch].sync_bit &= ~BIT_SYNC2;
640651 }
641652 if(port[ch].sync_bit == 0) {
642-#ifdef SIO_DEBUG
643- this->out_debug_log(_T("Z80SIO: ch=%d leave hunt/sync phase\n"), ch);
644-#endif
653+//#ifdef SIO_DEBUG
654+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d leave hunt/sync phase\n"), ch);
655+//#endif
645656 if(!port[ch].stat_intr) {
646657 port[ch].stat_intr = true;
647658 update_intr_required = true;
@@ -655,9 +666,9 @@ void Z80SIO::event_callback(int event_id, int err)
655666 }
656667 }
657668 // load received data into buffer
658-#ifdef SIO_DEBUG
659- this->out_debug_log(_T("Z80SIO: ch=%d recv %2x\n"), ch, data);
660-#endif
669+//#ifdef SIO_DEBUG
670+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d recv %2x\n"), ch, data);
671+//#endif
661672 port[ch].recv->write(data);
662673
663674 // quit abort
@@ -691,9 +702,9 @@ request_next_data:
691702 }
692703 if(port[ch].rtmp->empty()) {
693704 // no data received
694-#ifdef SIO_DEBUG
695- this->out_debug_log(_T("Z80SIO: ch=%d end of block\n"), ch);
696-#endif
705+//#ifdef SIO_DEBUG
706+ if(__SIO_DEBUG) this->out_debug_log(_T("Z80SIO: ch=%d end of block\n"), ch);
707+//#endif
697708 port[ch].recv_id = -1;
698709 } else {
699710 REGISTER_RECV_EVENT(ch);
@@ -808,36 +819,39 @@ void Z80SIO::update_intr()
808819
809820 // create vector
810821 if(port[1].wr[1] & 4) {
811-#ifdef HAS_UPD7201
812- uint8_t affect = 7; // no interrupt pending
813- for(int ch = 0; ch < 2; ch++) {
814- if(port[ch].in_service) {
815- break;
822+//#ifdef HAS_UPD7201
823+ if(__HAS_UPD7201) {
824+ uint8_t affect = 7; // no interrupt pending
825+ for(int ch = 0; ch < 2; ch++) {
826+ if(port[ch].in_service) {
827+ break;
828+ }
829+ if(port[ch].req_intr) {
830+ affect = port[ch].affect;
831+ break;
832+ }
816833 }
817- if(port[ch].req_intr) {
818- affect = port[ch].affect;
819- break;
834+ uint8_t mode = port[0].wr[2] & 0x38;
835+ if(mode == 0 || mode == 8 || mode == 0x20 || mode == 0x28 || mode == 0x38) {
836+ port[1].vector = (port[1].wr[2] & 0xe3) | (affect << 2); // 8085
837+ } else {
838+ port[1].vector = (port[1].wr[2] & 0xf8) | (affect << 0); // 8086
820839 }
821- }
822- uint8_t mode = port[0].wr[2] & 0x38;
823- if(mode == 0 || mode == 8 || mode == 0x20 || mode == 0x28 || mode == 0x38) {
824- port[1].vector = (port[1].wr[2] & 0xe3) | (affect << 2); // 8085
825840 } else {
826- port[1].vector = (port[1].wr[2] & 0xf8) | (affect << 0); // 8086
827- }
828-#else
829- uint8_t affect = 3; // no interrupt pending
830- for(int ch = 0; ch < 2; ch++) {
831- if(port[ch].in_service) {
832- break;
833- }
834- if(port[ch].req_intr) {
835- affect = port[ch].affect;
836- break;
841+//#else
842+ uint8_t affect = 3; // no interrupt pending
843+ for(int ch = 0; ch < 2; ch++) {
844+ if(port[ch].in_service) {
845+ break;
846+ }
847+ if(port[ch].req_intr) {
848+ affect = port[ch].affect;
849+ break;
850+ }
837851 }
852+ port[1].vector = (port[1].wr[2] & 0xf1) | (affect << 1);
838853 }
839- port[1].vector = (port[1].wr[2] & 0xf1) | (affect << 1);
840-#endif
854+//#endif
841855 } else {
842856 port[1].vector = port[1].wr[2];
843857 }
@@ -928,10 +942,12 @@ void Z80SIO::save_state(FILEIO* state_fio)
928942 state_fio->FputBool(port[i].abort);
929943 state_fio->FputBool(port[i].sync);
930944 state_fio->FputUint8(port[i].sync_bit);
931-#ifdef HAS_UPD7201
932- state_fio->FputUint16(port[i].tx_count);
933- state_fio->FputUint8(port[i].tx_count_hi);
934-#endif
945+//#ifdef HAS_UPD7201
946+ if(__HAS_UPD7201) {
947+ state_fio->FputUint16(port[i].tx_count);
948+ state_fio->FputUint8(port[i].tx_count_hi);
949+ }
950+//#endif
935951 state_fio->FputDouble(port[i].tx_clock);
936952 state_fio->FputDouble(port[i].tx_interval);
937953 state_fio->FputDouble(port[i].rx_clock);
@@ -983,10 +999,12 @@ bool Z80SIO::load_state(FILEIO* state_fio)
983999 port[i].abort = state_fio->FgetBool();
9841000 port[i].sync = state_fio->FgetBool();
9851001 port[i].sync_bit = state_fio->FgetUint8();
986-#ifdef HAS_UPD7201
987- port[i].tx_count = state_fio->FgetUint16();
988- port[i].tx_count_hi = state_fio->FgetUint8();
989-#endif
1002+//#ifdef HAS_UPD7201
1003+ if(__HAS_UPD7201) {
1004+ port[i].tx_count = state_fio->FgetUint16();
1005+ port[i].tx_count_hi = state_fio->FgetUint8();
1006+ }
1007+//#endif
9901008 port[i].tx_clock = state_fio->FgetDouble();
9911009 port[i].tx_interval = state_fio->FgetDouble();
9921010 port[i].rx_clock = state_fio->FgetDouble();
--- a/source/src/vm/z80sio.h
+++ b/source/src/vm/z80sio.h
@@ -10,8 +10,8 @@
1010 #ifndef _Z80SIO_H_
1111 #define _Z80SIO_H_
1212
13-#include "vm.h"
14-#include "../emu.h"
13+//#include "vm.h"
14+//#include "../emu.h"
1515 #include "device.h"
1616
1717 #define SIG_Z80SIO_RECV_CH0 0
@@ -49,10 +49,10 @@ private:
4949 bool abort;
5050 bool sync;
5151 uint8_t sync_bit;
52-#ifdef HAS_UPD7201
52+//#ifdef HAS_UPD7201
5353 uint16_t tx_count;
5454 uint8_t tx_count_hi;
55-#endif
55+//#endif
5656 double tx_clock, tx_interval;
5757 double rx_clock, rx_interval;
5858 int tx_data_bits;
@@ -94,6 +94,9 @@ private:
9494 DEVICE *d_cpu, *d_child;
9595 bool iei, oei;
9696 uint32_t intr_bit;
97+
98+ bool __HAS_UPD7201;
99+ bool __SIO_DEBUG;
97100 void update_intr();
98101
99102 public:
@@ -113,6 +116,8 @@ public:
113116 initialize_output_signals(&port[i].outputs_rxdone);
114117 }
115118 d_cpu = d_child = NULL;
119+ __HAS_UPD7201 = false;
120+ __SIO_DEBUG = false;
116121 set_device_name(_T("Z80 SIO"));
117122 }
118123 ~Z80SIO() {}
Show on old repository browser