Add files using upload-large-folder tool
Browse files- snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/files.yaml +39 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/macros.def +49 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/mame2mra.toml +91 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/arkanoid2.cpp +242 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/seta001.cpp +502 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/seta001.h +91 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs.cpp +0 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs.h +302 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs_m.cpp +498 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/x1-007.v +39 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_colmix.v +140 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_draw.v +108 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_game.v +246 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_gfx.v +308 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_main.v +254 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_obj.v +172 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_snd.v +543 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_tilemap.v +180 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_video.v +187 -0
- snapshots/jotego_jtcores_pr1111/cores/kiwi/ver/extrm/sim.sh +34 -0
snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/files.yaml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kiwi:
|
| 2 |
+
- get:
|
| 3 |
+
- jtkiwi_game.v
|
| 4 |
+
- jtkiwi_main.v
|
| 5 |
+
- jtkiwi_video.v
|
| 6 |
+
- jtkiwi_colmix.v
|
| 7 |
+
- jtkiwi_snd.v
|
| 8 |
+
- jtkiwi_gfx.v
|
| 9 |
+
- jtkiwi_obj.v
|
| 10 |
+
- jtkiwi_draw.v
|
| 11 |
+
- jtkiwi_tilemap.v
|
| 12 |
+
jtframe:
|
| 13 |
+
- get:
|
| 14 |
+
- jtframe_ff.v
|
| 15 |
+
- jtframe_sort.v
|
| 16 |
+
- from: clocking
|
| 17 |
+
get:
|
| 18 |
+
- jtframe_cen48.v
|
| 19 |
+
- jtframe_cen24.v
|
| 20 |
+
- from: ram
|
| 21 |
+
get:
|
| 22 |
+
- jtframe_ram.v
|
| 23 |
+
- jtframe_dual_ram16.v
|
| 24 |
+
- jtframe_obj_buffer.v
|
| 25 |
+
- jtframe_prom.v
|
| 26 |
+
- from: video
|
| 27 |
+
get:
|
| 28 |
+
- jtframe_vtimer.v
|
| 29 |
+
- jtframe_blank.v
|
| 30 |
+
- from: cpu
|
| 31 |
+
get:
|
| 32 |
+
# Z80
|
| 33 |
+
- jtframe_z80.yaml
|
| 34 |
+
# MCU
|
| 35 |
+
- jtframe_i8742.v
|
| 36 |
+
- upi41.yaml
|
| 37 |
+
jt12:
|
| 38 |
+
- get:
|
| 39 |
+
- jt03.yaml
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/macros.def
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[*]
|
| 2 |
+
CORENAME=JTKIWI
|
| 3 |
+
|
| 4 |
+
# Controls
|
| 5 |
+
JTFRAME_BUTTONS=3
|
| 6 |
+
JTFRAME_JOY_DURL
|
| 7 |
+
JTFRAME_DIAL
|
| 8 |
+
JTFRAME_DIALEMU_LEFT=0
|
| 9 |
+
JTFRAME_NOMULTIWAY
|
| 10 |
+
|
| 11 |
+
# Extermination, Kageki, etc. are vertical games
|
| 12 |
+
JTFRAME_VERTICAL
|
| 13 |
+
JTFRAME_CREDITS_HIDEVERT
|
| 14 |
+
|
| 15 |
+
# ROM loading
|
| 16 |
+
BRAM_OFFSET=0x100000
|
| 17 |
+
JTFRAME_HEADER=4
|
| 18 |
+
JTFRAME_BA1_START=0x20000
|
| 19 |
+
JTFRAME_BA2_START=0x30000
|
| 20 |
+
PCM_START=0x40000
|
| 21 |
+
JTFRAME_BA3_START=0x50000
|
| 22 |
+
JTFRAME_PROM_START=0x250000
|
| 23 |
+
MCU_START=0x251000
|
| 24 |
+
|
| 25 |
+
# Video
|
| 26 |
+
JTFRAME_COLORW=5
|
| 27 |
+
JTFRAME_WIDTH=256
|
| 28 |
+
JTFRAME_HEIGHT=224
|
| 29 |
+
|
| 30 |
+
# Debug options
|
| 31 |
+
JTFRAME_STATUS
|
| 32 |
+
|
| 33 |
+
# Clocks
|
| 34 |
+
JTFRAME_PXLCLK=6
|
| 35 |
+
|
| 36 |
+
[mister]
|
| 37 |
+
JTFRAME_ARX=5
|
| 38 |
+
JTFRAME_ARY=4
|
| 39 |
+
CORE_OSD=OD,Button aid,Off,On
|
| 40 |
+
|
| 41 |
+
[mist]
|
| 42 |
+
-JTFRAME_CREDITS
|
| 43 |
+
NOCREDITS
|
| 44 |
+
JTFRAME_OSD_NOCREDITS
|
| 45 |
+
NOKABUKIZ
|
| 46 |
+
|
| 47 |
+
[sidi]
|
| 48 |
+
# does not fit any more
|
| 49 |
+
JTFRAME_SKIP
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/cfg/mame2mra.toml
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[global]
|
| 2 |
+
author=["jotego"]
|
| 3 |
+
platform="jtkiwi"
|
| 4 |
+
|
| 5 |
+
[parse]
|
| 6 |
+
sourcefile=[ "tnzs.cpp" ]
|
| 7 |
+
skip = { setnames = [
|
| 8 |
+
# Inputs not working
|
| 9 |
+
"plumppop", # most left column missing, see service screen
|
| 10 |
+
"chukatai", # top screen row missing for objects plus garbage at top left
|
| 11 |
+
"chukataij",
|
| 12 |
+
"chukataija",
|
| 13 |
+
"chukataiu",
|
| 14 |
+
|
| 15 |
+
# Korean hack on mostly unrelated hardware
|
| 16 |
+
"jpopnics",
|
| 17 |
+
]}
|
| 18 |
+
debug = { machine="kabukiz" }
|
| 19 |
+
|
| 20 |
+
[Audio]
|
| 21 |
+
volume = [
|
| 22 |
+
{ machine="arknoid2", value=0x93 },
|
| 23 |
+
{ machine="drtoppel", value=0x66 },
|
| 24 |
+
{ machine="extrmatn", value=0x71 },
|
| 25 |
+
{ machine="insectx", value=0xAD },
|
| 26 |
+
{ machine="kageki", value=0x86 },
|
| 27 |
+
{ machine="tnzs", value=0xFF },
|
| 28 |
+
{ machine="kabukiz", value=0xFF },
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
[header]
|
| 32 |
+
info="""bit 0 = MCU
|
| 33 |
+
bit 1 = color PROM
|
| 34 |
+
bit 2 = Kabuki Z (specific sound features)
|
| 35 |
+
bit 3 = Kageki (specific sound features)
|
| 36 |
+
bit 4 = banked RAM
|
| 37 |
+
bit 5 = coin XOR
|
| 38 |
+
bit 6 = dip_flip XOR
|
| 39 |
+
bit 7 = HB delay
|
| 40 |
+
Byte 1:
|
| 41 |
+
bit 0 = service XOR
|
| 42 |
+
bit 1 = button aid
|
| 43 |
+
bit 2 = 3 MHz for FM module
|
| 44 |
+
bit 3 = Kabuki Z with different memory map """
|
| 45 |
+
data=[
|
| 46 |
+
{ setnames=["tnzso","tnzsjo","tnzsoa","tnzsop","tnzsuo"], data="B1 04" }, # HB dly, Banked RAM, MCU, 3MHz FM
|
| 47 |
+
{ machines=["chukatai"], data="41" }, # MCU
|
| 48 |
+
{ machines=["insectx"], data="40" }, # dip_flip inversion
|
| 49 |
+
{ machines=["drtoppel"], data="03" },
|
| 50 |
+
{ machines=["extrmatn","plumppop" ], data="03" }, # MCU - Color PROM
|
| 51 |
+
{ machines=["arknoid2"], data="03 03" }, # MCU - Color PROM, Service XOR, Button aid
|
| 52 |
+
{ machine="kabukiz", data="14 04" }, # Kabuki Z sound subsystem, Banked RAM, 3MHz FM
|
| 53 |
+
{ setnames=["tnzs","tnzsj"], data="94 0C" }, # Kabuki Z sound subsystem (with mod), Banked RAM, 3MHz FM, HB dly
|
| 54 |
+
{ machine="kageki" , data="08" }, # Kageki sound subsystem
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
[buttons]
|
| 58 |
+
Names = [ { machine="insectx", names="Fire,Warp"},
|
| 59 |
+
{ machine="extrmatn", names="Fire,Warp"},
|
| 60 |
+
{ machine="tnzs", names="Shoot,Jump"},
|
| 61 |
+
{ machine="kabuki", names="Attack,Block"},
|
| 62 |
+
{ machine="kageki", names="Left jab,Right hook"},
|
| 63 |
+
{ machine="arknoid2", names="Shoot"},
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
[dipsw]
|
| 67 |
+
bitcnt = 16
|
| 68 |
+
delete=[{names=["Unused","Unknown"]}]
|
| 69 |
+
rename = [{ name="P1 & P2 Children Collision", to="P1/P2 Collision" }]
|
| 70 |
+
|
| 71 |
+
[ROM]
|
| 72 |
+
regions = [
|
| 73 |
+
{ name="maincpu", No_offset=true },
|
| 74 |
+
{ name="sub", start="JTFRAME_BA1_START" },
|
| 75 |
+
{ name="audiocpu", start="JTFRAME_BA2_START" },
|
| 76 |
+
{ name="samples", start="PCM_START" },
|
| 77 |
+
{ name="gfx1", start="JTFRAME_BA3_START", width=32, sequence=[2,0,3,1] },
|
| 78 |
+
{ machines=["kageki", "tnzs", "chukatai","drtoppel" ], name="gfx1", start="JTFRAME_BA3_START", width=32, sequence=[4,0,6,2, 5,1,7,3] },
|
| 79 |
+
{ machines=["plumppop"], name="gfx1", start="JTFRAME_BA3_START", width=32, sequence=[4,0,6,2, 4,0,6,2, 5,1,7,3, 5,1,7,3 ] },
|
| 80 |
+
{ machine="insectx", name="gfx1", start="JTFRAME_BA3_START", width=16, no_offset=true },
|
| 81 |
+
{ name="proms", start="JTFRAME_PROM_START", No_offset=true },
|
| 82 |
+
{ name="mcu", start="MCU_START", No_offset=true, len=0x800, custom={ dev="8042" } },
|
| 83 |
+
{ name="pal", skip=true },
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
order = [
|
| 87 |
+
"maincpu", "sub", "audiocpu", "samples",
|
| 88 |
+
"gfx1", "proms", "mcu"
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/arkanoid2.cpp
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 0;
|
| 10 |
+
m_mcu_coins_b = 0;
|
| 11 |
+
m_mcu_credits = 0;
|
| 12 |
+
m_mcu_reportcoin = 0;
|
| 13 |
+
m_mcu_command = 0;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
void arknoid2_state::mcu_handle_coins( int coin )
|
| 17 |
+
{
|
| 18 |
+
/* The coin inputs and coin counters are managed by the i8742 mcu. */
|
| 19 |
+
/* Here we simulate it. */
|
| 20 |
+
/* Credits are limited to 9, so more coins should be rejected */
|
| 21 |
+
/* Coin/Play settings must also be taken into consideration */
|
| 22 |
+
|
| 23 |
+
if (coin & 0x08) /* tilt */
|
| 24 |
+
m_mcu_reportcoin = coin;
|
| 25 |
+
else if (coin && coin != m_insertcoin)
|
| 26 |
+
{
|
| 27 |
+
if (coin & 0x01) /* coin A */
|
| 28 |
+
{
|
| 29 |
+
// logerror("Coin dropped into slot A\n");
|
| 30 |
+
machine().bookkeeping().coin_counter_w(0,1); machine().bookkeeping().coin_counter_w(0,0); /* Count slot A */
|
| 31 |
+
m_mcu_coins_a++;
|
| 32 |
+
if (m_mcu_coins_a >= m_mcu_coinage[0])
|
| 33 |
+
{
|
| 34 |
+
m_mcu_coins_a -= m_mcu_coinage[0];
|
| 35 |
+
m_mcu_credits += m_mcu_coinage[1];
|
| 36 |
+
if (m_mcu_credits >= 9)
|
| 37 |
+
{
|
| 38 |
+
m_mcu_credits = 9;
|
| 39 |
+
machine().bookkeeping().coin_lockout_global_w(1); /* Lock all coin slots */
|
| 40 |
+
}
|
| 41 |
+
else
|
| 42 |
+
{
|
| 43 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (coin & 0x02) /* coin B */
|
| 49 |
+
{
|
| 50 |
+
// logerror("Coin dropped into slot B\n");
|
| 51 |
+
machine().bookkeeping().coin_counter_w(1,1); machine().bookkeeping().coin_counter_w(1,0); /* Count slot B */
|
| 52 |
+
m_mcu_coins_b++;
|
| 53 |
+
if (m_mcu_coins_b >= m_mcu_coinage[2])
|
| 54 |
+
{
|
| 55 |
+
m_mcu_coins_b -= m_mcu_coinage[2];
|
| 56 |
+
m_mcu_credits += m_mcu_coinage[3];
|
| 57 |
+
if (m_mcu_credits >= 9)
|
| 58 |
+
{
|
| 59 |
+
m_mcu_credits = 9;
|
| 60 |
+
machine().bookkeeping().coin_lockout_global_w(1); /* Lock all coin slots */
|
| 61 |
+
}
|
| 62 |
+
else
|
| 63 |
+
{
|
| 64 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
if (coin & 0x04) /* service */
|
| 70 |
+
{
|
| 71 |
+
// logerror("Coin dropped into service slot C\n");
|
| 72 |
+
m_mcu_credits++;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
m_mcu_reportcoin = coin;
|
| 76 |
+
}
|
| 77 |
+
else
|
| 78 |
+
{
|
| 79 |
+
if (m_mcu_credits < 9)
|
| 80 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 81 |
+
|
| 82 |
+
m_mcu_reportcoin = 0;
|
| 83 |
+
}
|
| 84 |
+
m_insertcoin = coin;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
uint8_t arknoid2_state::mcu_r(offs_t offset)
|
| 88 |
+
{
|
| 89 |
+
static const char mcu_startup[] = "\x55\xaa\x5a";
|
| 90 |
+
|
| 91 |
+
//logerror("%s: read mcu %04x\n", m_maincpu->pc(), 0xc000 + offset);
|
| 92 |
+
|
| 93 |
+
if (offset == 0)
|
| 94 |
+
{
|
| 95 |
+
/* if the mcu has just been reset, return startup code */
|
| 96 |
+
if (m_mcu_initializing)
|
| 97 |
+
{
|
| 98 |
+
m_mcu_initializing--;
|
| 99 |
+
return mcu_startup[2 - m_mcu_initializing];
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
switch (m_mcu_command)
|
| 103 |
+
{
|
| 104 |
+
case 0x41:
|
| 105 |
+
return m_mcu_credits;
|
| 106 |
+
|
| 107 |
+
case 0xc1:
|
| 108 |
+
/* Read the credit counter or the inputs */
|
| 109 |
+
if (m_mcu_readcredits == 0)
|
| 110 |
+
{
|
| 111 |
+
m_mcu_readcredits = 1;
|
| 112 |
+
if (m_mcu_reportcoin & 0x08)
|
| 113 |
+
{
|
| 114 |
+
m_mcu_initializing = 3;
|
| 115 |
+
return 0xee; /* tilt */
|
| 116 |
+
}
|
| 117 |
+
else return m_mcu_credits;
|
| 118 |
+
}
|
| 119 |
+
else return m_in0->read(); /* buttons */
|
| 120 |
+
|
| 121 |
+
default:
|
| 122 |
+
logerror("error, unknown mcu command\n");
|
| 123 |
+
/* should not happen */
|
| 124 |
+
return 0xff;
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
else
|
| 128 |
+
{
|
| 129 |
+
/*
|
| 130 |
+
status bits:
|
| 131 |
+
0 = mcu is ready to send data (read from c000)
|
| 132 |
+
1 = mcu has read data (from c000)
|
| 133 |
+
2 = unused
|
| 134 |
+
3 = unused
|
| 135 |
+
4-7 = coin code
|
| 136 |
+
0 = nothing
|
| 137 |
+
1,2,3 = coin switch pressed
|
| 138 |
+
e = tilt
|
| 139 |
+
*/
|
| 140 |
+
if (m_mcu_reportcoin & 0x08) return 0xe1; /* tilt */
|
| 141 |
+
if (m_mcu_reportcoin & 0x01) return 0x11; /* coin 1 (will trigger "coin inserted" sound) */
|
| 142 |
+
if (m_mcu_reportcoin & 0x02) return 0x21; /* coin 2 (will trigger "coin inserted" sound) */
|
| 143 |
+
if (m_mcu_reportcoin & 0x04) return 0x31; /* coin 3 (will trigger "coin inserted" sound) */
|
| 144 |
+
return 0x01;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
void arknoid2_state::mcu_w(offs_t offset, uint8_t data)
|
| 149 |
+
{
|
| 150 |
+
if (offset == 0)
|
| 151 |
+
{
|
| 152 |
+
//logerror("%s: write %02x to mcu %04x\n", m_maincpu->pc(), data, 0xc000 + offset);
|
| 153 |
+
if (m_mcu_command == 0x41)
|
| 154 |
+
{
|
| 155 |
+
m_mcu_credits = (m_mcu_credits + data) & 0xff;
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
else
|
| 159 |
+
{
|
| 160 |
+
/*
|
| 161 |
+
0xc1: read number of credits, then buttons
|
| 162 |
+
0x54+0x41: add value to number of credits
|
| 163 |
+
0x15: sub 1 credit (when "Continue Play" only)
|
| 164 |
+
0x84: coin 1 lockout (issued only in test mode)
|
| 165 |
+
0x88: coin 2 lockout (issued only in test mode)
|
| 166 |
+
0x80: release coin lockout (issued only in test mode)
|
| 167 |
+
during initialization, a sequence of 4 bytes sets coin/credit settings
|
| 168 |
+
*/
|
| 169 |
+
//logerror("%s: write %02x to mcu %04x\n", m_maincpu->pc(), data, 0xc000 + offset);
|
| 170 |
+
|
| 171 |
+
if (m_mcu_initializing)
|
| 172 |
+
{
|
| 173 |
+
/* set up coin/credit settings */
|
| 174 |
+
m_mcu_coinage[m_mcu_coinage_init++] = data;
|
| 175 |
+
if (m_mcu_coinage_init == 4)
|
| 176 |
+
m_mcu_coinage_init = 0; /* must not happen */
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
if (data == 0xc1)
|
| 180 |
+
m_mcu_readcredits = 0; /* reset input port number */
|
| 181 |
+
|
| 182 |
+
if (data == 0x15)
|
| 183 |
+
{
|
| 184 |
+
m_mcu_credits = (m_mcu_credits - 1) & 0xff;
|
| 185 |
+
if (m_mcu_credits == 0xff)
|
| 186 |
+
m_mcu_credits = 0;
|
| 187 |
+
}
|
| 188 |
+
m_mcu_command = data;
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
INTERRUPT_GEN_MEMBER(arknoid2_state::mcu_interrupt)
|
| 193 |
+
{
|
| 194 |
+
int coin = ((m_coin1->read() & 1) << 0);
|
| 195 |
+
coin |= ((m_coin2->read() & 1) << 1);
|
| 196 |
+
coin |= ((m_in2->read() & 3) << 2);
|
| 197 |
+
coin ^= 0x0c;
|
| 198 |
+
mcu_handle_coins(coin);
|
| 199 |
+
|
| 200 |
+
device.execute().set_input_line(0, HOLD_LINE);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
void arknoid2_state::machine_reset()
|
| 204 |
+
{
|
| 205 |
+
/* initialize the mcu simulation */
|
| 206 |
+
mcu_reset();
|
| 207 |
+
|
| 208 |
+
m_mcu_readcredits = 0;
|
| 209 |
+
m_insertcoin = 0;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
void arknoid2_state::machine_start()
|
| 213 |
+
{
|
| 214 |
+
tnzs_base_state::machine_start();
|
| 215 |
+
|
| 216 |
+
save_item(NAME(m_mcu_readcredits));
|
| 217 |
+
save_item(NAME(m_insertcoin));
|
| 218 |
+
save_item(NAME(m_mcu_initializing));
|
| 219 |
+
save_item(NAME(m_mcu_coinage_init));
|
| 220 |
+
save_item(NAME(m_mcu_coinage));
|
| 221 |
+
save_item(NAME(m_mcu_coins_a));
|
| 222 |
+
save_item(NAME(m_mcu_coins_b));
|
| 223 |
+
save_item(NAME(m_mcu_credits));
|
| 224 |
+
save_item(NAME(m_mcu_reportcoin));
|
| 225 |
+
save_item(NAME(m_mcu_command));
|
| 226 |
+
|
| 227 |
+
// kludge to make device work with active-high coin inputs
|
| 228 |
+
m_upd4701->left_w(0);
|
| 229 |
+
m_upd4701->middle_w(0);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
void arknoid2_state::bankswitch1_w(uint8_t data)
|
| 233 |
+
{
|
| 234 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 235 |
+
|
| 236 |
+
if (BIT(data, 2))
|
| 237 |
+
mcu_reset();
|
| 238 |
+
|
| 239 |
+
// never actually written by arknoid2 (though code exists to do it)
|
| 240 |
+
m_upd4701->resetx_w(BIT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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// license:BSD-3-Clause
|
| 2 |
+
// copyright-holders:Luca Elia, David Haywood
|
| 3 |
+
/*
|
| 4 |
+
emulation of Seta sprite chips
|
| 5 |
+
X1-001A X1-002A (SDIP64)
|
| 6 |
+
|
| 7 |
+
these always seem to be used as a pair, some board have been seen without the
|
| 8 |
+
'A', so it's probably a chip revision / bugfix.
|
| 9 |
+
|
| 10 |
+
used by:
|
| 11 |
+
|
| 12 |
+
seta.cpp
|
| 13 |
+
taito_x.cpp
|
| 14 |
+
tnzs.cpp
|
| 15 |
+
srmp2.cpp
|
| 16 |
+
champbwl.cpp
|
| 17 |
+
cchance.cpp
|
| 18 |
+
thedealr.cpp
|
| 19 |
+
|
| 20 |
+
note: the data bus is almost certainly 8-bit, dating back to the earliest
|
| 21 |
+
hardware the games were used on. the RAM arrangements changes
|
| 22 |
+
slightly between games depending on how the RAM is hooked up to the
|
| 23 |
+
main cpu.
|
| 24 |
+
|
| 25 |
+
'y' low bits are NEVER buffered?
|
| 26 |
+
|
| 27 |
+
TODO:
|
| 28 |
+
use getter callbacks in drivers for spriterams rather than allocating memory
|
| 29 |
+
here, then we won't have to allocate extra memory for seta.cpp games which
|
| 30 |
+
appear to have 0x800 bytes of RAM that isn't connected to the sprite chip
|
| 31 |
+
between the banks.
|
| 32 |
+
|
| 33 |
+
This should implement device_video_interface, since it generates the vertical
|
| 34 |
+
and horizontal blanking and sync signals from a master clock.
|
| 35 |
+
|
| 36 |
+
understand sprite limits / how sprite 0 sometimes must be skipped, maybe
|
| 37 |
+
layers being enabled counts against limits? maybe some chip revisions skip
|
| 38 |
+
the first sprite? see note in device_start
|
| 39 |
+
|
| 40 |
+
understand why we need offset kludges for some games, they can even differ
|
| 41 |
+
from layer to layer
|
| 42 |
+
|
| 43 |
+
*/
|
| 44 |
+
|
| 45 |
+
#include "emu.h"
|
| 46 |
+
#include "seta001.h"
|
| 47 |
+
#include "screen.h"
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
DEFINE_DEVICE_TYPE(SETA001_SPRITE, seta001_device, "seta001", "Seta SETA001 Sprites")
|
| 51 |
+
|
| 52 |
+
seta001_device::seta001_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
| 53 |
+
: device_t(mconfig, SETA001_SPRITE, tag, owner, clock)
|
| 54 |
+
, device_gfx_interface(mconfig, *this)
|
| 55 |
+
, m_gfxbank_cb(*this)
|
| 56 |
+
, m_fg_flipxoffs(0)
|
| 57 |
+
, m_fg_noflipxoffs(0)
|
| 58 |
+
, m_fg_flipyoffs(0)
|
| 59 |
+
, m_fg_noflipyoffs(0)
|
| 60 |
+
, m_bg_flipyoffs(0)
|
| 61 |
+
, m_bg_noflipyoffs(0)
|
| 62 |
+
, m_bg_flipxoffs(0)
|
| 63 |
+
, m_bg_noflipxoffs(0)
|
| 64 |
+
, m_colorbase(0)
|
| 65 |
+
, m_spritelimit(0x1ff)
|
| 66 |
+
, m_transpen(0)
|
| 67 |
+
{
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
void seta001_device::device_start()
|
| 71 |
+
{
|
| 72 |
+
m_spriteylow = std::make_unique<uint8_t[]>(0x300); // 0x200 low y + 0x100 bg stuff
|
| 73 |
+
m_spritecodelow = std::make_unique<uint8_t[]>(0x2000);
|
| 74 |
+
m_spritecodehigh = std::make_unique<uint8_t[]>(0x2000);
|
| 75 |
+
|
| 76 |
+
/* chukatai draws a column on the left from uninitialized RAM which causes garbage
|
| 77 |
+
|
| 78 |
+
the reason for this is because the m_spriteylow only gets populated from 0x000 to 0x17d
|
| 79 |
+
with the remainder of the ram (0x17e - 0x1ff) never being written to.
|
| 80 |
+
|
| 81 |
+
If we initialize ram to 0xff it has a single line in the top left instead, but
|
| 82 |
+
the PCB has no error at all, initializing to 0xf8 is better, but unlikely from a hardware
|
| 83 |
+
perspective.
|
| 84 |
+
|
| 85 |
+
jjsquawk has a garbage tile in the bottom left instead, but in this case the entire
|
| 86 |
+
m_spriteylow is initalized (to 0), but sprite entry 0 for the other tables is never
|
| 87 |
+
written to, again meaning it picks up whatever we clear the RAM to as positional
|
| 88 |
+
values.
|
| 89 |
+
|
| 90 |
+
we can't simply skip sprite 0 as other games (mostly tnzs.cpp ones, eg. kabukiz) rely
|
| 91 |
+
on it being rendered, even if a number of seta.cpp games specifically avoid it.
|
| 92 |
+
|
| 93 |
+
maybe other components on the board determine the sprite start / end limits on a per
|
| 94 |
+
game basis?
|
| 95 |
+
|
| 96 |
+
*/
|
| 97 |
+
|
| 98 |
+
memset(m_spritectrl,0xff,4);
|
| 99 |
+
memset(m_spriteylow.get(),0xff,0x300);
|
| 100 |
+
memset(m_spritecodelow.get(),0xff,0x2000);
|
| 101 |
+
memset(m_spritecodehigh.get(),0xff,0x2000);
|
| 102 |
+
|
| 103 |
+
m_bgflag = 0x00;
|
| 104 |
+
|
| 105 |
+
m_gfxbank_cb.resolve();
|
| 106 |
+
|
| 107 |
+
save_item(NAME(m_bgflag));
|
| 108 |
+
save_item(NAME(m_spritectrl));
|
| 109 |
+
save_pointer(NAME(m_spriteylow),0x300);
|
| 110 |
+
save_pointer(NAME(m_spritecodelow),0x2000);
|
| 111 |
+
save_pointer(NAME(m_spritecodehigh),0x2000);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
void seta001_device::device_reset()
|
| 115 |
+
{
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
uint16_t seta001_device::spritectrl_r16(offs_t offset)
|
| 119 |
+
{
|
| 120 |
+
return m_spritectrl[offset];
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
void seta001_device::spritectrl_w16(offs_t offset, uint16_t data, uint16_t mem_mask)
|
| 124 |
+
{
|
| 125 |
+
if (ACCESSING_BITS_0_7)
|
| 126 |
+
{
|
| 127 |
+
m_spritectrl[offset] = data;
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
uint8_t seta001_device::spritectrl_r8(offs_t offset)
|
| 132 |
+
{
|
| 133 |
+
return m_spritectrl[offset];
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
void seta001_device::spritectrl_w8(offs_t offset, uint8_t data)
|
| 137 |
+
{
|
| 138 |
+
m_spritectrl[offset] = data;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
uint16_t seta001_device::spriteylow_r16(offs_t offset)
|
| 142 |
+
{
|
| 143 |
+
return m_spriteylow[offset];
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
void seta001_device::spriteylow_w16(offs_t offset, uint16_t data, uint16_t mem_mask)
|
| 147 |
+
{
|
| 148 |
+
if (ACCESSING_BITS_0_7)
|
| 149 |
+
{
|
| 150 |
+
m_spriteylow[offset] = data;
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
uint8_t seta001_device::spriteylow_r8(offs_t offset)
|
| 155 |
+
{
|
| 156 |
+
return m_spriteylow[offset];
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
void seta001_device::spriteylow_w8(offs_t offset, uint8_t data)
|
| 160 |
+
{
|
| 161 |
+
m_spriteylow[offset] = data;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
uint8_t seta001_device::spritecodelow_r8(offs_t offset)
|
| 166 |
+
{
|
| 167 |
+
return m_spritecodelow[offset];
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
void seta001_device::spritecodelow_w8(offs_t offset, uint8_t data)
|
| 171 |
+
{
|
| 172 |
+
m_spritecodelow[offset] = data;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
uint8_t seta001_device::spritecodehigh_r8(offs_t offset)
|
| 176 |
+
{
|
| 177 |
+
return m_spritecodehigh[offset];
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
void seta001_device::spritecodehigh_w8(offs_t offset, uint8_t data)
|
| 181 |
+
{
|
| 182 |
+
m_spritecodehigh[offset] = data;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
uint16_t seta001_device::spritecode_r16(offs_t offset)
|
| 186 |
+
{
|
| 187 |
+
uint16_t ret = m_spritecodelow[offset];
|
| 188 |
+
ret |= m_spritecodehigh[offset] << 8;
|
| 189 |
+
return ret;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
void seta001_device::spritecode_w16(offs_t offset, uint16_t data, uint16_t mem_mask)
|
| 193 |
+
{
|
| 194 |
+
if (ACCESSING_BITS_0_7) m_spritecodelow[offset] = data & 0x00ff;
|
| 195 |
+
if (ACCESSING_BITS_8_15) m_spritecodehigh[offset] = (data & 0xff00)>>8;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
void seta001_device::spritebgflag_w8(uint8_t data)
|
| 199 |
+
{
|
| 200 |
+
m_bgflag = data;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/***************************************************************************
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
Sprites Drawing
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
***************************************************************************/
|
| 210 |
+
|
| 211 |
+
/*
|
| 212 |
+
|
| 213 |
+
these mostly seem to be controlling the tilemap part of the chip
|
| 214 |
+
|
| 215 |
+
twineagl: 10 2d 0f 10 (ship)
|
| 216 |
+
tndrcade: 58 2d 07 18 (start of game - yes, flip on!)
|
| 217 |
+
arbalest: 18 2d 0f 10 (logo)
|
| 218 |
+
metafox : 18 21 0f f0 (bomb)
|
| 219 |
+
zingzip : 10 2c 00 0f (bomb)
|
| 220 |
+
wrofaero: 10 21 00 ff (test mode)
|
| 221 |
+
thunderl: 10 6c 00 ff (always?)
|
| 222 |
+
krzybowl: 11 28 c0 ff (game)
|
| 223 |
+
kiwame : 16 21 7f 00 (logo)
|
| 224 |
+
oisipuzl: 59 20 00 00 (game - yes, flip on!)
|
| 225 |
+
superman: 10 21 07 38 (game)
|
| 226 |
+
twineagl: 00 27 00 0f (test mode)
|
| 227 |
+
doraemon: 19 2a 00 03 (always)
|
| 228 |
+
srmp2: 1e 20 xx xx
|
| 229 |
+
tnzs: 1a 20 xx xx
|
| 230 |
+
|
| 231 |
+
format
|
| 232 |
+
byte 0 byte 1 byte 2 byte3
|
| 233 |
+
-f-e uUss -Bb- cccc ---- ---- ---- ----
|
| 234 |
+
|
| 235 |
+
f = flipy
|
| 236 |
+
e = possible enable (only disabled in twineagl test mode? check if it needs sprites)
|
| 237 |
+
u = sometimes set
|
| 238 |
+
U = sometimes set (srmp2)
|
| 239 |
+
s = start column
|
| 240 |
+
B = buffering control - toggles often (kabukiz doesn't seem to use these like the other games)
|
| 241 |
+
b = buffering control
|
| 242 |
+
c = number of columns, 0x0 = disabled, 0x01 = 16 columns 0x2 = 2 coluns ... 0xf = 15 columns
|
| 243 |
+
|
| 244 |
+
bytes 2 and 3 get set in a bitwize way in the tnzs driver games while horizontal scrolling happens, dependong on how
|
| 245 |
+
far we've scrolled, what they actually do is unclear.
|
| 246 |
+
|
| 247 |
+
*/
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
void seta001_device::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size)
|
| 253 |
+
{
|
| 254 |
+
int transpen;
|
| 255 |
+
|
| 256 |
+
int offs, col;
|
| 257 |
+
int xoffs, yoffs;
|
| 258 |
+
|
| 259 |
+
int const total_color_codes = gfx(0)->colors();
|
| 260 |
+
|
| 261 |
+
int const ctrl = m_spritectrl[0];
|
| 262 |
+
int const ctrl2 = m_spritectrl[1];
|
| 263 |
+
|
| 264 |
+
bool const flip = BIT(ctrl, 6);
|
| 265 |
+
int numcol = ctrl2 & 0x0f;
|
| 266 |
+
|
| 267 |
+
int scrollx, scrolly;
|
| 268 |
+
|
| 269 |
+
uint32_t upper;
|
| 270 |
+
|
| 271 |
+
const uint8_t* scrollram = &m_spriteylow[0x200];
|
| 272 |
+
|
| 273 |
+
/* Sprites Banking and/or Sprites Buffering */
|
| 274 |
+
uint16_t bank = ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? bank_size : 0 ); // bank_size = 0x800
|
| 275 |
+
|
| 276 |
+
int const max_y = 0xf0;
|
| 277 |
+
|
| 278 |
+
int startcol = 0;
|
| 279 |
+
|
| 280 |
+
if (ctrl & 0x01)
|
| 281 |
+
startcol += 0x4;
|
| 282 |
+
|
| 283 |
+
if (ctrl & 0x02)
|
| 284 |
+
startcol += 0x8;
|
| 285 |
+
|
| 286 |
+
xoffs = flip ? m_bg_flipxoffs : m_bg_noflipxoffs;
|
| 287 |
+
yoffs = flip ? m_bg_flipyoffs : m_bg_noflipyoffs;
|
| 288 |
+
|
| 289 |
+
if (m_bgflag & 0x80)
|
| 290 |
+
transpen = -1;
|
| 291 |
+
else
|
| 292 |
+
transpen = m_transpen;
|
| 293 |
+
|
| 294 |
+
if (numcol == 1)
|
| 295 |
+
numcol = 16;
|
| 296 |
+
|
| 297 |
+
upper = m_spritectrl[2] + m_spritectrl[3] * 256;
|
| 298 |
+
|
| 299 |
+
for (col = 0; col < numcol; col++)
|
| 300 |
+
{
|
| 301 |
+
scrollx = scrollram[col * 0x10 + 4];
|
| 302 |
+
scrolly = scrollram[col * 0x10];
|
| 303 |
+
|
| 304 |
+
/* draw this column */
|
| 305 |
+
for ( offs = 0 ; offs < 0x20; offs += 1 )
|
| 306 |
+
{
|
| 307 |
+
int i = ((col+startcol)&0xf) * 32 + offs;
|
| 308 |
+
|
| 309 |
+
int code = ((m_spritecodehigh[i+0x400+bank]) << 8) | m_spritecodelow[i+0x400+bank];
|
| 310 |
+
int color =((m_spritecodehigh[i+0x600+bank]) << 8) | m_spritecodelow[i+0x600+bank];
|
| 311 |
+
|
| 312 |
+
int flipx = code & 0x8000;
|
| 313 |
+
int flipy = code & 0x4000;
|
| 314 |
+
|
| 315 |
+
int sx = scrollx + xoffs + (offs & 1) * 16;
|
| 316 |
+
int sy = -(scrolly + yoffs) + (offs / 2) * 16;
|
| 317 |
+
|
| 318 |
+
if (upper & (1 << col)) sx -= 256;
|
| 319 |
+
|
| 320 |
+
if (flip)
|
| 321 |
+
{
|
| 322 |
+
sy = max_y - sy;
|
| 323 |
+
flipx = !flipx;
|
| 324 |
+
flipy = !flipy;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
color = ( color >> (16-5) ) % total_color_codes;
|
| 328 |
+
code &= 0x3fff;
|
| 329 |
+
|
| 330 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 331 |
+
code,
|
| 332 |
+
color,
|
| 333 |
+
flipx,flipy,
|
| 334 |
+
((sx) & 0x1ff),((sy) & 0x0ff),
|
| 335 |
+
transpen);
|
| 336 |
+
|
| 337 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 338 |
+
code,
|
| 339 |
+
color,
|
| 340 |
+
flipx,flipy,
|
| 341 |
+
((sx) & 0x1ff)-512,((sy) & 0x0ff),
|
| 342 |
+
transpen);
|
| 343 |
+
|
| 344 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 345 |
+
code,
|
| 346 |
+
color,
|
| 347 |
+
flipx,flipy,
|
| 348 |
+
((sx) & 0x1ff),((sy) & 0x0ff)-256,
|
| 349 |
+
transpen);
|
| 350 |
+
|
| 351 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 352 |
+
code,
|
| 353 |
+
color,
|
| 354 |
+
flipx,flipy,
|
| 355 |
+
((sx) & 0x1ff)-512,((sy) & 0x0ff)-256,
|
| 356 |
+
transpen);
|
| 357 |
+
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
void seta001_device::draw_foreground( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size)
|
| 364 |
+
{
|
| 365 |
+
int const screenflip = (m_spritectrl[0] & 0x40) >> 6;
|
| 366 |
+
int const ctrl2 = m_spritectrl[1];
|
| 367 |
+
|
| 368 |
+
int const total_color_codes = gfx(0)->colors();
|
| 369 |
+
|
| 370 |
+
uint8_t *char_pointer = &m_spritecodelow[0x0000];
|
| 371 |
+
uint8_t *ctrl_pointer = &m_spritecodehigh[0x0000];
|
| 372 |
+
uint8_t *x_pointer = &m_spritecodelow[0x0200];
|
| 373 |
+
uint8_t *color_pointer = &m_spritecodehigh[0x0200];
|
| 374 |
+
|
| 375 |
+
// note that drgnunit, stg and qzkklogy run on the same board, yet they need different alignment
|
| 376 |
+
int xoffs = screenflip ? m_fg_flipxoffs : m_fg_noflipxoffs;
|
| 377 |
+
int yoffs = screenflip ? m_fg_flipyoffs : m_fg_noflipyoffs;
|
| 378 |
+
|
| 379 |
+
if ((ctrl2 ^ (~ctrl2 << 1)) & 0x40)
|
| 380 |
+
{
|
| 381 |
+
char_pointer += bank_size;
|
| 382 |
+
x_pointer += bank_size;
|
| 383 |
+
ctrl_pointer += bank_size;
|
| 384 |
+
color_pointer += bank_size;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
int const max_y = screen.height();
|
| 388 |
+
|
| 389 |
+
/* Draw up to 512 sprites, mjyuugi has glitches if you draw them all.. */
|
| 390 |
+
for (int i = m_spritelimit; i >= 0; i--)
|
| 391 |
+
{
|
| 392 |
+
int code, color, sx, sy, flipx, flipy;
|
| 393 |
+
|
| 394 |
+
code = char_pointer[i] + ((ctrl_pointer[i] & 0x3f) << 8);
|
| 395 |
+
color = (color_pointer[i] & 0xf8) >> 3;
|
| 396 |
+
|
| 397 |
+
sx = x_pointer[i] - ((color_pointer[i] & 1) << 8);
|
| 398 |
+
sy = (m_spriteylow[i] & 0xff);
|
| 399 |
+
flipx = ctrl_pointer[i] & 0x80;
|
| 400 |
+
flipy = ctrl_pointer[i] & 0x40;
|
| 401 |
+
|
| 402 |
+
if (!m_gfxbank_cb.isnull()) code = m_gfxbank_cb(code, color_pointer[i]);
|
| 403 |
+
|
| 404 |
+
color %= total_color_codes;
|
| 405 |
+
|
| 406 |
+
color += m_colorbase;
|
| 407 |
+
|
| 408 |
+
if (screenflip)
|
| 409 |
+
{
|
| 410 |
+
sy = max_y - sy
|
| 411 |
+
+(screen.height() - (screen.visible_area().max_y + 1));
|
| 412 |
+
flipx = !flipx;
|
| 413 |
+
flipy = !flipy;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 417 |
+
code,
|
| 418 |
+
color,
|
| 419 |
+
flipx,flipy,
|
| 420 |
+
((sx + xoffs)&0x1ff),
|
| 421 |
+
max_y - ((sy + yoffs) & 0x0ff),m_transpen);
|
| 422 |
+
|
| 423 |
+
/* wrap around x */
|
| 424 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 425 |
+
code,
|
| 426 |
+
color,
|
| 427 |
+
flipx,flipy,
|
| 428 |
+
((sx + xoffs)&0x1ff) - 512,
|
| 429 |
+
max_y - ((sy + yoffs) & 0x0ff),m_transpen);
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 433 |
+
code,
|
| 434 |
+
color,
|
| 435 |
+
flipx,flipy,
|
| 436 |
+
((sx + xoffs)&0x1ff),
|
| 437 |
+
max_y - ((sy + yoffs) & 0x0ff)-256,m_transpen);
|
| 438 |
+
|
| 439 |
+
/* wrap around x */
|
| 440 |
+
gfx(0)->transpen(bitmap,cliprect,
|
| 441 |
+
code,
|
| 442 |
+
color,
|
| 443 |
+
flipx,flipy,
|
| 444 |
+
((sx + xoffs)&0x1ff) - 512,
|
| 445 |
+
max_y - ((sy + yoffs) & 0x0ff)-256,m_transpen);
|
| 446 |
+
|
| 447 |
+
}
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
void seta001_device::setac_eof()
|
| 453 |
+
{
|
| 454 |
+
// is this handling right?
|
| 455 |
+
// it differs to tnzs, and thundercade has sprite flickering issues (not related to the devicification)
|
| 456 |
+
|
| 457 |
+
int const ctrl2 = m_spritectrl[1];
|
| 458 |
+
|
| 459 |
+
if (~ctrl2 & 0x20)
|
| 460 |
+
{
|
| 461 |
+
if (ctrl2 & 0x40)
|
| 462 |
+
{
|
| 463 |
+
memcpy( &m_spritecodelow[0x0000], &m_spritecodelow[0x1000],0x800);
|
| 464 |
+
memcpy(&m_spritecodehigh[0x0000],&m_spritecodehigh[0x1000],0x800);
|
| 465 |
+
}
|
| 466 |
+
else
|
| 467 |
+
{
|
| 468 |
+
memcpy( &m_spritecodelow[0x1000], &m_spritecodelow[0x0000],0x800);
|
| 469 |
+
memcpy(&m_spritecodehigh[0x1000],&m_spritecodehigh[0x0000],0x800);
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
void seta001_device::tnzs_eof( void )
|
| 475 |
+
{
|
| 476 |
+
int const ctrl2 = m_spritectrl[1];
|
| 477 |
+
if (~ctrl2 & 0x20)
|
| 478 |
+
{
|
| 479 |
+
// note I copy sprites only. setac implementation also copies the "floating tilemap"
|
| 480 |
+
if (ctrl2 & 0x40)
|
| 481 |
+
{
|
| 482 |
+
memcpy( &m_spritecodelow[0x0000], &m_spritecodelow[0x0800], 0x0400);
|
| 483 |
+
memcpy(&m_spritecodehigh[0x0000], &m_spritecodehigh[0x0800], 0x0400);
|
| 484 |
+
}
|
| 485 |
+
else
|
| 486 |
+
{
|
| 487 |
+
memcpy( &m_spritecodelow[0x0800], &m_spritecodelow[0x0000], 0x0400);
|
| 488 |
+
memcpy(&m_spritecodehigh[0x0800], &m_spritecodehigh[0x0000], 0x0400);
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
// and I copy the "floating tilemap" BACKWARDS - this fixes kabukiz
|
| 492 |
+
memcpy( &m_spritecodelow[0x0400], &m_spritecodelow[0x0c00], 0x0400);
|
| 493 |
+
memcpy(&m_spritecodehigh[0x0400], &m_spritecodehigh[0x0c00], 0x0400);
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
void seta001_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size)
|
| 499 |
+
{
|
| 500 |
+
draw_background(bitmap, cliprect, bank_size);
|
| 501 |
+
draw_foreground(screen, bitmap, cliprect, bank_size);
|
| 502 |
+
}
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/seta001.h
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// license:BSD-3-Clause
|
| 2 |
+
// copyright-holders:Luca Elia, David Haywood
|
| 3 |
+
#ifndef MAME_VIDEO_SETA001_H
|
| 4 |
+
#define MAME_VIDEO_SETA001_H
|
| 5 |
+
|
| 6 |
+
#pragma once
|
| 7 |
+
|
| 8 |
+
typedef device_delegate<int (uint16_t code, uint8_t color)> gfxbank_cb_delegate;
|
| 9 |
+
|
| 10 |
+
#define SETA001_SPRITE_GFXBANK_CB_MEMBER(_name) int _name(uint16_t code, uint8_t color)
|
| 11 |
+
|
| 12 |
+
class seta001_device : public device_t, public device_gfx_interface
|
| 13 |
+
{
|
| 14 |
+
public:
|
| 15 |
+
seta001_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
| 16 |
+
template <typename T> seta001_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&palette_tag, const gfx_decode_entry *gfxinfo)
|
| 17 |
+
: seta001_device(mconfig, tag, owner, clock)
|
| 18 |
+
{
|
| 19 |
+
set_info(gfxinfo);
|
| 20 |
+
set_palette(std::forward<T>(palette_tag));
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// configuration
|
| 24 |
+
template <typename... T> void set_gfxbank_callback(T &&... args) { m_gfxbank_cb.set(std::forward<T>(args)...); }
|
| 25 |
+
|
| 26 |
+
void spritebgflag_w8(uint8_t data);
|
| 27 |
+
|
| 28 |
+
uint16_t spritectrl_r16(offs_t offset);
|
| 29 |
+
void spritectrl_w16(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
|
| 30 |
+
uint8_t spritectrl_r8(offs_t offset);
|
| 31 |
+
void spritectrl_w8(offs_t offset, uint8_t data);
|
| 32 |
+
|
| 33 |
+
uint16_t spriteylow_r16(offs_t offset);
|
| 34 |
+
void spriteylow_w16(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
|
| 35 |
+
uint8_t spriteylow_r8(offs_t offset);
|
| 36 |
+
void spriteylow_w8(offs_t offset, uint8_t data);
|
| 37 |
+
|
| 38 |
+
uint8_t spritecodelow_r8(offs_t offset);
|
| 39 |
+
void spritecodelow_w8(offs_t offset, uint8_t data);
|
| 40 |
+
uint8_t spritecodehigh_r8(offs_t offset);
|
| 41 |
+
void spritecodehigh_w8(offs_t offset, uint8_t data);
|
| 42 |
+
uint16_t spritecode_r16(offs_t offset);
|
| 43 |
+
void spritecode_w16(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
|
| 44 |
+
|
| 45 |
+
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size);
|
| 46 |
+
|
| 47 |
+
void setac_eof();
|
| 48 |
+
void tnzs_eof();
|
| 49 |
+
|
| 50 |
+
// position kludges for seta.cpp & srmp2.cpp
|
| 51 |
+
void set_fg_xoffsets(int flip, int noflip) { m_fg_flipxoffs = flip; m_fg_noflipxoffs = noflip; }
|
| 52 |
+
void set_fg_yoffsets(int flip, int noflip) { m_fg_flipyoffs = flip; m_fg_noflipyoffs = noflip; }
|
| 53 |
+
void set_bg_yoffsets(int flip, int noflip) { m_bg_flipyoffs = flip; m_bg_noflipyoffs = noflip; }
|
| 54 |
+
void set_bg_xoffsets(int flip, int noflip) { m_bg_flipxoffs = flip; m_bg_noflipxoffs = noflip; }
|
| 55 |
+
|
| 56 |
+
void set_colorbase(int base) { m_colorbase = base; }
|
| 57 |
+
void set_spritelimit(int limit) { m_spritelimit = limit; }
|
| 58 |
+
void set_transpen(int pen) { m_transpen = pen; }
|
| 59 |
+
|
| 60 |
+
int is_flipped() { return ((m_spritectrl[ 0 ] & 0x40) >> 6); }
|
| 61 |
+
|
| 62 |
+
protected:
|
| 63 |
+
virtual void device_start() override;
|
| 64 |
+
virtual void device_reset() override;
|
| 65 |
+
|
| 66 |
+
private:
|
| 67 |
+
void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size);
|
| 68 |
+
void draw_foreground(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank_size);
|
| 69 |
+
|
| 70 |
+
gfxbank_cb_delegate m_gfxbank_cb;
|
| 71 |
+
|
| 72 |
+
// configuration
|
| 73 |
+
int m_fg_flipxoffs, m_fg_noflipxoffs;
|
| 74 |
+
int m_fg_flipyoffs, m_fg_noflipyoffs;
|
| 75 |
+
int m_bg_flipyoffs, m_bg_noflipyoffs;
|
| 76 |
+
int m_bg_flipxoffs, m_bg_noflipxoffs;
|
| 77 |
+
int m_colorbase;
|
| 78 |
+
int m_spritelimit;
|
| 79 |
+
int m_transpen;
|
| 80 |
+
|
| 81 |
+
// live state
|
| 82 |
+
uint8_t m_bgflag = 0;
|
| 83 |
+
uint8_t m_spritectrl[4];
|
| 84 |
+
std::unique_ptr<uint8_t[]> m_spriteylow;
|
| 85 |
+
std::unique_ptr<uint8_t[]> m_spritecodelow; // tnzs.cpp stuff only uses half?
|
| 86 |
+
std::unique_ptr<uint8_t[]> m_spritecodehigh; // ^
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
DECLARE_DEVICE_TYPE(SETA001_SPRITE, seta001_device)
|
| 90 |
+
|
| 91 |
+
#endif // MAME_VIDEO_SETA001_H
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs.cpp
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs.h
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// license:BSD-3-Clause
|
| 2 |
+
// copyright-holders:Luca Elia, Mirko Buffoni, Takahiro Nogi
|
| 3 |
+
#ifndef MAME_INCLUDES_TNZS_H
|
| 4 |
+
#define MAME_INCLUDES_TNZS_H
|
| 5 |
+
|
| 6 |
+
#pragma once
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
#include "cpu/mcs48/mcs48.h"
|
| 10 |
+
#include "machine/bankdev.h"
|
| 11 |
+
#include "machine/gen_latch.h"
|
| 12 |
+
#include "machine/upd4701.h"
|
| 13 |
+
#include "sound/dac.h"
|
| 14 |
+
#include "sound/samples.h"
|
| 15 |
+
#include "video/seta001.h"
|
| 16 |
+
#include "emupal.h"
|
| 17 |
+
#include "screen.h"
|
| 18 |
+
|
| 19 |
+
class tnzs_base_state : public driver_device
|
| 20 |
+
{
|
| 21 |
+
public:
|
| 22 |
+
tnzs_base_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 23 |
+
: driver_device(mconfig, type, tag)
|
| 24 |
+
, m_maincpu(*this, "maincpu")
|
| 25 |
+
, m_subcpu(*this, "sub")
|
| 26 |
+
, m_seta001(*this, "spritegen")
|
| 27 |
+
, m_palette(*this, "palette")
|
| 28 |
+
, m_screen(*this, "screen")
|
| 29 |
+
, m_mainbank(*this, "mainbank")
|
| 30 |
+
, m_subbank(*this, "subbank")
|
| 31 |
+
{ }
|
| 32 |
+
|
| 33 |
+
void tnzs_base(machine_config &config);
|
| 34 |
+
void tnzs_mainbank(machine_config &config);
|
| 35 |
+
|
| 36 |
+
protected:
|
| 37 |
+
virtual void machine_start() override;
|
| 38 |
+
|
| 39 |
+
virtual void bankswitch1_w(uint8_t data);
|
| 40 |
+
|
| 41 |
+
void ramrom_bankswitch_w(uint8_t data);
|
| 42 |
+
|
| 43 |
+
void prompalette(palette_device &palette) const;
|
| 44 |
+
uint32_t screen_update_tnzs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
| 45 |
+
DECLARE_WRITE_LINE_MEMBER(screen_vblank_tnzs);
|
| 46 |
+
|
| 47 |
+
void base_sub_map(address_map &map);
|
| 48 |
+
void main_map(address_map &map);
|
| 49 |
+
void mainbank_map(address_map &map);
|
| 50 |
+
|
| 51 |
+
/* devices */
|
| 52 |
+
required_device<cpu_device> m_maincpu;
|
| 53 |
+
optional_device<cpu_device> m_subcpu;
|
| 54 |
+
required_device<seta001_device> m_seta001;
|
| 55 |
+
required_device<palette_device> m_palette;
|
| 56 |
+
required_device<screen_device> m_screen;
|
| 57 |
+
optional_device<address_map_bank_device> m_mainbank; /* FIXME: optional because of reuse from cchance.cpp */
|
| 58 |
+
optional_memory_bank m_subbank; /* FIXME: optional because of reuse from cchance.cpp */
|
| 59 |
+
|
| 60 |
+
/* misc / mcu */
|
| 61 |
+
int m_bank2 = 0;
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
class tnzs_mcu_state : public tnzs_base_state
|
| 65 |
+
{
|
| 66 |
+
public:
|
| 67 |
+
tnzs_mcu_state(const machine_config &mconfig, device_type type, const char *tag, bool lockout_level)
|
| 68 |
+
: tnzs_base_state(mconfig, type, tag)
|
| 69 |
+
, m_mcu(*this, "mcu")
|
| 70 |
+
, m_upd4701(*this, "upd4701")
|
| 71 |
+
, m_in0(*this, "IN0")
|
| 72 |
+
, m_in1(*this, "IN1")
|
| 73 |
+
, m_in2(*this, "IN2")
|
| 74 |
+
, m_input_select(0)
|
| 75 |
+
, m_lockout_level(lockout_level)
|
| 76 |
+
{ }
|
| 77 |
+
|
| 78 |
+
void tnzs(machine_config &config);
|
| 79 |
+
|
| 80 |
+
protected:
|
| 81 |
+
virtual void bankswitch1_w(uint8_t data) override;
|
| 82 |
+
|
| 83 |
+
uint8_t mcu_port1_r();
|
| 84 |
+
void mcu_port2_w(uint8_t data);
|
| 85 |
+
uint8_t mcu_r(offs_t offset);
|
| 86 |
+
void mcu_w(offs_t offset, uint8_t data);
|
| 87 |
+
|
| 88 |
+
uint8_t analog_r(offs_t offset);
|
| 89 |
+
|
| 90 |
+
void tnzs_sub_map(address_map &map);
|
| 91 |
+
|
| 92 |
+
required_device<upi41_cpu_device> m_mcu;
|
| 93 |
+
optional_device<upd4701_device> m_upd4701;
|
| 94 |
+
|
| 95 |
+
required_ioport m_in0;
|
| 96 |
+
required_ioport m_in1;
|
| 97 |
+
required_ioport m_in2;
|
| 98 |
+
|
| 99 |
+
int m_input_select = 0;
|
| 100 |
+
bool m_lockout_level = false;
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
class tnzs_state : public tnzs_mcu_state
|
| 104 |
+
{
|
| 105 |
+
public:
|
| 106 |
+
tnzs_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 107 |
+
: tnzs_mcu_state(mconfig, type, tag, true)
|
| 108 |
+
{ }
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
class extrmatn_state : public tnzs_mcu_state
|
| 112 |
+
{
|
| 113 |
+
public:
|
| 114 |
+
extrmatn_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 115 |
+
: tnzs_mcu_state(mconfig, type, tag, false)
|
| 116 |
+
{ }
|
| 117 |
+
void extrmatn(machine_config &config);
|
| 118 |
+
void plumppop(machine_config &config);
|
| 119 |
+
|
| 120 |
+
protected:
|
| 121 |
+
void prompal_main_map(address_map &map);
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
class arknoid2_state : public extrmatn_state
|
| 125 |
+
{
|
| 126 |
+
public:
|
| 127 |
+
arknoid2_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 128 |
+
: extrmatn_state(mconfig, type, tag)
|
| 129 |
+
, m_coin1(*this, "COIN1")
|
| 130 |
+
, m_coin2(*this, "COIN2")
|
| 131 |
+
, m_in0(*this, "IN0")
|
| 132 |
+
, m_in1(*this, "IN1")
|
| 133 |
+
, m_in2(*this, "IN2")
|
| 134 |
+
{ }
|
| 135 |
+
|
| 136 |
+
void arknoid2(machine_config &config);
|
| 137 |
+
|
| 138 |
+
private:
|
| 139 |
+
virtual void machine_start() override;
|
| 140 |
+
virtual void machine_reset() override;
|
| 141 |
+
|
| 142 |
+
virtual void bankswitch1_w(uint8_t data) override;
|
| 143 |
+
|
| 144 |
+
uint8_t mcu_r(offs_t offset);
|
| 145 |
+
void mcu_w(offs_t offset, uint8_t data);
|
| 146 |
+
INTERRUPT_GEN_MEMBER(mcu_interrupt);
|
| 147 |
+
|
| 148 |
+
void arknoid2_sub_map(address_map &map);
|
| 149 |
+
|
| 150 |
+
required_ioport m_coin1;
|
| 151 |
+
required_ioport m_coin2;
|
| 152 |
+
required_ioport m_in0;
|
| 153 |
+
required_ioport m_in1;
|
| 154 |
+
required_ioport m_in2;
|
| 155 |
+
|
| 156 |
+
void mcu_reset();
|
| 157 |
+
|
| 158 |
+
int m_mcu_initializing = 0;
|
| 159 |
+
int m_mcu_coinage_init = 0;
|
| 160 |
+
int m_mcu_command = 0;
|
| 161 |
+
int m_mcu_readcredits = 0;
|
| 162 |
+
int m_mcu_reportcoin = 0;
|
| 163 |
+
int m_insertcoin = 0;
|
| 164 |
+
uint8_t m_mcu_coinage[4]{};
|
| 165 |
+
uint8_t m_mcu_coins_a = 0;
|
| 166 |
+
uint8_t m_mcu_coins_b = 0;
|
| 167 |
+
uint8_t m_mcu_credits = 0;
|
| 168 |
+
|
| 169 |
+
void mcu_handle_coins(int coin);
|
| 170 |
+
};
|
| 171 |
+
|
| 172 |
+
class kageki_state : public tnzs_base_state
|
| 173 |
+
{
|
| 174 |
+
public:
|
| 175 |
+
kageki_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 176 |
+
: tnzs_base_state(mconfig, type, tag)
|
| 177 |
+
, m_samples(*this, "samples")
|
| 178 |
+
, m_dswa(*this, "DSWA")
|
| 179 |
+
, m_dswb(*this, "DSWB")
|
| 180 |
+
, m_csport_sel(0)
|
| 181 |
+
{ }
|
| 182 |
+
|
| 183 |
+
void kageki(machine_config &config);
|
| 184 |
+
|
| 185 |
+
void init_kageki();
|
| 186 |
+
|
| 187 |
+
protected:
|
| 188 |
+
virtual void machine_start() override;
|
| 189 |
+
virtual void machine_reset() override;
|
| 190 |
+
|
| 191 |
+
private:
|
| 192 |
+
static constexpr unsigned MAX_SAMPLES = 0x2f;
|
| 193 |
+
|
| 194 |
+
virtual void bankswitch1_w(uint8_t data) override;
|
| 195 |
+
|
| 196 |
+
uint8_t csport_r();
|
| 197 |
+
void csport_w(uint8_t data);
|
| 198 |
+
|
| 199 |
+
DECLARE_MACHINE_RESET(kageki);
|
| 200 |
+
|
| 201 |
+
SAMPLES_START_CB_MEMBER(init_samples);
|
| 202 |
+
|
| 203 |
+
void kageki_sub_map(address_map &map);
|
| 204 |
+
|
| 205 |
+
required_device<samples_device> m_samples;
|
| 206 |
+
|
| 207 |
+
required_ioport m_dswa;
|
| 208 |
+
required_ioport m_dswb;
|
| 209 |
+
|
| 210 |
+
/* sound-related */
|
| 211 |
+
std::unique_ptr<int16_t[]> m_sampledata[MAX_SAMPLES];
|
| 212 |
+
int m_samplesize[MAX_SAMPLES]{};
|
| 213 |
+
|
| 214 |
+
int m_csport_sel = 0;
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
class jpopnics_state : public tnzs_base_state
|
| 218 |
+
{
|
| 219 |
+
public:
|
| 220 |
+
jpopnics_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 221 |
+
: tnzs_base_state(mconfig, type, tag)
|
| 222 |
+
, m_upd4701(*this, "upd4701")
|
| 223 |
+
{ }
|
| 224 |
+
|
| 225 |
+
void jpopnics(machine_config &config);
|
| 226 |
+
|
| 227 |
+
protected:
|
| 228 |
+
virtual void machine_reset() override;
|
| 229 |
+
|
| 230 |
+
private:
|
| 231 |
+
void subbankswitch_w(uint8_t data);
|
| 232 |
+
|
| 233 |
+
void jpopnics_main_map(address_map &map);
|
| 234 |
+
void jpopnics_sub_map(address_map &map);
|
| 235 |
+
required_device<upd4701_device> m_upd4701;
|
| 236 |
+
};
|
| 237 |
+
|
| 238 |
+
class insectx_state : public tnzs_base_state
|
| 239 |
+
{
|
| 240 |
+
public:
|
| 241 |
+
insectx_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 242 |
+
: tnzs_base_state(mconfig, type, tag)
|
| 243 |
+
{ }
|
| 244 |
+
|
| 245 |
+
void insectx(machine_config &config);
|
| 246 |
+
|
| 247 |
+
private:
|
| 248 |
+
virtual void bankswitch1_w(uint8_t data) override;
|
| 249 |
+
void insectx_sub_map(address_map &map);
|
| 250 |
+
};
|
| 251 |
+
|
| 252 |
+
class tnzsb_state : public tnzs_base_state
|
| 253 |
+
{
|
| 254 |
+
public:
|
| 255 |
+
tnzsb_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 256 |
+
: tnzs_base_state(mconfig, type, tag)
|
| 257 |
+
, m_audiocpu(*this, "audiocpu")
|
| 258 |
+
, m_soundlatch(*this, "soundlatch")
|
| 259 |
+
{ }
|
| 260 |
+
|
| 261 |
+
void tnzsb(machine_config &config);
|
| 262 |
+
|
| 263 |
+
protected:
|
| 264 |
+
DECLARE_WRITE_LINE_MEMBER(ym2203_irqhandler);
|
| 265 |
+
|
| 266 |
+
void sound_command_w(uint8_t data);
|
| 267 |
+
|
| 268 |
+
virtual void bankswitch1_w(uint8_t data) override;
|
| 269 |
+
|
| 270 |
+
void tnzsb_base_sub_map(address_map &map);
|
| 271 |
+
void tnzsb_cpu2_map(address_map &map);
|
| 272 |
+
void tnzsb_io_map(address_map &map);
|
| 273 |
+
void tnzsb_main_map(address_map &map);
|
| 274 |
+
void tnzsb_sub_map(address_map &map);
|
| 275 |
+
|
| 276 |
+
required_device<cpu_device> m_audiocpu;
|
| 277 |
+
required_device<generic_latch_8_device> m_soundlatch;
|
| 278 |
+
};
|
| 279 |
+
|
| 280 |
+
class kabukiz_state : public tnzsb_state
|
| 281 |
+
{
|
| 282 |
+
public:
|
| 283 |
+
kabukiz_state(const machine_config &mconfig, device_type type, const char *tag)
|
| 284 |
+
: tnzsb_state(mconfig, type, tag)
|
| 285 |
+
, m_audiobank(*this, "audiobank")
|
| 286 |
+
{ }
|
| 287 |
+
|
| 288 |
+
void kabukiz(machine_config &config);
|
| 289 |
+
|
| 290 |
+
protected:
|
| 291 |
+
virtual void machine_start() override;
|
| 292 |
+
|
| 293 |
+
private:
|
| 294 |
+
void sound_bank_w(uint8_t data);
|
| 295 |
+
|
| 296 |
+
void kabukiz_cpu2_map(address_map &map);
|
| 297 |
+
void kabukiz_sub_map(address_map &map);
|
| 298 |
+
|
| 299 |
+
required_memory_bank m_audiobank;
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
#endif // MAME_INCLUDES_TNZS_H
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/tnzs_m.cpp
ADDED
|
@@ -0,0 +1,498 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// license:BSD-3-Clause
|
| 2 |
+
// copyright-holders:Luca Elia, Mirko Buffoni, Takahiro Nogi,Stephane Humbert
|
| 3 |
+
/***************************************************************************
|
| 4 |
+
|
| 5 |
+
machine.c
|
| 6 |
+
|
| 7 |
+
Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
|
| 8 |
+
I/O ports)
|
| 9 |
+
|
| 10 |
+
The I8742 MCU takes care of handling the coin inputs and the tilt switch.
|
| 11 |
+
To simulate this, we read the status in the interrupt handler for the main
|
| 12 |
+
CPU and update the counters appropriately. We also must take care of
|
| 13 |
+
handling the coin/credit settings ourselves.
|
| 14 |
+
|
| 15 |
+
***************************************************************************/
|
| 16 |
+
|
| 17 |
+
#include "emu.h"
|
| 18 |
+
#include "cpu/mcs48/mcs48.h"
|
| 19 |
+
#include "tnzs.h"
|
| 20 |
+
|
| 21 |
+
uint8_t tnzs_mcu_state::mcu_r(offs_t offset)
|
| 22 |
+
{
|
| 23 |
+
uint8_t data = m_mcu->upi41_master_r(offset & 1);
|
| 24 |
+
m_subcpu->yield();
|
| 25 |
+
|
| 26 |
+
// logerror("%s: read %02x from mcu $c00%01x\n", m_maincpu->pcbase(), data, offset);
|
| 27 |
+
|
| 28 |
+
return data;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
void tnzs_mcu_state::mcu_w(offs_t offset, uint8_t data)
|
| 32 |
+
{
|
| 33 |
+
// logerror("%s: write %02x to mcu $c00%01x\n", m_maincpu->pcbase(), data, offset);
|
| 34 |
+
|
| 35 |
+
m_mcu->upi41_master_w(offset & 1, data);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
uint8_t tnzs_mcu_state::mcu_port1_r()
|
| 39 |
+
{
|
| 40 |
+
int data = 0;
|
| 41 |
+
|
| 42 |
+
switch (m_input_select)
|
| 43 |
+
{
|
| 44 |
+
case 0x0a: data = m_in2->read(); break;
|
| 45 |
+
case 0x0c: data = m_in0->read(); break;
|
| 46 |
+
case 0x0d: data = m_in1->read(); break;
|
| 47 |
+
default: data = 0xff; break;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// logerror("%s: Read %02x from port 1\n", m_maincpu->pcbase(), data);
|
| 51 |
+
|
| 52 |
+
return data;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
void tnzs_mcu_state::mcu_port2_w(uint8_t data)
|
| 56 |
+
{
|
| 57 |
+
machine().bookkeeping().coin_lockout_w(0, (data & 0x40) != 0 ? m_lockout_level : !m_lockout_level);
|
| 58 |
+
machine().bookkeeping().coin_lockout_w(1, (data & 0x80) != 0 ? m_lockout_level : !m_lockout_level);
|
| 59 |
+
machine().bookkeeping().coin_counter_w(0, (~data & 0x10));
|
| 60 |
+
machine().bookkeeping().coin_counter_w(1, (~data & 0x20));
|
| 61 |
+
|
| 62 |
+
m_input_select = data & 0xf;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
uint8_t tnzs_mcu_state::analog_r(offs_t offset)
|
| 66 |
+
{
|
| 67 |
+
return m_upd4701.found() ? m_upd4701->read_xy(offset) : 0;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
void arknoid2_state::mcu_reset()
|
| 71 |
+
{
|
| 72 |
+
m_mcu_initializing = 3;
|
| 73 |
+
m_mcu_coinage_init = 0;
|
| 74 |
+
m_mcu_coinage[0] = 1;
|
| 75 |
+
m_mcu_coinage[1] = 1;
|
| 76 |
+
m_mcu_coinage[2] = 1;
|
| 77 |
+
m_mcu_coinage[3] = 1;
|
| 78 |
+
m_mcu_coins_a = 0;
|
| 79 |
+
m_mcu_coins_b = 0;
|
| 80 |
+
m_mcu_credits = 0;
|
| 81 |
+
m_mcu_reportcoin = 0;
|
| 82 |
+
m_mcu_command = 0;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
void arknoid2_state::mcu_handle_coins( int coin )
|
| 86 |
+
{
|
| 87 |
+
/* The coin inputs and coin counters are managed by the i8742 mcu. */
|
| 88 |
+
/* Here we simulate it. */
|
| 89 |
+
/* Credits are limited to 9, so more coins should be rejected */
|
| 90 |
+
/* Coin/Play settings must also be taken into consideration */
|
| 91 |
+
|
| 92 |
+
if (coin & 0x08) /* tilt */
|
| 93 |
+
m_mcu_reportcoin = coin;
|
| 94 |
+
else if (coin && coin != m_insertcoin)
|
| 95 |
+
{
|
| 96 |
+
if (coin & 0x01) /* coin A */
|
| 97 |
+
{
|
| 98 |
+
// logerror("Coin dropped into slot A\n");
|
| 99 |
+
machine().bookkeeping().coin_counter_w(0,1); machine().bookkeeping().coin_counter_w(0,0); /* Count slot A */
|
| 100 |
+
m_mcu_coins_a++;
|
| 101 |
+
if (m_mcu_coins_a >= m_mcu_coinage[0])
|
| 102 |
+
{
|
| 103 |
+
m_mcu_coins_a -= m_mcu_coinage[0];
|
| 104 |
+
m_mcu_credits += m_mcu_coinage[1];
|
| 105 |
+
if (m_mcu_credits >= 9)
|
| 106 |
+
{
|
| 107 |
+
m_mcu_credits = 9;
|
| 108 |
+
machine().bookkeeping().coin_lockout_global_w(1); /* Lock all coin slots */
|
| 109 |
+
}
|
| 110 |
+
else
|
| 111 |
+
{
|
| 112 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
if (coin & 0x02) /* coin B */
|
| 118 |
+
{
|
| 119 |
+
// logerror("Coin dropped into slot B\n");
|
| 120 |
+
machine().bookkeeping().coin_counter_w(1,1); machine().bookkeeping().coin_counter_w(1,0); /* Count slot B */
|
| 121 |
+
m_mcu_coins_b++;
|
| 122 |
+
if (m_mcu_coins_b >= m_mcu_coinage[2])
|
| 123 |
+
{
|
| 124 |
+
m_mcu_coins_b -= m_mcu_coinage[2];
|
| 125 |
+
m_mcu_credits += m_mcu_coinage[3];
|
| 126 |
+
if (m_mcu_credits >= 9)
|
| 127 |
+
{
|
| 128 |
+
m_mcu_credits = 9;
|
| 129 |
+
machine().bookkeeping().coin_lockout_global_w(1); /* Lock all coin slots */
|
| 130 |
+
}
|
| 131 |
+
else
|
| 132 |
+
{
|
| 133 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
if (coin & 0x04) /* service */
|
| 139 |
+
{
|
| 140 |
+
// logerror("Coin dropped into service slot C\n");
|
| 141 |
+
m_mcu_credits++;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
m_mcu_reportcoin = coin;
|
| 145 |
+
}
|
| 146 |
+
else
|
| 147 |
+
{
|
| 148 |
+
if (m_mcu_credits < 9)
|
| 149 |
+
machine().bookkeeping().coin_lockout_global_w(0); /* Unlock all coin slots */
|
| 150 |
+
|
| 151 |
+
m_mcu_reportcoin = 0;
|
| 152 |
+
}
|
| 153 |
+
m_insertcoin = coin;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/*********************************
|
| 157 |
+
|
| 158 |
+
TNZS sync bug kludge
|
| 159 |
+
|
| 160 |
+
In all TNZS versions there is code like this:
|
| 161 |
+
|
| 162 |
+
0C5E: ld ($EF10),a
|
| 163 |
+
0C61: ld a,($EF10)
|
| 164 |
+
0C64: inc a
|
| 165 |
+
0C65: ret nz
|
| 166 |
+
0C66: jr $0C61
|
| 167 |
+
|
| 168 |
+
which is sometimes executed by the main cpu when it writes to shared RAM a
|
| 169 |
+
command for the second CPU. The intended purpose of the code is to wait an
|
| 170 |
+
acknowledge from the sub CPU: the sub CPU writes FF to the same location
|
| 171 |
+
after reading the command.
|
| 172 |
+
|
| 173 |
+
However the above code is wrong. The "ret nz" instruction means that the
|
| 174 |
+
loop will be exited only when the contents of $EF10 are *NOT* $FF!!
|
| 175 |
+
On the real board, this casues little harm: the main CPU will just write
|
| 176 |
+
the command, read it back and, since it's not $FF, return immediately. There
|
| 177 |
+
is a chance that the command might go lost, but this will cause no major
|
| 178 |
+
harm, the worse that can happen is that the background tune will not change.
|
| 179 |
+
|
| 180 |
+
In MAME, however, since CPU interleaving is not perfect, it can happen that
|
| 181 |
+
the main CPU ends its timeslice after writing to EF10 but before reading it
|
| 182 |
+
back. In the meantime, the sub CPU will run, read the command and write FF
|
| 183 |
+
there - therefore causing the main CPU to enter an endless loop.
|
| 184 |
+
|
| 185 |
+
Unlike the usual sync problems in MAME, which can be fixed by increasing the
|
| 186 |
+
interleave factor, in this case increasing it will actually INCREASE the
|
| 187 |
+
chance of entering the endless loop - because it will increase the chances of
|
| 188 |
+
the main CPU ending its timeslice at the wrong moment.
|
| 189 |
+
|
| 190 |
+
So what we do here is catch writes by the main CPU to the RAM location, and
|
| 191 |
+
process them using a timer, in order to
|
| 192 |
+
a) force a resync of the two CPUs
|
| 193 |
+
b) make sure the main CPU will be the first one to run after the location is
|
| 194 |
+
changed
|
| 195 |
+
|
| 196 |
+
Since the answer from the sub CPU is ignored, we don't even need to boost
|
| 197 |
+
interleave.
|
| 198 |
+
|
| 199 |
+
*********************************/
|
| 200 |
+
|
| 201 |
+
/*
|
| 202 |
+
TIMER_CALLBACK_MEMBER(tnzs_base_state::kludge_callback)
|
| 203 |
+
{
|
| 204 |
+
tnzs_sharedram[0x0f10] = param;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
void tnzs_base_state::tnzs_sync_kludge_w(uint8_t data)
|
| 208 |
+
{
|
| 209 |
+
machine().scheduler().synchronize(timer_expired_delegate(FUNC(tnzs_base_state::kludge_callback),this), data);
|
| 210 |
+
}
|
| 211 |
+
*/
|
| 212 |
+
|
| 213 |
+
uint8_t arknoid2_state::mcu_r(offs_t offset)
|
| 214 |
+
{
|
| 215 |
+
static const char mcu_startup[] = "\x55\xaa\x5a";
|
| 216 |
+
|
| 217 |
+
//logerror("%s: read mcu %04x\n", m_maincpu->pc(), 0xc000 + offset);
|
| 218 |
+
|
| 219 |
+
if (offset == 0)
|
| 220 |
+
{
|
| 221 |
+
/* if the mcu has just been reset, return startup code */
|
| 222 |
+
if (m_mcu_initializing)
|
| 223 |
+
{
|
| 224 |
+
m_mcu_initializing--;
|
| 225 |
+
return mcu_startup[2 - m_mcu_initializing];
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
switch (m_mcu_command)
|
| 229 |
+
{
|
| 230 |
+
case 0x41:
|
| 231 |
+
return m_mcu_credits;
|
| 232 |
+
|
| 233 |
+
case 0xc1:
|
| 234 |
+
/* Read the credit counter or the inputs */
|
| 235 |
+
if (m_mcu_readcredits == 0)
|
| 236 |
+
{
|
| 237 |
+
m_mcu_readcredits = 1;
|
| 238 |
+
if (m_mcu_reportcoin & 0x08)
|
| 239 |
+
{
|
| 240 |
+
m_mcu_initializing = 3;
|
| 241 |
+
return 0xee; /* tilt */
|
| 242 |
+
}
|
| 243 |
+
else return m_mcu_credits;
|
| 244 |
+
}
|
| 245 |
+
else return m_in0->read(); /* buttons */
|
| 246 |
+
|
| 247 |
+
default:
|
| 248 |
+
logerror("error, unknown mcu command\n");
|
| 249 |
+
/* should not happen */
|
| 250 |
+
return 0xff;
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
else
|
| 254 |
+
{
|
| 255 |
+
/*
|
| 256 |
+
status bits:
|
| 257 |
+
0 = mcu is ready to send data (read from c000)
|
| 258 |
+
1 = mcu has read data (from c000)
|
| 259 |
+
2 = unused
|
| 260 |
+
3 = unused
|
| 261 |
+
4-7 = coin code
|
| 262 |
+
0 = nothing
|
| 263 |
+
1,2,3 = coin switch pressed
|
| 264 |
+
e = tilt
|
| 265 |
+
*/
|
| 266 |
+
if (m_mcu_reportcoin & 0x08) return 0xe1; /* tilt */
|
| 267 |
+
if (m_mcu_reportcoin & 0x01) return 0x11; /* coin 1 (will trigger "coin inserted" sound) */
|
| 268 |
+
if (m_mcu_reportcoin & 0x02) return 0x21; /* coin 2 (will trigger "coin inserted" sound) */
|
| 269 |
+
if (m_mcu_reportcoin & 0x04) return 0x31; /* coin 3 (will trigger "coin inserted" sound) */
|
| 270 |
+
return 0x01;
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
void arknoid2_state::mcu_w(offs_t offset, uint8_t data)
|
| 275 |
+
{
|
| 276 |
+
if (offset == 0)
|
| 277 |
+
{
|
| 278 |
+
//logerror("%s: write %02x to mcu %04x\n", m_maincpu->pc(), data, 0xc000 + offset);
|
| 279 |
+
if (m_mcu_command == 0x41)
|
| 280 |
+
{
|
| 281 |
+
m_mcu_credits = (m_mcu_credits + data) & 0xff;
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
else
|
| 285 |
+
{
|
| 286 |
+
/*
|
| 287 |
+
0xc1: read number of credits, then buttons
|
| 288 |
+
0x54+0x41: add value to number of credits
|
| 289 |
+
0x15: sub 1 credit (when "Continue Play" only)
|
| 290 |
+
0x84: coin 1 lockout (issued only in test mode)
|
| 291 |
+
0x88: coin 2 lockout (issued only in test mode)
|
| 292 |
+
0x80: release coin lockout (issued only in test mode)
|
| 293 |
+
during initialization, a sequence of 4 bytes sets coin/credit settings
|
| 294 |
+
*/
|
| 295 |
+
//logerror("%s: write %02x to mcu %04x\n", m_maincpu->pc(), data, 0xc000 + offset);
|
| 296 |
+
|
| 297 |
+
if (m_mcu_initializing)
|
| 298 |
+
{
|
| 299 |
+
/* set up coin/credit settings */
|
| 300 |
+
m_mcu_coinage[m_mcu_coinage_init++] = data;
|
| 301 |
+
if (m_mcu_coinage_init == 4)
|
| 302 |
+
m_mcu_coinage_init = 0; /* must not happen */
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
if (data == 0xc1)
|
| 306 |
+
m_mcu_readcredits = 0; /* reset input port number */
|
| 307 |
+
|
| 308 |
+
if (data == 0x15)
|
| 309 |
+
{
|
| 310 |
+
m_mcu_credits = (m_mcu_credits - 1) & 0xff;
|
| 311 |
+
if (m_mcu_credits == 0xff)
|
| 312 |
+
m_mcu_credits = 0;
|
| 313 |
+
}
|
| 314 |
+
m_mcu_command = data;
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
INTERRUPT_GEN_MEMBER(arknoid2_state::mcu_interrupt)
|
| 319 |
+
{
|
| 320 |
+
int coin = ((m_coin1->read() & 1) << 0);
|
| 321 |
+
coin |= ((m_coin2->read() & 1) << 1);
|
| 322 |
+
coin |= ((m_in2->read() & 3) << 2);
|
| 323 |
+
coin ^= 0x0c;
|
| 324 |
+
mcu_handle_coins(coin);
|
| 325 |
+
|
| 326 |
+
device.execute().set_input_line(0, HOLD_LINE);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
void arknoid2_state::machine_reset()
|
| 330 |
+
{
|
| 331 |
+
/* initialize the mcu simulation */
|
| 332 |
+
mcu_reset();
|
| 333 |
+
|
| 334 |
+
m_mcu_readcredits = 0;
|
| 335 |
+
m_insertcoin = 0;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
void kageki_state::machine_reset()
|
| 339 |
+
{
|
| 340 |
+
tnzs_base_state::machine_reset();
|
| 341 |
+
m_csport_sel = 0;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
void tnzs_base_state::machine_start()
|
| 345 |
+
{
|
| 346 |
+
uint8_t *sub = memregion("sub")->base();
|
| 347 |
+
|
| 348 |
+
m_bank2 = 0;
|
| 349 |
+
m_mainbank->set_bank(2);
|
| 350 |
+
|
| 351 |
+
m_subbank->configure_entries(0, 4, &sub[0x08000], 0x2000);
|
| 352 |
+
m_subbank->set_entry(m_bank2);
|
| 353 |
+
|
| 354 |
+
save_item(NAME(m_bank2));
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
void arknoid2_state::machine_start()
|
| 358 |
+
{
|
| 359 |
+
tnzs_base_state::machine_start();
|
| 360 |
+
|
| 361 |
+
save_item(NAME(m_mcu_readcredits));
|
| 362 |
+
save_item(NAME(m_insertcoin));
|
| 363 |
+
save_item(NAME(m_mcu_initializing));
|
| 364 |
+
save_item(NAME(m_mcu_coinage_init));
|
| 365 |
+
save_item(NAME(m_mcu_coinage));
|
| 366 |
+
save_item(NAME(m_mcu_coins_a));
|
| 367 |
+
save_item(NAME(m_mcu_coins_b));
|
| 368 |
+
save_item(NAME(m_mcu_credits));
|
| 369 |
+
save_item(NAME(m_mcu_reportcoin));
|
| 370 |
+
save_item(NAME(m_mcu_command));
|
| 371 |
+
|
| 372 |
+
// kludge to make device work with active-high coin inputs
|
| 373 |
+
m_upd4701->left_w(0);
|
| 374 |
+
m_upd4701->middle_w(0);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
void kageki_state::machine_start()
|
| 378 |
+
{
|
| 379 |
+
tnzs_base_state::machine_start();
|
| 380 |
+
save_item(NAME(m_csport_sel));
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
void kabukiz_state::machine_start()
|
| 384 |
+
{
|
| 385 |
+
tnzs_base_state::machine_start();
|
| 386 |
+
uint8_t *sound = memregion("audiocpu")->base();
|
| 387 |
+
m_audiobank->configure_entries(0, 8, &sound[0x00000], 0x4000);
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
void tnzs_base_state::ramrom_bankswitch_w(uint8_t data)
|
| 391 |
+
{
|
| 392 |
+
// logerror("%s: writing %02x to bankswitch\n", m_maincpu->pc(),data);
|
| 393 |
+
|
| 394 |
+
// bit 4 resets the second CPU
|
| 395 |
+
m_subcpu->set_input_line(INPUT_LINE_RESET, BIT(data, 4) ? CLEAR_LINE : ASSERT_LINE);
|
| 396 |
+
|
| 397 |
+
// bits 0-2 select RAM/ROM bank
|
| 398 |
+
m_mainbank->set_bank(data & 0x07);
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
void arknoid2_state::bankswitch1_w(uint8_t data)
|
| 402 |
+
{
|
| 403 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 404 |
+
|
| 405 |
+
if (BIT(data, 2))
|
| 406 |
+
mcu_reset();
|
| 407 |
+
|
| 408 |
+
// never actually written by arknoid2 (though code exists to do it)
|
| 409 |
+
m_upd4701->resetx_w(BIT(data, 5));
|
| 410 |
+
m_upd4701->resety_w(BIT(data, 5));
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
void insectx_state::bankswitch1_w(uint8_t data)
|
| 414 |
+
{
|
| 415 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 416 |
+
|
| 417 |
+
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
|
| 418 |
+
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
|
| 419 |
+
machine().bookkeeping().coin_counter_w(0, BIT(data, 4));
|
| 420 |
+
machine().bookkeeping().coin_counter_w(1, BIT(data, 5));
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
void tnzsb_state::bankswitch1_w(uint8_t data) // kabukiz_state
|
| 424 |
+
{
|
| 425 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 426 |
+
|
| 427 |
+
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 4));
|
| 428 |
+
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 5));
|
| 429 |
+
machine().bookkeeping().coin_counter_w(0, BIT(data, 2));
|
| 430 |
+
machine().bookkeeping().coin_counter_w(1, BIT(data, 3));
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
void kageki_state::bankswitch1_w(uint8_t data)
|
| 434 |
+
{
|
| 435 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 436 |
+
|
| 437 |
+
machine().bookkeeping().coin_lockout_global_w(BIT(~data, 5));
|
| 438 |
+
machine().bookkeeping().coin_counter_w(0, BIT(data, 2));
|
| 439 |
+
machine().bookkeeping().coin_counter_w(1, BIT(data, 3));
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
void tnzs_mcu_state::bankswitch1_w(uint8_t data)
|
| 443 |
+
{
|
| 444 |
+
tnzs_base_state::bankswitch1_w(data);
|
| 445 |
+
|
| 446 |
+
if (BIT(data, 2) && m_mcu)
|
| 447 |
+
m_mcu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
|
| 448 |
+
|
| 449 |
+
// written only at startup by plumppop?
|
| 450 |
+
if (m_upd4701.found())
|
| 451 |
+
{
|
| 452 |
+
m_upd4701->resetx_w(BIT(data, 5));
|
| 453 |
+
m_upd4701->resety_w(BIT(data, 5));
|
| 454 |
+
}
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
void tnzs_base_state::bankswitch1_w(uint8_t data)
|
| 458 |
+
{
|
| 459 |
+
// logerror("%s: writing %02x to bankswitch 1\n", m_maincpu->pc(),data);
|
| 460 |
+
|
| 461 |
+
// bits 0-1 select ROM bank
|
| 462 |
+
m_bank2 = data & 0x03;
|
| 463 |
+
m_subbank->set_entry(m_bank2);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
void jpopnics_state::machine_reset()
|
| 467 |
+
{
|
| 468 |
+
tnzs_base_state::machine_reset();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
void jpopnics_state::subbankswitch_w(uint8_t data)
|
| 472 |
+
{
|
| 473 |
+
// bits 0-1 select ROM bank
|
| 474 |
+
m_subbank->set_entry(data & 0x03);
|
| 475 |
+
|
| 476 |
+
// written once at startup
|
| 477 |
+
m_upd4701->resetx_w(BIT(data, 5));
|
| 478 |
+
m_upd4701->resety_w(BIT(data, 5));
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
void tnzsb_state::sound_command_w(uint8_t data)
|
| 482 |
+
{
|
| 483 |
+
m_soundlatch->write(data);
|
| 484 |
+
m_audiocpu->set_input_line_and_vector(0, HOLD_LINE, 0xff); // Z80
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
// handler called by the 2203 emulator when the internal timers cause an IRQ
|
| 488 |
+
WRITE_LINE_MEMBER(tnzsb_state::ym2203_irqhandler)
|
| 489 |
+
{
|
| 490 |
+
m_audiocpu->set_input_line(INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
void kabukiz_state::sound_bank_w(uint8_t data)
|
| 494 |
+
{
|
| 495 |
+
// to avoid the write when the sound chip is initialized
|
| 496 |
+
if (data != 0xff)
|
| 497 |
+
m_audiobank->set_entry(data & 0x07);
|
| 498 |
+
}
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/doc/x1-007.v
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// x1-007 model by Furrtek
|
| 2 |
+
|
| 3 |
+
module x1_007(
|
| 4 |
+
input PXCLK,
|
| 5 |
+
input nVBLK,
|
| 6 |
+
input nHSYNC, nVSYNC,
|
| 7 |
+
input RGB[14:0],
|
| 8 |
+
input PIN26,
|
| 9 |
+
output CSYNC,
|
| 10 |
+
output reg R[5:0],
|
| 11 |
+
output reg G[5:0],
|
| 12 |
+
output reg B[5:0],
|
| 13 |
+
output reg PIN11
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
reg PIN26_reg;
|
| 17 |
+
reg [14:0] RGB_reg;
|
| 18 |
+
reg nVBLK_A_reg, nVBLK_B_reg;
|
| 19 |
+
|
| 20 |
+
assign CSYNC = ~(nHSYNC | nVSYNC); // BOTO
|
| 21 |
+
|
| 22 |
+
always @(negedge PXCLK) begin
|
| 23 |
+
PIN26_reg <= PIN26; // AGIT
|
| 24 |
+
nVBLK_A_reg <= nVBLK; // AFAX
|
| 25 |
+
nVBLK_B_reg <= nVBLK_A_reg; // BOLO
|
| 26 |
+
PIN11 <= nVBLK_A_reg ? PIN26_reg : 1'b0; // BEDI
|
| 27 |
+
end
|
| 28 |
+
|
| 29 |
+
always @(posedge PXCLK)
|
| 30 |
+
RGB_reg <= RGB; // 15x FD1S cells
|
| 31 |
+
|
| 32 |
+
always @(posedge PXCLK or negedge nVBLK_B_reg) begin
|
| 33 |
+
if (!nVBLK_B_reg)
|
| 34 |
+
{R, G, B} <= 18'd0; // 18x FD2S cells
|
| 35 |
+
else
|
| 36 |
+
{R, G, B} <= {RGB_reg[14:10], |{RGB_reg[14:10]}, RGB_reg[9:5], |{RGB_reg[9:5]} , RGB_reg[4:0], |{RGB_reg[4:0]}};
|
| 37 |
+
end
|
| 38 |
+
|
| 39 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_colmix.v
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 18-9-2022 */
|
| 18 |
+
|
| 19 |
+
module jtkiwi_colmix(
|
| 20 |
+
input clk,
|
| 21 |
+
input clk_cpu,
|
| 22 |
+
input pxl_cen,
|
| 23 |
+
input LHBL,
|
| 24 |
+
input LVBL,
|
| 25 |
+
|
| 26 |
+
input [8:0] scr_pxl,
|
| 27 |
+
input [8:0] obj_pxl,
|
| 28 |
+
|
| 29 |
+
input [9:0] cpu_addr,
|
| 30 |
+
input [7:0] cpu_dout,
|
| 31 |
+
input cpu_rnw,
|
| 32 |
+
output [7:0] cpu_din,
|
| 33 |
+
input pal_cs,
|
| 34 |
+
|
| 35 |
+
input pal2_cs,
|
| 36 |
+
input [7:0] cpu2_dout,
|
| 37 |
+
input cpu2_rnw,
|
| 38 |
+
input [9:0] cpu2_addr,
|
| 39 |
+
|
| 40 |
+
input [9:0] prog_addr,
|
| 41 |
+
input [7:0] prog_data,
|
| 42 |
+
input prom_we,
|
| 43 |
+
input colprom_en,
|
| 44 |
+
|
| 45 |
+
input [7:0] debug_bus,
|
| 46 |
+
input [3:0] gfx_en,
|
| 47 |
+
output [4:0] red,
|
| 48 |
+
output [4:0] green,
|
| 49 |
+
output [4:0] blue
|
| 50 |
+
);
|
| 51 |
+
|
| 52 |
+
wire [ 7:0] pal_dout;
|
| 53 |
+
wire [ 9:0] pal_addr;
|
| 54 |
+
reg [ 7:0] pall;
|
| 55 |
+
reg [ 8:0] coll, col_addr;
|
| 56 |
+
reg [14:0] rgb;
|
| 57 |
+
wire pal_we;
|
| 58 |
+
wire blank;
|
| 59 |
+
reg half, obj_sel;
|
| 60 |
+
// PROM variation
|
| 61 |
+
wire [15:0] prom_dout;
|
| 62 |
+
wire promhi_we, promlo_we;
|
| 63 |
+
wire [ 3:0] sort;
|
| 64 |
+
|
| 65 |
+
assign pal_addr = { coll, half };
|
| 66 |
+
assign pal_we = (pal_cs & ~cpu_rnw) | (pal2_cs & ~cpu2_rnw);
|
| 67 |
+
assign blank = ~(LVBL & LHBL);
|
| 68 |
+
assign {red,green,blue} = {15{~blank}} & rgb;
|
| 69 |
+
// PROM
|
| 70 |
+
assign promhi_we = prom_we & ~prog_addr[9];
|
| 71 |
+
assign promlo_we = prom_we & prog_addr[9];
|
| 72 |
+
|
| 73 |
+
always @* begin
|
| 74 |
+
obj_sel = obj_pxl[3:0] != 4'h0;
|
| 75 |
+
case( {gfx_en[3],gfx_en[0]})
|
| 76 |
+
2'b00: col_addr = 0;
|
| 77 |
+
2'b01: col_addr = scr_pxl;
|
| 78 |
+
2'b10: col_addr = obj_pxl;
|
| 79 |
+
2'b11: col_addr = obj_sel ? obj_pxl : scr_pxl; // simple priority for now.
|
| 80 |
+
endcase
|
| 81 |
+
end
|
| 82 |
+
|
| 83 |
+
always @(posedge clk) begin
|
| 84 |
+
half <= ~half;
|
| 85 |
+
if( pxl_cen ) begin
|
| 86 |
+
`ifdef GRAY
|
| 87 |
+
rgb <= ~{3{ {coll[3:0]}, 1'b0 } };
|
| 88 |
+
`else
|
| 89 |
+
rgb <= colprom_en ? prom_dout[14:0] : { pal_dout[6:0], pall };
|
| 90 |
+
`endif
|
| 91 |
+
half <= 1;
|
| 92 |
+
coll <= col_addr;
|
| 93 |
+
end
|
| 94 |
+
pall <= pal_dout;
|
| 95 |
+
end
|
| 96 |
+
|
| 97 |
+
jtframe_sort u_sort(
|
| 98 |
+
.debug_bus ( debug_bus ),
|
| 99 |
+
.busin ( col_addr[3:0] ),
|
| 100 |
+
.busout ( sort )
|
| 101 |
+
);
|
| 102 |
+
|
| 103 |
+
// Palette RAM X1-007 chip
|
| 104 |
+
jtframe_dual_ram #(.AW(10),.SIMFILE("pal.bin")) u_comm(
|
| 105 |
+
.clk0 ( clk_cpu ),
|
| 106 |
+
.clk1 ( clk ),
|
| 107 |
+
// Main/Sub CPU
|
| 108 |
+
.addr0 ( pal2_cs ? cpu2_addr : cpu_addr ),
|
| 109 |
+
.data0 ( pal2_cs ? cpu2_dout : cpu_dout ),
|
| 110 |
+
.we0 ( pal_we ),
|
| 111 |
+
.q0 ( cpu_din ),
|
| 112 |
+
// Color mixer
|
| 113 |
+
.addr1 ( pal_addr ),
|
| 114 |
+
.data1 ( ),
|
| 115 |
+
.we1 ( 1'b0 ),
|
| 116 |
+
.q1 ( pal_dout )
|
| 117 |
+
);
|
| 118 |
+
|
| 119 |
+
// PROM for Extermination
|
| 120 |
+
jtframe_prom #( .AW(9), .SIMFILE("../../../../rom/extrmatn/b06-09.15f")) u_promhi(
|
| 121 |
+
.clk ( clk ),
|
| 122 |
+
.cen ( 1'b1 ),
|
| 123 |
+
.data ( prog_data ),
|
| 124 |
+
.rd_addr( {col_addr[8:4], sort} ),
|
| 125 |
+
.wr_addr( prog_addr[8:0] ),
|
| 126 |
+
.we ( promhi_we ),
|
| 127 |
+
.q ( prom_dout[15:8] )
|
| 128 |
+
);
|
| 129 |
+
|
| 130 |
+
jtframe_prom #( .AW(9), .SIMFILE("../../../../rom/extrmatn/b06-08.17f")) u_promlo(
|
| 131 |
+
.clk ( clk ),
|
| 132 |
+
.cen ( 1'b1 ),
|
| 133 |
+
.data ( prog_data ),
|
| 134 |
+
.rd_addr( {col_addr[8:4], sort} ),
|
| 135 |
+
.wr_addr( prog_addr[8:0] ),
|
| 136 |
+
.we ( promlo_we ),
|
| 137 |
+
.q ( prom_dout[7:0] )
|
| 138 |
+
);
|
| 139 |
+
|
| 140 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_draw.v
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 7-11-2022 */
|
| 18 |
+
|
| 19 |
+
// This is tile map section of the SETA chip
|
| 20 |
+
// This one uses an independent line buffer
|
| 21 |
+
// from that of the sprites
|
| 22 |
+
|
| 23 |
+
module jtkiwi_draw(
|
| 24 |
+
input rst,
|
| 25 |
+
input clk,
|
| 26 |
+
|
| 27 |
+
input draw,
|
| 28 |
+
output reg busy,
|
| 29 |
+
input [13:0] code,
|
| 30 |
+
input [ 8:0] xpos,
|
| 31 |
+
input [ 3:0] ysub,
|
| 32 |
+
input flip,
|
| 33 |
+
|
| 34 |
+
input hflip,
|
| 35 |
+
input vflip,
|
| 36 |
+
input [ 4:0] pal,
|
| 37 |
+
|
| 38 |
+
output [20:2] rom_addr,
|
| 39 |
+
output reg rom_cs,
|
| 40 |
+
input rom_ok,
|
| 41 |
+
input [31:0] rom_data,
|
| 42 |
+
|
| 43 |
+
output reg [ 8:0] buf_addr,
|
| 44 |
+
output buf_we,
|
| 45 |
+
output [ 8:0] buf_din,
|
| 46 |
+
|
| 47 |
+
input [ 7:0] debug_bus
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
// Each tile is 16x16 and comes from the same ROM
|
| 51 |
+
// but it looks like the sprites have the two 8x16 halves swapped
|
| 52 |
+
parameter SWAP_HALVES = 1'b0;
|
| 53 |
+
|
| 54 |
+
reg [31:0] pxl_data;
|
| 55 |
+
reg rom_lsb;
|
| 56 |
+
reg [ 3:0] cnt;
|
| 57 |
+
wire [ 3:0] ysubf, pxl_in;
|
| 58 |
+
|
| 59 |
+
assign ysubf = ysub^{4{vflip}};
|
| 60 |
+
assign buf_din = { pal, pxl_in };
|
| 61 |
+
assign pxl_in = hflip ?
|
| 62 |
+
{ pxl_data[23], pxl_data[ 7], pxl_data[31], pxl_data[15] } :
|
| 63 |
+
{ pxl_data[16], pxl_data[ 0], pxl_data[24], pxl_data[ 8] };
|
| 64 |
+
|
| 65 |
+
// { pxl_data[15], pxl_data[31], pxl_data[ 7], pxl_data[23] } :
|
| 66 |
+
// { pxl_data[ 8], pxl_data[24], pxl_data[ 0], pxl_data[16] } };
|
| 67 |
+
|
| 68 |
+
assign rom_addr = { code, ysubf[3], rom_lsb^SWAP_HALVES, ysubf[2:0] };
|
| 69 |
+
assign buf_we = busy & ~cnt[3];
|
| 70 |
+
|
| 71 |
+
always @(posedge clk, posedge rst) begin
|
| 72 |
+
if( rst ) begin
|
| 73 |
+
rom_cs <= 0;
|
| 74 |
+
buf_addr <= 0;
|
| 75 |
+
pxl_data <= 0;
|
| 76 |
+
busy <= 0;
|
| 77 |
+
cnt <= 0;
|
| 78 |
+
end else begin
|
| 79 |
+
if( !busy ) begin
|
| 80 |
+
if( draw ) begin
|
| 81 |
+
rom_lsb <= hflip; // 14+4 = 18 (+2=20)
|
| 82 |
+
rom_cs <= 1;
|
| 83 |
+
buf_addr <= xpos;
|
| 84 |
+
busy <= 1;
|
| 85 |
+
cnt <= 8;
|
| 86 |
+
end
|
| 87 |
+
end else begin
|
| 88 |
+
if( rom_ok && rom_cs && cnt[3]) begin
|
| 89 |
+
pxl_data <= rom_data;
|
| 90 |
+
cnt[3] <= 0;
|
| 91 |
+
if( rom_lsb^hflip ) begin
|
| 92 |
+
rom_cs <= 0;
|
| 93 |
+
end else begin
|
| 94 |
+
rom_cs <= 1;
|
| 95 |
+
end
|
| 96 |
+
end
|
| 97 |
+
if( !cnt[3] ) begin
|
| 98 |
+
cnt <= cnt+1'd1;
|
| 99 |
+
buf_addr <= buf_addr+1'd1;
|
| 100 |
+
pxl_data <= hflip ? pxl_data << 1 : pxl_data >> 1;
|
| 101 |
+
rom_lsb <= ~hflip;
|
| 102 |
+
if( cnt[2:0]==7 && !rom_cs ) busy <= 0;
|
| 103 |
+
end
|
| 104 |
+
end
|
| 105 |
+
end
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_game.v
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 02-05-2020 */
|
| 18 |
+
|
| 19 |
+
module jtkiwi_game(
|
| 20 |
+
`include "jtframe_game_ports.inc" // see $JTFRAME/hdl/inc/jtframe_game_ports.inc
|
| 21 |
+
);
|
| 22 |
+
|
| 23 |
+
wire sub_rnw, shr_cs, mshramen, snd_rstn;
|
| 24 |
+
wire [ 7:0] shr_din, shr_dout, main_st, gfx_st, snd_st,
|
| 25 |
+
vram_dout, pal_dout, cpu_dout;
|
| 26 |
+
wire [ 8:0] hdump;
|
| 27 |
+
wire [ 1:0] eff_coin;
|
| 28 |
+
wire [12:0] shr_addr, cpu_addr;
|
| 29 |
+
|
| 30 |
+
wire bram_cs, vram_cs, pal_cs, pal2_cs, flip;
|
| 31 |
+
wire cpu_rnw, vctrl_cs, vflag_cs,
|
| 32 |
+
button_aid, // merges 1P, coin and
|
| 33 |
+
colprom_we, mcuprom_we, eff_service;
|
| 34 |
+
reg hb_dly=0, dip_flip_xor=0,
|
| 35 |
+
coin_xor=0, banked_ram=0,
|
| 36 |
+
kageki=0, kabuki=0, kabuki_mod = 0, service_xor=0,
|
| 37 |
+
colprom_en=0, mcu_en=0, aid_en, fast_fm=0;
|
| 38 |
+
|
| 39 |
+
assign dip_flip = ~flip ^ dip_flip_xor;
|
| 40 |
+
assign debug_view = st_addr[7:6]==0 ? { hb_dly, dip_flip_xor, coin_xor, banked_ram,
|
| 41 |
+
kageki, kabuki, colprom_en, mcu_en } :
|
| 42 |
+
st_addr[7:6]==1 ? main_st :
|
| 43 |
+
st_addr[7:6]==2 ? gfx_st : snd_st;
|
| 44 |
+
assign colprom_we = prom_we && prog_addr[15:10]==0;
|
| 45 |
+
assign mcuprom_we = prom_we && prog_addr >= `MCU_START;
|
| 46 |
+
assign st_dout = debug_view;
|
| 47 |
+
// Banked RAM
|
| 48 |
+
assign bram_we = bram_cs & ~cpu_rnw;
|
| 49 |
+
// assign bram_dsn = { 1'd1, bram_cs & cpu_rnw };
|
| 50 |
+
assign bram_din = cpu_dout;
|
| 51 |
+
// button_aid will make up/down inputs to work as coins too. This helps
|
| 52 |
+
// button mapping for spinners in MiSTer
|
| 53 |
+
assign eff_coin = {2{coin_xor}}^( coin[1:0] & ({2{~button_aid}}| {&joystick2[3:2],&joystick1[3:2]}));
|
| 54 |
+
assign eff_service= service_xor ^ service;
|
| 55 |
+
assign button_aid = `ifdef MISTER status[13]&aid_en `else 0 `endif ;
|
| 56 |
+
|
| 57 |
+
always @(posedge clk) begin
|
| 58 |
+
if( prog_we && header ) begin
|
| 59 |
+
if( prog_addr==0 )
|
| 60 |
+
{ hb_dly, dip_flip_xor, coin_xor, banked_ram,
|
| 61 |
+
kageki, kabuki, colprom_en, mcu_en } <= prog_data;
|
| 62 |
+
else if( prog_addr==1 )
|
| 63 |
+
{ kabuki_mod, fast_fm, aid_en, service_xor } <= prog_data[3:0];
|
| 64 |
+
end
|
| 65 |
+
end
|
| 66 |
+
|
| 67 |
+
/* verilator tracing_on */
|
| 68 |
+
jtkiwi_main u_main(
|
| 69 |
+
.rst ( rst ),
|
| 70 |
+
.clk ( clk ),
|
| 71 |
+
.cen6 ( cen6 ),
|
| 72 |
+
|
| 73 |
+
.LVBL ( LVBL ),
|
| 74 |
+
.hcnt ( hdump ),
|
| 75 |
+
.colprom_en ( colprom_en ),
|
| 76 |
+
// Banked RAM
|
| 77 |
+
.banked_ram ( banked_ram ),
|
| 78 |
+
.bram_cs ( bram_cs ),
|
| 79 |
+
.bram_ok ( 1'b1 ), //bram_ok ),
|
| 80 |
+
.bram_data ( bram_dout ),
|
| 81 |
+
.bram_addr ( bram_addr ),
|
| 82 |
+
// Main CPU ROM
|
| 83 |
+
.rom_addr ( main_addr ),
|
| 84 |
+
.rom_cs ( main_cs ),
|
| 85 |
+
.rom_data ( main_data ),
|
| 86 |
+
|
| 87 |
+
// Sub CPU access to shared RAM
|
| 88 |
+
.shr_addr ( shr_addr ),
|
| 89 |
+
.shr_dout ( shr_dout ),
|
| 90 |
+
.sub_rnw ( sub_rnw ),
|
| 91 |
+
.shr_din ( shr_din ),
|
| 92 |
+
.shr_cs ( shr_cs ),
|
| 93 |
+
.mshramen ( mshramen ),
|
| 94 |
+
// Sound
|
| 95 |
+
.snd_rstn ( snd_rstn ),
|
| 96 |
+
|
| 97 |
+
// Video
|
| 98 |
+
.cpu_addr ( cpu_addr ),
|
| 99 |
+
.cpu_dout ( cpu_dout ),
|
| 100 |
+
.cpu_rnw ( cpu_rnw ),
|
| 101 |
+
|
| 102 |
+
.vctrl_cs ( vctrl_cs ),
|
| 103 |
+
.vram_cs ( vram_cs ),
|
| 104 |
+
.vflag_cs ( vflag_cs ),
|
| 105 |
+
.vram_dout ( vram_dout ),
|
| 106 |
+
|
| 107 |
+
.pal_cs ( pal_cs ),
|
| 108 |
+
.pal_dout ( pal_dout ),
|
| 109 |
+
.dip_pause ( dip_pause ),
|
| 110 |
+
.debug_bus ( debug_bus ),
|
| 111 |
+
.st_dout ( main_st )
|
| 112 |
+
);
|
| 113 |
+
|
| 114 |
+
/* verilator tracing_on */
|
| 115 |
+
jtkiwi_video u_video(
|
| 116 |
+
.rst ( rst ),
|
| 117 |
+
.clk ( clk ),
|
| 118 |
+
.clk_cpu ( clk ),
|
| 119 |
+
|
| 120 |
+
.pxl2_cen ( pxl2_cen ),
|
| 121 |
+
.pxl_cen ( pxl_cen ),
|
| 122 |
+
.hb_dly ( hb_dly ),
|
| 123 |
+
.LHBL ( LHBL ),
|
| 124 |
+
.LVBL ( LVBL ),
|
| 125 |
+
.HS ( HS ),
|
| 126 |
+
.VS ( VS ),
|
| 127 |
+
.flip ( flip ),
|
| 128 |
+
.hdump ( hdump ),
|
| 129 |
+
// PROMs
|
| 130 |
+
.prom_we ( colprom_we ),
|
| 131 |
+
.prog_addr ( prog_addr[9:0]),
|
| 132 |
+
.prog_data ( prog_data ),
|
| 133 |
+
.colprom_en ( colprom_en ),
|
| 134 |
+
// GFX - CPU interface
|
| 135 |
+
.cpu_rnw ( cpu_rnw ),
|
| 136 |
+
.cpu_addr ( cpu_addr ),
|
| 137 |
+
.cpu_dout ( cpu_dout ),
|
| 138 |
+
|
| 139 |
+
.vram_cs ( vram_cs ),
|
| 140 |
+
.vctrl_cs ( vctrl_cs ),
|
| 141 |
+
.vflag_cs ( vflag_cs ),
|
| 142 |
+
.vram_dout ( vram_dout ),
|
| 143 |
+
|
| 144 |
+
.pal_cs ( pal_cs ),
|
| 145 |
+
.pal_dout ( pal_dout ),
|
| 146 |
+
|
| 147 |
+
.pal2_cs ( pal2_cs ),
|
| 148 |
+
.cpu2_dout ( shr_din ),
|
| 149 |
+
.cpu2_rnw ( sub_rnw ),
|
| 150 |
+
.cpu2_addr ( shr_addr[9:0] ),
|
| 151 |
+
|
| 152 |
+
// SDRAM
|
| 153 |
+
.scr_addr ( scr_addr ),
|
| 154 |
+
.scr_data ( scr_data ),
|
| 155 |
+
.scr_ok ( scr_ok ),
|
| 156 |
+
.scr_cs ( scr_cs ),
|
| 157 |
+
|
| 158 |
+
.obj_addr ( obj_addr ),
|
| 159 |
+
.obj_data ( obj_data ),
|
| 160 |
+
.obj_ok ( obj_ok ),
|
| 161 |
+
.obj_cs ( obj_cs ),
|
| 162 |
+
// pixels
|
| 163 |
+
.red ( red ),
|
| 164 |
+
.green ( green ),
|
| 165 |
+
.blue ( blue ),
|
| 166 |
+
// Test
|
| 167 |
+
.gfx_en ( gfx_en ),
|
| 168 |
+
.debug_bus ( debug_bus ),
|
| 169 |
+
.st_dout ( gfx_st )
|
| 170 |
+
);
|
| 171 |
+
|
| 172 |
+
/* verilator tracing_off */
|
| 173 |
+
jtkiwi_snd u_sound(
|
| 174 |
+
.rst ( rst ),
|
| 175 |
+
.clk ( clk ),
|
| 176 |
+
.snd_rstn ( snd_rstn ),
|
| 177 |
+
.fast_fm ( fast_fm ),
|
| 178 |
+
.cen6 ( cen6 ),
|
| 179 |
+
.cen3 ( cen3 ),
|
| 180 |
+
.cen1p5 ( cen1p5 ),
|
| 181 |
+
.LVBL ( LVBL ),
|
| 182 |
+
// Game variations
|
| 183 |
+
`ifdef NOKABUKIZ
|
| 184 |
+
.kabuki ( 1'b0 ),
|
| 185 |
+
.kabuki_mod ( 1'b0 ),
|
| 186 |
+
`else
|
| 187 |
+
.kabuki ( kabuki ),
|
| 188 |
+
.kabuki_mod ( kabuki_mod ), // different memory map for TNZS
|
| 189 |
+
`endif
|
| 190 |
+
.kageki ( kageki ),
|
| 191 |
+
|
| 192 |
+
// PCM
|
| 193 |
+
.pcm_addr ( pcm_addr ),
|
| 194 |
+
.pcm_data ( pcm_data ),
|
| 195 |
+
.pcm_ok ( pcm_ok ),
|
| 196 |
+
.pcm_cs ( pcm_cs ),
|
| 197 |
+
|
| 198 |
+
// cabinet I/O
|
| 199 |
+
.cab_1p ( cab_1p[1:0] ),
|
| 200 |
+
.coin ( eff_coin ),
|
| 201 |
+
.joystick1 ( joystick1 ),
|
| 202 |
+
.joystick2 ( joystick2 ),
|
| 203 |
+
.service ( eff_service ),
|
| 204 |
+
.tilt ( tilt ),
|
| 205 |
+
.dial_x ( dial_x ),
|
| 206 |
+
.dial_y ( dial_y ),
|
| 207 |
+
// DIP switches
|
| 208 |
+
.dipsw ( dipsw[15:0] ),
|
| 209 |
+
.dip_pause ( dip_pause ),
|
| 210 |
+
|
| 211 |
+
// Shared RAM
|
| 212 |
+
.ram_addr ( shr_addr ),
|
| 213 |
+
.ram_din ( shr_din ),
|
| 214 |
+
.ram_dout ( shr_dout ),
|
| 215 |
+
.cpu_rnw ( sub_rnw ),
|
| 216 |
+
.ram_cs ( shr_cs ),
|
| 217 |
+
.mshramen ( mshramen ),
|
| 218 |
+
.pal_cs ( pal2_cs ),
|
| 219 |
+
.pal_dout ( pal_dout ),
|
| 220 |
+
// MCU
|
| 221 |
+
.mcu_en ( mcu_en ),
|
| 222 |
+
.prog_addr ( prog_addr[10:0]),
|
| 223 |
+
.prog_data ( prog_data ),
|
| 224 |
+
.prom_we ( mcuprom_we ),
|
| 225 |
+
|
| 226 |
+
// ROM
|
| 227 |
+
.rom_addr ( sub_addr ),
|
| 228 |
+
.rom_cs ( sub_cs ),
|
| 229 |
+
.rom_data ( sub_data ),
|
| 230 |
+
|
| 231 |
+
.audiocpu_addr ( audiocpu_addr ),
|
| 232 |
+
.audiocpu_cs ( audiocpu_cs ),
|
| 233 |
+
.audiocpu_data ( audiocpu_data ),
|
| 234 |
+
.audiocpu_ok ( audiocpu_ok ),
|
| 235 |
+
|
| 236 |
+
// Sound output
|
| 237 |
+
.f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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a dma_bsy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 18-09-2022 */
|
| 18 |
+
|
| 19 |
+
// There is bus contention to access the memories
|
| 20 |
+
// in this module, based. When H4 is high, the
|
| 21 |
+
// GPU is in control. When H4 is low, it's the CPU
|
| 22 |
+
|
| 23 |
+
module jtkiwi_gfx(
|
| 24 |
+
input rst,
|
| 25 |
+
input clk,
|
| 26 |
+
input clk_cpu,
|
| 27 |
+
|
| 28 |
+
input pxl2_cen,
|
| 29 |
+
input pxl_cen,
|
| 30 |
+
|
| 31 |
+
input LHBL,
|
| 32 |
+
input LVBL,
|
| 33 |
+
input hs,
|
| 34 |
+
input vs,
|
| 35 |
+
output flip,
|
| 36 |
+
|
| 37 |
+
input [ 8:0] vdump,
|
| 38 |
+
input [ 8:0] vrender,
|
| 39 |
+
input [ 8:0] hdump,
|
| 40 |
+
|
| 41 |
+
input cpu_rnw,
|
| 42 |
+
input [12:0] cpu_addr,
|
| 43 |
+
input [ 7:0] cpu_dout,
|
| 44 |
+
input vram_cs,
|
| 45 |
+
input vctrl_cs,
|
| 46 |
+
input vflag_cs,
|
| 47 |
+
output [ 7:0] cpu_din,
|
| 48 |
+
|
| 49 |
+
// SDRAM interface
|
| 50 |
+
output [20:2] scr_addr,
|
| 51 |
+
input [31:0] scr_data,
|
| 52 |
+
input scr_ok,
|
| 53 |
+
output scr_cs,
|
| 54 |
+
|
| 55 |
+
output [20:2] obj_addr,
|
| 56 |
+
input [31:0] obj_data,
|
| 57 |
+
input obj_ok,
|
| 58 |
+
output obj_cs,
|
| 59 |
+
|
| 60 |
+
output [ 8:0] scr_pxl,
|
| 61 |
+
output [ 8:0] obj_pxl,
|
| 62 |
+
input [ 7:0] debug_bus,
|
| 63 |
+
output [ 7:0] st_dout
|
| 64 |
+
);
|
| 65 |
+
|
| 66 |
+
wire yram_we, video_en;
|
| 67 |
+
wire [ 1:0] vram_we;
|
| 68 |
+
wire [11:0] tm_addr, lut_addr;
|
| 69 |
+
reg [11:0] code_addr;
|
| 70 |
+
reg [ 9:0] col_addr;
|
| 71 |
+
wire [ 7:0] yram_dout, col_data;
|
| 72 |
+
wire [ 7:0] scol_addr;
|
| 73 |
+
reg [ 7:0] attr, xpos, ypos;
|
| 74 |
+
reg [ 7:0] cfg[0:3], flag;
|
| 75 |
+
reg scan_cen, done, dr_start, dr_busy,
|
| 76 |
+
match, xflip, yflip,
|
| 77 |
+
yram_cs, cfg_cs;
|
| 78 |
+
reg [ 2:0] st;
|
| 79 |
+
reg [13:0] code;
|
| 80 |
+
reg [ 1:0] cen_cnt;
|
| 81 |
+
wire tm_page, obj_bufb;
|
| 82 |
+
wire [15:0] vram_dout, code_dout, col_xmsb;
|
| 83 |
+
wire [ 3:0] col_cfg;
|
| 84 |
+
wire [ 1:0] col0;
|
| 85 |
+
reg tm_cen, lut_cen;
|
| 86 |
+
// Objects
|
| 87 |
+
wire [ 8:0] y_addr;
|
| 88 |
+
|
| 89 |
+
`ifdef SIMULATION
|
| 90 |
+
wire [7:0] cfg0 = cfg[0], cfg1 = cfg[1], cfg2 = cfg[2], cfg3 = cfg[3];
|
| 91 |
+
`endif
|
| 92 |
+
|
| 93 |
+
assign vram_we = {2{vram_cs & ~cpu_rnw}} & { cpu_addr[12], ~cpu_addr[12] };
|
| 94 |
+
assign yram_we = yram_cs & ~cpu_rnw;
|
| 95 |
+
assign flip = ~cfg[0][6]; // only flip y?
|
| 96 |
+
assign video_en = cfg[0][4]; // uncertain
|
| 97 |
+
assign col0 = cfg[0][1:0]; // start column in the tilemap VRAM
|
| 98 |
+
assign tm_page = cfg[1][6];
|
| 99 |
+
assign obj_bufb = cfg[1][5];
|
| 100 |
+
assign col_cfg = cfg[1][3:0];
|
| 101 |
+
assign col_xmsb = { cfg[3], cfg[2] };
|
| 102 |
+
assign cpu_din = yram_cs ? yram_dout :
|
| 103 |
+
vram_cs ? (cpu_addr[12] ? vram_dout[15:8] : vram_dout[7:0]) : 8'h00;
|
| 104 |
+
assign st_dout = { flip, video_en, col0, col_cfg };
|
| 105 |
+
|
| 106 |
+
always @* begin
|
| 107 |
+
yram_cs = 0;
|
| 108 |
+
cfg_cs = 0;
|
| 109 |
+
if( vctrl_cs ) case( cpu_addr[9:8] )
|
| 110 |
+
0,1,2: yram_cs = 1;
|
| 111 |
+
3: cfg_cs = 1;
|
| 112 |
+
default:;
|
| 113 |
+
endcase
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
always @(posedge clk, posedge rst) begin
|
| 117 |
+
if( rst ) begin
|
| 118 |
+
cen_cnt <= 0;
|
| 119 |
+
tm_cen <= 0;
|
| 120 |
+
lut_cen <= 0;
|
| 121 |
+
end else begin
|
| 122 |
+
cen_cnt <= cen_cnt + 1'd1;
|
| 123 |
+
tm_cen <= cen_cnt==0;
|
| 124 |
+
lut_cen <= cen_cnt==2;
|
| 125 |
+
end
|
| 126 |
+
end
|
| 127 |
+
|
| 128 |
+
`ifdef NOMAIN
|
| 129 |
+
initial $readmemh("seta_cfg.hex",cfg);
|
| 130 |
+
`endif
|
| 131 |
+
|
| 132 |
+
always @(posedge clk, posedge rst) begin
|
| 133 |
+
`ifndef NOMAIN
|
| 134 |
+
if( rst ) begin
|
| 135 |
+
cfg[0] <= 0;
|
| 136 |
+
cfg[1] <= 9;
|
| 137 |
+
cfg[2] <= 0;
|
| 138 |
+
cfg[3] <= 0;
|
| 139 |
+
end else
|
| 140 |
+
`endif
|
| 141 |
+
begin
|
| 142 |
+
if( cfg_cs ) cfg[ cpu_addr[1:0] ] <= cpu_dout;
|
| 143 |
+
if( vflag_cs ) flag <= cpu_dout;
|
| 144 |
+
end
|
| 145 |
+
end
|
| 146 |
+
|
| 147 |
+
always @* begin
|
| 148 |
+
case( cen_cnt )
|
| 149 |
+
0,1: begin
|
| 150 |
+
col_addr = { 2'b10, scol_addr };
|
| 151 |
+
code_addr = tm_addr;
|
| 152 |
+
end
|
| 153 |
+
2,3: begin // objects
|
| 154 |
+
col_addr = { 1'b0, y_addr };
|
| 155 |
+
code_addr = lut_addr;
|
| 156 |
+
end
|
| 157 |
+
endcase
|
| 158 |
+
end
|
| 159 |
+
|
| 160 |
+
jtkiwi_tilemap u_tilemap(
|
| 161 |
+
.rst ( rst ),
|
| 162 |
+
.clk ( clk ),
|
| 163 |
+
.pxl_cen ( pxl_cen ),
|
| 164 |
+
.tm_cen ( tm_cen ),
|
| 165 |
+
|
| 166 |
+
.hs ( hs ),
|
| 167 |
+
.flip ( flip ),
|
| 168 |
+
.page ( tm_page ),
|
| 169 |
+
|
| 170 |
+
.col_xmsb ( col_xmsb ),
|
| 171 |
+
.col_cfg ( col_cfg ),
|
| 172 |
+
.col0 ( col0 ),
|
| 173 |
+
|
| 174 |
+
.tm_addr ( tm_addr ),
|
| 175 |
+
.tm_data ( code_dout ),
|
| 176 |
+
|
| 177 |
+
// Column scroll
|
| 178 |
+
.col_addr ( scol_addr ),
|
| 179 |
+
.col_data ( col_data ),
|
| 180 |
+
|
| 181 |
+
.rom_addr ( scr_addr ),
|
| 182 |
+
.rom_cs ( scr_cs ),
|
| 183 |
+
.rom_ok ( scr_ok ),
|
| 184 |
+
.rom_data ( scr_data ),
|
| 185 |
+
|
| 186 |
+
.vrender ( vdump ),
|
| 187 |
+
.hdump ( hdump ),
|
| 188 |
+
.pxl ( scr_pxl ),
|
| 189 |
+
.debug_bus ( debug_bus )
|
| 190 |
+
);
|
| 191 |
+
|
| 192 |
+
jtkiwi_obj u_obj(
|
| 193 |
+
.rst ( rst ),
|
| 194 |
+
.clk ( clk ),
|
| 195 |
+
.lut_cen ( lut_cen ),
|
| 196 |
+
.pxl_cen ( pxl_cen ),
|
| 197 |
+
|
| 198 |
+
.hs ( hs ),
|
| 199 |
+
.flip ( flip ),
|
| 200 |
+
.page ( tm_page ^ ~obj_bufb),
|
| 201 |
+
|
| 202 |
+
.lut_addr ( lut_addr ),
|
| 203 |
+
.lut_data ( code_dout ),
|
| 204 |
+
|
| 205 |
+
// Column scroll
|
| 206 |
+
.y_addr ( y_addr ),
|
| 207 |
+
.y_data ( col_data ),
|
| 208 |
+
|
| 209 |
+
.rom_addr ( obj_addr ),
|
| 210 |
+
.rom_cs ( obj_cs ),
|
| 211 |
+
.rom_ok ( obj_ok ),
|
| 212 |
+
.rom_data ( obj_data ),
|
| 213 |
+
|
| 214 |
+
.vdump ( vdump ),
|
| 215 |
+
.hdump ( hdump ),
|
| 216 |
+
.pxl ( obj_pxl ),
|
| 217 |
+
.debug_bus ( debug_bus )
|
| 218 |
+
);
|
| 219 |
+
|
| 220 |
+
// This is an external memory chip. The original
|
| 221 |
+
// one is an 8-bit memory. Changed to 16-bit access
|
| 222 |
+
// to ease the drawing logic
|
| 223 |
+
// the upper byte refers to the upper half of the
|
| 224 |
+
// memory for the CPU
|
| 225 |
+
// In MAME the lower half is called spritecodelow
|
| 226 |
+
// and the upper spritecodehigh
|
| 227 |
+
|
| 228 |
+
reg [9:0] dma_addr;
|
| 229 |
+
reg LVBLl;
|
| 230 |
+
reg dma_st;
|
| 231 |
+
reg dma_obj = 0;
|
| 232 |
+
reg dma_tm = 0;
|
| 233 |
+
reg dma_start = 0;
|
| 234 |
+
wire dma_bsy = dma_obj | dma_tm;
|
| 235 |
+
|
| 236 |
+
// DMA when cfg[1][5] == 0
|
| 237 |
+
// Sprite DMA starts with VBLANK
|
| 238 |
+
// Tilemap DMA starts with writing to cfg[1]
|
| 239 |
+
always @(posedge clk) begin
|
| 240 |
+
if (cfg_cs && cpu_addr[1:0] == 1 && !cpu_rnw && !cpu_dout[5]) dma_start <= 1;
|
| 241 |
+
LVBLl <= LVBL;
|
| 242 |
+
|
| 243 |
+
if (~obj_bufb && LVBLl && !LVBL) begin
|
| 244 |
+
// Start sprite dma_bsy
|
| 245 |
+
dma_addr <= 0;
|
| 246 |
+
dma_obj <= 1;
|
| 247 |
+
dma_st <= 0;
|
| 248 |
+
end else if (dma_start && !dma_bsy) begin
|
| 249 |
+
// Start tilemap dma_bsy
|
| 250 |
+
dma_start <= 0;
|
| 251 |
+
dma_addr <= 0;
|
| 252 |
+
dma_tm <= 1;
|
| 253 |
+
dma_st <= 0;
|
| 254 |
+
end else if (dma_bsy && pxl_cen ) begin // executed at 6MHz. Needs confirmation from PCB measurements
|
| 255 |
+
dma_st <= ~dma_st;
|
| 256 |
+
if (!dma_st) begin
|
| 257 |
+
// read phase
|
| 258 |
+
;
|
| 259 |
+
end else begin
|
| 260 |
+
// write phase
|
| 261 |
+
dma_addr <= dma_addr + 1'd1;
|
| 262 |
+
if (&dma_addr) begin
|
| 263 |
+
dma_addr <= 0;
|
| 264 |
+
dma_obj <= 0;
|
| 265 |
+
dma_tm <= 0;
|
| 266 |
+
end
|
| 267 |
+
end
|
| 268 |
+
end
|
| 269 |
+
end
|
| 270 |
+
|
| 271 |
+
jtframe_dual_ram16 #(.AW(12),
|
| 272 |
+
.SIMFILE_LO("vram_lo.bin"),
|
| 273 |
+
.SIMFILE_HI("vram_hi.bin")
|
| 274 |
+
) u_vram(
|
| 275 |
+
.clk0 ( clk_cpu ),
|
| 276 |
+
.clk1 ( clk ),
|
| 277 |
+
// Main CPU
|
| 278 |
+
// probably the CPU should be WAIT-ed during DMA access, but it's
|
| 279 |
+
// very fast, thus there's no overlap with CPU VRAM access
|
| 280 |
+
.addr0 ( dma_bsy ? {dma_tm ^ tm_page ^ dma_st, dma_tm, dma_addr} : cpu_addr[11:0] ),
|
| 281 |
+
.data0 ( dma_bsy ? vram_dout : {2{cpu_dout}} ),
|
| 282 |
+
.we0 ( dma_bsy ? {2{dma_st}} : vram_we ),
|
| 283 |
+
.q0 ( vram_dout ),
|
| 284 |
+
// GFX
|
| 285 |
+
.addr1 ( code_addr ),
|
| 286 |
+
.data1 ( 16'd0 ),
|
| 287 |
+
.we1 ( 2'd0 ),
|
| 288 |
+
.q1 ( code_dout )
|
| 289 |
+
);
|
| 290 |
+
|
| 291 |
+
// This memory is internal to the SETA-X1-001 chip
|
| 292 |
+
// this is called spriteylow by MAME
|
| 293 |
+
jtframe_dual_ram #(.AW(10),.SIMFILE("col.bin")) u_yram(
|
| 294 |
+
.clk0 ( clk_cpu ),
|
| 295 |
+
.clk1 ( clk ),
|
| 296 |
+
// Main CPU
|
| 297 |
+
.addr0 (cpu_addr[9:0]),
|
| 298 |
+
.data0 ( cpu_dout ),
|
| 299 |
+
.we0 ( yram_we ),
|
| 300 |
+
.q0 ( yram_dout ),
|
| 301 |
+
// GFX
|
| 302 |
+
.addr1 ( col_addr ),
|
| 303 |
+
.data1 ( 8'd0 ),
|
| 304 |
+
.we1 ( 1'd0 ),
|
| 305 |
+
.q1 ( col_data )
|
| 306 |
+
);
|
| 307 |
+
|
| 308 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_main.v
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 17-9-2022 */
|
| 18 |
+
|
| 19 |
+
module jtkiwi_main(
|
| 20 |
+
input rst,
|
| 21 |
+
input clk,
|
| 22 |
+
input cen6,
|
| 23 |
+
input LVBL,
|
| 24 |
+
input colprom_en,
|
| 25 |
+
|
| 26 |
+
// Video devices
|
| 27 |
+
output reg vram_cs,
|
| 28 |
+
output reg vctrl_cs,
|
| 29 |
+
output reg vflag_cs,
|
| 30 |
+
output reg pal_cs,
|
| 31 |
+
input [ 7:0] pal_dout,
|
| 32 |
+
input [ 7:0] vram_dout,
|
| 33 |
+
input [ 8:0] hcnt,
|
| 34 |
+
|
| 35 |
+
output [12:0] cpu_addr,
|
| 36 |
+
output [ 7:0] cpu_dout,
|
| 37 |
+
output cpu_rnw,
|
| 38 |
+
|
| 39 |
+
// Sub CPU (sound)
|
| 40 |
+
output reg snd_rstn,
|
| 41 |
+
// access to RAM
|
| 42 |
+
input [12:0] shr_addr,
|
| 43 |
+
input [ 7:0] shr_din,
|
| 44 |
+
input sub_rnw,
|
| 45 |
+
input shr_cs,
|
| 46 |
+
output reg mshramen,
|
| 47 |
+
output [ 7:0] shr_dout,
|
| 48 |
+
|
| 49 |
+
input dip_pause,
|
| 50 |
+
|
| 51 |
+
// Banked RAM (TNZS)
|
| 52 |
+
input banked_ram,
|
| 53 |
+
input [ 7:0] bram_data,
|
| 54 |
+
output reg [14:0] bram_addr,
|
| 55 |
+
output reg bram_cs,
|
| 56 |
+
input bram_ok,
|
| 57 |
+
// ROM interface
|
| 58 |
+
output [16:0] rom_addr,
|
| 59 |
+
output reg rom_cs,
|
| 60 |
+
input [ 7:0] rom_data,
|
| 61 |
+
// Debug
|
| 62 |
+
input [ 7:0] debug_bus,
|
| 63 |
+
output [ 7:0] st_dout
|
| 64 |
+
);
|
| 65 |
+
`ifndef NOMAIN
|
| 66 |
+
wire irq_ack, mreq_n, m1_n, iorq_n, rd_n, wr_n,
|
| 67 |
+
rfsh_n, int_n, ram_we, cpu_cen;
|
| 68 |
+
reg [ 7:0] din;
|
| 69 |
+
wire [ 7:0] dout, ram_dout;
|
| 70 |
+
reg [ 2:0] bank;
|
| 71 |
+
wire [15:0] A;
|
| 72 |
+
reg ram_cs, bank_cs,
|
| 73 |
+
sshramen, dev_busy, obj_vram_en;
|
| 74 |
+
wire mem_acc;
|
| 75 |
+
|
| 76 |
+
assign cpu_rnw = wr_n | ~cpu_cen;
|
| 77 |
+
assign cpu_addr = A[12:0];
|
| 78 |
+
assign cpu_dout = dout;
|
| 79 |
+
assign irq_ack = /*!m1_n &&*/ !iorq_n; // The original PCB just uses iorq_n,
|
| 80 |
+
// the orthodox way to do it is to use m1_n too
|
| 81 |
+
assign ram_we = mshramen & ~wr_n;
|
| 82 |
+
assign rom_addr = { A[15] ? bank : {2'd0, A[14]}, A[13:0] };
|
| 83 |
+
assign st_dout = { 3'd0, ~snd_rstn, 1'd0, bank };
|
| 84 |
+
assign mem_acc = ~mreq_n & rfsh_n;
|
| 85 |
+
|
| 86 |
+
`ifdef SIMULATION
|
| 87 |
+
wire rombank_cs = rom_cs && A[15:12]>=8;
|
| 88 |
+
`endif
|
| 89 |
+
|
| 90 |
+
always @(posedge clk, posedge rst) begin
|
| 91 |
+
if ( rst ) begin
|
| 92 |
+
bram_cs <= 0;
|
| 93 |
+
rom_cs <= 0;
|
| 94 |
+
vram_cs <= 0;
|
| 95 |
+
ram_cs <= 0;
|
| 96 |
+
vctrl_cs <= 0;
|
| 97 |
+
vflag_cs <= 0;
|
| 98 |
+
bank_cs <= 0;
|
| 99 |
+
pal_cs <= 0;
|
| 100 |
+
bram_addr <= 0;
|
| 101 |
+
end else begin
|
| 102 |
+
bram_cs <= 0;
|
| 103 |
+
rom_cs <= mem_acc && A[15:12] < 4'hc;
|
| 104 |
+
vram_cs <= mem_acc && A[15:13] == 3'b110; // C,D
|
| 105 |
+
ram_cs <= mem_acc && A[15:12] == 4'he; // A[12:0] used in Insector X (?)
|
| 106 |
+
vctrl_cs <= mem_acc && A[15:10] == 6'b1111_00; // internal RAM and config registers
|
| 107 |
+
vflag_cs <= mem_acc && A[15: 9] == 7'b1111_010 && !wr_n; // config registers
|
| 108 |
+
bank_cs <= mem_acc && A[15: 9] == 7'b1111_011 && !wr_n; // f6xx/f7xx
|
| 109 |
+
pal_cs <= mem_acc && A[15:11] == 5'h1f && !colprom_en;
|
| 110 |
+
if( mem_acc && banked_ram && bank<2 && A[15:12]>=8 && A[15:12]<4'hc ) begin
|
| 111 |
+
rom_cs <= 0;
|
| 112 |
+
bram_cs <= 1;
|
| 113 |
+
bram_addr <= { bank[0], A[13:0] };
|
| 114 |
+
end
|
| 115 |
+
end
|
| 116 |
+
end
|
| 117 |
+
|
| 118 |
+
always @* begin
|
| 119 |
+
obj_vram_en = mem_acc && (
|
| 120 |
+
(A[15:11]==5'b11110 && !A[9]) ||
|
| 121 |
+
A[15:10]==6'b111100 ||
|
| 122 |
+
A[15:13]==3'b110 );
|
| 123 |
+
dev_busy = (sshramen & ram_cs) || (obj_vram_en && hcnt[1:0]!=0) || (bram_cs&&!bram_ok);
|
| 124 |
+
end
|
| 125 |
+
|
| 126 |
+
always @(posedge clk) begin
|
| 127 |
+
din <= rom_cs ? rom_data :
|
| 128 |
+
ram_cs ? ram_dout :
|
| 129 |
+
bram_cs ? bram_data :
|
| 130 |
+
(vram_cs | vctrl_cs) ? vram_dout :
|
| 131 |
+
pal_cs ? pal_dout : 8'h00;
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
always @(posedge clk, posedge rst) begin
|
| 135 |
+
if( rst ) begin
|
| 136 |
+
bank <= 0;
|
| 137 |
+
snd_rstn <= 0;
|
| 138 |
+
end else begin
|
| 139 |
+
if( bank_cs ) begin
|
| 140 |
+
bank <= dout[2:0];
|
| 141 |
+
snd_rstn <= dout[4];
|
| 142 |
+
`ifdef SIMULATION
|
| 143 |
+
if( !snd_rstn && dout[4] ) $display("Sound CPU reset released");
|
| 144 |
+
if( snd_rstn && !dout[4] ) $display("Sound CPU reset");
|
| 145 |
+
`endif
|
| 146 |
+
end
|
| 147 |
+
end
|
| 148 |
+
end
|
| 149 |
+
|
| 150 |
+
`ifdef SIMULATION
|
| 151 |
+
integer line_cnt=1;
|
| 152 |
+
|
| 153 |
+
always @(negedge ram_cs, posedge rst) begin
|
| 154 |
+
if( rst )
|
| 155 |
+
line_cnt <= 1;
|
| 156 |
+
else
|
| 157 |
+
line_cnt <= line_cnt+1;
|
| 158 |
+
end
|
| 159 |
+
`endif
|
| 160 |
+
|
| 161 |
+
jtframe_ff u_irq(
|
| 162 |
+
.clk ( clk ),
|
| 163 |
+
.rst ( rst ),
|
| 164 |
+
.cen ( 1'b1 ),
|
| 165 |
+
.din ( 1'b1 ),
|
| 166 |
+
.q ( ),
|
| 167 |
+
.qn ( int_n ),
|
| 168 |
+
.set ( 1'b0 ),
|
| 169 |
+
.clr ( irq_ack ),
|
| 170 |
+
.sigedge( ~LVBL & dip_pause )
|
| 171 |
+
);
|
| 172 |
+
|
| 173 |
+
// To do: add dev_busy to match the wait signal
|
| 174 |
+
// when accessing the VRAM
|
| 175 |
+
jtframe_z80_devwait #(.RECOVERY(0)) u_gamecpu(
|
| 176 |
+
.rst_n ( ~rst ),
|
| 177 |
+
.clk ( clk ),
|
| 178 |
+
.cen ( cen6 ),
|
| 179 |
+
.cpu_cen ( cpu_cen),
|
| 180 |
+
`ifdef NOINT
|
| 181 |
+
.int_n ( 1'b1 ),
|
| 182 |
+
`else
|
| 183 |
+
.int_n ( int_n ),
|
| 184 |
+
`endif
|
| 185 |
+
.nmi_n ( 1'b1 ),
|
| 186 |
+
.busrq_n ( 1'b1 ),
|
| 187 |
+
.m1_n ( m1_n ),
|
| 188 |
+
.mreq_n ( mreq_n ),
|
| 189 |
+
.iorq_n ( iorq_n ),
|
| 190 |
+
.rd_n ( rd_n ),
|
| 191 |
+
.wr_n ( wr_n ),
|
| 192 |
+
.rfsh_n ( rfsh_n ),
|
| 193 |
+
.halt_n ( ),
|
| 194 |
+
.busak_n ( ),
|
| 195 |
+
.A ( A ),
|
| 196 |
+
.din ( din ),
|
| 197 |
+
.dout ( dout ),
|
| 198 |
+
.rom_cs ( rom_cs ),
|
| 199 |
+
.rom_ok ( 1'b1 ),
|
| 200 |
+
.dev_busy ( dev_busy )
|
| 201 |
+
);
|
| 202 |
+
|
| 203 |
+
// first come, first served
|
| 204 |
+
always @(posedge clk, posedge rst) begin
|
| 205 |
+
if( rst ) begin
|
| 206 |
+
mshramen <= 0;
|
| 207 |
+
sshramen <= 0;
|
| 208 |
+
end else begin
|
| 209 |
+
// Main CPU drives the RAM
|
| 210 |
+
if( ram_cs && !sshramen )
|
| 211 |
+
mshramen <= 1;
|
| 212 |
+
if( !ram_cs ) mshramen <= 0;
|
| 213 |
+
// Sub CPU drives the RAM
|
| 214 |
+
if( shr_cs && !mshramen && !ram_cs )
|
| 215 |
+
sshramen <= 1;
|
| 216 |
+
if( !shr_cs ) sshramen <= 0;
|
| 217 |
+
end
|
| 218 |
+
end
|
| 219 |
+
|
| 220 |
+
jtframe_dual_ram #(.AW(13),.DUMPFILE("mainmem")) u_comm(
|
| 221 |
+
.clk0 ( clk ),
|
| 222 |
+
.clk1 ( clk ),
|
| 223 |
+
// Main CPU
|
| 224 |
+
.addr0 ( A[12:0] ),
|
| 225 |
+
.data0 ( dout ),
|
| 226 |
+
.we0 ( ram_we ),
|
| 227 |
+
.q0 ( ram_dout ),
|
| 228 |
+
// MCU
|
| 229 |
+
.addr1 ( shr_addr ),
|
| 230 |
+
.data1 ( shr_din ),
|
| 231 |
+
.we1 ( sshramen & ~sub_rnw ),
|
| 232 |
+
.q1 ( shr_dout )
|
| 233 |
+
`ifdef JTFRAME_DUAL_RAM_DUMP
|
| 234 |
+
,.dump ( LVBL )
|
| 235 |
+
`endif
|
| 236 |
+
);
|
| 237 |
+
`else // NOMAIN
|
| 238 |
+
initial begin
|
| 239 |
+
rom_cs = 0;
|
| 240 |
+
rom_addr = 0;
|
| 241 |
+
vram_cs = 0;
|
| 242 |
+
vflag_cs = 0;
|
| 243 |
+
vctrl_cs = 0;
|
| 244 |
+
pal_cs = 0;
|
| 245 |
+
snd_rstn = 0;
|
| 246 |
+
mshramen = 0;
|
| 247 |
+
end
|
| 248 |
+
assign cpu_rnw = 1;
|
| 249 |
+
assign cpu_addr = 1;
|
| 250 |
+
assign cpu_dout = 0;
|
| 251 |
+
assign shr_dout = 0;
|
| 252 |
+
assign st_dout = 0;
|
| 253 |
+
`endif
|
| 254 |
+
endmodule
|
snapshots/jotego_jt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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 7-11-2022 */
|
| 18 |
+
|
| 19 |
+
// This is object processor section of the SETA chip
|
| 20 |
+
|
| 21 |
+
module jtkiwi_obj(
|
| 22 |
+
input rst,
|
| 23 |
+
input clk,
|
| 24 |
+
input lut_cen,
|
| 25 |
+
input pxl_cen,
|
| 26 |
+
|
| 27 |
+
input hs,
|
| 28 |
+
input flip,
|
| 29 |
+
input page,
|
| 30 |
+
|
| 31 |
+
output [11:0] lut_addr,
|
| 32 |
+
input [15:0] lut_data,
|
| 33 |
+
|
| 34 |
+
output [ 8:0] y_addr,
|
| 35 |
+
input [ 7:0] y_data,
|
| 36 |
+
|
| 37 |
+
output [20:2] rom_addr,
|
| 38 |
+
output rom_cs,
|
| 39 |
+
input rom_ok,
|
| 40 |
+
input [31:0] rom_data,
|
| 41 |
+
|
| 42 |
+
input [ 8:0] vdump,
|
| 43 |
+
input [ 8:0] hdump,
|
| 44 |
+
output [ 8:0] pxl,
|
| 45 |
+
|
| 46 |
+
input [ 7:0] debug_bus
|
| 47 |
+
);
|
| 48 |
+
|
| 49 |
+
reg done;
|
| 50 |
+
reg [ 8:0] objcnt;
|
| 51 |
+
reg [ 4:0] pal, dr_pal;
|
| 52 |
+
reg [ 3:0] dr_ysub, ysub;
|
| 53 |
+
reg [ 8:0] ydiff, dr_xpos;
|
| 54 |
+
reg [ 8:0] xpos;
|
| 55 |
+
wire [ 8:0] vf;
|
| 56 |
+
reg [ 1:0] st;
|
| 57 |
+
reg dr_draw, dr_hflip, dr_vflip,
|
| 58 |
+
match, vflip, hflip;
|
| 59 |
+
reg [15:0] code;
|
| 60 |
+
reg [13:0] dr_code;
|
| 61 |
+
wire dr_busy;
|
| 62 |
+
wire [ 8:0] buf_din, buf_addr;
|
| 63 |
+
wire buf_we;
|
| 64 |
+
|
| 65 |
+
assign lut_addr = { page, 1'b0, ~st[1], objcnt }; // 1 + 1 + 1 + 9 = 12
|
| 66 |
+
assign y_addr = objcnt;
|
| 67 |
+
assign vf = {9{flip}} ^ (vdump-9'd1);
|
| 68 |
+
|
| 69 |
+
always @* begin
|
| 70 |
+
ydiff = { 1'b0, vf[7:0] } - {1'b0, y_data };
|
| 71 |
+
match = ydiff[8:4]==0;
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
// Columns are 32-pixel wide
|
| 75 |
+
always @(posedge clk, posedge rst) begin
|
| 76 |
+
if( rst ) begin
|
| 77 |
+
st <= 0;
|
| 78 |
+
objcnt <= 0;
|
| 79 |
+
dr_draw <= 0;
|
| 80 |
+
dr_code <= 0;
|
| 81 |
+
dr_pal <= 0;
|
| 82 |
+
dr_hflip<= 0;
|
| 83 |
+
dr_vflip<= 0;
|
| 84 |
+
dr_xpos <= 0;
|
| 85 |
+
dr_ysub <= 0;
|
| 86 |
+
end else begin
|
| 87 |
+
dr_draw <= 0;
|
| 88 |
+
if( hs || vdump>9'hf8 ) begin
|
| 89 |
+
objcnt <= 9'h1ff;
|
| 90 |
+
done <= 0;
|
| 91 |
+
st <= 0;
|
| 92 |
+
dr_draw <= 0;
|
| 93 |
+
end else if( !done && lut_cen ) begin
|
| 94 |
+
st <= st + 1'd1;
|
| 95 |
+
case( st )
|
| 96 |
+
0: begin
|
| 97 |
+
ysub <= ydiff[3:0];
|
| 98 |
+
if( !match ) begin
|
| 99 |
+
objcnt <= objcnt - 1'd1;
|
| 100 |
+
st <= 0;
|
| 101 |
+
done <= objcnt==0;
|
| 102 |
+
end
|
| 103 |
+
end
|
| 104 |
+
1: { pal, code[15:14], xpos } <= lut_data;
|
| 105 |
+
2: { hflip, vflip, code[13:0] } <= lut_data;
|
| 106 |
+
3: begin
|
| 107 |
+
if( !dr_busy ) begin
|
| 108 |
+
dr_draw <= 1;
|
| 109 |
+
dr_code <= code[13:0];
|
| 110 |
+
dr_hflip <= hflip^flip;
|
| 111 |
+
dr_vflip <= vflip;
|
| 112 |
+
dr_pal <= pal;
|
| 113 |
+
dr_xpos <= xpos;
|
| 114 |
+
dr_ysub <= ~ysub;
|
| 115 |
+
objcnt <= objcnt - 1'd1;
|
| 116 |
+
done <= objcnt==0;
|
| 117 |
+
end else begin
|
| 118 |
+
st <= st;
|
| 119 |
+
end
|
| 120 |
+
end
|
| 121 |
+
endcase
|
| 122 |
+
end
|
| 123 |
+
end
|
| 124 |
+
end
|
| 125 |
+
|
| 126 |
+
jtkiwi_draw #(.SWAP_HALVES(1'b1)) u_draw (
|
| 127 |
+
.rst ( rst ),
|
| 128 |
+
.clk ( clk ),
|
| 129 |
+
|
| 130 |
+
.draw ( dr_draw ),
|
| 131 |
+
.busy ( dr_busy ),
|
| 132 |
+
.code ( dr_code ),
|
| 133 |
+
.pal ( dr_pal ),
|
| 134 |
+
.hflip ( dr_hflip ),
|
| 135 |
+
.vflip ( dr_vflip ),
|
| 136 |
+
.xpos ( dr_xpos ),
|
| 137 |
+
.ysub ( dr_ysub ),
|
| 138 |
+
.flip ( flip ),
|
| 139 |
+
|
| 140 |
+
.rom_addr ( rom_addr ),
|
| 141 |
+
.rom_cs ( rom_cs ),
|
| 142 |
+
.rom_ok ( rom_ok ),
|
| 143 |
+
.rom_data ( rom_data ),
|
| 144 |
+
|
| 145 |
+
.buf_addr ( buf_addr ),
|
| 146 |
+
.buf_we ( buf_we ),
|
| 147 |
+
.buf_din ( buf_din ),
|
| 148 |
+
.debug_bus ( 8'd0 )
|
| 149 |
+
//.debug_bus ( debug_bus )
|
| 150 |
+
);
|
| 151 |
+
|
| 152 |
+
// During HS the contents of the memory are cleared
|
| 153 |
+
|
| 154 |
+
jtframe_obj_buffer #(
|
| 155 |
+
.DW ( 9 ),
|
| 156 |
+
.ALPHA( 0 ),
|
| 157 |
+
.FLIP_OFFSET(9'h100)
|
| 158 |
+
) u_linebuf(
|
| 159 |
+
.clk ( clk ),
|
| 160 |
+
.flip ( 1'b0 ),
|
| 161 |
+
.LHBL ( ~hs ),
|
| 162 |
+
// New line writting
|
| 163 |
+
.we ( buf_we ),
|
| 164 |
+
.wr_data( buf_din ),
|
| 165 |
+
.wr_addr( buf_addr ),
|
| 166 |
+
// Previous line reading
|
| 167 |
+
.rd ( pxl_cen ),
|
| 168 |
+
.rd_addr( hdump ),
|
| 169 |
+
.rd_data( pxl )
|
| 170 |
+
);
|
| 171 |
+
|
| 172 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_snd.v
ADDED
|
@@ -0,0 +1,543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 18-9-2022 */
|
| 18 |
+
|
| 19 |
+
module jtkiwi_snd(
|
| 20 |
+
input rst,
|
| 21 |
+
input clk,
|
| 22 |
+
input cen6,
|
| 23 |
+
input cen3,
|
| 24 |
+
input cen1p5,
|
| 25 |
+
|
| 26 |
+
input LVBL,
|
| 27 |
+
input fast_fm,
|
| 28 |
+
|
| 29 |
+
// MCU
|
| 30 |
+
input mcu_en,
|
| 31 |
+
input kabuki,
|
| 32 |
+
input kabuki_mod,
|
| 33 |
+
input kageki,
|
| 34 |
+
input [10:0] prog_addr, // 2kB
|
| 35 |
+
input [ 7:0] prog_data,
|
| 36 |
+
input prom_we,
|
| 37 |
+
|
| 38 |
+
// Cabinet inputs
|
| 39 |
+
input [ 1:0] cab_1p,
|
| 40 |
+
input [ 1:0] coin,
|
| 41 |
+
input [ 6:0] joystick1,
|
| 42 |
+
input [ 6:0] joystick2,
|
| 43 |
+
input [ 1:0] dial_x,
|
| 44 |
+
input [ 1:0] dial_y,
|
| 45 |
+
|
| 46 |
+
// ROM interface
|
| 47 |
+
output reg [15:0] rom_addr,
|
| 48 |
+
output reg rom_cs,
|
| 49 |
+
input [ 7:0] rom_data,
|
| 50 |
+
|
| 51 |
+
// Audio CPU (Z80)
|
| 52 |
+
output [16:0] audiocpu_addr,
|
| 53 |
+
output audiocpu_cs,
|
| 54 |
+
input [ 7:0] audiocpu_data,
|
| 55 |
+
input audiocpu_ok,
|
| 56 |
+
|
| 57 |
+
// Sub CPU (sound)
|
| 58 |
+
input snd_rstn,
|
| 59 |
+
|
| 60 |
+
// PCM (Kageki)
|
| 61 |
+
output reg [15:0] pcm_addr,
|
| 62 |
+
input [ 7:0] pcm_data,
|
| 63 |
+
input pcm_ok,
|
| 64 |
+
output pcm_cs,
|
| 65 |
+
// access to RAM
|
| 66 |
+
output [12:0] ram_addr,
|
| 67 |
+
output [ 7:0] ram_din,
|
| 68 |
+
output cpu_rnw,
|
| 69 |
+
output reg ram_cs,
|
| 70 |
+
input [ 7:0] ram_dout,
|
| 71 |
+
input mshramen,
|
| 72 |
+
output reg pal_cs,
|
| 73 |
+
input [ 7:0] pal_dout,
|
| 74 |
+
|
| 75 |
+
// DIP switches
|
| 76 |
+
input dip_pause,
|
| 77 |
+
input service,
|
| 78 |
+
input tilt,
|
| 79 |
+
input [15:0] dipsw,
|
| 80 |
+
|
| 81 |
+
// Sound output
|
| 82 |
+
output signed [15:0] fm,
|
| 83 |
+
output [ 9:0] psg,
|
| 84 |
+
output [ 7:0] pcm,
|
| 85 |
+
// Debug
|
| 86 |
+
input [ 7:0] debug_bus,
|
| 87 |
+
input [ 7:0] st_addr,
|
| 88 |
+
output reg [ 7:0] st_dout
|
| 89 |
+
);
|
| 90 |
+
`ifndef NOSOUND
|
| 91 |
+
|
| 92 |
+
wire irq_ack, mreq_n, m1_n, iorq_n, rd_n, wr_n, sample,
|
| 93 |
+
fmint_n, int_n, cpu_cen, rfsh_n;
|
| 94 |
+
reg [ 7:0] din, cab_dout, psg_gain, p1_din, porta_din;
|
| 95 |
+
wire [ 7:0] fm_dout, dout, p2_din, p2_dout, mcu_dout, mcu_st, porta_dout, portb_dout,
|
| 96 |
+
dial_dout, p1_dout;
|
| 97 |
+
reg [ 1:0] bank, dial_rst;
|
| 98 |
+
wire [15:0] A;
|
| 99 |
+
reg bank_cs, fm_cs, cab_cs, mcu_cs, dial_cs, kabuki_dipsnd,
|
| 100 |
+
dev_busy, fm_busy, fmcs_l,
|
| 101 |
+
mcu_rstn, comb_rstn=0;
|
| 102 |
+
wire mem_acc, mcu_comb_rst;
|
| 103 |
+
wire [1:0] mcu_we, mcu_rd;
|
| 104 |
+
|
| 105 |
+
`ifdef SIMULATION
|
| 106 |
+
wire shared_rd = ram_cs && !A[0] && !rd_n;
|
| 107 |
+
wire shared_wr = ram_cs && !A[0] && !wr_n;
|
| 108 |
+
`endif
|
| 109 |
+
|
| 110 |
+
assign mem_acc = ~mreq_n & rfsh_n;
|
| 111 |
+
assign ram_din = dout;
|
| 112 |
+
assign ram_addr = A[12:0];
|
| 113 |
+
assign cpu_rnw = wr_n | ~cpu_cen;
|
| 114 |
+
assign mcu_comb_rst = ~(mcu_rstn & comb_rstn);
|
| 115 |
+
// assign mcu_comb_rst = ~comb_rstn;
|
| 116 |
+
assign p2_din = { 6'h3f, tilt, service };
|
| 117 |
+
assign pcm_cs = kageki;
|
| 118 |
+
assign mcu_we = {2{mcu_cs & ~wr_n}} & { A[0], ~A[0] };
|
| 119 |
+
assign mcu_rd = {2{mcu_cs & ~rd_n}} & { A[0], ~A[0] };
|
| 120 |
+
assign pcm = kabuki ? portb_dout : pcm_re;
|
| 121 |
+
|
| 122 |
+
assign irq_ack = /*!m1_n &&*/ !iorq_n; // The original PCB just uses iorq_n,
|
| 123 |
+
// the orthodox way to do it is to use m1_n too
|
| 124 |
+
|
| 125 |
+
always @* begin
|
| 126 |
+
rom_addr = A;
|
| 127 |
+
if( A[15] ) begin // Bank access
|
| 128 |
+
rom_addr[14:13] = bank;
|
| 129 |
+
end
|
| 130 |
+
end
|
| 131 |
+
|
| 132 |
+
always @* begin
|
| 133 |
+
dev_busy = mshramen & ram_cs | fm_busy;
|
| 134 |
+
end
|
| 135 |
+
|
| 136 |
+
always @(posedge clk) begin
|
| 137 |
+
comb_rstn <= snd_rstn & ~rst;
|
| 138 |
+
if( cen6 ) begin
|
| 139 |
+
fmcs_l <= fm_cs;
|
| 140 |
+
fm_busy <= fm_cs & ~fmcs_l;
|
| 141 |
+
end
|
| 142 |
+
end
|
| 143 |
+
|
| 144 |
+
always @(posedge clk) begin
|
| 145 |
+
rom_cs <= mem_acc && A[15:12] < 4'ha;
|
| 146 |
+
bank_cs <= mem_acc && A[15:12] == 4'ha; // this cleans the watchdog counter - not implemented
|
| 147 |
+
fm_cs <= mem_acc && A[15:12] == 4'hb && !kabuki;
|
| 148 |
+
kabuki_dipsnd <= mem_acc && A[15:12] == 4'hb && kabuki;
|
| 149 |
+
cab_cs <= mem_acc && A[15:12] == 4'hc && !mcu_en;
|
| 150 |
+
mcu_cs <= mem_acc && A[15:12] == 4'hc && mcu_en;
|
| 151 |
+
ram_cs <= mem_acc && (A[15:12] == 4'hd || A[15:12] == 4'he);
|
| 152 |
+
dial_cs <= mem_acc && A[15:12] == 4'hf;
|
| 153 |
+
pal_cs <= mem_acc && A[15:12] == 4'hf && (A[11] ^ kabuki_mod) && !A[10] && kabuki;
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
always @(posedge clk, negedge comb_rstn) begin
|
| 157 |
+
if( !comb_rstn ) begin
|
| 158 |
+
bank <= 0;
|
| 159 |
+
mcu_rstn <= 1;
|
| 160 |
+
dial_rst <= 0;
|
| 161 |
+
end else begin
|
| 162 |
+
if( bank_cs ) begin
|
| 163 |
+
bank <= dout[1:0];
|
| 164 |
+
dial_rst <= dout[3:2];
|
| 165 |
+
mcu_rstn <= dout[4];
|
| 166 |
+
`ifdef SIMULATION
|
| 167 |
+
if( !mcu_rstn && dout[4] ) $display("MCU reset released");
|
| 168 |
+
if( mcu_rstn && !dout[4] ) $display("MCU reset");
|
| 169 |
+
`endif
|
| 170 |
+
end
|
| 171 |
+
end
|
| 172 |
+
end
|
| 173 |
+
|
| 174 |
+
wire [7:0] kabuki_dipsw = A[0] ? dipsw[15:8] : dipsw[7:0];
|
| 175 |
+
|
| 176 |
+
always @(posedge clk) begin
|
| 177 |
+
if( !dip_pause )
|
| 178 |
+
cab_dout <= 8'hff; // do not let inputs disturb the pause
|
| 179 |
+
else begin
|
| 180 |
+
case( A[2:0] )
|
| 181 |
+
0: cab_dout <= { cab_1p[0], joystick1 };
|
| 182 |
+
1: cab_dout <= { cab_1p[1], joystick2 };
|
| 183 |
+
2: cab_dout <= (kabuki | kageki) ?
|
| 184 |
+
{ 2'h3, coin[1], coin[0], 2'h3, tilt, service } :
|
| 185 |
+
{ 4'hf, coin[0], coin[1], tilt, service };
|
| 186 |
+
// 3: cab_dout <= { 7'h7f, ~coin[0] };
|
| 187 |
+
// 4: cab_dout <= { 7'h7f, ~coin[1] };
|
| 188 |
+
default: cab_dout <= 8'h00;
|
| 189 |
+
endcase
|
| 190 |
+
end
|
| 191 |
+
din <= rom_cs ? rom_data :
|
| 192 |
+
ram_cs ? ram_dout :
|
| 193 |
+
fm_cs ? fm_dout :
|
| 194 |
+
mcu_cs ? mcu_dout :
|
| 195 |
+
cab_cs ? cab_dout :
|
| 196 |
+
pal_cs ? pal_dout :
|
| 197 |
+
(kabuki_dipsnd & !A[2]) ? kabuki_dipsw :
|
| 198 |
+
dial_cs ? dial_dout :
|
| 199 |
+
8'h00;
|
| 200 |
+
end
|
| 201 |
+
|
| 202 |
+
always @(posedge clk) begin
|
| 203 |
+
case( p2_dout[2:0] )
|
| 204 |
+
3'h4: p1_din <= { cab_1p[0], joystick1 };
|
| 205 |
+
3'h5: p1_din <= { cab_1p[1], joystick2 };
|
| 206 |
+
3'h2: p1_din <= { 6'h3f, tilt, service };
|
| 207 |
+
default: p1_din <= 8'hff;
|
| 208 |
+
endcase
|
| 209 |
+
end
|
| 210 |
+
|
| 211 |
+
// Kageki's PCM
|
| 212 |
+
reg [7:0] pcm_lsb, pcm_re;
|
| 213 |
+
wire [7:0] pcm_dcrm;
|
| 214 |
+
reg [1:0] pcm_st;
|
| 215 |
+
reg [2:0] pcm_cnt;
|
| 216 |
+
reg pcm_cen, sample_l, pb7l;
|
| 217 |
+
|
| 218 |
+
always @(posedge clk, negedge comb_rstn) begin
|
| 219 |
+
if( !comb_rstn ) begin
|
| 220 |
+
pcm_cnt <= 1;
|
| 221 |
+
pcm_cen <= 0;
|
| 222 |
+
sample_l <= 0;
|
| 223 |
+
end else begin
|
| 224 |
+
sample_l <= sample;
|
| 225 |
+
pcm_cen <= 0;
|
| 226 |
+
if( sample && !sample_l ) begin
|
| 227 |
+
pcm_cnt <= { pcm_cnt[1:0], pcm_cnt[2] };
|
| 228 |
+
pcm_cen <= pcm_cnt[2];
|
| 229 |
+
end
|
| 230 |
+
end
|
| 231 |
+
end
|
| 232 |
+
|
| 233 |
+
always @(posedge clk) begin
|
| 234 |
+
case( st_addr[5:4] )
|
| 235 |
+
0: st_dout <= { 3'd0, mcu_en, 3'd0, mcu_comb_rst };
|
| 236 |
+
1: st_dout <= mcu_st;
|
| 237 |
+
2: case( st_addr[1:0])
|
| 238 |
+
0: st_dout <= { pcm_st, portb_dout[5:0] };
|
| 239 |
+
1: st_dout <= pcm_addr[15:8];
|
| 240 |
+
2: st_dout <= pcm_re;
|
| 241 |
+
default: st_dout <= 0;
|
| 242 |
+
endcase
|
| 243 |
+
3: case( st_addr[1:0] )
|
| 244 |
+
0: st_dout <= p1_din;
|
| 245 |
+
1: st_dout <= p2_din;
|
| 246 |
+
3: st_dout <= p2_dout;
|
| 247 |
+
default: st_dout <= 0;
|
| 248 |
+
endcase
|
| 249 |
+
endcase
|
| 250 |
+
end
|
| 251 |
+
|
| 252 |
+
always @(posedge clk, negedge comb_rstn) begin
|
| 253 |
+
if( !comb_rstn ) begin
|
| 254 |
+
pcm_st <= 0;
|
| 255 |
+
pcm_addr <= 0;
|
| 256 |
+
pcm_re <= 8'h80;
|
| 257 |
+
pb7l <= 0;
|
| 258 |
+
end else begin
|
| 259 |
+
pb7l <= portb_dout[7];
|
| 260 |
+
if( pcm_cen && pcm_ok ) begin
|
| 261 |
+
case( pcm_st )
|
| 262 |
+
default:;
|
| 263 |
+
1: begin
|
| 264 |
+
pcm_lsb <= pcm_data;
|
| 265 |
+
pcm_addr[0] <= 1;
|
| 266 |
+
pcm_st <= 2;
|
| 267 |
+
end
|
| 268 |
+
2: begin
|
| 269 |
+
pcm_addr <= { pcm_data, pcm_lsb };
|
| 270 |
+
pcm_st <= 3;
|
| 271 |
+
end
|
| 272 |
+
3: begin
|
| 273 |
+
if( pcm_data == 0 || (&pcm_addr) ) begin
|
| 274 |
+
pcm_st <= 0;
|
| 275 |
+
pcm_re <= 8'h80;
|
| 276 |
+
end else begin
|
| 277 |
+
// the 0 value is not part of the sample.
|
| 278 |
+
// pcm_re will keep the last valid value
|
| 279 |
+
// this prevents noise at the start and end of samples
|
| 280 |
+
pcm_re <= pcm_data;
|
| 281 |
+
end
|
| 282 |
+
pcm_addr <= pcm_addr + 1'd1;
|
| 283 |
+
end
|
| 284 |
+
endcase
|
| 285 |
+
end
|
| 286 |
+
if( portb_dout[7] && !pb7l ) begin
|
| 287 |
+
pcm_st <= 1;
|
| 288 |
+
pcm_addr <= { 9'd0, portb_dout[5:0], 1'b0 } + 16'h90;
|
| 289 |
+
end
|
| 290 |
+
end
|
| 291 |
+
end
|
| 292 |
+
|
| 293 |
+
`ifdef SIMULATION
|
| 294 |
+
integer line_cnt=1;
|
| 295 |
+
|
| 296 |
+
always @(negedge ram_cs, posedge rst) begin
|
| 297 |
+
if( rst )
|
| 298 |
+
line_cnt <= 1;
|
| 299 |
+
else
|
| 300 |
+
line_cnt <= line_cnt+1;
|
| 301 |
+
end
|
| 302 |
+
`endif
|
| 303 |
+
|
| 304 |
+
jtframe_ff u_irq(
|
| 305 |
+
.clk ( clk ),
|
| 306 |
+
.rst ( ~comb_rstn),
|
| 307 |
+
.cen ( 1'b1 ),
|
| 308 |
+
.din ( 1'b1 ),
|
| 309 |
+
.q ( ),
|
| 310 |
+
.qn ( int_n ),
|
| 311 |
+
.set ( 1'b0 ),
|
| 312 |
+
.clr ( irq_ack ),
|
| 313 |
+
.sigedge( ~LVBL )
|
| 314 |
+
);
|
| 315 |
+
|
| 316 |
+
jtframe_z80_devwait #(.RECOVERY(0)) u_gamecpu(
|
| 317 |
+
.rst_n ( comb_rstn ),
|
| 318 |
+
.clk ( clk ),
|
| 319 |
+
.cen ( cen6 ),
|
| 320 |
+
.cpu_cen ( cpu_cen ),
|
| 321 |
+
`ifdef NOINT
|
| 322 |
+
.int_n ( 1'b1 ),
|
| 323 |
+
.nmi_n ( 1'b1 ),
|
| 324 |
+
`else
|
| 325 |
+
.int_n ( int_n ),
|
| 326 |
+
.nmi_n ( kabuki | fmint_n ),
|
| 327 |
+
`endif
|
| 328 |
+
.busrq_n ( 1'b1 ),
|
| 329 |
+
.m1_n ( m1_n ),
|
| 330 |
+
.mreq_n ( mreq_n ),
|
| 331 |
+
.iorq_n ( iorq_n ),
|
| 332 |
+
.rd_n ( rd_n ),
|
| 333 |
+
.wr_n ( wr_n ),
|
| 334 |
+
.rfsh_n ( rfsh_n ),
|
| 335 |
+
.halt_n ( ),
|
| 336 |
+
.busak_n ( ),
|
| 337 |
+
.A ( A ),
|
| 338 |
+
.din ( din ),
|
| 339 |
+
.dout ( dout ),
|
| 340 |
+
.rom_cs ( rom_cs ),
|
| 341 |
+
.rom_ok ( 1'b1 ),
|
| 342 |
+
.dev_busy ( dev_busy )
|
| 343 |
+
);
|
| 344 |
+
|
| 345 |
+
`ifndef NOMCU
|
| 346 |
+
// `ifdef SIMULATION
|
| 347 |
+
// reg mcu_rdl, mcu_wel;
|
| 348 |
+
|
| 349 |
+
// always @(posedge clk ) begin
|
| 350 |
+
// mcu_rdl <= |mcu_rd;
|
| 351 |
+
// mcu_wel <= |mcu_we;
|
| 352 |
+
// if( mcu_we==0 && mcu_wel ) $display("Wr %X to %X", dout, A);
|
| 353 |
+
// if( mcu_rd==0 && mcu_rdl ) $display("Rd %X from %X",din, A);
|
| 354 |
+
// end
|
| 355 |
+
// `endif
|
| 356 |
+
|
| 357 |
+
jtframe_i8742 #(
|
| 358 |
+
.SIMFILE("../../firmware/arknoid2.bin")
|
| 359 |
+
) u_mcu(
|
| 360 |
+
.rst ( mcu_comb_rst ),
|
| 361 |
+
.clk ( clk ),
|
| 362 |
+
.cen ( cen6 ),
|
| 363 |
+
|
| 364 |
+
// CPU communication
|
| 365 |
+
.a0 ( A[0] ),
|
| 366 |
+
.cs_n ( ~mcu_cs ),
|
| 367 |
+
.cpu_rdn ( rd_n ),
|
| 368 |
+
.cpu_wrn ( wr_n ),
|
| 369 |
+
.din ( dout ),
|
| 370 |
+
.dout ( mcu_dout ),
|
| 371 |
+
|
| 372 |
+
// Ports
|
| 373 |
+
.p1_din ( p1_din ),
|
| 374 |
+
.p2_din ( p2_din ),
|
| 375 |
+
.p1_dout ( p1_dout ),
|
| 376 |
+
.p2_dout ( p2_dout ),
|
| 377 |
+
|
| 378 |
+
// Test pins (used in the assembler TEST instruction)
|
| 379 |
+
.t0_din (~coin[0]),
|
| 380 |
+
.t1_din (~coin[1]),
|
| 381 |
+
|
| 382 |
+
.prog_addr ( prog_addr ),
|
| 383 |
+
.prog_data ( prog_data ),
|
| 384 |
+
.prom_we ( prom_we ),
|
| 385 |
+
|
| 386 |
+
// Debug
|
| 387 |
+
.st_addr ( st_addr ),
|
| 388 |
+
.st_dout ( mcu_st )
|
| 389 |
+
);
|
| 390 |
+
`else
|
| 391 |
+
assign p2_dout = 0;
|
| 392 |
+
assign mcu_dout = 8'hff;
|
| 393 |
+
`endif
|
| 394 |
+
|
| 395 |
+
always @(posedge clk) begin
|
| 396 |
+
if( kageki ) begin
|
| 397 |
+
case( portb_dout[1:0] )
|
| 398 |
+
0: porta_din <= { 4'd0, dipsw[4+8], dipsw[0+8], dipsw[4], dipsw[0] };
|
| 399 |
+
2: porta_din <= { 4'd0, dipsw[5+8], dipsw[1+8], dipsw[5], dipsw[1] };
|
| 400 |
+
1: porta_din <= { 4'd0, dipsw[6+8], dipsw[2+8], dipsw[6], dipsw[2] };
|
| 401 |
+
3: porta_din <= { 4'd0, dipsw[7+8], dipsw[3+8], dipsw[7], dipsw[3] };
|
| 402 |
+
endcase
|
| 403 |
+
end else porta_din <= dipsw[7:0];
|
| 404 |
+
end
|
| 405 |
+
|
| 406 |
+
// Kabuki sound CPU
|
| 407 |
+
wire snd_mreq_n, snd_m1_n, snd_iorq_n, snd_rd_n, snd_wr_n, snd_rfsh_n, snd_cpu_cen;
|
| 408 |
+
reg snd_int_n;
|
| 409 |
+
reg [ 7:0] snd_latch;
|
| 410 |
+
wire [ 7:0] snd_dout, snd_ram_dout;
|
| 411 |
+
wire [15:0] snd_A;
|
| 412 |
+
wire [2:0] snd_bank = porta_dout[2:0];
|
| 413 |
+
reg snd_rom_cs, snd_ram_cs, snd_bank_cs, snd_fm_cs, snd_latch_cs;
|
| 414 |
+
assign audiocpu_cs = snd_rom_cs | snd_bank_cs;
|
| 415 |
+
assign audiocpu_addr = {snd_bank_cs ? snd_bank[2:0] : {2'd0, snd_A[14]}, snd_A[13:0]};
|
| 416 |
+
|
| 417 |
+
always @(posedge clk) begin
|
| 418 |
+
snd_rom_cs <= ~snd_mreq_n && snd_rfsh_n && !snd_A[15];
|
| 419 |
+
snd_ram_cs <= ~snd_mreq_n && snd_rfsh_n && snd_A[15:14] == 2'b11 && (snd_A[13] ^ kabuki_mod); // E000-FFFF or C000-DFFF
|
| 420 |
+
snd_bank_cs <= ~snd_mreq_n && snd_rfsh_n && snd_A[15:14] == 2'b10 && !kabuki_mod; // 8000-BFFF
|
| 421 |
+
snd_fm_cs <= ~snd_iorq_n && snd_m1_n && !snd_A[1];
|
| 422 |
+
snd_latch_cs<= ~snd_iorq_n && snd_m1_n && snd_A[1];
|
| 423 |
+
|
| 424 |
+
if (kabuki_dipsnd && !A[1]) begin
|
| 425 |
+
snd_int_n <= 0;
|
| 426 |
+
snd_latch <= dout;
|
| 427 |
+
end
|
| 428 |
+
if (snd_latch_cs) snd_int_n <= 1;
|
| 429 |
+
end
|
| 430 |
+
|
| 431 |
+
wire [7:0] snd_din =
|
| 432 |
+
(snd_rom_cs | snd_bank_cs) ? audiocpu_data :
|
| 433 |
+
snd_ram_cs ? snd_ram_dout :
|
| 434 |
+
snd_fm_cs ? fm_dout :
|
| 435 |
+
snd_latch_cs ? snd_latch : 8'hFF;
|
| 436 |
+
|
| 437 |
+
jtframe_z80_devwait #(.RECOVERY(0)) u_sndcpu(
|
| 438 |
+
.rst_n ( comb_rstn & kabuki ),
|
| 439 |
+
.clk ( clk ),
|
| 440 |
+
.cen ( cen6 ),
|
| 441 |
+
.cpu_cen ( snd_cpu_cen ),
|
| 442 |
+
`ifdef NOINT
|
| 443 |
+
.int_n ( 1'b1 ),
|
| 444 |
+
.nmi_n ( 1'b1 ),
|
| 445 |
+
`else
|
| 446 |
+
.int_n ( snd_int_n ),
|
| 447 |
+
.nmi_n ( fmint_n ),
|
| 448 |
+
`endif
|
| 449 |
+
.busrq_n ( 1'b1 ),
|
| 450 |
+
.m1_n ( snd_m1_n ),
|
| 451 |
+
.mreq_n ( snd_mreq_n ),
|
| 452 |
+
.iorq_n ( snd_iorq_n ),
|
| 453 |
+
.rd_n ( snd_rd_n ),
|
| 454 |
+
.wr_n ( snd_wr_n ),
|
| 455 |
+
.rfsh_n ( snd_rfsh_n ),
|
| 456 |
+
.halt_n ( ),
|
| 457 |
+
.busak_n ( ),
|
| 458 |
+
.A ( snd_A ),
|
| 459 |
+
.din ( snd_din ),
|
| 460 |
+
.dout ( snd_dout ),
|
| 461 |
+
.rom_cs ( audiocpu_cs ),
|
| 462 |
+
.rom_ok ( audiocpu_ok ),
|
| 463 |
+
.dev_busy ( dev_busy )
|
| 464 |
+
);
|
| 465 |
+
|
| 466 |
+
jtframe_ram #(.AW(13)) u_sndram(
|
| 467 |
+
.clk ( clk ),
|
| 468 |
+
.cen ( 1'b1 ),
|
| 469 |
+
// Main CPU
|
| 470 |
+
.addr ( snd_A[12:0] ),
|
| 471 |
+
.data ( snd_dout ),
|
| 472 |
+
.we ( snd_ram_cs & ~snd_wr_n ),
|
| 473 |
+
.q ( snd_ram_dout )
|
| 474 |
+
);
|
| 475 |
+
|
| 476 |
+
// only used by Arkanoid 2
|
| 477 |
+
jt4701 u_dial(
|
| 478 |
+
.rst ( rst ),
|
| 479 |
+
.clk ( clk ),
|
| 480 |
+
.x_in ( dial_x ),
|
| 481 |
+
.y_in ( dial_y ),
|
| 482 |
+
.rightn ( service ),
|
| 483 |
+
.leftn (coin[0]),
|
| 484 |
+
.middlen(coin[1]),
|
| 485 |
+
.x_rst (dial_rst[0]),
|
| 486 |
+
.y_rst (dial_rst[1]),
|
| 487 |
+
.csn ( ~dial_cs ),
|
| 488 |
+
.uln ( A[0] ),
|
| 489 |
+
.xn_y ( A[1] ),
|
| 490 |
+
.cfn ( ),
|
| 491 |
+
.sfn ( ),
|
| 492 |
+
.dout ( dial_dout ),
|
| 493 |
+
.dir ( )
|
| 494 |
+
);
|
| 495 |
+
|
| 496 |
+
`ifndef VERILATOR_KEEP_JT03
|
| 497 |
+
/* verilator tracing_off */
|
| 498 |
+
`endif
|
| 499 |
+
reg fm_cen;
|
| 500 |
+
|
| 501 |
+
always @(negedge clk) fm_cen <= fast_fm ? cen3 : cen1p5;
|
| 502 |
+
|
| 503 |
+
jt03 #(.YM2203_LUMPED(1)) u_2203(
|
| 504 |
+
.rst ( ~comb_rstn ),
|
| 505 |
+
.clk ( clk ),
|
| 506 |
+
.cen ( fm_cen ),
|
| 507 |
+
.din ( kabuki ? snd_dout : dout ),
|
| 508 |
+
.dout ( fm_dout ),
|
| 509 |
+
.addr ( kabuki ? snd_A[0] : A[0] ),
|
| 510 |
+
.cs_n ( ~fm_cs & ~snd_fm_cs ),
|
| 511 |
+
.wr_n ( kabuki ? snd_wr_n : wr_n ),
|
| 512 |
+
.psg_snd ( psg ),
|
| 513 |
+
.fm_snd ( fm ),
|
| 514 |
+
.snd_sample ( sample ),
|
| 515 |
+
.irq_n ( fmint_n ),
|
| 516 |
+
// IO ports
|
| 517 |
+
.IOA_in ( porta_din ),
|
| 518 |
+
.IOB_in ( dipsw[15:8]),
|
| 519 |
+
.IOA_oe ( ),
|
| 520 |
+
.IOA_out ( porta_dout ),
|
| 521 |
+
.IOB_out ( portb_dout ),
|
| 522 |
+
.IOB_oe ( ),
|
| 523 |
+
// unused outputs
|
| 524 |
+
.psg_A ( ),
|
| 525 |
+
.psg_B ( ),
|
| 526 |
+
.psg_C ( ),
|
| 527 |
+
.snd ( ),
|
| 528 |
+
.debug_view ( )
|
| 529 |
+
);
|
| 530 |
+
`else
|
| 531 |
+
initial begin
|
| 532 |
+
rom_addr = 0;
|
| 533 |
+
rom_cs = 0;
|
| 534 |
+
$display("WARNING: without the sound CPU, the main CPU won't work correctly");
|
| 535 |
+
end
|
| 536 |
+
assign ram_addr = 0;
|
| 537 |
+
assign ram_din = 0;
|
| 538 |
+
initial ram_cs = 0;
|
| 539 |
+
assign cpu_rnw = 1;
|
| 540 |
+
assign snd = 0;
|
| 541 |
+
assign sample = 0;
|
| 542 |
+
`endif
|
| 543 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_tilemap.v
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 7-11-2022 */
|
| 18 |
+
|
| 19 |
+
// This is tile map section of the SETA chip
|
| 20 |
+
// This one uses an independent line buffer
|
| 21 |
+
// from that of the sprites
|
| 22 |
+
|
| 23 |
+
module jtkiwi_tilemap(
|
| 24 |
+
input rst,
|
| 25 |
+
input clk,
|
| 26 |
+
input pxl_cen,
|
| 27 |
+
input tm_cen,
|
| 28 |
+
|
| 29 |
+
input hs,
|
| 30 |
+
input flip,
|
| 31 |
+
input page,
|
| 32 |
+
input [15:0] col_xmsb,
|
| 33 |
+
input [ 3:0] col_cfg,
|
| 34 |
+
input [ 1:0] col0,
|
| 35 |
+
|
| 36 |
+
output [11:0] tm_addr,
|
| 37 |
+
input [15:0] tm_data,
|
| 38 |
+
|
| 39 |
+
// Column scroll
|
| 40 |
+
output [ 7:0] col_addr,
|
| 41 |
+
input [ 7:0] col_data,
|
| 42 |
+
|
| 43 |
+
output [20:2] rom_addr,
|
| 44 |
+
output rom_cs,
|
| 45 |
+
input rom_ok,
|
| 46 |
+
input [31:0] rom_data,
|
| 47 |
+
|
| 48 |
+
input [ 8:0] vrender,
|
| 49 |
+
input [ 8:0] hdump,
|
| 50 |
+
output [ 8:0] pxl,
|
| 51 |
+
|
| 52 |
+
input [ 7:0] debug_bus
|
| 53 |
+
);
|
| 54 |
+
|
| 55 |
+
reg line, done, hsl, video_en;
|
| 56 |
+
reg [ 4:0] col_cnt, dr_pal;
|
| 57 |
+
reg [ 3:0] dr_ysub, col_end;
|
| 58 |
+
reg [ 8:0] eff_h, eff_v, dr_xpos;
|
| 59 |
+
reg [ 7:0] yscr;
|
| 60 |
+
reg [ 8:0] xscr;
|
| 61 |
+
wire [ 8:0] vf, raw_pxl;
|
| 62 |
+
reg [ 1:0] st;
|
| 63 |
+
reg dr_draw, dr_hflip, dr_vflip, hflip, vflip;
|
| 64 |
+
reg [13:0] dr_code, code;
|
| 65 |
+
wire dr_busy;
|
| 66 |
+
wire [ 8:0] buf_din, buf_addr;
|
| 67 |
+
wire buf_we;
|
| 68 |
+
|
| 69 |
+
assign tm_addr = { page, 1'b1, st[0], eff_h[8:5], eff_v[7:4], eff_h[4] }; // 1 + 1 + 1 + 4 + 5 = 12
|
| 70 |
+
assign col_addr = { col_cnt[4:1], 1'd0, st[0], 2'd0 };
|
| 71 |
+
assign vf = {9{~flip}} ^ vrender;
|
| 72 |
+
assign pxl = video_en ? raw_pxl : 9'd0;
|
| 73 |
+
|
| 74 |
+
always @* begin
|
| 75 |
+
eff_v = vf + { 1'b0, yscr };
|
| 76 |
+
eff_h = { col_cnt + {col0,3'd0}, 4'b0 };
|
| 77 |
+
end
|
| 78 |
+
|
| 79 |
+
// Columns are 32-pixel wide
|
| 80 |
+
always @(posedge clk, posedge rst) begin
|
| 81 |
+
if( rst ) begin
|
| 82 |
+
col_cnt <= 0;
|
| 83 |
+
line <= 0;
|
| 84 |
+
hsl <= 0;
|
| 85 |
+
dr_code <= 0;
|
| 86 |
+
dr_hflip <= 0;
|
| 87 |
+
dr_vflip <= 0;
|
| 88 |
+
dr_xpos <= 0;
|
| 89 |
+
dr_ysub <= 0;
|
| 90 |
+
video_en <= 0;
|
| 91 |
+
end else begin
|
| 92 |
+
hsl <= hs;
|
| 93 |
+
dr_draw <= 0;
|
| 94 |
+
if ( hs & ~hsl ) line <= ~line;
|
| 95 |
+
if( hs || (vrender>9'hf0 && vrender<8) || col_cfg==0 ) begin
|
| 96 |
+
col_cnt <= 0;
|
| 97 |
+
done <= col_cfg==0; // don't do anything for col_cfg==0
|
| 98 |
+
video_en <= col_cfg!=0;
|
| 99 |
+
st <= 0;
|
| 100 |
+
dr_draw <= 0;
|
| 101 |
+
col_end <= col_cfg==1 ? 4'hf : col_cfg-4'd1;
|
| 102 |
+
end else if( !done && tm_cen ) begin
|
| 103 |
+
st <= st + 1'd1;
|
| 104 |
+
case( st )
|
| 105 |
+
0: yscr <= col_data;
|
| 106 |
+
1: begin
|
| 107 |
+
xscr <= { col_xmsb[col_cnt[4:1]], col_data };
|
| 108 |
+
end
|
| 109 |
+
2: begin
|
| 110 |
+
{ hflip, vflip } <= tm_data[15:14];
|
| 111 |
+
code <= tm_data[13:0];
|
| 112 |
+
end
|
| 113 |
+
3: begin
|
| 114 |
+
if( !dr_busy ) begin
|
| 115 |
+
dr_draw <= 1;
|
| 116 |
+
dr_code <= code;
|
| 117 |
+
dr_hflip <= hflip^flip;
|
| 118 |
+
dr_vflip <= vflip;
|
| 119 |
+
dr_pal <= tm_data[11+:5]; //{1'b1, tm_data[12:9] }; // some games seem to use the fifth bit too. This is probably some config setting unexplored by MAME
|
| 120 |
+
dr_xpos <= { 4'd0, col_cnt[0], 4'd0 } + xscr;
|
| 121 |
+
dr_ysub <= eff_v[3:0];
|
| 122 |
+
col_cnt <= col_cnt + 1'd1;
|
| 123 |
+
done <= col_cnt[4:1]==col_end && col_cnt[0];
|
| 124 |
+
end else begin
|
| 125 |
+
st <= st;
|
| 126 |
+
end
|
| 127 |
+
end
|
| 128 |
+
endcase
|
| 129 |
+
end
|
| 130 |
+
end
|
| 131 |
+
end
|
| 132 |
+
|
| 133 |
+
jtkiwi_draw #(.SWAP_HALVES(1'b1)) u_draw(
|
| 134 |
+
.rst ( rst ),
|
| 135 |
+
.clk ( clk ),
|
| 136 |
+
|
| 137 |
+
.draw ( dr_draw ),
|
| 138 |
+
.busy ( dr_busy ),
|
| 139 |
+
.code ( dr_code ),
|
| 140 |
+
.pal ( dr_pal ),
|
| 141 |
+
.hflip ( dr_hflip ),
|
| 142 |
+
.vflip ( dr_vflip ),
|
| 143 |
+
.xpos ( dr_xpos ),
|
| 144 |
+
.ysub ( dr_ysub ),
|
| 145 |
+
.flip ( flip ),
|
| 146 |
+
|
| 147 |
+
.rom_addr ( rom_addr ),
|
| 148 |
+
.rom_cs ( rom_cs ),
|
| 149 |
+
.rom_ok ( rom_ok ),
|
| 150 |
+
.rom_data ( rom_data ),
|
| 151 |
+
|
| 152 |
+
.buf_addr ( buf_addr ),
|
| 153 |
+
.buf_we ( buf_we ),
|
| 154 |
+
.buf_din ( buf_din ),
|
| 155 |
+
.debug_bus ( 8'd0 )
|
| 156 |
+
//.debug_bus ( debug_bus )
|
| 157 |
+
);
|
| 158 |
+
|
| 159 |
+
// The tilemap is made of transparent tiles
|
| 160 |
+
// that can be drawn on top of other ones. That's
|
| 161 |
+
// how the sky in TNZS intro scene is drawn
|
| 162 |
+
|
| 163 |
+
jtframe_obj_buffer #(
|
| 164 |
+
.DW ( 9 ),
|
| 165 |
+
.ALPHA( 0 )
|
| 166 |
+
) u_linebuf(
|
| 167 |
+
.clk ( clk ),
|
| 168 |
+
.flip ( 1'b0 ),
|
| 169 |
+
.LHBL ( ~hs ),
|
| 170 |
+
// New line writting
|
| 171 |
+
.we ( buf_we ),
|
| 172 |
+
.wr_data( buf_din ),
|
| 173 |
+
.wr_addr( buf_addr ),
|
| 174 |
+
// Previous line reading
|
| 175 |
+
.rd ( pxl_cen ),
|
| 176 |
+
.rd_addr( hdump ),
|
| 177 |
+
.rd_data( raw_pxl )
|
| 178 |
+
);
|
| 179 |
+
|
| 180 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/hdl/jtkiwi_video.v
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* This file is part of JTCORES.
|
| 2 |
+
JTCORES program is free software: you can redistribute it and/or modify
|
| 3 |
+
it under the terms of the GNU General Public License as published by
|
| 4 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 5 |
+
(at your option) any later version.
|
| 6 |
+
|
| 7 |
+
JTCORES program is distributed in the hope that it will be useful,
|
| 8 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
+
GNU General Public License for more details.
|
| 11 |
+
|
| 12 |
+
You should have received a copy of the GNU General Public License
|
| 13 |
+
along with JTCORES. If not, see <http://www.gnu.org/licenses/>.
|
| 14 |
+
|
| 15 |
+
Author: Jose Tejada Gomez. Twitter: @topapate
|
| 16 |
+
Version: 1.0
|
| 17 |
+
Date: 18-09-2022 */
|
| 18 |
+
|
| 19 |
+
module jtkiwi_video(
|
| 20 |
+
input rst,
|
| 21 |
+
input clk,
|
| 22 |
+
input clk_cpu,
|
| 23 |
+
input pxl2_cen,
|
| 24 |
+
input pxl_cen,
|
| 25 |
+
input hb_dly,
|
| 26 |
+
|
| 27 |
+
output LHBL,
|
| 28 |
+
output LVBL,
|
| 29 |
+
output HS,
|
| 30 |
+
output VS,
|
| 31 |
+
output flip,
|
| 32 |
+
output [ 8:0] hdump,
|
| 33 |
+
// PROMs
|
| 34 |
+
input [ 9:0] prog_addr,
|
| 35 |
+
input [ 7:0] prog_data,
|
| 36 |
+
input prom_we,
|
| 37 |
+
input colprom_en,
|
| 38 |
+
// CPU interface
|
| 39 |
+
input pal_cs,
|
| 40 |
+
output [ 7:0] pal_dout,
|
| 41 |
+
input cpu_rnw,
|
| 42 |
+
input [12:0] cpu_addr,
|
| 43 |
+
input [ 7:0] cpu_dout,
|
| 44 |
+
input vram_cs,
|
| 45 |
+
input vctrl_cs,
|
| 46 |
+
input vflag_cs,
|
| 47 |
+
output [ 7:0] vram_dout,
|
| 48 |
+
// Sub-CPU interface
|
| 49 |
+
input pal2_cs,
|
| 50 |
+
input [ 7:0] cpu2_dout,
|
| 51 |
+
input cpu2_rnw,
|
| 52 |
+
input [ 9:0] cpu2_addr,
|
| 53 |
+
// SDRAM interface
|
| 54 |
+
output [20:2] scr_addr,
|
| 55 |
+
input [31:0] scr_data,
|
| 56 |
+
input scr_ok,
|
| 57 |
+
output scr_cs,
|
| 58 |
+
|
| 59 |
+
output [20:2] obj_addr,
|
| 60 |
+
input [31:0] obj_data,
|
| 61 |
+
input obj_ok,
|
| 62 |
+
output obj_cs,
|
| 63 |
+
// Colours
|
| 64 |
+
output [ 4:0] red,
|
| 65 |
+
output [ 4:0] green,
|
| 66 |
+
output [ 4:0] blue,
|
| 67 |
+
// Test
|
| 68 |
+
input [ 3:0] gfx_en,
|
| 69 |
+
input [ 7:0] debug_bus,
|
| 70 |
+
output [ 7:0] st_dout
|
| 71 |
+
);
|
| 72 |
+
|
| 73 |
+
wire [ 8:0] vrender, vrender1, vdump;
|
| 74 |
+
wire [ 8:0] scr_pxl, obj_pxl;
|
| 75 |
+
reg [ 7:0] LHBL_l;
|
| 76 |
+
wire preLHBL;
|
| 77 |
+
|
| 78 |
+
assign LHBL = hb_dly ? LHBL_l[4] : preLHBL; // used by JTKIWI
|
| 79 |
+
|
| 80 |
+
always @(posedge clk) begin
|
| 81 |
+
LHBL_l <= LHBL_l<<1;
|
| 82 |
+
LHBL_l[0] <= preLHBL;
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
jtframe_vtimer #(
|
| 86 |
+
.HB_START( 9'd256 ),
|
| 87 |
+
.HS_START( 9'd297 ),
|
| 88 |
+
.HCNT_END( 9'd383 ),
|
| 89 |
+
.HB_END ( 9'd0 ),
|
| 90 |
+
.V_START ( 9'd008 ),
|
| 91 |
+
.VS_START( 9'd254 ),
|
| 92 |
+
.VB_START( 9'd239 ),
|
| 93 |
+
.VCNT_END( 9'd271 ),
|
| 94 |
+
.VB_END ( 9'd015 )
|
| 95 |
+
) u_timer(
|
| 96 |
+
.clk ( clk ),
|
| 97 |
+
.pxl_cen ( pxl_cen ),
|
| 98 |
+
.vdump ( vdump ),
|
| 99 |
+
.vrender ( vrender ),
|
| 100 |
+
.vrender1 ( vrender1 ),
|
| 101 |
+
.H ( hdump ),
|
| 102 |
+
.Hinit ( ),
|
| 103 |
+
.Vinit ( ),
|
| 104 |
+
.LHBL ( preLHBL ),
|
| 105 |
+
.LVBL ( LVBL ),
|
| 106 |
+
.HS ( HS ),
|
| 107 |
+
.VS ( VS )
|
| 108 |
+
);
|
| 109 |
+
|
| 110 |
+
jtkiwi_gfx u_gfx(
|
| 111 |
+
.rst ( rst ),
|
| 112 |
+
.clk ( clk ),
|
| 113 |
+
.clk_cpu ( clk_cpu ),
|
| 114 |
+
.pxl_cen ( pxl_cen ),
|
| 115 |
+
.pxl2_cen ( pxl2_cen ),
|
| 116 |
+
// PROMs
|
| 117 |
+
// .prog_addr ( prog_addr ),
|
| 118 |
+
// .prog_data ( prog_data ),
|
| 119 |
+
// .prom_we ( prom_we ),
|
| 120 |
+
// Screen
|
| 121 |
+
.flip ( flip ),
|
| 122 |
+
.LHBL ( LHBL ),
|
| 123 |
+
.LVBL ( LVBL ),
|
| 124 |
+
.vs ( VS ),
|
| 125 |
+
.hs ( HS ),
|
| 126 |
+
.vdump ( vdump ),
|
| 127 |
+
.vrender ( vrender ),
|
| 128 |
+
.hdump ( hdump ),
|
| 129 |
+
// CPU interface
|
| 130 |
+
.vram_cs ( vram_cs ),
|
| 131 |
+
.vctrl_cs ( vctrl_cs ),
|
| 132 |
+
.vflag_cs ( vflag_cs ),
|
| 133 |
+
.cpu_din ( vram_dout ),
|
| 134 |
+
.cpu_addr ( cpu_addr ),
|
| 135 |
+
.cpu_rnw ( cpu_rnw ),
|
| 136 |
+
.cpu_dout ( cpu_dout ),
|
| 137 |
+
// SDRAM
|
| 138 |
+
.scr_addr ( scr_addr ),
|
| 139 |
+
.scr_data ( scr_data ),
|
| 140 |
+
.scr_ok ( scr_ok ),
|
| 141 |
+
.scr_cs ( scr_cs ),
|
| 142 |
+
|
| 143 |
+
.obj_addr ( obj_addr ),
|
| 144 |
+
.obj_data ( obj_data ),
|
| 145 |
+
.obj_ok ( obj_ok ),
|
| 146 |
+
.obj_cs ( obj_cs ),
|
| 147 |
+
// Color address to palette
|
| 148 |
+
.scr_pxl ( scr_pxl ),
|
| 149 |
+
.obj_pxl ( obj_pxl ),
|
| 150 |
+
.debug_bus ( debug_bus ),
|
| 151 |
+
.st_dout ( st_dout )
|
| 152 |
+
);
|
| 153 |
+
|
| 154 |
+
jtkiwi_colmix u_colmix(
|
| 155 |
+
.clk ( clk ),
|
| 156 |
+
.clk_cpu ( clk_cpu ),
|
| 157 |
+
.pxl_cen ( pxl_cen ),
|
| 158 |
+
// Screen
|
| 159 |
+
.LHBL ( LHBL ),
|
| 160 |
+
.LVBL ( LVBL ),
|
| 161 |
+
// CPU interface
|
| 162 |
+
.cpu_addr ( cpu_addr[9:0] ),
|
| 163 |
+
.cpu_rnw ( cpu_rnw ),
|
| 164 |
+
.cpu_dout ( cpu_dout ),
|
| 165 |
+
.cpu_din ( pal_dout ),
|
| 166 |
+
.pal_cs ( pal_cs ),
|
| 167 |
+
// Sub-CPU interface
|
| 168 |
+
.pal2_cs ( pal2_cs ),
|
| 169 |
+
.cpu2_addr ( cpu2_addr[9:0] ),
|
| 170 |
+
.cpu2_rnw ( cpu2_rnw ),
|
| 171 |
+
.cpu2_dout ( cpu2_dout ),
|
| 172 |
+
// PROMs
|
| 173 |
+
.prog_addr ( prog_addr ),
|
| 174 |
+
.prog_data ( prog_data ),
|
| 175 |
+
.prom_we ( prom_we ),
|
| 176 |
+
.colprom_en ( colprom_en ),
|
| 177 |
+
// Colour output
|
| 178 |
+
.scr_pxl ( scr_pxl ),
|
| 179 |
+
.obj_pxl ( obj_pxl ),
|
| 180 |
+
.red ( red ),
|
| 181 |
+
.green ( green ),
|
| 182 |
+
.blue ( blue ),
|
| 183 |
+
.gfx_en ( gfx_en ),
|
| 184 |
+
.debug_bus ( debug_bus )
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
endmodule
|
snapshots/jotego_jtcores_pr1111/cores/kiwi/ver/extrm/sim.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# The MCU gets out of reset at frame 19
|
| 4 |
+
|
| 5 |
+
# Use cpsnap.sh to copy MAME scenes to a new folder
|
| 6 |
+
|
| 7 |
+
ARG=
|
| 8 |
+
SCENE=
|
| 9 |
+
|
| 10 |
+
touch seta_cfg.hex
|
| 11 |
+
|
| 12 |
+
while [ $# -gt 0 ]; do
|
| 13 |
+
case $1 in
|
| 14 |
+
-s) shift
|
| 15 |
+
SCENE=$1
|
| 16 |
+
ARG="$ARG -d NOMAIN -d NOMCU -nosnd -video 2"
|
| 17 |
+
;;
|
| 18 |
+
*) ARG="$ARG $1";;
|
| 19 |
+
esac
|
| 20 |
+
shift
|
| 21 |
+
done
|
| 22 |
+
|
| 23 |
+
if [ ! -z "$SCENE" ]; then
|
| 24 |
+
if [ ! -d "$SCENE" ]; then
|
| 25 |
+
echo "Requested scene $SCENE cannot be found"
|
| 26 |
+
exit 1
|
| 27 |
+
fi
|
| 28 |
+
cp $SCENE/* .
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
if [ ! -e rom.bin ]; then ln -sf $ROM/extrmatn.rom rom.bin; fi
|
| 33 |
+
|
| 34 |
+
jtsim -sysname kiwi -d JTFRAME_SIM_ROMRQ_NOCHECK $ARG
|