skip to main content

Jixun's Blog 填坑还是开坑,这是个好问题。

Final Fantasy I & II (GBA, USA) - Infinity Gil

Because the game is too difficult at the early stage, I decided to create a patch that allows me to gain an unfair amount of gold.

So instead of taking money away, it will give you the same amount of money.

Tested against Japanese version of the game - may or may not work with the US/EU version.

; ------------------------------------------------------------------------------
; GAME       : Final Fantasy I & II
; PLATFORM   : GameBoy Advance
; REGION     : USA
; PATCH TYPE : Infinity Gil
; NOTES      : Required to have some gold to begin with
; ------------------------------------------------------------------------------
; AUTHOR     : Jixun
; URL        : https://jixun.uk/
; ------------------------------------------------------------------------------

.gba

.open "1805 - Final Fantasy I & II - Dawn of Souls (USA).gba", "1805 - Final Fantasy I & II - Dawn of Souls (USA) (Inf. Gil).gba", 0x08000000

; ------------------------------------------------------------------------------
; Final Fantasy I - Inf. Gil
; ------------------------------------------------------------------------------
.thumb
; Routine to cost Gil
; 0807F100:  B500     	push {lr}
; 0807F102:  4B05     	ldr r3, [$0807F118]
; 0807F104:  18C2     	add r2, r0, r3
; 0807F106:  6810     	ldr r0, [r2, #0]
; 0807F108:  1A40     	sub r0, r0, r1
; 0807F10A:  2800     	cmp r0, #0
; 0807F10C:  DA00     	bge $0807F110
; 0807F10E:  2000     	mov r0, #0
; 0807F110:  6010     	str r0, [r2, #0]
; 0807F112:  BC01     	pop {r0}
; 0807F114:  4700     	bx r0
.org 0x0807F108
  add r0, r0, r1

; ------------------------------------------------------------------------------
; Final Fantasy II - Inf. Gil
; ------------------------------------------------------------------------------
.thumb
; Calculate Cost
; 0817BCAC:  4A14     	ldr r2, [$0817BD00]
; 0817BCAE:  18BB     	add r3, r7, r2
; 0817BCB0:  781A     	ldrb r2, [r3, #0]
; 0817BCB2:  4C14     	ldr r4, [$0817BD04]
; 0817BCB4:  1938     	add r0, r7, r4
; 0817BCB6:  8800     	ldrh r0, [r0, #0]
; 0817BCB8:  4342     	mul r2, r0          ; r2 = [r7 + $4BE7] * [r7 + $4BE4]
; 0817BCBA:  6808     	ldr r0, [r1, #0]
; 0817BCBC:  1A80     	sub r0, r0, r2
; 0817BCBE:  6008     	str r0, [r1, #0]
.org 0x0807F108
  add r0, r0, r2

; ------------------------------------------------------------------------------
.Close
; ------------------------------------------------------------------------------

Japanese version (or Chinese translated version) of the game will use a different file:

; ------------------------------------------------------------------------------
; GAME       : Final Fantasy I & II
; PLATFORM   : GameBoy Advance
; REGION     : Japan
; PATCH TYPE : Infinity Gil
; NOTES      : Required to have some gold to begin with
; ------------------------------------------------------------------------------
; AUTHOR     : Jixun
; URL        : https://jixun.uk/
; ------------------------------------------------------------------------------

.gba

.open "FF1+2.gba", "FF1+2_GOLD.gba", 0x08000000

; ------------------------------------------------------------------------------
; FF1 Cost Routine
; ------------------------------------------------------------------------------
.org 0x0807dd9c
.thumb
  FN_FF1_COST_GOLD_ORIG:
    LDR r3, =FN_FF1_COST_GOLD + 1
    BX r3          ; jmp_thumb FN_FF1_COST_GOLD
    .pool

; ------------------------------------------------------------------------------
; FF2 Cost Routine
; ------------------------------------------------------------------------------
; 08178f7c  4a13 ldr r2, [$08178fcc] (=$00004bdf)
; 08178f7e  18bb add r3, r7, r2
; 08178f80  781a ldrb r2, [r3, #0x0]        ; r2 = [r7 + $4bdf]
.org 0x08178f82
.thumb
  FN_FF2_COST_GOLD_ORIG:
    push {r2}        ; Backup r2
    LDR r2, =FN_FF2_COST_GOLD + 1
    BX r2             ; jmp_thumb FN_FF2_COST_GOLD
    .pool

.org 0x08178f8E
  FN_FF2_CONTINUE:

; 08178F7C:  4A13       ldr r2, [$08178FCC]   ; $4bdf
; 08178F7E:  18BB       add r3, r7, r2
; 08178F80:  781A       ldrb r2, [r3, #0]

; <---- Jump to our own code.
; 08178F82:  4C13       ldr r4, [$08178FD0]   ; $4bdc
; 08178F84:  1938       add r0, r7, r4
; 08178F86:  8800       ldrh r0, [r0, #0]
; 08178F88:  4342       mul r2, r0            ; r2 = [r7 + $4bdc]*[r7 + $4bdf]

; 08178F8A:  6808       ldr r0, [r1, #0]
; 08178F8C:  1A80       sub r0, r0, r2

; <---- When we finish, jump back here.
; 08178F8E:  6008       str r0, [r1, #0]      ; [r1] = [r1] - r2


; ------------------------------------------------------------------------------
; Find an empty space to put our code.
; ------------------------------------------------------------------------------
.org 0x0881a640
; ------------------------------------------------------------------------------
; FF1
; ------------------------------------------------------------------------------
.thumb
  FN_FF1_COST_GOLD:
    ; r0: BASE_ADDR
    ; r1: COST
    push {lr}               ; push [ret addr]

    ldr r3, =$0b84          ; r3 = GOLD_OFFSET
    add r2, r0, r3          ; r2 = 02001ec8 + $0b84 = 2002A4C[GOLD]
    ldr r0, [r2, #0x0]
    add r0, r0, r1          ; r0 = [r2] + r1
    ldr r3, =#999999
    cmp r0, r3              ; if r0 > 999999
  ble FF1_SKIP_RESET_MONEY  ;   goto FF1_SKIP_RESET_MONEY
    mov r0, r3              ; r0 = [DAT_SOME_MONEY]
  FF1_SKIP_RESET_MONEY:
    str r0, [r2, $0]        ; [r2] = r0

    pop {r0}
    bx r0                   ; ret
; ------------------------------------------------------------------------------
; FF2
; ------------------------------------------------------------------------------
.thumb
  FN_FF2_COST_GOLD:
    pop {r2}                ; Restore r2
; 08178F82:  4C13       ldr r4, [$08178FD0]
; 08178F84:  1938       add r0, r7, r4
; 08178F86:  8800       ldrh r0, [r0, #0]
; 08178F88:  4342       mul r2, r0          ; r2 = [r7 + $4bdf] * [r7 + $0b84]
    ldr r4, =$4bdc
    add r0, r7, r4
    ldrh r0, [r0, #0x0]   ; r2: COST
    mul r2, r0            ; r2 = r2 * [r7 + $4bdc]

; 08178F8A:  6808       ldr r0, [r1, #0]
; 08178F8C:  1A80       sub r0, r0, r2      ; 
; 08178F8E:  6008       str r0, [r1, #0]    ; [r1] = [r1] - r2
    ldr r0, [r1, #0]      ; r0 = [r1]
    add r0, r0, r2        ; r0 += r2

    ; Since r2 is written after we jump back, we don't need to backup this value,
		; we'll just use this register for good use.
    ldr r2, =#999999      ; Prevent overflow
    cmp r0, r2
  ble FF2_SKIP_RESET_MONEY
    mov r0, r2
  FF2_SKIP_RESET_MONEY:
    ldr r2, =FN_FF2_CONTINUE + 1
    bx r2
.pool
; ------------------------------------------------------------------------------


; ------------------------------------------------------------------------------
.Close
; ------------------------------------------------------------------------------

IPS Patch Download: Final.Fantasy.I+II.Advanced.(GBA)(J)(C).Inf.Gold.Patch.ips

Creative Commons Licence This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Comments