luascript "Console Mode [lua]" \
 "comm:Coin button is used for pause. In training mode, pause the game and then press start to select character."
run:
-- Start-up --
if (peek(0xFF82E9)==0x00) then
    poke(0x15A39,"            ")
    poke(0x15A5D,"            ")
    poke(0x15A81,"            ")
    poke(0x2B5E,0x07) -- Restore initial value --
    poke(0x2B64,0x0B)
    poke(0xFF2000,0x00)
    p1char=0x00
    p2char=0x04
    if (peek(0xFF8005)>0x00) and (peek(0xFF807E)>0x00) then -- Start button start --
      poke(0xFF2021,0xFF)
      poke(0xFF82E9,0x09) -- Max credit --
    end
end
-- Menu in the Title screen --
if (dpeek(0xFFD43E)==0x82FA) and (peek(0xFF82E9)>0x00) then
    if ((peek(0xFF8087)==0x00) and (peek(0xFF808B)==0x00)) and (peek(0xFF2001)==0xFF) then
      poke(0xFF2001,0x00)
      poke(0xFF2020,0x00) -- Act as music 'stopper' --
    end
    if (peek(0xFF8087)==0x04) or (peek(0xFF808B)==0x04) then
            if peek(0xFF2020)==0x00 then -- Sound effect --
               poke(0x618001,0x00)
               poke(0x618003,0x42)
               poke(0x61801F,0x00)
               poke(0xFF2020,0xFF)
            end
       if (dpeek(0xFF2000)==0x0000) then
         dpoke(0xFF2000,0x01FF)
       elseif (dpeek(0xFF2000)==0x0100) then
         dpoke(0xFF2000,0x02FF)
       elseif (dpeek(0xFF2000)==0x0200) then
         dpoke(0xFF2000,0x03FF)
       elseif (dpeek(0xFF2000)==0x0300) then
         dpoke(0xFF2000,0x00FF)
       end
    end
    if (peek(0xFF8087)==0x08) or (peek(0xFF808B)==0x08) then
            if peek(0xFF2020)==0x00 then -- Sound effect --
               poke(0x618001,0x00)
               poke(0x618003,0x42)
               poke(0x61801F,0x00)
               poke(0xFF2020,0xFF)
            end
       if (dpeek(0xFF2000)==0x0000) then
         dpoke(0xFF2000,0x03FF)
       elseif (dpeek(0xFF2000)==0x0300) then
         dpoke(0xFF2000,0x02FF)
       elseif (dpeek(0xFF2000)==0x0200) then
         dpoke(0xFF2000,0x01FF)
       elseif (dpeek(0xFF2000)==0x0100) then
         dpoke(0xFF2000,0x00FF)
       end
    end
    if (peek(0x90CCD5)~=0x4E) then -- All menu text --
        poke(0xFF8035,0x38)
        poke(0x90C8C9,"S")
        poke(0x90C949,"U")
        poke(0x90C9C9,"P")
        poke(0x90CA49,"E")
        poke(0x90CAC9,"R")
        poke(0x90CB49," ")
        poke(0x90CBC9,"B")
        poke(0x90CC49,"A")
        poke(0x90CCC9,"T")
        poke(0x90CD49,"T")
        poke(0x90CDC9,"L")
        poke(0x90CE49,"E")
        poke(0x90C8CD,"V")
        poke(0x90C94D,"E")
        poke(0x90C9CD,"R")
        poke(0x90CA4D,"S")
        poke(0x90CACD,"U")
        poke(0x90CB4D,"S")
        poke(0x90CBCD," ")
        poke(0x90CC4D,"B")
        poke(0x90CCCD,"A")
        poke(0x90CD4D,"T")
        poke(0x90CDCD,"T")
        poke(0x90CE4D,"L")
        poke(0x90CECD,"E")
        poke(0x90C8D1,"T")
        poke(0x90C951,"R")
        poke(0x90C9D1,"A")
        poke(0x90CA51,"I")
        poke(0x90CAD1,"N")
        poke(0x90CB51,"I")
        poke(0x90CBD1,"N")
        poke(0x90CC51,"G")
        poke(0x90CCD1," ")
        poke(0x90CD51,"M")
        poke(0x90CDD1,"O")
        poke(0x90CE51,"D")
        poke(0x90CED1,"E")
        poke(0x90CA55,"O")
        poke(0x90CAD5,"P")
        poke(0x90CB55,"T")
        poke(0x90CBD5,"I")
        poke(0x90CC55,"O")
        poke(0x90CCD5,"N")
    end
    -- Menu Text --
      if (peek(0xFF2000)==0x00) and (peek(0x90C8CB)~=0x01) then -- Arcade Mode pointer --
         for i=0,0x580,0x80 do
            poke(0x90C8CB+i,0x01)
         end
         for i=0,0x280,0x80 do
            poke(0x90CA57+i,0x00)
         end
         for i=0,0x600,0x80 do
            poke(0x90C8CF+i,0x00)
         end
      elseif (peek(0xFF2000)==0x01) and (peek(0x90C8CF)~=0x01) then -- Versus Mode pointer --
         for i=0,0x600,0x80 do
            poke(0x90C8CF+i,0x01)
         end
         for i=0,0x580,0x80 do
            poke(0x90C8CB+i,0x00)
         end
         for i=0,0x600,0x80 do
            poke(0x90C8D3+i,0x00)
         end
      elseif (peek(0xFF2000)==0x02) and (peek(0x90C8D3)~=0x01) then -- Training Mode pointer --
         for i=0,0x600,0x80 do
            poke(0x90C8D3+i,0x01)
         end
         for i=0,0x600,0x80 do
            poke(0x90C8CF+i,0x00)
         end
         for i=0,0x280,0x80 do
            poke(0x90CA57+i,0x00)
         end
      elseif (peek(0xFF2000)==0x03) and (peek(0x90CA57)~=0x01) then -- Option pointer --
         for i=0,0x280,0x80 do
            poke(0x90CA57+i,0x01)
         end
         for i=0,0x600,0x80 do
            poke(0x90C8D3+i,0x00)
         end
         for i=0,0x580,0x80 do
            poke(0x90C8CB+i,0x00)
         end
      end
    -- Game Start --
    if (peek(0x90CCD5)==0x4E) and ((peek(0x804020)==0xFE) or (peek(0x804020)==0xFD)) and (peek(0xFF2021)==0x00) then
       poke(0x618001,0x00) -- Sound effect --
       poke(0x618003,0x40)
       poke(0x61801F,0x00)
       poke(0xFF2021,0xFF)
    end
    if (peek(0xFF8001)==0x04) and (peek(0x804020)==0xFF) then
       poke(0xFF2021,0x00) -- Act as music 'stopper' --
    end
end
-- Infinity Credits Script --
if (peek(0xFF82E9)>0x00) then
    poke(0xFF82E9,0x09) -- Infinity Credits --
end
-- Versus Mode Script --
if (peek(0xFF2000)==0x01) then
    if (dpeek(0xFFD43E)==0x82FA) and (peek(0xFF82F0)>0x00) then -- Auto activate P1 & P2 --
       poke(0xFF82F0,0x03)
       poke(0xFF8B5C,0x01)
       lpoke(0xFF8B4E,0x02010400)
    end
    if (peek(0xFF8009)==0x04) then -- Memorizes characters --
      p1char=peek(0xFF875F)
      p2char=peek(0xFF8B5F)
    end
    if (peek(0xFF8009)>=0x0C) then -- Prevent continue text --
       poke(0xFF874E,0xFF)
       poke(0xFF8B4E,0xFF)
    end
    if (peek(0xFF800D)==0x0C) and (peek(0xFF8009)==0x12) then
       poke(0xFF8005,0x00) -- Return to character screen --
       poke(0xFF8009,0x00)
       poke(0xFF800D,0x00)
       poke(0xFF82F0,0x03) -- Reactivate P1 & P2 --
       poke(0xFF875C,0x01)
       poke(0xFF8B5C,0x01)
       poke(0xFF875D,0x00) -- Deselect characters --
       poke(0xFF8B5D,0x00)
       dpoke(0xFF8C00,0x0000) -- Prevent bonus stage --
       lpoke(0xFF8BED,0x00000000) -- Prevent character turn grey after lose --
       lpoke(0xFF8BF1,0x00000000)
       lpoke(0xFF8BF5,0x00000000)
       lpoke(0xFF8BF9,0x00000000)
       poke(0xFF8BED,0x00) -- Repeated due to bug --
       poke(0xFF8BFC,0x00) -- Repeated due to bug --
       poke(0xFF2006,0x01)
    end
    if (peek(0xFF2006)==01) and (dpeek(0xFFE0D2)==0x253B) then -- Re-load last round characters --
      poke(0xFF875F,p1char)
      poke(0xFF8B5F,p2char)
      poke(0xFF2006,0x00)
    end
    if (dpeek(0xFFD4A4)==0xC5F2) then -- Randomize stage select - P1 or P2 --
       if math.random()*255<=127 then
         poke(0xFF8BE1,peek(0xFF875F)) -- Flight start at P1 --
         poke(0xFFE08B,peek(0xFF8B5F)) -- P2 character's stage --
       else
         poke(0xFF8BE1,peek(0xFF8B5F)) -- Flight start at P2 --
         poke(0xFFE08B,peek(0xFF875F)) -- P1 character's stage --
       end
       poke(0xFF8BE0,0x00) -- Prevent CPU stage --
    end
end
-- Training Mode Script --
if (peek(0xFF2000)==0x02) then
    if (dpeek(0xFFD43E)==0x82FA) and (peek(0xFF82F0)>0x00) then -- Auto activate P1 & P2 --
       poke(0xFF82F0,0x03)
       poke(0xFF8B5C,0x01)
       lpoke(0xFF8B4E,0x02010400)
    end
    if (peek(0xFF8783)==0x01) and (peek(0xFF8B83)==0x00) and (dpeek(0xFF8086)==0x0000) then -- P1 as main player --
      poke(0x2B5E,0x0B) -- Switch control --
      poke(0x2B64,0x07)
      poke(0xFF2003,0x01)
    end
    if (peek(0xFF8B83)==0x01) and (peek(0xFF8783)==0x00) and (dpeek(0xFF808A)==0x0000) then -- P2 as main player --
      poke(0x2B5E,0x0B) -- Switch control --
      poke(0x2B64,0x07)
      poke(0xFF2003,0x02)
    end
    if (peek(0xFF875D)==0x01) and (peek(0xFF8B5D)==0x01) then
      poke(0x2B5E,0x07) -- Restore control --
      poke(0x2B64,0x0B)
    end
    if (peek(0xFF2003)==0x01) or (peek(0xFF2003)==0x00) then
      poke(0xFF8BE1,peek(0xFF875F)) -- Flight start at P1 --
      poke(0xFFE08B,peek(0xFF8B5F)) -- P2 character's stage --
    end
    if (peek(0xFF2003)==0x02) then
      poke(0xFF8BE1,peek(0xFF8B5F)) -- Flight start at P2 --
      poke(0xFFE08B,peek(0xFF875F)) -- P1 character's stage --
    end
    if (peek(0xFF8009)==0x04) then -- Memorizes characters --
      p1char=peek(0xFF875F)
      p2char=peek(0xFF8B5F)
    end
    if (peek(0xFF8009)==0x0A) then
       poke(0xFF8CCF,0x28) -- infinite time --
       if (dpeek(0xFF83F8)<0x60) and ((peek(0xFF83D1)&0x10)==0x00) and (peek(0xFF8BE4)==0x0) then -- P1 infinite energy --
         dpoke(0xFF83F8,0x90)
         dpoke(0xFF858A,0x90)
       end
       if (dpeek(0xFF87F8)<0x60) and ((peek(0xFF87D1)&0x10)==0x00) and (peek(0xFF8BE4)==0x0) then -- P2 infinite energy --
         dpoke(0xFF87F8,0x90)
         dpoke(0xFF898A,0x90)
       end
       if (peek(0xFF8005)==0x08) and ((peek(0xFF807E)==0x10) or (peek(0xFF807E)==0x20)) then -- Return to Character Screen Step 1 --
         poke(0xFF875D,0x00) -- Deselect characters --
         poke(0xFF8B5D,0x00)
         poke(0xFF8009,0x02)
         poke(0xFF800B,0x01)
         poke(0xFF2004,0x01)
         poke(0xFF2006,0x01)
       end
       if (peek(0xFF2004)==0x01) then -- Return to Character Screen Step 2 --
         poke(0xFF8005,0x0C)
         poke(0xFF2004,0x00)
       end
    end
    if (peek(0xFF2006)==01) and (dpeek(0xFFE0D2)==0x253B) then -- Re-load last round characters --
      poke(0xFF875F,p1char)
      poke(0xFF8B5F,p2char)
      poke(0xFF2006,0x00)
    end
end
-- Option Mode Script --
if (peek(0xFF2000)==0x03) and ((peek(0xFF807E)==0x10) or (peek(0xFF807E)==0x20)) and (peek(0xFF801F)==0x08) then -- Step 1 --
    lpoke(0x1AE2,0x00000000) -- Rom hack --
    lpoke(0x1B1C,0x00000000)
    poke(0xFF2005,0x01)
    poke(0xFF807E,0x40)
end
if (peek(0xFF2000)==0x03) and (peek(0xFF8001)==0x02) and (peek(0xFF2005)==0x01) then -- step 2 - Restore value --
    lpoke(0x1AE2,0x2B40007E)
    lpoke(0x1B1C,0x1B42007E)
    poke(0xFF2005,0x00)
end
-- Pause Function Script --
    if (peek(0xFF8009)==0x0A) then
       if (peek(0xFF807E)==0x00) then
       poke(0xFF2002,0x00)
       end
       if (peek(0xFF8005)==0x04) and ((peek(0xFF807E)==0x01) or (peek(0xFF807E)==0x02)) and (peek(0xFF2002)==0x00) then
       poke(0xFF8005,0x08)
       poke(0xFF2002,0xFF)
       end
       if (peek(0xFF8005)==0x08) and ((peek(0xFF807E)==0x01) or (peek(0xFF807E)==0x02)) and (peek(0xFF2002)==0x00) then
       poke(0xFF8005,0x04)
       poke(0xFF2002,0xFF)
       end
    end
off:
    poke(0x15A39,"INSERT COIN.")
    poke(0x15A5D,"INSERT COIN.")
    poke(0x15A81,"INSERT COIN.")
    poke(0x2B5E,0x07)
    poke(0x2B64,0x0B)

script "Console Mode" \
 "comm:Coin button is used for pause. In training mode, pause the game and then press start to select character."
run:
#Start-up#
if (peek($FF82E9)==$00)
    poke $15A39 "            "
    poke $15A5D "            "
    poke $15A81 "            "
    poke $2B5E $07 #Restore initial value#
    poke $2B64 $0B
    poke $FF2000 $00
    p1char=$00
    p2char=$04
    if (peek($FF8005)>$00)and(peek($FF807E)>$00) #Start button start#
      poke $FF2021 $FF
      poke $FF82E9 $09 #Max credit#
    endif
endif
#Menu in the Title screen#
if (dpeek($FFD43E)==$82FA)and(peek($FF82E9)>$00)
    if ((peek($FF8087)==$00)and(peek($FF808B)==$00))and(peek($FF2001)==$FF)
      poke $FF2001 $00
      poke $FF2020 $00 #Act as music 'stopper'#
    endif
    if (peek($FF8087)==$04)or(peek($FF808B)==$04)
            if peek($FF2020)==$00 #Sound effect#
               poke $618001 $00
               poke $618003 $42
               poke $61801F $00
               poke $FF2020 $FF
            endif
       if (dpeek($FF2000)==$0000)
         dpoke $FF2000 $01FF
       elsif (dpeek($FF2000)==$0100)
         dpoke $FF2000 $02FF
       elsif (dpeek($FF2000)==$0200)
         dpoke $FF2000 $03FF
       elsif (dpeek($FF2000)==$0300)
         dpoke $FF2000 $00FF
       endif
    endif
    if (peek($FF8087)==$08)or(peek($FF808B)==$08)
            if peek($FF2020)==$00 #Sound effect#
               poke $618001 $00
               poke $618003 $42
               poke $61801F $00
               poke $FF2020 $FF
            endif
       if (dpeek($FF2000)==$0000)
         dpoke $FF2000 $03FF
       elsif (dpeek($FF2000)==$0300)
         dpoke $FF2000 $02FF
       elsif (dpeek($FF2000)==$0200)
         dpoke $FF2000 $01FF
       elsif (dpeek($FF2000)==$0100)
         dpoke $FF2000 $00FF
       endif
    endif
    if (peek($90CCD5)!=$4E) #All menu text#
        poke $FF8035 $38
        poke $90C8C9 'S'
        poke $90C949 'U'
        poke $90C9C9 'P'
        poke $90CA49 'E'
        poke $90CAC9 'R'
        poke $90CB49 ' '
        poke $90CBC9 'B'
        poke $90CC49 'A'
        poke $90CCC9 'T'
        poke $90CD49 'T'
        poke $90CDC9 'L'
        poke $90CE49 'E'
        poke $90C8CD 'V'
        poke $90C94D 'E'
        poke $90C9CD 'R'
        poke $90CA4D 'S'
        poke $90CACD 'U'
        poke $90CB4D 'S'
        poke $90CBCD ' '
        poke $90CC4D 'B'
        poke $90CCCD 'A'
        poke $90CD4D 'T'
        poke $90CDCD 'T'
        poke $90CE4D 'L'
        poke $90CECD 'E'
        poke $90C8D1 'T'
        poke $90C951 'R'
        poke $90C9D1 'A'
        poke $90CA51 'I'
        poke $90CAD1 'N'
        poke $90CB51 'I'
        poke $90CBD1 'N'
        poke $90CC51 'G'
        poke $90CCD1 ' '
        poke $90CD51 'M'
        poke $90CDD1 'O'
        poke $90CE51 'D'
        poke $90CED1 'E'
        poke $90CA55 'O'
        poke $90CAD5 'P'
        poke $90CB55 'T'
        poke $90CBD5 'I'
        poke $90CC55 'O'
        poke $90CCD5 'N'
    endif
    #Menu Text#
      if (peek($FF2000)==$00)and(peek($90C8CB)!=$01) #Arcade Mode pointer#
         for i=0 i<=$580 i=i+$80 poke $90C8CB+i $01
         for i=0 i<=$280 i=i+$80 poke $90CA57+i $00
         for i=0 i<=$600 i=i+$80 poke $90C8CF+i $00
      elsif (peek($FF2000)==$01)and(peek($90C8CF)!=$01) #Versus Mode pointer#
         for i=0 i<=$600 i=i+$80 poke $90C8CF+i $01
         for i=0 i<=$580 i=i+$80 poke $90C8CB+i $00
         for i=0 i<=$600 i=i+$80 poke $90C8D3+i $00
      elsif (peek($FF2000)==$02)and(peek($90C8D3)!=$01) #Training Mode pointer#
         for i=0 i<=$600 i=i+$80 poke $90C8D3+i $01
         for i=0 i<=$600 i=i+$80 poke $90C8CF+i $00
         for i=0 i<=$280 i=i+$80 poke $90CA57+i $00
      elsif (peek($FF2000)==$03)and(peek($90CA57)!=$01) #Option pointer#
         for i=0 i<=$280 i=i+$80 poke $90CA57+i $01
         for i=0 i<=$600 i=i+$80 poke $90C8D3+i $00
         for i=0 i<=$580 i=i+$80 poke $90C8CB+i $00
      endif
    #Game Start#
    if (peek($90CCD5)==$4E)and((peek($804020)==$FE)or(peek($804020)==$FD))and(peek($FF2021)==$00)
       poke $618001 $00 #Sound effect#
       poke $618003 $40
       poke $61801F $00
       poke $FF2021 $FF
    endif
    if (peek($FF8001)==$04)and(peek($804020)==$FF)
       poke $FF2021 $00 #Act as music 'stopper'#
    endif
endif
#Infinity Credits Script#
if (peek($FF82E9)>$00)
    poke $FF82E9 $09 #Infinity Credits#
endif
#Versus Mode Script#
if (peek($FF2000)==$01)
    if (dpeek($FFD43E)==$82FA)and(peek($FF82F0)>$00) #Auto activate P1 & P2#
       poke $FF82F0 $03
       poke $FF8B5C $01
       lpoke $FF8B4E $02010400
    endif
    if (peek($FF8009)==$04) #Memorizes characters#
      p1char=peek($FF875F)
      p2char=peek($FF8B5F)
    endif
    if (peek($FF8009)>=$0C) #Prevent continue text#
       poke $FF874E $FF
       poke $FF8B4E $FF
    endif
    if (peek($FF800D)==$0C)and(peek($FF8009)==$12)
       poke $FF8005 $00 #Return to character screen#
       poke $FF8009 $00
       poke $FF800D $00
       poke $FF82F0 $03 #Reactivate P1 & P2#
       poke $FF875C $01
       poke $FF8B5C $01
       poke $FF875D $00 #Deselect characters#
       poke $FF8B5D $00
       dpoke $FF8C00 $0000 #Prevent bonus stage#
       lpoke $FF8BED $00000000 #Prevent character turn grey after lose#
       lpoke $FF8BF1 $00000000
       lpoke $FF8BF5 $00000000
       lpoke $FF8BF9 $00000000
       poke $FF8BED $00 #Repeated due to bug#
       poke $FF8BFC $00 #Repeated due to bug#
       poke $FF2006 $01
    endif
    if (peek($FF2006)==01)and(dpeek($FFE0D2)==$253B) #Re-load last round characters#
      poke $FF875F p1char
      poke $FF8B5F p2char
      poke $FF2006 $00
    endif
    if (dpeek($FFD4A4)==$C5F2) #Randomize stage select - P1 or P2#
       if rnd()<=127
         poke $FF8BE1 peek($FF875F) #Flight start at P1#
         poke $FFE08B peek($FF8B5F) #P2 character's stage#
       else
         poke $FF8BE1 peek($FF8B5F) #Flight start at P2#
         poke $FFE08B peek($FF875F) #P1 character's stage#
       endif
       poke $FF8BE0 $00 #Prevent CPU stage#
    endif
endif
#Training Mode Script#
if (peek($FF2000)==$02)
    if (dpeek($FFD43E)==$82FA)and(peek($FF82F0)>$00) #Auto activate P1 & P2#
       poke $FF82F0 $03
       poke $FF8B5C $01
       lpoke $FF8B4E $02010400
    endif
    if (peek($FF8783)==$01)and(peek($FF8B83)==$00)and(dpeek($FF8086)==$0000) #P1 as main player#
      poke $2B5E $0B #Switch control#
      poke $2B64 $07
      poke $FF2003 $01
    endif
    if (peek($FF8B83)==$01)and(peek($FF8783)==$00)and(dpeek($FF808A)==$0000) #P2 as main player#
      poke $2B5E $0B #Switch control#
      poke $2B64 $07
      poke $FF2003 $02
    endif
    if (peek($FF875D)==$01)and(peek($FF8B5D)==$01)
      poke $2B5E $07 #Restore control#
      poke $2B64 $0B
    endif
    if (peek($FF2003)==$01)or(peek($FF2003)==$00)
      poke $FF8BE1 peek($FF875F) #Flight start at P1#
      poke $FFE08B peek($FF8B5F) #P2 character's stage#
    endif
    if (peek($FF2003)==$02)
      poke $FF8BE1 peek($FF8B5F) #Flight start at P2#
      poke $FFE08B peek($FF875F) #P1 character's stage#
    endif
    if (peek($FF8009)==$04) #Memorizes characters#
      p1char=peek($FF875F)
      p2char=peek($FF8B5F)
    endif
    if (peek($FF8009)==$0A)
       poke $FF8CCF $28 #infinite time#
       if (dpeek($FF83F8)<$60)and((peek($FF83D1)&$10)==$00)and(peek($FF8BE4)==$0) #P1 infinite energy#
         dpoke $FF83F8 $90
         dpoke $FF858A $90
       endif
       if (dpeek($FF87F8)<$60)and((peek($FF87D1)&$10)==$00)and(peek($FF8BE4)==$0) #P2 infinite energy#
         dpoke $FF87F8 $90
         dpoke $FF898A $90
       endif
       if (peek($FF8005)==$08)and((peek($FF807E)==$10)or(peek($FF807E)==$20)) #Return to Character Screen Step 1#
         poke $FF875D $00 #Deselect characters#
         poke $FF8B5D $00
         poke $FF8009 $02
         poke $FF800B $01
         poke $FF2004 $01
         poke $FF2006 $01
       endif
       if (peek($FF2004)==$01) #Return to Character Screen Step 2#
         poke $FF8005 $0C
         poke $FF2004 $00
       endif
    endif
    if (peek($FF2006)==01)and(dpeek($FFE0D2)==$253B) #Re-load last round characters#
      poke $FF875F p1char
      poke $FF8B5F p2char
      poke $FF2006 $00
    endif
endif
#Option Mode Script#
if (peek($FF2000)==$03)and((peek($FF807E)==$10)or(peek($FF807E)==$20))and(peek($FF801F)==$08) #Step 1#
    lpoke $1AE2 $00000000 #Rom hack#
    lpoke $1B1C $00000000
    poke $FF2005 $01
    poke $FF807E $40
endif
if (peek($FF2000)==$03)and(peek($FF8001)==$02)and(peek($FF2005)==$01) #step 2 - Restore value#
    lpoke $1AE2 $2B40007E
    lpoke $1B1C $1B42007E
    poke $FF2005 $00
endif
#Pause Function Script#
    if (peek($FF8009)==$0A)
       if (peek($FF807E)==$00)
       poke $FF2002 $00
       endif
       if (peek($FF8005)==$04)and((peek($FF807E)==$01)or(peek($FF807E)==$02))and(peek($FF2002)==$00)
       poke $FF8005 $08
       poke $FF2002 $FF
       endif
       if (peek($FF8005)==$08)and((peek($FF807E)==$01)or(peek($FF807E)==$02))and(peek($FF2002)==$00)
       poke $FF8005 $04
       poke $FF2002 $FF
       endif
    endif
off:
    poke $15A39 "INSERT COIN."
    poke $15A5D "INSERT COIN."
    poke $15A81 "INSERT COIN."
    poke $2B5E $07
    poke $2B64 $0B

script "Infinite Time"
run:
    if (peek($FF8CD2)==$00)and(peek($FF8CCE)>$01)
      dpoke $FF8CCE $9928
      dpoke $FFE0D2 $253C
    endif
script "Finish this Round Now!"
on:
    dpoke $FF8CCE $0101
script "Disable projectile impact slowdown"
run:
    if (peek($FF83F8)!=$FF)and(peek($FF87F8)!=$FF)
      poke $FF82F2 $00
    endif
script "Always in Turbo Mode" \
 "comm:Characters move faster"
run:
    poke $FF82ED $01
script "Select Starting Stage" \
 "0x0000/Stage 1"\
 "0x0100/Stage 2"\
 "0x0200/Stage 3"\
 "0x0300/Bonus stage: car"\
 "0x0301/Stage 4"\
 "0x0401/Stage 5"\
 "0x0501/Stage 6"\
 "0x0601/Bonus stage: barrels"\
 "0x0602/Stage 7"\
 "0x0702/Stage 8"\
 "0x0802/Stage 9 (Boxer)"\
 "0x0902/Bonus stage: drums"\
 "0x0903/Stage 10 (Claw)"\
 "0x0A03/Stage 11 (Sagat)"\
 "0x0B03/Stage 12 (Dictator)"
run:
    if ((dpeek($FF8C01)==$0000))or((peek($FF8BD1)=$00))or((dpeek($FF8C01)==param))
      poke $FF8BD1 param/$100
      dpoke $FF8C01 param
    endif
script "Select Backdrop" \
 "0x00/Japan (Castle)"\
 "0x01/Japan (Bath House)"\
 "0x02/Brazil"\
 "0x03/USA (Air Base)"\
 "0x04/USA (Pier)"\
 "0x05/China"\
 "0x06/USSR"\
 "0x07/India (Dhalsim)"\
 "0x08/USA (Las Vegas)"\
 "0x09/Thailand (Statue)"\
 "0x0A/Spain"\
 "0x0B/Thailand (Temple)"\
 "0x0C/England"\
 "0x0D/Mexico"\
 "0x0E/Hong Kong"\
 "0x0F/Jamaica"
run:
    poke $FFE08B param
script "Select Ending" \
 "0/No Losses"\
 "1/No Continues"\
 "2/Normal"
run:
    if param<2
      poke $FF831A $00
      poke $FF8C21 param
    endif
    if param==$2
      poke $FF831A $01
    endif
script " "
script "P1 Infinite Energy"
run:
    if (dpeek($FF83F8)<$60)and((peek($FF83D1)&$10)==$00)and(peek($FF8BE4)==$0)
      dpoke $FF83F8 $90
      dpoke $FF858A $90
    endif
script "P1 Dizzy Status" \
 "0x00/Never get dizzied"\
 "0x40/Always get dizzied"
run:
    dpoke $FF842A param
    dpoke $FF842C param
script "P1 Drain All Energy Now!"
on:
    poke $FF83F9 $00
script "P1 Finish round to win match"
run:
    poke $FF875E $02
script "P1 Rounds won always set = 0"
run:
    poke $FF875E $00
script "P1 Rounds won set = 0 Now!"
on:
    poke $FF875E $00
script "P1 Invincibility"
run:
    poke $FF858D $01
script "P1 Hit Anywhere"
on:
    temp0=lpeek($0934F6)
    temp1=dpeek($0934FA)
    temp2=lpeek($3FFFE0)
    temp3=lpeek($3FFFE4)
    temp4=lpeek($3FFFE8)
    temp5=lpeek($3FFFEC)
    temp6=lpeek($3FFFF0)
    temp7=lpeek($3FFFF4)
    temp8=lpeek($3FFFF8)
    temp9=lpeek($3FFFFC)
run:
    lpoke $0934F6 $4EF9003F
    dpoke $0934FA $FFE0
    lpoke $3FFFE0 $4A6A002A
    lpoke $3FFFE4 $6B0EB5FC
    lpoke $3FFFE8 $FFFF87CE
    lpoke $3FFFEC $66064EF9
    lpoke $3FFFF0 $00093572
    lpoke $3FFFF4 $3B7C0000
    lpoke $3FFFF8 $A6324EF9
    lpoke $3FFFFC $000934FC
off:
    lpoke $0934F6 temp0
    dpoke $0934FA temp1
    lpoke $3FFFE0 temp2
    lpoke $3FFFE4 temp3
    lpoke $3FFFE8 temp4
    lpoke $3FFFEC temp5
    lpoke $3FFFF0 temp6
    lpoke $3FFFF4 temp7
    lpoke $3FFFF8 temp8
    lpoke $3FFFFC temp9
script "P1 Allow special moves during jump"
run:
    poke $FF854F $00
script "P1 Hadou Ken motion Cancel" \
 "comm:Buggy"
run:
    poke $FF83EC $01
script "P1 No limit next shot" \
 "comm:Buggy"
run:
    poke $FF85A2 $00
    poke $FF85A3 $00
script "P1 Set Boxer Turnpunch level" \
 "0001/One"\
 "0121/Two"\
 "0241/Three"\
 "0481/Four"\
 "0961/Five"\
 "1441/Six"\
 "1921/Seven"\
 "2401/Final"
run:
    if peek($FF83CE+$391)==$0A
      dpoke ($FF83CE+$B6) param
      dpoke ($FF83CE+$B8) param
    endif
script "P1 Select Character" \
 "0x00/Ryu"\
 "0x01/Edmund Honda"\
 "0x02/Blanka"\
 "0x03/Guile"\
 "0x04/Ken Masters"\
 "0x05/Chun-Li"\
 "0x06/Zangief"\
 "0x07/Dhalsim"\
 "0x08/Balrog"\
 "0x09/Sagat"\
 "0x0A/Vega"\
 "0x0B/M. Bison"\
 "0x0C/Cammy"\
 "0x0D/Thunder Hawk"\
 "0x0E/Fei Long"\
 "0x0F/Dee Jay"
run:
    poke $FF875F param
script "P1 Select Colour" \
 "0x00/LP button"\
 "0x01/MP button"\
 "0x02/HP button"\
 "0x03/LK button"\
 "0x04/MK button"\
 "0x05/HK button"\
 "0x06/Start button"\
 "0x07/Hold any P/K button"
run:
    poke $FF877F param
script "P1 Easy charge moves"
run:
    temp0=peek($FF83CE+$391)
    if peek($FF83CE)==$0
      temp0=$FF
    endif
    if temp0==$1
      poke ($FF83CE+$81) $01
    endif
    if (temp0==$1)and(peek(FF83CE+$AA)<=$02)
      poke ($FF83CE+$AB) $01
    endif
    if temp0==$2
      poke ($FF83CE+$81) $01
      poke ($FF83CE+$B4) $01
      poke ($FF83CE+$BA) $01
    endif
    if temp0==$3
      poke ($FF83CE+$81) $01
      poke ($FF83CE+$87) $01
    endif
    if temp0==$5
      poke ($FF83CE+$81) $01
    endif
    if (temp0==$5)and(peek(FF83CE+$B0)<=$02)
      poke ($FF83CE+$B1) $01
    endif
    if temp0==$8
      poke ($FF83CE+$81) $01
      poke ($FF83CE+$89) $01
      poke ($FF83CE+$92) $01
    endif
    if (temp0==$8)and(peek(FF83CE+$AC)<=$02)
      poke ($FF83CE+$AD) $01
    endif
    if temp0==$A
      poke ($FF83CE+$81) $01
      poke ($FF83CE+$89) $01
      poke ($FF83CE+$C1) $01
      dpoke ($FF83CE+$B2) $0101
    endif
    if (temp0==$B)and(peek(FF83CE+$88)<=$02)
      poke ($FF83CE+$89) $01
    endif
    if (temp0==$B)and(peek(FF83CE+$8C)<=$02)
      poke ($FF83CE+$8D) $01
    endif
    if (temp0==$B)and(peek(FF83CE+$90)<=$02)
      poke ($FF83CE+$91) $01
    endif
    if (temp0==$F)and(peek(FF83CE+$92)<=$02)
      poke ($FF83CE+$93) $01
    endif
    if (temp0==$F)and(peek(FF83CE+$96)<=$02)
      poke ($FF83CE+$97) $01
    endif
    if (temp0==$F)and(peek(FF83CE+$A6)<=$02)
      poke ($FF83CE+$A7) $01
    endif
script "P1 Easy QCF + QCB moves"
run:
    temp0=peek($FF83CE+$391)
    if peek($FF83CE)==$0
      temp0=$FF
    endif
    if ((temp0==$0)or(temp0==$4))
      poke ($FF83CE+$90) $04
      poke ($FF83CE+$94) $04
    endif
    if temp0==$7
      poke ($FF83CE+$80) $04
    endif
    if temp0==$9
      poke ($FF83CE+$88) $04
      poke ($FF83CE+$8C) $04
    endif
    if temp0==$C
      poke ($FF83CE+$96) $04
    endif
    if temp0==$E
      poke ($FF83CE+$90) $04
      poke ($FF83CE+$A0) $04
    endif
script "P1 Easy F,D,DF + B,D,DB moves"
run:
    temp0=peek($FF83CE+$391)
    if peek($FF83CE)==$0
      temp0=$FF
    endif
    if ((temp0==$0)or(temp0==$4))
      poke ($FF83CE+$98) $04
    endif
    if temp0==$9
      poke ($FF83CE+$80) $04
    endif
    if temp0==$C
      poke ($FF83CE+$92) $04
    endif
    if temp0==$D
      poke ($FF83CE+$92) $04
    endif
    if temp0==$E
      poke ($FF83CE+$94) $04
    endif
    if (temp0==$7)and((dpeek(FF83CE+$392)&$2)>$0)
      dpoke ($FF83CE+$88) $0608
      poke ($FF83CE+$8D) $05
    endif
    if (temp0==$7)and((dpeek(FF83CE+$392)&$1)>$0)
      dpoke ($FF83CE+$88) $0608
      poke ($FF83CE+$8D) $06
    endif
script "P1 Easy 360, half-circle + tiger-knee moves"
run:
    temp0=peek($FF83CE+$391)
    if peek($FF83CE)==$0
      temp0=$FF
    endif
    if temp0==$0
      poke ($FF83CE+$E0) $08
    endif
    if temp0==$7
      poke ($FF83CE+$84) $08
    endif
    if temp0==$C
      poke ($FF83CE+$A2) $04
    endif
    if (temp0==$6)and(peek(FF83CE+$12)!=$0)
      lpoke ($FF83CE+$80) $06060800
      lpoke ($FF83CE+$9B) $06040800
    endif
    if (temp0==$6)and(peek(FF83CE+$12)==$0)
      lpoke ($FF83CE+$80) $06070800
      lpoke ($FF83CE+$9B) $06050800
    endif
    if (temp0==$D)and(peek(FF83CE+$12)!=$0)
      lpoke ($FF83CE+$99) $04060800
    endif
    if (temp0==$D)and(peek(FF83CE+$12)==$0)
      lpoke ($FF83CE+$99) $05060800
    endif
    if temp0==$9
      poke ($FF83CE+$84) $04
    endif
script "P1 Easy button tap moves"
run:
    temp0=peek($FF83CE+$391)
    if peek($FF83CE)==$0
      temp0=$FF
    endif
    if (temp0==$1)and(peek(FF83CE+$9A)<$2)
      poke ($FF83CE+$9A) $2
    endif
    if (temp0==$1)and(peek(FF83CE+$9C)<$2)
      poke ($FF83CE+$9C) $2
    endif
    if (temp0==$1)and(peek(FF83CE+$9E)<$2)
      poke ($FF83CE+$9E) $2
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF83CE+$9A)<$3)
      poke ($FF83CE+$9A) $3
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF83CE+$9C)<$3)
      poke ($FF83CE+$9C) $3
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF83CE+$9E)<$3)
      poke ($FF83CE+$9E) $3
    endif
script " "
script "P2 Infinite Energy"
run:
    if (dpeek($FF87F8)<$60)and((peek($FF87D1)&$10)==$00)and(peek($FF8BE4)==$0)
      dpoke $FF87F8 $90
      dpoke $FF898A $90
    endif
script "P2 Dizzy Status" \
 "0x00/Never get dizzied"\
 "0x40/Always get dizzied"
run:
    dpoke $FF882A param
    dpoke $FF882C param
script "P2 Drain All Energy Now!"
on:
    poke $FF87F9 $00
script "P2 Finish round to win match"
run:
    poke $FF8B5E $02
script "P2 Rounds won always set = 0"
run:
    poke $FF8B5E $00
script "P2 Rounds won set = 0 Now!"
on:
    poke $FF8B5E $00
script "P2 Invincibility"
run:
    poke $FF898D $01
script "P2 Allow special moves during jump"
run:
    poke $FF894F $00
script "P2 Hadou Ken motion Cancel" \
 "comm:Buggy"
run:
    poke $FF87EC $01
script "P2 No limit next shot" \
 "comm:Buggy"
run:
    poke $FF89A2 $00
    poke $FF89A3 $00
script "P2 Set Boxer Turnpunch level" \
 "0001/One"\
 "0121/Two"\
 "0241/Three"\
 "0481/Four"\
 "0961/Five"\
 "1441/Six"\
 "1921/Seven"\
 "2401/Final"
run:
    if peek($FF87CE+$391)==$0A
      dpoke ($FF87CE+$B6) param
      dpoke ($FF87CE+$B8) param
    endif
script "P2 Select Character" \
 "0x00/Ryu"\
 "0x01/Edmund Honda"\
 "0x02/Blanka"\
 "0x03/Guile"\
 "0x04/Ken Masters"\
 "0x05/Chun-Li"\
 "0x06/Zangief"\
 "0x07/Dhalsim"\
 "0x08/Balrog"\
 "0x09/Sagat"\
 "0x0A/Vega"\
 "0x0B/M. Bison"\
 "0x0C/Cammy"\
 "0x0D/Thunder Hawk"\
 "0x0E/Fei Long"\
 "0x0F/Dee Jay"
run:
    poke $FF8B5F param
script "P2 Select Colour" \
 "0x00/LP button"\
 "0x01/MP button"\
 "0x02/HP button"\
 "0x03/LK button"\
 "0x04/MK button"\
 "0x05/HK button"\
 "0x06/Start button"\
 "0x07/Hold any P/K button"
run:
    poke $FF8B7F param
script "P2 Easy charge moves"
run:
    temp0=peek($FF87CE+$391)
    if peek($FF87CE)==$0
      temp0=$FF
    endif
    if temp0==$1
      poke ($FF87CE+$81) $01
    endif
    if (temp0==$1)and(peek(FF87CE+$AA)<=$02)
      poke ($FF87CE+$AB) $01
    endif
    if temp0==$2
      poke ($FF87CE+$81) $01
      poke ($FF87CE+$B4) $01
      poke ($FF87CE+$BA) $01
    endif
    if temp0==$3
      poke ($FF87CE+$81) $01
      poke ($FF87CE+$87) $01
    endif
    if temp0==$5
      poke ($FF87CE+$81) $01
    endif
    if (temp0==$5)and(peek(FF87CE+$B0)<=$02)
      poke ($FF87CE+$B1) $01
    endif
    if temp0==$8
      poke ($FF87CE+$81) $01
      poke ($FF87CE+$89) $01
      poke ($FF87CE+$92) $01
    endif
    if (temp0==$8)and(peek(FF87CE+$AC)<=$02)
      poke ($FF87CE+$AD) $01
    endif
    if temp0==$A
      poke ($FF87CE+$81) $01
      poke ($FF87CE+$89) $01
      poke ($FF87CE+$C1) $01
      dpoke ($FF87CE+$B2) $0101
    endif
    if (temp0==$B)and(peek(FF87CE+$88)<=$02)
      poke ($FF87CE+$89) $01
    endif
    if (temp0==$B)and(peek(FF87CE+$8C)<=$02)
      poke ($FF87CE+$8D) $01
    endif
    if (temp0==$B)and(peek(FF87CE+$90)<=$02)
      poke ($FF87CE+$91) $01
    endif
    if (temp0==$F)and(peek(FF87CE+$92)<=$02)
      poke ($FF87CE+$93) $01
    endif
    if (temp0==$F)and(peek(FF87CE+$96)<=$02)
      poke ($FF87CE+$97) $01
    endif
    if (temp0==$F)and(peek(FF87CE+$A6)<=$02)
      poke ($FF87CE+$A7) $01
    endif
script "P2 Easy QCF + QCB moves"
run:
    temp0=peek($FF87CE+$391)
    if peek($FF87CE)==$0
      temp0=$FF
    endif
    if ((temp0==$0)or(temp0==$4))
      poke ($FF87CE+$90) $04
      poke ($FF87CE+$94) $04
    endif
    if temp0==$7
      poke ($FF87CE+$80) $04
    endif
    if temp0==$9
      poke ($FF87CE+$88) $04
      poke ($FF87CE+$8C) $04
    endif
    if temp0==$C
      poke ($FF87CE+$96) $04
    endif
    if temp0==$E
      poke ($FF87CE+$90) $04
      poke ($FF87CE+$A0) $04
    endif
script "P2 Easy F,D,DF + B,D,DB moves"
run:
    temp0=peek($FF87CE+$391)
    if peek($FF87CE)==$0
      temp0=$FF
    endif
    if ((temp0==$0)or(temp0==$4))
      poke ($FF87CE+$98) $04
    endif
    if temp0==$9
      poke ($FF87CE+$80) $04
    endif
    if temp0==$C
      poke ($FF87CE+$92) $04
    endif
    if temp0==$D
      poke ($FF87CE+$92) $04
    endif
    if temp0==$E
      poke ($FF87CE+$94) $04
    endif
    if (temp0==$7)and((dpeek(FF87CE+$392)&$2)>$0)
      dpoke ($FF87CE+$88) $0608
      poke ($FF87CE+$8D) $05
    endif
    if (temp0==$7)and((dpeek(FF87CE+$392)&$1)>$0)
      dpoke ($FF87CE+$88) $0608
      poke ($FF87CE+$8D) $06
    endif
script "P2 Easy 360, half-circle + tiger-knee moves"
run:
    temp0=peek($FF87CE+$391)
    if peek($FF87CE)==$0
      temp0=$FF
    endif
    if temp0==$0
      poke ($FF87CE+$E0) $08
    endif
    if temp0==$7
      poke ($FF87CE+$84) $08
    endif
    if temp0==$C
      poke ($FF87CE+$A2) $04
    endif
    if (temp0==$6)and(peek(FF87CE+$12)!=$0)
      lpoke ($FF87CE+$80) $06060800
      lpoke ($FF87CE+$9B) $06040800
    endif
    if (temp0==$6)and(peek(FF87CE+$12)==$0)
      lpoke ($FF87CE+$80) $06070800
      lpoke ($FF87CE+$9B) $06050800
    endif
    if (temp0==$D)and(peek(FF87CE+$12)!=$0)
      lpoke ($FF87CE+$99) $04060800
    endif
    if (temp0==$D)and(peek(FF87CE+$12)==$0)
      lpoke ($FF87CE+$99) $05060800
    endif
    if temp0==$9
      poke ($FF87CE+$84) $04
    endif
script "P2 Easy button tap moves"
run:
    temp0=peek($FF87CE+$391)
    if peek($FF87CE)==$0
      temp0=$FF
    endif
    if (temp0==$1)and(peek(FF87CE+$9A)<$2)
      poke ($FF87CE+$9A) $2
    endif
    if (temp0==$1)and(peek(FF87CE+$9C)<$2)
      poke ($FF87CE+$9C) $2
    endif
    if (temp0==$1)and(peek(FF87CE+$9E)<$2)
      poke ($FF87CE+$9E) $2
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF87CE+$9A)<$3)
      poke ($FF87CE+$9A) $3
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF87CE+$9C)<$3)
      poke ($FF87CE+$9C) $3
    endif
    if ((temp0==$2)or(temp0==$5))and(peek(FF87CE+$9E)<$3)
      poke ($FF87CE+$9E) $3
    endif
script " "
script "No Background Music"
run:
    cpu audio
    dpoke $F018 $0000
    cpu main
