|
Post by guest on Jan 28, 2015 14:46:01 GMT
So, I am trying to utilize the kernel print routines, and was reading through mapping the c128 and came across $EB and $EC and they seem like a very good place to just put your x and y and print... so I wrote this little test program:
10 poke 235,4:poke236,10:print"hello"
and ran it... and got a very unexpected result... the value I placed in 236 was used immediately upon print, but the value in 235 did not take effect until the second character printed... So I would up with something like below:
ello
h
So, obviously the print routines don't read $eb value before output, but do read $ec.. so I guess my question is where is the right place to put the y value so that it is picked up immediately? I see there is a kernel plot routine at $cc6a but figured if I could just poke the x and y properly save myself the overhead of the call, since I assume the output routines probably do that themselves anyway.
Any ideas?
|
|
|
Post by hydrophilic on Jan 31, 2015 9:45:35 GMT
These are internal variables intended to be updated "behind the scenes" by the OS (Editor ROM). If you try to update them directly, expect strange results (like you reported).
The most compatible way to change cursor position before printing is to first call "Plot" ($FFF0).
Another alternative is to set (POKE) the column into $EC and, *the important part*, set the line into $EB and call $C15C. The routine at $c15c sets up screen pointers and line links based on the line# stored in $EB. After, you can call 'print' ($ffd2) like normal.
Example:
ldx #column ldy #row stx $ec sty $eb jsr $c15c ... [do print routine]
I hope that helps!
*FYI* today FREE-FORUMSs gave a totally different rendering of a 'code block' compare to the past... check out my other posts... they look good, but this one looks crappy! Don't blame me... some idiot has been forking the rendering code!! Did I mention !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (Stupid x60)
|
|
|
Post by mirkosoft on Feb 3, 2015 13:08:57 GMT
Easier way and memory cost less is Kernal PLOT routine usable also in Basic:
Assembler ldx #row ldy #column clc jsr $fff0 (65520) ... [do print routine]
Basic SYS65520,,row,column,0:PRINT"anything"
Miro
|
|
|
Post by hydrophilic on Feb 4, 2015 4:13:53 GMT
Good job Miro! I was automatically thinking assembly, when obviously the original post was in BASIC :/
|
|
|
Post by VDC 8x2 on Feb 4, 2015 5:46:25 GMT
Why not just use the CHAR command to position the cursor then print?
Better than pokes I say.
|
|
|
Post by guest on Feb 6, 2015 19:50:18 GMT
Thanks guys.
|
|
|
Post by guest on Feb 13, 2015 1:55:26 GMT
Nope, no dice, the routines do NOT perform as advertised... according to the Mapping the Commodore 128, the call to c01b should move the cursor to the position pointed to by Eb/Ec (row/column)
But they just dont work as advertised, the column seems to take effect correctly, but the row does not take effect until after 1 character is printed... here is the code, does not perform as advertised in 40 or 80 columns
ldx $eb inx inx stx $eb jsr $c01b lda #$40 jsr ffd2 jsr ffd2 rts
this should, if it behaves as described move the cursor down two rows and then print out 2 @, instead it prints 1 @ on the current line, even though the PLOT call shoudl have moved it, and the next one 2 rows down.
|
|
|
Post by hydrophilic on Feb 19, 2015 9:09:27 GMT
That is a very interesting problem...
The code at $c01b only updates the VDC "cursor position". (see code in ROM at $cd57)
The code at $c01b does *NOT* set the position where "print" will occur ($ffd2 or, more low-level, $c72d).
The best way (most compatible) is to first call PLOT (at $FFF0)... after you can print at any position (whatever co-ordinate was given to PLOT).
Edit Sorry that does not DIRECTLY answer question about $eb and $ec...
Those are "internal" variables... you would need to invoke sneeky/internal routines in the ROM for them to work in reality...
Umm, I guess there might be (or was?) some CBM article about hacking those variables... sadly I do not know..................
/Edit
|
|
badco
Windows User
Posts: 8
|
Post by badco on Jun 19, 2015 14:28:32 GMT
Its a nature of the plot command, the carry flag determines if the plot sets the cursor to the location passed, or whether it loads those locations with the value of the current cursor...
|
|
|
Post by hydrophilic on Jun 21, 2015 9:20:34 GMT
Not sure why there seems to be so much confusion... so here below is a simple BASIC program to demonstrate.... 10 input"x (column)";x 20 input"y (row)";y 30 input"string";s$ 40 print chr$(147); :rem clear screen 50 sys 65520,,y,x :rem plot 60 print s$; The only weird thing about "PLOT" (decimal 65520 = hexadecimal $fff0) is that the row (Y) comes first and the column (X) is second [if you are an ML programmer, this means X register has row(Y) and Y register has column(X)] If you doubt my published code above, then download PRG file [ anywhere (123 B) ] and try for yourself... Edit
Or, like VDC 8x2 said, use CHAR: 10 input"x (column)";x 20 input"y (row)";y 30 input"string";s$ 40 print chr$(147); :rem clear screen 50 char ,x,y :rem plot 60 print s$;
If you doubt VDC's method, the download PRG file [ anychar (117 B) ] and try for yourself...
|
|