News: 11 March 2016 - Forum Rules

Author Topic: Bankswitch code help for Metal Gear or other games  (Read 1295 times)

Dracula X

  • Full Member
  • ***
  • Posts: 154
    • View Profile
    • My YouTube Page for ROM hacking
Bankswitch code help for Metal Gear or other games
« on: July 18, 2021, 05:18:46 pm »
I'm trying to swap out this code to $8000 in bank 08:

Code: [Select]
Lbl_fe00:
.byte $10,$00,$00,$00,$50,$00,$10,$50,$50,$04,$14,$00,$50,$00,$04,$00
.byte $00,$00,$00,$00,$00,$04,$00,$00,$04,$04,$00,$04,$04,$04,$00,$04
.byte $00,$00,$00,$00,$04,$00,$00,$00,$25,$21,$21,$21,$25,$45,$45,$21
.byte $25,$21,$21,$21,$21,$21,$00,$00,$04,$00,$04,$00,$14,$10,$10,$14
.byte $10,$10,$10,$10,$10,$10,$50,$00,$04,$50,$50,$50,$00,$50,$50,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$21,$25,$21,$21,$25,$00,$04,$50
.byte $04,$04,$04,$00,$04,$04,$10,$10,$10,$50,$50,$50,$00,$00,$00,$04
.byte $04,$00,$04,$04,$00,$10,$21,$00,$10,$10,$31,$00,$00,$00,$31,$31
.byte $31,$31,$35,$31,$35,$31,$31,$31,$31,$35,$31,$35,$35,$35,$31,$35
.byte $31,$31,$31,$31,$31,$31,$35,$35,$31,$35,$35,$00,$31,$31,$31,$31
.byte $35,$31,$31,$31,$31,$31,$31,$35,$35,$35,$31,$35,$31,$31,$31,$31
.byte $35,$31,$35,$31,$31,$31,$35,$35,$35,$35,$31,$31,$31,$35,$35,$31
.byte $31,$31,$31,$31,$31,$31,$31,$31,$35,$31,$31,$31,$00,$35,$31,$35
.byte $14,$14,$14,$50,$50,$31,$31,$31,$31,$31,$31,$31,$00,$00,$10,$10
.byte $10,$10,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$45,$45
.byte $45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$45,$00

But I think I need this whole code to do this:
Code: [Select]
Lbl_c989:
ldy $30
lda Lbl_fe00,y
and #$03
clc
adc #$02
tay
lda Lbl_ffd0,y
tay
jsr Lbl_c94c
ldy $30
lda Lbl_fd00,y
lsr a
lsr a
lsr a
lsr a
lsr a
lsr a
and #$03
asl a
tax
lda Lbl_8001,x
sta $80
lda Lbl_8002,x
sta $81
rts

and this:
Code: [Select]
Lbl_ca03:
ldy $30
lda Lbl_fe00,y
lsr a
lsr a
and #$03
clc
adc #$00
tay
lda Lbl_ffd0,y
tay
jsr Lbl_c94c
ldy $30
lda Lbl_fd00,y
and #$1f
asl a
tax
rts

So is there's another way to swap out that type of code to another bank?
Code: [Select]
lda banknumberThat part is not working.

I just want to swap out the $fe00 code to another bank.
Back to Thunder Force II hacking again.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 719
  • I am the baldest romhacker
    • View Profile
Re: Bankswitch code help for Metal Gear or other games
« Reply #1 on: July 19, 2021, 07:32:58 am »
I don't see how your code examples have anything to do with bank swapping.

Dracula X

  • Full Member
  • ***
  • Posts: 154
    • View Profile
    • My YouTube Page for ROM hacking
Re: Bankswitch code help for Metal Gear or other games
« Reply #2 on: August 03, 2021, 09:44:22 pm »
Metal Gear:
Now I'm trying to add this code in bank 9 for testing:

Code: [Select]
__f365: Bank_07     
jsr Bank_09
jmp __f365_bank9

and new location for the code:
Code: [Select]
.base $8000

__f365_bank9:
    lda $12            ; $f365: a5 12     
            and #$03           ; $f367: 29 03     
            cmp #$02           ; $f369: c9 02     
            beq __f36e         ; $f36b: f0 01     
            rts                ; $f36d: 60       

;-------------------------------------------------------------------------------
__f36e:     ldy #$00           ; $f36e: a0 00     
__f370:     lda $89aa,y        ; $f370: b9 aa 89 
            sta $0740,y        ; $f373: 99 40 07 
            iny                ; $f376: c8       
            cpy #$03           ; $f377: c0 03     
            bne __f370         ; $f379: d0 f5     
            lda $6d            ; $f37b: a5 6d     
            lsr                ; $f37d: 4a       
            tax                ; $f37e: aa       
            inx                ; $f37f: e8       
            lda #$a1           ; $f380: a9 a1     
__f382:     dex                ; $f382: ca       
            beq __f38b         ; $f383: f0 06     
            sta $0740,y        ; $f385: 99 40 07 
            iny                ; $f388: c8       
            bne __f382         ; $f389: d0 f7     
__f38b:     lda $6d            ; $f38b: a5 6d     
            lsr                ; $f38d: 4a       
            bcc __f396         ; $f38e: 90 06     
            lda #$a0           ; $f390: a9 a0     
            sta $0740,y        ; $f392: 99 40 07 
            iny                ; $f395: c8       
__f396:     lda #$00           ; $f396: a9 00     
__f398:     sta $0740,y        ; $f398: 99 40 07 
            iny                ; $f39b: c8       
            cpy #$0c           ; $f39c: c0 0c     
            bne __f398         ; $f39e: d0 f8     
            lda #$ff           ; $f3a0: a9 ff     
            sta $0740,y        ; $f3a2: 99 40 07 
            iny                ; $f3a5: c8       
            ldx #$00           ; $f3a6: a2 00     
__f3a8:     lda $89ad,x        ; $f3a8: bd ad 89 
            sta $0740,y        ; $f3ab: 99 40 07 
            iny                ; $f3ae: c8       
            inx                ; $f3af: e8       
            cpx #$03           ; $f3b0: e0 03     
            bne __f3a8         ; $f3b2: d0 f4     
            ldx $6e            ; $f3b4: a6 6e     
            beq __f3d2         ; $f3b6: f0 1a     
            cpx #$05           ; $f3b8: e0 05     
            bcs __f3d3         ; $f3ba: b0 17     
            lda #$7c           ; $f3bc: a9 7c     
__f3be:     sta $0740,y        ; $f3be: 99 40 07 
            iny                ; $f3c1: c8       
            dex                ; $f3c2: ca       
            bne __f3be         ; $f3c3: d0 f9     
            lda #$ff           ; $f3c5: a9 ff     
            sta $0741,y        ; $f3c7: 99 41 07 
            lda #$00           ; $f3ca: a9 00     
            sta $0742,y        ; $f3cc: 99 42 07 
            sta $0740,y        ; $f3cf: 99 40 07 
__f3d2:     rts                ; $f3d2: 60       

;-------------------------------------------------------------------------------
__f3d3:     lda #$04           ; $f3d3: a9 04     
            sta $6e            ; $f3d5: 85 6e     
            rts                ; $f3d7: 60
I think this code shows the life bar.

When I tried this code in a new location, the life bar is not showing up. Is something wrong with the code? It looks fine to me.

I'm using a compact mapper.

Back to Thunder Force II hacking again.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 719
  • I am the baldest romhacker
    • View Profile
Re: Bankswitch code help for Metal Gear or other games
« Reply #3 on: August 03, 2021, 10:50:44 pm »
I guess debugging is out of the question.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7213
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Bankswitch code help for Metal Gear or other games
« Reply #4 on: August 04, 2021, 12:23:23 am »
We don't know what the purpose of unlabeled instructions do, and people probably aren't going to sit and find out what every line does first in order to help you.
You have to put as much meaningful comments (telling us the hex codes isn't helpful information) as you can in your code before you'll be likely to get an answer.
"My watch says 30 chickens" Google, 2018