The original version used in the initial release relied heavily on ds_list structuring for holding variable data. While this made it easier to pass variables between scripts and across objects (if ever that should be desired), it was a huge waste of resources (if you think about how many bytes one list index takes up, then multiply that by 30... Yeah, not very efficient).
So I rewrote the script to use variables. Since most of the variables are object-local, care needs to be taken to make it difficult for people to hack the script if its used in a fan game. A few variables have been edited to be script-local to make it a tad harder to hack, but it's still a lot easier to hack than before, especially since all the variables will be located in the RAM pretty close to each other rather than spread out as they were with the ds_list method.
The various subscripts have been minimalized as well. This was another crack-stopper method I was considering -- jump between so many subscripts that any possible rookie hackers would become befuddled from the chaos. The latest version only retains those functions which alter or read the Status Byte's carry bit, effectively reducing the script count by half.
So if I am so worried about people cracking the script, why release it? Because my concern isn't people cracking the original script, it's people cracking your variations on the script. And since the base code is now out, it's up to anyone who wants to use it for their fan game to take great pains in modifying it to be crack-resistant. Sorry, that's just how it is.
I'll release the Password Decryptor whenever I get around to actually working on it. It's three times as long.
////VARIABLES TO BE SET IN THE CREATE EVENT////
cbit=0;
byte_a=0;
byte_y=0;
byte_0=0;
byte_1=0;
byte_3=0;
byte_4=0;
for (byte_x=5;byte_x<14;byte_x+=1)
{
execute_string("byte_"+string(byte_x)+"=0;");
}
////NAME SET SCRIPT////
/*
Modifies the values saved in the name[v] array. Initially the values are
set to the corresponding image_index in the sprite cv_font; to work with
the password generator, the values need to match the original in CV3.
*/
//Set values to be encrypted
if argument0
{
for (name_slot=0;name_slot<8;name_slot+=1)
if name[name_slot]>0
name[name_slot]+=$2F;
}
//Set values to be drawn
else
for (name_slot=0;name_slot<8;name_slot+=1)
if name[name_slot]>0
name[name_slot]-=$2F;
////THE HEXED SCRIPT////
switch argument1
{
case 0:
var dec,hex,h,byte,hi,lo;
dec = argument0;
if (dec) hex = ""; else hex="00";
h = "0123456789ABCDEF";
while (dec) {
byte = dec & 255;
hi = string_char_at(h,byte div 16 + 1);
lo = string_char_at(h,byte mod 16 + 1);
hex = hi + lo + hex;
dec = dec >> 8;
}
return hex;
break;
case 1:
var hex,dec,h,p;
hex = string_upper(argument0);
dec = 0;
h = "0123456789ABCDEF";
for (p=1;p<=string_length(hex);p+=1) {
dec = dec << 4 | (string_pos(string_char_at(hex,p),h)-1);
}
return dec;
break;
}
////ADC SCRIPT////
variable_local_set(argument0,variable_local_get(argument0)+argument1+cbit);
//Since 6502 processed single bytes, only the lowest byte is saved
if variable_local_get(argument0)>$FF
cbit=1;
variable_local_set(argument0,variable_local_get(argument0)&$FF);
return variable_local_get(argument0);
////CMP SCRIPT////
if !argument2
{
if argument0 >= argument1
cbit=1;
else cbit=0;
}
if argument0 > argument1
return 1;
else
if argument0 < argument1
return -1;
else
return 0;
////ROL SCRIPT////
var C;
C = cbit;
cbit=variable_local_get(argument0)>>7;
variable_local_set(argument0,((variable_local_get(argument0) << 1) & (1 << 8)-1) | C);
////ASL SCRIPT////
cbit=variable_local_get(argument0) >> 7;
variable_local_set(argument0,(variable_local_get(argument0) << 1) & $FF);
return variable_local_get(argument0);
////LSR SCRIPT////
cbit=variable_local_get(argument0) & 1;
variable_local_set(argument0,(variable_local_get(argument0) >> 1) & $FF);
return variable_local_get(argument0);
////THE CODE ITSELF////
var byte_r, byte_2, pw3, pwt;
//This counted steps in the game; it's just a random value here.
byte_r=irandom($FF);
//This is actually performed later in the script, but was moved up here.
if ally&$FF=$FF ally=0
//Clear the carry bit
cbit=0;
name_set(1);
//This subscript encrypts the player name and sums up the letters.
//Yes, it takes this many steps to sum 3 variables.
for (byte_x=0;byte_x<$8;byte_x+=1)
{
byte_a=name[byte_x];
adc("byte_a",cryptos(0,byte_x));
cbit=0;
adc("byte_a",byte_0);
cbit=0;
byte_0=byte_a;
}
byte_0&=$7;
byte_a=stage;
//Change $11 to the highest resumable stage value
cmp(byte_a,$11);
if cbit stage=$11;
lsr("byte_a");
rol("byte_0");
byte_a=byte_r;
lsr("byte_a");
repeat(3) rol("byte_0");
byte_a=ally|byte_0;
asl("byte_a");
byte_13=byte_a|quest;
byte_a=byte_r;
lsr("byte_a");
byte_4=$50+($50*cbit);
byte_a=byte_13;
repeat(4) asl("byte_a");
byte_3=byte_a;
cbit=0;
byte_1=adc("byte_a",byte_13&$F0);
byte_0=byte_4^(byte_13&$F0);
byte_a=byte_4^byte_3;
cbit=0;
adc("byte_a",byte_0);
repeat(4) lsr("byte_a");
byte_a|=byte_1;
cbit=0;
byte_1=adc("byte_a",stage);
byte_0=byte_13;
byte_13=$0;
for(byte_x=$0;byte_x<$8;byte_x+=1)
{
temp=string(5+byte_x);
lsr("byte_0");
rol("byte_"+temp);
lsr("byte_1");
rol("byte_"+temp);
}
byte_a=stage;
byte_y=lsr("byte_a");
for(byte_x=$2;byte_x>=$0;byte_x-=1)
{
byte_0=cryptos(1,byte_y)&$C;
repeat(2) lsr("byte_0");
byte_a=(cryptos(1,byte_y)&$30)|byte_0;
if cmp(byte_a,cryptos(2,byte_x))==0 break;
}
byte_y=byte_x;
repeat(3) asl("byte_y");
adc("byte_y",byte_x);
for(byte_x=$0;byte_x<$9;byte_x+=1)
{
temp=string(5+byte_x);
byte_1=cryptos(3,byte_y+1)&$30;
byte_a=cryptos(3,byte_y+1)&$3;
repeat(2) asl("byte_a");
byte_a|=byte_1|variable_local_get("byte_"+temp);
pw3+=hexed(byte_a);
byte_y+=1;
}
cbit=1;
byte_y=stage;
lsr("byte_y");
pw3+=hexed(cryptos(1,byte_y));
name_set(0);
//Create the password as read by pw_draw()
var L,K;
pw = 0;
for (L=$1;L<$14;L+=$2)
{
pwt=hexed(string_copy(pw3,L,2),1)
for (K=$0;K<$10;K+=$1)
{
if pwt<=K*$4+$3 && pwt>=K*$4
{
pwt&=$3;
pw += pwt<<(K*$2);
}
}
}