2021-09-26 10:42:21 +00:00
|
|
|
<?php
|
|
|
|
|
2024-05-28 02:43:58 +00:00
|
|
|
namespace App\Console\Commands\BBS;
|
2021-09-26 10:42:21 +00:00
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
use App\Classes\ANSI;
|
|
|
|
|
|
|
|
class ANSIEncode extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2024-05-28 02:43:58 +00:00
|
|
|
protected $signature = 'bbs:ansi:encode'
|
2021-09-26 10:42:21 +00:00
|
|
|
.' {file : ANS file to encode}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Encode ANS file to custom binary';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
2024-05-27 05:08:39 +00:00
|
|
|
* @return int
|
2021-09-26 10:42:21 +00:00
|
|
|
*/
|
2024-05-27 05:08:39 +00:00
|
|
|
public function handle(): int
|
2021-09-26 10:42:21 +00:00
|
|
|
{
|
|
|
|
foreach (ANSI::binary($this->argument('file')) as $line) {
|
|
|
|
foreach (str_split(bin2hex($line),2) as $y)
|
|
|
|
echo hex2bin($y);
|
|
|
|
|
|
|
|
echo "\r";
|
|
|
|
}
|
2024-05-27 05:08:39 +00:00
|
|
|
|
|
|
|
return self::SUCCESS;
|
2021-09-26 10:42:21 +00:00
|
|
|
}
|
|
|
|
}
|