Development thread for Bisquixe (asking for js/jquery code review)

GlkOte sets the individual top, right, bottom, and left properties, and then the browser converts that into an inset property.

2 Likes

I got images to work using just inform code alone (no html editing) but Zarf’s really not going to like the way I did it…

Edit: Basically, people are supposed to edit a form in play.html. When play begins, a function called blorb_init is called to check that form.

What I do instead is use Inform to fill out that form. Except…by then the blorb has already been initiated!

And you can’t initiate twice, because the game throws an error…

And I don’t know how to upload an array so I have to add one of these at a time…

so I removed the code that doesn’t let you blorb_init more than once…

and I re-initialize it (at the beginning of the game) every time a new image is added.

Basically, this is like running a movie projector by pulling the reel and running away instead of getting the machine to do it for you. It’s very inefficient and sloppy, but it works, and that’s the spirit of Bisquixe!

EditEdit: I haven’t uploaded this yet, but I likely will later.

The code in question:

Summary
/*bisquixe start*/var image_keys={};/*bisquixe end*/
function glk_add_image(num_key,val_url,val_alt,num_width,num_height){
	var tempkey = {
	'image': num_key,
	'url': 'Figures/'+val_url,
	'alttext': val_alt,
	'width': num_width,
	'height': num_height
	}
	image_keys[num_key]=tempkey;
	console.log(image_keys);
	console.log(game_options);
	game_options['image_info_map'] = image_keys;
	console.log(game_options);
	Blorb.init(game_options.image_info_map,{format:'infomap'});
}
5 Likes

I’m attempting to get as many sound features as possible working on Bisquixe, using @Angstsmurf’s Soundtest file.

I’ve uploaded a demo of what I have so far here:

I’d be interested in seeing people test this out on their own devices to see what works and what doesn’t.

Just type ‘autotest’ at the beginning. The game uses some weird command editing stuff that’s not really working (probably since it conflicts with my echo input code in my extension so I deleted some I6 inclusions in this file), so if you try playing around too much it’ll mess up your actions. Just typing AUTOTEST should work.

Known bugs:
-Mobile safari does not allow changing volume of audio elements, so none of the volume tests will work.
-Notifications are not working. I’ve managed to create the correct javascript objects, but they kept getting sent several milliseconds before code listed before them fired, so there was some multithreading issue, and I’m pretty sure I have to hard code something elsewhere in Quixe to get them recognized. So this is a major pain and I cut all of that out.
-The same sound cannot be played on multiple channels. Any test involving the same sound on multiple channels won’t work. I don’t plan on fixing this, as there are easy workarounds (like making multiple audio elements with the same src).

Most other things should be working! Let me know what it sounds like on your end (and which device and browser you use).

2 Likes

I don’t think the original code does any command editing or anything else hacky or out of the ordinary. It would be interesting to investigate what goes wrong.

Otherwise the tests work apart from the things you mentioned. The main problem is seamless looping. On Safari 17.2, there is a long pause after each loop. On Brave 1.61.104 and Firefox 120.0.1 the pause is shorter, but still audible. MacOS Sonoma, MacBook M1.

2 Likes

If that’s the case, I’m sure it’s because the game and my extension both replace keyboard.i6t, and I removed the game’s replacement. It must have been different than the replacement in my extension (which I think was also originally authored by you).

I’ll see if I can do anything about the looping; thanks!

1 Like

Right, Soundtest turns off command echo to avoid extra line breaks when the notification messages are printed. It should be functionally the same as the code in the echo replacement extension.

2 Likes

Okay, I’ve completed the last of my targeted implementation tasks (implementing all glk sound functions).

I could use a code review. Basically, these functions were all blank or threw exceptions before in Quixe. The specifications of what they’re supposed to accomplish are given here:
https://www.eblong.com/zarf/glk/Glk-Spec-075.html#sound

A ‘rock’ is just a number that gets associated to something. An schan is just a blank pair of braces {} that gets attributes assigned to it. Things like GiDispa are just copied from other code.

I was working with minimized code, so chunks that are all on one line are just copied over from the minimized code, and slightly changed.

function glk_schannel_get_rock(schan){if(!schan)
throw('glk_schannel_get_rock: invalid schannel');return schan.rock;}
function glk_schannel_create(rock){
	var schan={};schan.rock=rock;schan.volume=65535;schan.disprock=undefined;schan.current_sndid=null;schan.paused=false;schan.win=null;schan.prev=null;schan.next=gli_schannellist;gli_schannellist=schan;if(schan.next)
schan.next.prev=schan;if(GiDispa)
GiDispa.class_register('schannel',schan);
return schan;
}

function glk_schannel_destroy(schan){var Dialog=GlkOte.getlibrary('Dialog');if(!schan)
throw('glk_schaneam_close: invalid schaneam')
var prev,next;
if(GiDispa)GiDispa.class_unregister('schannel',schan);prev=schan.prev;schan.volume=null;next=schan.next;schan.prev=null;schan.next=null;if(prev)
prev.next=next;else
gli_schannellist=next;if(next)
next.prev=prev;schan.rock=null;schan.disprock=null;
	return schan;
}

function glk_schannel_play(schan,sndid){
	glk_schannel_play_ext(schan,sndid,1,0);
	return 1;
}
function glk_schannel_play_ext(schan,sndid,repeats,notify){
	glk_schannel_stop(schan);
	var tempid = 'Snd'+sndid;
	console.log('Playing '+tempid);
	schan.current_sndid = tempid;
	var el=document.getElementById(tempid);
	if(notify!=0){
		el.notify=notify;
	}
	el.repeats=repeats;
//	console.log(el);
//	console.log(el.repeats);
	if(el.repeats != 0){
		el.load();
		if (schan.volume)
			el.volume=Math.min(1,schan.volume/65536);
		else
			el.volume=0;
//		console.log('el.volume is '+el.volume);
//		console.log('Intended volume is '+schan.volume);
		el.play();
	}
	if (schan.paused==true){
		el.pause();
	}
	return 1;
}
function glk_schannel_stop(schan){
	if(schan.current_sndid){
		var tempid = schan.current_sndid;
//		console.log(tempid);
		if(document.getElementById(tempid)){
			document.getElementById(tempid).pause();
			document.getElementById(tempid).currentTime = 0;
		}
	}	
}
function glk_schannel_set_volume(schan,vol){if(!schan){throw('glk_schannel_set_volume: invalid schannel');}
	glk_schannel_set_volume_ext(schan,vol,0,0);
}
function glk_sound_load_hint(sndid,flag){}

function glk_schannel_create_ext(rock,vol){
	var schan={};schan.rock=rock;schan.volume=vol;schan.disprock=undefined;schan.current_sndid=null;schan.win=null;schan.prev=null;schan.next=gli_schannellist;gli_schannellist=schan;if(schan.next)
schan.next.prev=schan;if(GiDispa)
GiDispa.class_register('schannel',schan);
return schan;}

function glk_schannel_play_multi(schans,sndids,notify){
	var ix;
	var arrlength=schans.length;
	for(ix=0;ix<arrlength;ix++){
		glk_schannel_play_ext(schans[ix],sndids[ix],1,notify);
	}
}
	
function glk_schannel_pause(schan){if(!schan){throw('glk_schannel_pause: invalid schannel');}
	schan.paused=true;
	if(schan.current_sndid){
		var tempid = schan.current_sndid;
//		console.log(tempid);
		if(document.getElementById(tempid)){
			document.getElementById(tempid).pause();
		}
	}	
}
function glk_schannel_unpause(schan){if(!schan){throw('glk_schannel_pause: invalid schannel');}
	schan.paused=false;
	if(schan.current_sndid){
//		var tempid = schan.current_sndid;
		console.log(tempid);
		if(document.getElementById(tempid)){
			document.getElementById(tempid).play();
		}
	}	
}
function glk_schannel_set_volume_ext(schan,vol,duration,notify){if(!schan){throw('glk_schannel_set_volume: invalid schannel');}
//	console.log ('Trying fade');
	schan.volume=vol;
//	console.log('I really set the volume to '+schan.volume);
	if(schan.current_sndid){
		var tempid = schan.current_sndid;
		if(document.getElementById(tempid)){
//			console.log('We found it! Volume is '+vol);
			var newVolume=Math.min(1,vol/65536);
//			console.log('duration is '+duration);
			$("#" + tempid).animate({volume: newVolume}, duration, function() {
				if(!gli_selectref)
				return;gli_selectref.set_field(0,Const.evtype_VolumeNotify);gli_selectref.set_field(1,null);gli_selectref.set_field(2,0);gli_selectref.set_field(3,notify);if(GiDispa)
				GiDispa.prepare_resume(gli_selectref);gli_selectref=null;VM.resume();
			});
		}
	}	
}

With author’s permission, I’ve gotten the sound-heavy games Six and Transparent working just fine with this method. The only troublesome thing is that you can’t autoplay right when a game starts unless you clicked first (like on itch).

3 Likes

I’ve made this change in Parchment. It will only make a difference for people adding their own styles by manually editing the .css, not to anyone using stylehints.

1 Like