diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf099f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.rogo +*.swp +.DS_Store +Build +Thumbs.db diff --git a/Assets/Cinema/Appomattox/appcontrol.bmp b/Assets/Cinema/Appomattox/appcontrol.bmp new file mode 100644 index 0000000..9ed40e9 Binary files /dev/null and b/Assets/Cinema/Appomattox/appcontrol.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves.bmp b/Assets/Cinema/Appomattox/appwaves.bmp new file mode 100644 index 0000000..5d35118 Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves0.bmp b/Assets/Cinema/Appomattox/appwaves0.bmp new file mode 100644 index 0000000..baafb38 Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves0.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves1.bmp b/Assets/Cinema/Appomattox/appwaves1.bmp new file mode 100644 index 0000000..d1e6a8f Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves1.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves2.bmp b/Assets/Cinema/Appomattox/appwaves2.bmp new file mode 100644 index 0000000..24ea2ba Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves2.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves3.bmp b/Assets/Cinema/Appomattox/appwaves3.bmp new file mode 100644 index 0000000..81304dc Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves3.bmp differ diff --git a/Assets/Cinema/Appomattox/appwaves4.bmp b/Assets/Cinema/Appomattox/appwaves4.bmp new file mode 100644 index 0000000..08ec1c3 Binary files /dev/null and b/Assets/Cinema/Appomattox/appwaves4.bmp differ diff --git a/Assets/Cinema/Appomattox/cantsave.bmp b/Assets/Cinema/Appomattox/cantsave.bmp new file mode 100644 index 0000000..e393410 Binary files /dev/null and b/Assets/Cinema/Appomattox/cantsave.bmp differ diff --git a/Assets/Cinema/Appomattox/cantsave_flying.bmp b/Assets/Cinema/Appomattox/cantsave_flying.bmp new file mode 100644 index 0000000..6bdf0fb Binary files /dev/null and b/Assets/Cinema/Appomattox/cantsave_flying.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud0.bmp b/Assets/Cinema/Appomattox/cloud0.bmp new file mode 100644 index 0000000..840e52f Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud0.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud1.bmp b/Assets/Cinema/Appomattox/cloud1.bmp new file mode 100644 index 0000000..76fc06d Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud1.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud2.bmp b/Assets/Cinema/Appomattox/cloud2.bmp new file mode 100644 index 0000000..9e5eab5 Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud2.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud3.bmp b/Assets/Cinema/Appomattox/cloud3.bmp new file mode 100644 index 0000000..f0bc942 Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud3.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud4.bmp b/Assets/Cinema/Appomattox/cloud4.bmp new file mode 100644 index 0000000..644ec4a Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud4.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud5.bmp b/Assets/Cinema/Appomattox/cloud5.bmp new file mode 100644 index 0000000..ea84e3b Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud5.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud6.bmp b/Assets/Cinema/Appomattox/cloud6.bmp new file mode 100644 index 0000000..667a30b Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud6.bmp differ diff --git a/Assets/Cinema/Appomattox/cloud7.bmp b/Assets/Cinema/Appomattox/cloud7.bmp new file mode 100644 index 0000000..dca3569 Binary files /dev/null and b/Assets/Cinema/Appomattox/cloud7.bmp differ diff --git a/Assets/Cinema/Appomattox/cloudscroll.bmp b/Assets/Cinema/Appomattox/cloudscroll.bmp new file mode 100644 index 0000000..e69bb4f Binary files /dev/null and b/Assets/Cinema/Appomattox/cloudscroll.bmp differ diff --git a/Assets/Cinema/Appomattox/cloudsorange.bmp b/Assets/Cinema/Appomattox/cloudsorange.bmp new file mode 100644 index 0000000..9b54cbb Binary files /dev/null and b/Assets/Cinema/Appomattox/cloudsorange.bmp differ diff --git a/Assets/Cinema/Appomattox/cloudvscroll.bmp b/Assets/Cinema/Appomattox/cloudvscroll.bmp new file mode 100644 index 0000000..61aa7e5 Binary files /dev/null and b/Assets/Cinema/Appomattox/cloudvscroll.bmp differ diff --git a/Assets/Cinema/Appomattox/controlpanel.bmp b/Assets/Cinema/Appomattox/controlpanel.bmp new file mode 100644 index 0000000..e4e9f68 Binary files /dev/null and b/Assets/Cinema/Appomattox/controlpanel.bmp differ diff --git a/Assets/Cinema/Appomattox/fgbmap_big.bmp b/Assets/Cinema/Appomattox/fgbmap_big.bmp new file mode 100644 index 0000000..16e6271 Binary files /dev/null and b/Assets/Cinema/Appomattox/fgbmap_big.bmp differ diff --git a/Assets/Cinema/Appomattox/intro_ba_b12dropship.bmp b/Assets/Cinema/Appomattox/intro_ba_b12dropship.bmp new file mode 100644 index 0000000..506f72e Binary files /dev/null and b/Assets/Cinema/Appomattox/intro_ba_b12dropship.bmp differ diff --git a/Assets/Cinema/Appomattox/intro_ba_croutondropship.bmp b/Assets/Cinema/Appomattox/intro_ba_croutondropship.bmp new file mode 100644 index 0000000..2c4adfe Binary files /dev/null and b/Assets/Cinema/Appomattox/intro_ba_croutondropship.bmp differ diff --git a/Assets/Cinema/Appomattox/kiwi1.bmp b/Assets/Cinema/Appomattox/kiwi1.bmp new file mode 100644 index 0000000..ed8e077 Binary files /dev/null and b/Assets/Cinema/Appomattox/kiwi1.bmp differ diff --git a/Assets/Cinema/Appomattox/kiwi2.bmp b/Assets/Cinema/Appomattox/kiwi2.bmp new file mode 100644 index 0000000..90f30c9 Binary files /dev/null and b/Assets/Cinema/Appomattox/kiwi2.bmp differ diff --git a/Assets/Cinema/Appomattox/kiwi3.bmp b/Assets/Cinema/Appomattox/kiwi3.bmp new file mode 100644 index 0000000..4d75d73 Binary files /dev/null and b/Assets/Cinema/Appomattox/kiwi3.bmp differ diff --git a/Assets/Cinema/Appomattox/landing_bg.bmp b/Assets/Cinema/Appomattox/landing_bg.bmp new file mode 100644 index 0000000..43255e2 Binary files /dev/null and b/Assets/Cinema/Appomattox/landing_bg.bmp differ diff --git a/Assets/Cinema/Appomattox/landing_sprites.bmp b/Assets/Cinema/Appomattox/landing_sprites.bmp new file mode 100644 index 0000000..171d093 Binary files /dev/null and b/Assets/Cinema/Appomattox/landing_sprites.bmp differ diff --git a/Assets/Cinema/Appomattox/landingpicts.bmp b/Assets/Cinema/Appomattox/landingpicts.bmp new file mode 100644 index 0000000..7ae7d67 Binary files /dev/null and b/Assets/Cinema/Appomattox/landingpicts.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_brokenwall.bmp b/Assets/Cinema/Appomattox/lz_brokenwall.bmp new file mode 100644 index 0000000..74acd92 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_brokenwall.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_canyon.bmp b/Assets/Cinema/Appomattox/lz_canyon.bmp new file mode 100644 index 0000000..ea09fcb Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_canyon.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_croutongate.bmp b/Assets/Cinema/Appomattox/lz_croutongate.bmp new file mode 100644 index 0000000..5be46a4 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_croutongate.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_desert.bmp b/Assets/Cinema/Appomattox/lz_desert.bmp new file mode 100644 index 0000000..e535271 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_desert.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_gate.bmp b/Assets/Cinema/Appomattox/lz_gate.bmp new file mode 100644 index 0000000..8eb0c7f Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_gate.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_graves.bmp b/Assets/Cinema/Appomattox/lz_graves.bmp new file mode 100644 index 0000000..9ba8d4c Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_graves.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_ice1.bmp b/Assets/Cinema/Appomattox/lz_ice1.bmp new file mode 100644 index 0000000..b7ab940 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_ice1.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_icecubes.bmp b/Assets/Cinema/Appomattox/lz_icecubes.bmp new file mode 100644 index 0000000..263e94e Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_icecubes.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_jungle.bmp b/Assets/Cinema/Appomattox/lz_jungle.bmp new file mode 100644 index 0000000..14f9d55 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_jungle.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_mist.bmp b/Assets/Cinema/Appomattox/lz_mist.bmp new file mode 100644 index 0000000..1fb05b1 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_mist.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_mountains.bmp b/Assets/Cinema/Appomattox/lz_mountains.bmp new file mode 100644 index 0000000..9c6cec1 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_mountains.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_ocean.bmp b/Assets/Cinema/Appomattox/lz_ocean.bmp new file mode 100644 index 0000000..da10f58 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_ocean.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_palace.bmp b/Assets/Cinema/Appomattox/lz_palace.bmp new file mode 100644 index 0000000..8093036 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_palace.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_pencil.bmp b/Assets/Cinema/Appomattox/lz_pencil.bmp new file mode 100644 index 0000000..f615836 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_pencil.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_treepath.bmp b/Assets/Cinema/Appomattox/lz_treepath.bmp new file mode 100644 index 0000000..0671b29 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_treepath.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_trees1.bmp b/Assets/Cinema/Appomattox/lz_trees1.bmp new file mode 100644 index 0000000..6a1fb35 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_trees1.bmp differ diff --git a/Assets/Cinema/Appomattox/lz_zorhaus.bmp b/Assets/Cinema/Appomattox/lz_zorhaus.bmp new file mode 100644 index 0000000..2c87b19 Binary files /dev/null and b/Assets/Cinema/Appomattox/lz_zorhaus.bmp differ diff --git a/Assets/Cinema/Appomattox/nokey.bmp b/Assets/Cinema/Appomattox/nokey.bmp new file mode 100644 index 0000000..c75344e Binary files /dev/null and b/Assets/Cinema/Appomattox/nokey.bmp differ diff --git a/Assets/Cinema/Appomattox/panelsprites.bmp b/Assets/Cinema/Appomattox/panelsprites.bmp new file mode 100644 index 0000000..e30aef2 Binary files /dev/null and b/Assets/Cinema/Appomattox/panelsprites.bmp differ diff --git a/Assets/Cinema/Appomattox/savegame.bmp b/Assets/Cinema/Appomattox/savegame.bmp new file mode 100644 index 0000000..3719bcb Binary files /dev/null and b/Assets/Cinema/Appomattox/savegame.bmp differ diff --git a/Assets/Cinema/Appomattox/starfield.bmp b/Assets/Cinema/Appomattox/starfield.bmp new file mode 100644 index 0000000..061badc Binary files /dev/null and b/Assets/Cinema/Appomattox/starfield.bmp differ diff --git a/Assets/Cinema/Appomattox/starfield_sprite.bmp b/Assets/Cinema/Appomattox/starfield_sprite.bmp new file mode 100644 index 0000000..4cdbc28 Binary files /dev/null and b/Assets/Cinema/Appomattox/starfield_sprite.bmp differ diff --git a/Assets/Cinema/CharSelect/SCROLL.BMP b/Assets/Cinema/CharSelect/SCROLL.BMP new file mode 100644 index 0000000..9e881e4 Binary files /dev/null and b/Assets/Cinema/CharSelect/SCROLL.BMP differ diff --git a/Assets/Cinema/CharSelect/backinside.bmp b/Assets/Cinema/CharSelect/backinside.bmp new file mode 100644 index 0000000..63ae83a Binary files /dev/null and b/Assets/Cinema/CharSelect/backinside.bmp differ diff --git a/Assets/Cinema/CharSelect/charnames.bmp b/Assets/Cinema/CharSelect/charnames.bmp new file mode 100644 index 0000000..e916c32 Binary files /dev/null and b/Assets/Cinema/CharSelect/charnames.bmp differ diff --git a/Assets/Cinema/CharSelect/charselect.bmp b/Assets/Cinema/CharSelect/charselect.bmp new file mode 100644 index 0000000..7b0b6f0 Binary files /dev/null and b/Assets/Cinema/CharSelect/charselect.bmp differ diff --git a/Assets/Cinema/CharSelect/charselecthills.bmp b/Assets/Cinema/CharSelect/charselecthills.bmp new file mode 100644 index 0000000..13f61c5 Binary files /dev/null and b/Assets/Cinema/CharSelect/charselecthills.bmp differ diff --git a/Assets/Cinema/CharSelect/deathscreen.bmp b/Assets/Cinema/CharSelect/deathscreen.bmp new file mode 100644 index 0000000..2bb264c Binary files /dev/null and b/Assets/Cinema/CharSelect/deathscreen.bmp differ diff --git a/Assets/Cinema/CharSelect/kgname.bmp b/Assets/Cinema/CharSelect/kgname.bmp new file mode 100644 index 0000000..2594119 Binary files /dev/null and b/Assets/Cinema/CharSelect/kgname.bmp differ diff --git a/Assets/Cinema/CharSelect/select_ba.bmp b/Assets/Cinema/CharSelect/select_ba.bmp new file mode 100644 index 0000000..33088d7 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_ba.bmp differ diff --git a/Assets/Cinema/CharSelect/select_ba_name.bmp b/Assets/Cinema/CharSelect/select_ba_name.bmp new file mode 100644 index 0000000..8e0103d Binary files /dev/null and b/Assets/Cinema/CharSelect/select_ba_name.bmp differ diff --git a/Assets/Cinema/CharSelect/select_bg.bmp b/Assets/Cinema/CharSelect/select_bg.bmp new file mode 100644 index 0000000..18b71fe Binary files /dev/null and b/Assets/Cinema/CharSelect/select_bg.bmp differ diff --git a/Assets/Cinema/CharSelect/select_bg_144.bmp b/Assets/Cinema/CharSelect/select_bg_144.bmp new file mode 100644 index 0000000..2a43802 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_bg_144.bmp differ diff --git a/Assets/Cinema/CharSelect/select_bs.bmp b/Assets/Cinema/CharSelect/select_bs.bmp new file mode 100644 index 0000000..4ff52d8 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_bs.bmp differ diff --git a/Assets/Cinema/CharSelect/select_bs_name.bmp b/Assets/Cinema/CharSelect/select_bs_name.bmp new file mode 100644 index 0000000..7c95c53 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_bs_name.bmp differ diff --git a/Assets/Cinema/CharSelect/select_grenade.bmp b/Assets/Cinema/CharSelect/select_grenade.bmp new file mode 100644 index 0000000..d396ad5 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_grenade.bmp differ diff --git a/Assets/Cinema/CharSelect/select_haiku.bmp b/Assets/Cinema/CharSelect/select_haiku.bmp new file mode 100644 index 0000000..a13dfc6 Binary files /dev/null and b/Assets/Cinema/CharSelect/select_haiku.bmp differ diff --git a/Assets/Cinema/CharSelect/select_haiku_name.bmp b/Assets/Cinema/CharSelect/select_haiku_name.bmp new file mode 100644 index 0000000..c9d39fb Binary files /dev/null and b/Assets/Cinema/CharSelect/select_haiku_name.bmp differ diff --git a/Assets/Cinema/Cinema1/ba.bmp b/Assets/Cinema/Cinema1/ba.bmp new file mode 100644 index 0000000..e191f63 Binary files /dev/null and b/Assets/Cinema/Cinema1/ba.bmp differ diff --git a/Assets/Cinema/Cinema1/bs.bmp b/Assets/Cinema/Cinema1/bs.bmp new file mode 100644 index 0000000..9a4cc9c Binary files /dev/null and b/Assets/Cinema/Cinema1/bs.bmp differ diff --git a/Assets/Cinema/Cinema1/flour gang mono.bmp b/Assets/Cinema/Cinema1/flour gang mono.bmp new file mode 100644 index 0000000..861f4e6 Binary files /dev/null and b/Assets/Cinema/Cinema1/flour gang mono.bmp differ diff --git a/Assets/Cinema/Cinema1/flourdriving.bmp b/Assets/Cinema/Cinema1/flourdriving.bmp new file mode 100644 index 0000000..ed84533 Binary files /dev/null and b/Assets/Cinema/Cinema1/flourdriving.bmp differ diff --git a/Assets/Cinema/Cinema1/flowernight.bmp b/Assets/Cinema/Cinema1/flowernight.bmp new file mode 100644 index 0000000..06952c6 Binary files /dev/null and b/Assets/Cinema/Cinema1/flowernight.bmp differ diff --git a/Assets/Cinema/Cinema1/flowerviewscreen.bmp b/Assets/Cinema/Cinema1/flowerviewscreen.bmp new file mode 100644 index 0000000..26b2156 Binary files /dev/null and b/Assets/Cinema/Cinema1/flowerviewscreen.bmp differ diff --git a/Assets/Cinema/Cinema1/haiku.bmp b/Assets/Cinema/Cinema1/haiku.bmp new file mode 100644 index 0000000..67bf23f Binary files /dev/null and b/Assets/Cinema/Cinema1/haiku.bmp differ diff --git a/Assets/Cinema/Cinema1/palace.bmp b/Assets/Cinema/Cinema1/palace.bmp new file mode 100644 index 0000000..38a55e3 Binary files /dev/null and b/Assets/Cinema/Cinema1/palace.bmp differ diff --git a/Assets/Cinema/Cinema1/yacht in space.bmp b/Assets/Cinema/Cinema1/yacht in space.bmp new file mode 100644 index 0000000..fd93bf7 Binary files /dev/null and b/Assets/Cinema/Cinema1/yacht in space.bmp differ diff --git a/Assets/Cinema/Disco/party_over.bmp b/Assets/Cinema/Disco/party_over.bmp new file mode 100644 index 0000000..7723263 Binary files /dev/null and b/Assets/Cinema/Disco/party_over.bmp differ diff --git a/Assets/Cinema/Disco/success.bmp b/Assets/Cinema/Disco/success.bmp new file mode 100644 index 0000000..a793cae Binary files /dev/null and b/Assets/Cinema/Disco/success.bmp differ diff --git a/Assets/Cinema/Distress/appomattox_big.bmp b/Assets/Cinema/Distress/appomattox_big.bmp new file mode 100644 index 0000000..4b0ea03 Binary files /dev/null and b/Assets/Cinema/Distress/appomattox_big.bmp differ diff --git a/Assets/Cinema/Distress/appomattox_big_side.bmp b/Assets/Cinema/Distress/appomattox_big_side.bmp new file mode 100644 index 0000000..9ebd536 Binary files /dev/null and b/Assets/Cinema/Distress/appomattox_big_side.bmp differ diff --git a/Assets/Cinema/Distress/appomattox_big_sprites.bmp b/Assets/Cinema/Distress/appomattox_big_sprites.bmp new file mode 100644 index 0000000..898bcf0 Binary files /dev/null and b/Assets/Cinema/Distress/appomattox_big_sprites.bmp differ diff --git a/Assets/Cinema/Distress/appomattox_tokiwi.bmp b/Assets/Cinema/Distress/appomattox_tokiwi.bmp new file mode 100644 index 0000000..effeee0 Binary files /dev/null and b/Assets/Cinema/Distress/appomattox_tokiwi.bmp differ diff --git a/Assets/Cinema/Distress/at_gunpoint.bmp b/Assets/Cinema/Distress/at_gunpoint.bmp new file mode 100644 index 0000000..b66a72c Binary files /dev/null and b/Assets/Cinema/Distress/at_gunpoint.bmp differ diff --git a/Assets/Cinema/Distress/at_gunpoint_sprites.bmp b/Assets/Cinema/Distress/at_gunpoint_sprites.bmp new file mode 100644 index 0000000..9536fd8 Binary files /dev/null and b/Assets/Cinema/Distress/at_gunpoint_sprites.bmp differ diff --git a/Assets/Cinema/Distress/ba.bmp b/Assets/Cinema/Distress/ba.bmp new file mode 100644 index 0000000..13e1382 Binary files /dev/null and b/Assets/Cinema/Distress/ba.bmp differ diff --git a/Assets/Cinema/Distress/bee.bmp b/Assets/Cinema/Distress/bee.bmp new file mode 100644 index 0000000..978b5fd Binary files /dev/null and b/Assets/Cinema/Distress/bee.bmp differ diff --git a/Assets/Cinema/Distress/bs.bmp b/Assets/Cinema/Distress/bs.bmp new file mode 100644 index 0000000..d4df946 Binary files /dev/null and b/Assets/Cinema/Distress/bs.bmp differ diff --git a/Assets/Cinema/Distress/distress.bmp b/Assets/Cinema/Distress/distress.bmp new file mode 100644 index 0000000..e61acab Binary files /dev/null and b/Assets/Cinema/Distress/distress.bmp differ diff --git a/Assets/Cinema/Distress/downramp.bmp b/Assets/Cinema/Distress/downramp.bmp new file mode 100644 index 0000000..7d5965e Binary files /dev/null and b/Assets/Cinema/Distress/downramp.bmp differ diff --git a/Assets/Cinema/Distress/downramp_sprites.bmp b/Assets/Cinema/Distress/downramp_sprites.bmp new file mode 100644 index 0000000..34a05fe Binary files /dev/null and b/Assets/Cinema/Distress/downramp_sprites.bmp differ diff --git a/Assets/Cinema/Distress/fgstars.bmp b/Assets/Cinema/Distress/fgstars.bmp new file mode 100644 index 0000000..1402a0c Binary files /dev/null and b/Assets/Cinema/Distress/fgstars.bmp differ diff --git a/Assets/Cinema/Distress/final.bmp b/Assets/Cinema/Distress/final.bmp new file mode 100644 index 0000000..4cb6acb Binary files /dev/null and b/Assets/Cinema/Distress/final.bmp differ diff --git a/Assets/Cinema/Distress/flour_and_flower.bmp b/Assets/Cinema/Distress/flour_and_flower.bmp new file mode 100644 index 0000000..0f3f92b Binary files /dev/null and b/Assets/Cinema/Distress/flour_and_flower.bmp differ diff --git a/Assets/Cinema/Distress/flour_gang_mono.bmp b/Assets/Cinema/Distress/flour_gang_mono.bmp new file mode 100644 index 0000000..861f4e6 Binary files /dev/null and b/Assets/Cinema/Distress/flour_gang_mono.bmp differ diff --git a/Assets/Cinema/Distress/flourdriving.bmp b/Assets/Cinema/Distress/flourdriving.bmp new file mode 100644 index 0000000..7991e43 Binary files /dev/null and b/Assets/Cinema/Distress/flourdriving.bmp differ diff --git a/Assets/Cinema/Distress/flower_and_flour_establishing.bmp b/Assets/Cinema/Distress/flower_and_flour_establishing.bmp new file mode 100644 index 0000000..85bffce Binary files /dev/null and b/Assets/Cinema/Distress/flower_and_flour_establishing.bmp differ diff --git a/Assets/Cinema/Distress/flowernight.bmp b/Assets/Cinema/Distress/flowernight.bmp new file mode 100644 index 0000000..6a8428d Binary files /dev/null and b/Assets/Cinema/Distress/flowernight.bmp differ diff --git a/Assets/Cinema/Distress/flowerviewscreen.bmp b/Assets/Cinema/Distress/flowerviewscreen.bmp new file mode 100644 index 0000000..273d9ab Binary files /dev/null and b/Assets/Cinema/Distress/flowerviewscreen.bmp differ diff --git a/Assets/Cinema/Distress/moon_mini.bmp b/Assets/Cinema/Distress/moon_mini.bmp new file mode 100644 index 0000000..e0ea341 Binary files /dev/null and b/Assets/Cinema/Distress/moon_mini.bmp differ diff --git a/Assets/Cinema/Distress/nar_certaindanger.bmp b/Assets/Cinema/Distress/nar_certaindanger.bmp new file mode 100644 index 0000000..db6fd44 Binary files /dev/null and b/Assets/Cinema/Distress/nar_certaindanger.bmp differ diff --git a/Assets/Cinema/Distress/nar_meanwhile.bmp b/Assets/Cinema/Distress/nar_meanwhile.bmp new file mode 100644 index 0000000..c02926b Binary files /dev/null and b/Assets/Cinema/Distress/nar_meanwhile.bmp differ diff --git a/Assets/Cinema/Distress/palace.bmp b/Assets/Cinema/Distress/palace.bmp new file mode 100644 index 0000000..82d9c48 Binary files /dev/null and b/Assets/Cinema/Distress/palace.bmp differ diff --git a/Assets/Cinema/Distress/pirate_sprites.bmp b/Assets/Cinema/Distress/pirate_sprites.bmp new file mode 100644 index 0000000..099409c Binary files /dev/null and b/Assets/Cinema/Distress/pirate_sprites.bmp differ diff --git a/Assets/Cinema/Distress/remote.bmp b/Assets/Cinema/Distress/remote.bmp new file mode 100644 index 0000000..dfe5bbb Binary files /dev/null and b/Assets/Cinema/Distress/remote.bmp differ diff --git a/Assets/Cinema/Distress/spacepan.bmp b/Assets/Cinema/Distress/spacepan.bmp new file mode 100644 index 0000000..622600a Binary files /dev/null and b/Assets/Cinema/Distress/spacepan.bmp differ diff --git a/Assets/Cinema/Distress/yacht in space.bmp b/Assets/Cinema/Distress/yacht in space.bmp new file mode 100644 index 0000000..fd93bf7 Binary files /dev/null and b/Assets/Cinema/Distress/yacht in space.bmp differ diff --git a/Assets/Cinema/Distress/yacht_mini.bmp b/Assets/Cinema/Distress/yacht_mini.bmp new file mode 100644 index 0000000..4d9d8e1 Binary files /dev/null and b/Assets/Cinema/Distress/yacht_mini.bmp differ diff --git a/Assets/Cinema/Distress/yacht_under_fire.bmp b/Assets/Cinema/Distress/yacht_under_fire.bmp new file mode 100644 index 0000000..652e6c7 Binary files /dev/null and b/Assets/Cinema/Distress/yacht_under_fire.bmp differ diff --git a/Assets/Cinema/Ending/appland3d.bmp b/Assets/Cinema/Ending/appland3d.bmp new file mode 100644 index 0000000..09ccee4 Binary files /dev/null and b/Assets/Cinema/Ending/appland3d.bmp differ diff --git a/Assets/Cinema/Ending/appland3d2.bmp b/Assets/Cinema/Ending/appland3d2.bmp new file mode 100644 index 0000000..90d342f Binary files /dev/null and b/Assets/Cinema/Ending/appland3d2.bmp differ diff --git a/Assets/Cinema/Ending/appland_anim_test.bmp b/Assets/Cinema/Ending/appland_anim_test.bmp new file mode 100644 index 0000000..d7951df Binary files /dev/null and b/Assets/Cinema/Ending/appland_anim_test.bmp differ diff --git a/Assets/Cinema/Ending/appland_sprites.bmp b/Assets/Cinema/Ending/appland_sprites.bmp new file mode 100644 index 0000000..254d6aa Binary files /dev/null and b/Assets/Cinema/Ending/appland_sprites.bmp differ diff --git a/Assets/Cinema/Ending/appx_takeoff.bmp b/Assets/Cinema/Ending/appx_takeoff.bmp new file mode 100644 index 0000000..6b7b40a Binary files /dev/null and b/Assets/Cinema/Ending/appx_takeoff.bmp differ diff --git a/Assets/Cinema/Ending/appx_takeoff_sprites.bmp b/Assets/Cinema/Ending/appx_takeoff_sprites.bmp new file mode 100644 index 0000000..687b533 Binary files /dev/null and b/Assets/Cinema/Ending/appx_takeoff_sprites.bmp differ diff --git a/Assets/Cinema/Ending/big_station_approach.bmp b/Assets/Cinema/Ending/big_station_approach.bmp new file mode 100644 index 0000000..fb573b8 Binary files /dev/null and b/Assets/Cinema/Ending/big_station_approach.bmp differ diff --git a/Assets/Cinema/Ending/big_station_sprites.bmp b/Assets/Cinema/Ending/big_station_sprites.bmp new file mode 100644 index 0000000..5f30018 Binary files /dev/null and b/Assets/Cinema/Ending/big_station_sprites.bmp differ diff --git a/Assets/Cinema/Ending/button.bmp b/Assets/Cinema/Ending/button.bmp new file mode 100644 index 0000000..79cf684 Binary files /dev/null and b/Assets/Cinema/Ending/button.bmp differ diff --git a/Assets/Cinema/Ending/button_note.bmp b/Assets/Cinema/Ending/button_note.bmp new file mode 100644 index 0000000..befbdad Binary files /dev/null and b/Assets/Cinema/Ending/button_note.bmp differ diff --git a/Assets/Cinema/Ending/closed hatch.bmp b/Assets/Cinema/Ending/closed hatch.bmp new file mode 100644 index 0000000..c5d249c Binary files /dev/null and b/Assets/Cinema/Ending/closed hatch.bmp differ diff --git a/Assets/Cinema/Ending/gyro on ramp.bmp b/Assets/Cinema/Ending/gyro on ramp.bmp new file mode 100644 index 0000000..880a629 Binary files /dev/null and b/Assets/Cinema/Ending/gyro on ramp.bmp differ diff --git a/Assets/Cinema/Ending/gyro_screen.bmp b/Assets/Cinema/Ending/gyro_screen.bmp new file mode 100644 index 0000000..5f2d8e2 Binary files /dev/null and b/Assets/Cinema/Ending/gyro_screen.bmp differ diff --git a/Assets/Cinema/Ending/gyro_ship_takeoff.bmp b/Assets/Cinema/Ending/gyro_ship_takeoff.bmp new file mode 100644 index 0000000..389296a Binary files /dev/null and b/Assets/Cinema/Ending/gyro_ship_takeoff.bmp differ diff --git a/Assets/Cinema/Ending/gyro_surrounded.bmp b/Assets/Cinema/Ending/gyro_surrounded.bmp new file mode 100644 index 0000000..29b4760 Binary files /dev/null and b/Assets/Cinema/Ending/gyro_surrounded.bmp differ diff --git a/Assets/Cinema/Ending/minuteslater.bmp b/Assets/Cinema/Ending/minuteslater.bmp new file mode 100644 index 0000000..8ffff2e Binary files /dev/null and b/Assets/Cinema/Ending/minuteslater.bmp differ diff --git a/Assets/Cinema/Ending/palacedaylight.bmp b/Assets/Cinema/Ending/palacedaylight.bmp new file mode 100644 index 0000000..47315e6 Binary files /dev/null and b/Assets/Cinema/Ending/palacedaylight.bmp differ diff --git a/Assets/Cinema/Ending/small_station_approach.bmp b/Assets/Cinema/Ending/small_station_approach.bmp new file mode 100644 index 0000000..8de93ea Binary files /dev/null and b/Assets/Cinema/Ending/small_station_approach.bmp differ diff --git a/Assets/Cinema/Ending/small_station_sprites.bmp b/Assets/Cinema/Ending/small_station_sprites.bmp new file mode 100644 index 0000000..7684940 Binary files /dev/null and b/Assets/Cinema/Ending/small_station_sprites.bmp differ diff --git a/Assets/Cinema/Ending/station_tactical.bmp b/Assets/Cinema/Ending/station_tactical.bmp new file mode 100644 index 0000000..0c1e6b0 Binary files /dev/null and b/Assets/Cinema/Ending/station_tactical.bmp differ diff --git a/Assets/Cinema/Ending/station_tactical_sprites.bmp b/Assets/Cinema/Ending/station_tactical_sprites.bmp new file mode 100644 index 0000000..3ec8612 Binary files /dev/null and b/Assets/Cinema/Ending/station_tactical_sprites.bmp differ diff --git a/Assets/Cinema/Ending/waving_from_flowers_yacht.bmp b/Assets/Cinema/Ending/waving_from_flowers_yacht.bmp new file mode 100644 index 0000000..9b2077b Binary files /dev/null and b/Assets/Cinema/Ending/waving_from_flowers_yacht.bmp differ diff --git a/Assets/Cinema/Ending/yacht_open_hatch.bmp b/Assets/Cinema/Ending/yacht_open_hatch.bmp new file mode 100644 index 0000000..60fcb52 Binary files /dev/null and b/Assets/Cinema/Ending/yacht_open_hatch.bmp differ diff --git a/Assets/Cinema/Intro/bcs_vestigial.bmp b/Assets/Cinema/Intro/bcs_vestigial.bmp new file mode 100644 index 0000000..d9c5042 Binary files /dev/null and b/Assets/Cinema/Intro/bcs_vestigial.bmp differ diff --git a/Assets/Cinema/Intro/brainiac.bmp b/Assets/Cinema/Intro/brainiac.bmp new file mode 100644 index 0000000..eddf012 Binary files /dev/null and b/Assets/Cinema/Intro/brainiac.bmp differ diff --git a/Assets/Cinema/Intro/dropship_tiny.bmp b/Assets/Cinema/Intro/dropship_tiny.bmp new file mode 100644 index 0000000..8b10989 Binary files /dev/null and b/Assets/Cinema/Intro/dropship_tiny.bmp differ diff --git a/Assets/Cinema/Intro/group_in_triumph.bmp b/Assets/Cinema/Intro/group_in_triumph.bmp new file mode 100644 index 0000000..c0e7350 Binary files /dev/null and b/Assets/Cinema/Intro/group_in_triumph.bmp differ diff --git a/Assets/Cinema/Intro/gyro_cornered_gun.bmp b/Assets/Cinema/Intro/gyro_cornered_gun.bmp new file mode 100644 index 0000000..3bbf634 Binary files /dev/null and b/Assets/Cinema/Intro/gyro_cornered_gun.bmp differ diff --git a/Assets/Cinema/Intro/gyrocornered.bmp b/Assets/Cinema/Intro/gyrocornered.bmp new file mode 100644 index 0000000..5b46f01 Binary files /dev/null and b/Assets/Cinema/Intro/gyrocornered.bmp differ diff --git a/Assets/Cinema/Intro/moon.bmp b/Assets/Cinema/Intro/moon.bmp new file mode 100644 index 0000000..8b96d46 Binary files /dev/null and b/Assets/Cinema/Intro/moon.bmp differ diff --git a/Assets/Cinema/Intro/moontact.bmp b/Assets/Cinema/Intro/moontact.bmp new file mode 100644 index 0000000..9c3430c Binary files /dev/null and b/Assets/Cinema/Intro/moontact.bmp differ diff --git a/Assets/Cinema/Intro/nar_crewquarters.bmp b/Assets/Cinema/Intro/nar_crewquarters.bmp new file mode 100644 index 0000000..883873c Binary files /dev/null and b/Assets/Cinema/Intro/nar_crewquarters.bmp differ diff --git a/Assets/Cinema/Intro/nar_skippyshuttle.bmp b/Assets/Cinema/Intro/nar_skippyshuttle.bmp new file mode 100644 index 0000000..d086ef4 Binary files /dev/null and b/Assets/Cinema/Intro/nar_skippyshuttle.bmp differ diff --git a/Assets/Cinema/Intro/narrator_warroom.bmp b/Assets/Cinema/Intro/narrator_warroom.bmp new file mode 100644 index 0000000..d001f0e Binary files /dev/null and b/Assets/Cinema/Intro/narrator_warroom.bmp differ diff --git a/Assets/Cinema/Intro/space_bg1.bmp b/Assets/Cinema/Intro/space_bg1.bmp new file mode 100644 index 0000000..3f18a99 Binary files /dev/null and b/Assets/Cinema/Intro/space_bg1.bmp differ diff --git a/Assets/Cinema/Intro/space_bg2.bmp b/Assets/Cinema/Intro/space_bg2.bmp new file mode 100644 index 0000000..4037f8d Binary files /dev/null and b/Assets/Cinema/Intro/space_bg2.bmp differ diff --git a/Assets/Cinema/Intro/tactmap.bmp b/Assets/Cinema/Intro/tactmap.bmp new file mode 100644 index 0000000..957aab6 Binary files /dev/null and b/Assets/Cinema/Intro/tactmap.bmp differ diff --git a/Assets/Cinema/Intro/triumphBIG.bmp b/Assets/Cinema/Intro/triumphBIG.bmp new file mode 100644 index 0000000..13dbbbd Binary files /dev/null and b/Assets/Cinema/Intro/triumphBIG.bmp differ diff --git a/Assets/Cinema/Intro/triumph_small.bmp b/Assets/Cinema/Intro/triumph_small.bmp new file mode 100644 index 0000000..06a8884 Binary files /dev/null and b/Assets/Cinema/Intro/triumph_small.bmp differ diff --git a/Assets/Cinema/Intro/viewscreen.bmp b/Assets/Cinema/Intro/viewscreen.bmp new file mode 100644 index 0000000..51c558b Binary files /dev/null and b/Assets/Cinema/Intro/viewscreen.bmp differ diff --git a/Assets/Cinema/Logo/fgbtitle.bmp b/Assets/Cinema/Logo/fgbtitle.bmp new file mode 100644 index 0000000..1f955cd Binary files /dev/null and b/Assets/Cinema/Logo/fgbtitle.bmp differ diff --git a/Assets/Cinema/Logo/logo160.bmp b/Assets/Cinema/Logo/logo160.bmp new file mode 100644 index 0000000..4a9e073 Binary files /dev/null and b/Assets/Cinema/Logo/logo160.bmp differ diff --git a/Assets/Cinema/Logo/logo160_b&w.bmp b/Assets/Cinema/Logo/logo160_b&w.bmp new file mode 100644 index 0000000..4d78a58 Binary files /dev/null and b/Assets/Cinema/Logo/logo160_b&w.bmp differ diff --git a/Assets/Cinema/Logo/ocloud0.bmp b/Assets/Cinema/Logo/ocloud0.bmp new file mode 100644 index 0000000..132bf5f Binary files /dev/null and b/Assets/Cinema/Logo/ocloud0.bmp differ diff --git a/Assets/Cinema/Logo/ocloud1.bmp b/Assets/Cinema/Logo/ocloud1.bmp new file mode 100644 index 0000000..a827a1e Binary files /dev/null and b/Assets/Cinema/Logo/ocloud1.bmp differ diff --git a/Assets/Cinema/Logo/ocloud2.bmp b/Assets/Cinema/Logo/ocloud2.bmp new file mode 100644 index 0000000..3c0a020 Binary files /dev/null and b/Assets/Cinema/Logo/ocloud2.bmp differ diff --git a/Assets/Cinema/Logo/ocloud3.bmp b/Assets/Cinema/Logo/ocloud3.bmp new file mode 100644 index 0000000..b102d5b Binary files /dev/null and b/Assets/Cinema/Logo/ocloud3.bmp differ diff --git a/Assets/Cinema/Logo/ocloud4.bmp b/Assets/Cinema/Logo/ocloud4.bmp new file mode 100644 index 0000000..4efd42d Binary files /dev/null and b/Assets/Cinema/Logo/ocloud4.bmp differ diff --git a/Assets/Cinema/Logo/ocloud5.bmp b/Assets/Cinema/Logo/ocloud5.bmp new file mode 100644 index 0000000..ef2c97e Binary files /dev/null and b/Assets/Cinema/Logo/ocloud5.bmp differ diff --git a/Assets/Cinema/Logo/ocloud6.bmp b/Assets/Cinema/Logo/ocloud6.bmp new file mode 100644 index 0000000..4cc7939 Binary files /dev/null and b/Assets/Cinema/Logo/ocloud6.bmp differ diff --git a/Assets/Cinema/Logo/ocloud7.bmp b/Assets/Cinema/Logo/ocloud7.bmp new file mode 100644 index 0000000..b06a681 Binary files /dev/null and b/Assets/Cinema/Logo/ocloud7.bmp differ diff --git a/Assets/Cinema/Logo/ocloud8.bmp b/Assets/Cinema/Logo/ocloud8.bmp new file mode 100644 index 0000000..1a392aa Binary files /dev/null and b/Assets/Cinema/Logo/ocloud8.bmp differ diff --git a/Assets/Cinema/Logo/ocloud9.bmp b/Assets/Cinema/Logo/ocloud9.bmp new file mode 100644 index 0000000..fac48da Binary files /dev/null and b/Assets/Cinema/Logo/ocloud9.bmp differ diff --git a/Assets/Cinema/Logo/oclouda.bmp b/Assets/Cinema/Logo/oclouda.bmp new file mode 100644 index 0000000..f4be735 Binary files /dev/null and b/Assets/Cinema/Logo/oclouda.bmp differ diff --git a/Assets/Cinema/Logo/ocloudb.bmp b/Assets/Cinema/Logo/ocloudb.bmp new file mode 100644 index 0000000..a06de24 Binary files /dev/null and b/Assets/Cinema/Logo/ocloudb.bmp differ diff --git a/Assets/Cinema/Logo/ocloudc.bmp b/Assets/Cinema/Logo/ocloudc.bmp new file mode 100644 index 0000000..ebd61db Binary files /dev/null and b/Assets/Cinema/Logo/ocloudc.bmp differ diff --git a/Assets/Cinema/Logo/ocloudd.bmp b/Assets/Cinema/Logo/ocloudd.bmp new file mode 100644 index 0000000..01767ff Binary files /dev/null and b/Assets/Cinema/Logo/ocloudd.bmp differ diff --git a/Assets/Cinema/Logo/ocloude.bmp b/Assets/Cinema/Logo/ocloude.bmp new file mode 100644 index 0000000..3348b3e Binary files /dev/null and b/Assets/Cinema/Logo/ocloude.bmp differ diff --git a/Assets/Cinema/Logo/ocloudf.bmp b/Assets/Cinema/Logo/ocloudf.bmp new file mode 100644 index 0000000..d0337d0 Binary files /dev/null and b/Assets/Cinema/Logo/ocloudf.bmp differ diff --git a/Assets/Cinema/Logo/ocloudtest.bmp b/Assets/Cinema/Logo/ocloudtest.bmp new file mode 100644 index 0000000..cc7c3ec Binary files /dev/null and b/Assets/Cinema/Logo/ocloudtest.bmp differ diff --git a/Assets/Cinema/Logo/presents.bmp b/Assets/Cinema/Logo/presents.bmp new file mode 100644 index 0000000..ca46816 Binary files /dev/null and b/Assets/Cinema/Logo/presents.bmp differ diff --git a/Assets/Cinema/Logo/titlesprite.bmp b/Assets/Cinema/Logo/titlesprite.bmp new file mode 100644 index 0000000..01b1665 Binary files /dev/null and b/Assets/Cinema/Logo/titlesprite.bmp differ diff --git a/Assets/Cinema/MainCharDialog/flour_triumph.bmp b/Assets/Cinema/MainCharDialog/flour_triumph.bmp new file mode 100644 index 0000000..569e928 Binary files /dev/null and b/Assets/Cinema/MainCharDialog/flour_triumph.bmp differ diff --git a/Assets/Cinema/MainCharDialog/haiku.bmp b/Assets/Cinema/MainCharDialog/haiku.bmp new file mode 100644 index 0000000..d68ac50 Binary files /dev/null and b/Assets/Cinema/MainCharDialog/haiku.bmp differ diff --git a/Assets/Cinema/MainCharDialog/skippy_triumph.bmp b/Assets/Cinema/MainCharDialog/skippy_triumph.bmp new file mode 100644 index 0000000..982877a Binary files /dev/null and b/Assets/Cinema/MainCharDialog/skippy_triumph.bmp differ diff --git a/Assets/Cinema/Map/fgbmap_big.bmp b/Assets/Cinema/Map/fgbmap_big.bmp new file mode 100644 index 0000000..7bbd662 Binary files /dev/null and b/Assets/Cinema/Map/fgbmap_big.bmp differ diff --git a/Assets/Cinema/Menu/MainMenu.bmp b/Assets/Cinema/Menu/MainMenu.bmp new file mode 100644 index 0000000..0e40b6f Binary files /dev/null and b/Assets/Cinema/Menu/MainMenu.bmp differ diff --git a/Assets/Cinema/Menu/WaitingToJoin.bmp b/Assets/Cinema/Menu/WaitingToJoin.bmp new file mode 100644 index 0000000..c0c2af7 Binary files /dev/null and b/Assets/Cinema/Menu/WaitingToJoin.bmp differ diff --git a/Assets/Cinema/Menu/bullet.bmp b/Assets/Cinema/Menu/bullet.bmp new file mode 100644 index 0000000..9fb863b Binary files /dev/null and b/Assets/Cinema/Menu/bullet.bmp differ diff --git a/Assets/Cinema/Menu/fgbmenu.bmp b/Assets/Cinema/Menu/fgbmenu.bmp new file mode 100644 index 0000000..d8f3a5f Binary files /dev/null and b/Assets/Cinema/Menu/fgbmenu.bmp differ diff --git a/Assets/Cinema/Menu/menuCursor.bmp b/Assets/Cinema/Menu/menuCursor.bmp new file mode 100644 index 0000000..2f1ac39 Binary files /dev/null and b/Assets/Cinema/Menu/menuCursor.bmp differ diff --git a/Assets/Cinema/Menu/waiting_to_join.bmp b/Assets/Cinema/Menu/waiting_to_join.bmp new file mode 100644 index 0000000..ca37528 Binary files /dev/null and b/Assets/Cinema/Menu/waiting_to_join.bmp differ diff --git a/Assets/Cinema/Promo/haveseenthelast.bmp b/Assets/Cinema/Promo/haveseenthelast.bmp new file mode 100644 index 0000000..0fde3d6 Binary files /dev/null and b/Assets/Cinema/Promo/haveseenthelast.bmp differ diff --git a/Assets/Cinema/Promo/publish.bmp b/Assets/Cinema/Promo/publish.bmp new file mode 100644 index 0000000..5752fce Binary files /dev/null and b/Assets/Cinema/Promo/publish.bmp differ diff --git a/Assets/Cinema/Promo/willtheyland.bmp b/Assets/Cinema/Promo/willtheyland.bmp new file mode 100644 index 0000000..6e52329 Binary files /dev/null and b/Assets/Cinema/Promo/willtheyland.bmp differ diff --git a/Assets/Cinema/Wedding/bs_driving.bmp b/Assets/Cinema/Wedding/bs_driving.bmp new file mode 100644 index 0000000..2f5d7d1 Binary files /dev/null and b/Assets/Cinema/Wedding/bs_driving.bmp differ diff --git a/Assets/Cinema/Wedding/dandelions.bmp b/Assets/Cinema/Wedding/dandelions.bmp new file mode 100644 index 0000000..cb84ef8 Binary files /dev/null and b/Assets/Cinema/Wedding/dandelions.bmp differ diff --git a/Assets/Cinema/Wedding/flour_at_wedding.bmp b/Assets/Cinema/Wedding/flour_at_wedding.bmp new file mode 100644 index 0000000..1383cc0 Binary files /dev/null and b/Assets/Cinema/Wedding/flour_at_wedding.bmp differ diff --git a/Assets/Cinema/Wedding/flower_at_wedding.bmp b/Assets/Cinema/Wedding/flower_at_wedding.bmp new file mode 100644 index 0000000..0f26953 Binary files /dev/null and b/Assets/Cinema/Wedding/flower_at_wedding.bmp differ diff --git a/Assets/Cinema/Wedding/gang_watches_front.bmp b/Assets/Cinema/Wedding/gang_watches_front.bmp new file mode 100644 index 0000000..20d304a Binary files /dev/null and b/Assets/Cinema/Wedding/gang_watches_front.bmp differ diff --git a/Assets/Cinema/Wedding/gang_watches_wedding.bmp b/Assets/Cinema/Wedding/gang_watches_wedding.bmp new file mode 100644 index 0000000..22448e9 Binary files /dev/null and b/Assets/Cinema/Wedding/gang_watches_wedding.bmp differ diff --git a/Assets/Cinema/Wedding/gyro_big.bmp b/Assets/Cinema/Wedding/gyro_big.bmp new file mode 100644 index 0000000..24a82b7 Binary files /dev/null and b/Assets/Cinema/Wedding/gyro_big.bmp differ diff --git a/Assets/Cinema/Wedding/gyro_costume.bmp b/Assets/Cinema/Wedding/gyro_costume.bmp new file mode 100644 index 0000000..44740ec Binary files /dev/null and b/Assets/Cinema/Wedding/gyro_costume.bmp differ diff --git a/Assets/Cinema/Wedding/gyro_in_costume.bmp b/Assets/Cinema/Wedding/gyro_in_costume.bmp new file mode 100644 index 0000000..6b05af0 Binary files /dev/null and b/Assets/Cinema/Wedding/gyro_in_costume.bmp differ diff --git a/Assets/Cinema/Wedding/gyro_tree.bmp b/Assets/Cinema/Wedding/gyro_tree.bmp new file mode 100644 index 0000000..4e0b276 Binary files /dev/null and b/Assets/Cinema/Wedding/gyro_tree.bmp differ diff --git a/Assets/Cinema/Wedding/in_prison.bmp b/Assets/Cinema/Wedding/in_prison.bmp new file mode 100644 index 0000000..d96f5a1 Binary files /dev/null and b/Assets/Cinema/Wedding/in_prison.bmp differ diff --git a/Assets/Cinema/Wedding/preacher.bmp b/Assets/Cinema/Wedding/preacher.bmp new file mode 100644 index 0000000..f69db31 Binary files /dev/null and b/Assets/Cinema/Wedding/preacher.bmp differ diff --git a/Assets/Cinema/Wedding/wedding_panoramic.bmp b/Assets/Cinema/Wedding/wedding_panoramic.bmp new file mode 100644 index 0000000..8486cf4 Binary files /dev/null and b/Assets/Cinema/Wedding/wedding_panoramic.bmp differ diff --git a/Assets/Dialog/Apocalypse/apocalypse.script b/Assets/Dialog/Apocalypse/apocalypse.script new file mode 100644 index 0000000..43ab3c6 --- /dev/null +++ b/Assets/Dialog/Apocalypse/apocalypse.script @@ -0,0 +1,63 @@ +L1104_whereisgyro +Brainstorming|begins|Where did the|General go|In his tiny ship? + +L1104_station +Looks like there's|a Crouton space|station not too far|from here...| + +L1104_apocalypse +...Space Station|"Apocalypse." I'll|bet he went there!|| + +L1104_letsgo +I'll show them an|apocalypse! Let's|go!|| + +L0012_bombs +bs: +This must be the|command core. It'll|have to wait,|though: sensors are|picking up four|bombs planted around|the station! I'd|better disarm them! +haiku: +See the command|core||Station scans reveal|four bombs||I must disarm them +ba: +This is the|command core.|Scanners show four|bombs planted around|the station. That's|four places I have|to go and rough|things up. Better|get started. + +L0012_defused +bs: +I defused this|bomb; on to the|next! +haiku: +This bomb is|defused||But it is not the|last one||On to another +ba: +This bomb's|disarmed. Where's|the next one? + +L0012_alldefused +bs: +That's the last! I|haven't seen Gyro|though; I'd better|get to the command|core and try to|track him from|there. +haiku: +That bomb was the|last||Now it's to the|command core||Need to find Gyro +ba: +I better head over|to the command core|and find Gyro. He's|outta bombs and he's|outta time. + +L1204_gyro_notthere +You've reached the|Command Core. Too|bad I'm not there!|I'm on Space Station|Armageddon far away! + +L1204_gyro_ofcourse +Apocalypse would|be the obvious place|for me to... retreat|to, so of course I|didn't go there! + +L1204_gyro_unfortunately +It all goes to|show why I'm a gen-|eral and you're not!|I'd love to chat but|unfortunately... + +L1204_gyro_explode +...the space station|is about to explode!|There's too much top|secret information|stored there. + +L1204_gyro_escape +Don't worry,|there's plenty of|time to escape. You|have about... 5|seconds!Hah-hah-hah! + +L1204_gyro_button +Hah-ha! Ha! Hum.|Actually, could you|press that blinking|red button over|there? Oh darn... + +L1204_gotitall +Scan shows inbound|Crouton warships!|They must be ticked|about losing that|data! We get it all? + +L1204_datahere +The data is here|All twelve|exabytes of it|That's really a lot| + +L1204_letsroll +Tight! Let's roll!|||| + diff --git a/Assets/Dialog/Appomattox/appomattox.script b/Assets/Dialog/Appomattox/appomattox.script new file mode 100644 index 0000000..a13c23d --- /dev/null +++ b/Assets/Dialog/Appomattox/appomattox.script @@ -0,0 +1,3 @@ +pause +Paused||Press B to continue| + diff --git a/Assets/Dialog/Distress/distress.script b/Assets/Dialog/Distress/distress.script new file mode 100644 index 0000000..2dab3b8 --- /dev/null +++ b/Assets/Dialog/Distress/distress.script @@ -0,0 +1,90 @@ +lady_badNews +Bee, we just heard|some distessing|news.|| + +lady_dispatched +The Council of|Planet B-12 has dis-|patched a starship|to the Crouton|Homeworld. + +lady_surrender +They're going to|sign a surrender|agreement. And they|sent Captain Flour|to do it! + +lady_bigBullies +Those Croutons are|nothing if not a|bunch of brutish|louts.| + +lady_poorCaptain +Our poor captain|will get himself|killed! We must take|action. Prepare our|royal yacht! + +captain_cider +Haiku, did you|remember the apple|cider?|| + +haiku_cider +I have the cider|That glistening gold|liquid|To warm our cold|souls + +captain_whyglum +Great! BA, why do|you look so glum?||| + +BA_surrendering +It sucks that|we're surrendering|after only two|weeks!| + +captain_winsome +Well, you win|some, you lose some.|BS, where are we|right now?| + +bs_nearKiwi +Near Planet Kiwi|and you-know-who.|Oh hello, there's|something on the|radar up ahead. + +haiku_signal +I have a signal|It's an urgent|distress call|From Lady Flower| + +captain_showit +Uh oh! Show it on|the big screen!||| + +lady_help +Help, Captain|Flour! Our ship is|being attacked by a|space gang!| + +captain_goodness +Oh my goodness!|We're on our way!||| + +lady_saved +Oh Captain, you|scared those ships|away just in time!|You saved us!| + +captain_seeyou +I did? Okay, see|you around!||| + +lady_wait +No, wait! Um, our|ship is badly|damaged! Can you|take us home?| + +captain_holdout +Do you think you|can hold out for a|few days? I kinda|have some important|business. + +lady_no +What?! No! We must|get back soon.|Sorry.|| + +captain_shuttle +BS, send over a|shuttle to pick up|Lady Flower. Haiku,|warm up some of that|apple cider! + +lady_stay +Thank you so much!|Can you stay?||| + +captain_nostuff +No, I have to go|do some stuff.||| + +lady_please +I would really|enjoy your company...|please stay.|| + +captain_nothanks +No thanks.|||| + +lady_must +You must stay.|||| + +captain_no +No.|||| + +lady_insist +We insist you|stay.||| + +captain_okay +Okay.|||| + +ba_goneawhile +The Captain's been|gone a while.|Somebody should go|check on him!| + diff --git a/Assets/Dialog/Intro/main_intro.script b/Assets/Dialog/Intro/main_intro.script new file mode 100644 index 0000000..10387c7 --- /dev/null +++ b/Assets/Dialog/Intro/main_intro.script @@ -0,0 +1,84 @@ +flour1 +As you all know,|the war with the|Croutons is going a|tad bit worse than|we had hoped for. + +flour2 +Here's our|position:||| + +flour3 +And our spies say|the Croutons are|here:|| + +flour4 +They're about to|launch their next|attack from a base|on this small moon|called Cobala: + +skippy1 +Captain Flour,|that there moon|looks kinda|familiar...| + +flour5 +That's our home|planet's moon, Major|Skippy!|| + +skippy2 +I figgered I seen|it somewhere.||| + +flour6 +So if we're going|to do something we|should do it now.|Major Skippy, your|orders? + +skippy3 +I reckon let's|round up a bunch of|fellers and go shoot|up the moon base!| + +flour7 +Yes, Sir!|||| + +intercom +"Attention! We are|approaching the LZ.|Landing party|proceed to the|dropship.|Red alert!"|(Press B) + +gyro_cornered1 +Okay! Okay!|I give up!||| + +gyro_cornered2 +I guess we're no|match for the mighty|forces of Planet|B12!| + +gyro_cornered3 +I'm General Gyro.|Tell you what:|I'll trade you some|information in|return for my life. + +gyro_cornered4 +I'll show your|commanding officer|all the secret|battle plans that|are in our computer! + +blank +|||| + +skippycapture_gyves1 +This is|BRAINIAC, our|supercomputer.|| + +skippycapture_gyves1_2 +BRAINIAC, why|don't you tell|our new friends here|anything they want|to know? + +skippycapture_brainiac1 +BRAINIAC givez it|to you straight.|:)|| + +skippycapture_skippy1 +Well hot dang!|||| + +skippycapture_skippy1_2 +So, "BRAINIAC,"|just what were you|fellers plannin to|do here on the moon|base? + +skippycapture_brainiac2 +BRAINIAC sez we|gonna capture big|B12 officer, gonna|make him tell us|lotz of stuff :) + +skippycapture_skippy2 +And just how were|you thinkin you'd do|that?|| + +skippycapture_brainiac3 +BRAINIAC sez gonna|make him think he|capture the base,|gonna trap him|later. ROFL! :) + +skippycapture_flour1 +Oh my gosh,|Major Skippy's been|captured! We have to|rescue him! Haiku?| + +skippycapture_haiku1 +Yes, Sir, what is|it?|My group and I stand|ready|To do our duty. + +skippycapture_flour2 +Take your merry|band of ninjas down|to the moon base,|sneak in, and rescue|Major Skippy! + +skippycapture_haiku2 +I will take|Quatrain,|Iambic Pentameter,|And perhaps|Free Verse. + diff --git a/Assets/Dialog/IntroBS/intro_bs.script b/Assets/Dialog/IntroBS/intro_bs.script new file mode 100644 index 0000000..6a2c483 --- /dev/null +++ b/Assets/Dialog/IntroBS/intro_bs.script @@ -0,0 +1,138 @@ +soldier_how +That entrance is|guarded! So how you|going to get in? + +bs_likeButter +Like butter,my|violent violet|friend. + +soldier_yellow +You mean yellow? + +bs_slippery +No,I mean|slippery! Watch|this... + +guard_freeze +Freeze milksop!|You're trespassing|on Crouton|territory! + +bs_actually +Actually I'm|turning myself in.|If you could just|let me by...? + +guard_moveAlong +That's different!|Move along! + +brainiac_detectIntruder +BRAINAIC detectz|intruder! (:-o + +bs_segashuating +Hey Brain, what's|up? How's it|segashuating for ya?|Don't get too comfy,|'cause I'm coming to|unplug your freakish|huge brain! + +brainiac_bringIt +BRAINIAC sez|bring it on!!|:) + +monitor_onlyCroutons +Freeze! What are|you doing here? Only|Croutons can go into|the computer room!|Move along! + +bs_idea +Hmm what's this?|Some crates,a|paintbrush,and some|paint... let's see,|that gives me an|idea! I'll just|empty this crate...|paint some eyes...|mouth... bad teeth...|and finally: + +bs_presto +Presto!|I'm a Crouton! + +bs_hangin1 +Yo homeslice,|what's up? + +grunt_hangin2 +Oh,hey there... I|haven't seen you|around before,|what's your name? + +bs_hangin3 +ba: +The name's CS,man.|So how's the war|going anyways? +any: +The name's BS,bro,|good to meet you! So|what's the word on|the war effort? + +grunt_hangin4 +Oh, it's good.|Their soldiers are|pretty tough but|their generals don't|have much nerve.|They'll probably|give up pretty soon. + +bs_hangin5 +You're tellin' me!|See ya round,man. + +monitor_openDoor +Hey there soldier!|Going in the|computer room? Hold|on... okay,door's|open! + +brainiac_wait +BRAINIAC sez|wait!! BRAINIAC|sez thiz croutonz an|imposter!! :( + +monitor_sorry +Sorry BRAINIAC!|Hold on, we'll get|him! + +brainiac_justClose +BRAINIAC sez no,|just cloze the|door!!! + +monitor_oneSecond +Okay, we'll just|grab him first! + +brainiac_idiotz +BRAINIAC thinkz|ur all idiotz!|:( + +bs_justYouAnMe +Okay Brainy it's|just you and me now.|You've sure been|causing a lot of|trouble 'round here. + +brainiac_sorry +BRAINIAC sorry.|:( + +bs_answerSomeQuestions +I'll bet! My|orders are to unplug|you for good but I|might just leave you|up and running if|you answer some|questions. + +brainiac_lovzHelping +BRAINIAC lovz|helping hiz|friendz.:) + +bs_showMe +Show me what you|know about my|planet's defenses.|Hmm that's pretty|accurate. Now show|me all the Crouton|forces. Ouch,that's|a lot. + +brainiac_notNeedBRAINIAC +BRAINIAC sez|Croutonz not|really need|BRAINIAC.:) BRAINIAC|sez Croutonz could|capture Planet B12|in their sleep.:) + +bs_gotAPoint +Hmm you've got a|point. Okay,one|more question - it's|a tough one though. + +brainiac_sezAsk +BRAINIAC sez ask|the question.:) + +bs_reallyHard +I dunno,this one's|really hard. + +brainiac_canAnswerAny +BRAINIAC can|answer any|question! :) + +bs_hereGoes +Here goes then:|how can we stop the|Croutons from taking|over Planet B12? + +brainiac_computes1 +###BRAINIAC idz|problem az|insanely NP-Hard :( + +brainiac_computes2 +###BRAINIAC|shutz down|non-essential|programz :) + +brainiac_computes3 +###BRAINIAC|overclockz self|:) + +brainiac_computes4 +###BRAINIAC|parallelizez|problem :) + +brainiac_computes5 +###BRAINIAC|uploadz data to|Crouton Net :) + +brainiac_computes6 +###BRAINIAC|checkz hiz email|:) + +brainiac_computes7 +###BRAINIAC| down-loadz data|from Crouton net :) + +bs_well +Well? + +brainiac_surrender +BRAINIAC sez|surrender iz the|only option. :( + +bs_wellSee +We'll see about|that! + diff --git a/Assets/Dialog/IntroHaiku/intro_haiku.script b/Assets/Dialog/IntroHaiku/intro_haiku.script new file mode 100644 index 0000000..e9b1fd5 --- /dev/null +++ b/Assets/Dialog/IntroHaiku/intro_haiku.script @@ -0,0 +1,69 @@ +haiku_warn +bs: +Like the early|nightingale||I cry:||Watch out! +any: +Be careful my|friends!||The radar indicates|that||Enemies are near + +haiku_askOkay +bs: +Like black ravens||The bombs burst||Are you alive||Or what? +any: +Quatrain! Iambic!||Did you get hurt|over there||Or are you okay? + +quatrain +Well I can tell|you only this:|Our situation now|seems quite dire -|For though those|pesky bombs did miss|They seem to've|open'd a river of|fire! + +haiku_goAhead +bs: +Go on without me||I'll find a way||Like the three|fingered sea. +any: +You go on ahead.||I'll find another|way in||To the Crouton base. + +haiku_enterPrison +bs: +There over there||I see Major Skippy|in the cell,||Imprisoned.||Perhaps I can free|him if the guards||Don't see me. +any: +There's Major|Skippy||If the guards do not|see me||Perhaps I can free|him. + +skippy_clues +Howdy son! If|you can just hit|this yeller button|we can get out of|here. Mind those|guards, though, they|got eyes in their|backs! + +skippy_letsGo +Ho yeah I'm glad|to see you!|Let's hightail it!! + +skippy_holdOn +Oh hey there!|Sure is a lot of|commotion round|here... maybe you|should come back|when things have|settled down! + +skippy_woowee +Woowee that was a|close one!||| + +flour_anySign +Any sign|of Quatrain and|Iambic Pentameter?|| + +haiku_theyNever +They never|returned... I fear|they have met their|fate... We will mourn|their loss. + +flour_poorIambic +Oh poor Iambic|Pentameter! You|always knew how to|set my watch! I'll|miss you! + +flour_poorQuatrain +And poor Quatrain!|You made the most|sense of all the|ninjas! I'll miss|you too! + +flour_headHome +Well I guess it's|time to head back|home.|| + +skippy_notJustYet +Not just yet! We|have to get rid of|that infernal|computer of theirs!| + +skippy_smartestThing +I reckon it's just|about the smartest|thing in this whole|galaxy!| + +skippy_loseForSure +We'll lose for|sure if we let it|keep thinkin' up|plans like it does.| + +flour_sendBS +Okay let's send|BS! He's our best|computer guy and|he's really clever.| + +flour_sabotage +He can sabotage|the computer! + diff --git a/Assets/Dialog/Landing/landing.script b/Assets/Dialog/Landing/landing.script new file mode 100644 index 0000000..314865a --- /dev/null +++ b/Assets/Dialog/Landing/landing.script @@ -0,0 +1,84 @@ +hero_checkgate +haiku: +Did I see movement||Near the gate that|lies yonder||I should look|closely +bs: +Whoa! Did Captain|Flour just go|through that gate?|I'd better take a|closer look. +any: +This sucks.|Where's Captain|Flour? I'd better|check out that gate. + +guard_dontcomecloser +Ah...Okay, don't|come much closer! + +hero_whoareyou +bs: +What's all this? +haiku: +Oh pretty flowers||That bar the path|before me||Tell me who you are +any: +Who're you? + +guard_pansies +We're the Queen's|Royal Pansies. + +hero_move +haiku: +Bright, fragile|Pansy||Gentle child of|earth and sun||Make a path for me +bs: +Oh I'm sure you|are! Move it or lose|it. +any: +Move! I'm going|after my Captain! + +guard_notpossible +That, ah, may not|be possible. Lady|Flower told us to|guard this trail.|And guard it we|will, with our...ah...|guns, if necessary! + +hero_whatever +bs: +You, your guns,|and what army? Oh,|that army! Ya know,|now that I think|about it, I heard|those whatchacallit|blue pansies saying|smack about the|purple dudes. +haiku: +I weep for you all||To resist is to|perish||For I am Haiku +any: +Whatever! + +guard_really +Really? + +bs_absolutely +Absolutely. Now|it's none of my|business but you|better straighten|things out and show|'em who's in charge|before things get|out of hand. + +guard_yeah +Yeah, you're|right! Everybody|freeze! + +hero_closedgate +haiku: +The gate, tightly|locked||I must return to the|ship||The Appomattox +bs: +Ooh nasty, they|locked the gate! I'd|better go tell the|homeboys back at the|ship. +any: +The gate's locked!|I'd better go back|to the Appomattox|and tell them what|happened. + +hero_report +haiku: +The Captain is|gone||The gate is closed|and locked||We must fly after +bs: +Dudes, Captain got|snatched by that|flower chick and the|gate they went|through is locked,|but we could still|catch them if we|flew after them|right now. +any: +Guys! That crazy|weed has kidnapped|our Captain! Let's|fly after them! + +bs_tookkey +But Captain Flour|took the ignition|key! + +ba_whataboutspare +What about the|spare? + +bs_wasspare +That was the|spare!! + +ba_guns +Well the guns|still work. + +bs_finelotofgood +Fine lot of good|that will do! + +bs_cool +Cool... + diff --git a/Assets/Dialog/Talk/talk.script b/Assets/Dialog/Talk/talk.script new file mode 100644 index 0000000..c229aae --- /dev/null +++ b/Assets/Dialog/Talk/talk.script @@ -0,0 +1,409 @@ +L0000_hero_honey +bs: +Let's see what old|queenie has tucked|away... aha, some|honey! I'll just|snag that! +haiku: +Is that candy? No.||Soda? No. Fruit? No.|Wax? No.||It is sweet honey +any: +What's this? I got|stung all those|times for lousy|honey? Give me a|break! + +L0002_bees +Hey. Watch out,|there's bees|everywhere. You|might think about|getting some bug|spray to keep them|disoriented. + +L0002_hero_spray +bs: +Not a problem,|friend-o; those bees|mess with me and|they'll be in a|world of hurt. Where|did you say the bug|spray was again? +haiku: +Stealth and clever|tricks||Is the ninja way of|life||Where to find the|spray +ba: +How can I get|some? + +L0002_village +There's some at my|village down south,|past Sunset. I'd|show you myself but|I have to hide out|and shoot some folks|if they walk by.|Have you met anyone|named Biss, Bah, or...|what was it... Poem? + +L0002_hero_no +bs: +Nope! +haiku: +Well-no not at all||No... no. I haven't|seen them||Even a little +ba: +Why do you wanna|shoot 'em? + +L0002_croutons +ba: +Oh there's a|secret deal going on|between us tree-folk|and the croutons...|very hush-hush. You|didn't hear this|from me but I|wouldn't be|surprised if that|insufferable Lady|Flower and her lot|aren't around too|much longer! +any: +Oh well; keep an|eye out! + +L0003_wolves +Howdy, partner.|Billy said he saw|some wolves slinkin'|about, so keep an|eye out. Sneaky|devils, those|wolves! + +L0003_shootfast +Out here in the|green pastures life|can be pretty rough|and tumble. Between|the wolves and the|bees ya have ter|shoot fast or die|tryin'. If yer|lookin' fer lessons|ol' Jeb can learn|ya. + +L0003_hero_jeb +haiku: +Jeb? Jeb did you|say?||Tell me more about|this Jeb||Where can he be|found? +any: +Jeb? + +L0003_nevermind +Never mind, ya|don't look the type. + +L0003_aboutjeb +Yep, ol' Jeb. He's|one acre over|eastwise. + +L0004_howdypilgrim +Howdy, pilgrim.|This here's the|start of the green|pastures, loveliest|country ya ever|seen! We been havin'|some problems with|Trakktors lately-|would ya like ter|help out? + +L0004_sure +bs: +Those blue sucky|things? Sure, I'll|help. +haiku: +The Trakktors are|strange||They are blue and|they vacuum||So I will help you +any: +Whatever. + +L0004_mindyourbusiness +Well I reckon ya|can help best by|mindin' yer own|business and movin'|along! We don't need|a bunch of strangers|makin' a fuss. And|we don't take kindly|ter sheep-rustlers|'round here neither! + +L0006_avacado +Ich zerquetsche|Sie mag ein avacado! + +L0006_hero_sayagain +bs: +Exsqueeze me? +haiku: +What language is|that?||I am a simple Ninja||I don't understand +any: +How about I crush|your face, rock-|brain?! + +L0006_fixbridge +Oh, so sorry! We|were on our way to|fix bridge when we|find tool shed|infested with bees!|Can you help us get|rid of bees? Middle|house. + +L0006_fixed +Thank you for|getting rid of bees|long enough for we|to grab tools! We|fixed the bridge,|you can cross it!|Kreuzen Sie es, wenn|Sie sich trauen. + +L0008_findspray +bs: +Ah, some cheapo|bug spray. The label|reads: intoxicates|bees and other bugs|while providing a|full day's supply of|vitamin C! +haiku: +I take this bug|spray||And somewhere along|the path||The bees are|confused +any: +Bug spray. Can.|Cool. + +L0010_mattermitter +bs: +Wonder-Port 400|mattermitter:|activate! +haiku: +Oh see: a lever||I wonder what it|will do?||Why don't we find|out? +any: +Clear!!! + +L0010_foundmask +bs: +Here's a gas mask|shaped to fit... a|giant mouse head!|Weird! Fits okay on|me though. +haiku: +What hidden|meaning||And unspoken tragedy||A mouse head gas|mask +any: +Here's a gas mask.|I'll save it for|later. + +L0010_crate +bs: +What's this? A|bunch of ammo. Way|too big for my gun...|I'll leave it. +haiku: +A box of ammo||Extremely large|caliber||Not interested +ba: +Hmm, a crate of|Magnus .50 caliber|high-impact rounds.|Lock and load! + +L0105_hero_wrangling +bs: +Oh no way, there's|a wrangling iron|under the hive!|Score! +haiku: +What's that on the|ground||It's metallic and|twisted||A wrangling iron +any: +What the heck is|this under the hive?|It's a stupid|wrangling iron! + +L0103_shootinfast +Jeb be my name,|shootin' fast be my|game. + +L0103_wrangling +Jeb be my name,|shootin' fast be my|game. If ya want|ter learn I can|teach ya, 'ceptin'|I'm too worried|about losin' my|wranglin' iron ter|concentrate right|now. + +L0103_bs_where +Okay first off|what exactly is a|wrangling iron? You|know what: never|mind. I don't want|to know. Just tell|me where this thing|is and I'll go grab|it for you. + +L0103_forest +Well, thank ya|kindly! It so|happens I let it|drop beneath a bee|hive in the rainy|forest. + +L0103_bs_figures +Bees. Typical. + +L0103_learn +There's my|wranglin' iron!|Thank ya! Lemme|learn ya how ter|shoot fast. First ya|drawl like .this.|and then you shoot|like .that. Got it?|See ya round,|partner! + +L0103_honey +My name's Lil' Ed.|I sure do love|honey! Lordy, but I|love that stuff! And|do ya know what the|best honey of all|is? Queen Bee honey,|that's right! + +L0103_hero_honeyresponse +bs: +I think I see|where this is going. +haiku: +Very interesting||I love sticky sweet|honey||And you love it too +any: +I'm more of a|saccharin person|myself. + +L0103_gethoney +There's a lil'|hive up yonder|northwise, got some|good Queen Bee|honey. I've got a|snake bite kit fer|the feller brave|enough to get me|some o' that honey. + +L0103_snakebitekit +Ya brought me some|honey! That there's|mighty good stuff.|Here's that snake|bite kit fer yer|trouble. + +L0103_seenyoubefore +My name's Lil' Ed.|I sure do love... wait|a minute, I seen you|before. Hey, I|already gave ya a|snake bite kit - let|me be! + +L0106_heysonny +Hey sonny yer|tearin' through here|a mite fast, ain't|ya? You'd best slow|down and watch out|for snakes; if you|don't have a snake|bite kit they're|deadly! + +L0106_hero_seethem +bs: +Hey yourself, old|dude. Did you like|see anybody come|through here just|now? +haiku: +I look for my|captain||A bag of flour,|kidnapped||By a begonia +ba: +Did you see a|begonia and a bag of|flour come through|here? The begonia|might have had a|gun. + +L0106_sure +Sure! I seen Lady|Flower and her new|gentleman friend|strollin' through,|headed fer the|palace. Heard there|was goin' ter be a|weddin! + +L0106_headnorth +To get on ter the|palace just head|north one acre and|then due east fer|four. You can't|scarcely miss it! + +L0108_sign +"This is Landing|Zone +@@@. Press|start in a landing|zone to see its|coordinates." + +L0205_idiot +Ein idiot sagt what? + +L0205_what +bs: +What? +haiku: +What was that you|said||I did not quite|understand||Your foreign|language +any: +You talking to me? + +L0205_forgive +Oh forgive me! How|you say... the|bridge is out. I|wait for my friends|from Sunset Village|to help fix, but|they not come long|time. You tell them,|yes? + +L0205_okay +bs: +Sure. Eh, where's|this Sunset Village? +haiku: +I will tell your|friends||When I find Sunset|Village||To give you a hand +any: +Whatever. Which|way? + +L0205_west +Just travel two|acres west, one|south. Yellow|houses, lots of|bats. Goodby, my|friend! Der|Auslander wird|vermutlich verloren. + +L0304_spores +bs: +Whoa, freakadelic!|These spores are|giving me a|headache; if it gets|any worse I might|need an oxy mask or|something. +haiku: +The silent fungus||Releasing spores in|the air||I should find a|filter +any: +Nrarg! Spores...|hurting head...|must... go back...|find... gas mask! + +L0405_ho +Ho, miscreant!|Thou shalt not pass!|Milady's wedding|draws nigh and I|will not permit|scoundrels through|the gates. + +L0405_hero_reaction +bs: +Verily! Why don't|you get off your|high horse, drop the|oldskool guard|routine, and let me|sneak a peek at the|wedding? +haiku: +Please sir let me|pass||To stop that|wedding, perhaps||Another way in +ba: +Scoundrel?! I'll|show you scoundrel! + +L0405_final_word +bs: +Oh yeah? Well why|don't you just... stop|being a... stupid blue|guy and... go away! +haiku: +Are thine ears|shut?! Verily I say:|'tis no way in! The|west gate is closed,|and the east gate,|and so too the south|gate! +any: +Nay, stay thy|wrath, Barium. Me|and mine fellows far|outnumber thee and|would surely be|victorious in|battle. + +L0612_plan +bs: +Scary! This must|be where the armies|teleport in from the|Crouton Homeworld!|That control panel|on the far wall|looks promising... +haiku: +A sinister place||It is a teleport|chamber||I see some controls +any: +Nice teleport|chamber. Better blow|it up. Those|controls on the far|wall might do the|trick. + +L0612_clearance +bs: +Oops! Looks like I|need Zeta-level|clearance to use|these controls! I|could maybe forge a|Group 6 access but|that never works|right. +haiku: +Access is denied||I need high level|clearance||Like Zeta Clearance +any: +Grr... says I need|Zeta Clearance to|use these controls.|Looks like I'll be|visiting some|Crouton outposts! + +L0612_controls +bs: +Okay it's locking|on to Planet|Crouton. In 90|seconds I can jump|in one of these|stations and blow up|their generators|from the other side. +haiku: +In ninety seconds||I will enter a|station||Bound for Crouton|World +any: +Too many buttons...|okay... setting|coordinates for|Planet Crouton... blow|up the generators|real good. Better|get to a teleport|chamber... Delay of 90|seconds?! Roids! + +L0612_go +bs: +Here we go! +haiku: +I'm set for travel||To distant Crouton|Homeworld||It is beginning +any: +...88 Mississippi,|89 Mississippi, 90|Mississipi! Let's|go! + +L0612_duke +bs: +Wait!|What's that? Oh no!|That stupid monkey|is messing with the|controls! +haiku: +An anomaly||Is there someone|tampering?||An orangutan +any: +Hold on... Someone's|screwing with the|controls! It's a|monkey! + +L0612_return +bs: +Ah, good old Kiwi|Firma! I guess|that'll stop the|teleporters for a|while and give those|grenade guys a|break! +haiku: +Haiku has returned||The teleporters|silent||Grenades have free|time +any: +I came. I saw. I'm|back. + +L0912_sign +bs: +Hmm,|"Monkey Library." +haiku: +Here's a little|sign||It reads "Monkey|Library"||That is what it says +any: +"Monkey Library."|Very cute. I hate|monkeys and I hate|reading. + +L0912_welcome +Welcome, comrad,|to the Monkey|Homeworld. It's been|under Crouton rule,|but the monkeys are|revolting! + +L0912_hero_revolt +bs: +Yes they are! How|do you get out of|this joint? +haiku: +It's a nice planet||I must leave to|travel to||The Crouton|Homeworld +any: +This isn't the|Crouton Homeworld!|That's where I was|trying to go. + +L0912_justit +That's just it:the|monkeys destroyed|the outbound|teleport generators!|What happened is|that my identical|robotic twin Patsy-|who's in the disco|right now-will time|travel into the past|twenty minutes from|now and start the|revolution! + +L0912_hero_losing +bs: +You're losing me,|doc. +haiku: +That sounds very|good||But I do not|understand||Any word you said +ba: +You're talking|jibber-jabber! + +L0912_killpatsy +Just go into the|disco right now and|shoot Patsy in the|orange shirt! He|won't mind, and I|can fix him later!|Then you can|teleport to planet|Crouton! + +L0912_hero_brokenteleport +bs: +Hmm this rig seems|broken. +haiku: +In the teleport||I am vexed and|frustrated||It does not function +any: +This gimmick's|broken! That chaps|my hide. + +L0912_hero_startteleport_nopassword +bs: +Fire up this ride,|daddy-o! +haiku: +Set coordinates||For the Crouton Home|Planet||Bid monkeys goodbye +any: +Activate teleport! + +L0912_needpassword +I'm sorry, you|need a password! + +L0912_hero_startteleport_password +bs: +Fire up this ride,|daddy-o!|Password is Gravy. +haiku: +Set coordinates||For the Crouton Home|Planet||Password is Gravy +any: +Activate teleport! + +L0912_ba_givepassword +I'll give you a|password: shut up|and do it! + +L1000_needbomb +bs: +This gate is sooo|not jake. I'm gonna|need a really big|bomb or something to|blow it up! +haiku: +This is a huge|gate||And I cannot get|past it||Maybe a big bomb? +grenade: +Your end is|near, O evil|ones. I am the bomb! +any: +Gonna need a big|bomb to get through|here! Oh yeah. + +L1000_freeze +bs: +Hey! Back away|from the space ship,|General Wacko! +haiku: +You crazy crouton||If you know what's|good for you||You'll hold it right|there +any: +It's over, Gyro! + +L1000_toolate +bs: +Too late! And by|the way, it's|General "Gyro,"|though I suspect you|knew that! +haiku: +Too late! I'm|outta here! +any: +When monkeys|fly, BA! You're|too late; I'm outta|here! + +L1000_follow +bs: +Woo but he's|slippery! We have to|follow him! +haiku: +Gyro has escaped||We won't let him|get away||We will follow him +any: +It's never too|late. + +L1010_amking +I am King|Grenade. Maybe|you need some help?|Maybe you want to|blow something up?|I am the bomb. + +L1010_cannotleave +But I cannot|leave now. Every|day, more Croutons|teleport here from|their homeworld. You|need my help? I need|your help. Find the|teleport generators,|destroy them! + +L1010_readytogo +You have|destroyed the|teleport generators!|I shall go with you,|help you now. I will|wait for you in your|space ship. + +L1012_hero_readbook +"Monkeys and|Croutons have been|enemies since|ancient times. While|Croutons are|smarter, they're|also lazier. For|instance, 'Gravy'|has been the Crouton|password for over|four centuries now..." + +L1212_anytime +bs: +Get ready, gang.|That annoying|blue guy should be|coming through from|Kiwi any minute now!|We're ready for him|this time! +haiku: +Get ready, gang.|That weird green|guy should be coming|through from Kiwi|any minute now!|We're ready for him|this time! +any: +Get ready, gang.|That stupid red|guy should be coming|through from Kiwi|any minute now!|We're ready for him|this time! + +L1212_yeah +Yeah! Yeah! + +L1212_makesure +Just make sure|he doesn't make|it up North and blow|up the teleport|generators. + +L1212_suckstobehim +Sucks to be him|when he comes|through this|teleport! + diff --git a/Assets/Dialog/Wedding/wedding.script b/Assets/Dialog/Wedding/wedding.script new file mode 100644 index 0000000..6c124ca --- /dev/null +++ b/Assets/Dialog/Wedding/wedding.script @@ -0,0 +1,110 @@ +preacher_blah +Blah, blah, blah,|blah. Blah blah.||| + +preacher_reasons +Can anyone think|of any reasons why|these two should not|be joined in Holy|Moly? + +hero_reasons +bs: +Totally! Homeboy|Captain here was|snatched against his|will-being!| +haiku: +Yes.Dog chases cat|But cat hates it,|like captain|What a strange|offspring +any: +Yeah! Captain|don't wanna!||| + +captain_thanks +haiku: +Eh? Anyways...|thanks for coming.|Actually I've kinda|changed my mind|about, uh, you know. +any: +Oh, hey there. Um,|thanks for coming.|Actually I've kinda|changed my mind|about, uh, you know. + +captain_cake +There's lots of|swell cake and punch|here, so if we could|sort of keep going...| + +lady_byallmeans +By all means!|It's all been so|fast we've neglected|to invite your|friends,naughty boy. + +lady_radio +Why don't we radio|the Appomattox and|have the rest of the|crew come and join|us? + +preacher_takebegonia +Do you, Captain|Flour, take this|begonia to be your|lawfully wedded|wife? + +gyro_bs +PSST! BS! Come|here a minute and|check out my new|calculator!| + +preacher_takesack +And do you, Lady|Flower, take this|sack of flour to be|your lawfully wedded|husband? + +gyro_ba +PSST! BA! You|wanna see a video of|a space station|getting eaten by a|giant camel? + +preacher_pronounce +I now pronounce|you man and wife.|You may plant a wet|one.| + +gyro_haiku +PSST! Haiku! I|think I just saw|Quatrain over here|behind the bushes!| + +preacher_married +Okay you guys are|married now. It's|time to party!|| + +gyro_notsofast +Not so fast!|||| + +captain_why +Why not, my dainty|flower friend?||| + +gyro_reveals +Aha! I'm not a|flower at all! I'm|General Gyro, and I|have a little|present for you! + +captain_thankyou +Why thank you,|General Gyro! Is it|yummy?|| + +gyro_notyummy +No it's not yummy!|It's your friends!|I've captured your|whole gang and|locked them up! + +gyro_recall +If you'll recall|you were on your way|to surrender to the|Crouton Empire.| + +gyro_surrender +I simply want you|to sign this|surrender form and|I'll return your|crew. Otherwise... + +gyro_difficult +I've landed eight|platoons of troops|in the kingdom and|they'll be making|life... difficult! + +captain_okay +Oh. Er, okay, I|guess. What do you|think, dear?|| + +lady_dontbesilly +Don't be silly,|Captain. Go beat up|the guards and|rescue your friends!| + +flour_heyguys +Hey guys, what's|up? Let's go back|down and grab some|cake!| + +bs_explain +...saw someone|sneaking around and|I was pretty sure it|was Gyro.| + +bs_explain2 +So I got up from|the wedding real|quiet-like and went|to teach him a|lesson... + +captain_interrupt +Sorry to interrupt|but the misses and I|have to take off on|our honeymoon!| + +captain_tellyouwhat +Tell you what,|though: General Gyro|sure seems to be|causing a lot of|trouble. + +captain_key +Here's the key to|the Appomattox; why|don't you guys fly|around...| + +captain_dosomething +...And see if you|can't do something|about him and his|Crouton armies!| + +captain_camp +The misses says|their main base is|probably in an old|warehouse in the|frozen north-east! + +bs_driving +Well she starts up|fine but she seems|to be burning a lot|of oil.| + +bs_palace +We could fly to|the palace and start|looking there. I|think the coordi-|nates were *}}%. + diff --git a/Assets/Dialog/pause.script b/Assets/Dialog/pause.script new file mode 100644 index 0000000..a13c23d --- /dev/null +++ b/Assets/Dialog/pause.script @@ -0,0 +1,3 @@ +pause +Paused||Press B to continue| + diff --git a/Assets/Music/Trailer.mp3 b/Assets/Music/Trailer.mp3 new file mode 100644 index 0000000..3af2494 Binary files /dev/null and b/Assets/Music/Trailer.mp3 differ diff --git a/Assets/Music/alarm.gbm b/Assets/Music/alarm.gbm new file mode 100644 index 0000000..030ebb6 --- /dev/null +++ b/Assets/Music/alarm.gbm @@ -0,0 +1,58 @@ +//FGB +//Alarm/panic +//Jacob Stevens +notesPerSecond 10 + +track 1 //countermelody + + counterA + + .repeat + counterB, counterB + jmp .repeat + +track 2 //melody + + melodyA + .repeat + melodyB, melodyC + jmp .repeat + +track 3 //bass + bassA + .repeat + bassB,bassB,bassB,bassB + jmp .repeat + +track 1 +counterA: +E5 D5# D5 C5# + +track 1 +counterB: +C5,h5 F5#,h5 +D5#,h D5 C5# + +track 2 +melodyA: +A5# A5 G5# G5 + +track 2 +melodyB: +F5#,h F5#,h +F5#,h A5,h +A6,h A5,h +D5#,h D6#,h + +track 2 +melodyC: +-16 + +track 3 +bassA: +E4 D4# D4 C4# + +track 3 +bassB: +C4 C4# D4 D4# +E4 D4# D4 C4# \ No newline at end of file diff --git a/Assets/Music/beehive.gbm b/Assets/Music/beehive.gbm new file mode 100644 index 0000000..600cbe3 --- /dev/null +++ b/Assets/Music/beehive.gbm @@ -0,0 +1,132 @@ +//FGB +//Bee Hive +//Jacob Stevens +notesPerSecond 10 //one note equals one sixteenth + +track 1 //countermelody + + counterA,counterB,counterC + + .repeat + + counterD,counterD,counterD,counterD + counterE,counterE + + jmp .repeat + +track 2 //melody + + melodyA,melodyB,melodyC + + .repeat + + melodyD,melodyE,melodyD,melodyE + melodyF,melodyF + + jmp .repeat + +track 3 //bass + + bassA,bassB,bassC + + .repeat + + bassD,bassD,bassD,bassD + bassE,bassE + + jmp .repeat + +//counter +track 1 +counterA: +D5# E5 F5 F5# + +track 1 +counterB: +G5 G5 -2 +-2 F5# F5# +G5 G5 -2 +-2 F5# F5# + +track 1 +counterC: +G5 G5 F5# F5# +G5 G5 F5# F5# +G5 G5 F5# F5# +G5 G5 F5# F5# + +track 1 +counterD: +-16 + +track 1 +counterE: +C6,h7 +C6#,h3 D6,h3 + +//melody +track 2 +melodyA: +-4 + +track 2 +melodyB: +-16 + +track 2 +melodyC: +-8 +C6# F6# B6 F7# +F7 C7 C7# F6# + +track 2 +melodyD: +G6,h5 F6#,h +G6,h5 F6#,h + +track 2 +melodyE: +G6,h A6# D7 +A6#,h A6# A6 +G6# G6 F6# F6 +E6 D6# D6 C6# + +track 2 +melodyF: +C6,h G6 F6# +G6,h C7,h +G6# G6 G6#,h +A6,h D7,h + +//bass +track 3 +bassA: +G3# A3 A3# B3 + +track 3 +bassB: +C4 C4 -2 +-2 C4# C4# +C4 C4 -2 +-2 C4# C4# + +track 3 +bassC: +C4 C4 C4# C4# +C4 C4 C4# C4# +C4 C4 C4# C4# +C4 C4 C4# C4# + +track 3 +bassD: +C4,h3 +C5,h C4,h +B3,h B4,h +A3#,h A4#,h + +track 3 +bassE: +C4,h3 +C5,h C4,h +C4#,h C5#,h +D4,h D5,h \ No newline at end of file diff --git a/Assets/Music/cowboy.gbm b/Assets/Music/cowboy.gbm new file mode 100644 index 0000000..4179006 --- /dev/null +++ b/Assets/Music/cowboy.gbm @@ -0,0 +1,121 @@ +//FGB +//Cowboy +//Jacob Stevens +notesPerSecond 4 //quarter = 80, one note equals one triplet + +track 1 //countermelody + instrument1 0044A23286 + + counterA,counterA + + .repeat + counterA,counterB,counterA,counterB + counterC,counterD,counterE,counterF + counterA + jmp .repeat + +track 2 //melody + + melodyA,melodyB + + .repeat + melodyC,melodyD,melodyE,melodyG + melodyH,melodyJ,melodyK,melodyL + melodyB + jmp .repeat + +//counter +track 1 +counterA: +C5,h G4 +A4,h G4 +C5,h G4 +A4,h G4 + +track 1 +counterB: +F4,h C4 +D4,h C4 +F4,h C4 +D4,h C4 + +track 1 +counterC: +C5,h2 +E5,h G5 +B4,h2 +D5,h G5 + +track 1 +counterD: +A4,h2 +C5,h E5 +F4,h2 +A4,h C5 + +track 1 +counterE: +G4,h8 +G4,h2 + +track 1 +counterF: +C4,h G4 +A4,h G4 +C5,h G4 +A4,h G4 + +//melody +track 2 +melodyA: +-12 + +track 2 +melodyB: +-11 +G6 + +track 2 +melodyC: +G6,h5 +E6,h2 +C6,h2 + +track 2 +melodyD: +G5,h A5,h6 +G6,h2 + +track 2 +melodyE: +G6,h5 +E6,h2 +G6,h2 + +track 2 +melodyG: +A6,h8 +C6,h D6 + +track 2 +melodyH: +E6,h2 E6,h2 +D6,h2 +E6,h +D6 + +track 2 +melodyJ: +C6,h B5 +C6,h +A5,h3 +A5,h2 + +track 2 +melodyK: +G5,h2 C6,h2 D6,h +C6,h3 + +track 2 +melodyL: +C6,h11 diff --git a/Assets/Music/death.gbm b/Assets/Music/death.gbm new file mode 100644 index 0000000..0b07d32 --- /dev/null +++ b/Assets/Music/death.gbm @@ -0,0 +1,115 @@ +//FGB +//death tune +//Jacob Stevens +notesPerSecond 4 //quarter = 120, one note equals one eighth + +track 1 //countermelody + instrument1 0044A23286 + .repeat + counterA,counterA,counterA,counterA + counterB,counterB,counterC,counterD + counterE,counterF,counterE,counterG + counterE,counterF,counterE,counterG + jmp .repeat + +track 2 //melody + .repeat + melodyA,melodyA,melodyB,melodyC + melodyA,melodyA,melodyB,melodyC + melodyD,melodyE,melodyF,melodyG + melodyD,melodyH,melodyJ,melodyG + jmp .repeat + +track 3 //bass + .repeat + bassA,bassA,bassB,bassC + bassA,bassA,bassB,bassC + bassC,bassD,bassC,bassC + bassC,bassD,bassC,bassC + jmp .repeat + +//counter melody +track 1 +counterA: +-8 + +track 1 +counterB: +D6,h2 E6,h2 E6,h + +track 1 +counterC: +D6,h2 C6,h2 A5#,h + +track 1 +counterD: +C6,h7 + +track 1 +counterE: +E5,h3 G5,h3 + +track 1 +counterF: +D5,h3 F5,h3 + +track 1 +counterG: +C6,h3 E6,h3 + +//melody +track 2 +melodyA: +B5,h2 C6,h2 G5,h + +track 2 +melodyB: +A5#,h2 A5,h2 G5,h + +track 2 +melodyC: +C5,h7 + +track 2 +melodyD: +G6,h2 E6 C6,h G5,h + +track 2 +melodyE: +A5#,h3 A5,h A5# A5 + +track 2 +melodyF: +G5,h C6,h5 + +track 2 +melodyG: +-8 + +track 2 +melodyH: +A5#,h3 +A5,h +C6 D6 + +track 2 +melodyJ: +E6,h7 + +//bass +track 3 +bassA: +C4 G4 C5,h5 + +track 3 +bassB: +G4 A5# D6,h5 + +track 3 +bassC: +C4 G4 C5 C5,h G4 C5 G4 + +track 3 +bassD: +A3# F4 A4# A4#,h F4 A4# F4 + diff --git a/Assets/Music/fgbwar.gbm b/Assets/Music/fgbwar.gbm new file mode 100644 index 0000000..0c793a3 --- /dev/null +++ b/Assets/Music/fgbwar.gbm @@ -0,0 +1,148 @@ +//FGB +//War +//Jacob Stevens + +notesPerSecond 10 + +track 1 //countermelody + .repeat + + counterA,counterA,counterA,counterA + counterB,counterB,counterB,counterB + counterC,counterD,counterA,counterA + counterA,counterA,counterB,counterB + counterB,counterB,counterC,counterD + counterE + + jmp .repeat + +track 2 //melody + .repeat + + melodyA,melodyA,melodyA,melodyA + melodyA,melodyA,melodyB,melodyB + melodyB,melodyB,melodyA,melodyA + melodyA,melodyA,melodyA,melodyA + melodyB,melodyB,melodyB,melodyB + melodyC + + jmp .repeat + +track 3 //bass + .repeat + + bassA,bassA,bassB,bassB + bassB,bassB,bassB,bassB + bassB,bassB,bassA,bassA + bassB,bassB,bassB,bassB + bassB,bassB,bassB,bassB + bassC + + jmp .repeat + +track 4 //percussion + .repeat + + percA,percA,percA,percA + percA,percA,percA,percA + percA,percA,percA,percA + percA,percA,percA,percA + percA,percA,percA,percA + percB + + jmp .repeat + +//countermelody + +track 1 +counterA: +-20 + +track 1 +counterB: +C7,h5 G6,h5 +F6#,h3 +A6#,h B6,h + +track 1 +counterC: +C7 B6 A6# A6 G6# G6 +F6# F6 E6 D6# D6 C6# +C6 B5 A5# A5 +G5# G5 F5# F5 + +track 1 +counterD: +F5# G5 G5# A5 A5# B5 +C6 C6# D6 D6# E6 F6 +F6# G6 G6# A6 +A6# B6 C7 C7# + +track 1 +counterE: +C7 C7 -2 -2 +D7# D7# -2 +C7 C7 -2 -2 +D7# D7# C7 C7 +D7# D7# C7 C7 +D7# D7# C7 C7 + +//melody +track 2 +melodyA: +-20 + +track 2 +melodyB: +C5 D5# F5 F5# G5 G5# +C6 A5 G5# G5 F5# D5# +F5# D5# C5 D5# +A4# C5# D5 F5 + +track 2 +melodyC: +F5# F5# -2 -2 +A5 A5 -2 +F5# F5# -2 -2 +A5 A5 F5# F5# +A5 A5 F5# F5# +A5 A5 F5# F5# + +//bass +track 3 +bassA: +C4,h5 +C4,h5 +F4,h3 +A3#,h3 + +track 3 +bassB: +C4,h C5,h C5,h +C4,h C5,h C5,h +F4#,h F5#,h +A3#,h A4#,h + +track 3 +bassC: +C4 C4 -2 -2 C4 C4 -2 +C4 C4 -2 -2 +C4 C4 C4 C4 +C4 C4 C4 C4 +C4 C4 C4 C4 + +//percussion + +track 4 +percA: +ta,- sn,- sn,- +ta,- sn,- sn,- +ta,- sn,- +ta,- sn,- + +track 4 +percB: +sn - sn - sn - sn - +sn - sn - sn - sn - +sn - sn - sn - sn - +sn - sn - diff --git a/Assets/Music/frosty.gbm b/Assets/Music/frosty.gbm new file mode 100644 index 0000000..3e85025 --- /dev/null +++ b/Assets/Music/frosty.gbm @@ -0,0 +1,253 @@ +//FGB +//Frosty +//Jacob Stevens +notesPerSecond 9 //quarter ~ 140, one note equals one sixteenth + +track 1 //countermelody + + counterA,counterB + + .repeat + counterC,counterC,counterC,counterD + counterD,counterE,counterF,counterC + counterC,counterD,counterD,counterE + counterG,counterG,counterH,counterJ + counterC + jmp .repeat + +track 2 //melody + + melodyA, melodyB + + .repeat + melodyC,melodyC,melodyD,melodyE + melodyF,melodyG,melodyC,melodyC + melodyD,melodyE,melodyF,melodyG + melodyH,melodyJ,melodyK,melodyL + melodyM + jmp .repeat + +track 3 //bass + + bassA, bassB + + .repeat + bassC,bassC,bassC,bassD + bassD,bassD,bassC,bassC + bassC,bassD,bassD,bassD + bassC,bassE,bassF,bassG + bassC + jmp .repeat + +track 4 //percussion + + percA,percB + .repeat + percC + jmp .repeat + +//counter melody segments + +track 1 +counterA: +-16 + +track 1 +counterB: +-8 +F5,h3 +E5,h3 + +track 1 +counterC: +-2 D5#,h +-2 D5#,h +-2 D5#,h +-2 D5#,h + +track 1 +counterD: +-2 F5,h +-2 F5,h +-2 D5#,h +-2 D5#,h + +track 1 +counterE: +-2 G5,h +-2 F5,h +-2 E5,h +-2 E5,h + +track 1 +counterF: +-2 E5,h +-2 E5,h +-2 D5#,h +-2 D5#,h + +track 1 +counterG: +-2 E5,h +-2 E5,h +-2 E5,h +-2 E5,h + +track 1 +counterQ: +-2 E5,h +-2 E5,h +-2 F5,h +-2 F5,h + +track 1 +counterH: +-2 E5,h +-2 E5,h +-2 F5,h +-2 F5,h + +track 1 +counterJ: +-2 G5,h +-2 G5,h +-2 F5,h +-2 B5,h + +//melody segments +track 2 +melodyA: +D6#,h D6,h +C6,h2 A5# +C6,h A5#,h +G5#,h2 G5 + +track 2 +melodyB: +F5,h D5#,h +C5#,h2 D5# +C5#,h3 +C5,h3 + +track 2 +melodyC: +-16 + +track 2 +melodyD: +G6,h3 +D6#,h2 F6 +G6,h C7,h3 B6 C7 + +track 2 +melodyE: +C7#,h C7#,h +C7#,h C7#,h +C7,h5 B6 C7 + +track 2 +melodyF: +C7#,h C7#,h +C7#,h C7#,h +C7,h C7,h +C7,h C7,h + +track 2 +melodyG: +A6#,h G6#,h +G6,h F6,h +E6,h7 + +track 2 +melodyH: +-8 +G6 F6 E6 F6 +G6,h C7,h + +track 2 +melodyJ: +G6,h C7,h +G6,h3 +G6# G6 F6 G6 +G6#,h G6#,h + +track 2 +melodyK: +G6,h7 +F6 D6# D6 C6 +A5#,h D6,h + +track 2 +melodyL: +D6# F6 G6 G6# +A6#,h D6#,h +D6 F6 A6 D7 +G6 D6 B5 G5 + +track 2 +melodyM: +C6,h15 + +//bass sections + +track 3 +bassA: +-16 + +track 3 +bassB: +-8 +C4#,h3 C4,h3 + +track 3 +bassC: +C4,h C5,h +G3,h C5,h +C4,h C5,h +G3,h C5,h + +track 3 +bassD: +C4#,h C5#,h +G3#,h C5#,h +C4,h C5,h +G3,h C5,h + +track 3 +bassE: +C4,h C5,h +G3,h C5,h +F4,h F5,h +C4,h F5,h + +track 3 +bassF: +C4,h C5,h +G3,h C5,h +A3#,h A4#,h +F4,h A4#,h + +track 3 +bassG: +D4#,h D5#,h +A3#,h D5#,h +D4,h D5,h +G3,h G4,h + +//percussion sections +track 4 +percA: +-16 + +track 4 +percB: +-8 +sn,-3 +sn,-3 + +track 4 +percC: +-2 sn,- +-2 sn,- +-2 sn,- +-2 sn,- \ No newline at end of file diff --git a/Assets/Music/hoedown.gbm b/Assets/Music/hoedown.gbm new file mode 100644 index 0000000..37a3540 --- /dev/null +++ b/Assets/Music/hoedown.gbm @@ -0,0 +1,153 @@ +//FGB +//Hoedown!!! (Mad Coyboys) +//Jacob Stevens +notesPerSecond 10 //one note equals one sixteenth + +track 1 //countermelody + + counterA + + .repeat + + counterB,counterC,counterB,counterB + counterB,counterD,counterE,counterB + + jmp .repeat + +track 2 //melody + + melodyA + + .repeat + + melodyB,melodyC,melodyB,melodyD + melodyB,melodyE,melodyF,melodyG + + jmp .repeat + +track 3 //bass + + bassA + + .repeat + + bassB,bassC,bassB,bassD + bassB,bassE,bassF,bassB + + jmp .repeat + +//counter +track 1 +counterA: +-4 + +track 1 +counterB: +-2 G5,h +-2 G5,h +-2 G5,h +-2 G5,h + +track 1 +counterC: +-2 A5,h +-2 A5,h +-2 A5,h +-2 A5,h + +track 1 +counterD: +-2 F5,h +-2 F5,h +-2 F5,h +-2 F5,h + +track 1 +counterE: +B5,h3 +B5,h3 +-2 G5,h +-2 G5,h + +//melody +track 2 +melodyA: +D6 E6 F6 F6# + +track 2 +melodyB: +G6,h G6 G6 +G6,h G6,h +A6,h G6,h +E6,h C6,h + +track 2 +melodyC: +G5,h +A5,h7 +-2 +D6 E6 F6 F6# + +track 2 +melodyD: +D6,h11 +-2 F6 F6# + +track 2 +melodyE: +A6,h A6 A6 +A6,h A6,h +B6,h A6,h +F6,h D6,h + +track 2 +melodyF: +G6 A6 G6,h +G6 A6 G6,h +G6 A6 G6 F6 +D6 B5 G5 B5 + +track 2 +melodyG: +C6,h11 +D6 E6 F6 F6# + +//bass +track 3 +bassA: +-4 + +track 3 +bassB: +C4,h E5,h +G3,h E5,h +C4,h E5,h +G3,h E5,h + +track 3 +bassC: +F4,h F5,h +C5,h F5,h +F4,h F5,h +C5,h F5,h + +track 3 +bassD: +G3,h B4,h +D4,h B4,h +G3,h B4,h +D4,h B4,h + +track 3 +bassE: +D4,h A4,h +A3,h A4,h +D4,h A4,h +A3,h A4,h + +track 3 +bassF: +G4,h3 +G4,h3 +G3,h B4,h +D4,h B4,h \ No newline at end of file diff --git a/Assets/Music/intro_cinema.gbm b/Assets/Music/intro_cinema.gbm new file mode 100644 index 0000000..69daef3 --- /dev/null +++ b/Assets/Music/intro_cinema.gbm @@ -0,0 +1,286 @@ +//FGB +//Introduction (Cinema) Music +//Jacob Stevens +notesPerSecond 5 //quarter = 80, one note equals one sixteenth + +track 1 //countermelody + .repeat + instrument1 0044F23286 + counterA,counterB,counterC,counterC + counterA,counterB,counterD,counterE + counterA,counterB,counterC,counterC + counterA,counterB,counterD,counterF + counterD,counterF,counterG,counterH + jmp .repeat + +track 2 //melody + .repeat + instrument2 80F70887 + melodyA + melodyB + melodyC + melodyA + melodyD + melodyE + melodyF + melodyA + melodyB + melodyC + melodyA + melodyD + melodyG + melodyH + melodyG + melodyJ + melodyK + melodyL + jmp .repeat + +track 3 //bass + .repeat + bassA,bassB,bassC,bassC + bassA,bassB,bassD,bassD + bassA,bassB,bassC,bassC + bassA,bassB,bassD,bassE + bassD,bassE,bassD,bassA + jmp .repeat + +track 4 //percussion + .repeat + percA + jmp .repeat + + +///////Counter Melody Segments + +track 1 +counterA: +G5,h7 +D5#,h7 + +track 1 +counterB: +C5,h7 +G5,h7 + +track 1 +counterC: +B5,h7 +G5,h3 +D5,h3 + +track 1 +counterD: +E5,h7 +E5,h3 +E5,h +A4 +C5# + +track 1 +counterE: +E5,h7 +E5,h3 +E5,h +A4 +E5 + +track 1 +counterF: +D5,h7 +B5,h3 +G5,h1 +B4 +D5 + +track 1 +counterG: +A5,h15 + +track 1 +counterH: +-16 + +/////////Melody Segments +track 2 +melodyA: +C6,h7 +G5,h5 +C6,h + +track 2 +melodyB: +G6#,h5 +G6 +F6 +D6#,h5 +C6,h + +track 2 +melodyC: +D6,h27 +G5,h +G5,h + +track 2 +melodyD: +G6#,h5 +G6 +F6 +D6#,h5 +D6,h + +track 2 +melodyE: +C6#,h15 + +track 2 +melodyF: +C6,h7 +C6,h3 +C6,h +A5 +B5 + +track 2 +melodyG: +C6# +C6#,h +C6# +C6# +C6#,h +C6# +C6# +C6#,h +C6# +C6# +C6#,h +C6# + +track 2 +melodyH: +D6 +D6,h +D6 +D6 +D6,h +D6 +D6 +D6,h +D6 +D6 +D6,h +D6 + +track 2 +melodyJ: +D6 +D6,h +D6 +D6 +D6,h +D6 +G6 +G6,h +G6 +G6 +G6,h +G6 + +track 2 +melodyK: +A6 +A6,h +A6 +A6 +A6,h +A6 +A6,h7 + +track 2 +melodyL: +-16 + +/////////Bass Segments +track 3 +bassA: +C4 +C4 +C4,h +C4,h +C4 +C4 +C4 +C4 +C4,h +C4,h +C4 +C4 + +track 3 +bassB: +G4# +G4# +G4#,h +G4#,h +G4# +G4# +D4# +D4# +D4#,h +D4#,h +D4# +D4# + +track 3 +bassC: +G4 +G4 +G4,h +G4,h +G4 +G4 +G4 +G4 +G4,h +G4,h +G4 +G4 + +track 3 +bassD: +A4 +A4 +A4,h +A4,h +A4 +A4 +A4 +A4 +A4,h +A4,h +A4 +A4 + +track 3 +bassE: +G4 +G4 +G4,h +G4,h +G4 +G4 +G4 +G4 +G4,h +G4,h +G4 +G3 + +/////////Percussion Segments +track 4 +PercA: +sn,sn,sn,- +sn,-,sn,sn +sn,sn,sn,- +sn,-,sn,sn diff --git a/Assets/Music/jazzy.gbm b/Assets/Music/jazzy.gbm new file mode 100644 index 0000000..6de53aa --- /dev/null +++ b/Assets/Music/jazzy.gbm @@ -0,0 +1,225 @@ +//FGB +//Jazzy (BS?) +//Jacob Stevens +notesPerSecond 8 //quarter = 120, one note equals one sixteenth + +track 1 //countermelody + + counterA,counterA + + .repeat + counterB,counterC,counterB,counterC + counterB,counterC,counterB,counterC + counterB,counterC,counterD,counterE + counterD,counterF + jmp .repeat + +track 2 //melody + + melodyA,melodyA + + .repeat + + melodyB,melodyC,melodyB,melodyC + melodyB,melodyC,melodyD,melodyE + melodyD,melodyE,melodyF,melodyG + melodyF,melodyH + + jmp .repeat + +track 3 //bass + + bassA,bassB + + .repeat + + bassC,bassD,bassC,bassD + bassE,bassF,bassE,bassF + bassE,bassF,bassG,bassH + bassJ,bassK + + jmp .repeat + +track 4 //percussion + + percA,percA + + .repeat + percA,percA,percA,percA + percB,percB,percB,percB + percB,percB,percB,percB + percB,percB + jmp .repeat + +//counter +track 1 +counterA: +-16 + +track 1 +counterB: +-4 +C6,h2 C6 +C6 C6 C6,h +-4 + +track 1 +counterC: +-4 +D6#,h2 D6# +D6# D6# D6#,h +-4 + +track 1 +counterD: +G5,h2 G5 +G5,h2 G5 +E5,h2 E5 +E5,h2 E5 + +track 1 +counterE: +F5,h2 F5 +F5,h2 F5 +B4,h2 B4 +B4,h2 B4 + +track 1 +counterF: +F5,h2 F5 +F5,h2 F5 +B4,h2 B4 +-4 + +//melody +track 2 +melodyA: +-16 + +track 2 +melodyB: +-4 +A5#,h2 A5# +A5# A5# A5#,h +-4 + +track 2 +melodyC: +-4 +C6,h2 C6 +C6 C6 C6,h +-4 + +track 2 +melodyD: +- C6 F6 F6# +G6,h2 D6# +E6 C6,h6 + +track 2 +melodyE: +- C6 D6# E6 +F6,h2 D6# +F6 D6# F6 D6# +F6# G6,h2 + +track 2 +melodyF: +B6 A6# A6 G6# +G6,h2 D6# +E6 D6# D6 C6# +C6,h3 + +track 2 +melodyG: +A6 G6# G6 F6# +F6,h2 A5# +B5 A5# A5 G5# +G5,h3 + +track 2 +melodyH: +A6 G6# G6 F6# +F6 G6# A6 A6# +B6 A6# A6 G6# +G6,h3 + +//bass +track 3 +bassA: +-16 + +track 3 +bassB: +-12 +G5 A5#,h2 + +track 3 +bassC: +C6,h3 +-8 +G5 A5#,h2 + +track 3 +bassD: +F5,h3 +-8 +G5 A5#,h2 + +track 3 +bassE: +C5,h C5,h +A5#,h2 C5 +C6 C6 C6,h +A5#,h G5,h + +track 3 +bassF: +F5,h F5,h +D6#,h2 F5 +F6 F6 F6,h +G5 A5#,h2 + +track 3 +bassG: +E6,h3 +E5,h3 +A5,h3 +A6,h3 + +track 3 +bassH: +D6,h3 +D5,h3 +G5,h3 +G6,h3 + +track 3 +bassJ: +E6,h3 +E5,h3 +A5,h3 +A6,h3 + +track 3 +bassK: +D6,h3 +D5,h3 +G5,h3 +G5 A5#,h2 + +//perc +track 4 +percA: +rd,-3 +rd,-2 rd +rd,-3 +rd,-2 rd + + +track 4 +percB: +rd rd rd,- +sn sn,- sn +rd,- rd rd +sn sn,- sn \ No newline at end of file diff --git a/Assets/Music/jungle.gbm b/Assets/Music/jungle.gbm new file mode 100644 index 0000000..5877082 --- /dev/null +++ b/Assets/Music/jungle.gbm @@ -0,0 +1,153 @@ +//FGB +//Jungle? (Maybe Swamp) +//Jacob Stevens 1901 +notespersecond 9 //one note = sixteenth +transpose -2 + +track 1 + + .repeat + + counterA,counterB,counterA,counterB + counterC,counterD,counterC,counterD + counterF,counterG,counterA,counterB + counterF,counterG,counterA,counterB + + jmp .repeat + +track 2 + .repeat + + melodyA,melodyB,melodyC,melodyB + melodyA,melodyB,melodyD,melodyB + melodyE,melodyF,melodyG,melodyB + melodyE,melodyF,melodyA,melodyB + + jmp .repeat + +track 3 + .repeat + + bassA,bassB,bassA,bassB + bassC,bassD,bassC,bassD + bassE,bassF,bassA,bassB + bassE,bassF,bassA,bassB + + jmp .repeat + +//counter +track 1 +counterA: +G5,h2 G5,h2 G5,h3 G5#,h +G5,h G5,h + +track 1 +counterB: +G5,h2 G5 +G5,h G5,h3 G5#,h +G5,h G5,h + +track 1 +counterC: +C5,h2 C5,h2 C5,h3 C5#,h +C5,h C5,h + +track 1 +counterD: +C5,h2 C5 +C5,h C5,h3 C5#,h +C5,h C5,h + +//track 1 //unused +//counterE: + +track 1 +counterF: +G5,h2 G5 +G5,h3 +-8 + +track 1 +counterG: +A5#,h2 A5# +A5#,h3 +G5#,h2 G5# +G5#,h3 + +//melody + +track 2 +melodyA: +C6 C6# C6,h +-12 + +track 2 +melodyB: +-16 + +track 2 +melodyC: +C6 C6# D6# C6# +C6 C6# C6 A5# +C6 C6# C6 A5# +C6,h3 + +track 2 +melodyD: +C6 C6# D6# F6 +F6# F6 D6# C6# +C6 A5# G5# F5# +F5 D5# F5,h + +track 2 +melodyE: +C6,h5 C6# D6# +F6 G6 G6# G6 +F6 G6 G6# G6 + +track 2 +melodyF: +D6#,h F6 G6 +G6# G6 F6 D6# +C6#,h D6# F6 +G6 F6 D6# C6# + +track 2 +melodyG: +C6,h15 + +//bass +track 3 +bassA: +C4,h2 C4,h2 C4,h3 C4#,h +C4,h C4,h + +track 3 +bassB: +C4,h2 C4 +C4,h C4,h3 C4#,h +C4,h C4,h + +track 3 +bassC: +F4,h2 F4,h2 F4,h3 F4#,h +F4,h F4,h + +track 3 +bassD: +F4,h2 F4 +F4,h F4,h3 F4#,h +F4,h F4,h + +track 3 +bassE: +C4,h2 C4 +C4,h3 +-8 + +track 3 +bassF: +D4#,h2 D4# +D4#,h3 +C4#,h2 C4# +C4#,h3 \ No newline at end of file diff --git a/Assets/Music/lady_flower.gbm b/Assets/Music/lady_flower.gbm new file mode 100644 index 0000000..f929443 --- /dev/null +++ b/Assets/Music/lady_flower.gbm @@ -0,0 +1,128 @@ +//FGB +//lady flower +//Jacob Stevens +notesPerSecond 4 //quarter = 120, one note equals one eighth + +track 1 //countermelody + instrument1 0044A23286 + + counterA + + .repeat + + counterB,counterC,counterB,counterC + counterD,counterE,counterD,counterF + counterB,counterC,counterB,counterC + counterD,counterE,counterD,counterF + counterH,counterJ,counterK,counterB + counterH,counterJ,counterK,counterL + counterH,counterJ,counterB,counterC + jmp .repeat + +track 2 //melody + instrument2 80F70887 + + melodyA + + .repeat + melodyB,melodyB,melodyC,melodyD + melodyC,melodyE,melodyB,melodyB + melodyC,melodyD,melodyC,melodyF + melodyG,melodyG,melodyH,melodyJ + melodyG,melodyG,melodyH,melodyK + melodyL,melodyM,melodyM,melodyN + jmp .repeat + +//counter +track 1 +counterA: +-2 + +track 1 +counterB: +C4 E4 G4 B4 E5 G5 + +track 1 +counterC: +B5 G5 E5 B4 G4 E4 + +track 1 +counterD: +D4 F4 A4 D5 F5 A5 + +track 1 +counterE: +D6 B5 G5 F5 D5 B4 + +track 1 +counterF: +G3 B3 D4 F4 G4 B4 + +track 1 +counterH: +F3 A3 C4 F4 A4 C5 + +track 1 +counterJ: +F5 C5 A4 F4 C4 A3 + +track 1 +counterK: +C4# F4 G4# B5# F5 G5# + +track 1 +counterL: +D3# F3 A3# D4# F4 A4# + +//melody +track 2 +melodyA: +E6,h + +track 2 +melodyB: +E6,h9 D6 E6 + +track 2 +melodyC: +F6 E6 D6 C6 B5 A5 + +track 2 +melodyD: +G5,h3 D6,h + +track 2 +melodyE: +G5,h D5,h D6,h + +track 2 +melodyF: +G5,h D5,h D6,h + +track 2 +melodyG: +F6,h2 E6 D6 E6 + +track 2 +melodyH: +F6 D6# C6# D6# F6 D6# + +track 2 +melodyJ: +E6,h5 + +track 2 +melodyK: +G6 D6# F6 G6 D6# G6 + +track 2 +melodyL: +A6,h5 + +track 2 +melodyM: +-6 + +track 2 +melodyN: +-4 E6,h \ No newline at end of file diff --git a/Assets/Music/main_in_game.gbm b/Assets/Music/main_in_game.gbm new file mode 100644 index 0000000..bed093d --- /dev/null +++ b/Assets/Music/main_in_game.gbm @@ -0,0 +1,771 @@ +//FGB +//Main In-Game Music +//Jacob Stevens +notesPerSecond 30 //quarter ~= 160, one note equals 1/12 of 1 beat + +track 1 //countermelody + + counterA,counterB,counterB,counterB,counterC //intro + + .repeat + instrument1 0044F23286 + counter1A,counter1B,counter1C,counter1D //counter set 1 + counter1A,counter1B,counter1C,counter1E + counter1F,counter1G,counter1C,counter1E + counter1F,counter1G,counter1H,counter1F + counter1J,counter1K,counter1L + + counter2A,counter2B,counter2C,counter2D //counter set 2 + counter2A,counter2B,counter2C,counter2E + counter2F,counter2G,counter2H,counter2J + counter2F,counter2K,counter2L,counter2M + counter2N,counter2O,counter2P + + counter3A,counter3B,counter3A,counter3A //counter set 3 + counter3A,counter3B,counter3A,counter3A + counter3C,counter3D,counter3A,counter3A + counter3C,counter3E,counter3F,counter3G + counter3H,counter3J,counter3K + + jmp .repeat + +track 2 //melody + + melodyA,melodyA,melodyB,melodyC,melodyD //intro + instrument2 80F70887 + .repeat + melodyE,melodyF,melodyG,melodyE //main repeating melody + melodyH,melodyJ,melodyK,melodyL + melodyM,melodyN,melodyO,melodyP + melodyQ + jmp .repeat + +track 3 //bass + + bassA,bassA,bassA,bassA,bassB //bass intro + + .repeat + + bass1A,bass1B,bass1A,bass1C //bass set 1 + bass1A,bass1B,bass1A,bass1C + bass1D,bass1E,bass1J,bass1J + bass1K,bass1L,bass1M,bass1N + bass1F,bass1G,bass1H + + bass2A,bass2B,bass2A,bass2C //bass set 2 + bass2A,bass2B,bass2A,bass2C + bass2D,bass2E,bass2F,bass2F + bass2D,bass2G,bass2H,bass2J + bass2K,bass2L,bass2M + + bass3A,bass3B,bass3A,bass3A //bass set 3 + bass3A,bass3B,bass3A,bass3A + bass3C,bass3C,bass3A,bass3A + bass3C,bass3D,bass3E,bass3F + bass3G,bass3H,bass3J + + jmp .repeat + +track 4 //percussion + + percA,percA,percA,percA,percB //percussion intro + + .repeat + + percC,percC,percC,percD //perc 1 + percC,percC,percC,percD + percE,percF,percB,percB + percE,percF,percD,percD + percF,percA,percG + + percC,percC,percC,percD //perc 2 (same as 1) + percC,percC,percC,percD + percE,percF,percB,percB + percE,percF,percD,percD + percF,percA,percG + + perc3A,perc3B,perc3A,perc3A //perc 3 + perc3A,perc3B,perc3A,perc3A + perc3C,perc3C,perc3A,perc3A + perc3C,perc3D,perc3C,perc3C + perc3C,perc3E,perc3F + + + + jmp .repeat + +//counter melody track +//intro segments +track 1 +counterA: +-48 + +track 1 +counterB: +C5,h11 +C5,h3 C5,h3 C5,h3 +C5,h11 +C5,h3 C5,h3 C5,h3 + +track 1 +counterC: +G4,h11 +G4,h3 G4,h3 G4,h3 +G4,h11 +G4,h3 G4,h3 G4,h3 + +//counter set 1 +track 1 +counter1A: +C5,h23 +E5,h23 + +track 1 +counter1B: +D5,h23 +F5,h23 + +track 1 +counter1C: +E5,h23 +G5,h23 + +track 1 +counter1D: +C6,h23 +G5,h23 + +track 1 +counter1E: +C6,h23 +E5,h23 + +track 1 +counter1F: +F5,h23 +G5#,h23 + +track 1 +counter1G: +C5,h23 +G5#,h23 + +track 1 +counter1H: +A5#,h23 +G5,h23 + +track 1 +counter1J: +G5#,h23 +G5,h23 + +track 1 +counter1K: +A5,h23 +F5,h23 + +track 1 +counter1L: +A5,h23 +C6,h23 + +//counter set 2 + +track 1 +counter2A: +E5,h11 +G4,h11 +C5,h11 +E5,h11 + +track 1 +counter2B: +F5,h11 +D5,h11 +A4#,h11 +D5,h11 + +track 1 +counter2C: +E5,h11 +C5,h11 +E5,h11 +G5,h11 + +track 1 +counter2D: +C6,h11 +G5,h11 +C6,h11 +G6,h11 + +track 1 +counter2E: +C6,h11 +G5,h11 +C6,h11 +C6,h5 E6,h5 + +track 1 +counter2F: +F6,h5 C6,h5 +G5#,h5 C6,h5 +G5#,h5 F5,h5 +C5,h5 F5,h5 + +track 1 +counter2G: +G5#,h5 F5,h5 +G5#,h5 C6,h5 +F6,h5 C6,h5 +D6#,h5 C6#,h5 + +track 1 +counter2H: +C6,h2 D6,h2 G6,h5 +C6,h5 G5,h5 +E5,h5 G5,h5 +C6,h5 G5,h5 + +track 1 +counter2J: +E5,h5 C5,h5 +E5,h5 G5,h5 +C6,h2 G5,h2 C6,h2 E6,h2 +C6,h2 G5,h2 C6,h2 E6,h2 + +track 1 +counter2K: +G5#,h5 F5,h5 +G5#,h5 C6,h5 +F6,h5 C6,h5 +D6#,h5 F6,h5 + +track 1 +counter2L: +G5,h5 A5#,h5 +A5#,h5 G5,h5 +A5#,h5 A5#,h5 +G5,h5 A5#,h5 + +track 1 +counter2M: +G5#,h5 F5,h5 +F5,h5 G5#,h5 +F5,h5 F5,h5 +G5#,h5 F5,h5 + +track 1 +counter2N: +C5#,h5 F5,h5 +G5#,h5 C6#,h5 +D6#,h5 A5#,h5 +A5#,h2 G5,h2 D5#,h2 G5,h2 + +track 1 +counter2O: +A5,h11 +A5,h3 C6,h3 F6,h3 +A6,h11 +A6,h3 F6,h3 C6,h3 + +track 1 +counter2P: +A5,h11 +A5,h3 C6,h3 F6,h3 +A6,h11 +C6,h3 C6,h3 C6,h3 + +//counter set 3 + +track 1 +counter3A: +G5,h5 -6 +-6 C6,h5 +G5,h5 G5,h5 +-12 + +track 1 +counter3B: +-6 F5,h5 +-6 F5,h2 F5,h2 +-6 F5,h5 +-6 F5,h5 + +track 1 +counter3C: +G5#,h5 -6 +-6 C5,h5 +G5#,h2 G5#,h2 -6 +C5,h11 + +track 1 +counter3D: +G5#,h5 -6 +-6 C5,h5 +G5#,h2 G5#,h2 -6 +G5#,h11 + +track 1 +counter3E: +G5#,h5 -6 +-6 C5,h5 +G5#,h2 G5#,h2 -6 +-12 + +track 1 +counter3F: +A5#,h5, -6 +-6 G5,h5 +A5#,h2 A5#,h2 -6 +G5,h11 + +track 1 +counter3G: +G5#,h5 -6 +-6 F5,h5 +G5#,h2 G5#,h2 -6 +F5,h11 + +track 1 +counter3H: +G5#,h5 -6 +-6 F5,h5 +G5#,h2 G5#,h2 -6 +G5#,h11 + +track 1 +counter3J: +A5,h11 +A5,h3 C6,h3 F6,h3 +A6,h11 +A6,h3 F6,h3 C6,h3 + +track 1 +counter3K: +A5,h11 +A5,h3 C6,h3 F6,h3 +A6,h11 +C6,h3 C6,h3 C6,h3 + +//melody track +track 2 +melodyA: +-48 + +track 2 +melodyB: +F4,h11 +F4,h3 F4,h3 F4,h3 +A4#,h11 +A4#,h3 A4#,h3 A4#,h3 + +track 2 +melodyC: +D5#,h3 D5#,h3 D5#,h3 +G5#,h3 G5#,h3 G5#,h3 +C6#,h3 C6#,h3 C6#,h3 +F6#,h3 F6#,h3 F6#,h3 + +track 2 +melodyD: +G6,h11 +G6,h3 G6,h3 G6,h3 +G6,h11 +G6,h3 G6,h3 G6,h3 + +track 2 +melodyE: +G6,h11 +E6,h11 +C6,h11 +G5,h11 + +track 2 +melodyF: +A5#,h23 +A5,h11 +A5#,h5 A5,h5 + +track 2 +melodyG: +G5,h11 +C6,h83 + +track 2 +melodyH: +A5#,h23 +A5,h11 +A5#,h5 C6,h5 + +track 2 +melodyJ: +E6,h83 +F6,h5 G6,h5 + +track 2 +melodyK: +G6#,h83 +G6,h5 F6,h5 + +track 2 +melodyL: +E6,h2 F6,h2 G6,h77 +F6,h5 G6,h5 + +track 2 +melodyM: +G6#,h83 +G6,h5 G6#,h5 + +track 2 +melodyN: +A6#,h17 +D6#,h17 +D7#,h11 + +track 2 +melodyO: +C7#,h35 +C7,h5 A6#,h5 + +track 2 +melodyP: +G6#,h23 +G6#,h23 + +track 2 +melodyQ: +A6,h95 + +//track 3 +//intro +track 3 +bassA: +C4,h11 +C4,h3 C4,h3 C4,h3 +C4,h11 +C4,h3 C4,h3 C4,h3 + +track 3 +bassB: +G3,h11 +G3,h3 G3,h3 G3,h3 +G3,h11 +G3,h3 G3,h3 G3,h3 + +//bass 1 +track 3 +bass1A: +C4,h11 +C5,h3 C4,h3 C4,h3 +C4,h11 +C5,h3 C4,h3 C4,h3 + +track 3 +bass1B: +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 + +track 3 +bass1C: +C4,h11 +C5,h3 C4,h3 C4,h3 +C4,h3 G4,h3 C5,h3 +G5,h3 C5,h3 G4,h3 + +track 3 +bass1D: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F5,h5 F4,h5 + +track 3 +bass1E: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F4,h5 G4,h5 + +track 3 +bass1F: +D5#,h17 D5#,h5 +E5#,h17 E5#,h5 + +track 3 +bass1G: +F4,h11 +F4,h3 F4,h3 F4,h3 +F4,h11 +F4,h3 F4,h3 F4,h3 + +track 3 +bass1H: +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 + +track 3 +bass1J: +C4,h17 C4,h5 +G4,h5 G4,h5 +C5,h5 C5,h5 + +track 3 +bass1K: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F5,h5 F4,h5 + +track 3 +bass1L: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F4,h5 E4,h5 + +track 3 +bass1M: +D4#,h17 +A3#,h17 +D4#,h11 + +track 3 +bass1N: +C4#,h17 G3#,h5 +C4#,h17 G3#,h5 + +//bass 2 +track 3 +bass2A: +C4,h11 +C5,h3 C4,h3 C4,h3 +C4,h11 +C5,h3 C4,h3 C4,h3 + +track 3 +bass2B: +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 + +track 3 +bass2C: +C4,h11 +C5,h3 C4,h3 C4,h3 +C4,h3 G4,h3 C5,h3 +G5,h3 C5,h3 G4,h3 + +track 3 +bass2D: +F4,h17 +C5,h17 +C4,h11 + +track 3 +bass2E: +F4,h17 +C5,h17 +F4,h5 G4,h5 + +track 3 +bass2F: +C4,h17 C4,h5 +G4,h5 G5,h5 +C5,h5 C5,h5 + +track 3 +bass2G: +F4,h17 +C5,h17 +F4,h5 E4,h5 + +track 3 +bass2H: +D4#,h17 +A3#,h17 +D4#,h11 + +track 3 +bass2J: +C4#,h17 G3#,h5 +C4#,h17 G3#,h5 + +track 3 +bass2K: +D5#,h17 D5#,h5 +E5#,h17 E5#,h5 + +track 3 +bass2L: +F4,h11 +F4,h3 F4,h3 F4,h3 +F4,h11 +F4,h3 F4,h3 F4,h3 + +track 3 +bass2M: +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 + +//bass 3 +track 3 +bass3A: +C4,h5 -6 +-6 G4,h5 +C4,h5 C4,h5 +-12 + +track 3 +bass3B: +-6 A3#,h5 +-6 A3#,h2 A3#,h2 +-6 A3#,h5 +-6 A3#,h5 + +track 3 +bass3C: +F4,h5 -6 +-6 C4,h5 +F4,h2 F4,h2 -6 +C4,h11 + +track 3 +bass3D: +F4,h5 -6 +-6 C4,h5 +F4,h2 F4,h2 -6 +-12 + +track 3 +bass3E: +D4#,h5 -6 +-6 A3#,h5 +D4#,h2 D4#,h2 -6 +A3#,h11 + +track 3 +bass3F: +C4#,h5 -6 +-6 G3#,h5 +C4#,h2 C4#,h2 -6 +G3#,h11 + +track 3 +bass3G: +C4#,h5 -6 +-6 G3#,h5 +C4#,h2 C4#,h2 -6 +D4#,h11 + +track 3 +bass3H: +F4,h11 +F4,h3 F4,h3 F4,h3 +F4,h11 +F4,h3 F4,h3 F4,h3 + +track 3 +bass3J: +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 + +//percussion +//perc 1 +track 4 +percA: +sn,-11 +sn,-3 sn,-3 sn,-3 +sn,-11 +sn,-3 sn,-3 sn,-3 + +track 4 +percB: +sn,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 + +track 4 +percC: +bs,-11 +sn,-3 sn,-3 sn,-3 +bs,-11 +sn,-3 sn,-3 sn,-3 + +track 4 +percD: +bs,-5 sn,-5 +sn,-5 bs,-5 +sn,-5 sn,-5 +sn,-2 sn,-2 sn,-5 + +track 4 +percE: +bs,-5 bs,-5 +sn,-5 sn,-5 +bs,-5 bs,-5 +sn,-5 sn,-5 + +track 4 +percF: +sn,-5 sn,-5 +tb,-5 tb,-5 +ta,-5 ta,-5 +bs,-2 sn,-2 sn,-5 + +track 4 +percG: +bs,-3 sn,-3 sn,-3 +bs,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 + +//perc 3 +track 4 +perc3A: +sn,-5 -6 +-6 sn,-5 +sn,-5 sn,-5 +-12 + +perc3B: +-6 sn,-5 +-6 sn,-2 sn,-2 +-6 sn,-5 +-6 sn,-5 + +perc3C: +sn,-5 -6 +-6 sn,-5 +sn,-5 sn,-5 +sn,-11 + +perc3D: +sn,-5 -6 +-6 sn,-5 +sn,-2 sn,-2 -6 +-12 + +perc3E: +sn,-11 +sn,-3 sn,-3 sn,-3 +sn,-11 +sn,-3 sn,-3 sn,-3 + +perc3F: +bs,-3 sn,-3 sn,-3 +bs,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 +sn,-3 sn,-3 sn,-3 diff --git a/Assets/Music/maybe_haiku.gbm b/Assets/Music/maybe_haiku.gbm new file mode 100644 index 0000000..944c6a9 --- /dev/null +++ b/Assets/Music/maybe_haiku.gbm @@ -0,0 +1,287 @@ +//FGB +//Haiku? +//Jacob Stevens +notesPerSecond 8 + +track 1 //countermelody + + instrument1 0044B23286 + + counterrest,counterrest,counterA,counterB //intro + counterC,counterD,counterA,counterB + counterC,counterD + + .repeat + + counterE,counterE,counterF,counterF //main + counterE,counterE,counterF,counterF + counterG,counterH,counterL,counterJ + counterK,counterK,counterL,counterL + + jmp .repeat + +track 2 //melody + + instrument2 80F70887 + + melodyA,melodyA,melodyB,melodyC //intro + melodyD,melodyE,melodyB,melodyC + melodyD,melodyE + + .repeat + + melodyB,melodyC,melodyD,melodyE //main + melodyB,melodyC,melodyD,melodyE2 + melodyF,melodyG,melodyF,melodyG + melodyH,melodyJ,melodyK,melodyA + + jmp .repeat + +track 3 //bass + + bassXA,bassXA,bassXA,bassXA //intro + bassXB,bassXB,bassXA,bassXA + bassXB,bassXC + + .repeat + + bassA,bassA,bassB,bassB //main + bassA,bassA,bassB,bassC + bassD,bassE,bassD,bassE + bassF,bassF,bassG,bassG + + jmp .repeat + +track 4 //percussion + + percA,percB,percC,percC //intro + percC,percC,percC,percC + percC,percC + + .repeat + + percD,percD,percD,percD + percD,percD,percD,percD + percD,percD,percD,percD + percD,percD,percD,percD + + jmp .repeat + +//counter +track 1: +counterrest: +-16 + +track 1 +counterA: +C6,h7 +E5,h7 + +track 1 +counterB: +G5,h7 +E5,h7 + +track 1 +counterC: +F5,h7 +G5#,h7 + +track 1 +counterD: +G5#,h7 +F5,h7 + +track 1 +counterE: +C5 G4 E4 G4 +C5 G4 E4 G4 +C5 G4 E4 G4 +C5 G4 E4 G4 + +track 1 +counterF: +C5# G4# F4 G4# +C5# G4# F4 G4# +C5# G4# F4 G4# +C5# G4# F4 G4# + +track 1 +counterG: +A5,h7 +A5,h7 + +track 1 +counterH: +A5#,h7 +A5#,h7 + +track 1 +counterJ: +A5# F5# C5# A4# +A5# F5# C5# A4# +A5# F5# C5# A4# +A5# F5# C5# A4# + +track 1 +counterK: +C5# G5# F4 G5# +C5# G5# F4 G5# +C5# G5# F4 G5# +C5# G5# F4 G5# + +track 1 +counterL: +A5 F5 C5 A4 +A5 F5 C5 A4 +A5 F5 C5 A4 +A5 F5 C5 A4 + +//melody +track 2 +melodyA: +-16 + +track 2 +melodyB: +G6,h5 E6,h +C6,h7 + +track 2 +melodyC: +-4 +E6,h3 +C6,h3 +E6,h3 + +track 2 +melodyD: +C6#,h5 F6,h +G6#,h7 + +track 2 +melodyE: +-4 +F6,h3 +G6#,h3 +A6#,h A6 G6# + +track 2 +melodyE2: +D6#,h5 G6,h +A6#,h7 + +track 2 +melodyF: +F6,h F6 A6 +C7,h F6 A6 +C7,h C7,h +C7,h A6 F6 + +track 2 +melodyG: +F6#,h F6# A6# +C7#,h F6# A6# +C7#,h C7#,h +C7#,h A6# F6# + +track 2 +melodyH: +F6,h D6#,h +F6,h D6# A5# +G5,h A5#,h5 + +track 2 +melodyJ: +-2 D6#,h +F6,h D6# A5# +G5,h A5#,h +D6#,h E6,h + +track 2 +melodyK: +F6,h15 + +//bass +track 3 +bassXA: +C5,h C5,h3 G4,h +C5,h C5,h5 + +track 3 +bassXB: +C5#,h C5#,h3 G4#,h +C4#,h C4#,h5 + +track 3 +bassXC: +C5#,h C5#,h3 G4#,h +C5#,h +F3# G3 G3# A3 A3# B3 + +track 3 +bassA: +C4,h C4,h +C5,h C4,h +C4,h C5,h +C4,h C5,h + +track 3 +bassB: +C4#,h C4#,h +C5#,h C4#,h +C4#,h C5#,h +C4#,h C5#,h + +track 3 +bassC: +D4#,h D4#,h +D5#,h D4#,h +D4#,h D5#,h +D4#,h D5#,h + +track 3 +bassD: +F4,h F4,h F4,h F4,h +F4,h F4,h F4,h F4,h + +track 3 +bassE: +F4#,h F4#,h F4#,h F4#,h +F4#,h F4#,h F4#,h F4#,h + +track 3 +bassF: +C4#,h C4#,h C4#,h C4#,h +D4#,h D4#,h D4#,h D4#,h + +track 3 +bassG: +F4,h F4,h C4,h C4,h +F4,h F4,h C4,h C4,h + +//percussion +track 4 +percA: +-16 + +track 4 +percB: +sn,-3 +sn,-3 +sn,- sn,- +sn,- sn sn + +track 4 +percC: +sn,- sn,- +sn sn sn,- +sn,- sn,- +sn sn sn,- + +track 4 +percD: +sn sn sn sn +sn,- sn sn +sn sn sn,- +sn,- sn sn \ No newline at end of file diff --git a/Assets/Music/moon_base_ba.gbm b/Assets/Music/moon_base_ba.gbm new file mode 100644 index 0000000..6250acf --- /dev/null +++ b/Assets/Music/moon_base_ba.gbm @@ -0,0 +1,369 @@ +//FGB +//Moon Base (BA) Music +//Jacob Stevens +notesPerSecond 8 //quarter = 120, one note equals one sixteenth + +track 1 //countermelody + counterA,counterB,counterA,counterC //intro + counterD,counterE,counterF + + .repeat + counterA,counterA,counterA,counterA //main + counterA,counterG,counterF,counterH + counterA,counterA,counterA,counterA + counterG,counterF,counterH,counterA + counterA,counterJ,counterK,counterL + counterM,counterN,counterJ,counterK + counterL,counterM,counterN + jmp .repeat + +track 2 //melody + + //melodyA,melodyB,melodyA,melodyC //intro + + melbassA,melbassB,melbassA,melbassC //new intro + melodyA,melodyD,melodyE + + .repeat + melodyA,melodyA,melodyF,melodyG //main + melodyH,melodyJ,melodyK,melodyL + melodyA,melodyF,melodyG,melodyH + melodyJ,melodyK,melodyL,melodyA + melodyA,melodyM,melodyN,melodyO + melodyP,melodyQ,melodyM,melodyN + melodyO,melodyP,melodyN + jmp .repeat + +track 3 //bass + bassRest,bassRest,bassRest,bassRest //intro + bassA,bassA,bassC + + .repeat + bassD,bassD,bassD,bassD //main + bassD,bassD,bassE,bassD + bassD,bassD,bassD,bassD + bassD,bassF,bassG,bassH + bassJ,bassK,bassK,bassK + bassK,bassK,bassK,bassK + bassK,bassK,bassL + jmp .repeat + +track 4 //percussion + + percA,percA,percA,percA //intro + percA,percA,percA + + .repeat + percB,percB,percB,percB //main + percB,percB,percC,percB + percB,percB,percB,percB + percB,percC,percC,percC + percC,percD,percD,percD + percD,percD,percD,percD + percD,percD,percD + + jmp .repeat + +//counter melody +track 1 +counterA: +-16 + +track 1 +counterB: +-4 +C7,h3 +C7,h3 +C7,h3 + +track 1 +counterC: +C7,h C6,h +C7,h C6,h +C7,h C6,h +C7,h C6,h + +track 1 +counterD: +D5#,h C5,h +F5#,h D5#,h +A5,h F5#,H +C6,h A5,h + +track 1 +counterE: +D6#,h C6,h +F6#,h D6#,h +A6,h A6#,h +C7,h A6,h + +track 1 +counterF: +C7,h3 +C7,h3 +C7,h C7,h +C7,h C7 C7 + +track 1 +counterG: +F6# F6 E6 D6# +G6# G6 F6# F6 +A6# A6 G6# G6 +C7 B6 A6# A6 + +track 1 +counterH: +C7,h3 +-12 + +track 1 +counterJ: +B6,h -2 +-12 + +track 1 +counterK: +B6,h B6,h +-12 + +track 1 +counterL: +B6 B6 B6,h +B6,h B6,h +-8 + +track 1 +counterM: +B6,h F6,h +B6,h F6,h +B6,h F6,h +B6 B6 F6,h + +track 1 +counterN: +B6,h15 + +//melody +track 2 +melbassA: +C5,h A4#,h +D5#,h C5,h +F5#,h D5#,h +C5,h A4#,h + +track 2 +melbassB: +C5,h C5,h +F7#,h3 +F7#,h3 +F7#,h3 + +track 2 +melbassC: +C5,h C5,h +F6#,h F7#,h +F6#,h F7#,h +F6#,h F7#,h + +track 2 +melodyA: +-16 + +track 2 +melodyB: +-4 +F7#,h3 +F7#,h3 +F7#,h3 + +track 2 +melodyC: +F6#,h F7#,h +F6#,h F7#,h +F6#,h F7#,h +F6#,h F7#,h + +track 2 +melodyD: +C6 C6 C5#,h +C6 C6 C5#,h +C6 C6 C5#,h +C6 C6 C5#,h + +track 2 +melodyE: +F6#,h3 +F6#,h3 +F6#,h F6#,h +F6#,h F6# F6# + +track 2 +melodyF: +C6,h5 A5# C6 +D6#,h C6#,h +G5#,h A5#,h + +track 2 +melodyG: +C6,h5 A5# C6 +D6#,h C6#,h +F6#,h F6,h + +track 2 +melodyH: +F6#,h5 +F6 F6# +A6# A6 G6# G6 +C7 B6 A6# A6 + +track 2 +melodyJ: +D7# D7 C7# C7 +F7# F7 E7 D7# +A7# A7 G7# G7 +C8 B7 A7# A7 + +track 2 +melodyK: +C8,h3 +C8,h3 +C8,h C8,h +C8 C8 C8,h + +track 2 +melodyL: +C8,h3 +-12 + +track 2 +melodyM: +F6,h -2 +-12 + +track 2 +melodyN: +F6,h F6,h +-12 + +track 2 +melodyO: +F6 F6 F6,h +F6,h F6,h +-8 + +track 2 +melodyP: +F6,h B5,h +F6,h B5,h +F6,h B5,h +F6 F6 B5,h + +track 2 +melodyQ: +F6,h15 + +//bass +track 3 +bassRest: +-16 + +track 3 +bassA: +C5,h A4#,h +D5#,h C5,h +F5#,h D5#,h +C5,h A4#,h + +track 3 +bassB: +C5,h C5,h +-12 + +track 3 +bassC: +C6,h C5,h +C6,h C5,h +C6 F5# C5,h +C6 F5# C5,h + +track 3 +bassD: +C4 C4 C5 C4 +F4# F4# F5# F4# +D4# D4# D5# D4# +C4# C4# C5# C4# + +track 3 +bassE: +C4 B3 A3# D4# +C4 F4# F4 G4 +D4# C4# G3 A3# +D4# C4# G3 A3# + +track 3 +bassF: +C4 B3 A3# D4# +C4 F4# F4 G4 +D4# C4# G3 A3# +D4# C4# G3 A3# + +track 3 +bassG: +C4 B3 A3# D4# +C4 F4# F4 G4 +D4# C4# G3 A3# +D4# C4# G3 A3# + +track 3 +bassH: +C4 B3 A3# D4# +C4 F4# F4 G4 +G4 C5 A4# A4 +G4# G4 F4# F4 + +track 3 +bassJ: +F4# A4# A4 G4# +D5# D5 C5# C5 +A4# F4# D4# A3# +C4# D4 D4# E4 + +track 3 +bassK: +F4 F4 F5 F4 +B4 B4 B5 B4 +G4# G4# G5# G4# +F4# F4# F5# F4# + +track 3 +bassL: +F4 F4 F5 F4 +B4 B4 B5 B4 +G4# G4# G5# G4# +F4# D4# D4 C4# + +//percussion +track 4 +percA: +-16 + +track 4 +percB: +bs bs bs,- +sn,- bs,- +bs bs bs,- +sn,h sn sn + +track 4 +percC: +bs bs sn sn +tb tb ta ta +bs bs sn sn +tb tb ta ta + +track 4 +percD: +-2 sn - +-2 sn sn +sn,- sn sn +sn sn sn,- diff --git a/Assets/Music/moon_base_haiku.gbm b/Assets/Music/moon_base_haiku.gbm new file mode 100644 index 0000000..416e7e4 --- /dev/null +++ b/Assets/Music/moon_base_haiku.gbm @@ -0,0 +1,301 @@ +//FGB +//Moon Base (Haiku) Music +//Jacob Stevens +notesPerSecond 9 //quarter = 140, one note equals one sixteenth + +track 1 //countermelody + instrument1 0044A23286 + counterA,counterB,counterC,counterD //intro + counterE,counterE + + .repeat + counterF,counterG,counterF,counterG //main + counterH,counterH,counterJ,counterJ + counterH,counterH,counterJ,counterK + counterE,counterE + jmp .repeat + +track 2 //melody + instrument2 80F70887 + melodyA,melodyB,melodyC,melodyD //intro + melodyE,melodyF + + .repeat + melodyG,melodyH,melodyG,melodyJ //main + melodyK,melodyL,melodyM,melodyN + melodyO,melodyP,melodyQ,melodyR + melodyS,melodyF + jmp .repeat + +track 3 //bass + + bassA,bassB,bassB,bassC //intro + bassD,bassD + + .repeat + bassE,bassF,bassE,bassF //main + bassG,bassG,bassH,bassH + bassG,bassG,bassH,bassJ + bassD,bassD + jmp .repeat + +track 4 //percussion + + percA,percB,percB,percC + percC,percD + + .repeat + percC,percC,percC,percC + percC,percD,percD,percD + percD,percD,percD,percD + percD,percD + jmp .repeat + +//counter +track 1 +counterA: +-2 + +track 1 +counterB: +G6,h D6#,h +C6,h D6#,h +C6,h G5,h +D5#,h G5,h + +track 1 +counterC: +D5#,h C5,h +D5#,h G5#,h +C6,h G5#,h +C6,h D6#,h + +track 1 +counterD: +F5,h D5,h +F5,h A5#,h +D6,h A5#,h +D6,h F6#,h + +track 1 +counterE: +E6 C6 G5 E5 +C6 G5 E5 C5 +G5 E5 C5 G4 +E5 C5 G4 E4 + +track 1 +counterF: +G5 E5 C5 G4 +G5 E5 C5 G4 +G5 E5 C5 G4 +G5 E5 C5 G4 + +track 1 +counterG: +A5 F5# D5 A4 +A5 F5# D5 A4 +A5 F5# D5 A4 +A5 F5# D5 A4 + +track 1 +counterH: +G5 D5 A4# G4 +G5 D5 A4# G4 +G5 D5 A4# G4 +G5 D5 A4# G4 + +track 1 +counterJ: +G5# D5# C5 G4# +G5# D5# C5 G4# +G5# D5# C5 G4# +G5# D5# C5 G4# + +track 1 +counterK: +A5# F5 D5 A4 +A5# F5 D5 A4 +A5# F5 D5 A4 +A5# F5 D5 A4 + +//melody +track 2 +melodyA: +A6# B6 + +track 2 +melodyB: +C7,h G6,h +D6#,h G6,h +D6#,h C6,h +G5,h C6,h + +track 2 +melodyC: +G5#,h D5#,h +G5#,h C6,h +D6#,h C6,h +D6#,h G6#,h + +track 2 +melodyD: +A5#,h F5,h +A5#,h D6,h +F6,h D6,h +F6,h A6#,h + +track 2 +melodyE: +C7,h15 + +track 2 +melodyF: +-16 + +track 2 +melodyG: +-2 C6,h +D6,h E6,h +G6,h E6,h5 + +track 2 +melodyH: +F6#,h D6,h +F6#,h A6,h +D7,h7 + +track 2 +melodyJ: +D6,h A5,h +D6,h F6#,h +A6,h3 +A6,h3 + +track 2 +melodyK: +A6#,h5 G6,h +D6,h7 + +track 2 +melodyL: +A6#,h5 G6,h +D6,h3 A6#,h3 + +track 2 +melodyM: +C7,h5 G6#,h +D6#,h7 + +track 2 +melodyN: +C7,h5 G6#,h +D6#,h3 G6#,h3 + +track 2 +melodyO: +G6,h5 D6,h +A5#,h7 + +track 2 +melodyP: +G6,h3 +D6,h3 +A5#,h3 +G5,h3 + +track 2 +melodyQ: +G5#,h5 +C6,h +D6#,h7 + +track 2 +melodyR: +A5#,h3 +D6,h3 +F6,h7 + +track 2 +melodyS: +E6,h15 + +//bass +track 3 +bassA: +-2 + +track 3 +bassB: +-16 + +track 3 +bassC: +A4#,h A4#,h +A4#,h A4# A4# +A4#,h A4#,h +A4#,h A4# A4# + +track 3 +bassD: +C4,h3 +C4,h C4,h +C4,h C4,h +C4,h C4 C4 + +track 3 +bassE: +C4,h E4 E4 +G4,h C5,h +C4,h C5 C5 +G4,h E4,h + +track 3 +bassF: +D4,h F4# F4# +A4,h D5,h +D4,h D5 D5 +A4,h F4#,h + +track 3 +bassG: +G3,h A3# A3# +D4,h G4,h +G3,h G4 G4 +D4,h A3,h + +track 3 +bassH: +G3#,h C4 C4 +D4#,h G5,h +G3#,h G4 G4 +D4#,h C4,h + +track 3 +bassJ: +A3#,h D4 D4 +F4,h A4#,h +A3#,h A4# A4# +F4,h D4,h + +//perc +track 4 +percA: +-2 + +track 4 +percB: +-16 + +track 4 +percC: +sn,- sn,- +sn,- sn sn +sn,- sn,- +sn,- sn sn + +track 4 +percD: +sn sn sn sn +-2 sn,- -2 sn,- +-2 sn sn diff --git a/Assets/Music/mysterious.gbm b/Assets/Music/mysterious.gbm new file mode 100644 index 0000000..b70818e --- /dev/null +++ b/Assets/Music/mysterious.gbm @@ -0,0 +1,199 @@ +//FGB +//Mysterious +//Jacob Stevens +notesPerSecond 4 //one note equals one eigth +transpose -4 + +track 1 //countermelody + + counterA,counterB + + .repeat + + counterA,counterB,counterC,counterD + counterC,counterD,counterA,counterB + counterA,counterB,counterC,counterD + counterC,counterD,counterE,counterF + counterE,counterF,counterG,counterH + counterA,counterB + + jmp .repeat + +track 2 //melody + + melodyA,melodyA + + .repeat + + melodyA,melodyA,melodyA,melodyA + melodyA,melodyA,melodyB,melodyB + melodyB,melodyB,melodyC,melodyC + melodyC,melodyC,melodyD,melodyE + melodyD,melodyE,melodyF,melodyG + melodyH,melodyA + + jmp .repeat + +track 3 //bass + + bassA,bassA + + .repeat + + bassB,bassC,bassD,bassE + bassD,bassF,bassB,bassC + bassB,bassC,bassD,bassE + bassD,bassG,bassH,bassJ + bassH,bassJ,bassK,bassL + bassB,bassC + + jmp .repeat + +//countermelody + +track 1 +counterA: +C5, D5# +G5 C6 +D6# G6 + +track 1 +counterB: +G6# G6 +D6# C6 +G5 D5# + +track 1 +counterC: +F5 G5# +C6 F6 +G6# C7 + +track 1 +counterD: +C7# C7 +G6# F6 +C6 G5# + +track 1 +counterE: +A5 D5 +-4 + +track 1 +counterF: +D6# G6 +E6 B5 +F6 G6# + +track 1 +counterG: +F6# A6 +G6 D6 +G6# B6 + +track 1 +counterH: +A6 G6# +G6 F6# +F6 E6 + +//melody +track 2 +melodyA: +-6 + +track 2 +melodyB: +C6 G6# G6 +C6 G6# G6 + +track 2 +melodyC: +F6 C6# C6 +F6 C6# C6 + +track 2 +melodyD: +G6# D6 +-4 + +track 2 +melodyE: +A5# D6# +B5 F5# +G5# C6 + +track 2 +melodyF: +C6# F6# +D6 A5# +D6# G6# + +track 2 +melodyG: +A5 A5# +B5 D5# +D5 C5# + +track 2 +melodyH: +C5,h5 + +//bass +track 3 +bassA: +-6 + +track 3 +bassB: +C4,h5 + +track 3 +bassC: +C5,h3 +G4,h + +track 3 +bassD: +G4#,h5 + +track 3 +bassE: +F4,h5 + +track 3 +bassF: +F4,h3 A3#,h + +track 3 +bassG: +A4#,h C5,h C5,h + +track 3 +bassH: +D5 D4 +D4 D4 +D4 D4 + +track 3 +bassJ: +D5# D4# +E5 E4 +E5 F4 + +track 3 +bassK: +F4# F5# +G4 G5 +G4# G5# + +track 3 +bassL: +A4 A4# +B4 D4# +D4 C4# + +track 3 +bassZ: +C5 \ No newline at end of file diff --git a/Assets/Music/shroom.gbm b/Assets/Music/shroom.gbm new file mode 100644 index 0000000..29743f3 --- /dev/null +++ b/Assets/Music/shroom.gbm @@ -0,0 +1,172 @@ +//FGB +//Shroom Hallucination +//Jacob Stevens +notesPerSecond 30 //quarter ~= 160, one note equals 1/12 of 1 beat + +track 1 //countermelody + + + melodyA + instrument1 6B80F20084 + melodyA + instrument1 6BC0F20084 + melodyB + instrument1 6B40F20084 + melodyC + instrument1 6B00F20084 + melodyD + + .repeat + instrument1 6B00F20084 + melodyE + instrument1 6B40F20084 + melodyF + instrument1 6B80F20084 + melodyG + instrument1 6BC0F20084 + melodyE + instrument1 6B40F20084 + melodyH + instrument1 6BC0F20084 + melodyJ + instrument1 6B00F20084 + melodyK + instrument1 6BC0F20084 + melodyL + instrument1 6B00F20084 + melodyM + instrument1 6B80F20084 + melodyN + instrument1 6BC0F20084 + melodyO + instrument1 6B00F20084 + melodyP + instrument1 6BC0F20084 + melodyQ + jmp .repeat + +track 2 //melody + instrument2 80F70887 + .repeat + wholeTone + jmp .repeat + +track 3 //bass + + .repeat + bass + jmp .repeat + +track 4 //percussion + + .repeat + perc + jmp .repeat + +//melody track +track 1 +melodyA: +-48 + +track 1 +melodyB: +F4,h11 +F4,h3 F4,h3 F4,h3 +A4#,h11 +A4#,h3 A4#,h3 A4#,h3 + +track 1 +melodyC: +D5#,h3 D5#,h3 D5#,h3 +G5#,h3 G5#,h3 G5#,h3 +C6#,h3 C6#,h3 C6#,h3 +F6#,h3 F6#,h3 F6#,h3 + +track 1 +melodyD: +G6,h11 +G6,h3 G6,h3 G6,h3 +G6,h11 +G6,h3 G6,h3 G6,h3 + +track 1 +melodyE: +G6,h11 +E6,h11 +C6,h11 +G5,h11 + +track 1 +melodyF: +A5#,h23 +A5,h11 +A5#,h5 A5,h5 + +track 1 +melodyG: +G5,h11 +C6,h83 + +track 1 +melodyH: +A5#,h23 +A5,h11 +A5#,h5 C6,h5 + +track 1 +melodyJ: +G6,h83 +F6,h5 E6,h5 + +track 1 +melodyK: +G6#,h83 +G6,h5 F6,h5 + +track 1 +melodyL: +E6,h2 F6,h2 G6,h77 +F6,h5 G6,h5 + +track 1 +melodyM: +G6#,h83 +G6,h5 G6#,h5 + +track 1 +melodyN: +A6#,h17 +D6#,h17 +D7#,h11 + +track 1 +melodyO: +C7#,h35 +C7,h5 A6#,h5 + +track 1 +melodyP: +G6#,h23 +G6#,h23 + +track 1 +melodyQ: +A6,h95 + +track 2 +wholeTone: +C5,h5 D5,h5 +E5,h5 F5#,h5 +G5#,h5 A5#,h5 + +C6,h5 A5#,h5 +G5#,h5 F5#,h5 +E5,h5 D5,h5 + +track 3 +bass: +E4,h5 C4,h5 A3#,h5 + +track 4 +perc: +sn -2 sn -2 bs -2 rd -2 ta -2 tb -2 diff --git a/Assets/Music/something_happy.gbm b/Assets/Music/something_happy.gbm new file mode 100644 index 0000000..635e381 --- /dev/null +++ b/Assets/Music/something_happy.gbm @@ -0,0 +1,14 @@ +//FGB +//nothing +//Jacob Stevens +notesPerSecond 9 //quarter = 140, one note equals one sixteenth + +track 1 //countermelody + + .repeat + melodyA + jmp .repeat + +track 1 +melodyA: +C5 E5 G5 E5 diff --git a/Assets/Music/spaceish.gbm b/Assets/Music/spaceish.gbm new file mode 100644 index 0000000..8169e96 --- /dev/null +++ b/Assets/Music/spaceish.gbm @@ -0,0 +1,224 @@ +//FGB +//Space-ish Music +//Jacob Stevens +notesPerSecond 12 + +track 2 //countermelody + + instrument2 44F23286 + + counterA,counterA + + .repeat + + counterA,counterA,counterA,counterA + counterA,counterA,counterB,counterA + counterA,counterA,counterA,counterB + counterC,counterC,counterD,counterD + counterE,counterE,counterF,counterG + counterA,counterA,counterA,counterA + counterA,counterA,counterB,counterA + counterA,counterA,counterA,counterB + counterC,counterC,counterD,counterD + counterE,counterE,counterH,counterH + counterE,counterE,counterF,counterG + + jmp .repeat + +track 1 //melody + + instrument1 0080F70887 + + melodyA,melodyA + + .repeat + + melodyA,melodyA,melodyA,melodyA + melodyB,melodyC,melodyD,melodyB + melodyC,melodyE,melodyF,melodyG + melodyG,melodyH,melodyA,melodyA + melodyA,melodyA,melodyB,melodyC + melodyD,melodyB,melodyC,melodyE + melodyF,melodyG,melodyG,melodyJ + melodyJ,melodyG,melodyG,melodyH + + jmp .repeat + +track 3 //bass + + bassZ,bassZ + + .repeat + + bassA,bassA,bassA,bassA + bassA,bassA,bassB,bassA + bassA,bassA,bassA,bassB + bassC,bassC,bassD,bassD + bassE,bassE,bassE,bassE + bassA,bassA,bassA,bassA + bassA,bassA,bassB,bassA + bassA,bassA,bassA,bassB + bassC,bassC,bassD,bassD + bassE,bassE,bassF,bassF + bassE,bassE,bassE,bassE + + jmp .repeat + +//countermelody + +track 2 +counterA: +C6,h G6,h +C7,h G6,h +A5#,h G6,h +A6#,h G6,h + +track 2 +counterB: +A5#,h F6,h +A6#,h F6,h +A5#,h F6,h +A6#,h F6,h + +track 2 +counterC: +A5#,h D6#,h +A6#,h D6#,h +A5#,h D6#,h +A6#,h D6#,h + +track 2 +counterD: +G5#,h C6#,h +G6#,h C6#,h +G5#,h C6#,h +G6#,h C6#,h + +track 2 +counterE: +D7#,h A6#,h +G6,h D6#,h +D7#,h A6#,h +G6,h D6#,h + +track 2 +counterF: +D7# A6# G6 D6# +A6# G6 D6# A5# +G7 D6# A5# G5 +D6# A5# G5 D5# + +track 2 +counterG: +D6# A5# G5 D5# +G7 D6# A5# G5 +A6# G6 D6# A5# +D7# A6# G6 D6# + +track 2 +counterH: +C7#,h G6#,h +F6,h C6#,h +C7#,h G6#,h +F6,h C6#,h + +//melody +track 1 +melodyA: +-16 + +track 1 +melodyB: +C6,h27 +A5#,h C6,h + +track 1 +melodyC: +D6,h3 +A5#,h3 +A5#,h D6,h5 + +track 1 +melodyD: +C6,h31 + +track 1 +melodyE: +D6#,h D6,h +C6,h A5#,h +G5,h9 +A5#,h +D6#,h A5#,h +G5,h A5#,h +D6#,h G6,h + +track 1 +melodyF: +F6,h D6#,h +C6#,h C6,h +G5#,h9 +C6#,h +F6,h C6#,h +G6#,h C6#,h +F6,h G6,h + +track 1 +melodyG: +G6,h5 +G5,h5 +G6,h3 + +track 1 +melodyH: +G6,h31 + +track 1 +melodyJ: +F6,h5 +F6,h5 +F6,h3 + +//bass +track 3 +bassZ: +-16 + +track 3 +bassA: +C4,h C4,h +C5,h C5,h +A3#,h A3#,h +A4#,h A4#,h + +track 3 +bassB: +A3#,h A3#,h +A4#,h A4#,h +A3#,h A3#,h +A4#,h A4#,h + +track 3 +bassC: +D4#,h D4#,h +D5#,h D5#,h +D4#,h D4#,h +D5#,h D5#,h + +track 3 +bassD: +C4#,h C4#,h +C5#,h C5#,h +C4#,h C4#,h +C5#,h C5#,h + +track 3 +bassE: +D4#,h D5#,h D5#,h +D4#,h D5#,h D5#,h +D4#,h D5#,h + +track 3 +bassF: +C4#,h C5#,h C5#,h +C4#,h C5#,h C5#,h +C4#,h C5#,h diff --git a/Assets/Music/takeoff.gbm b/Assets/Music/takeoff.gbm new file mode 100644 index 0000000..5905e82 --- /dev/null +++ b/Assets/Music/takeoff.gbm @@ -0,0 +1,1307 @@ +//FGB +//Appomattox takeoff sequence +//Jacob Stevens + +notesPerSecond 10 + +track 1 //countermelody + + .counterMain1 //section 1 + .counterA1 + counterA + cmp r0,1 + jmp eq,.counterB1 + cmp r0,2 + jmp eq,.counterB2 + cmp r0,3 + jmp eq,.counterB3 + cmp r0,4 + jmp eq,.counterB4 + cmp r0,5 + jmp eq,.counterB5 + .counterB1 + counterB + cmp r0,1 + jmp eq,.counterC1 + cmp r0,2 + jmp eq,.counterC2 + cmp r0,3 + jmp eq,.counterC3 + cmp r0,4 + jmp eq,.counterC4 + cmp r0,5 + jmp eq,.counterC5 + .counterC1 + counterC + cmp r0,1 + jmp eq,.counterD1 + cmp r0,2 + jmp eq,.counterD2 + cmp r0,3 + jmp eq,.counterD3 + cmp r0,4 + jmp eq,.counterD4 + cmp r0,5 + jmp eq,.counterD5 + .counterD1 + counterD + cmp r0,1 + jmp eq,.counterE1 + cmp r0,2 + jmp eq,.counterE2 + cmp r0,3 + jmp eq,.counterE3 + cmp r0,4 + jmp eq,.counterE4 + cmp r0,5 + jmp eq,.counterE5 + .counterE1 + counterE + cmp r0,1 + jmp eq,.counterF1 + cmp r0,2 + jmp eq,.counterF2 + cmp r0,3 + jmp eq,.counterF3 + cmp r0,4 + jmp eq,.counterF4 + cmp r0,5 + jmp eq,.counterF5 + .counterF1 + counterF + cmp r0,1 + jmp eq,.counterA1 + cmp r0,2 + jmp eq,.counterA2 + cmp r0,3 + jmp eq,.counterA3 + cmp r0,4 + jmp eq,.counterA4 + cmp r0,5 + jmp eq,.counterA5 + jmp counterMain1 + + .counterMain2 //section 2 + .counterA2 + counterA + cmp r0,1 + jmp eq,.counterB1 + cmp r0,2 + jmp eq,.counterB2 + cmp r0,3 + jmp eq,.counterB3 + cmp r0,4 + jmp eq,.counterB4 + cmp r0,5 + jmp eq,.counterB5 + .counterB2 + counterB + cmp r0,1 + jmp eq,.counterC1 + cmp r0,2 + jmp eq,.counterC2 + cmp r0,3 + jmp eq,.counterC3 + cmp r0,4 + jmp eq,.counterC4 + cmp r0,5 + jmp eq,.counterC5 + .counterC2 + counterC + cmp r0,1 + jmp eq,.counterD1 + cmp r0,2 + jmp eq,.counterD2 + cmp r0,3 + jmp eq,.counterD3 + cmp r0,4 + jmp eq,.counterD4 + cmp r0,5 + jmp eq,.counterD5 + .counterD2 + counterD + cmp r0,1 + jmp eq,.counterE1 + cmp r0,2 + jmp eq,.counterE2 + cmp r0,3 + jmp eq,.counterE3 + cmp r0,4 + jmp eq,.counterE4 + cmp r0,5 + jmp eq,.counterE5 + .counterE2 + counterE + cmp r0,1 + jmp eq,.counterF1 + cmp r0,2 + jmp eq,.counterF2 + cmp r0,3 + jmp eq,.counterF3 + cmp r0,4 + jmp eq,.counterF4 + cmp r0,5 + jmp eq,.counterF5 + .counterF2 + counterF + cmp r0,1 + jmp eq,.counterA1 + cmp r0,2 + jmp eq,.counterA2 + cmp r0,3 + jmp eq,.counterA3 + cmp r0,4 + jmp eq,.counterA4 + cmp r0,5 + jmp eq,.counterA5 + jmp counterMain2 + + .counterMain3 //section 3 + .counterA3 + counterA + cmp r0,1 + jmp eq,.counterB1 + cmp r0,2 + jmp eq,.counterB2 + cmp r0,3 + jmp eq,.counterB3 + cmp r0,4 + jmp eq,.counterB4 + cmp r0,5 + jmp eq,.counterB5 + .counterB3 + counterB + cmp r0,1 + jmp eq,.counterC1 + cmp r0,2 + jmp eq,.counterC2 + cmp r0,3 + jmp eq,.counterC3 + cmp r0,4 + jmp eq,.counterC4 + cmp r0,5 + jmp eq,.counterC5 + .counterC3 + counterC + cmp r0,1 + jmp eq,.counterD1 + cmp r0,2 + jmp eq,.counterD2 + cmp r0,3 + jmp eq,.counterD3 + cmp r0,4 + jmp eq,.counterD4 + cmp r0,5 + jmp eq,.counterD5 + .counterD3 + counterD + cmp r0,1 + jmp eq,.counterE1 + cmp r0,2 + jmp eq,.counterE2 + cmp r0,3 + jmp eq,.counterE3 + cmp r0,4 + jmp eq,.counterE4 + cmp r0,5 + jmp eq,.counterE5 + .counterE3 + counterE + cmp r0,1 + jmp eq,.counterF1 + cmp r0,2 + jmp eq,.counterF2 + cmp r0,3 + jmp eq,.counterF3 + cmp r0,4 + jmp eq,.counterF4 + cmp r0,5 + jmp eq,.counterF5 + .counterF3 + counterF + cmp r0,1 + jmp eq,.counterA1 + cmp r0,2 + jmp eq,.counterA2 + cmp r0,3 + jmp eq,.counterA3 + cmp r0,4 + jmp eq,.counterA4 + cmp r0,5 + jmp eq,.counterA5 + jmp counterMain3 + + .counterMain4 //section 4 + .counterA4 + counterA + cmp r0,1 + jmp eq,.counterB1 + cmp r0,2 + jmp eq,.counterB2 + cmp r0,3 + jmp eq,.counterB3 + cmp r0,4 + jmp eq,.counterB4 + cmp r0,5 + jmp eq,.counterB5 + .counterB4 + counterB + cmp r0,1 + jmp eq,.counterC1 + cmp r0,2 + jmp eq,.counterC2 + cmp r0,3 + jmp eq,.counterC3 + cmp r0,4 + jmp eq,.counterC4 + cmp r0,5 + jmp eq,.counterC5 + .counterC4 + counterC + cmp r0,1 + jmp eq,.counterD1 + cmp r0,2 + jmp eq,.counterD2 + cmp r0,3 + jmp eq,.counterD3 + cmp r0,4 + jmp eq,.counterD4 + cmp r0,5 + jmp eq,.counterD5 + .counterD4 + counterD + cmp r0,1 + jmp eq,.counterE1 + cmp r0,2 + jmp eq,.counterE2 + cmp r0,3 + jmp eq,.counterE3 + cmp r0,4 + jmp eq,.counterE4 + cmp r0,5 + jmp eq,.counterE5 + .counterE4 + counterE + cmp r0,1 + jmp eq,.counterF1 + cmp r0,2 + jmp eq,.counterF2 + cmp r0,3 + jmp eq,.counterF3 + cmp r0,4 + jmp eq,.counterF4 + cmp r0,5 + jmp eq,.counterF5 + .counterF4 + counterF + cmp r0,1 + jmp eq,.counterA1 + cmp r0,2 + jmp eq,.counterA2 + cmp r0,3 + jmp eq,.counterA3 + cmp r0,4 + jmp eq,.counterA4 + cmp r0,5 + jmp eq,.counterA5 + jmp counterMain4 + + .counterMain5 //section 5 + .counterA5 + counterG + cmp r0,1 + jmp eq,.counterB1 + cmp r0,2 + jmp eq,.counterB2 + cmp r0,3 + jmp eq,.counterB3 + cmp r0,4 + jmp eq,.counterB4 + cmp r0,5 + jmp eq,.counterB5 + .counterB5 + counterH + cmp r0,1 + jmp eq,.counterC1 + cmp r0,2 + jmp eq,.counterC2 + cmp r0,3 + jmp eq,.counterC3 + cmp r0,4 + jmp eq,.counterC4 + cmp r0,5 + jmp eq,.counterC5 + .counterC5 + counterJ + cmp r0,1 + jmp eq,.counterD1 + cmp r0,2 + jmp eq,.counterD2 + cmp r0,3 + jmp eq,.counterD3 + cmp r0,4 + jmp eq,.counterD4 + cmp r0,5 + jmp eq,.counterD5 + .counterD5 + counterK + cmp r0,1 + jmp eq,.counterE1 + cmp r0,2 + jmp eq,.counterE2 + cmp r0,3 + jmp eq,.counterE3 + cmp r0,4 + jmp eq,.counterE4 + cmp r0,5 + jmp eq,.counterE5 + .counterE5 + counterL + cmp r0,1 + jmp eq,.counterF1 + cmp r0,2 + jmp eq,.counterF2 + cmp r0,3 + jmp eq,.counterF3 + cmp r0,4 + jmp eq,.counterF4 + cmp r0,5 + jmp eq,.counterF5 + .counterF5 + counterM + cmp r0,1 + jmp eq,.counterA1 + cmp r0,2 + jmp eq,.counterA2 + cmp r0,3 + jmp eq,.counterA3 + cmp r0,4 + jmp eq,.counterA4 + cmp r0,5 + jmp eq,.counterA5 + jmp counterMain5 + + +track 2 //melody + .melodyMain1 //section 1 + .melodyA1 + melodyA + cmp r0,1 + jmp eq,.melodyB1 + cmp r0,2 + jmp eq,.melodyB2 + cmp r0,3 + jmp eq,.melodyB3 + cmp r0,4 + jmp eq,.melodyB4 + cmp r0,5 + jmp eq,.melodyB5 + .melodyB1 + melodyB + cmp r0,1 + jmp eq,.melodyC1 + cmp r0,2 + jmp eq,.melodyC2 + cmp r0,3 + jmp eq,.melodyC3 + cmp r0,4 + jmp eq,.melodyC4 + cmp r0,5 + jmp eq,.melodyC5 + .melodyC1 + melodyC + cmp r0,1 + jmp eq,.melodyD1 + cmp r0,2 + jmp eq,.melodyD2 + cmp r0,3 + jmp eq,.melodyD3 + cmp r0,4 + jmp eq,.melodyD4 + cmp r0,5 + jmp eq,.melodyD5 + .melodyD1 + melodyD + cmp r0,1 + jmp eq,.melodyE1 + cmp r0,2 + jmp eq,.melodyE2 + cmp r0,3 + jmp eq,.melodyE3 + cmp r0,4 + jmp eq,.melodyE4 + cmp r0,5 + jmp eq,.melodyE5 + .melodyE1 + melodyE + cmp r0,1 + jmp eq,.melodyF1 + cmp r0,2 + jmp eq,.melodyF2 + cmp r0,3 + jmp eq,.melodyF3 + cmp r0,4 + jmp eq,.melodyF4 + cmp r0,5 + jmp eq,.melodyF5 + .melodyF1 + melodyF + cmp r0,1 + jmp eq,.melodyA1 + cmp r0,2 + jmp eq,.melodyA2 + cmp r0,3 + jmp eq,.melodyA3 + cmp r0,4 + jmp eq,.melodyA4 + cmp r0,5 + jmp eq,.melodyA5 + jmp melodyMain1 + + .melodyMain2 //section 2 + .melodyA2 + melodyA + cmp r0,1 + jmp eq,.melodyB1 + cmp r0,2 + jmp eq,.melodyB2 + cmp r0,3 + jmp eq,.melodyB3 + cmp r0,4 + jmp eq,.melodyB4 + cmp r0,5 + jmp eq,.melodyB5 + .melodyB2 + melodyB + cmp r0,1 + jmp eq,.melodyC1 + cmp r0,2 + jmp eq,.melodyC2 + cmp r0,3 + jmp eq,.melodyC3 + cmp r0,4 + jmp eq,.melodyC4 + cmp r0,5 + jmp eq,.melodyC5 + .melodyC2 + melodyC + cmp r0,1 + jmp eq,.melodyD1 + cmp r0,2 + jmp eq,.melodyD2 + cmp r0,3 + jmp eq,.melodyD3 + cmp r0,4 + jmp eq,.melodyD4 + cmp r0,5 + jmp eq,.melodyD5 + .melodyD2 + melodyD + cmp r0,1 + jmp eq,.melodyE1 + cmp r0,2 + jmp eq,.melodyE2 + cmp r0,3 + jmp eq,.melodyE3 + cmp r0,4 + jmp eq,.melodyE4 + cmp r0,5 + jmp eq,.melodyE5 + .melodyE2 + melodyE + cmp r0,1 + jmp eq,.melodyF1 + cmp r0,2 + jmp eq,.melodyF2 + cmp r0,3 + jmp eq,.melodyF3 + cmp r0,4 + jmp eq,.melodyF4 + cmp r0,5 + jmp eq,.melodyF5 + .melodyF2 + melodyF + cmp r0,1 + jmp eq,.melodyA1 + cmp r0,2 + jmp eq,.melodyA2 + cmp r0,3 + jmp eq,.melodyA3 + cmp r0,4 + jmp eq,.melodyA4 + cmp r0,5 + jmp eq,.melodyA5 + jmp melodyMain2 + + .melodyMain3 //section 3 + .melodyA3 + melodyG + cmp r0,1 + jmp eq,.melodyB1 + cmp r0,2 + jmp eq,.melodyB2 + cmp r0,3 + jmp eq,.melodyB3 + cmp r0,4 + jmp eq,.melodyB4 + cmp r0,5 + jmp eq,.melodyB5 + .melodyB3 + melodyH + cmp r0,1 + jmp eq,.melodyC1 + cmp r0,2 + jmp eq,.melodyC2 + cmp r0,3 + jmp eq,.melodyC3 + cmp r0,4 + jmp eq,.melodyC4 + cmp r0,5 + jmp eq,.melodyC5 + .melodyC3 + melodyJ + cmp r0,1 + jmp eq,.melodyD1 + cmp r0,2 + jmp eq,.melodyD2 + cmp r0,3 + jmp eq,.melodyD3 + cmp r0,4 + jmp eq,.melodyD4 + cmp r0,5 + jmp eq,.melodyD5 + .melodyD3 + melodyK + cmp r0,1 + jmp eq,.melodyE1 + cmp r0,2 + jmp eq,.melodyE2 + cmp r0,3 + jmp eq,.melodyE3 + cmp r0,4 + jmp eq,.melodyE4 + cmp r0,5 + jmp eq,.melodyE5 + .melodyE3 + melodyL + cmp r0,1 + jmp eq,.melodyF1 + cmp r0,2 + jmp eq,.melodyF2 + cmp r0,3 + jmp eq,.melodyF3 + cmp r0,4 + jmp eq,.melodyF4 + cmp r0,5 + jmp eq,.melodyF5 + .melodyF3 + melodyM + cmp r0,1 + jmp eq,.melodyA1 + cmp r0,2 + jmp eq,.melodyA2 + cmp r0,3 + jmp eq,.melodyA3 + cmp r0,4 + jmp eq,.melodyA4 + cmp r0,5 + jmp eq,.melodyA5 + jmp melodyMain3 + + .melodyMain4 //section 4 + .melodyA4 + melodyN + cmp r0,1 + jmp eq,.melodyB1 + cmp r0,2 + jmp eq,.melodyB2 + cmp r0,3 + jmp eq,.melodyB3 + cmp r0,4 + jmp eq,.melodyB4 + cmp r0,5 + jmp eq,.melodyB5 + .melodyB4 + melodyO + cmp r0,1 + jmp eq,.melodyC1 + cmp r0,2 + jmp eq,.melodyC2 + cmp r0,3 + jmp eq,.melodyC3 + cmp r0,4 + jmp eq,.melodyC4 + cmp r0,5 + jmp eq,.melodyC5 + .melodyC4 + melodyP + cmp r0,1 + jmp eq,.melodyD1 + cmp r0,2 + jmp eq,.melodyD2 + cmp r0,3 + jmp eq,.melodyD3 + cmp r0,4 + jmp eq,.melodyD4 + cmp r0,5 + jmp eq,.melodyD5 + .melodyD4 + melodyQ + cmp r0,1 + jmp eq,.melodyE1 + cmp r0,2 + jmp eq,.melodyE2 + cmp r0,3 + jmp eq,.melodyE3 + cmp r0,4 + jmp eq,.melodyE4 + cmp r0,5 + jmp eq,.melodyE5 + .melodyE4 + melodyR + cmp r0,1 + jmp eq,.melodyF1 + cmp r0,2 + jmp eq,.melodyF2 + cmp r0,3 + jmp eq,.melodyF3 + cmp r0,4 + jmp eq,.melodyF4 + cmp r0,5 + jmp eq,.melodyF5 + .melodyF4 + melodyS + cmp r0,1 + jmp eq,.melodyA1 + cmp r0,2 + jmp eq,.melodyA2 + cmp r0,3 + jmp eq,.melodyA3 + cmp r0,4 + jmp eq,.melodyA4 + cmp r0,5 + jmp eq,.melodyA5 + jmp melodyMain4 + + .melodyMain5 //section 5 + .melodyA5 + melodyN + cmp r0,1 + jmp eq,.melodyB1 + cmp r0,2 + jmp eq,.melodyB2 + cmp r0,3 + jmp eq,.melodyB3 + cmp r0,4 + jmp eq,.melodyB4 + cmp r0,5 + jmp eq,.melodyB5 + .melodyB5 + melodyO + cmp r0,1 + jmp eq,.melodyC1 + cmp r0,2 + jmp eq,.melodyC2 + cmp r0,3 + jmp eq,.melodyC3 + cmp r0,4 + jmp eq,.melodyC4 + cmp r0,5 + jmp eq,.melodyC5 + .melodyC5 + melodyP + cmp r0,1 + jmp eq,.melodyD1 + cmp r0,2 + jmp eq,.melodyD2 + cmp r0,3 + jmp eq,.melodyD3 + cmp r0,4 + jmp eq,.melodyD4 + cmp r0,5 + jmp eq,.melodyD5 + .melodyD5 + melodyQ + cmp r0,1 + jmp eq,.melodyE1 + cmp r0,2 + jmp eq,.melodyE2 + cmp r0,3 + jmp eq,.melodyE3 + cmp r0,4 + jmp eq,.melodyE4 + cmp r0,5 + jmp eq,.melodyE5 + .melodyE5 + melodyR + cmp r0,1 + jmp eq,.melodyF1 + cmp r0,2 + jmp eq,.melodyF2 + cmp r0,3 + jmp eq,.melodyF3 + cmp r0,4 + jmp eq,.melodyF4 + cmp r0,5 + jmp eq,.melodyF5 + .melodyF5 + melodyS + cmp r0,1 + jmp eq,.melodyA1 + cmp r0,2 + jmp eq,.melodyA2 + cmp r0,3 + jmp eq,.melodyA3 + cmp r0,4 + jmp eq,.melodyA4 + cmp r0,5 + jmp eq,.melodyA5 + jmp melodyMain5 + +track 3 //bass + .bassMain1 //section 1 + .bassA1 + bassA + cmp r0,1 + jmp eq,.bassB1 + cmp r0,2 + jmp eq,.bassB2 + cmp r0,3 + jmp eq,.bassB3 + cmp r0,4 + jmp eq,.bassB4 + cmp r0,5 + jmp eq,.bassB5 + .bassB1 + bassB + cmp r0,1 + jmp eq,.bassC1 + cmp r0,2 + jmp eq,.bassC2 + cmp r0,3 + jmp eq,.bassC3 + cmp r0,4 + jmp eq,.bassC4 + cmp r0,5 + jmp eq,.bassC5 + .bassC1 + bassC + cmp r0,1 + jmp eq,.bassD1 + cmp r0,2 + jmp eq,.bassD2 + cmp r0,3 + jmp eq,.bassD3 + cmp r0,4 + jmp eq,.bassD4 + cmp r0,5 + jmp eq,.bassD5 + .bassD1 + bassD + cmp r0,1 + jmp eq,.bassE1 + cmp r0,2 + jmp eq,.bassE2 + cmp r0,3 + jmp eq,.bassE3 + cmp r0,4 + jmp eq,.bassE4 + cmp r0,5 + jmp eq,.bassE5 + .bassE1 + bassE + cmp r0,1 + jmp eq,.bassF1 + cmp r0,2 + jmp eq,.bassF2 + cmp r0,3 + jmp eq,.bassF3 + cmp r0,4 + jmp eq,.bassF4 + cmp r0,5 + jmp eq,.bassF5 + .bassF1 + bassF + cmp r0,1 + jmp eq,.bassA1 + cmp r0,2 + jmp eq,.bassA2 + cmp r0,3 + jmp eq,.bassA3 + cmp r0,4 + jmp eq,.bassA4 + cmp r0,5 + jmp eq,.bassA5 + jmp bassMain1 + + .bassMain2 //section 2 + .bassA2 + bassG + cmp r0,1 + jmp eq,.bassB1 + cmp r0,2 + jmp eq,.bassB2 + cmp r0,3 + jmp eq,.bassB3 + cmp r0,4 + jmp eq,.bassB4 + cmp r0,5 + jmp eq,.bassB5 + .bassB2 + bassH + cmp r0,1 + jmp eq,.bassC1 + cmp r0,2 + jmp eq,.bassC2 + cmp r0,3 + jmp eq,.bassC3 + cmp r0,4 + jmp eq,.bassC4 + cmp r0,5 + jmp eq,.bassC5 + .bassC2 + bassJ + cmp r0,1 + jmp eq,.bassD1 + cmp r0,2 + jmp eq,.bassD2 + cmp r0,3 + jmp eq,.bassD3 + cmp r0,4 + jmp eq,.bassD4 + cmp r0,5 + jmp eq,.bassD5 + .bassD2 + bassK + cmp r0,1 + jmp eq,.bassE1 + cmp r0,2 + jmp eq,.bassE2 + cmp r0,3 + jmp eq,.bassE3 + cmp r0,4 + jmp eq,.bassE4 + cmp r0,5 + jmp eq,.bassE5 + .bassE2 + bassL + cmp r0,1 + jmp eq,.bassF1 + cmp r0,2 + jmp eq,.bassF2 + cmp r0,3 + jmp eq,.bassF3 + cmp r0,4 + jmp eq,.bassF4 + cmp r0,5 + jmp eq,.bassF5 + .bassF2 + bassM + cmp r0,1 + jmp eq,.bassA1 + cmp r0,2 + jmp eq,.bassA2 + cmp r0,3 + jmp eq,.bassA3 + cmp r0,4 + jmp eq,.bassA4 + cmp r0,5 + jmp eq,.bassA5 + jmp bassMain2 + + .bassMain3 //section 3 + .bassA3 + bassG + cmp r0,1 + jmp eq,.bassB1 + cmp r0,2 + jmp eq,.bassB2 + cmp r0,3 + jmp eq,.bassB3 + cmp r0,4 + jmp eq,.bassB4 + cmp r0,5 + jmp eq,.bassB5 + .bassB3 + bassH + cmp r0,1 + jmp eq,.bassC1 + cmp r0,2 + jmp eq,.bassC2 + cmp r0,3 + jmp eq,.bassC3 + cmp r0,4 + jmp eq,.bassC4 + cmp r0,5 + jmp eq,.bassC5 + .bassC3 + bassJ + cmp r0,1 + jmp eq,.bassD1 + cmp r0,2 + jmp eq,.bassD2 + cmp r0,3 + jmp eq,.bassD3 + cmp r0,4 + jmp eq,.bassD4 + cmp r0,5 + jmp eq,.bassD5 + .bassD3 + bassK + cmp r0,1 + jmp eq,.bassE1 + cmp r0,2 + jmp eq,.bassE2 + cmp r0,3 + jmp eq,.bassE3 + cmp r0,4 + jmp eq,.bassE4 + cmp r0,5 + jmp eq,.bassE5 + .bassE3 + bassL + cmp r0,1 + jmp eq,.bassF1 + cmp r0,2 + jmp eq,.bassF2 + cmp r0,3 + jmp eq,.bassF3 + cmp r0,4 + jmp eq,.bassF4 + cmp r0,5 + jmp eq,.bassF5 + .bassF3 + bassM + cmp r0,1 + jmp eq,.bassA1 + cmp r0,2 + jmp eq,.bassA2 + cmp r0,3 + jmp eq,.bassA3 + cmp r0,4 + jmp eq,.bassA4 + cmp r0,5 + jmp eq,.bassA5 + jmp bassMain3 + + .bassMain4 //section 4 + .bassA4 + bassG + cmp r0,1 + jmp eq,.bassB1 + cmp r0,2 + jmp eq,.bassB2 + cmp r0,3 + jmp eq,.bassB3 + cmp r0,4 + jmp eq,.bassB4 + cmp r0,5 + jmp eq,.bassB5 + .bassB4 + bassH + cmp r0,1 + jmp eq,.bassC1 + cmp r0,2 + jmp eq,.bassC2 + cmp r0,3 + jmp eq,.bassC3 + cmp r0,4 + jmp eq,.bassC4 + cmp r0,5 + jmp eq,.bassC5 + .bassC4 + bassJ + cmp r0,1 + jmp eq,.bassD1 + cmp r0,2 + jmp eq,.bassD2 + cmp r0,3 + jmp eq,.bassD3 + cmp r0,4 + jmp eq,.bassD4 + cmp r0,5 + jmp eq,.bassD5 + .bassD4 + bassK + cmp r0,1 + jmp eq,.bassE1 + cmp r0,2 + jmp eq,.bassE2 + cmp r0,3 + jmp eq,.bassE3 + cmp r0,4 + jmp eq,.bassE4 + cmp r0,5 + jmp eq,.bassE5 + .bassE4 + bassL + cmp r0,1 + jmp eq,.bassF1 + cmp r0,2 + jmp eq,.bassF2 + cmp r0,3 + jmp eq,.bassF3 + cmp r0,4 + jmp eq,.bassF4 + cmp r0,5 + jmp eq,.bassF5 + .bassF4 + bassM + cmp r0,1 + jmp eq,.bassA1 + cmp r0,2 + jmp eq,.bassA2 + cmp r0,3 + jmp eq,.bassA3 + cmp r0,4 + jmp eq,.bassA4 + cmp r0,5 + jmp eq,.bassA5 + jmp bassMain4 + + .bassMain5 //section 5 + .bassA5 + bassG + cmp r0,1 + jmp eq,.bassB1 + cmp r0,2 + jmp eq,.bassB2 + cmp r0,3 + jmp eq,.bassB3 + cmp r0,4 + jmp eq,.bassB4 + cmp r0,5 + jmp eq,.bassB5 + .bassB5 + bassH + cmp r0,1 + jmp eq,.bassC1 + cmp r0,2 + jmp eq,.bassC2 + cmp r0,3 + jmp eq,.bassC3 + cmp r0,4 + jmp eq,.bassC4 + cmp r0,5 + jmp eq,.bassC5 + .bassC5 + bassJ + cmp r0,1 + jmp eq,.bassD1 + cmp r0,2 + jmp eq,.bassD2 + cmp r0,3 + jmp eq,.bassD3 + cmp r0,4 + jmp eq,.bassD4 + cmp r0,5 + jmp eq,.bassD5 + .bassD5 + bassK + cmp r0,1 + jmp eq,.bassE1 + cmp r0,2 + jmp eq,.bassE2 + cmp r0,3 + jmp eq,.bassE3 + cmp r0,4 + jmp eq,.bassE4 + cmp r0,5 + jmp eq,.bassE5 + .bassE5 + bassL + cmp r0,1 + jmp eq,.bassF1 + cmp r0,2 + jmp eq,.bassF2 + cmp r0,3 + jmp eq,.bassF3 + cmp r0,4 + jmp eq,.bassF4 + cmp r0,5 + jmp eq,.bassF5 + .bassF5 + bassM + cmp r0,1 + jmp eq,.bassA1 + cmp r0,2 + jmp eq,.bassA2 + cmp r0,3 + jmp eq,.bassA3 + cmp r0,4 + jmp eq,.bassA4 + cmp r0,5 + jmp eq,.bassA5 + jmp bassMain5 + + +//countermelody +track 1 +counterA: +G5,h E5,h C5,h + +track 1 +counterB: +G5,h G5,h E5,h + +track 1 +counterC: +C5,h G5,h + +track 1 +counterD: +A5,h F5#,h D5,h + +track 1 +counterE: +F5#,h A5,h F5#,h + +track 1 +counterF: +D5,h F5#,h + +track 1 +counterG: +C7 G6 E6 C6 G6 C6 + +track 1 +counterH: +E7 C7 G6 E6 G6 E6 + +track 1 +counterJ: +G6 E6 C6 G5 + +track 1 +counterK: +F7# D7 A6 F6# A6 F6# + +track 1 +counterL: +A7 F7# D7 A6 D7 A7 + +track 1 +counterM: +D7 A6 F6# D6 + +//melody +track 2 +melodyA: +-6 + +track 2 +melodyB: +-6 + +track 2 +melodyC: +-4 + +track 2 +melodyD: +-6 + +track 2 +melodyE: +-6 + +track 2 +melodyF: +-4 + +track 2 +melodyG: +C6,h G5,h E5,h + +track 2 +melodyH: +C6,h C6,h G5,h + +track 2 +melodyJ: +E5,h C6,h + +track 2 +melodyK: +D6,h A5,h F5#,h + +track 2 +melodyL: +A5,h D6,h A5,h + +track 2 +melodyM: +F5#,h A5,h + +track 2 +melodyN: +E6,h C6 D6 E6,h + +track 2 +melodyO: +G6,h E6,h C6 D6 + +track 2 +melodyP: +E6,h G6,h + +track 2 +melodyQ: +F6# D6 A5 F5# D5,h + +track 2 +melodyR: +F6# D6 F6# D6 A5 F5# + +track 2 +melodyS: +D5,h F5#,h + +//bass +track 3 +bassA: +-6 + +track 3 +bassB: +-6 + +track 3 +bassC: +-4 + +track 3 +bassD: +-6 + +track 3 +bassE: +-6 + +track 3 +bassF: +-4 + +track 3 +bassG: +C4,h5 + +track 3 +bassH: +C4,h5 + +track 3 +bassJ: +C4,h3 + +track 3 +bassK: +D4,h5 + +track 3 +bassL: +D4,h5 + +track 3 +bassM: +D4,h3 diff --git a/Assets/Music/wedding.gbm b/Assets/Music/wedding.gbm new file mode 100644 index 0000000..0c9f4a7 --- /dev/null +++ b/Assets/Music/wedding.gbm @@ -0,0 +1,516 @@ +//FGB +//Main In-Game Music +//Jacob Stevens +notesPerSecond 30 //quarter ~= 160, one note equals 1/12 of 1 beat + +track 1 //countermelody + + counter1,counter1,counter2,counter3 + counter4 + + .repeat + instrument1 0044F23286 + + counter5,counter6,counter7 + counter8,counter9,counter10,counter11 + counter12,counter13,counter6,counter7 + counter8,counter9,counter10,counter14 + counter6,counter15,counter16,counter17 + counter18,counter19,counter20,counter21 + counter22,counter23,counter24,counter25 + counter26,counter27,counter28,counter29 + counter30 + + jmp .repeat + +track 2 //melody + melody1,melody2,melody2,melody2 + melody3 + + .repeat + instrument2 80F70887 + + melody4,melody5,melody6,melody5 + melody7,melody8,melody9,melody10 + melody4,melody5,melody6,melody5 + melody7,melody8,melody11,melody5 + melody12,melody13,melody14,melody15 + melody12,melody16,melody12,melody17 + melody18,melody19,melody12,melody17 + melody18,melody19,melody20,melody21 + melody22,melody23,melody24,melody25 + + jmp .repeat + +track 3 //bass + + bass1,bass1,bass1,bass1, + bass2 + + .repeat + + bass3,bass4,bass5,bass4 + bass6,bass7,bass8,bass9 + bass6,bass4,bass5,bass4 + bass6,bass7,bass10,bassA + bass11,bass12,bass13,bass14 + bass11,bass12,bass11,bass11 + bass15,bass16,bass17,bass17 + bass15,bass18,bass19,bass20 + bass21,bass22,bass23,bass24 + + jmp .repeat + + +//counter melody segments + +track 1 +counter1: +-48 + +track 1 +counter2: +F4,h11 +F4,h3 F4,h3 F4,h3 +A4#,h11 +A4#,h3 A4#,h3 A4#,h3 + +track 1 +counter3: +D5#,h3 D5#,h3 D5#,h3 +G5#,h3 G5#,h3 G5#,h3 +C6#,h3 C6#,h3 C6#,h3 +F6#,h3 F6#,h3 F6#,h3 + +track 1 +counter4: +G6,h11 +G6,h3 G6,h3 G6,h3 +G6,h11 +-12 + +track 1 +counter5: +-24 +E5,h17 E5,h5 + +track 1 +counter6: +E5,h47 + +track 1 +counter7: +E5,h23 +D5,h17 B4,h5 + +track 1 +counter8: +C5,h47 + +track 1 +counter9: +E5,h23 +G5,h17 C6,h5 + +track 1 +counter10: +B5,h23 +C6,h17 A5,h5 + +track 1 +counter11: +C5,h23 +C5,h17 C5,h5 + +track 1 +counter12: +C5,h23 +B4,h23 + +track 1 +counter13: +C5,h23 +E5,h17 E5,h5 + +track 1 +counter14: +C5,h23 +B5,h17 G5,h5 + +track 1 +counter15: +E5,h11 +G5,h8 G5,h2 +G5,h23 + +track 1 +counter16: +D5,h11 +F5,h8 F5,h2 +F5,h23 + +track 1 +counter17: +D5#,h11 +G5#,h8 C6,h2 +D6#,h11 +C6,h8 G5#,h2 + +track 1 +counter18: +G5,h23 +D5,h23 + +track 1 +counter19: +G6,h11 +E6,h11 +C6,h11 +G5,h11 + +track 1 +counter20: +A5#,h23 +A5,h11 +A5#,h5 A5,h5 + +track 1 +counter21: +G5,h11 +C6,h35 + +track 1 +counter22: +-36 +F6,h5 G6,h5 + +track 1 +counter23: +G6#,h83 G6,h5 F6,h5 + +track 1 +counter24: +E6,h2 F6,h2 G6,h77 +F6,h5 G6,h5 + +track 1 +counter25: +G6#,h83 G6,h5 A6,h5 + +track 1 +counter26: +A6#,h17 D6#,h17 +D7#,h11 + +track 1 +counter27: +C7#,h35 +C7,h5 A6#,h5 + +track 1 +counter28: +G6#,h23 +G6#,h23 + +track 1 +counter29: +A6,h95 + +track 1 +counter30: +A6,h11 +-36 + +//melody sections +track 2 +melody1: +-48 + +track 2 +melody2: +C5,h11 +C5,h3 C5,h3 C5,h3 +C5,h11 +C5,h3 C5,h3 C5,h3 + + +track 2 +melody3: +G4,h11 +G4,h3 G4,h3 G4,h3 +G4,h11 +G5,h3 G5,h3 G5,h3 + +track 2 +melody4: +G5,h23 +C6,h17 C6,h5 + +track 2 +melody5: +C6,h47 + +track 2 +melody6: +G5,h23 +D6,h17 B5,h5 + +track 2 +melody7: +G5,h23 +C6,h17 E6,h5 + +track 2 +melody8: +G6,h23 +E6,h17 C6,h5 + +track 2 +melody9: +A5,h23 +B5,h17 C6,h5 + +track 2 +melody10: +D6,h47 + +track 2 +melody11: +A5,h23 +D6,h17 B5,h5 + +track 2 +melody12: +G5,h11 +C6,h8 C6,h2 +C6,h23 + +track 2 +melody13: +G5,h11 +D6,h8 A5#,h2 +C6,h23 + +track 2 +melody14: +G5#,h11 +C6,h8 D6#,h2 +G6#,h11 +D6#,h8 C6,h2 + +track 2 +melody15: +C6,h23 +B5,h23 + +track 2 +melody16: +G5,h11 +D6,h8 A5#,h2 +F5,h23 + +track 2 +melody17: +G5,h11 +D6,h8 B5,h2 +C6,h23 + +track 2 +melody18: +F5,h11 +G5#,h8 G5#,h2 +G5#,h23 + +track 2 +melody19: +F5,h11 C6,h8 G5#,h2 +F5,h23 + +track 2 +melody20: +A5#,h11 +D6#,h8 D6#,h2 +D6#,h23 + +track 2 +melody21: +G5#,h11 +C6#,h8 C6,h2 +C6#,h23 + +track 2 +melody22: +G5#,h11 C6#,h8 C6#,h2 +C6#,h23 + +track 2 +melody23: +C6,h11 +F6,h8 F6,h2 +F6,h23 + +track 2 +melody24: +C6,h11 +G6,h8 E6,h2 +F6,h23 + +track 2 +melody25: +F6,h11 +G5,h3 G5,h3 G5,h3 +G5,h11 +G5,h3 G5,h3 G5,h3 + +//BASS +track 3 +bass1: +C4,h11 +C4,h3 C4,h3 C4,h3 +C4,h11 +C4,h3 C4,h3 C4,h3 + + +track 3 +bass2: +G3,h11 +G3,h3 G3,h3 G3,h3 +G3,h11 +G3,h3 G3,h3 G3,h3 + +track 3 +bass3: +G3,h23 +C4,h17 C4,h5 + +track 3 +bass4: +C4,h47 + +track 3 +bass5: +C4,h23 +G4,h17 G4,h5 + +track 3 +bass6: +C4,h23 +C4,h17 C4,h5 + +track 3 +bass7: +E4,h23 +A4,h17 A4,h5 + +track 3 +bass8: +F4,h23 +F4,h17 F4,h5 + +track 3 +bass9: +G4,h47 + +track 3 +bass10: +F4,h23 +G4,h17 G4,h5 + +track 3 +bassA: +C4,h23 +C4,h5 C4,h5 +C5,h3 C4,h3 C4,h3 + + +track 3 +bass11: +C4,h11 +C5,h3 C4,h3 C4,h3 +C4,h11 +C5,h3 C4,h3 C4,h3 + +track 3 +bass12: +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 +A3#,h11 +A4#,h3 A3#,h3 A3#,h3 + +track 3 +bass13: +G3#,h11 +G4#,h3 G3#,h3 G3,h3 +G3#,h11 +G4#,h3 G3#,h3 G3,h3 + +track 3 +bass14: +G3,h5 G4,h5 +G4,h5 G3,h5 +G4,h5 G4,h5 +G4,h3 G4,h3 G4,h3 + +track 3 +bass15: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F5,h5 F4,h5 + +track 3 +bass16: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F5,h5 G4,h5 + +track 3 +bass17: +C4,h17 C4,h5 +G4,h5 G4,h5 +C5,h5 C5,h5 + +track 3 +bass18: +F4,h5 F5,h5 +F4,h5 F4,h5 +F4,h5 F4,h5 +F5,h5 E4,h5 + +track 3 +bass19: +D4#,h17 +A3#,h17 +E4#,h11 + +track 3 +bass20: +C4#,h17 G3#,h5 +C4#,h17 G3#,h5 + +track 3 +bass21: +C4#,h17 C4#,h5 +D4#,h17 D4#,h5 + +track 3 +bass22: +F4,h11 +F4,h3 F4,h3 F4,h3 +F4,h11 +F4,h3 F4,h3 F4,h3 + +track 3 +bass23: +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 +F4,h3 C4,h3 C4,h3 + +track 3 +bass24: +F4,h11 +G3,h3 G3,h3 G3,h3 +G3,h11 +G3,h3 G3,h3 G3,h3 \ No newline at end of file diff --git a/Assets/SoundSamples/eat.wav b/Assets/SoundSamples/eat.wav new file mode 100644 index 0000000..f8a5a9d Binary files /dev/null and b/Assets/SoundSamples/eat.wav differ diff --git a/Build.rogue b/Build.rogue new file mode 100644 index 0000000..4796580 --- /dev/null +++ b/Build.rogue @@ -0,0 +1,322 @@ +# To run this build file, install Rogue from github.com/AbePralle/Rogue and type "rogo" at the command line. + +#$ LIBRARIES(macOS) = rgbds( which:rgbasm ) + +# description()s are optional - Rogo uses introspection to determine which commands are available. +# 'rogo help default' displays the description for "default", etc. +description( "default", "The default action is performed when no other actions are specified. Use 'rogo default' to explicitly perform the default option." ) +description( "help", "Displays a list of all actions that can be performed by Rogo." ) + +augment Build + PROPERTIES + # These properties can be overridden with a Local.mk setting ROM_NAME=OtherName etc. + ROM_NAME = "FGB.gb" +endAugment + +routine rogo_default + rogo_build +endRoutine + +routine rogo_build + local rgbasm = System.find_program( "rgbasm" ) + if (not rgbasm) + throw Error( "Please install the RGBDS Game Boy assembler from https://github.com/rednex/rgbds" ) + endIf + + File.create_folder( "Build" ) + File.create_folder( "ROM" ) + + local build_output = "Build/" + Build.ROM_NAME + local rom_output = "ROM/" + Build.ROM_NAME + + local newest_datafile_timestamp = 0.0 + forEach (datafile in File.listing("Data/**",&files,&ignore_hidden)) + newest_datafile_timestamp = newest_datafile_timestamp.or_larger( File.timestamp(datafile) ) + endForEach + + local obj_files = String[] + local any_new_obj_files = false + forEach (asm_file in File.listing("Source/**/*.asm")) + local obj_file = "Build/$.obj" (File.filename(asm_file).leftmost(-4)) + if (File.is_newer_than(asm_file,obj_file) or newest_datafile_timestamp > File.timestamp(obj_file)) + execute "rgbasm -p 0xff $ -o $" (asm_file,obj_file) + any_new_obj_files = true + elseIf (File.is_newer_than(obj_file,rom_output)) + any_new_obj_files = true + endIf + obj_files.add( obj_file ) + endForEach + + if (any_new_obj_files) + execute "rgblink --map Build/FGB.map --sym Build/FGB.sym $ -o $" (obj_files.join(" "),build_output) + execute "rgbfix -p 0xff -v $" (build_output) + + local file_size = File.size( build_output ) + println "> Copy $ -> $ ($ bytes)" (build_output,rom_output,file_size.format(",")) + File.copy( build_output, rom_output ) + else + println "No changes detected. Output: $ ($ bytes)" (rom_output,File.size(rom_output).format(",")) + endIf +endRoutine + +routine rogo_clean + verbose_delete( "Build" ) +endRoutine + +routine verbose_delete( filepath:String ) + if (File.exists(filepath)) + println "> Delete " + filepath + File.delete( filepath ) + endIf +endRoutine + +routine execute( commands:String, &suppress_error )->Logical + forEach (cmd in LineReader(commands)) + print( "> " ).println( cmd ) + if (System.run(cmd) != 0) + if (suppress_error) return false + else throw Error( "Build failed." ) + endIf + endForEach + return true +endRoutine + +#------------------------------------------------------------------------------ +# Introspection-based Launcher Framework +#------------------------------------------------------------------------------ +# Rogo is a "build your own build system" facilitator. At its core Rogo just recompiles build files if +# needed and then runs the build executable while forwarding any command line arguments. This file contains +# a default framework which uses introspection to turn command line arguments into parameterized routine calls. + +# Example: to handle the command "rogo abc xyz 5", define "routine rogo_abc_xyz( n:Int32 )". + +# "rogo_default" will run in the absence of any other command line argument. + +# The following "comment directives" can be used in this file to control how RogueC compiles it and to +# manage automatic dependency installation and linking. + +# Each of the following should be on a line beginning with the characters #$ (preceding whitespace is fine). +# Sample args are given. + +# ROGUEC = roguec # Path to roguec compiler to compile this file with +# ROGUEC_ARGS = --whatever # Additional options to pass to RogueC +# CPP = g++ -Wall -std=gnu++11 -fno-strict-aliasing -Wno-invalid-offsetof # C++ compiler path and/or invocation +# CPP_ARGS = -a -b -c # Additional C++ args +# LINK = true # Links following LIBRARIES with this Build file +# LINK = -lalpha -lbeta # Links following LIBRARIES and includes these additional flags +# LINK = false # Linking turned off for following LIBRARIES - info can still be obtained from #$LIBRARY_FLAGS() +# LINK(macOS) = ... # Options applying only to System.os=="macOS" (use with any OS and any comment directive) +# LIBRARIES = libalpha +# LIBRARIES = libbeta(library-name) +# LIBRARIES = libfreetype6-dev(freetype2) +# DEPENDENCIES = Library/Rogue/**/*.rogue +# +# LIBRARIES = name(package) +# LIBRARIES = name(package: install: link: which:) +# +# The following macro is replaced within this file (Build.rogue) - the libraries should also be declared in #$ LIBRARIES: +# +# $LIBRARY_FLAGS(lib1,lib2) # sample macro +# -> +# -Ipath/to/lib1/include -Lpath/to/lib1/library -I ... # sample replacement + +routine syntax( command:String, text:String ) + Build.rogo_syntax[ command ] = text +endRoutine + +routine description( command:String, text:String ) + Build.rogo_descriptions[ command ] = text +endRoutine + +routine help( command:String, description=null:String, syntax=null:String ) + if (description) Global.description( command, description ) + if (syntax) Global.syntax( command, syntax ) +endRoutine + +try + Build.launch +catch (err:Error) + Build.rogo_error = err + Build.on_error +endTry + +class Build [singleton] + PROPERTIES + rogo_syntax = StringTable<>() + rogo_descriptions = StringTable<>() + rogo_prefix = ?:{ $moduleName.count:$moduleName "::" || "" } + "rogo_" : String + rogo_command = "default" + rogo_args = @[] + rogo_error : Error + + LOCAL_DEFS_FILE = "Local.mk" + + METHODS + method launch + rogo_args.add( forEach in System.command_line_arguments ) + read_defs + on_launch + parse_args + dispatch_command + + method dispatch_command + local m = find_command( rogo_command ) + require m || "no such routine rogo_$()" (rogo_command) + + local args = @[] + forEach (arg in rogo_args) + which (arg) + case "true": args.add( true ) + case "false": args.add( false ) + case "null": args.add( NullValue ) + others: args.add( arg ) + endWhich + endForEach + if (m.parameter_count == 1 and args.count > 1) args = @[ args ] # Wrap args in a ValueList. + m( args ) + + method find_command( name:String )->MethodInfo + return <>.find_global_method( rogo_prefix + name ) + + method on_error + Console.error.println "=" * 79 + Console.error.println rogo_error + Console.error.println "=" * 79 + on_exit + System.exit 1 + + method on_command_found + noAction + + method on_command_not_found + println "=" * 79 + println "ERROR: No such command '$'." (rogo_args.first) + println "=" * 79 + println + rogo_command = "help" + rogo_args.clear + on_command_found + + method on_launch + noAction + + method on_exit + noAction + + method parse_args + block + if (rogo_args.count) + local parts = String[] + parts.add( forEach in rogo_args ) + rogo_args.clear + + while (parts.count) + local cmd = _join( parts ) + if (find_command(cmd)) + rogo_command = cmd + on_command_found + escapeBlock + endIf + rogo_args.insert( parts.remove_last ) + endWhile + + on_command_not_found + endIf + + # Use default command + on_command_found + endBlock + + method read_defs + read_defs( LOCAL_DEFS_FILE ) + + method read_defs( defs_filepath:String ) + # Attempt to read defs from Local.mk + local overrides = String[] + if (File.exists(defs_filepath)) + forEach (line in LineReader(File(defs_filepath))) + if (line.contains("=")) + local name = line.before_first('=').trimmed + local value = line.after_first('=').trimmed + if (value.begins_with('"') or value.begins_with('\'')) + value = value.leftmost(-1).rightmost(-1) + endIf + local p = <>.find_property( name ) + if (p) + overrides.add( "$ = $" (name,value) ) + <>.set_property( this, p, Value(value) ) + endIf + endIf + endForEach + endIf + + method _join( value:Value )->String + local args = String[] + args.add( forEach in value ) + return args.join( "_" ) +endClass + + +routine rogo_help( command="":String ) + command = Build._join( Build.rogo_args ) + if (command.count) + local syntax = get_syntax( command ) + local success = false + if (syntax) + println "SYNTAX" + println " " + syntax + println + success = true + endIf + local description = get_description( command ) + if (description) + println "DESCRIPTION" + forEach (line in LineReader(description.word_wrapped(76))) + print( " " ).println( line ) + endForEach + println + success = true + endIf + if (success) + return + else + println "=" * 79 + println "ERROR: No such command '$'." (command) + println "=" * 79 + println + endIf + endIf + + println "USAGE" + local lines = String[] + forEach (m in <>.global_methods) + if (m.name.begins_with(Build.rogo_prefix)) + lines.add( " " + get_syntax(m.name.after_first(Build.rogo_prefix)) ) + endIf + endForEach + lines.sort( (a,b)=>(aString + if (Build.rogo_syntax.contains(m_name)) + return "rogo " + Build.rogo_syntax[ m_name ] + else + local m = <>.find_global_method( Build.rogo_prefix + m_name ) + if (not m) return null + local line = "rogo $" (m_name.replacing('_',' ')) + line += " <$>" (m.parameter_name(forEach in 0..String + if (Build.rogo_descriptions.contains(m_name)) + return Build.rogo_descriptions[ m_name ] + else + return null + endIf +endRoutine diff --git a/Data/Cinema/Appomattox/appwaves0.bg b/Data/Cinema/Appomattox/appwaves0.bg new file mode 100644 index 0000000..874ad05 Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves0.bg differ diff --git a/Data/Cinema/Appomattox/appwaves0.dat b/Data/Cinema/Appomattox/appwaves0.dat new file mode 100644 index 0000000..e6e640b Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves0.dat differ diff --git a/Data/Cinema/Appomattox/appwaves1.bg b/Data/Cinema/Appomattox/appwaves1.bg new file mode 100644 index 0000000..65afa0c Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves1.bg differ diff --git a/Data/Cinema/Appomattox/appwaves1.dat b/Data/Cinema/Appomattox/appwaves1.dat new file mode 100644 index 0000000..9970657 Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves1.dat differ diff --git a/Data/Cinema/Appomattox/appwaves1.sp b/Data/Cinema/Appomattox/appwaves1.sp new file mode 100644 index 0000000..7872ac2 Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves1.sp differ diff --git a/Data/Cinema/Appomattox/appwaves2.bg b/Data/Cinema/Appomattox/appwaves2.bg new file mode 100644 index 0000000..fbee78b Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves2.bg differ diff --git a/Data/Cinema/Appomattox/appwaves2.dat b/Data/Cinema/Appomattox/appwaves2.dat new file mode 100644 index 0000000..bfac3ff Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves2.dat differ diff --git a/Data/Cinema/Appomattox/appwaves3.bg b/Data/Cinema/Appomattox/appwaves3.bg new file mode 100644 index 0000000..82a23c9 Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves3.bg differ diff --git a/Data/Cinema/Appomattox/appwaves3.dat b/Data/Cinema/Appomattox/appwaves3.dat new file mode 100644 index 0000000..bc3204b Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves3.dat differ diff --git a/Data/Cinema/Appomattox/appwaves4.bg b/Data/Cinema/Appomattox/appwaves4.bg new file mode 100644 index 0000000..fd694c5 Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves4.bg differ diff --git a/Data/Cinema/Appomattox/appwaves4.dat b/Data/Cinema/Appomattox/appwaves4.dat new file mode 100644 index 0000000..0e5392e Binary files /dev/null and b/Data/Cinema/Appomattox/appwaves4.dat differ diff --git a/Data/Cinema/Appomattox/cantsave.bg b/Data/Cinema/Appomattox/cantsave.bg new file mode 100644 index 0000000..15fb28e Binary files /dev/null and b/Data/Cinema/Appomattox/cantsave.bg differ diff --git a/Data/Cinema/Appomattox/cantsave_flying.bg b/Data/Cinema/Appomattox/cantsave_flying.bg new file mode 100644 index 0000000..e0dc0f6 Binary files /dev/null and b/Data/Cinema/Appomattox/cantsave_flying.bg differ diff --git a/Data/Cinema/Appomattox/cloud0.bg b/Data/Cinema/Appomattox/cloud0.bg new file mode 100644 index 0000000..8dbbe81 Binary files /dev/null and b/Data/Cinema/Appomattox/cloud0.bg differ diff --git a/Data/Cinema/Appomattox/cloud1.bg b/Data/Cinema/Appomattox/cloud1.bg new file mode 100644 index 0000000..e2a2cdb Binary files /dev/null and b/Data/Cinema/Appomattox/cloud1.bg differ diff --git a/Data/Cinema/Appomattox/cloud2.bg b/Data/Cinema/Appomattox/cloud2.bg new file mode 100644 index 0000000..e2f8383 Binary files /dev/null and b/Data/Cinema/Appomattox/cloud2.bg differ diff --git a/Data/Cinema/Appomattox/cloud3.bg b/Data/Cinema/Appomattox/cloud3.bg new file mode 100644 index 0000000..649b971 Binary files /dev/null and b/Data/Cinema/Appomattox/cloud3.bg differ diff --git a/Data/Cinema/Appomattox/cloud4.bg b/Data/Cinema/Appomattox/cloud4.bg new file mode 100644 index 0000000..cf36002 Binary files /dev/null and b/Data/Cinema/Appomattox/cloud4.bg differ diff --git a/Data/Cinema/Appomattox/cloud5.bg b/Data/Cinema/Appomattox/cloud5.bg new file mode 100644 index 0000000..0a4edfa Binary files /dev/null and b/Data/Cinema/Appomattox/cloud5.bg differ diff --git a/Data/Cinema/Appomattox/cloud6.bg b/Data/Cinema/Appomattox/cloud6.bg new file mode 100644 index 0000000..01f2d1b Binary files /dev/null and b/Data/Cinema/Appomattox/cloud6.bg differ diff --git a/Data/Cinema/Appomattox/cloud7.bg b/Data/Cinema/Appomattox/cloud7.bg new file mode 100644 index 0000000..812103d Binary files /dev/null and b/Data/Cinema/Appomattox/cloud7.bg differ diff --git a/Data/Cinema/Appomattox/cloudvscroll.bg b/Data/Cinema/Appomattox/cloudvscroll.bg new file mode 100644 index 0000000..8bd3c95 Binary files /dev/null and b/Data/Cinema/Appomattox/cloudvscroll.bg differ diff --git a/Data/Cinema/Appomattox/controlpanel.bg b/Data/Cinema/Appomattox/controlpanel.bg new file mode 100644 index 0000000..1ccd6ab Binary files /dev/null and b/Data/Cinema/Appomattox/controlpanel.bg differ diff --git a/Data/Cinema/Appomattox/fgbmap_big.bg b/Data/Cinema/Appomattox/fgbmap_big.bg new file mode 100644 index 0000000..c5d5c22 Binary files /dev/null and b/Data/Cinema/Appomattox/fgbmap_big.bg differ diff --git a/Data/Cinema/Appomattox/kiwi1.bg b/Data/Cinema/Appomattox/kiwi1.bg new file mode 100644 index 0000000..518b4a4 Binary files /dev/null and b/Data/Cinema/Appomattox/kiwi1.bg differ diff --git a/Data/Cinema/Appomattox/kiwi2.bg b/Data/Cinema/Appomattox/kiwi2.bg new file mode 100644 index 0000000..968b235 Binary files /dev/null and b/Data/Cinema/Appomattox/kiwi2.bg differ diff --git a/Data/Cinema/Appomattox/kiwi3.bg b/Data/Cinema/Appomattox/kiwi3.bg new file mode 100644 index 0000000..7fe9a49 Binary files /dev/null and b/Data/Cinema/Appomattox/kiwi3.bg differ diff --git a/Data/Cinema/Appomattox/landing_bg.bg b/Data/Cinema/Appomattox/landing_bg.bg new file mode 100644 index 0000000..0b4806c Binary files /dev/null and b/Data/Cinema/Appomattox/landing_bg.bg differ diff --git a/Data/Cinema/Appomattox/landing_sprites.sp b/Data/Cinema/Appomattox/landing_sprites.sp new file mode 100644 index 0000000..19f195e Binary files /dev/null and b/Data/Cinema/Appomattox/landing_sprites.sp differ diff --git a/Data/Cinema/Appomattox/lz_brokenwall.bg b/Data/Cinema/Appomattox/lz_brokenwall.bg new file mode 100644 index 0000000..278da67 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_brokenwall.bg differ diff --git a/Data/Cinema/Appomattox/lz_canyon.bg b/Data/Cinema/Appomattox/lz_canyon.bg new file mode 100644 index 0000000..0132253 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_canyon.bg differ diff --git a/Data/Cinema/Appomattox/lz_croutongate.bg b/Data/Cinema/Appomattox/lz_croutongate.bg new file mode 100644 index 0000000..a8e21e1 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_croutongate.bg differ diff --git a/Data/Cinema/Appomattox/lz_desert.bg b/Data/Cinema/Appomattox/lz_desert.bg new file mode 100644 index 0000000..ff219e3 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_desert.bg differ diff --git a/Data/Cinema/Appomattox/lz_gate.bg b/Data/Cinema/Appomattox/lz_gate.bg new file mode 100644 index 0000000..68ade39 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_gate.bg differ diff --git a/Data/Cinema/Appomattox/lz_graves.bg b/Data/Cinema/Appomattox/lz_graves.bg new file mode 100644 index 0000000..a2a80f8 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_graves.bg differ diff --git a/Data/Cinema/Appomattox/lz_ice1.bg b/Data/Cinema/Appomattox/lz_ice1.bg new file mode 100644 index 0000000..9705fd1 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_ice1.bg differ diff --git a/Data/Cinema/Appomattox/lz_icecubes.bg b/Data/Cinema/Appomattox/lz_icecubes.bg new file mode 100644 index 0000000..a847f96 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_icecubes.bg differ diff --git a/Data/Cinema/Appomattox/lz_jungle.bg b/Data/Cinema/Appomattox/lz_jungle.bg new file mode 100644 index 0000000..3ed0fe9 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_jungle.bg differ diff --git a/Data/Cinema/Appomattox/lz_mist.bg b/Data/Cinema/Appomattox/lz_mist.bg new file mode 100644 index 0000000..7ebc877 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_mist.bg differ diff --git a/Data/Cinema/Appomattox/lz_mountains.bg b/Data/Cinema/Appomattox/lz_mountains.bg new file mode 100644 index 0000000..182db75 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_mountains.bg differ diff --git a/Data/Cinema/Appomattox/lz_ocean.bg b/Data/Cinema/Appomattox/lz_ocean.bg new file mode 100644 index 0000000..462fff0 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_ocean.bg differ diff --git a/Data/Cinema/Appomattox/lz_palace.bg b/Data/Cinema/Appomattox/lz_palace.bg new file mode 100644 index 0000000..39798af Binary files /dev/null and b/Data/Cinema/Appomattox/lz_palace.bg differ diff --git a/Data/Cinema/Appomattox/lz_pencil.bg b/Data/Cinema/Appomattox/lz_pencil.bg new file mode 100644 index 0000000..661df33 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_pencil.bg differ diff --git a/Data/Cinema/Appomattox/lz_treepath.bg b/Data/Cinema/Appomattox/lz_treepath.bg new file mode 100644 index 0000000..3bc180d Binary files /dev/null and b/Data/Cinema/Appomattox/lz_treepath.bg differ diff --git a/Data/Cinema/Appomattox/lz_trees1.bg b/Data/Cinema/Appomattox/lz_trees1.bg new file mode 100644 index 0000000..44dc652 Binary files /dev/null and b/Data/Cinema/Appomattox/lz_trees1.bg differ diff --git a/Data/Cinema/Appomattox/lz_zorhaus.bg b/Data/Cinema/Appomattox/lz_zorhaus.bg new file mode 100644 index 0000000..ee7b49f Binary files /dev/null and b/Data/Cinema/Appomattox/lz_zorhaus.bg differ diff --git a/Data/Cinema/Appomattox/nokey.bg b/Data/Cinema/Appomattox/nokey.bg new file mode 100644 index 0000000..d155dc7 Binary files /dev/null and b/Data/Cinema/Appomattox/nokey.bg differ diff --git a/Data/Cinema/Appomattox/panelsprites.sp b/Data/Cinema/Appomattox/panelsprites.sp new file mode 100644 index 0000000..d0d1aca Binary files /dev/null and b/Data/Cinema/Appomattox/panelsprites.sp differ diff --git a/Data/Cinema/Appomattox/savegame.bg b/Data/Cinema/Appomattox/savegame.bg new file mode 100644 index 0000000..f123296 Binary files /dev/null and b/Data/Cinema/Appomattox/savegame.bg differ diff --git a/Data/Cinema/Appomattox/starfield.bg b/Data/Cinema/Appomattox/starfield.bg new file mode 100644 index 0000000..1b69b25 Binary files /dev/null and b/Data/Cinema/Appomattox/starfield.bg differ diff --git a/Data/Cinema/Appomattox/starfield_sprite.sp b/Data/Cinema/Appomattox/starfield_sprite.sp new file mode 100644 index 0000000..750a5a1 Binary files /dev/null and b/Data/Cinema/Appomattox/starfield_sprite.sp differ diff --git a/Data/Cinema/CharSelect/backinside.bg b/Data/Cinema/CharSelect/backinside.bg new file mode 100644 index 0000000..04a18a1 Binary files /dev/null and b/Data/Cinema/CharSelect/backinside.bg differ diff --git a/Data/Cinema/CharSelect/charselecthills.bg b/Data/Cinema/CharSelect/charselecthills.bg new file mode 100644 index 0000000..3a21a26 Binary files /dev/null and b/Data/Cinema/CharSelect/charselecthills.bg differ diff --git a/Data/Cinema/CharSelect/deathscreen.bg b/Data/Cinema/CharSelect/deathscreen.bg new file mode 100644 index 0000000..058482f Binary files /dev/null and b/Data/Cinema/CharSelect/deathscreen.bg differ diff --git a/Data/Cinema/CharSelect/kgname.bg b/Data/Cinema/CharSelect/kgname.bg new file mode 100644 index 0000000..3e7f409 Binary files /dev/null and b/Data/Cinema/CharSelect/kgname.bg differ diff --git a/Data/Cinema/CharSelect/select_ba.sp b/Data/Cinema/CharSelect/select_ba.sp new file mode 100644 index 0000000..a77b864 Binary files /dev/null and b/Data/Cinema/CharSelect/select_ba.sp differ diff --git a/Data/Cinema/CharSelect/select_ba_name.bg b/Data/Cinema/CharSelect/select_ba_name.bg new file mode 100644 index 0000000..a4fdabf Binary files /dev/null and b/Data/Cinema/CharSelect/select_ba_name.bg differ diff --git a/Data/Cinema/CharSelect/select_bg.bg b/Data/Cinema/CharSelect/select_bg.bg new file mode 100644 index 0000000..6154276 Binary files /dev/null and b/Data/Cinema/CharSelect/select_bg.bg differ diff --git a/Data/Cinema/CharSelect/select_bs.sp b/Data/Cinema/CharSelect/select_bs.sp new file mode 100644 index 0000000..bcc3eb5 Binary files /dev/null and b/Data/Cinema/CharSelect/select_bs.sp differ diff --git a/Data/Cinema/CharSelect/select_bs_name.bg b/Data/Cinema/CharSelect/select_bs_name.bg new file mode 100644 index 0000000..5a92585 Binary files /dev/null and b/Data/Cinema/CharSelect/select_bs_name.bg differ diff --git a/Data/Cinema/CharSelect/select_grenade.sp b/Data/Cinema/CharSelect/select_grenade.sp new file mode 100644 index 0000000..e4e5001 Binary files /dev/null and b/Data/Cinema/CharSelect/select_grenade.sp differ diff --git a/Data/Cinema/CharSelect/select_haiku.sp b/Data/Cinema/CharSelect/select_haiku.sp new file mode 100644 index 0000000..9fc90b4 Binary files /dev/null and b/Data/Cinema/CharSelect/select_haiku.sp differ diff --git a/Data/Cinema/CharSelect/select_haiku_name.bg b/Data/Cinema/CharSelect/select_haiku_name.bg new file mode 100644 index 0000000..c08712b Binary files /dev/null and b/Data/Cinema/CharSelect/select_haiku_name.bg differ diff --git a/Data/Cinema/Disco/party_over.bg b/Data/Cinema/Disco/party_over.bg new file mode 100644 index 0000000..0c452f7 Binary files /dev/null and b/Data/Cinema/Disco/party_over.bg differ diff --git a/Data/Cinema/Disco/success.bg b/Data/Cinema/Disco/success.bg new file mode 100644 index 0000000..23e24ea Binary files /dev/null and b/Data/Cinema/Disco/success.bg differ diff --git a/Data/Cinema/Distress/appomattox_big.bg b/Data/Cinema/Distress/appomattox_big.bg new file mode 100644 index 0000000..acb8b50 Binary files /dev/null and b/Data/Cinema/Distress/appomattox_big.bg differ diff --git a/Data/Cinema/Distress/appomattox_big_sprites.bg b/Data/Cinema/Distress/appomattox_big_sprites.bg new file mode 100644 index 0000000..841d506 Binary files /dev/null and b/Data/Cinema/Distress/appomattox_big_sprites.bg differ diff --git a/Data/Cinema/Distress/appomattox_big_sprites.sp b/Data/Cinema/Distress/appomattox_big_sprites.sp new file mode 100644 index 0000000..3c649be Binary files /dev/null and b/Data/Cinema/Distress/appomattox_big_sprites.sp differ diff --git a/Data/Cinema/Distress/appomattox_tokiwi.bg b/Data/Cinema/Distress/appomattox_tokiwi.bg new file mode 100644 index 0000000..81e2844 Binary files /dev/null and b/Data/Cinema/Distress/appomattox_tokiwi.bg differ diff --git a/Data/Cinema/Distress/at_gunpoint.bg b/Data/Cinema/Distress/at_gunpoint.bg new file mode 100644 index 0000000..8fcdb22 Binary files /dev/null and b/Data/Cinema/Distress/at_gunpoint.bg differ diff --git a/Data/Cinema/Distress/at_gunpoint_sprites.sp b/Data/Cinema/Distress/at_gunpoint_sprites.sp new file mode 100644 index 0000000..2f61ac8 Binary files /dev/null and b/Data/Cinema/Distress/at_gunpoint_sprites.sp differ diff --git a/Data/Cinema/Distress/ba.bg b/Data/Cinema/Distress/ba.bg new file mode 100644 index 0000000..efc0884 Binary files /dev/null and b/Data/Cinema/Distress/ba.bg differ diff --git a/Data/Cinema/Distress/bee.sp b/Data/Cinema/Distress/bee.sp new file mode 100644 index 0000000..46359bd Binary files /dev/null and b/Data/Cinema/Distress/bee.sp differ diff --git a/Data/Cinema/Distress/bs.bg b/Data/Cinema/Distress/bs.bg new file mode 100644 index 0000000..b8f4370 Binary files /dev/null and b/Data/Cinema/Distress/bs.bg differ diff --git a/Data/Cinema/Distress/downramp.bg b/Data/Cinema/Distress/downramp.bg new file mode 100644 index 0000000..a908298 Binary files /dev/null and b/Data/Cinema/Distress/downramp.bg differ diff --git a/Data/Cinema/Distress/downramp_sprites.sp b/Data/Cinema/Distress/downramp_sprites.sp new file mode 100644 index 0000000..c8d506f Binary files /dev/null and b/Data/Cinema/Distress/downramp_sprites.sp differ diff --git a/Data/Cinema/Distress/fgstars.sp b/Data/Cinema/Distress/fgstars.sp new file mode 100644 index 0000000..0858f4c Binary files /dev/null and b/Data/Cinema/Distress/fgstars.sp differ diff --git a/Data/Cinema/Distress/final.bg b/Data/Cinema/Distress/final.bg new file mode 100644 index 0000000..56d5304 Binary files /dev/null and b/Data/Cinema/Distress/final.bg differ diff --git a/Data/Cinema/Distress/flour_and_flower.bg b/Data/Cinema/Distress/flour_and_flower.bg new file mode 100644 index 0000000..e65697e Binary files /dev/null and b/Data/Cinema/Distress/flour_and_flower.bg differ diff --git a/Data/Cinema/Distress/flour_gang_mono.bg b/Data/Cinema/Distress/flour_gang_mono.bg new file mode 100644 index 0000000..47eeca7 Binary files /dev/null and b/Data/Cinema/Distress/flour_gang_mono.bg differ diff --git a/Data/Cinema/Distress/flourdriving.bg b/Data/Cinema/Distress/flourdriving.bg new file mode 100644 index 0000000..34aab5c Binary files /dev/null and b/Data/Cinema/Distress/flourdriving.bg differ diff --git a/Data/Cinema/Distress/flower_and_flour_establishing.bg b/Data/Cinema/Distress/flower_and_flour_establishing.bg new file mode 100644 index 0000000..b421497 Binary files /dev/null and b/Data/Cinema/Distress/flower_and_flour_establishing.bg differ diff --git a/Data/Cinema/Distress/flowernight.bg b/Data/Cinema/Distress/flowernight.bg new file mode 100644 index 0000000..6d32340 Binary files /dev/null and b/Data/Cinema/Distress/flowernight.bg differ diff --git a/Data/Cinema/Distress/flowerviewscreen.bg b/Data/Cinema/Distress/flowerviewscreen.bg new file mode 100644 index 0000000..a6d48f1 Binary files /dev/null and b/Data/Cinema/Distress/flowerviewscreen.bg differ diff --git a/Data/Cinema/Distress/moon_mini.bg b/Data/Cinema/Distress/moon_mini.bg new file mode 100644 index 0000000..957982f Binary files /dev/null and b/Data/Cinema/Distress/moon_mini.bg differ diff --git a/Data/Cinema/Distress/nar_certaindanger.bg b/Data/Cinema/Distress/nar_certaindanger.bg new file mode 100644 index 0000000..7a87487 Binary files /dev/null and b/Data/Cinema/Distress/nar_certaindanger.bg differ diff --git a/Data/Cinema/Distress/nar_meanwhile.bg b/Data/Cinema/Distress/nar_meanwhile.bg new file mode 100644 index 0000000..447264a Binary files /dev/null and b/Data/Cinema/Distress/nar_meanwhile.bg differ diff --git a/Data/Cinema/Distress/palace.bg b/Data/Cinema/Distress/palace.bg new file mode 100644 index 0000000..16f430f Binary files /dev/null and b/Data/Cinema/Distress/palace.bg differ diff --git a/Data/Cinema/Distress/pirate_sprites.sp b/Data/Cinema/Distress/pirate_sprites.sp new file mode 100644 index 0000000..41618a9 Binary files /dev/null and b/Data/Cinema/Distress/pirate_sprites.sp differ diff --git a/Data/Cinema/Distress/remote.bg b/Data/Cinema/Distress/remote.bg new file mode 100644 index 0000000..1c929c3 Binary files /dev/null and b/Data/Cinema/Distress/remote.bg differ diff --git a/Data/Cinema/Distress/spacepan.bg b/Data/Cinema/Distress/spacepan.bg new file mode 100644 index 0000000..276e33a Binary files /dev/null and b/Data/Cinema/Distress/spacepan.bg differ diff --git a/Data/Cinema/Distress/yacht_mini.sp b/Data/Cinema/Distress/yacht_mini.sp new file mode 100644 index 0000000..f9ee68c Binary files /dev/null and b/Data/Cinema/Distress/yacht_mini.sp differ diff --git a/Data/Cinema/Distress/yacht_under_fire.bg b/Data/Cinema/Distress/yacht_under_fire.bg new file mode 100644 index 0000000..313e50f Binary files /dev/null and b/Data/Cinema/Distress/yacht_under_fire.bg differ diff --git a/Data/Cinema/Ending/appland3d2.bg b/Data/Cinema/Ending/appland3d2.bg new file mode 100644 index 0000000..a7c15b9 Binary files /dev/null and b/Data/Cinema/Ending/appland3d2.bg differ diff --git a/Data/Cinema/Ending/appland_sprites.sp b/Data/Cinema/Ending/appland_sprites.sp new file mode 100644 index 0000000..ec1a2f8 Binary files /dev/null and b/Data/Cinema/Ending/appland_sprites.sp differ diff --git a/Data/Cinema/Ending/appx_takeoff.bg b/Data/Cinema/Ending/appx_takeoff.bg new file mode 100644 index 0000000..05b7d1d Binary files /dev/null and b/Data/Cinema/Ending/appx_takeoff.bg differ diff --git a/Data/Cinema/Ending/appx_takeoff_sprites.sp b/Data/Cinema/Ending/appx_takeoff_sprites.sp new file mode 100644 index 0000000..22a43e1 Binary files /dev/null and b/Data/Cinema/Ending/appx_takeoff_sprites.sp differ diff --git a/Data/Cinema/Ending/big_station_approach.bg b/Data/Cinema/Ending/big_station_approach.bg new file mode 100644 index 0000000..a789c28 Binary files /dev/null and b/Data/Cinema/Ending/big_station_approach.bg differ diff --git a/Data/Cinema/Ending/big_station_sprites.sp b/Data/Cinema/Ending/big_station_sprites.sp new file mode 100644 index 0000000..9165010 Binary files /dev/null and b/Data/Cinema/Ending/big_station_sprites.sp differ diff --git a/Data/Cinema/Ending/button.bg b/Data/Cinema/Ending/button.bg new file mode 100644 index 0000000..7cde1b3 Binary files /dev/null and b/Data/Cinema/Ending/button.bg differ diff --git a/Data/Cinema/Ending/gyro_screen.bg b/Data/Cinema/Ending/gyro_screen.bg new file mode 100644 index 0000000..c475775 Binary files /dev/null and b/Data/Cinema/Ending/gyro_screen.bg differ diff --git a/Data/Cinema/Ending/minuteslater.bg b/Data/Cinema/Ending/minuteslater.bg new file mode 100644 index 0000000..e2c56ea Binary files /dev/null and b/Data/Cinema/Ending/minuteslater.bg differ diff --git a/Data/Cinema/Ending/small_station_approach.bg b/Data/Cinema/Ending/small_station_approach.bg new file mode 100644 index 0000000..4223247 Binary files /dev/null and b/Data/Cinema/Ending/small_station_approach.bg differ diff --git a/Data/Cinema/Ending/small_station_sprites.sp b/Data/Cinema/Ending/small_station_sprites.sp new file mode 100644 index 0000000..079b468 Binary files /dev/null and b/Data/Cinema/Ending/small_station_sprites.sp differ diff --git a/Data/Cinema/Ending/station_tactical.bg b/Data/Cinema/Ending/station_tactical.bg new file mode 100644 index 0000000..2296311 Binary files /dev/null and b/Data/Cinema/Ending/station_tactical.bg differ diff --git a/Data/Cinema/Ending/station_tactical_sprites.sp b/Data/Cinema/Ending/station_tactical_sprites.sp new file mode 100644 index 0000000..088fa16 Binary files /dev/null and b/Data/Cinema/Ending/station_tactical_sprites.sp differ diff --git a/Data/Cinema/Intro/bcs_vestigial.bg b/Data/Cinema/Intro/bcs_vestigial.bg new file mode 100644 index 0000000..0224512 Binary files /dev/null and b/Data/Cinema/Intro/bcs_vestigial.bg differ diff --git a/Data/Cinema/Intro/brainiac.bg b/Data/Cinema/Intro/brainiac.bg new file mode 100644 index 0000000..cd0ec0d Binary files /dev/null and b/Data/Cinema/Intro/brainiac.bg differ diff --git a/Data/Cinema/Intro/dropship_tiny.sp b/Data/Cinema/Intro/dropship_tiny.sp new file mode 100644 index 0000000..a6c3f24 Binary files /dev/null and b/Data/Cinema/Intro/dropship_tiny.sp differ diff --git a/Data/Cinema/Intro/group_in_triumph.bg b/Data/Cinema/Intro/group_in_triumph.bg new file mode 100644 index 0000000..2fb3bf9 Binary files /dev/null and b/Data/Cinema/Intro/group_in_triumph.bg differ diff --git a/Data/Cinema/Intro/gyro_cornered_gun.sp b/Data/Cinema/Intro/gyro_cornered_gun.sp new file mode 100644 index 0000000..be36be7 Binary files /dev/null and b/Data/Cinema/Intro/gyro_cornered_gun.sp differ diff --git a/Data/Cinema/Intro/gyrocornered.bg b/Data/Cinema/Intro/gyrocornered.bg new file mode 100644 index 0000000..11d1d9b Binary files /dev/null and b/Data/Cinema/Intro/gyrocornered.bg differ diff --git a/Data/Cinema/Intro/moon.bg b/Data/Cinema/Intro/moon.bg new file mode 100644 index 0000000..2344619 Binary files /dev/null and b/Data/Cinema/Intro/moon.bg differ diff --git a/Data/Cinema/Intro/moontact.bg b/Data/Cinema/Intro/moontact.bg new file mode 100644 index 0000000..387cae5 Binary files /dev/null and b/Data/Cinema/Intro/moontact.bg differ diff --git a/Data/Cinema/Intro/nar_crewquarters.bg b/Data/Cinema/Intro/nar_crewquarters.bg new file mode 100644 index 0000000..2f1de91 Binary files /dev/null and b/Data/Cinema/Intro/nar_crewquarters.bg differ diff --git a/Data/Cinema/Intro/nar_skippyshuttle.bg b/Data/Cinema/Intro/nar_skippyshuttle.bg new file mode 100644 index 0000000..6437399 Binary files /dev/null and b/Data/Cinema/Intro/nar_skippyshuttle.bg differ diff --git a/Data/Cinema/Intro/narrator_warroom.bg b/Data/Cinema/Intro/narrator_warroom.bg new file mode 100644 index 0000000..c36e491 Binary files /dev/null and b/Data/Cinema/Intro/narrator_warroom.bg differ diff --git a/Data/Cinema/Intro/space_bg1.bg b/Data/Cinema/Intro/space_bg1.bg new file mode 100644 index 0000000..1916ee2 Binary files /dev/null and b/Data/Cinema/Intro/space_bg1.bg differ diff --git a/Data/Cinema/Intro/tactmap.bg b/Data/Cinema/Intro/tactmap.bg new file mode 100644 index 0000000..6e2041f Binary files /dev/null and b/Data/Cinema/Intro/tactmap.bg differ diff --git a/Data/Cinema/Intro/temp.sp b/Data/Cinema/Intro/temp.sp new file mode 100644 index 0000000..536908c Binary files /dev/null and b/Data/Cinema/Intro/temp.sp differ diff --git a/Data/Cinema/Intro/triumphBIG.bg b/Data/Cinema/Intro/triumphBIG.bg new file mode 100644 index 0000000..c11e22d Binary files /dev/null and b/Data/Cinema/Intro/triumphBIG.bg differ diff --git a/Data/Cinema/Intro/triumph_small.sp b/Data/Cinema/Intro/triumph_small.sp new file mode 100644 index 0000000..bb6caa8 Binary files /dev/null and b/Data/Cinema/Intro/triumph_small.sp differ diff --git a/Data/Cinema/Logo/fgbtitle.bg b/Data/Cinema/Logo/fgbtitle.bg new file mode 100644 index 0000000..55951d4 Binary files /dev/null and b/Data/Cinema/Logo/fgbtitle.bg differ diff --git a/Data/Cinema/Logo/logo160.bg b/Data/Cinema/Logo/logo160.bg new file mode 100644 index 0000000..3f230ca Binary files /dev/null and b/Data/Cinema/Logo/logo160.bg differ diff --git a/Data/Cinema/Logo/ocloud0.bg b/Data/Cinema/Logo/ocloud0.bg new file mode 100644 index 0000000..e145d08 Binary files /dev/null and b/Data/Cinema/Logo/ocloud0.bg differ diff --git a/Data/Cinema/Logo/ocloud1.bg b/Data/Cinema/Logo/ocloud1.bg new file mode 100644 index 0000000..05757b1 Binary files /dev/null and b/Data/Cinema/Logo/ocloud1.bg differ diff --git a/Data/Cinema/Logo/ocloud2.bg b/Data/Cinema/Logo/ocloud2.bg new file mode 100644 index 0000000..82a98b8 Binary files /dev/null and b/Data/Cinema/Logo/ocloud2.bg differ diff --git a/Data/Cinema/Logo/ocloud3.bg b/Data/Cinema/Logo/ocloud3.bg new file mode 100644 index 0000000..13a4432 Binary files /dev/null and b/Data/Cinema/Logo/ocloud3.bg differ diff --git a/Data/Cinema/Logo/ocloud4.bg b/Data/Cinema/Logo/ocloud4.bg new file mode 100644 index 0000000..c8a955b Binary files /dev/null and b/Data/Cinema/Logo/ocloud4.bg differ diff --git a/Data/Cinema/Logo/ocloud5.bg b/Data/Cinema/Logo/ocloud5.bg new file mode 100644 index 0000000..b95cad6 Binary files /dev/null and b/Data/Cinema/Logo/ocloud5.bg differ diff --git a/Data/Cinema/Logo/ocloud6.bg b/Data/Cinema/Logo/ocloud6.bg new file mode 100644 index 0000000..dfb8bb0 Binary files /dev/null and b/Data/Cinema/Logo/ocloud6.bg differ diff --git a/Data/Cinema/Logo/ocloud7.bg b/Data/Cinema/Logo/ocloud7.bg new file mode 100644 index 0000000..9db23d3 Binary files /dev/null and b/Data/Cinema/Logo/ocloud7.bg differ diff --git a/Data/Cinema/Logo/ocloud8.bg b/Data/Cinema/Logo/ocloud8.bg new file mode 100644 index 0000000..b95af2a Binary files /dev/null and b/Data/Cinema/Logo/ocloud8.bg differ diff --git a/Data/Cinema/Logo/ocloud9.bg b/Data/Cinema/Logo/ocloud9.bg new file mode 100644 index 0000000..098288c Binary files /dev/null and b/Data/Cinema/Logo/ocloud9.bg differ diff --git a/Data/Cinema/Logo/oclouda.bg b/Data/Cinema/Logo/oclouda.bg new file mode 100644 index 0000000..e15496b Binary files /dev/null and b/Data/Cinema/Logo/oclouda.bg differ diff --git a/Data/Cinema/Logo/ocloudb.bg b/Data/Cinema/Logo/ocloudb.bg new file mode 100644 index 0000000..8d20455 Binary files /dev/null and b/Data/Cinema/Logo/ocloudb.bg differ diff --git a/Data/Cinema/Logo/ocloudc.bg b/Data/Cinema/Logo/ocloudc.bg new file mode 100644 index 0000000..b69a406 Binary files /dev/null and b/Data/Cinema/Logo/ocloudc.bg differ diff --git a/Data/Cinema/Logo/ocloudd.bg b/Data/Cinema/Logo/ocloudd.bg new file mode 100644 index 0000000..2b18e0d Binary files /dev/null and b/Data/Cinema/Logo/ocloudd.bg differ diff --git a/Data/Cinema/Logo/ocloude.bg b/Data/Cinema/Logo/ocloude.bg new file mode 100644 index 0000000..882b750 Binary files /dev/null and b/Data/Cinema/Logo/ocloude.bg differ diff --git a/Data/Cinema/Logo/ocloudf.bg b/Data/Cinema/Logo/ocloudf.bg new file mode 100644 index 0000000..2f0f417 Binary files /dev/null and b/Data/Cinema/Logo/ocloudf.bg differ diff --git a/Data/Cinema/Logo/ocloudtest.bg b/Data/Cinema/Logo/ocloudtest.bg new file mode 100644 index 0000000..e145d08 Binary files /dev/null and b/Data/Cinema/Logo/ocloudtest.bg differ diff --git a/Data/Cinema/Logo/presents.bg b/Data/Cinema/Logo/presents.bg new file mode 100644 index 0000000..51739c9 Binary files /dev/null and b/Data/Cinema/Logo/presents.bg differ diff --git a/Data/Cinema/Logo/titlesprite.sp b/Data/Cinema/Logo/titlesprite.sp new file mode 100644 index 0000000..dcc174b Binary files /dev/null and b/Data/Cinema/Logo/titlesprite.sp differ diff --git a/Data/Cinema/MainCharDialog/flour_triumph.bg b/Data/Cinema/MainCharDialog/flour_triumph.bg new file mode 100644 index 0000000..c47e5d8 Binary files /dev/null and b/Data/Cinema/MainCharDialog/flour_triumph.bg differ diff --git a/Data/Cinema/MainCharDialog/haiku.bg b/Data/Cinema/MainCharDialog/haiku.bg new file mode 100644 index 0000000..7b99e0b Binary files /dev/null and b/Data/Cinema/MainCharDialog/haiku.bg differ diff --git a/Data/Cinema/MainCharDialog/skippy_triumph.bg b/Data/Cinema/MainCharDialog/skippy_triumph.bg new file mode 100644 index 0000000..be50569 Binary files /dev/null and b/Data/Cinema/MainCharDialog/skippy_triumph.bg differ diff --git a/Data/Cinema/Map/fgbmap_big.bg b/Data/Cinema/Map/fgbmap_big.bg new file mode 100644 index 0000000..407f89f Binary files /dev/null and b/Data/Cinema/Map/fgbmap_big.bg differ diff --git a/Data/Cinema/Menu/MainMenu.bg b/Data/Cinema/Menu/MainMenu.bg new file mode 100644 index 0000000..7ab5f9a Binary files /dev/null and b/Data/Cinema/Menu/MainMenu.bg differ diff --git a/Data/Cinema/Menu/WaitingToJoin.bg b/Data/Cinema/Menu/WaitingToJoin.bg new file mode 100644 index 0000000..eb3b7a8 Binary files /dev/null and b/Data/Cinema/Menu/WaitingToJoin.bg differ diff --git a/Data/Cinema/Menu/bullet.sp b/Data/Cinema/Menu/bullet.sp new file mode 100644 index 0000000..12c20b0 Binary files /dev/null and b/Data/Cinema/Menu/bullet.sp differ diff --git a/Data/Cinema/Menu/fgbmenu.bg b/Data/Cinema/Menu/fgbmenu.bg new file mode 100644 index 0000000..32b8678 Binary files /dev/null and b/Data/Cinema/Menu/fgbmenu.bg differ diff --git a/Data/Cinema/Menu/menuCursor.sp b/Data/Cinema/Menu/menuCursor.sp new file mode 100644 index 0000000..6e343f0 Binary files /dev/null and b/Data/Cinema/Menu/menuCursor.sp differ diff --git a/Data/Cinema/Menu/waiting_to_join.bg b/Data/Cinema/Menu/waiting_to_join.bg new file mode 100644 index 0000000..7ca38f2 Binary files /dev/null and b/Data/Cinema/Menu/waiting_to_join.bg differ diff --git a/Data/Cinema/Promo/haveseenthelast.bg b/Data/Cinema/Promo/haveseenthelast.bg new file mode 100644 index 0000000..744e41e Binary files /dev/null and b/Data/Cinema/Promo/haveseenthelast.bg differ diff --git a/Data/Cinema/Promo/publish.bg b/Data/Cinema/Promo/publish.bg new file mode 100644 index 0000000..2012f7f Binary files /dev/null and b/Data/Cinema/Promo/publish.bg differ diff --git a/Data/Cinema/Promo/willtheyland.bg b/Data/Cinema/Promo/willtheyland.bg new file mode 100644 index 0000000..c805911 Binary files /dev/null and b/Data/Cinema/Promo/willtheyland.bg differ diff --git a/Data/Cinema/Wedding/bs_driving.bg b/Data/Cinema/Wedding/bs_driving.bg new file mode 100644 index 0000000..8ad27de Binary files /dev/null and b/Data/Cinema/Wedding/bs_driving.bg differ diff --git a/Data/Cinema/Wedding/flour_at_wedding.bg b/Data/Cinema/Wedding/flour_at_wedding.bg new file mode 100644 index 0000000..59176a2 Binary files /dev/null and b/Data/Cinema/Wedding/flour_at_wedding.bg differ diff --git a/Data/Cinema/Wedding/flower_at_wedding.bg b/Data/Cinema/Wedding/flower_at_wedding.bg new file mode 100644 index 0000000..91b8284 Binary files /dev/null and b/Data/Cinema/Wedding/flower_at_wedding.bg differ diff --git a/Data/Cinema/Wedding/gang_watches_front.bg b/Data/Cinema/Wedding/gang_watches_front.bg new file mode 100644 index 0000000..bbb27ce Binary files /dev/null and b/Data/Cinema/Wedding/gang_watches_front.bg differ diff --git a/Data/Cinema/Wedding/gang_watches_wedding.bg b/Data/Cinema/Wedding/gang_watches_wedding.bg new file mode 100644 index 0000000..c74b562 Binary files /dev/null and b/Data/Cinema/Wedding/gang_watches_wedding.bg differ diff --git a/Data/Cinema/Wedding/gyro_big.bg b/Data/Cinema/Wedding/gyro_big.bg new file mode 100644 index 0000000..f61a3d6 Binary files /dev/null and b/Data/Cinema/Wedding/gyro_big.bg differ diff --git a/Data/Cinema/Wedding/gyro_costume.sp b/Data/Cinema/Wedding/gyro_costume.sp new file mode 100644 index 0000000..0f6ecd1 Binary files /dev/null and b/Data/Cinema/Wedding/gyro_costume.sp differ diff --git a/Data/Cinema/Wedding/gyro_tree.bg b/Data/Cinema/Wedding/gyro_tree.bg new file mode 100644 index 0000000..9bc91fa Binary files /dev/null and b/Data/Cinema/Wedding/gyro_tree.bg differ diff --git a/Data/Cinema/Wedding/in_prison.bg b/Data/Cinema/Wedding/in_prison.bg new file mode 100644 index 0000000..e411b4d Binary files /dev/null and b/Data/Cinema/Wedding/in_prison.bg differ diff --git a/Data/Cinema/Wedding/preacher.bg b/Data/Cinema/Wedding/preacher.bg new file mode 100644 index 0000000..9d2e526 Binary files /dev/null and b/Data/Cinema/Wedding/preacher.bg differ diff --git a/Data/Cinema/Wedding/wedding_panoramic.bg b/Data/Cinema/Wedding/wedding_panoramic.bg new file mode 100644 index 0000000..72cea62 Binary files /dev/null and b/Data/Cinema/Wedding/wedding_panoramic.bg differ diff --git a/Data/Dialog/Apocalypse/l0012_alldefused.gtx b/Data/Dialog/Apocalypse/l0012_alldefused.gtx new file mode 100644 index 0000000..e8b1913 Binary files /dev/null and b/Data/Dialog/Apocalypse/l0012_alldefused.gtx differ diff --git a/Data/Dialog/Apocalypse/l0012_bombs.gtx b/Data/Dialog/Apocalypse/l0012_bombs.gtx new file mode 100644 index 0000000..c191118 Binary files /dev/null and b/Data/Dialog/Apocalypse/l0012_bombs.gtx differ diff --git a/Data/Dialog/Apocalypse/l0012_defused.gtx b/Data/Dialog/Apocalypse/l0012_defused.gtx new file mode 100644 index 0000000..338ef97 Binary files /dev/null and b/Data/Dialog/Apocalypse/l0012_defused.gtx differ diff --git a/Data/Dialog/Apocalypse/l1104_apocalypse.gtx b/Data/Dialog/Apocalypse/l1104_apocalypse.gtx new file mode 100644 index 0000000..1462fd5 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1104_apocalypse.gtx differ diff --git a/Data/Dialog/Apocalypse/l1104_letsgo.gtx b/Data/Dialog/Apocalypse/l1104_letsgo.gtx new file mode 100644 index 0000000..c33a8bd Binary files /dev/null and b/Data/Dialog/Apocalypse/l1104_letsgo.gtx differ diff --git a/Data/Dialog/Apocalypse/l1104_station.gtx b/Data/Dialog/Apocalypse/l1104_station.gtx new file mode 100644 index 0000000..cfb25d6 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1104_station.gtx differ diff --git a/Data/Dialog/Apocalypse/l1104_whereisgyro.gtx b/Data/Dialog/Apocalypse/l1104_whereisgyro.gtx new file mode 100644 index 0000000..ebe3aec Binary files /dev/null and b/Data/Dialog/Apocalypse/l1104_whereisgyro.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_allset.gtx b/Data/Dialog/Apocalypse/l1204_allset.gtx new file mode 100644 index 0000000..9148704 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_allset.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_datahere.gtx b/Data/Dialog/Apocalypse/l1204_datahere.gtx new file mode 100644 index 0000000..b910011 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_datahere.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gotitall.gtx b/Data/Dialog/Apocalypse/l1204_gotitall.gtx new file mode 100644 index 0000000..476024b Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gotitall.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_button.gtx b/Data/Dialog/Apocalypse/l1204_gyro_button.gtx new file mode 100644 index 0000000..8ebc021 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_button.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_escape.gtx b/Data/Dialog/Apocalypse/l1204_gyro_escape.gtx new file mode 100644 index 0000000..acbd93a Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_escape.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_explode.gtx b/Data/Dialog/Apocalypse/l1204_gyro_explode.gtx new file mode 100644 index 0000000..0a28fbe Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_explode.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_notthere.gtx b/Data/Dialog/Apocalypse/l1204_gyro_notthere.gtx new file mode 100644 index 0000000..c99398b Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_notthere.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_ofcourse.gtx b/Data/Dialog/Apocalypse/l1204_gyro_ofcourse.gtx new file mode 100644 index 0000000..62ee733 Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_ofcourse.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_gyro_unfortunately.gtx b/Data/Dialog/Apocalypse/l1204_gyro_unfortunately.gtx new file mode 100644 index 0000000..b837e8f Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_gyro_unfortunately.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_letsroll.gtx b/Data/Dialog/Apocalypse/l1204_letsroll.gtx new file mode 100644 index 0000000..482e9fd Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_letsroll.gtx differ diff --git a/Data/Dialog/Apocalypse/l1204_note.gtx b/Data/Dialog/Apocalypse/l1204_note.gtx new file mode 100644 index 0000000..482e9fd Binary files /dev/null and b/Data/Dialog/Apocalypse/l1204_note.gtx differ diff --git a/Data/Dialog/Distress/BA_surrendering.gtx b/Data/Dialog/Distress/BA_surrendering.gtx new file mode 100644 index 0000000..a522d62 Binary files /dev/null and b/Data/Dialog/Distress/BA_surrendering.gtx differ diff --git a/Data/Dialog/Distress/ba_goneawhile.gtx b/Data/Dialog/Distress/ba_goneawhile.gtx new file mode 100644 index 0000000..6cdc295 Binary files /dev/null and b/Data/Dialog/Distress/ba_goneawhile.gtx differ diff --git a/Data/Dialog/Distress/bs_nearKiwi.gtx b/Data/Dialog/Distress/bs_nearKiwi.gtx new file mode 100644 index 0000000..d35fb5b Binary files /dev/null and b/Data/Dialog/Distress/bs_nearKiwi.gtx differ diff --git a/Data/Dialog/Distress/captain_cider.gtx b/Data/Dialog/Distress/captain_cider.gtx new file mode 100644 index 0000000..cb222f5 Binary files /dev/null and b/Data/Dialog/Distress/captain_cider.gtx differ diff --git a/Data/Dialog/Distress/captain_goodness.gtx b/Data/Dialog/Distress/captain_goodness.gtx new file mode 100644 index 0000000..e96d0d1 Binary files /dev/null and b/Data/Dialog/Distress/captain_goodness.gtx differ diff --git a/Data/Dialog/Distress/captain_holdout.gtx b/Data/Dialog/Distress/captain_holdout.gtx new file mode 100644 index 0000000..0c8506d Binary files /dev/null and b/Data/Dialog/Distress/captain_holdout.gtx differ diff --git a/Data/Dialog/Distress/captain_no.gtx b/Data/Dialog/Distress/captain_no.gtx new file mode 100644 index 0000000..9d1dcc3 Binary files /dev/null and b/Data/Dialog/Distress/captain_no.gtx differ diff --git a/Data/Dialog/Distress/captain_nostuff.gtx b/Data/Dialog/Distress/captain_nostuff.gtx new file mode 100644 index 0000000..8ada142 Binary files /dev/null and b/Data/Dialog/Distress/captain_nostuff.gtx differ diff --git a/Data/Dialog/Distress/captain_nothanks.gtx b/Data/Dialog/Distress/captain_nothanks.gtx new file mode 100644 index 0000000..3be422c Binary files /dev/null and b/Data/Dialog/Distress/captain_nothanks.gtx differ diff --git a/Data/Dialog/Distress/captain_okay.gtx b/Data/Dialog/Distress/captain_okay.gtx new file mode 100644 index 0000000..115978d Binary files /dev/null and b/Data/Dialog/Distress/captain_okay.gtx differ diff --git a/Data/Dialog/Distress/captain_seeyou.gtx b/Data/Dialog/Distress/captain_seeyou.gtx new file mode 100644 index 0000000..2a3ba7a Binary files /dev/null and b/Data/Dialog/Distress/captain_seeyou.gtx differ diff --git a/Data/Dialog/Distress/captain_showit.gtx b/Data/Dialog/Distress/captain_showit.gtx new file mode 100644 index 0000000..eeb9817 Binary files /dev/null and b/Data/Dialog/Distress/captain_showit.gtx differ diff --git a/Data/Dialog/Distress/captain_shuttle.gtx b/Data/Dialog/Distress/captain_shuttle.gtx new file mode 100644 index 0000000..0d01b32 Binary files /dev/null and b/Data/Dialog/Distress/captain_shuttle.gtx differ diff --git a/Data/Dialog/Distress/captain_whyglum.gtx b/Data/Dialog/Distress/captain_whyglum.gtx new file mode 100644 index 0000000..4b9336a Binary files /dev/null and b/Data/Dialog/Distress/captain_whyglum.gtx differ diff --git a/Data/Dialog/Distress/captain_winsome.gtx b/Data/Dialog/Distress/captain_winsome.gtx new file mode 100644 index 0000000..8a57d9f Binary files /dev/null and b/Data/Dialog/Distress/captain_winsome.gtx differ diff --git a/Data/Dialog/Distress/haiku_cider.gtx b/Data/Dialog/Distress/haiku_cider.gtx new file mode 100644 index 0000000..e013b3a Binary files /dev/null and b/Data/Dialog/Distress/haiku_cider.gtx differ diff --git a/Data/Dialog/Distress/haiku_signal.gtx b/Data/Dialog/Distress/haiku_signal.gtx new file mode 100644 index 0000000..c21cbe6 Binary files /dev/null and b/Data/Dialog/Distress/haiku_signal.gtx differ diff --git a/Data/Dialog/Distress/lady_badNews.gtx b/Data/Dialog/Distress/lady_badNews.gtx new file mode 100644 index 0000000..09966ad Binary files /dev/null and b/Data/Dialog/Distress/lady_badNews.gtx differ diff --git a/Data/Dialog/Distress/lady_bigBullies.gtx b/Data/Dialog/Distress/lady_bigBullies.gtx new file mode 100644 index 0000000..b7a79f2 Binary files /dev/null and b/Data/Dialog/Distress/lady_bigBullies.gtx differ diff --git a/Data/Dialog/Distress/lady_dispatched.gtx b/Data/Dialog/Distress/lady_dispatched.gtx new file mode 100644 index 0000000..edfe250 Binary files /dev/null and b/Data/Dialog/Distress/lady_dispatched.gtx differ diff --git a/Data/Dialog/Distress/lady_help.gtx b/Data/Dialog/Distress/lady_help.gtx new file mode 100644 index 0000000..8e19abe Binary files /dev/null and b/Data/Dialog/Distress/lady_help.gtx differ diff --git a/Data/Dialog/Distress/lady_insist.gtx b/Data/Dialog/Distress/lady_insist.gtx new file mode 100644 index 0000000..ebdbd73 Binary files /dev/null and b/Data/Dialog/Distress/lady_insist.gtx differ diff --git a/Data/Dialog/Distress/lady_must.gtx b/Data/Dialog/Distress/lady_must.gtx new file mode 100644 index 0000000..9848e47 Binary files /dev/null and b/Data/Dialog/Distress/lady_must.gtx differ diff --git a/Data/Dialog/Distress/lady_no.gtx b/Data/Dialog/Distress/lady_no.gtx new file mode 100644 index 0000000..27dbe0c Binary files /dev/null and b/Data/Dialog/Distress/lady_no.gtx differ diff --git a/Data/Dialog/Distress/lady_please.gtx b/Data/Dialog/Distress/lady_please.gtx new file mode 100644 index 0000000..757f868 Binary files /dev/null and b/Data/Dialog/Distress/lady_please.gtx differ diff --git a/Data/Dialog/Distress/lady_poorCaptain.gtx b/Data/Dialog/Distress/lady_poorCaptain.gtx new file mode 100644 index 0000000..33d2697 Binary files /dev/null and b/Data/Dialog/Distress/lady_poorCaptain.gtx differ diff --git a/Data/Dialog/Distress/lady_saved.gtx b/Data/Dialog/Distress/lady_saved.gtx new file mode 100644 index 0000000..4de2811 Binary files /dev/null and b/Data/Dialog/Distress/lady_saved.gtx differ diff --git a/Data/Dialog/Distress/lady_stay.gtx b/Data/Dialog/Distress/lady_stay.gtx new file mode 100644 index 0000000..e020181 Binary files /dev/null and b/Data/Dialog/Distress/lady_stay.gtx differ diff --git a/Data/Dialog/Distress/lady_surrender.gtx b/Data/Dialog/Distress/lady_surrender.gtx new file mode 100644 index 0000000..6fcbd32 Binary files /dev/null and b/Data/Dialog/Distress/lady_surrender.gtx differ diff --git a/Data/Dialog/Distress/lady_wait.gtx b/Data/Dialog/Distress/lady_wait.gtx new file mode 100644 index 0000000..9256805 Binary files /dev/null and b/Data/Dialog/Distress/lady_wait.gtx differ diff --git a/Data/Dialog/Distress/meanwhile_1.gtx b/Data/Dialog/Distress/meanwhile_1.gtx new file mode 100644 index 0000000..00158b9 Binary files /dev/null and b/Data/Dialog/Distress/meanwhile_1.gtx differ diff --git a/Data/Dialog/Distress/meanwhile_2.gtx b/Data/Dialog/Distress/meanwhile_2.gtx new file mode 100644 index 0000000..ec1767b Binary files /dev/null and b/Data/Dialog/Distress/meanwhile_2.gtx differ diff --git a/Data/Dialog/Intro/blank.gtx b/Data/Dialog/Intro/blank.gtx new file mode 100644 index 0000000..9b7e680 Binary files /dev/null and b/Data/Dialog/Intro/blank.gtx differ diff --git a/Data/Dialog/Intro/flour1.gtx b/Data/Dialog/Intro/flour1.gtx new file mode 100644 index 0000000..8c04ff0 Binary files /dev/null and b/Data/Dialog/Intro/flour1.gtx differ diff --git a/Data/Dialog/Intro/flour2.gtx b/Data/Dialog/Intro/flour2.gtx new file mode 100644 index 0000000..ef74a2c Binary files /dev/null and b/Data/Dialog/Intro/flour2.gtx differ diff --git a/Data/Dialog/Intro/flour3.gtx b/Data/Dialog/Intro/flour3.gtx new file mode 100644 index 0000000..7d83ced Binary files /dev/null and b/Data/Dialog/Intro/flour3.gtx differ diff --git a/Data/Dialog/Intro/flour4.gtx b/Data/Dialog/Intro/flour4.gtx new file mode 100644 index 0000000..d94761e Binary files /dev/null and b/Data/Dialog/Intro/flour4.gtx differ diff --git a/Data/Dialog/Intro/flour5.gtx b/Data/Dialog/Intro/flour5.gtx new file mode 100644 index 0000000..83f50cb Binary files /dev/null and b/Data/Dialog/Intro/flour5.gtx differ diff --git a/Data/Dialog/Intro/flour6.gtx b/Data/Dialog/Intro/flour6.gtx new file mode 100644 index 0000000..03e04ca Binary files /dev/null and b/Data/Dialog/Intro/flour6.gtx differ diff --git a/Data/Dialog/Intro/flour7.gtx b/Data/Dialog/Intro/flour7.gtx new file mode 100644 index 0000000..7ba003e Binary files /dev/null and b/Data/Dialog/Intro/flour7.gtx differ diff --git a/Data/Dialog/Intro/gyro_cornered1.gtx b/Data/Dialog/Intro/gyro_cornered1.gtx new file mode 100644 index 0000000..e8f8456 Binary files /dev/null and b/Data/Dialog/Intro/gyro_cornered1.gtx differ diff --git a/Data/Dialog/Intro/gyro_cornered2.gtx b/Data/Dialog/Intro/gyro_cornered2.gtx new file mode 100644 index 0000000..d098898 Binary files /dev/null and b/Data/Dialog/Intro/gyro_cornered2.gtx differ diff --git a/Data/Dialog/Intro/gyro_cornered3.gtx b/Data/Dialog/Intro/gyro_cornered3.gtx new file mode 100644 index 0000000..e377211 Binary files /dev/null and b/Data/Dialog/Intro/gyro_cornered3.gtx differ diff --git a/Data/Dialog/Intro/gyro_cornered4.gtx b/Data/Dialog/Intro/gyro_cornered4.gtx new file mode 100644 index 0000000..f16e534 Binary files /dev/null and b/Data/Dialog/Intro/gyro_cornered4.gtx differ diff --git a/Data/Dialog/Intro/intercom.gtx b/Data/Dialog/Intro/intercom.gtx new file mode 100644 index 0000000..43c63fe Binary files /dev/null and b/Data/Dialog/Intro/intercom.gtx differ diff --git a/Data/Dialog/Intro/skippy1.gtx b/Data/Dialog/Intro/skippy1.gtx new file mode 100644 index 0000000..e1d3198 Binary files /dev/null and b/Data/Dialog/Intro/skippy1.gtx differ diff --git a/Data/Dialog/Intro/skippy2.gtx b/Data/Dialog/Intro/skippy2.gtx new file mode 100644 index 0000000..452feff Binary files /dev/null and b/Data/Dialog/Intro/skippy2.gtx differ diff --git a/Data/Dialog/Intro/skippy3.gtx b/Data/Dialog/Intro/skippy3.gtx new file mode 100644 index 0000000..70a09e3 Binary files /dev/null and b/Data/Dialog/Intro/skippy3.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_brainiac1.gtx b/Data/Dialog/Intro/skippycapture_brainiac1.gtx new file mode 100644 index 0000000..90e569f Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_brainiac1.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_brainiac2.gtx b/Data/Dialog/Intro/skippycapture_brainiac2.gtx new file mode 100644 index 0000000..8a1affd Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_brainiac2.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_brainiac3.gtx b/Data/Dialog/Intro/skippycapture_brainiac3.gtx new file mode 100644 index 0000000..5e99bd7 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_brainiac3.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_flour1.gtx b/Data/Dialog/Intro/skippycapture_flour1.gtx new file mode 100644 index 0000000..db538c3 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_flour1.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_flour2.gtx b/Data/Dialog/Intro/skippycapture_flour2.gtx new file mode 100644 index 0000000..d709a98 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_flour2.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_gyves1.gtx b/Data/Dialog/Intro/skippycapture_gyves1.gtx new file mode 100644 index 0000000..a8c3d18 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_gyves1.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_gyves1_2.gtx b/Data/Dialog/Intro/skippycapture_gyves1_2.gtx new file mode 100644 index 0000000..081c584 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_gyves1_2.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_haiku1.gtx b/Data/Dialog/Intro/skippycapture_haiku1.gtx new file mode 100644 index 0000000..721a092 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_haiku1.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_haiku2.gtx b/Data/Dialog/Intro/skippycapture_haiku2.gtx new file mode 100644 index 0000000..7e7e5df Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_haiku2.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_skippy1.gtx b/Data/Dialog/Intro/skippycapture_skippy1.gtx new file mode 100644 index 0000000..49a8166 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_skippy1.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_skippy1_2.gtx b/Data/Dialog/Intro/skippycapture_skippy1_2.gtx new file mode 100644 index 0000000..80033a2 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_skippy1_2.gtx differ diff --git a/Data/Dialog/Intro/skippycapture_skippy2.gtx b/Data/Dialog/Intro/skippycapture_skippy2.gtx new file mode 100644 index 0000000..bdd5d21 Binary files /dev/null and b/Data/Dialog/Intro/skippycapture_skippy2.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_bringIt.gtx b/Data/Dialog/IntroBS/brainiac_bringIt.gtx new file mode 100644 index 0000000..2cef948 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_bringIt.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_canAnswerAny.gtx b/Data/Dialog/IntroBS/brainiac_canAnswerAny.gtx new file mode 100644 index 0000000..19e838e Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_canAnswerAny.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes1.gtx b/Data/Dialog/IntroBS/brainiac_computes1.gtx new file mode 100644 index 0000000..72af5b6 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes1.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes2.gtx b/Data/Dialog/IntroBS/brainiac_computes2.gtx new file mode 100644 index 0000000..4eea10f Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes2.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes3.gtx b/Data/Dialog/IntroBS/brainiac_computes3.gtx new file mode 100644 index 0000000..ac7a401 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes3.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes4.gtx b/Data/Dialog/IntroBS/brainiac_computes4.gtx new file mode 100644 index 0000000..8f5649f Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes4.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes5.gtx b/Data/Dialog/IntroBS/brainiac_computes5.gtx new file mode 100644 index 0000000..11b03af Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes5.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes6.gtx b/Data/Dialog/IntroBS/brainiac_computes6.gtx new file mode 100644 index 0000000..856f717 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes6.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_computes7.gtx b/Data/Dialog/IntroBS/brainiac_computes7.gtx new file mode 100644 index 0000000..0ff1b34 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_computes7.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_detectIntruder.gtx b/Data/Dialog/IntroBS/brainiac_detectIntruder.gtx new file mode 100644 index 0000000..b4ead39 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_detectIntruder.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_idiotz.gtx b/Data/Dialog/IntroBS/brainiac_idiotz.gtx new file mode 100644 index 0000000..3576670 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_idiotz.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_justClose.gtx b/Data/Dialog/IntroBS/brainiac_justClose.gtx new file mode 100644 index 0000000..a2057ef Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_justClose.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_lovzHelping.gtx b/Data/Dialog/IntroBS/brainiac_lovzHelping.gtx new file mode 100644 index 0000000..9981763 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_lovzHelping.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_notNeedBRAINIAC.gtx b/Data/Dialog/IntroBS/brainiac_notNeedBRAINIAC.gtx new file mode 100644 index 0000000..e17fc65 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_notNeedBRAINIAC.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_sezAsk.gtx b/Data/Dialog/IntroBS/brainiac_sezAsk.gtx new file mode 100644 index 0000000..93b6f66 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_sezAsk.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_sorry.gtx b/Data/Dialog/IntroBS/brainiac_sorry.gtx new file mode 100644 index 0000000..9332752 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_sorry.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_surrender.gtx b/Data/Dialog/IntroBS/brainiac_surrender.gtx new file mode 100644 index 0000000..8603f17 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_surrender.gtx differ diff --git a/Data/Dialog/IntroBS/brainiac_wait.gtx b/Data/Dialog/IntroBS/brainiac_wait.gtx new file mode 100644 index 0000000..bb123e7 Binary files /dev/null and b/Data/Dialog/IntroBS/brainiac_wait.gtx differ diff --git a/Data/Dialog/IntroBS/bs_actually.gtx b/Data/Dialog/IntroBS/bs_actually.gtx new file mode 100644 index 0000000..85aef7c Binary files /dev/null and b/Data/Dialog/IntroBS/bs_actually.gtx differ diff --git a/Data/Dialog/IntroBS/bs_answerSomeQuestions.gtx b/Data/Dialog/IntroBS/bs_answerSomeQuestions.gtx new file mode 100644 index 0000000..477998c Binary files /dev/null and b/Data/Dialog/IntroBS/bs_answerSomeQuestions.gtx differ diff --git a/Data/Dialog/IntroBS/bs_gotAPoint.gtx b/Data/Dialog/IntroBS/bs_gotAPoint.gtx new file mode 100644 index 0000000..c953058 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_gotAPoint.gtx differ diff --git a/Data/Dialog/IntroBS/bs_hangin1.gtx b/Data/Dialog/IntroBS/bs_hangin1.gtx new file mode 100644 index 0000000..7eb4624 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_hangin1.gtx differ diff --git a/Data/Dialog/IntroBS/bs_hangin3.gtx b/Data/Dialog/IntroBS/bs_hangin3.gtx new file mode 100644 index 0000000..213e981 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_hangin3.gtx differ diff --git a/Data/Dialog/IntroBS/bs_hangin5.gtx b/Data/Dialog/IntroBS/bs_hangin5.gtx new file mode 100644 index 0000000..f5b8855 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_hangin5.gtx differ diff --git a/Data/Dialog/IntroBS/bs_hereGoes.gtx b/Data/Dialog/IntroBS/bs_hereGoes.gtx new file mode 100644 index 0000000..0066479 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_hereGoes.gtx differ diff --git a/Data/Dialog/IntroBS/bs_idea.gtx b/Data/Dialog/IntroBS/bs_idea.gtx new file mode 100644 index 0000000..ac22fa3 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_idea.gtx differ diff --git a/Data/Dialog/IntroBS/bs_justYouAnMe.gtx b/Data/Dialog/IntroBS/bs_justYouAnMe.gtx new file mode 100644 index 0000000..0565b78 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_justYouAnMe.gtx differ diff --git a/Data/Dialog/IntroBS/bs_likeButter.gtx b/Data/Dialog/IntroBS/bs_likeButter.gtx new file mode 100644 index 0000000..0475838 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_likeButter.gtx differ diff --git a/Data/Dialog/IntroBS/bs_presto.gtx b/Data/Dialog/IntroBS/bs_presto.gtx new file mode 100644 index 0000000..215e3ea Binary files /dev/null and b/Data/Dialog/IntroBS/bs_presto.gtx differ diff --git a/Data/Dialog/IntroBS/bs_reallyHard.gtx b/Data/Dialog/IntroBS/bs_reallyHard.gtx new file mode 100644 index 0000000..f77852f Binary files /dev/null and b/Data/Dialog/IntroBS/bs_reallyHard.gtx differ diff --git a/Data/Dialog/IntroBS/bs_segashuating.gtx b/Data/Dialog/IntroBS/bs_segashuating.gtx new file mode 100644 index 0000000..f501d47 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_segashuating.gtx differ diff --git a/Data/Dialog/IntroBS/bs_showMe.gtx b/Data/Dialog/IntroBS/bs_showMe.gtx new file mode 100644 index 0000000..a565c26 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_showMe.gtx differ diff --git a/Data/Dialog/IntroBS/bs_slippery.gtx b/Data/Dialog/IntroBS/bs_slippery.gtx new file mode 100644 index 0000000..717ba8b Binary files /dev/null and b/Data/Dialog/IntroBS/bs_slippery.gtx differ diff --git a/Data/Dialog/IntroBS/bs_well.gtx b/Data/Dialog/IntroBS/bs_well.gtx new file mode 100644 index 0000000..ae6a3e7 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_well.gtx differ diff --git a/Data/Dialog/IntroBS/bs_wellSee.gtx b/Data/Dialog/IntroBS/bs_wellSee.gtx new file mode 100644 index 0000000..4b71331 Binary files /dev/null and b/Data/Dialog/IntroBS/bs_wellSee.gtx differ diff --git a/Data/Dialog/IntroBS/grunt_hangin2.gtx b/Data/Dialog/IntroBS/grunt_hangin2.gtx new file mode 100644 index 0000000..bf53541 Binary files /dev/null and b/Data/Dialog/IntroBS/grunt_hangin2.gtx differ diff --git a/Data/Dialog/IntroBS/grunt_hangin4.gtx b/Data/Dialog/IntroBS/grunt_hangin4.gtx new file mode 100644 index 0000000..ffcc61c Binary files /dev/null and b/Data/Dialog/IntroBS/grunt_hangin4.gtx differ diff --git a/Data/Dialog/IntroBS/guard_freeze.gtx b/Data/Dialog/IntroBS/guard_freeze.gtx new file mode 100644 index 0000000..6aca30e Binary files /dev/null and b/Data/Dialog/IntroBS/guard_freeze.gtx differ diff --git a/Data/Dialog/IntroBS/guard_moveAlong.gtx b/Data/Dialog/IntroBS/guard_moveAlong.gtx new file mode 100644 index 0000000..045b6a8 Binary files /dev/null and b/Data/Dialog/IntroBS/guard_moveAlong.gtx differ diff --git a/Data/Dialog/IntroBS/monitor_oneSecond.gtx b/Data/Dialog/IntroBS/monitor_oneSecond.gtx new file mode 100644 index 0000000..56087ea Binary files /dev/null and b/Data/Dialog/IntroBS/monitor_oneSecond.gtx differ diff --git a/Data/Dialog/IntroBS/monitor_onlyCroutons.gtx b/Data/Dialog/IntroBS/monitor_onlyCroutons.gtx new file mode 100644 index 0000000..dacf34f Binary files /dev/null and b/Data/Dialog/IntroBS/monitor_onlyCroutons.gtx differ diff --git a/Data/Dialog/IntroBS/monitor_openDoor.gtx b/Data/Dialog/IntroBS/monitor_openDoor.gtx new file mode 100644 index 0000000..85272de Binary files /dev/null and b/Data/Dialog/IntroBS/monitor_openDoor.gtx differ diff --git a/Data/Dialog/IntroBS/monitor_sorry.gtx b/Data/Dialog/IntroBS/monitor_sorry.gtx new file mode 100644 index 0000000..bafb458 Binary files /dev/null and b/Data/Dialog/IntroBS/monitor_sorry.gtx differ diff --git a/Data/Dialog/IntroBS/soldier_how.gtx b/Data/Dialog/IntroBS/soldier_how.gtx new file mode 100644 index 0000000..f76c0af Binary files /dev/null and b/Data/Dialog/IntroBS/soldier_how.gtx differ diff --git a/Data/Dialog/IntroBS/soldier_yellow.gtx b/Data/Dialog/IntroBS/soldier_yellow.gtx new file mode 100644 index 0000000..1f36ba5 Binary files /dev/null and b/Data/Dialog/IntroBS/soldier_yellow.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_anySign.gtx b/Data/Dialog/IntroHaiku/flour_anySign.gtx new file mode 100644 index 0000000..591c227 Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_anySign.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_headHome.gtx b/Data/Dialog/IntroHaiku/flour_headHome.gtx new file mode 100644 index 0000000..9975d6b Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_headHome.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_poorIambic.gtx b/Data/Dialog/IntroHaiku/flour_poorIambic.gtx new file mode 100644 index 0000000..330ae36 Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_poorIambic.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_poorQuatrain.gtx b/Data/Dialog/IntroHaiku/flour_poorQuatrain.gtx new file mode 100644 index 0000000..8b4fa00 Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_poorQuatrain.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_sabotage.gtx b/Data/Dialog/IntroHaiku/flour_sabotage.gtx new file mode 100644 index 0000000..9c1c363 Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_sabotage.gtx differ diff --git a/Data/Dialog/IntroHaiku/flour_sendBS.gtx b/Data/Dialog/IntroHaiku/flour_sendBS.gtx new file mode 100644 index 0000000..85a729a Binary files /dev/null and b/Data/Dialog/IntroHaiku/flour_sendBS.gtx differ diff --git a/Data/Dialog/IntroHaiku/haiku_askOkay.gtx b/Data/Dialog/IntroHaiku/haiku_askOkay.gtx new file mode 100644 index 0000000..cbba000 Binary files /dev/null and b/Data/Dialog/IntroHaiku/haiku_askOkay.gtx differ diff --git a/Data/Dialog/IntroHaiku/haiku_enterPrison.gtx b/Data/Dialog/IntroHaiku/haiku_enterPrison.gtx new file mode 100644 index 0000000..8ea7c63 Binary files /dev/null and b/Data/Dialog/IntroHaiku/haiku_enterPrison.gtx differ diff --git a/Data/Dialog/IntroHaiku/haiku_goAhead.gtx b/Data/Dialog/IntroHaiku/haiku_goAhead.gtx new file mode 100644 index 0000000..1f3acad Binary files /dev/null and b/Data/Dialog/IntroHaiku/haiku_goAhead.gtx differ diff --git a/Data/Dialog/IntroHaiku/haiku_theyNever.gtx b/Data/Dialog/IntroHaiku/haiku_theyNever.gtx new file mode 100644 index 0000000..84b18f3 Binary files /dev/null and b/Data/Dialog/IntroHaiku/haiku_theyNever.gtx differ diff --git a/Data/Dialog/IntroHaiku/haiku_warn.gtx b/Data/Dialog/IntroHaiku/haiku_warn.gtx new file mode 100644 index 0000000..56606d1 Binary files /dev/null and b/Data/Dialog/IntroHaiku/haiku_warn.gtx differ diff --git a/Data/Dialog/IntroHaiku/quatrain.gtx b/Data/Dialog/IntroHaiku/quatrain.gtx new file mode 100644 index 0000000..ef4ebf0 Binary files /dev/null and b/Data/Dialog/IntroHaiku/quatrain.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_anySign.gtx b/Data/Dialog/IntroHaiku/skippy_anySign.gtx new file mode 100644 index 0000000..21c473b Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_anySign.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_clues.gtx b/Data/Dialog/IntroHaiku/skippy_clues.gtx new file mode 100644 index 0000000..89fe8af Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_clues.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_holdOn.gtx b/Data/Dialog/IntroHaiku/skippy_holdOn.gtx new file mode 100644 index 0000000..a9ff85b Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_holdOn.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_letsGo.gtx b/Data/Dialog/IntroHaiku/skippy_letsGo.gtx new file mode 100644 index 0000000..1313308 Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_letsGo.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_loseForSure.gtx b/Data/Dialog/IntroHaiku/skippy_loseForSure.gtx new file mode 100644 index 0000000..f71c23a Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_loseForSure.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_notJustYet.gtx b/Data/Dialog/IntroHaiku/skippy_notJustYet.gtx new file mode 100644 index 0000000..45a8508 Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_notJustYet.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_smartestThing.gtx b/Data/Dialog/IntroHaiku/skippy_smartestThing.gtx new file mode 100644 index 0000000..aec5bfc Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_smartestThing.gtx differ diff --git a/Data/Dialog/IntroHaiku/skippy_woowee.gtx b/Data/Dialog/IntroHaiku/skippy_woowee.gtx new file mode 100644 index 0000000..c409ec6 Binary files /dev/null and b/Data/Dialog/IntroHaiku/skippy_woowee.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_ba1.gtx b/Data/Dialog/Landing/app_closed_gate_ba1.gtx new file mode 100644 index 0000000..d7683b2 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_ba1.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_ba2.gtx b/Data/Dialog/Landing/app_closed_gate_ba2.gtx new file mode 100644 index 0000000..a765181 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_ba2.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_ba3.gtx b/Data/Dialog/Landing/app_closed_gate_ba3.gtx new file mode 100644 index 0000000..ef19aa9 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_ba3.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_ba4.gtx b/Data/Dialog/Landing/app_closed_gate_ba4.gtx new file mode 100644 index 0000000..7dfb627 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_ba4.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_bs1.gtx b/Data/Dialog/Landing/app_closed_gate_bs1.gtx new file mode 100644 index 0000000..9fecc6a Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_bs1.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_bs2.gtx b/Data/Dialog/Landing/app_closed_gate_bs2.gtx new file mode 100644 index 0000000..4ee6bee Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_bs2.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_bs3.gtx b/Data/Dialog/Landing/app_closed_gate_bs3.gtx new file mode 100644 index 0000000..d210da9 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_bs3.gtx differ diff --git a/Data/Dialog/Landing/app_closed_gate_bs4.gtx b/Data/Dialog/Landing/app_closed_gate_bs4.gtx new file mode 100644 index 0000000..5c359ce --- /dev/null +++ b/Data/Dialog/Landing/app_closed_gate_bs4.gtx @@ -0,0 +1 @@ +ÔààÝñ \ No newline at end of file diff --git a/Data/Dialog/Landing/app_closed_gate_bs5.gtx b/Data/Dialog/Landing/app_closed_gate_bs5.gtx new file mode 100644 index 0000000..9ec3a26 Binary files /dev/null and b/Data/Dialog/Landing/app_closed_gate_bs5.gtx differ diff --git a/Data/Dialog/Landing/at_closed_gate1.gtx b/Data/Dialog/Landing/at_closed_gate1.gtx new file mode 100644 index 0000000..124c92a Binary files /dev/null and b/Data/Dialog/Landing/at_closed_gate1.gtx differ diff --git a/Data/Dialog/Landing/ba1.gtx b/Data/Dialog/Landing/ba1.gtx new file mode 100644 index 0000000..7eaf0ad Binary files /dev/null and b/Data/Dialog/Landing/ba1.gtx differ diff --git a/Data/Dialog/Landing/ba2.gtx b/Data/Dialog/Landing/ba2.gtx new file mode 100644 index 0000000..6af518f Binary files /dev/null and b/Data/Dialog/Landing/ba2.gtx differ diff --git a/Data/Dialog/Landing/ba_guns.gtx b/Data/Dialog/Landing/ba_guns.gtx new file mode 100644 index 0000000..0791c95 Binary files /dev/null and b/Data/Dialog/Landing/ba_guns.gtx differ diff --git a/Data/Dialog/Landing/ba_return_1.gtx b/Data/Dialog/Landing/ba_return_1.gtx new file mode 100644 index 0000000..7960d1d Binary files /dev/null and b/Data/Dialog/Landing/ba_return_1.gtx differ diff --git a/Data/Dialog/Landing/ba_whataboutspare.gtx b/Data/Dialog/Landing/ba_whataboutspare.gtx new file mode 100644 index 0000000..c42f428 Binary files /dev/null and b/Data/Dialog/Landing/ba_whataboutspare.gtx differ diff --git a/Data/Dialog/Landing/ba_whatever.gtx b/Data/Dialog/Landing/ba_whatever.gtx new file mode 100644 index 0000000..912733a --- /dev/null +++ b/Data/Dialog/Landing/ba_whatever.gtx @@ -0,0 +1 @@ + èÙÒåÖçÖãí \ No newline at end of file diff --git a/Data/Dialog/Landing/bs_absolutely.gtx b/Data/Dialog/Landing/bs_absolutely.gtx new file mode 100644 index 0000000..07df4ea Binary files /dev/null and b/Data/Dialog/Landing/bs_absolutely.gtx differ diff --git a/Data/Dialog/Landing/bs_cool.gtx b/Data/Dialog/Landing/bs_cool.gtx new file mode 100644 index 0000000..c175c5e Binary files /dev/null and b/Data/Dialog/Landing/bs_cool.gtx differ diff --git a/Data/Dialog/Landing/bs_finelotofgood.gtx b/Data/Dialog/Landing/bs_finelotofgood.gtx new file mode 100644 index 0000000..e77e555 Binary files /dev/null and b/Data/Dialog/Landing/bs_finelotofgood.gtx differ diff --git a/Data/Dialog/Landing/bs_to_guard_1.gtx b/Data/Dialog/Landing/bs_to_guard_1.gtx new file mode 100644 index 0000000..8617e67 --- /dev/null +++ b/Data/Dialog/Landing/bs_to_guard_1.gtx @@ -0,0 +1 @@ +èÒÚåí \ No newline at end of file diff --git a/Data/Dialog/Landing/bs_to_guard_2.gtx b/Data/Dialog/Landing/bs_to_guard_2.gtx new file mode 100644 index 0000000..464f8f3 Binary files /dev/null and b/Data/Dialog/Landing/bs_to_guard_2.gtx differ diff --git a/Data/Dialog/Landing/bs_to_guard_3.gtx b/Data/Dialog/Landing/bs_to_guard_3.gtx new file mode 100644 index 0000000..dc00a8b Binary files /dev/null and b/Data/Dialog/Landing/bs_to_guard_3.gtx differ diff --git a/Data/Dialog/Landing/bs_tookkey.gtx b/Data/Dialog/Landing/bs_tookkey.gtx new file mode 100644 index 0000000..61d9d4f Binary files /dev/null and b/Data/Dialog/Landing/bs_tookkey.gtx differ diff --git a/Data/Dialog/Landing/bs_wasspare.gtx b/Data/Dialog/Landing/bs_wasspare.gtx new file mode 100644 index 0000000..efa7ecc Binary files /dev/null and b/Data/Dialog/Landing/bs_wasspare.gtx differ diff --git a/Data/Dialog/Landing/finished.gtx b/Data/Dialog/Landing/finished.gtx new file mode 100644 index 0000000..aa9123b Binary files /dev/null and b/Data/Dialog/Landing/finished.gtx differ diff --git a/Data/Dialog/Landing/finished2.gtx b/Data/Dialog/Landing/finished2.gtx new file mode 100644 index 0000000..dab9d40 Binary files /dev/null and b/Data/Dialog/Landing/finished2.gtx differ diff --git a/Data/Dialog/Landing/guard1.gtx b/Data/Dialog/Landing/guard1.gtx new file mode 100644 index 0000000..a4706ff Binary files /dev/null and b/Data/Dialog/Landing/guard1.gtx differ diff --git a/Data/Dialog/Landing/guard2.gtx b/Data/Dialog/Landing/guard2.gtx new file mode 100644 index 0000000..3674cf4 Binary files /dev/null and b/Data/Dialog/Landing/guard2.gtx differ diff --git a/Data/Dialog/Landing/guard3.gtx b/Data/Dialog/Landing/guard3.gtx new file mode 100644 index 0000000..db03e2a Binary files /dev/null and b/Data/Dialog/Landing/guard3.gtx differ diff --git a/Data/Dialog/Landing/guard4.gtx b/Data/Dialog/Landing/guard4.gtx new file mode 100644 index 0000000..170f2bb Binary files /dev/null and b/Data/Dialog/Landing/guard4.gtx differ diff --git a/Data/Dialog/Landing/guard_dontcomecloser.gtx b/Data/Dialog/Landing/guard_dontcomecloser.gtx new file mode 100644 index 0000000..3d420bc Binary files /dev/null and b/Data/Dialog/Landing/guard_dontcomecloser.gtx differ diff --git a/Data/Dialog/Landing/guard_notpossible.gtx b/Data/Dialog/Landing/guard_notpossible.gtx new file mode 100644 index 0000000..6fd66cc Binary files /dev/null and b/Data/Dialog/Landing/guard_notpossible.gtx differ diff --git a/Data/Dialog/Landing/guard_pansies.gtx b/Data/Dialog/Landing/guard_pansies.gtx new file mode 100644 index 0000000..64dedb6 Binary files /dev/null and b/Data/Dialog/Landing/guard_pansies.gtx differ diff --git a/Data/Dialog/Landing/guard_really.gtx b/Data/Dialog/Landing/guard_really.gtx new file mode 100644 index 0000000..6fb01de Binary files /dev/null and b/Data/Dialog/Landing/guard_really.gtx differ diff --git a/Data/Dialog/Landing/guard_return_1.gtx b/Data/Dialog/Landing/guard_return_1.gtx new file mode 100644 index 0000000..a884faf --- /dev/null +++ b/Data/Dialog/Landing/guard_return_1.gtx @@ -0,0 +1 @@ +ÙÒÝåí \ No newline at end of file diff --git a/Data/Dialog/Landing/guard_return_2.gtx b/Data/Dialog/Landing/guard_return_2.gtx new file mode 100644 index 0000000..23477a8 Binary files /dev/null and b/Data/Dialog/Landing/guard_return_2.gtx differ diff --git a/Data/Dialog/Landing/guard_return_3.gtx b/Data/Dialog/Landing/guard_return_3.gtx new file mode 100644 index 0000000..597c580 Binary files /dev/null and b/Data/Dialog/Landing/guard_return_3.gtx differ diff --git a/Data/Dialog/Landing/guard_return_4.gtx b/Data/Dialog/Landing/guard_return_4.gtx new file mode 100644 index 0000000..3861e6d Binary files /dev/null and b/Data/Dialog/Landing/guard_return_4.gtx differ diff --git a/Data/Dialog/Landing/guard_to_bs_1.gtx b/Data/Dialog/Landing/guard_to_bs_1.gtx new file mode 100644 index 0000000..f037644 --- /dev/null +++ b/Data/Dialog/Landing/guard_to_bs_1.gtx @@ -0,0 +1 @@ +èÙÒåô \ No newline at end of file diff --git a/Data/Dialog/Landing/guard_to_bs_2.gtx b/Data/Dialog/Landing/guard_to_bs_2.gtx new file mode 100644 index 0000000..504ef3b --- /dev/null +++ b/Data/Dialog/Landing/guard_to_bs_2.gtx @@ -0,0 +1 @@ +ãÖÒÝÝêô \ No newline at end of file diff --git a/Data/Dialog/Landing/guard_to_bs_3.gtx b/Data/Dialog/Landing/guard_to_bs_3.gtx new file mode 100644 index 0000000..162bb6d Binary files /dev/null and b/Data/Dialog/Landing/guard_to_bs_3.gtx differ diff --git a/Data/Dialog/Landing/guard_yeah.gtx b/Data/Dialog/Landing/guard_yeah.gtx new file mode 100644 index 0000000..d301623 Binary files /dev/null and b/Data/Dialog/Landing/guard_yeah.gtx differ diff --git a/Data/Dialog/Landing/hero_checkgate.gtx b/Data/Dialog/Landing/hero_checkgate.gtx new file mode 100644 index 0000000..b5ab632 Binary files /dev/null and b/Data/Dialog/Landing/hero_checkgate.gtx differ diff --git a/Data/Dialog/Landing/hero_closedgate.gtx b/Data/Dialog/Landing/hero_closedgate.gtx new file mode 100644 index 0000000..5e5c8ed Binary files /dev/null and b/Data/Dialog/Landing/hero_closedgate.gtx differ diff --git a/Data/Dialog/Landing/hero_move.gtx b/Data/Dialog/Landing/hero_move.gtx new file mode 100644 index 0000000..4d8636a Binary files /dev/null and b/Data/Dialog/Landing/hero_move.gtx differ diff --git a/Data/Dialog/Landing/hero_report.gtx b/Data/Dialog/Landing/hero_report.gtx new file mode 100644 index 0000000..946c5a8 Binary files /dev/null and b/Data/Dialog/Landing/hero_report.gtx differ diff --git a/Data/Dialog/Landing/hero_whatever.gtx b/Data/Dialog/Landing/hero_whatever.gtx new file mode 100644 index 0000000..64ad90d Binary files /dev/null and b/Data/Dialog/Landing/hero_whatever.gtx differ diff --git a/Data/Dialog/Landing/hero_whoareyou.gtx b/Data/Dialog/Landing/hero_whoareyou.gtx new file mode 100644 index 0000000..32d90c4 Binary files /dev/null and b/Data/Dialog/Landing/hero_whoareyou.gtx differ diff --git a/Data/Dialog/Landing/intro.gtx b/Data/Dialog/Landing/intro.gtx new file mode 100644 index 0000000..0e2b2e8 Binary files /dev/null and b/Data/Dialog/Landing/intro.gtx differ diff --git a/Data/Dialog/Landing/intro2.gtx b/Data/Dialog/Landing/intro2.gtx new file mode 100644 index 0000000..b7615a9 Binary files /dev/null and b/Data/Dialog/Landing/intro2.gtx differ diff --git a/Data/Dialog/Landing/intro3.gtx b/Data/Dialog/Landing/intro3.gtx new file mode 100644 index 0000000..6eb0817 Binary files /dev/null and b/Data/Dialog/Landing/intro3.gtx differ diff --git a/Data/Dialog/Talk/l0000_hero_honey.gtx b/Data/Dialog/Talk/l0000_hero_honey.gtx new file mode 100644 index 0000000..88a76e5 Binary files /dev/null and b/Data/Dialog/Talk/l0000_hero_honey.gtx differ diff --git a/Data/Dialog/Talk/l0002_bees.gtx b/Data/Dialog/Talk/l0002_bees.gtx new file mode 100644 index 0000000..dd26983 Binary files /dev/null and b/Data/Dialog/Talk/l0002_bees.gtx differ diff --git a/Data/Dialog/Talk/l0002_croutons.gtx b/Data/Dialog/Talk/l0002_croutons.gtx new file mode 100644 index 0000000..957cb83 Binary files /dev/null and b/Data/Dialog/Talk/l0002_croutons.gtx differ diff --git a/Data/Dialog/Talk/l0002_hero_no.gtx b/Data/Dialog/Talk/l0002_hero_no.gtx new file mode 100644 index 0000000..dd7e793 Binary files /dev/null and b/Data/Dialog/Talk/l0002_hero_no.gtx differ diff --git a/Data/Dialog/Talk/l0002_hero_spray.gtx b/Data/Dialog/Talk/l0002_hero_spray.gtx new file mode 100644 index 0000000..33927df Binary files /dev/null and b/Data/Dialog/Talk/l0002_hero_spray.gtx differ diff --git a/Data/Dialog/Talk/l0002_village.gtx b/Data/Dialog/Talk/l0002_village.gtx new file mode 100644 index 0000000..58f8558 Binary files /dev/null and b/Data/Dialog/Talk/l0002_village.gtx differ diff --git a/Data/Dialog/Talk/l0003_aboutjeb.gtx b/Data/Dialog/Talk/l0003_aboutjeb.gtx new file mode 100644 index 0000000..0e3a4c1 Binary files /dev/null and b/Data/Dialog/Talk/l0003_aboutjeb.gtx differ diff --git a/Data/Dialog/Talk/l0003_hero_jeb.gtx b/Data/Dialog/Talk/l0003_hero_jeb.gtx new file mode 100644 index 0000000..2ad664b Binary files /dev/null and b/Data/Dialog/Talk/l0003_hero_jeb.gtx differ diff --git a/Data/Dialog/Talk/l0003_nevermind.gtx b/Data/Dialog/Talk/l0003_nevermind.gtx new file mode 100644 index 0000000..665ae00 Binary files /dev/null and b/Data/Dialog/Talk/l0003_nevermind.gtx differ diff --git a/Data/Dialog/Talk/l0003_shootfast.gtx b/Data/Dialog/Talk/l0003_shootfast.gtx new file mode 100644 index 0000000..9c435ed Binary files /dev/null and b/Data/Dialog/Talk/l0003_shootfast.gtx differ diff --git a/Data/Dialog/Talk/l0003_wolves.gtx b/Data/Dialog/Talk/l0003_wolves.gtx new file mode 100644 index 0000000..758eb34 Binary files /dev/null and b/Data/Dialog/Talk/l0003_wolves.gtx differ diff --git a/Data/Dialog/Talk/l0004_howdypilgrim.gtx b/Data/Dialog/Talk/l0004_howdypilgrim.gtx new file mode 100644 index 0000000..80a7125 Binary files /dev/null and b/Data/Dialog/Talk/l0004_howdypilgrim.gtx differ diff --git a/Data/Dialog/Talk/l0004_mindyourbusiness.gtx b/Data/Dialog/Talk/l0004_mindyourbusiness.gtx new file mode 100644 index 0000000..bbc154a Binary files /dev/null and b/Data/Dialog/Talk/l0004_mindyourbusiness.gtx differ diff --git a/Data/Dialog/Talk/l0004_sure.gtx b/Data/Dialog/Talk/l0004_sure.gtx new file mode 100644 index 0000000..0493a8e Binary files /dev/null and b/Data/Dialog/Talk/l0004_sure.gtx differ diff --git a/Data/Dialog/Talk/l0006_avacado.gtx b/Data/Dialog/Talk/l0006_avacado.gtx new file mode 100644 index 0000000..86b0663 Binary files /dev/null and b/Data/Dialog/Talk/l0006_avacado.gtx differ diff --git a/Data/Dialog/Talk/l0006_fixbridge.gtx b/Data/Dialog/Talk/l0006_fixbridge.gtx new file mode 100644 index 0000000..f4f4890 Binary files /dev/null and b/Data/Dialog/Talk/l0006_fixbridge.gtx differ diff --git a/Data/Dialog/Talk/l0006_fixed.gtx b/Data/Dialog/Talk/l0006_fixed.gtx new file mode 100644 index 0000000..d6ed7e5 Binary files /dev/null and b/Data/Dialog/Talk/l0006_fixed.gtx differ diff --git a/Data/Dialog/Talk/l0006_hero_sayagain.gtx b/Data/Dialog/Talk/l0006_hero_sayagain.gtx new file mode 100644 index 0000000..a91c0e9 Binary files /dev/null and b/Data/Dialog/Talk/l0006_hero_sayagain.gtx differ diff --git a/Data/Dialog/Talk/l0008_findspray.gtx b/Data/Dialog/Talk/l0008_findspray.gtx new file mode 100644 index 0000000..6eefad5 Binary files /dev/null and b/Data/Dialog/Talk/l0008_findspray.gtx differ diff --git a/Data/Dialog/Talk/l0010_crate.gtx b/Data/Dialog/Talk/l0010_crate.gtx new file mode 100644 index 0000000..7a7a048 Binary files /dev/null and b/Data/Dialog/Talk/l0010_crate.gtx differ diff --git a/Data/Dialog/Talk/l0010_foundmask.gtx b/Data/Dialog/Talk/l0010_foundmask.gtx new file mode 100644 index 0000000..57b7824 Binary files /dev/null and b/Data/Dialog/Talk/l0010_foundmask.gtx differ diff --git a/Data/Dialog/Talk/l0010_mattermitter.gtx b/Data/Dialog/Talk/l0010_mattermitter.gtx new file mode 100644 index 0000000..2d04655 Binary files /dev/null and b/Data/Dialog/Talk/l0010_mattermitter.gtx differ diff --git a/Data/Dialog/Talk/l0010_sign.gtx b/Data/Dialog/Talk/l0010_sign.gtx new file mode 100644 index 0000000..e5a5659 Binary files /dev/null and b/Data/Dialog/Talk/l0010_sign.gtx differ diff --git a/Data/Dialog/Talk/l0103_bs_figures.gtx b/Data/Dialog/Talk/l0103_bs_figures.gtx new file mode 100644 index 0000000..6d24b26 Binary files /dev/null and b/Data/Dialog/Talk/l0103_bs_figures.gtx differ diff --git a/Data/Dialog/Talk/l0103_bs_where.gtx b/Data/Dialog/Talk/l0103_bs_where.gtx new file mode 100644 index 0000000..b8309fa Binary files /dev/null and b/Data/Dialog/Talk/l0103_bs_where.gtx differ diff --git a/Data/Dialog/Talk/l0103_forest.gtx b/Data/Dialog/Talk/l0103_forest.gtx new file mode 100644 index 0000000..155e63a Binary files /dev/null and b/Data/Dialog/Talk/l0103_forest.gtx differ diff --git a/Data/Dialog/Talk/l0103_gethoney.gtx b/Data/Dialog/Talk/l0103_gethoney.gtx new file mode 100644 index 0000000..fee6b99 Binary files /dev/null and b/Data/Dialog/Talk/l0103_gethoney.gtx differ diff --git a/Data/Dialog/Talk/l0103_hero_honeyresponse.gtx b/Data/Dialog/Talk/l0103_hero_honeyresponse.gtx new file mode 100644 index 0000000..ad23e59 Binary files /dev/null and b/Data/Dialog/Talk/l0103_hero_honeyresponse.gtx differ diff --git a/Data/Dialog/Talk/l0103_honey.gtx b/Data/Dialog/Talk/l0103_honey.gtx new file mode 100644 index 0000000..91400fc Binary files /dev/null and b/Data/Dialog/Talk/l0103_honey.gtx differ diff --git a/Data/Dialog/Talk/l0103_learn.gtx b/Data/Dialog/Talk/l0103_learn.gtx new file mode 100644 index 0000000..366ed54 Binary files /dev/null and b/Data/Dialog/Talk/l0103_learn.gtx differ diff --git a/Data/Dialog/Talk/l0103_seenyoubefore.gtx b/Data/Dialog/Talk/l0103_seenyoubefore.gtx new file mode 100644 index 0000000..f9db582 Binary files /dev/null and b/Data/Dialog/Talk/l0103_seenyoubefore.gtx differ diff --git a/Data/Dialog/Talk/l0103_shootinfast.gtx b/Data/Dialog/Talk/l0103_shootinfast.gtx new file mode 100644 index 0000000..03ea23c Binary files /dev/null and b/Data/Dialog/Talk/l0103_shootinfast.gtx differ diff --git a/Data/Dialog/Talk/l0103_snakebitekit.gtx b/Data/Dialog/Talk/l0103_snakebitekit.gtx new file mode 100644 index 0000000..e771248 Binary files /dev/null and b/Data/Dialog/Talk/l0103_snakebitekit.gtx differ diff --git a/Data/Dialog/Talk/l0103_wrangling.gtx b/Data/Dialog/Talk/l0103_wrangling.gtx new file mode 100644 index 0000000..1501e5a Binary files /dev/null and b/Data/Dialog/Talk/l0103_wrangling.gtx differ diff --git a/Data/Dialog/Talk/l0105_hero_wrangling.gtx b/Data/Dialog/Talk/l0105_hero_wrangling.gtx new file mode 100644 index 0000000..436aef0 Binary files /dev/null and b/Data/Dialog/Talk/l0105_hero_wrangling.gtx differ diff --git a/Data/Dialog/Talk/l0106_headnorth.gtx b/Data/Dialog/Talk/l0106_headnorth.gtx new file mode 100644 index 0000000..3f27855 Binary files /dev/null and b/Data/Dialog/Talk/l0106_headnorth.gtx differ diff --git a/Data/Dialog/Talk/l0106_hero_seethem.gtx b/Data/Dialog/Talk/l0106_hero_seethem.gtx new file mode 100644 index 0000000..839cc1b Binary files /dev/null and b/Data/Dialog/Talk/l0106_hero_seethem.gtx differ diff --git a/Data/Dialog/Talk/l0106_heysonny.gtx b/Data/Dialog/Talk/l0106_heysonny.gtx new file mode 100644 index 0000000..9be5a29 Binary files /dev/null and b/Data/Dialog/Talk/l0106_heysonny.gtx differ diff --git a/Data/Dialog/Talk/l0106_sure.gtx b/Data/Dialog/Talk/l0106_sure.gtx new file mode 100644 index 0000000..8e5d63a Binary files /dev/null and b/Data/Dialog/Talk/l0106_sure.gtx differ diff --git a/Data/Dialog/Talk/l0108_sign.gtx b/Data/Dialog/Talk/l0108_sign.gtx new file mode 100644 index 0000000..0334657 Binary files /dev/null and b/Data/Dialog/Talk/l0108_sign.gtx differ diff --git a/Data/Dialog/Talk/l0205_forgive.gtx b/Data/Dialog/Talk/l0205_forgive.gtx new file mode 100644 index 0000000..e8aa655 Binary files /dev/null and b/Data/Dialog/Talk/l0205_forgive.gtx differ diff --git a/Data/Dialog/Talk/l0205_idiot.gtx b/Data/Dialog/Talk/l0205_idiot.gtx new file mode 100644 index 0000000..4b3c36c Binary files /dev/null and b/Data/Dialog/Talk/l0205_idiot.gtx differ diff --git a/Data/Dialog/Talk/l0205_okay.gtx b/Data/Dialog/Talk/l0205_okay.gtx new file mode 100644 index 0000000..b3922f8 Binary files /dev/null and b/Data/Dialog/Talk/l0205_okay.gtx differ diff --git a/Data/Dialog/Talk/l0205_west.gtx b/Data/Dialog/Talk/l0205_west.gtx new file mode 100644 index 0000000..b287f98 Binary files /dev/null and b/Data/Dialog/Talk/l0205_west.gtx differ diff --git a/Data/Dialog/Talk/l0205_what.gtx b/Data/Dialog/Talk/l0205_what.gtx new file mode 100644 index 0000000..9b2fbd3 Binary files /dev/null and b/Data/Dialog/Talk/l0205_what.gtx differ diff --git a/Data/Dialog/Talk/l0304_spores.gtx b/Data/Dialog/Talk/l0304_spores.gtx new file mode 100644 index 0000000..836c274 Binary files /dev/null and b/Data/Dialog/Talk/l0304_spores.gtx differ diff --git a/Data/Dialog/Talk/l0405_final_word.gtx b/Data/Dialog/Talk/l0405_final_word.gtx new file mode 100644 index 0000000..63c7f6c Binary files /dev/null and b/Data/Dialog/Talk/l0405_final_word.gtx differ diff --git a/Data/Dialog/Talk/l0405_hero_reaction.gtx b/Data/Dialog/Talk/l0405_hero_reaction.gtx new file mode 100644 index 0000000..33f0731 Binary files /dev/null and b/Data/Dialog/Talk/l0405_hero_reaction.gtx differ diff --git a/Data/Dialog/Talk/l0405_ho.gtx b/Data/Dialog/Talk/l0405_ho.gtx new file mode 100644 index 0000000..c027b14 Binary files /dev/null and b/Data/Dialog/Talk/l0405_ho.gtx differ diff --git a/Data/Dialog/Talk/l0612_clearance.gtx b/Data/Dialog/Talk/l0612_clearance.gtx new file mode 100644 index 0000000..151ea15 Binary files /dev/null and b/Data/Dialog/Talk/l0612_clearance.gtx differ diff --git a/Data/Dialog/Talk/l0612_controls.gtx b/Data/Dialog/Talk/l0612_controls.gtx new file mode 100644 index 0000000..4842527 Binary files /dev/null and b/Data/Dialog/Talk/l0612_controls.gtx differ diff --git a/Data/Dialog/Talk/l0612_duke.gtx b/Data/Dialog/Talk/l0612_duke.gtx new file mode 100644 index 0000000..05a0937 Binary files /dev/null and b/Data/Dialog/Talk/l0612_duke.gtx differ diff --git a/Data/Dialog/Talk/l0612_go.gtx b/Data/Dialog/Talk/l0612_go.gtx new file mode 100644 index 0000000..86fda17 Binary files /dev/null and b/Data/Dialog/Talk/l0612_go.gtx differ diff --git a/Data/Dialog/Talk/l0612_plan.gtx b/Data/Dialog/Talk/l0612_plan.gtx new file mode 100644 index 0000000..e4a8006 Binary files /dev/null and b/Data/Dialog/Talk/l0612_plan.gtx differ diff --git a/Data/Dialog/Talk/l0612_return.gtx b/Data/Dialog/Talk/l0612_return.gtx new file mode 100644 index 0000000..71f6fbe Binary files /dev/null and b/Data/Dialog/Talk/l0612_return.gtx differ diff --git a/Data/Dialog/Talk/l0912_ba_givepassword.gtx b/Data/Dialog/Talk/l0912_ba_givepassword.gtx new file mode 100644 index 0000000..a68183a Binary files /dev/null and b/Data/Dialog/Talk/l0912_ba_givepassword.gtx differ diff --git a/Data/Dialog/Talk/l0912_hero_brokenteleport.gtx b/Data/Dialog/Talk/l0912_hero_brokenteleport.gtx new file mode 100644 index 0000000..189c2b5 Binary files /dev/null and b/Data/Dialog/Talk/l0912_hero_brokenteleport.gtx differ diff --git a/Data/Dialog/Talk/l0912_hero_losing.gtx b/Data/Dialog/Talk/l0912_hero_losing.gtx new file mode 100644 index 0000000..829654b Binary files /dev/null and b/Data/Dialog/Talk/l0912_hero_losing.gtx differ diff --git a/Data/Dialog/Talk/l0912_hero_revolt.gtx b/Data/Dialog/Talk/l0912_hero_revolt.gtx new file mode 100644 index 0000000..a8e3680 Binary files /dev/null and b/Data/Dialog/Talk/l0912_hero_revolt.gtx differ diff --git a/Data/Dialog/Talk/l0912_hero_startteleport_nopassword.gtx b/Data/Dialog/Talk/l0912_hero_startteleport_nopassword.gtx new file mode 100644 index 0000000..721b279 Binary files /dev/null and b/Data/Dialog/Talk/l0912_hero_startteleport_nopassword.gtx differ diff --git a/Data/Dialog/Talk/l0912_hero_startteleport_password.gtx b/Data/Dialog/Talk/l0912_hero_startteleport_password.gtx new file mode 100644 index 0000000..f80e7e1 Binary files /dev/null and b/Data/Dialog/Talk/l0912_hero_startteleport_password.gtx differ diff --git a/Data/Dialog/Talk/l0912_justit.gtx b/Data/Dialog/Talk/l0912_justit.gtx new file mode 100644 index 0000000..c1a8a35 Binary files /dev/null and b/Data/Dialog/Talk/l0912_justit.gtx differ diff --git a/Data/Dialog/Talk/l0912_killpatsy.gtx b/Data/Dialog/Talk/l0912_killpatsy.gtx new file mode 100644 index 0000000..9ce8972 Binary files /dev/null and b/Data/Dialog/Talk/l0912_killpatsy.gtx differ diff --git a/Data/Dialog/Talk/l0912_needpassword.gtx b/Data/Dialog/Talk/l0912_needpassword.gtx new file mode 100644 index 0000000..006b1b3 Binary files /dev/null and b/Data/Dialog/Talk/l0912_needpassword.gtx differ diff --git a/Data/Dialog/Talk/l0912_sign.gtx b/Data/Dialog/Talk/l0912_sign.gtx new file mode 100644 index 0000000..31bcdd8 Binary files /dev/null and b/Data/Dialog/Talk/l0912_sign.gtx differ diff --git a/Data/Dialog/Talk/l0912_welcome.gtx b/Data/Dialog/Talk/l0912_welcome.gtx new file mode 100644 index 0000000..661453f Binary files /dev/null and b/Data/Dialog/Talk/l0912_welcome.gtx differ diff --git a/Data/Dialog/Talk/l1000_follow.gtx b/Data/Dialog/Talk/l1000_follow.gtx new file mode 100644 index 0000000..f2e4439 Binary files /dev/null and b/Data/Dialog/Talk/l1000_follow.gtx differ diff --git a/Data/Dialog/Talk/l1000_freeze.gtx b/Data/Dialog/Talk/l1000_freeze.gtx new file mode 100644 index 0000000..4b7daec Binary files /dev/null and b/Data/Dialog/Talk/l1000_freeze.gtx differ diff --git a/Data/Dialog/Talk/l1000_needbomb.gtx b/Data/Dialog/Talk/l1000_needbomb.gtx new file mode 100644 index 0000000..df0a8c7 Binary files /dev/null and b/Data/Dialog/Talk/l1000_needbomb.gtx differ diff --git a/Data/Dialog/Talk/l1000_toolate.gtx b/Data/Dialog/Talk/l1000_toolate.gtx new file mode 100644 index 0000000..c19e45b Binary files /dev/null and b/Data/Dialog/Talk/l1000_toolate.gtx differ diff --git a/Data/Dialog/Talk/l1010_amking.gtx b/Data/Dialog/Talk/l1010_amking.gtx new file mode 100644 index 0000000..4d178a4 Binary files /dev/null and b/Data/Dialog/Talk/l1010_amking.gtx differ diff --git a/Data/Dialog/Talk/l1010_cannotleave.gtx b/Data/Dialog/Talk/l1010_cannotleave.gtx new file mode 100644 index 0000000..8bf48c9 Binary files /dev/null and b/Data/Dialog/Talk/l1010_cannotleave.gtx differ diff --git a/Data/Dialog/Talk/l1010_readytogo.gtx b/Data/Dialog/Talk/l1010_readytogo.gtx new file mode 100644 index 0000000..0944e17 Binary files /dev/null and b/Data/Dialog/Talk/l1010_readytogo.gtx differ diff --git a/Data/Dialog/Talk/l1012_hero_readbook.gtx b/Data/Dialog/Talk/l1012_hero_readbook.gtx new file mode 100644 index 0000000..caf3963 Binary files /dev/null and b/Data/Dialog/Talk/l1012_hero_readbook.gtx differ diff --git a/Data/Dialog/Talk/l1212_anytime.gtx b/Data/Dialog/Talk/l1212_anytime.gtx new file mode 100644 index 0000000..da5db1e Binary files /dev/null and b/Data/Dialog/Talk/l1212_anytime.gtx differ diff --git a/Data/Dialog/Talk/l1212_makesure.gtx b/Data/Dialog/Talk/l1212_makesure.gtx new file mode 100644 index 0000000..1269c39 Binary files /dev/null and b/Data/Dialog/Talk/l1212_makesure.gtx differ diff --git a/Data/Dialog/Talk/l1212_suckstobehim.gtx b/Data/Dialog/Talk/l1212_suckstobehim.gtx new file mode 100644 index 0000000..d535036 Binary files /dev/null and b/Data/Dialog/Talk/l1212_suckstobehim.gtx differ diff --git a/Data/Dialog/Talk/l1212_yeah.gtx b/Data/Dialog/Talk/l1212_yeah.gtx new file mode 100644 index 0000000..282bb7e Binary files /dev/null and b/Data/Dialog/Talk/l1212_yeah.gtx differ diff --git a/Data/Dialog/Wedding/bs_driving.gtx b/Data/Dialog/Wedding/bs_driving.gtx new file mode 100644 index 0000000..1ee083a Binary files /dev/null and b/Data/Dialog/Wedding/bs_driving.gtx differ diff --git a/Data/Dialog/Wedding/bs_explain.gtx b/Data/Dialog/Wedding/bs_explain.gtx new file mode 100644 index 0000000..626f23f Binary files /dev/null and b/Data/Dialog/Wedding/bs_explain.gtx differ diff --git a/Data/Dialog/Wedding/bs_explain2.gtx b/Data/Dialog/Wedding/bs_explain2.gtx new file mode 100644 index 0000000..543bad8 Binary files /dev/null and b/Data/Dialog/Wedding/bs_explain2.gtx differ diff --git a/Data/Dialog/Wedding/bs_palace.gtx b/Data/Dialog/Wedding/bs_palace.gtx new file mode 100644 index 0000000..a2aaa0c Binary files /dev/null and b/Data/Dialog/Wedding/bs_palace.gtx differ diff --git a/Data/Dialog/Wedding/captain_cake.gtx b/Data/Dialog/Wedding/captain_cake.gtx new file mode 100644 index 0000000..04d75b0 Binary files /dev/null and b/Data/Dialog/Wedding/captain_cake.gtx differ diff --git a/Data/Dialog/Wedding/captain_camp.gtx b/Data/Dialog/Wedding/captain_camp.gtx new file mode 100644 index 0000000..96a5766 Binary files /dev/null and b/Data/Dialog/Wedding/captain_camp.gtx differ diff --git a/Data/Dialog/Wedding/captain_dosomething.gtx b/Data/Dialog/Wedding/captain_dosomething.gtx new file mode 100644 index 0000000..0737cd3 Binary files /dev/null and b/Data/Dialog/Wedding/captain_dosomething.gtx differ diff --git a/Data/Dialog/Wedding/captain_interrupt.gtx b/Data/Dialog/Wedding/captain_interrupt.gtx new file mode 100644 index 0000000..77450d6 Binary files /dev/null and b/Data/Dialog/Wedding/captain_interrupt.gtx differ diff --git a/Data/Dialog/Wedding/captain_key.gtx b/Data/Dialog/Wedding/captain_key.gtx new file mode 100644 index 0000000..6a3cec5 Binary files /dev/null and b/Data/Dialog/Wedding/captain_key.gtx differ diff --git a/Data/Dialog/Wedding/captain_okay.gtx b/Data/Dialog/Wedding/captain_okay.gtx new file mode 100644 index 0000000..8dbc33b Binary files /dev/null and b/Data/Dialog/Wedding/captain_okay.gtx differ diff --git a/Data/Dialog/Wedding/captain_tellyouwhat.gtx b/Data/Dialog/Wedding/captain_tellyouwhat.gtx new file mode 100644 index 0000000..c11ff7c Binary files /dev/null and b/Data/Dialog/Wedding/captain_tellyouwhat.gtx differ diff --git a/Data/Dialog/Wedding/captain_thanks.gtx b/Data/Dialog/Wedding/captain_thanks.gtx new file mode 100644 index 0000000..7042991 Binary files /dev/null and b/Data/Dialog/Wedding/captain_thanks.gtx differ diff --git a/Data/Dialog/Wedding/captain_thankyou.gtx b/Data/Dialog/Wedding/captain_thankyou.gtx new file mode 100644 index 0000000..712179e Binary files /dev/null and b/Data/Dialog/Wedding/captain_thankyou.gtx differ diff --git a/Data/Dialog/Wedding/captain_why.gtx b/Data/Dialog/Wedding/captain_why.gtx new file mode 100644 index 0000000..2096f8a Binary files /dev/null and b/Data/Dialog/Wedding/captain_why.gtx differ diff --git a/Data/Dialog/Wedding/flour_heyguys.gtx b/Data/Dialog/Wedding/flour_heyguys.gtx new file mode 100644 index 0000000..2405574 Binary files /dev/null and b/Data/Dialog/Wedding/flour_heyguys.gtx differ diff --git a/Data/Dialog/Wedding/gyro_ba.gtx b/Data/Dialog/Wedding/gyro_ba.gtx new file mode 100644 index 0000000..e04f0ff Binary files /dev/null and b/Data/Dialog/Wedding/gyro_ba.gtx differ diff --git a/Data/Dialog/Wedding/gyro_bs.gtx b/Data/Dialog/Wedding/gyro_bs.gtx new file mode 100644 index 0000000..f639552 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_bs.gtx differ diff --git a/Data/Dialog/Wedding/gyro_difficult.gtx b/Data/Dialog/Wedding/gyro_difficult.gtx new file mode 100644 index 0000000..15a8ac7 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_difficult.gtx differ diff --git a/Data/Dialog/Wedding/gyro_haiku.gtx b/Data/Dialog/Wedding/gyro_haiku.gtx new file mode 100644 index 0000000..1d71392 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_haiku.gtx differ diff --git a/Data/Dialog/Wedding/gyro_notsofast.gtx b/Data/Dialog/Wedding/gyro_notsofast.gtx new file mode 100644 index 0000000..9b864b6 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_notsofast.gtx differ diff --git a/Data/Dialog/Wedding/gyro_notyummy.gtx b/Data/Dialog/Wedding/gyro_notyummy.gtx new file mode 100644 index 0000000..31e6990 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_notyummy.gtx differ diff --git a/Data/Dialog/Wedding/gyro_recall.gtx b/Data/Dialog/Wedding/gyro_recall.gtx new file mode 100644 index 0000000..ae69cef Binary files /dev/null and b/Data/Dialog/Wedding/gyro_recall.gtx differ diff --git a/Data/Dialog/Wedding/gyro_reveals.gtx b/Data/Dialog/Wedding/gyro_reveals.gtx new file mode 100644 index 0000000..573ad54 Binary files /dev/null and b/Data/Dialog/Wedding/gyro_reveals.gtx differ diff --git a/Data/Dialog/Wedding/gyro_surrender.gtx b/Data/Dialog/Wedding/gyro_surrender.gtx new file mode 100644 index 0000000..5a73e0f Binary files /dev/null and b/Data/Dialog/Wedding/gyro_surrender.gtx differ diff --git a/Data/Dialog/Wedding/hero_reasons.gtx b/Data/Dialog/Wedding/hero_reasons.gtx new file mode 100644 index 0000000..68202e6 Binary files /dev/null and b/Data/Dialog/Wedding/hero_reasons.gtx differ diff --git a/Data/Dialog/Wedding/lady_byallmeans.gtx b/Data/Dialog/Wedding/lady_byallmeans.gtx new file mode 100644 index 0000000..e11b7cf Binary files /dev/null and b/Data/Dialog/Wedding/lady_byallmeans.gtx differ diff --git a/Data/Dialog/Wedding/lady_dontbesilly.gtx b/Data/Dialog/Wedding/lady_dontbesilly.gtx new file mode 100644 index 0000000..d5ec1fa Binary files /dev/null and b/Data/Dialog/Wedding/lady_dontbesilly.gtx differ diff --git a/Data/Dialog/Wedding/lady_radio.gtx b/Data/Dialog/Wedding/lady_radio.gtx new file mode 100644 index 0000000..46bc338 Binary files /dev/null and b/Data/Dialog/Wedding/lady_radio.gtx differ diff --git a/Data/Dialog/Wedding/preacher_blah.gtx b/Data/Dialog/Wedding/preacher_blah.gtx new file mode 100644 index 0000000..bad1eef Binary files /dev/null and b/Data/Dialog/Wedding/preacher_blah.gtx differ diff --git a/Data/Dialog/Wedding/preacher_married.gtx b/Data/Dialog/Wedding/preacher_married.gtx new file mode 100644 index 0000000..f33458a Binary files /dev/null and b/Data/Dialog/Wedding/preacher_married.gtx differ diff --git a/Data/Dialog/Wedding/preacher_pronounce.gtx b/Data/Dialog/Wedding/preacher_pronounce.gtx new file mode 100644 index 0000000..a113824 Binary files /dev/null and b/Data/Dialog/Wedding/preacher_pronounce.gtx differ diff --git a/Data/Dialog/Wedding/preacher_reasons.gtx b/Data/Dialog/Wedding/preacher_reasons.gtx new file mode 100644 index 0000000..d298303 Binary files /dev/null and b/Data/Dialog/Wedding/preacher_reasons.gtx differ diff --git a/Data/Dialog/Wedding/preacher_takebegonia.gtx b/Data/Dialog/Wedding/preacher_takebegonia.gtx new file mode 100644 index 0000000..4dbe4d1 Binary files /dev/null and b/Data/Dialog/Wedding/preacher_takebegonia.gtx differ diff --git a/Data/Dialog/Wedding/preacher_takesack.gtx b/Data/Dialog/Wedding/preacher_takesack.gtx new file mode 100644 index 0000000..6902e88 Binary files /dev/null and b/Data/Dialog/Wedding/preacher_takesack.gtx differ diff --git a/Data/Dialog/pause.gtx b/Data/Dialog/pause.gtx new file mode 100644 index 0000000..655698b Binary files /dev/null and b/Data/Dialog/pause.gtx differ diff --git a/Data/Levels/L0000_hive.lvl b/Data/Levels/L0000_hive.lvl new file mode 100644 index 0000000..bcf8d81 Binary files /dev/null and b/Data/Levels/L0000_hive.lvl differ diff --git a/Data/Levels/L0001_bees.lvl b/Data/Levels/L0001_bees.lvl new file mode 100644 index 0000000..e4a57fa Binary files /dev/null and b/Data/Levels/L0001_bees.lvl differ diff --git a/Data/Levels/L0002_bees.lvl b/Data/Levels/L0002_bees.lvl new file mode 100644 index 0000000..29dd522 Binary files /dev/null and b/Data/Levels/L0002_bees.lvl differ diff --git a/Data/Levels/L0003_green.lvl b/Data/Levels/L0003_green.lvl new file mode 100644 index 0000000..a0a9f3a Binary files /dev/null and b/Data/Levels/L0003_green.lvl differ diff --git a/Data/Levels/L0004_ranch.lvl b/Data/Levels/L0004_ranch.lvl new file mode 100644 index 0000000..bcd076c Binary files /dev/null and b/Data/Levels/L0004_ranch.lvl differ diff --git a/Data/Levels/L0005_path.lvl b/Data/Levels/L0005_path.lvl new file mode 100644 index 0000000..3942961 Binary files /dev/null and b/Data/Levels/L0005_path.lvl differ diff --git a/Data/Levels/L0006_sunset.lvl b/Data/Levels/L0006_sunset.lvl new file mode 100644 index 0000000..658e74b Binary files /dev/null and b/Data/Levels/L0006_sunset.lvl differ diff --git a/Data/Levels/L0007_forest.lvl b/Data/Levels/L0007_forest.lvl new file mode 100644 index 0000000..e3d43db Binary files /dev/null and b/Data/Levels/L0007_forest.lvl differ diff --git a/Data/Levels/L0008_forest.lvl b/Data/Levels/L0008_forest.lvl new file mode 100644 index 0000000..fd032fe Binary files /dev/null and b/Data/Levels/L0008_forest.lvl differ diff --git a/Data/Levels/L0009_mouse.lvl b/Data/Levels/L0009_mouse.lvl new file mode 100644 index 0000000..86be7f3 Binary files /dev/null and b/Data/Levels/L0009_mouse.lvl differ diff --git a/Data/Levels/L0010_serpent.lvl b/Data/Levels/L0010_serpent.lvl new file mode 100644 index 0000000..cf53faf Binary files /dev/null and b/Data/Levels/L0010_serpent.lvl differ diff --git a/Data/Levels/L0011_seasons.lvl b/Data/Levels/L0011_seasons.lvl new file mode 100644 index 0000000..9b8918a Binary files /dev/null and b/Data/Levels/L0011_seasons.lvl differ diff --git a/Data/Levels/L0012_ssa_cmdcore.lvl b/Data/Levels/L0012_ssa_cmdcore.lvl new file mode 100644 index 0000000..9c8ef3a Binary files /dev/null and b/Data/Levels/L0012_ssa_cmdcore.lvl differ diff --git a/Data/Levels/L0013_intro_ba1.lvl b/Data/Levels/L0013_intro_ba1.lvl new file mode 100644 index 0000000..8d6e7f2 Binary files /dev/null and b/Data/Levels/L0013_intro_ba1.lvl differ diff --git a/Data/Levels/L0014_intro_haiku1.lvl b/Data/Levels/L0014_intro_haiku1.lvl new file mode 100644 index 0000000..d9803d3 Binary files /dev/null and b/Data/Levels/L0014_intro_haiku1.lvl differ diff --git a/Data/Levels/L0015_intro_bs1.lvl b/Data/Levels/L0015_intro_bs1.lvl new file mode 100644 index 0000000..1c1cc22 Binary files /dev/null and b/Data/Levels/L0015_intro_bs1.lvl differ diff --git a/Data/Levels/L0100_river.lvl b/Data/Levels/L0100_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0100_river.lvl differ diff --git a/Data/Levels/L0101_river.lvl b/Data/Levels/L0101_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0101_river.lvl differ diff --git a/Data/Levels/L0102_river.lvl b/Data/Levels/L0102_river.lvl new file mode 100644 index 0000000..a9c0050 Binary files /dev/null and b/Data/Levels/L0102_river.lvl differ diff --git a/Data/Levels/L0103_green.lvl b/Data/Levels/L0103_green.lvl new file mode 100644 index 0000000..ae158e5 Binary files /dev/null and b/Data/Levels/L0103_green.lvl differ diff --git a/Data/Levels/L0104_spring.lvl b/Data/Levels/L0104_spring.lvl new file mode 100644 index 0000000..68cd96b Binary files /dev/null and b/Data/Levels/L0104_spring.lvl differ diff --git a/Data/Levels/L0105_path.lvl b/Data/Levels/L0105_path.lvl new file mode 100644 index 0000000..19343a7 Binary files /dev/null and b/Data/Levels/L0105_path.lvl differ diff --git a/Data/Levels/L0106_path.lvl b/Data/Levels/L0106_path.lvl new file mode 100644 index 0000000..f1587c3 Binary files /dev/null and b/Data/Levels/L0106_path.lvl differ diff --git a/Data/Levels/L0107_landing.lvl b/Data/Levels/L0107_landing.lvl new file mode 100644 index 0000000..2ad90d4 Binary files /dev/null and b/Data/Levels/L0107_landing.lvl differ diff --git a/Data/Levels/L0108_forest_landing.lvl b/Data/Levels/L0108_forest_landing.lvl new file mode 100644 index 0000000..105becd Binary files /dev/null and b/Data/Levels/L0108_forest_landing.lvl differ diff --git a/Data/Levels/L0109_mouse.lvl b/Data/Levels/L0109_mouse.lvl new file mode 100644 index 0000000..a571749 Binary files /dev/null and b/Data/Levels/L0109_mouse.lvl differ diff --git a/Data/Levels/L0110_mouse.lvl b/Data/Levels/L0110_mouse.lvl new file mode 100644 index 0000000..67cc772 Binary files /dev/null and b/Data/Levels/L0110_mouse.lvl differ diff --git a/Data/Levels/L0111_tower.lvl b/Data/Levels/L0111_tower.lvl new file mode 100644 index 0000000..25646eb Binary files /dev/null and b/Data/Levels/L0111_tower.lvl differ diff --git a/Data/Levels/L0112_hive_entrance.lvl b/Data/Levels/L0112_hive_entrance.lvl new file mode 100644 index 0000000..fe17097 Binary files /dev/null and b/Data/Levels/L0112_hive_entrance.lvl differ diff --git a/Data/Levels/L0113_intro_ba2.lvl b/Data/Levels/L0113_intro_ba2.lvl new file mode 100644 index 0000000..80935f4 Binary files /dev/null and b/Data/Levels/L0113_intro_ba2.lvl differ diff --git a/Data/Levels/L0114_intro_haiku2.lvl b/Data/Levels/L0114_intro_haiku2.lvl new file mode 100644 index 0000000..983d107 Binary files /dev/null and b/Data/Levels/L0114_intro_haiku2.lvl differ diff --git a/Data/Levels/L0115_intro_bs2.lvl b/Data/Levels/L0115_intro_bs2.lvl new file mode 100644 index 0000000..dd28e54 Binary files /dev/null and b/Data/Levels/L0115_intro_bs2.lvl differ diff --git a/Data/Levels/L0200_evilvill.lvl b/Data/Levels/L0200_evilvill.lvl new file mode 100644 index 0000000..881e8c0 Binary files /dev/null and b/Data/Levels/L0200_evilvill.lvl differ diff --git a/Data/Levels/L0201_mist.lvl b/Data/Levels/L0201_mist.lvl new file mode 100644 index 0000000..ec972d3 Binary files /dev/null and b/Data/Levels/L0201_mist.lvl differ diff --git a/Data/Levels/L0202_river.lvl b/Data/Levels/L0202_river.lvl new file mode 100644 index 0000000..03a40fe Binary files /dev/null and b/Data/Levels/L0202_river.lvl differ diff --git a/Data/Levels/L0203_path.lvl b/Data/Levels/L0203_path.lvl new file mode 100644 index 0000000..2616314 Binary files /dev/null and b/Data/Levels/L0203_path.lvl differ diff --git a/Data/Levels/L0203_river.lvl b/Data/Levels/L0203_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0203_river.lvl differ diff --git a/Data/Levels/L0204_path.lvl b/Data/Levels/L0204_path.lvl new file mode 100644 index 0000000..55cd860 Binary files /dev/null and b/Data/Levels/L0204_path.lvl differ diff --git a/Data/Levels/L0204_river.lvl b/Data/Levels/L0204_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0204_river.lvl differ diff --git a/Data/Levels/L0205_bridge.lvl b/Data/Levels/L0205_bridge.lvl new file mode 100644 index 0000000..4800076 Binary files /dev/null and b/Data/Levels/L0205_bridge.lvl differ diff --git a/Data/Levels/L0206_river.lvl b/Data/Levels/L0206_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0206_river.lvl differ diff --git a/Data/Levels/L0207_river.lvl b/Data/Levels/L0207_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0207_river.lvl differ diff --git a/Data/Levels/L0208_river.lvl b/Data/Levels/L0208_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0208_river.lvl differ diff --git a/Data/Levels/L0209_river.lvl b/Data/Levels/L0209_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0209_river.lvl differ diff --git a/Data/Levels/L0210_river.lvl b/Data/Levels/L0210_river.lvl new file mode 100644 index 0000000..57703cc Binary files /dev/null and b/Data/Levels/L0210_river.lvl differ diff --git a/Data/Levels/L0211_tower.lvl b/Data/Levels/L0211_tower.lvl new file mode 100644 index 0000000..67860da Binary files /dev/null and b/Data/Levels/L0211_tower.lvl differ diff --git a/Data/Levels/L0212_sunsethouseup.lvl b/Data/Levels/L0212_sunsethouseup.lvl new file mode 100644 index 0000000..f1075a6 Binary files /dev/null and b/Data/Levels/L0212_sunsethouseup.lvl differ diff --git a/Data/Levels/L0213_intro_ba3.lvl b/Data/Levels/L0213_intro_ba3.lvl new file mode 100644 index 0000000..4266f54 Binary files /dev/null and b/Data/Levels/L0213_intro_ba3.lvl differ diff --git a/Data/Levels/L0214_intro_haiku3.lvl b/Data/Levels/L0214_intro_haiku3.lvl new file mode 100644 index 0000000..91f0dfe Binary files /dev/null and b/Data/Levels/L0214_intro_haiku3.lvl differ diff --git a/Data/Levels/L0215_intro_bs3.lvl b/Data/Levels/L0215_intro_bs3.lvl new file mode 100644 index 0000000..b8fa880 Binary files /dev/null and b/Data/Levels/L0215_intro_bs3.lvl differ diff --git a/Data/Levels/L0300_mist.lvl b/Data/Levels/L0300_mist.lvl new file mode 100644 index 0000000..338cc70 Binary files /dev/null and b/Data/Levels/L0300_mist.lvl differ diff --git a/Data/Levels/L0301_mist.lvl b/Data/Levels/L0301_mist.lvl new file mode 100644 index 0000000..be7cdb8 Binary files /dev/null and b/Data/Levels/L0301_mist.lvl differ diff --git a/Data/Levels/L0302_mistland.lvl b/Data/Levels/L0302_mistland.lvl new file mode 100644 index 0000000..da8dfbe Binary files /dev/null and b/Data/Levels/L0302_mistland.lvl differ diff --git a/Data/Levels/L0303_bridge.lvl b/Data/Levels/L0303_bridge.lvl new file mode 100644 index 0000000..bfb59f4 Binary files /dev/null and b/Data/Levels/L0303_bridge.lvl differ diff --git a/Data/Levels/L0303_stone_mist.lvl b/Data/Levels/L0303_stone_mist.lvl new file mode 100644 index 0000000..97dd63b Binary files /dev/null and b/Data/Levels/L0303_stone_mist.lvl differ diff --git a/Data/Levels/L0304_shroom.lvl b/Data/Levels/L0304_shroom.lvl new file mode 100644 index 0000000..497f2bb Binary files /dev/null and b/Data/Levels/L0304_shroom.lvl differ diff --git a/Data/Levels/L0305_path.lvl b/Data/Levels/L0305_path.lvl new file mode 100644 index 0000000..e35dce0 Binary files /dev/null and b/Data/Levels/L0305_path.lvl differ diff --git a/Data/Levels/L0306_twoguns.lvl b/Data/Levels/L0306_twoguns.lvl new file mode 100644 index 0000000..11d5b51 Binary files /dev/null and b/Data/Levels/L0306_twoguns.lvl differ diff --git a/Data/Levels/L0307_outpost.lvl b/Data/Levels/L0307_outpost.lvl new file mode 100644 index 0000000..0638834 Binary files /dev/null and b/Data/Levels/L0307_outpost.lvl differ diff --git a/Data/Levels/L0308_drylake.lvl b/Data/Levels/L0308_drylake.lvl new file mode 100644 index 0000000..0037ef8 Binary files /dev/null and b/Data/Levels/L0308_drylake.lvl differ diff --git a/Data/Levels/L0309_desert.lvl b/Data/Levels/L0309_desert.lvl new file mode 100644 index 0000000..667251b Binary files /dev/null and b/Data/Levels/L0309_desert.lvl differ diff --git a/Data/Levels/L0310_desertland.lvl b/Data/Levels/L0310_desertland.lvl new file mode 100644 index 0000000..23d4dac Binary files /dev/null and b/Data/Levels/L0310_desertland.lvl differ diff --git a/Data/Levels/L0311_tower.lvl b/Data/Levels/L0311_tower.lvl new file mode 100644 index 0000000..838ed03 Binary files /dev/null and b/Data/Levels/L0311_tower.lvl differ diff --git a/Data/Levels/L0312_sunsethousedown.lvl b/Data/Levels/L0312_sunsethousedown.lvl new file mode 100644 index 0000000..34557f9 Binary files /dev/null and b/Data/Levels/L0312_sunsethousedown.lvl differ diff --git a/Data/Levels/L0313_intro_ba4.lvl b/Data/Levels/L0313_intro_ba4.lvl new file mode 100644 index 0000000..bbf9fee Binary files /dev/null and b/Data/Levels/L0313_intro_ba4.lvl differ diff --git a/Data/Levels/L0314_intro_haiku4.lvl b/Data/Levels/L0314_intro_haiku4.lvl new file mode 100644 index 0000000..37c992d Binary files /dev/null and b/Data/Levels/L0314_intro_haiku4.lvl differ diff --git a/Data/Levels/L0315_intro_bs4.lvl b/Data/Levels/L0315_intro_bs4.lvl new file mode 100644 index 0000000..8dd027b Binary files /dev/null and b/Data/Levels/L0315_intro_bs4.lvl differ diff --git a/Data/Levels/L0400_ice_out.lvl b/Data/Levels/L0400_ice_out.lvl new file mode 100644 index 0000000..5c40c3f Binary files /dev/null and b/Data/Levels/L0400_ice_out.lvl differ diff --git a/Data/Levels/L0401_pitch_black.lvl b/Data/Levels/L0401_pitch_black.lvl new file mode 100644 index 0000000..2f53faf Binary files /dev/null and b/Data/Levels/L0401_pitch_black.lvl differ diff --git a/Data/Levels/L0402_dusk.lvl b/Data/Levels/L0402_dusk.lvl new file mode 100644 index 0000000..2e566be Binary files /dev/null and b/Data/Levels/L0402_dusk.lvl differ diff --git a/Data/Levels/L0403_shroom.lvl b/Data/Levels/L0403_shroom.lvl new file mode 100644 index 0000000..26d8f27 Binary files /dev/null and b/Data/Levels/L0403_shroom.lvl differ diff --git a/Data/Levels/L0404_shroom.lvl b/Data/Levels/L0404_shroom.lvl new file mode 100644 index 0000000..d98d7d6 Binary files /dev/null and b/Data/Levels/L0404_shroom.lvl differ diff --git a/Data/Levels/L0405_garden.lvl b/Data/Levels/L0405_garden.lvl new file mode 100644 index 0000000..cc707f2 Binary files /dev/null and b/Data/Levels/L0405_garden.lvl differ diff --git a/Data/Levels/L0406_bios.lvl b/Data/Levels/L0406_bios.lvl new file mode 100644 index 0000000..b13bfa3 Binary files /dev/null and b/Data/Levels/L0406_bios.lvl differ diff --git a/Data/Levels/L0407_bios.lvl b/Data/Levels/L0407_bios.lvl new file mode 100644 index 0000000..1407381 Binary files /dev/null and b/Data/Levels/L0407_bios.lvl differ diff --git a/Data/Levels/L0408_deathvalley.lvl b/Data/Levels/L0408_deathvalley.lvl new file mode 100644 index 0000000..2f0b6e2 Binary files /dev/null and b/Data/Levels/L0408_deathvalley.lvl differ diff --git a/Data/Levels/L0409_desert.lvl b/Data/Levels/L0409_desert.lvl new file mode 100644 index 0000000..a926f43 Binary files /dev/null and b/Data/Levels/L0409_desert.lvl differ diff --git a/Data/Levels/L0410_outpost.lvl b/Data/Levels/L0410_outpost.lvl new file mode 100644 index 0000000..0aa77ee Binary files /dev/null and b/Data/Levels/L0410_outpost.lvl differ diff --git a/Data/Levels/L0411_tower.lvl b/Data/Levels/L0411_tower.lvl new file mode 100644 index 0000000..82d85c7 Binary files /dev/null and b/Data/Levels/L0411_tower.lvl differ diff --git a/Data/Levels/L0412_sunsethousewest.lvl b/Data/Levels/L0412_sunsethousewest.lvl new file mode 100644 index 0000000..7dfca7a Binary files /dev/null and b/Data/Levels/L0412_sunsethousewest.lvl differ diff --git a/Data/Levels/L0500_ice.lvl b/Data/Levels/L0500_ice.lvl new file mode 100644 index 0000000..35f2d80 Binary files /dev/null and b/Data/Levels/L0500_ice.lvl differ diff --git a/Data/Levels/L0501_winter.lvl b/Data/Levels/L0501_winter.lvl new file mode 100644 index 0000000..6440bdd Binary files /dev/null and b/Data/Levels/L0501_winter.lvl differ diff --git a/Data/Levels/L0502_chill.lvl b/Data/Levels/L0502_chill.lvl new file mode 100644 index 0000000..d7bef85 Binary files /dev/null and b/Data/Levels/L0502_chill.lvl differ diff --git a/Data/Levels/L0503_hermit.lvl b/Data/Levels/L0503_hermit.lvl new file mode 100644 index 0000000..f5c8016 Binary files /dev/null and b/Data/Levels/L0503_hermit.lvl differ diff --git a/Data/Levels/L0504_garden.lvl b/Data/Levels/L0504_garden.lvl new file mode 100644 index 0000000..9fb568a Binary files /dev/null and b/Data/Levels/L0504_garden.lvl differ diff --git a/Data/Levels/L0505_palace.lvl b/Data/Levels/L0505_palace.lvl new file mode 100644 index 0000000..960ba2e Binary files /dev/null and b/Data/Levels/L0505_palace.lvl differ diff --git a/Data/Levels/L0506_garden.lvl b/Data/Levels/L0506_garden.lvl new file mode 100644 index 0000000..fb89b59 Binary files /dev/null and b/Data/Levels/L0506_garden.lvl differ diff --git a/Data/Levels/L0507_swamp.lvl b/Data/Levels/L0507_swamp.lvl new file mode 100644 index 0000000..842d684 Binary files /dev/null and b/Data/Levels/L0507_swamp.lvl differ diff --git a/Data/Levels/L0508_witch.lvl b/Data/Levels/L0508_witch.lvl new file mode 100644 index 0000000..2dc0096 Binary files /dev/null and b/Data/Levels/L0508_witch.lvl differ diff --git a/Data/Levels/L0509_bigdesert.lvl b/Data/Levels/L0509_bigdesert.lvl new file mode 100644 index 0000000..4d8a8e3 Binary files /dev/null and b/Data/Levels/L0509_bigdesert.lvl differ diff --git a/Data/Levels/L0510_summer.lvl b/Data/Levels/L0510_summer.lvl new file mode 100644 index 0000000..71abca4 Binary files /dev/null and b/Data/Levels/L0510_summer.lvl differ diff --git a/Data/Levels/L0512_witch_house.lvl b/Data/Levels/L0512_witch_house.lvl new file mode 100644 index 0000000..c36cc5e Binary files /dev/null and b/Data/Levels/L0512_witch_house.lvl differ diff --git a/Data/Levels/L0600_ice.lvl b/Data/Levels/L0600_ice.lvl new file mode 100644 index 0000000..2849f23 Binary files /dev/null and b/Data/Levels/L0600_ice.lvl differ diff --git a/Data/Levels/L0601_wolf.lvl b/Data/Levels/L0601_wolf.lvl new file mode 100644 index 0000000..56c4249 Binary files /dev/null and b/Data/Levels/L0601_wolf.lvl differ diff --git a/Data/Levels/L0602_hillpeople.lvl b/Data/Levels/L0602_hillpeople.lvl new file mode 100644 index 0000000..41ec0b8 Binary files /dev/null and b/Data/Levels/L0602_hillpeople.lvl differ diff --git a/Data/Levels/L0603_hillpeople.lvl b/Data/Levels/L0603_hillpeople.lvl new file mode 100644 index 0000000..1e28e28 Binary files /dev/null and b/Data/Levels/L0603_hillpeople.lvl differ diff --git a/Data/Levels/L0604_tower.lvl b/Data/Levels/L0604_tower.lvl new file mode 100644 index 0000000..589602c Binary files /dev/null and b/Data/Levels/L0604_tower.lvl differ diff --git a/Data/Levels/L0605_garden.lvl b/Data/Levels/L0605_garden.lvl new file mode 100644 index 0000000..df5489a Binary files /dev/null and b/Data/Levels/L0605_garden.lvl differ diff --git a/Data/Levels/L0606_mooreslanding.lvl b/Data/Levels/L0606_mooreslanding.lvl new file mode 100644 index 0000000..c7f62c4 Binary files /dev/null and b/Data/Levels/L0606_mooreslanding.lvl differ diff --git a/Data/Levels/L0607_swampthang.lvl b/Data/Levels/L0607_swampthang.lvl new file mode 100644 index 0000000..78ad140 Binary files /dev/null and b/Data/Levels/L0607_swampthang.lvl differ diff --git a/Data/Levels/L0608_moores.lvl b/Data/Levels/L0608_moores.lvl new file mode 100644 index 0000000..ca62429 Binary files /dev/null and b/Data/Levels/L0608_moores.lvl differ diff --git a/Data/Levels/L0609_outback.lvl b/Data/Levels/L0609_outback.lvl new file mode 100644 index 0000000..add7e59 Binary files /dev/null and b/Data/Levels/L0609_outback.lvl differ diff --git a/Data/Levels/L0610_outback.lvl b/Data/Levels/L0610_outback.lvl new file mode 100644 index 0000000..2fcb6df Binary files /dev/null and b/Data/Levels/L0610_outback.lvl differ diff --git a/Data/Levels/L0612_teleport.lvl b/Data/Levels/L0612_teleport.lvl new file mode 100644 index 0000000..bf8a9c7 Binary files /dev/null and b/Data/Levels/L0612_teleport.lvl differ diff --git a/Data/Levels/L0700_ice.lvl b/Data/Levels/L0700_ice.lvl new file mode 100644 index 0000000..9494fe6 Binary files /dev/null and b/Data/Levels/L0700_ice.lvl differ diff --git a/Data/Levels/L0701_kiwikeep.lvl b/Data/Levels/L0701_kiwikeep.lvl new file mode 100644 index 0000000..9390008 Binary files /dev/null and b/Data/Levels/L0701_kiwikeep.lvl differ diff --git a/Data/Levels/L0702_caverns.lvl b/Data/Levels/L0702_caverns.lvl new file mode 100644 index 0000000..6ea5980 Binary files /dev/null and b/Data/Levels/L0702_caverns.lvl differ diff --git a/Data/Levels/L0703_caverns.lvl b/Data/Levels/L0703_caverns.lvl new file mode 100644 index 0000000..3042a4e Binary files /dev/null and b/Data/Levels/L0703_caverns.lvl differ diff --git a/Data/Levels/L0704_canyon.lvl b/Data/Levels/L0704_canyon.lvl new file mode 100644 index 0000000..87276ca Binary files /dev/null and b/Data/Levels/L0704_canyon.lvl differ diff --git a/Data/Levels/L0705_jungle.lvl b/Data/Levels/L0705_jungle.lvl new file mode 100644 index 0000000..a819e9f Binary files /dev/null and b/Data/Levels/L0705_jungle.lvl differ diff --git a/Data/Levels/L0706_swamp.lvl b/Data/Levels/L0706_swamp.lvl new file mode 100644 index 0000000..5d1a2f3 Binary files /dev/null and b/Data/Levels/L0706_swamp.lvl differ diff --git a/Data/Levels/L0707_barrows.lvl b/Data/Levels/L0707_barrows.lvl new file mode 100644 index 0000000..27d987d Binary files /dev/null and b/Data/Levels/L0707_barrows.lvl differ diff --git a/Data/Levels/L0708_swamp.lvl b/Data/Levels/L0708_swamp.lvl new file mode 100644 index 0000000..d715513 Binary files /dev/null and b/Data/Levels/L0708_swamp.lvl differ diff --git a/Data/Levels/L0709_outback.lvl b/Data/Levels/L0709_outback.lvl new file mode 100644 index 0000000..0ed9e7d Binary files /dev/null and b/Data/Levels/L0709_outback.lvl differ diff --git a/Data/Levels/L0710_outback.lvl b/Data/Levels/L0710_outback.lvl new file mode 100644 index 0000000..c5138f8 Binary files /dev/null and b/Data/Levels/L0710_outback.lvl differ diff --git a/Data/Levels/L0711_spacestation.lvl b/Data/Levels/L0711_spacestation.lvl new file mode 100644 index 0000000..a4d4629 Binary files /dev/null and b/Data/Levels/L0711_spacestation.lvl differ diff --git a/Data/Levels/L0712_farmlanding.lvl b/Data/Levels/L0712_farmlanding.lvl new file mode 100644 index 0000000..4100bf3 Binary files /dev/null and b/Data/Levels/L0712_farmlanding.lvl differ diff --git a/Data/Levels/L0800_ice.lvl b/Data/Levels/L0800_ice.lvl new file mode 100644 index 0000000..e2001dd Binary files /dev/null and b/Data/Levels/L0800_ice.lvl differ diff --git a/Data/Levels/L0801_escape.lvl b/Data/Levels/L0801_escape.lvl new file mode 100644 index 0000000..a420322 Binary files /dev/null and b/Data/Levels/L0801_escape.lvl differ diff --git a/Data/Levels/L0802_windypass.lvl b/Data/Levels/L0802_windypass.lvl new file mode 100644 index 0000000..caf37a9 Binary files /dev/null and b/Data/Levels/L0802_windypass.lvl differ diff --git a/Data/Levels/L0803_djinn.lvl b/Data/Levels/L0803_djinn.lvl new file mode 100644 index 0000000..7fc71c2 Binary files /dev/null and b/Data/Levels/L0803_djinn.lvl differ diff --git a/Data/Levels/L0804_canyon.lvl b/Data/Levels/L0804_canyon.lvl new file mode 100644 index 0000000..a6a220b Binary files /dev/null and b/Data/Levels/L0804_canyon.lvl differ diff --git a/Data/Levels/L0805_jungle.lvl b/Data/Levels/L0805_jungle.lvl new file mode 100644 index 0000000..3186b1d Binary files /dev/null and b/Data/Levels/L0805_jungle.lvl differ diff --git a/Data/Levels/L0806_moores.lvl b/Data/Levels/L0806_moores.lvl new file mode 100644 index 0000000..7a9cb9d Binary files /dev/null and b/Data/Levels/L0806_moores.lvl differ diff --git a/Data/Levels/L0807_swamp.lvl b/Data/Levels/L0807_swamp.lvl new file mode 100644 index 0000000..d9d0063 Binary files /dev/null and b/Data/Levels/L0807_swamp.lvl differ diff --git a/Data/Levels/L0808_warcamp.lvl b/Data/Levels/L0808_warcamp.lvl new file mode 100644 index 0000000..77edbb5 Binary files /dev/null and b/Data/Levels/L0808_warcamp.lvl differ diff --git a/Data/Levels/L0809_warzone.lvl b/Data/Levels/L0809_warzone.lvl new file mode 100644 index 0000000..43c31d0 Binary files /dev/null and b/Data/Levels/L0809_warzone.lvl differ diff --git a/Data/Levels/L0810_graveslanding.lvl b/Data/Levels/L0810_graveslanding.lvl new file mode 100644 index 0000000..8bce8f9 Binary files /dev/null and b/Data/Levels/L0810_graveslanding.lvl differ diff --git a/Data/Levels/L0811_ssa_nw.lvl b/Data/Levels/L0811_ssa_nw.lvl new file mode 100644 index 0000000..5ed337d Binary files /dev/null and b/Data/Levels/L0811_ssa_nw.lvl differ diff --git a/Data/Levels/L0812_warp.lvl b/Data/Levels/L0812_warp.lvl new file mode 100644 index 0000000..faf13b9 Binary files /dev/null and b/Data/Levels/L0812_warp.lvl differ diff --git a/Data/Levels/L0900_guardpost.lvl b/Data/Levels/L0900_guardpost.lvl new file mode 100644 index 0000000..f0ccbd9 Binary files /dev/null and b/Data/Levels/L0900_guardpost.lvl differ diff --git a/Data/Levels/L0901_slavecamp.lvl b/Data/Levels/L0901_slavecamp.lvl new file mode 100644 index 0000000..d7214ad Binary files /dev/null and b/Data/Levels/L0901_slavecamp.lvl differ diff --git a/Data/Levels/L0902_iceplainland.lvl b/Data/Levels/L0902_iceplainland.lvl new file mode 100644 index 0000000..24870bc Binary files /dev/null and b/Data/Levels/L0902_iceplainland.lvl differ diff --git a/Data/Levels/L0903_cornville.lvl b/Data/Levels/L0903_cornville.lvl new file mode 100644 index 0000000..e1ef93a Binary files /dev/null and b/Data/Levels/L0903_cornville.lvl differ diff --git a/Data/Levels/L0904_canyon.lvl b/Data/Levels/L0904_canyon.lvl new file mode 100644 index 0000000..4f88587 Binary files /dev/null and b/Data/Levels/L0904_canyon.lvl differ diff --git a/Data/Levels/L0905_junglelanding.lvl b/Data/Levels/L0905_junglelanding.lvl new file mode 100644 index 0000000..9e92547 Binary files /dev/null and b/Data/Levels/L0905_junglelanding.lvl differ diff --git a/Data/Levels/L0906_stone_wisp.lvl b/Data/Levels/L0906_stone_wisp.lvl new file mode 100644 index 0000000..36ca58c Binary files /dev/null and b/Data/Levels/L0906_stone_wisp.lvl differ diff --git a/Data/Levels/L0907_bullseye.lvl b/Data/Levels/L0907_bullseye.lvl new file mode 100644 index 0000000..657fa7c Binary files /dev/null and b/Data/Levels/L0907_bullseye.lvl differ diff --git a/Data/Levels/L0908_warzone.lvl b/Data/Levels/L0908_warzone.lvl new file mode 100644 index 0000000..e8f52ec Binary files /dev/null and b/Data/Levels/L0908_warzone.lvl differ diff --git a/Data/Levels/L0909_warzone.lvl b/Data/Levels/L0909_warzone.lvl new file mode 100644 index 0000000..dad0e64 Binary files /dev/null and b/Data/Levels/L0909_warzone.lvl differ diff --git a/Data/Levels/L0910_warzone.lvl b/Data/Levels/L0910_warzone.lvl new file mode 100644 index 0000000..eb72653 Binary files /dev/null and b/Data/Levels/L0910_warzone.lvl differ diff --git a/Data/Levels/L0911_ssa_ne.lvl b/Data/Levels/L0911_ssa_ne.lvl new file mode 100644 index 0000000..0d2be25 Binary files /dev/null and b/Data/Levels/L0911_ssa_ne.lvl differ diff --git a/Data/Levels/L0912_monkeyworld.lvl b/Data/Levels/L0912_monkeyworld.lvl new file mode 100644 index 0000000..2b17a3d Binary files /dev/null and b/Data/Levels/L0912_monkeyworld.lvl differ diff --git a/Data/Levels/L1000_basecamp.lvl b/Data/Levels/L1000_basecamp.lvl new file mode 100644 index 0000000..1ae1fc7 Binary files /dev/null and b/Data/Levels/L1000_basecamp.lvl differ diff --git a/Data/Levels/L1001_iceplain.lvl b/Data/Levels/L1001_iceplain.lvl new file mode 100644 index 0000000..4b1246d Binary files /dev/null and b/Data/Levels/L1001_iceplain.lvl differ diff --git a/Data/Levels/L1002_guardpost.lvl b/Data/Levels/L1002_guardpost.lvl new file mode 100644 index 0000000..601cd5a Binary files /dev/null and b/Data/Levels/L1002_guardpost.lvl differ diff --git a/Data/Levels/L1003_beach.lvl b/Data/Levels/L1003_beach.lvl new file mode 100644 index 0000000..1a469f9 Binary files /dev/null and b/Data/Levels/L1003_beach.lvl differ diff --git a/Data/Levels/L1004_pumpkins.lvl b/Data/Levels/L1004_pumpkins.lvl new file mode 100644 index 0000000..ae08b13 Binary files /dev/null and b/Data/Levels/L1004_pumpkins.lvl differ diff --git a/Data/Levels/L1005_autumn.lvl b/Data/Levels/L1005_autumn.lvl new file mode 100644 index 0000000..bdba0d9 Binary files /dev/null and b/Data/Levels/L1005_autumn.lvl differ diff --git a/Data/Levels/L1006_outpost.lvl b/Data/Levels/L1006_outpost.lvl new file mode 100644 index 0000000..67b8a35 Binary files /dev/null and b/Data/Levels/L1006_outpost.lvl differ diff --git a/Data/Levels/L1007_stoneheads.lvl b/Data/Levels/L1007_stoneheads.lvl new file mode 100644 index 0000000..98b9c9c Binary files /dev/null and b/Data/Levels/L1007_stoneheads.lvl differ diff --git a/Data/Levels/L1008_graves.lvl b/Data/Levels/L1008_graves.lvl new file mode 100644 index 0000000..49c854d Binary files /dev/null and b/Data/Levels/L1008_graves.lvl differ diff --git a/Data/Levels/L1009_warzone.lvl b/Data/Levels/L1009_warzone.lvl new file mode 100644 index 0000000..bd70138 Binary files /dev/null and b/Data/Levels/L1009_warzone.lvl differ diff --git a/Data/Levels/L1010_kinggrenade.lvl b/Data/Levels/L1010_kinggrenade.lvl new file mode 100644 index 0000000..a10f5f8 Binary files /dev/null and b/Data/Levels/L1010_kinggrenade.lvl differ diff --git a/Data/Levels/L1011_ssa_sw.lvl b/Data/Levels/L1011_ssa_sw.lvl new file mode 100644 index 0000000..cac022e Binary files /dev/null and b/Data/Levels/L1011_ssa_sw.lvl differ diff --git a/Data/Levels/L1012_library.lvl b/Data/Levels/L1012_library.lvl new file mode 100644 index 0000000..d0e31ac Binary files /dev/null and b/Data/Levels/L1012_library.lvl differ diff --git a/Data/Levels/L1111_ssa_se.lvl b/Data/Levels/L1111_ssa_se.lvl new file mode 100644 index 0000000..45dd980 Binary files /dev/null and b/Data/Levels/L1111_ssa_se.lvl differ diff --git a/Data/Levels/L1112_disco.lvl b/Data/Levels/L1112_disco.lvl new file mode 100644 index 0000000..c78a449 Binary files /dev/null and b/Data/Levels/L1112_disco.lvl differ diff --git a/Data/Levels/L1212_crouton_hw1.lvl b/Data/Levels/L1212_crouton_hw1.lvl new file mode 100644 index 0000000..0972e8e Binary files /dev/null and b/Data/Levels/L1212_crouton_hw1.lvl differ diff --git a/Data/Levels/L1300_appomattox.lvl b/Data/Levels/L1300_appomattox.lvl new file mode 100644 index 0000000..f7abdd4 Binary files /dev/null and b/Data/Levels/L1300_appomattox.lvl differ diff --git a/Data/Levels/L1312_crouton_hw2.lvl b/Data/Levels/L1312_crouton_hw2.lvl new file mode 100644 index 0000000..ecfa031 Binary files /dev/null and b/Data/Levels/L1312_crouton_hw2.lvl differ diff --git a/Data/Levels/L1412_crouton_hw3.lvl b/Data/Levels/L1412_crouton_hw3.lvl new file mode 100644 index 0000000..8599161 Binary files /dev/null and b/Data/Levels/L1412_crouton_hw3.lvl differ diff --git a/Data/Levels/L1504_landing.lvl b/Data/Levels/L1504_landing.lvl new file mode 100644 index 0000000..0fff01f Binary files /dev/null and b/Data/Levels/L1504_landing.lvl differ diff --git a/Data/Levels/L1512_crouton_hw4.lvl b/Data/Levels/L1512_crouton_hw4.lvl new file mode 100644 index 0000000..0a2f3da Binary files /dev/null and b/Data/Levels/L1512_crouton_hw4.lvl differ diff --git a/Data/Music/alarm.gbm.bin b/Data/Music/alarm.gbm.bin new file mode 100644 index 0000000..db99c62 Binary files /dev/null and b/Data/Music/alarm.gbm.bin differ diff --git a/Data/Music/beehive.gbm.bin b/Data/Music/beehive.gbm.bin new file mode 100644 index 0000000..6343dc4 Binary files /dev/null and b/Data/Music/beehive.gbm.bin differ diff --git a/Data/Music/cowboy.gbm.bin b/Data/Music/cowboy.gbm.bin new file mode 100644 index 0000000..760a3ca Binary files /dev/null and b/Data/Music/cowboy.gbm.bin differ diff --git a/Data/Music/death.gbm.bin b/Data/Music/death.gbm.bin new file mode 100644 index 0000000..3fd1570 Binary files /dev/null and b/Data/Music/death.gbm.bin differ diff --git a/Data/Music/fgbwar.gbm.bin b/Data/Music/fgbwar.gbm.bin new file mode 100644 index 0000000..e165330 Binary files /dev/null and b/Data/Music/fgbwar.gbm.bin differ diff --git a/Data/Music/frosty.gbm.bin b/Data/Music/frosty.gbm.bin new file mode 100644 index 0000000..5fe958f Binary files /dev/null and b/Data/Music/frosty.gbm.bin differ diff --git a/Data/Music/hoedown.gbm.bin b/Data/Music/hoedown.gbm.bin new file mode 100644 index 0000000..0dbfd74 Binary files /dev/null and b/Data/Music/hoedown.gbm.bin differ diff --git a/Data/Music/intro_cinema.gbm.bin b/Data/Music/intro_cinema.gbm.bin new file mode 100644 index 0000000..7e2a52e Binary files /dev/null and b/Data/Music/intro_cinema.gbm.bin differ diff --git a/Data/Music/jazzy.gbm.bin b/Data/Music/jazzy.gbm.bin new file mode 100644 index 0000000..bc2f67b Binary files /dev/null and b/Data/Music/jazzy.gbm.bin differ diff --git a/Data/Music/jungle.gbm.bin b/Data/Music/jungle.gbm.bin new file mode 100644 index 0000000..6108bca Binary files /dev/null and b/Data/Music/jungle.gbm.bin differ diff --git a/Data/Music/lady_flower.gbm.bin b/Data/Music/lady_flower.gbm.bin new file mode 100644 index 0000000..6fb8117 Binary files /dev/null and b/Data/Music/lady_flower.gbm.bin differ diff --git a/Data/Music/main_in_game.gbm.bin b/Data/Music/main_in_game.gbm.bin new file mode 100644 index 0000000..a03dbd0 Binary files /dev/null and b/Data/Music/main_in_game.gbm.bin differ diff --git a/Data/Music/makefile b/Data/Music/makefile new file mode 100644 index 0000000..9123ddd --- /dev/null +++ b/Data/Music/makefile @@ -0,0 +1,3 @@ +makegbm.exe: makegbm.cpp makegbm.h + gxx makegbm.cpp -o makegbm.exe + diff --git a/Data/Music/maybe_haiku.gbm.bin b/Data/Music/maybe_haiku.gbm.bin new file mode 100644 index 0000000..10e31b3 Binary files /dev/null and b/Data/Music/maybe_haiku.gbm.bin differ diff --git a/Data/Music/moon_base_ba.gbm.bin b/Data/Music/moon_base_ba.gbm.bin new file mode 100644 index 0000000..a35c4c7 Binary files /dev/null and b/Data/Music/moon_base_ba.gbm.bin differ diff --git a/Data/Music/moon_base_haiku.gbm.bin b/Data/Music/moon_base_haiku.gbm.bin new file mode 100644 index 0000000..61d2496 Binary files /dev/null and b/Data/Music/moon_base_haiku.gbm.bin differ diff --git a/Data/Music/mysterious.gbm.bin b/Data/Music/mysterious.gbm.bin new file mode 100644 index 0000000..d47c2ea Binary files /dev/null and b/Data/Music/mysterious.gbm.bin differ diff --git a/Data/Music/shroom.gbm.bin b/Data/Music/shroom.gbm.bin new file mode 100644 index 0000000..795144f Binary files /dev/null and b/Data/Music/shroom.gbm.bin differ diff --git a/Data/Music/something_happy.gbm.bin b/Data/Music/something_happy.gbm.bin new file mode 100644 index 0000000..36d90b3 Binary files /dev/null and b/Data/Music/something_happy.gbm.bin differ diff --git a/Data/Music/spaceish.gbm.bin b/Data/Music/spaceish.gbm.bin new file mode 100644 index 0000000..968876a Binary files /dev/null and b/Data/Music/spaceish.gbm.bin differ diff --git a/Data/Music/takeoff.gbm.bin b/Data/Music/takeoff.gbm.bin new file mode 100644 index 0000000..fb7e2f2 Binary files /dev/null and b/Data/Music/takeoff.gbm.bin differ diff --git a/Data/Music/wedding.gbm.bin b/Data/Music/wedding.gbm.bin new file mode 100644 index 0000000..2d1e2b0 Binary files /dev/null and b/Data/Music/wedding.gbm.bin differ diff --git a/Data/SoundSamples/eat.gbw b/Data/SoundSamples/eat.gbw new file mode 100644 index 0000000..1ac0c85 Binary files /dev/null and b/Data/SoundSamples/eat.gbw differ diff --git a/Data/Sprites/explosions0-85.bin b/Data/Sprites/explosions0-85.bin new file mode 100644 index 0000000..6102d22 Binary files /dev/null and b/Data/Sprites/explosions0-85.bin differ diff --git a/Data/Tiles/bgTiles1-256.bin b/Data/Tiles/bgTiles1-256.bin new file mode 100644 index 0000000..fe6a30d Binary files /dev/null and b/Data/Tiles/bgTiles1-256.bin differ diff --git a/Data/Tiles/bgTiles1024-1279.bin b/Data/Tiles/bgTiles1024-1279.bin new file mode 100644 index 0000000..734fd83 Binary files /dev/null and b/Data/Tiles/bgTiles1024-1279.bin differ diff --git a/Data/Tiles/bgTiles1280-1535.bin b/Data/Tiles/bgTiles1280-1535.bin new file mode 100644 index 0000000..aa18685 Binary files /dev/null and b/Data/Tiles/bgTiles1280-1535.bin differ diff --git a/Data/Tiles/bgTiles1536-1791.bin b/Data/Tiles/bgTiles1536-1791.bin new file mode 100644 index 0000000..a586326 Binary files /dev/null and b/Data/Tiles/bgTiles1536-1791.bin differ diff --git a/Data/Tiles/bgTiles1792-2047.bin b/Data/Tiles/bgTiles1792-2047.bin new file mode 100644 index 0000000..069a18c Binary files /dev/null and b/Data/Tiles/bgTiles1792-2047.bin differ diff --git a/Data/Tiles/bgTiles257-512.bin b/Data/Tiles/bgTiles257-512.bin new file mode 100644 index 0000000..f649404 Binary files /dev/null and b/Data/Tiles/bgTiles257-512.bin differ diff --git a/Data/Tiles/bgTiles513-768.bin b/Data/Tiles/bgTiles513-768.bin new file mode 100644 index 0000000..9e4aca6 Binary files /dev/null and b/Data/Tiles/bgTiles513-768.bin differ diff --git a/Data/Tiles/bgTiles769-979.bin b/Data/Tiles/bgTiles769-979.bin new file mode 100644 index 0000000..e63ca48 Binary files /dev/null and b/Data/Tiles/bgTiles769-979.bin differ diff --git a/Data/Tiles/fgTiles2048-2302.bin b/Data/Tiles/fgTiles2048-2302.bin new file mode 100644 index 0000000..125d682 Binary files /dev/null and b/Data/Tiles/fgTiles2048-2302.bin differ diff --git a/Data/Tiles/fgTiles2304-2559.bin b/Data/Tiles/fgTiles2304-2559.bin new file mode 100644 index 0000000..8df55b5 Binary files /dev/null and b/Data/Tiles/fgTiles2304-2559.bin differ diff --git a/Data/discolights.dat b/Data/discolights.dat new file mode 100644 index 0000000..da4e003 Binary files /dev/null and b/Data/discolights.dat differ diff --git a/Data/font.bin b/Data/font.bin new file mode 100644 index 0000000..96dbf33 Binary files /dev/null and b/Data/font.bin differ diff --git a/LICENSE b/LICENSE index 97ee54c..bf381ae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,13 @@ +=============================================================================== +Source Code + +The source code for the FGB game (Source/ folder) and the included editors +(Tools/ folder) is released under the MIT license, as are the essential data +files for the editors. +=============================================================================== MIT License -Copyright (c) 2020 AbePralle +Copyright (c) 2000, 2020 Abe Pralle and Jacob Stevens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,3 +26,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +=============================================================================== +Game Data and Intellectual Property + +The FGB game data files in the Data/ folder and all intellectual property +(characters, art, dialog, maps, music, etc.) - collectively, "the FGB IP" - are +released under the following Creative Commons license. +=============================================================================== +The FGB IP by Abe Pralle and Jacob Stevens is licensed under CC BY-NC-SA 4.0 +https://creativecommons.org/licenses/by-nc-sa/4.0 + diff --git a/Media/DesignDocs/TopLevelStoryScript.doc b/Media/DesignDocs/TopLevelStoryScript.doc new file mode 100644 index 0000000..780949a Binary files /dev/null and b/Media/DesignDocs/TopLevelStoryScript.doc differ diff --git a/Media/DesignDocs/TopLevelStoryScript.pdf b/Media/DesignDocs/TopLevelStoryScript.pdf new file mode 100644 index 0000000..4a31d37 Binary files /dev/null and b/Media/DesignDocs/TopLevelStoryScript.pdf differ diff --git a/Media/DesignDocs/WorldMap.xls b/Media/DesignDocs/WorldMap.xls new file mode 100644 index 0000000..d04f906 Binary files /dev/null and b/Media/DesignDocs/WorldMap.xls differ diff --git a/Media/FGBPreview.gif b/Media/FGBPreview.gif new file mode 100644 index 0000000..9bb2c87 Binary files /dev/null and b/Media/FGBPreview.gif differ diff --git a/Media/FGBPreview.mp4 b/Media/FGBPreview.mp4 new file mode 100644 index 0000000..40ca8f8 Binary files /dev/null and b/Media/FGBPreview.mp4 differ diff --git a/Media/Flyer-E3-2000.doc b/Media/Flyer-E3-2000.doc new file mode 100644 index 0000000..071a0f2 Binary files /dev/null and b/Media/Flyer-E3-2000.doc differ diff --git a/Media/Levels/0000.png b/Media/Levels/0000.png new file mode 100644 index 0000000..6f5fa87 Binary files /dev/null and b/Media/Levels/0000.png differ diff --git a/Media/Levels/0001.png b/Media/Levels/0001.png new file mode 100644 index 0000000..0a85999 Binary files /dev/null and b/Media/Levels/0001.png differ diff --git a/Media/Levels/0002.png b/Media/Levels/0002.png new file mode 100644 index 0000000..6491c46 Binary files /dev/null and b/Media/Levels/0002.png differ diff --git a/Media/Levels/0003.png b/Media/Levels/0003.png new file mode 100644 index 0000000..bcf879a Binary files /dev/null and b/Media/Levels/0003.png differ diff --git a/Media/Levels/0004.png b/Media/Levels/0004.png new file mode 100644 index 0000000..363a24d Binary files /dev/null and b/Media/Levels/0004.png differ diff --git a/Media/Levels/0005.png b/Media/Levels/0005.png new file mode 100644 index 0000000..24bfef8 Binary files /dev/null and b/Media/Levels/0005.png differ diff --git a/Media/Levels/0006.png b/Media/Levels/0006.png new file mode 100644 index 0000000..7135c81 Binary files /dev/null and b/Media/Levels/0006.png differ diff --git a/Media/Levels/0007.png b/Media/Levels/0007.png new file mode 100644 index 0000000..d4e7b9f Binary files /dev/null and b/Media/Levels/0007.png differ diff --git a/Media/Levels/0008.png b/Media/Levels/0008.png new file mode 100644 index 0000000..b3f3be8 Binary files /dev/null and b/Media/Levels/0008.png differ diff --git a/Media/Levels/0009.png b/Media/Levels/0009.png new file mode 100644 index 0000000..5fddbec Binary files /dev/null and b/Media/Levels/0009.png differ diff --git a/Media/Levels/0010.png b/Media/Levels/0010.png new file mode 100644 index 0000000..ab7a644 Binary files /dev/null and b/Media/Levels/0010.png differ diff --git a/Media/Levels/0011.png b/Media/Levels/0011.png new file mode 100644 index 0000000..43bfb59 Binary files /dev/null and b/Media/Levels/0011.png differ diff --git a/Media/Levels/0012.png b/Media/Levels/0012.png new file mode 100644 index 0000000..5079bb0 Binary files /dev/null and b/Media/Levels/0012.png differ diff --git a/Media/Levels/0013.png b/Media/Levels/0013.png new file mode 100644 index 0000000..44ded68 Binary files /dev/null and b/Media/Levels/0013.png differ diff --git a/Media/Levels/0014.png b/Media/Levels/0014.png new file mode 100644 index 0000000..6c6f3bf Binary files /dev/null and b/Media/Levels/0014.png differ diff --git a/Media/Levels/0015.png b/Media/Levels/0015.png new file mode 100644 index 0000000..d18762f Binary files /dev/null and b/Media/Levels/0015.png differ diff --git a/Media/Levels/0100.png b/Media/Levels/0100.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0100.png differ diff --git a/Media/Levels/0101.png b/Media/Levels/0101.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0101.png differ diff --git a/Media/Levels/0102.png b/Media/Levels/0102.png new file mode 100644 index 0000000..1163f60 Binary files /dev/null and b/Media/Levels/0102.png differ diff --git a/Media/Levels/0103.png b/Media/Levels/0103.png new file mode 100644 index 0000000..e73c1c1 Binary files /dev/null and b/Media/Levels/0103.png differ diff --git a/Media/Levels/0104.png b/Media/Levels/0104.png new file mode 100644 index 0000000..7eb5bd5 Binary files /dev/null and b/Media/Levels/0104.png differ diff --git a/Media/Levels/0105.png b/Media/Levels/0105.png new file mode 100644 index 0000000..aadd07b Binary files /dev/null and b/Media/Levels/0105.png differ diff --git a/Media/Levels/0106.png b/Media/Levels/0106.png new file mode 100644 index 0000000..9372366 Binary files /dev/null and b/Media/Levels/0106.png differ diff --git a/Media/Levels/0107.png b/Media/Levels/0107.png new file mode 100644 index 0000000..fdadfb0 Binary files /dev/null and b/Media/Levels/0107.png differ diff --git a/Media/Levels/0108.png b/Media/Levels/0108.png new file mode 100644 index 0000000..0702994 Binary files /dev/null and b/Media/Levels/0108.png differ diff --git a/Media/Levels/0109.png b/Media/Levels/0109.png new file mode 100644 index 0000000..3248892 Binary files /dev/null and b/Media/Levels/0109.png differ diff --git a/Media/Levels/0110.png b/Media/Levels/0110.png new file mode 100644 index 0000000..3b3c760 Binary files /dev/null and b/Media/Levels/0110.png differ diff --git a/Media/Levels/0111.png b/Media/Levels/0111.png new file mode 100644 index 0000000..6cdaa37 Binary files /dev/null and b/Media/Levels/0111.png differ diff --git a/Media/Levels/0112.png b/Media/Levels/0112.png new file mode 100644 index 0000000..c669c02 Binary files /dev/null and b/Media/Levels/0112.png differ diff --git a/Media/Levels/0113.png b/Media/Levels/0113.png new file mode 100644 index 0000000..d75e2bc Binary files /dev/null and b/Media/Levels/0113.png differ diff --git a/Media/Levels/0114.png b/Media/Levels/0114.png new file mode 100644 index 0000000..0120492 Binary files /dev/null and b/Media/Levels/0114.png differ diff --git a/Media/Levels/0115.png b/Media/Levels/0115.png new file mode 100644 index 0000000..5226b6b Binary files /dev/null and b/Media/Levels/0115.png differ diff --git a/Media/Levels/0200.png b/Media/Levels/0200.png new file mode 100644 index 0000000..7991eaa Binary files /dev/null and b/Media/Levels/0200.png differ diff --git a/Media/Levels/0201.png b/Media/Levels/0201.png new file mode 100644 index 0000000..84d0f73 Binary files /dev/null and b/Media/Levels/0201.png differ diff --git a/Media/Levels/0202.png b/Media/Levels/0202.png new file mode 100644 index 0000000..1e82fd8 Binary files /dev/null and b/Media/Levels/0202.png differ diff --git a/Media/Levels/0203.png b/Media/Levels/0203.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0203.png differ diff --git a/Media/Levels/0204.png b/Media/Levels/0204.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0204.png differ diff --git a/Media/Levels/0205.png b/Media/Levels/0205.png new file mode 100644 index 0000000..38d097f Binary files /dev/null and b/Media/Levels/0205.png differ diff --git a/Media/Levels/0206.png b/Media/Levels/0206.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0206.png differ diff --git a/Media/Levels/0207.png b/Media/Levels/0207.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0207.png differ diff --git a/Media/Levels/0208.png b/Media/Levels/0208.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0208.png differ diff --git a/Media/Levels/0209.png b/Media/Levels/0209.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0209.png differ diff --git a/Media/Levels/0210.png b/Media/Levels/0210.png new file mode 100644 index 0000000..609d313 Binary files /dev/null and b/Media/Levels/0210.png differ diff --git a/Media/Levels/0211.png b/Media/Levels/0211.png new file mode 100644 index 0000000..67fddb6 Binary files /dev/null and b/Media/Levels/0211.png differ diff --git a/Media/Levels/0212.png b/Media/Levels/0212.png new file mode 100644 index 0000000..8d6eec6 Binary files /dev/null and b/Media/Levels/0212.png differ diff --git a/Media/Levels/0213.png b/Media/Levels/0213.png new file mode 100644 index 0000000..a203859 Binary files /dev/null and b/Media/Levels/0213.png differ diff --git a/Media/Levels/0214.png b/Media/Levels/0214.png new file mode 100644 index 0000000..e789db3 Binary files /dev/null and b/Media/Levels/0214.png differ diff --git a/Media/Levels/0215.png b/Media/Levels/0215.png new file mode 100644 index 0000000..cb59853 Binary files /dev/null and b/Media/Levels/0215.png differ diff --git a/Media/Levels/0300.png b/Media/Levels/0300.png new file mode 100644 index 0000000..94e0cf6 Binary files /dev/null and b/Media/Levels/0300.png differ diff --git a/Media/Levels/0301.png b/Media/Levels/0301.png new file mode 100644 index 0000000..08825d0 Binary files /dev/null and b/Media/Levels/0301.png differ diff --git a/Media/Levels/0302.png b/Media/Levels/0302.png new file mode 100644 index 0000000..1e5f19a Binary files /dev/null and b/Media/Levels/0302.png differ diff --git a/Media/Levels/0303.png b/Media/Levels/0303.png new file mode 100644 index 0000000..273656f Binary files /dev/null and b/Media/Levels/0303.png differ diff --git a/Media/Levels/0304.png b/Media/Levels/0304.png new file mode 100644 index 0000000..d0a7c8c Binary files /dev/null and b/Media/Levels/0304.png differ diff --git a/Media/Levels/0305.png b/Media/Levels/0305.png new file mode 100644 index 0000000..0fdf20d Binary files /dev/null and b/Media/Levels/0305.png differ diff --git a/Media/Levels/0306.png b/Media/Levels/0306.png new file mode 100644 index 0000000..bb25887 Binary files /dev/null and b/Media/Levels/0306.png differ diff --git a/Media/Levels/0307.png b/Media/Levels/0307.png new file mode 100644 index 0000000..0173b04 Binary files /dev/null and b/Media/Levels/0307.png differ diff --git a/Media/Levels/0308.png b/Media/Levels/0308.png new file mode 100644 index 0000000..d217c8c Binary files /dev/null and b/Media/Levels/0308.png differ diff --git a/Media/Levels/0309.png b/Media/Levels/0309.png new file mode 100644 index 0000000..50061e0 Binary files /dev/null and b/Media/Levels/0309.png differ diff --git a/Media/Levels/0310.png b/Media/Levels/0310.png new file mode 100644 index 0000000..4b966ea Binary files /dev/null and b/Media/Levels/0310.png differ diff --git a/Media/Levels/0311.png b/Media/Levels/0311.png new file mode 100644 index 0000000..6edfd88 Binary files /dev/null and b/Media/Levels/0311.png differ diff --git a/Media/Levels/0312.png b/Media/Levels/0312.png new file mode 100644 index 0000000..4fbe877 Binary files /dev/null and b/Media/Levels/0312.png differ diff --git a/Media/Levels/0313.png b/Media/Levels/0313.png new file mode 100644 index 0000000..96310c6 Binary files /dev/null and b/Media/Levels/0313.png differ diff --git a/Media/Levels/0314.png b/Media/Levels/0314.png new file mode 100644 index 0000000..d893293 Binary files /dev/null and b/Media/Levels/0314.png differ diff --git a/Media/Levels/0315.png b/Media/Levels/0315.png new file mode 100644 index 0000000..47c59a0 Binary files /dev/null and b/Media/Levels/0315.png differ diff --git a/Media/Levels/0400.png b/Media/Levels/0400.png new file mode 100644 index 0000000..78d3b8b Binary files /dev/null and b/Media/Levels/0400.png differ diff --git a/Media/Levels/0401.png b/Media/Levels/0401.png new file mode 100644 index 0000000..601f265 Binary files /dev/null and b/Media/Levels/0401.png differ diff --git a/Media/Levels/0402.png b/Media/Levels/0402.png new file mode 100644 index 0000000..25c13ce Binary files /dev/null and b/Media/Levels/0402.png differ diff --git a/Media/Levels/0403.png b/Media/Levels/0403.png new file mode 100644 index 0000000..6140cca Binary files /dev/null and b/Media/Levels/0403.png differ diff --git a/Media/Levels/0404.png b/Media/Levels/0404.png new file mode 100644 index 0000000..6ebbc14 Binary files /dev/null and b/Media/Levels/0404.png differ diff --git a/Media/Levels/0405.png b/Media/Levels/0405.png new file mode 100644 index 0000000..1f054a8 Binary files /dev/null and b/Media/Levels/0405.png differ diff --git a/Media/Levels/0406.png b/Media/Levels/0406.png new file mode 100644 index 0000000..d41ce05 Binary files /dev/null and b/Media/Levels/0406.png differ diff --git a/Media/Levels/0407.png b/Media/Levels/0407.png new file mode 100644 index 0000000..78a7811 Binary files /dev/null and b/Media/Levels/0407.png differ diff --git a/Media/Levels/0408.png b/Media/Levels/0408.png new file mode 100644 index 0000000..e141e4c Binary files /dev/null and b/Media/Levels/0408.png differ diff --git a/Media/Levels/0409.png b/Media/Levels/0409.png new file mode 100644 index 0000000..d6f2a14 Binary files /dev/null and b/Media/Levels/0409.png differ diff --git a/Media/Levels/0410.png b/Media/Levels/0410.png new file mode 100644 index 0000000..0f9854e Binary files /dev/null and b/Media/Levels/0410.png differ diff --git a/Media/Levels/0411.png b/Media/Levels/0411.png new file mode 100644 index 0000000..797764b Binary files /dev/null and b/Media/Levels/0411.png differ diff --git a/Media/Levels/0412.png b/Media/Levels/0412.png new file mode 100644 index 0000000..d901494 Binary files /dev/null and b/Media/Levels/0412.png differ diff --git a/Media/Levels/0500.png b/Media/Levels/0500.png new file mode 100644 index 0000000..ab0df7b Binary files /dev/null and b/Media/Levels/0500.png differ diff --git a/Media/Levels/0501.png b/Media/Levels/0501.png new file mode 100644 index 0000000..4879a42 Binary files /dev/null and b/Media/Levels/0501.png differ diff --git a/Media/Levels/0502.png b/Media/Levels/0502.png new file mode 100644 index 0000000..65e7c7e Binary files /dev/null and b/Media/Levels/0502.png differ diff --git a/Media/Levels/0503.png b/Media/Levels/0503.png new file mode 100644 index 0000000..5278f8e Binary files /dev/null and b/Media/Levels/0503.png differ diff --git a/Media/Levels/0504.png b/Media/Levels/0504.png new file mode 100644 index 0000000..a076a35 Binary files /dev/null and b/Media/Levels/0504.png differ diff --git a/Media/Levels/0505.png b/Media/Levels/0505.png new file mode 100644 index 0000000..2197e66 Binary files /dev/null and b/Media/Levels/0505.png differ diff --git a/Media/Levels/0506.png b/Media/Levels/0506.png new file mode 100644 index 0000000..cf0085b Binary files /dev/null and b/Media/Levels/0506.png differ diff --git a/Media/Levels/0507.png b/Media/Levels/0507.png new file mode 100644 index 0000000..a6c0f61 Binary files /dev/null and b/Media/Levels/0507.png differ diff --git a/Media/Levels/0508.png b/Media/Levels/0508.png new file mode 100644 index 0000000..bf64f1b Binary files /dev/null and b/Media/Levels/0508.png differ diff --git a/Media/Levels/0509.png b/Media/Levels/0509.png new file mode 100644 index 0000000..7567a52 Binary files /dev/null and b/Media/Levels/0509.png differ diff --git a/Media/Levels/0510.png b/Media/Levels/0510.png new file mode 100644 index 0000000..2b53ec3 Binary files /dev/null and b/Media/Levels/0510.png differ diff --git a/Media/Levels/0512.png b/Media/Levels/0512.png new file mode 100644 index 0000000..aea25c9 Binary files /dev/null and b/Media/Levels/0512.png differ diff --git a/Media/Levels/0600.png b/Media/Levels/0600.png new file mode 100644 index 0000000..7531d12 Binary files /dev/null and b/Media/Levels/0600.png differ diff --git a/Media/Levels/0601.png b/Media/Levels/0601.png new file mode 100644 index 0000000..8d93768 Binary files /dev/null and b/Media/Levels/0601.png differ diff --git a/Media/Levels/0602.png b/Media/Levels/0602.png new file mode 100644 index 0000000..4938b28 Binary files /dev/null and b/Media/Levels/0602.png differ diff --git a/Media/Levels/0603.png b/Media/Levels/0603.png new file mode 100644 index 0000000..dbb8f02 Binary files /dev/null and b/Media/Levels/0603.png differ diff --git a/Media/Levels/0604.png b/Media/Levels/0604.png new file mode 100644 index 0000000..b9d3ce2 Binary files /dev/null and b/Media/Levels/0604.png differ diff --git a/Media/Levels/0605.png b/Media/Levels/0605.png new file mode 100644 index 0000000..7683bc2 Binary files /dev/null and b/Media/Levels/0605.png differ diff --git a/Media/Levels/0606.png b/Media/Levels/0606.png new file mode 100644 index 0000000..a15d2bb Binary files /dev/null and b/Media/Levels/0606.png differ diff --git a/Media/Levels/0607.png b/Media/Levels/0607.png new file mode 100644 index 0000000..7dae9b7 Binary files /dev/null and b/Media/Levels/0607.png differ diff --git a/Media/Levels/0608.png b/Media/Levels/0608.png new file mode 100644 index 0000000..e4c8596 Binary files /dev/null and b/Media/Levels/0608.png differ diff --git a/Media/Levels/0609.png b/Media/Levels/0609.png new file mode 100644 index 0000000..3ac0831 Binary files /dev/null and b/Media/Levels/0609.png differ diff --git a/Media/Levels/0610.png b/Media/Levels/0610.png new file mode 100644 index 0000000..76b495c Binary files /dev/null and b/Media/Levels/0610.png differ diff --git a/Media/Levels/0612.png b/Media/Levels/0612.png new file mode 100644 index 0000000..db47ad6 Binary files /dev/null and b/Media/Levels/0612.png differ diff --git a/Media/Levels/0700.png b/Media/Levels/0700.png new file mode 100644 index 0000000..f787fcf Binary files /dev/null and b/Media/Levels/0700.png differ diff --git a/Media/Levels/0701.png b/Media/Levels/0701.png new file mode 100644 index 0000000..d859916 Binary files /dev/null and b/Media/Levels/0701.png differ diff --git a/Media/Levels/0702.png b/Media/Levels/0702.png new file mode 100644 index 0000000..22e6932 Binary files /dev/null and b/Media/Levels/0702.png differ diff --git a/Media/Levels/0703.png b/Media/Levels/0703.png new file mode 100644 index 0000000..f3c600d Binary files /dev/null and b/Media/Levels/0703.png differ diff --git a/Media/Levels/0704.png b/Media/Levels/0704.png new file mode 100644 index 0000000..df52784 Binary files /dev/null and b/Media/Levels/0704.png differ diff --git a/Media/Levels/0705.png b/Media/Levels/0705.png new file mode 100644 index 0000000..37f50fd Binary files /dev/null and b/Media/Levels/0705.png differ diff --git a/Media/Levels/0706.png b/Media/Levels/0706.png new file mode 100644 index 0000000..ab91969 Binary files /dev/null and b/Media/Levels/0706.png differ diff --git a/Media/Levels/0707.png b/Media/Levels/0707.png new file mode 100644 index 0000000..613668e Binary files /dev/null and b/Media/Levels/0707.png differ diff --git a/Media/Levels/0708.png b/Media/Levels/0708.png new file mode 100644 index 0000000..98ecd91 Binary files /dev/null and b/Media/Levels/0708.png differ diff --git a/Media/Levels/0709.png b/Media/Levels/0709.png new file mode 100644 index 0000000..3d79b8f Binary files /dev/null and b/Media/Levels/0709.png differ diff --git a/Media/Levels/0710.png b/Media/Levels/0710.png new file mode 100644 index 0000000..55ddd23 Binary files /dev/null and b/Media/Levels/0710.png differ diff --git a/Media/Levels/0711.png b/Media/Levels/0711.png new file mode 100644 index 0000000..877ea34 Binary files /dev/null and b/Media/Levels/0711.png differ diff --git a/Media/Levels/0712.png b/Media/Levels/0712.png new file mode 100644 index 0000000..29c54d4 Binary files /dev/null and b/Media/Levels/0712.png differ diff --git a/Media/Levels/0800.png b/Media/Levels/0800.png new file mode 100644 index 0000000..a591770 Binary files /dev/null and b/Media/Levels/0800.png differ diff --git a/Media/Levels/0801.png b/Media/Levels/0801.png new file mode 100644 index 0000000..0ed21df Binary files /dev/null and b/Media/Levels/0801.png differ diff --git a/Media/Levels/0802.png b/Media/Levels/0802.png new file mode 100644 index 0000000..531dca9 Binary files /dev/null and b/Media/Levels/0802.png differ diff --git a/Media/Levels/0803.png b/Media/Levels/0803.png new file mode 100644 index 0000000..2e3633c Binary files /dev/null and b/Media/Levels/0803.png differ diff --git a/Media/Levels/0804.png b/Media/Levels/0804.png new file mode 100644 index 0000000..f29e98e Binary files /dev/null and b/Media/Levels/0804.png differ diff --git a/Media/Levels/0805.png b/Media/Levels/0805.png new file mode 100644 index 0000000..c829979 Binary files /dev/null and b/Media/Levels/0805.png differ diff --git a/Media/Levels/0806.png b/Media/Levels/0806.png new file mode 100644 index 0000000..8c41192 Binary files /dev/null and b/Media/Levels/0806.png differ diff --git a/Media/Levels/0807.png b/Media/Levels/0807.png new file mode 100644 index 0000000..769a9d3 Binary files /dev/null and b/Media/Levels/0807.png differ diff --git a/Media/Levels/0808.png b/Media/Levels/0808.png new file mode 100644 index 0000000..a91a439 Binary files /dev/null and b/Media/Levels/0808.png differ diff --git a/Media/Levels/0809.png b/Media/Levels/0809.png new file mode 100644 index 0000000..ea2e759 Binary files /dev/null and b/Media/Levels/0809.png differ diff --git a/Media/Levels/0810.png b/Media/Levels/0810.png new file mode 100644 index 0000000..d393518 Binary files /dev/null and b/Media/Levels/0810.png differ diff --git a/Media/Levels/0811.png b/Media/Levels/0811.png new file mode 100644 index 0000000..37988fa Binary files /dev/null and b/Media/Levels/0811.png differ diff --git a/Media/Levels/0812.png b/Media/Levels/0812.png new file mode 100644 index 0000000..df7e00b Binary files /dev/null and b/Media/Levels/0812.png differ diff --git a/Media/Levels/0900.png b/Media/Levels/0900.png new file mode 100644 index 0000000..c91fc88 Binary files /dev/null and b/Media/Levels/0900.png differ diff --git a/Media/Levels/0901.png b/Media/Levels/0901.png new file mode 100644 index 0000000..59b0efc Binary files /dev/null and b/Media/Levels/0901.png differ diff --git a/Media/Levels/0902.png b/Media/Levels/0902.png new file mode 100644 index 0000000..1a79371 Binary files /dev/null and b/Media/Levels/0902.png differ diff --git a/Media/Levels/0903.png b/Media/Levels/0903.png new file mode 100644 index 0000000..c47809c Binary files /dev/null and b/Media/Levels/0903.png differ diff --git a/Media/Levels/0904.png b/Media/Levels/0904.png new file mode 100644 index 0000000..afef2db Binary files /dev/null and b/Media/Levels/0904.png differ diff --git a/Media/Levels/0905.png b/Media/Levels/0905.png new file mode 100644 index 0000000..e939af3 Binary files /dev/null and b/Media/Levels/0905.png differ diff --git a/Media/Levels/0906.png b/Media/Levels/0906.png new file mode 100644 index 0000000..130dab1 Binary files /dev/null and b/Media/Levels/0906.png differ diff --git a/Media/Levels/0907.png b/Media/Levels/0907.png new file mode 100644 index 0000000..f5a50f5 Binary files /dev/null and b/Media/Levels/0907.png differ diff --git a/Media/Levels/0908.png b/Media/Levels/0908.png new file mode 100644 index 0000000..2fc3275 Binary files /dev/null and b/Media/Levels/0908.png differ diff --git a/Media/Levels/0909.png b/Media/Levels/0909.png new file mode 100644 index 0000000..ec7e424 Binary files /dev/null and b/Media/Levels/0909.png differ diff --git a/Media/Levels/0910.png b/Media/Levels/0910.png new file mode 100644 index 0000000..3887d30 Binary files /dev/null and b/Media/Levels/0910.png differ diff --git a/Media/Levels/0911.png b/Media/Levels/0911.png new file mode 100644 index 0000000..66ba784 Binary files /dev/null and b/Media/Levels/0911.png differ diff --git a/Media/Levels/0912.png b/Media/Levels/0912.png new file mode 100644 index 0000000..14e2b96 Binary files /dev/null and b/Media/Levels/0912.png differ diff --git a/Media/Levels/1000.png b/Media/Levels/1000.png new file mode 100644 index 0000000..a22588e Binary files /dev/null and b/Media/Levels/1000.png differ diff --git a/Media/Levels/1001.png b/Media/Levels/1001.png new file mode 100644 index 0000000..7ba0ba5 Binary files /dev/null and b/Media/Levels/1001.png differ diff --git a/Media/Levels/1002.png b/Media/Levels/1002.png new file mode 100644 index 0000000..28d135f Binary files /dev/null and b/Media/Levels/1002.png differ diff --git a/Media/Levels/1003.png b/Media/Levels/1003.png new file mode 100644 index 0000000..4428a17 Binary files /dev/null and b/Media/Levels/1003.png differ diff --git a/Media/Levels/1004.png b/Media/Levels/1004.png new file mode 100644 index 0000000..e3ed32b Binary files /dev/null and b/Media/Levels/1004.png differ diff --git a/Media/Levels/1005.png b/Media/Levels/1005.png new file mode 100644 index 0000000..c209b14 Binary files /dev/null and b/Media/Levels/1005.png differ diff --git a/Media/Levels/1006.png b/Media/Levels/1006.png new file mode 100644 index 0000000..25bc63c Binary files /dev/null and b/Media/Levels/1006.png differ diff --git a/Media/Levels/1007.png b/Media/Levels/1007.png new file mode 100644 index 0000000..14aa5ae Binary files /dev/null and b/Media/Levels/1007.png differ diff --git a/Media/Levels/1008.png b/Media/Levels/1008.png new file mode 100644 index 0000000..62b51fb Binary files /dev/null and b/Media/Levels/1008.png differ diff --git a/Media/Levels/1009.png b/Media/Levels/1009.png new file mode 100644 index 0000000..86b03c3 Binary files /dev/null and b/Media/Levels/1009.png differ diff --git a/Media/Levels/1010.png b/Media/Levels/1010.png new file mode 100644 index 0000000..38c5c93 Binary files /dev/null and b/Media/Levels/1010.png differ diff --git a/Media/Levels/1011.png b/Media/Levels/1011.png new file mode 100644 index 0000000..04926f6 Binary files /dev/null and b/Media/Levels/1011.png differ diff --git a/Media/Levels/1012.png b/Media/Levels/1012.png new file mode 100644 index 0000000..e280f36 Binary files /dev/null and b/Media/Levels/1012.png differ diff --git a/Media/Levels/1111.png b/Media/Levels/1111.png new file mode 100644 index 0000000..9f1d3bb Binary files /dev/null and b/Media/Levels/1111.png differ diff --git a/Media/Levels/1112.png b/Media/Levels/1112.png new file mode 100644 index 0000000..22f8082 Binary files /dev/null and b/Media/Levels/1112.png differ diff --git a/Media/Levels/1212.png b/Media/Levels/1212.png new file mode 100644 index 0000000..6d7869b Binary files /dev/null and b/Media/Levels/1212.png differ diff --git a/Media/Levels/1300.png b/Media/Levels/1300.png new file mode 100644 index 0000000..2180fe2 Binary files /dev/null and b/Media/Levels/1300.png differ diff --git a/Media/Levels/1312.png b/Media/Levels/1312.png new file mode 100644 index 0000000..88725d2 Binary files /dev/null and b/Media/Levels/1312.png differ diff --git a/Media/Levels/1412.png b/Media/Levels/1412.png new file mode 100644 index 0000000..ebcf889 Binary files /dev/null and b/Media/Levels/1412.png differ diff --git a/Media/Levels/1504.png b/Media/Levels/1504.png new file mode 100644 index 0000000..07f2964 Binary files /dev/null and b/Media/Levels/1504.png differ diff --git a/Media/Levels/1512.png b/Media/Levels/1512.png new file mode 100644 index 0000000..d30eca7 Binary files /dev/null and b/Media/Levels/1512.png differ diff --git a/Media/Logo/Logo.png b/Media/Logo/Logo.png new file mode 100644 index 0000000..df30e2e Binary files /dev/null and b/Media/Logo/Logo.png differ diff --git a/Media/Maps/FarmLanding.png b/Media/Maps/FarmLanding.png new file mode 100644 index 0000000..551379d Binary files /dev/null and b/Media/Maps/FarmLanding.png differ diff --git a/Media/Maps/FourSeasonsHouse.png b/Media/Maps/FourSeasonsHouse.png new file mode 100644 index 0000000..43bfb59 Binary files /dev/null and b/Media/Maps/FourSeasonsHouse.png differ diff --git a/Media/Maps/MonkeyHomeworldAndCroutonHomeworld.png b/Media/Maps/MonkeyHomeworldAndCroutonHomeworld.png new file mode 100644 index 0000000..ce0e298 Binary files /dev/null and b/Media/Maps/MonkeyHomeworldAndCroutonHomeworld.png differ diff --git a/Media/Maps/MoonBase.png b/Media/Maps/MoonBase.png new file mode 100644 index 0000000..5c6c90c Binary files /dev/null and b/Media/Maps/MoonBase.png differ diff --git a/Media/Maps/SpaceStationApocalypse.png b/Media/Maps/SpaceStationApocalypse.png new file mode 100644 index 0000000..bda5f20 Binary files /dev/null and b/Media/Maps/SpaceStationApocalypse.png differ diff --git a/Media/Maps/SunsetVillageHouses.png b/Media/Maps/SunsetVillageHouses.png new file mode 100644 index 0000000..b0660eb Binary files /dev/null and b/Media/Maps/SunsetVillageHouses.png differ diff --git a/Media/Maps/TheAppomattox.png b/Media/Maps/TheAppomattox.png new file mode 100644 index 0000000..2180fe2 Binary files /dev/null and b/Media/Maps/TheAppomattox.png differ diff --git a/Media/Maps/TheHive.png b/Media/Maps/TheHive.png new file mode 100644 index 0000000..39b7037 Binary files /dev/null and b/Media/Maps/TheHive.png differ diff --git a/Media/Maps/Tower.png b/Media/Maps/Tower.png new file mode 100644 index 0000000..047d82c Binary files /dev/null and b/Media/Maps/Tower.png differ diff --git a/Media/Maps/WitchsHouse.png b/Media/Maps/WitchsHouse.png new file mode 100644 index 0000000..ab57c66 Binary files /dev/null and b/Media/Maps/WitchsHouse.png differ diff --git a/Media/Maps/WorldMap-HandDrawn.png b/Media/Maps/WorldMap-HandDrawn.png new file mode 100644 index 0000000..45ca05d Binary files /dev/null and b/Media/Maps/WorldMap-HandDrawn.png differ diff --git a/Media/Maps/WorldMap-InGame.png b/Media/Maps/WorldMap-InGame.png new file mode 100644 index 0000000..e72cea1 Binary files /dev/null and b/Media/Maps/WorldMap-InGame.png differ diff --git a/Media/Maps/WorldMap-Rendered.png b/Media/Maps/WorldMap-Rendered.png new file mode 100644 index 0000000..d07ebe8 Binary files /dev/null and b/Media/Maps/WorldMap-Rendered.png differ diff --git a/Media/Screenshots/FGB-01-Starfield.png b/Media/Screenshots/FGB-01-Starfield.png new file mode 100644 index 0000000..990d3ef Binary files /dev/null and b/Media/Screenshots/FGB-01-Starfield.png differ diff --git a/Media/Screenshots/FGB-02-Appomattox.png b/Media/Screenshots/FGB-02-Appomattox.png new file mode 100644 index 0000000..6c8a5a1 Binary files /dev/null and b/Media/Screenshots/FGB-02-Appomattox.png differ diff --git a/Media/Screenshots/FGB-03-Pansies.png b/Media/Screenshots/FGB-03-Pansies.png new file mode 100644 index 0000000..c3bee0e Binary files /dev/null and b/Media/Screenshots/FGB-03-Pansies.png differ diff --git a/Media/Screenshots/FGB-04-Hive.png b/Media/Screenshots/FGB-04-Hive.png new file mode 100644 index 0000000..8b27b91 Binary files /dev/null and b/Media/Screenshots/FGB-04-Hive.png differ diff --git a/Media/Screenshots/FGB-05-River.png b/Media/Screenshots/FGB-05-River.png new file mode 100644 index 0000000..5f17be9 Binary files /dev/null and b/Media/Screenshots/FGB-05-River.png differ diff --git a/Media/Screenshots/FGB-06-BA.png b/Media/Screenshots/FGB-06-BA.png new file mode 100644 index 0000000..539b5c2 Binary files /dev/null and b/Media/Screenshots/FGB-06-BA.png differ diff --git a/Media/Screenshots/FGB-07-BS.png b/Media/Screenshots/FGB-07-BS.png new file mode 100644 index 0000000..8b68c48 Binary files /dev/null and b/Media/Screenshots/FGB-07-BS.png differ diff --git a/Media/Screenshots/FGB-08-Haiku.png b/Media/Screenshots/FGB-08-Haiku.png new file mode 100644 index 0000000..434cf01 Binary files /dev/null and b/Media/Screenshots/FGB-08-Haiku.png differ diff --git a/Media/Screenshots/FGB-09-War.png b/Media/Screenshots/FGB-09-War.png new file mode 100644 index 0000000..d8ce33c Binary files /dev/null and b/Media/Screenshots/FGB-09-War.png differ diff --git a/Media/Screenshots/FGB-10-Crouton.png b/Media/Screenshots/FGB-10-Crouton.png new file mode 100644 index 0000000..73b263a Binary files /dev/null and b/Media/Screenshots/FGB-10-Crouton.png differ diff --git a/Media/Screenshots/FGB-11-LevelEditor1.png b/Media/Screenshots/FGB-11-LevelEditor1.png new file mode 100644 index 0000000..3ba824f Binary files /dev/null and b/Media/Screenshots/FGB-11-LevelEditor1.png differ diff --git a/Media/Screenshots/FGB-12-LevelEditor2.png b/Media/Screenshots/FGB-12-LevelEditor2.png new file mode 100644 index 0000000..c1c7d8d Binary files /dev/null and b/Media/Screenshots/FGB-12-LevelEditor2.png differ diff --git a/Media/Screenshots/FGB-13-TileConverter.png b/Media/Screenshots/FGB-13-TileConverter.png new file mode 100644 index 0000000..52c7d7f Binary files /dev/null and b/Media/Screenshots/FGB-13-TileConverter.png differ diff --git a/Media/Screenshots/GBConv2.png b/Media/Screenshots/GBConv2.png new file mode 100644 index 0000000..e1d7c0f Binary files /dev/null and b/Media/Screenshots/GBConv2.png differ diff --git a/Media/Screenshots/LevelEditor.png b/Media/Screenshots/LevelEditor.png new file mode 100644 index 0000000..d96c816 Binary files /dev/null and b/Media/Screenshots/LevelEditor.png differ diff --git a/Media/Splash.jpeg b/Media/Splash.jpeg new file mode 100644 index 0000000..842124b Binary files /dev/null and b/Media/Splash.jpeg differ diff --git a/Media/Wallpaper/BA_Whatever.png b/Media/Wallpaper/BA_Whatever.png new file mode 100644 index 0000000..1052554 Binary files /dev/null and b/Media/Wallpaper/BA_Whatever.png differ diff --git a/Media/Wallpaper/CroutonGang.png b/Media/Wallpaper/CroutonGang.png new file mode 100644 index 0000000..4e44b22 Binary files /dev/null and b/Media/Wallpaper/CroutonGang.png differ diff --git a/Media/Wallpaper/FlourAndFlower.png b/Media/Wallpaper/FlourAndFlower.png new file mode 100644 index 0000000..cf77c98 Binary files /dev/null and b/Media/Wallpaper/FlourAndFlower.png differ diff --git a/Media/Wallpaper/originals/ba.png b/Media/Wallpaper/originals/ba.png new file mode 100644 index 0000000..c5cee82 Binary files /dev/null and b/Media/Wallpaper/originals/ba.png differ diff --git a/Media/Wallpaper/originals/croutons.png b/Media/Wallpaper/originals/croutons.png new file mode 100644 index 0000000..1b5f180 Binary files /dev/null and b/Media/Wallpaper/originals/croutons.png differ diff --git a/Media/Wallpaper/originals/flower and flour.png b/Media/Wallpaper/originals/flower and flour.png new file mode 100644 index 0000000..12546c2 Binary files /dev/null and b/Media/Wallpaper/originals/flower and flour.png differ diff --git a/README.md b/README.md index 0f53098..a00f422 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,95 @@ -# FGB -The full project source for FGB, a Game Boy Color game developed in 2000 +![FGB](Media/Logo/Logo.png) + +A weird and wonderful action odyssey for Game Boy Color. Developed in 2000 by Abe Pralle and Jacob Stevens. Playable and fairly complete but not fully finished. + +![Preview Video](Media/FGBPreview.gif) + +About | Current Release +--------------|----------------------- +Version | 1.1 +Date | 2022.01.07 +Target | Game Boy Color +Build | macOS, Windows, Linux +Tools/Editors | Windows +Licenses | MIT (source code) and Creative Commons (IP) - see the [LICENSE](LICENSE). + +## ROM +The pre-compiled FGB ROM for Game Boy Color is [here](ROMS/fgb.gb). + +It can be run on emulators such as [SameBoy](https://sameboy.github.io). Note: the "battery save" feature does not seem to work correctly on SameBoy at least. Use emulator save states instead. + +## Developers +- Abe Pralle (programming, level design, dialog) grew up on the Commodore 64 but was too young to develop for it. He embraced the "second chance" of creating an 8-bit game for the Game Boy Color in the late 1990's. His current passion project is a programming language called [Rogue](https://github.com/AbePralle/Rogue). +- Jacob Stevens (art, music) is a long-time Nintendo fan and similarly loved the idea of developing for Game Boy Color. These days he and his brother Paul Stevens are a dynamic duo developing games as [Riverman Media](https://rivermanmedia.com). + +## Building from Source +1. Install the Rogue language from here to take advantage of the Rogo build system: + - [https://github.com/AbePralle/Rogue](https://github.com/AbePralle/Rogue) +2. Install the RGBDS assembler: + - [https://github.com/rednex/rgbds](https://github.com/rednex/rgbds) +3. Run `rogo` in this project's base folder. + +## Tools +- Each of the following tools is provided as a precompiled Windows `exe` along with their original source code. +- These `exe` files were last compiled circa 2000. No attempt has been made to update their project source. The Level Editor and Image Converter `exe`'s are both confirmed to work on Windows 10. +- During its original development, FGB was essentially a single folder containing hundreds of files. Because of this, each tool typically expects its data files to be in the same folder as the tool itself. +- This project has now been reorganized to cleanly separate original assets, converted data, and source code into separate folders. +- As such data files will generally need to be moved into each tool folder as inputs and the results moved back to the appropriate location if the editors are used. +- Ideally at some point Abe Pralle or a contributor will update the editor projects to be in a modern Visual Studio format and adjust the input and output locations to utilize the current folder structure. + +### LevelEditor + +![Level Editor](Media/Screenshots/LevelEditor.png) + +1. Refer to `Media/Levels/` to identify levels you want to edit. +2. Copy corresponding `Data/Levels/*.lvl` files to `Tools/LevelEditor`. +3. Run `Tools/LevelEditor`, load, edit, and save the levels. +4. Copy the modified levels back to `Data/Levels/`. + +### GBConv2 + +![GBConv2](Media/Screenshots/GBConv2.png) + +- GBConv2 loads BMP images and converts them to tiles and/or sprites. + +### Game Boy Sound Manipulator + +The [Game Boy Sound Manipulator](https://github.com/AbePralle/GameBoySoundManipulator) is a tool in a separate repository that allows developers to experiment with sound parameters in real time. It was used extensively in the creation of FGB. + +### MakeGBM + +**MakeGBM** compiles programmatic music `.gbm` source files into data files for the FGB engine. + +### MakeDiscoLights + +**MakeDiscoLights** is a simple program that generates data files for the "mirror ball disco lights" of the "Duke's Disco" level. + +### MapMaker + +**MapMaker** reads `.lvl` data files and uses them to generate PNG images of various level and maps. All of the content it generates has already been added to this repo as `Media/Levels` and `Media/Maps`. + +## Developer Notes + +### Origins +1. FGB was started in 1999 by college friends Abe Pralle, Jacob Stevens, and Martin Casado (pronounced "Mar-teen"). It was very loosely based on a game called "Flour" that Martin had created with input and art from Abe. The new game was designed for Game Boy Color due to Jacob's fondness for Nintendo and so they called it "Flour Game Boy" or "FGB". Martin helped set up the initial story and the wacky world, but he soon got too busy with school and bowed out of the project. +2. FGB and Flour were both partly inspired by [Crossroads](https://lparchive.org/Computes-Gazette/Update%2005/) for the Commodore 64, a type-in game that was one of the finest ever published in *COMPUTE!'s Gazette* magazine. + +### Story +1. Martin's original indie game filled the title screen with flowers and then presented the game title: "Flour". It was purely a visual pun that had no bearing on the game. +2. FGB was initially going to begin with the Appomattox en route to the Crouton Homeworld, the encounter with Lady Flower being attacked by the Space Gang, and landing on Planet Kiwi. The introductory sequences would all be cinematics and then upon landing on Kiwi you would immediately be able to pick any of the three playable characters at will (BA, Haiku, BS). +3. We had a good first chunk of the game implemented when we decided that we should have a prelude that introduces those main characters one at a time so players can get a feel for each of them. That's when we created the "Moon Base" levels. By that time we'd really nailed down our process and evolved our engine, so we were able to make those levels quickly and with a lot of polish and impressive features. This order of development was happenstance but it worked out beautifully. A resulting rule of thumb is: don't make the first part of the game first; make the middle part first so that you can come back and do your best work on the first part. +4. Major Skippy was originally an anthropomorphic bone with the allusion being that he was "bone-headed". The idea sounded good in theory but after the art was finished it was quickly apparent that his general shape was too phallic. We changed him to an unlit candle instead which only required changes to the top of his head in cinemas, allowing us to keep the facial expressions that had already been completed. +5. The fast-firing monkeys are a nod to the dangerous Brown Monkeys in *Crossroads I & II*, just a few of which can easily [dominate all other opponents](https://youtu.be/ibzePnoOHOQ?t=574). The leader and hero of the FGB monkeys is Duke, a one-armed orangutan. +6. The current version of the game ends on a cliffhanger as our heroes return from Space Station Apocalypse. Check out [Media/DesignDocs/TopLevelStoryScript.pdf](Media/DesignDocs/TopLevelStoryScript.pdf) to see the broad outlines of the ending we had planned. + +### Technical +1. FGB has full two-player support via link cable. It is very fast, unlike the use of link cable in most Game Boy games. +2. Game Boy has famously slow link cable data transfer. The reason is that when one Game Boy transmits a byte to another over the link cable, the receiver is notified that a byte was received but there is no return acknowledgement; no way for the sender to know that the byte was received. So most games would transmit information by sending only one or a few bytes per second; a long enough interval to ensure that the other Game Boy had received each byte before sending another. +3. FGB got around this limitation by having the sender and receiver continuously swap roles and transmit single bytes to each other as fast as possible. So the sender sends a byte and then implicitly becomes a receiver and waits to receive a byte. The receiver receives a byte and then immediately acts as a sender and sends a byte back. Sender control flip-flops in this way constantly whether or not any actual data is being sent. If Abe's memory serves, a chunk of data or "message" is transmitted as a size byte and then as one byte at a time every time the control flip-flops, with the receiver implicitly collecting a set of bytes and then acting on them. +4. FGB uses a very simple but effective algorithm for generating random numbers whenever it needs them. A desktop program shuffled byte values 0-255 into a random order and then those bytes are compiled in as a look-up table. Whenever a random byte is requested, the system just reads the next byte from the table, wrapping around. +5. FGB's levels (and level editor) support a relatively sophisticated zone-based pathfinding system. The designer highlights areas of the map as zones and can then draw waypoint-based paths between zones. It sounded good in theory and worked well technically speaking, but it diminished the gameplay rather than improving it. Levels (or screens) just became too hard and frustrating when every enemy would immediately start pathfinding its way toward you. Only the first landing zone at (1,7) uses enemy pathfinding, as it was the first level we made, and then we rarely or never used it again. Enemies use a simple algorithm that works well. It's something like: move toward the player if possible; if blocked, walk right X steps while trying to move forward; if still blocked, move 2X steps to the left while trying to move forward; if still blocked, move in a random direction for X steps. +6. FGB had a digitized sound sample for eating food (an "Mmmm" with lip-smacking). Conventional wisdom would have us playing the sound over Sound Channel 3 that supports a custom wave form. However, we figured out an alternate way to do it that didn't use up an instrument voice: we played 3-bit sound by setting the Game Boy's master sound volume (at `FF24`) to be 0-7 according to each sample. It didn't diminish the other music or sound effects and the digitized sound was significantly louder than it would have been playing on Channel 3. + +### Fate +Jacob and Abe were both passionate indie game devs but had no industry contacts. They attended E3 2000 with a nice demo of FGB and pitched it to various publishers. After failing to find a publisher at E3 or over the next few months, they finally threw in the FGB towel in late 2000 or early 2001 and released it as freeware for anyone to enjoy. + diff --git a/ROM/FGB.gb b/ROM/FGB.gb new file mode 100644 index 0000000..3a5478c Binary files /dev/null and b/ROM/FGB.gb differ diff --git a/Source/Cinema.asm b/Source/Cinema.asm new file mode 100644 index 0000000..2726405 --- /dev/null +++ b/Source/Cinema.asm @@ -0,0 +1,1693 @@ +;------------------------------------------------------------------------ +; Cinema.asm +; 1-5-2000 by Martin Casado +; 4.27.2000 by Abe Pralle +; +; Description: Routines to handle drawing and minipulating cinema +; tiles and sprites +; +; Contents: +; LoadCinemaBG +; LoadCinemaSprite +; LoadCinemaTextBox +;------------------------------------------------------------------------ + +INCLUDE "Source/Defs.inc" + +FIRST_TEXTBOX_TILE EQU 136 + +SECTION "Cinema",ROM0 + +;--------------------------------------------------------------------- +; Routine: LoadCinemaBG +; Arguments: a - bank containing data +; hl - addr of .bg data to load +; Alters: af +; Description: Uses DMA to load in new tile patterns, then loads +; in tile layout data into tileShadowBuffer and +; attributeShadowBuffer +;--------------------------------------------------------------------- +LoadCinemaBG:: + push bc + push de + push hl + + ld de,$9000 + call LoadTileDefs + + ld a,[hl+] + ld [mapWidth],a + + ld b,a + ld a,1 +.findPitch + rlca + cp b + jr c,.findPitch + ld [mapPitch],a + + ld a,[hl+] + ld [mapHeight],a + + call SetupMapVarsFromWidthPitchAndHeight + push hl + ld hl,mapMaxLeft + inc [hl] + ld hl,mapMaxTop + inc [hl] + pop hl + + ;load tile indices + ld a,TILESHADOWBANK + ld [$ff70],a + + call CinemaCommonClearBank + + ld de,tileShadowBuffer + + ld a,[mapHeight] + ld b,a + +.tileIndexOuter + ld a,[mapWidth] + ld c,a + +.tileIndexInner + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.tileIndexInner + + ;skip remaining pitch + call CinemaCommonSkipPitch + + dec b + jr nz,.tileIndexOuter + + + ;load tile attributes (packed 2:1 per byte) + ld a,ATTRSHADOWBANK + ld [$ff70],a + + call CinemaCommonClearBank + + ld de,attributeShadowBuffer + + ld a,[mapHeight] + ld b,a + +.tileAttrOuter + ld a,[mapWidth] + srl a + ld c,a + +.tileAttrInner + ld a,[hl+] + push af + swap a + and %00001111 + ld [de],a + inc de + pop af + and %00001111 + ld [de],a + inc de + dec c + jr nz,.tileAttrInner + + ;skip remaining pitch + call CinemaCommonSkipPitch + + dec b + jr nz,.tileAttrOuter + + ld a,0 + call LoadCinemaPalette + +.done + ld a,OBJROM + call SetActiveROM + + call PrepareForInitialMapDraw + + ;call VWait + ld a,1 ;necessary though I'm not sure why!! + call Delay + + pop hl + pop de + pop bc + ret + +CinemaCommonClearBank: + push hl + ld hl,map +.clearBankLoop + xor a + ld [hl+],a + ld a,h + cp $e0 + jr c,.clearBankLoop + + pop hl + ret + +CinemaCommonSkipPitch: + push hl + ld a,[mapSkip] + ld l,a + ld h,0 + add hl,de + ld d,h + ld e,l + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: LoadCinemaSprite +; Arguments: a - bank containing data +; hl - addr of .sp data to load +; Alters: af +; Description: Uses DMA to load in new sprite patterns, then loads +; in metasprite layout data into spriteOAMBuffer +;--------------------------------------------------------------------- +LoadCinemaSprite:: + push bc + push de + push hl + + ld de,$8000 + call LoadTileDefs + + ;switch to 8x16 sprites + ld a,[$ff40] + or %00000100 + ld [$ff40],a + + ;load oam definitions + inc hl ;discard width, pitch, and height + inc hl + inc hl + + ld a,[hl+] ;num sprites + ld c,a + +.loadSprite + call AllocateSprite + cp $ff + jr z,.noSpritesLeft + + ld d,((spriteOAMBuffer>>8) & $ff) + ld e,a + ld a,[hl+] ;y position + ld [de],a + inc de + ld a,[hl+] ;x position + ld [de],a + inc de + ld a,[hl+] ;tile index + ld [de],a + inc de + ld a,[hl+] ;attributes + ld [de],a + + dec c + jr nz,.loadSprite + jr .loadPalette + + +.noSpritesLeft + inc hl + inc hl + inc hl + inc hl + dec c + jr nz,.noSpritesLeft + +.loadPalette + ld a,64 + call LoadCinemaPalette + +.done + ld a,OBJROM + call SetActiveROM + + ;necessary (for loadbg) though I'm not sure why!! + call VWait + ;ld a,1 + ;call Delay + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: LoadTileDefs +; Arguments: a - bank containing data +; de - starting location to load tile patterns into, +; e.g. $9000 for backgrounds or $8000 for sprites. +; hl - addr of .bg or .sp data to load +; Alters: af, hl +; Description: Does some setup work for either Cinema backgrounds OR +; Cinema sprites then uses DMA to load in new tile or +; sprite patterns +;--------------------------------------------------------------------- +LoadTileDefs: + push bc + push de + + call SetActiveROM + ld a,1 + ld [displayType],a + + ;replace HBlank handler if default one + ld a,[hblankVector+1] + cp (OnHBlank & $ff) + jr nz,.afterInstallHandler + ld a,[hblankVector+2] + cp ((OnHBlank>>8) & $ff) + jr nz,.afterInstallHandler + +.replaceHandler + push hl + ld hl,CinemaOnHBlank + call InstallHBlankHandler + pop hl +.afterInstallHandler + + ;xor a + ;ld [levelCheckSkip],a + ;ld [levelCheckSkip+1],a + + ;ensure VBlank interrupt is enabled and interrupts are enabled + ldio a,[$ffff] + or %11 + ldio [$ffff],a + ei + + ;turn LCD on + ld a,[$ff40] + or a,%11000011 + ld [$ff40], a ;lcdc control + + ;indicate we've settled in + xor a + ld [amChangingMap],a + + ld a,[hl+] ;bank zero tiles exist? + or a + jr z,.checkBank1Tiles + + ld a,[hl+] ;number of bank zero tiles + ld b,a + call .copyTilesToMapRAM ;copy to buffer to ensure alignment + xor a + call .loadTiles + +.checkBank1Tiles + ld a,[hl+] ;bank one tiles exist? + or a + jr z,.loadLayout + ld a,[hl+] ;number of bank one tiles + ld b,a + call .copyTilesToMapRAM ;copy to buffer to ensure alignment + ld a,1 + call .loadTiles + +.loadLayout + ;switch back to VRAM bank 0 + xor a + ld [$ff4f],a + + pop de + pop bc + ret + +.copyTilesToMapRAM + push de + push bc + + ld a,MAPBANK + ld [$ff70],a + ld de,map + +.copyTilesOuter + ld c,16 + +.copyTilesInner + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.copyTilesInner + + dec b + jr nz,.copyTilesOuter + + pop bc + pop de + ret + +.loadTiles + ;load sets of 64 tiles and then leftover + push bc + push de + push hl + push af ;save bank + + ld hl,map + +.continueLoadTiles + ld a,b + or a ;zero equivalent to 256 in this case + jr z,.gt_64_bank + cp 65 ;<=64 tiles left? + jr nc,.gt_64_bank + + ld c,b ;# of tiles IS # of sets of 16 + jr .got_loadsize + +.gt_64_bank + ld c,64 ;load 64 tiles + +.got_loadsize + pop af ;retrieve bank + push af ;save bank again + call DMALoad + + ;push bc + ;push de + ;push hl + ;call GetInput + ;pop hl + ;pop de + ;pop bc + + ;subtract from count tiles we took care of + ld a,b + sub c + jr z,.loadTilesDone + ld b,a + + ;advance source + push de + ld de,1024 + add hl,de + pop de + + ;advance destination + push hl + ld hl,1024 + add hl,de + ld d,h + ld e,l + pop hl + + ;if >= $9800 then wrap to $8800 + ld a,d + cp $98 + jr c,.continueLoadTiles + + sub $10 + ld d,a + + jr .continueLoadTiles + +.loadTilesDone + pop af + pop hl + pop de + pop bc + + ret + +;--------------------------------------------------------------------- +; Routine: LoadCinemaPalette +; Arguments: a - byte offset to load into (e.g. 0 for tile +; palette, 64 for sprite palette, 56 for text box +; palette) +; (32-63) +; hl - addr of palette data to load (expecting +; spec, lobyte, hibyte triplets) +; Alters: af, hl +; Description: Loads the specified palette into GamePalette using +; the spec byte to calculate where to store +;--------------------------------------------------------------------- +LoadCinemaPalette: + push bc + push de + + ld b,a ;b is offset for bg or sprite palette + ld a,FADEBANK + ld [$ff70],a + + ;load palette into [gamePalette] + ld a,[hl+] ;num colors + ld c,a + +.loadPalette + ld d,((gamePalette>>8) & $ff) + ld a,[hl+] ;read spec & determine correct pos + and 63 + add b + add (gamePalette & $ff) + ld e,a + + ld a,[hl+] ;low byte of color + ld [de],a + inc de + ld a,[hl+] ;high byte of color + ld [de],a + inc de + dec c + jr nz,.loadPalette + + pop de + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: LoadCinemaTextBox +; Arguments: a - bank containing data +; hl - addr of .bg data to load +; Alters: af +; Description: Loads in normal BG file with the following +; alterations: +; - tile map size should be 20x6 +; - loads tile defs to $8880 e.g. 136-255 (overwriting +; font) +; - adds 136 to each tile index +; - loads the tile map to $9c00 +; - palette is loaded to gamePalette colors 28-31 +; regardless +; - of original index values +;--------------------------------------------------------------------- +LoadCinemaTextBox:: + push bc + push de + push hl + + ld de,$8880 + call LoadTileDefs + + ld a,[hl+] ;discard tile width (should be 20) + ld a,[hl+] ;discard tile height (should be 6) + + ;load tile indices + ld de,backBuffer + + ld b,6 ;height loop + +.tileIndexOuter + ld c,20 ;width loop + +.tileIndexInner + ld a,[hl+] + add a,FIRST_TEXTBOX_TILE + ld [de],a + inc de + dec c + jr nz,.tileIndexInner + + ;skip remaining pitch (32-20 = 12) + push hl + ld hl,12 + add hl,de + ld d,h + ld e,l + pop hl + + dec b + jr nz,.tileIndexOuter + + + ;load tile attributes (packed 2:1 per byte) + ld de,attributeBuffer + + ld b,6 ;height loop + +.tileAttrOuter + ld c,10 ;width loop (20 tiles / 2 attr per tile) + +.tileAttrInner + ld a,[hl+] + push af + swap a + and %00001111 + or %00000111 ;make palette 7 + ld [de],a + inc de + pop af + and %00001111 + or %00000111 ;make palette 7 + ld [de],a + inc de + dec c + jr nz,.tileAttrInner + + ;skip remaining pitch (32-20 = 12) + push hl + ld hl,12 + add hl,de + ld d,h + ld e,l + pop hl + + dec b + jr nz,.tileAttrOuter + + ld a,56 ;load palette 0 as palette 7 (colors 0-3 to 28-31) + call LoadCinemaPalette + +.done + ld a,OBJROM + call SetActiveROM + + call GfxBlitBackBufferToWindow + + ;necessary (for loadbg) though I'm not sure why!! + call VWait + ;ld a,1 ;necessary (for loadbg) though I'm not sure why!! + ;call Delay + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CinemaBlitRect +; Arguments: bc - tile width, height to copy +; de - dest tile (i,j) to blit to +; hl - source tile (i,j) to blit from +; Alters: af +; Description: Copies tiles from the tileShadowBuffer and the +; attributeShadowBuffer from one place to another +;--------------------------------------------------------------------- +CinemaBlitRect:: + push bc + push de + push hl + + ;get destination address (tileShadowBuffer + j*pitch + i) + push hl + ld h,d + ld l,e + call ConvertXYToLocHL + ld d,h + ld e,l + pop hl + + ;get start address + call ConvertXYToLocHL + + ;blit the tile indices + ld a,TILESHADOWBANK + ld [$ff70],a + call .blitSubroutine + + ;switch to attributes and copy those too + ld a,ATTRSHADOWBANK + ld [$ff70],a + call .blitSubroutine + + pop hl + pop de + pop bc + ret + +.blitSubroutine + ;hl source, de dest, bc width & height + push bc + push de + push hl + +.outer ;copy a row + push bc ;save width & height + push hl ;save source start + push de ;save dest start + +.inner ;copy a byte + ld a,[hl+] + ld [de],a + inc de + dec b + jr nz,.inner + + pop de ;retrieve dest start & add pitch to it + ld h,0 + ld a,[mapPitch] + ld l,a + add hl,de + ld d,h + ld e,l + + pop hl ;retrieve source start & add pitch to it + push de + ld d,0 + ld e,a ;a set above + add hl,de + pop de + + pop bc ;retrieve width & height + dec c ;one more row taken care of + jr nz,.outer + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CinemaSpotAnimationRandomHorizontalFrames +; Arguments: a - number of possible frames +; bc - metatile width, height to copy +; de - dest metatile (i,j) to blit to +; hl - corner of first source metatile (i,j) blit from +; Alters: af +; Description: Picks a new random frame and blits it to the image. +;--------------------------------------------------------------------- +CinemaSpotAnimationRandomHorizontalFrames:: + push bc + push hl + + ;pick a random frame + dec a + call GetRandomNumZeroToN + + ;scoot source over by (numframe * width of one frame) + push bc + ld c,a + xor a +.timesWidth + add b + dec c + jr nz,.timesWidth + add h + ld h,a + pop bc + + call CinemaBlitRect + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CinemaSpotAnimationRandomVerticalFrames +; Arguments: a - number of possible frames +; bc - metatile width, height to copy +; de - dest metatile (i,j) to blit to +; hl - corner of first source metatile (i,j) blit from +; Alters: af +; Description: Picks a new random frame and blits it to the image. +;--------------------------------------------------------------------- +CinemaSpotAnimationRandomVerticalFrames:: + push bc + push hl + + ;pick a random frame + dec a + call GetRandomNumZeroToN + + ;scoot source down by (numframe * height of one frame) + push bc + ld b,a + xor a +.timesWidth + add c + dec b + jr nz,.timesWidth + add l + ld l,a + pop bc + + call CinemaBlitRect + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routines: StdWaitDialog +; StdWaitDialogNoClear +; Arguments: a - desired next state after dialog +; Alters: af,hl +;--------------------------------------------------------------------- +StdWaitDialogNoClear:: + push hl + ld hl,dialogSettings + set DLG_NOCLEAR_BIT,[hl] + pop hl +StdWaitDialog:: + ld a,h + ldio [mapState+1],a + ld a,l + ldio [mapState],a + call SaveIdle + ret + +;--------------------------------------------------------------------- +SECTION "CharacterAnimationCode",ROMX +;--------------------------------------------------------------------- + +;--------------------------------------------------------------------- +; Routines: AnimateSkippy +; AnimateFlour +; AnimateFlourDriving +; AnimateBA +; AnimateBS +; AnimateHaiku +; AnimateBRAINIAC +; Arguments: d - duration (roughly d*100 60ths or d*1.6 sec) +;--------------------------------------------------------------------- +AnimateSkippy:: + ld b,d +.skippyEyes + ld c,10 + +.skippyTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 3 + ld a,3 + jr nc,.animateSkippyMouth + ld a,1 + +.animateSkippyMouth + ;animate mouth + ld bc,$0402 + ld de,$0609 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.skippyTalk + + ;animate eyes + push bc + ld a,5 + ld bc,$0403 + ld de,$0606 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.skippyEyes + + ;open eyes at end + ld a,1 + ld bc,$0403 + ld de,$0606 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateFlour:: + ld b,d +.flourEyes + ld c,10 + +.flourTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 1 + ld a,4 + jr nz,.animateFlourMouth + ld a,1 + +.animateFlourMouth + ;animate mouth + ld bc,$0502 + ld de,$0906 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.flourTalk + + ;animate eyes + push bc + ld a,3 + ld bc,$0603 + ld de,$0903 + ld hl,$1900 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.flourEyes + + ;open eyes at end + ld a,1 + ld bc,$0603 + ld de,$0903 + ld hl,$1900 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateFlourDriving:: + ld b,1 +.flourEyes + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.flourTalk + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,6 + jr nz,.animateFlourMouth + ld a,1 + +.animateFlourMouth + ;animate mouth + ld bc,$0604 + ld de,$0703 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.flourTalk + + dec b + jr nz,.flourEyes + + ;open eyes at end + ld a,1 + ld bc,$0604 + ld de,$0703 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + ld a,10 + call Delay + ret + +AnimateBA:: + ld b,1 + + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.baEyes + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,3 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0702 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.baEyes + + ;open eyes at end + ld a,1 + ld bc,$0702 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateBS:: + ld b,1 + + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.bsEyes + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,3 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0401 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.bsEyes + + ;open eyes at end + ld a,1 + ld bc,$0401 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateHaiku:: + ld b,21 +.haikuHand + ld c,2 + +.haikuTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 1 + ld a,4 + jr nz,.animateHaikuMouth + ld a,1 + +.animateHaikuMouth + ;animate mouth + ld bc,$0404 + ld de,$0605 + ld hl,$1408 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.haikuTalk + + ;animate hand + push bc + ld a,21 + sub b ;frame of hand (1-21) + cp 6 + jr c,.handFrameSet ;1st line 0-5 + sub 6 + cp 6 + jr c,.handFrameSet ;2nd line 0-5 + sub 5 + cp 3 + jr c,.handFrameSet ;2nd line 1-2 + sub 3 + cp 6 + jr c,.handFrameSet ;3rd line 0-5 + xor a ;final, done +.handFrameSet + ;times six + rlca ;times 2 + ld b,a ;b = a*2 + rlca ;times 2 again (a0 * 4) + add b ;a*6 = a*2 + a*4 + add 20 + ld h,a + ld l,0 + ld bc,$0608 + ld de,$0e04 + call CinemaBlitRect + pop bc + dec b + jr nz,.haikuHand + + ld a,40 + call Delay + + ret + +AnimateBRAINIAC:: + ld b,d +.brainiacEyes + ld c,10 + +.brainiacTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 1 + ld a,2 + jr nz,.animate + ld a,1 + +.animate + ;animate mouth + ld bc,$0402 + ld de,$0908 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.brainiacTalk + + ;animate eyes + push bc + ld a,4 + ld bc,$0702 + ld de,$0604 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.brainiacEyes + ret + +AnimateLadyFlower:: + ld b,d +.eyes + ld c,10 + +.talk + push bc + ld a,5 +.animateBeeLoop + call .animateBee + dec a + jr nz,.animateBeeLoop + + ld a,b + cp 1 + ld a,2 + jr nz,.animate + ld a,1 + +.animate + ;animate mouth + ld bc,$0101 + ld de,$0a06 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.talk + + ;animate eyes + push bc + ld a,3 + ld bc,$0302 + ld de,$0904 + ld hl,$1500 + call CinemaSpotAnimationRandomVerticalFrames + + ;animate bg flowers + ld a,2 + ld bc,$0302 + ld de,$0008 + ld hl,$1406 + call CinemaSpotAnimationRandomVerticalFrames + + ld a,2 + ld bc,$0202 + ld de,$0508 + ld hl,$140a + call CinemaSpotAnimationRandomHorizontalFrames + + ld a,2 + ld bc,$0201 + ld de,$020a + ld hl,$140c + call CinemaSpotAnimationRandomHorizontalFrames + + ld a,2 + ld bc,$0202 + ld de,$0f0a + ld hl,$140d + call CinemaSpotAnimationRandomHorizontalFrames + + ld a,2 + ld bc,$0202 + ld de,$1208 + ld hl,$140f + call CinemaSpotAnimationRandomHorizontalFrames + + pop bc + dec b + jr nz,.eyes + ret + +VAR_BEEPOS EQU 0 +.animateBee + push af + push bc + push hl + + ld a,1 + call Delay + + ;bee y position + ld a,[levelVars + VAR_BEEPOS] + add 2 + ld [levelVars + VAR_BEEPOS],a + cp 128 + jr c,.beeDirectionChosen + ld b,a ;a = 255 - a + ld a,255 + sub b +.beeDirectionChosen + sub 64 + rlca ;get sign bit in bit 7 + sra a + sra a + sra a + sra a + + ;adjust y coord + ld hl,spriteOAMBuffer + add 40 + ld [hl],a + ld hl,spriteOAMBuffer+4 + ld [hl],a + + ;adjust animation frame + ldio a,[updateTimer] + rlca + rlca + and %100 + ld hl,spriteOAMBuffer + 2 + ld [hl],a + inc a + inc a + ld hl,spriteOAMBuffer + 6 + ld [hl],a + + pop hl + pop bc + pop af + + ret + +AnimateLadyFlowerDistress:: + ld a,d + and %10000000 + ld b,a + + ld a,d ;c=d*8 + and %01111111 + rlca + rlca + rlca + ld c,a + +.ladyFace + push bc + + bit 7,b + jr z,.afterJiggle + ld a,%111 + call GetRandomNumMask + or a + jr nz,.afterJiggle + + ld a,15 + ldio [jiggleDuration],a + +.afterJiggle + ld a,8 + call Delay + + ld a,c + cp 1 + ld a,4 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0506 + ld de,$0702 + ld hl,$1500 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.ladyFace + + ;open eyes at end + ld a,1 + ld bc,$0506 + ld de,$0702 + ld hl,$1500 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateLadyFlowerRamp:: + ld b,d +.ladyEyes + ld c,10 + +.ladyTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 2 + ld a,2 + jr nc,.animateLadyMouth + ld a,1 + +.animateLadyMouth + ;animate mouth + ld bc,$0202 + ld de,$0806 + ld hl,$250c + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.ladyTalk + + ;animate eyes + push bc + ld a,4 + ld bc,$0403 + ld de,$0703 + ld hl,$2500 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.ladyEyes + + ;open eyes at end + ld a,1 + ld bc,$0403 + ld de,$0703 + ld hl,$2500 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateCaptainRamp:: + ld b,d +.flourEyes + ld c,10 + +.flourTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 2 + ld a,4 + jr nc,.animateFlour + ld a,1 + +.animateFlour + ;animate mouth + ld bc,$0402 + ld de,$1312 + ld hl,$2009 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.flourTalk + + ;animate eyes + push bc + ld a,3 + ld bc,$0503 + ld de,$130f + ld hl,$2000 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.flourEyes + + ;open eyes at end + ld a,1 + ld bc,$0503 + ld de,$130f + ld hl,$2000 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateCaptainGunpoint:: + ld a,d + rlca ;frames *8 + rlca + ld b,a +.flourEyes + ld c,3 + +.flourTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 8 + ld a,2 + jr nc,.animateFlour + ld a,1 + +.animateFlour + ;animate mouth + ld bc,$0402 + ld de,$0c06 + ld hl,$1402 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.flourTalk + + ;animate eyes + push bc + ld a,2 + ld bc,$0602 + ld de,$0b04 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec b + jr nz,.flourEyes + + ;open eyes at end + ld a,1 + ld bc,$0602 + ld de,$0b04 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + ld a,10 + call Delay + + ret + +AnimatePreacher:: + ld b,1 + + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.preacherEyes + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,2 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0302 + ld de,$0906 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.preacherEyes + + ;open eyes at end + ld a,1 + ld bc,$0302 + ld de,$0906 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateCaptainAtWedding:: + ld b,1 + + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.captainEyes + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,4 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0404 + ld de,$0505 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.captainEyes + + ;open eyes at end + ld a,1 + ld bc,$0404 + ld de,$0505 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +AnimateLadyAtWedding:: + ld b,d +.ladyEyes + ld c,10 + +.ladyTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 2 + ld a,2 + jr nc,.animateLadyMouth + ld a,1 + +.animateLadyMouth + ;animate mouth + ld bc,$0202 + ld de,$0b05 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.ladyTalk + + ;animate eyes + push bc + ld a,2 + ld bc,$0402 + ld de,$0a03 + ld hl,$1404 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.ladyEyes + + ;open eyes at end + ld a,1 + ld bc,$0402 + ld de,$0a03 + ld hl,$1404 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateGyroAtWedding:: + ld b,d + sla b ;b*=4 + sla b +.gyroEyes + ld c,4 + +.gyroTalk + push bc + ld a,3 + call Delay + + ld a,b + cp 8 + ld a,2 + jr nc,.animateGyroMouth + ld a,1 + +.animateGyroMouth + ;animate mouth + ld bc,$0a05 + ld de,$0606 + ld hl,$1800 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.gyroTalk + + ;animate eyes + push bc + ld a,4 + ld bc,$0402 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.gyroEyes + + ;open eyes at end + ld a,1 + ld bc,$0402 + ld de,$0604 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateGyroOnScreen:: + ld b,d + sla b ;b*=4 + sla b +.gyroEyes + ld c,4 + +.gyroTalk + push bc + ld a,3 + call Delay + + ld a,b + cp 8 + ld a,2 + jr nc,.animateGyroMouth + ld a,1 + +.animateGyroMouth + ;animate mouth + ld bc,$0903 + ld de,$0607 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.gyroTalk + + ;animate eyes + push bc + ld a,3 + ld bc,$0301 + ld de,$0705 + ld hl,$1406 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.gyroEyes + + ;open eyes at end + ld a,1 + ld bc,$0301 + ld de,$0705 + ld hl,$1406 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +AnimateBSDriving:: + ld b,1 + + ld a,d ;c=d*10 + rlca + rlca + rlca + add d + add d + ld c,a + +.bsEyes + push bc + ld a,5 + call Delay + + ld a,c + cp 1 + ld a,3 + jr nz,.animateFrames + ld a,1 + +.animateFrames + ;animate mouth + ld bc,$0402 + ld de,$0803 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.bsEyes + + ;open eyes at end + ld a,1 + ld bc,$0402 + ld de,$0803 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +;***WARNING*** Not HOME Section + diff --git a/Source/Class.asm b/Source/Class.asm new file mode 100644 index 0000000..20a3f51 --- /dev/null +++ b/Source/Class.asm @@ -0,0 +1,14437 @@ +;1.2.2000 by Abe Pralle +;functions that compose the 'classes' of FGB. +;Each class begins a vector table of jump instructions. + +;Each method call takes the following inputs: +; c - class index +; de - pointer to object + +;The various methods behave as follows: +; redraw - Draws itself and its tile attributes into the shadowbuffers +; update - performs any required AI +; adjusts its own position within the map + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Start.inc" +INCLUDE "Source/Items.inc" + + +GRENADE_CINDEX EQU 2048+ 12 +WALLCREATURE_CINDEX EQU 2048+ 19 +BEE_CINDEX EQU 2048+ 22 +RECIPROCATOR_POWERUP_CINDEX EQU 2048+ 35 +TRI_CINDEX EQU 2048+ 37 +TRILING_CINDEX EQU 2048+ 39 +BAT_CINDEX EQU 2048+ 45 +BURROWER_CINDEX EQU 2048+ 47 +BURROWER_DIRT_CINDEX EQU 2048+ 49 +DANDELION_CINDEX EQU 2048+ 51 +DANDELIONPUFF_CINDEX EQU 2048+ 52 +SHEEP_CINDEX EQU 2048+ 96 +CHICKEN_CINDEX EQU 2048+ 98 +WOLF_CINDEX EQU 2048+104 +NEANDERTHAL_CINDEX EQU 2048+108 +BOW_CINDEX EQU 2048+146 +CROUTONBULLET_CINDEX EQU 2048+154 +WIZARDBULLET_CINDEX EQU 2048+158 +ARROWBULLET_CINDEX EQU 2048+162 +CROUTONROCKET_CINDEX EQU 2048+164 +COWBOYBULLET_CINDEX EQU 2048+166 +BIGSPIDER_CINDEX EQU 2048+210 +LITTLESPIDER_CINDEX EQU 2048+218 +TCUBE_CINDEX EQU 2048+220 +TCUBE2_CINDEX EQU 2048+224 +B12SOLDIERBULLET_CINDEX EQU 2048+246 +TREEBULLET_CINDEX EQU 2048+253 +STUNNEDWALL_CINDEX EQU 2048+256 +INVISIBLEBAT_CINDEX EQU 2048+258 +SLIME_CINDEX EQU 2048+260 +MONKEY_CINDEX EQU 2048+267 +BANANABULLET_CINDEX EQU 2048+269 +DUKE_CINDEX EQU 2048+271 +PIG_CINDEX EQU 2048+281 +EGG_CINDEX EQU 2048+283 +BLOWER_CINDEX EQU 2048+284 +SLEEPINGMONKEY_CINDEX EQU 2048+286 +BELL_CINDEX EQU 2048+287 +RINGINGBELL_CINDEX EQU 2048+291 +BANANATREE_CINDEX EQU 2048+295 +HERMITINSHELL_CINDEX EQU 2048+301 +CRAB_CINDEX EQU 2048+311 +CRABBURROWING_CINDEX EQU 2048+313 +UBERMOUSE_CINDEX EQU 2048+314 +TURRET_CINDEX EQU 2048+322 +TURRETBULLET_CINDEX EQU 2048+334 +FAKEBA_CINDEX EQU 2048+336 +FAKEBS_CINDEX EQU 2048+338 +FAKEHAIKU_CINDEX EQU 2048+340 +HEROLADY_CINDEX EQU 2048+350 +HEROFLOUR_CINDEX EQU 2048+352 +FLOUR_BULLET_CINDEX EQU 2048+406 +LADY_BULLET_CINDEX EQU 2048+408 + +BA_MAX_HEALTH EQU 20 +BS_MAX_HEALTH EQU 10 +HAIKU_MAX_HEALTH EQU 20 +FLOUR_MAX_HEALTH EQU 40 +LADY_MAX_HEALTH EQU 40 +GRENADE_MAX_HEALTH EQU 30 + +SECTION "ClassTableSection",ROMX +classTable:: ;starts with ptr to FIRSTOBJTILE + ;BG classes + REPT 27 ;0-26 + DW classGenericBG + ENDR + + DW classAppomattoxBG ;27 + + REPT 78 ;28-105 + DW classGenericBG + ENDR + + DW classShiftPlusOneBG ;106 destructable pumpkin + DW classShiftPlusOneBG ;107 destructable pumpkin + DW classShiftPlusOneBG ;108 destructable pumpkin + DW classDestructableBG ;109 destructable pumpkin + + DW classGenericBG ;110 blue thingy + + REPT 9 ;111-119 purple destructable + DW classChangeTo120BG + ENDR + + DW classShiftPlusOneBG ;120 purple destroy stage 1 + DW classShiftPlusOneBG ;121 purple destroy stage 2 + DW classDestructableBG ;122 purple destroy stage 3 + DW classSplitterBG ;123 four-way shot splitter + + REPT 133 ;124-256 + DW classGenericBG + ENDR + + REPT 46 ;257-302 + DW classHiveBG + ENDR + + REPT 588 ;303-890 + DW classGenericBG + ENDR + + DW classNoExplosionBG ;891 grey door + + REPT 181 ;892-1072 + DW classGenericBG + ENDR + + DW classLandingLightsBG ;1073 + + REPT 328 ;1074-1401 + DW classGenericBG + ENDR + + DW classChangeToBigSpiderBG ;TL corner big spider weed + DW classAdjoinWestBG ;big spider weed + DW classAdjoinNorthBG ;big spider weed + DW classAdjoinNorthBG ;big spider weed + DW classChangeToLittleSpiderBG ;small spider weed + + REPT 57 ;1407-1463 + DW classGenericBG + ENDR + + ;1464-1475 destructable shrooms + REPT 12 + DW classDestructableBG + ENDR + + DW classNoExplosionBG ;wall tile + + ;1477-1493 + REPT 17 + DW classGenericBG + ENDR + + ;1494-1511 Destructable foliage + REPT 18 + DW classDestructableBG + ENDR + + DW classEdibleCheeseBG ;1512 edible cheese + DW classCheeseBG ;1513 cheese + DW classCheeseBG ;1514 cheese + DW classCheeseBG ;1515 cheese + DW classCheeseBG ;1516 cheese + DW classCheeseBG ;1517 cheese + DW classCheeseBG ;1518 cheese + DW classCheeseBG ;1519 cheese + DW classCheeseBG ;1520 cheese + DW classCheeseBG ;1521 cheese + DW classCheeseBG ;1522 cheese + DW classCheeseBG ;1523 cheese + DW classCheeseBG ;1524 cheese + DW classCheeseBG ;1525 cheese + DW classCheeseBG ;1526 cheese + DW classCheeseBG ;1527 cheese + DW classCheeseBG ;1528 cheese + DW classCheeseBG ;1529 cheese + DW classCheeseBG ;1530 cheese + DW classCheeseBG ;1531 cheese + DW classCheeseBG ;1532 cheese + DW classInvisibleWallBG ;1533 Invisible Wall + + DW classPorkBG ;1534 Bacon + DW classPorkBG ;1535 Ham + DW classPorkBG ;1536 Sausage + DW classFriedEggBG ;1537 Fried Egg + DW classDrumstickBG ;1538 Drumstick + + ;1539-1571 + REPT 33 + DW classGenericBG + ENDR + + DW classHermitCrabShellBG ;1572 Hermit Crab Shell + DW classBananaBG ;1573 Banana + + ;1574-1642 + REPT 69 + DW classGenericBG + ENDR + + DW classGeneratorBG ;1643 + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG + DW classGeneratorBG ;1651 + + DW classSlugTrailBG ;1652 slug trail + + ;1653-1854 + REPT 202 + DW classGenericBG + ENDR + + ;1855-1874 + DW classDestructableBG + DW classDestructableBG + DW classDestructableBG + DW classDestructableBG + DW classDestructableAdjoinRightBG + DW classDestructableAdjoinLeftBG + DW classDestructableAdjoinRightBG + DW classDestructableAdjoinLeftBG + DW classDestructableAdjoinRightBG + DW classDestructableAdjoinLeftBG + DW classDestructableAdjoinRightBG + DW classDestructableAdjoinLeftBG + DW classDestructableAdjoinBottomBG + DW classDestructableAdjoinTopBG + DW classDestructableAdjoinBottomBG + DW classDestructableAdjoinTopBG + DW classDestructableAdjoinBottomBG + DW classDestructableAdjoinTopBG + DW classDestructableAdjoinBottomBG + DW classDestructableAdjoinTopBG + + ;1875-2042 + REPT 168 + DW classGenericBG + ENDR + + DW classClearanceBG + + ;2044-2047 + REPT 4 + DW classGenericBG + ENDR + + ;FG classes + + ;pansies o+0, +2, +4 + REPT 3 + DW classPansy,0 + ENDR + + DW classBAPlayer,0 ;BA +6 + DW classBSPlayer,0 ;BS +8 + + DW classHaikuPlayer, 0 ;+10 Haiku + + DW classGrenade, 0 ;+12 Grenade + DW classGeneric ;+14 old Stunned Wall Creature (unused) + DW classVacuum, 0 ;+15 vacuum + DW classSlug, 0 ;+17 Slug + DW classWallCreature, 0 ;+19 Wall Creature + DW classSmallBeeHive ;+21 small bee hive + + DW classBee, 0 ;+22 bee + + DW classGeneric ;+24 yinyang + DW classGeneric, 0 ;+25 yin + DW classGeneric, 0 ;+27 yang + DW classScaredie, 0 ;+29 scaredie + DW classChomper, 0 ;+31 big mouth (chomper) + DW classReciprocator, 0 ;+33 purple energy dude lo power + DW classReciprocatorPowerup,0 ;+35 purple dude hi power + DW classTri, 0 ;+37 yellow thing + DW classTriling, 0 ;+39 small yellow thing + DW classTree ;+41 tree + DW classBush ;+42 bush + DW classNeedle,0 ;+43 needle thing + DW classBat, 0 ;+45 bat + DW classBurrower,0 ;+47 burrower + DW classBurrowerDirt,0 ;+49 burrower dirt mound + DW classDandelion ;+51 dandelion + DW classDandelionPuff,0 ;+52 dandelion puff + DW classGeneric,0,0,0,0,0,0,0 ;+54 King Grenade + DW classMouse, 0 ;+62 mouse + DW classPenguin, 0 ;+64 penguin + DW classBIOS,0 ;+66 BIOS soldier + DW classGeneric,0,0,0 ;+68 king snake + DW classCroutonHulk,0,0,0,0,0,0,0 ;+72 crouton hulk + DW classCroutonGrunt, 0 ;+80 crouton grunt + + ;BA Bullet +82 + DW classBABullet, 0 + + ;Pansy Bullet +84 + DW classPansyBullet, 0 + + ;Big Long Laser +86 + DW classBigLongLaser, 0 + + DW classLadyFlower, 0 ;Lady Flower +88 +;DW classBSPlayer,0 ;BS +8 + DW classCaptainFlour, 0 ;Captain Flour +90 + DW classBigBeeHive, 0, 0, 0 ;+92 big bee hive + DW classSheep, 0 ;+96 sheep + DW classChicken, 0 ;+98 chicken + DW classPurpleWisp, 0 ;+100 wisp + DW classQuatrain,0 ;+102 quatrain + DW classWolf, 0 ;+104 ice wolf + DW classSnake, 0 ;+106 snake + DW classNeanderthal, 0 ;+108 neanderthal + DW classGeneric,0,0,0,0,0,0,0 ;+110 genie + DW classCrow,0 ;+118 crow + DW classScarecrow,0,0,0,0,0,0,0 ;+120 scarecrow + DW classTalker, 0 ;+128 hermit + DW classTalker, 0 ;+130 grey hermit + DW classGeneric, 0 ;+132 red villager + DW classGeneric, 0 ;+134 blue villager + DW classAlligator,0,0,0,0,0,0,0 ;+136 alligator + DW classScorpion, 0 ;+144 scorpion + DW classBow,0 ;+146 archer + DW classCowboy, 0 ;+148 blue villager + DW classCowboy, 0 ;+150 brown villager + DW classCroutonDoctor, 0 ;+152 doctor crouton / guard + DW classCroutonBullet, 0 ;+154 crouton bullet + DW classCroutonWizard, 0 ;+156 wizard crouton + DW classWizardBullet, 0 ;+158 spiral wizard bullet + DW classGeneric, 0 ;+160 mud? + DW classArrowBullet, 0 ;+162 arrow bullet + DW classRocketBullet, 0 ;+164 rocket bullet + DW classCowboyBullet, 0 ;+166 yellow bolt bullet + DW classGeneric, 0 ;+168 purple sparkley bullet + DW classBSBullet, 0 ;+170 bs bullet + DW classCroutonGoblin, 0 ;+172 goblin crouton + DW classGeneralGyro,0,0,0,0,0,0,0 ;+174 General Gyro + DW classCroutonArtillery,0,0,0,0,0,0,0 ;+182 artillery tank crouton + DW classGeneric,0,0,0,0,0,0,0 ;+190 stabbing tank crouton + DW classMajorSkippy,0,0,0,0,0,0,0 ;+198 Major Skippy + DW classBAPlayer,0 ;+206 RA + DW classBSPlayer,0 ;+208 CS + DW classBigSpider,0,0,0,0,0,0,0 ;+210 Big Spider + DW classLittleSpider,0 ;+218 Little Spider + DW classTeleportCube,0,0,0 ;+220 Teleport Field + DW classTeleportCube2,0,0,0 ;+224 Teleport Field + DW classDandelionGuard,0 ;+228 Dandelion guard + DW classB12Soldier,0 ;+230 Purple Soldier + DW classB12Soldier,0 ;+232 Grey Soldier + DW classB12Soldier,0 ;+234 Yellow Soldier + DW classGeneric,0 ;+236 Orange Specialist + DW classGeneric,0 ;+238 Grey Specialist + DW classGeneric,0 ;+240 Green Specialist + DW classActor,0 ;+242 Red Ninja (Iambic) + DW classHaikuPlayer,0 ;+244 Purple Ninja (Free Verse) + DW classB12SoldierBullet,0 ;+246 B12 Soldier Bullet + DW classGeneric ;+248 bomb thing + DW classGeneric,0,0,0 ;+249 BRAINIAC + DW classTreeBullet,0 ;+253 Tree and bush bullet + DW 0 ;+255 pad + DW classStunnedWall,0 ;+256 Stunned wall creature + DW classInvisibleBat,0 ;+258 Invisible Bat + DW classSlime,0 ;+260 Small slime + + DW classYellowWisp,0 ;+262 Yellow wisp + DW classGeneric ;+264 Immobile armor + DW classGeneric,0 ;+265 Suit of armor + DW classMonkey,0 ;+267 Brown Monkey + DW classBananaBullet,0 ;+269 Bananna bullet + DW classDuke,0,0,0,0,0,0,0 ;+271 Duke the one-armed orangutan + DW classGeneric,0 ;+279 leprechaun + DW classPig,0 ;+281 pig + DW classEgg ;+283 egg + DW classBlower,0 ;+284 Crouton Blower + DW classSleepingMonkey ;+286 Sleeping Monkey + DW classBell,0,0,0 ;+287 Bell + DW classRingingBell,0,0,0 ;+291 Ringing Bell + DW classBananaTree,0,0,0 ;+295 Banana Tree + DW classHermitNoShell,0 ;+299 Hermit Crab, no shell + DW classHermitInShell,0 ;+301 Hermit Crab inside shell + DW classSwampThang,0,0,0,0,0,0,0 ;+303 Swamp Thang + DW classCrab,0 ;+311 Red Crab + DW classCrabBurrowing ;+313 Red Crab Burrowing + DW classUberMouse,0,0,0,0,0,0,0 ;+314 Uber Mouse + DW classTurret,0,0,0 ;+322 Turret + DW classCroutonKing,0,0,0,0,0,0,0 ;+326 Turret Bullet + DW classTurretBullet,0 ;+334 Turret Bullet + DW classActor,0 ;+336 Fake BA + DW classActor,0 ;+338 Fake BS + DW classActor,0 ;+340 Fake Haiku + DW classGrenadePlayer,0,0,0,0,0,0,0 ;+342 Fake King Grenade + DW classHeroLady,0 ;+350 Hero Lady Flower + DW classHeroFlour,0 ;+352 Hero Captain Flour + DW classGeneric,0 ;+354 Disco Dancer + DW classActor,0,0,0 ;+356 Lying Head single 2x2 frame + DW classActor2x2,0,0,0,0,0,0,0 ;+360 Thaddius Pencilbody + DW classActor,0 ;+368 Blue Skull + DW classActor2x2,0,0,0,0,0,0,0 ;+370 Santa + DW classActor2x2,0,0,0,0,0,0,0 ;+378 Queen Bee + DW classActor2x2,0,0,0,0,0,0,0 ;+386 Rocking Horse + DW classActor,0 ;+394 Candy Cane + DW classActor,0 ;+396 Doll + DW classActor2x2,0,0,0,0,0,0,0 ;+398 Reindeer + DW classFlourBullet,0 ;+406 Captain Flour Bullet + DW classLadyBullet,0 ;+408 Hero Lady Flower Bullet + ;DW classLadyBullet,0 ;+410 Hero Lady Flower Bullet + ;DW classLadyBullet,0 ;+412 Hero Lady Flower Bullet + ;DW classLadyBullet,0 ;+414 Hero Lady Flower Bullet + +classDoNothing:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DoNothingCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classDoNothing2:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DoNothingCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classDoNothing3:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DoNothingCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHeroIdle:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW IdleCantDieCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classGeneric:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GenericCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTalker:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TalkerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classActor:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classActor2:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classGuard:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GuardCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classActorSpeed1:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorSpeed1Check ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classActor2x2:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classPansy:: + DW PansyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW PansyCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHippiePansy:: + DW PansyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW HippiePansyCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classPansyBullet:: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW StdBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBAPlayer:: + DW BAInit + DW StandardRedraw + DW BAPlayerCheck + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBAPlayerSpace:: + DW BAInit + DW StandardRedraw + DW BAPlayerCheckSpace + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBSPlayer:: + DW BSInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BSPlayerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBSPlayerSpace:: + DW BSInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BSPlayerCheckSpace ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHaikuPlayer:: + DW HaikuInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW HaikuPlayerCheck ;vector for check method + DW HaikuTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHaikuPlayerSpace:: + DW HaikuInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW HaikuPlayerCheckSpace ;vector for check method + DW HaikuTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHeroLady:: + DW LadyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW LadyPlayerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHeroFlour:: + DW FlourInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW FlourPlayerCheck ;vector for check method + ;DW HaikuTakeDamage ;vector for take damage method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classFlourBullet:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW FlourBulletCheck ;vector for check method + DW HaikuTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classLadyBullet:: + DW LadyBulletInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW LadyBulletCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classGrenadePlayer:: + DW GrenadePlayerInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GrenadePlayerCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classBSActor:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBee: + DW BeeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BeeCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classStunnedWall:: + DW StunnedWallInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW StunnedWallCheck ;vector for check method + DW WallTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classGrenade: + DW GrenadeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GrenadeCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classVacuum: + DW VacuumInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW VacuumCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSlug: + DW SlugInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SlugCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classWallCreature:: + DW WallCreatureInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW WallCreatureCheck ;vector for check method + DW WallTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classWallTalker:: + DW WallCreatureInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TalkerCheck ;vector for check method + DW WallTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSmallBeeHive: + DW SmallBeeHiveInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SmallBeeHiveCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classScaredie: + DW ScardieInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ScardieCheck ;vector for check method + DW ScardieTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classChomper:: + DW ChomperInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ChomperCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classReciprocator: + DW ReciprocatorInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ReciprocatorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classReciprocatorPowerup: + DW ReciprocatorInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ReciprocatorPowerupCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTri: + DW TriInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TriCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTriling: + DW TrilingInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TrilingCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTree:: + DW TreeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TreeCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTreeTalker:: + DW TreeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TreeTalkerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBush: + DW BushInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BushCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classNeedle: + DW NeedleInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW NeedleCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBat: + DW BatInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BatCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBurrower: + DW BurrowerInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BurrowerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBurrowerDirt: + DW BurrowerDirtInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BurrowerDirtCheck ;vector for check method + DW TakeZeroDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classDandelion:: + DW DandelionInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DandelionCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classDandelionPuff: + DW DandelionPuffInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DandelionPuffCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBABullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW BASuperFastBulletCheck + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBigLongLaser:: + DW StdBulletInit ;vector for init method + DW StreamRedraw ;vector for redraw method + DW StreamCheck ;vector for check method + DW DoNothing ;vector for take damage method + DW StreamDie ;vector for die method + +classExplosion:: + DW ExplosionInit ;vector for init method + DW ExplosionRedraw ;vector for redraw method + DW ExplosionCheck ;vector for check method + DW ExplosionCheck ;vector for take damage method + DW ExplosionDie ;vector for die method + +classLadyFlower:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCaptainFlour:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classMouse:: + DW MouseInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW MouseCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classPenguin:: + DW PenguinInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW PenguinCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBIOS:: + DW BIOSInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BIOSCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonHulk:: + DW CroutonHulkInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonHulkCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonGrunt:: + DW CroutonGruntInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonGruntCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBigBeeHive: + DW BigBeeHiveInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BigBeeHiveCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classSheep: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SheepCheck ;vector for check method + DW CowboyTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classChicken:: + DW ChickenInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ChickenCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classPurpleWisp:: + DW WispInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW WispCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classQuatrain:: + DW QuatrainInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW QuatrainCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classWolf:: + DW WolfInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW WolfCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSnake:: + DW SnakeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SnakeCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classNeanderthal:: + DW NeanderthalInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW NeanderthalCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCrow:: + DW CrowInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CrowCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classScarecrow:: + DW ScarecrowInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ScarecrowCheck ;vector for check method + DW ScarecrowTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classAlligator: + DW AlligatorInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW AlligatorCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classWolfSheep:: + DW WolfSheepInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW WolfSheepCheck ;vector for check method + DW WolfSheepTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classScorpion: + DW ScorpionInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ScorpionCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBow: + DW BowInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BowCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCowboy:: + DW CowboyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CowboyCheck ;vector for check method + DW CowboyTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classAngryCowboy:: + DW CowboyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW AngryCowboyCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCowboyTalker:: + DW CowboyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TalkerCheck ;vector for check method + DW CowboyTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonDoctor:: + DW CroutonDoctorInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonDoctorCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW StdBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonWizard:: + DW CroutonWizardInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonWizardCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classWizardBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW WizardBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBSBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method +IF UPGRADES + DW HeroSuperFastBulletCheck +ELSE + ;DW HeroBulletCheck ;vector for check method + DW HeroSuperFastBulletCheck +ENDC + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classArrowBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW StdBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classRocketBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW ExplodingBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCowboyBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW SuperFastBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonGoblin:: + DW CroutonGoblinInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonGoblinCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classGeneralGyro:: + DW GeneralGyroInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonArtillery:: + DW CroutonArtilleryInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CroutonArtilleryCheck;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classMajorSkippy:: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW ActorCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classTeleportCube:: + DW TeleportCubeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TeleportCubeCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classTeleportCube2:: + DW TeleportCubeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TeleportCubeCheck2 ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classDandelionGuard:: + DW DandelionGuardInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DandelionGuardCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classB12Soldier:: + DW B12SoldierInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW B12SoldierCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classB12SoldierBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW StdBulletCheck ;vector for check method + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBigSpider: + DW BigSpiderInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BigSpiderCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classLittleSpider: + DW LittleSpiderInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW LittleSpiderCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classTreeBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW SuperFastBulletCheck + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBushBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW StdBulletCheck + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classInvisibleBat: + DW BatInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW InvisibleBatCheck ;vector for check method + DW InvisibleBatTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSlime:: + DW SlimeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SlimeCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classYellowWisp:: + DW WispInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW WispCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classMonkey:: + DW MonkeyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW MonkeyCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBananaBullet: + DW YellowBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW SuperFastBulletCheck + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classDuke: + DW DukeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DukeCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classPig: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW PigCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classEgg:: + DW EggInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW EggCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBlower: + DW BlowerInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BlowerCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSleepingMonkey: + DW SleepingMonkeyInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW SleepingMonkeyCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classBell: + DW BellInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DoNothingCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classRingingBell: + DW BellInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW DoNothingCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classBananaTree: + DW BananaTreeInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW BananaTreeCheck ;vector for check method + DW BananaTreeTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHermitNoShell: + DW HermitNoShellInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW HermitNoShellCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classHermitInShell: + DW HermitNoShellInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW HermitInShellCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classSwampThang: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GenericCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classCrab: + DW CrabInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW CrabCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classCrabBurrowing: + DW CrabBurrowingInit ;vector for init method + DW DoNothing ;vector for redraw method + DW CrabBurrowingCheck ;vector for check method + DW StdTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +classUberMouse: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW UberMouseCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classTurret:: + DW TurretInit ;vector for init method + DW StandardRedraw ;vector for redraw method + DW TurretCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classCroutonKing: + DW InitTwoHealth ;vector for init method + DW StandardRedraw ;vector for redraw method + DW GenericCheck ;vector for check method + DW StdTakeDamage2x2 ;vector for take damage method + DW StandardDie ;vector for die method + +classTurretBullet: + DW StdBulletInit ;vector for init method + DW StdBulletRedraw ;vector for redraw method + DW SuperSuperFastBulletCheck + DW BulletTakeDamage ;vector for take damage method + DW StandardDie ;vector for die method + +SECTION "ClassesSection",ROMX,BANK[CLASSROM] + +;--------------------------------------------------------------------- +;bg methods +;are passed parameters: +; a - method type (BGACTION_HIT,BGACTION_MOVEOVER) +; c - tile index (eg class index 24, not class 1045) +; hl - map location +;--------------------------------------------------------------------- +classGenericBG: + ret + +classAppomattoxBG:: + ret +classLandingLightsBG:: + ret +classInvisibleWallBG:: + ret + +classChangeTo120BG: + cp BGACTION_HIT + ret nz + + ld bc,classShiftPlusOneBG + call FindClassIndex + + push af + ld a,MAPBANK + ldio [$ff70],a + pop af + + ld [hl],a + ret + +classShiftPlusOneBG: + cp BGACTION_HIT + ret nz + + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + inc a + ld [hl],a + ret + +classGeneratorBG: +classDestructableBG: + cp BGACTION_HIT + ret nz + + ;remove myself from the map + ld a,MAPBANK + ldio [$ff70],a + ld [hl],0 + + ld hl,levelVars+15 + inc [hl] + ret + +classDestructableAdjoinRightBG: + cp BGACTION_HIT + ret nz + + ;remove myself & neighbor from the map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl+],a + ld [hl],a + inc a + + ld hl,levelVars+15 + inc [hl] + ret + +classDestructableAdjoinLeftBG: + cp BGACTION_HIT + ret nz + + ;remove myself & neighbor from the map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl-],a + ld [hl],a + inc a + + ld hl,levelVars+15 + inc [hl] + ret + +classDestructableAdjoinBottomBG: + cp BGACTION_HIT + ret nz + + ;remove myself & neighbor from the map + ld a,MAPBANK + ldio [$ff70],a + ld [hl],0 + ld a,[mapPitch] + add l + ld l,a + ld a,h + adc 0 + ld h,a + ld [hl],0 + + ld hl,levelVars+15 + inc [hl] + ret + +classDestructableAdjoinTopBG: + cp BGACTION_HIT + ret nz + + ;remove myself & upper neighbor from the map + ld a,MAPBANK + ldio [$ff70],a + ld [hl],0 + ld a,[mapOffsetNorth] + add l + ld l,a + ld a,[mapOffsetNorth+1] + adc h + ld h,a + ld [hl],0 + + ld hl,levelVars+15 + inc [hl] + ret + + +classSplitterBG: + cp BGACTION_HIT + jr nz,.done + + ;get class of bullet + ld a,[bulletClassIndex] + ld c,a + + call GetFGAttributes + and FLAG_ISBULLET + ret z + + ld a,[bulletDirection] + ld b,a + ld [fireBulletDirection],a + + ;create a bullet continuing in the same direction + call CreateBulletOfClass + + ;and 90 CW + ld a,b + inc a + and %11 + ld [fireBulletDirection],a + call CreateBulletOfClass + + ;and 90 CCW + ld a,b + dec a + and %11 + ld [fireBulletDirection],a + call CreateBulletOfClass + +.done + xor a ;no explosion + ret + +classNoExplosionBG: + xor a + ret + +classChangeToBigSpiderBG: + cp BGACTION_HIT + ret nz + + ;I'm corner of 2x2 tile; remove tile + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl+],a + ld [hl-],a + push hl + ld a,[mapPitch] + add l + ld l,a + ld a,h + adc 0 + ld h,a + ld [hl+],a + ld [hl-],a + pop hl + + ;create a big spider here + ld bc,classBigSpider + call FindClassIndex + ret z + ld c,a + jp CreateInitAndDrawObject + +classAdjoinWestBG: + cp BGACTION_HIT + ret nz + + ;pass the buck to the west + ld a,MAPBANK + ldio [$ff70],a + dec hl + ld c,[hl] + ld a,BGACTION_HIT + jp CallBGAction + +classAdjoinNorthBG: + cp BGACTION_HIT + ret nz + + ;pass the buck to the north + ld a,MAPBANK + ldio [$ff70],a + ld a,[mapOffsetNorth] + ld e,a + ld d,$ff + add hl,de + ld c,[hl] + ld a,BGACTION_HIT + jp CallBGAction + +classChangeToLittleSpiderBG: + cp BGACTION_HIT + ret nz + + ;create a little spider right here + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl],a + + ld bc,classLittleSpider + call FindClassIndex + ret z + ld c,a + jp CreateInitAndDrawObject + +classHiveBG: + call FindEmptyLocationAround1x1Loc + or a + ret z + + ;create an adjacent bee when the wall is shot + ld bc,classBee + call FindClassIndex + ret z + ld c,a + jp CreateInitAndDrawObject + +classCheeseBG: + call FindEmptyLocationAround1x1Loc + or a + ret z + + ld bc,classEdibleCheeseBG + call FindClassIndex + push af + ld a,MAPBANK + ldio [$ff70],a + pop af + ld [hl],a + + jp ResetMyBGSpecialFlags + +classHermitCrabShellBG: + ret + +classEdibleCheeseBG: + jr HealthPlusOneBG + +classPorkBG: + jr HealthPlusOneBG + +classFriedEggBG: + jr HealthPlusOneBG + +classDrumstickBG: + jr HealthPlusOneBG + +classBananaBG: + jr HealthPlusOneBG + +HealthPlusOneBG: + cp BGACTION_MOVEOVER + ret nz + + ldio a,[firstMonster] + ld b,a + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call EnsureTileIsHead + cp b + ret c ;not a monster + + ld c,a + call GetFGAttributes + and FLAG_ISBULLET + ret nz ;want monster not bullet + + ;clear out tile shadow bank at this loc + ;(egg->nothing under creature) + call ClearBGUnderSprite + + call GetObjectOnBG + ;ld a,MAPBANK + ;ldio [$ff70],a + ;ld a,[hl] + ;call EnsureTileIsHead + ;ld d,h + ;ld e,l + ;call FindObject ;get that monster + call GetHealth ;increase its health + cp 63 + ret nc + inc a + call SetHealth + ld a,BANK(eat_gbw) + ld hl,eat_gbw + jp PlaySample + +classSlugTrailBG: + cp BGACTION_MOVEOVER + ret nz + + push hl + call GetObjectOnBG + pop hl + call GetFGAttributes + and FLAG_ISBULLET + ret nz + call ClearBGUnderSprite + ld a,30 + jp SetMoveDelay + +GetObjectOnBG: + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call EnsureTileIsHead + ld c,a + ld d,h + ld e,l + jp FindObject ;get that monster + +ClearBGUnderSprite: + ld a,TILESHADOWBANK + ldio [$ff70],a + xor a + ld [hl],a + ret + +classClearanceBG: + cp BGACTION_MOVEOVER + ret nz + + push hl + call GetObjectOnBG + pop hl + call IsHero + ret z + call ClearBGUnderSprite + + ;add appropriate code to inventory + ld hl,mapToCodeIndexTable + ld a,[curLevelStateIndex] + call LookupIndexOfData8 + ld hl,codeIndexToItemTable + call Lookup16 + push hl + pop bc + call AddInventoryItem + + ;increase clearance level + ld bc,ITEM_ALPHACLEAR + call HasInventoryItem + jr nz,.foundCurLevel + ld bc,ITEM_BETACLEAR + call HasInventoryItem + jr nz,.foundCurLevel + ld bc,ITEM_GAMMACLEAR + call HasInventoryItem + jr nz,.foundCurLevel + ld bc,ITEM_DELTACLEAR + call HasInventoryItem + jr nz,.foundCurLevel + ld bc,ITEM_EPSILONCLEAR + call HasInventoryItem + jr nz,.foundCurLevel + ld bc,ITEM_ZETACLEAR + call HasInventoryItem + ret nz ;don't go higher than zeta + + ;start with alpha clearance + ld bc,ITEM_ALPHACLEAR + call AddInventoryItem + ret + +.foundCurLevel + call RemoveInventoryItem + rlc c + call AddInventoryItem + ret + +IsHero: + ld a,[hero0_index] + cp c + jr z,.returnTrue + + ld a,[hero1_index] + cp c + jr z,.returnTrue + +.returnFalse + xor a + ret + +.returnTrue + ld a,1 + or a + ret + +mapToCodeIndexTable: + DB $04,$09,$2a,$6a,$a4,$73 + +codeIndexToItemTable: + DW ITEM_CODE0400,ITEM_CODE0900,ITEM_CODE1002,ITEM_CODE1006 + DW ITEM_CODE0410,ITEM_CODE0307 + +; Arguments: bc - item corresponding to clearance +RemoveClearanceIfTaken:: + call HasInventoryItem + ret z ;not taken yet + + ld hl,classClearanceBG + call FindFirstBGLoc + ret z + + xor a + ld [hl],a + ret + + + +;--------------------------------------------------------------------- +;obj methods +;--------------------------------------------------------------------- + +SuperInit:: + push hl + + ld a,OBJBANK + ldio [$ff70],a + + ld hl,OBJ_FRAME + add hl,de + + xor a + ld [hl+],a ;frame + ld a,1 + ld [hl+],a ;move countdown + xor a + ld [hl+],a ;limit + ld [hl+],a ;health + ld [hl+],a ; + ld [hl+],a ; + ld [hl+],a ;state + ld [hl+],a ;group + ld [hl+],a ;destl + ld [hl+],a ;desth + + ld a,$ff + ld [hl+],a ;spritelo + + xor a + ld [hl+],a ;13 + ld [hl+],a ;14 + ;leave NEXTL alone + + pop hl + ret + +SuperDie:: + push hl + xor a + call SetHealth + jr SuperDieFreeSprite +FreeSpriteLoPtr: + push hl +SuperDieFreeSprite: + call GetSpriteLo + call FreeSprite + ld a,$ff + call SetSpriteLo + pop hl + ret + +InitTwoHealth: + ld hl,.initTwoHealthTable + jp StdInitFromTable + +.initTwoHealthTable + DB 4 ;initial facing + DB 2 ;health (max) + DB GROUP_MONSTERN ;group friends with everyone + DB 0 ;has bullet + +DoNothing: + ret + +StandardRedraw: + push bc + push de + push hl + + call GetFacing + + bit 7,a + jr z,StandardRedrawAfterPush ;not a sprite + + push bc + ld c,a + call RemoveFromMap + pop bc + + jr StandardRedrawAfterPush + +StandardRedrawNoCheckSprite: +StandardChooseColor: + push bc + push de + push hl + +StandardRedrawAfterPush: + ;white if dandelion puffs on me + call GetPuffCount + or a + jr z,.noPuffs + + ld b,0 + jr StandardDraw + +.noPuffs + call GetFGAttributes + and %111 + ld b,a + + ;falling through from above +StandardDraw: + ;bc, de, hl already pushed in chooseColor + ld a,c + ld [curObjIndex],a + + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + + ;save map location for later use + ld a,[de] + inc de + ld [methodParamL],a + ld a,[de] + inc de + ld [methodParamH],a + + ;get frame (facing + animation) + ;check isSprite flag + ld a,[de] + bit 7,a + jr z,.drawTileBased + + jp .drawSpriteBased + +.drawTileBased + and %111 ;mask off facing stuff + push af ;save frame for later + ld d,0 + ld e,a ;done with original de + + ;get attributes of tile + ld hl,.attributeLookup + ld a,[fgFlags] + bit BIT_NOROTATE,a + jr z,.afterLoadAttributeLookup + ld hl,.attributeLookup+8 +.afterLoadAttributeLookup + add hl,de ;hl is &attributeLookup[frame] + + ld a,[hl] ;flip attributes for this frame + or b ;combined + ld b,a ;B is full attributes + + ld a,TILEINDEXBANK ;select RAM bank of tile index maps + ldio [$ff70],a + + ;add 16+(is2x2*16) to attributeLookup to get tile offset Lookup + ld e,16 + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.eHasCorrectValue + ld e,32 +.eHasCorrectValue + add hl,de ;[hl] is tile offset + + ld e,c ;index of tile is low byte + ld d,((fgTileMap>>8) & $ff) ;de pts to base tile + + ld a,[de] ;get base tile + pop de ;frame in d + ld e,c ;save class index in e + cp $ff + jr z,.afterAddOffset + add [hl] ;add offset +.afterAddOffset + ld c,a ;c is tile to draw + + ;retrieve ptr to map location of this object + ld a,[methodParamL] ;hl = ptr to draw dest + ld l,a + ld a,[methodParamH] + ld h,a + + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.draw1x1tileBased + + jp Draw2x2tileBased + +.draw1x1tileBased + ;use frame to determine how many tiles to spread this across + ;and in what direction + bit 2,d ;d is frame + jr z,.drawSingleTile + bit 0,d + jr z,.drawNorthToSouthSplit + +.drawEastToWestSplit + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld a,e + ld [hl+],a ;draw class index + ld a,CLASS_ADJOIN_W + ld [hl-],a ;in next tile too + ld a,TILESHADOWBANK ;select tile shadow RAM + ldio [$ff70],a + ld a,c + ld [hl+],a ;draw tile to tile shadow RAM + ;tile plus one or minus one for frame modifier + bit 1,d + jr z,.EWIncrement + dec a + jr .EWDone +.EWIncrement + inc a +.EWDone + ld [hl-],a ;and again + ld a,ATTRSHADOWBANK ;select attribute shadow RAM + ldio [$ff70],a + ld a,b + ld [hl+],a ;draw attribute to attribute shadow RAM + ld [hl-],a ;and again + jr .done + +.drawNorthToSouthSplit + call .drawAtHL + push de + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + pop de + ld e,CLASS_ADJOIN_N + ;tile plus one or minus one for frame modifier + bit 1,d + jr z,.NSIncrement + ;handle NOROTATE + ld a,[fgFlags] + bit BIT_NOROTATE,a + jr nz,.NSIncrement + dec c + jr .NSDone +.NSIncrement + inc c +.NSDone + call .drawAtHL + jr .done + +.drawSingleTile + call .drawAtHL + jr .done + +.drawAtHL + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld [hl],e ;draw class index +.drawShadowAtHL + ld a,TILESHADOWBANK ;select tile shadow RAM + ldio [$ff70],a + ld [hl],c ;draw tile to tile shadow RAM + ld a,ATTRSHADOWBANK ;select attribute shadow RAM + ldio [$ff70],a + ld [hl],b ;draw attribute to attribute shadow RAM + ret + +.done pop hl + pop de + pop bc + ret + +.drawSpriteBased + push bc + push af ;save frame + dec de + dec de + call GetCurLocation + + ;copy map underneath current to tile & attribute shadow buffers + call .copyMapToShadowBuffers + pop af ;get frame back + + bit 2,a ;split? + jr z,.updateSprite ;done copying tile stuff + + bit 0,a ;n/s or e/w? + jr z,.spriteNS + + ;e/w split + inc hl + call .copyMapToShadowBuffers + jr .updateSprite + +.spriteNS + ;n/s split + push de ;retrieve vertical offset + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + pop de + + call .copyMapToShadowBuffers + +.updateSprite + pop bc + + push bc + ld a,[curObjIndex] + ld c,a + ;draw the object's id to the map buffer + call GetFacing + ld b,a + call GetCurLocation + ld a,MAPBANK + ldio [$ff70],a + ld [hl],c ;head of obj + ld a,b + and %00000101 + cp %00000101 ;E/W split + jr nz,.checkNS_Split + inc hl + ld [hl],CLASS_ADJOIN_W + jr .doneDrawID +.checkNS_Split + ld a,b + and %00000100 + jr z,.doneDrawID + ;N/S split + ld a,[mapOffsetSouth] + add l + ld l,a + ld a,[mapOffsetSouth+1] + adc h + ld h,a + ld [hl],CLASS_ADJOIN_N +.doneDrawID + pop bc + + call GetCurLocation + ld a,TILESHADOWBANK + ldio [$ff70],a + ld a,[hl] + or a + jr z,.afterCallMoveOverBG + + push bc + ld c,a + ld a,BGACTION_MOVEOVER + call CallBGAction + pop bc + +.afterCallMoveOverBG + ;attempt to allocate sprite if we don't have one + call GetSpriteLo + cp $ff + jr nz,.haveSprite + + ;see if the sprite will show up onscreen + call GetCurLocation + call ConvertLocHLToSpriteCoords + ;ld a,l + ;or a + ;jr z,.spdone ;won't show up anyways + + call AllocateSprite + cp $ff + jr z,.spdone ;no sprite for you + call SetSpriteLo + +.coordsOkay + ;initialize the sprite's position + push af + push de + ld e,a + ld d,((spriteOAMBuffer>>8) & $ff) + ld a,l + ld [de],a + inc de + ld a,h + ld [de],a + pop de + pop af + + ;if split bit is set scoot in one direction or another + push bc + push af + call GetFacing + bit 2,a + jr z,.afterScoot + + bit 0,a ;N/S or E/W? + jr nz,.scootEW + + ;scoot down for N/S split + ld b,%00000010 + jr .doSplit + +.scootEW ;scoot right for E/W split + ld b,%00000001 + +.doSplit + pop af + push af + call ScootSprite + +.afterScoot + pop af + pop bc + +.haveSprite ;set up the sprite to reflect the current facing + push bc + + call GetSpritePtrInHL + inc hl + inc hl + call GetFGTileMapping + ld c,a + + call GetFacing + bit 0,a + jr nz,.facingEastWest + + ;facing north/south + inc c + inc c + bit 1,a + jr z,.checkAnim ;facing north no flip + + ;facing south + set 6,b ;flip tile vertically + jr .checkAnim + +.facingEastWest + bit 1,a ;facing east or west? + jr z,.checkAnim ;facing east, no flip + + set 5,b ;facing west, flip horizontally + +.checkAnim + bit 2,a ;check split bit + jr z,.baseAnimOkay + + inc c + +.baseAnimOkay + ld a,c ;tile number + ld [hl+],a + + ld a,b + or %00001000 ;attributes + ld [hl],a + + pop bc + + ;clear vflip bit if NOROTATE flag set + call GetFGAttributes + and FLAG_NOROTATE + jr z,.spdone + + res 6,[hl] + +.spdone pop hl + pop de + pop bc + ret + +.copyMapToShadowBuffers + ;assumes hl points to location + ld a,MAPBANK + ldio [$ff70],a + + ld a,[hl] ;get map tile + + ;get bg attributes of this map tile + ld c,a + ld b,((bgAttributes>>8) & $ff) + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,[bc] + + ;clear off all but the palette + and %00000111 + ld b,a + call .drawShadowAtHL + + ret + +.attributeLookup + DB %00001000,%00001000,%01001000,%00101000 ;1x1 normal + DB %00001000,%00001000,%01001000,%00101000 + DB %00001000,%00001000,%00001000,%00101000 ;no rotate + DB %00001000,%00001000,%00001000,%00101000 +.tileOffsetLookup + DB 0, 3, 0, 3, 1, 4, 2, 5 ;1x1 creature n,e,s,w,nsp,esp,ssp,wsp + DB 0, 3, 0, 3, 1, 4, 1, 5 ;1x1 no rotate + DB 0,10, 2,11, 4,14, 8,16 ;2x2 creature + DB 0,10, 2,11, 4,14, 8,16 ;2x2 creature + + DB 0 ;pad to make emulator not freak the disasm + +Draw2x2tileBased: + ;use frame to determine how many tiles to spread this across + ;and in what direction + bit 2,d ;d is frame + jr nz,.decideWhichSplit + jp .drawNonSplit +.decideWhichSplit + bit 0,d + jr z,.drawNorthToSouthSplit + +.drawEastToWestSplit + bit 1,d + jr nz,.drawSplitFacingWest + +.drawSplitFacingEast + push hl + call .drawHeadOfEWSplit + call .drawSplitE_PatternAndAttrNumbers + ld a,c + add 3 + ld c,a + + ;move hl to start of next row + pop hl + call HLToNextRow + + ;repeat for row 2 + call .drawSecondRowOfEWSplit + call .drawSplitE_PatternAndAttrNumbers + jp .done + +.drawSplitFacingWest + push hl + call .drawHeadOfEWSplit + call .drawSplitW_PatternAndAttrNumbers + ld a,c + add 3 + ld c,a + + ;move hl to start of next row + pop hl + call HLToNextRow + + ;repeat for row 2 + call .drawSecondRowOfEWSplit + call .drawSplitW_PatternAndAttrNumbers + jp .done + +.drawNorthToSouthSplit + bit 1,d + jr nz,.drawSplitFacingSouth + +.drawSplitFacingNorth + push hl + call .drawHeadOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + inc c + inc c + + ;move hl to start of next row + pop hl + call HLToNextRow + + ;repeat for row 2 & 3 + push hl + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + inc c + inc c + pop hl + call HLToNextRow + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + jp .done + +.drawSplitFacingSouth + push hl + call .drawHeadOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + dec c + dec c + + ;move hl to start of next row + pop hl + call HLToNextRow + + ;repeat for row 2 & 3 + push hl + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + dec c + dec c + pop hl + call HLToNextRow + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + jr .done + +.drawNonSplit + bit 1,d + jr z,.drawNonSplitNorE + + bit 0,d + jr nz,.drawNonSplitW + +.drawNonSplitS + push hl + call .drawHeadOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + dec c + dec c + + ;move hl to start of next row + pop hl + call HLToNextRow + + ;repeat for next row + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + jr .done + +.drawNonSplitW + push hl + ld a,MAPBANK + ldio [$ff70],a + ld a,e + ld [hl+],a + ld a,CLASS_ADJOIN_W + ld [hl-],a + + call .drawWPatternAndAttributeNumbers + inc c + inc c + + pop hl + call HLToNextRow + + ld a,MAPBANK + ldio [$ff70],a + ld a,CLASS_ADJOIN_N + ld [hl+],a + ld [hl-],a + call .drawWPatternAndAttributeNumbers + jr .done + +.drawNonSplitNorE + push hl + call .drawHeadOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + inc c + inc c + pop hl + call HLToNextRow + call .drawSecondRowOfNSSplit + call .drawSplitNS_PatternAndAttrNumbers + +.done pop hl + pop de + pop bc + ret + +.drawHeadOfEWSplit + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld a,e + ld [hl+],a ;draw class index + ld a,CLASS_ADJOIN_W + ld [hl+],a + ld [hl-],a + dec hl + ret + +.drawSecondRowOfEWSplit + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld a,CLASS_ADJOIN_N + ld [hl+],a + ld [hl+],a + ld [hl-],a + dec hl + ret + +.drawSplitE_PatternAndAttrNumbers + ;draw pattern numbers to tile shadow bank + ld a,TILESHADOWBANK ;select tile shadow RAM + ldio [$ff70],a + ld a,c + ld [hl+],a ;draw tile to tile shadow RAM + inc a + ld [hl+],a + inc a + ld [hl],a + + ;draw colors to attr shadow bank + ld a,ATTRSHADOWBANK ;select attribute shadow RAM + ldio [$ff70],a + ld a,b + ld [hl-],a ;draw attribute to attribute shadow RAM + ld [hl-],a + ld [hl],a + ret + +.drawSplitW_PatternAndAttrNumbers + ;draw pattern numbers to tile shadow bank + ld a,TILESHADOWBANK ;select tile shadow RAM + ldio [$ff70],a + ld a,c + ld [hl+],a ;draw tile to tile shadow RAM + dec a + ld [hl+],a + dec a + ld [hl],a + + ;draw colors to attr shadow bank + ld a,ATTRSHADOWBANK ;select attribute shadow RAM + ldio [$ff70],a + ld a,b + ld [hl-],a ;draw attribute to attribute shadow RAM + ld [hl-],a + ld [hl],a + ret + +.drawHeadOfNSSplit + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld a,e + ld [hl+],a ;draw class index + ld a,CLASS_ADJOIN_W + ld [hl-],a + ret + +.drawSecondRowOfNSSplit + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + ld a,CLASS_ADJOIN_N + ld [hl+],a + ld [hl-],a + ret + +.drawSplitNS_PatternAndAttrNumbers + ;draw pattern numbers to tile shadow bank + ld a,TILESHADOWBANK ;select tile shadow RAM + ldio [$ff70],a + ld a,c + ld [hl+],a ;draw tile to tile shadow RAM + inc a + ld [hl],a + + ;draw colors to attr shadow bank + ld a,ATTRSHADOWBANK ;select attribute shadow RAM + ldio [$ff70],a + ld a,b + ld [hl-],a ;draw attribute to attribute shadow RAM + ld [hl],a + ret + +.drawWPatternAndAttributeNumbers + ld a,TILESHADOWBANK + ldio [$ff70],a + ld a,c + ld [hl+],a + dec a + ld [hl],a + + ld a,ATTRSHADOWBANK + ldio [$ff70],a + ld a,b + ld [hl-],a + ld [hl],a + ret + +HLToNextRow: + push de + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + pop de + ret + +GenericCheck: + ld hl,.genericCheckTable + jp StdCheckFromTable + +.genericCheckTable + DB 5 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 10 ;fire delay + DW StdVectorToState + +IF 0 + ;push bc + ;push de + ;push hl + + ;am I dead? + call GetHealth + or a + jr nz,.checkTimeToMove + call StandardDie + jr .done + +.checkTimeToMove + ;time to move? + ld a,5 ;2 + call TestMove + or a + jr z,.skipMove ;timer lsb==frame lsb, don't move yet + + ld a,1 + ld [moveAlignPrecision],a + call StdVectorToState + or a + jr z,.skipMove + ;call GetRandomMovement + ;ld b,2 ;everyone move this way + call StandardValidateMoveAndRedraw +.skipMove + +.done ;pop hl + ;pop de + ;pop bc + ret +ENDC + +TalkerCheck: + ld hl,talkerCheckTable +TalkerCheckAfterSetupHL: + ld a,c + ld [dialogBalloonClassIndex],a + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + push hl + call StdCheckTalk + pop hl + ret z + call StdMove + ret + + +talkerCheckTable: + DB 5 ;move delay + DW StdVectorToState + + +GetRandomMovement: + ;returns random value in b + ;alters a, b, and hl + + ;pick a "random value" ((counter+=17)) + ld a,%00001111 + call GetRandomNumMask + + ;ldio a,[randomLoc] + ;add 17 + ;ldio [randomLoc],a + ;and %00001111 ;restrict to 0-15 + cp 4 + jr c,.randomDir ;less than 4 move in a different direction + + ;move in direction we're currently facing + ;get current frame + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,2 + add hl,de + ld a,[hl] + and %00000011 ;clear off all but the direction bits + ld b,a ;b is same direction as before + ret + +.randomDir + and %00000011 ;mask off our random # to a direction + ld b,a + ret + + +;--------------------------------------------------------------------- +; Routine: EnforceLegalMove +; Arguments: b - original desired move direction +; c - class index +; de - "this" +; Returns: b - modified move direction +; Alters: a, b, hl +; Description: Adjusts move direction stored in b so that it is legal. +; A creature can always turn 180 around, but otherwise +; this means that it will travel forward if it is split +; between two tiles or if there is a wall in the desired +; direction. +;--------------------------------------------------------------------- +EnforceLegalMove: + ;get current frame in a + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,2 + add hl,de + ld a,[hl] + + ;is object split between two tiles? + bit 2,a + jr z,.notSplit + + ;It is split. This makes our job easy - creature can only + ;turn around or go forward + ld h,a ;save current direction in h + add 2 ;add two and mask off to reverse + and %00000011 + cp b ;reverse dir equal to desired? + jr nz,.splitMF ;no, move forward + + ret ;allow move in reverse direction + +.splitMF + ;force the wee bairn to move forward + ld a,h + and %00000011 + ld b,a + ret + +.notSplit + ;critter's not split. Maybe it just wants to turn around + ;without a lot of fuss? + ld h,a ;save current direction in h + add 2 ;add two and mask off to reverse + and %00000011 + cp b ;reverse dir equal to desired? + jr nz,.noReverse ;hmm guess not + + ret ;let 'im turn around slowly like + +.noReverse + push de + push hl +jr .moveAnywhere + + ;setup de with ptr to current location + ld h,d + ld l,e + ld a,[hl+] + ld d,[hl] + ld e,a ;de has ptr to cur location + + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + + ;Determine offset to check for wall and store in HL. + ld a,b ;desired dir + add b ;times two + ld h,((mapOffsetNorth>>8)&$ff) + add (mapOffsetNorth & $ff) + ld l,a ;hl pts to offset + ld a,[hl+] + ld h,[hl] + ld l,a ;hl IS offset + + ;don't examine my tail in the process; multiply offset + ;by two if 2x2 and facing east or south + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.afterModifyOffset + + ld a,b + and %00000011 + cp %01 ;east + jr z,.offsetTimesTwo + cp %10 ;south + jr nz,.afterModifyOffset + +.offsetTimesTwo + sla l ;hl<<=1 (same as *2) + rl h + +.afterModifyOffset + add hl,de ;hl is &location in desired dir + ldio a,[firstMonster] ;d = firstMonster + ld d,a + ld a,[hl] ;what's there? + or a + jr z,.moveAnywhere ;nothing there + cp d + jr nc,.moveAnywhere + + ;wall there, move forward unless special flag says okay + push af + ld a,ZONEBANK + ldio [$ff70],a + pop af + bit 7,[hl] ;marked as special somehow? + jr z,.moveForwardIfNotBlocked ;nope + + call GetBGAttributes + bit BG_BIT_ATTACKABLE,a + jr nz,.moveAnywhere + + bit BG_BIT_WALKOVER,a + jr z,.moveForwardIfNotBlocked + + ldio a,[curObjWidthHeight] + cp 1 + jr z,.moveAnywhere ;can walk over + jr .moveForwardIfNotBlocked + + ;nuttin there or a monster to face, let the creature move in + ;whatever direction it wants, bless its little heart (direction + ;B is fine) +.moveAnywhere + pop hl + pop de + ret + +.moveForwardIfNotBlocked + pop hl + pop de + ld l,b + ld a,h + and %00000011 + ld b,a + push hl + ld a,1 + call CheckDestEmpty + pop hl + or a + jr nz,.done + ld b,l ;allow turn anywhere if blocked ahead + ret + + +.moveForward + ;hey, you can only move forward asshole + ld a,h ;desired dir = cur dir + and %00000011 + ld b,a +.done + ret + +;--------------------------------------------------------------------- +; Routine: ScootSprite +; Arguments: a - loptr to sprite +; b - desired move direction +; Alters: af +; Description: Moves an existing sprite 4 pixels in a given +; direction. +;--------------------------------------------------------------------- +ScootSprite: + cp $ff + ret z + + push hl + + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + + bit 0,b ;test direction of travel + jr nz,.eastWest + + ld a,[hl] + bit 1,b + jr nz,.south + + ;north + sub 4 + ld [hl],a + jr .afterUpdateSpritePos + +.south + add 4 + ld [hl],a + jr .afterUpdateSpritePos + +.eastWest + inc hl + ld a,[hl] + bit 1,b + jr nz,.west + + ;east + add 4 + ld [hl],a + jr .afterUpdateSpritePos + +.west + sub 4 + ld [hl],a + +.afterUpdateSpritePos + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: Move +; Arguments: b - desired move direction +; c - class index +; de - "this" +; Returns: Nothing +; Alters: a, hl +; Description: If desired dir is != current dir then turns creature +; to desired dir. Otherwise takes a step forward. +; If it moves AND changes zones the curPathPos +; (frame bits 6:5) is set to zero. +; +; There are three steps: +; 1) Remove From Map +; If the IsSprite flag is set (FRAME:7) then the +; map is restored from the contents of the +; tileShadowBuffer. Otherwise the map tiles creature +; is occupying are cleared to zero. +; +; 2) Adjust IsSprite flag (FRAME:7) +; If 0: If [bgFlags] contains FLAG_WALKOVER or +; FLAG_SHOOTOVER then IsSprite is set to 1. +; Else If 1: +; If frame:split is 0 and tile under is zero +; then IsSprite is set to zero. +; +; 3) Redraw +; If the IsSprite flag is set then the map +; underneath is copied to the tileShadowBuffer. +; +; Regardless the class index of the object is drawn +; into the map. + +; If [bgFlags] contains either BG_FLAG_WALKOVER or +; BG_FLAG_SHOOTOVER then +;--------------------------------------------------------------------- +Move: + push bc + + ;save current zone to see if it changes when we move + call GetCurZone + ld [oldZone],a + + ;get current direction in c + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_FRAME + add hl,de + ld a,[hl] ;a = frame + ld c,a + + ;same as desired direction? + and %00000011 + cp b + jr z,.sameDirection + + ;Different direction. Turn to desired direction. + ld a,c + and %11111100 ;preserve non-direction other bits + or b ;combined with new direction + ld [hl],a ;and that's our new frame! + + ;have to remove from map if we're a sprite + call GetFacing + bit 7,a + jr z,.doneTurn + + call RemoveFromMap + +.doneTurn + pop bc + ret + +.sameDirection + call RemoveFromMap ;gonna be drawin again real soon, Baby! + + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ;if we were split facing west or north then we don't actually + ;move, we just turn off the split bit + bit 2,c + jr z,.noSplitCheckEastSouth + + ;facing west? + ld a,c + and %00000111 + cp %00000111 + jr nz,.checkSplitFacingNorth + +.noMoveToggleSplit + ld a,c + xor %00000100 + ld c,a + jr .stowNewFrame + +.checkSplitFacingNorth + cp %00000100 + jr z,.noMoveToggleSplit + jr .moveForwardToggleSplit + +.noSplitCheckEastSouth + ;if we're not split and we're heading East or South then again + ;we just toggle the split bit as our move + ld a,c + and %00000111 + cp %00000001 ;facing East? + jr z,.noMoveToggleSplit + cp %00000010 ;facing South? + jr z,.noMoveToggleSplit + +.moveForwardToggleSplit + push hl + push de + + ;setup de with ptr to current location + ld h,d + ld l,e + ld a,[hl+] + ld d,[hl] + ld e,a ;de has ptr to cur location + + ;Determine offset to check for wall and store in HL. + ld a,b ;desired dir + add b ;times two + ld hl,mapOffsetNorth + add l + ld l,a ;hl pts to offset + ld a,[hl+] + ld h,[hl] + ld l,a ;hl IS offset + add hl,de + ld d,h + ld e,l + + ;toggle the split bit for the new frame + ld a,c + xor %00000100 + ld c,a ;c has new frame + + ;store new location in object + pop hl ;hl is ptr to this + + ld a,e + ld [hl+],a + ld a,d + ld [hl-],a + + ;restore de + ld d,h + ld e,l + + pop hl + +.stowNewFrame + ;if IsSprite bit off, check to see if we want to turn + ;it on + bit 7,c + jr nz,.spriteBitIsOn + + ld a,[bgFlags] + and BG_FLAG_SPECIAL + jr z,.reallyStowNewFrame + + set 7,c ;turn sprite flag on + ;call AllocateSprite + ;call StoreSpriteLo + jr .reallyStowNewFrame + +.spriteBitIsOn + ;can we turn it off? + bit 2,c ;is frame bit zero? + jr nz,.updateSpritePos ;no, leave it on + + ;maybe turn it off; see what we're over + push hl + call GetCurLocation + ld a,MAPBANK + ld [$ff70],a + ld a,[hl] + push af + ld a,OBJBANK + ld [$ff70],a + pop af + pop hl + + or a + jr nz,.updateSpritePos ;leave it on + + res 7,c ;turn it off + call FreeSpriteLoPtr + jr .reallyStowNewFrame + +.updateSpritePos + ;since the sprite has been on let's scoot the sprite 4 + ;pixels in the direction we've moved + + call GetSpriteLo + call ScootSprite + +.reallyStowNewFrame + ld a,OBJBANK + ld [$ff70],a + ld a,c ;new frame + ld [hl],a + + ;if oldZone != curZone then set curPathPos to zero + call GetCurZone + ld hl,oldZone + cp [hl] + jr z,.done + + call ResetCurPathPos + +.done pop bc + ret + +;--------------------------------------------------------------------- +; Routine: RemoveFromMap +; Arguments: c - current frame +; de - "this" +; Returns: Nothing +; Alters: af +; Description: Removes the this object's class index from the main +; map buffa +;--------------------------------------------------------------------- +RemoveFromMap:: + push bc + push de + push hl + + call GetCurLocation + + ;is object currently a sprite? + bit 7,c + jr nz,.clearSprite + + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + + ldio a,[curObjWidthHeight] + cp 2 + jr z,.clear2x2tiles + + ;clear out this location + xor a + ld [hl+],a + + ;if we were a split tile then clear out the next one to the + ;right OR to the bottom + bit 2,c + jr z,.done + + bit 0,c + jr z,.splitNS + + ;split E/W + ld [hl+],a ;clear out the next location too, sucka + jr .done + +.splitNS + ;scoot HL down a row + ld d,0 + ld a,[mapPitchMinusOne] + ld e,a + add hl,de + ld [hl],d ;clear 'em all + jr .done + +.clearSprite + call .getTilePreviouslyHere + + ;if we were a split tile then clear out the next one to the + ;right OR to the bottom + bit 2,c + jr z,.done + + bit 0,c + jr z,.spriteSplitNS + + ;split E/W + inc hl + call .getTilePreviouslyHere + jr .done + +.spriteSplitNS + ;scoot HL down a row + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + call .getTilePreviouslyHere + +.done pop hl + pop de + pop bc + ret + +.getTilePreviouslyHere + ld a,TILESHADOWBANK + ld [$ff70],a + + ld b,[hl] + + ld a,MAPBANK + ld [$ff70],a + + ld [hl],b + + ret + +.clear2x2tiles + push hl + call .clear2x2row + pop hl + call HLToNextRow + push hl + call .clear2x2row + pop hl + ld a,c + and %00000101 + cp %00000100 + jr nz,.done2x2 + call HLToNextRow + call .clear2x2row + +.done2x2 + pop hl + pop de + pop bc + ret + +.clear2x2row + xor a + ld [hl+],a + ld [hl+],a + ld a,c + and %00000101 + xor %00000101 + ret nz + ld [hl+],a + ret + +;--------------------------------------------------------------------- +; Routine: CheckDestEmpty +; Arguments: b - desired direction +; de - "this" +; a - 0=don't consider facing, 1=consider facing +; +; Returns: a - dest is empty +; !a - dest is not empty +; Alters: a, hl +; Description: Checks along direction of travel for empty tile +;--------------------------------------------------------------------- +CheckDestEmpty: + ld [temp],a + + xor a + ld [bgFlags],a + + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + + ;load cur frame into a + ld hl,2 + add hl,de + ld a,[hl] + + ;don't bother if split bit is set, we're fine + bit 2,a + ret nz + + ;and don't bother if direction of travel is not equal to + ;current facing (just turning) + ld a,[temp] + or a + jr z,.check + ld a,[hl] + + and %00000011 + cp b + jr z,.check + ld a,1 ;set return value A to non-zero + ret + +.check + push de + push hl + + ;setup de with ptr to current location + ld h,d + ld l,e + ld a,[hl+] + ld d,[hl] + ld e,a ;de has ptr to cur location + + ld a,MAPBANK ;select map RAM + ldio [$ff70],a + + call GetMapOffset + + ;don't examine my tail in the process; multiply offset + ;by two if 2x2 and facing east or south + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.afterModifyOffset + + ld a,b + and %00000011 + cp %01 ;east + jr z,.offsetTimesTwo + cp %10 ;south + jr nz,.afterModifyOffset + +.offsetTimesTwo + sla l ;hl<<=1 (same as *2) + rl h + +.afterModifyOffset + add hl,de ;hl is ptr to new location + + ldio a,[curObjWidthHeight] + cp 2 + jr z,.check2x2 + + ;check 1x1 + ld a,[hl] ;contents of dest into a + call .checkCanMoveOver + pop hl + pop de + ret + +.check2x2 + ;check first adjacent tile + ld a,[hl] + call .checkCanMoveOver + or a + jr z,.done ;blocked on first, no use checking second + + ;first clear; check second adj tile + ld a,b + and 1 ;now 0=n/s, 1=e/w + add 1 ;now check adj in e for original n/s, s for e/w + call AdvanceLocHLInDirection + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call .checkCanMoveOver + +.done pop hl + pop de + ret + +.checkCanMoveOver + or a ;zero? + jr nz,.checkSpecialFlags + ld a,1 ;return true + ret + +.checkSpecialFlags + ld e,a + ldio a,[firstMonster] + cp e + jr z,.false ;is a monster + jr c,.false ;is a monster + + ld a,TILEINDEXBANK + ld [$ff70],a + ld d,((bgAttributes>>8) & $ff) + ld a,[de] + ld [bgFlags],a + and BG_FLAG_WALKOVER + jr z,.false + + ldio a,[curObjWidthHeight] + cp 1 + jr nz,.false + + ;return true + ld a,1 + ret + +.false xor a ;return false + ret + +;--------------------------------------------------------------------- +; Routines: GetMapOffset +; Arguments: b - map direction to get offset in +; Returns: hl - desired offset +; Alters: a, hl +;--------------------------------------------------------------------- +GetMapOffset: + ld a,b ;desired dir + add b ;times two + ld hl,mapOffsetNorth + add l + ld l,a ;hl pts to offset + ld a,[hl+] + ld h,[hl] + ld l,a ;hl IS offset + ret + +;--------------------------------------------------------------------- +; Routines: TestMove +; HeroTestMove +; Arguments: a - value to reset counter to if it reaches zero +; de - "this" +; Returns: a - time to move +; !a - don't move +; Alters: a,hl +; Description: +;--------------------------------------------------------------------- +TestMove: + push af + call PointToSpecialFlags + bit OBJBIT_THROWN,[hl] + jr nz,TestMoveThrown + pop af + +TestMoveNoCheckSpecial: + push bc + ld c,a + + ld a,[objTimer60ths] ;get timer + and %00011000 ;get rid of other bits + ld b,a + ld hl,OBJ_FRAME ;offset of frame variable + add hl,de + xor a,[hl] ;xor timer4:3 w/frame4:3, hl=&move + + push af + ld a,[hl] ;current state + and %11100111 ;mask off area for timer + or b ;store bits from current timer + ld [hl],a + pop af + and %00011000 ;get rid of other bits + jr z,.skipMove ;already moved this turn + + push bc + inc hl + + dec [hl] + + jr z,.timeToMove + + ;no move but save modified timer + pop bc + pop bc + xor a + ret + +.timeToMove + ;time to move! + push hl + ld hl,OBJ_DESTZONE ;point to # puffs + add hl,de + ld a,[hl] + and %1111 + pop hl + add a,c ;reset move counter (add #puffs) + + ;or b + ld [hl-],a + + pop bc + + ld a,1 ;return true/able to move + +.skipMove + pop bc + ret + +HeroTestMove: + push af + call PointToSpecialFlags + bit OBJBIT_THROWN,[hl] + jr nz,TestMoveThrown + pop af + + push bc + ld c,a + + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + + ld a,[heroTimer60ths] ;get timer + and %00011000 ;get rid of other bits + ld b,a + ld hl,OBJ_FRAME ;offset of frame variable + add hl,de + xor a,[hl] ;xor timer4:3 w/frame4:3, hl=&move + push af + ld a,[hl] ;current state + and %11100111 ;mask off area for timer + or b ;store bits from current timer + ld [hl],a + pop af + and %00011000 ;get rid of other bits + jr z,.skipMove ;already moved this turn + + push bc + inc hl + + dec [hl] + + jr z,.timeToMove + + ;no move but save modified timer + pop bc + pop bc + xor a + ret + +.timeToMove + ;time to move! + push hl + ld hl,OBJ_DESTZONE ;point to # puffs + add hl,de + ld a,[hl] + and %1111 + pop hl + add a,c ;reset move counter (add #puffs) + + ld [hl-],a + pop bc + + ld a,1 ;return true/able to move + +.skipMove + pop bc + ret + +TestMoveThrown: + ;move one in current facing and return "unable to move" + pop af + ld a,1 + call TestMoveNoCheckSpecial + or a + ret z + + ldio a,[firstMonster] + ld b,a + ld a,4 + call GetLocInFront + or a + jr z,.emptyAhead + + cp b + jr nc,.stop + + ld a,[bgFlags] + bit BG_BIT_WALKOVER,a + jr z,.stop + + ldio a,[curObjWidthHeight] + cp 1 + jr z,.emptyAhead + +.stop call PointToSpecialFlags + res OBJBIT_THROWN,[hl] + ld a,[hero0_index] + cp c + jr z,.heroJiggle + ld a,[hero1_index] + cp c + jr z,.heroJiggle + xor a + ret + +.heroJiggle + ld a,5 + ldio [jiggleDuration],a + xor a + ret + +.emptyAhead + call GetCurLocation + push hl + call GetFacing + and %111 + ld b,a + push bc + and %11 + ld b,a + call StandardValidateMoveAndRedraw + pop bc + pop hl + + ;check if way blocked after all (2x2 monster) + call GetFacing + and %111 + cp b + jr nz,.done + ld a,[de] + cp l + jr nz,.done + inc de + ld a,[de] + dec de + cp h + jr z,.stop + +.done + xor a + ret + +;--------------------------------------------------------------------- +; Routines: StdVectorToState +; EatVectorToState +; TrackEnemyVectorToState +; ActorVectorToState +; FleeVectorToState +; Arguments: de - "this" +; Returns: b - direction to move +; a - non-zero for move valid, zero for no move +; Alters: a, b, hl +;--------------------------------------------------------------------- +VectorToStateCommonInit: + call GetState + rlca + and %01111110 + ret + +StdVectorToState: + call VectorToStateCommonInit + add (stdStateTable & $ff) + ld l,a + ld h,((stdStateTable>>8) & $ff) +VectorToStateCommon: + ld a,[hl+] + ld h,[hl] + ld l,a + jp hl + +EatVectorToState: + call VectorToStateCommonInit + add (eatStateTable & $ff) + ld l,a + ld h,((eatStateTable>>8) & $ff) + jr VectorToStateCommon + +TrackEnemyVectorToState: + call VectorToStateCommonInit + add (trackEnemyStateTable & $ff) + ld l,a + ld h,((trackEnemyStateTable>>8) & $ff) + jr VectorToStateCommon + +ActorVectorToState: + call VectorToStateCommonInit + add (actorStateTable & $ff) + ld l,a + ld h,((actorStateTable>>8) & $ff) + jr VectorToStateCommon + +FleeVectorToState: + call VectorToStateCommonInit + add (fleeStateTable & $ff) + ld l,a + ld h,((fleeStateTable>>8) & $ff) + jr VectorToStateCommon + +LadyVectorToState: + call VectorToStateCommonInit + add (ladyBulletStateTable & $ff) + ld l,a + ld h,((ladyBulletStateTable>>8) & $ff) + jr VectorToStateCommon + +;--------------------------------------------------------------------- +; STATE METHODS +; Arguments: de - "this" +; Returns: b - direction to move +; a - non-zero for move valid, zero for no move +; Alters: a, b, hl +;--------------------------------------------------------------------- +SetupRandomMoveState: + ld a,6 + call SetState + xor a + ret + +EatOrTrackState: + ;move in direction of food next to me + ld b,0 +.checkDirectionForFood + ld a,b + call GetLocInFront + or a + jr z,.continue + + push bc + push hl + ld b,a + call GetDestL ;min index I can eat + cp b + jr z,.maybeFood + jr nc,.notFood +.maybeFood + call GetDestH ;max index I can eat + cp b + jr nc,.food + +.notFood + pop hl + pop bc + jr .continue + + +.food + pop hl + pop bc + + ;remove tile in direction I'm facing that way and I'm not split + call GetFacing + bit 2,a + jr nz,.foundFood + + and %11 + cp b + jr nz,.foundFood + + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl],a + + ld hl,eatSound + call PlaySound + +.foundFood + ld a,1 ;b contains valid move + ret + +.continue + inc b + ld a,b + cp 4 + jr nz,.checkDirectionForFood + + jp TrackEnemyVectorToState ;no food around, track hero + +SetupTrackEnemy: + call GetCurZone + ld b,a + ;Use bit 5 of my object address to determine which hero + ;to try and follow. + ld a,e + swap a + and %10 ;from %00 or %10 we get... + ld h,a + rrca + xor %01 + or h ;%01 or %10 + call GetHeroZone + cp b + jr z,.inSameZone + + call SetDestZone + ld a,1 + call SetState + xor a + ret + +.inSameZone + ;ld a,1 ;bit of slack + xor a ;no slack + jp MoveToLocation + +;return zero for no move +SetupMoveToLoc: + call GetActorDestLoc + ld a,h + or a + jr nz,.moveToLoc + ;ret z ;no dest loc + + ;1/32 chance of face random direction + ld a,31 + call GetRandomNumMask + or a + jr z,.faceRandom + + xor a + ret + +.faceRandom + call GetFacing + bit 2,a + ret nz ;don't change dir if split + and %11111000 + ld b,a + ld a,3 + call GetRandomNumMask + or b + call SetFacing + call StandardRedraw + xor a + ret + +.moveToLoc + push hl + call GetCurZone + pop hl + ld b,a + + call GetActorDestZone + cp b + jr z,.inSameZone + + call SetDestZone + ld a,1 + call SetState + xor a + ret + +.inSameZone + call GetActorDestLoc + xor a + ld [moveAlignPrecision],a + call AmAtLocation + or a + jr z,.findLocation + + ld hl,0 + call SetActorDestLoc + + ;call GetFacing + ;and %11111011 ;set split bit to zero + ;call SetFacing + + xor a + + ret + +.findLocation + xor a ;no slack + ld [moveAlignPrecision],a + jp MoveToLocation + + +MoveToZone: + ;------------------------------------------------------------- + ; State 1: MOVE TOWARDS DEST ZONE + ; if (curZone == destZone){ + ; this->state = 0; + ; }else{ + ; nextWayPoint=GetNextWayPoint(curZone,destZone); + ; if(this->pos == nextWayPoint){ + ; curPathPos++; + ; }else{ + ; int r = ChooseDirection(nextWayPoint, &dir); + ; if(!r){ + ; this->moveLimit = 3; + ; this->majorAxis = dir:7; + ; this->state = 2; //try to the right + ; } + ; return r; + ; } + ; } + ; return 0; + ;------------------------------------------------------------- + call GetCurZone + ld b,a ;save curZone + call GetDestZone + + ;if(curZone==destZone) + cp b + jr nz,.cur_NE_dest + + xor a + call SetState + xor a + ret + +.cur_NE_dest + swap a + or b ;destZone in 7:4, curZone in 3:0 + call GetNextWayPoint ;returns next WP loc in hl + xor a + cp h + jr nz,.validWayPoint + cp l + jr nz,.validWayPoint + + ;invalid way point, try just moving towards hero w/dumb ai + ;Use bit 5 of my object address to determine which hero + ;to try and follow. + ld a,e + swap a + and %10 ;from %00 or %10 we get... + ld h,a + rrca + xor %01 + or h ;%01 or %10 + call GetHeroZone + xor a ;no slack + jp MoveToLocation + +.validWayPoint + call AmAtLocation + or a + jr z,.moveToLocation + + call IncrementPathPos ;at next waypoint, increment waypoint + xor a + ret + +.moveToLocation + ld a,1 ;cut some slack on alignment +MoveToLocation: + ;use "dumb-AI" to move towards waypoint + ;hl should be destination location + call ChooseDirection ;args hl=curWP + ;returns a=1 on success, b=dir + or a + jr z,.decideDirectionLeftOrRight + + ;success! + ret + +.decideDirectionLeftOrRight + ld a,b + call SetDesiredDirection + ld a,6 + call SetMoveLimit + call GetMoveRightOfDesiredDir + or a + jr z,.tryLeft ;try left if no exit to right + + ld a,[secondChoiceDirection] + cp b + jr z,.tryRight ;right matches our second choice + +.tryLeft ;try left then right + ld a,8 + call SetState + xor a + ret + + +.tryRight + ;set critter to try along its right for a while + ld a,2 + call SetState + xor a + ret + +TryRight: + ;------------------------------------------------------------- + ; State 2: MOVE RIGHT TO LOOK FOR PASSAGE + ;------------------------------------------------------------- + call GetMoveRightOfDesiredDir + or a + jr z,.changeState2To4 ;can't move right + + ;if move limit has expired switch to looking left + call DecrementMoveLimit + or a + jr z,.changeState2To4 + +.moveRightCheckForward + ld a,3 ;check for forward passage next + call SetState + ld a,1 + ret + +.changeState2To4 + ld a,15 + call SetMoveLimit + ld a,4 + call SetState + xor a + ret + +TryFwdAfterRight: + ;------------------------------------------------------------- + ; State 3: JUST MOVED RIGHT, CHECK FOR FORWARD PASSAGE + ;------------------------------------------------------------- + call CheckForwardPassage + or a + jr nz,.changeState3ToState7 + + ld a,2 + call SetState + xor a + ret + +.changeState3ToState7 + ;passage exists, MF twice (once to turn, once to move) + ld a,7 + call SetState + ld a,1 + ret + +TryLeft: + ;------------------------------------------------------------- + ; State 4: MOVE LEFT CHECKING FOR FORWARD PROGRESS + ;------------------------------------------------------------- + call GetMoveLeftOfDesiredDir + or a + jr z,.changeState4To6 ;can't move left, move random + + ;if move limit has expired switch to moving random + call DecrementMoveLimit + or a + jr z,.changeState4To6 + + ld a,5 ;check for forward passage next + call SetState + ld a,1 + ret + +.changeState4To6 +ChangeToStateRandom: + ld a,15 + call SetMoveLimit + ld a,6 + call SetState + xor a + ret + +TryFwdAfterLeft: + ;------------------------------------------------------------- + ; State 5: CHECK FORWARD AFTER HAVING MOVED LEFT + ;------------------------------------------------------------- + call CheckForwardPassage + or a + jr nz,.changeState5ToState7 + + ld a,4 + call SetState + xor a + ret + +.changeState5ToState7 + ;passage exists, MF twice (once now to turn, once to move) + ld a,7 + call SetState + ld a,1 + ret + +RandomMove: + ;------------------------------------------------------------- + ; State 6: MOVE IN A RANDOM DIRECTION + ;------------------------------------------------------------- + call GetRandomMovement + + call DecrementMoveLimit + or a + jr z,.randomBackToState0 + ret + +.randomBackToState0 + ;a is zero + call SetState + ret + +MoveFwdThenState1: + ;------------------------------------------------------------- + ; State 7: Move Forward, Go to state 1 + ;------------------------------------------------------------- + ld a,1 + call SetState + call CheckForwardPassage + ret + +TryLeftFirst: + ;------------------------------------------------------------- + ; State 8: MOVE LEFT CHECKING FOR FORWARD PROGRESS + ;------------------------------------------------------------- + call GetMoveLeftOfDesiredDir + or a + jr z,.changeState8To10 ;can't move left, move right + + ;if move limit has expired switch to looking right + call DecrementMoveLimit + or a + jr z,.changeState8To10 + + ld a,9 ;check for forward passage next + call SetState + ld a,1 + ret + +.changeState8To10 + ;look to the right + ld a,15 + call SetMoveLimit + ld a,10 + call SetState + xor a + ret + +TryFwdAfterLeftFirst: + ;------------------------------------------------------------- + ; State 9: CHECK FORWARD AFTER HAVING MOVED LEFT + ;------------------------------------------------------------- + call CheckForwardPassage + or a + jr nz,.changeState9ToState7 + + ld a,8 ;go back to checking left + call SetState + xor a + ret + +.changeState9ToState7 + ;passage exists, MF twice (once now to turn, once to move) + ld a,7 + call SetState + ld a,1 + ret + +TryRightSecond: + ;------------------------------------------------------------- + ; State 10: MOVE RIGHT TO LOOK FOR PASSAGE + ;------------------------------------------------------------- + call GetMoveRightOfDesiredDir + or a + jr z,.changeState10To6 ;can't move right, move random + + ;if move limit has expired switch to moving random + call DecrementMoveLimit + or a + jr z,.changeState10To6 + +.moveRightCheckForward + ld a,11 ;check for forward passage next + call SetState + ld a,1 + ret + +.changeState10To6 + ld a,15 + call SetMoveLimit + ld a,6 + call SetState + xor a + ret + +TryFwdAfterRightSecond: + ;------------------------------------------------------------- + ; State 11: JUST MOVED RIGHT, CHECK FOR FORWARD PASSAGE + ;------------------------------------------------------------- + call CheckForwardPassage + or a + jr nz,.changeState11ToState7 + +.keepGoing + ld a,10 + call SetState + xor a + ret + +.changeState11ToState7 + ;passage exists, MF twice (once to turn, once to move) + ld a,7 + call SetState + ld a,1 + ret + +NoMove: + ;------------------------------------------------------------- + ; Default: RETURN "NO MOVE" + ;------------------------------------------------------------- + xor a + ret + +;--------------------------------------------------------------------- +; Routine: GetCurZone +; Arguments: de - "this" +; Returns: a - ID of current zone +; hl - current location +; Alters: a, hl +;--------------------------------------------------------------------- +GetCurZone:: + call GetCurLocation + + ld a,ZONEBANK ;select zone RAM parallel to map ram + ldio [$ff70],a + + ld a,[hl] ;A is curZone + and $0f + ret +;--------------------------------------------------------------------- +; Routine: GetHeroZone +; Arguments: a - prefer which hero? 1=Hero0, 2=Hero1, 0/3=Either +; de - "this" +; Returns: a - ID of zone hero is in +; hl - current location +; Alters: a, hl +;--------------------------------------------------------------------- +GetHeroZone: + push de + + ld d,a + ld a,[heroesPresent] + and d + jr z,.pickFirstAvailable + cp 3 + jr c,.getChosenHero + +.pickFirstAvailable + ld a,[heroesPresent] + and %01 + jr nz,.getChosenHero + + ld a,%10 + +.getChosenHero + ;a has the valid, desired hero %10 or %01. + ld hl,hero0_object + cp %01 ;do we want hero 0? + jr z,.haveHeroObjAddr + + ld l,(hero1_object & $ff) ;we want hero 1 + +.haveHeroObjAddr + ;Load the Hero object + ld a,[hl+] ;heroX_objectL + ld e,a + ld d,[hl] ;heroX_objectH + + call GetCurZone + pop de + ret + +;--------------------------------------------------------------------- +; Routine: GetState +; Arguments: de - "this" +; Returns: a - this->state +; hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +GetState: + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_STATE + add hl,de + ld a,[hl] + and %00111111 + ret + +;--------------------------------------------------------------------- +; Routine: SetState +; Arguments: de - "this" +; a - desired state +; Returns: hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +SetState:: + push bc + + and %00111111 + ld b,a + + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_STATE + add hl,de + + ld a,[hl] ;get old state + and %11000000 + or b + ld [hl],a ;save new state + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetAttackDirState +; Arguments: de - "this" +; Returns: a - 2-bit value[1:0] from this->state[7:6] +; hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +GetAttackDirState: + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_STATE + add hl,de + ld a,[hl] + + rlca + rlca + and %00000011 + ret + +;--------------------------------------------------------------------- +; Routine: SetAttackDirState +; Arguments: de - "this" +; a - desired state (lower 2 bits) +; Returns: hl - &this->state +; Alters: a, hl +; Description: Sets the upper two bits of "state" to be the value +; passed in. +;--------------------------------------------------------------------- +SetAttackDirState: + push bc + + rrca + rrca + and %11000000 + ld b,a + + call GetState + or b + ld [hl],a + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetDestZone +; Arguments: de - "this" +; a - desired dest zone +; Returns: hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +SetDestZone: + ld hl,OBJ_DESTZONE ;hl = &this->move + add hl,de + + push af + ld a,OBJBANK ;select object RAM + ld [$ff70],a + ld a,[hl] + and %00001111 ;mask off old zone + ld [hl],a + pop af + swap a ;destZone in 7:4 + or [hl] ;combine with move + ld [hl],a ;save in move + + ret + +;--------------------------------------------------------------------- +; Routine: GetDestZone +; Arguments: de - "this" +; Returns: a - dest zone +; hl - &this->destzone +; Alters: a, hl +;--------------------------------------------------------------------- +GetDestZone: + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_DESTZONE ;hl = &this->destzone + add hl,de + + ld a,[hl] ;get this->destzone + swap a + and %00001111 + ret + +;--------------------------------------------------------------------- +; Routine: GetPuffCount +; Arguments: de - "this" +; Returns: a - dest zone +; hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +GetPuffCount:: + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_DESTZONE ;hl = &this->state + add hl,de + + ld a,[hl] ;get this->state + and %00001111 + ret + +;--------------------------------------------------------------------- +; Routine: SetPuffCount +; Arguments: a - # of puffs +; de - "this" +; Returns: a - dest zone +; hl - &this->state +; Alters: a, hl +;--------------------------------------------------------------------- +SetPuffCount:: + push bc + ld b,a + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_DESTZONE ;hl = &this->state + add hl,de + + ld a,[hl] + and %11110000 + or b + ld [hl],a ;get this->state + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetNextWayPoint +; Arguments: de - "this" +; a - curZone[7:4], destZone[3:0] +; Returns: hl - position of next waypoint +; Alters: a, hl +; C Code: +; int curPath = pathMatrix[curZone][destZone]; +; int curWPIndex = pathList[curPath][this->pathPos]; +; int nextWayPoint = wayPointList[curWPIndex]; +; return nextWayPoint +;--------------------------------------------------------------------- +GetNextWayPoint: + push bc + + ld b,0 + ld c,a ;BC gets index to array + + call GetPathPos + push de + ld d,0 + ld e,a ;E gets pathPos + + ld a,WAYPOINTBANK ;select object list RAM + ld [$ff70],a + + ld hl,pathMatrix + add hl,bc + ld a,[hl] ;A = curPath + ld c,a ;Setup curPath*4 as offset into + xor a ; pathlist + sla c + rla + sla c + rla + ld b,a ;bc = curPath*4 + ld hl,pathList + add hl,bc ;hl = &pathList[curPath] + add hl,de ;hl = &pathList[curPath][pathPos] + ld a,[hl] ;a = curWPIndex + ld c,a ;offset into WP list = curWPIndex*2 + xor a + sla c + rla + ld b,a ;bc = offset + ld hl,wayPointList + add hl,bc + ld a,[hl+] ;low byte of waypoint location + ld h,[hl] ;high byte + ld l,a ;hl is location of next waypoint + + pop de + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetPathPos +; Arguments: de - "this" +; Returns: a - current path position (0-3) +; hl - &this->frame +; Alters: a, hl +;--------------------------------------------------------------------- +GetPathPos: + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_FRAME + add hl,de + + ld a,[hl] ;get frame var + swap a + rrca + and %00000011 ;get pathPos in 1:0 + ret + +;--------------------------------------------------------------------- +; Routine: AmAtLocation +; Arguments: de - "this" +; hl - a location +; [moveAlignPrecision] +; Returns: a - 1 if this->loc == location, 0 if not +; Alters: a +; Note: Compares X,Y coordinates +/- [moveAlignPrecision] +;--------------------------------------------------------------------- +AmAtLocation:: + push bc + push de + push hl + + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ;not there if split bit is set + call GetFacing + and %100 + ld a,0 + jr nz,.done + + ;cur loc in bc + ld a,[de] ;low byte of cur pos + inc de + ld c,a + ld a,[de] ;high byte + ld b,a + + ;dest XY in de + call ConvertLocHLToXY + ld d,h + ld e,l + + ;cur XY in hl + ld h,b + ld l,c + call ConvertLocHLToXY + + ;compare sourceX to destX +/- 1 + ;ld a,h + ;add 1 + + ld a,[moveAlignPrecision] ;x + precision + add h + cp d + jr c,.returnFalse + + ;sub 3 + ld a,[moveAlignPrecision] ;x - precision + cpl + add 1 + add h + cp d + jr z,.checkY + jr nc,.returnFalse + +.checkY + ;compare sourceY to destY +/- 1 + ld a,[moveAlignPrecision] ;y + precision + add l + cp e + jr c,.returnFalse + + ld a,[moveAlignPrecision] ;y - precision + cpl + add 1 + add l + cp e + jr z,.returnTrue + jr nc,.returnFalse + +.returnTrue + ld a,1 + jr .done + +.returnFalse + xor a +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: IsActorAtDest +; Arguments: de - "this" +; Returns: a - 1 if actor stopped moving, 0 if not +; Alters: af +;--------------------------------------------------------------------- +IsActorAtDest:: + push hl + call GetActorDestLoc + ld a,h + or a + jr z,.returnTrue + + xor a + pop hl + ret + +.returnTrue + ld a,1 + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: ResetCurPathPos +; Arguments: de - "this" +; Returns: Nothing +; Alters: a,hl +; Description: Sets curPathPos (bits 6:5 of this->frame) to zero +;--------------------------------------------------------------------- +ResetCurPathPos: + ld a,OBJBANK ;select object RAM + ld [$ff70],a + + ld hl,OBJ_FRAME + add hl,de + + ld a,[hl] + and %10011111 + ld [hl],a + + ret + + +;--------------------------------------------------------------------- +; Routine: IncrementPathPos +; Arguments: de - "this" +; Returns: Nothing +; Alters: a,hl +; Description: Adds 1 to bits 6:5 of this->frame, preserving others +;--------------------------------------------------------------------- +IncrementPathPos: + ld a,OBJBANK ;select object RAM + ld [$ff70],a + ld hl,OBJ_FRAME + add hl,de + ld a,[hl] + bit 7,a + jr nz,.bit7WasOne + + add %00100000 + res 7,a + ld [hl],a + ret + +.bit7WasOne + add %00100000 + set 7,a + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: ChooseDirection +; Arguments: [moveAlignPrecision] 0=go to exact spot, 1=+/-1 +; de - "this" +; hl - location of destination +; Returns: a - 1 for valid move, 0 for no move +; b - direction of desired move (N,E,S,W) +; Alters: a,b,hl +; Description: Converts current "source" location and destination +; location into x,y coordinates, then picks a direction +; based on the following "dumb-AI" algorithm: +; +; int order = GetDirectionAttemptOrder(sx,sy,dx,dy); +; if(CheckDestEmpty(order[0])) +; { dir = order[0]; return 1;} +; return 0; +;--------------------------------------------------------------------- +ChooseDirection: + push bc + push de + + ld [moveAlignPrecision],a + + call ConvertLocHLToXY + push hl + + call GetCurLocation ;into hl + + call ConvertLocHLToXY + ld b,h + ld c,l + pop de ;source in bc, dest in de + + call GetDirectionAttemptOrder ;check order in A + + pop de ;retrieve ptr to this + + ;check first direction + rlca ;get first direction in 1:0 + rlca + ld c,a + and %00000011 ;mask off other choices + ld b,a + xor a + call CheckDestEmpty + or a ;check result + jr z,.checkDir2 + +.foundDirection + ld a,b ;setup b with direction, return 1 + pop bc + ld b,a + ld a,1 + ret + +.checkDir2 + ld a,c + rlca ;get second direction in 1:0 + rlca + ld c,a + and %00000011 ;mask off other choices + ld [secondChoiceDirection],a ;save for left/right decision + + ;ld b,a + ;xor a + ;call CheckDestEmpty + ;or a ;check result + ;jr z,.checkDir3 + + ;foundDirection + ;ld a,b ;setup b with direction, return 1 + ;pop bc + ;ld b,a + ;ld a,1 + ;ret + +.checkDir3 + ;ld a,c + ;rlca ;get third direction in 1:0 + ;rlca + ;ld c,a + ;and %00000011 ;mask off other choices + ;ld b,a + ;xor a + ;call CheckDestEmpty + ;or a ;check result + ;jr z,.checkDir4 + + ;foundDirection + ;ld a,b ;setup b with direction, return 1 + ;pop bc + ;ld b,a + ;ld a,1 + ;ret + +.checkDir4 + ;no direction found, load b with desired direction and return + ;false + ld a,b + pop bc + ld b,a + xor a + ret + +;--------------------------------------------------------------------- +; Routine: GetDirectionAttemptOrder +; Arguments: de - x,y of destination +; bc - x,y of origin +; Returns: a - every two bits is a direction to attempt; +; [7:6] is the first direction and so on. +; Alters: a,hl +; Description: Based off the following formula: +; +; if(sx>=dx-2){ +; if(sy < dy) order = SWEN; +; else order = NEWS; +; }else if(sy==dy){ +; if(sx < dx) order = ESNW; +; else order = WNSE; +; }else{ +; offset_x = abs(sx - dx); +; offset_y = abs(sy - dy); +; if(offset_x < offset_y){ //close horizontal gap +; if(sx < dx){ +; if(sy < dy) order = ESWN; +; else order = ENWS; +; }else{ +; if(sy < dy) order = WSEN; +; else order = WNES; +; } +; }else{ //close vertical gap first +; if(sx < dx){ +; if(sy < dy) order = SENW; +; else order = NESW; +; }else{ +; if(sy < dy) order = SWNE; +; else order = NWSE; +; } +; } +; } +; +; Note: precision of "cur==dest" depends on current value +; stored in [moveAlignPrecision], e.g. value of 1 yields +; cur>=(dest-1) && cur<=(dest+1) +; e.g. (cur+1)>=dest && (cur-1)<=dest +;--------------------------------------------------------------------- +GetDirectionAttemptOrder: +IF 0 + ;if abs(dx-sx) <= 1 and abs(dy-sY)<=1 then set tolerance to + ;zero. dx-sx yields $ff, 0, or 1 - plus one gives 0, 1, or 2 + ld h,3 + ld a,b + sub d + cp h + jr nc,.afterSetAlignPrecision + + ld a,c + sub e + cp h + jr nc,.afterSetAlignPrecision + + xor a + ld [moveAlignPrecision],a + +.afterSetAlignPrecision +ENDC + ld h,0 + + ld a,[moveAlignPrecision] + add b + ;ld a,b + ;add 1 + cp d + jr c,.sx_LessThan_dx + + ld a,[moveAlignPrecision] + cpl + add 1 + add b + cp d + jr c,.sx_Equals_dx + jr z,.sx_Equals_dx + + ;sx > dx + jr .checkYCoords + +.sx_Equals_dx + set 3,h + jr .checkYCoords + +.sx_LessThan_dx + set 1,h + +.checkYCoords + ;ld a,c + ;add 1 + ld a,[moveAlignPrecision] + add c + cp e + jr c,.sy_LessThan_dy + + ld a,[moveAlignPrecision] + cpl + add 1 + add c + ;sub 3 + cp e + jr c,.sy_Equals_dy + jr z,.sy_Equals_dy + + ;sy>dy + jr .checkOffsets + +.sy_Equals_dy + set 2,h + jr .pickOrder + +.sy_LessThan_dy + set 0,h + +.checkOffsets + bit 3,h + jr nz,.pickOrder + + ;set bit 4 if abs(sx-dx) < abs(sy-dy) + ld a,b + cp d ;is sx < dx? + jr c,.subtract_sx_from_dx + + sub d + jr .getAbsY + +.subtract_sx_from_dx + ld a,d + sub b + +.getAbsY + ld l,a ;save abs(sx-dx) in l + ld a,c + cp e + jr c,.subtract_sy_from_dy + + sub e + jr .haveAbsValues + +.subtract_sy_from_dy + ld a,e + sub c + +.haveAbsValues + cp l ;is abs(sy-dy) < abs(sx-dx)? + jr nc,.pickOrder ;no, leave bit 4 alone + + set 4,h + +.pickOrder + ld a,h + add (.orderTable & $ff) + ld l,a + ld a,0 ;not xoring to leave the carry alone + adc ((.orderTable >> 8) & $ff) + ld h,a ;hl is &orderTable[directionFlags] + ld a,[hl] + ret + +.orderTable + ;first half of table is for closing x-distance first + DB %11000110 ;WNES 0000 sx > dx, sy > dy + DB %11100100 ;WSEN 0001 sx > dx, sy < dy + DB %01001101 ;ENWS 0010 sx < dx, sy > dy + DB %01101100 ;ESWN 0011 sx < dx, sy < dy + DB %11100001 ;WSNE 0100 sy==dy, sx > dx + DB %11100001 ;WSNE 0101 sy==dy, sx > dx (invalid) + DB %01001011 ;ENSW 0110 sy==dy, sx < dx + DB %01001011 ;ENSW 0111 sy==dy, sx < dx (invalid) + DB %00011110 ;NEWS 1000 sx==dx, sy > dy + DB %10110100 ;SWEN 1001 sx==dx, sy < dy + DB %00011110 ;NEWS 1010 sx==dx, sy > dy (invalid) + DB %10110100 ;SWEN 1011 sx==dx, sy < dy (invalid) + DB %00011110 ;NEWS 1100 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1101 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1110 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1111 sx==dx, sy==dy (invalid) + + ;second half of table is for closing y-distance first + DB %00111001 ;NWSE 0000 sx > dx, sy > dy + DB %10110001 ;SWNE 0001 sx > dx, sy < dy + DB %00011011 ;NESW 0010 sx < dx, sy > dy + DB %10010011 ;SENW 0011 sx < dx, sy < dy + DB %10110100 ;SWEN 0100 sy==dy, sx > dx + DB %10110100 ;SWEN 0101 sy==dy, sx > dx (invalid) + DB %00011110 ;NEWS 0110 sy==dy, sx < dx + DB %00011110 ;NEWS 0111 sy==dy, sx < dx (invalid) + DB %01001011 ;ENSW 1000 sx==dx, sy > dy + DB %11100001 ;WSNE 1001 sx==dx, sy < dy + DB %01001011 ;ENSW 1010 sx==dx, sy > dy (invalid) + DB %11100001 ;WSNE 1011 sx==dx, sy < dy (invalid) + DB %00011110 ;NEWS 1100 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1101 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1110 sx==dx, sy==dy (invalid) + DB %00011110 ;NEWS 1111 sx==dx, sy==dy (invalid) + +;--------------------------------------------------------------------- +; Routine: SetDesiredDirection +; Arguments: a - (0-3) - direction critter was trying to travel +; when it ran into a wall. +; Returns: Nothing +; Alters: a,hl +; Description: Sets bits 7:6 of this->health to be value passed in +;--------------------------------------------------------------------- +SetDesiredDirection: + push bc + + rrca + rrca + and %11000000 + ld b,a + + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + and %00111111 + or b + ld [hl],a + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: SetMoveLimit / SetFireDirection +; Arguments: a - move limit 0-15 +; Returns: Nothing +; Alters: a,hl +; Description: Sets bits 3:0 of the obj->misc to indicate how many +; moves should be made before changing to a new state +;--------------------------------------------------------------------- +SetMoveLimit: +SetFireDirection: + push bc + ld b,a + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_LIMIT + add hl,de + ld a,[hl] + and %11110000 + or b + ld [hl],a + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetMoveLimit / GetFireDirection +; Returns: a - value +; Alters: a,hl +; Description: Retrieves bits 3:0 of the obj->limit +;--------------------------------------------------------------------- +GetMoveLimit: +GetFireDirection: + ld a,OBJBANK ;select object RAM + ldio [$ff70],a + ld hl,OBJ_LIMIT + add hl,de + ld a,[hl] + and %00001111 + ret + +;--------------------------------------------------------------------- +; Routine: PointToSpecialFlags +; Arguments: de - this +; Returns: Nothing. +; Alters: a,hl +; Description: Sets HL to point to obj->limit. +;--------------------------------------------------------------------- +PointToSpecialFlags: + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_LIMIT + add hl,de + ret + +;--------------------------------------------------------------------- +; Routines: GetMoveRightOfDesiredDir +; GetMoveLeftOfDesiredDir +; Arguments: None. +; Returns: a - 0=no move, 1=move +; b - direction of move if move possible +; Alters: a,b,hl +; Description: Uses the value of this->desiredDirection to determine the +; direction to move right of the major axis. If that +; move is possible, returns 1 and the direction in b. +;--------------------------------------------------------------------- +GetMoveRightOfDesiredDir: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + + rlca + rlca + inc a ;"turn" right + and %00000011 + ld b,a + xor a + call CheckDestEmpty + ret + +GetMoveLeftOfDesiredDir: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + + rlca + rlca + dec a ;"turn" left + and %00000011 + ld b,a + xor a + call CheckDestEmpty + ret + +;--------------------------------------------------------------------- +; Routines: CheckForwardPassage +; Arguments: None. +; Returns: a - 0=no move, 1=move +; b - direction of move if move possible +; Alters: a,hl +; Description: Uses the value of this->desiredDirection along with +; current facing to determine the direction to move +; forward. +; Note: Returns zero if the creature is split between +; tiles (this->frame:2 == 1) +;--------------------------------------------------------------------- +CheckForwardPassage: + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_FRAME + add hl,de + + ;check for split tile first + ld a,[hl+] + and %00000100 + jr z,.continue + + xor a + ret + +.continue + inc hl ;state to misc + inc hl ;misc to health + ld a,[hl] ;get health byte + + rlca ;bits 7:6 have desired dir + rlca + and %00000011 + ld b,a + xor a + call CheckDestEmpty + ret + +;--------------------------------------------------------------------- +; Routines: DecrementMoveLimit +; Arguments: None. +; Returns: a - moves left = non-zero, no moves = 0 +; Alters: a,hl +; Description: Decrements bits 3:0 of this->misc +; Does not decrement if split across tiles +;--------------------------------------------------------------------- +DecrementMoveLimit: + push bc + + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME + add hl,de + + ld a,[hl+] ;check for split tiles + and %00000100 + jr z,.continue + + pop bc + ld a,1 + ret + +.continue + inc hl + ld a,[hl] + ld c,a + and %11110000 + ld b,a + ld a,c + dec a + and %00001111 + or b + ld [hl],a + and %00001111 ;set a to be zero/nonzero + + pop bc + ret + +BAInit: + push bc + push de + ld a,OBJBANK ;select object RAM + ld bc,8 + inc de + inc de + ld hl,.baInitTable + call MemCopy + pop de + pop bc + + ;setup baUpgrades + push bc + ld hl,baUpgrades + ld [hl],0 + ld bc,ITEM_BAHIGHIMPACT + call HasInventoryItem + jr z,.afterSetHighImpactBullets + set UPGRADE_BAHIGHIMPACT,[hl] +.afterSetHighImpactBullets + pop bc + + ;Load BA's bullet-type + call SaveFGTileInfo + ld a,HERO_BA_FLAG + call SetHeroTileSet + + ld de,classBABullet + ld hl,BABULLET_CINDEX + xor a + call LoadAssociatedClass + call GetAssociated + ld b,a + ld a,HERO_BA_FLAG + call SetHeroBulletIndex + + call RestoreFGTileInfo +.done + ret + +.baInitTable + DB 1,1,$0f,BA_MAX_HEALTH,0,0,0,GROUP_HERO + +BAPlayerCheck: + ld b,BA_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.noDirPressed + ;xor a + ;call SetMisc + +.checkButtons + call DecrementAttackDelay + or a + jr z,.done + + ;ld a,HERO_BA_FLAG + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + call GetFireDirection + ld b,a + cp 4 + jr nc,.noStrafe ;button not held down previously + +.strafeCheckSplit + ;can only fire if not split frame or firing perpendicular + call GetFacing + bit 2,a + jr z,.gotFireDirection + xor b + bit 0,a ;bit zero = 0 if parallel direction + jr z,.gotFireDirection + jr .forceMoveForward ;can't fire + +.noStrafe + call GetFacing + and %00000011 + ld b,a + call SetFireDirection + +.gotFireDirection + ld a,b + call GetLocInFront + push bc + push af + push hl + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + ld hl,baFireSound +IF UPGRADES + ld a,4 ;four points of damage +ELSE + ld a,2 ;two points of damage +ENDC + call StdFireBullet + ld a,22 + call SetAttackDelay + + pop hl + pop af + + ld b,a + ldio a,[firstMonster] + cp b + pop bc + jr z,.checkUpgrade + jr nc,.afterThrowMonster + +.checkUpgrade + ld a,[baUpgrades] + bit UPGRADE_BAHIGHIMPACT,a + jr z,.afterThrowMonster + + call ThrowObjAtHLInDirB + +.afterThrowMonster + jr .checkButtonB + +.forceMoveForward + call GetHeroMoved + ;ld a,[baMoved] + or a + jr nz,.checkButtonB + call GetFacing + and %00000011 + ld b,a + call PlayerValidateMoveAndRedraw + +.checkButtonB +.done + ret + +BAPlayerCheckSpace: + ld b,BA_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + ;can only move if in different direction than facing + ;and not opposite to fire direction + call GetFacing + and %11 + cp b + jr z,.checkButtons + + call GetFireDirection + cp 4 + jr nc,.move + + add 2 + and %11 + cp b + jr z,.checkButtons + +.move + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.noDirPressed + ;xor a + ;call SetMisc + +.checkButtons + call DecrementAttackDelay + or a + jp z,.done + + ;ld a,HERO_BA_FLAG + call GetHeroJoyInput + bit 4,a ;button A pressed? + jp z,.checkButtonB + + call GetFireDirection + ld b,a + cp 4 + jr nc,.noStrafe ;button not held down previously + +.strafeCheckSplit + ;can only fire if not split frame or firing perpendicular + call GetFacing + bit 2,a + jr z,.gotFireDirection + xor b + bit 0,a ;bit zero = 0 if parallel direction + jr z,.gotFireDirection + jr .forceMoveForward ;can't fire + +.noStrafe + call GetFacing + and %00000011 + ld b,a + call SetFireDirection + +.gotFireDirection + ld a,b + call GetLocInFront + push bc + push af + push hl + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + ld hl,baFireSound +IF UPGRADES + ld a,4 ;four points of damage +ELSE + ld a,2 ;two points of damage +ENDC + call StdFireBullet + ld a,22 + call SetAttackDelay + + ;reverse fire direction for travel direction + call GetFacing + and %11 + push af + + call GetCurLocation + ld a,b + add 2 + and %11 + push af + call ShiftObjectInDirection + call GetCurLocation + pop af + push af + call ShiftObjectInDirection + call GetCurLocation + pop af + call ShiftObjectInDirection + + call GetFacing + and %11111100 + ld b,a + pop af + or b + call SetFacing + call StandardRedrawNoCheckSprite + + pop hl + pop af + + ld b,a + ldio a,[firstMonster] + cp b + pop bc + jr z,.checkUpgrade + jr nc,.afterThrowMonster + +.checkUpgrade + ld a,[baUpgrades] + bit UPGRADE_BAHIGHIMPACT,a + jr z,.afterThrowMonster + + call ThrowObjAtHLInDirB + +.afterThrowMonster + jr .checkButtonB + +.forceMoveForward + call GetHeroMoved + ;ld a,[baMoved] + or a + jr nz,.checkButtonB + call GetFacing + and %00000011 + ld b,a + call PlayerValidateMoveAndRedraw + +.checkButtonB +.done + ret + +IF 0 +BAPlayerCheck: + ld b,BA_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.checkButtons + call DecrementAttackDelay + or a + jr z,.done + + ;ld a,HERO_BA_FLAG + call GetHeroJoyInput + bit 4,a ;button A pressed? + ret z + + call HeroSetupFireDirection + ret z + + ld a,b + call GetLocInFront + + push bc + push af + push hl + + ld hl,baFireSound +IF UPGRADES + ld a,4 ;four points of damage +ELSE + ld a,2 ;two points of damage +ENDC + call StdFireBullet + ld a,22 + call SetAttackDelay + + pop hl + pop af + + jr BAThrowMonster +.done + ret + +BAThrowMonster: + ld b,a + ldio a,[firstMonster] + cp b + pop bc + jr z,.checkUpgrade + ret nc + +.checkUpgrade + ld a,[baUpgrades] + bit UPGRADE_BAHIGHIMPACT,a + ret z + + call ThrowObjAtHLInDirB + ret +ENDC + +;--------------------------------------------------------------------- +; Routine: SetHeroBulletIndex +; Arguments: a - flag of hero (e.g. HERO_BA_FLAG) +; b - bullet index of hero +; Returns: Nothing. +; Alters: af +; Description: Stores the bullet index in the appropriate +; hero0_bullet_index or hero1_bullet_index. +;--------------------------------------------------------------------- +SetHeroBulletIndex: + push hl + ld hl,heroJoyIndex + and [hl] + ld a,b + jr nz,.useIndex1 ;note flags are still from AND + +.useIndex0 + ld [hero0_bullet_index],a + jr .done + +.useIndex1 + ld [hero1_bullet_index],a + +.done + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetHeroTileSet +; Arguments: a - flag of hero (e.g. HERO_BA_FLAG) +; Returns: Nothing. +; Alters: af +; Description: Sets [numFGTiles] to be either 6 or 26 depending on +; who's controlling the hero. Note that the original +; value of [numFGTiles] must be saved and restored +; separately. Also sets [fgDestPtr] and [numClasses] +;--------------------------------------------------------------------- +SetHeroTileSet: + push bc + push de + push hl + + ld hl,heroJoyIndex + and [hl] + jr nz,.secondTileSet + ld a,6 + ld bc,$9060 + ld d,1 + jr .pickedTileSet +.secondTileSet + ld a,26 + ld bc,$91a0 + ld d,3 +.pickedTileSet + ld [numFGTiles],a + ld a,c + ld [fgDestPtr],a + ld a,b + ld [fgDestPtr+1],a + ld a,[firstHero] + add d + ld [numClasses],a + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetHeroJoyInput +; Arguments: c - hero class index +; Returns: a - current input from [curJoy0] or [curJoy1] +; Alters: af +;--------------------------------------------------------------------- +GetHeroJoyInput: + ld a,[hero0_index] + cp c + jr nz,.useIndex1 + ld a,[curJoy0] + ret + +.useIndex1 + ld a,[curJoy1] + ret + +GetAssocJoyInput: + call GetAssociated + push bc + ld b,a + ld a,[hero0_index] + cp b + pop bc + jr nz,.useIndex1 + ld a,[curJoy0] + ret + +.useIndex1 + ld a,[curJoy1] + ret + + +;--------------------------------------------------------------------- +; Routine: SetHeroMoved +; Arguments: a - value to set to (1 or 0) +; c - class index of current hero +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +SetHeroMoved: + push af + ld a,[hero0_index] + cp c + jr nz,.useIndex1 + pop af + ld [hero0_moved],a + ret + +.useIndex1 + pop af + ld [hero1_moved],a + ret + +;--------------------------------------------------------------------- +; Routine: GetHeroMoved +; Arguments: c - class index of current hero +; Returns: a - "moved" value +; Alters: af +;--------------------------------------------------------------------- +GetHeroMoved: + ld a,[hero0_index] + cp c + jr nz,.useIndex1 + ld a,[hero0_moved] + ret + +.useIndex1 + ld a,[hero1_moved] + ret + +;--------------------------------------------------------------------- +; BS +;--------------------------------------------------------------------- +BSInit: + push bc + push de + push hl + + push bc + push de + ld a,OBJBANK ;select object RAM + ld bc,8 + inc de + inc de + ld hl,.bsInitTable + call MemCopy + pop de + pop bc + + + ;setup bsUpgrades + push bc + ld hl,bsUpgrades + ld [hl],0 + ld bc,ITEM_BSSHOOTFAST + call HasInventoryItem + jr z,.afterSetShootFast + set UPGRADE_BSSHOOTFAST,[hl] +.afterSetShootFast + pop bc + + ;Load BS's bullet-type + call SaveFGTileInfo + ld a,HERO_BS_FLAG + call SetHeroTileSet + + ld de,classBSBullet + ld hl,BSBULLET_CINDEX + xor a + call LoadAssociatedClass + call GetAssociated + ld b,a + ld a,HERO_BS_FLAG + call SetHeroBulletIndex + + call RestoreFGTileInfo + + pop hl + pop de + pop bc + ret + +.bsInitTable + DB 1,1,$0f,BS_MAX_HEALTH,0,0,0,GROUP_HERO + +BSPlayerCheck: + ld b,BS_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.checkButtons + call HeroCheckCanFire + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + call HeroSetupFireDirection + jr z,.checkButtonB + + ld hl,bsFireSound + ld a,1 ;one point of damage + call StdFireBullet + ld a,[bsUpgrades] + bit UPGRADE_BSSHOOTFAST,a + jr z,.shootSlow +.shootFast + ld a,10 + jr .setAttackD +.shootSlow + ld a,18 +.setAttackD + call SetAttackDelay + jr .checkButtonB + +.checkButtonB +.done + ret + +BSPlayerCheckSpace: + ld b,BS_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + ;can only move if in different direction than facing + ;and not opposite to fire direction + call GetFacing + and %11 + cp b + jr z,.checkButtons + + call GetFireDirection + cp 4 + jr nc,.move + + add 2 + and %11 + cp b + jr z,.checkButtons + +.move + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.checkButtons + call HeroCheckCanFire + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + call HeroSetupFireDirection + jr z,.checkButtonB + + ld hl,bsFireSound + ld a,1 ;one point of damage + call StdFireBullet + ld a,[bsUpgrades] + bit UPGRADE_BSSHOOTFAST,a + jr z,.shootSlow +.shootFast + ld a,10 + jr .setAttackD +.shootSlow + ld a,18 +.setAttackD + call SetAttackDelay + + ;reverse fire direction for travel direction + call GetFacing + and %11 + push af + + call GetCurLocation + ld a,b + add 2 + and %11 + push af + call ShiftObjectInDirection + call GetCurLocation + pop af + push af + call ShiftObjectInDirection + call GetCurLocation + pop af + call ShiftObjectInDirection + + call GetFacing + and %11111100 + ld b,a + pop af + or b + call SetFacing + call StandardRedrawNoCheckSprite + + ;call ThrowObjAtHLInDirB + + jr .checkButtonB + +.checkButtonB +.done + ret + +HeroCheckCanFire: + call DecrementAttackDelay + or a + ret z + + call GetAssociated ;has a gun? + or a + ret + +HeroSetupFireDirection: + call GetFireDirection + ld b,a + cp 4 + jr nc,.noStrafe ;button not held down previously + +.strafeCheckSplit + ;can only fire if not split frame or firing perpendicular + call GetFacing + bit 2,a + jr z,.gotFireDirection + xor b + bit 0,a ;bit zero = 0 if parallel direction + jr z,.gotFireDirection + jr .forceMoveForward ;can't fire + +.noStrafe + call GetFacing + and %00000011 + ld b,a + call SetFireDirection + +.gotFireDirection + ld a,b + call GetLocInFront + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + or a + ret + +.forceMoveForward + call GetHeroMoved + or a + jr nz,.done + call GetFacing + and %00000011 + ld b,a + call PlayerValidateMoveAndRedraw +.done + xor a + ret + + +;--------------------------------------------------------------------- +; HAIKU +;--------------------------------------------------------------------- +HaikuInit: + ld a,OBJBANK ;select object RAM + ld bc,8 + inc de + inc de + ld hl,.haikuInitTable + call MemCopy + ret + +.haikuInitTable + DB 3,1,$0f,HAIKU_MAX_HEALTH,0,0,0,GROUP_HERO + +HaikuPlayerCheck: + ;am I dead? + ld b,HAIKU_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + or a + jr z,.checkButtons + + call GetHeroJoyInput ;no attack if braking + bit JOY_B_BIT,a + jr nz,.checkButtons + + call HaikuHitObject + +.checkButtons + call DecrementAttackDelay + or a + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + ;clip to edges of map +;and (JOY_DOWN | JOY_A) +;cp (JOY_DOWN | JOY_A) +;jr nz,.skip +;ld b,b +;.skip + call GetFacing + and %11 + ld b,a + call AmAtEdgeInDirection + jr nz,.checkButtonB + + call GetFacing + and %00000011 + ld b,a + call GetLocInFront + ld a,b + call AdvanceLocHLInDirection + + call LocIsPassable + jr z,.checkButtonB + + ;haiku teleports two squares ahead + call GetFacing + push af + push bc + ld c,a + call RemoveFromMap + pop bc + call SetCurLocation + pop af + + push hl + res 2,a ;turn off split + bit 7,a ;sprite? + jr z,.afterFreeSprite + push af + call FreeSpriteLoPtr + pop af + res 7,a +.afterFreeSprite + call SetFacing + pop hl + + ;----BEGIN call MOVEOVER method + push bc + + ld a,[bgFlags] + ld b,a + push af + + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + + push af + ld a,b + bit BG_BIT_WALKOVER,a + jr z,.afterSetSpriteBit + call GetFacing + set 7,a + call SetFacing +.afterSetSpriteBit + call StandardRedrawNoCheckSprite + pop af + + ld c,a + pop af + bit BG_BIT_WALKOVER,a + jr z,.afterAction + ld a,BGACTION_MOVEOVER + call CallBGAction +.afterAction + + pop bc + ;----END call MOVEOVER method + + ld a,15 + call SetAttackDelay + jr .checkButtonB + +.forceMoveForward +.checkButtonB +.done + ret + +HaikuPlayerCheckSpace: + ;am I dead? + ld b,HAIKU_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + ;can only move if in different direction than facing + ;or object in front + ld a,4 + call GetLocInFront + or a + jr nz,.move + + call GetFacing + and %11 + cp b + jr z,.checkButtons + +.move + call PlayerValidateMoveAndRedraw + or a + jr z,.checkButtons + + call GetHeroJoyInput ;no attack if braking + bit JOY_B_BIT,a + jr nz,.checkButtons + + call HaikuHitObject + +.checkButtons + call DecrementAttackDelay + or a + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + ;clip to edges of map + call GetFacing + and %11 + ld b,a + call AmAtEdgeInDirection + jr nz,.checkButtonB + + call GetFacing + and %00000011 + ld b,a + call GetLocInFront + ld a,b + call AdvanceLocHLInDirection + + call LocIsPassable + jr z,.checkButtonB + + ;haiku teleports two squares ahead + call GetFacing + push af + push bc + ld c,a + call RemoveFromMap + pop bc + call SetCurLocation + pop af + + push hl + res 2,a ;turn off split + bit 7,a ;sprite? + jr z,.afterFreeSprite + push af + call FreeSpriteLoPtr + pop af + res 7,a +.afterFreeSprite + call SetFacing + pop hl + + ;----BEGIN call MOVEOVER method + push bc + + ld a,[bgFlags] + ld b,a + push af + + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + + push af + ld a,b + bit BG_BIT_WALKOVER,a + jr z,.afterSetSpriteBit + call GetFacing + set 7,a + call SetFacing +.afterSetSpriteBit + call StandardRedrawNoCheckSprite + pop af + + ld c,a + pop af + bit BG_BIT_WALKOVER,a + jr z,.afterAction + ld a,BGACTION_MOVEOVER + call CallBGAction +.afterAction + + pop bc + ;----END call MOVEOVER method + + ld a,15 + call SetAttackDelay + jr .checkButtonB + +.forceMoveForward +.checkButtonB +.done + ret + +HaikuHitObject: + ;attack forward + call GetFacing + and %00000011 + ld b,a + ld [fireBulletDirection],a + ld a,4 + call GetLocInFront + ld a,MAPBANK + ldio [$ff70],a + + ldio a,[firstMonster] + ld b,a + ld a,[hl] + cp b + jr nc,.hitMonster + +.hitAttackableWall + call HitWall + jr .afterHit + +.hitMonster + ld b,a ;index of monster being hit + + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + ld a,1 ;one point of damage + ld [methodParamL],a + + ldio a,[curObjWidthHeight] + push af + ld a,[fireBulletDirection] + call HitObject + pop af + ldio [curObjWidthHeight],a + +.afterHit + ld hl,haikuSound + call PlaySound + ld a,15 + call SetAttackDelay + call GetFacing + ld h,a + add 2 + and %00000011 + ld l,a + ld a,h + and %11111100 + or l + call SetFacing + push bc + call GetFacing + ld c,a + call RemoveFromMap + pop bc + call StandardRedrawNoCheckSprite ;turn around + ret + +HaikuTakeDamage: + push bc + push hl + + ;store object palette color to be the explosion color later + call GetFGAttributes + and %111 + ld [bulletColor],a + + ;take damage only if I'm not facing bullet + call GetFacing + add 2 + and %11 + ld hl,bulletDirection ;was fireBulletDirection + cp [hl] + jr nz,.notFacingBullet + + ;take no damage + xor a + pop hl + pop bc + ret + +.notFacingBullet + ld a,OBJBANK + ld [$ff70],a + + ;play the explosion sound effect + ld hl,stdExplosionSound + call PlaySound + + ;blow off a puff instead of taking damage? + ld hl,OBJ_DESTZONE + add hl,de + ld a,[hl] + and %1111 + jr z,.noPuffs + + dec [hl] + ld b,METHOD_DRAW + call CallMethod + ld b,1 + jr .done + +.noPuffs + ld a,[methodParamL] + ld c,a ;c is damage + + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + ;ld b,a + ld b,0 + and %00111111 + jr z,.done ;already dead + ld b,c ;b is damage inflicted + sub c + jr nc,.notNegative + + add c ;original health + ld b,a ;is damage inflicted + xor a ;less than zero is zero +.notNegative + ld c,a + ld a,[hl] + ;ld a,b + and %11000000 + or c + ld [hl],a + +.done + ld a,b ;return damage inflicted + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Hero Lady Flower +;--------------------------------------------------------------------- +LadyInit: + ;initialize object + push bc + push de + ld a,OBJBANK ;select object RAM + ld bc,8 + inc de + inc de + ld hl,.ladyInitTable + call MemCopy + pop de + pop bc + + ;Load Lady's bullet-type + push bc + push de + call SaveFGTileInfo + ld a,HERO_FLOWER_FLAG + call SetHeroTileSet + + ld de,classLadyBullet + ld hl,LADY_BULLET_CINDEX + xor a + call LoadAssociatedClass + call GetAssociated + ld b,a + ld a,HERO_FLOWER_FLAG + call SetHeroBulletIndex + + call RestoreFGTileInfo + + pop de + pop bc + + ret + +.ladyInitTable + DB 1,1,$0f,LADY_MAX_HEALTH,0,0,0,GROUP_HERO + +LadyPlayerCheck: + ld b,LADY_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call LadyGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + + ld a,1 + call SetHeroMoved + +.checkButtons + call HeroCheckCanFire + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.checkButtonB + + call HeroSetupFireDirection + jr z,.checkButtonB + + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] ;way obstructed? + or a + jr nz,.checkShootOver + + ld a,[numFreeObjects] + cp 200 + jr c,.done + +.checkShootOver ;don't shoot on shootover-only tiles + ldio a,[firstMonster] + push bc + ld b,a + ld a,[hl] + cp b + pop bc + jr nc,.fire + + call GetBGAttributes + bit BG_BIT_WALKOVER,a + jr nz,.fire + bit BG_BIT_SHOOTOVER,a + jr nz,.done + +.fire + ld hl,ladyFireSound + ld a,1 ;one point of damage + call StdFireBullet + ld a,20 + call SetAttackDelay + jr .checkButtonB + +.checkButtonB +.done + ret + +ladyFireSound: + DB 1,$35,$80,$f3,$00,$c4 + +LadyGetInput: + call GetHeroJoyInput + + bit JOY_A_BIT,a ;check strafe release + jr nz,.afterStrafeRelease ;nope + + push af + ld a,15 ;yep + call SetFireDirection + pop af + +.afterStrafeRelease + bit JOY_B_BIT,a + jr z,.normalMove + +.slowMove + xor a + ret + +.normalMove + ld a,2 + +.testMove + call HeroTestMove + or a + ret z + jp HeroDoSparks + +LadyBulletInit: + ;ld a,3 + ;call GetRandomNumMask + ;add c + ;call ChangeMyClass + + ld hl,.pansyInitTable + call StdInitFromTable + + ld a,[methodParamL] + and %00000011 + ld b,a + call GetFacing + and %11111100 + or b + call SetFacing + + call PointToSpecialFlags + set OBJBIT_THROWN,[hl] + + xor a + call SetMisc + + ret + +.pansyInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_HERO ;group + DB 1 ;has bullet + DW classPansyBullet ;associated bullet class ptr + DW PANSYBULLET_CINDEX + +LadyBulletCheck: + call GetMisc + or a + jr nz,.changedClass + +.changedClass + ld hl,.pansyCheckTable + jp StdCheckFromTable + +.pansyCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW pansyFireSound + DB 10 ;fire delay + DW LadyVectorToState + +;--------------------------------------------------------------------- +; Hero Captain Flour +;--------------------------------------------------------------------- +FlourInit: + ;initialize object + push bc + push de + ld a,OBJBANK ;select object RAM + ld bc,9 + inc de + inc de + ld hl,.flourInitTable + call MemCopy + pop de + pop bc + + ;Load Captain's bullet-type + push bc + push de + call SaveFGTileInfo + ld a,HERO_FLOUR_FLAG + call SetHeroTileSet + ld de,classFlourBullet + ld hl,FLOUR_BULLET_CINDEX + xor a + call LoadAssociatedClass + call GetAssociated + ld b,a + ld a,HERO_FLOUR_FLAG + call SetHeroBulletIndex + call RestoreFGTileInfo + pop de + pop bc + + call LinkAssocToMe + ret + +.flourInitTable + DB 1,1,$0f,FLOUR_MAX_HEALTH,0,0,0,GROUP_HERO,1 + +FlourPlayerCheck: + ld b,FLOUR_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call StdPlayerGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + +.checkButtons + call DecrementAttackDelay + or a + jr z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jr z,.done + + ld hl,flourAttackSound + call PlaySound + + ;turn into bullet + xor a + call SetMisc + call ChangeMyClassToAssociatedAndRedraw + +.done + ret + +flourAttackSound: + DB 1,$43,$81,$f7,$00,$c3 + +FlourBulletCheck: + call .flourBulletCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call HeroTestMove + + or a + ret z + + call .flourBulletCheckMain ;move first of two + ;ret + + call GetHealth + ld b,FLOUR_MAX_HEALTH + call HealthSparks + call GetHealth ;died yet? + or a + ret z + + ld a,1 ;no, move again + + call .flourBulletCheckMain ;move first of two + call GetHealth ;died yet? + or a + ret z + + ld a,1 ;no, move again + +.flourBulletCheckMain + or a + jr z,.done ;timer lsb==frame lsb, don't move yet + + ldio a,[firstMonster] + ld b,a + + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr nc,.hitMonster + + ;bg in front flagged as shoot over? + ld a,[bgFlags] + bit BG_BIT_SHOOTOVER,a + jr z,.hitWall + ;and BG_FLAG_SHOOTOVER + ;jr z,.hitWall + jr .keepGoing + +.hitMonster + call .flourBulletHitMonster + ret + +.hitWall + call .flourBulletHitWall + ret + +.keepGoing + jp .flourBulletKeepGoing +.done + ret + +.flourBulletCheckDead + call GetHealth + cp b + jr c,.afterLimitHealth + + ld a,b + push af + call SetHealth + pop af + +.afterLimitHealth + or a + ret nz + + ld a,[amShowingDialog] ;don't die while showing dialog + or a + ret nz +IF INFINITEHEALTH==0 + call ChangeMyClassToAssociatedAndRedraw + xor a +ELSE + ld a,1 + or a +ENDC + ret + + +.flourBulletHitMonster + ;object in front, hit it for damage + ld b,a ;monster index in b, loc in hl + + ;get damage + ld a,1 + + ld [methodParamL],a + ld a,4 ;use direction of this object for expl + call HitObject + call .changeDirection + ret + +.flourBulletHitWall + bit BG_BIT_ATTACKABLE,a + jr z,.afterHitWall + + ld b,16 ;initial frame + call HitWall + +.afterHitWall + call .changeDirection + ret + +.flourBulletKeepGoing + call GetMisc ;bounced over three times? + cp 1 + jr c,.afterCheckStop + +.checkStop + call GetFacing ;can't be split + bit 2,a + jr nz,.afterCheckStopSound ;can't be sprite + bit 7,a + jr nz,.afterCheckStopSound + + call ChangeMyClassToAssociatedAndRedraw + ret + +.afterCheckStopSound + ld hl,flourAttackSound + call PlaySound + +.afterCheckStop + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME ;get current direction + add hl,de + ld a,[hl] + and %00000011 ;keep going same direction + ld b,a + + call Move + call StdBulletRedraw ;draw me please + ret + +.changeDirection + call GetMisc + inc [hl] + call GetFacing + ld b,a + + call GetAssocJoyInput ;allow user to dictate dir of exit + and %1111 + jr z,.reverseDir + + push bc + call JoyAToDirB + ld a,b + pop bc + push bc + ld c,a + xor b + and %11 + ld a,c + pop bc + jr nz,.gotDir + +.reverseDir + ld a,2 + add b + and %11 +.gotDir + ;call GetRandomNumZeroToN + ;inc a + res 0,b + res 1,b + or b + push af + call SetFacing + pop af + and %11 + ld b,a + ;call Move + ;call StdBulletRedraw + push bc + call GetFacing + ld c,a + call RemoveFromMap + pop bc + call StandardRedrawNoCheckSprite ;turn around + ret + +StdPlayerCheckDead: + call GetHealth + cp b + jr c,.afterLimitHealth + + ld a,b + push af + call SetHealth + pop af + +.afterLimitHealth + or a + ret nz + + ld a,[amShowingDialog] ;don't die while showing dialog + or a + ret nz +IF INFINITEHEALTH==0 + call RemoveHero + xor a +ELSE + ld a,1 + or a +ENDC + ret + +StdPlayerGetInput: + ;args: b - max health + ;returns: z - no move, nz=has move + ; b - dir of move + call GetHeroJoyInput + + bit JOY_A_BIT,a ;check strafe release + jr nz,.afterStrafeRelease ;nope + + push af + ld a,15 ;yep + call SetFireDirection + pop af + +.afterStrafeRelease + bit JOY_B_BIT,a + jr z,.normalMove + +.slowMove + ld a,2 + jr .testMove + +.normalMove + ld a,1 + +.testMove + call HeroTestMove + or a + ret z +;fall through below + +;falling through above +HeroDoSparks: + xor a + call SetHeroMoved + + call GetHealth + ;ld b,HAIKU_MAX_HEALTH ;b should be set up + call HealthSparks + + call GetHeroJoyInput + + and %1111 ;get directions only + ret z + ;jr nz,.checkEast + ;jp .checkButtons + + call JoyAToDirB + ld a,1 + or a + ret + +JoyAToDirB: +.checkEast + bit 0,a + jr z,.checkWest + ld b,DIR_EAST + ret + +.checkWest + bit 1,a + jr z,.checkNorth + ld b,DIR_WEST + ret + +.checkNorth + bit 2,a + jr z,.checkSouth + ld b,DIR_NORTH + ret + +.checkSouth + ld b,DIR_SOUTH + ret + +;--------------------------------------------------------------------- +; Routine: LocIsPassable +; Arguments: hl - location +; Alters: af +; Returns: a - 1 if passable, 0 if not +; [bgFlags] +;--------------------------------------------------------------------- +LocIsPassable: + push bc + + ldio a,[firstMonster] + ld b,a + + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + or a + jr z,.returnTrueSetBG + + cp b + jr nc,.returnFalse + + call GetBGAttributes + ld [bgFlags],a + bit BG_BIT_WALKOVER,a + jr nz,.returnTrue + +.returnFalse + xor a + pop bc + ret + +.returnTrueSetBG + call GetBGAttributes + ld [bgFlags],a + +.returnTrue + pop bc + ld a,1 + or a + ret + +;--------------------------------------------------------------------- +; Routine: AmAtEdgeInDirection +; Arguments: b - direction +; c - class index of object +; de - this +; Alters: af,hl +; Returns: a - 1=at edge, 0=not at edge +; zflag - or a +;--------------------------------------------------------------------- +AmAtEdgeInDirection: + ;clip and make sure I'm at least 2 from the edge + call GetCurLocation + call ConvertLocHLToXY + ld a,b + cp DIR_NORTH + jr z,.checkNorth + cp DIR_EAST + jr z,.checkEast + cp DIR_SOUTH + jr z,.checkSouth + +.checkWest + ld a,h + cp 2 + jr c,.returnTrue + jr .returnFalse + +.checkNorth + ld a,l + cp 2 + jr c,.returnTrue + jr .returnFalse + +.checkEast + ;add 1 to X if split + call GetFacing + bit 2,a + jr z,.xOkay + + inc h +.xOkay + ld a,[mapWidth] + sub 3 + cp h + jr c,.returnTrue + jr .returnFalse + +.checkSouth + ;add 1 to Y if split + call GetFacing + bit 2,a + jr z,.yOkay + + inc l + +.yOkay + ld a,[mapHeight] + sub 3 + cp l + jr c,.returnTrue + +.returnFalse + xor a + ret + +.returnTrue + ld a,1 + or a + ret + +;--------------------------------------------------------------------- +; Hero King Grenade +;--------------------------------------------------------------------- +GrenadePlayerInit: + ;initialize object + push bc + push de + ld a,OBJBANK ;select object RAM + ld bc,9 + inc de + inc de + ld hl,.grenadeInitTable + call MemCopy + pop de + pop bc + + xor a + call SetMisc + ret + +.grenadeInitTable + DB 1,1,$0f,GRENADE_MAX_HEALTH,0,0,0,GROUP_HERO,1 + +GrenadePlayerCheck: + ld b,GRENADE_MAX_HEALTH + call StdPlayerCheckDead + ret z + + call GrenadeGetInput + jr z,.checkButtons + + call PlayerValidateMoveAndRedraw + +.checkButtons + call DecrementAttackDelay + or a + jp z,.done + + call GetHeroJoyInput + bit 4,a ;button A pressed? + jp z,.done + + call GetMisc ;already started explosion? + or a + jr nz,.done + + ld a,1 + call SetMisc + + push bc + push de + ld a,3 + ld [bulletColor],a + ld a,15 + ldio [jiggleDuration],a + call GetCurLocation + call ConvertLocHLToXY + dec h + dec l + call ConvertXYToLocHL + ld bc,$0404 + ld de,$1407 + call CreateBigExplosion + ld hl,bigExplosionSound + call PlaySound + pop de + pop bc + + xor a + call SetHealth + + ;on correct level $1010 to blow up gate? + ld a,[curLevelIndex] + or a + jr nz,.done + ld a,[curLevelIndex+1] + cp $10 + jr nz,.done + + call GetCurZone + cp 4 + jr nz,.done + + ld a,1 + ld [levelVars+4],a ;used in $1000 VAR_EXPLODEDGATE + ;ld hl,heroesAvailable + ;res HERO_GRENADE_BIT,[hl] + + call levelCheckRAM ;start gate exploding before death + +IF 0 + ld a,[hero0_type] + cp HERO_GRENADE_FLAG + jr nz,.resetHero1 + + ;reset hero to bs + ld hl,2056 ;bs + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_BS_FLAG + ld [hero0_type],a + jr .done + +.resetHero1 + ;reset hero to bs + ld hl,2056 ;bs + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_BS_FLAG + ld [hero1_type],a +ENDC + +.done + ret + +GrenadeGetInput: + call GetHeroJoyInput + + bit JOY_A_BIT,a ;check strafe release + jr nz,.afterStrafeRelease ;nope + + push af + ld a,15 ;yep + call SetFireDirection + pop af + +.afterStrafeRelease + bit JOY_B_BIT,a + jr z,.normalMove + +.slowMove + ld a,5 + jr .testMove + +.normalMove + ld a,4 + +.testMove + call HeroTestMove + or a + ret z + jp HeroDoSparks + +;--------------------------------------------------------------------- +; Routine: StdBulletInit +; Arguments: c - class index, de - this +; [methodParamL] - 4:2=color, 1:0=direction +;--------------------------------------------------------------------- +StdBulletInit: + push bc + push hl + + ld a,OBJBANK + ld [$ff70],a + + ld a,[methodParamL] + ld b,a + + ld hl,OBJ_FRAME + add hl,de + ld a,b + and %10000011 + ld c,a + ld a,[objTimer60ths] ;set to cur timer so no move this round + or c + ld [hl+],a ;set frame + push af ;save frame for later + + ld a,1 + ld [hl+],a ;move one + ld a,b + and %00011100 ;extract color palette + srl a + srl a + ld [hl+],a ;store in misc + ld a,1 + ld [hl+],a ;health = 1 + inc hl ;skip nextL + inc hl ;skip nextH + ld a,1 + ld [hl+],a ;state=1 (length for long bullets) + ld a,GROUP_FFA + ld [hl+],a ;group = FFA + + ld a,[fireBulletDamage] + ld [hl+],a ;DESTL/Damage + + inc hl ;skip DESTH + + ;allocate a sprite if the isSprite flag starts out at 1 + pop af ;retrieve frame + bit 7,a ;sprite flag set? + jr z,.afterAlloc + + ;call AllocateSprite + ;ld [hl+],a ;set SPRITELO + +.afterAlloc + pop hl + pop bc + ret + +YellowBulletInit: + ld hl,methodParamL + ld a,[hl] + and %11100011 + or %00010100 ;yellow + ld [hl],a + jp StdBulletInit + +StdBulletRedraw: + push bc + push de + push hl + + ld a,OBJBANK + ld [$ff70],a + + xor a + ld [fgFlags],a + + ld hl,OBJ_LIMIT ;get my color + add hl,de + ld b,[hl] + jp StandardDraw + +StdCheckDead: + push hl + call GetHealth + pop hl + or a + ret nz + call StandardDie + xor a + ret ;return z flag set + +StdCheckTimeToMove: + ;time to move? + ld a,[hl+] + ld [checkTemp],a + or a + jr nz,.goAhead + inc a + ret ;return nz - no move but can attack + +.goAhead + push hl + call TestMove + pop hl + or a + ret nz ;can move + xor a ;return z + ret ;timer lsb==frame lsb, don't move yet + +StdCheckAttack: +.checkAttack + ;can I attack yet? + push hl + call DecrementAttackDelay + pop hl + or a + jr nz,.attackOkay + inc hl +.didntFindEnemy + inc hl + inc hl + inc hl + inc hl + jr .skipAttack + +.attackOkay + ld a,[hl+] + or a + jr z,.didntFindEnemy + + cp 1 + jr z,.meleeOnly + + ;Got an enemy in my sights? + xor a + ld [losLimit],a + call LookForEnemyInLOS ;returns dir of enemy in b + or a + jr z,.didntFindEnemy + jr .foundEnemy + +.meleeOnly + ld a,1 + ld [losLimit],a + call LookForEnemyInLOS ;returns dir of enemy in b + or a + jr z,.didntFindEnemy + +.foundEnemy + ;Fire instead of moving + ld a,[curObjWidthHeight] + push af + + ld a,[hl+] ;bullet damage + push hl + push af + + ld a,[hl+] ;hl = fire sound + ld h,[hl] + ld l,a + + pop af ;damage + call StdFireBullet ;b is direction to fire + pop hl + inc hl + inc hl + ld a,[hl+] ;delay + call SetAttackDelay + + pop af + ld [curObjWidthHeight],a + + ;turn to face the direction we just fired + ld a,[checkTemp] + or a + jr z,.skipMove + + call GetFacing + and %11 + cp b + jr z,.skipMove ;no need to turn + + ld a,1 + ld [moveAlignPrecision],a + call StandardValidateMoveAndRedraw + + jr .skipMove + +.skipAttack + ld a,1 ;return nz (go ahead and move) + or a + ret + +.skipMove + xor a ;return z (skip move) + ret + +StdCheckTalk: + ld a,[dialogNPC_speakerIndex] ;someone else talking? + or a + jr nz,.skipTalk + + call GetMisc ;already talked? + or a + ret nz + + call GetCurLocation + inc hl + +.checkTalkEast + ld b,DIR_EAST + call .getHeroAtHL + or a + jr nz,.foundHero + +.checkTalkWest + ld b,DIR_WEST + dec hl + dec hl + call .getHeroAtHL + or a + jr nz,.foundHero + +.checkTalkSouth + ld b,DIR_SOUTH + ld a,[mapPitch] + inc hl + call ConvertLocHLToXY + push hl + inc l + call ConvertXYToLocHL + call .getHeroAtHL + pop hl + or a + jr nz,.foundHero + +.checkTalkNorth + ld b,DIR_NORTH + dec hl + call ConvertXYToLocHL + call .getHeroAtHL + or a + jr z,.skipTalk + +.foundHero + ld a,1 + call SetMisc + + call GetFacing + and %11 + cp b + jr z,.skipMove ;no need to turn + + ld a,1 + ld [moveAlignPrecision],a + call StandardValidateMoveAndRedraw + + jr .skipMove + +.skipTalk + ld a,1 ;return nz (go ahead and move) + or a + ret + +.skipMove + xor a ;return z (skip move) + ret + +.getHeroAtHL + ;if a hero is at HL, sets up [dialogNPC*] with appropriate + ;values + ld a,MAPBANK + ldio [$ff70],a + + push bc + ld a,[hl] + or a + jr z,.checkHero1 + push hl + call EnsureTileIsHead + pop hl + ld b,a + + ld a,[hero0_index] + or a + jr z,.checkHero1 + cp b + jr z,.isHero + +.checkHero1 + ld a,[hero1_index] + or a + jr z,.notHero + cp b + jr z,.isHero + +.notHero + pop bc + xor a + ret + +.isHero + pop bc + ld [dialogNPC_heroIndex],a + ld a,c + ld [dialogNPC_speakerIndex],a + ret + +StdMove: + ld a,1 + ld [moveAlignPrecision],a + ld a,c + ld bc,.vectorToStateReturnAddress + push bc + ld c,a + ld a,[hl+] + ld h,[hl] + ld l,a + or a ;no movement if vector table is zero + jr nz,.jumpToVector + cp h + jr nz,.jumpToVector + + pop bc + jr .vectorToStateReturnAddress + +.jumpToVector + jp hl +.vectorToStateReturnAddress + or a + ret z + + call StandardValidateMoveAndRedraw +.done + ret + + + +;----bullet check methods--------------------------------------------- +WizardBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,2 + call TestMove + + or a + jr z,.done ;timer lsb==frame lsb, don't move yet + + ldio a,[firstMonster] + ld b,a + + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr nc,.hitMonster + + ;bg in front flagged as shoot over? + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr z,.hitWall + jr .keepGoing + +.hitMonster + ;'a' is class index of monster hit, hl it's location + ld b,a + call StandardDie + ld c,b + ld d,h + ld e,l + call FindObject + + ;perform a random effect on the monster hit + ld a,1 + call GetRandomNumMask + or a + jr nz,.checkMonsterRand1 + + ;freeze the monster for a bit + ld a,60 + call SetMoveDelay + ret + +.checkMonsterRand1 + ;don't let the monster attack for a bit + ld a,[hero0_index] + cp c + jr z,.setHeroAttackDelay + ld a,[hero1_index] + cp c + jr z,.setHeroAttackDelay + + ;set monster attack delay + ld a,20 + call SetAttackDelay + ret + +.setHeroAttackDelay + ld a,200 + call SetAttackDelay + ret + +.hitWall + call StdBulletHitWall + ret + +.keepGoing + jp StdBulletKeepGoing +.done + ret + +SuperSuperFastBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call TestMove + + or a + ret z + + call BulletCheckCommon ;move first of two + call GetHealth ;died yet? + or a + ret z + + ;no, move again + call BulletCheckCommon + call GetHealth ;died yet? + or a + ret z + + ;no, move yet again + jr BulletCheckCommon + +SuperFastBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call TestMove + + or a + ret z + + call BulletCheckCommon ;move first of two + call GetHealth ;died yet? + or a + ret z + + ld a,1 ;no, move again + jr BulletCheckCommon + +StdBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,2 + call TestMove + +BulletCheckCommon: + or a + jr z,.done ;timer lsb==frame lsb, don't move yet + + ldio a,[firstMonster] + ld b,a + + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr nc,.hitMonster + + ;bg in front flagged as shoot over? + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr z,.hitWall + jr .keepGoing + +.hitMonster + call StdBulletHitMonster + ret + ;jr .done + +.hitWall + call StdBulletHitWall + ret + ;jr .done + +.keepGoing + jp StdBulletKeepGoing +.done +bulletCheckDone: + ret + +StdBulletHitMonster: + ;object in front, hit it for damage + ld b,a ;monster index in b, loc in hl + + ;get damage from object + push hl + call GetBulletDamage + pop hl + + ld [methodParamL],a + ld a,4 ;use direction of this object for expl + call HitObject + call StandardDie + ret + +StdBulletHitWall: + ld b,16 ;initial frame + call HitWall + call StandardDie + ret + +StdBulletKeepGoing: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME ;get current direction + add hl,de + ld a,[hl] + and %00000011 ;keep going same direction + ld b,a + + call Move + call StdBulletRedraw ;draw me please + ret + +BASuperFastBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call HeroTestMove + + or a + ret z + + call BABulletCheckCommon ;move first of two + call GetHealth ;died yet? + or a + ret z + + ld a,1 ;no, move again +BABulletCheckCommon: + or a + jr z,.done ;timer lsb==frame lsb, don't move yet + + ldio a,[firstMonster] + ld b,a + + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr nc,.hitMonster + + ;bg in front flagged as shoot over? + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr z,.hitWall + jr .keepGoing + +.hitMonster + push hl + call StdBulletHitMonster + pop hl + ld a,[baUpgrades] + bit UPGRADE_BAHIGHIMPACT,a + ret z + call GetFacing + and %11 + ld b,a + call ThrowObjAtHLInDirB + ret + ;jr .done + +.hitWall + call StdBulletHitWall + ret + ;jr .done + +.keepGoing + jp StdBulletKeepGoing +.done + ret + + + +HeroBulletCheck: + ;am I dead? + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call HeroTestMove + jp BulletCheckCommon + +HeroSuperFastBulletCheck: + call StdCheckDead + ret z + +.checkTimeToMove + ;time to move? + ld a,1 + call HeroTestMove + + or a + ret z + + call BulletCheckCommon ;move first of two + call GetHealth ;died yet? + or a + ret z + + ld a,1 ;no, move again + jp BulletCheckCommon + + +ExplodingBulletCheck: + ;am I dead? + call GetHealth + or a + jr nz,.checkTimeToMove + call StandardDie + jr .done + +.checkTimeToMove + ;time to move? + ld a,2 + call TestMove + or a + jr z,.done ;timer lsb==frame lsb, don't move yet + + ldio a,[firstMonster] + ld b,a + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr nc,.hitSomething + + ;bg in front flagged as shoot over? + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr nz,.keepGoing + +.hitWall + call GetMoveLimit + and %00000111 + ld [bulletColor],a + call GetBulletDamage + ld b,a + call GetCurLocation + call StandardDie + call BombLocation + jr .done + +.hitSomething + ;get damage from object + push hl + call GetMoveLimit + and %00000111 + ld [bulletColor],a + call GetBulletDamage + pop hl + ld b,a + call StandardDie + call BombLocation + jr .done + +.keepGoing + call GetFacing + and %00000011 ;keep going same direction + ld b,a + + call Move + call StdBulletRedraw ;draw me please + +.done + ret + +;--------------------------------------------------------------------- +; Routine: GetLocInFront +; Arguments: a - 4=in front, same directon, split tile included +; returns zero +; 0-3=this direction AFTER split tile +; c - class index +; de - this +; Returns: a - tile index in front of object +; hl - location in front of object +; [bgFlags] - if tile in front is non-zero bg tile, +; its flags are loaded here +; Alters: af,hl +; Description: For 2x2 creatures facing east or south, returns +; location one tile further away to avoid tail of obj. +;--------------------------------------------------------------------- +GetLocInFront: + push bc + push de + + cp 4 + jr nz,.checkArbitraryAfterSplit + + xor a + ld [bgFlags],a + + ;check in direction of current facing + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME ;get facing + add hl,de + ld a,[hl] + bit 2,a + jr z,.notSplit + + ;is split, return zero and location in hl + ld h,d + ld l,e ;hl = location + ld a,[hl+] + ld h,[hl] + ld l,a + xor a ;return zero + jr .done + +.notSplit + and %00000011 ;left with cur direction in A + +.checkArbitraryAfterSplit + ld b,a ;b is dir to check + ld [getLocInitFacing],a + + xor a + ld [bgFlags],a + + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME ;get facing + add hl,de + ld a,[hl] + bit 2,a + jr nz,.isSplit + + ;not split, get offset, get location & we're done + call .getLocInHLAndOffsetInDE + jr .addedOnceOrTwice + ;ld a,[hl] + ;jr .done + +.isSplit + ;combine desired facing + cur facing in B + rlca + rlca + and %00001100 + or b + ld b,a ;B is combo cur facing+desired check + ld hl,getLocSplitTable + add l + ld l,a + ld a,[hl] + or a + jr nz, .addTwice + + ;add once + call .getLocInHLAndOffsetInDE + jr .addedOnceOrTwice + +.addTwice + ldio a,[curObjWidthHeight] + push af + ld a,1 + ldio [curObjWidthHeight],a + call .getLocInHLAndOffsetInDE + add hl,de + pop af + ldio [curObjWidthHeight],a + +.addedOnceOrTwice + ldio a,[firstMonster] + ld b,a + + ld a,[hl] + or a + jr z,.done + cp b + jr nc,.done + + ;non-zero bg tile, get attribute flags in [bgFlags] + ld e,a + ld d,((bgAttributes>>8) & $ff) + ld a,TILEINDEXBANK + ld [$ff70],a + ld a,[de] + ld [bgFlags],a + ld a,MAPBANK + ld [$ff70],a + ld a,e + +.done + pop de + pop bc + ret + +.getLocInHLAndOffsetInDE + ;location in hl + ld a,OBJBANK + ld [$ff70],a + ld h,d + ld l,e ;hl = location + ld a,[hl+] + ld h,[hl] + ld l,a + + ;direction offset in de + ld a,MAPBANK + ld [$ff70],a + + ld d,((mapOffsetNorth>>8)&$ff) ;add offset to go in front + ld a,b + and %00000011 + rla ;times two + add (mapOffsetNorth & $ff) + ld e,a ;de pts to offset + ld a,[de] + ld c,a + inc de + ld a,[de] + ld e,c + ld d,a ;de IS offset + + ;2x2 creatures facing east or south should be +1 more tile + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.afterAdjust + + ld a,[getLocInitFacing] + cp 1 + jr z,.offsetTimesTwo + + cp 2 + jr nz,.afterAdjust + +.offsetTimesTwo + sla e + rl d + +.afterAdjust + add hl,de ;hl += offset + ret + +;--------------------------------------------------------------------- +; Routine: StdFireBullet +; Arguments: a - amount of damage +; b - direction to fire (0-3) or 4=in dir of facing +; c - class index of firing object +; de - "this" +; hl - ptr to fire sound data for channel 1 +; Alters: af +;--------------------------------------------------------------------- +StdFireBullet: + push bc + push de + push hl + push hl ;save temp copy of fire sound + + ld [fireBulletDamage],a + ld a,1 + ld [guardAlarm],a + + ;save my facing for later + ld a,b + cp 4 ;use current facing if b=4 + jr nz,.gotFacing ;otherwise b is facing + + call GetFacing + and %00000011 + ld b,a + call GetLocInFront + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + ld a,b +.gotFacing + ld [fireBulletDirection],a + + ;Position to place bullet + ldio a,[firstMonster] + ld b,a + ;ld a,[fireBulletDirection] + ;call GetLocInFront ;a is direction + ld a,MAPBANK + ldio [$ff70],a + ld a,[fireBulletLocation] + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + ld a,[hl] + or a + jr z,.okayToFire + cp b + jr nc,.hitMonsterRightAway + ld a,[bgFlags] + bit BG_BIT_SHOOTOVER,a + jr nz,.okayToFire + bit BG_BIT_ATTACKABLE,a + jr nz,.hitWallRightAway + + ;wall straight ahead, can't fire + pop hl ;get rid of fire sound + jr .done + +.hitWallRightAway + ld a,[fireBulletDirection] + ld [bulletDirection],a + call GetFGAttributes + and %111 + ld [bulletColor],a + call GetAssociated + push bc + ld c,a + call HitWallAfterSetDirection + pop bc + jr .playFireSound + +.hitMonsterRightAway + ;object in front, hit it for damage + ld b,a ;monster index in b, loc in hl + ld a,[fireBulletDamage] ;one point of damage + ld [methodParamL],a + ld a,[fireBulletDirection] + call HitObject + + pop hl ;fire sound + call PlaySound + jr .done + +.okayToFire + ;Get class index of bullet + call GetAssociated + ld b,c ;save class index + ld c,a ;retreive class index + + ;create the bullet + call CreateObject + + ;init bullet sending my color palette and my facing + ld a,TILEINDEXBANK + ld [$ff70],a + ld l,b ;retrieve my class index + ld h,((fgAttributes>>8) & $ff) + ld a,[hl] + rlca + rlca ;b has palette in 4:2 + and %00011100 + ld b,a + + ;retrieve facing + ld a,[fireBulletDirection] + or b + + ;set isSprite if firing over background + ld b,a + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr z,.doneSetSprite + + set 7,b + +.doneSetSprite + ld a,b + + ld [methodParamL],a ;param is combo color+facing + ld b,METHOD_INIT + call CallMethod + ld b,METHOD_DRAW + call CallMethod + +.playFireSound + pop hl ;fire sound + call PlaySound + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CreateBulletOfClass +; Arguments: [fireBulletDamage] - amount of damage +; [fireBulletDirection] - 1:0 - direction to fire +; [bulletColor] - bullet color +; hl - location of bullet origin +; c - class index of bullet +; Alters: af, de +;--------------------------------------------------------------------- +CreateBulletOfClass: + push bc + push de + push hl + + ld a,[fireBulletDirection] + call AdvanceLocHLInDirection + + ;Position to place bullet + ldio a,[firstMonster] + ld b,a + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + push af + call GetBGAttributes + ld [bgFlags],a + pop af + or a + jr z,.okayToFire + cp b + jr nc,.hitMonsterRightAway + ld a,[bgFlags] + bit BG_BIT_SHOOTOVER,a + jr nz,.okayToFire + bit BG_BIT_ATTACKABLE,a + jr nz,.hitWallRightAway + + ;wall straight ahead, can't fire + jr .done + +.hitWallRightAway + ld a,[fireBulletDirection] + ld [bulletDirection],a + call HitWallAfterSetDirection + jr .done + +.hitMonsterRightAway + ;object in front, hit it for damage + ld b,a ;monster index in b, loc in hl + ld a,[fireBulletDamage] ;one point of damage + ld [methodParamL],a + ld a,[fireBulletDirection] + call HitObject + jr .done + +.okayToFire + ;create the bullet + call CreateObject + + ld a,[bulletColor] + and %111 + rlca + rlca + ld b,a + ld a,[fireBulletDirection] + or b + + ;set isSprite if firing over background + ld b,a + ld a,[bgFlags] + and BG_FLAG_SHOOTOVER + jr z,.doneSetSprite + + set 7,b + +.doneSetSprite + ld a,b + + ld [methodParamL],a ;param is combo color+facing + ld b,METHOD_INIT + call CallMethod + ld b,METHOD_DRAW + call CallMethod + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetFireTimer +; Arguments: a - value to set fire timer to +; Alters: af,hl +;--------------------------------------------------------------------- +SetFireTimer: + push af + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FIRETIMER + add hl,de + pop af + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: DecrementAttackDelay +; Arguments: c - class index of object +; de - "this" +; Returns: a - 1=can attack now, 2=can't attack +; Alters: af,hl +; Description: If this->attackDelay==0 returns 1. +; Otherwise decrements attackDelay and returns zero +;--------------------------------------------------------------------- +DecrementAttackDelay: + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_FIRETIMER + add hl,de + ld a,[hl] + or a + jr z,.returnTrue + + dec [hl] + + xor a + ret + +.returnTrue + ld a,1 + ret + +;--------------------------------------------------------------------- +; Routine: SetAttackDelay +; Arguments: a - desired attack delay 0-15 +; c - class index of object +; de - "this" +; Alters: af,hl +; Description: Stores attack delay in OBJ_FIRETIMER +;--------------------------------------------------------------------- +SetAttackDelay:: + push bc + ld b,a + + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_FIRETIMER + add hl,de + ld a,b + ld [hl],a + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetAttackDelay +; Arguments: c - class index of object +; de - "this" +; Returns: a - remaining attack delay +; Alters: af,hl +; Description: Stores attack delay in OBJ_FIRETIMER +;--------------------------------------------------------------------- +GetAttackDelay:: + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_FIRETIMER + add hl,de + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: HitObject +; Arguments: a - 0-3=direction of explosion, 4=use this obj 4 dir +; b - class index of monster hit +; c - class index of object +; de - "this" +; hl - map location of monster hit +; [methodParamL] - points of damage +; Alters: af +; Description: Locates the creature that's been hit and calls its +; TAKE_DAMAGE method. +;--------------------------------------------------------------------- +HitObject: + push bc + push de + push hl + + ;Get direction bullet was travelling + cp a,4 + jr nz,.gotBulletDirection + + ;use this objects facing for bullet direction + ld a,OBJBANK + ld [$ff70],a + inc de + inc de + ld a,[de] +.gotBulletDirection + and %11 + ld [bulletDirection],a + + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + + ld a,b ;store monster class index in c + call EnsureTileIsHead + ld d,h ;de stores location of monster + ld e,l + ld c,a ;a is class of monster + + call FindObject + ld b,METHOD_TAKE_DAMAGE ;should fill [bulletColor] w/obj color + call CallMethod + or a + jr z,.done ;zero damage, skip explosion + + ld b,1 + call CreateExplosion + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: HitWall +; Arguments: b - initial frame +; c - class index of object +; de - "this" +; hl - map location of wall hit +; [bgFlags] +; [bulletDirection] +; Alters: af,hl +; Description: Creates an explosion over the wall that's been hit +; If wall is flagged as BG_FLAG_ATTACKABLE, wall's +; method is called with BGACTION_HIT. +;--------------------------------------------------------------------- +HitWallAfterSetDirection: + push bc + push de + jr HitWallAfterSetDirectionPushedBCDE + +HitWall: + push bc + push de + + ld a,[bgFlags] + and BG_FLAG_ATTACKABLE + jr z,HitWall_WallNotAttackable + + ;set bullet's facing + call GetFacing + and %11 + ;ld [fireBulletDirection],a + ld [bulletDirection],a + + ;save bullet's damage and color + push hl + call GetDestL + ld [fireBulletDamage],a + call GetMoveLimit + ld [bulletColor],a + pop hl + +HitWallAfterSetDirectionPushedBCDE: + ;save bullet's class index + ld a,c + ld [bulletClassIndex],a + + ;set 'b' to directional blast over wall + ld b,1 + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + + ;get the bg tiles color + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + ld c,a + call GetBGAttributes + and %111 + push af + + ld a,BGACTION_HIT + call CallBGAction + jr z,HitWall_DoneAF + + pop af + ld [bulletColor],a + ;call GetHealth + ;cp 2 + ;jr nc,.skipSound ;kludge for captain flour + + ld hl,stdExplosionSound + call PlaySound +.skipSound + jr HitWall_CreateExplosion + +HitWall_WallNotAttackable: + ;Get direction bullet was travelling + ld a,OBJBANK + ld [$ff70],a + ld h,d + ld l,e + ld a,[hl+] + ld [bulletLocation],a + ld a,[hl+] + ld [bulletLocation+1],a + + ;get bullet color + ld hl,OBJ_LIMIT + add hl,de + ld a,[hl] + ld [bulletColor],a + + ;call GetHealth + ;cp 2 + ;jr nc,.skipSound ;kludge for captain flour + ld hl,bigExplosionSound + call PlaySound +.skipSound + +HitWall_CreateExplosion: + call CreateExplosion ;uses b as initial frame + +HitWall_Done: + pop de + pop bc + ret + +HitWall_DoneAF: + pop af + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: StdTakeDamage +; Arguments: [methodParamL] - points of damage +; c - class index of object +; de - "this" +; Returns: [bulletColor] - color of this obj for explosion +; a - points of damage actually taken by this creature +; Alters: af +;--------------------------------------------------------------------- +StdTakeDamage: + push bc + push hl + + ;store object palette color to be the explosion color later + call GetFGAttributes + and %111 + ld [bulletColor],a + + ld a,OBJBANK + ld [$ff70],a + + ;play the explosion sound effect + ld hl,stdExplosionSound + call PlaySound + +TakeDamageCommon: + ;blow off a puff instead of taking damage? + ld hl,OBJ_DESTZONE + add hl,de + ld a,[hl] + and %1111 + jr z,.noPuffs + + dec [hl] + ld b,METHOD_DRAW + call CallMethod + jr .resetState + +.noPuffs + ld a,[methodParamL] + ld c,a ;c is damage + + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + ;ld b,a + ld b,0 + and %00111111 + jr z,.done ;already dead + ld b,c ;b is damage inflicted + sub c + jr nc,.notNegative + + add c ;original health + ld b,a ;is damage inflicted + xor a ;less than zero is zero +.notNegative + ld c,a + ld a,[hl] + ;ld a,b + and %11000000 + or c + ld [hl],a + +.resetState + ;reset state to zero (rethink where I'm going) + ld a,0 + call SetState + +.done + ld a,b ;return damage inflicted + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CowboyTakeDamage +; Alters: af +; Description: Pisses the cowboys off (group M becomes enemy) +;--------------------------------------------------------------------- +CowboyTakeDamage: + push bc + push de + push hl + + xor a + ld b,GROUP_HERO + ld c,GROUP_MONSTERM + call SetFOF + + ;change any remaining CowboyTalkers to Angry Cowboys + ld bc,classCowboyTalker + ld de,classAngryCowboy + call ChangeClass + + ;change any regular cowboys to angry cowboys + ld bc,classCowboy + ld de,classAngryCowboy + call ChangeClass + + ;change music to hoedown music + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call IsCurMusic + jr z,.afterChangeMusic ;not in cowboy land + + ld a,BANK(hoedown_gbm) + ld hl,hoedown_gbm + call InitMusic +.afterChangeMusic + + ;zero talker index + xor a + ld [dialogBalloonClassIndex],a + + pop hl + pop de + pop bc + jp StdTakeDamage + +;--------------------------------------------------------------------- +; Routine: WallTakeDamage +; Description: Toggles the wall creature between stunned and +; normal. +;--------------------------------------------------------------------- +WallTakeDamage: + ;change to other state (stunned<->normal) + call ChangeMyClassToAssociatedAndRedraw + + ld b,METHOD_DRAW + call CallMethod +.done + xor a + ld [bulletColor],a + ld a,1 + ret + +;--------------------------------------------------------------------- +; Routine: TakeZeroDamage +;--------------------------------------------------------------------- +TakeZeroDamage: + xor a + ret + +;--------------------------------------------------------------------- +; Routine: BulletTakeDamage +; Arguments: [methodParamL] - points of damage +; c - class index of object +; de - "this" +; Returns: [bulletColor] - color of this bullet for explosion +; Alters: af +;--------------------------------------------------------------------- +BulletTakeDamage: + push bc + push hl + + ;store bullet palette color to be the explosion color later + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_LIMIT + add hl,de + ld a,[hl] + and %00000111 + ld [bulletColor],a + + ;play the explosion sound effect + ld hl,stdExplosionSound + call PlaySound + + jp TakeDamageCommon + +;--------------------------------------------------------------------- +; Routine: StdTakeDamage2x2 +; Arguments: c - class index of object +; de - this +; Alters: af +; Description: Like StandardTakeDamage except creates 4 explosion +; sprites over the area of the object when it dies. +;--------------------------------------------------------------------- +StdTakeDamage2x2: + push bc + push hl + + ;store object palette color to be the explosion color later + call GetFGAttributes + and %111 + ld [bulletColor],a + + ld a,OBJBANK + ld [$ff70],a + + ;play the explosion sound effect + ld hl,stdExplosionSound + call PlaySound + + ld a,[methodParamL] + ld c,a ;c is damage + ld b,c ;b is damage actually inflicted + + call GetHealth + and %00111111 + jr z,.doneReturnZero ;already dead + sub c + jr nc,.notNegative + + add c + ld b,a + xor a ;less than zero is zero +.notNegative + ld c,a + ld a,[hl] + and %11000000 + or c + ld [hl],a + and %00111111 + jr nz,.done + + ;it's dead; blow up the 2x2 creature + ;save original bullet hit location + push bc + ld a,[bulletLocation] + ld l,a + ld a,[bulletLocation+1] + ld h,a + push hl + + ;create explosions + call GetCurLocation + push hl + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + xor a + call .createExplosion + ld a,[bulletLocation] + inc a + ld [bulletLocation],a + ld a,1 + call .createExplosion + pop hl + call ConvertLocHLToXY + inc l + call ConvertXYToLocHL + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + ld a,2 + call .createExplosion + ld a,[bulletLocation] + inc a + ld [bulletLocation],a + ld a,3 + call .createExplosion + + ;restore original bullet location + pop hl + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + pop bc + jr .done + +.doneReturnZero + ld b,0 +.done + ld a,b + pop hl + pop bc + ret + +.createExplosion + rlca ;times 8 + rlca + rlca + and %00011000 + add 32 + ld b,a + call CreateExplosion + or a + ret z + + ;offset sprites +0,+0 to +4,+4 + call IndexToPointerHL + ld a,l + add 12 + ld l,a + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + push hl + call GetFacing + pop hl + + bit 2,a + jr z,.afterSetOffset + + bit 0,a + jr nz,.eastWest + + ;facing north/south, add +4 offset + ld a,[hl] + add 4 + ld [hl],a + jr .afterSetOffset + +.eastWest + inc hl + ld a,[hl] + add 4 + ld [hl],a + dec hl + +.afterSetOffset + ret + + +;--------------------------------------------------------------------- +; Routine: StandardDie +; Arguments: c - class index of object +; de - this +; Alters: af +; Description: Removes the object from the map and deletes it +;--------------------------------------------------------------------- +StandardDie: + push bc + push de + push hl + + ld b,c + call GetFacing + ld c,a + call RemoveFromMap + ld c,b + call SuperDie + call DeleteObject + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetHealth +; Arguments: c - class index of object +; de - this +; Returns: a - number of health points +; Alters: af,hl +;--------------------------------------------------------------------- +GetHealth:: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + and %00111111 + ret + +;--------------------------------------------------------------------- +; Routine: SetHealth +; Arguments: a - health to set to +; de - this +; Returns: Nothing. +; Alters: af,hl +;--------------------------------------------------------------------- +SetHealth:: + push af + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_HEALTH + add hl,de + ld a,[hl] + and %11000000 + ld [hl],a + pop af + or [hl] + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: SetMoveDelay +; Arguments: a - move delay to set to (0-255) +; de - this +; Returns: Nothing. +; Alters: af,hl +;--------------------------------------------------------------------- +SetMoveDelay: + push af + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_MOVE + add hl,de + pop af + ld [hl],a + ret + + ;push bc + ;ld b,a + ;ld a,OBJBANK + ;ldio [$ff70],a + ;ld hl,OBJ_MOVE + ;add hl,de + ;ld a,[hl] + ;and %11110000 + ;or b + ;ld [hl],a + ;pop bc + ;ret + + +;--------------------------------------------------------------------- +; Routine: ConvertLocHLToSpriteCoords +; Arguments: hl - map location +; Returns: hl - h = x, l = y sprite coords +; Alters: af,hl +;--------------------------------------------------------------------- +ConvertLocHLToSpriteCoords:: + ;calculate screen pixel positions + ;x = (((tile_x * 8) - (mapLeft * 8)) - pixelOffset_x) + 8 + ; = (((tile_x - mapLeft) * 8) - pixelOffset_x) + 8 + ;y = (((tile_y - mapTop) * 8) - pixelOffset_y) + 16 + call ConvertLocHLToXY + + ;----------------------x coordinate--------------------------- + ld a,[mapLeft] ;a = -mapLeft + cpl + add 1 + add h ;a += tile_x + cp 32 ;any chance of being visible? + jr nc,.returnZero + rlca ;a *= 8 + rlca + rlca + ld h,a ;tile_x = a + ld a,[desiredPixelOffset_x] + cpl + add 1 + add h + add 8 + ld h,a ;tile_x=(tile_x-pixelOffset_x)+8 + + ;----------------------y coordinate--------------------------- + ld a,[mapTop] ;a = -mapTop + cpl + add 1 + add l ;a += tile_y + cp 32 ;any chance of being visible? + jr nc,.returnZero + rlca ;a *= 8 + rlca + rlca + ld l,a ;tile_y = a + ld a,[desiredPixelOffset_y] + cpl + add 1 + add l + add 16 + ld l,a ;tile_y=(tile_y-pixelOffset_y)+16 + ret + +.returnZero + ld hl,0 ;sprite not visible + ret + + +;--------------------------------------------------------------------- +; Routine: CreateExplosion +; Arguments: b - 1=moves in direction, >1 initial frame +; c - class index of object (if directed) +; de - this (if directed) +; [bulletColor] +; [bulletLocation] +; Returns: a - explosion object index +; Alters: af +; Description: Creates an explosion sprite positioned over this +; object with this object's color +; Object memory usage for sprites: +; Bytes 0,1: screen coordinate location (x,y) +; Byte 2: frame +; bit[1:0] - direction +; bit[2] - 1 if no direction +; bit[3] - unused +; bit[6:4] - color palette (0-7) +; Byte 3: (move) +; Byte 4: bit[2:0] - animation frame (0-7) +; Byte 10: initial frame (0,8,16,24,32,64,...) +; Byte 12: Lo-Ptr to OAM table position +;--------------------------------------------------------------------- +CreateExplosion:: + push bc + push de + push hl + + call AllocateSprite ;returns sprite OAM lo-ptr in a or $ff + inc a + jr z,.done ;no free sprites for explosion + + dec a + ld [methodParamL],a + + ld hl,bulletLocation + ld a,[hl+] + ld h,[hl] + ld l,a + call ConvertLocHLToSpriteCoords + ld a,b + cp 1 ;directional or round? + jr nz,.roundExplosion + + ;directed explosion + xor a + ld [explosionInitialFrame],a + ld a,[bulletColor] + ld b,a + swap b + + ld a,[bulletDirection] + and %00000011 + or b + jr .aIsSetup + +.roundExplosion + ld [explosionInitialFrame],a + ld a,[bulletColor] + swap a + or %00000100 + +.aIsSetup + ld [methodParamH],a + + ld c,CLASS_EXPLOSION + call CreateObject + + ld b,METHOD_INIT + call CallMethod + + call PointerDEToIndex ;return index of explosion object + +.done pop hl + pop de + pop bc + ret + +ExplosionInit: + push bc + push de + push hl + + push de + + ld a,[methodParamL] + call SetSpriteLo + + ;set up other stuff + ld hl,OBJ_FRAME + add hl,de + ld a,[methodParamH] ;color + direction + ld b,a + ld [hl+],a + inc hl + xor a + ld [hl],a ;anim frame zero + dec hl ;hl = move + ld d,((spriteOAMBuffer>>8) & $ff) + ld a,[methodParamL] ;loptr + ld e,a + ld a,1 + ld [hl-],a ;move = 1 + dec hl + + inc de + ld a,[hl-] ;copy y pixel coordinate + ld [de],a + dec de + ld a,[hl+] ;copy x pixel coordinate + ld [de],a + inc de + inc de ;de pts to pattern + + ;make hl point to frame lookup table + ld a,b ;get color+dir byte + and %00000111 ;mask off all but dir + add (explosionFrameTable & $ff) + ld l,a + ld h,((explosionFrameTable>>8) & $ff) + ld a,[explosionInitialFrame] + add [hl] ;pattern + ld [de],a + inc de ;de now pts to flags + set 3,l ;hl += 8 + ld a,b + swap a + and %00001111 + ld b,a + ld a,[hl] + or b + ld b,a + + ;set flak to be randomly flipped + ld a,[explosionInitialFrame] + cp 64 ;flack or spark? + ld a,b + jr c,.afterFlipFlack + + ld a,%01100000 + call GetRandomNumMask + +.afterFlipFlack + or b + ld [de],a ;store attributes + + pop de + + ;---extra setup----------------------------------------------- + ;store initial frame in DESTL + ld a,[explosionInitialFrame] + ld hl,OBJ_DESTL + add hl,de + ld [hl],a + + pop hl + pop de + pop bc + ret + +ExplosionRedraw: +ExplosionCheck: + push hl + + ld a,OBJBANK + ldio [$ff70],a + + ;Check timer slower for flack & 2x2 explosions + ld hl,OBJ_DESTL ;storage of initial frame + add hl,de + ld a,[hl] + cp 32 + jr c,.faster + cp 72 + jr nc,.faster + +.slower + ld a,3 ;slower + jr .checkMove + +.faster + ld a,1 + +.checkMove + ;my turn yet? + call TestMove + or a + jr z,.skipTurn ;timer lsb==frame lsb, don't move yet + + ld hl,OBJ_FRAME + add hl,de + ld a,[hl] + bit 2,a ;should explosion move position? + jr nz,.afterMove + + ;figger out which direction to move + ;get ptr to sprite in hl + ld hl,OBJ_SPRITELO + add hl,de + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + + bit 1,a + jr nz,.moveSouthOrWest + + bit 0,a + jr z,.moveNorth + +.moveEast + inc hl + inc [hl] + inc [hl] + jr .afterMove + +.moveNorth + dec [hl] + dec [hl] + jr .afterMove + +.moveSouthOrWest + bit 0,a + jr z,.moveSouth + +.moveWest + inc hl + dec [hl] + dec [hl] + jr .afterMove + +.moveSouth + inc [hl] + inc [hl] + +.afterMove + ld hl,OBJ_LIMIT ;get current frame + add hl,de + inc [hl] ;add one + ld a,[hl+] ;get frame in a + + ;get lo-ptr to sprite + ld hl,OBJ_SPRITELO + add hl,de + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + bit 3,a ;become 8? + jr z,.keepGoing + + ;run out of frames, delete myself + call SuperDie + call ExplosionDie + + jr .skipTurn + +.keepGoing + inc hl ;add one to actual sprite frame + inc hl + inc [hl] + +.skipTurn + pop hl + ret + +ExplosionDie: + call DeleteObject ;delete myself + ret + +IdleCantDieCheck: + ret + +DoNothingCheck: + ;am I dead? + call GetHealth + or a + jr nz,.skipMove + call StandardDie +.skipMove + ret + +;--------------------------------------------------------------------- +; Routine: StdInitFromTable +; Arguments: hl - table containing +; BYTE initial facing (4 = random) +; BYTE health (last value popped off) +; BYTE monster group (e.g. MONSTER_A) +; BYTE hasBullet +; WORD bullet class ptr +; WORD bullet class index +; Alters: all +; Returns: Nothing. +; Description: Sets +; - state to zero +; - facing to random +; - fire delay to 1 +; - group to specified +; - health to specified +; Loads associated bullet class +;--------------------------------------------------------------------- +StdInitFromTable: + ld a,[hl+] + cp 4 + jr nz,.setFacing + + ld a,3 + call GetRandomNumZeroToN + +.setFacing + push hl + call SetFacing + + xor a + call SetState + + xor a + call SetFireTimer + pop hl + + ld a,[hl+] + push hl + call SetHealth + pop hl + + ld a,[hl+] + call SetGroup + + push de + ld a,[hl+] ;has bullet? + or a + jr z,.afterLoadAssociated + + ld a,[hl+] + ld e,a + ld a,[hl+] + ld d,a + + ld a,[hl+] + ld h,[hl] + ld l,a + + ld a,1 + call LoadAssociatedClass +.afterLoadAssociated + ;hl screwed up here + pop de + ret + +;--------------------------------------------------------------------- +; Routine: StdCheckFromTable +; Arguments: hl - pointer to table containing: +; BYTE move delay +; BYTE attack type (0=no attack,1=melee,2=missile) +; BYTE bullet damage +; WORD fire sound effect address +; BYTE fire delay +; WORD vectore to state routine pointer +; Alters: all +; Returns: Nothing. +;--------------------------------------------------------------------- +StdCheckFromTable: + call StdCheckDead + ret z +StdCheckFromTableNotDead: + call StdCheckTimeToMove + ret z + call StdCheckAttack + ret z + call StdMove + ret + +ActorSpeed1Check: + ld hl,.actorCheckTable + jp StdCheckFromTable + +.actorCheckTable + DB 1 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW nullSound + DB 3 ;fire delay + DW ActorVectorToState + +GuardCheck: + ;this guy can only attack in the direction he's facing + ;call GetFacing + ;and %00000011 + ;call SetAttackDirState + + call StdCheckDead + ret z + ld hl,.guardCheckTable + call StdCheckFromTableNotDead + + ;sound the alarm if I attacked recently (attack delay non-zero) + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_FIRETIMER + add hl,de + ld a,[hl] + or a + ret z + + ld a,1 + ld [guardAlarm],a + ret + + +.guardCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW guardFireSound + DB 6 ;fire delay + DW ActorVectorToState + +;----bee-------------------------------------------------------------- +BeeInit: + ld hl,.beeInitTable + jp StdInitFromTable + +.beeInitTable + DB 4 ;initial facing + DB 1 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +BeeCheck: + push bc + ld bc,ITEM_BUGSPRAY + call HasInventoryItem + pop bc + jr z,.fastCheck + +.slowCheck + ld hl,.beeCheckTableSlow + jp StdCheckFromTable + +.fastCheck + ld hl,.beeCheckTableFast + jp StdCheckFromTable + +.beeCheckTableFast + DB 1 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW beeSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +.beeCheckTableSlow + DB 2 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW beeSound + DB 20 ;fire delay + DW StdVectorToState + + +;----Stunned Wall----------------------------------------------------- +StunnedWallInit: + ld hl,.stunnedWallInitTable + call StdInitFromTable + + jp LinkAssocToMe + +.stunnedWallInitTable + DB 4 ;initial facing + DB 63 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classWallCreature + DW WALLCREATURE_CINDEX + +StunnedWallCheck: + ld hl,.stunnedWallCheckTable + jp StdCheckFromTable + +.stunnedWallCheckTable + DB 0 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 64 ;fire delay + DW 0 + +;----Grenade---------------------------------------------------------- +GrenadeInit: + ld hl,.grenadeInitTable + jp StdInitFromTable + +.grenadeInitTable + DB 4 ;initial facing + DB 3 ;health + DB GROUP_HERO ;group + DB 0 ;has bullet + +GrenadeCheck: + call GetHealth + or a + jr nz,.check + + call GetCurLocation + ld b,4 + call BombLocation + ld hl,bigExplosionSound + call PlaySound + ld a,5 + ld [jiggleDuration],a + +.check + ld hl,.grenadeCheckTable + jp StdCheckFromTable + +.grenadeCheckTable + DB 4 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +;----Vacuum----------------------------------------------------------- +VacuumInit: + ld hl,.vacuumInitTable + jp StdInitFromTable + +.vacuumInitTable + DB 4 ;initial facing + DB 6 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +VacuumCheck: + call StdCheckDead + ret z + ld hl,.vacuumCheckTable + call StdCheckFromTableNotDead + + ;handle 'firing' ourselves + ;can we attack yet? + call DecrementAttackDelay + or a + ret z + + push de + call GetFacing + push af + and %11 + call GetLocInFront + pop af + rlca + and %110 + push hl + ld l,a + ld a,(mapOffsetNorth & $ff) + add l + ld l,a + ld h,((mapOffsetNorth>>8)&$ff) + ld a,[hl+] + ld e,a + ld a,[hl] + ld d,a + pop hl + + xor a + ld [losLimit],a + call ScanDirectionForEnemy ;returns dir of enemy in b + or a + jr z,.doneDE + + ;suck the enemy towards me + ld a,[fireBulletLocation] ;enemy's location + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + pop de + call GetFacing + add 2 + and %11 + call ShiftObjectInDirection + ld a,3 + call SetAttackDelay + ld hl,.vacuumSuckSound + call PlaySound + ret + +.doneDE pop de + ret + +.vacuumCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW .vacuumAttackSound + DB 25 ;fire delay + DW TrackEnemyVectorToState + +.vacuumAttackSound + DB 1,$54,$c0,$f2,$00,$83 + +.vacuumSuckSound + DB 1,$55,$80,$f3,$00,$84 + +;----Slug------------------------------------------------------------- +SlugInit: + ld hl,.slugInitTable + call StdInitFromTable + ld bc,classSlugTrailBG + call FindClassIndex + jp SetMisc + +.slugInitTable + DB 4 ;initial facing + DB 5 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +SlugCheck: + call GetCurLocation + call GetFacing + and %111 + cp %100 + jr z,.adjustSouth + cp %111 + jr nz,.foundCurLocation + +.adjustWest + call ConvertLocHLToXY + inc h + jr .convertBack + +.adjustSouth + call ConvertLocHLToXY + inc l + +.convertBack + call ConvertXYToLocHL + +.foundCurLocation + push hl + + call GetHealth + push af + ld hl,.slugCheckTable + call StdCheckFromTable + pop af + or a + jr nz,.notDead + + pop af ;dead + ret + +.notDead + call GetMisc + ld b,a + pop hl ;retrieve old location + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] ;empty now? + or a + ret nz ;still something in there + + ;leave a slime trail + ld [hl],b + jp ResetMyBGSpecialFlags + +.slugCheckTable + DB 6 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .slugFireSound + DB 15 ;fire delay + DW StdVectorToState + +.slugFireSound + DB 1,$14,$80,$f0,$00,$c1 + +;----Wall Creature---------------------------------------------------- +WallCreatureInit: + ld hl,.wallCreatureInitTable + call StdInitFromTable + + jp LinkAssocToMe + +.wallCreatureInitTable + DB 4 ;initial facing + DB 63 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classStunnedWall + DW STUNNEDWALL_CINDEX + +WallCreatureCheck: + ld hl,.wallCreatureCheckTable + jp StdCheckFromTable + +.wallCreatureCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .wallCreatureFireSound + DB 25 ;fire delay + DW TrackEnemyVectorToState + +.wallCreatureFireSound + DB 1,$7b,$40,$f0,$00,$c6 + +;----Small Bee Hive--------------------------------------------------- +BigBeeHiveInit: +SmallBeeHiveInit: + ld hl,.smallBeeHiveInitTable + jp StdInitFromTable + +.smallBeeHiveInitTable + DB DIR_EAST ;initial facing + DB 5 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classBee ;associated bullet class ptr + DW BEE_CINDEX + +SmallBeeHiveCheck: + ld hl,.smallBeeHiveCheckTable + jp StdCheckFromTable + +.smallBeeHiveCheckTable + DB 0 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW beeSound + DB 20 ;fire delay + DW 0 + +;----Scardie---------------------------------------------------------- +ScardieInit: + ld hl,.scardieInitTable + jp StdInitFromTable + +.scardieInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_FFA ;group + DB 0 ;has bullet + +ScardieCheck: + call StdCheckDead + ret z + ld hl,.scardieCheckTable + call StdCheckFromTableNotDead + + ;test if either hero in zone + call GetCurZone + ld b,a + ld a,1 + call GetHeroZone + cp b + jr z,.heroHere + ld a,2 + call GetHeroZone + cp b + ret nz +.heroHere + jp ScardieFlee + +.scardieCheckTable + DB 2 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW nullSound + DB 20 ;fire delay + DW StdVectorToState + +;If scardie's dest zone is == cur zone or not moving to zone then pick +;a new dest zone +ScardieFlee: + call GetCurZone + ld b,a + call GetDestZone + or a + jr z,ScardiePickNewZone + cp b + jr z,ScardiePickNewZone + + call GetState + or a + ret nz + + ld a,1 + jp SetState + +ScardiePickNewZone: + ;starting at my current zone, run through the zone path matrix + ;to see what's available + ld a,b + swap a + or b + ld l,a + ld h,((pathMatrix>>8)&$ff) + + ld a,WAYPOINTBANK + ldio [$ff70],a + + ld b,15 +.checkNewZone + push bc ;increment dest zone + ld a,l + add 1 + and %1111 + ld b,a + ld a,l + and %11110000 + or b + ld l,a + and %1111 + jr nz,.afterIncL + inc l ;dest zone can't be zero +.afterIncL + pop bc + + ld a,[hl] + or a + jr nz,.foundPath + + dec b + jr nz,.checkNewZone + + ret ;can do nothing + +.foundPath + ld a,l + and %1111 + call SetDestZone + ld a,1 + jp SetState + +ScardieTakeDamage: + call ScardieFlee + jp StdTakeDamage + +LadyBulletMove: + ld a,[hero0_type] + cp HERO_FLOWER_FLAG + jr nz,.useJoy1 + + ld hl,curJoy0 + jr .gotJoy + +.useJoy1 + ld hl,curJoy1 + +.gotJoy + ld a,[hl] + and %1111 + ret z + + call JoyAToDirB + ld a,1 + or a + ret + +;----Chomper---------------------------------------------------------- +ChomperInit: + ld hl,.chomperInitTable + jp StdInitFromTable + +.chomperInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +ChomperCheck: + ld hl,.chomperCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + call StdCheckAttack + ret z + + ;see if an enemy is +2 in any direction; if so eat + ;through the wall towards it + push hl + + call AmAtEdge + jr nz,.stdMove + + ld b,0 +.checkNextDirection + call GetMapOffset + sla l ;offset times 2 + rl h + + push de + push hl + call GetCurLocation + pop de + add hl,de + pop de + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call IsMyEnemy + cp 1 + jr nz,.continue + + ;remove wall if in-between, not split and facing + ;correct direction and not a walkover tile + call GetFacing + bit 2,a + ;jr nz,.gotDirection + jr nz,.directionToB + + and %11 + cp b + ;jr nz,.gotDirection + jr nz,.directionToB + + ;remove wall before moving + push de + call GetMapOffset + push hl + call GetCurLocation + pop de + add hl,de + pop de + ld a,MAPBANK + ldio [$ff70],a + + ldio a,[firstMonster] + cp [hl] + jr z,.gotDirection + jr c,.gotDirection ;is not a wall + + ;make sure not walkover + push hl + ld l,[hl] + ld a,TILEINDEXBANK + ld [$ff70],a + ld h,((bgAttributes>>8) & $ff) + ld a,[hl] + pop hl + bit BG_BIT_WALKOVER,a + jr nz,.gotDirection ;is a walkover + + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl],a + ld hl,eatSound + call PlaySound + +.gotDirection + call StandardValidateMoveAndRedraw + pop hl + ret + +.directionToB + ld b,a + jr .gotDirection + +.continue + inc b + ld a,b + cp 4 + jr nz,.checkNextDirection + +.stdMove + pop hl + call StdMove ;nothing special found + ret + + +.chomperCheckTable + DB 5 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW .chomperSound + DB 3 ;fire delay + DW TrackEnemyVectorToState + +.chomperSound + DB 1,$59,$00,$f0,$00,$c4 + +;--------------------------------------------------------------------- +; Routine: AmAtEdge +; Arguments: c - class index of object +; de - this +; Alters: af,hl +; Returns: a - 1=at edge, 0=not at edge +; zflag - or a +;--------------------------------------------------------------------- +AmAtEdge: + ;clip and make sure I'm at least 2 from the edge + call GetCurLocation + call ConvertLocHLToXY + ld a,h + cp 2 + jr c,.returnTrue + ld a,l + cp 2 + jr c,.returnTrue + ld a,[mapWidth] + sub 3 + cp h + jr c,.returnTrue + ld a,[mapHeight] + sub 3 + cp l + jr c,.returnTrue + + xor a + ret + +.returnTrue + ld a,1 + or a + ret + +;----Reciprocator----------------------------------------------------- +ReciprocatorInit: + ld hl,.reciprocatorInitTable + jp StdInitFromTable + +.reciprocatorInitTable + DB 4 ;initial facing + DB 10 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classReciprocatorPowerup + DW RECIPROCATOR_POWERUP_CINDEX + +ReciprocatorCheck: + call GetHealth + cp 10 + jr nc,.afterChangeToPowerup + + jp ChangeMyClassToAssociatedAndRedraw + +.afterChangeToPowerup + ld hl,.reciprocatorCheckTable + jp StdCheckFromTable + +.reciprocatorCheckTable + DB 10 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW reciprocatorSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +reciprocatorSound: + DB 1,$2e,$80,$f0,$00,$c7 + +;----ReciprocatorPowerup---------------------------------------------- +ReciprocatorPowerupCheck: + ;use $c000 as temporary check table, fill in with: + ; moveDelay = health; + ; bulletDamage = 11 - health; + call GetHealth + ld b,a + ld hl,$c000 + ld [hl+],a + ld [hl],1 + inc hl + ld a,11 + sub b + ld [hl+],a + ld a,(reciprocatorSound & $ff) + ld [hl+],a + ld a,((reciprocatorSound>>8) & $ff) + ld [hl+],a + ld [hl],10 + inc hl + ld a,(TrackEnemyVectorToState & $ff) + ld [hl+],a + ld a,((TrackEnemyVectorToState>>8) & $ff) + ld [hl],a + + ld hl,$c000 + jp StdCheckFromTable + +;----Tri-------------------------------------------------------------- +TriInit: + ld hl,.triInitTable + jp StdInitFromTable + +.triInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classTriling + DW TRILING_CINDEX + +TriCheck: + call GetHealth + or a + jr nz,.afterCheckSplit + + ;split into 3 trilings + call GetCurLocation + push bc + call GetAssociated + ld c,a + + ld b,3 +.createTrilings + call FindEmptyLocationAround1x1 + or a + jr z,.doneCreateTrilings + + push de + call CreateInitAndDrawObject + pop de + dec b + jr nz,.createTrilings + +.doneCreateTrilings + pop bc + call StandardDie + ret + +.afterCheckSplit + ld hl,.triCheckTable + jp StdCheckFromTable + +.triCheckTable + DB 12 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW .triSound + DB 25 ;fire delay + DW TrackEnemyVectorToState + +.triSound + DB 1,$43,$c0,$f0,$00,$c2 + +;----Triling---------------------------------------------------------- +TrilingInit: + ld hl,.trilingInitTable + jp StdInitFromTable + +.trilingInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classTri + DW TRI_CINDEX + +TrilingCheck: + call StdCheckDead + ret z + ld hl,.trilingCheckTable + call StdCheckFromTableNotDead + + call GetMisc ;mature into adult after 256 cycles + inc a + ld [hl],a + ret nz + + jp ChangeMyClassToAssociatedAndRedraw + +.trilingCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .trilingSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +.trilingSound + DB 1,$43,$c0,$f0,$00,$c4 + +;----Tree------------------------------------------------------------- +TreeInit: + ld hl,.treeInitTable + jp StdInitFromTable + +.treeInitTable + DB DIR_EAST ;initial facing + DB 8 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classTreeBullet ;associated bullet class ptr + DW TREEBULLET_CINDEX + +TreeCheck: + ld hl,.treeCheckTable + jp StdCheckFromTable + +.treeCheckTable + DB 0 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW treeFireSound + DB 10 ;fire delay + DW 0 + +TreeTalkerCheck: + ld hl,.treeTalkerCheckTable + jp TalkerCheckAfterSetupHL + +.treeTalkerCheckTable + DB 0 ;move delay + DW 0 + +;----Bush------------------------------------------------------------- +BushInit: + ld hl,.bushInitTable + jp StdInitFromTable + +.bushInitTable + DB DIR_EAST ;initial facing + DB 4 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classBushBullet ;associated bullet class ptr + DW TREEBULLET_CINDEX + +BushCheck: + ld hl,.bushCheckTable + jp StdCheckFromTable + +.bushCheckTable + DB 0 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW bushFireSound + DB 15 ;fire delay + DW 0 + +;----Needle----------------------------------------------------------- +NeedleInit: + ld hl,.needleInitTable + call StdInitFromTable + ld a,3 + call SetDestL ;bullet damage + xor a + call SetMoveLimit ;bullet color + xor a + jp SetMisc ;not triggered + +.needleInitTable + DB 4 ;initial facing + DB 8 ;health + DB GROUP_MONSTERC + DB 0 ;has bullet + +NeedleCheck: + call GetMisc ;triggered? + or a + jr z,.notTriggered + jp SuperFastBulletCheck +.notTriggered + ld hl,.needleCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + + call GetFacing + bit 2,a ;split tile? + jr nz,.noEnemy ;don't "fire" on the split tile + + xor a + ld [losLimit],a + ld a,4 +.lookInAllDirections + push af + call LookForEnemyInLOS + or a + jr nz,.foundEnemy + pop af + dec a + jr nz,.lookInAllDirections + jr .noEnemy + +.foundEnemy + pop af + ld a,1 + call SetMisc ;mark as triggered + + ld hl,.needleTriggeredSound + call PlaySound + + call .amFacingB + ret z + + ;close split tile or turn in dir + push bc + call StandardValidateMoveAndRedraw ;move in dir 'b' + pop bc + call .amFacingB + ret z + + ;closed split tile, now turn in dir + jp StandardValidateMoveAndRedraw ;move in dir 'b' + +.noEnemy + ;move forward if possible + call GetFacing + and %11 + ld b,a + xor a + call CheckDestEmpty + or a + jr z,.turnInRandomDir + jp StandardValidateMoveAndRedraw + +.turnInRandomDir + ld a,%11 + call GetRandomNumMask + ld b,a + jp StandardValidateMoveAndRedraw + +.amFacingB + call GetFacing ;turn to face enemy + and %11 + cp b + ret ;z=1 facing direction of enemy, z=0 not + +.needleCheckTable + DB 8 ;move delay + +.needleTriggeredSound + DB 1,$15,$00,$f0,$00,$c4 + +;----Bat-------------------------------------------------------------- +BatInit: + ld hl,.batInitTable + call StdInitFromTable + + ;countdown until turn invisible + ld a,15 + call GetRandomNumMask + add 10 + call SetMisc + + ld b,c ;this->assoc->assoc = this + call GetAssociated + ld c,a + call SetAssociated + + ret + +.batInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC + DB 1 ;has bullet + DW classInvisibleBat + DW INVISIBLEBAT_CINDEX + +BatCheck: + call StdCheckDead + ret z + + ld hl,.batCheckTable + call StdCheckFromTableNotDead + + call GetAttackDelay ;attacked someone? + or a + jr z,.checkInvisible + + ld a,50 ;delay until invisible + call SetMisc + ret + +.checkInvisible + call GetMisc + dec a + ld [hl],a + ret nz + jp ChangeMyClassToAssociatedAndRedraw + +.batCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW batFireSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +batFireSound: + DB 1,$35,$00,$f0,$00,$c7 + +;----Burrower-------------------------------------------------------------- +BurrowerInit: + ld hl,.burrowerInitTable + call StdInitFromTable + + ld a,10 ;keep track of my health + call SetMisc + + ld b,c ;this->assoc->assoc = this + call GetAssociated + ld c,a + call SetAssociated + + ret + +.burrowerInitTable + DB 4 ;initial facing + DB 10 ;health (above also) + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classBurrowerDirt + DW BURROWER_DIRT_CINDEX + +BurrowerCheck: + ;burrow if I've taken damage + call GetHealth + ld b,a + call GetMisc + cp b + jr z,.normalCheck ;same health, no burrow + + ld a,64 ;cycles until unburrow + call SetMisc + + jp ChangeMyClassToAssociatedAndRedraw + +.normalCheck + ld hl,.burrowerCheckTable + jp StdCheckFromTable + +.burrowerCheckTable + DB 5 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .burrowerSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +.burrowerSound + DB 1,$2c,$c0,$f0,$00,$c4 + +;----BurrowerDirt---------------------------------------------------------- +BurrowerDirtInit: + ld hl,.burrowerDirtInitTable + jp StdInitFromTable + +.burrowerDirtInitTable + DB 4 ;initial facing + DB 10 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classBurrower + DW BURROWER_CINDEX + +BurrowerDirtCheck: + ;unburrow at end of 64 cycles + call GetMisc + dec [hl] + jr nz,.normalCheck + + call GetHealth ;track my health + call SetMisc + + jp ChangeMyClassToAssociatedAndRedraw + +.normalCheck + ld hl,.burrowerDirtCheckTable + jp StdCheckFromTable + +.burrowerDirtCheckTable + DB 7 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +;----Dandelion-------------------------------------------------------- +DandelionInit: + ld hl,.dandelionInitTable + call StdInitFromTable + jp LinkAssocToMe + +.dandelionInitTable + DB 1 ;initial facing + DB 1 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classDandelionPuff + DW DANDELIONPUFF_CINDEX + +DandelionCheck: + call GetHealth + or a + ret nz + + call GetCurLocation + push bc + call GetAssociated + ld c,a + + ld b,4 +.createPuffs + call FindEmptyLocationAround1x1 + or a + jr z,.doneCreatePuffs + + push de + call CreateInitAndDrawObject + pop de + dec b + jr nz,.createPuffs + +.doneCreatePuffs + pop bc + + jp StdCheckDead + +;----Dandelion Puff--------------------------------------------------- +DandelionPuffInit: + ld hl,.dandelionPuffInitTable + call StdInitFromTable + ld a,255 ;countdown till take root + jp SetMisc + +.dandelionPuffInitTable + DB 4 ;initial facing + DB 1 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classDandelion + DW DANDELION_CINDEX + +DandelionPuffCheck: + call GetMisc + dec [hl] ;countdown till root + jr nz,.checkAttach + + ld a,[numFreeObjects] + cp (255-60) + jr nc,.takeRoot + + xor a + jp SetHealth + +.takeRoot + call MoveForwardIfSplit + jp ChangeMyClassToAssociatedAndRedraw + +.checkAttach + ld hl,.dandelionPuffCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z +.checkAttack + ld a,1 + ld [losLimit],a + call LookForEnemyInLOS + or a + jr z,.noEnemy + +.enemyFound + xor a + call SetHealth ;die next time + ld hl,.dandelionPuffAttackSound + call PlaySound + ld a,[fireBulletLocation] ;location of enemy + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + ld a,MAPBANK + ld [$ff70],a + ld a,[hl] ;enemy class index + call EnsureTileIsHead + ld c,a + ld d,h + ld e,l + call FindObject + call GetPuffCount + cp 15 + ret z + add 1 + call SetPuffCount + ret + +.noEnemy + inc hl + inc hl + inc hl + inc hl + inc hl + jp StdMove + +.dandelionPuffCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW .dandelionPuffAttackSound + DB 1 ;fire delay + DW StdVectorToState + +.dandelionPuffAttackSound + DB 1,$7c,$80,$f4,$00,$84 + +;----Mouse------------------------------------------------------------ +MouseInit: + ld hl,.mouseInitTable + jp StdInitFromTable + +.mouseInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_HERO ;group + DB 1 ;has bullet + DW classUberMouse ;associated bullet class ptr + DW UBERMOUSE_CINDEX + +MouseCheck: + ;health >= 5? + call GetHealth + cp 5 + jr c,.mouseCheck + + ;want to become UberMouse + ld a,63 + call SetHealth + call GetFacing ;must not be split or sprite + and %10000100 + jr nz,.mouseCheck + + ;adjacent locations must be clear + call GetCurLocation + inc hl + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + or a + jr nz,.mouseCheck ;not empty + + ld a,[mapPitch] + add l + ld l,a + ld a,h + adc 0 + ld h,a + ld a,[hl-] + or a + jr nz,.mouseCheck + ld a,[hl] + or a + jr nz,.mouseCheck + + jp ChangeMyClassToAssociatedAndRedraw + +.mouseCheck + ld hl,.mouseCheckTable + jp StdCheckFromTable + +.mouseCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .mouseFireSound + DB 4 ;fire delay + DW StdVectorToState + +.mouseFireSound + DB 1,$17,$80,$f0,$00,$c7 + + +;----Penguin---------------------------------------------------------- +PenguinInit: + ld hl,.penguinInitTable + jp StdInitFromTable + +.penguinInitTable + DB 4 ;initial facing + DB 5 ;health + DB GROUP_MONSTERB ;group + DB 0 ;has bullet + +PenguinCheck: + ld hl,.penguinCheckTable + jp StdCheckFromTable + +.penguinCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .penguinFireSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +.penguinFireSound + DB 1,$2e,$c0,$f0,$00,$c6 + +;----BIOS------------------------------------------------------------- +BIOSInit: + ld hl,.BIOSInitTable + jp StdInitFromTable + +.BIOSInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_MONSTERA ;group + DB 0 ;has bullet + +BIOSCheck: + ld hl,.BIOSCheckTable + jp StdCheckFromTable + +.BIOSCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .BIOSFireSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +.BIOSFireSound + DB 1,$01,$00,$f0,$00,$c4 + +;----Crouton Hulk----------------------------------------------------- +CroutonHulkInit: + ld hl,.croutonHulkInitTable + jp StdInitFromTable + +.croutonHulkInitTable + DB 4 ;initial facing + DB 10 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classCroutonBullet ;associated bullet class ptr + DW CROUTONBULLET_CINDEX + +CroutonHulkCheck: + ld hl,.croutonHulkCheckTable + jp StdCheckFromTable + +.croutonHulkCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW hulkFireSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +CroutonGruntInit: + ld hl,.croutonGruntInitTable + jp StdInitFromTable + +.croutonGruntInitTable + DB 4 ;initial facing + DB 5 ;health + DB GROUP_MONSTERA ;group + DB 0 ;has bullet + +;----Crouton Grunt---------------------------------------------------- +CroutonGruntCheck: + ld hl,.croutonGruntCheckTable + jp StdCheckFromTable + +.croutonGruntCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW gruntFireSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +;----Wolf------------------------------------------------------------- +WolfSheepInit: + ld hl,.wolfSheepInitTable + jp StdInitFromTable + +.wolfSheepInitTable + DB 4 ;initial facing + DB 3 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classWolf ;associated bullet class ptr + DW WOLF_CINDEX + +WolfInit: + ld hl,.wolfInitTable + call StdInitFromTable + + call LinkAssocToMe + + jp ChangeMyClassToAssociatedAndRedraw + +.wolfInitTable: + DB 4 ;initial facing + DB 3 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classWolfSheep ;associated bullet class ptr + DW SHEEP_CINDEX + +WolfCheck: + call StdCheckDead + ret z + + ld hl,.wolfCheckTable + call StdCheckFromTableNotDead + + call GetAttackDelay + or a + jr z,.checkChangeToSheep + + ld a,100 ;delay until I can change back + call SetMisc + ret + +.checkChangeToSheep + ;turn back into a sheep after bit + call GetMisc ;countdown until sheep + dec a + ld [hl],a + ret nz + jp ChangeMyClassToAssociatedAndRedraw + +.wolfCheckTable: + DB 2 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW wolfFireSound + DB 6 ;fire delay + DW TrackEnemyVectorToState + +WolfSheepCheck: + call StdCheckDead + ret z + + ld hl,.wolfSheepCheckTable + call StdCheckFromTableNotDead + + ;turn into a wolf if I attacked somebody + call GetAttackDelay ;attacked this round? + or a + ret z + + ;change into wolf + ld a,100 ;delay until I can change back + call SetMisc + jp ChangeMyClassToAssociatedAndRedraw + +.wolfSheepCheckTable: + DB 5 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW wolfFireSound + DB 6 ;fire delay + DW TrackEnemyVectorToState + +wolfFireSound: + DB 1,$1d,$40,$f2,$00,$82 + +WolfSheepTakeDamage: + call StdTakeDamage + + ;change into wolf + ld a,100 ;delay until I can change back + call SetMisc + jp ChangeMyClassToAssociatedAndRedraw + +;--------------------------------------------------------------------- +; LinkAssocToMe +;--------------------------------------------------------------------- +LinkAssocToMe: + push bc + ld b,c ;this->assoc->assoc = this + call GetAssociated + ld c,a + call SetAssociated + pop bc + ret + +;----Snake------------------------------------------------------------ +SnakeInit: + ld hl,.snakeInitTable + jp StdInitFromTable + +.snakeInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +SnakeCheck: + push bc + ld bc,ITEM_SNAKEBITEKIT + call HasInventoryItem + pop bc + jr z,.checkNoKit + +.checkWithKit + ld hl,.snakeCheckTable + jp StdCheckFromTable + +.checkNoKit + ld hl,.snakeCheckTableNoKit + jp StdCheckFromTable + +.snakeCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .snakeFireSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +.snakeCheckTableNoKit + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 20 ;bullet damage + DW .snakeFireSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +.snakeFireSound + DB 4,$00,$f3,$41,$80 + +;----Neanderthal------------------------------------------------------ +NeanderthalInit: + ld hl,.neanderthalInitTable + call StdInitFromTable + ld a,4 + jp SetMisc ;direction throwing enemy 4=none + +.neanderthalInitTable + DB 4 ;initial facing + DB 6 ;health + DB GROUP_MONSTERD ;group + DB 0 ;has bullet + +NeanderthalCheck: + ld hl,.neanderthalCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + call .neanderthalCheckAttack + ret z + call StdMove + ret + +.neanderthalCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .neanderthalAttackSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +.neanderthalCheckAttack + ;can I attack yet? + push hl + call DecrementAttackDelay + pop hl + or a + jr nz,.attackOkay + inc hl +.didntFindEnemy + inc hl + inc hl + inc hl + inc hl + jr .skipAttack + +.attackOkay + ld a,[hl+] + +.meleeOnly + ld a,1 + ld [losLimit],a + call LookForEnemyInLOS ;returns dir of enemy in b + or a + jr z,.didntFindEnemy + +.foundEnemy + + ;Fire instead of moving + ld a,[curObjWidthHeight] + push af + + ld a,[hl+] ;bullet damage + push hl + push af + + ld a,[hl+] ;hl = fire sound + ld h,[hl] + ld l,a + + pop af ;damage + call StdFireBullet ;b is direction to fire + pop hl + inc hl + inc hl + ld a,[hl+] ;delay + call SetAttackDelay + + ;throw enemy object away from us + push hl + ld a,[fireBulletLocation] + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + call ThrowObjAtHLInDirB + pop hl + + pop af + ld [curObjWidthHeight],a + + ;turn to face the direction we just fired + call GetFacing + and %11 + cp b + jr z,.skipMove ;no need to turn + + ld a,1 + ld [moveAlignPrecision],a + call StandardValidateMoveAndRedraw + + jr .skipMove + +.skipAttack + ld a,1 ;return nz (go ahead and move) + or a + ret + +.skipMove + xor a ;return z (skip move) + ret + +.neanderthalAttackSound + DB 1,$79,$c0,$f3,$00,$c3 + +ThrowObjAtHLInDirB: + push bc + push de + push hl + ldio a,[curObjWidthHeight] + push af + ld a,MAPBANK + ldio [$ff70],a + ldio a,[firstMonster] + ld c,a + ld a,[hl] + cp c + jr c,.done ;no monster here + + call EnsureTileIsHead + ld d,h + ld e,l + ld c,a + call GetFGAttributes + and FLAG_NOTHROW + jr nz,.done + + call FindObject + call SetObjWidthHeight + call StandardValidateMoveAndRedraw + call StandardValidateMoveAndRedraw + call PointToSpecialFlags + set OBJBIT_THROWN,[hl] + + ;set timer to current-1 to ensure this moves next check + ld hl,OBJ_FRAME + add hl,de + ld a,[hl] + and %11100111 + ld b,a + ld a,[objTimer60ths] + sub %00001000 + and %00011000 + or b + ld [hl+],a + ld [hl],1 ;can move next turn + +.done + pop af + ldio [curObjWidthHeight],a + pop hl + pop de + pop bc + ret + +;----Crow------------------------------------------------------------- +CrowInit: + ld hl,.crowInitTable + call StdInitFromTable + ld hl,0 + call SetFoodIndexRange + ret + +.crowInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +CrowCheck: + ld hl,.crowCheckTable + jp StdCheckFromTable + +.crowCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .crowSound + DB 20 ;fire delay + DW EatVectorToState + +.crowSound + DB 1,$4c,$80,$f0,$00,$c5 + +;----Scarecrow-------------------------------------------------------- +ScarecrowInit: + ld hl,.scarecrowInitTable + jp StdInitFromTable + +.scarecrowInitTable + DB 1 ;initial facing + DB 20 ;health + DB GROUP_MONSTERN ;group + DB 0 ;has bullet + +ScarecrowCheck: + ld hl,.crowCheckTable + jp StdCheckFromTable + +.crowCheckTable + DB 0 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW nullSound + DB 20 ;fire delay + DW 0 + +ScarecrowTakeDamage: + ;call GetFacing + ;xor %10 + ;call SetFacing + ;ld b,METHOD_DRAW + ;call CallMethod + jp StdTakeDamage2x2 + +;----Alligator-------------------------------------------------------- +AlligatorInit: + ld hl,.alligatorInitTable + jp StdInitFromTable +.alligatorInitTable + DB 4 ;initial facing + DB 13 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +AlligatorCheck: + call StdCheckDead + ret z + + ;save original facing + call GetFacing + and %00000011 + push af + + ld hl,.alligatorCheckTable + call StdCheckFromTableNotDead + + ;if facing changes set move delay to 10 + call GetFacing + and %00000011 + pop bc + cp b + ret z + ld a,10 + call SetMoveDelay + ret + +.alligatorCheckTable + DB 2 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .alligatorAttackSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +.alligatorAttackSound + DB 1,$d9,$00,$f0,$00,$c4 + +;----Scorpion--------------------------------------------------------- +ScorpionInit: + ld hl,.scorpionInitTable + jp StdInitFromTable + +.scorpionInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC + DB 0 ;has bullet + +ScorpionCheck: + ld hl,.scorpionCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + call .scorpionCheckAttack + ret z + call StdMove + ret + +.scorpionCheckAttack + ;can I attack yet? + push hl + call DecrementAttackDelay + pop hl + or a + jr nz,.attackOkay + inc hl +.didntFindEnemy + inc hl + inc hl + inc hl + inc hl + jr .skipAttack + +.attackOkay + ld a,[hl+] + +.meleeOnly + ld a,1 + ld [losLimit],a + call LookForEnemyInLOS ;returns dir of enemy in b + or a + jr z,.didntFindEnemy + +.foundEnemy + ;Fire instead of moving + ld a,[curObjWidthHeight] + push af + + ld a,[hl+] ;bullet damage + push hl + push af + + ld a,[hl+] ;hl = fire sound + ld h,[hl] + ld l,a + + pop af ;damage + call StdFireBullet ;b is direction to fire + pop hl + inc hl + inc hl + ld a,[hl+] ;delay + call SetAttackDelay + + ;freeze enemy + push bc + push de + push hl + ld a,[fireBulletLocation] + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call EnsureTileIsHead + ld d,h + ld e,l + ld c,a + call FindObject + + ;freeze the enemy for a bit + call GetHealth + or a + jr z,.afterFreeze + + ld a,60 + call SetMoveDelay + + call GetHealth ;deal 1 point of damage + dec a ;(so can't get stuck with Haiku) + call SetHealth + +.afterFreeze + pop hl + pop de + pop bc + + pop af + ld [curObjWidthHeight],a + + ;turn to face the direction we just fired + call GetFacing + and %11 + cp b + jr z,.skipMove ;no need to turn + + ld a,1 + ld [moveAlignPrecision],a + call StandardValidateMoveAndRedraw + + jr .skipMove + +.skipAttack + ld a,1 ;return nz (go ahead and move) + or a + ret + +.skipMove + xor a ;return z (skip move) + ret + +.scorpionCheckTable + DB 5 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW scorpionFireSound + DB 15 ;fire delay + DW StdVectorToState + +scorpionFireSound: + DB 1,$3b,$c0,$f0,$00,$c4 + + +;----Bow-------------------------------------------------------------- +BowInit: + ld hl,.bowInitTable + jp StdInitFromTable + +.bowInitTable + DB 4 ;initial facing + DB 3 ;health + DB GROUP_MONSTERC + DB 1 ;has bullet + DW classArrowBullet + DW ARROWBULLET_CINDEX + +BowCheck: + ld hl,.bowCheckTable + jp StdCheckFromTable + +.bowCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=none,1=melee,2=missile) + DB 2 ;bullet damage + DW bowFireSound + DB 8 ;fire delay + DW StdVectorToState + +bowFireSound: + DB 1,$25,$00,$f0,$00,$c3 + +;----Cowboy----------------------------------------------------------- +CowboyInit: + ld hl,.cowboyInitTable + jp StdInitFromTable + +.cowboyInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_MONSTERM ;friends + DB 1 ;has bullet + DW classCowboyBullet + DW COWBOYBULLET_CINDEX + +CowboyCheck: + ld hl,.cowboyCheckTable + jp StdCheckFromTable + +.cowboyCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW cowboyFireSound + DB 6 ;fire delay + DW StdVectorToState + +cowboyFireSound: + DB 4,$00,$f2,$42,$80 + +AngryCowboyCheck: + ld hl,.cowboyCheckTable + jp StdCheckFromTable + +.cowboyCheckTable + DB 2 ;move delay + DB 2 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW cowboyFireSound + DB 6 ;fire delay + DW TrackEnemyVectorToState + +;----Crouton Doctor / Guard------------------------------------------- +CroutonDoctorInit: + ld hl,.croutonDoctorInitTable + jp StdInitFromTable + +.croutonDoctorInitTable + DB 4 ;initial facing + DB 3 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classCroutonBullet ;associated bullet class ptr + DW CROUTONBULLET_CINDEX + +CroutonDoctorCheck: + ld hl,.croutonDoctorCheckTable + jp StdCheckFromTable + +.croutonDoctorCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW guardFireSound + DB 6 ;fire delay + DW TrackEnemyVectorToState + +;----Crouton Wizard--------------------------------------------------- +CroutonWizardInit: + ld hl,.croutonWizardInitTable + jp StdInitFromTable + +.croutonWizardInitTable + DB 4 ;initial facing + DB 3 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classWizardBullet ;associated bullet class ptr + DW WIZARDBULLET_CINDEX + +CroutonWizardCheck: + ld hl,.croutonWizardCheckTable + jp StdCheckFromTable + +.croutonWizardCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW .wizardFireSound + DB 6 ;fire delay + DW TrackEnemyVectorToState + +.wizardFireSound + DB 1,$34,$40,$f6,$00,$81 + +;----Big Bee Hive----------------------------------------------------- +BigBeeHiveCheck: + ;randomly create a bee every so often + ld a,127 + call GetRandomNumMask + or a + jr nz,.afterCreateBee + + ld a,[numFreeObjects] + cp (255-32) + jr c,.afterCreateBee + + call FindEmptyLocationAround2x2 + ld a,h + or a + jr z,.afterCreateBee + + push bc + push de + ld bc,classBee + call FindClassIndex + or a + jr z,.afterCreateObject + ld c,a + call CreateInitAndDrawObject +.afterCreateObject + pop de + pop bc + +.afterCreateBee + ld hl,.bigBeeHiveCheckTable + jp StdCheckFromTable + +.bigBeeHiveCheckTable + DB 0 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW beeSound + DB 20 ;fire delay + DW 0 + +;----Sheep------------------------------------------------------------ +SheepCheck: + call GetHealth + or a + jr nz,.afterChangeToDrumstick + + call GetCurLocation + push hl + call StandardDie + pop hl + + ld bc,classDrumstickBG + call FindClassIndex + push af + ld a,MAPBANK + ldio [$ff70],a + pop af + ld [hl],a + + jp ResetMyBGSpecialFlags + +.afterChangeToDrumstick + jp GenericCheck + +;----Chicken---------------------------------------------------------- +ChickenInit: + ld hl,.chickenInitTable + jp StdInitFromTable + +.chickenInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERB ;group + DB 1 ;has bullet + DW classEgg + DW EGG_CINDEX + +ChickenCheck: + ;lay egg? + ld a,255 + call GetRandomNumMask + or a + jr nz,.afterLayEgg + ldio a,[updateTimer] + and %11 + or a + jr nz,.afterLayEgg + ld a,[numFreeObjects] + cp 200 + jr c,.afterLayEgg + + push bc + call GetAssociated + ld c,a + call FindEmptyLocationAround1x1 + or a + jr z,.afterCreateEgg + push de + call CreateInitAndDrawObject + pop de +.afterCreateEgg + pop bc + +.afterLayEgg + ld hl,.chickenCheckTable + jp StdCheckFromTable + +.chickenCheckTable + DB 5 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 30 ;fire delay + DW StdVectorToState + +;----Wisp------------------------------------------------------------- +WispInit: + ld hl,.wispInitTable + jp StdInitFromTable + +.wispInitTable + DB 4 ;initial facing + DB 1 ;health + DB GROUP_MONSTERC ;group + DB 0 ;has bullet + +WispCheck: + ld hl,.wispCheckTable + call StdCheckDead + ret z + call StdCheckTimeToMove + ret z + call .wispCheckAttack + ret z + call StdMove + ret + +.wispCheckAttack + ;can I attack yet? + push hl + call DecrementAttackDelay + pop hl + or a + jr nz,.attackOkay + inc hl +.didntFindEnemy + inc hl + inc hl + inc hl + inc hl + jp .skipAttack + +.attackOkay + ld a,[hl+] + +.meleeOnly + ld a,1 + ld [losLimit],a + call LookForEnemyInLOS ;returns dir of enemy in b + or a + jr z,.didntFindEnemy + +.foundEnemy + ;Fire instead of moving + ld a,[curObjWidthHeight] + push af + + ld a,[hl+] ;bullet damage + push hl + push af + + ld a,[hl+] ;hl = fire sound + ld h,[hl] + ld l,a + + pop af ;damage + call StdFireBullet ;b is direction to fire + pop hl + inc hl + inc hl + ld a,[hl+] ;delay + call SetAttackDelay + + push bc + ;exchange enemy with another randomly selected wisp + ld a,c + call CountNumObjects + dec a + jr z,.afterExchange + call GetRandomNumZeroToN + + ld b,a + inc b + + push bc ;save my class and object + push de + + call GetFirst + dec b + jr z,.foundRemoteWisp + +.findWisp + call GetNextObject + dec b + jr nz,.findWisp + +.foundRemoteWisp + ;save remote wisp's class and object + push bc + push de + + call GetCurLocation + push hl + + call .wispRemove + + call GetFireTargetAsObject + call GetCurLocation + push hl + call .wispRemove + ld hl,sp+2 ;other object's location + ld a,[hl+] + ld h,[hl] + ld l,a + call SetCurLocation + ld b,METHOD_DRAW + call CallMethod + + ;reset camera if it was the hero that was moved + LDHL_CURHERODATA HERODATA_OBJ + ld a,[hl+] + cp e + jr nz,.afterResetCamera + ld a,[hl+] + cp d + jr nz,.afterResetCamera + + call AdjustCameraToHero + call RestrictCameraToBounds + ld a,[desiredMapLeft] + ld [mapLeft],a + ld a,[desiredMapTop] + ld [mapTop],a +.afterResetCamera + + pop hl + pop de ;first location(discard) + + pop de ;first object + pop bc + call SetCurLocation + ld b,METHOD_DRAW + call CallMethod + +.exchangeDone + pop de + pop bc +.afterExchange + pop bc + + pop af + ld [curObjWidthHeight],a + + ;turn to face the direction we just fired + call GetFacing + and %11 + cp b + jr z,.skipMove ;no need to turn + + ld a,1 + ld [moveAlignPrecision],a + call StandardValidateMoveAndRedraw + + jr .skipMove + +.skipAttack + ld a,1 ;return nz (go ahead and move) + or a + ret + +.skipMove + xor a ;return z (skip move) + ret + +.wispCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .wispFireSound + DB 4 ;fire delay + DW StdVectorToState + +.wispFireSound + DB 1,$75,$c0,$f0,$00,$c6 + +.wispRemove + call GetFGAttributes + and FLAG_2X2 + swap a + ldio [curObjWidthHeight],a + call GetFacing + push bc + ld c,a + call RemoveFromMap + pop bc + call GetFacing + and %11111011 ;turn off split + jp SetFacing + +;----GetFireTargetAsObject-------------------------------------------- +GetFireTargetAsObject: + ld a,[fireBulletLocation] + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call EnsureTileIsHead + ld d,h + ld e,l + ld c,a + jp FindObject + +;----Quatrain--------------------------------------------------------- +QuatrainInit: + ld hl,.quatrainInitTable + jp StdInitFromTable + +.quatrainInitTable + DB 4 ;initial facing + DB 10 ;health + DB GROUP_MONSTERA ;group + DB 0 ;has bullet + +QuatrainCheck: + ld hl,.quatrainCheckTable + jp StdCheckFromTable + +.quatrainCheckTable + DB 1 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW nullSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +;----Crouton Goblin--------------------------------------------------- +CroutonGoblinInit: + ld hl,.croutonGoblinInitTable + jp StdInitFromTable +.croutonGoblinInitTable + DB 4 ;initial facing + DB 1 ;health + DB GROUP_MONSTERA ;group + DB 0 ;has bullet + +CroutonGoblinCheck: + ld hl,.croutonGoblinCheckTable + jp StdCheckFromTable + +.croutonGoblinCheckTable + DB 2 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW goblinSound + DB 3 ;fire delay + DW TrackEnemyVectorToState + +;----General Gyro----------------------------------------------------- +GeneralGyroInit: + ld hl,.gyroInitTable + jp StdInitFromTable +.gyroInitTable + DB 4 ;initial facing + DB 63 ;health (max) + DB GROUP_MONSTERA ;group + DB 0 ;has bullet + +;----Crouton Artillery------------------------------------------------ +CroutonArtilleryInit: + ld hl,.croutonArtilleryInitTable + jp StdInitFromTable +.croutonArtilleryInitTable + DB 4 ;initial facing + DB 10 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classRocketBullet ;associated bullet class ptr + DW CROUTONROCKET_CINDEX + +CroutonArtilleryCheck: + call StdCheckDead + ret z + + ;save original facing + call GetFacing + and %00000011 + push af + + ld hl,.croutonArtilleryCheckTable + call StdCheckFromTableNotDead + + ;if facing changes set move delay to 15 + call GetFacing + and %00000011 + pop bc + cp b + ret z + ld a,15 + call SetMoveDelay + ret + +.croutonArtilleryCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 6 ;bullet damage + DW rocketFireSound + DB 10 ;fire delay + DW TrackEnemyVectorToState + +;----Teleport Cube---------------------------------------------------- +TeleportCubeInit: + ld hl,.cubeInitTable + call StdInitFromTable + jp LinkAssocToMe + +.cubeInitTable + DB 1 ;initial facing + DB 2 ;health + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classTeleportCube2 + DW TCUBE2_CINDEX + +TeleportCubeCheck: + call GetCurLocation + push hl + call StdCheckDead + pop hl + jr nz,.tick + + ;died because of being shot (was timer up?) + push hl + call GetMisc + pop hl + cp 254 + ret nz + + ;finished; resolve into one or more enemies + ld a,3 + call GetRandomNumMask + cp 2 + jr nc,.cluster + + ;one big enemy + or a + jr nz,.artillery + + ;create a hulk + ld bc,classCroutonHulk + jr .createSingle + +.artillery + ld bc,classCroutonArtillery +.createSingle + call FindClassIndex + ret z + ld c,a + jp CreateInitAndDrawObject + +.cluster + ;create a cluster of grunts or goblins + and 1 + jr nz,.goblins + + ld bc,classCroutonGrunt + jr .createCluster + +.goblins + ;goblins + ld bc,classCroutonGoblin +.createCluster + call FindClassIndex + ret z + ld c,a + call CreateInitAndDrawObject + inc hl + call CreateInitAndDrawObject + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + call CreateInitAndDrawObject + dec hl + jp CreateInitAndDrawObject + +.tick + call GetMisc + add 2 + ld [hl],a + cp 254 + jr nz,.notFinished + + xor a + call SetHealth + ret + +.notFinished + ;determine how fast we're flashing + ld a,[hl] + cp 226 + jr nc,.speed1 + cp 200 + jr nc,.speed2 + cp 150 + jr nc,.speed3 + cp 100 + jr nc,.speed4 +.speed5 + ldio a,[updateTimer] + and %11111 + jr .checkFlash + +.speed4 + ldio a,[updateTimer] + and %1111 + jr .checkFlash + +.speed3 + ldio a,[updateTimer] + and %111 + jr .checkFlash + +.speed2 + ldio a,[updateTimer] + and %11 + jr .checkFlash + +.speed1 + xor a + +.checkFlash + ret nz + + ld hl,.flashSound + call PlaySound + jp ChangeMyClassToAssociatedAndRedraw + +.flashSound + DB 1,$35,$40,$f0,$00,$c4 + +TeleportCubeCheck2: + call StdCheckDead + ret z + jp ChangeMyClassToAssociatedAndRedraw + +;----Dandelion Guard-------------------------------------------------- +DandelionGuardInit: + ld hl,.dandelionGuardInitTable + jp StdInitFromTable + +.dandelionGuardInitTable + DB 4 ;initial facing + DB 5 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classPansyBullet ;associated bullet class ptr + DW PANSYBULLET_CINDEX + +DandelionGuardCheck: + ld hl,.dandelionGuardCheckTable + jp StdCheckFromTable + +.dandelionGuardCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW .dandelionGuardFireSound + DB 8 ;fire delay + DW TrackEnemyVectorToState + +.dandelionGuardFireSound + DB 1,$32,$80,$f0,$00,$c3 + +;----B12 Soldier------------------------------------------------------ +B12SoldierInit: + ld hl,.b12SoldierInitTable + jp StdInitFromTable + +.b12SoldierInitTable + DB 4 ;initial facing + DB 8 ;health + DB GROUP_MONSTERB ;group + DB 1 ;has bullet + DW classB12SoldierBullet ;associated bullet class ptr + DW B12SOLDIERBULLET_CINDEX + +B12SoldierCheck: + ld hl,.b12SoldierCheckTable + jp StdCheckFromTable + +.b12SoldierCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW baFireSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +;----Big Spider------------------------------------------------------- +BigSpiderInit: + ld hl,.bigSpiderInitTable + jp StdInitFromTable + +.bigSpiderInitTable + DB 4 ;initial facing + DB 9 ;health + DB GROUP_MONSTERE ;group + DB 0 ;has bullet + +BigSpiderCheck: + ld hl,.bigSpiderCheckTable + jp StdCheckFromTable + +.bigSpiderCheckTable + DB 12 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW .bigSpiderSound + DB 5 ;fire delay + DW StdVectorToState + +.bigSpiderSound + DB $33,$80,$f0,$00,$c5 + +;----Little Spider---------------------------------------------------- +LittleSpiderInit: + ld hl,.littleSpiderInitTable + jp StdInitFromTable + +.littleSpiderInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERE ;group + DB 0 ;has bullet + +LittleSpiderCheck: + ld hl,.littleSpiderCheckTable + jp StdCheckFromTable + +.littleSpiderCheckTable + DB 10 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .littleSpiderSound + DB 5 ;fire delay + DW StdVectorToState + +.littleSpiderSound + DB $33,$80,$f0,$60,$c5 + +;----Invisible Bat---------------------------------------------------- +InvisibleBatCheck: + call StdCheckDead + ret z + + ld hl,.invisibleBatCheckTable + call StdCheckFromTableNotDead + + ;make a noise every so often + ld hl,updateTimer + ld a,e + rrca + rrca + rrca + add [hl] + and %11111 + cp %10000 + jr nz,.checkAttack + + ld hl,batFireSound + call PlaySound + +.checkAttack + call GetAttackDelay ;attacked someone? + or a + ret z + + call ChangeMyClassToAssociatedAndRedraw + ld a,50 ;delay until invisible + jp SetMisc + +.invisibleBatCheckTable + DB 3 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW batFireSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +InvisibleBatTakeDamage: + call StdTakeDamage + + call ChangeMyClassToAssociatedAndRedraw + ld a,50 ;delay until invisible + jp SetMisc + + +;----Slime------------------------------------------------------------ +SlimeInit: + call GetCurLocation + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl],a ;clear slime BG tile I'm on + + ld hl,.slimeInitTable + jp StdInitFromTable + +.slimeInitTable + DB 4 ;initial facing + DB 1 ;health + DB GROUP_MONSTERC + DB 0 ;has bullet + +SlimeCheck: + ld hl,.slimeCheckTable + jp StdCheckFromTable + +.slimeCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW .slimeFireSound + DB 20 ;fire delay + DW TrackEnemyVectorToState + +.slimeFireSound + DB 1,$35,$00,$f0,$00,$c7 + +;----Egg-------------------------------------------------------------- +EggInit: + ld hl,.eggInitTable + call StdInitFromTable + ld a,255 + jp SetMisc ;turns until hatch + +.eggInitTable + DB 1 ;initial facing + DB 2 ;health + DB GROUP_MONSTERN + DB 1 ;has bullet + DW classChicken + DW CHICKEN_CINDEX + +;----Monkey----------------------------------------------------------- +MonkeyInit: + push bc + push de + ld de,classSleepingMonkey + ld hl,MONKEY_CINDEX + ld a,1 + call LoadAssociatedClass + pop de + pop bc + + ld hl,.monkeyInitTable + jp StdInitFromTable + +.monkeyInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERD + DB 1 ;has bullet + DW classBananaBullet + DW BANANABULLET_CINDEX + +MonkeyCheck: + ld hl,.monkeyCheckTable + jp StdCheckFromTable + +.monkeyCheckTable + DB 3 ;move delay + DB 2 ;attack type (0=none,1=melee,2=missile) + DB 1 ;bullet damage + DW monkeyFireSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +monkeyFireSound: + DB 1,$57,$2a,$f3,$10,$c7 + +;----Duke------------------------------------------------------------- +DukeInit: + ld hl,.dukeInitTable + jp StdInitFromTable +.dukeInitTable + DB 4 ;initial facing + DB 63 ;health (max) + DB GROUP_MONSTERD ;group + DB 1 ;has bullet + DW classBananaBullet + DW BANANABULLET_CINDEX + +DukeCheck: + ld hl,.dukeCheckTable + jp StdCheckFromTable + +.dukeCheckTable + DB 5 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 3 ;bullet damage + DW monkeyFireSound + DB 3 ;fire delay + DW StdVectorToState + +;----Pig-------------------------------------------------------------- +PigCheck: + call GetHealth + or a + jr nz,.afterPorkProducts + + call GetCurLocation + push hl + call StandardDie + pop hl + + ld bc,classPorkBG + call FindClassIndex + ld b,a + ld a,MAPBANK + ldio [$ff70],a + ld a,2 + call GetRandomNumZeroToN + add b + ld [hl],a + + call ResetMyBGSpecialFlags + ret + +.afterPorkProducts + jp GenericCheck + + +EggCheck: + call GetHealth + or a + jr nz,.afterFried + + call GetCurLocation + push hl + call StandardDie + pop hl + + ld bc,classFriedEggBG + call FindClassIndex + push af + ld a,MAPBANK + ldio [$ff70],a + pop af + ld [hl],a + + call ResetMyBGSpecialFlags + ret + +.afterFried + call GetMisc + dec [hl] + jr nz,.notHatchedYet + + ld hl,.eggHatchSound + call PlaySound + jp ChangeMyClassToAssociatedAndRedraw + +.notHatchedYet + ld hl,.eggCheckTable + jp StdCheckFromTable + +.eggCheckTable + DB 0 ;move delay + DB 0 ;attack type (0=none,1=melee,2=missile) + DB 0 ;bullet damage + DW nullSound + DB 20 ;fire delay + DW 0 + +.eggHatchSound + DB 4,$1b,$f0,$62,$c0 + +;----Crouton Blower--------------------------------------------------- +BlowerInit: + ld hl,.blowerInitTable + jp StdInitFromTable + +.blowerInitTable + DB 4 ;initial facing + DB 4 ;health + DB GROUP_MONSTERA + DB 0 ;has bullet + +BlowerCheck: + call StdCheckDead + ret z + + ld hl,.blowerCheckTable + call StdCheckFromTableNotDead + + ;handle 'firing' ourselves + ;can we attack yet? + call DecrementAttackDelay + or a + ret z + + push de + call GetFacing + push af + and %11 + call GetLocInFront + pop af + rlca + and %110 + push hl + ld l,a + ld a,(mapOffsetNorth & $ff) + add l + ld l,a + ld h,((mapOffsetNorth>>8)&$ff) + ld a,[hl+] + ld e,a + ld a,[hl] + ld d,a + pop hl + + xor a + ld [losLimit],a + call ScanDirectionForEnemy ;returns dir of enemy in b + or a + jr z,.doneDE + + ;blow the enemy away from me + ld a,[fireBulletLocation] ;enemy's location + ld l,a + ld a,[fireBulletLocation+1] + ld h,a + pop de + call GetFacing + and %11 + call ShiftObjectInDirection + ld a,3 + call SetAttackDelay + ld hl,.blowerBlowSound + call PlaySound + ret + +.doneDE pop de + ret + +.blowerCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=none,1=melee,2=missile) + DB 2 ;bullet damage + DW gruntFireSound + DB 5 ;fire delay + DW TrackEnemyVectorToState + +.blowerBlowSound + DB 4,$00,$f5,$07,$80 + +;----Sleeping Monkey-------------------------------------------------- +SleepingMonkeyInit: + ld hl,.sleepingMonkeyInitTable + jp StdInitFromTable + +.sleepingMonkeyInitTable + DB 4 ;initial facing + DB 2 ;health (max) + DB GROUP_MONSTERD ;group + DB 1 ;has bullet + DW classMonkey + DW MONKEY_CINDEX + +SleepingMonkeyCheck: + ld a,[guardAlarm] + or a + jr z,.check + + call ChangeMyClassToAssociatedAndRedraw + ld de,classBananaBullet + ld hl,BANANABULLET_CINDEX + ld a,1 + jp LoadAssociatedClass + +.check + ld hl,.sleepingMonkeyCheckTable + jp StdCheckFromTable + +.sleepingMonkeyCheckTable + DB 0 ;move delay + DB 0 ;attack type (0=no attack,1=melee,2=missile) + DB 0 ;bullet damage + DW monkeyFireSound + DB 3 ;fire delay + DW 0 + +;----Bell------------------------------------------------------------- +BellInit: + ld hl,.bellInitTable + call StdInitFromTable + + jp LinkAssocToMe + +.bellInitTable + DB 1 ;initial facing + DB 63 ;health (max) + DB GROUP_MONSTERN ;group + DB 1 ;has bullet + DW classRingingBell + DW RINGINGBELL_CINDEX + +;----Banana Tree------------------------------------------------------ +BananaTreeInit: + ld hl,.bananaTreeInitTable + jp StdInitFromTable + +.bananaTreeInitTable + DB 1 ;initial facing + DB 6 ;health (max) + DB GROUP_MONSTERN ;group + DB 0 ;has bullet + +BananaTreeCheck: + ;regain 1 health every few seconds + ldio a,[updateTimer] + or a + jr nz,.check + + call GetHealth + cp 6 ;at max? + jr nc,.check + + inc a + call SetHealth +.check + jp DoNothingCheck + +BananaTreeTakeDamage: + ;create an adjacent banana that "fell off" + call FindEmptyLocationAround2x2 + or a + jr z,.takeDamage + + push bc + ld bc,classBananaBG + call FindClassIndex + push af + ld a,MAPBANK + ldio [$ff70],a + pop af + ld [hl],a + pop bc + call ResetMyBGSpecialFlags + +.takeDamage + jp StdTakeDamage2x2 + +;----Hermit Crab No Shell--------------------------------------------- +HermitNoShellInit: + ld hl,.hermitNoShellInitTable + call StdInitFromTable + + ;set misc to be class index of shell + ld bc,classHermitCrabShellBG + call FindClassIndex + jp SetMisc + +.hermitNoShellInitTable + DB 4 ;initial facing + DB 3 ;health (max) + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classHermitInShell + DW HERMITINSHELL_CINDEX + +HermitNoShellCheck: + ;standing on shell? + call GetFacing + bit 7,a ;must be sprite + jr z,.notOnShell + + call GetMisc + ld b,a + + call GetCurLocation + ld a,TILESHADOWBANK + ldio [$ff70],a + ld a,[hl] + cp b + jr nz,.notOnShell + + ;get in shell + ld [hl],0 ;clear out shell + push bc + call GetFacing + ld c,a + call RemoveFromMap + pop bc + + ld a,20 + call SetHealth + call ChangeMyClassToAssociatedAndRedraw + ret + +.notOnShell + ld hl,.hermitNoShellCheckTable + jp StdCheckFromTable + +.hermitNoShellCheckTable + DB 5 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW crabAttackSound + DB 4 ;fire delay + DW StdVectorToState + +crabAttackSound: + DB 1,$2c,$38,$f0,$00,$c6 + +;----Hermit Crab In Shell--------------------------------------------- +HermitInShellCheck: + ld hl,.hermitInShellCheckTable + jp StdCheckFromTable + +.hermitInShellCheckTable + DB 4 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW crabAttackSound + DB 4 ;fire delay + DW TrackEnemyVectorToState + +;----Crab / Crab Burrowing ------------------------------------------- +CrabInit: + ld hl,.crabInitTable + call StdInitFromTable + ld a,100 ;time till burrow + jp SetMisc + +.crabInitTable + DB 4 ;initial facing + DB 3 ;health (max) + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classCrabBurrowing + DW CRABBURROWING_CINDEX + +CrabCheck: + ;can't burrow if sprite + call GetFacing + bit 7,a + jr nz,.notBurrowing + + call GetMisc + dec [hl] + jr nz,.notBurrowing + + ;take another step if split tile + call MoveForwardIfSplit + jp ChangeMyClassToAssociatedAndRedraw + +.notBurrowing + ld hl,.crabCheckTable + jp StdCheckFromTable + +.crabCheckTable + DB 6 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 2 ;bullet damage + DW crabAttackSound + DB 1 ;fire delay + DW TrackEnemyVectorToState + +CrabBurrowingInit: + ld hl,.crabBurrowingInitTable + call StdInitFromTable + xor a + call SetMisc + + jp LinkAssocToMe + +.crabBurrowingInitTable + DB 4 ;initial facing + DB 3 ;health (max) + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classCrab + DW CRAB_CINDEX + +CrabBurrowingCheck: + ;fully burrowed yet? + call GetMisc + cp 100 + jr z,.burrowed + cp 5 + jr z,.burrowed + + inc [hl] + call GetFacing + ld c,a + jp RemoveFromMap + +.burrowed + call GetMisc ;time to unburrow? + cp 100 + jr nz,.notUnburrowing + + call GetCurLocation + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + or a + ret nz ;can't unburrow when someone's on top + + call GetFacing ;clear split bit + res 2,a + call SetFacing + jp ChangeMyClassToAssociatedAndRedraw + +.notUnburrowing + ;is an enemy on top of me? + call GetCurLocation + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + call IsMyEnemy + cp 1 + ret nz + + ;flag to unburrow next time + ld a,100 + jp SetMisc + + +;--------------------------------------------------------------------- +;MoveForwardIfSplit +;--------------------------------------------------------------------- +MoveForwardIfSplit: + call GetFacing + bit 2,a + ret z + and %11 + ld b,a + jp StandardValidateMoveAndRedraw + +;----UberMouse-------------------------------------------------------- +UberMouseCheck: + ld a,63 ;can never die + call SetHealth + ld hl,.uberMouseCheckTable + jp StdCheckFromTable + +.uberMouseCheckTable + DB 5 ;move delay + DB 1 ;attack type (0=no attack,1=melee,2=missile) + DB 5 ;bullet damage + DW .uberMouseFireSound + DB 2 ;fire delay + DW TrackEnemyVectorToState + +.uberMouseFireSound + DB 1,$17,$00,$f0,$00,$c6 + +;----Turret----------------------------------------------------------- +TurretInit: + ld hl,.turretInitTable + jp StdInitFromTable +.turretInitTable + DB 4 ;initial facing + DB 20 ;health (max) + DB GROUP_MONSTERA ;group + DB 1 ;has bullet + DW classTurretBullet + DW TURRETBULLET_CINDEX + +TurretCheck: + ld hl,.turretCheckTable + jp StdCheckFromTable + +.turretCheckTable + DB 2 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW .turretFireSound + DB 1 ;fire delay + DW 0 + +.turretFireSound + DB 1,$3b,$80,$f3,$00,$83 + ;DB 1,$fa,$80,$f3,$00,$84 + +;----Pansy------------------------------------------------------------ +PansyInit: + ld hl,.pansyInitTable + jp StdInitFromTable + +.pansyInitTable + DB 4 ;initial facing + DB 2 ;health + DB GROUP_MONSTERC ;group + DB 1 ;has bullet + DW classPansyBullet ;associated bullet class ptr + DW PANSYBULLET_CINDEX + +PansyCheck: + ld hl,.pansyCheckTable + jp StdCheckFromTable + +.pansyCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW pansyFireSound + DB 10 ;fire delay + DW TrackEnemyVectorToState + +HippiePansyCheck: + ld hl,.hippiePansyCheckTable + jp StdCheckFromTable + +.hippiePansyCheckTable + DB 4 ;move delay + DB 2 ;attack type (0=no attack,1=melee,2=missile) + DB 1 ;bullet damage + DW pansyFireSound + DB 10 ;fire delay + DW EatVectorToState + +;--------------------------------------------------------------------- +; ActorCheck +;--------------------------------------------------------------------- +ActorCheck: + push bc + push de + push hl + + ;am I dead? + call GetHealth + or a + jr nz,.checkTimeToMove + call StandardDie + jr .done + +.checkTimeToMove + ;time to move? + ld a,2 + call TestMove + or a + jr z,.skipMove ;timer lsb==frame lsb, don't move yet + + ;xor a + ld a,1 + ld [moveAlignPrecision],a + call ActorVectorToState + or a + jr z,.skipMove + call StandardValidateMoveAndRedraw +.skipMove + +.done pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: LookForEnemyInLOS +; Arguments: c - class index of object +; de - this +; Alters: af,b +; Returns: a - 1=enemy spotted, 0=no enemy +; b - direction of enemy +; [fireBulletLocation] +; loc adj to shooter to place bullet +;--------------------------------------------------------------------- +LookForEnemyInLOS: + push hl + + ;save my group and direction first + call GetGroup + ld [myGroup],a + + call GetAttackDirState + or a + jr nz,.scanEast + + ;de = north offset + push de + ld a,DIR_NORTH + ld [myFacing],a + call GetLocInFront + ld a,[mapOffsetNorth] ;get North offset + ld e,a + ld a,[mapOffsetNorth+1] + ld d,a + + call ScanDirectionForEnemy + or a + jr nz,.afterN2 + ldio a,[curObjWidthHeight] + cp 2 + jr z,.try2x2N + xor a + jr .afterN2 +.try2x2N + inc hl ;try again to the side + call ScanDirectionForEnemy + +.afterN2 + pop de + or a + jr nz,.foundEnemyN + jp .advanceState ;found a wall +.foundEnemyN + ld b,DIR_NORTH ;found enemy + jp .saveEnemyLocation + +.scanEast + ;Attack Dir State says look east? + cp 1 + jr nz,.scanSouth + + ;de = east offset + push de + ld a,DIR_EAST + ld [myFacing],a + call GetLocInFront + ld a,[mapOffsetEast] ;get East offset + ld e,a + ld a,[mapOffsetEast+1] + ld d,a + + call ScanDirectionForEnemy + or a + jr nz,.afterE2 + ldio a,[curObjWidthHeight] + cp 2 + jr z,.try2x2E + xor a + jr .afterE2 +.try2x2E + ;try again to the side + ld a,[mapOffsetSouth] + add l + ld l,a + ld a,[mapOffsetSouth+1] + adc h + ld h,a + call ScanDirectionForEnemy + +.afterE2 + pop de + or a + jr z,.advanceState ;found a wall + ld b,DIR_EAST ;found enemy + jr .saveEnemyLocation + +.scanSouth + ;Attack Dir State says look south? + cp 2 + jr nz,.scanWest + + ;de = south offset + push de + ld a,DIR_SOUTH + ld [myFacing],a + call GetLocInFront + ld a,[mapOffsetSouth] ;get South offset + ld e,a + ld a,[mapOffsetSouth+1] + ld d,a + + call ScanDirectionForEnemy + or a + jr nz,.afterS2 + ldio a,[curObjWidthHeight] + cp 2 + jr z,.try2x2S + xor a + jr .afterS2 +.try2x2S + inc hl ;try again to the side + call ScanDirectionForEnemy + +.afterS2 + pop de + or a + jr z,.scanWest ;found a wall + ld b,DIR_SOUTH ;found enemy + jr .saveEnemyLocation + +.scanWest + ;de = west offset + push de + ld a,DIR_WEST + ld [myFacing],a + call GetLocInFront + ld a,[mapOffsetWest] ;get West offset + ld e,a + ld a,[mapOffsetWest+1] + ld d,a + + call ScanDirectionForEnemy + or a + jr nz,.afterW2 + ldio a,[curObjWidthHeight] + cp 2 + jr z,.try2x2W + xor a + jr .afterW2 +.try2x2W + ;try again to the side + ld a,[mapOffsetSouth] + add l + ld l,a + ld a,[mapOffsetSouth+1] + adc h + ld h,a + call ScanDirectionForEnemy + +.afterW2 + pop de + or a + jr z,.advanceState ;found a wall + ld b,DIR_WEST ;found enemy + +.saveEnemyLocation + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + ld a,1 + jr .done + +.advanceState + ;no enemies found, look next direction next time + call GetAttackDirState + inc a + call SetAttackDirState + xor a + +.done + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: ScanDirectionForEnemy +; Arguments: c - class index of scanning object +; de - offset to scan in +; hl - starting location for scan +; [losLimit] - 1=1 tile, 0=infinite +; Returns: a - 1=enemy found, 0=no enemy +; [fireBulletLocation] - location of enemy if found +; Alters: af +;--------------------------------------------------------------------- +ScanDirectionForEnemy: + push bc + push hl + + ld a,MAPBANK + ld [$ff70],a + ldio a,[firstMonster] + ld b,a + + ld a,[losLimit] + cp 1 + jr nz,.loop + + ;one time only + ld a,[hl] + or a + jr z,.done + cp b + jr c,.returnFalse + call IsMyEnemy + and 1 ;mask out & ignore bullets + jr .done + + ;infinite until hit wall +.loop ld a,[hl] + or a + jr z,.nextLocation + cp b + jr c,.foundWall + + ;might be an enemy + push af + ld a,l + ld [fireBulletLocation],a + ld a,h + ld [fireBulletLocation+1],a + pop af + call IsMyEnemy + cp 2 + jr z,.restoreMapNextLocation ;is bullet, look past it + and 1 + jr .done ;is creature + +.restoreMapNextLocation + ld a,MAPBANK + ldio [$ff70],a +.nextLocation + add hl,de + jr .loop + +.foundWall + ;might be a shoot-over wall + push af + ld a,ZONEBANK + ldio [$ff70],a + pop af + bit 7,[hl] ;anything special here? + jr z,.returnFalse ;nope + call GetBGAttributes ;maybe... + and BG_FLAG_SHOOTOVER + jr z,.returnFalse ;still no + ld a,MAPBANK + ldio [$ff70],a + jr .nextLocation ;go back to looking + +.returnFalse + xor a +.done + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: IsMyEnemy +; Arguments: a - class index of potential enemy +; c - class index of object +; hl - map location +; Returns: a - 0=no enemy, 1=is enemy, 2=no enemy but is bullet +; (bullet coming towards me = 1) +; Alters: af +; Description: Follows tail tiles back to head (if need be) & figures +; out if this index is friend or foe +;--------------------------------------------------------------------- +IsMyEnemy: + push bc + push de + push hl + + push af + ldio a,[firstMonster] + ld b,a + pop af + cp b + jr c,.notEnemy + + call EnsureTileIsHead ;a = findHead(a) + ld c,a + ld d,h + ld e,l + call FindObject + + call GetFGAttributes + and FLAG_ISBULLET + jr nz,.specialCaseIsBullet + + call GetGroup + + ld b,a + ld a,[myGroup] + ld c,a + call GetFOF + xor 1 ;reverse return value + jr .done + +.specialCaseIsBullet + call GetFacing ;get bullets direction + add 2 ;reverse it + and %11 + ld hl,myFacing + cp [hl] ;coming towards me if same dir + jr z,.isEnemy + + ;no enemy but is bullet + ld a,2 + jr .done + +.notEnemy + ;not my enemy + xor a + jr .done + +.isEnemy + ld a,1 + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: EnsureTileIsHead +; Arguments: a - class index of tile (maybe adjoin ptr) +; hl - map location +; Returns: a - head of obj / class index +; hl - location of head +; Alters: af,hl +; Description: Follows tail tiles back to head (if need be) +;--------------------------------------------------------------------- +EnsureTileIsHead:: + push bc + push de + ld c,a + + ld d,h + ld e,l + + ld a,MAPBANK + ld [$ff70],a + +.checkIfFoundHead + ld a,c + cp CLASS_ADJOIN_N + jr c,.foundHeadTile + + jr z,.followTileToNorth + cp CLASS_ADJOIN_W + jr z,.followTileToWest + + di +.error jr .error ;no classes should adjoin east or south + +.followTileToNorth + ld a,[mapOffsetNorth] + ld l,a + ld a,[mapOffsetNorth+1] + ld h,a + add hl,de + ld d,h + ld e,l + ld c,[hl] + jr .checkIfFoundHead + +.followTileToWest + dec de + ld a,[de] + ld c,a + jr .checkIfFoundHead + +.foundHeadTile + ld h,d + ld l,e + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: StandardValidateMoveAndRedraw +; Arguments: b - direction to move +;--------------------------------------------------------------------- +StandardValidateMoveAndRedraw: + ld a,b + and %11 + ld b,a + call EnforceLegalMove + ld a,1 + call CheckDestEmpty + or a + ret z + call Move + call StandardRedrawNoCheckSprite + ret + +;--------------------------------------------------------------------- +; Routine: PlayerValidateMoveAndRedraw +; Arguments: b - desired move dir +; Returns: a - 1 if bumping into monster +; 0 otherwise +; Description: Additional functionality of changing map if player +; hits a wall flagged as an exit +;--------------------------------------------------------------------- +PlayerValidateMoveAndRedraw: + call EnforceLegalMove + ld a,1 + call CheckDestEmpty + or a + jr nz,.move + + ;can't move. Bumping into exit? + ld a,4 + call GetLocInFront + + ;can't be a monster + ld a,MAPBANK + ld [$ff70],a + ldio a,[firstMonster] + ld b,a + ld a,[hl] + cp b + jr c,.notAMonster + + ;return is monster unless it is a talker + call EnsureTileIsHead + ld b,a + ld a,[dialogBalloonClassIndex] + cp b + jr nz,.returnTrue + + xor a + ret + +.returnTrue + ld a,1 + ret + +.notAMonster + ;save monster(?) index in b + ;ld b,a + + ;switch to zone/exit map + ld a,ZONEBANK + ld [$ff70],a + + ;get & check exit at location in front + ld a,[hl] + and %01110000 ;clear off extraneous + xor %01110000 ;must be type "X" + ;jr nz,.checkBumpIntoMonster + jr nz,.checkBumpIntoAttackable + + ;have an exit! + ;save exit tile index + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + ld [exitTileIndex],a + call HandleExitFromMap + xor a + ret + +.move + call Move + call StandardRedrawNoCheckSprite + xor a + ret + + ;ld a,MAPBANK + ;ldio [$ff70],a + ;ld a,[firstMonster] + ;ld b,a + ;ld a,[hl] + ;cp b + ;jr c,.checkBumpIntoAttackable + ;ld a,1 + ;ret + +.checkBumpIntoAttackable + ld a,[bgFlags] + and BG_FLAG_ATTACKABLE + ret z + ld a,1 + ret + +;--------------------------------------------------------------------- +; Routines: StreamRedraw +; StreamCheck +; StreamDraw +; StreamDie +;--------------------------------------------------------------------- +StreamRedraw: + push bc + push de + push hl + + ld a,OBJBANK + ld [$ff70],a + + xor a + ld [fgFlags],a + + ld hl,OBJ_LIMIT ;get my color + add hl,de + ld b,[hl] + jp StreamDraw + +StreamCheck: + ;time to move? + ld a,1 + call TestMove + or a + jr z,.streamDone ;timer lsb==frame lsb, don't move yet + + call .streamMove + call .streamMove + call .streamMove + call StreamRedraw ;draw me please +.streamDone + ret + +.streamMove + push bc + push hl + + ldio a,[firstMonster] + ld b,a + + ld a,4 + call GetLocInFront ;4=in front, split included + or a + jr z,.keepGoing ;nothing in front + cp b ;is a monster or what? + jr c,.hitWall ;wall in front, bullet just dies + + ;object in front, hit it for damage but keep going next time + ld b,a ;monster index in b, loc in hl + ld a,1 ;one point of damage + ld [methodParamL],a + ld a,4 ;use direction of this object for expl + call HitObject + jr .done + +.hitWall + call StreamDie + call GetCurLocation ;move obj over wall + call GetFacing + and %11 + call AdvanceLocHLInDirection + call SetCurLocation + ld a,MAPBANK + ld [$ff70],a + xor a + ld [hl],a ;destroy bg tile at this loc + + ld b,24 ;initial frame + call HitWall + + ld hl,bigExplosionSound + call PlaySound + pop hl + pop bc + pop af ;return addr + ret + +.keepGoing + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME ;get current direction + add hl,de + ld a,[hl] + and %00000011 ;keep going same direction + ld b,a + + call Move + ;call StreamRedraw ;draw me please + +.done + pop hl + pop bc + ret + +StreamDraw: + jp StandardDraw + + ;call GetCurLocation + ;call GetFacing + ;add 2 + ;and %11 ;reverse facing + ;call AdvanceLocHLInDirection ;location behind head + ;call GetBaseTile + + + +StreamDie: + ld a,5 + ld [jiggleDuration],a + jp StandardDie + +;--------------------------------------------------------------------- +; Routine: BombLocation +; Arguments: b - damage +; hl - center of blast +; Returns: Nothing. +; Alters: af +; Description: Does 'b' damage in a cross shape spreading outward +; from center in a random radius of (2...b) horizontally +; and another random radius of (2...b) vertically. +; +; Uses $c000 as work RAM to collect locations and +; objects affected. +;--------------------------------------------------------------------- +BombLocation: + push bc + push de + push hl + + ld a,MAPBANK + ldio [$ff70],a + + ;save current object width & height + ldio a,[curObjWidthHeight] + push af + + xor a ;number of objects found + ld [$c000],a + + ld a,b + ld [fireBulletDamage],a + + ;limit b to 4 max + ld a,b + cp 5 + jr c,.bOkay + ld b,4 +.bOkay + + push hl + + ;----left/right----------------------------------------------- + ;get random radius 1...b + ld a,b + sub 2 + call GetRandomNumZeroToN + inc a + inc a + ld c,a ;c is original desired number of explosions + + ;find left and right boundaries + ld de,$ffff + call .numTilesUntilWall + cp c + jr c,.leftSideOkay + jr z,.leftSideOkay + ld a,c ;clip +.leftSideOkay + push af + + ld de,1 + call .numTilesUntilWall + cp c + jr c,.rightSideOkay + jr z,.rightSideOkay + ld a,c ;clip +.rightSideOkay + dec a + ld c,a + pop af + push af + add c + ld c,a + pop af + cpl + inc a + inc a + add l + ld l,a + + ;hl is at left side, c indiates num tiles until right side + ld de,1 + call .createExplosions + + pop hl + + ;----up/down-------------------------------------------------- + ;get random radius 1...b + ld a,b + sub 2 + call GetRandomNumZeroToN + inc a + inc a + ld c,a + + ;find top and bottom boundaries + ld a,[mapOffsetNorth] + ld e,a + ld a,[mapOffsetNorth+1] + ld d,a + call .numTilesUntilWall + cp c + jr c,.topSideOkay + jr z,.topSideOkay + ld a,c ;clip +.topSideOkay + ld b,c + dec a + ld c,a + or a + jr z,.topSideDone + + push hl +.adjustTopHL + add hl,de + dec a + jr nz,.adjustTopHL + + ;hl is at top side, c indiates num tiles until bottom side + ld a,[mapOffsetSouth] + ld e,a + ld a,[mapOffsetSouth+1] + ld d,a + call .createExplosions + pop hl +.topSideDone + + ld a,[mapOffsetSouth] + ld e,a + ld a,[mapOffsetSouth+1] + ld d,a + ld c,b + call .numTilesUntilWall + cp c + jr c,.bottomSideOkay + jr z,.bottomSideOkay + ld a,c ;clip +.bottomSideOkay + dec a + jr z,.bottomSideDone + ld c,a + + add hl,de + + ;hl is at top side, c indiates num tiles until bottom side + call .createExplosions +.bottomSideDone + + ;loop through list of objects recorded as being in bomb + ;blast and cause damage to each one + ld a,[$c000] + or a + jr z,.done + ld c,a + ld hl,$c001 + +.distributeDamageLoop + push bc + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl+] + ld e,a + ld a,[hl+] + ld d,a + ld a,[de] ;class index of target + ld c,a ;class index to look for + call FindObject + ld a,[fireBulletDamage] + ld [methodParamL],a + ld a,4 + ld [fireBulletDirection],a + ld b,METHOD_TAKE_DAMAGE + call CallMethod + pop bc + dec c + jr nz,.distributeDamageLoop + + ;ld hl,bombSound + ;call PlaySound + +.done + ;restore current object width and height + pop af + ldio [curObjWidthHeight],a + + pop hl + pop de + pop bc + ret + +.createExplosions + ld a,c + or a + ret z + + push bc + push de + push hl + +.createExplosionLoop + ld a,MAPBANK + ldio [$ff70],a + ldio a,[firstMonster] + ld b,a + ld a,[hl] + cp b + push de + push hl + jr c,.afterRecordObject + + call EnsureTileIsHead + + ;add location to list of locations if not already there + call .isLocationRecorded + or a + jr nz,.afterRecordObject + + ;record the location + ld a,[$c000] + push af + sla a ;times two + 1 + inc a + ld e,a + ld d,$c0 ;de = numObj*2 + 1 + ld a,l + ld [de],a + inc de + ld a,h + ld [de],a + pop af + inc a + ld [$c000],a ;one more in the list + +.afterRecordObject + pop hl + pop de + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + ld b,16 + call CreateExplosion + add hl,de + dec c + jr nz,.createExplosionLoop + + pop hl + pop de + pop bc + ret + +.isLocationRecorded + ;args: a - class + ; hl - cur location + ;returns: a - 1=in list, 0=not in list + push bc + push de + push hl + call EnsureTileIsHead + ld d,h + ld e,l + ld a,[$c000] ;num classes + or a + jr z,.inListDone ;no list - so not in list + ld c,a + ld hl,$c001 +.testInListLoop + ld a,[hl+] + cp e + jr nz,.continueInListLoop + ld a,[hl] + cp d + jr nz,.continueInListLoop + + ld a,1 ;is in list + jr .inListDone + +.continueInListLoop + inc hl + dec c + jr nz,.testInListLoop + + xor a + +.inListDone + pop hl + pop de + pop bc + ret + +.numTilesUntilWall + ;takes a location (hl), an offset (de), and returns how + ;many tiles (including the first) there are until a wall. + push bc + push hl + + ld a,MAPBANK + ldio [$ff70],a + + ldio a,[firstMonster] + ld b,a + + ld c,0 +.loop ld a,[hl] + or a + jr z,.keepCounting + cp b + jr c,.foundWall + +.keepCounting + inc c + add hl,de + jr .loop + +.foundWall + ;keep going if shoot-over type + push af + ld a,ZONEBANK + ldio [$ff70],a + pop af + bit 7,[hl] ;special? + jr z,.foundWallDone + call GetBGAttributes + bit BG_BIT_SHOOTOVER,a + jr z,.foundWallDone + ld a,MAPBANK ;keep looking + ldio [$ff70],a + jr .keepCounting + +.foundWallDone + ld a,c + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindEmptyLocationAround1x1 +; Arguments: de - 1x1 object +; Returns: hl - empty location around object or $0000 if none +; a - 0 = no empty locations +; Alters: af,hl +;--------------------------------------------------------------------- +FindEmptyLocationAround1x1Loc: + push bc + jr FindEmptyLocationAround1x1Common + +FindEmptyLocationAround1x1: + push bc + + ;get my TL corner plus (-1,-1) + call GetCurLocation +FindEmptyLocationAround1x1Common: + call ConvertLocHLToXY + dec h + dec l + + ld b,0 +.outer + ld c,0 +.inner + push hl + ld a,h + add b + ld h,a + ld a,l + add c + ld l,a + call ConvertXYToLocHL + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + or a + jr nz,.notEmpty + + ld a,1 + pop bc + jr .done + +.notEmpty + pop hl + ld a,3 + inc c + cp c + jr nz,.inner + inc b + cp b + jr nz,.outer + + ld hl,0 + xor a + +.done + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindEmptyLocationAround2x2 +; Arguments: de - 2x2 object +; Returns: hl - empty location around object or $0000 if none +; a - 0 if none empty +; Alters: af,hl +;--------------------------------------------------------------------- +FindEmptyLocationAround2x2: + push bc + + ;get my TL corner plus (-1,-1) + call GetCurLocation + call ConvertLocHLToXY + dec h + dec l + + ld b,0 +.outer + ld c,0 +.inner + push hl + ld a,h + add b + ld h,a + ld a,l + add c + ld l,a + call ConvertXYToLocHL + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + or a + jr nz,.notEmpty + + ld a,1 + pop bc + jr .done + +.notEmpty + pop hl + ld a,4 + inc c + cp c + jr nz,.inner + inc b + cp b + jr nz,.outer + + xor a + ld hl,0 + +.done + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetCurLocation +; Arguments: de - object +; Returns: hl - current location +; Alters: af +;--------------------------------------------------------------------- +GetCurLocation:: + ld a,OBJBANK + ld [$ff70],a + ld a,[de] + ld l,a + inc de + ld a,[de] + ld h,a + dec de + ret + +;--------------------------------------------------------------------- +; Routine: SetCurLocation +;--------------------------------------------------------------------- +SetCurLocation:: + ld a,OBJBANK + ld [$ff70],a + ld a,l + ld [de],a + inc de + ld a,h + ld [de],a + dec de + ret + +;--------------------------------------------------------------------- +; Routine: GetFacing +; Returns: current facing + split +; Alters: af +;--------------------------------------------------------------------- +GetFacing:: + push hl + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME + add hl,de + ld a,[hl] + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetFacing +; Arguments: a - byte to set facing to +; Alters: af,hl +;--------------------------------------------------------------------- +SetFacing:: + push af + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_FRAME + add hl,de + pop af + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: AdvanceLocHLInDirection +; Arguments: a - direction to advance in +;--------------------------------------------------------------------- +AdvanceLocHLInDirection: + bit 0,a + jr nz,.eastOrWest + + push de + + rlca + ld de,mapOffsetNorth ;de to correct map offset + add e + ld e,a + + ld a,[de] + inc de + add l + ld l,a + ld a,[de] + adc h + ld h,a + + pop de + ret + +.eastOrWest + bit 1,a + jr nz,.west + + inc hl + ret + +.west dec hl + ret + +;--------------------------------------------------------------------- +; Routine: SetGroup +; Arguments: a - group to set to (see Object.asm for details) +; de - object +; Alters: af +; Returns: nothing +;--------------------------------------------------------------------- +SetGroup:: + push bc + push hl + + ld b,a + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_GROUP + add hl,de + ld a,[hl] + and %11110000 + or b + ld [hl],a + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetGroup +; Arguments: de - object +; Alters: af +; Returns: a - this object's group (see Object.asm for details) +;--------------------------------------------------------------------- +GetGroup: + push hl + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_GROUP + add hl,de + ld a,[hl] + and %00001111 + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetActorDestZone +; Arguments: de - object +; Alters: af +; Returns: a - destination zone of DESTL/DESTH +;--------------------------------------------------------------------- +GetActorDestZone: + push hl + + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_DESTL + add hl,de + + ld a,[hl+] ;get location in hl + ld h,[hl] + ld l,a + + ld a,ZONEBANK + ld [$ff70],a + + ld a,[hl] + and %1111 + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetActorDestLoc +; aka SetFoodIndexRange +; Arguments: de - object +; hl - location / food range h=high index, l=low +; Alters: af +; Returns: nothing +;--------------------------------------------------------------------- +SetActorDestLoc:: +SetFoodIndexRange:: + push bc + push hl + + ld b,h + ld c,l + + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_DESTL + add hl,de + + ld [hl],c + inc hl + ld [hl],b + + xor a + call SetState + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetActorDestLoc +; Arguments: de - object +; Alters: af, hl +; Returns: hl - location +;--------------------------------------------------------------------- +GetActorDestLoc: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_DESTL + add hl,de + ld a,[hl+] + ld h,[hl] + ld l,a + ret + +;--------------------------------------------------------------------- +; Routine: GetDestL +; GetDestH +; Arguments: de - object +; Returns: a - contents of DESTL/DESTH +; Alters: af,hl +;--------------------------------------------------------------------- +GetDestL:: + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_DESTL + add hl,de + ld a,[hl] + ret + +GetDestH:: + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_DESTH + add hl,de + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: SetDestL +; SetDestH +; Arguments: a - value to set to +; de - object +; Returns: Nothing. +; Alters: af,hl +;--------------------------------------------------------------------- +SetDestL:: + push af + ld a,OBJBANK + ldio [$ff70],a + pop af + ld hl,OBJ_DESTL + add hl,de + ld [hl],a + ret + +SetDestH:: + push af + ld a,OBJBANK + ldio [$ff70],a + pop af + ld hl,OBJ_DESTH + add hl,de + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: SetMisc +; GetMisc +; Arguments: a - value to set to (SetMisc) +; de - object +; Returns: a - retrieved value (GetMisc) +; Alters: af,hl +;--------------------------------------------------------------------- +SetMisc:: + push af + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_MISC + add hl,de + pop af + ld [hl],a + ret + +GetMisc:: + ld a,OBJBANK + ldio [$ff70],a + ld hl,OBJ_MISC + add hl,de + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: SetSpriteLo +; Alters: af +; Arguments: a - loptr to sprite +; de - object +;--------------------------------------------------------------------- +SetSpriteLo: + push hl + ld h,a + ld a,OBJBANK + ld [$ff70],a + ld a,h + ld hl,OBJ_SPRITELO + add hl,de + ld [hl],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetSpriteLo +; Arguments: de - object +; Returns: a - loptr to sprite +; Alters: af +;--------------------------------------------------------------------- +GetSpriteLo: + push hl + + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_SPRITELO + add hl,de + ld a,[hl] + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetSpritePtrInHL +; Arguments: de - object +; Returns: hl - loptr to sprite +; Alters: af +;--------------------------------------------------------------------- +GetSpritePtrInHL: + call GetSpriteLo + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + ret + +;--------------------------------------------------------------------- +; Routine: GetBulletDamage +; Returns: this.destL +; Alters: a,hl +;--------------------------------------------------------------------- +GetBulletDamage: + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_DESTL + add hl,de + ld a,[hl] + ret + + +;--------------------------------------------------------------------- +; Routine: GetFGAttributes +; Arguments: c - class index +; Alters: af +; Returns: a - attributes for given class index +; [fgFlags] copy of attributes +; +; Returns full set of attributes including: +; [2:0] - color FLAG_PALETTE +; [4] - isBullet FLAG_ISBULLET +; [5] - is2x2 FLAG_2X2 +; [6] - noRotate FLAG_NOROTATE +;--------------------------------------------------------------------- +GetFGAttributes:: + push hl + ld a,TILEINDEXBANK + ldio [$ff70],a + ld l,c + ld h,((fgAttributes>>8) & $ff) + ld a,[hl] + ld [fgFlags],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetFGAttributes +; Arguments: a - new attributs +; c - class index +; Alters: af +;--------------------------------------------------------------------- +SetFGAttributes:: + push hl + push af + ld a,TILEINDEXBANK + ldio [$ff70],a + ld l,c + ld h,((fgAttributes>>8) & $ff) + pop af + ld [hl],a + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: GetFGTileMapping +; Arguments: c - class index +; Returns: a - base fg tile for given class index +; Alters: af +;--------------------------------------------------------------------- +GetFGTileMapping: + push hl + + ld a,TILEINDEXBANK + ld [$ff70],a + + ld l,c + ld h,((fgTileMap>>8) & $ff) + + ld a,[hl] + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetupHeroData +; Arguments: c - class index +; Returns: hl - ptr to hero0_data or hero1_data +; Alters: af,hl +;--------------------------------------------------------------------- +SetupHeroData: + ld a,[hero0_index] + cp c + jr nz,.hero1 + ld hl,hero0_data + ret + +.hero1 + ld hl,hero1_data + ret + +;--------------------------------------------------------------------- +; Routine: GetHeroData +; Arguments: a - data offset (e.g. HERODATA_HEALTH) +; hl - ptr to hero0_data or hero1_data +; Returns: a - 8-bit value +; Alters: af +;--------------------------------------------------------------------- +GetHeroData: + push de + push hl + + ld d,0 + ld e,a + add hl,de + ld a,[hl] + + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: SetHeroData +; Arguments: a - data to set +; b - data offset (e.g. HERODATA_HEALTH) +; hl - ptr to hero0_data or hero1_data +; Returns: a - 8-bit value +; Alters: af +;--------------------------------------------------------------------- +SetHeroData: + push de + push hl + + ld d,0 + ld e,b + add hl,de + ld [hl],a + + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: HealthSparks +; Arguments: a - cur health +; b - max health +; de - this +; Returns: Nothing. +; Alters: af, hl +; Description: Makes a spark every often if lower than half +; health, twice as often if lower than 1/4 health, +; like crazy if lower than 1/8 health or at 1 +;--------------------------------------------------------------------- +HealthSparks: + push bc + push de + + srl b ;half max health + cp b + jr z,.atHalfHealth + jr nc,.done ;greater than half health + + srl b ;1/4 max + cp b + jr z,.atQuarterHealth + jr nc,.atHalfHealth + + srl b ;1/8 max + cp b + jr z,.atEighthHealth + jr nc,.atQuarterHealth + +.atEighthHealth + ;at 1/8 health + call GetState + add 1 + call SetState + and %00000001 + jr .spark + +.atQuarterHealth + call GetState + add 1 + call SetState + and %00000111 + jr .spark + +.atHalfHealth + call GetState + add 1 + call SetState + and %00001111 + +.spark + or a + jr nz,.done + + call GetFGAttributes + and %111 + ld [bulletColor],a + call GetCurLocation + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + ld b,72 ;initial spark frame + call CreateExplosion + + ;hl points to explosion object + push de + call IndexToPointerDE + call GetSpriteLo + ld h,((spriteOAMBuffer>>8) & $ff) + ld l,a + pop de + + ;add +4 y if split north/south + push hl + push hl + call GetFacing + pop hl + bit 2,a + jr z,.afterSplit + + bit 0,a + jr z,.splitNS + + inc hl ;split e/w + +.splitNS + ld a,[hl] + add 4 + ld [hl],a +.afterSplit + pop hl + + ;offset by random +/- 0-3 pixels + ld a,%111 + call GetRandomNumMask + add [hl] ;sprite y pos + sub 4 + ld [hl+],a + ld a,%111 + call GetRandomNumMask + add [hl] ;sprite x pos + sub 4 + ld [hl],a + +.done + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ShiftObjectInDirection +; Arguments: a - direction to shift object +; hl - location of object +; Alters: af, [curObjWidthHeight] +; Returns: Nothing. +;--------------------------------------------------------------------- +ShiftObjectInDirection:: + push bc + push de + push hl + + ld b,a + + ldio a,[curObjWidthHeight] + push af + + ld a,MAPBANK + ldio [$ff70],a + + ld a,[hl] + call EnsureTileIsHead + ld d,h + ld e,l + + ld c,a + ld a,[hero0_index] + cp c + jr z,.isPlayer + ld a,[hero1_index] + cp c + jr z,.isPlayer + + call FindObject + call SetObjWidthHeight + call StandardValidateMoveAndRedraw + + pop af + ldio [curObjWidthHeight],a + + pop hl + pop de + pop bc + ret + +.isPlayer + call FindObject + call PlayerValidateMoveAndRedraw + + pop af + ldio [curObjWidthHeight],a + + pop hl + pop de + pop bc + ret + + +nullSound: + DB 0 + +;channel 1 effects +pansyFireSound: + DB 1,$72,$80,$f7,$00,$84 +baFireSound: + DB 1,$3b,$40,$f3,$00,$84 +bsFireSound: + DB 1,$4c,$40,$f3,$00,$87 +bigLaserSound:: + DB 1,$3d,$80,$f6,$00,$86 +disappearSound:: + DB 1,$72,$80,$f5,$00,$c2 +goblinSound: + DB 1,$11,$80,$f0,$00,$c1 +rocketFireSound: + DB 1,$25,$00,$f4,$00,$81 +hulkFireSound: + DB 1,$31,$c0,$f0,$00,$c1 +gruntFireSound: + DB 1,$21,$e0,$f8,$50,$80 +haikuSound: + DB 1,$9c,$48,$f2,$d0,$c7 +guardFireSound: + DB 1,$31,$80,$f0,$00,$c1 +treeFireSound: + DB 1,$4d,$c0,$f0,$00,$c5 +bushFireSound: + DB 1,$4d,$c0,$f0,$00,$c4 +beeSound: + DB 1,$f7,$00,$f3,$00,$83 +eatSound: + DB 1,$5a,$80,$f2,$00,$84 + + +;low frogger 1,$23,$20,$af,$00,$81 + +;channel 4 effects +stdExplosionSound: + DB 4,$00,$c3,$44,$80 +bigExplosionSound:: + DB 4,$00,$f3,$81,$80 +closeGateSound:: + DB 4,$00,$f4,$4f,$80 +bombSound:: + DB 4,$00,$f6,$90,$80 + + + +;SECTION "AlignedClassTables",ROMX[$7F00],BANK[CLASSROM] +;--------------------------------------------------------------------- +SECTION "AlignedClassTables",ROM0[$200] +;--------------------------------------------------------------------- +stdStateTable: + ;$7f00 + DW SetupRandomMoveState, MoveToZone, TryRight, TryFwdAfterRight + DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + +eatStateTable: + ;$7f20 + ;DW EatOrTrack, MoveToZone, TryRight, TryFwdAfterRight + ;DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + ;DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + ;DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + DW EatOrTrackState,EatOrTrackState,EatOrTrackState,EatOrTrackState + DW EatOrTrackState,EatOrTrackState,EatOrTrackState,EatOrTrackState + DW EatOrTrackState,EatOrTrackState,EatOrTrackState,EatOrTrackState + DW EatOrTrackState,EatOrTrackState,EatOrTrackState,EatOrTrackState + +explosionFrameTable: + ;$7f40 + DB 0,8,0,8,0,0,0,0 ;pattern numbers + DB %00000000,%00000000,%01000000,%00100000 ;base attributes + DB %00000000,%01000000,%00100000,%01100000 + +trackEnemyStateTable: + ;$7f50 + DW SetupTrackEnemy, MoveToZone, TryRight, TryFwdAfterRight + DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + +getLocSplitTable: + ;$7f70 + DB 0 ;%00 00 Facing: N Check: N + DB 0 ;%00 01 Facing: N Check: E + DB 1 ;%00 10 Facing: N Check: S + DB 0 ;%00 11 Facing: N Check: W + DB 0 ;%01 00 Facing: E Check: N + DB 1 ;%01 01 Facing: E Check: E + DB 0 ;%01 10 Facing: E Check: S + DB 0 ;%01 11 Facing: E Check: W + DB 0 ;%10 00 Facing: S Check: N + DB 0 ;%10 01 Facing: S Check: E + DB 1 ;%10 10 Facing: S Check: S + DB 0 ;%10 11 Facing: S Check: W + DB 0 ;%11 00 Facing: W Check: N + DB 1 ;%11 01 Facing: W Check: E + DB 0 ;%11 10 Facing: W Check: S + DB 0 ;%01 11 Facing: W Check: W + + +actorStateTable: + ;$7f80 + DW SetupMoveToLoc, MoveToZone, TryRight, TryFwdAfterRight + DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + +fleeStateTable: + ;$7fa0 + DW ScardieFlee, MoveToZone, TryRight, TryFwdAfterRight + DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + +ladyBulletStateTable: + ;$7fc0 + DW LadyBulletMove, MoveToZone, TryRight, TryFwdAfterRight + DW TryLeft, TryFwdAfterLeft, RandomMove, MoveFwdThenState1 + DW TryLeftFirst, TryFwdAfterLeftFirst, TryRightSecond + DW TryFwdAfterRightSecond, NoMove, NoMove, NoMove, NoMove + + ;$7fe0 diff --git a/Source/Class.inc b/Source/Class.inc new file mode 100644 index 0000000..57044ca --- /dev/null +++ b/Source/Class.inc @@ -0,0 +1,206 @@ +;1.2.2000 by Abe Pralle + +;vector offsets +METHOD_INIT EQU 0 +METHOD_DRAW EQU 2 +METHOD_CHECK EQU 4 +METHOD_TAKE_DAMAGE EQU 6 +METHOD_DIE EQU 8 + +BGACTION_HIT EQU 0 +BGACTION_MOVEOVER EQU 1 + +;object offsets +OBJ_IPOS EQU 0 +OBJ_JPOS EQU 1 +OBJ_FRAME EQU 2 +OBJ_MOVE EQU 3 +OBJ_LIMIT EQU 4 +OBJ_HEALTH EQU 5 +OBJ_DESTZONE EQU 6 +OBJ_MISC EQU 7 +OBJ_STATE EQU 8 +OBJ_GROUP EQU 9 +OBJ_DESTL EQU 10 +OBJ_DESTH EQU 11 +OBJ_SPRITELO EQU 12 +OBJ_FIRETIMER EQU 13 +OBJ_NEXT EQU 15 +OBJ_BYTES EQU 16 + +OBJBIT_THROWN EQU 7 + +;Flags (FGAttributes) +FLAG_PALETTE EQU %00000111 +FLAG_ISBULLET EQU %00010000 +FLAG_2X2 EQU %00100000 +FLAG_NOROTATE EQU %01000000 +FLAG_NOTHROW EQU %10000000 + +BIT_ISBULLET EQU 4 +BIT_2X2 EQU 5 +BIT_NOROTATE EQU 6 +BIT_NOTHROW EQU 7 + +;Groups +GROUP_FFA EQU 0 +GROUP_HERO EQU 1 +GROUP_MONSTERA EQU 2 +GROUP_MONSTERB EQU 3 +GROUP_MONSTERC EQU 4 +GROUP_MONSTERD EQU 5 +GROUP_MONSTERE EQU 6 +GROUP_MONSTERF EQU 7 +GROUP_MONSTERG EQU 8 +GROUP_MONSTERH EQU 9 +GROUP_MONSTERI EQU 10 +GROUP_MONSTERJ EQU 11 +GROUP_MONSTERK EQU 12 +GROUP_MONSTERL EQU 13 +GROUP_MONSTERM EQU 14 +GROUP_MONSTERN EQU 15 +FOF_FRIEND EQU 1 +FOF_ENEMY EQU 0 + +;misc defines +CLASS_EXPLOSION EQU 255 ;$ff + +;class fns +EXPORT ConvertLocHLToXY +EXPORT ConvertXYToLocHL +EXPORT ConvertLocHLToSpriteCoords + +EXPORT classDoNothing +EXPORT classDoNothing2 +EXPORT classDoNothing3 +EXPORT classHeroIdle +EXPORT classGeneric +EXPORT classTalker +EXPORT classBAPlayer +EXPORT classBSPlayer +EXPORT classPansy +EXPORT classBigLongLaser +EXPORT classExplosion +EXPORT classLadyFlower +EXPORT classCaptainFlour +EXPORT classCroutonHulk +EXPORT classCroutonGrunt +EXPORT classB12Soldier +EXPORT classActor +EXPORT classActorSpeed1 +EXPORT classActor2x2 +EXPORT classGuard + +;global class methods +EXPORT SuperInit +EXPORT SuperDie +EXPORT RemoveFromMap +EXPORT GetCurZone +EXPORT SetState +EXPORT SetPuffCount +EXPORT GetPuffCount +EXPORT AmAtLocation +EXPORT IsActorAtDest +EXPORT SetAttackDelay +EXPORT GetAttackDelay +EXPORT GetHealth +EXPORT SetHealth +EXPORT SetDestL +EXPORT SetDestH +EXPORT GetDestL +EXPORT GetDestH +EXPORT SetMisc +EXPORT GetMisc +EXPORT CreateExplosion +EXPORT GetCurLocation +EXPORT SetCurLocation +EXPORT GetFacing +EXPORT SetFacing +EXPORT SetGroup +EXPORT GetGroup +EXPORT SetActorDestLoc +EXPORT SetFoodIndexRange +EXPORT GetBGAttributes +EXPORT GetFGAttributes +EXPORT SetFGAttributes +EXPORT ShiftObjectInDirection + +;objList vars and functions +EXPORT headTable +EXPORT tailTable +EXPORT AddObjectsToObjList +EXPORT IndexToPointerDE +EXPORT IndexToPointerHL +EXPORT PointerDEToIndex +EXPORT PointerHLToIndex +EXPORT ResetList +EXPORT CreateObject +EXPORT CreateInitAndDrawObject +EXPORT DeleteObject +EXPORT IterateAllLists +EXPORT IterateList +EXPORT FindObject +EXPORT CallMethod +EXPORT SetObjWidthHeight +EXPORT IterateMaxObjects +EXPORT AllocateSprite +EXPORT FreeSprite +EXPORT CreateMetaSprite +EXPORT CreateMetaSpriteUsingMask +EXPORT ScrollMetaSprite +EXPORT SetMetaSpritePos +EXPORT FreeMetaSprite +EXPORT DeleteObjectsOfClass +EXPORT DeleteObjectsOfClassIndex +EXPORT GetFirst +EXPORT GetNextObject +EXPORT GetNext +EXPORT GetAssociated +EXPORT GetHead +EXPORT GetTail +EXPORT SetHead +EXPORT SetNext +EXPORT InitFOF +EXPORT SetFOF +EXPORT GetFOF +EXPORT LinkRemakeLists +EXPORT GetClass +EXPORT GetFGMapping +EXPORT SetFGMapping +EXPORT GetBGMapping +EXPORT SetBGMapping +EXPORT GetMyHero + +EXPORT classTable +EXPORT objects +EXPORT objExists +EXPORT objClassLookup + +EXPORT colorTable +EXPORT oldZone +EXPORT firstFreeObj +EXPORT curObjIndex +EXPORT nextObjIndex +EXPORT iterateNext +EXPORT oamFindPos +EXPORT numFreeSprites + +EXPORT GetClassMethodTable +EXPORT InstanceOf +EXPORT SetAssociated +EXPORT CountNumObjects +EXPORT ClassIndexIsHeroType + +BA_CINDEX EQU 2054 +BS_CINDEX EQU 2056 +HAIKU_CINDEX EQU 2058 +BABULLET_CINDEX EQU 2130 +FLOWER_CINDEX EQU 2136 +FLOUR_CINDEX EQU 2138 +BSBULLET_CINDEX EQU 2218 +PANSYBULLET_CINDEX EQU 2132 + +FREEVERSE_CINDEX EQU 2292 +CS_CINDEX EQU 2256 +RA_CINDEX EQU 2254 + diff --git a/Source/Defs.inc b/Source/Defs.inc new file mode 100644 index 0000000..eab482f --- /dev/null +++ b/Source/Defs.inc @@ -0,0 +1,688 @@ +INCLUDE "Source/Class.inc" + +DEBUG EQU 0 +EMULATORCOMPATIBLE EQU 1 + +ENV_NONE EQU 0 +ENV_RAIN EQU 1 +ENV_SNOW EQU 2 +ENV_WINDYSNOW EQU 3 +ENV_DIRT EQU 4 +ENV_CLOUDS EQU 5 +ENV_COUNTER EQU 6 +ENV_DISCO EQU 7 + +HERODATASIZE EQU 16 + +HERODATA_DATA EQU 0 +HERODATA_JOY EQU 0 +HERODATA_INDEX EQU 1 +HERODATA_OBJ EQU 2 +HERODATA_BULLET_INDEX EQU 4 +HERODATA_CLASS EQU 5 +HERODATA_ENTERDIR EQU 7 +HERODATA_ENTERLOC EQU 8 +HERODATA_I EQU 10 +HERODATA_J EQU 11 +HERODATA_TYPE EQU 12 +HERODATA_HEALTH EQU 13 +HERODATA_MOVED EQU 14 ;to help with strafe etc +HERODATA_PUFFCOUNT EQU 15 + +DLG_BORDER EQU %00000001 +DLG_PRESSB EQU %00000010 +DLG_WAITRELEASE EQU %00000100 +DLG_NOCLEAR EQU %00001000 +DLG_BRAINIAC EQU %00010000 +DLG_CLEARSKIP EQU %00100000 + +DLG_BORDER_BIT EQU 0 +DLG_PRESSB_BIT EQU 1 +DLG_WAITRELEASE_BIT EQU 2 +DLG_NOCLEAR_BIT EQU 3 +DLG_BRAINIAC_BIT EQU 4 +DLG_CLEARSKIP_BIT EQU 5 +;dialog settings are tweaked in CheckSkip + +JOY_START EQU $80 +JOY_SELECT EQU $40 +JOY_B EQU $20 +JOY_A EQU $10 +JOY_DOWN EQU $08 +JOY_UP EQU $04 +JOY_LEFT EQU $02 +JOY_RIGHT EQU $01 + +JOY_START_BIT EQU 7 +JOY_SELECT_BIT EQU 6 +JOY_B_BIT EQU 5 +JOY_A_BIT EQU 4 +JOY_DOWN_BIT EQU 3 +JOY_UP_BIT EQU 2 +JOY_LEFT_BIT EQU 1 +JOY_RIGHT_BIT EQU 0 + +FIRSTOBJTILE EQU 160 +TOTALOBJTILE EQU 80 +TOTALTILES EQU ((FIRSTOBJTILE - TOTALOBJTILE) - 1) + +;reserved classes indicate that a tile in the map is part of a larger +;creature. If a tile were "CLASS_ADJOIN_N", for example, then the tile +;to the north would be either the actual monster or a pointer indicating +;which direction to look next +CLASS_ADJOIN_N EQU $fc +CLASS_ADJOIN_E EQU $fd +CLASS_ADJOIN_S EQU $fe +CLASS_ADJOIN_W EQU $ff + +DIR_NORTH EQU 0 +DIR_EAST EQU 1 +DIR_SOUTH EQU 2 +DIR_WEST EQU 3 + +EXIT_N EQU 1 +EXIT_E EQU 2 +EXIT_S EQU 3 +EXIT_W EQU 4 +EXIT_U EQU 5 +EXIT_D EQU 6 +EXIT_X EQU 7 + +;RAM banks +MAPBANK EQU 1 +TILEINDEXBANK EQU 2 +OBJLISTBANK EQU 2 +OBJBANK EQU 3 +TILESHADOWBANK EQU 4 +ATTRSHADOWBANK EQU 5 +ZONEBANK EQU 6 +WAYPOINTBANK EQU 7 +LEVELSTATEBANK EQU 7 +FADEBANK EQU 7 +MUSICBANK EQU 7 +FLIGHTCODEBANK EQU 7 + +;ROM banks +;0 - HOME: All map- and gfx-loading routines are here as well as the +; main control structures. The class vector table is also +; stored here. +;1 - CLASS: All class+object methods for the main game are here. This +; bank is switched in after a level has been loaded. +;2 - Tile0: First set of tile bitmap data and attribute tables. +;3 - Map0: First set of level data +CLASSROM EQU 1 +OBJROM EQU 1 +BGTILEROM1 EQU 2 +BGTILEROM2 EQU 5 +FGTILEROM EQU 3 +MAP0ROM EQU 4 + +FX_FADE EQU 1 + +;Flags (BGAttributes) +BG_FLAG_SPECIAL EQU %00111000 +BG_FLAG_WALKOVER EQU %00001000 +BG_FLAG_SHOOTOVER EQU %00010000 +BG_FLAG_ATTACKABLE EQU %00100000 + +BG_BIT_WALKOVER EQU 3 +BG_BIT_SHOOTOVER EQU 4 +BG_BIT_ATTACKABLE EQU 5 + +;Game State Flags +HERO_BA_FLAG EQU %00000001 +HERO_CS_FLAG EQU %00000001 + +HERO_BS_FLAG EQU %00000010 +HERO_RA_FLAG EQU %00000010 +HERO_FREEVERSE_FLAG EQU %00000010 + +HERO_HAIKU_FLAG EQU %00000100 +HERO_FLOUR_FLAG EQU %00001000 +HERO_FLOWER_FLAG EQU %00010000 +HERO_GRENADE_FLAG EQU %00100000 + +HERO_BA_BIT EQU 0 +HERO_BS_BIT EQU 1 +HERO_HAIKU_BIT EQU 2 +HERO_FLOUR_BIT EQU 3 +HERO_FLOWER_BIT EQU 4 +HERO_GRENADE_BIT EQU 5 + +;link cable codes +LTRUE EQU 1 +LSYNCHREADY EQU 1 +LSYNCHWAIT EQU 2 +LNULL EQU $40 ;control code %01000000 = no buttons +LGETGAMESTATE EQU $81 +LGETMAPINDEX EQU $82 +LUPDATESTATE EQU $83 +LUPDATEHERO EQU $84 +LSYNCHRONIZE EQU $85 +LYANKPLAYER EQU $86 ;yank player to specified map +LTERMINATE EQU $87 ;terminate the current link +LRESYNCHRONIZE EQU $88 +LGETRANDOMSEED EQU $89 +LLOCKHEROES EQU $8a +LCHANGEAPPXMAP EQU $8b +LADDINVITEM EQU $8c +LREMINVITEM EQU $8d +LUPDATEMEMORY EQU $8e +LLINKTEST EQU $90 +LNOLINK EQU $ff + +;main.asm +EXPORT encodeControlByteTable +EXPORT decodeControlByteTable + +;user.asm +EXPORT SetActiveROM +EXPORT LongCall +EXPORT LongCallNoArgs +EXPORT WaitFade +EXPORT GetInput +EXPORT VWait +EXPORT UpdateObjects +EXPORT RedrawMap +EXPORT HandleRemoteInput +EXPORT TransmitByte +EXPORT ReceiveByte +EXPORT ExchangeByte +EXPORT TransmitData +EXPORT ReceiveData +EXPORT TransmitCompressedData +EXPORT ReceiveCompressedData +EXPORT CheckSimultaneousLCC +EXPORT YankRemotePlayer +EXPORT RemoveRemoteHero +EXPORT DebugMesg +EXPORT DebugVal +EXPORT SetDialogSkip +EXPORT SetDialogForward +EXPORT ClearDialogSkipForward +EXPORT ClearSkipForward +EXPORT SetSkipStackPos +EXPORT OnHBlank +EXPORT CinemaOnHBlank +EXPORT HOffsetOnHBlank +EXPORT SeasonsOnHBlank +EXPORT UpdateObjTimers +EXPORT InstallHBlankHandler +EXPORT PlaySample +EXPORT samplePlaying +EXPORT sampleBank +EXPORT sampleAddress +EXPORT sampleMask +EXPORT AddAppomattoxIfPresent +EXPORT Lookup8 +EXPORT Lookup16 +EXPORT LookupIndexOfData8 +EXPORT FindFirstBGLoc +EXPORT LinkTransmitMemoryLocation + +EXPORT curInput0 +EXPORT curInput1 +EXPORT dialogJoyIndex +EXPORT dialogSpeakerIndex +EXPORT getLocInitFacing +EXPORT losLimit +EXPORT longCallTempA +EXPORT amChangingMap +EXPORT curHeroAddressL +EXPORT heroesPresent +EXPORT vblankTimer +EXPORT backBufferReady +EXPORT backBufferDestHighByte +EXPORT paletteBufferReady +EXPORT dmaLoad +EXPORT randomLoc +EXPORT jiggleDuration +EXPORT jiggleType +EXPORT transmitACK +EXPORT hblankVector + +EXPORT objTimerBase +EXPORT objTimer60ths +EXPORT heroTimerBase +EXPORT heroTimer60ths +EXPORT levelCheckSkip +EXPORT dialogSettings +EXPORT fadeRange +EXPORT moveAlignPrecision +EXPORT fireBulletDirection +EXPORT fireBulletDamage +EXPORT fireBulletSound +EXPORT fireBulletLocation +EXPORT explosionInitialFrame +EXPORT myGroup +EXPORT myFacing +EXPORT secondChoiceDirection + +EXPORT curLevelIndex +EXPORT curLevelStateIndex +EXPORT timeToChangeLevel +EXPORT mapTotalSize +EXPORT mapExitLinks +EXPORT specialFX +EXPORT dmaLoadSrc0 +EXPORT dmaLoadDest0 +EXPORT dmaLoadLen0 +EXPORT dmaLoadSrc1 +EXPORT dmaLoadDest1 +EXPORT dmaLoadLen1 +EXPORT bgFlags +EXPORT baMoved +EXPORT bsMoved +EXPORT heroJoyIndex +EXPORT myJoy +EXPORT levelCheckStackPos +EXPORT displayType +EXPORT scrollSprites +EXPORT heroesIdle +EXPORT allIdle +EXPORT dialogIdleSettings +EXPORT canJoinMap +EXPORT checkTemp +EXPORT metaSprite_y +EXPORT metaSprite_x +EXPORT metaSprite_first_x + +EXPORT curJoy0 +EXPORT hero0_data +EXPORT hero0_index +EXPORT hero0_object +EXPORT hero0_bullet_index +EXPORT hero0_class +EXPORT hero0_enterLevelFacing +EXPORT hero0_enterLevelLocation +EXPORT hero0_i +EXPORT hero0_j +EXPORT hero0_type +EXPORT hero0_health +EXPORT hero0_moved +EXPORT hero0_puffCount + +EXPORT curJoy1 +EXPORT hero1_data +EXPORT hero1_index +EXPORT hero1_object +EXPORT hero1_bullet_index +EXPORT hero1_class +EXPORT hero1_enterLevelFacing +EXPORT hero1_enterLevelLocation +EXPORT hero1_i +EXPORT hero1_j +EXPORT hero1_type +EXPORT hero1_health +EXPORT hero1_moved +EXPORT hero1_puffCount + +EXPORT levelVars + +EXPORT linkBailOut + +EXPORT musicEnabled +EXPORT musicOverride1 +EXPORT musicOverride4 +EXPORT musicBank +EXPORT musicNoteCountdownInit +EXPORT musicNoteCountdown +EXPORT musicTrack1Pos +EXPORT musicTrack2Pos +EXPORT musicTrack3Pos +EXPORT musicTrack4Pos +EXPORT musicInstrument1 +EXPORT musicInstrument2 +EXPORT musicInstrument3 +EXPORT musicInstrument4 +EXPORT musicWaveform +EXPORT musicStack +EXPORT curTrackStackL +EXPORT musicStackL1 +EXPORT musicStackL2 +EXPORT musicStackL3 +EXPORT musicStackL4 +EXPORT musicRegisters +EXPORT musicAddress + +EXPORT numFreeObjects +EXPORT fgFlags +EXPORT lineZeroHorizontalOffset +EXPORT exitTileIndex + +EXPORT hblankWinOn +EXPORT hblankWinOff +EXPORT hblankFlag + +;Gfx.asm +EXPORT LoadNextLevel +EXPORT temp +EXPORT drawMapTemp +EXPORT SpriteDMAHandler +EXPORT InitGfx +EXPORT DisplayOff +EXPORT VMemCopy +EXPORT MemSet +EXPORT MemCopy +EXPORT InitDMALoad +EXPORT WaitDMALoad +EXPORT DMALoad +EXPORT SetupCommonColor +EXPORT AddHL16 +EXPORT AddDE16 +EXPORT GenerateFacings +EXPORT LoadSprites +EXPORT LoadFont +EXPORT PrepareForInitialMapDraw +EXPORT DrawMapToBackBuffer +EXPORT DrawCinemaToBackBuffer +EXPORT AdjustCameraToHero +EXPORT GentleCameraAdjust +EXPORT RestrictCameraToBounds +EXPORT ScrollToCamera +EXPORT ScrollSpritesLeft +EXPORT ScrollSpritesRight +EXPORT ScrollSpritesUp +EXPORT ScrollSpritesDown +EXPORT GetRandomNumZeroToN +EXPORT GetRandomNumMask +EXPORT SetupFadeFromWhite +EXPORT SetupFadeFromStandard +EXPORT FadeCommonSetPaletteToWhite +EXPORT FadeCommonSetPaletteToBlack +EXPORT FadeCommonSetPaletteToBlackBGOnly +EXPORT SetupFadeToWhite +EXPORT SetupFadeToStandard +EXPORT SetupFadeFromBlack +EXPORT BlackoutPalette +EXPORT SetupFadeToBlack +EXPORT SetupFadeFromBlackBGOnly +EXPORT SetupFadeToBlackBGOnly +EXPORT SetupFadeFromSaturated +EXPORT SetupFadeToGamePalette +EXPORT SetupFadeToHalfbrite +EXPORT FadeCommonCopyPalette +EXPORT CopyPalette64 +EXPORT CopyPalette32 +EXPORT InstallGamePalette +EXPORT FadeInit +EXPORT FadeStep +EXPORT LighteningOut +EXPORT LighteningIn +EXPORT GetRedComponent +EXPORT GetGreenComponent +EXPORT GetBlueComponent +EXPORT SetRedComponent +EXPORT SetGreenComponent +EXPORT SetBlueComponent +EXPORT PlaySound +EXPORT PlaySoundChannel1 +EXPORT PlaySoundChannel2 +EXPORT PlaySoundChannel3 +EXPORT PlaySoundChannel4 + +EXPORT WaitInput +EXPORT WaitInputZero +EXPORT WaitInputClick +EXPORT CreateBigExplosion +EXPORT BlitMap +EXPORT LCheckGetVectorToState +EXPORT SaveIdle +EXPORT RestoreIdle +EXPORT MakeIdle +EXPORT MakeNonIdle +EXPORT UseAlternatePalette +EXPORT UpdateDialogBalloons +EXPORT DisableDialogBalloons +EXPORT ResetFreeSprites +EXPORT UpdateEnvEffect +EXPORT SetEnvEffect + +EXPORT CheckEachHero +EXPORT RemoveHero +EXPORT SetRespawnMap +EXPORT SetJoinMap +EXPORT SetLinkBailOutAddress +EXPORT SetHBlankHandler +EXPORT GetMethodAddrFromPointer +EXPORT CallBGAction + +EXPORT ResetSprites + +;Cinema.asm +EXPORT LoadCinemaBG +EXPORT LoadCinemaSprite +EXPORT LoadCinemaTextBox +EXPORT CinemaBlitRect +EXPORT CinemaSpotAnimationRandomVerticalFrames +EXPORT CinemaSpotAnimationRandomHorizontalFrames +EXPORT StdWaitDialogNoClear +EXPORT StdWaitDialog + +;cinema character animation routines +EXPORT AnimateSkippy +EXPORT AnimateFlour +EXPORT AnimateHaiku +EXPORT AnimateBRAINIAC +EXPORT AnimateLadyFlower +EXPORT AnimateFlourDriving +EXPORT AnimateBS +EXPORT AnimateBA +EXPORT AnimateLadyFlowerDistress +EXPORT AnimateCaptainGunpoint +EXPORT State0To1 + + +;Map.asm +EXPORT BGTiles1024 +EXPORT LoadMap +EXPORT MapCoordsToIndex +EXPORT SetupMapVarsFromWidthPitchAndHeight +EXPORT ParseMap +EXPORT ClearBackBuffer +EXPORT SetBGSpecialFlags +EXPORT ResetMyBGSpecialFlags +EXPORT CallMapInit +EXPORT LoadAssociatedClass +EXPORT SaveFGTileInfo +EXPORT RestoreFGTileInfo +EXPORT PrepSetupHero +EXPORT PrepSetupHeroBC +EXPORT SetupHero +EXPORT FindExitLocation +EXPORT FindClassIndex +EXPORT ChangeClass +EXPORT ChangeFirstClass +EXPORT ChangeMyClass +EXPORT ChangeMyClassAndRedraw +EXPORT ChangeMyClassToAssociatedAndRedraw +EXPORT RemoveObjectFromList +EXPORT AddObjectToList +EXPORT CopyMapMethodToRAM +EXPORT HandleExitFromMap +EXPORT HasInventoryItem +EXPORT AddInventoryItem +EXPORT GetFirstInventoryIndex +EXPORT GetNextInventoryIndex +EXPORT RemoveInventoryItem +EXPORT GuestContinueSynchronization + +EXPORT map +EXPORT zoneBuffer +EXPORT backBuffer +EXPORT attributeBuffer +EXPORT tileShadowBuffer +EXPORT attributeShadowBuffer +EXPORT gamePalette +EXPORT objBackBuffer +EXPORT objAttributeBuffer +EXPORT mapOffsetNorth +EXPORT mapOffsetEast +EXPORT mapOffsetSouth +EXPORT mapOffsetWest +EXPORT mapWidth +EXPORT mapPitch +EXPORT mapPitchMinusOne +EXPORT mapPitchMinusOneComplement +EXPORT mapSkip +EXPORT mapHeight +EXPORT numClasses +EXPORT firstHero +EXPORT numFGTiles +EXPORT fgDestPtr +EXPORT firstMonster +EXPORT mapColor +EXPORT mapLeft +EXPORT mapTop +EXPORT mapRight +EXPORT mapBottom +EXPORT mapRightPlusOne +EXPORT mapBottomPlusOne +EXPORT mapMaxLeft +EXPORT mapMaxTop +EXPORT camera_i; +EXPORT camera_j; +EXPORT distToWall_N +EXPORT distToWall_E +EXPORT distToWall_S +EXPORT distToWall_W + +EXPORT curROMBank +EXPORT updateTimer +EXPORT curObjWidthHeight +EXPORT scrollSpeed + +EXPORT gameState +EXPORT heroesAvailable +EXPORT heroesUsed +EXPORT heroesLocked +EXPORT appomattoxMapIndex +EXPORT respawnMap +EXPORT joinMap +EXPORT guardAlarm +EXPORT amLinkMaster +EXPORT lastLinkAction +EXPORT checkInputInMainLoop +EXPORT amShowingDialog +EXPORT gameStatePad + +EXPORT desiredMapLeft +EXPORT desiredMapTop +EXPORT curPixelOffset_x +EXPORT curPixelOffset_y +EXPORT desiredPixelOffset_x +EXPORT desiredPixelOffset_y +EXPORT scrollAccelState_x +EXPORT scrollAccelState_y + +EXPORT tempL,tempH +EXPORT delTempL,delTempH + +EXPORT methodParamL +EXPORT methodParamH +EXPORT bulletDirection +EXPORT bulletLocation +EXPORT bulletColor +EXPORT bulletClassIndex +EXPORT bulletDamage + +EXPORT inventory +EXPORT dialogNPC_speakerIndex +EXPORT dialogNPC_heroIndex +EXPORT dialogBalloonClassIndex +EXPORT envEffectType +EXPORT bsUpgrades +EXPORT baUpgrades +EXPORT haikuUpgrades + +EXPORT mapBank +EXPORT mapContents +EXPORT mapState +EXPORT mapDialogClassIndex +EXPORT mapHeroZone + +EXPORT dialogBank +EXPORT classLookup + +EXPORT bgTileMap +EXPORT bgAttributes +EXPORT fgTileMap +EXPORT fgAttributes +EXPORT spritesUsed +EXPORT associatedIndex +EXPORT flightCode +EXPORT fadeCurPalette +EXPORT fadeFinalPalette +EXPORT fadeCurRGB +EXPORT fadeDelta +EXPORT fadeError +EXPORT fadeSteps +EXPORT fadeStepsToGo + +EXPORT FOFTable +EXPORT wayPointList +EXPORT pathList +EXPORT pathMatrix +EXPORT levelState +EXPORT heroState + +EXPORT rainbowColors +EXPORT horizontalOffset + +EXPORT levelCheckRAM +levelCheckADDR EQU $c900 +EXPORT spriteOAMBuffer + +EXPORT ShowTitle +EXPORT SetSpeakerToFirstHero +EXPORT SetSpeakerFromHeroIndex +EXPORT SetPressBDialog +EXPORT CheckDialogContinue +EXPORT ShowDialogNPC +EXPORT ShowDialogHero +EXPORT ShowDialogAtTop +EXPORT ShowDialogAtTopNoWait +EXPORT ShowDialogAtTopCommon +EXPORT ShowDialogAtBottom +EXPORT ShowDialogAtBottomNoWait +EXPORT ShowDialogAtBottomCommon +EXPORT ShowDialogWait +EXPORT ClearGTXLine +EXPORT WriteGTXLine +EXPORT ClearDialog +EXPORT GfxBlitBackBufferToWindow +EXPORT GfxShowStandardTextBox +EXPORT CheckSkip +EXPORT Delay + +;Music.asm +EXPORT InitMusic +EXPORT PlayMusic +EXPORT StopMusic +EXPORT IsCurMusic + +EXPORT beehive_gbm +EXPORT hoedown_gbm +EXPORT alarm_gbm +EXPORT intro_cinema_gbm +EXPORT bs_gbm +EXPORT lady_flower_gbm +EXPORT main_in_game_gbm +EXPORT haiku_gbm +EXPORT moon_base_ba_gbm +EXPORT moon_base_haiku_gbm +;EXPORT shroom_gbm +EXPORT cowboy_gbm +EXPORT frosty_gbm +EXPORT fgbwar_gbm +EXPORT wedding_gbm +EXPORT takeoff_gbm +EXPORT spaceish_gbm +EXPORT death_gbm +EXPORT jungle_gbm +EXPORT mysterious_gbm + +EXPORT GetNumObjects + +INCLUDE "Source/Macro.inc" + diff --git a/Source/Gfx.asm b/Source/Gfx.asm new file mode 100644 index 0000000..a3302a4 --- /dev/null +++ b/Source/Gfx.asm @@ -0,0 +1,7714 @@ +;*************************************************************************** +;* Gfx.asm - graphics support routines +;* 12.17.99 by Abe Pralle +;* +;*************************************************************************** + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Start.inc" + +MAX_PER_TURN EQU 32 + + + +FAST_SCROLL_THRESHOLD EQU 2 + + +SECTION "Graphics",ROM0 +;--------------------------------------------------------------------- +; Routine: InitGfx +; Description: Sets up some basic graphics stuff - One time +;--------------------------------------------------------------------- +InitGfx:: + push bc + push de + push hl + + ;set up game state + ld a,$ff + ld [amLinkMaster],a + xor a + ld [lastLinkAction],a + ld [amChangingMap],a + ld [heroesPresent],a + + ld a,(hero0_data & $ff) + ld [curHeroAddressL],a + + ld a,(HERO_BA_FLAG | HERO_BS_FLAG | HERO_HAIKU_FLAG) + ld [heroesAvailable],a + + xor a + ld [heroesUsed],a + ld [randomLoc],a + ldio [musicEnabled],a + ld [musicBank],a + ld [musicAddress],a + ld [musicAddress+1],a + ld [heroesLocked],a + ld [hero0_puffCount],a + ld [hero1_puffCount],a + ld [inLoadMethod],a + + ld c,16 + ld hl,inventory +.clearInventory + ld [hl+],a + dec c + jr nz,.clearInventory + +;ld a,%10100001 +;ld [inventory],a +;ld a,%00000011 +;ld [inventory+1],a + + xor a + ld [musicOverride1],a + ld [musicOverride4],a + + ld a,64 + ld [fadeRange],a + + ld a,APPOMATTOXMAPINDEX + ld [appomattoxMapIndex],a + + ld a,BANK(init_flightCodes) + call SetActiveROM + ld a,FLIGHTCODEBANK + ld bc,256 + ld de,flightCode + ld hl,init_flightCodes + call MemCopy + + xor a + ldio [dmaLoad],a + ld [displayType],a + + ld a,1 + ldio [curROMBank],a + + call DisplayOff + call SetupSpriteHandler + + ;sound off + xor a + ldio [$ff26],a + + ;envelopes to zero + xor a + ldio [$ff12],a ;zero envelope all instruments + ldio [$ff17],a + ldio [$ff1c],a + ldio [$ff21],a + + ;turn on sound master control + ld a,$80 + ldio [$ff26],a + ld a,$ff + ldio [$ff24],a ;full volume both channels + ldio [$ff25],a ;all sounds to both channels + + ;setup vector to hblank + ld a,$c3 + ld [hblankVector],a ;opcode of jp + ld hl,OnHBlank + ld a,l + ld [hblankVector+1],a + ld a,h + ld [hblankVector+2],a + + ;enable VBlank interrupts + ld a,[$ffff] + or 1 + ld [$ffff],a + + ;turn LCD on + ld a,%11000011 + ld [$ff40], a ;lcdc control + + ;clear all level states to zero + ld a,LEVELSTATEBANK + ld [$ff70],a + ld c,0 ;loop 256 times + ld hl,levelState + xor a +.clearStateLoop + ld [hl+],a + dec c + jr nz,.clearStateLoop + + ld a,1 ;fade from white the first time + ld [standardFadeColor],a + + ;enable interrupts + ei + + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: VMemCopy +; Arguments: a - VRAM bank of destination +; c - number of 16-byte blocks (tiles) to copy +; de - dest +; hl - source +; Alters: af +; [$ff4f] VRAM bank +; Description: Copies bytes from source to destination in VRAM. +; If screen is active it utilizes DMA loading, otherwise +; a normal copy is performed. DMA copies exceeding +; 2048 bytes may produce weird results. +;--------------------------------------------------------------------- +VMemCopy:: + push bc + push de + push hl + push af + + ;test if screen is on + ldio a,[$ff40] + and %10000000 + jr nz,.screenIsOn + +.screenIsOff + pop af + ldio [$ff4f],a ;switch VRAM bank + +.setLoop + ld b,16 +.bytesLoop + ld a,[hl+] + ld [de],a + inc de + dec b + jr nz,.bytesLoop + + dec c + jr nz,.setLoop + jr .done + +.screenIsOn ;copy using DMA + pop af + call InitDMALoad + call WaitDMALoad + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: MemSet +; Arguments: a - RAM bank of destination +; bc - length in bytes +; d - byte to set to +; hl - dest +; Alters: af +; [$ff70] RAM bank +; Description: Sets each byte in the range to be the specified value. +;--------------------------------------------------------------------- +MemSet:: + push bc + push de + push hl + + ldio [$ff70],a + +.loop ld a,d + ld [hl+],a + dec bc + xor a + cp b + jr nz,.loop + cp c + jr nz,.loop + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: MemCopy +; Arguments: a - RAM bank +; bc - non-zero length in bytes +; de - destination starting address +; hl - source start address +; Alters: af +; [$ff70] RAM bank +; Description: Copies each of "bc" # of bytes from source to dest. +; Alters the RAM bank to specified but does not revert +; to original during or after copying. +;--------------------------------------------------------------------- +MemCopy:: + push bc + push de + push hl + + ldio [$ff70],a ;set RAM + +.copy ld a,[hl+] + ld [de],a + inc de + xor a + dec bc + cp b + jr nz,.copy + cp c + jr nz,.copy + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: InitDMALoad +; Arguments: a - VRAM bank of destination +; c - length in multiples of 16 bytes +; de - dest +; hl - source +; Alters: af +; Description: Preps appropriate variables for DMA transfer to take +; place on VBlank. Note may be called multiple times +; (er, twice) to set up values for bank 0 and bank 1 +; transfer. Note that transfers for bank 0 and bank 1 +; combined should not exceed 2048 bytes (and perhaps +; a bit less) +;--------------------------------------------------------------------- +InitDMALoad:: + or a + jr nz,.prepBank1 + +.prepBank0 + ld a,l + ld [dmaLoadSrc0],a + ld a,h + ld [dmaLoadSrc0+1],a + + ld a,e + ld [dmaLoadDest0],a + ld a,d + ld [dmaLoadDest0+1],a + + ld a,c + dec a + ld [dmaLoadLen0],a + + ldio a,[dmaLoad] + or 1 + ldio [dmaLoad],a + ret + +.prepBank1 + ld a,l + ld [dmaLoadSrc1],a + ld a,h + ld [dmaLoadSrc1+1],a + + ld a,e + ld [dmaLoadDest1],a + ld a,d + ld [dmaLoadDest1+1],a + + ld a,c + dec a + ld [dmaLoadLen1],a + + ldio a,[dmaLoad] + or 2 + ldio [dmaLoad],a + ret + +;--------------------------------------------------------------------- +; Routine: WaitDMALoad +; Alters: af +;--------------------------------------------------------------------- +WaitDMALoad:: + push bc + push de + push hl +.wait + ldio a,[dmaLoad] + and %11 + jr nz,.wait + + call GetInput + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: DMALoad +; Arguments: a - VRAM bank of destination +; c - byte length / 16 +; hl - source +; de - dest +; Alters: af +; Description: Combines InitDMALoad and WaitDMALoad. +;--------------------------------------------------------------------- +DMALoad:: + call InitDMALoad + call WaitDMALoad + ret + +;--------------------------------------------------------------------- +; Routine: DisplayOff +; Arguments: +; Alters: af +; Description: Waits for VBlank then turns of the display +;--------------------------------------------------------------------- +DisplayOff:: + ;skip if the display is off already + ld a,[$ff40] + and %10000000 + ret z + + ;turn display off + ld a,[$ffff] ;get interrupts enabled + push af ;save original value + and %11111110 ;turn off vblank interrupt + ld [$ffff],a ;"interrupt THIS!" +.wait ld a,[$ff44] ;get line being drawn + cp 144 ;wait until line is >= 144 + jr c,.wait + ld a,[$ff40] ;LCDC register + and %01111111 ;turn off screen + ld [$ff40],a + pop af ;retrieve original interrupt settings + ld [$ffff],a + +.waitVRAM + ld a,[$ff41] ;STAT register + and %00000010 ;bit 1 needs to be zero to access VRAM + jr nz,.waitVRAM + ret + +;--------------------------------------------------------------------- +; Subroutine: LoadNextLevel +; Arguments: +; Alters: af +; Description: Does all the prep work of setting up the next level +; based on arguments stored in memory +;--------------------------------------------------------------------- +LoadNextLevel:: + push bc + push de + push hl + +.reload + ld a,1 + ld [amChangingMap],a + + ;xor a + ;ld [timeToChangeLevel],a + + ;save old level's level state + ld a,LEVELSTATEBANK + ld [$ff70],a + ld a,[curLevelStateIndex] + ld l,a + ld h,((levelState>>8) & $ff) + ldio a,[mapState] + or a + jr nz,.stateNotZero + ld a,1 +.stateNotZero + ld [hl],a + + ;clear joystick input + xor a + ld [curJoy0],a + ld [curJoy1],a + ldio [jiggleDuration],a + ld [jiggleType],a ;normal jiggle + + call PrepLevel + ld a,[timeToChangeLevel] + or a + jr nz,.reload + + ;set interrupt controller flag so the interrupt will happen + ld a,[$ffff] ;interrupt enable control register + or %00000011 ;enable vblank and hblank interrupts + ld [$ffff],a ;store that back in the IEC + + call DrawMapToBackBuffer + + ;ld b,METHOD_CHECK + ;call IterateAllLists + + ;initialize some values + xor a + ldio [backBufferReady],a + + xor a + ld [amChangingMap],a + + ei ;enable interrupts + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: PrepLevel +; Description: Sets up some basic graphics stuff +;--------------------------------------------------------------------- +PrepLevel:: + push bc + push de + push hl + + ;reset some stuff + xor a + ld [levelCheckSkip],a + ld [levelCheckSkip+1],a + ld [levelCheckSkip+2],a + ld [levelCheckSkip+3],a + ld a,MAX_PER_TURN + ld [iterateNumObjects],a + + ld hl,timeToChangeLevel + ld a,[hl] + ld [hl],0 + cp 2 ;2=skip init & load in next + jp z,.loadMap + + ;restore default vector to hblank + ld hl,OnHBlank + call InstallHBlankHandler + + xor a + ldh [$ff43], a ;set screen offsets to 0 + ldh [$ff42], a + + xor a + ldh [$ff4a], a ;set window offsets to 7,0 + ld a,7 + ldh [$ff4b], a + + xor a + ld [specialFX],a + ld [paletteBufferReady],a + ld [mapColor],a + ld [mapColor+1],a + ld [bgAttributes],a + ld [bgTileMap],a + ld [checkInputInMainLoop],a + ld [dialogJoyIndex],a + ld [heroJoyIndex],a + ld [hero0_index],a + ld [hero1_index],a + ld [heroesIdle],a + ld [allIdle],a + ld [mapDialogClassIndex],a + ld [dialogSettings],a ;no border, no press B + ld [amShowingDialog],a + ld [objTimerBase],a + ld [objTimer60ths],a + ld [heroTimerBase],a + ld [heroTimerBase],a + ld [lineZeroHorizontalOffset],a + ld [samplePlaying],a + ld [guardAlarm],a + ld [dialogNPC_speakerIndex],a + ld [dialogNPC_heroIndex],a + ld [dialogBalloonClassIndex],a + ld [envEffectType],a + + ;clear the horizontal offsets + ld bc,144 + ld d,0 + ld hl,horizontalOffset + ld a,TILEINDEXBANK + call MemSet + + ld a,1 + ld [canJoinMap],a + + ld de,0 + call SetDialogSkip + call SetDialogForward + + ;--------------------------- + xor a + ;turn all sounds off + ldio [$ff12],a ;sound 1 envelope + ldio [$ff17],a ;sound 2 envelope + ldio [$ff1a],a ;sound 3 output + ldio [$ff21],a ;sound 4 envelope + + ld a,$ff + ld [$ff24],a ;full volume both channels + ;--------------------------- + + ld a,$ff + ld [dialogSpeakerIndex],a + + ;ld a,$21 ;fast=2, slow=1 + ;ld a,$22 ;fast=2, slow=2 + ld a,$42 + ldio [scrollSpeed],a + + ;set up each entry of bgTileMap to be its own index for a + ;speed trick in the map redraw + ld c,0 + ld hl,bgTileMap + xor a +.initBGTileMap + ld [hl+],a + inc a + dec c + jr nz,.initBGTileMap + + ld a,%00100111 ;background palette colors + ld [$ff47],a + + ld a,1 + ld [scrollSprites],a + + call LoadGraphics + + ;go back to VRAM bank zero + xor a ;Switch to tile map + ld [$ff00+$4f],a ;(VRAM bank 0) + + call SetupGamePalettes + + ;load in inventory items tiles 246-254 + ld a,BANK(BGTiles1024) + call SetActiveROM + ld a,1 + ;xor a + ld c,9 ;#characters + ld de,$8f60 + ld hl,BGTiles1024+$3f70 + call VMemCopy + + call LoadFont + + ld a,1 + ld c,1 ;1 character + ld de,$8ff0 + ld hl,blankTileData + call VMemCopy + + ;set up hblank interrupt + ld a,143 + ld [$ff45],a ;set lyc + xor a + ld [hblankFlag],a ;don't show dialog window + ld a,[$ff0f] ;clear LCDC interrupt flag + and %11111101 + ld [$ff0f],a + + ld a,119 + ldio [hblankWinOn],a + ld a,143 + ldio [hblankWinOff],a + + ld a,%00001100 ;setup stat for lyc = ly + ld [$ff41],a + + ld a,[$ffff] ;enable hblank interrupt + or %00000010 + ld [$ffff],a + + ld a,$98 + ld [backBufferDestHighByte],a + + call ResetSprites + +.loadMap + ; load in a map + ld a,BANK(ResetList) + call SetActiveROM + call ResetList + call ClearFGBGFlags + + ld hl,curLevelIndex + ld a,[hl+] + ld h,[hl] + ld l,a + call LoadMap + +.done + pop hl + pop de + pop bc + ret + +LoadFont:: + ;load in font into $8c80 (tiles 200-253) + ld a,BANK(fontData) + call SetActiveROM + xor a + ld c,62 ;# characters + ld de,$8c00 + ld hl,fontData + jp VMemCopy + +;--------------------------------------------------------------------- +; Routine: SetupSpriteHandler +; Description: Copies the routine required for sprite DMA to high +; RAM and initializes the sprites to off +;--------------------------------------------------------------------- +SetupSpriteHandler:: + ld hl,oamHandlerStart ;src addr + ld de,SpriteDMAHandler ;dest addr + ld c,(oamHandlerFinish - oamHandlerStart) ;# of bytes + +.loop ld a,[hl+] + ld [de],a + inc de + + dec c + jr nz,.loop + + call ResetSprites + + ret + +oamHandlerStart: + ld a,((spriteOAMBuffer>>8) & $ff) ;addr of start (in $100's) + ld [$ff00+$46],a ;start sprite dma + ld a,$28 ;start a delay loop +.wait dec a + jr nz,.wait + ret +oamHandlerFinish: + + +;--------------------------------------------------------------------- +; Routine: SetupCommonColor +; Arguments: b - Color Spec for entry to set up +; de - color for entry +; Description: Sets all 8 palettes (bg AND sprite) to have the same +; colors for the specified entry. +; Note: The format specification should have bit 7 set so it +; auto-selects the next palette +;--------------------------------------------------------------------- +SetupCommonColor:: + push af + push bc + push hl + + ld a,FADEBANK + ld [$ff70],a + ld a,b + + ld h,((gamePalette>>8) & $ff) + and %00000110 ;color # * 2 + add (gamePalette & $ff) + ld l,a + + ld a,b + + ld c,16 + +.loop + ld a,e ;Get low byte of color + ld [hl+],a ;store it in game palette + + ld a,d ;Get high byte of color + ld [hl+],a ;store in game palette + + ld a,l ;skip next 3 colors in game palette + add 6 + ld l,a + + dec c + jr nz,.loop + + pop hl + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: SetupGamePalettes +; Description: Sets up [gamePalette] the in-game colors but sets +; the actual hardware to be all standard +;--------------------------------------------------------------------- +SetupGamePalettes: + push bc + push de + push hl + + ld a,FADEBANK + ld [$ff70],a + + ld a,%10000000 ;color specs + ld [$ff68],a + ld [$ff6a],a + + ld bc,$0000 ;standard fade color + ld hl,standardFadeColor + ld a,[hl] + ld [hl],0 + or a + jr z,.fadeColorSet + + ld bc,$7fff ;color 1 = white + +.fadeColorSet + ld hl,.stdPaletteData + ld de,gamePalette + ld a,32 ;set up 64 bytes (32 colors) + + +.loop push af + ld a,[hl+] + ld [de],a ;copy of palette + inc de + ld a,[hl+] + ld [de],a + inc de + + ld a,c + ld [$ff69],a ;bg palette + ld [$ff6b],a ;fg palette + + ld a,b + ld [$ff69],a ;bg palette + ld [$ff6b],a ;fg palette + + pop af + dec a + jr nz,.loop + +;repeat for FG colors + ld hl,.stdPaletteData + ld c,32 ;set up 64 bytes (32 colors) + +.loopFG ld a,[hl+] + ld [de],a ;copy of palette + inc de + ld a,[hl+] + ld [de],a + inc de + + dec c + jr nz,.loopFG + + pop hl + pop de + pop bc + + ret + +.stdPaletteData + DW $0000, $2108, $4210, $7fff ;Palette 0 (Grey) + DW $0000, $000A, $001f, $7fff ;Palette 1 (Red) + DW $0000, $5000, $7e00, $7fff ;Palette 2 (Blue) + DW $0000, $0140, $03e0, $7fff ;Palette 3 (Green) + DW $0000, $4008, $5192, $7fff ;Palette 4 (Purple) + DW $0000, $01cd, $03fe, $7fff ;Palette 5 (Yellow) + DW $0000, $00d1, $09ff, $7fff ;Palette 6 (Brown) + DW $0000, $4412, $799c, $7fff ;Palette 7 (Fuscia) + +;--------------------------------------------------------------------- +; Routines: IndexToPointerDE +; IndexToPointerHL +; Arguments: a - index 1-255 of object +; Returns: de/hl - pointer $d010-$dff0 to object +;--------------------------------------------------------------------- +IndexToPointerDE:: + swap a + jr z,.null + ld e,a + and %00001111 + add $d0 + ld d,a + ld a,e + and %11110000 + ld e,a + ret +.null + ld de,0 + ret + +IndexToPointerHL:: + swap a + jr z,.null + ld l,a + and %00001111 + add $d0 + ld h,a + ld a,l + and %11110000 + ld l,a + ret +.null + ld hl,0 + ret + + +SECTION "TileCopyRoutines",ROM0 +;--------------------------------------------------------------------- +; Routines: AddHL16 +; AddDE16 +; Alters: af, (hl or de) +;--------------------------------------------------------------------- +AddHL16:: + ld a,l + add 16 + ld l,a + ret nc + inc h + ret +AddDE16:: + ld a,e + add 16 + ld e,a + ret nc + inc d + ret + +;--------------------------------------------------------------------- +; Routines: TileIndexLToAddressHL +; TileIndexEToAddressDE +; Arguments: l/e - tile index (0-255) +; Returns: hl/de - address of tile index ($9000 +/- index*16) +;--------------------------------------------------------------------- +TileIndexLToAddressHL: + push af + + ;shift "l" 4 left and into a + xor a ;clear a to zero (new high byte) + sla l ;shift into carry + rla ;carry into a + sla l ;repeat total of 4 times + rla ;carry into a + sla l + rla + sla l + rla + or $90 ;add base addr of $9000 + cp $98 ;>=$9800? + jr c,.allSet + + sub $10 ;signed #'s means >$9800 should be $8800+ + +.allSet + ld h,a ;a into h; hl is now $9000+/-offset + + pop af + ret + +TileIndexEToAddressDE: + push af + + ;shift "e" 4 left and into a + xor a ;clear a to zero (new high byte) + sla e ;shift into carry + rla ;carry into a + sla e ;repeat total of 4 times + rla ;carry into a + sla e + rla + sla e + rla + or $90 ;add base addr of $9000 + cp $98 + jr c,.allSet + + sub $10 + +.allSet + ld d,a ;a into d; de is now $9000+/-offset + + pop af + ret + + +;--------------------------------------------------------------------- +; Routine: TileCopyRotateCCW +; Arguments: l - Source tile index (0-255) +; e - Dest tile index +; Description: Copies pixels from source tile to dest tile, rotating +; 90 degrees counter clock-wise in the process +; Note: Assumes VRAM to be already accessible +;--------------------------------------------------------------------- +TileCopyRotateCCW: + push af + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ;Set up outer loop + ld a,8 ;outer loop 8 times + + ;Beginning of outer loop / Set up inner loop +.outer1 push de ;save source start + push af ;save outer loop counter + ld a,8 ;inner loop 8 times + +.inner1 push af ;save loop counter on stack + ld a,[de] ;get next even byte + rrca + rl b + ld [de],a + inc de + ld a,[de] ;get next odd byte + rrca + rl c + ld [de],a + inc de + + pop af ;retrieve loop counter + dec a + jr nz,.inner1 + + + ld a,b ;save next two bytes of result + ld [hl+],a + ld a,c + ld [hl+],a + + pop af ;retrieve outer loop counter + pop de ;reset srcptr to start of tile + dec a + jr nz,.outer1 + + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routines: TileCopy +; TileCopyShiftLeft +; TileCopyShiftRight +; TileCopyShiftLeftOverlay +; TileCopyShiftRightOverlay +; TileCopyShiftUp +; TileCopyShiftDown +; Arguments: e - Source tile index (0-15) +; l - Dest tile index (0-15) +; Description: Copies tiles while shifting 4 pixels in the specified +; direction (except for plain TileCopy). Tile patterns +; should be stored in $c000-$c0ff. "Overlay" routines +; OR the source with the destination. +;--------------------------------------------------------------------- +TileCopy: + push af + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ld c,16 ;loop 16 times +.loop ld a,[de] ;get a byte + inc de + ld [hl+],a ;put it in dest + dec c + jr nz,.loop + + pop hl + pop de + pop bc + pop af + ret + +TileCopyShiftLeft: + push af + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ld c,16 ;loop 16 times +.loop ld a,[de] ;get a byte + inc de + swap a ;flip nibbles + and $f0 ;clear out lower four bits + ld [hl+],a ;put it in dest + dec c + jr nz,.loop + + pop hl + pop de + pop bc + pop af + ret + +TileCopyShiftRight: + push af + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ld c,16 ;loop 16 times +.loop ld a,[de] ;get a byte + inc de + swap a ;flip nibbles + and $0f ;clear out upper four bits + ld [hl+],a ;put it in dest + dec c + jr nz,.loop + + pop hl + pop de + pop bc + pop af + ret + +TileCopyShiftLeftOverlay: + push af + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ld c,16 ;loop 16 times +.loop ld a,[de] ;get a byte + inc de + swap a ;flip nibbles + and $f0 ;clear out lower four bits + or [hl] ;combine with dest + ld [hl+],a + dec c + jr nz,.loop + + pop hl + pop de + pop bc + pop af + ret + +TileCopyShiftRightOverlay: + push af + push bc + push de + push hl + + ;Get tile addresses + call TileCopyIndicesToAddresses + + ld c,16 ;loop 16 times +.loop ld a,[de] ;get a byte + inc de + swap a ;flip nibbles + and $0f ;clear out upper four bits + or [hl] ;combine with dest + ld [hl+],a + dec c + jr nz,.loop + + pop hl + pop de + pop bc + pop af + ret + +TileCopyIndicesToAddresses: + push bc + ld c,4 + ld h,0 + ld d,0 +.loop + sla l + rl h + sla e + rl d + dec c + jr nz,.loop + pop bc + ld a,((backBuffer>>8) & $ff) + add a,h + ld h,a + ld a,((backBuffer>>8) & $ff) + add a,d + ld d,a + ret + +TileCopyShiftUp: + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ld a,e ;source += 8 + add 8 + ld e,a + + ld c,8 ;loop 8 times +.loop ld a,[de] ;get a byte + inc de + ld [hl+],a ;put it in dest + dec c + jr nz,.loop + + ;clear 4 rows (8 bytes) + ld c,8 + xor a +.clear + ld [hl+],a + dec c + jr nz,.clear + + pop hl + pop de + pop bc + ret + +TileCopyShiftDown: + push bc + push de + push hl + + call TileCopyIndicesToAddresses + + ;clear 4 rows (8 bytes) + ld c,8 + xor a +.clear + ld [hl+],a + dec c + jr nz,.clear + + ld c,8 ;loop 8 times +.loop ld a,[de] ;get a byte + inc de + ld [hl+],a ;put it in dest + dec c + jr nz,.loop + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: DuplicateTilesToSpriteMem +; Arguments: a - number of tiles to duplicate (1+) +; c - index of first tile in tile mem +; Alters: af +; Description: Copies {a} number of tiles (a*16 bytes) from $c000 +; (backBuffer) to $8000 + c*16. +; Note: Uses current VRAM bank +;--------------------------------------------------------------------- +DuplicateTilesToSpriteMem: + push bc + push de + push hl + + ld b,a ;tiles remaining + + ;de = $8000 + c*16 + ld a,c + swap a + and %00001111 + add $80 + ld d,a + + ld a,c + swap a + and %11110000 + ld e,a + + ;hl = $c000 + ld hl,backBuffer + +.next_tile + ;tiles 128-255 are in VRAM shared between sprites and tiles + ;and do not need to be copied. + ld a,c + cp 128 + jr nc,.after_copy + + push bc + ld c,1 ;1*16 bytes + ld a,1 ;VRAM bank 1 + call VMemCopy + pop bc + +.after_copy + ;de+=16, hl+=16 + call AddHL16 + call AddDE16 + + ;tileNum++, tilesRemaining-- + inc c + dec b + jr nz,.next_tile + + pop hl + pop de + pop bc + ret + +IF 0 + push bc + push de + push hl + + ld b,a + ld l,c + call TileIndexLToAddressHL + +.next_tile + ld a,h + cp $90 + jr c,.no_copy_necessary + + ;dest addr = source addr - $1000 + ld a,h + sub $10 + ld d,a + ld e,l + + ;source addr + ld hl,$c000 + ld c,16 + +.copy ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.copy + jr .after_copy + +.no_copy_necessary + ld de,16 + add hl,de + +.after_copy + dec b + jr nz,.next_tile + + pop hl + pop de + pop bc + ret +ENDC + +;--------------------------------------------------------------------- +; Routine: GenerateFacings +; Arguments: a - index (0-255) of the first of two consecutive +; tiles (frame1 and frame2) which should be facing +; east. Tiles should be located at $c000 +; (backBuffer). +; [curObjWidthHeight] - copy of FG attribute flags +; Description: Creates the following tiles at $9000-$97ff (indices +; 0-127) and $8800-$8fff (128-255): +; a - North facing, frame 1 +; a+1 - Top half of North facing, frame 2 +; a+2 - Bottom half of North facing, frame 2 +; a+3...a+5 - East facing (frame1, left frame2, right +; frame2) +; +; Duplicates any tiles in area $9000-$9800 into +; $8000-$8800 for tile<->sprite purposes +;--------------------------------------------------------------------- +GenerateFacings:: + push af + push bc + push de + push hl + + ld c,a ;starting index + + ldio a,[curObjWidthHeight] ;retrieve flags + bit BIT_2X2,a + jr z,.generate1x1 + jp .generate2x2 + +.generate1x1 + ld a,[curObjWidthHeight] ;attribute flags + bit BIT_NOROTATE,a + jr nz,.createNonRotatedSprites + +.createRotatedSprites + ;create non-split frames for sprites + ld e,0 ;source index + ld l,2 ;dest index + call TileCopyRotateCCW + inc e + inc l + call TileCopyRotateCCW + jr .copyTilesToSpriteMem + +.createNonRotatedSprites + ;create non-split frames for sprites + ld e,0 ;source index + ld l,2 ;dest index + call TileCopy + inc e + inc l + call TileCopy + +.copyTilesToSpriteMem + ld a,4 + call DuplicateTilesToSpriteMem + + ;East-facing frames + ld e,0 ;source index in e + ld l,3 ;dest index in l + call TileCopy + inc e ;source to next frame + inc l ;set dest index to next frame + call TileCopyShiftRight + inc l + call TileCopyShiftLeft + + ld a,[curObjWidthHeight] ;attribute flags + bit BIT_NOROTATE,a + jr nz,.copyNorthNoRotate + + ;North facings + ld l,0 ;dest is +0 (North) + ld e,3 ;Set source ptr to +3 (East) + call TileCopyRotateCCW + inc e + inc l + inc l + call TileCopyRotateCCW + inc e + dec l + call TileCopyRotateCCW + jr .copyBufferToVMem + +.copyNorthNoRotate + ld e,1 + ld l,6 + call TileCopy + ld e,6 + ld l,1 + call TileCopyShiftDown + inc l + call TileCopyShiftUp + +.copyBufferToVMem + ;Copy 6 tiles beginning at $c000+ to $9000+(c*16). + ;Next location after $97f0 is $8800. + ld a,c + cp 122 ;122+6 < 128 + jr c,.copySet ;to $9000+ + + cp 128 + jr nc,.copySet ;to $8800+ + +.copyOneByOne ;split across different banks + ld e,c + call TileIndexEToAddressDE ;destination + ld hl,$c000 ;source + + ld b,6 ;tiles to copy + ld c,1 ;copy 16 bytes at a time + +.nextTile + ld a,1 ;VRAM Bank 1 + call VMemCopy + call AddDE16 + call AddHL16 + ld a,d + cp $98 + jr nz,.destPtrOkay + ld d,$88 +.destPtrOkay + dec b + jr nz,.nextTile + jp .done + +.copySet + ld e,a + call TileIndexEToAddressDE + ld hl,$c000 + ld c,6 ;6*16 + ld a,1 + call VMemCopy + jp .done + +.generate2x2 + ;East-facing 2x2 + ld e,0 ;source index in e + ld l,10 ;dest index in l + call TileCopy + inc e + inc l + call TileCopy + inc e + inc l + call TileCopy + inc e + inc l + call TileCopy + + inc e + inc l + call TileCopyShiftRight + inc l + call TileCopyShiftLeft + inc e + call TileCopyShiftRightOverlay + inc l + call TileCopyShiftLeft + + inc e + inc l + call TileCopyShiftRight + inc l + call TileCopyShiftLeft + inc e + call TileCopyShiftRightOverlay + inc l + call TileCopyShiftLeft + + ld e,10 + ld l,2 + call TileCopyRotateCCW + inc e + ld l,0 + call TileCopyRotateCCW + inc e + ld l,3 + call TileCopyRotateCCW + inc e + ld l,1 + call TileCopyRotateCCW + inc e + ld l,8 + call TileCopyRotateCCW + inc e + ld l,6 + call TileCopyRotateCCW + inc e + ld l,4 + call TileCopyRotateCCW + inc e + ld l,9 + call TileCopyRotateCCW + inc e + ld l,7 + call TileCopyRotateCCW + inc e + ld l,5 + call TileCopyRotateCCW + + ;Copy 20 tiles beginning at $c000+ to $9000+(c*16). + ;Next location after $97f0 is $8800. + ld a,c + cp 108 ;108+20 < 128 + jr c,.copySet20 ;to $9000+ + + cp 128 + jr nc,.copySet20 ;to $8800+ + +.copyOneByOne20 ;split across different banks + ld e,c + call TileIndexEToAddressDE ;destination + ld hl,$c000 ;source + + ld b,20 ;tiles to copy + ld c,1 ;copy 16 bytes at a time + +.nextTile20 + ld a,1 ;VRAM Bank 1 + call VMemCopy + call AddDE16 + call AddHL16 + ld a,d + cp $98 + jr nz,.destPtrOkay20 + ld d,$88 +.destPtrOkay20 + dec b + jr nz,.nextTile20 + jr .done + +.copySet20 + ld e,a + call TileIndexEToAddressDE + ld hl,$c000 + ld c,20 ;20*16 + ld a,1 + call VMemCopy + jp .done + +.done + pop hl + pop de + pop bc + pop af + ret + +SECTION "Graphics2",ROM0 +;--------------------------------------------------------------------- +; Routine: LoadGraphics +; Arguments: +;--------------------------------------------------------------------- +LoadGraphics: + ld a,BANK(BGTiles) + call SetActiveROM + + ;switch to vram bank 1 + ld a,1 + ;ld [$ff4f],a + call .loadBlank + + ;switch to vram bank 0 + xor a + ;ld [$ff4f],a + call .loadBlank + + ;load 86 explosion sprites + ld a,MAP0ROM + call SetActiveROM + xor a + ld c,86 ;#sprites + ld de,$8000 + ld hl,explosionSprites + call VMemCopy + +IF 0 + ;load 80 explosion sprites + ld a,MAP0ROM + call SetActiveROM + ld hl,explosionSprites + ld de,$8000 + ld b,80 ;# sprites +.outer ld c,16 ;16 bytes each +.inner ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.inner + dec b + jr nz,.outer +ENDC + + ret + +.loadBlank + ;load a blank tile to tile 0 of VRAM bank "a" + ;xor a + ld c,1 ;1 tile + ld de,$9000 + ld hl,BGTiles ;1st tile is blank + call VMemCopy + ret + +IF 0 + ld hl,blankTile ;address to get graphics from + ld de, $9000 ;destination address (Tile VRAM) + ld c, 1 * 16 ;copy 1 tile of 16 bytes +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + ret +ENDC + +;--------------------------------------------------------------------- +; Routine: LoadSprites +; Arguments: a - ROM bank containing sprites +; c - number of sprites to load +; hl - starting addr of sprites to load +; de - dest addr of sprites to load +; Alters: af +; Description: Loads specified number of sprites to VRAM bank 0 +; specified location. Switches back to CLASSROM when +; done. Must be done on VBLANK or when display is off +;--------------------------------------------------------------------- +LoadSprites:: + push bc + push de + push hl + + call SetActiveROM + xor a ;VRAM bank 0 + ld [$ff4f],a + +.outer ld b,16 ;copy 16 bytes +.inner ld a,[hl+] + ld [de],a + inc de + dec b + jr nz,.inner + dec c + jr nz,.outer + + ld a,CLASSROM + call SetActiveROM + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: PrepareForInitialMapDraw +; Description: Sets relevant variables so the map can be drawn +;--------------------------------------------------------------------- +PrepareForInitialMapDraw:: + call AdjustCameraToHero + call RestrictCameraToBounds + + ld hl,mapLeft + ld a,[desiredMapLeft] + ld [hl+],a ;mapLeft + add 20 + ld [hl+],a ;mapRight + inc a + ld [hl+],a ;mapRightPlusOne + + ld a,[desiredMapTop] + ld [hl+],a ;mapTop + add 18 + ld [hl+],a ;mapBottom + inc a + ld [hl+],a ;mapBottomPlusOne + + xor a + ld [curPixelOffset_x],a + ld [curPixelOffset_y],a + ld [desiredPixelOffset_x],a + ld [desiredPixelOffset_y],a + ld [scrollAccelState_x],a + ld [scrollAccelState_y],a + + ;set up a table for speedy AI + ;east offset is +1 + ld a,1 + ld [mapOffsetEast],a ;low byte + xor a + ld [mapOffsetEast+1],a ;high byte + + ;west offset is -1 + ld a,$ff + ld [mapOffsetWest],a + ld [mapOffsetWest+1],a + + ;south offset is +pitch + xor a + ld [mapOffsetSouth+1],a + ld a,[mapPitch] + ld [mapOffsetSouth],a + + ;north offset is -pitch + cpl + inc a + ld [mapOffsetNorth],a + ld a,$ff + ld [mapOffsetNorth+1],a + + ret + +;--------------------------------------------------------------------- +; Routine: AdjustCameraToHero +; Arguments: None. +; Description: Centers camera on hero, then adjusts so that maximum +; amount of space on in all 4 directions is visible +; +;--------------------------------------------------------------------- +AdjustCameraToHero:: + ld a,[displayType] + or a + jr z,.mapType + + ;cinema type + xor a + ld [camera_i],a + ld [camera_j],a + ret + +.mapType + push bc + push de + push hl + + ld a,OBJBANK ;Get Location of hero + ld [$ff70],a + + ;hl = &heroX_object + LDHL_CURHERODATA HERODATA_OBJ + + ld a,[hl+] + ld e,a + ld a,[hl] + ld d,a + + ld a,[de] + ld l,a + ld [tempL],a + inc de + ld a,[de] + ld h,a + ld [tempH],a + + call ConvertLocHLToXY ;convert to x,y indices + ld a,h + ld [camera_i],a + ld a,l + ld [camera_j],a + ld a,MAPBANK + ld [$ff70],a + ldio a,[firstMonster] + ld c,a ;c class of first monster + + ;find nearest wall to the north of location + ld a,[tempL] ;hl will track location + ld l,a + ld a,[tempH] + ld h,a + ld b,0 ;b will track north offset + ld d,$ff ;de = -pitch + ld a,[mapPitch] + cpl + add 1 + ld e,a + push hl + +.nloop add hl,de + inc b + ld a,[hl] + or a + jr z,.nloop ;nothing at all here + cp c ;found something, check if monster + jr nc,.nloop ;don't count monsters + call GetBGAttributes + and (BG_FLAG_WALKOVER|BG_FLAG_SHOOTOVER) + ld a,MAPBANK + ldio [$ff70],a + jr nz,.nloop + + ;b is tile distance of closest wall to the north + pop hl ;retrieve original location + push bc ;save north count b + ld b,0 ;b counts clear tiles to south + ld d,0 ;de is offset to go south + ld a,[mapPitch] + ld e,a + push hl ;push original location again + +.sloop add hl,de + inc b + ld a,[hl] + or a + jr z,.sloop + cp c + jr nc,.sloop + call GetBGAttributes + and (BG_FLAG_WALKOVER|BG_FLAG_SHOOTOVER) + ld a,MAPBANK + ldio [$ff70],a + jr nz,.sloop + + ;now b is distance of closest wall to south + pop hl ;retrieve original location + ld a,b + pop bc ;retrieve north distance + ld c,a ;b=north, c=south dist + + ;---------------Scroll Camera South--------------------------- + ;while(s_dist >= 10 && n_dist<8){ + ; move camera to south; + ; south dist--; + ; north dist++; + ;} +.cam_south_loop + ld a,c ;s_dist >= 10? + cp 10 + jr c,.cam_south_loopDone + + ld a,b + cp 7 + jr nc,.cam_south_loopDone ;n_dist < 8? + + call .moveCameraSouth + jr .cam_south_loop + +.cam_south_loopDone + + ;---------------Scroll Camera North--------------------------- + ;while(n_dist >= 9 && s_dist<9){ + ; move camera to north; + ; south dist++; + ; north dist--; + ;} +.cam_north_loop + ld a,b ;n_dist >= 9? + cp 9 + jr c,.cam_north_loopDone + + ld a,c + cp 9 + jr nc,.cam_north_loopDone ;s_dist < 9? + + call .moveCameraNorth + jr .cam_north_loop + +.cam_north_loopDone + ld a,c ;save distances for later use + ld [distToWall_S],a + ld a,b + ld [distToWall_N],a + + ;---------------------------- + ; Handle east/west scrolling + ;---------------------------- + ld b,0 ;b counts clear tiles to west + ld d,h ;save hl in de + ld e,l + ldio a,[firstMonster] + ld c,a + dec hl + +.wloop inc b + ld a,[hl-] ;get location + or a + jr z,.wloop ;loop if empty + cp c + jr nc,.wloop ;loop if monster + call GetBGAttributes + and (BG_FLAG_WALKOVER|BG_FLAG_SHOOTOVER) + ld a,MAPBANK + ldio [$ff70],a + jr nz,.wloop + + ;now b is distance of closest wall to west + ld h,d ;set hl back to original location + ld l,e + ld d,b ;store west distance in d + ld b,0 + inc hl + +.eloop inc b + ld a,[hl+] ;get location + or a + jr z,.eloop ;loop if empty + cp c + jr nc,.eloop ;loop if monster + call GetBGAttributes + and (BG_FLAG_WALKOVER|BG_FLAG_SHOOTOVER) + ld a,MAPBANK + ldio [$ff70],a + jr nz,.eloop + + ;now b is distance of closest wall to east + ld c,b ;b=west, c=east dist + ld b,d + + ;---------------Scroll Camera East---------------------------- + ;while(e_dist >= 11 && w_dist<9){ + ; move camera to east; + ; east dist--; + ; west dist++; + ;} +.cam_east_loop + ld a,c ;e_dist >= 11? + cp 11 + jr c,.cam_east_loopDone + + ld a,b + cp 9 + jr nc,.cam_east_loopDone ;w_dist < 10? + + ld a,[camera_i] + inc a + ld [camera_i],a + dec c + inc b + jr .cam_east_loop + +.cam_east_loopDone + + ;---------------Scroll Camera West---------------------------- + ;while(w_dist >= 10 && e_dist<10){ + ; move camera to west; + ; east dist++; + ; west dist--; + ;} +.cam_west_loop + ld a,b ;w_dist >= 10? + cp 10 + jr c,.cam_west_loopDone + + ld a,c + cp 9 + jr nc,.cam_west_loopDone ;e_dist < 10? + + ld a,[camera_i] + dec a + ld [camera_i],a + inc c + dec b + jr .cam_west_loop + +.cam_west_loopDone + ld a,c ;save distances for later use + ld [distToWall_E],a + ld a,b + ld [distToWall_W],a + +.done + pop hl + pop de + pop bc + ret + +.moveCameraSouth + ld a,[camera_j] + inc a + ld [camera_j],a + dec c + inc b + ret + +.moveCameraNorth + ld a,[camera_j] + dec a + ld [camera_j],a + inc c + dec b + ret + +;--------------------------------------------------------------------- +; Routine: GentleCameraAdjust +; Arguments: None. +; Description: Adjusts the camera to the hero but then goes with the +; old camera position if it doesn't make much difference +;--------------------------------------------------------------------- +GentleCameraAdjust:: + ld a,[displayType] + or a + ret nz ;done if cinema display type + + push bc + push de + push hl + + ;save previous camera i,j + ld a,[camera_i] + ld b,a + ld a,[camera_j] + ld c,a + push bc + + call AdjustCameraToHero + + pop bc ;retrieve old camera coords + ld a,[camera_i] + cp b + jr z,.checkCamera_j ;new_i==old_i, don't bother + jr c,.new_i_lt_old_i + + ;new i > old i + sub b ;d = new_i - old_i + ld d,a + ld a,[distToWall_E] ;a = dist_E + offset + add d + cp 11 + jr c,.useOldCamera_i ;only good if east dist < 11 + jr .checkCamera_j + +.new_i_lt_old_i + ;new i < old i + sub b ;d = old_i - new_i + cpl + inc a + ld d,a + + ld a,[distToWall_W] + add d + cp 9 + jr c,.useOldCamera_i ;only good if west dist < 10 + jr .checkCamera_j + +.useOldCamera_i + ;we can use the old camera pos and be less jerky + ld a,b + ld [camera_i],a + +.checkCamera_j + ld a,[camera_j] + cp c + jr z,.done ;new_j==old_j, don't bother + jr c,.new_j_lt_old_j + + ;new j > old j + sub c ;d = new_j - old_j + ld d,a + ld a,[distToWall_S] ;a = dist_S + offset + add d + cp 10 + jr c,.useOldCamera_j ;only good if south dist < 10 + jr .done + +.new_j_lt_old_j + ;new j < old j + sub c ;d = old_j - new_j + cpl + inc a + ld d,a + + ld a,[distToWall_N] + add d + cp 9 + jr c,.useOldCamera_j ;only good if north dist < 9 + jr .done + +.useOldCamera_j + ;we can use the old camera pos and be less jerky + ld a,c + ld [camera_j],a + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: RestrictCameraToBounds +; Arguments: None. +;--------------------------------------------------------------------- +RestrictCameraToBounds:: + ld a,[displayType] + or a + jr nz,.cinemaType + + push hl + + ;set map left/right based on camera_i + ld a,[camera_i] + sub 9 + jr z,.left_le_0 + jr nc,.left_gt_0 + +.left_le_0 + ld a,1 ;set to 1 if < 1 + +.left_gt_0 + ld hl,mapMaxLeft + cp [hl] + jr z,.left_le_max + jr c,.left_le_max + + ld a,[hl] ;left = maxLeft + +.left_le_max + ld [desiredMapLeft],a + + ;now see about top/bottom boundaries using camera_j + ld a,[camera_j] + sub 8 + jr z,.top_le_0 + jr nc,.top_gt_0 + +.top_le_0 + ld a,1 ;set to one if less than one + +.top_gt_0 + ld hl,mapMaxTop + cp [hl] + jr z,.top_le_max + jr c,.top_le_max + + ld a,[hl] ;top = maxTop + +.top_le_max + ld [desiredMapTop],a + + pop hl + ret + +.cinemaType + push hl + + ;set map left/right based on camera_i + ld a,[camera_i] + sub 9 + jr z,.left_ge_0 + jr nc,.left_ge_0 + +.left_lt_0 + xor a ;set to 0 if < 0 + +.left_ge_0 + ld hl,mapMaxLeft + cp [hl] + jr z,.left_le_max2 + jr c,.left_le_max2 + + ld a,[hl] ;left = maxLeft + +.left_le_max2 + ld [desiredMapLeft],a + + ;now see about top/bottom boundaries using camera_j + ld a,[camera_j] + sub 8 + jr z,.top_ge_0 + jr nc,.top_ge_0 + +.top_lt_0 + xor a ;set to zero if less than zero + +.top_ge_0 + ld hl,mapMaxTop + cp [hl] + jr z,.top_le_max2 + jr c,.top_le_max2 + + ld a,[hl] ;top = maxTop + +.top_le_max2 + ld [desiredMapTop],a + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: ScrollToCamera +; Description: Scrolls from old camera view to new camera position. +; Increments of 2 pixels if difference < 4 tiles, +; increments of 4 pixels if >= 4 tiles +; Update: Uses [scrollSpeed][7:4] for fast, [3:0] slow +; instead of 4 and 2. +;--------------------------------------------------------------------- +ScrollToCamera:: + push bc + push de + push hl + + ;calculate tiles different in x & store in d + ld a,[mapLeft] + ld b,a + ld a,[desiredMapLeft] + sub b + jr nc,.gotPositiveXDiff + cpl + inc a +.gotPositiveXDiff + ld d,a + + ;calculate tiles different in y & store in e + ld a,[mapTop] + ld b,a + ld a,[desiredMapTop] + sub b + jr nc,.gotPositiveYDiff + cpl + inc a +.gotPositiveYDiff + ld e,a + + ;setup d,e with x-pixel step-size and max value + push de + ld a,d + cp FAST_SCROLL_THRESHOLD + jr c,.setupXForSlow + ld a,[scrollAccelState_x] + or a + jr z,.setupXForSlow + + ;get fast scroll speed in 9 + ldio a,[scrollSpeed] + swap a + and $0f + ld d,a + ;ld a,8 + ;sub d + ;ld e,a + ;ld d,4 + ;ld e,4 + + ;ld a,[desiredPixelOffset_x] ;make sure its a multiple of 4 + ;and %00000100 + ;ld [desiredPixelOffset_x],a + + jr .checkLeft +.setupXForSlow + ;get slow scroll speed in d + ldio a,[scrollSpeed] + and $0f + ld d,a + +.checkLeft + ;make sure current pixel offset is an even multiple of the speed + ;offset &= ~(speed - 1) + ;off mask off dec cpl + ;1 - and %111 0001 0000 1111 + ;2 - and %110 0010 0001 1110 + ;4 - and %100 0100 0011 1100 + ;8 - and %000 1000 0111 1000 + ld a,d + dec a + + ;first scroll sprites right by value to be masked off + ld e,a + ld hl,desiredPixelOffset_x + ld a,[hl] + and e + push de + ld d,a + call ScrollSpritesRight + pop de + ld a,e + cpl + and %00000111 + ld e,a + ld a,[hl] + and e + ld [hl],a + ld a,8 + sub d + ld e,a + + + ;ld a,[desiredPixelOffset_x] ;make sure its a multiple of 4 + ;and %00000100 + ;ld [desiredPixelOffset_x],a + + ld a,[mapLeft] + ld b,a + ld a,[desiredMapLeft] + cp b + jr z,.checkPixelOffset + + jr c,.desired_lt_current + jr .desired_gt_current + +.checkPixelOffset + ld a,[desiredPixelOffset_x] + or a + jr z,.x_offsetOkay + + push af + ld a,[scrollSprites] + or a + jr z,.afterScrollRight1 + call ScrollSpritesRight +.afterScrollRight1 + pop af + jr .scrollPixelsLeft + +.x_offsetOkay + ;reset accelleration if no scroll + xor a + ld [scrollAccelState_x],a + + jr .leftRightAdjustDone + +.desired_gt_current + ;desired is > current + ld a,[scrollSprites] + or a + jr z,.afterScrollSpritesLeft1 + call ScrollSpritesLeft +.afterScrollSpritesLeft1 + ld a,[desiredPixelOffset_x] + cp e + jr nc,.atMaxLeftPixelOffset + + add d + ld [desiredPixelOffset_x],a + jr .leftRightAdjustDone + +.atMaxLeftPixelOffset + ld hl,scrollAccelState_x + inc [hl] + xor a + ld [desiredPixelOffset_x],a + ld a,b + inc a + jr .recalcMapLeftRight + +.desired_lt_current + ld a,[scrollSprites] + or a + jr z,.afterScrollSpritesRight2 + call ScrollSpritesRight +.afterScrollSpritesRight2 + ld a,[desiredPixelOffset_x] + or a + jr z,.atMinLeftPixelOffset + +.scrollPixelsLeft + sub d + ld [desiredPixelOffset_x],a + + or a + jr nz,.leftRightAdjustDone + ld hl,scrollAccelState_x + inc [hl] + + jr .leftRightAdjustDone + +.atMinLeftPixelOffset + ld a,e + ld [desiredPixelOffset_x],a + ld a,b + dec a + +.recalcMapLeftRight + ld hl,mapLeft + ld [hl+],a ;mapLeft, mapRight, mapRight+1 + add 20 + ld [hl+],a + inc a + ld [hl+],a + +.leftRightAdjustDone + ;setup d,e with y-pixel step-size and max value + pop de + ld a,e + cp FAST_SCROLL_THRESHOLD + jr c,.setupYForSlow + or a + jr z,.setupYForSlow + + ldio a,[scrollSpeed] + swap a + and $0f + ld d,a + ld a,8 + sub d + ld e,a + ;ld d,4 + ;ld e,4 + ;ld a,[desiredPixelOffset_y] ;make sure its a multiple of 4 + ;and %00000100 + ;ld [desiredPixelOffset_y],a + jr .checkTop +.setupYForSlow + ldio a,[scrollSpeed] + and $0f + ld d,a + ld a,8 + sub d + ld e,a + ;ld d,2 + ;ld e,6 + +.checkTop + ;make sure current pixel offset is an even multiple of the speed + ;offset &= ~(speed - 1) + ;1 - and %111 0001 0000 1111 + ;2 - and %110 0010 0001 1110 + ;4 - and %100 0100 0011 1100 + ;8 - and %000 1000 0111 1000 + + ld a,d + dec a + + ;first scroll sprites down by value to be masked off to snap + ;them to the new grid + ld e,a + ld hl,desiredPixelOffset_y + ld a,[hl] + and e + push de + ld d,a + call ScrollSpritesDown + pop de + ld a,e + + cpl + and %00000111 + ld e,a + ld a,[hl] + and e + ld [hl],a + ld a,8 + sub d + ld e,a + + ld a,[mapTop] + ld b,a + ld a,[desiredMapTop] + cp b + jr z,.checkPixelOffsetTB + jr c,.desired_tb_lt_current + jr .desired_tb_gt_current + +.checkPixelOffsetTB + ld a,[desiredPixelOffset_y] + or a + jr z,.y_offsetOkay + + push af + ld a,[scrollSprites] + or a + jr z,.afterScrollSpritesDown1 + call ScrollSpritesDown +.afterScrollSpritesDown1 + pop af + jr .scrollPixelsUp + +.y_offsetOkay + ;reset accelleration if no scroll + xor a + ld [scrollAccelState_y],a + + jr .topBottomAdjustDone + +.desired_tb_gt_current + ;desired is > current + ld a,[scrollSprites] + or a + jr z,.afterScrollSpritesUp1 + call ScrollSpritesUp +.afterScrollSpritesUp1 + ld a,[desiredPixelOffset_y] + cp e + jr nc,.atMaxTopPixelOffset + + add d + ld [desiredPixelOffset_y],a + jr .topBottomAdjustDone + +.atMaxTopPixelOffset + ld hl,scrollAccelState_y + inc [hl] + + xor a + ld [desiredPixelOffset_y],a + ld a,b + inc a + jr .recalcMapTopBottom + +.desired_tb_lt_current + ld a,[scrollSprites] + or a + jr z,.afterScrollSpritesDown2 + call ScrollSpritesDown +.afterScrollSpritesDown2 + ld a,[desiredPixelOffset_y] + or a + jr z,.atMinTopPixelOffset + +.scrollPixelsUp + sub d + ld [desiredPixelOffset_y],a + + or a + jr nz,.topBottomAdjustDone + ld hl,scrollAccelState_y + inc [hl] + + jr .topBottomAdjustDone + +.atMinTopPixelOffset + ld a,e + ld [desiredPixelOffset_y],a + ld a,b + dec a + +.recalcMapTopBottom + ld hl,mapTop + ld [hl+],a ;mapTop, mapBottom, mapBottom+1 + add 18 + ld [hl+],a + inc a + ld [hl+],a + +.topBottomAdjustDone + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routines: ScrollSpritesLeft +; ScrollSpritesRight +; ScrollSpritesUp +; ScrollSpritesDown +; Arguments: d - pixels to scroll +; Alters: af +; Description: Scrolls each of the 40 sprites (if their y-pos!=0) +; "d" # of pixels in the desired direction. +;--------------------------------------------------------------------- +ScrollSpritesLeft:: + push af + push bc + push de + push hl + + xor a + sub d + ld d,a + jr ScrollSpritesLRCommon + +ScrollSpritesRight:: + push af + push bc + push de + push hl + +ScrollSpritesLRCommon: + ld hl,spriteOAMBuffer + ld bc,3 + ld e,40 + +.loop ld a,[hl+] + or a + jr z,.afterChange ;sprite inactive + + ld a,[hl] + add d + ld [hl],a + +.afterChange + add hl,bc + dec e + jr nz,.loop + +.done + pop hl + pop de + pop bc + pop af + ret + +ScrollSpritesUp:: + push af + push bc + push de + push hl + + xor a + sub d + ld d,a + jr ScrollSpritesUDCommon + +ScrollSpritesDown:: + push af + push bc + push de + push hl + +ScrollSpritesUDCommon: + ld hl,spriteOAMBuffer + ld bc,4 + ld e,40 + +.loop ld a,[hl] + or a + jr z,.afterChange ;sprite inactive + + add d + ld [hl],a + +.afterChange + add hl,bc + dec e + jr nz,.loop + +.done + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: DrawMapToBackBuffer +; Description: Sets relevant variables so the map can be drawn +; Note: Uses [temp] to store tile attributes +;--------------------------------------------------------------------- +DrawMapToBackBuffer:: + ld a,[displayType] + or a + jr z,.mapType + + jp DrawCinemaToBackBuffer + +.mapType + push bc + push de + push hl + + call SetupDrawCommon + +.outer push bc ;save vertical count "b" on stack + push de ;save starting ptr to dest (hl) and source (de) + push hl + +;----copy 21 bg tiles into backBuffer/attributeBuffer + ;save starting point, copy tile pattern numbers + push de + push hl + + ld a,MAPBANK + ld [$ff70],a + ld b,((bgTileMap>>8) & $ff) + + call .copy7BGTiles + call .copy7BGTiles + call .copy7BGTiles + + ;start over copying attributes + pop hl + pop de + push de + push hl + + ld a,h ;backBuffer -> attributeBuffer + add 3 + ld h,a + ld b,((bgAttributes>>8) & $ff) + call .copy7BGAttributes + call .copy7BGAttributes + call .copy7BGAttributes + + ;back to start again + pop hl + pop de + push de + push hl + + ;recopy FG tiles from shadow buffers + ld a,TILESHADOWBANK + ld [$ff70],a + + ldio a,[firstMonster] + ld b,a + + call .copy7FGTiles + call .copy7FGTiles + call .copy7FGTiles + + pop hl + pop de + + ld a,MAPBANK + ld [$ff70],a + ld a,h + add 3 + ld h,a + + call .copy7FGAttributes + call .copy7FGAttributes + call .copy7FGAttributes + + ;row done + +;---begin old code 3-------------------------------------------------- +IF 0 + + ;copy tile patterns & attributes for any BG tiles to --------- + ;tile & attribute shadow buffers + + ;save starting point + push de + push hl + + ;use hl for map source / shadow buffer dest + ld h,d + ld l,e + + ;setup loop + ld a,MAPBANK + ld [$ff70],a + ldio a,[firstMonster] + ld b,a + ld c,21 + +.copyBGTiles + ld a,[hl] + cp b + jr c,.isBGTile + inc hl + dec c + jr nz,.copyBGTiles + jr .copyBGTilesDone + +.isBGTile + ld d,((bgTileMap>>8) & $ff) + ld e,a + ld a,TILESHADOWBANK + ld [$ff70],a + ld a,[de] + ld [hl],a + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld d,((bgAttributes>>8) & $ff) + ld a,[de] + and %00000111 + ld [hl+],a + ld a,MAPBANK + ld [$ff70],a + dec c + jr nz,.copyBGTiles + +.copyBGTilesDone + ;retrieve starting point & save again + pop hl + pop de + push de + push hl + + ;copy set of 21 bytes from TILESHADOWBANK to backBuffer + ld a,TILESHADOWBANK + ld [$ff70],a + call .copy21 + + ;retrieve starting point + pop hl + pop de + + ;copy set of 21 bytes from ATTRSHADOWBANK to backBuffer + ld a,h + add 3 + ld h,a + ld a,ATTRSHADOWBANK + ld [$ff70],a + call .copy21 + +ENDC + ;row done +;----end old code 3--------------------------------------------------- + + +;------begin old code 2----------------------------------------------- +IF 0 + ;copy tile pattern numbers from map/buffer to backBuffer + ld a,MAPBANK + ld [$ff70],a + ldio a,[firstMonster] ;get index of first fg class + ld b,a + ld c,21 + push de + push hl + +.copyTileNumbers + ld a,[de] ;next class number from map + cp b + jr nc,.isFGTile + + ;lookup tile used for background + push bc + ld b,((bgTileMap>>8) & $ff) + ld c,a + ld a,[bc] + ld [hl+],a + inc de + pop bc + + dec c + jr nz,.copyTileNumbers + jr .setupCopyAttributes + +.isFGTile + ;lookup class number in tile shadow buffer + ;push bc + ld a,TILESHADOWBANK + ld [$ff70],a + ld a,[de] + inc de + ld [hl+],a + ld a,MAPBANK + ld [$ff70],a + dec c + jr nz,.copyTileNumbers + +.setupCopyAttributes + pop hl ;go back to start of line + pop de + ld a,h ;copy to attributeBuffer + add 3 + ld h,a + ld c,21 ;loop 21 times + +.copyAttributes + ld a,[de] ;next class number from map + cp b + jr nc,.isFGAttribute + + ;BG Attribute + push bc + ld b,((bgAttributes>>8) & $ff) + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + inc de + pop bc + dec c + jr nz,.copyAttributes + jr .rowDone + +.isFGAttribute + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] + ld [hl+],a + inc de + ld a,MAPBANK + ld [$ff70],a + dec c + jr nz,.copyAttributes + +.rowDone +ENDC +;------end old code 2----------------------------------------------- + + +;old loop code +;-------old code begin------------------------------------------------ +IF 0 + ld a,MAPBANK ;set RAM bank to the map bank + ld [$ff70],a + ld c,21 ;times to loop horizontally + +.inner push bc + ld a,[de] ;load a tile index from level map + cp b ;index of first monster + jr c,.isBGTile ;< first monster + +.isFGTile + ;retrieve FG tile info from shadow buffers parallel to main map + ld a,ATTRSHADOWBANK ;set RAM bank to the attribute shadow bank + ld [$ff70],a + ld a,[de] ;attributes + ldio [temp],a + ld a,TILESHADOWBANK ;set RAM bank to the tile shadow bank + ld [$ff70],a + ld a,[de] ;tile to draw + inc de + ld [hl],a ;store tile in backBuffer + ld a,MAPBANK ;set RAM bank to the map bank + ld [$ff70],a + jr .gotTile + +.isBGTile + inc de + or a + jr z,.isNullTile + ld c,a + ;ld a,TILEINDEXBANK ;select RAM bank of tile index maps + ;ld [$ff70],a + ld b,((bgAttributes>>8)&$ff) + ld a,[bc] ;attributes for this tile + and %00000111 ;get palette only + ldio [temp],a ;store for later + ld b,((bgTileMap>>8)&$ff) ;get ptr to tile to draw in bc + ld a,[bc] ;get tile to draw + ld [hl],a ;store tile in backBuffer + jr .gotTile + +.isNullTile + ld [temp],a ;attributes zero + ld [hl],a ;store tile in backBuffer + +.gotTile + push hl + ld a,h + add 3 ;768 bytes to get from backbuffer to attr buffer + ld h,a + + ld a,[temp] ;get attributes for this tile + ld [hl],a ;store attribute in buffer + + pop hl ;back to map buffer + +.afterDrawTile + inc hl + + ;inner loop termination test + pop bc + dec c + jr nz,.inner +ENDC +;-------old code end-------------------------------------------------- + + pop hl ;retrieve initial pointers + pop de + + ld a,[mapPitch] ;mapPtr += mapPitch + add e + ld e,a + jr nc,.hlNoCarry + inc d +.hlNoCarry + + ld a,32 ;bgTileMapPtr += 32 + add l + ld l,a + jr nc,.deNoCarry + inc h +.deNoCarry + + ;loop the outer loop again? + pop bc + dec b + jr nz,.outer + + call PostDrawCommon + +.done ;map is drawn, bitch + ld a,MAPBANK ;set RAM bank to the map bank + ld [$ff00+$70],a + + pop hl + pop de + pop bc + ret + +.copy7BGTiles + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + ld [hl+],a + ret + +.copy7BGAttributes + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ld a,[de] + inc de + ld c,a + ld a,[bc] + and %00000111 + ld [hl+],a + ret + +.copy7FGTiles + ld a,[hl] + cp b + jr c,.notMonster0 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster0 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster1 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster1 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster2 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster2 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster3 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster3 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster4 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster4 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster5 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster5 + inc hl + inc de + ld a,[hl] + cp b + jr c,.notMonster6 + ld a,[de] ;get monster tile + ld [hl],a +.notMonster6 + inc hl + inc de + ret + +.copy7FGAttributes + ld a,[de] + cp b + jr c,.fgNotMonster0 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster0 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster1 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster1 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster2 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster2 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster3 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster3 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster4 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster4 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster5 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster5 + inc hl + inc de + ld a,[de] + cp b + jr c,.fgNotMonster6 + ld a,ATTRSHADOWBANK + ld [$ff70],a + ld a,[de] ;get monster tile + ld [hl],a + ld a,MAPBANK + ld [$ff70],a +.fgNotMonster6 + inc hl + inc de + ret + +IF 0 +;loop unrolled for max speed +.copy21 + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ret +ENDC + +SetupDrawCommon: + ;set VRAM bank to zero + ld a,MAPBANK + ld [$ff00+$4f],a + + ;find address to start getting tile indices from + ld a,[mapPitchMinusOne] + ld c,a + ld a,[mapTop] + ld e,a + xor a + +.jTimesPitch + sla e ;times two + rla ;carry from low bit into high bit + srl c ;c is pitch-1, counter of how many times to shift + jr nz,.jTimesPitch + ld d,a ;high byte into d; de is now == j * pitch + + ld a,[mapLeft] + add e + ld e,a ;de is now (j*pitch) + i + ld hl,map ;add in base address of map + add hl,de + ld d,h + ld e,l + + ;get memory address of backBuffer in hl + ld hl,backBuffer + + ;start looping + ld b,19 ;times to loop vertically + ret + +PostDrawCommon: + ;if the map is scrolled as far as possible right and/or down we + ;need to clear the right and/or bottom border so the jiggle effect + ;won't look goofy + ld a,[mapMaxLeft] + ld b,a + ld a,[mapLeft] + cp b + jr c,.rightBorderOkay + + ;set up vertical loop clearing tiles to zero + ld hl,(backBuffer + 20) + ld de,32 + ld c,19 + xor a + +.vloop ld [hl],a + add hl,de + dec c + jr nz,.vloop + +.rightBorderOkay + ;does bottom border need clearing? + ld a,[mapMaxTop] + ld b,a + ld a,[mapTop] + cp b + jr c,.done + + ;set up horizontal loop clearing tiles to zero + ld hl,(backBuffer + (32*18)) + ld c,21 + xor a + +.hloop ld [hl+],a + dec c + jr nz,.hloop + +.done + ret + + +;--------------------------------------------------------------------- +; Routine: DrawCinemaToBackBuffer +; Alters: af +; Description: Sets relevant variables so the map can be drawn +; Note: Uses [temp] to store tile attributes +;--------------------------------------------------------------------- +DrawCinemaToBackBuffer:: + push bc + push de + push hl + + call SetupDrawCommon + +.outer push de ;save starting ptr to dest (hl) and source (de) + push hl + ld c,21 ;times to loop horizontally + +.inner push bc + ;retrieve tile info from shadow buffers parallel to main map + ld a,ATTRSHADOWBANK ;set RAM bank to the attribute shadow bank + ld [$ff70],a + ld a,[de] ;attributes + ldio [temp],a + ld a,TILESHADOWBANK ;set RAM bank to the tile shadow bank + ld [$ff70],a + ld a,[de] ;tile to draw + inc de + + ld [hl],a ;store tile in backBuffer + push hl + ld a,h + add 3 ;768 bytes to get from backbuffer to attr buffer + ld h,a + ld a,[temp] ;get attributes for this tile + ld [hl],a ;store attribute in buffer + pop hl ;back to map buffer +.afterDrawTile + inc hl + + ;inner loop termination test + pop bc + dec c + jr nz,.inner + + pop hl ;retrieve initial pointers + pop de + + ld a,[mapPitch] ;mapPtr += mapPitch + add e + ld e,a + jr nc,.hlNoCarry + inc d +.hlNoCarry + + ld a,32 ;bgTileMapPtr += 32 + add l + ld l,a + jr nc,.deNoCarry + inc h +.deNoCarry + + ;loop the outer loop again? + dec b + jr nz,.outer + + call PostDrawCommon + +.done ;map is drawn, bitch + ld a,MAPBANK ;set RAM bank to the map bank + ld [$ff00+$70],a + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ShowTitle +; Arguments: de - pointer to text +; Description: Shows the text centered on-screen and waits until +; the user presses a button to continue. +; Alters: a,hl +;--------------------------------------------------------------------- +ShowTitle:: + push bc + + ld a,[de] ;length of text + inc de + ld c,a + ld hl,spriteOAMBuffer+3 + +.loop + xor a ;sprite attributes + ld [hl-],a + ld a,[de] ;letter + inc de + ld [hl-],a + ld a,16 ;calculate x coordinate + sub c + sla a ;times 8 for pixels + sla a + sla a + ld [hl-],a ;y coordinate + ld a,80 + ld [hl],a + ld a,l ;add 7 to hl + add 7 + ld l,a + ld a,h + adc 0 + ld h,a + + dec c + jr nz,.loop + + pop bc + ret + +;--------------------------------------------------------------------- +; Routines: SetSpeakerToFirstHero +; Arguments: None. +; Returns: c - index of first hero present +; [dialogSpeakerIndex] +; [dialogJoyIndex] +; Alters: af, c +; Description: Finds the first hero on the map and sets up +; some dialog parameters based on who it is. +;--------------------------------------------------------------------- +SetSpeakerToFirstHero:: + push de + push hl + xor a + ld hl,hero0_index + call .setParameters + or a + jr nz,.done + + ld a,1 + ld hl,hero1_index + call .setParameters + +.done + pop hl + pop de + ret + +.setParameters + ld [dialogJoyIndex],a + ld a,[hl-] ;get hero index + or a ;non-zero? + ret z ;not present + + ld c,a ;class index + ld de,HERODATA_TYPE + add hl,de + ld a,[hl] + ld [dialogSpeakerIndex],a ;flag indicating speaker + ld a,1 ;operation successful + ret + +;--------------------------------------------------------------------- +; Routines: SetSpeakerFromHeroIndex +; Arguments: c - index of speaking hero +; Returns: [dialogSpeakerIndex] +; [dialogJoyIndex] +; Alters: af +; Description: +;--------------------------------------------------------------------- +SetSpeakerFromHeroIndex:: + push de + push hl + + ld hl,hero0_index + ld a,[hl-] + cp c + ld a,0 + jr nz,.setHero1 + + call .setParameters + jr .done + +.setHero1 + ld a,1 + ld hl,hero1_data + call .setParameters + +.done + pop hl + pop de + ret + +.setParameters + ld [dialogJoyIndex],a + ld de,HERODATA_TYPE + add hl,de + ld a,[hl] + ld [dialogSpeakerIndex],a ;flag indicating speaker + ret + + +;--------------------------------------------------------------------- +; Routine: SetPressBDialog +;--------------------------------------------------------------------- +SetPressBDialog: + ld a,DLG_BORDER | DLG_PRESSB + ld [dialogSettings],a + ret + +;--------------------------------------------------------------------- +; Routine: SetDialogJoy:: +; Arguments: None. +; Returns: hl - pointer to appropriate joy inputs +; Alters: af,hl +;--------------------------------------------------------------------- +SetDialogJoy:: + ld a,[displayType] + cp 1 + jr z,.cinemaType + ld a,[canJoinMap] + cp 2 ;asynchronous join? + jr z,.cinemaType + + ld hl,curInput0 + ld a,[dialogJoyIndex] + or a + ret z + inc hl + ret + +.cinemaType + ld hl,myJoy + ret + +;--------------------------------------------------------------------- +; Routine: CheckDialogContinue +; Arguments: None. +; Returns: a - 1 if done (B is pressed), 0 if not done +; Alters: af +; Description: Calls CheckDialogSkip and then sees if button B of +; the speaker's joystick is pressed. +;--------------------------------------------------------------------- +CheckDialogContinue:: + push hl + call CheckSkip + + call SetDialogJoy + + ld a,[dialogSettings] + and DLG_WAITRELEASE + jr nz,.waitRelease + + ld a,[hl] + and JOY_B + jr z,.returnFalse + + ld hl,dialogSettings + set DLG_WAITRELEASE_BIT,[hl] + jr .returnFalse + +.waitRelease + ld a,[hl] + and JOY_B + jr nz,.returnFalse + + ld hl,dialogSettings + res DLG_WAITRELEASE_BIT,[hl] + + bit DLG_CLEARSKIP_BIT,[hl] + jr z,.afterClearSkip + + res DLG_CLEARSKIP_BIT,[hl] + push hl + ld de,0 + call SetDialogSkip + pop hl + +.afterClearSkip + bit DLG_NOCLEAR_BIT,[hl] + res DLG_NOCLEAR_BIT,[hl] + jr nz,.returnTrue + + call ClearDialog + +.returnTrue + ld a,1 + jr .done + + +.returnFalse + xor a +.done + pop hl + ret + +;--------------------------------------------------------------------- +; Routines: ShowDialogAtTop +; ShowDialogAtTopNoWait +; ShowDialogAtBottom +; ShowDialogAtBottomNoWait +; ClearDialog +; Arguments: [dialogBank] - bank containing text +; c - class index of speaking character +; de - pointer to gtx text +; Description: Shows the text centered at the top or bottom dialog +; bar & waits until the user presses a button to +; continue. +; Alters: none +; Note: Format of gtx: +; BYTE number of lines +; REPT[nLines]: +; BYTE spaces to center +; BYTE num chars in line +; BYTE[nChars] characters +;--------------------------------------------------------------------- +ShowDialogNPC:: + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + ld a,[dialogNPC_speakerIndex] + ld c,a + call ShowDialogAtTop + call ClearDialog + ret + +ShowDialogHero:: + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + call ClearDialog + ret + +ShowDialogAtTop:: + ld a,[dialogBank] + push af + push bc + push de + push hl + + call ChooseFromDialogAlternates + + ld b,0 ;lines to skip at top + call ShowDialogCommon + call ShowDialogAtTopCommon + call ShowDialogWait + + pop hl + pop de + pop bc + pop af + ret + +ShowDialogAtTopNoWait:: + ld a,[dialogBank] + push af + push bc + push de + push hl + + call ChooseFromDialogAlternates + + ld b,0 ;lines to skip at top + call ShowDialogCommon + call ShowDialogAtTopCommon + + pop hl + pop de + pop bc + pop af + ret + +ShowDialogAtTopCommon:: + call DrawDialogBorderAtBottom + call GfxBlitBackBufferToWindow + + xor a + ldh [$ff4a], a ;set window y position + + ld a,[de] ;number of lines + rlca ;times 8 = pixels for window + rlca + rlca + add 7 + ld [hblankWinOff],a + + ld a,143 + ld [hblankWinOn],a + + ld a,[hblankFlag] + bit 1,a + jr nz,.afterSetLYC + + ld a,143 + ld [$ff45],a ;lyc + ld a,[hblankFlag] + +.afterSetLYC + or %10 ;allow window to show + ld [hblankFlag],a + + ld a,OBJROM + call SetActiveROM + ret + +ShowDialogAtBottom:: + ld a,[dialogBank] + push af + push bc + push de + push hl + + call ChooseFromDialogAlternates + + ld b,1 ;lines to skip at top + call ShowDialogCommon + call ShowDialogAtBottomCommon + call ShowDialogWait + + pop hl + pop de + pop bc + pop af + ret + +ShowDialogAtBottomNoWait:: + ld a,[dialogBank] + push af + push bc + push de + push hl + + call ChooseFromDialogAlternates + + ld b,1 ;lines to skip at top + call ShowDialogCommon + call ShowDialogAtBottomCommon + + pop hl + pop de + pop bc + pop af + ret + +ShowDialogAtBottomCommon:: + call DrawDialogBorderAtTop + call GfxBlitBackBufferToWindow + + ld a,143 + ld [hblankWinOff],a + + ;set window y pos. Req'd for actual GBC, not emulator + ld a,[de] ;# lines + cpl + add 1+17 ;(max lines) - (text lines+1) + rlca + rlca + rlca ;times 8 + ldh [$ff4a], a ;set window y position + + ld a,[de] ;number of lines + rlca ;times 8 = pixels for window + rlca + rlca + add 8 + cpl ;make negative (+1), subtract from 143 + add 144 ;+1 2's compl, +143 + ld [hblankWinOn],a + + ld a,[hblankFlag] + bit 1,a + jr nz,.afterSetLYC + + ld a,[hblankWinOn] + ld [$ff45],a ;lyc + ld a,[hblankFlag] + +.afterSetLYC + or %10 ;allow window to show + ld [hblankFlag],a + + ld a,OBJROM + call SetActiveROM + ret + +ClearDialog:: + push af + xor a + ld [amShowingDialog],a + + ld a,[hblankFlag] ;turn off dialog box and window + and %11111101 + ld [hblankFlag],a + call VWait + ;call InstallGamePalette + ld a,1 + ldio [paletteBufferReady],a + call VWait + pop af + ret + +ShowDialogWait:: + ;change both heroes to idle + ld a,[heroesIdle] + push af + ld a,1 + ld [heroesIdle],a + + call .waitInputZero + +.wait + call UpdateObjects + call RedrawMap + call CheckDialogContinue + or a + jr z,.wait + + ;call .waitInput + ;call .waitInputZero + + pop af + ld [heroesIdle],a + + ret + +.waitInputZero +DialogWaitInputZero:: + call UpdateObjects + call RedrawMap + ld h,((curInput0>>8) & $ff) + ld a,[dialogJoyIndex] + add (curInput0 & $ff) + ld l,a + ld a,[hl] + and %11110000 + jr nz,DialogWaitInputZero + ret + + +;--------------------------------------------------------------------- +; Routines: ShowDialogCommon +; Arguments: a - bank message is in +; b - lines to skip at top +; c - class index of speaking character +; de - pointer to gtx text beginning with #lines +; Description: +; Alters: af +; Note: Format of gtx: +; BYTE number of lines +; REPT[nLines]: +; BYTE spaces to center +; BYTE num chars in line +; BYTE[nChars] characters +;--------------------------------------------------------------------- +ShowDialogCommon:: + push de + push bc ;save class index of speaking character + + call SetActiveROM + + ld a,1 + ld [amShowingDialog],a + + ;wait until the backbuffer is blitted +.waitBackBuffer + ldio a,[backBufferReady] + or a + jr z,.canMessWithBackBuffer + + call VWait + jr .waitBackBuffer + +.canMessWithBackBuffer + ;clear the backbuffer and attribute buffer for given #lines + ld a,[de] ;b = number of lines + 1 + add 1 + ld b,a + ld hl,backBuffer + +.clearLines + call ClearGTXLine + push bc + ld bc,32 + add hl,bc + pop bc + dec b + jr nz,.clearLines + ;xor a +;.outer1 ld c,32 +;.inner1 ld [hl+],a + ;dec c + ;jr nz,.inner1 + ;dec b + ;jr nz,.outer1 + + ;ld a,[de] ;b = number of lines + 1 + ;add 1 + ;ld b,a + ;ld hl,attributeBuffer + ;xor a +;.outer2 ld c,32 +;.inner2 ld [hl+],a + ;dec c + ;jr nz,.inner2 + ;dec b + ;jr nz,.outer2 + + ;adjust hl down a line? + pop bc + push bc + ld hl,backBuffer + bit 0,b + jr z,.hlOkay + ld bc,32 + add hl,bc +.hlOkay + + ;for each line of text... + ld a,[de] ;b = number of lines + inc de + ld b,a + +.line + call WriteGTXLine + + ;go to next line + dec b + jr nz,.line + + ;retrieve class index of speaking character and + ;blit that tile to the top-left corner of the buffer + pop bc + call DrawTileToTLCorner + ;call GfxBlitBackBufferToWindow + pop de + ret + +;--------------------------------------------------------------------- +; Routine: ClearGTXLine +; Arguments: +; hl - backbuffer location to draw at +; Alters: af +;--------------------------------------------------------------------- +ClearGTXLine:: + push bc + push hl + + push hl + + ;clear backbuffer + xor a + ld c,32 +.loop ld [hl+],a + dec c + jr nz,.loop + + ;clear attr buffer + xor a + pop hl + ld bc,$300 + add hl,bc + ld c,32 +.loop2 ld [hl+],a + dec c + jr nz,.loop2 + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: WriteGTXLine +; Arguments: de - pointer to gtx text beginning with centerSpaces +; hl - location to draw at +; Alters: hl,de +;--------------------------------------------------------------------- +WriteGTXLine:: + ;advance hl spaces required to center text + push bc + ld b,0 + ld a,[de] + inc de + ld c,a + add hl,bc + + ;get the char count for this line + ld a,[de] + inc de + ld c,a + or a + jr z,.afterLoop + + ;copy the characters to the buffer +.loop ld a,[de] + inc de + ld [hl+],a + dec c + jr nz,.loop + +.afterLoop + ;advance hl to next line + ld a,l + and ~31 + add 32 + ld l,a + ld a,0 + adc h + ld h,a + + pop bc + ret + + +GfxBlitBackBufferToWindow:: + ;xor a + ;ld c,38 ;38*16 = 608 + ;ld de,$9c00 ;dest = window map memory + ;ld hl,$c000 ;source + ;call VMemCopy + ;ret + + ld a,$9c ;copy to window map memory + ldio [backBufferDestHighByte],a + ld a,1 + ldio [backBufferReady],a +.vwait call VWait + ldio a,[backBufferReady] ;wait until buffer is copied + or a + jr nz,.vwait + ld a,$98 ;go back to copying to bg map memory + ldio [backBufferDestHighByte],a + ret + +GfxShowStandardTextBox:: + ;set interrupt to turn window off at bottom of screen + ld a,143 + ld [hblankWinOff],a + + ;set window y pos. Req'd for actual GBC, not emulator + ld a,96 + ldh [$ff4a], a ;set window y position + ld [hblankWinOn],a + + ld a,[hblankFlag] + bit 1,a + jr nz,.afterSetLYC + + ld a,[hblankWinOn] + ld [$ff45],a ;lyc + ld a,[hblankFlag] + +.afterSetLYC + or %10 ;allow window to show + ld [hblankFlag],a + ret + +DrawDialogBorderAtTop: + push hl + ld hl,$c000 ;9c00 + call DrawDialogBorder + pop hl + ret + +DrawDialogBorderAtBottom: + push de + push hl + ld hl,$c000 ;9c00 + ld a,[de] ;num lines + ld d,a + xor a + srl d + rra + srl d + rra + srl d + rra + ld e,a + add hl,de + call DrawDialogBorder + pop hl + pop de + ret + +DrawDialogBorder: + push bc + push hl + + ld a,[dialogSettings] + and DLG_BORDER + jr z,.done + + ;draw border at edge + push hl + + ;xor a + ;ldio [$ff4f],a ;VRAM bank + + ld c,20 + ld a,252 +.drawBorder + ld [hl+],a + dec c + jr nz,.drawBorder + + dec hl + ld a,[dialogSettings] + and DLG_PRESSB + jr z,.clearBG + + ld [hl],253 + +.clearBG + pop hl + + ;clear bg attributes + ld bc,$300 + add hl,bc + + ;ld a,1 + ;ldio [$ff4f],a ;VRAM bank + + ld c,20 + xor a +.clearBGLoop + ld [hl+],a + dec c + jr nz,.clearBGLoop + +.done + pop hl + pop bc + ret + +DrawTileToTLCorner: ;class index in c, 1 line down in b +.drawTile + ld hl,backBuffer + bit 0,b + jr z,.hlOkay + ld l,32 +.hlOkay + ld a,c + or a + jr z,.useNullTile ;use null tile + + ld a,TILEINDEXBANK + ld [$ff70],a + + ld b,((fgAttributes>>8) & $ff) + ld a,[bc] + bit 5,a ;2x2 monster? + jr nz,.speaker2x2 + + and %00000111 + or %00001000 ;coming from bank 1 + ld h,((attributeBuffer>>8) & $ff) + ld [hl],a + + ld h,((backBuffer>>8) & $ff) + ld b,((fgTileMap>>8) & $ff) + ld a,[bc] ;a is tile to draw + add 3 ;get right-facing + ld [hl],a + + ret + +.speaker2x2 + and %00000111 ;color + or %00001000 ;coming from bank 1 + push hl + push hl + ld h,((attributeBuffer>>8) & $ff) + ld [hl+],a + ld [hl+],a + push de + ld de,30 + add hl,de + pop de + ld [hl+],a + ld [hl-],a + + ld h,((backBuffer>>8) & $ff) + ld b,((fgTileMap>>8) & $ff) + ld a,[bc] ;a is tile to draw + add 12 ;get right-facing + ld [hl+],a + inc a + ld [hl+],a + pop hl + sub 3 + ld [hl+],a + inc a + ld [hl+],a + pop hl + + ;kludge for two-color BRAINIAC + ld a,[dialogSettings] + bit DLG_BRAINIAC_BIT,a + ret z + + res DLG_BRAINIAC_BIT,a + ld [dialogSettings],a + ld h,((attributeBuffer>>8) & $ff) + inc hl + ld a,8+3 ;green color from bank 1 + ld [hl],a + push de + ld de,32 + add hl,de + pop de + ld [hl+],a + + ret + + +.useNullTile + xor a + ld [hl],a + ld h,((attributeBuffer>>8) & $ff) + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: ChooseFromDialogAlternates +; Arguments: de - pointer to gtx text +; Returns: de - adjusted pointer +; Alters: de +; Description: de points to start of an indeterminate number of +; byte triplets of the form: +; [mask] [offsetL] [offsetH] +; This routine finds a mask that (when ANDed) matches +; the value in [dialogSpeakerIndex] and jumps to the +; gtx alternate beginning at the given offset. The +; offset given for the cursor being at a position of +; 1 past [offsetH] of the matching triplet. +;--------------------------------------------------------------------- +ChooseFromDialogAlternates: + push af + push bc + push hl + + call SetActiveROM + + ld h,d + ld l,e + + ld a,[dialogSpeakerIndex] + ld c,a + +.attemptMatch + ld a,[hl+] ;mask + and c + jr nz,.foundMatch + + inc hl ;skip offset to look at next mask + inc hl + jr .attemptMatch + +.foundMatch + ld a,[hl+] ;retrieve offset to start of gtx proper + ld e,a + ld a,[hl+] + ld d,a + add hl,de + + ld d,h + ld e,l + + pop hl + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: CheckSkip +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Intended for use in cinemas and in-game dialog, +; resets the pc and sp to an address set with +; SetDialogSkip. Sets to the skip address if start is +; pushed, to fast-forward address if B is pushed. +;--------------------------------------------------------------------- +CheckSkip:: + push hl + + ld a,[displayType] + cp 1 + jr z,.cinemaType + ld a,[canJoinMap] ;asynchronous join? + cp 2 + jr z,.cinemaType + + ld hl,curInput0 + ld a,[dialogJoyIndex] ;0 or 1 + add l + ld l,a + jr .afterSetJoy + +.cinemaType + ld hl,myJoy + +.afterSetJoy + ld a,[hl] ;get the input + and JOY_START + jr nz,.startPressed + + ld a,[hl] + and JOY_B + jr z,.done ;no buttons pushed + +.abPressed + push hl + ld hl,levelCheckSkip ;fast forward address + jr .restore + +.startPressed + push hl + ld hl,levelCheckSkip+2 ;skip address + +.restore + ld a,[hl] + or a + jr nz,.addressOkay + inc hl + ld a,[hl-] + or a + jr nz,.addressOkay + + pop hl + jr .done + +.addressOkay + ;make the class/object ROM the current + ld a,OBJROM + call SetActiveROM + xor a + ld e,[hl] + ld [hl],a + inc hl + ld d,[hl] + ld [hl],a + pop hl + cp d + jr nz,.addrOkay + cp e + jr z,.done ;null address + +.addrOkay + ld a,$f0 + call WaitInputZero + + ;reset all one-shot dialog options + ld hl,dialogSettings + res DLG_BRAINIAC_BIT,[hl] + res DLG_NOCLEAR_BIT,[hl] + res DLG_CLEARSKIP_BIT,[hl] + + ;restore stack pointer + ld a,[levelCheckStackPos] + ld l,a + ld a,[levelCheckStackPos+1] + ld h,a + ld sp,hl + + ;push return address on stack and go there + push de + ret + +.done + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: Delay +; Arguments: a - number of 1/60 seconds to delay +; Alters: af +; Description: Updates and displays objects for specified number of +; 1/60 seconds. Jumps to [levelCheckSkip] if start +; button is pressed if addr is non-null. +;--------------------------------------------------------------------- +Delay:: + push bc + push de + push hl + + +.delay push af + call UpdateObjects + call RedrawMap + + call CheckSkip +.keepGoing + pop af + dec a + jr nz,.delay + +.waitBlit + ldio a,[backBufferReady] + or a + jr nz,.waitBlit + + ;if we're in a cinema and we get a YANK from the remote player + ;then we need to kill into the cinema script + ld a,[timeToChangeLevel] + or a + jr z,.done + + ld a,[inLoadMethod] + or a + jr z,.done + + call BlackoutPalette + ld a,[loadStackPosL] + ld l,a + ld a,[loadStackPosH] + ld h,a + ld sp,hl + jp AfterLoadLevelMethod + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetRandomNumZeroToN +; Arguments: a - maximum desired random number "N" +; Returns: a - random number between 0 and N +; Alters: af +;--------------------------------------------------------------------- +GetRandomNumZeroToN:: + or a + ret z + + push bc + push hl + + inc a + jr z,.handleFF + ld b,a ;b is N + + PUSHROM + ld a,BANK(randomTable) + call SetActiveROM + + ld hl,randomLoc + inc [hl] + ld l,[hl] + ld h,((randomTable>>8) & $ff) + + ld a,[hl] + bit 7,b + jr nz,.loop ;N+1>=128 + + ;divide raw number by two until it's less than limit*2 + ld c,b + sla c ;c = (limit * 2) + 1 + inc c +.fastReduce + cp c ;a < limit*2 + 1? + jr c,.loop ;yes, go to slower precision work + srl a ;a/=2 + jr .fastReduce + +.loop cp b ;subtract N while r > N + jr c,.done + sub b + jr .loop + +.done + ld b,a + POPROM + ld a,b + pop hl + pop bc + ret + +.handleFF + PUSHROM + ld a,BANK(randomTable) + call SetActiveROM + + ld hl,randomLoc + inc [hl] + ld l,[hl] + ld h,((randomTable>>8) & $ff) + + ld a,[hl] + ld b,a + POPROM + ld a,b + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetRandomNumMask +; Arguments: a - bit mask for random number +; Returns: a - random number +; Alters: af +;--------------------------------------------------------------------- +GetRandomNumMask:: + push bc + push hl + + ld b,a ;b is bitmask + + PUSHROM + ld a,BANK(randomTable) + call SetActiveROM + + ld hl,randomLoc + inc [hl] + ld l,[hl] + ld h,((randomTable>>8) & $ff) + + ld a,[hl] + and b + +.done + ld b,a + POPROM + ld a,b + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeFromWhite +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeFromWhite:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set cur palette to be all white + ld hl,fadeCurPalette + call FadeCommonSetPaletteToWhite + + ;set final palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +FadeCommonSetPaletteToWhite:: + ld c,64 +.loop + ld a,$ff + ld [hl+],a + ld a,$7f + ld [hl+],a + dec c + jr nz,.loop + ret + +CopyPalette64:: +FadeCommonCopyPalette:: + push bc + push de + push hl + ld a,FADEBANK + ld [$ff70],a + ld c,128 +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + pop hl + pop de + pop bc + ret + +CopyPalette32:: + push bc + push de + push hl + ld a,FADEBANK + ld [$ff70],a + ld c,64 +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: InstallGamePalette +; Arguments: None. +; Alters: af +; Description: Sets gamePalette to be installed to the hardware +; on the next VBlank. +;--------------------------------------------------------------------- +InstallGamePalette:: + push hl + push de + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld a,1 + ldio [paletteBufferReady],a +.wait + ldio a,[paletteBufferReady] ;wait for vblank to install it + or a + jr nz,.wait + + pop de + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeToWhite +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeToWhite:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette to be all white + ld hl,fadeFinalPalette + call FadeCommonSetPaletteToWhite + + ;set cur palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeFromBlack +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeFromStandard:: +SetupFadeFromBlack:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set cur palette to be all white + ld hl,fadeCurPalette + call FadeCommonSetPaletteToBlack + + ;set final palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeToBlack +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeToStandard:: +SetupFadeToBlack:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette to be all black + ld hl,fadeFinalPalette + call FadeCommonSetPaletteToBlack + + ;set cur palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +FadeCommonSetPaletteToBlack:: + ld c,64 + xor a +.loop + ld [hl+],a + ld [hl+],a + dec c + jr nz,.loop + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeFromBlackBGOnly +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeFromBlackBGOnly:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ;set cur palette to be all black + ld hl,fadeCurPalette + call FadeCommonSetPaletteToBlackBGOnly + + ;set final palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ld a,32 + ld [fadeRange],a + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: BlackoutPalette +; Arguments: +; Alters: af +; Description: Sets fadeCurPalette and final palette to all black +;--------------------------------------------------------------------- +BlackoutPalette:: + push bc + push de + push hl + + ld a,FADEBANK + ld [$ff70],a + + ld hl,fadeFinalPalette + call FadeCommonSetPaletteToBlack + + ld hl,fadeCurPalette + call FadeCommonSetPaletteToBlack + + ;turn off any existing fade + ld hl,specialFX + res 0,[hl] ;reset fade bit + + ;install the current palette on the next VBlank + ld a,1 + ldio [paletteBufferReady],a +.wait + ldio a,[paletteBufferReady] ;wait for vblank to install it + or a + jr nz,.wait + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeToBlackBGOnly +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeToBlackBGOnly:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ;set final palette BG Colors to be all black + ld hl,fadeFinalPalette + call FadeCommonSetPaletteToBlackBGOnly + + ;set cur palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ld a,32 + ld [fadeRange],a + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +FadeCommonSetPaletteToBlackBGOnly:: + ld c,32 + xor a +.loop + ld [hl+],a + ld [hl+],a + dec c + jr nz,.loop + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeFromSaturated +; Arguments: a - steps +; b - amount of saturation (white) to start at +; Alters: af +;--------------------------------------------------------------------- +SetupFadeFromSaturated:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;copy game palette to starting palette and ending palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ld l,b ;saturation + + ;add saturation to each color + ld h,64 +.setup call FadeCommonGetColor + dec de + dec de + call GetRedComponent + call .saturate + call SetRedComponent + call GetGreenComponent + call .saturate + call SetGreenComponent + call GetBlueComponent + call .saturate + call SetBlueComponent + + ;save color + ld a,c + ld [de],a + inc de + ld a,b + ld [de],a + inc de + + dec h + jr nz,.setup + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +.saturate + add l + bit 7,l + jr nz,.satneg + cp 32 ;over the limit? + ret c + + ld a,$1f + ret + +.satneg + xor a + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeToGamePalette +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeToGamePalette:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette to be current game palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetupFadeToHalfbrite +; Arguments: a - steps +; Alters: af +;--------------------------------------------------------------------- +SetupFadeToHalfbrite:: + push bc + push de + push hl + + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette to be halfbrite game palette + ld hl,gamePalette + ld de,fadeCurPalette + ld c,64 +.copyHalfbrite + push bc + ld a,[hl+] + ld c,a + ld a,[hl-] + ld b,a + call GetRedComponent + srl a + call SetRedComponent + call GetGreenComponent + srl a + call SetGreenComponent + call GetBlueComponent + srl a + call SetBlueComponent + ld a,c + ld [hl+],a + ld a,b + ld [hl+],a + pop bc + dec c + jr nz,.copyHalfbrite + + ;set cur palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FadeCommonGetColor +; Arguments: de - ptr to next color +; Returns: bc - next color +; Alters: af,de +;--------------------------------------------------------------------- +FadeCommonGetColor: + ld a,[de] + inc de + ld c,a + ld a,[de] + inc de + ld b,a + ret + +;--------------------------------------------------------------------- +; Routine: FadeInit +; Arguments: a - number of steps +; [fadeCurPalette], [fadeFinalPalette] already setup +; with palettes to fade between +; Alters: af +; Description: Sets up and uses fadeDelta[32*3] +; and fadeError[32*3]. +; FadeStep must then be called every vblank until +; [specialFX:0] becomes zero. +;--------------------------------------------------------------------- +FadeInit:: + push bc + push de + push hl + + ld [fadeSteps],a + ld [fadeStepsToGo],a + + ld a,FADEBANK + ld [$ff70],a + + ;for each color component, difference is (c2-c1) + ;subtract each element of fadeCurPalette from fadeFinalPalette + ;and store separate RGB offsets in fadeDelta. + ;fadeCurPalette RGB elements in fadeCurRGB. + + ;clear out fadeError and fadeDelta + ld hl,fadeError + ld de,fadeDelta + ld c,192 + xor a +.clearError + ld [hl+],a + ld [de],a + inc de + dec c + jr nz,.clearError + + ;begin by storing each color component of each color in + ;fadeCurPalette into fadeDelta + ld a,64 + ld hl,fadeDelta + ld de,fadeCurPalette + +.copyCurToDelta + push af + call FadeCommonGetColor + call GetRedComponent + ld [hl+],a + call GetGreenComponent + ld [hl+],a + call GetBlueComponent + ld [hl+],a + pop af + dec a + jr nz,.copyCurToDelta + + ;copy fadeDelta[192] to fadeCurRGB[192]. + ;ld hl,fadeDelta + ;ld de,fadeCurRGB + ;ld c,192 +;.copyToCurRGB + ;ld a,[hl+] + ;ld [de],a + ;inc de + ;dec c + ;jr nz,.copyToCurRGB + + ;fadeDelta[...] = fadeFinalPalette[...] - fadeDelta[...] + ld a,64 + ld hl,fadeDelta + ld de,fadeFinalPalette + +.findStep + push af + call FadeCommonGetColor + call GetRedComponent + sub [hl] + ld [hl+],a + call GetGreenComponent + sub [hl] + ld [hl+],a + call GetBlueComponent + sub [hl] + ld [hl+],a + pop af + dec a + jr nz,.findStep + + + ;indicate we've got a fade goin on + ld a,FX_FADE + ld [specialFX],a + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: FadeStep +; Alters: af +; Description: Peforms the next step of the fade in progress. +; Should only be called if [specialFX] & FX_FADE is 1. +; fadeRange is reset to 64 afterwards. +;--------------------------------------------------------------------- +FadeStep:: + push bc + push de + push hl + +.waitReady + ldio a,[paletteBufferReady] ;wait for vblank + or a + jr nz,.waitReady + + ;loop 64 times, adding the fade delta for each component + ;to the error. If error >= 32: + ; error -= 32; + ; increment component; + ;Then flag the newly created palette to be displayed + ld a,FADEBANK + ld [$ff70],a + + ld a,[fadeStepsToGo] + dec a + ld [fadeStepsToGo],a + jr z,.lastFade + + ;ld c,64 + ;ld hl,fadeError + ;ld de,fadeCurRGB +; +;.fadeInner + ;ld a,[de] ;red component + ;call .addDeltaToError + ;ld [de],a + ;inc de +; + ;ld a,[de] ;green component + ;call .addDeltaToError + ;ld [de],a + ;inc de + + ;ld a,[de] ;blue component + ;call .addDeltaToError + ;ld [de],a + ;inc de + ;;dec c + ;jr nz,.fadeInner + + ;copy RGB palette to 15-bit palette + ;ld a,64 + ;ld bc,0 + ;ld hl,fadeCurRGB + ;ld de,fadeCurPalette +;.RGBtoCur + ;push af + ;ld a,[hl+] + ;call SetRedComponent + ;ld a,[hl+] + ;call SetGreenComponent + ;ld a,[hl+] + ;call SetBlueComponent + ;ld a,c + ;ld [de],a + ;inc de + ;ld a,b + ;ld [de],a + ;inc de + ;pop af + ;dec a + ;jr nz,.RGBtoCur + + + ld a,[fadeRange] + ld hl,fadeError + ld de,fadeCurPalette + +.fadeInner + push af + + ;get current color in bc, though keep de where it was + call FadeCommonGetColor + dec de + dec de + + call GetRedComponent + call .addDeltaToError + call SetRedComponent ;store component + + call GetGreenComponent + call .addDeltaToError + call SetGreenComponent ;store component + + call GetBlueComponent + call .addDeltaToError + call SetBlueComponent ;store component + + ;store back in cur table + ld a,c + ld [de],a + inc de + ld a,b + ld [de],a + inc de + + pop af + dec a + jr nz,.fadeInner + +.install + ;make mapColor the current color 0 + ld de,mapColor + ld hl,fadeCurPalette + ld a,[hl+] + ld [de],a + inc de + ld a,[hl+] + ld [de],a + + ;install the current palette on the next VBlank + ld a,1 + ldio [paletteBufferReady],a + + pop hl + pop de + pop bc + ret + + +.lastFade + ;finally copy actual palette + ld hl,fadeFinalPalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ld a,64 + ld [fadeRange],a + + xor a + ld [specialFX],a + jr .install + +.addDeltaToError + ;accepts: a - color value + ;returns: a - new color value + push bc + push af + + ld a,[fadeSteps] + ld b,a + cpl + add 1 + ld c,a + + push hl + push de + ld de,$ff40 ;-192 + add hl,de + pop de + + ld a,[hl] + pop hl + + bit 7,a ;negative? + jr nz,.negative + +.positive + add a,[hl] + cp b + jr c,.done + + ;>=32 + ld c,0 +.while_pos_ge_32 + sub b + inc c + cp b + jr nc,.while_pos_ge_32 + + ld [hl+],a + pop af + add c + pop bc + ret + +.negative + add a,[hl] + cp c + jr nc,.done + + ;<= -32 + ld b,0 +.while_neg_le_n32 + sub c + inc b + cp c + jr c,.while_neg_le_n32 + ld [hl+],a + pop af + sub b + pop bc + ret + +.done + ld [hl+],a + pop af + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetColor0AllPalettes +; Arguments: bc - color to set to +; hl - ptr to start of palettes +; Alters: af +;--------------------------------------------------------------------- +SetColor0AllPalettes:: + push de + push hl + + ld d,16 +.loop ld a,c + ld [hl+],a + ld a,b + ld [hl+],a + ld a,l + add 6 + ld l,a + dec d + jr nz,.loop + + pop hl + pop de + ret + + +;--------------------------------------------------------------------- +; Routine: SetColors123AllPalettes +; Arguments: bc - color to set to +; hl - ptr to start of palettes +; Alters: af +;--------------------------------------------------------------------- +SetColors123AllPalettes:: + push de + push hl + + ld d,16 +.loop + inc hl + inc hl + ld e,3 +.inner + ld a,c + ld [hl+],a + ld a,b + ld [hl+],a + dec e + jr nz,.inner + + dec d + jr nz,.loop + + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: LighteningOut +; Alters: af +;--------------------------------------------------------------------- +LighteningOut:: + push bc + push de + push hl + + ld a,FADEBANK + ld [$ff70],a + + ;white background + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeCurPalette + ld bc,$7fff + call SetColor0AllPalettes + ld a,128 + ldio [paletteBufferReady],a + + ld c,3 + call .pause + + ld bc,0 + ld hl,fadeCurPalette + call SetColors123AllPalettes + + ld a,128 + ldio [paletteBufferReady],a + + ld c,7 + call .pause + + pop hl + pop de + pop bc + ret + +.pause call VWait + dec c + jr nz,.pause + ret + +;--------------------------------------------------------------------- +; Routine: LighteningIn +; Alters: af +;--------------------------------------------------------------------- +LighteningIn:: + push bc + push de + push hl + + ld a,FADEBANK + ld [$ff70],a + + ;black fg on white background + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeCurPalette + ld bc,$7fff + call SetColor0AllPalettes + ld bc,0 + call SetColors123AllPalettes + + ld a,128 + ldio [paletteBufferReady],a + + ld c,7 + call .pause + + ;normal fg on white background + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeCurPalette + ld bc,$7fff + call SetColor0AllPalettes + + ld a,128 + ldio [paletteBufferReady],a + + ld c,3 + call .pause + + ;normal + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld a,128 + ldio [paletteBufferReady],a + + pop hl + pop de + pop bc + ret + +.pause call VWait + dec c + jr nz,.pause + ret + +;--------------------------------------------------------------------- +; Routines: GetRedComponent +; GetGreenComponent +; GetBlueComponent +; SetRedComponent +; SetGreenComponent +; SetBlueComponent +; Arguments: Get: bc - 15 bit BGR value +; Set: bc - 15 bit BGR value, a - value to set +; Returns: Get: a - color component +; Alters: af, bc +;--------------------------------------------------------------------- +GetRedComponent:: + ld a,c + and %00011111 + ret + +GetGreenComponent:: + push de + ld a,b +IF 1 + ld e,c + sla e + rla + sla e + rla + sla e + rla + and %00011111 + pop de + ret +ENDC + +IF 0 + ld e,c + sla e + rl d + sla e + rl d + sla e + rl d + ld a,d + and %00011111 + pop de + ret +ENDC + +GetBlueComponent:: + ld a,b + rrca + rrca + and %00011111 + ret + +SetRedComponent:: + push af + ld a,c + and %11100000 + ld c,a + pop af + or c + ld c,a + ret + +SetGreenComponent:: + push de + ld d,a + rrca + rrca + rrca + and %00000011 + ld e,a + + ld a,b + and %01111100 + or e + ld b,a + + ld a,d + swap a + rlca + and %11100000 + ld d,a + + ld a,c + and %00011111 + or d + ld c,a + + pop de + ret + +SetBlueComponent:: + push af + ld a,b + and %00000011 + ld b,a + pop af + rlca + rlca + or b + ld b,a + ret + +;--------------------------------------------------------------------- +; Routine: PlaySound +; Arguments: hl - addr of table 1st byte of which indicates sound +; type (1-4) and remainder is data specific to that +; type. +; Alters: af, hl +;--------------------------------------------------------------------- +PlaySound:: + ld a,[hl+] + cp 1 + jr nz,.check2 + + xor a + ld [musicOverride1],a + call PlaySoundChannel1 + ld a,3 + ld [musicOverride1],a + ret +.check2 + cp 2 + jr nz,.check4 + call PlaySoundChannel2 + ret +.check4 + cp 4 + jr nz,.done + + xor a + ld [musicOverride4],a + call PlaySoundChannel4 + ld a,3 + ld [musicOverride4],a + ret + +.done + ret + +;--------------------------------------------------------------------- +; Routine: PlaySoundChannel1 +; Arguments: hl - addr of 5 sound bytes for sweep, duty/len, +; envelope, freq_lo, and freq_high +; Alters: af, hl +;--------------------------------------------------------------------- +PlaySoundChannel1:: + ld a,[musicOverride1] + or a + ret nz + +.playSound + ld a,[hl+] + ldio [$ff10],a + ld a,[hl+] + ldio [$ff11],a + ld a,[hl+] + ldio [$ff12],a + ld a,[hl+] + ldio [$ff13],a + ld a,[hl+] + ldio [$ff14],a + ret + +;--------------------------------------------------------------------- +; Routine: PlaySoundChannel2 +; Arguments: hl - addr of 4 sound bytes for duty/len, +; envelope, freq_lo, and freq_high +; Alters: af, hl +;--------------------------------------------------------------------- +PlaySoundChannel2:: + ld a,[hl+] + ldio [$ff16],a + ld a,[hl+] + ldio [$ff17],a + ld a,[hl+] + ldio [$ff18],a + ld a,[hl+] + ldio [$ff19],a + ret + +;--------------------------------------------------------------------- +; Routine: PlaySoundChannel3 +; Arguments: hl - addr of 4 sound bytes channel 4 +; Alters: af, hl +;--------------------------------------------------------------------- +PlaySoundChannel3:: + ld a,$80 + ldio [$ff1a],a + ld a,[hl+] + ldio [$ff1b],a + ld a,[hl+] + ldio [$ff1c],a + ld a,[hl+] + ldio [$ff1d],a + ld a,[hl+] + ldio [$ff1e],a + ret + +;--------------------------------------------------------------------- +; Routine: PlaySoundChannel4 +; Arguments: hl - addr of 4 sound bytes for length, envelope, +; frequency, and consecutive +; Alters: af, hl +;--------------------------------------------------------------------- +PlaySoundChannel4:: + ld a,[musicOverride4] + or a + ret nz + +.playSound + ld a,[hl+] + ldio [$ff20],a + ld a,[hl+] + ldio [$ff21],a + ld a,[hl+] + ldio [$ff22],a + ld a,[hl+] + ldio [$ff23],a + ret + +;--------------------------------------------------------------------- +; Routine: WaitInput +; Arguments: a - button mask [7:4] buttons, [3:0] dpad +; Alters: af +;--------------------------------------------------------------------- +WaitInput:: + push bc + push de + ld b,a +.wait + push bc + push hl + call UpdateObjects + call RedrawMap + pop hl + pop bc + ld h,((curJoy0>>8) & $ff) + ld a,[dialogJoyIndex] + add (curJoy0 & $ff) + ld l,a + ld a,[hl] + and b + jr z,.wait + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: WaitInputZero +; Arguments: a - button mask [7:4] buttons, [3:0] dpad +; hl - address of joystick button code to check +; Alters: af +;--------------------------------------------------------------------- +WaitInputZero:: + push bc + push de + ld b,a +.wait + push bc + push hl + call UpdateObjects + call RedrawMap + pop hl + pop bc + ld a,[hl] + and b + jr nz,.wait + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: WaitInputClick +; Arguments: a - button mask [7:4] buttons, [3:0] dpad +; Alters: af +; Description: WaitInputZero +; WaitInput +; WaitInputZero +;--------------------------------------------------------------------- +WaitInputClick:: + push bc + push hl + + ld b,a + ld hl,myJoy + call WaitInputZero + ld a,b + call WaitInput + ld a,b + call WaitInputZero + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ResetSprites +; Arguments: none +; Alters: af +; Description: Sets all spritesUsed flags to false and sets each +; sprite y position in the OAM buffer to zero. +;--------------------------------------------------------------------- +ResetSprites:: + push bc + push de + push hl + + ;clear sprites used table + ld a,TILEINDEXBANK + ld [$ff70],a + + ld hl,spritesUsed + xor a + ld c,40 +.clr2 ld [hl+],a + dec c + jr nz,.clr2 + + ;clear sprites + ld hl,spriteOAMBuffer + ld c,40 + ld de,3 +.clr3 + ld [hl+],a + add hl,de + dec c + jr nz,.clr3 + + xor a + ld [oamFindPos],a + ld a,40 + ld [numFreeSprites],a + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: AllocateSprite +; Arguments: none +; Returns: a - 00-9C=success (lowptr), ff=failure +; Alters: af +; Description: Loops through spritesUsed flag table, finds a free +; sprite, and returns that sprite's loPtr. +;--------------------------------------------------------------------- +AllocateSprite:: + ;any free sprites? + ld a,[numFreeSprites] + or a + jr nz,.freeSpriteExists + + ld a,$ff + ret + +.freeSpriteExists + push bc + push de + push hl + + dec a + ld [numFreeSprites],a + + ;we know there's at least one free sprite so start at + ;the the search position (which is guaranteed to be + ;<= pos of first free) and loop till we find it + + ld a,TILEINDEXBANK + ld [$ff70],a + + ld h,((spritesUsed>>8)&$ff) + ld a,[oamFindPos] + ld l,a + +.loop ld a,[hl+] ;get sprite used flag + or a + jr nz,.loop ;not free + +.foundSprite + dec hl + ld a,1 ;mark sprite as used + ld [hl],a + + ld a,l ;return loptr in a + inc a + ld [oamFindPos],a + + ld a,l + + ;change 1-byte offset to 4-byte offset (loPtr) + rlca ;times 2 + rlca ;times 2 again + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FreeSprite +; Arguments: a - loptr to sprite +; Alters: af +; Description: Sets the sprite's YPOS to zero +; Flags the sprite as unused +; oamFindPos = min(thisPos, oamFindPos) +; numFreeSprites++ +;--------------------------------------------------------------------- +FreeSprite:: + ;if loptr is $ff then don't bother + cp $ff + ret z + + push hl + + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + + xor a + ld [hl],a ;ypos to zero + + ld a,TILEINDEXBANK + ld [$ff70],a + + rrc l ;convert loptr to sprite index + rrc l + ld h,((spritesUsed>>8) & $ff) + + xor a + ld [hl],a ;clear sprite used flag + + ;set find pos to be mininum + ld a,[oamFindPos] + cp l + jr c,.findPosIsMin + + ld a,l + ld [oamFindPos],a + +.findPosIsMin + ;add one to # of free sprites + ld hl,numFreeSprites + inc [hl] + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: CreateMetaSprite +; Arguments: +; bc - width (b) and height (c) of metasprite, in 8x8 +; tiles. +; d - initial pattern number for first sprite. +; e - default attributes for each sprite. +; hl - ptr to location to store metasprite info. Should +; be w*h + 1 in size. +; [metaSprite_x], [metaSprite_y] - location of TL corner +; Alters: af +;--------------------------------------------------------------------- +CreateMetaSprite:: + push bc + push de + push hl + + ld a,[metaSprite_x] + ld [metaSprite_first_x],a + + ;calculate width times height + push bc + xor a +.calcTotalSize + add a,b + dec c + jr nz,.calcTotalSize + pop bc + + ;store total sprites used in metaSpriteInfo + ld [hl+],a + + ;go through and allocate each sprite, set it up, and store its + ;loptr in the metaSpriteInfo + push bc +.height pop af ;setup width from original value + push af + ld b,a + ld a,[metaSprite_first_x] + ld [metaSprite_x],a + +.width call AllocateSprite + ld [hl+],a ;save loptr + + ;set up sprite + push hl + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,[metaSprite_y] + ld [hl+],a + ld a,[metaSprite_x] + ld [hl+],a + add 8 + ld [metaSprite_x],a + ld a,d ;pattern number + ld [hl+],a + inc d + ld [hl],e ;attributes + pop hl + + dec b + jr nz,.width + + ld a,[metaSprite_y] + add 8 + ld [metaSprite_y],a + dec c + jr nz,.height + +.done + pop bc + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CreateMetaSpriteUsingMask +; Arguments: +; bc - width (b) and height (c) of metasprite, in 8x8 +; tiles. +; d - initial pattern number for first sprite. +; e - default attributes for each sprite. +; hl - ptr to location to store metasprite info. Should +; be w*h + 1 in size and location 1+ should contain +; a zero if its corresponding sprite is not to +; be allocated after all. +; [metaSprite_x], [metaSprite_y] - location of TL corner +; Alters: af +;--------------------------------------------------------------------- +CreateMetaSpriteUsingMask:: + push bc + push de + push hl + + ld a,[metaSprite_x] + ld [metaSprite_first_x],a + + ;calculate width times height + push bc + xor a +.calcTotalSize + add a,b + dec c + jr nz,.calcTotalSize + pop bc + + ;store total sprites used in metaSpriteInfo + ld [hl+],a + + ;go through and allocate each sprite marked with non-zero, + ;set it up, and store its loptr in the metaSpriteInfo + push bc +.height pop af ;setup width from original value + push af + ld b,a + ld a,[metaSprite_first_x] + ld [metaSprite_x],a + +.width ld a,[hl] ;load flag from destination + or a + ld a,$ff + jr z,.afterAllocate + call AllocateSprite + +.afterAllocate + ld [hl+],a ;save loptr + + cp $ff + jr z,.afterSetup + + ;set up sprite + push hl + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,[metaSprite_y] + ld [hl+],a + ld a,[metaSprite_x] + ld [hl+],a + ld a,d ;pattern number + ld [hl+],a + ld [hl],e ;attributes + pop hl + +.afterSetup + ld a,[metaSprite_x] + add 8 + ld [metaSprite_x],a + inc d + dec b + jr nz,.width + + ld a,[metaSprite_y] + add 8 + ld [metaSprite_y],a + dec c + jr nz,.height + +.done + pop bc + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ScrollMetaSprite +; Arguments: bc - x (b) and y (c) offset to scroll each sprite. +; hl - ptr to metaSpriteInfo created with +; CreateMetaSprite +; Alters: af +;--------------------------------------------------------------------- +ScrollMetaSprite:: + push de + + ld a,[hl+] ;number of sprites +.loop + push af + ld a,[hl+] ;loptr to sprite + ld e,a + ld d,((spriteOAMBuffer>>8) & $ff) + + ld a,[de] ;get the y position + add c ;add y offset + ld [de],a + inc de + ld a,[de] ;get the x position + add b ;add x offset + ld [de],a + inc de + + pop af + dec a + jr nz,.loop + pop de + ret + +;--------------------------------------------------------------------- +; Routine: SetMetaSpritePos +; Arguments: bc - desired x (b) and y (c) pixel position in sprite +; coords +; hl - ptr to metaSpriteInfo created with +; CreateMetaSprite +; Alters: af +;--------------------------------------------------------------------- +SetMetaSpritePos:: + push bc + + push hl + + inc hl ;go to y pos of first sprite + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + + ld a,c ;desired y pos + sub [hl] + ld c,a ;becomes offset to scroll + + inc hl + ld a,b + sub [hl] + ld b,a ;becomes offset to scroll + + pop hl + + call ScrollMetaSprite + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FreeMetaSprite +; Arguments: hl - ptr to metaSpriteInfo created with +; CreateMetaSprite +; Alters: af +;--------------------------------------------------------------------- +FreeMetaSprite:: + push bc + push hl + + ld a,[hl+] ;number of sprites + ld c,a + +.freeASprite + ld a,[hl+] ;get loptr + call FreeSprite + dec c + jr nz,.freeASprite + + pop hl + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: CreateBigExplosion +; Arguments: bc - tile width and height of explosion area +; d - max sprites (must be >0) +; e - flags for allowed explosion types: +; :0 - small round explosions +; :1 - shrapnel plus +; :2 - big (2x2) round explosions (4 sprites ea) +; hl - TL map corner (e.g. $d0ca) of explosion +; [bulletColor] +; Returns: Nothing. +; Alters: af +; Description: Creates a big explosion of randomly dispersed smaller +; explosions within the given area. +; +;--------------------------------------------------------------------- +CreateBigExplosion:: + push bc + push de + push hl + + ;limit the number of sprites according to the system's + ;resources + ld a,[numFreeSprites] + cp d + jr nc,.numSpritesOkay + ld d,a +.numSpritesOkay + or a + jr nz,.continue + jp .done +.continue + call ConvertLocHLToXY + ld a,[bulletColor] + +.loop ;limit myself to smaller explosions if I have less than 4 + ;sprites left + push af + push hl + + ld a,d + cp 4 + jr nc,.afterLimitToSmaller + res 2,e ;remove larger fr possible explosions flags + ld a,e + or a + jr nz,.afterLimitToSmaller + ld d,1 + jr .afterCreateExplosion +.afterLimitToSmaller + + ;select random tile position within area + + ;width + ld a,b + dec a + call GetRandomNumZeroToN + add h + ld h,a + + ;height + ld a,c + dec a + call GetRandomNumZeroToN + add l + ld l,a + + call ConvertXYToLocHL + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + + ;choose random explosion + ld a,e + call GetRandomNumMask + bit 2,a + jr z,.checkType1 + +.isType2 + bit 2,e ;this type allowed? + jr z,.isType0 + ;type two - big 2x2 explosion + ld a,6 + ld [bulletColor],a + + push bc + ld b,32 + call .create2x2Frame + inc hl + call .create2x2Frame + push de + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + pop de + dec hl + call .create2x2Frame + inc hl + call .create2x2Frame + pop bc + + dec d + dec d + dec d + jr .afterCreateExplosion + +.checkType1 + bit 1,a + jr z,.isType0 + +.isType1 + bit 1,e ;this type allowed? + jr z,.isType2 + ;type one - shrapnel + ld a,64 + jr .determinedFrame + +.isType0 ;default + bit 0,e ;this type allowed? + jr z,.isType1 + ;type zero - small round explosion + ld a,5 + ld [bulletColor],a + ld a,16 + +.determinedFrame + push bc + ld b,a + call CreateExplosion + call .offsetSprite + pop bc + +.afterCreateExplosion + pop hl +.beforeRestoreColor + pop af + ld [bulletColor],a + + dec d + jr z,.done + jp .loop + +.done + pop hl + pop de + pop bc + ret + +.offsetSprite + or a + ret z + push de + push hl + call IndexToPointerHL ;get ptr to explosion class + ld a,OBJBANK + ldio [$ff70],a + ld de,OBJ_SPRITELO + add hl,de + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,%111 + call GetRandomNumMask + add [hl] + ld [hl+],a + ld a,%111 + call GetRandomNumMask + add [hl] + ld [hl],a + pop hl + pop de + ret + +.create2x2Frame + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + call CreateExplosion + ld a,b + add 8 + ld b,a + ret + +;--------------------------------------------------------------------- +; Routine: BlitMap +; Arguments: bc - tile width and height of area to copy +; de - destination XY coords +; hl - source XY coords +; Returns: Nothing. +; Alters: af +; Description: Copies a section of the current map, not overwriting +; any objects +;--------------------------------------------------------------------- +BlitMap:: + push bc + push de + push hl + + push hl + ld h,d + ld l,e + call ConvertXYToLocHL + ld d,h + ld e,l + pop hl + call ConvertXYToLocHL + ld a,MAPBANK + ldio [$ff70],a + +.blitMapOuter + push bc + push de + push hl + ldio a,[firstMonster] + ld c,a + +.blitMapInner + ld a,[de] + cp c ;< first monster? + jr nc,.blitSkip + + ld a,[hl] + ld [de],a +.blitSkip + inc hl + inc de + dec b + jr nz,.blitMapInner + + pop hl + pop de + push hl + ld a,[mapPitch] + ld h,0 + ld l,a + add hl,de + ld d,h + ld e,l + pop hl + ld a,[mapPitch] + ld b,0 + ld c,a + add hl,bc + + pop bc + dec c + jr nz,.blitMapOuter + + pop hl + pop de + pop bc + + ret + +;--------------------------------------------------------------------- +; Routine: ConvertLocHLToXY +; Arguments: hl - location ($D000-$DFFF) +; Returns: hl - h = x index, l = y index +; Alters: a,hl +; Description: x = location & (pitch-1) +; y = (location - $D000) / pitch +;--------------------------------------------------------------------- +ConvertLocHLToXY:: + ld a,[mapPitchMinusOne] + and l + push af ;push a (x index) on stack + + ld a,h ;subtract $D000 from hl by adding $3000 + add $30 + ld h,a + ld a,[mapPitchMinusOneComplement] ;times to left-shift +.shift rlca ;shift a bit left out of a + jr nc,.shiftDone ;hl<<=1 if bits left in a + sla l + rl h + jr .shift + +.shiftDone + ld l,h + pop af + ld h,a ;h = x index, l = y index + + ret + +;--------------------------------------------------------------------- +; Routine: ConvertXYToLocHL +; Arguments: hl - h = x index, l = y index +; Returns: hl - location ptr ($D000-$DFFF) +; Alters: a,hl +; Description: hl = $d000 + (y * pitch) + x +; Instead of having y in the LoByte and left-shifting it +; by the bits in the pitch, we'll put y in the HiByte +; and right-shift it by 8-bitsInPitch. Fewer ops. +;--------------------------------------------------------------------- +ConvertXYToLocHL:: + push de + + ;multiply y*pitch + ld a,[mapPitchMinusOneComplement] + ld d,l + ld e,0 + +.shift rlca ;if bits left in A then keep shifting + jr nc,.shiftDone + srl d + rr e + jr .shift + +.shiftDone + ld l,h ;add x + $d000 + ld h,$d0 + add hl,de + + pop de + ret + +;--------------------------------------------------------------------- +; Routine: LCheckGetVectorToState +; Arguments: hl - address of method table +; Returns: hl - methodTable[mapState] +; Alters: af,hl +; Description: Use the VECTORTOSTATE macro. +;--------------------------------------------------------------------- +LCheckGetVectorToState:: + push de + ldio a,[mapState] + ld d,0 + ld e,a + sla e + rl d + add hl,de + pop de + ld a,[hl+] + ld h,[hl] + ld l,a + ret + +;--------------------------------------------------------------------- +; Routine: SaveIdle +; Arguments: None. +; Returns: +; Alters: af,hl +; Description: Saves the current state of [heroesIdle] and [allIdle] +; in [dialogIdleSettings] and activates both idle +; settings +;--------------------------------------------------------------------- +SaveIdle:: + ld a,[heroesIdle] + rlca + ld hl,allIdle + or [hl] + ld [dialogIdleSettings],a + + ld a,1 + ld [heroesIdle],a + ld [allIdle],a + ret + +;--------------------------------------------------------------------- +; Routine: RestoreIdle +; Arguments: None. +; Returns: +; Alters: af,hl +; Description: Restores the idle settings to what they were previous +; to SaveIdle +;--------------------------------------------------------------------- +RestoreIdle:: + ld a,[dialogIdleSettings] + push af + and 1 + ld [allIdle],a + pop af + srl a + ld [heroesIdle],a + ret + +;--------------------------------------------------------------------- +; Routine: MakeIdle +; Arguments: None. +; Returns: +; Alters: af +; Description: Sets [heroesIdle] and [allIdle] to 1 +;--------------------------------------------------------------------- +MakeIdle:: + ld a,1 + ld [heroesIdle],a + ld [allIdle],a + ret + +;--------------------------------------------------------------------- +; Routine: MakeNonIdle +; Arguments: None. +; Returns: +; Alters: af +; Description: Sets [heroesIdle] and [allIdle] to 0 +;--------------------------------------------------------------------- +MakeNonIdle:: + xor a + ld [heroesIdle],a + ld [allIdle],a + ret + +;--------------------------------------------------------------------- +; Routine: UseAlternatePalette +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Darkens colors 1 & 2 of each palette, intended for +; use on the light-background maps. +;--------------------------------------------------------------------- +UseAlternatePalette:: + push bc + push hl + + ld a,FADEBANK + ldio [$ff70],a + + ld c,16 + ld hl,gamePalette+2 +.loop call .halve + call .halve + inc hl + inc hl + inc hl + inc hl + dec c + jr nz,.loop + + pop hl + pop bc + ret + +.halve + ld a,[hl+] ;color[i]>>=1; + ld b,a + ld a,[hl] + rrca + rr b + and %00111101 + ld [hl-],a + ld a,b + and %11101111 + ld [hl+],a + inc hl + ret + +;--------------------------------------------------------------------- +; Routine: GetMyHero +; Arguments: None. +; Returns: a - class index of local hero (i.e. not remote) +; hl - pointer to hero0_data or hero1_data approprately +; Alters: af, hl +;--------------------------------------------------------------------- +GetMyHero:: + ld a,[amLinkMaster] + cp 0 + jr z,.getHero1 + + ;get hero zero if link master + ld a,[hero0_index] + ld hl,hero0_data + ret + +.getHero1 + ld a,[hero1_index] + ld hl,hero1_data + ret + +;--------------------------------------------------------------------- +; Routine: GetBGAttributes +; Arguments: a - class index +; Alters: af +; Returns: a - attributes for given class index +; Returns full set off attributes including: +; [2:0] - color FLAG_PALETTE +; [3] - can walk over FLAG_WALKOVER +; [4] - can shoot over FLAG_SHOOTOVER +;--------------------------------------------------------------------- +GetBGAttributes:: + push hl + ld l,a + ld h,((bgAttributes>>8) & $ff) + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,[hl] + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: UpdateDialogBalloons +; Arguments: de - intial pos in [spritesUsed] +; hl - initial pos in spriteOAMBuffer +; Alters: af, de, hl +;--------------------------------------------------------------------- +UpdateDialogBalloons:: + ld a,[amShowingDialog] + or a + ret nz ;no balloons during dialog + + ldio a,[updateTimer] + and %00010000 + ret z ;all blank + + push bc + call FindNextFreeSprite + jr z,.done + ld a,[dialogBalloonClassIndex] + ld c,a + call GetFirst +.setNextBalloon + or a + jr z,.done + + call PutBalloonAboveObject + + ;remake de from hl + push de + inc hl + inc hl + inc hl + inc hl + call .remakeDEfromHL + call FindNextFreeSprite + pop de + jr z,.done + + call GetNextObject + jr .setNextBalloon + +.done + call .remakeDEfromHL + pop bc + ret + +.remakeDEfromHL + ld a,l ;e = l/4 + rrca + rrca + ld e,a + ld d,((spritesUsed>>8)&$ff) + ret + +;--------------------------------------------------------------------- +; Routine: DisableDialogBalloons +; Arguments: a - mask of objects (up to 8) to disable. %101 +; would disable the first and third speakers, etc. +; Speakers after the eigth are disabled. +; Alters: af +;--------------------------------------------------------------------- +DisableDialogBalloons:: + push bc + push de + push hl + + ld b,a + + ld a,[dialogBalloonClassIndex] + or a + jr z,.done + + ld c,a + call GetFirst +.disableNext + or a + jr z,.done + + ld a,b + or a + jr z,.disableAfter8 + + and 1 + jr z,.continue + + ld a,1 + call SetMisc + +.continue + srl b + call GetNextObject + jr .disableNext + +.disableAfter8 + ld b,8 + ld a,[dialogBalloonClassIndex] + ld c,a + call GetFirst +.find9th + or a + jr z,.done + + call GetNextObject + dec b + jr nz,.find9th + +.disableAfter8Next + or a + jr z,.done + + ld a,1 + call SetMisc + + call GetNextObject + jr .disableAfter8Next + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindNextFreeSprite +; Arguments: de - ptr to position within spritesUsed to begin +; resetting +; hl - ptr to sprite OAM buffer corresponding to +; de +; Alters: af,de,hl +; Returns: a - 0 on failure +;--------------------------------------------------------------------- +FindNextFreeSprite: + ld a,e + cp 40 + jr nc,.notFound + + push bc + ld a,TILEINDEXBANK + ldio [$ff70],a + ld bc,4 + +.checkNext + ld a,[de] + or a + jr z,.foundIt + + inc de + add hl,bc + ld a,e + cp 40 + jr c,.checkNext + + pop bc +.notFound + xor a + ret + +.foundIt + ld a,1 + or a + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: PutBalloonAboveObject +; Arguments: de - ptr to object +; hl - ptr to sprite OAM buffer +; Alters: af +;--------------------------------------------------------------------- +PutBalloonAboveObject: + push de + push hl + + ld [hl],0 ;zero sprite in case we don't use it + push hl + call GetMisc + pop hl + or a + jr nz,.done ;already spoke + call GetCurLocation + call ConvertLocHLToSpriteCoords + ld d,h + ld e,l + pop hl + push hl + ld a,e + or a + jr z,.afterAdjustCoords ;leave zero at zero + + sub 8 + ld e,a + ld a,d + add 8 + ld d,a + +.afterAdjustCoords + ld [hl],e ;y coord + inc hl + ld [hl],d ;x coord + inc hl + ld a,80 ;pattern number + ld [hl+],a + xor a + ld [hl],a ;palette/etc +.done + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: ResetFreeSprites +; Arguments: de - ptr to position within spritesUsed to begin +; resetting +; hl - ptr to sprite OAM buffer corresponding to +; de +; Alters: af,de,hl +; Returns: Nothing. +; Description: Sets y=0 of all sprites after initial position not +; flagged as in use; necessary for resetting +; environmental effects +;--------------------------------------------------------------------- +ResetFreeSprites:: + ld a,e + cp 40 + ret nc + + push bc + + ld a,TILEINDEXBANK + ldio [$ff70],a + ld bc,4 + +.resetNext + ld a,[de] + or a + jr nz,.afterReset + + ld [hl],a ;ypos = 0 + +.afterReset + add hl,bc + inc de + ld a,e + cp 40 + jr c,.resetNext + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetEnvEffect +; Arguments: a - env effect such as ENV_RAIN +; Alters: af +; Returns: Nothing. +; Description: Sets an environmental effect and quickly updates it +; a number of times to be in full swing by the time +; the player sees it +;--------------------------------------------------------------------- +SetEnvEffect:: + push bc + ld [envEffectType],a + + ld c,16 +.updateEffect + call UpdateEnvEffect + dec c + jr nz,.updateEffect + + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: UpdateEnvEffect +; Arguments: None. +; Alters: af +; Returns: Nothing. +; Description: Sets unused sprites to be dialog/rain/snow etc based +; on [envEffectType]. Calls UpdateDialogBalloons and +; ResetFreeSprites +;--------------------------------------------------------------------- +UpdateEnvEffect:: + push bc + push de + push hl + + ld de,spritesUsed + ld hl,spriteOAMBuffer + + ld c,0 + + ld a,[dialogBalloonClassIndex] + or a + jr z,.afterUpdateBalloons + + inc c + call nz,UpdateDialogBalloons + +.afterUpdateBalloons + ld a,[envEffectType] + or a + jr z,.afterEffect + + ldio a,[randomLoc] + push af + ld a,[asyncRandLoc] + ldio [randomLoc],a + ld a,[envEffectType] + call .updateAppropriate + ldio a,[randomLoc] + ldio [asyncRandLoc],a + pop af + ldio [randomLoc],a + +.afterEffect + call ResetFreeSprites + + pop hl + pop de + pop bc + ret + +.updateAppropriate + inc c + + cp ENV_RAIN + jr nz,.checkSnow + + ld d,e + LONGCALLNOARGS EnvRain + ret + +.checkSnow + cp ENV_SNOW + jr nz,.checkDirt + + ld d,e + LONGCALLNOARGS EnvSnow + ret + +.checkDirt + cp ENV_DIRT + jr nz,.checkClouds + + ld d,e + LONGCALLNOARGS EnvDirt + ret + +.checkClouds + cp ENV_CLOUDS + jr nz,.checkWindySnow + + ld d,e + LONGCALLNOARGS EnvClouds + ret + +.checkWindySnow + cp ENV_WINDYSNOW + jr nz,.checkCounter + + ld d,e + LONGCALLNOARGS EnvWindySnow + ret + +.checkCounter + cp ENV_COUNTER + jr nz,.checkDisco + + ;reset first two sprites to y=16 + ld hl,spriteOAMBuffer + ld de,4 + ld [hl],16 + add hl,de + ld [hl],16 + ret + +.checkDisco + cp ENV_DISCO + ret nz + + LONGCALLNOARGS EnvDisco + ret + +;--------------------------------------------------------------------- +SECTION "GfxSupport",ROMX +;--------------------------------------------------------------------- +EnvRain: + call EnvSetupDEHL + ld b,0 +.nextDrop + call FindNextFreeSprite + ret z + + inc b + + ld a,[hl] + or a + jr nz,.updatePosition + +.newDrop + ;create new raindrop + ld a,63 + call GetRandomNumMask + cpl + add 16 + ld [hl+],a ;ypos + + ld a,255 + call GetRandomNumMask + ;add 8 + ;ld [hl],a + ;ld a,63 + ;call GetRandomNumMask + ;add [hl] + ;sub 64 + ld [hl+],a ;xpos + + ld [hl],81 ;pattern + inc hl + ld [hl],2 ;palette + inc hl + inc de + jr .nextDrop + +.updatePosition + ld a,[hl] + add 8 + ld [hl],a + and 184 + cp 184 + jr nz,.afterRemove + +.remove + ld [hl],0 +.afterRemove + inc hl + ld a,[hl] + add 4 + ld [hl+],a + ld a,[hl+] + cp 81 ;rain pattern + jr z,.dropOkay + + ;change into a rain sprite + dec hl + ld [hl],81 + inc hl + ld [hl],2 + + ;push hl + ;dec hl + ;dec hl + ;ld [hl],0 ;reset sprite + ;pop hl + +.dropOkay + inc hl + inc de + jp .nextDrop + +EnvSnow: + call EnvSetupDEHL + ld b,0 +.nextFlake + call FindNextFreeSprite + ret z + + inc b + + ld a,[hl] + or a + jr nz,.updatePosition + +.newFlake + ;create new snowflake + ld a,63 + call GetRandomNumMask + cpl + add 16 + ld [hl+],a ;ypos + + ld a,255 + call GetRandomNumMask + ;add 8 + ;ld [hl],a + ;ld a,63 + ;call GetRandomNumMask + ;add [hl] + ;sub 10 + ld [hl+],a ;xpos + + ld [hl],74 ;pattern + inc hl + ld [hl],0 ;palette + inc hl + inc de + jr .nextFlake + +.updatePosition + ld a,[hl] + ;add 4 + inc a + ld [hl],a + and 184 + cp 184 + jr nz,.afterRemove + +.remove + ld [hl],0 +.afterRemove + ;get deltax offset for this flake mem loc + y loc + ld a,l + rrca + rrca + add [hl] ;plus y coord + and 63 + + push hl + add (flakeSineTable & $ff) + ld l,a + ld a,0 + adc ((flakeSineTable>>8)&$ff) + ld h,a + ld a,[hl] + pop hl + inc hl + add [hl] + ld [hl+],a ;new x coord + ld a,[hl+] + cp 74 ;flake pattern + jr z,.flakeOkay + + ;change into a snowflake sprite + dec hl + ld [hl],74 + inc hl + ld [hl],0 + + ;push hl + ;dec hl + ;dec hl + ;ld [hl],0 ;reset sprite + ;pop hl + +.flakeOkay + inc hl + inc de + jp .nextFlake + + +EnvDirt: + call EnvSetupDEHL + ld b,0 +.nextGrit + call FindNextFreeSprite + ret z + + inc b + + ld a,[hl] + or a + jr nz,.updatePosition + +.newGrit + ;create new sand + ld a,127 + call GetRandomNumMask + ld [hl],a ;ypos + ld a,31 + call GetRandomNumMask + add [hl] + sub 10 + ld [hl+],a + + ld a,63 + call GetRandomNumMask + cpl + add 8 + ld [hl+],a ;xpos + + ld [hl],72 ;pattern + inc hl + ld [hl],6 ;palette + inc hl + inc de + jr .nextGrit + +.updatePosition + ld a,l ;y += (-1,0,1,2) + rrca + rrca + and %11 + sub 1 + add [hl] + ld [hl+],a + + ld a,[hl] + add 8 + ld [hl+],a + and 184 + cp 184 + jr nz,.afterRemove + +.remove + push hl + dec hl + dec hl + ld [hl],0 + pop hl +.afterRemove + ld a,[hl+] + cp 72 ;grit pattern + jr z,.gritOkay + + push hl + dec hl + dec hl + dec hl + ld [hl],0 ;reset sprite + pop hl + +.gritOkay + inc hl + inc de + jp .nextGrit + +EnvWindySnow: + call EnvSetupDEHL + ld b,0 +.nextFlake + call FindNextFreeSprite + ret z + + inc b + + ld a,[hl] + or a + jr nz,.updatePosition + +.newFlake + ;create new flake + ld a,127 + call GetRandomNumMask + ld [hl],a ;ypos + ld a,31 + call GetRandomNumMask + add [hl] + sub 10 + ld [hl+],a + + ld a,63 + call GetRandomNumMask + cpl + add 168 + ld [hl+],a ;xpos + + ld [hl],74 ;pattern + inc hl + ld [hl],0 ;palette + inc hl + inc de + jr .nextFlake + +.updatePosition + ld a,l ;y += (-1,0,1,2) + rrca + rrca + and %11 + sub 1 + add [hl] + ld [hl+],a + + ld a,[hl] + sub 8 + ld [hl+],a + and 248 + cp 248 + jr nz,.afterRemove + +.remove + push hl + dec hl + dec hl + ld [hl],0 + pop hl +.afterRemove + ld a,[hl+] + cp 74 ;flake pattern + jr z,.flakeOkay + + ;change into a snowflake sprite + dec hl + ld [hl],74 + inc hl + ld [hl],0 + + ;push hl + ;dec hl + ;dec hl + ;dec hl + ;ld [hl],0 ;reset sprite + ;pop hl + +.flakeOkay + inc hl + inc de + jp .nextFlake + +EnvClouds: + call EnvSetupDEHL + ld b,0 +.nextCloud + call FindNextFreeSprite + ret z + + inc b + + ld a,[hl] + or a + jr nz,.updatePosition + + ld a,b + and %11 + jr nz,.addToCloud + + ;one in 8 chance of creating a cloud + ld a,1 + call GetRandomNumMask + or a + jr z,.newCloud + + inc hl + inc hl + inc hl + inc hl + inc de + jr .nextCloud + +.newCloud + ;create new cloud + ld a,144 + call GetRandomNumZeroToN + add 16 + ld [hl+],a ;ypos + ld [$c01e],a + + ld a,63 + call GetRandomNumMask + cpl + ld [hl+],a ;xpos + ld [$c01f],a + + ld a,3 + call GetRandomNumMask + add 82 + ld [hl+],a ;pattern + ld [hl],4 ;palette + inc hl + inc de + jr .nextCloud + +.addToCloud + push de + ld a,7 + call GetRandomNumMask + ld d,a + ld a,[$c01e] + add d + ld [hl+],a ;ypos + + ld a,7 + call GetRandomNumMask + ld d,a + ld a,[$c01f] + add d + ld [hl+],a ;xpos + + ld a,3 + call GetRandomNumMask + add 82 + ld [hl+],a ;pattern + ld [hl],4 ;palette + inc hl + pop de + inc de + jr .nextCloud + +.updatePosition + inc hl + ;bit 2,l + ;jr z,.updateOnTimer + jr .updateOnTimer + inc [hl] + jr .afterIncr +.updateOnTimer + ldio a,[updateTimer] + and 1 + jr z,.afterIncr + inc [hl] +.afterIncr + ld a,[hl] + cp 178 + jr nz,.afterRemove + + dec hl + ld [hl],0 + inc hl +.afterRemove + inc hl + inc hl + inc hl + inc de + jp .nextCloud + +EnvSetupDEHL: + ld d,((spritesUsed>>8)&$ff) + ld a,e + rlca + rlca + ld l,a + ld h,((spriteOAMBuffer>>8)&$ff) + ret + +flakeSineTable: + DB $ff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 + DB 0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0 + DB 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$ff + DB 0,0,$ff,0,0,$ff,0,0,$ff,0,$ff,0,0,$ff,0,0 + +;--------------------------------------------------------------------- +; EnvDisco +; Uses binary data "discoLights" to set all colors to purple in +; drawing buffer except where lights are flashing. Uses levelVars[0] +; to determine current frame +;--------------------------------------------------------------------- +EnvDisco: + push bc + push de + push hl + + ;setup hl to point to light data for appropriate frame + ld de,20*18 + ld hl,discoLights + ld a,[levelVars] + or a + jr z,.frameSet + +.times360 + add hl,de + dec a + jr nz,.times360 + +.frameSet + ld de,attributeBuffer + ld b,18 ;18 rows +.outer + ld c,20 ;20 columns +.inner + ld a,[hl+] + or a + jr nz,.afterSetColor + + ld a,[de] + or %111 + ld [de],a + +.afterSetColor + inc de + + dec c + jr nz,.inner + + push hl + ld hl,12 + add hl,de + ld d,h + ld e,l + pop hl + + dec b + jr nz,.outer + + pop hl + pop de + pop bc + ret + +discoLights: +INCBIN "Data/discolights.dat" + +;Not in HOME + +;--------------------------------------------------------------------- +SECTION "FontSection",ROMX,BANK[MAP0ROM],ALIGN[4] +fontData: + INCBIN "Data/font.bin" + +blankTileData: + DW 0,0,0,0,0,0,0,0 + +explosionSprites: +INCBIN "Data/Sprites/explosions0-85.bin" + +SECTION "ReservedSpriteDMAHandler",HRAM[$FF80] +SpriteDMAHandler:: + DS (oamHandlerFinish - oamHandlerStart) + +;--------------------------------------------------------------------- +SECTION "GfxSupportSection",ROMX[$4000] +;--------------------------------------------------------------------- +;$4000 +randomTable: +DB $9f,$d2,$e6,$e7,$70,$db,$11,$63,$6b,$37,$99,$98,$30,$9c,$d9,$35 +DB $65,$af,$56,$ee,$b1,$00,$fd,$c7,$61,$48,$df,$45,$2e,$41,$6d,$9b +DB $13,$40,$d8,$fa,$91,$02,$29,$e0,$cb,$5d,$28,$fb,$2f,$77,$ea,$f9 +DB $7e,$92,$5b,$75,$b5,$fc,$ae,$a2,$71,$cc,$a9,$3f,$7f,$7d,$ad,$7c +DB $73,$a5,$f8,$03,$9e,$25,$f6,$e8,$4d,$33,$b3,$44,$aa,$26,$08,$6e +DB $82,$97,$96,$19,$c8,$b4,$ba,$d3,$1f,$d0,$f5,$06,$54,$86,$49,$e2 +DB $69,$43,$0b,$b0,$f1,$83,$a8,$9d,$38,$42,$ef,$e4,$74,$12,$20,$a0 +DB $55,$01,$66,$23,$3d,$51,$c0,$79,$10,$de,$eb,$d5,$09,$8e,$5e,$67 +DB $4a,$7a,$3e,$4b,$68,$8d,$e9,$62,$1b,$dd,$da,$bb,$53,$22,$3c,$b6 +DB $ff,$81,$24,$8b,$d4,$6f,$d7,$9a,$d6,$21,$f4,$0a,$b2,$bc,$a7,$36 +DB $34,$64,$c5,$a6,$4e,$b9,$f3,$0e,$f0,$3b,$cd,$0d,$17,$ec,$1a,$8a +DB $e3,$16,$93,$05,$c9,$14,$c1,$cf,$52,$2c,$1e,$bf,$88,$27,$1d,$f7 +DB $5c,$ac,$ab,$3a,$bd,$a1,$f2,$04,$e5,$2d,$e1,$c2,$15,$fe,$8c,$6a +DB $2b,$84,$1c,$d1,$47,$c6,$58,$c3,$0f,$ce,$5f,$90,$8f,$76,$60,$0c +DB $94,$2a,$6c,$89,$39,$46,$18,$95,$7b,$dc,$b7,$72,$78,$5a,$57,$ca +DB $4f,$a4,$59,$07,$32,$c4,$ed,$b8,$50,$85,$a3,$31,$4c,$87,$80,$be + +;0=star 1=moon 2=flower 3=crouton 4=i 5=monkey 6=wrench 7=man +;$4100 +init_flightCodes: +DB $0f +DB $00,$00,$06 +DB $00,$00,$23 +DB $00,$00,$29 +DB $00,$00,$3a +DB $00,$00,$47 +DB $00,$00,$59 +DB $00,$00,$66 +DB $00,$00,$a3 +DB $00,$00,$a8 +DB $00,$00,$0a +DB $00,$00,$3d +DB $63,$02,$71 ;initial landing star flower wrench crouton +DB $33,$53,$81 ;mouse landing monkey crouton crouton crouton +DB $65,$70,$c7 ;farm landing man star wrench monkey +DB $12,$01,$55 ;palace star moon moon flower +DB $00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + + diff --git a/Source/Gfx.inc b/Source/Gfx.inc new file mode 100644 index 0000000..09c9397 --- /dev/null +++ b/Source/Gfx.inc @@ -0,0 +1,2 @@ +EXPORT select_hero_bg + diff --git a/Source/Items.inc b/Source/Items.inc new file mode 100644 index 0000000..a894a0a --- /dev/null +++ b/Source/Items.inc @@ -0,0 +1,37 @@ +;--------------------------------------------------------------------- +; Item & Flight Code Definitions +; 2001.02.12 by Abe Pralle +;--------------------------------------------------------------------- + +;items are defined as BYTE/BITMASK + +ITEM_SNAKEBITEKIT EQU $0001 +ITEM_SPOREMASK EQU $0002 +ITEM_CODE0400 EQU $0004 +ITEM_CODE0900 EQU $0008 +ITEM_CODE1002 EQU $0010 +ITEM_CODE1006 EQU $0020 +ITEM_CODE0410 EQU $0040 +ITEM_BATJUICE EQU $0080 +ITEM_SPACEMONEY EQU $0101 +ITEM_SPACESODA EQU $0102 +ITEM_HONEY EQU $0104 +ITEM_WRANGLING EQU $0108 +ITEM_BSSHOOTFAST EQU $0110 +ITEM_BUGSPRAY EQU $0120 +ITEM_BAHIGHIMPACT EQU $0140 +ITEM_CODE0307 EQU $0180 + +ITEM_ALPHACLEAR EQU $0201 +ITEM_BETACLEAR EQU $0202 +ITEM_GAMMACLEAR EQU $0204 +ITEM_DELTACLEAR EQU $0208 +ITEM_EPSILONCLEAR EQU $0210 +ITEM_ZETACLEAR EQU $0220 + +ITEM_APPXKEY EQU $0240 + +;bit numbers +UPGRADE_BSSHOOTFAST EQU 0 +UPGRADE_BAHIGHIMPACT EQU 0 + diff --git a/Source/Levels.inc b/Source/Levels.inc new file mode 100644 index 0000000..57dfeb3 --- /dev/null +++ b/Source/Levels.inc @@ -0,0 +1,6 @@ +LVLOFFSET_LOAD EQU 0 +LVLOFFSET_INIT EQU 2 +LVLOFFSET_CHECK EQU 4 +LVLOFFSET_MAP EQU 6 + + diff --git a/Source/Levels/L0000.asm b/Source/Levels/L0000.asm new file mode 100644 index 0000000..d271807 --- /dev/null +++ b/Source/Levels/L0000.asm @@ -0,0 +1,129 @@ +;L0000.asm hive +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +STATE_NORMAL EQU 1 +STATE_HONEYTAKEN EQU 2 + +;--------------------------------------------------------------------- +SECTION "LevelsSection0000",ROMX,BANK[MAP0ROM] +;--------------------------------------------------------------------- + +dialog: +L0000_hero_honey_gtx: + INCBIN "Data/Dialog/Talk/L0000_hero_honey.gtx" + +L0000_Contents:: + DW L0000_Load + DW L0000_Init + DW L0000_Check + DW L0000_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0000_Load: + DW ((L0000_LoadFinished - L0000_Load2)) ;size +L0000_Load2: + call ParseMap + ret + +L0000_LoadFinished: + +L0000_Map: +INCBIN "Data/Levels/L0000_hive.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0000_Init: +;--------------------------------------------------------------------- + DW ((L0000_InitFinished - L0000_Init2)) ;size +L0000_Init2: + call State0To1 + + STDSETUPDIALOG + + ldio a,[mapState] + cp STATE_HONEYTAKEN + jr nz,.done + + ;remove honey from map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d146],a + +.done + ret + +L0000_InitFinished: + + +;--------------------------------------------------------------------- +L0000_Check: +;--------------------------------------------------------------------- + DW ((L0000_CheckFinished - L0000_Check) - 2) ;size +L0000_Check2: + ldio a,[mapState] + cp STATE_HONEYTAKEN + jr z,.done + + xor a + ld hl,((.checkFoundHoney-L0000_Check2)+levelCheckRAM) + call CheckEachHero +.done + ret + +.checkFoundHoney + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.foundHoney + + xor a + ret + +.foundHoney + ;found honey + ld de,((.afterDialog-L0000_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0000_hero_honey_gtx + call ShowDialogAtBottom +.afterDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld bc,ITEM_HONEY + call AddInventoryItem + + ;remove honey from map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d146],a + + ld a,STATE_HONEYTAKEN + ldio [mapState],a + + ld a,1 + ret +L0000_CheckFinished: + + +PRINT " 0000 Level Check Size: " +PRINT (L0000_CheckFinished - L0000_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0001.asm b/Source/Levels/L0001.asm new file mode 100644 index 0000000..69e411a --- /dev/null +++ b/Source/Levels/L0001.asm @@ -0,0 +1,79 @@ +; L0001.asm outside the hive +; Generated 08.27.2000 by mlevel +; Modified 08.27.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 35 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0001Section",ROMX +;--------------------------------------------------------------------- + +L0001_Contents:: + DW L0001_Load + DW L0001_Init + DW L0001_Check + DW L0001_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0001_Load: + DW ((L0001_LoadFinished - L0001_Load2)) ;size +L0001_Load2: + call ParseMap + ret + +L0001_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0001_Map: +INCBIN "Data/Levels/L0001_bees.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0001_Init: + DW ((L0001_InitFinished - L0001_Init2)) ;size +L0001_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ret + +L0001_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0001_Check: + DW ((L0001_CheckFinished - L0001_Check2)) ;size +L0001_Check2: + call ((.animateWater-L0001_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0001_CheckFinished: +PRINT "0001 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0001_LoadFinished - L0001_Load2) +PRINT " / " +PRINT (L0001_InitFinished - L0001_Init2) +PRINT " / " +PRINT (L0001_CheckFinished - L0001_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0002.asm b/Source/Levels/L0002.asm new file mode 100644 index 0000000..ed64b4c --- /dev/null +++ b/Source/Levels/L0002.asm @@ -0,0 +1,158 @@ +; L0002.asm bee border +; Generated 08.27.2000 by mlevel +; Modified 08.27.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 23 +VAR_WATER EQU 0 + +STATE_NORMAL EQU 1 +STATE_TALKED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0002Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0002_bees_gtx: + INCBIN "Data/Dialog/Talk/L0002_bees.gtx" + +L0002_hero_spray_gtx: + INCBIN "Data/Dialog/Talk/L0002_hero_spray.gtx" + +L0002_village_gtx: + INCBIN "Data/Dialog/Talk/L0002_village.gtx" + +L0002_hero_no_gtx: + INCBIN "Data/Dialog/Talk/L0002_hero_no.gtx" + +L0002_croutons_gtx: + INCBIN "Data/Dialog/Talk/L0002_croutons.gtx" + +L0002_Contents:: + DW L0002_Load + DW L0002_Init + DW L0002_Check + DW L0002_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0002_Load: + DW ((L0002_LoadFinished - L0002_Load2)) ;size +L0002_Load2: + call ParseMap + ret + +L0002_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0002_Map: +INCBIN "Data/Levels/L0002_bees.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0002_Init: + DW ((L0002_InitFinished - L0002_Init2)) ;size +L0002_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + STDSETUPDIALOG + + ld a,STATE_NORMAL + ldio [mapState],a + + ld bc,classTree + ld de,classTreeTalker + call ChangeClass + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0002_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0002_Check: + DW ((L0002_CheckFinished - L0002_Check2)) ;size +L0002_Check2: + call ((.animateWater-L0002_Check2)+levelCheckRAM) + call ((.checkDialog-L0002_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_TALKED + ret z + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ld de,((.afterDialog-L0002_Check2)+levelCheckRAM) + call SetDialogSkip + + ;Careful; bees + ld de,L0002_bees_gtx + call ShowDialogNPC + + ;Where's the spray? + ld de,L0002_hero_spray_gtx + call ShowDialogHero + + ;Down south; seen anybody? + ld de,L0002_village_gtx + call ShowDialogNPC + + ;No + ld de,L0002_hero_no_gtx + call ShowDialogHero + + ;tell about croutons + ld de,L0002_croutons_gtx + call ShowDialogNPC + +.afterDialog + call ClearDialog + + call MakeNonIdle + ld a,STATE_TALKED + ldio [mapState],a + + ld a,1 + call DisableDialogBalloons + + xor a + ld [dialogNPC_speakerIndex],a + ret + + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0002_CheckFinished: +PRINT "0002 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0002_LoadFinished - L0002_Load2) +PRINT " / " +PRINT (L0002_InitFinished - L0002_Init2) +PRINT " / " +PRINT (L0002_CheckFinished - L0002_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0003.asm b/Source/Levels/L0003.asm new file mode 100644 index 0000000..7f9dc73 --- /dev/null +++ b/Source/Levels/L0003.asm @@ -0,0 +1,199 @@ +; L0003.asm green pastures big sheep pen +; Generated 08.26.2000 by mlevel +; Modified 08.26.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +BLUE_INDEX EQU 49 + +STATE_NORMAL EQU 1 +STATE_TALKED1 EQU 2 +STATE_TALKED2 EQU 3 + + +;--------------------------------------------------------------------- +SECTION "Level0003Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0003_wolves_gtx: + INCBIN "Data/Dialog/Talk/L0003_wolves.gtx" + +L0003_shootfast_gtx: + INCBIN "Data/Dialog/Talk/L0003_shootfast.gtx" + +L0003_hero_jeb_gtx: + INCBIN "Data/Dialog/Talk/L0003_hero_jeb.gtx" + +L0003_nevermind_gtx: + INCBIN "Data/Dialog/Talk/L0003_nevermind.gtx" + +L0003_aboutjeb_gtx: + INCBIN "Data/Dialog/Talk/L0003_aboutjeb.gtx" + +L0003_Contents:: + DW L0003_Load + DW L0003_Init + DW L0003_Check + DW L0003_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0003_Load: + DW ((L0003_LoadFinished - L0003_Load2)) ;size +L0003_Load2: + call ParseMap + ret + +L0003_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0003_Map: +INCBIN "Data/Levels/L0003_green.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0003_Init: + DW ((L0003_InitFinished - L0003_Init2)) ;size +L0003_Init2: + STDSETUPDIALOG + + ld bc,classCowboy + ld de,classCowboyTalker + call ChangeFirstClass + + ld a,BLUE_INDEX + ld [dialogBalloonClassIndex],a + ld a,%0011 + call DisableDialogBalloons + + ld a,STATE_NORMAL + ldio [mapState],a + + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call InitMusic + ret + +L0003_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0003_Check: + DW ((L0003_CheckFinished - L0003_Check2)) ;size +L0003_Check2: + call ((.checkDialog-L0003_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_TALKED2 + jr c,.dialogOkay + + ld a,$ff + call DisableDialogBalloons + ret + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ldio a,[mapState] + cp STATE_TALKED1 + jr z,.talkAboutJeb + + ld de,((.afterWolfDialog-L0003_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ;Warn about wolves + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0003_wolves_gtx + call ShowDialogAtTop + call ClearDialog + +.afterWolfDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + ld a,STATE_TALKED1 + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +.talkAboutJeb + ld de,((.afterJebDialog-L0003_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ;Out here ya gotta shoot fast + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0003_shootfast_gtx + call ShowDialogAtTop + call ClearDialog + + ;Jeb? + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + ld de,L0003_hero_jeb_gtx + call ShowDialogAtBottom + call ClearDialog + + ld a,HERO_BS_FLAG + call ClassIndexIsHeroType + jr z,.notBS + + ;nevermind + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0003_aboutjeb_gtx + call ShowDialogAtTop + jr .afterJebDialog + +.notBS + ;nevermind + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0003_nevermind_gtx + call ShowDialogAtTop + +.afterJebDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + ld a,STATE_TALKED2 + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +L0003_CheckFinished: +PRINT "0003 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0003_LoadFinished - L0003_Load2) +PRINT " / " +PRINT (L0003_InitFinished - L0003_Init2) +PRINT " / " +PRINT (L0003_CheckFinished - L0003_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0004.asm b/Source/Levels/L0004.asm new file mode 100644 index 0000000..663c762 --- /dev/null +++ b/Source/Levels/L0004.asm @@ -0,0 +1,144 @@ +; L0004.asm start of green pastures +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_NORMAL EQU 1 +STATE_TALKED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0004Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0004_howdypilgrim_gtx: + INCBIN "Data/Dialog/Talk/L0004_howdypilgrim.gtx" + +L0004_sure_gtx: + INCBIN "Data/Dialog/Talk/L0004_sure.gtx" + +L0004_mindyourbusiness_gtx: + INCBIN "Data/Dialog/Talk/L0004_mindyourbusiness.gtx" + +L0004_Contents:: + DW L0004_Load + DW L0004_Init + DW L0004_Check + DW L0004_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0004_Load: + DW ((L0004_LoadFinished - L0004_Load2)) ;size +L0004_Load2: + call ParseMap + ret + +L0004_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0004_Map: +INCBIN "Data/Levels/L0004_ranch.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0004_Init: + DW ((L0004_InitFinished - L0004_Init2)) ;size +L0004_Init2: + ld a,BANK(dialog) + ld [dialogBank],a + call SetPressBDialog + + ld a,STATE_NORMAL + ldio [mapState],a + + ld bc,classCowboy + ld de,classCowboyTalker + call ChangeClass + + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call InitMusic + ret + +L0004_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0004_Check: + DW ((L0004_CheckFinished - L0004_Check2)) ;size +L0004_Check2: + call ((.checkDialog-L0004_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_TALKED + jr c,.dialogOkay + + ld a,%11 + call DisableDialogBalloons + ret + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ld de,((.afterDialog-L0004_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ;Howdy pilgrim + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0004_howdypilgrim_gtx + call ShowDialogAtTop + call ClearDialog + + ;Sure I'll help + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + ld de,L0004_sure_gtx + call ShowDialogAtBottom + call ClearDialog + + ;Mind your own business + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0004_mindyourbusiness_gtx + call ShowDialogAtTop + +.afterDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + ld a,STATE_TALKED + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +L0004_CheckFinished: +PRINT "0004 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0004_LoadFinished - L0004_Load2) +PRINT " / " +PRINT (L0004_InitFinished - L0004_Init2) +PRINT " / " +PRINT (L0004_CheckFinished - L0004_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0005.asm b/Source/Levels/L0005.asm new file mode 100644 index 0000000..5c67212 --- /dev/null +++ b/Source/Levels/L0005.asm @@ -0,0 +1,69 @@ +; L0005.asm trakktor clearing +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0005Section",ROMX +;--------------------------------------------------------------------- + +L0005_Contents:: + DW L0005_Load + DW L0005_Init + DW L0005_Check + DW L0005_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0005_Load: + DW ((L0005_LoadFinished - L0005_Load2)) ;size +L0005_Load2: + call ParseMap + ret + +L0005_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0005_Map: +INCBIN "Data/Levels/L0005_path.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0005_Init: + DW ((L0005_InitFinished - L0005_Init2)) ;size +L0005_Init2: + ld a,ENV_RAIN + call SetEnvEffect + + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ld hl,$1300 + call SetRespawnMap + ret + +L0005_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0005_Check: + DW ((L0005_CheckFinished - L0005_Check2)) ;size +L0005_Check2: + ret + +L0005_CheckFinished: +PRINT "0005 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0005_LoadFinished - L0005_Load2) +PRINT " / " +PRINT (L0005_InitFinished - L0005_Init2) +PRINT " / " +PRINT (L0005_CheckFinished - L0005_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0006.asm b/Source/Levels/L0006.asm new file mode 100644 index 0000000..134acad --- /dev/null +++ b/Source/Levels/L0006.asm @@ -0,0 +1,63 @@ +; L0006.asm Sunset Village +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0006Section",ROMX +;--------------------------------------------------------------------- + +L0006_Contents:: + DW L0006_Load + DW L0006_Init + DW L0006_Check + DW L0006_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0006_Load: + DW ((L0006_LoadFinished - L0006_Load2)) ;size +L0006_Load2: + call ParseMap + ret + +L0006_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0006_Map: +INCBIN "Data/Levels/L0006_sunset.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0006_Init: + DW ((L0006_InitFinished - L0006_Init2)) ;size +L0006_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ret + +L0006_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0006_Check: + DW ((L0006_CheckFinished - L0006_Check2)) ;size +L0006_Check2: + ret + +L0006_CheckFinished: +PRINT "0006 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0006_LoadFinished - L0006_Load2) +PRINT " / " +PRINT (L0006_InitFinished - L0006_Init2) +PRINT " / " +PRINT (L0006_CheckFinished - L0006_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0007.asm b/Source/Levels/L0007.asm new file mode 100644 index 0000000..6d25560 --- /dev/null +++ b/Source/Levels/L0007.asm @@ -0,0 +1,72 @@ +; L0007.asm +; Generated 09.04.2000 by mlevel +; Modified 09.04.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0007Section",ROMX +;--------------------------------------------------------------------- + +L0007_Contents:: + DW L0007_Load + DW L0007_Init + DW L0007_Check + DW L0007_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0007_Load: + DW ((L0007_LoadFinished - L0007_Load2)) ;size +L0007_Load2: + call ParseMap + ret + +L0007_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0007_Map: +INCBIN "Data/Levels/L0007_forest.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +CROWINDEX EQU 31 +EATRANGE EQU ((29<<8) | 21) + +L0007_Init: + DW ((L0007_InitFinished - L0007_Init2)) ;size +L0007_Init2: + ;set crows to eat the trees and bushes + ld c,CROWINDEX + call GetFirst +.setCrowsFood + ld hl,EATRANGE + call SetFoodIndexRange + call GetNextObject + or a + jr nz,.setCrowsFood + + ret + +L0007_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0007_Check: + DW ((L0007_CheckFinished - L0007_Check2)) ;size +L0007_Check2: + ret + +L0007_CheckFinished: +PRINT "0007 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0007_LoadFinished - L0007_Load2) +PRINT " / " +PRINT (L0007_InitFinished - L0007_Init2) +PRINT " / " +PRINT (L0007_CheckFinished - L0007_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0008.asm b/Source/Levels/L0008.asm new file mode 100644 index 0000000..89e0811 --- /dev/null +++ b/Source/Levels/L0008.asm @@ -0,0 +1,130 @@ +; L0008.asm +; Generated 09.04.2000 by mlevel +; Modified 09.04.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +STATE_NORMAL EQU 1 +STATE_SPRAYTAKEN EQU 2 + +;--------------------------------------------------------------------- +SECTION "Level0008Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0008_findspray_gtx: + INCBIN "Data/Dialog/Talk/L0008_findspray.gtx" + +L0008_Contents:: + DW L0008_Load + DW L0008_Init + DW L0008_Check + DW L0008_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0008_Load: + DW ((L0008_LoadFinished - L0008_Load2)) ;size +L0008_Load2: + call ParseMap + ret + +L0008_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0008_Map: +INCBIN "Data/Levels/L0008_forest.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0008_Init: + DW ((L0008_InitFinished - L0008_Init2)) ;size +L0008_Init2: + call State0To1 + + STDSETUPDIALOG + + ldio a,[mapState] + cp STATE_SPRAYTAKEN + jr nz,.done + + ;remove spray from map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d32d],a + +.done + ret + +L0008_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0008_Check: + DW ((L0008_CheckFinished - L0008_Check2)) ;size +L0008_Check2: + ldio a,[mapState] + cp STATE_SPRAYTAKEN + jr z,.done + + xor a + ld hl,((.checkFoundSpray-L0008_Check2)+levelCheckRAM) + call CheckEachHero +.done + ret + +.checkFoundSpray + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.foundSpray + + xor a + ret + +.foundSpray + ;found spray + ld de,((.afterDialog-L0008_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0008_findspray_gtx + call ShowDialogAtBottom +.afterDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld bc,ITEM_BUGSPRAY + call AddInventoryItem + + ;remove spray from map + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d32d],a + + ld a,STATE_SPRAYTAKEN + ldio [mapState],a + + ld a,1 + ret + +L0008_CheckFinished: +PRINT "0008 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0008_LoadFinished - L0008_Load2) +PRINT " / " +PRINT (L0008_InitFinished - L0008_Init2) +PRINT " / " +PRINT (L0008_CheckFinished - L0008_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0009.asm b/Source/Levels/L0009.asm new file mode 100644 index 0000000..bf1c2a0 --- /dev/null +++ b/Source/Levels/L0009.asm @@ -0,0 +1,59 @@ +; L0009.asm +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0009Section",ROMX +;--------------------------------------------------------------------- + +L0009_Contents:: + DW L0009_Load + DW L0009_Init + DW L0009_Check + DW L0009_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0009_Load: + DW ((L0009_LoadFinished - L0009_Load2)) ;size +L0009_Load2: + call ParseMap + ret + +L0009_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0009_Map: +INCBIN "Data/Levels/L0009_mouse.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0009_Init: + DW ((L0009_InitFinished - L0009_Init2)) ;size +L0009_Init2: + ret + +L0009_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0009_Check: + DW ((L0009_CheckFinished - L0009_Check2)) ;size +L0009_Check2: + ret + +L0009_CheckFinished: +PRINT "0009 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0009_LoadFinished - L0009_Load2) +PRINT " / " +PRINT (L0009_InitFinished - L0009_Init2) +PRINT " / " +PRINT (L0009_CheckFinished - L0009_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0010.asm b/Source/Levels/L0010.asm new file mode 100644 index 0000000..44655dc --- /dev/null +++ b/Source/Levels/L0010.asm @@ -0,0 +1,436 @@ +; L0010.asm mouse teleport room +; Generated 11.06.2000 by mlevel +; Modified 11.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +BOULDER_INDEX EQU 1 +MASK_INDEX EQU 68 +MOUSE_INDEX EQU 69 +UBERMOUSE_INDEX EQU 71 + +VAR_CONTROLS EQU 0 +VAR_CRATE EQU 1 +VAR_CRATETAKEN EQU 2 + +STATE_MASKTAKEN EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0010Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0010_mattermitter_gtx: + INCBIN "Data/Dialog/Talk/L0010_mattermitter.gtx" + +L0010_foundmask_gtx: + INCBIN "Data/Dialog/Talk/L0010_foundmask.gtx" + +L0010_crate_gtx: + INCBIN "Data/Dialog/Talk/L0010_crate.gtx" + +L0010_Contents:: + DW L0010_Load + DW L0010_Init + DW L0010_Check + DW L0010_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0010_Load: + DW ((L0010_LoadFinished - L0010_Load2)) ;size +L0010_Load2: + call ParseMap + ret + +L0010_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0010_Map: +INCBIN "Data/Levels/L0010_serpent.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0010_Init: + DW ((L0010_InitFinished - L0010_Init2)) ;size +L0010_Init2: + STDSETUPDIALOG + xor a + ld [levelVars+VAR_CONTROLS],a + + ;remove mask if taken + ldio a,[mapState] + cp STATE_MASKTAKEN + jr nz,.checkRemoveCrate + + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d168],a + +.checkRemoveCrate + xor a + ld hl,levelVars+VAR_CRATETAKEN + ld [hl],a + + ;remove create if taken already + ld bc,ITEM_BAHIGHIMPACT + call HasInventoryItem + jr z,.doneRemoveCreate + + ld a,1 + ld [hl],a + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d1f3],a + +.doneRemoveCreate + + ret + +L0010_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0010_Check: + DW ((L0010_CheckFinished - L0010_Check2)) ;size +L0010_Check2: + call ((.checkUberMouseOpenWall-L0010_Check2)+levelCheckRAM) + call ((.checkSign-L0010_Check2)+levelCheckRAM) + ldio a,[mapState] + cp STATE_MASKTAKEN + jr z,.checkControls + + xor a + ld hl,((.checkFoundMask-L0010_Check2)+levelCheckRAM) + call CheckEachHero + +.checkControls + ;can't operate if ubermouse half-in + ld a,MAPBANK + ldio [$ff70],a + ld a,[$d064] + cp UBERMOUSE_INDEX + ret z + + ld a,1 + ld hl,((.heroAtControls-L0010_Check2)+levelCheckRAM) + call CheckEachHero + + ld hl,levelVars + VAR_CONTROLS + cp [hl] + jp z,((.afterResetControls-L0010_Check2)+levelCheckRAM) + + ld [hl],a + or a + jp z,((.afterResetControls-L0010_Check2)+levelCheckRAM) + + ;activate teleport! + ld de,((.afterTportDialog-L0010_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0010_mattermitter_gtx + call ShowDialogAtBottom +.afterTportDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,15 + call SetupFadeFromWhite + + ld a,1 + call Delay + + ld hl,$d063 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d064 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d083 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d084 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d148 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d149 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d168 + call ((.package-L0010_Check2)+levelCheckRAM) + ld hl,$d169 + call ((.package-L0010_Check2)+levelCheckRAM) + + ld de,$d063 + ld hl,$d148 + call ((.exchange-L0010_Check2)+levelCheckRAM) + ld de,$d064 + ld hl,$d149 + call ((.exchange-L0010_Check2)+levelCheckRAM) + ld de,$d083 + ld hl,$d168 + call ((.exchange-L0010_Check2)+levelCheckRAM) + ld de,$d084 + ld hl,$d169 + call ((.exchange-L0010_Check2)+levelCheckRAM) + + ;unpack in reverse order + ld de,$d169 + ld hl,$d084 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld de,$d168 + ld hl,$d083 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld de,$d149 + ld hl,$d064 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld de,$d148 + ld hl,$d063 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + + ld hl,$d169 + ld de,$d084 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld hl,$d168 + ld de,$d083 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld hl,$d149 + ld de,$d064 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + ld hl,$d148 + ld de,$d063 + call ((.unpackage-L0010_Check2)+levelCheckRAM) + +.afterResetControls + ret + +.checkSign + ld a,1 + ld hl,((.heroAtSign-L0010_Check2)+levelCheckRAM) + call CheckEachHero + + ld hl,levelVars + VAR_CRATE + cp [hl] + ret z + + ld [hl],a + or a + ret z + + ld a,[levelVars+VAR_CRATETAKEN] + or a + ret nz + + ld de,((.afterSignDialog-L0010_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0010_crate_gtx + call ShowDialogAtBottom +.afterSignDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ;remove create if BA + ld a,HERO_BA_FLAG + call ClassIndexIsHeroType + ret z + + ld a,1 + ld [levelVars+VAR_CRATETAKEN],a + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [$d1f3],a + ld bc,ITEM_BAHIGHIMPACT + call AddInventoryItem + ld hl,baUpgrades + set UPGRADE_BAHIGHIMPACT,[hl] + + ret + +.heroAtSign + ld c,a + call GetFirst + call GetCurZone + cp 5 + jp z,((.returnTrue-L0010_Check2)+levelCheckRAM) + + ;return false + xor a + ret + + +.checkUberMouseOpenWall + ld a,MAPBANK + ldio [$ff70],a + ld a,[$d10d] + cp UBERMOUSE_INDEX + ret nz + + ld a,[$d10f] + cp BOULDER_INDEX + ret nz + + xor a + ld [$d10f],a + ld [$d12f],a + + ld a,15 + ldio [jiggleDuration],a + ld hl,bombSound + call PlaySound + ret + +.package + ;pick up object at [hl], remove it from map, place index back + ;at [hl] + ld a,MAPBANK + ldio [$ff70],a + ldio a,[firstMonster] + ld b,a + ld a,[hl] + cp b + ret c ;is a BG tile + + push hl + push hl + call EnsureTileIsHead + ld c,a + push hl + pop de + call FindObject + call SetObjWidthHeight + call GetFacing + push bc + ld c,a + call RemoveFromMap + pop bc + pop hl + call SetCurLocation + ;turn off split bit + call GetFacing + res 2,a + call SetFacing + ld a,MAPBANK + ldio [$ff70],a + ld a,c + pop hl + ld [hl],a + ret + +.unpackage + ;hl - location object is at + ;de - object's previous location + ld a,MAPBANK + ldio [$ff70],a + ldio a,[firstMonster] + ld b,a + ld a,[hl] + cp b + ret c ;is a BG tile + + push hl + ld c,a + call FindObject + pop hl + call SetCurLocation + + ld b,METHOD_DRAW + call CallMethod + ret + +.exchange + ;exchange obj/items at [hl] with [de] + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + ld b,a + ld a,[de] + ld [hl],a + ld a,b + ld [de],a + ret + +.heroAtControls + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.returnTrue + +.returnFalse + xor a + ret + +.returnTrue + ld a,1 + ret + +.checkFoundMask + ld c,a + call GetFirst + call GetCurZone + cp 4 + jr z,.checkZone4 + cp 3 + jr nz,.returnFalse ;not near mask at all + +.checkZone3 + ld hl,$d083 + jr .checkHLForMask + +.checkZone4 + ld hl,$d168 +.checkHLForMask + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl] + cp MASK_INDEX + jr nz,.returnFalse ;mask not here + +.foundMask + ;remove mask from map + ld [hl],0 + + ld de,((.afterDialog-L0010_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0010_foundmask_gtx + call ShowDialogAtBottom +.afterDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld bc,ITEM_SPOREMASK + call AddInventoryItem + + ld a,STATE_MASKTAKEN + ldio [mapState],a + + ld a,1 + ret + +L0010_CheckFinished: +PRINT "0010 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0010_LoadFinished - L0010_Load2) +PRINT " / " +PRINT (L0010_InitFinished - L0010_Init2) +PRINT " / " +PRINT (L0010_CheckFinished - L0010_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0011.asm b/Source/Levels/L0011.asm new file mode 100644 index 0000000..9f5ad6f --- /dev/null +++ b/Source/Levels/L0011.asm @@ -0,0 +1,101 @@ +; L0011.asm House of the Seasons +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0011Section",ROMX +;--------------------------------------------------------------------- + +L0011_Contents:: + DW L0011_Load + DW L0011_Init + DW L0011_Check + DW L0011_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0011_Load: + DW ((L0011_LoadFinished - L0011_Load2)) ;size +L0011_Load2: + call ParseMap + ret + +L0011_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0011_Map: +INCBIN "Data/Levels/L0011_seasons.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_FIRE EQU 0 + +FIREINDEX EQU 40 + +L0011_Init: + DW ((L0011_InitFinished - L0011_Init2)) ;size +L0011_Init2: + ld a,[bgTileMap + FIREINDEX] + ld [levelVars + VAR_FIRE],a + + ;map color to white for fade + ld hl,mapColor + ld a,$ff + ld [hl+],a + ld a,$7f + ld [hl+],a + + ;last color to $0888 for fade/hblank + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette+62 + ld a,$88 + ld [hl+],a + ld a,$08 + ld [hl+],a + + ;new hblank + ld hl,SeasonsOnHBlank + call InstallHBlankHandler + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0011_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0011_Check: + DW ((L0011_CheckFinished - L0011_Check2)) ;size +L0011_Check2: + call ((.animateFire-L0011_Check2)+levelCheckRAM) + ret + +.animateFire + ldio a,[updateTimer] + rrca + rrca + and %11 + ld hl,levelVars + VAR_FIRE + add [hl] + ld [bgTileMap + FIREINDEX],a + ret + + +L0011_CheckFinished: +PRINT "0011 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0011_LoadFinished - L0011_Load2) +PRINT " / " +PRINT (L0011_InitFinished - L0011_Init2) +PRINT " / " +PRINT (L0011_CheckFinished - L0011_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0012.asm b/Source/Levels/L0012.asm new file mode 100644 index 0000000..ea12e9c --- /dev/null +++ b/Source/Levels/L0012.asm @@ -0,0 +1,179 @@ +; L0012.asm Command Core +; Generated 04.26.2001 by mlevel +; Modified 04.26.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;same for other ssa rooms +STATE_DEFUSED EQU 2 + +VAR_TALKED EQU 0 + +STATIC_INDEX EQU 23 +GRUNT_INDEX EQU 28 +GYRO_INDEX EQU 29 + +;--------------------------------------------------------------------- +SECTION "Level0012Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0012_bombs_gtx: + INCBIN "Data/Dialog/Apocalypse/L0012_bombs.gtx" + +L0012_defused_gtx:: + INCBIN "Data/Dialog/Apocalypse/L0012_defused.gtx" + +L0012_alldefused_gtx:: + INCBIN "Data/Dialog/Apocalypse/L0012_alldefused.gtx" + +L0012_Contents:: + DW L0012_Load + DW L0012_Init + DW L0012_Check + DW L0012_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0012_Load: + DW ((L0012_LoadFinished - L0012_Load2)) ;size +L0012_Load2: + call ParseMap + ret + +L0012_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0012_Map: +INCBIN "Data/Levels/L0012_ssa_cmdcore.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0012_Init: + DW ((L0012_InitFinished - L0012_Init2)) ;size +L0012_Init2: + STDSETUPDIALOG + xor a + ld [levelVars+VAR_TALKED],a + ret + +L0012_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0012_Check: + DW ((L0012_CheckFinished - L0012_Check2)) ;size +L0012_Check2: + call ((.animateStatic-L0012_Check2)+levelCheckRAM) + call ((.checkDialog-L0012_Check2)+levelCheckRAM) + ret + +.checkDialog + ld a,[levelVars+VAR_TALKED] + or a + ret nz + + ;enemies gone? + ld c,GRUNT_INDEX + call GetFirst + or a + ret nz + + ;check all defused + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$b8] + cp 2 + jr nz,.needDefuse + ld a,[levelState+$b9] + cp 2 + jr nz,.needDefuse + ld a,[levelState+$ba] + cp 2 + jr nz,.needDefuse + ld a,[levelState+$bb] + cp 2 + jr nz,.needDefuse + + ;all defused. + call MakeIdle + + ld a,30 +.delayStatic + push af + ld a,1 + call Delay + call ((.animateStatic-L0012_Check2)+levelCheckRAM) + pop af + dec a + jr nz,.delayStatic + + ;Gyro appears on screen + ld c,GYRO_INDEX + ld hl,$d14a + call CreateInitAndDrawObject + + ld a,30 + call Delay + + call MakeNonIdle + ld a,1 + ld [levelVars+VAR_TALKED],a + + ;go to escape ssa cinema + ld a,0 + ld hl,$1204 + call YankRemotePlayer + + ld hl,$1204 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.needDefuse + ld de,((.afterDialog-L0012_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerToFirstHero + ld de,L0012_bombs_gtx + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ld [levelVars+VAR_TALKED],a + ret + +.animateStatic + ldio a,[updateTimer] + rrca + and %00000010 + add STATIC_INDEX + ld hl,bgTileMap+STATIC_INDEX + ld [hl+],a + inc a + ld [hl+],a + ret + +L0012_CheckFinished: +PRINT "0012 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0012_LoadFinished - L0012_Load2) +PRINT " / " +PRINT (L0012_InitFinished - L0012_Init2) +PRINT " / " +PRINT (L0012_CheckFinished - L0012_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0013.asm b/Source/Levels/L0013.asm new file mode 100644 index 0000000..c6ee86b --- /dev/null +++ b/Source/Levels/L0013.asm @@ -0,0 +1,770 @@ +; L0013.asm - first map, ba lands on the moon +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +DROPSPEED1 EQU $ff00 ;normal +DROPSPEED2 EQU $0001 + +;DROPSPEED1 EQU $fc00 ;fast +;DROPSPEED2 EQU $0004 + + +;--------------------------------------------------------------------- +SECTION "Level0013Section",ROMX +;--------------------------------------------------------------------- + +L0013_Contents:: + DW L0013_Load + DW L0013_Init + DW L0013_Check + DW L0013_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0013_Load: + DW ((L0013_LoadFinished - L0013_Load2)) ;size +L0013_Load2: + call ParseMap + + ;load in tiles used for sprite ships + ;bg tiles 1153-1242 to Bank 0 100-189 + ldio a,[curROMBank] + push af + + ld a,BANK(BGTiles1024) + call SetActiveROM + + xor a ;bank 0 + ld c,90 ;number of tiles to copy + ld de,$8000+1600 + ld hl,BGTiles1024 + 129*16 + call VMemCopy + + pop af + call SetActiveROM + ret + +L0013_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0013_Map: +INCBIN "Data/Levels/L0013_intro_ba1.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +ORIGINALTILE EQU 0 +VAR_HERO0_INDEX EQU 1 +VAR_HERO1_INDEX EQU 2 + +HULKINDEX EQU 73 +GRUNTINDEX EQU 74 +B12PURPLEINDEX EQU 75 +B12GREYINDEX EQU 76 +B12YELLOWINDEX EQU 77 + +STATE_INITIALDRAW EQU 0 +STATE_B12DROP_INIT EQU 1 +STATE_B12DROP EQU 2 +STATE_CROUTONDROP_INIT EQU 3 +STATE_CROUTONDROP EQU 4 +STATE_NORMAL EQU 5 + +L0013_Init: + DW ((L0013_InitFinished - L0013_Init2)) ;size +L0013_Init2: + ld a,BANK(moon_base_ba_gbm) + ld hl,moon_base_ba_gbm + call InitMusic + + ld hl,$0013 + call SetJoinMap + + ld hl,$0013 + call SetRespawnMap + + ld a,$13 + ld [respawnMap],a + ld [joinMap],a + ld a,$00 + ld [respawnMap+1],a + ld [joinMap+1],a + + ;get rid of existing monsters + ld a,HULKINDEX + call DeleteObjectsOfClassIndex + ld a,GRUNTINDEX + call DeleteObjectsOfClassIndex + ld a,B12PURPLEINDEX + call DeleteObjectsOfClassIndex + ld a,B12GREYINDEX + call DeleteObjectsOfClassIndex + ld a,B12YELLOWINDEX + call DeleteObjectsOfClassIndex + + ld a,[bgTileMap+48] + ld [levelVars+ORIGINALTILE],a + + ld bc,((GROUP_MONSTERB<<8) | GROUP_HERO) + ld a,1 ;make soldiers friends with hero + call SetFOF + + ldio a,[mapState] + cp STATE_NORMAL + jr z,.afterRemoveHeroes + + cp STATE_CROUTONDROP_INIT + jr z,.removeHeroes + cp STATE_CROUTONDROP + jr z,.removeHeroes + xor a + ld [canJoinMap],a + +.removeHeroes + ;remove heroes + ld a,[hero0_index] + call ((.heroInvisible - L0013_Init2) + levelCheckRAM) + + ld a,[hero1_index] + call ((.heroInvisible - L0013_Init2) + levelCheckRAM) + + ld a,1 + ld [heroesIdle],a +.afterRemoveHeroes + ret + +.heroInvisible + or a + ret z + ld c,a + call GetFirst + call GetFacing + ld c,a + call RemoveFromMap + ret + + +L0013_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +CROUTON_DROPY EQU 22 + +L0013_Check: + DW ((L0013_CheckFinished - L0013_Check2)) ;size +L0013_Check2: + ;animate the radar tower (index 48-53) based on timer/8 + ldio a,[updateTimer] + rrca ;(t/8)*6 == t/4*3 + and %00000110 + ld b,a + add b + add b + ld b,a + ld a,[levelVars+ORIGINALTILE] + add b + + ld hl,bgTileMap + 48 + ld c,6 +.animateTower + ld [hl+],a + inc a + dec c + jr nz,.animateTower + + ldio a,[mapState] + cp STATE_INITIALDRAW + jr nz,.checkB12DropInit + + ld a,STATE_B12DROP_INIT + ldio [mapState],a + ret + +.checkB12DropInit + cp STATE_B12DROP_INIT + jr nz,.checkB12Drop + +;ld a,STATE_NORMAL +;ldio [mapState],a +;ret + ;----b12 drop init-------------------------------------------- + ;set up mask table + call ((.clearMask - L0013_Check2) + levelCheckRAM) + call ((.createB12Ship - L0013_Check2) + levelCheckRAM) + call ((.fadeOut - L0013_Check2) + levelCheckRAM) + + ld a,STATE_B12DROP + ldio [mapState],a + ret + +.checkB12Drop + cp STATE_B12DROP + jr z,.inB12Drop + jp ((.checkCroutonDropInit-L0013_Check2)+levelCheckRAM) + +.inB12Drop + ;b12 dropship + ld bc,DROPSPEED1 + ld hl,$cdc0 + call ScrollMetaSprite + + call ((.animateB12Thrusters - L0013_Check2) + levelCheckRAM) + + ;remove ship if nose sprite is 192 + ;get the x position of the first sprite on third row + ld a,[$cdc0 + 16 + 1] + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + inc hl + ld a,[hl] + cp 192 + jr nz,.afterRemoveShip + + ld hl,$cdc0 + call FreeMetaSprite + ld a,STATE_CROUTONDROP_INIT + ldio [mapState],a + ld hl,((.shipFadeSound - L0013_Check2) + levelCheckRAM) + call PlaySound + call ((.fadeIn - L0013_Check2) + levelCheckRAM) + ld a,30 + ldio [mapState+1],a ;delay until next ship + ret + +.afterRemoveShip + ;drop soldiers when ship is at specific pixel positions + cp 48 + jr nz,.checkSoldierDrop2 + + ld c,B12YELLOWINDEX + ld hl,$d0ca + push hl + ld hl,$d0ea + push hl + ld hl,$d10a + push hl + jp ((.createSoldiers - L0013_Check2) + levelCheckRAM) + +.checkSoldierDrop2 + cp 40 + jr nz,.checkSoldierDrop3 + + ld c,B12YELLOWINDEX + ld hl,$d0c9 + push hl + ld hl,$d0e9 + push hl + ld hl,$d109 + push hl + jp ((.createSoldiers - L0013_Check2) + levelCheckRAM) + +.checkSoldierDrop3 + cp 32 + jr nz,.checkSoldierDrop4 + + ld c,B12PURPLEINDEX + ld hl,$d0c8 + push hl + ld hl,$d0e8 + push hl + ld hl,$d108 + push hl + jp ((.createSoldiers - L0013_Check2) + levelCheckRAM) + +.checkSoldierDrop4 + cp 24 + jr nz,.checkSoldierDrop5 + + ld c,B12PURPLEINDEX + ld hl,$d0c7 + push hl + ld hl,$d0e7 + push hl + ld hl,$d107 + push hl + jp ((.createSoldiers - L0013_Check2) + levelCheckRAM) + +.checkSoldierDrop5 + cp 16 + jr nz,.checkSoldierDrop6 + + ;make heroes visible + ld a,[hero0_index] + call ((.heroVisible - L0013_Check2) + levelCheckRAM) + + ld a,[hero1_index] + call ((.heroVisible - L0013_Check2) + levelCheckRAM) + + ret + +.heroVisible + or a + ret z + ld c,a + call GetFirst + ld b,METHOD_DRAW + call CallMethod + ret + + ;ld c,B12PURPLEINDEX + ;ld hl,$d0c6 + ;push hl + ;ld hl,$d0e6 + ;push hl + ;ld hl,$d106 + ;push hl + ;jp ((.createSoldiers - L0013_Check2) + levelCheckRAM) + +.checkSoldierDrop6 + ret + +.checkCroutonDropInit + cp STATE_CROUTONDROP_INIT + jr nz,.checkCroutonDrop + + ;crouton drop init + + ld hl,mapState+1 + ld a,[hl] + or a + jr z,.afterDelay + + dec [hl] + ret + +.afterDelay + ;set up mask table + call ((.clearMask - L0013_Check2) + levelCheckRAM) + call ((.createCroutonShip - L0013_Check2)+levelCheckRAM) + + ld hl,((.croutonShipApproachSound - L0013_Check2) + levelCheckRAM) + call PlaySound + call ((.fadeOut - L0013_Check2) + levelCheckRAM) + + ld a,STATE_CROUTONDROP + ldio [mapState],a + ret + +.checkCroutonDrop + cp STATE_CROUTONDROP + jr z,.inCroutonDrop + + ld a,1 ;can join now + ld [canJoinMap],a + + jp ((.checkNormal - L0013_Check2)+levelCheckRAM) + +.inCroutonDrop + ;crouton dropship + ld bc,DROPSPEED2 + ld hl,$cdc0 + call ScrollMetaSprite + + call ((.animateCroutonThrusters-L0013_Check2)+levelCheckRAM) + + ;remove ship if top sprite is 161 + ;get the y position of the first sprite + ld a,[$cdc0 + 1] + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,[hl] + cp 162 + jr nz,.afterRemoveCroutonShip + + ld hl,$cdc0 + call FreeMetaSprite + ld a,STATE_NORMAL + ldio [mapState],a + ld hl,((.croutonShipFadeSound - L0013_Check2) + levelCheckRAM) + call PlaySound + call ((.fadeIn - L0013_Check2) + levelCheckRAM) + ld hl,musicEnabled ;enable track 4 + set 3,[hl] + + ;everybody start fighting + ld bc,classDoNothing + ld de,classB12Soldier + call ChangeClass + + ld bc,classDoNothing2 + ld de,classCroutonGrunt + call ChangeClass + + ld bc,classDoNothing3 + ld de,classCroutonHulk + call ChangeClass + + ;let the heroes move + xor a + ld [heroesIdle],a + + ld a,STATE_NORMAL + ldio [mapState],a + ret + +.afterRemoveCroutonShip + ;place croutons under ship based on y position + cp CROUTON_DROPY + jr nz,.placeCroutons2 + + ld hl,$d06e + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons2 + cp CROUTON_DROPY + 8*1 + jr nz,.placeCroutons3 + + ld hl,$d08e + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons3 + cp CROUTON_DROPY + 8*2 + jr nz,.placeCroutons4 + + ld hl,$d0ae + jp ((.placeCroutonDoubleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons4 + cp CROUTON_DROPY + 8*4 + jr nz,.placeCroutons5 + + ld hl,$d0ee + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons5 + cp CROUTON_DROPY + 8*5 + jr nz,.placeCroutons6 + + ld hl,$d10e + jp ((.placeCroutonDoubleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons6 + cp CROUTON_DROPY + 8*7 + jr nz,.placeCroutons7 + + ld hl,$d14e + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons7 + cp CROUTON_DROPY + 8*8 + jr nz,.placeCroutons8 + + ld hl,$d16e + jp ((.placeCroutonDoubleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons8 + cp CROUTON_DROPY + 8*10 + jr nz,.placeCroutons9 + + ld hl,$d1ae + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.placeCroutons9 + cp CROUTON_DROPY + 8*11 + ret nz + + ld hl,$d1ce + jp ((.placeCroutonSingleRow-L0013_Check2)+levelCheckRAM) + +.checkNormal + ret + +.createSoldiers + push bc + ld bc,classDoNothing + ld de,classB12Soldier + call ChangeClass + pop bc + ld b,3 +.createSoldiersLoop + pop hl + push bc + call CreateObject + ld b,METHOD_INIT + call CallMethod + ld a,DIR_EAST + call SetFacing + ld b,METHOD_DRAW + call CallMethod + pop bc + dec b + jr nz,.createSoldiersLoop + ld bc,classB12Soldier + ld de,classDoNothing + call ChangeClass + ret + +.clearMask + ld hl,$cdc0 + ld c,49 + ld a,1 +.clearMaskLoop + ld [hl+],a + dec c + jr nz,.clearMaskLoop + ret + +.createB12Ship + ;clear spots in the mask + xor a + ld [$cdc0 + 0 + 1],a + ld [$cdc0 + 1 + 1],a + ld [$cdc0 + 7 + 1],a + ld [$cdc0 + 1*8+0 + 1],a + ld [$cdc0 + 1*8+7 + 1],a + ld [$cdc0 + 4*8+0 + 1],a + ld [$cdc0 + 4*8+7 + 1],a + ld [$cdc0 + 5*8+0 + 1],a + ld [$cdc0 + 5*8+1 + 1],a + ld [$cdc0 + 5*8+7 + 1],a + + ld a,192 ;190 + ld [metaSprite_x],a + ld a,44 + ld [metaSprite_y],a + + ld bc,$0806 ;width and height of metasprite + ld d,100 ;starts at pattern #100 + ld e,5 ;default attributes (palette) + ld hl,$cdc0 + call CreateMetaSpriteUsingMask + + ld hl,musicEnabled ;disable track 4 + res 3,[hl] + ld hl,((.shipApproachSound - L0013_Check2) + levelCheckRAM) + call PlaySound + ret + +.animateB12Thrusters + ;animate thrusters by setting or clearing +128 to each + ;thruster sprite's y position + ld hl,$cdc0 + 6 + 1 + push hl + ld hl,$cdc0 + 8 + 6 + 1 + push hl + ld hl,$cdc0 + 8*4 + 6 + 1 + push hl + ld hl,$cdc0 + 8*5 + 6 + 1 + push hl + + ld b,0 + ld a,[updateTimer] + bit 0,a + jr nz,.afterSetMask + ld b,%10000000 +.afterSetMask + ld c,4 +.thrusterChangeLoop + pop hl + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,[hl] + and %01111111 + or b + ld [hl],a + dec c + jr nz,.thrusterChangeLoop + ret + +.createCroutonShip + ;clear spots in the mask + xor a + ld [$cdc0 + 5*6+1 + 1],a + ld [$cdc0 + 5*6+4 + 1],a + ld [$cdc0 + 6*6+1 + 1],a + ld [$cdc0 + 6*6+2 + 1],a + ld [$cdc0 + 6*6+3 + 1],a + ld [$cdc0 + 6*6+4 + 1],a + + ld a,104 + ld [metaSprite_x],a + ld a,166 + ld [metaSprite_y],a + + ld bc,$0607 ;width and height of metasprite + ld d,$94 ;initial pattern number + ld e,6 ;default attributes (palette) + ld hl,$cdc0 + call CreateMetaSpriteUsingMask + ret + +.animateCroutonThrusters + ;animate thrusters by setting or clearing +128 to each + ;thruster sprite's y position + ld hl,$cdc0 + 1 + push hl + ld hl,$cdc0 + 5 + 1 + push hl + + ld b,0 + ld a,[updateTimer] + bit 0,a + jr nz,.afterSetCroutonMask + ld b,80 +.afterSetCroutonMask + ld c,2 +.croutonThrusterChangeLoop + pop hl + ld l,[hl] + ld h,((spriteOAMBuffer>>8) & $ff) + inc hl ;to sprite x pos + ld a,[hl] + cp 160 + jr c,.xposOriginal + sub 80 +.xposOriginal + add b + ld [hl],a + dec c + jr nz,.croutonThrusterChangeLoop + ret + +.placeCroutonSingleRow + ld b,2 + ld c,GRUNTINDEX + push hl + inc hl + push hl + jr .createCroutons + +.placeCroutonDoubleRow + push hl + ld bc,((.drowRetAddr-L0013_Check2)+levelCheckRAM) + push bc + jr .placeCroutonSingleRow +.drowRetAddr + pop hl + push hl + ld bc,32 + add hl,bc + ld bc,((.drowRetAddr2-L0013_Check2)+levelCheckRAM) + push bc + jr .placeCroutonSingleRow +.drowRetAddr2 + pop hl + + ld bc,((.afterCreateHulk-L0013_Check2)+levelCheckRAM) + push bc + inc hl + inc hl + push hl + + ld bc,classDoNothing3 + ld de,classCroutonHulk + call ChangeClass + + ld b,1 + ld c,HULKINDEX + jr .createCroutons +.afterCreateHulk + ld bc,classCroutonHulk + ld de,classDoNothing3 + call ChangeClass + ret + +.createCroutons + push bc + ld bc,classDoNothing2 + ld de,classCroutonGrunt + call ChangeClass + pop bc + pop hl + push bc + call CreateObject + ld b,METHOD_INIT + call CallMethod + ld a,DIR_WEST + call SetFacing + ld b,METHOD_DRAW + call CallMethod + pop bc + dec b + jr nz,.createCroutons + ld bc,classCroutonGrunt + ld de,classDoNothing2 + call ChangeClass + ret + +.fadeOut + ld a,FADEBANK + ld [$ff70],a + + ;set final bg palette to be all white w/black bg + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ld hl,fadeFinalPalette + call ((.setPaletteToWhiteBlackBG-L0013_Check2)+levelCheckRAM) + + ;set cur palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ld a,120 + call FadeInit + ret + +.fadeIn + ld a,FADEBANK + ld [$ff70],a + + ;set cur palette to be all white w black bg + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeCurPalette + call ((.setPaletteToWhiteBlackBG-L0013_Check2)+levelCheckRAM) + + ;set final palette to be copy of current game palette + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ld a,30 + call FadeInit + ret + +.setPaletteToWhiteBlackBG + ld c,8 +.setBlackLoop + ld a,$ff + ld [hl+],a + ld a,$7f + ld [hl+],a + ld b,3 +.setWhiteLoop + ld a,$b5 + ld [hl+],a + ld a,$56 + ld [hl+],a + dec b + jr nz,.setWhiteLoop + dec c + jr nz,.setBlackLoop + ret + +.shipApproachSound + DB 4,$00,$0f,$81,$80 +.shipFadeSound + DB 4,$00,$f7,$81,$80 +.croutonShipApproachSound + DB 4,$00,$0f,$82,$80 +.croutonShipFadeSound + DB 4,$00,$f7,$82,$80 + +L0013_CheckFinished: +PRINT "0013 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0013_LoadFinished - L0013_Load2) +PRINT " / " +PRINT (L0013_InitFinished - L0013_Init2) +PRINT " / " +PRINT (L0013_CheckFinished - L0013_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0014.asm b/Source/Levels/L0014.asm new file mode 100644 index 0000000..ac06edc --- /dev/null +++ b/Source/Levels/L0014.asm @@ -0,0 +1,830 @@ +; L0014.asm +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0014Section",ROMX +;--------------------------------------------------------------------- + +L0014_Contents:: + DW L0014_Load + DW L0014_Init + DW L0014_Check + DW L0014_Map + +dialog: +haiku_warn_gtx: + INCBIN "Data/Dialog/IntroHaiku/haiku_warn.gtx" +haiku_askOkay_gtx: + INCBIN "Data/Dialog/IntroHaiku/haiku_askOkay.gtx" +quatrain_gtx: + INCBIN "Data/Dialog/IntroHaiku/quatrain.gtx" +haiku_goAhead_gtx: + INCBIN "Data/Dialog/IntroHaiku/haiku_goAhead.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0014_Load: + DW ((L0014_LoadFinished - L0014_Load2)) ;size +L0014_Load2: + call ParseMap + + ;load in tiles used for sprite ship + ;bg tiles 1386-1389 to Bank 0 100-103 + ldio a,[curROMBank] + push af + ld a,BANK(BGTiles1024) + call SetActiveROM + + xor a ;bank 0 + ld c,4 ;number of tiles to copy + ld de,$8000+1600 + ld hl,BGTiles1024 + (1386-1024)*16 + call VMemCopy + pop af + call SetActiveROM + ret + +L0014_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0014_Map: +INCBIN "Data/Levels/L0014_intro_haiku1.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +CRATERINDEX EQU 3 +RADARINDEX EQU 50 +CRACKMIDINDEX EQU 81 +CRACKTOPINDEX EQU 82 +QUATRAININDEX EQU 107 +SOLDIERINDEX EQU 108 +IAMBICINDEX EQU 109 +LAVAINDEX EQU 74 + +VAR_RADAR EQU 0 +VAR_CRACK_TOP EQU 1 +VAR_CRACK_BOTTOM EQU 2 +VAR_DELAY EQU 3 +VAR_LAVA EQU 4 +VAR_METASPRITE EQU 5 ;5-9 + +STATE_CROSSCRACK EQU 0 +STATE_BOMBER1 EQU 2 +STATE_BOMBER2 EQU 3 +STATE_LAVA EQU 4 +STATE_LAVA2 EQU 5 +STATE_LAVA3 EQU 6 +STATE_DIALOG2_1 EQU 7 +STATE_DIALOG2_2 EQU 8 +STATE_DIALOG2_3 EQU 9 +STATE_DIALOG_WAIT EQU 10 +STATE_NORMAL EQU 11 + + +L0014_Init: + DW ((L0014_InitFinished - L0014_Init2)) ;size +L0014_Init2: +;ld a,STATE_NORMAL +;ldio [mapState],a + + ld hl,$0014 + call SetJoinMap + + ld hl,$0014 + call SetRespawnMap + + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(moon_base_haiku_gbm) + ld hl,moon_base_haiku_gbm + call InitMusic + + ld a,[bgTileMap+RADARINDEX] + ld [levelVars+VAR_RADAR],a + + ld a,[bgTileMap+LAVAINDEX] + ld [levelVars+VAR_LAVA],a + + ;----soldiers do nothing + ld bc,classB12Soldier + ld de,classDoNothing + call ChangeClass + + ;fill in hole at $d190, $d191 if not occupied + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d190 + ld a,[hl] + or a + jr nz,.firstFilled + ld [hl],45 +.firstFilled + inc hl + ld a,[hl] + or a + jr nz,.secondFilled + ld [hl],46 +.secondFilled + + ld a,10 + ld [camera_i],a + ld [camera_j],a + ld a,1 + ld [mapLeft],a + ld a,1 + ld [mapTop],a + + ld a,10 + ld [levelVars + VAR_CRACK_TOP],a + inc a + ld [levelVars + VAR_CRACK_BOTTOM],a + + ldio a,[mapState] + cp STATE_CROSSCRACK + jr nz,.checkBomber1 + + ld a,1 + ld [heroesIdle],a + call ((.createCompanions-L0014_Init2)+levelCheckRAM) + jr .createBomber1 + +.checkBomber1 + cp STATE_BOMBER1 + jr nz,.checkBomber2 + + ld a,1 + ld [heroesIdle],a + +.createBomber1 + ld bc,$0202 + ld d,100 + ld e,6 + ld hl,levelVars+VAR_METASPRITE + ld a,220 + ld [metaSprite_x],a + ld a,52 + ld [metaSprite_y],a + call CreateMetaSprite + ret + +.checkBomber2 + cp STATE_BOMBER2 + jr nz,.checkLava1 + + ld a,1 + ld [heroesIdle],a + call ((.createCompanions-L0014_Init2)+levelCheckRAM) + ld bc,$0202 + ld d,100 + ld e,6 + ld hl,levelVars+VAR_METASPRITE + ld a,220 + ld [metaSprite_x],a + ld a,88 + ld [metaSprite_y],a + call CreateMetaSprite + ret + +.checkLava1 + ;cp STATE_LAVA1 + ;jr nz,.checkLava2 + +.checkLava2 + ;cp STATE_LAVA2 + ;jr nz,.checkLava3 + +.checkLava3 + ;cp STATE_LAVA3 + cp STATE_NORMAL + jr z,.checkNormal + + ld a,1 + ld [heroesIdle],a + +.checkNormal + ld a,STATE_NORMAL + ldio [mapState],a ;be sure + + ld bc,$1614 + ld de,0 + ld hl,$2c00 + call BlitMap + call SetBGSpecialFlags + ret + +.createCompanions + ld c,QUATRAININDEX + ld hl,$d48d + call CreateInitAndDrawObject + ld hl,$d306 + call SetActorDestLoc + ld c,IAMBICINDEX + ld hl,$d50d + call CreateInitAndDrawObject + ld hl,$d387 + call SetActorDestLoc + ld bc,classQuatrain + ld de,classActor + call ChangeClass + ret + +L0014_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0014_Check: + DW ((L0014_CheckFinished - L0014_Check2)) ;size +L0014_Check2: + + ;if any soldiers are killed change them to class B12 Soldier + ld c,SOLDIERINDEX + call GetFirst + or a + jr z,.animateRadar + + call GetNextObject + or a + jr nz,.animateRadar + +.soldierDefend + ld bc,classDoNothing + ld de,classB12Soldier + call ChangeClass + + ld bc,(GROUP_HERO<<8) | GROUP_MONSTERB + xor a ;enemies + call SetFOF + +.animateRadar + ;animate the radar tower (index 47-52) based on timer/8 + ldio a,[updateTimer] + rrca ;(t/8)*6 == t/4*3 + and %00000110 + ld b,a + add b + add b + ld b,a + ld a,[levelVars+VAR_RADAR] + add b + + ld hl,bgTileMap + RADARINDEX + ld c,6 +.animateTower + ld [hl+],a + inc a + dec c + jr nz,.animateTower + + ;animate the lava on updateTimer / 16 + ldio a,[updateTimer] + rlca + swap a + and %00000011 + ld b,a + ld a,[levelVars+VAR_LAVA] + add b + ld [bgTileMap + LAVAINDEX],a + + ldio a,[mapState] + cp STATE_NORMAL + jr nz,.checkDialogWait + + ;normal + xor a + ld [heroesIdle],a + + ret + +.checkDialogWait + cp STATE_DIALOG_WAIT + jr nz,.checkCrossCrack + + call CheckDialogContinue + or a + ret z + + ldio a,[mapState+1] + ldio [mapState],a + ret + +.checkCrossCrack + cp STATE_CROSSCRACK + jr nz,.checkBomber1 + + ld c,QUATRAININDEX + call GetFirst + call IsActorAtDest + or a + ret z + + ld c,IAMBICINDEX + call GetFirst + call IsActorAtDest + or a + ret z + + ld de,((.setBomber1-L0014_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,haiku_warn_gtx + call ShowDialogAtBottomNoWait + + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ld a,STATE_BOMBER1 + ldio [mapState+1],a + ret + +.checkDialog2 + cp STATE_DIALOG2_1 + jr nz,.checkBomber1 + + ret + +.setBomber1 + call ClearDialog + ld a,STATE_BOMBER1 + ldio [mapState],a + +.checkBomber1 + cp STATE_BOMBER1 + jr nz,.checkBomber2 + + ld de,0 + call SetDialogSkip + + ;bomber1 + ld hl,levelVars+VAR_METASPRITE ;bomber metasprite + ld bc,$fc00 ;x -= 4 + call ScrollMetaSprite + + ld a,[levelVars+VAR_METASPRITE+1] ;get x pos of first sprite + ld h,((spriteOAMBuffer>>8) & $ff) + ld l,a + inc hl + ld a,[hl] + cp 224 + jr nz,.bomber1StillActive + + ;reset bomber to second fly-by position + ld bc,$dc58 + ld hl,levelVars+VAR_METASPRITE + call SetMetaSpritePos + ld a,STATE_BOMBER2 + ldio [mapState],a + +.bomber1StillActive + cp 188 + jr nz,.afterBombSound1 + + ld hl,((.bombSound-L0014_Check2)+levelCheckRAM) + call PlaySound +.afterBombSound1 + + cp 88 + jr nz,.b1CheckPos2 + + ld a,20 + ld b,8 + call SetupFadeFromSaturated + call ((.explosion1 - L0014_Check2) + levelCheckRAM) + + ;create a 2x2 crater + ld a,MAPBANK + ldio [$ff70],a + + ld hl,$d30d + ld a,CRATERINDEX + ld [hl+],a + inc a + ld [hl+],a + inc a + ld hl,$d38d + ld [hl+],a + inc a + ld [hl+],a + ret + +.b1CheckPos2 + cp 64 + ret nz + call ((.explosion1 - L0014_Check2) + levelCheckRAM) + ld c,QUATRAININDEX + call GetFirst + ld hl,$d586 + call SetActorDestLoc + ld c,IAMBICINDEX + call GetFirst + ld hl,$d607 + call SetActorDestLoc + ret + + +.checkBomber2 + cp STATE_BOMBER2 + jr nz,.checkLava + + ;bomber2 + ld hl,levelVars+VAR_METASPRITE ;bomber metasprite + ld bc,$fc00 ;x -= 4 + call ScrollMetaSprite + + ld a,[levelVars+VAR_METASPRITE+1] ;get x pos of first sprite + ld h,((spriteOAMBuffer>>8) & $ff) + ld l,a + inc hl + ld a,[hl] + cp 224 + jr nz,.bomber2StillActive + + ;kill bomber + ld hl,levelVars+VAR_METASPRITE + call FreeMetaSprite + + ld c,QUATRAININDEX + call GetFirst + ld hl,$d888 ;run in circles + call SetActorDestLoc + ld c,IAMBICINDEX + call GetFirst + ld hl,$d888 + call SetActorDestLoc + + ld a,STATE_LAVA + ldio [mapState],a + +.bomber2StillActive + cp 144 + jr nz,.afterBombSound2 + ld hl,((.bombSound-L0014_Check2)+levelCheckRAM) + call PlaySound +.afterBombSound2 + + cp 44 + jr nz,.checkPos20 + + ld a,20 + ld b,8 + call SetupFadeFromSaturated + call ((.explosion2 - L0014_Check2) + levelCheckRAM) + call ((.drawCrack1 - L0014_Check2) + levelCheckRAM) + ret + +.checkPos20 + cp 20 + ret nz + call ((.explosion2 - L0014_Check2) + levelCheckRAM) + ld c,QUATRAININDEX + call GetFirst + ld hl,$d306 + call SetActorDestLoc + ld c,IAMBICINDEX + call GetFirst + ld hl,$d387 + call SetActorDestLoc + ret + +.checkLava + cp STATE_LAVA + jr nz,.checkLava2 + + ;extend crack to top and bottom + ld hl,levelVars + VAR_DELAY + dec [hl] + ret nz + + ld a,[updateTimer] + and %1000 + jr nz,.afterQuakeSound1 + ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) + call PlaySound +.afterQuakeSound1 + + ld a,[levelVars + VAR_CRACK_TOP] + or a + jr nz,.crackNotDone + + ld a,[levelVars + VAR_CRACK_BOTTOM] + cp 19 + jr nz,.crackNotDone + + ld a,30 + ld [levelVars + VAR_DELAY],a + + ld a,STATE_LAVA2 ;crack has extended + ldio [mapState],a + ret + +.crackNotDone + ld a,[levelVars + VAR_CRACK_TOP] + or a + jr z,.afterCheckTop + + dec a + ld [levelVars + VAR_CRACK_TOP],a + +.afterCheckTop + ld a,[levelVars + VAR_CRACK_BOTTOM] + cp 19 + jr z,.afterCheckBottom + + inc a + ld [levelVars + VAR_CRACK_BOTTOM],a + +.afterCheckBottom + call ((.drawCrack1 - L0014_Check2) + levelCheckRAM) + ret + +.checkLava2 + cp STATE_LAVA2 + jr nz,.checkLava3 + + ld a,10 + ldio [jiggleDuration],a + + ld a,[updateTimer] + and %1000 + jr nz,.afterQuakeSound2 + ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) + call PlaySound +.afterQuakeSound2 + + ld hl,levelVars + VAR_DELAY + dec [hl] + ret nz + + ;blit the second stage of lava to the screen + call ((.scootObjects - L0014_Check2) + levelCheckRAM) + ld bc,$1614 + ld de,0 + ld hl,$1600 + call BlitMap + call SetBGSpecialFlags + + ld a,30 + ld [levelVars + VAR_DELAY],a + + ld a,STATE_LAVA3 + ldio [mapState],a + + ret + +.checkLava3 + cp STATE_LAVA3 + jr nz,.checkDialog2_1 + + ld a,10 + ldio [jiggleDuration],a + + ld a,[updateTimer] + and %1000 + jr nz,.afterQuakeSound3 + ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) + call PlaySound +.afterQuakeSound3 + + ld hl,levelVars + VAR_DELAY + dec [hl] + ret nz + + ;blit the third stage of lava to the screen + call ((.scootObjects - L0014_Check2) + levelCheckRAM) + ld bc,$1614 + ld de,0 + ld hl,$2c00 + call BlitMap + call SetBGSpecialFlags + + ld c,QUATRAININDEX + call GetFirst + ld hl,$d403 + call SetActorDestLoc + ld c,IAMBICINDEX + call GetFirst + ld hl,$d502 + call SetActorDestLoc + + ld a,30 + ld [levelVars + VAR_DELAY],a + + ld a,STATE_DIALOG2_1 + ldio [mapState],a + + ret + +.checkDialog2_1 + cp STATE_DIALOG2_1 + jr nz,.checkDialog2_2 + + ld de,((.setNormal-L0014_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,haiku_askOkay_gtx + call ShowDialogAtBottomNoWait + + ld a,STATE_DIALOG2_2 + ldio [mapState+1],a + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ret + +.checkDialog2_2 + cp STATE_DIALOG2_2 + jr nz,.checkDialog2_3 + + call SetSpeakerToFirstHero + ld de,quatrain_gtx + ld c,QUATRAININDEX + call ShowDialogAtTopNoWait + + ld a,STATE_DIALOG2_3 + ldio [mapState+1],a + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ret + +.checkDialog2_3 + call SetSpeakerToFirstHero + ld de,haiku_goAhead_gtx + call ShowDialogAtBottomNoWait + + ld a,STATE_NORMAL + ldio [mapState+1],a + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ret + +.setNormal + call ClearDialog + ld a,STATE_NORMAL + ldio [mapState],a + ret + +.explosion1 + ;drop the bomb + ld bc,$0404 + ld de,$0a01 + ld hl,$d28c + call CreateBigExplosion + ld hl,((.bigExplosionSound-L0014_Check2)+levelCheckRAM) + call PlaySound + + ld a,10 + ldio [jiggleDuration],a + ret + +.explosion2 + ;drop the bomb + ld bc,$0404 + ld de,$0a01 + ld hl,$d488 + call CreateBigExplosion + ld hl,((.bigExplosionSound-L0014_Check2)+levelCheckRAM) + call PlaySound + + ld a,10 + ldio [jiggleDuration],a + ret + +.drawCrack1 + call ((.drawCrackTop - L0014_Check2) + levelCheckRAM) + call ((.drawCrackMid1 - L0014_Check2) + levelCheckRAM) + call ((.drawCrackBottom - L0014_Check2) + levelCheckRAM) + ld a,3 + ld [levelVars + VAR_DELAY],a + ld a,6 + ldio [jiggleDuration],a + ret + +.drawCrackTop + ld h,9 ;x coord + ld a,[levelVars + VAR_CRACK_TOP] + ld l,a + call ConvertXYToLocHL + + ld a,MAPBANK + ldio [$ff70],a + + ld a,CRACKTOPINDEX + ld [hl+],a + inc a + ld [hl],a + ret + +.drawCrackMid1 + ld h,9 ;x coord + ld a,[levelVars + VAR_CRACK_TOP] + ld l,a + ld c,a + inc l + call ConvertXYToLocHL + + ld a,[levelVars + VAR_CRACK_BOTTOM] + sub c + ret z + dec a + ret z + ld c,a ;c is (bottom_y - top_y) - 1 (is >= 0) + + ld a,MAPBANK + ldio [$ff70],a + ld de,128 ;level pitch + +.drawMid1Loop + ld a,CRACKMIDINDEX + ld [hl+],a + dec a + ld [hl-],a + add hl,de + dec c + jr nz,.drawMid1Loop + ret + +.drawCrackBottom + ld h,9 ;x coord + ld a,[levelVars + VAR_CRACK_BOTTOM] + ld l,a + call ConvertXYToLocHL + + ld a,MAPBANK + ldio [$ff70],a + + ld a,CRACKTOPINDEX + 2 + ld [hl+],a + inc a + ld [hl],a + ret + +.scootObjects + ;scoots everyone < half left, >half right + ;loop through 255 objects + ld a,OBJLISTBANK + ldio [$ff70],a + ld b,((objExists>>8) & $ff) + ld c,1 +.scootLoop + ld a,[bc] + or a + jr z,.nextObj + + ld a,c + push bc + call IndexToPointerDE + call GetFacing + ld c,a + call RemoveFromMap + call GetCurLocation + call ConvertLocHLToXY + ld a,h ;x coord + cp 9 ;< half? + jr nc,.greaterThanHalf + dec h + jr .setNewLoc +.greaterThanHalf + inc h +.setNewLoc + call ConvertXYToLocHL + call SetCurLocation + call GetClass + ld b,METHOD_DRAW + call CallMethod + + ld a,OBJLISTBANK + ldio [$ff70],a + pop bc +.nextObj + inc c + jr nz,.scootLoop + ret + +.bombSound + DB 1,$1f,$80,$f5,$80,$86 + +.bigExplosionSound + DB 4,$00,$f3,$81,$80 + +.earthquakeSound + DB 4,$00,$f7,$67,$80 + + +L0014_CheckFinished: +PRINT "0014 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0014_LoadFinished - L0014_Load2) +PRINT " / " +PRINT (L0014_InitFinished - L0014_Init2) +PRINT " / " +PRINT (L0014_CheckFinished - L0014_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0015.asm b/Source/Levels/L0015.asm new file mode 100644 index 0000000..3eb7747 --- /dev/null +++ b/Source/Levels/L0015.asm @@ -0,0 +1,342 @@ +; L0015.asm +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0015Section",ROMX +;--------------------------------------------------------------------- + +L0015_Contents:: + DW L0015_Load + DW L0015_Init + DW L0015_Check + DW L0015_Map + + +dialog: +soldier_how_gtx: + INCBIN "Data/Dialog/IntroBS/soldier_how.gtx" + +bs_likeButter_gtx: + INCBIN "Data/Dialog/IntroBS/bs_likeButter.gtx" + +soldier_yellow_gtx: + INCBIN "Data/Dialog/IntroBS/soldier_yellow.gtx" + +bs_slippery_gtx: + INCBIN "Data/Dialog/IntroBS/bs_slippery.gtx" + +guard_freeze_gtx: + INCBIN "Data/Dialog/IntroBS/guard_freeze.gtx" + +bs_actually_gtx: + INCBIN "Data/Dialog/IntroBS/bs_actually.gtx" + +guard_moveAlong_gtx: + INCBIN "Data/Dialog/IntroBS/guard_moveAlong.gtx" + + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0015_Load: + DW ((L0015_LoadFinished - L0015_Load2)) ;size +L0015_Load2: + call ParseMap + ret + +L0015_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0015_Map: +INCBIN "Data/Levels/L0015_intro_bs1.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_RADAR EQU 0 +VAR_SPEAKINGHERO EQU 1 + +RADARINDEX EQU 52 +GRUNTINDEX EQU 87 +B12SOLDIERINDEX EQU 88 + +STATE_INITIALDRAW EQU 0 +STATE_TALKSOLDIER1 EQU 1 +STATE_TALKSOLDIER2 EQU 2 +STATE_TALKSOLDIER3 EQU 3 +STATE_TALKSOLDIER4 EQU 4 +STATE_TALKGUARD1 EQU 5 +STATE_TALKGUARD2 EQU 6 +STATE_TALKGUARD3 EQU 7 +STATE_NORMAL EQU 8 +STATE_WAIT_DIALOG EQU 9 + +L0015_Init: + DW ((L0015_InitFinished - L0015_Init2)) ;size +L0015_Init2: + ld hl,$0015 + call SetJoinMap + + ld hl,$0015 + call SetRespawnMap + + ld a,BANK(bs_gbm) + ld hl,bs_gbm + call InitMusic + + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,[bgTileMap+RADARINDEX] + ld [levelVars+VAR_RADAR],a + + ld bc,classB12Soldier + ld de,classDoNothing + call ChangeClass + + ld bc,classCroutonGrunt + ld de,classDoNothing + call ChangeClass + ret + +L0015_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0015_Check: + DW ((L0015_CheckFinished - L0015_Check2)) ;size +L0015_Check2: + call ((.animateRadar-L0015_Check2)+levelCheckRAM) + + ldio a,[mapState] + cp STATE_NORMAL + jr nz,.checkInitialDraw + + ret + +.checkInitialDraw + cp STATE_INITIALDRAW + jr nz,.checkTalkSoldier1 + + ld a,STATE_TALKSOLDIER1 + ldio [mapState],a + ret + +.checkTalkSoldier1 + cp STATE_TALKSOLDIER1 + jr nz,.checkTalkSoldier2 + + call SetSpeakerToFirstHero + + ld de,soldier_how_gtx + ld c,B12SOLDIERINDEX + call ShowDialogAtTopNoWait + + ld de,((.endTalkSoldier-L0015_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKSOLDIER2 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + ret + +.checkTalkSoldier2 + cp STATE_TALKSOLDIER2 + jr nz,.checkTalkSoldier3 + + call SetSpeakerToFirstHero + ld de,bs_likeButter_gtx + call ShowDialogAtBottomNoWait + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKSOLDIER3 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + ret + +.checkTalkSoldier3 + cp STATE_TALKSOLDIER3 + jr nz,.checkTalkSoldier4 + + ld de,soldier_yellow_gtx + ld c,B12SOLDIERINDEX + call ShowDialogAtTopNoWait + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKSOLDIER4 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + ret + +.checkTalkSoldier4 + cp STATE_TALKSOLDIER4 + jr nz,.checkTalkGuard1 + + call SetSpeakerToFirstHero + ld de,bs_slippery_gtx + call ShowDialogAtBottomNoWait + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKGUARD1 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + ret + +.endTalkSoldier + xor a + ld [heroesIdle],a + ld [allIdle],a + ld de,0 + call SetDialogSkip + call ClearDialog + ld a,STATE_TALKGUARD1 + ldio [mapState],a + ret + +.checkTalkGuard1 + cp STATE_TALKGUARD1 + jr nz,.checkTalkGuard2 + + ld a,[hero0_index] + call ((.checkHeroTalkToGuard-L0015_Check2)+levelCheckRAM) + ld a,[hero1_index] + call ((.checkHeroTalkToGuard-L0015_Check2)+levelCheckRAM) + ret + +.checkTalkGuard2 + cp STATE_TALKGUARD2 + jr nz,.checkTalkGuard3 + + ld a,[levelVars + VAR_SPEAKINGHERO] + ld c,a + call SetSpeakerFromHeroIndex + ld de,bs_actually_gtx + call ShowDialogAtBottomNoWait + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKGUARD3 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + + ret + +.checkTalkGuard3 + cp STATE_TALKGUARD3 + jr nz,.checkWaitDialog + + ld c,GRUNTINDEX + ld de,guard_moveAlong_gtx + call ShowDialogAtTopNoWait + + ld a,1 + ld [heroesIdle],a + ld a,STATE_NORMAL + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + + ret + +.endTalkGuard + ld de,0 + call SetDialogSkip + xor a + ld [heroesIdle],a + ld [allIdle],a + call ClearDialog + ld a,STATE_NORMAL + ldio [mapState],a + ret + +.checkWaitDialog + call CheckDialogContinue + or a + ret z + + xor a + ld [heroesIdle],a + + ldio a,[mapState+1] + ldio [mapState],a + ret + + ret + +.animateRadar + ;animate the radar tower (index 47-52) based on timer/8 + ldio a,[updateTimer] + rrca ;(t/8)*6 == t/4*3 + and %00000110 + ld b,a + add b + add b + ld b,a + ld a,[levelVars+VAR_RADAR] + add b + + ld hl,bgTileMap + RADARINDEX + ld c,6 +.animateTower + ld [hl+],a + inc a + dec c + jr nz,.animateTower + ret + +.checkHeroTalkToGuard + or a + ret z + ld c,a + call GetFirst + call GetCurZone + cp 2 + ret nz + + ld a,c + ld [levelVars + VAR_SPEAKINGHERO],a + call SetSpeakerFromHeroIndex + + ld de,guard_freeze_gtx + ld c,GRUNTINDEX + call ShowDialogAtTopNoWait + + pop bc ;adjust stack pos for dialog skip + ld de,((.endTalkGuard-L0015_Check2)+levelCheckRAM) + call SetDialogSkip + push bc + + ld a,1 + ld [heroesIdle],a + ld a,STATE_TALKGUARD2 + ldio [mapState+1],a + ld a,STATE_WAIT_DIALOG + ldio [mapState],a + ret + +L0015_CheckFinished: +PRINT "0015 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0015_LoadFinished - L0015_Load2) +PRINT " / " +PRINT (L0015_InitFinished - L0015_Init2) +PRINT " / " +PRINT (L0015_CheckFinished - L0015_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0103.asm b/Source/Levels/L0103.asm new file mode 100644 index 0000000..6ced9ea --- /dev/null +++ b/Source/Levels/L0103.asm @@ -0,0 +1,283 @@ +; L0103.asm east farm +; Generated 08.27.2000 by mlevel +; Modified 08.27.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +WATERINDEX EQU 12 +VAR_WATER EQU 0 + +STATE_NORMAL EQU 1 +STATE_TALKED1 EQU 2 +STATE_TALKED2 EQU 3 + + + +;--------------------------------------------------------------------- +SECTION "Level0103Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0103_shootinfast_gtx: + INCBIN "Data/Dialog/Talk/L0103_shootinfast.gtx" + +L0103_wrangling_gtx: + INCBIN "Data/Dialog/Talk/L0103_wrangling.gtx" + +L0103_bs_where_gtx: + INCBIN "Data/Dialog/Talk/L0103_bs_where.gtx" + +L0103_forest_gtx: + INCBIN "Data/Dialog/Talk/L0103_forest.gtx" + +L0103_bs_figures_gtx: + INCBIN "Data/Dialog/Talk/L0103_bs_figures.gtx" + +L0103_learn_gtx: + INCBIN "Data/Dialog/Talk/L0103_learn.gtx" + +L0103_honey_gtx: + INCBIN "Data/Dialog/Talk/L0103_honey.gtx" + +L0103_hero_honeyresponse_gtx: + INCBIN "Data/Dialog/Talk/L0103_hero_honeyresponse.gtx" + +L0103_gethoney_gtx: + INCBIN "Data/Dialog/Talk/L0103_gethoney.gtx" + +L0103_snakebitekit_gtx: + INCBIN "Data/Dialog/Talk/L0103_snakebitekit.gtx" + +L0103_seenyoubefore_gtx: + INCBIN "Data/Dialog/Talk/L0103_seenyoubefore.gtx" + + +L0103_Contents:: + DW L0103_Load + DW L0103_Init + DW L0103_Check + DW L0103_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0103_Load: + DW ((L0103_LoadFinished - L0103_Load2)) ;size +L0103_Load2: + call ParseMap + ret + +L0103_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0103_Map: +INCBIN "Data/Levels/L0103_green.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0103_Init: + DW ((L0103_InitFinished - L0103_Init2)) ;size +L0103_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + STDSETUPDIALOG + + ld bc,classCowboy + ld de,classCowboyTalker + call ChangeFirstClass + + ld a,STATE_NORMAL + ldio [mapState],a + + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call InitMusic + + ret + +L0103_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0103_Check: + DW ((L0103_CheckFinished - L0103_Check2)) ;size +L0103_Check2: + call ((.animateWater-L0103_Check2)+levelCheckRAM) + call ((.checkDialog-L0103_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_TALKED2 + ret nc + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ldio a,[mapState] + cp STATE_TALKED1 + jr z,.talkAboutHoney + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ld a,HERO_BS_FLAG + call ClassIndexIsHeroType + jr z,.shortVersion + + ld bc,ITEM_BSSHOOTFAST + call HasInventoryItem + jr nz,.shortVersion + + ld bc,ITEM_WRANGLING + call HasInventoryItem + jr nz,.giveUpgrade + + ;About wrangling iron + ld de,((.afterUpgradeDialog-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ld de,L0103_wrangling_gtx + call ShowDialogNPC + + ;Where's the wrangling iron? + ld de,L0103_bs_where_gtx + call ShowDialogHero + + ;under a bee hive + ld de,L0103_forest_gtx + call ShowDialogNPC + + ;Typical + ld de,L0103_bs_figures_gtx + call ShowDialogHero + jr .afterUpgradeDialog + +.giveUpgrade + ld de,((.afterLearnDialog-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ;How to shoot fast + ld de,L0103_learn_gtx + call ShowDialogNPC + +.afterLearnDialog + ld hl,bsUpgrades + set UPGRADE_BSSHOOTFAST,[hl] + + ld bc,ITEM_BSSHOOTFAST + call AddInventoryItem + + ld bc,ITEM_WRANGLING + call RemoveInventoryItem + jr .afterUpgradeDialog + +.shortVersion + ld de,((.afterUpgradeDialog-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ;"Jeb is my name" + ld de,L0103_shootinfast_gtx + call ShowDialogNPC + +.afterUpgradeDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + ld a,STATE_TALKED1 + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +.talkAboutHoney + ld bc,ITEM_SNAKEBITEKIT + call HasInventoryItem + jr nz,.hasSnakeBiteKit + + ld bc,ITEM_HONEY + call HasInventoryItem + jr nz,.hasHoney + + ld de,((.afterHoneyDialog-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ;I love honey + ld de,L0103_honey_gtx + call ShowDialogNPC + + ;Hero's response to honey lover + ld de,L0103_hero_honeyresponse_gtx + call ShowDialogHero + + ;Get me some honey + ld de,L0103_gethoney_gtx + call ShowDialogNPC + jr .afterHoneyDialog + +.hasSnakeBiteKit + ld de,((.afterHoneyDialog-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ;seen you before + ld de,L0103_seenyoubefore_gtx + call ShowDialogNPC + jr .afterHoneyDialog + +.hasHoney + ld de,((.giveKit-L0103_Check2)+levelCheckRAM) + call SetDialogSkip + + ;give snake bite kit + ld de,L0103_snakebitekit_gtx + call ShowDialogNPC + +.giveKit + ld bc,ITEM_HONEY + call RemoveInventoryItem + + ld bc,ITEM_SNAKEBITEKIT + call AddInventoryItem + +.afterHoneyDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + ld a,STATE_TALKED2 + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0103_CheckFinished: +PRINT "0103 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0103_LoadFinished - L0103_Load2) +PRINT " / " +PRINT (L0103_InitFinished - L0103_Init2) +PRINT " / " +PRINT (L0103_CheckFinished - L0103_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0104.asm b/Source/Levels/L0104.asm new file mode 100644 index 0000000..cdd2f8c --- /dev/null +++ b/Source/Levels/L0104.asm @@ -0,0 +1,62 @@ +; L0104.asm Spring +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0104Section",ROMX +;--------------------------------------------------------------------- + +L0104_Contents:: + DW L0104_Load + DW L0104_Init + DW L0104_Check + DW L0104_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0104_Load: + DW ((L0104_LoadFinished - L0104_Load2)) ;size +L0104_Load2: + call ParseMap + ret + +L0104_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0104_Map: +INCBIN "Data/Levels/L0104_spring.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0104_Init: + DW ((L0104_InitFinished - L0104_Init2)) ;size +L0104_Init2: + call UseAlternatePalette + ld a,ENV_RAIN + call SetEnvEffect + ret + +L0104_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0104_Check: + DW ((L0104_CheckFinished - L0104_Check2)) ;size +L0104_Check2: + ret + +L0104_CheckFinished: +PRINT "0104 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0104_LoadFinished - L0104_Load2) +PRINT " / " +PRINT (L0104_InitFinished - L0104_Init2) +PRINT " / " +PRINT (L0104_CheckFinished - L0104_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0105.asm b/Source/Levels/L0105.asm new file mode 100644 index 0000000..66388b9 --- /dev/null +++ b/Source/Levels/L0105.asm @@ -0,0 +1,107 @@ +;L0105.asm rainy forest w/hive & wrangling iron +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +HIVE_INDEX EQU 16 + +STATE_NORMAL EQU 1 +STATE_HIVEDESTROYED EQU 2 + +;--------------------------------------------------------------------- +SECTION "LevelsSection0105",ROMX +;--------------------------------------------------------------------- + +dialog: +L0105_hero_wrangling_gtx: + INCBIN "Data/Dialog/Talk/L0105_hero_wrangling.gtx" + +L0105_Contents:: + DW L0105_Load + DW L0105_Init + DW L0105_Check + DW L0105_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0105_Load: + DW ((L0105_LoadFinished - L0105_Load2)) ;size +L0105_Load2: + call ParseMap + ret + +L0105_LoadFinished: + +L0105_Map: +INCBIN "Data/Levels/L0105_path.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0105_Init: +;--------------------------------------------------------------------- + DW ((L0105_InitFinished - L0105_Init2)) ;size +L0105_Init2: + ld a,ENV_RAIN + call SetEnvEffect + + call State0To1 + + STDSETUPDIALOG + ret + +L0105_InitFinished: + + +;--------------------------------------------------------------------- +L0105_Check: +;--------------------------------------------------------------------- + DW ((L0105_CheckFinished - L0105_Check) - 2) ;size +L0105_Check2: + ldio a,[mapState] + cp STATE_HIVEDESTROYED + jr z,.done + + ;watch for hive being destroyed + ld a,MAPBANK + ldio [$ff70],a + ld hl,$dccb + ld a,[hl] + cp HIVE_INDEX + jr z,.done ;hive still there + + ;hive destroyed + ld de,((.afterDialog-L0105_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerToFirstHero + ld de,L0105_hero_wrangling_gtx + call ShowDialogAtBottom +.afterDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld bc,ITEM_WRANGLING + call AddInventoryItem + + ld a,STATE_HIVEDESTROYED + ldio [mapState],a + +.done + ret +L0105_CheckFinished: + + +PRINT " 0105 Level Check Size: " +PRINT (L0105_CheckFinished - L0105_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0106.asm b/Source/Levels/L0106.asm new file mode 100644 index 0000000..74c7757 --- /dev/null +++ b/Source/Levels/L0106.asm @@ -0,0 +1,148 @@ +;L0106.asm +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_TALKED EQU 2 + +;--------------------------------------------------------------------- +SECTION "LevelsSection0106",ROMX +;--------------------------------------------------------------------- + +dialog: +L0106_heysonny_gtx: + INCBIN "Data/Dialog/Talk/L0106_heysonny.gtx" + +L0106_hero_seethem_gtx: + INCBIN "Data/Dialog/Talk/L0106_hero_seethem.gtx" + +L0106_sure_gtx: + INCBIN "Data/Dialog/Talk/L0106_sure.gtx" + +L0106_headnorth_gtx: + INCBIN "Data/Dialog/Talk/L0106_headnorth.gtx" + +L0106_Contents:: + DW L0106_Load + DW L0106_Init + DW L0106_Check + DW L0106_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0106_Load: + DW ((L0106_LoadFinished - L0106_Load2)) ;size +L0106_Load2: + call ParseMap + ret + +L0106_LoadFinished: + +L0106_Map: +INCBIN "Data/Levels/L0106_path.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0106_Init: +;--------------------------------------------------------------------- + DW ((L0106_InitFinished - L0106_Init2)) ;size +L0106_Init2: + STDSETUPDIALOG + + ;reset state if bridge not crossed yet + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$5c] ;triling grove + or a + jr nz,.afterReset + ld a,1 + ldio [mapState],a +.afterReset + + ld a,ENV_RAIN + call SetEnvEffect + ret + +L0106_InitFinished: + + +;--------------------------------------------------------------------- +L0106_Check: +;--------------------------------------------------------------------- + DW ((L0106_CheckFinished - L0106_Check) - 2) ;size +L0106_Check2: + call ((.checkHermitDialog-L0106_Check2)+levelCheckRAM) + ret + +.checkHermitDialog + ldio a,[mapState] + cp STATE_TALKED + jr c,.dialogOkay + + ld a,1 + call DisableDialogBalloons + ret + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ld de,((.afterDialog-L0106_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ;Hey Sonny + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0106_heysonny_gtx + call ShowDialogAtTop + call ClearDialog + + ;Seen 'em? + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + ld de,L0106_hero_seethem_gtx + call ShowDialogAtBottom + call ClearDialog + + ;Sure + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0106_sure_gtx + call ShowDialogAtTop + + ;Head north + ld de,L0106_headnorth_gtx + call ShowDialogAtTop + +.afterDialog + call ClearDialog + + call MakeNonIdle + ld a,STATE_TALKED + ldio [mapState],a + + xor a + ld [dialogNPC_speakerIndex],a + ret + +L0106_CheckFinished: + + +PRINT " 0106 Level Check Size: " +PRINT (L0106_CheckFinished - L0106_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0107.asm b/Source/Levels/L0107.asm new file mode 100644 index 0000000..90fc9f2 --- /dev/null +++ b/Source/Levels/L0107.asm @@ -0,0 +1,599 @@ +;L0107.asm first landing +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Gfx.inc" + +GATE_INDEX EQU 10 +LIGHTINDEX EQU 48 +PURPLE_INDEX EQU 55 +BLUE_INDEX EQU 56 +YELLOW_INDEX EQU 57 +BA_INDEX EQU 58 +BS_INDEX EQU 59 +LASER_INDEX EQU 60 + +VAR_LIGHT EQU 0 +VAR_SPEAKING_HERO EQU 1 + +STATE_INITIALUPDATE EQU 1 +STATE_MISSION EQU 2 +STATE_WAITPANSIES EQU 3 +STATE_WAITGATE EQU 4 +STATE_WAITRETURN EQU 5 + +;referenced in L1401 lz_brokenwall_bg +STATE_NORMAL EQU 6 + +EXPORT bigLaserSound +EXPORT disappearSound +EXPORT closeGateSound + + +;--------------------------------------------------------------------- +SECTION "LevelsSection1",ROMX,BANK[MAP0ROM] +;--------------------------------------------------------------------- + +L0107_Contents:: + DW L0107_Load + DW L0107_Init + DW L0107_Check + DW L0107_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0107_Load: + DW ((L0107_LoadFinished - L0107_Load)-2) ;size +L0107_Load2: + call ParseMap + ret + +L0107_LoadFinished: + + +L0107_Map: +INCBIN "Data/Levels/L0107_landing.lvl" + +dialog: +hero_checkgate_gtx: + INCBIN "Data/Dialog/landing/hero_checkgate.gtx" + +guard_dontcomecloser_gtx: + INCBIN "Data/Dialog/landing/guard_dontcomecloser.gtx" + +hero_whoareyou_gtx: + INCBIN "Data/Dialog/landing/hero_whoareyou.gtx" + +guard_pansies_gtx: + INCBIN "Data/Dialog/landing/guard_pansies.gtx" + +hero_move_gtx: + INCBIN "Data/Dialog/landing/hero_move.gtx" + +guard_notpossible_gtx: + INCBIN "Data/Dialog/landing/guard_notpossible.gtx" + +hero_whatever_gtx: + INCBIN "Data/Dialog/landing/hero_whatever.gtx" + +guard_really_gtx: + INCBIN "Data/Dialog/landing/guard_really.gtx" + +bs_absolutely_gtx: + INCBIN "Data/Dialog/landing/bs_absolutely.gtx" + +guard_yeah_gtx: + INCBIN "Data/Dialog/landing/guard_yeah.gtx" + +hero_closedgate_gtx: + INCBIN "Data/Dialog/landing/hero_closedgate.gtx" + +hero_report_gtx: + INCBIN "Data/Dialog/landing/hero_report.gtx" + +bs_tookkey_gtx: + INCBIN "Data/Dialog/landing/bs_tookkey.gtx" + +ba_whataboutspare_gtx: + INCBIN "Data/Dialog/landing/ba_whataboutspare.gtx" + +bs_wasspare_gtx: + INCBIN "Data/Dialog/landing/bs_wasspare.gtx" + +ba_guns_gtx: + INCBIN "Data/Dialog/landing/ba_guns.gtx" + +bs_finelotofgood_gtx: + INCBIN "Data/Dialog/landing/bs_finelotofgood.gtx" + +bs_cool_gtx: + INCBIN "Data/Dialog/landing/bs_cool.gtx" + +L0107_Init: + DW ((L0107_InitFinished - L0107_Init)-2) ;size +L0107_Init2: +;ld a,STATE_NORMAL +;ldio [mapState],a + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + ld a,BANK(dialog) + ld [dialogBank],a + + call SetPressBDialog + + ;ld a,ENV_WINDYSNOW + ;call SetEnvEffect + +.ready + ;make pansies inactive? + ldio a,[mapState] + cp STATE_WAITGATE + jr nc,.afterInactiveCheck + + ld bc,classPansy + ld de,classDoNothing + call ChangeClass + +.afterInactiveCheck + ldio a,[mapState] + cp STATE_NORMAL + jr z,.removeTrees + +.close + call (.closeGate + (levelCheckRAM-L0107_Init2)) + jr .afterClose + +.removeTrees + ;clear the bushes the appomattox shot out & the pansies + ld a,MAPBANK + ld [$ff70],a + xor a + ld hl,$d109 + ld [hl],a + ld hl,$d149 + ld [hl+],a + ld [hl],a + ld hl,$d189 + ld [hl+],a + ld [hl],a + ld hl,$d209 + ld [hl+],a + ld [hl],a + ld hl,$d249 + ld [hl],a + ld hl,$d24a + ld [hl],a + ld hl,$d28a + ld [hl],a + +.afterClose + ldio a,[mapState] + cp STATE_WAITRETURN + jr c,.afterDeletePansies + + ld bc,classPansy + call DeleteObjectsOfClass + +.afterDeletePansies + ret + +.closeGate + ld a,MAPBANK + ld [$ff70],a + ld hl,$d049 + ld a,GATE_INDEX + ld [hl+],a + inc a + ld [hl],a + ld hl,$d089 + inc a + ld [hl+],a + inc a + ld [hl],a + ret +L0107_InitFinished: + + +L0107_Check: + DW ((L0107_CheckFinished - L0107_Check) - 2) ;size +L0107_Check2: + call ((.animateLandingLights-L0107_Check2)+levelCheckRAM) + VECTORTOSTATE ((.stateTable-L0107_Check2)+levelCheckRAM) + +.stateTable + DW ((.state_initialUpdate-L0107_Check2)+levelCheckRAM) + DW ((.state_initialUpdate-L0107_Check2)+levelCheckRAM) + DW ((.state_mission-L0107_Check2)+levelCheckRAM) + DW ((.state_waitPansies-L0107_Check2)+levelCheckRAM) + DW ((.state_waitGate-L0107_Check2)+levelCheckRAM) + DW ((.state_waitReturn-L0107_Check2)+levelCheckRAM) + DW ((.state_normal-L0107_Check2)+levelCheckRAM) + +.state_initialUpdate + ld a,STATE_MISSION + ldio [mapState],a + ret + +.state_mission + ld a,5 + call Delay + + call SetSpeakerToFirstHero + ld de,((.afterStateMissionDialog-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + ld de,hero_checkgate_gtx + call ShowDialogAtBottom +.afterStateMissionDialog + call ClearDialogSkipForward + call ClearDialog + call MakeNonIdle + ld a,STATE_WAITPANSIES + ldio [mapState],a + ret + +.state_waitPansies + ld a,1 ;skip second if first true + ld hl,((.checkSeePansies-L0107_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkSeePansies + ld c,a + call GetFirst + call GetCurZone + cp 5 + jr z,.seesPansies + + xor a ;return false + ret + +.seesPansies + ld a,c + ld [levelVars+VAR_SPEAKING_HERO],a + + ld a,STATE_WAITGATE + ldio [mapState],a + + ;to get joystick right + ld de,((.afterChallengeDialog-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + call SetSpeakerFromHeroIndex + + ld c,YELLOW_INDEX + ld de,guard_dontcomecloser_gtx + call ShowDialogAtTop + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + ld de,hero_whoareyou_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + + ld c,YELLOW_INDEX + ld de,guard_pansies_gtx + call ShowDialogAtTop + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + ld de,hero_move_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + + ld c,YELLOW_INDEX + ld de,guard_notpossible_gtx + call ShowDialogAtTop + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + ld de,hero_whatever_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom +.afterChallengeDialog + call ClearDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + ld a,HERO_BS_FLAG + call ClassIndexIsHeroType + or a + jr z,.afterBS + + ld de,((.afterChallengeBSDialog-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + + ld c,PURPLE_INDEX + ld de,guard_really_gtx + call ShowDialogAtTop + + ld a,[levelVars+VAR_SPEAKING_HERO] + ld c,a + ld de,bs_absolutely_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + + ld c,PURPLE_INDEX + ld de,guard_yeah_gtx + call ShowDialogAtTop + +.afterChallengeBSDialog + ;set the pansies against each other + ld a,FOF_ENEMY + ld b,GROUP_MONSTERC + ld c,GROUP_MONSTERC + call SetFOF + + ;randomize their fire delays so they won't all shoot at once + ld a,YELLOW_INDEX + call (.randomizeAttackDelay - L0107_Check2) + levelCheckRAM + ld a,BLUE_INDEX + call (.randomizeAttackDelay - L0107_Check2) + levelCheckRAM + ld a,PURPLE_INDEX + call (.randomizeAttackDelay - L0107_Check2) + levelCheckRAM + +.afterBS + call ClearDialog + call ClearDialogSkipForward + ld bc,classDoNothing ;pansies become active + ld de,classPansy + call ChangeClass + call MakeNonIdle + + ld a,1 ;return true + ret + +.state_waitGate + ld a,1 ;skip second if first true + ld hl,((.checkSeeGate-L0107_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkSeeGate + ld c,a + call GetFirst + call GetCurZone + cp 8 + jr z,.seesGate + + xor a ;return false + ret + +.seesGate + call MakeIdle + + ld de,((.afterGateDialog-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + + ld de,hero_closedgate_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom +.afterGateDialog + call ClearDialog + call ClearDialogSkipForward + + call MakeNonIdle + + ld a,STATE_WAITRETURN + ldio [mapState],a + ret + +.state_waitReturn + ld a,1 ;skip second if first true + ld hl,((.checkZone8Occupied-L0107_Check2)+levelCheckRAM) + call CheckEachHero + or a + ret nz ;not clear of zone 8 + + ld a,1 ;skip second if first true + ld hl,((.checkAtAppomattox-L0107_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkZone8Occupied + ld c,a + call GetFirst + call GetCurZone + cp 8 + jr nz,.notInZone8 + + ld a,1 + ret + +.notInZone8 + cp 2 + jr nz,.notInZone8or2 + + ld a,1 + ret + +.notInZone8or2 + xor a + ret + +.checkAtAppomattox + ;at appomattox if on EXIT_U + ld c,a + call GetFirst + call GetCurZone + ld a,[hl] + and $f0 + cp (EXIT_U << 4) + jr z,.atAppx + + xor a + ret + +.atAppx + ;dialog + ld a,10 ;move camera over appomattox + ld [camera_i],a + ld a,12 + ld [camera_j],a + + ld a,1 + ld [heroesIdle],a + + push bc + ld bc,classPansy ;pansies inactive + ld de,classDoNothing + call ChangeClass + pop bc + + ld a,STATE_NORMAL + ldio [mapState],a + + ld de,((.afterReport-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + + ld de,hero_report_gtx + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + + ld c,BS_INDEX + ld de,bs_tookkey_gtx + call ShowDialogAtTop + + ld c,BA_INDEX + ld de,ba_whataboutspare_gtx + call ShowDialogAtBottom + + ld c,BS_INDEX + ld de,bs_wasspare_gtx + call ShowDialogAtTop + + ld c,BA_INDEX + ld de,ba_guns_gtx + call ShowDialogAtBottom + + ld c,BS_INDEX + ld de,bs_finelotofgood_gtx + call ShowDialogAtTop +.afterReport + call ClearDialog + call ClearDialogSkipForward + + call ((.blowOpenGate-L0107_Check2)+levelCheckRAM) + + ld de,((.afterCool-L0107_Check2)+levelCheckRAM) + call SetDialogSkip + ld c,BS_INDEX + ld de,bs_cool_gtx + call ShowDialogAtTop +.afterCool + call ClearDialog + call ClearDialogSkipForward + + ld bc,classDoNothing ;pansies become active + ld de,classPansy + call ChangeClass + + call MakeNonIdle + + ld a,1 + ret + +.state_normal + ret + +.blowOpenGate + ld c,LASER_INDEX + + ld b,7 +.laserLoop + ld a,%00001000 ;blue palette, heading north + ld [methodParamL],a + ld hl,$d2ca ;location + call CreateInitAndDrawObject ;make a laser + ld hl,bigLaserSound + call PlaySound + + push bc + ld b,2 + ld a,16 + call SetupFadeFromSaturated + pop bc + + ld a,5 ;15 + call Delay + ld a,%00001000 ;blue palette, heading north + ld [methodParamL],a + ld hl,$d2c9 ;location + call CreateInitAndDrawObject ;make a laser + ld hl,bigLaserSound + call PlaySound + + push bc + ld b,2 + ld a,16 + call SetupFadeFromSaturated + pop bc + + ld a,6 + call Delay + dec b + jr nz,.laserLoop + + ;ld a,5 ;15 + ;call Delay + + ld b,16 + ld a,28 + call SetupFadeFromSaturated + + ld a,30 + call Delay + ret + +.randomizeAttackDelay + ld c,a + call GetFirst +.randomizeLoop + or a + ret z + ld a,5 + call GetRandomNumZeroToN + call SetAttackDelay + call GetNextObject + jr .randomizeLoop + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0107_Check2)+levelCheckRAM) + call ((.animateLight-L0107_Check2)+levelCheckRAM) + call ((.animateLight-L0107_Check2)+levelCheckRAM) + call ((.animateLight-L0107_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0107_CheckFinished: + +arrowInfo: DS 5 +bsExists: DS 1 + +PRINT " 0107 Level Check Size: " +PRINT (L0107_CheckFinished - L0107_Check2) + 5 +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0108.asm b/Source/Levels/L0108.asm new file mode 100644 index 0000000..3aa2d02 --- /dev/null +++ b/Source/Levels/L0108.asm @@ -0,0 +1,148 @@ +; L0108.asm forest landing +; Generated 09.04.2000 by mlevel +; Modified 09.04.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 61 +VAR_LIGHT EQU 0 +VAR_SIGN EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0108Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0108_sign_gtx: + INCBIN "Data/Dialog/Talk/L0108_sign.gtx" + +L0108_Contents:: + DW L0108_Load + DW L0108_Init + DW L0108_Check + DW L0108_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0108_Load: + DW ((L0108_LoadFinished - L0108_Load2)) ;size +L0108_Load2: + call ParseMap + ret + +L0108_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0108_Map: +INCBIN "Data/Levels/L0108_forest_landing.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0108_Init: + DW ((L0108_InitFinished - L0108_Init2)) ;size +L0108_Init2: + STDSETUPDIALOG + + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + xor a + ld [levelVars+VAR_SIGN],a + ret + +L0108_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0108_Check: + DW ((L0108_CheckFinished - L0108_Check2)) ;size +L0108_Check2: + call ((.animateLandingLights-L0108_Check2)+levelCheckRAM) + call ((.checkSign-L0108_Check2)+levelCheckRAM) + ret + +.checkSign + ld a,1 + ld hl,((.heroAtSign-L0108_Check2)+levelCheckRAM) + call CheckEachHero + + ld hl,levelVars + VAR_SIGN + cp [hl] + jp z,((.afterResetSign-L0108_Check2)+levelCheckRAM) + + ld [hl],a + or a + jp z,((.afterResetSign-L0108_Check2)+levelCheckRAM) + + ;read sign + ld de,((.afterSignDialog-L0108_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + + call SetSpeakerFromHeroIndex + ld de,L0108_sign_gtx + call ShowDialogAtTop +.afterSignDialog + call ClearDialogSkipForward + call MakeNonIdle + +.afterResetSign + ret + +.heroAtSign + ld c,a + call GetFirst + call GetCurZone + cp 3 + jr z,.returnTrue + +.returnFalse + xor a + ret + +.returnTrue + ld a,1 + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0108_Check2)+levelCheckRAM) + call ((.animateLight-L0108_Check2)+levelCheckRAM) + call ((.animateLight-L0108_Check2)+levelCheckRAM) + call ((.animateLight-L0108_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0108_CheckFinished: +PRINT "0108 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0108_LoadFinished - L0108_Load2) +PRINT " / " +PRINT (L0108_InitFinished - L0108_Init2) +PRINT " / " +PRINT (L0108_CheckFinished - L0108_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0109.asm b/Source/Levels/L0109.asm new file mode 100644 index 0000000..babb623 --- /dev/null +++ b/Source/Levels/L0109.asm @@ -0,0 +1,59 @@ +; L0109.asm +; Generated 09.04.2000 by mlevel +; Modified 09.04.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0109Section",ROMX +;--------------------------------------------------------------------- + +L0109_Contents:: + DW L0109_Load + DW L0109_Init + DW L0109_Check + DW L0109_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0109_Load: + DW ((L0109_LoadFinished - L0109_Load2)) ;size +L0109_Load2: + call ParseMap + ret + +L0109_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0109_Map: +INCBIN "Data/Levels/L0109_mouse.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0109_Init: + DW ((L0109_InitFinished - L0109_Init2)) ;size +L0109_Init2: + ret + +L0109_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0109_Check: + DW ((L0109_CheckFinished - L0109_Check2)) ;size +L0109_Check2: + ret + +L0109_CheckFinished: +PRINT "0109 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0109_LoadFinished - L0109_Load2) +PRINT " / " +PRINT (L0109_InitFinished - L0109_Init2) +PRINT " / " +PRINT (L0109_CheckFinished - L0109_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0110.asm b/Source/Levels/L0110.asm new file mode 100644 index 0000000..72ddb3f --- /dev/null +++ b/Source/Levels/L0110.asm @@ -0,0 +1,59 @@ +; L0110.asm +; Generated 11.06.2000 by mlevel +; Modified 11.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0110Section",ROMX +;--------------------------------------------------------------------- + +L0110_Contents:: + DW L0110_Load + DW L0110_Init + DW L0110_Check + DW L0110_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0110_Load: + DW ((L0110_LoadFinished - L0110_Load2)) ;size +L0110_Load2: + call ParseMap + ret + +L0110_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0110_Map: +INCBIN "Data/Levels/L0110_mouse.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0110_Init: + DW ((L0110_InitFinished - L0110_Init2)) ;size +L0110_Init2: + ret + +L0110_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0110_Check: + DW ((L0110_CheckFinished - L0110_Check2)) ;size +L0110_Check2: + ret + +L0110_CheckFinished: +PRINT "0110 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0110_LoadFinished - L0110_Load2) +PRINT " / " +PRINT (L0110_InitFinished - L0110_Init2) +PRINT " / " +PRINT (L0110_CheckFinished - L0110_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0111.asm b/Source/Levels/L0111.asm new file mode 100644 index 0000000..60b3e1e --- /dev/null +++ b/Source/Levels/L0111.asm @@ -0,0 +1,60 @@ +; L0111.asm +; Generated 10.20.2000 by mlevel +; Modified 10.20.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0111Section",ROMX +;--------------------------------------------------------------------- + +L0111_Contents:: + DW L0111_Load + DW L0111_Init + DW L0111_Check + DW L0111_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0111_Load: + DW ((L0111_LoadFinished - L0111_Load2)) ;size +L0111_Load2: + call ParseMap + ret + + +L0111_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0111_Map: +INCBIN "Data/Levels/L0111_tower.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0111_Init: + DW ((L0111_InitFinished - L0111_Init2)) ;size +L0111_Init2: + ret + +L0111_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0111_Check: + DW ((L0111_CheckFinished - L0111_Check2)) ;size +L0111_Check2: + ret + +L0111_CheckFinished: +PRINT "0111 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0111_LoadFinished - L0111_Load2) +PRINT " / " +PRINT (L0111_InitFinished - L0111_Init2) +PRINT " / " +PRINT (L0111_CheckFinished - L0111_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0112.asm b/Source/Levels/L0112.asm new file mode 100644 index 0000000..4123f99 --- /dev/null +++ b/Source/Levels/L0112.asm @@ -0,0 +1,62 @@ +; L0112.asm hive entrance +; Generated 08.31.2000 by mlevel +; Modified 08.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0112Section",ROMX +;--------------------------------------------------------------------- + +L0112_Contents:: + DW L0112_Load + DW L0112_Init + DW L0112_Check + DW L0112_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0112_Load: + DW ((L0112_LoadFinished - L0112_Load2)) ;size +L0112_Load2: + call ParseMap + ret + +L0112_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0112_Map: +INCBIN "Data/Levels/L0112_hive_entrance.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0112_Init: + DW ((L0112_InitFinished - L0112_Init2)) ;size +L0112_Init2: + ld a,BANK(beehive_gbm) + ld hl,beehive_gbm + call InitMusic + ret + +L0112_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0112_Check: + DW ((L0112_CheckFinished - L0112_Check2)) ;size +L0112_Check2: + ret + +L0112_CheckFinished: +PRINT "0112 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0112_LoadFinished - L0112_Load2) +PRINT " / " +PRINT (L0112_InitFinished - L0112_Init2) +PRINT " / " +PRINT (L0112_CheckFinished - L0112_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0113.asm b/Source/Levels/L0113.asm new file mode 100644 index 0000000..63c03a5 --- /dev/null +++ b/Source/Levels/L0113.asm @@ -0,0 +1,427 @@ +; L0113.asm ship blows up battleground BA +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +CRATERINDEX EQU 30 + +;--------------------------------------------------------------------- +SECTION "Level0113Section",ROMX +;--------------------------------------------------------------------- + +L0113_Contents:: + DW L0113_Load + DW L0113_Init + DW L0113_Check + DW L0113_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0113_Load: + DW ((L0113_LoadFinished - L0113_Load2)) ;size +L0113_Load2: + call ParseMap + + ;load in tiles used for sprite ship + ;bg tiles 1454-1457 to Bank 0 100-189 + ldio a,[curROMBank] + push af + ld a,BANK(BGTiles1024) + call SetActiveROM + + xor a ;bank 0 + ld c,4 ;number of tiles to copy + ld de,$8000+1600 + ld hl,BGTiles1024 + 430*16 + call VMemCopy + pop af + call SetActiveROM + ret + +L0113_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0113_Map: +INCBIN "Data/Levels/L0113_intro_ba2.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +STATE_CREATE_BOMBER EQU 0 +STATE_BOMBER_RUN EQU 1 +STATE_EXPLOSION_STAGE1 EQU 2 +STATE_EXPLOSION_STAGE2 EQU 3 +STATE_EXPLOSION_STAGE3 EQU 4 +STATE_NORMAL EQU 5 + +VAR_DELAY EQU 0 +VAR_METASPRITE EQU 1 ;1-5 + +L0113_Init: + DW ((L0113_InitFinished - L0113_Init2)) ;size +L0113_Init2: + ld bc,((GROUP_MONSTERB<<8) | GROUP_HERO) + ld a,1 ;make soldiers friends with hero + call SetFOF + + ldio a,[mapState] + cp STATE_NORMAL + call z,((.removeShip-L0113_Init2) + levelCheckRAM) + + ret + +.removeShip + ;remove crouton ship from map + ld hl,$d1cf + ld c,4 + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld c,6 + ld hl,$d20e + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld hl,$d24e + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld hl,$d28e + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld hl,$d2ce + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld hl,$d30e + call ((.removeRow-L0113_Init2) + levelCheckRAM) + ld hl,$d34e + call ((.removeRow-L0113_Init2) + levelCheckRAM) + + ;add crater to map + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d20f + ld a,CRATERINDEX + ld [hl+],a + inc a + ld [hl+],a + ld [hl+],a + inc a + ld [hl+],a + + ld hl,$d24f + ld a,CRATERINDEX+3 + ld [hl+],a + xor a + ld [hl+],a + ld [hl+],a + ld a,CRATERINDEX+5 + ld [hl+],a + + ld hl,$d28f + ld a,CRATERINDEX+6 + ld [hl+],a + inc a + ld [hl+],a + ld [hl+],a + inc a + ld [hl+],a + + ret + +.removeRow + push bc + + ld a,MAPBANK + ldio [$ff70],a + + xor a +.removeRowLoop + ld [hl+],a + dec c + jr nz,.removeRowLoop + + pop bc + ret + +L0113_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0113_Check: + DW ((L0113_CheckFinished - L0113_Check2)) ;size +L0113_Check2: + + ldio a,[mapState] + cp STATE_NORMAL + jr nz,.checkCreateBomber + + ret + +.checkCreateBomber + cp STATE_CREATE_BOMBER + jr nz,.checkBomberRun + + ;create bomber + ld a,128 + ld [metaSprite_x],a + ld a,220 + ld [metaSprite_y],a + ld bc,$0202 + ld d,100 + ld e,5 + ld hl,levelVars+VAR_METASPRITE + call CreateMetaSprite + ld a,STATE_BOMBER_RUN + ldio [mapState],a + ret + +.checkBomberRun + cp STATE_BOMBER_RUN + jr nz,.checkExplosionStage1 + + ld bc,$00fc + ld hl,levelVars+VAR_METASPRITE + call ScrollMetaSprite + + ;get top sprite y coord + ld h,((spriteOAMBuffer>>8) & $ff) + ld a,[levelVars+VAR_METASPRITE+1] + ld l,a + ld a,[hl] + + ;play sound effect? + cp 144 + jr nz,.afterPlayShipSound + + ld hl,((shipSound-L0113_Check2) + levelCheckRAM) + call PlaySound + + ret + +.afterPlayShipSound + ;reached bombing position? + cp 44 + jr nz,.afterCheckBombPosition + + ;first explosion from bomb + ld a,5 + ld [bulletColor],a + ld bc,$0405 + ld de,$0a01 + ld hl,$d1ce + call CreateBigExplosion + ld a,20 + ld b,8 + call SetupFadeFromSaturated + ld hl,((bigExplosionSound-L0113_Check2) + levelCheckRAM) + call PlaySound + ld a,10 + ldio [jiggleDuration],a + ret + +.afterCheckBombPosition + ;off top of screen? + cp 240 ;wrapped around to bottom + ret nz + + ;remove bomber + ld hl,levelVars+VAR_METASPRITE + call FreeMetaSprite + + ld a,5 + ld [bulletColor],a + ld bc,$0405 + ld de,$0601 + ld hl,$d1ce + call CreateBigExplosion + ld a,20 + ld b,8 + call SetupFadeFromSaturated + ld hl,((bigExplosionSound-L0113_Check2) + levelCheckRAM) + call PlaySound + ld a,10 + ldio [jiggleDuration],a + + ld a,16 + ld [levelVars + VAR_DELAY],a + ld a,STATE_EXPLOSION_STAGE1 + ldio [mapState],a + ret + +.checkExplosionStage1 + cp STATE_EXPLOSION_STAGE1 + jr nz,.checkExplosionStage2 + + ld hl,levelVars+VAR_DELAY + ld a,[hl] + or a + jr z,.stage1explosion + dec [hl] + ret + +.stage1explosion + ld a,5 + ld [bulletColor],a + ld bc,$0405 + ld de,$0a04 + ld hl,$d1ce + call CreateBigExplosion + ld de,$0502 + call CreateBigExplosion + ld a,20 + ld b,8 + call SetupFadeFromSaturated + ld hl,((bigExplosionSound-L0113_Check2) + levelCheckRAM) + call PlaySound + ld a,10 + ldio [jiggleDuration],a + + ld a,30 + ld [levelVars + VAR_DELAY],a + ld a,STATE_EXPLOSION_STAGE2 + ldio [mapState],a + ret + +.checkExplosionStage2 + cp STATE_EXPLOSION_STAGE2 + jr nz,.checkExplosionStage3 + + ld hl,levelVars+VAR_DELAY + ld a,[hl] + or a + jr z,.stage2explosion + dec [hl] + ret + +.stage2explosion + ld a,5 + ld [bulletColor],a + ld bc,$0405 + ld de,$1001 + ld hl,$d1ce + call CreateBigExplosion + ld a,20 + ld b,8 + call SetupFadeFromSaturated + ld hl,((bigExplosionSound-L0113_Check2) + levelCheckRAM) + call PlaySound + ld a,10 + ldio [jiggleDuration],a + + ld a,20 + ld [levelVars + VAR_DELAY],a + ld a,STATE_EXPLOSION_STAGE3 + ldio [mapState],a + ret + +.checkExplosionStage3 + cp STATE_EXPLOSION_STAGE3 + ret nz + + ld hl,levelVars+VAR_DELAY + ld a,[hl] + or a + jr z,.stage3explosion + dec [hl] + ret + +.stage3explosion + ;remove crouton ship from map + ld hl,$d1cf + ld c,4 + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld c,6 + ld hl,$d20e + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld hl,$d24e + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld hl,$d28e + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld hl,$d2ce + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld hl,$d30e + call ((.removeRow-L0113_Check2) + levelCheckRAM) + ld hl,$d34e + call ((.removeRow-L0113_Check2) + levelCheckRAM) + + + ld a,5 + ld [bulletColor],a + ld bc,$0405 + ld de,$0804 + ld hl,$d1ce + call CreateBigExplosion + ld de,$1803 + call CreateBigExplosion + ld a,30 + call SetupFadeFromWhite + ;ld b,15 + ;call SetupFadeFromSaturated + ld hl,((bigExplosionSound-L0113_Check2) + levelCheckRAM) + call PlaySound + ld a,15 + ldio [jiggleDuration],a + ld a,1 + call Delay + + ;add crater to map + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d20f + ld a,30 + ld [hl+],a + inc a + ld [hl+],a + ld [hl+],a + inc a + ld [hl+],a + + ld hl,$d24f + ld a,33 + ld [hl+],a + xor a + ld [hl+],a + ld [hl+],a + ld a,35 + ld [hl+],a + + ld hl,$d28f + ld a,36 + ld [hl+],a + inc a + ld [hl+],a + ld [hl+],a + inc a + ld [hl+],a + + ld a,STATE_NORMAL + ldio [mapState],a + ret + +.removeRow + push bc + + ld a,MAPBANK + ldio [$ff70],a + + xor a +.removeRowLoop + ld [hl+],a + dec c + jr nz,.removeRowLoop + + pop bc + ret + +shipSound: + DB 1,$1f,$80,$f5,$80,$86 + +bigExplosionSound: + DB 4,$00,$f3,$81,$80 + +L0113_CheckFinished: +PRINT "0113 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0113_LoadFinished - L0113_Load2) +PRINT " / " +PRINT (L0113_InitFinished - L0113_Init2) +PRINT " / " +PRINT (L0113_CheckFinished - L0113_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0114.asm b/Source/Levels/L0114.asm new file mode 100644 index 0000000..54ddfd4 --- /dev/null +++ b/Source/Levels/L0114.asm @@ -0,0 +1,190 @@ +; L0114.asm haiku in moonbase tunnel +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0114Section",ROMX +;--------------------------------------------------------------------- + +L0114_Contents:: + DW L0114_Load + DW L0114_Init + DW L0114_Check + DW L0114_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0114_Load: + DW ((L0114_LoadFinished - L0114_Load2)) ;size +L0114_Load2: + call ParseMap + ret + +L0114_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0114_Map: +INCBIN "Data/Levels/L0114_intro_haiku2.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_PREVZONE EQU 0 +VAR_LIGHT EQU 1 + +LIGHTINDEX EQU 41 + +L0114_Init: + DW ((L0114_InitFinished - L0114_Init2)) ;size +L0114_Init2: + ld a,BANK(moon_base_haiku_gbm) + ld hl,moon_base_haiku_gbm + call InitMusic + + ;set default game palette to be bright green + ld hl,((.greenBright-L0114_Init2)+levelCheckRAM) + ld de,gamePalette + call CopyPalette32 + ld de,gamePalette+64 + call CopyPalette32 + ld de,fadeCurPalette+64 + call CopyPalette32 + ld de,fadeFinalPalette+64 + call CopyPalette32 + + xor a + ld [levelVars + VAR_PREVZONE],a + + ld a,[bgTileMap+LIGHTINDEX] ;tile index of first light + ld [levelVars+VAR_LIGHT],a + ret + +.greenBright +DW $0000, $1104, $2208, $3fef +DW $0000, $0005, $000f, $3fef +DW $0000, $2800, $3e00, $3fef +DW $0000, $0140, $03e0, $3fef +DW $0000, $2004, $2989, $3fef +DW $0000, $01c6, $03ef, $3fef +DW $0000, $00c8, $05ef, $3fef +DW $0000, $2009, $3d8e, $3fef + +L0114_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0114_Check: + DW ((L0114_CheckFinished - L0114_Check2)) ;size +L0114_Check2: + ;animate dice lights + ld a,[levelVars+VAR_LIGHT] + ld b,a + + ;slow red lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + ld hl,bgTileMap+LIGHTINDEX + ld [hl+],a + sub b + inc a + and %00000011 + add b + ld [hl+],a + + ;get my hero zone + ld a,[levelVars + VAR_PREVZONE] + ld b,a + ld h,((hero0_data>>8) & $ff) + ld a,[curHeroAddressL] + add HERODATA_INDEX + ld l,a + ld c,[hl] + call GetFirst ;sets up de + call GetCurZone + + ;get random number before branching + push af + ld a,%111 + call GetRandomNumMask + ld h,a + pop af + + cp 4 + jr nc,.darkZone + +.lightZone + ;1/8 chance of resetting to brighter palette + xor a + ld [levelVars + VAR_PREVZONE],a + + ld a,h ;the random number + or a + jr nz,.sameZone + + ld hl,((.greenDark-L0114_Check2)+levelCheckRAM) + ld de,fadeFinalPalette + call CopyPalette32 + ld hl,gamePalette + ld de,fadeCurPalette + call CopyPalette32 + ld a,32 + ld [fadeRange],a + + ld a,16 + call FadeInit + jr .sameZone + +.darkZone + cp b ;in a different zone than last time? + jr z,.sameZone + + ld [levelVars + VAR_PREVZONE],a ;yep + ;set palette to be black except for red color + ld hl,((.greenBlack-L0114_Check2)+levelCheckRAM) + ld de,fadeFinalPalette + call CopyPalette32 + ld a,32 + ld [fadeRange],a + ld a,40 + call FadeInit + +.sameZone + + ret + +.greenDark +DW $0000, $0882, $1104, $1de7 +DW $0000, $0005, $000f, $1de7 ;red stays +DW $0000, $1400, $1d00, $1de7 +DW $0000, $00a0, $01e0, $1de7 +DW $0000, $1002, $14c4, $1de7 +DW $0000, $00e3, $01e7, $1de7 +DW $0000, $0064, $00e7, $1de7 +DW $0000, $1004, $1cc7, $1de7 + +.greenBlack +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0005+$40, $000f+$40, $0060+$40 ;red stays +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0060+$40, $0060+$40, $0060+$40 +DW $0000, $0060+$40, $00a0+$40, $0060+$40 + +L0114_CheckFinished: +PRINT "0114 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0114_LoadFinished - L0114_Load2) +PRINT " / " +PRINT (L0114_InitFinished - L0114_Init2) +PRINT " / " +PRINT (L0114_CheckFinished - L0114_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0115.asm b/Source/Levels/L0115.asm new file mode 100644 index 0000000..240712d --- /dev/null +++ b/Source/Levels/L0115.asm @@ -0,0 +1,864 @@ +; L0115.asm BS sneaks in the crouton base +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0115Section",ROMX +;--------------------------------------------------------------------- + +L0115_Contents:: + DW L0115_Load + DW L0115_Init + DW L0115_Check + DW L0115_Map + +dialog: +brainiac_detectIntruder_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_detectIntruder.gtx" + +bs_segashuating_gtx: + INCBIN "Data/Dialog/IntroBS/bs_segashuating.gtx" + +brainiac_bringIt_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_bringIt.gtx" + +monitor_onlyCroutons_gtx: + INCBIN "Data/Dialog/IntroBS/monitor_onlyCroutons.gtx" + +bs_idea_gtx: + INCBIN "Data/Dialog/IntroBS/bs_idea.gtx" + +bs_presto_gtx: + INCBIN "Data/Dialog/IntroBS/bs_presto.gtx" + +bs_hangin1_gtx: + INCBIN "Data/Dialog/IntroBS/bs_hangin1.gtx" + +grunt_hangin2_gtx: + INCBIN "Data/Dialog/IntroBS/grunt_hangin2.gtx" + +bs_hangin3_gtx: + INCBIN "Data/Dialog/IntroBS/bs_hangin3.gtx" + +grunt_hangin4_gtx: + INCBIN "Data/Dialog/IntroBS/grunt_hangin4.gtx" + +bs_hangin5_gtx: + INCBIN "Data/Dialog/IntroBS/bs_hangin5.gtx" + +monitor_openDoor_gtx: + INCBIN "Data/Dialog/IntroBS/monitor_openDoor.gtx" + +brainiac_wait_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_wait.gtx" + +monitor_sorry_gtx: + INCBIN "Data/Dialog/IntroBS/monitor_sorry.gtx" + +brainiac_justClose_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_justClose.gtx" + +monitor_oneSecond_gtx: + INCBIN "Data/Dialog/IntroBS/monitor_oneSecond.gtx" + +brainiac_idiotz_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_idiotz.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0115_Load: + DW ((L0115_LoadFinished - L0115_Load2)) ;size +L0115_Load2: + call ParseMap + ret + +L0115_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0115_Map: +INCBIN "Data/Levels/L0115_intro_bs2.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +STATE_DETECT1 EQU 0 +STATE_DETECT2 EQU 1 +STATE_DETECT3 EQU 2 +STATE_PRESTO EQU 3 +STATE_HANGIN2 EQU 4 +STATE_HANGIN3 EQU 5 +STATE_HANGIN4 EQU 6 +STATE_HANGIN5 EQU 7 +STATE_MONITOR1 EQU 8 +STATE_WAIT_ALLBRAINIAC EQU 9 +STATE_MONITOR2 EQU 10 +STATE_MONITOR3 EQU 11 +STATE_MONITOR4 EQU 12 +STATE_MONITOR5 EQU 13 +STATE_NORMAL EQU 14 +STATE_WAIT_DIALOG EQU 15 + +VAR_MONITOR_WARNING EQU 0 +VAR_STATIC EQU 1 +VAR_SPEAKINGHERO EQU 2 +VAR_GRUNT_TILE EQU 3 +VAR_COSTUME_DIALOG EQU 4 +VAR_BS_TILE EQU 5 +VAR_NUMMONITORS EQU 6 +VAR_MONITORS EQU 7 ;7-26, 20 monitors +VAR_HANGIN_DIALOG EQU 27 +VAR_COSTUME_HERO EQU 28 + +STATICINDEX EQU 34 +BGBRAINIACINDEX EQU 31 +GOBLININDEX EQU 46 +GRUNTINDEX EQU 44 +GUARDINDEX EQU 45 +BRAINIACINDEX EQU 49 + +DETECTZONE EQU 11 +PAINTZONE EQU 10 ;8 +HANGINZONE1 EQU 5 +HANGINZONE2 EQU 8 ;5 +MONITORZONE EQU 9 + +L0115_Init: + DW ((L0115_InitFinished - L0115_Init2)) ;size +L0115_Init2: + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(bs_gbm) + ld hl,bs_gbm + call InitMusic + + xor a + ld [levelVars + VAR_MONITOR_WARNING],a + ld [levelVars + VAR_COSTUME_DIALOG],a + ld [levelVars + VAR_HANGIN_DIALOG],a + + ;save BS's current tile for later + call SetSpeakerToFirstHero + call GetFGMapping + ld [levelVars+VAR_BS_TILE],a + + ld a,20 + ld [levelVars + VAR_NUMMONITORS],a + + xor a + ld c,20 + ld hl,levelVars + VAR_MONITORS +.clearMonitors + ld [hl+],a + dec c + jr nz,.clearMonitors + + + ;ld a,$ff + ;ld [levelVars + VAR_BS_TILE],a + + ld a,[bgTileMap+STATICINDEX] + ld [levelVars+VAR_STATIC],a + + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,[fgTileMap+GRUNTINDEX] + ld [levelVars+VAR_GRUNT_TILE],a + + ldio a,[mapState] + cp STATE_NORMAL + ret nz + + ;open doors + ;open the security door + ;ld a,MAPBANK + ;ldio [$ff70],a + ;xor a + ;ld hl,$d189 + ;ld [hl+],a + ;ld [hl],a + + ;open the outer door + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d049 + ld [hl+],a + ld [hl],a + + ;mark certain dialogs as having happened + ld a,1 + ld [levelVars + VAR_COSTUME_DIALOG],a + ld [levelVars + VAR_HANGIN_DIALOG],a + + ret + +L0115_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0115_Check: + DW ((L0115_CheckFinished - L0115_Check2)) ;size +L0115_Check2: + call SetSkipStackPos + call CheckSkip + call ((.animateStatic-L0115_Check2)+levelCheckRAM) + call ((.checkBSAttack-L0115_Check2)+levelCheckRAM) + call ((.checkPaintRoom-L0115_Check2)+levelCheckRAM) + call ((.checkHangin-L0115_Check2)+levelCheckRAM) + call ((.adjustCameraInMonitorRoom-L0115_Check2)+levelCheckRAM) + call ((.checkMonitorWarn-L0115_Check2)+levelCheckRAM) + VECTORTOSTATE ((.stateTable-L0115_Check2)+levelCheckRAM) + +.stateTable + DW ((.checkDetect1-L0115_Check2)+levelCheckRAM) + DW ((.checkDetect2-L0115_Check2)+levelCheckRAM) + DW ((.checkDetect3-L0115_Check2)+levelCheckRAM) + DW ((.checkPresto-L0115_Check2)+levelCheckRAM) + DW ((.checkHangin2-L0115_Check2)+levelCheckRAM) + DW ((.checkHangin3-L0115_Check2)+levelCheckRAM) + DW ((.checkHangin4-L0115_Check2)+levelCheckRAM) + DW ((.checkHangin5-L0115_Check2)+levelCheckRAM) + DW ((.checkMonitor1-L0115_Check2)+levelCheckRAM) + DW ((.checkWaitAllBRAINIAC-L0115_Check2)+levelCheckRAM) + DW ((.checkMonitor2-L0115_Check2)+levelCheckRAM) + DW ((.checkMonitor3-L0115_Check2)+levelCheckRAM) + DW ((.checkMonitor4-L0115_Check2)+levelCheckRAM) + DW ((.checkMonitor5-L0115_Check2)+levelCheckRAM) + DW ((.checkNormal-L0115_Check2)+levelCheckRAM) + DW ((.checkWaitDialog-L0115_Check2)+levelCheckRAM) + +.checkDetect1 + ld a,1 + ld hl,((.checkDetect1_hero-L0115_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkDetect1_hero + ld c,a + call GetFirst + call GetCurZone + cp DETECTZONE + ld a,0 + ret nz + + ld a,c + ld [levelVars + VAR_SPEAKINGHERO],a + call SetSpeakerFromHeroIndex + + call MakeIdle + + ld hl,$d85d + call ((.monitorToStatic-L0115_Check2)+levelCheckRAM) + + ld c,8 +.waitStatic + ld de,((.skipDetect - L0115_Check2) + levelCheckRAM) + call SetDialogSkip + + ld a,1 + call Delay + call ((.animateStatic-L0115_Check2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.waitStatic + + ld hl,$d85d + call ((.monitorToBRAINIAC-L0115_Check2)+levelCheckRAM) + call ((.setupBRAINIAC-L0115_Check2)+levelCheckRAM) + DIALOGTOP brainiac_detectIntruder_gtx + WAITDIALOG STATE_DETECT2 + ld a,1 + ret + +.checkDetect2 + ld a,[levelVars + VAR_SPEAKINGHERO] + ld c,a + DIALOGBOTTOM bs_segashuating_gtx + WAITDIALOG STATE_DETECT3 + ret + +.checkDetect3 + call ((.setupBRAINIAC-L0115_Check2)+levelCheckRAM) + DIALOGTOP brainiac_bringIt_gtx + call MakeNonIdle + WAITDIALOG STATE_MONITOR1 + ret + +.checkPaintRoom + ldio a,[mapState] + cp STATE_PRESTO + ret z + + xor a + ld hl,((.checkPaintRoom_hero-L0115_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkPaintRoom_hero + ld c,a + call GetFirst + call GetCurZone + cp PAINTZONE + ld a,0 + ret nz + + ;only if hero's attack delay is zero + call GetAttackDelay + or a + ld a,0 + ret nz + + ;possible for costume? + ld a,[levelVars + VAR_GRUNT_TILE] + inc a + ret z ;returns if $ff (no tile) + + ;already talked about costume? + ld a,c + ld [levelVars + VAR_COSTUME_HERO],a + ld a,[levelVars + VAR_COSTUME_DIALOG] + or a + jr nz,.checkPresto + + call SetSpeakerFromHeroIndex + + ld de,((.skipCostume-L0115_Check2)+levelCheckRAM) + call SetDialogSkip + + call MakeIdle + DIALOGBOTTOM bs_idea_gtx + WAITDIALOGNOCLEAR STATE_PRESTO + + ld a,1 + ret + +.checkPresto + call ((.useCostume-L0115_Check2)+levelCheckRAM) + + ld a,[levelVars + VAR_COSTUME_DIALOG] + or a + ret nz + + ld a,[levelVars + VAR_COSTUME_HERO] + ld c,a + call SetSpeakerFromHeroIndex + + call ((.clearSkipAfterDialog-L0115_Check2)+levelCheckRAM) + DIALOGBOTTOM bs_presto_gtx + call MakeNonIdle + WAITDIALOG STATE_MONITOR1 + ld a,1 + ld [levelVars + VAR_COSTUME_DIALOG],a + ret + +.checkHangin + ld a,[levelVars + VAR_HANGIN_DIALOG] + or a + ret nz + + ;jr z,.okayToHang + ;ld a,STATE_MONITOR1 + ;ldio [mapState],a + ;ret +;.okayToHang + ld a,1 + ld hl,((.checkHangin_hero-L0115_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkHangin_hero + ld c,a + call GetFirst + call GetCurZone + cp HANGINZONE1 + jr z,.checkCostume + cp HANGINZONE2 + ld a,0 + ret nz + +.checkCostume + call SetSpeakerFromHeroIndex + ld a,TILEINDEXBANK + ldio [$ff70],a + ld h,((fgTileMap>>8) & $ff) + ld l,c + ld a,[levelVars + VAR_GRUNT_TILE] + cp [hl] + ld a,0 + ret nz ;not in costume! + + ;make sure there's some grunts to talk to + push bc + push de + ld c,GRUNTINDEX + call GetFirst + pop de + pop bc + or a + ret z ;no grunts + + ld a,1 + ld [levelVars + VAR_HANGIN_DIALOG],a + ld de,((.skipHangin-L0115_Check2)+levelCheckRAM) + call SetDialogSkip + call MakeIdle + ld a,c + ld [levelVars + VAR_SPEAKINGHERO],a + call SetSpeakerFromHeroIndex + DIALOGBOTTOM bs_hangin1_gtx + WAITDIALOG STATE_HANGIN2 + ld a,1 + ret + +.checkHangin2 + ld c,GRUNTINDEX + DIALOGTOP grunt_hangin2_gtx + WAITDIALOG STATE_HANGIN3 + ret + +.checkHangin3 + ld a,[levelVars + VAR_SPEAKINGHERO] + ld c,a + call SetSpeakerFromHeroIndex + DIALOGBOTTOM bs_hangin3_gtx + WAITDIALOG STATE_HANGIN4 + ret + +.checkHangin4 + ld c,GRUNTINDEX + DIALOGTOP grunt_hangin4_gtx + WAITDIALOG STATE_HANGIN5 + ret + +.checkHangin5 + call ((.clearSkipAfterDialog-L0115_Check2)+levelCheckRAM) + call MakeNonIdle + ld a,[levelVars + VAR_SPEAKINGHERO] + ld c,a + call SetSpeakerFromHeroIndex + DIALOGBOTTOM bs_hangin5_gtx + WAITDIALOG STATE_MONITOR1 + ret + +.checkMonitor1 + ld a,1 + ld hl,((.checkMonitor1_hero-L0115_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkMonitor1_hero + or a + ret z + + ld c,a + ;hero in costume? + call GetFGMapping + ld hl,levelVars + VAR_GRUNT_TILE + cp [hl] + ld a,0 + ret nz ;not yet! + + call GetFirst + call GetCurZone + cp MONITORZONE + ld a,0 + ret nz + + call SetSpeakerFromHeroIndex + call MakeIdle + ld a,1 ;make sure the warning won't happen + ld [levelVars + VAR_MONITOR_WARNING],a + ld c,GUARDINDEX + DIALOGTOP monitor_openDoor_gtx + WAITDIALOG STATE_WAIT_ALLBRAINIAC + ld a,MAPBANK + ldio [$ff70],a + + ;open the outer door + xor a + ld hl,$d049 + ld [hl+],a + ld [hl],a + + ld de,((.skipMonitor-L0115_Check2)+levelCheckRAM) + call SetDialogSkip + + ld a,1 + ret + +.checkWaitAllBRAINIAC + ld a,[levelVars + VAR_NUMMONITORS] + or a + jr z,.brainiacTalks + + ;animate monitors from normal to static to BRAINIAC + dec a ;pick a monitor at random + call GetRandomNumZeroToN + inc a + ld c,a + ld de,0 + ld hl,levelVars + VAR_MONITORS + + ;find monitor state data +.findActiveMonitor + ld a,[hl+] + inc e + cp 5 + jr nc,.findActiveMonitor ;skip if this one finished + dec c + jr nz,.findActiveMonitor + dec hl + dec e + inc [hl] + inc a + ld c,a ;save monitor state + sla e ;de *= 2 (offset) + rl d + ld hl,((.monitorLocations-L0115_Check2)+levelCheckRAM) + add hl,de ;hl = monitor location table + ld a,[hl+] + ld h,[hl] + ld l,a ;hl is monitor location + ld a,c + cp 5 + jr nc,.changeToFace + + ;change to static + call ((.monitorToStatic-L0115_Check2)+levelCheckRAM) + ret + +.changeToFace + call ((.monitorToBRAINIAC-L0115_Check2)+levelCheckRAM) + ld hl,levelVars + VAR_NUMMONITORS + dec [hl] + ret + +.brainiacTalks + call ((.setupBRAINIAC-L0115_Check2)+levelCheckRAM) + DIALOGTOP brainiac_wait_gtx + WAITDIALOG STATE_MONITOR2 + ret + +.resetHero + or a + ret z + ld c,a + call GetFirst + ld a,10 + call SetAttackDelay + ld b,METHOD_DRAW + call CallMethod + ret + +.checkMonitor2 + call ((.openSecurityDoor-L0115_Check2)+levelCheckRAM) + + ld c,GUARDINDEX + DIALOGTOP monitor_sorry_gtx + WAITDIALOGNOCLEAR STATE_MONITOR3 + ret + +.checkMonitor3 + call ((.setupBRAINIAC-L0115_Check2)+levelCheckRAM) + DIALOGTOP brainiac_justClose_gtx + WAITDIALOGNOCLEAR STATE_MONITOR4 + ret + +.checkMonitor4 + ld c,GUARDINDEX + DIALOGTOP monitor_oneSecond_gtx + WAITDIALOGNOCLEAR STATE_MONITOR5 + ret + +.checkMonitor5 + call ((.setupBRAINIAC-L0115_Check2)+levelCheckRAM) + set DLG_CLEARSKIP_BIT,[hl] + DIALOGTOP brainiac_idiotz_gtx + call MakeNonIdle + WAITDIALOG STATE_NORMAL + ret + +.checkNormal + ret + +.checkWaitDialog + STDWAITDIALOG + ret + +;----support routines------------------------------------------------- +.clearSkipAfterDialog + ld hl,dialogSettings + set DLG_CLEARSKIP_BIT,[hl] + ret + +.skipDetect + call ClearDialog + call MakeNonIdle + ld hl,$d85d + call ((.monitorToBRAINIAC-L0115_Check2)+levelCheckRAM) + ld a,STATE_MONITOR1 + ldio [mapState],a + ld a,1 + ret + +.useCostume + ld a,[levelVars + VAR_COSTUME_HERO] + ld c,a + ld a,[levelVars + VAR_GRUNT_TILE] ;use the grunt's tile + call SetFGMapping + + call GetFirst + ld a,0 + call SetAttackDelay + ld b,METHOD_DRAW + call CallMethod + ld a,GROUP_MONSTERA ;hero is one of the boys now + call SetGroup + ret + +.skipCostume + call ClearDialog + call MakeNonIdle + call ((.useCostume-L0115_Check2)+levelCheckRAM) + ld a,1 + ld [levelVars + VAR_COSTUME_DIALOG],a + ld a,STATE_MONITOR1 + ldio [mapState],a + ret + +.skipHangin + call ClearDialog + call MakeNonIdle + ld a,STATE_MONITOR1 + ldio [mapState],a + ret + +.skipMonitor + call ClearDialog + call MakeNonIdle + ld a,STATE_NORMAL + ldio [mapState],a + + call ((.openSecurityDoor-L0115_Check2)+levelCheckRAM) + + ;set all monitors to brainiac + ld c,20 + ld hl,((.monitorLocations-L0115_Check2)+levelCheckRAM) +.setAllMonitorsLoop + ld a,[hl+] + push hl + ld h,[hl] + ld l,a + call ((.monitorToBRAINIAC-L0115_Check2)+levelCheckRAM) + pop hl + inc hl + dec c + jr nz,.setAllMonitorsLoop + ret + +.openSecurityDoor + ld a,[hero0_index] + call ((.resetHero-L0115_Check2)+levelCheckRAM) + ld a,[hero1_index] + call ((.resetHero-L0115_Check2)+levelCheckRAM) + call ((.checkBSAttack-L0115_Check2)+levelCheckRAM) + + ;open the security door + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d189 + ld [hl+],a + ld [hl],a + + ;ld a,$ff + ;ld [levelVars + VAR_GRUNT_TILE],a ;no more changing + + ret + +.setupBRAINIAC + ld hl,dialogSettings + set DLG_BRAINIAC_BIT,[hl] + ld c,BRAINIACINDEX + ret + +.checkMonitorWarn + ld a,[levelVars + VAR_MONITOR_WARNING] + or a + ret nz + + ld a,1 + ld hl,((.checkMonitorWarn_hero-L0115_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkMonitorWarn_hero + ld c,a + call GetFirst + call GetCurZone + cp MONITORZONE + ld a,0 + ret nz + + ;no warning if I'm in crouton disguise + call GetFGMapping + ld hl,levelVars + VAR_GRUNT_TILE + cp [hl] + ld a,0 + ret z + + ld a,1 + ld [levelVars + VAR_MONITOR_WARNING],a + + ld de,((.skipMonitorWarn-L0115_Check2)+levelCheckRAM) + call SetDialogSkip + + call ((.clearSkipAfterDialog-L0115_Check2)+levelCheckRAM) + ld c,GUARDINDEX + DIALOGTOP monitor_onlyCroutons_gtx + WAITDIALOG STATE_MONITOR1 + ld a,1 + ret + +.skipMonitorWarn + call ClearDialog + call MakeNonIdle + ld a,STATE_MONITOR1 + ldio [mapState],a + ret + +.monitorLocations + DW $d082 + DW $d084 + DW $d086 + DW $d08c + DW $d08e + DW $d090 + DW $d102 + DW $d182 + DW $d202 + DW $d282 + DW $d110 + DW $d190 + DW $d210 + DW $d290 + DW $d302 + DW $d304 + DW $d306 + DW $d30c + DW $d30e + DW $d310 ;20 total (does not include entrance) + +.adjustCameraInMonitorRoom + call GetMyHero + ld c,a + call GetFirst + call GetCurZone + cp 7 + jr z,.adjustCamera + cp 9 + ret nz +.adjustCamera + ld a,1 + ld [camera_i],a + ld [camera_j],a + ret + +.monitorToStatic + push bc + push de + push hl + + ;push hl + ;ld hl,((.staticSound-L0115_Check2)+levelCheckRAM) + ;call PlaySound + ;pop hl + + ld de,$2901 + jr .monitorCommon + +.monitorToBRAINIAC + push bc + push de + push hl + + ld de,$2903 + +.monitorCommon + call ConvertLocHLToXY + push de + push hl + pop de + pop hl + ld bc,$0202 + call BlitMap + + pop hl + pop de + pop bc + ret + +.animateStatic + ld a,[levelVars+VAR_STATIC] + ld b,a + ldio a,[updateTimer] + rrca + and %00000010 + add b + ld hl,bgTileMap+STATICINDEX + ld [hl+],a + inc a + ld [hl+],a + ret + +.checkBSAttack + ;sets BS's group back to hero and get rid of his disguise + ;if he attacks + ld a,[hero0_index] + call ((.groupToHero-L0115_Check2)+levelCheckRAM) + ld a,[hero1_index] + call ((.groupToHero-L0115_Check2)+levelCheckRAM) + ret + +.groupToHero + or a + ret z + + ld c,a + call GetFirst + call GetAttackDelay + or a + ret z + + ;have a copy of BS's original tile? + ld a,[levelVars + VAR_BS_TILE] + cp $ff + ret z + + + ld a,[levelVars + VAR_BS_TILE] + call SetFGMapping + + ld b,METHOD_DRAW + call CallMethod + + ld a,GROUP_HERO + call SetGroup + ld a,TILEINDEXBANK + ret + +;.staticSound + ;DB 4,$00,$f0,$20,$c0 + +L0115_CheckFinished: +PRINT "0115 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0115_LoadFinished - L0115_Load2) +PRINT " / " +PRINT (L0115_InitFinished - L0115_Init2) +PRINT " / " +PRINT (L0115_CheckFinished - L0115_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0200.asm b/Source/Levels/L0200.asm new file mode 100644 index 0000000..f5b8312 --- /dev/null +++ b/Source/Levels/L0200.asm @@ -0,0 +1,90 @@ +; L0200.asm evil village +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;water=lava here +WATERINDEX EQU 29 +FIREINDEX EQU 38 +VAR_FIRE EQU 0 +VAR_WATER EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0200Section",ROMX +;--------------------------------------------------------------------- + +L0200_Contents:: + DW L0200_Load + DW L0200_Init + DW L0200_Check + DW L0200_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0200_Load: + DW ((L0200_LoadFinished - L0200_Load2)) ;size +L0200_Load2: + call ParseMap + ret + +L0200_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0200_Map: +INCBIN "Data/Levels/L0200_evilvill.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0200_Init: + DW ((L0200_InitFinished - L0200_Init2)) ;size +L0200_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ld a,[bgTileMap + FIREINDEX] + ld [levelVars + VAR_FIRE],a + ret + +L0200_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0200_Check: + DW ((L0200_CheckFinished - L0200_Check2)) ;size +L0200_Check2: + call ((.animateWater-L0200_Check2)+levelCheckRAM) + call ((.animateFire-L0200_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +.animateFire + ldio a,[updateTimer] + rrca + rrca + and %11 + ld hl,levelVars + VAR_FIRE + add [hl] + ld [bgTileMap + FIREINDEX],a + ret + +L0200_CheckFinished: +PRINT "0200 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0200_LoadFinished - L0200_Load2) +PRINT " / " +PRINT (L0200_InitFinished - L0200_Init2) +PRINT " / " +PRINT (L0200_CheckFinished - L0200_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0201.asm b/Source/Levels/L0201.asm new file mode 100644 index 0000000..b889bc7 --- /dev/null +++ b/Source/Levels/L0201.asm @@ -0,0 +1,74 @@ +; L0201.asm mist south of evil village +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0201Section",ROMX +;--------------------------------------------------------------------- + +L0201_Contents:: + DW L0201_Load + DW L0201_Init + DW L0201_Check + DW L0201_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0201_Load: + DW ((L0201_LoadFinished - L0201_Load2)) ;size +L0201_Load2: + call ParseMap + ret + +L0201_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0201_Map: +INCBIN "Data/Levels/L0201_mist.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0201_Init: + DW ((L0201_InitFinished - L0201_Init2)) ;size +L0201_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0201_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0201_Check: + DW ((L0201_CheckFinished - L0201_Check2)) ;size +L0201_Check2: + call ((.animateWater-L0201_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0201_CheckFinished: +PRINT "0201 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0201_LoadFinished - L0201_Load2) +PRINT " / " +PRINT (L0201_InitFinished - L0201_Init2) +PRINT " / " +PRINT (L0201_CheckFinished - L0201_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0203.asm b/Source/Levels/L0203.asm new file mode 100644 index 0000000..b5a3cc3 --- /dev/null +++ b/Source/Levels/L0203.asm @@ -0,0 +1,166 @@ +;L0203.asm +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "LevelsSection0203",ROMX +;--------------------------------------------------------------------- + +L0203_Contents:: + DW L0203_Load + DW L0203_Init + DW L0203_Check + DW L0203_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0203_Load: + DW ((L0203_LoadFinished - L0203_Load2)) ;size +L0203_Load2: + call ParseMap + ret + +L0203_LoadFinished: + +L0203_Map: +INCBIN "Data/Levels/L0203_path.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0203_Init: +;--------------------------------------------------------------------- + DW ((L0203_InitFinished - L0203_Init2)) ;size +L0203_Init2: + + ret + +L0203_InitFinished: + + +;--------------------------------------------------------------------- +L0203_Check: +;--------------------------------------------------------------------- + DW ((L0203_CheckFinished - L0203_Check) - 2) ;size +L0203_Check2: + ;-----------------see what zone the hero is in------------------ + ;get hero object + ld a,[hero0_object] + ld l,a + ld a,[hero0_object+1] + ld h,a + + ;get hero's location from hero object + ld a,OBJBANK + ld [$ff70],a + ld e,[hl] + inc hl + ld d,[hl] + + ;see what zone he's in + ld a,ZONEBANK + ld [$ff70],a + ld a,[de] + and %1111 ;no exit info please + ld [mapHeroZone],a + + ;change palette if changed zones + ld hl,(.lastZone + (levelCheckRAM-L0203_Check2)) + cp [hl] + jr z,.afterChangePalette + + ;note new zone + ld [(.lastZone + (levelCheckRAM-L0203_Check2))],a + + ld a,FADEBANK + ld [$ff70],a + + ;copy standard palette to fadeFinalPalette, dividing colors by two + ld hl,(.stdPaletteData + (levelCheckRAM-L0203_Check2)) + ld de,fadeFinalPalette + ld c,32 +.copyLoop + push bc + + ld a,[mapHeroZone] + ld c,a + + ld a,[hl+] ;low byte + ld b,a + ld a,[hl+] ;high byte + + ;rotate ab by # bits equal to the current zone number - 1 + dec c + jr z,.shiftDone + +.shiftLoop + rrca + rr b + + ;mask ab with %00111101 11101111 + push af + ld a,b + and %11101111 + ld b,a + pop af + and %00111101 + + dec c + jr nz,.shiftLoop + +.shiftDone + ;write ba to dest + push af + ld a,b + ld [de],a + inc de + pop af + ld [de],a + inc de + + pop bc + + dec c + jr nz,.copyLoop + + ;restore red + ld de,fadeFinalPalette + 10 + ld hl,(.stdPaletteData + (levelCheckRAM-L0203_Check2))+10 + ld c,6 +.restoreLoop + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.restoreLoop + + ld a,60 + call FadeInit + +.afterChangePalette + ret + +.lastZone DB $ff + +.stdPaletteData + DW $0068, $2108, $4210, $7fff ;Palette 0 (Grey) + DW $0068, $000A, $001f, $7fff ;Palette 1 (Red) + DW $0068, $5000, $7e00, $7fff ;Palette 2 (Blue) + DW $0068, $0140, $03e0, $7fff ;Palette 3 (Green) + DW $0068, $4008, $5192, $7fff ;Palette 4 (Purple) + DW $0068, $01cd, $03fe, $7fff ;Palette 5 (Yellow) + DW $0068, $00d1, $09ff, $7fff ;Palette 6 (Brown) + DW $0068, $4412, $799c, $7fff ;Palette 7 (Fuscia) +L0203_CheckFinished: + + +PRINT " 0203 Level Check Size: " +PRINT (L0203_CheckFinished - L0203_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0204.asm b/Source/Levels/L0204.asm new file mode 100644 index 0000000..9d5b6c6 --- /dev/null +++ b/Source/Levels/L0204.asm @@ -0,0 +1,155 @@ +;L0204.asm +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "LevelsSection0204",ROMX +;--------------------------------------------------------------------- + +L0204_Contents:: + DW L0204_Load + DW L0204_Init + DW L0204_Check + DW L0204_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0204_Load: + DW ((L0204_LoadFinished - L0204_Load2)) ;size +L0204_Load2: + call ParseMap + ret + +L0204_LoadFinished: + +L0204_Map: +INCBIN "Data/Levels/L0204_path.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0204_Init: +;--------------------------------------------------------------------- + DW ((L0204_InitFinished - L0204_Init2)) ;size +L0204_Init2: + + ret + +L0204_InitFinished: + + +;--------------------------------------------------------------------- +L0204_Check: +;--------------------------------------------------------------------- + DW ((L0204_CheckFinished - L0204_Check) - 2) ;size +L0204_Check2: + ;-----------------see what zone the hero is in------------------ + ;get hero object + ld a,[hero0_object] + ld l,a + ld a,[hero0_object+1] + ld h,a + + ;get hero's location from hero object + ld a,OBJBANK + ld [$ff70],a + ld e,[hl] + inc hl + ld d,[hl] + + ;see what zone he's in + ld a,ZONEBANK + ld [$ff70],a + ld a,[de] + and %1111 ;no exit info please + ld [mapHeroZone],a + + ;change palette if changed zones + ld hl,(.lastZone + (levelCheckRAM-L0204_Check2)) + cp [hl] + jr z,.afterChangePalette + + ;note new zone + ld [(.lastZone + (levelCheckRAM-L0204_Check2))],a + + ld a,FADEBANK + ld [$ff70],a + + ;copy standard palette to fadeFinalPalette, dividing colors by two + ld hl,(.stdPaletteData + (levelCheckRAM-L0204_Check2)) + ld de,fadeFinalPalette + ld c,32 +.copyLoop + push bc + + ld a,[mapHeroZone] + ld c,a + + ld a,[hl+] ;low byte + ld b,a + ld a,[hl+] ;high byte + + ;rotate ab by # bits equal to the current zone number - 1 + dec c + jr z,.shiftDone + +.shiftLoop + rrca + rr b + + ;mask ab with %00111101 11101111 + push af + ld a,b + and %11101111 + ld b,a + pop af + and %00111101 + + dec c + jr nz,.shiftLoop + +.shiftDone + ;write ba to dest + push af + ld a,b + ld [de],a + inc de + pop af + ld [de],a + inc de + + pop bc + + dec c + jr nz,.copyLoop + + ld a,60 + call FadeInit + +.afterChangePalette + ret + +.lastZone DB $ff + +.stdPaletteData + DW $0068, $2108, $4210, $7fff ;Palette 0 (Grey) + DW $0068, $000A, $001f, $7fff ;Palette 1 (Red) + DW $0068, $5000, $7e00, $7fff ;Palette 2 (Blue) + DW $0068, $0140, $03e0, $7fff ;Palette 3 (Green) + DW $0068, $4008, $5192, $7fff ;Palette 4 (Purple) + DW $0068, $01cd, $03fe, $7fff ;Palette 5 (Yellow) + DW $0068, $00d1, $09ff, $7fff ;Palette 6 (Brown) + DW $0068, $4412, $799c, $7fff ;Palette 7 (Fuscia) +L0204_CheckFinished: + + +PRINT " 0204 Level Check Size: " +PRINT (L0204_CheckFinished - L0204_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0205.asm b/Source/Levels/L0205.asm new file mode 100644 index 0000000..09aae05 --- /dev/null +++ b/Source/Levels/L0205.asm @@ -0,0 +1,284 @@ +;L0205.asm bridge +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATER_INDEX EQU 7 +DARKWATER_INDEX EQU 22 +FLOOR_INDEX EQU 40 +STONEHEAD_INDEX EQU 41 +STUNNED_INDEX EQU 42 + +STATE_BROKEN EQU 1 +STATE_BROKEN_TALKED EQU 2 +STATE_FIXED EQU 3 +STATE_TALK_WHAT EQU 4 +STATE_TALK_FORGIVE EQU 5 +STATE_TALK_OKAY EQU 6 +STATE_TALK_GOWEST EQU 7 +STATE_TALK_AFTER EQU 8 +STATE_WAIT_DIALOG EQU 9 + +;from L0312 +STATE_HIVE_DESTROYED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "LevelsSection0205",ROMX,BANK[MAP0ROM] +;--------------------------------------------------------------------- + +dialog: +L0205_idiot_gtx: + INCBIN "Data/Dialog/Talk/L0205_idiot.gtx" + +L0205_what_gtx: + INCBIN "Data/Dialog/Talk/L0205_what.gtx" + +L0205_forgive_gtx: + INCBIN "Data/Dialog/Talk/L0205_forgive.gtx" + +L0205_okay_gtx: + INCBIN "Data/Dialog/Talk/L0205_okay.gtx" + +L0205_west_gtx: + INCBIN "Data/Dialog/Talk/L0205_west.gtx" + +L0205_Contents:: + DW L0205_Load + DW L0205_Init + DW L0205_Check + DW L0205_Map + +;--------------------------------------------------------------------- +; landing +;--------------------------------------------------------------------- +L0205_Load: + DW ((L0205_LoadFinished - L0205_Load2)) ;size +L0205_Load2: + call ParseMap + ret + +L0205_LoadFinished: + +L0205_Map: +INCBIN "Data/Levels/L0205_bridge.lvl" + +;gtx_intro: INCBIN "Data/Dialog/Landing/intro.gtx" +;gtx_intro2: INCBIN "Data/Dialog/Landing/intro2.gtx" +;gtx_finished: INCBIN "Data/Dialog/Landing/finished.gtx" +;gtx_finished2: INCBIN "Data/Dialog/Landing/finished2.gtx" + +;--------------------------------------------------------------------- +L0205_Init: +;--------------------------------------------------------------------- + DW ((L0205_InitFinished - L0205_Init2)) ;size +L0205_Init2: + ld a,BANK(dialog) + ld [dialogBank],a + call SetPressBDialog + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$c3] ;bee house in sunset + cp STATE_HIVE_DESTROYED + jr nz,.notFixed + + ld a,STATE_FIXED + ldio [mapState],a +.notFixed + + ldio a,[mapState] + ld hl,((.resetStateTable-L0205_Init2)+levelCheckRAM) + call Lookup8 + ldio [mapState],a + + cp STATE_BROKEN + jr nz,.fixed + call ((.removeBridge-L0205_Init2)+levelCheckRAM) + jr .statesDone +.fixed + ld bc,classWallCreature + call DeleteObjectsOfClass +.statesDone + + ret + +.removeBridge + ld bc,classWallCreature + ld de,classWallTalker + call ChangeClass + ld bc,classStunnedWall + call DeleteObjectsOfClass + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d34f + call ((.remove10Tiles-L0205_Init2)+levelCheckRAM) + ld hl,$d350 + call ((.remove10Tiles-L0205_Init2)+levelCheckRAM) + ret + +.remove10Tiles + ld a,[mapPitch] + ld e,a + ld d,0 + ld c,10 + ld a,WATER_INDEX +.remove10TilesLoop + ld [hl],a + add hl,de + dec c + jr nz,.remove10TilesLoop + ret + +.resetStateTable + DB STATE_BROKEN,STATE_BROKEN,STATE_BROKEN + DB STATE_FIXED,STATE_FIXED + +L0205_InitFinished: + + +;--------------------------------------------------------------------- +L0205_Check: +;--------------------------------------------------------------------- + DW ((L0205_CheckFinished - L0205_Check) - 2) ;size +L0205_Check2: + call SetSkipStackPos + call CheckSkip + + call ((.animateWater-L0205_Check2)+levelCheckRAM) + + VECTORTOSTATE ((.stateTable - L0205_Check2) + levelCheckRAM) + ret + +.stateTable + DW ((.checkDialog-L0205_Check2)+levelCheckRAM) + DW ((.checkDialog-L0205_Check2)+levelCheckRAM) + DW ((.normal-L0205_Check2)+levelCheckRAM) + DW ((.normal-L0205_Check2)+levelCheckRAM) + DW ((.what-L0205_Check2)+levelCheckRAM) + DW ((.forgive-L0205_Check2)+levelCheckRAM) + DW ((.okay-L0205_Check2)+levelCheckRAM) + DW ((.gowest-L0205_Check2)+levelCheckRAM) + DW ((.afterDialog-L0205_Check2)+levelCheckRAM) + DW ((.waitDialog-L0205_Check2)+levelCheckRAM) + +.normal + ret + +.checkDialog + ld a,[dialogNPC_speakerIndex] + or a + ret z + + ld a,%1 + call DisableDialogBalloons + + call MakeIdle + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ;Idiot says what? + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,((.what-L0205_Check2) + levelCheckRAM) + call SetDialogForward + ld de,((.afterDialog-L0205_Check2) + levelCheckRAM) + call SetDialogSkip + DIALOGTOP L0205_idiot_gtx + WAITDIALOG STATE_TALK_WHAT + ret + +.what + ;what? + call ClearDialog + ld a,[dialogNPC_heroIndex] + ld c,a + DIALOGBOTTOM L0205_what_gtx + WAITDIALOG STATE_TALK_FORGIVE + ret + +.forgive + ;Forgive me + call ClearDialog + ld a,[dialogNPC_speakerIndex] + ld c,a + DIALOGTOP L0205_forgive_gtx + WAITDIALOG STATE_TALK_OKAY + ret + +.okay + ;okay + call ClearDialog + ld a,[dialogNPC_heroIndex] + ld c,a + DIALOGBOTTOM L0205_okay_gtx + WAITDIALOG STATE_TALK_GOWEST + ret + +.gowest + ;go west + call ClearDialog + ld a,[dialogNPC_speakerIndex] + ld c,a + DIALOGTOP L0205_west_gtx + WAITDIALOG STATE_TALK_AFTER + ret + +.afterDialog + ld a,STATE_BROKEN_TALKED + ldio [mapState],a + call ClearDialog + call MakeNonIdle + + ld de,0 + call SetDialogForward + call SetDialogSkip + + xor a + ld [dialogNPC_speakerIndex],a + + ret + + +.animateWater + ldio a,[updateTimer] + and %11 + ret nz + + ;animate water by cycling the tile mapping of class 7 from + ;7-10 and class 22 from 22-25 + ld a,TILEINDEXBANK + ld [$ff70],a + + ld hl,bgTileMap+WATER_INDEX + ld a,[hl] + sub WATER_INDEX + inc a + and %11 + add WATER_INDEX + ld [hl],a + + ld hl,bgTileMap+DARKWATER_INDEX + ld a,[hl] + sub DARKWATER_INDEX + inc a + and %11 + add DARKWATER_INDEX + ld [hl],a + + ret + +.waitDialog + STDWAITDIALOG + ret + +L0205_CheckFinished: + + +PRINT " 0205 Level Check Size: " +PRINT (L0205_CheckFinished - L0205_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L0211.asm b/Source/Levels/L0211.asm new file mode 100644 index 0000000..ac694ba --- /dev/null +++ b/Source/Levels/L0211.asm @@ -0,0 +1,90 @@ +; L0211.asm +; Generated 10.20.2000 by mlevel +; Modified 10.20.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +FIRST_HOLE EQU 26 + +;--------------------------------------------------------------------- +SECTION "Level0211Section",ROMX +;--------------------------------------------------------------------- + +L0211_Contents:: + DW L0211_Load + DW L0211_Init + DW L0211_Check + DW L0211_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0211_Load: + DW ((L0211_LoadFinished - L0211_Load2)) ;size +L0211_Load2: + call ParseMap + + ;alter yellow palette to purple w/black + ld a,FADEBANK + ld bc,6 + ld de,gamePalette + 5*8 + 2 + ld hl,((.purpleBlackPalette-L0211_Load2)+levelCheckRAM) + call MemCopy + ret + +.purpleBlackPalette + DW $4008,$5192,$0000 + +L0211_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0211_Map: +INCBIN "Data/Levels/L0211_tower.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0211_Init: + DW ((L0211_InitFinished - L0211_Init2)) ;size +L0211_Init2: + ret + +L0211_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0211_Check: + DW ((L0211_CheckFinished - L0211_Check2)) ;size +L0211_Check2: + call ((.checkFalling-L0211_Check2)+levelCheckRAM) + ret + +.checkFalling + ld a,[timeToChangeLevel] + or a + ret z + + ld a,[exitTileIndex] + cp FIRST_HOLE + ret c + + ld hl,((.fallSound-L0211_Check2)+levelCheckRAM) + call PlaySound + ld a,15 + call Delay + ret + +.fallSound + DB 1,$7e,$80,$f5,$00,$86 + +L0211_CheckFinished: +PRINT "0211 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0211_LoadFinished - L0211_Load2) +PRINT " / " +PRINT (L0211_InitFinished - L0211_Init2) +PRINT " / " +PRINT (L0211_CheckFinished - L0211_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0212.asm b/Source/Levels/L0212.asm new file mode 100644 index 0000000..639249d --- /dev/null +++ b/Source/Levels/L0212.asm @@ -0,0 +1,59 @@ +; L0212.asm +; Generated 08.31.2000 by mlevel +; Modified 08.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0212Section",ROMX +;--------------------------------------------------------------------- + +L0212_Contents:: + DW L0212_Load + DW L0212_Init + DW L0212_Check + DW L0212_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0212_Load: + DW ((L0212_LoadFinished - L0212_Load2)) ;size +L0212_Load2: + call ParseMap + ret + +L0212_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0212_Map: +INCBIN "Data/Levels/L0212_sunsethouseup.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0212_Init: + DW ((L0212_InitFinished - L0212_Init2)) ;size +L0212_Init2: + ret + +L0212_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0212_Check: + DW ((L0212_CheckFinished - L0212_Check2)) ;size +L0212_Check2: + ret + +L0212_CheckFinished: +PRINT "0212 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0212_LoadFinished - L0212_Load2) +PRINT " / " +PRINT (L0212_InitFinished - L0212_Init2) +PRINT " / " +PRINT (L0212_CheckFinished - L0212_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0213.asm b/Source/Levels/L0213.asm new file mode 100644 index 0000000..d90212a --- /dev/null +++ b/Source/Levels/L0213.asm @@ -0,0 +1,249 @@ +; L0213.asm storming moonbase obliteration +; Generated 07.09.2000 by mlevel +; Modified 07.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0213Section",ROMX +;--------------------------------------------------------------------- + +L0213_Contents:: + DW L0213_Load + DW L0213_Init + DW L0213_Check + DW L0213_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0213_Load: + DW ((L0213_LoadFinished - L0213_Load2)) ;size +L0213_Load2: + call ParseMap + ret + +L0213_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0213_Map: +INCBIN "Data/Levels/L0213_intro_ba3.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_LIGHT EQU 0 +VAR_STATIC EQU 1 +VAR_FACEON EQU 2 + +MONITORINDEX EQU 36 +LIGHTINDEX EQU 40 +FACEINDEX EQU 44 +STATICINDEX EQU 48 + + +L0213_Init: + DW ((L0213_InitFinished - L0213_Init2)) ;size +L0213_Init2: + ld a,[bgTileMap+LIGHTINDEX] ;tile index of first light + ld [levelVars+VAR_LIGHT],a + ld a,[bgTileMap+STATICINDEX] ;tile index of monitor + ld [levelVars+VAR_STATIC],a + xor a + ld [levelVars+VAR_FACEON],a + + ;have general gyro face west + ld bc,classGeneralGyro + call FindClassIndex + ld c,a + call GetFirst + ld a,DIR_WEST + call SetFacing + ld b,METHOD_DRAW + call CallMethod + + ld bc,classGeneralGyro + ld de,classDoNothing + call ChangeClass + ret + +L0213_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0213_Check: + DW ((L0213_CheckFinished - L0213_Check2)) ;size +L0213_Check2: + ;animate dice lights + ld a,[levelVars+VAR_LIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+LIGHTINDEX + call ((.updateTwoLights - L0213_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L0213_Check2) + levelCheckRAM) + + ;animate static + ld a,[levelVars+VAR_STATIC] + ld b,a + ldio a,[updateTimer] + rrca + and %00000010 + add b + ld hl,bgTileMap+STATICINDEX + ld [hl+],a + inc a + ld [hl+],a + + ;----cycle monitor displays----------------------------------- + ld a,MAPBANK + ldio [$ff70],a + + ;pick a random location + ld a,22 + call GetRandomNumZeroToN + + ;ld a,31 + ;call GetRandomNumMask + ;cp 23 + ;jr nc,.afterScreen + + sla a + ld d,0 + ld e,a + ld hl,((.monitorLocations-L0213_Check2)+levelCheckRAM) + add hl,de + ld a,[hl+] + ld h,[hl] + ld l,a + + ;is this static? + ld a,[hl] + cp STATICINDEX + jr z,.staticToFace + + ;is this the face? + ld a,[hl] + cp FACEINDEX + jr z,.turnOffFace + + ;is the face on elsewhere? + ld a,[levelVars+VAR_FACEON] + or a + jr nz,.afterScreen ;face is on; skip + + ;turn this to static to become the face + ld a,1 + ld [levelVars+VAR_FACEON],a + ld a,STATICINDEX + jr .pickedScreen + +.turnOffFace + xor a + ld [levelVars+VAR_FACEON],a + ld a,MONITORINDEX ;monitor + jr .pickedScreen + +.staticToFace + ld a,FACEINDEX ;face +.pickedScreen + ld [hl+],a + inc a + ld [hl+],a + inc a + cp STATICINDEX+2 + jr nz,.afterStaticCheck + sub 2 +.afterStaticCheck + ld de,30 ;map pitch + add hl,de + ld [hl+],a + inc a + ld [hl+],a + +.afterScreen + ;----Check to see if confronting General Gyro----------------- + ld hl,hero0_data + call ((.checkConfrontGyro - L0213_Check2) + levelCheckRAM) + ld hl,hero1_data + call ((.checkConfrontGyro - L0213_Check2) + levelCheckRAM) + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L0213_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +.checkConfrontGyro + inc hl + ld a,[hl-] + or a ;look at the hero class index I've been given + ret z ;not present if zero + + ld c,a ;save class index + ld a,[hl] ;get my joy index + ld [dialogJoyIndex],a ;save that in case I talk + + ld de,HERODATA_TYPE + add hl,de + ld a,[hl] ;get my type + ld [dialogSpeakerIndex],a ;save that for talking too + + ;get my object then my zone + call GetFirst + call GetCurZone + + cp 9 ;in same zone as Gyro? + ret nz ;all for naught + + ld hl,$1302 ;next level + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + call YankRemotePlayer + ld a,1 + ld [timeToChangeLevel],a + ret + + +.monitorLocations +DW $d021,$d033,$d056,$d058,$d05a,$d05c ;6 +DW $d262,$d264,$d266 ;3 +DW $d2d2,$d312,$d352,$d392 ;4 +DW $d255,$d295,$d2d5,$d315,$d355,$d395 ;6 +DW $d25c,$d29c,$d2dc,$d31c ;4 23 + +L0213_CheckFinished: + +PRINT "0213 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0213_LoadFinished - L0213_Load2) +PRINT " / " +PRINT (L0213_InitFinished - L0213_Init2) +PRINT " / " +PRINT (L0213_CheckFinished - L0213_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0214.asm b/Source/Levels/L0214.asm new file mode 100644 index 0000000..debbc6f --- /dev/null +++ b/Source/Levels/L0214.asm @@ -0,0 +1,552 @@ +; L0214.asm skippy's prison +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0214Section",ROMX +;--------------------------------------------------------------------- + +L0214_Contents:: + DW L0214_Load + DW L0214_Init + DW L0214_Check + DW L0214_Map + +dialog: +haiku_enterPrison_gtx: + INCBIN "Data/Dialog/IntroHaiku/haiku_enterPrison.gtx" + +skippy_clues_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_clues.gtx" + +skippy_letsGo_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_letsGo.gtx" + +skippy_holdOn_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_holdOn.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0214_Load: + DW ((L0214_LoadFinished - L0214_Load2)) ;size +L0214_Load2: + call ParseMap + ret + +L0214_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0214_Map: +INCBIN "Data/Levels/L0214_intro_haiku3.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +STATE_INITIALDRAW EQU 0 +STATE_ENTER EQU 1 +STATE_CLUES EQU 2 +STATE_ALARMOFF EQU 3 +STATE_DIALOG_WAIT EQU 4 +STATE_WAIT_DIALOG EQU 4 +STATE_NEXTLEVEL EQU 5 +STATE_LEAVE EQU 6 +STATE_NORMAL EQU 7 + +VAR_LIGHT EQU 0 +VAR_FLASHER EQU 1 +VAR_PRISONOPEN EQU 2 + +LIGHTINDEX EQU 37 +FLASHERINDEX EQU 42 +GUARDINDEX EQU 48 +GOBLININDEX EQU 49 +SKIPPYINDEX EQU 50 + +L0214_Init: + DW ((L0214_InitFinished - L0214_Init2)) ;size +L0214_Init2: + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,[bgTileMap+LIGHTINDEX] ;tile index of first light + ld [levelVars+VAR_LIGHT],a + + ld a,[bgTileMap+FLASHERINDEX] ;tile index of first light + ld [levelVars+VAR_FLASHER],a + + ld bc,classCroutonDoctor + ld de,classGuard + call ChangeClass + + ;dest dest to unreachable so Skippy will pace around + ld c,SKIPPYINDEX + call GetFirst + ld hl,$d1ef + call SetActorDestLoc + + xor a + ld [guardAlarm],a + ldio [mapState],a + ld [levelVars + VAR_PRISONOPEN],a + + ret + +L0214_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0214_Check: + DW ((L0214_CheckFinished - L0214_Check2)) ;size +L0214_Check2: + call ((.animateLights - L0214_Check2) + levelCheckRAM) + call ((.moveGuards - L0214_Check2) + levelCheckRAM) + call ((.checkOpenPrison - L0214_Check2) + levelCheckRAM) + + ldio a,[mapState] + cp STATE_NORMAL + jr nz,.checkInitialDraw + + call ((.checkNearSkippy - L0214_Check2) + levelCheckRAM) + call ((.addGoblins - L0214_Check2) + levelCheckRAM) + + ret + +.checkInitialDraw + cp STATE_INITIALDRAW + jr nz,.checkAlarmOff + + ld a,STATE_ENTER + ldio [mapState],a + ret + +.checkAlarmOff + cp STATE_ALARMOFF + jr nz,.checkDialogWait + + call ((.checkNearSkippy - L0214_Check2) + levelCheckRAM) + ;fade the palette if alarm just tripped + ld a,[guardAlarm] + or a + ret z + + ld a,BANK(alarm_gbm) + ld hl,alarm_gbm + call InitMusic + + ld hl,gamePalette + ld de,fadeCurPalette + call CopyPalette64 + ld hl,((.darkRedPalette - L0214_Check2) + levelCheckRAM) + ld de,fadeFinalPalette + call CopyPalette32 + ld de,fadeFinalPalette+64 + call CopyPalette32 + ld a,16 + call FadeInit + ld de,gamePalette + call CopyPalette32 + ld de,gamePalette+64 + call CopyPalette32 + + ;remove door + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d023 + xor a + ld [hl+],a + ld [hl+],a + ld hl,$d242 + ld [hl+],a + ld [hl+],a + + ld a,STATE_NORMAL + ;ldio [mapState+1],a + ;ld a,STATE_DIALOG_WAIT + ldio [mapState],a + + ret + +.checkDialogWait + cp STATE_DIALOG_WAIT + jr nz,.checkNextLevel + + call CheckDialogContinue + or a + ret z + + call RestoreIdle + + ld bc,classDoNothing + ld de,classCroutonGoblin + call ChangeClass + ld bc,classDoNothing2 + ld de,classGuard + call ChangeClass + + ldio a,[mapState+1] + ldio [mapState],a + ret + +.checkNextLevel + cp STATE_NEXTLEVEL + jr nz,.checkEnter + + ld hl,$0314 + ld a,h + ld [curLevelIndex+1],a + ld a,l + ld [curLevelIndex],a + ld a,EXIT_D + call YankRemotePlayer + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.checkEnter + cp STATE_ENTER + jr nz,.checkClues + + ;ld a,1 + ;ld [heroesIdle],a + ;call SetSpeakerToFirstHero + ;ld a,BANK(haiku_enterPrison_gtx) + ;ld de,haiku_enterPrison_gtx + ;call ShowDialogAtBottomNoWait + ;ld a,STATE_CLUES + ;ldio [mapState+1],a + ;ld a,STATE_DIALOG_WAIT + ;ldio [mapState],a + + xor a + ld [heroesIdle],a + ld [allIdle],a + call SetSpeakerToFirstHero + DIALOGBOTTOM haiku_enterPrison_gtx + WAITDIALOG STATE_CLUES + ret + +.checkClues + cp STATE_CLUES + jr nz,.checkLeave + + xor a + ld [heroesIdle],a + ld [allIdle],a + ld c,SKIPPYINDEX + DIALOGTOP skippy_clues_gtx + WAITDIALOG STATE_ALARMOFF + ret + +.checkLeave + call ((.addGoblins - L0214_Check2) + levelCheckRAM) + ret + +;----support routines------------------------------------------------- + +.addGoblins + ;normal state + ;add goblins + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d023 + ld a,[hl] + or a + jr nz,.afterAddGoblin1 + + ld c,GOBLININDEX + call CreateInitAndDrawObject + +.afterAddGoblin1 + ld hl,$d242 + ld a,[hl] + or a + jr nz,.afterAddGoblin2 + + ld c,GOBLININDEX + call CreateInitAndDrawObject + +.afterAddGoblin2 + ret + +.checkOpenPrison + ld a,[levelVars + VAR_PRISONOPEN] + or a + ret nz + + ld a,[hero0_index] + call ((.checkHeroOpen - L0214_Check2) + levelCheckRAM) + ld a,[hero1_index] + call ((.checkHeroOpen - L0214_Check2) + levelCheckRAM) + ret + +.checkHeroOpen + or a + ret z + + ld c,a + ld [dialogSpeakerIndex],a + call GetFirst + call GetCurLocation + ld a,h + cp $d1 + ret nz + ld a,l + cp $ca + ret nz + + ;open bars + ld a,1 + ld [levelVars + VAR_PRISONOPEN],a + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d1cc + call ((.clearBars - L0214_Check2) + levelCheckRAM) + ld hl,$d1ec + call ((.clearBars - L0214_Check2) + levelCheckRAM) + ld hl,((.openBarsSound - L0214_Check2) + levelCheckRAM) + call PlaySound + ld c,SKIPPYINDEX + call GetFirst + ld hl,$d1ef + call SetActorDestLoc + ret + +.openBarsSound + DB 4,$00,$f4,$4f,$80 + +.clearBars + ld c,8 + xor a +.clearBarsLoop + ld [hl+],a + dec c + jr nz,.clearBarsLoop + ret + +.checkNearSkippy + ld a,[hero0_index] + call ((.checkHeroNearSkippy - L0214_Check2) + levelCheckRAM) + ld a,[hero1_index] + call ((.checkHeroNearSkippy - L0214_Check2) + levelCheckRAM) + ret + +.checkHeroNearSkippy + or a + ret z + + ld c,a + call GetFirst + call GetCurZone + cp 3 + ret nz + + call SetSpeakerFromHeroIndex + ld a,[guardAlarm] + or a + jr nz,.alarmIsOn + + ld a,1 + ld [heroesIdle],a + ld bc,classCroutonGoblin + ld de,classDoNothing + call ChangeClass + ld bc,classGuard + ld de,classDoNothing2 + call ChangeClass + ld a,BANK(skippy_letsGo_gtx) + ld de,skippy_letsGo_gtx + ld c,SKIPPYINDEX + call ShowDialogAtTopNoWait + + ld a,STATE_NEXTLEVEL + ldio [mapState+1],a + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ret + +.alarmIsOn + ld a,1 + ld [heroesIdle],a + ld bc,classCroutonGoblin + ld de,classDoNothing + call ChangeClass + ld bc,classGuard + ld de,classDoNothing2 + call ChangeClass + ld a,BANK(skippy_holdOn_gtx) + ld de,skippy_holdOn_gtx + ld c,SKIPPYINDEX + call ShowDialogAtTopNoWait + + ld a,STATE_LEAVE + ldio [mapState+1],a + ld a,STATE_DIALOG_WAIT + ldio [mapState],a + ret + +.animateLights + + ;animate dice lights + ld a,[levelVars+VAR_LIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+LIGHTINDEX + call ((.updateTwoLights - L0214_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L0214_Check2) + levelCheckRAM) + + ;flasher + ld a,[guardAlarm] + or a + jr z,.afterAnimateFlasher + + ld hl,levelVars+VAR_FLASHER + ldio a,[updateTimer] + rrca + rrca + push af + and %11 + add [hl] + ld [bgTileMap+FLASHERINDEX],a + pop af + and %100 + jr z,.afterAnimateFlasher + ld hl,((.klaxonSound - L0214_Check2) + levelCheckRAM) + call PlaySound +.afterAnimateFlasher + ret + +.moveGuards + ;----move guards---------------------------------------------- + ld c,GUARDINDEX + call GetFirst + or a + jr z,.afterMoveGuards + +.moveGuard + call IsActorAtDest + or a + jr z,.nextGuard + call GetCurLocation + push bc + push de + ld d,h ;save location + ld e,l + ld hl,((.patrolTable-L0214_Check2)+levelCheckRAM) + ld c,14 ;14 chances to find cur location + +.tryNextLocation + ld a,[hl+] + cp e + jr nz,.notTheOne + ld a,[hl] + cp d + jr nz,.notTheOne + + ;found it + pop de + pop bc + inc hl + ld a,[hl+] + ld h,[hl] + ld l,a + call SetActorDestLoc + jr .nextGuard + +.notTheOne + inc hl + inc hl + inc hl + dec c + jr nz,.tryNextLocation + pop de + pop bc + +.nextGuard + call GetNextObject + or a + jr nz,.moveGuard + +.afterMoveGuards + ret + +.patrolTable + DW $d042,$d046 + DW $d046,$d0a6 + DW $d0a6,$d0a2 + DW $d0a2,$d042 + + DW $d0eb,$d16b + DW $d16b,$d0eb + + DW $d0f1,$d171 + DW $d171,$d0f1 + + DW $d166,$d126 + DW $d126,$d166 + + DW $d204,$d202 + DW $d202,$d204 + + DW $d206,$d208 + DW $d208,$d206 + ;14 total + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L0214_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +.darkRedPalette +DW $0000, $0424, $0848, $0c6f +DW $0000, $0005, $000f, $0c6f +DW $0000, $080a, $0c4f, $0c6f +DW $0000, $0025, $006f, $0c6f +DW $0000, $0808, $082a, $0c6f +DW $0000, $0027, $006f, $0c6f +DW $0000, $0008, $002f, $0c6f +DW $0000, $0809, $0c2f, $0c6f + + +.klaxonSound + DB 4,$00,$f7,$5a,$c0 + +L0214_CheckFinished: +PRINT "0214 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0214_LoadFinished - L0214_Load2) +PRINT " / " +PRINT (L0214_InitFinished - L0214_Init2) +PRINT " / " +PRINT (L0214_CheckFinished - L0214_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0215.asm b/Source/Levels/L0215.asm new file mode 100644 index 0000000..04acbd5 --- /dev/null +++ b/Source/Levels/L0215.asm @@ -0,0 +1,1148 @@ +; L0215.asm BRAINIAC computer room +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + + +;--------------------------------------------------------------------- +SECTION "Level0215Section",ROMX +;--------------------------------------------------------------------- + +L0215_Contents:: + DW L0215_Load + DW L0215_Init + DW L0215_Check + DW L0215_Map + +brainiac_bg:: + INCBIN "Data/Cinema/Intro/brainiac.bg" + +haiku_bg:: + INCBIN "Data/Cinema/MainCharDialog/haiku.bg" + +dialog: +skippycapture_gyves1_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_gyves1.gtx" + +skippycapture_gyves1_2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_gyves1_2.gtx" + +skippycapture_brainiac1_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_brainiac1.gtx" + +skippycapture_skippy1_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_skippy1.gtx" + +skippycapture_skippy1_2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_skippy1_2.gtx" + +skippycapture_brainiac2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_brainiac2.gtx" + +skippycapture_skippy2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_skippy2.gtx" + +skippycapture_brainiac3_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_brainiac3.gtx" + +skippycapture_flour1_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_flour1.gtx" + +skippycapture_haiku1_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_haiku1.gtx" + +skippycapture_flour2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_flour2.gtx" + +skippycapture_haiku2_gtx: + INCBIN "Data/Dialog/Intro/skippycapture_haiku2.gtx" + +;----BS Dialog-------------------------------------- + +bs_justYouAnMe_gtx: + INCBIN "Data/Dialog/IntroBS/bs_justYouAnMe.gtx" + +brainiac_sorry_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_sorry.gtx" + +bs_answerSomeQuestions_gtx: + INCBIN "Data/Dialog/IntroBS/bs_answerSomeQuestions.gtx" + +brainiac_lovzHelping_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_lovzHelping.gtx" + +bs_showMe_gtx: + INCBIN "Data/Dialog/IntroBS/bs_showMe.gtx" + +brainiac_notNeedBRAINIAC_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_notNeedBRAINIAC.gtx" + +bs_gotAPoint_gtx: + INCBIN "Data/Dialog/IntroBS/bs_gotAPoint.gtx" + +brainiac_sezAsk_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_sezAsk.gtx" + +bs_reallyHard_gtx: + INCBIN "Data/Dialog/IntroBS/bs_reallyHard.gtx" + +brainiac_canAnswerAny_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_canAnswerAny.gtx" + +bs_hereGoes_gtx: + INCBIN "Data/Dialog/IntroBS/bs_hereGoes.gtx" + +brainiac_computes1_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes1.gtx" + +brainiac_computes2_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes2.gtx" + +brainiac_computes3_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes3.gtx" + +brainiac_computes4_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes4.gtx" + +brainiac_computes5_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes5.gtx" + +brainiac_computes6_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes6.gtx" + +brainiac_computes7_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_computes7.gtx" + +bs_well_gtx: + INCBIN "Data/Dialog/IntroBS/bs_well.gtx" + +brainiac_surrender_gtx: + INCBIN "Data/Dialog/IntroBS/brainiac_surrender.gtx" + +bs_wellSee_gtx: + INCBIN "Data/Dialog/IntroBS/bs_wellSee.gtx" + +STATE_MOVETOBRAINIAC EQU 1 +STATE_GYROTALKDELAY1 EQU 2 +STATE_GYROTALKDELAY2 EQU 3 +STATE_BRAINIACCINEMA EQU 4 +STATE_SKIPPY_CAPTURE EQU 5 +STATE_FLOUR_ORDERS_RESCUE EQU 6 +STATE_NORMAL EQU 7 +STATE_WAIT_DIALOG EQU 8 +STATE_BS1 EQU 9 +STATE_BS2 EQU 10 +STATE_BS3 EQU 11 +STATE_BS4 EQU 12 +STATE_BS5 EQU 13 +STATE_BS6 EQU 14 +STATE_BS7 EQU 15 +STATE_BS8 EQU 16 +STATE_BS9 EQU 17 +STATE_BS10 EQU 18 +STATE_BS11 EQU 19 +STATE_BS12 EQU 20 +STATE_BS13 EQU 21 +STATE_BS14 EQU 22 +STATE_BS15 EQU 23 +STATE_BS16 EQU 24 +STATE_BS17 EQU 25 +STATE_BS18 EQU 26 +STATE_BS19 EQU 27 +STATE_BS20 EQU 28 +STATE_BS21 EQU 29 + +VAR_LIGHT EQU 0 +VAR_GYRO EQU 1 +VAR_SKIPPY EQU 2 +VAR_DELAY EQU 3 +GYRO_DEST EQU $d0ce + +LIGHTINDEX EQU 45 +HULKINDEX EQU 134 +GRUNTINDEX EQU 135 +GYROINDEX EQU 137 +SKIPPYINDEX EQU 138 +PURPLEINDEX EQU 139 +YELLOWINDEX EQU 140 +BRAINIACINDEX EQU 141 + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0215_Load: + DW ((L0215_LoadFinished - L0215_Load2)) ;size +L0215_Load2: +;ld a,STATE_NORMAL +;ldio [mapState],a + ldio a,[mapState] + or a + jr nz,.notZero + + ld a,1 + ld [mapState],a + +.notZero + cp STATE_BRAINIACCINEMA + jr z,.brainiacCinema + + cp STATE_MOVETOBRAINIAC + jr z,.zeroHealth + + cp STATE_SKIPPY_CAPTURE + jr nz,.parseMap + + ld a,BANK(alarm_gbm) + ld hl,alarm_gbm + call InitMusic + +.zeroHealth + ;zero health so sparklies don't show up on screen + xor a + ld [hero0_health],a + ld [hero1_health],a + + ld a,2 + ld [canJoinMap],a + + +.parseMap + call ParseMap + ret + +.brainiacCinema + ;----display cinema scenes------------------------------------ + ;----"BRAINIAC givez it to you straight :)"------------------- + ld a,BANK(dialog) + ld [dialogBank],a + +.brain1 + ld hl,dialogSettings + res DLG_BORDER_BIT,[hl] + ld a,BANK(brainiac_bg) + ld hl,brainiac_bg + call LoadCinemaBG + call ((.fadeFromBlack16-L0215_Load2)+levelCheckRAM) + + ld de,((.skippy1 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + ld de,((.endCinemaPart1 - L0215_Load2) + levelCheckRAM) + call SetDialogSkip + + ld c,0 + ld de,skippycapture_brainiac1_gtx + call ShowDialogAtBottomNoWait + + ld d,4 + LONGCALLNOARGS AnimateBRAINIAC + + ;----"Well hot dang!!!"--------------------------------------- +.skippy1 + call ((.fadeToBlack1 - L0215_Load2) + levelCheckRAM) + call ((.loadSkippy - L0215_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L0215_Load2) + levelCheckRAM) + + ld de,((.skippy2 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + + ld c,0 + ld de,skippycapture_skippy1_gtx + call ShowDialogAtBottomNoWait + + ld d,3 + LONGCALLNOARGS AnimateSkippy + + ;----"just what were you fellers plannin to do"--------------- +.skippy2 + ld c,0 + ld de,skippycapture_skippy1_2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.brain2 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,5 + LONGCALLNOARGS AnimateSkippy + + ;----"we gonna capture big B12 officer"----------------------- +.brain2 + call ((.loadBRAINIAC - L0215_Load2) + levelCheckRAM) + + ld de,((.skippy3 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + + ld c,0 + ld de,skippycapture_brainiac2_gtx + call ShowDialogAtBottomNoWait + + ld d,6 + LONGCALLNOARGS AnimateBRAINIAC + + ;----"And just how were you thinkin you'd do that?"----------- +.skippy3 + call ((.fadeToBlack1 - L0215_Load2) + levelCheckRAM) + call ((.loadSkippy - L0215_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L0215_Load2) + levelCheckRAM) + + ld de,((.brain3 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + + ld c,0 + ld de,skippycapture_skippy2_gtx + call ShowDialogAtBottomNoWait + + ld d,4 + LONGCALLNOARGS AnimateSkippy + + ;----"BRAINIAC sez gonna make him think he capture the base"-- +.brain3 + call ((.loadBRAINIAC - L0215_Load2) + levelCheckRAM) + + ld de,((.endCinemaPart1 - L0215_Load2) + levelCheckRAM) + call SetDialogForward + + ld c,0 + ld de,skippycapture_brainiac3_gtx + call ShowDialogAtBottomNoWait + + ld d,6 + LONGCALLNOARGS AnimateBRAINIAC + +.endCinemaPart1 + call ClearDialog + + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld a,STATE_SKIPPY_CAPTURE + ldio [mapState],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.fadeToBlack1 + call ClearDialog + ld a,1 + call SetupFadeToBlack + jr .fadeCommon + +.fadeFromBlack1 + ld a,1 + call SetupFadeFromBlack + jr .fadeCommon + +.fadeToBlack16 + ld a,16 + call SetupFadeToBlack + jr .fadeCommon + +.fadeFromBlack16 + ld a,16 + call SetupFadeFromBlack + jr .fadeCommon + +.fadeCommon + call WaitFade + ret + +.loadSkippy + ld a,BANK(skippy_bg) + ld hl,skippy_bg + call LoadCinemaBG + ret + +.loadBRAINIAC + call ((.fadeToBlack1-L0215_Load2)+levelCheckRAM) + call ClearDialog + ld a,BANK(brainiac_bg) + ld hl,brainiac_bg + jr .loadCommon + ret + +.loadFlour + ld a,BANK(flour_bg) + ld hl,flour_bg + call LoadCinemaBG + ret + +.loadCommon + call LoadCinemaBG + call ((.fadeFromBlack1-L0215_Load2)+levelCheckRAM) + ret + +L0215_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0215_Map: +INCBIN "Data/Levels/L0215_intro_bs3.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0215_Init: + DW ((L0215_InitFinished - L0215_Init2)) ;size +L0215_Init2: +;ld a,STATE_NORMAL +;ldio [mapState],a + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,10 + ld [camera_i],a + ld [camera_j],a + ld a,1 + ld [mapLeft],a + + ld a,[bgTileMap+LIGHTINDEX] ;tile index of first light + ld [levelVars+VAR_LIGHT],a + + ldio a,[mapState] + cp STATE_MOVETOBRAINIAC + jr nz,.checkSkippyCapture + + ;----skippy and gyro moving to brainiac----------------------- + ;create Gyro, Skippy, and some B12 guards + call ((.removeHulks - L0215_Init2) + levelCheckRAM) + ld c,GYROINDEX ;gyro + ld hl,$d22a + call CreateInitAndDrawObject + ld hl,$d18e + call SetActorDestLoc + call PointerDEToIndex + ld [levelVars + VAR_GYRO],a + + ld c,SKIPPYINDEX ;skippy + ld hl,$d1ea + call CreateInitAndDrawObject + ld hl,$d14e + call SetActorDestLoc + call PointerDEToIndex + ld [levelVars + VAR_SKIPPY],a + + call ((.createGuards - L0215_Init2) + levelCheckRAM) + call ((.removeHeroes - L0215_Init2) + levelCheckRAM) + + ld bc,classB12Soldier + ld de,classDoNothing + call ChangeClass + + ld bc,classMajorSkippy + ld de,classActor2x2 + call ChangeClass + + ld bc,classGeneralGyro + ld de,classActor2x2 + call ChangeClass + ret + +.checkSkippyCapture + cp STATE_SKIPPY_CAPTURE + jr nz,.checkNormal + + ;----crouton grunts moving to kill guards--------------------- + call ((.removeHulks - L0215_Init2) + levelCheckRAM) + ld c,GYROINDEX + ld hl,$d0ce + call CreateInitAndDrawObject + ld b,DIR_EAST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + ld a,GROUP_MONSTERN + call SetGroup + + ld c,SKIPPYINDEX ;skippy + ld hl,$d0cb + call CreateInitAndDrawObject + ld b,DIR_EAST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + ld a,GROUP_MONSTERN + call SetGroup + + call ((.createGuards - L0215_Init2) + levelCheckRAM) + call ((.removeHeroes - L0215_Init2) + levelCheckRAM) + + ;create croutons + ld b,6 + ld hl,$d1e9 + call ((.createCroutons - L0215_Init2) + levelCheckRAM) + ld b,6 + ld hl,$d209 + call ((.createCroutons - L0215_Init2) + levelCheckRAM) + ld b,2 + ld hl,$d22a + call ((.createCroutons - L0215_Init2) + levelCheckRAM) + ld b,2 + ld hl,$d24a + call ((.createCroutons - L0215_Init2) + levelCheckRAM) + + ld bc,classMajorSkippy + ld de,classDoNothing + call ChangeClass + + ld bc,classGeneralGyro + ld de,classDoNothing + call ChangeClass + + ret + +.checkNormal + ;----BS Enters room, must kill hulks-------------------------- + ld a,30 ;delay after killing last hulk before text box + ld [levelVars + VAR_DELAY],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +.createGuards + ld c,PURPLEINDEX ;purple guard + ld hl,$d144 + call CreateInitAndDrawObject + ld b,DIR_EAST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + ld hl,$d184 + call CreateInitAndDrawObject + ld b,DIR_EAST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + + ld c,YELLOWINDEX ;yellow guard + ld hl,$d152 + call CreateInitAndDrawObject + ld b,DIR_WEST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + ld hl,$d192 + call CreateInitAndDrawObject + ld b,DIR_WEST + call ((.faceDirection - L0215_Init2) + levelCheckRAM) + ret + +.createCroutons + ld c,GRUNTINDEX ;crouton class index + call CreateInitAndDrawObject + inc hl + dec b + jr nz,.createCroutons + ret + +.faceDirection + ld a,b + call SetFacing + ld b,METHOD_DRAW + call CallMethod + ret + +.removeHeroes + ld a,[hero0_index] + call ((.removeHero - L0215_Init2) + levelCheckRAM) + + ld a,[hero1_index] + call ((.removeHero - L0215_Init2) + levelCheckRAM) + + ld a,1 + ld [heroesIdle],a + ret + +.removeHero + or a + ret z + ld c,a + call GetFirst + call GetFacing + ld c,a + call RemoveFromMap + ret + +.removeHulks + ld a,HULKINDEX + call DeleteObjectsOfClassIndex + ret + +L0215_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +;STATE_MOVETOBRAINIAC EQU 0 +;STATE_SKIPPY_CAPTURE EQU 1 +;STATE_NORMAL EQU 2 +L0215_Check: + DW ((L0215_CheckFinished - L0215_Check2)) ;size +L0215_Check2: + call SetSkipStackPos + call CheckSkip + + ;animate dice lights + ld a,[levelVars+VAR_LIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+LIGHTINDEX + call ((.updateTwoLights - L0215_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L0215_Check2) + levelCheckRAM) + + VECTORTOSTATE ((.stateTable - L0215_Check2) + levelCheckRAM) + +.stateTable + DW ((.checkMoveToBRAINIAC-L0215_Check2)+levelCheckRAM) + DW ((.checkMoveToBRAINIAC-L0215_Check2)+levelCheckRAM) + DW ((.checkGyroTalkDelay1-L0215_Check2)+levelCheckRAM) + DW ((.checkGyroTalkDelay2-L0215_Check2)+levelCheckRAM) + DW ((.checkBRAINIACCinema-L0215_Check2)+levelCheckRAM) + DW ((.checkSkippyCapture-L0215_Check2)+levelCheckRAM) + DW ((.checkFlourOrdersRescue-L0215_Check2)+levelCheckRAM) + DW ((.checkNormal-L0215_Check2)+levelCheckRAM) + DW ((.checkWaitDialog-L0215_Check2)+levelCheckRAM) + DW ((.checkBS1-L0215_Check2)+levelCheckRAM) + DW ((.checkBS2-L0215_Check2)+levelCheckRAM) + DW ((.checkBS3-L0215_Check2)+levelCheckRAM) + DW ((.checkBS4-L0215_Check2)+levelCheckRAM) + DW ((.checkBS5-L0215_Check2)+levelCheckRAM) + DW ((.checkBS6-L0215_Check2)+levelCheckRAM) + DW ((.checkBS7-L0215_Check2)+levelCheckRAM) + DW ((.checkBS8-L0215_Check2)+levelCheckRAM) + DW ((.checkBS9-L0215_Check2)+levelCheckRAM) + DW ((.checkBS10-L0215_Check2)+levelCheckRAM) + DW ((.checkBS11-L0215_Check2)+levelCheckRAM) + DW ((.checkBS12-L0215_Check2)+levelCheckRAM) + DW ((.checkBS13-L0215_Check2)+levelCheckRAM) + DW ((.checkBS14-L0215_Check2)+levelCheckRAM) + DW ((.checkBS15-L0215_Check2)+levelCheckRAM) + DW ((.checkBS16-L0215_Check2)+levelCheckRAM) + DW ((.checkBS17-L0215_Check2)+levelCheckRAM) + DW ((.checkBS18-L0215_Check2)+levelCheckRAM) + DW ((.checkBS19-L0215_Check2)+levelCheckRAM) + DW ((.checkBS20-L0215_Check2)+levelCheckRAM) + DW ((.checkBS21-L0215_Check2)+levelCheckRAM) + +.checkNormal + ;normal state + ;wait 'till all hulks are dead + ld c,HULKINDEX + call GetFirst + or a + ret nz + + ld a,1 + ld [heroesIdle],a + ld a,STATE_BS1 + ldio [mapState],a + ret + +.checkWaitDialog + STDWAITDIALOG + ret + +.setupBRAINIAC + call SetSpeakerToFirstHero + ld c,BRAINIACINDEX + ld hl,dialogSettings + set DLG_BRAINIAC_BIT,[hl] + ret + +.checkBS1 + ld hl,levelVars + VAR_DELAY ;allow bullets to explode etc + dec [hl] + ret nz + + ld de,((.endBSBRAINIAC - L0215_Check2) + levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_justYouAnMe_gtx + WAITDIALOG STATE_BS2 + ret +.checkBS2 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_sorry_gtx + WAITDIALOG STATE_BS3 + ret +.checkBS3 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_answerSomeQuestions_gtx + WAITDIALOG STATE_BS4 + ret +.checkBS4 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_lovzHelping_gtx + WAITDIALOG STATE_BS5 + ret +.checkBS5 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_showMe_gtx + WAITDIALOG STATE_BS6 + ret +.checkBS6 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_notNeedBRAINIAC_gtx + WAITDIALOG STATE_BS7 + ret +.checkBS7 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_gotAPoint_gtx + WAITDIALOG STATE_BS8 + ret +.checkBS8 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_sezAsk_gtx + WAITDIALOG STATE_BS9 + ret +.checkBS9 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_reallyHard_gtx + WAITDIALOG STATE_BS10 + ret +.checkBS10 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_canAnswerAny_gtx + WAITDIALOG STATE_BS11 + ret +.checkBS11 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_hereGoes_gtx + WAITDIALOG STATE_BS12 + ret +.checkBS12 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes1_gtx + WAITDIALOGNOCLEAR STATE_BS13 + ret +.checkBS13 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes2_gtx + WAITDIALOGNOCLEAR STATE_BS14 + ret +.checkBS14 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes3_gtx + WAITDIALOGNOCLEAR STATE_BS15 + ret +.brainiacPrint + ld h,29 + ld de,$1205 + ld bc,$0203 + call BlitMap + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + ret +.checkBS15 + ld l,1 + call ((.brainiacPrint-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes4_gtx + WAITDIALOGNOCLEAR STATE_BS16 + ret +.checkBS16 + ld l,4 + call ((.brainiacPrint-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes5_gtx + WAITDIALOGNOCLEAR STATE_BS17 + ret +.checkBS17 + ld l,7 + call ((.brainiacPrint-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes6_gtx + WAITDIALOGNOCLEAR STATE_BS18 + ret +.checkBS18 + ld l,10 + call ((.brainiacPrint-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_computes7_gtx + WAITDIALOG STATE_BS19 + ret +.checkBS19 + call SetSpeakerToFirstHero + DIALOGBOTTOM bs_well_gtx + WAITDIALOG STATE_BS20 + ret +.checkBS20 + call ((.setupBRAINIAC-L0215_Check2)+levelCheckRAM) + DIALOGTOP brainiac_surrender_gtx + WAITDIALOG STATE_BS21 + ret +.checkBS21 + ;call SetSpeakerToFirstHero + ;DIALOGBOTTOM bs_wellSee_gtx +.endBSBRAINIAC + call ClearDialog + ld a,96 + call SetupFadeToStandard + call WaitFade + ld hl,fadeFinalPalette + ld de,gamePalette + call CopyPalette64 + + ld hl,$1402 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + call YankRemotePlayer + ld a,1 + ld [timeToChangeLevel],a + ret + + +.checkMoveToBRAINIAC + ld de,((.checkBRAINIACCinema - L0215_Check2) + levelCheckRAM) + call SetDialogSkip + ld de,((.bothAtFinalDest - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ;skippy there yet? + ld c,SKIPPYINDEX ;skippy class index + ld a,[levelVars + VAR_SKIPPY] + call ((.checkActorAtDest - L0215_Check2) + levelCheckRAM) + jr z,.afterResetSkippy + + ;reset skippy once he gets to his waypoint + call GetCurZone + cp 4 + jr nz,.afterResetSkippy + + ld hl,$d0cb + call SetActorDestLoc + ret + +.checkActorAtDest + call IndexToPointerDE + call IsActorAtDest + or a + ret + +.afterResetSkippy + ;do the same for gyro + ld c,GYROINDEX + ld a,[levelVars + VAR_GYRO] + call ((.checkActorAtDest - L0215_Check2) + levelCheckRAM) + ret z + + call GetCurZone + cp 4 + jr nz,.bothAtFinalDest + + ld hl,GYRO_DEST + call SetActorDestLoc + ret + +.bothAtFinalDest + call SetSpeakerToFirstHero + ld c,GYROINDEX + ld de,skippycapture_gyves1_gtx + call ShowDialogAtBottomNoWait + + ld de,((.checkBRAINIACCinema - L0215_Check2) + levelCheckRAM) + call SetDialogSkip + ld de,((.gyvesIntroduce2 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ld a,100 + ld [levelVars + VAR_DELAY],a + ld a,STATE_GYROTALKDELAY1 + ldio [mapState],a + ret + +.checkGyroTalkDelay1 + ld hl,levelVars + VAR_DELAY + dec [hl] + ret nz + +.gyvesIntroduce2 + ld a,140 ;reset delay for next dialog + ld [levelVars + VAR_DELAY],a + + ;display second half of dialog + ld c,GYROINDEX ;gyro class index + ld de,skippycapture_gyves1_2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.checkBRAINIACCinema - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ld a,STATE_GYROTALKDELAY2 + ldio [mapState],a + ld a,1 + ;ld [timeToChangeLevel],a + ret + +.checkGyroTalkDelay2 + ld hl,levelVars + VAR_DELAY + dec [hl] + ret nz + +.checkBRAINIACCinema + call ClearDialog + ld a,STATE_BRAINIACCINEMA + ldio [mapState],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.checkSkippyCapture + ld de,((.fadeOut - L0215_Check2) + levelCheckRAM) + call SetDialogForward + call SetDialogSkip + + ;wait until all the guards (PURPLEINDEX & YELLOWINDEX are dead + ;OR all the croutons (GRUNTINDEX) are dead (god forbid) + ld c,PURPLEINDEX + call GetFirst + or a + jr nz,.checkCroutonsRemaining + + ld c,YELLOWINDEX + call GetFirst + or a + jr z,.fadeOut + +.checkCroutonsRemaining + ld c,GRUNTINDEX + call GetFirst + or a + ret nz + +.fadeOut + ld a,96 + call SetupFadeToBlack + + ld de,0 + call SetDialogForward + call SetDialogSkip + + ld a,STATE_FLOUR_ORDERS_RESCUE + ldio [mapState],a + + ret + +.checkFlourOrdersRescue +.isFlourOrdersRescue + ld a,[specialFX] + and FX_FADE + ret nz + + ld hl,dialogSettings + res DLG_BORDER_BIT,[hl] + call ResetSprites + ld a,BANK(moon_bg) + ld hl,moon_bg + call LoadCinemaBG + + ld de,((.endCinemaPart2 - L0215_Check2) + levelCheckRAM) + call SetDialogSkip + ld de,((.flour1 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ld a,60 + call SetupFadeFromBlack + call WaitFade + + ld a,60 + call Delay + + call ((.fadeToBlack16-L0215_Check2)+levelCheckRAM) + + ld a,BANK(triumphBIG_bg) + ld hl,triumphBIG_bg + call LoadCinemaBG + + ld bc,$140c + ld hl,$1402 + ld de,$0000 + call CinemaBlitRect + ld a,1 + call Delay + + call ((.fadeFromBlack16-L0215_Check2)+levelCheckRAM) + + ld a,30 + call Delay + +.flour1 + ;----"Oh my gosh Major Skippy's been kidnapped!"-------------- + call ((.fadeToBlack16-L0215_Check2)+levelCheckRAM) + call ((.loadFlour - L0215_Check2) + levelCheckRAM) + call ((.fadeFromBlack16-L0215_Check2)+levelCheckRAM) + + ld c,0 + ld de,skippycapture_flour1_gtx + call ShowDialogAtBottomNoWait + + ld de,((.haiku1 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ld d,6 + LONGCALLNOARGS AnimateFlour + +.haiku1 + ;----"Yes what is it?"---------------------------------------- + call ((.loadHaiku - L0215_Check2) + levelCheckRAM) + + ld a,BANK(haiku_gbm) + ld hl,haiku_gbm + call InitMusic + + ld c,0 + ld de,skippycapture_haiku1_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour2 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + LONGCALLNOARGS AnimateHaiku + +.flour2 + ;----"Take your merry band of Ninjas..."---------------------- + call ((.fadeToBlack1-L0215_Check2)+levelCheckRAM) + call ((.loadFlour - L0215_Check2) + levelCheckRAM) + call ((.fadeFromBlack1-L0215_Check2)+levelCheckRAM) + + ld c,0 + ld de,skippycapture_flour2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.haiku2 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + ld d,6 + LONGCALLNOARGS AnimateFlour + +.haiku2 + ;----"I will take Quatrain..."-------------------------------- + call ((.loadHaiku - L0215_Check2) + levelCheckRAM) + + ld c,0 + ld de,skippycapture_haiku2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.endCinemaPart2 - L0215_Check2) + levelCheckRAM) + call SetDialogForward + + LONGCALLNOARGS AnimateHaiku + +.endCinemaPart2 + call ClearDialog + + ;ld a,16 + ;call SetupFadeToWhite + ;call WaitFade + + ld hl,2058 ;haiku + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_HAIKU_FLAG + ld [hero0_type],a + + ld hl,FREEVERSE_CINDEX + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_BS_FLAG + ld [hero1_type],a + + xor a + ld [hero0_health],a + ld [hero1_health],a + + ld hl,$0014 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld a,1 + ld [timeToChangeLevel],a + + ld a,STATE_NORMAL + ldio [mapState],a + + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L0215_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.fadeToBlack1 + ld a,1 + call SetupFadeToBlack + jr .fadeCommon + +.fadeFromBlack1 + ld a,1 + call SetupFadeFromBlack + jr .fadeCommon + +.fadeToBlack16 + ld a,16 + call SetupFadeToBlack + jr .fadeCommon + +.fadeFromBlack16 + ld a,16 + call SetupFadeFromBlack + jr .fadeCommon + +.fadeCommon + call WaitFade + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +.loadSkippy + ld a,BANK(skippy_bg) + ld hl,skippy_bg + jr .loadCommon + ret + +.loadFlour + ld a,BANK(flour_bg) + ld hl,flour_bg + call LoadCinemaBG + ret + +.loadHaiku + call ((.fadeToBlack1-L0215_Check2)+levelCheckRAM) + ld a,BANK(haiku_bg) + ld hl,haiku_bg + jr .loadCommon + ret + +.loadCommon + call LoadCinemaBG + call ((.fadeFromBlack1-L0215_Check2)+levelCheckRAM) + ret + +L0215_CheckFinished: +PRINT "0215 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0215_LoadFinished - L0215_Load2) +PRINT " / " +PRINT (L0215_InitFinished - L0215_Init2) +PRINT " / " +PRINT (L0215_CheckFinished - L0215_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0300.asm b/Source/Levels/L0300.asm new file mode 100644 index 0000000..8e5ef75 --- /dev/null +++ b/Source/Levels/L0300.asm @@ -0,0 +1,59 @@ +; L0300.asm +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0300Section",ROMX +;--------------------------------------------------------------------- + +L0300_Contents:: + DW L0300_Load + DW L0300_Init + DW L0300_Check + DW L0300_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0300_Load: + DW ((L0300_LoadFinished - L0300_Load2)) ;size +L0300_Load2: + call ParseMap + ret + +L0300_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0300_Map: +INCBIN "Data/Levels/L0300_mist.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0300_Init: + DW ((L0300_InitFinished - L0300_Init2)) ;size +L0300_Init2: + ret + +L0300_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0300_Check: + DW ((L0300_CheckFinished - L0300_Check2)) ;size +L0300_Check2: + ret + +L0300_CheckFinished: +PRINT "0300 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0300_LoadFinished - L0300_Load2) +PRINT " / " +PRINT (L0300_InitFinished - L0300_Init2) +PRINT " / " +PRINT (L0300_CheckFinished - L0300_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0301.asm b/Source/Levels/L0301.asm new file mode 100644 index 0000000..267211b --- /dev/null +++ b/Source/Levels/L0301.asm @@ -0,0 +1,74 @@ +; L0301.asm mist se of evil village +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0301Section",ROMX +;--------------------------------------------------------------------- + +L0301_Contents:: + DW L0301_Load + DW L0301_Init + DW L0301_Check + DW L0301_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0301_Load: + DW ((L0301_LoadFinished - L0301_Load2)) ;size +L0301_Load2: + call ParseMap + ret + +L0301_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0301_Map: +INCBIN "Data/Levels/L0301_mist.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0301_Init: + DW ((L0301_InitFinished - L0301_Init2)) ;size +L0301_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0301_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0301_Check: + DW ((L0301_CheckFinished - L0301_Check2)) ;size +L0301_Check2: + call ((.animateWater-L0301_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0301_CheckFinished: +PRINT "0301 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0301_LoadFinished - L0301_Load2) +PRINT " / " +PRINT (L0301_InitFinished - L0301_Init2) +PRINT " / " +PRINT (L0301_CheckFinished - L0301_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0302.asm b/Source/Levels/L0302.asm new file mode 100644 index 0000000..498cfd2 --- /dev/null +++ b/Source/Levels/L0302.asm @@ -0,0 +1,111 @@ +; L0302.asm mist landing +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +LIGHTINDEX EQU 61 +VAR_WATER EQU 0 +VAR_LIGHT EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0302Section",ROMX +;--------------------------------------------------------------------- + +L0302_Contents:: + DW L0302_Load + DW L0302_Init + DW L0302_Check + DW L0302_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0302_Load: + DW ((L0302_LoadFinished - L0302_Load2)) ;size +L0302_Load2: + call ParseMap + ret + +L0302_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0302_Map: +INCBIN "Data/Levels/L0302_mistland.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0302_Init: + DW ((L0302_InitFinished - L0302_Init2)) ;size +L0302_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + ld a,BANK(mysterious_gbm) + ld hl,mysterious_gbm + call InitMusic + ret + +L0302_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0302_Check: + DW ((L0302_CheckFinished - L0302_Check2)) ;size +L0302_Check2: + call ((.animateWater-L0302_Check2)+levelCheckRAM) + call ((.animateLandingLights-L0302_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0302_Check2)+levelCheckRAM) + call ((.animateLight-L0302_Check2)+levelCheckRAM) + call ((.animateLight-L0302_Check2)+levelCheckRAM) + call ((.animateLight-L0302_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0302_CheckFinished: +PRINT "0302 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0302_LoadFinished - L0302_Load2) +PRINT " / " +PRINT (L0302_InitFinished - L0302_Init2) +PRINT " / " +PRINT (L0302_CheckFinished - L0302_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0303.asm b/Source/Levels/L0303.asm new file mode 100644 index 0000000..8a87915 --- /dev/null +++ b/Source/Levels/L0303.asm @@ -0,0 +1,78 @@ +; L0303.asm mist stone henge +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 3 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0303Section",ROMX +;--------------------------------------------------------------------- + +L0303_Contents:: + DW L0303_Load + DW L0303_Init + DW L0303_Check + DW L0303_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0303_Load: + DW ((L0303_LoadFinished - L0303_Load2)) ;size +L0303_Load2: + call ParseMap + ret + +L0303_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0303_Map: +INCBIN "Data/Levels/L0303_stone_mist.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0303_Init: + DW ((L0303_InitFinished - L0303_Init2)) ;size +L0303_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld a,BANK(mysterious_gbm) + ld hl,mysterious_gbm + call InitMusic + ret + +L0303_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0303_Check: + DW ((L0303_CheckFinished - L0303_Check2)) ;size +L0303_Check2: + call ((.animateWater-L0303_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0303_CheckFinished: +PRINT "0303 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0303_LoadFinished - L0303_Load2) +PRINT " / " +PRINT (L0303_InitFinished - L0303_Init2) +PRINT " / " +PRINT (L0303_CheckFinished - L0303_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0304.asm b/Source/Levels/L0304.asm new file mode 100644 index 0000000..9989c02 --- /dev/null +++ b/Source/Levels/L0304.asm @@ -0,0 +1,253 @@ +; L0304.asm pansies eat shrooms +; Generated 08.03.2000 by mlevel +; Modified 08.03.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0304Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0304_spores_gtx: + INCBIN "Data/Dialog/Talk/L0304_spores.gtx" + +L0304_Contents:: + DW L0304_Load + DW L0304_Init + DW L0304_Check + DW L0304_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0304_Load: + DW ((L0304_LoadFinished - L0304_Load2)) ;size +L0304_Load2: + call ParseMap + ret + +L0304_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0304_Map: +INCBIN "Data/Levels/L0304_shroom.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +PANSYINDEX1 EQU 45 +PANSYINDEX2 EQU 46 +PANSYINDEX3 EQU 47 +LOWSHROOMINDEX EQU 2 +HIGHSHROOMINDEX EQU 13 + +MAPPITCH EQU 32 + +STATE_NORMAL_INIT EQU 1 +STATE_NORMAL_TALK EQU 2 +STATE_NORMAL EQU 3 +STATE_SOLVED_INIT EQU 4 +STATE_SOLVED_TALK EQU 5 +STATE_SOLVED EQU 6 + +L0304_Init: + DW ((L0304_InitFinished - L0304_Init2)) ;size +L0304_Init2: + ldio a,[mapState] + ld hl,((.resetStateTable-L0304_Init2)+levelCheckRAM) + call Lookup8 + ldio [mapState],a + + STDSETUPDIALOG + + ld bc,ITEM_SPOREMASK + call HasInventoryItem + jr nz,.hasMask + + ld hl,HOffsetOnHBlank + call InstallHBlankHandler +.hasMask + + ;ld a,BANK(shroom_gbm) + ;ld hl,shroom_gbm + ;call InitMusic + + ;set the pansies to be friendly and to eat the shrooms + ld c,PANSYINDEX1 + call ((.makeFriendly-L0304_Init2)+levelCheckRAM) + ld c,PANSYINDEX2 + call ((.makeFriendly-L0304_Init2)+levelCheckRAM) + ld c,PANSYINDEX3 + call ((.makeFriendly-L0304_Init2)+levelCheckRAM) + + ld bc,classPansy + ld de,classHippiePansy + call ChangeClass + + ;remove the shrooms blocking the exit if level solved already + ldio a,[mapState] + cp STATE_SOLVED_INIT + ret nz + + ld hl,$d1dd + call ((.remove2x2-L0304_Init2)+levelCheckRAM) + + ld hl,$d23d + call ((.remove2x2-L0304_Init2)+levelCheckRAM) + ret + +.makeFriendly + call GetFirst + or a + ret z + +.continue + ld a,GROUP_MONSTERB + call SetGroup + ld hl,((HIGHSHROOMINDEX<<8) | LOWSHROOMINDEX) + call SetActorDestLoc + call GetNextObject + or a + jr nz,.continue + ret + +.remove2x2 + ld a,MAPBANK + ldio [$ff70],a + xor a + ld [hl+],a + ld [hl-],a + ld de,MAPPITCH + add hl,de + ld [hl+],a + ld [hl],a + ret + +.resetStateTable + DB STATE_NORMAL_INIT,STATE_NORMAL_INIT,STATE_NORMAL_INIT + DB STATE_NORMAL_INIT,STATE_SOLVED_INIT,STATE_SOLVED_INIT + DB STATE_SOLVED_INIT + +L0304_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0304_Check: + DW ((L0304_CheckFinished - L0304_Check2)) ;size +L0304_Check2: + call ((.updateWave-L0304_Check2)+levelCheckRAM) + ldio a,[mapState] + + cp STATE_NORMAL_INIT + jr z,.initialUpdate + cp STATE_SOLVED_INIT + jr z,.initialUpdate + + cp STATE_NORMAL_TALK + jr z,.talk + cp STATE_SOLVED_TALK + jr z,.talk + + ld a,1 + ld hl,((.checkSolved-L0304_Check2)+levelCheckRAM) + call CheckEachHero + ret + +.initialUpdate + inc a + ldio [mapState],a + ret + +.talk + ld bc,ITEM_SPOREMASK + call HasInventoryItem + jr nz,.afterTalk + + call MakeIdle + + ld de,((.afterTalk-L0304_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,L0304_spores_gtx + call ShowDialogAtBottom +.afterTalk + call ClearDialogSkipForward + call MakeNonIdle + ldio a,[mapState] + inc a + ldio [mapState],a + ret + +.checkSolved + or a + ret z + + ld c,a + call GetFirst ;get my hero object + call GetCurZone + cp 2 + jr z,.inZone2 + xor a ;return false + ret + +.inZone2 + ;in zone 2, level solved + ld a,STATE_SOLVED + ldio [mapState],a + ld a,1 ;return true + ret + +.updateWave + ld bc,ITEM_SPOREMASK + call HasInventoryItem + ret nz + + ;fill the horizontalOffset table with values from the sine table + ld a,TILEINDEXBANK + ldio [$ff70],a + ldio a,[updateTimer] + and 63 + ld e,a + ld d,0 + ld hl,((.sineTable-L0304_Check2)+levelCheckRAM) + add hl,de + ld de,horizontalOffset + ld c,144 +.updateLoop + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.updateLoop + + ld a,[horizontalOffset] + ld [lineZeroHorizontalOffset],a + + ld hl,hblankFlag + set 2,[hl] + + ret + +.sineTable ;four 64-byte sine waves, values between 0 and 7 +REPT 4 +DB 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7 +DB 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4 +DB 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 +DB 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3 +ENDR + +L0304_CheckFinished: +PRINT "0304 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0304_LoadFinished - L0304_Load2) +PRINT " / " +PRINT (L0304_InitFinished - L0304_Init2) +PRINT " / " +PRINT (L0304_CheckFinished - L0304_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0305.asm b/Source/Levels/L0305.asm new file mode 100644 index 0000000..4b7ce2f --- /dev/null +++ b/Source/Levels/L0305.asm @@ -0,0 +1,59 @@ +; L0305.asm +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0305Section",ROMX +;--------------------------------------------------------------------- + +L0305_Contents:: + DW L0305_Load + DW L0305_Init + DW L0305_Check + DW L0305_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0305_Load: + DW ((L0305_LoadFinished - L0305_Load2)) ;size +L0305_Load2: + call ParseMap + ret + +L0305_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0305_Map: +INCBIN "Data/Levels/L0305_path.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0305_Init: + DW ((L0305_InitFinished - L0305_Init2)) ;size +L0305_Init2: + ret + +L0305_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0305_Check: + DW ((L0305_CheckFinished - L0305_Check2)) ;size +L0305_Check2: + ret + +L0305_CheckFinished: +PRINT "0305 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0305_LoadFinished - L0305_Load2) +PRINT " / " +PRINT (L0305_InitFinished - L0305_Init2) +PRINT " / " +PRINT (L0305_CheckFinished - L0305_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0306.asm b/Source/Levels/L0306.asm new file mode 100644 index 0000000..8fb6fca --- /dev/null +++ b/Source/Levels/L0306.asm @@ -0,0 +1,61 @@ +; L0306.asm Two Guns +; Generated 11.07.2000 by mlevel +; Modified 11.07.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0306Section",ROMX +;--------------------------------------------------------------------- + +L0306_Contents:: + DW L0306_Load + DW L0306_Init + DW L0306_Check + DW L0306_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0306_Load: + DW ((L0306_LoadFinished - L0306_Load2)) ;size +L0306_Load2: + call ParseMap + ret + +L0306_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0306_Map: +INCBIN "Data/Levels/L0306_twoguns.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0306_Init: + DW ((L0306_InitFinished - L0306_Init2)) ;size +L0306_Init2: + ld a,ENV_DIRT + call SetEnvEffect + ret + +L0306_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0306_Check: + DW ((L0306_CheckFinished - L0306_Check2)) ;size +L0306_Check2: + ret + +L0306_CheckFinished: +PRINT "0306 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0306_LoadFinished - L0306_Load2) +PRINT " / " +PRINT (L0306_InitFinished - L0306_Init2) +PRINT " / " +PRINT (L0306_CheckFinished - L0306_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0307.asm b/Source/Levels/L0307.asm new file mode 100644 index 0000000..e1f7348 --- /dev/null +++ b/Source/Levels/L0307.asm @@ -0,0 +1,66 @@ +; L0307.asm crouton outpost: desolation +; Generated 11.07.2000 by mlevel +; Modified 11.07.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0307Section",ROMX +;--------------------------------------------------------------------- + +L0307_Contents:: + DW L0307_Load + DW L0307_Init + DW L0307_Check + DW L0307_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0307_Load: + DW ((L0307_LoadFinished - L0307_Load2)) ;size +L0307_Load2: + call ParseMap + ret + +L0307_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0307_Map: +INCBIN "Data/Levels/L0307_outpost.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0307_Init: + DW ((L0307_InitFinished - L0307_Init2)) ;size +L0307_Init2: + ld a,ENV_DIRT + call SetEnvEffect + + ld bc,ITEM_CODE0307 + call RemoveClearanceIfTaken + ret + +L0307_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0307_Check: + DW ((L0307_CheckFinished - L0307_Check2)) ;size +L0307_Check2: + ret + +L0307_CheckFinished: +PRINT "0307 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0307_LoadFinished - L0307_Load2) +PRINT " / " +PRINT (L0307_InitFinished - L0307_Init2) +PRINT " / " +PRINT (L0307_CheckFinished - L0307_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0308.asm b/Source/Levels/L0308.asm new file mode 100644 index 0000000..7ac4c2d --- /dev/null +++ b/Source/Levels/L0308.asm @@ -0,0 +1,61 @@ +; L0308.asm desert bridge +; Generated 11.07.2000 by mlevel +; Modified 11.07.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0308Section",ROMX +;--------------------------------------------------------------------- + +L0308_Contents:: + DW L0308_Load + DW L0308_Init + DW L0308_Check + DW L0308_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0308_Load: + DW ((L0308_LoadFinished - L0308_Load2)) ;size +L0308_Load2: + call ParseMap + ret + +L0308_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0308_Map: +INCBIN "Data/Levels/L0308_drylake.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0308_Init: + DW ((L0308_InitFinished - L0308_Init2)) ;size +L0308_Init2: + ld a,ENV_DIRT + call SetEnvEffect + ret + +L0308_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0308_Check: + DW ((L0308_CheckFinished - L0308_Check2)) ;size +L0308_Check2: + ret + +L0308_CheckFinished: +PRINT "0308 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0308_LoadFinished - L0308_Load2) +PRINT " / " +PRINT (L0308_InitFinished - L0308_Init2) +PRINT " / " +PRINT (L0308_CheckFinished - L0308_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0309.asm b/Source/Levels/L0309.asm new file mode 100644 index 0000000..bdca005 --- /dev/null +++ b/Source/Levels/L0309.asm @@ -0,0 +1,59 @@ +; L0309.asm +; Generated 11.14.2000 by mlevel +; Modified 11.14.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0309Section",ROMX +;--------------------------------------------------------------------- + +L0309_Contents:: + DW L0309_Load + DW L0309_Init + DW L0309_Check + DW L0309_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0309_Load: + DW ((L0309_LoadFinished - L0309_Load2)) ;size +L0309_Load2: + call ParseMap + ret + +L0309_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0309_Map: +INCBIN "Data/Levels/L0309_desert.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0309_Init: + DW ((L0309_InitFinished - L0309_Init2)) ;size +L0309_Init2: + ret + +L0309_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0309_Check: + DW ((L0309_CheckFinished - L0309_Check2)) ;size +L0309_Check2: + ret + +L0309_CheckFinished: +PRINT "0309 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0309_LoadFinished - L0309_Load2) +PRINT " / " +PRINT (L0309_InitFinished - L0309_Init2) +PRINT " / " +PRINT (L0309_CheckFinished - L0309_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0310.asm b/Source/Levels/L0310.asm new file mode 100644 index 0000000..83574b7 --- /dev/null +++ b/Source/Levels/L0310.asm @@ -0,0 +1,93 @@ +; L0310.asm desert landing +; Generated 11.03.2000 by mlevel +; Modified 11.03.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 59 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0310Section",ROMX +;--------------------------------------------------------------------- + +L0310_Contents:: + DW L0310_Load + DW L0310_Init + DW L0310_Check + DW L0310_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0310_Load: + DW ((L0310_LoadFinished - L0310_Load2)) ;size +L0310_Load2: + call ParseMap + ret + +L0310_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0310_Map: +INCBIN "Data/Levels/L0310_desertland.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0310_Init: + DW ((L0310_InitFinished - L0310_Init2)) ;size +L0310_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + ret + +L0310_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0310_Check: + DW ((L0310_CheckFinished - L0310_Check2)) ;size +L0310_Check2: + call ((.animateLandingLights-L0310_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0310_Check2)+levelCheckRAM) + call ((.animateLight-L0310_Check2)+levelCheckRAM) + call ((.animateLight-L0310_Check2)+levelCheckRAM) + call ((.animateLight-L0310_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0310_CheckFinished: +PRINT "0310 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0310_LoadFinished - L0310_Load2) +PRINT " / " +PRINT (L0310_InitFinished - L0310_Init2) +PRINT " / " +PRINT (L0310_CheckFinished - L0310_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0311.asm b/Source/Levels/L0311.asm new file mode 100644 index 0000000..0474ae3 --- /dev/null +++ b/Source/Levels/L0311.asm @@ -0,0 +1,90 @@ +; L0311.asm +; Generated 10.20.2000 by mlevel +; Modified 10.20.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +FIRST_HOLE EQU 25 + +;--------------------------------------------------------------------- +SECTION "Level0311Section",ROMX +;--------------------------------------------------------------------- + +L0311_Contents:: + DW L0311_Load + DW L0311_Init + DW L0311_Check + DW L0311_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0311_Load: + DW ((L0311_LoadFinished - L0311_Load2)) ;size +L0311_Load2: + call ParseMap + + ;alter yellow palette to purple w/black + ld a,FADEBANK + ld bc,6 + ld de,gamePalette + 5*8 + 2 + ld hl,((.purpleBlackPalette-L0311_Load2)+levelCheckRAM) + call MemCopy + ret + +.purpleBlackPalette + DW $4008,$5192,$0000 + +L0311_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0311_Map: +INCBIN "Data/Levels/L0311_tower.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0311_Init: + DW ((L0311_InitFinished - L0311_Init2)) ;size +L0311_Init2: + ret + +L0311_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0311_Check: + DW ((L0311_CheckFinished - L0311_Check2)) ;size +L0311_Check2: + call ((.checkFalling-L0311_Check2)+levelCheckRAM) + ret + +.checkFalling + ld a,[timeToChangeLevel] + or a + ret z + + ld a,[exitTileIndex] + cp FIRST_HOLE + ret c + + ld hl,((.fallSound-L0311_Check2)+levelCheckRAM) + call PlaySound + ld a,15 + call Delay + ret + +.fallSound + DB 1,$7e,$80,$f5,$00,$86 + +L0311_CheckFinished: +PRINT "0311 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0311_LoadFinished - L0311_Load2) +PRINT " / " +PRINT (L0311_InitFinished - L0311_Init2) +PRINT " / " +PRINT (L0311_CheckFinished - L0311_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0312.asm b/Source/Levels/L0312.asm new file mode 100644 index 0000000..fb13c58 --- /dev/null +++ b/Source/Levels/L0312.asm @@ -0,0 +1,70 @@ +; L0312.asm sunset bee house +; Generated 08.31.2000 by mlevel +; Modified 08.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +HIVE_INDEX EQU 15 + +STATE_HIVE_DESTROYED EQU 2 + +;--------------------------------------------------------------------- +SECTION "Level0312Section",ROMX +;--------------------------------------------------------------------- + +L0312_Contents:: + DW L0312_Load + DW L0312_Init + DW L0312_Check + DW L0312_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0312_Load: + DW ((L0312_LoadFinished - L0312_Load2)) ;size +L0312_Load2: + call ParseMap + ret + +L0312_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0312_Map: +INCBIN "Data/Levels/L0312_sunsethousedown.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0312_Init: + DW ((L0312_InitFinished - L0312_Init2)) ;size +L0312_Init2: + ret + +L0312_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0312_Check: + DW ((L0312_CheckFinished - L0312_Check2)) ;size +L0312_Check2: + ld c,15 + call GetFirst + or a + ret nz + + ld a,STATE_HIVE_DESTROYED + ldio [mapState],a + ret + +L0312_CheckFinished: +PRINT "0312 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0312_LoadFinished - L0312_Load2) +PRINT " / " +PRINT (L0312_InitFinished - L0312_Init2) +PRINT " / " +PRINT (L0312_CheckFinished - L0312_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0313.asm b/Source/Levels/L0313.asm new file mode 100644 index 0000000..cb9391e --- /dev/null +++ b/Source/Levels/L0313.asm @@ -0,0 +1,239 @@ +; L0313.asm ba ships quarters +; Generated 07.28.2000 by mlevel +; Modified 07.28.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0313Section",ROMX +;--------------------------------------------------------------------- + +L0313_Contents:: + DW L0313_Load + DW L0313_Init + DW L0313_Check + DW L0313_Map + +dialog: +intercom_gtx: + INCBIN "Data/Dialog/Intro/intercom.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0313_Load: + DW ((L0313_LoadFinished - L0313_Load2)) ;size +L0313_Load2: + call ParseMap + ret + +L0313_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0313_Map: +INCBIN "Data/Levels/L0313_intro_ba4.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_LIGHT EQU 00 +LIGHT_INDEX EQU 44 + +STATE_INITIALDRAW EQU 1 +STATE_INIT EQU 2 +STATE_NORMAL EQU 3 + +L0313_Init: + DW ((L0313_InitFinished - L0313_Init2)) ;size +L0313_Init2: + call State0To1 + + ld hl,$0313 + call SetJoinMap + + ld hl,$0313 + call SetRespawnMap + + call SetPressBDialog + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,STATE_INITIALDRAW + ldio [mapState],a + + xor a + ld [musicEnabled],a + + ;ld a,STATE_INITIALDRAW + ;ldio [mapState],a + + ld a,[bgTileMap + LIGHT_INDEX] + ld [levelVars+VAR_LIGHT],a + + ;adjust palette 7 for text box + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette + 58 + xor a + ld [hl+],a + ld a,$02 + ld [hl+],a + ld a,$f0 + ld [hl+],a + ld a,$43 + ld [hl+],a + + ret + +L0313_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0313_Check: + DW ((L0313_CheckFinished - L0313_Check2)) ;size +L0313_Check2: + ldio a,[mapState] + + cp STATE_INITIALDRAW + jr nz,.checkInit + + ld a,STATE_INIT + ldio [mapState],a + ret + +.checkInit + cp STATE_INIT + jr nz,.checkStateNormal + + ;just loaded level + call GfxShowStandardTextBox + ld a,20 + call Delay + + ;adjust palette 7 for text box to black + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette + 58 + xor a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld a,120 + call SetupFadeToGamePalette + ld de,((.afterBAQuartersText-L0313_Check2)+levelCheckRAM) + call SetDialogForward + ld de,((.afterShowAlarmText-L0313_Check2)+levelCheckRAM) + call SetDialogSkip + call WaitFade + call ClearDialog + +.afterBAQuartersText + ld de,((.afterShowAlarmText-L0313_Check2)+levelCheckRAM) + call SetDialogForward + + call SetSpeakerToFirstHero + ld a,BANK(intercom_gtx) + ld c,0 + ld de,intercom_gtx + call ShowDialogAtTop + +.afterShowAlarmText + ld de,0 + call SetDialogSkip + call SetDialogForward + call ClearDialog + + ld a,10 + call Delay + + call ((.alterGamePalette - L0313_Check2) + levelCheckRAM) + ld hl,musicEnabled + res 3,[hl] + ld a,STATE_NORMAL + ldio [mapState],a + + call MakeNonIdle + +.checkStateNormal + ;make the light flash + ld hl,levelVars+VAR_LIGHT + ldio a,[updateTimer] + rrca + rrca + and %11 + push af + add [hl] + ld [bgTileMap+LIGHT_INDEX],a + pop af + cp 3 + jr nz,.afterRedFlash + + ld a,30 + call SetupFadeToBlack + + ld a,[updateTimer] + bit 4,a + jr z,.afterRedFlash + ld hl,((.klaxonSound - L0313_Check2) + levelCheckRAM) + call PlaySound + +.afterRedFlash + ret + +.klaxonSound + DB 4,$00,$f7,$5a,$c0 + +.alterGamePalette + ;alter game palette to halve green and blue + ld a,FADEBANK + ldio [$ff70],a + + ld hl,gamePalette+2 + ld d,64 +.halveGB + ld a,[hl+] + ld c,a + ld a,[hl-] + ld b,a + call GetRedComponent ;highest component so far + ld e,a + call GetGreenComponent + cp e + jr c,.afterGreenHighestCheck + ld e,a +.afterGreenHighestCheck + srl a + srl a + call SetGreenComponent + call GetBlueComponent + cp e + jr c,.afterBlueHighestCheck + ld e,a +.afterBlueHighestCheck + srl a + srl a + call SetBlueComponent + ld a,e + call SetRedComponent + ld a,c + ld [hl+],a + ld a,b + ld [hl+],a + + dec d + jr nz,.halveGB + + ret + +L0313_CheckFinished: +PRINT "0313 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0313_LoadFinished - L0313_Load2) +PRINT " / " +PRINT (L0313_InitFinished - L0313_Init2) +PRINT " / " +PRINT (L0313_CheckFinished - L0313_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0314.asm b/Source/Levels/L0314.asm new file mode 100644 index 0000000..445e6ae --- /dev/null +++ b/Source/Levels/L0314.asm @@ -0,0 +1,560 @@ +; L0314.asm skippy runs for it +; Generated 07.09.2000 by mlevel +; Modified 07.09.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + + +;--------------------------------------------------------------------- +SECTION "Level0314Section",ROMX +;--------------------------------------------------------------------- + +L0314_Contents:: + DW L0314_Load + DW L0314_Init + DW L0314_Check + DW L0314_Map + +dialog: +skippy_woowee_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_woowee.gtx" + +flour_anySign_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_anySign.gtx" + +haiku_theyNever_gtx: + INCBIN "Data/Dialog/IntroHaiku/haiku_theyNever.gtx" + +flour_poorIambic_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_poorIambic.gtx" + +flour_poorQuatrain_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_poorQuatrain.gtx" + +flour_headHome_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_headHome.gtx" + +skippy_notJustYet_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_notJustYet.gtx" + +skippy_smartestThing_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_smartestThing.gtx" + +skippy_loseForSure_gtx: + INCBIN "Data/Dialog/IntroHaiku/skippy_loseForSure.gtx" + +flour_sendBS_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_sendBS.gtx" + +flour_sabotage_gtx: + INCBIN "Data/Dialog/IntroHaiku/flour_sabotage.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +STATE_WAITSKIPPY EQU 0 +STATE_WAITFADE EQU 1 +STATE_CINEMA EQU 2 + +L0314_Load: + DW ((L0314_LoadFinished - L0314_Load2)) ;size +L0314_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ldio a,[mapState] + cp STATE_WAITSKIPPY + jr nz,.doCinema + call ParseMap + ret + +.doCinema + ld a,BANK(intro_cinema_gbm) + ld hl,intro_cinema_gbm + call InitMusic + + ld a,BANK(moon_bg) + ld hl,moon_bg + call LoadCinemaBG + + ld de,((.endCinema - L0314_Load2) + levelCheckRAM) + call SetDialogSkip + ld de,((.skippy1 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,60 + call SetupFadeFromStandard + call WaitFade + + ld a,30 + call Delay + + ld a,16 + call SetupFadeToBlack + call WaitFade + + ld a,BANK(triumphBIG_bg) + ld hl,triumphBIG_bg + call LoadCinemaBG + + ld bc,$140c + ld hl,$1402 + ld de,$0000 + call CinemaBlitRect + ld a,1 + call Delay + + ld a,16 + call SetupFadeFromBlack + call WaitFade + + ld a,30 + call Delay + +.skippy1 + ;----"Woowee that was a close one!"--------------------------- + ld a,16 + call SetupFadeToBlack + call WaitFade + + call ((.loadSkippy - L0314_Load2) + levelCheckRAM) + + ld a,16 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(skippy_woowee_gtx) + ld c,0 + ld de,skippy_woowee_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour1 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,3 + LONGCALLNOARGS AnimateSkippy + +.flour1 + ;----"Any sign of Quatrain and Iambic Pentameter?"------------ + call ClearDialog + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ((.loadFlour - L0314_Load2) + levelCheckRAM) + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(flour_anySign_gtx) + ld c,0 + ld de,flour_anySign_gtx + call ShowDialogAtBottomNoWait + + ld de,((.haiku1 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.haiku1 + call ClearDialog + ;----"They never returned..."--------------------------------- + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ((.loadHaiku - L0314_Load2) + levelCheckRAM) + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(haiku_theyNever_gtx) + ld c,0 + ld de,haiku_theyNever_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour2 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + LONGCALLNOARGS AnimateHaiku + +.flour2 + call ClearDialog + ;----"Oh poor Iambic Pentamter!..."--------------------------- + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ((.loadFlour - L0314_Load2) + levelCheckRAM) + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(flour_poorIambic_gtx) + ld c,0 + ld de,flour_poorIambic_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour3 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,6 + LONGCALLNOARGS AnimateFlour + +.flour3 + ;----"And poor Quatrain!..."---------------------------------- + ld a,BANK(flour_poorQuatrain_gtx) + ld c,0 + ld de,flour_poorQuatrain_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour4 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,6 + LONGCALLNOARGS AnimateFlour + +.flour4 + ;----"Well I guess it's time to head back home."-------------- + ld a,BANK(flour_headHome_gtx) + ld c,0 + ld de,flour_headHome_gtx + call ShowDialogAtBottomNoWait + + ld de,((.skippy2 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.skippy2 + call ClearDialog + ;----"Not just yet! We have to get rid..."------------------- + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ((.loadSkippy - L0314_Load2) + levelCheckRAM) + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(skippy_notJustYet_gtx) + ld c,0 + ld de,skippy_notJustYet_gtx + call ShowDialogAtBottomNoWait + + ld de,((.skippy3 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateSkippy + +.skippy3 + ;----"I reckon it's just about the smartest thing..."--------- + ld a,BANK(skippy_smartestThing_gtx) + ld c,0 + ld de,skippy_smartestThing_gtx + call ShowDialogAtBottomNoWait + + ld de,((.skippy4 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,5 + LONGCALLNOARGS AnimateSkippy + +.skippy4 + ;----""We'll lose for sure..."-------------------------------- + ld a,BANK(skippy_loseForSure_gtx) + ld c,0 + ld de,skippy_loseForSure_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour5 - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,5 + LONGCALLNOARGS AnimateSkippy + +.flour5 + call ClearDialog + ;----"Okay let's send BS!"------------------------------------ + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ((.loadFlour - L0314_Load2) + levelCheckRAM) + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld a,BANK(flour_sendBS_gtx) + ld c,0 + ld de,flour_sendBS_gtx + call ShowDialogAtBottomNoWait + + ld de,((.transitionToMoon - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld d,6 + LONGCALLNOARGS AnimateFlour + +.transitionToMoon + call ClearDialog + ld a,16 + call SetupFadeToBlack + call WaitFade + + ld a,BANK(moon_bg) + ld hl,moon_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromBlack + call WaitFade + + ld de,((.endCinema - L0314_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + +.endCinema + call ClearDialog + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld hl,$0015 + ld a,l + ld [respawnMap],a + ld a,h + ld [respawnMap+1],a + + ld hl,2056 ;bs + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_BS_FLAG + ld [hero0_type],a + + ld hl,CS_CINDEX + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_BA_FLAG + ld [hero1_type],a + + xor a + ld [hero0_health],a + ld [hero1_health],a + + ld hl,$0015 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.loadSkippy + ld a,BANK(skippy_bg) + ld hl,skippy_bg + call LoadCinemaBG + ret + +.loadFlour + ld a,BANK(flour_bg) + ld hl,flour_bg + call LoadCinemaBG + ret + +.loadHaiku + ld a,BANK(haiku_bg) + ld hl,haiku_bg + call LoadCinemaBG + ret + +L0314_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0314_Map: +INCBIN "Data/Levels/L0314_intro_haiku4.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +CROUTONINDEX EQU 21 +SKIPPYINDEX EQU 22 + +L0314_Init: + DW ((L0314_InitFinished - L0314_Init2)) ;size +L0314_Init2: + ld a,2 + ld [canJoinMap],a + + ;ld a,BANK(alarm_gbm) + ;ld hl,alarm_gbm + ;call InitMusic + + ;all friends here + ld bc,((GROUP_MONSTERB<<8) | GROUP_MONSTERA) + ld a,1 + call SetFOF + + ;set everybody to run to the right + ld c,CROUTONINDEX + call GetFirst +.setCroutonLoop + call ((.runRight-L0314_Init2)+levelCheckRAM) + call GetNextObject + or a + jr nz,.setCroutonLoop + + ld c,SKIPPYINDEX + call GetFirst + call ((.runRight-L0314_Init2)+levelCheckRAM) + + ld a,[hero0_index] + or a + jr z,.afterSetHero0 + ld c,a + call GetFirst + call ((.runRight-L0314_Init2)+levelCheckRAM) + +.afterSetHero0 + ld a,[hero1_index] + or a + jr z,.afterSetHero1 + ld c,a + call GetFirst + call ((.runRight-L0314_Init2)+levelCheckRAM) +.afterSetHero1 + + ;everybody's an actor + ld bc,classCroutonDoctor + ld de,classActor + call ChangeClass + + ld bc,classHaikuPlayer + ld de,classActor + call ChangeClass + + ld bc,classMajorSkippy + ld de,classActorSpeed1 + call ChangeClass + + ld hl,((.greenDark-L0314_Init2)+levelCheckRAM) + ld de,gamePalette + call CopyPalette32 + +IF 0 + ld c,9 +.updateLoop + call UpdateObjTimers + ld b,METHOD_CHECK + call IterateAllLists + dec c + jr nz,.updateLoop +ENDC + + ret + +.runRight + call GetCurLocation + call ConvertLocHLToXY + ld h,61 + call ConvertXYToLocHL + call SetActorDestLoc + call GetFacing + and %11111100 + or %00000001 + call SetFacing + ld b,METHOD_DRAW + call CallMethod + ret + +.greenDark +DW $0000, $0882, $1104, $1de7 +DW $0000, $0005, $000f, $1de7 ;red stays +DW $0000, $1400, $1d00, $1de7 +DW $0000, $00a0, $01e0, $1de7 +DW $0000, $1002, $14c4, $1de7 +DW $0000, $00e3, $01e7, $1de7 +DW $0000, $0064, $00e7, $1de7 +DW $0000, $1004, $1cc7, $1de7 + +L0314_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0314_Check: + DW ((L0314_CheckFinished - L0314_Check2)) ;size +L0314_Check2: + ldio a,[mapState] + cp STATE_WAITSKIPPY + jr nz,.checkWaitFade + + ;skippy far enough? + ld c,SKIPPYINDEX + call GetFirst + call GetCurLocation + ld a,h + cp $d2 + ret nz + ld a,l + cp $e9 + ret nz + + ;end level + ld a,48 + call SetupFadeToStandard + ld a,STATE_WAITFADE + ldio [mapState],a + ret + +.checkWaitFade + ld a,[specialFX] + and FX_FADE + ret nz + + ld hl,fadeFinalPalette + ld de,gamePalette + call CopyPalette64 + + ld hl,$0314 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + + ld a,STATE_CINEMA + ldio [mapState],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +L0314_CheckFinished: +PRINT "0314 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0314_LoadFinished - L0314_Load2) +PRINT " / " +PRINT (L0314_InitFinished - L0314_Init2) +PRINT " / " +PRINT (L0314_CheckFinished - L0314_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0315.asm b/Source/Levels/L0315.asm new file mode 100644 index 0000000..2f23de1 --- /dev/null +++ b/Source/Levels/L0315.asm @@ -0,0 +1,59 @@ +; L0315.asm +; Generated 07.30.2000 by mlevel +; Modified 07.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0315Section",ROMX +;--------------------------------------------------------------------- + +L0315_Contents:: + DW L0315_Load + DW L0315_Init + DW L0315_Check + DW L0315_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0315_Load: + DW ((L0315_LoadFinished - L0315_Load2)) ;size +L0315_Load2: + call ParseMap + ret + +L0315_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0315_Map: +INCBIN "Data/Levels/L0315_intro_bs4.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0315_Init: + DW ((L0315_InitFinished - L0315_Init2)) ;size +L0315_Init2: + ret + +L0315_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0315_Check: + DW ((L0315_CheckFinished - L0315_Check2)) ;size +L0315_Check2: + ret + +L0315_CheckFinished: +PRINT "0315 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0315_LoadFinished - L0315_Load2) +PRINT " / " +PRINT (L0315_InitFinished - L0315_Init2) +PRINT " / " +PRINT (L0315_CheckFinished - L0315_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0400.asm b/Source/Levels/L0400.asm new file mode 100644 index 0000000..a1abdf5 --- /dev/null +++ b/Source/Levels/L0400.asm @@ -0,0 +1,65 @@ +; L0400.asm crouton ice post +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0400Section",ROMX +;--------------------------------------------------------------------- + +L0400_Contents:: + DW L0400_Load + DW L0400_Init + DW L0400_Check + DW L0400_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0400_Load: + DW ((L0400_LoadFinished - L0400_Load2)) ;size +L0400_Load2: + call ParseMap + ret + +L0400_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0400_Map: +INCBIN "Data/Levels/L0400_ice_out.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0400_Init: + DW ((L0400_InitFinished - L0400_Init2)) ;size +L0400_Init2: + call UseAlternatePalette + + ld bc,ITEM_CODE0400 + call RemoveClearanceIfTaken + ret + +L0400_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0400_Check: + DW ((L0400_CheckFinished - L0400_Check2)) ;size +L0400_Check2: + ret + +L0400_CheckFinished: +PRINT "0400 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0400_LoadFinished - L0400_Load2) +PRINT " / " +PRINT (L0400_InitFinished - L0400_Init2) +PRINT " / " +PRINT (L0400_CheckFinished - L0400_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0401.asm b/Source/Levels/L0401.asm new file mode 100644 index 0000000..78c9069 --- /dev/null +++ b/Source/Levels/L0401.asm @@ -0,0 +1,136 @@ +; L0401.asm pitch black +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0401Section",ROMX +;--------------------------------------------------------------------- + +L0401_Contents:: + DW L0401_Load + DW L0401_Init + DW L0401_Check + DW L0401_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0401_Load: + DW ((L0401_LoadFinished - L0401_Load2)) ;size +L0401_Load2: + call ParseMap + ret + +L0401_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0401_Map: +INCBIN "Data/Levels/L0401_pitch_black.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0401_Init: + DW ((L0401_InitFinished - L0401_Init2)) ;size +L0401_Init2: + ld hl,((.blackPalette-L0401_Init2)+levelCheckRAM) + ld de,gamePalette + call CopyPalette32 + ld de,fadeFinalPalette + call CopyPalette32 + ld de,fadeCurPalette + call CopyPalette32 + ;call InstallGamePalette + + ld a,ENV_RAIN + call SetEnvEffect + + ret + + +.blackPalette + DW $0000, $2108, $4210, $7fff ;Palette 0 (Grey) + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + DW $0000, $0000, $0000, $0000 + +L0401_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0401_Check: + DW ((L0401_CheckFinished - L0401_Check2)) ;size +L0401_Check2: + ld hl,((.heroToGrey-L0401_Check2)+levelCheckRAM) + xor a + call CheckEachHero + + call ((.lightening-L0401_Check2)+levelCheckRAM) + ret + +.heroToGrey + or a + ret z + + ld c,a + call GetFGAttributes + and %11111000 ;palette to grey + call SetFGAttributes + call GetFirst + ld b,METHOD_DRAW + call CallMethod + ret + +.lightening + ld a,31 + call GetRandomNumMask + cp 31 + jr nz,.playThunderSound + + ld hl,((.lighteningPalette-L0401_Check2)+levelCheckRAM) + ld de,fadeCurPalette + call CopyPalette32 + ld a,7 + call GetRandomNumMask + add 8 + call FadeInit + ret + +.playThunderSound + and 15 + ret nz + + ld hl,((.thunderSound-L0401_Check2)+levelCheckRAM) + call PlaySound + ret + +.thunderSound + DB 4,$00,$f4,$66,$80 + +.lighteningPalette + DW $7fff, $0000, $0000, $0000 ;Palette 0 (Grey) + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + DW $7fff, $0000, $0000, $0000 + +L0401_CheckFinished: +PRINT "0401 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0401_LoadFinished - L0401_Load2) +PRINT " / " +PRINT (L0401_InitFinished - L0401_Init2) +PRINT " / " +PRINT (L0401_CheckFinished - L0401_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0402.asm b/Source/Levels/L0402.asm new file mode 100644 index 0000000..ca90cab --- /dev/null +++ b/Source/Levels/L0402.asm @@ -0,0 +1,59 @@ +; L0402.asm +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0402Section",ROMX +;--------------------------------------------------------------------- + +L0402_Contents:: + DW L0402_Load + DW L0402_Init + DW L0402_Check + DW L0402_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0402_Load: + DW ((L0402_LoadFinished - L0402_Load2)) ;size +L0402_Load2: + call ParseMap + ret + +L0402_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0402_Map: +INCBIN "Data/Levels/L0402_dusk.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0402_Init: + DW ((L0402_InitFinished - L0402_Init2)) ;size +L0402_Init2: + ret + +L0402_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0402_Check: + DW ((L0402_CheckFinished - L0402_Check2)) ;size +L0402_Check2: + ret + +L0402_CheckFinished: +PRINT "0402 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0402_LoadFinished - L0402_Load2) +PRINT " / " +PRINT (L0402_InitFinished - L0402_Init2) +PRINT " / " +PRINT (L0402_CheckFinished - L0402_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0403.asm b/Source/Levels/L0403.asm new file mode 100644 index 0000000..7237bd1 --- /dev/null +++ b/Source/Levels/L0403.asm @@ -0,0 +1,108 @@ +; L0403.asm +; Generated 08.26.2000 by mlevel +; Modified 08.26.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +;--------------------------------------------------------------------- +SECTION "Level0403Section",ROMX +;--------------------------------------------------------------------- + +L0403_Contents:: + DW L0403_Load + DW L0403_Init + DW L0403_Check + DW L0403_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0403_Load: + DW ((L0403_LoadFinished - L0403_Load2)) ;size +L0403_Load2: + call ParseMap + ret + +L0403_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0403_Map: +INCBIN "Data/Levels/L0403_shroom.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0403_Init: + DW ((L0403_InitFinished - L0403_Init2)) ;size +L0403_Init2: + ld bc,ITEM_SPOREMASK + call HasInventoryItem + jr nz,.hasMask + + ld hl,HOffsetOnHBlank + call InstallHBlankHandler +.hasMask + + ;ld a,BANK(shroom_gbm) + ;ld hl,shroom_gbm + ;call InitMusic + ret + +L0403_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0403_Check: + DW ((L0403_CheckFinished - L0403_Check2)) ;size +L0403_Check2: + call ((.updateWave-L0403_Check2)+levelCheckRAM) + ret + +.updateWave + ld bc,ITEM_SPOREMASK + call HasInventoryItem + ret nz + + ;fill the horizontalOffset table with values from the sine table + ld a,TILEINDEXBANK + ldio [$ff70],a + ldio a,[updateTimer] + and 63 + ld e,a + ld d,0 + ld hl,((.sineTable-L0403_Check2)+levelCheckRAM) + add hl,de + ld de,horizontalOffset + ld c,144 +.updateLoop + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.updateLoop + + ld a,[horizontalOffset] + ld [lineZeroHorizontalOffset],a + + ld hl,hblankFlag + set 2,[hl] + + ret + +.sineTable ;sixteen 16-byte sine waves, values between 0 and 24 +REPT 16 + DB 0, 3, 5, 7, 7, 7, 5, 3, 0, 253, 251, 249, 249, 249, 251, 253 +ENDR + +L0403_CheckFinished: +PRINT "0403 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0403_LoadFinished - L0403_Load2) +PRINT " / " +PRINT (L0403_InitFinished - L0403_Init2) +PRINT " / " +PRINT (L0403_CheckFinished - L0403_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0404.asm b/Source/Levels/L0404.asm new file mode 100644 index 0000000..17c04bb --- /dev/null +++ b/Source/Levels/L0404.asm @@ -0,0 +1,189 @@ +; L0404.asm +; Generated 08.26.2000 by mlevel +; Modified 08.26.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0404Section",ROMX +;--------------------------------------------------------------------- + +L0404_Contents:: + DW L0404_Load + DW L0404_Init + DW L0404_Check + DW L0404_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0404_Load: + DW ((L0404_LoadFinished - L0404_Load2)) ;size +L0404_Load2: + call ParseMap + ret + +L0404_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0404_Map: +INCBIN "Data/Levels/L0404_shroom.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +VAR_SLIMETRIGGERED EQU 0 + +L0404_Init: + DW ((L0404_InitFinished - L0404_Init2)) ;size +L0404_Init2: + ld bc,ITEM_SPOREMASK + call HasInventoryItem + jr nz,.hasMask + + ld hl,HOffsetOnHBlank + call InstallHBlankHandler +.hasMask + + ;ld a,BANK(shroom_gbm) + ;ld hl,shroom_gbm + ;call InitMusic + + xor a + ld [levelVars + VAR_SLIMETRIGGERED],a + ret + +L0404_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0404_Check: + DW ((L0404_CheckFinished - L0404_Check2)) ;size +L0404_Check2: + call ((.updateWave-L0404_Check2)+levelCheckRAM) + call ((.checkMossTriggered469-L0404_Check2)+levelCheckRAM) + ret + +.checkMossTriggered469 + ld a,[levelVars + VAR_SLIMETRIGGERED] + or a + ret nz + + ld hl,((.heroInZone469-L0404_Check2)+levelCheckRAM) + ld a,1 + call CheckEachHero + or a + ret z ;hero not in zone 4, 6, or 9 + + ;activate slime in any zone 15 location + ld [levelVars + VAR_SLIMETRIGGERED],a + ld hl,$d000 + ld a,ZONEBANK + ldio [$ff70],a + + ld a,[mapHeight] +.outer push af + push hl + ld a,[mapWidth] + +.inner push af + ld a,[hl+] + and $0f + cp 15 + jr nz,.afterActivate + + dec hl + ld bc,classSlime + call FindClassIndex + ld c,a + call CreateInitAndDrawObject + ld a,ZONEBANK + ldio [$ff70],a + inc hl + +.afterActivate + pop af + dec a + jr nz,.inner + + pop hl + call ConvertLocHLToXY + inc l + call ConvertXYToLocHL + pop af + dec a + jr nz,.outer + + ret + +.heroInZone469 + or a + ret z + + ld c,a + call GetFirst + call GetCurZone + cp 4 + jr z,.true + cp 6 + jr z,.true + cp 9 + jr z,.true + +.false xor a + ret + +.true ld a,1 + ret + +.updateWave + ld bc,ITEM_SPOREMASK + call HasInventoryItem + ret nz + + ;fill the horizontalOffset table with values from the sine table + ld a,TILEINDEXBANK + ldio [$ff70],a + ldio a,[updateTimer] + and 63 + ld e,a + ld d,0 + ld hl,((.sineTable-L0404_Check2)+levelCheckRAM) + add hl,de + ld de,horizontalOffset + ld c,144 +.updateLoop + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.updateLoop + + ld a,[horizontalOffset] + ld [lineZeroHorizontalOffset],a + + ld hl,hblankFlag + set 2,[hl] + + ret + +.sineTable ;eight 32-byte sine waves, values between 0 and 15 +REPT 8 + DB 0, 1, 3, 4, 5, 6, 7, 7, 7, 7, 7, 6, 5, 4, 3, 1 + DB 0,$fe,$fc,$fb,$fa,$f9,$f8,$f8,$f8,$f8,$f8,$f9,$fa,$fb,$fc,$fe +ENDR + + +L0404_CheckFinished: +PRINT "0404 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0404_LoadFinished - L0404_Load2) +PRINT " / " +PRINT (L0404_InitFinished - L0404_Init2) +PRINT " / " +PRINT (L0404_CheckFinished - L0404_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0405.asm b/Source/Levels/L0405.asm new file mode 100644 index 0000000..e6790ce --- /dev/null +++ b/Source/Levels/L0405.asm @@ -0,0 +1,234 @@ +; L0405.asm west gardens +; Generated 10.16.2000 by mlevel +; Modified 10.16.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 40 +LOW_INDEX EQU 46 +HIGH_INDEX EQU 49 + +VAR_WATER EQU 0 +VAR_ALARM EQU 1 + +STATE_NORMAL EQU 1 +STATE_TALKED EQU 2 + +;for L0505 +STATE_AFTERWEDDING EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0405Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0405_ho_gtx: + INCBIN "Data/Dialog/Talk/L0405_ho.gtx" + +L0405_hero_reaction_gtx: + INCBIN "Data/Dialog/Talk/L0405_hero_reaction.gtx" + +L0405_final_word_gtx: + INCBIN "Data/Dialog/Talk/L0405_final_word.gtx" + +L0405_Contents:: + DW L0405_Load + DW L0405_Init + DW L0405_Check + DW L0405_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0405_Load: + DW ((L0405_LoadFinished - L0405_Load2)) ;size +L0405_Load2: + call ParseMap + ret + +L0405_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0405_Map: +INCBIN "Data/Levels/L0405_garden.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0405_Init: + DW ((L0405_InitFinished - L0405_Init2)) ;size +L0405_Init2: + ld a,STATE_NORMAL + ldio [mapState],a + + STDSETUPDIALOG + + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld bc,classPansy + ld de,classActor2 + call ChangeClass + + xor a + ld [levelVars+VAR_ALARM],a + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$55] ;palace + cp STATE_AFTERWEDDING + jr nc,.afterWedding + +.beforeWedding + ld bc,classDandelionGuard + ld de,classTreeTalker + call ChangeClass + + jr .done + +.afterWedding + call ((.openGate-L0405_Init2)+levelCheckRAM) + ld bc,classDandelionGuard + ld de,classActor + call ChangeClass + +.done + ret + +.openGate + ld a,MAPBANK + ldio [$ff70],a + ld hl,$d113 + xor a + ld [hl+],a + ld [hl],a + ld hl,$d133 + ld [hl+],a + ld [hl],a + ret + +L0405_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0405_Check: + DW ((L0405_CheckFinished - L0405_Check2)) ;size +L0405_Check2: + call ((.animateWater-L0405_Check2)+levelCheckRAM) + call ((.checkAlarm-L0405_Check2)+levelCheckRAM) + call ((.checkDialog-L0405_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_TALKED + ret z + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + call MakeIdle + + ld de,((.afterDialog-L0405_Check2)+levelCheckRAM) + call SetDialogSkip + + ;Ho, miscreant! + ld de,L0405_ho_gtx + call ShowDialogNPC + + ;Reaction + ld de,L0405_hero_reaction_gtx + call ShowDialogHero + + ;Final word + ld de,L0405_final_word_gtx + call ShowDialogNPC + +.afterDialog + call ClearDialog + + call MakeNonIdle + ld a,STATE_TALKED + ldio [mapState],a + + ld a,$ff + call DisableDialogBalloons + + xor a + ld [dialogNPC_speakerIndex],a + ret + + +.checkAlarm + ld a,[levelVars+VAR_ALARM] + or a + ret nz + + ;ld a,[guardAlarm] + ;or a + ;jr nz,.soundAlarm + + ;count pansies + ld b,0 + ld c,LOW_INDEX + call GetNumObjects + add b + ld b,a + ld c,LOW_INDEX+1 + call GetNumObjects + add b + ld b,a + ld c,LOW_INDEX+2 + call GetNumObjects + add b + ld b,a + ld c,LOW_INDEX+3 + call GetNumObjects + add b + ld b,a + cp 49 ;all still here? + ret nc + +.soundAlarm + xor a + ld [dialogBalloonClassIndex],a + + ld a,1 + ld [levelVars+VAR_ALARM],a + + ld bc,classActor2 + ld de,classPansy + call ChangeClass + + ld bc,classActor + ld de,classDandelionGuard + call ChangeClass + + ld bc,classTreeTalker + ld de,classDandelionGuard + call ChangeClass + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0405_CheckFinished: +PRINT "0405 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0405_LoadFinished - L0405_Load2) +PRINT " / " +PRINT (L0405_InitFinished - L0405_Init2) +PRINT " / " +PRINT (L0405_CheckFinished - L0405_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0406.asm b/Source/Levels/L0406.asm new file mode 100644 index 0000000..73bbd68 --- /dev/null +++ b/Source/Levels/L0406.asm @@ -0,0 +1,59 @@ +; L0406.asm +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0406Section",ROMX +;--------------------------------------------------------------------- + +L0406_Contents:: + DW L0406_Load + DW L0406_Init + DW L0406_Check + DW L0406_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0406_Load: + DW ((L0406_LoadFinished - L0406_Load2)) ;size +L0406_Load2: + call ParseMap + ret + +L0406_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0406_Map: +INCBIN "Data/Levels/L0406_bios.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0406_Init: + DW ((L0406_InitFinished - L0406_Init2)) ;size +L0406_Init2: + ret + +L0406_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0406_Check: + DW ((L0406_CheckFinished - L0406_Check2)) ;size +L0406_Check2: + ret + +L0406_CheckFinished: +PRINT "0406 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0406_LoadFinished - L0406_Load2) +PRINT " / " +PRINT (L0406_InitFinished - L0406_Init2) +PRINT " / " +PRINT (L0406_CheckFinished - L0406_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0407.asm b/Source/Levels/L0407.asm new file mode 100644 index 0000000..e88119a --- /dev/null +++ b/Source/Levels/L0407.asm @@ -0,0 +1,59 @@ +; L0407.asm +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0407Section",ROMX +;--------------------------------------------------------------------- + +L0407_Contents:: + DW L0407_Load + DW L0407_Init + DW L0407_Check + DW L0407_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0407_Load: + DW ((L0407_LoadFinished - L0407_Load2)) ;size +L0407_Load2: + call ParseMap + ret + +L0407_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0407_Map: +INCBIN "Data/Levels/L0407_bios.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0407_Init: + DW ((L0407_InitFinished - L0407_Init2)) ;size +L0407_Init2: + ret + +L0407_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0407_Check: + DW ((L0407_CheckFinished - L0407_Check2)) ;size +L0407_Check2: + ret + +L0407_CheckFinished: +PRINT "0407 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0407_LoadFinished - L0407_Load2) +PRINT " / " +PRINT (L0407_InitFinished - L0407_Init2) +PRINT " / " +PRINT (L0407_CheckFinished - L0407_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0408.asm b/Source/Levels/L0408.asm new file mode 100644 index 0000000..310b566 --- /dev/null +++ b/Source/Levels/L0408.asm @@ -0,0 +1,61 @@ +; L0408.asm death valley +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0408Section",ROMX +;--------------------------------------------------------------------- + +L0408_Contents:: + DW L0408_Load + DW L0408_Init + DW L0408_Check + DW L0408_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0408_Load: + DW ((L0408_LoadFinished - L0408_Load2)) ;size +L0408_Load2: + call ParseMap + ret + +L0408_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0408_Map: +INCBIN "Data/Levels/L0408_deathvalley.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0408_Init: + DW ((L0408_InitFinished - L0408_Init2)) ;size +L0408_Init2: + ld a,ENV_DIRT + call SetEnvEffect + ret + +L0408_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0408_Check: + DW ((L0408_CheckFinished - L0408_Check2)) ;size +L0408_Check2: + ret + +L0408_CheckFinished: +PRINT "0408 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0408_LoadFinished - L0408_Load2) +PRINT " / " +PRINT (L0408_InitFinished - L0408_Init2) +PRINT " / " +PRINT (L0408_CheckFinished - L0408_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0409.asm b/Source/Levels/L0409.asm new file mode 100644 index 0000000..4cebb15 --- /dev/null +++ b/Source/Levels/L0409.asm @@ -0,0 +1,59 @@ +; L0409.asm +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0409Section",ROMX +;--------------------------------------------------------------------- + +L0409_Contents:: + DW L0409_Load + DW L0409_Init + DW L0409_Check + DW L0409_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0409_Load: + DW ((L0409_LoadFinished - L0409_Load2)) ;size +L0409_Load2: + call ParseMap + ret + +L0409_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0409_Map: +INCBIN "Data/Levels/L0409_desert.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0409_Init: + DW ((L0409_InitFinished - L0409_Init2)) ;size +L0409_Init2: + ret + +L0409_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0409_Check: + DW ((L0409_CheckFinished - L0409_Check2)) ;size +L0409_Check2: + ret + +L0409_CheckFinished: +PRINT "0409 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0409_LoadFinished - L0409_Load2) +PRINT " / " +PRINT (L0409_InitFinished - L0409_Init2) +PRINT " / " +PRINT (L0409_CheckFinished - L0409_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0410.asm b/Source/Levels/L0410.asm new file mode 100644 index 0000000..d39677b --- /dev/null +++ b/Source/Levels/L0410.asm @@ -0,0 +1,100 @@ +; L0410.asm crouton outpost +; Generated 11.07.2000 by mlevel +; Modified 11.07.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +HFENCE_INDEX EQU 72 +VFENCE_INDEX EQU 76 +VAR_HFENCE EQU 0 +VAR_VFENCE EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0410Section",ROMX +;--------------------------------------------------------------------- + +L0410_Contents:: + DW L0410_Load + DW L0410_Init + DW L0410_Check + DW L0410_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0410_Load: + DW ((L0410_LoadFinished - L0410_Load2)) ;size +L0410_Load2: + call ParseMap + ret + +L0410_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0410_Map: +INCBIN "Data/Levels/L0410_outpost.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0410_Init: + DW ((L0410_InitFinished - L0410_Init2)) ;size +L0410_Init2: + ld a,[bgTileMap+HFENCE_INDEX] + ld [levelVars + VAR_HFENCE],a + ld a,[bgTileMap+VFENCE_INDEX] + ld [levelVars + VAR_VFENCE],a + + ld bc,ITEM_CODE0410 + call RemoveClearanceIfTaken + ret + +L0410_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0410_Check: + DW ((L0410_CheckFinished - L0410_Check2)) ;size +L0410_Check2: + call ((.animateFence-L0410_Check2)+levelCheckRAM) + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+HFENCE_INDEX + ld a,[levelVars+VAR_HFENCE] + ld d,a + call ((.animateFourFrames-L0410_Check2)+levelCheckRAM) + ld a,[levelVars+VAR_VFENCE] + ld d,a + jp ((.animateFourFrames-L0410_Check2)+levelCheckRAM) + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + +L0410_CheckFinished: +PRINT "0410 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0410_LoadFinished - L0410_Load2) +PRINT " / " +PRINT (L0410_InitFinished - L0410_Init2) +PRINT " / " +PRINT (L0410_CheckFinished - L0410_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0411.asm b/Source/Levels/L0411.asm new file mode 100644 index 0000000..62fe469 --- /dev/null +++ b/Source/Levels/L0411.asm @@ -0,0 +1,109 @@ +; L0411.asm top of tower +; Generated 10.20.2000 by mlevel +; Modified 10.20.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +FIRST_HOLE EQU 32 + +;--------------------------------------------------------------------- +SECTION "Level0411Section",ROMX +;--------------------------------------------------------------------- + +L0411_Contents:: + DW L0411_Load + DW L0411_Init + DW L0411_Check + DW L0411_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0411_Load: + DW ((L0411_LoadFinished - L0411_Load2)) ;size +L0411_Load2: + call ParseMap + + ;alter yellow palette to purple w/black + ld a,FADEBANK + ld bc,6 + ld de,gamePalette + 5*8 + 2 + ld hl,((.purpleBlackPalette-L0411_Load2)+levelCheckRAM) + call MemCopy + + ret + +.purpleBlackPalette + DW $4008,$5192,$0000 + +L0411_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0411_Map: +INCBIN "Data/Levels/L0411_tower.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0411_Init: + DW ((L0411_InitFinished - L0411_Init2)) ;size +L0411_Init2: + ;already rescued guys? + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$3c] ;rescue from tower cinema state + or a + jr z,.done + + ;rescued already + ld bc,classActor + call DeleteObjectsOfClass + + ;disable up exit + ld de,$4040 + ld hl,mapExitLinks+EXIT_U*2 + ld [hl],e + inc hl + ld [hl],d +.done + ret + +L0411_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0411_Check: + DW ((L0411_CheckFinished - L0411_Check2)) ;size +L0411_Check2: + call ((.checkFalling-L0411_Check2)+levelCheckRAM) + ret + +.checkFalling + ld a,[timeToChangeLevel] + or a + ret z + + ld a,[exitTileIndex] + cp FIRST_HOLE + ret c + + ld hl,((.fallSound-L0411_Check2)+levelCheckRAM) + call PlaySound + ld a,15 + call Delay + ret + +.fallSound + DB 1,$7e,$80,$f5,$00,$86 + +L0411_CheckFinished: +PRINT "0411 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0411_LoadFinished - L0411_Load2) +PRINT " / " +PRINT (L0411_InitFinished - L0411_Init2) +PRINT " / " +PRINT (L0411_CheckFinished - L0411_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0412.asm b/Source/Levels/L0412.asm new file mode 100644 index 0000000..8d6b0a3 --- /dev/null +++ b/Source/Levels/L0412.asm @@ -0,0 +1,198 @@ +; L0412.asm sunset village stonehead house +; Generated 08.31.2000 by mlevel +; Modified 08.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +STATE_TALK_MISSION EQU 1 +STATE_MISSION_TALKED EQU 2 +STATE_TALK_FIXED EQU 3 +STATE_FIXED_TALKED EQU 4 + +STATE_HIVE_DESTROYED EQU 2 ;from 0312 + +;--------------------------------------------------------------------- +SECTION "Level0412Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0006_avacado_gtx: + INCBIN "Data/Dialog/Talk/L0006_avacado.gtx" + +L0006_hero_sayagain_gtx: + INCBIN "Data/Dialog/Talk/L0006_hero_sayagain.gtx" + +L0006_fixbridge_gtx: + INCBIN "Data/Dialog/Talk/L0006_fixbridge.gtx" + +L0006_fixed_gtx: + INCBIN "Data/Dialog/Talk/L0006_fixed.gtx" + +L0412_Contents:: + DW L0412_Load + DW L0412_Init + DW L0412_Check + DW L0412_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0412_Load: + DW ((L0412_LoadFinished - L0412_Load2)) ;size +L0412_Load2: + call ParseMap + ret + +L0412_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0412_Map: +INCBIN "Data/Levels/L0412_sunsethousewest.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0412_Init: + DW ((L0412_InitFinished - L0412_Init2)) ;size +L0412_Init2: + ld a,BANK(dialog) + ld [dialogBank],a + call SetPressBDialog + + ldio a,[mapState] + cp STATE_TALK_FIXED + jr nc,.fixed + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState + $c3] ;hive in house map + cp STATE_HIVE_DESTROYED + jr z,.fixed + + ld a,STATE_TALK_MISSION + ldio [mapState],a + jr .stateSet + +.fixed + ld a,STATE_TALK_FIXED + ldio [mapState],a +.stateSet + ld bc,classWallCreature + ld de,classWallTalker + call ChangeClass + ret + +L0412_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0412_Check: + DW ((L0412_CheckFinished - L0412_Check2)) ;size +L0412_Check2: + call ((.checkDialog-L0412_Check2)+levelCheckRAM) + ret + +.checkDialog + ldio a,[mapState] + cp STATE_MISSION_TALKED + ret z + cp STATE_FIXED_TALKED + ret z + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + ld a,%11 + call DisableDialogBalloons + ld bc,classStunnedWall + call FindClassIndex + or a + jr z,.afterDisableDialogStunned + + ;disable dialog for any stunned walls + ld c,a + call GetFirst + ld a,1 + call SetMisc + call GetNextObject + or a + jr z,.afterDisableDialogStunned + ld a,1 + call SetMisc + +.afterDisableDialogStunned + call MakeIdle + + ld a,[dialogNPC_heroIndex] + ld c,a + call SetSpeakerFromHeroIndex + + ldio a,[mapState] + cp STATE_TALK_FIXED + jr z,.fixed + + ld de,((.afterFixDialog-L0412_Check2)+levelCheckRAM) + call SetDialogSkip + + ;Crush you like avacado + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0006_avacado_gtx + call ShowDialogAtTop + call ClearDialog + + ;say again? + ld a,[dialogNPC_heroIndex] + ld c,a + ld de,L0006_hero_sayagain_gtx + call ShowDialogAtBottom + call ClearDialog + + ;Fix bridge + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0006_fixbridge_gtx + call ShowDialogAtTop + +.afterFixDialog + call ClearDialog + ld a,STATE_MISSION_TALKED + ldio [mapState],a + jr .afterDialog + +.fixed + ld de,((.afterFixedDialog-L0412_Check2)+levelCheckRAM) + call SetDialogSkip + + ;bridge fixed + ld a,[dialogNPC_speakerIndex] + ld c,a + ld de,L0006_fixed_gtx + call ShowDialogAtTop +.afterFixedDialog + call ClearDialog + ld a,STATE_FIXED_TALKED + ldio [mapState],a + +.afterDialog + call MakeNonIdle + + xor a + ld [dialogNPC_speakerIndex],a + + ret + +L0412_CheckFinished: +PRINT "0412 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0412_LoadFinished - L0412_Load2) +PRINT " / " +PRINT (L0412_InitFinished - L0412_Init2) +PRINT " / " +PRINT (L0412_CheckFinished - L0412_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0413.asm b/Source/Levels/L0413.asm new file mode 100644 index 0000000..0b0a690 --- /dev/null +++ b/Source/Levels/L0413.asm @@ -0,0 +1,57 @@ +; L0413.asm +; Generated 04.22.2001 by mlevel +; Modified 04.22.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0413Section",ROMX +;--------------------------------------------------------------------- + +L0413_Contents:: + DW L0413_Load + DW L0413_Init + DW L0413_Check + DW L0413_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0413_Load: + DW ((L0413_LoadFinished - L0413_Load2)) ;size +L0413_Load2: + ret + +L0413_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0413_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0413_Init: + DW ((L0413_InitFinished - L0413_Init2)) ;size +L0413_Init2: + ret + +L0413_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0413_Check: + DW ((L0413_CheckFinished - L0413_Check2)) ;size +L0413_Check2: + ret + +L0413_CheckFinished: +PRINT "0413 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0413_LoadFinished - L0413_Load2) +PRINT " / " +PRINT (L0413_InitFinished - L0413_Init2) +PRINT " / " +PRINT (L0413_CheckFinished - L0413_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0500.asm b/Source/Levels/L0500.asm new file mode 100644 index 0000000..d36f7e3 --- /dev/null +++ b/Source/Levels/L0500.asm @@ -0,0 +1,63 @@ +; L0500.asm +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0500Section",ROMX +;--------------------------------------------------------------------- + +L0500_Contents:: + DW L0500_Load + DW L0500_Init + DW L0500_Check + DW L0500_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0500_Load: + DW ((L0500_LoadFinished - L0500_Load2)) ;size +L0500_Load2: + call ParseMap + ret + +L0500_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0500_Map: +INCBIN "Data/Levels/L0500_ice.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0500_Init: + DW ((L0500_InitFinished - L0500_Init2)) ;size +L0500_Init2: + call UseAlternatePalette + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0500_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0500_Check: + DW ((L0500_CheckFinished - L0500_Check2)) ;size +L0500_Check2: + ret + +L0500_CheckFinished: +PRINT "0500 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0500_LoadFinished - L0500_Load2) +PRINT " / " +PRINT (L0500_InitFinished - L0500_Init2) +PRINT " / " +PRINT (L0500_CheckFinished - L0500_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0501.asm b/Source/Levels/L0501.asm new file mode 100644 index 0000000..d67844c --- /dev/null +++ b/Source/Levels/L0501.asm @@ -0,0 +1,66 @@ +; L0501.asm +; Generated 09.05.2000 by mlevel +; Modified 09.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0501Section",ROMX +;--------------------------------------------------------------------- + +L0501_Contents:: + DW L0501_Load + DW L0501_Init + DW L0501_Check + DW L0501_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0501_Load: + DW ((L0501_LoadFinished - L0501_Load2)) ;size +L0501_Load2: + call ParseMap + ret + +L0501_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0501_Map: +INCBIN "Data/Levels/L0501_winter.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0501_Init: + DW ((L0501_InitFinished - L0501_Init2)) ;size +L0501_Init2: + call UseAlternatePalette + ld a,ENV_SNOW + call SetEnvEffect + + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + ret + +L0501_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0501_Check: + DW ((L0501_CheckFinished - L0501_Check2)) ;size +L0501_Check2: + ret + +L0501_CheckFinished: +PRINT "0501 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0501_LoadFinished - L0501_Load2) +PRINT " / " +PRINT (L0501_InitFinished - L0501_Init2) +PRINT " / " +PRINT (L0501_CheckFinished - L0501_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0502.asm b/Source/Levels/L0502.asm new file mode 100644 index 0000000..4532efb --- /dev/null +++ b/Source/Levels/L0502.asm @@ -0,0 +1,62 @@ +; L0502.asm +; Generated 09.05.2000 by mlevel +; Modified 09.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0502Section",ROMX +;--------------------------------------------------------------------- + +L0502_Contents:: + DW L0502_Load + DW L0502_Init + DW L0502_Check + DW L0502_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0502_Load: + DW ((L0502_LoadFinished - L0502_Load2)) ;size +L0502_Load2: + call ParseMap + ret + +L0502_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0502_Map: +INCBIN "Data/Levels/L0502_chill.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0502_Init: + DW ((L0502_InitFinished - L0502_Init2)) ;size +L0502_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0502_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0502_Check: + DW ((L0502_CheckFinished - L0502_Check2)) ;size +L0502_Check2: + ret + +L0502_CheckFinished: +PRINT "0502 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0502_LoadFinished - L0502_Load2) +PRINT " / " +PRINT (L0502_InitFinished - L0502_Init2) +PRINT " / " +PRINT (L0502_CheckFinished - L0502_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0503.asm b/Source/Levels/L0503.asm new file mode 100644 index 0000000..2872032 --- /dev/null +++ b/Source/Levels/L0503.asm @@ -0,0 +1,59 @@ +; L0503.asm +; Generated 09.05.2000 by mlevel +; Modified 09.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0503Section",ROMX +;--------------------------------------------------------------------- + +L0503_Contents:: + DW L0503_Load + DW L0503_Init + DW L0503_Check + DW L0503_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0503_Load: + DW ((L0503_LoadFinished - L0503_Load2)) ;size +L0503_Load2: + call ParseMap + ret + +L0503_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0503_Map: +INCBIN "Data/Levels/L0503_hermit.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0503_Init: + DW ((L0503_InitFinished - L0503_Init2)) ;size +L0503_Init2: + ret + +L0503_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0503_Check: + DW ((L0503_CheckFinished - L0503_Check2)) ;size +L0503_Check2: + ret + +L0503_CheckFinished: +PRINT "0503 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0503_LoadFinished - L0503_Load2) +PRINT " / " +PRINT (L0503_InitFinished - L0503_Init2) +PRINT " / " +PRINT (L0503_CheckFinished - L0503_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0504.asm b/Source/Levels/L0504.asm new file mode 100644 index 0000000..a1417b1 --- /dev/null +++ b/Source/Levels/L0504.asm @@ -0,0 +1,59 @@ +; L0504.asm north gardens +; Generated 10.16.2000 by mlevel +; Modified 10.16.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0504Section",ROMX +;--------------------------------------------------------------------- + +L0504_Contents:: + DW L0504_Load + DW L0504_Init + DW L0504_Check + DW L0504_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0504_Load: + DW ((L0504_LoadFinished - L0504_Load2)) ;size +L0504_Load2: + call ParseMap + ret + +L0504_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0504_Map: +INCBIN "Data/Levels/L0504_garden.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0504_Init: + DW ((L0504_InitFinished - L0504_Init2)) ;size +L0504_Init2: + ret + +L0504_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0504_Check: + DW ((L0504_CheckFinished - L0504_Check2)) ;size +L0504_Check2: + ret + +L0504_CheckFinished: +PRINT "0504 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0504_LoadFinished - L0504_Load2) +PRINT " / " +PRINT (L0504_InitFinished - L0504_Init2) +PRINT " / " +PRINT (L0504_CheckFinished - L0504_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0505.asm b/Source/Levels/L0505.asm new file mode 100644 index 0000000..fb0dc92 --- /dev/null +++ b/Source/Levels/L0505.asm @@ -0,0 +1,187 @@ +; L0505.asm palace / wedding +; Generated 10.19.2000 by mlevel +; Modified 10.19.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 71 + +VAR_LIGHT EQU 0 +VAR_WEDDINGSTAGE EQU 10 +VAR_HERO EQU 11 + +STATE_INIT EQU 0 +STATE_WEDDING EQU 1 +;STATE_AFTERWEDDING referenced in L0405 and L0505 +STATE_AFTERWEDDING EQU 2 + + + +;--------------------------------------------------------------------- +SECTION "Level0505Section",ROMX +;--------------------------------------------------------------------- + +L0505_Contents:: + DW L0505_Load + DW L0505_Init + DW L0505_Check + DW L0505_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0505_Load: + DW ((L0505_LoadFinished - L0505_Load2)) ;size +L0505_Load2: + call ParseMap + ret + +L0505_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0505_Map: +INCBIN "Data/Levels/L0505_palace.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0505_Init: + DW ((L0505_InitFinished - L0505_Init2)) ;size +L0505_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + ldio a,[mapState] + cp STATE_AFTERWEDDING + jr nc,.afterWedding + + xor a + ld [levelVars+VAR_WEDDINGSTAGE],a + ld bc,classPansy + ld de,classActor + call ChangeClass + + ld bc,classDandelionGuard + call ChangeClass + + ld a,BANK(wedding_gbm) + ld hl,wedding_gbm + call InitMusic + jr .done + +.afterWedding + ld bc,classPansy + call DeleteObjectsOfClass + ld bc,classCaptainFlour + call DeleteObjectsOfClass + ld bc,classLadyFlower + call DeleteObjectsOfClass + ld bc,classDandelionGuard + call DeleteObjectsOfClass + +.done + ret + +L0505_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0505_Check: + DW ((L0505_CheckFinished - L0505_Check2)) ;size +L0505_Check2: + ldio a,[mapState] + cp STATE_AFTERWEDDING + jr z,.afterWedding + + cp STATE_INIT + jr nz,.wedding + + ;initial draw + ld a,STATE_WEDDING + ldio [mapState],a + + ld a,1 + ld [heroesIdle],a + ;call MakeIdle + ret + +.wedding + ld a,$11 + ldio [scrollSpeed],a + xor a + ld [camera_i],a + ld [camera_j],a + + ld de,((.endPan-L0505_Check2)+levelCheckRAM) + call SetDialogForward + call SetDialogSkip + + ld a,220 + call Delay + +.endPan + call SetSpeakerToFirstHero + ld a,[dialogSpeakerIndex] + ld [levelVars+VAR_HERO],a + + ld hl,levelVars+VAR_HERO + xor a + call LinkTransmitMemoryLocation + + ld hl,$1103 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + call MakeNonIdle + ld a,STATE_AFTERWEDDING + ldio [mapState],a + ret + +.afterWedding + call ((.animateLandingLights-L0505_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0505_Check2)+levelCheckRAM) + call ((.animateLight-L0505_Check2)+levelCheckRAM) + call ((.animateLight-L0505_Check2)+levelCheckRAM) + call ((.animateLight-L0505_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + + +L0505_CheckFinished: +PRINT "0505 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0505_LoadFinished - L0505_Load2) +PRINT " / " +PRINT (L0505_InitFinished - L0505_Init2) +PRINT " / " +PRINT (L0505_CheckFinished - L0505_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0506.asm b/Source/Levels/L0506.asm new file mode 100644 index 0000000..4636c3b --- /dev/null +++ b/Source/Levels/L0506.asm @@ -0,0 +1,78 @@ +; L0506.asm +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0506Section",ROMX +;--------------------------------------------------------------------- + +L0506_Contents:: + DW L0506_Load + DW L0506_Init + DW L0506_Check + DW L0506_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0506_Load: + DW ((L0506_LoadFinished - L0506_Load2)) ;size +L0506_Load2: + call ParseMap + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$3c] ;rescue from tower + or a + jr z,.notRescued + + ;rescued, open gates + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d04f + ld [hl+],a + ld [hl],a + ld hl,$d06f + ld [hl+],a + ld [hl],a + +.notRescued + ret + +L0506_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0506_Map: +INCBIN "Data/Levels/L0506_garden.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0506_Init: + DW ((L0506_InitFinished - L0506_Init2)) ;size +L0506_Init2: + ret + +L0506_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0506_Check: + DW ((L0506_CheckFinished - L0506_Check2)) ;size +L0506_Check2: + ret + +L0506_CheckFinished: +PRINT "0506 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0506_LoadFinished - L0506_Load2) +PRINT " / " +PRINT (L0506_InitFinished - L0506_Init2) +PRINT " / " +PRINT (L0506_CheckFinished - L0506_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0507.asm b/Source/Levels/L0507.asm new file mode 100644 index 0000000..5557844 --- /dev/null +++ b/Source/Levels/L0507.asm @@ -0,0 +1,74 @@ +; L0507.asm swamp +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0507Section",ROMX +;--------------------------------------------------------------------- + +L0507_Contents:: + DW L0507_Load + DW L0507_Init + DW L0507_Check + DW L0507_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0507_Load: + DW ((L0507_LoadFinished - L0507_Load2)) ;size +L0507_Load2: + call ParseMap + ret + +L0507_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0507_Map: +INCBIN "Data/Levels/L0507_swamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0507_Init: + DW ((L0507_InitFinished - L0507_Init2)) ;size +L0507_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0507_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0507_Check: + DW ((L0507_CheckFinished - L0507_Check2)) ;size +L0507_Check2: + call ((.animateWater-L0507_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0507_CheckFinished: +PRINT "0507 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0507_LoadFinished - L0507_Load2) +PRINT " / " +PRINT (L0507_InitFinished - L0507_Init2) +PRINT " / " +PRINT (L0507_CheckFinished - L0507_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0508.asm b/Source/Levels/L0508.asm new file mode 100644 index 0000000..019366c --- /dev/null +++ b/Source/Levels/L0508.asm @@ -0,0 +1,59 @@ +; L0508.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0508Section",ROMX +;--------------------------------------------------------------------- + +L0508_Contents:: + DW L0508_Load + DW L0508_Init + DW L0508_Check + DW L0508_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0508_Load: + DW ((L0508_LoadFinished - L0508_Load2)) ;size +L0508_Load2: + call ParseMap + ret + +L0508_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0508_Map: +INCBIN "Data/Levels/L0508_witch.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0508_Init: + DW ((L0508_InitFinished - L0508_Init2)) ;size +L0508_Init2: + ret + +L0508_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0508_Check: + DW ((L0508_CheckFinished - L0508_Check2)) ;size +L0508_Check2: + ret + +L0508_CheckFinished: +PRINT "0508 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0508_LoadFinished - L0508_Load2) +PRINT " / " +PRINT (L0508_InitFinished - L0508_Init2) +PRINT " / " +PRINT (L0508_CheckFinished - L0508_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0509.asm b/Source/Levels/L0509.asm new file mode 100644 index 0000000..fca4c33 --- /dev/null +++ b/Source/Levels/L0509.asm @@ -0,0 +1,77 @@ +; L0509.asm big desert +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0509Section",ROMX +;--------------------------------------------------------------------- + +L0509_Contents:: + DW L0509_Load + DW L0509_Init + DW L0509_Check + DW L0509_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0509_Load: + DW ((L0509_LoadFinished - L0509_Load2)) ;size +L0509_Load2: + call ParseMap + ret + +L0509_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0509_Map: +INCBIN "Data/Levels/L0509_bigdesert.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +WATERINDEX EQU 22 + +VAR_WATER EQU 0 + +L0509_Init: + DW ((L0509_InitFinished - L0509_Init2)) ;size +L0509_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ld a,ENV_DIRT + call SetEnvEffect + ret + +L0509_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0509_Check: + DW ((L0509_CheckFinished - L0509_Check2)) ;size +L0509_Check2: + call ((.animateWater-L0509_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0509_CheckFinished: +PRINT "0509 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0509_LoadFinished - L0509_Load2) +PRINT " / " +PRINT (L0509_InitFinished - L0509_Init2) +PRINT " / " +PRINT (L0509_CheckFinished - L0509_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0510.asm b/Source/Levels/L0510.asm new file mode 100644 index 0000000..1b5dd93 --- /dev/null +++ b/Source/Levels/L0510.asm @@ -0,0 +1,59 @@ +; L0510.asm +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0510Section",ROMX +;--------------------------------------------------------------------- + +L0510_Contents:: + DW L0510_Load + DW L0510_Init + DW L0510_Check + DW L0510_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0510_Load: + DW ((L0510_LoadFinished - L0510_Load2)) ;size +L0510_Load2: + call ParseMap + ret + +L0510_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0510_Map: +INCBIN "Data/Levels/L0510_summer.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0510_Init: + DW ((L0510_InitFinished - L0510_Init2)) ;size +L0510_Init2: + ret + +L0510_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0510_Check: + DW ((L0510_CheckFinished - L0510_Check2)) ;size +L0510_Check2: + ret + +L0510_CheckFinished: +PRINT "0510 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0510_LoadFinished - L0510_Load2) +PRINT " / " +PRINT (L0510_InitFinished - L0510_Init2) +PRINT " / " +PRINT (L0510_CheckFinished - L0510_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0512.asm b/Source/Levels/L0512.asm new file mode 100644 index 0000000..2791180 --- /dev/null +++ b/Source/Levels/L0512.asm @@ -0,0 +1,59 @@ +; L0512.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0512Section",ROMX +;--------------------------------------------------------------------- + +L0512_Contents:: + DW L0512_Load + DW L0512_Init + DW L0512_Check + DW L0512_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0512_Load: + DW ((L0512_LoadFinished - L0512_Load2)) ;size +L0512_Load2: + call ParseMap + ret + +L0512_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0512_Map: +INCBIN "Data/Levels/L0512_witch_house.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0512_Init: + DW ((L0512_InitFinished - L0512_Init2)) ;size +L0512_Init2: + ret + +L0512_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0512_Check: + DW ((L0512_CheckFinished - L0512_Check2)) ;size +L0512_Check2: + ret + +L0512_CheckFinished: +PRINT "0512 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0512_LoadFinished - L0512_Load2) +PRINT " / " +PRINT (L0512_InitFinished - L0512_Init2) +PRINT " / " +PRINT (L0512_CheckFinished - L0512_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0600.asm b/Source/Levels/L0600.asm new file mode 100644 index 0000000..494020d --- /dev/null +++ b/Source/Levels/L0600.asm @@ -0,0 +1,103 @@ +; L0600.asm +; Generated 08.24.2000 by mlevel +; Modified 08.24.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 57 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0600Section",ROMX +;--------------------------------------------------------------------- + +L0600_Contents:: + DW L0600_Load + DW L0600_Init + DW L0600_Check + DW L0600_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0600_Load: + DW ((L0600_LoadFinished - L0600_Load2)) ;size +L0600_Load2: + call ParseMap + ret + +L0600_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0600_Map: +INCBIN "Data/Levels/L0600_ice.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0600_Init: + DW ((L0600_InitFinished - L0600_Init2)) ;size +L0600_Init2: + call UseAlternatePalette + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + + LONGCALLNOARGS AddAppomattoxIfPresent + + ld a,ENV_SNOW + call SetEnvEffect + + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + + ret + +L0600_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0600_Check: + DW ((L0600_CheckFinished - L0600_Check2)) ;size +L0600_Check2: + call ((.animateLandingLights-L0600_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0600_Check2)+levelCheckRAM) + call ((.animateLight-L0600_Check2)+levelCheckRAM) + call ((.animateLight-L0600_Check2)+levelCheckRAM) + call ((.animateLight-L0600_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0600_CheckFinished: +PRINT "0600 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0600_LoadFinished - L0600_Load2) +PRINT " / " +PRINT (L0600_InitFinished - L0600_Init2) +PRINT " / " +PRINT (L0600_CheckFinished - L0600_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0601.asm b/Source/Levels/L0601.asm new file mode 100644 index 0000000..9995585 --- /dev/null +++ b/Source/Levels/L0601.asm @@ -0,0 +1,60 @@ +; L0601.asm +; Generated 09.05.2000 by mlevel +; Modified 09.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0601Section",ROMX +;--------------------------------------------------------------------- + +L0601_Contents:: + DW L0601_Load + DW L0601_Init + DW L0601_Check + DW L0601_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0601_Load: + DW ((L0601_LoadFinished - L0601_Load2)) ;size +L0601_Load2: + call ParseMap + ret + +L0601_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0601_Map: +INCBIN "Data/Levels/L0601_wolf.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0601_Init: + DW ((L0601_InitFinished - L0601_Init2)) ;size +L0601_Init2: + call UseAlternatePalette + ret + +L0601_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0601_Check: + DW ((L0601_CheckFinished - L0601_Check2)) ;size +L0601_Check2: + ret + +L0601_CheckFinished: +PRINT "0601 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0601_LoadFinished - L0601_Load2) +PRINT " / " +PRINT (L0601_InitFinished - L0601_Init2) +PRINT " / " +PRINT (L0601_CheckFinished - L0601_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0602.asm b/Source/Levels/L0602.asm new file mode 100644 index 0000000..1bc9a33 --- /dev/null +++ b/Source/Levels/L0602.asm @@ -0,0 +1,76 @@ +; L0602.asm +; Generated 10.25.2000 by mlevel +; Modified 10.25.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_FIRE EQU 0 +FIRE_INDEX EQU 24 + +;--------------------------------------------------------------------- +SECTION "Level0602Section",ROMX +;--------------------------------------------------------------------- + +L0602_Contents:: + DW L0602_Load + DW L0602_Init + DW L0602_Check + DW L0602_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0602_Load: + DW ((L0602_LoadFinished - L0602_Load2)) ;size +L0602_Load2: + call ParseMap + ret + +L0602_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0602_Map: +INCBIN "Data/Levels/L0602_hillpeople.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0602_Init: + DW ((L0602_InitFinished - L0602_Init2)) ;size +L0602_Init2: + ;store index of first (of 4) fire frames + ld a,[bgTileMap + FIRE_INDEX] + ld [levelVars + VAR_FIRE],a + ret + +L0602_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0602_Check: + DW ((L0602_CheckFinished - L0602_Check2)) ;size +L0602_Check2: + call ((.animateFire-L0602_Check2)+levelCheckRAM) + ret + +.animateFire + ldio a,[updateTimer] + rrca + rrca + and %11 + ld hl,levelVars + VAR_FIRE + add [hl] + ld [bgTileMap + FIRE_INDEX],a + ret + +L0602_CheckFinished: +PRINT "0602 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0602_LoadFinished - L0602_Load2) +PRINT " / " +PRINT (L0602_InitFinished - L0602_Init2) +PRINT " / " +PRINT (L0602_CheckFinished - L0602_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0603.asm b/Source/Levels/L0603.asm new file mode 100644 index 0000000..733bf0f --- /dev/null +++ b/Source/Levels/L0603.asm @@ -0,0 +1,76 @@ +; L0603.asm +; Generated 10.23.2000 by mlevel +; Modified 10.23.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_FIRE EQU 0 +FIRE_INDEX EQU 19 + +;--------------------------------------------------------------------- +SECTION "Level0603Section",ROMX +;--------------------------------------------------------------------- + +L0603_Contents:: + DW L0603_Load + DW L0603_Init + DW L0603_Check + DW L0603_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0603_Load: + DW ((L0603_LoadFinished - L0603_Load2)) ;size +L0603_Load2: + call ParseMap + ret + +L0603_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0603_Map: +INCBIN "Data/Levels/L0603_hillpeople.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0603_Init: + DW ((L0603_InitFinished - L0603_Init2)) ;size +L0603_Init2: + ;store index of first (of 4) fire frames + ld a,[bgTileMap + FIRE_INDEX] + ld [levelVars + VAR_FIRE],a + ret + +L0603_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0603_Check: + DW ((L0603_CheckFinished - L0603_Check2)) ;size +L0603_Check2: + call ((.animateFire-L0603_Check2)+levelCheckRAM) + ret + +.animateFire + ldio a,[updateTimer] + rrca + rrca + and %11 + ld hl,levelVars + VAR_FIRE + add [hl] + ld [bgTileMap + FIRE_INDEX],a + ret + +L0603_CheckFinished: +PRINT "0603 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0603_LoadFinished - L0603_Load2) +PRINT " / " +PRINT (L0603_InitFinished - L0603_Init2) +PRINT " / " +PRINT (L0603_CheckFinished - L0603_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0604.asm b/Source/Levels/L0604.asm new file mode 100644 index 0000000..9331cd8 --- /dev/null +++ b/Source/Levels/L0604.asm @@ -0,0 +1,82 @@ +; L0604.asm outside of tower +; Generated 10.20.2000 by mlevel +; Modified 10.20.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0604Section",ROMX +;--------------------------------------------------------------------- + +L0604_Contents:: + DW L0604_Load + DW L0604_Init + DW L0604_Check + DW L0604_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0604_Load: + DW ((L0604_LoadFinished - L0604_Load2)) ;size +L0604_Load2: + call ParseMap + ret + +L0604_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0604_Map: +INCBIN "Data/Levels/L0604_tower.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0604_Init: + DW ((L0604_InitFinished - L0604_Init2)) ;size +L0604_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$3c] ;rescue from tower + or a + jr nz,.afterRescue + + ;not rescued yet + ld hl,$0604 + call SetJoinMap + call SetRespawnMap + + ;disable south exit + ld de,$4040 + ld hl,mapExitLinks+EXIT_S*2 + ld [hl],e + inc hl + ld [hl],d + +.afterRescue + ret + +L0604_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0604_Check: + DW ((L0604_CheckFinished - L0604_Check2)) ;size +L0604_Check2: + ret + +L0604_CheckFinished: +PRINT "0604 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0604_LoadFinished - L0604_Load2) +PRINT " / " +PRINT (L0604_InitFinished - L0604_Init2) +PRINT " / " +PRINT (L0604_CheckFinished - L0604_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0605.asm b/Source/Levels/L0605.asm new file mode 100644 index 0000000..0088a0d --- /dev/null +++ b/Source/Levels/L0605.asm @@ -0,0 +1,84 @@ +; L0605.asm +; Generated 09.14.2000 by mlevel +; Modified 09.14.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0605Section",ROMX +;--------------------------------------------------------------------- + +L0605_Contents:: + DW L0605_Load + DW L0605_Init + DW L0605_Check + DW L0605_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0605_Load: + DW ((L0605_LoadFinished - L0605_Load2)) ;size +L0605_Load2: + call ParseMap + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$3c] ;rescue from tower + or a + jr z,.notRescued + + ;rescued, open gates + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d057 + ld [hl+],a + ld [hl],a + ld hl,$d097 + ld [hl+],a + ld [hl],a + ld hl,$d3c1 + ld [hl+],a + ld [hl],a + ld hl,$d401 + ld [hl+],a + ld [hl],a + +.notRescued + ret + +L0605_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0605_Map: +INCBIN "Data/Levels/L0605_garden.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0605_Init: + DW ((L0605_InitFinished - L0605_Init2)) ;size +L0605_Init2: + ret + +L0605_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0605_Check: + DW ((L0605_CheckFinished - L0605_Check2)) ;size +L0605_Check2: + ret + +L0605_CheckFinished: +PRINT "0605 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0605_LoadFinished - L0605_Load2) +PRINT " / " +PRINT (L0605_InitFinished - L0605_Init2) +PRINT " / " +PRINT (L0605_CheckFinished - L0605_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0606.asm b/Source/Levels/L0606.asm new file mode 100644 index 0000000..ba7ba84 --- /dev/null +++ b/Source/Levels/L0606.asm @@ -0,0 +1,93 @@ +; L0606.asm moores landing +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 57 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0606Section",ROMX +;--------------------------------------------------------------------- + +L0606_Contents:: + DW L0606_Load + DW L0606_Init + DW L0606_Check + DW L0606_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0606_Load: + DW ((L0606_LoadFinished - L0606_Load2)) ;size +L0606_Load2: + call ParseMap + ret + +L0606_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0606_Map: +INCBIN "Data/Levels/L0606_mooreslanding.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0606_Init: + DW ((L0606_InitFinished - L0606_Init2)) ;size +L0606_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + ret + +L0606_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0606_Check: + DW ((L0606_CheckFinished - L0606_Check2)) ;size +L0606_Check2: + call ((.animateLandingLights-L0606_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0606_Check2)+levelCheckRAM) + call ((.animateLight-L0606_Check2)+levelCheckRAM) + call ((.animateLight-L0606_Check2)+levelCheckRAM) + call ((.animateLight-L0606_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0606_CheckFinished: +PRINT "0606 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0606_LoadFinished - L0606_Load2) +PRINT " / " +PRINT (L0606_InitFinished - L0606_Init2) +PRINT " / " +PRINT (L0606_CheckFinished - L0606_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0607.asm b/Source/Levels/L0607.asm new file mode 100644 index 0000000..2310237 --- /dev/null +++ b/Source/Levels/L0607.asm @@ -0,0 +1,61 @@ +; L0607.asm swampy +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0607Section",ROMX +;--------------------------------------------------------------------- + +L0607_Contents:: + DW L0607_Load + DW L0607_Init + DW L0607_Check + DW L0607_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0607_Load: + DW ((L0607_LoadFinished - L0607_Load2)) ;size +L0607_Load2: + call ParseMap + ret + +L0607_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0607_Map: +INCBIN "Data/Levels/L0607_swampthang.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0607_Init: + DW ((L0607_InitFinished - L0607_Init2)) ;size +L0607_Init2: + ld a,ENV_RAIN + call SetEnvEffect + ret + +L0607_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0607_Check: + DW ((L0607_CheckFinished - L0607_Check2)) ;size +L0607_Check2: + ret + +L0607_CheckFinished: +PRINT "0607 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0607_LoadFinished - L0607_Load2) +PRINT " / " +PRINT (L0607_InitFinished - L0607_Init2) +PRINT " / " +PRINT (L0607_CheckFinished - L0607_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0608.asm b/Source/Levels/L0608.asm new file mode 100644 index 0000000..57945ca --- /dev/null +++ b/Source/Levels/L0608.asm @@ -0,0 +1,59 @@ +; L0608.asm +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0608Section",ROMX +;--------------------------------------------------------------------- + +L0608_Contents:: + DW L0608_Load + DW L0608_Init + DW L0608_Check + DW L0608_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0608_Load: + DW ((L0608_LoadFinished - L0608_Load2)) ;size +L0608_Load2: + call ParseMap + ret + +L0608_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0608_Map: +INCBIN "Data/Levels/L0608_moores.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0608_Init: + DW ((L0608_InitFinished - L0608_Init2)) ;size +L0608_Init2: + ret + +L0608_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0608_Check: + DW ((L0608_CheckFinished - L0608_Check2)) ;size +L0608_Check2: + ret + +L0608_CheckFinished: +PRINT "0608 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0608_LoadFinished - L0608_Load2) +PRINT " / " +PRINT (L0608_InitFinished - L0608_Init2) +PRINT " / " +PRINT (L0608_CheckFinished - L0608_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0609.asm b/Source/Levels/L0609.asm new file mode 100644 index 0000000..3425763 --- /dev/null +++ b/Source/Levels/L0609.asm @@ -0,0 +1,74 @@ +; L0609.asm outback farm +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 4 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0609Section",ROMX +;--------------------------------------------------------------------- + +L0609_Contents:: + DW L0609_Load + DW L0609_Init + DW L0609_Check + DW L0609_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0609_Load: + DW ((L0609_LoadFinished - L0609_Load2)) ;size +L0609_Load2: + call ParseMap + ret + +L0609_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0609_Map: +INCBIN "Data/Levels/L0609_outback.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0609_Init: + DW ((L0609_InitFinished - L0609_Init2)) ;size +L0609_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0609_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0609_Check: + DW ((L0609_CheckFinished - L0609_Check2)) ;size +L0609_Check2: + call ((.animateWater-L0609_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0609_CheckFinished: +PRINT "0609 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0609_LoadFinished - L0609_Load2) +PRINT " / " +PRINT (L0609_InitFinished - L0609_Init2) +PRINT " / " +PRINT (L0609_CheckFinished - L0609_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0610.asm b/Source/Levels/L0610.asm new file mode 100644 index 0000000..bfa20a1 --- /dev/null +++ b/Source/Levels/L0610.asm @@ -0,0 +1,74 @@ +; L0610.asm outback +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 2 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0610Section",ROMX +;--------------------------------------------------------------------- + +L0610_Contents:: + DW L0610_Load + DW L0610_Init + DW L0610_Check + DW L0610_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0610_Load: + DW ((L0610_LoadFinished - L0610_Load2)) ;size +L0610_Load2: + call ParseMap + ret + +L0610_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0610_Map: +INCBIN "Data/Levels/L0610_outback.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0610_Init: + DW ((L0610_InitFinished - L0610_Init2)) ;size +L0610_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0610_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0610_Check: + DW ((L0610_CheckFinished - L0610_Check2)) ;size +L0610_Check2: + call ((.animateWater-L0610_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0610_CheckFinished: +PRINT "0610 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0610_LoadFinished - L0610_Load2) +PRINT " / " +PRINT (L0610_InitFinished - L0610_Init2) +PRINT " / " +PRINT (L0610_CheckFinished - L0610_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0612.asm b/Source/Levels/L0612.asm new file mode 100644 index 0000000..61f4814 --- /dev/null +++ b/Source/Levels/L0612.asm @@ -0,0 +1,592 @@ +; L0612.asm crouton teleport chamber +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +DICEINDEX EQU 31 +VAR_DICELIGHT EQU 0 +VAR_TENS EQU 1 +VAR_ONES EQU 2 +VAR_COUNT EQU 3 +VAR_VBLANKS EQU 4 + +STATE_NOP EQU 1 +STATE_TALKPLAN EQU 2 +STATE_TALKCONTROLS EQU 3 +STATE_NOCLEARANCE EQU 4 +STATE_COUNTDOWN EQU 5 +STATE_DUKE EQU 6 +STATE_RETURNINIT EQU 7 +STATE_RETURNTALK EQU 8 +STATE_NORMAL EQU 9 + + +;--------------------------------------------------------------------- +SECTION "Level0612Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L0612_plan_gtx: + INCBIN "Data/Dialog/Talk/L0612_plan.gtx" + +L0612_clearance_gtx: + INCBIN "Data/Dialog/Talk/L0612_clearance.gtx" + +L0612_controls_gtx: + INCBIN "Data/Dialog/Talk/L0612_controls.gtx" + +L0612_go_gtx: + INCBIN "Data/Dialog/Talk/L0612_go.gtx" + +L0612_duke_gtx: + INCBIN "Data/Dialog/Talk/L0612_duke.gtx" + +L0612_return_gtx: + INCBIN "Data/Dialog/Talk/L0612_return.gtx" + +L0612_Contents:: + DW L0612_Load + DW L0612_Init + DW L0612_Check + DW L0612_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0612_Load: + DW ((L0612_LoadFinished - L0612_Load2)) ;size +L0612_Load2: + call ParseMap + + ;make sure $ff is a blank sprite tile + PUSHROM + ld a,BANK(BGTiles1024) + call SetActiveROM + ld a,0 + ld c,1 + ld de,$8ff0 + ld hl,BGTiles1024 + call VMemCopy + POPROM + ret + +L0612_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0612_Map: +INCBIN "Data/Levels/L0612_teleport.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0612_Init: + DW ((L0612_InitFinished - L0612_Init2)) ;size +L0612_Init2: + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cf] ;been to generators? + or a + jr nz,.afterReset ;blown up + + ld a,STATE_NOP + ldio [mapState],a + +.afterReset + STDSETUPDIALOG + + ld hl,$1100 + call SetJoinMap + call SetRespawnMap + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + + ld a,[bgTileMap+DICEINDEX] ;tile index of first light + ld [levelVars+VAR_DICELIGHT],a + + ld a,ENV_COUNTER + ld [envEffectType],a + + ld a,$ff + ld [levelVars+VAR_COUNT],a + xor a + ld [levelVars+VAR_VBLANKS],a + + ;allocate and position two sprites for the timer countdown + ;set them to $ff (blank sprite tile) + call ((.alloc-L0612_Init2)+levelCheckRAM) + ld [levelVars+VAR_TENS],a + call ((.alloc-L0612_Init2)+levelCheckRAM) + ld [levelVars+VAR_ONES],a + inc hl + ld [hl],88 ;different xpos for second + + ;delete hulk, grunt, goblin, and artillery + ld bc,classCroutonGrunt + call DeleteObjectsOfClass + ld bc,classCroutonHulk + call DeleteObjectsOfClass + ld bc,classCroutonArtillery + call DeleteObjectsOfClass + ld bc,classCroutonGoblin + call DeleteObjectsOfClass + + ret + +.alloc + call AllocateSprite + ld l,a + ld h,((spriteOAMBuffer>>8)&$ff) + push hl + ld [hl],16 + inc hl + ld [hl],80 + inc hl + ld [hl],$ff + inc hl + ld [hl],0 + pop hl + ld a,l + ret + +L0612_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0612_Check: + DW ((L0612_CheckFinished - L0612_Check2)) ;size +L0612_Check2: + call ((.animateDiceLights-L0612_Check2)+levelCheckRAM) + call ((.generateCube-L0612_Check2)+levelCheckRAM) + call ((.displayCount-L0612_Check2)+levelCheckRAM) + ld hl,((.vectorToStateTable-L0612_Check2)+levelCheckRAM) + VECTORTOSTATE ((.vectorToStateTable-L0612_Check2)+levelCheckRAM) + ret + +.vectorToStateTable + DW ((.stateNOP-L0612_Check2)+levelCheckRAM) + DW ((.stateNOP-L0612_Check2)+levelCheckRAM) + DW ((.stateTalkPlan-L0612_Check2)+levelCheckRAM) + DW ((.stateTalkControls-L0612_Check2)+levelCheckRAM) + DW ((.stateNoClearance-L0612_Check2)+levelCheckRAM) + DW ((.stateCountdown-L0612_Check2)+levelCheckRAM) + DW ((.stateDuke-L0612_Check2)+levelCheckRAM) + DW ((.stateReturnInit-L0612_Check2)+levelCheckRAM) + DW ((.stateReturnTalk-L0612_Check2)+levelCheckRAM) + DW ((.stateNormal-L0612_Check2)+levelCheckRAM) + +.stateNOP + ld a,STATE_TALKPLAN + ldio [mapState],a + ret + +.stateTalkPlan + call MakeIdle + ld de,((.afterTalkPlanDialog-L0612_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,L0612_plan_gtx + call ShowDialogAtBottom + +.afterTalkPlanDialog + call ClearDialogSkipForward + call MakeNonIdle + ld a,STATE_TALKCONTROLS + ldio [mapState],a + ret + +.stateTalkControls + ld a,1 + ld hl,((.checkAtControls-L0612_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkAtControls + ld c,a + call GetFirst + call GetCurZone + cp 3 + jr z,.atControls + + xor a + ret + +.atControls + push bc + ld bc,ITEM_ZETACLEAR + call HasInventoryItem + pop bc + jr z,.needClearance + + call SetSpeakerFromHeroIndex + call MakeIdle + ld de,((.afterControlsDialog-L0612_Check2)+levelCheckRAM) + call SetDialogSkip + + ld de,L0612_controls_gtx + call ShowDialogAtBottom + +.afterControlsDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,90 + ld [levelVars+VAR_COUNT],a + ld a,STATE_COUNTDOWN + ldio [mapState],a + ld a,1 + ret + +.needClearance + call MakeIdle + ld de,((.afterClearanceDialog-L0612_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,L0612_clearance_gtx + call ShowDialogAtBottom + +.afterClearanceDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,STATE_NOCLEARANCE + ldio [mapState],a + ld a,1 + ret + +.stateNoClearance + ret + +.stateCountdown + ld hl,levelVars+VAR_VBLANKS + inc [hl] + ld a,[hl] + cp 30 + ret c + + ld [hl],0 + ld hl,levelVars+VAR_COUNT + dec [hl] + ret nz + + ld a,STATE_DUKE + ldio [mapState],a + ret + +.stateDuke + ld a,1 + ld hl,((.checkAtStation-L0612_Check2)+levelCheckRAM) + jp CheckEachHero + +.checkAtStation + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atStation + + xor a + ret + +.atStation + call MakeIdle + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld de,((.afterGoDialog-L0612_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0612_go_gtx + call ShowDialogAtBottom + +.afterGoDialog + + ld c,7 +.flicker + ld a,c + rlca + ld b,15 + call SetupFadeFromSaturated + call WaitFade + + ld a,c + rlca + call Delay + + dec c + jr nz,.flicker + + ld a,BANK(jungle_gbm) + ld hl,jungle_gbm + call InitMusic + + xor a + ld [camera_i],a + ld [camera_j],a + + ld de,L0612_duke_gtx + call ShowDialogAtBottom + + ld c,7 +.flicker2 + ld a,c + rlca + ld b,15 + call SetupFadeFromSaturated + call WaitFade + + ld a,c + rlca + call Delay + + dec c + jr nz,.flicker2 + +.afterDukeDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$0912 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + + ld a,STATE_RETURNINIT + ldio [mapState],a + + ld a,EXIT_D + call YankRemotePlayer + + ld a,1 + ld [timeToChangeLevel],a + + ld a,1 + ret + +.stateReturnInit + ld a,STATE_RETURNTALK + ldio [mapState],a + ret + +.stateReturnTalk + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cf] ;homeworld 4 + or a + jr nz,.talk + + ld a,STATE_RETURNINIT + ldio [mapState],a + ret + +.talk + call MakeIdle + ld de,((.afterReturnDialog-L0612_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerToFirstHero + ld de,L0612_return_gtx + call ShowDialogAtBottom + +.afterReturnDialog + call ClearDialogSkipForward + call MakeNonIdle + ld a,STATE_NORMAL + ldio [mapState],a + ret + +.stateNormal + ret + +.displayCount + ld a,[levelVars+VAR_COUNT] + cp 100 + ret nc ;don't display values >= 100 + + ;tens = count / 10 + ld b,a + ld c,0 +.getDiv + cp 10 + jr c,.gotDiv + sub 10 + inc c + jr .getDiv + +.gotDiv + add 200 + ld hl,spriteOAMBuffer+4+2 + ld [hl],a ;ones digit + ld a,c + add 200 + ld hl,spriteOAMBuffer+2 + ld [hl],a ;tens digit + ret + +.generateCube + ldio a,[mapState] + cp STATE_RETURNINIT + ret nc + + ;make a cube every so often + ldio a,[updateTimer] + and 63 + ret nz + + ;pick one of 12 positions from the table + ;ld a,3 + ;call GetRandomNumMask + ;ld b,a + ;rlca + ;add b + ld a,11 + call GetRandomNumZeroToN + ld hl,((.cubeAppearTable-L0612_Check2)+levelCheckRAM) + ld b,a + call Lookup16 + + ;make sure it's clear + push hl + call ((.isOccupied2x2-L0612_Check2)+levelCheckRAM) + pop hl + jr z,.go + + ld a,b + inc a + cp 12 + jr c,.aokay + xor a +.aokay + ld b,a + ld hl,((.cubeAppearTable-L0612_Check2)+levelCheckRAM) + call Lookup16 + + push hl + call ((.isOccupied2x2-L0612_Check2)+levelCheckRAM) + pop hl + jr z,.go + + ld a,b + inc a + cp 12 + jr c,.aokay2 + xor a +.aokay2 + ld b,a + ld hl,((.cubeAppearTable-L0612_Check2)+levelCheckRAM) + call Lookup16 + + push hl + call ((.isOccupied2x2-L0612_Check2)+levelCheckRAM) + pop hl + ret nz + +.go + ld bc,classTeleportCube + call FindClassIndex + ret z + ld c,a + call CreateInitAndDrawObject + ret + +.isOccupied2x2 + ld a,MAPBANK + ldio [$ff70],a + ld a,[hl+] + or a + ret nz + + ld a,[hl-] + or a + ret nz + + ld a,[mapPitch] + ld e,a + ld d,0 + push de + add hl,de + pop de + ld a,[hl+] + or a + ret nz + + ld a,[hl] + or a + ret + +.animateDiceLights + ;animate dice lights + ld a,[levelVars+VAR_DICELIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+DICEINDEX + call ((.updateTwoLights - L0612_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L0612_Check2) + levelCheckRAM) + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L0612_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +.cubeAppearTable + DW $d1a3, $d223, $d2a3, $d323, $d3a3, $d423 + DW $d1b1, $d231, $d2b1, $d331, $d3b1, $d431 +;$d1a3 + ;$d223 + ;$d2a3 +;$d323 + ;$d3a3 + ;$d423 +;$d1b1 + ;$d231 + ;$d2b1 +;$d331 + ;$d3b1 + ;$d431 + + +L0612_CheckFinished: +PRINT "0612 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0612_LoadFinished - L0612_Load2) +PRINT " / " +PRINT (L0612_InitFinished - L0612_Init2) +PRINT " / " +PRINT (L0612_CheckFinished - L0612_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0700.asm b/Source/Levels/L0700.asm new file mode 100644 index 0000000..294e1e5 --- /dev/null +++ b/Source/Levels/L0700.asm @@ -0,0 +1,62 @@ +; L0700.asm +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0700Section",ROMX +;--------------------------------------------------------------------- + +L0700_Contents:: + DW L0700_Load + DW L0700_Init + DW L0700_Check + DW L0700_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0700_Load: + DW ((L0700_LoadFinished - L0700_Load2)) ;size +L0700_Load2: + call ParseMap + ret + +L0700_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0700_Map: +INCBIN "Data/Levels/L0700_ice.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0700_Init: + DW ((L0700_InitFinished - L0700_Init2)) ;size +L0700_Init2: + call UseAlternatePalette + ld a,ENV_SNOW + call SetEnvEffect + ret + +L0700_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0700_Check: + DW ((L0700_CheckFinished - L0700_Check2)) ;size +L0700_Check2: + ret + +L0700_CheckFinished: +PRINT "0700 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0700_LoadFinished - L0700_Load2) +PRINT " / " +PRINT (L0700_InitFinished - L0700_Init2) +PRINT " / " +PRINT (L0700_CheckFinished - L0700_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0701.asm b/Source/Levels/L0701.asm new file mode 100644 index 0000000..3f660b0 --- /dev/null +++ b/Source/Levels/L0701.asm @@ -0,0 +1,61 @@ +; L0701.asm kiwi keep +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0701Section",ROMX +;--------------------------------------------------------------------- + +L0701_Contents:: + DW L0701_Load + DW L0701_Init + DW L0701_Check + DW L0701_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0701_Load: + DW ((L0701_LoadFinished - L0701_Load2)) ;size +L0701_Load2: + call ParseMap + ret + +L0701_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0701_Map: +INCBIN "Data/Levels/L0701_kiwikeep.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0701_Init: + DW ((L0701_InitFinished - L0701_Init2)) ;size +L0701_Init2: + ld a,ENV_CLOUDS + call SetEnvEffect + ret + +L0701_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0701_Check: + DW ((L0701_CheckFinished - L0701_Check2)) ;size +L0701_Check2: + ret + +L0701_CheckFinished: +PRINT "0701 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0701_LoadFinished - L0701_Load2) +PRINT " / " +PRINT (L0701_InitFinished - L0701_Init2) +PRINT " / " +PRINT (L0701_CheckFinished - L0701_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0702.asm b/Source/Levels/L0702.asm new file mode 100644 index 0000000..9a80c56 --- /dev/null +++ b/Source/Levels/L0702.asm @@ -0,0 +1,59 @@ +; L0702.asm +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0702Section",ROMX +;--------------------------------------------------------------------- + +L0702_Contents:: + DW L0702_Load + DW L0702_Init + DW L0702_Check + DW L0702_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0702_Load: + DW ((L0702_LoadFinished - L0702_Load2)) ;size +L0702_Load2: + call ParseMap + ret + +L0702_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0702_Map: +INCBIN "Data/Levels/L0702_caverns.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0702_Init: + DW ((L0702_InitFinished - L0702_Init2)) ;size +L0702_Init2: + ret + +L0702_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0702_Check: + DW ((L0702_CheckFinished - L0702_Check2)) ;size +L0702_Check2: + ret + +L0702_CheckFinished: +PRINT "0702 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0702_LoadFinished - L0702_Load2) +PRINT " / " +PRINT (L0702_InitFinished - L0702_Init2) +PRINT " / " +PRINT (L0702_CheckFinished - L0702_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0703.asm b/Source/Levels/L0703.asm new file mode 100644 index 0000000..099fe6c --- /dev/null +++ b/Source/Levels/L0703.asm @@ -0,0 +1,59 @@ +; L0703.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0703Section",ROMX +;--------------------------------------------------------------------- + +L0703_Contents:: + DW L0703_Load + DW L0703_Init + DW L0703_Check + DW L0703_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0703_Load: + DW ((L0703_LoadFinished - L0703_Load2)) ;size +L0703_Load2: + call ParseMap + ret + +L0703_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0703_Map: +INCBIN "Data/Levels/L0703_caverns.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0703_Init: + DW ((L0703_InitFinished - L0703_Init2)) ;size +L0703_Init2: + ret + +L0703_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0703_Check: + DW ((L0703_CheckFinished - L0703_Check2)) ;size +L0703_Check2: + ret + +L0703_CheckFinished: +PRINT "0703 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0703_LoadFinished - L0703_Load2) +PRINT " / " +PRINT (L0703_InitFinished - L0703_Init2) +PRINT " / " +PRINT (L0703_CheckFinished - L0703_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0704.asm b/Source/Levels/L0704.asm new file mode 100644 index 0000000..95ff9d1 --- /dev/null +++ b/Source/Levels/L0704.asm @@ -0,0 +1,98 @@ +; L0704.asm Canyon Landing +; Generated 09.18.2000 by mlevel +; Modified 09.18.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 65 + +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0704Section",ROMX +;--------------------------------------------------------------------- + +L0704_Contents:: + DW L0704_Load + DW L0704_Init + DW L0704_Check + DW L0704_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0704_Load: + DW ((L0704_LoadFinished - L0704_Load2)) ;size +L0704_Load2: + call ParseMap + ret + +L0704_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0704_Map: +INCBIN "Data/Levels/L0704_canyon.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0704_Init: + DW ((L0704_InitFinished - L0704_Init2)) ;size +L0704_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + ;ld a,BANK(main_in_game_gbm) + ;ld hl,main_in_game_gbm + ;call InitMusic + ret + +L0704_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0704_Check: + DW ((L0704_CheckFinished - L0704_Check2)) ;size +L0704_Check2: + call ((.animateLandingLights-L0704_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0704_Check2)+levelCheckRAM) + call ((.animateLight-L0704_Check2)+levelCheckRAM) + call ((.animateLight-L0704_Check2)+levelCheckRAM) + call ((.animateLight-L0704_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0704_CheckFinished: +PRINT "0704 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0704_LoadFinished - L0704_Load2) +PRINT " / " +PRINT (L0704_InitFinished - L0704_Init2) +PRINT " / " +PRINT (L0704_CheckFinished - L0704_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0705.asm b/Source/Levels/L0705.asm new file mode 100644 index 0000000..cec1ca0 --- /dev/null +++ b/Source/Levels/L0705.asm @@ -0,0 +1,59 @@ +; L0705.asm +; Generated 10.26.2000 by mlevel +; Modified 10.26.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0705Section",ROMX +;--------------------------------------------------------------------- + +L0705_Contents:: + DW L0705_Load + DW L0705_Init + DW L0705_Check + DW L0705_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0705_Load: + DW ((L0705_LoadFinished - L0705_Load2)) ;size +L0705_Load2: + call ParseMap + ret + +L0705_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0705_Map: +INCBIN "Data/Levels/L0705_jungle.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0705_Init: + DW ((L0705_InitFinished - L0705_Init2)) ;size +L0705_Init2: + ret + +L0705_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0705_Check: + DW ((L0705_CheckFinished - L0705_Check2)) ;size +L0705_Check2: + ret + +L0705_CheckFinished: +PRINT "0705 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0705_LoadFinished - L0705_Load2) +PRINT " / " +PRINT (L0705_InitFinished - L0705_Init2) +PRINT " / " +PRINT (L0705_CheckFinished - L0705_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0706.asm b/Source/Levels/L0706.asm new file mode 100644 index 0000000..5d056e4 --- /dev/null +++ b/Source/Levels/L0706.asm @@ -0,0 +1,59 @@ +; L0706.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0706Section",ROMX +;--------------------------------------------------------------------- + +L0706_Contents:: + DW L0706_Load + DW L0706_Init + DW L0706_Check + DW L0706_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0706_Load: + DW ((L0706_LoadFinished - L0706_Load2)) ;size +L0706_Load2: + call ParseMap + ret + +L0706_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0706_Map: +INCBIN "Data/Levels/L0706_swamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0706_Init: + DW ((L0706_InitFinished - L0706_Init2)) ;size +L0706_Init2: + ret + +L0706_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0706_Check: + DW ((L0706_CheckFinished - L0706_Check2)) ;size +L0706_Check2: + ret + +L0706_CheckFinished: +PRINT "0706 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0706_LoadFinished - L0706_Load2) +PRINT " / " +PRINT (L0706_InitFinished - L0706_Init2) +PRINT " / " +PRINT (L0706_CheckFinished - L0706_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0707.asm b/Source/Levels/L0707.asm new file mode 100644 index 0000000..7ba1b69 --- /dev/null +++ b/Source/Levels/L0707.asm @@ -0,0 +1,61 @@ +; L0707.asm +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0707Section",ROMX +;--------------------------------------------------------------------- + +L0707_Contents:: + DW L0707_Load + DW L0707_Init + DW L0707_Check + DW L0707_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0707_Load: + DW ((L0707_LoadFinished - L0707_Load2)) ;size +L0707_Load2: + call ParseMap + ret + +L0707_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0707_Map: +INCBIN "Data/Levels/L0707_barrows.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0707_Init: + DW ((L0707_InitFinished - L0707_Init2)) ;size +L0707_Init2: + ld a,ENV_RAIN + call SetEnvEffect + ret + +L0707_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0707_Check: + DW ((L0707_CheckFinished - L0707_Check2)) ;size +L0707_Check2: + ret + +L0707_CheckFinished: +PRINT "0707 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0707_LoadFinished - L0707_Load2) +PRINT " / " +PRINT (L0707_InitFinished - L0707_Init2) +PRINT " / " +PRINT (L0707_CheckFinished - L0707_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0708.asm b/Source/Levels/L0708.asm new file mode 100644 index 0000000..f8bb6be --- /dev/null +++ b/Source/Levels/L0708.asm @@ -0,0 +1,59 @@ +; L0708.asm +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0708Section",ROMX +;--------------------------------------------------------------------- + +L0708_Contents:: + DW L0708_Load + DW L0708_Init + DW L0708_Check + DW L0708_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0708_Load: + DW ((L0708_LoadFinished - L0708_Load2)) ;size +L0708_Load2: + call ParseMap + ret + +L0708_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0708_Map: +INCBIN "Data/Levels/L0708_swamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0708_Init: + DW ((L0708_InitFinished - L0708_Init2)) ;size +L0708_Init2: + ret + +L0708_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0708_Check: + DW ((L0708_CheckFinished - L0708_Check2)) ;size +L0708_Check2: + ret + +L0708_CheckFinished: +PRINT "0708 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0708_LoadFinished - L0708_Load2) +PRINT " / " +PRINT (L0708_InitFinished - L0708_Init2) +PRINT " / " +PRINT (L0708_CheckFinished - L0708_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0709.asm b/Source/Levels/L0709.asm new file mode 100644 index 0000000..5fb9cf5 --- /dev/null +++ b/Source/Levels/L0709.asm @@ -0,0 +1,81 @@ +; L0709.asm scardie +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 2 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0709Section",ROMX +;--------------------------------------------------------------------- + +L0709_Contents:: + DW L0709_Load + DW L0709_Init + DW L0709_Check + DW L0709_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0709_Load: + DW ((L0709_LoadFinished - L0709_Load2)) ;size +L0709_Load2: + call ParseMap + ret + +L0709_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0709_Map: +INCBIN "Data/Levels/L0709_outback.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0709_Init: + DW ((L0709_InitFinished - L0709_Init2)) ;size +L0709_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld a,ENV_DIRT + call SetEnvEffect + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0709_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0709_Check: + DW ((L0709_CheckFinished - L0709_Check2)) ;size +L0709_Check2: + call ((.animateWater-L0709_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0709_CheckFinished: +PRINT "0709 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0709_LoadFinished - L0709_Load2) +PRINT " / " +PRINT (L0709_InitFinished - L0709_Init2) +PRINT " / " +PRINT (L0709_CheckFinished - L0709_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0710.asm b/Source/Levels/L0710.asm new file mode 100644 index 0000000..906bb90 --- /dev/null +++ b/Source/Levels/L0710.asm @@ -0,0 +1,78 @@ +; L0710.asm outback croc keeper +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 3 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0710Section",ROMX +;--------------------------------------------------------------------- + +L0710_Contents:: + DW L0710_Load + DW L0710_Init + DW L0710_Check + DW L0710_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0710_Load: + DW ((L0710_LoadFinished - L0710_Load2)) ;size +L0710_Load2: + call ParseMap + ret + +L0710_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0710_Map: +INCBIN "Data/Levels/L0710_outback.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0710_Init: + DW ((L0710_InitFinished - L0710_Init2)) ;size +L0710_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0710_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0710_Check: + DW ((L0710_CheckFinished - L0710_Check2)) ;size +L0710_Check2: + call ((.animateWater-L0710_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0710_CheckFinished: +PRINT "0710 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0710_LoadFinished - L0710_Load2) +PRINT " / " +PRINT (L0710_InitFinished - L0710_Init2) +PRINT " / " +PRINT (L0710_CheckFinished - L0710_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0711.asm b/Source/Levels/L0711.asm new file mode 100644 index 0000000..cec8a6a --- /dev/null +++ b/Source/Levels/L0711.asm @@ -0,0 +1,104 @@ +; L0711.asm Space Station Apocalypse Exterior +; Generated 04.25.2001 by mlevel +; Modified 04.25.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0711Section",ROMX +;--------------------------------------------------------------------- + +;import classBAPlayer +;import classBSPlayer +;import classHaikuPlayer +;import classBAPlayerSpace +;import classBSPlayerSpace +;import classHaikuPlayerSpace + +L0711_Contents:: + DW L0711_Load + DW L0711_Init + DW L0711_Check + DW L0711_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0711_Load: + DW ((L0711_LoadFinished - L0711_Load2)) ;size +L0711_Load2: + ld a,[hero0_enterLevelFacing] + cp EXIT_U + jr nz,.checkHero1 + + ld a,50 + ld [hero0_enterLevelLocation],a + ld a,23 + ld [hero0_enterLevelLocation+1],a + +.checkHero1 + ld a,[hero1_enterLevelFacing] + cp EXIT_U + jr nz,.afterChangeEnterLoc + + ld a,50 + ld [hero1_enterLevelLocation],a + ld a,23 + ld [hero1_enterLevelLocation+1],a + +.afterChangeEnterLoc + call ParseMap + ret + +L0711_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0711_Map: +INCBIN "Data/Levels/L0711_spacestation.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0711_Init: + DW ((L0711_InitFinished - L0711_Init2)) ;size +L0711_Init2: + ld a,BANK(spaceish_gbm) + ld hl,spaceish_gbm + call InitMusic + ret + +L0711_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0711_Check: + DW ((L0711_CheckFinished - L0711_Check2)) ;size +L0711_Check2: + call ((.changePlayersToSpace-L0711_Check2)+levelCheckRAM) + ret + +.changePlayersToSpace + ld bc,classBAPlayer + ld de,classBAPlayerSpace + call ChangeClass + + ld bc,classBSPlayer + ld de,classBSPlayerSpace + call ChangeClass + + ld bc,classHaikuPlayer + ld de,classHaikuPlayerSpace + call ChangeClass + ret + +L0711_CheckFinished: +PRINT "0711 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0711_LoadFinished - L0711_Load2) +PRINT " / " +PRINT (L0711_InitFinished - L0711_Init2) +PRINT " / " +PRINT (L0711_CheckFinished - L0711_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0712.asm b/Source/Levels/L0712.asm new file mode 100644 index 0000000..918c907 --- /dev/null +++ b/Source/Levels/L0712.asm @@ -0,0 +1,97 @@ +; L0712.asm farm landing +; Generated 11.29.2000 by mlevel +; Modified 11.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 46 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0712Section",ROMX +;--------------------------------------------------------------------- + +L0712_Contents:: + DW L0712_Load + DW L0712_Init + DW L0712_Check + DW L0712_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0712_Load: + DW ((L0712_LoadFinished - L0712_Load2)) ;size +L0712_Load2: + call ParseMap + ret + +L0712_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0712_Map: +INCBIN "Data/Levels/L0712_farmlanding.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0712_Init: + DW ((L0712_InitFinished - L0712_Init2)) ;size +L0712_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call InitMusic + ret + +L0712_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0712_Check: + DW ((L0712_CheckFinished - L0712_Check2)) ;size +L0712_Check2: + call ((.animateLandingLights-L0712_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0712_Check2)+levelCheckRAM) + call ((.animateLight-L0712_Check2)+levelCheckRAM) + call ((.animateLight-L0712_Check2)+levelCheckRAM) + call ((.animateLight-L0712_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0712_CheckFinished: +PRINT "0712 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0712_LoadFinished - L0712_Load2) +PRINT " / " +PRINT (L0712_InitFinished - L0712_Init2) +PRINT " / " +PRINT (L0712_CheckFinished - L0712_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0800.asm b/Source/Levels/L0800.asm new file mode 100644 index 0000000..67e377d --- /dev/null +++ b/Source/Levels/L0800.asm @@ -0,0 +1,95 @@ +; L0800.asm ice bridge +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX1 EQU 6 +WATERINDEX2 EQU 16 +VAR_WATER1 EQU 0 +VAR_WATER2 EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0800Section",ROMX +;--------------------------------------------------------------------- + +L0800_Contents:: + DW L0800_Load + DW L0800_Init + DW L0800_Check + DW L0800_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0800_Load: + DW ((L0800_LoadFinished - L0800_Load2)) ;size +L0800_Load2: + call ParseMap + ret + +L0800_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0800_Map: +INCBIN "Data/Levels/L0800_ice.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0800_Init: + DW ((L0800_InitFinished - L0800_Init2)) ;size +L0800_Init2: + call UseAlternatePalette + ld a,[bgTileMap + WATERINDEX1] + ld [levelVars + VAR_WATER1],a + ld a,[bgTileMap + WATERINDEX2] + ld [levelVars + VAR_WATER2],a + ld a,ENV_SNOW + call SetEnvEffect + + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + ret + +L0800_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0800_Check: + DW ((L0800_CheckFinished - L0800_Check2)) ;size +L0800_Check2: + call ((.animateWater1-L0800_Check2)+levelCheckRAM) + call ((.animateWater2-L0800_Check2)+levelCheckRAM) + ret + +.animateWater1 + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER1 + add [hl] + ld [bgTileMap + WATERINDEX1],a + ret + +.animateWater2 + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER2 + add [hl] + ld [bgTileMap + WATERINDEX2],a + ret + +L0800_CheckFinished: +PRINT "0800 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0800_LoadFinished - L0800_Load2) +PRINT " / " +PRINT (L0800_InitFinished - L0800_Init2) +PRINT " / " +PRINT (L0800_CheckFinished - L0800_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0801.asm b/Source/Levels/L0801.asm new file mode 100644 index 0000000..a98cc97 --- /dev/null +++ b/Source/Levels/L0801.asm @@ -0,0 +1,59 @@ +; L0801.asm +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0801Section",ROMX +;--------------------------------------------------------------------- + +L0801_Contents:: + DW L0801_Load + DW L0801_Init + DW L0801_Check + DW L0801_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0801_Load: + DW ((L0801_LoadFinished - L0801_Load2)) ;size +L0801_Load2: + call ParseMap + ret + +L0801_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0801_Map: +INCBIN "Data/Levels/L0801_escape.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0801_Init: + DW ((L0801_InitFinished - L0801_Init2)) ;size +L0801_Init2: + ret + +L0801_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0801_Check: + DW ((L0801_CheckFinished - L0801_Check2)) ;size +L0801_Check2: + ret + +L0801_CheckFinished: +PRINT "0801 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0801_LoadFinished - L0801_Load2) +PRINT " / " +PRINT (L0801_InitFinished - L0801_Init2) +PRINT " / " +PRINT (L0801_CheckFinished - L0801_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0802.asm b/Source/Levels/L0802.asm new file mode 100644 index 0000000..edf0de3 --- /dev/null +++ b/Source/Levels/L0802.asm @@ -0,0 +1,65 @@ +; L0802.asm windy passage +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0802Section",ROMX +;--------------------------------------------------------------------- + +L0802_Contents:: + DW L0802_Load + DW L0802_Init + DW L0802_Check + DW L0802_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0802_Load: + DW ((L0802_LoadFinished - L0802_Load2)) ;size +L0802_Load2: + call ParseMap + ret + +L0802_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0802_Map: +INCBIN "Data/Levels/L0802_windypass.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0802_Init: + DW ((L0802_InitFinished - L0802_Init2)) ;size +L0802_Init2: + call UseAlternatePalette + ld a,ENV_WINDYSNOW + call SetEnvEffect + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0802_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0802_Check: + DW ((L0802_CheckFinished - L0802_Check2)) ;size +L0802_Check2: + ret + +L0802_CheckFinished: +PRINT "0802 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0802_LoadFinished - L0802_Load2) +PRINT " / " +PRINT (L0802_InitFinished - L0802_Init2) +PRINT " / " +PRINT (L0802_CheckFinished - L0802_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0803.asm b/Source/Levels/L0803.asm new file mode 100644 index 0000000..fcf35b5 --- /dev/null +++ b/Source/Levels/L0803.asm @@ -0,0 +1,74 @@ +; L0803.asm genie +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 24 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0803Section",ROMX +;--------------------------------------------------------------------- + +L0803_Contents:: + DW L0803_Load + DW L0803_Init + DW L0803_Check + DW L0803_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0803_Load: + DW ((L0803_LoadFinished - L0803_Load2)) ;size +L0803_Load2: + call ParseMap + ret + +L0803_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0803_Map: +INCBIN "Data/Levels/L0803_djinn.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0803_Init: + DW ((L0803_InitFinished - L0803_Init2)) ;size +L0803_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0803_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0803_Check: + DW ((L0803_CheckFinished - L0803_Check2)) ;size +L0803_Check2: + call ((.animateWater-L0803_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0803_CheckFinished: +PRINT "0803 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0803_LoadFinished - L0803_Load2) +PRINT " / " +PRINT (L0803_InitFinished - L0803_Init2) +PRINT " / " +PRINT (L0803_CheckFinished - L0803_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0804.asm b/Source/Levels/L0804.asm new file mode 100644 index 0000000..ffde67c --- /dev/null +++ b/Source/Levels/L0804.asm @@ -0,0 +1,75 @@ +; L0804.asm grand canyon +; Generated 09.18.2000 by mlevel +; Modified 09.18.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + + +;--------------------------------------------------------------------- +SECTION "Level0804Section",ROMX +;--------------------------------------------------------------------- + +L0804_Contents:: + DW L0804_Load + DW L0804_Init + DW L0804_Check + DW L0804_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0804_Load: + DW ((L0804_LoadFinished - L0804_Load2)) ;size +L0804_Load2: + call ParseMap + ret + +L0804_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0804_Map: +INCBIN "Data/Levels/L0804_canyon.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0804_Init: + DW ((L0804_InitFinished - L0804_Init2)) ;size +L0804_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ret + +L0804_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0804_Check: + DW ((L0804_CheckFinished - L0804_Check2)) ;size +L0804_Check2: + call ((.animateWater-L0804_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L0804_CheckFinished: +PRINT "0804 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0804_LoadFinished - L0804_Load2) +PRINT " / " +PRINT (L0804_InitFinished - L0804_Init2) +PRINT " / " +PRINT (L0804_CheckFinished - L0804_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0805.asm b/Source/Levels/L0805.asm new file mode 100644 index 0000000..2f94e41 --- /dev/null +++ b/Source/Levels/L0805.asm @@ -0,0 +1,59 @@ +; L0805.asm +; Generated 10.27.2000 by mlevel +; Modified 10.27.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0805Section",ROMX +;--------------------------------------------------------------------- + +L0805_Contents:: + DW L0805_Load + DW L0805_Init + DW L0805_Check + DW L0805_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0805_Load: + DW ((L0805_LoadFinished - L0805_Load2)) ;size +L0805_Load2: + call ParseMap + ret + +L0805_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0805_Map: +INCBIN "Data/Levels/L0805_jungle.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0805_Init: + DW ((L0805_InitFinished - L0805_Init2)) ;size +L0805_Init2: + ret + +L0805_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0805_Check: + DW ((L0805_CheckFinished - L0805_Check2)) ;size +L0805_Check2: + ret + +L0805_CheckFinished: +PRINT "0805 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0805_LoadFinished - L0805_Load2) +PRINT " / " +PRINT (L0805_InitFinished - L0805_Init2) +PRINT " / " +PRINT (L0805_CheckFinished - L0805_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0806.asm b/Source/Levels/L0806.asm new file mode 100644 index 0000000..057d66a --- /dev/null +++ b/Source/Levels/L0806.asm @@ -0,0 +1,62 @@ +; L0806.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0806Section",ROMX +;--------------------------------------------------------------------- + +L0806_Contents:: + DW L0806_Load + DW L0806_Init + DW L0806_Check + DW L0806_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0806_Load: + DW ((L0806_LoadFinished - L0806_Load2)) ;size +L0806_Load2: + call ParseMap + ret + +L0806_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0806_Map: +INCBIN "Data/Levels/L0806_moores.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0806_Init: + DW ((L0806_InitFinished - L0806_Init2)) ;size +L0806_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0806_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0806_Check: + DW ((L0806_CheckFinished - L0806_Check2)) ;size +L0806_Check2: + ret + +L0806_CheckFinished: +PRINT "0806 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0806_LoadFinished - L0806_Load2) +PRINT " / " +PRINT (L0806_InitFinished - L0806_Init2) +PRINT " / " +PRINT (L0806_CheckFinished - L0806_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0807.asm b/Source/Levels/L0807.asm new file mode 100644 index 0000000..c35480b --- /dev/null +++ b/Source/Levels/L0807.asm @@ -0,0 +1,62 @@ +; L0807.asm +; Generated 11.03.2000 by mlevel +; Modified 11.03.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0807Section",ROMX +;--------------------------------------------------------------------- + +L0807_Contents:: + DW L0807_Load + DW L0807_Init + DW L0807_Check + DW L0807_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0807_Load: + DW ((L0807_LoadFinished - L0807_Load2)) ;size +L0807_Load2: + call ParseMap + ret + +L0807_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0807_Map: +INCBIN "Data/Levels/L0807_swamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0807_Init: + DW ((L0807_InitFinished - L0807_Init2)) ;size +L0807_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0807_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0807_Check: + DW ((L0807_CheckFinished - L0807_Check2)) ;size +L0807_Check2: + ret + +L0807_CheckFinished: +PRINT "0807 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0807_LoadFinished - L0807_Load2) +PRINT " / " +PRINT (L0807_InitFinished - L0807_Init2) +PRINT " / " +PRINT (L0807_CheckFinished - L0807_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0808.asm b/Source/Levels/L0808.asm new file mode 100644 index 0000000..0c365f4 --- /dev/null +++ b/Source/Levels/L0808.asm @@ -0,0 +1,101 @@ +; L0808.asm crouton war camp +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +HFENCE_INDEX EQU 129 +VFENCE_INDEX EQU 133 +VAR_HFENCE EQU 0 +VAR_VFENCE EQU 1 + + +;--------------------------------------------------------------------- +SECTION "Level0808Section",ROMX +;--------------------------------------------------------------------- + +L0808_Contents:: + DW L0808_Load + DW L0808_Init + DW L0808_Check + DW L0808_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0808_Load: + DW ((L0808_LoadFinished - L0808_Load2)) ;size +L0808_Load2: + call ParseMap + ret + +L0808_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0808_Map: +INCBIN "Data/Levels/L0808_warcamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0808_Init: + DW ((L0808_InitFinished - L0808_Init2)) ;size +L0808_Init2: + ld a,[bgTileMap+HFENCE_INDEX] + ld [levelVars + VAR_HFENCE],a + ld a,[bgTileMap+VFENCE_INDEX] + ld [levelVars + VAR_VFENCE],a + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + + ret + +L0808_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0808_Check: + DW ((L0808_CheckFinished - L0808_Check2)) ;size +L0808_Check2: + call ((.animateFence-L0808_Check2)+levelCheckRAM) + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+HFENCE_INDEX + ld a,[levelVars+VAR_HFENCE] + ld d,a + call ((.animateFourFrames-L0808_Check2)+levelCheckRAM) + ld a,[levelVars+VAR_VFENCE] + ld d,a + jp ((.animateFourFrames-L0808_Check2)+levelCheckRAM) + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + +L0808_CheckFinished: +PRINT "0808 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0808_LoadFinished - L0808_Load2) +PRINT " / " +PRINT (L0808_InitFinished - L0808_Init2) +PRINT " / " +PRINT (L0808_CheckFinished - L0808_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0809.asm b/Source/Levels/L0809.asm new file mode 100644 index 0000000..772951c --- /dev/null +++ b/Source/Levels/L0809.asm @@ -0,0 +1,65 @@ +; L0809.asm grenade vs goblin charge +; Generated 11.01.2000 by mlevel +; Modified 11.01.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0809Section",ROMX +;--------------------------------------------------------------------- + +L0809_Contents:: + DW L0809_Load + DW L0809_Init + DW L0809_Check + DW L0809_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0809_Load: + DW ((L0809_LoadFinished - L0809_Load2)) ;size +L0809_Load2: + call ParseMap + ret + +L0809_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0809_Map: +INCBIN "Data/Levels/L0809_warzone.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0809_Init: + DW ((L0809_InitFinished - L0809_Init2)) ;size +L0809_Init2: + ld a,ENV_DIRT + call SetEnvEffect + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + ret + +L0809_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0809_Check: + DW ((L0809_CheckFinished - L0809_Check2)) ;size +L0809_Check2: + ret + +L0809_CheckFinished: +PRINT "0809 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0809_LoadFinished - L0809_Load2) +PRINT " / " +PRINT (L0809_InitFinished - L0809_Init2) +PRINT " / " +PRINT (L0809_CheckFinished - L0809_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0810.asm b/Source/Levels/L0810.asm new file mode 100644 index 0000000..0a21087 --- /dev/null +++ b/Source/Levels/L0810.asm @@ -0,0 +1,98 @@ +; L0810.asm graves landing +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 40 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0810Section",ROMX +;--------------------------------------------------------------------- + +L0810_Contents:: + DW L0810_Load + DW L0810_Init + DW L0810_Check + DW L0810_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0810_Load: + DW ((L0810_LoadFinished - L0810_Load2)) ;size +L0810_Load2: + call ParseMap + ret + +L0810_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0810_Map: +INCBIN "Data/Levels/L0810_graveslanding.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0810_Init: + DW ((L0810_InitFinished - L0810_Init2)) ;size +L0810_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + + LONGCALLNOARGS AddAppomattoxIfPresent + ret + +L0810_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0810_Check: + DW ((L0810_CheckFinished - L0810_Check2)) ;size +L0810_Check2: + call ((.animateLandingLights-L0810_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0810_Check2)+levelCheckRAM) + call ((.animateLight-L0810_Check2)+levelCheckRAM) + call ((.animateLight-L0810_Check2)+levelCheckRAM) + call ((.animateLight-L0810_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0810_CheckFinished: +PRINT "0810 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0810_LoadFinished - L0810_Load2) +PRINT " / " +PRINT (L0810_InitFinished - L0810_Init2) +PRINT " / " +PRINT (L0810_CheckFinished - L0810_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0811.asm b/Source/Levels/L0811.asm new file mode 100644 index 0000000..c5cbedf --- /dev/null +++ b/Source/Levels/L0811.asm @@ -0,0 +1,174 @@ +; L0811.asm ssa nw goblin module +; Generated 04.26.2001 by mlevel +; Modified 04.26.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_DEFUSED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0811Section",ROMX +;--------------------------------------------------------------------- + +L0811_Contents:: + DW L0811_Load + DW L0811_Init + DW L0811_Check + DW L0811_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0811_Load: + DW ((L0811_LoadFinished - L0811_Load2)) ;size +L0811_Load2: + call ParseMap + ret + +L0811_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0811_Map: +INCBIN "Data/Levels/L0811_ssa_nw.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0811_Init: + DW ((L0811_InitFinished - L0811_Init2)) ;size +L0811_Init2: + ld a,BANK(L0012_defused_gtx) + ld [dialogBank],a + call SetPressBDialog + + ldio a,[mapState] + cp STATE_DEFUSED + jr nz,.afterRemoveBomb + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d042 + ld [hl+],a + ld [hl],a + ld hl,$d062 + ld [hl+],a + ld [hl],a + +.afterRemoveBomb + ret + +L0811_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0811_Check: + DW ((L0811_CheckFinished - L0811_Check2)) ;size +L0811_Check2: + call ((.checkAtBomb-L0811_Check2)+levelCheckRAM) + ret + +.checkAtBomb + ldio a,[mapState] + cp STATE_DEFUSED + ret z + + ld hl,((.checkHeroAtBomb-L0811_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtBomb + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atBomb + + xor a + ret + +.atBomb + ld a,STATE_DEFUSED + ldio [mapState],a + + call UpdateState + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d042 + ld [hl+],a + ld [hl],a + ld hl,$d062 + ld [hl+],a + ld [hl],a + + ;check all defused + ld d,0 + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$b8] + cp 2 + jr nz,.check2 + inc d +.check2 + ld a,[levelState+$b9] + cp 2 + jr nz,.check3 + inc d +.check3 + ld a,[levelState+$ba] + cp 2 + jr nz,.check4 + inc d +.check4 + ld a,[levelState+$bb] + cp 2 + jr nz,.checkTotal + inc d +.checkTotal + ;if 3 bombs were defused before this one then that's all + ld a,d + cp 3 + jr nz,.bombsRemain + + ld hl,L0012_alldefused_gtx + jr .dialog + +.bombsRemain + ld hl,L0012_defused_gtx + +.dialog + call MakeIdle + ld de,((.afterDialog-L0811_Check2)+levelCheckRAM) + call SetDialogSkip + + ld d,h + ld e,l + + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ret + + +L0811_CheckFinished: +PRINT "0811 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0811_LoadFinished - L0811_Load2) +PRINT " / " +PRINT (L0811_InitFinished - L0811_Init2) +PRINT " / " +PRINT (L0811_CheckFinished - L0811_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0812.asm b/Source/Levels/L0812.asm new file mode 100644 index 0000000..3c74e30 --- /dev/null +++ b/Source/Levels/L0812.asm @@ -0,0 +1,75 @@ +; L0812.asm demo warp zone +; Generated 12.01.2000 by mlevel +; Modified 12.01.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +FIREINDEX EQU 88 +VAR_FIRE EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0812Section",ROMX +;--------------------------------------------------------------------- + +L0812_Contents:: + DW L0812_Load + DW L0812_Init + DW L0812_Check + DW L0812_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0812_Load: + DW ((L0812_LoadFinished - L0812_Load2)) ;size +L0812_Load2: + call ParseMap + ret + +L0812_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0812_Map: +INCBIN "Data/Levels/L0812_warp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0812_Init: + DW ((L0812_InitFinished - L0812_Init2)) ;size +L0812_Init2: + ld a,[bgTileMap + FIREINDEX] + ld [levelVars + VAR_FIRE],a + ret + +L0812_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0812_Check: + DW ((L0812_CheckFinished - L0812_Check2)) ;size +L0812_Check2: + call ((.animateFire-L0812_Check2)+levelCheckRAM) + ret + +.animateFire + ldio a,[updateTimer] + rrca + rrca + and %11 + ld hl,levelVars + VAR_FIRE + add [hl] + ld [bgTileMap + FIREINDEX],a + ret + +L0812_CheckFinished: +PRINT "0812 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0812_LoadFinished - L0812_Load2) +PRINT " / " +PRINT (L0812_InitFinished - L0812_Init2) +PRINT " / " +PRINT (L0812_CheckFinished - L0812_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0900.asm b/Source/Levels/L0900.asm new file mode 100644 index 0000000..c135a53 --- /dev/null +++ b/Source/Levels/L0900.asm @@ -0,0 +1,71 @@ +; L0900.asm Crouton Guard Post +; Generated 01.03.1980 by mlevel +; Modified 01.03.1980 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0900Section",ROMX +;--------------------------------------------------------------------- + +L0900_Contents:: + DW L0900_Load + DW L0900_Init + DW L0900_Check + DW L0900_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0900_Load: + DW ((L0900_LoadFinished - L0900_Load2)) ;size +L0900_Load2: + call ParseMap + ret + +L0900_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0900_Map: +INCBIN "Data/Levels/L0900_guardpost.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0900_Init: + DW ((L0900_InitFinished - L0900_Init2)) ;size +L0900_Init2: + call UseAlternatePalette + ld a,ENV_SNOW + call SetEnvEffect + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld bc,ITEM_CODE0900 + call RemoveClearanceIfTaken + ret + +L0900_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0900_Check: + DW ((L0900_CheckFinished - L0900_Check2)) ;size +L0900_Check2: + ret + +L0900_CheckFinished: +PRINT "0900 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0900_LoadFinished - L0900_Load2) +PRINT " / " +PRINT (L0900_InitFinished - L0900_Init2) +PRINT " / " +PRINT (L0900_CheckFinished - L0900_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0901.asm b/Source/Levels/L0901.asm new file mode 100644 index 0000000..879a1cd --- /dev/null +++ b/Source/Levels/L0901.asm @@ -0,0 +1,95 @@ +; L0901.asm +; Generated 01.03.1980 by mlevel +; Modified 01.03.1980 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +HFENCE_INDEX EQU 35 +VFENCE_INDEX EQU 39 +VAR_HFENCE EQU 0 +VAR_VFENCE EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level0901Section",ROMX +;--------------------------------------------------------------------- + +L0901_Contents:: + DW L0901_Load + DW L0901_Init + DW L0901_Check + DW L0901_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0901_Load: + DW ((L0901_LoadFinished - L0901_Load2)) ;size +L0901_Load2: + call ParseMap + ret + +L0901_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0901_Map: +INCBIN "Data/Levels/L0901_slavecamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0901_Init: + DW ((L0901_InitFinished - L0901_Init2)) ;size +L0901_Init2: + ld a,[bgTileMap+HFENCE_INDEX] + ld [levelVars + VAR_HFENCE],a + ld a,[bgTileMap+VFENCE_INDEX] + ld [levelVars + VAR_VFENCE],a + ret + +L0901_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0901_Check: + DW ((L0901_CheckFinished - L0901_Check2)) ;size +L0901_Check2: + call ((.animateFence-L0901_Check2)+levelCheckRAM) + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+HFENCE_INDEX + ld a,[levelVars+VAR_HFENCE] + ld d,a + call ((.animateFourFrames-L0901_Check2)+levelCheckRAM) + ld a,[levelVars+VAR_VFENCE] + ld d,a + jp ((.animateFourFrames-L0901_Check2)+levelCheckRAM) + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + +L0901_CheckFinished: +PRINT "0901 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0901_LoadFinished - L0901_Load2) +PRINT " / " +PRINT (L0901_InitFinished - L0901_Init2) +PRINT " / " +PRINT (L0901_CheckFinished - L0901_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0902.asm b/Source/Levels/L0902.asm new file mode 100644 index 0000000..212839a --- /dev/null +++ b/Source/Levels/L0902.asm @@ -0,0 +1,99 @@ +; L0902.asm Ice Plain Landing +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 70 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0902Section",ROMX +;--------------------------------------------------------------------- + +L0902_Contents:: + DW L0902_Load + DW L0902_Init + DW L0902_Check + DW L0902_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0902_Load: + DW ((L0902_LoadFinished - L0902_Load2)) ;size +L0902_Load2: + call ParseMap + ret + +L0902_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0902_Map: +INCBIN "Data/Levels/L0902_iceplainland.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0902_Init: + DW ((L0902_InitFinished - L0902_Init2)) ;size +L0902_Init2: + call UseAlternatePalette + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + ld a,ENV_SNOW + call SetEnvEffect + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + ret + +L0902_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0902_Check: + DW ((L0902_CheckFinished - L0902_Check2)) ;size +L0902_Check2: + call ((.animateLandingLights-L0902_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0902_Check2)+levelCheckRAM) + call ((.animateLight-L0902_Check2)+levelCheckRAM) + call ((.animateLight-L0902_Check2)+levelCheckRAM) + call ((.animateLight-L0902_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0902_CheckFinished: +PRINT "0902 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0902_LoadFinished - L0902_Load2) +PRINT " / " +PRINT (L0902_InitFinished - L0902_Init2) +PRINT " / " +PRINT (L0902_CheckFinished - L0902_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0903.asm b/Source/Levels/L0903.asm new file mode 100644 index 0000000..949f86c --- /dev/null +++ b/Source/Levels/L0903.asm @@ -0,0 +1,59 @@ +; L0903.asm +; Generated 01.03.1980 by mlevel +; Modified 01.03.1980 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0903Section",ROMX +;--------------------------------------------------------------------- + +L0903_Contents:: + DW L0903_Load + DW L0903_Init + DW L0903_Check + DW L0903_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0903_Load: + DW ((L0903_LoadFinished - L0903_Load2)) ;size +L0903_Load2: + call ParseMap + ret + +L0903_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0903_Map: +INCBIN "Data/Levels/L0903_cornville.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0903_Init: + DW ((L0903_InitFinished - L0903_Init2)) ;size +L0903_Init2: + ret + +L0903_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0903_Check: + DW ((L0903_CheckFinished - L0903_Check2)) ;size +L0903_Check2: + ret + +L0903_CheckFinished: +PRINT "0903 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0903_LoadFinished - L0903_Load2) +PRINT " / " +PRINT (L0903_InitFinished - L0903_Init2) +PRINT " / " +PRINT (L0903_CheckFinished - L0903_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0904.asm b/Source/Levels/L0904.asm new file mode 100644 index 0000000..a23ef19 --- /dev/null +++ b/Source/Levels/L0904.asm @@ -0,0 +1,59 @@ +; L0904.asm +; Generated 09.18.2000 by mlevel +; Modified 09.18.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0904Section",ROMX +;--------------------------------------------------------------------- + +L0904_Contents:: + DW L0904_Load + DW L0904_Init + DW L0904_Check + DW L0904_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0904_Load: + DW ((L0904_LoadFinished - L0904_Load2)) ;size +L0904_Load2: + call ParseMap + ret + +L0904_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0904_Map: +INCBIN "Data/Levels/L0904_canyon.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0904_Init: + DW ((L0904_InitFinished - L0904_Init2)) ;size +L0904_Init2: + ret + +L0904_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0904_Check: + DW ((L0904_CheckFinished - L0904_Check2)) ;size +L0904_Check2: + ret + +L0904_CheckFinished: +PRINT "0904 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0904_LoadFinished - L0904_Load2) +PRINT " / " +PRINT (L0904_InitFinished - L0904_Init2) +PRINT " / " +PRINT (L0904_CheckFinished - L0904_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0905.asm b/Source/Levels/L0905.asm new file mode 100644 index 0000000..6e00718 --- /dev/null +++ b/Source/Levels/L0905.asm @@ -0,0 +1,93 @@ +; L0905.asm monkey landing +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 41 +VAR_LIGHT EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level0905Section",ROMX +;--------------------------------------------------------------------- + +L0905_Contents:: + DW L0905_Load + DW L0905_Init + DW L0905_Check + DW L0905_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0905_Load: + DW ((L0905_LoadFinished - L0905_Load2)) ;size +L0905_Load2: + call ParseMap + ret + +L0905_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0905_Map: +INCBIN "Data/Levels/L0905_junglelanding.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0905_Init: + DW ((L0905_InitFinished - L0905_Init2)) ;size +L0905_Init2: + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + ret + +L0905_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0905_Check: + DW ((L0905_CheckFinished - L0905_Check2)) ;size +L0905_Check2: + call ((.animateLandingLights-L0905_Check2)+levelCheckRAM) + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L0905_Check2)+levelCheckRAM) + call ((.animateLight-L0905_Check2)+levelCheckRAM) + call ((.animateLight-L0905_Check2)+levelCheckRAM) + call ((.animateLight-L0905_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L0905_CheckFinished: +PRINT "0905 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0905_LoadFinished - L0905_Load2) +PRINT " / " +PRINT (L0905_InitFinished - L0905_Init2) +PRINT " / " +PRINT (L0905_CheckFinished - L0905_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0906.asm b/Source/Levels/L0906.asm new file mode 100644 index 0000000..70aff35 --- /dev/null +++ b/Source/Levels/L0906.asm @@ -0,0 +1,62 @@ +; L0906.asm +; Generated 10.29.2000 by mlevel +; Modified 10.29.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0906Section",ROMX +;--------------------------------------------------------------------- + +L0906_Contents:: + DW L0906_Load + DW L0906_Init + DW L0906_Check + DW L0906_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0906_Load: + DW ((L0906_LoadFinished - L0906_Load2)) ;size +L0906_Load2: + call ParseMap + ret + +L0906_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0906_Map: +INCBIN "Data/Levels/L0906_stone_wisp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0906_Init: + DW ((L0906_InitFinished - L0906_Init2)) ;size +L0906_Init2: + ld a,BANK(mysterious_gbm) + ld hl,mysterious_gbm + call InitMusic + ret + +L0906_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0906_Check: + DW ((L0906_CheckFinished - L0906_Check2)) ;size +L0906_Check2: + ret + +L0906_CheckFinished: +PRINT "0906 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0906_LoadFinished - L0906_Load2) +PRINT " / " +PRINT (L0906_InitFinished - L0906_Init2) +PRINT " / " +PRINT (L0906_CheckFinished - L0906_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0907.asm b/Source/Levels/L0907.asm new file mode 100644 index 0000000..c71235e --- /dev/null +++ b/Source/Levels/L0907.asm @@ -0,0 +1,62 @@ +; L0907.asm bullseye village +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0907Section",ROMX +;--------------------------------------------------------------------- + +L0907_Contents:: + DW L0907_Load + DW L0907_Init + DW L0907_Check + DW L0907_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0907_Load: + DW ((L0907_LoadFinished - L0907_Load2)) ;size +L0907_Load2: + call ParseMap + ret + +L0907_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0907_Map: +INCBIN "Data/Levels/L0907_bullseye.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0907_Init: + DW ((L0907_InitFinished - L0907_Init2)) ;size +L0907_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L0907_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0907_Check: + DW ((L0907_CheckFinished - L0907_Check2)) ;size +L0907_Check2: + ret + +L0907_CheckFinished: +PRINT "0907 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0907_LoadFinished - L0907_Load2) +PRINT " / " +PRINT (L0907_InitFinished - L0907_Init2) +PRINT " / " +PRINT (L0907_CheckFinished - L0907_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0908.asm b/Source/Levels/L0908.asm new file mode 100644 index 0000000..dbee365 --- /dev/null +++ b/Source/Levels/L0908.asm @@ -0,0 +1,62 @@ +; L0908.asm +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0908Section",ROMX +;--------------------------------------------------------------------- + +L0908_Contents:: + DW L0908_Load + DW L0908_Init + DW L0908_Check + DW L0908_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0908_Load: + DW ((L0908_LoadFinished - L0908_Load2)) ;size +L0908_Load2: + call ParseMap + ret + +L0908_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0908_Map: +INCBIN "Data/Levels/L0908_warzone.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0908_Init: + DW ((L0908_InitFinished - L0908_Init2)) ;size +L0908_Init2: + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + ret + +L0908_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0908_Check: + DW ((L0908_CheckFinished - L0908_Check2)) ;size +L0908_Check2: + ret + +L0908_CheckFinished: +PRINT "0908 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0908_LoadFinished - L0908_Load2) +PRINT " / " +PRINT (L0908_InitFinished - L0908_Init2) +PRINT " / " +PRINT (L0908_CheckFinished - L0908_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0909.asm b/Source/Levels/L0909.asm new file mode 100644 index 0000000..f0c3d73 --- /dev/null +++ b/Source/Levels/L0909.asm @@ -0,0 +1,59 @@ +; L0909.asm +; Generated 11.01.2000 by mlevel +; Modified 11.01.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level0909Section",ROMX +;--------------------------------------------------------------------- + +L0909_Contents:: + DW L0909_Load + DW L0909_Init + DW L0909_Check + DW L0909_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0909_Load: + DW ((L0909_LoadFinished - L0909_Load2)) ;size +L0909_Load2: + call ParseMap + ret + +L0909_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0909_Map: +INCBIN "Data/Levels/L0909_warzone.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0909_Init: + DW ((L0909_InitFinished - L0909_Init2)) ;size +L0909_Init2: + ret + +L0909_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0909_Check: + DW ((L0909_CheckFinished - L0909_Check2)) ;size +L0909_Check2: + ret + +L0909_CheckFinished: +PRINT "0909 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0909_LoadFinished - L0909_Load2) +PRINT " / " +PRINT (L0909_InitFinished - L0909_Init2) +PRINT " / " +PRINT (L0909_CheckFinished - L0909_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0910.asm b/Source/Levels/L0910.asm new file mode 100644 index 0000000..3a041d9 --- /dev/null +++ b/Source/Levels/L0910.asm @@ -0,0 +1,78 @@ +; L0910.asm +; Generated 11.05.2000 by mlevel +; Modified 11.05.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level0910Section",ROMX +;--------------------------------------------------------------------- + +L0910_Contents:: + DW L0910_Load + DW L0910_Init + DW L0910_Check + DW L0910_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0910_Load: + DW ((L0910_LoadFinished - L0910_Load2)) ;size +L0910_Load2: + call ParseMap + ret + +L0910_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0910_Map: +INCBIN "Data/Levels/L0910_warzone.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0910_Init: + DW ((L0910_InitFinished - L0910_Init2)) ;size +L0910_Init2: + ;make gun turrets friendly + ld bc,classTurret + call FindClassIndex + ld c,a + call GetFirst + + ld b,5 +.setNext + call ((.setGroup-L0910_Init2)+levelCheckRAM) + dec b + jr nz,.setNext + + ret + +.setGroup + ld a,GROUP_HERO + call SetGroup + call GetNextObject + ret + +L0910_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0910_Check: + DW ((L0910_CheckFinished - L0910_Check2)) ;size +L0910_Check2: + ret + +L0910_CheckFinished: +PRINT "0910 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0910_LoadFinished - L0910_Load2) +PRINT " / " +PRINT (L0910_InitFinished - L0910_Init2) +PRINT " / " +PRINT (L0910_CheckFinished - L0910_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0911.asm b/Source/Levels/L0911.asm new file mode 100644 index 0000000..f32f833 --- /dev/null +++ b/Source/Levels/L0911.asm @@ -0,0 +1,172 @@ +; L0911.asm apocalypse NE goblin module +; Generated 04.26.2001 by mlevel +; Modified 04.26.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_DEFUSED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0911Section",ROMX +;--------------------------------------------------------------------- + +L0911_Contents:: + DW L0911_Load + DW L0911_Init + DW L0911_Check + DW L0911_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0911_Load: + DW ((L0911_LoadFinished - L0911_Load2)) ;size +L0911_Load2: + call ParseMap + ret + +L0911_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0911_Map: +INCBIN "Data/Levels/L0911_ssa_ne.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0911_Init: + DW ((L0911_InitFinished - L0911_Init2)) ;size +L0911_Init2: + ld a,BANK(L0012_defused_gtx) + ld [dialogBank],a + call SetPressBDialog + + ldio a,[mapState] + cp STATE_DEFUSED + jr nz,.afterRemoveBomb + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d091 + ld [hl+],a + ld [hl],a + ld hl,$d0b1 + ld [hl+],a + ld [hl],a +.afterRemoveBomb + ret + +L0911_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0911_Check: + DW ((L0911_CheckFinished - L0911_Check2)) ;size +L0911_Check2: + call ((.checkAtBomb-L0911_Check2)+levelCheckRAM) + ret + +.checkAtBomb + ldio a,[mapState] + cp STATE_DEFUSED + ret z + + ld hl,((.checkHeroAtBomb-L0911_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtBomb + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atBomb + + xor a + ret + +.atBomb + ld a,STATE_DEFUSED + ldio [mapState],a + + call UpdateState + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d091 + ld [hl+],a + ld [hl],a + ld hl,$d0b1 + ld [hl+],a + ld [hl],a + + ;check all defused + ld d,0 + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$b8] + cp 2 + jr nz,.check2 + inc d +.check2 + ld a,[levelState+$b9] + cp 2 + jr nz,.check3 + inc d +.check3 + ld a,[levelState+$ba] + cp 2 + jr nz,.check4 + inc d +.check4 + ld a,[levelState+$bb] + cp 2 + jr nz,.checkTotal + inc d +.checkTotal + ;if 3 bombs were defused before this one then that's all + ld a,d + cp 3 + jr nz,.bombsRemain + + ld hl,L0012_alldefused_gtx + jr .dialog + +.bombsRemain + ld hl,L0012_defused_gtx + +.dialog + call MakeIdle + ld de,((.afterDialog-L0911_Check2)+levelCheckRAM) + call SetDialogSkip + + ld d,h + ld e,l + + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ret + +L0911_CheckFinished: +PRINT "0911 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0911_LoadFinished - L0911_Load2) +PRINT " / " +PRINT (L0911_InitFinished - L0911_Init2) +PRINT " / " +PRINT (L0911_CheckFinished - L0911_Check2) +PRINT "\n" + diff --git a/Source/Levels/L0912.asm b/Source/Levels/L0912.asm new file mode 100644 index 0000000..a9cf5f2 --- /dev/null +++ b/Source/Levels/L0912.asm @@ -0,0 +1,371 @@ +; L0912.asm monkey homeworld +; Generated 04.09.2001 by mlevel +; Modified 04.09.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +CROUTON_INDEX EQU 95 +ORANGE_INDEX EQU 98 + +VAR_SAWSIGN EQU 0 +VAR_TALKED EQU 1 +VAR_TALKEDTELEPORT EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level0912Section",ROMX +;--------------------------------------------------------------------- +dialog: +L0912_sign_gtx: + INCBIN "Data/Dialog/Talk/L0912_sign.gtx" + +L0912_welcome_gtx: + INCBIN "Data/Dialog/Talk/L0912_welcome.gtx" + +L0912_hero_revolt_gtx: + INCBIN "Data/Dialog/Talk/L0912_hero_revolt.gtx" + +L0912_justit_gtx: + INCBIN "Data/Dialog/Talk/L0912_justit.gtx" + +L0912_hero_losing_gtx: + INCBIN "Data/Dialog/Talk/L0912_hero_losing.gtx" + +L0912_killpatsy_gtx: + INCBIN "Data/Dialog/Talk/L0912_killpatsy.gtx" + +L0912_hero_brokenteleport_gtx: + INCBIN "Data/Dialog/Talk/L0912_hero_brokenteleport.gtx" + +L0912_hero_startteleport_nopassword_gtx: + INCBIN "Data/Dialog/Talk/L0912_hero_startteleport_nopassword.gtx" + +L0912_needpassword_gtx: + INCBIN "Data/Dialog/Talk/L0912_needpassword.gtx" + +L0912_hero_startteleport_password_gtx: + INCBIN "Data/Dialog/Talk/L0912_hero_startteleport_password.gtx" + +L0912_ba_givepassword_gtx: + INCBIN "Data/Dialog/Talk/L0912_ba_givepassword.gtx" + +L0912_Contents:: + DW L0912_Load + DW L0912_Init + DW L0912_Check + DW L0912_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L0912_Load: + DW ((L0912_LoadFinished - L0912_Load2)) ;size +L0912_Load2: + call ParseMap + ret + +L0912_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L0912_Map: +INCBIN "Data/Levels/L0912_monkeyworld.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L0912_Init: + DW ((L0912_InitFinished - L0912_Init2)) ;size +L0912_Init2: + ld hl,$0912 + call SetJoinMap + call SetRespawnMap + + STDSETUPDIALOG + + ld a,BANK(jungle_gbm) + ld hl,jungle_gbm + call InitMusic + + xor a + ld [levelVars+VAR_SAWSIGN],a + ld [levelVars+VAR_TALKED],a + ld [levelVars+VAR_TALKEDTELEPORT],a + + ld bc,classGeneric + ld de,classTalker + call ChangeClass + + ld a,ORANGE_INDEX + ld [dialogBalloonClassIndex],a + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cb] ;shot orange guy? + cp 2 + jr nz,.done + + ;revolt averted + ;monkeys & croutons friends + ld b,GROUP_MONSTERD + ld c,GROUP_MONSTERA + ld a,1 + call SetFOF + + ;monkeys & heroes friends + ld c,GROUP_HERO + ld a,1 + call SetFOF + + ld bc,classMonkey + ld de,classGeneric + call ChangeClass + + ;orange guy doesn't speak + ld a,1 + call DisableDialogBalloons + +.done + ret + +L0912_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L0912_Check: + DW ((L0912_CheckFinished - L0912_Check2)) ;size +L0912_Check2: + call ((.checkSign-L0912_Check2)+levelCheckRAM) + call ((.checkDialog-L0912_Check2)+levelCheckRAM) + call ((.checkTeleport-L0912_Check2)+levelCheckRAM) + ret + +.checkTeleport + ld a,[levelVars+VAR_TALKEDTELEPORT] + or a + ret nz + + ld hl,((.checkHeroAtTeleport-L0912_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtTeleport + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atTeleport + + xor a + ret + +.atTeleport + ld a,1 + ld [levelVars+VAR_TALKEDTELEPORT],a + call MakeIdle + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cb] ;shot orange guy? + cp 2 + jp nz,((.brokenTeleport-L0912_Check2)+levelCheckRAM) + + ;fixed teleport. Separate for BA + ld a,HERO_BA_FLAG + call ClassIndexIsHeroType + jr nz,.baTeleport + + ;has password? + ld a,[levelState+$ca] ;read book in monkey library? + cp 2 + jr z,.hasPassword + + ;push bc + ;ld bc,ITEM_MONKEYPASSWD + ;call HasInventoryItem + ;pop bc + ;jr nz,.hasPassword + + ;no password + ld de,((.afterNoPasswordDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0912_hero_startteleport_nopassword_gtx + call ShowDialogAtBottom + call ClearDialog + + push bc + ld c,CROUTON_INDEX + ld de,L0912_needpassword_gtx + call ShowDialogAtTop + pop bc + +.afterNoPasswordDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ret + +.hasPassword + ld de,((.afterHasPasswordDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0912_hero_startteleport_password_gtx + call ShowDialogAtBottom + +.afterHasPasswordDialog + jr .activateTeleport + +.baTeleport + ld de,((.afterBATeleportDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0912_hero_startteleport_nopassword_gtx + call ShowDialogAtBottom + + push bc + ld c,CROUTON_INDEX + ld de,L0912_needpassword_gtx + call ShowDialogAtBottom + pop bc + + call SetSpeakerFromHeroIndex + ld de,L0912_ba_givepassword_gtx + call ShowDialogAtBottom +.afterBATeleportDialog + +.activateTeleport + call ClearDialog + call MakeNonIdle + + ;ld a,15 + ;call SetupFadeFromWhite + + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1212 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + + ld a,1 + ld [timeToChangeLevel],a + + ld a,1 + ret + +.brokenTeleport + ld de,((.afterTeleportDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0912_hero_brokenteleport_gtx + call ShowDialogAtBottom + +.afterTeleportDialog + call ClearDialog + call MakeNonIdle + + ld a,1 + ret + +.checkSign + ld a,[levelVars+VAR_SAWSIGN] + or a + ret nz + + ld hl,((.checkHeroAtSign-L0912_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtSign + ld c,a + call GetFirst + call GetCurZone + cp 3 + jr z,.atSign + + xor a + ret + +.atSign + ld a,1 + ld [levelVars+VAR_SAWSIGN],a + call MakeIdle + + ld de,((.afterSignDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L0912_sign_gtx + call ShowDialogAtBottom + +.afterSignDialog + call ClearDialog + call MakeNonIdle + + ld a,1 + ret + +.checkDialog + ld hl,levelVars+VAR_TALKED + ld a,[hl] + or a + ret nz + +.dialogOkay + ld a,[dialogNPC_speakerIndex] + or a + ret z + + ld [hl],1 ;talked + call MakeIdle + + ld de,((.afterDialog-L0912_Check2)+levelCheckRAM) + call SetDialogSkip + + ld de,L0912_welcome_gtx + call ShowDialogNPC + + ld de,L0912_hero_revolt_gtx + call ShowDialogHero + + ld de,L0912_justit_gtx + call ShowDialogNPC + + ld de,L0912_hero_losing_gtx + call ShowDialogHero + + ld de,L0912_killpatsy_gtx + call ShowDialogNPC + +.afterDialog + call ClearDialog + + call MakeNonIdle + + xor a + ld [dialogNPC_speakerIndex],a + ret + + +L0912_CheckFinished: +PRINT "0912 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L0912_LoadFinished - L0912_Load2) +PRINT " / " +PRINT (L0912_InitFinished - L0912_Init2) +PRINT " / " +PRINT (L0912_CheckFinished - L0912_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1000.asm b/Source/Levels/L1000.asm new file mode 100644 index 0000000..26865a9 --- /dev/null +++ b/Source/Levels/L1000.asm @@ -0,0 +1,447 @@ +; L1000.asm crouton base camp landing +; Generated 01.02.1998 by mlevel +; Modified 01.02.1998 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 79 +DICEINDEX EQU 87 +HFENCE_INDEX EQU 97 +VFENCE_INDEX EQU 101 +GYRO_INDEX EQU 109 + +VAR_HFENCE EQU 0 +VAR_VFENCE EQU 1 +VAR_LIGHT EQU 2 +VAR_DICELIGHT EQU 3 +VAR_EXPLODEDGATE EQU 4 ;used in Class.asm +VAR_TALKED EQU 5 +VAR_SPEAKER EQU 6 + +STATE_GATECLOSED EQU 1 +STATE_WAITGYRO EQU 2 +STATE_NORMAL EQU 3 + + +;--------------------------------------------------------------------- +SECTION "Level1000Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1000_needbomb_gtx: + INCBIN "Data/Dialog/Talk/L1000_needbomb.gtx" + +L1000_freeze_gtx: + INCBIN "Data/Dialog/Talk/L1000_freeze.gtx" + +L1000_toolate_gtx: + INCBIN "Data/Dialog/Talk/L1000_toolate.gtx" + +L1000_follow_gtx: + INCBIN "Data/Dialog/Talk/L1000_follow.gtx" + +L1000_Contents:: + DW L1000_Load + DW L1000_Init + DW L1000_Check + DW L1000_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1000_Load: + DW ((L1000_LoadFinished - L1000_Load2)) ;size +L1000_Load2: + call ParseMap + ret + +L1000_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1000_Map: +INCBIN "Data/Levels/L1000_basecamp.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1000_Init: + DW ((L1000_InitFinished - L1000_Init2)) ;size +L1000_Init2: + ld a,[bgTileMap+HFENCE_INDEX] + ld [levelVars + VAR_HFENCE],a + ld a,[bgTileMap+VFENCE_INDEX] + ld [levelVars + VAR_VFENCE],a + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + ld a,[bgTileMap+DICEINDEX] ;tile index of first light + ld [levelVars+VAR_DICELIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + + STDSETUPDIALOG + + xor a + ld [levelVars+VAR_TALKED],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + xor a + ld [levelVars+VAR_EXPLODEDGATE],a + + call State0To1 + + ldio a,[mapState] + cp STATE_WAITGYRO + call nc,((.removeGate-L1000_Init2)+levelCheckRAM) + ldio a,[mapState] + cp STATE_NORMAL + call z,((.removeGyro-L1000_Init2)+levelCheckRAM) + ret + +.removeGate + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d24e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld hl,$d26e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld hl,$d28e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ret + +.removeGyro + ld a,MAPBANK + ldio [$ff70],a + xor a + ;remove space ship + ld hl,$d04f + ld [hl+],a + ld [hl+],a + ld hl,$d06f + ld [hl+],a + ld [hl+],a + + ;remove Gyro + ld bc,classGeneralGyro + call DeleteObjectsOfClass + ret + +L1000_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1000_Check: + DW ((L1000_CheckFinished - L1000_Check2)) ;size +L1000_Check2: + call ((.animateFence-L1000_Check2)+levelCheckRAM) + call ((.animateLandingLights-L1000_Check2)+levelCheckRAM) + call ((.animateDiceLights-L1000_Check2)+levelCheckRAM) + call ((.checkDialog-L1000_Check2)+levelCheckRAM) + call ((.checkConfrontGyro-L1000_Check2)+levelCheckRAM) + + ldio a,[mapState] + cp STATE_GATECLOSED + jr nz,.done + + call ((.checkOpenGate-L1000_Check2)+levelCheckRAM) + +.done + ret + +.checkConfrontGyro + ldio a,[mapState] + cp STATE_WAITGYRO ;exploded gate? + ret nz + + ld hl,((.checkHeroConfront-L1000_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroConfront + ld c,a + ld [levelVars+VAR_SPEAKER],a + call GetFirst + call GetCurZone + cp 5 + jr z,.inConfrontZone + + xor a + ret + +.inConfrontZone + call MakeIdle + + ld de,((.afterConfrontDialog-L1000_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L1000_freeze_gtx + call ShowDialogAtBottom + + call ClearDialog + ld de,L1000_toolate_gtx + ld c,GYRO_INDEX + call ShowDialogAtTop + + call ClearDialog + ld a,15 + call Delay + + ld bc,classGeneralGyro + call DeleteObjectsOfClass + + ld a,15 + call Delay + + ld a,30 + ldio [jiggleDuration],a + + ld a,15 + call Delay + + ;clear ship + ld a,MAPBANK + ldio [$ff70],a + + xor a + ld hl,$d04f + ld [hl+],a + ld [hl+],a + ld hl,$d06f + ld [hl+],a + ld [hl+],a + + ld a,15 + call Delay + + ld a,[levelVars+VAR_SPEAKER] + ld c,a + ld de,L1000_follow_gtx + call ShowDialogAtBottom + +.afterConfrontDialog + ld bc,classGeneralGyro + call DeleteObjectsOfClass + + ;clear ship + ld a,MAPBANK + ldio [$ff70],a + + xor a + ld hl,$d04f + ld [hl+],a + ld [hl+],a + ld hl,$d06f + ld [hl+],a + ld [hl+],a + + call ClearDialogSkipForward + call MakeNonIdle + + ld hl,$1104 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ld a,STATE_NORMAL + ldio [mapState],a + + ld a,1 + ret + +.checkDialog + ld a,[levelVars+VAR_TALKED] + or a + ret nz + + ldio a,[mapState] + cp STATE_WAITGYRO ;exploded gate? + ret nc + + ld hl,((.checkHeroInZone-L1000_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroInZone + ld c,a + call GetFirst + call GetCurZone + cp 4 + jr z,.inZone + + xor a + ret + +.inZone + call MakeIdle + + ld de,((.afterDialog-L1000_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L1000_needbomb_gtx + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ld [levelVars+VAR_TALKED],a + + ld a,1 + ret + +.checkOpenGate + ld a,[levelVars+VAR_EXPLODEDGATE] + or a + ret z + + ld bc,$0403 + ld de,$1407 + ld hl,$d24e + call CreateBigExplosion + ld hl,bigExplosionSound + call PlaySound + + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d24e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld hl,$d26e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld hl,$d28e + ld [hl+],a + ld [hl+],a + ld [hl+],a + ld [hl+],a + + ld a,STATE_WAITGYRO + ldio [mapState],a + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+HFENCE_INDEX + ld a,[levelVars+VAR_HFENCE] + ld d,a + call ((.animateFourFrames-L1000_Check2)+levelCheckRAM) + ld a,[levelVars+VAR_VFENCE] + ld d,a + jp ((.animateFourFrames-L1000_Check2)+levelCheckRAM) + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L1000_Check2)+levelCheckRAM) + call ((.animateLight-L1000_Check2)+levelCheckRAM) + call ((.animateLight-L1000_Check2)+levelCheckRAM) + call ((.animateLight-L1000_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +.animateDiceLights + ;animate dice lights + ld a,[levelVars+VAR_DICELIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+DICEINDEX + call ((.updateTwoLights - L1000_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L1000_Check2) + levelCheckRAM) + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L1000_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +L1000_CheckFinished: +PRINT "1000 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1000_LoadFinished - L1000_Load2) +PRINT " / " +PRINT (L1000_InitFinished - L1000_Init2) +PRINT " / " +PRINT (L1000_CheckFinished - L1000_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1001.asm b/Source/Levels/L1001.asm new file mode 100644 index 0000000..551b3fa --- /dev/null +++ b/Source/Levels/L1001.asm @@ -0,0 +1,65 @@ +; L1001.asm +; Generated 11.13.2000 by mlevel +; Modified 11.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1001Section",ROMX +;--------------------------------------------------------------------- + +L1001_Contents:: + DW L1001_Load + DW L1001_Init + DW L1001_Check + DW L1001_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1001_Load: + DW ((L1001_LoadFinished - L1001_Load2)) ;size +L1001_Load2: + call ParseMap + ret + +L1001_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1001_Map: +INCBIN "Data/Levels/L1001_iceplain.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1001_Init: + DW ((L1001_InitFinished - L1001_Init2)) ;size +L1001_Init2: + call UseAlternatePalette + ld a,ENV_SNOW + call SetEnvEffect + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + ret + +L1001_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1001_Check: + DW ((L1001_CheckFinished - L1001_Check2)) ;size +L1001_Check2: + ret + +L1001_CheckFinished: +PRINT "1001 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1001_LoadFinished - L1001_Load2) +PRINT " / " +PRINT (L1001_InitFinished - L1001_Init2) +PRINT " / " +PRINT (L1001_CheckFinished - L1001_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1002.asm b/Source/Levels/L1002.asm new file mode 100644 index 0000000..15526fc --- /dev/null +++ b/Source/Levels/L1002.asm @@ -0,0 +1,70 @@ +; L1002.asm +; Generated 01.02.1998 by mlevel +; Modified 01.02.1998 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1002Section",ROMX +;--------------------------------------------------------------------- + +L1002_Contents:: + DW L1002_Load + DW L1002_Init + DW L1002_Check + DW L1002_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1002_Load: + DW ((L1002_LoadFinished - L1002_Load2)) ;size +L1002_Load2: + call ParseMap + ret + +L1002_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1002_Map: +INCBIN "Data/Levels/L1002_guardpost.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1002_Init: + DW ((L1002_InitFinished - L1002_Init2)) ;size +L1002_Init2: + call UseAlternatePalette + ld a,ENV_SNOW + call SetEnvEffect + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld bc,ITEM_CODE1002 + call RemoveClearanceIfTaken + ret + +L1002_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1002_Check: + DW ((L1002_CheckFinished - L1002_Check2)) ;size +L1002_Check2: + ret + +L1002_CheckFinished: +PRINT "1002 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1002_LoadFinished - L1002_Load2) +PRINT " / " +PRINT (L1002_InitFinished - L1002_Init2) +PRINT " / " +PRINT (L1002_CheckFinished - L1002_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1003.asm b/Source/Levels/L1003.asm new file mode 100644 index 0000000..6330fae --- /dev/null +++ b/Source/Levels/L1003.asm @@ -0,0 +1,108 @@ +; L1003.asm beach +; Generated 01.03.1980 by mlevel +; Modified 01.03.1980 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 42 +VAR_WATER EQU 0 +LIGHTINDEX EQU 64 +VAR_LIGHT EQU 1 + +;--------------------------------------------------------------------- +SECTION "Level1003Section",ROMX +;--------------------------------------------------------------------- + +L1003_Contents:: + DW L1003_Load + DW L1003_Init + DW L1003_Check + DW L1003_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1003_Load: + DW ((L1003_LoadFinished - L1003_Load2)) ;size +L1003_Load2: + call ParseMap + ret + +L1003_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1003_Map: +INCBIN "Data/Levels/L1003_beach.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1003_Init: + DW ((L1003_InitFinished - L1003_Init2)) ;size +L1003_Init2: + call UseAlternatePalette + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + LONGCALLNOARGS AddAppomattoxIfPresent + ret + +L1003_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1003_Check: + DW ((L1003_CheckFinished - L1003_Check2)) ;size +L1003_Check2: + call ((.animateWater-L1003_Check2)+levelCheckRAM) + call ((.animateLandingLights-L1003_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L1003_Check2)+levelCheckRAM) + call ((.animateLight-L1003_Check2)+levelCheckRAM) + call ((.animateLight-L1003_Check2)+levelCheckRAM) + call ((.animateLight-L1003_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + +L1003_CheckFinished: +PRINT "1003 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1003_LoadFinished - L1003_Load2) +PRINT " / " +PRINT (L1003_InitFinished - L1003_Init2) +PRINT " / " +PRINT (L1003_CheckFinished - L1003_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1004.asm b/Source/Levels/L1004.asm new file mode 100644 index 0000000..6edfadb --- /dev/null +++ b/Source/Levels/L1004.asm @@ -0,0 +1,59 @@ +; L1004.asm +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1004Section",ROMX +;--------------------------------------------------------------------- + +L1004_Contents:: + DW L1004_Load + DW L1004_Init + DW L1004_Check + DW L1004_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1004_Load: + DW ((L1004_LoadFinished - L1004_Load2)) ;size +L1004_Load2: + call ParseMap + ret + +L1004_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1004_Map: +INCBIN "Data/Levels/L1004_pumpkins.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1004_Init: + DW ((L1004_InitFinished - L1004_Init2)) ;size +L1004_Init2: + ret + +L1004_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1004_Check: + DW ((L1004_CheckFinished - L1004_Check2)) ;size +L1004_Check2: + ret + +L1004_CheckFinished: +PRINT "1004 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1004_LoadFinished - L1004_Load2) +PRINT " / " +PRINT (L1004_InitFinished - L1004_Init2) +PRINT " / " +PRINT (L1004_CheckFinished - L1004_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1005.asm b/Source/Levels/L1005.asm new file mode 100644 index 0000000..4e030db --- /dev/null +++ b/Source/Levels/L1005.asm @@ -0,0 +1,59 @@ +; L1005.asm +; Generated 09.06.2000 by mlevel +; Modified 09.06.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1005Section",ROMX +;--------------------------------------------------------------------- + +L1005_Contents:: + DW L1005_Load + DW L1005_Init + DW L1005_Check + DW L1005_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1005_Load: + DW ((L1005_LoadFinished - L1005_Load2)) ;size +L1005_Load2: + call ParseMap + ret + +L1005_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1005_Map: +INCBIN "Data/Levels/L1005_autumn.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1005_Init: + DW ((L1005_InitFinished - L1005_Init2)) ;size +L1005_Init2: + ret + +L1005_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1005_Check: + DW ((L1005_CheckFinished - L1005_Check2)) ;size +L1005_Check2: + ret + +L1005_CheckFinished: +PRINT "1005 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1005_LoadFinished - L1005_Load2) +PRINT " / " +PRINT (L1005_InitFinished - L1005_Init2) +PRINT " / " +PRINT (L1005_CheckFinished - L1005_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1006.asm b/Source/Levels/L1006.asm new file mode 100644 index 0000000..ba9ab8e --- /dev/null +++ b/Source/Levels/L1006.asm @@ -0,0 +1,67 @@ +; L1006.asm crouton outpost +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1006Section",ROMX +;--------------------------------------------------------------------- + +L1006_Contents:: + DW L1006_Load + DW L1006_Init + DW L1006_Check + DW L1006_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1006_Load: + DW ((L1006_LoadFinished - L1006_Load2)) ;size +L1006_Load2: + call ParseMap + ret + +L1006_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1006_Map: +INCBIN "Data/Levels/L1006_outpost.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1006_Init: + DW ((L1006_InitFinished - L1006_Init2)) ;size +L1006_Init2: + ld bc,ITEM_CODE1006 + call RemoveClearanceIfTaken + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L1006_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1006_Check: + DW ((L1006_CheckFinished - L1006_Check2)) ;size +L1006_Check2: + ret + +L1006_CheckFinished: +PRINT "1006 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1006_LoadFinished - L1006_Load2) +PRINT " / " +PRINT (L1006_InitFinished - L1006_Init2) +PRINT " / " +PRINT (L1006_CheckFinished - L1006_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1007.asm b/Source/Levels/L1007.asm new file mode 100644 index 0000000..70354bd --- /dev/null +++ b/Source/Levels/L1007.asm @@ -0,0 +1,80 @@ +; L1007.asm liars heads +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level1007Section",ROMX +;--------------------------------------------------------------------- + +L1007_Contents:: + DW L1007_Load + DW L1007_Init + DW L1007_Check + DW L1007_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1007_Load: + DW ((L1007_LoadFinished - L1007_Load2)) ;size +L1007_Load2: + call ParseMap + ret + +L1007_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1007_Map: +INCBIN "Data/Levels/L1007_stoneheads.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1007_Init: + DW ((L1007_InitFinished - L1007_Init2)) ;size +L1007_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + ld a,ENV_RAIN + call SetEnvEffect + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + ret + +L1007_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1007_Check: + DW ((L1007_CheckFinished - L1007_Check2)) ;size +L1007_Check2: + call ((.animateWater-L1007_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L1007_CheckFinished: +PRINT "1007 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1007_LoadFinished - L1007_Load2) +PRINT " / " +PRINT (L1007_InitFinished - L1007_Init2) +PRINT " / " +PRINT (L1007_CheckFinished - L1007_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1008.asm b/Source/Levels/L1008.asm new file mode 100644 index 0000000..75107a9 --- /dev/null +++ b/Source/Levels/L1008.asm @@ -0,0 +1,78 @@ +; L1008.asm east graves +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +WATERINDEX EQU 1 +VAR_WATER EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level1008Section",ROMX +;--------------------------------------------------------------------- + +L1008_Contents:: + DW L1008_Load + DW L1008_Init + DW L1008_Check + DW L1008_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1008_Load: + DW ((L1008_LoadFinished - L1008_Load2)) ;size +L1008_Load2: + call ParseMap + ret + +L1008_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1008_Map: +INCBIN "Data/Levels/L1008_graves.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1008_Init: + DW ((L1008_InitFinished - L1008_Init2)) ;size +L1008_Init2: + ld a,[bgTileMap + WATERINDEX] + ld [levelVars + VAR_WATER],a + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + ret + +L1008_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1008_Check: + DW ((L1008_CheckFinished - L1008_Check2)) ;size +L1008_Check2: + call ((.animateWater-L1008_Check2)+levelCheckRAM) + ret + +.animateWater + ldio a,[updateTimer] + swap a + and %11 + ld hl,levelVars + VAR_WATER + add [hl] + ld [bgTileMap + WATERINDEX],a + ret + +L1008_CheckFinished: +PRINT "1008 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1008_LoadFinished - L1008_Load2) +PRINT " / " +PRINT (L1008_InitFinished - L1008_Init2) +PRINT " / " +PRINT (L1008_CheckFinished - L1008_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1009.asm b/Source/Levels/L1009.asm new file mode 100644 index 0000000..25caa04 --- /dev/null +++ b/Source/Levels/L1009.asm @@ -0,0 +1,59 @@ +; L1009.asm +; Generated 10.30.2000 by mlevel +; Modified 10.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1009Section",ROMX +;--------------------------------------------------------------------- + +L1009_Contents:: + DW L1009_Load + DW L1009_Init + DW L1009_Check + DW L1009_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1009_Load: + DW ((L1009_LoadFinished - L1009_Load2)) ;size +L1009_Load2: + call ParseMap + ret + +L1009_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1009_Map: +INCBIN "Data/Levels/L1009_warzone.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1009_Init: + DW ((L1009_InitFinished - L1009_Init2)) ;size +L1009_Init2: + ret + +L1009_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1009_Check: + DW ((L1009_CheckFinished - L1009_Check2)) ;size +L1009_Check2: + ret + +L1009_CheckFinished: +PRINT "1009 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1009_LoadFinished - L1009_Load2) +PRINT " / " +PRINT (L1009_InitFinished - L1009_Init2) +PRINT " / " +PRINT (L1009_CheckFinished - L1009_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1010.asm b/Source/Levels/L1010.asm new file mode 100644 index 0000000..b4c622f --- /dev/null +++ b/Source/Levels/L1010.asm @@ -0,0 +1,222 @@ +; L1010.asm king grenade +; Generated 11.08.2000 by mlevel +; Modified 11.08.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +DICEINDEX EQU 62 +KING_INDEX EQU 68 + +VAR_TALKED EQU 0 +VAR_DICELIGHT EQU 3 + +;--------------------------------------------------------------------- +SECTION "Level1010Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1010_amking_gtx: + INCBIN "Data/Dialog/Talk/L1010_amking.gtx" + +L1010_cannotleave_gtx: + INCBIN "Data/Dialog/Talk/L1010_cannotleave.gtx" + +L1010_readytogo_gtx: + INCBIN "Data/Dialog/Talk/L1010_readytogo.gtx" + +L1010_Contents:: + DW L1010_Load + DW L1010_Init + DW L1010_Check + DW L1010_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1010_Load: + DW ((L1010_LoadFinished - L1010_Load2)) ;size +L1010_Load2: + call ParseMap + ret + +L1010_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1010_Map: +INCBIN "Data/Levels/L1010_kinggrenade.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1010_Init: + DW ((L1010_InitFinished - L1010_Init2)) ;size +L1010_Init2: + ;make gun turret friendly + ld bc,classTurret + call FindClassIndex + ld c,a + call GetFirst + ld a,GROUP_HERO + call SetGroup + call GetNextObject + ld a,GROUP_HERO + call SetGroup + + ld a,[bgTileMap+DICEINDEX] ;tile index of first light + ld [levelVars+VAR_DICELIGHT],a + + STDSETUPDIALOG + + ld hl,$1100 + call SetJoinMap + call SetRespawnMap + + ;already have King Grenade? + xor a + ld [levelVars+VAR_TALKED],a + + ld a,[heroesAvailable] + and HERO_GRENADE_FLAG + jr z,.afterRemoveGrenade + + ld a,1 + ld [levelVars+VAR_TALKED],a + + ld bc,classGeneric + call DeleteObjectsOfClass + +.afterRemoveGrenade + ret + +L1010_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1010_Check: + DW ((L1010_CheckFinished - L1010_Check2)) ;size +L1010_Check2: + call ((.animateDiceLights-L1010_Check2)+levelCheckRAM) + call ((.checkDialog-L1010_Check2)+levelCheckRAM) + ret + +.checkDialog + ld a,[levelVars+VAR_TALKED] + or a + ret nz + + ld hl,((.checkHeroInZone-L1010_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroInZone + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.inZone + + xor a + ret + +.inZone + call MakeIdle + + ld de,((.afterDialog-L1010_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L1010_amking_gtx + ld c,KING_INDEX + call ShowDialogAtTop + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cf] ;been to generators? + or a + jr nz,.blownUp + + ld de,L1010_cannotleave_gtx + call ShowDialogAtTop + jr .afterDialog + +.blownUp + ld de,L1010_readytogo_gtx + call ShowDialogAtTop + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ld [levelVars+VAR_TALKED],a + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$cf] ;been to generators? + or a + jr z,.done + + ld hl,heroesAvailable + ld a,[hl] + or HERO_GRENADE_FLAG + ld [hl],a + + xor a + call LinkTransmitMemoryLocation + + ld bc,classGeneric + call DeleteObjectsOfClass + +.done + ld a,1 + ret + +.animateDiceLights + ;animate dice lights + ld a,[levelVars+VAR_DICELIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+DICEINDEX + call ((.updateTwoLights - L1010_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L1010_Check2) + levelCheckRAM) + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L1010_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + +L1010_CheckFinished: +PRINT "1010 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1010_LoadFinished - L1010_Load2) +PRINT " / " +PRINT (L1010_InitFinished - L1010_Init2) +PRINT " / " +PRINT (L1010_CheckFinished - L1010_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1011.asm b/Source/Levels/L1011.asm new file mode 100644 index 0000000..fb47e7a --- /dev/null +++ b/Source/Levels/L1011.asm @@ -0,0 +1,173 @@ +; L1011.asm +; Generated 04.26.2001 by mlevel +; Modified 04.26.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_DEFUSED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level1011Section",ROMX +;--------------------------------------------------------------------- + +L1011_Contents:: + DW L1011_Load + DW L1011_Init + DW L1011_Check + DW L1011_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1011_Load: + DW ((L1011_LoadFinished - L1011_Load2)) ;size +L1011_Load2: + call ParseMap + ret + +L1011_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1011_Map: +INCBIN "Data/Levels/L1011_ssa_sw.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1011_Init: + DW ((L1011_InitFinished - L1011_Init2)) ;size +L1011_Init2: + ld a,BANK(L0012_defused_gtx) + ld [dialogBank],a + call SetPressBDialog + + ldio a,[mapState] + cp STATE_DEFUSED + jr nz,.afterRemoveBomb + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d062 + ld [hl+],a + ld [hl],a + ld hl,$d082 + ld [hl+],a + ld [hl],a + +.afterRemoveBomb + ret + +L1011_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1011_Check: + DW ((L1011_CheckFinished - L1011_Check2)) ;size +L1011_Check2: + call ((.checkAtBomb-L1011_Check2)+levelCheckRAM) + ret + +.checkAtBomb + ldio a,[mapState] + cp STATE_DEFUSED + ret z + + ld hl,((.checkHeroAtBomb-L1011_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtBomb + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atBomb + + xor a + ret + +.atBomb + ld a,STATE_DEFUSED + ldio [mapState],a + + call UpdateState + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d062 + ld [hl+],a + ld [hl],a + ld hl,$d082 + ld [hl+],a + ld [hl],a + + ;check all defused + ld d,0 + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$b8] + cp 2 + jr nz,.check2 + inc d +.check2 + ld a,[levelState+$b9] + cp 2 + jr nz,.check3 + inc d +.check3 + ld a,[levelState+$ba] + cp 2 + jr nz,.check4 + inc d +.check4 + ld a,[levelState+$bb] + cp 2 + jr nz,.checkTotal + inc d +.checkTotal + ;if 3 bombs were defused before this one then that's all + ld a,d + cp 3 + jr nz,.bombsRemain + + ld hl,L0012_alldefused_gtx + jr .dialog + +.bombsRemain + ld hl,L0012_defused_gtx + +.dialog + call MakeIdle + ld de,((.afterDialog-L1011_Check2)+levelCheckRAM) + call SetDialogSkip + + ld d,h + ld e,l + + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ret + +L1011_CheckFinished: +PRINT "1011 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1011_LoadFinished - L1011_Load2) +PRINT " / " +PRINT (L1011_InitFinished - L1011_Init2) +PRINT " / " +PRINT (L1011_CheckFinished - L1011_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1012.asm b/Source/Levels/L1012.asm new file mode 100644 index 0000000..fa7b113 --- /dev/null +++ b/Source/Levels/L1012.asm @@ -0,0 +1,107 @@ +; L1012.asm library +; Generated 04.10.2001 by mlevel +; Modified 04.10.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_NORMAL EQU 1 +STATE_READBOOK EQU 2 + +;--------------------------------------------------------------------- +SECTION "Level1012Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1012_hero_readbook_gtx: + INCBIN "Data/Dialog/Talk/L1012_hero_readbook.gtx" + +L1012_Contents:: + DW L1012_Load + DW L1012_Init + DW L1012_Check + DW L1012_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1012_Load: + DW ((L1012_LoadFinished - L1012_Load2)) ;size +L1012_Load2: + call ParseMap + ret + +L1012_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1012_Map: +INCBIN "Data/Levels/L1012_library.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1012_Init: + DW ((L1012_InitFinished - L1012_Init2)) ;size +L1012_Init2: + STDSETUPDIALOG + ret + +L1012_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1012_Check: + DW ((L1012_CheckFinished - L1012_Check2)) ;size +L1012_Check2: + call ((.checkAtBook-L1012_Check2)+levelCheckRAM) + ret + +.checkAtBook + ldio a,[mapState] + cp STATE_READBOOK + ret z + + ld hl,((.checkHeroAtBook-L1012_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtBook + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atBook + + xor a + ret + +.atBook + call MakeIdle + ld de,((.afterDialog-L1012_Check2)+levelCheckRAM) + call SetDialogSkip + + call SetSpeakerFromHeroIndex + ld de,L1012_hero_readbook_gtx + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + ld a,STATE_READBOOK + ldio [mapState],a + + ld a,1 + ret + + +L1012_CheckFinished: +PRINT "1012 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1012_LoadFinished - L1012_Load2) +PRINT " / " +PRINT (L1012_InitFinished - L1012_Init2) +PRINT " / " +PRINT (L1012_CheckFinished - L1012_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1100.asm b/Source/Levels/L1100.asm new file mode 100644 index 0000000..0702bcf --- /dev/null +++ b/Source/Levels/L1100.asm @@ -0,0 +1,669 @@ +;L1100 character select +;Abe Pralle 4.3.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Gfx.inc" +INCLUDE "Source/Start.inc" + +EXITAPPOMATTOX EQU $1300 +;EXITAPPOMATTOX EQU $0812 +;EXITAPPOMATTOX EQU $0107 + + +;--------------------------------------------------------------------- +SECTION "L1100Gfx1",ROMX +;--------------------------------------------------------------------- +select_grenade_sp: + INCBIN "Data/Cinema/CharSelect/select_grenade.sp" + +select_grenade_name_bg: + INCBIN "Data/Cinema/CharSelect/kgname.bg" + +;--------------------------------------------------------------------- +SECTION "L1100Section",ROMX +;--------------------------------------------------------------------- + +select_hero_bg: + INCBIN "Data/Cinema/CharSelect/charselecthills.bg" + +select_ba_sp: + INCBIN "Data/Cinema/CharSelect/select_ba.sp" + +select_ba_name_bg: + INCBIN "Data/Cinema/CharSelect/select_ba_name.bg" + +select_bs_sp: + INCBIN "Data/Cinema/CharSelect/select_bs.sp" + +select_bs_name_bg: + INCBIN "Data/Cinema/CharSelect/select_bs_name.bg" + +select_haiku_sp: + INCBIN "Data/Cinema/CharSelect/select_haiku.sp" + +select_haiku_name_bg: + INCBIN "Data/Cinema/CharSelect/select_haiku_name.bg" + +L1100_Contents:: + DW L1100_Load + DW L1100_Init + DW L1100_Check + DW L1100_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1100_Load: + DW ((L1100_LoadFinished - L1100_Load)-2) ;size +L1100_Load2: + ld hl,$1100 + call SetJoinMap + ld hl,EXITAPPOMATTOX + call SetRespawnMap + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + +;ld a,[heroesAvailable] +;or HERO_GRENADE_FLAG +;ld [heroesAvailable],a + xor a + ld [scrollSprites],a + + ld a,$44 + ldio [scrollSpeed],a + + ld a,BANK(select_hero_bg) + ld hl,select_hero_bg + call LoadCinemaBG + + xor a + ld [gamePalette+2],a + ld [gamePalette+3],a + + ;if my hero type is the same as both hero types (e.g. the other + ;hero's types) then pick an alternate hero (probably just + ;joined game) + LDHL_CURHERODATA HERODATA_TYPE + ld b,[hl] + ld a,[hero0_type] + cp b + jr nz,.myTypeOkay + ld a,[amLinkMaster] + bit 7,a + jr nz,.myTypeOkay ;no link + ld a,[hero1_type] + cp b + jr nz,.myTypeOkay + + ;change my type + cp 1 + jr z,.changeTypeTo2 + ld a,1 + jr .pickedANewType +.changeTypeTo2 + ld a,2 +.pickedANewType + ld [hl],a +.myTypeOkay + ;mark my hero as used + ld b,[hl] + ld a,[heroesUsed] + or b + ld [heroesUsed],a + call UpdateRemoteHeroesUsed + + call ((.loadCurHeroSprite-L1100_Load2)+levelCheckRAM) + ld d,160 + call ScrollSpritesRight + + ld hl,((CharSelectOnHBlank-L1100_Load2)+levelCheckRAM) + call InstallHBlankHandler + ld a,1 + call SetupFadeFromStandard + ld a,120 + ld [camera_i],a + + ld d,160 + call ScrollSpritesLeft + call ((.scrollInFromRight-L1100_Load2)+levelCheckRAM) + +.waitInputLoop + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,[myJoy] + bit JOY_RIGHT_BIT,a + jr z,.checkLeft + + call ((.nextHeroRight-L1100_Load2)+levelCheckRAM) + jp ((.waitContinue-L1100_Load2)+levelCheckRAM) + +.checkLeft + bit JOY_LEFT_BIT,a + jr z,.checkExit + + call ((.nextHeroLeft-L1100_Load2)+levelCheckRAM) + jr .waitContinue + +.checkExit + bit JOY_A_BIT,a + jr nz,.exit + bit JOY_START_BIT,a + jr z,.waitContinue + +.exit + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + cp HERO_BA_FLAG + jr nz,.exitCheckBS + ld de,BA_CINDEX + jr .exitGotHeroClass +.exitCheckBS + cp HERO_BS_FLAG + jr nz,.exitCheckHaiku + ld de,BS_CINDEX + jr .exitGotHeroClass +.exitCheckHaiku + cp HERO_HAIKU_FLAG + jr nz,.exitCheckGrenade + ld de,HAIKU_CINDEX + jr .exitGotHeroClass +.exitCheckGrenade + ld de,KGRENADE_CINDEX +.exitGotHeroClass + LDHL_CURHERODATA HERODATA_CLASS + ld a,e + ld [hl+],a + ld a,d + ld [hl+],a + LDHL_CURHERODATA HERODATA_HEALTH + xor a + ld [hl],a + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_D + ld [hl],a + ld hl,EXITAPPOMATTOX + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + call ClearDialog + ld hl,OnHBlank + call InstallHBlankHandler + ld a,1 + call SetupFadeToStandard + ld a,1 + call Delay + call ResetSprites + ret + +.waitContinue + ld a,1 + call Delay + jp ((.waitInputLoop-L1100_Load2)+levelCheckRAM) + ret + +;----Support Routines------------------------------------------------- +.nextHeroRight + ;wait until I can lock heroesUsed + call LockRemoteHeroesUsed + jr nz,.heroesLockedRight + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + jr .nextHeroRight + +.heroesLockedRight + ;if no link set all to unused (fix used hero on broken link) + ld a,[amLinkMaster] + bit 7,a + jr z,.unlockMyHeroRight ;has link + + ;mark all as unused + xor a + ld [heroesUsed],a + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + jr .pickNewRotateRight + +.unlockMyHeroRight + ;mark cur hero as unused + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + push af + xor $ff + ld hl,heroesUsed + and [hl] + ld [hl],a + pop af + +.pickNewRotateRight + ;pick new by rotating right until matches available + ld b,a + ld a,[heroesUsed] + xor $ff + ld c,a + ld a,[heroesAvailable] + and c + ld c,a +.nextHeroLeftLoop + rrc b + ld a,c + or b + cp c + jr nz,.nextHeroLeftLoop + + LDHL_CURHERODATA HERODATA_TYPE + ld [hl],b ;found new hero + ld a,[heroesUsed] + or b + ld [heroesUsed],a + call UpdateRemoteHeroesUsed + call ((.scrollOutToLeft-L1100_Load2)+levelCheckRAM) + call ((.loadCurHeroSprite-L1100_Load2)+levelCheckRAM) + call ((.scrollInFromRight-L1100_Load2)+levelCheckRAM) + ret + +.nextHeroLeft + ;wait until I can lock heroesUsed + call LockRemoteHeroesUsed + jr nz,.heroesLockedLeft + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + jr .nextHeroLeft + +.heroesLockedLeft + ;if no link set all to unused (fix used hero on broken link) + ld a,[amLinkMaster] + bit 7,a + jr z,.unlockMyHeroLeft ;has link + + ;mark all as unused + xor a + ld [heroesUsed],a + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + jr .pickNewRotateLeft + +.unlockMyHeroLeft + ;mark cur hero as unused + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + push af + xor $ff + ld hl,heroesUsed + and [hl] + ld [hl],a + pop af + +.pickNewRotateLeft + ;pick new by rotating left until matches available + ld b,a + ld a,[heroesUsed] + xor $ff + ld c,a + ld a,[heroesAvailable] + and c + ld c,a +.nextHeroRightLoop + rlc b + ld a,c + or b + cp c + jr nz,.nextHeroRightLoop + + LDHL_CURHERODATA HERODATA_TYPE + ld [hl],b ;found new hero + ld a,[heroesUsed] + or b + ld [heroesUsed],a + call UpdateRemoteHeroesUsed + call ((.scrollOutToRight-L1100_Load2)+levelCheckRAM) + call ((.loadCurHeroSprite-L1100_Load2)+levelCheckRAM) + call ((.scrollInFromLeft-L1100_Load2)+levelCheckRAM) + ret + +.scrollInFromRight + ;scroll sprites out of view to the right + ld d,160 + call ScrollSpritesRight + ld a,[specialFX] + and FX_FADE + jr nz,.afterInstallPaletteRight + call InstallGamePalette +.afterInstallPaletteRight + call GfxShowStandardTextBox + + ;scroll sprites into view + ld c,24 +.scrollInFromRightLoop + ld d,5 + call ScrollSpritesLeft + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.scrollInFromRightLoop + ret + +.scrollInFromLeft + ;scroll sprites out of view to the left + ld d,80 + call ScrollSpritesLeft + ld a,[specialFX] + and FX_FADE + jr nz,.afterInstallPaletteLeft + call InstallGamePalette +.afterInstallPaletteLeft + call GfxShowStandardTextBox + + ;scroll sprites into view from left + ld c,24 +.scrollInFromLeftLoop + ld d,5 + call ScrollSpritesRight + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.scrollInFromLeftLoop + ret + +.scrollOutToRight + call ClearDialog + ld c,20 +.scrollOutToRightLoop + ld d,6 + call ScrollSpritesRight + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.scrollOutToRightLoop + call ResetSprites + ret + +.scrollOutToLeft + call ClearDialog + ld c,20 +.scrollOutToLeftLoop + ld d,6 + call ScrollSpritesLeft + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.scrollOutToLeftLoop + call ResetSprites + ret + +.scrollBG + ld a,[mapLeft] + cp 44 + ret nz + xor a + ld [mapLeft],a + ret + +.loadCurHeroSprite + xor a + ldio [backBufferReady],a + + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + cp HERO_BA_FLAG + jr nz,.loadBS + ld a,BANK(select_ba_name_bg) + ld hl,select_ba_name_bg + call LoadCinemaTextBox + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + ld a,BANK(select_ba_sp) + ld hl,select_ba_sp + call LoadCinemaSprite + ret + +.loadBS + cp HERO_BS_FLAG + jr nz,.loadHaiku + + ld a,BANK(select_bs_name_bg) + ld hl,select_bs_name_bg + call LoadCinemaTextBox + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + ld a,BANK(select_bs_sp) + ld hl,select_bs_sp + call LoadCinemaSprite + ret + +.loadHaiku + cp HERO_HAIKU_FLAG + jr nz,.loadGrenade + + ld a,BANK(select_haiku_name_bg) + ld hl,select_haiku_name_bg + call LoadCinemaTextBox + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + ld a,BANK(select_haiku_sp) + ld hl,select_haiku_sp + call LoadCinemaSprite + ret + +.loadGrenade + ld a,BANK(select_grenade_name_bg) + ld hl,select_grenade_name_bg + call LoadCinemaTextBox + call ((.scrollBG-L1100_Load2)+levelCheckRAM) + ld a,1 + call Delay + ld a,BANK(select_grenade_sp) + ld hl,select_grenade_sp + call LoadCinemaSprite + ret + +CharSelectOnHBlank: + push af + push bc + push hl + + ;rainbow sky + ld c,$69 + ldio a,[$ff44] +.checkRainbowSky + cp 70 + jr nc,.resetSkyTop + + inc a + rlca ;times two (index to word array) + add (((.rainbowSky-L1100_Load2)+levelCheckRAM)&$ff) + ld l,a + ld a,((((.rainbowSky-L1100_Load2)+levelCheckRAM)>>8)&$ff) + adc 0 + ld h,a + ld a,%10000010 + ldio [$ff68],a + ld a,[hl+] + ld [c],a + ld a,[hl+] + ld [c],a + jr .checkDialogOnOff + +.resetSkyTop + ld a,%10000010 + ld [$ff68],a + xor a + ld [c],a + ld [c],a + +.checkDialogOnOff + ldio a,[$ff41] ;get stat register + bit 2,a ;equal to lyc? + jr z,.done + +.continue + ld hl,hblankFlag + bit 0,[hl] ;turning window on or off? + jr nz,.turnOffWindow + + ;turn on window + bit 1,[hl] ;allowed to? + jr nz,.turnOn + jr .done +.turnOn + set 0,[hl] + ldio a,[hblankWinOff] + ld [$ff45],a ;reset lyc to win off pos + ld hl,$ff40 ;turn window on + set 5,[hl] + + ;set background palette 0, color zero to black + ld c,$68 + ld a,%10000000 ;specification + ld [c],a + xor a + inc c + ld [c],a + ld [c],a + jr .done + +.turnOffWindow + res 0,[hl] + ldio a,[hblankWinOn] + ld [$ff45],a ;reset lyc to win on pos + ld hl,$ff40 ;turn window off + res 5,[hl] + + ;restore background palette 0, color zero + ld a,%10000000 ;specification + ld c,$68 + ld hl,mapColor + ld [c],a ;ff68 + ld a,[hl+] ;[mapColor] + inc c + ld [c],a ;ff69 + ld a,[hl] ;[mapColor+1] + ld [c],a ;ff69 + +.done + pop hl + pop bc + pop af + reti + +.rainbowSky + COLOR 0,0,0 + COLOR 0,0,8 + COLOR 0,0,17 + COLOR 0,0,25 + COLOR 0,0,34 + COLOR 0,0,42 + COLOR 0,0,51 + COLOR 0,0,59 + COLOR 0,0,68 + COLOR 0,0,76 + COLOR 0,0,85 + COLOR 0,0,93 + COLOR 0,0,102 + COLOR 0,0,110 + COLOR 0,0,119 + COLOR 0,0,127 + COLOR 0,0,136 + COLOR 0,0,144 + COLOR 0,0,153 + COLOR 0,0,161 + COLOR 0,0,170 + COLOR 0,0,178 + COLOR 0,0,187 + COLOR 0,0,195 + COLOR 0,0,204 + COLOR 0,0,212 + COLOR 0,0,221 + COLOR 0,0,229 + COLOR 0,0,238 + COLOR 0,0,246 + COLOR 0,0,255 + + COLOR 0,0,255 + COLOR 4,6,255 + COLOR 8,12,255 + COLOR 12,19,255 + COLOR 17,25,255 + COLOR 21,32,255 + COLOR 25,38,255 + COLOR 29,44,255 + COLOR 34,51,255 + COLOR 38,57,255 + COLOR 42,64,255 + COLOR 46,70,255 + COLOR 51,76,255 + COLOR 55,83,255 + COLOR 59,89,255 + COLOR 64,96,255 + COLOR 68,102,255 + COLOR 72,108,255 + COLOR 76,115,255 + COLOR 81,121,255 + COLOR 85,128,255 + COLOR 89,134,255 + COLOR 93,140,255 + COLOR 98,147,255 + COLOR 102,153,255 + COLOR 106,160,255 + COLOR 110,166,255 + COLOR 115,172,255 + COLOR 119,179,255 + COLOR 123,185,255 + COLOR 128,192,255 + + COLOR 128,192,255 + COLOR 139,197,255 + COLOR 151,203,255 + COLOR 162,209,255 + COLOR 174,214,255 + COLOR 185,220,255 + COLOR 197,226,255 + COLOR 208,232,255 + COLOR 220,237,255 + COLOR 231,243,255 + COLOR 243,249,255 + COLOR 255,255,255 + +L1100_LoadFinished: + +PRINT " 1100 Level Load Size: " +PRINT (L1100_LoadFinished - L1100_Load2) +PRINT "/$500 bytes\n" + + +L1100_Map: + +;gtx_app_closed_gate_bs5: INCBIN "Data/Dialog/Landing/app_closed_gate_bs5.gtx" + +L1100_Init: + DW ((L1100_InitFinished - L1100_Init)-2) ;size +L1100_Init2: + ret + +L1100_InitFinished: + + +L1100_Check: + DW ((L1100_CheckFinished - L1100_Check) - 2) ;size +L1100_Check2: + ret + +L1100_CheckFinished: + +PRINT " 1100 Level Load Size: " +PRINT (L1100_LoadFinished - L1100_Load2) +PRINT "/$500 bytes\n" + diff --git a/Source/Levels/L1101.asm b/Source/Levels/L1101.asm new file mode 100644 index 0000000..5751bbb --- /dev/null +++ b/Source/Levels/L1101.asm @@ -0,0 +1,648 @@ +;L1101.asm main menu +;Abe Pralle 3.4.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Start.inc" + + +INTCLK EQU $83 +EXTCLK EQU $82 + +;JOINMAP EQU $1102 +;JOINMAP EQU $1100 +JOINDIR EQU EXIT_D + +;JOINMAP EQU $0015 +;JOINDIR EQU EXIT_W + +;--------------------------------------------------------------------- +SECTION "LevelsSection1101_data2",ROMX +;--------------------------------------------------------------------- +bullet_sp: + INCBIN "Data/Cinema/menu/menucursor.sp" + + +;--------------------------------------------------------------------- +SECTION "LevelsSection1101",ROMX +;--------------------------------------------------------------------- + +L1101_Contents:: + DW L1101_Load + DW L1101_Init + DW L1101_Check + DW L1101_Map + +mainmenu_bg: + INCBIN "Data/Cinema/menu/fgbmenu.bg" + + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1101_Load: + DW ((L1101_LoadFinished - L1101_Load2)) ;size +L1101_Load2: + ;reset all 256 mapState entries to zero + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld hl,levelState + xor a +.resetStates + ld [hl+],a + cp l + jr nz,.resetStates + + ;reveal river tiles on computer map + ld a,1 + ld [levelState+0*16+1],a + ld [levelState+1*16+1],a + ld [levelState+2*16+1],a + ld [levelState+2*16+2],a + ld [levelState+3*16+2],a + ld [levelState+3*16+2],a + ld [levelState+4*16+2],a + ld [levelState+5*16+2],a + ld [levelState+6*16+2],a + ld [levelState+7*16+2],a + ld [levelState+8*16+2],a + ld [levelState+9*16+2],a + ld [levelState+10*16+2],a + ld [levelState+7*16+1],a + + ;set heroes' health to zero so that it's reset first time + ;and puffball count to zero + xor a + ld [hero0_health],a + ld [hero1_health],a + ld [hero0_puffCount],a + ld [hero1_puffCount],a + + ld a,BANK(mainmenu_bg) + ld hl,mainmenu_bg + call LoadCinemaBG + + ld a,BANK(bullet_sp) + ld hl,bullet_sp + call LoadCinemaSprite + + ld hl,(bullet_y + (levelCheckRAM-L1101_Load2)) + xor a + ld [hl+],a ;bullet_y + ld [hl+],a ;cur_choice + ld a,1 + ld [hl+],a ;hasSavedGame + xor a + ld [hl+],a ;hasLinkMaster + + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterTerminateLink + +.sendTerminate + ld a,LTERMINATE + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.sendTerminate + + ld a,$ff + ld [amLinkMaster],a + +.afterTerminateLink + ;setup attempt to link as slave + ld a,$aa + ldio [$ff01],a ;exchange data + ld a,EXTCLK + ldio [$ff02],a ;ready for xchg, use remote clock + + ;ld d,4 + ;call ScrollSpritesRight + call (.drawMenu + (levelCheckRAM-L1101_Load2)) + call RedrawMap + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + +.mainloop + call UpdateObjects + call (.drawMenu + (levelCheckRAM-L1101_Load2)) + call RedrawMap + + ld a,[amLinkMaster] + cp $ff ;do I care about attempting link as a slave? + jr nz,.afterUpdateLinkStatus + + ldio a,[$ff02] + and $80 + jr nz,.afterUpdateLinkStatus ;no change + + ld a,[$ff01] ;got something useful? + cp $55 + jr z,.become_slave + +.resetLinkAttempt + ld a,$aa + ldio [$ff01],a + ld a,EXTCLK + ldio [$ff02],a + jr .afterUpdateLinkStatus ;no change + +.become_slave + ;We transferred a byte! I just became somebody's bitch. + xor a + ld [amLinkMaster],a ;I'm a slave + ld a,1 + ld [(hasLinkMaster + (levelCheckRAM-L1101_Load2))],a + ld a,2 ;force bullet to "join game" + ld [(cur_choice + (levelCheckRAM-L1101_Load2))],a + + ;disabled load game + xor a + ld [(hasSavedGame + (levelCheckRAM-L1101_Load2))],a + + ;kill some time + ld a,$80 +.killTime + push af + pop af + dec a + jr nz,.killTime + +.afterUpdateLinkStatus + ld hl,(cur_choice + (levelCheckRAM-L1101_Load2)) + ld a,[myJoy] + and JOY_DOWN + jr z,.checkJoyUp + + ld a,[hl] + or a + jr nz,.checkDownWasLoad + +.checkDownWasNewGame + ;down, cursor was on "new game" + inc [hl] + ld a,[(hasSavedGame + (levelCheckRAM-L1101_Load2))] + or a + jr z,.downWasLoad + jr .checkJoyDone + +.checkDownWasLoad + cp 1 + jr nz,.checkDownWasJoin + +.downWasLoad + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr nz,.downOkayToJoin + + ld [hl],0 ;set bullet to new game + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr z,.checkJoyDone + jr .checkDownWasNewGame + +.downOkayToJoin + inc [hl] + jr .checkJoyDone + +.checkDownWasJoin + xor a + ld [hl],a + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr z,.checkJoyDone + jr .checkDownWasNewGame + +.checkJoyUp + ld a,[myJoy] + and JOY_UP + jr z,.checkJoyButtons + + ld a,[hl] + or a + jr nz,.checkUpWasLoad + + ld [hl],2 + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr z,.upWasJoin + +.checkUpWasLoad + cp 1 + jr nz,.upWasJoin + jr .upWasLoad + +.upWasNewGame + jr .checkJoyDone + +.upWasLoad + dec [hl] ;set to new game + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr z,.checkJoyDone + ld [hl],2 + jr .checkJoyDone + +.upWasJoin + dec [hl] + ld a,[(hasSavedGame + (levelCheckRAM-L1101_Load2))] + or a + jr z,.upWasLoad + +.checkJoyDone + call (.drawMenu + (levelCheckRAM-L1101_Load2)) + ld a,JOY_DOWN | JOY_UP + push hl + ld hl,myJoy + call WaitInputZero + pop hl + +.checkJoyButtons + ld a,[myJoy] + and %11110000 + jr nz,.haveButtons + jp (.mainloop + (levelCheckRAM-L1101_Load2)) + +.haveButtons + ;if starting a new game w/no link, make me the master + ld a,[amLinkMaster] + cp $ff + jr nz,.afterMakeMaster + or a + jr z,.afterMakeMaster + ld a,$fe ;no link/master + ld [amLinkMaster],a + +.afterMakeMaster + ld a,%11111111 + push hl + ld hl,myJoy + call WaitInputZero + pop hl + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld a,[(cur_choice + (levelCheckRAM-L1101_Load2))] + cp 2 + jp z,((.joinGame-L1101_Load2)+levelCheckRAM) + + cp 1 + jr z,.loadGame + + ;begin a new game + LONGCALLNOARGS RandomizeFlightCodes + + ;save game + ;call ((.saveGame-L1101_Load2)+levelCheckRAM) + + ld hl,MENUTOMAP + jp ((.setNextLevel-L1101_Load2)+levelCheckRAM) + +.loadGame + ld a,$0a ;enable save ram access + ld [0],a + + ;if number of flight codes is zero, must not be a saved game here + ld a,[$a000+9+16+256] + or a + jr z,.afterLoadGame + + ld hl,$a000 ;start of ram area $a000-$bfff + ld de,gameState + ld bc,9 + xor a + call ((.loadData-L1101_Load2)+levelCheckRAM) + + ld de,inventory + ld bc,16 + xor a + call ((.loadData-L1101_Load2)+levelCheckRAM) + + ld de,levelState + ld bc,256 + ld a,LEVELSTATEBANK + call ((.loadData-L1101_Load2)+levelCheckRAM) + + ld de,flightCode + ld bc,256 + ld a,FLIGHTCODEBANK + call ((.loadData-L1101_Load2)+levelCheckRAM) + +.afterLoadGame + xor a + ld [heroesUsed],a + + xor a + ld [0],a ;disable save ram to prevent false writes on powerdown + + ld a,LEVELSTATEBANK ;analyze level states to see if we're somewhere special + ldio [$ff70],a + ld hl,$1100 ;level # of char select + ld a,[levelState+$2f] ;distress + or a + ;after distress cinema, start at char select + jp nz,((.setNextLevel-L1101_Load2)+levelCheckRAM) + + ld hl,$1102 ;intro missions + jp ((.setNextLevel-L1101_Load2)+levelCheckRAM) + +.loadData + ;copies "bc" # of bytes from [hl] to [de] in bank "a" + ldio [$ff70],a +.loadLoop + ld a,[hl+] + ld [de],a + inc de + dec bc + xor a + cp b + jr nz,.loadLoop + cp c + jr nz,.loadLoop + ret + +.saveGame + ld a,$0a ;enable save ram access + ld [0],a + + ld hl,$a000 ;start of save area $a000-$bfff + ld de,gameState + ld bc,9 + xor a + call ((.saveData-L1101_Load2)+levelCheckRAM) + + ld de,inventory + ld bc,16 + xor a + call ((.saveData-L1101_Load2)+levelCheckRAM) + + ld de,levelState + ld bc,256 + ld a,LEVELSTATEBANK + call ((.saveData-L1101_Load2)+levelCheckRAM) + + ld de,flightCode + ld bc,256 + ld a,FLIGHTCODEBANK + call ((.saveData-L1101_Load2)+levelCheckRAM) + + xor a + ld [0],a ;disable save ram to prevent false writes on powerdown + ret + +.saveData + ;copies "bc" # of bytes from [de] to [hl] in bank "a" + ldio [$ff70],a +.saveLoop + ld a,[de] + inc de + ld [hl+],a + dec bc + xor a + cp b + jr nz,.saveLoop + cp c + jr nz,.saveLoop + ret + + + +.joinGame +;----LINK TEST BEGIN-------------------------------------------------- +IF 0 + ld a,LLINKTEST + call ExchangeByte + ld a,1 + ld bc,$1000 + ld hl,$d000 + di + + ld a,4 +.transfer32k + push af + ld a,1 + call ReceiveData + + ld a,1 + call TransmitData + pop af + dec a + jr nz,.transfer32k + +;di +;.infi5 jr .infi5 +rst $00 +ENDC + +;----LINK TEST END---------------------------------------------------- + ;get the current game state + ld a,LGETGAMESTATE + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.joinGame + + ld hl,.bailOutAddress + xor a + call SetLinkBailOutAddress + + ld hl,gameState + ld bc,5 + xor a + call ReceiveData + + ld hl,levelState + ld bc,256 + ld a,LEVELSTATEBANK + call ReceiveData + + ;inventory + ld hl,inventory + ld bc,16 + xor a + call ReceiveData + + ;flight codes + ld hl,flightCode + ld bc,256 + ld a,FLIGHTCODEBANK + call ReceiveData + + ld hl,hero0_data + ld bc,HERODATASIZE*2 + xor a + call ReceiveData + + ld a,(hero1_data & $ff) + ld [curHeroAddressL],a + + ld a,[appomattoxMapIndex] + call ReceiveByte + + ;get map to join + call ReceiveByte + ld [joinMap],a + ld l,a + call ReceiveByte + ld [joinMap+1],a + ld h,a + +.setNextLevel + ld a,h + ld [curLevelIndex+1],a + ld a,l + ld [curLevelIndex],a + ld a,JOINDIR + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld a,1 + ld [timeToChangeLevel],a + + ret + +.bailOutAddress + rst $00 + +.drawMenu + push bc + push de + push hl + + xor a + ldio [backBufferReady],a + + ld hl,(bullet_y + (levelCheckRAM-L1101_Load2)) + ld a,[hl+] ;bullet_y + ld d,a + call ScrollSpritesUp ;reset bullet to top of screen + + ;scroll the bullet down to the correct position + ld hl,(cur_choice + (levelCheckRAM-L1101_Load2)) + ld a,[hl-] ;get cur choice + ld b,a ;a = a * 3 + rlca + add b + add 4 ;topmost is four tiles down + rlca ;times 8 pixels per tile + rlca + rlca + ld [hl+],a ;save new bullet_y + ld d,a + call ScrollSpritesDown + + ;-----draw 'New Game' text------------------------------------ + ld a,[(cur_choice + (levelCheckRAM-L1101_Load2))] + ld hl,$1400 ;origin tile 20,0 + or a + jr z,.highlightNewGame + + ;check for disabled + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr z,.newGameHighlightDone + + ;disable + ld l,6 + jr .newGameHighlightDone + +.highlightNewGame + ;highlighted + ld l,3 ;origin 20,3 + +.newGameHighlightDone + ld de,$0405 ;dest tile 3,5 + ld bc,$0d03 ;dest w,h 13x3 + call CinemaBlitRect + + ;-----draw 'Load Game' text----------------------------------- + ld hl,$1409 ;origin tile 20,9 + ld a,[(cur_choice + (levelCheckRAM-L1101_Load2))] + cp 1 + jr nz,.checkLoadDisabled + + ;highlighted + ld l,12 ;origin 20,12 + jr .loadGameHighlightDone + +.checkLoadDisabled + ld a,[(hasSavedGame + (levelCheckRAM-L1101_Load2))] + or a + jr nz,.loadGameHighlightDone + + ;disabled + ld l,15 ;origin 20,15 + +.loadGameHighlightDone + ld de,$0408 ;dest tile 4,8 + ld bc,$0d03 ;dest w,h 13x3 + call CinemaBlitRect + + ;-----draw 'Join Game' text----------------------------------- + ld hl,$2100 ;origin tile 33,0 + ld a,[(cur_choice + (levelCheckRAM-L1101_Load2))] + cp 2 + jr nz,.checkJoinDisabled + + ;highlighted + ld l,3 ;origin 33,3 + jr .joinGameHighlightDone + +.checkJoinDisabled + ld a,[(hasLinkMaster + (levelCheckRAM-L1101_Load2))] + or a + jr nz,.joinGameHighlightDone + + ;disabled + ld l,6 ;origin 33,6 + +.joinGameHighlightDone + ld de,$040b ;dest tile 4,11 + ld bc,$0d03 ;dest w,h 13x3 + call CinemaBlitRect + + pop hl + pop de + pop bc + ret + +L1101_LoadFinished: + +;some local vars +bullet_y: DS 1 +cur_choice: DS 1 +hasSavedGame: DS 1 +hasLinkMaster: DS 1 + +L1101_Map: +;--------------------------------------------------------------------- +L1101_Init: +;--------------------------------------------------------------------- + DW ((L1101_InitFinished - L1101_Init2)) ;size +L1101_Init2: + + ret + +L1101_InitFinished: + + +;--------------------------------------------------------------------- +L1101_Check: +;--------------------------------------------------------------------- + DW ((L1101_CheckFinished - L1101_Check) - 2) ;size +L1101_Check2: + ret +L1101_CheckFinished: + + +PRINT " 1101 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1101_LoadFinished - L1101_Load2) +PRINT " / " +PRINT (L1101_InitFinished - L1101_Init2) +PRINT " / " +PRINT (L1101_CheckFinished - L1101_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1102.asm b/Source/Levels/L1102.asm new file mode 100644 index 0000000..fbc2a18 --- /dev/null +++ b/Source/Levels/L1102.asm @@ -0,0 +1,934 @@ +; L1102.asm main intro cinema +; Generated 07.26.2000 by mlevel +; Modified 07.26.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +MUSICTEST EQU 0 + +NEXTLEVEL EQU $0313 +;NEXTLEVEL EQU $0013 +NEXTLEVELDIR EQU EXIT_D + +;--------------------------------------------------------------------- +SECTION "Level1102Section2",ROMX +;--------------------------------------------------------------------- +flour_bg:: + INCBIN "Data/Cinema/MainCharDialog/flour_triumph.bg" +skippy_bg:: + INCBIN "Data/Cinema/MainCharDialog/skippy_triumph.bg" + +dialog: +flour1_gtx: + INCBIN "Data/Dialog/Intro/flour1.gtx" + +flour2_gtx: + INCBIN "Data/Dialog/Intro/flour2.gtx" + +flour3_gtx: + INCBIN "Data/Dialog/Intro/flour3.gtx" + +flour4_gtx: + INCBIN "Data/Dialog/Intro/flour4.gtx" + +flour5_gtx: + INCBIN "Data/Dialog/Intro/flour5.gtx" + +flour6_gtx: + INCBIN "Data/Dialog/Intro/flour6.gtx" + +flour7_gtx: + INCBIN "Data/Dialog/Intro/flour7.gtx" + +skippy1_gtx: + INCBIN "Data/Dialog/Intro/skippy1.gtx" + +skippy2_gtx: + INCBIN "Data/Dialog/Intro/skippy2.gtx" + +skippy3_gtx: + INCBIN "Data/Dialog/Intro/skippy3.gtx" + +triumph_small_sp: + INCBIN "Data/Cinema/Intro/triumph_small.sp" + +bcs_vestigial_bg: + INCBIN "Data/Cinema/Intro/bcs_vestigial.bg" + +narrator_warroom_bg: + INCBIN "Data/Cinema/Intro/narrator_warroom.bg" + +nar_crewquarters_bg: + INCBIN "Data/Cinema/Intro/nar_crewquarters.bg" + +;--------------------------------------------------------------------- +SECTION "Level1102Section",ROMX +;--------------------------------------------------------------------- + +L1102_Contents:: + DW L1102_Load + DW L1102_Init + DW L1102_Check + DW L1102_Map + +moon_bg:: + INCBIN "Data/Cinema/Intro/moon.bg" +group_in_triumph_bg: + INCBIN "Data/Cinema/Intro/group_in_triumph.bg" +space_bg1_bg: + INCBIN "Data/Cinema/Intro/space_bg1.bg" +moontact_bg:: + INCBIN "Data/Cinema/Intro/moontact.bg" +tactmap_bg: + INCBIN "Data/Cinema/Intro/tactmap.bg" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1102_Load: + DW ((L1102_LoadFinished - L1102_Load2)) ;size +L1102_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + +IF MUSICTEST==0 + ld a,BANK(intro_cinema_gbm) + ld hl,intro_cinema_gbm + call InitMusic +ENDC + + ld a,BANK(moon_bg) + ld hl,moon_bg + call LoadCinemaBG + + +IF MUSICTEST +ld a,16 +call SetupFadeFromStandard +call WaitFade +.repeat + ld a,BANK(jungle_gbm) + ld hl,jungle_gbm + call InitMusic + +.getJoy0_5 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_5 + +.releaseJoy0_5 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_5 + + ld a,BANK(mysterious_gbm) + ld hl,mysterious_gbm + call InitMusic + +.getJoy0_55 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_55 + +.releaseJoy0_55 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_55 + + ld a,BANK(spaceish_gbm) + ld hl,spaceish_gbm + call InitMusic + +.getJoy0_6 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_6 + +.releaseJoy0_6 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_6 + + ld a,BANK(alarm_gbm) + ld hl,alarm_gbm + call InitMusic + +.getJoy0_7 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_7 + +.releaseJoy0_7 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_7 + + ld a,BANK(frosty_gbm) + ld hl,frosty_gbm + call InitMusic + +.getJoy0_8 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_8 + +.releaseJoy0_8 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_8 + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + +.getJoy0_9 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy0_9 + +.releaseJoy0_9 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy0_9 + + ld a,BANK(wedding_gbm) + ld hl,wedding_gbm + call InitMusic + +.getJoy1 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy1 + +.releaseJoy1 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy1 + + ld a,BANK(intro_cinema_gbm) + ld hl,intro_cinema_gbm + call InitMusic + +.getJoy2 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy2 + +.releaseJoy2 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy2 + + ld a,BANK(bs_gbm) + ld hl,bs_gbm + call InitMusic + +.getJoy3 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy3 + +.releaseJoy3 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy3 + + ld a,BANK(lady_flower_gbm) + ld hl,lady_flower_gbm + call InitMusic + +.getJoy4 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy4 + +.releaseJoy4 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy4 + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + +.getJoy5 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy5 + +.releaseJoy5 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy5 + + ld a,BANK(haiku_gbm) + ld hl,haiku_gbm + call InitMusic + +.getJoy6 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy6 + +.releaseJoy6 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy6 + + ld a,BANK(moon_base_ba_gbm) + ld hl,moon_base_ba_gbm + call InitMusic + +.getJoy7 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy7 + +.releaseJoy7 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy7 + + ld a,BANK(moon_base_haiku_gbm) + ld hl,moon_base_haiku_gbm + call InitMusic + +;.getJoy8 + ;ld a,1 + ;call Delay + ;ld a,[myJoy] + ;and %10000 + ;jr z,.getJoy8 + +;.releaseJoy8 + ;ld a,1 + ;call Delay + ;ld a,[myJoy] + ;or a + ;jr nz,.releaseJoy8 + + ;ld a,BANK(shroom_gbm) + ;ld hl,shroom_gbm + ;call InitMusic + +.getJoy9 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy9 + +.releaseJoy9 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy9 + + ld a,BANK(cowboy_gbm) + ld hl,cowboy_gbm + call InitMusic + +.getJoy10 + ld a,1 + call Delay + ld a,[myJoy] + and %10000 + jr z,.getJoy10 + +.releaseJoy10 + ld a,1 + call Delay + ld a,[myJoy] + or a + jr nz,.releaseJoy10 + + jp ((.repeat-L1102_Load2)+levelCheckRAM) + +ENDC + + ld a,BANK(triumph_small_sp) + ld hl,triumph_small_sp + call LoadCinemaSprite + + ld d,52 + call ScrollSpritesLeft + + ld d,144 + call ScrollSpritesDown + + ld a,BANK(bcs_vestigial_bg) + ld hl,bcs_vestigial_bg + call LoadCinemaTextBox + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ld de,((.endCinema - L1102_Load2) + levelCheckRAM) + call SetDialogSkip + ld de,((.showGroup - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + + ;scroll the view, waiting until left edge is at tile 6 before + ;raising the ship sprites to make it visible + ld a,$41 + ldio [scrollSpeed],a + ld a,30 + ld [camera_i],a + + ld c,120 + ld b,1 ;flag that we need to show ship +.waitScroll + ld a,1 + call Delay + + ld a,[mapLeft] + cp 6 + jr nz,.afterShowShip + ld a,b + or a + jr z,.afterShowShip + + ld b,0 + ld d,104 + call ScrollSpritesUp + call GfxShowStandardTextBox + +.afterShowShip + dec c + jr nz,.waitScroll + +.showGroup + call ClearDialog + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + call ResetSprites + + ld de,((.flourDialog1 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(narrator_warroom_bg) + ld hl,narrator_warroom_bg + call LoadCinemaTextBox + call GfxShowStandardTextBox + call ((.showGroupInTriumph - L1102_Load2) + levelCheckRAM) + +.flourDialog1 + ld a,1 + call SetupFadeToBlack + call WaitFade + + call ClearDialog + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld de,((.flourDialog2 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour1_gtx) + ld c,0 + ld de,flour1_gtx + call ShowDialogAtBottomNoWait + + ld b,5 ;5*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.flourDialog2 + call ClearDialog + ld a,BANK(flour2_gtx) + ld c,0 + ld de,flour2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.tactMap1 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld b,2 ;3*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.tactMap1 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + + call ClearDialog + + ;----tactical map of our position----------------------------- + call ((.loadTactMap - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + + ld de,((.flour3 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,40 + call ((.animateMap - L1102_Load2) + levelCheckRAM) + +.flour3 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + + ld de,((.tactMap2 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour3_gtx) + ld c,0 + ld de,flour3_gtx + call ShowDialogAtBottomNoWait + + ld b,5 ;5*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.tactMap2 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + call ClearDialog + call ((.loadTactMap - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + + ld de,((.showGroup2 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + ld a,60 + call ((.animateMap - L1102_Load2) + levelCheckRAM) + +.showGroup2 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + ld de,((.flour4 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + call ((.showGroupInTriumph - L1102_Load2) + levelCheckRAM) + +.flour4 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + ld de,((.moontact - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour4_gtx) + ld c,0 + ld de,flour4_gtx + call ShowDialogAtBottomNoWait + + ld b,6 ;6*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.moontact + call ClearDialog + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + ld a,BANK(moontact_bg) + ld hl,moontact_bg + call LoadCinemaBG + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + ld de,((.skippy1 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + ld a,40 + call ((.animateMap - L1102_Load2) + levelCheckRAM) +.skippy1 + call ((.fadeToBlack - L1102_Load2) + levelCheckRAM) + call ((.loadSkippy - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + + ld a,BANK(skippy1_gtx) + ld c,0 + ld de,skippy1_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour5 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld b,4 + call ((.animateSkippy - L1102_Load2) + levelCheckRAM) + +.flour5 + call ClearDialog + call ((.fadeToBlack1 - L1102_Load2) + levelCheckRAM) + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L1102_Load2) + levelCheckRAM) + ld de,((.skippy2 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour5_gtx) + ld c,0 + ld de,flour5_gtx + call ShowDialogAtBottomNoWait + + ld b,3 ;6*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.skippy2 + call ClearDialog + call ((.fadeToBlack1 - L1102_Load2) + levelCheckRAM) + call ((.loadSkippy - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L1102_Load2) + levelCheckRAM) + + ld a,BANK(skippy2_gtx) + ld c,0 + ld de,skippy2_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour6 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld b,3 + call ((.animateSkippy - L1102_Load2) + levelCheckRAM) + +.flour6 + call ClearDialog + call ((.fadeToBlack1 - L1102_Load2) + levelCheckRAM) + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L1102_Load2) + levelCheckRAM) + ld de,((.skippy3 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour6_gtx) + ld c,0 + ld de,flour6_gtx + call ShowDialogAtBottomNoWait + + ld b,5 ;5*50 delay + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.skippy3 + call ClearDialog + call ((.fadeToBlack1 - L1102_Load2) + levelCheckRAM) + call ((.loadSkippy - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L1102_Load2) + levelCheckRAM) + + ld a,BANK(skippy3_gtx) + ld c,0 + ld de,skippy3_gtx + call ShowDialogAtBottomNoWait + + ld de,((.flour7 - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld b,5 + call ((.animateSkippy - L1102_Load2) + levelCheckRAM) + +.flour7 + call ClearDialog + call ((.fadeToBlack1 - L1102_Load2) + levelCheckRAM) + call ((.loadFlour - L1102_Load2) + levelCheckRAM) + call ((.fadeFromBlack1 - L1102_Load2) + levelCheckRAM) + ld de,((.endCinema - L1102_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(flour7_gtx) + ld c,0 + ld de,flour7_gtx + call ShowDialogAtBottomNoWait + + ld b,2 + call ((.animateFlour - L1102_Load2) + levelCheckRAM) + +.endCinema + call ClearDialog + ld a,BANK(nar_crewquarters_bg) + ld hl,nar_crewquarters_bg + call LoadCinemaTextBox + + ld hl,2054 ;BA + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_BA_FLAG + ld [hero0_type],a + ld hl,$0409 + ld a,l + ld [hero0_enterLevelLocation],a + ld a,h + ld [hero0_enterLevelLocation+1],a + + ld hl,RA_CINDEX + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_BS_FLAG + ld [hero1_type],a + + ld hl,NEXTLEVEL + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,NEXTLEVELDIR + ld [hero0_enterLevelFacing],a + ld a,1 + ld [timeToChangeLevel],a + + ld a,16 + call SetupFadeToStandard + call WaitFade + + ret + +.loadFlour + ld a,BANK(flour_bg) + ld hl,flour_bg + call LoadCinemaBG + ret + +.loadSkippy + ld a,BANK(skippy_bg) + ld hl,skippy_bg + call LoadCinemaBG + ret + +.loadTactMap + ld a,BANK(tactmap_bg) + ld hl,tactmap_bg + call LoadCinemaBG + ret + +.fadeToBlack + ld a,16 + call SetupFadeToBlack + call WaitFade + ret + +.fadeFromBlack + ld a,16 + call SetupFadeFromBlack + call WaitFade + ret + +.fadeToBlack1 + ld a,16 + call SetupFadeToBlack + call WaitFade + ret + +.fadeFromBlack1 + ld a,16 + call SetupFadeFromBlack + call WaitFade + ret + +.showGroupInTriumph + ld a,BANK(group_in_triumph_bg) + ld hl,group_in_triumph_bg + call LoadCinemaBG + + call ((.fadeFromBlack - L1102_Load2) + levelCheckRAM) + + ld a,90 + call Delay + + ret + +.animateFlour + ;b already set up with # of loops +.flourEyes + ld c,10 + +.flourTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 1 + ld a,4 + jr nz,.animate + ld a,1 + +.animate + ;animate mouth + ld bc,$0502 + ld de,$0906 + ld hl,$1400 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.flourTalk + + ;animate eyes + push bc + ld a,3 + ld bc,$0603 + ld de,$0903 + ld hl,$1900 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.flourEyes + + ;open eyes at end + ld a,1 + ld bc,$0603 + ld de,$0903 + ld hl,$1900 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + ret + +.animateSkippy +.skippyEyes + ld c,10 + +.skippyTalk + push bc + ld a,5 + call Delay + + ld a,b + cp 3 + ld a,3 + jr nc,.animateSkippyMouth + ld a,1 + +.animateSkippyMouth + ;animate mouth + ld bc,$0402 + ld de,$0609 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec c + jr nz,.skippyTalk + + ;animate eyes + push bc + ld a,5 + ld bc,$0403 + ld de,$0606 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec b + jr nz,.skippyEyes + + ;open eyes at end + ld a,1 + ld bc,$0403 + ld de,$0606 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + ld a,10 + call Delay + + ret + +.animateMap + ld h,a + ld l,0 + ld de,0 + + ld c,6 + +.animateMapLoop + push bc + ld a,10 + call Delay + ld bc,$1412 + call CinemaBlitRect + push hl + ld hl,((.mapSound - L1102_Load2) + levelCheckRAM) + call PlaySound + pop hl + ld a,10 + call Delay + push hl + ld hl,$1400 + call CinemaBlitRect + pop hl + pop bc + dec c + jr nz,.animateMapLoop + ret + +.mapSound + DB 1,$00,$b8,$f0,$80,$c6 + + +L1102_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1102_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1102_Init: + DW ((L1102_InitFinished - L1102_Init2)) ;size +L1102_Init2: + ret + +L1102_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1102_Check: + DW ((L1102_CheckFinished - L1102_Check2)) ;size +L1102_Check2: + ret + +L1102_CheckFinished: +PRINT "1102 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1102_LoadFinished - L1102_Load2) +PRINT " / " +PRINT (L1102_InitFinished - L1102_Init2) +PRINT " / " +PRINT (L1102_CheckFinished - L1102_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1103.asm b/Source/Levels/L1103.asm new file mode 100644 index 0000000..a5e1a47 --- /dev/null +++ b/Source/Levels/L1103.asm @@ -0,0 +1,782 @@ +; L1103.asm wedding / gyro pops from tree +; Generated 08.03.2000 by mlevel +; Modified 08.03.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;from L0505 +VAR_HERO EQU 11 + + + +;--------------------------------------------------------------------- +SECTION "Level1103Gfx1",ROMX +;--------------------------------------------------------------------- +gyro_tree_bg: + INCBIN "Data/Cinema/Wedding/gyro_tree.bg" + +gyro_costume_sp: + INCBIN "Data/Cinema/Wedding/gyro_costume.sp" + +gang_watches_wedding_bg: + INCBIN "Data/Cinema/Wedding/gang_watches_wedding.bg" + +;--------------------------------------------------------------------- +SECTION "Level1103Gfx2",ROMX +;--------------------------------------------------------------------- +preacher_bg: + INCBIN "Data/Cinema/Wedding/preacher.bg" + +wedding_panoramic_bg: + INCBIN "Data/Cinema/Wedding/wedding_panoramic.bg" + +flour_at_wedding_bg: + INCBIN "Data/Cinema/Wedding/flour_at_wedding.bg" + +;--------------------------------------------------------------------- +SECTION "Level1103Gfx3",ROMX +;--------------------------------------------------------------------- +flower_at_wedding_bg: + INCBIN "Data/Cinema/Wedding/flower_at_wedding.bg" + +gang_watches_front_bg:: + INCBIN "Data/Cinema/Wedding/gang_watches_front.bg" + +gyro_big_bg: + INCBIN "Data/Cinema/Wedding/gyro_big.bg" + +;--------------------------------------------------------------------- +SECTION "Level1103Dialog",ROMX +;--------------------------------------------------------------------- + +dialog: +preacher_blah_gtx: + INCBIN "Data/Dialog/Wedding/preacher_blah.gtx" + +preacher_reasons_gtx: + INCBIN "Data/Dialog/Wedding/preacher_reasons.gtx" + +hero_reasons_gtx: + INCBIN "Data/Dialog/Wedding/hero_reasons.gtx" + +captain_thanks_gtx: + INCBIN "Data/Dialog/Wedding/captain_thanks.gtx" + +captain_cake_gtx: + INCBIN "Data/Dialog/Wedding/captain_cake.gtx" + +lady_byallmeans_gtx: + INCBIN "Data/Dialog/Wedding/lady_byallmeans.gtx" + +lady_radio_gtx: + INCBIN "Data/Dialog/Wedding/lady_radio.gtx" + +preacher_takebegonia_gtx: + INCBIN "Data/Dialog/Wedding/preacher_takebegonia.gtx" + +gyro_bs_gtx: + INCBIN "Data/Dialog/Wedding/gyro_bs.gtx" + +preacher_takesack_gtx: + INCBIN "Data/Dialog/Wedding/preacher_takesack.gtx" + +gyro_ba_gtx: + INCBIN "Data/Dialog/Wedding/gyro_ba.gtx" + +preacher_pronounce_gtx: + INCBIN "Data/Dialog/Wedding/preacher_pronounce.gtx" + +gyro_haiku_gtx: + INCBIN "Data/Dialog/Wedding/gyro_haiku.gtx" + +preacher_married_gtx: + INCBIN "Data/Dialog/Wedding/preacher_married.gtx" + +gyro_notsofast_gtx: + INCBIN "Data/Dialog/Wedding/gyro_notsofast.gtx" + +captain_why_gtx: + INCBIN "Data/Dialog/Wedding/captain_why.gtx" + +gyro_reveals_gtx: + INCBIN "Data/Dialog/Wedding/gyro_reveals.gtx" + +captain_thankyou_gtx: + INCBIN "Data/Dialog/Wedding/captain_thankyou.gtx" + +gyro_notyummy_gtx: + INCBIN "Data/Dialog/Wedding/gyro_notyummy.gtx" + +gyro_recall_gtx: + INCBIN "Data/Dialog/Wedding/gyro_recall.gtx" + +gyro_surrender_gtx: + INCBIN "Data/Dialog/Wedding/gyro_surrender.gtx" + +gyro_difficult_gtx: + INCBIN "Data/Dialog/Wedding/gyro_difficult.gtx" + +captain_okay_gtx: + INCBIN "Data/Dialog/Wedding/captain_okay.gtx" + +lady_dontbesilly_gtx: + INCBIN "Data/Dialog/Wedding/lady_dontbesilly.gtx" + + +;--------------------------------------------------------------------- +SECTION "Level1103Section",ROMX +;--------------------------------------------------------------------- + +L1103_Contents:: + DW L1103_Load + DW L1103_Init + DW L1103_Check + DW L1103_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1103_Load: + DW ((L1103_LoadFinished - L1103_Load2)) ;size +L1103_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(wedding_panoramic_bg) + ld hl,wedding_panoramic_bg + call LoadCinemaBG + + ld a,EXIT_D + ld hl,$1103 + call YankRemotePlayer + + ;set state of 0505 in case I was yanked from elsewhere + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,2 ;STATE_AFTERWEDDING + ld [levelState+$55],a + + xor a + ld [hero0_health],a + ld [hero1_health],a + + ld a,15 + call SetupFadeFromStandard + call WaitFade + + ld de,((.endCinema-L1103_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.preacher_blah-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + + ld a,BANK(wedding_panoramic_bg) + + ld a,80 + call Delay + +.preacher_blah + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + + ld a,BANK(preacher_bg) + ld hl,preacher_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld de,((.preacher_reasons-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM preacher_blah_gtx + + ld d,3 + LONGCALLNOARGS AnimatePreacher + +.preacher_reasons + ld c,0 + DIALOGBOTTOM preacher_reasons_gtx + + ld de,((.hero_reasons-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimatePreacher + +.hero_reasons + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + ld de,((.captainThanks-L1103_Load2)+levelCheckRAM) + call SetDialogForward + ld a,[levelVars+VAR_HERO] + ld [dialogSpeakerIndex],a + cp HERO_BS_FLAG + jr z,.hero_bs + + cp HERO_HAIKU_FLAG + jr z,.hero_haiku + +.hero_ba + ld a,BANK(ba_bg) + ld hl,ba_bg + call LoadCinemaBG + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM hero_reasons_gtx + ld d,4 + LONGCALLNOARGS AnimateBA + jr .captainThanks + +.hero_bs + ld a,BANK(bs_bg) + ld hl,bs_bg + call LoadCinemaBG + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM hero_reasons_gtx + ld d,4 + LONGCALLNOARGS AnimateBS + jr .captainThanks + +.hero_haiku + ld a,BANK(haiku_bg) + ld hl,haiku_bg + call LoadCinemaBG + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM hero_reasons_gtx + LONGCALLNOARGS AnimateHaiku + +.captainThanks + call ((.loadCaptain-L1103_Load2)+levelCheckRAM) + + ld de,((.captainCake-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_thanks_gtx + ld d,4 + LONGCALLNOARGS AnimateCaptainAtWedding + +.captainCake + ld c,0 + DIALOGBOTTOM captain_cake_gtx + ld de,((.lady_byallmeans-L1103_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateCaptainAtWedding + +.lady_byallmeans + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + + ld a,BANK(flower_at_wedding_bg) + ld hl,flower_at_wedding_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM lady_byallmeans_gtx + + ld de,((.lady_radio-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateLadyAtWedding + +.lady_radio + ld c,0 + DIALOGBOTTOM lady_radio_gtx + ld de,((.minutesLater-L1103_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateLadyAtWedding + +.minutesLater + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + + ld a,BANK(gang_watches_front_bg) + ld hl,gang_watches_front_bg + call LoadCinemaBG + + ld de,((.preacherTakeBegonia-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld a,90 + call Delay + +.preacherTakeBegonia + ld hl,$0704 + call ((.loadGang-L1103_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM preacher_takebegonia_gtx + + ld de,((.gyro_bs-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.gyro_bs + call ((.gyroPopOut-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM gyro_bs_gtx + + ld de,((.takeCaptain-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,11 + call ((.animateGyroSprite-L1103_Load2)+levelCheckRAM) + +.takeCaptain + ld hl,$1400 + call ((.loadGang-L1103_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM preacher_takesack_gtx + + ld de,((.gyro_ba-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.gyro_ba + call ((.gyroPopOut-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM gyro_ba_gtx + + ld de,((.pronounce-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,11 + call ((.animateGyroSprite-L1103_Load2)+levelCheckRAM) + +.pronounce + ld hl,$1406 + call ((.loadGang-L1103_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM preacher_pronounce_gtx + + ld de,((.gyro_haiku-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.gyro_haiku + call ((.gyroPopOut-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM gyro_haiku_gtx + + ld de,((.married-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,11 + call ((.animateGyroSprite-L1103_Load2)+levelCheckRAM) + +.married + ld hl,$140c + call ((.loadGang-L1103_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM preacher_married_gtx + + ld de,((.notSoFast-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.notSoFast + call ((.setupGyroSpritesInOpen-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM gyro_notsofast_gtx + + ld de,((.captainWhyNot-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,5 + call ((.animateGyroSprite-L1103_Load2)+levelCheckRAM) + +.captainWhyNot + call ((.loadCaptain-L1103_Load2)+levelCheckRAM) + + ld de,((.because-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_why_gtx + ld d,2 + LONGCALLNOARGS AnimateCaptainAtWedding + +.because + call ((.setupGyroSpritesInOpen-L1103_Load2)+levelCheckRAM) + ld a,30 + call Delay + + call ((.shedCostume-L1103_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM gyro_reveals_gtx + + ld de,((.captainThankYou-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,11 + call ((.animateGyroSprite-L1103_Load2)+levelCheckRAM) + +.captainThankYou + call ((.loadCaptain-L1103_Load2)+levelCheckRAM) + + ld de,((.notYummy-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_thankyou_gtx + ld d,3 + LONGCALLNOARGS AnimateCaptainAtWedding + +.notYummy + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + + ld a,BANK(gyro_big_bg) + ld hl,gyro_big_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM gyro_notyummy_gtx + + ld de,((.recall-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateGyroAtWedding + +.recall + ld c,0 + DIALOGBOTTOM gyro_recall_gtx + + ld de,((.surrender-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateGyroAtWedding + +.surrender + ld c,0 + DIALOGBOTTOM gyro_surrender_gtx + + ld de,((.difficult-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateGyroAtWedding + +.difficult + ld c,0 + DIALOGBOTTOM gyro_difficult_gtx + + ld de,((.captainOkay-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateGyroAtWedding + +.captainOkay + call ((.loadCaptain-L1103_Load2)+levelCheckRAM) + + ld de,((.ladyDontBeSilly-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_okay_gtx + ld d,3 + LONGCALLNOARGS AnimateCaptainAtWedding + +.ladyDontBeSilly + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + + ld a,BANK(flower_at_wedding_bg) + ld hl,flower_at_wedding_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM lady_dontbesilly_gtx + + ld de,((.endCinema-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateLadyAtWedding + +.endCinema + + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + + ld hl,2400 ;captain flour + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_FLOUR_FLAG + ld [hero0_type],a + + ld hl,2398 ;haiku + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_FLOWER_FLAG + ld [hero1_type],a + + ld a,EXIT_S + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$0604 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.shedCostume + ld b,30 +.shedCostumeLoop + ;move sprites 12-29 3 pixels right and 1 down + ld c,18 + ld de,3 + ld hl,spriteOAMBuffer+12*4 +.shedCostumeSpriteLoop + inc [hl] + inc hl + inc [hl] + inc [hl] + inc [hl] + add hl,de + dec c + jr nz,.shedCostumeSpriteLoop + + ld a,1 + call Delay + dec b + jr nz,.shedCostumeLoop + ret + +.loadCaptain + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + call ResetSprites + + ld a,BANK(flour_at_wedding_bg) + ld hl,flour_at_wedding_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + ret + +.setupGyroSpritesInOpen + call ((.prepGyroSprites-L1103_Load2)+levelCheckRAM) + ld d,$4c + call ScrollSpritesRight + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + ret + +.animateGyroSprite + ;ld c,11 +.animateGyroSpriteLoop + ld b,8 + call ((.shiftSpritePatterns-L1103_Load2)+levelCheckRAM) + ld a,5 + call Delay + ld b,-8 + call ((.shiftSpritePatterns-L1103_Load2)+levelCheckRAM) + ld a,5 + call Delay + dec c + jr nz,.animateGyroSpriteLoop + + ld a,50 + call Delay + ret + +.shiftSpritePatterns + push bc + ld hl,spriteOAMBuffer+4*4+2 + ld de,4 + ld c,4 +.shiftSpriteLoop + ld a,[hl] + add b + ld [hl],a + add hl,de + dec c + jr nz,.shiftSpriteLoop + pop bc + ret + +.loadGang + push hl + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ClearDialog + call ResetSprites + + ld a,BANK(gang_watches_wedding_bg) + ld hl,gang_watches_wedding_bg + call LoadCinemaBG + pop hl + + ld bc,$0d06 + ld de,$0704 + call CinemaBlitRect + ret + +.gyroPopOut + call ((.prepGyroSprites-L1103_Load2)+levelCheckRAM) + + call ((.quickFromBlack-L1103_Load2)+levelCheckRAM) + + ld de,((.poppedOut-L1103_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + + ld c,48 +.popOutLoop + ld d,1 + call ScrollSpritesRight + ld a,2 + call Delay + dec c + jr nz,.popOutLoop + +.poppedOut + ld de,0 + call SetDialogForward + + ld a,[spriteOAMBuffer+1] ;1st sprite xpos should be $4c + cpl + add $4d + ld d,a + call ScrollSpritesRight + + ret + +.prepGyroSprites + call ((.quickToBlack-L1103_Load2)+levelCheckRAM) + call ResetSprites + ld a,BANK(gyro_tree_bg) + ld hl,gyro_tree_bg + call LoadCinemaBG + + ld a,BANK(gyro_costume_sp) + ld hl,gyro_costume_sp + call LoadCinemaSprite + + ;kill sprites 8-11 (alternate mouth) + ld hl,spriteOAMBuffer + 4 * 8 + xor a + ld de,3 + ld c,4 +.kill8to11 + ld [hl+],a ;sprite 8 y pos to zero + add hl,de + dec c + jr nz,.kill8to11 + + ;move sprites 12-29 40 pixels up and 8 pixels left + ld c,18 +.scootCostume + ld a,[hl] + sub 40 + ld [hl+],a + ld a,[hl] + sub 8 + ld [hl],a + add hl,de + dec c + jr nz,.scootCostume + + ld d,20 + call ScrollSpritesRight + ld d,40 + call ScrollSpritesDown + + ;set the priority of all sprites to appear behind BG + ld hl,spriteOAMBuffer + 3 + ld de,3 + ld c,40 +.setPriorityLoop + ld a,[hl] + or %10000000 + ld [hl+],a + add hl,de + dec c + jr nz,.setPriorityLoop + + ret + + +.quickToBlack + call BlackoutPalette + call ClearDialog + jp ResetSprites + +.quickFromBlack + ld a,1 + jp SetupFadeFromBlack + +L1103_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1103_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1103_Init: + DW ((L1103_InitFinished - L1103_Init2)) ;size +L1103_Init2: + ret + +L1103_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1103_Check: + DW ((L1103_CheckFinished - L1103_Check2)) ;size +L1103_Check2: + ret + +L1103_CheckFinished: +PRINT "1103 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1103_LoadFinished - L1103_Load2) +PRINT " / " +PRINT (L1103_InitFinished - L1103_Init2) +PRINT " / " +PRINT (L1103_CheckFinished - L1103_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1104.asm b/Source/Levels/L1104.asm new file mode 100644 index 0000000..856f65d --- /dev/null +++ b/Source/Levels/L1104.asm @@ -0,0 +1,528 @@ +; L1104.asm To Space Station Apocalypse +; Generated 04.22.2001 by mlevel +; Modified 04.22.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_TAKEOFFPOS EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level1104Gfx1",ROMX +;--------------------------------------------------------------------- +appx_takeoff_bg: + INCBIN "Data/Cinema/Ending/appx_takeoff.bg" + +station_tactical_bg:: + INCBIN "Data/Cinema/Ending/station_tactical.bg" + +;--------------------------------------------------------------------- +SECTION "Level1104Gfx2",ROMX +;--------------------------------------------------------------------- +small_station_approach_bg: + INCBIN "Data/Cinema/Ending/small_station_approach.bg" + +big_station_approach_bg: + INCBIN "Data/Cinema/Ending/big_station_approach.bg" + +;--------------------------------------------------------------------- +SECTION "Level1104Gfx3",ROMX +;--------------------------------------------------------------------- +appx_takeoff_sprites_sp: + INCBIN "Data/Cinema/Ending/appx_takeoff_sprites.sp" + +station_tactical_sprites_sp: + INCBIN "Data/Cinema/Ending/station_tactical_sprites.sp" + +small_station_sprites_sp: + INCBIN "Data/Cinema/Ending/small_station_sprites.sp" + +big_station_sprites_sp: + INCBIN "Data/Cinema/Ending/big_station_sprites.sp" + + +;--------------------------------------------------------------------- +SECTION "Level1104Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1104_whereisgyro_gtx: + INCBIN "Data/Dialog/Apocalypse/L1104_whereisgyro.gtx" + +L1104_station_gtx: + INCBIN "Data/Dialog/Apocalypse/L1104_station.gtx" + +L1104_apocalypse_gtx: + INCBIN "Data/Dialog/Apocalypse/L1104_apocalypse.gtx" + +L1104_letsgo_gtx: + INCBIN "Data/Dialog/Apocalypse/L1104_letsgo.gtx" + + +L1104_Contents:: + DW L1104_Load + DW L1104_Init + DW L1104_Check + DW L1104_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1104_Load: + DW ((L1104_LoadFinished - L1104_Load2)) ;size +L1104_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,EXIT_D + ld hl,$1104 + call YankRemotePlayer + + ld a,BANK(intro_cinema_gbm) + ld hl,intro_cinema_gbm + call InitMusic + + ld a,$b7 + ld [appomattoxMapIndex],a + + xor a + ld [levelVars+VAR_TAKEOFFPOS],a + + ;set fg tile map for first three chars to allow characters in + ;dialog + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,$ff + ld hl,$d701 + ld [hl+],a + inc a + ld [hl+],a + inc a + ld [hl+],a + ld hl,$dd01 ;fg attributes + ld [hl],2 ;red + inc hl + ld [hl],3 ;blue + inc hl + ld [hl],4 ;green + + ld de,((.endCinema-L1104_Load2)+levelCheckRAM) + call SetDialogSkip + + ld a,BANK(appx_takeoff_bg) + ld hl,appx_takeoff_bg + call LoadCinemaBG + + ld a,BANK(appx_takeoff_sprites_sp) + ld hl,appx_takeoff_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + ld de,((.bs1-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + + ld a,15 + call SetupFadeFromStandard + + ld c,3 + DIALOGBOTTOM L1104_whereisgyro_gtx + + ld a,150 + call Delay + +.bs1 + ld de,((.bs2-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,2 + DIALOGBOTTOM L1104_station_gtx + + ld a,150 + call Delay + +.bs2 + call ((.quickToBlack-L1104_Load2)+levelCheckRAM) + + ld a,BANK(station_tactical_bg) + ld hl,station_tactical_bg + call LoadCinemaBG + + ld a,BANK(station_tactical_sprites_sp) + ld hl,station_tactical_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + call ((.quickFromBlack-L1104_Load2)+levelCheckRAM) + + ld de,((.ba-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + + ld c,2 + DIALOGBOTTOM L1104_apocalypse_gtx + + ;blink station id + ld c,15 + +.blink + ld a,10 + call Delay + + push bc + ld b,128 + ld c,10 + call ((.addSpriteYPos-L1104_Load2)+levelCheckRAM) + pop bc + + dec c + jr nz,.blink + +.ba + call ((.quickToBlack-L1104_Load2)+levelCheckRAM) + + ld a,BANK(appx_takeoff_bg) + ld hl,appx_takeoff_bg + call LoadCinemaBG + + ld a,BANK(appx_takeoff_sprites_sp) + ld hl,appx_takeoff_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + ld de,((.flyAway-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + call ((.quickFromBlack-L1104_Load2)+levelCheckRAM) + + ld c,1 + DIALOGBOTTOM L1104_letsgo_gtx + + ld a,75 + call Delay + + ld b,24 + call ((.setAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + + ld a,75 + call Delay + +.flyAway + call ClearDialog + + ld b,24 + call ((.setAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + + ld de,((.approachSmall-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,30 +.takeOff + push af + call ((.takeOffUpdate-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.takeOff + + ;retract landing gear + ld b,48 + call ((.setAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + + ld a,10 +.takeOff2 + push af + call ((.takeOffUpdate-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.takeOff2 + + ld a,35 +.takeOff3 + push af + call ((.takeOffUpdate-L1104_Load2)+levelCheckRAM) + call ((.takeOffUpdateX-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.takeOff3 + +.approachSmall + call ((.quickToBlack-L1104_Load2)+levelCheckRAM) + + ld a,BANK(small_station_approach_bg) + ld hl,small_station_approach_bg + call LoadCinemaBG + + ld a,BANK(small_station_sprites_sp) + ld hl,small_station_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + call ((.quickFromBlack-L1104_Load2)+levelCheckRAM) + + ld de,((.approachBig-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,75 +.approachSmallLoop + push af + call ((.updateSmallApproach-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.approachSmallLoop + + ld a,30 +.approachSmallLoop2 + push af + call ((.updateSmallApproachNoThrust-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.approachSmallLoop2 + +.approachBig + call ((.quickToBlack-L1104_Load2)+levelCheckRAM) + + ld a,BANK(big_station_approach_bg) + ld hl,big_station_approach_bg + call LoadCinemaBG + + ld a,BANK(big_station_sprites_sp) + ld hl,big_station_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + call ((.quickFromBlack-L1104_Load2)+levelCheckRAM) + + ld de,((.endCinema-L1104_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,20 +.approachBigLoop + push af + call ((.updateBigApproach-L1104_Load2)+levelCheckRAM) + pop af + dec a + jr nz,.approachBigLoop + + ld a,60 + call Delay + +.endCinema + ld a,15 + call SetupFadeToStandard + call WaitFade + ;call ((.quickToBlack-L1104_Load2)+levelCheckRAM) + call ClearDialogSkipForward + + ld a,EXIT_U + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + ld a,29 + ld [hero0_enterLevelLocation],a + ld [hero1_enterLevelLocation],a + ld a,59 + ld [hero0_enterLevelLocation+1],a + ld [hero1_enterLevelLocation+1],a + + ld hl,$1100 + call SetJoinMap + call SetRespawnMap + + ld hl,$0711 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.updateBigApproach + ld a,3 + call Delay + + ld b,$ff + ld c,5 + call ((.addSpriteYPos-L1104_Load2)+levelCheckRAM) + ld b,$ff + ld c,5 + call ((.addSpriteXPos-L1104_Load2)+levelCheckRAM) + ret + +.updateSmallApproach + ld a,1 + call Delay + + ld b,10 + call ((.setLittleAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + + ld a,1 + call Delay + + ld b,6 + call ((.setLittleAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + + ld hl,spriteOAMBuffer+3*4+1 ;x pos + inc [hl] + ld hl,spriteOAMBuffer+4*4+1 ;x pos + inc [hl] + ret + +.updateSmallApproachNoThrust + ld a,2 + call Delay + + ld hl,spriteOAMBuffer+3*4+1 ;x pos + inc [hl] + ld hl,spriteOAMBuffer+4*4+1 ;x pos + inc [hl] + ret + +.takeOffUpdateX + ;ld a,[levelVars+VAR_TAKEOFFPOS] + ;cp 128 + ;jr c,.thrustSet + ;xor a +;.thrustSet + ld b,2 + ld c,12 + call ((.addSpriteXPos-L1104_Load2)+levelCheckRAM) + + ldio a,[updateTimer] + and %10 + jr z,.thrustOff + + ld b,72 + call ((.setAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + ret + +.thrustOff + ld b,48 + call ((.setAppxSpriteFrame-L1104_Load2)+levelCheckRAM) + ret + +.takeOffUpdate + ld a,2 + call Delay + + ld hl,levelVars+VAR_TAKEOFFPOS + ld a,[hl] + inc [hl] + ;and 63 + ld hl,((.shipSineTable-L1104_Load2)+levelCheckRAM) + call Lookup8 + dec a + ld b,a + ld c,12 + call ((.addSpriteYPos-L1104_Load2)+levelCheckRAM) + ret + +.addSpriteXPos + ld hl,spriteOAMBuffer+1 + jr .addSpritePos + +.addSpriteYPos + ;add b to ypos of all c sprites + ld hl,spriteOAMBuffer +.addSpritePos + ld de,4 +.add128Loop + ld a,[hl] + add b + ld [hl],a + add hl,de + dec c + jr nz,.add128Loop + ret + +.setLittleAppxSpriteFrame + ld hl,spriteOAMBuffer+3*4+2 + ld [hl],b + inc b + inc b + ld hl,spriteOAMBuffer+4*4+2 + ld [hl],b + ret + +.setAppxSpriteFrame + ld hl,spriteOAMBuffer+2 + ld de,4 + ld c,12 +.setAppxSpriteFrameLoop + ld [hl],b + add hl,de + inc b + inc b + dec c + jr nz,.setAppxSpriteFrameLoop + ret + +.quickToBlack + call ClearDialog + call ResetSprites + ld a,1 + call SetupFadeToBlack + call WaitFade + ret + +.quickFromBlack + ld a,1 + call SetupFadeFromBlack + call WaitFade + ret + +.shipSineTable + ;DB $ff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 + ;DB 0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0 + ;DB 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$ff + ;DB 0,0,$ff,0,0,$ff,0,0,$ff,0,$ff,0,0,$ff,0,0 + DB 0, 0, 0, 0, 0, 0, -1, -1, -2, -2, -3 + DB -3, -3, -3, -2, -2, -2, -1, -1 + DB 0, 0, 0, 1, 1, 1, 2, 2 + DB 2, 3, 3, 3, 3, 3, 3, 3 + DB 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0 + DB 0, -1, -1, -2, -2, -2, -3, -3, -3, -4, -4, -4, -4, -4, -4, -4 + DB -4, -4, -4, -4, -4, -4, -4, -4 + +L1104_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1104_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1104_Init: + DW ((L1104_InitFinished - L1104_Init2)) ;size +L1104_Init2: + ret + +L1104_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1104_Check: + DW ((L1104_CheckFinished - L1104_Check2)) ;size +L1104_Check2: + ret + +L1104_CheckFinished: +PRINT "1104 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1104_LoadFinished - L1104_Load2) +PRINT " / " +PRINT (L1104_InitFinished - L1104_Init2) +PRINT " / " +PRINT (L1104_CheckFinished - L1104_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1105.asm b/Source/Levels/L1105.asm new file mode 100644 index 0000000..9f9459c --- /dev/null +++ b/Source/Levels/L1105.asm @@ -0,0 +1,260 @@ +; L1105.asm Save game screen +; Generated 05.09.2001 by mlevel +; Modified 05.09.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_SELECTION EQU 0 + +;--------------------------------------------------------------------- +SECTION "Level1105Gfx1",ROMX +;--------------------------------------------------------------------- +savegame_bg: + INCBIN "Data/Cinema/Appomattox/savegame.bg" + +cantsave_bg: + INCBIN "Data/Cinema/Appomattox/cantsave.bg" + +;--------------------------------------------------------------------- +SECTION "Level1105Gfx2",ROMX +;--------------------------------------------------------------------- +cantsave_flying_bg: + INCBIN "Data/Cinema/Appomattox/cantsave_flying.bg" + +;--------------------------------------------------------------------- +SECTION "Level1105Section",ROMX +;--------------------------------------------------------------------- + +L1105_Contents:: + DW L1105_Load + DW L1105_Init + DW L1105_Check + DW L1105_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1105_Load: + DW ((L1105_LoadFinished - L1105_Load2)) ;size +L1105_Load2: + ld a,[amLinkMaster] + or a + jp z,((.amSlave-L1105_Load2)+levelCheckRAM) + + ld a,[appomattoxMapIndex] + or a + jp z,((.amFlying-L1105_Load2)+levelCheckRAM) + + ld a,BANK(savegame_bg) + ld hl,savegame_bg + call LoadCinemaBG + + ld a,15 + call SetupFadeFromStandard + call WaitFade + + xor a + ld [levelVars+VAR_SELECTION],a +.waitSelection + call ((.blitCurSelection-L1105_Load2)+levelCheckRAM) + + ld a,1 + call Delay + + ld a,[myJoy] + bit JOY_UP_BIT,a + jr z,.checkDown + + xor a + ld [levelVars+VAR_SELECTION],a + jr .checkDone + +.checkDown + bit JOY_DOWN_BIT,a + jr z,.checkDone + + ld a,1 + ld [levelVars+VAR_SELECTION],a + +.checkDone + ld a,[myJoy] + bit JOY_A_BIT,a + jr z,.waitSelection + + ld a,[levelVars+VAR_SELECTION] + or a + call z,((.saveGame-L1105_Load2)+levelCheckRAM) + + ld a,15 + call SetupFadeToStandard + call WaitFade + + ld a,EXIT_S + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.saveGame + ld a,$0a ;enable save ram access + ld [0],a + + ld hl,$a000 ;start of save area $a000-$bfff + ld de,gameState + ld bc,9 + xor a + call ((.saveData-L1105_Load2)+levelCheckRAM) + + ld de,inventory + ld bc,16 + xor a + call ((.saveData-L1105_Load2)+levelCheckRAM) + + ld de,levelState + ld bc,256 + ld a,LEVELSTATEBANK + call ((.saveData-L1105_Load2)+levelCheckRAM) + + ld de,flightCode + ld bc,256 + ld a,FLIGHTCODEBANK + call ((.saveData-L1105_Load2)+levelCheckRAM) + + xor a + ld [0],a ;disable save ram to prevent false writes on powerdown + + ;blit "saved" + ld bc,$0a06 + ld de,$0509 + ld hl,$1412 + call CinemaBlitRect + ld a,15 + call Delay + ret + +.saveData + ;copies "bc" # of bytes from [de] to [hl] in bank "a" + ldio [$ff70],a +.saveLoop + ld a,[de] + inc de + ld [hl+],a + dec bc + xor a + cp b + jr nz,.saveLoop + cp c + jr nz,.saveLoop + ret + +.blitCurSelection + ldio a,[updateTimer] + and %1000 + jr z,.blitAppropriateCursor + + ;blit empty space + ld bc,$0a06 + ld de,$0509 + ld hl,$1400 + call CinemaBlitRect + ret + +.blitAppropriateCursor + ld a,[levelVars+VAR_SELECTION] ;selection * 6 + 6 + rlca + ld b,a + rlca + add b + add 6 + ld l,a + ld h,$14 + ld bc,$0a06 + ld de,$0509 + call CinemaBlitRect + ret + +.amFlying + ld a,BANK(cantsave_flying_bg) + ld hl,cantsave_flying_bg + call LoadCinemaBG + jr .showReason + +.amSlave + ld a,BANK(cantsave_bg) + ld hl,cantsave_bg + call LoadCinemaBG + +.showReason + ld a,15 + call SetupFadeFromStandard + call WaitFade + + ld de,((.returnToShip-L1105_Load2)+levelCheckRAM) + call SetDialogForward + call SetDialogSkip + + ld a,150 + call Delay + +.returnToShip + call ClearDialogSkipForward + + ld a,15 + call SetupFadeToStandard + call WaitFade + + ld a,EXIT_S + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +L1105_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1105_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1105_Init: + DW ((L1105_InitFinished - L1105_Init2)) ;size +L1105_Init2: + ret + +L1105_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1105_Check: + DW ((L1105_CheckFinished - L1105_Check2)) ;size +L1105_Check2: + ret + +L1105_CheckFinished: +PRINT "1105 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1105_LoadFinished - L1105_Load2) +PRINT " / " +PRINT (L1105_InitFinished - L1105_Init2) +PRINT " / " +PRINT (L1105_CheckFinished - L1105_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1111.asm b/Source/Levels/L1111.asm new file mode 100644 index 0000000..0192f40 --- /dev/null +++ b/Source/Levels/L1111.asm @@ -0,0 +1,173 @@ +; L1111.asm ssa se hulk module +; Generated 04.26.2001 by mlevel +; Modified 04.26.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_DEFUSED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level1111Section",ROMX +;--------------------------------------------------------------------- + +L1111_Contents:: + DW L1111_Load + DW L1111_Init + DW L1111_Check + DW L1111_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1111_Load: + DW ((L1111_LoadFinished - L1111_Load2)) ;size +L1111_Load2: + call ParseMap + ret + +L1111_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1111_Map: +INCBIN "Data/Levels/L1111_ssa_se.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1111_Init: + DW ((L1111_InitFinished - L1111_Init2)) ;size +L1111_Init2: + ld a,BANK(L0012_defused_gtx) + ld [dialogBank],a + call SetPressBDialog + + ldio a,[mapState] + cp STATE_DEFUSED + jr nz,.afterRemoveBomb + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d072 + ld [hl+],a + ld [hl],a + ld hl,$d092 + ld [hl+],a + ld [hl],a + +.afterRemoveBomb + ret + +L1111_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1111_Check: + DW ((L1111_CheckFinished - L1111_Check2)) ;size +L1111_Check2: + call ((.checkAtBomb-L1111_Check2)+levelCheckRAM) + ret + +.checkAtBomb + ldio a,[mapState] + cp STATE_DEFUSED + ret z + + ld hl,((.checkHeroAtBomb-L1111_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroAtBomb + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.atBomb + + xor a + ret + +.atBomb + ld a,STATE_DEFUSED + ldio [mapState],a + + call UpdateState + + ;remove bomb + ld a,MAPBANK + ldio [$ff70],a + xor a + ld hl,$d072 + ld [hl+],a + ld [hl],a + ld hl,$d092 + ld [hl+],a + ld [hl],a + + ;check all defused + ld d,0 + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$b8] + cp 2 + jr nz,.check2 + inc d +.check2 + ld a,[levelState+$b9] + cp 2 + jr nz,.check3 + inc d +.check3 + ld a,[levelState+$ba] + cp 2 + jr nz,.check4 + inc d +.check4 + ld a,[levelState+$bb] + cp 2 + jr nz,.checkTotal + inc d +.checkTotal + ;if 3 bombs were defused before this one then that's all + ld a,d + cp 3 + jr nz,.bombsRemain + + ld hl,L0012_alldefused_gtx + jr .dialog + +.bombsRemain + ld hl,L0012_defused_gtx + +.dialog + call MakeIdle + ld de,((.afterDialog-L1111_Check2)+levelCheckRAM) + call SetDialogSkip + + ld d,h + ld e,l + + call SetSpeakerFromHeroIndex + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ret + +L1111_CheckFinished: +PRINT "1111 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1111_LoadFinished - L1111_Load2) +PRINT " / " +PRINT (L1111_InitFinished - L1111_Init2) +PRINT " / " +PRINT (L1111_CheckFinished - L1111_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1112.asm b/Source/Levels/L1112.asm new file mode 100644 index 0000000..c4d1e2c --- /dev/null +++ b/Source/Levels/L1112.asm @@ -0,0 +1,325 @@ +; L1112.asm duke's disco +; Generated 04.10.2001 by mlevel +; Modified 04.10.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +DISCOBALL_INDEX EQU 29 +REDDANCER_INDEX EQU 45 +BLUEDANCER_INDEX EQU 47 +REDDANCER_2X1_INDEX EQU 49 +BLUEDANCER_2X1_INDEX EQU 53 +REDDANCER_1X2_INDEX EQU 57 +BLUEDANCER_1X2_INDEX EQU 61 + +REDOBJ_INDEX EQU 65 +BLUEOBJ_INDEX EQU 66 +ORANGEOBJ_INDEX EQU 67 + +VAR_LIGHTFRAME EQU 0 +VAR_BGKILLED EQU 15 + +STATE_NORMAL EQU 1 +STATE_AVERTED EQU 2 + + +;--------------------------------------------------------------------- +SECTION "Level1112Gfx1",ROMX +;--------------------------------------------------------------------- +success_bg: + INCBIN "Data/Cinema/Disco/success.bg" + +party_over_bg: + INCBIN "Data/Cinema/Disco/party_over.bg" + +;--------------------------------------------------------------------- +SECTION "Level1112Section",ROMX +;--------------------------------------------------------------------- + +L1112_Contents:: + DW L1112_Load + DW L1112_Init + DW L1112_Check + DW L1112_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1112_Load: + DW ((L1112_LoadFinished - L1112_Load2)) ;size +L1112_Load2: + call ParseMap + ret + +L1112_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1112_Map: +INCBIN "Data/Levels/L1112_disco.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1112_Init: + DW ((L1112_InitFinished - L1112_Init2)) ;size +L1112_Init2: + ;change palette 7's BG color to black + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette+8*7 + xor a + ld [hl+],a + ld [hl+],a + + xor a + ld [levelVars+VAR_LIGHTFRAME],a + ld [levelVars+VAR_BGKILLED],a + + ld a,ENV_DISCO + ld [envEffectType],a + + call State0To1 + ret + +L1112_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1112_Check: + DW ((L1112_CheckFinished - L1112_Check2)) ;size +L1112_Check2: + call ((.animateBG-L1112_Check2)+levelCheckRAM) + call ((.checkPartyOver-L1112_Check2)+levelCheckRAM) + ret + +.checkPartyOver + ld c,REDOBJ_INDEX + call GetNumObjects + cp 8 + jr nz,.partyOver + + ld c,BLUEOBJ_INDEX + call GetNumObjects + cp 12 + jr nz,.partyOver + + ld a,[levelVars+VAR_BGKILLED] + or a + jr nz,.partyOver + + ld c,ORANGEOBJ_INDEX + call GetNumObjects + or a + ret nz + + ;success + ld a,STATE_AVERTED + ldio [mapState],a + + ;we leave on a cinema so need to update state manually + call UpdateState + + ;yank player even if he's on the homeworld already + ld a,(EXIT_W | 8) + ld hl,$0912 + call YankRemotePlayer + + ld a,30 + call Delay + + ld a,15 + call SetupFadeToBlack + call WaitFade + call ResetSprites + + ld a,BANK(success_bg) + ld hl,success_bg + call LoadCinemaBG + jr .exitDisco + +.partyOver + ld a,30 + call Delay + + ld a,15 + call SetupFadeToBlack + call WaitFade + call ResetSprites + + ld a,BANK(party_over_bg) + ld hl,party_over_bg + call LoadCinemaBG + +.exitDisco + xor a + ld [envEffectType],a + + ld a,15 + call SetupFadeFromBlack + call WaitFade + + ld c,90 +.waitInputLoop + ld a,1 + call Delay + ld a,[myJoy] + and %11110000 + jr nz,.continueExit + dec c + jr nz,.waitInputLoop + +.continueExit + call BlackoutPalette + + ld a,EXIT_W + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$0912 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.animateBG + ld a,TILEINDEXBANK + ld [$ff70],a + + call ((.animateDiscoBall-L1112_Check2)+levelCheckRAM) + call ((.animateDancer1-L1112_Check2)+levelCheckRAM) + call ((.animateDancer2-L1112_Check2)+levelCheckRAM) + call ((.animateDancer3-L1112_Check2)+levelCheckRAM) + call ((.animateDancer4-L1112_Check2)+levelCheckRAM) + call ((.animateDancer5-L1112_Check2)+levelCheckRAM) + call ((.animateDancer6-L1112_Check2)+levelCheckRAM) + ret + +.animateDiscoBall + ldio a,[updateTimer] + and %11 + ret nz + + ld hl,bgTileMap+DISCOBALL_INDEX + ld b,DISCOBALL_INDEX + call ((.incDiscoFrame-L1112_Check2)+levelCheckRAM) + call ((.incDiscoFrame-L1112_Check2)+levelCheckRAM) + call ((.incDiscoFrame-L1112_Check2)+levelCheckRAM) + call ((.incDiscoFrame-L1112_Check2)+levelCheckRAM) + + ld hl,levelVars+VAR_LIGHTFRAME + ld a,[hl] + inc a + and 7 + ld [hl],a + ret + +.incDiscoFrame + ld a,[hl] + sub b + add 4 + and %1100 + add b + ld [hl+],a + inc b + ret + +.animateDancer1 + ldio a,[updateTimer] + and %111 + ret nz + + ld hl,bgTileMap+REDDANCER_INDEX + ld b,REDDANCER_INDEX + call ((.inc1-L1112_Check2)+levelCheckRAM) + ret +.animateDancer2 + ldio a,[updateTimer] + inc a + and %11 + ret nz + + ld hl,bgTileMap+BLUEDANCER_INDEX + ld b,BLUEDANCER_INDEX + call ((.inc1-L1112_Check2)+levelCheckRAM) + ret + +.animateDancer3 + ldio a,[updateTimer] + and %111 + ret nz + + ld hl,bgTileMap+REDDANCER_2X1_INDEX + ld b,REDDANCER_2X1_INDEX + call ((.inc2-L1112_Check2)+levelCheckRAM) + call ((.inc2-L1112_Check2)+levelCheckRAM) + ret + +.animateDancer4 + ldio a,[updateTimer] + inc a + and %11 + ret nz + + ld hl,bgTileMap+BLUEDANCER_2X1_INDEX + ld b,BLUEDANCER_2X1_INDEX + call ((.inc2-L1112_Check2)+levelCheckRAM) + call ((.inc2-L1112_Check2)+levelCheckRAM) + ret + +.animateDancer5 + ldio a,[updateTimer] + add 3 + and %11 + ret nz + + ld hl,bgTileMap+REDDANCER_1X2_INDEX + ld b,REDDANCER_1X2_INDEX + call ((.inc2-L1112_Check2)+levelCheckRAM) + call ((.inc2-L1112_Check2)+levelCheckRAM) + ret + +.animateDancer6 + ldio a,[updateTimer] + add 3 + and %11 + ret nz + + ld hl,bgTileMap+BLUEDANCER_1X2_INDEX + ld b,BLUEDANCER_1X2_INDEX + call ((.inc2-L1112_Check2)+levelCheckRAM) + call ((.inc2-L1112_Check2)+levelCheckRAM) + ret + +.inc1 + ld a,[hl] + sub b + inc a + and %1 + add b + ld [hl+],a + ret + +.inc2 + ld a,[hl] + sub b + add 2 + and %10 + add b + ld [hl+],a + inc b + ret + +L1112_CheckFinished: +PRINT "1112 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1112_LoadFinished - L1112_Load2) +PRINT " / " +PRINT (L1112_InitFinished - L1112_Init2) +PRINT " / " +PRINT (L1112_CheckFinished - L1112_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1200.asm b/Source/Levels/L1200.asm new file mode 100644 index 0000000..1e9a60c --- /dev/null +++ b/Source/Levels/L1200.asm @@ -0,0 +1,744 @@ +;L1200 Logo cinema +;Abe Pralle 5.2.2000 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Gfx.inc" + +TEMPKLUDGE EQU 50 + +;--------------------------------------------------------------------- +SECTION "L1200DataSection",ROMX +;--------------------------------------------------------------------- +logo160_bg: + INCBIN "Data/Cinema/Logo/logo160.bg" + +presents_bg: + INCBIN "Data/Cinema/Logo/presents.bg" + +fgbtitle_bg: + INCBIN "Data/Cinema/Logo/fgbtitle.bg" + +;--------------------------------------------------------------------- +SECTION "L1200DataSection2",ROMX +;--------------------------------------------------------------------- +kiwi1_bg:: + INCBIN "Data/Cinema/Appomattox/kiwi1.bg" + +kiwi2_bg:: + INCBIN "Data/Cinema/Appomattox/kiwi2.bg" + +kiwi3_bg:: + INCBIN "Data/Cinema/Appomattox/kiwi3.bg" + +landing_bg_bg:: + INCBIN "Data/Cinema/Appomattox/landing_bg.bg" + +landing_sprites_sp:: + INCBIN "Data/Cinema/Appomattox/landing_sprites.sp" + +;--------------------------------------------------------------------- +SECTION "L1200DataSection3",ROMX +;--------------------------------------------------------------------- +titlesprite_sp: + INCBIN "Data/Cinema/Logo/titlesprite.sp" + +ocloud0_bg: + INCBIN "Data/Cinema/Logo/ocloud0.bg" + +ocloud1_bg: + INCBIN "Data/Cinema/Logo/ocloud1.bg" + +;--------------------------------------------------------------------- +SECTION "L1200DataSection4",ROMX +;--------------------------------------------------------------------- +ocloud2_bg: + INCBIN "Data/Cinema/Logo/ocloud2.bg" + +ocloud3_bg: + INCBIN "Data/Cinema/Logo/ocloud3.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection5",ROMX +;--------------------------------------------------------------------- +ocloud4_bg: + INCBIN "Data/Cinema/Logo/ocloud4.bg" + +ocloud5_bg: + INCBIN "Data/Cinema/Logo/ocloud5.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection6",ROMX +;--------------------------------------------------------------------- +ocloud6_bg: + INCBIN "Data/Cinema/Logo/ocloud6.bg" + +ocloud7_bg: + INCBIN "Data/Cinema/Logo/ocloud7.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection7",ROMX +;--------------------------------------------------------------------- +ocloud8_bg: + INCBIN "Data/Cinema/Logo/ocloud8.bg" + +ocloud9_bg: + INCBIN "Data/Cinema/Logo/ocloud9.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection8",ROMX +;--------------------------------------------------------------------- +oclouda_bg: + INCBIN "Data/Cinema/Logo/oclouda.bg" + +ocloudb_bg: + INCBIN "Data/Cinema/Logo/ocloudb.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection9",ROMX +;--------------------------------------------------------------------- +ocloudc_bg: + INCBIN "Data/Cinema/Logo/ocloudc.bg" + +ocloudd_bg: + INCBIN "Data/Cinema/Logo/ocloudd.bg" + + +;--------------------------------------------------------------------- +SECTION "L1200DataSection10",ROMX +;--------------------------------------------------------------------- +ocloude_bg: + INCBIN "Data/Cinema/Logo/ocloude.bg" + +ocloudf_bg: + INCBIN "Data/Cinema/Logo/ocloudf.bg" + +;--------------------------------------------------------------------- +SECTION "L1200CodeSection",ROMX +;--------------------------------------------------------------------- +L1200_Contents:: + DW L1200_Load + DW L1200_Init + DW L1200_Check + DW L1200_Map + +;--------------------------------------------------------------------- +; demo intro +;--------------------------------------------------------------------- +L1200_Load: + DW ((L1200_LoadFinished - L1200_Load)-2) ;size +L1200_Load2: + ;----------------plasmaworks Logo---------------------- + ld a,BANK(logo160_bg) + ld hl,logo160_bg + call LoadCinemaBG + + ld a,1 + call Delay + + ld a,BANK(haiku_gbm) + ld hl,haiku_gbm + call InitMusic + + ld de,((.endLogoCinema-L1200_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.showPresents-L1200_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,16 + call SetupFadeFromWhite + call WaitFade + + ld a,30 + call Delay + + ;----------------presents------------------------------ +.showPresents + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld a,BANK(presents_bg) + ld hl,presents_bg + call LoadCinemaBG + + ld de,((.showTitle-L1200_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ld a,27 + call Delay + + ;----------------fgb title----------------------------- +.showTitle + ld a,16 + call SetupFadeToStandard + call WaitFade + + ;ld a,BANK(fgbtitle_bg) + ;ld hl,fgbtitle_bg + ;call LoadCinemaBG + + ld a,BANK(ocloud0_bg) + ld hl,ocloud0_bg + call LoadCinemaBG + + ld a,BANK(titlesprite_sp) + ld hl,titlesprite_sp + call LoadCinemaSprite + ld a,1 + call Delay + + ld de,((.endLogoCinema-L1200_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ld b,32 + ld c,1 +.cloudAnim + ;load next cloud frame + ld d,0 ;de = c*4 + ld e,c + sla e + rl d + sla e + rl d + ld hl,((.cloudFrames-L1200_Load2)+levelCheckRAM) + add hl,de + ld a,[hl+] ;mem bank of cloud frame + inc hl + push af + ld a,[hl+] + ld h,[hl] + ld l,a + pop af + call LoadCinemaBG + ;ld a,1 + ;call Delay + + ld a,c + inc a + and 15 + ld c,a + + dec b + jr nz,.cloudAnim + +.endLogoCinema + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld hl,$1101 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + +IF 0 +.starfield + ;----------------star field----------------------------- + ld a,BANK(starfield_bg) + ld hl,starfield_bg + call LoadCinemaBG + + ld a,BANK(starfield_sprite_sp) + ld hl,starfield_sprite_sp + call LoadCinemaSprite + + ld a,FADEBANK + ld [$ff70],a + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + + ld d,48 + (TEMPKLUDGE/2) + call ScrollSpritesLeft + + ld d,48 + (TEMPKLUDGE/2) + call ScrollSpritesDown + + SETDIALOGSKIP(.afterIntro + (levelCheckRAM-L1200_Load2)) + + ;number of cycles total + ld b,180 + TEMPKLUDGE + 20 + +.loop + push bc + + call (.clearPaletteToBlack + (levelCheckRAM-L1200_Load2)) + call (.cycleColors + (levelCheckRAM-L1200_Load2)) + ld a,1 + ld [paletteBufferReady],a + + ld a,1 + call Delay + pop bc + + ld a,b + and %00000001 + jr nz,.afterScrollSprites + + ld d,1 + call ScrollSpritesUp + + ld d,1 + call ScrollSpritesRight + +.afterScrollSprites + ld a,b + and %00000010 + jr nz,.turnThrustOn + + call (.routine_thrustoff + (levelCheckRAM-L1200_Load2)) + jr .afterThrust + +.turnThrustOn + call (.routine_thruston + (levelCheckRAM-L1200_Load2)) + +.afterThrust + dec b + jr nz,.loop + + ld a,16 + call SetupFadeToStandard + call WaitFade + ld a,1 + call Delay + + ;----------------approach kiwi------------------------------- + ld a,BANK(kiwi1_bg) + ld hl,kiwi1_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + call (.animate_ship + (levelCheckRAM-L1200_Load2)) + + ld a,16 + call SetupFadeToBlackBGOnly + call WaitFade + + ;kiwi 2 + ld a,BANK(kiwi2_bg) + ld hl,kiwi2_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromBlackBGOnly + call WaitFade + + call (.animate_ship + (levelCheckRAM-L1200_Load2)) + + ld a,16 + call SetupFadeToBlackBGOnly + call WaitFade + + ;kiwi 3 + ld a,BANK(kiwi3_bg) + ld hl,kiwi3_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromBlackBGOnly + call WaitFade + + call (.animate_ship + (levelCheckRAM-L1200_Load2)) + + ld a,16 + call SetupFadeToBlack + call WaitFade + + ;----------------landing on kiwi----------------------- + call ResetSprites + ld a,BANK(landing_bg_bg) + ld hl,landing_bg_bg + call LoadCinemaBG + ld a,BANK(landing_sprites_sp) + ld hl,landing_sprites_sp + call LoadCinemaSprite + + ld d,16 + call ScrollSpritesRight + ld d,48 + call ScrollSpritesUp + + ;set landing gear sprites and flame to off + ld hl,spriteOAMBuffer+6 + ld c,8 + xor a +.init_landing_loop + ld [hl+],a + inc hl + inc hl + inc hl + dec c + jr nz,.init_landing_loop + + + SETDIALOGSKIP(.afterIntro + (levelCheckRAM-L1200_Load2)) + + ;----------------animate descent of appomattox + + ;landing gear stowed + ld a,16 + call SetupFadeFromBlack + ld b,45 +.descent1 + push bc + ld a,1 + call Delay + ld d,1 + call (.scrollDownAllSprites + (levelCheckRAM-L1200_Load2)) + pop bc + + dec b + jr nz,.descent1 + + ;landing gear half-out + ld hl,spriteOAMBuffer+(9*4)+2 + ld c,4 + ld a,2 +.gear_half_loop + ld [hl+],a ;change tile index + inc hl + inc hl + inc hl + add 2 + dec c + jr nz,.gear_half_loop + + ld b,5 +.descent2 + push bc + ld a,1 + call Delay + ld a,1 + call Delay + ld d,1 + call (.scrollDownAllSprites + (levelCheckRAM-L1200_Load2)) + pop bc + + dec b + jr nz,.descent2 + + ;landing gear full out + ld hl,spriteOAMBuffer+(9*4)+2 + ld c,4 + ld a,10 +.gear_full_loop + ld [hl+],a ;change tile index + inc hl + inc hl + inc hl + add 2 + dec c + jr nz,.gear_full_loop + + ld b,28 +.descent3 + push bc + ld a,1 + call Delay + ld a,1 + call Delay + ld d,1 + call (.scrollDownAllSprites + (levelCheckRAM-L1200_Load2)) + pop bc + + dec b + jr nz,.descent3 + + + ld a,16 + call SetupFadeToStandard + ld b,8 +.descent4 + push bc + ld a,1 + call Delay + ld a,1 + call Delay + ld a,1 + call Delay + ld d,1 + call (.scrollDownAllSprites + (levelCheckRAM-L1200_Load2)) + pop bc + + dec b + jr nz,.descent4 + + ;ld a,16 + ;call SetupFadeToWhite + call WaitFade + +.afterIntro + ld a,$05 + ld [curLevelIndex],a + ld a,$02 + ld [curLevelIndex+1],a + + ld a,1 + ld [timeToChangeLevel],a + + ret +ENDC + +.show_pic + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ld a,48 + call Delay + + ret + +IF 0 +.routine_thrustoff + ;turn thrust off by setting sprites 0-5 to pattern 50 + ld hl,spriteOAMBuffer+2 + ld de,4 + ld a,50 + ld c,6 +.thrustOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.thrustOffLoop + ret + +.routine_thruston + ;turn thrust on by setting sprites 0-5 to patterns 0,2,4,6,8,10 + ld hl,spriteOAMBuffer+2 + ld de,4 + xor a + ld c,6 +.thrustOnLoop + ld [hl],a + inc a + inc a + add hl,de + dec c + jr nz,.thrustOnLoop + ret + +.clearPaletteToBlack + push bc + ld c,64 + ld hl,fadeCurPalette + xor a +.clearPaletteLoop + ld [hl+],a + dec c + jr nz,.clearPaletteLoop + pop bc + ret + +.cycleColors + ;b is current cycle + ;set palettes 1,5, & 7 to cycle half-speed (1/8 speed of b) + ;rest to cycle full speed (1/4 speed of b) + push bc + + ;----------set full-speed palettes (0,2,3,4,6)------------ + ;color = (clock % 6) / 2 + ld c,6 + ld a,b +.getMod6 + cp c + jr c,.gotMod6 + sub c + jr .getMod6 +.gotMod6 + srl a ;divided by 2 yields 0-2 + ld c,a + inc c ;c is now 1-3 + + push bc + ld b,0 + xor a + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;0 + inc a + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;2 + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;3 + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;4 + inc a + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;6 + pop bc + + ;----------set half-speed palettes (1,5,7)--------------- + ;color = (clock % 12) / 4 + ld c,12 + ld a,b +.getMod12 + cp c + jr c,.gotMod12 + sub c + jr .getMod12 +.gotMod12 + srl a ;divided by 4 yields 0-2 + srl a + ld c,a + inc c ;c is now 1-3 + + push bc + ld b,1 + ld a,1 + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;1 + ld a,5 + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;5 + inc a + call (.setCycle + (levelCheckRAM-L1200_Load2)) ;7 + pop bc + + pop bc + ret + +.setCycle + ;a is palette # to set (0-7) + ;b is color flag (0=white, 1=grey) + ;c is color number to set (1-3) + push af + push hl + + ;(palette# * 4 + color) * 2 + 128 is first byte to set + rlca + rlca + add c + rlca + add 128 + ld l,a + ld h,((fadeCurPalette>>8) & $ff) + + ld a,b + cp 1 + jr z,.setToGrey + + ;set to white + ld a,$ff + ld [hl+],a + ld a,$7f + ld [hl],a + jr .done + +.setToGrey + ld a,$08 + ld [hl+],a + ld a,$21 + ld [hl],a + +.done + pop hl + pop af + inc a + ret + +.animate_ship + SETDIALOGSKIP(.afterIntro + (levelCheckRAM-L1200_Load2)) + push bc + ld b,90 +.animate_loop + push bc + ld a,1 + call Delay + pop bc + + ld a,b + and %10 ;thrust on or off? + + jr nz,.animate_thruston + call (.routine_thrustoff + (levelCheckRAM-L1200_Load2)) + jr .animate_check_done + +.animate_thruston + call (.routine_thruston + (levelCheckRAM-L1200_Load2)) + +.animate_check_done + dec b + jr nz,.animate_loop + + pop bc + + ret + +.scrollDownAllSprites + push bc + push de + push hl + + ld hl,spriteOAMBuffer + ld c,35 +.scrollDownLoop + ld a,[hl] + add d + ld [hl+],a + inc hl + inc hl + inc hl + dec c + jr nz,.scrollDownLoop + + pop hl + pop de + pop bc + ret + +ENDC + +.cloudFrames + DW BANK(ocloud0_bg), ocloud0_bg, BANK(ocloud1_bg), ocloud1_bg + DW BANK(ocloud2_bg), ocloud2_bg, BANK(ocloud3_bg), ocloud3_bg + DW BANK(ocloud4_bg), ocloud4_bg, BANK(ocloud5_bg), ocloud5_bg + DW BANK(ocloud6_bg), ocloud6_bg, BANK(ocloud7_bg), ocloud7_bg + DW BANK(ocloud8_bg), ocloud8_bg, BANK(ocloud9_bg), ocloud9_bg + DW BANK(oclouda_bg), oclouda_bg, BANK(ocloudb_bg), ocloudb_bg + DW BANK(ocloudc_bg), ocloudc_bg, BANK(ocloudd_bg), ocloudd_bg + DW BANK(ocloude_bg), ocloude_bg, BANK(ocloudf_bg), ocloudf_bg + +L1200_LoadFinished: + +PRINT " 1200 Level Load Size: " +PRINT (L1200_LoadFinished - L1200_Load2) +PRINT "/$500 bytes\n" + + +L1200_Map: + +;gtx_app_closed_gate_bs5: INCBIN "Data/Dialog/Landing/app_closed_gate_bs5.gtx" + +L1200_Init: + DW ((L1200_InitFinished - L1200_Init)-2) ;size +L1200_Init2: + ret + +L1200_InitFinished: + + +L1200_Check: + DW ((L1200_CheckFinished - L1200_Check) - 2) ;size +L1200_Check2: + ret + +L1200_CheckFinished: + +PRINT " 1200 Level Check Size: " +PRINT (L1200_CheckFinished - L1200_Check2) +PRINT "/$500 bytes\n" + diff --git a/Source/Levels/L1201.asm b/Source/Levels/L1201.asm new file mode 100644 index 0000000..4749387 --- /dev/null +++ b/Source/Levels/L1201.asm @@ -0,0 +1,86 @@ +;L1201.asm +;Abe Pralle 6.13.2000 + +;called when the level the guest is going to is the same as the one +;the host is on + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "LevelsSection1201",ROMX,BANK[MAP0ROM] +;--------------------------------------------------------------------- + +L1201_Contents:: + DW L1201_Load + DW L1201_Init + DW L1201_Check + DW L1201_Map + +waiting_to_join_bg: + INCBIN "Data/Cinema/menu/waiting_to_join.bg" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1201_Load: + DW ((L1201_LoadFinished - L1201_Load2)) ;size +L1201_Load2: + ld a,1 + call SetupFadeToWhite + call WaitFade + + ld a,BANK(waiting_to_join_bg) + ld hl,waiting_to_join_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ld a,30 + call Delay + + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld a,$02 + ld [curLevelIndex+1],a + ld a,$05 + ld [curLevelIndex],a + + ld a,1 + ld [timeToChangeLevel],a + + ret + + +L1201_LoadFinished: +;some local vars + +L1201_Map: +;--------------------------------------------------------------------- +L1201_Init: +;--------------------------------------------------------------------- + DW ((L1201_InitFinished - L1201_Init2)) ;size +L1201_Init2: + + ret + +L1201_InitFinished: + + +;--------------------------------------------------------------------- +L1201_Check: +;--------------------------------------------------------------------- + DW ((L1201_CheckFinished - L1201_Check) - 2) ;size +L1201_Check2: + ret +L1201_CheckFinished: + + +PRINT " 1201 Level Check Size: " +PRINT (L1201_CheckFinished - L1201_Check2) +PRINT "/$500 bytes" + diff --git a/Source/Levels/L1202.asm b/Source/Levels/L1202.asm new file mode 100644 index 0000000..1e25f51 --- /dev/null +++ b/Source/Levels/L1202.asm @@ -0,0 +1,238 @@ +; L1202.asm dropship leaving triumph +; Generated 07.30.2000 by mlevel +; Modified 07.30.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +STATE_BASHUTTLE EQU 1 +STATE_SKIPPYSHUTTLE EQU 2 + +;--------------------------------------------------------------------- +SECTION "Level1202Section",ROMX +;--------------------------------------------------------------------- + +L1202_Contents:: + DW L1202_Load + DW L1202_Init + DW L1202_Check + DW L1202_Map + +triumphBIG_bg:: + INCBIN "Data/Cinema/Intro/triumphBIG.bg" + +dropship_tiny_sp: + INCBIN "Data/Cinema/Intro/dropship_tiny.sp" + +nar_skippyshuttle_bg: + INCBIN "Data/Cinema/Intro/nar_skippyshuttle.bg" + +dialog: +blank_gtx: + INCBIN "Data/Dialog/Intro/blank.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1202_Load: + DW ((L1202_LoadFinished - L1202_Load2)) ;size + +L1202_Load2: + ld a,STATE_BASHUTTLE + ldio [mapState],a + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$2d] ;gyro catches BA + or a + jr z,.afterSkippyShuttle + ld a,STATE_SKIPPYSHUTTLE + ldio [mapState],a +.afterSkippyShuttle + + ld a,BANK(dialog) + ld [dialogBank],a + + ;ldio a,[mapState] + ;or a + ;jr nz,.afterState0 + + ;ld a,BANK(moon_base_ba_gbm) + ;ld hl,moon_base_ba_gbm + ;call InitMusic + +.afterState0 + ld a,BANK(triumphBIG_bg) + ld hl,triumphBIG_bg + call LoadCinemaBG + + ld a,BANK(dropship_tiny_sp) + ld hl,dropship_tiny_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + ld a,BANK(nar_skippyshuttle_bg) + ld hl,nar_skippyshuttle_bg + call LoadCinemaTextBox + + ld a,1 + call Delay + + ld d,72 + call ScrollSpritesRight + ld d,74 + call ScrollSpritesDown + + ld b,%10000000 + call ((.setSpritePriority-L1202_Load2)+levelCheckRAM) + + ld a,1 + call Delay + + ld a,16 + call SetupFadeFromStandard + call WaitFade + + ldio a,[mapState] + cp STATE_SKIPPYSHUTTLE + jr nc,.describe_skippy + + ld a,BANK(blank_gtx) + ld c,0 + ld de,blank_gtx + call ShowDialogAtBottomNoWait + jr .afterSetupTextBox + +.describe_skippy + call GfxShowStandardTextBox + +.afterSetupTextBox + ld a,1 + call Delay + + ;blit the full image from the offscreen buffer now that the + ;bottom is obscured by the text box + ld bc,$1424 + ld de,$0000 + ld hl,$1400 + call CinemaBlitRect + + ld a,$22 + ldio [scrollSpeed],a + + ;start the screen scrolling down + ld a,28 + ld [camera_j],a + +.afterShowSkippyShuttle + + ld de,((.endCinema - L1202_Load2) + levelCheckRAM) + call SetDialogSkip + ld de,((.endCinema - L1202_Load2) + levelCheckRAM) + call SetDialogForward + + ld c,80 + 144 +.scrollDropshipLoop + ld d,1 + call ScrollSpritesDown + ld a,1 + call Delay + ld a,c + + cp 80 + jr nz,.stillScrolling + ldio a,[mapState] + cp STATE_SKIPPYSHUTTLE + jr nc,.stillScrolling + call ClearDialog +.stillScrolling + + dec c + jr nz,.scrollDropshipLoop + +.endCinema + ld hl,$0013 + ld de,$0013 ;respawn map + ldio a,[mapState] + cp STATE_SKIPPYSHUTTLE + jr nz,.afterChooseNextLevel + + ld hl,$0215 + ld de,$0014 ;respawn map +.afterChooseNextLevel + + call ClearDialog + + ld a,e + ld [respawnMap],a + ld a,d + ld [respawnMap+1],a + + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + cp STATE_SKIPPYSHUTTLE + ldio [mapState],a + + ld a,1 + ld [timeToChangeLevel],a + + ld a,16 + call SetupFadeToStandard + call WaitFade + + ret + +.setSpritePriority + ;set the priority flag for the first 8 sprites + ld hl,spriteOAMBuffer+3 + ld de,4 + ld c,8 +.setPriorityLoop + ld a,[hl] + and %01111111 + or b + ld [hl],a + add hl,de + dec c + jr nz,.setPriorityLoop + ret + +L1202_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1202_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1202_Init: + DW ((L1202_InitFinished - L1202_Init2)) ;size +L1202_Init2: + ret + +L1202_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1202_Check: + DW ((L1202_CheckFinished - L1202_Check2)) ;size +L1202_Check2: + ret + +L1202_CheckFinished: +PRINT "1202 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1202_LoadFinished - L1202_Load2) +PRINT " / " +PRINT (L1202_InitFinished - L1202_Init2) +PRINT " / " +PRINT (L1202_CheckFinished - L1202_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1203.asm b/Source/Levels/L1203.asm new file mode 100644 index 0000000..f84b8ac --- /dev/null +++ b/Source/Levels/L1203.asm @@ -0,0 +1,352 @@ +; L1203.asm Rescue From The Tower Cinema +; Generated 03.31.2001 by mlevel +; Modified 03.31.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1203Gfx1",ROMX +;--------------------------------------------------------------------- +in_prison_bg: + INCBIN "Data/Cinema/Wedding/in_prison.bg" + +bs_driving_bg: + INCBIN "Data/Cinema/Wedding/bs_driving.bg" + +;--------------------------------------------------------------------- +SECTION "Level1203Section",ROMX +;--------------------------------------------------------------------- + +dialog: +flour_heyguys_gtx: + INCBIN "Data/Dialog/Wedding/flour_heyguys.gtx" + +bs_explain_gtx: + INCBIN "Data/Dialog/Wedding/bs_explain.gtx" + +bs_explain2_gtx: + INCBIN "Data/Dialog/Wedding/bs_explain2.gtx" + +captain_interrupt_gtx: + INCBIN "Data/Dialog/Wedding/captain_interrupt.gtx" + +captain_tellyouwhat_gtx: + INCBIN "Data/Dialog/Wedding/captain_tellyouwhat.gtx" + +captain_key_gtx: + INCBIN "Data/Dialog/Wedding/captain_key.gtx" + +captain_dosomething_gtx: + INCBIN "Data/Dialog/Wedding/captain_dosomething.gtx" + +captain_camp_gtx: + INCBIN "Data/Dialog/Wedding/captain_camp.gtx" + +bs_driving_gtx: + INCBIN "Data/Dialog/Wedding/bs_driving.gtx" + +bs_palace_gtx: + INCBIN "Data/Dialog/Wedding/bs_palace.gtx" + + +L1203_Contents:: + DW L1203_Load + DW L1203_Init + DW L1203_Check + DW L1203_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1203_Load: + DW ((L1203_LoadFinished - L1203_Load2)) ;size +L1203_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,EXIT_D + ld hl,$1203 + call YankRemotePlayer + + ld bc,ITEM_APPXKEY + call AddInventoryItem + + ld a,[heroesUsed] + ld hl,heroesAvailable + or [hl] + ld [hl],a + xor a + ld [heroesUsed],a + + ld a,BANK(moon_base_haiku_gbm) + ld hl,moon_base_haiku_gbm + call InitMusic + + ld a,BANK(in_prison_bg) + ld hl,in_prison_bg + call LoadCinemaBG + + ld a,15 + call SetupFadeFromStandard + call WaitFade + + ld de,((.endCinema-L1203_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.doorOpen-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,60 + call Delay + +.doorOpen + ld bc,$0508 + ld de,$0201 + ld hl,$1400 + call CinemaBlitRect + + ld de,((.heyGuys-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + +.heyGuys + ld c,0 + DIALOGBOTTOM flour_heyguys_gtx + + ld de,((.fewMinutesLater-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.fewMinutesLater + call ((.quickToBlack-L1203_Load2)+levelCheckRAM) + + ld a,BANK(gang_watches_front_bg) + ld hl,gang_watches_front_bg + call LoadCinemaBG + call ((.quickFromBlack-L1203_Load2)+levelCheckRAM) + + ld de,((.bsExplain-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,90 + call Delay + +.bsExplain + call ((.quickToBlack-L1203_Load2)+levelCheckRAM) + + ld a,BANK(bs_bg) + ld hl,bs_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1203_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM bs_explain_gtx + + ld de,((.bsExplain2-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateBS + +.bsExplain2 + call ClearDialog + + ld c,0 + DIALOGBOTTOM bs_explain2_gtx + + ld de,((.captainInterrupt-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateBS + +.captainInterrupt + call ((.quickToBlack-L1203_Load2)+levelCheckRAM) + + ld a,BANK(flour_bg) + ld hl,flour_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1203_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM captain_interrupt_gtx + + ld de,((.captainTellYouWhat-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.captainTellYouWhat + call ClearDialog + ld c,0 + DIALOGBOTTOM captain_tellyouwhat_gtx + + ld de,((.captainKey-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.captainKey + call ClearDialog + ld c,0 + DIALOGBOTTOM captain_key_gtx + + ld de,((.captainDoSomething-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.captainDoSomething + call ClearDialog + ld c,0 + DIALOGBOTTOM captain_dosomething_gtx + + ld de,((.captainCamp-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.captainCamp + call ClearDialog + ld c,0 + DIALOGBOTTOM captain_camp_gtx + + ld de,((.backAtAppx-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateFlour + +.backAtAppx + call ((.quickToBlack-L1203_Load2)+levelCheckRAM) + + ld a,BANK(bs_driving_bg) + ld hl,bs_driving_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1203_Load2)+levelCheckRAM) + + ld de,((.bsDriving-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,90 + call Delay + +.bsDriving + ld bc,$1406 + ld de,$000c + ld hl,$1412 + call CinemaBlitRect + + ld a,1 + call Delay + + ld c,0 + DIALOGBOTTOM bs_driving_gtx + + ld de,((.bsPalace-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateBSDriving + +.bsPalace + call ClearDialog + + ld c,0 + DIALOGBOTTOM bs_palace_gtx + + ld de,((.endCinema-L1203_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,4 + LONGCALLNOARGS AnimateBSDriving + +.endCinema + call ClearDialogSkipForward + + ;call ((.quickToBlack-L1203_Load2)+levelCheckRAM) + + ld hl,2056 ;bs + ld a,l + ld [hero0_class],a + ld a,h + ld [hero0_class+1],a + ld a,HERO_BS_FLAG + ld [hero0_type],a + + ld hl,2058 ;haiku + ld a,l + ld [hero1_class],a + ld a,h + ld [hero1_class+1],a + ld a,HERO_HAIKU_FLAG + ld [hero1_type],a + + ld a,EXIT_N + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1100 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.quickToBlack + call BlackoutPalette + call ClearDialog + jp ResetSprites + +.quickFromBlack + ld a,1 + jp SetupFadeFromBlack + + +L1203_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1203_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1203_Init: + DW ((L1203_InitFinished - L1203_Init2)) ;size +L1203_Init2: + ret + +L1203_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1203_Check: + DW ((L1203_CheckFinished - L1203_Check2)) ;size +L1203_Check2: + ret + +L1203_CheckFinished: +PRINT "1203 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1203_LoadFinished - L1203_Load2) +PRINT " / " +PRINT (L1203_InitFinished - L1203_Init2) +PRINT " / " +PRINT (L1203_CheckFinished - L1203_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1204.asm b/Source/Levels/L1204.asm new file mode 100644 index 0000000..c607862 --- /dev/null +++ b/Source/Levels/L1204.asm @@ -0,0 +1,441 @@ +; L1204.asm Escape from the space station +; Generated 05.02.2001 by mlevel +; Modified 05.02.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1204Gfx1",ROMX +;--------------------------------------------------------------------- +gyro_screen_bg: + INCBIN "Data/Cinema/Ending/gyro_screen.bg" + +button_bg: + INCBIN "Data/Cinema/Ending/button.bg" + +minuteslater_bg: + INCBIN "Data/Cinema/Ending/minuteslater.bg" + +;--------------------------------------------------------------------- +SECTION "Level1204Gfx2",ROMX +;--------------------------------------------------------------------- +appland3d2_bg: + INCBIN "Data/Cinema/Ending/appland3d2.bg" + +appland_sprites_sp: + INCBIN "Data/Cinema/Ending/appland_sprites.sp" + +;--------------------------------------------------------------------- +SECTION "Level1204Gfx3",ROMX +;--------------------------------------------------------------------- +willtheyland_bg: + INCBIN "Data/Cinema/promo/willtheyland.bg" + +haveseenthelast_bg: + INCBIN "Data/Cinema/promo/haveseenthelast.bg" + +publish_bg: + INCBIN "Data/Cinema/promo/publish.bg" + +;--------------------------------------------------------------------- +SECTION "Level1204Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1204_gyro_notthere_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_notthere.gtx" + +L1204_gyro_ofcourse_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_ofcourse.gtx" + +L1204_gyro_unfortunately_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_unfortunately.gtx" + +L1204_gyro_explode_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_explode.gtx" + +L1204_gyro_escape_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_escape.gtx" + +L1204_gyro_button_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gyro_button.gtx" + +L1204_gotitall_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_gotitall.gtx" + +L1204_datahere_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_datahere.gtx" + +L1204_letsroll_gtx: + INCBIN "Data/Dialog/Apocalypse/L1204_letsroll.gtx" + +blank_gtx: + INCBIN "Data/Dialog/Intro/blank.gtx" + +L1204_Contents:: + DW L1204_Load + DW L1204_Init + DW L1204_Check + DW L1204_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1204_Load: + DW ((L1204_LoadFinished - L1204_Load2)) ;size +L1204_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(gyro_screen_bg) + ld hl,gyro_screen_bg + call LoadCinemaBG + + ld a,15 + call SetupFadeFromBlack + call WaitFade + + ld de,((.afterDialog-L1204_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.notThere-L1204_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + +.notThere + ld c,0 + DIALOGBOTTOM L1204_gyro_notthere_gtx + ld de,((.ofCourse-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateGyroOnScreen + + +.ofCourse + ld c,0 + DIALOGBOTTOM L1204_gyro_ofcourse_gtx + ld de,((.unfortunately-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateGyroOnScreen + +.unfortunately + ld c,0 + DIALOGBOTTOM L1204_gyro_unfortunately_gtx + ld de,((.explode-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateGyroOnScreen + +.explode + ld c,0 + DIALOGBOTTOM L1204_gyro_explode_gtx + ld de,((.escape-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateGyroOnScreen + +.escape + ld c,0 + DIALOGBOTTOM L1204_gyro_escape_gtx + ld de,((.button-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateGyroOnScreen + +.button + call ((.quickToBlack-L1204_Load2)+levelCheckRAM) + ld a,BANK(button_bg) + ld hl,button_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1204_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM L1204_gyro_button_gtx + ld de,((.minuteslater-L1204_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,15 +.blinkLoop + push af + ld a,5 + call Delay + ld bc,$1412 + ld de,$0000 + ld hl,$1400 + call CinemaBlitRect + + ld a,5 + call Delay + ld bc,$1412 + ld de,$0000 + ld hl,$2800 + call CinemaBlitRect + pop af + dec a + jr nz,.blinkLoop + +.minuteslater + call ((.quickToBlack-L1204_Load2)+levelCheckRAM) + ld a,BANK(minuteslater_bg) + ld hl,minuteslater_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1204_Load2)+levelCheckRAM) + ld de,((.gotitall-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld a,120 + call Delay + +.gotitall + call ((.quickToBlack-L1204_Load2)+levelCheckRAM) + ld a,BANK(bs_bg) + ld hl,bs_bg + call LoadCinemaBG + call ((.quickFromBlack-L1204_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM L1204_gotitall_gtx + ld de,((.datahere-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateBS + +.datahere + call ((.quickToBlack-L1204_Load2)+levelCheckRAM) + ld a,BANK(haiku_bg) + ld hl,haiku_bg + call LoadCinemaBG + call ((.quickFromBlack-L1204_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM L1204_datahere_gtx + ld de,((.letsroll-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateHaiku + +.letsroll + call ((.quickToBlack-L1204_Load2)+levelCheckRAM) + ld a,BANK(bs_bg) + ld hl,bs_bg + call LoadCinemaBG + call ((.quickFromBlack-L1204_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM L1204_letsroll_gtx + ld de,((.descending-L1204_Load2)+levelCheckRAM) + call SetDialogForward + ld d,2 + LONGCALLNOARGS AnimateBS + +.afterDialog +.descending + ld de,0 + call SetDialogForward + + ld a,15 + call SetupFadeToBlack + call WaitFade + call ResetSprites + call ClearDialog + + ld a,BANK(appland3d2_bg) + ld hl,appland3d2_bg + call LoadCinemaBG + + ld a,BANK(appland_sprites_sp) + ld hl,appland_sprites_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld c,0 + DIALOGBOTTOM blank_gtx + + ld a,15 + call SetupFadeFromBlack + + ;ld de,((.willtheyland-L1204_Load2)+levelCheckRAM) + ;call SetDialogForward + + ld c,24 +.shipScroll1 + ld d,1 + call ScrollSpritesDown + call ((.shakeShip-L1204_Load2)+levelCheckRAM) + ld a,1 + call Delay + dec c + jr nz,.shipScroll1 + + ld a,$11 + ldio [scrollSpeed],a + ld a,30 + ld [camera_j],a + + + ld a,48 +.shipScrollLoop + push af + ld d,1 + call ScrollSpritesDown + call ((.scrollTerrain-L1204_Load2)+levelCheckRAM) + call ((.shakeShip-L1204_Load2)+levelCheckRAM) + ld a,1 + call Delay + pop af + dec a + jr nz,.shipScrollLoop + +.willtheyland + call ClearDialog + ld a,BANK(willtheyland_bg) + ld hl,willtheyland_bg + call LoadCinemaTextBox + call InstallGamePalette + call GfxShowStandardTextBox + + ld de,((.haveseenthelast-L1204_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,120 + call ((.scrollShakeDelay-L1204_Load2)+levelCheckRAM) + +.haveseenthelast + call ClearDialog + ld a,BANK(haveseenthelast_bg) + ld hl,haveseenthelast_bg + call LoadCinemaTextBox + call InstallGamePalette + call GfxShowStandardTextBox + + ld de,((.publish-L1204_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,120 + call ((.scrollShakeDelay-L1204_Load2)+levelCheckRAM) + +.publish + call ClearDialog + ld a,BANK(publish_bg) + ld hl,publish_bg + call LoadCinemaTextBox + call InstallGamePalette + call GfxShowStandardTextBox + + ld de,((.tempEnd-L1204_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,120 + call ((.scrollShakeDelay-L1204_Load2)+levelCheckRAM) + +.tempEnd + +.infi + call ((.scrollTerrain-L1204_Load2)+levelCheckRAM) + call ((.shakeShip-L1204_Load2)+levelCheckRAM) + ld a,1 + call Delay + jr .infi + + ret + +.scrollShakeDelay + push af + call ((.scrollTerrain-L1204_Load2)+levelCheckRAM) + call ((.shakeShip-L1204_Load2)+levelCheckRAM) + ld a,1 + call Delay + pop af + dec a + jr nz,.scrollShakeDelay + +.scrollTerrain + ldio a,[updateTimer] ;frame * 6 + rrca + and %11 + ld b,a + ld a,3 + sub b + rlca + ld b,a + rlca + add b + ld l,a + ld h,$14 + ld bc,$1406 + ld de,$000c + call CinemaBlitRect + ret + +.shakeShip + ;scroll ship vertical by value in shipSineTable + ldio a,[updateTimer] + and 63 + add (((.shipSineTable-L1204_Load2)+levelCheckRAM) & $ff) + ld l,a + ld a,0 + adc ((((.shipSineTable-L1204_Load2)+levelCheckRAM)>>8) & $ff) + ld h,a + ld d,[hl] + call ScrollSpritesDown + ret + +.quickToBlack + call ClearDialog + call ResetSprites + ld a,1 + call SetupFadeToBlack + call WaitFade + ret + +.quickFromBlack + ld a,1 + call SetupFadeFromBlack + call WaitFade + ret + +.shipSineTable + DB 1, 0, 0,255, 0, 1, 0, 0,254, 0, 0, 1, 0, 0, 0, 0 + DB 0, 2, 0, 0,255, 0, 0, 0,254, 0, 0, 0, 1, 0, 0, 0 + DB 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + DB 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + +L1204_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1204_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1204_Init: + DW ((L1204_InitFinished - L1204_Init2)) ;size +L1204_Init2: + ret + +L1204_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1204_Check: + DW ((L1204_CheckFinished - L1204_Check2)) ;size +L1204_Check2: + ret + +L1204_CheckFinished: +PRINT "1204 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1204_LoadFinished - L1204_Load2) +PRINT " / " +PRINT (L1204_InitFinished - L1204_Init2) +PRINT " / " +PRINT (L1204_CheckFinished - L1204_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1212.asm b/Source/Levels/L1212.asm new file mode 100644 index 0000000..93d24b8 --- /dev/null +++ b/Source/Levels/L1212.asm @@ -0,0 +1,189 @@ +; L1212.asm Crouton Homeworld 1 +; Generated 04.19.2001 by mlevel +; Modified 04.19.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +NUM_DIALOG EQU 3 + +HFENCE_INDEX EQU 18 +HULK_INDEX EQU 43 +GOBLIN_INDEX EQU 44 + +VAR_OVERHEARD EQU 0 + +STATE_ANYTIME EQU 0 +STATE_MAKESURE EQU 1 +STATE_SUCKS EQU 2 + +;--------------------------------------------------------------------- +SECTION "Level1212Section",ROMX +;--------------------------------------------------------------------- + +dialog: +L1212_anytime_gtx: + INCBIN "Data/Dialog/Talk/L1212_anytime.gtx" + +L1212_yeah_gtx: + INCBIN "Data/Dialog/Talk/L1212_yeah.gtx" + +L1212_makesure_gtx: + INCBIN "Data/Dialog/Talk/L1212_makesure.gtx" + +L1212_suckstobehim_gtx: + INCBIN "Data/Dialog/Talk/L1212_suckstobehim.gtx" + +L1212_Contents:: + DW L1212_Load + DW L1212_Init + DW L1212_Check + DW L1212_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1212_Load: + DW ((L1212_LoadFinished - L1212_Load2)) ;size +L1212_Load2: + call ParseMap + ret + +L1212_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1212_Map: +INCBIN "Data/Levels/L1212_crouton_hw1.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1212_Init: + DW ((L1212_InitFinished - L1212_Init2)) ;size +L1212_Init2: + ld hl,$1212 + call SetJoinMap + call SetRespawnMap + + call State0To1 + + ld a,BANK(fgbwar_gbm) + ld hl,fgbwar_gbm + call InitMusic + + STDSETUPDIALOG + + xor a + ld [levelVars+VAR_OVERHEARD],a + ret + +L1212_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1212_Check: + DW ((L1212_CheckFinished - L1212_Check2)) ;size +L1212_Check2: + call ((.animateFence-L1212_Check2)+levelCheckRAM) + call ((.checkDialog-L1212_Check2)+levelCheckRAM) + ret + +.checkDialog + ld a,[levelVars+VAR_OVERHEARD] + or a + ret nz + + ld hl,((.checkHeroInZone-L1212_Check2)+levelCheckRAM) + xor a + call CheckEachHero + ret + +.checkHeroInZone + ld c,a + call GetFirst + call GetCurZone + cp 2 + jr z,.inZone + + xor a + ret + +.inZone + ;increment dialog number + ld hl,mapState + ld a,[hl] + push af + inc a + cp (NUM_DIALOG+1) + jr c,.dialogNumOkay + + ld a,1 + +.dialogNumOkay + ld [hl],a + pop af + + ld hl,((.dialogLookup-L1212_Check2)+levelCheckRAM) + call Lookup16 + + push hl + call MakeIdle + pop hl + ld de,((.afterDialog-L1212_Check2)+levelCheckRAM) + call SetDialogSkip + + ld d,h + ld e,l + call SetSpeakerFromHeroIndex + ld c,HULK_INDEX + call ShowDialogAtTop + + call ClearDialog + ld c,GOBLIN_INDEX + ld de,L1212_yeah_gtx + call ShowDialogAtBottom + +.afterDialog + call ClearDialogSkipForward + call MakeNonIdle + + ld a,1 + ld [levelVars+VAR_OVERHEARD],a + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+HFENCE_INDEX + ld d,HFENCE_INDEX + call ((.animateFourFrames-L1212_Check2)+levelCheckRAM) + ret + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + +.dialogLookup + DW 0,L1212_anytime_gtx,L1212_makesure_gtx,L1212_suckstobehim_gtx + +L1212_CheckFinished: +PRINT "1212 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1212_LoadFinished - L1212_Load2) +PRINT " / " +PRINT (L1212_InitFinished - L1212_Init2) +PRINT " / " +PRINT (L1212_CheckFinished - L1212_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1300.asm b/Source/Levels/L1300.asm new file mode 100644 index 0000000..3167435 --- /dev/null +++ b/Source/Levels/L1300.asm @@ -0,0 +1,313 @@ +; L1300.asm appomattox interior +; Generated 02.16.2001 by mlevel +; Modified 02.16.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Start.inc" + +DICEINDEX EQU 6 +GRENADE_INDEX EQU 170 +BAINDEX EQU 173 +BSINDEX EQU 174 +HAIKUINDEX EQU 175 + +VAR_DICELIGHT EQU 0 +VAR_HEROESUSED EQU 1 +VAR_BA EQU 2 +VAR_BS EQU 3 +VAR_HAIKU EQU 4 + + +;--------------------------------------------------------------------- +SECTION "Level1300Section",ROMX +;--------------------------------------------------------------------- + +L1300_Contents:: + DW L1300_Load + DW L1300_Init + DW L1300_Check + DW L1300_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1300_Load: + DW ((L1300_LoadFinished - L1300_Load2)) ;size +L1300_Load2: + call ParseMap + + ;reset heroes to full health + xor a + ld [hero0_health],a + ld [hero1_health],a + ret + +L1300_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1300_Map: +INCBIN "Data/Levels/L1300_appomattox.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1300_Init: + DW ((L1300_InitFinished - L1300_Init2)) ;size +L1300_Init2: + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld hl,$1100 + call SetJoinMap + call SetRespawnMap + + ld a,[bgTileMap+DICEINDEX] ;tile index of first light + ld [levelVars+VAR_DICELIGHT],a + + ld a,0 + ld [levelVars+VAR_HEROESUSED],a + + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,[fgTileMap+BAINDEX] + ld [levelVars+VAR_BA],a + ld a,[fgTileMap+BSINDEX] + ld [levelVars+VAR_BS],a + ld a,[fgTileMap+HAIKUINDEX] + ld [levelVars+VAR_HAIKU],a + + ;get rid of king grenade if he's not available + ld a,[heroesAvailable] + and HERO_GRENADE_FLAG + jr nz,.afterRemoveKingGrenade + + ld bc,classGeneric + call DeleteObjectsOfClass +.afterRemoveKingGrenade + + ;link down exit to appomattox map + ld a,[appomattoxMapIndex] + or a + jr z,.afterLinkDownExit + + ;convert map index to 16-bit BCD index + ld b,a + and %1111 + call NumberToBCD + ld d,a + ld a,b + swap a + and %1111 + call NumberToBCD + ld e,a + +IF FORCE_EXIT +ld de,FORCE_EXIT_MAP +ENDC + ;store in exit list + ld hl,mapExitLinks+EXIT_D*2 + ld [hl],e + inc hl + ld [hl],d + +.afterLinkDownExit + ;if player is king grenade and appx is not at base camp, + ;set exit to "back inside" level + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + cp HERO_GRENADE_FLAG + jr nz,.afterLinkGrenade + + ld a,[appomattoxMapIndex] + cp $000a + jr z,.afterLinkGrenade + + ld de,$1304 + ld hl,mapExitLinks+EXIT_D*2 + ld [hl],e + inc hl + ld [hl],d + +.afterLinkGrenade + ;kill north exit (flight) if at space station + ld a,[appomattoxMapIndex] + cp $b7 + jr nz,.afterApocalypse + + ld de,$4040 ;null exit + ld hl,mapExitLinks+EXIT_N*2 + ld [hl],e + inc hl + ld [hl],d + +.afterApocalypse + ret + +L1300_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1300_Check: + DW ((L1300_CheckFinished - L1300_Check2)) ;size +L1300_Check2: + call ((.animateDiceLights-L1300_Check2)+levelCheckRAM) + + ld a,[levelVars+VAR_HEROESUSED] + ld hl,heroesUsed + xor [hl] + jr z,.afterChangeLounge + + ld a,[hl] + ld [levelVars+VAR_HEROESUSED],a + ld b,a + + bit HERO_BA_BIT,b + jr z,.BAinLounge + call ((.removeBA-L1300_Check2)+levelCheckRAM) + jr .afterCheckBA +.BAinLounge + call ((.addBA-L1300_Check2)+levelCheckRAM) +.afterCheckBA + + bit HERO_BS_BIT,b + jr z,.BSinLounge + call ((.removeBS-L1300_Check2)+levelCheckRAM) + jr .afterCheckBS +.BSinLounge + call ((.addBS-L1300_Check2)+levelCheckRAM) +.afterCheckBS + + bit HERO_HAIKU_BIT,b + jr z,.HaikuInLounge + call ((.removeHaiku-L1300_Check2)+levelCheckRAM) + jr .afterCheckHaiku +.HaikuInLounge + call ((.addHaiku-L1300_Check2)+levelCheckRAM) +.afterCheckHaiku + + bit HERO_GRENADE_BIT,b + jr z,.GrenadeInLounge + call ((.removeGrenade-L1300_Check2)+levelCheckRAM) + jr .afterCheckGrenade +.GrenadeInLounge + call ((.addGrenade-L1300_Check2)+levelCheckRAM) +.afterCheckGrenade + +.afterChangeLounge + ret + +.removeHaiku + ld c,HAIKUINDEX + jr .removeIndex +.removeBS + ld c,BSINDEX + jr .removeIndex +.removeBA + ld c,BAINDEX +.removeIndex + push bc + ld a,TILEINDEXBANK + ldio [$ff70],a + ld l,c + ld h,((fgTileMap>>8)&$ff) + ld [hl],$ff + call GetFirst + ld b,METHOD_DRAW + call CallMethod + pop bc + ret + +.removeGrenade + ld bc,classGeneric + call DeleteObjectsOfClass + ret + +.addHaiku + ld l,HAIKUINDEX + ld a,[levelVars+VAR_HAIKU] + jr .addIndex +.addBS + ld l,BSINDEX + ld a,[levelVars+VAR_BS] + jr .addIndex +.addBA + ld l,BAINDEX + ld a,[levelVars+VAR_BA] +.addIndex + push bc + ld c,a + ld a,TILEINDEXBANK + ldio [$ff70],a + ld a,c + ld h,((fgTileMap>>8)&$ff) + ld [hl],a + ld c,l + call GetFirst + ld b,METHOD_DRAW + call CallMethod + pop bc + ret + +.addGrenade + ld a,[heroesAvailable] + and HERO_GRENADE_FLAG + ret z + + ld c,GRENADE_INDEX + call GetFirst + or a + ret nz ;already exists + + ld hl,$d253 + call CreateInitAndDrawObject + ret + +.animateDiceLights + ;animate dice lights + ld a,[levelVars+VAR_DICELIGHT] + ld b,a + + ;slow lights + ldio a,[updateTimer] + swap a + and %00000011 + add b + + ld hl,bgTileMap+DICEINDEX + call ((.updateTwoLights - L1300_Check2) + levelCheckRAM) + + ;fast lights + ldio a,[updateTimer] + swap a + rlca + and %00000011 + add b + call ((.updateTwoLights - L1300_Check2) + levelCheckRAM) + ret + +.updateTwoLights + ld [hl+],a + call ((.incCount4 - L1300_Check2) + levelCheckRAM) + ld [hl+],a + ret + +.incCount4 + sub b + inc a + and %00000011 + add b + ret + + +L1300_CheckFinished: +PRINT "1300 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1300_LoadFinished - L1300_Load2) +PRINT " / " +PRINT (L1300_InitFinished - L1300_Init2) +PRINT " / " +PRINT (L1300_CheckFinished - L1300_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1301.asm b/Source/Levels/L1301.asm new file mode 100644 index 0000000..82a41aa --- /dev/null +++ b/Source/Levels/L1301.asm @@ -0,0 +1,261 @@ +; L1301.asm map view +; Generated 02.22.2001 by mlevel +; Modified 02.22.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_MAPI EQU 0 +VAR_MAPJ EQU 1 + + +;--------------------------------------------------------------------- +SECTION "Level1301Section",ROMX +;--------------------------------------------------------------------- + +fgbmap_bg: + INCBIN "Data/Cinema/Appomattox/fgbmap_big.bg" + +L1301_Contents:: + DW L1301_Load + DW L1301_Init + DW L1301_Check + DW L1301_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1301_Load: + DW ((L1301_LoadFinished - L1301_Load2)) ;size +L1301_Load2: + ld a,BANK(fgbmap_bg) + ld hl,fgbmap_bg + call LoadCinemaBG + + ld a,[appomattoxMapIndex] + cp $b7 + jp z,((.onSpaceStation-L1301_Load2)+levelCheckRAM) + + ;ld a,LEVELSTATEBANK + ;ldio [$ff70],a + ;ld a,[levelState+$2e] ;off moon yet? + ;or a + ;jp z,((.onMoon-L1301_Load2)+levelCheckRAM) + + ;clear unvisited zones + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld hl,$d000 + ld b,0 +.outer ld c,0 +.inner ld a,b ;a = b*16 + c + swap a + or c + ld d,((levelState>>8)&$ff) + ld e,a + ld a,[de] + or a + jr nz,.continue + + ld a,TILESHADOWBANK + ldio [$ff70],a + push hl + ld de,61 + xor a + ld [hl+],a + ld [hl+],a + ld [hl+],a + add hl,de + ld [hl+],a + ld [hl+],a + ld [hl+],a + add hl,de + ld [hl+],a + ld [hl+],a + ld [hl+],a + pop hl + ld a,LEVELSTATEBANK + ldio [$ff70],a + +.continue + inc hl + inc hl + inc hl + inc c + ld a,c + cp 11 + jr nz,.inner + ld de,64*3-33 + add hl,de + inc b + ld a,b + cp 11 + jr nz,.outer + +.findMapIndex + ;figure out map index + ld a,[appomattoxMapIndex] + cp $c7 + jr nz,.notFarmLanding + ld a,$31 +.notFarmLanding + ld b,a + and %1111 + ld c,a ;*3 + rlca + add c + ld [levelVars+VAR_MAPI],a + ld [camera_i],a + ld c,a + cp 9 + jr c,.afterSub9 + ld c,9 +.afterSub9 + sub c + ld [mapLeft],a + ld a,b + swap a + and %1111 + ld c,a ;*3 + rlca + add c + ld [levelVars+VAR_MAPJ],a + ld [camera_j],a + ld c,a + cp 8 + jr c,.afterSub8 + ld c,8 +.afterSub8 + sub c + ld [mapTop],a + + ;constrain horizontal + ld a,[levelVars+VAR_MAPI] + cp 23 + jr c,.hokay + ld a,22 + ld [levelVars+VAR_MAPI],a + ld a,13 + ld [mapLeft],a +.hokay + + ;constrain vertical + ld a,[levelVars+VAR_MAPJ] + cp 24 + jr c,.vokay + ld a,23 + ld [levelVars+VAR_MAPJ],a + ld a,15 + ld [mapTop],a +.vokay + + ld a,15 + call SetupFadeFromStandard + +.loop + ld a,1 + call Delay + ld a,[myJoy] + ld b,a + + ld a,[levelVars+VAR_MAPI] + ld [camera_i],a + ld a,[levelVars+VAR_MAPJ] + ld [camera_j],a +.checkLeft + xor a + bit JOY_LEFT_BIT,b + jr z,.checkUp + ld [camera_i],a +.checkUp + bit JOY_UP_BIT,b + jr z,.checkRight + ld [camera_j],a +.checkRight + ld a,22 + bit JOY_RIGHT_BIT,b + jr z,.checkDown + ld [camera_i],a +.checkDown + bit JOY_DOWN_BIT,b + jr z,.checkExit + ld a,23 + ld [camera_j],a + +.checkExit + ld a,b + and (JOY_A | JOY_B | JOY_START) + jr z,.loop + +.exit + ld a,15 + call SetupFadeToStandard + call WaitFade + + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_W + ld [hl],a + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.onSpaceStation + ld a,BANK(station_tactical_bg) + ld hl,station_tactical_bg + call LoadCinemaBG + jr .loadAlternate + +.onMoon + ld a,BANK(moontact_bg) + ld hl,moontact_bg + call LoadCinemaBG + +.loadAlternate + ld a,15 + call SetupFadeFromStandard + +.waitExit + ld a,1 + call Delay + ld a,[myJoy] + and (JOY_A | JOY_B | JOY_START) + jr z,.waitExit + jr .exit + +L1301_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1301_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1301_Init: + DW ((L1301_InitFinished - L1301_Init2)) ;size +L1301_Init2: + ret + +L1301_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1301_Check: + DW ((L1301_CheckFinished - L1301_Check2)) ;size +L1301_Check2: + ret + +L1301_CheckFinished: +PRINT "1301 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1301_LoadFinished - L1301_Load2) +PRINT " / " +PRINT (L1301_InitFinished - L1301_Init2) +PRINT " / " +PRINT (L1301_CheckFinished - L1301_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1302.asm b/Source/Levels/L1302.asm new file mode 100644 index 0000000..41e9633 --- /dev/null +++ b/Source/Levels/L1302.asm @@ -0,0 +1,369 @@ +; L1302.asm gyves cornered cinema +; Generated 07.31.2000 by mlevel +; Modified 07.31.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1302Section",ROMX +;--------------------------------------------------------------------- + +L1302_Contents:: + DW L1302_Load + DW L1302_Init + DW L1302_Check + DW L1302_Map + +gyro_cornered_bg: + INCBIN "Data/Cinema/Intro/gyrocornered.bg" + +gyro_cornered_gun_sp: + INCBIN "Data/Cinema/Intro/gyro_cornered_gun.sp" + +dialog: +gyro_cornered1_gtx: + INCBIN "Data/Dialog/Intro/gyro_cornered1.gtx" + +gyro_cornered2_gtx: + INCBIN "Data/Dialog/Intro/gyro_cornered2.gtx" + +gyro_cornered3_gtx: + INCBIN "Data/Dialog/Intro/gyro_cornered3.gtx" + +gyro_cornered4_gtx: + INCBIN "Data/Dialog/Intro/gyro_cornered4.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1302_Load: + DW ((L1302_LoadFinished - L1302_Load2)) ;size +L1302_Load2: + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld a,BANK(gyro_cornered_bg) + ld hl,gyro_cornered_bg + call LoadCinemaBG + + ld a,BANK(gyro_cornered_gun_sp) + ld hl,gyro_cornered_gun_sp + call LoadCinemaSprite + + ld d,162 + call ScrollSpritesRight + + ld d,40 + call ScrollSpritesDown + + ;cur palette to game palette + gun quarter-bright + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ;fade from black to gun quarter-bright + ;cur palette to all white + ld hl,fadeCurPalette + call FadeCommonSetPaletteToBlack + + ld hl,fadeFinalPalette + 64 + ld d,8 + call ((.paletteToQuarterBright - L1302_Load2) + levelCheckRAM) + + ld a,16 + call FadeInit + call WaitFade + + ld de,((.endCinema - L1302_Load2) + levelCheckRAM) + call SetDialogSkip + ld de,((.dialog1 - L1302_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,16 + call Delay + + ;----focus on gun--------------------------------------------- + call ((.setupFadeToFocusOnGun-L1302_Load2) + levelCheckRAM) + ld a,60 + call FadeInit + + ;slide gun out as fade is happening + ld c,60 +.slideGunOutLoop + ld d,1 + call ScrollSpritesLeft + ld a,1 + call Delay + dec c + jr nz,.slideGunOutLoop + + ld a,30 + call Delay + + ld a,BANK(gyro_cornered1_gtx) + ld c,0 + ld de,gyro_cornered1_gtx + call ShowDialogAtBottomNoWait + +.dialog1 + call ((.showGunForSure - L1302_Load2) + levelCheckRAM) + ;----gyro says wait------------------------------------------- + ld de,((.dialog2 - L1302_Load2) + levelCheckRAM) + call SetDialogForward + + ld b,3 + call ((.animateGyro-L1302_Load2)+levelCheckRAM) + + ;----focus on gyro-------------------------------------------- + call ((.setupFadeToFocusOnGyro-L1302_Load2) + levelCheckRAM) + ld a,60 + call FadeInit + + ld c,120 + ld b,0 +.hideGunLoop + ld a,b + srl a + and 1 + ld d,a + call ScrollSpritesRight + ld a,1 + call Delay + inc b + dec c + jr nz,.hideGunLoop + +.dialog2 + call ((.hideGunForSure - L1302_Load2) + levelCheckRAM) + ;----gyro makes the deal-------------------------------------- + ld de,((.dialog3 - L1302_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(gyro_cornered2_gtx) + ld c,0 + ld de,gyro_cornered2_gtx + call ShowDialogAtBottomNoWait + + ld b,4 + call ((.animateGyro-L1302_Load2)+levelCheckRAM) + +.dialog3 + ld de,((.dialog4 - L1302_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(gyro_cornered3_gtx) + ld c,0 + ld de,gyro_cornered3_gtx + call ShowDialogAtBottomNoWait + + ld b,5 + call ((.animateGyro-L1302_Load2)+levelCheckRAM) + +.dialog4 + ld de,((.endCinema - L1302_Load2) + levelCheckRAM) + call SetDialogForward + + ld a,BANK(gyro_cornered4_gtx) + ld c,0 + ld de,gyro_cornered4_gtx + call ShowDialogAtBottomNoWait + + ld b,5 + call ((.animateGyro-L1302_Load2)+levelCheckRAM) + +.endCinema + call ClearDialog + ld a,16 + call SetupFadeToStandard + call WaitFade + + ld hl,$1202 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.animateGyro + ;b already set up with # of loops + sla b ;b*=4 + sla b +.gyroEyes + ld c,4 + +.gyroTalk + push bc + ld a,3 + call Delay + + ld a,b + cp 8 + ld a,2 + jr nc,.animate + ld a,1 + +.animate + ;animate mouth + ld bc,$0604 + ld de,$0806 + ld hl,$1402 + call CinemaSpotAnimationRandomVerticalFrames + pop bc + dec c + jr nz,.gyroTalk + + ;animate eye + push bc + ld a,4 + ld bc,$0202 + ld de,$0704 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + pop bc + dec b + jr nz,.gyroEyes + + ;open eye at end + ld a,1 + ld bc,$0202 + ld de,$0704 + ld hl,$1400 + call CinemaSpotAnimationRandomHorizontalFrames + ld a,10 + call Delay + ret + +.paletteToQuarterBright + push bc + push de + push hl + ld a,FADEBANK + ldio [$ff70],a + +.quarterBrightLoop + ld a,[hl+] + ld c,a + ld a,[hl-] + ld b,a + call GetRedComponent + srl a + srl a + call SetRedComponent + call GetGreenComponent + srl a + srl a + call SetGreenComponent + call GetBlueComponent + srl a + srl a + call SetBlueComponent + ld a,c + ld [hl+],a + ld a,b + ld [hl+],a + dec d + jr nz,.quarterBrightLoop + pop hl + pop de + pop bc + ret + +.setupFadeToFocusOnGun + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeFinalPalette + 8 + ld d,28 + call ((.paletteToQuarterBright - L1302_Load2) + levelCheckRAM) + ld hl,fadeCurPalette + 64 + ld d,8 + call ((.paletteToQuarterBright - L1302_Load2) + levelCheckRAM) + ret + +.setupFadeToFocusOnGyro + ld a,FADEBANK + ldio [$ff70],a + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld hl,fadeFinalPalette + 64 + ld d,8 + call ((.paletteToQuarterBright-L1302_Load2)+levelCheckRAM) + ld hl,fadeCurPalette + 8 + ld d,28 + call ((.paletteToQuarterBright-L1302_Load2)+levelCheckRAM) + ret + +.showGunForSure + ld hl,spriteOAMBuffer + 1 + ld a,[hl] ;first sprite x pos + sub 102+8 ;minus desired x pos + ld d,a + call ScrollSpritesLeft ;is amount to scroll sprites + + call ((.setupFadeToFocusOnGun-L1302_Load2) + levelCheckRAM) + ld a,1 + call FadeInit + ret + +.hideGunForSure + ld hl,spriteOAMBuffer + 1 + ld a,162+8 ;desired x pos + sub [hl] ;minus first sprite x pos + ld d,a + call ScrollSpritesRight ;is amount to scroll sprites + + call ((.setupFadeToFocusOnGyro-L1302_Load2)+levelCheckRAM) + ld a,1 + call FadeInit + ret + +L1302_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1302_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1302_Init: + DW ((L1302_InitFinished - L1302_Init2)) ;size +L1302_Init2: + ret + +L1302_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1302_Check: + DW ((L1302_CheckFinished - L1302_Check2)) ;size +L1302_Check2: + ret + +L1302_CheckFinished: +PRINT "1302 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1302_LoadFinished - L1302_Load2) +PRINT " / " +PRINT (L1302_InitFinished - L1302_Init2) +PRINT " / " +PRINT (L1302_CheckFinished - L1302_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1304.asm b/Source/Levels/L1304.asm new file mode 100644 index 0000000..eb8d50c --- /dev/null +++ b/Source/Levels/L1304.asm @@ -0,0 +1,97 @@ +; L1304.asm +; Generated 05.08.2001 by mlevel +; Modified 05.08.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1304Gfx",ROMX +;--------------------------------------------------------------------- +backinside_bg: + INCBIN "Data/Cinema/CharSelect/backinside.bg" + +;--------------------------------------------------------------------- +SECTION "Level1304Section",ROMX +;--------------------------------------------------------------------- + +L1304_Contents:: + DW L1304_Load + DW L1304_Init + DW L1304_Check + DW L1304_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1304_Load: + DW ((L1304_LoadFinished - L1304_Load2)) ;size +L1304_Load2: + ld a,BANK(backinside_bg) + ld hl,backinside_bg + call LoadCinemaBG + + ld a,15 + call SetupFadeFromStandard + call WaitFade + + ld de,((.returnToShip-L1304_Load2)+levelCheckRAM) + call SetDialogForward + call SetDialogSkip + + ld a,150 + call Delay + +.returnToShip + call ClearDialogSkipForward + + ld a,15 + call SetupFadeToStandard + call WaitFade + + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +L1304_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1304_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1304_Init: + DW ((L1304_InitFinished - L1304_Init2)) ;size +L1304_Init2: + ret + +L1304_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1304_Check: + DW ((L1304_CheckFinished - L1304_Check2)) ;size +L1304_Check2: + ret + +L1304_CheckFinished: +PRINT "1304 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1304_LoadFinished - L1304_Load2) +PRINT " / " +PRINT (L1304_InitFinished - L1304_Init2) +PRINT " / " +PRINT (L1304_CheckFinished - L1304_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1312.asm b/Source/Levels/L1312.asm new file mode 100644 index 0000000..2db31b2 --- /dev/null +++ b/Source/Levels/L1312.asm @@ -0,0 +1,59 @@ +; L1312.asm Crouton Homeworld 2 +; Generated 04.19.2001 by mlevel +; Modified 04.19.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1312Section",ROMX +;--------------------------------------------------------------------- + +L1312_Contents:: + DW L1312_Load + DW L1312_Init + DW L1312_Check + DW L1312_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1312_Load: + DW ((L1312_LoadFinished - L1312_Load2)) ;size +L1312_Load2: + call ParseMap + ret + +L1312_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1312_Map: +INCBIN "Data/Levels/L1312_crouton_hw2.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1312_Init: + DW ((L1312_InitFinished - L1312_Init2)) ;size +L1312_Init2: + ret + +L1312_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1312_Check: + DW ((L1312_CheckFinished - L1312_Check2)) ;size +L1312_Check2: + ret + +L1312_CheckFinished: +PRINT "1312 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1312_LoadFinished - L1312_Load2) +PRINT " / " +PRINT (L1312_InitFinished - L1312_Init2) +PRINT " / " +PRINT (L1312_CheckFinished - L1312_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1400.asm b/Source/Levels/L1400.asm new file mode 100644 index 0000000..7f96fe0 --- /dev/null +++ b/Source/Levels/L1400.asm @@ -0,0 +1,659 @@ +; L1400.asm Appomattox flying +; Generated 02.21.2001 by mlevel +; Modified 02.21.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_DESTZONE EQU 0 +VAR_DESTCOLOR EQU 1 +VAR_DESTBG EQU 3 +VAR_DESTBANK EQU 5 + +VAR_SELSTAGE EQU 6 + + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ1",ROMX +;--------------------------------------------------------------------- +lz_mist_bg:: + INCBIN "Data/Cinema/Appomattox/lz_mist.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ2",ROMX +;--------------------------------------------------------------------- +lz_ice1_bg:: + INCBIN "Data/Cinema/Appomattox/lz_ice1.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ3",ROMX +;--------------------------------------------------------------------- +lz_gate_bg:: + INCBIN "Data/Cinema/Appomattox/lz_gate.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ4",ROMX +;--------------------------------------------------------------------- +lz_brokenwall_bg:: + INCBIN "Data/Cinema/Appomattox/lz_brokenwall.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ5",ROMX +;--------------------------------------------------------------------- +lz_canyon_bg:: + INCBIN "Data/Cinema/Appomattox/lz_canyon.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ6",ROMX +;--------------------------------------------------------------------- +lz_desert_bg:: + INCBIN "Data/Cinema/Appomattox/lz_desert.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ7",ROMX +;--------------------------------------------------------------------- +lz_graves_bg:: + INCBIN "Data/Cinema/Appomattox/lz_graves.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ8",ROMX +;--------------------------------------------------------------------- +lz_icecubes_bg:: + INCBIN "Data/Cinema/Appomattox/lz_icecubes.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ9",ROMX +;--------------------------------------------------------------------- +lz_jungle_bg:: + INCBIN "Data/Cinema/Appomattox/lz_jungle.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ10",ROMX +;--------------------------------------------------------------------- +lz_mountains_bg:: + INCBIN "Data/Cinema/Appomattox/lz_mountains.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ11",ROMX +;--------------------------------------------------------------------- +lz_ocean_bg:: + INCBIN "Data/Cinema/Appomattox/lz_ocean.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ12",ROMX +;--------------------------------------------------------------------- +lz_pencil_bg:: + INCBIN "Data/Cinema/Appomattox/lz_pencil.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionLZ13",ROMX +;--------------------------------------------------------------------- +lz_treepath_bg:: + INCBIN "Data/Cinema/Appomattox/lz_treepath.bg" + + +;--------------------------------------------------------------------- +SECTION "Level1400SectionData3",ROMX +;--------------------------------------------------------------------- +lz_trees1_bg:: + INCBIN "Data/Cinema/Appomattox/lz_trees1.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400SectionData2",ROMX +;--------------------------------------------------------------------- +cloud0_bg:: + INCBIN "Data/Cinema/Appomattox/cloud0.bg" +cloud1_bg:: + INCBIN "Data/Cinema/Appomattox/cloud1.bg" +cloud2_bg:: + INCBIN "Data/Cinema/Appomattox/cloud2.bg" +cloud3_bg:: + INCBIN "Data/Cinema/Appomattox/cloud3.bg" +cloud4_bg:: + INCBIN "Data/Cinema/Appomattox/cloud4.bg" + +;--------------------------------------------------------------------- +SECTION "Level1400Section",ROMX +;--------------------------------------------------------------------- + +cloud5_bg:: + INCBIN "Data/Cinema/Appomattox/cloud5.bg" +cloud6_bg:: + INCBIN "Data/Cinema/Appomattox/cloud6.bg" +cloud7_bg:: + INCBIN "Data/Cinema/Appomattox/cloud7.bg" + +L1400_Contents:: + DW L1400_Load + DW L1400_Init + DW L1400_Check + DW L1400_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1400_Load: + DW ((L1400_LoadFinished - L1400_Load2)) ;size +L1400_Load2: + ld a,1 + ld [displayType],a + xor a + ld [scrollSprites],a + + ld a,200 + ldio [jiggleDuration],a + + ld a,1 + ldio [jiggleType],a ;take-off jiggle + + ld hl,musicEnabled ;disable track 4 + res 3,[hl] + + ld hl,((.engineSound1-L1400_Load2)+levelCheckRAM) + call PlaySound + + ld a,$11 + ldio [scrollSpeed],a + + + ld de,((.tookOff-L1400_Load2)+levelCheckRAM) + call SetDialogSkip + call SetDialogForward + + ld a,60 + call ((.delayAnimateWave-L1400_Load2)+levelCheckRAM) + + xor a + ld [camera_j],a + + ld hl,((.engineSound2-L1400_Load2)+levelCheckRAM) + call PlaySound + + ld a,69 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + +.tookOff + ld hl,((.silentSound4-L1400_Load2)+levelCheckRAM) + call PlaySound + call ClearSkipForward + xor a + ldio [jiggleDuration],a + ld [mapTop],a + ld a,1 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + + ld hl,musicEnabled ;enable track 4 + set 3,[hl] + + ld a,1 + call ((.setupFadeFromSky-L1400_Load2)+levelCheckRAM) + ld a,1 + call Delay + + ld de,((.skipToLanding-L1400_Load2)+levelCheckRAM) + call SetDialogSkip + call SetDialogForward + +.flying + ld a,BANK(cloud0_bg) + ld hl,cloud0_bg + call LoadCinemaBG + + ld a,15 + call ((.setupFadeToClouds-L1400_Load2)+levelCheckRAM) + + ld b,50 + ld c,1 +.cloudAnim + ;load next cloud frame + ld d,0 ;de = c*4 + ld e,c + sla e + rl d + sla e + rl d + ld hl,((.cloudFrames-L1400_Load2)+levelCheckRAM) + add hl,de + ld a,[hl+] ;mem bank of cloud frame + inc hl + push af + ld a,[hl+] + ld h,[hl] + ld l,a + pop af + call LoadCinemaBG + ;ld a,1 + ;call Delay + call ((.animateWave-L1400_Load2)+levelCheckRAM) + + ld a,c + inc a + and 7 + ld c,a + + ld a,b + cp 20 + jr nz,.afterStartFadeOutInClouds + + ld a,15 + call ((.setupFadeToSky-L1400_Load2)+levelCheckRAM) + +.afterStartFadeOutInClouds + dec b + jr nz,.cloudAnim + jr .naturalLanding + +.skipToLanding + call ClearSkipForward + ld a,15 + call ((.setupFadeToSky-L1400_Load2)+levelCheckRAM) + call WaitFade + +.naturalLanding + ld a,3 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1400_Load2)+levelCheckRAM) + +;----Load picture of new landing zone--------------------------------- + ld hl,levelVars+VAR_DESTBANK + ld a,[hl-] + push af + ld a,[hl-] + ld l,[hl] + ld h,a + pop af + call LoadCinemaBG + ld a,1 + call Delay + + ld a,FADEBANK + ld [$ff70],a + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld a,1 + call FadeInit + call WaitFade + ld a,2 + call Delay + + ld a,190 + ldio [jiggleDuration],a + + ld a,1 + ldio [jiggleType],a ;take-off jiggle + + ld a,18 + ld [camera_j],a + + ld a,$11 + ldio [scrollSpeed],a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterRemoteAppx + +.addRemoteAppx + ld a,LCHANGEAPPXMAP + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.addRemoteAppx ;must repeat + ld a,[appomattoxMapIndex] + call TransmitByte +.afterRemoteAppx + + ld de,((.landed-L1400_Load2)+levelCheckRAM) + call SetDialogSkip + call SetDialogForward + + ld hl,musicEnabled ;disable track 4 + res 3,[hl] + + ld hl,((.engineSound1-L1400_Load2)+levelCheckRAM) + call PlaySound + + ld a,40 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + + ld a,2 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1400_Load2)+levelCheckRAM) + + ld a,40 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + + ld a,1 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1400_Load2)+levelCheckRAM) + + ld hl,((.engineSound2-L1400_Load2)+levelCheckRAM) + call PlaySound + + ld a,30 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + + xor a + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1400_Load2)+levelCheckRAM) + + ld a,30 + call ((.delayAdjustHorizon-L1400_Load2)+levelCheckRAM) + + ld hl,musicEnabled ;enable track 4 + set 3,[hl] + + call ((.powerDown-L1400_Load2)+levelCheckRAM) + +.landed + ld hl,((.silentSound4-L1400_Load2)+levelCheckRAM) + call PlaySound + xor a + ldio [jiggleDuration],a + call ClearSkipForward + ld a,15 + call SetupFadeToStandard + call WaitFade + call ClearDialog + ld a,2 + call Delay + + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_N + ld [hl],a + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.powerDown + ;xor a + ;ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1400_Load2)+levelCheckRAM) + call ((.recticleOff-L1400_Load2)+levelCheckRAM) + call ((.horizonOff-L1400_Load2)+levelCheckRAM) + call ((.diagramOff-L1400_Load2)+levelCheckRAM) + ld a,30 + call ((.delayAnimateWave-L1400_Load2)+levelCheckRAM) + ret + +.silentSound4 + DB 4,0,0,0,$c0 + +.setPowerBar + ld a,[levelVars+VAR_SELSTAGE] + inc a + ld [musicRegisters+0],a + dec a + rlca ;sprite = stage*4 + 44 + rlca + add 44 + ld hl,spriteOAMBuffer+22*4+2 + ld [hl+],a + inc hl + inc hl + inc hl + add 2 + ld [hl],a + + ;ld hl,((.buttonSound-L1400_Load2)+levelCheckRAM) + ;call PlaySound + ret + +.horizonOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+16*4 + ld c,4 +.horizonOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.horizonOffLoop + ret + +.recticleOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+8*4 + ld c,8 +.recticleOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.recticleOffLoop + ret + +.diagramOff + ld hl,spriteOAMBuffer+20*4 + ld [hl],160 + ld hl,spriteOAMBuffer+21*4 + ld [hl],160 + ret + + +.delayAdjustHorizon + ld c,a + ld hl,spriteOAMBuffer+16*4 + ld de,4 +.delayLoop + call ((.animateWave-L1400_Load2)+levelCheckRAM) + + ld a,1 + call Delay + + ;horizon = 58 - ((mapTop*8+desiredPixelOffset_y)/4) + ld a,[mapTop] + rlca + rlca + rlca + ld b,a + ld a,[desiredPixelOffset_y] + add b + srl a + srl a + cpl + add 59 + + push hl + ld b,4 +.alterHorizonSpriteLoop + ld [hl],a + add hl,de + dec b + jr nz,.alterHorizonSpriteLoop + pop hl + dec c + jr nz,.delayLoop + ret + + +.setupFadeFromSky + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette bg7 to be bg7 color 0 + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld hl,fadeFinalPalette+8*7 + ld a,[hl+] + ld c,a + ld b,[hl] + ;call ((.getLandingInfo-L1400_Load2)+levelCheckRAM) + ld hl,fadeFinalPalette+8*7 + call ((.setBG7-L1400_Load2)+levelCheckRAM) + + pop af + call FadeInit + ret + +.setBG7 + ;copy bc to 4 entries at palette hl + ld hl,fadeFinalPalette+8*7 + ld a,4 +.setBG7Loop + ld [hl],c + inc hl + ld [hl],b + inc hl + dec a + jr nz,.setBG7Loop + ret + +.setupFadeToSky + push bc + push de + push hl + + push af + + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ld hl,levelVars+VAR_DESTZONE + ld a,[hl+] + ld [appomattoxMapIndex],a + ld a,[hl+] + ld b,[hl] + ld c,a + ld hl,fadeCurPalette+8*7 + call ((.setBG7-L1400_Load2)+levelCheckRAM) + pop af + call FadeInit + pop hl + pop de + pop bc + ret + +.defaultSkyColor + ld bc,$7e20 + ret + +.setupFadeToClouds + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette bg7 to be bg7 color 0 + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + pop af + call FadeInit + ret + +.cloudFrames + DW BANK(cloud0_bg), cloud0_bg, BANK(cloud1_bg), cloud1_bg + DW BANK(cloud2_bg), cloud2_bg, BANK(cloud3_bg), cloud3_bg + DW BANK(cloud4_bg), cloud4_bg, BANK(cloud5_bg), cloud5_bg + DW BANK(cloud6_bg), cloud6_bg, BANK(cloud7_bg), cloud7_bg + +.engineSound1 + DB 4,$00,$df,$a9,$80 ;looping/infinite + +.engineSound2 + DB 4,$00,$d7,$a9,$80 ;fades + +.buttonSound + DB 1,$79,$80,$f1,$00,$87 + +.byte8 + DB 8 + +.delayAnimateWave + push af + call ((.animateWave-L1400_Load2)+levelCheckRAM) + ld a,1 + call Delay + pop af + dec a + jr nz,.delayAnimateWave + ret + +.animateWave + push bc + push de + push hl + PUSHROM + ld a,BANK(appwaves0_dat) + call SetActiveROM + ld a,[levelVars+VAR_SELSTAGE] ;a=stage*8 + frame*2 + rlca + rlca + rlca + ld b,a + ldio a,[vblankTimer] + and %11000 + rrca + rrca + or b + add (((.waveFrameTable-L1400_Load2)+levelCheckRAM) & $ff) + ld l,a + ld a,0 + adc ((((.waveFrameTable-L1400_Load2)+levelCheckRAM)>>8) & $ff) + ld h,a + ld a,[hl+] + ld h,[hl] + ld l,a + ld de,$9420 + ld c,40 + ld a,1 + call VMemCopy + POPROM + pop hl + pop de + pop bc + ret + +.waveFrameTable + DW appwaves0_dat,appwaves0_dat+640,appwaves0_dat+640*2,appwaves0_dat+640*3 + DW appwaves1_dat,appwaves1_dat+640,appwaves1_dat+640*2,appwaves1_dat+640*3 + DW appwaves2_dat,appwaves2_dat+640,appwaves2_dat+640*2,appwaves2_dat+640*3 + DW appwaves3_dat,appwaves3_dat+640,appwaves3_dat+640*2,appwaves3_dat+640*3 + DW appwaves4_dat,appwaves4_dat+640,appwaves4_dat+640*2,appwaves4_dat+640*3 + +L1400_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1400_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1400_Init: + DW ((L1400_InitFinished - L1400_Init2)) ;size +L1400_Init2: + ret + +L1400_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1400_Check: + DW ((L1400_CheckFinished - L1400_Check2)) ;size +L1400_Check2: + ret + +L1400_CheckFinished: +PRINT "1400 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1400_LoadFinished - L1400_Load2) +PRINT " / " +PRINT (L1400_InitFinished - L1400_Init2) +PRINT " / " +PRINT (L1400_CheckFinished - L1400_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1401.asm b/Source/Levels/L1401.asm new file mode 100644 index 0000000..fc61bf9 --- /dev/null +++ b/Source/Levels/L1401.asm @@ -0,0 +1,895 @@ +; L1401.asm Appomattox control panel / destination select +; Generated 02.27.2001 by mlevel +; Modified 02.27.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" +INCLUDE "Source/Items.inc" + +VAR_DESTZONE EQU 0 +VAR_DESTCOLOR EQU 1 +VAR_DESTBG EQU 3 +VAR_DESTBANK EQU 5 + +;this var used in user.asm +VAR_SELSTAGE EQU 6 +VAR_STAGE0 EQU 7 +VAR_STAGE1 EQU 8 +VAR_STAGE2 EQU 9 +VAR_STAGE3 EQU 10 + +VAR_LASTDIR EQU 11 + + +;--------------------------------------------------------------------- +SECTION "Level1401Gfx2",ROMX +;--------------------------------------------------------------------- +nokey_bg:: + INCBIN "Data/Cinema/Appomattox/nokey.bg" + +;--------------------------------------------------------------------- +SECTION "Level1401Gfx",ROMX +;--------------------------------------------------------------------- +lz_zorhaus_bg:: + INCBIN "Data/Cinema/Appomattox/lz_zorhaus.bg" + +lz_palace_bg:: + INCBIN "Data/Cinema/Appomattox/lz_palace.bg" + +lz_croutongate_bg:: + INCBIN "Data/Cinema/Appomattox/lz_croutongate.bg" + +;--------------------------------------------------------------------- +SECTION "Level1401SectionDataControlPanel",ROMX +;--------------------------------------------------------------------- +controlpanel_bg:: + INCBIN "Data/Cinema/Appomattox/controlpanel.bg" + +panelsprites_sp:: + INCBIN "Data/Cinema/Appomattox/panelsprites.sp" + +;--------------------------------------------------------------------- +SECTION "Level1401Waves",ROMX +;--------------------------------------------------------------------- +appwaves0_dat:: + INCBIN "Data/Cinema/Appomattox/appwaves0.dat" + +appwaves1_dat:: + INCBIN "Data/Cinema/Appomattox/appwaves1.dat" + +appwaves2_dat:: + INCBIN "Data/Cinema/Appomattox/appwaves2.dat" + +appwaves3_dat:: + INCBIN "Data/Cinema/Appomattox/appwaves3.dat" + +appwaves4_dat:: + INCBIN "Data/Cinema/Appomattox/appwaves4.dat" + + +;--------------------------------------------------------------------- +SECTION "Level1401Section",ROMX +;--------------------------------------------------------------------- + +L1401_Contents:: + DW L1401_Load + DW L1401_Init + DW L1401_Check + DW L1401_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1401_Load: + DW ((L1401_LoadFinished - L1401_Load2)) ;size +L1401_Load2: + jr .afterDirectionTable + +.directionTable +;lookup table to convert 4-bit input into 0-7 or 8 (no dir) + ; DULR + DB 8 ;%0000 701 + DB 2 ;%0001 682 + DB 6 ;%0010 543 + DB 8 ;%0011 + DB 0 ;%0100 + DB 1 ;%0101 + DB 7 ;%0110 + DB 8 ;%0111 + DB 4 ;%1000 + DB 3 ;%1001 + DB 5 ;%1010 + DB 8 ;%1011 + DB 8 ;%1100 + DB 8 ;%1101 + DB 8 ;%1110 + DB 8 ;%1111 + +.afterDirectionTable + ld bc,ITEM_APPXKEY + call HasInventoryItem + jp z,((.noKey-L1401_Load2)+levelCheckRAM) + + ld a,1 + ld [musicRegisters+0],a + + ld a,BANK(takeoff_gbm) + ld hl,takeoff_gbm + call InitMusic + + ;----set up control panel window------------------------------ + ld a,BANK(controlpanel_bg) + ld hl,controlpanel_bg + call LoadCinemaBG + + ld a,BANK(panelsprites_sp) + ld hl,panelsprites_sp + call LoadCinemaSprite + + ;set last three positional indicators to blank sprite + ld hl,spriteOAMBuffer+8+2 + ld de,4 + ld a,36 + ld c,6 +.clearIndicators + ld [hl],a + add hl,de + dec c + jr nz,.clearIndicators + + ;set sprites 8-19 to be HUD instead of dest symbol + ld hl,spriteOAMBuffer+8*4+2 + ld a,64 + ld b,4 ;palette 4 for HUD + ld c,12 + ld de,3 +.spritesToHUD + ld [hl+],a + ld [hl],b + add hl,de + add 2 + dec c + jr nz,.spritesToHUD + + ;hide all HUD sprites except power bars + ld hl,spriteOAMBuffer+8*4 + ld b,144 ;offset to add to each sprite + ld c,14 + ld de,4 +.hideAllHUD + ld a,[hl] + add b + ld [hl],a + add hl,de + dec c + jr nz,.hideAllHUD + + ;copy panel to top half of map + ld bc,$1409 + ld de,$0000 + ld hl,$0009 + call CinemaBlitRect + ld a,1 + call Delay + + ;panel to dialog window + ld de,((.byte8-L1401_Load2)+levelCheckRAM) + call ShowDialogAtBottomCommon + + ld a,[appomattoxMapIndex] + call ((.getLandingInfo-L1401_Load2)+levelCheckRAM) + call LoadCinemaBG + + ld a,18 + ld [camera_j],a + ld a,9 + ld [mapTop],a + + ;someone already flying? + ld a,[appomattoxMapIndex] + or a + call z,((.backToAppx-L1401_Load2)+levelCheckRAM) + + ld a,15 + call SetupFadeFromStandard + + xor a + ld hl,levelVars+VAR_SELSTAGE + ld [hl+],a + ld [hl+],a ;stage 0 + ld [hl+],a ;stage 1 + ld [hl+],a ;stage 2 + ld [hl+],a ;stage 3 + ld a,8 + ld [hl+],a ;last direction pushed + +.setCoords + ld a,[myJoy] + and %1111 ;directions + add (((.directionTable-L1401_Load2)+levelCheckRAM) & $ff) + ld l,a + ld h,((((.directionTable-L1401_Load2)+levelCheckRAM)>>8)&$ff) + ld a,[hl] + push af + call ((.setHLCurStage-L1401_Load2)+levelCheckRAM) + pop af + ld [hl],a + ld a,[levelVars+VAR_LASTDIR] + cp [hl] + jr z,.afterPlayChangeSound + + ld a,[hl] + ld [levelVars+VAR_LASTDIR],a + ;ld hl,((.changeSound-L1401_Load2)+levelCheckRAM) + ;call PlaySound + +.afterPlayChangeSound + call ((.drawCurSymbol-L1401_Load2)+levelCheckRAM) + + ld a,[myJoy] + bit JOY_A_BIT,a + jr z,.checkUp + + call ((.changeStage-L1401_Load2)+levelCheckRAM) + call ((.drawCurSymbol-L1401_Load2)+levelCheckRAM) + ;ld hl,((.buttonSound-L1401_Load2)+levelCheckRAM) + ;call PlaySound + ld a,1 + call Delay + call ((.waitInputZero-L1401_Load2)+levelCheckRAM) + jr .setCoordsContinue + +.checkUp +IF 0 + bit JOY_UP_BIT,a + jr z,.checkDown + + call ((.previousSymbol-L1401_Load2)+levelCheckRAM) + call ((.drawCurSymbol-L1401_Load2)+levelCheckRAM) + call ((.waitInputZero-L1401_Load2)+levelCheckRAM) + jr .setCoordsContinue + +.checkDown + bit JOY_DOWN_BIT,a + jr z,.setCoordsContinue + + call ((.nextSymbol-L1401_Load2)+levelCheckRAM) + call ((.drawCurSymbol-L1401_Load2)+levelCheckRAM) + call ((.waitInputZero-L1401_Load2)+levelCheckRAM) +ENDC + +.setCoordsContinue + ld a,1 + call Delay + + ld a,[levelVars+VAR_SELSTAGE] + cp $ff + call z,((.backToAppx-L1401_Load2)+levelCheckRAM) + cp 4 + jr nz,.setCoords + + call ((.convertCoordsToMapIndex-L1401_Load2)+levelCheckRAM) + ld [levelVars+VAR_DESTZONE],a + call ((.getLandingInfo-L1401_Load2)+levelCheckRAM) + ld d,h + ld e,l + ld hl,levelVars+VAR_DESTCOLOR + ld [hl],c + inc hl + ld [hl],b + inc hl + ld [hl],e + inc hl + ld [hl],d + inc hl + ld [hl],a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterRemoteAppx + +.removeRemoteAppx + ld a,LCHANGEAPPXMAP + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.removeRemoteAppx ;must repeat + xor a + call TransmitByte +.afterRemoteAppx + + ld hl,$1400 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,2 + ld [timeToChangeLevel],a + ret + +.animateWave + PUSHROM + ld a,BANK(appwaves0_dat) + call SetActiveROM + ld a,[levelVars+VAR_SELSTAGE] ;a=stage*8 + frame*2 + rlca + rlca + rlca + ld b,a + ldio a,[vblankTimer] + and %11000 + rrca + rrca + or b + add (((.waveFrameTable-L1401_Load2)+levelCheckRAM) & $ff) + ld l,a + ld a,0 + adc ((((.waveFrameTable-L1401_Load2)+levelCheckRAM)>>8) & $ff) + ld h,a + ld a,[hl+] + ld h,[hl] + ld l,a + ld de,$9420 + ld c,40 + ld a,1 + call VMemCopy + POPROM + ret + +.waveFrameTable + DW appwaves0_dat,appwaves0_dat+640,appwaves0_dat+640*2,appwaves0_dat+640*3 + DW appwaves1_dat,appwaves1_dat+640,appwaves1_dat+640*2,appwaves1_dat+640*3 + DW appwaves2_dat,appwaves2_dat+640,appwaves2_dat+640*2,appwaves2_dat+640*3 + DW appwaves3_dat,appwaves3_dat+640,appwaves3_dat+640*2,appwaves3_dat+640*3 + DW appwaves4_dat,appwaves4_dat+640,appwaves4_dat+640*2,appwaves4_dat+640*3 + +.convertCoordsToMapIndex + ;de = binary map coords + ld hl,levelVars+VAR_STAGE0 + ld a,[hl+] + swap a + ld d,a + ld a,[hl+] + or d + ld d,a + ld a,[hl+] + swap a + ld e,a + ld a,[hl+] + or e + ld e,a + + ld a,FLIGHTCODEBANK + ld [$ff70],a + ld hl,flightCode + ld c,[hl] ;num flight codes +.findCode + inc hl + ld a,[hl+] + cp e + jr nz,.noMatch + + ld a,[hl] + cp d + jr nz,.noMatch + + ;match! Get map index + inc hl + ld a,[hl] + ret + +.noMatch + inc hl + dec c + jr nz,.findCode + + ;go to default map + ld a,$71 + ret + +.waitInputZero + ld a,JOY_A ;|JOY_UP|JOY_DOWN + ld hl,myJoy + jp WaitInputZero + +.setHLCurStage + ld h,(((levelVars+VAR_STAGE0)>>8) & $ff) + ld a,[levelVars+VAR_SELSTAGE] + ld b,a + add ((levelVars+VAR_STAGE0) & $ff) + ld l,a + ld a,[hl] + ret + + +.drawCurSymbol + call ((.animateWave-L1401_Load2)+levelCheckRAM) + ;set power bar level + ld a,[levelVars+VAR_SELSTAGE] + inc a + ld [musicRegisters+0],a + dec a + push af + rlca ;sprite = stage*4 + 44 + rlca + add 44 + ld hl,spriteOAMBuffer+22*4+2 + ld [hl+],a + inc hl + inc hl + inc hl + add 2 + ld [hl],a + pop af + + ;turn on HUD sprites based on stage + push af + or a + jr nz,.checkHUD1 + + ;HUD 0 + call ((.diagramOff-L1401_Load2)+levelCheckRAM) + jr .afterCheckHUD + +.checkHUD1 + cp 1 + jr nz,.checkHUD2 + + call ((.diagramOn-L1401_Load2)+levelCheckRAM) + call ((.recticleOff-L1401_Load2)+levelCheckRAM) + jr .afterCheckHUD + +.checkHUD2 + cp 2 + jr nz,.checkHUD3 + + call ((.recticleOn-L1401_Load2)+levelCheckRAM) + call ((.horizonOff-L1401_Load2)+levelCheckRAM) + jr .afterCheckHUD + +.checkHUD3 + cp 3 + jr nz,.HUD4 + + call ((.horizonOn-L1401_Load2)+levelCheckRAM) + jr .afterCheckHUD + +.HUD4 + +.afterCheckHUD + pop af + cp 4 + ret z ;done + + call ((.setHLCurStage-L1401_Load2)+levelCheckRAM) + cp 8 + jr nz,.drawYellow + + ;draw blue + ld d,1 + jr .afterSetPalette + +.drawYellow + ld d,0 + +.afterSetPalette + ;alter palette based on time + push af + ldio a,[vblankTimer] + and %1000 + rrca + rrca + or d + ld d,a + pop af + rlca ;selection times four is sprite pattern index + rlca + ld c,a + ld a,b + rlca ;stage*8+2 is sprite index + rlca + rlca + add 2 + add (spriteOAMBuffer&$ff) + ld l,a + ld h,((spriteOAMBuffer>>8) & $ff) + ld [hl],c ;tile pattern + inc hl + ld [hl],d ;palette + inc hl + inc hl + inc hl + inc c + inc c + ld [hl],c + inc hl + ld [hl],d + ret + +.diagramOn + ld hl,spriteOAMBuffer+20*4 + ld [hl],16 + ld hl,spriteOAMBuffer+21*4 + ld [hl],16 + ret + +.diagramOff + ld hl,spriteOAMBuffer+20*4 + ld [hl],160 + ld hl,spriteOAMBuffer+21*4 + ld [hl],160 + ret + +.recticleOn + ld b,2 + ld de,4 + ld a,32 + ld hl,spriteOAMBuffer+8*4 +.recticleOnLoopOuter + ld c,4 +.recticleOnLoopInner + ld [hl],a + add hl,de + dec c + jr nz,.recticleOnLoopInner + add 16 + dec b + jr nz,.recticleOnLoopOuter + ret + +.recticleOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+8*4 + ld c,8 +.recticleOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.recticleOffLoop + ret + +.horizonOn + ld de,4 + ld a,40 + ld hl,spriteOAMBuffer+16*4 + ld c,4 +.horizonOnLoop + ld [hl],a + add hl,de + dec c + jr nz,.horizonOnLoop + ret + +.horizonOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+16*4 + ld c,4 +.horizonOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.horizonOffLoop + ret + + +;----changeStage------------------------------------------------------ +.changeStage + call ((.setHLCurStage-L1401_Load2)+levelCheckRAM) + cp 8 ;back arrow? + jr z,.backArrow + + ;forward + inc b + ld a,b + ld [levelVars+VAR_SELSTAGE],a + cp 4 + ret z ;all done! + + ;set this sprite to palette 0 and reset sprite for next level + ld a,[hl] + inc hl + ld [hl],a + ld a,b + rlca ;times eight + rlca + rlca + sub 5 + add (spriteOAMBuffer&$ff) + ld l,a + ld h,((spriteOAMBuffer>>8)&$ff) + ld de,4 + ld [hl],0 + add hl,de + ld [hl],0 + add hl,de + dec hl + ld [hl],0 + add hl,de + ld [hl],2 + + ret + +.backArrow + dec b + ld a,b + cp $ff + jr nz,.notPos0 + +.backToAppx + ;return to appomattox + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_N + ld [hl],a + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ld a,15 + call SetupFadeToStandard + call WaitFade + call ClearDialog + ld a,1 + call Delay + pop hl ;pop return address, return from Load2 + ret + +.notPos0 + dec hl ;set stage[n-1] to be back arrow too + ld [hl],8 + ld [levelVars+VAR_SELSTAGE],a + + ;reset this sprite to blank before going back + inc a + rlca ;times eight + rlca + rlca + add 2 + add (spriteOAMBuffer&$ff) + ld l,a + ld h,((spriteOAMBuffer>>8)&$ff) + ld [hl],36 + ld de,4 + add hl,de + ld [hl],36 + + ;decrement rolloever sprite (8 & 9) xpos + ;ld hl,spriteOAMBuffer+8*4+1 + ;ld b,24 + ;ld a,[hl] + ;sub b + ;ld [hl],a + ;ld hl,spriteOAMBuffer+9*4+1 + ;ld a,[hl] + ;sub b + ;ld [hl],a + + ret + +;----getLandingInfo--------------------------------------------------- +.getLandingInfo +.checkGate + cp $71 + jr nz,.checkCroutonGate + + ld a,LEVELSTATEBANK + ldio [$ff70],a + ld a,[levelState+$71] + cp 6 + jr nz,.gate + + ;broken wall (blasted) + ld a,BANK(lz_brokenwall_bg) + ld hl,lz_brokenwall_bg + jp ((.defaultSkyColor-L1401_Load2)+levelCheckRAM) + +.gate + ld a,BANK(lz_gate_bg) + ld hl,lz_gate_bg + jp ((.defaultSkyColor-L1401_Load2)+levelCheckRAM) + +.checkCroutonGate + cp $0a + jr nz,.checkZorhaus + + ld a,BANK(lz_croutongate_bg) + ld hl,lz_croutongate_bg + ld bc,0 ;sky color + ret + +.checkZorhaus + cp $3d + jr nz,.checkPalace + + ld a,BANK(lz_zorhaus_bg) + ld hl,lz_zorhaus_bg + ld bc,$33f ;sky color + ret + +.checkPalace + cp $55 + jr nz,.checkTrees1 + + ld a,BANK(lz_palace_bg) + ld hl,lz_palace_bg + ld bc,$7eee ;sky color + ret + +.checkTrees1 + cp $81 + jr nz,.checkMist + ld a,BANK(lz_trees1_bg) + ld hl,lz_trees1_bg + jp ((.defaultSkyColor-L1401_Load2)+levelCheckRAM) + +.checkMist + cp $23 + jr nz,.checkIce1 + ld a,BANK(lz_mist_bg) + ld hl,lz_mist_bg + ld bc,$592e + ret + +.checkIce1 + cp $06 + jr nz,.checkCanyon + + ld a,BANK(lz_ice1_bg) + ld hl,lz_ice1_bg + ld bc,$7eed + ret + +.checkCanyon + cp $47 + jr nz,.checkDesert + + ld a,BANK(lz_canyon_bg) + ld hl,lz_canyon_bg + ld bc,$2fff + ret + +.checkDesert + cp $a3 + jr nz,.checkGraves + + ld a,BANK(lz_desert_bg) + ld hl,lz_desert_bg + ld bc,$2fff + ret + +.checkGraves + cp $a8 + jr nz,.checkIceCubes + + ld a,BANK(lz_graves_bg) + ld hl,lz_graves_bg + ld bc,0 + ret + +.checkIceCubes + cp $29 + jr nz,.checkJungle + + ld a,BANK(lz_icecubes_bg) + ld hl,lz_icecubes_bg + ld bc,$7e2b + ret + +.checkJungle + cp $59 + jr nz,.checkMountains + + ld a,BANK(lz_jungle_bg) + ld hl,lz_jungle_bg + ld bc,$a0 + ret + +.checkMountains + cp $66 + jr nz,.checkOcean + + ld a,BANK(lz_mountains_bg) + ld hl,lz_mountains_bg + ld bc,$487f + ret + +.checkOcean + cp $3a + jr nz,.checkTreePath + + ld a,BANK(lz_ocean_bg) + ld hl,lz_ocean_bg + ld bc,$121f + ret + +.checkTreePath + ;cp $c7 + ld a,BANK(lz_treepath_bg) + ld hl,lz_treepath_bg + +.defaultSkyColor + ld bc,$7e20 + ret + +.changeSound + DB 1,$31,$80,$c1,$00,$83 + +.buttonSound + DB 1,$79,$80,$f1,$00,$87 + +.byte8 + DB 8 + +.noKey + ld a,BANK(nokey_bg) + ld hl,nokey_bg + call LoadCinemaBG + + ld a,15 + call SetupFadeFromStandard + call WaitFade + + ld de,((.returnToShip-L1401_Load2)+levelCheckRAM) + call SetDialogForward + call SetDialogSkip + + ld a,150 + call Delay + +.returnToShip + call ClearDialogSkipForward + + ld a,15 + call SetupFadeToStandard + call WaitFade + + ld a,EXIT_N + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$1300 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +L1401_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1401_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1401_Init: + DW ((L1401_InitFinished - L1401_Init2)) ;size +L1401_Init2: + ret + +L1401_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1401_Check: + DW ((L1401_CheckFinished - L1401_Check2)) ;size +L1401_Check2: + ret + +L1401_CheckFinished: +PRINT "1401 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1401_LoadFinished - L1401_Load2) +PRINT " / " +PRINT (L1401_InitFinished - L1401_Init2) +PRINT " / " +PRINT (L1401_CheckFinished - L1401_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1402.asm b/Source/Levels/L1402.asm new file mode 100644 index 0000000..d1d42f6 --- /dev/null +++ b/Source/Levels/L1402.asm @@ -0,0 +1,595 @@ +; L1402.asm lady flower intervenes +; Generated 08.13.2000 by mlevel +; Modified 08.13.2000 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1402SectionData2",ROMX +;--------------------------------------------------------------------- +spacepan_bg: + INCBIN "Data/Cinema/Distress/spacepan.bg" + +final_bg: + INCBIN "Data/Cinema/Distress/final.bg" + +;--------------------------------------------------------------------- +SECTION "Level1402Section",ROMX +;--------------------------------------------------------------------- + +L1402_Contents:: + DW L1402_Load + DW L1402_Init + DW L1402_Check + DW L1402_Map + +moon_mini_bg: + INCBIN "Data/Cinema/Distress/moon_mini.bg" + +palace_bg: + INCBIN "Data/Cinema/Distress/palace.bg" + +flowernight_bg: + INCBIN "Data/Cinema/Distress/flowernight.bg" + +fgstars_sp: + INCBIN "Data/Cinema/Distress/fgstars.sp" + +yacht_mini_sp: + INCBIN "Data/Cinema/Distress/yacht_mini.sp" + +bee_sp: + INCBIN "Data/Cinema/Distress/bee.sp" + +dialog: +lady_badNews_gtx: + INCBIN "Data/Dialog/Distress/lady_badNews.gtx" + +lady_dispatched_gtx: + INCBIN "Data/Dialog/Distress/lady_dispatched.gtx" + +lady_surrender_gtx: + INCBIN "Data/Dialog/Distress/lady_surrender.gtx" + +lady_bigBullies_gtx: + INCBIN "Data/Dialog/Distress/lady_bigBullies.gtx" + +lady_poorCaptain_gtx: + INCBIN "Data/Dialog/Distress/lady_poorCaptain.gtx" + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +VAR_BEEPOS EQU 0 + +L1402_Load: + DW ((L1402_LoadFinished - L1402_Load2)) ;size +L1402_Load2: + ld hl,$1402 + call SetJoinMap + + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(moon_bg) + ld hl,moon_bg + call LoadCinemaBG + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ;center moon in stars + ;right top stars to bottom + ld bc,$1406 + ld hl,$1406 + ld de,$140c + call CinemaBlitRect + ld a,1 + call Delay + + ;left moon centered in right + ld bc,$140c + ld hl,$0000 + ld de,$1403 + call CinemaBlitRect + ld a,1 + call Delay + + ;right to left + ld bc,$1412 + ld hl,$1400 + ld de,$0000 + call CinemaBlitRect + ld a,1 + call Delay + + ld a,48 + call SetupFadeFromStandard + call WaitFade + + ld de,((.endCinema-L1402_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.showMoonMini-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,32 + call Delay + +.showMoonMini + call ((.fadeToBlack32-L1402_Load2)+levelCheckRAM) + + ld a,BANK(moon_mini_bg) + ld hl,moon_mini_bg + call LoadCinemaBG + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.showSpacePan-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,32 + call Delay + +.showSpacePan + call ((.fadeToBlack32-L1402_Load2)+levelCheckRAM) + + ld a,BANK(spacepan_bg) + ld hl,spacepan_bg + call LoadCinemaBG + + ld a,BANK(fgstars_sp) + ld hl,fgstars_sp + call LoadCinemaSprite + + ld a,1 + call Delay + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.showKiwi-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,32 + call Delay + + ld a,$44 + ld [scrollSpeed],a + + ld a,117 + ld [camera_i],a + + ld c,4 +.stars1 + ld a,1 + call Delay + ld d,2 + call ScrollSpritesLeft + dec c + jr nz,.stars1 + + + ld a,$82 + ld [scrollSpeed],a + + ld c,150 +.stars2 + ld a,1 + call Delay + ld a,[mapLeft] + cp 108 + jr nc,.afterStarScroll + ld d,4 + call ScrollSpritesLeft +.afterStarScroll + dec c + jr nz,.stars2 + +.showKiwi + call ((.fadeToBlack32-L1402_Load2)+levelCheckRAM) + call ResetSprites + + ld a,BANK(kiwi1_bg) + ld hl,kiwi1_bg + call LoadCinemaBG + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.showPalace1-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,32 + call Delay + +.showPalace1 + call ((.fadeToBlack32-L1402_Load2)+levelCheckRAM) + + ld a,BANK(palace_bg) + ld hl,palace_bg + call LoadCinemaBG + + ld a,BANK(yacht_mini_sp) + ld hl,yacht_mini_sp + call LoadCinemaSprite + ;set bg priority + ld hl,spriteOAMBuffer+3 + set 7,[hl] + ld hl,spriteOAMBuffer+7 + set 7,[hl] + + ld a,28 + ld [camera_j],a + ld a,18 + ld [mapTop],a + + ld a,1 + call Delay + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.showLadyFlower-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,32 + call Delay + +.showLadyFlower + call ((.fadeToBlack32-L1402_Load2)+levelCheckRAM) + call ResetSprites + + ld a,BANK(lady_flower_gbm) + ld hl,lady_flower_gbm + call InitMusic + + xor a + ld [levelVars + VAR_BEEPOS],a + + ld a,BANK(flowernight_bg) + ld hl,flowernight_bg + call LoadCinemaBG + + ld a,BANK(bee_sp) + ld hl,bee_sp + call LoadCinemaSprite + + ;clear the sprites of bee's other two frames + ld hl,spriteOAMBuffer+8 + xor a + ld [hl+],a ;ypos to zero + inc hl + inc hl + inc hl + ld [hl+],a ;ypos to zero + + ld d,16 + call ScrollSpritesRight + ld d,16 + call ScrollSpritesDown + + ld a,1 + call Delay + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.dialog1-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,1 ;get her to open her eyes + LONGCALLNOARGS AnimateLadyFlower + +.dialog1 + ld c,0 + DIALOGBOTTOM lady_badNews_gtx + ld de,((.dialog2-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld d,2 + LONGCALLNOARGS AnimateLadyFlower + +.dialog2 + ld c,0 + DIALOGBOTTOM lady_dispatched_gtx + ld de,((.dialog3-L1402_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateLadyFlower + +.dialog3 + ld c,0 + DIALOGBOTTOM lady_surrender_gtx + ld de,((.dialog4-L1402_Load2)+levelCheckRAM) + call SetDialogForward + ld d,6 + LONGCALLNOARGS AnimateLadyFlower + +.dialog4 + ld c,0 + DIALOGBOTTOM lady_bigBullies_gtx + ld de,((.dialog5-L1402_Load2)+levelCheckRAM) + call SetDialogForward + ld d,4 + LONGCALLNOARGS AnimateLadyFlower + +.dialog5 + ld c,0 + DIALOGBOTTOM lady_poorCaptain_gtx + ld de,((.showPalace2-L1402_Load2)+levelCheckRAM) + call SetDialogForward + ld d,6 + LONGCALLNOARGS AnimateLadyFlower + +.showPalace2 + call ClearDialog + ld a,32 + call SetupFadeToBlack +.waitFadeBee + call ((.animateBee-L1402_Load2)+levelCheckRAM) + ld a,1 + call Delay + ld a,[specialFX] + and FX_FADE + jr nz,.waitFadeBee + + call ResetSprites + ld a,BANK(palace_bg) + ld hl,palace_bg + call LoadCinemaBG + + ld a,BANK(yacht_mini_sp) + ld hl,yacht_mini_sp + call LoadCinemaSprite + + ld a,28 + ld [camera_j],a + ld a,18 + ld [mapTop],a + ld a,1 + call Delay + + ;set bg priority + ld hl,spriteOAMBuffer+3 + set 7,[hl] + ld hl,spriteOAMBuffer+7 + set 7,[hl] + + ;sprites don't scroll with the bg + xor a + ld [scrollSprites],a + ld a,$11 + ld [scrollSpeed],a ;bg scroll speed + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.endCinema-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ;----take off------------------------------------------------- + ;setup a fade + ld hl,gamePalette + ld de,fadeCurPalette + call CopyPalette32 + ld de,fadeFinalPalette + call CopyPalette32 + + ;set the final palette's first 6 BG colors to dark purple + ld c,6 + ld de,6 + ld hl,fadeFinalPalette +.setPurpleLoop + ld [hl],$04 + inc hl + ld [hl],$10 + inc hl + add hl,de + dec c + jr nz,.setPurpleLoop + ld a,14*8 + call FadeInit + + ;set the camera to pan up + xor a + ld [camera_j],a + + ld c,14*8 +.takeoffLoop + push bc + ld a,1 + call Delay + + ;scroll the ship sprites up 1 pixel + ;ld hl,spriteOAMBuffer + ;dec [hl] + ;ld hl,spriteOAMBuffer+4 + ;dec [hl] + + call ((.scrollMoons-L1402_Load2)+levelCheckRAM) + + pop bc + dec c + jr nz,.takeoffLoop + + ;accellerate offscreen + ld hl,fadeFinalPalette + ld de,fadeCurPalette + call CopyPalette32 + ld hl,fadeFinalPalette + call FadeCommonSetPaletteToBlack + ld hl,fadeFinalPalette + ld de,gamePalette + call CopyPalette32 + ld a,14*8 + call FadeInit + + ld c,14*8 +.accelerateLoop + push bc + ld a,1 + call Delay + + ;scroll the ship sprites up 1 pixel + ld hl,spriteOAMBuffer + dec [hl] + ld hl,spriteOAMBuffer+4 + dec [hl] + + call ((.scrollMoons-L1402_Load2)+levelCheckRAM) + call ((.scrollMoons-L1402_Load2)+levelCheckRAM) + + pop bc + dec c + jr nz,.accelerateLoop + +.endCinema + call ClearDialog + ld a,16 + call SetupFadeToBlack + call WaitFade + call ResetSprites + +IF 0 + ld a,BANK(final_bg) + ld hl,final_bg + call LoadCinemaBG + + call ((.fadeFromBlack32-L1402_Load2)+levelCheckRAM) + + ld de,((.backToMenu-L1402_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.backToMenu-L1402_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,150 + call Delay + +.backToMenu +;.infi + ;ld a,1 + ;call Delay ;upkeep so remote game won't freak +;jr .infi +ENDC + ;ld de,0 + ;call SetDialogSkip + ;call SetDialogForward + + ;ld a,16 + ;call SetupFadeToStandard + ;call WaitFade + + ;ld hl,fadeFinalPalette + ;ld de,gamePalette + ;call CopyPalette64 + ;ld de,fadeCurPalette + ;call CopyPalette64 + + ld hl,$1502 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,2 + ld [timeToChangeLevel],a + + ret + +;----support routines------------------------------------------------- +.fadeToBlack32 + ld a,32 + call SetupFadeToBlack + call WaitFade + ret + +.fadeFromBlack32 + ld a,32 + call SetupFadeFromBlack + call WaitFade + ret + +.animateBee + ;bee y position + ld a,[levelVars + VAR_BEEPOS] + add 2 + ld [levelVars + VAR_BEEPOS],a + cp 128 + jr c,.beeDirectionChosen + ld b,a ;a = 255 - a + ld a,255 + sub b +.beeDirectionChosen + sub 64 + rlca ;get sign bit in bit 7 + sra a + sra a + sra a + sra a + + ;adjust y coord + ld hl,spriteOAMBuffer + add 40 + ld [hl],a + ld hl,spriteOAMBuffer+4 + ld [hl],a + + ;adjust animation frame + ldio a,[updateTimer] + rlca + rlca + and %100 + ld hl,spriteOAMBuffer + 2 + ld [hl],a + inc a + inc a + ld hl,spriteOAMBuffer + 6 + ld [hl],a + + ret + +.scrollMoons + ;scroll the 13 moon sprites down 1 pixel every other time + ld a,[updateTimer] + and 1 + ret z + ld c,13 + ld hl,spriteOAMBuffer+8 +.scrollMoonsLoop + inc [hl] + ld a,l + add 4 + ld l,a + dec c + jr nz,.scrollMoonsLoop + ret + +L1402_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1402_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1402_Init: + DW ((L1402_InitFinished - L1402_Init2)) ;size +L1402_Init2: + ret + +L1402_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1402_Check: + DW ((L1402_CheckFinished - L1402_Check2)) ;size +L1402_Check2: + ret + +L1402_CheckFinished: +PRINT "1402 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1402_LoadFinished - L1402_Load2) +PRINT " / " +PRINT (L1402_InitFinished - L1402_Init2) +PRINT " / " +PRINT (L1402_CheckFinished - L1402_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1403.asm b/Source/Levels/L1403.asm new file mode 100644 index 0000000..4650e2a --- /dev/null +++ b/Source/Levels/L1403.asm @@ -0,0 +1,604 @@ +; L1403.asm approaching kiwi +; Generated 03.08.2001 by mlevel +; Modified 03.08.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_DESTZONE EQU 0 +VAR_DESTCOLOR EQU 1 +VAR_DESTBG EQU 3 +VAR_DESTBANK EQU 5 + +;this var used in user.asm +VAR_SELSTAGE EQU 6 +VAR_EXHAUST_FRAME EQU 7 + + + + + +;--------------------------------------------------------------------- +SECTION "Level1403Section",ROMX +;--------------------------------------------------------------------- + +L1403_Contents:: + DW L1403_Load + DW L1403_Init + DW L1403_Check + DW L1403_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1403_Load: + DW ((L1403_LoadFinished - L1403_Load2)) ;size +L1403_Load2: + ld a,1 + ld [displayType],a + xor a + ld [scrollSprites],a + xor a + ld [levelVars+VAR_EXHAUST_FRAME],a + ld a,4 + ld [levelVars+VAR_SELSTAGE],a + + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + +;----"Thank you"------------------------------------------------------ +.thankYou + call ((.loadLadyFlowerOnScreen-L1403_Load2)+levelCheckRAM) + + ld de,((.seeYou-L1403_Load2)+levelCheckRAM) + call SetDialogForward + ld de,((.endCinema-L1403_Load2)+levelCheckRAM) + call SetDialogSkip + + ld c,0 + DIALOGBOTTOM lady_saved_gtx + + ld d,3 + LONGCALLNOARGS AnimateLadyFlowerDistress + +;----"See you"-------------------------------------------------------- +.seeYou + call ((.loadFlour-L1403_Load2)+levelCheckRAM) + + ld de,((.wait-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_seeyou_gtx + + call ((.animateFlourDriving3-L1403_Load2)+levelCheckRAM) + +;----"Wait..."-------------------------------------------------------- +.wait + call ((.loadLadyFlowerOnScreen-L1403_Load2)+levelCheckRAM) + + ld de,((.holdOut-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM lady_wait_gtx + + ld d,3 + LONGCALLNOARGS AnimateLadyFlowerDistress + +;----"Do you think you can hold out for a few days?"------------------ +.holdOut + call ((.loadFlour-L1403_Load2)+levelCheckRAM) + + ld de,((.whatNo-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_holdout_gtx + + call ((.animateFlourDriving4-L1403_Load2)+levelCheckRAM) + + +;----"What?! No!"----------------------------------------------------- +.whatNo + call ((.loadLadyFlowerOnScreen-L1403_Load2)+levelCheckRAM) + + ld de,((.sendShuttle-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM lady_no_gtx + + ld d,3 + LONGCALLNOARGS AnimateLadyFlowerDistress + +;----"BS, send over the shuttle"-------------------------------------- +.sendShuttle + call ((.loadFlour-L1403_Load2)+levelCheckRAM) + + ld de,((.toKiwi-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_shuttle_gtx + + call ((.animateFlourDriving4-L1403_Load2)+levelCheckRAM) + + ld a,60 + call SetupFadeToBlack + call WaitFade + +.toKiwi + call ((.quickToBlack-L1403_Load2)+levelCheckRAM) + ld de,((.approachKiwi-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,BANK(appomattox_tokiwi_bg) + ld hl,appomattox_tokiwi_bg + call ((.appxSideView-L1403_Load2)+levelCheckRAM) + ld a,16 + call SetupFadeToBlack + ld c,20 + call ((.appxScrollStarsWaitFade-L1403_Load2)+levelCheckRAM) + +;----Approach Kiwi---------------------------------------------------- +.approachKiwi + call ((.quickToBlack-L1403_Load2)+levelCheckRAM) + ld a,BANK(kiwi1_bg) + ld hl,kiwi1_bg + call LoadCinemaBG + + ld a,BANK(starfield_sprite_sp) + ld hl,starfield_sprite_sp + call LoadCinemaSprite + ld a,1 + call Delay + + ld de,((.controlPanel-L1403_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,16 + call SetupFadeFromBlack + call WaitFade + + ld b,30 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + + ld a,16 + call SetupFadeToBlackBGOnly + ld b,16 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + + ;kiwi 2 + ld a,BANK(kiwi2_bg) + ld hl,kiwi2_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromBlackBGOnly + ld c,16 + call ((.animate_ship-L1403_Load2)+levelCheckRAM) + + ld b,30 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + + ld a,16 + call SetupFadeToBlackBGOnly + ld b,16 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + + ;kiwi 3 + ld a,BANK(kiwi3_bg) + ld hl,kiwi3_bg + call LoadCinemaBG + + ld a,16 + call SetupFadeFromBlackBGOnly + + ld b,30 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + + ld a,16 + call ((.setupFadeFromSky-L1403_Load2)+levelCheckRAM) + ld b,16 + call (.animate_ship + (levelCheckRAM-L1403_Load2)) + +.endCinema +.controlPanel + ld a,2 + call ((.setupFadeFromSky-L1403_Load2)+levelCheckRAM) + call WaitFade + + call ResetSprites + + ;----set up control panel window------------------------------ + ld a,BANK(controlpanel_bg) + ld hl,controlpanel_bg + call LoadCinemaBG + + ld a,BANK(panelsprites_sp) + ld hl,panelsprites_sp + call LoadCinemaSprite + + ;set coords to be star flower wrench crouton + ld hl,spriteOAMBuffer+2 + ld de,4 + ld [hl],0 + add hl,de + ld [hl],2 + add hl,de + ld [hl],8 + add hl,de + ld [hl],10 + add hl,de + ld [hl],24 + add hl,de + ld [hl],26 + add hl,de + ld [hl],12 + add hl,de + ld [hl],14 + +IF 0 + ;set four positional indicators to blank sprite + ld hl,spriteOAMBuffer+2 + ld de,4 + ld a,36 + ld c,8 +.clearIndicators + ld [hl],a + add hl,de + dec c + jr nz,.clearIndicators +ENDC + + ;set sprites 8-19 to be HUD instead of dest symbol + ld hl,spriteOAMBuffer+8*4+2 + ld a,64 + ld b,4 ;palette 4 for HUD + ld c,12 + ld de,3 +.spritesToHUD + ld [hl+],a + ld [hl],b + add hl,de + add 2 + dec c + jr nz,.spritesToHUD + +IF 0 + ;hide all HUD sprites except power bars + ld hl,spriteOAMBuffer+8*4 + ld b,144 ;offset to add to each sprite + ld c,14 + ld de,4 +.hideAllHUD + ld a,[hl] + add b + ld [hl],a + add hl,de + dec c + jr nz,.hideAllHUD +ENDC + + ;copy panel to top half of map + ld bc,$1409 + ld de,$0000 + ld hl,$0009 + call CinemaBlitRect + ld a,1 + call Delay + + ;panel to dialog window + ld de,((.byte8-L1403_Load2)+levelCheckRAM) + call ShowDialogAtBottomCommon + ld a,1 + call Delay + + ld a,BANK(lz_gate_bg) + ld hl,lz_gate_bg + call LoadCinemaBG + + ;set up DEST info + ld hl,levelVars+VAR_DESTZONE + ld a,$71 + ld [hl+],a + ld a,$20 + ld [hl+],a + ld a,$7e + ld [hl+],a + ld a,(lz_gate_bg & $ff) + ld [hl+],a + ld a,((lz_gate_bg>>8) & $ff) + ld [hl+],a + ld a,BANK(lz_gate_bg) + ld [hl+],a + ld a,4 + ld [hl+],a + +.setPowerBar + ld hl,spriteOAMBuffer+22*4+2 + ld a,60 + ld de,4 + ld [hl],a + add hl,de + add 2 + ld [hl],a + + ;set horizon bar vertical + ld hl,spriteOAMBuffer+16*4 + ld a,$3a + ld [hl],a + add hl,de + ld [hl],a + add hl,de + ld [hl],a + add hl,de + ld [hl],a + + ld hl,$1503 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,2 + ld [timeToChangeLevel],a + + ret + +;--------------------------------------------------------------------- +;Support Routines +;--------------------------------------------------------------------- +.appxSideView + call LoadCinemaBG + + ld a,BANK(appomattox_big_sprites_sp) + ld hl,appomattox_big_sprites_sp + call LoadCinemaSprite + + ;change 1st 32 sprites to be BG priority + ld c,32 + ld hl,spriteOAMBuffer+8*4+3 + ld de,4 +.spritePriorityLoop + set 7,[hl] + add hl,de + dec c + jr nz,.spritePriorityLoop + + ld a,90 + call SetupFadeFromBlack + + ld c,160 +.appxScrollStarsWaitFade +.waitFade + ld a,1 + call Delay + call ((.scrollStars-L1403_Load2)+levelCheckRAM) + dec c + jr nz,.waitFade + + ret + +.quickToBlack + call BlackoutPalette + call ClearDialog + jp ResetSprites + +.quickFromBlack + ld a,1 + jp SetupFadeFromBlack + +.loadFlour + call ((.quickToBlack-L1403_Load2)+levelCheckRAM) + + ld a,BANK(flourdriving_bg) + ld hl,flourdriving_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1403_Load2)+levelCheckRAM) + ret + +.animateFlourDriving3 + ld d,3 + jr .animateFlourDrivingN + +.animateFlourDriving4 + ld d,4 +.animateFlourDrivingN + LONGCALLNOARGS AnimateFlourDriving + +.scrollStars + push bc + push de + push hl + + ;of 32 stars, scroll odd ones by one pixel and evens + ;by two + ld c,16 + ld de,4 + ld hl,spriteOAMBuffer+8*4+1 +.scrollStarsLoop + dec [hl] + add hl,de + dec [hl] + dec [hl] + add hl,de + dec c + jr nz,.scrollStarsLoop + + ;ping-pong exhaust + ld hl,levelVars+VAR_EXHAUST_FRAME + ld a,[updateTimer] + bit 0,a + jr nz,.gotCurFrame + + ;increment frame + ld a,[hl] + add 16 + cp 160 + jr nz,.wrapFrame + xor a +.wrapFrame + ld [hl],a + +.gotCurFrame + ld a,[hl] + ;sprite = curframe + 80 + cp 96 + jr c,.frameOkay + cpl + add 161 +.frameOkay + add 80 + ld hl,spriteOAMBuffer+2 + ld de,4 + ld c,8 +.setThrust + ld [hl],a + add 2 + add hl,de + dec c + jr nz,.setThrust + + pop hl + pop de + pop bc + ret + +.loadLadyFlowerOnScreen + call ((.loadLadyFlowerInDistress-L1403_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1403_Load2)+levelCheckRAM) + jp ((.ladyFaceToViewscreen-L1403_Load2)+levelCheckRAM) + +.loadLadyFlowerInDistress + call ((.quickToBlack-L1403_Load2)+levelCheckRAM) + + ld a,BANK(flowerviewscreen_bg) + ld hl,flowerviewscreen_bg + call LoadCinemaBG + ret + +.ladyFaceToViewscreen + ;put lady flower's face on + ld bc,$1009 + ld de,$0201 + ld hl,$1a12 + call CinemaBlitRect + ret + +.animate_ship + push bc +.animate_loop + push bc + ld a,1 + call Delay + pop bc + + ld a,b + and %10 ;thrust on or off? + + jr nz,.animate_thruston + call (.routine_thrustoff + (levelCheckRAM-L1403_Load2)) + jr .animate_check_done + +.animate_thruston + call (.routine_thruston + (levelCheckRAM-L1403_Load2)) + +.animate_check_done + dec b + jr nz,.animate_loop + + pop bc + + ret + +.routine_thrustoff + ;turn thrust off by setting sprites 0-5 to pattern 50 + ld hl,spriteOAMBuffer+2 + ld de,4 + ld a,50 + ld c,6 +.thrustOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.thrustOffLoop + ret + +.routine_thruston + ;turn thrust on by setting sprites 0-5 to patterns 0,2,4,6,8,10 + ld hl,spriteOAMBuffer+2 + ld de,4 + xor a + ld c,6 +.thrustOnLoop + ld [hl],a + inc a + inc a + add hl,de + dec c + jr nz,.thrustOnLoop + ret + +.setupFadeFromSky + push af + + ld a,FADEBANK + ld [$ff70],a + + ;ld hl,gamePalette + ;ld de,fadeCurPalette + ;call FadeCommonCopyPalette + + ;set all colors to be $7d80 + ld hl,fadeFinalPalette + ld c,64 +.setAll7d80 + ld [hl],$80 + inc hl + ld [hl],$7d + inc hl + dec c + jr nz,.setAll7d80 + + pop af + call FadeInit + ret + +.byte8 + DB 8 + +L1403_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1403_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1403_Init: + DW ((L1403_InitFinished - L1403_Init2)) ;size +L1403_Init2: + ret + +L1403_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1403_Check: + DW ((L1403_CheckFinished - L1403_Check2)) ;size +L1403_Check2: + ret + +L1403_CheckFinished: +PRINT "1403 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1403_LoadFinished - L1403_Load2) +PRINT " / " +PRINT (L1403_InitFinished - L1403_Init2) +PRINT " / " +PRINT (L1403_CheckFinished - L1403_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1412.asm b/Source/Levels/L1412.asm new file mode 100644 index 0000000..726f1c6 --- /dev/null +++ b/Source/Levels/L1412.asm @@ -0,0 +1,59 @@ +; L1412.asm Crouton Homeworld 3 +; Generated 04.19.2001 by mlevel +; Modified 04.19.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +;--------------------------------------------------------------------- +SECTION "Level1412Section",ROMX +;--------------------------------------------------------------------- + +L1412_Contents:: + DW L1412_Load + DW L1412_Init + DW L1412_Check + DW L1412_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1412_Load: + DW ((L1412_LoadFinished - L1412_Load2)) ;size +L1412_Load2: + call ParseMap + ret + +L1412_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1412_Map: +INCBIN "Data/Levels/L1412_crouton_hw3.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1412_Init: + DW ((L1412_InitFinished - L1412_Init2)) ;size +L1412_Init2: + ret + +L1412_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1412_Check: + DW ((L1412_CheckFinished - L1412_Check2)) ;size +L1412_Check2: + ret + +L1412_CheckFinished: +PRINT "1412 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1412_LoadFinished - L1412_Load2) +PRINT " / " +PRINT (L1412_InitFinished - L1412_Init2) +PRINT " / " +PRINT (L1412_CheckFinished - L1412_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1500.asm b/Source/Levels/L1500.asm new file mode 100644 index 0000000..f38aa54 --- /dev/null +++ b/Source/Levels/L1500.asm @@ -0,0 +1,139 @@ +; L1500.asm +; Generated 03.22.2001 by mlevel +; Modified 03.22.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;--------------------------------------------------------------------- +SECTION "Level1500Section",ROMX +;--------------------------------------------------------------------- + +deathscreen_bg: + INCBIN "Data/Cinema/CharSelect/deathscreen.bg" + +L1500_Contents:: + DW L1500_Load + DW L1500_Init + DW L1500_Check + DW L1500_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1500_Load: + DW ((L1500_LoadFinished - L1500_Load2)) ;size +L1500_Load2: + ;ld a,1 + ;ld [displayType],a + ;xor a + ;ld [scrollSprites],a + + ;fade to black + ;ld a,15 + ;call SetupFadeToBlack + ;call WaitFade + + call ResetSprites + ld a,BANK(deathscreen_bg) + ld hl,deathscreen_bg + call LoadCinemaBG + + ld a,BANK(death_gbm) + ld hl,death_gbm + call InitMusic + + ld a,30 + call SetupFadeFromStandard + ld d,0 + call ((.setEnvCounter-L1500_Load2)+levelCheckRAM) + +.loop + dec c + jr nz,.afterChangeEnv + dec b + jr nz,.afterChangeEnv + + call ((.setEnvCounter-L1500_Load2)+levelCheckRAM) + ld a,d + add 1 + cp 6 + jr nz,.afterResetEffectType + + xor a + +.afterResetEffectType + ld d,a + cp 4 + jr c,.validEffect + + cpl + add 7 + +.validEffect + ld [envEffectType],a + +.afterChangeEnv + ld a,1 + call Delay + ld a,[myJoy] + and %11110000 + jr z,.loop + + ;ld de,HERODATA_ENTERDIR + ;add hl,de + ;ld a,EXIT_D + ;ld [hl],a + + ld a,15 + call SetupFadeToBlack + call WaitFade + call ResetSprites + + ;----respawn at the appropriate map---- + ld hl,curLevelIndex + ld a,[respawnMap] + ld [hl+],a + ld a,[respawnMap+1] + ld [hl+],a + ld a,1 + ld [timeToChangeLevel],a + ret + +.setEnvCounter + ld bc,$02d8 + ret + +L1500_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1500_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1500_Init: + DW ((L1500_InitFinished - L1500_Init2)) ;size +L1500_Init2: + ret + +L1500_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1500_Check: + DW ((L1500_CheckFinished - L1500_Check2)) ;size +L1500_Check2: + ret + +L1500_CheckFinished: +PRINT "1500 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1500_LoadFinished - L1500_Load2) +PRINT " / " +PRINT (L1500_InitFinished - L1500_Init2) +PRINT " / " +PRINT (L1500_CheckFinished - L1500_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1502.asm b/Source/Levels/L1502.asm new file mode 100644 index 0000000..890162b --- /dev/null +++ b/Source/Levels/L1502.asm @@ -0,0 +1,998 @@ +; L1502.asm approach to kiwi +; Generated 03.06.2001 by mlevel +; Modified 03.06.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VAR_EXHAUST_FRAME EQU 0 + +TEMPKLUDGE EQU 0 + + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx1",ROMX +;--------------------------------------------------------------------- +flour_gang_mono_bg: + INCBIN "Data/Cinema/Distress/flour_gang_mono.bg" + +appomattox_big_bg: + INCBIN "Data/Cinema/Distress/appomattox_big.bg" + +appomattox_big_sprites_sp:: + INCBIN "Data/Cinema/Distress/appomattox_big_sprites.sp" + +nar_certaindanger_bg: + INCBIN "Data/Cinema/Distress/nar_certaindanger.bg" + + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx2",ROMX +;--------------------------------------------------------------------- +flourdriving_bg:: + INCBIN "Data/Cinema/Distress/flourdriving.bg" + +ba_bg:: + INCBIN "Data/Cinema/Distress/ba.bg" + +bs_bg:: + INCBIN "Data/Cinema/Distress/bs.bg" + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx3",ROMX +;--------------------------------------------------------------------- +remote_bg: + INCBIN "Data/Cinema/Distress/remote.bg" + +flowerviewscreen_bg:: + INCBIN "Data/Cinema/Distress/flowerviewscreen.bg" + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx4",ROMX +;--------------------------------------------------------------------- +yacht_under_fire_bg: + INCBIN "Data/Cinema/Distress/yacht_under_fire.bg" + +pirate_sprites_sp: + INCBIN "Data/Cinema/Distress/pirate_sprites.sp" + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx5",ROMX +;--------------------------------------------------------------------- +starfield_bg: + INCBIN "Data/Cinema/Appomattox/starfield.bg" + +starfield_sprite_sp:: + INCBIN "Data/Cinema/Appomattox/starfield_sprite.sp" + +;--------------------------------------------------------------------- +SECTION "Level1502Gfx6",ROMX +;--------------------------------------------------------------------- +appomattox_tokiwi_bg:: + INCBIN "Data/Cinema/Distress/appomattox_tokiwi.bg" + + +;--------------------------------------------------------------------- +SECTION "Level1502Dialog",ROMX +;--------------------------------------------------------------------- +dialog: +captain_cider_gtx: + INCBIN "Data/Dialog/Distress/captain_cider.gtx" + +haiku_cider_gtx: + INCBIN "Data/Dialog/Distress/haiku_cider.gtx" + +captain_whyglum_gtx: + INCBIN "Data/Dialog/Distress/captain_whyglum.gtx" + +ba_surrendering_gtx: + INCBIN "Data/Dialog/Distress/ba_surrendering.gtx" + +captain_winsome_gtx: + INCBIN "Data/Dialog/Distress/captain_winsome.gtx" + +bs_nearKiwi_gtx: + INCBIN "Data/Dialog/Distress/bs_nearKiwi.gtx" + +haiku_signal_gtx: + INCBIN "Data/Dialog/Distress/haiku_signal.gtx" + +captain_showit_gtx: + INCBIN "Data/Dialog/Distress/captain_showit.gtx" + +lady_help_gtx: + INCBIN "Data/Dialog/Distress/lady_help.gtx" + +captain_goodness_gtx: + INCBIN "Data/Dialog/Distress/captain_goodness.gtx" + +lady_saved_gtx:: + INCBIN "Data/Dialog/Distress/lady_saved.gtx" + +captain_seeyou_gtx:: + INCBIN "Data/Dialog/Distress/captain_seeyou.gtx" + +lady_wait_gtx:: + INCBIN "Data/Dialog/Distress/lady_wait.gtx" + +captain_holdout_gtx:: + INCBIN "Data/Dialog/Distress/captain_holdout.gtx" + +lady_no_gtx:: + INCBIN "Data/Dialog/Distress/lady_no.gtx" + +captain_shuttle_gtx:: + INCBIN "Data/Dialog/Distress/captain_shuttle.gtx" + +lady_stay_gtx:: + INCBIN "Data/Dialog/Distress/lady_stay.gtx" + +captain_nostuff_gtx:: + INCBIN "Data/Dialog/Distress/captain_nostuff.gtx" + +lady_please_gtx:: + INCBIN "Data/Dialog/Distress/lady_please.gtx" + +captain_nothanks_gtx:: + INCBIN "Data/Dialog/Distress/captain_nothanks.gtx" + +lady_must_gtx:: + INCBIN "Data/Dialog/Distress/lady_must.gtx" + +captain_no_gtx:: + INCBIN "Data/Dialog/Distress/captain_no.gtx" + +lady_insist_gtx:: + INCBIN "Data/Dialog/Distress/lady_insist.gtx" + +captain_okay_gtx:: + INCBIN "Data/Dialog/Distress/captain_okay.gtx" + +ba_goneawhile_gtx:: + INCBIN "Data/Dialog/Distress/ba_goneawhile.gtx" + + +;--------------------------------------------------------------------- +SECTION "Level1502Section",ROMX +;--------------------------------------------------------------------- + +L1502_Contents:: + DW L1502_Load + DW L1502_Init + DW L1502_Check + DW L1502_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1502_Load: + DW ((L1502_LoadFinished - L1502_Load2)) ;size +L1502_Load2: + ;restore health of heroes on next game engine level + xor a + ld [hero0_health],a + ld [hero1_health],a + + ld a,BANK(dialog) + ld [dialogBank],a + + ld a,BANK(intro_cinema_gbm) + ld hl,intro_cinema_gbm + call InitMusic + + xor a + ld [levelVars+VAR_EXHAUST_FRAME],a + + ld de,((.endCinema-L1502_Load2)+levelCheckRAM) + call SetDialogSkip + ld de,((.flourGang-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,BANK(appomattox_big_bg) + ld hl,appomattox_big_bg + call ((.appxSideView-L1502_Load2)+levelCheckRAM) + +.flourGang + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(flour_gang_mono_bg) + ld hl,flour_gang_mono_bg + call LoadCinemaBG + + ld a,BANK(nar_certaindanger_bg) + ld hl,nar_certaindanger_bg + call LoadCinemaTextBox + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + call GfxShowStandardTextBox + + ld de,((.appleCider-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,120 + call Delay + +;----"Haiku, did you bring the apple cider?"-------------------------- +.appleCider + call ((.loadFlour-L1502_Load2)+levelCheckRAM) + call LoadFont + + ld de,((.iBroughtTheCider-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_cider_gtx + + call ((.animateFlourDriving4-L1502_Load2)+levelCheckRAM) + +;----"I brought the cider..."----------------------------------------- +.iBroughtTheCider + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(haiku_bg) + ld hl,haiku_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.whySoGlum-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM haiku_cider_gtx + + LONGCALLNOARGS AnimateHaiku + +;----Why so glum?----------------------------------------------------- +.whySoGlum + call ((.loadFlour-L1502_Load2)+levelCheckRAM) + + ld de,((.itSucks-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_whyglum_gtx + + call ((.animateFlourDriving3-L1502_Load2)+levelCheckRAM) + +;----It sucks that we're surrendering after only two weeks!----------- +.itSucks + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(ba_bg) + ld hl,ba_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.winSomeLoseSome-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM ba_surrendering_gtx + + ld d,4 + LONGCALLNOARGS AnimateBA + +;----"Well you win some you lose some"-------------------------------- +.winSomeLoseSome + call ((.loadFlour-L1502_Load2)+levelCheckRAM) + + ld de,((.nearPlanetKiwi-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_winsome_gtx + + call ((.animateFlourDriving4-L1502_Load2)+levelCheckRAM) + +;----"Near planet Kiwi and you-know-who"------------------------------ +.nearPlanetKiwi + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(bs_bg) + ld hl,bs_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.distressCallFromLadyFlower-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM bs_nearKiwi_gtx + + ld d,4 + LONGCALLNOARGS AnimateBS + +;----"Distress call from Lady Flower"--------------------------------- +.distressCallFromLadyFlower + call ((.loadHaiku-L1502_Load2)+levelCheckRAM) + + ld de,((.showIt-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM haiku_signal_gtx + + LONGCALLNOARGS AnimateHaiku + +;----"Show it on the big screen"-------------------------------------- +.showIt + call ((.loadFlour-L1502_Load2)+levelCheckRAM) + + ld de,((.remoteControl-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_showit_gtx + + call ((.animateFlourDriving4-L1502_Load2)+levelCheckRAM) + +;----Remote control turns on screen----------------------------------- +.remoteControl + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(remote_bg) + ld hl,remote_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.help-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + call ((.delay15-L1502_Load2)+levelCheckRAM) + + ld bc,$0809 + ld de,$0800 + ld hl,$1400 + call CinemaBlitRect + + call ((.delay15-L1502_Load2)+levelCheckRAM) + + ld bc,$0809 + ld de,$0800 + ld hl,$1409 + call CinemaBlitRect + + call ((.delay15-L1502_Load2)+levelCheckRAM) + +;----"Help, our ship is being attacked by a space gang!"--------------- +.help + ld a,BANK(alarm_gbm) + ld hl,alarm_gbm + call InitMusic + call ((.loadLadyFlowerInDistress-L1502_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.myGoodness-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ;flash "distress" + ld a,60 +.flashDistress + push af + ld hl,$1a00 + ld a,[updateTimer] + and %1000 + jr z,.flashFrame0 + ld l,$09 +.flashFrame0 + ld bc,$1009 + ld de,$0201 + call CinemaBlitRect + ld a,1 + call Delay + pop af + dec a + jr nz,.flashDistress + + call ((.ladyFaceToViewscreen-L1502_Load2)+levelCheckRAM) + + ld c,0 + DIALOGBOTTOM lady_help_gtx + + ld d,(3|$80) + LONGCALLNOARGS AnimateLadyFlowerDistress + +;----"Oh my goodness!"------------------------------------------------ +.myGoodness + call ((.loadFlour-L1502_Load2)+levelCheckRAM) + + ld de,((.yachtUnderFire-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_goodness_gtx + + call ((.animateFlourDriving3-L1502_Load2)+levelCheckRAM) + + ld a,120 + call SetupFadeToBlack + call WaitFade + +;----Yacht under fire------------------------------------------------- +.yachtUnderFire + call ((.loadYachtScene-L1502_Load2)+levelCheckRAM) + + ld a,60 + call SetupFadeFromBlack + + ld de,((.appxWarp-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,110/3 +.laserLoop + push af + + ld bc,$0303 ;laser 1 + ld de,$0802 + ld hl,$1400 + ld a,6*4 ;pirate sprite number + call ((.pirateFire-L1502_Load2)+levelCheckRAM) + + ld bc,$0702 ;laser 2 + ld de,$0a05 + ld hl,$1700 + ld a,9*4 ;pirate sprite number + call ((.pirateFire-L1502_Load2)+levelCheckRAM) + + ld a,3 + call Delay + + pop af + dec a + jr nz,.laserLoop + + ;----------------star field----------------------------- +.appxWarp + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + ld a,BANK(main_in_game_gbm) + ld hl,main_in_game_gbm + call InitMusic + + ld a,BANK(starfield_bg) + ld hl,starfield_bg + call LoadCinemaBG + + ld a,BANK(starfield_sprite_sp) + ld hl,starfield_sprite_sp + call LoadCinemaSprite + + ld d,48 + (TEMPKLUDGE/2) + 40 + call ScrollSpritesLeft + + ld d,48 + (TEMPKLUDGE/2) + 40 + call ScrollSpritesDown + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.piratesFlee-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ;number of cycles total + ld b,180 + TEMPKLUDGE + 20 + +.loop + push bc + + call (.clearPaletteToBlack + (levelCheckRAM-L1502_Load2)) + call (.cycleColors + (levelCheckRAM-L1502_Load2)) + ld a,1 + ld [paletteBufferReady],a + + ld a,1 + call Delay + pop bc + + ld a,b + and %00000001 + jr nz,.afterScrollSprites + + ld d,1 + call ScrollSpritesUp + + ld d,1 + call ScrollSpritesRight + +.afterScrollSprites + ld a,b + and %00000010 + jr nz,.turnThrustOn + + call (.routine_thrustoff + (levelCheckRAM-L1502_Load2)) + jr .afterThrust + +.turnThrustOn + call (.routine_thruston + (levelCheckRAM-L1502_Load2)) + +.afterThrust + dec b + jr nz,.loop + + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + +;----Pirates Flee----------------------------------------------------- +.piratesFlee + call ((.loadYachtScene-L1502_Load2)+levelCheckRAM) + + ;replace yacht with damaged yacht + ld bc,$0906 + ld de,$0303 + ld hl,$1f06 + call CinemaBlitRect + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + + ld de,((.endCinema-L1502_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,30 + call Delay + + ld c,15 +.fleeLoopSlow + ld d,1 + call ScrollSpritesLeft + ld b,24 + call ((.setPirateSpriteDuringFlee-L1502_Load2)+levelCheckRAM) + ld d,1 + call ScrollSpritesLeft + ld b,12 + call ((.setPirateSpriteDuringFlee-L1502_Load2)+levelCheckRAM) + dec c + jr nz,.fleeLoopSlow + + ld c,35 +.fleeLoopFast + ld d,2 + call ScrollSpritesLeft + ld b,24 + call ((.setPirateSpriteDuringFlee-L1502_Load2)+levelCheckRAM) + ld d,2 + call ScrollSpritesLeft + ld b,12 + call ((.setPirateSpriteDuringFlee-L1502_Load2)+levelCheckRAM) + dec c + jr nz,.fleeLoopFast + +.endCinema + call LoadFont + + ld hl,$1403 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,2 + ld [timeToChangeLevel],a + ret + +.loadYachtScene + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(yacht_under_fire_bg) + ld hl,yacht_under_fire_bg + call LoadCinemaBG + + ld a,BANK(pirate_sprites_sp) + ld hl,pirate_sprites_sp + call LoadCinemaSprite + + ret + +.pirateFire + push af + ld a,1 + call GetRandomNumMask + or a + jr nz,.firing + +.notFiring + ld a,l + add c + ld l,a + call CinemaBlitRect + ld b,12 + jr .setPirateSprite + +.firing + call CinemaBlitRect + ld b,30 + +.setPirateSprite + pop af +.setPirateSpriteAfterPop + add 2 + ld h,((spriteOAMBuffer>>8)&$ff) + ld l,a + ld de,4 + ld a,b + cp 30 + jr nz,.afterSound + cp [hl] + jr z,.afterSound ;same sound + + push hl + ld hl,((.pirateLaserSound-L1502_Load2)+levelCheckRAM) + call PlaySound + pop hl + ld a,b + +.afterSound + ld [hl],a + add hl,de + add 2 + ld [hl],a + add hl,de + add 2 + ld [hl],a + add hl,de + ret + +.setPirateSpriteDuringFlee + ld a,6*4 + call ((.setPirateSpriteAfterPop-L1502_Load2)+levelCheckRAM) + ld a,9*4 + call ((.setPirateSpriteAfterPop-L1502_Load2)+levelCheckRAM) + ld a,1 + call Delay + ret + + +.quickToBlack + call BlackoutPalette + call ClearDialog + jp ResetSprites + +.quickFromBlack + ld a,1 + jp SetupFadeFromBlack + +.delay15 + ld a,15 + jp Delay + +.loadLadyFlowerOnScreen + call ((.loadLadyFlowerInDistress-L1502_Load2)+levelCheckRAM) + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + jp ((.ladyFaceToViewscreen-L1502_Load2)+levelCheckRAM) + +.loadLadyFlowerInDistress + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(flowerviewscreen_bg) + ld hl,flowerviewscreen_bg + call LoadCinemaBG + ret + +.ladyFaceToViewscreen + ;put lady flower's face on + ld bc,$1009 + ld de,$0201 + ld hl,$1a12 + call CinemaBlitRect + ret + +.loadHaiku + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(haiku_bg) + ld hl,haiku_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + ret + +.loadFlour + call ((.quickToBlack-L1502_Load2)+levelCheckRAM) + + ld a,BANK(flourdriving_bg) + ld hl,flourdriving_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1502_Load2)+levelCheckRAM) + ret + +.animateFlourDriving3 + ld d,3 + jr .animateFlourDrivingN + +.animateFlourDriving4 + ld d,4 +.animateFlourDrivingN + LONGCALLNOARGS AnimateFlourDriving + + +.scrollStars + push bc + push de + push hl + + ;of 32 stars, scroll odd ones by one pixel and evens + ;by two + ld c,16 + ld de,4 + ld hl,spriteOAMBuffer+8*4+1 +.scrollStarsLoop + dec [hl] + add hl,de + dec [hl] + dec [hl] + add hl,de + dec c + jr nz,.scrollStarsLoop + + ;ping-pong exhaust + ld hl,levelVars+VAR_EXHAUST_FRAME + ld a,[updateTimer] + bit 0,a + jr nz,.gotCurFrame + + ;increment frame + ld a,[hl] + add 16 + cp 160 + jr nz,.wrapFrame + xor a +.wrapFrame + ld [hl],a + +.gotCurFrame + ld a,[hl] + ;sprite = curframe + 80 + cp 96 + jr c,.frameOkay + cpl + add 161 +.frameOkay + add 80 + ld hl,spriteOAMBuffer+2 + ld de,4 + ld c,8 +.setThrust + ld [hl],a + add 2 + add hl,de + dec c + jr nz,.setThrust + + pop hl + pop de + pop bc + ret + +.routine_thrustoff + ;turn thrust off by setting sprites 0-5 to pattern 50 + ld hl,spriteOAMBuffer+2 + ld de,4 + ld a,50 + ld c,6 +.thrustOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.thrustOffLoop + ret + +.routine_thruston + ;turn thrust on by setting sprites 0-5 to patterns 0,2,4,6,8,10 + ld hl,spriteOAMBuffer+2 + ld de,4 + xor a + ld c,6 +.thrustOnLoop + ld [hl],a + inc a + inc a + add hl,de + dec c + jr nz,.thrustOnLoop + ret + +.clearPaletteToBlack + push bc + ld c,64 + ld hl,fadeCurPalette + xor a +.clearPaletteLoop + ld [hl+],a + dec c + jr nz,.clearPaletteLoop + pop bc + ret + +.cycleColors + ;b is current cycle + ;set palettes 1,5, & 7 to cycle half-speed (1/8 speed of b) + ;rest to cycle full speed (1/4 speed of b) + push bc + + ;----------set full-speed palettes (0,2,3,4,6)------------ + ;color = (clock % 6) / 2 + ld c,6 + ld a,b +.getMod6 + cp c + jr c,.gotMod6 + sub c + jr .getMod6 +.gotMod6 + srl a ;divided by 2 yields 0-2 + ld c,a + inc c ;c is now 1-3 + + push bc + ld b,0 + xor a + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;0 + inc a + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;2 + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;3 + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;4 + inc a + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;6 + pop bc + + ;----------set half-speed palettes (1,5,7)--------------- + ;color = (clock % 12) / 4 + ld c,12 + ld a,b +.getMod12 + cp c + jr c,.gotMod12 + sub c + jr .getMod12 +.gotMod12 + srl a ;divided by 4 yields 0-2 + srl a + ld c,a + inc c ;c is now 1-3 + + push bc + ld b,1 + ld a,1 + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;1 + ld a,5 + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;5 + inc a + call (.setCycle + (levelCheckRAM-L1502_Load2)) ;7 + pop bc + + pop bc + ret + +.setCycle + ;a is palette # to set (0-7) + ;b is color flag (0=white, 1=grey) + ;c is color number to set (1-3) + push af + push hl + + ;(palette# * 4 + color) * 2 + 128 is first byte to set + rlca + rlca + add c + rlca + add 128 + ld l,a + ld h,((fadeCurPalette>>8) & $ff) + + ld a,b + cp 1 + jr z,.setToGrey + + ;set to white + ld a,$ff + ld [hl+],a + ld a,$7f + ld [hl],a + jr .done + +.setToGrey + ld a,$08 + ld [hl+],a + ld a,$21 + ld [hl],a + +.done + pop hl + pop af + inc a + ret + +.animate_ship + push bc + ld b,90 +.animate_loop + push bc + ld a,1 + call Delay + pop bc + + ld a,b + and %10 ;thrust on or off? + + jr nz,.animate_thruston + call (.routine_thrustoff + (levelCheckRAM-L1502_Load2)) + jr .animate_check_done + +.animate_thruston + call (.routine_thruston + (levelCheckRAM-L1502_Load2)) + +.animate_check_done + dec b + jr nz,.animate_loop + + pop bc + + ret + +.pirateLaserSound + DB 1,$3c,00,$f6,00,$87 + +.appxSideView + call LoadCinemaBG + + ld a,BANK(appomattox_big_sprites_sp) + ld hl,appomattox_big_sprites_sp + call LoadCinemaSprite + + ;change 1st 32 sprites to be BG priority + ld c,32 + ld hl,spriteOAMBuffer+8*4+3 + ld de,4 +.spritePriorityLoop + set 7,[hl] + add hl,de + dec c + jr nz,.spritePriorityLoop + + ld a,90 + call SetupFadeFromBlack + +.appxScrollStarsWaitFade + ld c,160 +.waitFade + ld a,1 + call Delay + call ((.scrollStars-L1502_Load2)+levelCheckRAM) + dec c + jr nz,.waitFade + + ret + + +L1502_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1502_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1502_Init: + DW ((L1502_InitFinished - L1502_Init2)) ;size +L1502_Init2: + ret + +L1502_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1502_Check: + DW ((L1502_CheckFinished - L1502_Check2)) ;size +L1502_Check2: + ret + +L1502_CheckFinished: +PRINT "1502 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1502_LoadFinished - L1502_Load2) +PRINT " / " +PRINT (L1502_InitFinished - L1502_Init2) +PRINT " / " +PRINT (L1502_CheckFinished - L1502_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1503.asm b/Source/Levels/L1503.asm new file mode 100644 index 0000000..e1e2786 --- /dev/null +++ b/Source/Levels/L1503.asm @@ -0,0 +1,847 @@ +; L1503.asm +; Generated 03.08.2001 by mlevel +; Modified 03.08.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + + + + + +VAR_DESTZONE EQU 0 +VAR_DESTCOLOR EQU 1 +VAR_DESTBG EQU 3 +VAR_DESTBANK EQU 5 + +VAR_SELSTAGE EQU 6 + +;--------------------------------------------------------------------- +SECTION "Level1503Gfx1",ROMX +;--------------------------------------------------------------------- +downramp_bg:: + INCBIN "Data/Cinema/Distress/downramp.bg" + +downramp_sprites_sp: + INCBIN "Data/Cinema/Distress/downramp_sprites.sp" + +;--------------------------------------------------------------------- +SECTION "Level1503Gfx2",ROMX +;--------------------------------------------------------------------- +flower_and_flour_establishing_bg: + INCBIN "Data/Cinema/Distress/flower_and_flour_establishing.bg" + +flour_and_flower_bg: + INCBIN "Data/Cinema/Distress/flour_and_flower.bg" + +;--------------------------------------------------------------------- +SECTION "Level1503Section",ROMX +;--------------------------------------------------------------------- + +L1503_Contents:: + DW L1503_Load + DW L1503_Init + DW L1503_Check + DW L1503_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1503_Load: + DW ((L1503_LoadFinished - L1503_Load2)) ;size +L1503_Load2: + ld a,1 + ld [displayType],a + xor a + ld [scrollSprites],a + ld a,1 + call Delay + + ld de,((.landingOnKiwi-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld de,((.endCinema-L1503_Load2)+levelCheckRAM) + call SetDialogSkip + +.flying + ld a,BANK(cloud0_bg) + ld hl,cloud0_bg + call LoadCinemaBG + ld a,1 + call Delay + + ld a,15 + call ((.setupFadeToClouds-L1503_Load2)+levelCheckRAM) + + ld b,50 + ld c,1 +.cloudAnim + ;load next cloud frame + ld d,0 ;de = c*4 + ld e,c + sla e + rl d + sla e + rl d + ld hl,((.cloudFrames-L1503_Load2)+levelCheckRAM) + add hl,de + ld a,[hl+] ;mem bank of cloud frame + inc hl + push af + ld a,[hl+] + ld h,[hl] + ld l,a + pop af + call LoadCinemaBG + ;ld a,1 + ;call Delay + call ((.animateWave-L1503_Load2)+levelCheckRAM) + + ld a,c + inc a + and 7 + ld c,a + + ld a,b + cp 20 + jr nz,.afterStartFadeOutInClouds + + ld a,15 + call ((.setupFadeToSky-L1503_Load2)+levelCheckRAM) + +.afterStartFadeOutInClouds + dec b + jr nz,.cloudAnim + + ld a,3 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1503_Load2)+levelCheckRAM) + +;----Load picture of new landing zone--------------------------------- + ld hl,levelVars+VAR_DESTBANK + ld a,[hl-] + push af + ld a,[hl-] + ld l,[hl] + ld h,a + pop af + call LoadCinemaBG + ld a,1 + call Delay + + ld a,FADEBANK + ld [$ff70],a + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld a,1 + call FadeInit + call WaitFade + ld a,2 + call Delay + + ld a,190 + ldio [jiggleDuration],a + + ld a,1 + ldio [jiggleType],a ;take-off jiggle + + ld a,18 + ld [camera_j],a + + ld a,$11 + ldio [scrollSpeed],a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterRemoteAppx + +.addRemoteAppx + ld a,LCHANGEAPPXMAP + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.addRemoteAppx ;must repeat + ld a,[appomattoxMapIndex] + call TransmitByte +.afterRemoteAppx + + ld hl,musicEnabled ;disable track 4 + res 3,[hl] + + ld hl,((.engineSound1-L1503_Load2)+levelCheckRAM) + call PlaySound + + ld a,40 + call ((.delayAdjustHorizon-L1503_Load2)+levelCheckRAM) + + ld a,2 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1503_Load2)+levelCheckRAM) + + ld a,15 + call ((.delayAdjustHorizon-L1503_Load2)+levelCheckRAM) + + ld a,1 + ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1503_Load2)+levelCheckRAM) + + ;ld hl,((.engineSound2-L1503_Load2)+levelCheckRAM) + ;call PlaySound + + ;ld a,30 + ;call ((.delayAdjustHorizon-L1503_Load2)+levelCheckRAM) + + ;xor a + ;ld [levelVars+VAR_SELSTAGE],a + ;call ((.setPowerBar-L1503_Load2)+levelCheckRAM) + + ;ld a,30 + ;call ((.delayAdjustHorizon-L1503_Load2)+levelCheckRAM) + + ;ld hl,musicEnabled ;enable track 4 + ;set 3,[hl] + + ;call ((.powerDown-L1503_Load2)+levelCheckRAM) + + ;----------------landing on kiwi----------------------- +.landingOnKiwi + xor a + ldio [jiggleDuration],a + call ((.delay2-L1503_Load2)+levelCheckRAM) + call BlackoutPalette + call ClearDialog + call ResetSprites + call ((.delay2-L1503_Load2)+levelCheckRAM) + + ld a,BANK(landing_bg_bg) + ld hl,landing_bg_bg + call LoadCinemaBG + ld a,BANK(landing_sprites_sp) + ld hl,landing_sprites_sp + call LoadCinemaSprite + + ld d,16 + call ScrollSpritesRight + ld d,48 + call ScrollSpritesUp + + ;set landing gear sprites and flame to off + ld hl,spriteOAMBuffer+6 + ld c,8 + xor a +.init_landing_loop + ld [hl+],a + inc hl + inc hl + inc hl + dec c + jr nz,.init_landing_loop + + ld de,((.ramp-L1503_Load2)+levelCheckRAM) + call SetDialogForward + + ;----------------animate descent of appomattox + + ;landing gear stowed + ld a,1 + call SetupFadeFromBlack + ld b,60 +.descent1 + push bc + ld a,1 + call Delay + ld d,1 + call ((.scrollAllSpritesDown-L1503_Load2)+levelCheckRAM) + pop bc + + dec b + jr nz,.descent1 + + ;landing gear half-out + ld hl,spriteOAMBuffer+(9*4)+2 + ld c,4 + ld a,2 +.gear_half_loop + ld [hl+],a ;change tile index + inc hl + inc hl + inc hl + add 2 + dec c + jr nz,.gear_half_loop + + ld b,5 +.descent2 + push bc + call ((.delay2-L1503_Load2)+levelCheckRAM) + ld d,1 + call ((.scrollAllSpritesDown-L1503_Load2)+levelCheckRAM) + pop bc + + dec b + jr nz,.descent2 + + ;landing gear full out + ld hl,spriteOAMBuffer+(9*4)+2 + ld c,4 + ld a,10 +.gear_full_loop + ld [hl+],a ;change tile index + inc hl + inc hl + inc hl + add 2 + dec c + jr nz,.gear_full_loop + + ld b,20 +.descent3 + push bc + call ((.delay2-L1503_Load2)+levelCheckRAM) + ld d,1 + call ((.scrollAllSpritesDown-L1503_Load2)+levelCheckRAM) + pop bc + + dec b + jr nz,.descent3 + + ;engine noise fade to off + ld hl,((.engineSound2-L1503_Load2)+levelCheckRAM) + call PlaySound + + ld b,10 +.descent4 + push bc + ld a,3 + call Delay + ld d,1 + call ((.scrollAllSpritesDown-L1503_Load2)+levelCheckRAM) + pop bc + + dec b + jr nz,.descent4 + + ld a,30 + call Delay + +;----Walking down the landing ramp------------------------------------ +.ramp + call BlackoutPalette + call ResetSprites + + ld a,BANK(downramp_bg) + ld hl,downramp_bg + call LoadCinemaBG + + ld a,BANK(downramp_sprites_sp) + ld hl,downramp_sprites_sp + call LoadCinemaSprite + + call ((.quickFromBlack-L1503_Load2)+levelCheckRAM) + + ld de,((.establishing-L1503_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,BANK(lady_flower_gbm) + ld hl,lady_flower_gbm + call InitMusic + + ld a,30 + call Delay + + ld c,9 +.walkDownRamp + ;second frame + ld a,8 + call ((.animateRampSprites-L1503_Load2)+levelCheckRAM) + ld d,2 + call ScrollSpritesRight + ld d,1 + call ScrollSpritesDown + ld a,5 + call Delay + + ;first frame + xor a + call ((.animateRampSprites-L1503_Load2)+levelCheckRAM) + ld d,2 + call ScrollSpritesRight + ld d,1 + call ScrollSpritesDown + ld a,5 + call Delay + dec c + jr nz,.walkDownRamp + + ld a,30 + call Delay + +.establishing + call BlackoutPalette + call ResetSprites + call LoadFont + + ld a,BANK(flower_and_flour_establishing_bg) + ld hl,flower_and_flour_establishing_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1503_Load2)+levelCheckRAM) + + ld de,((.talking-L1503_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,60 + call Delay + +.talking + ld a,$21 + ldio [scrollSpeed],a + call BlackoutPalette + + ld a,BANK(flour_and_flower_bg) + ld hl,flour_and_flower_bg + call LoadCinemaBG + + call ((.quickFromBlack-L1503_Load2)+levelCheckRAM) + + ld de,((.nostuff-L1503_Load2)+levelCheckRAM) + call SetDialogForward + + ld a,BANK(lady_stay_gtx) + ld [dialogBank],a + + ld c,0 + DIALOGBOTTOM lady_stay_gtx + ld d,3 + LONGCALLNOARGS AnimateLadyFlowerRamp + +.nostuff + call ((.panToCaptain-L1503_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM captain_nostuff_gtx + ld de,((.please-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,3 + LONGCALLNOARGS AnimateCaptainRamp + +.please + call ((.panToLady-L1503_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM lady_please_gtx + ld de,((.nothanks-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,3 + LONGCALLNOARGS AnimateLadyFlowerRamp + +.nothanks + call ((.panToCaptain-L1503_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM captain_nothanks_gtx + ld de,((.must-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,2 + LONGCALLNOARGS AnimateCaptainRamp + +.must + ;call StopMusic + ;ld hl,((.buzzerSound-L1503_Load2)+levelCheckRAM) + ;call PlaySound + ld a,$41 + ldio [scrollSpeed],a + call ((.panToLady-L1503_Load2)+levelCheckRAM) + ;ld a,30 + ;call Delay + ;ld a,15 + ;ldio [jiggleDuration],a + ld c,0 + DIALOGBOTTOM lady_must_gtx + ld de,((.no-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,2 + LONGCALLNOARGS AnimateLadyFlowerRamp + +.no + call ((.panToCaptain-L1503_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM captain_no_gtx + ld de,((.insist-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,2 + LONGCALLNOARGS AnimateCaptainRamp + +.insist + ld a,$82 + ldio [scrollSpeed],a + call ((.panToLady-L1503_Load2)+levelCheckRAM) + ld c,0 + DIALOGBOTTOM lady_insist_gtx + ld de,((.okay-L1503_Load2)+levelCheckRAM) + call SetDialogForward + ld d,2 + LONGCALLNOARGS AnimateLadyFlowerRamp + +.okay + +.endCinema + call BlackoutPalette + call ClearDialog + call ResetSprites + + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_N + ld [hl],a + ld hl,$1504 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,2 + ld [timeToChangeLevel],a + ret + +.panToCaptain + ld a,21 + ld [camera_i],a + ld a,23 + ld [camera_j],a + ret + +.panToLady + xor a + ld [camera_i],a + ld [camera_j],a + ret + +.animateRampSprites + push bc + ld hl,spriteOAMBuffer+2 + ld de,4 + ld c,4 +.animateRampSpritesLoop + ld [hl],a + add hl,de + add 2 + dec c + jr nz,.animateRampSpritesLoop + pop bc + ret + +.powerDown + ;xor a + ;ld [levelVars+VAR_SELSTAGE],a + call ((.setPowerBar-L1503_Load2)+levelCheckRAM) + call ((.recticleOff-L1503_Load2)+levelCheckRAM) + call ((.horizonOff-L1503_Load2)+levelCheckRAM) + call ((.diagramOff-L1503_Load2)+levelCheckRAM) + ld a,30 + call ((.delayAnimateWave-L1503_Load2)+levelCheckRAM) + ret + +.setPowerBar + ld a,[levelVars+VAR_SELSTAGE] + inc a + ld [musicRegisters+0],a + dec a + rlca ;sprite = stage*4 + 44 + rlca + add 44 + ld hl,spriteOAMBuffer+22*4+2 + ld [hl+],a + inc hl + inc hl + inc hl + add 2 + ld [hl],a + + ret + +.horizonOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+16*4 + ld c,4 +.horizonOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.horizonOffLoop + ret + +.recticleOff + ld de,4 + xor a + ld hl,spriteOAMBuffer+8*4 + ld c,8 +.recticleOffLoop + ld [hl],a + add hl,de + dec c + jr nz,.recticleOffLoop + ret + +.diagramOff + ld hl,spriteOAMBuffer+20*4 + ld [hl],160 + ld hl,spriteOAMBuffer+21*4 + ld [hl],160 + ret + + +.delayAdjustHorizon + ld c,a + ld hl,spriteOAMBuffer+16*4 + ld de,4 +.delayLoop + call ((.animateWave-L1503_Load2)+levelCheckRAM) + + ld a,1 + call Delay + + ;horizon = 58 - ((mapTop*8+desiredPixelOffset_y)/4) + ld a,[mapTop] + rlca + rlca + rlca + ld b,a + ld a,[desiredPixelOffset_y] + add b + srl a + srl a + cpl + add 59 + + push hl + ld b,4 +.alterHorizonSpriteLoop + ld [hl],a + add hl,de + dec b + jr nz,.alterHorizonSpriteLoop + pop hl + dec c + jr nz,.delayLoop + ret + + +.setupFadeFromSky + push af + + ld a,FADEBANK + ld [$ff70],a + + ;set final palette bg7 to be bg7 color 0 + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + ld hl,fadeFinalPalette+8*7 + ld a,$80 + ld c,a + ld b,$7d + ld hl,fadeFinalPalette+8*7 + call ((.setBG7-L1503_Load2)+levelCheckRAM) + + pop af + call FadeInit + ret + +.setBG7 + ;copy bc to 4 entries at palette hl + ld hl,fadeFinalPalette+8*7 + ld a,4 +.setBG7Loop + ld [hl],c + inc hl + ld [hl],b + inc hl + dec a + jr nz,.setBG7Loop + ret + +.setupFadeToSky + push bc + push de + push hl + + push af + + ld hl,gamePalette + ld de,fadeCurPalette + call FadeCommonCopyPalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ld hl,levelVars+VAR_DESTZONE + ld a,[hl+] + ld [appomattoxMapIndex],a + ld a,[hl+] + ld b,[hl] + ld c,a + ld hl,fadeCurPalette+8*7 + call ((.setBG7-L1503_Load2)+levelCheckRAM) + pop af + call FadeInit + pop hl + pop de + pop bc + ret + +.defaultSkyColor + ld bc,$7e20 + ret + +.setupFadeToClouds + push af + + ld a,FADEBANK + ld [$ff70],a + + ld hl,gamePalette + ld de,fadeFinalPalette + call FadeCommonCopyPalette + + ;set all colors to be $7d80 + ld hl,fadeCurPalette + ld c,64 +.setAll7d80 + ld [hl],$80 + inc hl + ld [hl],$7d + inc hl + dec c + jr nz,.setAll7d80 + + pop af + call FadeInit + ret + +.cloudFrames + DW BANK(cloud0_bg), cloud0_bg, BANK(cloud1_bg), cloud1_bg + DW BANK(cloud2_bg), cloud2_bg, BANK(cloud3_bg), cloud3_bg + DW BANK(cloud4_bg), cloud4_bg, BANK(cloud5_bg), cloud5_bg + DW BANK(cloud6_bg), cloud6_bg, BANK(cloud7_bg), cloud7_bg + +.engineSound1 + DB 4,$00,$df,$a9,$80 ;looping/infinite + +.engineSound2 + DB 4,$00,$d7,$a9,$80 ;fades + +.byte8 + DB 8 + +.delayAnimateWave + push af + call ((.animateWave-L1503_Load2)+levelCheckRAM) + ld a,1 + call Delay + pop af + dec a + jr nz,.delayAnimateWave + ret + +.animateWave + push bc + push de + push hl + PUSHROM + ld a,BANK(appwaves0_dat) + call SetActiveROM + ld a,[levelVars+VAR_SELSTAGE] ;a=stage*8 + frame*2 + rlca + rlca + rlca + ld b,a + ldio a,[vblankTimer] + and %11000 + rrca + rrca + or b + add (((.waveFrameTable-L1503_Load2)+levelCheckRAM) & $ff) + ld l,a + ld a,0 + adc ((((.waveFrameTable-L1503_Load2)+levelCheckRAM)>>8) & $ff) + ld h,a + ld a,[hl+] + ld h,[hl] + ld l,a + ld de,$9420 + ld c,40 + ld a,1 + call VMemCopy + POPROM + pop hl + pop de + pop bc + ret + +.waveFrameTable + DW appwaves0_dat,appwaves0_dat+640,appwaves0_dat+640*2,appwaves0_dat+640*3 + DW appwaves1_dat,appwaves1_dat+640,appwaves1_dat+640*2,appwaves1_dat+640*3 + DW appwaves2_dat,appwaves2_dat+640,appwaves2_dat+640*2,appwaves2_dat+640*3 + DW appwaves3_dat,appwaves3_dat+640,appwaves3_dat+640*2,appwaves3_dat+640*3 + DW appwaves4_dat,appwaves4_dat+640,appwaves4_dat+640*2,appwaves4_dat+640*3 + +.scrollAllSpritesDown + push bc + push de + push hl + + ld hl,spriteOAMBuffer + ld c,35 +.scrollDownLoop + ld a,[hl] + add d + ld [hl+],a + inc hl + inc hl + inc hl + dec c + jr nz,.scrollDownLoop + + pop hl + pop de + pop bc + ret + +.quickFromBlack + ld a,1 + jp SetupFadeFromBlack + +.delay2 + ld a,2 + jp Delay + +L1503_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1503_Map: + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1503_Init: + DW ((L1503_InitFinished - L1503_Init2)) ;size +L1503_Init2: + ret + +L1503_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1503_Check: + DW ((L1503_CheckFinished - L1503_Check2)) ;size +L1503_Check2: + ret + +L1503_CheckFinished: +PRINT "1503 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1503_LoadFinished - L1503_Load2) +PRINT " / " +PRINT (L1503_InitFinished - L1503_Init2) +PRINT " / " +PRINT (L1503_CheckFinished - L1503_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1504.asm b/Source/Levels/L1504.asm new file mode 100644 index 0000000..864d5e5 --- /dev/null +++ b/Source/Levels/L1504.asm @@ -0,0 +1,355 @@ +; L1504.asm kidnap +; Generated 03.09.2001 by mlevel +; Modified 03.09.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +LIGHTINDEX EQU 49 +LADY_INDEX EQU 60 +CAPTAIN_INDEX EQU 61 + +VAR_LIGHT EQU 0 + +STATE_WAITFOREXIT EQU 2 +STATE_FIRSTEXITED EQU 3 +STATE_BOTHEXITED EQU 4 + + + + + +;--------------------------------------------------------------------- +SECTION "Level1504Gfx1",ROMX +;--------------------------------------------------------------------- +at_gunpoint_bg: + INCBIN "Data/Cinema/Distress/at_gunpoint.bg" + +at_gunpoint_sprites_sp: + INCBIN "Data/Cinema/Distress/at_gunpoint_sprites.sp" + +;--------------------------------------------------------------------- +SECTION "Level1504Section",ROMX +;--------------------------------------------------------------------- + +L1504_Contents:: + DW L1504_Load + DW L1504_Init + DW L1504_Check + DW L1504_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1504_Load: + DW ((L1504_LoadFinished - L1504_Load2)) ;size +L1504_Load2: + call State0To1 + cp 1 + jr z,.cinema + + ;map + jp ParseMap + +.cinema + ld a,1 + ld [displayType],a + xor a + ld [scrollSprites],a + ld a,BANK(captain_okay_gtx) + ld [dialogBank],a + + call LoadFont + + ;call StopMusic + ld a,BANK(lady_flower_gbm) + ld hl,lady_flower_gbm + call InitMusic + +;----Points gun at flour---------------------------------------------- + ld a,BANK(at_gunpoint_bg) + ld hl,at_gunpoint_bg + call LoadCinemaBG + + ld a,BANK(at_gunpoint_sprites_sp) + ld hl,at_gunpoint_sprites_sp + call LoadCinemaSprite + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld de,((.okay-L1504_Load2)+levelCheckRAM) + call SetDialogForward + ld de,((.endCinema-L1504_Load2)+levelCheckRAM) + call SetDialogSkip + + + ld c,80 +.scrollGun + ld d,1 + call ScrollSpritesRight + ld a,1 + call Delay + dec c + jr nz,.scrollGun + + ld a,60 + call Delay + +.okay + call ((.showGunForSure-L1504_Load2)+levelCheckRAM) + ld de,((.endCinema-L1504_Load2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM captain_okay_gtx + + ld d,2 + LONGCALLNOARGS AnimateCaptainGunpoint + +.endCinema + call ClearDialog + call ResetSprites + ld a,15 + call SetupFadeToStandard + + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,EXIT_D + ld [hl],a + ld a,2 + ldio [mapState],a + dec a + ld [timeToChangeLevel],a + + ret + +.showGunForSure + ld hl,spriteOAMBuffer + 1 + ld a,[hl] ;negative of first sprite x pos + 8 + cpl + add 9 + ld d,a + call ScrollSpritesRight ;is amount to scroll sprites + + ret + +L1504_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1504_Map: + INCBIN "Data/Levels/L1504_landing.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1504_Init: + DW ((L1504_InitFinished - L1504_Init2)) ;size +L1504_Init2: + ld a,0 + ld hl,((.heroInvisible - L1504_Init2) + levelCheckRAM) + call CheckEachHero + + ld a,1 + ld [heroesIdle],a + + ld a,[bgTileMap+LIGHTINDEX] + ld [levelVars+VAR_LIGHT],a + + ld c,CAPTAIN_INDEX + call GetFirst + ld hl,$d04A + call SetActorDestLoc + + ld c,LADY_INDEX + call GetFirst + ld hl,$d04A + call SetActorDestLoc + + ld a,16 + ld [mapLeft],a + ld a,$11 + ldio [scrollSpeed],a + + ret + +.heroInvisible + or a + ret z + ld c,a + call GetFirst + call GetFacing + ld c,a + call RemoveFromMap + ret + +L1504_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1504_Check: + DW ((L1504_CheckFinished - L1504_Check2)) ;size +L1504_Check2: + call ((.animateLandingLights-L1504_Check2)+levelCheckRAM) + + ldio a,[mapState] + cp STATE_BOTHEXITED + jr z,.bothExited + + ld c,CAPTAIN_INDEX + call ((.checkActorExit-L1504_Check2)+levelCheckRAM) + + ld c,LADY_INDEX + call ((.checkActorExit-L1504_Check2)+levelCheckRAM) + ret + +.bothExited + ld de,((.downramp-L1504_Check2)+levelCheckRAM) + call SetDialogForward + ld de,((.endCinema-L1504_Check2)+levelCheckRAM) + call SetDialogSkip + + ld c,60 +.delayAfterExitGate + ld a,1 + call Delay + push bc + call ((.animateLandingLights-L1504_Check2)+levelCheckRAM) + pop bc + dec c + jr nz,.delayAfterExitGate + + +.downramp + call ResetSprites + call BlackoutPalette + + ld a,BANK(downramp_bg) + ld hl,downramp_bg + call LoadCinemaBG + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld de,((.ba_awhile-L1504_Check2)+levelCheckRAM) + call SetDialogForward + + ld a,90 + call Delay + +.ba_awhile + call BlackoutPalette + + ld a,BANK(ba_bg) + ld hl,ba_bg + call LoadCinemaBG + + ld a,1 + call SetupFadeFromBlack + call WaitFade + + ld de,((.endCinema-L1504_Check2)+levelCheckRAM) + call SetDialogForward + + ld c,0 + DIALOGBOTTOM ba_goneawhile_gtx + + ld d,3 + LONGCALLNOARGS AnimateBA + + ;ld a,15 + ;call SetupFadeToStandard + ;call WaitFade + +.endCinema + call ClearDialogSkipForward + ;ld a,15 + ;call SetupFadeToBlack + ;call WaitFade + + ld hl,$1100 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + + ret + +.checkActorExit + call GetFirst + or a + ret z ;already exited + + call GetCurLocation + call ConvertLocHLToXY + + ld a,l ;y coord + cp 1 + ret nz ;not at gate exit + + ld b,METHOD_DIE + call CallMethod + + ld hl,disappearSound + call PlaySound + + ld hl,mapState ;at exit, mapState++ + inc [hl] + ld a,[hl] + cp STATE_BOTHEXITED + ret nz + + ;close the gate + ld bc,$0202 ;blit the closed gate + ld de,$0901 + ld hl,$2409 + call BlitMap + + ld a,5 + call Delay + ld hl,closeGateSound + call PlaySound + ret + + +.animateLandingLights + ldio a,[updateTimer] + rrca + rrca + and %11 + ld b,a + + ld a,[levelVars+VAR_LIGHT] + ld c,a + ld d,0 + + ld hl,bgTileMap+LIGHTINDEX + call ((.animateLight-L1504_Check2)+levelCheckRAM) + call ((.animateLight-L1504_Check2)+levelCheckRAM) + call ((.animateLight-L1504_Check2)+levelCheckRAM) + call ((.animateLight-L1504_Check2)+levelCheckRAM) + ret + +.animateLight + ld a,d + add b + and %11 + add c + ld [hl+],a + inc d + ret + + +L1504_CheckFinished: +PRINT "1504 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1504_LoadFinished - L1504_Load2) +PRINT " / " +PRINT (L1504_InitFinished - L1504_Init2) +PRINT " / " +PRINT (L1504_CheckFinished - L1504_Check2) +PRINT "\n" + diff --git a/Source/Levels/L1512.asm b/Source/Levels/L1512.asm new file mode 100644 index 0000000..206e880 --- /dev/null +++ b/Source/Levels/L1512.asm @@ -0,0 +1,210 @@ +; L1512.asm Crouton Homeworld 4 +; Generated 04.19.2001 by mlevel +; Modified 04.19.2001 by Abe Pralle + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + +VFENCE_INDEX EQU 19 + +VAR_BGKILLED EQU 15 + + +;--------------------------------------------------------------------- +SECTION "Level1512Section",ROMX +;--------------------------------------------------------------------- + +L1512_Contents:: + DW L1512_Load + DW L1512_Init + DW L1512_Check + DW L1512_Map + +;--------------------------------------------------------------------- +; Load +;--------------------------------------------------------------------- +L1512_Load: + DW ((L1512_LoadFinished - L1512_Load2)) ;size +L1512_Load2: + call ParseMap + ret + +L1512_LoadFinished: +;--------------------------------------------------------------------- +; Map +;--------------------------------------------------------------------- +L1512_Map: +INCBIN "Data/Levels/L1512_crouton_hw4.lvl" + +;--------------------------------------------------------------------- +; Init +;--------------------------------------------------------------------- +L1512_Init: + DW ((L1512_InitFinished - L1512_Init2)) ;size +L1512_Init2: + xor a + ld [levelVars+VAR_BGKILLED],a + ret + +L1512_InitFinished: +;--------------------------------------------------------------------- +; Check +;--------------------------------------------------------------------- +L1512_Check: + DW ((L1512_CheckFinished - L1512_Check2)) ;size +L1512_Check2: + call ((.animateFence-L1512_Check2)+levelCheckRAM) + call ((.checkBlowGenerators-L1512_Check2)+levelCheckRAM) + ret + +.checkBlowGenerators + ld a,[levelVars+VAR_BGKILLED] + or a + ret z + + ld a,[hero0_index] + or a + jr z,.checkHero1 + + ;change hero 0 to actor & walk to teleport + ld c,a + call GetFirst + ld hl,$d0e4 + call SetActorDestLoc + call GetClassMethodTable + ld b,h + ld c,l + ld de,classActor + call ChangeClass + +.checkHero1 + ld a,[hero1_index] + or a + jr z,.startExplosions + + ;change hero 1 to actor & walk to teleport + ld c,a + call GetFirst + ld hl,$d104 + call SetActorDestLoc + call GetClassMethodTable + ld b,h + ld c,l + ld de,classActor + call ChangeClass + +.startExplosions + ld hl,$d0cb + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + call ((.animateDelay-L1512_Check2)+levelCheckRAM) + ld hl,$d0ce + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + call ((.animateDelay-L1512_Check2)+levelCheckRAM) + ld hl,$d0d1 + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + ld hl,$d12e + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + call ((.animateDelay-L1512_Check2)+levelCheckRAM) + + ld hl,$d0d4 + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + ld hl,$d131 + call ((.explodeGenerator-L1512_Check2)+levelCheckRAM) + call ((.animateDelay-L1512_Check2)+levelCheckRAM) + + ld a,EXIT_U + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,$0612 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + + ld a,EXIT_U + call YankRemotePlayer + + ld a,1 + ld [timeToChangeLevel],a + + ret + +.explodeGenerator + xor a + ld [bulletColor],a + ld bc,$0303 + ld de,$1407 + push hl + call CreateBigExplosion + ld hl,bigExplosionSound + call PlaySound + ld a,15 + ldio [jiggleDuration],a + pop hl + + ;remove generator from map + ld a,MAPBANK + ldio [$ff70],a + ld d,0 + ld a,[mapPitch] + ld e,a + xor a + ld [hl+],a + ld [hl+],a + ld [hl],a + add hl,de + ld [hl-],a + ld [hl-],a + ld [hl],a + add hl,de + ld [hl+],a + ld [hl+],a + ld [hl],a + ret + +.animateDelay + ld a,30 +.animateDelayLoop + push af + ld a,1 + call Delay + call ((.animateFence-L1512_Check2)+levelCheckRAM) + pop af + dec a + jr nz,.animateDelayLoop + ret + +.animateFence + ldio a,[updateTimer] + rrca + and 3 + ld b,a + ld hl,bgTileMap+VFENCE_INDEX + ld d,VFENCE_INDEX + call ((.animateFourFrames-L1512_Check2)+levelCheckRAM) + ret + +.animateFourFrames + ld c,4 + +.animateFourFrames_loop + ld a,b + add c + and 3 + add d + ld [hl+],a + dec c + jr nz,.animateFourFrames_loop + ret + + +L1512_CheckFinished: +PRINT "1512 Script Sizes (Load/Init/Check) (of $500): " +PRINT (L1512_LoadFinished - L1512_Load2) +PRINT " / " +PRINT (L1512_InitFinished - L1512_Init2) +PRINT " / " +PRINT (L1512_CheckFinished - L1512_Check2) +PRINT "\n" + diff --git a/Source/Macro.inc b/Source/Macro.inc new file mode 100644 index 0000000..c22c60b --- /dev/null +++ b/Source/Macro.inc @@ -0,0 +1,157 @@ +;PADNOCARRY: MACRO + ;;if low byte of addr is > max addr for space required + ;;add pad bytes to bring low byte to 0 + ;IF ((\1 & $ff) > ((-\2) & $ff)) + ;DS ((-\1) & $ff) + ;ENDC +;ENDM + +SETDIALOGSKIP: MACRO + ld de,\1 + call SetDialogSkip +ENDM + +PREPLONGCALL: MACRO + ld hl,\1 + push hl ;push return addr + ldio a,[curROMBank] ;push current ROM bank + push af +ENDM + +LONGCALL: MACRO + add sp,-4 ;leave a blank spot + push af ;save parameter af + push de ;save parameter de + ld a,BANK(\1) + ld de,\1 + jp LongCall +ENDM + +LONGCALLNOARGS: MACRO + ld a,BANK(\1) + ld hl,\1 + call LongCallNoArgs +ENDM + +DEBUGTITLE: MACRO +IF DEBUG + DB \1 +ENDC +ENDM + +GTX: MACRO + DB $ff,0,0,1,1,STRLEN(\1) +COUNTER = 1 +REPT STRLEN(\1) + DB ((STRSUB(\1,COUNTER,1)+145) & $ff) +COUNTER = COUNTER+1 +ENDR +ENDM + +GTXSTRING: MACRO + DB 0,STRLEN(\1) +COUNTER = 1 +REPT STRLEN(\1) + DB ((STRSUB(\1,COUNTER,1)+145) & $ff) +COUNTER = COUNTER+1 +ENDR +ENDM + +GTXSTRINGC: MACRO + DB ((20-STRLEN(\1))/2),STRLEN(\1) +COUNTER = 1 +REPT STRLEN(\1) + DB ((STRSUB(\1,COUNTER,1)+145) & $ff) +COUNTER = COUNTER+1 +ENDR +ENDM + +ITEMSTRING: MACRO + DB 0,STRLEN(\2)+2,\1,0 +COUNTER = 1 +REPT STRLEN(\2) + DB ((STRSUB(\2,COUNTER,1)+145) & $ff) +COUNTER = COUNTER+1 +ENDR +ENDM + + +LDHL_CURHERODATA: MACRO + ld h,((hero0_data>>8) & $ff) + ld a,[curHeroAddressL] + add \1 + ld l,a +ENDM + +PUSHROM: MACRO + ld a,[curROMBank] + push af +ENDM + +POPROM: MACRO + pop af + call SetActiveROM +ENDM + +VECTORTOSTATE: MACRO + ld hl,\1 + call LCheckGetVectorToState + jp hl +ENDM + +DIALOGTOP: MACRO + ld de,\1 + call ShowDialogAtTopNoWait +ENDM + +DIALOGBOTTOM: MACRO + ld de,\1 + call ShowDialogAtBottomNoWait + +ENDM + +WAITDIALOG: MACRO + ld hl,((\1 << 8) | STATE_WAIT_DIALOG) + call StdWaitDialog +ENDM + +WAITDIALOGNOCLEAR: MACRO + ld hl,((\1 << 8) | STATE_WAIT_DIALOG) + call StdWaitDialogNoClear +ENDM + +STDWAITDIALOG: MACRO + call CheckDialogContinue + or a + ret z + + call RestoreIdle + ld hl,mapState+1 + ld a,[hl-] + ld [hl],a +ENDM + +COLOR: MACRO + DW (((\3>>3)<<10) | ((\2>>3)<<5) | (\1>>3)) +ENDM + +LOAD16HLXX: MACRO + ld a,[hl+] + ld \2,a + ld a,[hl+] + ld \1,a +ENDM + +SAVE16HLXX: MACRO + ld a,\2 + ld [hl+],a + ld a,\1 + ld [hl+],a +ENDM + +STDSETUPDIALOG: MACRO + ld a,BANK(dialog) + ld [dialogBank],a + call SetPressBDialog +ENDM + diff --git a/Source/Main.asm b/Source/Main.asm new file mode 100644 index 0000000..a3de515 --- /dev/null +++ b/Source/Main.asm @@ -0,0 +1,179 @@ +;*************************************************************************** +;* +;* Main.asm - Standard ROM-image header +;* +;* All fields left to zero since RGBFix does a nice job of filling them in +;* in for us... +;* +;*************************************************************************** + + ;INCLUDE "irq.inc" + ;INCLUDE "utility.inc" + ;INCLUDE "hardware.inc" + + SECTION "Startup",ROM0[0] + +RST_00: jp Main8Mhz + DS 5 +RST_08: jp Main + DS 5 +RST_10: jp Main + DS 5 +RST_18: jp Main + DS 5 +RST_20: jp Main + DS 5 +RST_28: jp Main + DS 5 +RST_30: jp Main + DS 5 +RST_38: jp Main + DS 5 + + jp OnVBlank + DS 5 + + ;jp OnHBlank + jp hblankVector + DS 5 + + ;jp irq_Timer + ;DS 5 + reti + DS 7 + + ;jp irq_Serial + ;DS 5 + reti + DS 7 + + ;jp irq_HiLo + ;DS 5 + reti + DS 7 + + DS $100-$68 + + nop + jp Main + + DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D + DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 + DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E + + ;0123456789ABCDEF + DB "FGB ",$c0 + DB 0,0,0 ;SuperGameboy + DB $1b ;CARTTYPE + ;-------- + ;0 - ROM ONLY + ;1 - ROM+MBC1 + ;2 - ROM+MBC1+RAM + ;3 - ROM+MBC1+RAM+BATTERY + ;5 - ROM+MBC2 + ;6 - ROM+MBC2+BATTERY + ;$19 - ROM + MBC5 + ;$19 - ROM + MBC5 + RAM + battery + + DB 0 ;ROMSIZE + ;------- + ;0 - 256 kBit ( 32 kByte, 2 banks) + ;1 - 512 kBit ( 64 kByte, 4 banks) + ;2 - 1 MBit (128 kByte, 8 banks) + ;3 - 2 MBit (256 kByte, 16 banks) + ;3 - 4 MBit (512 kByte, 32 banks) + + DB 0 ;RAMSIZE + ;------- + ;0 - NONE + ;1 - 16 kBit ( 2 kByte, 1 bank ) + ;2 - 64 kBit ( 8 kByte, 1 bank ) + ;3 - 256 kBit (32 kByte, 4 banks) + + DW $0000 ;Manufacturer + + DB 0 ;Version + DB 0 ;Complement check + DW 0 ;Checksum + +; -- +; -- Initialize the Gameboy +; -- + +Main:: + ;@ $150 + ; disable interrupts + di + + ;kick CPU to 8 MHZ + ld a,$30 + ld [$ff00],a + ld a,1 + ld [$ff4d],a + stop + +Main8Mhz: + ; we want a stack + di + ld hl,StackTop + ld sp,hl + + ; no interrupts to begin with + xor a + ldio [$ff0f],a ;interrupt flags + ldio [$ffff],a ;interrupt control + ei ;enable interrupts + + jp UserMain ;in home memory + +;--------------------------------------------------------------------- +SECTION "HomeTableSection",ROM0[$170] +;--------------------------------------------------------------------- +;$170 +encodeControlByteTable:: + DB %01000000 ;buttons 0000 of (start,select,b,a) + DB %00010000 ;buttons 0001 if b or a or none then -> 00ba + DB %00100000 ;buttons 0010 else -> 01te (t=start, e=select) + DB %00110000 ;buttons 0011 + DB %01010000 ;buttons 0100 if final result=0 set it to be + DB %00010000 ;buttons 0101 %01000000 (same diff) to avoid + DB %00100000 ;buttons 0110 sending the byte $00 which takes + DB %00110000 ;buttons 0111 two cycles instead of 1 + DB %01100000 ;buttons 1000 + DB %00010000 ;buttons 1001 + DB %00100000 ;buttons 1010 + DB %00110000 ;buttons 1011 + DB %01110000 ;buttons 1100 + DB %00010000 ;buttons 1101 + DB %00100000 ;buttons 1110 + DB %00110000 ;buttons 1111 + +;$180 +decodeControlByteTable:: + DB %00000000 ;coded 0000 + DB %00010000 ;coded 0001 + DB %00100000 ;coded 0010 + DB %00110000 ;coded 0011 + DB %00000000 ;coded 0100 + DB %01000000 ;coded 0101 + DB %10000000 ;coded 0110 + DB %11000000 ;coded 0111 + DB %00000000 ;coded 1000 N/A + DB %00000000 ;coded 1001 N/A + DB %00000000 ;coded 1010 N/A + DB %00000000 ;coded 1011 N/A + DB %00000000 ;coded 1100 N/A + DB %00000000 ;coded 1101 N/A + DB %00000000 ;coded 1110 N/A + DB %00000000 ;coded 1111 N/A + +;$190 + +; -- +; -- Variables +; -- + + SECTION "StartupVars",WRAM0[$CF00] + +Stack: DS $100 +StackTop: diff --git a/Source/Map.asm b/Source/Map.asm new file mode 100644 index 0000000..9611d17 --- /dev/null +++ b/Source/Map.asm @@ -0,0 +1,4135 @@ +;12.29.1999 + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Levels.inc" + + +;world map + + + + + + + + + + + +;miscellaneous areas + + + + + +SECTION "SysVariables",WRAM0[$c000] +backBuffer:: DS 608 ;32x19; automatically copied to VRAM every vblank + ;NOTE: addr must start on multiple of 16 + ;NOTE: attribute buffer starts 160 bytes later + ;at $c300 + +;0 - $c260 - map attributes & calculation helpers +mapOffsetNorth:: DS 2 ;this memory location + 6 must not +mapOffsetEast:: DS 2 ;have carry +mapOffsetSouth:: DS 2 +mapOffsetWest:: DS 2 + +;8 +mapWidth:: DS 1 ;8 $c268 +mapPitch:: DS 1 ;9 $c269 +mapPitchMinusOne:: DS 1 ;10 $c26a +mapPitchMinusOneComplement :: DS 1 ;11 $c26b +mapSkip:: DS 1 ;difference between width and pitch +mapHeight:: DS 1 ;13 $c26d +mapColor: DS 2 ;14 $c26e +firstHero:: DS 1 ;16 $c270 class index of first hero +numBGTiles: DS 1 ;17 $c271 +bgDestPtr: DS 2 ;18 $c272 +numFGTiles:: DS 1 ;20 $c274 +numFGTiles_save: DS 1 ;addr by offset in SaveFGTileInfo +numClasses:: DS 1 ;22 $ c276 +numClasses_save: DS 1 ; $c277 +fgDestPtr:: DS 2 ;ref by offset in SaveFGTileInfo +fgDestPtr_save: DS 2 ;for use in SaveFGTileInfo +loadTileL: DS 1 ; $c27c +loadTileH: DS 1 ; $c27d + +;30 +mapLeft:: DS 1 ; $c27e +mapRight:: DS 1 ; $c27f +mapRightPlusOne:: DS 1 ; $c280 +mapTop:: DS 1 ; $c281 +mapBottom:: DS 1 ; $c282 +mapBottomPlusOne:: DS 1 ; $c283 +mapMaxLeft:: DS 1 ; $c284 +mapMaxTop:: DS 1 ; $c285 +camera_i:: DS 1 ; $c286 +camera_j:: DS 1 ; $c287 +distToWall_N:: DS 1 ; $c288 +distToWall_E:: DS 1 ; $c289 +distToWall_S:: DS 1 ; $c28a +distToWall_W:: DS 1 ; $c28b + +;44 +mapTotalSize:: DS 2 ;location 1 beyond end, e.g. $dc00 ($c28c) +mapExitLinks:: DS 16 ; $c28e + +desiredMapLeft:: DS 1 ; $c29e +desiredMapTop:: DS 1 ; $c29f +curPixelOffset_x:: DS 1 ; $c2a0 +curPixelOffset_y:: DS 1 ; $c2a1 +desiredPixelOffset_x:: DS 1 ; $c2a2 +desiredPixelOffset_y:: DS 1 ; $c2a3 +scrollAccelState_x:: DS 1 ; $c2a4 +scrollAccelState_y:: DS 1 ; $c2a5 + +mapBank:: DS 2 ; $c2a6 +mapContents:: DS 2 ; $c2a8 +dialogBank:: DS 1 ; $c2aa xlink +curTrackStackL:: DS 1 ; $c2ab for music + +;----routine parameters---------------------------------------------- +;74 +methodParamL:: DS 1 ; $c2ac +methodParamH:: DS 1 ; $c2ad +bulletDirection:: DS 1 ; $c2ae +bulletLocation:: DS 2 ; $c2af +bulletColor:: DS 1 ; $c2b1 +tempL:: DS 1 ; $c2b2 +tempH:: DS 1 ; $c2b3 +delTempL:: DS 1 ; $c2b4 +delTempH:: DS 1 ; $c2b5 + +;84 +moveAlignPrecision:: DS 1 ; $c2b6 +fireBulletDirection:: DS 1 ; $c2b7 +bulletDamage:: +fireBulletDamage:: DS 1 ; $c2b8 +fireBulletSound:: DS 2 ; $c2b9 +fireBulletLocation:: DS 2 ; $c2bb +explosionInitialFrame:: DS 1 ; $c2bd +myGroup:: DS 1 ; $c2be +myFacing:: DS 1 ; $c2bf +secondChoiceDirection:: DS 1 ; $c2c0 + +;95 +fadeSteps:: DS 1 ; $c2c1 +fadeStepsToGo:: DS 1 ; $c2c2 + +dmaLoadSrc0:: DS 2 ; $c2c3 +dmaLoadDest0:: DS 2 ; $c2c5 +dmaLoadLen0:: DS 1 ; $c2c7 +dmaLoadSrc1:: DS 2 ; $c2c8 +dmaLoadDest1:: DS 2 ; $c2ca +dmaLoadLen1:: DS 1 ; $c2cc + +;97 +metaSprite_y:: DS 1 ; $c2cd +metaSprite_x:: DS 1 ; $c2ce +metaSprite_first_x:: DS 1 ; $c2cf + +bgFlags:: DS 1 ;set in some methods to look at later + ;$c2d0 + +;----environment info and control------------------------------------ +;101 +mapDialogClassIndex:: DS 10 ;$c2d1 +mapHeroZone:: DS 1 ;$c2db + +specialFX:: DS 1 ;$c2dc +displayType:: DS 1 ;0 for map, 1 for cinema $c2dd +scrollSprites:: DS 1 ;$c2de +heroesIdle:: DS 1 ;1=idle, 0=active ;$c2df + + +;----class stuff----------------------------------------------------- +;116 +oldZone:: DS 1 ;$c2e0 +firstFreeObj:: DS 1 ;index of first free node $c2e1 +curObjIndex:: DS 1 ;$c2e2 +iterateNext:: DS 2 ;$c2e3 +oamFindPos:: DS 1 ;$c2e5 +numFreeSprites:: DS 1 ;$c2e6 +nextObjIndex:: DS 1 ;$c2e7 +levelCheckStackPos:: DS 2 ;$c2e8 + +;126 +objTimerBase:: DS 1 ;$c2ea +objTimer60ths:: DS 1 ;$c2eb +heroTimerBase:: DS 1 ;$c2ec +heroTimer60ths:: DS 1 ;$c2ed + +;130 +baMoved:: DS 1 ;used in BA check $c2ee +bsMoved:: DS 1 ;used in BS check $c2ef + ;--set above to zero in LinkRemakeList +heroJoyIndex:: DS 1 ;bits 5:0 grenade, lady, captain, + ;haiku, bs, ba $c2f0 + +myJoy:: DS 1 ;$c2f1 +curInput0:: DS 1 ;$c2f2 +curInput1:: DS 1 ;$c2f3 +dialogJoyIndex:: DS 1 ;0 or 1 $c2f4 +getLocInitFacing:: DS 1 ;$c2f5 +losLimit:: DS 1 ;tiles to scan (0=infinite or 1) $c2f6 +dialogSpeakerIndex:: DS 1 ;in ChooseFromDialogAlterates $c2f7 + +levelCheckSkip:: DS 4 ;$c2f8 +jiggleLoc:: DS 1 ;random pos for async jiggle $c2fc +dialogSettings:: DS 1 ;[:0] show border, [:1] show continue + ;[:2] wait release (see defs.h DLG_*) +fadeRange:: DS 1 ;defaults to 64 (all colors) but + ;can be set to 32 (or the like) for + ;BG fades only (is reset to 64 after) +guardAlarm:: DS 1 ;guard sounded the alarm? +;next pos: $c2fe +;160/160 + +blankSpace: +PRINT "blank space 1: " +PRINT (768 - (blankSpace - backBuffer)) +PRINT "\n" + +DS (768 - (blankSpace - backBuffer)) + +attributeBuffer:: DS 608 ;see notes on backBuffer above + +;game state variables $c560 +gameState:: +heroesAvailable:: DS 2 ;$c560 +heroesUsed:: DS 1 ;$c562 +heroesLocked:: DS 1 ;$c563 +appomattoxMapIndex:: DS 1 ;$c564 +respawnMap:: DS 2 ;$c565 ;map to go to after dying +joinMap:: DS 2 ;$c567 ;map to join for 2nd player + +;pad +allIdle:: DS 1 ;$c569 ;no one allowed to move +dialogIdleSettings:: DS 1 ;$c56a +canJoinMap:: DS 1 ;$c56b +checkTemp:: DS 1 ;$c56c + +amLinkMaster:: DS 1 ;$ff=no link/slave, $fe=no link/master + ;1=link/master, 0=link/slave $c56d +lastLinkAction:: DS 1 ;$00=receive, $01=transmit $c56e +checkInputInMainLoop:: DS 1 ;$c56f +amShowingDialog:: DS 1 ;$c570 +amSynchronizing: DS 1 ;$c571 +longCallTempA:: DS 1 ;$c572 +amChangingMap:: DS 1 ;$c573 +curHeroAddressL:: DS 1 ;LCByte of hero address $c574 +heroesPresent:: DS 1 ;%000000ba, b=hero1, a=hero0 $c575 + +curLevelIndex:: DS 2 ;in BCD $c576 +curLevelStateIndex:: DS 1 ;0-255 $c578 +timeToChangeLevel:: DS 1 ;$c579 + +musicOverride1:: DS 1 ;$c57a +musicOverride4:: DS 1 ;$c57b + +linkBailOut:: DS 4 ;$c57c + +fadeCurPalette:: DS 128 ;$c580 +;128 + +bgTileMap:: DS 256 ;$c600 +bgAttributes:: DS 256 ;$c700 + +;$c800-$c81f hero data +hero0_data:: +curJoy0:: DS 1 ;NOTE: MSByte of address should not +hero0_index:: DS 1 ;change between here and the end of +hero0_object:: DS 2 ;the hero stuff +hero0_bullet_index:: DS 1 +hero0_class:: DS 2 +hero0_enterLevelFacing:: DS 1 ;misnomer, actually exit direction +hero0_enterLevelLocation:: DS 2 +hero0_i:: DS 1 +hero0_j:: DS 1 +hero0_type:: DS 1 ;HERO_BA_FLAG etc +hero0_health:: DS 1 +hero0_moved:: DS 1 +hero0_puffCount:: DS 1 +;NOTE change HERODATASIZE if adding more than 16 vars here + +;$c810 +hero1_data:: +curJoy1:: DS 1 +hero1_index:: DS 1 +hero1_object:: DS 2 +hero1_bullet_index:: DS 1 ;See NOTE above +hero1_class:: DS 2 ;e.g. 1030 = BA +hero1_enterLevelFacing:: DS 1 ;misnomer, actually exit direction +hero1_enterLevelLocation:: DS 2 +hero1_i:: DS 1 +hero1_j:: DS 1 +hero1_type:: DS 1 ;HERO_BA_FLAG etc +hero1_health:: DS 1 +hero1_moved:: DS 1 +hero1_puffCount:: DS 1 +;NOTE change HERODATASIZE if adding more than 16 vars here + +;$c820 variables for level check in RAM +levelVars:: DS 64 + +;$c860 music vars +musicBank:: DS 1 ;c860 +musicNoteCountdownInit:: DS 1 ;c861 +musicNoteCountdown:: DS 1 ;c862 +musicTrack1Pos:: DS 2 ;c863 +musicTrack2Pos:: DS 2 ;c865 +musicTrack3Pos:: DS 2 ;c867 +musicTrack4Pos:: DS 2 ;c869 +musicInstrument1:: DS 5 ;c86b +musicInstrument2:: DS 4 ;c870 +musicInstrument3:: DS 4 ;c874 +musicInstrument4:: DS 4 ;c878 +musicWaveform:: DS 16 ;c87c +musicStackL1:: DS 1 ;c88c +musicStackL2:: DS 1 ;c88d +musicStackL3:: DS 1 ;c88e +musicStackL4:: DS 1 ;c88f +musicRegisters:: DS 16 ;c890 r[15] = flags, :0 = z + +numFreeObjects:: DS 1 ;$c8a0 +fgFlags:: DS 1 ;$c8a1 temp variable, set in GetFGAttributes +lineZeroHorizontalOffset:: DS 1 ;$c8a2 +musicAddress:: DS 2 ;$c8a3-c8a4 +hblankVector:: DS 3 ;c8a5-c8a7 +exitTileIndex:: DS 1 ;c8a8 +bulletClassIndex:: DS 1 ;c8a9 +inventory: DS 16 ;c8aa-c8b9 +dialogNPC_speakerIndex:: DS 1 ;c8ba who's talking +dialogNPC_heroIndex:: DS 1 ;c8bb hero being talked to +dialogBalloonClassIndex:: DS 1 ;c8bc class that has dialog balloons +envEffectType:: DS 1 ;c8bd type of env effect in use +bsUpgrades:: DS 1 ;c8be +baUpgrades:: DS 1 ;c8bf +haikuUpgrades:: DS 1 ;c8c0 +iterateNumObjects:: DS 1 ;c8c1 try to keep frame rate at 30fps (UNUSED, screws synch) +standardFadeColor:: DS 1 ;c8c2 +inLoadMethod:: DS 1 ;c8c3 +loadStackPosL:: DS 1 ;c8c4 +loadStackPosH:: DS 1 ;c8c5 + +;$c8c2 - $c8ff free space + +SECTION "LevelCheckMethodSection",WRAM0[$c900] +levelCheckRAM:: DS $500 ;1.25 k of data + +SECTION "SpriteMemory",WRAM0[$ce00] +spriteOAMBuffer:: DS $A0 ;must start on even $100 + +;In the following definitions note that some of the labels that are defined +;as the same address will be used to store values in different +;memory banks +SECTION "MapAndObjVars",WRAMX[$d000] +map:: +objects:: +headTable:: +tileShadowBuffer:: +attributeShadowBuffer:: +zoneBuffer:: +wayPointList:: + DS 256 ;bank 1, first 256 bytes of map + ;bank 2, start of 256 bytes of linked list head indices + ;bank 3, start of 4k of object storage + ;bank 4, start of 4k of tile shadow buffer + ;bank 5, start of 4k of attribute shadow buffer + ;bank 6, start of 4k of zone info + ;bank 7, start of 512 byte wayPointList + +tailTable:: + DS 256 ;bank 1, bytes 256-512 of map + ;bank 2, indices of objects at tail of list + ;bank 3, bytes 256-512 of object storage + ;bank 7, wayPointList continued + +pathList:: +rainbowColors:: + ;$d200 + DS 256 ;bank 1, bytes 512-1024 of map (512 bytes) + ;bank 2, free + ;bank 3, bytes 512-1024 of object storage (512 bytes) + ;bank 7, start of 1024-byte pathList (512 bytes) + +horizontalOffset:: + DS 144 ;bank 1, bytes 768-1024 of map (256) + ;bank 2, horizontal scroll position for each line (144) + ;bank 3, bytes 768-1024 of object storage (256) + ;bank 7, pathList continued (256) + + DS 112 ;bank 2, free + +objExists:: + ;$d400 + DS 256 ;bank 1, bytes 1024-1535 of map + ;bank 2, 256 bytes validity of object index n + ;bank 3, bytes 1024-1535 of object storage + ;bank 7, pathList continued + +FOFTable:: + ;$d500 + DS 256 ;bank 1, bytes 1024-1279 of map + ;bank 2, Group FOF table + ;bank 3, bytes 1024-1279 of object storage + ;bank 7, pathList continued + +pathMatrix:: + ;$d600 + DS 256 ;bank 1, bytes 1536-1791 of map + ;bank 2, free + ;bank 3, bytes 1536-1791 of object storage + ;bank 7, 256 byte pathMatrix[16][16] + +levelState:: +fgTileMap:: ;bank 1, bytes 1792-2047 of map + ;$d700 + DS 256 ;bank 2, index of first tile for each class + ;bank 3, bytes 1792-2047 of object storage + ;bank 7, 256 byte map state save levelState[256] + +objClassLookup:: +heroState:: ;UNUSED! + ;$d800 + DS 256 ;bank 1, bytes 2048-2303 of map + ;bank 2, 256 byte lookup table for class type + ;bank 3, bytes 2048-2303 of object storage + ;bank 7, 256 byte heroState storage (16 bytes/hero) UNUSED! + +musicStack:: + ;$d900 + DS 256 ;bank 1, bytes 2304-2559 of map + ;bank 2, unused + ;bank 3, bytes 2304-2559 of object storage + ;bank 7, 128 byte stack for music code + +associatedIndex:: +flightCode:: + ;$da00 + DS 256 ;bank 1, bytes 2560-2815 of map + ;bank 2, 256 byte table of associated class indices + ;bank 3, bytes 2560-2815 of object storage + ;bank 7, 1-byte count + 85 3-byte flight codes + +spritesUsed:: + ;$db00 + DS 128 ;bank 1, bytes 2816-3071 of map + ;bank 2, 40-byte lookup (1=sprite used, 0=free) + ;bank 3, bytes 2816-3071 of object storage +fadeFinalPalette:: + DS 128 ;bank 7, 128-byte fade final palette + + +;bgAttributes:: + ;$dc00 + DS 256 ;bank 2, free + +fgAttributes:: + ;$dd00 + DS 256 ;bank 2, tile attributes for FG tiles + ;bank 1, bytes 3328-3583 of map + ;bank 3, bytes 3328-3583 of object storage + +classLookup:: +fadeDelta:: ;bank 1, bytes 3584-4095 of map + ;$de00 + DS 192 ;bank 2, 512 byte table for class info + ;bank 3, bytes 3584-4095 of object storage + ;bank 7, 192 bytes of fade info +fadeError:: + DS 192 ;bank 7, 192 bytes of fade info + +gamePalette:: + ;$df80 + DS 128 ;bank 7, 128 bytes of "true" game palette + + + +SECTION "MapLoader",ROM0 +;--------------------------------------------------------------------- +; Routine: LoadMap +; Arguments: hl - index of map xxyy 0000 - 1515 in BCD +; Alters: af +; Description: Loads specified map +;--------------------------------------------------------------------- +LoadMap:: + push bc + push de + push hl + + push hl + + ;clear out zone & exit memory + ld a,ZONEBANK + ld [$ff70],a + ld hl,$d000 + xor a + ld [displayType],a + + ld c,0 ;256 +.clr1_o ld b,16 ;*16 +.clr1_i ld [hl+],a + dec b + jr nz,.clr1_i + dec c + jr nz,.clr1_o + + pop hl + + call MapCoordsToIndex + ld l,a + ld h,0 + + ;load in the level state for this level + ld a,l + ld [curLevelStateIndex],a + ld a,LEVELSTATEBANK + ld [$ff70],a + push hl + ld h,((levelState>>8) & $ff) + ld a,[hl] + ldio [mapState],a + xor a + ldio [mapState+1],a + pop hl + + ;multiply map index by 4 to find offset into address lookup + sla l ;shift <<= 2 + rl h + sla l + rl h + ld de,MapLookupTable + add hl,de + + ld a,BANK(MapLookupTable) + call SetActiveROM + + ld de,mapBank ;start of 4 bytes of info storage + ld c,4 +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + + xor a + ld [amSynchronizing],a + ld [hero0_index],a + ld [hero1_index],a + ld [heroJoyIndex],a + + ;set up one hero for now, hero 0 if we're master and hero 1 + ;if we're slave. + ld a,[amLinkMaster] + or a + jr z,.setMyHeroAs1 + + ld a,1 + ld [hero0_index],a + ld a,[hero0_type] + ;note joy index remains zero if we're master + jr .afterSetMyHero + +.setMyHeroAs1 + ld hl,heroJoyIndex + ld a,1 + ld [hero1_index],a + ld a,[hero1_type] + or [hl] + ld [hl],a + +.afterSetMyHero + + ;Check if we're linked up to another game + ld a,[amLinkMaster] + bit 7,a + jr z,.amLinked + jp .afterLinkCheck + +.amLinked + ;am linked up. See if I'm trying to join the same map + ;as is already playing on the remote machine. +.checkSameMap + ld a,LGETMAPINDEX + call ExchangeByte + cp LGETMAPINDEX + jr z,.linkMachineChangingMapAlso + call CheckSimultaneousLCC + jr nz,.checkSameMap ;must repeat + jr .compareMapIndex + +.linkMachineChangingMapAlso + ;Proceed if I'm the Link Master, wait and try again + ;if I'm the slave. + ld a,[amLinkMaster] + or a + jr z,.checkSameMapTryAgain + + ;call KillWaitScreen + jp .afterLinkCheck + +.checkSameMapTryAgain + call ShowWaitScreen + + ;kill some time to allow host to do its thing + ld c,10 +.checkSameMapDelay + ld a,LNULL + call ExchangeByte + call HandleRemoteInput + dec c + jr nz,.checkSameMapDelay + jr .checkSameMap + +.compareMapIndex + call ReceiveByte ;next byte will be the map index + cp $ff ;wait code? + jr z,.checkSameMapTryAgain + ld b,a + ;call KillWaitScreen + ld a,[curLevelStateIndex] + cp b + jr z,.isSameMap + jp .afterLinkCheck ;not the same map + +.isSameMap + ;same map; go ahead and synchronize to it +.requestSynchronize + ld a,LSYNCHRONIZE + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.requestSynchronize + + call ReceiveByte ;get the response + cp LSYNCHREADY + jr z,.readyToSynchronize + + ;Not ready. Send a few null control codes to allow the other + ;machine to continue game-play and then try again. + call ShowWaitScreen + +.nullDelay_init + ld c,10 +.nullDelay + ld a,LNULL + call ExchangeByte + call HandleRemoteInput + dec c + jr nz,.nullDelay + ;jr .requestSynchronize + jr .checkSameMap + +.readyToSynchronize + ld hl,BailOutAddress + xor a + call SetLinkBailOutAddress + + call KillWaitScreen + + ;send my desired entry direction so host can evaluate if there's + ;a free spot + ld a,1 ;just a precaution for slave, host MUST do this + ldio [curObjWidthHeight],a + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,[hl] + call TransmitByte + + call ReceiveByte ;go/nogo signal from host + or a + jr nz,.goSignal + + ;nogo + jr .nullDelay_init + +.goSignal + call ReceiveByte + ldio [mapState],a + call ReceiveByte + ldio [mapState+1],a + + call GuestExchangeHeroData + + ld hl,heroJoyIndex + ld a,[hero1_type] + or [hl] + ld [hl],a + + ld a,1 + ld [amSynchronizing],a + +.afterLinkCheck + call KillWaitScreen + + ;Let the map figure out how to load itself. Typically + ;will be just a call to ParseMap, but it could be different + ;to do some cinematic stuff + call ClearBackBuffer + + ld a,LVLOFFSET_LOAD + call CopyMapMethodToRAM + ld a,OBJROM + call SetActiveROM + + ld hl,sp+0 + ld a,l + ld [loadStackPosL],a + ld a,h + ld [loadStackPosH],a + ld a,1 + ld [inLoadMethod],a + + call levelCheckRAM +AfterLoadLevelMethod:: + xor a + ld [inLoadMethod],a + + ld a,[timeToChangeLevel] + or a + jr z,.stillOkay + + ;need to redo (perhaps cinematic) + ;save the map state back where it came from + ;if zero set to one to indicate we've been here + ld a,LEVELSTATEBANK + ld [$ff70],a + ld a,[curLevelStateIndex] + ld l,a + ld h,((levelState>>8) & $ff) + ldio a,[mapState] + or a + jr nz,.stateNotZero + ld a,1 +.stateNotZero + ld [hl],a + jr .done + +.stillOkay + ld a,OBJROM + call SetActiveROM + call AddObjectsToObjList + call InitFOF + + ;Add the heroes to the map. Add Host's hero first. + ld a,[amSynchronizing] + or a + jr z,.addZeroThenOne + + ld a,[amLinkMaster] + or a + jr z,.addZeroThenOne + + ;add one then zero + ld hl,hero0_index + push hl + ld hl,hero1_index + jr .decidedHeroLoadOrder + +.addZeroThenOne + ld hl,hero1_index + push hl + ld hl,hero0_index + +.decidedHeroLoadOrder + call PrepSetupHero + pop hl + call PrepSetupHero + + call PrepareForInitialMapDraw ;adjust camera & calc offsets + + ld a,LVLOFFSET_INIT + call CopyMapMethodToRAM + ld a,OBJROM + call SetActiveROM + call levelCheckRAM + + call ClearBackBuffer + + ld a,LVLOFFSET_CHECK + call CopyMapMethodToRAM + ld a,OBJROM + call SetActiveROM + + ;----continue synchronizing if warranted---------------------- + ld a,[amSynchronizing] + or a + jr z,.afterSynchronization + +.continueSynchronization + LONGCALLNOARGS GuestContinueSynchronization + +.afterSynchronization + xor a + ld [amSynchronizing],a + + ;turn LCD on and stuff + ld a,%11000011 + ld [$ff40], a ;lcdc control + +.done +LoadMapDone: + pop hl + pop de + pop bc + ret + +BailOutAddress: + ld hl,0 + xor a + call SetLinkBailOutAddress + ld a,1 + ld [timeToChangeLevel],a + jr LoadMapDone + +ShowWaitScreen: + ld a,[displayType] ;shown the "waiting" screen yet + or a + ret nz + + ;load the "Waiting To Join" screen + ld a,BANK(waitingToJoin_bg) + ld hl,waitingToJoin_bg + call LoadCinemaBG + ld a,1 + call Delay + + ld a,15 + call SetupFadeFromStandard + call WaitFade + ret + +KillWaitScreen: + ;was I showing the "waiting to join" screen? + ld a,[displayType] + or a + ret z + + push bc + push de + push hl + ld a,15 + call SetupFadeToStandard + call WaitFade + ;call DisplayOff + xor a + ld [displayType],a + pop hl + pop de + pop bc + ret + +.afterRemoveWaitScreen + + +.addHeroToMap +PrepSetupHero:: + ld a,[hl+] ;get hero index + or a + ret z ;hero not present + + ld a,l ;get hero number 0 or 1 +IF HERODATASIZE!=16 + jr fix this +ENDC + and 16 + swap a + ld d,a ;d is 0 or 1 + + inc hl ;skip object L,H + inc hl + inc hl ;skip bullet_index + ld a,[hl+] ;bc = heroClass + ld c,a + ld a,[hl+] + ld b,a + ld a,[hl+] ;enter level direction + push af + ld a,[hl+] ;hl = entry location in XY + ld h,[hl] + ld l,a + pop af ;retrieve entry direction + call SetupHero + ret + +PrepSetupHeroBC:: + ld h,b + ld l,c + jr PrepSetupHero ;ret will return to my caller + +GuestExchangeHeroData: + ;get the host's hero data + ld a,[amLinkMaster] + or a + jr z,.recvHero0_sendHero1 ;slave exchange + +.recvHero1_sendHero0 ;master exchange + ;turn on hero 1 + ld a,1 + ld [hero1_index],a + + ;set hero 1 joy index + ld hl,hero0_data ;send this second + push hl + + ld hl,hero1_data ;recv this first + jr .afterExchangeHeroData + +.recvHero0_sendHero1 + ;turn on hero 0 + ld a,1 + ld [hero0_index],a + + ld hl,hero1_data + push hl + ld hl,hero0_data ;recv dest + +.afterExchangeHeroData + ld bc,HERODATASIZE + xor a + call ReceiveData + + ;send my hero data + pop hl + ld bc,HERODATASIZE + xor a + call TransmitData + + ret + + +;--------------------------------------------------------------------- +; Routine: MapCoordsToIndex +; Arguments: hl - map number in bcd (e.g. 0205) +; Returns: a - converted number (e.g. 82) +; Alters: af +; Description: Returns FromBCD(L) * 16 + FromBCD(H) +;--------------------------------------------------------------------- +MapCoordsToIndex:: + push hl + + ;Change bytes hl from BCD to normal + ld a,h + call BCDToNumber + ld h,a + ld a,l + call BCDToNumber + ld l,a + + ;a = l*16 + h (h & l must be 0-15 for this code) + ld a,l + swap a + add h + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: BCDToNumber +; Arguments: a - a number in BCD (e.g. hex $19 = dec 19) +; Returns: a - converted number +; Alters: af +;--------------------------------------------------------------------- +BCDToNumber: + push bc + push hl + + ;convert back to normal with: + ; a = a[7:4] * 10 + a[3:0] + ld b,a ;save A + swap a + and %00001111 + ld hl,.lookupTimes10 + add l + ld l,a + ld a,0 + adc h + ld h,a + ld a,[hl] ;Upper nibble times 10 + ld c,a + ld a,b + and %00001111 + add c + + pop hl + pop bc + ret + +.lookupTimes10 + DB 0,10,20,30,40,50,60,70,80,90 + +;--------------------------------------------------------------------- +; Routine: NumberToBCD +; Arguments: a - a number (e.g. 19) +; Returns: a - converted number (e.g. $19) +; Alters: af +;--------------------------------------------------------------------- +NumberToBCD:: + ;a[7:4] = num / 10, a[3:0] = num % 10; + push bc + ld b,0 + +.divide10 + cp 10 + jr c,.dividedOut10 + + inc b + sub 10 + jr .divide10 + +.dividedOut10 + swap b + or b + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: LookupInMapContents +; Arguments: a - offset in contents table to look up +; [mapContents] must have been initialized +; Returns: hl - address stored at requested offset +; Alters: af, hl +; Description: Adds the offset to the start of the MapContents and +; returns the 16-bit value stored there +;--------------------------------------------------------------------- +LookupInMapContents: + push de + + ld d,0 + ld e,a + + ld a,[mapBank] + call SetActiveROM + + ld a,[mapContents] + ld l,a + ld a,[mapContents+1] + ld h,a + + add hl,de + ld a,[hl+] + ld h,[hl] + ld l,a + + pop de + ret + +;--------------------------------------------------------------------- +; Routine: SetupMapVarsFromWidthPitchAndHeight +; Arguments: [mapWidth],[mapPitch],[mapHeight] +; Description: Sets up: +; mapMaxLeft +; mapPitchMinusOne +; mapPitchMinusOneComplement +; mapSkip +; mapMaxTop +;--------------------------------------------------------------------- +SetupMapVarsFromWidthPitchAndHeight:: + push bc + + ;Get level dimensions width, pitch, and height + ld a,[mapWidth] + ld c,a + sub 21 + ld [mapMaxLeft],a + ld a,[mapPitch] + push af + dec a + ld [mapPitchMinusOne],a + cpl + ld [mapPitchMinusOneComplement],a + pop af + sub c + ld [mapSkip],a ;skip width calculated fr width & pitch + ld a,[mapHeight] + ld b,a ;height in b + sub 19 + ld [mapMaxTop],a + + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ParseMap +; Arguments: [mapBank]/[mapContents] +; Description: Loads a map +;--------------------------------------------------------------------- +ParseMap:: + ;set bank and ptr to map + ld a,LVLOFFSET_MAP + call LookupInMapContents ;point hl at map + + ld a,[hl+] ;get and discard version number + ld a,[hl+] ;get # of classes + ld [numClasses],a ;store # classes + + ;Clear/initialize memory locations + ;set initial # of bg/fg tiles + ld a,40 ;leave room for 2 sets of 4x4 hero + ld [numFGTiles],a ;tiles (20*2) + ld a,1 + ld [numBGTiles],a + + ;Set up ptrs to bg tile pattern mem and fg tile pattern mem + ld a,$80 + ld [fgDestPtr],a ;fg ptr gets $9280 (low byte) + ld a,$92 ;high byte + ld [fgDestPtr+1],a + ld a,$10 + ld [bgDestPtr],a ;bg ptr gets $9010 (low byte) + ld a,$90 ;high byte + ld [bgDestPtr+1],a + + ;Get index # of first monster + ld a,[hl+] + ldio [firstMonster],a + + ;discard first monster class (2 bytes) + ld a,[hl+] + ld a,[hl+] + + ;Load in class lookup table + ld a,[numClasses] + ld c,a ;set counter at # of classes + ld b,1 ;index currently loading + ;ld de,classLookup+2 ;lookup table to store classes in + +.loop ld a,[hl+] ;load in low byte of class + ld [loadTileL],a + ld a,[hl+] ;repeat with high byte + ld [loadTileH],a + + ;set classLookup[i] to point to addr of class methods + call SetClassLookupEntryForTile + + ;determine whether we're loading a BG tile or a monster tile + ldio a,[firstMonster] + cp b ;is firstMonster <= cur index? + push bc + jr z,.isMonsterTile + jr c,.isMonsterTile + +.isBackgroundTile + ld c,0 ;set c=0 to indicate BG tile + jr .nowLoadTile + +.isMonsterTile + ld c,1 ;set c=1 to indicate FG tile + +.nowLoadTile + call LoadTile + + ;make sure we're back to the map bank + ld a,[mapBank] + call SetActiveROM + + pop bc + inc b ;next class + + ldio a,[firstMonster] ;just loaded last bg tile? + cp b + jr nz,.terminationTest + ld a,[numBGTiles] ;already copied the remaining buffer? + and 31 + call nz,CopyBGWorkToVRAM ;not yet + +.terminationTest + dec c ;one less to go + jr nz,.loop + + ;current value of numClasses will be value of firstHero + ld a,[numClasses] + ld [firstHero],a + + ;final value of numClasses (past 2 heroes+bullets) + add 4 + ld [numClasses],a + + ;Get level dimensions width, pitch, and height + ld a,[hl+] ;width + ld [mapWidth],a + ld a,[hl+] ;pitch + ld [mapPitch],a + ld a,[hl+] ;height + ld [mapHeight],a + ld b,a ;height in b + call SetupMapVarsFromWidthPitchAndHeight + + ;Get width*height class indices + ld a,MAPBANK ;switch to map RAM bank + ld [$ff00+$70],a + ld d,h ;Switch to using de for retrieval + ld e,l + ld hl,map ;and hl for storage + + +.outer0 + ld a,[mapWidth] ;width in c + ld c,a + + ;Load a row into memory +.inner0 ld a,[de] ;get a tile class index + inc de + ld [hl+],a ;store it in RAM + + dec c + jr nz,.inner0 + + ;load excess with zero to make internal map power of two wide + ld a,[mapSkip] + or a + jr z,.afterFillExtra + ld c,a + xor a +.fillExtra + ld [hl+],a + dec c + jr nz,.fillExtra + +.afterFillExtra + dec b + jr nz,.outer0 + + ;hl contains location 1 beyond end of map + ld a,l + ld [mapTotalSize],a + ld a,h + ld [mapTotalSize+1],a + + ;Load background color + ld a,[de] ;bg color low byte + inc de + ld [mapColor],a + ld l,a + ld a,[de] ;bg color high byte + inc de + ld [mapColor+1],a + ld h,a + ld b,%10000000 + push de + ld d,h + ld e,l + call SetupCommonColor + pop de + + call ParseWayPointStuff + call ParseZones + call ParseExits + call SetBGSpecialFlags + + ld b,255 + ld hl,classExplosion + call SetClassLookupEntry + + ret + +;--------------------------------------------------------------------- +; Routine: ClearBackBuffer +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Clears the backBuffer and attributeBuffer so that +; horizontal offsets don't show any garbage +;--------------------------------------------------------------------- +ClearBackBuffer:: + push bc + push de + push hl + + ld bc,608 + ld d,0 + ld hl,backBuffer + xor a + call MemSet + + ld bc,608 + ld d,0 + ld hl,attributeBuffer + xor a + call MemSet + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetClassLookupEntryForTile +; Arguments: [loadTileL/H] - tile index being loaded +; b - index in classLookup to load into +; Alters: +; Description: +;--------------------------------------------------------------------- +SetClassLookupEntryForTile: + push bc + push de + push hl + + ld a,OBJLISTBANK + ld [$ff70],a + + ;set de to point to classLookup[b] (times two) + ld d,0 + ld e,b + sla e + rl d + ld hl,classLookup + add hl,de + ld d,h + ld e,l + + ld a,[loadTileH] + ld h,a + ld a,[loadTileL] + ld l,a + + sla l + rl h ;hl *= 2 + ld bc,classTable + add hl,bc + + ld a,BANK(classTable) + call SetActiveROM + ld a,[hl+] ;low byte of addr of class methods + ld [de],a + inc de + ld a,[hl+] ;high byte + ld [de],a + ld a,OBJROM + call SetActiveROM + ;inc de + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetClassLookupEntry +; Arguments: b - index in classLookup to set +; hl - ptr to class +; Alters: +; Description: +;--------------------------------------------------------------------- +SetClassLookupEntry: + push bc + push de + + ld a,OBJLISTBANK + ld [$ff70],a + + ;set de to point to classLookup[b] (times two) + push hl + ld d,0 + ld e,b + sla e + rl d + ld hl,classLookup + add hl,de + ld d,h + ld e,l + pop hl + + ld a,l ;low byte of addr of class methods + ld [de],a + inc de + ld a,h ;high byte + ld [de],a + + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ParseZones +; Arguments: hl - pointer to start of zone data +; Alters: all registers +; Description: loads in zone attributes (parallel buffer to map) +; Stored using 2:1 backed bytes and run-length encoding +;--------------------------------------------------------------------- +ParseZones: + ld a,ZONEBANK ;switch in RAM bank for zones + ld [$ff00+$70],a + + ld hl,zoneBuffer ;dest + + call .getNextRLEData + + ;loop as usual + ld a,[mapHeight] ;# of rows + ld b,a + +.outer ld a,[mapWidth] ;# of columns + ld c,a + srl c ;divide by two + + ;save two bytes for each count +.inner ld a,[loadTileL] ;what's our RLE count look like? + or a + jr nz,.continue + + push bc + call .getNextRLEData + pop bc + +.continue + ld a,[tempH] + ld [hl+],a + ld a,[tempL] + ld [hl+],a + + ld a,[loadTileL] ;decrement RLE count + dec a + ld [loadTileL],a + ;jr nz,.continue + + ;push bc + ;call .getNextRLEData + ;pop bc + +;.continue + + dec c + jr nz,.inner + + ;reached the end of a row, advance destptr to next row + push bc + xor a + ld b,a + ld a,[mapSkip] + ld c,a + add hl,bc + pop bc + + dec b + jr nz,.outer + + ret + +.getNextRLEData + ld a,[de] ;read in a run length + inc de + ld [loadTileL],a ;store remaining # of bytes + ld a,[de] ;read in run data + inc de + ld b,a + swap a + and $f ;zone for first byte + ld [tempH],a + ld a,b + and $f + ld [tempL],a ;zone for second byte + ret + + +;--------------------------------------------------------------------- +; Routine: ParseExits +; Arguments: hl - pointer to start of exit data +; Alters: all registers +; Description: loads in exit attributes (parallel buffer to map) +; Stored using 2:1 backed bytes and run-length encoding +;--------------------------------------------------------------------- +ParseExits: + ld a,ZONEBANK ;switch in RAM bank for zones + ld [$ff00+$70],a + + ld hl,zoneBuffer ;dest + + call .getNextRLEData + + ;loop as usual + ld a,[mapHeight] ;# of rows + ld b,a + +.outer ld a,[mapWidth] ;# of columns + ld c,a + srl c ;divide by two + + ;save two bytes for each count +.inner ld a,[loadTileL] ;what's our RLE count look like? + or a + jr nz,.continue + + push bc + call .getNextRLEData + pop bc + +.continue + ld a,[tempH] + or [hl] + ld [hl+],a ;exit in 7:4, zone in 3:0 + ld a,[tempL] + or [hl] + ld [hl+],a + + ld a,[loadTileL] ;decrement RLE count + dec a + ld [loadTileL],a + + dec c + jr nz,.inner + + ;reached the end of a row, advance destptr to next row + push bc + xor a + ld b,a + ld a,[mapSkip] + ld c,a + add hl,bc + pop bc + + dec b + jr nz,.outer + + ;read in 16 bytes of map links + ld c,16 + ld hl,mapExitLinks +.readLink + ld a,[de] + inc de + ld [hl+],a + dec c + jr nz,.readLink + + ret + +.getNextRLEData + ld a,[de] ;read in a run length + inc de + ld [loadTileL],a ;store remaining # of bytes + ld a,[de] ;read in run data + inc de + ld b,a + and $f0 ;exit for first byte (in 7:4) + ld [tempH],a + ld a,b + swap a + and $f0 + ld [tempL],a ;exit for second byte + ret + +;--------------------------------------------------------------------- +; Routine: SetBGSpecialFlags +; Arguments: none +; Alters: af +; Description: Loops through the loaded map and for each background +; tile with a special flag (WalkOver, ShootOver) sets +; bit 7 of the exit/zone map. +;--------------------------------------------------------------------- +SetBGSpecialFlags:: + push bc + push de + push hl + + ;clear out bit 7 in zone bank + ld a,ZONEBANK + ldio [$ff70],a + + ld hl,$d000 + ld a,$e0 +.clearZone + res 7,[hl] + inc hl + cp h + jr nz,.clearZone + + + ld hl,map + ld de,bgAttributes + + ld a,[mapHeight] + ld b,a + +.outer + push bc + ldio a,[firstMonster] + ld b,a + ld a,[mapPitch] + ld c,a + ld a,MAPBANK + ld [$ff00+$70],a + +.inner + ld a,[hl] ;get a tile + or a + jr z,.notSpecial + cp b + jr nc,.notSpecial + + ;might be a Special tile + ld e,a ;look up its BG attributes + ld a,TILEINDEXBANK + ld [$ff00+$70],a + ld a,[de] + and BG_FLAG_SPECIAL + jr z,.notSpecialResetRAMBank + + ;is Special type + ld a,ZONEBANK + ld [$ff00+$70],a + + set 7,[hl] + +.notSpecialResetRAMBank + ld a,MAPBANK + ld [$ff00+$70],a + +.notSpecial + inc hl + dec c + jr nz,.inner + + pop bc + dec b + jr nz,.outer + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ResetMyBGSpecialFlags +; Arguments: hl - map location +; Alters: af +; Description: If this background tile has any special flags then +; bit 7 of the exit/zone map is set. +;--------------------------------------------------------------------- +ResetMyBGSpecialFlags:: + push bc + push de + + ldio a,[firstMonster] + ld b,a + + ld a,MAPBANK + ldio [$ff70],a + + ld a,[hl] ;get a tile + or a + jr z,.notSpecial + cp b + jr c,.maybeSpecial + +.isMonster + ;get tile under monster + ld a,TILESHADOWBANK + ld [$ff70],a + or a + jr z,.notSpecial + +.maybeSpecial + ;might be a Special tile + ld d,((bgAttributes>>8)&$ff) + ld e,a ;look up its BG attributes + ld a,TILEINDEXBANK + ld [$ff70],a + ld a,[de] + and BG_FLAG_SPECIAL + jr z,.notSpecial + + ;is Special type + ld a,ZONEBANK + ld [$ff00+$70],a + + set 7,[hl] + jr .done + +.notSpecial + ld a,ZONEBANK + ld [$ff70],a + res 7,[hl] + +.done + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: ParseWayPointStuff +; Arguments: hl - pointer to start of stored way point stuff +; Alters: all registers +;--------------------------------------------------------------------- +ParseWayPointStuff: + ld a,WAYPOINTBANK ;switch in waypoint RAM bank + ld [$ff00+$70],a + + ;zero out waypoint list + push hl + ld c,0 + xor a + ld hl,wayPointList +.zeroWayPoints + ld [hl+],a + ld [hl+],a + dec c + jr nz,.zeroWayPoints + pop hl + + ;512-byte wayPoint list (location*[256]) + ld a,[de] ;number of waypoints + inc de + ld [wayPointList],a + or a + jr nz,.continue + + ret ;no waypoints, no nothing + +.continue + ld c,a ;c is number of waypoints + ld a,[de] ;pad, discard + inc de + ld hl,wayPointList+2 ;&wayPointList[1] + +.wpLoad ld a,[de] ;copy high/low byte of waypoint + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + + dec c + jr nz,.wpLoad + + ;load paths + ld a,[de] ;num paths + inc de + ld [pathList],a + or a + jr z,.afterPaths + + ld c,a + ld hl,pathList+4 ;&pathList[1][0] + +.pathLoad + ld a,[de] ;each path has 4 waypoint indices + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + + dec c + jr nz,.pathLoad + +.afterPaths + ;load pathMatrix[16][16] + ld hl,pathMatrix + + ld b,16 + +.outer ld c,16 + +.inner ld a,[de] + inc de + ld [hl+],a + + dec c + jr nz,.inner + + dec b + jr nz,.outer + + ret + + +;--------------------------------------------------------------------- +; Routine: LoadTile +; Arguments: [loadTileL/H] - tile number +; b - index of class being loaded (0-255) +; c - 0=bg tile, 1=fg tile +; Description: Switches in the ROM bank containing the tile to be +; loaded, sets a ptr to the source address, and calls +; LoadBGTile or LoadFGTile appropriately +;--------------------------------------------------------------------- +LoadTile: + push af + push bc + push de + push hl + + ;figure out which bank the tile is in + ld a,[loadTileL] + ld l,a + ld a,[loadTileH] + ld h,a + cp $08 ;bg if tile # less than 2048 ($800)? + jr c,.bgTileSet + + ;fg tile set + ld a,BANK(FGTiles) ;Swap in the right bank + call SetActiveROM + ld de,FGTiles + ld a,h + sub $08 ;minus 2048 (fg tiles new bank) + ld h,a + + jp .loadTile + +.bgTileSet + cp $04 ;first or second bank? + jr c,.bgSet1 + +.bgSet2 + sub $04 + ld h,a + ld a,BANK(BGTiles1024) + ld de,BGTiles1024 + jr .gotBank + +.bgSet1 + ld a,BANK(BGTiles) ;Swap in the right bank + ld de,BGTiles + +.gotBank + call SetActiveROM + +.loadTile + ;Convert hl into a src address offset (hl<<=4) and add base addr de + ld a,h + sla l + rla + sla l + rla + sla l + rla + sla l + rla + ld h,a + add hl,de + + ;BG or FG class? + ld a,c + or a + jr nz,.fgTile + +.bgTile + call LoadBGTile + jr .done + +.fgTile + call LoadFGTile + +.done + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: LoadBGTile +; Arguments: b - index of class being loaded +; hl - src ptr to tile ROM +; Note: [bgDestPtr] - assumed to point to destination in VRAM +; tile bank 0 +; [numBGTiles] - index of tile in tile bank 0 +; Description: Loads in a tile to tile bank 0 at the given address. +; bgTileMap[index] is set to numBGTiles-1 +;--------------------------------------------------------------------- +LoadBGTile: + push af + push bc + push de + push hl + + ld a,TILEINDEXBANK ;select RAM bank of tile index maps + ld [$ff70],a + ld de,bgTileMap ;setup de with &bgTileMap[classIndex] + ld e,b ;b is class index + + ;set the attributes byte for this BG tile + PUSHROM + ld a,BANK(bg_colorTable) + call SetActiveROM + push de + push hl + push de + ld a,[loadTileL] + ld e,a + ld a,[loadTileH] + ld d,a + ld hl,bg_colorTable + add hl,de + pop de + ld d,((bgAttributes>>8)&$ff) + ld a,[hl] + ld [de],a + pop hl + pop de + POPROM + + ;Increment number of BG tiles counter + ld a,[numBGTiles] + ld [de],a ;cur tile index into bgTileMap[classIndex] + inc a + ld [numBGTiles],a + + ;Load in 16 bytes to the work buffer ($c000 + (bgDestPtr&511)) + ;(32 * 16 = 511) + ld a,[bgDestPtr] + ld e,a + ld a,[bgDestPtr+1] + ld d,a + push de + and 1 + add $c0 + ld d,a + + ld c,16 +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + + pop de + call AddDE16 + + ;copy the work buffer to VRAM if numBGTiles is a multiple of 32 + ld a,[numBGTiles] + and 31 + call z,CopyBGWorkToVRAM + +IF 0 + ;Load in 16 bytes + ld a,0 + ld [$ff00+$4f],a ;load into bank 0 + ld a,[bgDestPtr] ;set de=destPtr + ld e,a + ld a,[bgDestPtr+1] + ld d,a + ld c,16 ;# of bytes to load + +.loop ld a,[hl+] + ld [de],a + inc de + + dec c + jr nz,.loop +ENDC + + ;store modified destptr + ld a,e + ld [bgDestPtr],a + ld a,d + cp $98 + jr c,.checkedNegative + sub $10 +.checkedNegative + ld [bgDestPtr+1],a + +.done + pop hl + pop de + pop bc + pop af + ret + +CopyBGWorkToVRAM: + push bc + push de + push hl + + ;set destptr to be bgDestPtr & (~511) + ld e,0 + ld a,[bgDestPtr+1] + and $fe + ld d,a + + ;if bgDestPtr is $9000 (1st tile) set $c000-$c00f to black + ;for the blank tile + ld a,e + or a + jr nz,.afterCopyBlank + ld a,d + cp $90 + jr nz,.afterCopyBlank + ld c,16 + ld hl,$c000 + xor a +.setBlankLoop + ld [hl+],a + dec c + jr nz,.setBlankLoop + +.afterCopyBlank + ld a,[numBGTiles] + dec a + and 31 + inc a + ld c,a + xor a + ld hl,$c000 + call VMemCopy + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: LoadFGTile +; Arguments: b - index of class being loaded +; hl - src ptr to tile ROM +; Note: [fgDestPtr] - assumed to point to destination in VRAM +; tile bank 1 +; [numFGTiles] - index of tile in tile bank 1 +; Description: Loads in a tile to tile bank 0 at the given address. +; fgTileMap[index] is set to numFGTiles-1 +; Duplicates any tiles loaded into $9000-$9800 into +; $8000-$8800 for tile<->sprite conversion purposes +;--------------------------------------------------------------------- +LoadFGTile: + push af + push bc + push de + push hl + + ld a,TILEINDEXBANK ;select RAM bank of tile index maps + ld [$ff00+$70],a + ld de,fgTileMap ;setup de with &fgTileMap[classIndex] + ld e,b ;b is class index + + ;set the attributes byte for this FG tile + push de + push hl + push de + ld a,[loadTileL] + ld e,a + ld a,[loadTileH] + and $03 + ld d,a + ld hl,fg_colorTable + add hl,de + pop de + ld d,((fgAttributes>>8)&$ff) + ld a,[hl] + ld [de],a + ld b,a ;save the attributes byte in b + ldio [curObjWidthHeight],a + pop hl + pop de + + ;Place tile index in fgTileMap + ld a,[numFGTiles] + ld [de],a ;cur tile index into fgTileMap[classIndex] + push af + + ;load in 2 tiles for a FG object + ;b has bit 5 set for 2x2 or cleared for 1x1; + ;manipulate b to have either 8 for 2x2 or 2 for 1x1. + bit 5,b + jr nz,.load8Tiles + ld b,2 + jr .setNumTilesToLoad +.load8Tiles + ld b,8 +.setNumTilesToLoad + ld de,$c000 ;load to work buffer + +.nextTile + ;Increment number of FG tiles counter + ld a,[numFGTiles] + inc a + ld [numFGTiles],a + + ;Load in 16 bytes + ld c,16 +.nextByte + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.nextByte + + dec b + jr nz,.nextTile + + ;retrieve index of first tile to generate facings with + pop af ;retrieve index of first tile + call GenerateFacings ;expand 2 tiles into 6 tiles + + ;Increment number of FG tiles counter to account for the new + ;tiles added in Generate Facings (4 for 1x1 or 12 for 2x2) + ldio a,[curObjWidthHeight] ;xxFxxxxx + rrca ;xxxFxxxx + rrca ;xxxxFxxx + and %00001000 ;0000F000 + or %00000100 ;0000F100 4 or 12 + ld b,a + ld a,[numFGTiles] + add b + ld [numFGTiles],a + + ;store modified destptr (plus n*16 extra tiles) + ld a,[fgDestPtr] + ld e,a + ld a,[fgDestPtr+1] + ld d,a + ld h,0 + ld l,b ;num extra tiles + swap l ;*16 + add hl,de + ld a,l + ld [fgDestPtr],a + ld a,h + cp a,$98 + jr c,.doneCheckNegative + + sub $10 +.doneCheckNegative + ld [fgDestPtr+1],a + +.done + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: LoadAssociatedClass +; Arguments: a - check if it exists already (1=yes, 0=no) +; c - class index of calling class method +; de - class ptr for new class (vector table address) +; hl - tile index of class to load +; Alters: af +; Description: Loads in the specified class IF NOT ALREADY PRESENT +; and regardless puts its index in the "associated" +; array of the calling class. +;--------------------------------------------------------------------- +LoadAssociatedClass:: + push bc + push hl + + or a + jr z,.notFound ;don't look for it + + push bc + ld b,d + ld c,e + call FindClassIndex + pop bc + or a + jr z,.notFound + +.foundMatch + ld b,a + jr .setAssociated + +.notFound + + ;------------------------------------------------------------- + ;Didn't find it; go ahead and load it into the next available + ;slot + ;------------------------------------------------------------- + ld a,l + ld [loadTileL],a + ld a,h + ld [loadTileH],a + + ld a,[numClasses] + inc a + ld [numClasses],a + ld b,a + + ld a,OBJLISTBANK + ld [$ff70],a + + ;----------Set classLookup to point to vector table---------- + ;set hl to point to classLookup[b] (times two) + push de + ld h,0 + ld l,b + sla l + rl h + ld de,classLookup + add hl,de + pop de + ld [hl],e + inc hl + ld [hl],d + + ;-----------Load in the tile-------------------------------- + push bc + ld c,1 ;loading fg tile + call LoadTile + pop bc + + ld a,OBJROM + call SetActiveROM + +.setAssociated + ;------------------------------------------------------------- + ;Expecting calling class index in c, new class index in b + ;------------------------------------------------------------- + call SetAssociated + pop hl + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: SaveFGTileInfo +; Arguments: None. +; Alters: af +; Description: Saves [numClasses], [fgDestPtr], and [numFGTiles] into +; temporary variables. +;--------------------------------------------------------------------- +SaveFGTileInfo:: + push de + push hl + + ld hl,numFGTiles + ld a,[hl+] ;get numFGTiles + ld [hl+],a ;put numFGTiles_save + ld a,[hl+] ;get numClasses + ld [hl+],a ;put numClasses_save + ld a,[hl+] ;get fgTilePtrL + ld e,a + ld a,[hl+] ;get fgTilePtrH + ld d,a + ld a,e + ld [hl+],a ;put fgTilePtrL + ld [hl],d ;put fgTilePtrH + + pop hl + pop de + ret + + +;--------------------------------------------------------------------- +; Routine: RestoreFGTileInfo +; Arguments: None. +; Alters: af +; Description: Restores [numClasses], [fgDestPtr] and [numFGTiles] +; from temp vars. +;--------------------------------------------------------------------- +RestoreFGTileInfo:: + push de + push hl + + ld hl,fgDestPtr_save+1 + ld a,[hl-] ;get fgDestPtrH + ld d,a + ld a,[hl-] ;get fgDestPtrL + ld e,a + ld a,d + ld [hl-],a ;put fgDestPtrH + ld a,e + ld [hl-],a ;put fgDestPtrL + ld a,[hl-] ;get numClasses + ld [hl-],a ;put numClasses + ld a,[hl-] ;get numFGTiles + ld [hl],a ;put numFGTiles + + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: SetupHero +; Arguments: a - type of exit to place hero at: +; 1=N, 2=E, 3=S, 4=W, 5=U, 6=D, 7=X +; bc - tile index of hero class to load +; d - hero number (0 or 1) +; hl - suggested location to start searching for exit +; in XY format. +; Alters: af +; Description: Loads in the hero tile & class +; Sets up [heroX_index], [heroX_class], [heroX_object] +; Sets heroes health to be [heroX_health] unless that's +; zero then it leaves it as initialized. +; Sets heroes puffCount from [heroX_puffCount] +;--------------------------------------------------------------------- +SetupHero:: + push bc + push de + push hl + + ld e,a ;save exit type for a bit + + ;save tile to load into method parameters + ld a,c + ld [loadTileL],a + ld a,b + ld [loadTileH],a + + ;pick one of two reserved tile sets to load hero into + call SaveFGTileInfo + ld a,d ;hero number + or a + jr nz,.loadHero1 + + ld a,[firstHero] + ld [numClasses],a + xor a + ld bc,$9000 + jr .decidedOnTileSet + +.loadHero1 + ld a,[firstHero] + add 2 + ld [numClasses],a + ld a,20 + ld bc,$9140 +.decidedOnTileSet + ld [numFGTiles],a + ld a,c + ld [fgDestPtr],a + ld a,b + ld [fgDestPtr+1],a + ld a,1 + ldio [curObjWidthHeight],a + +.setupBC_heroX_index + ;setup bc with addr of hero0_index or hero1_index + ld bc,hero0_index + ld a,d ;want hero 0 or 1? + or a + jr nz,.wantHero1 + +.wantHero0 + ld a,[hero0_type] + cp HERO_GRENADE_FLAG + jr nz,.hero0_afterSetWH + + ld a,2 + ldio [curObjWidthHeight],a + +.hero0_afterSetWH + ld a,[heroesPresent] + or %01 + jr .heroDataPtrOkay + +.wantHero1 + ld a,[hero1_type] + cp HERO_GRENADE_FLAG + jr nz,.hero1_afterSetWH + + ld a,2 + ldio [curObjWidthHeight],a + +.hero1_afterSetWH + ld a,[heroesPresent] + or %10 + ld c,(hero1_index & $ff) + +.heroDataPtrOkay + ld [heroesPresent],a + + ld a,e ;retrieve desired exit + push bc ;save &heroX_index + + call FindExitLocation ;returns exit loc in hl + push hl ;save it for later + + ld h,b + ld l,c + ld a,[numClasses] + inc a + ld [numClasses],a + ld b,a + ld [hl+],a ;store class index in heroX_index + inc hl ;hl = &heroX_classL + inc hl + inc hl + push af ;save the hero class index + + call SetClassLookupEntryForTile + + ld c,1 ;loading fg tile + call LoadTile + + ld a,OBJROM + call SetActiveROM + + pop af ;retrieve hero class index + ld c,a + pop hl ;starting location + call CreateObject ;returns objPtr in de + + pop hl ;retrieve &heroX_index + inc hl ;hl = &heroX_objectL + ld [hl],e + inc hl + ld [hl],d + + call RestoreFGTileInfo + + ld b,METHOD_INIT + call CallMethod + + ;face opposite direction coming in + call GetFacing + and %11111000 + ld b,a + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,[hl] + cp EXIT_U + jr c,.cardinal + + ;we're coming in up, down, or X; let's just face east + ld a,DIR_EAST + jr .gotDir + +.cardinal + add 1 + and %11 +.gotDir + or b + call SetFacing + + ;reset health of hero + ;push de + ;ld a,l + ;and (255 - (HERODATASIZE-1)) ;set back to heroX_data + ;ld l,a + ;ld de,HERODATA_HEALTH + ;add hl,de + ;pop de + LDHL_CURHERODATA HERODATA_HEALTH + ld a,[hl] + or a + jr z,.afterInitHealth + + ;push hl + call SetHealth + ;pop hl + + ;reset hero puffs + LDHL_CURHERODATA HERODATA_PUFFCOUNT + ld a,[hl] + and %1111 + call SetPuffCount + + ;inc hl + ;inc hl ;hl = heroX_puffCount + ;ld a,[hl] + ;call SetPuffCount + +.afterInitHealth + ld b,METHOD_DRAW + call CallMethod + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindExitLocation +; Arguments: a - type of exit to find: +; 1=N, 2=E, 3=S, 4=W, 5=U, 6=D, 7=X +; hl - "suggested" location to start searching for exit +; in XY format. +; [curObjWidthHeight] +; Returns: hl - location of first exit found or $0000 +; Alters: af +; Description: First adjusts suggested location to be opposite side +; if NESW and restricts it to map bounds. +; +; Searches forward through the map beginning at hl and +; stopping on an exit of the specified type. +; +; If there are no exits found once it reaches the end +; of the map it searches through once more starting at +; the first map cell. If there are STILL no exits found +; it returns location (1,1). +;--------------------------------------------------------------------- +FindExitLocation:: + push bc + push de + + ld b,a ;save exit type + + ;swap sides if exit type is NESW + ld a,b + dec a + and %11111100 + jr nz,.afterSwapExit + + ld a,b + dec a + bit 0,a + jr nz,.east_or_west + + ;north or south + bit 1,a + jr nz,.south + +.north ;looking for north entrance so coming from south, place at top + ld l,1 + jr .afterSwapExit + +.south ;entering south means coming from north, place at bottom + ld a,[mapHeight] + dec a + dec a + ld l,a + jr .afterSwapExit + +.east_or_west + bit 0,a + jr nz,.west + + ;entering east, place at right + ld a,[mapWidth] + dec a + dec a + ld h,a + jr .afterSwapExit + +.west ;entering west, place at left + ld h,1 + +.afterSwapExit + ;make sure x & y are within bounds + ld a,[mapWidth] + cp h ;width > x? + jr z,.xOutOfBounds + jr nc,.xInBounds + +.xOutOfBounds + sub 2 ;x out-of-bounds, set to width-2 + ld h,a + +.xInBounds + ld a,[mapHeight] + cp l + jr z,.yOutOfBounds + jr nc,.yInBounds + +.yOutOfBounds + sub 2 + ld l,a + +.yInBounds + call ConvertXYToLocHL ;location back to ptr + + swap b + ld c,$f0 ;put mask in register for faster ANDing + + ;setup de with first out-of-bounds index + ld a,[mapTotalSize] + ld e,a + ld a,[mapTotalSize+1] + ld d,a + + ld a,ZONEBANK + ld [$ff70],a + +.loop ld a,h + cp d + jr nz,.continue + ld a,l + cp e + jr nz,.continue + + ;reached end of map + jr .didntFind + +.continue + ld a,[hl+] + and c + cp b + jr nz,.loop + + ;found an exit location; see if it's empty + call .isValidExit + jr nz,.done + inc hl + jr .loop + +.didntFind ;look again starting at beginning + ld hl,map + ld a,[mapHeight] + ld d,a + +.outer ld a,[mapPitch] + ld e,a +.inner ld a,[hl+] + and c + cp b + jr nz,.notFoundYet + + ;maybe found; check if map location occupied + call .isValidExit + jr nz,.done + inc hl + +.notFoundYet + dec e + jr nz,.inner + dec d + jr nz,.outer + +;didnt find it after searching the WHOLE map + ld hl,$0000 + +.done + pop de + pop bc + ret + +.isValidExit + ld a,MAPBANK + ld [$ff70],a + dec hl + ld a,[hl] ;get this location in the map array + push af ;save it for a sec + ld a,ZONEBANK ;switch back to zones just in case + ld [$ff70],a + pop af + or a + jr nz,.validFalse + + ldio a,[curObjWidthHeight] + cp 1 + jr z,.validTrue + + ;2x2; must check locations to right, down-right, and down + ld a,MAPBANK + ld [$ff70],a + push hl + + inc hl + ld a,[hl] + or a + jr nz,.validFalseCleanUp + + push de + ld d,0 + ld a,[mapPitch] + ld e,a + add hl,de + pop de + + ld a,[hl] + or a + jr nz,.validFalseCleanUp + + dec hl + ld a,[hl] + or a + jr nz,.validFalseCleanUp + +.validTrueCleanUp + pop hl + ld a,ZONEBANK ;switch back to zones + ld [$ff70],a + jr .validTrue + +.validFalseCleanUp + pop hl + ld a,ZONEBANK ;switch back to zones + ld [$ff70],a + xor a + ret + +.validTrue + ld a,1 + or a + ret + +.validFalse + xor a + ret + +;--------------------------------------------------------------------- +; Routine: FindClassIndex +; Arguments: bc - class to find +; Returns: a - class index +; zflag - result of "OR a" +; Alters: af +; Description: Finds first class index of class "bc" & returns class +; index or 0 if it doesn't exist +;--------------------------------------------------------------------- +FindClassIndex:: + push de + push hl + + ld a,OBJLISTBANK + ld [$ff70],a + + ld a,[numClasses] + ld d,a + ld e,1 + + ld hl,classLookup+2 + +.loop ld a,[hl+] + cp c + jr nz,.afterCheck + ld a,[hl] + cp b + jr nz,.afterCheck + + ;found it! + ld a,e ;a is class index + or a + pop hl + pop de + ret + +.afterCheck + inc hl + inc e + dec d + jr nz,.loop + + pop hl + pop de + xor a ;didn't find it + ret + +;--------------------------------------------------------------------- +; Routine: ChangeClass +; Arguments: bc - class to change +; de - pointer to new class +; Alters: af,hl +; Description: Changes all objects of the "old" class type to the +; "new" class type +;--------------------------------------------------------------------- +ChangeClass:: + ld a,OBJLISTBANK + ld [$ff70],a + + ld a,$ff + ld hl,classLookup+2 + +.loop push af + ld a,[hl+] + cp c + jr nz,.afterCheck + ld a,[hl] + cp b + jr nz,.afterCheck + + ;replace old class with new + ld [hl],d + dec hl + ld [hl],e + inc hl + +.afterCheck + inc hl + pop af + dec a + jr nz,.loop + + ret + +;--------------------------------------------------------------------- +; Routine: ChangeFirstClass +; Arguments: bc - class to change +; de - pointer to new class +; Alters: af,hl +; Description: Changes of first class found to match the "old" class +; type to the "new" class type +;--------------------------------------------------------------------- +ChangeFirstClass:: + ld a,OBJLISTBANK + ld [$ff70],a + + ld a,$ff + ld hl,classLookup+2 + +.loop push af + ld a,[hl+] + cp c + jr nz,.afterCheck + ld a,[hl] + cp b + jr nz,.afterCheck + + ;replace old class with new + ld [hl],d + dec hl + ld [hl],e + inc hl + pop af + ret + +.afterCheck + inc hl + pop af + dec a + jr nz,.loop + + ret + +;--------------------------------------------------------------------- +; Routines: CopyMapMethodToRAM +; Arguments: a - offset of method in map contents +; [mapMethodContents] be set up +; Returns: nothing. +; Alters: nothing. +; Description: Copies the Map Check or Init Method to RAM so it can +; be called w/o switching ROM banks +;--------------------------------------------------------------------- +CopyMapMethodToRAM:: + push af + push bc + push de + push hl + + call LookupInMapContents ;set hl to point to source + + ;setup bc as # bytes to copy + ld c,[hl] ;low byte of size + inc hl + ld b,[hl] ;high byte of size + inc hl + + ld de,levelCheckRAM ;dest addr + + ;copy sets of 256 + ld a,b + or a + jr z,.copy_lt_256 + push bc +.outer ld c,0 +.inner ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.inner + dec b + jr nz,.outer + pop bc + +.copy_lt_256 + ;copy remaining < 256 bytes + ld a,c + or a + jr z,.done +.loop ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.loop + +.done + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: HandleExitFromMap +; Arguments: c - hero class index +; de - ptr to object +; Returns: Nothing. +; Alters: af +; Description: If the hero exiting is the one controlled by this +; machine, sets the paramaters which will cause a new +; map to be loaded (in user.asm) if the exit has a map +; associated with it. +; +; Deletes the remote hero if an exit is found. +;--------------------------------------------------------------------- +HandleExitFromMap:: + push bc + push de + push hl + + ;save exit type in B + call GetCurLocation + ldio a,[curObjWidthHeight] + cp 2 + jr nz,.locationSet + + call GetFacing + and %11 + cp DIR_NORTH + jr z,.locationSet + cp DIR_WEST + jr z,.locationSet + push af + call ConvertLocHLToXY + pop af + cp DIR_EAST + jr z,.incH + + inc l + jr .locationAltered + +.incH + inc h + +.locationAltered + call ConvertXYToLocHL + +.locationSet + ld a,ZONEBANK + ld [$ff70],a + ld a,[hl] + swap a + and %00000111 + ld b,a + + ;save exit location as entry location + call ConvertLocHLToXY + + push de + ld d,((hero0_data>>8) & $ff) + ld a,[curHeroAddressL] + add HERODATA_ENTERLOC + ld e,a + ld a,l + ld [de],a + inc de + ld a,h + ld [de],a + pop de + + ;lookup link in link table + ld a,b + sla a + add (mapExitLinks & $ff) + ld l,a + ld a,0 + adc ((mapExitLinks>>8) & $ff) + ld h,a + + ;store 16-bit BCD link value in hl + ld a,[hl+] + ld h,[hl] + ld l,a + + ld a,$40 + cp h + jr nz,.linkOkay + cp l + jr nz,.linkOkay + jp .done ;link is $4040 = (+0,+0) = no link + +.linkOkay + ;if remote hero exiting then don't change my map + push hl + LDHL_CURHERODATA HERODATA_INDEX + ld a,[hl] + pop hl + cp c ;cur hero index == cur index? + jr z,.localHero + jp .removeRemoteHero + +.localHero + call RemoveHero + ld a,h ;x link/offset + and %11000000 + jr nz,.xlinkRelative + + ld a,h + jr .doY + +.xlinkRelative + bit 6,h ;positive offset? + jr z,.negative_x_offset + + ;positive offset + call .setupH + call BCDToNumber + add h + call NumberToBCD + jr .doY + +.negative_x_offset + call .setupH + call BCDToNumber + sub h + call NumberToBCD + jr .doY + +.setupH + ld a,h + and %00111111 + ld h,a + ld a,[curLevelIndex+1] + ret + +.doY + ld [curLevelIndex+1],a + + ld a,l ;y link/offset + and %11000000 + jr nz,.ylinkRelative + + ld a,l + jr .finishedY + +.ylinkRelative + bit 6,l ;positive offset? + jr z,.negative_y_offset + + ;positive offset + call .setupL + call BCDToNumber + add l + call NumberToBCD + jr .finishedY + +.negative_y_offset + call .setupL + call BCDToNumber + sub l + call NumberToBCD + jr .finishedY + +.setupL + ld a,l + and %00111111 + ld l,a + ld a,[curLevelIndex] + ret + +.finishedY + ld [curLevelIndex],a + ld a,1 + ld [timeToChangeLevel],a + + ;switch NESW to be opposite + ld a,b + dec a + and %11111100 + jr nz,.switchUp + + ld a,b + inc a ;same as a--, a+=2 + and %00000011 + inc a + ld b,a + jr .afterSwitchToOpposite + +.switchUp + ld a,b + cp EXIT_U + jr nz,.switchDown + ld b,EXIT_D + ld a,b + jr .afterSwitchToOpposite + +.switchDown + cp EXIT_D + jr nz,.afterSwitchToOpposite + ld b,EXIT_U + ld a,b + +.afterSwitchToOpposite + LDHL_CURHERODATA HERODATA_ENTERDIR + ld a,b + ld [hl],a + +.updateState + ;don't update the state if it's an asynchronous can-join + ;map or a cinema + ld a,[canJoinMap] + cp 2 + jr z,.afterUpdateState + ld a,[displayType] + cp 1 + jr z,.afterUpdateState + + call UpdateState + +.removeRemoteHero + call RemoveHero + +.afterUpdateState +.zeroIndex + ld a,[hero0_index] + cp c + jr nz,.zeroIndex1 + + xor a + ld [hero0_index],a + jr .done + +.zeroIndex1 + ld a,[hero1_index] + cp c + jr nz,.done + xor a + ld [hero1_index],a + +.done + pop hl + pop de + pop bc + ret + +UpdateState:: + ld a,[amLinkMaster] + bit 7,a + ret nz ;no link + +.updateState + ld a,LUPDATESTATE + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.updateState ;must repeat + + ld a,[curLevelStateIndex] + call TransmitByte + ldio a,[mapState] + or a + jr nz,.stateNotZero + ld a,1 +.stateNotZero + call TransmitByte + ret + + +;--------------------------------------------------------------------- +; Routines: HasInventoryItem +; AddInventoryItem +; RemoveInventoryItem +; Arguments: bc - b=item byte, c=bitmask +; Alters: af +; Returns: a, zflag +; Description: Returns !0 if inventory item exists, 0 otherwise +;--------------------------------------------------------------------- +HasInventoryItem:: + push hl + call PointHLToInventory + pop hl + and c + ret + +AddInventoryItem:: + ;duplicate code also in user.asm + push hl + call PointHLToInventory + or c + ld [hl],a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterUpdateRemote + +.updateRemote + ld a,LADDINVITEM + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.updateRemote ;must repeat + ld a,c + call TransmitByte + ld a,b + call TransmitByte +.afterUpdateRemote + + pop hl + ret + +RemoveInventoryItem:: + ;duplicate code also in user.asm + push hl + call PointHLToInventory + xor $ff + or c + xor $ff + ld [hl],a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.afterUpdateRemote + +.updateRemote + ld a,LREMINVITEM + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.updateRemote ;must repeat + ld a,c + call TransmitByte + ld a,b + call TransmitByte +.afterUpdateRemote + + pop hl + ret + +PointHLToInventory:: + ld h,((inventory>>8)&$ff) + ld a,(inventory & $ff) + add b + ld l,a + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routines: GetFirstInventoryIndex +; GetNextInventoryIndex +; Arguments: a - previous inventory index (for GetNextII) +; Alters: af +; Description: Returns $ff for none, index otherwise (0,1,2,....) +;--------------------------------------------------------------------- +GetFirstInventoryIndex: + ld a,$ff + +GetNextInventoryIndex: + inc a + cp 48 ;reached max inventory items? + jr c,.notDone + + ld a,$ff + ret + +.notDone + push bc + push de + push hl + ld b,a + + ;position hl at current byte of inventory + ld h,((inventory >> 8) & $ff) + rrca ;itemIndex /= 8 + rrca + rrca + and %00011111 + add (inventory & $ff) + ld l,a + + ;jump to routine checking appropriate bit of inventory + ld a,b + rlca + and %1110 + add (.vectorTable & $ff) + ld e,a + ld a,0 + adc ((.vectorTable>>8) & $ff) + ld d,a + ld a,[hl] + push de ;jump to [de] + ret + +.vectorTable + jr .bit0 + jr .bit1 + jr .bit2 + jr .bit3 + jr .bit4 + jr .bit5 + jr .bit6 + jr .bit7 + +.bit0 + bit 0,a + jr nz,.foundIt + inc b +.bit1 + bit 1,a + jr nz,.foundIt + inc b +.bit2 + bit 2,a + jr nz,.foundIt + inc b +.bit3 + bit 3,a + jr nz,.foundIt + inc b +.bit4 + bit 4,a + jr nz,.foundIt + inc b +.bit5 + bit 5,a + jr nz,.foundIt + inc b +.bit6 + bit 6,a + jr nz,.foundIt + inc b +.bit7 + bit 7,a + jr nz,.foundIt + inc b + inc hl + ld a,l + cp ((inventory+16)&$ff) + jr z,.didntFind + ld a,[hl] + jr .bit0 + +.didntFind + ld a,$ff + jr .done + +.foundIt + ld a,b ;index + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: State0To1 +; Arguments: [mapState] +; Alters: af, [mapState] +; Returns: a - [mapState] +; Description: If [mapState] is 0 it is changed to 1, otherwise it +; is unmodified. The new map state is returned in a. +;--------------------------------------------------------------------- +State0To1:: + ldio a,[mapState] + or a + ret nz + ld a,1 + ldio [mapState],a + ret + +;--------------------------------------------------------------------- +; map data +;--------------------------------------------------------------------- +SECTION "MapSupportSection",ROMX + +;--------------------------------------------------------------------- +; Routine: GuestContinueSynchronization +; Arguments: None. +; Alters: af +; Returns: Nothing. +; Description: +;--------------------------------------------------------------------- +GuestContinueSynchronization:: + push bc + push de + push hl + + xor a + ld [backBufferReady],a + + ld a,LSYNCHREADY + call TransmitByte + + ;receive fresh copy of all my hero data from host + ld hl,hero0_data + ld bc,HERODATASIZE*2 + xor a + call ReceiveData + + LONGCALLNOARGS ResetList + + call ReceiveByte + ld [randomLoc],a + + call ReceiveByte + ld [heroesIdle],a + + ld hl,map + ld bc,4096 + ld a,MAPBANK + call ReceiveData + + ;fadeCurPalette + ld hl,fadeCurPalette + ld bc,128 + xor a + call ReceiveData + + ;gamePalette + ld hl,gamePalette + ld bc,128 + ld a,FADEBANK + call ReceiveData + + ;first 16 bytes of level check RAM + ld hl,levelCheckRAM + ld bc,16 + xor a + call ReceiveData + + ;spriteOAMdata + ld hl,spriteOAMBuffer + ld bc,160 + xor a + call ReceiveData + + ld hl,headTable ;headTable - linked list head + ld bc,256 + ld a,OBJLISTBANK + call ReceiveData + + ld hl,objExists ;objExists, FOF table + ld bc,512 + ld a,OBJLISTBANK + call ReceiveCompressedData + + call ReceiveByte + ld [numClasses],a + ld b,0 ;bc = numClasses*2 + 2 + ld c,a + sla c + rl b + inc bc + inc bc + + ld hl,classLookup + ;ld bc,512 numClasses*2 + ld a,OBJLISTBANK + call ReceiveData + + ld hl,fgTileMap + ld a,[numClasses] + ld b,0 + ld c,a + ld a,OBJLISTBANK + call ReceiveData + + ld hl,objClassLookup ;class indices for each obj + ld bc,256 + ld a,OBJLISTBANK + call ReceiveData + + ld hl,associatedIndex + ld bc,256 + ld a,OBJLISTBANK + call ReceiveData + + ld hl,spritesUsed + ld bc,40 + ld a,OBJLISTBANK + call ReceiveCompressedData + + ;---------------receive used objects------------------------- + ld a,OBJLISTBANK + ld [$ff70],a + ld de,objExists+1 +.receiveUsedObject + ld a,[de] ;is this object used? + or a + jr z,.afterReceiveUsedObject ;not used + + PREPLONGCALL .afterCvtIndexToPtr + ld a,e ;get object index + LONGCALL IndexToPointerHL ;cvt to ptr +.afterCvtIndexToPtr + ld bc,16 + ld a,OBJBANK + call ReceiveData + ld a,OBJLISTBANK + ld [$ff70],a + +.afterReceiveUsedObject + inc de + ld a,e + or a + jr nz,.receiveUsedObject + + call ReceiveByte + ld [numFreeSprites],a + + call ReceiveByte + ld [firstFreeObj],a + + call ReceiveByte + ld [randomLoc],a + + call ReceiveByte + ld [guardAlarm],a + + ;call ReceiveByte + ;ld [dialogBank],a + + call ReceiveByte + ld [respawnMap],a + call ReceiveByte + ld [respawnMap+1],a + + call ReceiveByte + ldio [mapState],a + call ReceiveByte + ldio [mapState+1],a + + ld hl,levelVars + ld bc,64 + xor a + call ReceiveData + + ;my music to off + xor a + ld [musicEnabled],a + + ld hl,musicBank + ld bc,64 + xor a + call ReceiveData + + ;setup the wave table + ld c,16 + ld de,$ff30 + ld hl,musicWaveform +.setupWave + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.setupWave + + ;set default instruments + ld hl,musicInstrument1 + ld de,$ff10 + ld bc,4 + xor a + call MemCopy + ld hl,musicInstrument2 + ld de,$ff16 + ld bc,3 + call MemCopy + ld hl,musicInstrument3 + ld de,$ff31 + call MemCopy + ld hl,musicInstrument4 + ld de,$ff20 + call MemCopy + + ;disable sound + xor a + ldio [$ff26],a + + ldio [$ff12],a ;zero envelope all instruments + ldio [$ff17],a + ldio [$ff1c],a + ldio [$ff21],a + + ;enable sound + ld a,$80 + ldio [$ff26],a ;master + ld a,$ff + ldio [$ff24],a ;volume + ldio [$ff25],a ;sound output terminals + + ld hl,musicStack + ld bc,128 + ld a,MUSICBANK + call ReceiveData + + call ReceiveByte + ldio [musicEnabled],a + + + LONGCALLNOARGS LinkRemakeLists + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: RandomizeFlightCodes +; Arguments: None. +; Alters: all +; Returns: Nothing. +; Description: Randomizes the flight codes +;--------------------------------------------------------------------- +RandomizeFlightCodes:: + ;randomize 11/15 flight codes + ld a,FLIGHTCODEBANK + ldio [$ff70],a + + ldio a,[randomLoc] + push af + ldio a,[vblankTimer] + ldio [randomLoc],a + + ld hl,flightCode+1 + ld a,11 +.loop + push af + + ;get a random octal coordinate in bc + ld a,7 + call GetRandomNumMask + swap a + ld b,a + ld a,7 + call GetRandomNumMask + or b + ld b,a + ld a,7 + call GetRandomNumMask + swap a + ld c,a + ld a,7 + call GetRandomNumMask + or c + ld c,a +.validateCode + call .checkCodeExists + jr nz,.placeCode + call .incrementCode + jr .validateCode + +.placeCode + ld [hl],c + inc hl + ld [hl],b + inc hl + inc hl + pop af + dec a + jr nz,.loop + + ldio a,[randomLoc] + ldio [asyncRandLoc],a + pop af + ldio [randomLoc],a + ret + +.incrementCode + ;separate code bc into bcde + ld a,c + and 7 + ld e,a + ld a,c + swap a + and 7 + ld d,a + ld a,b + and 7 + ld c,a + ld a,b + swap a + and 7 + ld b,a + + inc e + ld a,e + cp 8 + jr nz,.incrementDone + + ld e,0 + inc d + ld a,d + cp 8 + jr nz,.incrementDone + + ld d,0 + inc c + ld a,c + cp 8 + jr nz,.incrementDone + + ld c,0 + inc b + ld a,b + cp 8 + jr nz,.incrementDone + + ld b,0 + +.incrementDone + ;reassemble bcde into bc + swap b + ld a,c + or b + ld b,a + swap d + ld a,e + or d + ld c,a + ret + +.checkCodeExists + push bc + push hl + + ld hl,flightCode + ld c,[hl] + inc hl +.checkCodeLoop + ld a,[hl+] + cp c + jr nz,.keepGoing + + ld a,[hl] + cp b + jr nz,.keepGoing + + ;found a match :( + xor a + pop hl + pop bc + ret + +.keepGoing + inc hl + inc hl + dec c + jr nz,.checkCodeLoop + + ;no match! + ld a,1 + or a + pop hl + pop bc + ret + +;WARNING not home section + +;--------------------------------------------------------------------- +; map data +;--------------------------------------------------------------------- +SECTION "MapLookupTableSection",ROMX +MapLookupTable: + +;calculate index number 0-255 from xxyy with "i = yy*16 + xx" +;e.g. L0205 = 5*16 + 2 = 82 +DW BANK(L0000_Contents),L0000_Contents ;0 The Hive +DW 0,0 ;1 +DW BANK(L0200_Contents),L0200_Contents ;2 +DW BANK(L0300_Contents),L0300_Contents ;3 +DW BANK(L0400_Contents),L0400_Contents ;4 +DW BANK(L0500_Contents),L0500_Contents ;5 +DW BANK(L0600_Contents),L0600_Contents ;6 +DW BANK(L0700_Contents),L0700_Contents ;7 +DW BANK(L0800_Contents),L0800_Contents ;8 +DW BANK(L0900_Contents),L0900_Contents ;9 +DW BANK(L1000_Contents),L1000_Contents ;10 +DW BANK(L1100_Contents),L1100_Contents ;11 (1100, char select) +DW BANK(L1200_Contents),L1200_Contents ;12 (1200, demo intro) +DW BANK(L1300_Contents),L1300_Contents ;13 +DW BANK(L1400_Contents),L1400_Contents ;14 +DW BANK(L1500_Contents),L1500_Contents ;15 +DW BANK(L0001_Contents),L0001_Contents ;16 +DW 0,0 ;17 +DW BANK(L0201_Contents),L0201_Contents ;18 +DW BANK(L0301_Contents),L0301_Contents ;19 +DW BANK(L0401_Contents),L0401_Contents ;20 +DW BANK(L0501_Contents),L0501_Contents ;21 +DW BANK(L0601_Contents),L0601_Contents ;22 +DW BANK(L0701_Contents),L0701_Contents ;23 +DW BANK(L0801_Contents),L0801_Contents ;24 +DW BANK(L0901_Contents),L0901_Contents ;25 +DW BANK(L1001_Contents),L1001_Contents ;26 +DW BANK(L1101_Contents),L1101_Contents ;27 (1101, Main Menu) +DW BANK(L1201_Contents),L1201_Contents ;28 (join game) +DW BANK(L1301_Contents),L1301_Contents ;29 +DW BANK(L1401_Contents),L1401_Contents ;30 +DW 0,0 ;31 +DW BANK(L0002_Contents),L0002_Contents ;32 +DW 0,0 ;33 +DW 0,0 ;34 +DW BANK(L0302_Contents),L0302_Contents ;35 +DW BANK(L0402_Contents),L0402_Contents ;36 +DW BANK(L0502_Contents),L0502_Contents ;37 +DW BANK(L0602_Contents),L0602_Contents ;38 +DW BANK(L0702_Contents),L0702_Contents ;39 +DW BANK(L0802_Contents),L0802_Contents ;40 +DW BANK(L0902_Contents),L0902_Contents ;41 +DW BANK(L1002_Contents),L1002_Contents ;42 +DW BANK(L1102_Contents),L1102_Contents ;43 (1102, main intro) +DW BANK(L1202_Contents),L1202_Contents ;44 (1202, dropship lv v.t.) +DW BANK(L1302_Contents),L1302_Contents ;45 (1302 ba corners gyro) +DW BANK(L1402_Contents),L1402_Contents ;46 (1402 b12 surrenders) +DW BANK(L1502_Contents),L1502_Contents ;47 +DW BANK(L0003_Contents),L0003_Contents ;48 +DW BANK(L0103_Contents),L0103_Contents ;49 +DW BANK(L0203_Contents),L0203_Contents ;50 +DW BANK(L0303_Contents),L0303_Contents ;51 +DW BANK(L0403_Contents),L0403_Contents ;52 +DW BANK(L0503_Contents),L0503_Contents ;53 +DW BANK(L0603_Contents),L0603_Contents ;54 +DW BANK(L0703_Contents),L0703_Contents ;55 +DW BANK(L0803_Contents),L0803_Contents ;56 +DW BANK(L0903_Contents),L0903_Contents ;57 +DW BANK(L1003_Contents),L1003_Contents ;58 +DW BANK(L1103_Contents),L1103_Contents ;59 +DW BANK(L1203_Contents),L1203_Contents ;60 +DW 0,0 ;61 +DW BANK(L1403_Contents),L1403_Contents ;62 +DW BANK(L1503_Contents),L1503_Contents ;63 +DW BANK(L0004_Contents),L0004_Contents ;64 +DW BANK(L0104_Contents),L0104_Contents ;65 +DW BANK(L0204_Contents),L0204_Contents ;66 +DW BANK(L0304_Contents),L0304_Contents ;67 0304 shroom +DW BANK(L0404_Contents),L0404_Contents ;68 +DW BANK(L0504_Contents),L0504_Contents ;69 +DW BANK(L0604_Contents),L0604_Contents ;70 +DW BANK(L0704_Contents),L0704_Contents ;71 +DW BANK(L0804_Contents),L0804_Contents ;72 +DW BANK(L0904_Contents),L0904_Contents ;73 +DW BANK(L1004_Contents),L1004_Contents ;74 +DW BANK(L1104_Contents),L1104_Contents ;75 +DW BANK(L1204_Contents),L1204_Contents ;76 +DW BANK(L1304_Contents),L1304_Contents ;77 +DW 0,0 ;78 +DW BANK(L1504_Contents),L1504_Contents ;79 +DW BANK(L0005_Contents),L0005_Contents ;80 +DW BANK(L0105_Contents),L0105_Contents ;81 path +DW BANK(L0205_Contents),L0205_Contents ;82 bridge +DW BANK(L0305_Contents),L0305_Contents ;83 +DW BANK(L0405_Contents),L0405_Contents ;84 +DW BANK(L0505_Contents),L0505_Contents ;85 +DW BANK(L0605_Contents),L0605_Contents ;86 +DW BANK(L0705_Contents),L0705_Contents ;87 +DW BANK(L0805_Contents),L0805_Contents ;88 +DW BANK(L0905_Contents),L0905_Contents ;89 +DW BANK(L1005_Contents),L1005_Contents ;90 +DW BANK(L1105_Contents),L1105_Contents ;91 +DW 0,0 ;92 +DW 0,0 ;93 +DW 0,0 ;94 +DW 0,0 ;95 +DW BANK(L0006_Contents),L0006_Contents ;96 +DW BANK(L0106_Contents),L0106_Contents ;97 path +DW 0,0 ;98 +DW BANK(L0306_Contents),L0306_Contents ;99 +DW BANK(L0406_Contents),L0406_Contents ;100 +DW BANK(L0506_Contents),L0506_Contents ;101 +DW BANK(L0606_Contents),L0606_Contents ;102 +DW BANK(L0706_Contents),L0706_Contents ;103 +DW BANK(L0806_Contents),L0806_Contents ;104 +DW BANK(L0906_Contents),L0906_Contents ;105 +DW BANK(L1006_Contents),L1006_Contents ;106 +DW 0,0 ;107 +DW 0,0 ;108 +DW 0,0 ;109 +DW 0,0 ;110 +DW 0,0 ;111 +DW BANK(L0007_Contents),L0007_Contents ;112 +DW BANK(L0107_Contents),L0107_Contents ;113 path +DW 0,0 ;114 +DW BANK(L0307_Contents),L0307_Contents ;115 +DW BANK(L0407_Contents),L0407_Contents ;116 +DW BANK(L0507_Contents),L0507_Contents ;117 +DW BANK(L0607_Contents),L0607_Contents ;118 +DW BANK(L0707_Contents),L0707_Contents ;119 +DW BANK(L0807_Contents),L0807_Contents ;120 +DW BANK(L0907_Contents),L0907_Contents ;121 +DW BANK(L1007_Contents),L1007_Contents ;122 +DW 0,0 ;123 +DW 0,0 ;124 +DW 0,0 ;125 +DW 0,0 ;126 +DW 0,0 ;127 +DW BANK(L0008_Contents),L0008_Contents +DW BANK(L0108_Contents),L0108_Contents +DW 0,0 ;130 +DW BANK(L0308_Contents),L0308_Contents +DW BANK(L0408_Contents),L0408_Contents +DW BANK(L0508_Contents),L0508_Contents +DW BANK(L0608_Contents),L0608_Contents +DW BANK(L0708_Contents),L0708_Contents +DW BANK(L0808_Contents),L0808_Contents +DW BANK(L0908_Contents),L0908_Contents +DW BANK(L1008_Contents),L1008_Contents +DW 0,0 ;139 +DW 0,0 ;140 +DW 0,0 ;141 +DW 0,0 ;142 +DW 0,0 ;143 +DW BANK(L0009_Contents),L0009_Contents +DW BANK(L0109_Contents),L0109_Contents +DW 0,0 ;146 +DW BANK(L0309_Contents),L0309_Contents +DW BANK(L0409_Contents),L0409_Contents +DW BANK(L0509_Contents),L0509_Contents +DW BANK(L0609_Contents),L0609_Contents +DW BANK(L0709_Contents),L0709_Contents +DW BANK(L0809_Contents),L0809_Contents +DW BANK(L0909_Contents),L0909_Contents +DW BANK(L1009_Contents),L1009_Contents +DW 0,0 ;155 +DW 0,0 ;156 +DW 0,0 ;157 +DW 0,0 ;158 +DW 0,0 ;159 +DW BANK(L0010_Contents),L0010_Contents +DW BANK(L0110_Contents),L0110_Contents +DW 0,0 ;162 +DW BANK(L0310_Contents),L0310_Contents +DW BANK(L0410_Contents),L0410_Contents +DW BANK(L0510_Contents),L0510_Contents +DW BANK(L0610_Contents),L0610_Contents +DW BANK(L0710_Contents),L0710_Contents +DW BANK(L0810_Contents),L0810_Contents +DW BANK(L0910_Contents),L0910_Contents +DW BANK(L1010_Contents),L1010_Contents +DW 0,0 ;171 +DW 0,0 ;172 +DW 0,0 ;173 +DW 0,0 ;174 +DW 0,0 ;175 +DW BANK(L0011_Contents),L0011_Contents +DW BANK(L0111_Contents),L0111_Contents +DW BANK(L0211_Contents),L0211_Contents +DW BANK(L0311_Contents),L0311_Contents +DW BANK(L0411_Contents),L0411_Contents +DW 0,0 ;181 +DW 0,0 ;182 +DW BANK(L0711_Contents),L0711_Contents +DW BANK(L0811_Contents),L0811_Contents +DW BANK(L0911_Contents),L0911_Contents +DW BANK(L1011_Contents),L1011_Contents +DW BANK(L1111_Contents),L1111_Contents +DW 0,0 ;188 +DW 0,0 ;189 +DW 0,0 ;190 +DW 0,0 ;191 +DW BANK(L0012_Contents),L0012_Contents +DW BANK(L0112_Contents),L0112_Contents +DW BANK(L0212_Contents),L0212_Contents +DW BANK(L0312_Contents),L0312_Contents +DW BANK(L0412_Contents),L0412_Contents +DW BANK(L0512_Contents),L0512_Contents +DW BANK(L0612_Contents),L0612_Contents +DW BANK(L0712_Contents),L0712_Contents +DW BANK(L0812_Contents),L0812_Contents +DW BANK(L0912_Contents),L0912_Contents +DW BANK(L1012_Contents),L1012_Contents +DW BANK(L1112_Contents),L1112_Contents +DW BANK(L1212_Contents),L1212_Contents +DW BANK(L1312_Contents),L1312_Contents +DW BANK(L1412_Contents),L1412_Contents +DW BANK(L1512_Contents),L1512_Contents +DW BANK(L0013_Contents),L0013_Contents ;208 intro_ba1 +DW BANK(L0113_Contents),L0113_Contents ;209 intro_ba2 +DW BANK(L0213_Contents),L0213_Contents ;210 intro_ba3 +DW BANK(L0313_Contents),L0313_Contents ;211 intro_ba4 +DW BANK(L0413_Contents),L0413_Contents ;212 +DW 0,0 ;213 +DW 0,0 ;214 +DW 0,0 ;215 +DW 0,0 ;216 +DW 0,0 ;217 +DW 0,0 ;218 +DW 0,0 ;219 +DW 0,0 ;220 +DW 0,0 ;221 +DW 0,0 ;222 +DW 0,0 ;223 +DW BANK(L0014_Contents),L0014_Contents ;224 intro haiku 1 +DW BANK(L0114_Contents),L0114_Contents ;225 intro haiku 2 +DW BANK(L0214_Contents),L0214_Contents ;226 intro haiku 3 +DW BANK(L0314_Contents),L0314_Contents ;227 intro haiku 4 (escape) +DW 0,0 ;228 +DW 0,0 ;229 +DW 0,0 ;230 +DW 0,0 ;231 +DW 0,0 ;232 +DW 0,0 ;233 +DW 0,0 ;234 +DW 0,0 ;235 +DW 0,0 ;236 +DW 0,0 ;237 +DW 0,0 ;238 +DW 0,0 ;239 +DW BANK(L0015_Contents),L0015_Contents ;240 intro bs 1 +DW BANK(L0115_Contents),L0115_Contents ;241 intro bs 2 +DW BANK(L0215_Contents),L0215_Contents ;242 intro bs 3 +DW BANK(L0315_Contents),L0315_Contents ;243 intro bs 4 +DW 0,0 ;244 +DW 0,0 ;245 +DW 0,0 ;246 +DW 0,0 ;247 +DW 0,0 ;248 +DW 0,0 ;249 +DW 0,0 ;250 +DW 0,0 ;251 +DW 0,0 ;252 +DW 0,0 ;253 +DW 0,0 ;254 +DW 0,0 ;255 + +;SECTION "BGTileSection",ROMX,BANK[BGTILEROM] +SECTION "BGTileSection",ROMX[$4000],BANK[BGTILEROM1] +BGTiles:: +DB 0,0,0,0, 0,0,0,0, 0,0,0,0,0,0,0,0 ;blank tile zero +INCBIN "Data/Tiles/bgTiles1-256.bin" +INCBIN "Data/Tiles/bgTiles257-512.bin" +INCBIN "Data/Tiles/bgTiles513-768.bin" +INCBIN "Data/Tiles/bgTiles769-979.bin" + +SECTION "BGTileSection2",ROMX[$4000],BANK[BGTILEROM2] +BGTiles1024:: +DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +INCBIN "Data/Tiles/bgTiles1024-1279.bin" +INCBIN "Data/Tiles/bgTiles1280-1535.bin" +INCBIN "Data/Tiles/bgTiles1536-1791.bin" +INCBIN "Data/Tiles/bgTiles1792-2047.bin" + +;DS 16*((1024-256)-1) ;pad tiles + +SECTION "BGColorTable",ROMX[$4000] +bg_colorTable:: ;defines a byte for the tile attribute (color) for each class +;0=Grey, 1=Red, 2=Blue, 3=Green, 4=Purple, 5=Yellow, 6=Brown/Orange, 7=Fuscia +;+8=can walk over +;+16=can shoot over +;+32=attackable + + ;bg tiles +; 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 + DB 0 ; 0 + DB 0, 0, 0, 4, 2, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 1- 20 + DB 0, 3, 3, 3, 3, 3,34,34,34,34,34,34,34,34,34,34,34,34,34,34 ; 21- 40 + DB 34,34,34,34,34,34,34,34,34,34, 1, 1, 1, 1, 2, 2, 2, 2, 6, 6 ; 41- 60 + DB 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ; 61- 80 + DB 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 81-100 + DB 0, 0, 0, 0, 0,38,38,38,38, 2,36,36,36,36,36,36,36,36,36,36 ;101-120 + DB 36,36,39, 6, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 5 ;121-140 + DB 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ;141-160 + DB 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;161-180 + DB 0, 0, 0, 6, 4, 1, 5, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ;181-200 + DB 4, 4, 4, 4, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ;201-220 + DB 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ;221-240 + DB 3, 3, 3, 3, 3, 3, 0,16, 0, 6, 6, 3, 3, 3, 3, 0,37,37,37,37 ;241-260 + DB 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37 ;261-280 + DB 37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37 ;281-300 + DB 37,37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;301-320 + DB 0, 0,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18 ;321-340 + DB 18,18, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;341-360 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3 ;361-380 + DB 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0 ;381-400 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6 ;401-420 + DB 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 5, 5, 5, 5 ;421-440 + DB 5, 5, 5, 6,18,18,18,18,18,18,18,18,18,18,18,18, 0, 0, 0,18 ;441-460 ;water + DB 18,18,18,22,22,22,22,22,22,22,22,22,22,22,22,22,22, 7, 4, 4 ;461-480 ;bank + DB 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 3, 3 ;481-500 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 ;501-520 + DB 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2 ;521-540 + DB 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2 ;541-560 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;561-580 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;581-600 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 ;601 + DB 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ;621 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;641 + DB 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ;661 + DB 4, 4, 4, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3 ;681 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3 ;701 + DB 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1 ;721 + DB 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ;741 + DB 1, 1, 1, 1, 1, 1, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;761 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;781 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;801 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;821 + DB 6, 6, 6, 6, 6,38, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,38, 6, 0 ;841 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6 ;861 + DB 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,32, 0, 3, 3, 3, 3,35, 3, 5, 5 ;881 + DB 5, 5,37, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6 ;901 + DB 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 ;921 + DB 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;941 + DB 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5,37, 5, 1, 1, 1, 1 ;961 + DB 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;981 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1001 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1021 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1041 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,34,34,34,34, 2, 2, 2, 2 ;1061 + DB 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ;1081 + DB 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,24,24,24,24 ;1101 + DB 24,24,24,24,24,24,24,24,24,24,24,24, 0, 0, 0, 2, 2, 0, 0, 0 ;1121 +; 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 +;0=Grey, 1=Red, 2=Blue, 3=Green, 4=Purple, 5=Yellow, 6=Brown/Orange, 7=Fuscia + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32 ;1141 + DB 32, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1161 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1181 + DB 3, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;1201 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3 ;1221 + DB 3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4 ;1241 + DB 4,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 6, 0 ;1261 + DB 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0,32,32, 0, 0, 0, 0, 0, 0, 0 ;1281 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1301 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2 ;1321 + DB 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, 2, 2, 3 ;1341 + DB 3, 3, 3, 1, 1, 3, 3, 3, 3, 3, 6, 5, 5, 3, 3, 3, 2, 2, 2, 2 ;1361 + DB 2, 2, 2, 0, 0, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1381 + DB 0,35,35,35,35,35, 8, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1401 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1421 + DB 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 5, 6, 6 ;1441 + DB 1, 3, 2,33,33,33,33,34,34,34,34,38,38,38,38,32,32,32,32,32 ;1461 + DB 32,32,32,32,32,32,32,32,32,33,33,33,33,35,35,35,35,35,35,35 ;1481 + DB 35,35,35,35,35,35,35,35,35,35,35,29,37,37,37,37,37,37,37,37 ;1501 + DB 37,37,37,37,37,37,37,37,37,37,37,37,16,25,25,25,29,30,32,32 ;1521 + DB 32,32,32,32,32,32, 4, 4, 4, 4,53,53,53,53,53,53,53,53,53,53 ;1541 + DB 53,53,53,53,53,53,53,53, 0, 0, 0,30,29, 2, 2, 2, 2, 2, 2, 2 ;1561 + DB 2, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;1581 + DB 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0 ;1601 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1621 + DB 0, 0,32,32,32,32,32,32,32,32,32,30, 6, 6, 6, 6, 6, 6, 6, 6 ;1641 + DB 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0 ;1661 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2 ;1681 + DB 2, 2, 2, 0, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ;1701 + DB 6, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6 ;1721 + DB 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0 ;1741 + DB 0, 3, 3, 3, 0,32,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1761 + DB 0,32,32, 0, 0,32,32, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ;1781 + DB 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 ;1801 + DB 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ;1821 + DB 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,33, 1,34, 2,33,33 ;1841 + DB 1, 1,34,34, 2, 2,33,33, 1, 1,34,34, 2, 2, 6, 0, 0, 0, 0,24 ;1861 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1881 + DB 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1901 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1921 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1941 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1961 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;1981 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;2001 + DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5 ;2021 + DB 0, 0,25, 0, 0, 5, 1 ;2041 +; 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 +;0=Grey, 1=Red, 2=Blue, 3=Green, 4=Purple, 5=Yellow, 6=Brown/Orange, 7=Fuscia +;+8=can walk over +;+16=can shoot over +;+32=attackable + +SECTION "FGTileSection",ROMX[$4800] +FGTiles: +INCBIN "Data/Tiles/fgTiles2048-2302.bin" ;monsta tiles +INCBIN "Data/Tiles/fgTiles2304-2559.bin" ;monsta tiles + + +fg_colorTable:: ;defines a byte for the tile attribute (color) for each class +;0=Grey, 1=Red, 2=Blue, 3=Green, 4=Purple, 5=Yellow, 6=Brown/Orange, 7=Fuscia +; + any combination of: +;16 = is bullet +;32 = 2x2 monster +;64 = no rotate when facing N/S +;128 = can't be thrown (probably stationary) + +;obj tiles +; +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +; 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 +DB 4, 4, 2, 2, 5, 5, 1, 1, 2, 2, 3, 3, 3, 3,64, 2, 2, 6, 6,64 ;2048 +0 +DB 0,133,5, 0, 0, 0, 0, 0, 0, 1, 0, 6, 6, 4, 0, 4, 0, 5, 5, 5 ;2068 +20 +DB 5,195,195,0,0,65,65, 6, 6,70,70,67, 0, 0,35,35,35,35,35,35 ;2088 +40 +DB 0, 0, 0, 0, 2, 2, 5, 5, 6, 6, 0, 0,38,38,38,38,38,38,38,38 ;2108 +60 +DB 6, 6,16,16,16,16,16,16, 3, 3, 0, 0,165,165,165,165,2,2,1,1 ;2128 +80 +DB 4, 0, 0, 0, 2, 2, 3, 3, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5 ;2148 +100 +DB 166,0, 0, 0, 0, 0,70,70,70,70,64,64,65,65,66,66,35,35,35,35 ;2168 +120 +DB 35,35, 0, 0, 6, 6, 6, 6,66,66,70,70, 6, 6,16,16, 6, 6,16,16 ;2188 +140 +DB 0, 0,16,16,16,16,16,16,16,16,16,16, 6, 6,38,38,38,38,38,38 ;2208 +160 +DB 38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,37,37 ;2228 +180 +DB 37,37,37,37,37,37, 3, 3, 5, 5,33,33,33,33,33,33,33,33, 1, 1 ;2248 +200 +DB 34,34,34,34,34,34,34,34, 5, 5, 4, 4, 0, 0, 5, 5, 5, 5, 0, 0 ;2268 +220 +DB 3, 3, 1, 1, 4, 4,16,16,34,34,34,34,19,19, 0, 0,64,64,65,65 ;2288 +240 +DB 3, 3, 5, 5, 0, 0, 0, 6, 6,21,21,38,38,38,38,38,38,38,38, 3 ;2308 +260 +DB 3, 7, 7, 5, 6, 6, 6,37, 5, 5, 5,37, 5, 5, 5,163,3, 3, 3, 6 ;2328 +280 +DB 6, 6, 6,35, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,32, 0, 0, 0, 0, 0 ;2348 +300 +DB 0, 0,32, 0, 0, 0,38, 0, 0, 0, 0, 0, 0, 0,16, 0, 1, 0, 2, 0 ;2368 +320 +DB 3, 0,35, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0,70, 0, 0, 0, 0, 0 ;2388 +340 +DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;2408 +360 +DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;2428 +380 +DB 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 2, 0, 5, 0, 1, 0, 0, 0, 0, 0 ;2448 +400 +DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;2468 +420 + +; +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +; 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 + +;--------------------------------------------------------------------- +SECTION "MapBGPix",ROMX +;--------------------------------------------------------------------- +waitingToJoin_bg: + INCBIN "Data/Cinema/menu/WaitingToJoin.bg" + diff --git a/Source/Music.asm b/Source/Music.asm new file mode 100644 index 0000000..80d0ae8 --- /dev/null +++ b/Source/Music.asm @@ -0,0 +1,709 @@ +;--------------------------------------------------------------------- +; Music.asm +; 8.20.00 by Abe Pralle +;--------------------------------------------------------------------- + +INCLUDE "Source/Defs.inc" + +;Routines +;-------------- +; InitMusic +; PlayMusic + +SECTION "MusicHome",ROM0 +;--------------------------------------------------------------------- +; Routine: IsCurMusic +; Arguments: a - bank of gbm data +; hl - address of compiled gbm music +; Alters: af +; Returns: a - 1 if same music is playing, 0 if not +; zflag - or a +; Description: Initializes a new piece of music *unless* it is +; already playing in which case it leaves it alone. +;--------------------------------------------------------------------- +IsCurMusic:: + push bc + ld b,a + ld a,[musicBank] + cp b + jr nz,.different + ld a,[musicAddress] + cp l + jr nz,.different + ld a,[musicAddress+1] + cp h + jr nz,.different + +.same + pop bc + ld a,1 + or a + ret + +.different + pop bc + xor a + ret + +;--------------------------------------------------------------------- +; Routine: InitMusic +; Arguments: a - bank of gbm data +; hl - address of compiled gbm music +; Alters: af +; Description: Initializes a new piece of music *unless* it is +; already playing in which case it leaves it alone. +;--------------------------------------------------------------------- +InitMusic:: + push bc + push de + push hl + + push af + ld b,a + ld a,[musicBank] + cp b + jr nz,.newMusic + ld a,[musicAddress] + cp l + jr nz,.newMusic + ld a,[musicAddress+1] + cp h + jr nz,.newMusic + pop af + jp .done ;currently playing this one + +.newMusic + pop af + di + ld [musicBank],a + xor a + ld [musicEnabled],a + ei + + ld a,l + ld [musicAddress],a + ld a,h + ld [musicAddress+1],a + + PUSHROM + ld a,[musicBank] + call SetActiveROM + + ;parse header + inc hl ;skip version + ld a,[hl+] ;notes per second + ld [musicNoteCountdownInit],a + ld [musicNoteCountdown],a + ld de,6 + add hl,de + + ld bc,musicTrack1Pos + call .getTrackOffset + ld bc,musicTrack2Pos + call .getTrackOffset + ld bc,musicTrack3Pos + call .getTrackOffset + ld bc,musicTrack4Pos + call .getTrackOffset + + ld a,BANK(instrumentDefaults) + call SetActiveROM + + ld c,33 + ld de,musicInstrument1 + ld hl,instrumentDefaults +.copyDefaultInstruments + ld a,[hl+] + ld [de],a + inc de + dec c + jr nz,.copyDefaultInstruments + + ;actually set default instruments + ld hl,musicInstrument1 + ld de,$ff10 + ld bc,4 + xor a + call MemCopy + ld hl,musicInstrument2 + ld de,$ff16 + ld bc,3 + call MemCopy + ld hl,musicInstrument3 + ld de,$ff31 + call MemCopy + ld hl,musicInstrument4 + ld de,$ff20 + call MemCopy + + ;disable sound + xor a + ldio [$ff26],a + + ldio [$ff12],a ;zero envelope all instruments + ldio [$ff17],a + ldio [$ff1c],a + ldio [$ff21],a + ;ldio [$ff14],a ;turn off instruments + ;ldio [$ff19],a + ;ldio [$ff1e],a + ;ldio [$ff23],a + + ;enable sound + ld a,$80 + ldio [$ff26],a ;master + ld a,$ff + ldio [$ff24],a ;volume + ldio [$ff25],a ;sound output terminals + + ;ld a,[musicInstrument1] + ;ldio [$ff10],a + ;ld a,[musicInstrument1+1] + ;ldio [$ff11],a + ;ld a,[musicInstrument2] + ;ldio [$ff16],a + ;ld a,[musicInstrument2] + ;ldio [$ff16],a + + ;setup waveform data + ld de,$ff30 + ld hl,musicWaveform + ld bc,16 + call MemCopy + xor a + + POPROM + + ;initialize music stacks + ld a,32 + ld hl,musicStackL1 + ld [hl+],a + ld a,64 + ld [hl+],a + ld a,96 + ld [hl+],a + ld a,128 + ld [hl+],a + +.done + ld a,%11111 + ldio [musicEnabled],a + + pop hl + pop de + pop bc + ret + +.getTrackOffset + ld a,[hl+] + ld e,a + ld a,[hl+] + ld d,a + push hl + add hl,de + ld a,l + ld [bc],a + inc bc + ld a,h + ld [bc],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: StopMusic +; Arguments: None. +; Alters: af +; Description: Halts the music +;--------------------------------------------------------------------- +StopMusic:: + xor a + ldio [musicEnabled],a + ret + +;--------------------------------------------------------------------- +; Routine: PlayMusic +; Arguments: None. +; Alters: af +; Description: Plays the next note for each voice. Should only be +; called after [musicNoteCountdown] has reached zero +; (being decremented 60 times per second). +;--------------------------------------------------------------------- +PlayMusic:: + push bc + push de + push hl + + ;save the current RAM bank in use + ldio a,[$ff70] + push af + + ld a,MUSICBANK + ldio [$ff70],a + + PUSHROM + ld hl,musicBank + ld a,[hl+] + call SetActiveROM + ld a,[hl+] ;countdown init + ld [hl+],a ;reset cur countdown + + ;decrement sound effect override counters + push hl + xor a + ld hl,musicOverride1 + cp [hl] + jr z,.skipOverride1 + dec [hl] +.skipOverride1 + inc hl + cp [hl] + jr z,.skipOverride4 + dec [hl] +.skipOverride4 + pop hl + + ld a,[musicStackL1] + ld [curTrackStackL],a + call .playTrack + ld a,[curTrackStackL] + ld [musicStackL1],a + +.playTrack2 + ld a,[musicStackL2] + ld [curTrackStackL],a + call .playTrack + ld a,[curTrackStackL] + ld [musicStackL2],a + +.playTrack3 + ld a,[musicStackL3] + ld [curTrackStackL],a + call .playTrack + ld a,[curTrackStackL] + ld [musicStackL3],a + +.playTrack4 + ld a,[musicStackL4] + ld [curTrackStackL],a + call .playTrack + ld a,[curTrackStackL] + ld [musicStackL4],a + +.afterPlayTrack4 + POPROM + + ;restore RAM bank + pop af + ldio [$ff70],a + + pop hl + pop de + pop bc + ret + +.playTrack + ;hl - address of pc for current track + push hl + ld a,[hl+] ;set the pc + ld e,a + ld a,[hl+] + ld d,a +;ld a,d +;cp $ff +;jr nz,.okay +;ld b,b +;.okay + call ExecuteByteCode + pop hl + + ;save new pc for this track + ld a,e + ld [hl+],a + ld a,d + ld [hl+],a + ret + +ExecuteByteCode: + ld a,[de] ;get a bytecode + inc de + or a ;nop? + ret z + + ld b,a + and $f0 + jr nz,.check1xTo8x + + ld a,b + bit 3,a + jr nz,.check08To0f + + cp 2 + jp z,.return + cp 4 + jp z,.note1 + cp 5 + jp z,.note2 + cp 6 + jp z,.note3 + cp 7 + jp z,.note4 +.error02To07 jr .error02To07 + +.check08To0f + cp 8 + jp z,.hold1 + cp 9 + jp z,.hold2 + cp $0a + jp z,.hold3 + cp $0b + jp z,.hold4 + cp $0c + jp z,.instr1 + cp $0d + jp z,.instr2 + cp $0e + jp z,.instr3 + cp $0f + jp z,.instr4 +.error08To0f jr .error08To0f + +.check1xTo8x + cp $10 + jp z,.setDec + cp $20 + jp z,.setReg + cp $30 + jp z,.decReg + cp $40 + jp z,.cmpDec + cp $50 + jp z,.cmpReg + cp $60 + jp z,.jump + cp $70 + jp z,.call + cp $80 + jp z,.repeat +.error1xTo8x jr .error1xTo8x + +.return + ;pop return address off the current stack & execute another + ;command + ld h,((musicStack>>8)&$ff) + ld a,[curTrackStackL] + ld l,a + ld a,[hl+] + ld e,a + ld a,[hl+] + ld d,a + ld a,l + ld [curTrackStackL],a + jp ExecuteByteCode + +.hold1 + ld a,[de] + inc de + ld [musicInstrument1+2],a + jr .note1 + +.hold2 ld a,[de] + inc de + ld [musicInstrument2+1],a + jr .note2 + +.hold3 ld a,[de] + inc de + ld [musicInstrument3],a + jr .note3 + +.hold4 ld a,[de] + inc de + ld [musicInstrument4+1],a + jr .note4 + +.note1 + ld hl,musicInstrument1+3 + call .noteCommon +.repeat1 + ldio a,[musicEnabled] + and %00001 + ret z + ld hl,musicInstrument1 + jp PlaySoundChannel1 + +.note2 + ld hl,musicInstrument2+2 + call .noteCommon +.repeat2 + ldio a,[musicEnabled] + and %00010 + ret z + ld hl,musicInstrument2 + jp PlaySoundChannel2 + +.note3 + ld hl,musicInstrument3+2 + call .noteCommon +.repeat3 + ldio a,[musicEnabled] + and %00100 + ret z + ld hl,musicInstrument3 + jp PlaySoundChannel3 + +.note4 + ld hl,musicInstrument4 + call .noteCommon + call .noteCommon +.repeat4 + ldio a,[musicEnabled] + and %01000 + ret z + ld hl,musicInstrument4 + jp PlaySoundChannel4 + +.noteCommon + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ret + +.instr1 + ld hl,musicInstrument1 + ld c,3 + jp .instrCommon + +.instr2 + ld hl,musicInstrument2 + ld c,2 + jp .instrCommon + +.instr3 + ld hl,musicInstrument3 + ld a,[de] + inc de + ld [hl+],a + ld a,[de] + inc de + ld [hl+],a + ld hl,musicWaveform + ld c,16 + jp .instrCommon + +.instr4 + ld hl,musicInstrument4 + ld c,4 + jp .instrCommon + +.instrCommon + ld a,[de] + inc de + ld [hl+],a + dec c + jr nz,.instrCommon + jp ExecuteByteCode + +.setDec +ld b,b + ld a,b + call .setHLToReg + ld a,[de] + inc de + ld [hl],a + jp ExecuteByteCode + +.setReg +ld b,b + ld a,[de] + inc de + call .setHLToReg + ld c,[hl] + ld a,b + call .setHLToReg + ld [hl],a + jp ExecuteByteCode + +.decReg + ;ld a,b + ;call .setHLToReg + ;dec [hl] + ;TODO + jp ExecuteByteCode + +.cmpDec + ld b,a ;which register? + and $f + add (musicRegisters & $ff) + ld l,a + ld h,((musicRegisters>>8) & $ff) + ld a,[de] + cp [hl] + call nz,.nonZeroResult + call z,.zeroResult + +.cmpReg + ;TODO + inc de + jp ExecuteByteCode + +.nonZeroResult + ld a,0 + ld [musicRegisters+15],a + ret + +.zeroResult + ld a,1 + ld [musicRegisters+15],a + ret + +.setHLToReg + and $0f + add (musicRegisters & $ff) + ld h,((musicRegisters>>8) & $ff) + ld l,a + ret + +.jump + ld a,[de] ;hl = offset to new address + inc de + ld l,a + ld a,[de] + inc de + ld h,a + + ld a,b + and $7 + cp 6 + jr z,.jumpAlways + + ;assume cc=eq + ld a,[musicRegisters+15] + or a + jr z,.afterJump ;not eq + +.jumpAlways + add hl,de + ld d,h + ld e,l +.afterJump + jp ExecuteByteCode + +.call ;save return address on current music stack + ld h,((musicStack>>8)&$ff) + ld a,[curTrackStackL] + sub 2 + ld [curTrackStackL],a + ld l,a + ld a,e + add 2 + ld [hl+],a + ld a,d + adc 0 + ld [hl-],a + ld b,6 ;cc=jump always + jr .jump + +.repeat + ld a,b + and $0f + jp z,.repeat1 + cp 1 + jp z,.repeat2 + cp 2 + jp z,.repeat3 + cp 3 + jp z,.repeat4 +.error8x jr .error8x + + +;--------------------------------------------------------------------- +SECTION "MusicData1",ROMX +;--------------------------------------------------------------------- +instrumentDefaults: +.instrument1 +DB $07,$80,$f1,$43,$85 +.instrument2 +DB $80,$c2,$02,$86 +.instrument3 +DB $cf,$20,$00,$c5 +.instrument4 +DB $00,$f0,$00,$c0 +.waveform +DB $dd,$dd,$dd,$dd,$dd,$dd,$dd,$dd +DB $00,$00,$00,$00,$00,$00,$00,$00 + +alarm_gbm:: + INCBIN "Data/Music/alarm.gbm.bin" + +intro_cinema_gbm:: + INCBIN "Data/Music/intro_cinema.gbm.bin" + +bs_gbm:: + INCBIN "Data/Music/jazzy.gbm.bin" + +lady_flower_gbm:: + INCBIN "Data/Music/lady_flower.gbm.bin" + +main_in_game_gbm:: + INCBIN "Data/Music/main_in_game.gbm.bin" + +haiku_gbm:: + INCBIN "Data/Music/maybe_haiku.gbm.bin" + +;--------------------------------------------------------------------- +SECTION "MusicData2",ROMX +;--------------------------------------------------------------------- + +moon_base_ba_gbm:: + INCBIN "Data/Music/moon_base_ba.gbm.bin" + +moon_base_haiku_gbm:: + INCBIN "Data/Music/moon_base_haiku.gbm.bin" + +;shroom_gbm:: + ;INCBIN "Data/Music/shroom.gbm.bin" + +cowboy_gbm:: + INCBIN "Data/Music/cowboy.gbm.bin" + +frosty_gbm:: + INCBIN "Data/Music/frosty.gbm.bin" + +fgbwar_gbm:: + INCBIN "Data/Music/fgbwar.gbm.bin" + +wedding_gbm:: + INCBIN "Data/Music/wedding.gbm.bin" + +takeoff_gbm:: + INCBIN "Data/Music/takeoff.gbm.bin" + +;--------------------------------------------------------------------- +SECTION "MusicData3",ROMX +;--------------------------------------------------------------------- + +spaceish_gbm:: + INCBIN "Data/Music/spaceish.gbm.bin" + +beehive_gbm:: + INCBIN "Data/Music/beehive.gbm.bin" + +hoedown_gbm:: + INCBIN "Data/Music/hoedown.gbm.bin" + +death_gbm:: + INCBIN "Data/Music/death.gbm.bin" + +;--------------------------------------------------------------------- +SECTION "MusicData4",ROMX +;--------------------------------------------------------------------- +jungle_gbm:: + INCBIN "Data/Music/jungle.gbm.bin" + +mysterious_gbm:: + INCBIN "Data/Music/mysterious.gbm.bin" + diff --git a/Source/Object.asm b/Source/Object.asm new file mode 100644 index 0000000..c6d045f --- /dev/null +++ b/Source/Object.asm @@ -0,0 +1,2263 @@ +; Object.asm +; 1.2.2000 by Abe Pralle +; defines and handles the objects (data of classes) of FGB + +;see Map.asm for location definitions of object RAM + +;object data: +;each object is 16 bytes long +; Byte Name Description +; ---- ------ ------------------------------------------------------------- +; 0 i_pos i index of left of object within map +; 1 j_pos j index of top of object within map +; 2 frame bits[2:0] - facing/frame of object. See (1) below. +; bits[4:3] - copy of timer's 2 LSB on upon last move +; bits[6:5] - index 0-3 on current path +; bit[7] - 1 if obj is currently a sprite, 0 if not +; 3 move Next move info +; bits[7:0] - counter 'till next move +; 4 limit Moves until AI switch + moves until fire again +; bits[3:0] - moveLimit. Decremented every move and +; sometimes used to switch states ("well this +; direction's not working"). +; - Used as direction of fire by hero +; - Used as bullet color by bullet. +; bits[7-4] - special flags +; 7 = travel straight, speed=1 (OBJBIT_THROWN) +; 5 health Amount of health left +; bits[5:0] - Amount of health / hit points left +; bits[7:6] - desired direction. When the AI is sliding +; to the side looking for forward progress +; these bits tell the original direction. +; bits[7:6] - Fire timer. When not equal to classes +; 6 destzone bits [7:4] Destination zone (0-15) (no zone zero) +; [3:0] Number of dandelion puffs on me +; 7 misc bits[7:0] - Used for class-specific AI +; 8 state Current state of movement/ai +; bits[5:0] - state. Commonly: +; 0 - Reset. Figure out from scratch what +; to do. +; 1 - Move straightforwardly towards waypoint. +; 2 - Move up to "moveLimit" (see byte 4 +; following) parallel to right of major +; axis, each time switching to state 3 to +; check for forward movement +; 3 - If can move forward along major axis do +; do and go back to state 1. If not go back +; to state 2. +; 4 - Same as (2) but moving left of major axis. +; 5 - Same as 3. +; 6 - Wander randomly. +; For heroes is spark timer +; bits[7:6] - attack dir state (direction to scan for +; attacking) +; 9 group bits[3:0] - group. Values: +; 0 - Free for all (shoot anything) +; 1 - Hero group +; 2-15 Monster A - Monster N +; 10 DESTL - actor dest low byte +; - eater low index +; - bullet damage +; - explosion initial frame +; 11 DESTH - actor dest high byte +; - eater high byte +; 12 SPRITELO - low ptr to sprite when obj is sprite +; 13 FIRETIMER - ticks before can fire again +; 14 unused +; 15 NEXT - index of next object or 0 for null + +; (1) Frames have the following definitions: +; 0 (%000) - Facing north, frame0 +; 1 (%001) - East, frame0 +; 2 (%010) - South, frame0 +; 3 (%011) - West, frame0 +; 4 (%100) - Facing north, frame1 (top of two tiles) +; 5 (%101) - East, frame1 (left of two tiles) +; 6 (%110) - South, frame1 (top of two tiles) +; 7 (%111) - West, frame1 (left of two tiles) + +; The object list works as follows: +; - All objects of the same class are stored as consecutive nodes in the +; linked list. +; - The following variables are used to keep track of the linked list: +; firstFree[1]: Index of first free object in objectExists[]. +; node is linked to the next free node and so on (stored +; in bank0 instead of bank3 like the others) +; headTable[256]: Indices of head of list of a certain class. Every two +; bytes marks the start of a LowByte, HighByte address +; tailTable[256]: Indices of tail of list of a certain class. + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Start.inc" + + +SECTION "ObjList",ROMX,BANK[CLASSROM] + +;--------------------------------------------------------------------- +; Routine: AddObjectsToObjList +; Arguments: none +; Description: Parses through the map (just loaded) and creates an +; object for each creature and adds it to the objList. +;--------------------------------------------------------------------- +AddObjectsToObjList:: + push bc + push de + push hl + + + ;initialize outer loop (b=0...mapHeight-1) + ld hl,map ;set hl to point to first tile in map + ld b,0 + + ;initialize inner loop (c=0...mapWidth-1) +.outer ld c,0 + ldio a,[firstMonster] + ld d,a + +.inner ld a,MAPBANK ;switch to map RAM bank + ld [$ff00+$70],a + ld a,[hl] ;get a class index from map + cp d ;is it < first monster index? + jr c,.notAnObject + + ;create an object for d monsta + push bc + push de + ;hl is ptr to location in map + ld c,a ;class index + call CreateObject ;returns de as ptr to object + pop de + pop bc + +.notAnObject + ;termination test for inner loop (is c==mapWidth?) + inc hl + inc c + ld a,[mapWidth] + cp c + jr nz,.inner + + ;skip excess width to make power of 2 pitch + ld a,[mapSkip] + ld d,0 + ld e,a + add hl,de + + ;termination test for outer loop (is b==mapHeight?) + inc b + ld a,[mapHeight] + cp b + jr nz,.outer + + ;call the INIT method of each object + ld b,METHOD_INIT + call IterateAllLists + + ;call the DRAW method of each object + ld b,METHOD_DRAW + call IterateAllLists + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routines: PointerDEToIndex +; PointerHLToIndex +; Arguments: de/hl - pointer $d010-$dff0 to object +; Returns: a - index 1-255 of object +;--------------------------------------------------------------------- +PointerDEToIndex:: + push de + ld a,d + and %00001111 + ld d,a + ld a,e + and %11110000 + or d + swap a + pop de + ret + +PointerHLToIndex:: + push hl + ld a,h + and %00001111 + ld h,a + ld a,l + and %11110000 + or h + swap a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: ResetList +; Arguments: none +; Description: Sets all elements of headTable[] and tailTable[] to +; point to null. Sets up all 256 objExists flags to +; zero and [firstFreeObj] to 1. A few other misc things +;--------------------------------------------------------------------- +ResetList:: + push af + push bc + push de + push hl + + ;Switch to the objectList RAM bank + ld a,OBJLISTBANK + ld [$ff00+$70],a + + ;Set object zero (which should never be accessed) to + ;all-null to help ID infinite loops. + ld hl,objects + ld b,16 + xor a +.setObjNullLoop + ld [hl+],a + dec b + jr nz,.setObjNullLoop + + ;Clear all elements of headTable[] and tailTable[] to + ;point to null. tailTable[] follows headTable[] in memory so + ;in total that's 512 bytes we need to set (or 256*2) + ld hl,headTable + xor a + ld c,0 ;e.g. counter of 256 + +.loop1 ld [hl+],a + ld [hl+],a + dec c + jr nz,.loop1 + + ;Switch to the object RAM bank + ld a,OBJBANK + ld [$ff00+$70],a + + ;Set firstFreeObj to point to the first object, 1 ($d010) + ld a,1 + ld [firstFreeObj],a + + ;255 objExists flags to zero + ld a,OBJLISTBANK + ld bc,255 + ld d,0 + ld hl,objExists+1 + call MemSet + + ;set objExists[0] to 1 to prevent it from being allocated + ld a,1 + ld [objExists],a + + ld a,((objExists+1) & $ff) + ld [iterateNext],a + ld a,(((objExists+1)>>8) & $ff) + ld [iterateNext+1],a + + ld a,255 + ld [numFreeObjects],a + + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: ClearFGBGFlags +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Clears bgAttributes and fgAttributes +;--------------------------------------------------------------------- +ClearFGBGFlags:: + push bc + push de + push hl + + ld a,OBJLISTBANK + ld bc,256 + ld d,0 + ld hl,bgAttributes + call MemSet + + ld a,OBJLISTBANK + ld bc,256 + ld d,0 + ld hl,fgAttributes + call MemSet + +IF 0 + ;set all bgAttribute flags to zero + ld c,0 + ld hl,bgAttributes + xor a +.bgAttrLoop + ld [hl+],a + dec c + jr nz,.bgAttrLoop + + ;set all fgAttribute flags to zero + ld c,0 + ld hl,fgAttributes + xor a +.attrLoop + ld [hl+],a + dec c + jr nz,.attrLoop +ENDC + + ld a,OBJLISTBANK + ld bc,256 + ld d,0 + ld hl,associatedIndex + call MemSet + + ld a,OBJLISTBANK + ld bc,512 + ld d,0 + ld hl,classLookup + call MemSet + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CreateObject +; Arguments: c - class index of object to create +; hl - ptr to location in map +; Returns: de - address of object +; Alters: af,de +; Description: Creates and adds the specified object into the list +; providing there's room. Equivalent to the following +; C code: +; +; if(!firstFreeObj) return 0; +; newObj = firstFreeObj; +; firstFreeObj = (next free obj index); +; if(!headTable[c]){ +; headTable[c] = tailTable[c] = newObj; +; }else{ +; tailTable[c]->nextItem = newObj; +; tailTable[c] = newObj; +; } +; return newObj; +;--------------------------------------------------------------------- +CreateObject:: + push af + push bc + push hl + + ld a,OBJBANK ;switch in Object RAM + ld [$ff00+$70],a + + ;see if there's room for a new object + ;if(!firstFreeObj) return 0; + ld a,[firstFreeObj] + or a ;check it out + jr nz,.freeNodeExists + + ld de,0 ;return null + jp .doneHL + +.freeNodeExists + push bc ;save class index for a bit + ;newObj = firstFreeObj + ;setup de to point to free node + ld [curObjIndex],a + call IndexToPointerDE ;de is now ptr to free node + + ;store location ptr (hl) + ld a,l + ld [de],a ;OBJ_IPOS + inc de + ld a,h + ld [de],a ;OBJ_JPOS + dec de + + ld hl,numFreeObjects + dec [hl] + + ;firstFreeObj = (next free object index) + ld a,OBJLISTBANK + ld [$ff70],a + ld a,[firstFreeObj] + ld h,((objExists>>8) & $ff) + inc a + jr z,.foundNextFree ;no free objects + ld l,a +.lookAtNextObj + ld a,[hl+] + or a + jr nz,.thisObjNotFree + + dec hl + ld a,l + jr .foundNextFree + +.thisObjNotFree + ld a,l + or a + jr nz,.lookAtNextObj + ;no free objects (1st is zero) + +.foundNextFree + ld [firstFreeObj],a + + ;if(!headTable[c]){ + ld h,((headTable>>8) & $ff) + ld l,c + ld a,[hl] ;get object index + or a + jr nz,.headExists + +.noHead ;headTable[c] = curObjIndex + ld a,[curObjIndex] + ld [hl],a + + ;tailTable[c] = curObjIndex + ld h,((tailTable>>8) & $ff) ;hl is tailTable[c] + ld [hl],a + + ;switch in object RAM + ld a,OBJBANK + ld [$ff00+$70],a + + jr .setNextToNull + +.headExists + ;oldTail = tailTable[c] + ld h,((tailTable>>8) & $ff) + ld a,[hl] ;old tail index + push de + call IndexToPointerDE + ld b,d + ld c,e ;bc = oldTail + pop de + + ;tailTable[c] = curObjIndex + ld a,[curObjIndex] + ld [hl],a + + ;switch in object RAM + ld a,OBJBANK + ld [$ff00+$70],a + + ;oldTail->nextItem = newObj + ld hl,OBJ_NEXT ;offset to get to nextItem + add hl,bc ;hl = &oldTail->nextItem + ld a,[curObjIndex] + ld [hl],a ;oldTail->nextItem = newObj + +.setNextToNull + ;newObj->nextItem = null + ld hl,OBJ_NEXT ;offset to get to nextItem low byte + add hl,de ;hl = &newObj->nextItem + xor a + ld [hl],a ;newObj->nextItem = null + + ;objExists[objectIndex] = 1; + ld a,OBJLISTBANK + ld [$ff00+$70],a + call GetObjectIndex ;sets up hl + ld a,1 + ld [hl],a + + ;objClassLookup[objIndex] = classIndex + ld h,((objClassLookup>>8) & $ff) + pop bc ;get class lookup in c + ld [hl],c + +.doneHL pop hl + ;de is return value + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: CreateInitAndDrawObject +; Arguments: c - class index to create +; hl - ptr to location in map +; Returns: de - address of object +; Alters: af,de +; Description: Creates and adds the specified object into the list +; providing there's room. +;--------------------------------------------------------------------- +CreateInitAndDrawObject:: + push bc + push hl + + call CreateObject + ld a,d + or a + jr z,.done + + ld b,METHOD_INIT + call CallMethod + ld b,METHOD_DRAW + call CallMethod + +.done + pop hl + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: DeleteObject +; Arguments: c - class index of object to delete +; de - address of object +; Alters: af +; Description: Deletes the specified object from the class index's +; object list and returns it to the free node list. +; Equivalent to the following C code: +; +; //find the object +; prev = 0; +; for(cur=headTable[c]; cur; cur=cur->nextItem){ +; if(cur==obj) break; +; prev = cur; +; } +; if(!cur) goto addToFreeList; //object not found +; +; //handle special cases of head and tail +; if(cur==headTable[c]){ +; headTable[c] = cur->nextItem; +; }else{ +; prev->nextItem = cur->nextItem; +; } +; if(cur==tailTable[c]){ +; tailTable[c] = prev; +; } +; +; addToFreeList: +; firstFreeObj = min(firstFreeObj, curIndex); +; objExists[objIndex] = 0; +;--------------------------------------------------------------------- +DeleteObject:: + push bc + push de + push hl + + ld hl,numFreeObjects + inc [hl] + + ;retrieve & save index of next object + ld a,OBJBANK + ld [$ff70],a + ld hl,OBJ_NEXT + add hl,de + ld a,[hl] + ld [nextObjIndex],a + + ;switch in objectList RAM + ld a,OBJLISTBANK + ld [$ff00+$70],a + + ;hl = &headTable[c] + ld h,((headTable>>8) & $ff) + ld l,c + + ;c = object index to remove + call PointerDEToIndex + ld [curObjIndex],a + ld c,a + ;push de ;save original ptr to object + + ; prev = 0 + ; for(cur=headTable[c]; cur!=obj; cur=cur->nextItem){ + ; prev = cur; + ; } + + ;b is prev index, a is cur index + ld b,0 ; prev = 0; + ld a,[hl] ; cur=headTable[c] + push hl ; save headTable + push hl ; save headTable again + + push af + ld a,OBJBANK + ld [$ff70],a + pop af + + ;cur equal to desired? +.findIt + cp c + jr z,.foundIt + + ;prev = cur + ld b,a + + ;cur=cur->nextItem + call IndexToPointerHL + ld de,OBJ_NEXT + add hl,de + + ld a,[hl] + jr .findIt + +.foundIt + pop hl ;retrieve headTable[c] + + ld a,OBJLISTBANK + ld [$ff70],a + + ;check value of prev to determine if cur is head or not + ld a,b + or a + + ;is head, set headTable[c] = cur->nextObj + jr z,.afterCheckHead + +.notHead + ;prev->nextObj = cur->nextObj + call IndexToPointerHL ;'a' is prevObj + ld de,OBJ_NEXT + add hl,de + ld a,OBJBANK + ld [$ff70],a + +.afterCheckHead + ld a,[nextObjIndex] + ld [hl],a + + ;-------------------------check tail----------------- + ; if(cur==tailTable[c]){ + ; tailTable[c] = prev; + ; } + ld a,OBJLISTBANK + ld [$ff70],a + pop hl ;retrieve headTable[c] + ld h,((tailTable>>8) & $ff) ;make it tailTable[c] + + ld a,c ;c is cur (found) obj + cp [hl] + jr nz,.afterCheckTail + + ld [hl],b ;change tail = prev + +.afterCheckTail + ;objExists[objIndex] = 0; + ld h,((objExists>>8) & $ff) ;hl = &objExists[objIndex] + ld a,[curObjIndex] + ld l,a + xor a + ld [hl],a + + ;firstFreeObj = min(firstFreeObj, curObjIndex) + ld a,[firstFreeObj] + cp l ;compare to curObjIndex + jr c,.afterSetFirstFree ;no change + + ld a,l + ld [firstFreeObj],a + +.afterSetFirstFree + + ;pop de ;retrieve original pointer to object + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: IterateAllLists +; Arguments: b - offset of method to call on a given object +; Description: Loops through all the objects in each class calling a +; specified method on each. Makes use of the IterateList +; routine to do so. +; +; Equivalent to the following C code: +; +; void IterateAllLists(void *fnptr()){ +; for(i=0; i<256; i++){ +; IterateList(headTable[i],fnptr); +; } +; } +; +;--------------------------------------------------------------------- +IterateAllLists:: + push bc + push de + push hl + + ld hl,headTable ;start of array of ptrs to heads of list + ld c,0 ;loop 0...numClasses - 1 + +.loop ld a,OBJLISTBANK ;switch in objectList RAM + ld [$ff00+$70],a + + ld a,[hl+] ;de = headTable[i] + or a + jr z,.afterIterate + + call IndexToPointerDE + call IterateList + +.afterIterate + inc c + jr nz,.loop + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: IterateList +; Arguments: b - offset of method to call on a given object +; c - class index of object +; de - ptr to current object +; Description: Given a pointer to a list node (presumably the head), +; loops though all linked nodes calling a specified method +; on each object. +; +; Equivalent to the following C code: +; +; void IterateList(Node*cur, void *fnptr()){ +; if(!cur) return; +; do{ +; cur->fnptr(); //not really a C cmd I know! +; cur = cur->nextItem; +; }while(cur); +; } +; +;--------------------------------------------------------------------- +IterateList:: + push bc + push de + push hl + + ldio a,[curObjWidthHeight] + push af + + ;pre-test curPtr to avoid unnecessary work if null + ld a,d ;test high byte of ptr + or a + jr z,.done + + ;save class index + ld a,c + ld [delTempL],a + ld a,b + ld [delTempH],a ;and method type + + ld a,OBJLISTBANK + ld [$ff70],a + + ;convert offset into actual address of class method to call + ld a,b ;save function offset + ld b,0 ;clear high byte of bc + sla c ;shift c one left + rl b ;bit shifted out of c into b + ld hl,classLookup + add hl,bc ;hl is &classLookup[classIndex*2] + + ld c,a ;method offset into c + ld a,[hl+] + ld b,a ;store LOW byte of addr in b + ld h,[hl] ;get high byte + ld l,b ;hl is now ptr to class + ld b,0 ;clear high byte of bc + add hl,bc ;hl is now ptr to ptr to class method + + call GetMethodAddrFromPointer + +.loop ;get ptr to next before calling method + ld a,OBJBANK ;switch in object RAM + ld [$ff00+$70],a + + push hl + ld hl,OBJ_NEXT + add hl,de + ld a,[hl] + call IndexToPointerHL + ld b,h + ld c,l + pop hl + push bc ;save ptr to next on stack + + push hl + ld bc,.returnAddress ;save return address on stack + push bc + ld a,[delTempL] ;class index into c + ld c,a + + ;----call super methods + push bc + push de + ld a,[delTempH] ;method index + cp METHOD_INIT + jr nz,.checkSuperDie + + call SuperInit + jr .afterSuperDie + +.checkSuperDie + cp METHOD_DIE + jr nz,.afterSuperDie + + call SuperDie + +.afterSuperDie + ld a,b + cp METHOD_CHECK + jr nz,.afterCheckIdle + ld a,[allIdle] + or a + jr z,.afterCheckIdle + ;can't be explosion + pop de + pop bc + ld a,c + cp $ff + jr z,.returnAddress + jr .afterPopDEBC +.afterCheckIdle + + pop de + pop bc +.afterPopDEBC + ;--------- + + push hl + call SetObjWidthHeight + pop hl + jp hl ;start class method (de is cur) +.returnAddress + + pop hl + pop de ;de = de->nextItem + ld a,d + or a ;we done? + jr nz,.loop + +.done pop af + ldio [curObjWidthHeight],a + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindObject +; Arguments: c - class index of object to find +; de - location of object +; Returns: de - ptr to object +; a - non-zero if object was found +; Alters: af,de +; Description: Given a class and a location, finds the corresponding +; object. +; Note: Leaves the RAM bank set to OBJECT mem +; +; cur = headTable[c]; +; while(cur){ +; if(cur->loc == loc) return cur; +; cur = cur->nextItem; +; } +;--------------------------------------------------------------------- +FindObject:: + push bc + ;de is return value + push hl + + ;find the head of the list + ld a,OBJLISTBANK ;switch in objectList RAM + ld [$ff00+$70],a + + ;find byte index into headTable array + ld h,((headTable>>8) & $ff) + ld l,c + ld a,[hl] + call IndexToPointerHL ;hl is head of list + + ld bc,OBJ_NEXT-1 ;offset to add to hl during loop + + ;loop while our pointer is non-null + ld a,OBJBANK ;switch in object RAM + ld [$ff00+$70],a + +.terminationTest + ld a,h ;high byte of ptr + or a ;null? + jr nz,.pointerOkay + +.pointerNull + ld de,0 ;return null + jr .done + +.pointerOkay + ;test to see if object->loc == loc + ld a,[hl+] ;compare low byte + cp e + jr nz,.continue + ld a,[hl] ;compare high byte + cp d + jr nz,.continue + +.foundMatch + dec hl + jr .returnMatch + +.continue + add hl,bc ;add offset to get to nextItem + ld a,[hl] + call IndexToPointerHL ;cur = cur->nextItem + jr .terminationTest + +.returnMatch + ld d,h + ld e,l + +.done pop hl + ;de is return value + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CallMethod +; Arguments: b - offset of method to call +; c - class index of object +; de - ptr to object +; Returns: a - return value +; Alters: af +; Description: Calls the a class method passing in the location of an +; associated object. +; If calling Init or Die then calls SuperInit or +; or SuperDie first. +;--------------------------------------------------------------------- +CallMethod:: + ld a,b + cp METHOD_CHECK + jr nz,.afterCheckIdle + + ld a,[allIdle] + or a + jr z,.afterCheckIdle + ;can't be explosion + ld a,c + cp $ff + ret nz + +.afterCheckIdle + push bc + push de + push hl + ldio a,[curObjWidthHeight] + push af + + call SetObjWidthHeight + + ld a,b + cp METHOD_INIT + jr nz,.checkSuperDie + + call SuperInit + jr .afterSuperDie + +.checkSuperDie + cp METHOD_DIE + jr nz,.afterSuperDie + + call SuperDie + +.afterSuperDie + ;find the base address of class and add method offset + ;get offset into classLookup + ld l,c + ld a,OBJLISTBANK + ld [$ff70],a + xor a + sla l + rla + add ((classLookup>>8) & $ff) + ld h,a ;hl is &classLookup[c] + ld a,[hl+] + add b ;add offset of method + ld h,[hl] + ld l,a ;hl is addr of class methods + ld a,0 + adc h + ld h,a ;hl is addr of specific method + + call GetMethodAddrFromPointer + + ld a,c ;store class index in A temporarily + ld bc,.returnAddress ;save return address on stack + push bc + ld c,a ;class index into c + jp hl ;start class method (de is cur) +.returnAddress + +.done + ld h,a ;save return value + pop af + ldio [curObjWidthHeight],a + ld a,h ;restore return value + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetObjWidthHeight +; Arguments: c - class index +; Returns: Nothing. +; Alters: af,hl +; Description: Sets up [curObjWidthHeight] with either 1 (for 1x1) +; or 2 (2x2) +;--------------------------------------------------------------------- +SetObjWidthHeight:: + ;set the tile width and height to either 1x1 or 2x2 + ld a,TILEINDEXBANK + ld [$ff70],a + ld h,((fgAttributes>>8) & $ff) + ld l,c + ld a,[hl] + rrca + swap a + and 1 + inc a ;one or two + ldio [curObjWidthHeight],a + ret + +;--------------------------------------------------------------------- +; Routine: GetObjectIndex +; Arguments: de - ptr to object +; Returns: hl - &objExists[objIndex] +; Alters: af,hl +;--------------------------------------------------------------------- +GetObjectIndex: + call PointerDEToIndex + ld h,((objExists>>8) & $ff) + ld l,a + ret + +;--------------------------------------------------------------------- +; Routine: IterateMaxObjects +; Arguments: b - offset of method to call on a given object +; c - max objects to iterate through +; Alters: af +; Description: Loops through the next 256 objects indices. If an +; object exists then the specified method is called on +; it and one is added to the maxObjects counter. When +; "maxObjects" have been handled the routine returns +; and picks up again next time where it left off. Each +; time the counter wraps around the object timers are +; incremented +;--------------------------------------------------------------------- +IterateMaxObjects:: + push bc + push de + push hl + + ld a,OBJLISTBANK + ld [$ff00+$70],a + + ld a,[iterateNext] + ld l,a + ld a,[iterateNext+1] + ld h,a + +.outer ld e,0 + +.inner ld a,[hl+] ;pick up the next flag + + or a ;non-zero? + jr z,.continue + + ;found an existing object + push de + push hl + + dec hl ;go back to where we found it + + ;convert objIndex hl into objAddress de + ld a,l + call IndexToPointerDE + + ;get the class index + ;hl = &objClassLookup[objIndex] + ld h,((objClassLookup>>8) & $ff) + ld a,[hl] ;what's the class index? + ld h,c ;stow c for a sec + ld c,a + + call CallMethod + + ld c,h ;retrieve c from storage + + pop hl + pop de + dec c ;used one of our max checks + + ld a,OBJLISTBANK ;be sure & point back to our + ld [$ff00+$70],a ;list RAM + +.continue + ;wrap around hl + ld a,h ;is hl < objExists + 256? + cp (((objExists>>8)&$ff)+1) + jr c,.hlOkay + + ld hl,objExists+1 ;wrap around to beginning + call UpdateObjTimers ;update timers + +.hlOkay + xor a + cp c + jr z,.skipUnused ;bust out if we've checked enough + + dec e + jr nz,.inner + +.skipUnused + +.done + ;save current value of hl + ld a,l + ld [iterateNext],a + ld a,h + ld [iterateNext+1],a + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: DeleteObjectsOfClass +; Arguments: bc - class to delete objects +; Alters: af +; Description: +;--------------------------------------------------------------------- +DeleteObjectsOfClass:: + push de + push hl + + ld a,OBJLISTBANK + ld [$ff70],a + + ld e,1 + ld hl,classLookup+2 + +.loop ld a,[hl+] + cp c + jr nz,.afterCheck + ld a,[hl] + cp b + jr nz,.afterCheck + + ld a,e + call DeleteObjectsOfClassIndex + +.afterCheck + inc hl + inc e + jr nz,.loop + + pop hl + pop de + ret + +;--------------------------------------------------------------------- +; Routine: DeleteObjectsOfClassIndex +; Arguments: a - class index to delete objects +; Alters: af,hl +; Description: Deletes all objects of the specified class index type +;--------------------------------------------------------------------- +DeleteObjectsOfClassIndex:: + push bc + push de + push hl + + ld c,a ;class index in c + + ld a,TILEINDEXBANK + ldio [$ff70],a + + ld h,((headTable>>8) & $ff) + ld l,c + +.loop ld a,[hl] ;get head object in de + or a + jr z,.done + call IndexToPointerDE + + ld b,METHOD_DIE + call IterateList + + ld a,OBJLISTBANK + ld [$ff70],a + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetFirst +; Arguments: c - class index +; Returns: de - head of list or null +; a - null if no first object +; zflag - or a +; Alters: af,de +;--------------------------------------------------------------------- +GetFirst:: + call GetHead + call IndexToPointerDE + ret + +;--------------------------------------------------------------------- +; Routine: GetNextObject +; Arguments: de - current object +; Returns: a - null if no next object +; de - next object +; zflag - or a +; Alters: af,de +;--------------------------------------------------------------------- +GetNextObject:: + call GetNext + call IndexToPointerDE + ld a,d + or a + ret + +;--------------------------------------------------------------------- +; Routine: GetNext +; Arguments: de - current object +; Returns: a - index of next object or null +; Alters: af +;--------------------------------------------------------------------- +GetNext:: + push hl + + ld a,OBJBANK + ld [$ff70],a + + ld hl,OBJ_NEXT + add hl,de + ld a,[hl] + + pop hl + or a + ret + +;--------------------------------------------------------------------- +; Routine: SetNext +; Arguments: a - index of next object +; de - current object +; Returns: Nothing. +; Alters: Nothing. +;--------------------------------------------------------------------- +SetNext:: + push hl + push af + ld a,OBJBANK + ldio [$ff70],a + pop af + + ld hl,OBJ_NEXT + add hl,de + ld [hl],a + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetHead +; Arguments: a - index to set head to +; c - class index +; Returns: None. +; Alters: af +;--------------------------------------------------------------------- +SetHead:: + push hl + push af + ld a,OBJLISTBANK + ld [$ff70],a + pop af + + ld h,((headTable>>8) & $ff) + ld l,c + + ld [hl],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetHead +; Arguments: c - class index +; Returns: a - index of object at head or null if empty list +; Alters: af +;--------------------------------------------------------------------- +GetHead:: + push hl + ld a,OBJLISTBANK + ld [$ff70],a + + ld h,((headTable>>8) & $ff) + ld l,c + + ld a,[hl] ;get head object index + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetTail +; Arguments: c - class index +; Returns: a - index of object at tail or null if empty list +; de - list +; Alters: af +;--------------------------------------------------------------------- +GetTail:: + push hl + ld a,OBJLISTBANK + ld [$ff70],a + + ld h,((tailTable>>8) & $ff) + ld l,c + + ld a,[hl] ;get tail object index + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: SetTail +; Arguments: a - index to set head to +; c - class index +; Returns: Nothing. +; Alters: Nothing. +;--------------------------------------------------------------------- +SetTail:: + push hl + push af + ld a,OBJLISTBANK + ld [$ff70],a + pop af + + ld h,((tailTable>>8) & $ff) + ld l,c + + ld [hl],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: GetNumObjects +; Arguments: c - class index +; Returns: a - object count for class +; zflag - or a +; Alters: af +;--------------------------------------------------------------------- +GetNumObjects:: + push bc + push de + push hl + + ld b,0 + call GetFirst + jr z,.countFinished + +.getNext + inc b + call GetNextObject + jr z,.countFinished + jr .getNext + +.countFinished + ld a,b + or a + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetAssociated +; Arguments: c - class index +; Returns: a - associated class index +; Alters: af +;--------------------------------------------------------------------- +GetAssociated:: + push hl + ld a,TILEINDEXBANK + ld [$ff70],a + ld h,((associatedIndex>>8)&$ff) + ld l,c + ld a,[hl] + pop hl + ret + +;--------------------------------------------------------------------- +SECTION "ObjListHome",ROM0 +;--------------------------------------------------------------------- + +;--------------------------------------------------------------------- +; Routine: InitFOF +; Arguments: none +; Returns: nothing +; Alters: af +; Description: Initializes the Friend Or Foe Table so that each group +; is friends only with itself except for: +; - FFA group friends with no one (not even selves) +; - MONSTERM/N (groups M&N) set to friends with all +; but FFA +; - MONSTERB set to friends with hero +;--------------------------------------------------------------------- +InitFOF:: + push bc + push de + push hl + + ld a,OBJLISTBANK + ld [$ff70],a + + ld c,0 ;loop 256 times + ld hl,FOFTable + xor a + +.loop1 ld [hl+],a + dec c + jr nz,.loop1 + + ld hl,FOFTable+17 + ld c,15 + ld a,1 + ld de,16 ;offset + +.loop2 ld [hl+],a + add hl,de + dec c + jr nz,.loop2 + + ;set monster N to be friends with all but FFA + ;row + ld hl,FOFTable+30 ;row 2, second to last column + ld c,15 ;set next 15 rows +.loop30 ld [hl],a + add hl,de + dec c + jr nz,.loop30 + + ;column + ld hl,FOFTable+(14*16)+1 + ld c,15 +.loop40 ld [hl+],a + dec c + jr nz,.loop40 + + ;set monster N to be friends with all but FFA + ;row + ld hl,FOFTable+31 ;row 2, last column + ld c,15 ;set next 15 rows +.loop3 ld [hl],a + add hl,de + dec c + jr nz,.loop3 + + ;column + ld hl,FOFTable+(15*16)+1 + ld c,15 +.loop4 ld [hl+],a + dec c + jr nz,.loop4 + + ld a,1 + ld b,GROUP_HERO + ld c,GROUP_MONSTERB + call SetFOF + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: SetFOF +; Arguments: a - value to set to (0=enemies or 1=friends) +; b - group 1 +; c - group 2 +; Returns: nothing +; Alters: af +; Description: Sets an entry in the FOF table +;--------------------------------------------------------------------- +SetFOF:: + push hl + + ;combine b and c in l + push af + + ld a,OBJLISTBANK + ld [$ff70],a + + ld a,b + swap a + or c + ld l,a + ld h,((FOFTable>>8) & $ff) + pop af + + ;set the one entry + ld [hl],a + + ;set the reverse entry + swap l + ld [hl],a + + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: GetFOF +; Arguments: b - group 1 +; c - group 2 +; Returns: a - 1=friend, 0=foe +; Alters: af +; Description: Sets an entry in the FOF table +;--------------------------------------------------------------------- +GetFOF:: + push hl + + ld a,OBJLISTBANK + ld [$ff70],a + + ld a,b + swap a + or c + ld l,a + ld h,((FOFTable>>8) & $ff) + + ld a,[hl] + + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: LinkRemakeLists +; Arguments: None. +; Alters: af +; Returns: Nothing. +; Description: Initializes some values. +; objTimerBase = 0 +; objTimer60ths = 0 +; heroTimerBase = 0 +; heroTimer60ths = 0 +; oamFindPos = 0 +; baMoved = 0 +; bsMoved = 0 +; iterateNext = objExists + 1 +; +; Remakes the tailTable. +; Waits for a VBLANK +; Resets $ff+vblankTimer to zero +; Resets updateTimer to zero +;--------------------------------------------------------------------- +LinkRemakeLists:: + push bc + push de + push hl + + ;initialize some values + xor a + ld [objTimerBase],a + ld [objTimer60ths],a + ld [heroTimerBase],a + ld [heroTimer60ths],a + ld [oamFindPos],a + ld [baMoved],a + ld [bsMoved],a + ld de,objExists+1 + ld hl,iterateNext + ld [hl],e + inc hl + ld [hl],d + + ld a,OBJLISTBANK + ld [$ff70],a + + ;----remake tailTable----------------------------------------- + ;first go through and zero out contents of tailTable + ld hl,tailTable + ld c,0 ;loop 256 times + xor a +.zeroTailTable + ld [hl+],a + dec c + jr nz,.zeroTailTable + + ;start at the head of each list and follow each link until + ;a null link is found. That will be the tail. + ld de,headTable +.getNextListHead + ld a,[de] + or a ;this linked list null? + jr z,.afterMakeTail + + ld b,a + ld a,OBJBANK + ld [$ff70],a + ld a,b ;index of object + ld bc,OBJ_NEXT +.followLink + call IndexToPointerHL ;convert into object pointer + add hl,bc ;set HL to point to link + ld a,[hl] ;get link + or a + jr nz,.followLink + + ;HL is the tail + OBJ_NEXT + ;convert HL to obj index and use that to set up + ;entry into tailTable + ld a,OBJLISTBANK + ld [$ff70],a + ld a,l ;align hl on 16-byte boundary + and %11110000 + ld l,a + call PointerHLToIndex + ld d,((tailTable>>8) & $ff) ;de is &tailTable[class] + ld [de],a + ld d,((headTable>>8) & $ff) ;de is &headTable[class] + +.afterMakeTail + inc de + ld a,e + or a + jr nz,.getNextListHead + + xor a + ldio [vblankTimer],a + ldio [updateTimer],a + + ;count the number of free objects + ld c,$ff + ld hl,objExists+1 +.countFree + ld a,[hl+] + or a + jr z,.countContinue + dec c +.countContinue + ld a,h + cp $d5 + jr nz,.countFree + ld a,c + ld [numFreeObjects],a + + call SetBGSpecialFlags + + ld b,METHOD_DRAW + call IterateAllLists + + call ClearBackBuffer + + call RestrictCameraToBounds + call ScrollToCamera + call DrawMapToBackBuffer + + ;turn on sound master control + ld a,$80 + ld [$ff26],a + + ld a,$ff + ld [$ff24],a ;full volume both channels + ld [$ff25],a ;all sounds to both channels + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GetClass +; Arguments: de - current object +; Returns: c - class index of object +; Alters: af,c +;--------------------------------------------------------------------- +GetClass:: + push hl + ld a,OBJLISTBANK + ldio [$ff70],a + call PointerDEToIndex + ld h,((objClassLookup>>8) & $ff) + ld l,a + ld c,[hl] ;obj class + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: InstanceOf +; Arguments: c - class index of object +; hl - class (e.g. classWallCreature) +; Returns: a - 1 if this instanceof, 0 if not instanceof +; Alters: af,hl +;--------------------------------------------------------------------- +InstanceOf:: + push de + ld d,h + ld e,l + call GetClassMethodTable + ld a,d + cp h + jr nz,.false + ld a,e + cp l + jr nz,.false + ld a,1 + pop de + ret +.false + pop de + xor a + ret + +;--------------------------------------------------------------------- +; Routine: GetClassMethodTable +; Arguments: c - class index of object +; Returns: hl - ptr to method vector table +; Alters: af,hl +;--------------------------------------------------------------------- +GetClassMethodTable:: + ld a,OBJLISTBANK + ldio [$ff70],a + + ld h,0 + ld l,c + sla l + rl h + push bc + ld bc,classLookup + add hl,bc + pop bc + + ld a,[hl+] + ld h,[hl] + ld l,a + ret + + +;--------------------------------------------------------------------- +; Routine: GetFGMapping +; Arguments: c - class index +; Returns: a - tile index mapped to class +; Alters: af, hl +;--------------------------------------------------------------------- +GetFGMapping:: + ld a,TILEINDEXBANK + ldio [$ff70],a + ld h,((fgTileMap>>8) & $ff) + ld l,c + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: SetFGMapping +; Arguments: a - tile index to set to +; c - class index +; Returns: Nothing. +; Alters: af, hl +;--------------------------------------------------------------------- +SetFGMapping:: + push af + ld a,TILEINDEXBANK + ldio [$ff70],a + pop af + ld h,((fgTileMap>>8) & $ff) + ld l,c + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: GetBGMapping +; Arguments: c - class index +; Returns: a - tile index mapped to class +; Alters: af, hl +;--------------------------------------------------------------------- +GetBGMapping:: + ld a,TILEINDEXBANK + ldio [$ff70],a + ld h,((bgTileMap>>8) & $ff) + ld l,c + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: SetBGMapping +; Arguments: a - tile index to set to +; c - class index +; Returns: Nothing. +; Alters: af, hl +;--------------------------------------------------------------------- +SetBGMapping:: + push af + ld a,TILEINDEXBANK + ldio [$ff70],a + pop af + ld h,((bgTileMap>>8) & $ff) + ld l,c + ld [hl],a + ret + +;--------------------------------------------------------------------- +; Routine: CheckEachHero +; Arguments: a - skip hero1 if hero0 return true (1=yes, 0=no) +; hl - routine to call +; Returns: a - 1 or 0 result of last function called +; Alters: all +; Description: loads {A} with hero0_index and then hero1_index, +; calling the routine pointer with each. +;--------------------------------------------------------------------- +CheckEachHero:: + push af + + ld a,[hero0_index] + or a + jr z,.checkHero1 + push hl + ld de,.returnPoint0 + push de ;return address + jp hl +.returnPoint0 + pop hl + or a + jr z,.checkHero1 + + ;second is optional + pop af + or a + ret nz ;optional okay + + push af +.checkHero1 + pop af + ld a,[hero1_index] + or a + ret z + + ld de,.returnAddress1 + push de + jp hl ;will return to my parent +.returnAddress1 + ret + +;--------------------------------------------------------------------- +; Routine: RemoveHero +; Arguments: c - hero class index +; Returns: Nothing. +; Alters: af +; Description: Saving heroes current health etc into heroX_data. +; If its health is zero: +; - restores health to full (incorrect) +; - changes map to [respawnMap] if local hero, leaves +; map be if remote hero. +; Does nothing if class index is null. +; Removes the hero from the map. +; If local, sets [heroesPresent] to zero. If remote +; then remote hero flag is removed by RemoveRemoteHero +;--------------------------------------------------------------------- +RemoveHero:: + ld a,c + or a + ret z + + push bc + push de + push hl + + call GetFirst ;get the hero object in de + call GetHealth + or a + jr nz,.afterDeath + +IF INFINITEHEALTH==0 + ;----dead, create an explosion---- + call GetFGAttributes + and %111 ;isolate color + ld [bulletColor],a + call GetCurLocation + ld a,l + ld [bulletLocation],a + ld a,h + ld [bulletLocation+1],a + ld b,16 ;initial frame + call CreateExplosion +ENDC + +.afterDeath + ld a,[hero0_index] + cp c + jr nz,.handleHero1 + + ;----hero 0 (local)----- + call GetPuffCount + ld [hero0_puffCount],a + call GetHealth + ld [hero0_health],a + ld b,a + ld hl,hero0_data + ld a,[amLinkMaster] + or a + jr z,.removeRemote + jr .removeLocal + +.handleHero1 + ;----hero 1 (remote)---- + call GetPuffCount + ld [hero1_puffCount],a + call GetHealth + ld [hero1_health],a + ld b,a + ld hl,hero1_data + ld a,[amLinkMaster] + or a + jr z,.removeLocal + jr .removeRemote + +.removeLocal + push bc + push hl + call GetFacing + ld c,a + call RemoveFromMap + xor a + ld [heroesPresent],a + pop hl + pop bc + + push bc + push de + push hl + ld de,classDoNothing + call GetClassMethodTable + ld b,h + ld c,l + call ChangeClass + pop hl + pop de + pop bc + + ld a,b + or a + jr nz,.done ;wasn't dying, just leaving + +IF INFINITEHEALTH==0 + ;pause for a second + ld a,30 + call Delay + + ;fade to black + ;ld a,30 + ;call SetupFadeToBlack + ;call WaitFade + + ;----respawn at the appropriate map---- + ld de,HERODATA_ENTERDIR + add hl,de + ld a,EXIT_D + ld [hl],a + + call UpdateState + + ld hl,$1500 + ld a,l + ld [curLevelIndex],a + ld a,h + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a +ENDC + jr .done + +.removeRemote + call RemoveRemoteHero + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CallBGAction +; Arguments: a - action type (BGACTION_HIT) +; c - class +; hl - map location of bg tile +; Returns: 'a' zflag from action + a's zflag, normally: +; 0 - no explosion +; non-zero - explosion +; Alters: af +; Description: +;--------------------------------------------------------------------- +CallBGAction:: + push bc + push de + push hl + + ;ensure class IS a bg class + ld d,a + ldio a,[firstMonster] + ld e,a + ld a,c + or a + jr z,.returnAddress ;null tile + cp e + jr nc,.returnAddress ;is a monster (myself?) + ld a,d + + ;save return address on stack + ld de,.returnAddress + push de + + ;get tile class in c + push af + + push hl + call GetClassMethodTable + ld d,h + ld e,l + pop hl + pop af + push de ;addr of method on stack + + ret ;call method + +.returnAddress + pop hl + pop de + pop bc + or a + ret + +;--------------------------------------------------------------------- +; Routine: ChangeMyClass +; ChangeMyClassAndRedraw +; ChangeMyClassToAssociatedAndRedraw +; Arguments: a - new class type +; c - old class type +; de - this +; Returns: c - new class type +; Alters: af,c +; Description: Changes this object from the old to new class type. +;--------------------------------------------------------------------- +ChangeMyClassToAssociatedAndRedraw:: + call GetAssociated + jp ChangeMyClassAndRedraw + +ChangeMyClassAndRedraw:: + call ChangeMyClass + ld b,METHOD_DRAW + jp CallMethod + +ChangeMyClass:: + push af + call RemoveObjectFromList + pop af + ld c,a + call AddObjectToList + ret + +;--------------------------------------------------------------------- +; Routine: RemoveObjectFromList +; Arguments: c - class type +; de - this +; Returns: Nothing. +; Alters: af +; Description: Removes the object from its class's linked list but +; does not delete it. +;--------------------------------------------------------------------- +RemoveObjectFromList:: + push bc + push de + push hl + + call PointerDEToIndex + ld b,a + + ;head of list? + call GetHead + cp b + jr nz,.notHead + + ;make next item new head of list + call IndexToPointerDE + call GetNext + call SetHead + jr .done + +.notHead +.search + ;search through list for item that points to that to remove + call IndexToPointerDE + call GetNext + cp b + jr nz,.search + +.foundPrevious + ;set prev->next = prev->next->next + call PointerDEToIndex + push af ;save index of prev + ld a,b ;get searchObj + call IndexToPointerDE + call GetNext ;searchObj->next + ld b,a + pop af + call IndexToPointerDE ;prev = searchObj->next + ld a,b + call SetNext + + ;if next is null then removed obj was tail. Reset tail + ;to prev + ;ld b,a redundant; A already == B + or a + jr nz,.done + + call PointerDEToIndex + call SetTail + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: AddObjectToList +; Arguments: c - class type +; de - this +; Returns: Nothing. +; Alters: af +; Description: +;--------------------------------------------------------------------- +AddObjectToList:: + push de + + xor a + call SetNext ;obj->next = null in all cases + + call PointerDEToIndex + + push af + + ;objClassLookup[objIndex] = classIndex + ld d,((objClassLookup>>8) & $ff) + ld e,a + ld a,OBJLISTBANK + ldio [$ff70],a + ld a,c + ld [de],a + + ;head == null? + call GetHead + or a + jr nz,.addToTail + +.addToHead + pop af + call SetHead + call SetTail + pop de + ret + +.addToTail + call GetTail + call IndexToPointerDE + pop af + + call SetNext + call SetTail + + pop de + ret + +;--------------------------------------------------------------------- +; Routine: SetAssociated +; Arguments: b - class to associate +; c - current class +; Alters: af +;--------------------------------------------------------------------- +SetAssociated:: + push hl + ld a,OBJLISTBANK + ld [$ff70],a + + ld h,((associatedIndex>>8)&$ff) + ld l,c + ld [hl],b + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: CountNumObjects +; Arguments: a - class index to count +; Returns: a - number of objects of this class +; Alters: af +;--------------------------------------------------------------------- +CountNumObjects:: + push bc + push de + + ld c,a + + ld b,0 + call GetFirst + or a + jr z,.done + + inc b + +.loop call GetNextObject + or a + jr z,.done + inc b + jr .loop + +.done ld a,b + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: ClassIndexIsHeroType +; Arguments: a - hero flag e.g. HERO_BS_FLAG +; c - class index +; Returns: a - 1 if matches +; zflag - or a +; Alters: af +;--------------------------------------------------------------------- +ClassIndexIsHeroType:: + push bc + ld b,a + + ld a,[hero0_index] + cp c + jr nz,.checkingHero1 + +.checkingHero0 + ld a,[hero0_type] + jr .checkType + +.checkingHero1 + ld a,[hero1_type] +.checkType + cp b + jr nz,.returnFalse + + ld a,1 ;return true + or a + pop bc + ret + +.returnFalse + xor a + pop bc + ret + diff --git a/Source/Sample.asm b/Source/Sample.asm new file mode 100644 index 0000000..116826d --- /dev/null +++ b/Source/Sample.asm @@ -0,0 +1,8 @@ +;--------------------------------------------------------------------- +; Eat +;--------------------------------------------------------------------- +SECTION "Section_eat_0",ROMX +eat_gbw:: + INCBIN "Data/SoundSamples/eat.gbw" + DB $80,$00 ;terminate sample + diff --git a/Source/Start.inc b/Source/Start.inc new file mode 100644 index 0000000..e3902c1 --- /dev/null +++ b/Source/Start.inc @@ -0,0 +1,49 @@ +INFINITEHEALTH EQU 0 +UPGRADES EQU 1 + +MENUTOMAP EQU $1102 ;intro missions +;MENUTOMAP EQU $1100 ;straight to appomattox +;MENUTOMAP EQU $1104 ;other map + +FORCE_EXIT EQU 0 +FORCE_EXIT_MAP EQU $1000 + +INITIALMAP EQU $1200 ;(Logo cinema) +;INITIALMAP EQU $1101 ;(main menu) +;INITIALMAP EQU $1300 ;(appomattox) +;INITIALMAP EQU $0808 +;INITIALMAP EQU $1401 ;(appomattox control panel) +;INITIALMAP EQU $1102 ;intro cinema / music test +;INITIALMAP EQU $1100 ;appomattox (no join menu) +;INITIALMAP EQU $1502 ;(approach kiwi cinema) +;INITIALMAP EQU $1402 ;(lady flower intervenes) + +INITEXIT0 EQU EXIT_D +;INITEXIT0 EQU EXIT_W + +APPOMATTOXMAPINDEX EQU $71 +;APPOMATTOXMAPINDEX EQU $0a + +;INITHERO0 EQU 2054 ;hero class (2054 = BA) +;INITHERO0 EQU 2056 ;hero class (2056 = BS) +INITHERO0 EQU 2058 ;hero class (2058 = Haiku) +;INITHERO0 EQU 2400 ;hero class (Captain Flour) +;INITHERO0 EQU 2398 ;hero class (Lady Flour) +;2390 = king grenade + +;INITTYPE0 EQU HERO_BA_FLAG +;INITTYPE0 EQU HERO_BS_FLAG +INITTYPE0 EQU HERO_HAIKU_FLAG +;INITTYPE0 EQU HERO_FLOUR_FLAG +;INITTYPE0 EQU HERO_FLOWER_FLAG + +INITLOC0 EQU $0909 +;INITLOC0 EQU $0e0f ;14,15 + +INITEXIT1 EQU EXIT_D +INITHERO1 EQU FREEVERSE_CINDEX +INITLOC1 EQU $0909 +;INITLOC1 EQU $0e10 ;14,16 +INITTYPE1 EQU HERO_BS_FLAG + +KGRENADE_CINDEX EQU 2390 diff --git a/Source/User.asm b/Source/User.asm new file mode 100644 index 0000000..fa71116 --- /dev/null +++ b/Source/User.asm @@ -0,0 +1,4715 @@ +;Class.asm +;Gfx.asm +;Map.asm +;Object.asm +;Music.asm +;--------------------------------------------------------------------- +; user.asm +; 12.18.99 by Abe Pralle +;--------------------------------------------------------------------- + +INCLUDE "Source/Defs.inc" +INCLUDE "Source/Start.inc" +INCLUDE "Source/Items.inc" + +MIN_VBLANKS EQU 2 + +INTCLK EQU $83 +EXTCLK EQU $82 + + + + + SECTION "User",ROM0 + +;--------------------------------------------------------------------- +; Subroutine: UserMain +; Description: Sets up game then goes into main loop +;--------------------------------------------------------------------- +UserMain:: + call InitGfx + + ;set up initial location + hero + ;initial L0009 (demo intro) + ld a,LEVELSTATEBANK + ld [$ff70],a + xor a + ld [curLevelStateIndex],a + + xor a + ldio [mapState],a + ldio [mapState+1],a + + ;initial level index + ld a,((INITIALMAP>>8) & $ff) + ld [curLevelIndex+1],a + ld a,(INITIALMAP & $ff) + ld [curLevelIndex],a + + ld hl,$1102 + call SetJoinMap + call SetRespawnMap + + ld a,[heroesUsed] + or INITTYPE0 + ld [heroesUsed],a + + ;hero 0 initial setup + ld a,(INITHERO0 & $ff) + ld [hero0_class],a + ld a,((INITHERO0>>8)&$ff) + ld [hero0_class+1],a + ld a,(INITLOC0 & $ff) + ld [hero0_enterLevelLocation],a + ld a,((INITLOC0>>8) & $ff) + ld [hero0_enterLevelLocation+1],a + ld a,INITEXIT0 + ld [hero0_enterLevelFacing],a + ld a,INITTYPE0 + ld [hero0_type],a + xor a + ld [hero0_health],a + + ;hero 1 initial setup + ld a,(INITHERO1 & $ff) + ld [hero1_class],a + ld a,((INITHERO1>>8)&$ff) + ld [hero1_class+1],a + ld a,(INITLOC1 & $ff) + ld [hero1_enterLevelLocation],a + ld a,((INITLOC1>>8) & $ff) + ld [hero1_enterLevelLocation+1],a + ld a,INITEXIT1 + ld [hero1_enterLevelFacing],a + ld a,INITTYPE1 + ld [hero1_type],a + xor a + ld [hero1_health],a + + ld a,1 + ld [timeToChangeLevel],a + + jr .loadNextLevel + +.game ld a,[timeToChangeLevel] + or a + jr z,.continue + + ;switch levels + ld b,METHOD_DIE + call IterateAllLists + ld a,15 + call SetupFadeToBlack + call WaitFade + +.loadNextLevel + call LoadNextLevel + call UpdateObjects + call GentleCameraAdjust + call levelCheckRAM + call RedrawMap + ld a,15 + call SetupFadeFromBlack + call WaitFade + ;call LighteningIn + +.continue + call MainLoopUpdateObjects + call GentleCameraAdjust + + call levelCheckRAM +.afterLevelCheck + call RedrawMap + jr .game + +;--------------------------------------------------------------------- +; Routine: SetActiveROM +; Argument: a - desired ROM bank +; Returns: Nothing. +; Alters: af +; Description: Switches to a new ROM bank by writing the new bank +; number to [$2100]. Also saves the bank in +; [curROMBank]. +;--------------------------------------------------------------------- +SetActiveROM:: + ldio [curROMBank],a + ld [$2100],a + ret + +;--------------------------------------------------------------------- +; Routine: LongCall +; Arguments: stack: +; +0: parameter de +; +2: parameter af +; +4: empty (for addr of routine) +; +6: empty (return addr from routine) +; +8: af - old ROM bank +; +10: return addr from LongCall +; a - bank of routine +; de - address of routine +; Returns: Whatever routine normally returns (excluding F). +; Alters: af, hl +; Description: +;--------------------------------------------------------------------- +LongCall:: + ldio [curROMBank],a ;switch to ROM containing routine + ld [$2100],a + + push hl + ld hl,sp+6 ;point hl to empty spot in stack + ld [hl],e + inc hl + ld [hl],d ;save addr of method + inc hl + ld de,.returnAddress + ld [hl],e ;save return addr of method + inc hl + ld [hl],d + pop hl + pop de + pop af + ret ;call method + +.returnAddress + ld [longCallTempA],a + pop af ;get old ROM bank + ldio [curROMBank],a + ld [$2100],a + ld a,[longCallTempA] + + ret ;return from this routine + +;--------------------------------------------------------------------- +; Routine: LongCallNoArgs +; Arguments: a - RAM bank of routine +; hl - address of routine +; Returns: Nothing. +; Alters: af +; Description: Quick & dirty long call (handles bank swapping) +; for routines that don't require arguments or return +; values. +;--------------------------------------------------------------------- +LongCallNoArgs:: + push bc + + ld b,a + ld a,[curROMBank] + push af ;save old bank + + ld a,b + ld [curROMBank],a ;swap in new bank + ld [$2100],a + + ld bc,.returnAddress + push bc + + jp hl +.returnAddress + + pop af ;retrieve old bank & swap it in + ld [curROMBank],a + ld [$2100],a + + pop bc + ret + +WaitFade:: + call FadeStep + + ;took out distorts synchronization + ;send a null control byte + ;ld a,LNULL + ;call ExchangeByte + ;call HandleRemoteInput + + call CheckSkip + ld a,[specialFX] + and FX_FADE + jr nz,WaitFade + + ;allow last palette to install +.waitInstall + ldio a,[paletteBufferReady] ;wait for vblank + or a + jr nz,.waitInstall + + ret + +;--------------------------------------------------------------------- +; Routine: CheckSpecialFX +; Alters: af +; Description: Performs any special effects upkeep +;--------------------------------------------------------------------- +CheckSpecialFX: + ld a,[specialFX] + and FX_FADE + jr z,.done + + call FadeStep + ret + +.done + ret + +;--------------------------------------------------------------------- +; Subroutine: UpdateObjTimers +; Alters: af +; Description: Updates timers used for object movement +;--------------------------------------------------------------------- +UpdateObjTimers:: + ld a,[objTimerBase] + inc a + ld [objTimerBase],a + + ;put 2 LSB bits in 4:3 + rlca + rlca + rlca + and %00011000 + ld [objTimer60ths],a + + ret + +;--------------------------------------------------------------------- +; Subroutine: UpdateHeroTimers +; Alters: af +; Description: Updates timers used for hero/hero bullet movement +;--------------------------------------------------------------------- +UpdateHeroTimers: + ld a,[heroTimerBase] + inc a + ld [heroTimerBase],a + + ;put 2 LSB bits in 4:3 + rlca + rlca + rlca + and %00011000 + ld [heroTimer60ths],a + + ret + + +;--------------------------------------------------------------------- +; Subroutine: VWait +; Description: Waits until a vertical blank occurs and then returns +;--------------------------------------------------------------------- +VWait:: +.vwait halt ;stop processor until interrupt + nop ;pad to prevent weird stuff after halt + + ;interrupt happened, let's look at our flag + ldio a,[vblankFlag] + or a ;a=a|a; tells us if vblankFlag is 1 or 0 + jr z,.vwait ;not the vblank flag after all + + ;If we're here then a vblank has occurred. Get on with our lives. + xor a ;clear vblank flag + ldio [vblankFlag],a + ret + +;--------------------------------------------------------------------- +; Subroutine: OnVBlank +; Description: Called every vertical blank. Sets "vblankFlag" to +; 1 to indicate a vertical blank has occurred +;--------------------------------------------------------------------- +OnVBlank:: + push af ;save all registers on stack + push bc + push de + push hl + + ld a,1 ;set "vblankFlag" to 1 + ldio [vblankFlag],a + + ;store current VRAM bank in use + ld a,[$ff00+$4f] + push af + + ;update timers + ld hl,vblankTimer + inc [hl] + + ;is the backBuffer ready for DMA blit to screen? + ldio a,[backBufferReady] + or a + jr z,.checkDMALoad ;wasn't ready + + ld a,[displayType] + or a + jr nz,.afterVblankCheck ;cinema type + + ldio a,[vblankTimer] + ld hl,vblankTemp + sub [hl] + ldio [vblanksPerUpdate],a + + ;update no faster than 1-frame-every-so-many-blanks clocks + cp MIN_VBLANKS + jr c,.checkDMALoad ;too soon to update + +;MUST SYNCHRONIZE WITH REMOTE TO DYNAMICALLY CHANGE THIS + ;jr z,.rightOn ;exactly right + ;updating too many objects; decrease iterateNumObjects + ;ld hl,iterateNumObjects + ;ld a,[hl] + ;cp 17 + ;jr c,.rightOn ;don't risk going below 16 per update + + ;dec [hl] + +.rightOn + ldio a,[vblankTimer] ;save time of this screen update + ldio [vblankTemp],a + +.afterVblankCheck + ld hl,updateTimer + inc [hl] + + xor a + ldio [backBufferReady],a ;signal we've blitted backbuffer + + ;set VRAM bank to 0 + xor a + ld [$ff00+$4f],a + + ;use DMA to transfer sprite OAM buffer to VRAM + call SpriteDMAHandler + + ;Initiate DMA transfer of backbuffer to VRAM + + ld hl,backBuffer + ld a,h + ld [$ff00+$51],a ;high byte of source + ld a,l + ld [$ff00+$52],a ;low byte of source + ldio a,[backBufferDestHighByte] + ld [$ff00+$53],a ;high byte of dest + xor a + ld [$ff00+$54],a ;low byte of dest + ld a,37 ;copy (37+1)*16 = 608 bytes + ld [$ff00+$55],a ;store length to start DMA + + ;set VRAM bank to 1 (tile attributes) + ld a,1 + ld [$ff00+$4f],a + + ;Initiate DMA transfer of tile attributes to VRAM + ld hl,attributeBuffer + ld a,h + ld [$ff00+$51],a ;high byte of source + ld a,l + ld [$ff00+$52],a ;low byte of source + ldio a,[backBufferDestHighByte] + ld [$ff00+$53],a ;high byte of dest + xor a + ld [$ff00+$54],a ;low byte of dest + ld a,37 ;copy (37+1)*16 = 608 bytes + ld [$ff00+$55],a ;store length to start DMA + + ld a,[desiredPixelOffset_x] + ld [curPixelOffset_x],a + ld a,[desiredPixelOffset_y] + ld [curPixelOffset_y],a + jr .scroll + +.checkDMALoad + ldio a,[dmaLoad] + or a + jr z,.scroll + +.checkLoadBank0 + bit 0,a + jr z,.checkLoadBank1 + +.loadBank0 + res 0,a + ldio [dmaLoad],a ;indicate we've loaded it + xor a + ld [$ff4f],a + + ;Initiate DMA transfer to bank 0 VRAM + ld a,[dmaLoadSrc0+1] + ld [$ff00+$51],a ;high byte of source + ld a,[dmaLoadSrc0] + ld [$ff00+$52],a ;low byte of source + ld a,[dmaLoadDest0+1] + ld [$ff00+$53],a ;high byte of dest + ld a,[dmaLoadDest0] + ld [$ff00+$54],a ;low byte of dest + ld a,[dmaLoadLen0] ;copy (N+1)*16 bytes + ld [$ff00+$55],a ;store length to start DMA + +.checkLoadBank1 + ldio a,[dmaLoad] + bit 1,a + jr z,.scroll + +.loadBank1 + res 1,a + ldio [dmaLoad],a ;indicate we've loaded it + ld a,1 + ld [$ff4f],a + + ;Initiate DMA transfer to bank 1 VRAM + ld a,[dmaLoadSrc1+1] + ld [$ff00+$51],a ;high byte of source + ld a,[dmaLoadSrc1] + ld [$ff00+$52],a ;low byte of source + ld a,[dmaLoadDest1+1] + ld [$ff00+$53],a ;high byte of dest + ld a,[dmaLoadDest1] + ld [$ff00+$54],a ;low byte of dest + ld a,[dmaLoadLen1] ;copy (N+1)*16 bytes + ld [$ff00+$55],a ;store length to start DMA + +.scroll ;Adjust scroll coordinates + ld hl,lineZeroHorizontalOffset + ldio a,[jiggleDuration] + or a + jr z,.useNormalScreenOffsets + + ;jiggle the screen! + dec a + ldio [jiggleDuration],a + + ;determine jiggle type + ld a,[jiggleType] + or a + jr nz,.takeoffJiggle + +.normalJiggle + ;pick a "random value" + ld a,[jiggleLoc] + add 17 + ld [jiggleLoc],a + ld b,a ;store random value in b + and %00000111 ;random x offset + ldio [baseHorizontalOffset],a + add [hl] ;add lineZeroHorizontalOffset + ldio [$ff43],a + swap b + ld a,%00000111 ;random y offset + and b + ldio [$ff42],a + jr .done + +.takeoffJiggle + ld a,[jiggleLoc] + add 17 + ld [jiggleLoc],a + ld b,a ;store random value in b + and %11 ;x offset + ldio [$ff43],a + swap b + ld a,%11 + and b + ld b,a + ld a,[curPixelOffset_y] + add b + cp 8 + jr c,.takeoffVOkay + + ld a,7 + +.takeoffVOkay + ldio [$ff42],a + jr .done + +.useNormalScreenOffsets + ld a,[curPixelOffset_x] + ldio [baseHorizontalOffset],a + add [hl] ;add lineZeroHorizontalOffset + ldio [$ff43],a + ld a,[curPixelOffset_y] + ldio [$ff42],a + + ;new palette to copy? + ldio a,[paletteBufferReady] + or a + jr z,.afterPaletteCopy + + ld c,16 ;c is count + ld hl,fadeCurPalette + ld a,%10000000 + ld [$ff68],a + ld [$ff6a],a +.paletteCopyBG + ld a,[hl+] ;copy sets of 4 bytes to avoid minute but + ld [$ff69],a ;killer delays decrementing the counter + ld a,[hl+] + ld [$ff69],a + ld a,[hl+] + ld [$ff69],a + ld a,[hl+] + ld [$ff69],a + dec c + jr nz,.paletteCopyBG + + ld c,16 ;c is count +.paletteCopyFG + ld a,[hl+] + ld [$ff6b],a + ld a,[hl+] + ld [$ff6b],a + ld a,[hl+] + ld [$ff6b],a + ld a,[hl+] + ld [$ff6b],a + dec c + jr nz,.paletteCopyFG + + xor a + ldio [paletteBufferReady],a + +.afterPaletteCopy + +.done + ;update music + ldio a,[musicEnabled] + and %10000 + jr z,.doneMusic + + ld hl,musicNoteCountdown + dec [hl] + call z,PlayMusic + +.doneMusic + ;restore VRAM bank that was in use + pop af + ld [$ff00+$4f],a + + pop hl ;restore all regs from stack + pop de + pop bc + pop af + reti ;return from interrupt + + +;--------------------------------------------------------------------- +; Subroutine: OnHBlank +; Description: Called after every line is drawn. +;--------------------------------------------------------------------- +OnHBlank:: + push af + push bc + push hl + +OnHBlank_afterPush: + ldio a,[$ff41] ;get stat register + bit 2,a ;equal to lyc? + jp z,FinishHBlankPlayingSample + +.continue + ld hl,hblankFlag + bit 0,[hl] ;turning window on or off? + jr nz,OnHBlank_turnOffWindow + + ;turn on window + bit 1,[hl] ;allowed to? + jr nz,.turnOn + jp z,FinishHBlankPlayingSample +.turnOn + set 0,[hl] + ldio a,[hblankWinOff] + ld [$ff45],a ;reset lyc to win off pos + ld hl,$ff40 ;turn window on + set 5,[hl] + +OnHBlank_SetBGColorBlack: + ;set background palette 0, color zero to black + ld b,0 + ld c,$68 + ld hl,$ff69 + ld a,%10000000 ;specification 0 + ld [c],a + ld [hl],b + ld [hl],b + + ;ld a,%10000110 ;white + ;ld [c],a + ;ld [hl],h + ;ld [hl],h + + ld a,%10001000 ;palette 1 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10010000 ;palette 2 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10011000 ;palette 3 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10100000 ;palette 4 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10101000 ;palette 5 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10110000 ;palette 6 + ld [c],a + ld [hl],b + ld [hl],b + + ld a,%10111000 ;palette 7 + ld [c],a + ld [hl],b + ld [hl],b + + jp FinishHBlankPlayingSample + +OnHBlank_turnOffWindow: + res 0,[hl] + ldio a,[hblankWinOn] + ld [$ff45],a ;reset lyc to win on pos + ld hl,$ff40 ;turn window off + res 5,[hl] + + ;restore background palette 0, color zero + push de + ld c,$68 + ld hl,mapColor + ld a,[hl+] + ld d,[hl] + ld e,a + ld hl,$ff69 + +HBlankSetBGColorCDEHL_DEPushed: + ld a,%10000000 ;specification 0 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10001000 ;specification 1 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10010000 ;specification 2 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10011000 ;specification 3 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10100000 ;specification 4 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10101000 ;specification 5 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10110000 ;specification 6 + ld [c],a + ld [hl],e + ld [hl],d + + ld a,%10111000 ;specification 7 + ld [c],a + ld [hl],e + ld [hl],d + + ;ld a,%10000110 ;white + ;ld [c],a + ;ld a,[fadeCurPalette+6] + ;ld [hl],a + ;ld a,[fadeCurPalette+7] + ;ld [hl],a + + pop de + +.done + jp FinishHBlankPlayingSample + +;--------------------------------------------------------------------- +; Subroutine: CinemaOnHBlank +; Description: Called after every line is drawn. +;--------------------------------------------------------------------- +CinemaOnHBlank:: + push af + push bc + push hl + + ldio a,[$ff41] ;get stat register + bit 2,a ;equal to lyc? + jp z,FinishHBlankPlayingSample + +.continue + ld hl,hblankFlag + bit 0,[hl] ;turning window on or off? + jr nz,.turnOff + + ;turn on window + bit 1,[hl] ;allowed to? + jr nz,.turnOn + jp z,FinishHBlankPlayingSample +.turnOn + set 0,[hl] + ldio a,[hblankWinOff] + ld [$ff45],a ;reset lyc to win off pos + ld hl,$ff40 ;turn window on + set 5,[hl] + jp FinishHBlankPlayingSample + +.turnOff + res 0,[hl] + ldio a,[hblankWinOn] + ld [$ff45],a ;reset lyc to win on pos + ld hl,$ff40 ;turn window off + res 5,[hl] + +.done + jp FinishHBlankPlayingSample + +;--------------------------------------------------------------------- +; Subroutine: HOffsetOnHBlank +; Description: Called after every line is drawn. Sets each line's +; horizontal offset from horizontalOffset[144] +;--------------------------------------------------------------------- +HOffsetOnHBlank:: + push af + push bc + push hl + + ;save current RAM bank + ldio a,[$ff70] + push af + + ld a,TILEINDEXBANK + ldio [$ff70],a + ;add to the horizontal offset for next line + ld c,$44 ;get $ff44 + ld a,[c] ;ypos of refresh (index to array) + dec c ;c=$43 ($ff43) + inc a + ld l,a + ld h,((horizontalOffset>>8)&$ff) + ldio a,[baseHorizontalOffset] + add [hl] + ld [c],a ;xpos of screen + +.afterAdjustOffsets + pop af + ldio [$ff70],a + jp OnHBlank_afterPush + +;--------------------------------------------------------------------- +; Subroutine: SeasonsOnHBlank +; Description: Called after every line is drawn. Sets color 0 (all +; bg palettes) to white on line 143 and to brown ($888) +; on line 39. +;--------------------------------------------------------------------- +SeasonsOnHBlank:: + push af + push bc + push hl + + ld a,[amShowingDialog] + or a + jr nz,.seasonsWindow + + ;jr z,.normal + ;ld a,[hblankFlag] + ;and %11 + ;jr nz,.seasonsWindow + +.normal + ldio a,[$ff44] ;ypos + cp 143 + jr z,.toWhite + cp 39 + jp nz,.seasonsWindow + +.toBrown + push de + ld c,$68 + ld hl,fadeCurPalette+62 + ld a,[hl+] + ld d,[hl] + ld e,a + ld hl,$ff69 + jp HBlankSetBGColorCDEHL_DEPushed + +.toWhite + push de + ld c,$68 + ld hl,mapColor + ld a,[hl+] + ld d,[hl] + ld e,a + ld hl,$ff69 + jp HBlankSetBGColorCDEHL_DEPushed + +.seasonsWindow + ldio a,[$ff41] ;get stat register + bit 2,a ;equal to lyc? + jp z,FinishHBlankPlayingSample + +.continue + ld hl,hblankFlag + bit 0,[hl] ;turning window on or off? + jr nz,.turnOff + + ;turn on window + bit 1,[hl] ;allowed to? + jr z,.toBrown + ;jr nz,.turnOn + ;jp FinishHBlankPlayingSample +.turnOn + set 0,[hl] + ldio a,[hblankWinOff] + ld [$ff45],a ;reset lyc to win off pos + ld hl,$ff40 ;turn window on + set 5,[hl] + jp OnHBlank_SetBGColorBlack + +.turnOff + res 0,[hl] + ldio a,[hblankWinOn] + ld [$ff45],a ;reset lyc to win on pos + ld hl,$ff40 ;turn window off + res 5,[hl] + + jr .toBrown + +;--------------------------------------------------------------------- +; Routine: GetInput +; Description: Swaps in the link code bank, passes the work along to +; HandleInput, and swaps in the object bank before +; ending. +;--------------------------------------------------------------------- +GetInput:: + LONGCALLNOARGS HandleInput + + ;if the heroes are idle then set both inputs to zero + ld a,[heroesIdle] + or a + ret z + + xor a + ld [curJoy0],a + ld [curJoy1],a + + ret + +;--------------------------------------------------------------------- +; Routine: CheckPause +; Description: Checks for pause button being pressed +;--------------------------------------------------------------------- +CheckPause: + ld hl,dialogJoyIndex + ld a,[hl] + push af + + ld a,[heroesPresent] + cp %11 + jr z,.checkBoth + + dec a + ld [hl],a + ld a,[myJoy] + bit JOY_START_BIT,a + jr z,.done + jr .checkModes + +.checkBoth + ld [hl],0 + ld a,[curInput0] + bit JOY_START_BIT,a + jr nz,.checkModes + + ld [hl],1 + ld a,[curInput1] + bit JOY_START_BIT,a + jr z,.done + +.checkModes + ld a,[amShowingDialog] + or a + jr nz,.done + + ld a,[displayType] + or a + jr nz,.done + + ld a,[amChangingMap] + or a + jr nz,.done + + ld a,[heroesIdle] + or a + jr nz,.done + + ;(show as dialog) + ld a,[dialogSettings] + push af + call SetPressBDialog + call SaveIdle + + ld de,.afterPause + call SetDialogSkip + + ld a,BANK(GeneratePauseMessage) + ld hl,GeneratePauseMessage + call LongCallNoArgs + + ld a,1 + ld [amShowingDialog],a + ld de,backBuffer+63 + + call ShowDialogAtTopCommon + call DialogWaitInputZero + +.wait + call UpdateObjects + call RedrawMap + call SetDialogJoy + bit JOY_SELECT_BIT,[hl] + jr nz,.selectPressed + call CheckDialogContinue + or a + jr z,.wait + +.afterPause + call ClearDialog + + call RestoreIdle + pop af + ld [dialogSettings],a +.done + pop af + ld [dialogJoyIndex],a + ret + +.selectPressed + call ClearDialog + call RestoreIdle + pop af + ld [dialogSettings],a + pop af + ld [dialogJoyIndex],a + + ld a,EXIT_D + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + + ld hl,respawnMap + ld a,[hl+] + ld [curLevelIndex],a + ld a,[hl+] + ld [curLevelIndex+1],a + ld a,1 + ld [timeToChangeLevel],a + ret + + +;--------------------------------------------------------------------- +; Routine: UpdateObjects +; Description: Waits for a vertical blank and then updates the +; objects +;--------------------------------------------------------------------- +MainLoopUpdateObjects: + call VWait ;wait for a vertical blank + ld a,1 + ld [checkInputInMainLoop],a + call GetInput + call CheckPause + xor a + ld [checkInputInMainLoop],a + jr .doneWithInput + +.vwait call VWait ;wait for a vertical blank + +.doneWithInput + call CheckSpecialFX + + ;wait for previous frame to be drawn + ldio a,[backBufferReady] + or a + jp nz,.vwait + jr UpdateObjectsCommon + +UpdateObjects:: + call VWait ;wait for a vertical blank + call GetInput + +.vwait call VWait ;wait for a vertical blank + +.doneWithInput + call CheckSpecialFX + + ;wait for previous frame to be drawn + ldio a,[backBufferReady] + or a + jp nz,.vwait + +UpdateObjectsCommon: + ld a,[displayType] + or a + ret nz ;done if cinema type + + ;check each object + ld b,METHOD_CHECK + ld a,[iterateNumObjects] + ld c,a + call IterateMaxObjects + + ;update the timers that hero/hero bullets base moves off of + call UpdateHeroTimers + + ;make sure we check the hero & hero's bullets each time + ld hl,hero0_index + call .checkHeroObjects + ld hl,hero1_index + call .checkHeroObjects + + ret + +.checkHeroObjects + ld a,[hl+] ;heroX_index + or a + ret z ;this hero doesn't exist + + ld c,a + call GetFirst + ld b,METHOD_CHECK + ;ld e,[hl] ;heroX_objectL + ;inc hl + ;ld d,[hl] ;heroX_objectH + ;inc hl + call CallMethod + + inc hl + inc hl + + ld a,[hl] ;heroX_bulletIndex + ld c,a + call GetFirst + call IterateList + ret + +;--------------------------------------------------------------------- +; Routine: RedrawMap +; Description: Redraws the map for the next vblank +;--------------------------------------------------------------------- +RedrawMap:: + call RestrictCameraToBounds + call ScrollToCamera + + call DrawMapToBackBuffer + call UpdateEnvEffect + + ld a,1 + ldio [backBufferReady],a ;signal we're ready for DMA + + ret + + + +;--------------------------------------------------------------------- +; Routine: HandleRemoteInput +; Arguments: a - remoteInput +; Returns: a - remoteInput +; zflag - set if must repeat +; Alters: af +;--------------------------------------------------------------------- +HandleRemoteInput:: + bit 7,a ;test bit 7 + ret z ;got the BCB + + ;handle the link command code we received. + call HandleLCC + + ;indicate we need to try exchanging our control bytes again + ld a,1 + or a ;don't set zero flag + ret + +;--------------------------------------------------------------------- +; Routine: HandleLCC +; Arguments: a - value of the Link Command Code. +; Returns: nothing. +; Alters: af +;--------------------------------------------------------------------- +HandleLCC: +.checkLGETGAMESTATE + cp LGETGAMESTATE + jr nz,.checkLGETMAPINDEX + + ;LGETGAMESTATE + LONGCALLNOARGS TransmitGameState + ret + +.checkLGETMAPINDEX + cp LGETMAPINDEX + jr nz,.checkLUPDATESTATE + + ;LGETMAPINDEX + ld a,[displayType] + or a + jr nz,.returnDifferentMapCode ;cinema type + ld a,[amChangingMap] + or a + jr nz,.returnWaitCode + ld a,[canJoinMap] + ;or a + ;jr z,.returnWaitCode + cp 2 + jr z,.returnDifferentMapCode ;do this map independently + + ld a,[curLevelStateIndex] + jr .returnMapIndex +.returnWaitCode + ld a,$ff + jr .returnMapIndex +.returnDifferentMapCode + ld a,$fe +.returnMapIndex + call TransmitByte + ret + +.checkLUPDATESTATE + cp LUPDATESTATE + jr nz,.checkLUPDATEHERO + + ;LUPDATESTATE + push hl + ld a,LEVELSTATEBANK + ld [$ff70],a + call ReceiveByte + ld h,((levelState>>8) & $ff) + ld l,a + call ReceiveByte + ld [hl],a + pop hl + + ret + +.checkLUPDATEHERO + cp LUPDATEHERO + jr nz,.checkLYANKPLAYER + + ;LUPDATEHERO + call ReceiveByte + ld [heroesUsed],a + ret + +.checkLYANKPLAYER + cp LYANKPLAYER + jr nz,.checkLRESYNCHRONIZE + + ;LYANKPLAYER + ;get exit direction + call ReceiveByte + ld [hero0_enterLevelFacing],a + + ;get new map coordinates + push bc + push af + call ReceiveByte + ld c,a + call ReceiveByte + ld b,a + ld a,[hero0_enterLevelFacing] + and 7 + ld [hero0_enterLevelFacing],a + ld [hero1_enterLevelFacing],a + pop af + cp 8 + jr nc,.changeMap + + ld a,[curLevelIndex] + cp c + jr nz,.changeMap + ld a,[curLevelIndex+1] + cp b + jr z,.noChangeMap + +.changeMap + ld a,c + ld [curLevelIndex],a ;map index lobyte + ld a,b + ld [curLevelIndex+1],a ;map index lobyte + ld a,1 + ld [timeToChangeLevel],a + +.noChangeMap ;already on this map + pop bc + ret + +.checkLRESYNCHRONIZE + cp LRESYNCHRONIZE + jr nz,.checkLGETRANDOMSEED + + LONGCALLNOARGS GuestContinueSynchronization + ret + +.checkLGETRANDOMSEED + cp LGETRANDOMSEED + jr nz,.checkLTERMINATE + + ldio a,[randomLoc] + call TransmitByte + ret + +.checkLTERMINATE + cp LTERMINATE + jr nz,.checkLSYNCHRONIZE + + ld a,[amLinkMaster] + cp 1 + jr z,.terminateMaster + + ;terminate slave + rst $00 +.terminateMaster + ld a,$fe + ld [amLinkMaster],a + ret + +.checkLSYNCHRONIZE + cp LSYNCHRONIZE + jr nz,.checkLLOCKHEROES + + ;LSYNCHRONIZE + ;am I ready to synchronize? + ld a,[checkInputInMainLoop] + or a + jr z,.notReadyToSync + ld a,[amShowingDialog] + or a + jr nz,.readyIfCinema + ld a,[canJoinMap] + or a + jr z,.notReadyToSync + jr .readyToSynchronize + +.readyIfCinema + ld a,[displayType] + or a + jr nz,.readyToSynchronize + + ;not ready +.notReadyToSync + ld a,LSYNCHWAIT + call TransmitByte + ret + +.readyToSynchronize + ld a,LSYNCHREADY + call TransmitByte + LONGCALLNOARGS HostSynchronize + ret + +.checkLLOCKHEROES + cp LLOCKHEROES + jr nz,.checkLNOLINK + + call ReceiveByte ;receive lock or unlock from remote + ld [heroesLocked],a + ret + +.checkLNOLINK + cp LNOLINK + jr nz,.checkLLINKTEST + ret + +.checkLLINKTEST + cp LLINKTEST + jr nz,.checkLCHANGEAPPXMAP + + LONGCALLNOARGS LinkTest + ret + +.checkLCHANGEAPPXMAP + cp LCHANGEAPPXMAP + jr nz,.checkLADDINVITEM + + LONGCALLNOARGS NewAppxLocation + ret + +.checkLADDINVITEM + cp LADDINVITEM + jr nz,.checkLREMINVITEM + + push bc + call ReceiveByte ;get bc (inventory item) + ld c,a + call ReceiveByte + ld b,a + + ;duplicate code also in Map.asm + push hl + call PointHLToInventory + or c + ld [hl],a + pop hl + pop bc + ret + +.checkLREMINVITEM + cp LREMINVITEM + jr nz,.checkLUPDATEMEMORY + + ;duplicate code also in Map.asm + push bc + call ReceiveByte ;get bc (inventory item) + ld c,a + call ReceiveByte + ld b,a + + ;duplicate code also in Map.asm + push hl + call PointHLToInventory + xor $ff + or c + xor $ff + ld [hl],a + pop hl + pop bc + ret + +.checkLUPDATEMEMORY + cp LUPDATEMEMORY + jr nz,.unknown + + push hl + call ReceiveByte ;memory bank of data + ldio [$ff70],a + call ReceiveByte ;address + ld l,a + call ReceiveByte + ld h,a + call ReceiveByte ;new value + ld [hl],a + pop hl + ret + +.unknown + ret + +;--------------------------------------------------------------------- +; Routines: LLTransmitByte +; Arguments: a - byte to send +; [amLinkMaster] - should be set to 1 or 0 +; Returns: Nothing. +; Alters: af +; Note: DON'T CALL THIS DIRECTLY. It should only be called +; via TransmitByte and ReceiveByte. +; Description: Low-level routine to transmit a byte via the link +; cable. +;--------------------------------------------------------------------- +LLTransmitByte: + di ;be sure we're not interrupted + ldio [$ff01],a ;store the data to transfer + ld a,INTCLK + ldio [$ff02],a ;let's do it +.waitForCompletion + ldio a,[$ff02] ;12 + and $80 ; 8 + jr nz,.waitForCompletion ; 8 + + ;go into slave mode to await next byte + ld a,EXTCLK ; 8 + ldio [$ff02],a ;12 TOTAL = 48 + + ;clear pending interrupts + xor a + ei + ld [$ff0f],a + + ret + +;--------------------------------------------------------------------- +; Routines: LLReceiveByte +; Arguments: [amLinkMaster] - should be set to 1 or 0 +; Returns: a - byte received from linked GameBoy. +; Alters: af +; Note: DON'T CALL THIS DIRECTLY. It should only be called +; via TransmitByte and ReceiveByte. +; Description: Low-level routine to receive a byte via the link +; cable. If no signal within nine seconds aborts link +; connection and: +; Master - continues game as slaveless master ($fe). +; Slave - restarts game. +;--------------------------------------------------------------------- +LLReceiveByte: + push bc + push de + + ld de,$0C00 ;abort timer counts down $C00 * 256 times + ld c,0 ;(about 1.25 sec per $100) +.waitForCompletion + ldio a,[$ff02] + and $80 + jr z,.gotValue + + ;update our abort timer + dec c + jr nz,.waitForCompletion + + dec de + xor a + cp d + jr nz,.waitForCompletion + cp e + jr nz,.waitForCompletion + jr .linkLost + +.gotValue + ldio a,[$ff01] ;return the value we received + + ;kill some time before we let ourselves change to master + ;to give the current master time to change to slave + push af +.killOuter + ld a,6 +.killTime + dec a ; 4 + jr nz,.killTime ; 4/8 TOTAL = 8, *6=48 + pop af + jr .done + +.linkLost + ld a,[amLinkMaster] + or a + jr z,.amSlave + + cp 1 + jr z,.amMaster + + ;link already lost, restore stack & jump to bail-out address + ;if not 0 + ld a,[linkBailOut] ;get bail-out address + ld e,a + ld a,[linkBailOut+1] + ld d,a + xor a + cp d + jr nz,.bail + cp e + jr nz,.bail + + ;null bail address; just quit + jr .done + +.bail + ;restore the stack before jumping to the bail address + ld a,[linkBailOut+2] + ld l,a + ld a,[linkBailOut+3] + ld h,a + ld sp,hl + push de + ret + +.amMaster + ld a,$fe + ld [amLinkMaster],a + + call RemoveRemoteHero + jr .done + +.amSlave + rst $00 ;restart the game + +.done + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: TransmitByte +; Argument: a - byte to send +; Returns: Nothing. +; Alters: af +; Description: Transmits a byte via the link cable to a remote GBC. +;--------------------------------------------------------------------- +TransmitByte:: + push bc + ld b,a + + ;If I was the last one to transmit, receive a byte as an + ;acknowledgement. + ld a,[lastLinkAction] + or a + jr z,.afterOrientStream + + call LLReceiveByte + +.afterOrientStream + ld a,1 ;our action this time is to transmit + ld [lastLinkAction],a + + ld a,b + call LLTransmitByte + +.done + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: ReceiveByte +; Arguments: None. +; Returns: a - byte received. +; Alters: af +; Description: Receives a byte from a remote machine. +;--------------------------------------------------------------------- +ReceiveByte:: + ;If necessary we'll transmit a value to avoid receiving twice + ;in a row. + ld a,[lastLinkAction] + or a + jr nz,.afterOrientStream + + ld a,1 + call LLTransmitByte + +.afterOrientStream + xor a ;our action this time is to receive + ld [lastLinkAction],a + + call LLReceiveByte + ret + + +;--------------------------------------------------------------------- +; Routine: ExchangeByte +; Argument: a - byte to send +; Returns: a - byte received in return +; Alters: af +; Description: Uses value of [amLinkMaster] (Master should be $01 and +; Slave should be $00) to determine sequencing of +; TransmitByte and ReceiveByte. +;--------------------------------------------------------------------- +ExchangeByte:: + push bc + ld b,a + + ld a,[amLinkMaster] + or a + jr z,.slaveExchange + + ;masterExchange + ld a,b + call TransmitByte + call ReceiveByte + jr .done + +.slaveExchange + call ReceiveByte + ld c,a + ld a,b + call TransmitByte + ld a,c + +.done + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: TransmitData +; Arguments: a - RAM bank to switch to (may/may not make a diff) +; bc - number of bytes to transmit +; hl - starting address of data to transmit +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +TransmitData:: + push bc + push hl + + ldio [$ff70],a + +.loop ld a,[hl+] + call TransmitByte + dec bc + xor a + cp b + jr nz,.loop + cp c + jr nz,.loop + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ReceiveData +; Arguments: a - RAM bank to switch to (may/may not make a diff) +; bc - number of bytes to receive +; hl - starting address to store data +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +ReceiveData:: + push bc + push hl + + ldio [$ff70],a ;change RAM bank + +.loop call ReceiveByte + ld [hl+],a + dec bc + xor a + cp b + jr nz,.loop + cp c + jr nz,.loop + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: TransmitCompressedData +; Arguments: a - RAM bank to switch to (may/may not make a diff) +; bc - number of bytes to transmit +; hl - starting address of data to transmit +; Returns: Nothing. +; Alters: af +; Description: Packs bytes 8:1 into the backBuffer by combining +; bit[0] from every eight bytes into one byte. The +; left-most bit will be from byte[0] and the right-most +; from byte[7]. +;--------------------------------------------------------------------- +TransmitCompressedData:: + push bc + push de + push hl + + ldio [$ff70],a + + ;divide len by 8 (>>3) + srl b + rr c + srl b + rr c + srl b + rr c + + push bc ;save length + + ;----Compress the data into backBuffer------------------------ + ld de,backBuffer ;compression buffer +.nextByte + push de ;push destination + ld de,8 ;d is compressed (0), e is times to loop + +.nextBit + ld a,[hl+] ;get the next byte + rrca ;shift out bit[0] into the carry flag + rl d ;rotate onto right side of result + dec e + jr nz,.nextBit + + ld a,d ;a has compressed byte + pop de ;pop destination + ld [de],a ;store the compressed byte + inc de + + dec bc + xor a + cp b + jr nz,.nextByte + cp c + jr nz,.nextByte + + pop bc ;done with compression, retrieve len + + ld hl,backBuffer ;transmit the compressed data + xor a + call TransmitData + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: ReceiveCompressedData +; Arguments: a - RAM bank to switch to (may/may not make a diff) +; bc - number of bytes to receive +; hl - starting address of data to receive +; Returns: Nothing. +; Alters: af +; Description: Receives numBytes/8 into the backBuffer, then unpacks +; each byte 1:8 to the data address. +;--------------------------------------------------------------------- +ReceiveCompressedData:: + push bc + push de + push hl + + push af ;save original RAM bank + push hl ;save original dest + + ;----Calculate numBytes/8 (>>3)------------------------------- + srl b + rr c + srl b + rr c + srl b + rr c + + ld hl,backBuffer ;receive the compressed data + xor a + call ReceiveData + + pop hl ;retrieve original dest + pop af ;retrieve original RAM bank + ldio [$ff70],a + + ;----Decompress the data into the destination buffer---------- + ld de,backBuffer ;decompression buffer +.nextByte + ld a,[de] ;get a byte from the buffer + inc de + push de ;push source + ld d,a ;store compressed byte in d + ld e,8 ;e is times to loop + +.nextBit + xor a + rl d ;get a bit off left side of compressed + rla ;shift onto right side of uncompressed + ld [hl+],a ;store in final destination + dec e + jr nz,.nextBit + + pop de ;pop source + + dec bc + xor a + cp b + jr nz,.nextByte + cp c + jr nz,.nextByte + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: CheckSimultaneousLCC +; Argument: a - byte received from link exchange +; Returns: not z flag - this machine must repeat its command +; z flag set - everything is okay +; Alters: af +; Description: Called after one machine has sent the first byte of +; a Link Command Code. If the remote machine +; coincidentally sent its own LCC at the same time then +; the Slave must delay its own LCC until the Master's +; LCC has been handled. +;--------------------------------------------------------------------- +CheckSimultaneousLCC:: + bit 7,a ;see if we got a LCC or a BCB. + ret z ;Got a BCB, everything's cool. + + ;Got a LCC. If I'm the Master then the other machine must + ;yield to me so everything's still cool. + push af + ld a,[amLinkMaster] + or a + jr z,.amSlave + pop af + xor a + ret + +.amSlave + ;I must yield to the Master. Handle his request and then + ;return a value indicating I must repeat my own request. + pop af + call HandleLCC + ld a,1 + or a + ret + +;--------------------------------------------------------------------- +; Routine: YankRemotePlayer +; Arguments: a - exit to set to (>7 means &7 and don't check +; to see if you're on the map) +; +; hl - map to set to in BCD (e.g. $0205) +; Returns: Nothing. +; Alters: af +; Description: Interrupts whatever the other player is doing and +; sets him to come to the specified map. Also sets +; the join/respawn map to the map to set to. +;--------------------------------------------------------------------- +YankRemotePlayer:: + push af + call UpdateState + call SetJoinMap + call SetRespawnMap + pop af + + ;verify link established + push hl + ld hl,amLinkMaster + bit 7,[hl] + pop hl + ret nz + + push af + push hl + ld a,2 ;two additional things on stack + ld hl,.linkBailAddress + call SetLinkBailOutAddress + + pop hl + +.sendYank + ld a,LYANKPLAYER + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.sendYank + pop af + + ;remote machine is listening; send map coords + call TransmitByte ;exit dir + ld a,l + call TransmitByte + ld a,h + call TransmitByte +.linkBailAddress + push hl + ld hl,0 + xor a + call SetLinkBailOutAddress + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: RemoveRemoteHero +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Deletes the remote hero and removes traces of its +; presence. +;--------------------------------------------------------------------- +RemoveRemoteHero:: + push bc + push de + push hl + + ;determine which is the remote hero + ld a,[amLinkMaster] + or a + jr z,.amSlave + +.amMaster + ld hl,hero1_index + jr .determinedRemoteHero + +.amSlave + ld hl,hero0_index + +.determinedRemoteHero + ;remove remote hero from map if present + ld a,[hl] ;heroX_index + or a + jr z,.done ;not here + + ;save the current ROM & switch in the object ROM + ldio a,[curROMBank] + push af + ld a,CLASSROM + call SetActiveROM + + ;----remove this one's heroesPresent flag---- + ld a,[hl] ;heroX_index + push af + + ld a,l + and 16 +IF HERODATASIZE!=16 +fix this +ENDC + swap a ;a is now 1 or 0 + add 1 ;now 2 or 1 + xor $ff ;now ~2 or ~1 + ld b,a + ld a,[heroesPresent] + and b + ld [heroesPresent],a + + ;push hl + ;ld de,(HERODATA_TYPE - HERODATA_INDEX) + ;add hl,de + ;ld a,[hl] ;heroX_type + ;xor $ff + ;ld b,a + ;ld a,[heroesPresent] + ;and b + ;ld [heroesPresent],a + ;pop hl + xor a + ld [hl],a ;heroX_index + pop af + + ld c,a + call GetFirst + ld b,METHOD_DIE + call CallMethod + + ;restore the old ROM + pop af + call SetActiveROM + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: DebugMesg +; Argument: hl - pointer to a gtx structure +; Returns: Nothing. +; Alters: af +; Description: Displays the given gtx string in a window for a +; brief period. +;--------------------------------------------------------------------- +DebugMesg:: + push bc + push de + push hl + + ldio a,[$ff40] + and %10000000 + jr z,.done + + ld d,h + ld e,l + xor a + + ;-------Show Dialog At Top------------------- + push af + push bc + push de + push hl + + ld b,0 ;lines to skip at top + ld a,[curROMBank] + call ShowDialogCommon + + xor a + ldh [$ff4a], a ;set window y position + + ld a,[de] ;number of lines + rlca ;times 8 = pixels for window + rlca + rlca + add 7 + ld [hblankWinOff],a + + ld a,143 + ld [hblankWinOn],a + + ld a,[hblankFlag] + bit 1,a + jr nz,.afterSetLYC + + ld a,143 + ld [$ff45],a ;lyc + ld a,[hblankFlag] + +.afterSetLYC + or %10 ;allow window to show + ld [hblankFlag],a + + pop hl + pop de + pop bc + pop af + ;-------Show Dialog At Top------------------- + + ld bc,16384 + call TimerDelay + call ClearDialog + +.done + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: DebugVal +; Argument: a - byte to show as a hex value +; Returns: Nothing. +; Alters: Nothing. +; Description: Displays the given value in hex using a Dialog +; window for a brief period. Game must be on. +;--------------------------------------------------------------------- +DebugVal:: + push af + push bc + push de + push hl + + ld b,a ;save byte + + ldio a,[$ff40] + and %10000000 + jr z,.done + + ld hl,$c200 + ld [hl],1 + inc hl + ld [hl],1 + inc hl + ld [hl],2 + inc hl + ld a,b + ld c,0 + swap a + and $0f + add 200 + ld [hl+],a + ld a,b + and $0f + add 200 + ld [hl+],a + ld de,$c200 + xor a + + ;-------Show Dialog At Top------------------- + push af + push bc + push de + push hl + + ld b,0 ;lines to skip at top + ld a,[curROMBank] + call ShowDialogCommon + + xor a + ldh [$ff4a], a ;set window y position + + ld a,[de] ;number of lines + rlca ;times 8 = pixels for window + rlca + rlca + add 7 + ld [hblankWinOff],a + + ld a,143 + ld [hblankWinOn],a + + ld a,[hblankFlag] + bit 1,a + jr nz,.afterSetLYC + + ld a,143 + ld [$ff45],a ;lyc + ld a,[hblankFlag] + +.afterSetLYC + or %10 ;allow window to show + ld [hblankFlag],a + + pop hl + pop de + pop bc + pop af + ;-------Show Dialog At Top------------------- + + ld bc,8192 ;16384 + call TimerDelay + call ClearDialog + +.done + pop hl + pop de + pop bc + pop af + ret + +;--------------------------------------------------------------------- +; Routine: TimerDelay +; Argument: bc - number of 16384's of a second to delay +; Alters: af +;--------------------------------------------------------------------- +TimerDelay:: + push bc + push de + push hl + + ld hl,$ff04 + ld d,0 ;prev value of time + ld [hl],0 +.wait + ld a,[hl] + ld e,a + xor d ;equal to prev value? + jr z,.wait + + ld d,e + dec bc + xor a + cp b + jr nz,.wait + cp c + jr nz,.wait + + pop hl + pop de + pop bc + ret + + +;--------------------------------------------------------------------- +; Routine: SetDialogSkip +; SetDialogForward +; Arguments: de - position to skip or fast forward to +; Alters: af +; Description: Saves the stack pointer (minus the space that this +; function call is taking up) and sets the go-to +; address for fast forwarding (any button pressed) +; or skipping (start button pressed). +;--------------------------------------------------------------------- +SetDialogSkip:: + push hl + ld hl,sp+4 ;stack ptr pos once returned from this fn + ld a,e + ld [levelCheckSkip+2],a ;set skip forward addr + ld a,d + ld [levelCheckSkip+3],a + jr SetDialogCommon + +SetDialogForward:: + push hl + ld hl,sp+4 ;stack ptr pos once returned from this fn + ld a,e ;set fast forward addr + ld [levelCheckSkip],a + ld a,d + ld [levelCheckSkip+1],a + jr SetDialogCommon + +SetSkipStackPos:: + push hl + ld hl,sp+4 ;stack ptr pos once returned from this fn + +SetDialogCommon: + ld a,l + ld [levelCheckStackPos],a + ld a,h + ld [levelCheckStackPos+1],a + pop hl + ret + +;--------------------------------------------------------------------- +; Routine: ClearDialogSkipForward +; Arguments: None. +; Alters: af,hl +;--------------------------------------------------------------------- +ClearDialogSkipForward:: + call ClearDialog + call ClearSkipForward + ret + +;--------------------------------------------------------------------- +; Routine: ClearSkipForward +; Arguments: None. +; Alters: af,hl +;--------------------------------------------------------------------- +ClearSkipForward:: + ld de,0 + call SetDialogSkip + call SetDialogForward + ret + +;--------------------------------------------------------------------- +; Routine: SetRespawnMap +; Arguments: hl - map to go to after hero dies +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +SetRespawnMap:: + ld a,l + ld [respawnMap],a + ld a,h + ld [respawnMap+1],a + ret + +;--------------------------------------------------------------------- +; Routine: SetJoinMap +; Arguments: hl - map to join from 2nd player title screen +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +SetJoinMap:: + ld a,l + ld [joinMap],a + ld a,h + ld [joinMap+1],a + ret + +;--------------------------------------------------------------------- +; Routine: SetLinkBailOutAddress +; Arguments: a - number of additional words to add to stack +; pointer +; hl - saves stack pointer and bailout address into +; [linkBailOut0...3]. +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +SetLinkBailOutAddress:: + push hl + push af + ;save bail out address + ld a,l + ld [linkBailOut],a + ld a,h + ld [linkBailOut+1],a + + ;save stack pointer (plus a*2 + 6 for things pushed on stack) + ld hl,sp+6 + pop af + or a + jr z,.afterAdjustStackPointer + +.adjustStackPointer + inc hl + inc hl + dec a + jr nz,.adjustStackPointer + +.afterAdjustStackPointer + ld a,l + ld [linkBailOut+2],a + ld a,h + ld [linkBailOut+3],a + + pop hl + ret + + +;--------------------------------------------------------------------- +; Routine: RemoveSpriteObjectsFromMap +;--------------------------------------------------------------------- +RemoveSpriteObjectsFromMap: + ;----remove all objects from the map-------------------------- + ld a,OBJLISTBANK + ldio [$ff70],a + ld hl,objExists+1 +.removeObjectsLoop + push hl + ld a,[hl] + or a + jr z,.removeObjects_continue + ld a,l + call IndexToPointerDE + ld a,[numClasses] + ld b,a + inc b + ld h,((objClassLookup>>8) & $ff) + ld a,[hl] + cp b ;this obj a regular creature? + jr nc,.removeObjects_continue + + call GetFacing + bit 7,a ;sprite? + jr z,.restoreObjListBank ;no + ld c,a + call RemoveFromMap +.restoreObjListBank + ld a,OBJLISTBANK + ldio [$ff70],a +.removeObjects_continue + pop hl + inc hl + ld a,h + cp ((objExists>>8) & $ff) + 1 + jr nz,.removeObjectsLoop + ret + +;--------------------------------------------------------------------- +; Routine: GetMethodAddrFromPointer +; Arguments: hl - pointer to method address +; Returns: hl - pointer to method +; Alters: af +;--------------------------------------------------------------------- +GetMethodAddrFromPointer:: + PUSHROM + ld a,BANK(classTable) + call SetActiveROM + + ld a,[hl+] + ld h,[hl] + ld l,a + + POPROM + ret + +;--------------------------------------------------------------------- +; Routine: InstallHBlankHandler +; Arguments: hl - pointer to hblank handler +; Returns: Nothing. +; Alters: af +;--------------------------------------------------------------------- +InstallHBlankHandler:: + di + ld a,l + ld [hblankVector+1],a ;+0 is opcode "jp" + ld a,h + ld [hblankVector+2],a + ei + ret + +;--------------------------------------------------------------------- +; Routine: LockRemoteHeroesUsed +; Arguments: None. +; Returns: z - lock attempt unsuccessful +; nz - success +; Alters: af +; Description: Informs the remote machine that this machine is +; messing with the heroes to prevent collisions +;--------------------------------------------------------------------- +LockRemoteHeroesUsed:: + ld a,[amLinkMaster] + bit 7,a + jr nz,.lockOkay + +.sendLock + ld a,[heroesLocked] + or a + jr nz,.returnFailure + ld a,LLOCKHEROES + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.sendLock + + ld a,1 ;send "locked" to remote + call TransmitByte + +.lockOkay + ld a,1 + ld [heroesLocked],a + or a + ret + +.returnFailure + xor a + ret + +;--------------------------------------------------------------------- +; Routine: UpdateRemoteHeroesUsed +; Arguments: None. +; Returns: Nothing. +; Alters: af +; Description: Sends current [heroesUsed] to the remote machine +; if present. Also unlocks heroesUsed if locked. +;--------------------------------------------------------------------- +UpdateRemoteHeroesUsed:: + ld a,[amLinkMaster] + bit 7,a + jr z,.updateHeroesUsed + + ;no link, free lock + xor a + ld [heroesLocked],a + ret + +.updateHeroesUsed + ld a,LUPDATEHERO + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.updateHeroesUsed ;must repeat + + ld a,[heroesUsed] + call TransmitByte + + ld a,[heroesLocked] + or a + ret z ;not locked don't bother + +.sendLock + ld a,LLOCKHEROES + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.sendLock + + xor a ;send "unlocked" to remote + ld [heroesLocked],a + call TransmitByte + + ret + +;--------------------------------------------------------------------- +; Routine: PlaySample +; Arguments: a - bank of sample +; hl - start address of sample +; Alters: af,hl +; Description: +;--------------------------------------------------------------------- +PlaySample:: + ;start sample playing + di + ldio [sampleBank],a + xor a + ldio [samplePlaying],a + ei + + ld a,l + ldio [sampleAddress],a + ld a,h + ldio [sampleAddress+1],a + ld a,$0f + ldio [sampleMask],a + ld a,$86 + ldio [$ff1a],a ;sound 3 enable + ld hl,$ff26 + set 2,[hl] + ld a,1 + ldio [samplePlaying],a + ret + +;--------------------------------------------------------------------- +; FinishHBlankPlayingSample +;--------------------------------------------------------------------- +FinishHBlankPlayingSample:: + ldio a,[samplePlaying] + or a + jr z,.done + +.nextSample + ld hl,sampleAddress + ld a,[hl+] + ld h,[hl] + ld l,a +.loadNextSample + ldio a,[sampleBank] + ld [$2100],a + ldio a,[sampleMask] + xor $ff + ldio [sampleMask],a + cp $0f + jr nz,.getLeftNibble + +.getRightNibble + and a,[hl] + inc hl + jr .normalData ;will never be special code + +.getLeftNibble + and a,[hl] ;next sample byte + +.checkForSpecialCodes + cp $80 + jr nz,.normalData + + ;code indicating termination or link follows + inc hl + ld a,[hl+] + or a + jr nz,.link + + ld [samplePlaying],a + ld a,$ff + ld [$ff24],a ;full volume both channels + jr .restoreBank + +.link ld a,[hl+] + ld [sampleBank],a + ld a,[hl+] + ld h,[hl] + ld l,a + jr .loadNextSample + +.normalData + ld b,a + swap a + or b + or $88 + ldio [$ff24],a ;sound enabled/volume + +.saveNewAddress + ld a,l + ldio [sampleAddress],a + ld a,h + ldio [sampleAddress+1],a + +.restoreBank + ldio a,[curROMBank] + ld [$2100],a + +.done + pop hl + pop bc + pop af + reti + +;--------------------------------------------------------------------- +; Routine: Lookup8 +; Arguments: a - index +; hl - start lookup table +; Alters: af,hl +; Returns: a - table[a] +;--------------------------------------------------------------------- +Lookup8:: + add l + ld l,a + ld a,h + adc 0 + ld h,a + ld a,[hl] + ret + +;--------------------------------------------------------------------- +; Routine: Lookup16 +; Arguments: a - index +; hl - start lookup table +; Alters: af,hl +; Returns: hl - table[a*2] +;--------------------------------------------------------------------- +Lookup16:: + push de + ld e,a + ld d,0 + sla e + rl d + add hl,de + ld a,[hl+] + ld h,[hl] + ld l,a + pop de + ret + +;--------------------------------------------------------------------- +; Routine: LookupIndexOfData8 +; Arguments: a - data +; hl - start of lookup table +; Alters: af,hl +; Returns: a - where table[a] is original data a. +; Data must exist! +;--------------------------------------------------------------------- +LookupIndexOfData8:: + push bc + + ld c,0 +.findLoop + cp [hl] + jr z,.done + + inc c + inc hl + jr .findLoop + +.done + ld a,c + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: FindFirstBGLoc +; Arguments: hl - bg class to find (e.g. classClearanceBG) +; Returns: hl - first location of class +; a - 0 on failure +; zflag - or a +; Alters: af +;--------------------------------------------------------------------- +FindFirstBGLoc:: + push bc + push de + + push hl + pop bc + call FindClassIndex + ld b,a + + ld a,MAPBANK + ld [$ff70],a + + ;setup de with first out-of-bounds index + ld a,[mapTotalSize] + ld e,a + ld a,[mapTotalSize+1] + ld d,a + + ld hl,map +.lookForFirst + ld a,[hl+] + cp b + jr z,.foundIt + + ;hl < de? + ld a,h + cp d + jr c,.lookForFirst + + ld a,l + cp e + jr c,.lookForFirst + + ;not found + xor a + jr .done + +.foundIt + dec hl + ld a,1 + or a + +.done + pop de + pop bc + + ret + +;--------------------------------------------------------------------- +; Routine: LinkTransmitMemoryLocation +; Arguments: a - RAM bank +; hl - memory location to transmit to the remote +; GameBoy +; Alters: af +;--------------------------------------------------------------------- +LinkTransmitMemoryLocation:: + push bc + ld b,a + + ld a,[amLinkMaster] + bit 7,a + jr nz,.done ;not linked + +.requestTransmit + ld a,LUPDATEMEMORY + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.requestTransmit + + ld a,b + ldio [$ff70],a + call TransmitByte + ld a,l + call TransmitByte + ld a,h + call TransmitByte + ld a,[hl] + call TransmitByte + +.done + pop bc + ret + + +;--------------------------------------------------------------------- +; Link Code +;--------------------------------------------------------------------- +SECTION "LinkCodeSection",ROMX +linkCode: + + +;--------------------------------------------------------------------- +; Routine: HandleInput +; Description: Polls the buttons and stores the input in [curInput0]. +; Then performs some network code and sets up [curJoy0], +; [curJoy1], [curInput0], and [curInput1]. curJoyX may +; be set to zero elsewhere to prevent the heroes from +; moving but curInput0 and curInput1 will always be the +; original values. +; +; $80 - 7:Start +; $40 - 6:Select +; $20 - 5:B +; $10 - 4:A +; $08 - 3:Down +; $04 - 2:Up +; $02 - 1:Left +; $01 - 0:Right +; +; A linked Master should read its input from [curJoy0]. +; A linked Slave should read its input from [curJoy1]. +; To make this easier [myJoy] is set up to be the +; appropriate one. +; +; If no link connection established, attempt a link +; connection. +; +; If no link: +; Convert curInput0->Joy1 (result will be same as +; encoding then decoding curInput). +; +; If link connection established: +; Exchange Control Byte with linked machine. If +; Command Code gotten in return, perform requested +; action and then repeat attempt to exchange control +; byte. +; +; If Master: curInput0->Joy1, remoteInput->Joy2 +; If Slave: curInput0->Joy2, remoteInput->Joy1 +;--------------------------------------------------------------------- +HandleInput: + ld a,$20 + ldio [$ff00],a ;select P14 + ldio a,[$ff00] + ldio a,[$ff00] ;wait a few cycles + cpl + and $0f + ld b,a ;b has direction info + ld a,$10 ;select P15 + ld [$ff00],a + ldio a,[$ff00] ;wait mo + ldio a,[$ff00] ;wait mo + ldio a,[$ff00] ;wait mo + ldio a,[$ff00] ;wait mo + ldio a,[$ff00] ;wait mo + ldio a,[$ff00] ;wait mo + cpl + and $0f + swap a + or b ;a has all buttons + ld [curInput0],a + ld a,$30 ;deselect P14 and P15 + ldio [$ff00],a + + ;--if no link, attempt link connection ---------------------- + ld a,[amLinkMaster] + cp $ff + jr z,.afterLinkAttempt ;L1101 attempts link as slave + cp $fe ;attempt link as master? + jr nz,.afterLinkAttempt + +.attemptLinkAsMaster + ld a,$55 + ldio [$ff01],a ;exchange data = $55 + ld a,INTCLK ;ready to xchg, use my clock + ldio [$ff02],a + +.waitMasterLinkAttempt + ldio a,[$ff02] + and $80 + jr nz,.waitMasterLinkAttempt + + ;see what we got + ldio a,[$ff01] + cp $aa + jr nz,.afterLinkAttempt + + ;found a Slave! That means I'm the Master! + ld a,EXTCLK ;switch to receive mode + ldio [$ff02],a + ld a,1 + ld [amLinkMaster],a + ld [lastLinkAction],a + +.afterLinkAttempt + ld a,[amLinkMaster] + bit 7,a + jr z,.amLinked + + ;no link, convert curInput->curJoy0. + ld a,[curInput0] + call ConvertInput + ld [curInput0],a + ld [curJoy0],a + ld [myJoy],a + xor a + ld [curJoy1],a + ld [curInput1],a + ret + +.amLinked + +IF 0 + ;----every second or so, get the remote machine's + ;----random seed and make sure it matches ours. + ;----Resynchronize the machines if not + ld a,[amLinkMaster] + cp 1 + jr nz,.exchangeBCB ;only master can initiate + + ld a,[updateTimer] ;not time yet + and 31 + cp 31 + jr nz,.exchangeBCB + + ;don't do it if can't join map + ld a,[canJoinMap] + or a + jr z,.exchangeBCB + +.getRandomSeed + ld a,LGETRANDOMSEED ;send the request + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.getRandomSeed ;must repeat + + ;get the actual seed + call ReceiveByte + ld b,a + ld a,[randomLoc] + cp b ;got same in return? + jr z,.exchangeBCB ;continue if yes + + ;on same map? + ld a,[heroesPresent] + cp %11 + jr nz,.exchangeBCB ;not on same map + +.resynchronize + ;resynchronize machines + ld a,LRESYNCHRONIZE + call ExchangeByte + call CheckSimultaneousLCC + jr nz,.resynchronize + LONGCALLNOARGS HostResynchronize +ENDC + +.exchangeBCB + ;----exchange Button Control Bytes with remote machine-------- + ld a,[curInput0] + call EncodeInput + call ExchangeByte + call HandleRemoteInput + jr nz,.exchangeBCB ;must repeat + + ;--Decode Button Control Bytes-------------------------------- + push af ;save remoteInput + ld a,[amLinkMaster] + or a + jr z,.amLinkSlave + + ;I am the master. curInput0->curJoy0, remoteInput->curJoy1 + pop af ;retrieve remoteInput + call DecodeInput + ld [curInput1],a + ld [curJoy1],a + ld a,[curInput0] + call ConvertInput + ld [curInput0],a + ld [curJoy0],a + ld [myJoy],a + ret + +.amLinkSlave + ld a,[curInput0] + call ConvertInput + ld [curInput1],a + ld [curJoy1],a + ld [myJoy],a + + pop af ;retrieve remoteInput + call DecodeInput + ld [curInput0],a + ld [curJoy0],a + ret + +;--------------------------------------------------------------------- +; Routine: ConvertInput +; Argument: a - uncoded button control byte +; Returns: a - converted BCB, same as calling Encode then +; Decode but quicker +; Description: To simulate uncoded->encoded->decoded, forces buttons +; 7:4 to have A/B or Start/Select info but not both +; (A/B has priority). +; Alters: af +;--------------------------------------------------------------------- +ConvertInput: + push bc + + ld b,a ;save original + and %00110000 ;has A/B info? + ld a,b ;restore original + jr z,.done ;if no AB info then conv. complete + and %00111111 ;has AB info; clear out start/sel + +.done + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: EncodeInput +; Argument: a - uncoded button control byte +; 7:st 6:se 5:b 4:a 3:0=DULR +; Returns: a - coded button control byte +; 7=0 +; 6=0 - 5:4 = ba +; =1 - 5:4 = te (start, select) +; 3:0 = DULR +; Alters: af +;--------------------------------------------------------------------- +EncodeInput: + push bc + push hl + + ld b,a ;save original + and %00001111 + ld c,a ;save D-PAD + + ld h,((encodeControlByteTable>>8) & $ff) + ld a,b + swap a + and %00001111 + add (encodeControlByteTable & $ff) + ld l,a + + ld a,[hl] ;get encoded buttons + or c ;combine with D-PAD + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: DecodeInput +; Argument: a - coded Control Byte +; Returns: a - uncoded button Control Byte +; Alters: af +;--------------------------------------------------------------------- +DecodeInput: + push bc + push hl + + ld b,a ;save original + and %00001111 + ld c,a ;save D-PAD + + ld h,((decodeControlByteTable>>8) & $ff) + ld a,b + swap a + and %00000111 + add (decodeControlByteTable & $ff) + ld l,a + + ld a,[hl] ;get decoded buttons + or c ;combine with D-PAD + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: TransmitGameState +; Arguments: none +; Returns: none +; Alters: af +; Description: Transmits relevant game state data to Slave +; Includes hero data so slave's classes will be set +; appropriately +;--------------------------------------------------------------------- +TransmitGameState: + push bc + push hl + + ld hl,.linkBailAddress + xor a + call SetLinkBailOutAddress + + ld hl,gameState + ld bc,5 + xor a ;RAM bank doesn't matter + call TransmitData + + ld hl,levelState + ld bc,256 + ld a,LEVELSTATEBANK + call TransmitData + + ld hl,inventory + ld bc,16 + xor a + call TransmitData + + ld hl,flightCode + ld bc,256 + ld a,FLIGHTCODEBANK + call TransmitData + + ld hl,hero0_data + ld bc,HERODATASIZE * 2 + xor a + call TransmitData + + ld a,[appomattoxMapIndex] + call TransmitByte + + ;send the joinMap + ld a,[joinMap] + call TransmitByte + ld a,[joinMap+1] + call TransmitByte + +.linkBailAddress + ld hl,0 + xor a + call SetLinkBailOutAddress + + pop hl + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: HostSynchronize +; Arguments: none +; Returns: none +; Alters: af +; Description: Transmits relevant map data to Guest +;--------------------------------------------------------------------- +HostResynchronize: + push bc + push hl + jr HostSynchronizeCommon + +HostSynchronize: + push bc + push hl + + ld hl,.nogo + xor a + call SetLinkBailOutAddress + + ld a,1 ;make sure it's looking at 1x1 + ldio [curObjWidthHeight],a + call ReceiveByte ;guest's requested exit direction + ld hl,$0101 ;start looking at (1,1) + call FindExitLocation + xor a ;didn't find it if $0000 + cp h + jr nz,.goAhead + cp l + jr nz,.goAhead + + ;nogo + xor a + call TransmitByte +.nogo + ld hl,0 + xor a + call SetLinkBailOutAddress + + pop hl + pop bc + ret + +.goAhead + call ConvertLocHLToXY + ld a,1 + call TransmitByte + + ldio a,[mapState] ;level state + call TransmitByte + ldio a,[mapState+1] + call TransmitByte + + ;make sure backbuffer doesn't redraw during hero loading + xor a + ldio [backBufferReady],a + + ;activate heroes 0 and 1 + ld a,[hero0_index] + or a + jr nz,.hero0_active + + ld a,1 + ld [hero0_index],a + +.hero0_active + ld a,[hero1_index] + or a + jr nz,.hero1_active + + ld a,1 + ld [hero1_index],a +.hero1_active + call HostExchangeHeroData + + ;set hero 1 to joystick 1 + push hl + ld a,[hero1_type] + ld hl,heroJoyIndex + or [hl] + ld [hl],a + pop hl + + inc hl + ld b,h + ld c,l + PREPLONGCALL .afterSetupHero + LONGCALL PrepSetupHeroBC ;bc is correct hero data +.afterSetupHero + +HostSynchronizeCommon: + xor a + ld [backBufferReady],a + + ;wait on ready signal from guest +.waitReady + call ReceiveByte + cp LSYNCHREADY + jr nz,.waitReady + + ;send all my hero data ;re-send all my hero data + ld hl,hero0_data + ld bc,HERODATASIZE*2 + xor a + call TransmitData + + ld a,[randomLoc] ;current random value/seed + call TransmitByte + + ld a,[heroesIdle] + call TransmitByte + + LONGCALLNOARGS RemoveSpriteObjectsFromMap + + ;----transmit map--------------------------------------------- + ld hl,map + ld bc,4096 + ld a,MAPBANK + call TransmitData + + ;fadeCurPalette + ld hl,fadeCurPalette + ld bc,128 + xor a + call TransmitData + + ;gamePalette + ld hl,gamePalette + ld bc,128 + ld a,FADEBANK + call TransmitData + + ;first 16 bytes of level check RAM + ld hl,levelCheckRAM + ld bc,16 + xor a + call TransmitData + + ;spriteOAMdata + ld hl,spriteOAMBuffer + ld bc,160 + xor a + call TransmitData + + ld hl,headTable ;headTable - linked list head + ld bc,256 + ld a,OBJLISTBANK + call TransmitData + + ld hl,objExists ;objExists, FOF table + ld bc,512 + ld a,OBJLISTBANK + call TransmitCompressedData + + ld a,[numClasses] + call TransmitByte + + ;bc = numClasses times two + 2 + ld a,[numClasses] + ld b,0 + ld c,a + sla c + rl b + inc bc + inc bc + + ld hl,classLookup ;objExists, FOF table + ;ld bc,512 numClasses * 2 + ld a,OBJLISTBANK + call TransmitData + + ld hl,fgTileMap + ld a,[numClasses] + ld b,0 + ld c,a + ld a,OBJLISTBANK + call TransmitData + + ld hl,objClassLookup ;class indices for each obj + ld bc,256 + ld a,OBJLISTBANK + call TransmitData + + ld hl,associatedIndex + ld bc,256 + ld a,OBJLISTBANK + call TransmitData + + ld hl,spritesUsed + ld bc,40 + ld a,OBJLISTBANK + call TransmitCompressedData + + ;---------------transmit used objects------------------------- + ld a,OBJLISTBANK + ld [$ff70],a + ld de,objExists+1 +.transmitUsedObject + ld a,[de] ;is this object used? + or a + jr z,.afterTransmitUsedObject ;not used + + PREPLONGCALL .afterCvtToPtr + ld a,e ;get object index + LONGCALL IndexToPointerHL ;cvt to ptr +.afterCvtToPtr + ld bc,16 + ld a,OBJBANK + call TransmitData + ld a,OBJLISTBANK + ld [$ff70],a + +.afterTransmitUsedObject + inc de + ld a,e + or a + jr nz,.transmitUsedObject + + ld a,[numFreeSprites] + call TransmitByte + + ld a,[firstFreeObj] + call TransmitByte + + ld a,[randomLoc] + call TransmitByte + + ld a,[guardAlarm] + call TransmitByte + + ;ld a,[dialogBank] + ;call TransmitByte + + ld a,[respawnMap] + call TransmitByte + ld a,[respawnMap+1] + call TransmitByte + + ldio a,[mapState] ;level state + call TransmitByte + ldio a,[mapState+1] + call TransmitByte + + ld hl,levelVars + ld bc,64 + xor a ;RAM bank doesn't matter + call TransmitData + + ld hl,musicBank + ld bc,64 + xor a ;RAM bank doesn't matter + call TransmitData + + ld hl,musicStack + ld bc,128 + ld a,MUSICBANK + call TransmitData + + ldio a,[musicEnabled] + call TransmitByte + + LONGCALLNOARGS LinkRemakeLists + +.done + pop hl + pop bc + ret + +HostExchangeHeroData: + ;send out my hero data + ld a,[amLinkMaster] + or a + jr z,.slave_sendHero1_recvHero0 + +.master_sendHero0_recvHero1 + ld hl,hero1_data + push hl + ld hl,hero0_data + jr .setHeroSequence + +.slave_sendHero1_recvHero0 + ld hl,hero0_data + push hl + ld hl,hero1_data + +.setHeroSequence + ;send my hero data + ld bc,HERODATASIZE + xor a + call TransmitData + + ;get remote hero data + pop hl + xor a + call ReceiveData + + ret + + +;--------------------------------------------------------------------- +; Routine: LinkTest +; Arguments: none +; Returns: none +; Alters: af +; Description: Fills 4k of memory with repeating pattern $00-$ff, +; transmits that data to Slave, receives that data +; back, compares it to the original pattern, and +; finally prints out a Debug message of 1 for equal +; or 0 for not equal. +;--------------------------------------------------------------------- +LinkTest: + push bc + push de + push hl + + di + ;fill $d000-$cfff with repeating pattern $00-$ff + ld a,1 + ld [$ff70],a + + ld hl,$d000 + xor a +.fill + ld [hl+],a + inc a + jr nz,.fill + ld a,h + cp $e0 + ld a,0 ;avoid setting z flag here + jr nz,.fill + + ld a,4 +.transfer32k + push af + ld a,1 + ld bc,$1000 + ld hl,$d000 + call TransmitData + + ld a,1 + call ReceiveData + pop af + dec a + jr nz,.transfer32k + + ;compare received data to original pattern + ld b,0 ;comparing to $00 + ld hl,$d000 +.compare + ld a,[hl+] + cp b + jr nz,.notEqual + inc b + ld a,h + cp $e0 + jr nz,.compare + +.equal + xor a + ldio [$ff0f],a + ei + ld a,1 + call DebugVal + jr .infi + +.notEqual + xor a + ldio [$ff0f],a + ei + xor a + call DebugVal + + dec hl + ld a,h + call DebugVal + ld a,l + call DebugVal +di +.infi jr .infi + + pop hl + pop de + pop bc + ret + +;--------------------------------------------------------------------- +; Routine: GeneratePauseMessage +; Arguments: none +; Returns: none +; Alters: all +; Description: Creates appropriate Pause Message +;--------------------------------------------------------------------- +GeneratePauseMessage: + ld a,[dialogBank] + push af + + ;wait until the backbuffer is blitted +.waitBackBuffer + ldio a,[backBufferReady] + or a + jr z,.canMessWithBackBuffer + + call VWait + jr .waitBackBuffer + +.canMessWithBackBuffer + ;generate gtx at backbuffer+$800 + + ;de = level name index + ld a,[curLevelStateIndex] + ld d,0 + ld e,a ;level index * 2 + sla e + rl d + ld hl,levelNames + add hl,de + ld a,[hl+] + ld e,a + ld a,[hl+] + ld d,a + ld hl,backBuffer + ld a,BANK(levelNames) + ld [dialogBank],a + call ClearGTXLine + call WriteGTXLine + + ;write char name + push hl + push hl + LDHL_CURHERODATA HERODATA_TYPE + ld a,[hl] + ld c,$ff +.findCharIndex + inc c + rrca + bit 7,a + jr z,.findCharIndex + ld a,c + ld hl,heroNames + call .lookupIndexAToHLToDE + pop hl + call ClearGTXLine + call WriteGTXLine + pop hl + + ;write map coordinates + add sp,-24 ;create temporary buffer on stack + push hl + ld hl,sp+2 + ld d,h + ld e,l + ld [hl],16 ;spaces to center + inc hl + ld [hl],4 ;number of chars + inc hl + ld a,[curLevelStateIndex] + push af + and $f + add 210 ;'A' character + ld [hl+],a + pop af + ld [hl],$f9 ;hyphen + inc hl + swap a + and $f + cp 10 + jr c,.oneDigit + ld [hl],201 ;'1' + inc hl + sub 10 +.oneDigit + add 200 ;get digit '0'-'9' + ld [hl+],a + ld [hl],0 ;blank space may or may not be used + pop hl + push de + call WriteGTXLine ;de is line to write + pop de + + ;write map coordinates if landing zone------------------------ + ld c,2 ;# of items in inventory screen + + push bc ;see if we're at an LZ + ld a,[curLevelStateIndex] + call .getFlightCodeBCFromMapA + pop bc + jr z,.afterWriteCoords + + push hl + ld h,d + ld l,e + ld [hl],8 ;spaces to center + inc hl + ld [hl],4 ;number of chars + inc hl + push bc + ld a,[curLevelStateIndex] + call .getFlightCodeBCFromMapA + call .writeCoordsBC + pop bc + pop hl + call ClearGTXLine + call WriteGTXLine ;de is line to write + inc c +.afterWriteCoords + add sp,24 ;free up temporary stack space + + ;write inventory + call GetFirstInventoryIndex + cp $ff + jr z,.afterWriteInventory + + ;blank line + push af + ld de,blankLine + call ClearGTXLine + call WriteGTXLine + inc c + pop af + + ;remaining inventory +.nextInventoryItem + ld b,a ;obj index in b + push af + push hl + ld hl,itemNames + call .lookupIndexAToHLToDE + pop hl + + inc de + ld a,[de] + dec de + or a + jr z,.skipItem ;an upgrade or something + + call ClearGTXLine + push hl + call WriteGTXLine + + ;write object color + ld a,b + add (itemColors&$ff) + ld e,a + ld a,((itemColors>>8)&$ff) + adc 0 + ld d,a + ld a,[de] + or 8 + pop de + push hl + ld hl,$300 + add hl,de + ld [hl],a + pop hl + inc c +.skipItem + pop af + call GetNextInventoryIndex + cp $ff + jr nz,.nextInventoryItem + +.afterWriteInventory + inc c + ld de,restart_message + call ClearGTXLine + call WriteGTXLine + + ld a,c + ld [backBuffer+63],a ;#lines + + pop af + ld [dialogBank],a + ret + +.getFlightCodeBCFromMapA + ;returns flight code in bc, zflag + push de + push hl + ld de,3 + + ld b,a + ld a,FLIGHTCODEBANK + ldio [$ff70],a + ld hl,flightCode + ld c,[hl] ;number of flight codes + add hl,de ;start at byte 2/3 (map index) +.findFlightCode + ld a,[hl] + cp b + jr z,.getFlightCodeMatch + add hl,de + dec c + jr nz,.findFlightCode + + xor a ;not found + pop hl + pop de + ret + +.getFlightCodeMatch + dec hl + ld b,[hl] + dec hl + ld c,[hl] + pop hl + pop de + ld a,1 + or a + ret + +.lookupIndexAToHLToDE + rlca + add l + ld l,a + ld a,h + adc 0 + ld h,a + ld a,[hl+] + ld d,[hl] + ld e,a + ret + +.writeCoordsBC + ld a,b + swap a + call .writeCoordA + ld a,b + call .writeCoordA + ld a,c + swap a + call .writeCoordA + ld a,c + call .writeCoordA + ret + +.writeCoordA + and $f + add $c0 ;first of 8 coordinate symbols + ld [hl+],a + ret + +restart_message: + GTXSTRINGC "SELECTgoRESTART" +blankLine: + DB 0,0 + +;--------------------------------------------------------------------- +; Routine: CopyMessageDEToHL +; Arguments: de - pointer to message +; hl - pointer to dest +; Returns: none +; Alters: all +; Description: First byte at [de] is number of bytes to copy from +; [de] to [hl]. Must be >= 1! +;--------------------------------------------------------------------- +CopyMessageDEToHL: + ld a,[de] + inc de + ld c,a +.loop ld a,[de] + inc de + ld [hl+],a + dec c + jr nz,.loop + ret + +levelNames: + DW L0000_Name,L0100_Name,L0200_Name,L0300_Name + DW L0400_Name,L0500_Name,L0600_Name,L0700_Name + DW L0800_Name,L0900_Name,L1000_Name,L1100_Name + DW L1200_Name,L1300_Name,L1400_Name,L1500_Name + + DW L0001_Name,L0101_Name,L0201_Name,L0301_Name + DW L0401_Name,L0501_Name,L0601_Name,L0701_Name + DW L0801_Name,L0901_Name,L1001_Name,L1101_Name + DW L1201_Name,L1301_Name,L1401_Name,L1501_Name + + DW L0002_Name,L0102_Name,L0202_Name,L0302_Name + DW L0402_Name,L0502_Name,L0602_Name,L0702_Name + DW L0802_Name,L0902_Name,L1002_Name,L1102_Name + DW L1202_Name,L1302_Name,L1402_Name,L1502_Name + + DW L0003_Name,L0103_Name,L0203_Name,L0303_Name + DW L0403_Name,L0503_Name,L0603_Name,L0703_Name + DW L0803_Name,L0903_Name,L1003_Name,L1103_Name + DW L1203_Name,L1303_Name,L1403_Name,L1503_Name + + DW L0004_Name,L0104_Name,L0204_Name,L0304_Name + DW L0404_Name,L0504_Name,L0604_Name,L0704_Name + DW L0804_Name,L0904_Name,L1004_Name,L1104_Name + DW L1204_Name,L1304_Name,L1404_Name,L1504_Name + + DW L0005_Name,L0105_Name,L0205_Name,L0305_Name + DW L0405_Name,L0505_Name,L0605_Name,L0705_Name + DW L0805_Name,L0905_Name,L1005_Name,L1105_Name + DW L1205_Name,L1305_Name,L1405_Name,L1505_Name + + DW L0006_Name,L0106_Name,L0206_Name,L0306_Name + DW L0406_Name,L0506_Name,L0606_Name,L0706_Name + DW L0806_Name,L0906_Name,L1006_Name,L1106_Name + DW L1206_Name,L1306_Name,L1406_Name,L1506_Name + + DW L0007_Name,L0107_Name,L0207_Name,L0307_Name + DW L0407_Name,L0507_Name,L0607_Name,L0707_Name + DW L0807_Name,L0907_Name,L1007_Name,L1107_Name + DW L1207_Name,L1307_Name,L1407_Name,L1507_Name + + DW L0008_Name,L0108_Name,L0208_Name,L0308_Name + DW L0408_Name,L0508_Name,L0608_Name,L0708_Name + DW L0808_Name,L0908_Name,L1008_Name,L1108_Name + DW L1208_Name,L1308_Name,L1408_Name,L1508_Name + + DW L0009_Name,L0109_Name,L0209_Name,L0309_Name + DW L0409_Name,L0509_Name,L0609_Name,L0709_Name + DW L0809_Name,L0909_Name,L1009_Name,L1109_Name + DW L1209_Name,L1309_Name,L1409_Name,L1509_Name + + DW L0010_Name,L0110_Name,L0210_Name,L0310_Name + DW L0410_Name,L0510_Name,L0610_Name,L0710_Name + DW L0810_Name,L0910_Name,L1010_Name,L1110_Name + DW L1210_Name,L1310_Name,L1410_Name,L1510_Name + + DW L0011_Name,L0111_Name,L0211_Name,L0311_Name + DW L0411_Name,L0511_Name,L0611_Name,L0711_Name + DW L0811_Name,L0911_Name,L1011_Name,L1111_Name + DW L1211_Name,L1311_Name,L1411_Name,L1511_Name + + DW L0012_Name,L0112_Name,L0212_Name,L0312_Name + DW L0412_Name,L0512_Name,L0612_Name,L0712_Name + DW L0812_Name,L0912_Name,L1012_Name,L1112_Name + DW L1212_Name,L1312_Name,L1412_Name,L1512_Name + + DW L0013_Name,L0113_Name,L0213_Name,L0313_Name + DW L0413_Name,L0513_Name,L0613_Name,L0713_Name + DW L0813_Name,L0913_Name,L1013_Name,L1113_Name + DW L1213_Name,L1313_Name,L1413_Name,L1513_Name + + DW L0014_Name,L0114_Name,L0214_Name,L0314_Name + DW L0414_Name,L0514_Name,L0614_Name,L0714_Name + DW L0814_Name,L0914_Name,L1014_Name,L1114_Name + DW L1214_Name,L1314_Name,L1414_Name,L1514_Name + + DW L0015_Name,L0115_Name,L0215_Name,L0315_Name + DW L0415_Name,L0515_Name,L0615_Name,L0715_Name + DW L0815_Name,L0915_Name,L1015_Name,L1115_Name + DW L1215_Name,L1315_Name,L1415_Name,L1515_Name + +L0000_Name: + GTXSTRINGC "THEoHIVE" +L0001_Name: + GTXSTRINGC "MADoBEEoPASS" +L0002_Name: + GTXSTRINGC "BEEoCOUNTRY" +L0003_Name: + GTXSTRINGC "BIGoEDaSoSHEEPoFARM" +L0004_Name: + GTXSTRINGC "HILLoBROTHERSoRANCH" +L0005_Name: + GTXSTRINGC "TRAKKTORoCOUNTRY" +L0006_Name: + GTXSTRINGC "SUNSEToVILLAGE" +L0007_Name: + GTXSTRINGC "CRAZYoCROWoGULCH" +L0008_Name: + GTXSTRINGC "SNEAKYoTREEoVALLEY" +L0009_Name: + GTXSTRINGC "PROVOLONE" +L0010_Name: + GTXSTRINGC "MUENSTER" +L0011_Name: + GTXSTRINGC "HOUSEoOFoSEASONS" +L0012_Name: + GTXSTRINGC "COMMANDoCORE" +L0013_Name: + GTXSTRINGC "ITCHYoTRIGGER" +L0014_Name: + GTXSTRINGC "THEoFAULT" +L0015_Name: + GTXSTRINGC "LOOSEoJARGON" + +L0100_Name: +L0101_Name: +L0102_Name: + GTXSTRINGC "RIVER" +L0103_Name: + GTXSTRINGC "LILoEDaSoSHEEPoFARM" +L0104_Name: + GTXSTRINGC "SPRING" +L0105_Name: + GTXSTRINGC "DARKERoFOREST" +L0106_Name: + GTXSTRINGC "DARKISHoFOREST" +L0107_Name: + GTXSTRINGC "KIDNAPoCORNERoeLZf" +L0108_Name: + GTXSTRINGC "SNAKEoPIToeLZf" +L0109_Name: + GTXSTRINGC "CHEDDAR" +L0110_Name: + GTXSTRINGC "HAVARTI" +L0111_Name: + GTXSTRINGC "GOBLINoPIT" +L0112_Name: + GTXSTRINGC "HIVEoENTRANCE" +L0113_Name: + GTXSTRINGC "FRIENDLYoFIRE" +L0114_Name: + GTXSTRINGC "PATHoOFoSHADOWS" +L0115_Name: + GTXSTRINGC "DOUBLEoENTENDRE" + +L0200_Name: + GTXSTRINGC "FORBIDDENoVILLAGE" +L0201_Name: + GTXSTRINGC "STRANGEoMIST" +L0202_Name: +L0203_Name: +L0204_Name: + GTXSTRINGC "RIVER" +L0205_Name: + GTXSTRINGC "JACOBaSoBRIDGE" +L0206_Name: +L0207_Name: +L0208_Name: +L0209_Name: +L0210_Name: + GTXSTRINGC "RIVER" +L0211_Name: + GTXSTRINGC "THEoBLOWERS" +L0212_Name: + GTXSTRINGC "THEoBELFRY" +L0213_Name: + GTXSTRINGC "CLOSEoQUARTERS" +L0214_Name: + GTXSTRINGC "JAILoBREAK" +L0215_Name: + GTXSTRINGC "BRAINIAC" + +L0300_Name: + GTXSTRINGC "WEIRDoMIST" +L0301_Name: + GTXSTRINGC "ODDoMIST" +L0302_Name: + GTXSTRINGC "BIZARREoMISToeLZf" +L0303_Name: + GTXSTRINGC "MISToGATE" +L0304_Name: + GTXSTRINGC "MUNGAoFUNGA" +L0305_Name: + GTXSTRINGC "TRILINGoBURROW" +L0306_Name: + GTXSTRINGC "TWOoGUNS" +L0307_Name: + GTXSTRINGC "OUTPOSTgoDESOLATION" +L0308_Name: + GTXSTRINGC "DRYoGULCH" +L0309_Name: + GTXSTRINGC "SHOOToOUT" +L0310_Name: + GTXSTRINGC "REDoBENDoeLZf" +L0311_Name: + GTXSTRINGC "HIGHoGROUND" +L0312_Name: + GTXSTRINGC "THEoSTING" +L0313_Name: + GTXSTRINGC "INSOMNIAC" +L0314_Name: + GTXSTRINGC "RUNAWAY" +L0315_Name: + GTXSTRINGC "INSOMNIAC" + +L0400_Name: + GTXSTRINGC "OUTPOSTgoDARKFROST" +L0401_Name: + GTXSTRINGC "PITCHoBLACK" +L0402_Name: + GTXSTRINGC "WYRMoDUSK" +L0403_Name: + GTXSTRINGC "GROMMOLD" +L0404_Name: + GTXSTRINGC "MILDEWoSTIRRING" +L0405_Name: + GTXSTRINGC "WESTGATE" +L0406_Name: + GTXSTRINGC "PIGSoINoAoBLANKET" +L0407_Name: + GTXSTRINGC "BIOS" +L0408_Name: + GTXSTRINGC "HOToVALLEYoOFoDEATH" +L0409_Name: + GTXSTRINGC "TUMBLEWEED" +L0410_Name: + GTXSTRINGC "OUTPOSTgoDRAGON" +L0411_Name: + GTXSTRINGC "THEoCELL" +L0412_Name: + GTXSTRINGC "STONEHEADoHOUSE" +L0413_Name: +L0414_Name: +L0415_Name: + GTXSTRINGC "FGB" + +L0500_Name: + GTXSTRINGC "PENGUINoSMACKDOWN" +L0501_Name: + GTXSTRINGC "WINTER" +L0502_Name: + GTXSTRINGC "CHILLVILLE" +L0503_Name: + GTXSTRINGC "OLDoHOSS" +L0504_Name: + GTXSTRINGC "NORTHGATE" +L0505_Name: + GTXSTRINGC "FLOWERoTOWER" +L0506_Name: + GTXSTRINGC "SOUTHGATE" +L0507_Name: + GTXSTRINGC "WETLANDS" +L0508_Name: + GTXSTRINGC "LAaSHANDAaS" +L0509_Name: + GTXSTRINGC "OUTBACK" +L0510_Name: + GTXSTRINGC "SUMMER" +L0511_Name: +L0512_Name: + GTXSTRINGC "LAaSHANDA" +L0513_Name: +L0514_Name: +L0515_Name: + GTXSTRINGC "FGB" + +L0600_Name: + GTXSTRINGC "ICEoPLAINSoeLZf" +L0601_Name: + GTXSTRINGC "ICEWOLFoRUN" +L0602_Name: + GTXSTRINGC "KINGoCHUBBAaSoHALL" +L0603_Name: + GTXSTRINGC "IGNORANToHILLoPEOPLE" +L0604_Name: + GTXSTRINGC "TOWERoOFoPAIN" +L0605_Name: + GTXSTRINGC "EASTGATE" +L0606_Name: + GTXSTRINGC "ROCKoBOTTOMoBENDeLZf" +L0607_Name: + GTXSTRINGC "SWAMPYaSoLAIR" +L0608_Name: + GTXSTRINGC "GOONoHILL" +L0609_Name: + GTXSTRINGC "LASToRESORT" +L0610_Name: + GTXSTRINGC "BITTERoROCKoPARK" +L0611_Name: +L0612_Name: + GTXSTRINGC "TELEPORToCHAMBER" +L0613_Name: +L0614_Name: +L0615_Name: + GTXSTRINGC "FGB" + +L0700_Name: + GTXSTRINGC "THEoPLANEoOFoNOTHING" +L0701_Name: + GTXSTRINGC "KIWIoKEEP" +L0702_Name: + GTXSTRINGC "BAToCAVE" +L0703_Name: + GTXSTRINGC "UNDERLAKEoCAVERNS" +L0704_Name: + GTXSTRINGC "STONEHEADoCANYONeLZf" +L0705_Name: + GTXSTRINGC "MONKEYoHOLLER" +L0706_Name: + GTXSTRINGC "SWAMPLACE" +L0707_Name: + GTXSTRINGC "THEoBARROWS" +L0708_Name: + GTXSTRINGC "BLACKoSWAMPoPASSAGE" +L0709_Name: + GTXSTRINGC "HERDoLANDS" +L0710_Name: + GTXSTRINGC "DONaToSHOOToTHEoCROC" +L0711_Name: + GTXSTRINGC "SPACEoSTNoAPOCALYPSE" +L0712_Name: + GTXSTRINGC "HICKoLANDINGoeLZf" +L0713_Name: +L0714_Name: +L0715_Name: + GTXSTRINGC "FGB" + +L0800_Name: + GTXSTRINGC "JACOBaSoOTHERoBRIDGE" +L0801_Name: + GTXSTRINGC "KIWIoROAD" +L0802_Name: + GTXSTRINGC "WINDYoPASS" +L0803_Name: + GTXSTRINGC "DJINNoLAKE" +L0804_Name: + GTXSTRINGC "ELDERoROCKoCANYON" +L0805_Name: + GTXSTRINGC "MONKEYoSURPRISE" +L0806_Name: + GTXSTRINGC "SCAREDIEoRUN" +L0807_Name: + GTXSTRINGC "SPIDERoMOORE" +L0808_Name: + GTXSTRINGC "CROUTONoWARoCAMP" +L0809_Name: + GTXSTRINGC "GRAPESHOT" +L0810_Name: + GTXSTRINGC "CROUTONoGRAVESoeLZf" +L0811_Name: + GTXSTRINGC "GOBLINoMODULE" +L0812_Name: + GTXSTRINGC "WARPoZONE" +L0813_Name: +L0814_Name: +L0815_Name: + GTXSTRINGC "FGB" + +L0900_Name: + GTXSTRINGC "OUTPOSTgoDELTA" +L0901_Name: + GTXSTRINGC "CROUTONoSLAVEoCAMP" +L0902_Name: + GTXSTRINGC "WIZARDaSoPASSoeLZf" +L0903_Name: + GTXSTRINGC "CORNVILLE" +L0904_Name: + GTXSTRINGC "SPIDERWEEDoCANYON" +L0905_Name: + GTXSTRINGC "MONKEYoLANDINGoeLZf" +L0906_Name: + GTXSTRINGC "MOOREoGATE" +L0907_Name: + GTXSTRINGC "ARROWHEADoCITY" +L0908_Name: + GTXSTRINGC "CANNONBALL" +L0909_Name: + GTXSTRINGC "CROSSROADS" +L0910_Name: + GTXSTRINGC "WARZONE" +L0911_Name: + GTXSTRINGC "ARTILLERYoMODULE" +L0912_Name: + GTXSTRINGC "MONKEYoHOMEWORLD" +L0913_Name: +L0914_Name: +L0915_Name: + GTXSTRINGC "FGB" + +L1000_Name: + GTXSTRINGC "GYROaSoBASEoCAMPeLZf" +L1001_Name: + GTXSTRINGC "CACTUSoPETE" +L1002_Name: + GTXSTRINGC "OUTPOSTgoDINGLE" +L1003_Name: + GTXSTRINGC "THEoBEACHoeLZf" +L1004_Name: + GTXSTRINGC "PUMPKINoPATCH" +L1005_Name: + GTXSTRINGC "AUTUMN" +L1006_Name: + GTXSTRINGC "OUTPOSTgoDESPAIR" +L1007_Name: + GTXSTRINGC "BUBoANDoJEB" +L1008_Name: + GTXSTRINGC "GRENADIERoGRAVEYARD" +L1009_Name: + GTXSTRINGC "BLACKoMAGIC" +L1010_Name: + GTXSTRINGC "GRENADIERoCASTLE" +L1011_Name: + GTXSTRINGC "DOCKINGoBAY" +L1012_Name: + GTXSTRINGC "MONKEYoLIBRARY" +L1013_Name: +L1014_Name: +L1015_Name: + GTXSTRINGC "FGB" + +L1100_Name: +L1101_Name: +L1102_Name: +L1103_Name: +L1104_Name: +L1105_Name: +L1106_Name: +L1107_Name: +L1108_Name: +L1109_Name: +L1110_Name: + GTXSTRINGC "FGB" +L1111_Name: + GTXSTRINGC "HULKoMODULE" +L1112_Name: + GTXSTRINGC "DUKEaSoDISCO" +L1113_Name: +L1114_Name: +L1115_Name: + +L1200_Name: +L1201_Name: +L1202_Name: +L1203_Name: +L1204_Name: +L1205_Name: +L1206_Name: +L1207_Name: +L1208_Name: +L1209_Name: +L1210_Name: +L1211_Name: + GTXSTRINGC "FGB" +L1212_Name: + GTXSTRINGC "THEoBESToLAIDoPLANS`" +L1213_Name: +L1214_Name: +L1215_Name: + +L1300_Name: + GTXSTRINGC "BCSoAPPOMATTOX" +L1301_Name: + GTXSTRINGC "FGB" +L1302_Name: +L1303_Name: +L1304_Name: +L1305_Name: +L1306_Name: +L1307_Name: +L1308_Name: +L1309_Name: +L1310_Name: +L1311_Name: + GTXSTRINGC "FGB" +L1312_Name: + GTXSTRINGC "GOBLINoCOUNTRY" +L1313_Name: +L1314_Name: +L1315_Name: + +L1400_Name: +L1401_Name: +L1402_Name: +L1403_Name: +L1404_Name: +L1405_Name: +L1406_Name: +L1407_Name: +L1408_Name: +L1409_Name: +L1410_Name: +L1411_Name: + GTXSTRINGC "FGB" +L1412_Name: + GTXSTRINGC "HIGHoNOON" +L1413_Name: +L1414_Name: +L1415_Name: + +L1500_Name: +L1501_Name: +L1502_Name: +L1503_Name: +L1504_Name: + ;THE KIDNAPPING! + DB ((20-STRLEN("THEoKIDNAPPING "))/2),STRLEN("THEoKIDNAPPING ") +COUNTER = 1 +REPT STRLEN("THEoKIDNAPPING") + DB ((STRSUB("THEoKIDNAPPING",COUNTER,1)+145) & $ff) +COUNTER = COUNTER+1 +ENDR + DB 237 ;! +L1505_Name: + GTXSTRINGC "FGB" +L1506_Name: +L1507_Name: +L1508_Name: +L1509_Name: +L1510_Name: +L1511_Name: + GTXSTRINGC "FGB" +L1512_Name: + GTXSTRINGC "GENERATORoCORE" +L1513_Name: +L1514_Name: +L1515_Name: + GTXSTRINGC "FGB" + +heroNames: + DW ba_name,bs_name,haiku_name,flour_name,flower_name,grenade_name + +ba_name: + GTXSTRING "BA" +bs_name: + GTXSTRING "BS" +haiku_name: + GTXSTRING "HAIKU" +flour_name: + GTXSTRING "CAPTAINoFLOUR" +flower_name: + GTXSTRING "LADYoFLOWER" +grenade_name: + GTXSTRING "KINGoGRENADE" + +itemNames: + DW item000_Name,item001_Name,item002_Name,item003_Name,item004_Name + DW item005_Name,item006_Name,item007_Name,item008_Name,item009_Name + DW item010_Name,item011_Name,item012_Name,item013_Name,item014_Name + DW item015_Name,item016_Name,item017_Name,item018_Name,item019_Name + DW item020_Name,item021_Name,item022_Name + +itemColors: + DB 1,1,0,0,0,0,0,1,3,1 ; 0- 9 + DB 5,0,0,5,0,0,1,6,5,3 ;10-19 + DB 2,4,5,0,0,0,0,0,0,0 ;20-29 +;0=Grey, 1=Red, 2=Blue, 3=Green, 4=Purple, 5=Yellow, 6=Brown/Orange, 7=Fuscia + +item000_Name: + ITEMSTRING 246,"SNAKEoBITEoKIT" +item001_Name: + ITEMSTRING 254,"SPOREoMASK" +item002_Name: + ;ITEMSTRING 250,"CODE0400" + DB 0,0 +item003_Name: + ;ITEMSTRING 250,"CODE0900" + DB 0,0 +item004_Name: + ;ITEMSTRING 250,"CODE1002" + DB 0,0 +item005_Name: + ;ITEMSTRING 250,"CODE1006" + DB 0,0 +item006_Name: + ;ITEMSTRING 250,"CODE0410" + DB 0,0 +item007_Name: + ITEMSTRING 249,"BAToJUICE" +item008_Name: + ITEMSTRING 248,"SPACEoMONEY" +item009_Name: + ITEMSTRING 247,"SPACEoSODA" +item010_Name: + ITEMSTRING 247,"HONEY" +item011_Name: + ITEMSTRING 254,"WRANGLINGoIRON" +item012_Name: + DB 0,0 ;BS Shoot Fast +item013_Name: + ITEMSTRING 253,"BUGoSPRAY" +item014_Name: + DB 0,0 ;BA High Impact Bullets +item015_Name: + ;ITEMSTRING 250,"CODE0307" + DB 0,0 +item016_Name: + ITEMSTRING 250,"ALPHAoCLEARANCE" +item017_Name: + ITEMSTRING 250,"BETAoCLEARANCE" +item018_Name: + ITEMSTRING 250,"GAMMAoCLEARANCE" +item019_Name: + ITEMSTRING 250,"DELTAoCLEARANCE" +item020_Name: + ITEMSTRING 250,"EPSILONoCLEARANCE" +item021_Name: + ITEMSTRING 250,"ZETAoCLEARANCE" +item022_Name: + ITEMSTRING 251,"APPOMATTOXoKEY" + + +SECTION "MiscSection",ROMX +;--------------------------------------------------------------------- +; Routine: NewAppxLocation +; Arguments: None. +; Returns: none +; Alters: af +; Description: +;--------------------------------------------------------------------- +NewAppxLocation: + push bc + push de + push hl + + ld a,[curLevelStateIndex] + ld b,a + ld a,[appomattoxMapIndex] + cp b + jr nz,.checkAppear + + ;remove appomattox from current map + call ReceiveByte ;new map location + ld [appomattoxMapIndex],a + ld a,190 + ldio [jiggleDuration],a + + call FindFirstLight ;remove appx + ld c,a ;invisible wall index + ld d,0 + ld a,[mapPitch] + ld e,a + ld a,b ;light index + call .drawLightRowTop + call .drawLightRowMiddle + call .drawLightRowMiddle + call .drawLightRowMiddle + call .drawLightRowMiddle + call .drawLightRowBottom + + ld hl,EngineSound + call PlaySound + + ;link up exit to $4040 (+0 +0) + ld hl,mapExitLinks+EXIT_U*2 + ld a,$40 + ld [hl+],a + ld [hl],a + + jr .done + +.checkAppear + call ReceiveByte ;new map location + ld [appomattoxMapIndex],a + cp b ;appearing on my map + jr nz,.checkInAppx + + ;place appomattox on current map + ld a,190 + ldio [jiggleDuration],a + + call AddAppomattox + ld hl,EngineSound + call PlaySound + + jr .done + +.checkInAppx + ld a,b + cp $0d + jr nz,.checkAtAppxControls + + ;I'm inside the Appomattox! + ld a,190 + ldio [jiggleDuration],a + + ld hl,EngineSound + call PlaySound + + ld a,[appomattoxMapIndex] + or a + jr nz,.landing + +.takingOff + ;link down exit to $4040 (+0 +0) + ld hl,mapExitLinks+EXIT_D*2 + ld a,$40 + ld [hl+],a + ld [hl],a + jr .done + +.landing + ;convert map index to 16-bit BCD index + ld b,a + and %1111 + call NumberToBCD + ld d,a + ld a,b + swap a + and %1111 + call NumberToBCD + ld e,a + + ld hl,mapExitLinks+EXIT_D*2 + ld [hl],e + inc hl + ld [hl],d + jr .done + +.checkAtAppxControls + ;if I was at the controls when my buddy took off, kick me off + cp $1e + jr nz,.done + + ld hl,EngineSound + call PlaySound + + ld a,$ff + ld [levelVars+6],a ;VAR_SELSTAGE in $1401 + +.done + pop hl + pop de + pop bc + ret + +.drawLightRowTop + push hl + ld [hl+],a + inc a + ld [hl+],a + inc a + ld [hl+],a + inc a + ld [hl+],a + sub 3 + pop hl + add hl,de + ret + +.drawLightRowMiddle + push hl + push af + sub b + add 3 + and 3 + add b + ld [hl+],a + ;xor a + ld a,c + ld [hl+],a + ld [hl+],a + pop af + ld [hl+],a + sub b + add 3 + and 3 + add b + pop hl + add hl,de + ret + +.drawLightRowBottom + push hl + add 3 + ld [hl+],a + dec a + ld [hl+],a + dec a + ld [hl+],a + dec a + ld [hl+],a + dec a + pop hl + add hl,de + ret + +FindFirstLight: + ;leaves hl at mem location of first landing light + ;b = first light index, c=first appx index + ;a = invisible wall index + ;must exist or infinite loop! + ld bc,classInvisibleWallBG + call FindClassIndex + + push af + ld bc,classLandingLightsBG + call FindClassIndex + ld b,a ;index to look for + + push bc + ld bc,classAppomattoxBG + call FindClassIndex + pop bc + ld c,a + + ld a,MAPBANK + ld [$ff70],a + + ;setup de with first out-of-bounds index + ;ld a,[mapTotalSize] + ;ld e,a + ;ld a,[mapTotalSize+1] + ;ld d,a + + ld hl,map +.lookForFirstLight + ld a,[hl+] + cp b + jr nz,.lookForFirstLight + + dec hl + pop af + + ret + +AddAppomattoxIfPresent:: + push bc + ld a,[curLevelStateIndex] + ld b,a + ld a,[appomattoxMapIndex] + cp b + jr nz,.done + + call AddAppomattox + +.done + pop bc + ret + +EngineSound: + DB 4,$00,$d7,$a9,$80 + +AddAppomattox: + push bc + push de + push hl + + call FindFirstLight ;draw appx + ld d,0 + ld a,[mapPitch] + ld e,a + ld a,c ;appx index + call .drawAppxMiddle + call .drawAppxMiddle + call .drawAppxMiddle + call .drawAppxRow + call .drawAppxRow + call .drawAppxRow + + ;link exit up to $1300 (appomattox interior) + ld hl,mapExitLinks+EXIT_U*2 + xor a + ld [hl+],a + ld [hl],$13 + + pop hl + pop de + pop bc + ret + +.drawAppxMiddle + push hl + inc hl + inc a + ld [hl+],a + inc a + ld [hl],a + add 2 + pop hl + add hl,de + ret + +.drawAppxRow + push hl + ld [hl+],a + inc a + ld [hl+],a + inc a + ld [hl+],a + inc a + ld [hl],a + inc a + pop hl + add hl,de + + ret + +;WARNING not in HOME section + +;--------------------------------------------------------------------- +; Variables +;--------------------------------------------------------------------- +SECTION "UserVarsHRAM",HRAM +vblankFlag: DS 1 ;0=no interrupt, 1=vblank +vblankTemp: DS 1 +vblankTimer:: DS 1 +vblanksPerUpdate: DS 1 +backBufferReady:: DS 1 +backBufferDestHighByte:: DS 1 +paletteBufferReady:: DS 1 +dmaLoad:: DS 1 ;1=load bank 0, 2=load bank 1 +randomLoc:: DS 1 ;ff92 +jiggleDuration:: DS 1 ;ff93 +temp:: DS 1 ;ff94 +drawMapTemp:: DS 2 ;ff95 +hblankFlag:: DS 1 ;ff97 :0 top/bottom, :1 show, :2 wave +hblankWinOn:: DS 1 ;ff98 +hblankWinOff:: DS 1 ;ff99 +firstMonster:: DS 1 ;ff9a +curROMBank:: DS 1 ;ff9b +updateTimer:: DS 1 ;ff9c +curObjWidthHeight:: DS 1 ;7:4 width, 3:0 height +scrollSpeed:: DS 1 ;7:4 fast speed (0,2,4,8) 3:0 slow speed +mapState:: DS 2 ;ff9f +transmitACK:: DS 1 ;ffa1 +musicEnabled:: DS 1 ;ffa2 +baseHorizontalOffset: DS 1 ;ffa3 + +samplePlaying: DS 1 ;ffa4 +sampleBank: DS 1 ;ffa5 +sampleAddress: DS 2 ;ffa6 +sampleMask: DS 1 ;ffa8 +jiggleType:: DS 1 ;ffa9 +asyncRandLoc:: DS 1 ;ffaa + + +IF 0 +;clear memory to ff +ld hl,$c000 +ld bc,$0f00 +;ld d,$ff +ld d,0 +xor a +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,1 +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,2 +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,3 +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,4 +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,5 +call MemSet + +ld hl,$d000 +ld bc,$1000 +ld a,6 +call MemSet + +ld hl,$d000 +ld bc,$0020 +ld a,7 +call MemSet + +ld d,0 +ld hl,$d020 +ld bc,$0fe0 +ld a,7 +call MemSet +ENDC + diff --git a/Tools/GBConv2/GBConv2.exe b/Tools/GBConv2/GBConv2.exe new file mode 100644 index 0000000..0b12b36 Binary files /dev/null and b/Tools/GBConv2/GBConv2.exe differ diff --git a/Tools/GBConv2/Source/BGSaveDialog.cpp b/Tools/GBConv2/Source/BGSaveDialog.cpp new file mode 100644 index 0000000..fc9a2b2 --- /dev/null +++ b/Tools/GBConv2/Source/BGSaveDialog.cpp @@ -0,0 +1,54 @@ +// BGSaveDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "BGSaveDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBGSaveDialog + +IMPLEMENT_DYNAMIC(CBGSaveDialog, CFileDialog) + +CBGSaveDialog::CBGSaveDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName, + DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) : + CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd) +{ +} + + +BEGIN_MESSAGE_MAP(CBGSaveDialog, CFileDialog) + //{{AFX_MSG_MAP(CBGSaveDialog) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +void CBGSaveDialog::OnTypeChange() +{ + int index = this->m_ofn.nFilterIndex; + char *filter = (char*) this->m_ofn.lpstrFilter; + int i; + for(i=1; i 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BGSaveDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CBGSaveDialog dialog + +class CBGSaveDialog : public CFileDialog +{ + DECLARE_DYNAMIC(CBGSaveDialog) + +public: + virtual void OnTypeChange(); + CBGSaveDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs + LPCTSTR lpszDefExt = NULL, + LPCTSTR lpszFileName = NULL, + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + LPCTSTR lpszFilter = NULL, + CWnd* pParentWnd = NULL); + +protected: + //{{AFX_MSG(CBGSaveDialog) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BGSAVEDIALOG_H__F9E2F187_1EE9_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/ChildFrm.cpp b/Tools/GBConv2/Source/ChildFrm.cpp new file mode 100644 index 0000000..8e81650 --- /dev/null +++ b/Tools/GBConv2/Source/ChildFrm.cpp @@ -0,0 +1,121 @@ +// ChildFrm.cpp : implementation of the CChildFrame class +// + +#include "stdafx.h" +#include "GBConv2.h" + +#include "ChildFrm.h" +#include "gb_pic.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#include "Controls.h" + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame + +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) + //{{AFX_MSG_MAP(CChildFrame) + ON_COMMAND(ID_FILE_CLOSE, OnFileClose) + ON_WM_SETFOCUS() + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + +} + +CChildFrame::~CChildFrame() +{ + +} + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIChildWnd::PreCreateWindow(cs) ) + return FALSE; + + cs.dwExStyle &= ~WS_EX_CLIENTEDGE; + cs.style &= ~WS_THICKFRAME; + cs.lpszClass = AfxRegisterWndClass(0); + + return TRUE; +} + + + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame message handlers +void CChildFrame::OnFileClose() +{ + + SendMessage(WM_CLOSE); +} + +int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + // create a view to occupy the client area of the frame + if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, + CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) + { + TRACE0("Failed to create view window\n"); + return -1; + } + + //if(!OnLoadBMP()) OnFileClose(); + + return 0; +} + +void CChildFrame::OnSetFocus(CWnd* pOldWnd) +{ + CMDIChildWnd::OnSetFocus(pOldWnd); + + m_wndView.SetFocus(); +} + +BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) +{ + // let the view have first crack at the command + if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) + return TRUE; + + // otherwise, do default handling + return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); +} + + +int CChildFrame::OnLoadBMP() +{ + return 1; +} diff --git a/Tools/GBConv2/Source/ChildFrm.h b/Tools/GBConv2/Source/ChildFrm.h new file mode 100644 index 0000000..d56cec3 --- /dev/null +++ b/Tools/GBConv2/Source/ChildFrm.h @@ -0,0 +1,61 @@ +// ChildFrm.h : interface of the CChildFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CHILDFRM_H__2F0A9B4A_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_CHILDFRM_H__2F0A9B4A_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChildView.h" +#include "gb_pic.h" // Added by ClassView + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChildFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); + //}}AFX_VIRTUAL + +// Implementation +public: + int OnLoadBMP(); + // view for the client area of the frame. + CChildView m_wndView; + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + //{{AFX_MSG(CChildFrame) + afx_msg void OnFileClose(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHILDFRM_H__2F0A9B4A_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/ChildView.cpp b/Tools/GBConv2/Source/ChildView.cpp new file mode 100644 index 0000000..efbf7a5 --- /dev/null +++ b/Tools/GBConv2/Source/ChildView.cpp @@ -0,0 +1,184 @@ +// ChildView.cpp : implementation of the CChildView class +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "ChildView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#include "Controls.h" +#include "EditArea.h" + +///////////////////////////////////////////////////////////////////////////// +// CChildView + +CString CChildView::preferredSourcePath = "d:\\aprogs\\fgbpix\\*.bmp"; + +CChildView::CChildView() +{ + sourceFile = destFile = 0; + sourceFileName = destFileName = ""; +} + +CChildView::~CChildView() +{ + if(sourceFile){ + delete sourceFile; + sourceFile = 0; + } + + if(destFile){ + delete destFile; + destFile = 0; + } +} + + +BEGIN_MESSAGE_MAP(CChildView,CWnd ) + //{{AFX_MSG_MAP(CChildView) + ON_WM_PAINT() + ON_WM_CREATE() + ON_WM_ERASEBKGND() + ON_WM_MOUSEMOVE() + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CChildView message handlers + +BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) +{ + if (!CWnd::PreCreateWindow(cs)) + return FALSE; + + cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.style &= ~WS_BORDER; + cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, + ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); + + return TRUE; +} + +void CChildView::OnPaint() +{ + CPaintDC dc(this); // device context for painting + +} + + +int CChildView::OnLoadBMP() +{ + if(!sourceFile){ + sourceFile = new CFileDialog(TRUE,"*.bmp", preferredSourcePath, + 0, "Bitmap Files (.bmp)|*.bmp|Backgrounds (*.bg)|*.bg|Sprites (*.sp)|*.sp|Bitmap, BG, & Sprite Files (.bmp;.bg;.sp)|*.bmp;*.bg;*.sp||"); + } + + + if(sourceFile->DoModal()==IDOK){ + sourceFileName = sourceFile->GetPathName(); + + //set dest + destFileName = sourceFileName.Left(sourceFileName.GetLength() + - (sourceFile->GetFileName()).GetLength()); + + preferredSourcePath = destFileName; + preferredSourcePath += "*.bmp"; + + destFileName += sourceFile->GetFileTitle(); + + if(sourceFileName.Right(3).CompareNoCase("bmp")==0){ + // BMP + pic.LoadBMP((char*) (LPCTSTR) sourceFileName); + }else if(sourceFileName.Right(2).CompareNoCase("bg")==0){ + // gameboy BG file + pic.LoadGBPic(sourceFileName); + }else{ + //hopefully a .sp file + pic.LoadGBSprite(sourceFileName); + } + + CFrameWnd *frame = this->GetParentFrame(); + int innerHeight = pic.GetDisplayHeight(); + if(innerHeight < CTRLHEIGHT) innerHeight = CTRLHEIGHT; + CRect frameRect(0,0,pic.GetDisplayWidth()+CTRLWIDTH,innerHeight); + AdjustWindowRectEx(&frameRect, frame->GetStyle() | GetStyle(), 0, + frame->GetExStyle()|GetExStyle()); + + int width = frameRect.Width(); + int height = frameRect.Height(); + //if(height < CTRLHEIGHT) height = CTRLHEIGHT; + + frame->SetWindowPos(&wndTop, 0, 0, width, height, SWP_NOMOVE); + + width = pic.GetDisplayWidth(); + height = pic.GetDisplayHeight(); + if(height < CTRLHEIGHT) height = CTRLHEIGHT; + + controls.SetWindowPos(&wndTop, 0, 0, CTRLWIDTH, height, SWP_SHOWWINDOW); + editArea.SetWindowPos(&wndTop, CTRLWIDTH, 0, width, height, SWP_SHOWWINDOW); + + return 1; + /* + switch(m_listType.GetCurSel()){ + case 0: + destFileName += ".bg"; + break; + case 1: + destFileName += ".tx"; + break; + case 2: + destFileName += ".sp"; + break; + } + */ + } + return 0; +} + +int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + + if (CWnd ::OnCreate(lpCreateStruct) == -1) + return -1; + + controls.Create(0,0,WS_CHILD,CRect(0,0,0,0),this,0,0); + editArea.Create(0,0,WS_CHILD,CRect(0,0,0,0),this,0,0); + + if(!OnLoadBMP()) this->GetParent()->PostMessage(WM_CLOSE); + + return 0; +} + +BOOL CChildView::OnEraseBkgnd(CDC* pDC) +{ + //return true; + return CWnd ::OnEraseBkgnd(pDC); +} + +void CChildView::DebugMesg(char *title, int num) +{ + char st[80]; + ostrstream stout(st,80); + stout << num << ends; + this->MessageBox(st,title); +} + + + +void CChildView::OnMouseMove(UINT nFlags, CPoint point) +{ + + CWnd ::OnMouseMove(nFlags, point); +} + +void CChildView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + CWnd ::OnKeyDown(nChar, nRepCnt, nFlags); +} diff --git a/Tools/GBConv2/Source/ChildView.h b/Tools/GBConv2/Source/ChildView.h new file mode 100644 index 0000000..bd5ee34 --- /dev/null +++ b/Tools/GBConv2/Source/ChildView.h @@ -0,0 +1,70 @@ +// ChildView.h : interface of the CChildView class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CHILDVIEW_H__2F0A9B4C_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_CHILDVIEW_H__2F0A9B4C_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_ + +#include "EditArea.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "gb_pic.h" +#include "EditArea.h" +#include "Controls.h" + + +///////////////////////////////////////////////////////////////////////////// +// CChildView window + +class CChildView : public CWnd +{ +// Construction +public: + CChildView(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChildView) + protected: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + CEditArea editArea; + CControls controls; + void DebugMesg(char *title, int num); + int OnLoadBMP(); + virtual ~CChildView(); + + static CString preferredSourcePath; + gbPic pic; + CString sourceFileName, destFileName; + CFileDialog* sourceFile, *destFile; + + // Generated message map functions +protected: + //{{AFX_MSG(CChildView) + afx_msg void OnPaint(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHILDVIEW_H__2F0A9B4C_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/Controls.cpp b/Tools/GBConv2/Source/Controls.cpp new file mode 100644 index 0000000..2479366 --- /dev/null +++ b/Tools/GBConv2/Source/Controls.cpp @@ -0,0 +1,437 @@ +// Controls.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "Controls.h" +#include "ChildView.h" +#include "wingk.h" +#include "EditPaletteDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CControls + +//statics +CString CControls::preferredDestPath = "d:\\aprogs\\fgbpix\\*.sp"; + +CControls::CControls() +{ + showSprites = 1; + showMapping = 1; + destFileDialog = 0; + bgFileDialog = 0; +} + +CControls::~CControls() +{ + if(destFileDialog){ + delete destFileDialog; + destFileDialog = 0; + } + if(bgFileDialog){ + delete bgFileDialog; + bgFileDialog = 0; + } +} + + +BEGIN_MESSAGE_MAP(CControls, CWnd) + //{{AFX_MSG_MAP(CControls) + ON_WM_CREATE() + ON_WM_PAINT() + ON_WM_MOUSEMOVE() + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP + ON_BN_CLICKED(IDB_PALETTEFROMSEL,OnPaletteFromSel) + ON_BN_CLICKED(IDB_SETTOBGCOLOR,OnB_SetToBGColor) + ON_BN_CLICKED(IDB_SWAPWITHBGCOLOR,OnB_SwapWithBGColor) + ON_BN_CLICKED(IDB_AUTOMAPTOPALETTE,OnB_AutoMapToPalette) + ON_BN_CLICKED(IDB_MAPTOPALETTE,OnB_MapToPalette) + ON_BN_CLICKED(IDB_UNMAP,OnB_Unmap) + ON_BN_CLICKED(IDB_SELECTNONEMPTY,OnB_SelectNonEmpty) + ON_BN_CLICKED(IDB_MAKESPRITES,OnB_MakeSprites) + ON_BN_CLICKED(IDB_SHOWSPRITES,OnB_CheckShowSprites) + ON_BN_CLICKED(IDB_SHOWMAPPING,OnB_ShowMapping) + ON_BN_CLICKED(IDB_SELECTUNMAPPED,OnB_SelectUnmapped) + ON_BN_CLICKED(IDB_SAVEGBSPRITE,OnB_SaveGBSprite) + ON_BN_CLICKED(IDB_EDITPALETTE,OnB_EditPalette) + + ON_BN_CLICKED(IDB_AUTOMAPALL,OnB_AutoMapAll) + ON_BN_CLICKED(IDB_SAVEGBPIC,OnB_SaveGBPic) + + ON_LBN_SELCHANGE(IDLIST_PALETTES,OnSelChangePalettes) +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CControls message handlers + +int CControls::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + view = (CChildView*) this->GetParent(); + + palettes.Create( + WS_CHILD|WS_VISIBLE|LBS_MULTIPLESEL|LBS_EXTENDEDSEL|LBS_OWNERDRAWFIXED, + CRect(CTRLWIDTH-64,0,CTRLWIDTH,272),this,IDLIST_PALETTES); + + CChildView *view = (CChildView*) this->GetParent(); + + palettes.pic = &(view->pic); + + int i; + for(i=0; i<8; i++){ + int index = palettes.AddString(""); + palettes.SetItemData(index, i); + } + /* + palettes.AddString((char*) -1); + for(i=0; i<8; i++){ + int index = palettes.AddString(""); + palettes.SetItemData(index, i+8); + } + */ + + CRect rect(0,0,144,24); + createPaletteFromSel.Create("Colors->Palette",WS_CHILD|WS_VISIBLE, + rect,this,IDB_PALETTEFROMSEL); + + rect.OffsetRect(0,24); + b_setToBGColor.Create("Colors To BG Color",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SETTOBGCOLOR); + + rect.OffsetRect(0,24); + b_swapWithBGColor.Create("Swap Colors w/BG",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SWAPWITHBGCOLOR); + + rect.OffsetRect(0,32); + b_autoMapToPalette.Create("AutoMap To Palette",WS_CHILD|WS_VISIBLE, + rect,this,IDB_AUTOMAPTOPALETTE); + + rect.OffsetRect(0,24); + b_mapToPalette.Create("Map To Palette",WS_CHILD|WS_VISIBLE,rect,this, + IDB_MAPTOPALETTE); + + rect.OffsetRect(0,24); + b_unmap.Create("Unmap",WS_CHILD|WS_VISIBLE, + rect,this,IDB_UNMAP); + + rect.OffsetRect(0,24); + b_selectUnmapped.Create("Select Unmapped",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SELECTUNMAPPED); + + rect.OffsetRect(0,24); + b_autoMapAll.Create("AutoMap All",WS_CHILD|WS_VISIBLE, + rect,this,IDB_AUTOMAPALL); + + rect.OffsetRect(0,24); + b_saveGBPic.Create("Save GB Pic",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SAVEGBPIC); + + rect.OffsetRect(0,32); + b_selectNonEmpty.Create("Select Non-Empty",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SELECTNONEMPTY); + + rect.OffsetRect(0,24); + b_makeSprites.Create("Make 8x16 Sprites",WS_CHILD|WS_VISIBLE, + rect,this,IDB_MAKESPRITES); + + rect.OffsetRect(0,24); + b_saveGBSprite.Create("Save GB Sprite",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SAVEGBSPRITE); + + rect.OffsetRect(0,32); + b_editPalette.Create("Edit Palette",WS_CHILD|WS_VISIBLE, + rect,this,IDB_EDITPALETTE); + + rect.OffsetRect(0,24); + b_showSprites.Create("Show Sprites",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SHOWSPRITES); + + rect.OffsetRect(0,24); + b_showMapping.Create("Show Mapping",WS_CHILD|WS_VISIBLE, + rect,this,IDB_SHOWMAPPING); + + + + return 0; +} + +void CControls::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + CChildView *view = (CChildView*) this->GetParent(); + + //------------------------draw magnified area------------------------------- + CPoint point; + GetCursorPos(&point); + view->editArea.ScreenToClient(&point); + + //view->pic.GetMagnifiedArea(point.x,point.y)->BlitToDC(&dc, CTRLWIDTH-80,288); + view->pic.GetMagnifiedArea(point.x,point.y)->BlitToHDC(dc, CTRLWIDTH-80,288); + + //-----------------------draw bg color & selected colors-------------------- + //clear the color area + dc.FillSolidRect(0,CTRLHEIGHT-16,CTRLWIDTH,CTRLHEIGHT,0x303030); + CBrush blackBrush; + blackBrush.CreateSolidBrush(0); + + //draw the bg color + CRect rect(0,CTRLHEIGHT-16,16,CTRLHEIGHT); + dc.FillSolidRect(&rect, view->pic.GetBGColor()); + dc.FrameRect(&rect,&blackBrush); + + int count = view->pic.GetNumSelectedColors(); + if(count > 0){ + int pixelsPer = (CTRLWIDTH-32) / count; + int totalWidth = count * pixelsPer; + CRect curRect(32,CTRLHEIGHT-16,32+pixelsPer,CTRLHEIGHT); + gkRGB *colors = view->pic.GetSelectedColors(); + + int i; + for(i=0; ipic.SetNeedsRedraw(); + view->editArea.InvalidateRect(0); +} + +void CControls::OnPaletteFromSel() +{ + int curPal = palettes.GetCurSel(); + if(curPal==-1) return; + if(curPal>=8) curPal--; //blank divider item + + int n = view->pic.GetNumSelectedColors(); + if(n>4) n = 4; + + gkRGB *colors = view->pic.GetSelectedColors(); + + int i; + for(i=0; ipic.SetColor(curPal, i, colors[i]); + } + + palettes.InvalidateRect(0); + InvalidateEditArea(); +} + +void CControls::OnB_SetToBGColor() +{ + //set selected colors to be the background color + view->pic.RemapSelectedToBGColor(); + InvalidateMagnifiedArea(); + InvalidateEditArea(); +} + +void CControls::OnB_SwapWithBGColor() +{ + view->pic.SwapSelectedWithBGColor(); + InvalidateMagnifiedArea(); + InvalidateEditArea(); +} + +void CControls::OnB_AutoMapToPalette() +{ + int pal = 0; + int numSel = palettes.GetSelItems(17,palettesSelected); + int i; + for(i=0; ipic.AutoMapToPalette(pal); + InvalidateEditArea(); +} + +void CControls::OnB_SelectNonEmpty() +{ + view->pic.SelectNonEmpty(); + InvalidateEditArea(); + InvalidateMagnifiedArea(); +} + +void CControls::OnB_Unmap() +{ + view->pic.Unmap(); + InvalidateEditArea(); +} + +void CControls::OnB_MakeSprites() +{ + view->pic.SetCurPalette(palettes.GetCurSel()); + view->pic.MakeSprites(); + InvalidateEditArea(); +} + +void CControls::OnSelChangePalettes() +{ + //See same in CPaletteListBox + this->MessageBox("Super!"); +} + +void CControls::OnB_CheckShowSprites() +{ + showSprites ^= 1; + view->pic.SetNeedsRedraw(); + InvalidateEditArea(); +} + +void CControls::OnB_SelectUnmapped() +{ + view->pic.SelectUnmapped(); + InvalidateEditArea(); +} + +void CControls::OnB_SaveGBSprite() +{ + if(!destFileDialog){ + CString initialDestFilename = view->destFileName; + if(initialDestFilename.Right(3).CompareNoCase(".sp")!=0) initialDestFilename += ".sp"; + destFileDialog = new CFileDialog(FALSE,".sp", initialDestFilename, + 0, "Sprite Files (.sp)|*.sp||"); + } + + + if(destFileDialog->DoModal()==IDOK){ + destFilename = destFileDialog->GetPathName(); + view->pic.SaveGBSprite((char*) (const char*) destFilename); + + char st[80]; + ostrstream stout(st,80); + stout << view->pic.GetFileSize() << " Bytes" << ends; + this->MessageBox(st); + } +} + + +void CControls::OnB_EditPalette() +{ + gbPic &pic = view->pic; + + int pal = pic.GetCurPalette(); + if(pal<0 || pal>7) return; + + CEditPaletteDialog dialog; + + int i; + for(i=0; i<4; i++){ + dialog.initColors[i] = pic.GetColor(pal,i); + } + + if(dialog.DoModal()==IDOK){ + for(i=0; i<4; i++){ + pic.SetColor(pal,i,dialog.initColors[i]); + } + view->controls.InvalidateEditArea(); + } +} + +void CControls::OnB_AutoMapAll() +{ + view->pic.AutoMap(255); + InvalidateEditArea(); + palettes.Invalidate(0); +} + +void CControls::OnB_SaveGBPic() +{ + if(!bgFileDialog){ + CString initialDestFilename = view->destFileName; + if(initialDestFilename.Right(3).CompareNoCase(".bg")!=0) initialDestFilename += ".bg"; + bgFileDialog = new CBGSaveDialog(FALSE,".bg", initialDestFilename, + 0, "Background (.bg)|*.bg||"); + } + + //CString path = bgFileDialog->GetPathName(); + //CString ext = bgFileDialog->GetFileExt(); + //if(ext.GetLength()>0) path = path.Left(path.GetLength() - ext.GetLength() - 1); + //strcpy(bgFileDialog->m_ofn.lpstrFile,path); + if(bgFileDialog->DoModal()==IDOK){ + bgFilename = bgFileDialog->GetPathName(); + //if(bgFileDialog->GetFileExt().CompareNoCase("bg")){ + view->pic.SaveGBPic(bgFilename); + //}else{ + //view->pic.SaveGBText(bgFilename); + //} + + char st[80]; + ostrstream stout(st,80); + stout << view->pic.GetNumUniqueTiles() << " Unique Tiles" << endl; + stout << view->pic.GetFileSize() << " Bytes" << ends; + this->MessageBox(st); + } + + InvalidateEditArea(); + palettes.Invalidate(0); +} + +BOOL CControls::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; + GetClientRect(&rect); + + pDC->FillSolidRect(&rect,0x303030); + return 1; + + //return CWnd::OnEraseBkgnd(pDC); +} + +void CControls::OnB_ShowMapping() +{ + showMapping ^= 1; + view->pic.SetNeedsRedraw(); + InvalidateEditArea(); +} + +void CControls::OnB_MapToPalette() +{ + int pal = 0; + int numSel = palettes.GetSelItems(17,palettesSelected); + int i; + for(i=0; ipic.MapToPalette(pal); + InvalidateEditArea(); +} diff --git a/Tools/GBConv2/Source/Controls.h b/Tools/GBConv2/Source/Controls.h new file mode 100644 index 0000000..768bf64 --- /dev/null +++ b/Tools/GBConv2/Source/Controls.h @@ -0,0 +1,108 @@ +#if !defined(AFX_CONTROLS_H__74CE4C48_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_CONTROLS_H__74CE4C48_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_ + +#include "PaletteListBox.h" // Added by ClassView +#include "BGSaveDialog.h" + +class CChildView; +class CPaletteListBox; + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Controls.h : header file +// + + +#define CTRLWIDTH 224 +#define CTRLHEIGHT 416 + + +///////////////////////////////////////////////////////////////////////////// +// CControls window + +class CControls : public CWnd +{ +// Construction +public: + CControls(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CControls) + //}}AFX_VIRTUAL + +// Implementation +public: + void OnB_MapToPalette(); + void OnB_ShowMapping(); + void OnB_SaveGBPic(); + void OnB_AutoMapAll(); + void OnB_EditPalette(); + void OnB_SaveGBSprite(); + void OnB_SelectUnmapped(); + void OnB_CheckShowSprites(); + void OnSelChangePalettes(); + void OnB_MakeSprites(); + void OnB_Unmap(); + void OnB_SelectNonEmpty(); + void OnB_AutoMapToPalette(); + void OnB_SwapWithBGColor(); + void OnB_SetToBGColor(); + void OnPaletteFromSel(); + void InvalidateEditArea(); + void InvalidateColors(); + void InvalidateMagnifiedArea(); + CPaletteListBox palettes; + virtual ~CControls(); + + int showSprites, showMapping; + + // Generated message map functions +protected: + int palettesSelected[17]; + CChildView *view; + CButton createPaletteFromSel; + CButton b_setToBGColor; + CButton b_swapWithBGColor; + CButton b_selectNonEmpty; + CButton b_unmap; + CButton b_makeSprites; + CButton b_autoMapToPalette; + CButton b_mapToPalette; + CButton b_showSprites; + CButton b_showMapping; + CButton b_selectUnmapped; + CButton b_saveGBSprite; + CButton b_editPalette; + + CButton b_autoMapAll; + CButton b_saveGBPic; + + static CString preferredDestPath; + CString destFilename; + CFileDialog *destFileDialog; + CString bgFilename; + CBGSaveDialog *bgFileDialog; + + //{{AFX_MSG(CControls) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnPaint(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CONTROLS_H__74CE4C48_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/EditArea.cpp b/Tools/GBConv2/Source/EditArea.cpp new file mode 100644 index 0000000..a375303 --- /dev/null +++ b/Tools/GBConv2/Source/EditArea.cpp @@ -0,0 +1,223 @@ +// EditArea.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "EditArea.h" +#include "ChildView.h" +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CEditArea + +CEditArea::CEditArea() +{ + view = 0; + downLMB = downRMB = 0; + pickingColors = 0; +} + +CEditArea::~CEditArea() +{ +} + + +BEGIN_MESSAGE_MAP(CEditArea, CWnd) + //{{AFX_MSG_MAP(CEditArea) + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_WM_CREATE() + ON_WM_KEYDOWN() + ON_WM_RBUTTONDOWN() + ON_WM_RBUTTONUP() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CEditArea message handlers + +BOOL CEditArea::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; + GetClientRect(&rect); + + //fill to the right of the picture + int width = rect.Width() - view->pic.GetDisplayWidth(); + if(width > 0){ + pDC->FillSolidRect(view->pic.GetDisplayWidth(), 0, width, rect.Height(), 0x303030); + } + + int height = rect.Height() - view->pic.GetDisplayHeight(); + if(height > 0){ + pDC->FillSolidRect(0,view->pic.GetDisplayHeight(), + view->pic.GetDisplayWidth(), height, 0x303030); + } + + return 1; + + //return CWnd::OnEraseBkgnd(pDC); +} + +void CEditArea::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + //view->pic.GetDisplayBuffer()->BlitToDC(&dc, 0, 0); + int flags = (view->controls.showMapping << 1) | view->controls.showSprites; + view->pic.GetDisplayBuffer(flags)->BlitToHDC(dc, 0, 0); + + } + +void CEditArea::OnMouseMove(UINT nFlags, CPoint point) +{ + this->SetFocus(); + + view->controls.InvalidateMagnifiedArea(); + + if(downLMB){ + if(!pickingColors){ + view->pic.OnMouseLDrag(point.x, point.y); + view->controls.InvalidateColors(); + if(view->pic.GetNeedsRedraw()) this->InvalidateRect(0); + }else{ + if(GetAsyncKeyState(VK_CONTROL) & 0x8000){ + if(GetAsyncKeyState(VK_SHIFT) & 0x8000){ + view->pic.AddNextColor(view->pic.GetColorAtPoint(point.x,point.y)); + }else{ + view->pic.SetFirstColor(view->pic.GetColorAtPoint(point.x,point.y)); + } + view->controls.InvalidateColors(); + }else{ + pickingColors = 0; + } + } + } + + if(downRMB){ + if(GetAsyncKeyState(VK_CONTROL) & 0x8000){ + if(GetAsyncKeyState(VK_SHIFT) & 0x8000){ + //remove a color + view->pic.RemoveColor(view->pic.GetColorAtPoint(point.x,point.y)); + }else{ + //set the bg color + view->pic.SetBGColor(view->pic.GetColorAtPoint(point.x,point.y)); + } + view->controls.InvalidateColors(); + } + } + + CMainFrame *frame = (CMainFrame*) view->GetTopLevelFrame(); + char st[80]; + ostrstream stout(st,80); + stout << "Selected: " << view->pic.GetNumSelTiles() + << " Sprites: " << view->pic.GetNumSprites() << " "; + stout << "Mapping: "; + int mapping = view->pic.GetMappingAtPoint(point.x,point.y); + if(mapping==-1) stout << "(None) "; + else stout << mapping << " "; + stout << ends; + CString str(st); + frame->ShowStatus(&str); + + CWnd::OnMouseMove(nFlags, point); +} + +void CEditArea::OnLButtonDown(UINT nFlags, CPoint point) +{ + if(view->controls.showSprites){ + if(view->pic.UnmakeSprite(point.x, point.y)){ + this->InvalidateRect(0); + return; + } + } + + downLMB = 1; + if(GetAsyncKeyState(VK_CONTROL) & 0x8000){ + if(GetAsyncKeyState(VK_SHIFT) & 0x8000){ + view->pic.AddNextColor(view->pic.GetColorAtPoint(point.x,point.y)); + }else{ + //pick a color + view->pic.SetFirstColor(view->pic.GetColorAtPoint(point.x,point.y)); + } + view->controls.InvalidateColors(); + pickingColors = 1; + }else{ + //select tiles + view->pic.OnMouseLMB(point.x, point.y); + view->controls.InvalidateColors(); + pickingColors = 0; + } + if(view->pic.GetNeedsRedraw()) this->InvalidateRect(0); + this->SetCapture(); + CWnd::OnLButtonDown(nFlags, point); +} + +void CEditArea::OnLButtonUp(UINT nFlags, CPoint point) +{ + if(downLMB){ + downLMB = 0; + if(!pickingColors){ + view->pic.OnMouseLRelease(point.x, point.y); + view->controls.InvalidateColors(); + CWnd::OnLButtonUp(nFlags, point); + if(view->pic.GetNeedsRedraw()) this->InvalidateRect(0); + } + ReleaseCapture(); + pickingColors = 0; + } +} + +int CEditArea::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + view = (CChildView*) this->GetParent(); + return 0; +} + +void CEditArea::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + if(nChar==VK_CONTROL){ + //this->MessageBox("CTRL pressed!"); + } + CWnd::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CEditArea::OnRButtonDown(UINT nFlags, CPoint point) +{ + if(GetAsyncKeyState(VK_CONTROL) & 0x8000){ + if(GetAsyncKeyState(VK_SHIFT) & 0x8000){ + //remove a color + view->pic.RemoveColor(view->pic.GetColorAtPoint(point.x,point.y)); + }else{ + //set the bg color + view->pic.SetBGColor(view->pic.GetColorAtPoint(point.x,point.y)); + } + view->controls.InvalidateColors(); + }else{ + //not picking colors; clear all selected pixels + view->pic.ClearSelection(); + this->InvalidateRect(0); + view->controls.InvalidateMagnifiedArea(); + view->controls.InvalidateColors(); + } + downRMB = 1; + CWnd::OnRButtonDown(nFlags, point); +} + +void CEditArea::OnRButtonUp(UINT nFlags, CPoint point) +{ + downRMB = 0; + CWnd::OnRButtonUp(nFlags, point); +} diff --git a/Tools/GBConv2/Source/EditArea.h b/Tools/GBConv2/Source/EditArea.h new file mode 100644 index 0000000..c75345a --- /dev/null +++ b/Tools/GBConv2/Source/EditArea.h @@ -0,0 +1,61 @@ +#if !defined(AFX_EDITAREA_H__74CE4C4A_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_EDITAREA_H__74CE4C4A_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// EditArea.h : header file +// + +class CChildView; + +///////////////////////////////////////////////////////////////////////////// +// CEditArea window + +class CEditArea : public CWnd +{ +// Construction +public: + CEditArea(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CEditArea) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CEditArea(); + + // Generated message map functions +protected: + int downRMB; + short int pickingColors; + CChildView *view; + int downLMB; + //{{AFX_MSG(CEditArea) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EDITAREA_H__74CE4C4A_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/EditPaletteDialog.cpp b/Tools/GBConv2/Source/EditPaletteDialog.cpp new file mode 100644 index 0000000..01a569d --- /dev/null +++ b/Tools/GBConv2/Source/EditPaletteDialog.cpp @@ -0,0 +1,109 @@ +// EditPaletteDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "EditPaletteDialog.h" +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CEditPaletteDialog dialog + + +CEditPaletteDialog::CEditPaletteDialog(CWnd* pParent /*=NULL*/) + : CDialog(CEditPaletteDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CEditPaletteDialog) + //}}AFX_DATA_INIT +} + + +void CEditPaletteDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CEditPaletteDialog) + DDX_Control(pDX, IDC_EDIT_PAL_RED3, m_editRed3); + DDX_Control(pDX, IDC_EDIT_PAL_RED2, m_editRed2); + DDX_Control(pDX, IDC_EDIT_PAL_RED1, m_editRed1); + DDX_Control(pDX, IDC_EDIT_PAL_RED0, m_editRed0); + DDX_Control(pDX, IDC_EDIT_PAL_GREEN3, m_editGreen3); + DDX_Control(pDX, IDC_EDIT_PAL_GREEN2, m_editGreen2); + DDX_Control(pDX, IDC_EDIT_PAL_GREEN1, m_editGreen1); + DDX_Control(pDX, IDC_EDIT_PAL_GREEN0, m_editGreen0); + DDX_Control(pDX, IDC_EDIT_PAL_BLUE3, m_editBlue3); + DDX_Control(pDX, IDC_EDIT_PAL_BLUE2, m_editBlue2); + DDX_Control(pDX, IDC_EDIT_PAL_BLUE1, m_editBlue1); + DDX_Control(pDX, IDC_EDIT_PAL_BLUE0, m_editBlue0); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CEditPaletteDialog, CDialog) + //{{AFX_MSG_MAP(CEditPaletteDialog) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CEditPaletteDialog message handlers + +void CEditPaletteDialog::OnOK() +{ + //copy working colors to initColors + initColors[0] = gkRGB(GetNum(m_editRed0),GetNum(m_editGreen0),GetNum(m_editBlue0)); + initColors[1] = gkRGB(GetNum(m_editRed1),GetNum(m_editGreen1),GetNum(m_editBlue1)); + initColors[2] = gkRGB(GetNum(m_editRed2),GetNum(m_editGreen2),GetNum(m_editBlue2)); + initColors[3] = gkRGB(GetNum(m_editRed3),GetNum(m_editGreen3),GetNum(m_editBlue3)); + + CDialog::OnOK(); +} + +int CEditPaletteDialog::GetNum(CEdit &edit) +{ + char st[80]; + edit.GetWindowText(st,80); + istrstream stin(st,80); + + int num; + stin >> num; + + if(num<0) num = 0; + if(num>255) num = 255; + num &= 0xf8; + return num; +} + +BOOL CEditPaletteDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + SetNum(m_editRed0,initColors[0].GetR()); + SetNum(m_editRed1,initColors[1].GetR()); + SetNum(m_editRed2,initColors[2].GetR()); + SetNum(m_editRed3,initColors[3].GetR()); + SetNum(m_editGreen0,initColors[0].GetG()); + SetNum(m_editGreen1,initColors[1].GetG()); + SetNum(m_editGreen2,initColors[2].GetG()); + SetNum(m_editGreen3,initColors[3].GetG()); + SetNum(m_editBlue0,initColors[0].GetB()); + SetNum(m_editBlue1,initColors[1].GetB()); + SetNum(m_editBlue2,initColors[2].GetB()); + SetNum(m_editBlue3,initColors[3].GetB()); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CEditPaletteDialog::SetNum(CEdit &edit, int n) +{ + char st[80]; + ostrstream stout(st,80); + n &= 0xff; + stout << n << ends; + edit.SetWindowText(st); +} diff --git a/Tools/GBConv2/Source/EditPaletteDialog.h b/Tools/GBConv2/Source/EditPaletteDialog.h new file mode 100644 index 0000000..12357f8 --- /dev/null +++ b/Tools/GBConv2/Source/EditPaletteDialog.h @@ -0,0 +1,63 @@ +#if !defined(AFX_EDITPALETTEDIALOG_H__E83CE848_1BC5_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_EDITPALETTEDIALOG_H__E83CE848_1BC5_11D4_B6CE_525400E2D57B__INCLUDED_ + +#include "wingk.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// EditPaletteDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CEditPaletteDialog dialog + +class CEditPaletteDialog : public CDialog +{ +// Construction +public: + void SetNum(CEdit &edit, int n); + int GetNum(CEdit &edit); + gkRGB colors[4]; + gkRGB initColors[4]; + CEditPaletteDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CEditPaletteDialog) + enum { IDD = IDD_EDIT_PALETTE }; + CEdit m_editRed3; + CEdit m_editRed2; + CEdit m_editRed1; + CEdit m_editRed0; + CEdit m_editGreen3; + CEdit m_editGreen2; + CEdit m_editGreen1; + CEdit m_editGreen0; + CEdit m_editBlue3; + CEdit m_editBlue2; + CEdit m_editBlue1; + CEdit m_editBlue0; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CEditPaletteDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CEditPaletteDialog) + virtual void OnOK(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EDITPALETTEDIALOG_H__E83CE848_1BC5_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/GBConv2.cpp b/Tools/GBConv2/Source/GBConv2.cpp new file mode 100644 index 0000000..c5d474e --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.cpp @@ -0,0 +1,157 @@ +// GBConv2.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "GBConv2.h" + +#include "MainFrm.h" +#include "ChildFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App + +BEGIN_MESSAGE_MAP(CGBConv2App, CWinApp) + //{{AFX_MSG_MAP(CGBConv2App) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + ON_COMMAND(ID_FILE_NEW, OnFileNew) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App construction + +CGBConv2App::CGBConv2App() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CGBConv2App object + +CGBConv2App theApp; + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App initialization + +BOOL CGBConv2App::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Change the registry key under which our settings are stored. + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + + + + CMDIFrameWnd* pFrame = new CMainFrame; + m_pMainWnd = pFrame; + + // create main MDI frame window + if (!pFrame->LoadFrame(IDR_MAINFRAME)) + return FALSE; + + // try to load shared MDI menus and accelerator table + + HINSTANCE hInst = AfxGetResourceHandle(); + m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_GBCONVTYPE)); + m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_GBCONVTYPE)); + + + pFrame->ShowWindow(SW_SHOWMAXIMIZED); + pFrame->UpdateWindow(); + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App message handlers + +int CGBConv2App::ExitInstance() +{ + if (m_hMDIMenu != NULL) + FreeResource(m_hMDIMenu); + if (m_hMDIAccel != NULL) + FreeResource(m_hMDIAccel); + + return CWinApp::ExitInstance(); +} + +void CGBConv2App::OnFileNew() +{ + CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd); + + // create a new MDI child window + pFrame->CreateNewChild( + RUNTIME_CLASS(CChildFrame), IDR_GBCONVTYPE, m_hMDIMenu, m_hMDIAccel); +} + + + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CGBConv2App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App message handlers + diff --git a/Tools/GBConv2/Source/GBConv2.dsp b/Tools/GBConv2/Source/GBConv2.dsp new file mode 100644 index 0000000..c47ae36 --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.dsp @@ -0,0 +1,253 @@ +# Microsoft Developer Studio Project File - Name="GBConv2" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=GBConv2 - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "GBConv2.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "GBConv2.mak" CFG="GBConv2 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "GBConv2 - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "GBConv2 - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "GBConv2 - Win32 Release" + +# PROP BASE Use_MFC 5 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 5 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=copy exe from Release directory +PostBuild_Cmds=copy /y Release\*.exe . +# End Special Build Tool + +!ELSEIF "$(CFG)" == "GBConv2 - Win32 Debug" + +# PROP BASE Use_MFC 5 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 5 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "GBConv2 - Win32 Release" +# Name "GBConv2 - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\BGSaveDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChildFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChildView.cpp +# End Source File +# Begin Source File + +SOURCE=.\Controls.cpp +# End Source File +# Begin Source File + +SOURCE=.\EditArea.cpp +# End Source File +# Begin Source File + +SOURCE=.\EditPaletteDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\gb_pic.cpp + +!IF "$(CFG)" == "GBConv2 - Win32 Release" + +# ADD CPP /Yu + +!ELSEIF "$(CFG)" == "GBConv2 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\GBConv2.cpp +# End Source File +# Begin Source File + +SOURCE=.\GBConv2.rc +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\PaletteButton.cpp +# End Source File +# Begin Source File + +SOURCE=.\PaletteListBox.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\wingk.cpp + +!IF "$(CFG)" == "GBConv2 - Win32 Release" + +# ADD CPP /Yu + +!ELSEIF "$(CFG)" == "GBConv2 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ENDIF + +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\BGSaveDialog.h +# End Source File +# Begin Source File + +SOURCE=.\ChildFrm.h +# End Source File +# Begin Source File + +SOURCE=.\ChildView.h +# End Source File +# Begin Source File + +SOURCE=.\Controls.h +# End Source File +# Begin Source File + +SOURCE=.\EditArea.h +# End Source File +# Begin Source File + +SOURCE=.\EditPaletteDialog.h +# End Source File +# Begin Source File + +SOURCE=.\gb_pic.h +# End Source File +# Begin Source File + +SOURCE=.\GBConv2.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.h +# End Source File +# Begin Source File + +SOURCE=.\PaletteButton.h +# End Source File +# Begin Source File + +SOURCE=.\PaletteListBox.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\wingk.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\GBConv2.ico +# End Source File +# Begin Source File + +SOURCE=.\res\GBConv2.rc2 +# End Source File +# Begin Source File + +SOURCE=.\res\Toolbar.bmp +# End Source File +# End Group +# End Target +# End Project diff --git a/Tools/GBConv2/Source/GBConv2.dsw b/Tools/GBConv2/Source/GBConv2.dsw new file mode 100644 index 0000000..7ab3cd4 --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "GBConv2"=.\GBConv2.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Tools/GBConv2/Source/GBConv2.h b/Tools/GBConv2/Source/GBConv2.h new file mode 100644 index 0000000..d59462a --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.h @@ -0,0 +1,54 @@ +// GBConv2.h : main header file for the GBCONV2 application +// + +#if !defined(AFX_GBCONV2_H__2F0A9B44_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_GBCONV2_H__2F0A9B44_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CGBConv2App: +// See GBConv2.cpp for the implementation of this class +// + +class CGBConv2App : public CWinApp +{ +public: + CGBConv2App(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGBConv2App) + public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + //}}AFX_VIRTUAL + +// Implementation +protected: + HMENU m_hMDIMenu; + HACCEL m_hMDIAccel; + +public: + //{{AFX_MSG(CGBConv2App) + afx_msg void OnAppAbout(); + afx_msg void OnFileNew(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBCONV2_H__2F0A9B44_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/GBConv2.plg b/Tools/GBConv2/Source/GBConv2.plg new file mode 100644 index 0000000..d92ee57 --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.plg @@ -0,0 +1,87 @@ + + +
+

Build Log

+

+--------------------Configuration: GBConv2 - Win32 Release-------------------- +

+

Command Lines

+Creating command line "rc.exe /l 0x409 /fo"Release/GBConv2.res" /d "NDEBUG" "D:\Aprogs\GBConv2\GBConv2.rc"" +Creating temporary file "C:\WINDOWS\TEMP\RSP1245.TMP" with contents +[ +/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/GBConv2.pch" /Yu"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c +"D:\Aprogs\GBConv2\BGSaveDialog.cpp" +"D:\Aprogs\GBConv2\ChildFrm.cpp" +"D:\Aprogs\GBConv2\ChildView.cpp" +"D:\Aprogs\GBConv2\Controls.cpp" +"D:\Aprogs\GBConv2\EditArea.cpp" +"D:\Aprogs\GBConv2\EditPaletteDialog.cpp" +"D:\Aprogs\GBConv2\gb_pic.cpp" +"D:\Aprogs\GBConv2\GBConv2.cpp" +"D:\Aprogs\GBConv2\MainFrm.cpp" +"D:\Aprogs\GBConv2\PaletteButton.cpp" +"D:\Aprogs\GBConv2\PaletteListBox.cpp" +"D:\Aprogs\GBConv2\wingk.cpp" +] +Creating command line "cl.exe @C:\WINDOWS\TEMP\RSP1245.TMP" +Creating temporary file "C:\WINDOWS\TEMP\RSP1246.TMP" with contents +[ +/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/GBConv2.pch" /Yc"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c +"D:\Aprogs\GBConv2\StdAfx.cpp" +] +Creating command line "cl.exe @C:\WINDOWS\TEMP\RSP1246.TMP" +Creating temporary file "C:\WINDOWS\TEMP\RSP1247.TMP" with contents +[ +/nologo /subsystem:windows /incremental:no /pdb:"Release/GBConv2.pdb" /machine:I386 /out:"Release/GBConv2.exe" +.\Release\BGSaveDialog.obj +.\Release\ChildFrm.obj +.\Release\ChildView.obj +.\Release\Controls.obj +.\Release\EditArea.obj +.\Release\EditPaletteDialog.obj +.\Release\gb_pic.obj +.\Release\GBConv2.obj +.\Release\MainFrm.obj +.\Release\PaletteButton.obj +.\Release\PaletteListBox.obj +.\Release\StdAfx.obj +.\Release\wingk.obj +.\Release\GBConv2.res +] +Creating command line "link.exe @C:\WINDOWS\TEMP\RSP1247.TMP" +

Output Window

+Compiling resources... +Compiling... +StdAfx.cpp +Compiling... +BGSaveDialog.cpp +ChildFrm.cpp +ChildView.cpp +Controls.cpp +EditArea.cpp +EditPaletteDialog.cpp +gb_pic.cpp +GBConv2.cpp +MainFrm.cpp +PaletteButton.cpp +PaletteListBox.cpp +wingk.cpp +Generating Code... +Linking... +Creating temporary file "C:\WINDOWS\TEMP\RSP1370.BAT" with contents +[ +@echo off +copy /y Release\*.exe . +] +Creating command line "C:\WINDOWS\TEMP\RSP1370.BAT" +copy exe from Release directory +Release\GBConv2.exe + 1 file(s) copied + + + +

Results

+GBConv2.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/Tools/GBConv2/Source/GBConv2.rc b/Tools/GBConv2/Source/GBConv2.rc new file mode 100644 index 0000000..b205b05 --- /dev/null +++ b/Tools/GBConv2/Source/GBConv2.rc @@ -0,0 +1,411 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\GBConv2.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\GBConv2.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 +BEGIN + BUTTON ID_FILE_NEW + SEPARATOR + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About GBConv2...", ID_APP_ABOUT + MENUITEM "Instructions", ID_APP_INSTRUCTIONS + END +END + +IDR_GBCONVTYPE MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Window" + BEGIN + MENUITEM "&Cascade", ID_WINDOW_CASCADE + MENUITEM "&Tile", ID_WINDOW_TILE_HORZ + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE + END + POPUP "&Help" + BEGIN + MENUITEM "&About GBConv2...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 236, 55 +STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | + WS_CAPTION | WS_SYSMENU +CAPTION "About GBConv2" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "GBConv2 Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2000 by Abe Pralle",IDC_STATIC,40,25,119, + 8 + DEFPUSHBUTTON "OK",IDOK,179,7,50,14,WS_GROUP +END + +IDD_EDIT_PALETTE DIALOG DISCARDABLE 0, 0, 231, 103 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Edit Palette" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_EDIT_PAL_RED0,37,23,38,15,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_PAL_GREEN0,81,23,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_BLUE0,125,23,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_RED1,37,41,38,15,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_PAL_GREEN1,81,41,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_BLUE1,125,41,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_RED2,37,58,38,15,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_PAL_GREEN2,81,58,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_BLUE2,125,58,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_RED3,37,76,38,15,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_PAL_GREEN3,81,76,38,15,ES_AUTOHSCROLL | + ES_NUMBER + EDITTEXT IDC_EDIT_PAL_BLUE3,125,76,38,15,ES_AUTOHSCROLL | + ES_NUMBER + DEFPUSHBUTTON "OK",IDOK,174,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,174,24,50,14 + LTEXT "Color 0",IDC_STATIC,7,26,29,13 + CTEXT "Red",IDC_STATIC,41,7,28,12 + CTEXT "Green",IDC_STATIC,83,7,32,11 + CTEXT "Blue",IDC_STATIC,126,7,34,10 + LTEXT "Color 1",IDC_STATIC,7,44,29,13 + LTEXT "Color 2",IDC_STATIC,7,61,29,13 + LTEXT "Color 3",IDC_STATIC,7,79,29,13 +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "GBConv2 MFC Application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "GBConv2\0" + VALUE "LegalCopyright", "Copyright (C) 2000\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "GBConv2.EXE\0" + VALUE "ProductName", "GBConv2 Application\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 229 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END + + IDD_EDIT_PALETTE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 224 + TOPMARGIN, 7 + BOTTOMMARGIN, 96 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "GBConv2" + IDR_GBCONVTYPE "\nGBConv\nGBConv" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "GBConv2" + AFX_IDS_IDLEMESSAGE "Ready" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "Create a new document\nNew" + ID_FILE_CLOSE "Close the active document\nClose" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" + ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" + ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" + AFX_IDS_MDICHILD "Activate this window" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\GBConv2.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Tools/GBConv2/Source/MainFrm.cpp b/Tools/GBConv2/Source/MainFrm.cpp new file mode 100644 index 0000000..2986113 --- /dev/null +++ b/Tools/GBConv2/Source/MainFrm.cpp @@ -0,0 +1,108 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "GBConv2.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE + | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE; + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + + +void CMainFrame::ShowStatus(CString *st) +{ + if(IsWindow(m_wndStatusBar.m_hWnd)){ + m_wndStatusBar.SetWindowText(*st); + } +} diff --git a/Tools/GBConv2/Source/MainFrm.h b/Tools/GBConv2/Source/MainFrm.h new file mode 100644 index 0000000..0e200b3 --- /dev/null +++ b/Tools/GBConv2/Source/MainFrm.h @@ -0,0 +1,57 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__2F0A9B48_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_MAINFRM_H__2F0A9B48_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + void ShowStatus(CString *st); + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__2F0A9B48_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/PaletteButton.cpp b/Tools/GBConv2/Source/PaletteButton.cpp new file mode 100644 index 0000000..82e6f46 --- /dev/null +++ b/Tools/GBConv2/Source/PaletteButton.cpp @@ -0,0 +1,33 @@ +// PaletteButton.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "PaletteButton.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPaletteButton + +CPaletteButton::CPaletteButton() +{ +} + +CPaletteButton::~CPaletteButton() +{ +} + + +BEGIN_MESSAGE_MAP(CPaletteButton, CButton) + //{{AFX_MSG_MAP(CPaletteButton) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPaletteButton message handlers diff --git a/Tools/GBConv2/Source/PaletteButton.h b/Tools/GBConv2/Source/PaletteButton.h new file mode 100644 index 0000000..22db0db --- /dev/null +++ b/Tools/GBConv2/Source/PaletteButton.h @@ -0,0 +1,48 @@ +#if !defined(AFX_PALETTEBUTTON_H__74CE4C52_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_PALETTEBUTTON_H__74CE4C52_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PaletteButton.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CPaletteButton window + +class CPaletteButton : public CButton +{ +// Construction +public: + CPaletteButton(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPaletteButton) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CPaletteButton(); + + // Generated message map functions +protected: + //{{AFX_MSG(CPaletteButton) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PALETTEBUTTON_H__74CE4C52_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/PaletteListBox.cpp b/Tools/GBConv2/Source/PaletteListBox.cpp new file mode 100644 index 0000000..6a89df6 --- /dev/null +++ b/Tools/GBConv2/Source/PaletteListBox.cpp @@ -0,0 +1,126 @@ +// PaletteListBox.cpp : implementation file +// + +#include "stdafx.h" +#include "GBConv2.h" +#include "PaletteListBox.h" +#include "gb_pic.h" +#include "ChildView.h" +#include "Controls.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPaletteListBox + +CPaletteListBox::CPaletteListBox() +{ + int i; + for(i=0; i<17; i++) itemSelected[i] = 0; + pic = 0; +} + +CPaletteListBox::~CPaletteListBox() +{ +} + + +BEGIN_MESSAGE_MAP(CPaletteListBox, CListBox) + //{{AFX_MSG_MAP(CPaletteListBox) + ON_WM_CREATE() + ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange) + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP + ON_LBN_SELCHANGE(IDLIST_PALETTES, OnSelchange) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPaletteListBox message handlers + +void CPaletteListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + lpMeasureItemStruct->itemWidth = 64; + lpMeasureItemStruct->itemHeight = 16; +} + +void CPaletteListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + + int index = this->GetItemData(lpDrawItemStruct->itemID); + if(index < 0 || index>15) return; + + if(lpDrawItemStruct->itemState & ODS_SELECTED){ + pic->SetCurPalette(index); + } + + CRect rect = lpDrawItemStruct->rcItem; + int x = rect.left; + int y = rect.top; + + CBrush black((int) 0); + CBrush white(0xffffff); + //CBrush bgColor(pDC->GetBkColor()); + CBrush bgColor(0x303030); + + gkRGB *pal = view->pic.GetPalette(index); + + int i; + for(i=0; i<4; i++){ + gkRGB color = pal[i]; + if(color.GetA()==0){ + //blit the "no color" image + //pic->nonColorBG.BlitToDC(pDC, x+3, y+3); + pic->nonColorBG.BlitToHDC(*pDC, x+3, y+3); + }else{ + pDC->FillSolidRect(x+3,y+3,10,10,color); + } + pDC->FrameRect(CRect(x+2,y+2,x+14,y+14), &black); + x += 16; + } + + //clear the frame to the bg color + //pDC->FrameRect(rect, &bgColor); + + if(lpDrawItemStruct->itemState & ODS_SELECTED){ + itemSelected[index] = 1; + pDC->FrameRect(rect, &white); + }else{ + itemSelected[index] = 0; + pDC->FrameRect(rect, &bgColor); + } +} + +int CPaletteListBox::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CListBox::OnCreate(lpCreateStruct) == -1) + return -1; + + controls = (CControls*) this->GetParent(); + view = (CChildView*) controls->GetParent(); + + return 0; +} + + + +void CPaletteListBox::OnSelchange() +{ + this->MessageBox("Super Duper!"); +} + + +BOOL CPaletteListBox::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; + GetClientRect(&rect); + + pDC->FillSolidRect(&rect, 0x303030); + return 1; + + //return CListBox::OnEraseBkgnd(pDC); +} diff --git a/Tools/GBConv2/Source/PaletteListBox.h b/Tools/GBConv2/Source/PaletteListBox.h new file mode 100644 index 0000000..5fe5403 --- /dev/null +++ b/Tools/GBConv2/Source/PaletteListBox.h @@ -0,0 +1,62 @@ +#if !defined(AFX_PALETTELISTBOX_H__74CE4C4B_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_PALETTELISTBOX_H__74CE4C4B_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PaletteListBox.h : header file +// + +#include "gb_pic.h" + +class CChildView; +class CControls; + +///////////////////////////////////////////////////////////////////////////// +// CPaletteListBox window + +class CPaletteListBox : public CListBox +{ +// Construction +public: + CPaletteListBox(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPaletteListBox) + public: + virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + //}}AFX_VIRTUAL + +// Implementation +public: + CChildView *view; + CControls *controls; + gbPic * pic; + virtual ~CPaletteListBox(); + + // Generated message map functions +protected: + int itemSelected[17]; + //{{AFX_MSG(CPaletteListBox) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSelchange(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PALETTELISTBOX_H__74CE4C4B_0DAC_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/StdAfx.cpp b/Tools/GBConv2/Source/StdAfx.cpp new file mode 100644 index 0000000..f43b5a0 --- /dev/null +++ b/Tools/GBConv2/Source/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// GBConv2.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/Tools/GBConv2/Source/StdAfx.h b/Tools/GBConv2/Source/StdAfx.h new file mode 100644 index 0000000..5d66901 --- /dev/null +++ b/Tools/GBConv2/Source/StdAfx.h @@ -0,0 +1,27 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__2F0A9B46_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_STDAFX_H__2F0A9B46_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__2F0A9B46_0CC2_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/GBConv2/Source/gb_pic.cpp b/Tools/GBConv2/Source/gb_pic.cpp new file mode 100644 index 0000000..27a7505 --- /dev/null +++ b/Tools/GBConv2/Source/gb_pic.cpp @@ -0,0 +1,1727 @@ +#include "stdafx.h" +#include "gb_pic.h" +#include +#include + +//statics +gkWinShape gbPic::nonPictureBG; +gkWinShape gbPic::nonColorBG; +gkWinShape gbPic::gfxTiles[20]; + +////////////////////////////////////////////////////////////////////// +// Open8BitHashTable +////////////////////////////////////////////////////////////////////// +Open8BitHashTable::Open8BitHashTable(){ + table = 0; + Reset(); +} + +Open8BitHashTable::~Open8BitHashTable(){ + Reset(); +} + +void Open8BitHashTable::Reset(){ + if(table) delete table; + table = 0; + size = 0; +} + +void Open8BitHashTable::Create(int maxElements){ + Reset(); + + size = maxElements + 1; + int powerTwo = 1; + while(powerTwo < size) powerTwo<<=1; + size = powerTwo; + + table = new HashEntry[size]; + + int i; + for(i=0; i<256; i++){ + entryPoint[i] = (size * i) / 256; + } +} + +int Open8BitHashTable::SetFirstIndex(int code){ + return entryPoint[code & 0xff]; +} + +int Open8BitHashTable::GetNextIndex(int &position){ + int retVal; + if(table[position].hash==-1){ + retVal = -1; + position++; + }else{ + retVal = table[position++].index; + } + position &= (size-1); //size is always power of two + return retVal; +} + +void Open8BitHashTable::Add(int code, int index){ + int pos = SetFirstIndex(code); + + //advance 'pos' to the proper position + while(GetNextIndex(pos)!=-1); + + pos--; + pos &= (size-1); + + table[pos].hash = code; + table[pos].index = index; +} + + + +////////////////////////////////////////////////////////////////////// +// gbTile +////////////////////////////////////////////////////////////////////// + +gbTile::gbTile(){ + gkWinShape::gkWinShape(); + colors = 0; + Reset(); +} + +gbTile::~gbTile(){ + Reset(); +} + +void gbTile::Reset(){ + gkWinShape::FreeData(); + if(colors) delete colors; + colors = 0; +} + +void gbTile::OnColorChange(){ + paletteUsed = -1; + + gkPaletteGenerator gen; + int numPixels; + numPixels = width * height; + gkRGB *curData = (gkRGB*) data; + while(numPixels--){ + gen.AddColor(*(curData++)); + } + colorsUsed = gen.GetNumColors(); + if(colors) delete colors; + colors = new gkRGB[colorsUsed]; + gen.CreatePalette(colors,colorsUsed); +} + +int gbTile::OnPaletteChange(int palettes){ + int result = 0; + + if(paletteUsed==-1) return 0; + if(palettes & (1 << paletteUsed)){ + paletteUsed = -1; + OnColorChange(); + result = 1; + } + + return result; +} + +int gbTile::TestMatch(gkRGB *palette){ + int i, diff = 0; + gkPaletteGenerator gen; + + for(i=0; i<4; i++){ + if(palette[i].GetA()==0){ + if(i==0) return 0xffff; + break; + } + gen.AddColor(palette[i]); + } + + for(i=0; idata; + int i, bit, dest; + dest = 0; + dataHash = 0; + for(i=0; i<8; i++){ //8 lines + int byte1 = 0; + int byte2 = 0; + for(bit=0; bit<8; bit++){ // 8 bits per line + //find the color index of next pixel + gkRGB color = *(src++); + int index; + for(index=0; index<4; index++){ + if(palettePtr[index]==color) break; + } + + //save the two bits of the color index in separate bytes + byte1 = (byte1<<1) | (index & 1); + byte2 = (byte2<<1) | ((index>>1)&1); + } + + dataHash += byte1 + byte2; + rawData[dest++] = byte1; + rawData[dest++] = byte2; + } +} + +void gbTile::SetRawData(gkBYTE *data){ + dataHash = 0; + int i; + for(i=0; i<16; i++){ + rawData[i] = data[i]; + dataHash += data[i]; + } +} + +void gbTile::CreateFromRawData(gbPic *pic){ + Create(8,8); + + gkRGB *dest = (gkRGB*) data; + int pos = 0; + + int i; + for(i=0; i<8; i++){ + int byte1 = rawData[pos++]; + int byte2 = rawData[pos++]; + + for(int bit=0; bit<8; bit++){ + int index = 0; + if(byte1 & 128) index += 1; + if(byte2 & 128) index += 2; + byte1<<=1; + byte2<<=1; + *(dest++) = palettePtr[index]; + } + } + + int pal = paletteUsed; + OnColorChange(); + SetPaletteUsed(pic,pal); +} + +int gbTile::CompareRawData(gkBYTE *data2){ + int i; + for(i=0; i<16; i++){ + if(rawData[i] != data2[i]) return 0; + } + return 1; +} + +void gbTile::SetPaletteUsed(gbPic *pic, int n){ + paletteUsed = n; + palettePtr = pic->GetPalette(n); +} + +void gbTile::CopyRawDataTo(gkBYTE *dest){ + int i; + for(i=0; i<16; i++) dest[i] = rawData[i]; +} + +void gbTile::WriteRawData(ostream &out){ + int i; + for(i=0; i<16; i++) out.put(rawData[i]); +} + + +////////////////////////////////////////////////////////////////////// +// gbSprite +////////////////////////////////////////////////////////////////////// +gbSprite::gbSprite(){ + gkWinShape::gkWinShape(); + Reset(); +} + +gbSprite::~gbSprite(){ + Reset(); + gkWinShape::~gkWinShape(); +} + +void gbSprite::Reset(){ + gkWinShape::Reset(); +} + +void gbSprite::Create8x16FromSelection(int x1, int y1, + gbTile *tile1, gbTile *tile2, gkWinShape *selection, gbPic *pic){ + + xp = x1; + yp = y1; + + Create(8,16); + int pal = tile1->GetPaletteUsed(); + if(pal==-1) pal = pic->GetCurPalette(); + + palette = pic->GetPalette(pal); + paletteNum = pal; + + gkRGB bgColor = pic->GetColor(pal,0); + Cls(bgColor); + + int x,y; + for(y=0; y<8; y++){ + for(x=0; x<8; x++){ + gkRGB color = selection->Point(x+x1,y+y1); + if(color.GetA() != 255){ + Plot(x,y,tile1->Point(x,y)); + selection->Plot(x+x1,y+y1,gkRGB(0,0,0,255)); + tile1->Plot(x,y,bgColor); + } + } + } + tile1->OnColorChange(); + + if(tile2){ + for(y=8; y<16; y++){ + for(x=0; x<8; x++){ + gkRGB color = selection->Point(x+x1,y+y1); + if(color.GetA() != 255){ + Plot(x,y,tile2->Point(x,y-8)); + selection->Plot(x+x1,y+y1,gkRGB(0,0,0,255)); + tile2->Plot(x,y-8,bgColor); + } + } + } + tile2->OnColorChange(); + } + + SetColorAlpha(bgColor,0); + MakeRawData(); +} + +void gbSprite::Blit(gkWinShape *dest){ + gkWinShape::Blit(dest,xp,yp); +} + +void gbSprite::DrawFrame(gkWinShape *dest, int magnification){ + int shrink = 1; + if(((yp>>3)&1) == 1) shrink = 3; + + int x = ((xp*magnification) >> 8); + int y = ((yp*magnification) >> 8); + + int width = (8 * magnification) >> 8; + int height = (16 * magnification) >> 8; + + dest->RectFrame(x+shrink,y+shrink,width-shrink*2,height-shrink*2, + gkRGB(128,255,128)); +} + +int gbSprite::ExistsAtIndex(int i, int j){ + int my_i = xp>>3; + int my_j = yp>>3; + if(my_i==i && (my_j==j || my_j+1==j)) return 1; + return 0; +} + +int gbSprite::Unmake(gbPic *pic){ + int i,j; + i = xp>>3; + j = yp>>3; + int index1 = j * pic->tileWidth + i; + int index2 = index1 + pic->tileWidth; + + this->gkWinShape::Blit(&pic->tiles[index1], 0, 0); + pic->tiles[index1].OnColorChange(); + if(j+1 < pic->tileHeight){ + this->gkWinShape::Blit(&pic->tiles[index2],0,-8); + pic->tiles[index2].OnColorChange(); + } + + return 1; +} + +void gbSprite::WriteTileDefinitions(ostream &out){ + int i; + for(i=0; i<32; i++) out.put((char) rawData[i]); +} + + +void gbSprite::ReadTileDefinitions(istream &in){ + //no palette yet, have to store raw data for later + int i; + for(i=0; i<32; i++) rawData[i] = in.get(); +} + + +void gbSprite::WriteAttributes(ostream &out, int index){ + // BYTE: Y-position + // BYTE: X-position + // BYTE: Image index of sprite used (0-127) + // BYTE: ATTRIBUTES: + // Bit 7: 0 = Sprite displayed over BG & window + // 1 = Sprite hidden behind colors 1,2,&3 of + // BG & win (stored as 0) + // Bit 6: Y flip status (stored as 0) + // Bit 5: X flip status (stored as 0) + // Bit 4: Not used in GBC (stored as 0) + // Bit 3: Character bank used (1/0) + // Bits[2:0]: Palette number (0-7) (Stored as 0) + out.put((char) (yp + 16)); + out.put((char) (xp + 8)); + out.put((char) (index * 2)); + + int attributes = paletteNum; + out.put((char) attributes); +} + + +void gbSprite::ReadAttributes(istream &in, gbPic *pic){ + // BYTE: Y-position + // BYTE: X-position + // BYTE: Image index of sprite used (0-127) + // BYTE: ATTRIBUTES: + // Bit 7: 0 = Sprite displayed over BG & window + // 1 = Sprite hidden behind colors 1,2,&3 of + // BG & win (stored as 0) + // Bit 6: Y flip status (stored as 0) + // Bit 5: X flip status (stored as 0) + // Bit 4: Not used in GBC (stored as 0) + // Bit 3: Character bank used (1/0) + // Bits[2:0]: Palette number (0-7) (Stored as 0) + yp = (in.get() & 0xff) - 16; + xp = (in.get() & 0xff) - 8; + in.get(); //discard index + paletteNum = in.get() & 7; + palette = pic->GetPalette(paletteNum); +} + + +void gbSprite::CreateFromRawData(){ + Create(8,16); + + gkRGB *dest = (gkRGB*) data; + int pos = 0; + + int i; + for(i=0; i<16; i++){ + int byte1 = rawData[pos++]; + int byte2 = rawData[pos++]; + + for(int bit=0; bit<8; bit++){ + int index = 0; + if(byte1 & 128) index += 1; + if(byte2 & 128) index += 2; + byte1<<=1; + byte2<<=1; + *(dest++) = palette[index]; + } + } + + SetColorAlpha(palette[0],0); +} + +void gbSprite::MakeRawData(){ + gkRGB *src = (gkRGB*) this->data; + int i, bit, dest; + dest = 0; + for(i=0; i<16; i++){ //16 lines + int byte1 = 0; + int byte2 = 0; + for(bit=0; bit<8; bit++){ // 8 bits per line + //find the color index of next pixel + gkRGB color = *(src++); + int index; + for(index=0; index<4; index++){ + if(palette[index]==color) break; + } + + //save the two bits of the color index in separate bytes + byte1 = (byte1<<1) | (index & 1); + byte2 = (byte2<<1) | ((index>>1)&1); + } + + rawData[dest++] = byte1; + rawData[dest++] = byte2; + } +} + + +////////////////////////////////////////////////////////////////////// +// gbPic +////////////////////////////////////////////////////////////////////// + +gbPic::gbPic(){ + tiles = 0; + selected = 0; + magnifiedArea.Create(80,80); + numSprites = 0; + Reset(); + + //set up static stuff + if(!nonPictureBG.GetData()){ + nonPictureBG.Create(80,80); + nonPictureBG.Cls(gkRGB(0x60,0x60,0x60)); + int i,j; + for(j=0; j<5; j++){ + for(i=0; i<5; i++){ + if(((j&1) && !(i&1)) || (!(j&1) && (i&1))){ + nonPictureBG.RectFill(i<<4, j<<4, 16, 16, gkRGB(0xa0,0xa0,0xa0)); + } + } + } + + nonColorBG.Create(10,10); + nonPictureBG.BlitScale(&nonColorBG,0,0,0x48,0); + + gkWinShape buffer; + buffer.LoadBMP("converter_gfx.bmp"); + for(i=0; i<20; i++){ + gfxTiles[i].GetShape(&buffer,i*16,0,16,16); + if(i<16) gfxTiles[i].SetAlpha(0xc0); + gfxTiles[i].SetColorAlpha(gkRGB(0,0,255), 0); + } + } +} + +gbPic::~gbPic(){ + Reset(); +} + +void gbPic::Reset(){ + if(tiles) delete [] tiles; + tiles = 0; + if(selected) delete selected; + selected = 0; + tileWidth = tileHeight = displayWidth = displayHeight = 0; + totalTiles = 0; + displayBuffer.FreeData(); + magnification = 0x400; + needsRedraw = 1; + showGrid = 1; + dragSetOrClear = 0; + + int i; + for(i=0; i<64; i++) palettes[i] = gkRGB(0,0,0,0); + + for(i=0; i> 3; + tileHeight = ((original.GetHeight() + 7) & (~7)) >> 3; + //displayWidth = tileWidth * 8 * 4; + //displayHeight = tileHeight * 8 * 4; + //magnification = 0x10000 << 2; + + original.ReduceColors(56); + + //merge vagrant colors (colors that will appear the same in the GBC + //15-bit palette) + int *data = (int*) original.GetData(); + int i = original.GetWidth() * original.GetHeight(); + while(i--){ + *(data++) &= 0xfff8f8f8; //clear bits 2:0 of each color + } + + //create some buffers + int pixelWidth = tileWidth << 3; + int pixelHeight = tileHeight << 3; + totalTiles = tileWidth * tileHeight; + SetMagnification(0x400); //default 4x magnification + + backbuffer.Create(pixelWidth, pixelHeight); + pixelBuffer.Create(pixelWidth, pixelHeight); + selectionBuffer.Create(pixelWidth, pixelHeight); + displayBuffer.Create(displayWidth, displayHeight); + + displayBuffer.Cls(gkRGB(255,255,0)); + original.Blit(&displayBuffer,0,0,0); + + selectionBuffer.SetAlpha(255); + + int j,index; + selected = new int[totalTiles]; + for(i=0; i=0; i--) sprites[i]->Blit(&backbuffer); + } + + //highlight selected tiles + //index = 0; + //for(j=0; j> 8; + for(i=0; i> 8; + int pal = tiles[index].GetPaletteUsed(); + if(pal>=0){ + gfxTiles[TILE_PAL0+pal].Blit(&displayBuffer,x,y); + } + index++; + } + } + } + + //draw the grid + if(showGrid){ + for(j=0; j> 8) - 1; + displayBuffer.Line(0,y,displayWidth-1,y,gkRGB(128,128,128)); + } + for(i=0; i> 8) - 1; + displayBuffer.Line(x,0,x,displayHeight-1,gkRGB(128,128,128)); + } + } + + //draw the sprite bounding boxes + if(flags & 1){ + for(i=numSprites-1; i>=0; i--){ + sprites[i]->DrawFrame(&displayBuffer,magnification); + } + } +} + +gkWinShape *gbPic::GetDisplayBuffer(int showSprites){ + if(needsRedraw){ + needsRedraw = 0; + Redraw(showSprites); + } + + return &displayBuffer; +} + +gkWinShape *gbPic::GetMagnifiedArea(int x, int y){ + //magnifiedArea.Cls(); + nonPictureBG.Blit(&magnifiedArea, 0, 0, 0); + + if(x<0 || y<0 || x>=displayWidth || y>=displayHeight + || !backbuffer.GetData()){ + //draw black frame + magnifiedArea.RectFrame(0,0,80,80,gkRGB(0,0,0)); + return &magnifiedArea; + } + + x = (x<<8) / magnification; + y = (y<<8) / magnification; + + x = (x * 0x1000) >> 8; + y = (y * 0x1000) >> 8; + backbuffer.BlitScale(&magnifiedArea,-x + 32, -y + 32, 0x1000, 0); + + //draw green highlight box around pixel under cursor + //magnifiedArea.RectFrame(32,32,16,16,gkRGB(128,255,128)); + gfxTiles[TILE_BORDER].Blit(&magnifiedArea,32,32); + + //draw black border around whole thing + magnifiedArea.RectFrame(0,0,80,80,gkRGB(0,0,0)); + + return &magnifiedArea; +} + + +void gbPic::SetMagnification(int n){ + int width = tileWidth * 8; + int height = tileHeight * 8; + + int sx = GetSystemMetrics(SM_CXSCREEN) - (224 + 32); + int sy = GetSystemMetrics(SM_CYSCREEN) - 128; + + //reduce magnification until image is <= width & height of screen + while(width * n > (sx << 8)){ + if(n > 0x200) n -= 0x100; + else n -= 0x10; + } + + while(height * n > (sy << 8)){ + if(n > 0x200) n -= 0x100; + else n -= 0x10; + } + + width = (width * n) >> 8; + height = (height * n) >> 8; + + if(width > displayWidth || height > displayHeight){ + displayBuffer.Create(width, height); + } + + displayWidth = width; + displayHeight = height; + magnification = n; +} + +gkRGB gbPic::GetColor(int pal, int n){ + return palettes[pal*4+n]; +} + +void gbPic::SetColor(int pal, int n, gkRGB c){ + palettes[pal*4+n] = c; + + int palChanged = (1<CreateFromRawData(); + sprites[i]->MakeRawData(); + } +} + +// Returns: 1 if tile index is selected, 0 if not or out of bounds +int gbPic::GetSelected(int i, int j){ + if(i<0 || j<0 || i>=tileWidth || j>=tileHeight) return 0; + return selected[j*tileWidth + i]; +} + +void gbPic::GetIndicesAtPoint(int x, int y, int &i, int &j){ + //get unmagnified pixel coords + x = (x<<8) / magnification; + y = (y<<8) / magnification; + + //divide by 8 to get tile indices + i = x >> 3; + j = y >> 3; + + if(i<0 || j<0 || i>=tileWidth || j>=tileHeight){ + i = j = -1; + } +} + + +gkRGB gbPic::GetColorAtPoint(int x, int y){ + //get unmagnified pixel coords + x = (x<<8) / magnification; + y = (y<<8) / magnification; + + if(x<0 || x<0 || x>=pixelBuffer.GetWidth() || y>=pixelBuffer.GetHeight()){ + return gkRGB(0,0,0); + } + + return pixelBuffer.Point(x,y); +} + + +int gbPic::GetMappingAtPoint(int x, int y){ + //get unmagnified pixel coords + x = (x<<8) / magnification; + y = (y<<8) / magnification; + + //divide by 8 to get tile indices + int i = x >> 3; + int j = y >> 3; + + if(i<0 || j<0 || i>=tileWidth || j>=tileHeight){ + return -1; + } + + return tiles[j*tileWidth+i].GetPaletteUsed(); +} + + + +void gbPic::OnMouseLMB(int x, int y){ + int i,j; + + GetIndicesAtPoint(x,y,i,j); + if(i==-1) return; + + //set selection to "set" if *all* pixels in selectionBuffer + //have alpha 255, "clear" otherwise. +//static int times=1; +//if(times++ == 2){ +//ASSERT(0); +//} + + x = i<<3; + y = j<<3; + int sel = 0, ii, jj; + for(jj=y+7; jj>=y; jj--){ + gkRGB *data = (gkRGB*) selectionBuffer.GetData(); + data += jj*selectionBuffer.GetWidth() + x + 7; + for(ii=x+7; ii>=x; ii--){ + if(data->GetA()!=255){ + sel = 1; + break; + } + data--; + } + if(sel==1) break; + } + dragSetOrClear = 1 - sel; + + //if(GetSelected(i,j)){ + //already highlighted, so clear it + //dragSetOrClear = 0; + //}else{ + //dragSetOrClear = 1; + //} + + int index = j*tileWidth + i; + //if(selected[index] != dragSetOrClear){ + selected[index] = dragSetOrClear; + needsRedraw = 1; + //} + + dragStart_i = i; + dragStart_j = j; +} + +void gbPic::OnMouseLDrag(int x, int y){ + int i1,j1,i2,j2; + GetIndicesAtPoint(x,y,i2,j2); + if(i2==-1) return; + + if(i2 > dragStart_i) i1 = dragStart_i; + else{ + i1 = i2; + i2 = dragStart_i; + } + + if(j2 > dragStart_j) j1 = dragStart_j; + else{ + j1 = j2; + j2 = dragStart_j; + } + + //clear temporary "visual feedback" selected grids + int i,j,index = 0; + for(j=0; j dragStart_i) i1 = dragStart_i; + else{ + i1 = i2; + i2 = dragStart_i; + } + + if(j2 > dragStart_j) j1 = dragStart_j; + else{ + j1 = j2; + j2 = dragStart_j; + } + + //select permanent + //ASSERT(0); + numSelColors = 0; + for(j=j1; j<=j2; j++){ + for(i=i1; i<=i2; i++){ + index = j*tileWidth + i; + selected[index] = dragSetOrClear; + if(dragSetOrClear){ + //set + selectionBuffer.RectFill(i<<3,j<<3,8,8,gkRGB(255,255,255,0x80)); + int numPixels = 64; + gkRGB *colors = (gkRGB*) tiles[index].GetData(); + while(numPixels--){ + gkRGB c = *(colors++); + int sel, found=0; + for(sel=0; sel=0; i--){ + gkRGB color = selectedColors[i]; + for(j=0; j1 || + tiles[index].GetColors()[0]!=bgColor){ + if(!selected[index]) numSelTiles++; + selected[index] = 1; + selectionBuffer.RectFill(i<<3,j<<3,8,8,gkRGB(255,255,255,0x80)); + needsRedraw = 1; + } + index++; + } + } +} + + +void gbPic::SelectUnmapped(){ + int i,j,index; + index = 0; + for(j=0; j=40) return; + int myIndex = j*tileWidth + i; + int nextIndex = (j+1)*tileWidth + i; + gbTile *tile1 = &tiles[myIndex]; + if(selected[myIndex]){ + selected[myIndex] = 0; + + //extract the tile + gbTile *tile2; + if(j == tileHeight-1 || !selected[nextIndex]){ + //no tile below or not selected + tile2 = 0; + }else{ + tile2 = &tiles[nextIndex]; + if(tile2->GetPaletteUsed() != tile1->GetPaletteUsed()){ + tile2 = 0; + }else{ + selected[nextIndex] = 0; + } + } + sprites[numSprites] = new gbSprite(); + sprites[numSprites]->Create8x16FromSelection(i<<3,j<<3, + tile1, tile2, &selectionBuffer, this); + numSprites++; + } + } + } + + needsRedraw = 1; +} + +int gbPic::FindBestSpritePalette(gkRGB *pal, int numColors){ + return 0; +} + +int gbPic::UnmakeSprite(int x, int y){ + int i2,j2; + GetIndicesAtPoint(x,y,i2,j2); + if(i2==-1) return 0; + + int i; + for(i=numSprites-1; i>=0; i--){ + if(sprites[i]->ExistsAtIndex(i2,j2)){ + sprites[i]->Unmake(this); + delete sprites[i]; + numSprites--; + for(; i> 3) & 31; + int g = (color.GetG() >> 3) & 31; + int b = (color.GetB() >> 3) & 31; + int gbColor = (b<<10) | (g<<5) | r; + out.put((char) (gbColor & 0xff)); + out.put((char) ((gbColor>>8) & 0xff)); + index++; + } + } + +} + +void gbPic::SaveGBSprite(const char *filename){ + + ofstream out(filename,ios::out|ios::binary); + if(!out) return; + + int numTiles = numSprites * 2; //will be 80 max + int i; + + // BYTE Bank 0 Sprite definition data exists (!0 = true) + // BYTE Number of sprite patterns (0 = 256) + // REPT[number of defined sprites] + // BYTE[16] sprite data + out.put((char) (numTiles!=0)); + if(numTiles>0){ + out.put((char) (numTiles)); + for(i=0; iWriteTileDefinitions(out); + } + } + + + // BYTE Bank 1 Sprite definition data exists (!0 = true) + out.put((char) 0); //no bank 1 sprites + + //width & height + out.put((char) tileWidth); + out.put((char) 0); //store zero for pitch + out.put((char) tileHeight); + + //sprite instances (composing metasprite) + // BYTE numSprites + // REPT[numSprites]: SPRITE ATTRIBUTE DATA (Copy to spriteOAMBuffer) + out.put((char) numSprites); + for(i=0; iWriteAttributes(out,i); + } + + SavePaletteInfo(out); + + fileSize = (int) out.tellp(); + + out.close(); +} + + +int gbPic::LoadGBSprite(const char *filename){ + ifstream in(filename, ios::in | ios::binary | ios::nocreate); + if(!in) return 0; + + Reset(); + + int hasBank0 = in.get(); + if(!hasBank0) return 1; + + int numTileDefs = in.get(); + numSprites = numTileDefs / 2; + + int i; + for(i=0; iReadTileDefinitions(in); + } + + in.get(); //discard bank 1 definitions exist + + tileWidth = in.get() & 0xff; + in.get(); + tileHeight = in.get() & 0xff; + + //Set up buffers + int pixelWidth = tileWidth << 3; + int pixelHeight = tileHeight << 3; + totalTiles = tileWidth * tileHeight; + SetMagnification(0x400); //default 4x magnification + + backbuffer.Create(pixelWidth, pixelHeight); + pixelBuffer.Create(pixelWidth, pixelHeight); + selectionBuffer.Create(pixelWidth, pixelHeight); + displayBuffer.Create(displayWidth, displayHeight); + + displayBuffer.Cls(gkRGB(0,0,0xf8)); + selectionBuffer.SetAlpha(255); + + int j,index; + selected = new int[totalTiles]; + for(i=0; iReadAttributes(in,this); + } + + //read palette + int numColors = in.get() & 0xff; + for(i=0; i> 3) & 7; + int entry = (spec >> 1) & 3; + int gbColor = in.get() & 0xff; + gbColor = ((in.get() & 0xff) << 8) | gbColor; + int r = (gbColor & 31) << 3; + int g = ((gbColor>>5) & 31) << 3; + int b = ((gbColor>>10) & 31) << 3; + palettes[pal*4 + entry] = gkRGB(r,g,b); + } + + for(i=0; iCreateFromRawData(); + } + + needsRedraw = 1; + + in.close(); + return 1; +} + +void gbPic::SaveGBPic(const char *filename){ + ofstream out(filename,ios::out|ios::binary); + if(!out) return; + + ClearSelection(); + AutoMap(255); + + out.put((char) 1); //bank 0 exists + out.put((char) 0); //allocate space for numBank0Tiles + + gkBYTE rawData[512*16]; + int dataHash[512]; + int numUnique = 0; + + //Write out blank tile definition as tile zero + int i; + for(i=0; i<16; i++){ + out.put((char) 0); + rawData[i] = 0; + } + dataHash[numUnique++] = 0; + + //write out tile definitions, avoiding duplicates + int bank1Pos = 0; + int index; + for(i=0; i0){ + out.seekp(bank1Pos); + out.put((char) (numUnique - 256)); + out.seekp(curFilePos); + }else{ + out.seekp(curFilePos); + out.put((char) 0); //no bank 1 tiles + } + + int tilePitch = 1; + while(tilePitch < tileWidth) tilePitch<<=1; + + out.put((char) tileWidth); + //out.put((char) tilePitch); + out.put((char) tileHeight); + + //write out tile index data + for(i=0; i=256) attr1 |= 8; + i++; + + index = tiles[i].GetTileIndex(); + int attr2 = tiles[i].GetPaletteUsed(); + if(index>=256) attr2 |= 8; + + out.put((char) ((attr1<<4) | attr2)); + } + + SavePaletteInfo(out); + + fileSize = (int) out.tellp(); + + out.close(); +} + +int gbPic::LoadGBPic(const char *filename){ + ifstream in(filename, ios::in | ios::binary | ios::nocreate); + if(!in) return 0; + + Reset(); + + int i; + gkBYTE rawData[1024*16]; //twice as much as max + + int hasBank0 = in.get(); + if(!hasBank0) return 1; + + int numBank0 = in.get(); + if(!numBank0) numBank0 = 256; + in.read(rawData,numBank0*16); + + int numBank1 = 0; + int hasBank1 = in.get(); + if(hasBank1){ + numBank1 = in.get(); + if(!numBank1) numBank1 = 256; + in.read(rawData + numBank0*16, numBank1*16); + } + + tileWidth = in.get(); + tileHeight = in.get(); + totalTiles = tileWidth * tileHeight; + + //Set up buffers + int pixelWidth = tileWidth << 3; + int pixelHeight = tileHeight << 3; + SetMagnification(0x400); //default 4x magnification + + backbuffer.Create(pixelWidth, pixelHeight); + pixelBuffer.Create(pixelWidth, pixelHeight); + selectionBuffer.Create(pixelWidth, pixelHeight); + displayBuffer.Create(displayWidth, displayHeight); + + displayBuffer.Cls(gkRGB(0,0,0xf8)); + selectionBuffer.SetAlpha(255); + + selected = new int[totalTiles]; + for(i=0; i>4) & 15; + int attr2 = combo & 15; + if(attr1 & 8) tiles[i].SetRawData( + rawData+numBank0*16+tiles[i].GetTileIndex()*16); + else tiles[i].SetRawData(rawData + tiles[i].GetTileIndex()*16); + tiles[i].SetPaletteUsed(this, attr1 & 7); + i++; + + if(attr2 & 8) tiles[i].SetRawData( + rawData+numBank0*16+tiles[i].GetTileIndex()*16); + else tiles[i].SetRawData(rawData + tiles[i].GetTileIndex()*16); + tiles[i].SetPaletteUsed(this, attr2 & 7); + } + + //read palette + int numColors = in.get() & 0xff; + for(i=0; i> 3) & 7; + int entry = (spec >> 1) & 3; + int gbColor = in.get() & 0xff; + gbColor = ((in.get() & 0xff) << 8) | gbColor; + int r = (gbColor & 31) << 3; + int g = ((gbColor>>5) & 31) << 3; + int b = ((gbColor>>10) & 31) << 3; + palettes[pal*4 + entry] = gkRGB(r,g,b); + } + + for(i=0; i bestRating){ + bestIndex = i; + bestRating = rating; + } + } + + if(bestRating>0){ + //add new colors to that palette + for(i=0; i + +gkTransparencyTable gkWinShape::tranTable; + +struct BMP_header{ + gkLONG fSize; //54 byte header + 4*numColors (1-8bit) + (w*h*bpp)/8 + gkWORD zero1, zero2; //0,0 + gkLONG offsetBytes; //should be header (54) plus Palette Size + + gkLONG headerSize; //size of remaining header (40) + gkLONG width, height; //w,h in pixels + gkWORD planes, bpp; //plane=1, bpp=1,2,4, or most commonly 8 + gkLONG compression, imageSize; //compression to zero, size is w*h(8bit) + gkLONG xpels, ypels, zero3, zero4; //set to 0,0,0,0 +}; + +int gkIO::ReadWord(istream &in){ + int retval = in.get() << 8; + return retval | (in.get() & 0xff); +} + +int gkIO::ReadLong(istream &in){ + int retval = ReadWord(in) << 16; + return retval | (ReadWord(in) & 0xffff); +} + +char *gkIO::ReadString(istream &in){ + static char st[80]; + int len = ReadWord(in); + if(!len) return 0; + in.read(st,len); + st[len] = 0; + return st; +} + +char *gkIO::ReadNewString(istream &in){ + int len = ReadWord(in); + if(!len) return 0; + + char *st = new char[len+1]; + in.read(st,len); + st[len] = 0; + return st; +} + +void gkIO::WriteLong(ostream &out, int n){ + WriteWord(out, n>>16); + WriteWord(out, n); +} + +void gkIO::WriteWord(ostream &out, int n){ + out << (char) ((n>>8)&0xff); + out << (char) (n&0xff); +} + +void gkIO::WriteString(ostream &out, char *st){ + WriteWord(out,strlen(st)); + out.write(st,strlen(st)); +} + + +int gkRGB::operator==(gkRGB &c2){ + return ((color.argb & 0xffffff) == (c2.color.argb & 0xffffff)); +} + +int gkRGB::Equals(int _r, int _g, int _b){ + return _r==color.bytes.r && _g==color.bytes.g && _b==color.bytes.b; +} + +void gkRGB::Combine(gkRGB c2, int alpha){ + //mix alpha + color.bytes.r += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetR()-GetR(), alpha); + color.bytes.g += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetG()-GetG(), alpha); + color.bytes.b += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetB()-GetB(), alpha); +} + +gkRGB::operator COLORREF(){ + return (color.bytes.b<<16) | (color.bytes.g<<8) | (color.bytes.r); +} + +gkPalGenItem::gkPalGenItem(gkRGB _color){ + color = _color; + occurrences = 1; + nextItem = 0; +} + +gkPalGenItem::~gkPalGenItem(){ +} + +gkRGB gkPalGenItem::GetColor(){ + return color; +} + +void gkPalGenItem::AddOccurrence(){ + occurrences++; +} + +int gkPalGenItem::GetOccurrences(){ + return occurrences; +} + +void gkPalGenItem::SetOccurrences(int n){ + occurrences = n; +} + +void gkPalGenItem::SetNextItem(gkPalGenItem *item){ + nextItem = item; +} + +gkPalGenItem *gkPalGenItem::GetNextItem(){ + return nextItem; +} + +int gkPalGenItem::GetCount(){ + gkPalGenItem *cur; + int count = 0; + for(cur=this; cur; cur=cur->nextItem){ + if(cur->occurrences) count++; + } + return count; +} + +int gkPalGenItem::SortCallback(const void *e1, const void *e2){ + gkPalGenItem *i1 = *((gkPalGenItem**) e1); + gkPalGenItem *i2 = *((gkPalGenItem**) e2); + if(i1->occurrences > i2->occurrences) return -1; + if(i1->occurrences == i2->occurrences) return 0; + return 1; +} + +gkPaletteGenerator::gkPaletteGenerator(){ + int i; + for(i=0; i<52; i++){ + colorCube[i] = 0; + } +} + +gkPaletteGenerator::~gkPaletteGenerator(){ + Reset(); +} + +void gkPaletteGenerator::Reset(){ + int i; + for(i=0; i<52; i++){ + if(colorCube[i]){ + gkPalGenItem *cur, *next; + for(cur=colorCube[i]; cur; cur=next){ + next = cur->GetNextItem(); + delete cur; + } + colorCube[i] = 0; + } + } +} + +void gkPaletteGenerator::AddColor(gkRGB color){ + int i = GetHash(color); + + if(!colorCube[i]){ + colorCube[i] = new gkPalGenItem(color); + }else{ + gkPalGenItem *cur, *prev; + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + if((cur->GetColor()) == color){ + cur->AddOccurrence(); //Color already in list + break; + } + prev = cur; + } + if(!cur){ //color not in list + prev->SetNextItem(new gkPalGenItem(color)); + } + } +} + +void gkPaletteGenerator::CreatePalette(gkRGB *palette, int numEntries){ + if(numEntries<=0) return; + + //Set all entries to black + int i; + for(i=0; iGetCount(); + } + while(!count){ //if no colors yet expand area of inclusion + if(first==0 && last==51) return; //no colors anywhere! + if(first>0){ + first--; + if(colorCube[first]) count += colorCube[first]->GetCount(); + } + if(last<51){ + last++; + if(colorCube[last]) count += colorCube[last]->GetCount(); + } + } + + //Create an array to hold all the colors for sorting purposes + gkPalGenItem **colors = new gkPalGenItem*[count]; + gkPalGenItem *cur; + i = 0; + int j; + for(j=first; j<=last; j++){ + if(colorCube[j]){ + for(cur=colorCube[j]; cur; cur=cur->GetNextItem()){ + if(cur->GetOccurrences()) colors[i++] = cur; + } + } + } + + //figure out how many colors will come from this section of the cube + int numToGrab = 1; + int tempCurEntry = curEntry; + while(nextEntry==first && tempCurEntry<52){ + tempCurEntry++; + nextEntry = (int) (scaleFactor * (tempCurEntry+1)); + numToGrab++; + } + + if(numToGrab > count) numToGrab = count; + + //sort colors into descending order and pick "num" most frequent + qsort(colors, count, sizeof(gkPalGenItem*), gkPalGenItem::SortCallback); + + for(i=0; iGetColor(); + colors[i]->SetOccurrences(0); + } + + //delete sorting table + delete colors; + } +} + + +int gkPaletteGenerator::GetNumColors(){ + int num = 0, i; + for(i=0; i<52; i++) + if(colorCube[i]) num += colorCube[i]->GetCount(); + return num; +} + + +int gkPaletteGenerator::GetHash(gkRGB color){ + int r = color.GetR() >> 6; //rough categories 0-3 + int g = color.GetG() >> 6; + int b = color.GetB() >> 6; + int highest = r; + if(g > highest) highest = g; + if(b > highest) highest = b; + + int hash; + + // r > (g < b) + // r > (g = b) + // r > (g > b) + // g > (r < b) + // g > (r = b) + // g > (r > b) + // b > (r < g) + // b > (r = g) + // b > (r > g) + // (r = b) > g + // (r = g) > b + // (g = b) > r + // (r = g) = b + if(r > g && r > b){ //red high + if(g < b) hash = 0; // r > (g < b) + else if(g==b) hash = 1; // r > (g = b) + else hash = 2; // r > (g > b) + }else if(g > r && g > b){ //green high + if(r < b) hash = 3; // g > (r < b) + else if(r==b) hash = 4; // g > (r = b) + else hash = 5; // g > (r > b) + }else if(b > r && b > g){ //blue high + if(r < g) hash = 6; // b > (r < g) + else if(r==g) hash = 7; // b > (r = g) + else hash = 8; // b > (r > g) + }else if(r==b && b==g){ //r = g = b + hash = 9; + }else if(r==b){ //(r = b) > g + hash = 10; + }else if(r==g){ //(r = g) > b + hash = 11; + }else{ //(g = b) > r + hash = 12; + } + + //make room in each category for four levels of intensity (0-3) + hash = hash*4 + highest; + + return hash; +} + +int gkPaletteGenerator::ColorExists(gkRGB color){ + int hash = GetHash(color); + if(!colorCube[hash]) return 0; + + gkPalGenItem *cur; + for(cur=colorCube[hash]; cur; cur=cur->GetNextItem()){ + if(cur->GetColor()==color) return 1; //found exact color + } + return 0; +} + +gkRGB gkPaletteGenerator::MatchColor(gkRGB color){ + int hash = GetHash(color); + int r = color.GetR(); + int g = color.GetG(); + int b = color.GetB(); + if(colorCube[hash]){ //near colors; search just this section + gkPalGenItem *cur, *bestMatch; + int bestDiff; + bestMatch = colorCube[hash]; + int r2, g2, b2; + r2 = abs(r - bestMatch->GetColor().GetR()); + g2 = abs(g - bestMatch->GetColor().GetG()); + b2 = abs(b - bestMatch->GetColor().GetB()); + bestDiff = r2 + g2 + b2; + for(cur=bestMatch->GetNextItem(); cur; cur=cur->GetNextItem()){ + r2 = abs(r - cur->GetColor().GetR()); + g2 = abs(g - cur->GetColor().GetG()); + b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + return bestMatch->GetColor(); + }else{ + //no colors nearby; expand search + //Get it from ~greyscale if possible + int first, last; + first = last = 36 + (hash % 4); + if(!colorCube[first]){ + first = 0; //nothing there either; search everything + last = 51; + /* + first = 36; + last = 39; + //first = hash - (hash%4); //different intensities, same color + //last = first + 3; + if(!colorCube[first] && !colorCube[first+1] && !colorCube[first+2] + && !colorCube[last]){ + first = 0; //nothing there either; search everything + last = 51; + } + */ + } + gkPalGenItem *cur, *bestMatch; + int bestDiff = 0x7fffffff; + bestMatch = 0; + int i; + for(i=first; i<=last; i++){ + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + int r2 = abs(r - cur->GetColor().GetR()); + int g2 = abs(g - cur->GetColor().GetG()); + int b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + } + if(!bestMatch) return gkRGB(0,0,0); + return bestMatch->GetColor(); + } +} + +gkTransparencyTable::gkTransparencyTable(){ + lookup = new gkBYTE[256*256]; + + int baseOffset, alpha, i; + i = 0; + for(baseOffset=0; baseOffset<256; baseOffset++){ + for(alpha=0; alpha<256; alpha++){ + lookup[i++] = (baseOffset * alpha) / 255; + } + } +} + +gkTransparencyTable::~gkTransparencyTable(){ + if(lookup) delete lookup; + lookup = 0; +} + +int gkTransparencyTable::LookupTransparencyOffset(int baseOffset, int alpha){ + return (baseOffset>=0) ? lookup[(baseOffset<<8)+alpha] + : (-lookup[((-baseOffset)<<8)+alpha]); +} + + +gkWinShape::gkWinShape(){ + data = 0; + width = height = bpp = 0; +} + +gkWinShape::~gkWinShape(){ + FreeData(); +} + +void gkWinShape::FreeData(){ + if(data){ + delete data; + data = 0; + } +} + +void gkWinShape::Create(int _width, int _height){ + if(_width <= 0 || _height <= 0) return; + + FreeData(); + width = _width; + height = _height; + + //round up width to ensure multiple of 4 pixels + //width = (width + 3) & (~3); + + data = new gkBYTE[(width*height)<<2]; + bpp = 32; +} + +void gkWinShape::Cls(){ + if(!this->data) return; + memset(this->data, 0, (this->width * this->height)<<2); +} + +void gkWinShape::Cls(gkRGB color){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = color.GetARGB(); + } +} + +void gkWinShape::Plot(int x, int y, gkRGB color, int testBoundaries){ + if(!data) return; + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return; + } + + gkRGB *dest = (gkRGB*) (data + ((y*width + x) << 2)); + *dest = color; +} + +gkRGB gkWinShape::Point(int x, int y, int testBoundaries){ + if(!data) return gkRGB(0,0,0); + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return gkRGB(0,0,0); + } + + gkRGB *color = (gkRGB*) (data + ((y*width + x) << 2)); + return *color; +} + +void gkWinShape::Line(int x1, int y1, int x2, int y2, gkRGB color){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + *(dest++) = color; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + *dest = color; + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkWinShape::LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, + int alpha){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + dest->Combine(color,alpha); + dest++; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + dest->Combine(color,alpha); + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkWinShape::RectFrame(int x, int y, int w, int h, gkRGB color){ + int x2 = x + w - 1; + int y2 = y + h - 1; + RectFill(x,y,w,1,color); + RectFill(x,y2,w,1,color); + RectFill(x,y,1,h,color); + RectFill(x2,y,1,h,color); +} + +void gkWinShape::RectFill(int x, int y, int w, int h, gkRGB color){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; iCombine(color,alpha); + dest++; + } + destStart += width; + } +} + +void gkWinShape::RectFillChannel(int x, int y, int w, int h, + gkRGB color, int mask){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkLONG *destStart = (gkLONG*) (data + (((y * width) + x) <<2)); + gkLONG *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + gkLONG srcColor = color.GetARGB() & mask; + gkLONG destMask = ~mask; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; iSetA(alpha); + } +} + +void gkWinShape::SetColorAlpha(gkRGB color, int alpha){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } + src++; + } + } +} + +int gkWinShape::GetShape(gkWinShape *srcShape, int x, int y, int w, int h){ + if(!srcShape || !srcShape->data) return 0; + + //adjust src rectangle until it fits within source data + if(x<0){ + w += x; + x = 0; + } + if(y<0){ + h += y; + y = 0; + } + if(x + w > srcShape->width){ + w = srcShape->width - x; + } + if(y + h > srcShape->height){ + h = srcShape->height - y; + } + + if(w<=0 || h<=0) return 0; + + FreeData(); + Create(w, h); + + gkBYTE *src = srcShape->data + ((y*srcShape->width + x)<<2); + gkBYTE *dest = this->data; + int srcSkip = srcShape->width << 2; //4 bytes per pixel + w <<= 2; //4 bytes per pixel + + while(h--){ + memcpy(dest, src, w); + dest += w; + src += srcSkip; + } + + return 1; +} + +int gkWinShape::GetShape(gkWinShape *srcShape){ + if(this->width != srcShape->width || this->height != srcShape->height + || (!this->data) || (!srcShape->data)){ + //mem needs to be reallocated + FreeData(); + memcpy(this, srcShape, sizeof(gkWinShape)); + data = 0; + if(srcShape->data){ + data = new gkBYTE[(width * height) << 2]; + memcpy(data, srcShape->data, (width * height) << 2 ); + } + }else{ + //already got right size mem, just copy data over + memcpy(data, srcShape->data, (width * height) << 2); + fontSpacing = srcShape->fontSpacing; + fontKerning = srcShape->fontKerning; + x_handle = srcShape->x_handle; + y_handle = srcShape->y_handle; + } + return data!=0; +} + +int gkWinShape::SaveShape(char *filename){ + ofstream outfile(filename, ios::out | ios::binary); + if(!outfile) return 0; + + int result = SaveShape(outfile); + outfile.close(); + + return result; +} + +int gkWinShape::SaveShape(ostream &out){ + int totalSize = ((width * height) << 2); + + out << "SHPE"; + int skipSize = totalSize + 20; + gkIO::WriteLong(out, skipSize); + + //Write shape header + gkIO::WriteWord(out, 3); //type 3 + gkIO::WriteWord(out, width); + gkIO::WriteWord(out, height); + gkIO::WriteWord(out, (bpp==8)?8:32); + out << (char) fontSpacing << (char) fontKerning; + gkIO::WriteWord(out, x_handle); + gkIO::WriteWord(out, y_handle); + gkIO::WriteWord(out, 0); //6 bytes of reserved space + gkIO::WriteLong(out, 0); + + + //Write data + if(data){ + int pitch = width << 2; + gkLONG *src; + gkBYTE *srcStart = data; + + int i,j; + for(j=0; jLoadShape(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadShape(istream &infile){ + FreeData(); + if(infile.get() != 'S') return 0; + if(infile.get() != 'H') return 0; + if(infile.get() != 'P') return 0; + if(infile.get() != 'E') return 0; + + gkIO::ReadLong(infile); //discard skipsize + + //Read shape header + if(gkIO::ReadWord(infile) != 2) return 0; + width = gkIO::ReadWord(infile); + height = gkIO::ReadWord(infile); + int filebpp = gkIO::ReadWord(infile); + if(!bpp) bpp = filebpp; + + if(width && height){ + Create(width,height); + } + + fontSpacing = infile.get(); + fontKerning = infile.get(); + x_handle = gkIO::ReadWord(infile); + y_handle = gkIO::ReadWord(infile); + + gkIO::ReadWord(infile); + gkIO::ReadLong(infile); //discard reserved space + + if(!width || !height) return 1; //nothing to load, null shape + + int pitch = width << 2; + gkBYTE *destStart = data; + gkLONG *dest; + int x,y; + for(y=0; yLoadBMP(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadBMP(istream &infile){ + BMP_header header; + if(gkIO::ReadWord(infile)!=0x424d){ //check for "BM" + return 0; + } + infile.read((char*)&header, sizeof(BMP_header)); + if(header.bpp != 24){ + cout << "LoadBMP can only handle 24-bit files" << endl; + return 0; + } + + FreeData(); + width = header.width; + height = header.height; + bpp = (char) header.bpp; + Create(width,height); + + // load graphics, coverting every three (B,R,G) bytes to one ARGB value. + // lines padded to even multiple of 4 bytes + int srcPitch = ((header.width * 3) + 3) & (~3); + gkBYTE *buffer = new gkBYTE[srcPitch * height]; + gkBYTE *nextBuffPtr = buffer + ((height-1) * srcPitch); + gkBYTE *buffPtr; + + infile.read(buffer, srcPitch * height); + + gkBYTE *nextDest = data; + gkRGB *dest; + int destPitch = (width << 2); + + int i, j; + j = height; + while(j--){ + buffPtr = nextBuffPtr; + nextBuffPtr -= srcPitch; + dest = (gkRGB*) nextDest; + nextDest += destPitch; + i = header.width; + while(i--){ + dest->SetB(*(buffPtr++)); + dest->SetG(*(buffPtr++)); + dest->SetR(*(buffPtr++)); + dest->SetA(0xff); + dest++; + } + for(i=header.width; iSetARGB(0); + dest++; + } + } + + delete buffer; + + return 1; +} + + +void gkWinShape::Blit(gkWinShape *destShape, int x, int y, int flags){ + if(!data || !destShape || !destShape->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } +} + +////////////////////////////////////////////////////////////////////// +// Function: BlitScale +// Arguments: destShape +// x +// y +// flags +// scale - number of source pixels for every one +// dest pixel, stored in 24:8 fixed point. +// $100=100%, $200=200% (mag x2), $80=50% +////////////////////////////////////////////////////////////////////// +void gkWinShape::BlitScale(gkWinShape *destShape, int x, int y, + int scale, int flags){ + if(!data || !destShape || !destShape->data || !scale) return; + + gkBYTE *src = 0; + int srcSkip = this->width; + int srcWidth = (this->width * scale) >> 8; + int lines = (this->height * scale) >> 8; + + //clip left side + if(x < 0){ + src += (-x << 8) / scale; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += ((-y * this->width) << 8) / scale; + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int ratio = (int) ((1.0f / (((float) scale) / 256.0f)) * 256.0f); + + int lineError = 0; + while(lines--){ + BlitLineScale(dest, src, srcWidth, ratio); + lineError += ratio; + src += srcSkip * (lineError >> 8); + lineError &= 0xff; + dest += destSkip; + } + + /* + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } + */ +} + +void gkWinShape::BlitScale(gkWinShape *destShape, int x, int y, + float scale, int flags){ + BlitScale(destShape,x,y,flags,(int) (256.0f * scale)); +} + +void gkWinShape::BlitChannel(gkWinShape *destShape, int x, int y, int mask){ + if(!data || !destShape || !destShape->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int inverseMask = ~mask; + + while(lines--){ + gkLONG *curSrc = (gkLONG*) src; + gkLONG *curDest = (gkLONG*) dest; + int pixels = srcWidth; + while(pixels--){ + *curDest = (*curSrc & mask) | (*curDest & inverseMask); + curSrc++; + curDest++; + } + src += srcSkip; + dest += destSkip; + } +} + +HBITMAP gkWinShape::GetDIB(CDC *pDC){ + //note you must DeleteObject() on the dib that's returned once done + static BITMAPINFO bmInfo={{40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}}; + static int setup=0; + + if(!setup){ + setup = 1; + *((int*)(&bmInfo.bmiColors[0])) = 0xff0000; //red mask + *((int*)(&bmInfo.bmiColors[4])) = 0x00ff00; //green mask + *((int*)(&bmInfo.bmiColors[8])) = 0x0000ff; //blue mask + } + + bmInfo.bmiHeader.biWidth = width; + bmInfo.bmiHeader.biHeight = -height; + + HBITMAP dib = CreateDIBitmap((HDC) (*pDC), + &bmInfo.bmiHeader, + CBM_INIT, + data, + &bmInfo, + DIB_RGB_COLORS); + + return dib; +} + +void gkWinShape::BlitToDC(CDC *pDC, int x, int y){ + static CDC srcDC; + static int setup=0; + + if(!setup){ + setup = 1; + srcDC.CreateCompatibleDC(0); + } + + HBITMAP dib = GetDIB(pDC); + + CBitmap bitmap; + bitmap.Attach(dib); + + CBitmap *oldBitmap = srcDC.SelectObject(&bitmap); + pDC->BitBlt(x, y, width, height, &srcDC, 0, 0, SRCCOPY); + srcDC.SelectObject(oldBitmap); + + bitmap.Detach(); + DeleteObject(dib); +} + +void gkWinShape::MemCpyTrans(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + int c1; + while(numColors--){ + int alpha; + switch(alpha = (srcColor->GetA())){ + case 0: break; + case 255: //Straight copy + *destColor = *srcColor; + break; + default: //mix alpha + c1 = destColor->GetR(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetR()-c1, alpha); + destColor->SetR(c1); + c1 = destColor->GetG(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetG()-c1, alpha); + destColor->SetG(c1); + c1 = destColor->GetB(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetB()-c1, alpha); + destColor->SetB(c1); + break; + } + srcColor++; + destColor++; + } +} + +void gkWinShape::BlitLineScale(gkBYTE *dest,gkBYTE *src,int pixels,int ratio){ + gkRGB *srcRGB = (gkRGB*) src; + gkRGB *destRGB = (gkRGB*) dest; + + int error = 0; + + while(pixels--){ + *(destRGB++) = *srcRGB; + error += ratio; + srcRGB += error >> 8; + error &= 0xff; + } +} + diff --git a/Tools/GBConv2/Source/wingk.cpp b/Tools/GBConv2/Source/wingk.cpp new file mode 100644 index 0000000..93c4237 --- /dev/null +++ b/Tools/GBConv2/Source/wingk.cpp @@ -0,0 +1,1546 @@ +#include "stdafx.h" +#include "wingk.h" +#include + +gkTransparencyTable gkWinShape::tranTable; + +struct BMP_header{ + gkLONG fSize; //54 byte header + 4*numColors (1-8bit) + (w*h*bpp)/8 + gkWORD zero1, zero2; //0,0 + gkLONG offsetBytes; //should be header (54) plus Palette Size + + gkLONG headerSize; //size of remaining header (40) + gkLONG width, height; //w,h in pixels + gkWORD planes, bpp; //plane=1, bpp=1,2,4, or most commonly 8 + gkLONG compression, imageSize; //compression to zero, size is w*h(8bit) + gkLONG xpels, ypels, zero3, zero4; //set to 0,0,0,0 +}; + +int gkIO::ReadWord(istream &in){ + int retval = in.get() << 8; + return retval | (in.get() & 0xff); +} + +int gkIO::ReadLong(istream &in){ + int retval = ReadWord(in) << 16; + return retval | (ReadWord(in) & 0xffff); +} + +char *gkIO::ReadString(istream &in){ + static char st[80]; + int len = ReadWord(in); + if(!len) return 0; + in.read(st,len); + st[len] = 0; + return st; +} + +char *gkIO::ReadNewString(istream &in){ + int len = ReadWord(in); + if(!len) return 0; + + char *st = new char[len+1]; + in.read(st,len); + st[len] = 0; + return st; +} + +void gkIO::WriteLong(ostream &out, int n){ + WriteWord(out, n>>16); + WriteWord(out, n); +} + +void gkIO::WriteWord(ostream &out, int n){ + out << (char) ((n>>8)&0xff); + out << (char) (n&0xff); +} + +void gkIO::WriteString(ostream &out, char *st){ + WriteWord(out,strlen(st)); + out.write(st,strlen(st)); +} + +int gkRGB::Equals(int _r, int _g, int _b){ + return _r==color.bytes.r && _g==color.bytes.g && _b==color.bytes.b; +} + +void gkRGB::Combine(gkRGB c2, int alpha){ + //mix alpha + color.bytes.r += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetR()-GetR(), alpha); + color.bytes.g += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetG()-GetG(), alpha); + color.bytes.b += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetB()-GetB(), alpha); +} + +gkRGB::operator COLORREF(){ + return (color.bytes.b<<16) | (color.bytes.g<<8) | (color.bytes.r); +} + +gkPalGenItem::gkPalGenItem(gkRGB _color){ + color = _color; + occurrences = 1; + nextItem = 0; +} + +gkPalGenItem::~gkPalGenItem(){ +} + +gkRGB gkPalGenItem::GetColor(){ + return color; +} + +void gkPalGenItem::AddOccurrence(){ + occurrences++; +} + +int gkPalGenItem::GetOccurrences(){ + return occurrences; +} + +void gkPalGenItem::SetOccurrences(int n){ + occurrences = n; +} + +void gkPalGenItem::SetNextItem(gkPalGenItem *item){ + nextItem = item; +} + +gkPalGenItem *gkPalGenItem::GetNextItem(){ + return nextItem; +} + +int gkPalGenItem::GetCount(){ + gkPalGenItem *cur; + int count = 0; + for(cur=this; cur; cur=cur->nextItem){ + if(cur->occurrences) count++; + } + return count; +} + +int gkPalGenItem::SortCallback(const void *e1, const void *e2){ + gkPalGenItem *i1 = *((gkPalGenItem**) e1); + gkPalGenItem *i2 = *((gkPalGenItem**) e2); + if(i1->occurrences > i2->occurrences) return -1; + if(i1->occurrences == i2->occurrences) return 0; + return 1; +} + +gkPaletteGenerator::gkPaletteGenerator(){ + int i; + for(i=0; i<52; i++){ + colorCube[i] = 0; + } +} + +gkPaletteGenerator::~gkPaletteGenerator(){ + Reset(); +} + +void gkPaletteGenerator::Reset(){ + int i; + for(i=0; i<52; i++){ + if(colorCube[i]){ + gkPalGenItem *cur, *next; + for(cur=colorCube[i]; cur; cur=next){ + next = cur->GetNextItem(); + delete cur; + } + colorCube[i] = 0; + } + } +} + +void gkPaletteGenerator::AddColor(gkRGB color){ + int i = GetHash(color); + + if(!colorCube[i]){ + colorCube[i] = new gkPalGenItem(color); + }else{ + gkPalGenItem *cur, *prev; + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + if((cur->GetColor()) == color){ + cur->AddOccurrence(); //Color already in list + break; + } + prev = cur; + } + if(!cur){ //color not in list + prev->SetNextItem(new gkPalGenItem(color)); + } + } +} + +void gkPaletteGenerator::CreatePalette(gkRGB *palette, int numEntries){ + if(numEntries<=0) return; + + //Set all entries to black + int i; + for(i=0; iGetCount(); + } + while(!count){ //if no colors yet expand area of inclusion + if(first==0 && last==51) return; //no colors anywhere! + if(first>0){ + first--; + if(colorCube[first]) count += colorCube[first]->GetCount(); + } + if(last<51){ + last++; + if(colorCube[last]) count += colorCube[last]->GetCount(); + } + } + + //Create an array to hold all the colors for sorting purposes + gkPalGenItem **colors = new gkPalGenItem*[count]; + gkPalGenItem *cur; + i = 0; + int j; + for(j=first; j<=last; j++){ + if(colorCube[j]){ + for(cur=colorCube[j]; cur; cur=cur->GetNextItem()){ + if(cur->GetOccurrences()) colors[i++] = cur; + } + } + } + + //figure out how many colors will come from this section of the cube + int numToGrab = 1; + int tempCurEntry = curEntry; + while(nextEntry==first && tempCurEntry<(52-1)){ + tempCurEntry++; + nextEntry = (int) (scaleFactor * (tempCurEntry+1)); + numToGrab++; + } + + if(numToGrab > count) numToGrab = count; + + //sort colors into descending order and pick "num" most frequent + qsort(colors, count, sizeof(gkPalGenItem*), gkPalGenItem::SortCallback); + + for(i=0; iGetColor(); + colors[i]->SetOccurrences(0); + } + + //delete sorting table + delete colors; + } +} + + +int gkPaletteGenerator::GetNumColors(){ + int num = 0, i; + for(i=0; i<52; i++) + if(colorCube[i]) num += colorCube[i]->GetCount(); + return num; +} + + +int gkPaletteGenerator::GetHash(gkRGB color){ + int r = color.GetR() >> 6; //rough categories 0-3 + int g = color.GetG() >> 6; + int b = color.GetB() >> 6; + int highest = r; + if(g > highest) highest = g; + if(b > highest) highest = b; + + int hash; + + // r > (g < b) + // r > (g = b) + // r > (g > b) + // g > (r < b) + // g > (r = b) + // g > (r > b) + // b > (r < g) + // b > (r = g) + // b > (r > g) + // (r = b) > g + // (r = g) > b + // (g = b) > r + // (r = g) = b + if(r > g && r > b){ //red high + if(g < b) hash = 0; // r > (g < b) + else if(g==b) hash = 1; // r > (g = b) + else hash = 2; // r > (g > b) + }else if(g > r && g > b){ //green high + if(r < b) hash = 3; // g > (r < b) + else if(r==b) hash = 4; // g > (r = b) + else hash = 5; // g > (r > b) + }else if(b > r && b > g){ //blue high + if(r < g) hash = 6; // b > (r < g) + else if(r==g) hash = 7; // b > (r = g) + else hash = 8; // b > (r > g) + }else if(r==b && b==g){ //r = g = b + hash = 9; + }else if(r==b){ //(r = b) > g + hash = 10; + }else if(r==g){ //(r = g) > b + hash = 11; + }else{ //(g = b) > r + hash = 12; + } + + //make room in each category for four levels of intensity (0-3) + hash = hash*4 + highest; + + return hash; +} + +int gkPaletteGenerator::ColorExists(gkRGB color){ + int hash = GetHash(color); + if(!colorCube[hash]) return 0; + + gkPalGenItem *cur; + for(cur=colorCube[hash]; cur; cur=cur->GetNextItem()){ + if(cur->GetColor()==color) return 1; //found exact color + } + return 0; +} + +gkRGB gkPaletteGenerator::MatchColor(gkRGB color){ + int hash = GetHash(color); + int r = color.GetR(); + int g = color.GetG(); + int b = color.GetB(); + if(colorCube[hash]){ //near colors; search just this section + gkPalGenItem *cur, *bestMatch; + int bestDiff; + bestMatch = colorCube[hash]; + int r2, g2, b2; + r2 = abs(r - bestMatch->GetColor().GetR()); + g2 = abs(g - bestMatch->GetColor().GetG()); + b2 = abs(b - bestMatch->GetColor().GetB()); + bestDiff = r2 + g2 + b2; + for(cur=bestMatch->GetNextItem(); cur; cur=cur->GetNextItem()){ + r2 = abs(r - cur->GetColor().GetR()); + g2 = abs(g - cur->GetColor().GetG()); + b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + return bestMatch->GetColor(); + }else{ + //no colors nearby; expand search + //Get it from ~greyscale if possible + int first, last; + first = last = 36 + (hash % 4); + if(!colorCube[first]){ + first = 0; //nothing there either; search everything + last = 51; + /* + first = 36; + last = 39; + //first = hash - (hash%4); //different intensities, same color + //last = first + 3; + if(!colorCube[first] && !colorCube[first+1] && !colorCube[first+2] + && !colorCube[last]){ + first = 0; //nothing there either; search everything + last = 51; + } + */ + } + gkPalGenItem *cur, *bestMatch; + int bestDiff = 0x7fffffff; + bestMatch = 0; + int i; + for(i=first; i<=last; i++){ + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + int r2 = abs(r - cur->GetColor().GetR()); + int g2 = abs(g - cur->GetColor().GetG()); + int b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + } + if(!bestMatch) return gkRGB(0,0,0); + return bestMatch->GetColor(); + } +} + +gkTransparencyTable::gkTransparencyTable(){ + lookup = new gkBYTE[256*256]; + + int baseOffset, alpha, i; + i = 0; + for(baseOffset=0; baseOffset<256; baseOffset++){ + for(alpha=0; alpha<256; alpha++){ + lookup[i++] = (baseOffset * alpha) / 255; + } + } +} + +gkTransparencyTable::~gkTransparencyTable(){ + if(lookup) delete lookup; + lookup = 0; +} + +int gkTransparencyTable::LookupTransparencyOffset(int baseOffset, int alpha){ + return (baseOffset>=0) ? lookup[(baseOffset<<8)+alpha] + : (-lookup[((-baseOffset)<<8)+alpha]); +} + + +gkWinShape::gkWinShape(){ + data = 0; + width = height = bpp = 0; +} + +gkWinShape::~gkWinShape(){ + FreeData(); +} + +void gkWinShape::FreeData(){ + if(data){ + delete data; + data = 0; + } + width = height = 0; +} + +void gkWinShape::Create(int _width, int _height){ + if(_width <= 0 || _height <= 0) return; + + FreeData(); + width = _width; + height = _height; + + //round up width to ensure multiple of 4 pixels + width = (width + 3) & (~3); + + data = new gkBYTE[(width*height)<<2]; + bpp = 32; +} + +void gkWinShape::Cls(){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = 0xff000000; + } +} + +void gkWinShape::Cls(gkRGB color){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = color.GetARGB(); + } +} + +void gkWinShape::Plot(int x, int y, gkRGB color, int testBoundaries){ + if(!data) return; + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return; + } + + gkRGB *dest = (gkRGB*) (data + ((y*width + x) << 2)); + *dest = color; +} + +gkRGB gkWinShape::Point(int x, int y, int testBoundaries){ + if(!data) return gkRGB(0,0,0); + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return gkRGB(0,0,0); + } + + gkRGB *color = (gkRGB*) (data + ((y*width + x) << 2)); + return *color; +} + +void gkWinShape::Line(int x1, int y1, int x2, int y2, gkRGB color){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + *(dest++) = color; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + *dest = color; + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkWinShape::LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, + int alpha){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + dest->Combine(color,alpha); + dest++; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + dest->Combine(color,alpha); + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkWinShape::RectFrame(int x, int y, int w, int h, gkRGB color){ + int x2 = x + w - 1; + int y2 = y + h - 1; + RectFill(x,y,w,1,color); + RectFill(x,y2,w,1,color); + RectFill(x,y,1,h,color); + RectFill(x2,y,1,h,color); +} + +void gkWinShape::RectFill(int x, int y, int w, int h, gkRGB color){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; iCombine(color,alpha); + dest++; + } + destStart += width; + } +} + +void gkWinShape::RectFillChannel(int x, int y, int w, int h, + gkRGB color, int mask){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkLONG *destStart = (gkLONG*) (data + (((y * width) + x) <<2)); + gkLONG *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + gkLONG srcColor = color.GetARGB() & mask; + gkLONG destMask = ~mask; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i=width || cur.y>=height) continue; + + //filling correct color check + if(!(*(cur.pos)==fillColor)) continue; + + //fill color & add adjacent + *(cur.pos) = color; + + queue[qTail++] = gkFillItem(cur.x+1,cur.y,cur.pos+1); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x-1,cur.y,cur.pos-1); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x,cur.y+1,cur.pos+width); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x,cur.y-1,cur.pos-width); + qTail &= 16383; + } +} + +int gkWinShape::GetNumColors(){ + gkPaletteGenerator palGen; + int i = width * height; + gkRGB *src = (gkRGB*) data; + while(i--){ + palGen.AddColor(*(src++)); + } + + return palGen.GetNumColors(); +} + +void gkWinShape::RemapColor(gkRGB oldColor, gkRGB newColor){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } +} + +void gkWinShape::SetColorAlpha(gkRGB color, int alpha){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } + src++; + } + } +} + +int gkWinShape::GetShape(gkWinShape *srcShape, int x, int y, int w, int h){ + if(!srcShape || !srcShape->data) return 0; + + //adjust src rectangle until it fits within source data + if(x<0){ + w += x; + x = 0; + } + if(y<0){ + h += y; + y = 0; + } + if(x + w > srcShape->width){ + w = srcShape->width - x; + } + if(y + h > srcShape->height){ + h = srcShape->height - y; + } + + if(w<=0 || h<=0) return 0; + + FreeData(); + Create(w, h); + + gkBYTE *src = srcShape->data + ((y*srcShape->width + x)<<2); + gkBYTE *dest = this->data; + int srcSkip = srcShape->width << 2; //4 bytes per pixel + w <<= 2; //4 bytes per pixel + + while(h--){ + memcpy(dest, src, w); + dest += w; + src += srcSkip; + } + + return 1; +} + +int gkWinShape::GetShape(gkWinShape *srcShape){ + if(this->width != srcShape->width || this->height != srcShape->height + || (!this->data) || (!srcShape->data)){ + //mem needs to be reallocated + FreeData(); + memcpy(this, srcShape, sizeof(gkWinShape)); + data = 0; + if(srcShape->data){ + data = new gkBYTE[(width * height) << 2]; + memcpy(data, srcShape->data, (width * height) << 2 ); + } + }else{ + //already got right size mem, just copy data over + memcpy(data, srcShape->data, (width * height) << 2); + fontSpacing = srcShape->fontSpacing; + fontKerning = srcShape->fontKerning; + x_handle = srcShape->x_handle; + y_handle = srcShape->y_handle; + } + return data!=0; +} + + +int gkWinShape::GetShape(HDC hdc){ + //get a handle to the bitmap currently in the HDC + HBITMAP bitmap = (HBITMAP) GetCurrentObject(hdc,OBJ_BITMAP); + + //get info about that bitmap + BITMAP bm; + GetObject(bitmap,sizeof(BITMAP),&bm); + + int width = bm.bmWidth; + int height = bm.bmHeight; + + static BITMAPINFO bmInfo={{40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}}; + static int setup=0; + + if(!setup){ + setup = 1; + *((int*)(&bmInfo.bmiColors[0])) = 0xff0000; //red mask + *((int*)(&bmInfo.bmiColors[4])) = 0x00ff00; //green mask + *((int*)(&bmInfo.bmiColors[8])) = 0x0000ff; //blue mask + } + + //specify height as negative to get a top-to-bottom bitmap + bmInfo.bmiHeader.biWidth = width; + bmInfo.bmiHeader.biHeight = -height; + + Create(width,height); + GetDIBits(hdc,bitmap,0,height,data,&bmInfo,DIB_RGB_COLORS); + return 1; +} + +int gkWinShape::GetShape(HBITMAP bitmap){ + //Create a DC compatible with the screen + HDC hdc = CreateDC("DISPLAY",0,0,0); + + //get info about that bitmap + BITMAP bm; + GetObject(bitmap,sizeof(BITMAP),&bm); + + int width = bm.bmWidth; + int height = bm.bmHeight; + + static BITMAPINFO bmInfo={{40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}}; + static int setup=0; + + if(!setup){ + setup = 1; + *((int*)(&bmInfo.bmiColors[0])) = 0xff0000; //red mask + *((int*)(&bmInfo.bmiColors[4])) = 0x00ff00; //green mask + *((int*)(&bmInfo.bmiColors[8])) = 0x0000ff; //blue mask + } + + //specify height as negative to get a top-to-bottom bitmap + bmInfo.bmiHeader.biWidth = width; + bmInfo.bmiHeader.biHeight = -height; + + Create(width,height); + GetDIBits(hdc,bitmap,0,height,data,&bmInfo,DIB_RGB_COLORS); + DeleteDC(hdc); + return 1; +} + + +int gkWinShape::SaveShape(char *filename){ + ofstream outfile(filename, ios::out | ios::binary); + if(!outfile) return 0; + + int result = SaveShape(outfile); + outfile.close(); + + return result; +} + +int gkWinShape::SaveShape(ostream &out){ + int totalSize = ((width * height) << 2); + + out << "SHPE"; + int skipSize = totalSize + 20; + gkIO::WriteLong(out, skipSize); + + //Write shape header + gkIO::WriteWord(out, 3); //type 3 + gkIO::WriteWord(out, width); + gkIO::WriteWord(out, height); + gkIO::WriteWord(out, (bpp==8)?8:32); + out << (char) fontSpacing << (char) fontKerning; + gkIO::WriteWord(out, x_handle); + gkIO::WriteWord(out, y_handle); + gkIO::WriteWord(out, 0); //6 bytes of reserved space + gkIO::WriteLong(out, 0); + + + //Write data + if(data){ + int pitch = width << 2; + gkLONG *src; + gkBYTE *srcStart = data; + + int i,j; + for(j=0; jLoadShape(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadShape(istream &infile){ + FreeData(); + if(infile.get() != 'S') return 0; + if(infile.get() != 'H') return 0; + if(infile.get() != 'P') return 0; + if(infile.get() != 'E') return 0; + + gkIO::ReadLong(infile); //discard skipsize + + //Read shape header + if(gkIO::ReadWord(infile) != 2) return 0; + width = gkIO::ReadWord(infile); + height = gkIO::ReadWord(infile); + int filebpp = gkIO::ReadWord(infile); + if(!bpp) bpp = filebpp; + + if(width && height){ + Create(width,height); + } + + fontSpacing = infile.get(); + fontKerning = infile.get(); + x_handle = gkIO::ReadWord(infile); + y_handle = gkIO::ReadWord(infile); + + gkIO::ReadWord(infile); + gkIO::ReadLong(infile); //discard reserved space + + if(!width || !height) return 1; //nothing to load, null shape + + int pitch = width << 2; + gkBYTE *destStart = data; + gkLONG *dest; + int x,y; + for(y=0; yLoadBMP(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadBMP(istream &infile){ + BMP_header header; + if(gkIO::ReadWord(infile)!=0x424d){ //check for "BM" + return 0; + } + infile.read((char*)&header, sizeof(BMP_header)); + if(header.bpp != 24){ + cout << "LoadBMP can only handle 24-bit files" << endl; + return 0; + } + + FreeData(); + width = header.width; + height = header.height; + bpp = (char) header.bpp; + Create(width,height); + + // load graphics, coverting every three (B,R,G) bytes to one ARGB value. + // lines padded to even multiple of 4 bytes + int srcPitch = ((header.width * 3) + 3) & (~3); + gkBYTE *buffer = new gkBYTE[srcPitch * height]; + gkBYTE *nextBuffPtr = buffer + ((height-1) * srcPitch); + gkBYTE *buffPtr; + + infile.read(buffer, srcPitch * height); + + gkBYTE *nextDest = data; + gkRGB *dest; + int destPitch = (width << 2); + + int i, j; + j = height; + while(j--){ + buffPtr = nextBuffPtr; + nextBuffPtr -= srcPitch; + dest = (gkRGB*) nextDest; + nextDest += destPitch; + i = header.width; + while(i--){ + dest->SetB(*(buffPtr++)); + dest->SetG(*(buffPtr++)); + dest->SetR(*(buffPtr++)); + dest->SetA(0xff); + dest++; + } + for(i=header.width; iSetARGB(0); + dest++; + } + } + + delete buffer; + + return 1; +} + + +void gkWinShape::Blit(gkWinShape *destShape, int x, int y, int flags){ + if(!data || !destShape || !destShape->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; //times 4 later + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); //times 4 later + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } +} + +////////////////////////////////////////////////////////////////////// +// Function: BlitScale +// Arguments: destShape +// x +// y +// flags +// scale - number of source pixels for every one +// dest pixel, stored in 24:8 fixed point. +// $100=100%, $200=200% (mag x2), $80=50% +////////////////////////////////////////////////////////////////////// +void gkWinShape::BlitScale(gkWinShape *destShape, int x, int y, + int scale, int flags){ + if(!data || !destShape || !destShape->data || !scale) return; + + gkBYTE *src = 0; + int srcSkip = this->width; + int srcWidth = (this->width * scale) >> 8; + int lines = (this->height * scale) >> 8; + + //clip left side + if(x < 0){ + src += (-x << 8) / scale; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += ((-y * this->width) << 8) / scale; + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int ratio = (int) ((1.0f / (((float) scale) / 256.0f)) * 256.0f); + + int lineError = 0; + while(lines--){ + BlitLineScale(dest, src, srcWidth, ratio); + lineError += ratio; + src += srcSkip * (lineError >> 8); + lineError &= 0xff; + dest += destSkip; + } + + /* + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } + */ +} + +void gkWinShape::BlitScale(gkWinShape *destShape, int x, int y, + float scale, int flags){ + BlitScale(destShape,x,y,flags,(int) (256.0f * scale)); +} + +void gkWinShape::BlitChannel(gkWinShape *destShape, int x, int y, int mask){ + if(!data || !destShape || !destShape->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = destShape->data + (((y * destShape->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int inverseMask = ~mask; + + while(lines--){ + gkLONG *curSrc = (gkLONG*) src; + gkLONG *curDest = (gkLONG*) dest; + int pixels = srcWidth; + while(pixels--){ + *curDest = (*curSrc & mask) | (*curDest & inverseMask); + curSrc++; + curDest++; + } + src += srcSkip; + dest += destSkip; + } +} + +HBITMAP gkWinShape::GetDIB(HDC hdc){ + //note you must DeleteObject() on the dib that's returned once done + static BITMAPINFO bmInfo={{40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}}; + static int setup=0; + + if(!setup){ + setup = 1; + *((int*)(&bmInfo.bmiColors[0])) = 0xff0000; //red mask + *((int*)(&bmInfo.bmiColors[4])) = 0x00ff00; //green mask + *((int*)(&bmInfo.bmiColors[8])) = 0x0000ff; //blue mask + } + + bmInfo.bmiHeader.biWidth = width; + bmInfo.bmiHeader.biHeight = -height; + + HBITMAP dib = CreateDIBitmap(hdc, + &bmInfo.bmiHeader, + CBM_INIT, + data, + &bmInfo, + DIB_RGB_COLORS); + + return dib; +} + + +void gkWinShape::BlitToHDC(HDC hDC, int x, int y){ + static HDC srcHDC; + static int setup=0; + + if(!setup){ + setup = 1; + srcHDC = CreateCompatibleDC(0); + } + + HBITMAP dib = GetDIB(hDC); + + HBITMAP oldBitmap = (HBITMAP) SelectObject(srcHDC,dib); + BitBlt(hDC, x, y, width, height, srcHDC, 0, 0, SRCCOPY); + SelectObject(srcHDC,oldBitmap); + + DeleteObject(dib); +} + +void gkWinShape::MemCpyTrans(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + int c1; + while(numColors--){ + int alpha; + switch(alpha = (srcColor->GetA())){ + case 0: break; + case 255: //Straight copy + *destColor = *srcColor; + break; + default: //mix alpha + c1 = destColor->GetR(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetR()-c1, alpha); + destColor->SetR(c1); + c1 = destColor->GetG(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetG()-c1, alpha); + destColor->SetG(c1); + c1 = destColor->GetB(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetB()-c1, alpha); + destColor->SetB(c1); + break; + } + srcColor++; + destColor++; + } +} + +void gkWinShape::BlitLineScale(gkBYTE *dest,gkBYTE *src,int pixels,int ratio){ + gkRGB *srcRGB = (gkRGB*) src; + gkRGB *destRGB = (gkRGB*) dest; + + int error = 0; + + while(pixels--){ + *(destRGB++) = *srcRGB; + error += ratio; + srcRGB += error >> 8; + error &= 0xff; + } +} + diff --git a/Tools/GBConv2/Source/wingk.h b/Tools/GBConv2/Source/wingk.h new file mode 100644 index 0000000..e2735c0 --- /dev/null +++ b/Tools/GBConv2/Source/wingk.h @@ -0,0 +1,187 @@ +#ifndef WINGK_H +#define WINGK_H + +#include "stdafx.h" + +#include +#include +#include +#include +#include + +typedef unsigned char gkBYTE; +typedef short int gkWORD; +typedef int gkLONG; + +#define GKHANDLE_TL 0 +#define GKHANDLE_TC 1 +#define GKHANDLE_TR 2 +#define GKHANDLE_CR 3 +#define GKHANDLE_BR 4 +#define GKHANDLE_BC 5 +#define GKHANDLE_BL 6 +#define GKHANDLE_CL 7 +#define GKHANDLE_CENTER 8 + +#define GKBLT_TRANSPARENT 1 + +class gkIO{ + public: + inline static int ReadByte(istream &in){ return in.get(); } + static int ReadWord(istream &in); + static int ReadLong(istream &in); + static char *ReadString(istream &in); + static char *ReadNewString(istream &in); + inline static void WriteByte(ostream &out, int n){ out << (char) n; } + static void WriteLong(ostream &out, int n); + static void WriteWord(ostream &out, int n); + static void WriteString(ostream &out, char *st); +}; + +struct gkRGB_4bytes{ + unsigned char b, g, r, a; +}; + +union gkRGB_ColorUnion{ + gkRGB_4bytes bytes; + gkLONG argb; +}; + +class gkRGB{ + public: + gkRGB_ColorUnion color; + + inline gkRGB(){ color.argb = 0xff000000; } + inline gkRGB(int _r, int _g, int _b, int _a=255){ + color.bytes.r=_r; color.bytes.g=_g; color.bytes.b=_b; color.bytes.a=_a;} + inline void SetR(gkBYTE n){ color.bytes.r = n; } + inline void SetG(gkBYTE n){ color.bytes.g = n; } + inline void SetB(gkBYTE n){ color.bytes.b = n; } + inline void SetA(gkBYTE n){ color.bytes.a = n; } + inline void SetARGB(gkLONG n){ color.argb = n; } + inline gkBYTE GetR(){ return color.bytes.r; } + inline gkBYTE GetG(){ return color.bytes.g; } + inline gkBYTE GetB(){ return color.bytes.b; } + inline gkBYTE GetA(){ return color.bytes.a; } + inline gkLONG GetARGB(){ return color.argb; } + inline int operator==(gkRGB &c2){ + return ((color.argb & 0xffffff) == (c2.color.argb & 0xffffff)); } + inline int Equals(int _r, int _g, int _b); + void Combine(gkRGB c2, int alpha); + operator COLORREF(); +}; + +class gkPalGenItem{ + protected: + gkRGB color; + int occurrences; + gkPalGenItem *nextItem; + + public: + gkPalGenItem(gkRGB _color); + ~gkPalGenItem(); + inline gkRGB GetColor(); + inline void AddOccurrence(); + inline int GetOccurrences(); + inline void SetOccurrences(int n); + inline void SetNextItem(gkPalGenItem *item); + inline gkPalGenItem *GetNextItem(); + int GetCount(); + static int SortCallback(const void *e1, const void *e2); +}; + +class gkPaletteGenerator{ + protected: + gkPalGenItem *colorCube[13*4]; + + public: + gkPaletteGenerator(); + ~gkPaletteGenerator(); + void Reset(); + void AddColor(gkRGB color); + int GetNumColors(); + void CreatePalette(gkRGB *palette, int numEntries); + int GetHash(gkRGB color); + int ColorExists(gkRGB color); + gkRGB MatchColor(gkRGB color); +}; + +class gkTransparencyTable{ + protected: + gkBYTE *lookup; + + public: + gkTransparencyTable(); + ~gkTransparencyTable(); + inline int LookupTransparencyOffset(int baseOffset, int alpha); +}; + +class gkWinShape{ + friend class gkRGB; + + protected: + gkBYTE *data; + int width, height; + char bpp, fontSpacing, fontKerning; + short int x_handle, y_handle; + static gkTransparencyTable tranTable; + + public: + gkWinShape(); + ~gkWinShape(); + + inline gkBYTE* GetData(){ return data; } + + void FreeData(); + inline void Reset(){ FreeData(); } + void Create(int _width, int _height); + HBITMAP GetDIB(HDC hdc); + void Cls(); + void Cls(gkRGB color); + void Plot(int x, int y, gkRGB color, int testBoundaries=1); + gkRGB Point(int x, int y, int testBoundaries=1); + void Line(int x1, int y1, int x2, int y2, gkRGB color); + void LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, int alpha); + void RectFrame(int x, int y, int w, int h, gkRGB color); + void RectFill(int x, int y, int w, int h, gkRGB color); + void RectFillAlpha(int x, int y, int w, int h, gkRGB color, int alpha); + void RectFillChannel(int x, int y, int w, int h, gkRGB color, int mask); + void FloodFill(int x, int y, gkRGB color); + void RemapColor(gkRGB oldColor, gkRGB newColor); + int GetNumColors(); + int GetPalette(gkRGB *palette, int maxColors); + void RemapToPalette(gkRGB *palette, int numColors); + void ReduceColors(int numColors); + void ExchangeColors(gkRGB c1, gkRGB c2); + void SetAlpha(int alpha); + void SetColorAlpha(gkRGB color, int alpha); + + int GetShape(gkWinShape *srcShape, int x, int y, int w, int h); + int GetShape(gkWinShape *srcShape); + int GetShape(HDC hdc); + int GetShape(HBITMAP bitmap); + int SaveShape(char *filename); + int SaveShape(ostream &outfile); + int LoadShape(char *filename); + int LoadShape(istream &infile); + int LoadBMP(char *filename); + int LoadBMP(istream &infile); + void Blit(gkWinShape *destShape, int x, int y, + int flags=GKBLT_TRANSPARENT); + void BlitScale(gkWinShape *destShape, int x, int y, int scale, + int flags=GKBLT_TRANSPARENT); + void BlitScale(gkWinShape *destShape, int x, int y, float scale, + int flags=GKBLT_TRANSPARENT); + void BlitChannel(gkWinShape *destShape, int x, int y, int mask); + void BlitToHDC(HDC hDC, int x, int y); + + int GetWidth(){ return width; } + int GetHeight(){ return height; } + + //internal support routines + static void MemCpyTrans(gkBYTE *dest, gkBYTE *src, int nBytes); + static void BlitLineScale(gkBYTE *dest, gkBYTE *src, int pixels,int ratio); +}; + +#endif + diff --git a/Tools/GBConv2/Source/wingk.hbk b/Tools/GBConv2/Source/wingk.hbk new file mode 100644 index 0000000..205bc5f --- /dev/null +++ b/Tools/GBConv2/Source/wingk.hbk @@ -0,0 +1,184 @@ +#ifndef WINGK_H +#define WINGK_H + +#include "stdafx.h" + +#include +#include +#include +#include +#include + +typedef unsigned char gkBYTE; +typedef short int gkWORD; +typedef int gkLONG; + +#define GKHANDLE_TL 0 +#define GKHANDLE_TC 1 +#define GKHANDLE_TR 2 +#define GKHANDLE_CR 3 +#define GKHANDLE_BR 4 +#define GKHANDLE_BC 5 +#define GKHANDLE_BL 6 +#define GKHANDLE_CL 7 +#define GKHANDLE_CENTER 8 + +#define GKBLT_TRANSPARENT 1 + +class gkIO{ + public: + inline static int ReadByte(istream &in){ return in.get(); } + static int ReadWord(istream &in); + static int ReadLong(istream &in); + static char *ReadString(istream &in); + static char *ReadNewString(istream &in); + inline static void WriteByte(ostream &out, int n){ out << (char) n; } + static void WriteLong(ostream &out, int n); + static void WriteWord(ostream &out, int n); + static void WriteString(ostream &out, char *st); +}; + +struct gkRGB_4bytes{ + unsigned char b, g, r, a; +}; + +union gkRGB_ColorUnion{ + gkRGB_4bytes bytes; + gkLONG argb; +}; + +class gkRGB{ + public: + gkRGB_ColorUnion color; + + inline gkRGB(){ color.argb = 0xff000000; } + inline gkRGB(int _r, int _g, int _b, int _a=255){ + color.bytes.r=_r; color.bytes.g=_g; color.bytes.b=_b; color.bytes.a=_a;} + inline void SetR(gkBYTE n){ color.bytes.r = n; } + inline void SetG(gkBYTE n){ color.bytes.g = n; } + inline void SetB(gkBYTE n){ color.bytes.b = n; } + inline void SetA(gkBYTE n){ color.bytes.a = n; } + inline void SetARGB(gkLONG n){ color.argb = n; } + inline gkBYTE GetR(){ return color.bytes.r; } + inline gkBYTE GetG(){ return color.bytes.g; } + inline gkBYTE GetB(){ return color.bytes.b; } + inline gkBYTE GetA(){ return color.bytes.a; } + inline gkLONG GetARGB(){ return color.argb; } + inline int operator==(gkRGB &c2); + inline int Equals(int _r, int _g, int _b); + void Combine(gkRGB c2, int alpha); + operator COLORREF(); +}; + +class gkPalGenItem{ + protected: + gkRGB color; + int occurrences; + gkPalGenItem *nextItem; + + public: + gkPalGenItem(gkRGB _color); + ~gkPalGenItem(); + inline gkRGB GetColor(); + inline void AddOccurrence(); + inline int GetOccurrences(); + inline void SetOccurrences(int n); + inline void SetNextItem(gkPalGenItem *item); + inline gkPalGenItem *GetNextItem(); + int GetCount(); + static int SortCallback(const void *e1, const void *e2); +}; + +class gkPaletteGenerator{ + protected: + gkPalGenItem *colorCube[13*4]; + + public: + gkPaletteGenerator(); + ~gkPaletteGenerator(); + void Reset(); + void AddColor(gkRGB color); + int GetNumColors(); + void CreatePalette(gkRGB *palette, int numEntries); + int GetHash(gkRGB color); + int ColorExists(gkRGB color); + gkRGB MatchColor(gkRGB color); +}; + +class gkTransparencyTable{ + protected: + gkBYTE *lookup; + + public: + gkTransparencyTable(); + ~gkTransparencyTable(); + inline int LookupTransparencyOffset(int baseOffset, int alpha); +}; + +class gkWinShape{ + friend class gkRGB; + + protected: + gkBYTE *data; + int width, height; + char bpp, fontSpacing, fontKerning; + short int x_handle, y_handle; + static gkTransparencyTable tranTable; + + HBITMAP GetDIB(CDC *pDC); + + public: + gkWinShape(); + ~gkWinShape(); + + inline gkBYTE* GetData(){ return data; } + + void FreeData(); + inline void Reset(){ FreeData(); } + void Create(int _width, int _height); + void Cls(); + void Cls(gkRGB color); + void Plot(int x, int y, gkRGB color, int testBoundaries=1); + gkRGB Point(int x, int y, int testBoundaries=1); + void Line(int x1, int y1, int x2, int y2, gkRGB color); + void LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, int alpha); + void RectFrame(int x, int y, int w, int h, gkRGB color); + void RectFill(int x, int y, int w, int h, gkRGB color); + void RectFillAlpha(int x, int y, int w, int h, gkRGB color, int alpha); + void RectFillChannel(int x, int y, int w, int h, gkRGB color, int mask); + void RemapColor(gkRGB oldColor, gkRGB newColor); + int GetNumColors(); + int GetPalette(gkRGB *palette, int maxColors); + void RemapToPalette(gkRGB *palette, int numColors); + void ReduceColors(int numColors); + void ExchangeColors(gkRGB c1, gkRGB c2); + void SetAlpha(int alpha); + void SetColorAlpha(gkRGB color, int alpha); + + int GetShape(gkWinShape *srcShape, int x, int y, int w, int h); + int GetShape(gkWinShape *srcShape); + int SaveShape(char *filename); + int SaveShape(ostream &outfile); + int LoadShape(char *filename); + int LoadShape(istream &infile); + int LoadBMP(char *filename); + int LoadBMP(istream &infile); + void Blit(gkWinShape *destShape, int x, int y, + int flags=GKBLT_TRANSPARENT); + void BlitScale(gkWinShape *destShape, int x, int y, int scale, + int flags=GKBLT_TRANSPARENT); + void BlitScale(gkWinShape *destShape, int x, int y, float scale, + int flags=GKBLT_TRANSPARENT); + void BlitChannel(gkWinShape *destShape, int x, int y, int mask); + void BlitToDC(CDC *pDC, int x, int y); + + int GetWidth(){ return width; } + int GetHeight(){ return height; } + + //internal support routines + static void MemCpyTrans(gkBYTE *dest, gkBYTE *src, int nBytes); + static void BlitLineScale(gkBYTE *dest, gkBYTE *src, int pixels,int ratio); +}; + +#endif + diff --git a/Tools/GBConv2/converter_gfx.bmp b/Tools/GBConv2/converter_gfx.bmp new file mode 100644 index 0000000..2cbd3ca Binary files /dev/null and b/Tools/GBConv2/converter_gfx.bmp differ diff --git a/Tools/LevelEditor/L0107_landing.lvl b/Tools/LevelEditor/L0107_landing.lvl new file mode 100644 index 0000000..2ad90d4 Binary files /dev/null and b/Tools/LevelEditor/L0107_landing.lvl differ diff --git a/Tools/LevelEditor/L1300_appomattox.lvl b/Tools/LevelEditor/L1300_appomattox.lvl new file mode 100644 index 0000000..f7abdd4 Binary files /dev/null and b/Tools/LevelEditor/L1300_appomattox.lvl differ diff --git a/Tools/LevelEditor/LevelDataFormat.txt b/Tools/LevelEditor/LevelDataFormat.txt new file mode 100644 index 0000000..3a304bf --- /dev/null +++ b/Tools/LevelEditor/LevelDataFormat.txt @@ -0,0 +1,38 @@ +FGB Level Data Format +July 6, 2020 by Abe pralle + +file_format_version = 3 : Byte +class_count_minus_1 : Byte + +first_character_index : Byte # the first index that is a mobile character rather than a BG tile +first_character_id : UInt16LowHigh # the class of the first character + +forEach (index in 0..class_count_minus_1) + class_number_low : Byte + class_number_high : Byte + class_number = ((class_number_high :<<: 8) | class_number) - 1 +endForEach + +tiles_wide : Byte +pitch : Byte # smallest power of 2 where tiles_wide <= pitch +tiles_high : Byte +loop (tiles_high) + loop (tiles_wide) + class_index : Byte + endLoop +endLoop + +bg_color : UInt16 # 0_bbbbb_ggggg_rrrrr + +# Waypoint List +# TODO (investigate starting at Tools/LevelEditor/Source/Controls.cpp line 393) + +# Zones +# TODO + +# Exits +# TODO + +# Exit Links +# TODO + diff --git a/Tools/LevelEditor/LevelEditor.exe b/Tools/LevelEditor/LevelEditor.exe new file mode 100644 index 0000000..634767c Binary files /dev/null and b/Tools/LevelEditor/LevelEditor.exe differ diff --git a/Tools/LevelEditor/Source/BGColorDialog.cpp b/Tools/LevelEditor/Source/BGColorDialog.cpp new file mode 100644 index 0000000..ce40811 --- /dev/null +++ b/Tools/LevelEditor/Source/BGColorDialog.cpp @@ -0,0 +1,153 @@ +// BGColorDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "BGColorDialog.h" +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +int CBGColorDialog::initRed = 0; +int CBGColorDialog::initGreen = 0; +int CBGColorDialog::initBlue = 0; + +///////////////////////////////////////////////////////////////////////////// +// CBGColorDialog dialog + + +CBGColorDialog::CBGColorDialog(CWnd* pParent /*=NULL*/) + : CDialog(CBGColorDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CBGColorDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void CBGColorDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBGColorDialog) + DDX_Control(pDX, IDC_COLOR, m_colorFrame); + DDX_Control(pDX, IDC_RED, m_red); + DDX_Control(pDX, IDC_GREEN, m_green); + DDX_Control(pDX, IDC_BLUE, m_blue); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CBGColorDialog, CDialog) + //{{AFX_MSG_MAP(CBGColorDialog) + ON_EN_KILLFOCUS(IDC_RED, OnKillfocusRed) + ON_EN_KILLFOCUS(IDC_GREEN, OnKillfocusGreen) + ON_EN_KILLFOCUS(IDC_BLUE, OnKillfocusBlue) + ON_WM_PAINT() + ON_EN_CHANGE(IDC_RED, OnChangeRed) + ON_EN_CHANGE(IDC_GREEN, OnChangeGreen) + ON_EN_CHANGE(IDC_BLUE, OnChangeBlue) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBGColorDialog message handlers + +BOOL CBGColorDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + SetValue(m_red, initRed); + SetValue(m_green, initGreen); + SetValue(m_blue, initBlue); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CBGColorDialog::SetValue(CEdit &edit, int val) +{ + char st[80]; + ostrstream stout(st,80); + stout << val << ends; + edit.SetWindowText(st); +} + +int CBGColorDialog::GetValue(CEdit &edit) +{ + char st[80]; + edit.GetWindowText(st,80); + istrstream stin(st,80); + + int n; + stin >> n; + return n; +} + +void CBGColorDialog::LimitValue(CEdit &edit, int min, int max) +{ + int n = GetValue(edit); + if(n < min || n > max){ + if(nInvalidateRect(0); +} + +void CBGColorDialog::OnKillfocusGreen() +{ + LimitValue(m_green, 0, 255); + initGreen = GetValue(m_green); + this->InvalidateRect(0); +} + +void CBGColorDialog::OnKillfocusBlue() +{ + LimitValue(m_blue, 0, 255); + initBlue = GetValue(m_blue); + this->InvalidateRect(0); +} + +void CBGColorDialog::OnOK() +{ + CDialog::OnOK(); +} + +void CBGColorDialog::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + CRect rect; + m_colorFrame.GetWindowRect(&rect); + this->ScreenToClient(&rect); + + int color = (initBlue<<16) | (initGreen<<8) | initRed; + dc.FillSolidRect(&rect,color); + + // Do not call CDialog::OnPaint() for painting messages +} + +void CBGColorDialog::OnChangeRed() +{ + this->OnKillfocusRed(); +} + +void CBGColorDialog::OnChangeGreen() +{ + this->OnKillfocusGreen(); +} + +void CBGColorDialog::OnChangeBlue() +{ + this->OnKillfocusBlue(); +} diff --git a/Tools/LevelEditor/Source/BGColorDialog.h b/Tools/LevelEditor/Source/BGColorDialog.h new file mode 100644 index 0000000..43e0e30 --- /dev/null +++ b/Tools/LevelEditor/Source/BGColorDialog.h @@ -0,0 +1,61 @@ +#if !defined(AFX_BGCOLORDIALOG_H__7540E1C1_F5D2_11D3_B6CE_525400E2D57B__INCLUDED_) +#define AFX_BGCOLORDIALOG_H__7540E1C1_F5D2_11D3_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BGColorDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CBGColorDialog dialog + +class CBGColorDialog : public CDialog +{ +// Construction +public: + void LimitValue(CEdit &edit, int min, int max); + int GetValue(CEdit &edit); + void SetValue(CEdit &edit, int val); + static int initRed, initGreen, initBlue; + CBGColorDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CBGColorDialog) + enum { IDD = IDD_COLORPICKER }; + CStatic m_colorFrame; + CEdit m_red; + CEdit m_green; + CEdit m_blue; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBGColorDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CBGColorDialog) + virtual BOOL OnInitDialog(); + afx_msg void OnKillfocusRed(); + afx_msg void OnKillfocusGreen(); + afx_msg void OnKillfocusBlue(); + virtual void OnOK(); + afx_msg void OnPaint(); + afx_msg void OnChangeRed(); + afx_msg void OnChangeGreen(); + afx_msg void OnChangeBlue(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BGCOLORDIALOG_H__7540E1C1_F5D2_11D3_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/ChildView.cpp b/Tools/LevelEditor/Source/ChildView.cpp new file mode 100644 index 0000000..65c701f --- /dev/null +++ b/Tools/LevelEditor/Source/ChildView.cpp @@ -0,0 +1,159 @@ +// ChildView.cpp : implementation of the CChildView class +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "ChildView.h" +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChildView + +CChildView::CChildView() +{ + + //load in bitmap + tyPic.LoadBMP("ty.bmp"); + +} + +CChildView::~CChildView() +{ +} + + +BEGIN_MESSAGE_MAP(CChildView,CWnd ) + //{{AFX_MSG_MAP(CChildView) + ON_WM_PAINT() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CChildView message handlers + +BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) +{ + if (!CWnd::PreCreateWindow(cs)) + return FALSE; + + cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.style &= ~WS_BORDER; + cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, + ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); + + return TRUE; +} + +void CChildView::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + if(1) + return; +} + + +void CChildView::OnMouseMove(UINT nFlags, CPoint point) +{ + + // TODO: Add your message handler code here and/or call default + this->InvalidateRect(0, TRUE); + CWnd ::OnMouseMove(nFlags, point); + +} + +void CChildView::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + + CWnd ::OnLButtonDown(nFlags, point); + + +} + +BOOL CChildView::OnEraseBkgnd(CDC* pDC) +{ + // TODO: Add your message handler code here and/or call default + + // we'll handle clearing + return true; + + //return CWnd ::OnEraseBkgnd(pDC); +} + + + +int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd ::OnCreate(lpCreateStruct) == -1) + return -1; + + + // TODO: Add your specialized creation code here + controls.Create(IDD_CONTROLS, this); + mapWin.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, + CRect(0,0,0,0), this, 0, 0); + + controls.ShowWindow(SW_SHOW); + + return 0; +} + +void CChildView::ReSizeWindows() +{ + + CRect rect; + + this->GetClientRect(&rect); + + controls.SetWindowPos(&wndTop, 0, 0, 300, rect.Height(), SWP_SHOWWINDOW); + mapWin.SetWindowPos(&wndTop, 300, 0, rect.Width()-300, rect.Height(), SWP_SHOWWINDOW); + + +} + +void CChildView::OnSize(UINT nType, int cx, int cy) +{ + CWnd ::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + this->ReSizeWindows(); + +} + +// display grids on the mapview +void CChildView::SetGrids(bool on){ + mapWin.SetGrids(on); +} + +// naughty function to grab a reference to WinMap +CMapWin* CChildView::GrabWinMap(){ + return &mapWin; +} + +// naughty function to grab a reference to control +CControls* CChildView::GrabControls(){ + return &controls; +} + + + + +void CChildView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +ASSERT(0); + CWnd ::OnKeyDown(nChar, nRepCnt, nFlags); +} diff --git a/Tools/LevelEditor/Source/ChildView.h b/Tools/LevelEditor/Source/ChildView.h new file mode 100644 index 0000000..fc6bd44 --- /dev/null +++ b/Tools/LevelEditor/Source/ChildView.h @@ -0,0 +1,78 @@ +// ChildView.h : interface of the CChildView class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CHILDVIEW_H__CA2832CA_B4C7_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_CHILDVIEW_H__CA2832CA_B4C7_11D3_958B_00A0CC533895__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "wingk.h" +#include "mapwin.h" +#include "Controls.h" + +///////////////////////////////////////////////////////////////////////////// +// CChildView window + +class CChildView : public CWnd +{ +// Construction +public: + CChildView(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChildView) + protected: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + void ReSizeWindows(); + void SetGrids(bool); + virtual ~CChildView(); + + // naughty function to grab references to Children + CMapWin* GrabWinMap(); + CControls* GrabControls(); + + + + // Generated message map functions +protected: + + gkWinShape tyPic; + //background + gkWinShape bckgrndBffr; + + CControls controls; + CMapWin mapWin; + + + //{{AFX_MSG(CChildView) + afx_msg void OnPaint(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHILDVIEW_H__CA2832CA_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/ClassList.cpp b/Tools/LevelEditor/Source/ClassList.cpp new file mode 100644 index 0000000..2c2f0ce --- /dev/null +++ b/Tools/LevelEditor/Source/ClassList.cpp @@ -0,0 +1,120 @@ +// ClassList.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "ClassList.h" +#include "EditDefines.h" +#include "wingk.h" +#include "strstrea.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CClassList dialog + + +CClassList::CClassList(CWnd* pParent /*=NULL*/) + : CDialog(CClassList::IDD, pParent) +{ + //{{AFX_DATA_INIT(CClassList) + //}}AFX_DATA_INIT +} + + +void CClassList::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CClassList) + DDX_Control(pDX, IDC_CLASS_LIST, m_classList); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CClassList, CDialog) + //{{AFX_MSG_MAP(CClassList) + ON_WM_CREATE() + ON_WM_CTLCOLOR() + ON_LBN_SELCHANGE(IDC_CLASS_LIST, OnSelchangeClassList) + ON_BN_CLICKED(IDC_CLASSLIST_CLEARALL, OnClasslistClearall) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassList message handlers + +int CClassList::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDialog::OnCreate(lpCreateStruct) == -1) + return -1; + + + return 0; +} + +HBRUSH CClassList::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) +{ + HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); + + + // TODO: Return a different brush if the default is not desired + return hbr; +} + +BOOL CClassList::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_classList.tileList = tileList; + int i; + for(i=2; i<=E_LAST_TILE; i++){ + char st[80]; + ostrstream stout(st,80); + stout << "Tile " << i << ends; + int index = m_classList.AddString(st); + int data = 0; + if(listOfAllTiles[i]) data |= (1<<16); + data |= (i & 0xffff); + m_classList.SetItemData(index, data); + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CClassList::OnSelchangeClassList() +{ + int index = m_classList.GetCurSel(); + + //toggle selected bit + int data = m_classList.GetItemData(index); + data ^= (1<<16); + m_classList.SetItemData(index, data); + + if(data & (1<<16)){ + //check was set + listOfAllTiles[index+2] = 1; + }else{ + //check was cleared + listOfAllTiles[index+2] = 0; + } + + m_classList.InvalidateRect(0); +} + +void CClassList::OnClasslistClearall() +{ + int last = m_classList.GetCount(); + int i; + for(i=0; i 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "wingk.h" +#include "ClassListList.h" + +// ClassList.h : header file +// + +#include "wingk.h" + +///////////////////////////////////////////////////////////////////////////// +// CClassList dialog + +class CClassList : public CDialog +{ +// Construction +public: + short int *listOfTilesUsed, *listOfAllTiles, totalTilesUsed; + gkWinShape *tileList; + CClassList(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CClassList) + enum { IDD = IDD_CLASS_LIST_DIALOG }; + CClassListList m_classList; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClassList) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CClassList) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); + virtual BOOL OnInitDialog(); + afx_msg void OnSelchangeClassList(); + afx_msg void OnClasslistClearall(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLASSLIST_H__D14BA4E8_C76B_11D3_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/ClassListList.cpp b/Tools/LevelEditor/Source/ClassListList.cpp new file mode 100644 index 0000000..3f1b6fe --- /dev/null +++ b/Tools/LevelEditor/Source/ClassListList.cpp @@ -0,0 +1,96 @@ +// ClassListList.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "ClassListList.h" +#include "ClassList.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CClassListList + +CClassListList::CClassListList() +{ +} + +CClassListList::~CClassListList() +{ +} + + +BEGIN_MESSAGE_MAP(CClassListList, CListBox) + //{{AFX_MSG_MAP(CClassListList) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClassListList message handlers + +void CClassListList::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + CRect rect; + this->GetClientRect(&rect); + + //tell windows the dimensions of each member of our selection box + //lpMeasureItemStruct->itemWidth = rect.Width(); + //lpMeasureItemStruct->itemHeight = 16; + +} + +void CClassListList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + HDC hdc = lpDrawItemStruct->hDC; + CDC dc; + dc.Attach(hdc); + + CBrush brush; + brush.Attach(::GetStockObject(BLACK_BRUSH)); + + CRect rect = lpDrawItemStruct->rcItem; + int x = rect.left; + int y = rect.top; + + + int data = lpDrawItemStruct->itemData; + int tile = data & 0xffff; + int isUsed = (data>>16) & 1; + + //checkbox + CRect checkBox(x+4,y+2,x+14,y+12); + dc.FillSolidRect(&checkBox,0xffffff); + dc.FrameRect(&checkBox,&brush); + + if(isUsed){ + checkBox.DeflateRect(2,2); + dc.FillSolidRect(&checkBox,0); + //dc.MoveTo(checkBox.left, checkBox.top); + //dc.LineTo(checkBox.right-1, checkBox.bottom-1); + //dc.MoveTo(checkBox.left, checkBox.bottom-1); + //dc.LineTo(checkBox.right-1, checkBox.top); + } + + //picture + if(tile){ + tileList[tile].BlitToDC(&dc, x+20, y); + } + + //text + dc.SetBkColor(::GetSysColor(COLOR_WINDOW)); + char st[80]; + GetText(lpDrawItemStruct->itemID,st); + dc.TextOut(x+38,y,st); + + if(lpDrawItemStruct->itemState & ODS_SELECTED){ + dc.FrameRect(rect,&brush); + } + + brush.Detach(); + dc.Detach(); +} diff --git a/Tools/LevelEditor/Source/ClassListList.h b/Tools/LevelEditor/Source/ClassListList.h new file mode 100644 index 0000000..31ebc45 --- /dev/null +++ b/Tools/LevelEditor/Source/ClassListList.h @@ -0,0 +1,55 @@ +#if !defined(AFX_CLASSLISTLIST_H__D14BA4E9_C76B_11D3_B6CE_525400E2D57B__INCLUDED_) +#define AFX_CLASSLISTLIST_H__D14BA4E9_C76B_11D3_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "wingk.h" + +// ClassListList.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CClassListList window + +class CClassListList : public CListBox +{ +// Construction +public: + CClassListList(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClassListList) + public: + virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + //}}AFX_VIRTUAL + +// Implementation +public: + gkWinShape* tileList; + virtual ~CClassListList(); + + // Generated message map functions +protected: + //{{AFX_MSG(CClassListList) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLASSLISTLIST_H__D14BA4E9_C76B_11D3_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/Controls.cpp b/Tools/LevelEditor/Source/Controls.cpp new file mode 100644 index 0000000..7937596 --- /dev/null +++ b/Tools/LevelEditor/Source/Controls.cpp @@ -0,0 +1,985 @@ +// Controls.cpp : implementation file +// + +#include +#include +#include "stdafx.h" +#include "EditDefines.h" +#include "LevelEditor.h" +#include "Controls.h" +#include "ChildView.h" +#include "MapWin.h" +#include "ZoneList.h" +#include "WayPointList.h" +#include "ClassList.h" +#include "BGColorDialog.h" +#include "LinkExitsDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define E_TILETITLE "background0001-1535.bmp" +#define E_PEOPLETITLE "objects2048-2303.bmp" + +///////////////////////////////////////////////////////////////////////////// +// CControls dialog + + +CControls::CControls(CWnd* pParent /*=NULL*/) + : CDialog(CControls::IDD, pParent) +{ + + gkWinShape temp1, temp2; + + //Load tiles into buffer + temp1.LoadBMP(E_TILETITLE); + + //CHANGE + //go ahead an set the cur tile as first tile in tileBuff + curTile = 1; + int i; + + //load all the tiles of a 512 wide file into tileList + //assuming all tiles are 16 pixel squares + int tmpIndex = 1; + for(int j=0;j<(E_TILEBMPSIZEY >> 4);j++) + for(i=0;i<(E_TILEBMPSIZEX >> 4);i++) + tileList[tmpIndex++].GetShape(&temp1,i<<4,j<<4,16,16); + + //Load people tiles into buffer + tmpIndex--; //start people at 1024, not 1025 + temp2.LoadBMP(E_PEOPLETITLE); + for(j=0;j<(E_PEOPLEBMPSIZEY >> 4);j++) + for(i=0;i<(E_PEOPLEBMPSIZEX >> 4);i++) + tileList[tmpIndex++].GetShape(&temp2,i<<4,j<<4,16,16); + + tileBuff.Create(E_TOTALBUFFERSIZEW,E_TOTALBUFFERSIZEH); + tileBuff.Cls(gkRGB(0,0,0)); + temp1.Blit(&tileBuff,0,0); + temp2.Blit(&tileBuff,0,E_TILEBMPSIZEY); + + mapWidth = E_LEVELSIZEX; + mapHeight = E_LEVELSIZEY; + + //discover map pitch + mapPitch = 0; + int temp = mapWidth-1; + while(temp){ + temp = (temp>>1) & 0x7f; + mapPitch = (mapPitch<<1) | 1; + } + mapPitch++; + + g_wayPointList.SetPitch(mapPitch); + + drawingZones = -1; + drawingExits = -1; + + metaWidth = metaHeight = 1; + areaSpecial = 0; + + links[0] = 0x4040; //+0, +0 + links[1] = 0x4081; //+0,-1 + links[2] = 0x4140; //+1,+0 + links[3] = 0x4041; //+0,+1 + links[4] = 0x8140; //-1,+0 + links[5] = links[6] = links[7] = 0x4040; //+0, +0 + + isWall = 0; + + //{{AFX_DATA_INIT(CControls) + //}}AFX_DATA_INIT +} + + +void CControls::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CControls) + DDX_Control(pDX, IDC_SORTCLASSESBY, m_sortClassesBy); + DDX_Control(pDX, IDC_WALLCHECK, m_wallCheck); + DDX_Control(pDX, IDC_COPYDOWN, m_copyDown); + DDX_Control(pDX, IDC_COPYLEFT, m_copyLeft); + DDX_Control(pDX, IDC_COPYRIGHT, m_copyRight); + DDX_Control(pDX, IDC_COPYUP, m_copyUp); + DDX_Control(pDX, IDC_SHIFTUP, m_shiftUp); + DDX_Control(pDX, IDC_SHIFTRIGHT, m_shiftRight); + DDX_Control(pDX, IDC_SHIFTLEFT, m_shiftLeft); + DDX_Control(pDX, IDC_SHIFTDOWN, m_shiftDown); + DDX_Control(pDX, IDC_META_HEIGHT, m_metaHeight); + DDX_Control(pDX, IDC_META_WIDTH, m_metaWidth); + DDX_Control(pDX, IDC_RADIO_TILES, m_radioTiles); + DDX_Control(pDX, IDC_LOAD_FILENAME, m_loadLevel); + DDX_Control(pDX, IDC_ZONELIST, m_zoneList); + DDX_Control(pDX, IDC_EDIT_HEIGHT, m_editHeight); + DDX_Control(pDX, IDC_EDIT_WIDTH, m_editWidth); + DDX_Control(pDX, IDC_CURTILE, m_loadlevelname); + DDX_Control(pDX, IDC_SAVELEVEL, m_levelname); + DDX_Control(pDX, IDC_SHOWGRIDS, m_showGrids); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CControls, CDialog) + //{{AFX_MSG_MAP(CControls) + ON_BN_CLICKED(IDC_SHOWGRIDS, OnShowgrids) + ON_WM_PAINT() + ON_WM_CREATE() + ON_WM_SIZE() + ON_BN_CLICKED(IDC_WRITEFILE, OnWritefile) + ON_BN_CLICKED(IDC_LOAD, OnLoad) + ON_BN_CLICKED(IDC_CLEAR, OnClear) + ON_EN_KILLFOCUS(IDC_EDIT_HEIGHT, OnKillfocusEditHeight) + ON_EN_KILLFOCUS(IDC_EDIT_WIDTH, OnKillfocusEditWidth) + ON_WM_MEASUREITEM() + ON_WM_DRAWITEM() + ON_LBN_SELCHANGE(IDC_ZONELIST, OnSelchangeZonelist) + ON_BN_CLICKED(IDC_BUTTON_CLASSLIST, OnButtonClasslist) + ON_WM_DESTROY() + ON_WM_KEYDOWN() + ON_BN_CLICKED(IDC_RADIO_TILES, OnRadioTiles) + ON_BN_CLICKED(IDC_RADIO_ZONES, OnRadioZones) + ON_BN_CLICKED(IDC_RADIO_EXITS, OnRadioExits) + ON_BN_CLICKED(IDC_BGCOLOR, OnBgcolor) + ON_BN_CLICKED(IDC_SETMETA_1X1, OnSetmeta1x1) + ON_BN_CLICKED(IDC_SETMETA_2X2, OnSetmeta2x2) + ON_EN_CHANGE(IDC_META_WIDTH, OnChangeMetaWidth) + ON_EN_CHANGE(IDC_META_HEIGHT, OnChangeMetaHeight) + ON_BN_CLICKED(IDC_SHIFTUP, OnShiftup) + ON_BN_CLICKED(IDC_SHIFTRIGHT, OnShiftright) + ON_BN_CLICKED(IDC_SHIFTDOWN, OnShiftdown) + ON_BN_CLICKED(IDC_SHIFTLEFT, OnShiftleft) + ON_BN_CLICKED(IDC_COPYUP, OnCopyup) + ON_BN_CLICKED(IDC_COPYRIGHT, OnCopyright) + ON_BN_CLICKED(IDC_COPYDOWN, OnCopydown) + ON_BN_CLICKED(IDC_COPYLEFT, OnCopyleft) + ON_BN_CLICKED(IDC_BUTTON_LINKEXITS, OnButtonLinkexits) + ON_BN_CLICKED(IDC_WALLCHECK, OnWallcheck) + ON_BN_CLICKED(IDC_SETMETA_3x3, OnSETMETA3x3) + ON_BN_CLICKED(IDC_SETMETA_4x4, OnSETMETA4x4) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CControls message handlers + +void CControls::OnShowgrids() +{ + CChildView* papa; + + if(!::IsWindow(this->m_hWnd)) + return; + + + //grab a pointer to the view + papa = (CChildView*)this->GetParent(); + //if(!papa) + // return; + + // TODO: Add your control notification handler code here + if(m_showGrids.GetCheck()) + { + papa->SetGrids(true); + }else + papa->SetGrids(false); + +} + +void CControls::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + // TODO: Add your message handler code here + + /////////////////Draw Current Tile///////////////// + + // draw Box + dc.MoveTo(15,50); + dc.LineTo(15,74); + dc.MoveTo(15,50); + dc.LineTo(39,50); + dc.MoveTo(39,50); + dc.LineTo(39,74); + dc.MoveTo(39,74); + dc.LineTo(15,74); + //draw current tile + tileList[curTile].BlitToDC(&dc,19,54); + + + // Do not call CDialog::OnPaint() for painting messages +} + + +// grab pointer to the current tile +gkWinShape *CControls::GrabCurTilePointer() +{ + return &tileList[curTile]; +} + +int CControls::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CDialog::OnCreate(lpCreateStruct) == -1) + return -1; + + // TODO: Add your specialized creation code here + + // TODO: Add your specialized creation code here + terrainTiles.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL + , CRect(0,0,0,0), this, 0, 0); + terrainTiles.ShowWindow(SW_SHOW); + + return 0; +} + +void CControls::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + + CRect rect; + this->GetClientRect(&rect); + terrainTiles.SetWindowPos(&wndTop,5,100,rect.Width()-10,189,SWP_SHOWWINDOW ); + + /* + SCROLLINFO info; + info.cbSize = sizeof(SCROLLINFO); + info.fMask = SIF_ALL; + info.nPage = 32; + info.nMin = 0; + info.nMax = TERRAINSCROLLMAXV; + info.nPos = 0; + terrainTiles.SetScrollInfo(SB_HORZ, &info); + terrainTiles.SetScrollInfo(SB_VERT, &info); + */ + +} + +gkWinShape* CControls::GrabTileBuffer(){ + return &tileBuff; +} + +void CControls::SetCurTilePointer(int index) +{ + curTile = index; + this->InvalidateRect(0); +} + +// when this button is pressed we want to take the current file +// and write it to a .lvl gb binary +void CControls::OnWritefile() +{ + ofstream output; + CMapWin* mapWin; + int i;//declare on top for compatibility + + char str[80]; + + m_levelname.GetWindowText(str,80); + //m_levelname + if(!strcmp(str,"")) + { + output.open(E_DEFAULTFILENAME, ios::out | ios::binary); + if(output.fail()) + { + this->MessageBox("Couldn't open file bitch ass"); + return; + } + }else{ + output.open(str, ios::out | ios::binary); + if(output.fail()) + { + this->MessageBox("Couldn't open file bitch ass"); + return; + } + } + + //add to drop-down filename list? + if(m_loadLevel.FindStringExact(0,str)==CB_ERR){ + //m_loadLevel.InsertString(0,str); + m_loadLevel.AddString(str); + } + + mapWin = (CMapWin*)(((CChildView*)this->GetParent())->GrabWinMap()); + + output.put((char) 3); //file format version 3 + //2: Added exit arrays + //3: Added exit links + //---------------------write number of classes used------------------- + unsigned char totalTilesUsed = mapWin->getTotalTilesUsed()-1; + output.write(&totalTilesUsed, sizeof(unsigned char)); + + //remap tiles + mapWin->remapMonsters(); + + //---------------------write index of first monster--------------- + short int firstCharacterID; + short int* listOfAllTiles; + + unsigned char firstCharacterIndex; + listOfAllTiles = mapWin->getListOfTilesUsed(); + + firstCharacterID = (E_TILEBMPSIZEX >> 4) * (E_TILEBMPSIZEY >> 4); + + firstCharacterIndex=0; + while((firstCharacterIndex>8) & 0xff)); + + //---------------------write full id for each tile-------------------- + + for(i=1;i<=totalTilesUsed;i++) + output.write((char*)&listOfAllTiles[i],sizeof(short int)); + + //---------------------write level width------------------------------ + unsigned char width = mapWidth; + output.write(&width, sizeof(unsigned char)); + + //----------------------write level pitch----------------------------- + unsigned char pitch; + + pitch = 1; + while(pitch < width) pitch *= 2; + + output.write(&pitch,sizeof(unsigned char)); + + //--------------------write level height------------------------------ + unsigned char height = mapHeight; + output.write(&height, sizeof(unsigned char)); + + //--------------------write level indeces----------------------------- + PicStruct envArray[256][256]; + mapWin->getEnvArray(envArray); + + + int numBGTiles = 0; + int numObjects = 0; + for(i=0;i=firstCharacterIndex){ + numObjects++; + }else{ + numBGTiles++; + } + //output.write(&(envArray[j][i].index), sizeof(unsigned char)); + } + } + + //--------------------write background color--------------------------- + int backgroundColor = mapWin->getBackgroundColor(); + short int modifiedColor = 0; + int mask1 = 0x00FF0000; + int mask2 = 0x0000FF00; + int mask3 = 0x000000FF; + + unsigned char blue = ((backgroundColor & mask1) >> 16); + unsigned char green = ((backgroundColor & mask2) >> 8); + unsigned char red = (backgroundColor & mask3); + + modifiedColor |= (blue >> 3)<< 10; + modifiedColor |= (green >> 3)<< 5; + modifiedColor |= (red >> 3); + + output.write((char *)&modifiedColor,sizeof(short int)); + + //--------------------let the WayPointList write itself---------------- + g_wayPointList.Write(output); + + //------------tell the map to write the zones & exit info-------------- + mapWin->WriteZones(output); + mapWin->WriteExits(output); + + //------------Write the exit links------------------------------------- + output << (char) 0 << (char) 0; + for(i=1; i<8; i++){ + output << (char) (links[i] & 0xff) << (char) ((links[i]>>8) & 0xff); + } + + output.close(); + + //Display results + char st[80]; + ostrstream stout(st,80); + stout << "Number of Classes: " << (mapWin->getTotalTilesUsed()-1) << endl; + stout << "Number of Objects: " << numObjects << ends; + MessageBox(st,"Statistics"); +} + + +int CControls::GrabCurTileIndex() +{ + return curTile; +} + + +void CControls::OnCancel() +{ + // TODO: Add extra cleanup here + +// CDialog::OnCancel(); +} + +void CControls::OnOK() +{ + // TODO: Add extra validation here + +// CDialog::OnOK(); +} + +void CControls::OnLoad() +{ + // TODO: Add your control notification handler code here + char str[80]; + m_loadLevel.GetWindowText(str,80); + m_levelname.SetWindowText(str); + + CMapWin* mapWin; + mapWin = (CMapWin*)(((CChildView*)this->GetParent())->GrabWinMap()); + + + if(!strcmp(str,"")) + { + this->MessageBox("You need to specify a level name bitch ass"); + return; + } + + //add to drop-down filename list? + if(m_loadLevel.FindStringExact(0,str)==CB_ERR){ + m_loadLevel.InsertString(0,str); + } + + mapWin->loadLevel(str); + offset_x = 0; + offset_y = 0; +} + +void CControls::OnClear() +{ + // TODO: Add your control notification handler code here + CMapWin* mapWin; + mapWin = (CMapWin*)(((CChildView*)this->GetParent())->GrabWinMap()); + mapWin->clearLevel(); + mapWin->InvalidateRect(0); + + links[0] = 0x4040; //+0, +0 + links[1] = 0x4081; //+0,-1 + links[2] = 0x4140; //+1,+0 + links[3] = 0x4041; //+0,+1 + links[4] = 0x8140; //-1,+0 + links[5] = links[6] = links[7] = 0x4040; + + m_levelname.SetWindowText("unnamed.lvl"); +} + +//return a pointer to a picture at a given index +gkWinShape* CControls::GrabPicAt(int index) +{ + return &tileList[index]; +} + +int CControls::GetMapWidth() +{ + return mapWidth; +} + +int CControls::GetMapHeight() +{ + return mapHeight; +} + +void CControls::SetMapWidth(int n) +{ + mapWidth = n; + char st[80]; + ostrstream stout(st,80); + stout << n << ends; + m_editWidth.SetWindowText(st); + +} + +void CControls::SetMapHeight(int n) +{ + mapHeight = n; + char st[80]; + ostrstream stout(st,80); + stout << n << ends; + m_editHeight.SetWindowText(st); +} + +void CControls::SetOffsetX(int n) +{ + offset_x = n; +} + +void CControls::SetOffsetY(int n) +{ + offset_y = n; +} + +int CControls::GetOffsetX() +{ + return offset_x; +} + +int CControls::GetOffsetY() +{ + return offset_y; +} + +void CControls::OnKillfocusEditHeight() +{ + char st[80]; + m_editHeight.GetWindowText(st,80); + istrstream stin(st,80); + stin >> mapHeight; + offset_y = 0; + + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *mapWin = view->GrabWinMap(); + mapWin->SetScrollBarPositions(); + mapWin->InvalidateRect(0); +} + +void CControls::OnKillfocusEditWidth() +{ + char st[80]; + m_editWidth.GetWindowText(st,80); + istrstream stin(st,80); + stin >> mapWidth; + offset_x = 0; + + //discover map pitch + mapPitch = 0; + int temp = mapWidth-1; + while(temp){ + temp = (temp>>1) & 0x7f; + mapPitch = (mapPitch<<1) | 1; + } + mapPitch++; + g_wayPointList.SetPitch(mapPitch); + + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *mapWin = view->GrabWinMap(); + mapWin->SetScrollBarPositions(); + mapWin->InvalidateRect(0); +} + +void CControls::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + lpMeasureItemStruct->itemWidth = 16; + lpMeasureItemStruct->itemHeight = 16; + + CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct); +} + + +void CControls::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + + CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); +} + +BOOL CControls::OnInitDialog() +{ + CDialog::OnInitDialog(); + + HANDLE findFileHandle; + WIN32_FIND_DATA findFileData; + + findFileHandle = FindFirstFile("L*.lvl",&findFileData); + do{ + m_loadLevel.AddString(findFileData.cFileName); + }while(FindNextFile(findFileHandle,&findFileData)); + /* + ifstream recentFiles("recentFiles.txt",ios::in|ios::nocreate); + if(!(!recentFiles)){ + char st[80]; + recentFiles.getline(st,80); + while(!recentFiles.eof()){ + m_loadLevel.AddString(st); + recentFiles.getline(st,80); + } + + recentFiles.close(); + } + */ + + int i; + for(i=0; i<16; i++) m_zoneList.AddString((char*) i); + + m_zoneList.SetCurSel(0); + + m_editWidth.SetWindowText("32"); + m_editHeight.SetWindowText("32"); + + m_radioTiles.SetCheck(1); + + m_metaWidth.SetWindowText("1"); + m_metaHeight.SetWindowText("1"); + + m_wallCheck.SetCheck(0); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CControls::OnCheckShowzones() +{ + /* + if(m_checkShowZones.GetCheck()){ + drawingZones = m_zoneList.GetCurSel(); + }else{ + drawingZones = -1; + } + + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + map->InvalidateRect(0); + */ +} + +int CControls::GetDrawingZones() +{ + return drawingZones; +} + +void CControls::OnSelchangeZonelist() +{ + if(drawingZones>=0) drawingZones = m_zoneList.GetCurSel(); + else if(drawingExits>=0) drawingExits = MapIndexToExit(m_zoneList.GetCurSel()); +} + +int CControls::GetMapPitch() +{ + return mapPitch; +} + +void CControls::OnButtonClasslist() +{ + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + CClassList classList; + classList.listOfTilesUsed = map->getListOfTilesUsed(); + classList.listOfAllTiles = map->getListOfAllTiles(); + classList.totalTilesUsed = map->getTotalTilesUsed(); + classList.tileList = this->tileList; + classList.DoModal(); + + map->RemakeListOfTilesUsed(); +} + +void CControls::OnDestroy() +{ + //write out recent files list + /* + ofstream outfile("recentFiles.txt",ios::out); + char st[80]; + int n = m_loadLevel.GetCount(); + int i; + for(i=0; i20) break; + m_loadLevel.GetLBText(i,st); + outfile << st << endl; + } + outfile.close(); + */ + + CDialog::OnDestroy(); +} + +void CControls::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + switch(nChar){ + case VK_LEFT: + curTile--; + this->InvalidateRect(0); + break; + case VK_RIGHT: + curTile++; + this->InvalidateRect(0); + break; + case VK_UP: + curTile-=32; + this->InvalidateRect(0); + break; + case VK_DOWN: + curTile+=32; + this->InvalidateRect(0); + break; + } + if(curTile<0) curTile=0; + else if(curTile>E_LASTTILE) curTile=E_LASTTILE; + CDialog::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CControls::SendToKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + OnKeyDown(nChar,nRepCnt,nFlags); +} + +void CControls::OnRadioTiles() +{ + drawingZones = -1; + drawingExits = -1; + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + map->InvalidateRect(0); + m_zoneList.InvalidateRect(0); +} + +void CControls::OnRadioZones() +{ + drawingZones = m_zoneList.GetCurSel(); + drawingExits = -1; + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + map->InvalidateRect(0); + m_zoneList.InvalidateRect(0); +} + +void CControls::OnRadioExits() +{ + drawingZones = -1; + drawingExits = MapIndexToExit(m_zoneList.GetCurSel()); + + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + map->InvalidateRect(0); + m_zoneList.InvalidateRect(0); +} + +int CControls::MapIndexToExit(int n) +{ + static int map[17] = {7,4,4,7, 1,5,6,3, 1,5,6,3, 7,2,2,7}; + return map[n]; +} + +int CControls::GetDrawingExits() +{ + return drawingExits; +} + +void CControls::OnBgcolor() +{ + CChildView *view = (CChildView*) this->GetParent(); + CMapWin *map = view->GrabWinMap(); + + CBGColorDialog dialog; + + int color = map->getBackgroundColor(); + dialog.initRed = (color & 0xff); + dialog.initGreen = ((color >> 8) & 0xff); + dialog.initBlue = ((color >> 16) & 0xff); + + if(dialog.DoModal()==IDOK){ + int r = dialog.initRed; + int g = dialog.initGreen; + int b = dialog.initBlue; + color = (b<<16) | (g<<8) | r; + map->setBackgroundColor(color); + map->InvalidateRect(0); + } +} + +void CControls::OnSetmeta1x1() +{ + isWall = 0; + m_wallCheck.SetCheck(0); + + metaWidth = metaHeight = 1; + m_metaWidth.SetWindowText("1"); + m_metaHeight.SetWindowText("1"); +} + +void CControls::OnSetmeta2x2() +{ + isWall = 0; + m_wallCheck.SetCheck(0); + + metaWidth = metaHeight = 2; + m_metaWidth.SetWindowText("2"); + m_metaHeight.SetWindowText("2"); +} + +void CControls::OnChangeMetaWidth() +{ + metaWidth = LimitEditValue(m_metaWidth, 1, 10); +} + +int CControls::LimitEditValue(CEdit &edit, int min, int max) +{ + char st[80]; + edit.GetWindowText(st,80); + + istrstream stin(st,80); + int n; + stin >> n; + + if(n < min || n > max){ + if(n 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Controls.h : header file +// + +#include "wingk.h" +#include "TerrainTiles.h" +#include "ZoneList.h" + +///////////////////////////////////////////////////////////////////////////// +// CControls dialog + +class CControls : public CDialog +{ +// Construction +public: + int GetSortClassesBy(); + int links[8]; + int areaSpecial; + gkWinShape* GrabTilePointer(int n); + int LimitEditValue(CEdit &edit, int min, int max); + int metaWidth, metaHeight, isWall; + int GetDrawingExits(); + int MapIndexToExit(int n); + void SendToKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + int GetMapPitch(); + int GetDrawingZones(); + void SetOffsetX(int n); //at what point in the map is the TL corner of view? + void SetOffsetY(int n); + int GetOffsetX(); + int GetOffsetY(); + + int GetMapWidth(); + int GetMapHeight(); + void SetMapWidth(int n); + void SetMapHeight(int n); + CControls(CWnd* pParent = NULL); // standard constructor + + //return the current tile pointer + gkWinShape *GrabCurTilePointer(); + //return the full tile buffer + gkWinShape* GrabTileBuffer(); + //return a pointer to a picture at a given index + gkWinShape* GrabPicAt(int); + void SetCurTilePointer(int index); + int GrabCurTileIndex(); + +// Dialog Data + //{{AFX_DATA(CControls) + enum { IDD = IDD_CONTROLS }; + CButton m_sortClassesBy; + CButton m_wallCheck; + CButton m_copyDown; + CButton m_copyLeft; + CButton m_copyRight; + CButton m_copyUp; + CButton m_shiftUp; + CButton m_shiftRight; + CButton m_shiftLeft; + CButton m_shiftDown; + CEdit m_metaHeight; + CEdit m_metaWidth; + CButton m_radioTiles; + CComboBox m_loadLevel; + CZoneList m_zoneList; + CEdit m_editHeight; + CEdit m_editWidth; + CStatic m_loadlevelname; + CEdit m_levelname; + CButton m_showGrids; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CControls) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + +// Implementation +protected: + int drawingZones, drawingExits; + CTerrainTiles terrainTiles; + int offset_x, offset_y; + int mapPitch; + + // Application Specific Code // + + //buffer for all tiles + gkWinShape tileBuff; + + //current tile index + //REMOVE gkWinShape curTile; + int curTile; + + //list of all tiles + gkWinShape tileList[E_MAXTILES]; + + //current map width and height + int mapWidth, mapHeight; + + + // // // // + + + // Generated message map functions + //{{AFX_MSG(CControls) + afx_msg void OnShowgrids(); + afx_msg void OnPaint(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnWritefile(); + virtual void OnCancel(); + virtual void OnOK(); + afx_msg void OnLoad(); + afx_msg void OnClear(); + afx_msg void OnKillfocusEditHeight(); + afx_msg void OnKillfocusEditWidth(); + afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); + afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual BOOL OnInitDialog(); + afx_msg void OnCheckShowzones(); + afx_msg void OnSelchangeZonelist(); + afx_msg void OnButtonClasslist(); + afx_msg void OnDestroy(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnRadioTiles(); + afx_msg void OnRadioZones(); + afx_msg void OnRadioExits(); + afx_msg void OnBgcolor(); + afx_msg void OnSetmeta1x1(); + afx_msg void OnSetmeta2x2(); + afx_msg void OnChangeMetaWidth(); + afx_msg void OnChangeMetaHeight(); + afx_msg void OnShiftup(); + afx_msg void OnShiftright(); + afx_msg void OnShiftdown(); + afx_msg void OnShiftleft(); + afx_msg void OnCopyup(); + afx_msg void OnCopyright(); + afx_msg void OnCopydown(); + afx_msg void OnCopyleft(); + afx_msg void OnButtonLinkexits(); + afx_msg void OnWallcheck(); + afx_msg void OnSETMETA3x3(); + afx_msg void OnSETMETA4x4(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CONTROLS_H__CA2832D1_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/Current Tile b/Tools/LevelEditor/Source/Current Tile new file mode 100644 index 0000000..e69de29 diff --git a/Tools/LevelEditor/Source/EditDefines.h b/Tools/LevelEditor/Source/EditDefines.h new file mode 100644 index 0000000..a500515 --- /dev/null +++ b/Tools/LevelEditor/Source/EditDefines.h @@ -0,0 +1,67 @@ +/***************************************** +* EditDefines.h +* 12/17/99 +* +* Martin Casado +* +* List of definitions and Macros for +* FGB level editer +********************************************/ + +#ifndef _OBEY_EDITER_LAW_OR_PERISH_IN_ETERNAL_PUDDING_ +#define _OBEY_EDITER_LAW_OR_PERISH_IN_ETERNAL_PUDDING_ + +#include "wingk.h" + + +//width and height of tiles +#define E_TILESIZE 16 + +// name of file which holds tiles +//#define E_TILETITLE "background1-228.bmp" +//#define E_PEOPLETITLE "objects241-308.bmp" + +//size of pic for terrain +#define E_TILEBMPSIZEX 512 +#define E_TILEBMPSIZEY 1024 + +//size of pic for peoples +#define E_PEOPLEBMPSIZEX 512 +#define E_PEOPLEBMPSIZEY 256 + +//TOTAL BUFFER SIZE FOR TILES +#define E_TOTALBUFFERSIZEW 512 +#define E_TOTALBUFFERSIZEH (E_TILEBMPSIZEY + E_PEOPLEBMPSIZEY) + +#define E_LAST_TILE ((((E_PEOPLEBMPSIZEY + E_TILEBMPSIZEY))/16) * 32) + +//struct to define pointer to a shape and the tile number +typedef struct picstruct{ + short int index; + gkWinShape *pic; +}PicStruct; + +//struct used for remapping of tile lists +typedef struct swapstruct{ + unsigned char index; + short int classID; +}SwapStruct; + +//maximum number of tiles for game +#define E_MAXTILES 4096 + +//Verticle and Horizontal scroll maximums for terraintile window +#define TERRAINSCROLLMAXH 512 +#define TERRAINSCROLLMAXV (E_TILEBMPSIZEY + E_PEOPLEBMPSIZEY) + +#define E_LASTTILE ((TERRAINSCROLLMAXV*32)/16) +#define E_FIRSTOBJ (E_TILEBMPSIZEY * 2) + +//default level size in grids +#define E_LEVELSIZEX 32 +#define E_LEVELSIZEY 32 + +//default level name +#define E_DEFAULTFILENAME "test.lvl" + +#endif diff --git a/Tools/LevelEditor/Source/LevelEditor.cpp b/Tools/LevelEditor/Source/LevelEditor.cpp new file mode 100644 index 0000000..d01cc56 --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.cpp @@ -0,0 +1,146 @@ +// LevelEditor.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "LevelEditor.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp + +BEGIN_MESSAGE_MAP(CLevelEditorApp, CWinApp) + //{{AFX_MSG_MAP(CLevelEditorApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp construction + +CLevelEditorApp::CLevelEditorApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CLevelEditorApp object + +CLevelEditorApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp initialization + +BOOL CLevelEditorApp::InitInstance() +{ + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Change the registry key under which our settings are stored. + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization. + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + + + // To create the main window, this code creates a new frame window + // object and then sets it as the application's main window object. + + CMainFrame* pFrame = new CMainFrame; + m_pMainWnd = pFrame; + + // create and load the frame with its resources + + pFrame->LoadFrame(IDR_MAINFRAME, + WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, + NULL); + + + + + // The one and only window has been initialized, so show and update it. + pFrame->ShowWindow(SW_SHOW); + pFrame->UpdateWindow(); + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp message handlers + + + + + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CLevelEditorApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp message handlers + diff --git a/Tools/LevelEditor/Source/LevelEditor.dsp b/Tools/LevelEditor/Source/LevelEditor.dsp new file mode 100644 index 0000000..568c99f --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.dsp @@ -0,0 +1,268 @@ +# Microsoft Developer Studio Project File - Name="LevelEditor" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=LevelEditor - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "LevelEditor.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "LevelEditor.mak" CFG="LevelEditor - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "LevelEditor - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "LevelEditor - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "LevelEditor - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 5 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy EXE to parent directory +PostBuild_Cmds=copy /y Release\*.exe . +# End Special Build Tool + +!ELSEIF "$(CFG)" == "LevelEditor - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 5 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy EXE to parent directory +PostBuild_Cmds=copy /y Release\*.exe . +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "LevelEditor - Win32 Release" +# Name "LevelEditor - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\BGColorDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChildView.cpp +# End Source File +# Begin Source File + +SOURCE=.\ClassList.cpp +# End Source File +# Begin Source File + +SOURCE=.\ClassListList.cpp +# End Source File +# Begin Source File + +SOURCE=.\Controls.cpp +# End Source File +# Begin Source File + +SOURCE=.\LevelEditor.cpp +# End Source File +# Begin Source File + +SOURCE=.\LevelEditor.rc +# End Source File +# Begin Source File + +SOURCE=.\LinkExitsDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\MapWin.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\TerrainTiles.cpp +# End Source File +# Begin Source File + +SOURCE=.\TileLimitDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\WayPointList.cpp +# End Source File +# Begin Source File + +SOURCE=.\ZoneList.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\BGColorDialog.h +# End Source File +# Begin Source File + +SOURCE=.\ChildView.h +# End Source File +# Begin Source File + +SOURCE=.\ClassList.h +# End Source File +# Begin Source File + +SOURCE=.\ClassListList.h +# End Source File +# Begin Source File + +SOURCE=.\Controls.h +# End Source File +# Begin Source File + +SOURCE=.\EditDefines.h +# End Source File +# Begin Source File + +SOURCE=.\LevelEditor.h +# End Source File +# Begin Source File + +SOURCE=.\LinkExitsDialog.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.h +# End Source File +# Begin Source File + +SOURCE=.\MapWin.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\TerrainTiles.h +# End Source File +# Begin Source File + +SOURCE=.\TileLimitDialog.h +# End Source File +# Begin Source File + +SOURCE=.\WayPointList.h +# End Source File +# Begin Source File + +SOURCE=.\ZoneList.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\LevelEditor.ico +# End Source File +# Begin Source File + +SOURCE=.\res\LevelEditor.rc2 +# End Source File +# Begin Source File + +SOURCE=.\res\Toolbar.bmp +# End Source File +# End Group +# Begin Group "GraphixUtils" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\wingk.cpp +# End Source File +# Begin Source File + +SOURCE=.\wingk.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/Tools/LevelEditor/Source/LevelEditor.dsw b/Tools/LevelEditor/Source/LevelEditor.dsw new file mode 100644 index 0000000..53ba1b2 --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "LevelEditor"=.\LevelEditor.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Tools/LevelEditor/Source/LevelEditor.h b/Tools/LevelEditor/Source/LevelEditor.h new file mode 100644 index 0000000..23f1eb6 --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.h @@ -0,0 +1,51 @@ +// LevelEditor.h : main header file for the LEVELEDITOR application +// + +#if !defined(AFX_LEVELEDITOR_H__CA2832C4_B4C7_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_LEVELEDITOR_H__CA2832C4_B4C7_11D3_958B_00A0CC533895__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CLevelEditorApp: +// See LevelEditor.cpp for the implementation of this class +// + +class CLevelEditorApp : public CWinApp +{ +public: + CLevelEditorApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CLevelEditorApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + +public: + //{{AFX_MSG(CLevelEditorApp) + afx_msg void OnAppAbout(); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LEVELEDITOR_H__CA2832C4_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/LevelEditor.plg b/Tools/LevelEditor/Source/LevelEditor.plg new file mode 100644 index 0000000..adbf588 --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.plg @@ -0,0 +1,57 @@ + + +
+

Build Log

+

+--------------------Configuration: LevelEditor - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\WINDOWS\TEMP\RSP60B1.TMP" with contents +[ +/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fo"Release/" /Fd"Release/" /FD /c +"D:\Aprogs\FGBEditor\Controls.cpp" +] +Creating command line "cl.exe @C:\WINDOWS\TEMP\RSP60B1.TMP" +Creating temporary file "C:\WINDOWS\TEMP\RSP60B2.TMP" with contents +[ +/nologo /subsystem:windows /incremental:no /pdb:"Release/LevelEditor.pdb" /machine:I386 /out:"Release/LevelEditor.exe" +.\Release\BGColorDialog.obj +.\Release\ChildView.obj +.\Release\ClassList.obj +.\Release\ClassListList.obj +.\Release\Controls.obj +.\Release\LevelEditor.obj +.\Release\LinkExitsDialog.obj +.\Release\MainFrm.obj +.\Release\MapWin.obj +.\Release\StdAfx.obj +.\Release\TerrainTiles.obj +.\Release\TileLimitDialog.obj +.\Release\WayPointList.obj +.\Release\ZoneList.obj +.\Release\wingk.obj +.\Release\LevelEditor.res +] +Creating command line "link.exe @C:\WINDOWS\TEMP\RSP60B2.TMP" +

Output Window

+Compiling... +Controls.cpp +Linking... +LINK : warning LNK4089: all references to "comdlg32.dll" discarded by /OPT:REF +Creating temporary file "C:\WINDOWS\TEMP\RSP6130.BAT" with contents +[ +@echo off +copy /y Release\*.exe . +] +Creating command line "C:\WINDOWS\TEMP\RSP6130.BAT" +Copy EXE to parent directory +Release\LevelEditor.exe + 1 file(s) copied + + + +

Results

+LevelEditor.exe - 0 error(s), 1 warning(s) +
+ + diff --git a/Tools/LevelEditor/Source/LevelEditor.rc b/Tools/LevelEditor/Source/LevelEditor.rc new file mode 100644 index 0000000..000af75 --- /dev/null +++ b/Tools/LevelEditor/Source/LevelEditor.rc @@ -0,0 +1,521 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\LevelEditor.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\LevelEditor.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15 +BEGIN + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + SEPARATOR + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Help" + BEGIN + MENUITEM "&About LevelEditor...", ID_APP_ABOUT + END + POPUP "Background" + BEGIN + MENUITEM "Red", MENU_RED + MENUITEM "Black", MENU_BLACK + MENUITEM "Blue", MENU_BLUE + MENUITEM "Yellow", MENU_YELLOW + MENUITEM "White", MENU_WHITE + MENUITEM "Gray", MENU_GRAY + MENUITEM "Green", MENU_GREEN + END + POPUP "Grid" + BEGIN + MENUITEM "Red", GRID_RED + MENUITEM "Black", GRID_BLACK + MENUITEM "White", GRID_WHITE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About LevelEditor" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "LevelEditor Version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 1999",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP +END + +IDD_CONTROLS DIALOG DISCARDABLE 0, 0, 200, 349 +STYLE WS_CHILD +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Show Grids",IDC_SHOWGRIDS,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,6,4,54,15 + EDITTEXT IDC_SAVELEVEL,38,190,83,12,ES_AUTOHSCROLL + PUSHBUTTON "Save",IDC_WRITEFILE,6,190,28,13 + COMBOBOX IDC_LOAD_FILENAME,38,210,83,132,CBS_DROPDOWN | + CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Load",IDC_LOAD,6,210,28,13 + PUSHBUTTON "Clear",IDC_CLEAR,6,230,28,13 + EDITTEXT IDC_EDIT_WIDTH,40,252,40,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_HEIGHT,40,272,40,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "Tiles",IDC_RADIO_TILES,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,61,299,47,12 + CONTROL "Zones",IDC_RADIO_ZONES,"Button",BS_AUTORADIOBUTTON,61, + 311,46,12 + CONTROL "Exits",IDC_RADIO_EXITS,"Button",BS_AUTORADIOBUTTON,61, + 323,46,12 + PUSHBUTTON "Class List",IDC_BUTTON_CLASSLIST,101,296,59,14 + LTEXT "Current Tile",IDC_CURTILE,31,33,37,8 + LTEXT "Terrain Tiles",IDC_STATIC,13,50,40,8 + LTEXT "Width",IDC_STATIC,9,252,25,12 + LTEXT "Height",IDC_STATIC,9,272,27,12 + LISTBOX IDC_ZONELIST,11,299,46,42,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | WS_TABSTOP + LTEXT "Zone List",IDC_STATIC,19,288,56,10 + PUSHBUTTON "BG Color",IDC_BGCOLOR,61,4,45,14 + LTEXT "Metatile",IDC_STATIC,132,5,26,8 + EDITTEXT IDC_META_WIDTH,136,16,24,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_META_HEIGHT,136,31,24,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Tiles Wide",IDC_STATIC,100,18,34,8 + LTEXT "Tiles High",IDC_STATIC,100,33,32,8 + PUSHBUTTON "1 x 1",IDC_SETMETA_1X1,165,5,29,12 + PUSHBUTTON "2 x 2",IDC_SETMETA_2X2,165,19,29,12 + GROUPBOX "Area Draw Special",IDC_STATIC,126,186,68,98 + CONTROL "Shift Up",IDC_SHIFTUP,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,196,41,10 + CONTROL "Shift Right",IDC_SHIFTRIGHT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,206,49,10 + CONTROL "Shift Down",IDC_SHIFTDOWN,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,216,51,10 + CONTROL "Shift Left",IDC_SHIFTLEFT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,226,44,10 + CONTROL "Cut",IDC_COPYUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 132,239,27,10 + CONTROL "Copy",IDC_COPYRIGHT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,249,32,10 + CONTROL "Paste",IDC_COPYDOWN,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,132,259,34,10 + CONTROL "Copy Left",IDC_COPYLEFT,"Button",BS_AUTOCHECKBOX | NOT + WS_VISIBLE | WS_DISABLED | WS_TABSTOP,132,269,46,10 + PUSHBUTTON "Link Exits",IDC_BUTTON_LINKEXITS,101,314,59,14 + CONTROL "4x4 Wall",IDC_WALLCHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,100,48,44,8 + PUSHBUTTON "3 x 3",IDC_SETMETA_3x3,165,33,29,12 + PUSHBUTTON "4 x 4",IDC_SETMETA_4x4,165,47,29,12 + CONTROL "Sort Classes BG/FG",IDC_SORTCLASSESBY,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,115,332,79,10 +END + +IDD_CLASS_LIST_DIALOG DIALOG DISCARDABLE 0, 0, 149, 215 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Included Classes" +FONT 8, "MS Sans Serif" +BEGIN + LISTBOX IDC_CLASS_LIST,7,7,135,182,LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + PUSHBUTTON "Clear All",IDC_CLASSLIST_CLEARALL,48,194,50,14 +END + +IDD_COLORPICKER DIALOG DISCARDABLE 0, 0, 136, 95 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select Background Color" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,79,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,79,24,50,14 + CONTROL "",IDC_COLOR,"Static",SS_BLACKFRAME,7,7,50,24 + EDITTEXT IDC_RED,25,41,32,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "R",IDC_STATIC,11,43,11,9 + EDITTEXT IDC_GREEN,25,56,32,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "G",IDC_STATIC,11,58,11,9 + EDITTEXT IDC_BLUE,25,71,32,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "B",IDC_STATIC,11,73,11,9 +END + +IDD_LINKEXITS DIALOG DISCARDABLE 0, 0, 239, 130 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Link Exits" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,182,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,182,24,50,14 + LTEXT "Links may be expressed in:\n1) Absolute Coordinates\n \t2,5 = map (2,5)", + IDC_STATIC,7,80,97,27 + LTEXT "North",IDC_STATIC,10,10,18,8 + EDITTEXT IDC_NORTHEXIT,37,8,40,14,ES_AUTOHSCROLL + LTEXT "East",IDC_STATIC,11,28,15,8 + EDITTEXT IDC_EASTEXIT,37,26,40,14,ES_AUTOHSCROLL + LTEXT "South",IDC_STATIC,11,45,20,8 + EDITTEXT IDC_SOUTHEXIT,37,43,40,14,ES_AUTOHSCROLL + LTEXT "West",IDC_STATIC,11,63,18,8 + EDITTEXT IDC_WESTEXIT,37,61,40,14,ES_AUTOHSCROLL + LTEXT "Up",IDC_STATIC,95,10,10,8 + EDITTEXT IDC_UPEXIT,121,8,40,14,ES_AUTOHSCROLL + LTEXT "Down",IDC_STATIC,95,27,20,8 + EDITTEXT IDC_DOWNEXIT,121,25,40,14,ES_AUTOHSCROLL + LTEXT "Exit (X)",IDC_STATIC,95,45,23,8 + EDITTEXT IDC_EXITEXIT,121,43,40,14,ES_AUTOHSCROLL + LTEXT "Coords may range from 0-15. +0,+0 indicates no link.", + IDC_STATIC,36,110,170,13 + LTEXT "2) Relative Coordinates (recommended)\n\t+2,+5 = map(this_i+2, this_j+5)", + IDC_STATIC,108,80,124,24 +END + +IDD_TILELIMIT DIALOG DISCARDABLE 0, 0, 143, 66 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select Bank 0 Tile Limit" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,45,46,50,14 + CONTROL "0-135 (preserves Text Box and font)",IDC_LIMIT_TEXTBOX, + "Button",BS_AUTORADIOBUTTON | WS_GROUP,7,7,129,10 + CONTROL "0-199 (preserves font only) ",IDC_LIMIT_FONT,"Button", + BS_AUTORADIOBUTTON,7,19,101,10 + CONTROL "0-255",IDC_LIMIT_NONE,"Button",BS_AUTORADIOBUTTON,7,31, + 34,10 +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "LevelEditor MFC Application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "LevelEditor\0" + VALUE "LegalCopyright", "Copyright (C) 1999\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "LevelEditor.EXE\0" + VALUE "ProductName", "LevelEditor Application\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END + + IDD_CONTROLS, DIALOG + BEGIN + LEFTMARGIN, 6 + RIGHTMARGIN, 194 + TOPMARGIN, 4 + BOTTOMMARGIN, 342 + END + + IDD_CLASS_LIST_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 142 + TOPMARGIN, 7 + BOTTOMMARGIN, 208 + END + + IDD_COLORPICKER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 129 + TOPMARGIN, 7 + BOTTOMMARGIN, 88 + END + + IDD_LINKEXITS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 232 + TOPMARGIN, 7 + BOTTOMMARGIN, 123 + END + + IDD_TILELIMIT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 136 + TOPMARGIN, 7 + BOTTOMMARGIN, 59 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "LevelEditor" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "LevelEditor" + AFX_IDS_IDLEMESSAGE "Ready" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\LevelEditor.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Tools/LevelEditor/Source/LinkExitsDialog.cpp b/Tools/LevelEditor/Source/LinkExitsDialog.cpp new file mode 100644 index 0000000..d99f37f --- /dev/null +++ b/Tools/LevelEditor/Source/LinkExitsDialog.cpp @@ -0,0 +1,188 @@ +// LinkExitsDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "LinkExitsDialog.h" +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +//static variables +int CLinkExitsDialog::initNorthExit = 0; +int CLinkExitsDialog::initEastExit = 0; +int CLinkExitsDialog::initSouthExit = 0; +int CLinkExitsDialog::initWestExit = 0; +int CLinkExitsDialog::initUpExit = 0; +int CLinkExitsDialog::initDownExit = 0; +int CLinkExitsDialog::initExitExit = 0; + +///////////////////////////////////////////////////////////////////////////// +// CLinkExitsDialog dialog + + +CLinkExitsDialog::CLinkExitsDialog(CWnd* pParent /*=NULL*/) + : CDialog(CLinkExitsDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CLinkExitsDialog) + //}}AFX_DATA_INIT +} + + +void CLinkExitsDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CLinkExitsDialog) + DDX_Control(pDX, IDC_WESTEXIT, m_westExit); + DDX_Control(pDX, IDC_UPEXIT, m_upExit); + DDX_Control(pDX, IDC_SOUTHEXIT, m_southExit); + DDX_Control(pDX, IDC_NORTHEXIT, m_northExit); + DDX_Control(pDX, IDC_EXITEXIT, m_exitExit); + DDX_Control(pDX, IDC_EASTEXIT, m_eastExit); + DDX_Control(pDX, IDC_DOWNEXIT, m_downExit); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CLinkExitsDialog, CDialog) + //{{AFX_MSG_MAP(CLinkExitsDialog) + ON_EN_KILLFOCUS(IDC_NORTHEXIT, OnKillfocusNorthexit) + ON_EN_KILLFOCUS(IDC_EASTEXIT, OnKillfocusEastexit) + ON_EN_KILLFOCUS(IDC_SOUTHEXIT, OnKillfocusSouthexit) + ON_EN_KILLFOCUS(IDC_WESTEXIT, OnKillfocusWestexit) + ON_EN_KILLFOCUS(IDC_UPEXIT, OnKillfocusUpexit) + ON_EN_KILLFOCUS(IDC_DOWNEXIT, OnKillfocusDownexit) + ON_EN_KILLFOCUS(IDC_EXITEXIT, OnKillfocusExitexit) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CLinkExitsDialog message handlers + +void CLinkExitsDialog::DisplayLink(CEdit &edit, int link) +{ + char st[80]; + ostrstream stout(st,80); + int x = (link >> 8) & 0xff; + int y = link & 0xff; + + //x and y are in BCD form; convert to normal (1st digit will be 0 or 1) + //preserve upper 3 bits of each byte unchanged + x = (((x>>4) & 1) * 10 + (x & 0x0f)) | (x & 0xe0); + y = (((y>>4) & 1) * 10 + (y & 0x0f)) | (y & 0xe0); + + if(x < 16) stout << x << ", "; + else if(x & 64) stout << "+" << (x & 15) << ", "; + else stout << "-" << (x & 15) << ", "; + + if(y < 16) stout << y << ends; + else if(y & 64) stout << "+" << (y & 15) << ends; + else stout << "-" << (y & 15) << ends; + + edit.SetWindowText(st); +} + +int CLinkExitsDialog::RetrieveLink(CEdit &edit) +{ + char st[80]; + edit.GetWindowText(st,80); + + int i,x,y; + + //eliminate white space + for(i=0; st[i]; i++){ + if(st[i]!=' ') break; + } + + //get x value + x = 0; + for(; st[i]; i++){ + if(st[i]=='+') x |= 64; + else if(st[i]=='-') x |= 128; + else if(st[i]>='0' && st[i]<='9') x = (x & 0xe0) | ((x & 1) * 10 + (st[i]-'0')); + else break; + } + + //skip comma and whitespace + y = 0; + for(; st[i]; i++){ + if(st[i]!=',' && st[i]!=' ') break; + } + + //get y value + y = 0; + for(; st[i]; i++){ + if(st[i]=='+') y |= 64; + else if(st[i]=='-') y |= 128; + else if(st[i]>='0' && st[i]<='9') y = (y & 0xe0) | ((y & 1) * 10 + (st[i]-'0')); + else break; + } + + //convert values to BCD, preserving upper 3 bits + x = (x & 0xe0) | ((((x & 31)/10)<<4) + ((x&31)%10)); + y = (y & 0xe0) | ((((y & 31)/10)<<4) + ((y&31)%10)); + + i = (x << 8) | y; + + //redisplay our interpretation of the input + DisplayLink(edit,i); + + return i; +} + + +void CLinkExitsDialog::OnKillfocusNorthexit() +{ + initNorthExit = RetrieveLink(m_northExit); +} + + +void CLinkExitsDialog::OnKillfocusEastexit() +{ + initEastExit = RetrieveLink(m_eastExit); +} + +void CLinkExitsDialog::OnKillfocusSouthexit() +{ + initSouthExit = RetrieveLink(m_southExit); +} + +void CLinkExitsDialog::OnKillfocusWestexit() +{ + initWestExit = RetrieveLink(m_westExit); +} + +void CLinkExitsDialog::OnKillfocusUpexit() +{ + initUpExit = RetrieveLink(m_upExit); +} + +void CLinkExitsDialog::OnKillfocusDownexit() +{ + initDownExit = RetrieveLink(m_downExit); +} + +void CLinkExitsDialog::OnKillfocusExitexit() +{ + initExitExit = RetrieveLink(m_exitExit); +} + +BOOL CLinkExitsDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DisplayLink(m_northExit, initNorthExit); + DisplayLink(m_eastExit, initEastExit); + DisplayLink(m_southExit, initSouthExit); + DisplayLink(m_westExit, initWestExit); + DisplayLink(m_upExit, initUpExit); + DisplayLink(m_downExit, initDownExit); + DisplayLink(m_exitExit, initExitExit); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/Tools/LevelEditor/Source/LinkExitsDialog.h b/Tools/LevelEditor/Source/LinkExitsDialog.h new file mode 100644 index 0000000..179630c --- /dev/null +++ b/Tools/LevelEditor/Source/LinkExitsDialog.h @@ -0,0 +1,64 @@ +#if !defined(AFX_LINKEXITSDIALOG_H__02AEC5A1_F6B8_11D3_B6CE_525400E2D57B__INCLUDED_) +#define AFX_LINKEXITSDIALOG_H__02AEC5A1_F6B8_11D3_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// LinkExitsDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CLinkExitsDialog dialog + +class CLinkExitsDialog : public CDialog +{ +// Construction +public: + int RetrieveLink(CEdit &edit); + void DisplayLink(CEdit &edit, int link); + static int initNorthExit, initEastExit, initSouthExit, initWestExit; + static int initUpExit, initDownExit, initExitExit; + + CLinkExitsDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CLinkExitsDialog) + enum { IDD = IDD_LINKEXITS }; + CEdit m_westExit; + CEdit m_upExit; + CEdit m_southExit; + CEdit m_northExit; + CEdit m_exitExit; + CEdit m_eastExit; + CEdit m_downExit; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CLinkExitsDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CLinkExitsDialog) + afx_msg void OnKillfocusNorthexit(); + afx_msg void OnKillfocusEastexit(); + afx_msg void OnKillfocusSouthexit(); + afx_msg void OnKillfocusWestexit(); + afx_msg void OnKillfocusUpexit(); + afx_msg void OnKillfocusDownexit(); + afx_msg void OnKillfocusExitexit(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LINKEXITSDIALOG_H__02AEC5A1_F6B8_11D3_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/MainFrm.cpp b/Tools/LevelEditor/Source/MainFrm.cpp new file mode 100644 index 0000000..12f5b45 --- /dev/null +++ b/Tools/LevelEditor/Source/MainFrm.cpp @@ -0,0 +1,237 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "LevelEditor.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_WM_CREATE() + ON_WM_SETFOCUS() + ON_COMMAND(MENU_RED, OnRed) + ON_COMMAND(MENU_BLACK, OnBlack) + ON_COMMAND(MENU_BLUE, OnBlue) + ON_COMMAND(MENU_WHITE, OnWhite) + ON_COMMAND(MENU_YELLOW, OnYellow) + ON_COMMAND(MENU_GRAY, OnGray) + ON_COMMAND(GRID_BLACK, OnGridBlack) + ON_COMMAND(GRID_RED, OnGridRed) + ON_COMMAND(GRID_WHITE, OnGridWhite) + ON_COMMAND(MENU_GREEN, OnGreen) + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here + +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + // create a view to occupy the client area of the frame + if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, + CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) + { + TRACE0("Failed to create view window\n"); + return -1; + } + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + // TODO: Delete these three lines if you don't want the toolbar to + // be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + this->ShowWindow(SW_SHOWMAXIMIZED); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + cs.dwExStyle &= ~WS_EX_CLIENTEDGE; + cs.lpszClass = AfxRegisterWndClass(0); + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers +void CMainFrame::OnSetFocus(CWnd* pOldWnd) +{ + // forward focus to the view window + m_wndView.SetFocus(); +} + +BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) +{ + // let the view have first crack at the command + if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) + return TRUE; + + // otherwise, do default handling + return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); +} + + CChildView m_wndView; + + +void CMainFrame::OnRed() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0x000022); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnBlack() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0x000000); + (m_wndView.GrabWinMap())->InvalidateRect(0); +} + +void CMainFrame::OnBlue() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0x220000); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnWhite() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0xffffff); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnYellow() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0x002222); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnGray() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setBackgroundColor(0x222222); + (m_wndView.GrabWinMap())->InvalidateRect(0); + + +} + +void CMainFrame::OnGridBlack() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setGridColor(0x010101); + (m_wndView.GrabWinMap())->InvalidateRect(0); + + +} + +void CMainFrame::OnGridRed() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setGridColor(0x0000ff); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnGridWhite() +{ + // TODO: Add your command handler code here + (m_wndView.GrabWinMap())->setGridColor(0xffffff); + (m_wndView.GrabWinMap())->InvalidateRect(0); + +} + +void CMainFrame::OnGreen() //background green +{ + (m_wndView.GrabWinMap())->setBackgroundColor(0x002200); + (m_wndView.GrabWinMap())->InvalidateRect(0); + + +} + +void CMainFrame::ShowStatus(char *st) +{ + m_wndStatusBar.SetWindowText(st); +} + +void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +ASSERT(0); + CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags); +} diff --git a/Tools/LevelEditor/Source/MainFrm.h b/Tools/LevelEditor/Source/MainFrm.h new file mode 100644 index 0000000..173a5b6 --- /dev/null +++ b/Tools/LevelEditor/Source/MainFrm.h @@ -0,0 +1,74 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__CA2832C8_B4C7_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_MAINFRM_H__CA2832C8_B4C7_11D3_958B_00A0CC533895__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "ChildView.h" + +class CMainFrame : public CFrameWnd +{ + +public: + CMainFrame(); +protected: + DECLARE_DYNAMIC(CMainFrame) + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); + //}}AFX_VIRTUAL + +// Implementation +public: + void ShowStatus(char *st); + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + CChildView m_wndView; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSetFocus(CWnd *pOldWnd); + afx_msg void OnRed(); + afx_msg void OnBlack(); + afx_msg void OnBlue(); + afx_msg void OnWhite(); + afx_msg void OnYellow(); + afx_msg void OnGray(); + afx_msg void OnGridBlack(); + afx_msg void OnGridRed(); + afx_msg void OnGridWhite(); + afx_msg void OnGreen(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__CA2832C8_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/MapWin.cpp b/Tools/LevelEditor/Source/MapWin.cpp new file mode 100644 index 0000000..1a5f751 --- /dev/null +++ b/Tools/LevelEditor/Source/MapWin.cpp @@ -0,0 +1,1658 @@ +// MapWin.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "MapWin.h" +#include "Controls.h" +#include "ChildView.h" +#include +#include +#include "MainFrm.h" +#include + + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#include "ChildView.h" +#include "Controls.h" +#include "WayPointList.h" + + +///////////////////////////////////////////////////////////////////////////// +// CMapWin + +CMapWin::CMapWin() +{ + + // Member initializations + showGrids = false; + backgroundColor = 0x808080; + gridColor = 0x0000ff; + curTile = 0; + for(int i=0;i<256;i++) + for(int j=0;j<256;j++) + envArray[i][j].index = 0; + + totalTilesUsed = 1; + for(i=0;i<=256;i++) + listOfTilesUsed[i] = -1; + for(i=0;i<65536;i++) + listOfAllTiles[i] = 0; + + lmb_isDown = rmb_isDown = 0; + drawingPath = 0; + selectedZone = 1; + pathStartX = pathStartY = 0; + + clearLevel(); + + gkWinShape buffer; + buffer.LoadBMP("exitTiles.bmp"); + for(i=0; i<7; i++){ + exitTiles[i+1].GetShape(&buffer,i*16,0,16,16); + exitTiles[i+1].SetAlpha(192); + } + copyWidth = copyHeight = 0; +} + +CMapWin::~CMapWin() +{ +} + + +BEGIN_MESSAGE_MAP(CMapWin, CWnd) + //{{AFX_MSG_MAP(CMapWin) + ON_WM_PAINT() + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() + ON_WM_RBUTTONDOWN() + ON_WM_SIZE() + ON_WM_HSCROLL() + ON_WM_VSCROLL() + ON_WM_LBUTTONUP() + ON_WM_MOUSEMOVE() + ON_WM_RBUTTONUP() + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CMapWin message handlers + +void CMapWin::OnPaint() +{ + //MODIFIED 12.30.1999 ABE + CPaintDC realdc(this); // device context for painting + + //get client window size MOVED 12.30.1999 ABE + CRect rect; + ::GetClientRect(this->m_hWnd,&rect); + + //NEW 12.30.1999 ABE + //variables for double-buffering + //static CBitmap backbuffer; + static int backbufferWidth=0, backbufferHeight=0, needSetup=1; + static gkWinShape tileBuffer; + static gkWinShape wayPoint; + + if(needSetup){ + //Create orange dot waypoint + needSetup = 0; + wayPoint.Create(16,16); + wayPoint.Cls(); + wayPoint.RectFill(5,5,6,6,gkRGB(255,128,0)); + wayPoint.SetColorAlpha(gkRGB(0,0,0), 0); + } + + //check to see if we need to (re)create bitmap + if(backbufferWidth < rect.Width() || backbufferHeight < rect.Height()){ + backbufferWidth = rect.Width(); + backbufferHeight = rect.Height(); + //if(backbuffer.GetSafeHandle() != 0){ + // backbuffer.DeleteObject(); + //} + //backbuffer.CreateCompatibleBitmap(&realdc, backbufferWidth, backbufferHeight); + tileBuffer.Create(backbufferWidth, backbufferHeight); + } + + //create a temporary device context & select the bitmap into it for drawing + //CDC dc; + //dc.CreateCompatibleDC(0); + //CBitmap *oldBitmap = (CBitmap*) dc.SelectObject(&backbuffer); + //END NEW + + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + // how many tiles by X? + int numX; + //how many tiles by Y? + int numY; + + numX = (rect.Width()>>4) + 1; + numY = (rect.Height()>>4) + 1; + + //see how far the screen is scrolled over + int tileOff_x = controls->GetOffsetX() >> 4; + int tileOff_y = controls->GetOffsetY() >> 4; + + //dc.FillSolidRect(0,0, rect.Width(), rect.Height(), backgroundColor); + tileBuffer.Cls(gkRGB(backgroundColor&0xff,(backgroundColor>>8)&0xff, + (backgroundColor>>16)&0xff)); + + //figure out how far to scoot each tile to the left because of scrolling + int pixOff_x = controls->GetOffsetX() & 15; + int pixOff_y = controls->GetOffsetY() & 15; + + + + //go ahead and draw the environment tiles + + //blit all the tiles to the tile backbuffer (to allow for transparency etc) + //then blit the tile backbuffer to the regular backbuffer + for(int i=0;i=controls->GetMapWidth() || tj>=controls->GetMapHeight()){ + continue; + } + + int dx = (i<<4)-pixOff_x; + int dy = (j<<4)-pixOff_y; + + if(controls->GetDrawingZones()==-1){ + if(envArray[i+tileOff_x][j+tileOff_y].index){ + //envArray[i+tileOff_x][j+tileOff_y].pic-> + //BlitToDC(&dc,(i<<4)-pixOff_x,(j<<4)-pixOff_y); + envArray[ti][tj].pic->Blit(&tileBuffer, dx, dy, 0); + } + + if(controls->GetDrawingExits()>0){ //overlay exit if necessary + if(exitArray[ti][tj]) + exitTiles[exitArray[ti][tj]].Blit(&tileBuffer,dx,dy); + }else{ + //flag too much open space + if(tooMuchOpenSpace[i+tileOff_x][j+tileOff_y]==1){ + tileBuffer.RectFillAlpha(dx, dy, 16, 16, gkRGB(128,0,0), 128); + } + } + }else{ + if(envArray[i+tileOff_x][j+tileOff_y].index){ + //envArray[i+tileOff_x][j+tileOff_y].pic-> + //BlitToDC(&dc,(i<<4)-pixOff_x,(j<<4)-pixOff_y); + envArray[ti][tj].pic->BlitHalfBrite(&tileBuffer, dx, dy, 0); + } + + //blit the zone if necessary + if(controls->GetDrawingZones()>-1){ + int color = CZoneList::GetZoneColor(zoneArray[ti][tj]); + //tileBuffer.RectFillAlpha(dx, dy, 16, 16, gkRGB(0,0,0), 128); + int r= color & 0xff; + int g = (color>>8) & 0xff; + int b = (color>>16) & 0xff; + tileBuffer.RectFillAlpha(dx, dy, 16, 16, gkRGB(r,g,b), 128); + } + + } + + + } + } + + //draw WayPoints + if(controls->GetDrawingZones()>-1){ + int nPoints = g_wayPointList.GetNumWayPoints(); + + int n; + for(n=1; n<=nPoints; n++){ + int p = g_wayPointList.GetWayPoint(n); + + int i = p & 0xff; + int j = (p>>8) & 0xff; + int dx = (i<<4) - controls->GetOffsetX(); + int dy = (j<<4) - controls->GetOffsetY(); + wayPoint.Blit(&tileBuffer, dx, dy); + } + } + + // show grids if showGrids is true + if(showGrids){ + + //CPen gridPen; + //if(!gridPen.CreatePen(PS_SOLID,1,gridColor)) + //{ + // //doh! + // ::AfxMessageBox("Pen Creation Failed drawing grids", MB_OK); + // ::AfxAbort(); + //} + + gkRGB lineColor; + lineColor.SetR(gridColor & 0xff); + lineColor.SetG((gridColor>>8) & 0xff); + lineColor.SetB((gridColor>>16) & 0xff); + + //save the old pen + //CPen* oldPen = dc.SelectObject(&gridPen); + + int off_x = controls->GetOffsetX(); + int off_y = controls->GetOffsetY(); + + //draw vertical lines + for(int i=0;i<(controls->GetMapWidth() + 1);i++) + { + tileBuffer.Line((i<<4)-off_x,0,(i<<4)-off_x,rect.Height(),lineColor); + //dc.MoveTo((i<<4)-off_x,0); + //dc.LineTo((i<<4)-off_x,rect.Height()); + } + //draw Horizontal lines + for(i=0;i<(controls->GetMapHeight() + 1);i++) + { + tileBuffer.Line(0,(i<<4)-off_y,rect.Width(),(i<<4)-off_y,lineColor); + //dc.MoveTo(0, (i<<4)-off_y); + //dc.LineTo(rect.Width(), (i<<4)-off_y); + } + + + //reset old pen + //dc.SelectObject(oldPen); + + }// end if(showGrids) + + + + //if we're currently drawing a path then draw just the path so far + if(drawingPath){ + this->DrawPath(selectedZone, drawingPath, tileBuffer); + }else{ + //draw all the paths that originate at the selected zone + if(selectedZone && controls->GetDrawingZones()>-1){ + int otherZone; + for(otherZone=1; otherZone<16; otherZone++){ + int path = g_wayPointList.GetPath(selectedZone, otherZone); + if(path){ + this->DrawPath(otherZone, path, tileBuffer); + } + } + } + } + + //if we're doing a selection rectangle then draw that + if(drawingRect){ + if(controls->GetDrawingZones()!=0){ + int sx = min(rectStartX,rectEndX)<<4; + int sy = min(rectStartY,rectEndY)<<4; + int dx = (max(rectStartX,rectEndX)<<4)+15; + int dy = (max(rectStartY,rectEndY)<<4)+15; + sx -= controls->GetOffsetX(); + dx -= controls->GetOffsetX(); + sy -= controls->GetOffsetY(); + dy -= controls->GetOffsetY(); + gkRGB color = gkRGB(255,255,255); + int curZone = controls->GetDrawingZones(); + if(curZone>0){ + int c = CZoneList::GetZoneColor(curZone); + color.SetR(c&0xff); + color.SetG((c>>8)&0xff); + color.SetB((c>>16)&0xff); + } + tileBuffer.RectFillAlpha(sx,sy,(dx-sx)+1, (dy-sy)+1, color, 128); + }else{ + //moving a waypoint + int sx = rectStartX<<4; + int sy = rectStartY<<4; + int dx = rectEndX<<4; + int dy = rectEndY<<4; + sx -= controls->GetOffsetX(); + dx -= controls->GetOffsetX(); + sy -= controls->GetOffsetY(); + dy -= controls->GetOffsetY(); + gkRGB color = gkRGB(255,255,255); + tileBuffer.Line(sx+7,sy+7,dx+7,dy+7,color); + wayPoint.Blit(&tileBuffer, dx, dy); + } + } + + tileBuffer.BlitToDC(&realdc, 0, 0); + + + //NEW 12.30.1999 ABE + //Blit the backbuffer to the screen + //realdc.BitBlt(0,0,rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY); + + //take bitmap out of temporary DC before the tempDC is destroyed + //dc.SelectObject(oldBitmap); + //END NEW + + // Do not call CWnd::OnPaint() for painting messages +} + +void CMapWin::SetGrids(bool on){ + showGrids = on; + this->InvalidateRect(0); +} + + +BOOL CMapWin::OnEraseBkgnd(CDC* pDC) +{ + // TODO: Add your message handler code here and/or call default + return true; + + //return CWnd::OnEraseBkgnd(pDC); +} + + +int CMapWin::getBackgroundColor(){ + return backgroundColor; +} + + +void CMapWin::setBackgroundColor(int color) +{ + backgroundColor = color; +} + +void CMapWin::setGridColor(int color) +{ + gridColor = color; +} + +void CMapWin::getEnvArray(PicStruct arg[256][256]) +{ + for(int i=0;i<256;i++) + for(int j=0;j<256;j++) + arg[i][j] = envArray[i][j]; +} +unsigned char CMapWin::getTotalTilesUsed() +{ + return totalTilesUsed; +} + +short int* CMapWin::getListOfTilesUsed() +{ + return listOfTilesUsed; +} + +//load a level from the file + +void CMapWin::loadLevel(char *str){ + + ifstream input(str, ios::in | ios::binary | ios::nocreate); + //unsigned char trash;//used to through away unnecessary info on reads + int i; + CControls *controls; + + controls = (CControls*)(((CChildView*)this->GetParent())->GrabControls()); + + if(input.fail()){ + this->MessageBox("Could not open file"); + return; + } + + //clear the current level + clearLevel(); + + // Member initializations + showGrids = false; + curTile = 0; + + int firstCharacterID = (E_TILEBMPSIZEX >> 4) * (E_TILEBMPSIZEY >> 4); + + int version = input.get() & 0xff; + //------------load in total classes used----------------------- + input.read(&totalTilesUsed, sizeof(unsigned char)); + totalTilesUsed++;//must add 1 to compensate for 0 index + //--------------throw away 1rst character index---------------- + int firstCharacterIndex = input.get() & 0xff; + int oldFirstID = (input.get() & 0xff); + oldFirstID |= (input.get() & 0xff) << 8; + + //----------------read monster list into listOfTilesUsed------- + for(i=1;i=firstCharacterIndex){ + listOfTilesUsed[i] += (firstCharacterID - oldFirstID); + } + } + //-------------------set up listOfAllTiles---------------------- + for(i=0;i<256;i++) + if(listOfTilesUsed[i] != -1) + listOfAllTiles[listOfTilesUsed[i]] = 1; + //----------------read level width----------------------------- + unsigned char width; + input.read(&width,sizeof(unsigned char)); + controls->SetMapWidth(width); + //----------------get pitch----------------------------- + int pitch = input.get() & 0xff; + g_wayPointList.SetPitch(pitch); + //-----------------read level height--------------------------- + unsigned char height; + input.read(&height,sizeof(unsigned char)); + controls->SetMapHeight(height); + //-----------------read in level-------------------------------- + for(i=0;iGrabPicAt(listOfTilesUsed[envArray[j][i].index]); + } + //-------------------get the backgruond color------------------- + int bgByte0 = input.get() & 0xff; + int bgByte1 = input.get() & 0xff; + int bgColor = (bgByte1<<8) | bgByte0; + int bg_r = (bgColor & 0x1f) << 3; + int bg_g = ((bgColor>>5) & 0x1f) << 3; + int bg_b = ((bgColor>>10) & 0x1f) << 3; + backgroundColor = (bg_b << 16) | (bg_g << 8) | (bg_r); + + g_wayPointList.Read(input); + + ReadZones(input); + + if(version>=2){ + ReadExits(input); + } + + if(version>=3){ + //read links + input.get(); //1st link always null + input.get(); + for(i=1; i<8; i++){ + int n = (input.get() & 0xff); + n |= (input.get() & 0xff) << 8; + controls->links[i] = n; + } + } + + //be a good poopy + input.close(); + this->SetScrollBarPositions(); + this->InvalidateRect(0); + FlagTooMuchOpenSpace(); + +} + +//we need to remap all the monsters so that listOfTilesUsed is in decending order +void CMapWin::remapMonsters() +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + //----get the ID of the first monster-------------------------------- + short int firstCharacterID; + firstCharacterID = (E_TILEBMPSIZEX >> 4) * (E_TILEBMPSIZEY >> 4); + + //----initialize the sort data-------------------------------------- + unsigned char tempArray[257]; + SwapStruct SortMeArray[257]; + int i,j; + + for(i = 0; i<=256; i++) + { + SortMeArray[i].index = i; + SortMeArray[i].classID = listOfTilesUsed[i]; + } + + + if(controls->GetSortClassesBy()==0){ + //sort linear low to high + //--------------bubble sort here... hehehe ------------------------- + + for(i=0;i<=totalTilesUsed;i++) + { + for( j=0;j<(totalTilesUsed-1);j++) + { + if(SortMeArray[j].classID > SortMeArray[j+1].classID) + {//SWAP!! + SwapStruct tmp; + tmp.classID = SortMeArray[j].classID; + tmp.index = SortMeArray[j].index; + SortMeArray[j].classID = SortMeArray[j+1].classID; + SortMeArray[j].index = SortMeArray[j+1].index; + SortMeArray[j+1].classID = tmp.classID; + SortMeArray[j+1].index = tmp.index; + } + } + } + }else{ + //keep same order except all monsters after all bg tiles + for(i=0;i<=totalTilesUsed;i++) + { + for( j=0;j<(totalTilesUsed-1);j++) + { + if(SortMeArray[j].classID>=firstCharacterID && SortMeArray[j+1].classIDGetMapWidth();i++) + for(j=0;jGetMapHeight();j++) + if(envArray[i][j].index) + envArray[i][j].index = tempArray[envArray[i][j].index]; + +} + +//Clear the level and start fresh... +void CMapWin::clearLevel() +{ + // Member initializations + showGrids = false; + backgroundColor = 0x808080; + gridColor = 0x0000ff; + curTile = 0; + for(int i=0;i<256;i++){ + for(int j=0;j<256;j++){ + envArray[i][j].index = 0; + zoneArray[i][j] = 1; + exitArray[i][j] = 0; + } + } + + totalTilesUsed = 1; + for(i=0;i<=256;i++) + listOfTilesUsed[i] = -1; + for(i=0;i<65536;i++) + listOfAllTiles[i] = 0; + + drawingPath=0; + pathStartX=0; + pathStartY=0; + selectedZone=0; + drawingRect = 0; + + g_wayPointList.Reset(); +} + +//-------------------------------------------------------------------------- +// Mouse Methods +//-------------------------------------------------------------------------- + +void CMapWin::OnRButtonDown(UINT nFlags, CPoint point) +{ + rmb_isDown = 1; + + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = (CControls*) view->GrabControls(); + + if(controls->GetDrawingZones()!=0){ + this->EraseTile(point); + }else{ + //screwing around with path stuff + CPoint tPoint = point; + tPoint.x += controls->GetOffsetX(); + tPoint.y += controls->GetOffsetY(); + + int i = tPoint.x >> 4; + int j = tPoint.y >> 4; + + if(i >= controls->GetMapWidth()) + return; + if(j >= controls->GetMapHeight()) + return; + + if(drawingPath==0){ + //start drawing a path? + if(!g_wayPointList.WayPointExists(i,j)){ + pathStartX = i; + pathStartY = j; + selectedZone = zoneArray[i][j]; + drawingPath = g_wayPointList.BeginPath(selectedZone); + }else{ + //delete waypoint + g_wayPointList.RemoveWayPoint(i,j); + } + this->InvalidateRect(0); + } + } + + CWnd::OnRButtonDown(nFlags, point); +} + + +void CMapWin::OnLButtonDown(UINT nFlags, CPoint point) +{ + this->SetFocus(); + + lmb_isDown = 1; + + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = (CControls*) view->GrabControls(); + + if(controls->GetDrawingZones()!=0){ + if(::GetAsyncKeyState(VK_SHIFT) & 0x8000){ + drawingRect = 1; + rectStartX = (point.x + controls->GetOffsetX()) >> 4; + rectStartY = (point.y + controls->GetOffsetY()) >> 4; + rectEndX = rectStartX; + rectEndY = rectStartY; + + }else{ + this->PlaceCurrentTile(point); + FlagTooMuchOpenSpace(); + } + }else{ + //make a waypoint or add to a path + + //account for scrolling + CPoint tPoint = point; + tPoint.x += controls->GetOffsetX(); + tPoint.y += controls->GetOffsetY(); + + int i = tPoint.x >> 4; + int j = tPoint.y >> 4; + + + if(i >= controls->GetMapWidth()) + return; + if(j >= controls->GetMapHeight()) + return; + + if(drawingPath){ + if(g_wayPointList.WayPointExists(i,j)){ + g_wayPointList.AddWayPointToPath(i,j); + }else{ + int pathnum = g_wayPointList.EndPath(zoneArray[i][j]); + if(::GetAsyncKeyState(VK_SHIFT) & 0x8000){ //make a new path + //make a separate path that is the same w/o last waypoint + int wpcount = 0; + if(g_wayPointList.GetFirstWayPoint(pathnum)>0){ + wpcount++; + while(g_wayPointList.GetNextWayPoint(pathnum)>0) wpcount++; + } + drawingPath = g_wayPointList.BeginPath(selectedZone); + wpcount--; + + if(wpcount>0){ + g_wayPointList.AddWayPointToPath( + g_wayPointList.GetWayPoint(g_wayPointList.GetFirstWayPoint(pathnum))); + int x; + for(x=1; xInvalidateRect(0); + } + + //CWnd::OnLButtonDown(nFlags, point); +} + + +void CMapWin::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + this->SetScrollBarPositions(); + this->InvalidateRect(0); +} + +void CMapWin::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + SCROLLINFO scrollInfo; + scrollInfo.cbSize = sizeof(SCROLLINFO); + scrollInfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; + this->GetScrollInfo(SB_HORZ, &scrollInfo, SIF_ALL); + int pos = this->GetScrollPos(SB_HORZ); + + switch(nSBCode){ + case SB_LEFT: //Scroll to far left. + pos = 0; + break; + case SB_ENDSCROLL: //End scroll. + break; + case SB_LINELEFT: //Scroll left. + pos -= 128; + break; + case SB_LINERIGHT: //Scroll right. + pos += 128; + break; + case SB_PAGELEFT: //Scroll one page left. + pos -= (scrollInfo.nPage * 3) / 4; + break; + case SB_PAGERIGHT: //Scroll one page right. + pos += (scrollInfo.nPage * 3) / 4; + break; + case SB_RIGHT: //Scroll to far right. + pos = scrollInfo.nMax; + break; + case SB_THUMBPOSITION: //Scroll to absolute position + case SB_THUMBTRACK: + pos = nPos; + break; + } + + //adjust pos so it won't be out of bounds (looks nicer than letting win do it) + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + + int mapWidth = controls->GetMapWidth() * 16; + CRect rect; + this->GetClientRect(&rect); + if(pos<0){ + pos = 0; + }else if(pos + rect.Width() > mapWidth){ + pos = mapWidth - rect.Width(); + } + + + scrollInfo.nPos = pos; + this->SetScrollInfo(SB_HORZ, &scrollInfo, scrollInfo.fMask); + + controls->SetOffsetX(pos); + this->InvalidateRect(0); +} + +void CMapWin::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + SCROLLINFO scrollInfo; + scrollInfo.cbSize = sizeof(SCROLLINFO); + scrollInfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; + this->GetScrollInfo(SB_VERT, &scrollInfo, SIF_ALL); + int pos = this->GetScrollPos(SB_VERT); + + switch(nSBCode){ + case SB_LEFT: //Scroll to far left. + pos = 0; + break; + case SB_ENDSCROLL: //End scroll. + break; + case SB_LINELEFT: //Scroll left. + pos -= 128; + break; + case SB_LINERIGHT: //Scroll right. + pos += 128; + break; + case SB_PAGELEFT: //Scroll one page left. + pos -= (scrollInfo.nPage * 3) / 4; + break; + case SB_PAGERIGHT: //Scroll one page right. + pos += (scrollInfo.nPage * 3) / 4; + break; + case SB_RIGHT: //Scroll to far right. + pos = scrollInfo.nMax; + break; + case SB_THUMBPOSITION: //Scroll to absolute position + case SB_THUMBTRACK: + pos = nPos; + break; + } + + //adjust pos so it won't be out of bounds (looks nicer than letting win do it) + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + + int mapHeight = controls->GetMapHeight() * 16; + CRect rect; + this->GetClientRect(&rect); + if(pos<0){ + pos = 0; + }else if(pos + rect.Height() > mapHeight){ + pos = mapHeight - rect.Height(); + } + + + scrollInfo.nPos = pos; + this->SetScrollInfo(SB_VERT, &scrollInfo, scrollInfo.fMask); + + controls->SetOffsetY(pos); + this->InvalidateRect(0); + + CWnd::OnVScroll(nSBCode, nPos, pScrollBar); +} + +void CMapWin::SetScrollBarPositions() +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + CRect rect; + this->GetClientRect(&rect); + + int mapWidth = (controls->GetMapWidth() * 16); + int mapHeight = (controls->GetMapHeight() * 16); + int extraWidth = rect.Width() - mapWidth; + int extraHeight = rect.Height() - mapHeight; + + SCROLLINFO scrollInfo; + scrollInfo.cbSize = sizeof(SCROLLINFO); + + if(extraWidth>=0){ + //don't need the scroll bar + scrollInfo.fMask = SIF_POS | SIF_RANGE; + scrollInfo.nMin = scrollInfo.nMax = scrollInfo.nPos = 0; + this->SetScrollInfo(SB_HORZ, &scrollInfo, scrollInfo.fMask); + }else{ + scrollInfo.fMask = SIF_RANGE | SIF_PAGE; + scrollInfo.nMin = 0; + scrollInfo.nMax = mapWidth; + scrollInfo.nPos = 0; + scrollInfo.nPage = rect.Width(); + controls->SetOffsetX(this->GetScrollPos(SB_HORZ)); + this->SetScrollInfo(SB_HORZ, &scrollInfo, scrollInfo.fMask); + + } + + if(extraHeight>=0){ + scrollInfo.fMask = SIF_POS | SIF_RANGE; + scrollInfo.nMin = scrollInfo.nMax = scrollInfo.nPos = 0; + this->SetScrollInfo(SB_VERT, &scrollInfo, scrollInfo.fMask); + }else{ + scrollInfo.fMask = SIF_RANGE | SIF_PAGE; + scrollInfo.nMin = 0; + scrollInfo.nMax = mapHeight+15; + scrollInfo.nPos = 0; + scrollInfo.nPage = rect.Height(); + controls->SetOffsetY(this->GetScrollPos(SB_VERT)); + this->SetScrollInfo(SB_VERT, &scrollInfo, scrollInfo.fMask); + } +} + +void CMapWin::PlaceCurrentTile(CPoint point) +{ + + + CPoint originalPoint = point; + + + if(!::IsWindow(this->m_hWnd)) + return; + + //grab a pointer to the view + CChildView* papa; + papa = (CChildView*)this->GetParent(); + CControls *controls = papa->GrabControls(); + + //account for scrolling + point.x += controls->GetOffsetX(); + point.y += controls->GetOffsetY(); + + if((point.x>>4) >= controls->GetMapWidth()) + return; + if((point.y>>4) >= controls->GetMapHeight()) + return; + + if(controls->GetDrawingZones()==-1){ + if(controls->GetDrawingExits()==-1){ + int index = controls->GrabCurTileIndex(); + if(index==1){ + EraseTile(originalPoint); + controls->SetCurTilePointer(1); + return; + } + + int i,j; + int width = controls->metaWidth; + for(j=0; jmetaHeight; j++){ + for(i=0; i>4][point.y>>4] = controls->GetDrawingExits(); + } + }else if(controls->GetDrawingZones()>0){ + //drawing zones, not tiles: + int i = point.x>>4; + int j = point.y>>4; + zoneArray[i][j] = controls->GetDrawingZones(); + }else{ + //placing a waypoint + } + + this->InvalidateRect(0); +} + +void CMapWin::PlaceTile(int tileIndex, CPoint point) +{ + //grab a pointer to the view + CChildView* papa; + papa = (CChildView*)this->GetParent(); + CControls *controls = papa->GrabControls(); + + //lets see if we are placing a new tile + int whatsCurTile; + whatsCurTile = tileIndex; + + int tileExists = listOfAllTiles[whatsCurTile]; + if(controls->isWall){ + int i; + for(i=0; i<16; i++){ + if(!listOfAllTiles[whatsCurTile+i]) tileExists = 0; + } + } + + if(!tileExists) + {//looks like this is a new one :-) + if(totalTilesUsed > 256 || (controls->isWall && totalTilesUsed > 256-15)) + {//have we used 255 tiles yet? + this->MessageBox("You've used too many tiles Bitch Ass"); + return; + } + + if(!controls->isWall){ + listOfTilesUsed[totalTilesUsed++] = whatsCurTile; + listOfAllTiles[whatsCurTile] = 1; + }else{ + int i; + for(i=0; i<16; i++){ + listOfTilesUsed[totalTilesUsed++] = whatsCurTile + i; + listOfAllTiles[whatsCurTile + i] = 1; + } + } + } + + // find game index of tile + int tempIndex; + for(int i = 0; i < totalTilesUsed; i++){ + if(listOfTilesUsed[i] == whatsCurTile){ + tempIndex = i; + } + } + + int dx = point.x >> 4; + int dy = point.y >> 4; + + //if part of a wall, change the drawn index based on surrounding similar walls + int offsetOriginal=0; + int offset = 0; + + static int offsetRemap[16] = + { 0, 12, 1, 13, + 4, 8, 5, 9, + 3, 15, 2, 14, + 7, 11, 6, 10 + }; + + static int offsetRemapBack[16] = + { 0, 2, 10, 8, + 4, 6, 14, 12, + 5, 7, 15, 13, + 1, 3, 11, 9 + }; + + if(controls->isWall){ + if(dy > 0 && (((envArray[dx][dy-1].index - tempIndex) | 15) == 15)) offset |= 1; + if(dx < controls->GetMapWidth()-1 && (((envArray[dx+1][dy].index - tempIndex) | 15)) == 15) offset |= 2; + if(dy < controls->GetMapHeight()-1 && (((envArray[dx][dy+1].index - tempIndex) | 15)) == 15) offset |= 4; + if(dx > 0 && (((envArray[dx-1][dy].index - tempIndex) | 15) == 15)) offset |= 8; + + /* + { 0, 2, 10, 8, + 4, 6, 14, 12, + 5, 7, 15, 13, + 1, 3, 11, 9}; + */ + + offsetOriginal = offset; + offset = offsetRemap[offset]; + } + + //CHANGE grab real index from controls + envArray[dx][dy].index = (tempIndex+offset); + envArray[dx][dy].pic = papa->GrabControls()->GrabTilePointer(tileIndex+offset); + + //make sure adjacent similar walls are modified accordingly + if(offsetOriginal & 1){ + int off = offsetRemap[offsetRemapBack[envArray[dx][dy-1].index - tempIndex] | 4]; + envArray[dx][dy-1].index = tempIndex + off; + envArray[dx][dy-1].pic = controls->GrabTilePointer(tileIndex + off); + } + if(offsetOriginal & 2){ + int off = offsetRemap[offsetRemapBack[envArray[dx+1][dy].index - tempIndex] | 8]; + envArray[dx+1][dy].index = tempIndex + off; + envArray[dx+1][dy].pic = controls->GrabTilePointer(tileIndex + off); + } + if(offsetOriginal & 4){ + int off = offsetRemap[offsetRemapBack[envArray[dx][dy+1].index - tempIndex] | 1]; + envArray[dx][dy+1].index = tempIndex + off; + envArray[dx][dy+1].pic = controls->GrabTilePointer(tileIndex + off); + } + if(offsetOriginal & 8){ + int off = offsetRemap[offsetRemapBack[envArray[dx-1][dy].index - tempIndex] | 2]; + envArray[dx-1][dy].index = tempIndex + off; + envArray[dx-1][dy].pic = controls->GrabTilePointer(tileIndex + off); + } +} + +void CMapWin::OnLButtonUp(UINT nFlags, CPoint point) +{ + lmb_isDown = 0; + + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + if(drawingRect){ + + drawingRect = 0; + + if(controls->GetDrawingZones()!=0){ + { + int temp; + if(rectEndY < rectStartY){ + temp = rectStartY; + rectStartY = rectEndY; + rectEndY = temp; + } + if(rectEndX < rectStartX){ + temp = rectStartX; + rectStartX = rectEndX; + rectEndX = temp; + } + } + if(controls->areaSpecial==0){ //no special fx + //loop through every tile in the rect, drawing an item there + int i,j; + int lineToggle = 1; + for(j=rectStartY; j<=rectEndY; j+=controls->metaHeight){ + int toggle = lineToggle; + lineToggle ^= 1; + for(i=rectStartX; i<=rectEndX; i+=controls->metaWidth){ + CPoint curPoint; + if(!(::GetKeyState(VK_MENU) & 0x8000) || toggle){ + curPoint.x = (i<<4) - controls->GetOffsetX(); + curPoint.y = (j<<4) - controls->GetOffsetY(); + PlaceCurrentTile(curPoint); + } + toggle ^= 1; + } + } + FlagTooMuchOpenSpace(); + }else{ + //do a special effect in the rect + + //if paste force the rect to be at least as large as the copy size + if(controls->areaSpecial & 64){ + int width = rectEndX - rectStartX + 1; + int height = rectEndY - rectStartY + 1; + if(width < copyWidth) width = copyWidth; + if(height < copyHeight) height = copyHeight; + rectEndX = rectStartX + width - 1; + rectEndY = rectStartY + height - 1; + } + + //clip the rect first + if(rectStartX<0) rectStartX = 0; + if(rectStartY<0) rectStartY = 0; + if(rectEndX >= controls->GetMapWidth()) rectEndX = controls->GetMapWidth()-1; + if(rectEndY >= controls->GetMapHeight()) rectEndY = controls->GetMapHeight()-1; + + int i,j; + picstruct temp; + + if(controls->areaSpecial & 1){ //shift up + for(i=rectStartX; i<=rectEndX; i++){ + temp = envArray[i][rectStartY]; + for(j=rectStartY; jareaSpecial & 2){ //shift right + for(j=rectStartY; j<=rectEndY; j++){ + temp = envArray[rectEndX][j]; + for(i=rectEndX; i>rectStartX; i--){ + envArray[i][j] = envArray[i-1][j]; + } + envArray[rectStartX][j] = temp; + } + } + if(controls->areaSpecial & 4){ //shift down + for(i=rectStartX; i<=rectEndX; i++){ + temp = envArray[i][rectEndY]; + for(j=rectEndY; j>rectStartY; j--){ + envArray[i][j] = envArray[i][j-1]; + } + envArray[i][rectStartY] = temp; + } + } + if(controls->areaSpecial & 8){ //shift left + for(j=rectStartY; j<=rectEndY; j++){ + temp = envArray[rectStartX][j]; + for(i=rectStartX; iareaSpecial & 16){ //copy up (cut) + for(i=rectStartX; i<=rectEndX; i++){ + for(j=rectStartY; j<=rectEndY; j++){ + copyBuffer[i-rectStartX][j-rectStartY] = envArray[i][j]; + envArray[i][j].index = 0; + } + } + copyWidth = rectEndX - rectStartX + 1; + copyHeight = rectEndY - rectStartY + 1; + } + if(controls->areaSpecial & 32){ //copy right (copy) + for(i=rectStartX; i<=rectEndX; i++){ + for(j=rectStartY; j<=rectEndY; j++){ + copyBuffer[i-rectStartX][j-rectStartY] = envArray[i][j]; + } + } + copyWidth = rectEndX - rectStartX + 1; + copyHeight = rectEndY - rectStartY + 1; + } + if(controls->areaSpecial & 64){ //copy down (paste) + for(i=rectStartX; i<=rectEndX; i++){ + for(j=rectStartY; j<=rectEndY; j++){ + envArray[i][j] = copyBuffer[(i-rectStartX)%copyWidth][(j-rectStartY)%copyHeight]; + } + } + } + if(controls->areaSpecial & 128){ //copy left + for(i=rectStartX; i<=rectEndX; i++){ + for(j=rectStartY; j<=rectEndY; j++){ + int di = i - rectWidth; + int dj = j; + if(di<0||dj<0||di>255||dj>255) continue; + + envArray[di][dj] = envArray[i][j]; + } + } + } + } + }else{ + //moving waypoint + g_wayPointList.MoveWayPoint(rectStartX, rectStartY, rectEndX, rectEndY); + } + + this->InvalidateRect(0); + this->FlagTooMuchOpenSpace(); + } + + CWnd::OnLButtonUp(nFlags, point); +} + +void CMapWin::OnMouseMove(UINT nFlags, CPoint point) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + CMainFrame *frame = (CMainFrame*) this->GetParentFrame(); + + if(lmb_isDown){ + if(drawingRect){ + rectEndX = (point.x + controls->GetOffsetX())>>4; + rectEndY = (point.y + controls->GetOffsetY())>>4; + this->InvalidateRect(0); + }else{ + this->PlaceCurrentTile(point); + FlagTooMuchOpenSpace(); + } + }else if(rmb_isDown){ + this->EraseTile(point); + }else if(drawingPath){ + this->InvalidateRect(0); + } + + int i = (point.x + controls->GetOffsetX()) >> 4; + int j = (point.y + controls->GetOffsetY()) >> 4; + + char st[80]; + ostrstream stout(st,80); + stout << "(" << i << "," << j; + g_wayPointList.GetPitch(); + stout << " / $" << (hex) << (0xd000 + (j * g_wayPointList.GetPitch()) + i); + stout << (dec) << ") index: " << envArray[i][j].index; + stout << " class: " << listOfTilesUsed[envArray[i][j].index]; + stout << " zone: " << (int) zoneArray[i][j] << ends; + frame->ShowStatus(st); + + CWnd::OnMouseMove(nFlags, point); +} + +void CMapWin::EraseTile(CPoint point) +{ + if(!::IsWindow(this->m_hWnd)) + return; + //grab a pointer to the view + CControls *controls; + controls = (CControls*)(((CChildView*)this->GetParent())->GrabControls()); + + //account for scrolling + point.x += controls->GetOffsetX(); + point.y += controls->GetOffsetY(); + + int i = point.x>>4; + int j = point.y>>4; + if(i>=0 && j>=0 && iGetMapWidth() && jGetMapHeight()){ + if(controls->GetDrawingZones()==-1){ + if(controls->GetDrawingExits()==-1){ + int curIndex = envArray[i][j].index; + + if(curIndex>0){ + //set the current tile + controls->SetCurTilePointer(listOfTilesUsed[envArray[point.x>>4][point.y>>4].index]); + } + + //reset index to zero + envArray[point.x>>4][point.y>>4].index = 0; + }else{ + //erasing exits + exitArray[point.x>>4][point.y>>4] = 0; + } + }else if(!drawingPath){ + //"erase" selects a zone when drawing zones + this->selectedZone = zoneArray[i][j]; + this->pathStartX = i; + this->pathStartY = j; + } + } + + this->InvalidateRect(0); + FlagTooMuchOpenSpace(); +} + +void CMapWin::OnRButtonUp(UINT nFlags, CPoint point) +{ + rmb_isDown = 0; + + CWnd::OnRButtonUp(nFlags, point); +} + +void CMapWin::DrawPath(int destZone, int nPath, gkWinShape &tileBuffer) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + int c = CZoneList::GetZoneColor(destZone); + gkRGB color(c&0xff, (c>>8)&0xff, (c>>16)&0xff); + int prev_i = pathStartX; + int prev_j = pathStartY; + int next_i; + int next_j; + //CPoint tempP; + //if(::GetCursorPos(&tempP)){ +// if(tempP.x > 600) ASSERT(0); +// } + int afterFirst = 0; + int nextWP = g_wayPointList.GetFirstWayPoint(nPath); + while(nextWP){ + + int wp = g_wayPointList.GetWayPoint(nextWP); + next_i = wp & 0xff; + next_j = (wp>>8) & 0xff; + int si = (prev_i<<4) - controls->GetOffsetX() + (destZone&afterFirst); + int sj = (prev_j<<4) - controls->GetOffsetY() + (destZone&afterFirst); + int di = (next_i<<4) - controls->GetOffsetX() + destZone; + int dj = (next_j<<4) - controls->GetOffsetY() + destZone; + afterFirst = 0xffffffff; + + tileBuffer.Line(si,sj,di,dj,color); + + prev_i = next_i; + prev_j = next_j; + nextWP = g_wayPointList.GetNextWayPoint(nPath); + } + + //connect to mouse if currently drawing + if(drawingPath){ + CPoint mousePoint; + ::GetCursorPos(&mousePoint); + this->ScreenToClient(&mousePoint); + + int si = (prev_i<<4) - controls->GetOffsetX() + destZone; + int sj = (prev_j<<4) - controls->GetOffsetY() + destZone; + int di = mousePoint.x; + int dj = mousePoint.y; + + tileBuffer.Line(si,sj,di,dj,color); + } +} + +void CMapWin::WriteZones(ostream &out) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + //pack the zone bytes 2:1 + int compressed[128][256]; + int i,j; + for(j=0; jGetMapHeight(); j++){ + for(i=0; iGetMapWidth(); i+=2){ + int byte1 = this->zoneArray[i][j] & 0x0f; + int byte2 = zoneArray[i+1][j] & 0x0f; + compressed[i/2][j] = (byte1<<4) | byte2; + } + } + + //write out zone info using RLE + int numContinuous = 0; + int continuousByte = compressed[0][0]; + for(j=0; jGetMapHeight(); j++){ + for(i=0; i<(controls->GetMapWidth()>>1); i++){ + if(compressed[i][j] == continuousByte){ + numContinuous++; + }else{ + out.put((char) numContinuous); + out.put((char) continuousByte); + continuousByte = compressed[i][j]; + numContinuous = 1; + } + if(numContinuous == 256){ + out.put((char) 255); + out.put((char) continuousByte); + numContinuous = 1; + } + } + } + out.put((char) numContinuous); + out.put((char) continuousByte); +// if(numContinuous != 0){ +// out.put((char) 0); +// out.put((char) 0); +// } +} + +void CMapWin::ReadZones(istream &in) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + //reads & inflates zones stored using Run Lengh Encoding and compressed 2:1 + int i,j,continuousByte,numContinuous; + + int temp = in.tellg(); + numContinuous = in.get() & 0xff; + if(in.eof()) return; + continuousByte = in.get() & 0xff; + + for(j=0; jGetMapHeight(); j++){ + for(i=0; iGetMapWidth(); i+=2){ + if(!numContinuous){ + numContinuous = in.get() & 0xff; + continuousByte = in.get() & 0xff; + } + zoneArray[i][j] = (continuousByte>>4) & 0x0f; + zoneArray[i+1][j] = continuousByte & 0x0f; + numContinuous--; + } + } + + //in.get(); //junk null terminator + //in.get(); +} + +short int * CMapWin::getListOfAllTiles() +{ + return this->listOfAllTiles; +} + +void CMapWin::RemakeListOfTilesUsed() +{ + //regenerates the tiles used list using the tiles from the map and the tiles + //in the list of all tiles. Called after the "classes used" dialog finishes. + + //first off flag any of the classes used in the map in the "listOfAllClasses" + //and convert the map indices into actual classes + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + int i,j; + for(i=0; i<256; i++){ + for(j=0; j<256; j++){ + if(envArray[i][j].index){ + if(iGetMapWidth() && jGetMapHeight()){ + listOfAllTiles[listOfTilesUsed[envArray[i][j].index]] = 1; + envArray[i][j].index = listOfTilesUsed[envArray[i][j].index]; + }else{ + envArray[i][j].index = 0; + } + } + } + } + + //clear the list of tiles used + totalTilesUsed = 1; + for(i=0;i<=256;i++) + listOfTilesUsed[i] = -1; + + //refresh the listOfTilesUsed from the listOfAllTiles + for(i=0; i<65536; i++){ + if(listOfAllTiles[i]){ + listOfTilesUsed[totalTilesUsed++] = i; + } + } + + //remap each location in the map back to an index + for(i=0; i<256; i++){ + for(j=0; j<256; j++){ + int lookfor = envArray[i][j].index; + if(lookfor){ + int n; + for(n=1; n<=totalTilesUsed; n++){ + if(listOfTilesUsed[n]==lookfor){ + envArray[i][j].index = n; + break; + } + } + } + } + } +} + +void CMapWin::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + controls->SendToKeyDown(nChar,nRepCnt,nFlags); + + CWnd::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CMapWin::WriteExits(ostream &out) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + //pack the exit bytes 2:1 + int compressed[128][256]; + int i,j; + for(j=0; jGetMapHeight(); j++){ + for(i=0; iGetMapWidth(); i+=2){ + int byte1 = this->exitArray[i][j] & 0x0f; + int byte2 = exitArray[i+1][j] & 0x0f; + compressed[i/2][j] = (byte1<<4) | byte2; + } + } + + //int temp = out.tellp(); + //char st[80]; + //ostrstream stout(st,80); + //stout << temp << ends; + //this->MessageBox(st); + + //write out exit info using RLE + int numContinuous = 0; + int continuousByte = compressed[0][0]; + for(j=0; jGetMapHeight(); j++){ + for(i=0; i<(controls->GetMapWidth()>>1); i++){ + if(compressed[i][j] == continuousByte){ + numContinuous++; + }else{ + out.put((char) numContinuous); + out.put((char) continuousByte); + continuousByte = compressed[i][j]; + numContinuous = 1; + } + if(numContinuous == 256){ + out.put((char) 255); + out.put((char) continuousByte); + numContinuous = 1; + } + } + } + + out.put((char) numContinuous); + out.put((char) continuousByte); + //if(numContinuous != 0){ + //out.put((char) 0); + //out.put((char) 0); + //} +} + +void CMapWin::ReadExits(istream &in) +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + + //reads & inflates zones stored using Run Lengh Encoding and compressed 2:1 + int i,j,continuousByte,numContinuous; + + //int temp = in.tellg(); + //char st[80]; + //ostrstream stout(st,80); + //stout << temp << ends; + //this->MessageBox(st); + + numContinuous = in.get() & 0xff; + if(in.eof()) return; + continuousByte = in.get() & 0xff; + + for(j=0; jGetMapHeight(); j++){ + for(i=0; iGetMapWidth(); i+=2){ + if(!numContinuous){ + numContinuous = in.get() & 0xff; + continuousByte = in.get() & 0xff; + } + exitArray[i][j] = (continuousByte>>4) & 0x0f; + exitArray[i+1][j] = continuousByte & 0x0f; + numContinuous--; + } + } + + //in.get(); //junk null terminator + //in.get(); +} + + + + +void CMapWin::FlagTooMuchOpenSpace() +{ + CChildView *view = (CChildView*) this->GetParent(); + CControls *controls = view->GrabControls(); + int width = controls->GetMapWidth(); + int height = controls->GetMapHeight(); + + int max_x = 18; + int max_y = 16; + + int count, start_i, start_j; + int i,j; + + //set all flags to zero + for(j=0; jtooMuchOpenSpace[i][j] = 0; + } + } + + //loop row by row + for(j=0; j=E_FIRSTOBJ){ + start_i = i; + count++; + } + }else{ + //continue finding open space + if(envArray[i][j].index==0 || listOfTilesUsed[envArray[i][j].index]>=E_FIRSTOBJ) count++; + else{ + if(count > max_x){ + while(start_i < i){ + tooMuchOpenSpace[start_i++][j] = 1; + } + } + count = 0; + } + } + } + } + + //loop again column by column + for(i=0; i=E_FIRSTOBJ){ + start_j = j; + count++; + } + }else{ + //continue finding open space + if(envArray[i][j].index==0 || listOfTilesUsed[envArray[i][j].index]>=E_FIRSTOBJ) count++; + else{ + if(count > max_y){ + while(start_j < j){ + tooMuchOpenSpace[i][start_j++] = 1; + } + } + count = 0; + } + } + } + } + +} diff --git a/Tools/LevelEditor/Source/MapWin.h b/Tools/LevelEditor/Source/MapWin.h new file mode 100644 index 0000000..db02490 --- /dev/null +++ b/Tools/LevelEditor/Source/MapWin.h @@ -0,0 +1,127 @@ +#if !defined(AFX_MAPWIN_H__CA2832D2_B4C7_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_MAPWIN_H__CA2832D2_B4C7_11D3_958B_00A0CC533895__INCLUDED_ + + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MapWin.h : header file +// + +#include "wingk.h" +#include "EditDefines.h" + + +///////////////////////////////////////////////////////////////////////////// +// CMapWin window + +class CMapWin : public CWnd +{ +// Construction +public: + CMapWin(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMapWin) + //}}AFX_VIRTUAL + +// Implementation +public: + void FlagTooMuchOpenSpace(); + void PlaceTile(int tileIndex, CPoint point); + void ReadExits(istream &in); + gkWinShape exitTiles[8]; + void WriteExits(ostream &out); + void RemakeListOfTilesUsed(); + short int * getListOfAllTiles(); + void ReadZones(istream &in); + void WriteZones(ostream &out); + void DrawPath(int destZone, int nPath, gkWinShape &tileBuffer); + void EraseTile(CPoint point); + void PlaceCurrentTile(CPoint point); + void SetScrollBarPositions(); + virtual ~CMapWin(); + + // Application specific public methods // + + void SetGrids(bool); + void setBackgroundColor(int color); + int getBackgroundColor(); + void setGridColor(int color); + void getEnvArray(PicStruct[256][256]); + unsigned char getTotalTilesUsed(); + short int* getListOfTilesUsed(); + void loadLevel(char*); + //sort the tiles in decending order for abe! + void remapMonsters(); + //clear the current level + void clearLevel(); + + // End Application specific pubilc methods // + + + // Generated message map functions +protected: + char tooMuchOpenSpace[256][256]; + PicStruct copyBuffer[256][256]; + int copyWidth, copyHeight; + int drawingRect, rectStartX, rectStartY, rectEndX, rectEndY; + int lmb_isDown, rmb_isDown; + int drawingPath, pathStartX, pathStartY; + int selectedZone; + +////// Application Specific Variables /////////// + bool showGrids; + + //current tile to be blitted + gkWinShape *curTile; + + //2-D array ofenvironment tiles + PicStruct envArray[256][256]; + + //2-D array of zone/attribute tiles + unsigned char zoneArray[256][256]; + unsigned char exitArray[256][256]; + + //background color + int backgroundColor; + int gridColor; + + //total number of tiles uesd + unsigned char totalTilesUsed; + short int listOfTilesUsed[257]; + short int listOfAllTiles[65536]; + +////// end App Specific Variables ///////////// + + + + //{{AFX_MSG(CMapWin) + afx_msg void OnPaint(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAPWIN_H__CA2832D2_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/ReadMe.txt b/Tools/LevelEditor/Source/ReadMe.txt new file mode 100644 index 0000000..0743c97 --- /dev/null +++ b/Tools/LevelEditor/Source/ReadMe.txt @@ -0,0 +1,94 @@ +======================================================================== + MICROSOFT FOUNDATION CLASS LIBRARY : LevelEditor +======================================================================== + + +AppWizard has created this LevelEditor application for you. This application +not only demonstrates the basics of using the Microsoft Foundation classes +but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your LevelEditor application. + +LevelEditor.dsp + This file (the project file) contains information at the project level and + is used to build a single project or subproject. Other users can share the + project (.dsp) file, but they should export the makefiles locally. + +LevelEditor.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + CLevelEditorApp application class. + +LevelEditor.cpp + This is the main application source file that contains the application + class CLevelEditorApp. + +LevelEditor.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +LevelEditor.clw + This file contains information used by ClassWizard to edit existing + classes or add new classes. ClassWizard also uses this file to store + information needed to create and edit message maps and dialog data + maps and to create prototype member functions. + +res\LevelEditor.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file LevelEditor.rc. + +res\LevelEditor.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. + + + +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CFrameWnd and controls all SDI frame features. + +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in LevelEditor.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + + + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named LevelEditor.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is +in a language other than the operating system's current language, you +will need to copy the corresponding localized resources MFC42XXX.DLL +from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, +and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. +For example, MFC42DEU.DLL contains resources translated to German.) If you +don't do this, some of the UI elements of your application will remain in the +language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tools/LevelEditor/Source/StdAfx.cpp b/Tools/LevelEditor/Source/StdAfx.cpp new file mode 100644 index 0000000..fd027ec --- /dev/null +++ b/Tools/LevelEditor/Source/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// LevelEditor.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/Tools/LevelEditor/Source/StdAfx.h b/Tools/LevelEditor/Source/StdAfx.h new file mode 100644 index 0000000..a97821b --- /dev/null +++ b/Tools/LevelEditor/Source/StdAfx.h @@ -0,0 +1,26 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__CA2832C6_B4C7_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_STDAFX_H__CA2832C6_B4C7_11D3_958B_00A0CC533895__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__CA2832C6_B4C7_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/TerrainTiles.cpp b/Tools/LevelEditor/Source/TerrainTiles.cpp new file mode 100644 index 0000000..dddb0ad --- /dev/null +++ b/Tools/LevelEditor/Source/TerrainTiles.cpp @@ -0,0 +1,237 @@ +// TerrainTiles.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "TerrainTiles.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#include "Controls.h" + +///////////////////////////////////////////////////////////////////////////// +// CTerrainTiles + +CTerrainTiles::CTerrainTiles() +{ +} + +CTerrainTiles::~CTerrainTiles() +{ +} + + +BEGIN_MESSAGE_MAP(CTerrainTiles, CWnd) + //{{AFX_MSG_MAP(CTerrainTiles) + ON_WM_PAINT() + ON_WM_HSCROLL() + ON_WM_VSCROLL() + ON_WM_RBUTTONDOWN() + ON_WM_LBUTTONDOWN() + ON_WM_CREATE() + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CTerrainTiles message handlers + +void CTerrainTiles::OnPaint() +{ + CPaintDC dc(this); // device context for painting + CControls* papa; + papa = (CControls*)this->GetParent(); + + // TODO: Add your message handler code here + //dc.FillSolidRect(0,0,100,100, 0x000000); + + (papa->GrabTileBuffer())->BlitToDC(&dc,-(this->GetScrollPos(SB_HORZ)), + -(this->GetScrollPos(SB_VERT))); + + int index = papa->GrabCurTileIndex(); + if(index<2047) index--; + int frame_x = ((index % 32) * 16) - this->GetScrollPos(SB_HORZ); + int frame_y = ((index / 32) * 16) - this->GetScrollPos(SB_VERT); + + CRect rect(frame_x, frame_y, frame_x+16, frame_y+16); + + + CBrush whiteBrush; + whiteBrush.Attach((HBRUSH) ::GetStockObject(WHITE_BRUSH)); + dc.FrameRect(rect,&whiteBrush); + whiteBrush.Detach(); + + + // Do not call CWnd::OnPaint() for painting messages +} + +void CTerrainTiles::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + + int pos = this->GetScrollPos(SB_HORZ); + + switch(nSBCode){ +//SB_LEFT + case SB_LINELEFT: + pos -= 16; + break; + case SB_LINERIGHT: + pos += 16; + break; + case SB_PAGELEFT: + pos -= 256; + break; + case SB_PAGERIGHT: + pos += 256; + break; + case SB_THUMBPOSITION: + ; + case SB_THUMBTRACK: + pos = nPos; + break; + default: + pos = pos; + } + + if(pos<0) pos = 0; + if(pos>(TERRAINSCROLLMAXH - 1)) pos = (TERRAINSCROLLMAXH - 1); + this->SetScrollPos(SB_HORZ, pos); + + this->InvalidateRect(0); +} + +void CTerrainTiles::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + + int pos = this->GetScrollPos(SB_VERT); + + switch(nSBCode){ + + case SB_LINELEFT: + pos -= 16; + break; + case SB_LINERIGHT: + pos += 16; + break; + case SB_PAGELEFT: + pos -= 64; + break; + case SB_PAGERIGHT: + pos += 64; + break; + case SB_THUMBPOSITION: + ; + case SB_THUMBTRACK: + pos = nPos; + break; + default: + pos = pos; + } + + if(pos<0) pos = 0; + if(pos>(TERRAINSCROLLMAXV - 1)) pos = (TERRAINSCROLLMAXV - 1); + this->SetScrollPos(SB_VERT, pos); + + + CWnd::OnVScroll(nSBCode, nPos, pScrollBar); + this->InvalidateRect(0); +} + +void CTerrainTiles::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default1 + CControls* papa; + int newCurTile; + + if(!::IsWindow(this->m_hWnd)) + return; + + //grab a pointer to the view + papa = (CControls*)this->GetParent(); + + + //set current tile from x position + newCurTile = (point.x + this->GetScrollPos(SB_HORZ)) >> 4; + //figure in y component of index + newCurTile += (32 * ((point.y + this->GetScrollPos(SB_VERT)) >> 4))+1; + if(newCurTile >= 2048) newCurTile--; + + papa->SetCurTilePointer(newCurTile); + papa->InvalidateRect(0); + + this->InvalidateRect(0); + + + CWnd::OnRButtonDown(nFlags, point); +} + +void CTerrainTiles::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + this->OnRButtonDown(nFlags, point); + CWnd::OnLButtonDown(nFlags, point); +} + +int CTerrainTiles::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + return 0; +} + +void CTerrainTiles::SetScrollBarPositions() +{ + CRect rect; + this->GetClientRect(&rect); + + int mapWidth = TERRAINSCROLLMAXH; + int mapHeight = TERRAINSCROLLMAXV; + int extraWidth = rect.Width() - mapWidth; + int extraHeight = rect.Height() - mapHeight; + + SCROLLINFO scrollInfo; + scrollInfo.cbSize = sizeof(SCROLLINFO); + + if(extraWidth>=0){ + //don't need the scroll bar + scrollInfo.fMask = SIF_POS | SIF_RANGE; + scrollInfo.nMin = scrollInfo.nMax = scrollInfo.nPos = 0; + this->SetScrollInfo(SB_HORZ, &scrollInfo, scrollInfo.fMask); + }else{ + scrollInfo.fMask = SIF_RANGE | SIF_PAGE; + scrollInfo.nMin = 0; + scrollInfo.nMax = mapWidth-1; + scrollInfo.nPos = 0; + scrollInfo.nPage = rect.Width(); + this->SetScrollInfo(SB_HORZ, &scrollInfo, scrollInfo.fMask); + + } + + if(extraHeight>=0){ + scrollInfo.fMask = SIF_POS | SIF_RANGE; + scrollInfo.nMin = scrollInfo.nMax = scrollInfo.nPos = 0; + this->SetScrollInfo(SB_VERT, &scrollInfo, scrollInfo.fMask); + }else{ + scrollInfo.fMask = SIF_RANGE | SIF_PAGE; + scrollInfo.nMin = 0; + scrollInfo.nMax = mapHeight-1; + scrollInfo.nPos = 0; + scrollInfo.nPage = rect.Height(); + this->SetScrollInfo(SB_VERT, &scrollInfo, scrollInfo.fMask); + } +} + +void CTerrainTiles::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + SetScrollBarPositions(); +} diff --git a/Tools/LevelEditor/Source/TerrainTiles.h b/Tools/LevelEditor/Source/TerrainTiles.h new file mode 100644 index 0000000..d46d8ea --- /dev/null +++ b/Tools/LevelEditor/Source/TerrainTiles.h @@ -0,0 +1,58 @@ +#if !defined(AFX_TERRAINTILES_H__5105A4C0_BC7B_11D3_958B_00A0CC533895__INCLUDED_) +#define AFX_TERRAINTILES_H__5105A4C0_BC7B_11D3_958B_00A0CC533895__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// TerrainTiles.h : header file +// + + +#include "EditDefines.h" + + +///////////////////////////////////////////////////////////////////////////// +// CTerrainTiles window + +class CTerrainTiles : public CWnd +{ +// Construction +public: + CTerrainTiles(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTerrainTiles) + //}}AFX_VIRTUAL + +// Implementation +public: + void SetScrollBarPositions(); + virtual ~CTerrainTiles(); + + // Generated message map functions +protected: + //{{AFX_MSG(CTerrainTiles) + afx_msg void OnPaint(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TERRAINTILES_H__5105A4C0_BC7B_11D3_958B_00A0CC533895__INCLUDED_) diff --git a/Tools/LevelEditor/Source/TileLimitDialog.cpp b/Tools/LevelEditor/Source/TileLimitDialog.cpp new file mode 100644 index 0000000..2e90a4d --- /dev/null +++ b/Tools/LevelEditor/Source/TileLimitDialog.cpp @@ -0,0 +1,43 @@ +// TileLimitDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "TileLimitDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTileLimitDialog dialog + + +CTileLimitDialog::CTileLimitDialog(CWnd* pParent /*=NULL*/) + : CDialog(CTileLimitDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CTileLimitDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void CTileLimitDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CTileLimitDialog) + DDX_Control(pDX, IDC_LIMIT_TEXTBOX, m_selection); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CTileLimitDialog, CDialog) + //{{AFX_MSG_MAP(CTileLimitDialog) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTileLimitDialog message handlers diff --git a/Tools/LevelEditor/Source/TileLimitDialog.h b/Tools/LevelEditor/Source/TileLimitDialog.h new file mode 100644 index 0000000..f017be3 --- /dev/null +++ b/Tools/LevelEditor/Source/TileLimitDialog.h @@ -0,0 +1,46 @@ +#if !defined(AFX_TILELIMITDIALOG_H__A65950A1_6466_11D4_B6CE_525400E2D57B__INCLUDED_) +#define AFX_TILELIMITDIALOG_H__A65950A1_6466_11D4_B6CE_525400E2D57B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// TileLimitDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CTileLimitDialog dialog + +class CTileLimitDialog : public CDialog +{ +// Construction +public: + CTileLimitDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CTileLimitDialog) + enum { IDD = IDD_TILELIMIT }; + CButton m_selection; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTileLimitDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CTileLimitDialog) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TILELIMITDIALOG_H__A65950A1_6466_11D4_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/WayPointList.cpp b/Tools/LevelEditor/Source/WayPointList.cpp new file mode 100644 index 0000000..bbb2266 --- /dev/null +++ b/Tools/LevelEditor/Source/WayPointList.cpp @@ -0,0 +1,305 @@ +#include "WayPointList.h" + +WayPointList::WayPointList(){ + Reset(); + pitch = 32; +} + +WayPointList::~WayPointList(){ +} + +void WayPointList::Reset(){ + int i,j; + for(i=1; i<16; i++){ + for(j=1; j<16; j++){ + zoneMatrix[i][j] = 0; + } + } + + for(i=0; i<256; i++){ + for(j=0; j<32; j++){ + path[i][j] = 0; + } + } + + numWayPoints = 0; + numPaths = 0; + curPathStartZone = 0; +} + +void WayPointList::CreateWayPoint(int i, int j){ + if(numWayPoints==255) return; + + //don't create if it's a duplicate of existing + int wp = (j<<8) + i; + + int index; + for(index=1; index<=numWayPoints; index++){ + if(wayPoints[index]==wp) return; + } + + wayPoints[++numWayPoints] = wp; +} + +void WayPointList::RemoveWayPoint(int i, int j){ + int wp = (j<<8) + i; + + //find the index of the existing waypoint + int index; + for(index=1; index<=numWayPoints; index++){ + if(wayPoints[index] == wp) break; + } + if(index>numWayPoints) return; //wasn't there + + //delete all paths that included the deleted waypoint + int n,m; + for(n=1; n<=numPaths; n++){ + if(path[n][0]>0){ + for(m=0; m<32; m++){ + if(path[n][m]==index){ + RemovePath(n); + n--; + break; + } + } + } + } + + //delete the waypoint itself by switching it with the end waypoint + int replaceWith = numWayPoints--; + if(numWayPoints>0){ + wayPoints[index] = wayPoints[replaceWith]; + + //change all paths that use the replacer to use its new index + for(n=1; nnumWayPoints) return; + + //add waypoint index to path + int n; + for(n=0; n<32; n++){ + if(path[curPath][n] == 0){ + path[curPath][n] = index; + break; + } + } + */ +} + +void WayPointList::AddWayPointToPath(int waypoint){ + int wp = waypoint; + int index; + for(index=1; index<=numWayPoints; index++){ + if(wayPoints[index] == wp) break; + } + if(index>numWayPoints) return; + + //add waypoint index to path + int n; + for(n=0; n<32; n++){ + if(path[curPath][n] == 0){ + path[curPath][n] = index; + break; + } + } +} + +int WayPointList::EndPath(int endZone){ + //remove the old path + int oldPath = zoneMatrix[curPathStartZone][endZone]; + if(oldPath){ + int shifted = RemovePath(zoneMatrix[curPathStartZone][endZone]); + if(shifted==curPath){ + zoneMatrix[curPathStartZone][endZone] = oldPath; + }else{ + zoneMatrix[curPathStartZone][endZone] = curPath; + } + }else{ + zoneMatrix[curPathStartZone][endZone] = curPath; + } + return zoneMatrix[curPathStartZone][endZone]; +} + +int WayPointList::GetPathLength(int nPath){ + int length=0; + int i; + for(i=0; i<32; i++){ + if(path[nPath][i]==0) break; + length++; + } + return length; +} + +int WayPointList::GetPath(int startZone, int endZone){ + return zoneMatrix[startZone][endZone]; +} + +int WayPointList::GetFirstWayPoint(int npath){ + curReturnedWayPoint = 0; + return path[npath][0]; +} + +int WayPointList::WayPointExists(int i, int j){ + int wp = (j<<8) + i; + + int index; + for(index=0; index<=numWayPoints; index++){ + if(wayPoints[index]==wp) return 1; + } + return 0; +} + +int WayPointList::GetNextWayPoint(int npath){ + curReturnedWayPoint++; + if(curReturnedWayPoint==32) return 0; + return path[npath][curReturnedWayPoint]; +} + +void WayPointList::Write(ostream &out){ + out.put((char) numWayPoints); + if(!numWayPoints) return; + out.put((char) 0); + + //write waypoints (up to 255) + int i,j; + for(i=1; i<=numWayPoints; i++){ + int wp = wayPoints[i]; + int w_i = wp & 0xff; + int w_j = (wp >> 8) & 0xff; + wp = (0xd000 + w_j*pitch + w_i); + out.put((char) (wp & 0xff)); + out.put((char) ((wp>>8) & 0xff)); + } + + //write paths (up to 255 paths, 4 bytes each) + out.put((char) numPaths); + for(i=1; i<=numPaths; i++){ + for(j=0; j<4; j++){ + out.put((char) path[i][j]); + } + } + + //write zone matrix containing paths 16 x 16 = 256 bytes + for(j=0; j<16; j++){ + for(i=0; i<16; i++){ + out.put((char) zoneMatrix[i][j]); + } + } +} + +void WayPointList::Read(istream &in){ + Reset(); + + int pos = in.tellg(); + + numWayPoints = in.get(); //get num waypoints + numWayPoints &= 0xff; + + if(in.eof() || !numWayPoints){ + numWayPoints = 0; + return; + } + + in.get(); //discard pad + + //read waypoints + int i,j; + for(i=1; i<=numWayPoints; i++){ + int wp = in.get() & 0xff; + wp |= in.get() << 8; + wp &= 0xffff; + wp -= 0xd000; + int w_j = wp / pitch; + int w_i = wp % pitch; + wayPoints[i] = (w_j<<8) | w_i; + } + + //read paths + numPaths = in.get() & 0xff; + for(i=1; i<=numPaths; i++){ + for(j=0; j<4; j++){ + path[i][j] = in.get() & 0xff; + } + } + + //read zone matrix + for(j=0; j<16; j++){ + for(i=0; i<16; i++){ + zoneMatrix[i][j] = in.get() & 0xff; + } + } +} + + +//global declaration +WayPointList g_wayPointList; + diff --git a/Tools/LevelEditor/Source/WayPointList.h b/Tools/LevelEditor/Source/WayPointList.h new file mode 100644 index 0000000..531a298 --- /dev/null +++ b/Tools/LevelEditor/Source/WayPointList.h @@ -0,0 +1,62 @@ +#ifndef WAYPOINTLIST_H +#define WAYPOINTLIST_H + +#include + +class WayPointList{ + protected: + //Lookup zoneMatrix[i][j] to find out the index of the path list + //to go to to get from zone i to zone j. Upon saving each path list + //will be a linked list that may merge with another waypoint list. + //But in the editor it's just a list of waypoints up to 32 long. + int zoneMatrix[16][16]; + + //The contents of path[i] is a list of 32 indices to waypoints + //that a unit must travel. + int path[256][32]; + + //Each waypoint is a ((j<<8)+i) coordinate that will be + //$c000 + (j*pitch) + i upon saving + int wayPoints[256]; + + //up to 255 + int numWayPoints; + int numPaths; + int curPath; + int curPathStartZone; + int curReturnedWayPoint; + int pitch; + + public: + WayPointList(); + ~WayPointList(); + void Reset(); + void CreateWayPoint(int i, int j); + void RemoveWayPoint(int i, int j); + void MoveWayPoint(int si, int sj, int di, int dj); + int RemovePath(int n); + int BeginPath(int zone); + void AddWayPointToPath(int i, int j); + void AddWayPointToPath(int waypoint); + int EndPath(int endZone); + + int GetPathLength(int nPath); + int GetPath(int startZone, int endZone); + int WayPointExists(int i, int j); + int GetFirstWayPoint(int npath); + int GetNextWayPoint(int npath); + + inline void SetPitch(int p){ pitch = p; } + inline int GetPitch(){ return pitch; } + inline int GetNumPaths(){ return numPaths; } + inline int GetNumWayPoints(){ return numWayPoints; } + inline int GetWayPoint(int n){ return wayPoints[n]; } + + void Write(ostream &out); + void Read(istream &in); +}; + +extern WayPointList g_wayPointList; + +#endif + diff --git a/Tools/LevelEditor/Source/ZoneList.cpp b/Tools/LevelEditor/Source/ZoneList.cpp new file mode 100644 index 0000000..718b416 --- /dev/null +++ b/Tools/LevelEditor/Source/ZoneList.cpp @@ -0,0 +1,132 @@ +// ZoneList.cpp : implementation file +// + +#include "stdafx.h" +#include "LevelEditor.h" +#include "ZoneList.h" +#include "wingk.h" +#include "Controls.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CZoneList + +CZoneList::CZoneList() +{ + gkWinShape buffer; + buffer.LoadBMP("exitTiles.bmp"); + + int i; + for(i=0; i<7; i++) exitTiles[i+1].GetShape(&buffer, i*16, 0, 16, 16); +} + +CZoneList::~CZoneList() +{ +} + + +BEGIN_MESSAGE_MAP(CZoneList, CListBox) + //{{AFX_MSG_MAP(CZoneList) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CZoneList message handlers + +void CZoneList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + CControls *controls = (CControls*) this->GetParent(); + + CDC dc; + dc.Attach(lpDrawItemStruct->hDC); + + if(controls->GetDrawingExits()==-1){ + int color = this->GetZoneColor(lpDrawItemStruct->itemData); + + dc.FillSolidRect(&(lpDrawItemStruct->rcItem), + color); + + CBrush brush; + + CRect rect = lpDrawItemStruct->rcItem; + rect.DeflateRect(1,1); + + //Draw outline around selected + if(lpDrawItemStruct->itemState & ODS_SELECTED){ + + + if(color!=0){ + brush.Attach(GetStockObject(BLACK_BRUSH)); + dc.FrameRect(&rect,&brush); + }else{ + brush.Attach(GetStockObject(WHITE_BRUSH)); + dc.FrameRect(&rect,&brush); + } + + brush.Detach(); + + } + + //draw the orange dot that means waypoint + if(color==0){ + rect.DeflateRect(4,4); + //brush.CreateSolidBrush(0x0080ff); //orange brush + dc.FillSolidRect(&rect,0x0080ff); + } + }else{ + //drawing exits + int index = controls->MapIndexToExit(lpDrawItemStruct->itemID); + CRect rect = lpDrawItemStruct->rcItem; + exitTiles[index].BlitToDC(&dc,rect.left, rect.top); + + rect.DeflateRect(1,1); + + //Draw outline around selected + CBrush brush; + if(lpDrawItemStruct->itemState & ODS_SELECTED){ + brush.Attach(GetStockObject(WHITE_BRUSH)); + dc.FrameRect(&rect,&brush); + brush.Detach(); + } + } + + dc.Detach(); +} + +int CZoneList::GetZoneColor(int n) +{ + int color=0; + switch(n){ + case 0: break; + case 1: color = 0xffffff; break; //white + case 2: color = 0x8888ff; break; //pink + case 3: color = 0x0000ff; break; //red + case 4: color = 0x0088ff; break; //orange + case 5: color = 0x00ffff; break; //yellow + case 6: color = 0x004488; break; //brown + case 7: color = 0x88ff88; break; //bright green + case 8: color = 0x00ff00; break; //green + case 9: color = 0x008800; break; //dark green + case 10: color = 0xffff00; break; //cyan + case 11: color = 0xff8888; break; //light blue + case 12: color = 0xff0000; break; //royal blue + case 13: color = 0x880000; break; //dark blue + case 14: color = 0xff88ff; break; //light purple + case 15: color = 0xff00ff; break; //purple + } + return color; +} + +void CZoneList::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + //tell windows the dimensions of each member of our selection box + lpMeasureItemStruct->itemWidth = 16; + lpMeasureItemStruct->itemHeight = 16; + +} diff --git a/Tools/LevelEditor/Source/ZoneList.h b/Tools/LevelEditor/Source/ZoneList.h new file mode 100644 index 0000000..af7b832 --- /dev/null +++ b/Tools/LevelEditor/Source/ZoneList.h @@ -0,0 +1,56 @@ +#if !defined(AFX_ZONELIST_H__FF8F62A8_C532_11D3_B6CE_525400E2D57B__INCLUDED_) +#define AFX_ZONELIST_H__FF8F62A8_C532_11D3_B6CE_525400E2D57B__INCLUDED_ + +#include "wingk.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ZoneList.h : header file +// + +#include "wingk.h" + +///////////////////////////////////////////////////////////////////////////// +// CZoneList window + +class CZoneList : public CListBox +{ +// Construction +public: + CZoneList(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CZoneList) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); + //}}AFX_VIRTUAL + +// Implementation +public: + static int GetZoneColor(int n); + virtual ~CZoneList(); + + // Generated message map functions +protected: + gkWinShape exitTiles[8]; + //{{AFX_MSG(CZoneList) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ZONELIST_H__FF8F62A8_C532_11D3_B6CE_525400E2D57B__INCLUDED_) diff --git a/Tools/LevelEditor/Source/res/LevelEditor.ico b/Tools/LevelEditor/Source/res/LevelEditor.ico new file mode 100644 index 0000000..1776962 Binary files /dev/null and b/Tools/LevelEditor/Source/res/LevelEditor.ico differ diff --git a/Tools/LevelEditor/Source/res/LevelEditor.rc2 b/Tools/LevelEditor/Source/res/LevelEditor.rc2 new file mode 100644 index 0000000..b9fcc00 --- /dev/null +++ b/Tools/LevelEditor/Source/res/LevelEditor.rc2 @@ -0,0 +1,13 @@ +// +// LEVELEDITOR.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tools/LevelEditor/Source/res/Toolbar.bmp b/Tools/LevelEditor/Source/res/Toolbar.bmp new file mode 100644 index 0000000..627d86b Binary files /dev/null and b/Tools/LevelEditor/Source/res/Toolbar.bmp differ diff --git a/Tools/LevelEditor/Source/resource.h b/Tools/LevelEditor/Source/resource.h new file mode 100644 index 0000000..a6a29ed --- /dev/null +++ b/Tools/LevelEditor/Source/resource.h @@ -0,0 +1,83 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by LevelEditor.rc +// +#define IDD_ABOUTBOX 100 +#define IDR_MAINFRAME 128 +#define IDR_LEVELETYPE 129 +#define IDD_CONTROLS 130 +#define IDD_CLASS_LIST_DIALOG 132 +#define IDD_COLORPICKER 133 +#define IDD_LINKEXITS 134 +#define IDD_TILELIMIT 135 +#define IDC_SHOWGRIDS 1003 +#define IDC_CURTILE 1004 +#define IDC_WRITEFILE 1005 +#define IDC_SAVELEVEL 1006 +#define IDC_LOADME 1007 +#define IDC_LOAD 1008 +#define IDC_CLEAR 1011 +#define IDC_EDIT_WIDTH 1012 +#define IDC_EDIT_HEIGHT 1013 +#define IDC_ZONELIST 1018 +#define IDC_CLASS_LIST 1020 +#define IDC_BUTTON_CLASSLIST 1021 +#define IDC_BUTTON_LINKEXITS 1022 +#define IDC_LOAD_FILENAME 1023 +#define IDC_RADIO_TILES 1024 +#define IDC_RADIO_ZONES 1025 +#define IDC_COLOR 1025 +#define IDC_RADIO_EXITS 1026 +#define IDC_RED 1027 +#define IDC_GREEN 1028 +#define IDC_BGCOLOR 1028 +#define IDC_BLUE 1029 +#define IDC_META_WIDTH 1029 +#define IDC_META_HEIGHT 1030 +#define IDC_SETMETA_1X1 1031 +#define IDC_SETMETA_2X2 1032 +#define IDC_SETMETA_3x3 1033 +#define IDC_SHIFTUP 1034 +#define IDC_SHIFTRIGHT 1035 +#define IDC_NORTHEXIT 1035 +#define IDC_SHIFTDOWN 1036 +#define IDC_EASTEXIT 1036 +#define IDC_SHIFTLEFT 1037 +#define IDC_SOUTHEXIT 1037 +#define IDC_COPYUP 1038 +#define IDC_WESTEXIT 1038 +#define IDC_COPYRIGHT 1039 +#define IDC_UPEXIT 1039 +#define IDC_COPYDOWN 1040 +#define IDC_DOWNEXIT 1040 +#define IDC_COPYLEFT 1041 +#define IDC_EXITEXIT 1041 +#define IDC_WALLCHECK 1042 +#define IDC_SETMETA_4x4 1043 +#define IDC_CLASSLIST_CLEARALL 1043 +#define IDC_LIMIT_TEXTBOX 1044 +#define IDC_LIMIT_FONT 1045 +#define IDC_SORTCLASSESBY 1045 +#define IDC_LIMIT_NONE 1046 +#define MENU_RED 32771 +#define MENU_BLACK 32772 +#define MENU_BLUE 32773 +#define MENU_YELLOW 32774 +#define MENU_WHITE 32775 +#define MENU_GRAY 32776 +#define GRID_RED 32777 +#define GRID_BLACK 32778 +#define GRID_WHITE 32779 +#define MENU_GREEN 32780 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 136 +#define _APS_NEXT_COMMAND_VALUE 32781 +#define _APS_NEXT_CONTROL_VALUE 1046 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Tools/LevelEditor/Source/waypoint.txt b/Tools/LevelEditor/Source/waypoint.txt new file mode 100644 index 0000000..a240905 --- /dev/null +++ b/Tools/LevelEditor/Source/waypoint.txt @@ -0,0 +1,20 @@ +Manipulating Paths and Waypoints: + +Click on "Show Zones" + + +Waypoints: + Set: Click on orange button, left-click on map to place new waypoint. + Delete: Right-click on existing waypoint. + +Path: + Place waypoint in current zone, adjacent zone, and destination zone. + With waypoint button selected, right-click on the "from" zone (but + not on a waypoint), left-click on "from" zone's waypoint, adjacent + zone's waypoint, destination zone's waypoint, and finally destination + zone (not on waypoint). + +To show paths leaving a specific zone: + Select zone color but not waypoint button. Right click on an existing + zone. + diff --git a/Tools/LevelEditor/Source/wingk.cpp b/Tools/LevelEditor/Source/wingk.cpp new file mode 100644 index 0000000..a22f875 --- /dev/null +++ b/Tools/LevelEditor/Source/wingk.cpp @@ -0,0 +1,1820 @@ +#include "wingk.h" +#include + +#include + + +gkTransparencyTable gkWinShape::tranTable; + +struct BMP_header{ + gkLONG fSize; //54 byte header + 4*numColors (1-8bit) + (w*h*bpp)/8 + gkWORD zero1, zero2; //0,0 + gkLONG offsetBytes; //should be header (54) plus Palette Size + + gkLONG headerSize; //size of remaining header (40) + gkLONG width, height; //w,h in pixels + gkWORD planes, bpp; //plane=1, bpp=1,2,4, or most commonly 8 + gkLONG compression, imageSize; //compression to zero, size is w*h(8bit) + gkLONG xpels, ypels, zero3, zero4; //set to 0,0,0,0 +}; + +int gkIO::ReadWord(istream &in){ + int retval = in.get() << 8; + return retval | (in.get() & 0xff); +} + +int gkIO::ReadLong(istream &in){ + int retval = ReadWord(in) << 16; + return retval | (ReadWord(in) & 0xffff); +} + +char *gkIO::ReadString(istream &in){ + static char st[80]; + int len = ReadWord(in); + if(!len) return 0; + in.read(st,len); + st[len] = 0; + return st; +} + +char *gkIO::ReadNewString(istream &in){ + int len = ReadWord(in); + if(!len) return 0; + + char *st = new char[len+1]; + in.read(st,len); + st[len] = 0; + return st; +} + +void gkIO::WriteLong(ostream &out, int n){ + WriteWord(out, n>>16); + WriteWord(out, n); +} + +void gkIO::WriteWord(ostream &out, int n){ + out << (char) ((n>>8)&0xff); + out << (char) (n&0xff); +} + +void gkIO::WriteString(ostream &out, char *st){ + WriteWord(out,strlen(st)); + out.write(st,strlen(st)); +} + + +int gkRGB::operator==(gkRGB &c2){ + return ((color.argb & 0xffffff) == (c2.color.argb & 0xffffff)); +} + +int gkRGB::Equals(int _r, int _g, int _b){ + return _r==color.bytes.r && _g==color.bytes.g && _b==color.bytes.b; +} + +int gkRGB::GetCategory(){ + int r = GetR() >> 6; //rough categories 0-3 + int g = GetG() >> 6; + int b = GetB() >> 6; + + int highest = r; + if(g > highest) highest = g; + if(b > highest) highest = b; + + int hash; + + if(r > g && r > b){ //red high + if(g < b) hash = 0; // r > (g < b) + else if(g==b) hash = 1; // r > (g = b) + else hash = 2; // r > (g > b) + }else if(g > r && g > b){ //green high + if(r < b) hash = 3; // g > (r < b) + else if(r==b) hash = 4; // g > (r = b) + else hash = 5; // g > (r > b) + }else if(b > r && b > g){ //blue high + if(r < g) hash = 6; // b > (r < g) + else if(r==g) hash = 7; // b > (r = g) + else hash = 8; // b > (r > g) + }else if(r==b && b==g){ //r = g = b + hash = 9; + }else if(r==b){ //(r = b) > g + hash = 10; + }else if(r==g){ //(r = g) > b + hash = 11; + }else{ //(g = b) > r + hash = 12; + } + + //make room in each category for four levels of intensity (0-3) + hash = hash*4 + highest; + + return hash; +} + +void gkRGB::Combine(gkRGB c2, int alpha){ + //mix alpha + color.bytes.r += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetR()-GetR(), alpha); + color.bytes.g += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetG()-GetG(), alpha); + color.bytes.b += + gkWinShape::tranTable.LookupTransparencyOffset(c2.GetB()-GetB(), alpha); +} + +gkPalGenItem::gkPalGenItem(gkRGB _color){ + color = _color; + occurrences = 1; + nextItem = 0; +} + +gkPalGenItem::gkPalGenItem(gkPalGenItem *item){ + color = item->color; + occurrences = item->occurrences; + nextItem = 0; +} + +gkPalGenItem::~gkPalGenItem(){ +} + +gkRGB gkPalGenItem::GetColor(){ + return color; +} + +void gkPalGenItem::AddOccurrence(){ + occurrences++; +} + +int gkPalGenItem::GetOccurrences(){ + return occurrences; +} + +void gkPalGenItem::SetOccurrences(int n){ + occurrences = n; +} + +void gkPalGenItem::SetNextItem(gkPalGenItem *item){ + nextItem = item; +} + +gkPalGenItem *gkPalGenItem::GetNextItem(){ + return nextItem; +} + +int gkPalGenItem::SortCallback(const void *e1, const void *e2){ + gkPalGenItem *i1 = *((gkPalGenItem**) e1); + gkPalGenItem *i2 = *((gkPalGenItem**) e2); + if(i1->occurrences > i2->occurrences) return -1; + if(i1->occurrences == i2->occurrences) return 0; + return 1; +} + +gkColorCategory::gkColorCategory(){ + int i; + for(i=0; i<64; i++) hashHead[i] = hashTail[i] = 0; + curHash = 0; + curItem = 0; + uniqueCount = 0; +} + +gkColorCategory::~gkColorCategory(){ + int i; + for(i=0; i<64; i++){ + gkPalGenItem *cur, *next; + for(cur=hashHead[i]; cur; cur=next){ + next = cur->GetNextItem(); + delete cur; + } + hashHead[i] = hashTail[i] = 0; + } + uniqueCount = 0; +} + +gkPalGenItem *gkColorCategory::GetFirstItem(){ + if(!uniqueCount) return 0; + curHash = -1; + curItem = 0; + return GetNextItem(); +} + +gkPalGenItem *gkColorCategory::GetNextItem(){ + if(curHash>=64) return 0; + + if(!curItem || !curItem->GetNextItem()){ + while(curHash<(64-1)){ + curHash++; + if(hashHead[curHash]){ + curItem = hashHead[curHash]; + return curItem; + } + } + return 0; + } + + curItem = curItem->GetNextItem(); + return curItem; +} + +gkPalGenItem *gkColorCategory::Exists(gkRGB color){ + int hash = GetHash(color); + gkPalGenItem *cur; + for(cur=hashHead[hash]; cur; cur=cur->GetNextItem()){ + if(cur->GetColor() == color) return cur; + } + return 0; +} + +void gkColorCategory::AddColor(gkRGB color){ + int hash = GetHash(color); + gkPalGenItem *item = new gkPalGenItem(color); + uniqueCount++; + if(!hashHead[hash]){ + hashHead[hash] = hashTail[hash] = item; + }else{ + gkPalGenItem *prev = hashTail[hash]; + //gkPalGenItem *cur, *prev; + //for(cur=hashHead[hash]; cur; cur=cur->GetNextItem()){ + //prev = cur; + //} + prev->SetNextItem(item); + hashTail[hash] = item; + } +} + +void gkColorCategory::SetZeroOccurrences(gkRGB color){ + int hash = GetHash(color); + gkPalGenItem *cur; + for(cur=hashHead[hash]; cur; cur=cur->GetNextItem()){ + if(cur->GetColor()==color){ + cur->SetOccurrences(0); + uniqueCount--; + break; + } + } +} + +int gkColorCategory::GetHash(gkRGB color){ + //hash is concatenation of lower 2 bits of r, g, and b so that minute color + //differences will elicit a different hash + int hash = ((color.GetR() & 3) << 4) | ((color.GetG() & 3) << 2) + | (color.GetB() & 3); + return hash; +} + +gkRGB gkColorCategory::GetMostFrequent(){ + gkPalGenItem *cur = GetMostFrequentItem(); + if(!cur) return gkRGB(0,0,0); + return cur->GetColor(); +} + +gkPalGenItem *gkColorCategory::GetMostFrequentItem(){ + gkPalGenItem *cur, *highest=0; + int highestCount=0; + for(cur=GetFirstItem(); cur; cur=GetNextItem()){ + if(cur->GetOccurrences() > highestCount){ + highest = cur; + highestCount = cur->GetOccurrences(); + } + } + return highest; +} + +gkPaletteGenerator::gkPaletteGenerator(){ +} + +gkPaletteGenerator::~gkPaletteGenerator(){ + Reset(); +} + +void gkPaletteGenerator::Reset(){ +} + +void gkPaletteGenerator::AddColor(gkRGB color){ + int i = GetHash(color); + gkPalGenItem *cur; + if(cur = colorCube[i].Exists(color)){ + cur->AddOccurrence(); + }else{ + //color not in list + colorCube[i].AddColor(color); + } +} + +int gkPaletteGenerator::CreatePalette(gkRGB *palette, int numEntries){ + if(numEntries<=0) return 0; + + //Set all entries to black + int i; + for(i=0; i0){ + first--; + count += colorCube[first].GetUniqueCount(); + } + if(last<(512-1)){ + last++; + count += colorCube[last].GetUniqueCount(); + } + } + + //Create an array to hold all the colors for sorting purposes + gkPalGenItem **colors = new gkPalGenItem*[count]; + gkPalGenItem *cur; + i = 0; + int j; + for(j=first; j<=last; j++){ + for(cur=colorCube[j].GetFirstItem(); cur; + cur=colorCube[j].GetNextItem()){ + if(cur->GetOccurrences()){ + colors[i++] = cur; + } + } + } + count = i; //i may be different from "count" since occurrences is set + //to zero after a color is selected + + //figure out how many colors will come from this section of the cube + int numToGrab = 1; + int tempCurEntry = curEntry; + while(nextEntry==first && tempCurEntry<(512-1)){ + tempCurEntry++; + nextEntry = (int) (scaleFactor * (tempCurEntry+1)); + numToGrab++; + } + + //sort colors into descending order and pick "num" most frequent + qsort(colors, count, sizeof(gkPalGenItem*), gkPalGenItem::SortCallback); + + for(i=0; iGetColor(); + curEntry++; + colorCube[GetHash(colors[i]->GetColor())].SetZeroOccurrences( + colors[i]->GetColor()); + } + + //delete sorting table + delete colors; + } + return numEntries; +} + +int gkPaletteGenerator::GetHash(gkRGB color){ + int r = color.GetR() >> 5; //rough categories 0-3 + int g = color.GetG() >> 5; + int b = color.GetB() >> 5; + return (r<<6) | (g<<3) | b; + + /* + int highest = r; + if(g > highest) highest = g; + if(b > highest) highest = b; + + int hash; + + // r > (g < b) + // r > (g = b) + // r > (g > b) + // g > (r < b) + // g > (r = b) + // g > (r > b) + // b > (r < g) + // b > (r = g) + // b > (r > g) + // (r = b) > g + // (r = g) > b + // (g = b) > r + // (r = g) = b + if(r > g && r > b){ //red high + if(g < b) hash = 0; // r > (g < b) + else if(g==b) hash = 1; // r > (g = b) + else hash = 2; // r > (g > b) + }else if(g > r && g > b){ //green high + if(r < b) hash = 3; // g > (r < b) + else if(r==b) hash = 4; // g > (r = b) + else hash = 5; // g > (r > b) + }else if(b > r && b > g){ //blue high + if(r < g) hash = 6; // b > (r < g) + else if(r==g) hash = 7; // b > (r = g) + else hash = 8; // b > (r > g) + }else if(r==b && b==g){ //r = g = b + hash = 9; + }else if(r==b){ //(r = b) > g + hash = 10; + }else if(r==g){ //(r = g) > b + hash = 11; + }else{ //(g = b) > r + hash = 12; + } + + //make room in each category for four levels of intensity (0-3) + hash = hash*4 + highest; + + return hash; + */ +} + +gkRGB gkPaletteGenerator::MatchColor(gkRGB color){ + int hash = GetHash(color); + int r = color.GetR(); + int g = color.GetG(); + int b = color.GetB(); + if(colorCube[hash].GetFirstItem()){ //near colors; search just this section + gkPalGenItem *cur, *bestMatch; + int bestDiff; + bestMatch = colorCube[hash].GetFirstItem(); + int r2, g2, b2; + r2 = abs(r - bestMatch->GetColor().GetR()); + g2 = abs(g - bestMatch->GetColor().GetG()); + b2 = abs(b - bestMatch->GetColor().GetB()); + bestDiff = r2*r2 + g2*g2 + b2*b2; + for(cur=colorCube[hash].GetNextItem(); cur; cur=colorCube[hash].GetNextItem()){ + r2 = abs(r - cur->GetColor().GetR()); + g2 = abs(g - cur->GetColor().GetG()); + b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2*r2 + g2*g2 + b2*b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + return bestMatch->GetColor(); + }else{ + //no colors nearby; expand search + //Get it from ~greyscale if possible + int first, last; + //first = last = 36 + (hash % 4); + //if(!colorCube[first].GetFirstItem()){ + first = 0; //nothing there either; search everything + last = (512-1); + /* + first = 36; + last = 39; + //first = hash - (hash%4); //different intensities, same color + //last = first + 3; + if(!colorCube[first] && !colorCube[first+1] && !colorCube[first+2] + && !colorCube[last]){ + first = 0; //nothing there either; search everything + last = 51; + } + */ + //} + gkPalGenItem *cur, *bestMatch; + int bestDiff = 0x7fffffff; + bestMatch = 0; + int i; + for(i=first; i<=last; i++){ + for(cur=colorCube[i].GetFirstItem(); cur; + cur=colorCube[i].GetNextItem()){ + int r2 = abs(r - cur->GetColor().GetR()); + int g2 = abs(g - cur->GetColor().GetG()); + int b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2*r2 + g2*g2 + b2*b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + } + if(!bestMatch) return gkRGB(0,0,0); + return bestMatch->GetColor(); + } +} + +gkRGB gkPaletteGenerator::GetMostFrequent(){ + int i, highestCount=0; + gkRGB highestColor; + for(i=0; i<512; i++){ + gkPalGenItem *cur; + for(cur=colorCube[i].GetFirstItem(); cur; cur=colorCube[i].GetNextItem()){ + int count = cur->GetOccurrences(); + if(count > highestCount){ + highestCount = count; + highestColor = cur->GetColor(); + } + } + } + return highestColor; +} + +int gkPaletteGenerator::NumUniqueColors(){ + int totalUnique = 0; + int i; + for(i=0; i<512; i++){ + totalUnique += colorCube[i].GetUniqueCount(); + } + return totalUnique; +} + +gkColorCategory *gkPaletteGenerator::GetCategory(int hash){ + return &colorCube[hash]; +} + +gkTransparencyTable::gkTransparencyTable(){ + lookup = new gkBYTE[256*256]; + + int baseOffset, alpha, i; + i = 0; + for(baseOffset=0; baseOffset<256; baseOffset++){ + for(alpha=0; alpha<256; alpha++){ + lookup[i++] = (baseOffset * alpha) / 255; + } + } +} + +gkTransparencyTable::~gkTransparencyTable(){ + if(lookup) delete lookup; + lookup = 0; +} + +int gkTransparencyTable::LookupTransparencyOffset(int baseOffset, int alpha){ + return (baseOffset>=0) ? lookup[(baseOffset<<8)+alpha] + : (-lookup[((-baseOffset)<<8)+alpha]); +} + + +gkWinShape::gkWinShape(){ + data = 0; + width = height = bpp = 0; + x_origin = y_origin = x_handle = y_handle = 0; +} + +gkWinShape::~gkWinShape(){ + FreeData(); +} + +void gkWinShape::FreeData(){ + if(data){ + delete data; + data = 0; + } +} + +void gkWinShape::Create(int _width, int _height){ + if(_width <= 0 || _height <= 0) return; + + FreeData(); + width = _width; + height = _height; + + //round up width to ensure multiple of 4 pixels + width = (width + 3) & (~3); + + data = new gkBYTE[(width*height)<<2]; + bpp = 32; +} + +void gkWinShape::Cls(){ + if(!this->data) return; + memset(this->data, 0, (this->width * this->height)<<2); +} + +void gkWinShape::Cls(gkRGB color){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = color.GetARGB(); + } +} + +void gkWinShape::Plot(int x, int y, gkRGB color, int testBoundaries){ + if(!data) return; + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return; + } + + gkRGB *dest = (gkRGB*) (data + ((((height - (y+1)) * width) + x) <<2)); + *dest = color; +} + +gkRGB gkWinShape::Point(int x, int y, int testBoundaries){ + if(!data) return gkRGB(0,0,0); + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return gkRGB(0,0,0); + } + + gkRGB *color = (gkRGB*) (data + ((((height - (y+1)) * width) + x) <<2)); + return *color; +} + +void gkWinShape::Line(int x1, int y1, int x2, int y2, gkRGB color){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + ((((height - (y1+1)) * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + *(dest++) = color; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest -= pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + *dest = color; + dest -= pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkWinShape::LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, + int alpha){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + ((((height - (y1+1)) * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + dest->Combine(color,alpha); + dest++; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest -= pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + dest->Combine(color,alpha); + dest -= pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + + +void gkWinShape::RectFill(int x, int y, int w, int h, gkRGB color){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + ((((height - (y+1)) * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + ((((height - (y+1)) * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; iCombine(color,alpha); + dest++; + } + destStart -= width; + } +} + + +void gkWinShape::RemapColor(gkRGB oldColor, gkRGB newColor){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jGetShape(this, (i<<3), (j<<3), 8, 8); + tiles[numTiles]->ReduceTo4Colors(); +if(numTiles==5) g_sixth = tiles[numTiles]; + numTiles++; + } + } + + int numTilePalettes = numTiles; + gkGBCPalette **tilePalettes = new gkGBCPalette*[numTilePalettes]; + for(i=0; iGetPalette(), + tiles[i]->GetColorsUsed()); + tiles[i]->SetCurPalette(tilePalettes[i]); + } + + //Sort into "most frequent first" + //qsort(tilePalettes, numTilePalettes, sizeof(gkGBCPalette*), + //gkGBCPalette::SortByReferences); + + + //Attempt to merge each palette with any of the previous ones in the list + for(i=0; iCanUnionWith(tilePalettes[j], colorsPerPalette)){ + tilePalettes[i]->MakeUnionWith(tilePalettes[j]); + for(k=0; kGetCurPalette()==tilePalettes[i]){ + tiles[k]->SetCurPalette(tilePalettes[j]); + } + } + delete tilePalettes[i]; + tilePalettes[i] = tilePalettes[--numTilePalettes]; + i--; //try new occupant of this index next loop + break; + } + } + } + + while(numTilePalettes > 8){ + //okay now re-sort, get rid of the least-used palette, and pick one + //of the remaining palettes for its tiles + qsort(tilePalettes, numTilePalettes, sizeof(gkGBCPalette*), + gkGBCPalette::SortByReferences); + + numTilePalettes--; //numTilePalettes is now index of disappearing palette + for(int t=0; tGetCurPalette() != tilePalettes[numTilePalettes]) continue; + int bestMatch = 0; + int smallestDifference = 0x7fffffff; + for(i=0; iMatchPalette(tilePalettes[i]->GetPalette(), + tilePalettes[i]->GetColorsUsed()); + if(diffSetNumReferences( + tilePalettes[bestMatch]->GetNumReferences() + 1); + tiles[t]->SetCurPalette(tilePalettes[bestMatch]); + } + + delete tilePalettes[numTilePalettes]; + } + + //Remap tiles to the palettes they've chosen + for(i=0; iGetCurPalette()) + tiles[i]->Finalize(j); + //} + } + + + ofstream outfile("gbpic.bin",ios::out|ios::binary); + if(!outfile) return; + + int totalTiles = (width>>3) * (height>>3); + if(totalTiles > 512) totalTiles = 512; + + int numBank0Tiles, numBank1Tiles; + + if(totalTiles > 256){ + numBank0Tiles = 256; + numBank1Tiles = totalTiles - 256; + }else{ + numBank0Tiles = totalTiles; + numBank1Tiles = 0; + } + + outfile.put((char)(numBank0Tiles>0)); + if(numBank0Tiles){ + outfile.put((char)numBank0Tiles); + for(i=0; iGetCurPalette()->GetPalette(); + int cbyte1, cbyte2; + for(int row=0; row<8; row++){ + for(int col=0; col<8; col++){ + gkRGB pixel = tile->Point(col,row); + int j; + for(j=0; j<4; j++) if(pal[j]==pixel) break; + cbyte1 = (cbyte1<<1) | (j&1); + cbyte2 = (cbyte2<<1) | ((j>>1)&1); + } + outfile.put((char)cbyte1); + outfile.put((char)cbyte2); + } + } + } + + outfile.put((char)(numBank1Tiles>0)); + if(numBank1Tiles){ + outfile.put((char)numBank1Tiles); + for(i=0; iGetCurPalette()->GetPalette(); + int cbyte1, cbyte2; + for(int row=0; row<8; row++){ + for(int col=0; col<8; col++){ + gkRGB pixel = tile->Point(col,row); + for(j=0; j<4; j++) if(pal[j]==pixel) break; + cbyte1 = (cbyte1<<1) | (j&1); + cbyte2 = (cbyte2<<1) | ((j>>1)&1); + } + outfile.put((char)cbyte1); + outfile.put((char)cbyte2); + } + } + } + + + outfile.put((char)tilesWide); + outfile.put((char)tilesHigh); + + for(j=0; jGetCurPalette(); + int p; + for(p=0; pGetCurPalette(); + for(p=0; p 255) spec1 |= 8; + if(j*tilesWide+i+1 > 255) spec2 |= 8; + + outfile.put((char)((spec1<<4) | spec2)); + } + } + + //write color palettes + for(j=0; j<8; j++){ + gkGBCPalette *gbpal = tilePalettes[j]; + gkRGB *pal = gbpal->GetPalette(); + for(i=0; i<4; i++){ + int sel = (j<<3) | (i<<1); + int p1 = ((pal[i].GetB()>>3)<<10) | ((pal[i].GetG()>>3)<<5) + | (pal[i].GetR()>>3); + int p2 = p1>>8; + p1 &= 0xff; + outfile.put((char)sel); + outfile.put((char)p1); + outfile.put((char)p2); + } + } + + outfile.close(); + + for(i=0; iBlit(this); + + //clean up + for(i=0; iSetA(alpha); + } +} + +void gkWinShape::SetColorAlpha(gkRGB color, int alpha){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } + src++; + } + } +} + +int gkWinShape::GetShape(gkWinShape *srcShape, int x, int y, int w, int h){ + if(!srcShape || !srcShape->data) return 0; + + //adjust src rectangle until it fits within source data + if(x<0){ + w += x; + x = 0; + } + if(y<0){ + h += y; + y = 0; + } + if(x + w > srcShape->width){ + w = srcShape->width - x; + } + if(y + h > srcShape->height){ + h = srcShape->height - y; + } + + if(w<=0 || h<=0) return 0; + + FreeData(); + Create(w, h); + x_origin = x; + y_origin = y; + + gkBYTE *src = (gkBYTE*) ((((srcShape->height-1) - y) * srcShape->width) + x); + src = srcShape->data + ((int)src <<2); + gkBYTE *dest = this->data + (((h-1) * w) << 2); + int srcSkip = srcShape->width << 2; + w <<= 2; + + while(h--){ + memcpy(dest, src, w); + dest -= w; + src -= srcSkip; + } + + return 1; +} + +int gkWinShape::GetShape(gkWinShape *srcShape){ + if(this->width != srcShape->width || this->height != srcShape->height + || (!this->data) || (!srcShape->data)){ + //mem needs to be reallocated + FreeData(); + memcpy(this, srcShape, sizeof(gkWinShape)); + data = 0; + if(srcShape->data){ + data = new gkBYTE[(width * height) << 2]; + memcpy(data, srcShape->data, (width * height) << 2 ); + } + }else{ + //already got right size mem, just copy data over + memcpy(data, srcShape->data, (width * height) << 2); + fontSpacing = srcShape->fontSpacing; + fontKerning = srcShape->fontKerning; + x_handle = srcShape->x_handle; + y_handle = srcShape->y_handle; + x_origin = srcShape->x_origin; + y_origin = srcShape->y_origin; + } + return data!=0; +} + +int gkWinShape::SaveShape(char *filename){ + ofstream outfile(filename, ios::out | ios::binary); + if(!outfile) return 0; + + int result = SaveShape(outfile); + outfile.close(); + + return result; +} + +int gkWinShape::SaveShape(ostream &out){ + int totalSize = ((width * height) << 2); + + out << "SHPE"; + int skipSize = totalSize + 20; + gkIO::WriteLong(out, skipSize); + + //Write shape header + gkIO::WriteWord(out, 3); //type 3 + gkIO::WriteWord(out, width); + gkIO::WriteWord(out, height); + gkIO::WriteWord(out, (bpp==8)?8:32); + out << (char) fontSpacing << (char) fontKerning; + gkIO::WriteWord(out, x_handle); + gkIO::WriteWord(out, y_handle); + gkIO::WriteWord(out, 0); //6 bytes of reserved space + gkIO::WriteLong(out, 0); + + + //Write data + if(data){ + int pitch = width << 2; + gkLONG *src; + gkBYTE *srcStart=(gkBYTE*) ((height-1) * pitch); + + int i,j; + for(j=0; jLoadShape(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadShape(istream &infile){ + FreeData(); + if(infile.get() != 'S') return 0; + if(infile.get() != 'H') return 0; + if(infile.get() != 'P') return 0; + if(infile.get() != 'E') return 0; + + gkIO::ReadLong(infile); //discard skipsize + + //Read shape header + if(gkIO::ReadWord(infile) != 2) return 0; + width = gkIO::ReadWord(infile); + height = gkIO::ReadWord(infile); + int filebpp = gkIO::ReadWord(infile); + if(!bpp) bpp = filebpp; + + if(width && height){ + Create(width,height); + } + + fontSpacing = infile.get(); + fontKerning = infile.get(); + x_handle = gkIO::ReadWord(infile); + y_handle = gkIO::ReadWord(infile); + + gkIO::ReadWord(infile); + gkIO::ReadLong(infile); //discard reserved space + + if(!width || !height) return 1; //nothing to load, null shape + + int pitch = width << 2; + gkBYTE *destStart = data + (height-1) * pitch; + gkLONG *dest; + int x,y; + for(y=0; ySetA(infile.get()); + //dest->SetR(infile.get()); + //dest->SetG(infile.get()); + //dest->SetB(infile.get()); + //dest++; + } + destStart -= pitch; + } + + return 1; +} + +int gkWinShape::LoadBMP(char *filename){ + ifstream infile(filename,ios::in | ios::binary | ios::nocreate); + if(!infile) return 0; + + int result = this->LoadBMP(infile); + infile.close(); + + return result; +} + +int gkWinShape::LoadBMP(istream &infile){ + BMP_header header; + if(gkIO::ReadWord(infile)!=0x424d){ //check for "BM" + return 0; + } + infile.read((char*)&header, sizeof(BMP_header)); + if(header.bpp != 24){ + cout << "LoadBMP can only handle 24-bit files" << endl; + return 0; + } + + FreeData(); + width = header.width; + height = header.height; + bpp = (char) header.bpp; + Create(width,height); + + // load graphics, coverting every three (B,R,G) bytes to one ARGB value. + // lines padded to even multiple of 4 bytes + int srcPitch = ((header.width * 3) + 3) & (~3); + gkBYTE *buffer = new gkBYTE[srcPitch * height]; + gkBYTE *nextBuffPtr = buffer; + gkBYTE *buffPtr; + + infile.read(buffer, srcPitch * height); + + gkBYTE *nextDest = data; + gkRGB *dest; + int destPitch = (width << 2); + + int i, j; + j = height; + while(j--){ + buffPtr = nextBuffPtr; + nextBuffPtr += srcPitch; + dest = (gkRGB*) nextDest; + nextDest += destPitch; + i = header.width; + while(i--){ + dest->SetB(*(buffPtr++)); + dest->SetG(*(buffPtr++)); + dest->SetR(*(buffPtr++)); + dest->SetA(0xff); + dest++; + } + for(i=header.width; iSetARGB(0); + dest++; + } + } + + delete buffer; + + return 1; +} + + +void gkWinShape::Blit(gkWinShape *destShape, int flags){ + Blit(destShape, x_origin, y_origin, flags); +} + +void gkWinShape::Blit(gkWinShape *destShape, int x, int y, int flags){ + if(!data || !destShape || !destShape->data) return; + + //keep in mind that we're dealing with info organized in the screwy + //BMP bottom-to-top, left-to-right format + + gkBYTE *src = (gkBYTE*) ((this->height - 1) * this->width); + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src -= (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = + (gkBYTE*) ((((destShape->height-1) - y) * destShape->width) + x); + src = this->data + ((int)src << 2); + dest = destShape->data + ((int)dest << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src -= srcSkip; + dest -= destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src -= srcSkip; + dest -= destSkip; + } + } +} + +void gkWinShape::BlitHalfBrite(gkWinShape *destShape, int x, int y, + int flags){ + if(!data || !destShape || !destShape->data) return; + + //keep in mind that we're dealing with info organized in the screwy + //BMP bottom-to-top, left-to-right format + + gkBYTE *src = (gkBYTE*) ((this->height - 1) * this->width); + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destShape->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src -= (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destShape->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destShape->width; + + gkBYTE *dest = + (gkBYTE*) ((((destShape->height-1) - y) * destShape->width) + x); + src = this->data + ((int)src << 2); + dest = destShape->data + ((int)dest << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTransHalfBrite(dest, src, srcWidth); + src -= srcSkip; + dest -= destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + MemCpyHalfBrite(dest, src, srcWidth); + src -= srcSkip; + dest -= destSkip; + } + } +} + +void gkWinShape::BlitToDC(CDC *pDC, int x, int y){ + //static BITMAPINFOHEADER bmHeader={40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}; + static BITMAPINFO bmInfo={{40, 0, 0, 1, 32, 0, 0, 0, 0, 0, 0}}; + static CDC srcDC; + static int setup=0; + + if(!setup){ + setup = 1; + + //HDC hdc = CreateDC("DISPLAY",0,0,0); + //srcDC.Attach(hdc); + srcDC.CreateCompatibleDC(0); + *((int*)(&bmInfo.bmiColors[0])) = 0xff0000; //red mask + *((int*)(&bmInfo.bmiColors[4])) = 0x00ff00; //green mask + *((int*)(&bmInfo.bmiColors[8])) = 0x0000ff; //blue mask + } + + bmInfo.bmiHeader.biWidth = width; + bmInfo.bmiHeader.biHeight = height; + + HBITMAP dib = CreateDIBitmap((HDC) (*pDC), + &bmInfo.bmiHeader, + CBM_INIT, + data, + &bmInfo, + DIB_RGB_COLORS); + + CBitmap bitmap; + bitmap.Attach(dib); + + CBitmap *oldBitmap = srcDC.SelectObject(&bitmap); + pDC->BitBlt(x, y, width, height, &srcDC, 0, 0, SRCCOPY); + srcDC.SelectObject(oldBitmap); + + bitmap.Detach(); + DeleteObject(dib); +} + +void gkWinShape::MemCpyTrans(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + int c1; + while(numColors--){ + int alpha; + switch(alpha = (srcColor->GetA())){ + case 0: break; + case 255: //Straight copy + *destColor = *srcColor; + break; + default: //mix alpha + c1 = destColor->GetR(); + c1 += tranTable.LookupTransparencyOffset(srcColor->GetR()-c1, alpha); + destColor->SetR(c1); + c1 = destColor->GetG(); + c1 += tranTable.LookupTransparencyOffset(srcColor->GetG()-c1, alpha); + destColor->SetG(c1); + c1 = destColor->GetB(); + c1 += tranTable.LookupTransparencyOffset(srcColor->GetB()-c1, alpha); + destColor->SetB(c1); + break; + } + srcColor++; + destColor++; + } +} + +void gkWinShape::MemCpyTransHalfBrite(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + int c1; + while(numColors--){ + int alpha; + switch(alpha = (srcColor->GetA())){ + case 0: break; + case 255: //Straight copy + destColor->SetR((srcColor->GetR()>>1)&0x7f); + destColor->SetG((srcColor->GetG()>>1)&0x7f); + destColor->SetB((srcColor->GetB()>>1)&0x7f); + break; + default: //mix alpha + c1 = destColor->GetR(); + c1 += tranTable.LookupTransparencyOffset( + (srcColor->GetR()>>1)-c1, alpha); + destColor->SetR(c1); + c1 = destColor->GetG(); + c1 += tranTable.LookupTransparencyOffset( + (srcColor->GetG()>>1)-c1, alpha); + destColor->SetG(c1); + c1 = destColor->GetB(); + c1 += tranTable.LookupTransparencyOffset( + (srcColor->GetB()>>1)-c1, alpha); + destColor->SetB(c1); + break; + } + srcColor++; + destColor++; + } +} + +void gkWinShape::MemCpyHalfBrite(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + while(numColors--){ + //Straight copy + destColor->SetR((srcColor->GetR()>>1)&0x7f); + destColor->SetG((srcColor->GetG()>>1)&0x7f); + destColor->SetB((srcColor->GetB()>>1)&0x7f); + srcColor++; + destColor++; + } +} + +gkGBCShape::gkGBCShape() : gkWinShape(){ + colorsMapped = 0; + numColorsMapped = 0; + curPalette = 0; +} + +gkGBCShape::~gkGBCShape(){ + gkWinShape::~gkWinShape(); +} + +void gkGBCShape::ReduceTo4Colors(){ + gkWinShape::ReduceColors(4); + + //record the colors used + colorsUsed = 0; + int i, j; + for(i=0; i<4; i++) occurrences[i] = 0; + gkRGB *src = (gkRGB*) data; + i = width*height; + while(i--){ + //generator.AddColor(*src); + for(j=0; j=colorsUsed){ //found unrecorded color + occurrences[colorsUsed] = 1; + colors[colorsUsed++] = *src; + } + if(colorsUsed==4) break; + src++; + } +} + +int gkGBCShape::MatchPalette(gkRGB *palette, int numColors){ + gkPaletteGenerator generator; + + //Add other palette to gen + int i; + for(i=0; iGetPalette()[0]; + gkRGB c2 = curPalette->GetPalette()[1]; + gkRGB c3 = curPalette->GetPalette()[2]; + gkRGB c4 = curPalette->GetPalette()[3]; + int cUsed = curPalette->GetColorsUsed(); + ASSERT(n!=1); + */ +//if(this==g_sixth) ASSERT(0); + RemapToPalette(curPalette->GetPalette(), + curPalette->GetColorsUsed()); +} + +gkGBCPalette::gkGBCPalette(gkRGB *init_colors, int init_colorsUsed){ + int i; + colorsUsed = init_colorsUsed; + for(i=0; inumReferences > p2->numReferences) return -1; + if(p1->numReferences < p2->numReferences) return 1; + return 0; +} + +int gkGBCPalette::CanUnionWith(gkGBCPalette *p2, int maxColors){ + gkPaletteGenerator generator; + + //add all colors in both palettes to generator + int i; + for(i=0; icolorsUsed; i++) generator.AddColor(p2->colors[i]); + + if(generator.NumUniqueColors() > maxColors) return 0; //no union possible + return 1; //can do a union +} + +void gkGBCPalette::MakeUnionWith(gkGBCPalette *p2){ + gkPaletteGenerator generator; + + //add all colors in both palettes to generator + int i; + for(i=0; icolorsUsed; i++) generator.AddColor(p2->colors[i]); + + p2->colorsUsed = + generator.CreatePalette(p2->colors, generator.NumUniqueColors()); + p2->numReferences += numReferences; +} + diff --git a/Tools/LevelEditor/Source/wingk.h b/Tools/LevelEditor/Source/wingk.h new file mode 100644 index 0000000..1473dfa --- /dev/null +++ b/Tools/LevelEditor/Source/wingk.h @@ -0,0 +1,242 @@ +#ifndef WINGK_H +#define WINGK_H + +#include "stdafx.h" + +#include +#include +#include +#include +#include + +typedef unsigned char gkBYTE; +typedef short int gkWORD; +typedef int gkLONG; + +#define GKHANDLE_TL 0 +#define GKHANDLE_TC 1 +#define GKHANDLE_TR 2 +#define GKHANDLE_CR 3 +#define GKHANDLE_BR 4 +#define GKHANDLE_BC 5 +#define GKHANDLE_BL 6 +#define GKHANDLE_CL 7 +#define GKHANDLE_CENTER 8 + +#define GKBLT_TRANSPARENT 1 + +class gkIO{ + public: + inline static int ReadByte(istream &in){ return in.get(); } + static int ReadWord(istream &in); + static int ReadLong(istream &in); + static char *ReadString(istream &in); + static char *ReadNewString(istream &in); + inline static void WriteByte(ostream &out, int n){ out << (char) n; } + static void WriteLong(ostream &out, int n); + static void WriteWord(ostream &out, int n); + static void WriteString(ostream &out, char *st); +}; + +struct gkRGB_4bytes{ + unsigned char b, g, r, a; +}; + +union gkRGB_ColorUnion{ + gkRGB_4bytes bytes; + gkLONG argb; +}; + +class gkRGB{ + public: + gkRGB_ColorUnion color; + + inline gkRGB(){ color.argb = 0xff000000; } + inline gkRGB(int _r, int _g, int _b, int _a=255){ + color.bytes.r=_r; color.bytes.g=_g; color.bytes.b=_b; color.bytes.a=_a;} + inline void SetR(gkBYTE n){ color.bytes.r = n; } + inline void SetG(gkBYTE n){ color.bytes.g = n; } + inline void SetB(gkBYTE n){ color.bytes.b = n; } + inline void SetA(gkBYTE n){ color.bytes.a = n; } + inline void SetARGB(gkLONG n){ color.argb = n; } + inline gkBYTE GetR(){ return color.bytes.r; } + inline gkBYTE GetG(){ return color.bytes.g; } + inline gkBYTE GetB(){ return color.bytes.b; } + inline gkBYTE GetA(){ return color.bytes.a; } + inline gkLONG GetARGB(){ return color.argb; } + inline int operator==(gkRGB &c2); + inline int Equals(int _r, int _g, int _b); + int GetCategory(); + void Combine(gkRGB c2, int alpha); +}; + +class gkPalGenItem{ + protected: + gkRGB color; + int occurrences; + gkPalGenItem *nextItem; + + public: + gkPalGenItem(gkRGB _color); + gkPalGenItem(gkPalGenItem *item); + ~gkPalGenItem(); + inline gkRGB GetColor(); + inline void AddOccurrence(); + inline int GetOccurrences(); + inline void SetOccurrences(int n); + inline void SetNextItem(gkPalGenItem *item); + inline gkPalGenItem *GetNextItem(); + static int SortCallback(const void *e1, const void *e2); +}; + +class gkColorCategory{ + protected: + gkPalGenItem *hashHead[64]; + gkPalGenItem *hashTail[64]; + int uniqueCount; + short int curHash; + gkPalGenItem *curItem; + + public: + gkColorCategory(); + ~gkColorCategory(); + gkPalGenItem *GetFirstItem(); + gkPalGenItem *GetNextItem(); + gkPalGenItem *Exists(gkRGB color); + void AddColor(gkRGB color); + void SetZeroOccurrences(gkRGB color); + int GetHash(gkRGB color); + int GetUniqueCount(){ return uniqueCount; } + gkRGB GetMostFrequent(); + gkPalGenItem *GetMostFrequentItem(); +}; + +class gkPaletteGenerator{ + protected: + gkColorCategory colorCube[512]; //8*8*8 + + public: + gkPaletteGenerator(); + ~gkPaletteGenerator(); + void Reset(); + void AddColor(gkRGB color); + int CreatePalette(gkRGB *palette, int numEntries); + int GetHash(gkRGB color); + gkRGB MatchColor(gkRGB color); + gkRGB GetMostFrequent(); + int NumUniqueColors(); + gkColorCategory *GetCategory(int hash); +}; + +class gkTransparencyTable{ + protected: + gkBYTE *lookup; + + public: + gkTransparencyTable(); + ~gkTransparencyTable(); + inline int LookupTransparencyOffset(int baseOffset, int alpha); +}; + +class gkGBCPalette; + +class gkWinShape{ + protected: + gkBYTE *data; + int width, height; + char bpp, fontSpacing, fontKerning; + short int x_handle, y_handle; + short int x_origin, y_origin; + + public: + static gkTransparencyTable tranTable; + + public: + gkWinShape(); + ~gkWinShape(); + void FreeData(); + void Create(int _width, int _height); + void Cls(); + void Cls(gkRGB color); + void Plot(int x, int y, gkRGB color, int testBoundaries=1); + gkRGB Point(int x, int y, int testBoundaries=1); + void Line(int x1, int y1, int x2, int y2, gkRGB color); + void LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, int alpha); + void RectFill(int x, int y, int w, int h, gkRGB color); + void RectFillAlpha(int x, int y, int w, int h, gkRGB color, int alpha); + void RemapColor(gkRGB oldColor, gkRGB newColor); + void RemapToPalette(gkRGB *palette, int numColors); + int ReduceColors(int numColors); + void RemapToGBC(gkRGB *palettes, int numPalettes, + int colorsPerPalette); + void ExchangeColors(gkRGB c1, gkRGB c2); + void SetAlpha(int alpha); + void SetColorAlpha(gkRGB color, int alpha); + + int GetShape(gkWinShape *srcShape, int x, int y, int w, int h); + int GetShape(gkWinShape *srcShape); + int SaveShape(char *filename); + int SaveShape(ostream &outfile); + int LoadShape(char *filename); + int LoadShape(istream &infile); + int LoadBMP(char *filename); + int LoadBMP(istream &infile); + void Blit(gkWinShape *destShape, int flags=GKBLT_TRANSPARENT); + void Blit(gkWinShape *destShape, int x, int y, + int flags=GKBLT_TRANSPARENT); + void BlitHalfBrite(gkWinShape *destShape, int x, int y, + int flags=GKBLT_TRANSPARENT); + void BlitToDC(CDC *pDC, int x, int y); + + int GetWidth(){ return width; } + int GetHeight(){ return height; } + gkBYTE *GetData(){ return data; } + + //internal support routines + static void MemCpyTrans(gkBYTE *dest, gkBYTE *src, int nBytes); + static void MemCpyTransHalfBrite(gkBYTE *dest, gkBYTE *src, int nBytes); + static void MemCpyHalfBrite(gkBYTE *dest, gkBYTE *src, int nBytes); +}; + +class gkGBCShape : public gkWinShape{ + protected: + gkRGB colors[4]; + int occurrences[4]; + int colorsUsed; + int colorsMapped; //bits 0-3 determine which colors are mapped + int numColorsMapped; + gkGBCPalette *curPalette; + + public: + gkGBCShape(); + ~gkGBCShape(); + + inline int GetColorsUsed(){ return colorsUsed; } + inline gkRGB *GetPalette(){ return colors; } + inline gkGBCPalette *GetCurPalette(){ return curPalette; } + inline void SetCurPalette(gkGBCPalette *pal){ curPalette = pal; } + + void ReduceTo4Colors(); + int MatchPalette(gkRGB *palette, int numColors); + void Finalize(int n); +}; + +class gkGBCPalette{ + protected: + gkRGB colors[4]; + int colorsUsed; + int numReferences; + + public: + gkGBCPalette(gkRGB *init_colors, int init_colorsUsed); + inline gkRGB *GetPalette(){ return colors; } + inline int GetColorsUsed(){ return colorsUsed; } + inline void SetNumReferences(int n){ numReferences = n; } + inline int GetNumReferences(){ return numReferences; } + static int SortByReferences(const void *e1, const void *e2); + int CanUnionWith(gkGBCPalette *p2, int maxColors); + void MakeUnionWith(gkGBCPalette *p2); +}; + +#endif + diff --git a/Tools/LevelEditor/background0001-1535.bmp b/Tools/LevelEditor/background0001-1535.bmp new file mode 100644 index 0000000..9226f52 Binary files /dev/null and b/Tools/LevelEditor/background0001-1535.bmp differ diff --git a/Tools/LevelEditor/exitTiles.bmp b/Tools/LevelEditor/exitTiles.bmp new file mode 100644 index 0000000..d0bd0fa Binary files /dev/null and b/Tools/LevelEditor/exitTiles.bmp differ diff --git a/Tools/LevelEditor/objects2048-2303.bmp b/Tools/LevelEditor/objects2048-2303.bmp new file mode 100644 index 0000000..0557dc8 Binary files /dev/null and b/Tools/LevelEditor/objects2048-2303.bmp differ diff --git a/Tools/MakeDiscoLights/gk.cpp b/Tools/MakeDiscoLights/gk.cpp new file mode 100644 index 0000000..c4b34ef --- /dev/null +++ b/Tools/MakeDiscoLights/gk.cpp @@ -0,0 +1,1747 @@ +#include "gk.h" +#include + +extern ofstream logFile; + +gkTransparencyTable gkBitmap::tranTable; + +struct BMP_header{ + gkLONG fSize; //54 byte header + 4*numColors (1-8bit) + (w*h*bpp)/8 + gkWORD zero1, zero2; //0,0 + gkLONG offsetBytes; //should be header (54) plus Palette Size + + gkLONG headerSize; //size of remaining header (40) + gkLONG width, height; //w,h in pixels + gkWORD planes, bpp; //plane=1, bpp=1,2,4, or most commonly 8 + gkLONG compression, imageSize; //compression to zero, size is w*h(8bit) + gkLONG xpels, ypels, zero3, zero4; //set to 0,0,0,0 +}; + +#ifdef _WIN32 +gkFileInputBuffer::gkFileInputBuffer(char *filename){ + buffer = 0; + stin = 0; + exists = 0; + HANDLE handle = CreateFile(filename,GENERIC_READ,FILE_SHARE_READ,0, + OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); + if(handle==INVALID_HANDLE_VALUE) return; + int size = GetFileSize(handle,0); + buffer = new char[size]; + unsigned long bytesRead; + ReadFile(handle,buffer,size,&bytesRead,0); + CloseHandle(handle); + stin = new istrstream(buffer,size); + exists = 1; +} + +gkFileInputBuffer::~gkFileInputBuffer(){ + if(stin){ + delete stin; + stin = 0; + } + if(buffer) delete buffer; + buffer = 0; +} + +gkFileOutputBuffer::gkFileOutputBuffer(char *filename){ + exists = 0; + handle = CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,0, + CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); + if(handle==INVALID_HANDLE_VALUE){ + return; + } + exists = 1; +} + +gkFileOutputBuffer::~gkFileOutputBuffer(){ + if(handle==INVALID_HANDLE_VALUE) return; + unsigned long written; + WriteFile(handle,stout.str(),stout.tellp(),&written,0); + //unfreeze the ostrstream so it will delete the array + stout.rdbuf()->freeze(0); + CloseHandle(handle); +} +#endif + +gkList::gkList(void){ + head = tail = 0; + numItems = 0; +} + +gkList::~gkList(void){ + Reset(); +} + + +void gkList::Reset(){ + gkListItem *cur, *next; + for(cur=head; cur; cur=next){ + next = cur->NextItem(); + delete cur; + } + head = tail = 0; +} + +gkListItem *gkList::GetItem(int n){ + if(n >= numItems) return 0; + gkListItem *cur; + cur = head; + while(n-- > 0){ + cur = cur->NextItem(); + } + return cur; +} + +void gkList::AddItem(gkListItem *li){ + numItems++; + if(!head){ + head = tail = li; + }else{ + tail->SetNextItem(li); + tail = tail->NextItem(); + li->SetNextItem(0); + } +} + +void gkList::DeleteItem(gkListItem *item){ + gkListItem *cur, *prev; + + //is it the head? + if(item==head){ + head=head->GetNext(); + if(!head) tail = 0; + delete item; + return; + } + + //must be in body or tail + prev = 0; + for(cur=head; cur; cur=cur->GetNext()){ + if(cur==item){ + prev->SetNext(cur->GetNext()); + if(cur==tail) tail=prev; + delete cur; + break; + } + prev = cur; + } +} + +int gkIO::ReadWord(istream &in){ + int retval = in.get() << 8; + return retval | (in.get() & 0xff); +} + +int gkIO::ReadLong(istream &in){ + int retval = ReadWord(in) << 16; + return retval | (ReadWord(in) & 0xffff); +} + +char *gkIO::ReadString(istream &in){ + static char st[80]; + int len = ReadWord(in); + if(!len) return 0; + in.read(st,len); + st[len] = 0; + return st; +} + +char *gkIO::ReadNewString(istream &in){ + int len = ReadWord(in); + if(!len) return 0; + + char *st = new char[len+1]; + in.read(st,len); + st[len] = 0; + return st; +} + +void gkIO::WriteLong(ostream &out, int n){ + WriteWord(out, n>>16); + WriteWord(out, n); +} + +void gkIO::WriteWord(ostream &out, int n){ + out << (char) ((n>>8)&0xff); + out << (char) (n&0xff); +} + +void gkIO::WriteString(ostream &out, char *st){ + WriteWord(out,strlen(st)); + out.write(st,strlen(st)); +} + +int gkRGB::Equals(int _r, int _g, int _b){ + return _r==color.bytes.r && _g==color.bytes.g && _b==color.bytes.b; +} + +void gkRGB::Combine(gkRGB c2, int alpha){ + //mix alpha + color.bytes.r += + gkBitmap::tranTable.LookupTransparencyOffset(c2.GetR()-GetR(), alpha); + color.bytes.g += + gkBitmap::tranTable.LookupTransparencyOffset(c2.GetG()-GetG(), alpha); + color.bytes.b += + gkBitmap::tranTable.LookupTransparencyOffset(c2.GetB()-GetB(), alpha); +} + +void gkRGB::SetFromGBColor(int gbColor){ + color.bytes.r = (gbColor<<3) & 0xf8; + color.bytes.g = (gbColor>>2) & 0xf8; + color.bytes.b = (gbColor>>7) & 0xf8; +} + +gkPalGenItem::gkPalGenItem(gkRGB _color){ + color = _color; + occurrences = 1; + nextItem = 0; +} + +gkPalGenItem::~gkPalGenItem(){ +} + +gkRGB gkPalGenItem::GetColor(){ + return color; +} + +void gkPalGenItem::AddOccurrence(){ + occurrences++; +} + +int gkPalGenItem::GetOccurrences(){ + return occurrences; +} + +void gkPalGenItem::SetOccurrences(int n){ + occurrences = n; +} + +void gkPalGenItem::SetNextItem(gkPalGenItem *item){ + nextItem = item; +} + +gkPalGenItem *gkPalGenItem::GetNextItem(){ + return nextItem; +} + +int gkPalGenItem::GetCount(){ + gkPalGenItem *cur; + int count = 0; + for(cur=this; cur; cur=cur->nextItem){ + if(cur->occurrences) count++; + } + return count; +} + +int gkPalGenItem::SortCallback(const void *e1, const void *e2){ + gkPalGenItem *i1 = *((gkPalGenItem**) e1); + gkPalGenItem *i2 = *((gkPalGenItem**) e2); + if(i1->occurrences > i2->occurrences) return -1; + if(i1->occurrences == i2->occurrences) return 0; + return 1; +} + +gkPaletteGenerator::gkPaletteGenerator(){ + int i; + for(i=0; i<52; i++){ + colorCube[i] = 0; + } +} + +gkPaletteGenerator::~gkPaletteGenerator(){ + Reset(); +} + +void gkPaletteGenerator::Reset(){ + int i; + for(i=0; i<52; i++){ + if(colorCube[i]){ + gkPalGenItem *cur, *next; + for(cur=colorCube[i]; cur; cur=next){ + next = cur->GetNextItem(); + delete cur; + } + colorCube[i] = 0; + } + } +} + +void gkPaletteGenerator::AddColor(gkRGB color){ + int i = GetHash(color); + + if(!colorCube[i]){ + colorCube[i] = new gkPalGenItem(color); + }else{ + gkPalGenItem *cur, *prev; + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + if((cur->GetColor()) == color){ + cur->AddOccurrence(); //Color already in list + break; + } + prev = cur; + } + if(!cur){ //color not in list + prev->SetNextItem(new gkPalGenItem(color)); + } + } +} + +void gkPaletteGenerator::CreatePalette(gkRGB *palette, int numEntries){ + if(numEntries<=0) return; + + //Set all entries to black + int i; + for(i=0; iGetCount(); + } + while(!count){ //if no colors yet expand area of inclusion + if(first==0 && last==51) return; //no colors anywhere! + if(first>0){ + first--; + if(colorCube[first]) count += colorCube[first]->GetCount(); + } + if(last<51){ + last++; + if(colorCube[last]) count += colorCube[last]->GetCount(); + } + } + + //Create an array to hold all the colors for sorting purposes + gkPalGenItem **colors = new gkPalGenItem*[count]; + gkPalGenItem *cur; + i = 0; + int j; + for(j=first; j<=last; j++){ + if(colorCube[j]){ + for(cur=colorCube[j]; cur; cur=cur->GetNextItem()){ + if(cur->GetOccurrences()) colors[i++] = cur; + } + } + } + + //figure out how many colors will come from this section of the cube + int numToGrab = 1; + int tempCurEntry = curEntry; + while(nextEntry==first && tempCurEntry<(52-1)){ + tempCurEntry++; + nextEntry = (int) (scaleFactor * (tempCurEntry+1)); + numToGrab++; + } + + if(numToGrab > count) numToGrab = count; + + //sort colors into descending order and pick "num" most frequent + qsort(colors, count, sizeof(gkPalGenItem*), gkPalGenItem::SortCallback); + + for(i=0; iGetColor(); + colors[i]->SetOccurrences(0); + } + + //delete sorting table + delete colors; + } +} + + +int gkPaletteGenerator::GetNumColors(){ + int num = 0, i; + for(i=0; i<52; i++) + if(colorCube[i]) num += colorCube[i]->GetCount(); + return num; +} + + +int gkPaletteGenerator::GetHash(gkRGB color){ + int r = color.GetR() >> 6; //rough categories 0-3 + int g = color.GetG() >> 6; + int b = color.GetB() >> 6; + int highest = r; + if(g > highest) highest = g; + if(b > highest) highest = b; + + int hash; + + // r > (g < b) + // r > (g = b) + // r > (g > b) + // g > (r < b) + // g > (r = b) + // g > (r > b) + // b > (r < g) + // b > (r = g) + // b > (r > g) + // (r = b) > g + // (r = g) > b + // (g = b) > r + // (r = g) = b + if(r > g && r > b){ //red high + if(g < b) hash = 0; // r > (g < b) + else if(g==b) hash = 1; // r > (g = b) + else hash = 2; // r > (g > b) + }else if(g > r && g > b){ //green high + if(r < b) hash = 3; // g > (r < b) + else if(r==b) hash = 4; // g > (r = b) + else hash = 5; // g > (r > b) + }else if(b > r && b > g){ //blue high + if(r < g) hash = 6; // b > (r < g) + else if(r==g) hash = 7; // b > (r = g) + else hash = 8; // b > (r > g) + }else if(r==b && b==g){ //r = g = b + hash = 9; + }else if(r==b){ //(r = b) > g + hash = 10; + }else if(r==g){ //(r = g) > b + hash = 11; + }else{ //(g = b) > r + hash = 12; + } + + //make room in each category for four levels of intensity (0-3) + hash = hash*4 + highest; + + return hash; +} + +int gkPaletteGenerator::ColorExists(gkRGB color){ + int hash = GetHash(color); + if(!colorCube[hash]) return 0; + + gkPalGenItem *cur; + for(cur=colorCube[hash]; cur; cur=cur->GetNextItem()){ + if(cur->GetColor()==color) return 1; //found exact color + } + return 0; +} + +gkRGB gkPaletteGenerator::MatchColor(gkRGB color){ + int hash = GetHash(color); + int r = color.GetR(); + int g = color.GetG(); + int b = color.GetB(); + if(colorCube[hash]){ //near colors; search just this section + gkPalGenItem *cur, *bestMatch; + int bestDiff; + bestMatch = colorCube[hash]; + int r2, g2, b2; + r2 = abs(r - bestMatch->GetColor().GetR()); + g2 = abs(g - bestMatch->GetColor().GetG()); + b2 = abs(b - bestMatch->GetColor().GetB()); + bestDiff = r2 + g2 + b2; + for(cur=bestMatch->GetNextItem(); cur; cur=cur->GetNextItem()){ + r2 = abs(r - cur->GetColor().GetR()); + g2 = abs(g - cur->GetColor().GetG()); + b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + return bestMatch->GetColor(); + }else{ + //no colors nearby; expand search + //Get it from ~greyscale if possible + int first, last; + first = last = 36 + (hash % 4); + if(!colorCube[first]){ + first = 0; //nothing there either; search everything + last = 51; + /* + first = 36; + last = 39; + //first = hash - (hash%4); //different intensities, same color + //last = first + 3; + if(!colorCube[first] && !colorCube[first+1] && !colorCube[first+2] + && !colorCube[last]){ + first = 0; //nothing there either; search everything + last = 51; + } + */ + } + gkPalGenItem *cur, *bestMatch; + int bestDiff = 0x7fffffff; + bestMatch = 0; + int i; + for(i=first; i<=last; i++){ + for(cur=colorCube[i]; cur; cur=cur->GetNextItem()){ + int r2 = abs(r - cur->GetColor().GetR()); + int g2 = abs(g - cur->GetColor().GetG()); + int b2 = abs(b - cur->GetColor().GetB()); + int curDiff = r2 + g2 + b2; + if(curDiff < bestDiff){ + bestDiff = curDiff; + bestMatch = cur; + if(!curDiff) return bestMatch->GetColor(); + } + } + } + if(!bestMatch) return gkRGB(0,0,0); + return bestMatch->GetColor(); + } +} + +gkTransparencyTable::gkTransparencyTable(){ + lookup = new gkBYTE[256*256]; + + int baseOffset, alpha, i; + i = 0; + for(baseOffset=0; baseOffset<256; baseOffset++){ + for(alpha=0; alpha<256; alpha++){ + lookup[i++] = (baseOffset * alpha) / 255; + } + } +} + +gkTransparencyTable::~gkTransparencyTable(){ + if(lookup) delete lookup; + lookup = 0; +} + +int gkTransparencyTable::LookupTransparencyOffset(int baseOffset, int alpha){ + return (baseOffset>=0) ? lookup[(baseOffset<<8)+alpha] + : (-lookup[((-baseOffset)<<8)+alpha]); +} + + +gkBitmap::gkBitmap(){ + data = 0; + width = height = bpp = 0; +} + +gkBitmap::~gkBitmap(){ + FreeData(); +} + +void gkBitmap::FreeData(){ + if(data){ + delete data; + data = 0; + } + width = height = 0; +} + +void gkBitmap::Create(int _width, int _height){ + if(_width <= 0 || _height <= 0) return; + + FreeData(); + width = _width; + height = _height; + + //round up width to ensure multiple of 4 pixels + width = (width + 3) & (~3); + + int size = (width*height)<<2; + data = new gkBYTE[size]; + + //data = new gkBYTE[(width*height)<<2]; + bpp = 32; +} + +void gkBitmap::Cls(){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = 0xff000000; + } +} + +void gkBitmap::Cls(gkRGB color){ + if(!this->data) return; + + gkLONG *dest = (gkLONG*) this->data; + int i = this->width * this->height; + while(i--){ + *(dest++) = color.GetARGB(); + } +} + +void gkBitmap::Plot(int x, int y, gkRGB color, int testBoundaries){ + if(!data) return; + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return; + } + + gkRGB *dest = (gkRGB*) (data + ((y*width + x) << 2)); + *dest = color; +} + +gkRGB gkBitmap::Point(int x, int y, int testBoundaries){ + if(!data) return gkRGB(0,0,0); + if(testBoundaries){ + if(x<0 || x>=width || y<0 || y>=height) return gkRGB(0,0,0); + } + + gkRGB *color = (gkRGB*) (data + ((y*width + x) << 2)); + return *color; +} + +void gkBitmap::Line(int x1, int y1, int x2, int y2, gkRGB color){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + *(dest++) = color; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + *dest = color; + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkBitmap::LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, + int alpha){ + int temp; + if(y1==y2){ //straight horizontal line + if(x2 < x1) RectFill(x2,y1,(x1-x2)+1,1,color); + else RectFill(x1,y1,(x2-x1)+1,1,color); + return; + }else if(x1==x2){ //straight vertical line + if(y2 < y1) RectFill(x1,y2,1,(y1-y2)+1,color); + else RectFill(x1,y1,1,(y2-y1)+1,color); + return; + } + + + //clip line to screen + if(y2 < y1){ //orient line to be drawn from top to + temp = x1; x1 = x2; x2 = temp; //bottom for initial clipping tests + temp = y1; y1 = y2; y2 = temp; + } + if(y2 < 0 || y1 >= height) return; + + double xdiff = x2-x1, ydiff = y2-y1; + double slopexy = xdiff / ydiff; + int diff; + + //perform vertical clipping + diff = 0 - y1; + if(diff > 0){ //y1 is above top boundary + x1 += (int) (slopexy * diff); + y1 = 0; + } + diff = (y2 - height) + 1; + if(diff > 0){ //y2 is below bottom boundary + x2 -= (int) (slopexy * diff); + y2 = height - 1; + } + + //reorient line to be drawn from left to right for horizontal clipping tests + if(x2 < x1){ + temp = x1; x1 = x2; x2 = temp; + temp = y1; y1 = y2; y2 = temp; + xdiff = x2-x1; + ydiff = y2-y1; + } + double slopeyx = ydiff / xdiff; + + if(x2 < 0 || x1 >= width) return; + + diff = 0 - x1; + if(diff > 0){ //x1 is to left of left boundary + y1 += (int) (slopeyx * diff); + x1 = 0; + } + diff = (x2 - width) + 1; + if(diff > 0){ //x2 is to right of right boundary + y2 -= (int) (slopeyx * diff); + x2 = width - 1; + } + + //draw the line using Bresenham's + //coordinates are now such that x increment is always positive + int xdist = x2-x1; + int ydist = y2-y1; + int pitch = width; + gkRGB *dest = (gkRGB*) (data + (((y1 * width) + x1) <<2)); + if(ydist < 0){ + ydist = -ydist; + pitch = -pitch; + } + + int err, i; + if(xdist >= ydist){ //loop on x, change y every so often + err = 0; + for(i=xdist; i>=0; i--){ + dest->Combine(color,alpha); + dest++; + err += ydist; + if(err >= xdist){ + err -= xdist; + dest += pitch; + } + } + }else{ //loop on y, change x every so often + err = 0; + for(i=ydist; i>=0; i--){ + dest->Combine(color,alpha); + dest += pitch; + err += xdist; + if(err >= ydist){ + err -= ydist; + dest++; + } + } + } +} + +void gkBitmap::RectFrame(int x, int y, int w, int h, gkRGB color){ + int x2 = x + w - 1; + int y2 = y + h - 1; + RectFill(x,y,w,1,color); + RectFill(x,y2,w,1,color); + RectFill(x,y,1,h,color); + RectFill(x2,y,1,h,color); +} + +void gkBitmap::RectFill(int x, int y, int w, int h, gkRGB color){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkRGB *destStart = (gkRGB*) (data + (((y * width) + x) <<2)); + gkRGB *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; iCombine(color,alpha); + dest++; + } + destStart += width; + } +} + +void gkBitmap::RectFillChannel(int x, int y, int w, int h, + gkRGB color, int mask){ + int x2 = (x + w) - 1; + int y2 = (y + h) - 1; + + //Clip rectangle + if(x < 0) x = 0; + if(y < 0) y = 0; + + if(x2 >= width) x2 = width - 1; + if(y2 >= height) y2 = height - 1; + + if(x2 < x || y2 < y) return; + + //Set pointers and offsets + gkLONG *destStart = (gkLONG*) (data + (((y * width) + x) <<2)); + gkLONG *dest; + int numRows = (y2 - y) + 1; + int rowWidth = (x2 - x) + 1; + + gkLONG srcColor = color.GetARGB() & mask; + gkLONG destMask = ~mask; + + //do it + while(numRows--){ + dest = destStart; + + int i; + for(i=0; i=width || cur.y>=height) continue; + + //filling correct color check + if(!(*(cur.pos)==fillColor)) continue; + + //fill color & add adjacent + *(cur.pos) = color; + + queue[qTail++] = gkFillItem(cur.x+1,cur.y,cur.pos+1); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x-1,cur.y,cur.pos-1); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x,cur.y+1,cur.pos+width); + qTail &= 16383; + queue[qTail++] = gkFillItem(cur.x,cur.y-1,cur.pos-width); + qTail &= 16383; + } +} + +int gkBitmap::GetNumColors(){ + gkPaletteGenerator palGen; + int i = width * height; + gkRGB *src = (gkRGB*) data; + while(i--){ + palGen.AddColor(*(src++)); + } + + return palGen.GetNumColors(); +} + +void gkBitmap::RemapColor(gkRGB oldColor, gkRGB newColor){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } +} + +void gkBitmap::SetColorAlpha(gkRGB color, int alpha){ + if(!data) return; + + gkRGB *src = (gkRGB*) data; + int i, j; + for(j=0; jSetA(alpha); + } + src++; + } + } +} + +void gkBitmap::SetAlphaEdges(float opacity, int iterations){ + { //body in block to prevent recursive memory waste + gkBitmap work; + work.GetBitmap(this); + gkRGB *src = (gkRGB*) work.data; + gkRGB *dest = (gkRGB*) data; + gkRGB alpha; + int i, j; + for(j=0; jGetA()==255){ + int alpha = 0; + int samples = 0; + if(i>0 && j>0){ + alpha += work.Point(i-1,j-1).GetA(); + samples++; + } + if(i>0 && j0){ + alpha += work.Point(i+1,j-1).GetA(); + samples++; + } + if(iSetA(alpha); + } + dest++; + src++; + } + } + } + + if(iterations>0) SetAlphaEdges(opacity, iterations-1); +} + +void gkBitmap::MirrorH(){ + gkRGB *buffer = new gkRGB[width]; + if(!buffer) return; + + gkRGB *cur = (gkRGB*) data; + + int i,j,i2; + for(j=0; jdata) return 0; + + //adjust src rectangle until it fits within source data + if(x<0){ + w += x; + x = 0; + } + if(y<0){ + h += y; + y = 0; + } + if(x + w > srcBitmap->width){ + w = srcBitmap->width - x; + } + if(y + h > srcBitmap->height){ + h = srcBitmap->height - y; + } + + if(w<=0 || h<=0) return 0; + + FreeData(); + Create(w, h); + + gkBYTE *src = srcBitmap->data + ((y*srcBitmap->width + x)<<2); + gkBYTE *dest = this->data; + int srcSkip = srcBitmap->width << 2; //4 bytes per pixel + w <<= 2; //4 bytes per pixel + + while(h--){ + memcpy(dest, src, w); + dest += w; + src += srcSkip; + } + + return 1; +} + +int gkBitmap::GetBitmap(gkBitmap *srcBitmap){ + if(this->width != srcBitmap->width || this->height != srcBitmap->height + || (!this->data) || (!srcBitmap->data)){ + //mem needs to be reallocated + FreeData(); + memcpy(this, srcBitmap, sizeof(gkBitmap)); + data = 0; + if(srcBitmap->data){ + data = new gkBYTE[(width * height) << 2]; + memcpy(data, srcBitmap->data, (width * height) << 2 ); + } + }else{ + //already got right size mem, just copy data over + memcpy(data, srcBitmap->data, (width * height) << 2); + fontSpacing = srcBitmap->fontSpacing; + fontKerning = srcBitmap->fontKerning; + x_handle = srcBitmap->x_handle; + y_handle = srcBitmap->y_handle; + } + return data!=0; +} + +int gkBitmap::SaveBitmap(char *filename){ + ofstream outfile; + outfile.open(filename, ios::out | ios::binary); + if(!outfile) return 0; + + int result = SaveBitmap(outfile); + outfile.close(); + + return result; +} + +int gkBitmap::SaveBitmap(ostream &out){ + int totalSize = ((width * height) << 2); + + out << "SHPE"; + int skipSize = totalSize + 20; + gkIO::WriteLong(out, skipSize); + + //Write shape header + gkIO::WriteWord(out, 3); //type 3 + gkIO::WriteWord(out, width); + gkIO::WriteWord(out, height); + gkIO::WriteWord(out, (bpp==8)?8:32); + out << (char) fontSpacing << (char) fontKerning; + gkIO::WriteWord(out, x_handle); + gkIO::WriteWord(out, y_handle); + gkIO::WriteWord(out, 0); //6 bytes of reserved space + gkIO::WriteLong(out, 0); + + + //Write data + if(data){ + int pitch = width << 2; + gkLONG *src; + gkBYTE *srcStart = data; + + int i,j; + for(j=0; jLoadBitmap(infile); + infile.close(); + + return result; +} + +int gkBitmap::LoadBitmap(istream &infile){ + FreeData(); + if(infile.get() != 'S') return 0; + if(infile.get() != 'H') return 0; + if(infile.get() != 'P') return 0; + if(infile.get() != 'E') return 0; + + gkIO::ReadLong(infile); //discard skipsize + + //Read shape header + if(gkIO::ReadWord(infile) != 2) return 0; + width = gkIO::ReadWord(infile); + height = gkIO::ReadWord(infile); + int filebpp = gkIO::ReadWord(infile); + if(!bpp) bpp = filebpp; + + if(width && height){ + Create(width,height); + } + + fontSpacing = infile.get(); + fontKerning = infile.get(); + x_handle = gkIO::ReadWord(infile); + y_handle = gkIO::ReadWord(infile); + + gkIO::ReadWord(infile); + gkIO::ReadLong(infile); //discard reserved space + + if(!width || !height) return 1; //nothing to load, null shape + + int pitch = width << 2; + gkBYTE *destStart = data; + gkLONG *dest; + int x,y; + for(y=0; yLoadBMP(infile); + infile.close(); + + return result; +} + +int gkBitmap::LoadBMP(istream &infile){ + BMP_header header; + if(gkIO::ReadWord(infile)!=0x424d){ //check for "BM" + return 0; + } + infile.read((char*)&header, sizeof(BMP_header)); + if(header.bpp != 24){ + cout << "LoadBMP can only handle 24-bit files" << endl; + return 0; + } + + FreeData(); + width = header.width; + height = header.height; + bpp = (char) header.bpp; + Create(width,height); + + // load graphics, coverting every three (B,R,G) bytes to one ARGB value. + // lines padded to even multiple of 4 bytes + int srcPitch = ((header.width * 3) + 3) & (~3); + gkBYTE *buffer = new gkBYTE[srcPitch * height]; + gkBYTE *nextBuffPtr = buffer + ((height-1) * srcPitch); + gkBYTE *buffPtr; + + infile.read(buffer, srcPitch * height); + + gkBYTE *nextDest = data; + gkRGB *dest; + int destPitch = (width << 2); + + int i, j; + j = height; + while(j--){ + buffPtr = nextBuffPtr; + nextBuffPtr -= srcPitch; + dest = (gkRGB*) nextDest; + nextDest += destPitch; + i = header.width; + while(i--){ + dest->SetB(*(buffPtr++)); + dest->SetG(*(buffPtr++)); + dest->SetR(*(buffPtr++)); + dest->SetA(0xff); + dest++; + } + for(i=header.width; iSetARGB(0); + dest++; + } + } + + delete buffer; + + return 1; +} + +int gkBitmap::SaveBMP(char *filename){ + if(!data) return 0; + if(!filename) return 0; + + //open file + ofstream outfile; + outfile.open(filename, ios::out | ios::binary); + if(!outfile) return 0; + + outfile << 'B' << 'M'; //"BM" (file type) + + BMP_header header; + memset(&header,0,sizeof(header)); //clear everything to zero + header.width = width; + header.height = height; + header.bpp = 24; + header.planes = 1; + header.imageSize = (header.width * header.height * header.bpp) / 8; + header.headerSize = 40; + header.offsetBytes = 54; //header + palette size + header.fSize = 54 + header.imageSize; + + outfile.write((char*)&header, sizeof(BMP_header)); + + // save graphics as bottom-to-top, left-to-right // + int y = height - 1; + int pitch = width*4; + gkBYTE *src = data + (y * pitch); //find bottom of buffer + gkBYTE *d; + + //write brg bytes out + int i; + for(; y>=0; y--){ + d = src; + for(i=0; idata) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; //times 4 later + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destBitmap->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); //times 4 later + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destBitmap->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destBitmap->width; + + gkBYTE *dest = destBitmap->data + (((y * destBitmap->width) + x) << 2); + src = this->data + ((int)src << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } +} + + +////////////////////////////////////////////////////////////////////// +// Method: BlitColorToAlpha +// Description: Converts this bitmap's colors into alpha values on +// the destination bitmap. Black becomes transparent, +// white fully opaque. +////////////////////////////////////////////////////////////////////// +void gkBitmap::BlitColorToAlpha(gkBitmap *destBitmap, int x, int y){ + if(!data || !destBitmap || !destBitmap->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; //times 4 later + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destBitmap->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); //times 4 later + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destBitmap->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destBitmap->width; + + gkBYTE *dest = destBitmap->data + (((y * destBitmap->width) + x) << 2); + src = this->data + ((int)src << 2); + srcWidth <<= 2; + srcSkip <<= 2; + destSkip <<= 2; + + //blit converting color(B) to alpha. + while(lines--){ + MemCpyColorToAlpha(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } +} + +////////////////////////////////////////////////////////////////////// +// Function: BlitScale +// Arguments: destBitmap +// x +// y +// flags +// scale - number of source pixels for every one +// dest pixel, stored in 24:8 fixed point. +// $100=100%, $200=200% (mag x2), $80=50% +////////////////////////////////////////////////////////////////////// +void gkBitmap::BlitScale(gkBitmap *destBitmap, int x, int y, + int scale, int flags){ + if(!data || !destBitmap || !destBitmap->data || !scale) return; + + gkBYTE *src = 0; + int srcSkip = this->width; + int srcWidth = (this->width * scale) >> 8; + int lines = (this->height * scale) >> 8; + + //clip left side + if(x < 0){ + src += (-x << 8) / scale; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destBitmap->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += ((-y * this->width) << 8) / scale; + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destBitmap->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destBitmap->width; + + gkBYTE *dest = destBitmap->data + (((y * destBitmap->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int ratio = (int) ((1.0f / (((float) scale) / 256.0f)) * 256.0f); + + int lineError = 0; + while(lines--){ + BlitLineScale(dest, src, srcWidth, ratio); + lineError += ratio; + src += srcSkip * (lineError >> 8); + lineError &= 0xff; + dest += destSkip; + } + + /* + if(flags & GKBLT_TRANSPARENT){ + //blit using alpha 0 as fully transparent + while(lines--){ + MemCpyTrans(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + }else{ + //blit without a transparent color + while(lines--){ + memcpy(dest, src, srcWidth); + src += srcSkip; + dest += destSkip; + } + } + */ +} + +void gkBitmap::BlitScale(gkBitmap *destBitmap, int x, int y, + float scale, int flags){ + BlitScale(destBitmap,x,y,flags,(int) (256.0f * scale)); +} + +void gkBitmap::BlitChannel(gkBitmap *destBitmap, int x, int y, int mask){ + if(!data || !destBitmap || !destBitmap->data) return; + + gkBYTE *src = 0; + int srcWidth = this->width; + int srcSkip = this->width; + int lines = this->height; + + //clip left side + if(x < 0){ + src += -x; + srcWidth -= -x; + x = 0; + } + + //clip right side + int diff = (x + srcWidth) - destBitmap->width; + if(diff > 0){ + srcWidth -= diff; + } + + if(srcWidth <= 0) return; + + //clip top + if(y<0){ + src += (-y * this->width); + lines += y; //lines -= (-y) + y = 0; + } + + //clip bottom + diff = (y + lines) - destBitmap->height; + if(diff > 0){ + lines -= diff; + } + + if(lines <= 0) return; + + int destSkip = destBitmap->width; + + gkBYTE *dest = destBitmap->data + (((y * destBitmap->width) + x) << 2); + src = this->data + ((int)src << 2); + srcSkip <<= 2; + destSkip <<= 2; + + int inverseMask = ~mask; + + while(lines--){ + gkLONG *curSrc = (gkLONG*) src; + gkLONG *curDest = (gkLONG*) dest; + int pixels = srcWidth; + while(pixels--){ + *curDest = (*curSrc & mask) | (*curDest & inverseMask); + curSrc++; + curDest++; + } + src += srcSkip; + dest += destSkip; + } +} + +void gkBitmap::MemCpyTrans(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //copies colors using the Alpha for transparency + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + int c1; + while(numColors--){ + int alpha; + switch(alpha = (srcColor->GetA())){ + case 0: break; + case 255: //Straight copy + *destColor = *srcColor; + break; + default: //mix alpha + c1 = destColor->GetR(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetR()-c1, alpha); + destColor->SetR(c1); + c1 = destColor->GetG(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetG()-c1, alpha); + destColor->SetG(c1); + c1 = destColor->GetB(); + c1 += tranTable.LookupTransparencyOffset( + srcColor->GetB()-c1, alpha); + destColor->SetB(c1); + break; + } + srcColor++; + destColor++; + } +} + +void gkBitmap::MemCpyColorToAlpha(gkBYTE *dest, gkBYTE *src, + int numBytes){ + //converts blue to alpha during copy + gkRGB *destColor = (gkRGB*) dest; + gkRGB *srcColor = (gkRGB*) src; + int numColors = numBytes >> 2; + while(numColors--){ + destColor->SetA(srcColor->GetB()); + srcColor++; + destColor++; + } +} + +void gkBitmap::BlitLineScale(gkBYTE *dest,gkBYTE *src,int pixels,int ratio){ + gkRGB *srcRGB = (gkRGB*) src; + gkRGB *destRGB = (gkRGB*) dest; + + int error = 0; + + while(pixels--){ + *(destRGB++) = *srcRGB; + error += ratio; + srcRGB += error >> 8; + error &= 0xff; + } +} + diff --git a/Tools/MakeDiscoLights/gk.h b/Tools/MakeDiscoLights/gk.h new file mode 100644 index 0000000..cf51f5b --- /dev/null +++ b/Tools/MakeDiscoLights/gk.h @@ -0,0 +1,263 @@ +#ifndef GK_H +#define GK_H + +#include +#include +#include +#include +#include + +typedef unsigned char gkBYTE; +typedef short int gkWORD; +typedef int gkLONG; + +#ifndef min +#define min(a,b) (((a)<(b))?(a):(b)) +#define max(a,b) (((a)>(b))?(a):(b)) +#endif +#define limit(a,low,hi) (((a)hi)?hi:(a))) +#ifndef abs +#define abs(a) ((a)>=0?(a):(-(a))) +#endif +#ifndef sgn +#define sgn(a) ((a)>0?1:((a)<0?-1:0)) +#endif + +#define GKHANDLE_TL 0 +#define GKHANDLE_TC 1 +#define GKHANDLE_TR 2 +#define GKHANDLE_CR 3 +#define GKHANDLE_BR 4 +#define GKHANDLE_BC 5 +#define GKHANDLE_BL 6 +#define GKHANDLE_CL 7 +#define GKHANDLE_CENTER 8 + +#define GKBLT_TRANSPARENT 1 + +#ifdef _WIN32 + +#include + +class gkFileInputBuffer{ + protected: + char *buffer; + istrstream *stin; + int exists; + + public: + gkFileInputBuffer(char *filename); + ~gkFileInputBuffer(); + inline istream *GetIStream(){ return stin; } + inline operator istream*(){ return stin; } + inline int Exists(){ return exists; } +}; + +class gkFileOutputBuffer{ + protected: + ostrstream stout; + int exists; + HANDLE handle; + + public: + gkFileOutputBuffer(char *filename); + ~gkFileOutputBuffer(); + inline ostream *GetOStream(){ return &stout; } + inline operator ostream*(){ return &stout; } + inline int Exists(){ return exists; } +}; + +#endif + +class gkListItem{ + protected: + gkListItem *nextItem; + + public: + gkListItem(void){ nextItem = 0; } + inline void SetNextItem(gkListItem *next){ nextItem = next; } + inline void SetNext(gkListItem *next){ nextItem = next; } + inline gkListItem *NextItem(void){ return nextItem; } + inline gkListItem *GetNext(void){ return nextItem; } +}; + +class gkList{ + private: + gkListItem *head, *tail; + int numItems; + + public: + gkList(void); + ~gkList(void); + void Reset(); + inline gkListItem *FirstItem(void){ return head; } + inline gkListItem *GetFirst(){ return head; } + gkListItem *GetItem(int n); + void AddItem(gkListItem *d); + void DeleteItem(gkListItem *item); +}; + +class gkIO{ + public: + inline static int ReadByte(istream &in){ return in.get(); } + static int ReadWord(istream &in); + static int ReadLong(istream &in); + static char *ReadString(istream &in); + char *ReadNewString(istream &in); + inline static void WriteByte(ostream &out, int n){ out << (char) n; } + static void WriteLong(ostream &out, int n); + static void WriteWord(ostream &out, int n); + static void WriteString(ostream &out, char *st); +}; + +struct gkRGB_4bytes{ + unsigned char b, g, r, a; +}; + +union gkRGB_ColorUnion{ + gkRGB_4bytes bytes; + gkLONG argb; +}; + +class gkRGB{ + public: + gkRGB_ColorUnion color; + + inline gkRGB(){ color.argb = 0xff000000; } + inline gkRGB(int _r, int _g, int _b, int _a=255){ + color.bytes.r=_r; color.bytes.g=_g; color.bytes.b=_b; color.bytes.a=_a;} + inline void SetR(gkBYTE n){ color.bytes.r = n; } + inline void SetG(gkBYTE n){ color.bytes.g = n; } + inline void SetB(gkBYTE n){ color.bytes.b = n; } + inline void SetA(gkBYTE n){ color.bytes.a = n; } + inline void SetARGB(gkLONG n){ color.argb = n; } + inline gkBYTE GetR(){ return color.bytes.r; } + inline gkBYTE GetG(){ return color.bytes.g; } + inline gkBYTE GetB(){ return color.bytes.b; } + inline gkBYTE GetA(){ return color.bytes.a; } + inline gkLONG GetARGB(){ return color.argb; } + inline int operator==(gkRGB &c2){ + return ((color.argb & 0xffffff) == (c2.color.argb & 0xffffff)); } + inline int Equals(int _r, int _g, int _b); + void Combine(gkRGB c2, int alpha); + + void SetFromGBColor(int gbColor); +}; + +class gkPalGenItem{ + protected: + gkRGB color; + int occurrences; + gkPalGenItem *nextItem; + + public: + gkPalGenItem(gkRGB _color); + ~gkPalGenItem(); + inline gkRGB GetColor(); + inline void AddOccurrence(); + inline int GetOccurrences(); + inline void SetOccurrences(int n); + inline void SetNextItem(gkPalGenItem *item); + inline gkPalGenItem *GetNextItem(); + int GetCount(); + static int SortCallback(const void *e1, const void *e2); +}; + +class gkPaletteGenerator{ + protected: + gkPalGenItem *colorCube[13*4]; + + public: + gkPaletteGenerator(); + ~gkPaletteGenerator(); + void Reset(); + void AddColor(gkRGB color); + int GetNumColors(); + void CreatePalette(gkRGB *palette, int numEntries); + int GetHash(gkRGB color); + int ColorExists(gkRGB color); + gkRGB MatchColor(gkRGB color); +}; + +class gkTransparencyTable{ + protected: + gkBYTE *lookup; + + public: + gkTransparencyTable(); + ~gkTransparencyTable(); + inline int LookupTransparencyOffset(int baseOffset, int alpha); +}; + +class gkBitmap{ + friend class gkRGB; + + protected: + gkBYTE *data; + int width, height; + char bpp, fontSpacing, fontKerning; + short int x_handle, y_handle; + static gkTransparencyTable tranTable; + + public: + gkBitmap(); + ~gkBitmap(); + + inline gkBYTE* GetData(){ return data; } + inline int Exists(){ return data!=0; } + + void FreeData(); + inline void Reset(){ FreeData(); } + void Create(int _width, int _height); + void Cls(); + void Cls(gkRGB color); + void Plot(int x, int y, gkRGB color, int testBoundaries=1); + gkRGB Point(int x, int y, int testBoundaries=1); + void Line(int x1, int y1, int x2, int y2, gkRGB color); + void LineAlpha(int x1, int y1, int x2, int y2, gkRGB color, int alpha); + void RectFrame(int x, int y, int w, int h, gkRGB color); + void RectFill(int x, int y, int w, int h, gkRGB color); + void RectFillAlpha(int x, int y, int w, int h, gkRGB color, int alpha); + void RectFillChannel(int x, int y, int w, int h, gkRGB color, int mask); + void FloodFill(int x, int y, gkRGB color); + void RemapColor(gkRGB oldColor, gkRGB newColor); + int GetNumColors(); + int GetPalette(gkRGB *palette, int maxColors); + void RemapToPalette(gkRGB *palette, int numColors); + void ReduceColors(int numColors); + void ExchangeColors(gkRGB c1, gkRGB c2); + void SetAlpha(int alpha); + void SetColorAlpha(gkRGB color, int alpha); + void SetAlphaEdges(float opacity=0.5f, int iterations=1); + + void MirrorH(); + + int GetBitmap(gkBitmap *srcBitmap, int x, int y, int w, int h); + int GetBitmap(gkBitmap *srcBitmap); + int SaveBitmap(char *filename); + int SaveBitmap(ostream &outfile); + int LoadBitmap(char *filename); + int LoadBitmap(istream &infile); + int LoadBMP(char *filename); + int LoadBMP(istream &infile); + int SaveBMP(char *filename); + void Blit(gkBitmap *destBitmap, int x, int y, + int flags=GKBLT_TRANSPARENT); + void BlitColorToAlpha(gkBitmap *destBitmap, int x, int y); + void BlitScale(gkBitmap *destBitmap, int x, int y, int scale, + int flags=GKBLT_TRANSPARENT); + void BlitScale(gkBitmap *destBitmap, int x, int y, float scale, + int flags=GKBLT_TRANSPARENT); + void BlitChannel(gkBitmap *destBitmap, int x, int y, int mask); + + int GetWidth(){ return width; } + int GetHeight(){ return height; } + + //internal support routines + static void MemCpyTrans(gkBYTE *dest, gkBYTE *src, int nBytes); + static void MemCpyColorToAlpha(gkBYTE *dest, gkBYTE *src, int nBytes); + static void BlitLineScale(gkBYTE *dest, gkBYTE *src, int pixels,int ratio); +}; + +#endif + diff --git a/Tools/MakeDiscoLights/lights_all.bmp b/Tools/MakeDiscoLights/lights_all.bmp new file mode 100644 index 0000000..11ca1e3 Binary files /dev/null and b/Tools/MakeDiscoLights/lights_all.bmp differ diff --git a/Tools/MakeDiscoLights/makelights.cpp b/Tools/MakeDiscoLights/makelights.cpp new file mode 100644 index 0000000..29761a5 --- /dev/null +++ b/Tools/MakeDiscoLights/makelights.cpp @@ -0,0 +1,41 @@ +// makelights.cpp +// 2001.04.12 by Abe Pralle +// Converts "lights_all.bmp" into a raw set of 8*22*20 bytes +// "discolights.dat" + +#include +#include +#include "gk.h" + +int main(void){ + gkBitmap bmp; + if(!bmp.LoadBMP("lights_all.bmp")){ + cout << "Can't read lights_all.bmp!" << endl; + return 0; + } + + ofstream outfile("discolights.dat"); + if(!outfile){ + cout << "Can't open discolights.dat for writing!" << endl; + return 0; + } + + gkRGB white(255,255,255); + int i,j,k; + for(k=0; k<8; k++){ + for(j=0; j<18; j++){ + for(i=0; i<20; i++){ + if(bmp.Point(k*20+i,j)==white){ + outfile.put((char)1); + }else{ + outfile.put((char)0); + } + } + } + } + + outfile.close(); + + return 0; +} + diff --git a/Tools/MakeDiscoLights/makelights.exe b/Tools/MakeDiscoLights/makelights.exe new file mode 100644 index 0000000..750b95d Binary files /dev/null and b/Tools/MakeDiscoLights/makelights.exe differ diff --git a/Tools/MakeGBM/makegbm.cpp b/Tools/MakeGBM/makegbm.cpp new file mode 100644 index 0000000..bc74bd9 --- /dev/null +++ b/Tools/MakeGBM/makegbm.cpp @@ -0,0 +1,844 @@ +// makegbm.cpp +// 2000.08.19 by Abe Pralle +// Plasma Works Game Boy Music Compiler + +#include "makegbm.h" + +#include +#include +#include +#include + +#define PERCUSSION_VOLUME 0x51 +// ride rd 20 71 00 80 +// snare sn 3f 71 17 80 +// bass bs 00 71 90 80 +// tom1 ta 2b 71 57 80 +// tom2 tb 2b 71 47 80 + +Label::Label(){ + text = 0; + pc = 0; +} + +Label::~Label(){ + if(text) delete text; + text = 0; +} + +Label::SetLabel(char *st,int pcPos){ + if(text) delete text; + text = new char[strlen(st)+1]; + strcpy(text,st); + pc = pcPos; +} + +GBMParser::GBMParser(){ + notesPerSecond = 4; + + curBaseLabel = new char[5]; + strcpy(curBaseLabel,"main"); + + track = 2; + + pc = 0; //program counter + line = 1; //line number + + numLabels = 0; + + track1Start = track2Start = track3Start = track4Start = 0; + + outfile = 0; + + lastByteWritten = 2; + + envelope1 = 0xf1; //default envelopes for restoring after a hold + envelope2 = 0xc2; + duration3 = 0xcf; + envelope4 = 0xf0; + repeat1 = repeat2 = repeat3 = repeat4 = 0; +} + + +GBMParser::~GBMParser(){ + delete curBaseLabel; + curBaseLabel = 0; + if(outfile){ + delete outfile; + outfile = 0; + } +} + + +int GBMParser::Compile(char *sourcefile){ + ifstream infile(sourcefile,ios::in | ios::binary | ios::nocreate); + if(!infile){ + cout << "Error: Can't open input file " << sourcefile << endl; + return 0; + } + + transpose = 0; + + pc += 4; //space for infinite nop loop + lastByteWritten = 2; + + //pass 1: collect labels + cout << "Pass 1..."; + char *input; + for(input=GetInput(infile); !infile.eof(); input=GetInput(infile)){ + if(!AddLabel(input)){ + //not a label or comment + if(!HandleCommand(infile,input,0)) return 0; + } + } + + //open the output file + char outputFilename[256]; + ostrstream stout(outputFilename,256); + stout << sourcefile << ".bin" << ends; + outfile = new ofstream(outputFilename,ios::out|ios::binary); + if(!(*outfile)){ + delete outfile; + outfile = 0; + return Error("Can't open output file"); + } + + //write out header + track1Start += 6; + track2Start += 4; + track3Start += 2; + + Write(1); //version + Write(60 / notesPerSecond); + Write(0); //flags + Write(0); //pad1 + Write(0); //pad2 + Write(0); //pad3 + Write(0); //pad4 + Write(0); //pad5 + Write(track1Start & 0xff); + Write((track1Start>>8) & 0xff); + Write(track2Start & 0xff); + Write((track2Start>>8) & 0xff); + Write(track3Start & 0xff); + Write((track3Start>>8) & 0xff); + Write(track4Start & 0xff); + Write((track4Start>>8) & 0xff); + + //write infinite nop loop + pc = 0; + Write(0); //nop + Write(0x6e); //jump.l cc=always + Write(0xfc); //-4 offset + Write(0xff); + + lastByteWritten = 2; + + //pass 2: generate code + cout << "Pass 2..."; + infile.close(); + infile.open(sourcefile,ios::in | ios::binary); + line = 1; + delete curBaseLabel; + curBaseLabel = new char[5]; + strcpy(curBaseLabel,"main"); + track = 2; + + for(input=GetInput(infile); !infile.eof(); input=GetInput(infile)){ + + if(input[0]=='.'){ //sub label + //char st[1024]; + //ostrstream stout(st,1024); + //stout << curBaseLabel << input << '.' << track << ends; + //labelList[numLabels++].SetLabel(st,pc); + }else if(input[strlen(input)-1]==':'){ // base label + int len = strlen(input); + if(curBaseLabel) delete curBaseLabel; + curBaseLabel = new char[len+3]; + { + ostrstream stout(curBaseLabel,len+3); + stout << input; + stout.seekp(stout.tellp()-1); //erase ':' + stout << ends; + } + + //char st[1024]; + //ostrstream stout(st,1024); + //stout << curBaseLabel << '.' << track << ends; + //labelList[numLabels++].SetLabel(st,pc); + }else{ + //not a label or comment + if(!HandleCommand(infile,input,1)) return 0; + } + } + + //write a return at the end + Write(2); + + cout << "Compilation successful to " << sourcefile << ".bin" << endl; + + return 1; +} + +char *GBMParser::GetInput(istream &in){ + static char buffer[1024]; + int pos=0; + + //eat whitespace + char ch; + for(ch=in.get(); ; ch=in.get()){ + if(in.eof()) return 0; + if(ch==10) line++; + if(ch==' ' || ch==9 || ch==10 || ch==13) continue; + break; + } + + //eat comments + if(ch=='/'){ + if(in.get()!='/'){ + in.unget(); + }else{ + for(ch=in.get(); ch!=10; ch=in.get()){ + if(in.eof()) return 0; + } + line++; + return GetInput(in); + } + } + + //accumulate the word + for(;;){ + buffer[pos++]=ch; + ch = in.get(); + if(in.eof()){ + buffer[pos]=0; + return buffer; + } + if(ch==10) line++; + if(ch==','||ch==' '||ch==9||ch==10||ch==13) break; //end of word + } + buffer[pos] = 0; //null terminate the word + return buffer; +} + +int GBMParser::GetByte(istream &in){ + int togo = 2; + int value = 0; + while(togo>0){ + int ch = in.get(); + if(ch>='A' && ch<='F') ch+=32; + if(ch>='a' && ch<='f'){ + value = value*16 + ((ch-'a')+10); + togo--; + }else if(ch>='0' && ch<='9'){ + value = value * 16 + (ch - '0'); + togo--; + }else if(ch != ',' && ch!=' '){ + char st[80]; + ostrstream stout(st,80); + stout << "Expecting hex digit, got " << ch << ends; + Error(st); + return -1; + } + } + return value; +} + +int GBMParser::GetRegister(istream &in){ + //eat white space until we find an "r" + int ch; + for(ch=in.get(); ch!='r'; ch=in.get()){ + if(in.eof()) return -1; + if(ch!=' ' && ch!=9 && ch!=','){ + in.unget(); + return -1; + } + } + + int value = 0; + for(ch=in.get(); ch>='0' && ch<='9'; ch=in.get()){ + if(in.eof()) return -1; + value = value*10 + (ch - '0'); + } + in.unget(); + + return value; +} + +int GBMParser::GetDecimal(istream &in){ + //eat white space until we find a number + int ch; + int negative = 1; + for(ch=in.get(); ch<'0' || ch>'9'; ch=in.get()){ + if(in.eof()) return -1; + if(ch=='-'){ + negative = -1; + }else if(ch!=' ' && ch!=9 && ch!=','){ + in.unget(); + return -1; + } + } + + int value = ch - '0'; + for(ch=in.get(); ch>='0' && ch<='9'; ch=in.get()){ + if(in.eof()) return value*negative; + value = value*10 + (ch - '0'); + } + in.unget(); + + return value*negative; +} + +int GBMParser::GetHold(istream &in){ + //eat white space until we find an h or non-h + int ch; + for(ch=in.get(); ch!='h' && ch!='H'; ch=in.get()){ + if(in.eof()) return 0; + if(ch==10) line++; + if(ch!=' ' && ch!=9 && ch!=',' && ch!=10 && ch!=13){ + in.unget(); + return 0; + } + } + + //multiplier? + int num = GetDecimal(in); + if(num>0) return num + GetHold(in); + else return 1 + GetHold(in); +} + +int GBMParser::HandleCommand(istream &in, char *cmd, int genCode){ + + int ch0 = cmd[0],i; + if(ch0>='A' && ch0<='Z') ch0+=32; + + if(stricmp(cmd,"track")==0){ + char *trackNum = GetInput(in); + if(!trackNum) return Error("Expecting track number 1-4"); + + track = trackNum[0] - '0'; + if(track<1 || track>4){ + return Error("Track number must be 1-4"); + } + + //implied "ret" if last command not "ret" + if(lastByteWritten != 2) Write(2); + + if(track==1 && track1Start==0) track1Start = pc; + if(track==2 && track2Start==0) track2Start = pc; + if(track==3 && track3Start==0) track3Start = pc; + if(track==4 && track4Start==0) track4Start = pc; + + }else if(stricmp(cmd,"transpose")==0){ + transpose = GetDecimal(in); + }else if(stricmp(cmd,"rd")==0){ + Write(7); + Write(0x20); + Write(PERCUSSION_VOLUME); + envelope4 = 0xf1; + Write(0x00); + Write(0x80); + repeat4 = 1; + }else if(stricmp(cmd,"sn")==0){ + Write(7); + Write(0x3f); + Write(PERCUSSION_VOLUME); + envelope4 = 0xf1; + Write(0x17); + Write(0x80); + repeat4 = 1; + }else if(stricmp(cmd,"bs")==0){ + Write(7); + Write(0x00); + Write(PERCUSSION_VOLUME); + envelope4 = 0xf1; + Write(0x90); + Write(0x80); + repeat4 = 1; + }else if(stricmp(cmd,"ta")==0){ + Write(7); + Write(0x2b); + Write(PERCUSSION_VOLUME); + envelope4 = 0xf1; + Write(0x57); + Write(0x80); + repeat4 = 1; + }else if(stricmp(cmd,"tb")==0){ + Write(7); + Write(0x2b); + Write(PERCUSSION_VOLUME); + envelope4 = 0xf1; + Write(0x47); + Write(0x80); + repeat4 = 1; + }else if(stricmp(cmd,"notesPerSecond")==0){ + notesPerSecond = GetDecimal(in); + if(notesPerSecond==-1) + return Error("Expecting decimal notesPerSecond value"); + }else if(stricmp(cmd,"skip")==0 || cmd[0]=='-' || cmd[0]=='h'||cmd[0]=='H'){ + istrstream inst(cmd+1,strlen(cmd)-1); + int repeatCount = GetDecimal(inst); + Write(0); + if(repeatCount>0){ + for(i=1; i>8) & 0xff); + }else{ + pc += 2; + } + }else if(stricmp(cmd,"call")==0){ + int cc; + char *ccst = GetInput(in); + if(stricmp(ccst,"lt")==0) cc = 0; + else if(stricmp(ccst,"le")==0) cc = 1; + else if(stricmp(ccst,"eq")==0) cc = 2; + else if(stricmp(ccst,"ge")==0) cc = 3; + else if(stricmp(ccst,"gt")==0) cc = 4; + else if(stricmp(ccst,"ne")==0) cc = 5; + else cc = 6; //jump always + + Write(0x78 + cc); //opcode + + char *label; + if(cc!=6) label = GetInput(in); + else label = ccst; + + if(genCode){ + int pos = GetLabel(label); + if(pos==-1){ + Error("Undefined label referenced"); + return Error(label); + } + int offset = pos - (pc + 2); + Write(offset & 0xff); + Write((offset>>8) & 0xff); + }else{ + pc += 2; + } + }else if((ch0>='a' && ch0<='g') && (cmd[1]>='3' && cmd[1]<='8')){ + + int freq = LookupFrequency(cmd); + if(!freq) return 0; + freq |= 0x8000; //set play bit + + //note + int hold = GetHold(in); + //cout << cmd << " got hold " << hold << endl; + + //write out the note + if(track==1){ + Write(0x04); + if(!repeat1) freq |= 0x4000; + } + else if(track==2){ + Write(0x05); + if(!repeat2) freq |= 0x4000; + }else if(track==3){ + Write(0x06); + if(!repeat3) freq |= 0x4000; + } + Write(freq & 0xff); + Write((freq>>8) & 0xff); + + //write out "hold" number of nops + for(i=0; i1){ + //write a note without fade + if(track==1){ + Write(0x08); + Write(0xf0); + }else if(track==2){ + Write(0x09); + Write(0xf0); + }else if(track==3){ + Write(0x0a); + Write(0x00); + }else if(track==4){ + Write(0x0b); + Write(0xf0); + } + + //write note w/repeat flag set + Write(freq & 0xff); + Write(((freq|0x4000)>>8)&0xff); + + //repeat this note for the hold between the start and end + for(i=2; i>8) & 0xff); + }else{ + } + */ + + }else if(ch0>='a' && ch0<='z'){ //implied function call + if(genCode){ + int pos = GetLabel(cmd); + if(pos==-1){ + Error("Undefined label referenced"); + return Error(cmd); + } + Write(0x7e); //long call cc=always opcode + int offset = pos - (pc + 2); + Write(offset & 0xff); + Write((offset>>8) & 0xff); + }else{ + pc += 3; + } + }else{ + char st[80]; + ostrstream stout(st,80); + stout << "Unexpected input: " << cmd << ends; + return Error(st); + } + return 1; +} + +int GBMParser::Error(char *st){ + cout << "Error (" << line << "): " << st << endl; + return 0; +} + +int GBMParser::AddLabel(char *text){ + if(GetLabel(text)>=0) return Error("Label already exists"); + if(numLabels >= MAX_LABELS) return Error("Max labels reached!"); + if(text[0]=='.'){ //sub label + char st[1024]; + ostrstream stout(st,1024); + stout << curBaseLabel << text << '.' << track << ends; + labelList[numLabels++].SetLabel(st,pc); + + }else if(text[strlen(text)-1]==':'){ // base label + int len = strlen(text); + if(curBaseLabel) delete curBaseLabel; + curBaseLabel = new char[len+3]; + { + ostrstream stout(curBaseLabel,len+3); + stout << text; + stout.seekp(stout.tellp()-1); //erase ':' + stout << ends; + } + + char st[1024]; + ostrstream stout(st,1024); + stout << curBaseLabel << '.' << track << ends; + labelList[numLabels++].SetLabel(st,pc); + }else{ + return 0; //not a label + } + return 1; +} + +int GBMParser::GetLabel(char *st){ + char text[120]; + ostrstream stout(text,120); + + if(st[0]=='.') stout << curBaseLabel << st << '.' << track << ends; + else if(st[strlen(st)-1]==':'){ + stout << st; + stout.seekp(stout.tellp()-1); //get rid of the ':' + stout << '.' << track << ends; + }else stout << st << '.' << track << ends; + + int i; + for(i=0; i 71) return Error("Bad note computation"); + //if(stricmp(st,"a4")==0) cout << st << " " << frequencyTable[index] << endl; + + return frequencyTable[index]; +} + +void GBMParser::Write(int n){ + if(outfile){ + outfile->put((char) n); + //cout << pc << ": " << n << endl; + } + lastByteWritten = n; + pc++; +} + +//-------------------------------------------------------------------- +// +int main(int argc, char *argv[]){ + if(argc==1){ + cout << "Usage: makegbm filename.gtx [file2.gtx...]" << endl; + exit(1); + } + + int i; + for(i=1; i +#include + +#define MAX_LABELS 4096 + +class Label{ + protected: + int pc; + char *text; + + public: + Label(); + ~Label(); + + SetLabel(char *st, int pcPos); + int GetPC(){ return pc; } + char *GetText(){ return text; } +}; + +class GBMParser{ +protected: + int notesPerSecond; + char *curBaseLabel; + int track; + int track1Start, track2Start, track3Start, track4Start; + int envelope1,envelope2,duration3,envelope4; + int repeat1,repeat2,repeat3,repeat4; + int pc; + int line; + Label labelList[MAX_LABELS]; + int numLabels; + int lastByteWritten; + ofstream *outfile; + int transpose; + +public: + GBMParser(); + ~GBMParser(); + + int Compile(char *sourcefile); + +protected: + char *GetInput(istream &in); + int GetByte(istream &in); + int GetRegister(istream &in); + int GetDecimal(istream &in); + int GetHold(istream &in); + int HandleCommand(istream &in, char *cmd, int genCode); + int Error(char *st); + + int AddLabel(char *text); + int GetLabel(char *st); + int LookupFrequency(char *st); + void Write(int n); +}; + diff --git a/Tools/MapMaker/.gitignore b/Tools/MapMaker/.gitignore new file mode 100644 index 0000000..3cb458f --- /dev/null +++ b/Tools/MapMaker/.gitignore @@ -0,0 +1 @@ +Images diff --git a/Tools/MapMaker/Build.rogue b/Tools/MapMaker/Build.rogue new file mode 100644 index 0000000..79c8aa4 --- /dev/null +++ b/Tools/MapMaker/Build.rogue @@ -0,0 +1,385 @@ +# To run this build file, install Rogue from github.com/AbePralle/Rogue then cd +# to this folder and type "rogo" at the command line. + +# description()s are optional - Rogo uses introspection to determine which +# commands are available. 'rogo help default' displays the description for +# "default", etc. +description( "default", "The default action is performed when no other actions are specified. Use 'rogo default' to explicitly perform the default option." ) +description( "help", "Displays a list of all actions that can be performed by Rogo." ) + +#$ LIBRARIES(macOS) = libpng libjpeg zlib +#$ LIBRARIES(Linux-apt) = libpng-dev libjpeg-dev + +augment Build + # You can create a Local.mk file with overrides for these values, e.g.: + # LAUNCHER_FOLDER = "~/bin" + PROPERTIES + PROJECT = "MapMaker" + LAUNCHER_NAME = "mapmaker" + LAUNCHER_FOLDER = "/usr/local/bin" +endAugment + +routine exe_filepath->String + if (System.is_windows) return "Build/$.exe" (Build.LAUNCHER_NAME) + return "Build/$-$" (Build.PROJECT,System.os) +endRoutine + +routine launcher_folder->String + local result = Build.LAUNCHER_FOLDER + result = File.expand_filepath( result ) + return File.without_trailing_separator( result ) +endRoutine + +routine rogo_default + rogo_build + rogo_run + #rogo_install_launcher # Uncomment to automatically install a /usr/local/bin/mapmaker launcher +endRoutine + +routine rogo_build + block exe_filepath + local source_files = Files( "Source", "**/*.rogue" ) + local src_filepath = "Source/$.rogue" (Build.PROJECT) + if (source_files.any_newer_than(exe_filepath)) + local cpp_filepath = "Build/$-$.cpp" (Build.PROJECT,System.os) + if (source_files.any_newer_than(cpp_filepath)) + execute "roguec $ --main --output=$ --target=Console,C++,$" (src_filepath,cpp_filepath,System.os) + endIf + if (System.is_windows) + local libs = "" + local cc = "cl /EHsc /nologo $ /Fe$ $" (cpp_filepath,exe_filepath,libs) + #cc += " /link /LTCG" # uncomment this if there are errors linking libraries + execute cc + else + local libs = which{ System.is_linux:" $LIBRARY_FLAGS(libpng-dev,libjpeg-dev)" || " $LIBRARY_FLAGS(libpng,libjpeg,zlib)" } + local cc = "c++ -Wall -std=gnu++11 -fno-strict-aliasing -Wno-invalid-offsetof $ -o $$" (cpp_filepath,exe_filepath,libs) + execute cc + endIf + endIf + endBlock +endRoutine + +routine rogo_run + execute File.conventional_filepath(exe_filepath) +endRoutine + +routine rogo_install_launcher + local exe_filepath = File.absolute_filepath( exe_filepath ) + if (System.is_windows) + local exe_folder = File.conventional_filepath( File.folder(exe_filepath) ) + local path = System.environment//PATH + if (not path.to_lowercase.contains(exe_folder.to_lowercase)) + println + println ''Add the following to your system PATH then reopen this command prompt to be able'' + println ''to launch $ by typing "$":'' (Build.PROJECT,Build.LAUNCHER_NAME) + println + println " ADD THIS TO YOUR PATH" + println " " + exe_folder + endIf + else + contingent + local result = Process.run( "which " + Build.LAUNCHER_NAME, &env ) + necessary (result.success) + local launcher_filepath = result->String.trimmed + necessary launcher_filepath + necessary File.load_as_string( launcher_filepath ).contains( exe_filepath ) + + unsatisfied + local launcher_filepath = "$/$" (launcher_folder,Build.LAUNCHER_NAME) + println "Creating launcher " + launcher_filepath + local sudo = "" + loop + try + if (not File.exists(launcher_folder)) execute( "$mkdir $"(sudo,launcher_folder) ) + File.save( "$.launcher"(Build.LAUNCHER_NAME), ''#!/bin/sh\nexec "$" "$@"\n''(exe_filepath,'$') ) + execute( "$mv $.launcher $"(sudo,Build.LAUNCHER_NAME,launcher_filepath) ) + execute( "$chmod a+x $"(sudo,launcher_filepath) ) + escapeLoop + catch (err:Error) + if (sudo != "") throw err + sudo = "sudo " + endTry + endLoop + endContingent + endIf +endRoutine + +routine rogo_clean + verbose_delete( "Build" ) + if (not System.is_windows) verbose_delete( "$/$"(launcher_folder,Build.LAUNCHER_NAME) ) +endRoutine + +routine verbose_delete( filepath:String ) + if (File.exists(filepath)) + println "> Delete " + filepath + if (not File.delete(filepath)) + println "*** Failed to delete - retrying with sudo" + local cmd = ''sudo rm -rf $'' (File.shell_escaped(filepath)) + execute cmd + endIf + endIf +endRoutine + +routine execute( commands:String, &suppress_error )->Logical + forEach (cmd in LineReader(commands)) + print( "> " ).println( cmd ) + if (System.run(cmd) != 0) + if (suppress_error) return false + else throw Error( "Build failed." ) + endIf + endForEach + return true +endRoutine + +#------------------------------------------------------------------------------- +# Introspection-based Launcher Framework +#------------------------------------------------------------------------------- +# Rogo is a "build your own build system" facilitator. At its core Rogo just +# recompiles build files if needed and then runs the build executable while +# forwarding any command line arguments. This file contains a default framework +# which uses introspection to turn command line arguments into parameterized +# routine calls. + +# Example: to handle the command "rogo abc xyz 5", define +# "routine rogo_abc_xyz( n:Int32 )". + +# "rogo_default" will run in the absence of any other command line argument. + +# The following "comment directives" can be used in this file to control how +# RogueC compiles it and to manage automatic dependency installation and +# linking. + +# Each of the following should be on a line beginning with the characters #$ +# (preceding whitespace is fine). Sample args are given. + +# ROGUEC = roguec # Path to roguec to compile this file with +# ROGUEC_ARGS = --whatever # Additional options to pass to RogueC +# CPP = g++ -Wall -std=gnu++11 -fno-strict-aliasing +# -Wno-invalid-offsetof # C++ compiler path and/or invocation +# CPP_ARGS = -a -b -c # Additional C++ args +# LINK = true # Links following LIBRARIES with this Build +# # file (otherwise just installs them) +# LINK = -lalpha -lbeta # Links following LIBRARIES and includes +# # these additional flags +# LINK = false # Linking turned off for following +# # LIBRARIES - info can still be obtained +# # from $LIBRARY_FLAGS() +# LINK(macOS) = ... # Options applying only to +# # System.os=="macOS" (use with any OS and +# # any comment directive) +# LIBRARIES = libalpha +# LIBRARIES = libbeta(library-name) +# LIBRARIES = libfreetype6-dev(freetype2) +# DEPENDENCIES = Library/Rogue/**/*.rogue +# +# LIBRARIES = name(package) +# LIBRARIES = name(package: install: +# link: which:) +# +# The following macro is replaced within this file (Build.rogue) - the libraries +# should normally also be declared in #$ LIBRARIES: +# +# $LIBRARY_FLAGS(lib1,lib2) # sample macro +# -> +# -Ipath/to/lib1/include -Lpath/to/lib1/library -I ... # sample replacement + +routine syntax( command:String, text:String ) + Build.rogo_syntax[ command ] = text +endRoutine + +routine description( command:String, text:String ) + Build.rogo_descriptions[ command ] = text +endRoutine + +routine help( command:String, description=null:String, syntax=null:String ) + if (description) Global.description( command, description ) + if (syntax) Global.syntax( command, syntax ) +endRoutine + +try + Build.launch +catch (err:Error) + Build.rogo_error = err + Build.on_error +endTry + +class Build [singleton] + PROPERTIES + rogo_syntax = StringTable<>() + rogo_descriptions = StringTable<>() + rogo_prefix = ?:{ $moduleName.count:$moduleName "::" || "" } + "rogo_" : String + rogo_command = "default" + rogo_args = @[] + rogo_error : Error + + LOCAL_DEFS_FILE = "Local.mk" + + METHODS + method launch + rogo_args.add( forEach in System.command_line_arguments ) + read_defs + on_launch + parse_args + dispatch_command + + method dispatch_command + local m = find_command( rogo_command ) + require m + + local args = @[] + forEach (arg in rogo_args) + which (arg) + case "true": args.add( true ) + case "false": args.add( false ) + case "null": args.add( NullValue ) + others: args.add( arg ) + endWhich + endForEach + if (m.parameter_count == 1 and args.count > 1) args = @[ args ] # Wrap args in a ValueList. + m.call( Global, args ) + + method find_command( name:String )->MethodInfo + return <>.find_method( rogo_prefix + name ) + + method on_error + Console.error.println "=" * 79 + Console.error.println rogo_error + Console.error.println "=" * 79 + on_exit + System.exit 1 + + method on_command_found + noAction + + method on_command_not_found + println "=" * 79 + println "ERROR: No such command '$'." (rogo_args.first) + println "=" * 79 + println + rogo_command = "help" + rogo_args.clear + on_command_found + + method on_launch + noAction + + method on_exit + noAction + + method parse_args + block + if (rogo_args.count) + local parts = String[] + parts.add( forEach in rogo_args ) + rogo_args.clear + + while (parts.count) + local cmd = _join( parts ) + if (find_command(cmd)) + rogo_command = cmd + on_command_found + escapeBlock + endIf + rogo_args.insert( parts.remove_last ) + endWhile + + on_command_not_found + endIf + + # Use default command + on_command_found + endBlock + + method read_defs + read_defs( LOCAL_DEFS_FILE ) + + method read_defs( defs_filepath:String ) + # Attempt to read defs from Local.mk + local overrides = String[] + if (File.exists(defs_filepath)) + forEach (line in LineReader(File(defs_filepath))) + if (line.contains("=")) + local name = line.before_first('=').trimmed + local value = line.after_first('=').trimmed + if (value.begins_with('"') or value.begins_with('\'')) + value = value.leftmost(-1).rightmost(-1) + endIf + local p = <>.find_property( name ) + if (p) + overrides.add( "$ = $" (name,value) ) + <>.set_property( this, p, Value(value) ) + endIf + endIf + endForEach + endIf + + method _join( value:Value )->String + local args = String[] + args.add( forEach in value ) + return args.join( "_" ) +endClass + + +routine rogo_help( command="":String ) + command = Build._join( Build.rogo_args ) + if (command.count) + local syntax = get_syntax( command ) + local success = false + if (syntax) + println "SYNTAX" + println " " + syntax + println + success = true + endIf + local description = get_description( command ) + if (description) + println "DESCRIPTION" + forEach (line in LineReader(description.word_wrapped(76))) + print( " " ).println( line ) + endForEach + println + success = true + endIf + if (success) + return + else + println "=" * 79 + println "ERROR: No such command '$'." (command) + println "=" * 79 + println + endIf + endIf + + println "USAGE" + local lines = String[] + forEach (m in <>.methods) + if (m.name.begins_with(Build.rogo_prefix)) + lines.add( " " + get_syntax(m.name.after_first(Build.rogo_prefix)) ) + endIf + endForEach + lines.sort( (a,b)=>(aString + if (Build.rogo_syntax.contains(m_name)) + return "rogo " + Build.rogo_syntax[ m_name ] + else + local m = <>.find_method( Build.rogo_prefix + m_name ) + if (not m) return null + local line = "rogo $" (m_name.replacing('_',' ')) + line += " <$>" (m.parameter_name(forEach in 0..String + if (Build.rogo_descriptions.contains(m_name)) + return Build.rogo_descriptions[ m_name ] + else + return null + endIf +endRoutine diff --git a/Tools/MapMaker/Source/MapMaker.rogue b/Tools/MapMaker/Source/MapMaker.rogue new file mode 100644 index 0000000..a1cf887 --- /dev/null +++ b/Tools/MapMaker/Source/MapMaker.rogue @@ -0,0 +1,617 @@ +#=============================================================================== +# MapMaker.rogue +# July 6, 2020 +#=============================================================================== +$requireRogue "1.7.5" + +uses Bitmap + +MapMaker() + +class MapMaker + DEFINITIONS + SCALED_WIDTH = 640 + SCALED_HEIGHT = 576 + + PROPERTIES + levels = FGBLevel[] + + METHODS + method init + File.create_folder( "../../Media/Levels" ) + print( "Rendering level images" ).flush + forEach (filepath at index in File.listing("../../Data/Levels/L*.lvl")) + if (index % 10 == 9) print( '.' ).flush + levels.add( FGBLevel(filepath) ) + endForEach + println + require levels.count + + print( "Saving level images" ).flush + forEach (level at index in levels) + if (index % 10 == 9) print( '.' ).flush + level.bitmap.save_as_png( "../../Media/Levels/$.png"(level.level_number.format("04")) ) + endForEach + println + + File.create_folder( "../../Media/Maps" ) + + local map = Bitmap( SCALED_WIDTH*11, SCALED_HEIGHT*11, Color.BLACK ) + print( "Building WorldMap-Rendered.png" ).flush + forEach (level at index in levels) + if (index % 10 == 9) print( '.' ).flush + if (level.column < 11 and level.row < 11) + place( level, map, level.column, level.row ) + endIf + endForEach + println + + println "Saving WorldMap-Rendered.png" + map.save_as_png( "../../Media/Maps/WorldMap-Rendered.png" ) + + create_map( "MoonBase.png", + [ + [ -1, 0213, -1, 0314, 0215], + [0013, 0113, 0214, 0114, 0115], + [0313, 0315, -1, 0014, 0015] + ] + ) + + create_map( "Tower.png", + [ + [0411], + [0311], + [0211], + [0111] + ] + ) + + create_map( "FourSeasonsHouse.png", 0011 ) + + create_map( "SunsetVillageHouses.png", + [ + [0212,0312,0412] + ] + ) + + create_map( "SpaceStationApocalypse.png", + [ + [0811,0012,0911], + [1011,0711,1111] + ] + ) + + create_map( "TheHive.png", + [ + [0000,0112] + ] + ) + + create_map( "WitchsHouse.png", + [ + [0512], + [0508] + ] + ) + + create_map( "FarmLanding.png", + [ + [0103], + [0712] + ] + ) + + create_map( "TheAppomattox.png", 1300 ) + #create_map( "DemoWarpZone.png", 0812 ) # can set L1100.asm to exit to 0812; was not in final game + + create_map( "MonkeyHomeworldAndCroutonHomeworld.png", + [ + [ -1, -1,1512], + [ -1, -1,1412], + [ -1,1112,1312], + [0612,0912,1212], + [0808,1012, -1] + ] + ) + + + method create_map( filename:String, level_numbers:Int32[][] ) + local h = level_numbers.count + local w = level_numbers.first.count + + local map = Bitmap( SCALED_WIDTH*w, SCALED_HEIGHT*h, Color.BLACK ) + forEach (row at j in level_numbers) + forEach (number at i in row) + if (number == -1) nextIteration + local level = levels.find( $.level_number == number ) + if (level.exists) + place( level.value, map, i, j ) + endIf + endForEach + endForEach + + println "Saving "+filename + map.save_as_png( "../../Media/Maps/"+filename ) + + method create_map( filename:String, level_number:Int32 ) + local level = levels.find( $.level_number == level_number ) + require level.exists + println "Saving "+filename + level.value.bitmap.save_as_png( "../../Media/Maps/"+filename ) + + + method place( level:FGBLevel, destination:Bitmap, i:Int32, j:Int32 ) + local x = i * SCALED_WIDTH + local y = j * SCALED_HEIGHT + level.scaled_bitmap.blit( destination, x, y, BitmapBlitFn.ALPHA ) + + #{ + # Was used to establish standard zone size of 640x576 + method calculate_sizes( levels:FGBLevel[] ) + println "Calculating sizes" + + # Max sizes + local max_column_width = Int32[] + local max_row_height = Int32[] + forEach (level in levels) + max_column_width.expand_to_include( level.column ) + max_column_width[level.column] = max_column_width[level.column].or_larger(level.pixel_width) + + max_row_height.expand_to_include( level.row ) + max_row_height[level.row] = max_row_height[level.row].or_larger(level.pixel_height) + endForEach + + # Max sizes help determine min sizes + local min_column_width = max_column_width.cloned + local min_row_height = max_row_height.cloned + forEach (level in levels) + min_column_width[level.column] = min_column_width[level.column].or_smaller(level.pixel_width) + min_row_height[level.row] = min_row_height[level.row].or_smaller(level.pixel_height) + endForEach + + local column_width = Int32[] + local row_height = Int32[] + forEach (min_w at i in min_column_width) + column_width.add( max_column_width[i].or_smaller(min_w*2) ) + endForEach + forEach (min_h at j in min_row_height) + row_height.add( max_row_height[j].or_smaller(min_h*2) ) + endForEach + + #column_width.add( 640 ) + #row_height.add( 576 ) + + trace column_width.count + trace row_height.count + trace column_width.count * row_height.count + trace levels.count + + @trace column_width + @trace row_height + local sum_width = 0 + sum_width += (forEach in column_width) + local sum_height = 0 + sum_height += (forEach in row_height) + + local mb = (sum_width * sum_height * 4) / 1024^2 + @trace sum_width, sum_height, mb + }# + +endClass + +class FGBLevel + PROPERTIES + filename : String + level_number : Int32 + version : Int32 + classes = Int32[] + first_character_index : Int32 + first_character_id : Int32 + width : Int32 + pitch : Int32 + height : Int32 + tiles = Int32[] + bg_color : Color + bitmap : Bitmap + scaled_bitmap : Bitmap + + METHODS + method init( filename ) + level_number = filename.after_last('L').before_first('_')->Int32 + local reader = File.reader( filename ) + version = reader.read + + local class_count = reader.read + classes.add( 0 ) # index 0 is always empty space + + block + first_character_index = reader.read + first_character_id = reader.read + first_character_id = first_character_id | (reader.read :<<: 8) + endBlock + + block + loop (class_count) + local low = reader.read : Int32 + local high = reader.read : Int32 + local cls = ((high:<<:8) | low) + if (cls < first_character_id) --cls + if (cls == 1532) cls = 0 + classes.add( cls ) + endLoop + endBlock + + width = reader.read + pitch = reader.read + height = reader.read + + forEach (j in 0..= 0 and index < classes.count) + tiles.add( classes[index] ) + endForEach + endForEach + + forEach (cls at index in tiles) + which (cls) + case 2102, 2120, 2140, 2168, 2222, 2230, 2238, 2246, 2258, 2268, 2298, 2319, 2335, + 2343, 2351, 2362, 2370, 2374, 2390, 2408, 2418, 2426, 2434, 2446 + tiles[index+1] = cls+1 + tiles[index+width] = cls+2 + tiles[index+width+1] = cls+3 + endWhich + endForEach + + local color_low = reader.read : Int32 + local color_high = reader.read : Int32 + local color = (color_high :<<: 8) | color_low + bg_color = Graphics.color_16_to_32( color ) + + # Waypoint List + # TODO (investigate starting at Tools/LevelEditor/Source/Controls.cpp line 393) + + # Zones + # TODO + + # Exits + # TODO + + # Exit Links + # TODO + bitmap = _render + + local W = MapMaker.SCALED_WIDTH + local H = MapMaker.SCALED_HEIGHT + local scale = (W/Real64(bitmap.width)).or_smaller( H/Real64(bitmap.height) ) + scaled_bitmap = bitmap.resized( bitmap.size*scale ).[ reframe(W,H,Anchor.CENTER,&pad_color=bg_color) ] + + method column->Int32 + return level_number / 100 + + method get( i:Int32, j:Int32 )->Int32 + return tiles[ j*width + i ] + + method pixel_height->Real64 + return (height-2)*16 + + method pixel_width->Real64 + return (width-2)*16 + + method _render->Bitmap + local result = Bitmap( (width-2)*16, (height-2)*16, bg_color ) + forEach (j in 1.. 0) + Graphics[ this.get(i,j) ].blit( result, (i-1)*16, (j-1)*16, BitmapBlitFn.ALPHA ) + endIf + endForEach + endForEach + + if (level_number == 0014) + result = Bitmap( result, Box(result.width-320,0,320,result.height) ) + elseIf (level_number == 0115) + result = Bitmap( result, Box(0,0,544,result.height) ) + elseIf (level_number == 0215) + result = Bitmap( result, Box(0,0,320,result.height) ) + endIf + + return result + + method row->Int32 + return (level_number % 100) +endClass + +class Graphics [singleton] + PROPERTIES + tiles = Bitmap[] + facings = Bitmap[][] + first_actor : Int32 + + + METHODS + method init + tiles.add( load_with_black_as_transparent("../LevelEditor/background0001-1535.bmp").split(32,64) ) + + first_actor = tiles.count + tiles.add( load_with_black_as_transparent("../LevelEditor/objects2048-2303.bmp").split(32,32) ) + local right = Bitmap[] + local left = Bitmap[] + local up = Bitmap[] + local down = Bitmap[] + facings.add( up ).add( left ).add( down ).add( right ) + forEach (tile in tiles from first_actor) + right.add( tile ) + up.add( tile.cloned.[rotate_90(&ccw)] ) + down.add( tile.cloned.[flip(&h), rotate_90(&ccw)] ) + left.add( tile.cloned.[flip(&h)] ) + endForEach + + # Loads binary data - but tile color table is incomplete so using the pre-rendered images above instead. + #tiles.add( forEach in TileData ) + #save_tileset + + method color_16_to_32( c:Int32 )->Color + return Color( color_5_to_8(c), color_5_to_8(c:>>:5), color_5_to_8(c:>>:10) ) + + method color_5_to_8( c:Int32 )->Int32 + c &= 0x1F + return ((c / Real64(0x1F)) * 255)->Int32 + + method get( tile_type:Int32 )->Bitmap + if (tile_type < first_actor) return tiles[ tile_type ] + if (TileData.flags[tile_type] & (TileData.FG_IS_2X2|TileData.FG_NO_ROTATE)) return tiles[ tile_type ] + return facings[Random.int32(4)][ tile_type-first_actor ] + + method load_with_black_as_transparent( filename:String )->Bitmap + local bmp = Bitmap( File(filename) ) + forEach (pixel at index in bmp.pixels) + if (pixel.argb == 0xff000000) + bmp.pixels[ index ] = Color(0) + endIf + endForEach + return bmp + + method save_tileset + local w = 32 + local h = TileData.count / 32 + local bitmap = Bitmap( w*8, h*8, 0 ) + local reader = tiles.reader + forEach (j in 0..Int32 + return flags.count + + method has_another->Logical + return tile_index < flags.count + + method read->Bitmap + local bits = Int32[] + local bitmap = Bitmap( 8, 8, Color[](64) ) + local palette = palettes[ flags[tile_index] & COLOR_MASK ] + loop 8 + bits.clear + loop (8) bits.add( reader.read(1) ) + forEach (v in bits) + v = (reader.read(1):<<:1) | v + bitmap.pixels.add( palette[v] ) + endForEach + endLoop + + ++tile_index + + return bitmap + +endClass