User Tools

Site Tools


zero_mission:locations:generic_bg_graphics
AddressDecimalWidthHeightDescription
0x2007000xxxxxxxxxxHatch Transition Tilemap RAM, uncompressed[1]
0x8364F803559296xxxHatch Transition Tilemap (ROM, RLE compressed)[1]
0x83655A0356086432?Hatch Animation Tilemap[2]
0x85D940C6132748324Generic BG GFX (Zebes)
0x85DA40C6136844324Generic BG GFX (Mothership)
0x85D980C6133772171Zebes Hatch Open Animation
0x85DA80C6137868171Mothership Hatch Open Animation
0x85DFE206159904Palette1 RowGeneric BG Tiles Palette
0x85DFE406159936Palette1 RowGeneric BG Hatch Palette
0x85E04206161440Palette6 RowsZebes Hatch Unlock Palette
0x85E02206160928Palette6 RowsMothership Hatch Unlock Palette

1: To Edit RLE Graphics

To edit:
1) Open ROM in nocash and load a save file. set a breakpoint for [0x2007000]?! . Go through a hatch to start a room transition.
2) Resume the game until it breaks right before the DMA at 0x8003248. This should happen the third time it breaks.
3) Go to 0x2007000 in the data window and dump 4096 (0x1000 bytes) using no$ → utility → “binary dump to .bin file”
4) Export generic BG GFX as raw. (use the default .gfx filetype)
5) Pad the beginning of exported generic BG with 2048 (0x800) bytes of 00.
6) MAGE → tools → compression → lz77 compress file… exported generic BG and dumped tilemap
7) Append both files to the end of ROM using a hex editor. Take note of the offset before you paste in the bytes of the first and second file.
8) Reload rom in MAGE, then open MAGE → editors → tile table editor → offset. punch in compressed tile table, compressed generic bg, and generic bg palette.
9) Make desired edits, then export raw. rename file to “tt.bin” then grab this C code below.1)
10) Go to jdoodle and paste in the code.
11) Upload tt.bin, then run the code. you should get tt.rle.
12) Copy the contents of tt.rle in a hex editor and paste-write over 0x8364F80 (Ctrl+B)

2: To View Hatch Animation Tilemap

To view in MAGE, add tileset (blank), open tileset editor, substract two from offset (0x836559E) and write it to new tileset's tiletable pointer, apply. then open tile table editor to new tileset.

1)
rle_encode.c
#include <iostream>
#include <fstream>
#include <cstring>
 
using namespace std;
 
int main() {
    char * buffin = (char*)malloc(1024*4+4);//+4 prevents need for index out of range checks
    char * buffout = (char*)malloc(1024*4);
    char * bufftmp = (char*)malloc(1024*4);
 
    std::fstream file;
    file.open ("/uploads/tt.bin", std::fstream::in | std::fstream::binary);
    file.read(buffin,1024*4);
    file.close();
	buffin[1024*4+0]=buffin[1024*4-2]+1;buffin[1024*4+1]=buffin[1024*4-1]+1; //ensure last four bytes don't match
	buffin[1024*4+2]=buffin[1024*4-2]-1;buffin[1024*4+3]=buffin[1024*4-1]-1; //ensure last four bytes don't match
    file.open ("/myfiles/tt.rle", std::fstream::out | std::fstream::binary);
 
    char cur;
    int i=0;int o=0;
    buffout[o++]=0x01;//size 4kb
    buffout[o++]=0x01;//size of count values?
    int t;
    while (i<1024*4){ //low bytes
		if (buffin[i]!=buffin[i+2]){ //start of nonrepeating
			t=0;
			while ((i<1024*4) && (buffin[i+2]!=buffin[i+4]) && (t<127-1)) {bufftmp[t++]=buffin[i];i+=2;} //while not start of repeating
			bufftmp[t++]=buffin[i];i+=2;
			buffout[o++]=t;memcpy(buffout+o,bufftmp,t);o+=t;continue;
		} else { //start of repeating
			t=1;i+=2;
			while ((i<1024*4) && (buffin[i-2]==buffin[i]) && (t<127)) {t++;i+=2;} //while not start of repeating
			buffout[o++]=0x80|t;buffout[o++]=buffin[i-2];continue;
 
		}
 
    }
	buffout[o++]=0x00; //terminator
	buffout[o++]=0x02; //size of count values?
 
	i=1;
    while (i<1024*4){ //high bytes
		if (buffin[i]!=buffin[i+2]){ //start of nonrepeating
			t=0;
			while ((i<1024*4) && (buffin[i+2]!=buffin[i+4]) && (t<32767-1)) {bufftmp[t++]=buffin[i];i+=2;} //while not start of repeating
			bufftmp[t++]=buffin[i];i+=2;
			buffout[o++]=t>>8;buffout[o++]=0xff&t;memcpy(buffout+o,bufftmp,t);o+=t;continue;
		} else { //start of repeating
			t=1;i+=2;
			while ((i<1024*4) && (buffin[i-2]==buffin[i]) && (t<32767)) {t++;i+=2;} //while not start of repeating
			buffout[o++]=(t>>8)|0x80;buffout[o++]=0xff&t;buffout[o++]=buffin[i-2];continue;
 
		}
 
    }
	buffout[o++]=0x00; //terminator
	buffout[o++]=0x00; //terminator
 
    file.write(buffout,o);
    file.close();
    free(buffin);free(buffout);free(bufftmp);
    return 0;
}
zero_mission/locations/generic_bg_graphics.txt · Last modified: 2024/05/20 21:27 by felixwright