From ec32192117f65e5ea68ee1cf06d2e01bb04ace53 Mon Sep 17 00:00:00 2001 From: greyrogue Date: Sun, 20 Feb 2022 20:02:01 -0500 Subject: [PATCH] NSF/MIDI phase complete (#297) -All expansion audio visualizers working -MIDI can now switch between controlling APU Pulse/Triangle split, APU Pulse, APU Triangle, MMC5 Pulse and MMC5 Pulse/APU Triangle split with C0 (patch commands) -- If patch bit 6 ($40-$7F), APU Triangle only and uses normal octaves. -- If patch bit 3 ($8). Then behaves like below, but uses MMC5 pulses in place of APU pulses -- If patch bit 2 ($4). Then only pulses used. If not set, triangle is used at G#3 and is up one octave. iei G3->G4 for the triangle. -- Patch bits 0 and 1 ($0-$03) set the pulse duty cycle. --- NES.sv | 2 +- rtl/cart.sv | 1 + rtl/font.chr | Bin 0 -> 2048 bytes rtl/loopy_NSF.mif | 2066 +++++++++++++++++++++++++++---------------- rtl/mappers/misc.sv | 328 ++++++- rtl/nes.v | 2 +- rtl/nsf.asm | 893 +++++++++++++++++++ 7 files changed, 2547 insertions(+), 745 deletions(-) create mode 100644 rtl/font.chr create mode 100644 rtl/nsf.asm diff --git a/NES.sv b/NES.sv index 29a3b77..b1c05b3 100644 --- a/NES.sv +++ b/NES.sv @@ -1642,7 +1642,7 @@ always @(posedge clk) begin ines[12] <= 8'h00; ines[13] <= 8'h00; ines[14] <= 8'h00; - ines[15] <= 8'h00; + ines[15] <= 8'h19;//miracle piano; controllers swapped state <= S_COPYPLAY; clearclk <= 4'h0; end diff --git a/rtl/cart.sv b/rtl/cart.sv index 5f16f36..c74c338 100644 --- a/rtl/cart.sv +++ b/rtl/cart.sv @@ -2110,6 +2110,7 @@ NSF nsfplayer( .chr_ain (chr_ain), .chr_aout_b (chr_addr_b), .chr_read (chr_read), + .chr_dout_b (chr_dout_b), // Special port .chr_allow_b(chr_allow_b), .vram_a10_b (vram_a10_b), .vram_ce_b (vram_ce_b), diff --git a/rtl/font.chr b/rtl/font.chr new file mode 100644 index 0000000000000000000000000000000000000000..f189b0c57ea0241e66b8a4a5d47074a66651941e GIT binary patch literal 2048 zcmd5-J&W5w5SGjr|}@+_f!J0Cl{J2S34p@IQ+WfALvLgjsIi%#)L zK2iG9yu56>nB|>oy_Q!VCzO8Y<0P?`_0c~)ns2myRxW(!J8%?ux&GWk_@x;D(u-!IMV;wAHJzO)yMr_75Yoim|9L`>*q#N=20mZT7)_$B{`*H0J#PRQMCjQEJqY zXA3-VkOR!m-@bk`&)MK_*BjRB_gd9E7Hfwuub(FbiDwfdUP(Wy>+NBy^s)L8Qs4fr z+u?<>zxwCrPhRO))E*x83+xY$^-2Eq%QbUqHXpYVAI4vel>MfUH(~wWy^>RQm1V|q z?{~ZIZlQRYl`7ut_Bl0RmbY|!u4O*$*PAlGafMCd3G)?M+ZA(jCTsB|!0%y<=`jq$ zcilA23!ZcCfc(H5^9zrwVjjm8%7p{0n^wuE*0vZB>!UrY$9$paj1~}i0<^;;zUK`& z*X)1oML+A$L+Qiq4k7kH?nR&CYZ_i2^-z9L32+~u{Gq|OA38tK-mT*U`(O3jlluUm z<+OjIdjFUJyOQkzJSBkQq+U3gXt7_lOyej@qDaESW(o8TDALrXX)#dxKDpEk08>Kl F>koFPt9t+d literal 0 HcmV?d00001 diff --git a/rtl/loopy_NSF.mif b/rtl/loopy_NSF.mif index c54f6ef..029bb5e 100644 --- a/rtl/loopy_NSF.mif +++ b/rtl/loopy_NSF.mif @@ -34,7 +34,7 @@ CONTENT BEGIN 019A : 06; 019B : 20; 019C : A9; - 019D : 32; + 019D : 18; 019E : 85; 019F : 00; 01A0 : A9; @@ -110,12 +110,12 @@ CONTENT BEGIN 01E6 : D0; 01E7 : F7; 01E8 : A9; - 01E9 : 22; + 01E9 : 20; 01EA : 8D; 01EB : 06; 01EC : 20; 01ED : A9; - 01EE : 10; + 01EE : 70; 01EF : 8D; 01F0 : 06; 01F1 : 20; @@ -128,8 +128,8 @@ CONTENT BEGIN 01F8 : 06; 01F9 : 41; 01FA : 20; - 01FB : 05; - 01FC : 45; + 01FB : EB; + 01FC : 44; 01FD : B9; 01FE : FC; 01FF : 01; @@ -145,7 +145,7 @@ CONTENT BEGIN 0209 : 06; 020A : 20; 020B : A9; - 020C : C2; + 020C : 42; 020D : 8D; 020E : 06; 020F : 20; @@ -165,12 +165,12 @@ CONTENT BEGIN 021D : D0; 021E : F3; 021F : A9; - 0220 : 21; + 0220 : 20; 0221 : 8D; 0222 : 06; 0223 : 20; 0224 : A9; - 0225 : 02; + 0225 : 22; 0226 : 8D; 0227 : 06; 0228 : 20; @@ -190,12 +190,12 @@ CONTENT BEGIN 0236 : D0; 0237 : F3; 0238 : A9; - 0239 : 21; + 0239 : 20; 023A : 8D; 023B : 06; 023C : 20; 023D : A9; - 023E : 42; + 023E : 02; 023F : 8D; 0240 : 06; 0241 : 20; @@ -270,8 +270,8 @@ CONTENT BEGIN 0286 : 2E; 0287 : 44; 0288 : 4C; - 0289 : 77; - 028A : 42; + 0289 : ED; + 028A : 4F; 028B : AD; 028C : 02; 028D : 20; @@ -361,8 +361,8 @@ CONTENT BEGIN 02E1 : F4; 02E2 : 01; 02E3 : 20; - 02E4 : 05; - 02E5 : 45; + 02E4 : EB; + 02E5 : 44; 02E6 : A9; 02E7 : 20; 02E8 : C8; @@ -382,12 +382,12 @@ CONTENT BEGIN 02F6 : 10; 02F7 : FB; 02F8 : A9; - 02F9 : 22; + 02F9 : 20; 02FA : 8D; 02FB : 06; 02FC : 20; 02FD : A9; - 02FE : 0D; + 02FE : 6D; 02FF : 8D; 0300 : 06; 0301 : 20; @@ -795,8 +795,8 @@ CONTENT BEGIN 0499 : 90; 049A : 03; 049B : 4C; - 049C : 12; - 049D : 45; + 049C : F8; + 049D : 44; 049E : 0A; 049F : 90; 04A0 : 08; @@ -815,734 +815,1322 @@ CONTENT BEGIN 04AF : B0; 04B0 : C5; 04B1 : 60; - 04B2 : A2; - 04B3 : 01; - 04B4 : 8E; - 04B5 : 16; - 04B6 : 40; - 04B7 : CA; - 04B8 : 8E; - 04B9 : 16; - 04BA : 40; - 04BB : A2; - 04BC : 08; - 04BD : 18; - 04BE : AD; - 04BF : 17; - 04C0 : 40; - 04C1 : AD; - 04C2 : 16; - 04C3 : 40; - 04C4 : 09; - 04C5 : FC; - 04C6 : 69; - 04C7 : 03; - 04C8 : 2E; - 04C9 : F6; - 04CA : 01; - 04CB : CA; - 04CC : D0; - 04CD : EF; - 04CE : 60; - 04CF : A2; - 04D0 : 00; - 04D1 : 8E; - 04D2 : FB; - 04D3 : 01; - 04D4 : C9; - 04D5 : A0; - 04D6 : 90; - 04D7 : 02; - 04D8 : E9; - 04D9 : A0; - 04DA : 2E; - 04DB : FB; - 04DC : 01; - 04DD : C9; - 04DE : 50; - 04DF : 90; - 04E0 : 02; - 04E1 : E9; - 04E2 : 50; - 04E3 : 2E; - 04E4 : FB; - 04E5 : 01; - 04E6 : C9; - 04E7 : 28; - 04E8 : 90; - 04E9 : 02; - 04EA : E9; - 04EB : 28; - 04EC : 2E; - 04ED : FB; - 04EE : 01; - 04EF : C9; - 04F0 : 14; - 04F1 : 90; - 04F2 : 02; - 04F3 : E9; - 04F4 : 14; - 04F5 : 2E; - 04F6 : FB; - 04F7 : 01; - 04F8 : C9; - 04F9 : 0A; - 04FA : 90; - 04FB : 02; - 04FC : E9; - 04FD : 0A; - 04FE : 2E; - 04FF : FB; - 0500 : 01; - 0501 : AE; - 0502 : FB; - 0503 : 01; - 0504 : 60; - 0505 : A0; - 0506 : FF; - 0507 : 20; - 0508 : CF; - 0509 : 44; - 050A : C8; - 050B : 99; - 050C : FC; - 050D : 01; - 050E : 8A; - 050F : D0; - 0510 : F6; - 0511 : 60; - 0512 : A9; - 0513 : 00; - 0514 : 8D; - 0515 : 00; - 0516 : 20; - 0517 : 8D; - 0518 : 01; - [0519..051A] : 20; - 051B : 9D; - 051C : 43; - 051D : A2; - 051E : 07; - 051F : BD; - 0520 : 2A; - 0521 : 45; - 0522 : 95; - 0523 : 00; - 0524 : CA; - 0525 : 10; - 0526 : F8; - 0527 : 4C; - [0528..0529] : 00; - 052A : A9; - 052B : 01; - 052C : 8D; - 052D : 07; - 052E : 42; - 052F : 6C; - 0530 : FC; - 0531 : FF; - 0532 : 7C; - [0533..0537] : C6; + 04B2 : 4C; + 04B3 : C0; + 04B4 : 4D; + 04B5 : A2; + 04B6 : 00; + 04B7 : 8E; + 04B8 : FB; + 04B9 : 01; + 04BA : C9; + 04BB : A0; + 04BC : 90; + 04BD : 02; + 04BE : E9; + 04BF : A0; + 04C0 : 2E; + 04C1 : FB; + 04C2 : 01; + 04C3 : C9; + 04C4 : 50; + 04C5 : 90; + 04C6 : 02; + 04C7 : E9; + 04C8 : 50; + 04C9 : 2E; + 04CA : FB; + 04CB : 01; + 04CC : C9; + 04CD : 28; + 04CE : 90; + 04CF : 02; + 04D0 : E9; + 04D1 : 28; + 04D2 : 2E; + 04D3 : FB; + 04D4 : 01; + 04D5 : C9; + 04D6 : 14; + 04D7 : 90; + 04D8 : 02; + 04D9 : E9; + 04DA : 14; + 04DB : 2E; + 04DC : FB; + 04DD : 01; + 04DE : C9; + 04DF : 0A; + 04E0 : 90; + 04E1 : 02; + 04E2 : E9; + 04E3 : 0A; + 04E4 : 2E; + 04E5 : FB; + 04E6 : 01; + 04E7 : AE; + 04E8 : FB; + 04E9 : 01; + 04EA : 60; + 04EB : A0; + 04EC : FF; + 04ED : 20; + 04EE : B5; + 04EF : 44; + 04F0 : C8; + 04F1 : 99; + 04F2 : FC; + 04F3 : 01; + 04F4 : 8A; + 04F5 : D0; + 04F6 : F6; + 04F7 : 60; + 04F8 : A9; + 04F9 : 00; + 04FA : 8D; + 04FB : 00; + 04FC : 20; + 04FD : 8D; + 04FE : 01; + [04FF..0500] : 20; + 0501 : 9D; + 0502 : 43; + 0503 : A2; + 0504 : 07; + 0505 : BD; + 0506 : 10; + 0507 : 45; + 0508 : 95; + 0509 : 00; + 050A : CA; + 050B : 10; + 050C : F8; + 050D : 4C; + [050E..050F] : 00; + 0510 : A9; + 0511 : 01; + 0512 : 8D; + 0513 : 07; + 0514 : 42; + 0515 : 6C; + 0516 : FC; + 0517 : FF; + 0518 : 7C; + [0519..051D] : C6; + 051E : 7C; + [051F..0527] : 00; + 0528 : 30; + 0529 : 70; + [052A..052D] : 30; + 052E : 78; + [052F..0537] : 00; 0538 : 7C; - [0539..0541] : 00; - 0542 : 30; - 0543 : 70; - [0544..0547] : 30; - 0548 : 78; - [0549..0551] : 00; - 0552 : 7C; - [0553..0554] : C6; - 0555 : 0C; - 0556 : 30; - 0557 : 60; - 0558 : FE; - [0559..0561] : 00; - 0562 : 7C; - 0563 : C6; - 0564 : 06; - 0565 : 3C; - 0566 : 06; - 0567 : C6; - 0568 : 7C; - [0569..0571] : 00; - 0572 : 1C; - 0573 : 3C; - 0574 : 6C; - 0575 : 4C; - 0576 : CC; - 0577 : FE; - 0578 : 0C; - [0579..0581] : 00; - 0582 : FE; - 0583 : C0; - 0584 : FC; - 0585 : C6; - 0586 : 06; - 0587 : C6; - 0588 : 7C; - [0589..0591] : 00; - 0592 : 7C; - 0593 : C6; - 0594 : C0; - 0595 : FC; - [0596..0597] : C6; + [0539..053A] : C6; + 053B : 0C; + 053C : 30; + 053D : 60; + 053E : FE; + [053F..0547] : 00; + 0548 : 7C; + 0549 : C6; + 054A : 06; + 054B : 3C; + 054C : 06; + 054D : C6; + 054E : 7C; + [054F..0557] : 00; + 0558 : 1C; + 0559 : 3C; + 055A : 6C; + 055B : 4C; + 055C : CC; + 055D : FE; + 055E : 0C; + [055F..0567] : 00; + 0568 : FE; + 0569 : C0; + 056A : FC; + 056B : C6; + 056C : 06; + 056D : C6; + 056E : 7C; + [056F..0577] : 00; + 0578 : 7C; + 0579 : C6; + 057A : C0; + 057B : FC; + [057C..057D] : C6; + 057E : 7C; + [057F..0587] : 00; + 0588 : FE; + 0589 : C6; + 058A : 0C; + [058B..058C] : 18; + [058D..058E] : 30; + [058F..0597] : 00; 0598 : 7C; - [0599..05A1] : 00; - 05A2 : FE; - 05A3 : C6; - 05A4 : 0C; - [05A5..05A6] : 18; - [05A7..05A8] : 30; - [05A9..05B1] : 00; - 05B2 : 7C; - [05B3..05B4] : C6; - 05B5 : 7C; - [05B6..05B7] : C6; - 05B8 : 7C; - [05B9..05C1] : 00; - 05C2 : 7C; - [05C3..05C4] : C6; - 05C5 : 7E; - 05C6 : 06; - 05C7 : C6; - 05C8 : 7C; - [05C9..05D1] : 00; - 05D2 : 38; - 05D3 : 6C; - 05D4 : 44; - 05D5 : C6; - 05D6 : FE; - [05D7..05D8] : C6; - [05D9..05E1] : 00; - 05E2 : FC; - [05E3..05E4] : C2; - 05E5 : FC; - [05E6..05E7] : C2; + [0599..059A] : C6; + 059B : 7C; + [059C..059D] : C6; + 059E : 7C; + [059F..05A7] : 00; + 05A8 : 7C; + [05A9..05AA] : C6; + 05AB : 7E; + 05AC : 06; + 05AD : C6; + 05AE : 7C; + [05AF..05B7] : 00; + 05B8 : 38; + 05B9 : 6C; + 05BA : 44; + 05BB : C6; + 05BC : FE; + [05BD..05BE] : C6; + [05BF..05C7] : 00; + 05C8 : FC; + [05C9..05CA] : C2; + 05CB : FC; + [05CC..05CD] : C2; + 05CE : FC; + [05CF..05D7] : 00; + 05D8 : 7C; + 05D9 : C2; + [05DA..05DC] : C0; + 05DD : C2; + 05DE : 7C; + [05DF..05E7] : 00; 05E8 : FC; - [05E9..05F1] : 00; - 05F2 : 7C; - 05F3 : C2; - [05F4..05F6] : C0; - 05F7 : C2; - 05F8 : 7C; - [05F9..0601] : 00; - 0602 : FC; - [0603..0607] : C2; - 0608 : FC; - [0609..0611] : 00; - 0612 : FE; - [0613..0614] : C0; - 0615 : FC; - [0616..0617] : C0; - 0618 : FE; - [0619..0621] : 00; - 0622 : FE; - [0623..0624] : C0; - 0625 : FC; - [0626..0628] : C0; - [0629..0741] : 00; - [0742..0746] : 08; - 0747 : 00; - 0748 : 08; - [0749..0751] : 00; - [0752..0753] : 6C; - 0754 : 24; - 0755 : 48; - [0756..0762] : 00; - 0763 : 24; - 0764 : 7E; - [0765..0766] : 24; - 0767 : 7E; - 0768 : 24; - [0769..0771] : 00; - 0772 : 10; - 0773 : 3C; - 0774 : 50; - 0775 : 38; - 0776 : 14; - 0777 : 78; - 0778 : 10; - [0779..0781] : 00; - 0782 : 42; - 0783 : A4; - 0784 : 48; - 0785 : 10; - 0786 : 24; - 0787 : 4A; - 0788 : 84; - [0789..0791] : 00; - 0792 : 38; - 0793 : 40; - 0794 : 48; - 0795 : 30; - 0796 : 4A; - 0797 : 44; - 0798 : 3A; - [0799..07A1] : 00; - [07A2..07A3] : 60; - 07A4 : 20; - 07A5 : 40; - [07A6..07B2] : 00; - 07B3 : 08; - [07B4..07B7] : 10; - 07B8 : 08; - [07B9..07C2] : 00; - 07C3 : 20; - [07C4..07C7] : 10; - 07C8 : 20; - [07C9..07D3] : 00; - 07D4 : 10; - 07D5 : 54; - 07D6 : 10; - 07D7 : 54; - 07D8 : 10; - [07D9..07E2] : 00; - [07E3..07E4] : 10; - 07E5 : 7C; - [07E6..07E7] : 10; - [07E8..07F5] : 00; - [07F6..07F7] : 60; - 07F8 : 20; - 07F9 : 40; - [07FA..0804] : 00; - 0805 : 7C; - [0806..0816] : 00; - [0817..0818] : 60; - [0819..0821] : 00; - 0822 : 02; - 0823 : 06; - 0824 : 0C; - 0825 : 18; - 0826 : 30; - 0827 : 60; - 0828 : C0; - [0829..0831] : 00; - 0832 : 7C; - [0833..0837] : C6; + [05E9..05ED] : C2; + 05EE : FC; + [05EF..05F7] : 00; + 05F8 : FE; + [05F9..05FA] : C0; + 05FB : FC; + [05FC..05FD] : C0; + 05FE : FE; + [05FF..0607] : 00; + 0608 : FE; + [0609..060A] : C0; + 060B : FC; + [060C..060E] : C0; + [060F..0617] : 00; + [0618..061F] : 80; + [0620..062F] : 40; + [0630..0637] : A0; + [0638..063F] : 20; + [0640..0647] : 50; + [0648..064F] : 10; + [0650..0657] : 28; + [0658..065F] : 08; + [0660..0667] : 14; + [0668..066F] : 04; + [0670..0677] : 0A; + [0678..067F] : 02; + [0680..0687] : 05; + [0688..068F] : 01; + [0690..0697] : 02; + [0698..069F] : 3C; + [06A0..06A7] : C3; + [06A8..06AF] : 3C; + [06B0..06B7] : C3; + [06B8..06BF] : 3C; + [06C0..06C7] : C3; + [06C8..06CF] : 3C; + [06D0..06D7] : C3; + [06D8..06DF] : 3C; + [06E0..06E7] : C3; + [06E8..06EF] : 3C; + [06F0..06F7] : C3; + [06F8..06FF] : 3C; + [0700..0707] : C3; + [0708..070F] : 3C; + [0710..0717] : C3; + [0718..0727] : 00; + [0728..072C] : 08; + 072D : 00; + 072E : 08; + [072F..0737] : 00; + [0738..0739] : 6C; + 073A : 24; + 073B : 48; + [073C..0748] : 00; + 0749 : 24; + 074A : 7E; + [074B..074C] : 24; + 074D : 7E; + 074E : 24; + [074F..0757] : 00; + 0758 : 10; + 0759 : 3C; + 075A : 50; + 075B : 38; + 075C : 14; + 075D : 78; + 075E : 10; + [075F..0767] : 00; + 0768 : 42; + 0769 : A4; + 076A : 48; + 076B : 10; + 076C : 24; + 076D : 4A; + 076E : 84; + [076F..0777] : 00; + 0778 : 38; + 0779 : 40; + 077A : 48; + 077B : 30; + 077C : 4A; + 077D : 44; + 077E : 3A; + [077F..0787] : 00; + [0788..0789] : 60; + 078A : 20; + 078B : 40; + [078C..0798] : 00; + 0799 : 08; + [079A..079D] : 10; + 079E : 08; + [079F..07A8] : 00; + 07A9 : 20; + [07AA..07AD] : 10; + 07AE : 20; + [07AF..07B9] : 00; + 07BA : 10; + 07BB : 54; + 07BC : 10; + 07BD : 54; + 07BE : 10; + [07BF..07C8] : 00; + [07C9..07CA] : 10; + 07CB : 7C; + [07CC..07CD] : 10; + [07CE..07DB] : 00; + [07DC..07DD] : 60; + 07DE : 20; + 07DF : 40; + [07E0..07EA] : 00; + 07EB : 7C; + [07EC..07FC] : 00; + [07FD..07FE] : 60; + [07FF..0807] : 00; + 0808 : 02; + 0809 : 06; + 080A : 0C; + 080B : 18; + 080C : 30; + 080D : 60; + 080E : C0; + [080F..0817] : 00; + 0818 : 7C; + [0819..081D] : C6; + 081E : 7C; + [081F..0827] : 00; + 0828 : 30; + 0829 : 70; + [082A..082D] : 30; + 082E : 78; + [082F..0837] : 00; 0838 : 7C; - [0839..0841] : 00; - 0842 : 30; - 0843 : 70; - [0844..0847] : 30; - 0848 : 78; - [0849..0851] : 00; - 0852 : 7C; - [0853..0854] : C6; - 0855 : 0C; - 0856 : 30; - 0857 : 60; - 0858 : FE; - [0859..0861] : 00; - 0862 : 7C; - 0863 : C6; - 0864 : 06; - 0865 : 3C; - 0866 : 06; - 0867 : C6; - 0868 : 7C; - [0869..0871] : 00; - 0872 : 1C; - 0873 : 3C; - 0874 : 6C; - 0875 : 4C; - 0876 : CC; - 0877 : FE; - 0878 : 0C; - [0879..0881] : 00; - 0882 : FE; - 0883 : C0; - 0884 : FC; - 0885 : C6; - 0886 : 06; - 0887 : C6; - 0888 : 7C; - [0889..0891] : 00; - 0892 : 7C; - 0893 : C6; - 0894 : C0; - 0895 : FC; - [0896..0897] : C6; + [0839..083A] : C6; + 083B : 0C; + 083C : 30; + 083D : 60; + 083E : FE; + [083F..0847] : 00; + 0848 : 7C; + 0849 : C6; + 084A : 06; + 084B : 3C; + 084C : 06; + 084D : C6; + 084E : 7C; + [084F..0857] : 00; + 0858 : 1C; + 0859 : 3C; + 085A : 6C; + 085B : 4C; + 085C : CC; + 085D : FE; + 085E : 0C; + [085F..0867] : 00; + 0868 : FE; + 0869 : C0; + 086A : FC; + 086B : C6; + 086C : 06; + 086D : C6; + 086E : 7C; + [086F..0877] : 00; + 0878 : 7C; + 0879 : C6; + 087A : C0; + 087B : FC; + [087C..087D] : C6; + 087E : 7C; + [087F..0887] : 00; + 0888 : FE; + 0889 : C6; + 088A : 0C; + [088B..088C] : 18; + [088D..088E] : 30; + [088F..0897] : 00; 0898 : 7C; - [0899..08A1] : 00; - 08A2 : FE; - 08A3 : C6; - 08A4 : 0C; - [08A5..08A6] : 18; - [08A7..08A8] : 30; - [08A9..08B1] : 00; - 08B2 : 7C; - [08B3..08B4] : C6; - 08B5 : 7C; - [08B6..08B7] : C6; - 08B8 : 7C; - [08B9..08C1] : 00; - 08C2 : 7C; - [08C3..08C4] : C6; - 08C5 : 7E; - 08C6 : 06; - 08C7 : C6; - 08C8 : 7C; - [08C9..08D1] : 00; - [08D2..08D3] : 30; - [08D4..08D5] : 00; - [08D6..08D7] : 30; - [08D8..08E2] : 00; - [08E3..08E4] : 60; - 08E5 : 00; - [08E6..08E7] : 60; - 08E8 : 20; - 08E9 : 40; - [08EA..08F1] : 00; - 08F2 : 04; - 08F3 : 08; - 08F4 : 10; - 08F5 : 20; - 08F6 : 10; - 08F7 : 08; - 08F8 : 04; - [08F9..0903] : 00; - 0904 : 7C; - 0905 : 00; - 0906 : 7C; - [0907..0911] : 00; - 0912 : 40; - 0913 : 20; - 0914 : 10; - 0915 : 08; - 0916 : 10; - 0917 : 20; - 0918 : 40; - [0919..0921] : 00; - 0922 : 38; - 0923 : 44; - 0924 : 08; - [0925..0926] : 10; - 0927 : 00; - 0928 : 10; - [0929..0931] : 00; - 0932 : 3C; - 0933 : 42; - 0934 : 9E; - 0935 : 96; - 0936 : 9C; - 0937 : 40; - 0938 : 3C; - [0939..0941] : 00; - 0942 : 38; - 0943 : 6C; - 0944 : 44; - 0945 : C6; - 0946 : FE; - [0947..0948] : C6; - [0949..0951] : 00; - 0952 : FC; - [0953..0954] : C2; - 0955 : FC; - [0956..0957] : C2; + [0899..089A] : C6; + 089B : 7C; + [089C..089D] : C6; + 089E : 7C; + [089F..08A7] : 00; + 08A8 : 7C; + [08A9..08AA] : C6; + 08AB : 7E; + 08AC : 06; + 08AD : C6; + 08AE : 7C; + [08AF..08B7] : 00; + [08B8..08B9] : 30; + [08BA..08BB] : 00; + [08BC..08BD] : 30; + [08BE..08C8] : 00; + [08C9..08CA] : 60; + 08CB : 00; + [08CC..08CD] : 60; + 08CE : 20; + 08CF : 40; + [08D0..08D7] : 00; + 08D8 : 04; + 08D9 : 08; + 08DA : 10; + 08DB : 20; + 08DC : 10; + 08DD : 08; + 08DE : 04; + [08DF..08E9] : 00; + 08EA : 7C; + 08EB : 00; + 08EC : 7C; + [08ED..08F7] : 00; + 08F8 : 40; + 08F9 : 20; + 08FA : 10; + 08FB : 08; + 08FC : 10; + 08FD : 20; + 08FE : 40; + [08FF..0907] : 00; + 0908 : 38; + 0909 : 44; + 090A : 08; + [090B..090C] : 10; + 090D : 00; + 090E : 10; + [090F..0917] : 00; + 0918 : 3C; + 0919 : 42; + 091A : 9E; + 091B : 96; + 091C : 9C; + 091D : 40; + 091E : 3C; + [091F..0927] : 00; + 0928 : 38; + 0929 : 6C; + 092A : 44; + 092B : C6; + 092C : FE; + [092D..092E] : C6; + [092F..0937] : 00; + 0938 : FC; + [0939..093A] : C2; + 093B : FC; + [093C..093D] : C2; + 093E : FC; + [093F..0947] : 00; + 0948 : 7C; + 0949 : C2; + [094A..094C] : C0; + 094D : C2; + 094E : 7C; + [094F..0957] : 00; 0958 : FC; - [0959..0961] : 00; - 0962 : 7C; - 0963 : C2; - [0964..0966] : C0; - 0967 : C2; - 0968 : 7C; - [0969..0971] : 00; - 0972 : FC; - [0973..0977] : C2; - 0978 : FC; - [0979..0981] : 00; - 0982 : FE; - [0983..0984] : C0; - 0985 : FC; - [0986..0987] : C0; - 0988 : FE; - [0989..0991] : 00; - 0992 : FE; - [0993..0994] : C0; - 0995 : FC; - [0996..0998] : C0; - [0999..09A1] : 00; - 09A2 : 7C; - 09A3 : C2; - 09A4 : C0; - 09A5 : DE; - 09A6 : C2; - 09A7 : C6; - 09A8 : 7C; - [09A9..09B1] : 00; - [09B2..09B4] : C2; - 09B5 : FE; - [09B6..09B8] : C2; - [09B9..09C1] : 00; - 09C2 : 3C; - [09C3..09C7] : 18; - 09C8 : 3C; - [09C9..09D1] : 00; - 09D2 : 7E; - [09D3..09D6] : 0C; - 09D7 : 8C; - 09D8 : 78; - [09D9..09E1] : 00; - [09E2..09E3] : C2; - 09E4 : C4; - 09E5 : F8; - 09E6 : C4; - [09E7..09E8] : C2; - [09E9..09F1] : 00; - [09F2..09F7] : C0; - 09F8 : FE; - [09F9..0A01] : 00; - 0A02 : C6; - 0A03 : EE; - 0A04 : FE; - 0A05 : D6; - [0A06..0A08] : C6; - [0A09..0A11] : 00; - 0A12 : C2; - 0A13 : E2; - 0A14 : D2; - 0A15 : CA; - 0A16 : C6; - [0A17..0A18] : C2; - [0A19..0A21] : 00; - 0A22 : 7C; - [0A23..0A27] : C2; + [0959..095D] : C2; + 095E : FC; + [095F..0967] : 00; + 0968 : FE; + [0969..096A] : C0; + 096B : FC; + [096C..096D] : C0; + 096E : FE; + [096F..0977] : 00; + 0978 : FE; + [0979..097A] : C0; + 097B : FC; + [097C..097E] : C0; + [097F..0987] : 00; + 0988 : 7C; + 0989 : C2; + 098A : C0; + 098B : DE; + 098C : C2; + 098D : C6; + 098E : 7C; + [098F..0997] : 00; + [0998..099A] : C2; + 099B : FE; + [099C..099E] : C2; + [099F..09A7] : 00; + 09A8 : 3C; + [09A9..09AD] : 18; + 09AE : 3C; + [09AF..09B7] : 00; + 09B8 : 7E; + [09B9..09BC] : 0C; + 09BD : 8C; + 09BE : 78; + [09BF..09C7] : 00; + [09C8..09C9] : C2; + 09CA : C4; + 09CB : F8; + 09CC : C4; + [09CD..09CE] : C2; + [09CF..09D7] : 00; + [09D8..09DD] : C0; + 09DE : FE; + [09DF..09E7] : 00; + 09E8 : C6; + 09E9 : EE; + 09EA : FE; + 09EB : D6; + [09EC..09EE] : C6; + [09EF..09F7] : 00; + 09F8 : C2; + 09F9 : E2; + 09FA : D2; + 09FB : CA; + 09FC : C6; + [09FD..09FE] : C2; + [09FF..0A07] : 00; + 0A08 : 7C; + [0A09..0A0D] : C2; + 0A0E : 7C; + [0A0F..0A17] : 00; + 0A18 : FC; + [0A19..0A1A] : C2; + 0A1B : FC; + [0A1C..0A1E] : C0; + [0A1F..0A27] : 00; 0A28 : 7C; - [0A29..0A31] : 00; - 0A32 : FC; - [0A33..0A34] : C2; - 0A35 : FC; - [0A36..0A38] : C0; - [0A39..0A41] : 00; - 0A42 : 7C; - [0A43..0A45] : C2; - 0A46 : DA; - 0A47 : D4; - 0A48 : 7A; - [0A49..0A51] : 00; - 0A52 : FC; - [0A53..0A54] : C2; - 0A55 : FC; - 0A56 : C8; - 0A57 : C4; - 0A58 : C2; - [0A59..0A61] : 00; - 0A62 : 7C; - 0A63 : C2; - 0A64 : C0; - 0A65 : 7C; - 0A66 : 02; - 0A67 : C2; - 0A68 : 7C; - [0A69..0A71] : 00; - 0A72 : 7E; - [0A73..0A78] : 18; - [0A79..0A81] : 00; - [0A82..0A87] : C2; - 0A88 : 7C; - [0A89..0A91] : 00; - [0A92..0A95] : C6; - [0A96..0A97] : 6C; - 0A98 : 38; - [0A99..0AA1] : 00; - [0AA2..0AA3] : C6; - [0AA4..0AA5] : D6; - 0AA6 : FE; - 0AA7 : EE; - 0AA8 : 44; - [0AA9..0AB1] : 00; - [0AB2..0AB3] : C6; - 0AB4 : 6C; - 0AB5 : 38; - 0AB6 : 6C; - [0AB7..0AB8] : C6; - [0AB9..0AC1] : 00; - [0AC2..0AC3] : C4; - 0AC4 : 68; - [0AC5..0AC8] : 30; - [0AC9..0AD1] : 00; - 0AD2 : FC; - 0AD3 : 08; - 0AD4 : 10; - 0AD5 : 20; - 0AD6 : 40; - 0AD7 : C0; - 0AD8 : FC; - [0AD9..0AE1] : 00; - 0AE2 : 1C; - [0AE3..0AE7] : 18; - 0AE8 : 1C; - [0AE9..0AF1] : 00; - 0AF2 : 80; - 0AF3 : C0; - 0AF4 : 60; - 0AF5 : 30; - 0AF6 : 18; - 0AF7 : 0C; - 0AF8 : 06; - [0AF9..0B01] : 00; - 0B02 : 70; - [0B03..0B07] : 30; - 0B08 : 70; - [0B09..0B11] : 00; - 0B12 : 10; - 0B13 : 28; - 0B14 : 44; - [0B15..0B28] : 00; - 0B29 : FF; - [0B2A..0B31] : 00; - 0B32 : 20; - 0B33 : 10; - 0B34 : 08; - [0B35..0B43] : 00; - 0B44 : 78; - [0B45..0B47] : CC; - 0B48 : 76; - [0B49..0B51] : 00; - [0B52..0B53] : C0; - 0B54 : F8; - [0B55..0B57] : CC; - 0B58 : F8; - [0B59..0B63] : 00; - 0B64 : 7C; - [0B65..0B67] : C0; - 0B68 : 7C; - [0B69..0B71] : 00; - [0B72..0B73] : 0C; - 0B74 : 7C; - [0B75..0B77] : CC; - 0B78 : 7C; - [0B79..0B83] : 00; - 0B84 : 78; - 0B85 : CC; - 0B86 : FC; - 0B87 : C0; - 0B88 : 7C; - [0B89..0B91] : 00; - 0B92 : 1C; - [0B93..0B94] : 30; - 0B95 : FC; - [0B96..0B98] : 30; - [0B99..0BA3] : 00; - 0BA4 : 7C; - [0BA5..0BA6] : CC; - 0BA7 : 7C; - 0BA8 : 0C; - 0BA9 : 78; - [0BAA..0BB1] : 00; - [0BB2..0BB4] : C0; - 0BB5 : F8; - [0BB6..0BB8] : CC; - [0BB9..0BC2] : 00; - 0BC3 : 18; - 0BC4 : 00; - [0BC5..0BC8] : 18; - [0BC9..0BD2] : 00; - 0BD3 : 18; - 0BD4 : 00; - [0BD5..0BD7] : 18; - 0BD8 : D8; - 0BD9 : 70; - [0BDA..0BE1] : 00; - [0BE2..0BE3] : C0; - 0BE4 : CC; - 0BE5 : D8; - 0BE6 : F0; - 0BE7 : D8; - 0BE8 : CC; - [0BE9..0BF1] : 00; - 0BF2 : 38; - [0BF3..0BF8] : 18; - [0BF9..0C03] : 00; - 0C04 : EC; - [0C05..0C08] : D6; - [0C09..0C13] : 00; - 0C14 : F8; - [0C15..0C18] : CC; - [0C19..0C23] : 00; - 0C24 : 78; - [0C25..0C27] : CC; - 0C28 : 78; - [0C29..0C33] : 00; - 0C34 : F8; - [0C35..0C36] : CC; - 0C37 : F8; - [0C38..0C39] : C0; - [0C3A..0C43] : 00; - 0C44 : 7C; - [0C45..0C46] : CC; - 0C47 : 7C; - [0C48..0C49] : 0C; - [0C4A..0C53] : 00; - 0C54 : DC; - 0C55 : E0; - [0C56..0C58] : C0; - [0C59..0C63] : 00; - 0C64 : 78; - 0C65 : C0; - 0C66 : 78; - 0C67 : 0C; - 0C68 : F8; - [0C69..0C71] : 00; - 0C72 : 70; - 0C73 : 30; - 0C74 : FC; - [0C75..0C77] : 30; - 0C78 : 1C; - [0C79..0C83] : 00; - [0C84..0C87] : CC; - 0C88 : 78; - [0C89..0C93] : 00; - [0C94..0C96] : CC; - 0C97 : 78; - 0C98 : 30; - [0C99..0CA3] : 00; - 0CA4 : C6; - [0CA5..0CA7] : D6; - 0CA8 : 6C; - [0CA9..0CB3] : 00; - 0CB4 : C6; - 0CB5 : 6C; - 0CB6 : 38; - 0CB7 : 6C; - 0CB8 : C6; - [0CB9..0CC3] : 00; - [0CC4..0CC5] : CC; - 0CC6 : 78; - 0CC7 : 30; - 0CC8 : 60; - 0CC9 : C0; - [0CCA..0CD3] : 00; - 0CD4 : FC; - 0CD5 : 18; - 0CD6 : 30; - 0CD7 : 60; - 0CD8 : FC; - [0CD9..0CE1] : 00; - 0CE2 : 0C; - [0CE3..0CE4] : 08; - 0CE5 : 18; - [0CE6..0CE7] : 08; - 0CE8 : 0C; - [0CE9..0CF1] : 00; - [0CF2..0CF4] : 10; - 0CF5 : 00; - [0CF6..0CF8] : 10; - [0CF9..0D01] : 00; - 0D02 : 60; - [0D03..0D04] : 20; - 0D05 : 30; - [0D06..0D07] : 20; - 0D08 : 60; - [0D09..0D14] : 00; - 0D15 : 32; - 0D16 : 4C; - [0D17..0D24] : 00; - 0D25 : 10; - 0D26 : 28; - 0D27 : 44; - 0D28 : 7C; - [0D29..0FFB] : 00; + [0A29..0A2B] : C2; + 0A2C : DA; + 0A2D : D4; + 0A2E : 7A; + [0A2F..0A37] : 00; + 0A38 : FC; + [0A39..0A3A] : C2; + 0A3B : FC; + 0A3C : C8; + 0A3D : C4; + 0A3E : C2; + [0A3F..0A47] : 00; + 0A48 : 7C; + 0A49 : C2; + 0A4A : C0; + 0A4B : 7C; + 0A4C : 02; + 0A4D : C2; + 0A4E : 7C; + [0A4F..0A57] : 00; + 0A58 : 7E; + [0A59..0A5E] : 18; + [0A5F..0A67] : 00; + [0A68..0A6D] : C2; + 0A6E : 7C; + [0A6F..0A77] : 00; + [0A78..0A7B] : C6; + [0A7C..0A7D] : 6C; + 0A7E : 38; + [0A7F..0A87] : 00; + [0A88..0A89] : C6; + [0A8A..0A8B] : D6; + 0A8C : FE; + 0A8D : EE; + 0A8E : 44; + [0A8F..0A97] : 00; + [0A98..0A99] : C6; + 0A9A : 6C; + 0A9B : 38; + 0A9C : 6C; + [0A9D..0A9E] : C6; + [0A9F..0AA7] : 00; + [0AA8..0AA9] : C4; + 0AAA : 68; + [0AAB..0AAE] : 30; + [0AAF..0AB7] : 00; + 0AB8 : FC; + 0AB9 : 08; + 0ABA : 10; + 0ABB : 20; + 0ABC : 40; + 0ABD : C0; + 0ABE : FC; + [0ABF..0AC7] : 00; + 0AC8 : 1C; + [0AC9..0ACD] : 18; + 0ACE : 1C; + [0ACF..0AD7] : 00; + 0AD8 : 80; + 0AD9 : C0; + 0ADA : 60; + 0ADB : 30; + 0ADC : 18; + 0ADD : 0C; + 0ADE : 06; + [0ADF..0AE7] : 00; + 0AE8 : 70; + [0AE9..0AED] : 30; + 0AEE : 70; + [0AEF..0AF7] : 00; + 0AF8 : 10; + 0AF9 : 28; + 0AFA : 44; + [0AFB..0B0E] : 00; + 0B0F : FF; + [0B10..0B17] : 00; + 0B18 : 20; + 0B19 : 10; + 0B1A : 08; + [0B1B..0B29] : 00; + 0B2A : 78; + [0B2B..0B2D] : CC; + 0B2E : 76; + [0B2F..0B37] : 00; + [0B38..0B39] : C0; + 0B3A : F8; + [0B3B..0B3D] : CC; + 0B3E : F8; + [0B3F..0B49] : 00; + 0B4A : 7C; + [0B4B..0B4D] : C0; + 0B4E : 7C; + [0B4F..0B57] : 00; + [0B58..0B59] : 0C; + 0B5A : 7C; + [0B5B..0B5D] : CC; + 0B5E : 7C; + [0B5F..0B69] : 00; + 0B6A : 78; + 0B6B : CC; + 0B6C : FC; + 0B6D : C0; + 0B6E : 7C; + [0B6F..0B77] : 00; + 0B78 : 1C; + [0B79..0B7A] : 30; + 0B7B : FC; + [0B7C..0B7E] : 30; + [0B7F..0B89] : 00; + 0B8A : 7C; + [0B8B..0B8C] : CC; + 0B8D : 7C; + 0B8E : 0C; + 0B8F : 78; + [0B90..0B97] : 00; + [0B98..0B9A] : C0; + 0B9B : F8; + [0B9C..0B9E] : CC; + [0B9F..0BA8] : 00; + 0BA9 : 18; + 0BAA : 00; + [0BAB..0BAE] : 18; + [0BAF..0BB8] : 00; + 0BB9 : 18; + 0BBA : 00; + [0BBB..0BBD] : 18; + 0BBE : D8; + 0BBF : 70; + [0BC0..0BC7] : 00; + [0BC8..0BC9] : C0; + 0BCA : CC; + 0BCB : D8; + 0BCC : F0; + 0BCD : D8; + 0BCE : CC; + [0BCF..0BD7] : 00; + 0BD8 : 38; + [0BD9..0BDE] : 18; + [0BDF..0BE9] : 00; + 0BEA : EC; + [0BEB..0BEE] : D6; + [0BEF..0BF9] : 00; + 0BFA : F8; + [0BFB..0BFE] : CC; + [0BFF..0C09] : 00; + 0C0A : 78; + [0C0B..0C0D] : CC; + 0C0E : 78; + [0C0F..0C19] : 00; + 0C1A : F8; + [0C1B..0C1C] : CC; + 0C1D : F8; + [0C1E..0C1F] : C0; + [0C20..0C29] : 00; + 0C2A : 7C; + [0C2B..0C2C] : CC; + 0C2D : 7C; + [0C2E..0C2F] : 0C; + [0C30..0C39] : 00; + 0C3A : DC; + 0C3B : E0; + [0C3C..0C3E] : C0; + [0C3F..0C49] : 00; + 0C4A : 78; + 0C4B : C0; + 0C4C : 78; + 0C4D : 0C; + 0C4E : F8; + [0C4F..0C57] : 00; + 0C58 : 70; + 0C59 : 30; + 0C5A : FC; + [0C5B..0C5D] : 30; + 0C5E : 1C; + [0C5F..0C69] : 00; + [0C6A..0C6D] : CC; + 0C6E : 78; + [0C6F..0C79] : 00; + [0C7A..0C7C] : CC; + 0C7D : 78; + 0C7E : 30; + [0C7F..0C89] : 00; + 0C8A : C6; + [0C8B..0C8D] : D6; + 0C8E : 6C; + [0C8F..0C99] : 00; + 0C9A : C6; + 0C9B : 6C; + 0C9C : 38; + 0C9D : 6C; + 0C9E : C6; + [0C9F..0CA9] : 00; + [0CAA..0CAB] : CC; + 0CAC : 78; + 0CAD : 30; + 0CAE : 60; + 0CAF : C0; + [0CB0..0CB9] : 00; + 0CBA : FC; + 0CBB : 18; + 0CBC : 30; + 0CBD : 60; + 0CBE : FC; + [0CBF..0CC7] : 00; + 0CC8 : 0C; + [0CC9..0CCA] : 08; + 0CCB : 18; + [0CCC..0CCD] : 08; + 0CCE : 0C; + [0CCF..0CD7] : 00; + [0CD8..0CDA] : 10; + 0CDB : 00; + [0CDC..0CDE] : 10; + [0CDF..0CE7] : 00; + 0CE8 : 60; + [0CE9..0CEA] : 20; + 0CEB : 30; + [0CEC..0CED] : 20; + 0CEE : 60; + [0CEF..0CFA] : 00; + 0CFB : 32; + 0CFC : 4C; + [0CFD..0D0A] : 00; + 0D0B : 10; + 0D0C : 28; + 0D0D : 44; + 0D0E : 7C; + [0D0F..0D17] : 00; + 0D18 : F1; + 0D19 : 7F; + 0D1A : 13; + 0D1B : AD; + 0D1C : 4D; + 0D1D : F3; + 0D1E : 9D; + 0D1F : 4C; + 0D20 : 00; + 0D21 : B8; + 0D22 : 74; + 0D23 : 34; + 0D24 : F8; + 0D25 : BF; + 0D26 : 89; + 0D27 : 56; + 0D28 : 26; + 0D29 : F9; + 0D2A : CE; + 0D2B : A6; + 0D2C : 80; + 0D2D : 5C; + 0D2E : 3A; + 0D2F : 1A; + 0D30 : FB; + 0D31 : DF; + 0D32 : C4; + 0D33 : AB; + 0D34 : 93; + 0D35 : 7C; + 0D36 : 67; + 0D37 : 52; + 0D38 : 3F; + 0D39 : 2D; + 0D3A : 1C; + 0D3B : 0C; + 0D3C : FD; + 0D3D : EF; + 0D3E : E1; + 0D3F : D5; + 0D40 : C9; + 0D41 : BD; + 0D42 : B3; + 0D43 : A9; + 0D44 : 9F; + 0D45 : 96; + 0D46 : 8E; + 0D47 : 86; + 0D48 : 7E; + 0D49 : 77; + 0D4A : 70; + 0D4B : 6A; + 0D4C : 64; + 0D4D : 5E; + 0D4E : 59; + 0D4F : 54; + 0D50 : 4F; + 0D51 : 4B; + 0D52 : 46; + 0D53 : 42; + 0D54 : 3F; + 0D55 : 3B; + 0D56 : 38; + 0D57 : 34; + 0D58 : 31; + 0D59 : 2F; + 0D5A : 2C; + 0D5B : 29; + 0D5C : 27; + 0D5D : 25; + 0D5E : 23; + 0D5F : 21; + 0D60 : 1F; + 0D61 : 1D; + 0D62 : 1B; + 0D63 : 1A; + 0D64 : 18; + 0D65 : 17; + 0D66 : 15; + 0D67 : 14; + [0D68..0D6B] : 00; + [0D6C..0D6E] : 07; + [0D6F..0D70] : 06; + [0D71..0D74] : 05; + [0D75..0D77] : 04; + [0D78..0D7C] : 03; + [0D7D..0D83] : 02; + [0D84..0D8F] : 01; + [0D90..0DBF] : 00; + 0DC0 : A2; + 0DC1 : 01; + 0DC2 : 8E; + 0DC3 : 16; + 0DC4 : 40; + 0DC5 : CA; + [0DC6..0DC8] : EA; + 0DC9 : 8E; + 0DCA : 16; + 0DCB : 40; + 0DCC : 8E; + 0DCD : 2F; + 0DCE : 40; + 0DCF : 8E; + 0DD0 : 2F; + 0DD1 : 40; + 0DD2 : AD; + 0DD3 : 16; + 0DD4 : 40; + 0DD5 : 6A; + 0DD6 : B0; + 0DD7 : 03; + 0DD8 : 4C; + 0DD9 : 95; + 0DDA : 4F; + 0DDB : A2; + 0DDC : 08; + 0DDD : AD; + 0DDE : 16; + 0DDF : 40; + 0DE0 : 6A; + 0DE1 : 2E; + 0DE2 : 2F; + 0DE3 : 40; + 0DE4 : CA; + 0DE5 : D0; + 0DE6 : F6; + 0DE7 : AD; + 0DE8 : 2F; + 0DE9 : 40; + 0DEA : 49; + 0DEB : FF; + 0DEC : 8D; + 0DED : 2F; + 0DEE : 40; + 0DEF : AE; + 0DF0 : 2D; + 0DF1 : 40; + 0DF2 : 9D; + 0DF3 : 30; + 0DF4 : 40; + 0DF5 : E8; + 0DF6 : 8A; + 0DF7 : 29; + 0DF8 : 0F; + 0DF9 : AA; + 0DFA : 8D; + 0DFB : 2D; + 0DFC : 40; + 0DFD : AE; + 0DFE : 2E; + 0DFF : 40; + 0E00 : BD; + 0E01 : 30; + 0E02 : 40; + 0E03 : C9; + 0E04 : FF; + 0E05 : D0; + 0E06 : 03; + 0E07 : 4C; + 0E08 : 95; + 0E09 : 4F; + 0E0A : 29; + 0E0B : F0; + 0E0C : C9; + 0E0D : F0; + 0E0E : D0; + 0E0F : 17; + 0E10 : E8; + 0E11 : 8A; + 0E12 : 29; + 0E13 : 0F; + 0E14 : AA; + 0E15 : EC; + 0E16 : 2D; + 0E17 : 40; + 0E18 : D0; + 0E19 : 03; + 0E1A : 4C; + 0E1B : 95; + 0E1C : 4F; + 0E1D : BD; + 0E1E : 30; + 0E1F : 40; + 0E20 : 29; + 0E21 : 80; + 0E22 : D0; + 0E23 : EC; + 0E24 : 4C; + 0E25 : 8F; + 0E26 : 4F; + 0E27 : C9; + 0E28 : C0; + 0E29 : D0; + 0E2A : 16; + 0E2B : E8; + 0E2C : 8A; + 0E2D : 29; + 0E2E : 0F; + 0E2F : AA; + 0E30 : EC; + 0E31 : 2D; + 0E32 : 40; + 0E33 : D0; + 0E34 : 03; + 0E35 : 4C; + 0E36 : 95; + 0E37 : 4F; + 0E38 : BD; + 0E39 : 30; + 0E3A : 40; + 0E3B : 8D; + 0E3C : 27; + 0E3D : 40; + 0E3E : 4C; + 0E3F : 8F; + 0E40 : 4F; + [0E41..0E43] : E8; + 0E44 : 8A; + 0E45 : 29; + 0E46 : 0F; + 0E47 : AA; + 0E48 : EC; + 0E49 : 2D; + 0E4A : 40; + 0E4B : F0; + 0E4C : 03; + 0E4D : 4C; + 0E4E : 95; + 0E4F : 4F; + 0E50 : AE; + 0E51 : 2E; + 0E52 : 40; + 0E53 : BD; + 0E54 : 30; + 0E55 : 40; + 0E56 : 29; + 0E57 : E0; + 0E58 : C9; + 0E59 : 80; + 0E5A : F0; + 0E5B : 03; + 0E5C : 4C; + 0E5D : 8F; + 0E5E : 4F; + 0E5F : AE; + 0E60 : 2E; + 0E61 : 40; + 0E62 : E8; + 0E63 : 8A; + 0E64 : 29; + 0E65 : 0F; + 0E66 : AA; + 0E67 : BD; + 0E68 : 30; + 0E69 : 40; + 0E6A : 8D; + 0E6B : 20; + 0E6C : 40; + 0E6D : A8; + 0E6E : E8; + 0E6F : 8A; + 0E70 : 29; + 0E71 : 0F; + 0E72 : AA; + 0E73 : BD; + 0E74 : 30; + 0E75 : 40; + 0E76 : 8D; + 0E77 : 21; + 0E78 : 40; + 0E79 : 98; + 0E7A : C9; + 0E7B : 71; + 0E7C : 30; + 0E7D : 03; + 0E7E : 4C; + 0E7F : 8F; + 0E80 : 4F; + 0E81 : C9; + 0E82 : 21; + 0E83 : 10; + 0E84 : 03; + 0E85 : 4C; + 0E86 : 8F; + 0E87 : 4F; + 0E88 : AD; + 0E89 : 27; + 0E8A : 40; + 0E8B : C9; + 0E8C : 40; + 0E8D : B0; + 0E8E : 09; + 0E8F : 29; + 0E90 : 04; + 0E91 : D0; + 0E92 : 08; + 0E93 : 98; + 0E94 : C9; + 0E95 : 39; + 0E96 : 10; + 0E97 : 03; + [0E98..0E99] : 4C; + 0E9A : 4F; + 0E9B : 98; + 0E9C : CD; + 0E9D : 22; + 0E9E : 40; + 0E9F : D0; + 0EA0 : 05; + 0EA1 : A9; + 0EA2 : 00; + 0EA3 : 4C; + 0EA4 : BD; + 0EA5 : 4E; + 0EA6 : CD; + 0EA7 : 26; + 0EA8 : 40; + 0EA9 : D0; + 0EAA : 05; + 0EAB : A9; + 0EAC : 04; + 0EAD : 4C; + 0EAE : BD; + 0EAF : 4E; + 0EB0 : AD; + 0EB1 : 21; + 0EB2 : 40; + 0EB3 : D0; + 0EB4 : 03; + 0EB5 : 4C; + 0EB6 : 8F; + 0EB7 : 4F; + 0EB8 : AD; + 0EB9 : 2C; + 0EBA : 40; + 0EBB : 49; + 0EBC : 04; + 0EBD : AA; + 0EBE : 98; + 0EBF : 9D; + 0EC0 : 22; + 0EC1 : 40; + 0EC2 : 38; + 0EC3 : E9; + 0EC4 : 21; + 0EC5 : A8; + 0EC6 : AD; + 0EC7 : 27; + 0EC8 : 40; + 0EC9 : 29; + 0ECA : 08; + 0ECB : D0; + 0ECC : 11; + 0ECD : B9; + 0ECE : 18; + 0ECF : 4D; + 0ED0 : 9D; + 0ED1 : 02; + 0ED2 : 40; + 0ED3 : B9; + 0ED4 : 6C; + 0ED5 : 4D; + 0ED6 : 09; + 0ED7 : 08; + 0ED8 : 9D; + 0ED9 : 03; + 0EDA : 40; + 0EDB : 4C; + 0EDC : EC; + 0EDD : 4E; + 0EDE : B9; + 0EDF : 18; + 0EE0 : 4D; + 0EE1 : 9D; + 0EE2 : 02; + 0EE3 : 50; + 0EE4 : B9; + 0EE5 : 6C; + 0EE6 : 4D; + 0EE7 : 09; + 0EE8 : 08; + 0EE9 : 9D; + 0EEA : 03; + 0EEB : 50; + 0EEC : AD; + 0EED : 21; + 0EEE : 40; + 0EEF : C9; + 0EF0 : 78; + 0EF1 : 10; + 0EF2 : 03; + 0EF3 : 18; + 0EF4 : 69; + 0EF5 : 07; + [0EF6..0EF8] : 6A; + 0EF9 : 29; + 0EFA : 0F; + 0EFB : A8; + 0EFC : 09; + 0EFD : 30; + 0EFE : 8D; + 0EFF : 20; + 0F00 : 40; + 0F01 : AD; + 0F02 : 27; + 0F03 : 40; + [0F04..0F06] : 6A; + 0F07 : 29; + 0F08 : C0; + 0F09 : 0D; + 0F0A : 20; + 0F0B : 40; + 0F0C : 8D; + 0F0D : 20; + 0F0E : 40; + 0F0F : AD; + 0F10 : 27; + 0F11 : 40; + 0F12 : 29; + 0F13 : 08; + 0F14 : D0; + 0F15 : 16; + 0F16 : AD; + 0F17 : 20; + 0F18 : 40; + 0F19 : 9D; + 0F1A : 00; + 0F1B : 40; + 0F1C : A9; + 0F1D : 00; + 0F1E : 9D; + 0F1F : 01; + 0F20 : 40; + 0F21 : AD; + 0F22 : 2B; + 0F23 : 40; + 0F24 : 09; + 0F25 : 03; + 0F26 : 8D; + 0F27 : 15; + 0F28 : 40; + 0F29 : 4C; + 0F2A : 3F; + 0F2B : 4F; + 0F2C : AD; + 0F2D : 20; + 0F2E : 40; + 0F2F : 9D; + 0F30 : 00; + 0F31 : 50; + 0F32 : A9; + 0F33 : 00; + 0F34 : 9D; + 0F35 : 01; + 0F36 : 50; + 0F37 : AD; + 0F38 : 2A; + 0F39 : 40; + 0F3A : 09; + 0F3B : 03; + 0F3C : 8D; + 0F3D : 15; + 0F3E : 50; + 0F3F : 98; + 0F40 : D0; + 0F41 : 04; + 0F42 : 8A; + 0F43 : 49; + 0F44 : 04; + 0F45 : AA; + 0F46 : 8E; + 0F47 : 2C; + 0F48 : 40; + 0F49 : 4C; + 0F4A : 8F; + 0F4B : 4F; + 0F4C : 98; + 0F4D : CD; + 0F4E : 25; + 0F4F : 40; + 0F50 : F0; + 0F51 : 06; + 0F52 : AD; + 0F53 : 21; + 0F54 : 40; + 0F55 : F0; + 0F56 : 38; + 0F57 : 98; + 0F58 : 8D; + 0F59 : 25; + 0F5A : 40; + 0F5B : A0; + 0F5C : 3F; + 0F5D : CC; + 0F5E : 27; + 0F5F : 40; + 0F60 : 90; + 0F61 : 05; + 0F62 : E9; + 0F63 : 09; + 0F64 : 4C; + 0F65 : 6A; + 0F66 : 4F; + 0F67 : 38; + 0F68 : E9; + 0F69 : 15; + 0F6A : A8; + 0F6B : B9; + 0F6C : 18; + 0F6D : 4D; + 0F6E : 8D; + 0F6F : 0A; + 0F70 : 40; + 0F71 : B9; + 0F72 : 6C; + 0F73 : 4D; + 0F74 : 09; + 0F75 : F8; + 0F76 : 8D; + 0F77 : 0B; + 0F78 : 40; + 0F79 : AD; + 0F7A : 21; + 0F7B : 40; + 0F7C : F0; + 0F7D : 04; + 0F7E : A9; + 0F7F : FF; + 0F80 : D0; + 0F81 : 02; + 0F82 : A9; + 0F83 : 80; + 0F84 : 8D; + 0F85 : 08; + 0F86 : 40; + 0F87 : AD; + 0F88 : 2B; + 0F89 : 40; + 0F8A : 09; + 0F8B : 04; + 0F8C : 8D; + 0F8D : 15; + 0F8E : 40; + 0F8F : AD; + 0F90 : 2D; + 0F91 : 40; + 0F92 : 8D; + 0F93 : 2E; + 0F94 : 40; + 0F95 : A2; + 0F96 : 08; + 0F97 : 18; + 0F98 : AD; + 0F99 : 17; + 0F9A : 40; + 0F9B : 09; + 0F9C : FC; + 0F9D : 69; + 0F9E : 03; + 0F9F : 2E; + 0FA0 : F6; + 0FA1 : 01; + 0FA2 : CA; + 0FA3 : D0; + 0FA4 : F2; + 0FA5 : 60; + [0FA6..0FEC] : 00; + 0FED : AD; + 0FEE : 15; + 0FEF : 40; + 0FF0 : 8D; + 0FF1 : 2B; + 0FF2 : 40; + 0FF3 : AD; + 0FF4 : 15; + 0FF5 : 50; + 0FF6 : 8D; + 0FF7 : 2A; + 0FF8 : 40; + 0FF9 : 4C; + 0FFA : 77; + 0FFB : 42; 0FFC : 80; 0FFD : 41; [0FFE..0FFF] : 00; diff --git a/rtl/mappers/misc.sv b/rtl/mappers/misc.sv index 70ac274..ff216c4 100644 --- a/rtl/mappers/misc.sv +++ b/rtl/mappers/misc.sv @@ -2082,6 +2082,7 @@ module NSF( input [13:0] chr_ain, // chr address in inout [21:0] chr_aout_b, // chr address out input chr_read, // chr ram read + inout [7:0] chr_dout_b, // chr data (non standard) inout chr_allow_b, // chr allow write inout vram_a10_b, // Value for A10 address line inout vram_ce_b, // True if the address should be routed to the internal 2kB VRAM. @@ -2097,13 +2098,14 @@ assign prg_aout_b = enable ? prg_aout : 22'hZ; assign prg_dout_b = enable ? prg_dout : 8'hZ; assign prg_allow_b = enable ? prg_allow : 1'hZ; assign chr_aout_b = enable ? chr_aout : 22'hZ; +assign chr_dout_b = enable ? chr_dout : 8'hZ; assign chr_allow_b = enable ? chr_allow : 1'hZ; assign vram_a10_b = enable ? vram_a10 : 1'hZ; assign vram_ce_b = enable ? vram_ce : 1'hZ; assign irq_b = enable ? 1'b0 : 1'hZ; assign flags_out_b = enable ? flags_out : 16'hZ; assign audio_b = enable ? {audio_in[15:0]} : 16'hZ; -assign exp_audioe = enable ? nsf_reg[3][5:0] : 6'h00; +assign exp_audioe = enable ? (nsf_reg[3][5:0]==6'd0) ? ({2'b00,midi_reg[5'd7][3],3'b000}) : nsf_reg[3][5:0] : 6'h00; wire [21:0] prg_aout, chr_aout; wire [7:0] prg_dout; @@ -2111,9 +2113,12 @@ wire prg_allow; wire chr_allow; wire vram_a10; wire vram_ce; -wire [15:0] flags_out = {14'd0, prg_bus_write, 1'b0}; +wire [15:0] flags_out = {14'd0, prg_bus_write, has_chr_dout}; reg prg_bus_write; +wire has_chr_dout; +wire [7:0] chr_dout; + wire [3:0] submapper = flags[24:21]; reg [7:0] nsf_reg [15:0]; reg [15:0] counter; @@ -2124,6 +2129,21 @@ reg [7:0] multiplier_1; reg [7:0] multiplier_2; wire [15:0] multiply_result = multiplier_1 * multiplier_2; +reg [7:0] apu_reg [31:0]; +reg [7:0] mmc5_reg [15:0]; +reg [7:0] vrc6_reg [15:0]; +reg [7:0] midi_reg [31:0]; +reg [7:0] ssb5_reg [15:0]; +reg [3:0] ssb5_add; +reg [7:0] fds_reg [15:0]; +reg [7:0] n163_reg[63:0]; +reg autoinc; +reg [6:0] ram_ain; +reg do_inc; +reg [7:0] vrc7_reg[31:0]; +reg [4:0] vrc7_add; + + /* ;---------------------------------- ; NSF player for PowerPak @@ -2145,6 +2165,7 @@ wire [15:0] multiply_result = multiplier_1 * multiplier_2; ; ;----------------------------------- */ +integer i; always @(posedge clk) begin // 21.477272MHz/1MHz // Using 21.5; Replace with actual pll? @@ -2173,6 +2194,16 @@ always @(posedge clk) begin nsf_reg[4'hD] <= 8'h05; nsf_reg[4'hE] <= 8'h06; nsf_reg[4'hF] <= 8'hFF; + for (i=0;i<32;i++) + apu_reg[i] <= i; + for (i=0;i<32;i++) + midi_reg[i] <= 8'h00; + for (i=0;i<16;i++) + vrc6_reg[i] <= 8'h00; + for (i=0;i<16;i++) + ssb5_reg[i] <= 8'h00; + for (i=0;i<16;i++) + fds_reg[i] <= 8'h00; end else if (ce) begin if ((prg_ain[15:4]==12'h5FF) && prg_write) nsf_reg[prg_ain[3:0]] <= prg_din; @@ -2182,6 +2213,35 @@ always @(posedge clk) begin multiplier_1 <= prg_din; if ((prg_ain==16'h5206) && prg_write) multiplier_2 <= prg_din; + if ((prg_ain[15:5]==11'b0100_0000_000) && prg_write) + apu_reg[prg_ain[4:0]] <= prg_din; + if ((prg_ain[15:5]==11'b0100_0000_001) && prg_write) + midi_reg[prg_ain[4:0]] <= prg_din; + if ((prg_ain[15:5]==11'b0101_0000_000) && prg_ain[3]==1'b0 && prg_write) + mmc5_reg[{prg_ain[4],prg_ain[2:0]}] <= prg_din; + if ((prg_ain[15:14]==2'b10 && prg_ain[13:12] != 2'b00 && prg_ain[11:2] == 10'b0000_0000_00) && prg_write) + vrc6_reg[{prg_ain[13:12],prg_ain[1:0]}] <= prg_din; + if ((prg_ain[15: 0]==16'hC000) && prg_write) + ssb5_add <= prg_din[3:0]; + if ((prg_ain[15: 0]==16'hE000) && prg_write) + ssb5_reg[ssb5_add] <= prg_din; + if ((prg_ain[15:4]==12'h408) && prg_write) + fds_reg[prg_ain[3:0]] <= prg_din; + //ram in + do_inc<= 0; + if (do_inc) + ram_ain<=ram_ain+1'd1; + if(prg_ain==16'hF800 && prg_write) + {autoinc,ram_ain}<=prg_din; + else if(prg_ain==16'h4800 & autoinc) + do_inc<=1; + if(prg_ain==16'h4800 && prg_write && ram_ain[6]) + n163_reg[ram_ain[5:0]] <= prg_din; + if ((prg_ain[15: 0]==16'h9010) && prg_write) + vrc7_add <= {prg_din[5:4],prg_din[2:0]}; + if ((prg_ain[15: 0]==16'h9030) && prg_write) + vrc7_reg[vrc7_add] <= prg_din; + end end @@ -2197,12 +2257,233 @@ always begin endcase end +reg [4:0] ppu_line; +always @(posedge clk) begin + if ((chr_ain[13:11] == 3'b10_0) && (chr_ain[9:6] != 4'b11_11) && chr_read) begin + ppu_line <= chr_ain[9:5]; + end +end + +wire pul0 = ppu_line[4:1] == 4'd2; +wire pul1 = ppu_line[4:1] == 4'd3; +wire tria = ppu_line[4:1] == 4'd4; +wire nois = ppu_line[4:1] == 4'd5; +wire samp = ppu_line[4:1] == 4'd6; +wire m5pul0 = ppu_line[4:1] == 4'd7 && !(exp_audioe[4] && n163_max) && !exp_audioe[1]; +wire m5pul1 = ppu_line[4:1] == 4'd8 && !(exp_audioe[4] && n163_max) && !exp_audioe[1]; +wire m5samp = ppu_line[4:1] == 4'd9 && !exp_audioe[4] && !exp_audioe[2] && !exp_audioe[1]; +wire v6pul0 = ppu_line[4:1] == 4'd10 && !exp_audioe[5] && !exp_audioe[4] && !exp_audioe[1]; //e=0 +wire v6pul1 = ppu_line[4:1] == 4'd11 && !exp_audioe[5] && !exp_audioe[4] && !exp_audioe[1]; //e=0 +wire v6saw = ppu_line[4:1] == 4'd12 && !exp_audioe[5] && !exp_audioe[4] && !exp_audioe[1]; //e=0 +wire s5pul0 = ppu_line[4:1] == 4'd10 && exp_audioe[5]; +wire s5pul1 = ppu_line[4:1] == 4'd11 && exp_audioe[5]; +wire s5pul2 = ppu_line[4:1] == 4'd12 && exp_audioe[5]; +wire fds = ppu_line[4:1] == 4'd9 && exp_audioe[2] && !exp_audioe[4]; +wire n163_0 = ppu_line[4:1] == 4'd9 && exp_audioe[4]; +wire n163_1 = ppu_line[4:1] == 4'd10 && !exp_audioe[5] && exp_audioe[4]; +wire n163_2 = ppu_line[4:1] == 4'd11 && !exp_audioe[5] && exp_audioe[4]; +wire n163_3 = ppu_line[4:1] == 4'd12 && !exp_audioe[5] && exp_audioe[4]; +wire n163_4 = ppu_line[4:1] == 4'd13 && exp_audioe[4] && n163_max; +wire n163_5 = ppu_line[4:1] == 4'd14 && exp_audioe[4] && n163_max; +wire n163_6 = ppu_line[4:1] == 4'd7 && exp_audioe[4] && n163_max; +wire n163_7 = ppu_line[4:1] == 4'd8 && exp_audioe[4] && n163_max; +wire vrc7_0 = ppu_line[4:1] == 4'd7 && !(exp_audioe[4] && n163_max) && exp_audioe[1]; +wire vrc7_1 = ppu_line[4:1] == 4'd8 && !(exp_audioe[4] && n163_max) && exp_audioe[1]; +wire vrc7_2 = ppu_line[4:1] == 4'd9 && !exp_audioe[4] && exp_audioe[1]; +wire vrc7_3 = ppu_line[4:1] == 4'd10 && !exp_audioe[4] && exp_audioe[1]; +wire vrc7_4 = ppu_line[4:1] == 4'd11 && !exp_audioe[4] && exp_audioe[1]; +wire vrc7_5 = ppu_line[4:1] == 4'd12 && !exp_audioe[4] && exp_audioe[1]; + +wire apu_type = pul0 | pul1 | tria | nois | samp; +wire mmc5_type = m5samp | m5pul0 | m5pul1; +wire vrc6_type = v6pul0 | v6pul1 | v6saw; +wire ssb5_type = s5pul0 | s5pul1 | s5pul2; +wire fds_type = fds; +wire n163_type = n163_0 | n163_1 | n163_2 | n163_3 | n163_4 | n163_5 | n163_6 | n163_7; +wire vrc7_type = vrc7_0 | vrc7_1 | vrc7_2 | vrc7_3 | vrc7_4 | vrc7_5; + +//wire [3:0] voi_idx = {!(ppu_line[4]^ppu_line[3]),!ppu_line[3],ppu_line[2:1]}; +wire [2:0] n163_idx = ~(n163_7 ? 3'd7 : n163_6 ? 3'd6 : n163_5 ? 3'd5 : n163_4 ? 3'd4 : n163_3 ? 3'd3 : n163_2 ? 3'd2 : n163_1 ? 3'd1 : 3'd0); +wire n163_max = n163_reg[6'h3F][6]; +wire [2:0] vrc7_idx = vrc7_5 ? 3'd5 : vrc7_4 ? 3'd4 : vrc7_3 ? 3'd3 : vrc7_2 ? 3'd2 : vrc7_1 ? 3'd1 : 3'd0; + +wire apu_off = !midi_reg[5'h0B][{1'b0, samp, tria | nois, pul1 | nois}]; // 'h403B = copy of read value of 'h4015 - voice on bits [4:0] +wire vrc6_off = !vrc6_reg[{!v6pul0,!v6pul1,2'b10}][7]; +wire fds_off = fds_reg[9][7]; +wire [1:0] ssb5_idx = {s5pul2,s5pul1}; +wire ssb5_off = ssb5_reg[7][ssb5_idx] & ssb5_reg[7][ssb5_idx+3'd3]; +wire mmc5_off = m5samp ? (mmc5_reg[4'h8]==0 && mmc5_reg[4'h9]==0) : !mmc5_reg[4'hD][!m5pul0]; +wire n163_off = n163_reg[6'h3F][6:4] < (~n163_idx); +wire vrc7_off = 1'b0; +wire voi_off = ssb5_type ? ssb5_off : n163_type ? n163_off : vrc6_type ? vrc6_off : vrc7_type ? vrc7_off : mmc5_type ? mmc5_off : fds_type ? fds_off : apu_off; + +wire [3:0] puls_vol = apu_reg[{2'b00,pul1,2'b00}][3:0]; //h'4000 or 'h4004 [3:0] +wire [3:0] tria_vol = (|apu_reg[5'h08][6:0]) ? 4'hF : 4'h0; // h'4008 [6:0] +wire [3:0] nois_vol = apu_reg[12][3:0]; // h'400C [3:0] +wire [3:0] samp_vol = 4'hF; +wire [3:0] apu_vol = samp ? samp_vol : nois ? nois_vol : tria ? tria_vol : puls_vol; +wire [3:0] vrc6_pul_vol = vrc6_reg[{!v6pul0,!v6pul1,2'b00}][3:0]; +wire [3:0] vrc6_saw_vol = {vrc6_reg[4'b1100][5:3],|vrc6_reg[4'b1100][2:0]}; +wire [3:0] vrc6_vol = v6saw ? vrc6_saw_vol : vrc6_pul_vol; +wire [3:0] fds_vol = {fds_reg[0][5:3],|fds_reg[0][2:0]}; +wire [3:0] ssb5_vol = ssb5_reg[{2'b10,ssb5_idx}][3:0]; +wire [3:0] mmc5_samp_vol = 4'hF; +wire [3:0] mmc5_pul_vol = mmc5_reg[{1'b0,m5pul1,2'b00}][3:0]; +wire [3:0] mmc5_vol = m5samp ? mmc5_samp_vol : mmc5_pul_vol; +wire [3:0] n163_vol = n163_reg[{n163_idx,3'b111}][3:0]; +wire [3:0] vrc7_vol = vrc7_reg[{2'b11,vrc7_idx}][3:0]; +wire [3:0] voi_vol = ssb5_type ? ssb5_vol : n163_type ? n163_vol : vrc6_type ? vrc6_vol : vrc7_type ? vrc7_vol : mmc5_type ? mmc5_vol : fds_type ? fds_vol : apu_vol; + + +wire [4:0] n_freq = {1'b0,~apu_reg[5'h0E][3:0]}; // 'h400E = noise period; invert for period +wire [4:0] s_freq = {1'b0,apu_reg[5'h10][3:0]}; // 'h4010/5010 = sample freq +wire [4:0] ms_freq = mmc5_reg[4'h8][0] ? 5'h1 : 5'h0; // 'h4010/5010 = sample freq +wire [4:0] freq = nois ? n_freq : samp ? s_freq : ms_freq; +wire use_freq = nois | samp | m5samp; + +wire [4:0] voi_tab_idx; +always begin + casez({n163_max,exp_audioe,ppu_line}) //6,5 + 12'b???????_000??: voi_tab_idx = 5'd0; //Info; + 12'b???????_001??: voi_tab_idx = {4'd0,ppu_line[1]}; //Apu; + 12'b???????_010??: voi_tab_idx = {4'd1,ppu_line[1]}; //Apu; + 12'b???????_0110?: voi_tab_idx = 5'd0; //Samp; + 12'b??0??0?_0111?: voi_tab_idx = 5'd3; //MMC5; + 12'b??0??0?_1000?: voi_tab_idx = 5'd4; //MMC5; + 12'b0?1????_0111?: voi_tab_idx = 5'd3; //MMC5; + 12'b0?1????_1000?: voi_tab_idx = 5'd4; //MMC5; + 12'b??0??1?_0111?: voi_tab_idx = 5'd20; //VRC7; + 12'b??0??1?_1000?: voi_tab_idx = 5'd21; //VRC7; + 12'b1?1????_0111?: voi_tab_idx = 5'd18; //N163; + 12'b1?1????_1000?: voi_tab_idx = 5'd19; //N163; + 12'b??0?1??_1001?: voi_tab_idx = 5'd12; //FDS; + 12'b??0?00?_1001?: voi_tab_idx = 5'd0; //MMC5; + 12'b??0?01?_1001?: voi_tab_idx = 5'd22; //VRC7; + 12'b??1????_1001?: voi_tab_idx = 5'd8; //N163; + 12'b?00??0?_101??: voi_tab_idx = {!ppu_line[1]?5'd5:5'd6}; //VRC6; + 12'b?00??0?_1100?: voi_tab_idx = 5'd7; //VRC6; + 12'b?1?????_101??: voi_tab_idx = {!ppu_line[1]?5'd13:5'd14}; //SSB5; + 12'b?1?????_1100?: voi_tab_idx = 5'd15; //SSB5; + 12'b?00??1?_1010?: voi_tab_idx = 5'd23; //VRC7; + 12'b?00??1?_1011?: voi_tab_idx = 5'd24; //VRC7; + 12'b?00??1?_1100?: voi_tab_idx = 5'd25; //VRC7; + 12'b?01????_1010?: voi_tab_idx = 5'd9; //N163; + 12'b?01????_1011?: voi_tab_idx = 5'd10; //N163; + 12'b?01????_1100?: voi_tab_idx = 5'd11; //N163; + 12'b1?1????_1101?: voi_tab_idx = 5'd16; //N163; + 12'b1?1????_1110?: voi_tab_idx = 5'd17; //N163; + 12'b0??????_1101?: voi_tab_idx = 5'd0; //Reg; + 12'b0??????_1110?: voi_tab_idx = 5'd0; //Reg; + 12'b1?0????_1101?: voi_tab_idx = 5'd0; //Reg; + 12'b1?0????_1110?: voi_tab_idx = 5'd0; //Reg; + 12'b???????_1111?: voi_tab_idx = 5'd0; //VBlank; + endcase +end + +reg [4:0] find_count; +reg [4:0] find_idx; +wire [11:0] period [25:0]; +assign period[0] = {1'b0,apu_reg[3][2:0],apu_reg[2][7:0]}; +assign period[1] = {1'b0,apu_reg[7][2:0],apu_reg[6][7:0]}; +assign period[2] = {apu_reg[11][2:0],apu_reg[10][7:0],1'b0}; +assign period[3] = (exp_audioe[3] | 1) ? {1'b0,mmc5_reg[3][2:0],mmc5_reg[2][7:0]} : 12'hFFF; +assign period[4] = (exp_audioe[3] | 1) ? {1'b0,mmc5_reg[7][2:0],mmc5_reg[6][7:0]} : 12'hFFF; +assign period[5] = exp_audioe[0] ? {vrc6_reg[6][3:0],vrc6_reg[5][7:0]} : 12'hFFF; +assign period[6] = exp_audioe[0] ? {vrc6_reg[10][3:0],vrc6_reg[9][7:0]}: 12'hFFF; +assign period[7] = exp_audioe[0] ? {vrc6_reg[14][3:0],vrc6_reg[13][7:0]} : 12'hFFF; +assign period[8] = exp_audioe[4] ? {n163_reg[6'b111100][1:0],n163_reg[6'b111010][7:0],n163_reg[6'b111000][7:6]} : 12'hFFF; +assign period[9] = exp_audioe[4] ? {n163_reg[6'b110100][1:0],n163_reg[6'b110010][7:0],n163_reg[6'b110000][7:6]} : 12'hFFF; +assign period[10] = exp_audioe[4] ? {n163_reg[6'b101100][1:0],n163_reg[6'b101010][7:0],n163_reg[6'b101000][7:6]} : 12'hFFF; +assign period[11] = exp_audioe[4] ? {n163_reg[6'b100100][1:0],n163_reg[6'b100010][7:0],n163_reg[6'b100000][7:6]} : 12'hFFF; +assign period[12] = exp_audioe[2] ? {fds_reg[3][3:0],fds_reg[2][7:0]} : 12'hFFF; +assign period[13] = exp_audioe[5] ? {ssb5_reg[1][2:0],ssb5_reg[0][7:0],1'b1} : 12'hFFF; +assign period[14] = exp_audioe[5] ? {ssb5_reg[3][2:0],ssb5_reg[2][7:0],1'b1} : 12'hFFF; +assign period[15] = exp_audioe[5] ? {ssb5_reg[5][2:0],ssb5_reg[4][7:0],1'b1} : 12'hFFF; +assign period[16] = exp_audioe[4] ? {n163_reg[6'b011100][1:0],n163_reg[6'b011010][7:0],n163_reg[6'b011000][7:6]} : 12'hFFF; +assign period[17] = exp_audioe[4] ? {n163_reg[6'b010100][1:0],n163_reg[6'b010010][7:0],n163_reg[6'b010000][7:6]} : 12'hFFF; +assign period[18] = exp_audioe[4] ? {n163_reg[6'b001100][1:0],n163_reg[6'b001010][7:0],n163_reg[6'b001000][7:6]} : 12'hFFF; +assign period[19] = exp_audioe[4] ? {n163_reg[6'b000100][1:0],n163_reg[6'b000010][7:0],n163_reg[6'b000000][7:6]} : 12'hFFF; +assign period[20] = exp_audioe[1] ? {vrc7_reg[5'b10000][0],vrc7_reg[5'b01000][7:0],3'b111} : 12'hFFF; +assign period[21] = exp_audioe[1] ? {vrc7_reg[5'b10001][0],vrc7_reg[5'b01001][7:0],3'b111} : 12'hFFF; +assign period[22] = exp_audioe[1] ? {vrc7_reg[5'b10010][0],vrc7_reg[5'b01010][7:0],3'b111} : 12'hFFF; +assign period[23] = exp_audioe[1] ? {vrc7_reg[5'b10011][0],vrc7_reg[5'b01011][7:0],3'b111} : 12'hFFF; +assign period[24] = exp_audioe[1] ? {vrc7_reg[5'b10100][0],vrc7_reg[5'b01100][7:0],3'b111} : 12'hFFF; +assign period[25] = exp_audioe[1] ? {vrc7_reg[5'b10101][0],vrc7_reg[5'b01101][7:0],3'b111} : 12'hFFF; +wire [11:0] period78 = period[find_idx] - {3'b000,period[find_idx][11:3]}; +wire [11:0] period1615 = {1'b0,period[find_idx][11:1]} + {5'b0,period[find_idx][11:5]} - {9'b0,period[find_idx][11:9]}; // add ~1/16th (should be half step?): down an octave to avoid add overflow +wire use_n163 = (find_idx[4:2]==3'b010) || (find_idx[4:2]==3'b100); +wire use_vrc7 = (find_idx[4:2]==3'b101) || (find_idx[4:1]==4'b1100); +wire use_v6saw = (find_idx==5'd7); +wire use_fds = (find_idx==5'd12); +wire use78 = use_v6saw || use_vrc7; +wire use1615 = use_n163; +wire [11:0] period_use = use_n163? period1615 : use78 ? period78 : period[find_idx]; + +wire [17:0] find_bits; + logic [10:0] find_note_lut[80]; //not used; done in asm + assign find_note_lut = '{ + 11'h7f1,11'h77f,11'h713,11'h6ad,11'h64d,11'h5f3,11'h59d,11'h54c, + 11'h500,11'h4b8,11'h474,11'h434, 11'h3f8,11'h3bf,11'h389,11'h356, + 11'h326,11'h2f9,11'h2ce,11'h2a6,11'h280,11'h25c,11'h23a,11'h21a, + 11'h1fb,11'h1df,11'h1c4,11'h1ab, 11'h193,11'h17c,11'h167,11'h152, + 11'h13f,11'h12d,11'h11c,11'h10c,11'h0fd,11'h0ef,11'h0e1,11'h0d5, + 11'h0c9,11'h0bd,11'h0b3,11'h0a9, 11'h09f,11'h096,11'h08e,11'h086, + 11'h07e,11'h077,11'h070,11'h06a,11'h064,11'h05e,11'h059,11'h054, + 11'h04f,11'h04b,11'h046,11'h042, 11'h03f,11'h03b,11'h038,11'h034, + 11'h031,11'h02f,11'h02c,11'h029,11'h027,11'h025,11'h023,11'h021, + 11'h01f,11'h01d,11'h01b,11'h01a, 11'h018,11'h017,11'h015,11'h014 + }; + + logic [9:0] find_steps_lut[32]; + assign find_steps_lut = '{ + 10'h3D4, 10'h39B, 10'h363, 10'h32E, + 10'h2F9, 10'h2C6, 10'h295, 10'h265, + 10'h236, 10'h209, 10'h1DD, 10'h1B2, + 10'h189, 10'h160, 10'h139, 10'h113, + 10'h0EE, 10'h0CA, 10'h0A7, 10'h085, + 10'h064, 10'h044, 10'h025, 10'h007, + 10'h000, 10'h000, 10'h000, 10'h000, + 10'h000, 10'h000, 10'h000, 10'h000 + }; + +always begin + casez(period_use[11:2]) + 10'b1???_????_??: find_bits = {4'd8,4'd0,period_use[10:1]}; + 10'b01??_????_??: find_bits = {4'd7,4'd1,period_use[9:0]}; + 10'b001?_????_??: find_bits = {4'd6,4'd2,period_use[8:0],1'b1}; + 10'b0001_????_??: find_bits = {4'd5,4'd3,period_use[7:0],2'b10}; + 10'b0000_1???_??: find_bits = {4'd4,4'd4,period_use[6:0],3'b100}; + 10'b0000_01??_??: find_bits = {4'd3,4'd5,period_use[5:0],4'b1000}; + 10'b0000_001?_??: find_bits = {4'd2,4'd6,period_use[4:0],5'b10000}; + 10'b0000_0001_??: find_bits = {4'd1,4'd7,period_use[3:0],6'b100000}; + 10'b0000_0000_1?: find_bits = {4'd0,4'd8,period_use[2:0],7'b1000000}; + 10'b0000_0000_0?: find_bits = {4'hF,4'd9,10'b1111111111}; // always find_count = 0 + endcase +end +reg [4:0] spot [25:0]; +reg [3:0] oct_no [25:0]; +always @(posedge clk) begin + find_count <= find_count + 1'b1; + if ((find_bits[9:0]>find_steps_lut[find_count[4:0]]) || (find_count[4:3] == 2'b11)) begin + spot[find_idx] <= (use_fds) || (use_vrc7) || (use_n163) ? (find_bits[17:14]==4'hF) ? 5'd0 : 5'd24 - find_count : find_count; + oct_no[find_idx] <= ((use_fds) || (use_vrc7) || (use_n163) ? (find_bits[17:14]==4'hF) ? 4'd0: find_bits[17:14] : find_bits[13:10]) - ((use_vrc7) ? 5'd8 - vrc7_reg[{2'b10,!find_idx[2],find_idx[1:0]}][3:1] : 5'd0); + find_count <= 0; + find_idx <= (find_idx == 5'd25) ? 5'd0 : find_idx + 1'b1; + end +end + always begin prg_bus_write = 1'b1; if (prg_ain == 16'h5205) begin prg_dout = multiply_result[7:0]; end else if (prg_ain == 16'h5206) begin prg_dout = multiply_result[15:8]; + end else if (prg_ain == 16'h4029) begin + prg_dout = find_note_lut[{midi_reg[5'h09][2:0],midi_reg[5'h08]}][1:0]; + end else if (prg_ain == 16'h4028) begin + prg_dout = {5'h0,find_note_lut[{midi_reg[5'h09][2:0],midi_reg[5'h08]}][7:0]}; + end else if (prg_ain[15:5]==11'b0100_0000_001) begin + prg_dout = midi_reg[prg_ain[4:0]]; end else if (prg_ain[15:8] == 8'h40) begin prg_dout = fds_din; end else if (prg_ain == 16'h5FF2) begin @@ -2213,14 +2494,53 @@ always begin end end + assign prg_aout = ((submapper == 4'hF) && ({prg_ain[15:1],1'b0} == 16'hFFFC)) ? {10'h0, prg_ain[11:0]} : {prg_bank, prg_ain[11:0]}; assign prg_allow = (((prg_ain[15] || ((prg_ain>=16'h4080) && (prg_ain<16'h4FFF))) && !prg_write) || (prg_ain[15:13]==3'b011) || (prg_ain[15:10]==6'b010111 && prg_ain[9:4]!=6'b111111) || ((prg_ain>=16'h8000) && (prg_ain<16'hDFFF) && exp_audioe[2])); assign chr_allow = flags[15]; // CHR RAM always... -assign chr_aout = {9'b10_0000_000, chr_ain[12:0]}; -assign vram_ce = chr_ain[13]; + +wire patt_bars = chr_ain[13:11] == 3'b00_1; // 'h0800-'hfff bar pattern for pulse1,pulse2,triangle,noise,sample volume +assign chr_aout = {9'b10_0000_000, chr_read && patt_bars ? {5'b0_0001,chr_ain[7:0]} : chr_ain[12:0]}; //replace 'h0800-'h0fff with 'h0100-'h01ff = bars location +assign vram_ce = chr_ain[13] & !has_chr_dout; assign vram_a10 = flags[14] ? chr_ain[10] : chr_ain[11]; +wire nt0 = chr_ain[13:10] == 4'b10_00; // 'h2000-23FF +wire [4:0] line_no = chr_ain[9:5]; // line # d0 - 31 +wire reg_line = ((line_no==5'b11_010) || (line_no==5'b11_011) || (line_no==5'b11_100) || (line_no==5'b11_101)) && (!n163_max || !exp_audioe[4]); // d4,5,6 +wire alt4 = chr_ain[2] == 1'b1; // every other (odd) four characters +wire midi_line = (line_no[4:1] == 4'b01_01) || (line_no[4:1] == 4'b01_10); // lines d10-13 +wire last16 = chr_ain[4] == 1'b1; // second half d16-31 +wire last1 = chr_ain[4:0] == 5'd31; // char d31 +wire last2 = chr_ain[4:0] == 5'd30; // char d30 +wire last3 = chr_ain[4:0] == 5'd29; // char d29 +wire print_reg = nt0 && alt4 && reg_line; +wire print_midi = nt0 && midi_line && last16; +wire print_spot = nt0 && !print_midi && (apu_type || mmc5_type || fds_type || vrc6_type || vrc7_type || n163_type || ssb5_type); +wire print_oct = nt0 && !midi_line && !use_freq && print_spot && last1; +wire print_let = nt0 && !midi_line && !use_freq && print_spot && last2; +wire print_shp = nt0 && !midi_line && !use_freq && print_spot && last3 && sharp; +wire [4:0] reg_ind = {!chr_ain[6],chr_ain[5:3],!chr_ain[1]}; // inverted1 means MSB first. lines up with d4,5,6 +wire [4:0] midi_ind = {!chr_ain[6],chr_ain[5],chr_ain[3:1]}; // last16 means ignore 4 +wire [7:0] chr_num = print_reg ? exp_audioe[3] ? mmc5_reg[reg_ind] : exp_audioe[4] ? n163_reg[{~reg_ind[4:2],~reg_ind[1],reg_ind[0],reg_ind[1:0]==2'b01}] : exp_audioe[2] ? fds_reg[reg_ind] : exp_audioe[1] ? vrc7_reg[reg_ind] : exp_audioe[0] ? vrc6_reg[{reg_ind[3:2],reg_ind[1]^reg_ind[0],!reg_ind[0]}] : exp_audioe[5] ? ssb5_reg[reg_ind] : apu_reg[reg_ind] : print_midi ? (n163_max && exp_audioe[4] && (midi_reg[5'd7]==8'd0)) ? n163_reg[{~midi_ind[4:2],~midi_ind[1],midi_ind[0],midi_ind[1:0]==2'b01}] : midi_reg[midi_ind] : oct_no[voi_tab_idx] + (inc_oct ? 1'b1 : 1'b0); +wire [4:0] oct_idx = {1'b0,oct_no[voi_tab_idx]} + {oct_no[voi_tab_idx],1'b0}; // 3 * oct_no[voi_idx[1:0]] +wire [4:0] spot_chr = use_freq ? freq : oct_idx + {3'b000,spot[voi_tab_idx][4:3]}; // noise+sample=d0-15, tri=d0-24 (25-27->24), puls=d3-27 (28-30->27) +wire [3:0] spot_vol = voi_off ? 4'h0 : voi_vol; +wire has_spot_chr = print_spot && (chr_ain[4:0] == spot_chr); +wire skip_vol = !print_midi && !print_oct && patt_bars && ((spot_vol[2:0]<=~chr_ain[2:0] && !(spot_vol[3] && !chr_ain[3])) || (!spot_vol[3] && chr_ain[3])); // skip middle volume bar if vol[2:0] is less than pixelrow[2:0]; skip outer volume bars if vol[3] is not set +wire spot_vol_row = !chr_ain[5]; // d18,20,22,24,26 +wire [4:0] spot_val = {spot_vol_row ? {4'b1000,use_freq ? 1'b1 : 1'b0}:5'h0}; // d18->10010, 20->10100, 22->10110, 24->11001, 25->11011: [4]=1 means bar pattern, [3:1]=voi_idx will be in chr_ain[10:8]->ignored, [0]=chr_ain[7] 0x0 = 0x800, 0x1 = 0x0880 pattern table address; will be adjusted to 0x100 and 0x180 +wire [4:0] note_val = spot[voi_tab_idx][4:0]; +wire inc_note = (note_val == 5'd23) || (note_val == 5'd24); +wire inc_oct = (note_val > 5'd5); +wire [4:0] note_no = inc_note ? 5'd4 : (note_val + (note_val > 5'd14 ? 5'd9 : note_val > 5'd5 ? 5'd7 : 5'd5)); +wire [7:0] letter = {5'b0100_0,note_no[4:2]}; // A=$41,G=$47 +wire sharp = note_no[1]; // #=$23 + +wire cpu_ppu_write = prg_write && prg_ain[15:12]==4'h2; // 'h2000-2FFF +assign has_chr_dout = !(cpu_ppu_write) && (print_reg || print_spot || skip_vol || print_midi || print_oct || print_let || print_shp); +assign chr_dout = skip_vol ? {8'h00} : print_let ? letter : print_shp ? 8'h23 : (print_spot && !print_oct) ? has_spot_chr ? {spot_val,use_freq?3'b000:spot[voi_tab_idx][2:0]} : {8'h20} : {4'h0, chr_ain[0] ? chr_num[3:0] : chr_num[7:4]}; + endmodule // 111 - Cheapocabra/GTROM diff --git a/rtl/nes.v b/rtl/nes.v index a069e6d..9c26eb0 100644 --- a/rtl/nes.v +++ b/rtl/nes.v @@ -600,7 +600,7 @@ wire [15:0] prg_addr = addr; wire [7:0] prg_din = dbus & (prg_conflict ? cpumem_din : 8'hFF); wire prg_read = mr_int && cart_pre && !apu_cs && !ppu_cs; -wire prg_write = mw_int && cart_pre && !apu_cs && !ppu_cs; +wire prg_write = mw_int && cart_pre; wire prg_allow, prg_bus_write, prg_conflict, vram_a10, vram_ce, chr_allow; wire [24:0] prg_linaddr; diff --git a/rtl/nsf.asm b/rtl/nsf.asm new file mode 100644 index 0000000..3a77bf9 --- /dev/null +++ b/rtl/nsf.asm @@ -0,0 +1,893 @@ +;---------------------------------- +; NSF player for PowerPak +; +; Player rom is at $4100-4FFF (NSF header at $4100) +; +; PowerPak registers: +; +; 5FF0: timer latch LSB +; 5FF1: timer latch MSB +; 5FF2: timer status (Read: bit7=timer wrapped, Write: clear status) +; 5FF3: Expansion audio control (copy header[0x7B] here) +; 5FF6-5FFF: banking registers (as described in NSF spec) +; +; Timer details: +; PowerPak NSF mapper has a 16bit 1MHz counter that counts down from [5FF1:5FF0] to 0. +; After the counter reaches 0, it's automatically reloaded and timer status bit is set. +; Clear the status bit by writing to $5FF2. +; +;----------------------------------- + + +A = $80 +B = $40 +SELECT = $20 +START = $10 +UP = $08 +DOWN = $04 +LEFT = $02 +RIGHT = $01 + +HDR_BASE = $4100 +HDR_SONGS = HDR_BASE+$06 +HDR_FIRST = HDR_BASE+$07 +HDR_LOAD = HDR_BASE+$08 +HDR_INIT = HDR_BASE+$0a +HDR_PLAY = HDR_BASE+$0c +HDR_TITLE = HDR_BASE+$0e +HDR_ARTIST = HDR_BASE+$2e +HDR_COPYRIGHT = HDR_BASE+$4e +HDR_NTSC_LO = HDR_BASE+$6E +HDR_NTSC_HI = HDR_BASE+$6F +HDR_BANK = HDR_BASE+$70 +HDR_PAL_LO = HDR_BASE+$78 +HDR_PAL_HI = HDR_BASE+$79 +HDR_EXP_HW = HDR_BASE+$7b + +STACK_TOP = $1f4 + CURRENT = $1f4 ;song# + PLAYING = $1f5 ;nonzero=song is playing + JOYPAD = $1f6 ;button state + JOYD = $1f7 ;button 0->1 + JOYTMP = $1f8 + FRAME = $1f9 + PAL = $1fa ;1=PAL detected + DIVTMP = $1fb + STR = $1fc ;4 bytes used for printing current song # + +; header ------ + + db $4E,$45,$53,$1A + db $01 ;PRG size/16k + db $00 ;CHR size/8k + db $00,$00 ;flags,mapper + db $00,$00,$00,$00,$00,$00,$00,$00 + + .org $4000 + .pad HDR_BASE+$80 + +reset ;------- + + sei + ldx #<(STACK_TOP-1) + txs + stx PLAYING + + lda #$00 + sta $2000 ;nmi off + sta $2001 ;screen off + jsr pal_detect + + ldx #8 ;load CHR: 128 tiles = $800 bytes + ldy #$00 + sty $2006 + sty $2006 + lda #chr + sta 1 +- lda (0),y + sta $2007 + iny + bne - + inc 1 + dex + bpl - + + lda #$3f ;set palette + sta $2006 + lda #$00 + sta $2006 + ldx #8 +- lda #$0f + sta $2007 + lda #$30 + sta $2007 + sta $2007 + sta $2007 + dex + bne - + + lda #$20 ;clear screens + sta $2006 + lda #$00 + sta $2006 + tax + ldy #4 ;$10 + lda #$20 ;" " +- sta $2007 + inx + bne - + dey + bne - + + lda #$20 + sta $2006 + lda #$70 + sta $2006 + lda #$2f ;"/" + sta $2007 + lda HDR_SONGS + jsr deci +- lda STR,y ;print #songs + sta $2007 + dey + bpl - + + lda #$20 ;print song infos + sta $2006 + lda #$42 + sta $2006 + ldy #0 +- lda HDR_TITLE,y + beq + + sta $2007 + iny + cpy #30 + bne - ++ + lda #$20 + sta $2006 + lda #$22 + sta $2006 + ldy #0 +- lda HDR_ARTIST,y + beq + + sta $2007 + iny + cpy #30 + bne - ++ + lda #$20 + sta $2006 + lda #$02 + sta $2006 + ldy #0 +- lda HDR_COPYRIGHT,y + beq + + sta $2007 + iny + cpy #30 + bne - ++ + lda HDR_EXP_HW ;enable extra audio HW (also PRG write enable for FDS) + sta $5ff3 + + ora #$40 ;- kevtris - swap VRC6 registers which is how all NSFs use VRC6 + ldx #$55 + stx $3ff2 + ldx #$aa + stx $3fea ;- these two writes enable the chip select mode in the HDNES hardware + sta $3ffa ;- automatic enable setting for HDNES + + jsr timer_init + + lda HDR_FIRST ;init first song + sta CURRENT + jsr init + + lda #%00001010 ;screen on, sprites off + sta $2001 + +busywait + lda $5ff2 + bpl busywait + sta $5ff2 + + inc FRAME + jsr joyread + jsr play + jmp copyapustatus ;busywait + +pal_detect ;----------------- + lda $2002 +- lda $2002 + bpl - + + ldy #24 ;eat about 30000 cycles (1 NTSC frame) + ldx #100 +- dex + bne - + dey + bne - + + lda $2002 ;VBL flag is set if NTSC + bmi + + inx ++ stx PAL + rts + +init ;------------------ ;begin CURRENT song + jsr stopsound + + jsr bank_init + + lda HDR_EXP_HW ;clear 6000-7fff unless FDS is enabled + and #4 + bne no_wram_clear + lda #$60 + sta 1 + lda #0 + sta 0 + tay +- sta (0),y + iny + bne - + inc 1 + bpl - + no_wram_clear + + lda #0 ;clear 0000-07ff + tax +- sta $00,x + sta $200,x ;(not 100-1ff) + sta $300,x + sta $400,x + sta $500,x + sta $600,x + sta $700,x + inx + bne - + + lda CURRENT ;print song# + jsr deci + lda #$20 ;<--- +- iny + sta STR,y + cpy #3 + bne - + lda $2002 +- lda $2002 + bpl - + lda #$20 + sta $2006 + lda #$6d + sta $2006 + lda STR+2 + sta $2007 + lda STR+1 + sta $2007 + lda STR + sta $2007 + + lda #$00 ;reset scroll + sta $2006 + sta $2006 + + lda PLAYING + bne + + rts ++ + ldx CURRENT ;call INIT w/ A=song#, X=pal + dex + txa + ldx PAL + jmp (HDR_INIT) + +bank_init ;--------------- + lda #0 + ldx #7 +- ora HDR_BANK,x + dex + bpl - + tax + bne banked_nsf + not_banked: + lda HDR_LOAD+1 + lsr + lsr + lsr + lsr + tax + ldy #0 +- tya + sta $5ff0,x + iny + inx + cpx #$10 + bne - + dey + sty $5ff7 + dey + sty $5ff6 + rts + banked_nsf: + ldx #7 +- lda HDR_BANK,x + sta $5ff8,x + dex + bpl - + lda HDR_BANK+6 ;FDS also has banks @ 6000-7FFF + sta $5ff6 + lda HDR_BANK+7 + sta $5ff7 + rts +timer_init ;------------- + lda HDR_NTSC_LO + ldy HDR_NTSC_HI + ldx PAL + beq + + lda HDR_PAL_LO + ldy HDR_PAL_HI ++ + cpy #0 + beq fixit ++ cmp #$41 + bne time_ok + cpy #$1a + bne time_ok + fixit + lda time_lo,x + ldy time_hi,x + time_ok + sta $5ff0 + sty $5ff1 + rts + + time_hi db $41, $4e + time_lo db $1a, $20 + +stopsound ;--------------- + lda #$00 ;reset sound regs + sta $4015 + sta $4008 + lda #$10 + sta $4000 + sta $4004 + sta $400c + lda #$0f + sta $4015 + lda #$40 + sta $4017 + + lda #$c0 ;FDS reset + sta $4083 + sta $4080 + sta $4084 + sta $4087 + sta $4089 + lda #$e8 + sta $408a + + ;-----------------------kevtris start + + lda HDR_EXP_HW + and #$01 + beq szz0 + + lda #$00 ;shut up VRC6 + sta $9000 + sta $a000 + sta $b000 + +szz0 + lda HDR_EXP_HW + and #$02 + beq szz1 + + lda #$00 ;shut up VRC7 + ldx #$35 +sswt ldy #$10 + stx $9010 + nop + nop + nop + nop + sta $9030 +sswx dey + bne sswx + dex + bne sswt + +szz1 + lda HDR_EXP_HW + and #$08 + beq ssz2 + + sta $5015 ;shut up MMC5 + +ssz2 + lda HDR_EXP_HW + and #$10 + beq ssz3 + + ldx #$80 ;shut up N163 + stx $f800 ;start from address 0, auto increment +sswq sta $4800 + dex + bpl sswq ;clear all RAM + +ssz3 + lda HDR_EXP_HW + and #$20 + beq ssz4 + + ldx #$0f ;shut up 5B +sswz stx $c000 + sta $e000 + dex + bpl sswz + +ssz4 + ;-------------------kevtris end + + rts +play ;-------------------- + lda PLAYING + beq + + lda #DOWN + bit JOYPAD + beq ++ + lda FRAME + lsr + bcc + +++ lda #UP + bit JOYPAD + beq playhere + jsr playhere + jsr playhere + playhere + jmp (HDR_PLAY) ++ rts + +joyread ;---------------- + lda JOYPAD + pha + jsr joyread2 +retry lda JOYPAD + sta JOYTMP + jsr joyread2 + lda JOYPAD + eor JOYTMP + bne retry + + pla + eor JOYPAD + and JOYPAD + sta JOYD + + asl ;A + bcc + +_A ldx CURRENT + cpx HDR_SONGS + bcc ++ + ldx #$00 +++ inx + stx CURRENT + jmp init ++ + asl ;B + bcc + +_B dec CURRENT + bne ++ + lda HDR_SONGS + sta CURRENT +++ jmp init ++ + asl ;SEL + bcc + + ;lda #$00 + ;sta PLAYING + ;jmp stopsound + jmp powerpak_bios_reset ++ + asl ;START + bcc + + lda #$01 + sta PLAYING + jmp init ++ + asl ;UP + asl ;DOWN + asl ;LEFT + bcs _B + + asl ;RIGHT + bcs _A + rts +joyread2 ;---------------- + jmp joyreadpiano +; nop +; nop +; ldx #1 +; stx $4016 +; dex +; stx $4016 +; ldx #$08 +;- clc +; lda $4017 ;kevtris - added to read controller 2 so the HDNES menu is still accessable +; lda $4016 +; ora #$fc +; adc #3 +; rol JOYPAD +; dex +; bne - +; rts +div10 ;------------------ + ldx #0 ;in: A=# + stx DIVTMP ;out: X=#/10, A=remainder + cmp #%10100000 + bcc + + sbc #%10100000 ++ rol DIVTMP + cmp #%01010000 + bcc + + sbc #%01010000 ++ rol DIVTMP + cmp #%00101000 + bcc + + sbc #%00101000 ++ rol DIVTMP + cmp #%00010100 + bcc + + sbc #%00010100 ++ rol DIVTMP + cmp #%00001010 + bcc + + sbc #%00001010 ++ rol DIVTMP + ldx DIVTMP + rts +deci ;------------------- ;in: A=# + ldy #$ff ;out: A,X=? Y=strlen-1 +- jsr div10 + iny + sta STR,y + txa + bne - + rts + +powerpak_bios_reset ;--------- + lda #$00 ;screen off + sta $2000 + sta $2001 + jsr stopsound + ldx #(resetcode_end - resetcode - 1) +- lda resetcode,x + sta $0,x + dex + bpl - + jmp 0 + + resetcode + lda #1 + sta $4207 + jmp ($fffc) + resetcode_end + +;------------------------ +chr .bin "font.chr" ;ascii chr set + +notesLow + db $F1,$7F,$13,$AD,$4D,$F3,$9D,$4C,$00,$B8,$74,$34 + db $F8,$BF,$89,$56,$26,$F9,$CE,$A6,$80,$5C,$3A,$1A + db $FB,$DF,$C4,$AB,$93,$7C,$67,$52,$3F,$2D,$1C,$0C + db $FD,$EF,$E1,$D5,$C9,$BD,$B3,$A9,$9F,$96,$8E,$86 + db $7E,$77,$70,$6A,$64,$5E,$59,$54,$4F,$4B,$46,$42 + db $3F,$3B,$38,$34,$31,$2F,$2C,$29,$27,$25,$23,$21 + db $1F,$1D,$1B,$1A,$18,$17,$15,$14,$00,$00,$00,$00 +notesHigh + db $07,$07,$07,$06,$06,$05,$05,$05,$05,$04,$04,$04 + db $03,$03,$03,$03,$03,$02,$02,$02,$02,$02,$02,$02 + db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 + ; can cut off here and do a compare (>= use $00) instead to save space + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + +MIDI_BUFF = $4030 ; 4030-403f +MIDI_READ = $402f +MIDI_START = $402e +MIDI_NEXT = $402d +MIDI_RECENT = $402c +APU_STATUSC = $402b ; Copy of last write to $4015 +MMC5_STATUSC = $402a ; Copy of last write to $5015 +LOOKUP_HI_R = $4029 ; Read - Based on 402a - change? +LOOKUP_LOW_R = $4028 ; Read - Based on 402a - change? +MIDI_PATCH = $4027 +MIDI_NOTE2 = $4026 ; keep in order 2,1 separate by 4 +MIDI_NOTE3 = $4025 +AVAILABLE = $4024 +FDS_ENABLE = $4023 ; Don't use this +MIDI_NOTE1 = $4022 +MIDI_TMP2 = $4021 +MIDI_TMP = $4020 + +joyreadpiano + ldx #1 + stx $4016 + dex + nop + nop + nop + stx $4016 + stx MIDI_READ + stx MIDI_READ + lda $4016 + ror a + bcs readmidi + jmp joy2read +readmidi + ;nop ; /needed on real hw? + ;nop ; /needed on real hw? + ldx #8 +readmidibit + lda $4016 + ror a + rol MIDI_READ + dex + bne readmidibit + lda MIDI_READ + eor #$ff + sta MIDI_READ + + ldx MIDI_NEXT + sta MIDI_BUFF,x + inx + txa ; these txa, and #0F, tax could be replaced with simple stx MIDI_NEXT (ie inc MIDI_NEXT) if buffer was 256 bytes + and #$0F + tax + sta MIDI_NEXT + + ldx MIDI_START + lda MIDI_BUFF,x + cmp #$ff + bne checkF + jmp doReset +checkF + and #$f0 + cmp #$f0 + bne checkC +testNext + inx + txa + and #$0F + tax + cpx MIDI_NEXT + bne contF + jmp doneTest +contF + lda MIDI_BUFF,x + and #$80 + bne testNext + jmp doNext +checkC + cmp #$c0 + bne check8B + inx + txa + and #$0F + tax + cpx MIDI_NEXT + bne doPatch + jmp doneTest +doPatch + lda MIDI_BUFF,x + sta MIDI_PATCH + jmp doNext +check8B + inx + inx + inx + txa + and #$0F + tax + cpx MIDI_NEXT + beq noteComplete + jmp doneTest +noteComplete + ldx MIDI_START + lda MIDI_BUFF,x + and #$e0 + cmp #$80 + beq doNote + jmp doNext +doNote + ldx MIDI_START + inx + txa + and #$0F + tax + lda MIDI_BUFF,x + sta MIDI_TMP ; note + tay + inx + txa + and #$0F + tax + lda MIDI_BUFF,x + sta MIDI_TMP2 ; vol + tya + cmp #$71 + bmi noteOkLow + jmp doNext +noteOkLow + cmp #$21 + bpl noteOkHigh + jmp doNext +noteOkHigh + lda MIDI_PATCH + cmp #$40 + bcs jNoteTri + and #$04 + bne noTri + tya + cmp #$39 ; split at A3 + bpl noTri +jNoteTri + jmp noteTri +noTri + tya + cmp MIDI_NOTE1 + bne testPulse2 + lda #$00 + jmp doPulse +testPulse2 + cmp MIDI_NOTE2 + bne useRecent + lda #$04 + jmp doPulse +useRecent + lda MIDI_TMP2 ; /vol + bne swapRecent + jmp doNext +swapRecent + lda MIDI_RECENT + eor #04 +doPulse + tax + tya + sta MIDI_NOTE1,x + sec + sbc #$21 + tay + lda MIDI_PATCH + and #$08 + bne noteM5 + lda notesLow,y + sta $4002,x + lda notesHigh,y + ora #$08 + sta $4003,x + jmp getVol +noteM5 + lda notesLow,y + sta $5002,x + lda notesHigh,y + ora #$08 + sta $5003,x +getVol + lda MIDI_TMP2 ; /vol + cmp #$78 + bpl setPulsVol + clc + adc #$07 +setPulsVol + ror + ror + ror + and #$0f + tay + ora #$30 + sta MIDI_TMP + lda MIDI_PATCH + ror + ror + ror + and #$c0 + ora MIDI_TMP + sta MIDI_TMP + lda MIDI_PATCH + and #$08 + bne volM5 + lda MIDI_TMP + sta $4000,x + lda #$00 + sta $4001,x + lda APU_STATUSC + ora #$03 + sta $4015 + jmp upRecent +volM5 + lda MIDI_TMP + sta $5000,x + lda #$00 + sta $5001,x + lda MMC5_STATUSC + ora #$03 + sta $5015 +upRecent + tya + bne setRecent + txa + eor #$04 + tax +setRecent + stx MIDI_RECENT + jmp doNext +noteTri + tya + cmp MIDI_NOTE3 + beq doTri + lda MIDI_TMP2 + beq doNext + tya +doTri + sta MIDI_NOTE3 + ldy #$3F + cpy MIDI_PATCH + bcc normOct + ;sec ; Must be set already if here + sbc #$09 ; (Up one octave) + jmp setTri +normOct + sec + sbc #$15 ; correct +setTri + tay + lda notesLow,y + sta $400a + lda notesHigh,y + ora #$f8 + sta $400b + lda MIDI_TMP2 + beq triOff + lda #$ff + bne triSet +triOff + lda #$80 +triSet + sta $4008 + lda APU_STATUSC + ora #$04 + sta $4015 +doNext + lda MIDI_NEXT + sta MIDI_START +doneTest +doReset + +joy2read + ldx #$08 +- clc + lda $4017 + ora #$fc + adc #3 + rol JOYPAD + dex + bne - + rts + + .pad $4fed +copyapustatus + lda $4015 + sta APU_STATUSC + lda $5015 + sta MMC5_STATUSC + jmp busywait + + .pad $4ffc ;powerpak bios jumps to (4FFC) + .dw reset ;vectors are NOT mapped to $Fxxx, IRQ/NMI must be disabled. + + .align $4000