Users browsing this thread: 1 Guest(s)
Random battle theme
12-14-2018, 03:52 AM
(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
« Next Oldest | Next Newest »
|
||||
Users browsing this thread: 1 Guest(s)