Open lonetech opened 2 years ago
Nice work! I can't speak for the repositor, but I believe that unless a routine is required for compiling the build, it's inclusion into the codebase is contraindicated. That's not to say that submissions are unwelcome. Durexforth acquires great power very easily. I think it's the C64's best kept secret.
Nice! Maybe it would fit in compat.fs as an optional include?
It does fit the compat.fs pattern as a word with standard functionality that isn't currently in use. I'd be quite happy with that.
Perhaps it's corollary would also be appropriate? XY-AT ? XY@ ? PLOT ?
EDIT: SETCUR in V.fs is this, but uses SYS?
: setcur ( x y -- ) \ hidden in v
xr ! yr ! $e50c sys ;
vs.
code setcur ( x y -- )
lsb lda,x
inx,
lsb ldy,x
inx,
w stx,
tax,
$e50c jsr,
w ldx,
;code
That's jumping inside the PLOT routine, to the set part. The $fff0 vector points to $e50a, which presumably does a branch if the carry flag is set (bcs) before falling through to $e50c. This sort of shortcut might make it incompatible with e.g. Commodore 128 80-column mode.
It is a significant find, though. It may make sense to change its name to at-xy and unhide it.
Fun, fun, fun!
: setcur ( x y -- ) \ hidden in v
xr ! yr ! $e50c sys ;
code at-xy ( x y -- )
lsb lda,x
inx,
lsb ldy,x
inx,
w stx,
tax,
$e50c jsr,
w ldx,
;code
size setcur \ 20
size at-xy \ 15
A pull request with this addition would be welcome. I suppose it should be added to documentation and changelog, too.
Guys, three things:
1 It can be done much simpler way on good old C-64: : get-xy ( – x y ) 211 c@ 214 c@ ; : goto-xy ( x y – ) 214 c! 211 c! ;
This doesn't set the screen pointers properly,
: goto-xy ( x y – ) 214 c! 211 c! ;
Alas, you're right; X works OK, but Y (214) seems to make sense just as read-only. Probably during my quick-check I used the value that moved cursor into the current line and on first glance it looked OK.
It's great fun to jump into the Kernal.
: goto-xy ( x y – ) 214 c! 211 c! $e56c sys ;
: goto-xy ( x y -- ) 214 c! 211 c!
$e56c sys ;
: try page
40 0 do 25 0 do j i goto-xy
118 emit loop
loop ;
Indeed. I have to admit my second mistake: since Durex Forth strives to be ANS-standard compliant, that word has to be named AT-XY, unfortunately, not GOTO-XY, But my new proposal for the name of „a word, that returns character code at X, Y” is XY@ ( x y -- char ) (on PC it would return character code and attribute byte).
Its code will be rather simple: : XY@ ( x y -- charcode ) 40 + 53272 C@ 16 / 1024 + C@ ;
It is fun to not presume from where screen memory may be obtained. : )
I didn't see where in the library at-xy was, so I cobbled one together using kernal plot:
Do you think it might be worth including somewhere?
It doesn't preserve interrupt disable, which might be something to improve. In assembly it would use CLC.
The routine itself would be grouped with page and emit, so I guess the norm here is assembly routines in io.asm. I did the exercise to convert to
code
:That also worked. It's rather cumbersome code, though, mostly dealing with ABI conversion. Still
size
reports the code version as smaller than the sys version.Evidently, I am a total newbie at 6502 assembly.