From eb11bcfad2949ae30cc2dfead74776e0205f6268 Mon Sep 17 00:00:00 2001 From: Timothee Groleau Date: Sun, 4 Aug 2024 23:28:02 +0800 Subject: [PATCH] fix: read field correctly --- public/emu/addresses.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/public/emu/addresses.js b/public/emu/addresses.js index eb5eef32..225d2e1b 100644 --- a/public/emu/addresses.js +++ b/public/emu/addresses.js @@ -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 @@ -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); } @@ -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; }