Skip to content

Commit

Permalink
visions: remove end address for tilemaps
Browse files Browse the repository at this point in the history
This data is unecessary, because the uncompress algorithm can infer
when the blob ends
  • Loading branch information
macabeus committed Jan 2, 2020
1 parent 9c3c858 commit fcdd237
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions scissors/src/rom.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isCustomRom = (romBuffer) => {
}

const visionHasCustomTilemap = (romBuffer, visionInfo) =>
romBuffer[visionInfo.rom.customTilemap[0]] !== 0x00
romBuffer[visionInfo.rom.customTilemap] !== 0x00

const setConstant = (romBuffer, address, value24hexLength) => {
const bytes = splitHexValueIntoBytesArray(value24hexLength, 4)
Expand All @@ -24,8 +24,8 @@ const setPatchCustomVisionLoader = (romBuffer) => {
visionHasCustomTilemap(romBuffer, visionInfo))

const addresses = allVisions.map(visionInfo => ({
custom: mapAddressToRomOffset(visionInfo.rom.customTilemap[0]),
original: mapAddressToRomOffset(visionInfo.rom.tilemap[0]),
custom: mapAddressToRomOffset(visionInfo.rom.customTilemap),
original: mapAddressToRomOffset(visionInfo.rom.tilemap),
}))

// set bl to go to our patch
Expand Down
10 changes: 5 additions & 5 deletions scissors/src/visionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {

const isNumeric = pipe(t => Number(t), identical(NaN), not)

const extractFullTilemap = (romBuffer, [addressStart, addressEnd]) =>
romBuffer.slice(addressStart, addressEnd)
const extractFullTilemap = (romBuffer, addressStart) =>
romBuffer.slice(addressStart)
|> huffmanDecode
|> lzssDecode

Expand Down Expand Up @@ -71,14 +71,14 @@ const extractPortals = (romBuffer, [addressStart, addressEnd]) =>

const getVision = (romBuffer, world, vision) => {
const infos = loadVisionInfo(world, vision)
const range = visionHasCustomTilemap(romBuffer, infos) ?
const addressStart = visionHasCustomTilemap(romBuffer, infos) ?
infos.rom.customTilemap :
infos.rom.tilemap

// The first 3 bytes of tilemap isn't the tiles,
// but something unknown important to plot the level at the game.
// So this proxy is useful to abstract Brush about this detail
const fullTilemap = extractFullTilemap(romBuffer, range)
const fullTilemap = extractFullTilemap(romBuffer, addressStart)

const tilemapProxy = new Proxy(fullTilemap, {
get: (target, property) => {
Expand Down Expand Up @@ -170,7 +170,7 @@ const compressTilemap = buffer =>

const saveVision = (romBuffer, world, index, tilemap, objectsDiffsMap) => {
const infos = loadVisionInfo(world, index)
const [customTilemapStartAddress] = infos.rom.customTilemap
const customTilemapStartAddress = infos.rom.customTilemap
const [objectsStartAddress] = infos.rom.objects

const encoded = compressTilemap(tilemap)
Expand Down
4 changes: 2 additions & 2 deletions scissors/src/visions/1-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
index: 1,
},
rom: {
tilemap: [0x1B27FC, 0x1B36F3],
customTilemap: [0x367700, 0x3686AF],
tilemap: 0x1B27FC,
customTilemap: 0x367700,
objects: [0xE2B90, 0xE2F59],
portals: [0xD48C8, 0xD48EF],
},
Expand Down
4 changes: 2 additions & 2 deletions scissors/src/visions/1-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
index: 2,
},
rom: {
tilemap: [0x1B3E5C, 0x1B4AC3],
customTilemap: [0x3686B0, 0x36937F],
tilemap: 0x1B3E5C,
customTilemap: 0x3686B0,
objects: [0xE3CC0, 0xE3FAC],
portals: [0xD4970, 0xD49A0],
},
Expand Down
4 changes: 2 additions & 2 deletions scissors/src/visions/1-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
index: 3,
},
rom: {
tilemap: [0x1B50AC, 0x1B5ECC],
customTilemap: [0x369380, 0x36A220],
tilemap: 0x1B50AC,
customTilemap: 0x369380,
objects: [0xE4DF0, 0xE5109],
portals: [0xD4A18, 0xD4A5F],
},
Expand Down

0 comments on commit fcdd237

Please sign in to comment.