OxC0FFEE Posted September 26, 2022 Share Posted September 26, 2022 (edited) In a game loop I'm trying to use the stick to move the text-mode cursor in the text window in the easiest, code and cpu-efficient way. Seems like using location 84 and 85 is the way (note: I don't need the high bit, stored in 86, because in text the column will never exceed 40), but the cursor keeps disappearing. I'm assuming when the cursor location is updated using poke, the cursor goes invisible. Things I've tried: Move cursor to new location, poke 752 to turn cursor back on. Doesn't work. rem get stick position, update posx,posy ... rem row is 84, column is 85 poke 84,posy:poke 85,posx poke 752,1 print CHR$(29) to print a blank character, has the side effect of showing the cursor, but offset by a row. I need the cursor at the actual cursor location, not one below it. poke 84,posy:poke 85,posx print CHR$(29); Edited September 26, 2022 by OxC0FFEE Quote Link to comment Share on other sites More sharing options...
vitoco Posted September 26, 2022 Share Posted September 26, 2022 The problem is that the cursor is managed by the OS screen drivers. You can change some cursor registers, but most of them will have an effect only after an I/O operation. 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 26, 2022 Share Posted September 26, 2022 The problem with the text cursor is that it's only really generated when text is being output. Simply using POS. or poking in a new set of values isn't sufficient. If you're dealing with the text window as in 4 lines at bottom of a graphics mode then you're using the wrong locations. 656 is text window cursor row. 657,658 is the column. You might experience annoyances such as cursor remnants being left behind or unwanted scrolling or line insertions. In a lot of cases you can be better off just calculating and poking in a cursor programatically. Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 26, 2022 Share Posted September 26, 2022 (edited) Sample program. This shows the problem with putting a generated cursor in the last position, it will force a scroll. You could always limit to column 38 I guess. Line 40 is just to print a single inverse space for the cursor. Uses a special trick also - normally Basic won't let you touch IOCB #0 but if you use #16 it lets you use it (although in this case you could probably just leave the #16 out altogether) 10 GRAPHICS 7:POKE 752,1 20 X=20:Y=1 30 POKE 656,Y:POKE 657,X:POKE 658,0 40 ? #16;"{inverse SPACE} "; 50 H=PTRIG(0)-PTRIG(1) 60 S=STICK(0):V=(S=13)-(S=14) 70 IF NOT (H OR V) THEN 50 80 POKE 656,Y:POKE 657,X:POKE 658,0 90 ? #16;" "; 100 X=X+H:Y=Y+V 110 IF X=1 THEN X=39 120 IF X=40 THEN X=2 130 IF Y=-1 THEN Y=3 140 IF Y=4 THEN Y=0 150 GOTO 30 Edited September 26, 2022 by Rybags Quote Link to comment Share on other sites More sharing options...
OxC0FFEE Posted September 26, 2022 Author Share Posted September 26, 2022 I'm getting the picture. It might just be easier to poke a fake "cursor" into the right place in the text window. Avoids the needing to tickle the screen editor and the last row/column issue. 2 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted September 26, 2022 Share Posted September 26, 2022 You could just map joystick axes to the four cursor direction keys and print them to the display. Unless I'm over-simplifying the problem somehow. If you're especially worried about efficiency and don't need the OS screen handler's features, you can just bypass it entirely and manage everything yourself. 1 Quote Link to comment Share on other sites More sharing options...
phaeron Posted September 27, 2022 Share Posted September 27, 2022 Not sure if this is a good idea, but you can print a clear tab (Ctrl+Tab) character to force the I/O routines to update the cursor without moving/changing/scrolling text. 2 Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 27, 2022 Share Posted September 27, 2022 (edited) Equally to Ctrl-Tab you can just use 2 x ESC as a non-print character followed by clearing the Esc flag at 658. Change to code in line 40. Cursor suppression and printing spaces no longer needed. This method or Ctrl-Tab as phaeron suggests also gets rid of the scrolling/residual cursor problem. Actually you could probably rework the whole thing to just use the control arrow as FJC suggests and not worry about tracking the cursor position. If you need to get the cursor pos you could just read locations 656/657 to get it. 10 GRAPHICS 7:REM POKE 752,1 20 X=20:Y=1 30 POKE 656,Y:POKE 657,X:POKE 658,0 40 ? #16;"{ESC ESC}";:POKE 674,0 50 H=PTRIG(0)-PTRIG(1) 60 S=STICK(0):V=(S=13)-(S=14) 70 IF NOT (H OR V) THEN 50 80 POKE 656,Y:POKE 657,X:POKE 658,0 90 REM ? #16;" "; 100 X=X+H:Y=Y+V 110 IF X=1 THEN X=39 120 IF X=40 THEN X=2 130 IF Y=-1 THEN Y=3 140 IF Y=4 THEN Y=0 150 GOTO 30 Edited September 27, 2022 by Rybags Quote Link to comment Share on other sites More sharing options...
danwinslow Posted September 27, 2022 Share Posted September 27, 2022 (edited) 20 hours ago, OxC0FFEE said: I'm getting the picture. It might just be easier to poke a fake "cursor" into the right place in the text window. Avoids the needing to tickle the screen editor and the last row/column issue. That's what I wound up doing. restore last 'under' if any, save what's under new location, place cursor. It ran in a pokey interrupt. Edited September 27, 2022 by danwinslow Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 27, 2022 Share Posted September 27, 2022 Second method I put above should work without unwanted scrolling. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.