Skip to content

Commit

Permalink
fix: read field correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Aug 4, 2024
1 parent 253783c commit eb11bcf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion public/emu/addresses.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// offsets extracted from
// https://github.com/kirjavascript/TetrisGYM/blob/master/src/ram.asm
// and
// https://github.com/zohassadar/TetrisGYM/blob/ed2ntc/src/nmi/ed2ntc.asm
// id to [address, num_bytes]
const gym6_data_maps = {
gameMode: [0xc0, 1], // gameMode
Expand All @@ -17,13 +21,20 @@ const gym6_data_maps = {
autoRepeatX: [0x46, 1], // autorepeatX

stats: [0x3f0, 7 * 2], // statsByType
field: [0x100, 200], // playfield
field: [0x400, 200], // playfield
};

export const address_maps = {
gym6: gym6_data_maps,
};

const TILE_ID_TO_NTC_BLOCK_ID = new Map([
[0xef, 0],
[0x7b, 1],
[0x7d, 2],
[0x7c, 3],
]);

function _bcdToDecimal(byte1, byte2) {
return byte2 * 100 + (byte1 >> 4) * 10 + (byte1 & 0xf);
}
Expand Down Expand Up @@ -95,6 +106,11 @@ export function assignData(rawData, definition) {
result.stats[statsByteIndex++],
result.stats[statsByteIndex++]
);
delete result.stats;

result.field = result.field.map(
tileId => TILE_ID_TO_NTC_BLOCK_ID.get(tileId) ?? tileId
);

return result;
}

0 comments on commit eb11bcf

Please sign in to comment.