From 58b73a2842745dc4dc96166e35b948821ec75df8 Mon Sep 17 00:00:00 2001 From: Greg King Date: Thu, 21 Aug 2014 10:46:25 -0400 Subject: [PATCH 1/3] Disable the Atmos keyboard's CAPS LOCK for both conio and stdio. --- libsrc/atmos/cgetc.s | 22 +++++++++------------- libsrc/atmos/crt0.s | 37 ++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index e13d143d2..0c6fb4c7a 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -1,6 +1,6 @@ ; ; 2003-04-13, Ullrich von Bassewitz -; 2013-07-26, Greg King +; 2014-08-21, Greg King ; ; char cgetc (void); ; @@ -22,11 +22,11 @@ ; No character, enable cursor and wait - lda cursor ; Cursor currently off? + lda cursor ; Should cursor be off? beq @L1 ; Skip if so - lda STATUS - ora #%00000001 ; Cursor ON - sta STATUS + lsr STATUS + sec ; Cursor ON + rol STATUS @L1: lda KEYBUF bpl @L1 @@ -34,13 +34,13 @@ ldx cursor beq @L2 - ldx #$00 ; Zero high byte dec STATUS ; Clear bit zero ; We have the character, clear avail flag @L2: and #$7F ; Mask out avail flag sta KEYBUF + ldx #>0 ldy MODEKEY cpy #FUNCTKEY bne @L3 @@ -53,16 +53,12 @@ .endproc ; ------------------------------------------------------------------------ -; Switch the cursor off, disable capslock. Code goes into the INIT segment +; Switch the cursor off. Code goes into the INIT segment ; which may be reused after it is run. .segment "INIT" initcgetc: - lda STATUS - and #%11111110 - sta STATUS - lda #$7F - sta CAPSLOCK + lsr STATUS + asl STATUS ; Clear bit zero rts - diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index 1588cbec0..2c7e9dc41 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -2,6 +2,7 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme and Ullrich von Bassewitz +; 2014-08-15, Greg King ; .export _exit @@ -39,26 +40,33 @@ .segment "STARTUP" -; Save the zero page area we're about to use +; Save the zero-page area we're about to use. ldx #zpspace-1 L1: lda sp,x - sta zpsave,x ; Save the zero page locations we need + sta zpsave,x dex bpl L1 -; Clear the BSS data +; Clear the BSS data. jsr zerobss -; Unprotect columns 0 and 1 +; Turn capitals lock off. + + lda CAPSLOCK + sta capsave + lda #$7F + sta CAPSLOCK + +; Unprotect screen columns 0 and 1. lda STATUS sta stsave and #%11011111 sta STATUS -; Save system stuff and setup the stack +; Save system stuff; and, set up the stack. tsx stx spsave ; Save system stk ptr @@ -68,26 +76,31 @@ L1: lda sp,x lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) sta sp+1 ; Set argument stack ptr -; Call module constructors +; Call module constructors. jsr initlib -; Push arguments and call main() +; Push arguments; and, call main(). jsr callmain -; Call module destructors. This is also the _exit entry. +; Call module destructors. This is also the exit() entry. _exit: jsr donelib ; Run module destructors -; Restore system stuff +; Restore system stuff. ldx spsave txs lda stsave sta STATUS -; Copy back the zero page stuff +; Restore capitals lock. + + lda capsave + sta CAPSLOCK + +; Copy back the zero-page stuff. ldx #zpspace-1 L2: lda zpsave,x @@ -95,7 +108,7 @@ L2: lda zpsave,x dex bpl L2 -; Back to BASIC +; Back to BASIC. rts @@ -111,3 +124,5 @@ zpsave: .res zpspace spsave: .res 1 stsave: .res 1 +capsave: + .res 1 From 145a010e59030cf6436b0db7edf2dfddb3815f8a Mon Sep 17 00:00:00 2001 From: Greg King Date: Fri, 22 Aug 2014 17:19:58 -0400 Subject: [PATCH 2/3] Moved the CAPS LOCK code out of the startup file, and into its own file. --- libsrc/atmos/capslock.s | 47 +++++++++++++++++++++++++++++++++++++++++ libsrc/atmos/cgetc.s | 4 +++- libsrc/atmos/crt0.s | 28 ++++++------------------ libsrc/atmos/read.s | 3 ++- 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 libsrc/atmos/capslock.s diff --git a/libsrc/atmos/capslock.s b/libsrc/atmos/capslock.s new file mode 100644 index 000000000..6811862c6 --- /dev/null +++ b/libsrc/atmos/capslock.s @@ -0,0 +1,47 @@ +; +; When Oric computers are in BASIC's command mode, the keyboard is in CAPS lock +; mode (because Oric BASIC keywords must be typed in upper-case). This +; constructor disables that mode, so that text will be typed as lower-case +; (which is the default on other cc65 platforms). +; This module is linked by the conio and POSIX input functions. +; +; 2014-08-22, Greg King +; + + .destructor restore_caps + .constructor disable_caps + + .include "atmos.inc" + + +;-------------------------------------------------------------------------- + +; Restore the old capitals-lock state. + +restore_caps: + lda capsave + sta CAPSLOCK + rts + + +;-------------------------------------------------------------------------- +; Put this constructor into a segment that can be re-used by programs. +; +.segment "INIT" + +; Turn the capitals lock off. + +disable_caps: + lda CAPSLOCK + sta capsave + lda #$7F + sta CAPSLOCK + rts + + +;-------------------------------------------------------------------------- + +.bss + +capsave: + .res 1 diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index 0c6fb4c7a..dab92f882 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -1,13 +1,15 @@ ; ; 2003-04-13, Ullrich von Bassewitz -; 2014-08-21, Greg King +; 2014-08-22, Greg King ; ; char cgetc (void); ; .export _cgetc .constructor initcgetc + .import cursor + .forceimport disable_caps .include "atmos.inc" diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index 2c7e9dc41..1d919f348 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -2,7 +2,7 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme and Ullrich von Bassewitz -; 2014-08-15, Greg King +; 2014-08-22, Greg King ; .export _exit @@ -40,7 +40,7 @@ .segment "STARTUP" -; Save the zero-page area we're about to use. +; Save the zero-page area that we're about to use. ldx #zpspace-1 L1: lda sp,x @@ -52,13 +52,6 @@ L1: lda sp,x jsr zerobss -; Turn capitals lock off. - - lda CAPSLOCK - sta capsave - lda #$7F - sta CAPSLOCK - ; Unprotect screen columns 0 and 1. lda STATUS @@ -66,7 +59,7 @@ L1: lda sp,x and #%11011111 sta STATUS -; Save system stuff; and, set up the stack. +; Save some system stuff; and, set up the stack. tsx stx spsave ; Save system stk ptr @@ -76,30 +69,25 @@ L1: lda sp,x lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) sta sp+1 ; Set argument stack ptr -; Call module constructors. +; Call the module constructors. jsr initlib -; Push arguments; and, call main(). +; Push the command-line arguments; and, call main(). jsr callmain -; Call module destructors. This is also the exit() entry. +; Call the module destructors. This is also the exit() entry. _exit: jsr donelib ; Run module destructors -; Restore system stuff. +; Restore the system stuff. ldx spsave txs lda stsave sta STATUS -; Restore capitals lock. - - lda capsave - sta CAPSLOCK - ; Copy back the zero-page stuff. ldx #zpspace-1 @@ -124,5 +112,3 @@ zpsave: .res zpspace spsave: .res 1 stsave: .res 1 -capsave: - .res 1 diff --git a/libsrc/atmos/read.s b/libsrc/atmos/read.s index 443808fa8..324ac789e 100644 --- a/libsrc/atmos/read.s +++ b/libsrc/atmos/read.s @@ -1,5 +1,5 @@ ; -; 2013-12-24, Greg King +; 2014-08-22, Greg King ; ; int read (int fd, void* buf, unsigned count); ; @@ -11,6 +11,7 @@ .import popax .importzp ptr1, ptr2, ptr3 + .forceimport disable_caps .macpack generic .include "atmos.inc" From 970af0cdb2f058f8e6a4fc7e82e0137d52fe6a5a Mon Sep 17 00:00:00 2001 From: Greg King Date: Thu, 4 Sep 2014 17:37:41 -0400 Subject: [PATCH 3/3] Swapped the locations of a constructor and a destructor in a source file. The constructor now is first. Used a more expressive literal zero. --- libsrc/atmos/capslock.s | 26 ++++++++++++++------------ libsrc/atmos/cgetc.s | 8 ++++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libsrc/atmos/capslock.s b/libsrc/atmos/capslock.s index 6811862c6..0ed6e70da 100644 --- a/libsrc/atmos/capslock.s +++ b/libsrc/atmos/capslock.s @@ -5,25 +5,15 @@ ; (which is the default on other cc65 platforms). ; This module is linked by the conio and POSIX input functions. ; -; 2014-08-22, Greg King +; 2014-09-04, Greg King ; - .destructor restore_caps .constructor disable_caps + .destructor restore_caps .include "atmos.inc" -;-------------------------------------------------------------------------- - -; Restore the old capitals-lock state. - -restore_caps: - lda capsave - sta CAPSLOCK - rts - - ;-------------------------------------------------------------------------- ; Put this constructor into a segment that can be re-used by programs. ; @@ -39,6 +29,18 @@ disable_caps: rts +;-------------------------------------------------------------------------- + +.code + +; Restore the old capitals-lock state. + +restore_caps: + lda capsave + sta CAPSLOCK + rts + + ;-------------------------------------------------------------------------- .bss diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index dab92f882..e4ea15ac6 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -1,6 +1,6 @@ ; ; 2003-04-13, Ullrich von Bassewitz -; 2014-08-22, Greg King +; 2014-09-04, Greg King ; ; char cgetc (void); ; @@ -38,15 +38,15 @@ beq @L2 dec STATUS ; Clear bit zero -; We have the character, clear avail flag +; We have the character, clear the "available" flag @L2: and #$7F ; Mask out avail flag sta KEYBUF - ldx #>0 + ldx #>$0000 ldy MODEKEY cpy #FUNCTKEY bne @L3 - ora #$80 ; FUNCT pressed + ora #$80 ; FUNCT-key pressed ; Done