nbarkhina / DosWasmX

Build your own DOS/Windows machine in the browser
https://www.neilb.net/doswasmx/
MIT License
45 stars 6 forks source link

how to autorun iso/hdd ? #11

Closed AlinGheaja closed 1 month ago

AlinGheaja commented 1 month ago

hello i know you can create a Startup Script on the hdd and then save hdd.img once i upload hdd.img to my website and edit settings.js i still need to hit start computer. is there a way to autorun a hdd.img if someone opens the link or index.html file ? thank you

nbarkhina commented 1 month ago

Yes in the finishInitialization() function of script.js you can add a call to myApp.loadRom(true) under the line this.loading = false;

the only issue is that on some devices you won't have any audio. That is because most browsers require you to interact with the page before allowing audio to play, that is the main reason for the Start Computer button.

AlinGheaja commented 1 month ago

thank you. how can i have smaller hdd images or is there any other formats that i can use ? the minimum is 256 mb but some dos games have like 200 kb.

nbarkhina commented 1 month ago

If you click on settings at the start page you can set the initial hard drive size to as low as 25mb. However you need press the clear button that will delete your current hard drive first. Make sure you take a backup before clearing if you want to save that old drive.

image

AlinGheaja commented 1 month ago

thank you so much is it possible istead of a hdd.img to use something else ? and not worry about ocupying to much ! 25 mb for a 200 kb game is a little to much. i love this project and i want to use it on my website. for now id like to start with 4 games unde 1 mb. i just want the user to just press "start computer"(rest of options like drag and drop removed) and the game sould start like "dave 2 haunted mansion"

nbarkhina commented 1 month ago

If you edit index.html you can add your own hard drive sizes like this:

<select class="form-control" rv-value="data.initialHardDriveTemp" id="ddlInitialHD">
   <option value="hd -size 1">1 MB</option>
   <option value="hd -size 25">25 MB</option>
   <option value="hd -size 50">50 MB</option>
AlinGheaja commented 1 month ago

i added the values but the minimum hdd size is 5mb. if i go lower then it shows an error. so far so good. thank you for your reply is there other way of "preloading" zip/iso so that "Start computer" works without hdd.img ? thank you again <3

nbarkhina commented 1 month ago

I haven't added the ability to have a game list yet out of the box but you can do it with a little customization. Go to romlist.js and your list of games there which are on your server:

var ROMLIST = [
    {url:"game1.zip",title:"Game1",skipiso:"true",ram:"128"},
    {url:"game2.zip",title:"Game2",skipiso:"true",ram:"128"},
    {url:"game3.zip",title:"Game3",skipiso:"true",ram:"128"},
];

then in Index.html delete the rv-if statement from ROM LIST

                <div class="form-group mt-2 mb-4"
                    style="width: 300px;margin-left: auto; margin-right:auto;">
                    <select class="form-control" id="romselect">
                        <option rv-each-rom="data.romList" rv-skipiso="rom.skipiso" 
                            rv-ram="rom.ram" rv-value="rom.url">{rom.title}</option>
                    </select>
                </div>

that will get the dropdown to show up. finally look for any calls to "myApp.loadRom(true)" in index.html and change them to "myApp.loadRom()". if you follow through the code you can see what this is doing, basically you're telling it to always load with a file. then based on which game they select it will download that zip and load it in before starting.

AlinGheaja commented 1 month ago

i edited the files exactly and .. it doesnt work or maybe i did something wrong here is a link for a test with the files i edited https://retrotech.ro/toons/ inside the folder there is a game DAVE2.zip

romlist has this var ROMLIST = [ /* {url:"DAVE2.zip",title:"Dave2",skipiso:"true",ram:"128"}, {url:"game2.iso",title:"Game2",skipiso:"true",ram:"128"}, {url:"game3.iso",title:"Game3",skipiso:"true",ram:"128"}, */ ];

nbarkhina commented 1 month ago

you need to remove the / and / in romlist.js - that comments out everything inside

AlinGheaja commented 1 month ago

did that just now but nothing happens

var ROMLIST = [

{url:"DAVE2.zip",title:"Dave2",skipiso:"true",ram:"128"},
{url:"game2.iso",title:"Game2",skipiso:"true",ram:"128"},
{url:"game3.iso",title:"Game3",skipiso:"true",ram:"128"},

];

nbarkhina commented 1 month ago

on the website you linked I still see comments around romlist

AlinGheaja commented 1 month ago

thats impossible !!! clear cookies ? here is a screenshot of the file live on the server image

nbarkhina commented 1 month ago

You removed the entire div -

            <!-- ROM LIST -->
            <div class="form-group mt-2 mb-4"  DELETE THIS -> rv-if="data.loggedIn | ev '==true'"
                style="width: 300px;margin-left: auto; margin-right:auto;">
                <select class="form-control" id="romselect">
                    <option rv-each-rom="data.romList" rv-skipiso="rom.skipiso" 
                        rv-ram="rom.ram" rv-value="rom.url">{rom.title}</option>
                </select>
            </div>

You need to put the div back and only remove the rv-if statement

AlinGheaja commented 1 month ago

damn :D my bad... i got it here image but thats it

AlinGheaja commented 1 month ago

sir can you please tell me what to do next or why does it not go anywere from this ?

nbarkhina commented 1 month ago

take a look at this commit - I did a proof of concept with all the modifications you need to make. in romlist.js add a property called "autostart" with the commands you want it to run after unzipping the game. you would use this instead of the startup script.

https://github.com/nbarkhina/DosWasmX/commit/1a3c8ef7f28e850b1f60b96774a5dce1c3196966

AlinGheaja commented 1 month ago

great !!! it works great ! inside your code is there an easy way to disable drag and drop/browse/settings without removing code from index.html ? thank you for your work <3

nbarkhina commented 1 month ago

no - you would need to just remove it from the index.html

AlinGheaja commented 1 month ago

all good and working great! after saving a hdd and then launching it again, when it extracts from the zip it asks to overwrite files but does nothing without confirmation. what file to edit and where so it overwrites/skip without confirmation. thank you

image
AlinGheaja commented 1 month ago

one last question and i hope you can help me. is there a setting for autofit game screen inside index.html

nbarkhina commented 1 month ago

take a look at this commit:

https://github.com/nbarkhina/DosWasmX/commit/5aace0ce22518c6e2d87f00404b01db3c218feb4

this should fix the issue where it keeps extracting the files for Overwrite after you saved the drive. now it will save each hard drive separately in the browser. for autofit you would need to play around with the width of the canvas, or set it to full screen.

AlinGheaja commented 1 month ago

thank you sir <3