User File #17856867996392106

Upload All User Files

#17856867996392106 - Partial conversion of Mugg's M&L:SS script to BizHawk.

MLSS_BisHawk.lua
602 downloads
Uploaded 10/5/2014 4:06 AM by FatRatKnight (see all 245)
I fished around for emulator specific functions, redefined names for them at the top, and now it's mostly a matter of picking similar functions when porting to a different emulator. Mostly.
I expect some poor alignments to come of this, so the rest of the conversion would best be handled by someone else. Haven't bothered looking for a GBA BIOS, so I just used the static screen of a ROM-less BizHawk for display and stand-in functions for memory related stuff. I hope I got the right memory functions, as I didn't rightly check them when getting rid of the stand-ins.
Also, I did two adjustments in the script itself. First, I moved the "EXP to next level calculator" from a list of if/else to a table, and compressed the Bros Attack Counters into fewer lines, including using math.max instead of checking if the number is below zero.
local R1u,R1s= memory.read_u8    ,memory.read_s8
local R2u=     memory.read_u16_le,memory.read_s16_le
local     R4s=                    memory.read_s32_le

local pixel= gui.drawPixel
local line = gui.drawLine
local box  = gui.drawBox
local function text(x,y,m,c) gui.drawText(x,y,m,c,8) end
--local text = gui.drawText

local ismovie= movie.isloaded

--Warning: I don't spot an identical version in BizHawk for these functions
local opacity= function() end

local TblNextM= { -- Mario experience needed
     7,   32,   68,  108,  218,  336,  470,  694,  962, 1254,  -- 1-10
  1578, 1924, 2306, 2756, 3256, 3830, 4480, 5195, 5975, 6845   --11-20
}

local TblNextL= { -- Luigi experience needed
    10,   37,   77,  123,  233,  353,  493,  699,  969, 1272,  -- 1-10
  1552, 1898, 2280, 2730, 3239, 3813, 4463, 5178, 5958, 6858   --11-20
}

--** variables to move everything around if needed **--
x = -1
y =  0

--*****************************************************************************
while true do
--*****************************************************************************

--** design **--
-- box
box(5+x, -2+y, 177+x ,26+y, 0xC41C1C1C)

-- mushroom graphic
line( 10+x,2+y ,14+x,2+y, 0xC4FF0000)
line(  9+x,3+y ,15+x,3+y, 0xC4FF0000)
line(  9+x,4+y ,15+x,4+y, 0xC4FF0000)
line( 11+x,5+y, 13+x,5+y, 0xC4F5D0A9)
line( 11+x,6+y, 13+x,6+y, 0xC4F5D0A9)
pixel(10+x,3+y, 0xC4FFFFFF)
pixel(12+x,2+y, 0xC4FFFFFF)
pixel(14+x,3+y, 0xC4FFFFFF)

-- nut graphic
line(10+x,  8+y, 12+x,  8+y, 0xC4FFCC66)
line( 9+x,  9+y, 13+x,  9+y, 0xC4FFCC66)
line( 9+x, 10+y, 14+x, 10+y, 0xC4FFCC66)
line(12+x, 11+y, 14+x, 11+y, 0xC4FFCC66)
line(13+x, 12+y, 14+x, 12+y, 0xC4FFCC66)

-- syrup graphic
line(11+x, 14+y, 12+x, 14+y, 0xC4FF9900)
line(11+x, 15+y, 12+x, 15+y, 0xC4FF9900)
line( 9+x, 16+y, 14+x, 16+y, 0xC4FF9900)
line( 9+x, 17+y, 14+x, 17+y, 0xC4FF9900)
line(10+x, 18+y, 13+x, 18+y, 0xC4FF9900)

-- seperation line
line(55+x, 1+y, 55+x, 18+y, 0x80FFFFFF)
line(56+x, 1+y, 56+x, 18+y, 0x80FFFFFF)

line(77+x, 1+y, 77+x, 18+y, 0x80FFFFFF)
line(78+x, 1+y, 78+x, 18+y, 0x80FFFFFF)

line(144+x, 1+y, 144+x, 25+y, 0x80FFFFFF)
line(145+x, 1+y, 145+x, 25+y, 0x80FFFFFF)

--** ADDRESS VALUES **--
mushrooms      = R1s(0x020048e2)
supermushrooms = R1s(0x020048e3)
ultramushrooms = R1s(0x020048e4)
maxmushrooms   = R1s(0x020048e5)
nuts           = R1s(0x020048e6)
supernuts      = R1s(0x020048e7)
ultranuts      = R1s(0x020048e8)
maxnuts        = R1s(0x020048e9)
syrups         = R1s(0x020048ea)
supersyrups    = R1s(0x020048eb)
ultrasyrups    = R1s(0x020048ec)
maxsyrups      = R1s(0x020048ed)
ONEups         = R1s(0x020048ee)
ONEupDXs       = R1s(0x020048ef)
goldmushrooms  = R1s(0x020048f0)
herbs          = R1s(0x020048f1)
redpeppers     = R1s(0x020048f2)
greenpeppers   = R1s(0x020048f3)
ahastraights   = R1s(0x020048f4)
ufustraights   = R1s(0x020048f5)
gerastraights  = R1s(0x020048f6)
dehestraights  = R1s(0x020048f7)
ufumanjaros    = R1s(0x020048f8)
gerapuccinos   = R1s(0x020048f9)
dehepressos    = R1s(0x020048fa)

ahabeans  = R1u(0x02004902)
ufubeans  = R1u(0x02004903)
gerabeans = R1u(0x02004904)
dehebeans = R1u(0x02004905)



--TODO: CLOTHES







--Mario
HPM    = R2u(0x02004866)
HPmaxM = R2u(0x0200486A)
BPM    = R2u(0x0200486c)
BPmaxM = R2u(0x02004870)
PowM   = R2u(0x02004874)
DefM   = R2u(0x0200487c)
SpeedM = R2u(0x02004878)
HigeM  = R2u(0x02004880)
levelM = R1u(0x02004888)
ExpM   = R2u(0x0200485c)


-- This calculates how much experience you have to get for the next level.
-- The NextM/NextL values seem to be hardcoded into the game.
NextM = TblNextM[levelM] or 0
NextexpM = NextM - ExpM

--Luigi
HPL    = R2u(0x020048a2)
HPmaxL = R2u(0x020048a6)
BPL    = R2u(0x020048a8)
BPmaxL = R2u(0x020048ac)
PowL   = R2u(0x020048b0)
DefL   = R2u(0x020048b8)
SpeedL = R2u(0x020048b4)
HigeL  = R2u(0x020048bc)
levelL = R1u(0x020048c4)
ExpL   = R2u(0x02004898)

-- 'Next' calculator
NextL = TblNextL[levelL] or 0
NextexpL = NextL - ExpL


-- display
 if mushrooms      == -1 then mushrooms      = 0 end
 if supermushrooms == -1 then supermushrooms = 0 end
 if ultramushrooms == -1 then ultramushrooms = 0 end
 if maxmushrooms   == -1 then maxmushrooms   = 0 end
 if nuts           == -1 then nuts           = 0 end
 if supernuts      == -1 then supernuts      = 0 end
 if ultranuts      == -1 then ultranuts      = 0 end
 if maxnuts        == -1 then maxnuts        = 0 end
 if syrups         == -1 then syrups         = 0 end
 if supersyrups    == -1 then supersyrups    = 0 end
 if ultrasyrups    == -1 then ultrasyrups    = 0 end
 if maxsyrups      == -1 then maxsyrups      = 0 end
 if ONEups         == -1 then ONEups         = 0 end
 if ONEupDXs       == -1 then ONEupDXs       = 0 end
 if redpeppers     == -1 then redpeppers     = 0 end
 if greenpeppers   == -1 then greenpeppers   = 0 end
 if herbs          == -1 then herbs          = 0 end
 if goldmushrooms  == -1 then goldmushrooms  = 0 end
 if ahastraights   == -1 then ahastraights   = 0 end
 if ufustraights   == -1 then ufustraights   = 0 end
 if gerastraights  == -1 then gerastraights  = 0 end
 if dehestraights  == -1 then dehestraights  = 0 end
 if ufumanjaros    == -1 then ufumanjaros    = 0 end
 if gerapuccinos   == -1 then gerapuccinos   = 0 end
 if dehepressos    == -1 then dehepressos    = 0 end
 if ahabeans       == -1 then ahabeans       = 0 end
 if ufubeans       == -1 then ufubeans       = 0 end
 if gerabeans      == -1 then gerabeans      = 0 end
 if dehebeans      == -1 then dehebeans      = 0 end


text(18+x,1+y, mushrooms)
text(28+x,1+y, supermushrooms)
text(38+x,1+y, ultramushrooms)
text(48+x,1+y, maxmushrooms)

--text(133+x,1+y, "(" ..mushrooms*0.078 + supermushrooms*0.098 + ultramushrooms*0.117 + maxmushrooms*0.199 .. ")" , "yellow")
--FRK's note:  (20/256)mush : (25/256)super : (30/256)ultra : (51/256)max ?

text(18+x,7+y, nuts)
text(28+x,7+y, supernuts)
text(38+x,7+y, ultranuts)
text(48+x,7+y, maxnuts)

text(18+x,13+y, syrups)
text(28+x,13+y, supersyrups)
text(38+x,13+y, ultrasyrups)
text(48+x,13+y, maxsyrups)

--text(57+x,1+y, "=" ..mushrooms*20+supermushrooms*50+ultramushrooms*110+maxmushrooms*280 ,"#81F7F3")
--text(78+x,1+y, mushrooms*24+supermushrooms*60+ultramushrooms*100+maxmushrooms*180 ,"#ACFA58")

--text(57+x,7+y, "=" ..nuts*50+supernuts*120+ultranuts*260+maxnuts*340 , "#81f7f3")
--text(78+x,7+y, nuts*50+supernuts*90+ultranuts*140+maxnuts*220 , "#acfa58")

--text(57+x,13+y, "=" ..syrups*24+supersyrups*50+ultrasyrups*80+maxsyrups*280 , "#81f7f3")
--text(78+x,13+y, syrups*24+supersyrups*50+ultrasyrups*80+maxsyrups*150 , "#acfa58")


--text(22+x,19+y, "=" ..ONEups*70+ONEupDXs*420+herbs*30+goldmushrooms*105+redpeppers*30+greenpeppers*30+ahastraights*100+ufustraights*100+gerastraights*100+dehestraights*100+ufumanjaros*100+gerapuccinos*100+dehepressos*100 , "#81f7f3")
--text(43+x,19+y, ONEups*80+ONEupDXs*240+herbs*30+goldmushrooms*60+redpeppers*50+greenpeppers*50+ahastraights*100+ufustraights*100+gerastraights*100+dehestraights*100+ufumanjaros*100+gerapuccinos*100+dehepressos*100 , "#acfa58")

text( 60+x, 7+y, "$" ..R2u(0x020048e0), "yellow")

text( 82+x, 1+y, "(M)", "#F78181")
text(116+x, 1+y, "(L)", "#ACFA58")
text( 94+x, 1+y, "Lv" .. levelM)
text(128+x, 1+y, "Lv" .. levelL)
text( 82+x, 7+y, "BP ", "#FFCC66")
text( 93+x, 7+y, BPM .. "/" .. BPmaxM .. "  " .. BPL .. "/" .. BPmaxL)
text( 82+x,13+y, "Pow  " , "#EAADEA")
text( 94+x,19+y, "hige " , "#A9F5D0")
--text( 86+x,25+y, "NEXT ", "#A9D0F5")
text(102+x,13+y, PowM .. "   " .. PowL)
text(116+x,19+y, HigeM .. "   " .. HigeL)
--text(107+x,25+y, NextexpM .. "   " .. NextexpL)

--Bros Attacks counters
text( 9+x,19+y, "S=".. math.max(20 - R1u(0x02004684),0)) --SplashCounter
text(30+x,19+y, "B=".. math.max( 8 - R1u(0x0200468c),0)) --BounceCounter
text(47+x,19+y, "C=".. math.max(32 - R1u(0x02004686),0)) --ChopperCounter
text(68+x,19+y, "K=".. math.max(43 - R1u(0x0200468e),0)) --KnockCounter

-- RNG
text(6+x,28+y, R1s(0x02001e60))
text(6+x,35+y, R1s(0x02001e64))


--Movie active?
if ismovie()~=true then box(29,29,140,39, 0xC4FF0000) end
if ismovie()~=true then text(35,31, "!! MOVIE NOT RECORDING !!") end


---- POS
text(150+x,  1+y, R4s(0x02006c14), 0xE5F78181)
text(150+x,  7+y, R4s(0x02006c18), 0xE5F78181)
text(150+x, 13+y, R4s(0x02006fb0), 0xE5ACFA58)
text(150+x, 19+y, R4s(0x02006fb4), 0xE5ACFA58)

---- MISC
--text(10, 89, "rookie hp " ..R2u(0x02008ce6)-5000, 0xE5FFFF00)
--text(10, 89, "Birdo hp "  ..R2u(0x02008fe2), 0xE5FFFF00)
text(10, 89, "head  "  ..R2u(0x0200aa42)-5000, 0xE5FFFF00)
text(10, 98, "heart  " ..R2u(0x0200a912)-5000, 0xE5FFFF00)
text(10,107, "left  "  ..R2u(0x0200ab72)-5000, 0xE5FFFF00)
text(10,116, "right  " ..R2u(0x0200aca2)-5000, 0xE5FFFF00)

opacity(0.6)
if     R1s(0x02004f4c) == 0 then box(126,36,158,44, 0x99666666,0x99666666)
elseif R1s(0x02004f4c) == 1 then box(126,27,158,35, 0x99666666,0x99666666) end

text(130+x, 28+y, R1u(0x03002429), 0xE5F78181)
text(150+x, 28+y, R1u(0x03002440), 0xE5ACFA58)

text(130+x, 37+y, R1u(0x03002441), 0xE5ACFA58)
text(150+x, 37+y, R1u(0x03002428), 0xE5F78181)


emu.frameadvance()
end