Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function Add_delete_p2_input($needed = true)
- {
- if(!$needed) return;
- static $added;
- if(isset($added)) return;
- $added = true;
- //
- for($part = 1; $part <= 2; ++$part)
- LoadAsmBlobWithMapAndLink(sprintf("bin/delete_p2_input_part$part.bin"));
- }
- ------------------------
- .include "macros.inc"
- .include "defines.inc"
- .code
- ; 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
- next_PART
- .if PART=::CURPART
- LINK_FREE_SPACE $1C453, ($1C4AF-$1C453)
- LINK_IN_ADDR $1C453
- PUBLIC_LABEL NMI_UpdateInput
- ldx #1
- JSRF NMI_ReadOneJoypad
- dex
- JSRF NMI_ReadOneJoypad
- lda $00
- cmp $01
- bne @blank
- tay
- eor $F1 ;Input_CurrentJoyButtonsOrig
- and $00
- sta $F5 ;Input_NewJoyButtonsWork
- sta $F3 ;Input_NewJoyButtonsOrig
- sty $F7 ;Input_CurrentJoyButtonsWork
- sty $F1 ;Input_CurrentJoyButtonsOrig
- rts
- @blank: stx $F5
- stx $F3
- nop
- nop
- nop
- php
- plp
- rts
- PUBLIC_LABEL NMI_ReadOneJoypad
- ldy #1
- sty $4016
- dey
- sty $4016
- ldy #8
- @loop: lda $4016
- sta $04
- lsr
- ora $04
- lsr
- rol $00,x
- dey
- bne @loop
- rts
- .endif
- next_PART
- .if PART=::CURPART
- ; 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)
- LINK_FREE_SPACE $1C5EF, ($C615-$C5EF)
- LINK_IN_ADDR $1C5EF
- PUBLIC_LABEL ReplaceC5EF
- ldy #$C6
- lda #0
- @loop: dey
- sta $0300,y
- bne @loop
- rts
- .endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement