He he, I don't know if someone else knows this failure... it is very
subtile, and somehow funny! X-)
Let's go:
Everybody knows (I suppose) that it is possible to easily emulate a
"LOCATE x,y" instruction by just printing these control characters:
27,"Y",32+y,32+x
so a "LOCATE" routine in assembler could be as follows:
;--- LOCATE X,Y (H=x, L=Y)
LOCATE: set 5,h
set 5,l
ld (COORD),hl
ld de,LOC_S
ld c,9
call 5
ret
LOC_S: db 27,"Y"
COORD: dw 0
db "$"
But... what happens when the value of the "y" coordinate is 4? 32+4=36,
which is the ASCII code for character "$"... and what happens when you
try to print 27,"Y","$",32+x,"$" via DOS function 9? Surprise: the first
"$" is interpreted as the string termination mark, cursor is not
located, and the next execution of function 9 gives unexpected results!
(O_o)
So what is the solution? Just treat y=4 as a special case and when this
is the input, use y=5 instead and print also a "cursor up" character
(&H1E):
;--- New LOCATE x,y (H=x, L=y)
LOCATE: set 5,h
set 5,l
ld a,l
cp &H24
jr z,LOC2
;Normal LOCATE
ld (COORD),hl
ld de,COORD_S
ld c,9
call 5
ret
LOC_S: db 27,"Y"
COORD: dw 0
db "$"
;Line 4 LOCATE
LOC2: inc l
ld (COORD2),hl
ld de,COORD_S2
ld c,9
call 5
ret
LOC_S2: db 27,"Y"
COORD2: dw 0
db &H1E,"$"
So it is again demonstred that I'm the best and the most handsome.
Hum... X-D
*** XX MSX USERS MEETING IN BARCELONA: DECEMBER 8th 2001 ***
--------------------------------------------------------------------------------------------------------------------------
Konami Man - AKA Nestor Soriano (^^)v
http://www.konamiman.com - [EMAIL PROTECTED]
ICQ#: 18281450
"Celebrating the imprudences must be unfailingly consequent with it said,
not for the fact in itself, but for some that another onomatopoeia to the use"
--------------------------------------------------------------------------------------------------------------------------
--
For info, see http://www.stack.nl/~wynke/MSX/listinfo.html