From 603b42797c4b0e7a3e2a3cac320daecf1ee34feb Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Sun, 28 Nov 2021 17:31:33 +0100 Subject: Add GitHub Actions CI/release workflow, rewrite changelog --- .github/scripts/generate_release_notes.py | 194 ++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 .github/scripts/generate_release_notes.py (limited to '.github/scripts/generate_release_notes.py') diff --git a/.github/scripts/generate_release_notes.py b/.github/scripts/generate_release_notes.py new file mode 100644 index 0000000..f3e4870 --- /dev/null +++ b/.github/scripts/generate_release_notes.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python3 +# PSn00bSDK release notes generator +# (C) 2021 spicyjpeg - MPL licensed + +import sys, re +from time import gmtime, strptime +from argparse import ArgumentParser, FileType + +## Helpers + +VERSION_REGEX = re.compile(r"^(?:refs\/tags\/)?(?:v|ver|version|release)? *(.*)") + +def parse_date(date): + return strptime(date.strip(), "%Y-%m-%d") + +def normalize_version(version): + match = VERSION_REGEX.match(version.lower()) + if not match: + raise ValueError(f"invalid version string: {version}") + + return match.group(1) + +## Changelog parser + +BLOCK_REGEX = re.compile(r"^#{2,}[ \t]*([0-9]{4}-[0-9]{2}-[0-9]{2})(?:[:\- \t]+(.+?))?$", re.MULTILINE) +AUTHOR_REGEX = re.compile(r"^([A-Za-z0-9_].*?)[ \t]*:.*?$", re.MULTILINE) +FIRST_VERSION = "initial" + +def parse_authors(block): + # [ _crap, author, body, author, body, ... ] + items = AUTHOR_REGEX.split(block.strip()) + + if items[0].strip(): + raise RuntimeError("a block has changes listed with no author specified") + + authors = {} + for i in range(1, len(items), 2): + name, body = items[i:i + 2] + + name = name.strip() + body = body.strip() + if name not in authors: + authors[name] = "" + + authors[name] += body + + return authors + +def parse_blocks(changelog): + # [ _crap, date, version, body, date, version, body, ... ] + items = BLOCK_REGEX.split(changelog.strip()) + + #if items[0].strip(): + #raise RuntimeError("the changelog doesn't start with a valid block") + + # Iterate over all blocks from bottom to top (i.e. oldest first). + last_version = FIRST_VERSION + + for i in range(len(items), 1, -3): + date, version, body = items[i - 3:i] + + # If no version is present in the header, assume it's the same as the + # previous block's version. + if version: + version = normalize_version(version) + last_version = version + else: + version = last_version + + yield parse_date(date), version, parse_authors(body) + +## Release notes generation + +VERSION_TEMPLATE = """New in version **{version}** (contributed by {authors}): + +{changes} + +""" +NOTES_TEMPLATE = """{notes} + +------------------------------------------------------- +_These notes have been generated automatically._ +_See the changelog or commit history for more details._ +""" + +NO_VERSIONS_TEMPLATE = "No information available about this release." +AUTHOR_LINK_TEMPLATE = "**{0}**" +#AUTHOR_LINK_TEMPLATE = "[{0}](https://github.com/{0})" + +def generate_notes(versions): + notes = "" + + for version, ( authors, changes ) in versions.items(): + _authors = list(set(authors)) + _authors.sort() + _authors = map(AUTHOR_LINK_TEMPLATE.format, _authors) + + notes += VERSION_TEMPLATE.format( + version = version, + authors = ", ".join(_authors), + changes = "\n\n".join(changes) + ) + + if not notes: + notes = NO_VERSIONS_TEMPLATE + + return NOTES_TEMPLATE.format(notes = notes.strip()) + +## Main + +def get_args(): + parser = ArgumentParser( + description = "Generates and outputs release notes from a Markdown changelog file.", + add_help = False + ) + + tools_group = parser.add_argument_group("Tools") + tools_group.add_argument( + "-h", "--help", + action = "help", + help = "Show this help message and exits" + ) + + files_group = parser.add_argument_group("Files") + files_group.add_argument( + "changelog", + type = FileType("rt"), + help = "Markdown changelog file to parse" + ) + files_group.add_argument( + "-o", "--output", + type = FileType("wt"), + default = sys.stdout, + help = "Where to output release notes (stdout by default)", + metavar = "file" + ) + + filter_group = parser.add_argument_group("Filters") + filter_group.add_argument( + "-v", "--version", + action = "append", + type = str, + help = "Ignore all changes not belonging to a version (can be specified multiple times)", + metavar = "name" + ) + filter_group.add_argument( + "-f", "--from-date", + type = parse_date, + default = parse_date("2000-01-01"), + help = "Ignore all changes before date", + metavar = "yyyy-mm-dd" + ) + filter_group.add_argument( + "-t", "--to-date", + type = parse_date, + default = gmtime(), + help = "Ignore all changes after date", + metavar = "yyyy-mm-dd" + ) + + return parser.parse_args() + +def main(): + args = get_args() + version_list = list(map(normalize_version, args.version or [])) + + with args.changelog as _file: + changelog = _file.read() + + # Iterate over all blocks in the changelog and sort them by version, + # merging all changes and authors for each version. + versions = {} + + for date, version, authors in parse_blocks(changelog): + # Apply version and date filters. + if version_list and (version not in version_list): + continue + if date < args.from_date or date > args.to_date: + continue + + if version not in versions: + versions[version] = [], [] + + _authors, _changes = versions[version] + _authors.extend(authors.keys()) + _changes.extend(authors.values()) + + notes = generate_notes(versions) + + with args.output as _file: + _file.write(notes) + +if __name__ == "__main__": + main() -- cgit v1.2.3 From 2e6625481cd006d0a9d68285ce557f195030718e Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Thu, 23 Dec 2021 22:09:06 +0100 Subject: Fix CdGetSector size inconsistency, update changelog --- .github/scripts/generate_release_notes.py | 46 ++++++++++--------------------- CHANGELOG.md | 29 +++++++++++++------ examples/cdrom/cdxa/main.c | 2 +- examples/io/system573/main.c | 2 +- libpsn00b/psxcd/cdgetsector.s | 3 +- libpsn00b/psxcd/isofs.c | 2 +- libpsn00b/psxcd/psxcd.c | 8 +++--- 7 files changed, 44 insertions(+), 48 deletions(-) (limited to '.github/scripts/generate_release_notes.py') diff --git a/.github/scripts/generate_release_notes.py b/.github/scripts/generate_release_notes.py index f3e4870..e3fbc7f 100644 --- a/.github/scripts/generate_release_notes.py +++ b/.github/scripts/generate_release_notes.py @@ -3,7 +3,7 @@ # (C) 2021 spicyjpeg - MPL licensed import sys, re -from time import gmtime, strptime +from time import gmtime, strptime, struct_time from argparse import ArgumentParser, FileType ## Helpers @@ -11,14 +11,13 @@ from argparse import ArgumentParser, FileType VERSION_REGEX = re.compile(r"^(?:refs\/tags\/)?(?:v|ver|version|release)? *(.*)") def parse_date(date): + if isinstance(date, struct_time): + return date + return strptime(date.strip(), "%Y-%m-%d") def normalize_version(version): - match = VERSION_REGEX.match(version.lower()) - if not match: - raise ValueError(f"invalid version string: {version}") - - return match.group(1) + return VERSION_REGEX.match(version.lower()).group(1) ## Changelog parser @@ -50,9 +49,6 @@ def parse_blocks(changelog): # [ _crap, date, version, body, date, version, body, ... ] items = BLOCK_REGEX.split(changelog.strip()) - #if items[0].strip(): - #raise RuntimeError("the changelog doesn't start with a valid block") - # Iterate over all blocks from bottom to top (i.e. oldest first). last_version = FIRST_VERSION @@ -110,51 +106,39 @@ def generate_notes(versions): def get_args(): parser = ArgumentParser( - description = "Generates and outputs release notes from a Markdown changelog file.", - add_help = False + description = "Generates and outputs release notes from a Markdown changelog file." ) - - tools_group = parser.add_argument_group("Tools") - tools_group.add_argument( - "-h", "--help", - action = "help", - help = "Show this help message and exits" - ) - - files_group = parser.add_argument_group("Files") - files_group.add_argument( + parser.add_argument( "changelog", type = FileType("rt"), help = "Markdown changelog file to parse" ) - files_group.add_argument( + parser.add_argument( "-o", "--output", type = FileType("wt"), default = sys.stdout, - help = "Where to output release notes (stdout by default)", + help = "where to output release notes (stdout by default)", metavar = "file" ) - - filter_group = parser.add_argument_group("Filters") - filter_group.add_argument( + parser.add_argument( "-v", "--version", action = "append", type = str, - help = "Ignore all changes not belonging to a version (can be specified multiple times)", + help = "ignore all changes not belonging to a version (can be specified multiple times)", metavar = "name" ) - filter_group.add_argument( + parser.add_argument( "-f", "--from-date", type = parse_date, default = parse_date("2000-01-01"), - help = "Ignore all changes before date", + help = "ignore all changes before date", metavar = "yyyy-mm-dd" ) - filter_group.add_argument( + parser.add_argument( "-t", "--to-date", type = parse_date, default = gmtime(), - help = "Ignore all changes after date", + help = "ignore all changes after date", metavar = "yyyy-mm-dd" ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9463b83..ea4f4d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ contributing to PSn00bSDK, add a new block at the top following this template: ``` -## --: +## --: [optional new version] : @@ -19,6 +19,17 @@ to ensure the changelog can be parsed correctly. ------------------------------------------------------------------------------- +## 2021-12-23 + +spicyjpeg: + +- psxcd: `CdGetSector()` now expects the sector size to be in 32-bit word units + (rather than bytes) for consistency with the official CD-ROM library. The + library's ISO9660 parser and helper functions have been updated accordingly. + **This is a breaking change**. + +- examples: Added `spustream` audio streaming example. + ## 2021-11-28: 0.18 spicyjpeg: @@ -453,7 +464,7 @@ Lameguy64: - psxgpu: Fixed typos in `setUVWH()` macro. -- Added `_boot()` BIOS function (A(A0h) aka Warmboot, useful for CD based +- Added `_boot()` BIOS function (`A(A0h)` aka Warmboot, useful for CD based serial loaders). ## 2019-08-17: 0.13b @@ -505,9 +516,9 @@ Lameguy64: executable to return to a parent executable, return logic automatically calls `EnterCriticalSection()`. -- libc: Updated build method which takes libgcc from the compiler and adds +- libc: Updated build method which takes `libgcc` from the compiler and adds its own object files into it, eliminating linker problems caused by having - to order libc and libgcc libraries in a specific manner. + to order `libc` and `libgcc` libraries in a specific manner. - psxgpu: Added `RestartCallback()`. @@ -526,7 +537,7 @@ Lameguy64: performance, as the R3000 does not support 64-bit arithmetic natively so its emulated like floats. `int64` still used for processing floats and doubles and old `vsprintf.c` file is still included for those who really - want int64 support for whatever reason. + want `int64` support for whatever reason. - libc: Removed `stdarg.h` which is part of GCC and not license compatible with MPL. The toolchain compiled with libgcc provides `stdarg.h` and other @@ -540,7 +551,7 @@ Lameguy64: - psxgpu: Fixed bug in DMACallback where the internal DMA handler would fail to install due to `GetInterruptCallback()` retrieving the callback value - immediately in the branch delay slot of a jr instruction, which resuls to + immediately in the branch delay slot of a `jr` instruction, which resuls to an inconsistent return value. This also broke `DrawSyncCallback()`. - psxsio: Done fixes on `_sio_control()` from the aformentioned issues with @@ -619,7 +630,7 @@ Lameguy64: ready instead of simply waiting for GPU transfer ready which is the likely cause of subtle GPU related timing issues, it also sets GPU DMA transfer mode to off afterwards. It can also read number of words remaining in DMA - transfer if a0 is non-zero but it likely only returns the correct value on + transfer if `a0` is non-zero but it likely only returns the correct value on VRAM transfers. Exact way how `DrawSync()` returns the count in the official SDK is currently unknown. @@ -645,10 +656,10 @@ Lameguy64: - Added `rgb24` example. - Got custom exit handler set using `SetCustomExitFromException()` (BIOS - function B(19h)) working. Currently used to acknowledge VSync IRQ but + function `B(19h)`) working. Currently used to acknowledge VSync IRQ but actual VSync handling is still done with events and needs to be transferred to the custom exit handler. At least it lets BIOS - controller functions to work now. See doc/dev `notes.txt` for details + controller functions to work now. See `doc/dev notes.txt` for details on how this handler behaves. - Made stack usage in `ResetGraph()` less wasteful. You only need to diff --git a/examples/cdrom/cdxa/main.c b/examples/cdrom/cdxa/main.c index 5f11d8d..284b92f 100644 --- a/examples/cdrom/cdxa/main.c +++ b/examples/cdrom/cdxa/main.c @@ -199,7 +199,7 @@ void xa_callback(int intr, unsigned char *result) if (intr == CdlDataReady) { /* Fetch data sector */ - CdGetSector((u_long*)&xa_sector_buff, 2048); + CdGetSector((u_long*)&xa_sector_buff, 512); /* Quirk: This CdGetSector() implementation must fetch 2048 bytes */ /* or more otherwise the following sectors will be read in an */ diff --git a/examples/io/system573/main.c b/examples/io/system573/main.c index 67a98da..95c3155 100644 --- a/examples/io/system573/main.c +++ b/examples/io/system573/main.c @@ -306,7 +306,7 @@ int main(int argc, const char* argv[]) { FntPrint(-1, " P1 BUTTONS =%07@\n", inputs.p1_btn); FntPrint(-1, " P2 JOYSTICK =%04@\n", inputs.p2_joy); FntPrint(-1, " P2 BUTTONS =%07@\n", inputs.p2_btn); - FntPrint(-1, " COIN/SERVICE=%04@\n", inputs.coin); + FntPrint(-1, " COIN/SERVICE=%04@\n", inputs.coin & 0xf); FntPrint(-1, " DIP SWITCHES=%04@\n", inputs.dip_sw); FntPrint(-1, "\nCABINET LIGHTS:\n"); diff --git a/libpsn00b/psxcd/cdgetsector.s b/libpsn00b/psxcd/cdgetsector.s index 9af3543..dbe95cb 100644 --- a/libpsn00b/psxcd/cdgetsector.s +++ b/libpsn00b/psxcd/cdgetsector.s @@ -18,7 +18,8 @@ CdGetSector: # nop lui $v0, 0x1 - srl $a1, 2 +# srl $a1, 2 # (the official implementation expects $a1/size + # to be in 32-bit words rather than bytes) or $v0, $a1 sw $a0, D3_MADR($a2) # Set DMA base address and transfer length sw $v0, D3_BCR($a2) diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c index 29bbb76..d1c1b18 100644 --- a/libpsn00b/psxcd/isofs.c +++ b/libpsn00b/psxcd/isofs.c @@ -795,7 +795,7 @@ static void _scan_callback(int status, unsigned char *result) { if( status == CdlDataReady ) { - CdGetSector((void*)_ses_scanbuff, 2048); + CdGetSector((void*)_ses_scanbuff, 512); if( _ses_scanbuff[0] == 0x1 ) { diff --git a/libpsn00b/psxcd/psxcd.c b/libpsn00b/psxcd/psxcd.c index 74c6c1c..76415f9 100644 --- a/libpsn00b/psxcd/psxcd.c +++ b/libpsn00b/psxcd/psxcd.c @@ -255,7 +255,7 @@ static void _CdReadReadyCallback(int status, unsigned char *result) CdGetSector((void*)_cd_read_addr, _cd_read_sector_sz); // Increment destination address - _cd_read_addr += _cd_read_sector_sz>>2; + _cd_read_addr += _cd_read_sector_sz; // Subtract sector count _cd_sector_count--; @@ -290,15 +290,15 @@ int CdRead(int sectors, u_long *buf, int mode) // Determine sector based on mode flags if( mode & CdlModeSize0 ) { - _cd_read_sector_sz = 2328; + _cd_read_sector_sz = 2328 / 4; } else if( mode & CdlModeSize1 ) { - _cd_read_sector_sz = 2340; + _cd_read_sector_sz = 2340 / 4; } else { - _cd_read_sector_sz = 2048; + _cd_read_sector_sz = 2048 / 4; } _cd_read_counter = VSync(-1); -- cgit v1.2.3