• Welcome to Final Fantasy Hacktics. Please login or sign up.
October 25, 2020, 03:35:09 am


Please use .png instead of .bmp when uploading unfinished sprites to the forum!

Javascript prototype for asm tooltips on the wiki

Started by Raijinili, June 18, 2014, 04:53:11 am


June 18, 2014, 04:53:11 am Last Edit: July 27, 2014, 03:19:46 am by Raijinili
Put into Greasemonkey.

// ==UserScript==
// @name        FFHwiki ASM helper
// @namespace   Raijinili
// @description FFH wiki ASM helper
// @include     http://ffhacktics.com/wiki/*
// @version     1.1
// @grant       none
// ==/UserScript==

var desc = {
'add': "Add add $d,$s,$t",
'addu': "Add unsigned addu $d,$s,$t",
'sub': "Subtract sub $d,$s,$t",
'subu': "Subtract unsigned subu $d,$s,$t",
'addi': "Add immediate addi $t,$s,C",
'addiu': "Add immediate unsigned addiu $t,$s,C",
'mult': "Multiply mult $s,$t",
'multu': "Multiply unsigned multu $s,$t",
'div': "Divide div $s, $t",
'divu': "Divide unsigned divu $s, $t",
'lw': "Load word lw $t,C($s)",
'lh': "Load halfword lh $t,C($s)",
'lhu': "Load halfword unsigned lhu $t,C($s)",
'lb': "Load byte lb $t,C($s)",
'lbu': "Load byte unsigned lbu $t,C($s)",
'sw': "Store word sw $t,C($s)",
'sh': "Store half sh $t,C($s)",
'sb': "Store byte sb $t,C($s)",
'lui': "Load upper immediate lui $t,C",
'mfhi': "Move from high mfhi $d",
'mflo': "Move from low mflo $d",
'mfcZ': "Move from Control Register mfcZ $t, $d",
'mtcZ': "Move to Control Register mtcZ $t, $d",
'and': "And and $d,$s,$t",
'andi': "And immediate andi $t,$s,C",
'or': "Or or $d,$s,$t",
'ori': "Or immediate ori $t,$s,C",
'xor': "Exclusive or xor $d,$s,$t",
'nor': "Nor nor $d,$s,$t",
'slt': "Set on less than slt $d,$s,$t",
'slti': "Set on less than immediate slti $t,$s,C",
'sll': "Shift left logical immediate sll $d,$t,shamt",
'srl': "Shift right logical immediate srl $d,$t,shamt",
'sra': "Shift right arithmetic immediate sra $d,$t,shamt",
'sllv': "Shift left logical sllv $d,$t,$s",
'srlv': "Shift right logical srlv $d,$t,$s",
'srav': "Shift right arithmetic srav $d,$t,$s",
'beq': "Branch on equal beq $s,$t,C",
'bne': "Branch on not equal bne $s,$t,C",
'j': "Jump j C",
'jr': "Jump register jr $s",
'jal': "Jump and link jal C",
'nop': "No operation (do nothing)",

var re = /^([0-9a-f]{8}: [0-9a-f]{8} )(\w+)(\s.*)?$/i;

function tooltipize(i, node){
var txt = node.textContent;
node.textContent = ''; //remove

//make new nodes and add them
.forEach(function parse(s){
var match = re.exec(s);
if(match == null){ //no asm detected

var prefix = document.createTextNode(match[1]);
var instr = match[2];
var suffix = document.createTextNode(match[3]+'\n');
var link = $("<a></a>", {
href: "./R3000_instruction set#"+instr,
title: desc[instr],
console.log(prefix, instr, suffix, link);
$(node).append(prefix, link, suffix);
$('div#mw-content-text pre').map(tooltipize);

It's a mockup of what can be done: tooltips and links for ASM instructions. Ideally, this would be done through wiki markup instead of Javascript, but this is fine until people figure out what they'd like out of it.
  • Modding version: Other/Unknown


  • Modding version: Other/Unknown


I am editing Monobook.js to add in Javascript that would help people read ASM.

To use this, log into your account, and go to "preferences" > "Appearance" > "Skin" = "Monobook", Monobook.css turns all the colors slightly red to make it clear what skin you're on.
  • Modding version: Other/Unknown