<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[ChipMusic.org - glitchNES code hacking - asm mod to support multitap/four score]]></title>
	<link rel="self" href="https://chipmusic.org:80/forums/feed/atom/topic/17445/"/>
	<updated>2015-12-16T14:39:47Z</updated>
	<generator>PunBB</generator>
	<id>https://chipmusic.org/forums/topic/17445/glitchnes-code-hacking-asm-mod-to-support-multitapfour-score/</id>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237609/#p237609"/>
			<content type="html"><![CDATA[<p>Heavy W8 bit, you are literally the wind beneath my wings.</p><p>I use OSX and I found something with a flower icon that works fine.&nbsp; &nbsp;I spent hours of my life trying to figure out why that wouldn&#039;t compile.&nbsp; &nbsp; <br />Used a different text editor and works like a charm (I run the .bat file through wine)</p><p>We like to do custom glitchnes sets for our shows, but this is the first time we&#039;ve gone beyond .chr editing and adding palettes on the empty left and right buttons on controller 2.&nbsp; &nbsp; Also, I changed the rate of color blinking and the colors that get changed, although I don&#039;t really know what i&#039;m doing.&nbsp; &nbsp;The changes I made leave a neat &quot;screen tearing&quot; effect though.&nbsp; &nbsp;The .chr (or pal0.pal) being greyscale is really important to things not looking like shit when the original glitchnes color flasher runs.</p><p>Next step is to add mutlitap support (we run this thing patched off a retron 5, so we&#039;ve got 4 controllers + ready to go) so that I have more buttons to use.&nbsp; I&#039;d like to implement some of the effects from cmcwavy and possibly some more color palettes.</p><p>The thing about changing palettes in the code when assigned to a button is you have to do it all longform with reads/writes to 2006/2007 rather than doing it .byte (palette data) or .INCBIN &quot;palette.pal&quot; or else it&#039;ll freeze the code.&nbsp; &nbsp; Is there a way to do that with nametables also?</p><p>What I mean with palettes is:</p><p>&nbsp; &nbsp; lda #$3f<br />&nbsp; &nbsp; sta $2006<br />&nbsp; &nbsp; lda #$00<br />&nbsp; &nbsp; sta $2006<br />&nbsp; &nbsp; ldx #$15<br />&nbsp; &nbsp; stx $2007<br />&nbsp; &nbsp; lda #$01<br />&nbsp; &nbsp; sta $2007<br />&nbsp; &nbsp; lda #$3a<br />&nbsp; &nbsp; sta $2007<br />&nbsp; &nbsp; lda #$30<br />&nbsp; &nbsp; sta $2007<br />&nbsp; &nbsp; stx $2007<br />(etc. etc.)&nbsp; - you can assign this to a button in glitchnes and it&#039;ll change the palette, which is a good recovery when your glitches have sent your entire color scheme to absolute hell, or even just one big grey blob or something.</p><p>Is there a similar notation that can be used for a nametable?</p>]]></content>
			<author>
				<name><![CDATA[slowflood]]></name>
				<uri>https://chipmusic.org/slowflood</uri>
			</author>
			<updated>2015-12-16T14:39:47Z</updated>
			<id>https://chipmusic.org/forums/post/237609/#p237609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237600/#p237600"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>slowflood wrote:</cite><blockquote><p>Editing my code in something that does RTF rather than TXT natively may be the second sick joke of ASM.&nbsp; &nbsp; I think you&#039;re right.</p><p>This is sort of like how I spent 45 minutes of my life figuring out that a semicolon in ASM is for commenting out lines, not ending them.</p></blockquote></div><p>What OS are you on? If you&#039;re using Windows, Notepad++ is a good, light editor.</p>]]></content>
			<author>
				<name><![CDATA[jefftheworld]]></name>
				<uri>https://chipmusic.org/jefftheworld</uri>
			</author>
			<updated>2015-12-16T01:20:29Z</updated>
			<id>https://chipmusic.org/forums/post/237600/#p237600</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237580/#p237580"/>
			<content type="html"><![CDATA[<p>Editing my code in something that does RTF rather than TXT natively may be the second sick joke of ASM.&nbsp; &nbsp; I think you&#039;re right.</p><p>This is sort of like how I spent 45 minutes of my life figuring out that a semicolon in ASM is for commenting out lines, not ending them.</p>]]></content>
			<author>
				<name><![CDATA[slowflood]]></name>
				<uri>https://chipmusic.org/slowflood</uri>
			</author>
			<updated>2015-12-15T14:15:16Z</updated>
			<id>https://chipmusic.org/forums/post/237580/#p237580</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237579/#p237579"/>
			<content type="html"><![CDATA[<p>I would say the problem is the quote character.&nbsp; if you look closely the first quote is &#039;curved&#039; on PIC 6, while all the other quotes are &#039;straight&#039;.</p><p>pic6:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN “icon.nam&quot;<br />pic7:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;icon.nam&quot;</p><p>The compiler might not like the curved quotes. I could be wrong but hope this helps!</p>]]></content>
			<author>
				<name><![CDATA[HeavyW8bit]]></name>
				<uri>https://chipmusic.org/HeavyW8bit</uri>
			</author>
			<updated>2015-12-15T12:37:59Z</updated>
			<id>https://chipmusic.org/forums/post/237579/#p237579</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237575/#p237575"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>slowflood wrote:</cite><blockquote><p>Here&#039;s a new one - whenever I try to change the name of any nametable in the glitchnes.asm (or put a different palette name in, for that matter), I get this error upon compiling:</p><p>*snip*</p><p>Upon compiling, I get an error on the line number saying &quot;can&#039;t open file&quot;.&nbsp; &nbsp; I got around this with palettes by coding them directly into the ASM, but what&#039;s going on here?&nbsp; &nbsp;I&#039;m trying to import custom nametables and this is breaking all my shit.</p></blockquote></div><p>I&#039;m sorry, I can&#039;t reproduce that issue. It compiles for me even when I change it. If you send me your modified sources I can take a look.</p>]]></content>
			<author>
				<name><![CDATA[jefftheworld]]></name>
				<uri>https://chipmusic.org/jefftheworld</uri>
			</author>
			<updated>2015-12-15T06:10:11Z</updated>
			<id>https://chipmusic.org/forums/post/237575/#p237575</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237573/#p237573"/>
			<content type="html"><![CDATA[<p>Here&#039;s a new one - whenever I try to change the name of any nametable in the glitchnes.asm (or put a different palette name in, for that matter), I get this error upon compiling:</p><p>Let&#039;s take this:</p><p>pic0:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic1:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic2:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic3:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic4:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic5:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic6:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic7:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;icon.nam&quot;</p><br /><p>This will compile fine.&nbsp; &nbsp;However, say I change it to:</p><p>pic0:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic1:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic2:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic3:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic4:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic5:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;order.nam&quot;<br />pic6:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN “icon.nam&quot;<br />pic7:<br />&nbsp; &nbsp; &nbsp; &nbsp; .INCBIN &quot;icon.nam&quot;</p><br /><p>Upon compiling, I get an error on the line number saying &quot;can&#039;t open file&quot;.&nbsp; &nbsp; I got around this with palettes by coding them directly into the ASM, but what&#039;s going on here?&nbsp; &nbsp;I&#039;m trying to import custom nametables and this is breaking all my shit.</p>]]></content>
			<author>
				<name><![CDATA[slowflood]]></name>
				<uri>https://chipmusic.org/slowflood</uri>
			</author>
			<updated>2015-12-15T05:36:29Z</updated>
			<id>https://chipmusic.org/forums/post/237573/#p237573</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237566/#p237566"/>
			<content type="html"><![CDATA[<p>Don&#039;t worry, it&#039;ll be just as easy. Each controller has three bytes of memory defined as labels; NewButtons, OldButtons &amp; JustPressed for controller 1 and NewButtons2, OldButtons2 &amp; JustPressed2 for controller 2. Each controller is done the same way, however, so I&#039;ll explain it for a single controller first.</p><div class="codebox"><pre><code>NewButtons = $41
OldButtons = $42
JustPressed = $43
NewButtons2 = $46
OldButtons2 = $47
JustPressed2 = $48</code></pre></div><p>The very first thing he does in the controller_test routine is to copy NewButtons over to OldButtons. This happens each time at the very start of the routine - before polling for new values from the controller - because OldButtons represents the buttons pressed last time the routine was checked.</p><div class="codebox"><pre><code>controller_test:

        LDA NewButtons
    STA OldButtons</code></pre></div><br /><p>Next, he polls the first controller 8 times to get each serial bit and stores all 8 bits as a single byte in NewButtons. He does the same for the second controller and calls it &quot;NewButtons2&quot;. (This is what my example above shows; I poll each controller 8 times and store those values in memory locations labeled con1Buttons, con2Buttons, con3Buttons, and con4Buttons.)</p><div class="codebox"><pre><code>ConLoop:
    LDA $4016
    LSR
    ROR NewButtons
        INX
        CPX #$08
        bne ConLoop</code></pre></div><p>He then takes the values from OldButtons, inverts them, and does a logical AND operation with NewButtons. This produces a value - stored at JustPressed - that shows only buttons that have been pressed since the last time the routine was run.</p><div class="codebox"><pre><code>    LDA OldButtons
    EOR #$FF
    AND NewButtons
    STA JustPressed</code></pre></div><p>Finally, it applies a bitmask to this JustPressed&nbsp; value and checks each bit individually to see if the corresponding button has been pressed. If it has been pressed then execution will fall through to the &quot;do stuff here&quot; area, otherwise it will jump to the next check.</p><div class="codebox"><pre><code>CheckRight:
    LDA #%10000000
    AND JustPressed
    BEQ CheckDown

           ; Do stuff here

CheckDown;</code></pre></div><p>If you look at the code and compare the code for the first and second controllers you&#039;ll realize it&#039;s identical. So, to adding polling for 2 more controllers you just need to duplicate all that twice more. Obviously, you&#039;ll need to define 6 more bytes in memory, for example:</p><div class="codebox"><pre><code>NewButtons3 = $58
OldButtons3 = $58
JustPressed3 = $5a
NewButtons4 = $5b
OldButtons4 = $5c
JustPressed4 = $5d</code></pre></div><p>And you&#039;ll need to initialize each OldButtonX at the start of the controller_test routine:</p><div class="codebox"><pre><code>controller_test:

        LDA NewButtons
    STA OldButtons

        LDA NewButtons2
    STA OldButtons2

        LDA NewButtons3
    STA OldButtons3

        LDA NewButtons4
    STA OldButtons4</code></pre></div><p>Etc, etc.</p>]]></content>
			<author>
				<name><![CDATA[jefftheworld]]></name>
				<uri>https://chipmusic.org/jefftheworld</uri>
			</author>
			<updated>2015-12-14T23:00:03Z</updated>
			<id>https://chipmusic.org/forums/post/237566/#p237566</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237558/#p237558"/>
			<content type="html"><![CDATA[<p>The thing is, No Carrier&#039;s code is pretty straightforward here, and I can understand what it&#039;s doing.&nbsp; &nbsp;I&#039;m not sure how to make #3 and #4 this simple.</p><p>;&nbsp; &nbsp; &nbsp; &nbsp;---------------------------------------------------- controller #2</p><p>CheckSelect2:<br />&nbsp; &nbsp; LDA #%00000100<br />&nbsp; &nbsp; AND JustPressed2<br />&nbsp; &nbsp; BEQ CheckStart2</p><p>&nbsp; &nbsp; &nbsp; &nbsp; lda flash&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; toggles flashing background color #0<br />&nbsp; &nbsp; &nbsp; &nbsp; eor #$01<br />&nbsp; &nbsp; &nbsp; &nbsp; sta flash</p><p>CheckStart2:<br />&nbsp; &nbsp; LDA #%00001000<br />&nbsp; &nbsp; AND NewButtons2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; notice this is NewButtons2<br />&nbsp; &nbsp; &nbsp; &nbsp; BEQ NoPause</p><p>&nbsp; &nbsp; &nbsp; &nbsp; lda #1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; if start is held, pause everything<br />&nbsp; &nbsp; &nbsp; &nbsp; sta pause<br />&nbsp; &nbsp; &nbsp; &nbsp; jmp CheckLeft2</p><p>NoPause:<br />&nbsp; &nbsp; &nbsp; &nbsp; lda #0<br />&nbsp; &nbsp; &nbsp; &nbsp; sta pause</p><p>CheckLeft2:<br />&nbsp; &nbsp; LDA #%01000000<br />&nbsp; &nbsp; AND JustPressed2<br />&nbsp; &nbsp; BEQ CheckRight2</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ; DO SOMETHING HERE</p><p>CheckRight2:<br />&nbsp; &nbsp; LDA #%10000000<br />&nbsp; &nbsp; AND JustPressed2<br />&nbsp; &nbsp; BEQ CheckDown2</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ; DO SOMETHING HERE, TOO</p><p>CheckDown2:<br />&nbsp; &nbsp; LDA #%00100000&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; changes the screen / NAM &amp; CHR bank<br />&nbsp; &nbsp; AND JustPressed2<br />&nbsp; &nbsp; BEQ CheckUp2</p><p>&nbsp; &nbsp; DEC ScreenNumber&nbsp; &nbsp; &nbsp; &nbsp; ; decrement screen number here<br />&nbsp; &nbsp; &nbsp; &nbsp; LDA ScreenNumber<br />&nbsp; &nbsp; &nbsp; &nbsp; BPL CheckUp2<br />&nbsp; &nbsp; LDA #7&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; equal to total # of screens, starting from 0<br />&nbsp; &nbsp; STA ScreenNumber</p><p>CheckUp2:<br />&nbsp; &nbsp; LDA #%00010000&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; changes the screen / NAM &amp; CHR bank<br />&nbsp; &nbsp; AND JustPressed2<br />&nbsp; &nbsp; BEQ CheckB2</p><p>&nbsp; &nbsp; INC ScreenNumber&nbsp; &nbsp; &nbsp; &nbsp; ; increment screen number here<br />&nbsp; &nbsp; &nbsp; &nbsp; LDA ScreenNumber<br />&nbsp; &nbsp; CMP #8&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; equal to total # of screens +1, starting from 0<br />&nbsp; &nbsp; BNE CheckB2<br />&nbsp; &nbsp; LDA #0<br />&nbsp; &nbsp; STA ScreenNumber</p>]]></content>
			<author>
				<name><![CDATA[slowflood]]></name>
				<uri>https://chipmusic.org/slowflood</uri>
			</author>
			<updated>2015-12-14T22:01:01Z</updated>
			<id>https://chipmusic.org/forums/post/237558/#p237558</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237556/#p237556"/>
			<content type="html"><![CDATA[<p>Yeah, it&#039;s quite simple:</p><p><a href="http://wiki.nesdev.com/w/index.php/Four_Score" target="_blank">http://wiki.nesdev.com/w/index.php/Four_Score</a></p><p>Just a bunch of reads from $4016 and $4017. That page even shows you how to build your own Four Score hardware.</p><p>In this case, you&#039;d need to do something similar to this:</p><div class="codebox"><pre><code>        LDX #$00
ReadCon1:
    LDA $4016
    LSR
    ROR con1Buttons
        INX
        CPX #$08
        bne ReadCon1

        LDX #$00
ReadCon3:
    LDA $4016
    LSR
    ROR con3Buttons
        INX
        CPX #$08
        bne ReadCon3

        LDX #$00
ReadCon2:
    LDA $4017
    LSR
    ROR con2Buttons
        INX
        CPX #$08
        bne ReadCon4

        LDX #$00
ReadCon4:
    LDA $4017
    LSR
    ROR con4Buttons
        INX
        CPX #$08
        bne ReadCon4</code></pre></div>]]></content>
			<author>
				<name><![CDATA[jefftheworld]]></name>
				<uri>https://chipmusic.org/jefftheworld</uri>
			</author>
			<updated>2015-12-14T20:40:39Z</updated>
			<id>https://chipmusic.org/forums/post/237556/#p237556</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[glitchNES code hacking - asm mod to support multitap/four score]]></title>
			<link rel="alternate" href="https://chipmusic.org/forums/post/237554/#p237554"/>
			<content type="html"><![CDATA[<p>Hello,</p><p>I&#039;ve been having some fun adding new features to glitchNES and customizing the .asm code.&nbsp; &nbsp;However, I have run out of buttons.&nbsp; &nbsp;Is there an easy way to have it support the multitap/four score adapter and plug it into the code, so that I have more options to play with?</p><p>I&#039;m hoping it&#039;s as simple as the code for controllers 1 and 2 are, but somehow I have my doubts and fears about such simplicity.</p><p>Also, since it&#039;s easy enough to swap button functions for controller 1 and 2, what should I assign the turbo buttons on the nes advantage to for maximum carnage?</p><p>Any ideas/thoughts on this?</p>]]></content>
			<author>
				<name><![CDATA[slowflood]]></name>
				<uri>https://chipmusic.org/slowflood</uri>
			</author>
			<updated>2015-12-14T20:27:07Z</updated>
			<id>https://chipmusic.org/forums/post/237554/#p237554</id>
		</entry>
</feed>
