diff --git a/drivers/Makefile b/drivers/Makefile index c2a23aa..cf98c18 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -24,6 +24,7 @@ C64OBJS=\ c64timer.o \ c64kernal.o \ c64input.o \ + c64filteredinput.o \ cbmcharconv.o A2OBJS=\ @@ -32,6 +33,7 @@ A2OBJS=\ a2timer.o \ a2kernal.o \ a2input.o \ + a2filteredinput.o \ a2charconv.o VIC20OBJS=\ @@ -40,6 +42,7 @@ VIC20OBJS=\ vic20timer.o \ vic20kernal.o \ vic20input.o \ + vic20filteredinput.o \ cbmcharconv.o c64rrnet.lib: rr-net.o cs8900a.o $(C64OBJS) diff --git a/drivers/a2filteredinput.s b/drivers/a2filteredinput.s new file mode 100644 index 0000000..9514dc4 --- /dev/null +++ b/drivers/a2filteredinput.s @@ -0,0 +1,167 @@ +.export get_filtered_input +.export filter_text +.export filter_ip +.export filter_dns +.export filter_url +.export filter_number + +.import get_key_ip65 +.import print_a +.import print_hex + +.include "zeropage.inc" +.include "../inc/common.i" + +allowed_ptr = ptr1 + + +.code + +; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input +; ====================================================================== +; Input a string and store it in GOTINPUT, terminated with a null byte. +; AX is a pointer to the allowed list of characters, null-terminated. +; set AX to $0000 for no filter on input +; max # of chars in y returns num of chars entered in y. +; ====================================================================== +; Main entry +get_filtered_input: + sty MAXCHARS + stax temp_allowed + + ; Zero characters received. + lda #$00 + sta INPUT_Y + + ; Wait for a character. +@input_get: + jsr get_key_ip65 + ; convert to standard ASCII by turning off high bit + and #$7f + sta LASTCHAR + + cmp #$08 ; Delete + beq @delete + + cmp #$0d ; Return + beq @input_done + + ; End reached? + lda INPUT_Y + cmp MAXCHARS + beq @input_get + + ; Check the allowed list of characters. + ldax temp_allowed + stax allowed_ptr ; Since we are reusing this zero page, it may not stil be the same value since last time! + + ldy #$00 + lda allowed_ptr+1 ; Was the input filter point nul? + beq @input_ok +@check_allowed: + lda (allowed_ptr),y ; Overwritten + beq @input_get ; Reached end of list (0) + + cmp LASTCHAR + beq @input_ok ; Match found + + ; Not end or match, keep checking + iny + jmp @check_allowed + +@input_ok: + lda LASTCHAR ; Get the char back + ldy INPUT_Y + sta GOTINPUT,y ; Add it to string + + inc INPUT_Y ; Next character + jsr print_a + ; Not yet. + jmp @input_get + +@input_done: + ldy INPUT_Y + beq @no_input + lda #$00 + sta GOTINPUT,y ; Zero-terminate + clc + ldax #GOTINPUT + rts +@no_input: + sec + rts + ; Delete last character. +@delete: + ; First, check if we're at the beginning. If so, just exit. + lda INPUT_Y + bne @delete_ok + jmp @input_get + + ; At least one character entered. +@delete_ok: + ; Move pointer back. + dec INPUT_Y + + ; Store a zero over top of last character, just in case no other characters are entered. + ldy INPUT_Y + lda #$00 + sta GOTINPUT,y + + ; Print the backspace char + lda #$88 + jsr print_a + + ; Print the a space + lda #$a0 + jsr print_a + + ; Print the backspace char + lda #$88 + jsr print_a + + ; Wait for next char + jmp @input_get + +; ================================================= +; Some example filters +; ================================================= +filter_text: + .byte ",!#'()* " +filter_url: + .byte ":/%&?+$" +filter_dns: + .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" +filter_ip: + .byte "." +filter_number: + .byte "1234567890",0 + + +.bss + +temp_allowed: .res 2 +MAXCHARS: .res 1 +LASTCHAR: .res 1 +INPUT_Y: .res 1 +GOTINPUT: .res 40 + + + +; -- LICENSE FOR a2filteredinput.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/drivers/a2input.s b/drivers/a2input.s index 3289754..defb4e3 100644 --- a/drivers/a2input.s +++ b/drivers/a2input.s @@ -1,21 +1,9 @@ .export get_key .export check_for_abort_key -.export get_filtered_input -.export filter_text -.export filter_ip -.export filter_dns -.export filter_number .export get_key_ip65 .export get_key_if_available .import ip65_process -.import print_a -.import print_hex - -.include "zeropage.inc" -.include "../inc/common.i" - -allowed_ptr = ptr1 .code @@ -24,16 +12,12 @@ allowed_ptr = ptr1 ; inputs: none ; outputs: A contains ASCII code of key pressed get_key: -; lda #$a0 -; lda #$20 -; ldy #$24 ; KEYIN assumes Y is loaded with column -; jmp $fd1b jmp $fd0c ; inputs: none ; outputs: A contains ASCII value of key just pressed (0 if no key pressed) get_key_if_available: - bit $c000 ; Key down? + bit $c000 ; key down? bmi get_key lda #0 rts @@ -43,7 +27,7 @@ get_key_if_available: ; outputs: sec if escape pressed, clear otherwise check_for_abort_key: lda $c000 ; current key pressed - cmp #$9B + cmp #$9b bne :+ bit $c010 ; clear the keyboard strobe sec @@ -54,134 +38,10 @@ check_for_abort_key: ; process inbound ip packets while waiting for a keypress get_key_ip65: jsr ip65_process - bit $c000 ; Key down? + bit $c000 ; key down? bpl get_key_ip65 jmp get_key -; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input -; ====================================================================== -; Input a string and store it in GOTINPUT, terminated with a null byte. -; AX is a pointer to the allowed list of characters, null-terminated. -; set AX to $0000 for no filter on input -; max # of chars in y returns num of chars entered in y. -; ====================================================================== -; Main entry -get_filtered_input: - sty MAXCHARS - stax temp_allowed - - ; Zero characters received. - lda #$00 - sta INPUT_Y - -; Wait for a character. -@input_get: - jsr get_key_ip65 - ; convert to standard ASCII by turning off high bit - and #$7f - sta LASTCHAR - cmp #$08 ; Delete - beq @delete - - cmp #$0d ; Return - beq @input_done - - ; End reached? - lda INPUT_Y - cmp MAXCHARS - beq @input_get - - ; Check the allowed list of characters. - ldax temp_allowed - stax allowed_ptr ; Since we are reusing this zero page, it may not stil be the same value since last time! - ldy #$00 - lda allowed_ptr+1 ; Was the input filter point nul? - beq @input_ok -@check_allowed: - lda (allowed_ptr),y ; Overwritten - beq @input_get ; Reached end of list (0) - - cmp LASTCHAR - beq @input_ok ; Match found - - ; Not end or match, keep checking - iny - jmp @check_allowed - -@input_ok: - lda LASTCHAR ; Get the char back - ldy INPUT_Y - sta GOTINPUT,y ; Add it to string - - inc INPUT_Y ; Next character - jsr print_a - ; Not yet. - jmp @input_get - -@input_done: - ldy INPUT_Y - beq @no_input - lda #$00 - sta GOTINPUT,y ; Zero-terminate - clc - ldax #GOTINPUT - rts -@no_input: - sec - rts - ; Delete last character. -@delete: - ; First, check if we're at the beginning. If so, just exit. - lda INPUT_Y - bne @delete_ok - jmp @input_get - - ; At least one character entered. -@delete_ok: - ; Move pointer back. - dec INPUT_Y - - ; Store a zero over top of last character, just in case no other characters are entered. - ldy INPUT_Y - lda #$00 - sta GOTINPUT,y - - ; Print the backspace char - lda #$88 - jsr print_a - - ; Print the a space - lda #$a0 - jsr print_a - - ; Print the backspace char - lda #$88 - jsr print_a - - ; Wait for next char - jmp @input_get - -; ================================================= -; Some example filters -; ================================================= -filter_text: - .byte ",+!#$%&'()* " -filter_dns: - .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" -filter_ip: - .byte "." -filter_number: - .byte "1234567890",0 - - -.bss - -temp_allowed: .res 2 -MAXCHARS: .res 1 -LASTCHAR: .res 1 -INPUT_Y: .res 1 -GOTINPUT: .res 40 - ; -- LICENSE FOR a2input.s -- diff --git a/drivers/c64filteredinput.s b/drivers/c64filteredinput.s new file mode 100644 index 0000000..640796e --- /dev/null +++ b/drivers/c64filteredinput.s @@ -0,0 +1,156 @@ +.export get_filtered_input +.export filter_text +.export filter_ip +.export filter_dns +.export filter_url +.export filter_number + +.import get_key + +.include "zeropage.inc" +.include "../inc/common.i" + +allowed_ptr = ptr1 + + +.code + +; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input +; ====================================================================== +; Input a string and store it in GOTINPUT, terminated with a null byte. +; AX is a pointer to the allowed list of characters, null-terminated. +; set AX to $0000 for no filter on input +; max # of chars in y returns num of chars entered in y. +; ====================================================================== +; Main entry +get_filtered_input: + sty MAXCHARS + stax temp_allowed + + ; Zero characters received. + lda #$00 + sta INPUT_Y + + ; Wait for a character. +@input_get: + jsr get_key + sta LASTCHAR + + cmp #$14 ; Delete + beq @delete + + cmp #$0d ; Return + beq @input_done + + ; End reached? + lda INPUT_Y + cmp MAXCHARS + beq @input_get + + ; Check the allowed list of characters. + ldax temp_allowed + stax allowed_ptr ; Since we are reusing this zero page, it may not stil be the same value since last time! + + ldy #$00 + lda allowed_ptr+1 ; Was the input filter point nul? + beq @input_ok +@check_allowed: + lda (allowed_ptr),y ; Overwritten + beq @input_get ; Reached end of list (0) + + cmp LASTCHAR + beq @input_ok ; Match found + + ; Not end or match, keep checking + iny + jmp @check_allowed + +@input_ok: + lda LASTCHAR ; Get the char back + ldy INPUT_Y + sta GOTINPUT,y ; Add it to string + jsr $ffd2 ; Print it + + inc INPUT_Y ; Next character + + ; Not yet. + jmp @input_get + +@input_done: + ldy INPUT_Y + beq @no_input + lda #$00 + sta GOTINPUT,y ; Zero-terminate + clc + ldax #GOTINPUT + rts +@no_input: + sec + rts + ; Delete last character. +@delete: + ; First, check if we're at the beginning. If so, just exit. + lda INPUT_Y + bne @delete_ok + jmp @input_get + + ; At least one character entered. +@delete_ok: + ; Move pointer back. + dec INPUT_Y + + ; Store a zero over top of last character, just in case no other characters are entered. + ldy INPUT_Y + lda #$00 + sta GOTINPUT,y + + ; Print the delete char + lda #$14 + jsr $ffd2 + + ; Wait for next char + jmp @input_get + +; ================================================= +; Some example filters +; ================================================= +filter_text: + .byte ",!#'()* " +filter_url: + .byte ":/%&?+$" +filter_dns: + .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" +filter_ip: + .byte "." +filter_number: + .byte "1234567890",0 + + +.bss + +temp_allowed: .res 2 +MAXCHARS: .res 1 +LASTCHAR: .res 1 +INPUT_Y: .res 1 +GOTINPUT: .res 40 + + + +; -- LICENSE FOR c64filteredinput.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/drivers/c64input.s b/drivers/c64input.s index 29e1e41..d35484f 100644 --- a/drivers/c64input.s +++ b/drivers/c64input.s @@ -1,21 +1,10 @@ .export get_key -.export get_filtered_input -.export filter_text -.export filter_ip -.export filter_dns -.export filter_url -.export filter_number .export check_for_abort_key .export get_key_if_available .export get_key_ip65 .import ip65_process -.include "zeropage.inc" -.include "../inc/common.i" - -allowed_ptr = ptr1 - .code @@ -58,125 +47,6 @@ check_for_abort_key: clc rts -; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input -; ====================================================================== -; Input a string and store it in GOTINPUT, terminated with a null byte. -; AX is a pointer to the allowed list of characters, null-terminated. -; set AX to $0000 for no filter on input -; max # of chars in y returns num of chars entered in y. -; ====================================================================== -; Main entry -get_filtered_input: - sty MAXCHARS - stax temp_allowed - - ; Zero characters received. - lda #$00 - sta INPUT_Y - -; Wait for a character. -@input_get: - jsr get_key - sta LASTCHAR - - cmp #$14 ; Delete - beq @delete - - cmp #$0d ; Return - beq @input_done - - ; End reached? - lda INPUT_Y - cmp MAXCHARS - beq @input_get - - ; Check the allowed list of characters. - ldax temp_allowed - stax allowed_ptr ; Since we are reusing this zero page, it may not stil be the same value since last time! - - ldy #$00 - lda allowed_ptr+1 ; Was the input filter point nul? - beq @input_ok -@check_allowed: - lda (allowed_ptr),y ; Overwritten - beq @input_get ; Reached end of list (0) - - cmp LASTCHAR - beq @input_ok ; Match found - - ; Not end or match, keep checking - iny - jmp @check_allowed - -@input_ok: - lda LASTCHAR ; Get the char back - ldy INPUT_Y - sta GOTINPUT,y ; Add it to string - jsr $ffd2 ; Print it - - inc INPUT_Y ; Next character - - ; Not yet. - jmp @input_get - -@input_done: - ldy INPUT_Y - beq @no_input - lda #$00 - sta GOTINPUT,y ; Zero-terminate - clc - ldax #GOTINPUT - rts -@no_input: - sec - rts - ; Delete last character. -@delete: - ; First, check if we're at the beginning. If so, just exit. - lda INPUT_Y - bne @delete_ok - jmp @input_get - - ; At least one character entered. -@delete_ok: - ; Move pointer back. - dec INPUT_Y - - ; Store a zero over top of last character, just in case no other characters are entered. - ldy INPUT_Y - lda #$00 - sta GOTINPUT,y - - ; Print the delete char - lda #$14 - jsr $ffd2 - - ; Wait for next char - jmp @input_get - -; ================================================= -; Some example filters -; ================================================= -filter_text: - .byte ",!#'()* " -filter_url: - .byte ":/%&?+$" -filter_dns: - .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" -filter_ip: - .byte "." -filter_number: - .byte "1234567890",0 - - -.bss - -temp_allowed: .res 2 -MAXCHARS: .res 1 -LASTCHAR: .res 1 -INPUT_Y: .res 1 -GOTINPUT: .res 40 - ; -- LICENSE FOR c64input.s -- diff --git a/drivers/vic20filteredinput.s b/drivers/vic20filteredinput.s new file mode 100644 index 0000000..a025477 --- /dev/null +++ b/drivers/vic20filteredinput.s @@ -0,0 +1,156 @@ +.export get_filtered_input +.export filter_text +.export filter_ip +.export filter_dns +.export filter_url +.export filter_number + +.import get_key + +.include "zeropage.inc" +.include "../inc/common.i" + +allowed_ptr = ptr1 + + +.code + +; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input +; ====================================================================== +; Input a string and store it in GOTINPUT, terminated with a null byte. +; AX is a pointer to the allowed list of characters, null-terminated. +; set AX to $0000 for no filter on input +; max # of chars in y returns num of chars entered in y. +; ====================================================================== +; Main entry +get_filtered_input: + sty MAXCHARS + stax temp_allowed + + ; Zero characters received. + lda #$00 + sta INPUT_Y + + ; Wait for a character. +@input_get: + jsr get_key + sta LASTCHAR + + cmp #$14 ; Delete + beq @delete + + cmp #$0d ; Return + beq @input_done + + ; End reached? + lda INPUT_Y + cmp MAXCHARS + beq @input_get + + ; Check the allowed list of characters. + ldax temp_allowed + stax allowed_ptr ; Since we are reusing this zero page, it may not stil be the same value since last time! + + ldy #$00 + lda allowed_ptr+1 ; Was the input filter point nul? + beq @input_ok +@check_allowed: + lda (allowed_ptr),y ; Overwritten + beq @input_get ; Reached end of list (0) + + cmp LASTCHAR + beq @input_ok ; Match found + + ; Not end or match, keep checking + iny + jmp @check_allowed + +@input_ok: + lda LASTCHAR ; Get the char back + ldy INPUT_Y + sta GOTINPUT,y ; Add it to string + jsr $ffd2 ; Print it + + inc INPUT_Y ; Next character + + ; Not yet. + jmp @input_get + +@input_done: + ldy INPUT_Y + beq @no_input + lda #$00 + sta GOTINPUT,y ; Zero-terminate + clc + ldax #GOTINPUT + rts +@no_input: + sec + rts + ; Delete last character. +@delete: + ; First, check if we're at the beginning. If so, just exit. + lda INPUT_Y + bne @delete_ok + jmp @input_get + + ; At least one character entered. +@delete_ok: + ; Move pointer back. + dec INPUT_Y + + ; Store a zero over top of last character, just in case no other characters are entered. + ldy INPUT_Y + lda #$00 + sta GOTINPUT,y + + ; Print the delete char + lda #$14 + jsr $ffd2 + + ; Wait for next char + jmp @input_get + +; ================================================= +; Some example filters +; ================================================= +filter_text: + .byte ",!#'()* " +filter_url: + .byte ":/%&?+$" +filter_dns: + .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" +filter_ip: + .byte "." +filter_number: + .byte "1234567890",0 + + +.bss + +temp_allowed: .res 2 +MAXCHARS: .res 1 +LASTCHAR: .res 1 +INPUT_Y: .res 1 +GOTINPUT: .res 40 + + + +; -- LICENSE FOR vic20filteredinput.s -- +; The contents of this file are subject to the Mozilla Public License +; Version 1.1 (the "License"); you may not use this file except in +; compliance with the License. You may obtain a copy of the License at +; http://www.mozilla.org/MPL/ +; +; Software distributed under the License is distributed on an "AS IS" +; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +; License for the specific language governing rights and limitations +; under the License. +; +; The Original Code is ip65. +; +; The Initial Developer of the Original Code is Jonno Downes, +; jonno@jamtronix.com. +; Portions created by the Initial Developer are Copyright (C) 2009 +; Jonno Downes. All Rights Reserved. +; -- LICENSE END -- diff --git a/drivers/vic20input.s b/drivers/vic20input.s index aa57d4e..b11eea3 100644 --- a/drivers/vic20input.s +++ b/drivers/vic20input.s @@ -1,21 +1,10 @@ .export get_key -.export get_filtered_input -.export filter_text -.export filter_ip -.export filter_dns -.export filter_url -.export filter_number .export check_for_abort_key .export get_key_if_available .export get_key_ip65 .import ip65_process -.include "zeropage.inc" -.include "../inc/common.i" - -allowed_ptr = ptr1 - .code @@ -58,127 +47,9 @@ check_for_abort_key: clc rts -; cribbed from http://codebase64.org/doku.php?id=base:robust_string_input -; ====================================================================== -; Input a string and store it in GOTINPUT, terminated with a null byte. -; AX is a pointer to the allowed list of characters, null-terminated. -; set AX to $0000 for no filter on input -; max # of chars in y returns num of chars entered in y. -; ====================================================================== -; Main entry -get_filtered_input: - sty MAXCHARS - stax temp_allowed - - ; Zero characters received. - lda #$00 - sta INPUT_Y - - ; Wait for a character. -@input_get: - jsr get_key - sta LASTCHAR - - cmp #$14 ; Delete - beq @delete - - cmp #$0d ; Return - beq @input_done - - ; End reached? - lda INPUT_Y - cmp MAXCHARS - beq @input_get - - ; Check the allowed list of characters. - ldax temp_allowed - stax allowed_ptr ; since we are reusing this zero page, it may not stil be the same value since last time! - - ldy #$00 - lda allowed_ptr+1 ; was the input filter point nul? - beq @input_ok -@check_allowed: - lda (allowed_ptr),y ; Overwritten - beq @input_get ; Reached end of list (0) - - cmp LASTCHAR - beq @input_ok ; Match found - - ; Not end or match, keep checking - iny - jmp @check_allowed - -@input_ok: - lda LASTCHAR ; Get the char back - ldy INPUT_Y - sta GOTINPUT,y ; Add it to string - jsr $ffd2 ; Print it - - inc INPUT_Y ; Next character - - ; Not yet. - jmp @input_get - -@input_done: - ldy INPUT_Y - beq @no_input - lda #$00 - sta GOTINPUT,y ; Zero-terminate - clc - ldax #GOTINPUT - rts -@no_input: - sec - rts - ; Delete last character. -@delete: - ; First, check if we're at the beginning. If so, just exit. - lda INPUT_Y - bne @delete_ok - jmp @input_get - - ; At least one character entered. -@delete_ok: - ; Move pointer back. - dec INPUT_Y - - ; Store a zero over top of last character, just in case no other characters are entered. - ldy INPUT_Y - lda #$00 - sta GOTINPUT,y - - ; Print the delete char - lda #$14 - jsr $ffd2 - - ; Wait for next char - jmp @input_get - -; ================================================= -; Some example filters -; ================================================= -filter_text: - .byte ",!#'()* " -filter_url: - .byte ":/%&?+$" -filter_dns: - .byte "-ABCDEFGHIJKLMNOPQRSTUVWXYZ" -filter_ip: - .byte "." -filter_number: - .byte "1234567890",0 - - -.bss - -temp_allowed: .res 2 -MAXCHARS: .res 1 -LASTCHAR: .res 1 -INPUT_Y: .res 1 -GOTINPUT: .res 40 - +; -- LICENSE FOR vic20input.s -- ; The contents of this file are subject to the Mozilla Public License ; Version 1.1 (the "License"); you may not use this file except in ; compliance with the License. You may obtain a copy of the License at