home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug134.arc
/
CLICK.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
1KB
|
109 lines
.z80
; keyboard interrupt
; clicks when key is pressed
; code located at spare ram above 0c000h
int equ 0e830h ; seems to be unused by shell or ccp
toggle equ 0e860h
status equ 0e862h ; 0fch = click enabled
vector equ 0e864h ; store original jump vector
ld a,(status)
cp 0fch
jr nz,start
xor a
ld (status),a
; restore original jump vector
ld a,4
rst 28h ; ==> HL = vector table base
inc hl
inc hl
ld de,vector
ld a,(de)
ld (hl),a
inc hl
inc de
ld a,(de)
ld (hl),a
; disable pio port B interrupts
ld a,3
out (3),a
ret
start:
; copy code
ld hl,klik
ld de,int
ld bc,klikend-klik
ldir
xor a
ld (toggle),a
; find interrupt vector
ld a,4
rst 28h
inc hl
inc hl
ld de,int
ld c,(hl)
ld (hl),e
inc hl
ld b,(hl)
ld (hl),d
; set up pio port B to generate interrupt on bit 1
ld a,0cfh
out (3),a
ld a,00011011b
out (3),a
ld a,10110111b
out (3),a
ld a,11111101b
out (3),a
ld a,0fch
ld (status),a
ld (vector),bc
ret
klik:
di
push af
push bc
ld a,(toggle)
xor 1
ld (toggle),a
or a
jr z,quit ; no click on key release
ld a,64
repeat:
ld b,128
push af
in a,(2)
xor 64
out (2),a
count:
djnz count
pop af
dec a
jr nz,repeat
quit:
pop bc
pop af
ei
reti
klikend equ $
end