Merge pull request #61 from FeralChild64/master

New keyboard handler for MEGA65
This commit is contained in:
FeralChild64 authored and GitHub committed 2020-12-06 16:32:13 +01:00
commit c33f4af079
110 files changed
+1363 -1147

No files matched your search

+1 -17
View File
@@ -197,12 +197,6 @@ Each of them needs a couple of bytes in KERNAL segment - but they can share some
Original keyboard support routine is just horrible. It does nothing to prevent ghosting - press A+S+D at the same time - it prints F. Try to use joystick connected to control port 1 - it outputs phantom characters. The Open ROMs provides much more sophisticated routines to prevent such problems.
### `LEGACY_SCNKEY`
Uses old Open ROMs keyboard scanning routine, which is basically the example routine by TWW/CTR, hacked to work within Kernal. It's greatest advantage is multi-key rollover, it's disadvantages - it's much less compatible (uses several bytes of memory which are normally free for user software - thus, it is considered legacy for now), does not support all the system variables (`RPTFLG` and `KEYLOG` are unsupported), and ignores the configuration options - this can be changed, but it requires some effort.
Needs 30-250 more space in KERNAL segment (depending on the features enabled for current default routine). If unsure - disable.
### `KEYBOARD_C128`
Allows to use additional keys found on the C128 keyboard.
@@ -215,10 +209,6 @@ Allows to use CAPS LOCK key on the C128 keyboard, this is independent from `KEYB
Needs about 50 bytes more space in KERNAL segment. If unsure - disable.
### `KEYBOARD_C65`, `KEYBOARD_C65_CAPS_LOCK`
Similar, but for C65 keyboard. Please note - the C65 keyboard support is (as of yet) completely untested!
### `KEY_REPEAT_DEFAULT`
Enables key repetition by default during the startup (sets `RPTFLG`).
@@ -239,7 +229,7 @@ Needs 13 bytes more space in KERNAL segment. Only disable if you are running out
### `JOY1_CURSOR` and `JOY2_CURSOR`
Joystick movement also moves the cursor.
Use joystick to move the cursor. On MEGA65 applies to legacy mode only (on native mode there is BASIC command available to set this option in runtime).
Needs about 65 bytes of ROM space in KERNAL segment to handle both joysticks.
@@ -257,12 +247,6 @@ If enabled, STOP key terminates insert/quote mode (like on some _Black Box_ cart
Feature needs 12 bytes in KERNAL segment. If unsure - enable.
### `EDIT_TABULATORS`
If enabled, allows use of TAB (or CTRL+>) and SHIFT+TAB (or CTRL+<) to switch between predefined tabulator positions.
Feature needs 35-45 bytes in KERNAL segment. If unsure - enable.
## Software features
### `PANIC_SCREEN`
+1
View File
@@ -9,6 +9,7 @@
* enthusi/Onslaught - for his example Turbo Tape 64 compatible loader
* djmips - for fast 8x8 multiplication routine
* Verz - for the integer division routine
* Mike Barry - for his PRIMM implementation
## for documentation
+13 -4
View File
@@ -47,14 +47,15 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \
src/kernal/board_m65 \
src/kernal/board_u64 \
src/kernal/board_x16 \
src/kernal/extapi_m65 \
src/kernal/iec \
src/kernal/iec_fast \
src/kernal/init \
src/kernal/interrupts \
src/kernal/iostack \
src/kernal/jumptable \
src/kernal/jumptable_m65 \
src/kernal/keyboard \
src/kernal/keyboard_m65 \
src/kernal/memory \
src/kernal/print \
src/kernal/rom_revision \
@@ -202,6 +203,7 @@ SEG_LIST_M65 = $(DIR_M65)/basic.seg_0 \
$(DIR_M65)/basic.seg_1 \
$(DIR_M65)/dos.seg_1 \
$(DIR_M65)/kernal.seg_0 \
$(DIR_M65)/kernal.seg_C \
$(DIR_M65)/kernal.seg_1
SEG_LIST_X16 = $(DIR_X16)/basic.seg_0 \
@@ -355,6 +357,8 @@ $(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1_combined.vs $(DIR_M65)/BASIC_1_combi
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_M65) $(GEN_STR_M65) $(DIR_M65)/KERNAL_0_combined.sym $(DIR_M65)/BASIC_0_combined.sym
$(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1_combined.vs $(DIR_M65)/DOS_1_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_DOS_M65) $(CFG_M65)
$(DIR_M65)/kernal.seg_C $(DIR_M65)/KERNAL_C_combined.vs $(DIR_M65)/KERNAL_C_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_M65) $(GEN_STR_M65) $(DIR_M65)/KERNAL_0_combined.sym
$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_M65) $(GEN_STR_M65) $(DIR_M65)/KERNAL_0_combined.sym
@@ -512,6 +516,11 @@ $(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1_combined.vs $(DIR_M65)/DOS_1_combined.sym:
@rm -f $@* $(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1*
@$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s DOS_1 -i DOS_1-mega65 -o dos.seg_1 -d $(DIR_M65) -l 4000 -h 7fff $(CFG_M65) $(SRCDIR_DOS_M65)
$(DIR_M65)/kernal.seg_C $(DIR_M65)/KERNAL_C_combined.vs $(DIR_M65)/KERNAL_C_combined.sym:
@mkdir -p $(DIR_M65)
@rm -f $@* $(DIR_M65)/kernal.seg_C $(DIR_M65)/KERNAL_C*
@$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s KERNAL_C -i KERNAL_C-mega65 -o kernal.seg_C -d $(DIR_M65) -l c000 -h cfff $(CFG_M65) $(GEN_STR_M65) $(SRCDIR_KERNAL) $(GEN_KERNAL)
$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym:
@mkdir -p $(DIR_M65)
@rm -f $@* $(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1*
@@ -684,7 +693,7 @@ $(TARGET_U64CRT_X): $(SEG_LIST_U64CRT) $(CRT_BIN_LIST) build/padding_8_KB
# $0:$6000 - 12 KB - BASIC segment 1
# $0:$9000 - 4 KB - native mode chargen
# $0:$A000 - 8 KB - BASIC segment 0
# $0:$C000 - 4 KB - unused for now, padding
# $0:$C000 - 4 KB - KERNAL segment C
# $0:$D000 - 4 KB - legacy mode chargen
# $0:$E000 - 9 KB - KERNAL segment 0
# $1:$0000 - 64 KB - unused for now, padding
@@ -709,7 +718,7 @@ $(TARGET_M65_x_ORF) $(TARGET_M65_x_PXL): $(SEG_LIST_M65) build/padding_64_KB bui
@cat $(DIR_M65)/basic.seg_1 >> $(TARGET_M65_x_ORF)
@cat build/chargen_openroms.patched >> $(TARGET_M65_x_ORF)
@cat $(DIR_M65)/basic.seg_0 >> $(TARGET_M65_x_ORF)
@cat build/padding_4_KB >> $(TARGET_M65_x_ORF)
@cat $(DIR_M65)/kernal.seg_C >> $(TARGET_M65_x_ORF)
@cat $(TARGET_CHR_ORF) >> $(TARGET_M65_x_ORF)
@cat $(DIR_M65)/kernal.seg_0 >> $(TARGET_M65_x_ORF)
@cat build/padding_64_KB >> $(TARGET_M65_x_ORF)
@@ -724,7 +733,7 @@ $(TARGET_M65_x_ORF) $(TARGET_M65_x_PXL): $(SEG_LIST_M65) build/padding_64_KB bui
@cat $(DIR_M65)/basic.seg_1 >> $(TARGET_M65_x_PXL)
@cat build/chargen_pxlfont.patched >> $(TARGET_M65_x_PXL)
@cat $(DIR_M65)/basic.seg_0 >> $(TARGET_M65_x_PXL)
@cat build/padding_4_KB >> $(TARGET_M65_x_PXL)
@cat $(DIR_M65)/kernal.seg_C >> $(TARGET_M65_x_PXL)
@cat $(TARGET_CHR_PXL) >> $(TARGET_M65_x_PXL)
@cat $(DIR_M65)/kernal.seg_0 >> $(TARGET_M65_x_PXL)
@cat build/padding_64_KB >> $(TARGET_M65_x_PXL)
+16 -1
View File
@@ -4,7 +4,7 @@
Here are the features of the Open ROMs not found in the original ROMs from the 80s (many of them are [configurable](CONFIG.md) during compilation):
* improved keyboard scanning, resistant to ghosting and joystick interference (one variant even supports multi-key rollover), supports additional C128 keys
* improved keyboard scanning, resistant to ghosting and joystick interference, supports additional C128 keys
* joystick can be used to move text cursor
* pre-defined function keys
@@ -386,6 +386,7 @@ Not all of them - only these we want to have implemented.
| `$EA31` | default IRQ | PARTIAL | |
| `$EA7E` | ack CIA1 + below | DONE | |
| `$EA81` | ret from IRQ/NMI | DONE | |
| `$EB48` | set keyboard mapping table | DONE | |
| `$F142` | get key from buffer | DONE | |
| `$F3F6` | (unknown) | NOT DONE | |
| `$F646` | IEC close | NOT DONE | |
@@ -397,3 +398,17 @@ Not all of them - only these we want to have implemented.
| `$FF80` | revision byte | DONE | |
<br />
### API extensions - MEGA65 build
Note: this is likely to change in the future, possibly in an incompatible way!
<br />
| Address | Name | Status | Remarks |
| :-------: | :------- | :------: | :--------------------------------------------------------------------: |
| ? | PRHEX | DONE | print hex value from .A |
| `$FF7D` | PRIMM | DONE | print immediate, address compatible with C128 and C65 ROMs |
| `$FFF8` | | DONE | reset vector for usage within hypervisor, starts in legacy mode |
<br />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+12 -18
View File
@@ -31,31 +31,25 @@ Open ROMs interrupt handlers do not touch the ROM mapping, range `0x4000-0xBFFF`
### API extensions
#### PETSCII
#### PETSCII - C128
Open ROMs provides support for several additional PETSCII codes (all compatible with C128 and/or C65):
When C128 keyboard support is compiled-in, Open ROMs provides support for a few PETSCII codes:
| PETSCII code | description |
| :----------: | :-------------------------------------------------- |
| `$07` | bell (C128 and C65 compatible), not implemented yet |
| `$1B` | `ESC` key (C128 and C65 compatible) |
| `$84` | `HELP` key (C128 and C65 compatible) |
| `$10` | `F9` key (C65 compatible) |
| `$15` | `F10` key (C65 compatible) |
| `$16` | `F11` key (C65 compatible) |
| `$17` | `F12` key (C65 compatible) |
| `$19` | `F13` key (C65 compatible) |
| `$1A` | `F14` key (C65 compatible) |
| PETSCII code | description |
| :----------: | :--------------------- |
| `$07` | bell |
| `$1B` | `ESC` key |
| `$84` | `HELP` key |
There is no official PETSCII code for `TAB` - we can't utilize the ones from C128 or C65 because it conflicts with some C64 codes.
There is no PETSCII code for `TAB` key - we can't utilize the ones from C128 or C65 because it conflicts with some C64 codes.
#### Bucky keys
`SHFLAG` (`$028D`) variable is extended to support additional bucky keys on C128 and C65 keyboards:
| bits 7-5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
| :------: | :---------: | :------: | :------: | :------: | :------: |
| reserved | `CAPS LOCK` | `ALT` | `CTRL` | `VENDOR` | `SHIFT` |
| bits 7-6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
| :------: | :-------: | :---------: | :------: | :------: | :------: | :------: |
| reserved | `NO SCRL` | `CAPS LOCK` | `ALT` | `CTRL` | `VENDOR` | `SHIFT` |
Bits 3 and 4 are extension to the original variable, compatible with the C128 ROMs API. There is no official way to retrieve `NO_SCRL` status as of yet. The `40/80` key status cannot be retrieved in C64 mode at all (C128 hardware limitation).
@@ -101,7 +95,7 @@ Currently there are 4 ROM layouts defined:
- `STD` - with 2 code segments: `BASIC` (`$A000-$E4D2`, where `$C000-$DFFF` is a skip-gap for RAM and I/O area) and `KERNAL` (`$E4D3 - $FFFF`)
- `CRT` - where `BASIC` becames `BASIC_0` and `KERNAL` becames `KERNAL_0`, with additional `BASIC`/`KERNAL` segments are placed on the required cartridge image
- `M65` - where `BASIC` becames `BASIC_0` and `KERNAL` becames `KERNAL_0`, additional segments might be added to the build system in the future; at the moment of writing this document additional 12KB of ROM is defined as `BASIC_1` segment and additional 8KB of ROM is defined as `KERNAL_1` segment
- `M65` - where `BASIC` becames `BASIC_0` and `KERNAL` becames `KERNAL_0`, additional segments might be added to the build system in the future; at the moment of writing this document additional 12KB of ROM is defined as `BASIC_1` segment, additional 4KB of ROM is defined as `KERNAL_C` segment, and additional 8KB of ROM is defined as `KERNAL_1` segment
- `X16` - memory layout for the Commander X16 machine
Expect at least one more, `U64`, if the planned additional ROM banks support for Ultimate 64 gets implemented. To check for current ROM layout or code segment use KickAssembler preprocessor defines, like `ROM_LAYOUT_STD`, `SEGMENT_M65_BASIC_0`, `SEGMENT_X16_KERNAL_1`.
+6
View File
@@ -69,6 +69,12 @@ Verify operation for the binary data starting from a given addres. NOTE: for now
Saves the binary data from the given memory area. NOTE: for now syntax differs from the BASIC V3.5+ - this will be changed once the necessary BASIC infrastructure is implemented.
## Additional BASIC commands - screen/keyboard
### `JOYCRSR joy_number` (MEGA65)
Sets the joystick (1 or 2) which moves the screen cursor. Native mode only.
## Additional BASIC commands - misc
### `COLD` (cart, MEGA65)
-11
View File
@@ -76,11 +76,8 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEYBOARD_C65 NO ; untested
;; #CONFIG# KEYBOARD_C65_CAPS_LOCK NO ; untested
;; #CONFIG# KEY_REPEAT_DEFAULT NO
;; #CONFIG# KEY_REPEAT_ALWAYS NO
;; #CONFIG# KEY_FAST_SCAN YES
@@ -102,18 +99,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
-8
View File
@@ -36,18 +36,10 @@
;; #CONFIG# KEYCMD_HELP NO
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE NO
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
-9
View File
@@ -65,7 +65,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
@@ -89,18 +88,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
-9
View File
@@ -67,7 +67,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
@@ -91,18 +90,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
+8 -17
View File
@@ -29,8 +29,8 @@
;; #CONFIG# IEC YES
;; #CONFIG# IEC_DOLPHINDOS NO
;; #CONFIG# IEC_DOLPHINDOS_FAST NO
;; #CONFIG# IEC_JIFFYDOS YES
;; #CONFIG# IEC_JIFFYDOS_BLANK YES
;; #CONFIG# IEC_JIFFYDOS NO ; fastloaders do not work on MEGA65 yet!
;; #CONFIG# IEC_JIFFYDOS_BLANK NO
;; #CONFIG# IEC_BURST_M65 NO ; please keep disabled for now
@@ -45,9 +45,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C65 NO ; untested
;; #CONFIG# KEYBOARD_C65_CAPS_LOCK NO ; untested
;; #CONFIG# KEY_REPEAT_DEFAULT NO
;; #CONFIG# KEY_REPEAT_ALWAYS NO
;; #CONFIG# KEY_FAST_SCAN YES
@@ -63,24 +60,23 @@
;; #CONFIG# KEYCMD_F3 "@9$"
;; #CONFIG# KEYCMD_F4 "RUN:"
;; #CONFIG# KEYCMD_F5 "@10$"
;; #CONFIG# KEYCMD_F6 NO
;; #CONFIG# KEYCMD_F6 "\5FL"
;; #CONFIG# KEYCMD_F7 "@11$"
;; #CONFIG# KEYCMD_F8 NO
;; #CONFIG# KEYCMD_F8 "\5FHF"
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 "\5FL"
;; #CONFIG# KEYCMD_F9 "REM F9"
;; #CONFIG# KEYCMD_F10 "REM F10"
;; #CONFIG# KEYCMD_F11 "\5FH"
;; #CONFIG# KEYCMD_F11 "REM F11"
;; #CONFIG# KEYCMD_F12 "REM F12"
;; #CONFIG# KEYCMD_F13 "REM F13"
;; #CONFIG# KEYCMD_F14 "REM F14"
;; #CONFIG# KEYCMD_F13 "JOYCRSR 2"
;; #CONFIG# KEYCMD_F14 "JOYCRSR 0"
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
@@ -110,8 +106,3 @@
; --- Other
;; #CONFIG# COMPRESSION_LVL_2 NO
; --- Temporary hotfixes
;; #CONFIG# HOTFIX_CHARPTR YES ; workaround for https://github.com/MEGA65/mega65-core/issues/308
-9
View File
@@ -65,7 +65,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY YES
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
@@ -89,18 +88,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS YES
; --- Software features
-9
View File
@@ -55,7 +55,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
@@ -79,18 +78,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
-9
View File
@@ -57,7 +57,6 @@
; --- Keyboard settings
;; #CONFIG# LEGACY_SCNKEY NO
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
@@ -81,18 +80,10 @@
;; #CONFIG# KEYCMD_HELP "LIST"
;; #CONFIG# KEYCMD_F9 NO
;; #CONFIG# KEYCMD_F10 NO
;; #CONFIG# KEYCMD_F11 NO
;; #CONFIG# KEYCMD_F12 NO
;; #CONFIG# KEYCMD_F13 NO
;; #CONFIG# KEYCMD_F14 NO
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
;; #CONFIG# EDIT_TABULATORS NO
; --- Software features
+2 -21
View File
@@ -227,25 +227,13 @@
; Check that keyboard settings are correct
!ifdef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_RS232_UP2400 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_RS232_UP2400" }
!ifdef CONFIG_RS232_UP9600 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_RS232_UP9600" }
!ifdef CONFIG_TAPE_NORMAL { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_TAPE_NORMAL" }
!ifdef CONFIG_KEYBOARD_C128 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C128" }
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" }
!ifdef CONFIG_KEYBOARD_C65 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C65" }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C65_CAPS_LOCK" }
}
!ifdef CONFIG_MB_M65 {
!ifdef CONFIG_KEYBOARD_C128 { !error "MEGA65 motherboard is not compatible with CONFIG_KEYBOARD_C128" }
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "MEGA65 motherboard is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" }
!ifdef CONFIG_LEGACY_SCNKEY { !error "MEGA65 motherboard is not compatible with CONFIG_LEGACY_SCNKEY" }
}
!ifdef CONFIG_MB_U64 {
!ifdef CONFIG_KEYBOARD_C128 { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C128" }
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" }
!ifdef CONFIG_KEYBOARD_C65 { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C65" }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C65_CAPS_LOCK" }
}
@@ -390,18 +378,11 @@
; Handle keyboard configuration
!ifdef CONFIG_KEYBOARD_C128 { !set CONFIG_KEYBOARD_C128_OR_C65 = 1 }
!ifdef CONFIG_KEYBOARD_C65 { !set CONFIG_KEYBOARD_C128_OR_C65 = 1 }
!ifdef CONFIG_KEYBOARD_C65 { !set CONFIG_KEYBOARD_C65_OR_CAPS_LOCK = 1 }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set CONFIG_KEYBOARD_C65_OR_CAPS_LOCK = 1 }
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !set CONFIG_KEYBOARD_CAPS_LOCK = 1 }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set CONFIG_KEYBOARD_CAPS_LOCK = 1 }
!ifdef CONFIG_JOY1_CURSOR { !set CONFIG_JOY1_OR_JOY2_CURSOR = 1 }
!ifdef CONFIG_JOY2_CURSOR { !set CONFIG_JOY1_OR_JOY2_CURSOR = 1 }
!ifdef CONFIG_RS232_UP9600 { !set CONFIG_KEY_DELAY = $18 } else { !set CONFIG_KEY_DELAY = $16 }
; Handle debug configuration
+4
View File
@@ -32,6 +32,10 @@
!addr C65_EXTKEYS_PR = $D607
!addr C65_EXTKEYS_DDR = $D608
!addr KBSCN_BUCKY = $D611
!addr KBSCN_PEEK = $D613
!addr KBSCN_SELECT = $D614
; SD card
!addr SD_CTL = $D680
+11 -20
View File
@@ -14,10 +14,8 @@
!ifdef CONFIG_KEYBOARD_C128 { !set _NEED_EXTENDED = 1 }
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !set _NEED_CAPS_LOCK = 1 }
!ifdef CONFIG_KEYBOARD_C65 { !set _NEED_EXTENDED = 1 }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set _NEED_CAPS_LOCK = 1 }
!ifdef CONFIG_MB_M65 { !set _NEED_CAPS_LOCK = 1 }
!ifdef CONFIG_MB_M65 { !set _NEED_EXTENDED = 1 }
!ifdef CONFIG_KEYBOARD_C65 { !set _NEED_C65KB = 1 }
!ifdef CONFIG_MB_M65 { !set _NEED_C65KB = 1 }
@@ -34,39 +32,32 @@
!set KEY_FLAG_NO_SCRL = %00100000
}
!ifdef _NEED_CAPS_LOCK {
!set KEY_CAPS_LOCK = %00010000
!set KEY_FLAG_CAPSL = %00010000
}
; Note - the following PETSCII codes are currently unassigned, can be used for further extensions: $01, $04, $06, ($80 ?)
; Note - the following PETSCII codes are currently unassigned, can be used for further extensions: $01, $04, $06, $80, $8F
!set KEY_NA = $00 ; to indicate that no key is presed
; PETSCII codes for our extended screen editor
!set KEY_C64_TAB_FW = $8F ; CTRL+>, TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove?
!set KEY_C64_TAB_BW = $80 ; CTRL+<, SHIFT+TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove?
; PETSCII codes for certain C128 and C65 functionalities
!ifdef _NEED_EXTENDED {
!set KEY_BELL = $07 ; no key, originally CTRL+G ; XXX implement, add to C65 keyboard matrix
!set KEY_BELL = $07 ; CTRL+G
!set KEY_ESC = $1B
}
!ifdef _NEED_C65KB {
!set KEY_TAB = $09 ; XXX add to C65 keyboard matrix
!set KEY_LINE_FEED = $0A ; XXX add to C65 keyboard matrix
!set KEY_TAB_SET_CLR = $18 ; XXX add to C65 keyboard matrix
!set KEY_UNDERLINE_ON = $02 ; XXX add to C65 keyboard matrix
!set KEY_UNDERLINE_OFF = $82 ; XXX add to C65 keyboard matrix
!set KEY_FLASHING_ON = $0F ; XXX add to C65 keyboard matrix
!set KEY_FLASHING_OFF = $8F ; XXX add to C65 keyboard matrix
!set KEY_TAB = $09
!set KEY_LINE_FEED = $0A ; XXX add to M65 matrix
!set KEY_TAB_SET_CLR = $18 ; XXX add to M65 matrix
!set KEY_UNDERLINE_ON = $02 ; XXX add to M65 matrix
!set KEY_UNDERLINE_OFF = $82 ; XXX add to M65 matrix
!set KEY_FLASHING_ON = $0F ; XXX add to M65 matrix
!set KEY_FLASHING_OFF = $8F ; XXX add to M65 matrix
}
+2 -11
View File
@@ -100,31 +100,25 @@
!addr COLSTORE = $9C ; [!] screen border storage for tape routines
}
!addr MSGFLG = $9D ; bit 6 = error messages, bit 7 = control message
!addr PTR1 = $9E ; for tape support, counter of errorneous bytes
!addr PTR2 = $9F ; for tape support, counter for errorneous bytes correction
!addr PTR1 = $9E ; for tape support, counter of errorneous bytes [!] also used by PRIMM
!addr PTR2 = $9F ; for tape support, counter for errorneous bytes correction [!] also used by PRIMM
!addr TIME = $A0 ; $A0-$A2 jiffy clock
!addr IECPROTO = $A3 ; [!] IEC or pseudo-IEC protocol, >= $80 for unknown; originally named TSFCNT
!addr TBTCNT = $A4 ; temporary variable for tape and IEC, [!] our usage probably differs in details
!addr CNTDN = $A5 ; -- NOT IMPLEMENTED --
!addr BUFPNT = $A6 ; -- NOT IMPLEMENTED --
!addr INBIT = $A7 ; temporary storage for tape / RS-232 received bits
!ifndef CONFIG_LEGACY_SCNKEY {
!addr BITCI = $A8 ; -- NOT IMPLEMENTED --
!addr RINONE = $A9 ; -- WIP -- (UP9600 only) RS-232 check for start bit flag
!addr RIDDATA = $AA ; -- NOT IMPLEMENTED --
!addr RIPRTY = $AB ; -- WIP -- checksum while reading tape
}
!addr SAL = $AC ; $AC-$AD -- XXX: describe -- (implemented screen part)
!addr EAL = $AE ; $AE-$AF -- XXX: describe -- [!] used also by screen editor, for temporary color storage when scrolling
!addr CMP0 = $B0 ; $B0-$B1 temporary tape storage, [!] here used for BRK instruction address
!addr TAPE1 = $B2 ; $B2-$B3 tape buffer pointer
!ifndef CONFIG_LEGACY_SCNKEY {
!addr BITTS = $B4 ; -- NOT IMPLEMENTED --
}
!addr NXTBIT = $B5 ; -- NOT IMPLEMENTED -- [!] also used by tape routine to store CPU turbo settings
!ifndef CONFIG_LEGACY_SCNKEY {
!addr RODATA = $B6 ; -- NOT IMPLEMENTED --
}
!addr FNLEN = $B7 ; current file name length
!addr LA = $B8 ; current logical_file number
!addr SA = $B9 ; current secondary address
@@ -175,7 +169,6 @@
!addr BUF = $200 ; $200-$250, BASIC line editor input buffer (81 bytes)
; $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20
; and not used on C64 - they are used if CONFIG_LEGACY_SCNKEY is enabled.
; [!] XXX document $251-$258 usage
!addr LAT = $259 ; $259-$262, logical file numbers (table, 10 bytes)
@@ -197,14 +190,12 @@
!addr KEYLOG = $28F ; $28F-$290 routine to setup keyboard decoding
!addr MODE = $291 ; flag, is case switch allowed
!addr AUTODN = $292 ; -- NOT IMPLEMENTED -- screen scroll disable
!ifndef CONFIG_LEGACY_SCNKEY {
!addr M51CRT = $293 ; -- NOT IMPLEMENTED -- mock 6551
!addr M51CDR = $294 ; -- NOT IMPLEMENTED -- mock 6551
!addr M51AJB = $295 ; $295-$296 -- NOT IMPLEMENTED -- mock 6551
!addr RSSTAT = $297 ; -- WIP -- (UP9600 only) mock 6551, RS-232 status
!addr BITNUM = $298 ; -- NOT IMPLEMENTED --
!addr BAUDOF = $299 ; $299-$29A -- NOT IMPLEMENTED --
}
!addr RIDBE = $29B ; -- WIP -- write pointer into RS-232 receive buffer
!addr RIDBS = $29C ; -- WIP -- read pointer into RS-232 receive buffer
!addr RODBS = $29D ; -- WIP -- read pointer into RS-232 send buffer
+24 -18
View File
@@ -39,24 +39,30 @@
; $580-$5FF - reserved for KERNAL
!addr M65_SCRSEG = $580 ; $580-$581 segment address (2 higher bytes) of the screen memory
!addr M65_SCRBASE = $582 ; $582-$583 first byte of screen memory
!addr M65_SCRGUARD = $584 ; $584-$585 last byte of screen memory + 1 XXX is it needed?
!addr M65_COLGUARD = $586 ; $586-$587 last byte of colour memory + 1
!addr M65_COLVIEW = $588 ; $588-$589 first byte of color memory viewport
!addr M65_COLVIEWMAX = $58A ; $58A-$58B largest allowed value of M65_COLVIEW
!addr M65_SCRMODE = $58C ; 0 = 40x25, 1 = 80x25, 2 = 80x50
!addr M65_SCRWINMODE = $58D ; $00 = normal mode, $FF = window enabled
!addr M65_TXTWIN_X0 = $58E ; text window - top-left X coordinate, starting from 0
!addr M65_TXTWIN_Y0 = $58F ; text window - top-left Y coordinate, starting from 0
!addr M65_TXTWIN_X1 = $590 ; text window - bottom-right X coordinate + 1
!addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1
!addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start
!addr M65_SCRCOLMAX = $594 ; maximum allowed column
; $595-$5EB -- UNUSED --
!addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed)
!addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer --
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
!addr M65_SCRSEG = $580 ; $580-$581 segment address (2 higher bytes) of the screen memory
!addr M65_SCRBASE = $582 ; $582-$583 first byte of screen memory
!addr M65_SCRGUARD = $584 ; $584-$585 last byte of screen memory + 1 XXX is it needed?
!addr M65_COLGUARD = $586 ; $586-$587 last byte of colour memory + 1
!addr M65_COLVIEW = $588 ; $588-$589 first byte of color memory viewport
!addr M65_COLVIEWMAX = $58A ; $58A-$58B largest allowed value of M65_COLVIEW
!addr M65_SCRMODE = $58C ; 0 = 40x25, 1 = 80x25, 2 = 80x50
!addr M65_SCRWINMODE = $58D ; $00 = normal mode, $FF = window enabled
!addr M65_TXTWIN_X0 = $58E ; text window - top-left X coordinate, starting from 0
!addr M65_TXTWIN_Y0 = $58F ; text window - top-left Y coordinate, starting from 0
!addr M65_TXTWIN_X1 = $590 ; text window - bottom-right X coordinate + 1
!addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1
!addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start
!addr M65_SCRCOLMAX = $594 ; maximum allowed column
!addr M65_KB_BUCKY = $595 ; result of bucky keys scan
!addr M65_KB_COLSCAN = $596 ; $596-$59E results of keyboard scan, columns 0-8
!addr M65_JOYCRSR = $59F ; joystick to be used for cursor movement
!addr M65_KB_PRESSED = $560 ; $560-$562 keys pressed, used during scanning keyboard
!addr M65_KB_PRESSED_OLD = $563 ; $563-$565 keys pressed during previous scan
!addr M65_KB_PRESSED_NEW = $566 ; $566-$568 set of M65_KB_PRESSED minus M65_KB_PRESSED_OLD
; $569-$5EB -- UNUSED --
!addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed)
!addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer --
!addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer --
;
; Addresses for configuring the DMA job
+1
View File
@@ -18,6 +18,7 @@
;; #ALIAS# clear_screen = KERNAL_0.clear_screen
;; #ALIAS# printf = KERNAL_0.printf
;; #ALIAS# PRIMM = KERNAL_0.PRIMM
;; #ALIAS# plot_set = KERNAL_0.plot_set
;; #ALIAS# print_hex_byte = KERNAL_0.print_hex_byte
@@ -27,12 +27,8 @@ cmd_return:
+nop
cmd_on:
+nop
cmd_wait:
+nop
cmd_def:
+nop
cmd_poke:
+nop
cmd_printhash:
+nop
cmd_cont:
+37
View File
@@ -0,0 +1,37 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
cmd_poke:
; Fetch address, store it on the stack
jsr fetch_uint16
+bcs do_SYNTAX_error
lda LINNUM+0
pha
lda LINNUM+1
pha
; Fetch value
jsr fetch_coma_uint8
+bcs do_SYNTAX_error
; Retrieve address
tay
pla
sta LINNUM+1
pla
sta LINNUM+0
; Write to memory
tya
ldy #$00
sta (LINNUM), y
rts
+62
View File
@@ -0,0 +1,62 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
cmd_wait:
; Fetch address, store it on the stack
jsr fetch_uint16
+bcs do_SYNTAX_error
lda LINNUM+0
pha
lda LINNUM+1
pha
; Fetch 1st value, store it on the stack
jsr fetch_coma_uint8
+bcs do_SYNTAX_error
pha
; Fetch 2nd value
jsr fetch_coma_uint8
bcc @1
lda #$00
@1:
; Put all the values into work area
sta INDEX+3
pla
sta INDEX+2
pla
sta INDEX+1
pla
sta INDEX+0
!ifdef CONFIG_MB_M65 {
jsr helper_eggshell
}
ldy #$00
; FALLTROUGH
cmd_wait_loop:
; Wait for the congition to be met - see https://www.c64-wiki.com/wiki/WAIT
lda (INDEX), y
eor INDEX+3
and INDEX+2
beq cmd_wait_loop
; FALLTROUGH
cmd_wait_end:
rts
@@ -0,0 +1,131 @@
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# * * #IGNORE
helper_eggshell:
!ifdef SEGMENT_M65_BASIC_0 {
jsr map_BASIC_1
jsr (VB1__helper_eggshell)
jmp map_NORMAL
} else {
; Make sure this is direct mode
ldx CURLIN+1
inx
bne helper_eggshell_end
; Make sure this is native mode
jsr M65_MODEGET
bcs helper_eggshell_end
; Make sure screen mode is 80x50 characters and it is the output device
jsr JSCREEN
cpy #50
bne helper_eggshell_end
cpx #80
bne helper_eggshell_end
lda DFLTO
cmp #$03
bne helper_eggshell_end
; Check key values
ldx #$03
@1:
lda INDEX, x
cmp helper_eggshell_key, x
bne helper_eggshell_end
dex
bpl @1
; FALLTROUGH
helper_eggshell_prepare:
; Enforce lowercase mode
lda MODE
pha
lda #$FF
sta MODE
lda VIC_CHARPTR+1
pha
ora #%00001000
sta VIC_CHARPTR+1
; FALLTROUGH
helper_eggshell_effect:
ldy #$00
@1:
lda helper_eggshell_content, y
eor #$65
beq helper_eggshell_wait
jsr JCHROUT
iny
bra @1
; FALLTROUGH
helper_eggshell_wait:
; Wait for a key
lda #$00
sta NDX
@1:
ldx NDX
beq @1
sta NDX
; FALLTROUGH
helper_eggshell_restore:
; Clear screen, restore mode
lda #147
jsr JCHROUT
pla
sta VIC_CHARPTR+1
pla
sta MODE
; FALLTROUGH
helper_eggshell_end:
rts
helper_eggshell_key:
!byte <6502, >6502, 65, 0
helper_eggshell_content:
!byte $93 XOR $65
!byte $0D XOR $65, $0D XOR $65, $0D XOR $65, $0D XOR $65
!byte $12 XOR $65, $20 XOR $65
!byte $D4 XOR $65, $48 XOR $65, $45 XOR $65, $20 XOR $65, $CF XOR $65, $50 XOR $65, $45 XOR $65, $4E XOR $65
!byte $20 XOR $65, $D2 XOR $65, $CF XOR $65, $CD XOR $65, $53 XOR $65, $20 XOR $65, $50 XOR $65, $52 XOR $65
!byte $4F XOR $65, $4A XOR $65, $45 XOR $65, $43 XOR $65, $54 XOR $65, $20 XOR $65, $4E XOR $65, $45 XOR $65
!byte $45 XOR $65, $44 XOR $65, $53 XOR $65, $20 XOR $65, $D9 XOR $65, $CF XOR $65, $D5 XOR $65, $D2 XOR $65
!byte $20 XOR $65, $43 XOR $65, $4F XOR $65, $4E XOR $65, $54 XOR $65, $52 XOR $65, $49 XOR $65, $42 XOR $65
!byte $55 XOR $65, $54 XOR $65, $49 XOR $65, $4F XOR $65, $4E XOR $65, $21 XOR $65
!byte $20 XOR $65
!byte $00 XOR $65
}
@@ -55,6 +55,7 @@ helper_ask_if_sure:
; Check if 'Y'
and #%01111111 ; allow 'Y' + SHIFT (or CAPS LOCK) too
cmp #$59
beq @2
@@ -1,4 +1,4 @@
;; #LAYOUT# M65 * #TAKE
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
@@ -6,7 +6,7 @@
;
!set ITEM_01 = cmd_sysinfo
!set ITEM_02 = cmd_joycrsr
!ifndef HAS_OPCODES_65C02 {
@@ -14,10 +14,13 @@
command_04_jumptable_lo:
!byte <(ITEM_01-1)
!byte <(ITEM_02-1)
command_04_jumptable_hi:
!byte >(ITEM_01-1)
!byte >(ITEM_02-1)
} else { ; HAS_OPCODES_65C02
@@ -26,4 +29,5 @@ command_04_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_01
!word ITEM_02
}
+24
View File
@@ -0,0 +1,24 @@
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
cmd_joycrsr:
; Make sure we are in MEGA65 native mode
jsr helper_ensure_native_mode
; Fetch joystick ID
jsr fetch_uint8
+bcs do_SYNTAX_error
; Check if joystick ID is valid
cmp #$03
+bcs do_ILLEGAL_QUANTITY_error
; Set the joystick responsible for moving cursor keys
sta M65_JOYCRSR ; XXX consider introducing Kernal call for this
rts
@@ -0,0 +1,10 @@
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
helper_ensure_native_mode:
jsr M65_MODEGET
+bcs do_NATIVE_MODE_ONLY_error
rts
@@ -26,9 +26,10 @@
!addr VB1__cmd_sysinfo = $4000 + 2 * 11
!addr VB1__prepare_direct_execution = $4000 + 2 * 12
!addr VB1__helper_ask_if_sure = $4000 + 2 * 13
!addr VB1__helper_eggshell = $4000 + 2 * 14
!ifdef CONFIG_DOS_WEDGE {
!addr VB1__wedge_dos = $4000 + 2 * 14
!addr VB1__wedge_dos = $4000 + 2 * 15
}
} else {
@@ -49,6 +50,7 @@
!word cmd_sysinfo
!word prepare_direct_execution
!word helper_ask_if_sure
!word helper_eggshell
!ifdef CONFIG_DOS_WEDGE {
!word wedge_dos
+1 -1
View File
@@ -121,7 +121,7 @@ shell_process_line:
lda BUF
cmp #$30
bcc shell_execute_line
cmp #$39
cmp #$3A
bcs shell_execute_line
; Yes, the line begins with a number - parse it and check validity
-23
View File
@@ -1,23 +0,0 @@
;
; Aliases for legacy keyboard scan routine
;
!ifdef CONFIG_LEGACY_SCNKEY {
; Low memory variables
; Reuse RS232 variables, since they should not be used by other things.
; Carefully avoid $A7 which is used by 64NET
!addr KeyQuantity = $A8 ; 1 byte
!addr BufferNew = $A9 ; 3 bytes
!addr TempZP = $B6 ; 1 byte
; These should be initialized in CINT to $FF
!addr BufferQuantity = $B4 ; 1 byte
!addr BufferOld = $293 ; 3 bytes
!addr Buffer = $297 ; 4 bytes
; $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20
; and not used on C64, so safe for us to use, probably.
!addr ScanResult = $250 ; 8 bytes
}
+5 -15
View File
@@ -23,13 +23,11 @@ programmable_keys_codes:
!ifdef CONFIG_KEYCMD_F7 { !byte KEY_F7 }
!ifdef CONFIG_KEYCMD_F8 { !byte KEY_F8 }
!ifndef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_KEYBOARD_C128 {
!ifdef CONFIG_KEYCMD_HELP { !byte KEY_HELP }
} else ifdef CONFIG_KEYBOARD_C65 {
} else ifdef CONFIG_MB_M65 {
!ifdef CONFIG_KEYCMD_HELP { !byte KEY_HELP }
@@ -39,9 +37,7 @@ programmable_keys_codes:
!ifdef CONFIG_KEYCMD_F12 { !byte KEY_F12 }
!ifdef CONFIG_KEYCMD_F13 { !byte KEY_F13 }
!ifdef CONFIG_KEYCMD_F14 { !byte KEY_F14 }
} }
}
__programmable_keys_codes_end:
@@ -69,14 +65,12 @@ __str_offset_F7: !ifdef CONFIG_KEYCMD_F7 { +CONFIG_KEYCMD_F7
__str_offset_F8: !ifdef CONFIG_KEYCMD_F8 { +CONFIG_KEYCMD_F8
!byte $00 }
!ifndef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_KEYBOARD_C128 {
__str_offset_HELP: !ifdef CONFIG_KEYCMD_HELP { +CONFIG_KEYCMD_HELP
!byte $00 }
} else ifdef CONFIG_KEYBOARD_C65 {
} else ifdef CONFIG_MB_M65 {
__str_offset_HELP: !ifdef CONFIG_KEYCMD_HELP { +CONFIG_KEYCMD_HELP
!byte $00 }
@@ -94,7 +88,7 @@ __str_offset_F13: !ifdef CONFIG_KEYCMD_F13 { +CONFIG_KEYCMD_F13
__str_offset_F14: !ifdef CONFIG_KEYCMD_F14 { +CONFIG_KEYCMD_F14
!byte $00 }
} }
}
__programmable_keys_strings_end:
@@ -117,13 +111,11 @@ programmable_keys_offsets:
!ifdef CONFIG_KEYCMD_F7 { !byte __str_offset_F7 - programmable_keys_strings }
!ifdef CONFIG_KEYCMD_F8 { !byte __str_offset_F8 - programmable_keys_strings }
!ifndef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_KEYBOARD_C128 {
!ifdef CONFIG_KEYCMD_HELP { !byte __str_offset_HELP - programmable_keys_strings }
} else ifdef CONFIG_KEYBOARD_C65 {
} else ifdef CONFIG_MB_M65 {
!ifdef CONFIG_KEYCMD_HELP { !byte __str_offset_HELP - programmable_keys_strings }
@@ -135,5 +127,3 @@ programmable_keys_offsets:
!ifdef CONFIG_KEYCMD_F14 { !byte __str_offset_F14 - programmable_keys_strings }
} }
}
+1
View File
@@ -0,0 +1 @@
This particular address is not for interoperability - we had to choose some fixed location for the extended ROM jumptable, beginning of the mapped memory block is just sane.
@@ -0,0 +1,26 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT
;; #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
; Definitions for communication with MEGA65 segment KERNAL_C from KERNAL_0 / KERNAL_1
;
!ifndef SEGMENT_KERNAL_C {
; Label definitions
!addr VKC__m65_cursor_blink = $C000 + 2 * 0
!addr VKC__m65_scnkey = $C000 + 2 * 1
!addr VKC__m65_scnkey_init_keylog = $C000 + 2 * 2
} else {
; Vector table (Open ROMs private!)
!word m65_cursor_blink
!word m65_scnkey
!word m65_scnkey_init_keylog
}
@@ -29,6 +29,8 @@
;; #ALIAS# colour_codes = KERNAL_0.colour_codes
;; #ALIAS# screen_check_toggle_quote = KERNAL_0.screen_check_toggle_quote
;; #ALIAS# screen_code_to_petscii = KERNAL_0.screen_code_to_petscii
;; #ALIAS# m65_scnkey_init_pressed = KERNAL_0.m65_scnkey_init_pressed
;; #ALIAS# scnkey_set_keytab = KERNAL_0.scnkey_set_keytab
;; #ALIAS# setup_irq_timer = KERNAL_0.setup_irq_timer
;; #ALIAS# wait_x_bars = KERNAL_0.wait_x_bars
+17
View File
@@ -0,0 +1,17 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;; #IMPORT# KERNAL_0 = KERNAL_0_combined.sym
;
; Definitions for calling MEGA65 segment KERNAL_0 routines from KERNAL_C
;
;; #ALIAS# m65_scnkey_init_pressed = KERNAL_0.m65_scnkey_init_pressed
;; #ALIAS# scnkey_buffer_full = KERNAL_0.scnkey_buffer_full
;; #ALIAS# scnkey_toggle_if_needed = KERNAL_0.scnkey_toggle_if_needed
;; #ALIAS# kb_matrix_alwaysrepeat = KERNAL_0.kb_matrix_alwaysrepeat
;; #ALIAS# __kb_matrix_alwaysrepeat_end = KERNAL_0.__kb_matrix_alwaysrepeat_end
;; #ALIAS# kb_matrix_joy_status = KERNAL_0.kb_matrix_joy_status
;; #ALIAS# kb_matrix_joy_keytab_idx = KERNAL_0.kb_matrix_joy_status
File renamed without changes.
@@ -25,6 +25,13 @@ m65_mode64:
jsr viciv_shutdown
jsr vicii_init
; Restore KEYLOG
lda #<scnkey_set_keytab
sta KEYLOG+0
lda #>scnkey_set_keytab
sta KEYLOG+1
; Switch CPU speed to normal
lda #$40
@@ -65,6 +72,11 @@ m65_mode65:
jsr m65_native_meminit
; Set C65 keybord handling - XXX check this before enabling
; lda #$02
; sta C65_EXTKEYS_DDR ; output for most keys, input for CAPS LOCK bit
; Set screen mode to 80x50
lda #$02
@@ -4,11 +4,39 @@
m65_native_meminit:
; Clear pages 4-7
lda #$00
tax
@1:
sta $0400, x
sta $0500, x
sta $0600, x
sta $0700, x
inx
bne @1
; Initialize variables for keyboard scanning
jsr m65_scnkey_init_pressed
lda VIC_CTRLA
pha
ora #%00100000
sta VIC_CTRLA
jsr (VKC__m65_scnkey_init_keylog)
pla
sta VIC_CTRLA
; Prepare generic DMAgic list
jsr m65_dmagic_init
;
; Copy MEGA65 charset to target location - set size
;
lda #$00
sta M65_DMAJOB_SIZE_0
+9 -2
View File
@@ -17,9 +17,16 @@ viciv_shutdown:
lda #$03
sta MISC_EMU
; Set misc VIC-IV flags
; Restore chargen location
lda #$10
sta VIC_CHARPTR+1
lda #$00
sta VIC_CHARPTR+0
sta VIC_CHARPTR+2
lda #%00000000
; Set misc VIC-IV flags
; .A is %00000000 here
sta VIC_CTRLB ; disable extended resolution and attributes, disable 3.5 MHz mode
jsr mega65_viciv_setctrl_AC ; enable C64 character set, initialize remaining CTRLA / CTRLC bits
+16
View File
@@ -34,6 +34,22 @@ wait_x_bars: ; additional entry point for delay in screen and tape support
dex
bne @1
; Alternative implementation, using CIA#1 timer B
; lda #%00001000 ; stop timer B, load latch once
; sta CIA1_CRB
; lda #$40
; sta CIA1_TIMBLO ; timer B - low byte
; stx CIA1_TIMBHI ; timer B - high byte
; lda #%00001001 ; start timer B, load latch once
; sta CIA1_CRB
;@1:
; lda CIA1_ICR
; and #%00000010
; beq @1
; FALLTROUGH
iec_wait_rts: ; dummy RTS, for very short waits
-24
View File
@@ -34,30 +34,6 @@ cint_screen_keyboard:
sta RPTFLG
} }
; Set keyboard decode vector (Computes Mapping the 64 p215)
!ifdef CONFIG_LEGACY_SCNKEY {
; Set initial variables for our improved keyboard scan routine
lda #$FF
ldx #6
@1:
sta BufferOld,x
dex
bpl @1
sta BufferQuantity
; Set key repeat delay (Computes Mapping the 64 p215)
; Making some numbers up here: Repeat every ~1/10th sec
; But require key to be held for ~1/3sec before
; repeating (Computes Mapping the 64 p58)
; Not needed for default keyboard scanning code
ldx #22-2 ; Fudge factor to match speed
stx DELAY
}
; Set current colour for text (Computes Mapping the 64 p215)
ldx #CONFIG_COLOR_TXT
stx COLOR
-6
View File
@@ -148,12 +148,6 @@ IOINIT_skip_DOS:
stx VIC_CLKRATE ; store $00
}
!ifdef CONFIG_KEYBOARD_C65_OR_CAPS_LOCK {
lda #$02
sta C65_EXTKEYS_DDR ; output for most keys, input for CAPS LOCK bit
}
; Set DDR on CIA2 for IEC bus, VIC-II banking (see [CM64], $DDOO description on page 193)
lda #$3F
sta CIA2_DDRA ; $DD02
@@ -20,7 +20,21 @@ default_irq_handler:
jsr M65_MODEGET
bcs @2
jsr m65_cursor_blink
; Map KERNAL_C segment
lda VIC_CTRLA
pha
ora #%00100000
sta VIC_CTRLA
; Call the native mode blink routine
jsr (VKC__m65_cursor_blink)
; Restore mapping and quit
pla
sta VIC_CTRLA
bra default_irq_handler_common
@2:
@@ -27,6 +27,10 @@ default_brk_handler:
; Make sure we have normal memory mapping
jsr map_NORMAL
lda VIC_CTRLA
and #%01000111
sta VIC_CTRLA
}
jsr JRESTOR
+11
View File
@@ -0,0 +1,11 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
; 'Print immediate' - useful debug routine, present on many CBM machines
; see https://www.pagetable.com/?p=926
JPRIMM:
jmp PRIMM
+10
View File
@@ -0,0 +1,10 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
; Prints value from .A in hex
JPRHEX:
jmp print_hex_byte
@@ -4,8 +4,7 @@
;
; Not this is not an official Kernal API extension (yet)! It is subject to change!
;
; XXX consider turning this into vector table, the only jumptable extension
; would copy the vector table to given memory location
; XXX assign addresses
M65_JMODEGET:
+2
View File
@@ -0,0 +1,2 @@
This routine is pointed by a vector - it has to be available at the same location as in the original ROM,
otherwise programs frozem with (for example) Action Replay might crash after loading.
@@ -13,24 +13,15 @@
scnkey_set_keytab:
!ifdef CONFIG_LEGACY_SCNKEY { ; routine not compatible with legacy SCNKEY
rts
} else {
; Set initial KEYTAB value
lda #<kb_matrix
sta KEYTAB+0
lda #>kb_matrix
sta KEYTAB+1
; Calculate table index
lda SHFLAG
and #$07 ; we are only interested in SHIFT / CTRL / VENDOR keys
and #$07 ; we are interested in SHIFT, VENDOR and CTRL keys only
tax
; Retrieve table offset
@@ -61,10 +52,6 @@ scnkey_valid_offset_cont:
; FALLTROUGH
} ; no CONFIG_LEGACY_SCNKEY
scnkey_toggle_if_needed: ; entry for SCNKEY (TWW/CTR version)
; Check if we should toggle the character set
@@ -109,5 +96,4 @@ scnkey_toggle_if_needed: ; entry for SCNKEY (TWW/CTR version)
sta VIC_YMCSB
@1:
rts
}
}
+35 -4
View File
@@ -1,6 +1,7 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
@@ -28,6 +29,22 @@ __kb_matrix_normal:
!byte $2B,$50,$4C,$2D,$2E,$3A,$40,$2C
!byte $5C,$2A,$3B,$13,$00,$3D,$5E,$2F
!byte $31,$5F,$00,$32,$20,$00,$51,$03
!ifdef SEGMENT_KERNAL_C {
!byte $00,$09,$00,$84,$10,$16,$19,$1B
}
!ifdef SEGMENT_KERNAL_C {
__kb_matrix_caps:
!byte $14,$0D,$1D,$88,$85,$86,$87,$11
!byte $33,$77,$61,$34,$7A,$73,$65,$00
!byte $35,$72,$64,$36,$63,$66,$74,$78
!byte $37,$79,$67,$38,$62,$68,$75,$76
!byte $39,$69,$6A,$30,$6D,$6B,$6F,$6E
!byte $2B,$70,$6C,$2D,$2E,$3A,$40,$2C
!byte $5C,$2A,$3B,$13,$00,$3D,$5E,$2F
!byte $31,$5F,$00,$32,$20,$00,$71,$03
!byte $00,$09,$00,$84,$10,$16,$19,$1B
}
__kb_matrix_shift:
!byte $94,$8D,$9D,$8C,$89,$8A,$8B,$91
@@ -38,6 +55,9 @@ __kb_matrix_shift:
!byte $DB,$70,$6C,$DD,$3E,$5B,$BA,$3C
!byte $A9,$C0,$5D,$93,$00,$3D,$DE,$3F
!byte $21,$5F,$00,$22,$A0,$00,$71,$83
!ifdef SEGMENT_KERNAL_C {
!byte $00,$00,$00,$84,$15,$17,$1A,$1B
}
__kb_matrix_vendor:
!byte $94,$8D,$9D,$8C,$89,$8A,$8B,$91
@@ -48,17 +68,28 @@ __kb_matrix_vendor:
!byte $A6,$AF,$B6,$DC,$3E,$5B,$A4,$3C
!byte $A8,$DF,$5D,$93,$00,$3D,$DE,$3F
!byte $81,$5F,$00,$95,$a0,$00,$AB,$83
!ifdef SEGMENT_KERNAL_C {
!byte $00,$00,$00,$84,$15,$17,$1A,$1B
}
__kb_matrix_ctrl:
!ifndef SEGMENT_KERNAL_C {
!byte $00,$00,$00,$00,$00,$00,$00,$00
!byte $1C,$17,$01,$9F,$1A,$13,$05,$00
!byte $9C,$12,$04,$1E,$03,$06,$14,$18
!byte $1F,$19,$07,$9E,$02,$08,$15,$16
!byte $12,$09,$0A,$92,$0D,$0B,$0F,$0E
!ifdef CONFIG_EDIT_TABULATORS {
!byte $00,$10,$0C,$00,KEY_C64_TAB_FW,$1B,$00,KEY_C64_TAB_BW
} else {
!byte $00,$10,$0C,$00,$00,$1B,$00,$00
}
!byte $1C,$00,$1D,$00,$00,$1F,$1E,$00
!byte $90,$06,$00,$05,$00,$00,$11,$00
} else {
!byte $00,$00,$00,$00,$00,$00,$00,$00
!byte $1C,$17,$01,$9F,$1A,$13,$05,$00
!byte $9C,$12,$04,$1E,$03,$06,$14,$18
!byte $1F,$19,$07,$9E,$02,$0B,$15,$16
!byte $12,$0C,$0A,$92,$0D,$0B,$0F,$0E
!byte $00,$10,$0C,$00,$00,$1B,$00,$00
!byte $1C,$00,$1D,$00,$00,$1F,$1E,$00
!byte $90,$06,$00,$05,$00,$00,$11,$00
!byte $00,$00,$00,$84,$00,$00,$00,$1B
}
+3 -5
View File
@@ -11,12 +11,12 @@
;
!ifdef CONFIG_KEYBOARD_C128 { !ifndef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_KEYBOARD_C128 {
kb_matrix_128:
!byte KEY_HELP,$38,$35,KEY_C64_TAB_FW,$32,$34,$37,$31
!byte KEY_HELP,$38,$35,$00,$32,$34,$37,$31 ; $00 replaces TAB key
!byte KEY_ESC,$2B,$2D,$8D,$0D,$36,$39,$33
!byte $00,$30,$2E,$91,$11,$9D,$1D,$00
@@ -28,6 +28,4 @@ kb_matrix_128_bucky_filter:
!byte %00000000
!byte %00000000
!byte %10000001 ; ALT, NO_SCRL
} } ; CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY
}
-25
View File
@@ -1,25 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Extended keyboard matrix for Commodore 65 keyboards, based on
;
; - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt
;
!ifdef CONFIG_KEYBOARD_C65 { !ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_65:
!byte $00, KEY_C64_TAB_FW, $00, KEY_HELP, KEY_F9, KEY_F11, KEY_F13, KEY_ESC
kb_matrix_65_shifted:
!byte $00, KEY_C64_TAB_BW, $00, KEY_HELP, KEY_F10, KEY_F12, KEY_F14, KEY_ESC
} } ; CONFIG_KEYBOARD_C65 and no CONFIG_LEGACY_SCNKEY
+2 -2
View File
@@ -11,7 +11,7 @@
;
!ifndef CONFIG_LEGACY_SCNKEY { !ifndef CONFIG_KEY_REPEAT_ALWAYS {
!ifndef CONFIG_KEY_REPEAT_ALWAYS {
kb_matrix_alwaysrepeat:
@@ -24,4 +24,4 @@ kb_matrix_alwaysrepeat:
__kb_matrix_alwaysrepeat_end:
} } ; no CONFIG_LEGACY_SCNKEY and no CONFIG_KEY_REPEAT_ALWAYS
}
+3 -25
View File
@@ -12,8 +12,6 @@
; - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt
;
!ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_bucky_confmask: ; values to be written to CIA1_PRA
@@ -21,8 +19,8 @@ kb_matrix_bucky_confmask: ; values to be written to CIA1_PRA
!byte %10111111 ; SHIFT (right)
!byte %01111111 ; VENDOR
!byte %01111111 ; CTRL
!ifdef CONFIG_KEYBOARD_C128_OR_C65 {
!byte %11111111 ; C128 / C65 extra keys
!ifdef CONFIG_KEYBOARD_C128 {
!byte %11111111 ; C128
!byte %11111111
}
@@ -42,19 +40,6 @@ kb_matrix_bucky_confmask_c128: ; values to be written to VIC_XSCAN
!byte %11111011 ; NO_SCRL
}
!ifdef CONFIG_KEYBOARD_C65 {
kb_matrix_bucky_confmask_c65: ; values to be written to C65_EXTKEYS_PR
!byte %11111111
!byte %11111111
!byte %11111111
!byte %11111111
!byte %11111101 ; ALT
!byte %11111101 ; NO_SCRL
}
kb_matrix_bucky_testmask: ; for AND with CIA1_PRB value
@@ -66,10 +51,6 @@ kb_matrix_bucky_testmask: ; for AND with CIA1_PRB value
!byte %10000000 ; ALT
!byte %00000001 ; NO_SCRL
}
!ifdef CONFIG_KEYBOARD_C65 {
!byte %00000100 ; ALT
!byte %00000001 ; NO_SCRL
}
kb_matrix_bucky_shflag: ; mask to be ORed to SHFLAG to mark key status
@@ -78,10 +59,7 @@ kb_matrix_bucky_shflag: ; mask to be ORed to SHFLAG to mark key status
!byte KEY_FLAG_SHIFT
!byte KEY_FLAG_VENDOR
!byte KEY_FLAG_CTRL
!ifdef CONFIG_KEYBOARD_C128_OR_C65 {
!ifdef CONFIG_KEYBOARD_C128 {
!byte KEY_FLAG_ALT
!byte KEY_FLAG_NO_SCRL
}
} ; no CONFIG_LEGACY_SCNKEY
@@ -11,9 +11,6 @@
;
!ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_bucky_filter:
; values for OR with CIA1_PRB content to filter out bucky keys
@@ -26,4 +23,3 @@ kb_matrix_bucky_filter:
!byte %00000000
!byte %00010000 ; SHIFT (right)
!byte %00100100 ; VENDOR + CONTROL
}
+2 -2
View File
@@ -8,7 +8,7 @@
;
!ifndef CONFIG_LEGACY_SCNKEY { !ifdef CONFIG_JOY1_OR_JOY2_CURSOR {
!ifdef CONFIG_JOY1_OR_JOY2_CURSOR {
kb_matrix_joy_status:
@@ -39,4 +39,4 @@ kb_matrix_joy_keytab_hi:
!byte >__kb_matrix_shift ; left
!byte >__kb_matrix_normal ; right
} }
}
+28 -3
View File
@@ -1,6 +1,7 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
@@ -11,10 +12,10 @@
;
!ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_lookup:
!ifndef SEGMENT_KERNAL_C {
!byte (__kb_matrix_normal - kb_matrix) ; %000 Normal
!byte (__kb_matrix_shift - kb_matrix) ; %001 SHIFT
!byte (__kb_matrix_vendor - kb_matrix) ; %010 VENDOR
@@ -23,4 +24,28 @@ kb_matrix_lookup:
!byte $FF ; %101 SHIFT+CTRL
!byte $FF ; %110 VENDOR+CTRL
!byte $FF ; %111 SHIFT+VENDOR+CTRL
}
} else {
; MEGA65 native mode - no CAPS LOCK active
!word __kb_matrix_normal ; %0.000 Normal
!word __kb_matrix_shift ; %0.001 SHIFT
!word __kb_matrix_vendor ; %0.010 VENDOR
!word $0000 ; %0.011 SHIFT+VENDOR
!word __kb_matrix_ctrl ; %0.100 CTRL
!word $0000 ; %0.101 SHIFT+CTRL
!word $0000 ; %0.110 VENDOR+CTRL
!word $0000 ; %0.111 SHIFT+VENDOR+CTRL
; MEGA65 native mode - CAPS LOCK pressed
!word __kb_matrix_caps ; %1.000 Normal
!word __kb_matrix_shift ; %1.001 SHIFT
!word __kb_matrix_vendor ; %1.010 VENDOR
!word $0000 ; %1.011 SHIFT+VENDOR
!word __kb_matrix_ctrl ; %1.100 CTRL
!word $0000 ; %1.101 SHIFT+CTRL
!word $0000 ; %1.110 VENDOR+CTRL
!word $0000 ; %1.111 SHIFT+VENDOR+CTRL
}
@@ -1,31 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Work out if normal, shifted, control or Vendor modified keyboard.
; Table contains the offsets into keyboard_matrixes that should be used
; for different values of the bottom 3 bits of key_bucky_state XXX
; Interaction is simple to work out when playing with a C64:
; CTRL trumps SHIFT or VENDOR
; VENDOR + SHIFT = DOES NOTHING
; All 3 does CONTROL
;
; This lookup table is used by TWW/CTR keyboard routine only!
!ifdef CONFIG_LEGACY_SCNKEY {
kb_matrix_lookup:
!byte $00 ; Normal
!byte $40 ; Shifted
!byte $80 ; Control
!byte $80 ; Control + SHIFT
!byte $C0 ; Vendor
!byte $C0 ; Vendor + SHIFT
!byte $80 ; Vendor + CTRL
!byte $80 ; Vendor + CTRL + SHIFT
}
-5
View File
@@ -11,9 +11,6 @@
;
!ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_row_keys:
; - values for CIA1_PRA to connect only the given row
@@ -28,5 +25,3 @@ kb_matrix_row_keys:
!byte %11011111
!byte %10111111
!byte %01111111
} ; no CONFIG_LEGACY_SCNKEY
@@ -8,9 +8,6 @@
;
!ifndef CONFIG_LEGACY_SCNKEY {
kb_matrix_row_offsets:
; - offsets (in bytes) to the first bytes of keyboard matrix rows
@@ -23,4 +20,3 @@ kb_matrix_row_offsets:
!byte 5*8
!byte 6*8
!byte 7*8
}
@@ -9,9 +9,6 @@
;
!ifndef CONFIG_LEGACY_SCNKEY {
keyboard_disconnect:
ldx #$FF
@@ -21,4 +18,3 @@ keyboard_disconnect:
}
rts
}
+42 -83
View File
@@ -25,15 +25,39 @@
; - RPTFLG - whether key repeat is allowed
!ifndef CONFIG_LEGACY_SCNKEY {
; Routine takes some ideas from TWW/CTR proposal, see here:
; - http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way
SCNKEY:
!ifdef CONFIG_MB_M65 {
jsr M65_MODEGET
bcs scnkey_legacy_mode
; Map KERNAL_C segment
lda VIC_CTRLA
pha
ora #%00100000
sta VIC_CTRLA
; Call the native mode routine
jsr (VKC__m65_scnkey)
; Restore mapping and quit
pla
sta VIC_CTRLA
rts
scnkey_legacy_mode:
}
; Prepare for SHFLAG update
lda SHFLAG
@@ -72,7 +96,7 @@ SCNKEY:
and #$40
bne @1 ; branch if no CAPS LOCK
lda #KEY_CAPS_LOCK
lda #KEY_FLAG_CAPSL
sta SHFLAG
@1:
@@ -80,21 +104,6 @@ SCNKEY:
stx VIC_XSCAN ; disconnect C128 keys if no C128 keyboard is supported
} }
!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK {
lda C65_EXTKEYS_PR
and #$01
bne @2 ; branch if no CAPS LOCK
lda #KEY_CAPS_LOCK
sta SHFLAG
@2:
!ifndef CONFIG_KEYBOARD_C65 {
ldx #$FF
stx C65_EXTKEYS_PR ; disconnect C65 keys if no C65 keyboard is supported
} }
ldy #(__kb_matrix_bucky_confmask_end - kb_matrix_bucky_confmask - 1)
scnkey_bucky_loop:
lda kb_matrix_bucky_confmask, y
@@ -102,10 +111,6 @@ scnkey_bucky_loop:
!ifdef CONFIG_KEYBOARD_C128 {
lda kb_matrix_bucky_confmask_c128, y
sta VIC_XSCAN
}
!ifdef CONFIG_KEYBOARD_C65 {
lda kb_matrix_bucky_confmask_c65, y
sta C65_EXTKEYS_PR
}
lda kb_matrix_bucky_testmask, y
and CIA1_PRB
@@ -156,9 +161,6 @@ scnkey_keytab_set_done:
stx CIA1_PRA ; connect all the rows
!ifdef CONFIG_KEYBOARD_C128 {
stx VIC_XSCAN
}
!ifdef CONFIG_KEYBOARD_C65 {
stx C65_EXTKEYS_PR
}
dex ; puts $FF
cpx CIA1_PRB
@@ -188,9 +190,6 @@ scnkey_keytab_set_done:
ldy #$FF ; offset in key matrix table, $FF for not found yet
!ifdef CONFIG_KEYBOARD_C128 {
jsr scnkey_128
}
!ifdef CONFIG_KEYBOARD_C65 {
jsr scnkey_65
}
ldx #$07
scnkey_matrix_loop:
@@ -257,7 +256,7 @@ scnkey_joystick_1:
scnkey_joystick_filtered:
; Set appropriate keyboard matrix and key code for joystick event
; Decode joystick event using appropriate matrix
ldy #$03
@5:
@@ -296,11 +295,7 @@ scnkey_got_key: ; .Y should now contain the key offset in matrix pointed by KEYT
;
; Besides - since I am the one who writes the code, I will make the values exactly how I like them :D
!ifndef CONFIG_RS232_UP9600 {
lda #$16
} else {
lda #$18
}
lda #CONFIG_KEY_DELAY
sta DELAY
; FALLTROUGH
@@ -311,7 +306,7 @@ scnkey_output_key:
lda NDX
cmp XMAX
bcs scnkey_early_repeat ; no space in buffer
bcs scnkey_buffer_full ; no space in buffer
; Reinitialize secondary counter
@@ -320,32 +315,12 @@ scnkey_output_key:
; Retrieve the PETSCII code
!ifdef CONFIG_KEYBOARD_C128_OR_C65 {
!ifdef CONFIG_KEYBOARD_C128 {
cpy #$40
bcc scnkey_output_get_keycode
!ifdef CONFIG_KEYBOARD_C128 {
lda kb_matrix_128 - $41, y ; retrieve key code from C128 extended matrix
} else ifdef CONFIG_KEYBOARD_C65 {
; Select key matrix (normal or shifted) for extended C65 keys
lda SHFLAG
and #%00000111 ; KEY_FLAG_SHIFT + KEY_FLAG_VENDOR + KEY_FLAG_CTRL
beq scnkey_output_65_no_shift
cmp #KEY_FLAG_SHIFT
; XXX how to behave on VENDOR/CTRL key? Harmonize this with clasic keys behavior
bne scnkey_no_keys ; no scanning for this bucky key combination
lda kb_matrix_65_shifted - $41, y
jmp scnkey_got_petscii
scnkey_output_65_no_shift:
lda kb_matrix_65 - $41, y
}
jmp scnkey_got_petscii
; FALLTROUGH
@@ -354,22 +329,22 @@ scnkey_output_get_keycode:
lda (KEYTAB), y ; retrieve key code from standard matrix
} ; CONFIG_KEYBOARD_C128 or CONFIG_KEYBOARD_C65
} ; CONFIG_KEYBOARD_C128
!ifdef CONFIG_KEYBOARD_CAPS_LOCK {
!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK {
; Check if we need special handling for a CAPS LOCK key
; This is shorter than a separate set of tables
scnkey_handle_caps_lock:
!ifndef CONFIG_KEYBOARD_C128_OR_C65 {
!ifndef CONFIG_KEYBOARD_C128 {
lda (KEYTAB), y
}
tax
lda SHFLAG
and #(%00000111 + KEY_CAPS_LOCK)
cmp #KEY_CAPS_LOCK
and #(%00000111 + KEY_FLAG_CAPSL)
cmp #KEY_FLAG_CAPSL
bne @7 ; branch if no special CAPS LOCK handling needed
cpx #$41 ; 'A'
@@ -384,9 +359,9 @@ scnkey_handle_caps_lock:
@7:
txa
} ; CONFIG_KEYBOARD_C128_CAPS_LOCK or CONFIG_KEYBOARD_C65_CAPS_LOCK
} ; CONFIG_KEYBOARD_C128_CAPS_LOCK
!ifndef CONFIG_KEYBOARD_C128_OR_C65 { !ifndef CONFIG_KEYBOARD_CAPS_LOCK {
!ifndef CONFIG_KEYBOARD_C128 { !ifndef CONFIG_KEYBOARD_C128_CAPS_LOCK {
lda (KEYTAB), y
} }
@@ -395,22 +370,6 @@ scnkey_handle_caps_lock:
scnkey_got_petscii:
!ifdef CONFIG_KEYBOARD_C128 { !ifdef CONFIG_EDIT_TABULATORS {
; Special handling for SHIFT+TAB; it is easier than creating new matrix
tax
cmp #KEY_C64_TAB_FW
bne @8
lda SHFLAG
and #KEY_FLAG_SHIFT
beq @8
ldx #KEY_C64_TAB_BW
@8:
txa
} } ; CONFIG_KEYBOARD_C128 and CONFIG_EDIT_TABULATORS
beq scnkey_no_keys ; branch if we have no PETSCII code for this key
ldy NDX
sta KEYD, y
@@ -440,6 +399,8 @@ scnkey_try_repeat:
bpl @9
bmi scnkey_done
; FALLTROUGH
scnkey_handle_repeat:
} ; no CONFIG_KEY_REPEAT_ALWAYS
@@ -460,7 +421,7 @@ scnkey_handle_repeat:
rts
scnkey_early_repeat:
scnkey_buffer_full:
; Keyboard buffer was full - at least make sure the key
; will be repeated as soon as possible
@@ -470,5 +431,3 @@ scnkey_early_repeat:
sta KOUNT
rts
} ; no CONFIG_LEGACY_SCNKEY
+2 -4
View File
@@ -10,7 +10,7 @@
;
!ifdef CONFIG_KEYBOARD_C128 { !ifndef CONFIG_LEGACY_SCNKEY {
!ifdef CONFIG_KEYBOARD_C128 {
; Inlining this within SCNKEY would both overcomplicate the implementation
@@ -66,6 +66,4 @@ scnkey_128_no_keys:
pla
jmp scnkey_no_keys ; pass controll to original routine
} } ; CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY
}
-68
View File
@@ -1,68 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Keyboard scanning routine extension for C65 keyboards
;
; - [CM128] Computes Mapping the Commodore 128 - pages 212 (SHFLAG)
; - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt (matrix)
;
!ifdef CONFIG_KEYBOARD_C65 { !ifndef CONFIG_LEGACY_SCNKEY {
; Inlining this within SCNKEY would both overcomplicate the implementation
; and disrupt a lot of branches (they would cross the 127 bytes distance limit)
; .Y is now $FF - try to put there a key code from extended keyboard
scnkey_65:
sty CIA1_PRA ; disconnect classic keys
lda #$00
sta C65_EXTKEYS_PR ; connect C65 keys
lda #%00000101 ; filter out bucky keys: ALT, NO_SCRL
ora CIA1_PRB
cmp #$FF
beq scnkey_65_done ; skip if no key pressed from this row
; At least one key is pressed - decode it
ldy #$07
scnkey_matrix_65_loop:
cmp kb_matrix_row_keys, y
bne @1 ; not this particular key
tya ; now .A contains key offset within a row
clc
adc kb_matrix_row_offsets, x ; now .A contains key offset from the matrix start
adc #$41 ; now .A contains offset after the standard matrix
tay
jmp scnkey_65_done
@1:
dey
bpl scnkey_matrix_65_loop
; FALLTROUGH, multiple keys must have been pressed
scnkey_65_no_keys:
pla ; get rid of return address from the stack
pla
jmp scnkey_no_keys ; pass controll to original routine
scnkey_65_done:
ldx #$FF
stx C65_EXTKEYS_PR ; connect C65 keys
rts
} } ; CONFIG_KEYBOARD_C65 and no CONFIG_LEGACY_SCNKEY
-519
View File
@@ -1,519 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Official Kernal routine, described in:
;
; - [RG64] C64 Programmers Reference Guide - page 295
; - [CM64] Computes Mapping the Commodore 64 - page 220
;
; CPU registers that has to be preserved (see [RG64]): none
;
; NOTE: The code here is described as legacy, because the algorithm (although working very well)
; requires much more RAM than the original Kernal routine uses; without any form of extended
; RAM available to Open ROMs it will always be a serious compatibility risk.
!ifdef CONFIG_LEGACY_SCNKEY {
; Scan the keyboard..
; Here we don't use the horrible buggy original routine,
; not just because of copyright. Instead, we use the
; nice one with joystick interference removal and
; key roll-over support from
; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Keyboard IO Routine
; ~~~~~~~~~~~~~~~~~~~
; By: TWW/CTR
; Information
; ~~~~~~~~~~~
; The routine uses "2 Key rollower" or up to 3 if the key-combination doesen't induce shadowing.
; If 2 or 3 keys are pressed simultaneously (within 1 scan) a "No Activity" state has to occur before new valid keys are returned.
; RESTORE is not detectable and must be handled by NMI IRQ.
; SHIFT LOCK is not detected due to unreliability.
; History:
; ~~~~~~~~
; V3.0 - Hacked to pieces by PGS to work as KERNAL keyboard scan routine
; V2.5 - New test tool.
; Added return of error codes.
; Fixed a bug causing Buffer Overflow.
; Fixed a bug in Non Alphanumerical Flags from 2.0.
; V2.1 - Shortened the source by adding .for loops & Updated the header and some comments.
; Added "simultaneous keypress" check.
; V2.0 - Added return of non-Alphanumeric keys into X & Y-Registers.
; Small optimizations here and there.
; V1.1 - Unrolled code to make it faster and optimized other parts of it.
; Removed SHIFT LOCK scanning.
; V1.0 - First Working Version along with test tool.
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
; Operational Variables
!set MaxKeyRollover = 3
SCNKEY:
lda #$00
sta BufferQuantity
; Decrement key repeat timeout if non-zero
ldx KOUNT
beq sk_start
dec KOUNT
sk_start:
; Call main keyboard scanning routine
jsr Main
lda BufferQuantity
beq no_keys_waiting
; Stuff each key pressed into the keyboard buffer
ldy #$00
@1:
lda Buffer,y
jsr accept_key
iny
cpy BufferQuantity
bne @1
no_keys_waiting:
rts
accept_key:
; Work out what is new and needs to be added
; to the input buffer.
; Also update the bucky key status flags etc
cmp #$ff
beq sk_nokey
; Got a key, turn it from matrix position to key value,
; and stuff it in the keyboard buffer
; Convert matrix position to key code
; XXX - Add offset of $40, $80 or $C0 if shift, CONTROL or C= are held down
pha
lda SHFLAG
and #$7
tax
pla
and #$3f
ora kb_matrix_lookup,x
tax
lda kb_matrix,x
; But don't insert $00 characters
beq sk_nokey
; Stash key into keyboard buffer
ldx NDX
cpx XMAX
beq sk_nokey
sta KEYD,x
inc NDX
sk_nokey:
rts
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Routine for Scanning a Matrix Row
KeyInRow:
ldy #7
NextKeyInRow:
ror
bcs nokey
jsr KeyFound
nokey:
inx
dey
bpl NextKeyInRow
rts
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Routine for handling: Key Found
KeyFound:
stx TempZP
dec KeyQuantity
bmi OverFlow
; Originally, we resolved the keys.
; Now we just return the matrix position, so that
; we can do C64-style bucky modifications as normal
; was: ldy KeyTable,x
pha
txa
ldx KeyQuantity
sta BufferNew,x
pla
ldx TempZP
rts
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Routine for handling: Overflow
OverFlow:
pla ; Dirty hack to handle 2 layers of JSR
pla
pla
pla
; Don't manipulate last legal buffer as the routine will fix itself once it gets valid input again.
ReturnNoKeys:
sec
lda #$00
sta BufferQuantity
lda #$FF
sta LSTX
ldx #MaxKeyRollover-1
@2:
sta Buffer,x
sta BufferOld,x
dex
bpl @2
rts
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Exit Routine for: No Activity
NoActivityDetected:
; So cancel all bucky keys
lda SHFLAG
sta LSTSHF
lda #$00
sta SHFLAG
jmp ReturnNoKeys
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Configure Data Direction Registers
Main:
; Begin with no key events
lda #$ff
sta BufferNew+0
sta BufferNew+1
sta BufferNew+2
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Check for Port Activity
ldx #$FF
ldy #$00
sty CIA1_PRA ; Connect all Keyboard Rows
cpx CIA1_PRB
bne skip0
jmp NoActivityDetected
JoystickActivity:
; Clear bucky key status
lda #$00
sta SHFLAG
lda CIA1_PRB
and #$03
cmp #$01
bne @3
; down
ldx #$07 ; UP/DOWN
jsr KeyFound
@3:
cmp #$02
bne @4
; Up
; Mark shift as pressed
ldx #$01
stx SHFLAG
ldx #$07 ; UP/DOWN
jsr KeyFound
@4:
; Only allow up/down OR left/right, since
; else we have confusing situation with SHIFT required
; for one, but not the other.
; XXX - We could fix this by making the joystick activity
; feed the key input at a higher level, rather than
; simulating directly pressing the cursor keys.
cmp #$03
beq @5
jmp skdone
@5:
lda CIA1_PRB
and #$0c
cmp #$04
bne @6
ldx #$02
jsr KeyFound ; LEFT/RIGHT
@6:
cmp #$08
bne @7
ldx #$01
stx SHFLAG
ldx #$02
jsr KeyFound ; LEFT/RIGHT
@7:
jmp skdone
skip0:
; ; Set max keys allowed before ignoring result
lda #MaxKeyRollover
sta KeyQuantity
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Check for Control Port #1 Activity
stx CIA1_PRA ; Disconnect all Keyboard Rows
cpx CIA1_PRB ; Only Control Port activity will be detected
bne JoystickActivity
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Scan Keyboard Matrix
ldx #7
lda #%11111110
next_row:
sta CIA1_PRA
pha
lda CIA1_PRB
sta ScanResult,x
pla
sec
rol
dex
bpl next_row
; X gets back to $FF here, which is assumed below
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Check for Control Port #1 Activity (again)
stx CIA1_PRA ; Disconnect all Keyboard Rows
cpx CIA1_PRB ; Only Control Port activity will be detected
beq @8
jmp ReturnNoKeys
@8:
; Make X = $00, assumed below
inx
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Check and flag Non Alphanumeric Keys
; Store de-bounce data for bucky keys
; (Compute's Mapping the 64, p58-59)
lda SHFLAG
sta LSTSHF
; Build bucky state
lda #$00
sta SHFLAG
lda ScanResult+6
eor #%10000000
and #%10000000 ; Left shift
rol
rol
and #$01
ora SHFLAG
sta SHFLAG
; Right shift
lda ScanResult+1
eor #$10
lsr
lsr
lsr
lsr
and #$01
ora SHFLAG
sta SHFLAG
; Control
lda ScanResult+0
eor #$04
and #$04
ora SHFLAG
sta SHFLAG
; Vendor key
lda ScanResult+0
eor #$ff
lsr
lsr
lsr
lsr
and #$02
ora SHFLAG
sta SHFLAG
; Handle SHIFT + VENDOR
jsr scnkey_toggle_if_needed
no_case_toggle:
; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ; Check for pressed key(s)
lda ScanResult+7
cmp #$ff
beq sk6
jsr KeyInRow
sk6:
ldx #8
lda ScanResult+6
beq sk5
jsr KeyInRow
sk5:
ldx #16
lda ScanResult+5
beq sk4
jsr KeyInRow
sk4:
ldx #24
lda ScanResult+4
beq sk3
jsr KeyInRow
sk3:
ldx #32
lda ScanResult+3
beq sk2
jsr KeyInRow
sk2:
ldx #40
lda ScanResult+2
beq sk1
jsr KeyInRow
sk1:
ldx #48
lda ScanResult+1
beq sk0
jsr KeyInRow
sk0:
ldx #56
lda ScanResult+0
beq skdone
jsr KeyInRow
skdone:
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Key Scan Completed
; Put any new key (not in old scan) into buffer
ldx #MaxKeyRollover-1
ProcessPressedKeys:
; Check if the currently pressed key is continuing to be held down
lda BufferNew,x
cmp #$ff
beq ConsiderNextKey
cmp BufferOld
beq KeyHeld
cmp BufferOld+1
beq KeyHeld
cmp BufferOld+2
beq KeyHeld
RecordKeypress:
; New Key Detected
ldy BufferQuantity
cpy #MaxKeyRollover
bcc @9
jmp ReturnNoKeys ; too many new keys
@9:
AcceptKeyEvent:
sta Buffer,y
iny
sty BufferQuantity
ConsiderNextKey:
dex
bpl ProcessPressedKeys
; Copy new presses to old list
ldx #MaxKeyRollover-1
@10:
lda BufferNew,x
sta BufferOld,x
dex
bpl @10
; Return success and set of pressed keys
clc
rts
KeyHeld:
; The key in A is still held down.
; compare with key in LSTX
; (Compute's Mapping the 64 p36-37)
; if different, reset repeat count down.
; Ignore bucky keys, so that repeat can work when a
; bucky is held down.
cmp #15
beq BuckyHeld
cmp #52
beq BuckyHeld
cmp #58
beq BuckyHeld
cmp #61
beq BuckyHeld
cmp LSTX
beq SameKeyHeld
; Different key held
sta LSTX
pha
lda DELAY
sta KOUNT
pla
BuckyHeld:
jmp ConsiderNextKey
SameKeyHeld:
pha
lda KOUNT
bmi KeyCanRepeat
bne KeyRepeatWait
; Count down ended, so repeat key now
KeyCanRepeat:
; (Compute's Mapping the 64 p58)
pha
lda #6-2 ; Fudge factor to match speed
sta KOUNT
pla
pla
jmp RecordKeypress
KeyRepeatWait:
pla
jmp ConsiderNextKey
} ; CONFIG_LEGACY_SCNKEY
@@ -0,0 +1,14 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
kb_matrix_bucky_shflag: ; mask to be ORed to SHFLAG to mark key status
!byte KEY_FLAG_SHIFT
!byte KEY_FLAG_SHIFT
!byte KEY_FLAG_CTRL
!byte KEY_FLAG_VENDOR
!byte KEY_FLAG_ALT
!byte KEY_FLAG_NO_SCRL
!byte KEY_FLAG_CAPSL
@@ -0,0 +1,37 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
; Matrix for retrieving C64 joystick status and inject is as keyboard event
;
!ifndef CONFIG_JOY1_OR_JOY2_CURSOR {
kb_matrix_joy_status:
!byte %00001110 ; up
!byte %00001101 ; down
!byte %00001011 ; left
!byte %00000111 ; right
kb_matrix_joy_keytab_idx:
!byte $07 ; up
!byte $07 ; down
!byte $02 ; left
!byte $02 ; right
}
kb_matrix_joy_keytab_lo:
!byte <__kb_matrix_shift ; up
!byte <__kb_matrix_normal ; down
!byte <__kb_matrix_shift ; left
!byte <__kb_matrix_normal ; right
kb_matrix_joy_keytab_hi:
!byte >__kb_matrix_shift ; up
!byte >__kb_matrix_normal ; down
!byte >__kb_matrix_shift ; left
!byte >__kb_matrix_normal ; right
+497
View File
@@ -0,0 +1,497 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
; Routine takes many ideas from TWW/CTR proposal, see here:
; - http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way
m65_scnkey:
; Initialize work variables for scanning the keyboard
lda M65_KB_PRESSED+0
sta M65_KB_PRESSED_OLD+0
lda M65_KB_PRESSED+1
sta M65_KB_PRESSED_OLD+1
lda M65_KB_PRESSED+2
sta M65_KB_PRESSED_OLD+2
jsr m65_scnkey_init_pressed
;
; Scan the whole keyboard, store results in memory
;
ldx #$08
lda #%01111111
and KBSCN_BUCKY
sta M65_KB_BUCKY
stx KBSCN_SELECT ; no loop here, for performance and accuracy purposes
lda KBSCN_PEEK
eor #$FF ; let bit 1 mean 'pressed', not the otherwise
sta M65_KB_COLSCAN+8
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+7
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+6
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+5
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+4
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+3
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+2
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+1
dex
stx KBSCN_SELECT
lda KBSCN_PEEK
eor #$FF
sta M65_KB_COLSCAN+0
;
; Calculate SHIFT / VENDOR / CTRL / ALT / NO SCROLL / CAPS LOCK status
;
lda SHFLAG
sta LSTSHF ; needed for SHIFT+VENDOR support
stx SHFLAG ; .X is $00 here
lda M65_KB_BUCKY
beq m65_scnkey_bucky_done
dex ; index into kb_matrix_bucky_shflag
; FALLTROUGH
m65_scnkey_bucky_loop:
inx
asr ; ASR preserves most significant bit, but in our case it is 0
bcc @1
; Bucky key pressed
tay
lda kb_matrix_bucky_shflag, x
ora SHFLAG
sta SHFLAG
tya
@1:
bne m65_scnkey_bucky_loop
; FALLTROUGH
m65_scnkey_bucky_done:
; Set KEYTAB vector
lda KEYLOG+1
bne @1
jsr m65_scnkey_set_keytab ; KEYLOG routine on zeropage? most likely vector not set
bra m65_scnkey_keytab_set_done
@1:
jsr (KEYLOG)
m65_scnkey_keytab_set_done:
;
; Scan the keyboard matrix stored in memory to determine which keys were pressed
;
lda M65_KB_COLSCAN+0 ; no loop here - for performance purposes
ora M65_KB_COLSCAN+1
ora M65_KB_COLSCAN+2
ora M65_KB_COLSCAN+3
ora M65_KB_COLSCAN+4
ora M65_KB_COLSCAN+5
ora M65_KB_COLSCAN+6
ora M65_KB_COLSCAN+7
ora M65_KB_COLSCAN+8
+beq m65_scnkey_try_joystick ; branch if no key was pressed
ldx #$08
; FALLTROUGH
m65_scnkey_loop:
lda M65_KB_COLSCAN, x
@8:
asl ; no loop here, for performance resons
bcc @7
ldy #$07
jsr m65_scnkey_add_pressed
@7:
asl
bcc @6
ldy #$06
jsr m65_scnkey_add_pressed
beq @0
@6:
asl
bcc @5
ldy #$05
jsr m65_scnkey_add_pressed
beq @0
@5:
asl
bcc @4
ldy #$04
jsr m65_scnkey_add_pressed
beq @0
@4:
asl
bcc @3
ldy #$03
jsr m65_scnkey_add_pressed
beq @0
@3:
asl
bcc @2
ldy #$02
jsr m65_scnkey_add_pressed
beq @0
@2:
asl
bcc @1
ldy #$01
jsr m65_scnkey_add_pressed
beq @0
@1:
asl
bcc @0
ldy #$00
jsr m65_scnkey_add_pressed
@0:
dex
bpl m65_scnkey_loop
;
; Analyze currently and previously pressed keys
;
; First select the new keys
lda M65_KB_PRESSED+0
jsr m65_scnkey_compare_with_old
jsr m65_scnkey_add_if_new_valid
lda M65_KB_PRESSED+1
jsr m65_scnkey_compare_with_old
jsr m65_scnkey_add_if_new_valid
lda M65_KB_PRESSED+2
jsr m65_scnkey_compare_with_old
jsr m65_scnkey_add_if_new_valid
; If we have more than one key - consider it a jam
lda M65_KB_PRESSED_NEW+1
bpl m65_scnkey_jam
; If we have exactly one new key - this is our key to output
ldy M65_KB_PRESSED_NEW+0
bpl m65_scnkey_got_key
; No new key - check if the last one is still pressed
ldy LSTX
cpy M65_KB_PRESSED+0
beq m65_scnkey_try_repeat
cpy M65_KB_PRESSED+1
beq m65_scnkey_try_repeat
cpy M65_KB_PRESSED+2
beq m65_scnkey_try_repeat
; Nope, previous key is not pressed
; FALLTROUGH
m65_scnkey_try_joystick:
lda M65_JOYCRSR
cmp #$02
beq m65_scnkey_try_joy2
cmp #$01
bne m65_scnkey_no_keys
; FALLTROUGH
m65_scnkey_try_joy1:
lda #$FF
sta CIA1_PRA ; disconnect all the rows to prevent keyboard interference
lda CIA1_PRB
bra m65_scnkey_try_joy_common
m65_scnkey_try_joy2:
lda CIA1_PRA
; FALLTROUGH
m65_scnkey_try_joy_common:
and #%00001111 ; filter out anything but joystick movement
beq m65_scnkey_no_keys ; branch if no joystick movement detected
; Decode joystick event using appropriate matrix
ldy #$03
@1:
cmp kb_matrix_joy_status, y
beq @2
dey
bpl @1
; Not found
bra m65_scnkey_no_keys
@2:
; Found joystick movement
lda kb_matrix_joy_keytab_lo, y
sta KEYTAB+0
lda kb_matrix_joy_keytab_hi, y
sta KEYTAB+1
lda kb_matrix_joy_keytab_idx, y
tay
; FALLTROUGH
m65_scnkey_got_key: ; .Y should now contain the key offset in matrix pointed by KEYTAB
cpy LSTX
beq m65_scnkey_try_repeat ; branch if the same key as previously
sty LSTX
; Reset key repeat counters
lda #CONFIG_KEY_DELAY
sta DELAY
; FALLTROUGH
m65_scnkey_output_key:
;
; Output selected key to the keyboard buffer
;
; Check if we have free space in the keyboard buffer
lda NDX
cmp XMAX
+bcs scnkey_buffer_full
; Reinitialize secondary counter
lda #$03
sta KOUNT
; Check if KEYTAB is valid
lda KEYTAB+1
beq m65_scnkey_no_keys
; Retrieve the PETSCII code
lda (KEYTAB), y
; FALLTROUGH
m65_scnkey_got_petscii:
; Put the key into the keyboard buffer
beq m65_scnkey_no_keys ; branch if we have no PETSCII code for this key
ldy NDX
sta KEYD, y
inc NDX
; FALLTROUGH
m65_scnkey_done:
rts
m65_scnkey_pla_jam:
pla
pla
pla
; FALLTROUGH
m65_scnkey_jam:
jsr m65_scnkey_init_pressed
; FALLTROUGH
m65_scnkey_no_keys:
; Mark no key press
lda #$80
sta LSTX
rts
m65_scnkey_try_repeat:
!ifndef CONFIG_KEY_REPEAT_ALWAYS {
; Check whether we should repeat keys - first the flag, afterwards hardcoded list
lda RPTFLG
bmi m65_scnkey_handle_repeat ; branch if we should repeat always
tya
ldx #(__kb_matrix_alwaysrepeat_end - kb_matrix_alwaysrepeat - 1)
@1:
cmp kb_matrix_alwaysrepeat, x
beq m65_scnkey_handle_repeat
dex
bpl @1
bmi m65_scnkey_done
; FALLTROUGH
m65_scnkey_handle_repeat:
} ; no CONFIG_KEY_REPEAT_ALWAYS
; Countdown before first repeat
lda DELAY
beq @1
dec DELAY
rts
@1:
; Countdown before subsequent repeats
lda KOUNT
beq m65_scnkey_output_key ; if second counter is also 0, we can repeat the key
dec KOUNT
rts
m65_scnkey_add_pressed:
; Add pressed key to the 'M65_KB_PRESSED' list, first preserve .A
pha
; Make space on the list
lda M65_KB_PRESSED+2
+bpl m65_scnkey_pla_jam ; branch if too many keys pressed
lda M65_KB_PRESSED+1
sta M65_KB_PRESSED+2
lda M65_KB_PRESSED+0
sta M65_KB_PRESSED+1
; Store key scan code
sty M65_KB_PRESSED+0
txa
asl
asl
asl
adc M65_KB_PRESSED+0 ; Carry already cleared by ASL
sta M65_KB_PRESSED+0
; Restore .A and uit
pla
rts
m65_scnkey_compare_with_old:
; Compare key index with the ones from previous scan
cmp M65_KB_PRESSED_OLD+0
beq @1
cmp M65_KB_PRESSED_OLD+1
beq @1
cmp M65_KB_PRESSED_OLD+2
@1:
rts
m65_scnkey_add_if_new_valid:
beq @1
cmp #$FF ; invalid key code
beq @1
; Filter-out SHIFT, VENDOR, etc.
cmp #$0F ; left SHIFT
beq @1
cmp #$34 ; right SHIFT
beq @1
cmp #$3A ; CONTROL
beq @1
cmp #$3D ; VENDOR
beq @1
cmp #$40 ; NO SCROLL
beq @1
cmp #$42 ; ALT
beq @1
; New, valid key index
ldx M65_KB_PRESSED_NEW+1
stx M65_KB_PRESSED_NEW+2
ldx M65_KB_PRESSED_NEW+0
stx M65_KB_PRESSED_NEW+1
sta M65_KB_PRESSED_NEW+0
@1
rts
@@ -0,0 +1,12 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
m65_scnkey_init_keylog:
lda #<m65_scnkey_set_keytab
sta KEYLOG+0
lda #>m65_scnkey_set_keytab
sta KEYLOG+1
rts
@@ -0,0 +1,15 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
m65_scnkey_init_pressed:
lda #$FF
sta M65_KB_PRESSED+0
sta M65_KB_PRESSED+1
sta M65_KB_PRESSED+2
sta M65_KB_PRESSED_NEW+0
sta M65_KB_PRESSED_NEW+1
sta M65_KB_PRESSED_NEW+2
rts
@@ -0,0 +1,36 @@
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
; MEGA65 native mode version of a well-known Kernal routine, described in:
;
; - [CM64] Computes Mapping the Commodore 64 - pages 220, 221
;
m65_scnkey_set_keytab:
; Calculate table index
lda SHFLAG
and #KEY_FLAG_CAPSL ; isolate CAPS LOCK bit
php
lda SHFLAG
and #%00000111 ; take SHIFT, VENDOR, CTRL, cancel the rest
plp
beq @1
ora #%00001000 ; apply CAPS lock bit at convenient position
@1:
asl ; multiply by 2 - we have a list of addresses
tax
; Set KEYTAB
lda kb_matrix_lookup+0, x
sta KEYTAB+0
lda kb_matrix_lookup+1, x
sta KEYTAB+1
; Fall back to original routine
jmp scnkey_toggle_if_needed
+31
View File
@@ -0,0 +1,31 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
; 'Print immediate', original implementation by Mike Barry, adapted to 65CE02
; see http://www.6502.org/source/io/primm.htm
PRIMM:
pla ; get low part of (string address-1)
sta PTR1
pla ; get high part of (string address-1)
sta PTR2
+bra @2
@1:
jsr JCHROUT ; output a string char
@2:
inc PTR1 ; advance the string pointer
bne @3
inc PTR2
@3:
ldy #$00
lda (PTR1), y ; get string char
bne @1 ; output and continue if not NUL
lda PTR2
pha
lda PTR1
pha
rts
@@ -29,10 +29,6 @@ __chrout_screen_jumptable_quote_guard:
!ifdef CONFIG_EDIT_STOPQUOTE {
!byte KEY_STOP
}
!ifdef CONFIG_EDIT_TABULATORS {
!byte KEY_C64_TAB_BW
!byte KEY_C64_TAB_FW
}
!byte KEY_DEL
!byte KEY_RETURN
@@ -60,10 +56,6 @@ chrout_screen_jumptable_lo:
!byte <(chrout_screen_INS-1)
!ifdef CONFIG_EDIT_STOPQUOTE {
!byte <(chrout_screen_STOP-1)
}
!ifdef CONFIG_EDIT_TABULATORS {
!byte <(chrout_screen_TAB_BW-1)
!byte <(chrout_screen_TAB_FW-1)
}
!byte <(chrout_screen_DEL-1)
!byte <(chrout_screen_RETURN-1)
@@ -85,10 +77,6 @@ chrout_screen_jumptable_hi:
!byte >(chrout_screen_INS-1)
!ifdef CONFIG_EDIT_STOPQUOTE {
!byte >(chrout_screen_STOP-1)
}
!ifdef CONFIG_EDIT_TABULATORS {
!byte >(chrout_screen_TAB_BW-1)
!byte >(chrout_screen_TAB_FW-1)
}
!byte >(chrout_screen_DEL-1)
!byte >(chrout_screen_RETURN-1)
@@ -114,10 +102,6 @@ chrout_screen_jumptable:
!word chrout_screen_INS
!ifdef CONFIG_EDIT_STOPQUOTE {
!word chrout_screen_STOP
}
!ifdef CONFIG_EDIT_TABULATORS {
!word chrout_screen_TAB_BW
!word chrout_screen_TAB_FW
}
!word chrout_screen_DEL
!word chrout_screen_RETURN
-42
View File
@@ -1,42 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 * #IGNORE
;; #LAYOUT# * KERNAL_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Tabulation keys handling within CHROUT
;
!ifdef CONFIG_EDIT_TABULATORS {
chrout_screen_TAB_FW:
jsr screen_get_clipped_PNTR
tya
ora #%00000111
tay
iny
cpy #40
bcc @1
ldy #39
@1:
sty PNTR
jmp chrout_screen_calc_lptr_done
chrout_screen_TAB_BW:
jsr screen_get_clipped_PNTR
beq @2 ; column 0, recalculating pointers is not necessary, but this is a rare case nevertheless
dey
tya
and #%11111000
sta PNTR
@2:
jmp chrout_screen_calc_lptr_done
} ; CONFIG_EDIT_TABULATORS
+1 -1
View File
@@ -14,7 +14,7 @@ screen_scroll_up:
; First handle CTRL and NO_SCRL keys
!ifdef CONFIG_KEYBOARD_C128_OR_C65 {
!ifdef CONFIG_KEYBOARD_C128 {
; Do not scroll if NO_SCRL is pressed and interrupts are enabled
@1:
+1 -1
View File
@@ -1,4 +1,4 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
;
@@ -1,4 +1,4 @@
;; #LAYOUT# M65 KERNAL_0 #TAKE
;; #LAYOUT# M65 KERNAL_C #TAKE
;; #LAYOUT# * * #IGNORE
@@ -91,8 +91,6 @@ m65_scrmodeset_internal: ; entry point for M65_MODE65
stx VIC_COLPTR+0
stx VIC_COLPTR+1
!ifndef CONFIG_HOTFIX_CHARPTR {
; Set the following location:
; - VIC_CHARPTR - for character generator location
@@ -102,7 +100,6 @@ m65_scrmodeset_internal: ; entry point for M65_MODE65
sta VIC_CHARPTR+1
lda #$01
sta VIC_CHARPTR+2
}
; Set the following locations:
; - M65_SCRGUARD, M65_COLGUARD - guards for virtual screen end
+5 -5
View File
@@ -70,7 +70,7 @@ udtim_keyboard:
; key press. But something as simple as this would have created warm restart
; with M+N+SPACE+RESTORE due to ghosting - so the original ROM has to provide
; some protection here. I do not know what the mechanism there exactly does,
; but I hope the mechanism below will be compatible enough.
; but I hope the code below will be compatible enough.
lda #$80
sta CIA1_PRA ; select all the rows except the last one
@@ -78,9 +78,9 @@ udtim_keyboard:
ldx #$00
stx VIC_XSCAN ; connect all the extra C128 keys
}
!ifdef CONFIG_KEYBOARD_C65 {
!ifdef CONFIG_MB_M65 {
ldx #$00
stx C65_EXTKEYS_PR ; connect all the extra C65 keys
stx C65_EXTKEYS_PR ; connect all the extra C65 keys XXX test this
}
lda CIA1_PRB ; read the keys
@@ -91,9 +91,9 @@ udtim_keyboard:
dex ; puts $FF
stx VIC_XSCAN ; disconnect the extra C128 keys
}
!ifdef CONFIG_KEYBOARD_C65 {
!ifdef CONFIG_MB_M65 {
dex ; puts $FF
stx C65_EXTKEYS_PR ; disconnect the extra C65 keys
stx C65_EXTKEYS_PR ; disconnect the extra C65 keys XXX test this
}
lda #$7F
sta CIA1_PRA ; select the last row (bit to 0)
+3
View File
@@ -0,0 +1,3 @@
$00 + STA ($14),Y + RTS
Routine ends by storing value in memory via pointer. Trivial - not copyrightable.
+4
View File
@@ -0,0 +1,4 @@
$D011 + ORA #$10 + STA $D011
Part of code setting a bit in documented hardware register. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
JSR $F7D7 + LDA # (value does not match)
Instruction + some part. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
STA $64 + LDA $63
Part of the code multiplying floating point mantissa by 8, by shifting it 8 bit left. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
STA $65 + LDA $64
Part of the code multiplying floating point mantissa by 8, by shifting it 8 bit left. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
STX $70 + RTS + LDA $61 + BEQ (offset does not match)
One routine ends by storing value in a well-known zaropage location, followed by other which starts by checking whether another location is zero or not. Not creative - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
BCC (skip next instruction) + LDA #$00
Load 0 into .A if carry is set. Trivial - not copyrightable.
+4
View File
@@ -0,0 +1,4 @@
STA $0100,X + INX
Small part of the loop iterating over memory area. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
LDY #$00 + LDA ($22),Y
Reading content of memory pointed by pointer in RAM. Would be one instruction os some CPUs. Trivial - not copyrightable.
+3
View File
@@ -0,0 +1,3 @@
LDA $6B + SBC $63 + STA (zeropage address does not match)
Small part of floating point mantissa manipulation - subtraction of 2 values. Trivial - not copyrightable.
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff. Show more