Can't get string from CALL (new function for BASIC )

بواسطة DanySoft

Champion (452)

صورة DanySoft

15-11-2011, 21:23

Hello, I was not able to send the string on the screen CALL string (VRAM, x, y, string). Smile

I tried to use the two call FRMEVL (0x4C64) and FRESTR (0x67D0) to send to the DAC and VALTYP that gives 3 to string.

The address is read in order to HL (POP HL)
the other addresses VRAM (word), X, Y (bytes) are managed by two 06F0Bh CALL (get item word) and 0521Ch (Bytes).
Help me?

I have my source, you see, only the string.

Talk you! Big smile

Login أوregister لوضع تعليقاتك

بواسطة DanySoft

Champion (452)

صورة DanySoft

15-11-2011, 23:56

Sorry, wait as long, but this is necessary for finish the my program as utility, is important for future for MSX.
But three comands not used by BASIC : IPL, ATTR$ and CMD.
Unfortunately...
First add this "CMD" and get too errors, forget !! Use CALL is easy... but not STRING!!!! SadSadSad

بواسطة NYYRIKKI

Enlighted (6016)

صورة NYYRIKKI

16-11-2011, 18:53


; Example of String handling in BASIC CALL-commands
; Made By: NYYRIKKI 16.11.2011


        OUTPUT "PRINT.ROM"
        ORG     #4000

;---------------------------

; External variables & routines
CHPUT   EQU     #A2
CALBAS	EQU	#159
ERRHAND EQU     #406F
FRMEVL  EQU     #4C64
CHRGTR  EQU     #4666
VALTYP  EQU     #F663
USR     EQU     #F7F8
PROCNM	EQU	#FD89

;---------------------------

; ROM-file header

        DEFW    #4241,0,CALLHAND,0,0,0,0,0


;---------------------------

; General BASIC CALL-command handler

CALLHAND:

	PUSH    HL
	LD	HL,CMDS	        ; Table with "_" commands
.CHKCMD:
	LD	DE,PROCNM
.LOOP:	LD	A,(DE)
	CP	(HL)
	JR	NZ,.TONEXTCMD	; Not equal
	INC	DE
	INC	HL
	AND	A
	JR	NZ,.LOOP	; No end of command name, go checking
	LD	E,(HL)
	INC	HL
	LD	D,(HL)
	POP	HL		; routine address
	CALL	GETPREVCHAR
	CALL	.CALLDE		; Call routine
	AND	A
	RET

.TONEXTCMD:
	LD	C,0FFH
	XOR	A
	CPIR			; Skip to end of commandname
	INC	HL
	INC	HL		; Skip address
	CP	(HL)
	JR	NZ,.CHKCMD	; Not end of table, go checking
	POP	HL
        SCF
	RET
	
.CALLDE:
	PUSH	DE
	RET

;---------------------------
CMDS:

; List of available commands (as ASCIIZ) and execute address (as word)

	DEFB	"UPRINT",0      ; Print upper case string
	DEFW	_UPRINT
	
	DEFB	"LPRINT",0      ; Print lower case string
	DEFW	_LPRINT

	DEFB	0               ; No more commands

;---------------------------
_UPRINT:
	CALL	EVALTXTPARAM	; Evaluate text parameter
	PUSH	HL
        CALL    GETSTRPNT
.LOOP
        LD      A,(HL)
        CALL    .UCASE
        CALL    CHPUT  ;Print
        INC     HL
        DJNZ    .LOOP

	POP	HL
	OR      A
	RET

.UCASE:
        CP      "a"
        RET     C
        CP      "z"+1
        RET     NC
        AND     %11011111
        RET
;---------------------------
_LPRINT:
	CALL	EVALTXTPARAM	; Evaluate text parameter
	PUSH	HL
        CALL    GETSTRPNT
.LOOP
        LD      A,(HL)
        CALL    .LCASE
        CALL    CHPUT  ;Print
        INC     HL
        DJNZ    .LOOP

	POP	HL
	OR      A
	RET

.LCASE:
        CP      "A"
        RET     C
        CP      "Z"+1
        RET     NC
        OR      %00100000
        RET
;---------------------------

GETSTRPNT:
; OUT:
; HL = String Address
; B  = Lenght

        LD      HL,(#F7F8)
        LD      B,(HL)
        INC     HL
        LD      E,(HL)
        INC     HL
        LD      D,(HL)
        EX      DE,HL
        RET

EVALTXTPARAM:
	CALL	CHKCHAR
	DEFB	"("             ; Check for (
	LD	IX,FRMEVL
	CALL	CALBAS		; Evaluate expression
        LD      A,(VALTYP)
        CP      3               ; Text type?
        JP      NZ,TYPE_MISMATCH
	CALL	CHKCHAR
	DEFB	")"             ; Check for )
        RET


CHKCHAR:
	CALL	GETPREVCHAR	; Get previous basic char
	EX	(SP),HL
	CP	(HL) 	        ; Check if good char
	JR	NZ,SYNTAX_ERROR	; No, Syntax error
	INC	HL
	EX	(SP),HL
	INC	HL		; Get next basic char

GETPREVCHAR:
	DEC	HL
	LD	IX,CHRGTR
	JP      CALBAS


TYPE_MISMATCH:
        LD      E,13
        DB      1

SYNTAX_ERROR:
        LD      E,2
	LD	IX,ERRHAND	; Call the Basic error handler
	JP	CALBAS
	
;---------------------------

        DS      #8000-$
        

بواسطة DanySoft

Champion (452)

صورة DanySoft

16-11-2011, 20:54

Okey, but after the string, I have to add the location of VRAM, X, Y as below:
CALL string (string, vram, x, y)
example:
call string ("Msx Computer", 6144,5,3): 6144 rem is the address in Screen 1
Then I met a bug as below:
string:
POP HL
... for string <- OK
... for VRAM <- ?
... for X <- ?
... for Y <- ?
PUSH HL

LD HL, (addr)
...
call 005Ch <- And see the screen : not CORRET!

POP HL
XOR A
RET

In short, no longer displays the string, but characters miscella .. Question

بواسطة DanySoft

Champion (452)

صورة DanySoft

16-11-2011, 20:56

Again add this my block on source :

;**** START of BLOCK
function_STRING:
	POP HL
	ADD_CHAR 40	;"("

	CALL  R_WORD   ;lees adres VRAM
	LD    (ADDR1),DE

    ADD_CHAR 44	;","

	CALL  R_WORD   ;lees adres X
	LD    (ADDR2),DE
	
    ADD_CHAR 44	;","

	CALL  R_WORD   ;lees adres Y
	LD    (ADDR3),DE

    ADD_CHAR 44	;","
	
	CALL N_4C64   ;FRM EVL STRING
	LD DE,(DAC)
	LD (ADDR4),DE
	
	ADD_CHAR 41	;")"
	
	PUSH HL
	
	LD hl,(ADDR4)
	LD (DAC),HL
	LD A,3
	LD (VALTYP),A
	CALL N_67D0

    ;MAKE POSIZIONE VRAM + Y*32+X

    LD HL,(ADDR3)   ;Y
    ADD HL,HL
    ADD HL,HL
    ADD HL,HL
    ADD HL,HL
    ADD HL,HL ;x32
    LD BC,(ADDR2)
    ADD HL,BC
    LD BC,(ADDR1)   ;
    ADD HL,BC
    LD (ADDR1),HL ; VRAM

	LD A,(HL)
	LD (DIMSTR),A
	XOR A
	LD (DIMSTR+1),A

	INC HL
	LD A,(HL)
	LD (ADRSTR),A
	INC HL
	LD A,(HL)
	LD (ADRSTR+1),A

	LD HL,(ADRSTR)
	LD DE,(ADDR1)
	LD BC,(DIMSTR)
	CALL #5C

	POP HL
	XOR A
	RET

;**** END of BLOCK

And return the result : not corret on display the string! oO
note the macro on

ADD_CHAR

is abbreviated to :

MACRO ADD_CHAR PO
        LD    A,(HL)
        CP    PO
        JP    NZ,SYNTAX 
        INC   HL
        ENDM

بواسطة NYYRIKKI

Enlighted (6016)

صورة NYYRIKKI

16-11-2011, 22:39

No hard feelings, but so far I have not found single byte from your example that I could say would be correct. -> Please try again.

(Sorry, I will not read all your code or make routines for you, but I will answer when ever you have such a good questions about MSX programming in general)

بواسطة DanySoft

Champion (452)

صورة DanySoft

16-11-2011, 23:39

Are you sure? Perhaps this listing should run the function String (Str, VRAM, X, Y).
Add This listing to my Source ...
:

  • LD IX, FRMEVL
    CALL CALBAS; Evaluate expression
    LD A, (VALTYP)
    CP 3; text type?
    JP NZ, TYPE_MISMATCH
    CALL CHKCHAR

...and meet me if it works well but will not repeat in the future, thanks!
Tongue

بواسطة Poltergeist

Champion (280)

صورة Poltergeist

17-11-2011, 16:48

My Z80 knowledge is rusty, to say the least, but you are calling with ("string",var,var,var). However, you are handling everything as the same string, and that seems incorrect... The string is terminated after the second quotations mark, and everything after that is not a string... You could try ("string,var,var,var" ), but you will need some routines to convert strings to numbers.

بواسطة DanySoft

Champion (452)

صورة DanySoft

17-11-2011, 21:47

It 'true, but I still have not solved the problem, try asking the author to Stefan Boer source ....
However I am still working to resolve the problem ....
See you soon!

... And the make this source is necessary for future x Application & Utility ! Tongue

بواسطة DanySoft

Champion (452)

صورة DanySoft

17-11-2011, 22:24

By the way, since the source I found on the Internet, but it was almost impossible that supported only two parameters: byte and word but not the string ...
But examine the source MEMMAN, TV, TL and TK that supported the strings but it was difficult. Sad

بواسطة DanySoft

Champion (452)

صورة DanySoft

20-11-2011, 16:09

LOL! DONE!!!!

CALL STRING ("MSX",6144+5*32+2) send to VRAM ad 6144 (screen1) the string !

My source is all : BYTE, WORD AND STRING!!
This send the string to vram (0-FFFFh)

DanySoft. Wink

P.S.: The CALL is high necessary to make editor and utility, replace the LOCATE and PRINT with CALL STRING!
Bye Bye