Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
stylua --glob '**/*.lua' -- .

git update-index --again
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"useTabs": false,
"tabWidth": 2,
"endOfLine": "lf",
"printWidth": 80,
"singleQuote": true,
"trailingComma": "es5"
}
10 changes: 10 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
column_width = 80
line_endings = "Unix"
indent_type = "Tabs"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "Never"

[sort_requires]
enabled = false
26 changes: 13 additions & 13 deletions cv64/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Castlevania 64 (USA v1.0)
* `cv64_figures_display.js`: Displays the more relevant variables from each entry of the `figures_array` list, which stores instances of models, cameras and lights.
* `cv64_heap_display.js`: Shows the state of all heaps, and each of the blocks allocated within each heap.</br></br>
Note that when allocating new blocks, the game doesn't clean the block header, so sometimes there may be leftover data from previous allocations, showing unusual data, such as wrong pointers.
* `cv64_map_piece_info.js`: Displays information on the currently loaded map pieces, which are subdivisions of the current map loaded into a grid that are used to display large maps without increasing performance.</br></br>
The information shown includes the state of the loaded map piece (active or inactive), as well as its location within the imaginary grid (this grid "moves" while the player is moving through the different map pieces).
* `cv64_object_ID_display.js`: Shows each non-emptyslot from the `Objects_array`, alongside its address and ID number.
* `cv64_misc_info_display.lua`: Displays miscellaneous information regarding the current state of gameplay, such as different player-related variables.
# Castlevania 64 (USA v1.0)

- `cv64_figures_display.js`: Displays the more relevant variables from each entry of the `figures_array` list, which stores instances of models, cameras and lights.

- `cv64_heap_display.js`: Shows the state of all heaps, and each of the blocks allocated within each heap.</br></br>
Note that when allocating new blocks, the game doesn't clean the block header, so sometimes there may be leftover data from previous allocations, showing unusual data, such as wrong pointers.

- `cv64_map_piece_info.js`: Displays information on the currently loaded map pieces, which are subdivisions of the current map loaded into a grid that are used to display large maps without increasing performance.</br></br>
The information shown includes the state of the loaded map piece (active or inactive), as well as its location within the imaginary grid (this grid "moves" while the player is moving through the different map pieces).

- `cv64_object_ID_display.js`: Shows each non-emptyslot from the `Objects_array`, alongside its address and ID number.

- `cv64_misc_info_display.lua`: Displays miscellaneous information regarding the current state of gameplay, such as different player-related variables.
59 changes: 35 additions & 24 deletions cv64/cv64_figures_display.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
function getfigsArrayID(i, fig_array_start, fig_size) {
return ((i - fig_array_start) / fig_size);
return (i - fig_array_start) / fig_size;
}

// CV64 (USA v1.0)
function print_info() {
const fig_array_start = 0x8034EAB8;
const fig_array_end = 0x80363AB8;
const fig_size = 0xA8;
var field_0x00 = 0;
var field_0x02 = 0;
var display_list_addr = 0;
var count = 0;

console.log("----------------------------------------------");
for (var i = fig_array_start; i < fig_array_end; i += fig_size) {
field_0x00 = mem.s16[i];
field_0x02 = mem.s16[i + 2];
display_list_addr = mem.u32[i + 0x34];
field_0x00 = field_0x00 >>> 0; // Signed -> Unsigned
field_0x02 = field_0x02 >>> 0; // Signed -> Unsigned

if (field_0x00 != 0) {
console.log("figs_array[", getfigsArrayID(i, fig_array_start, fig_size), "] = ", i.toString(16), "(", field_0x00.toString(16), " | ", field_0x02.toString(16), ") --- DL = ", display_list_addr.toString(16));
count++;
}
}
console.log("----------------------------------------------");
console.log("Number of figs =", count);
const fig_array_start = 0x8034eab8;
const fig_array_end = 0x80363ab8;
const fig_size = 0xa8;
var field_0x00 = 0;
var field_0x02 = 0;
var display_list_addr = 0;
var count = 0;

console.log('----------------------------------------------');
for (var i = fig_array_start; i < fig_array_end; i += fig_size) {
field_0x00 = mem.s16[i];
field_0x02 = mem.s16[i + 2];
display_list_addr = mem.u32[i + 0x34];
field_0x00 = field_0x00 >>> 0; // Signed -> Unsigned
field_0x02 = field_0x02 >>> 0; // Signed -> Unsigned

if (field_0x00 != 0) {
console.log(
'figs_array[',
getfigsArrayID(i, fig_array_start, fig_size),
'] = ',
i.toString(16),
'(',
field_0x00.toString(16),
' | ',
field_0x02.toString(16),
') --- DL = ',
display_list_addr.toString(16)
);
count++;
}
}
console.log('----------------------------------------------');
console.log('Number of figs =', count);
}

print_info();
206 changes: 115 additions & 91 deletions cv64/cv64_heap_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,121 +2,145 @@
const heap_array_start = 0x80271000;
const heap_array_end = 0x80271060;

const heap_array_entry_size = 0x0C;
const heap_array_entry_size = 0x0c;
const heap_block_header_size = 0x18;

const heapIDStrings = [
"HEAP_KIND_MULTIPURPOSE",
"HEAP_KIND_1",
"HEAP_KIND_MENU_DATA",
"HEAP_KIND_3",
"HEAP_KIND_4",
"HEAP_KIND_5",
"HEAP_KIND_6",
"HEAP_KIND_MAP_DATA"
'HEAP_KIND_MULTIPURPOSE',
'HEAP_KIND_1',
'HEAP_KIND_MENU_DATA',
'HEAP_KIND_3',
'HEAP_KIND_4',
'HEAP_KIND_5',
'HEAP_KIND_6',
'HEAP_KIND_MAP_DATA',
];

var heapBlockFlags = [
{ name: "HEAP_BLOCK_GRAPHIC_CONTAINER", value: 0x4000 },
{ name: "HEAP_BLOCK_ACTIVE", value: 0x8000 }
{ name: 'HEAP_BLOCK_GRAPHIC_CONTAINER', value: 0x4000 },
{ name: 'HEAP_BLOCK_ACTIVE', value: 0x8000 },
];

var heapFlags = [
{ name: "HEAP_WRITE_BACK_CACHE_TO_RAM", value: 0x4000 },
{ name: "HEAP_ACTIVE", value: 0x8000 }
{ name: 'HEAP_WRITE_BACK_CACHE_TO_RAM', value: 0x4000 },
{ name: 'HEAP_ACTIVE', value: 0x8000 },
];

function getFlagString(flags, flagDefinitions, freeStateName) {
var result = [];

for (var i = 0; i < flagDefinitions.length; i++) {
var flag = flagDefinitions[i];
if (flags & flag.value) {
result.push(flag.name);
}
var result = [];

for (var i = 0; i < flagDefinitions.length; i++) {
var flag = flagDefinitions[i];
if (flags & flag.value) {
result.push(flag.name);
}

return result.length > 0 ? result.join(" | ") : freeStateName;
}

return result.length > 0 ? result.join(' | ') : freeStateName;
}

function getHeapIDString(heapID) {
if (heapID >= 8) {
return "";
}
else {
return heapIDStrings[heapID];
}
if (heapID >= 8) {
return '';
} else {
return heapIDStrings[heapID];
}
}

function printHeapInfo(flags, size, heap_start) {
console.log("flags: ", getFlagString(flags, heapFlags, "HEAP_INACTIVE"));
console.log("size: ", size);
console.log("heap_start: ", heap_start.toString(16));
console.log('flags: ', getFlagString(flags, heapFlags, 'HEAP_INACTIVE'));
console.log('size: ', size);
console.log('heap_start: ', heap_start.toString(16));
}

function printHeapBlock(flags, size, field_0x08, data_start, data_end, raw_data_start) {
console.log(" flags: ", getFlagString(flags, heapBlockFlags, "HEAP_BLOCK_FREE"));
console.log(" size: ", size);
console.log(" graphic_container.field_0x00: ", field_0x08.toString(16));
console.log(" graphic_container.data_ptrs[0]: ", data_start.toString(16));
console.log(" graphic_container.data_ptrs[1]: ", data_end.toString(16));
console.log(" raw_data_start: ", raw_data_start.toString(16));
function printHeapBlock(
flags,
size,
field_0x08,
data_start,
data_end,
raw_data_start
) {
console.log(
' flags: ',
getFlagString(flags, heapBlockFlags, 'HEAP_BLOCK_FREE')
);
console.log(' size: ', size);
console.log(' graphic_container.field_0x00: ', field_0x08.toString(16));
console.log(' graphic_container.data_ptrs[0]: ', data_start.toString(16));
console.log(' graphic_container.data_ptrs[1]: ', data_end.toString(16));
console.log(' raw_data_start: ', raw_data_start.toString(16));
}

function printHeaps() {
var heapInfo_flags = 0;
var heapInfo_maxSize = 0;
var heapInfo_dataStart = 0;
var heapInfo_dataEnd = 0;

var heapBlock_flags = 0;
var heapBlock_dataStart = 0;
var heapBlock_maxSize = 0;

var heapInfo_index = 0;
var heapBlock_index = 0;

var heapInfo_usedSpace = 0;

// Loop through each of heap
for (var i = heap_array_start; i < heap_array_end; i += heap_array_entry_size) {
// Get heap header variables
heapInfo_flags = mem.u16[i];
heapInfo_maxSize = mem.u32[i + 4];
heapInfo_dataStart = mem.u32[i + 8];
heapInfo_dataEnd = heapInfo_dataStart + heapInfo_maxSize;

// Print heap header
console.log("--------- heap[", getHeapIDString(heapInfo_index), "] ---------");
printHeapInfo(heapInfo_flags, heapInfo_maxSize, heapInfo_dataStart);
console.log("----------------------------------------------");

// Don't print contents of inactive heap
if (heapInfo_flags != 0) {
// Loop through all blocks within heap
var j = heapInfo_dataStart;
while (j < heapInfo_dataEnd) {
heapBlock_flags = mem.u16[j];
heapBlock_maxSize = mem.u32[j + 4];
heapBlock_dataStart = mem.u32[j + 0xC];
// Don't print block marked as free
if (heapBlock_flags != 0) {
console.log(" Block", heapBlock_index, "(", j.toString(16), ")");
console.log(" -------------------");
printHeapBlock(heapBlock_flags, heapBlock_maxSize, mem.u32[j + 8], heapBlock_dataStart, mem.u32[j + 0x10], (j + 0x18).toString(16));
console.log(" -------------------");
heapInfo_usedSpace += heapBlock_maxSize;
}
j += heap_block_header_size + heapBlock_maxSize;
heapBlock_index += 1;
}
}
console.log(heapInfo_usedSpace, "/", heapInfo_maxSize, "bytes used\n");
heapInfo_index += 1;
heapBlock_index = 0;
heapInfo_usedSpace = 0;
}
console.log("----------------------------------------------");
var heapInfo_flags = 0;
var heapInfo_maxSize = 0;
var heapInfo_dataStart = 0;
var heapInfo_dataEnd = 0;

var heapBlock_flags = 0;
var heapBlock_dataStart = 0;
var heapBlock_maxSize = 0;

var heapInfo_index = 0;
var heapBlock_index = 0;

var heapInfo_usedSpace = 0;

// Loop through each of heap
for (
var i = heap_array_start;
i < heap_array_end;
i += heap_array_entry_size
) {
// Get heap header variables
heapInfo_flags = mem.u16[i];
heapInfo_maxSize = mem.u32[i + 4];
heapInfo_dataStart = mem.u32[i + 8];
heapInfo_dataEnd = heapInfo_dataStart + heapInfo_maxSize;

// Print heap header
console.log(
'--------- heap[',
getHeapIDString(heapInfo_index),
'] ---------'
);
printHeapInfo(heapInfo_flags, heapInfo_maxSize, heapInfo_dataStart);
console.log('----------------------------------------------');

// Don't print contents of inactive heap
if (heapInfo_flags != 0) {
// Loop through all blocks within heap
var j = heapInfo_dataStart;
while (j < heapInfo_dataEnd) {
heapBlock_flags = mem.u16[j];
heapBlock_maxSize = mem.u32[j + 4];
heapBlock_dataStart = mem.u32[j + 0xc];
// Don't print block marked as free
if (heapBlock_flags != 0) {
console.log(' Block', heapBlock_index, '(', j.toString(16), ')');
console.log(' -------------------');
printHeapBlock(
heapBlock_flags,
heapBlock_maxSize,
mem.u32[j + 8],
heapBlock_dataStart,
mem.u32[j + 0x10],
(j + 0x18).toString(16)
);
console.log(' -------------------');
heapInfo_usedSpace += heapBlock_maxSize;
}
j += heap_block_header_size + heapBlock_maxSize;
heapBlock_index += 1;
}
}
console.log(heapInfo_usedSpace, '/', heapInfo_maxSize, 'bytes used\n');
heapInfo_index += 1;
heapBlock_index = 0;
heapInfo_usedSpace = 0;
}
console.log('----------------------------------------------');
}

printHeaps();
Loading