Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement INKEY with negative argument #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions eval.asm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
XREF OSKEY
XREF INKEY1
XREF GETPORT
XREF KBSTATE
;
; BINARY FLOATING POINT REPRESENTATION:
; 32 BIT SIGN-MAGNITUDE NORMALIZED MANTISSA
Expand Down Expand Up @@ -1144,13 +1145,31 @@ GET1: SCF
;
INKEYS: CALL ITEMI
EXX
BIT 7,H
JR NZ, INKEY_NEG
CALL OSKEY
INKEY1: LD DE,ACCS
LD (DE),A
LD A,80H
RET NC
INC E
RET
; negative INKEY argument: See if that key is currently down
INKEY_NEG:
XOR A
LD H, A
SUB L ; +ve keycode in A
LD L, A
LD B, A
LD DE, KBSTATE
ADD HL, DE
LD A, (HL) ; non-zero if key is pressed
OR A
SCF
JR Z, INKEY1
LD A, B
JP INKEY1

;
;MID$ - Return sub-string.
;Result is string.
Expand Down
55 changes: 54 additions & 1 deletion patch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
XDEF OSSAVE
XDEF EXPR_W2
XDEF GETPORT
XDEF KBSTATE

XREF ASC_TO_NUMBER
XREF RAM_START
Expand Down Expand Up @@ -302,14 +303,65 @@ LTRAP1: LD HL,FLAGS ; Escape is pressed at this point, so
; Z-flag reset indicates AUTO-RUN.
; Destroys: A,D,E,H,L,F
;
OSINIT: CALL VBLANK_INIT
OSINIT: CALL VBLANK_INIT
CALL KBVECTOR_INIT
XOR A
LD (FLAGS), A ; Clear flags and set F = Z
LD HL, USER
LD DE, RAM_Top
LD E, A ; Page boundary
RET

KBVECTOR_STOP:
LD.L HL, 0
LD C,0 ; do not extend HL with MB: we want it zeroed
LD A, 1Dh
RST.LIS 8
RET

KBVECTOR_INIT:
LD HL,KBVECTOR
LD C,1 ; extend HL to 24-bits using MB
LD A,1Dh
RST.LIS 8
RET

.ASSUME ADL = 1
KBVECTOR:
PUSH IY
PUSH IX
PUSH DE
POP IX

LD.SIS DE,0
LD.SIS HL,KBSTATE
LD E, (IX+2) ; key code

; coerce upper case letters to lower case, otherwise there are issues with stuck keys when shift is used
LD A,E
SUB 48
JR C, $F
CP 26
JR NC, $F
LD A, E
SUB 26
LD E, A

$$:
ADD.S HL,DE

LD A, (IX+3) ; key down
LD.SIS (HL),A

POP IX
POP IY
RET

.ASSUME ADL = 0

KBSTATE:
DS 256

;
;OSCLI - Process a MOS command
;
Expand Down Expand Up @@ -404,6 +456,7 @@ COMDS: DB 'BY','E'+80h ; BYE
; *BYE
;
STAR_BYE: CALL VBLANK_STOP ; Restore MOS interrupts
CALL KBVECTOR_STOP
POP.LIL IX ; The return address to init
LD HL, 0 ; The return code
JP (IX)
Expand Down