Made NpcTbl.cpp ASM-accurate
This commit is contained in:
parent
7918e6067d
commit
260d245e4c
3 changed files with 72 additions and 24 deletions
|
@ -2126,6 +2126,14 @@ addr = 0x46E9E0
|
||||||
name = "ActNpc360"
|
name = "ActNpc360"
|
||||||
addr = 0x46EA90
|
addr = 0x46EA90
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "LoadNpcTable"
|
||||||
|
addr = 0x472400
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "ReleaseNpcTable"
|
||||||
|
addr = 0x472710
|
||||||
|
|
||||||
[[func]]
|
[[func]]
|
||||||
name = "InitBossChar"
|
name = "InitBossChar"
|
||||||
addr = 0x472740
|
addr = 0x472740
|
||||||
|
|
|
@ -1,60 +1,98 @@
|
||||||
#include "NpcTbl.h"
|
#include "NpcTbl.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Generic.h"
|
#include "Generic.h"
|
||||||
#include "NpcAct.h"
|
#include "NpcAct.h"
|
||||||
|
|
||||||
NPC_TABLE *gNpcTable;
|
NPC_TABLE *gNpcTable;
|
||||||
|
|
||||||
bool LoadNpcTable(const char *path)
|
BOOL LoadNpcTable(const char *path)
|
||||||
{
|
{
|
||||||
const long size = GetFileSizeLong(path);
|
FILE *fp;
|
||||||
if (size == -1)
|
long n;
|
||||||
return false;
|
long num;
|
||||||
|
unsigned long size;
|
||||||
|
|
||||||
const long num = size / 0x18;
|
size = GetFileSizeLong(path);
|
||||||
|
if (size == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
num = size / 0x18;
|
||||||
|
|
||||||
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
|
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
|
||||||
if (gNpcTable == NULL)
|
if (gNpcTable == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
FILE *fp = fopen(path, "rb");
|
fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
{
|
||||||
|
free(gNpcTable);
|
||||||
|
gNpcTable = NULL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
for (long n = 0; n < num; n++) //bits
|
#ifdef NONPORTABLE
|
||||||
gNpcTable[n].bits = File_ReadLE16(fp);
|
for (n = 0; n < num; n++) //bits
|
||||||
for (long n = 0; n < num; n++) //life
|
fread(&gNpcTable[n].bits, 2, 1, fp);
|
||||||
gNpcTable[n].life = File_ReadLE16(fp);
|
for (n = 0; n < num; n++) //life
|
||||||
for (long n = 0; n < num; n++) //surf
|
fread(&gNpcTable[n].life, 2, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //surf
|
||||||
fread(&gNpcTable[n].surf, 1, 1, fp);
|
fread(&gNpcTable[n].surf, 1, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //destroy_voice
|
for (n = 0; n < num; n++) //destroy_voice
|
||||||
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //hit_voice
|
for (n = 0; n < num; n++) //hit_voice
|
||||||
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //size
|
for (n = 0; n < num; n++) //size
|
||||||
fread(&gNpcTable[n].size, 1, 1, fp);
|
fread(&gNpcTable[n].size, 1, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //exp
|
for (n = 0; n < num; n++) //exp
|
||||||
gNpcTable[n].exp = File_ReadLE32(fp);
|
fread(&gNpcTable[n].exp, 4, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //damage
|
for (n = 0; n < num; n++) //damage
|
||||||
gNpcTable[n].damage = File_ReadLE32(fp);
|
fread(&gNpcTable[n].damage, 4, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //hit
|
for (n = 0; n < num; n++) //hit
|
||||||
fread(&gNpcTable[n].hit, 4, 1, fp);
|
fread(&gNpcTable[n].hit, 4, 1, fp);
|
||||||
for (long n = 0; n < num; n++) //view
|
for (n = 0; n < num; n++) //view
|
||||||
fread(&gNpcTable[n].view, 4, 1, fp);
|
fread(&gNpcTable[n].view, 4, 1, fp);
|
||||||
|
#else
|
||||||
|
for (n = 0; n < num; n++) //bits
|
||||||
|
gNpcTable[n].bits = File_ReadLE16(fp);
|
||||||
|
for (n = 0; n < num; n++) //life
|
||||||
|
gNpcTable[n].life = File_ReadLE16(fp);
|
||||||
|
for (n = 0; n < num; n++) //surf
|
||||||
|
fread(&gNpcTable[n].surf, 1, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //destroy_voice
|
||||||
|
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //hit_voice
|
||||||
|
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //size
|
||||||
|
fread(&gNpcTable[n].size, 1, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //exp
|
||||||
|
gNpcTable[n].exp = File_ReadLE32(fp);
|
||||||
|
for (n = 0; n < num; n++) //damage
|
||||||
|
gNpcTable[n].damage = File_ReadLE32(fp);
|
||||||
|
for (n = 0; n < num; n++) //hit
|
||||||
|
fread(&gNpcTable[n].hit, 4, 1, fp);
|
||||||
|
for (n = 0; n < num; n++) //view
|
||||||
|
fread(&gNpcTable[n].view, 4, 1, fp);
|
||||||
|
#endif
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseNpcTable()
|
void ReleaseNpcTable()
|
||||||
{
|
{
|
||||||
if (gNpcTable)
|
if (gNpcTable)
|
||||||
|
{
|
||||||
free(gNpcTable);
|
free(gNpcTable);
|
||||||
|
gNpcTable = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Npc function table
|
//Npc function table
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Draw.h"
|
#include "Draw.h"
|
||||||
#include "NpChar.h"
|
#include "NpChar.h"
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ struct NPC_TABLE
|
||||||
|
|
||||||
extern NPC_TABLE *gNpcTable;
|
extern NPC_TABLE *gNpcTable;
|
||||||
|
|
||||||
bool LoadNpcTable(const char *path);
|
BOOL LoadNpcTable(const char *path);
|
||||||
void ReleaseNpcTable();
|
void ReleaseNpcTable();
|
||||||
|
|
||||||
//NPC Function table
|
//NPC Function table
|
||||||
|
|
Loading…
Add table
Reference in a new issue