mirror of
https://github.com/pret/pokered.git
synced 2024-11-26 15:40:25 +00:00
Require rgbds 0.6.0
This commit is contained in:
parent
2b52ceb718
commit
f58dbe3849
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
path: rgbds
|
||||
ref: v0.5.2
|
||||
ref: v0.6.0
|
||||
repository: gbdev/rgbds
|
||||
|
||||
- name: Install rgbds
|
||||
|
22
INSTALL.md
22
INSTALL.md
@ -42,9 +42,9 @@ Run setup and leave the default settings. At the "**Select Packages**" step, cho
|
||||
|
||||
Double click on the text that says "**Skip**" next to each package to select the most recent version to install.
|
||||
|
||||
Then follow the [**rgbds** install instructions](https://rgbds.gbdev.io/install#pre-built) for Windows with Cygwin to install **rgbds 0.5.2**.
|
||||
Then follow the [**rgbds** install instructions](https://rgbds.gbdev.io/install#pre-built) for Windows with Cygwin to install **rgbds 0.6.0**.
|
||||
|
||||
**Note:** If you already have an older rgbds, you will need to update to 0.5.2. Ignore this if you have never installed rgbds before. If a version newer than 0.5.2 does not work, try downloading 0.5.2.
|
||||
**Note:** If you already have an older rgbds, you will need to update to 0.6.0. Ignore this if you have never installed rgbds before. If a version newer than 0.6.0 does not work, try downloading 0.6.0.
|
||||
|
||||
Now open the **Cygwin terminal** and enter the following commands.
|
||||
|
||||
@ -67,7 +67,7 @@ Install [**Homebrew**](https://brew.sh/). Follow the official instructions.
|
||||
|
||||
Open **Terminal** and prepare to enter commands.
|
||||
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for macOS to install **rgbds 0.5.2**.
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for macOS to install **rgbds 0.6.0**.
|
||||
|
||||
Now you're ready to [build **pokered**](#build-pokered).
|
||||
|
||||
@ -84,7 +84,7 @@ To install the software required for **pokered**:
|
||||
sudo apt-get install make gcc git
|
||||
```
|
||||
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.5.2** from source.
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.6.0** from source.
|
||||
|
||||
### OpenSUSE
|
||||
|
||||
@ -94,7 +94,7 @@ To install the software required for **pokered**:
|
||||
sudo zypper install make gcc git
|
||||
```
|
||||
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.5.2** from source.
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.6.0** from source.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
@ -104,9 +104,9 @@ To install the software required for **pokered**:
|
||||
sudo pacman -S make gcc git
|
||||
```
|
||||
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for Arch Linux to install **rgbds 0.5.2**.
|
||||
Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#pre-built) for Arch Linux to install **rgbds 0.6.0**.
|
||||
|
||||
If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.5.2** from source.
|
||||
If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.6.0** from source.
|
||||
|
||||
### Termux
|
||||
|
||||
@ -122,7 +122,7 @@ To install **rgbds**:
|
||||
sudo apt install rgbds
|
||||
```
|
||||
|
||||
If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.5.2** from source.
|
||||
If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.6.0** from source.
|
||||
|
||||
### Other distros
|
||||
|
||||
@ -133,7 +133,7 @@ If your distro is not listed here, try to find the required software in its repo
|
||||
- `git`
|
||||
- `rgbds`
|
||||
|
||||
If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.5.2** from source.
|
||||
If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install#building-from-source) to build **rgbds 0.6.0** from source.
|
||||
|
||||
Now you're ready to [build **pokered**](#build-pokered).
|
||||
|
||||
@ -155,8 +155,8 @@ make
|
||||
|
||||
### Build with a local rgbds version
|
||||
|
||||
If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 0.5.2 globally. Instead, you can put its files in a directory within pokered, such as `pokered/rgbds-0.5.2/`. Then specify it when you run `make`:
|
||||
If you have different projects that require different versions of `rgbds`, it might not be convenient to install rgbds 0.6.0 globally. Instead, you can put its files in a directory within pokered, such as `pokered/rgbds-0.6.0/`. Then specify it when you run `make`:
|
||||
|
||||
```bash
|
||||
make RGBDS=rgbds-0.5.2/
|
||||
make RGBDS=rgbds-0.6.0/
|
||||
```
|
||||
|
22
Makefile
22
Makefile
@ -85,7 +85,7 @@ tools:
|
||||
$(MAKE) -C tools/
|
||||
|
||||
|
||||
RGBASMFLAGS = -h -L -Weverything -Wnumeric-string=2 -Wtruncation=1
|
||||
RGBASMFLAGS = -hL -Q8 -P includes.asm -Weverything -Wnumeric-string=2 -Wtruncation=1
|
||||
# Create a sym/map for debug purposes if `make` run with `DEBUG=1`
|
||||
ifeq ($(DEBUG),1)
|
||||
RGBASMFLAGS += -E
|
||||
@ -107,7 +107,7 @@ rgbdscheck.o: rgbdscheck.asm
|
||||
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
|
||||
# It doesn't look like $(shell) can be deferred so there might not be a better way.
|
||||
define DEP
|
||||
$1: $2 $$(shell tools/scan_includes $2) | rgbdscheck.o
|
||||
$1: $2 $$(shell tools/scan_includes $2) | includes.asm rgbdscheck.o
|
||||
$$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
|
||||
endef
|
||||
|
||||
@ -125,8 +125,8 @@ $(foreach obj, $(pokered_vc_obj), $(eval $(call DEP,$(obj),$(obj:_red_vc.o=.asm)
|
||||
$(foreach obj, $(pokeblue_vc_obj), $(eval $(call DEP,$(obj),$(obj:_blue_vc.o=.asm))))
|
||||
|
||||
# Dependencies for VC files that need to run scan_includes
|
||||
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | rgbdscheck.o
|
||||
$(RGBASM) $< > $@
|
||||
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | includes.asm rgbdscheck.o
|
||||
$(RGBASM) $(RGBASMFLAGS) $< > $@
|
||||
|
||||
endif
|
||||
|
||||
@ -156,13 +156,13 @@ pokeblue_vc_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
|
||||
gfx/battle/move_anim_0.2bpp: tools/gfx += --trim-whitespace
|
||||
gfx/battle/move_anim_1.2bpp: tools/gfx += --trim-whitespace
|
||||
|
||||
gfx/intro/blue_jigglypuff_1.2bpp: rgbgfx += -h
|
||||
gfx/intro/blue_jigglypuff_2.2bpp: rgbgfx += -h
|
||||
gfx/intro/blue_jigglypuff_3.2bpp: rgbgfx += -h
|
||||
gfx/intro/red_nidorino_1.2bpp: rgbgfx += -h
|
||||
gfx/intro/red_nidorino_2.2bpp: rgbgfx += -h
|
||||
gfx/intro/red_nidorino_3.2bpp: rgbgfx += -h
|
||||
gfx/intro/gengar.2bpp: rgbgfx += -h
|
||||
gfx/intro/blue_jigglypuff_1.2bpp: rgbgfx += -Z
|
||||
gfx/intro/blue_jigglypuff_2.2bpp: rgbgfx += -Z
|
||||
gfx/intro/blue_jigglypuff_3.2bpp: rgbgfx += -Z
|
||||
gfx/intro/red_nidorino_1.2bpp: rgbgfx += -Z
|
||||
gfx/intro/red_nidorino_2.2bpp: rgbgfx += -Z
|
||||
gfx/intro/red_nidorino_3.2bpp: rgbgfx += -Z
|
||||
gfx/intro/gengar.2bpp: rgbgfx += -Z
|
||||
gfx/intro/gengar.2bpp: tools/gfx += --remove-duplicates --preserve=0x19,0x76
|
||||
|
||||
gfx/credits/the_end.2bpp: tools/gfx += --interleave --png=$<
|
||||
|
@ -1,6 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
|
||||
SECTION "Sound Effect Headers 1", ROMX
|
||||
INCLUDE "audio/headers/sfxheaders1.asm"
|
||||
|
||||
|
@ -1,6 +1,19 @@
|
||||
INCLUDE "charmap.asm"
|
||||
|
||||
INCLUDE "macros.asm"
|
||||
INCLUDE "macros/asserts.asm"
|
||||
INCLUDE "macros/const.asm"
|
||||
INCLUDE "macros/predef.asm"
|
||||
INCLUDE "macros/farcall.asm"
|
||||
INCLUDE "macros/data.asm"
|
||||
INCLUDE "macros/code.asm"
|
||||
INCLUDE "macros/gfx.asm"
|
||||
INCLUDE "macros/coords.asm"
|
||||
INCLUDE "macros/vc.asm"
|
||||
|
||||
INCLUDE "macros/scripts/audio.asm"
|
||||
INCLUDE "macros/scripts/maps.asm"
|
||||
INCLUDE "macros/scripts/events.asm"
|
||||
INCLUDE "macros/scripts/text.asm"
|
||||
|
||||
INCLUDE "constants/hardware_constants.asm"
|
||||
INCLUDE "constants/oam_constants.asm"
|
14
macros.asm
14
macros.asm
@ -1,14 +0,0 @@
|
||||
INCLUDE "macros/asserts.asm"
|
||||
INCLUDE "macros/const.asm"
|
||||
INCLUDE "macros/predef.asm"
|
||||
INCLUDE "macros/farcall.asm"
|
||||
INCLUDE "macros/data.asm"
|
||||
INCLUDE "macros/code.asm"
|
||||
INCLUDE "macros/gfx.asm"
|
||||
INCLUDE "macros/coords.asm"
|
||||
INCLUDE "macros/vc.asm"
|
||||
|
||||
INCLUDE "macros/scripts/audio.asm"
|
||||
INCLUDE "macros/scripts/maps.asm"
|
||||
INCLUDE "macros/scripts/events.asm"
|
||||
INCLUDE "macros/scripts/text.asm"
|
3
main.asm
3
main.asm
@ -1,6 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
|
||||
SECTION "bank1", ROMX
|
||||
|
||||
INCLUDE "data/sprites/facings.asm"
|
||||
|
3
maps.asm
3
maps.asm
@ -1,6 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
|
||||
SECTION "Maps 1", ROMX
|
||||
|
||||
INCLUDE "data/maps/headers/CeladonCity.asm"
|
||||
|
@ -1,18 +1,16 @@
|
||||
MAJOR EQU 0
|
||||
MINOR EQU 5
|
||||
PATCH EQU 2
|
||||
MINOR EQU 6
|
||||
PATCH EQU 0
|
||||
|
||||
MACRO wrong_rgbds
|
||||
fail "pokered requires rgbds v0.5.2 or newer."
|
||||
ENDM
|
||||
WRONG_RGBDS EQUS "fail \"pokered requires rgbds v0.6.0 or newer.\""
|
||||
|
||||
IF !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__)
|
||||
wrong_rgbds
|
||||
WRONG_RGBDS
|
||||
ELSE
|
||||
IF (__RGBDS_MAJOR__ < MAJOR) || \
|
||||
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \
|
||||
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH) || \
|
||||
(__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ == PATCH && DEF(__RGBDS_RC__))
|
||||
wrong_rgbds
|
||||
WRONG_RGBDS
|
||||
ENDC
|
||||
ENDC
|
||||
|
3
text.asm
3
text.asm
@ -1,6 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
|
||||
SECTION "Text 1", ROMX
|
||||
|
||||
INCLUDE "data/text/text_1.asm"
|
||||
|
@ -39,7 +39,7 @@ function register_bank(amount) {
|
||||
}
|
||||
}
|
||||
|
||||
rom_bank && toupper($0) ~ /^[ \t]*EMPTY/ {
|
||||
rom_bank && toupper($0) ~ /^[ \t]*EMPTY$/ {
|
||||
# Empty bank
|
||||
register_bank(16384)
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Usage: python3 free_space.py [BANK=none] [pokered.map]
|
||||
|
||||
Calculate the free space in the ROM or its individual banks.
|
||||
|
||||
The BANK argument allows printing free space in one, all, or none of the ROM's banks.
|
||||
Valid arguments are numbers (in decimal "42" or hexadecimal "0x2A"), "all" or "none".
|
||||
If not specified, defaults to "none".
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from mapreader import MapReader
|
||||
|
||||
def main():
|
||||
print_bank = 'none'
|
||||
filename = 'pokered.map'
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith('BANK='):
|
||||
print_bank = arg.split('=', 1)[-1]
|
||||
else:
|
||||
filename = arg
|
||||
|
||||
if print_bank not in {'all', 'none'}:
|
||||
try:
|
||||
print_bank = (int(print_bank[2:], 16)
|
||||
if print_bank.startswith(('0x', '0X'))
|
||||
else int(print_bank))
|
||||
except ValueError:
|
||||
error = f'Error: invalid BANK: {print_bank}'
|
||||
if print_bank.isalnum():
|
||||
error += f' (did you mean: 0x{print_bank}?)'
|
||||
print(error, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
num_banks = 0x80
|
||||
bank_size = 0x4000 # bytes
|
||||
total_size = num_banks * bank_size
|
||||
|
||||
reader = MapReader()
|
||||
with open(filename, 'r', encoding='utf-8') as file:
|
||||
reader.read_map_data(file.readlines())
|
||||
|
||||
free_space = 0
|
||||
per_bank = []
|
||||
default_bank_data = {'sections': [], 'used': 0, 'slack': bank_size}
|
||||
for bank in range(num_banks):
|
||||
bank_data = reader.bank_data['ROM0 bank' if bank == 0 else 'ROMX bank']
|
||||
data = bank_data.get(bank, default_bank_data)
|
||||
used, slack = data['used'], data['slack']
|
||||
per_bank.append((used, slack))
|
||||
free_space += slack
|
||||
|
||||
free_percent = 100 * free_space / total_size
|
||||
print(f'Free space: {free_space}/{total_size} ({free_percent:.2f}%)')
|
||||
if print_bank != 'none':
|
||||
print()
|
||||
print('bank, used, free')
|
||||
for bank in range(num_banks):
|
||||
used, slack = per_bank[bank]
|
||||
if print_bank in {'all', bank}:
|
||||
print(f'${bank:02X}, {used}, {slack}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,173 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# A library for parsing the pokered.map file output by rgbds.
|
||||
|
||||
import re
|
||||
|
||||
class MapReader:
|
||||
|
||||
# {'ROM Bank': { 0: { 'sections': [ { 'beg': 1234,
|
||||
# 'end': 5678,
|
||||
# 'name': 'Section001',
|
||||
# 'symbols': [ { 'symbol': 'Function1234',
|
||||
# 'address: 1234,
|
||||
# },
|
||||
# ]
|
||||
# },
|
||||
# ],
|
||||
# 'used': 1234,
|
||||
# 'slack': 4567,
|
||||
# },
|
||||
# },
|
||||
# 'OAM': { 'sections': [ { 'beg': 1234,
|
||||
# 'end': 5678,
|
||||
# 'name': 'Section002',
|
||||
# 'symbols': [ { 'symbol': 'Data1234',
|
||||
# 'address: 1234,
|
||||
# },
|
||||
# ]
|
||||
# },
|
||||
# ],
|
||||
# 'used': 1234,
|
||||
# 'slack': 4567,
|
||||
# },
|
||||
# }
|
||||
#
|
||||
bank_data = {}
|
||||
|
||||
bank_types = {
|
||||
'HRAM' : { 'size': 0x80, 'banked': False, },
|
||||
'OAM' : { 'size': 0xA0, 'banked': False, },
|
||||
'ROM0 bank': { 'size': 0x4000, 'banked': True, },
|
||||
'ROMX bank': { 'size': 0x4000, 'banked': True, },
|
||||
'SRAM bank': { 'size': 0x2000, 'banked': True, },
|
||||
'VRAM bank': { 'size': 0x1000, 'banked': True, },
|
||||
'WRAM bank': { 'size': 0x2000, 'banked': True, },
|
||||
}
|
||||
|
||||
# FSM states
|
||||
INIT, BANK, SECTION = range(3)
|
||||
|
||||
# $506D-$519A ($012E bytes) ["Type Matchups"]
|
||||
section_header_regex = re.compile('\$([0-9A-Fa-f]{4})-\$([0-9A-Fa-f]{4}) \(.*\) \["(.*)"\]')
|
||||
# $506D = TypeMatchups
|
||||
section_data_regex = re.compile('\$([0-9A-Fa-f]{4}) = (.*)')
|
||||
# $3ED2 bytes
|
||||
slack_regex = re.compile('\$([0-9A-Fa-f]{4}) bytes?')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
def _parse_init(self, line):
|
||||
|
||||
line = line.split(':', 1)[0]
|
||||
parts = line.split(' #', 1)
|
||||
|
||||
if (parts[0] in self.bank_types):
|
||||
self._cur_bank_name = parts[0]
|
||||
self._cur_bank_type = self.bank_types[self._cur_bank_name]
|
||||
if (self._cur_bank_type['banked'] and len(parts) > 1):
|
||||
parts[1] = parts[1].split(':', 1)[0]
|
||||
parts[1] = parts[1].split(' ', 1)[0]
|
||||
self._cur_bank = int(parts[1], 10)
|
||||
if self._cur_bank_name not in self.bank_data:
|
||||
self.bank_data[self._cur_bank_name] = {}
|
||||
if self._cur_bank_type['banked']:
|
||||
if self._cur_bank not in self.bank_data[self._cur_bank_name]:
|
||||
self.bank_data[self._cur_bank_name][self._cur_bank] = {}
|
||||
self._cur_data = self.bank_data[self._cur_bank_name][self._cur_bank]
|
||||
else:
|
||||
self._cur_data = self.bank_data[self._cur_bank_name]
|
||||
|
||||
if ({} == self._cur_data):
|
||||
self._cur_data['sections'] = []
|
||||
self._cur_data['used'] = 0
|
||||
self._cur_data['slack'] = self._cur_bank_type['size']
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _parse_section_header(self, header):
|
||||
|
||||
section_data = self.section_header_regex.match(header)
|
||||
if section_data is not None:
|
||||
beg = int(section_data.group(1), 16)
|
||||
end = int(section_data.group(2), 16)
|
||||
name = section_data.group(3)
|
||||
self._cur_section = {'beg': beg, 'end': end, 'name': name, 'symbols': []}
|
||||
self._cur_data['sections'].append(self._cur_section)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _parse_slack(self, data):
|
||||
|
||||
slack_data = self.slack_regex.match(data)
|
||||
slack_bytes = int(slack_data.group(1), 16)
|
||||
self._cur_data['slack'] = slack_bytes
|
||||
|
||||
used_bytes = 0
|
||||
|
||||
for s in self._cur_data['sections']:
|
||||
used_bytes += s['end'] - s['beg'] + 1
|
||||
|
||||
self._cur_data['used'] = used_bytes
|
||||
|
||||
def read_map_data(self, map):
|
||||
|
||||
if type(map) is str:
|
||||
map = map.split('\n')
|
||||
|
||||
self._state = MapReader.INIT
|
||||
self._cur_bank_name = ''
|
||||
self._cur_bank_type = {}
|
||||
self._cur_bank = 0
|
||||
self._cur_data = {}
|
||||
|
||||
for line in map:
|
||||
|
||||
line = line.rstrip()
|
||||
if (MapReader.INIT == self._state):
|
||||
|
||||
if (self._parse_init(line)):
|
||||
self._state = MapReader.BANK
|
||||
|
||||
elif (MapReader.BANK == self._state or MapReader.SECTION == self._state):
|
||||
|
||||
if ('' == line):
|
||||
self._state = MapReader.INIT
|
||||
else:
|
||||
|
||||
line = line.lstrip()
|
||||
parts = line.split(': ', 1)
|
||||
|
||||
if (MapReader.SECTION == self._state):
|
||||
section_data = self.section_data_regex.match(parts[0])
|
||||
if section_data is not None:
|
||||
address = int(section_data.group(1), 16)
|
||||
name = section_data.group(2)
|
||||
self._cur_section['symbols'].append({'name': name, 'address': address})
|
||||
continue
|
||||
|
||||
if ('SECTION' == parts[0]):
|
||||
if (self._parse_section_header(parts[1])):
|
||||
self._state = MapReader.SECTION
|
||||
elif ('SLACK' == parts[0]):
|
||||
self._parse_slack(parts[1])
|
||||
self._state = MapReader.INIT
|
||||
elif ('EMPTY' == parts[0]):
|
||||
self._cur_data = {'sections': [], 'used': 0, 'slack': self._cur_bank_type['size']}
|
||||
self._state = MapReader.INIT
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
for k, v in self.bank_data.items():
|
||||
if (self.bank_types[k]['banked']):
|
||||
for _, vv in v.items():
|
||||
vv['sections'].sort(key=lambda x: x['beg'])
|
||||
for vvv in vv['sections']:
|
||||
vvv['symbols'].sort(key=lambda x: x['address'])
|
||||
else:
|
||||
v['sections'].sort(key=lambda x: x['beg'])
|
||||
for vv in v['sections']:
|
||||
vv['symbols'].sort(key=lambda x: x['address'])
|
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Usage: python used_space.py [pokered.map] [used_space.png]
|
||||
|
||||
Generate a PNG visualizing the space used by each bank in the ROM.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from colorsys import hls_to_rgb
|
||||
|
||||
import png
|
||||
from mapreader import MapReader
|
||||
|
||||
def main():
|
||||
mapfile = sys.argv[1] if len(sys.argv) >= 2 else 'pokered.map'
|
||||
outfile = sys.argv[2] if len(sys.argv) >= 3 else 'used_space.png'
|
||||
|
||||
num_banks = 0x80
|
||||
bank_mask = 0x3FFF
|
||||
bank_size = 0x4000 # bytes
|
||||
|
||||
bpp = 8 # bytes per pixel
|
||||
height = 256 # pixels
|
||||
assert bank_size % bpp == 0 and (bank_size // bpp) % height == 0
|
||||
|
||||
pixels_per_bank = bank_size // bpp # 2048 pixels
|
||||
bank_width = pixels_per_bank // height # 8 pixels
|
||||
width = bank_width * num_banks # 1024 pixels
|
||||
|
||||
reader = MapReader()
|
||||
with open(mapfile, 'r', encoding='utf-8') as file:
|
||||
reader.read_map_data(file.readlines())
|
||||
|
||||
hit_data = []
|
||||
default_bank_data = {'sections': [], 'used': 0, 'slack': bank_size}
|
||||
for bank in range(num_banks):
|
||||
hits = [0] * pixels_per_bank
|
||||
bank_data = reader.bank_data['ROM0 bank' if bank == 0 else 'ROMX bank']
|
||||
data = bank_data.get(bank, default_bank_data)
|
||||
for s in data['sections']:
|
||||
beg = s['beg'] & bank_mask
|
||||
end = s['end'] & bank_mask
|
||||
for i in range(beg, end + 1):
|
||||
hits[i // bpp] += 1
|
||||
hit_data.append(hits)
|
||||
|
||||
pixels = [[(0xFF, 0xFF, 0xFF)] * width for _ in range(height)]
|
||||
for bank, hits in enumerate(hit_data):
|
||||
hue = 0 if bank == 0 else 210 if bank % 2 else 270
|
||||
for i, hit in enumerate(hits):
|
||||
x, y = i % bank_width + bank * bank_width, i // bank_width
|
||||
hls = (hue / 360, 1 - (85 * hit / bpp) / 100, 1)
|
||||
rgb = tuple(int(c * 0xFF) for c in hls_to_rgb(*hls))
|
||||
pixels[y][x] = rgb
|
||||
|
||||
png_data = [tuple(c for pixel in row for c in pixel) for row in pixels]
|
||||
with open(outfile, 'wb') as file:
|
||||
writer = png.Writer(width, height, greyscale=False, bitdepth=8, compression=9)
|
||||
writer.write(file, png_data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,5 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
; These are all the asm constants needed to make the blue_vc patch.
|
||||
|
||||
MACRO vc_const
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDE "constants.asm"
|
||||
|
||||
; These are all the asm constants needed to make the red_vc patch.
|
||||
|
||||
MACRO vc_const
|
||||
|
Loading…
Reference in New Issue
Block a user