Skip to content

Commit

Permalink
Add pause, lower audio volume, update sys
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmystones committed Apr 27, 2021
1 parent 33b4c5a commit abe02dd
Show file tree
Hide file tree
Showing 28 changed files with 2,090 additions and 866 deletions.
13 changes: 9 additions & 4 deletions Arcade-Defender.qsf
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ set_global_assignment -name PHYSICAL_SYNTHESIS_ASYNCHRONOUS_SIGNAL_PIPELINING ON
set_global_assignment -name ALM_REGISTER_PACKING_EFFORT LOW
set_global_assignment -name SEED 1

set_global_assignment -name VERILOG_MACRO "ARCADE_SYS=1"
set_global_assignment -name VERILOG_MACRO "USE_FB=1"
#set_global_assignment -name VERILOG_MACRO "USE_SDRAM=1"
#set_global_assignment -name VERILOG_MACRO "USE_DDRAM=1"
set_global_assignment -name VERILOG_MACRO "MISTER_FB=1"

#enable it only if 8bit indexed mode is used in core
#set_global_assignment -name VERILOG_MACRO "MISTER_FB_PALETTE=1"

#set_global_assignment -name VERILOG_MACRO "MISTER_DUAL_SDRAM=1"

#do not enable DEBUG_NOHDMI in release!
#set_global_assignment -name VERILOG_MACRO "MISTER_DEBUG_NOHDMI=1"

source sys/sys.tcl
source sys/sys_analog.tcl
Expand Down
116 changes: 98 additions & 18 deletions Arcade-Defender.sv
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ module emu
output CE_PIXEL,

//Video aspect ratio for HDMI. Most retro systems have ratio 4:3.
output [11:0] VIDEO_ARX,
output [11:0] VIDEO_ARY,
//if VIDEO_ARX[12] or VIDEO_ARY[12] is set then [11:0] contains scaled size instead of aspect ratio.
output [12:0] VIDEO_ARX,
output [12:0] VIDEO_ARY,

output [7:0] VGA_R,
output [7:0] VGA_G,
Expand All @@ -52,13 +53,17 @@ module emu
output [1:0] VGA_SL,
output VGA_SCALER, // Force VGA scaler

// Use framebuffer from DDRAM (USE_FB=1 in qsf)
input [11:0] HDMI_WIDTH,
input [11:0] HDMI_HEIGHT,

`ifdef MISTER_FB
// Use framebuffer in DDRAM (USE_FB=1 in qsf)
// FB_FORMAT:
// [2:0] : 011=8bpp(palette) 100=16bpp 101=24bpp 110=32bpp
// [3] : 0=16bits 565 1=16bits 1555
// [4] : 0=RGB 1=BGR (for 16/24/32 modes)
//
// FB_STRIDE either 0 (rounded to 256 bytes) or multiple of 16 bytes.
// FB_STRIDE either 0 (rounded to 256 bytes) or multiple of pixel size (in bytes)
output FB_EN,
output [4:0] FB_FORMAT,
output [11:0] FB_WIDTH,
Expand All @@ -69,13 +74,16 @@ module emu
input FB_LL,
output FB_FORCE_BLANK,

`ifdef MISTER_FB_PALETTE
// Palette control for 8bit modes.
// Ignored for other video modes.
output FB_PAL_CLK,
output [7:0] FB_PAL_ADDR,
output [23:0] FB_PAL_DOUT,
input [23:0] FB_PAL_DIN,
output FB_PAL_WR,
`endif
`endif

output LED_USER, // 1 - ON, 0 - OFF.

Expand All @@ -85,10 +93,26 @@ module emu
output [1:0] LED_POWER,
output [1:0] LED_DISK,

// I/O board button press simulation (active high)
// b[1]: user button
// b[0]: osd button
output [1:0] BUTTONS,

input CLK_AUDIO, // 24.576 MHz
output [15:0] AUDIO_L,
output [15:0] AUDIO_R,
output AUDIO_S, // 1 - signed audio samples, 0 - unsigned
output AUDIO_S, // 1 - signed audio samples, 0 - unsigned
output [1:0] AUDIO_MIX, // 0 - no mix, 1 - 25%, 2 - 50%, 3 - 100% (mono)

//ADC
inout [3:0] ADC_BUS,

//SD-SPI
output SD_SCK,
output SD_MOSI,
input SD_MISO,
output SD_CS,
input SD_CD,

//High latency DDR3 RAM interface
//Use for non-critical time purposes
Expand All @@ -103,43 +127,90 @@ module emu
output [7:0] DDRAM_BE,
output DDRAM_WE,

//SDRAM interface with lower latency
output SDRAM_CLK,
output SDRAM_CKE,
output [12:0] SDRAM_A,
output [1:0] SDRAM_BA,
inout [15:0] SDRAM_DQ,
output SDRAM_DQML,
output SDRAM_DQMH,
output SDRAM_nCS,
output SDRAM_nCAS,
output SDRAM_nRAS,
output SDRAM_nWE,

`ifdef MISTER_DUAL_SDRAM
//Secondary SDRAM
//Set all output SDRAM_* signals to Z ASAP if SDRAM2_EN is 0
input SDRAM2_EN,
output SDRAM2_CLK,
output [12:0] SDRAM2_A,
output [1:0] SDRAM2_BA,
inout [15:0] SDRAM2_DQ,
output SDRAM2_nCS,
output SDRAM2_nCAS,
output SDRAM2_nRAS,
output SDRAM2_nWE,
`endif

input UART_CTS,
output UART_RTS,
input UART_RXD,
output UART_TXD,
output UART_DTR,
input UART_DSR,

// Open-drain User port.
// 0 - D+/RX
// 1 - D-/TX
// 2..6 - USR2..USR6
// Set USER_OUT to 1 to read from USER_IN.
input [6:0] USER_IN,
output [6:0] USER_OUT
output [6:0] USER_OUT,

input OSD_STATUS
);

///////// Default values for ports not used in this core /////////

assign ADC_BUS = 'Z;
assign USER_OUT = '1;
assign {UART_RTS, UART_TXD, UART_DTR} = 0;
assign {SD_SCK, SD_MOSI, SD_CS} = 'Z;
assign {SDRAM_DQ, SDRAM_A, SDRAM_BA, SDRAM_CLK, SDRAM_CKE, SDRAM_DQML, SDRAM_DQMH, SDRAM_nWE, SDRAM_nCAS, SDRAM_nRAS, SDRAM_nCS} = 'Z;
assign VGA_F1 = 0;
assign VGA_SCALER =0;
assign USER_OUT = '1;
assign AUDIO_MIX = 0;
assign LED_USER = ioctl_download;
assign LED_DISK = 0;
assign LED_POWER = 0;
assign {FB_PAL_CLK, FB_FORCE_BLANK, FB_PAL_ADDR, FB_PAL_DOUT, FB_PAL_WR} = '0;
assign BUTTONS = 0;
assign FB_FORCE_BLANK = '0;

wire [1:0] ar = status[17:16];

assign VIDEO_ARX = (!ar) ? 8'd4 : (ar - 1'd1);
assign VIDEO_ARY = (!ar) ? 8'd3 : 12'd0;

assign VIDEO_ARX = (!ar) ? ((status[2] | landscape) ? 8'd4 : 8'd3) : (ar - 1'd1);
assign VIDEO_ARY = (!ar) ? ((status[2] | landscape) ? 8'd3 : 8'd4) : 12'd0;

`include "build_id.v"
localparam CONF_STR = {
"A.DFNDR;;",
"-;",
"H0OGH,Aspect ratio,Original,Full Screen,[ARC1],[ARC2];",
"H0OGH,Aspect ratio,Original,Full Screen,[ARC1],[ARC2];",
"H1H0O2,Orientation,Vert,Horz;",
"O35,Scandoubler Fx,None,HQ2x,CRT 25%,CRT 50%,CRT 75%;",
"-;",
"h2O67,Control,Mode 1,Mode 2,Cabinet;",
"h2-;",
"DIP;",
"-;",
"P1,Pause options;",
"P1OP,Pause when OSD is open,On,Off;",
"P1OQ,Dim video after 10s,On,Off;",
"-;",
"R0,Reset;",
"J1,Fire 1,Fire 2,Fire 3,Fire 4,Fire 5,Start 1P,Start 2P,Coin;",
"J1,Fire 1,Fire 2,Fire 3,Fire 4,Fire 5,Start 1P,Start 2P,Coin,Advance,Auto Up,High Score Reset,Pause;",
"V,v",`BUILD_DATE
};

Expand Down Expand Up @@ -173,7 +244,6 @@ wire [7:0] ioctl_index;
wire [7:0] ioctl_data;
wire ioctl_wait;


wire [31:0] joy1, joy2;
wire [31:0] joy = joy1 | joy2;

Expand All @@ -193,14 +263,12 @@ hps_io #(.STRLEN($size(CONF_STR)>>3)) hps_io
.gamma_bus(gamma_bus),
.direct_video(direct_video),


.ioctl_download(ioctl_download),
.ioctl_upload(ioctl_upload),
.ioctl_wr(ioctl_wr),
.ioctl_addr(ioctl_addr),
.ioctl_dout(ioctl_dout),
.ioctl_din(ioctl_din),

.ioctl_index(ioctl_index),
.ioctl_wait(ioctl_wait),

Expand All @@ -222,6 +290,7 @@ wire m_coin1 = joy[11];
wire m_advance = joy[12];
wire m_autoup = joy[13];
wire m_highreset=joy[14];
wire m_pause =joy[15];

wire m_right1 = joy1[0];
wire m_left1 = joy1[1];
Expand Down Expand Up @@ -265,6 +334,16 @@ wire m_fire_e = m_fire1e | m_fire2e;
//wire m_spccw = m_spccw1 | m_spccw2;
//wire m_spcw = m_spcw1 | m_spcw2;

// PAUSE SYSTEM
wire pause_cpu;
wire [7:0] rgb_out;
pause #(3,3,2,24) pause (
.*,
.user_button(m_pause),
.pause_request(1'b0),
.options(~status[26:25])
);

///////////////////////////////////////////////////////////////////

localparam mod_defender = 0;
Expand Down Expand Up @@ -354,6 +433,7 @@ defender defender
(
.clock_6(clk_6),
.reset(reset),
.pause(pause_cpu),
.defender_state(def_state),

.dn_clk(clk_sys),
Expand Down Expand Up @@ -397,12 +477,12 @@ arcade_video #(306,8) arcade_video
(
.*,
.clk_video(clk_48),
.RGB_in({r,g,b}),
.RGB_in(rgb_out),
.fx(status[5:3])
);

wire [7:0] audio;
assign AUDIO_L = {audio, audio};
assign AUDIO_L = {audio, audio[7:2]};
assign AUDIO_R = AUDIO_L;
assign AUDIO_S = 0;

Expand Down
1 change: 1 addition & 0 deletions files.qip
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ set_global_assignment -name VHDL_FILE rtl/pia6821.vhd
set_global_assignment -name VHDL_FILE rtl/cpu09l_128a.vhd
set_global_assignment -name VHDL_FILE rtl/williams_sound_board.vhd
set_global_assignment -name VHDL_FILE rtl/defender.vhd
set_global_assignment -name VERILOG_FILE rtl/pause.v
set_global_assignment -name SYSTEMVERILOG_FILE "Arcade-Defender.sv"
5 changes: 2 additions & 3 deletions releases/Colony 7.mra
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dip bits="0" name="Lives" ids="2,3"/>
<dip bits="1" name="Bonus" ids="20k/40k(30k/50k),30k/50k(40k/70k)"/>
</switches>
<buttons names="Fire,Bomb,-,-,-,Start 1P,Start 2P,Coin" default="A,B,Start,Select,R"/>
<buttons names="Fire,Bomb,-,-,-,Start 1P,Start 2P,Coin,Pause" default="A,B,Start,Select,R"/>
<rom index="1">
<part>1</part>
</rom>
Expand All @@ -30,6 +30,5 @@
<part crc="6032293c" name="cs11.bin"/>
<part crc="6032293c" name="cs11.bin"/>
</rom>
<nvram index="4" size="256"/>

<nvram index="4" size="256"/>
</misterromdescription>
4 changes: 2 additions & 2 deletions releases/Defender.mra
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rbf>defender</rbf>
<switches>
</switches>
<buttons names="Fire,Thrust,Smart Bomb,Hyperspace,Reverse,Start 1P,Start 2P,Coin,Advance,Auto Up,High Score Reset" default="A,B,X,Y,L,Start,Select,R"/>
<buttons names="Fire,Thrust,Smart Bomb,Hyperspace,Reverse,Start 1P,Start 2P,Coin,Advance,Auto Up,High Score Reset,Pause" default="A,B,X,Y,L,Start,Select,R"/>
<rom index="0" zip="defender.zip" md5="752a531ae38ffcf3be5c568d006bdf67">
<part crc="c3e52d7e" name="defend.1"/>
<part crc="9a72348b" name="defend.4"/>
Expand Down Expand Up @@ -47,5 +47,5 @@
<part crc="fefd5b48" name="defend.snd"/>
<part crc="fefd5b48" name="defend.snd"/>
</rom>
<nvram index="4" size="256"/>
<nvram index="4" size="256"/>
</misterromdescription>
5 changes: 2 additions & 3 deletions releases/Jin.mra
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dip bits="19" name="Lives" ids="3,4"/>
<dip bits="21,22" name="Level complete" ids="55%,65%,75%,85%"/>
</switches>
<buttons names="Button 1,Button 2,-,-,-,Start 1P,Start 2P,Coin,Advance,Auto Up,High Score Reset" default="A,B,Start,Select,R"/>
<buttons names="Button 1,Button 2,-,-,-,Start 1P,Start 2P,Coin,Advance,Auto Up,High Score Reset,Pause" default="A,B,Start,Select,R"/>
<rom index="1">
<part>3</part>
</rom>
Expand All @@ -26,6 +26,5 @@
<part crc="fefd5b48" name="jin15.3f"/>
<part crc="fefd5b48" name="jin15.3f"/>
</rom>
<nvram index="4" size="256"/>

<nvram index="4" size="256"/>
</misterromdescription>
5 changes: 2 additions & 3 deletions releases/Mayday.mra
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rbf>defender</rbf>
<switches>
</switches>
<buttons names="Fire,Back Fire,Mayday,-,-,Start 1P,Start 2P,Coin,Advance,Auto Up,Test Credit" default="A,B,X,Start,Select,R"/>
<buttons names="Fire,Back Fire,Mayday,-,-,Start 1P,Start 2P,Coin,Advance,Auto Up,Test Credit,Pause" default="A,B,X,Start,Select,R"/>
<rom index="1">
<part>2</part>
</rom>
Expand Down Expand Up @@ -93,6 +93,5 @@ abaaa9a8a7a6a5a4a3a2a1a09f9e9d9c
<part crc="fefd5b48" name="ic28-8.bin"/>
<part crc="fefd5b48" name="ic28-8.bin"/>
</rom>
<nvram index="4" size="256"/>

<nvram index="4" size="256"/>
</misterromdescription>
11 changes: 6 additions & 5 deletions rtl/defender.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ entity defender is
port(
clock_6 : in std_logic;
reset : in std_logic;
pause : in std_logic;

extvbl : in std_logic;
defender_state : out std_logic;
Expand All @@ -133,9 +134,9 @@ port(
dn_addr : in std_logic_vector(15 downto 0);
dn_data : in std_logic_vector(7 downto 0);
dn_wr : in std_logic;
dn_din : out std_logic_vector(7 downto 0);
dn_nvram : in std_logic;
dn_nvram_wr : in std_logic;
dn_din : out std_logic_vector(7 downto 0);
dn_nvram : in std_logic;
dn_nvram_wr : in std_logic;

video_r : out std_logic_vector(2 downto 0);
video_g : out std_logic_vector(2 downto 0);
Expand Down Expand Up @@ -480,7 +481,7 @@ cpu_irq <= pia_rom_irqa or pia_rom_irqb;
-- pia rom to sound board
select_sound <= pia_rom_pb_o(5 downto 0);

cpu_ce <= '1' when pixel_cnt = "100" or pixel_cnt = "010" else '0';
cpu_ce <= '1' when ((pixel_cnt = "100" or pixel_cnt = "010") and not pause = '1') else '0';

-- microprocessor 6809
main_cpu : entity work.cpu09
Expand All @@ -501,7 +502,7 @@ port map(
irq => cpu_irq, -- interrupt request input (active high)
firq => '0', -- fast interrupt request input (active high)
nmi => '0', -- non maskable interrupt request input (active high)
halt => '0' -- not cpu_ce -- hold input (active high) extend bus cycle
halt => '0' -- not cpu_ce -- hold input (active high) extend bus cycle
);

-- Mayday protection.
Expand Down
Loading

0 comments on commit abe02dd

Please sign in to comment.