From 26cf19642c2b7ec0ae4e11ade6b90390811fa3bd Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 30 Jun 2025 18:39:33 +0200 Subject: [PATCH 01/51] initial patch from #1972 --- asminc/cbm510.inc | 2 ++ asminc/cbm610.inc | 2 ++ asminc/pet.inc | 1 + libsrc/c128/crt0.s | 3 +-- libsrc/c128/status.s | 14 ++++++++++++-- libsrc/c16/crt0.s | 4 ++-- libsrc/c64/crt0.s | 4 ++-- libsrc/c64/status.s | 14 ++++++++++++-- libsrc/cbm/getdevice.s | 11 ++++------- libsrc/cbm510/kreadst.s | 4 +--- libsrc/cbm510/ksetnam.s | 7 ++----- libsrc/cbm510/status.s | 21 +++++++++++++++++++++ libsrc/cbm610/crt0.s | 2 +- libsrc/cbm610/kreadst.s | 4 +--- libsrc/cbm610/ksetnam.s | 7 +++---- libsrc/cbm610/status.s | 21 +++++++++++++++++++++ libsrc/pet/checkst.s | 4 ++-- libsrc/pet/crt0.s | 3 +-- libsrc/pet/kreadst.s | 6 ++---- libsrc/pet/status.s | 14 ++++++++++++-- libsrc/plus4/crt0.s | 3 +-- libsrc/plus4/kreadst.s | 3 +-- libsrc/plus4/status.s | 14 ++++++++++++-- libsrc/vic20/crt0.s | 4 ++-- libsrc/vic20/status.s | 14 ++++++++++++-- 25 files changed, 133 insertions(+), 53 deletions(-) create mode 100644 libsrc/cbm510/status.s create mode 100644 libsrc/cbm610/status.s diff --git a/asminc/cbm510.inc b/asminc/cbm510.inc index e1a86c487..627ba4991 100644 --- a/asminc/cbm510.inc +++ b/asminc/cbm510.inc @@ -15,6 +15,8 @@ IndReg := $01 ; Controls indirect indexed load-store bank TXTPTR := $85 ; Far pointer into BASIC source code FNAM := $90 ; Far pointer to LOAD/SAVE file-name +FNAM_SEG := $92 +STATUS := $9C ; Kernal I/O completion status FNAM_LEN := $9D ; Holds length of file-name ; --------------------------------------------------------------------------- diff --git a/asminc/cbm610.inc b/asminc/cbm610.inc index b1b03eb1d..b031b2e9f 100644 --- a/asminc/cbm610.inc +++ b/asminc/cbm610.inc @@ -15,6 +15,8 @@ IndReg := $01 ; Controls indirect indexed load-store bank TXTPTR := $85 ; Far pointer into BASIC source code FNAM := $90 ; Far pointer to LOAD/SAVE file-name +FNAM_SEG := $92 +STATUS := $9C ; Kernal I/O completion status FNAM_LEN := $9D ; Holds length of file-name ; --------------------------------------------------------------------------- diff --git a/asminc/pet.inc b/asminc/pet.inc index ee96d378c..c51010210 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -10,6 +10,7 @@ VARTAB := $2A ; Pointer to start of BASIC variables MEMSIZE := $34 ; Size of memory installed TXTPTR := $77 ; Pointer into BASIC source code TIME := $8D ; 60HZ clock +STATUS := $96 ; IEC status byte KEY_COUNT := $9E ; Number of keys in input buffer RVS := $9F ; Reverse flag CURS_FLAG := $A7 ; 1 = cursor off diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index f6a55778c..d74ca7681 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -9,7 +9,6 @@ .import push0, callmain .import RESTOR, BSOUT, CLRCH .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ - .importzp ST .include "zeropage.inc" .include "c128.inc" @@ -92,7 +91,7 @@ L2: lda zpsave,x ; Place the program return code into BASIC's status variable. pla - sta ST + sta STATUS ; Reset the stack and the memory configuration. diff --git a/libsrc/c128/status.s b/libsrc/c128/status.s index c6f279230..eae91fb4d 100644 --- a/libsrc/c128/status.s +++ b/libsrc/c128/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "c128.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index c203fb20f..01d3766d1 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -10,9 +10,9 @@ .import initlib, donelib .import callmain, zerobss .import MEMTOP, RESTOR, BSOUT, CLRCH - .importzp ST .include "zeropage.inc" + .include "c16.inc" ; ------------------------------------------------------------------------ ; Startup code @@ -76,7 +76,7 @@ L2: lda zpsave,x ; Store the return code into BASIC's status variable. pla - sta ST + sta STATUS ; Restore the stack pointer. diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index dea9226aa..727bbc691 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -10,9 +10,9 @@ .import BSOUT .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; from configure file - .importzp ST .include "zeropage.inc" + .include "c64.inc" ; ------------------------------------------------------------------------ @@ -62,7 +62,7 @@ L2: lda zpsave,x ; Place the program return code into BASIC's status variable. pla - sta ST + sta STATUS ; Restore the system stuff. diff --git a/libsrc/c64/status.s b/libsrc/c64/status.s index c6f279230..79d703489 100644 --- a/libsrc/c64/status.s +++ b/libsrc/c64/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "c64.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc diff --git a/libsrc/cbm/getdevice.s b/libsrc/cbm/getdevice.s index b68e716b4..cb63c8cd0 100644 --- a/libsrc/cbm/getdevice.s +++ b/libsrc/cbm/getdevice.s @@ -10,7 +10,8 @@ .import isdisk .import opencmdchannel .import closecmdchannel - .importzp ST + .import initst + .import READST .importzp tmp2 ;------------------------------------------------------------------------------ @@ -40,8 +41,7 @@ next: inx ; only [in|de]crement the reference count of the shared cmdchannel ; so we need to explicitly initialize ST here - lda #$00 - sta ST + jsr initst stx tmp2 jsr opencmdchannel @@ -49,10 +49,7 @@ next: inx jsr closecmdchannel ldx tmp2 -; As we had to reference ST above anyway we can as well do so -; here too (instead of calling READST) - - lda ST + jsr READST ; Either the Kernal calls above were successful or there was ; already a cmdchannel to the device open - which is a pretty diff --git a/libsrc/cbm510/kreadst.s b/libsrc/cbm510/kreadst.s index 66c0b880f..cb9363d42 100644 --- a/libsrc/cbm510/kreadst.s +++ b/libsrc/cbm510/kreadst.s @@ -16,11 +16,9 @@ jsr sys_bank sty ktmp ; Save Y register - ldy #$9C ; STATUS + ldy #STATUS lda (sysp0),y ; Load STATUS from system bank ldy ktmp jmp restore_bank ; Will set condition codes on A .endproc - - diff --git a/libsrc/cbm510/ksetnam.s b/libsrc/cbm510/ksetnam.s index c338c0de4..e0e488b9e 100644 --- a/libsrc/cbm510/ksetnam.s +++ b/libsrc/cbm510/ksetnam.s @@ -22,7 +22,7 @@ sty ktmp txa - ldy #$90 ; FNAM + ldy #FNAM sta (sysp0),y lda ktmp @@ -33,13 +33,10 @@ ldy #$92 ; FNAM_SEG sta (sysp0),y - ldy #$9D ; FNAM_LEN + ldy #FNAM_LEN pla sta (sysp0),y ldy ktmp jmp restore_bank .endproc - - - diff --git a/libsrc/cbm510/status.s b/libsrc/cbm510/status.s new file mode 100644 index 000000000..a21105710 --- /dev/null +++ b/libsrc/cbm510/status.s @@ -0,0 +1,21 @@ +; +; Stefan Haubenthal, 2023-01-16 +; + + .export initst + + .include "extzp.inc" + .include "cbm510.inc" + +.proc initst + + ldx IndReg + ldy #$0F + sty IndReg ; Switch to the system bank + ldy #STATUS + lda #$00 ; Initialize value + sta (sysp0),y + stx IndReg + rts + +.endproc diff --git a/libsrc/cbm610/crt0.s b/libsrc/cbm610/crt0.s index dc56fa2de..ce47e861a 100644 --- a/libsrc/cbm610/crt0.s +++ b/libsrc/cbm610/crt0.s @@ -394,7 +394,7 @@ _exit: pha ; Save the return code ; Place the program return code into BASIC's status variable. pla - ldy #$9C ; ST + ldy #STATUS sta (sysp0),y ; Set up the welcome code at the stack bottom in the system bank. diff --git a/libsrc/cbm610/kreadst.s b/libsrc/cbm610/kreadst.s index d9bbf7c2d..44dc1ebab 100644 --- a/libsrc/cbm610/kreadst.s +++ b/libsrc/cbm610/kreadst.s @@ -16,11 +16,9 @@ jsr sys_bank sty ktmp ; Save Y register - ldy #$9C ; STATUS + ldy #STATUS lda (sysp0),y ; Load STATUS from system bank ldy ktmp jmp restore_bank ; Will set condition codes on A .endproc - - diff --git a/libsrc/cbm610/ksetnam.s b/libsrc/cbm610/ksetnam.s index 97ecf0126..d3542c83d 100644 --- a/libsrc/cbm610/ksetnam.s +++ b/libsrc/cbm610/ksetnam.s @@ -22,7 +22,7 @@ sty ktmp txa - ldy #$90 ; FNAM + ldy #FNAM sta (sysp0),y lda ktmp @@ -30,14 +30,13 @@ sta (sysp0),y lda ExecReg ; Assume name is always in this segment - ldy #$92 ; FNAM_SEG + ldy #FNAM_SEG sta (sysp0),y - ldy #$9D ; FNAM_LEN + ldy #FNAM_LEN pla sta (sysp0),y ldy ktmp jmp restore_bank .endproc - diff --git a/libsrc/cbm610/status.s b/libsrc/cbm610/status.s new file mode 100644 index 000000000..b8583159e --- /dev/null +++ b/libsrc/cbm610/status.s @@ -0,0 +1,21 @@ +; +; Stefan Haubenthal, 2023-01-16 +; + + .export initst + + .include "extzp.inc" + .include "cbm610.inc" + +.proc initst + + ldx IndReg + ldy #$0F + sty IndReg ; Switch to the system bank + ldy #STATUS + lda #$00 ; Initialize value + sta (sysp0),y + stx IndReg + rts + +.endproc diff --git a/libsrc/pet/checkst.s b/libsrc/pet/checkst.s index 8d9d9a4f3..146a358e2 100644 --- a/libsrc/pet/checkst.s +++ b/libsrc/pet/checkst.s @@ -6,12 +6,12 @@ ; .export checkst - .importzp ST + .include "pet.inc" .proc checkst - lda ST + lda STATUS beq @L1 lda #5 ; ### Device not present sec diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index e3c6ed4b4..3902bf7f2 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -8,7 +8,6 @@ .import zerobss, push0 .import callmain .import CLRCH, BSOUT - .importzp ST .include "zeropage.inc" .include "pet.inc" @@ -80,7 +79,7 @@ L2: lda zpsave,x ; Store the program return code into BASIC's status variable. pla - sta ST + sta STATUS ; Restore the stack pointer. diff --git a/libsrc/pet/kreadst.s b/libsrc/pet/kreadst.s index 38f6bfb19..38e399bae 100644 --- a/libsrc/pet/kreadst.s +++ b/libsrc/pet/kreadst.s @@ -5,14 +5,12 @@ ; .export READST - .importzp ST + .include "pet.inc" .proc READST - lda ST + lda STATUS rts .endproc - - diff --git a/libsrc/pet/status.s b/libsrc/pet/status.s index 2e2e858a0..d7324b93c 100644 --- a/libsrc/pet/status.s +++ b/libsrc/pet/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $96 ; IEC status byte + .export initst + + .include "pet.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index a8a5b8e63..b598022ca 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -10,7 +10,6 @@ .import callmain, zerobss .import __INTERRUPTOR_COUNT__ .import __HIMEM__ ; Linker generated - .importzp ST .include "zeropage.inc" .include "plus4.inc" @@ -121,7 +120,7 @@ L2: lda zpsave,x ; Place the program return code into BASIC's status variable. pla - sta ST + sta STATUS ; Restore the stack pointer. diff --git a/libsrc/plus4/kreadst.s b/libsrc/plus4/kreadst.s index 2571f80f5..f833b8126 100644 --- a/libsrc/plus4/kreadst.s +++ b/libsrc/plus4/kreadst.s @@ -7,12 +7,11 @@ .export READST .include "plus4.inc" - .importzp ST ; Read the status byte from the zero page instead of banking in the ROM .proc READST - lda ST ; Load status + lda STATUS ; Load status rts ; Return to caller .endproc diff --git a/libsrc/plus4/status.s b/libsrc/plus4/status.s index c6f279230..0eceb6ba9 100644 --- a/libsrc/plus4/status.s +++ b/libsrc/plus4/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "plus4.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index 189114f5d..4c8d49ac5 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -10,9 +10,9 @@ .import RESTOR, BSOUT, CLRCH .import __MAIN_START__, __MAIN_SIZE__ ; Linker generated .import __STACKSIZE__ ; Linker generated - .importzp ST .include "zeropage.inc" + .include "vic20.inc" ; ------------------------------------------------------------------------ ; Startup code @@ -72,7 +72,7 @@ L2: lda zpsave,x ; Place the program return code into BASIC's status variable. pla - sta ST + sta STATUS ; Restore the stack pointer. diff --git a/libsrc/vic20/status.s b/libsrc/vic20/status.s index c6f279230..17c015a1f 100644 --- a/libsrc/vic20/status.s +++ b/libsrc/vic20/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "vic20.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc From d91f4f0b822835a5166da1d01e9b5039de7458cb Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 30 Jun 2025 19:10:52 +0200 Subject: [PATCH 02/51] adjust c65/mega65 functions --- libsrc/c65/status.s | 14 ++++++++++++-- libsrc/mega65/status.s | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libsrc/c65/status.s b/libsrc/c65/status.s index c6f279230..dc443a0f2 100644 --- a/libsrc/c65/status.s +++ b/libsrc/c65/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "c65.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc diff --git a/libsrc/mega65/status.s b/libsrc/mega65/status.s index c6f279230..cb6792289 100644 --- a/libsrc/mega65/status.s +++ b/libsrc/mega65/status.s @@ -1,5 +1,15 @@ ; -; Oliver Schmidt, 2012-09-30 +; Stefan Haubenthal, 2023-01-16 ; - .exportzp ST := $90 ; IEC status byte + .export initst + + .include "mega65.inc" + +.proc initst + + lda #$00 + sta STATUS + rts + +.endproc From aa41d51825172639a1ece2732416979a3dd44c6d Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 30 Jun 2025 19:11:13 +0200 Subject: [PATCH 03/51] add enumdevdir to cbm2 samples --- samples/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/Makefile b/samples/Makefile index 3c7c3518a..faa0de906 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -297,6 +297,7 @@ EXELIST_c16 = \ EXELIST_cbm510 = \ ascii \ checkversion \ + enumdevdir \ gunzip65 \ hello \ joydemo \ @@ -308,6 +309,7 @@ EXELIST_cbm510 = \ EXELIST_cbm610 = \ ascii \ checkversion \ + enumdevdir \ gunzip65 \ hello \ terminal \ From 81da8b21071535e1f6837bd92e9a610bfe8463a5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 30 Jun 2025 20:34:59 +0200 Subject: [PATCH 04/51] fix getdevice --- libsrc/cbm/getdevice.s | 13 ++++++++----- libsrc/cbm610/kreadst.s | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libsrc/cbm/getdevice.s b/libsrc/cbm/getdevice.s index cb63c8cd0..25b54fe9d 100644 --- a/libsrc/cbm/getdevice.s +++ b/libsrc/cbm/getdevice.s @@ -34,22 +34,25 @@ next: inx ; interpret a non-disk as a no-op while we need to interpret it ; as an error here - jsr isdisk + jsr isdisk ; carry clear if the unit number in X is a disk bcs next ; [open|close]cmdchannel don't call into the Kernal at all if they ; only [in|de]crement the reference count of the shared cmdchannel ; so we need to explicitly initialize ST here + stx tmp2 ; further calls my use X + jsr initst - stx tmp2 + ldx tmp2 ; get unit number back jsr opencmdchannel - ldx tmp2 + ldx tmp2 ; get unit number back jsr closecmdchannel - ldx tmp2 - jsr READST + ldx tmp2 ; get unit number back + + jsr READST ; preserves X, returns A and Flags ; Either the Kernal calls above were successful or there was ; already a cmdchannel to the device open - which is a pretty diff --git a/libsrc/cbm610/kreadst.s b/libsrc/cbm610/kreadst.s index 44dc1ebab..209f7a842 100644 --- a/libsrc/cbm610/kreadst.s +++ b/libsrc/cbm610/kreadst.s @@ -11,7 +11,7 @@ .include "cbm610.inc" - +; preserves X and Y, returns status in A and in status flags .proc READST jsr sys_bank From 5db0283571264360f32707f09a72ef270639d69c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 2 Jul 2025 22:12:03 +0200 Subject: [PATCH 05/51] CoC draft --- Code_of_Conduct.md | 122 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Code_of_Conduct.md diff --git a/Code_of_Conduct.md b/Code_of_Conduct.md new file mode 100644 index 000000000..6be56d8e3 --- /dev/null +++ b/Code_of_Conduct.md @@ -0,0 +1,122 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +groepaz@gmx.net. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations From a19e00d30404db47463e3e99bc6fa4d66c822592 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 3 Jul 2025 21:49:31 +0200 Subject: [PATCH 06/51] disable the basic interrupt before main(), fixes #2764 --- libsrc/c128/crt0.s | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index f6a55778c..d6853c1bb 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -65,6 +65,15 @@ L1: lda c_sp,x jsr initlib +; Disable the BASIC part of the IRQ handler. It would usually (once per frame) +; copy the VIC shadow register, move sprites, play music. This would only get +; in the way, so we turn it off. + + lda INIT_STATUS + sta initsave + and #$fe + sta INIT_STATUS + ; Set the bank for the file name to our execution bank. We must do this ; *after* calling the constructors because some of them might depend on ; the original value of this register. @@ -89,6 +98,11 @@ L2: lda zpsave,x dex bpl L2 +; Enable the BASIC interrupt again + + lda initsave + sta INIT_STATUS + ; Place the program return code into BASIC's status variable. pla @@ -116,5 +130,6 @@ zpsave: .res zpspace .bss -spsave: .res 1 -mmusave:.res 1 +spsave: .res 1 +mmusave: .res 1 +initsave: .res 1 From fcbc253bf993357d99c1bf98535a9393addd8441 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Thu, 3 Jul 2025 23:43:04 +0200 Subject: [PATCH 07/51] Add strlen and strnlen unit tests --- test/val/lib_common_strlen.c | 22 ++++++++++++++++++++++ test/val/lib_common_strnlen.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/val/lib_common_strlen.c create mode 100644 test/val/lib_common_strnlen.c diff --git a/test/val/lib_common_strlen.c b/test/val/lib_common_strlen.c new file mode 100644 index 000000000..ec79c025a --- /dev/null +++ b/test/val/lib_common_strlen.c @@ -0,0 +1,22 @@ +#include +#include "unittest.h" + +#define SHORT_STR "abcdefghijklmnopqrstuvwxyz" + +#define MID_STR_LEN 700 /* Two pages and something */ +TEST +{ + char *src; + int i; + + /* Long enough for the whole string */ + ASSERT_IsTrue(strlen("") == 0, "strlen(\"\") != 0"); + ASSERT_IsTrue(strlen(SHORT_STR) == 26, "strlen(\""SHORT_STR"\") != 26"); + + src = malloc(MID_STR_LEN+1); + ASSERT_IsTrue(src != NULL, "Could not allocate source string"); + memset(src, 'a', MID_STR_LEN-1); + src[MID_STR_LEN] = '\0'; + ASSERT_IsTrue(strlen(src) == MID_STR_LEN, "strlen(\"700 chars\") != 700"); +} +ENDTEST diff --git a/test/val/lib_common_strnlen.c b/test/val/lib_common_strnlen.c new file mode 100644 index 000000000..892bdffa1 --- /dev/null +++ b/test/val/lib_common_strnlen.c @@ -0,0 +1,29 @@ +#include +#include "unittest.h" + +#define SHORT_STR "abcdefghijklmnopqrstuvwxyz" + +#define MID_STR_LEN 700 /* Two pages and something */ +TEST +{ + char *src; + int i; + + /* Long enough for the whole string */ + ASSERT_IsTrue(strnlen("", 0) == 0, "strnlen(\"\", 0) != 0"); + ASSERT_IsTrue(strnlen("", 10) == 0, "strnlen(\"\", 10) != 0"); + ASSERT_IsTrue(strnlen(SHORT_STR, 0) == 0, "strnlen(\""SHORT_STR"\", 0) != 0"); + ASSERT_IsTrue(strnlen(SHORT_STR, 10) == 10, "strnlen(\""SHORT_STR"\", 10) != 10"); + ASSERT_IsTrue(strnlen(SHORT_STR, 26) == 26, "strnlen(\""SHORT_STR"\", 26) != 26"); + ASSERT_IsTrue(strnlen(SHORT_STR, 50) == 26, "strnlen(\""SHORT_STR"\", 50) != 26"); + + src = malloc(MID_STR_LEN+1); + ASSERT_IsTrue(src != NULL, "Could not allocate source string"); + memset(src, 'a', MID_STR_LEN-1); + src[MID_STR_LEN] = '\0'; + ASSERT_IsTrue(strnlen(src, 0) == 0, "strnlen(src, 0) != 0"); + ASSERT_IsTrue(strnlen(src, 10) == 10, "strnlen(src, 10) != 10"); + ASSERT_IsTrue(strnlen(src, 260) == 260, "strnlen(src, 260) != 260"); + ASSERT_IsTrue(strnlen(src, MID_STR_LEN+1) == MID_STR_LEN, "strnlen(src, MID_STR_LEN+1) != MID_STR_LEN"); +} +ENDTEST From 90e1ac374b51f03b2b58c2cc67cde71c39b693df Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Thu, 3 Jul 2025 23:43:23 +0200 Subject: [PATCH 08/51] Add strndup char* __fastcall__ strndup (const char* S, size_t maxlen); --- doc/funcref.sgml | 31 ++++++++++++++++++ include/string.h | 1 + libsrc/common/strndup.s | 56 ++++++++++++++++++++++++++++++++ test/val/lib_common_strndup.c | 60 +++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 libsrc/common/strndup.s create mode 100644 test/val/lib_common_strndup.c diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 82d5cf8bb..9138e132f 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -785,6 +785,7 @@ communication, see also testcode/lib/ser-test.c. + @@ -5621,6 +5622,7 @@ be used in presence of a prototype. , , + @@ -7774,6 +7776,35 @@ be used in presence of a prototype. , + + + + + + + +strndup