tewtal / alttp_sm_combo_randomizer

ALttP VT Randomizer and API - Super Metroid & ALTTP Combo Version (V10)
MIT License
43 stars 12 forks source link

Add Heartcolor to CLI Options #94

Open ghost opened 5 years ago

ghost commented 5 years ago

I would push a commit, but I don't have permissions. The following files needed changing

file: app/Console/Commands/Randomize.php

<?php namespace ALttP\Console\Commands;

use ALttP\Item;
use ALttP\Randomizer;
use ALttP\Rom;
use ALttP\World;
use ALttP\Support\Zspr;
use Illuminate\Console\Command;

class Randomize extends Command {
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'alttp:randomize {input_file : base rom to randomize}'
        . ' {output_directory : where to place randomized rom}'
        . ' {--unrandomized : do not apply randomization to the rom}'
        . ' {--vanilla : set game to vanilla item locations}'
        . ' {--debug : enable BAGE mode}'
        . ' {--spoiler : generate a spoiler file}'
        . ' {--difficulty=normal : set difficulty}'
        . ' {--variation=combo : set variation}'
        . ' {--logic=NoMajorGlitches : set logic}'
        . ' {--sm-logic=Casual : set SM logic}'
        . ' {--heartbeep=half : set heart beep speed}'
        . ' {--heartcolor=red : set heart color}'
        . ' {--skip-md5 : do not validate md5 of base rom}'
        . ' {--trace : enable SRAM trace}'
        . ' {--seed= : set seed number}'
        . ' {--bulk=1 : generate multiple roms}'
        . ' {--goal=ganon : set game goal}'
        . ' {--mode=open : set game mode}'
        . ' {--weapons=randomized : set weapons mode}'
        . ' {--sprite= : sprite file to change links graphics [zspr format]}'
        . ' {--no-rom : no not generate output rom}'
        . ' {--no-music : mute all music}'
        . ' {--menu-speed=normal : menu speed}'
        . ' {--morph=randomized : \'vanilla\' for vanilla Morph Ball location}';

        ...         

            $rom->setHeartColors($this->option('heartcolor'));

file: Rom.php

public function setHeartColors(string $color) : self {
        switch ($color) {
            case 'blue':
                $byte = 0x2C;
                $file_byte = 0x0D;
                break;
            case 'green':
                $byte = 0x3C;
                $file_byte = 0x19;
                break;
            case 'yellow':
                $byte = 0x28;
                $file_byte = 0x09;
                break;
            case 'red':
            default:
                $byte = 0x24;
                $file_byte = 0x05;
        }
        $this->write(0x6FA1E, pack('C*', $byte));
        $this->write(0x6FA20, pack('C*', $byte));
        $this->write(0x6FA22, pack('C*', $byte));
        $this->write(0x6FA24, pack('C*', $byte));
        $this->write(0x6FA26, pack('C*', $byte));
        $this->write(0x6FA28, pack('C*', $byte));
        $this->write(0x6FA2A, pack('C*', $byte));
        $this->write(0x6FA2C, pack('C*', $byte));
        $this->write(0x6FA2E, pack('C*', $byte));
        $this->write(0x6FA30, pack('C*', $byte));

        $this->write(0x65561, pack('C*', $file_byte));

        return $this;
    }
OneTrueFollower commented 5 years ago

Nice work. 👍