X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=de1_nes%2Fdummy-mos6502.vhd;h=955540e4cf668fc06f7e407a835b60afb8dbf0db;hb=5b02fcd0e44bb050b0eba3370eb912c93a7e32fa;hp=730e8d6e966f22b64767e502ff0d2f18ea2b5dc7;hpb=e0742cec7b5f9b2fc5b592277497b8275b3d0212;p=motonesfpga%2Fmotonesfpga.git diff --git a/de1_nes/dummy-mos6502.vhd b/de1_nes/dummy-mos6502.vhd index 730e8d6..955540e 100644 --- a/de1_nes/dummy-mos6502.vhd +++ b/de1_nes/dummy-mos6502.vhd @@ -62,6 +62,7 @@ begin addr <= conv_std_logic_vector(ad, 16); d_io <= conv_std_logic_vector(dt, 8); end; + procedure io_brk is begin addr <= (others => 'Z'); @@ -69,6 +70,13 @@ begin r_nw <= 'Z'; end; +procedure io_read (ad: in integer) is +begin + r_nw <= '1'; + addr <= conv_std_logic_vector(ad, 16); + d_io <= (others => 'Z'); +end; + begin if (rst_n = '0') then @@ -113,9 +121,14 @@ end; io_out(16#2006#, 16#02#); elsif (init_step_cnt = 5 * cpu_io_multi) then io_out(16#2006#, 16#40#); + elsif (init_step_cnt = 6 * cpu_io_multi) then + --scroll + io_out(16#2005#, 16#21#); + elsif (init_step_cnt = 7 * cpu_io_multi) then + io_out(16#2005#, 16#5#); else io_brk; - if (init_step_cnt > 5 * cpu_io_multi) then + if (init_step_cnt > 8 * cpu_io_multi) then global_step_cnt := global_step_cnt + 1; end if; end if; @@ -275,31 +288,32 @@ end; if (spr_step_cnt = 0) then --set sprite addr=00 (first sprite) io_out(16#2003#, 16#00#); + elsif (spr_step_cnt = 1 * cpu_io_multi) then --set sprite data: y=02 - io_out(16#2004#, 16#01#); + io_out(16#2004#, 16#05#); elsif (spr_step_cnt = 2 * cpu_io_multi) then - --tile=0x4d (ascii 'M') - io_out(16#2004#, 16#4d#); + --tile=0x4d (ascii 'O') + io_out(16#2004#, 16#4f#); elsif (spr_step_cnt = 3 * cpu_io_multi) then - --set sprite attr=03 (palette 03) + --set sprite attr=01 (palette 01) io_out(16#2004#, 16#01#); elsif (spr_step_cnt = 4 * cpu_io_multi) then - --set sprite data: x=100 - io_out(16#2004#, 16#64#); + --set sprite data: x=60 + io_out(16#2004#, 16#3c#); elsif (spr_step_cnt = 5 * cpu_io_multi) then --set sprite data: y=50 - io_out(16#2004#, 8); + io_out(16#2004#, 1); elsif (spr_step_cnt = 6 * cpu_io_multi) then - --tile=0x4d (ascii 'O') - io_out(16#2004#, 16#4f#); + --tile=0x4f (ascii 'M') + io_out(16#2004#, 16#4d#); elsif (spr_step_cnt = 7 * cpu_io_multi) then - --set sprite attr=01 - io_out(16#2004#, 16#01#); + --set sprite attr=02 + io_out(16#2004#, 16#02#); elsif (spr_step_cnt = 8 * cpu_io_multi) then - --set sprite data: x=30 - io_out(16#2004#, 16#1e#); + --set sprite data: x=100 + io_out(16#2004#, 16#64#); elsif (spr_step_cnt = 9 * cpu_io_multi) then --set sprite data: y=60 @@ -378,17 +392,71 @@ end; dma_step_cnt := dma_step_cnt + 1; elsif (global_step_cnt = 5) then - --step4 = scroll test. + --step4 = scroll test and ppu reg read test. if (scl_step_cnt = 0) then --x scroll pos=123 - io_out(16#2005#, 0); + io_out(16#2005#, 11); elsif (scl_step_cnt = 1 * cpu_io_multi) then --y scroll pos=100 io_out(16#2005#, 0); + elsif (scl_step_cnt = 2 * cpu_io_multi) then + --read status reg. + io_read(16#2002#); + + elsif (scl_step_cnt = 3 * cpu_io_multi) then + --read vram nt0. + io_out(16#2006#, 16#20#); + + elsif (scl_step_cnt = 4 * cpu_io_multi) then + io_out(16#2006#, 16#03#); + + elsif (scl_step_cnt = 5 * cpu_io_multi) then + io_read(16#2007#); + + elsif (scl_step_cnt = 6 * cpu_io_multi) then + --pattern tbl. + io_out(16#2006#, 16#04#); + + elsif (scl_step_cnt = 7 * cpu_io_multi) then + io_out(16#2006#, 16#d1#); + + elsif (scl_step_cnt = 8 * cpu_io_multi) then + io_read(16#2007#); + + elsif (scl_step_cnt = 9 * cpu_io_multi) then + --attr tbl. + io_out(16#2006#, 16#23#); + + elsif (scl_step_cnt = 10 * cpu_io_multi) then + io_out(16#2006#, 16#c0#); + + elsif (scl_step_cnt = 11 * cpu_io_multi) then + --set attr first. + io_out(16#2007#, 16#5a#); + + elsif (scl_step_cnt = 12 * cpu_io_multi) then + io_out(16#2006#, 16#23#); + + elsif (scl_step_cnt = 13 * cpu_io_multi) then + io_out(16#2006#, 16#c0#); + + elsif (scl_step_cnt = 14 * cpu_io_multi) then + io_read(16#2007#); + + elsif (scl_step_cnt = 15 * cpu_io_multi) then + --read palette tbl. + io_out(16#2006#, 16#3f#); + + elsif (scl_step_cnt = 16 * cpu_io_multi) then + io_out(16#2006#, 16#11#); + + elsif (scl_step_cnt = 17 * cpu_io_multi) then + io_read(16#2007#); + else io_brk; - if (scl_step_cnt > 1 * cpu_io_multi) then + if (scl_step_cnt > 17 * cpu_io_multi) then global_step_cnt := global_step_cnt + 1; end if; end if; @@ -431,6 +499,12 @@ end; --scroll y++ -- io_out(16#2005#, nmi_scl_y); io_brk; + elsif (nmi_step_cnt = 4 * cpu_io_multi) then + --set sprite addr=00 (first sprite) + io_out(16#2003#, 16#04#); + elsif (nmi_step_cnt = 5 * cpu_io_multi) then + --set sprite data: x=100 + io_out(16#2004#, nmi_oam_x); else if (ref_cnt = 0) then nmi_oam_x := nmi_oam_x + 1; @@ -439,7 +513,7 @@ end; nmi_scl_y := nmi_scl_y + 1; end if; io_brk; - if (nmi_step_cnt > 3 * cpu_io_multi) then + if (nmi_step_cnt > 5 * cpu_io_multi) then ref_cnt := ref_cnt + 1; global_step_cnt := global_step_cnt + 1; end if;