Skip to main content
gamedev.net
🔒 Locked

Direct memory writes

Started by Boenre Nov 29, 2001 at 12:00 AM 9 replies 400+ views
Original Post
Boenre
Boenre
Ok. Out of SHEER boredom, I''m writing a simple (but purportedly quite fast) MS-DOS text library, using mostly (fast) direct memory writes as opposed to (slow) bios calls. I''m all good, except I''d like to be able to allow switching between video pages to allow a back-buffer-like setup, where someone could write a full screen all full of wonderful, colorful text, and in a single interrupt, switch to a blank screen only to be able to later switch right back. I KNOW how to switch video pages (at least, I know the interrupt), I just don''t know how to directly write to other pages. For the default page, it''s easy--just write to segment 0xb800 (for color, anyway) and be done, but does anyone know the memory address for different pages? What''s the deal? Also, is there a faster (or somehow better or more elegant or what have you) way to: show/hide the cursor, move the cursor, set the active page, or maybe even switch text modes? Faster meaning faster than using interrupts. And while I''m on the subject, does anyone know the code to wait for retrace when in text mode? This could come in quite handy if I get the whole writing-to-other-pages thing down. I know how to wait for retrace in VGA mode, but is it the same when in text mode? That''s all for now. As soon as I can remember the myriad of other questions I had about how to write a direct-memory-writing DOS text library, I''ll ask ''em.
Boenre
Boenre
Anyone? Someone? Hello?
Drizzt DoUrden
Drizzt DoUrden
Stumped me.

Memory is some confusing stuff.

Good Luck.

------------------------------

"He who fights with monsters should look to it that he himself does not become a monster... when you gaze long into the abyss, the abyss also gazes into you..."~Friedrich Nietzsche
------------------------------Put THAT in your smoke and pipe it
Boenre
Boenre
Well, I''m pretty sure I tried the simple 4000 bytes-later-for-the-next-page dealie, and I''m pretty sure it didn''t work. I''ll give it another shot, double-checking EVERYTHING to make sure I''m doing it right. If all else fails, I think what I''ll do is bust out debug, run some pseudo-assembly on it to write some characters to the second page, and then search for those characters and see where they pop up. I''ll be sure to let all the faithful, anticipating, salivating readers know exactly what works!
Boenre
Boenre
Hmm... are you sure? I TOTALLY just wrote to b800:1000, switched to page 1, and there it was (in the upper left corner of the screen)! And switching back to page 0, it was gone. I''m working in 80x25 mode, 16 color (mode 0x03). Now... as I''m just learning, switching to 80x50 mode isn''t as simple as specifying a different al as you call interrupt 0x10 with ah set to 0. Is that right? I kept trying it on my old 386 and it didn''t EVEN work. So, after searching the internet high and low, I found that you have to call interrupt 0x10 with ah set to 0x11 and al set to 0x12 to get it to shimmy on up into 50 row mode. Is this just my 386 being weird, or is that really supposed to be how it''s done? Anyway... that brings up another dilemma... the address for page 1 of 50 row mode is different... it''s somewhere between 0x2000 and 0x3000 (as I found by randomly poking values into various places in segment 0xb800 while in 80x50 mode). It''ll take me a few more minutes to nail down the exact, upper-left corner offset, as randomly trying values can take a while. Anyway... that about wraps it up, I guess. Thanks for your help. Oh... by the way... since switching to 50 row mode technically keeps you in the same screen mode, do you know a way to detect how many rows you''ve got goin'' on? Using the "get screen mode" interrupt, it still returns 0x03 when in 80x50 mode, so I''m just wondering if I have to scrap my GetScreenMode() function because it''ll always return 3 (regardless of 80x50 or 80x25), or whether there''s a way to detect the number of rows (or scan lines or whatever''s significant). No big deal, really... it''d just be nice for completeness'' sake. Thanks again.
Boenre
Boenre
Ah HA!!! Actually, that IS most helpful. I was switching pages a TOTALLY different way, and I think I like your way better. I was using the bios, using interrupt 0x10 with ah set to 0x05 and al set to the page number (or something like that). I guess the difference is, your way tells the card a different address to start drawing the screen from, whereas mine calls the bios to do pretty much the same thing, but with funny memory addresses. I''ll give your way a whirl, as it DOES seem to be a little more... sure-to-work-every-time. For reference, the page offsets I found are: page * 0x1000 for 25 line mode, and page * 0x2040 for 50 line mode. Anyway... the whole "linear" deal makes more sense, so I''ll probably switch to that. Thanks for the help!
Boenre
Boenre
Works like a charm, I say.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.