Compare commits
No commits in common. "64492a5f6b8b2ab1ac6442aae7219f24291ff08a" and "5c02ff65858dc5d348c666e9731b34d77f40dc99" have entirely different histories.
64492a5f6b
...
5c02ff6585
@ -111,8 +111,10 @@ set:
|
|||||||
bit previous_scancode
|
bit previous_scancode
|
||||||
jmi break_key ; bit 7 set = BREAK
|
jmi break_key ; bit 7 set = BREAK
|
||||||
|
|
||||||
cpx #$60 ; codes >= 60 in separate table to reduce memory consumption
|
cmp #$90 ; only BREAK is higher than 8F, (also code table only has 8F bytes)
|
||||||
bcs x_ge_60
|
bcs check_release
|
||||||
|
cmp #$60 ; codes >= 60 in separate table to reduce memory consumption
|
||||||
|
bcs upper_range
|
||||||
bbs kb::MOD::SHIFT, modifier, modshift ; if shift active
|
bbs kb::MOD::SHIFT, modifier, modshift ; if shift active
|
||||||
bbs kb::MOD::RALT, modifier, modralt ; if ralt active
|
bbs kb::MOD::RALT, modifier, modralt ; if ralt active
|
||||||
|
|
||||||
@ -120,11 +122,19 @@ set:
|
|||||||
nomod:
|
nomod:
|
||||||
lda CHARS_NOMOD,x
|
lda CHARS_NOMOD,x
|
||||||
bra check_char
|
bra check_char
|
||||||
modralt:
|
upper_range:
|
||||||
lda CHARS_MODRALT,x
|
bbs kb::MOD::NUMLOCK, modifier, modnumlock ; if numlock active
|
||||||
|
; numlock off
|
||||||
|
lda CHARS_NUMLOCK_OFF,x
|
||||||
|
bra check_char
|
||||||
|
modnumlock:
|
||||||
|
lda CHARS_NUMLOCK_ON,x
|
||||||
bra check_char
|
bra check_char
|
||||||
modshift:
|
modshift:
|
||||||
lda CHARS_MODSHIFT,x
|
lda CHARS_MODSHIFT,x
|
||||||
|
bra check_char
|
||||||
|
modralt:
|
||||||
|
lda CHARS_MODRALT,x
|
||||||
check_char:
|
check_char:
|
||||||
beq not_mod ; 0 => not mod and not char
|
beq not_mod ; 0 => not mod and not char
|
||||||
cmp #1 ; 1 => mod
|
cmp #1 ; 1 => mod
|
||||||
@ -136,19 +146,8 @@ not_mod: ; store keycode if not mod
|
|||||||
_rts:
|
_rts:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
x_ge_60: ; x >= $60
|
check_release:
|
||||||
cpx #$90 ; only BREAK is higher than 8F, (also code table only has 8F bytes)
|
cmp #kb::K_BREAK
|
||||||
bcs check_release
|
|
||||||
; CHARS_NUMLOCK_OFF - CHARS_NOMOD = 60 -> no need to subtract $60 first
|
|
||||||
; CHARS_NUMLOCK_ON - CHARS_MODSHIFT = 60 -> no need to subtract $60 first
|
|
||||||
bbs kb::MOD::NUMLOCK, modifier, modshift ; if numlock active
|
|
||||||
lda CHARS_NOMOD,x
|
|
||||||
bra check_char
|
|
||||||
check_release: ; x >= $90
|
|
||||||
; DEBUG
|
|
||||||
lda #'9'
|
|
||||||
sta char
|
|
||||||
cpx #kb::K_BREAK
|
|
||||||
bne _rts
|
bne _rts
|
||||||
lda #$ff
|
lda #$ff
|
||||||
sta previous_scancode
|
sta previous_scancode
|
||||||
@ -235,9 +234,6 @@ update_leds:
|
|||||||
.proc break_key
|
.proc break_key
|
||||||
; rmb kb::PREVIOUS::BREAK, kb::previous_scancode
|
; rmb kb::PREVIOUS::BREAK, kb::previous_scancode
|
||||||
stz previous_scancode
|
stz previous_scancode
|
||||||
; DEBUG
|
|
||||||
lda #'F'
|
|
||||||
sta char
|
|
||||||
|
|
||||||
; check mod keys
|
; check mod keys
|
||||||
cpx #kb::K::LEFTSHIFT
|
cpx #kb::K::LEFTSHIFT
|
||||||
@ -256,12 +252,12 @@ update_leds:
|
|||||||
beq unset_ctrl
|
beq unset_ctrl
|
||||||
cpx #kb::K::LEFTCTRL
|
cpx #kb::K::LEFTCTRL
|
||||||
rts
|
rts
|
||||||
unset_shift: ; process shift
|
unset_shift: ; process shift
|
||||||
bbs kb::MOD::CAPSLOCK, modifier, @set_shift ; set shift when capslock is on
|
bbs kb::MOD::CAPSLOCK, modifier, @set_shift ; set shift when capslock is on
|
||||||
rmb kb::MOD::SHIFT, modifier ; unset if capslock is off
|
rmb kb::MOD::SHIFT, modifier ; unset if capslock is off
|
||||||
rts
|
rts
|
||||||
@set_shift:
|
@set_shift:
|
||||||
smb kb::MOD::SHIFT, modifier
|
smb kb::MOD::SHIFT, modifier
|
||||||
rts
|
rts
|
||||||
unset_ctrl:
|
unset_ctrl:
|
||||||
rmb kb::MOD::CTRL, modifier
|
rmb kb::MOD::CTRL, modifier
|
||||||
@ -286,10 +282,6 @@ CHARS_NOMOD:
|
|||||||
.byte "\x00nbhgz6\x00\x00\x01mju78\x00"
|
.byte "\x00nbhgz6\x00\x00\x01mju78\x00"
|
||||||
.byte "\x00,kio09\x00\x00.-l\xEFp\xE2\x00"
|
.byte "\x00,kio09\x00\x00.-l\xEFp\xE2\x00"
|
||||||
.byte "\x00\x00\xE1#\xF5`\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
.byte "\x00\x00\xE1#\xF5`\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
||||||
CHARS_NUMLOCK_OFF:
|
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x01/\x00\x00\x00\x00+\x00*\x00"
|
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00-\x00"
|
|
||||||
CHARS_MODSHIFT:
|
CHARS_MODSHIFT:
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xDF\x00"
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xDF\x00"
|
||||||
.byte "\x00\x01\x01>\x01Q!\x00\x00\x01YSAW\"\x00"
|
.byte "\x00\x01\x01>\x01Q!\x00\x00\x01YSAW\"\x00"
|
||||||
@ -297,10 +289,6 @@ CHARS_MODSHIFT:
|
|||||||
.byte "\x00NBHGZ&\x00\x00\x01MJU/(\x00"
|
.byte "\x00NBHGZ&\x00\x00\x01MJU/(\x00"
|
||||||
.byte "\x00;KIO=)\x00\x00:_L\xEFP\xE2\x00"
|
.byte "\x00;KIO=)\x00\x00:_L\xEFP\xE2\x00"
|
||||||
.byte "\x00\x00\xE1'\xF5`\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
.byte "\x00\x00\xE1'\xF5`\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
||||||
CHARS_NUMLOCK_ON:
|
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x001\x0047\x00\x00\x00"
|
|
||||||
.byte "0.2568\x01\x00\x00\x003\x00\x009\x00\x00"
|
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00"
|
|
||||||
CHARS_MODRALT:
|
CHARS_MODRALT:
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00"
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00"
|
||||||
.byte "\x00\x01\x01|\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
|
.byte "\x00\x01\x01|\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
|
||||||
@ -308,3 +296,11 @@ CHARS_MODRALT:
|
|||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00{[\x00"
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00{[\x00"
|
||||||
.byte "\x00\x00\x00\x00\x00}]\x00\x00\xA5\xB0\x00\x00\x00\x00\x00"
|
.byte "\x00\x00\x00\x00\x00}]\x00\x00\xA5\xB0\x00\x00\x00\x00\x00"
|
||||||
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x01"
|
||||||
|
CHARS_NUMLOCK_OFF:
|
||||||
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
.byte "\x00\x00\x00\x00\x00\x00\x01/\x00\x00\x00\x00+\x00*\x00"
|
||||||
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00-\x00"
|
||||||
|
CHARS_NUMLOCK_ON:
|
||||||
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x001\x0047\x00\x00\x00"
|
||||||
|
.byte "0.2568\x01\x00\x00\x003\x00\x009\x00\x00"
|
||||||
|
.byte "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00"
|
||||||
|
@ -99,13 +99,6 @@ CODE_START:
|
|||||||
|
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
wai
|
|
||||||
; put shift, ralt and lalt in debug leds
|
|
||||||
lda kb::modifier
|
|
||||||
Reverse A
|
|
||||||
and #%00000111
|
|
||||||
ora IO1 + IO::RANH
|
|
||||||
sta IO1 + IO::RANH
|
|
||||||
lda kb::char
|
lda kb::char
|
||||||
beq @no_char
|
beq @no_char
|
||||||
stz kb::char
|
stz kb::char
|
||||||
|
@ -35,14 +35,12 @@ Import ps2kb, send_command, send_cmd, send_data, cmd_response, response_length,
|
|||||||
|
|
||||||
VIA = IO1
|
VIA = IO1
|
||||||
; Enough time must pass for 3 bits to be shifted in.
|
; Enough time must pass for 3 bits to be shifted in.
|
||||||
; TIMER_RECV = 230 ; 230 ms (@1MHz)
|
TIMER_RECV = 230 ; 230 ms (@1MHz)
|
||||||
TIMER_RECV = 400 ; 230 ms (@1MHz)
|
|
||||||
; Enough time must pass for one bit must be shifted out (parity),
|
; Enough time must pass for one bit must be shifted out (parity),
|
||||||
; but at most two (parity+stop).
|
; but at most two (parity+stop).
|
||||||
; After that, the interrupt must have happened because the keyboard will pull data low.
|
; After that, the interrupt must have happened because the keyboard will pull data low.
|
||||||
; At that point, the SR needs to be set to input again
|
; At that point, the SR needs to be set to input again
|
||||||
; TIMER_SEND = 230 ; 180 ms (@1MHz)
|
TIMER_SEND = 230 ; 180 ms (@1MHz)
|
||||||
TIMER_SEND = 400 ; 180 ms (@1MHz)
|
|
||||||
|
|
||||||
PULL_REG = IO::RANH
|
PULL_REG = IO::RANH
|
||||||
PULL_DDR = IO::DDRA
|
PULL_DDR = IO::DDRA
|
||||||
|
47
test.s65
47
test.s65
@ -1,26 +1,23 @@
|
|||||||
.include "other/file.h65"
|
.include "system/system.h65"
|
||||||
|
.include "system/lcd.h65"
|
||||||
|
|
||||||
.zeropage
|
.segment "TEST"
|
||||||
var1: .res 1
|
.macro MaskedWrite2 addr,value,mask
|
||||||
char: .res 1
|
lda #value
|
||||||
|
eor addr
|
||||||
.code
|
and #mask
|
||||||
.proc my_subroutine
|
eor addr
|
||||||
pha
|
sta addr
|
||||||
bbr4 var1,@bit_4_set
|
.endmacro
|
||||||
bit var1
|
.import __SPI_SIZE__
|
||||||
; macro packs are supported
|
label:
|
||||||
jmi other_routine
|
; JsrIndirect $2022
|
||||||
lda #'a'
|
; .byte 0,1,2,3,4
|
||||||
sta char
|
; JsrIndirect {($2022,x)}, label
|
||||||
bra @end
|
; .byte 5,6,7,8,9
|
||||||
@bit_4_set:
|
; MaskedWrite2 lcd::LCD_IO+IO::DDRA, (lcd::RS | lcd::RW | lcd::E), lcd::RA_MASK
|
||||||
; custom macros can be highlighted
|
; lda #(lcd::RS | lcd::RW | lcd::E) ; RA 5-7 output
|
||||||
Printf STR_FMT,char,var1
|
; sta lcd::LCD_IO+IO::DDRA
|
||||||
@end:
|
.word __SPI_SIZE__
|
||||||
pla
|
.byte >__SPI_SIZE__
|
||||||
rts
|
.byte <__SPI_SIZE__
|
||||||
.endproc
|
|
||||||
|
|
||||||
.rodata
|
|
||||||
STR_FMT: .asciiz "%c: num=%x"
|
|
||||||
|
@ -79,9 +79,7 @@ INCLUDE_UTILITY = 1
|
|||||||
;; @TODO optimize when immediate is used
|
;; @TODO optimize when immediate is used
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.macro MaskedWrite addr,value,mask
|
.macro MaskedWrite addr,value,mask
|
||||||
.if .not .match(value, A)
|
|
||||||
lda value
|
lda value
|
||||||
.endif
|
|
||||||
eor addr
|
eor addr
|
||||||
and mask
|
and mask
|
||||||
eor addr
|
eor addr
|
||||||
|
Loading…
Reference in New Issue
Block a user