Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
21 May, 2013, 08:47:01 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: [Z80] Jump to a specific point in an edit buffer -  (Read 373 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:41:21
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Topic starter
Total Post Ratings: +492

View Profile
« on: 08 January, 2012, 07:55:40 »
0

The subject line mostly explains what I want to do. Inside of the OS program editor, I'm wondering what the easiest way is to "jump" to a point in the edit buffer. I don't want any scrolling, any adjusting of the cursor position on the screen, really any noticeable changes to the user. I just need the edit pointers to be adjusted and for the data in the edit buffer to be moved around properly. I probably explained that awfully, so let me sketch it out. I want to be able to start with a program in the edit buffer like it was just loaded:

X...............
................
.........XXXXXXX
XXXXXXXXXXXXXXXX


And "scroll" to a certain byte:

XXXXXXXXXXXXXXXX
XXX............
................
...........XXXXX



I feel like there's some easy way to do this involving a bcall or two instead of having to do the copying and pointer updating myself, but I don't know what it is. Sort of like an instant goto, but without any actual displaying. If you can only think of a way to do it with the displaying, that might be acceptable as well, so feel free to suggest whatever comes to mind.
« Last Edit: 08 January, 2012, 07:57:47 by Runer112 » Logged
ZippyDee
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 12 May, 2013, 10:03:36
Date Registered: 21 March, 2011, 03:15:07
Location: Yes.
Posts: 704


Total Post Ratings: +73

View Profile
« Reply #1 on: 08 January, 2012, 07:57:20 »
0

Is it that difficult to use a ldir and update the pointers? I don't think there's really anything else that needs to be done, is there?
Logged

There's something about Tuesday...


Pushpins 'n' stuff...

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:41:21
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Topic starter
Total Post Ratings: +492

View Profile
« Reply #2 on: 08 January, 2012, 07:59:58 »
0

That works, but I feel that there's some OS routine that will do it for me and save me 10 or 20 bytes.
« Last Edit: 08 January, 2012, 08:00:22 by Runer112 » Logged
ZippyDee
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 12 May, 2013, 10:03:36
Date Registered: 21 March, 2011, 03:15:07
Location: Yes.
Posts: 704


Total Post Ratings: +73

View Profile
« Reply #3 on: 08 January, 2012, 08:03:02 »
0

None that I know of...I thoroughly looked over all the edit buffer routines that I found when I was working with some edit buffers before, and I don't recall anything like that. I think I just wrote my own to do that.
Logged

There's something about Tuesday...


Pushpins 'n' stuff...

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:41:21
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Topic starter
Total Post Ratings: +492

View Profile
« Reply #4 on: 08 January, 2012, 08:05:53 »
0

I know Axe has a method of doing it for errors at least. I believe this is how Axe currently instantly scrolls to errors, and it does no manual copying or edit pointer updating. So that makes me think there's something similar that I can do for my purpose of simply adjusting the edit buffer.
Logged
FloppusMaximus
LV5 Advanced (Next: 300)
*****
Offline Offline

Last Login: 09 May, 2013, 05:05:29
Date Registered: 03 October, 2010, 00:02:51
Posts: 286

Total Post Ratings: +52

View Profile
« Reply #5 on: 08 January, 2012, 09:39:04 »
+2

I don't think there is any routine to do exactly what you're saying.

CursorToOffset (BC 494B) will scroll the editor to a given offset; i.e., it rewinds to the start of the buffer, then moves forward by (errOffset) bytes, displaying tokens as it goes (using the large or small font depending on the API flags.)  It then calls DispEOW to display the remainder of the screen after the cursor.  BC 4CD8 does the same as CursorToOffset except without the DispEOW.

(Displaying tokens one at a time is, as far as I know, the only way the OS ever handles scrolling.)

If you want to use one of these routines, you need to set curRow/curCol to the initial cursor position beforehand (e.g., for the program editor, you'd want to start at row 1, column 0, and display a colon character), and of course winTop and winBtm need to be correct.

To move to a given position without displaying anything, you could do something like this (untested):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
B_CALL BufToBtm
ld hl, (editTop)
push hl
ld bc, (errOffset)
add hl, bc

ld de, (editCursor)
sbc hl, de
add hl, de
jr c, offset_invalid

ld (editTop), hl

B_CALL BufToTop
pop hl
ld (editTop), hl
Logged
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Today at 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #6 on: 08 January, 2012, 10:53:54 »
+1

I think the ldir is the best route.  I mean you'd save less than 10 bytes if a bcall did exist, and plus its faster.  The one you linked to is not the version Axe uses, it had the same bug as my previous attempts.  The fixed version I posted on cemetech here.
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:41:21
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Topic starter
Total Post Ratings: +492

View Profile
« Reply #7 on: 08 January, 2012, 11:09:18 »
0

That is a great approach, FloppusMaximus! The best part is that your solution perfectly fits my more general goal, though I didn't even tell you what it was:

  • While the program editor is open, save the edit buffer's state
  • Move all the edit buffer data to one end
  • Parse the (now gapless) data
  • Restore the program editor to its original state like nothing ever happened

The B_CALL(_BufToBtm) at the start of your routine perfectly takes care of step two. And since the position I'm jumping to is just a saved (editCursor), calculating and validating the jump point can be completely cut out! So for my purposes, everything I need to do boils down to just this:


1
2
3
4
5
6
7
8
9
10
11
12
ld hl,(editTop)
push hl
ld hl,(editCursor)
push hl
B_CALL(_BufToBtm)
call ParseProgram
pop hl
ld (editTop),hl
B_CALL(_BufToTop)
pop hl
ld (editTop),hl


Excellent thinking, FloppusMaximus. Grin I may end up just trying to parse the data without removing the edit gap if if the code to do so is smaller overall, but for the question I asked, you've given what must surely be the best answer.
« Last Edit: 08 January, 2012, 11:24:04 by Runer112 » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 1.418 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.