-
-
Notifications
You must be signed in to change notification settings - Fork 5
vc64webplayer_advanced_scripting
mithrendal edited this page Jul 26, 2021
·
9 revisions
ok now you have integrated vc64web via the webplayer on your html page ...
🤔 sometimes you want to execute something inside the emulator which is triggered from the users interaction on your page
imagine you like to click a link on your html page and want as a result something to happen inside the c64 virtual machine.
the webplayer offers the exec
method for this.
this method takes a function as an argument exec(your_function)
a hello world example
<script>
function write_hello() {
action(`'hello world'`);
}
</script>
<a href="javascript:vc64web_player.exec(write_hello);">
type hello inside the c64
</a>
lets look this more complex example
<script>
async function write_with_type_errors() {
await action(`'l'=>600ms=>'o'=>1400ms=>'a'=>800ms=>'f'`);
let orig_color = wasm_peek(0xD020);
for(let i=0;i<16;i++)
{
wasm_poke( 0xD020, i%2==1 ? orig_color:2);
await action("100ms");
}
await action(`'"'=>400ms=>'$"'=>500ms=>',8'=>800ms=>loop6{ArrowLeft=>99ms}=>'d'=>loop5{ArrowRight=>99ms}=>Enter`);
await disk_loading_finished();
await action(`3000ms=>'r'=>800ms=>'u'=>400ms=>'n'=>Enter`);
};
</script>
<a href="javascript:vc64web_player.exec(write_with_type_errors);">
type like a user with type errors
</a>
the next chapter is easy ! Like to learn more ?
- simple hashtag preconfiguration
- preconfig with JSON notation
- using direct start links for sharing on social media
- preconfig of scripts and buttons
- scripting support for simple tasks
- scripting support for complex tasks like programming a game specific AI
lightweight integration into your own webpage (with only a few lines of code)
- using the web player for embedding and controlling vc64web inside another webpage
- preloading the web player with specific system roms
- send scripts into the emulator via the webplayer
- customizing the icon bar at the bottom of the webplayer
- how to preload original system roms and autostart a .d64 title
create a standalone package which contain all files to run your C64 program