Users browsing this thread: 1 Guest(s)
Random battle theme

#31
Posts: 3,856
Threads: 271
Thanks Received: 782
Thanks Given: 444
Joined: Oct 2011
Reputation: 63
Status
Tissue-aware
Note that if you add a lot you can simplify the code by having a table of $37 bytes with song IDs ($FF for current music) and load that single byte instead of a lot of CMPs and branches.
  Find
Quote  

#32
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(10-17-2018, 10:48 PM)madsiur Wrote: Note that if you add a lot you can simplify the code by having a table of $37 bytes with song IDs ($FF for current music) and load that single byte instead of a lot of CMPs and branches.


So far I've added Kefka's Interior, the Magitek Facility, and the Mountains - but I think I am going to stop there.  I want the default music to play for the other locations!
  Find
Quote  

#33
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(10-13-2018, 02:33 PM)Lightning Wrote:
(10-13-2018, 02:27 PM)madsiur Wrote:
(10-13-2018, 02:15 PM)Lightning Wrote: Well, the reason I have not expanded the ROM is out of fear it will no longer work on real hardware.

Well there are a bunch of 32Mb ROMs on the SNES as well as even 48Mb ROMs.

(10-13-2018, 02:15 PM)Lightning Wrote: Also, I just now read your final post in this thread (before I bumped it) about the world music not continuing where it left off after a battle.  This is actually a pretty bad side effect, so I think I might forget the random battle theme plan.

This is not what my hack is doing. The World map music not continuing where it stopped has to do with using one of the two "current music" bytes while the original post branch based on the battle music byte. Adding a branch based on the WoR event bit would be possible.

I see.  Well, I might consider expanding my ROM and see if it works on real hardware (I can experiment a bit).  It does bring up some questions though, like if the original save games will work, and if FF3USME will still load up.

Hey Madsiur, can this "issue" be fixed in my hack?  I know we talked about this before, but every time a battle finishes, the world music starts over from scratch. This is actually quite annoying since you barely ever get to hear music in its entirety anymore...
  Find
Quote  

#34
Posts: 3,856
Threads: 271
Thanks Received: 782
Thanks Given: 444
Joined: Oct 2011
Reputation: 63
Status
Tissue-aware
Sorry for the late reply. I think you need to relocate and expand this table and change the LDA in the following code. You new list must end with $FF so there is no infinite loop (well any value from $80 to $FF would do in fact).

Code:
Data: Song indexes which need the current song to be paused then resumed - Evil Peer
C5/06F9:    24                             (Battle, from C5/062B)
C5/06FA:    38                             (Nighty Night)
C5/06FB:    14                             (Decisive battle)
C5/06FC:    33                             (Fierce battle)
C5/06FD:    FF                             (Silence?)

Code:
C5/062B:    BFF906C5    LDA $C506F9,X  (Song indexes which need the current song to be paused then resumed)
C5/062F:    300D        BMI $063E      (branch if song is not on list?)
C5/0631:    C501        CMP $01
C5/0633:    F003        BEQ $0638      (branch if song on list matched?)
C5/0635:    E8          INX
C5/0636:    80F3        BRA $062B      (loop for all songs?)
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • Lightning (12-11-2018)

#35
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(12-11-2018, 03:52 PM)madsiur Wrote: Sorry for the late reply. I think you need to relocate and expand this table and change the LDA in the following code. You new list must end with $FF so there is no infinite loop (well any value from $80 to $FF would do in fact).

Code:
Data: Song indexes which need the current song to be paused then resumed - Evil Peer
C5/06F9:    24                             (Battle, from C5/062B)
C5/06FA:    38                             (Nighty Night)
C5/06FB:    14                             (Decisive battle)
C5/06FC:    33                             (Fierce battle)
C5/06FD:    FF                             (Silence?)

Code:
C5/062B:    BFF906C5    LDA $C506F9,X  (Song indexes which need the current song to be paused then resumed)
C5/062F:    300D        BMI $063E      (branch if song is not on list?)
C5/0631:    C501        CMP $01
C5/0633:    F003        BEQ $0638      (branch if song on list matched?)
C5/0635:    E8          INX
C5/0636:    80F3        BRA $062B      (loop for all songs?)

Thanks for the reply, and don't worry about the delay - I'm sure we are all busy for the Christmas season! 

Anyway, I looked at your suggestion briefly today, but I'm a bit confused.  I understand you are suggesting I move the table listed above somewhere else in the code (and make a pointer to it I imagine), but it seems like the the code you listed above already ends in FF at C506Fd.  I must be reading your suggestion wrong.  Can you give an example of what to change so I can continue from there?

Edit: Err, wait - does your code above already do all the work? I am still rubbish at ASM editing.
  Find
Quote  

#36
Posts: 3,856
Threads: 271
Thanks Received: 782
Thanks Given: 444
Joined: Oct 2011
Reputation: 63
Status
Tissue-aware
You need to move the table in another bank, add your new song IDs, end it with $FF and change the LDA at $C5062B so it load the values in your new table.
  Find
Quote  

#37
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(12-11-2018, 06:23 PM)madsiur Wrote: You need to move the table in another bank, add your new song IDs, end it with $FF and change the LDA at $C5062B so it load the values in your new table.

Ah, I figured it out now.  That was actually quite easy to accomplish; thanks!
  Find
Quote  
[-] The following 1 user says Thank You to Lightning for this post:
  • madsiur (12-12-2018)

#38
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(10-17-2018, 10:48 PM)madsiur Wrote: Note that if you add a lot you can simplify the code by having a table of $37 bytes with song IDs ($FF for current music) and load that single byte instead of a lot of CMPs and branches.

Hey Madsiur, I think we have to use your suggestion here, because I am now having an error when I compile the code (I think there are too many backgrounds used now).  Can you help me simplify the code as you suggested?  Here is how my code currently looks:

Code:
hirom
header

org $C2BDB7
JSR free_space
NOP

org $C264C9          ; change to free space
free_space:
LDA $C2BF3B,X
CMP #$24             ; check if battle song
BNE exit             ; branch if not
LDA $11E2            ; load battle background byte
AND #$3F             ; isolate battle background
BEQ is_wor_grass
CMP #$01
BEQ is_wob_forest
CMP #$02
BEQ is_wob_desert
CMP #$03
BEQ is_wor_forest
CMP #$05
BEQ is_wob_grass
CMP #$2F
BEQ is_wor_desert
CMP #$16
BEQ is_kefka1
CMP #$28
BEQ is_kefka2
CMP #$15
BEQ is_floating_island
CMP #$0B
BEQ is_mountain
CMP #$0C
BEQ is_mountain
CMP #$1D
BEQ is_magitek
CMP #$1B
BEQ is_research
CMP #$14
BEQ is_kefka_interior
CMP #$27
BEQ is_castle
CMP #$1A
BEQ is_castle
CMP #$1C
BEQ is_colosseum
LDA #$24             ; default battle song ID
BRA exit
is_wob_grass:
LDA #$55             ; song ID (WOR Grass) 55
BRA exit
is_wob_forest:
LDA #$57             ; song ID (WOR Forest) 57
BRA exit
is_wob_desert:
LDA #$66             ; song ID (W O B Desert)
BRA exit
is_wor_forest:
LDA #$5B             ; song ID (W O B Forest)
BRA exit
is_wor_grass:
LDA #$56             ; song ID (W O B Grass) 56
BRA exit
is_wor_desert:
LDA #$5D             ; song ID (WOR Desert) 5D
BRA exit
is_kefka1:
LDA #$59             ; song ID (Kefka Tower 1)
BRA exit
is_kefka2:
LDA #$59             ; song ID (Kefka Tower 2)
BRA exit
is_floating_island:
LDA #$62             ; song ID (Floating Continent)
BRA exit
is_mountain:
LDA #$61             ; song ID (Mountain outside and inside)
BRA exit
is_magitek:
LDA #$64             ; song ID (Magitek Generic)
BRA exit
is_research:
LDA #$5F             ; song ID (Magitek Tube Research)
BRA exit
is_kefka_interior:
LDA #$58             ; song ID (Kefka Tower Interior)
BRA exit
is_castle:
LDA #$6A             ; song ID (Ancient Castle)
BRA exit
is_colosseum:
LDA #$5C             ; song ID (Colosseum)
exit:
RTS
  Find
Quote  

#39
Posts: 3,856
Threads: 271
Thanks Received: 782
Thanks Given: 444
Joined: Oct 2011
Reputation: 63
Status
Tissue-aware
You have to do something like this:

Code:
hirom
header

org $C2BDB7
JSR free_space
NOP

org $C264C9          ; change to free space
free_space:
TDC
LDA $C2BF3B,X        ; load formation song
CMP #$24             ; check if battle song
BNE .exit            ; branch if not
LDA $11E2            ; load battle background byte
AND #$3F             ; isolate battle background
REP #$20
TAX                  ; set BG as index
SEP #$20
LDA table,X          ; load BG song ID
.exit:
RTS

; your $37 song IDs
; this table can be anywhere in the ROM:
; org $F35000 (uncomment and change to move table elsewhere)
table:
00    ; song ID for 1st background
00    ; song ID for 2nd background
00    ; song ID for 3rd background
00    ; song ID for 4th background
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • Lightning (12-14-2018)

#40
Posts: 277
Threads: 19
Thanks Received: 13
Thanks Given: 48
Joined: Dec 2017
Reputation: 2
Status
None
(12-11-2018, 06:23 PM)madsiur Wrote: You have to do something like this:


I'm getting a bunch of errors when I compile (I still have almost no understanding of ASM code, so forgive me if these problems are obvious):


[Image: sG4dgZt.png]


This is the code I have so far:

Code:
hirom
header

org $C2BDB7
JSR free_space
NOP

org $C264C9          ; change to free space
free_space:
TDC
LDA $C2BF3B,X        ; load formation song
CMP #$24             ; check if battle song
BNE .exit            ; branch if not
LDA $11E2            ; load battle background byte
AND #$3F             ; isolate battle background
REP #$20
TAX                  ; set BG as index
SEP #$20
LDA table,X          ; load BG song ID
.exit:
RTS

; your $37 song IDs
; this table can be anywhere in the ROM:
org $F15550 ;(uncomment and change to move table elsewhere)
table:
56    ; W O B Grass
57    ; WOR Forest
66    ; W O B Desert
00    ; song ID for 4th background
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite