Is it possible to swap break/delete keys on a +2 (grey)

Post Reply
Markie_V
Posts: 5
Joined: Sat Oct 11, 2014 10:51 am

Is it possible to swap break/delete keys on a +2 (grey)

Post by Markie_V »

I'm in the progress of restoring a ZX Spectrum 128k +2 (Grey) all works fine and I done a lot of mods,
but the position of the delete key will give me troubles in the future (why on earth did they put this key
on the left!)

Looking at the hardware, these keys are 'made' with the lower membrane from the keyboard and are not
more then 'shortcuts' for caps shift 0 and caps shift space.
I think a hardware mod is not possible, but maybe by patching the ROM?

Both keys produce a key scan code, plus the shift key scan code, looking at some ROM disassembly's (I'm
not an Z80 expert) it looks that the delete key and the break key call separate functions.

Just a thought, but is it possible to swap the jumps to these functions? or is something like this totally
not possible...

Grtzz Mark
User avatar
1024MAK
Posts: 5104
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Is it possible to swap break/delete keys on a +2 (grey)

Post by 1024MAK »

Is it possible, yes.

Is it easy, no.

The BREAK key may be checked for multiple places in the code. You will have to read through a disassembly of the code.

Best to modify a copy of the ROM code and run it in an emulator to test it.

To use in a real ZX Spectrum +2, burn the code to an EPROM or EEPROM.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
Markie_V
Posts: 5
Joined: Sat Oct 11, 2014 10:51 am

Re: Is it possible to swap break/delete keys on a +2 (grey)

Post by Markie_V »

Hi Mark :-)

Thanks for the answer, that with the break key is a good one...
Maybe I should update my knowledge about the Z80.

I own a Dataman S4 which can emulate eproms, so at least I can give it a try.

Grtzz Mark
Markie_V
Posts: 5
Joined: Sat Oct 11, 2014 10:51 am

Re: Is it possible to swap break/delete keys on a +2 (grey)

Post by Markie_V »

Maybe this should be in software and not in hardware, but moderator will change if needed.

In the meanwhile I had some sort of success, but not quite there yet...

To change the delete key into a break key seemed the most easy one;
Just change a byte for a different port, I think I'm lucky that both keys are 'shifted keys'
keys, so I do not need a real scancode.

Code: Select all

; ----------------------------
; Check for BREAK into Program
; ----------------------------

L05F5:  LD   A,$7F        ; Read keyboard row B - SPACE. => *** Change to $EF ***
        IN   A,($FE)      ;
        RRA               ; Extract the SPACE key.
        RET  C            ; Return if SPACE not pressed.

        LD   A,$FE        ; Read keyboard row CAPS SHIFT - V.
        IN   A,($FE)      ;
        RRA               ; Extract the CAPS SHIFT key.
        RET  C            ; Return if CAPS SHIFT not pressed.

        CALL L05CB        ; Produce an error.
        DEFB $14          ; "L Break into program"

; --------------
; Test BREAK Key
; --------------
; Test for BREAK being pressed.
; Exit: Carry flag reset if BREAK is being pressed.

L0A5D:  LD   A,$7F        ; => *** Change to $EF ***
        IN   A,($FE)      ;
        RRA               ;
        RET  C            ; Return with carry flag set if SPACE not pressed.

        LD   A,$FE        ;
        IN   A,($FE)      ;
        RRA               ;
        RET               ; Return with carry flag set if CAPS not pressed.
But the nasty one is to remap the original break key into a delete key,
this is done in the editor key mapping table;

Code: Select all

L2556:  DEFB $15          ; Number of table entries.
        DEFB $0B          ; Key code: Cursor up.
        DEFW L2ABA        ; CURSOR-UP handler routine.
        DEFB $0A          ; Key code: Cursor Down.
        DEFW L2ADB        ; CURSOR-DOWN handler routine.
        DEFB $08          ; Key code: Cursor Left.
        DEFW L2AFD        ; CURSOR-LEFT handler routine.
        DEFB $09          ; Key code: Cursor Right.
        DEFW L2B09        ; CURSOR-RIGHT handler routine.
        DEFB $AD          ; Key code: Extend Mode + P.
        DEFW L2A75        ; TEN-ROWS-UP handler routine.
        DEFB $AC          ; Key code: Symbol Shift + I.
        DEFW L2A4B        ; TEN-ROWS-DOWN handler routine.
        DEFB $AF          ; Key code: Extend Mode + I.
        DEFW L29FA        ; WORD-LEFT handler routine.
        DEFB $AE          ; Key code: Extend Mode + Shift + J.
        DEFW L2A07        ; WORD-RIGHT handler routine.
        DEFB $A6          ; Key code: Extend Mode + N, or Graph + W.
        DEFW L29A9        ; TOP-OF-PROGRAM handler routine.
        DEFB $A5          ; Key code: Extend Mode + T, or Graph + V.
        DEFW L29D1        ; END-OF-PROGRAM handler routine.
        DEFB $A8          ; Key code: Extend Mode Symbol Shift + 2, or Graph Y.
        DEFW L2AAD        ; START-OF-LINE handler routine.
        DEFB $A7          ; Key code: Extend Mode + M, or Graph + X.
        DEFW L2AA0        ; END-OF-LINE handler routine.
        DEFB $AA          ; Key code: Extend Mode + Shift + K.
        DEFW L2941        ; DELETE-RIGHT handler routine.
L257E   DEFB $0C          ; Key code: Delete.
        DEFW L2951        ; DELETE handler routine.
        DEFB $B3          ; Key code: Extend Mode + W.
        DEFW L303D        ; DELETE-WORD-RIGHT handler routine.
        DEFB $B4          ; Key code: Extend Mode + E.
        DEFW L2FE2        ; DELETE-WORD-LEFT handler routine.
        DEFB $B0          ; Key code: Extend Mode + J.
        DEFW L3098        ; DELETE-TO-END-OF-LINE handler routine.
        DEFB $B1          ; Key code: Extend Mode + K.
        DEFW L3064        ; DELETE-TO-START-OF-LINE handler routine.
        DEFB $0D          ; Key code: Enter.
        DEFW L296A        ; ENTER handler routine.
        DEFB $A9          ; Key code: Extend Mode + Symbol Shift + 8, or Graph + Z.
        DEFW L26BA        ; TOGGLE handler routine.
        DEFB $07          ; Key code: Edit.
        DEFW L2723        ; MENU handler routine.
On L257E is the call to the delete function, done with key scan code $0C, I can change this
to any key scan code and this will work.
But I need the key scan code for 'CAPS SHIFT + SPACE' I looked and searched a lot but
I don't seem to find it.

On this Wiki;
https://en.wikipedia.org/wiki/ZX_Spectrum_character_set
And on this disassembly;
http://www.primrosebank.net/computers/z ... blyThe.pdf

It looks there is no 'CAPS SHIFT + SPACE' key scan code, but then again I think every key/combination must
have it's own key scan code, any ideas would be great, I'm a bit stuck

Grtzz Mark
Post Reply