I truly need help, I've been going over this code for a few hours now, and I still don't get what's wrong with it. Here are my source files:
ROLAT_defs.h
Code: /*
All definitions for everything needed for ROL:AT are included here,
sorted by type and meaning
*/
//-----------------------
// TECHNICAL THINGS
//-----------------------
#define string(name, value) byte name##[] = value
#define clean_exit 0
#define error_exit 1
Main.c
Code: #include "ROLAT_defs.h"
#include "battle_system.c"
int main() {
battle_main();
return clean_exit;
}
useful.c
Code: #include "keyboard_syscalls.h"
#include "keyboard.hpp"
#define LCD_WIDTH_PX 384
#define LCD_HEIGHT_PX 216
#define MASK_RED 0xf800
void CopySpriteMasked(const char*data, int x, int y, int width, int height, int maskcolor);
int PRGM_GetKey(void);
void CopySpriteMasked(const char*data, int x, int y, int width, int height, int maskcolor) {
char* VRAM = (char*)0xA8000000;
VRAM += 2*(LCD_WIDTH_PX*y + x);
for(int j=y; j<y+height; j++) {
for(int i=x; i<x+width; i++) {
if ((((((int)(*data))&0x000000FF)<<8) | ((((int)(*(data+1))))&0x000000FF)) != maskcolor) {
*(VRAM++) = *(data++);
*(VRAM++) = *(data++);
} else { VRAM += 2; data += 2; }
}
VRAM += 2*(LCD_WIDTH_PX-width);
}
}
int PRGM_GetKey(){
unsigned char buffer[12];
PRGM_GetKey_OS( buffer );
return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}
Enemies.c
Code: const char Nomekati[] = {
0xf8,0x00,0xf8 ... (you get it, though there's 3 colors: 0xf800 (RED), 0x0000 (white) and 0xFFFF (black)
//goes on and on, it's a 64x64 image (troll face)
};
battle_system.c
Code: #include "bestiary.c"
#include "display_syscalls.h"
#include "ROLAT_defs.h"
#include "useful.c"
#define endof_render_exit 2
int render_status = clean_exit;
int Current_Opponents_nums[] = {1,0,0,0,0,0};
enemy Current_Opponents[6];
int battle_main(void);
int renderloop_bs(void);
int battle_main() {
for (int i=0;i<=5;i++) {
if (Current_Opponents_nums[i] != 0) {
CreateDynamicEnemy(&(Current_Opponents[i]), Current_Opponents_nums[i]);
}
}
while (render_status == clean_exit) {
render_status == renderloop_bs();
if (PRGM_GetKey()) {
render_status = endof_render_exit;
}
}
return (render_status == endof_render_exit) ? clean_exit : error_exit;
}
int renderloop_bs() {
Bdisp_AllCr_VRAM();
CopySpriteMasked(Bestiary[1].sprite_data, 20, 20, Bestiary[1].width, Bestiary[1].height, MASK_RED);
Bdisp_PutDisp_DD();
return clean_exit;
}
bestiary.c
Code: #include "ROLAT_defs.h"
#include "stdlib.h"
#include "Enemies.c"
#include "string.h"
typedef struct {
unsigned char name[9];
const void*sprite_data;
unsigned short magic;
unsigned char intelligence, hit, move_1, move_2, move_3;
unsigned short attack, defense;
unsigned char is_boss;
unsigned char can_heal;
unsigned char type;
unsigned char orb_held;
int width, height, gp, xp, hp, max_hp;
} enemy;
int ENEMY_SIZE = sizeof(enemy);
void CreateDynamicEnemy(enemy*p, int bestiary_num);
enemy Bestiary[] = {
{"/0",(const char*)0x00000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{"Nomekati\0",Nomekati,0,0,0,200,15,5,50,50,75,25,30,0,0,0,0,64,64}
};
void CreateDynamicEnemy(enemy*p, int bestiary_num) {
memcpy(p,&(Bestiary[bestiary_num]),ENEMY_SIZE);
}
And yes, I do copy "ROLAT_defs.h" to the "include" header of the Prizm SDK, I use this Batch script I made in a few minutes to do that and more:
Code: COPY /V /Y F:\ROLAT\Code F:\PrizmSDK\
COPY /V /Y F:\ROLAT\Code\Flibs F:\PrizmSDK\
COPY /V /Y F:\ROLAT\Code\Data F:\PrizmSDK\
COPY /V /Y F:\ROLAT\Code\Headers F:\PrizmSDK\include
COPY /V /Y F:\ROLAT\Graphics\Icons F:\PrizmSDK\icons
CD "F:\PrizmSDK"
DEL ROLAT.bin
DEL Main.bin
bin\make.exe %*
@ECHO off
IF NOT EXIST F:\PrizmSDK\ROLAT.g3a GOTO END
MOVE /Y F:\PrizmSDK\ROLAT.g3a F:\ROLAT\Builds\PlaceH.placeh
CD F:\ROLAT\Builds\
ECHO PlaceHold > ROLAT.g3a
COPY /Y PlaceH.placeh ROLAT.g3a
SET FileDate=%date:/=%_%time::=%
REN ROLAT.g3a "ROLAT_%FileDate%.g3a"
ECHO Build Version ROLAT_%FileDate%
:END
PAUSE
@ECHO on
What the problem is isn't that there's a problem getting things to compile alright -- I already fixed all the files so that it compiles with no errors whatsoever. The real problem is when I run the Add-in, I get this error:
Code: System ERROR
REBOOT :[EXIT]
INITIALIZE:[EXE]
ADDRESS(W)
TARGET=55555567
PC =0810000A
So, it's more of a problem with the actual code. The code is supposed to set up 6 enemies and run a battle system renderloop, in which for now I only render the first enemy (with an enemy index pointing to the "Nomekati" enemy in the bestiary) using the varibles not in the dynamic enemy variable, but rather in the const one in the Bestiary array (since those values aren't supposed to change anyways). I'm sorry for all of the boring code posted, but I really would sincerely love help figuring out what I did wrong here. TIA.