What's new

vholfx

Student
Joined
Sep 12, 2019
Messages
70
Reaction score
52
Location
USA
I recently got a Naomi 2 and since I didn't have a Raspberry Pi at hand, I was using triforcetools to transfer my games to the Naomi. Triforcetools worked great without a zero-key PIC because it has a loop where it keeps updating the timeout for the key check.

Today I got a PI setup with Piforce-Web and I was getting a Gateway error after loading the game, because unlike the standalone triforcetools, it was not creating the loop, so it requires a zero-key PIC installed

So, I connected to the PI using ssh and updated a couple of files and the result is that this mod on the Piforce-Web loader doesn't need the zero-key. It keeps the script running in a separate process. I'll post the updated scripts here and if there is any interest I'll work a bit more on it and perhaps create a new PI image.

The files updated are:
/sbin/piforce/webforce.py
/var/www/html/load.php

Code:
import os
import collections
import signal
import sys
import subprocess
import socket
import triforcetools
#from systemd import daemon
from time import sleep

logfile = open('/var/www/logs/webforce.log.txt', 'w+')
rom_dir = '/boot/roms/'

while True:
    try:
        triforcetools.disconnect()
    except:
        continue
    try:
        logfile.write("\nConnecting")
        triforcetools.connect('192.168.1.2', 10703)
    except:
        logfile.write("Error:\nConnect Failed")
        sys.exit()

    logfile.write("Uploading: " + sys.argv[1])
    triforcetools.HOST_SetMode(0, 1)
    triforcetools.SECURITY_SetKeycode("\x00" * 8)
    triforcetools.DIMM_UploadFile(rom_dir+sys.argv[1])
    logfile.write("\nDIMM_UploadFile Complete")

    logfile.write("\nRestarting Host")
    triforcetools.HOST_Restart()

    logfile.write("\nTime limit hack looping...")
    while 1:
        triforcetools.TIME_SetLimit(10*60*1000)
        sleep(5)

Code:
<?php

include 'header.php';
echo '<section><center><p>';

echo 'Loading ' . htmlspecialchars($_GET["rom"]) . ' ...';

// Kill any previous running script
exec('sudo pkill python');

// Execute command in a separate process
$command = escapeshellcmd('sudo python /sbin/piforce/webforce.py '.$_GET["rom"]);
exec('bash -c "exec nohup setsid ' . $command . ' > /dev/null 2>&1 &"');

echo '</p><center></body></html>';

?>
 
Back
Top