Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DeletePlayer2Input()
- {
- global $linker,$space;
- // Frees RAM addresses F4,F6 (new buttons player2),
- // F2,F8 (current buttons player2)
- /* Change NMI_UpdateInput (C453-C4AE, 92 bytes) to to:
- * ldx #1 ;2
- * jsr @read ;12+189
- * dex ;2
- * jsr @read ;12+189
- * lda $00 ;3
- * cmp $01 ;3
- * bne @blank (+14) ;2
- * tay ;2
- * eor $F1 (Input_CurrentJoyButtonsOrig) ;3
- * and $00 ;3
- * sta $F5 (Input_NewJoyButtonsWork) ;3
- * sta $F3 (Input_NewJoyButtonsOrig) ;3
- * sty $F7 (Input_CurrentJoyButtonsWork) ;3
- * sty $F1 (Input_CurrentJoyButtonsOrig) ;3
- * rts
- * @blank:
- * stx $F5 ;3
- * stx $F3 ;3
- * nop;nop;nop;php;plp ;13
- * rts
- * @read:
- * ldy #1 ;2
- * sty $4016 ;4
- * dey ;2
- * sty $4016 ;4
- * ldy #8 ;2
- * @loop:
- * lda $4016 ;4
- * sta $04 ;3
- * lsr a ;2
- * ora $04 ;3
- * lsr a ;2
- * rol $00,x ;3
- * dey ;2
- * bne @loop ;3
- * ; (4+3+2+3+2+3+2+3)*8-1 = 175
- * rts ; @read cost: 189 cycles + JSR+RTS
- *
- * Cost (normally): 2+12+189+2+12+189+3+3+2+2+6*3 = 434 cycles
- * Cost (if DMA error): 2+12+189+2+12+189+3+3+3+6+13 = 434 cycles
- */
- $location = 0x1C453;
- $space[$location] = 0x1C4AF - 0x1C453;
- $b = new Blob("NMI_UpdateInput",
- "\xA2\x01");
- $b->AppendCallPointerTo("NMI_ReadOneJoypad");
- $b->AppendRawData(
- "\xCA");
- $b->AppendCallPointerTo("NMI_ReadOneJoypad");
- $b->AppendRawData(
- "\xA5\x00\xC5\x01\xD0\x0E".
- "\xA8\x45\xF1\x25\x00\x85\xF5\x85\xF3\x84\xF7\x84\xF1\x60".
- "\x86\xF5\x86\xF3\xEA\xEA\xEA\x08\x28\x60");
- $b->AddPublicHere("NMI_ReadOneJoypad");
- $b->AppendRawData(
- "\xA0\x01\x8C\x16\x40\x88\x8C\x16\x40".
- "\xA0\x08".
- "\xAD\x16\x40\x85\x04\x4A\x05\x04\x4A\x36\x00".
- "\x88\xD0\xF2".
- "\x60");
- $linker->AddBlobTakeSpace($space, $b, $location);
- /* Change _func_1C5EF, which clears memory from 300..3C5,
- * to a more optimal implementation:
- * ldy #$C6
- * lda #0
- * @loop: dey
- * sta $0300,y
- * bne @loop
- * rts
- * (Also erases a couple of unused functions)
- */
- $location = 0x1C5EF;
- $space[$location] = 0xC615-0xC5EF;
- $b = new Blob("ReplaceC5EF",
- "\xA0\xC6\xA9\x00".
- "\x88\x99\x00\x03".
- "\xD0\xFA\x60");
- $linker->AddBlobTakeSpace($space, $b, $location);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement