Changes

Jump to: navigation, search

ACU January-February 1985 - Type-ins

2,310 bytes removed, 14:57, 31 July 2009
/* RSX Article */
[[image:Acu_Mmschedule8.png|192px]]
=RSX Articleand the CPC464=RSXASSEM.ASM contains the Z80 assembler code for the "RSX and the CPC464" article.<br/>RSXLIST2.BAS contains the BASIC code.<br/>See Amstrad Computer User, January/February 1985, page 29 for more details.
The |GETCHAR command reads the code for a character at position x,y in window n.<br/><br/>
The BASIC file RSXLIST2.BAS needed to create the |GETCHAR command is provided on the disk, for users without an assembler.<br/>
See Amstrad Computer User, January/February 1985 for more details.<br/><br/>
To see an example of this command in action, type:<br/>
RUN"RSXLIST4"<br/>
[[image:Acu_Getchar1.png|192px]]
[[image:Acu_Getchar2.png|192px]]
<br/><br/>
The Z80 assembler code for the |GETCHAR command.
<pre>
ORG &8000
; RSX to add |GETCHAR,return_char%,stream_num
.KL_LOG_EXT EQU &BCD1
.TXT_OUTPUT EQU &BB5A
.TXT_SWAP_STREAMS EQU &BBB7
.TXT_RD_CHAR EQU &BB60
 
.entry EQU $
LD HL,&E9E1
LD (&30),HL
RST &30
 
.this EX DE,HL
LD HL,rel_tab-this
ADD HL,DE ; HL has absolute address of rel_table
 
.loop LD C,(HL)
INC HL
LD B,(HL) ; BC has first entry in table
LD A,C
OR B
JR Z,done ; entry was 0000 so exit loop
PUSH HL ; stack current table pointer
LD H,B
LD L,C
ADD HL,DE ; make table entry absolute
PUSH HL ; and stack this value
LD C,(HL)
INC HL
LD B,(HL) ; get contents pointed to by entry
LD H,B
LD L,C
ADD HL,DE ; make this absolute
LD B,H
LD C,L
POP HL ; retrieve absolute entry value
LD (HL),C
INC HL
LD (HL),B ; store calculated absolute value at this address
POP HL ; get address of previous table entry
INC HL ; make HL point at next
JR loop
 
.done EQU $
 
.r01 LD BC,rsx_tab-this
.r02 LD HL,work-this
JP KL_LOG_EXT ; log-on new command
 
.rsx_tab EQU $
 
.r03 DEFW nam_tab-this
.r04 JP scr-this
 
.nam_tab EQU $
DEFM "GETCHA"
DEFB "R"+&80 ; final character has sign bit set
DEFB 0 ; finish table with zero byte
 
.scr EQU $
CP 2
JR NZ,error
LD L,(IX+2) ; pick up integer variable address
LD H,(IX+3)
PUSH HL ; and save it on the stack
LD B,(IX+0) ; get stream number
LD C,0
PUSH BC
CALL TXT_SWAP_STREAMS ; swap to desired stream
POP BC
CALL TXT_RD_CHAR ; pick up the character
POP HL
LD (HL),A ; store character in low byte of integer variable
SBC A,A ; subtract carry (give 0 if clear, 1 if set)
INC A
INC HL
LD (HL),A
 
.ss CALL TXT_SWAP_STREAMS
RET
 
.error EQU $
 
.r05 LD HL,msg-this ; haven't got two parameters
 
.pmess LD A,(HL)
INC HL
CALL TXT_OUTPUT
CP 10
JR NZ,pmess
RET
 
.work DEFS 4
 
.msg DEFM "Bad Command"
DEFB 13,10
 
.rel_tab EQU $
DEFW r01-this+1
DEFW r02-this+1
DEFW r03-this
DEFW r04-this+1
DEFW r05-this+1
DEFW 0
</pre>
=Trench=
3,699
edits