addr <= conv_std_logic_vector(ad, 16);\r
d_io <= conv_std_logic_vector(dt, 8);\r
end;\r
+\r
procedure io_brk is\r
begin\r
addr <= (others => 'Z');\r
r_nw <= 'Z';\r
end;\r
\r
+procedure io_read (ad: in integer) is\r
+begin\r
+ r_nw <= '1';\r
+ addr <= conv_std_logic_vector(ad, 16);\r
+ d_io <= (others => 'Z');\r
+end;\r
+\r
begin\r
if (rst_n = '0') then\r
\r
io_out(16#2006#, 16#02#);\r
elsif (init_step_cnt = 5 * cpu_io_multi) then\r
io_out(16#2006#, 16#40#);\r
+ elsif (init_step_cnt = 6 * cpu_io_multi) then\r
+ --scroll\r
+ io_out(16#2005#, 16#21#);\r
+ elsif (init_step_cnt = 7 * cpu_io_multi) then\r
+ io_out(16#2005#, 16#5#);\r
else\r
io_brk;\r
- if (init_step_cnt > 5 * cpu_io_multi) then\r
+ if (init_step_cnt > 8 * cpu_io_multi) then\r
global_step_cnt := global_step_cnt + 1;\r
end if;\r
end if;\r
if (spr_step_cnt = 0) then\r
--set sprite addr=00 (first sprite)\r
io_out(16#2003#, 16#00#);\r
+ \r
elsif (spr_step_cnt = 1 * cpu_io_multi) then\r
--set sprite data: y=02\r
- io_out(16#2004#, 16#01#);\r
+ io_out(16#2004#, 16#05#);\r
elsif (spr_step_cnt = 2 * cpu_io_multi) then\r
- --tile=0x4d (ascii 'M')\r
- io_out(16#2004#, 16#4d#);\r
+ --tile=0x4d (ascii 'O')\r
+ io_out(16#2004#, 16#4f#);\r
elsif (spr_step_cnt = 3 * cpu_io_multi) then\r
- --set sprite attr=03 (palette 03)\r
+ --set sprite attr=01 (palette 01)\r
io_out(16#2004#, 16#01#);\r
elsif (spr_step_cnt = 4 * cpu_io_multi) then\r
- --set sprite data: x=100\r
- io_out(16#2004#, 16#64#);\r
+ --set sprite data: x=60\r
+ io_out(16#2004#, 16#3c#);\r
\r
elsif (spr_step_cnt = 5 * cpu_io_multi) then\r
--set sprite data: y=50\r
- io_out(16#2004#, 8);\r
+ io_out(16#2004#, 1);\r
elsif (spr_step_cnt = 6 * cpu_io_multi) then\r
- --tile=0x4d (ascii 'O')\r
- io_out(16#2004#, 16#4f#);\r
+ --tile=0x4f (ascii 'M')\r
+ io_out(16#2004#, 16#4d#);\r
elsif (spr_step_cnt = 7 * cpu_io_multi) then\r
- --set sprite attr=01\r
- io_out(16#2004#, 16#01#);\r
+ --set sprite attr=02\r
+ io_out(16#2004#, 16#02#);\r
elsif (spr_step_cnt = 8 * cpu_io_multi) then\r
- --set sprite data: x=30\r
- io_out(16#2004#, 16#1e#);\r
+ --set sprite data: x=100\r
+ io_out(16#2004#, 16#64#);\r
\r
elsif (spr_step_cnt = 9 * cpu_io_multi) then\r
--set sprite data: y=60\r
dma_step_cnt := dma_step_cnt + 1;\r
\r
elsif (global_step_cnt = 5) then\r
- --step4 = scroll test.\r
+ --step4 = scroll test and ppu reg read test.\r
if (scl_step_cnt = 0) then\r
--x scroll pos=123\r
- io_out(16#2005#, 0);\r
+ io_out(16#2005#, 11);\r
elsif (scl_step_cnt = 1 * cpu_io_multi) then\r
--y scroll pos=100\r
io_out(16#2005#, 0);\r
\r
+ elsif (scl_step_cnt = 2 * cpu_io_multi) then\r
+ --read status reg.\r
+ io_read(16#2002#);\r
+\r
+ elsif (scl_step_cnt = 3 * cpu_io_multi) then\r
+ --read vram nt0.\r
+ io_out(16#2006#, 16#20#);\r
+\r
+ elsif (scl_step_cnt = 4 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#03#);\r
+\r
+ elsif (scl_step_cnt = 5 * cpu_io_multi) then\r
+ io_read(16#2007#);\r
+\r
+ elsif (scl_step_cnt = 6 * cpu_io_multi) then\r
+ --pattern tbl.\r
+ io_out(16#2006#, 16#04#);\r
+\r
+ elsif (scl_step_cnt = 7 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#d1#);\r
+\r
+ elsif (scl_step_cnt = 8 * cpu_io_multi) then\r
+ io_read(16#2007#);\r
+\r
+ elsif (scl_step_cnt = 9 * cpu_io_multi) then\r
+ --attr tbl.\r
+ io_out(16#2006#, 16#23#);\r
+\r
+ elsif (scl_step_cnt = 10 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#c0#);\r
+\r
+ elsif (scl_step_cnt = 11 * cpu_io_multi) then\r
+ --set attr first.\r
+ io_out(16#2007#, 16#5a#);\r
+\r
+ elsif (scl_step_cnt = 12 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#23#);\r
+\r
+ elsif (scl_step_cnt = 13 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#c0#);\r
+\r
+ elsif (scl_step_cnt = 14 * cpu_io_multi) then\r
+ io_read(16#2007#);\r
+\r
+ elsif (scl_step_cnt = 15 * cpu_io_multi) then\r
+ --read palette tbl.\r
+ io_out(16#2006#, 16#3f#);\r
+\r
+ elsif (scl_step_cnt = 16 * cpu_io_multi) then\r
+ io_out(16#2006#, 16#11#);\r
+\r
+ elsif (scl_step_cnt = 17 * cpu_io_multi) then\r
+ io_read(16#2007#);\r
+\r
else\r
io_brk;\r
- if (scl_step_cnt > 1 * cpu_io_multi) then\r
+ if (scl_step_cnt > 17 * cpu_io_multi) then\r
global_step_cnt := global_step_cnt + 1;\r
end if;\r
end if;\r
--scroll y++\r
-- io_out(16#2005#, nmi_scl_y);\r
io_brk;\r
+ elsif (nmi_step_cnt = 4 * cpu_io_multi) then\r
+ --set sprite addr=00 (first sprite)\r
+ io_out(16#2003#, 16#04#);\r
+ elsif (nmi_step_cnt = 5 * cpu_io_multi) then\r
+ --set sprite data: x=100\r
+ io_out(16#2004#, nmi_oam_x);\r
else\r
if (ref_cnt = 0) then\r
nmi_oam_x := nmi_oam_x + 1;\r
nmi_scl_y := nmi_scl_y + 1;\r
end if;\r
io_brk;\r
- if (nmi_step_cnt > 3 * cpu_io_multi) then\r
+ if (nmi_step_cnt > 5 * cpu_io_multi) then\r
ref_cnt := ref_cnt + 1;\r
global_step_cnt := global_step_cnt + 1;\r
end if;\r