Kubes
Kubes
- 6
- Posts
- 7
- Years
- Connecticut, USA
- Seen Jun 23, 2023
If anyone knows any good references for working with disassembled ROMs in C, it would be greatly appreciated!
I wanted to initially only use PoryScript, but I've found myself tempted with C, but am not finding many resources.
Right now, I am trying to get a custom special function that takes a byte as a parameter working. So far I have it compiling (when not referenced in a script)... now onto the working part :P
Edit1: One thing...
I hadn't added my script to ".rodata:" in "ld_script.txt"
-fixed- But, now my string comes out as gibberish :/
Edit2:
Changed script to:
Fixed gibberish.
Edit 3:
And today, success!
kubes_notspecial_test(x) will set string buffer x to a specific value! My main issue was that I was trying to make it a special function.
I wanted to initially only use PoryScript, but I've found myself tempted with C, but am not finding many resources.
Right now, I am trying to get a custom special function that takes a byte as a parameter working. So far I have it compiling (when not referenced in a script)... now onto the working part :P
Spoiler:
Code:
#include "aaa_kubes_test.h"
#include "string_util.h"
#include "script.h"
static u8 *const sScriptStringVars[] =
{
gStringVar1,
gStringVar2,
gStringVar3,
};
void kubes_test(void) {
u8 *dest = sScriptStringVars[0];
StringCopy(dest, _("Kubes string from C!"));
}
Edit1: One thing...
I hadn't added my script to ".rodata:" in "ld_script.txt"
-fixed- But, now my string comes out as gibberish :/
Edit2:
Changed script to:
Spoiler:
Code:
void kubes_test(void){
u8 *dest;
u8 str[8] = _("String!");
dest = sScriptStringVars[0];
StringCopy(dest, str);
}
Fixed gibberish.
Edit 3:
And today, success!
kubes_notspecial_test(x) will set string buffer x to a specific value! My main issue was that I was trying to make it a special function.
Spoiler:
Code:
// Added function name to data/script_cmd_table.inc
// Included macro in asm/macros.inc
// Script Command
// src/kubes.c
#include "kubes.h"
#include "string_util.h"
#include "script.h"
static u8 *const sScriptStringVars[] =
{
gStringVar1,
gStringVar2,
gStringVar3,
};
void ScrCmd_kubes_notspecial_test(struct ScriptContext *ctx)
{
u8 *dest;
u8 str[18] = _("NotspecialString!");
u8 stringVarIndex = ScriptReadByte(ctx);
if (stringVarIndex > 2) { // Index out of range
return;
}
dest = sScriptStringVars[stringVarIndex];
StringCopy(dest, str);
}
// Macro
// asm/macros/kubes.inc
.macro kubes_notspecial_test str_buf_index
.byte 0xe3 @ assuming this is the index in gScriptCmdTable
.byte \str_buf_index @ my parameter :D
.endm
Last edited: