[ZX81-ASM] New GET key function.

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
XavSnap
Posts: 757
Joined: Sat May 10, 2008 4:23 pm

[ZX81-ASM] New GET key function.

Post by XavSnap » Wed Jul 03, 2019 12:13 am

This new function wait and get a key.
(the famous GETA$ from the Apple Basic)
Can be used in menus, press a key…

>Set code to BC.
>Set spare1 (16417) key code.
>Display the key on the screen.(set PRINT AT)

Code: Select all

# ****** GET$ FUNCTION *******
     0  REM [HEX:\
14,7C,ED,4B,25,40,51,14,\
20,03,18,F6,C9,CD,BD,07,\
7E,32,21,40,D7,06,00,4F,\
C9 ]

    10 PRINT AT 10,10;
    15 LET K=VAL "16514"
    18 LET Z$=""
    20 LET Z=USR K
    25 LET Z$=Z$+CHR$ Z
    30 IF Z<>118 THEN GOTO 20

Code: Select all

;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------
; Zx81 Program name: VB81 XuR [META.P] : SAVE"META" Line 999
; REM   line   name: 1 REM:   247 Bytes@4082-4178

#define ORG  .org       ; TASM cross-assembler definitions
#define equ  .equ
;-----------------------------------

;------------------------------------
;-Basic sub-routine entry.          -
;+----------------------------------+
;------- Rom and Ram Symbols -------
RAM_LAST_K equ $4025
DECODE equ $07BD
RAM_SPARE1 equ $4021
RAM_VARS equ $4010
RAM_D_FILE equ $400C


ORG $4082 ; [@16514/@h4082]
Lb4082:
	INC D 
	LD A,H 
Lb4084:
	LD BC,(RAM_LAST_K) ; GET LAST-K
	LD D,C 
	INC D 
	JR NZ, Lb4090 ; [$4090:16528]
	JR Lb4084
	RET ; ==========================

Lb4090:
	CALL DECODE ; [DECODE]
	LD A,(HL) 
	LD (RAM_SPARE1),A ; GET UNUSED-8
	RST 10H
	LD B,0
	LD C,A
	RET ; ==========================
.end

Post Reply