From bba00ea2ba3b57d86c91a5c7fd31e2bf74efe7e5 Mon Sep 17 00:00:00 2001 From: antoniovillena Date: Thu, 28 Apr 2016 14:11:26 +0200 Subject: [PATCH] =?UTF-8?q?Apple2=20a=20=C3=BAltima=20versi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/Apple2/apple2.xise | 2 +- cores/Apple2/roms/hacer_imagen.bat | 1 + cores/Apple2/roms/links.txt | 0 cores/Apple2/source/apple2_top.vhd | 64 ++++++++++++++++++++----- cores/Apple2/source/apple2_zxuno_v2.ucf | 17 +++---- cores/Apple2/source/apple2_zxuno_v3.ucf | 17 +++---- cores/Apple2/source/keyboard.vhd | 10 ++-- 7 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 cores/Apple2/roms/hacer_imagen.bat create mode 100644 cores/Apple2/roms/links.txt diff --git a/cores/Apple2/apple2.xise b/cores/Apple2/apple2.xise index 69b6b18..8eb89be 100644 --- a/cores/Apple2/apple2.xise +++ b/cores/Apple2/apple2.xise @@ -76,7 +76,7 @@ - + diff --git a/cores/Apple2/roms/hacer_imagen.bat b/cores/Apple2/roms/hacer_imagen.bat new file mode 100644 index 0000000..7c1b5ca --- /dev/null +++ b/cores/Apple2/roms/hacer_imagen.bat @@ -0,0 +1 @@ +copy /B Apple33.nib + LodeRunner.nib + MarioBros.nib + MoonPatrol.nib + SpyVsSpy.nib + Zaxxon.nib + ZorkIII.nib + Choplifter.nib + Karateka.nib + Pacman.nib apple2_10disks.img \ No newline at end of file diff --git a/cores/Apple2/roms/links.txt b/cores/Apple2/roms/links.txt new file mode 100644 index 0000000..e69de29 diff --git a/cores/Apple2/source/apple2_top.vhd b/cores/Apple2/source/apple2_top.vhd index 27effd3..801a11a 100644 --- a/cores/Apple2/source/apple2_top.vhd +++ b/cores/Apple2/source/apple2_top.vhd @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------- --- +-- -- Papilio DUO with Classic computing shield top-level module for the Apple ][ -- -- VLA @@ -26,6 +26,7 @@ entity APPLE2_TOP is CLOCK50 : in std_logic; LED : out std_logic; + LED2 : out std_logic; I_RESET : in std_logic; -- SRAM @@ -59,8 +60,7 @@ entity APPLE2_TOP is O_AUDIO_L : out std_logic; -- ADC Data O_AUDIO_R : out std_logic; -- ADC Data - SW_LEFT : in std_logic; - SW_UP : in std_logic; + BTN2 : in std_logic; JOYSTICK1 : in std_logic_vector(4 downto 0) ); @@ -108,17 +108,53 @@ architecture datapath of APPLE2_TOP is signal PDL_STROBE : std_logic; signal joy1_x, joy1_y : std_logic; signal csjudlr1 : std_logic_vector(6 downto 0); + signal BTN3 : std_logic; + + signal keyCode : unsigned(11 downto 0); + signal resetKey : std_logic; + signal imageCount : unsigned(7 downto 0) := (others => '0'); begin - reset <= I_RESET or power_on_reset; + reset <= I_RESET or power_on_reset; + + resetKey <= '1' when keyCode = X"007" else '0'; --F12 reset + + img_select : process (keyCode) --Disk image selection = SHIFT + Fx (F1 to F10) + begin + if keyCode = X"105" then --F1 + imageCount <= X"00"; + elsif keyCode = X"106" then + imageCount <= X"01"; + elsif keyCode = X"104" then + imageCount <= X"02"; + elsif keyCode = X"10C" then + imageCount <= X"03"; + elsif keyCode = X"103" then + imageCount <= X"04"; + elsif keyCode = X"10B" then + imageCount <= X"05"; + elsif keyCode = X"183" then + imageCount <= X"06"; + elsif keyCode = X"10A" then + imageCount <= X"07"; + elsif keyCode = X"101" then + imageCount <= X"08"; + elsif keyCode = X"109" then --F10 + imageCount <= X"09"; + else + imageCount <= imageCount + 0; + end if; + end process; power_on : process(CLK_14M) begin if rising_edge(CLK_14M) then - if flash_clk(22) = '1' then + if flash_clk(22) = '1' and resetKey = '0' then power_on_reset <= '0'; - end if; + elsif resetKey = '1' then + power_on_reset <= '1'; + end if; end if; end process; @@ -126,7 +162,11 @@ begin flash_clkgen : process (CLK_14M) begin if rising_edge(CLK_14M) then - flash_clk <= flash_clk + 1; + if resetKey = '0' then + flash_clk <= flash_clk + 1; + else + flash_clk <= "00000000000000000000000"; + end if; end if; end process; @@ -138,6 +178,8 @@ begin O_CLK_28M => CLK_28M, O_CLK_14M => CLK_14M ); + + BTN3 <= '1'; -- joystick inputs, these should probably be debounced first csjudlr1 <= "00" & JOYSTICK1; @@ -149,7 +191,7 @@ begin -- y x bt3 bt2 bt1 -- Paddle buttons - GAMEPORT <= "00" & joy1_y & joy1_x & SW_LEFT & SW_UP & not csjudlr1(4) & '0'; --"0000" & "0000"; -- (not KEY(2 downto 0)) & "0"; + GAMEPORT <= "00" & joy1_y & joy1_x & not BTN3 & not BTN2 & not csjudlr1(4) & '0'; --"0000" & "0000"; -- (not KEY(2 downto 0)) & "0"; -- fake analog joystick... -- PDL_STROBE starts the counter @@ -244,6 +286,7 @@ begin PS2_Data => PS2_DAT, CLK_14M => CLK_14M, reset => reset, + key_code => keyCode, --Q read => read_key, K => K ); @@ -284,7 +327,7 @@ begin ram_we => TRACK_RAM_WE ); - image <= "0" & "000000000"; + image <= "00" & imageCount; --disk image selection SD_DAT3 <= CS_N; SD_CMD <= MOSI; @@ -309,7 +352,6 @@ begin SRAM_WE_N <= not ram_we; LED <= not CS_N; --Led SD +-- LED2 <= '1' when imageCount = "0000000001" else '0'; --Led ext3 - -- Set all other unused bidirectional ports to tri-state - end datapath; diff --git a/cores/Apple2/source/apple2_zxuno_v2.ucf b/cores/Apple2/source/apple2_zxuno_v2.ucf index a4fad14..37049e9 100644 --- a/cores/Apple2/source/apple2_zxuno_v2.ucf +++ b/cores/Apple2/source/apple2_zxuno_v2.ucf @@ -61,16 +61,13 @@ NET SRAM_DQ<7> LOC="P104" | IOSTANDARD = LVCMOS33; NET SRAM_WE_N LOC="P134" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(0) LOC="P142" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(1) LOC="P1" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(2) LOC="P2" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(4) LOC="P5" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(3) LOC="P143" | IOSTANDARD=LVCMOS33; +NET JOYSTICK1(0) LOC="P5" | IOSTANDARD=LVCMOS33 | PULLUP; #right +NET JOYSTICK1(1) LOC="P2" | IOSTANDARD=LVCMOS33 | PULLUP; #left +NET JOYSTICK1(2) LOC="P1" | IOSTANDARD=LVCMOS33 | PULLUP; #down +NET JOYSTICK1(4) LOC="P6" | IOSTANDARD=LVCMOS33 | PULLUP; #btn1 +NET JOYSTICK1(3) LOC="P142" | IOSTANDARD=LVCMOS33 | PULLUP; #up +NET BTN2 LOC="P143" | IOSTANDARD=LVCMOS33 | PULLUP; #btn2 NET LED LOC="P10" | IOSTANDARD=LVCMOS33; +#NET LED2 LOC="P11" | IOSTANDARD=LVCMOS33; #EXT3 test led - -#NET SW_LEFT LOC="P33" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_UP LOC="P34" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_DOWN LOC="P101" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_RIGHT LOC="P100" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; \ No newline at end of file diff --git a/cores/Apple2/source/apple2_zxuno_v3.ucf b/cores/Apple2/source/apple2_zxuno_v3.ucf index 7736c96..742b10b 100644 --- a/cores/Apple2/source/apple2_zxuno_v3.ucf +++ b/cores/Apple2/source/apple2_zxuno_v3.ucf @@ -61,15 +61,12 @@ NET SRAM_DQ(7) LOC="P127" | IOSTANDARD=LVCMOS33; NET SRAM_WE_N LOC="P118" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(0) LOC="P1" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(1) LOC="P5" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(2) LOC="P6" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(4) LOC="P7" | IOSTANDARD=LVCMOS33; -NET JOYSTICK1(3) LOC="P2" | IOSTANDARD=LVCMOS33; +NET JOYSTICK1(0) LOC="P7" | IOSTANDARD=LVCMOS33 | PULLUP; #right +NET JOYSTICK1(1) LOC="P6" | IOSTANDARD=LVCMOS33 | PULLUP; #left +NET JOYSTICK1(2) LOC="P5" | IOSTANDARD=LVCMOS33 | PULLUP; #down +NET JOYSTICK1(4) LOC="P2" | IOSTANDARD=LVCMOS33 | PULLUP; #btn1 +NET JOYSTICK1(3) LOC="P1" | IOSTANDARD=LVCMOS33 | PULLUP; #up +NET BTN2 LOC="P39" | IOSTANDARD=LVCMOS33 | PULLUP; #btn2 NET LED LOC="P10" | IOSTANDARD=LVCMOS33; - -#NET SW_LEFT LOC="P33" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_UP LOC="P34" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_DOWN LOC="P101" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; -#NET SW_RIGHT LOC="P100" | IOSTANDARD=LVCMOS33 | DRIVE=8 | SLEW=FAST; \ No newline at end of file +#NET LED2 LOC="P11" | IOSTANDARD=LVCMOS33; #EXT3 test led diff --git a/cores/Apple2/source/keyboard.vhd b/cores/Apple2/source/keyboard.vhd index 4c5a72b..737ed92 100644 --- a/cores/Apple2/source/keyboard.vhd +++ b/cores/Apple2/source/keyboard.vhd @@ -24,6 +24,7 @@ entity keyboard is CLK_14M : in std_logic; read : in std_logic; -- Read strobe reset : in std_logic; + key_code : out unsigned(11 downto 0); K : out unsigned(7 downto 0) -- Latched, decoded keyboard data ); end keyboard; @@ -69,9 +70,9 @@ begin Scan_DAV => code_available, Scan_Code => code); - K <= key_pressed & "00" & ascii(4 downto 0) when ctrl = '1' else - key_pressed & ascii(6 downto 0); - + K <= key_pressed & "00" & ascii(4 downto 0) when ctrl = '1' and ascii /= "00" else + key_pressed & ascii(6 downto 0) when ascii /= "00" else X"00"; --Q ascii + shift_ctrl : process (CLK_14M, reset) begin if reset = '1' then @@ -132,6 +133,7 @@ begin elsif code = LEFT_SHIFT or code = RIGHT_SHIFT or code = LEFT_CTRL then next_state <= IDLE; else + next_state <= NORMAL_KEY; end if; @@ -155,6 +157,8 @@ begin shifted_code <= "00" & alt & shift & latched_code; + key_code <= shifted_code when state = KEY_UP else X"000"; --Q + EN_us: if KEYMAP = "EN-us" generate with shifted_code select ascii <=