VOGONS


Quake2 + Acebot for DOSBox (128mb)

Topic actions

Reply 160 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie
ggorts wrote:

I think dosbox isn't the best way to test it. 🙁 Perhaps I'll switch to dosbox-x and put it to the test.

Your code only seems to be setting the screen but not doign anything else unless i copied it wrong (I'm trying to condense it into separate functions so SWimp_endframe isn't a mess anymore)

Reply 161 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

I also just pushed now code that divides the banked and planar into two separate functions, youll have to if 1 them to play around. This will make it easier if you figure it out and send me a diff

Reply 162 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

Also you can use -vgaonly to make sure you're not accidentally using a VESA mode. That will only add 320x200 , 320x240 (if you if 1 the add planar function) and the banked SVGA modes.

One thing I noticed is that screen_width is not being used at all, just being set.

Reply 164 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

what i'm saying is i think you only need to do the vregsetc and you can remove the changing to byte mode etc in drawbanked, and you only need taht select function.

The code is locking up at the dosmemput, so you're probably writing to something improperly. If you comment that line out you can invisibly type sw_mode 0 and get back to 320x200

Reply 166 of 862, by ggorts

User metadata
Rank Member
Rank
Member

One of the Quake 1 functions for planar mode is: VGA_UpdatePlanarScreen, in d_copy.s file. The function has a comment:

// copies 16 rows per plane at a pop; idea is that 16*512 = 8k, and since
// no Mode X mode is wider than 360, all the data should fit in the cache for
// the passes for the next 3 planes

It seems the easiest way to hook their "library" somehow, especially since it's in assembly.
Edit: here appears the other part:

	if (pcurrentmode->planar)
{
for (plane=0 ; plane<4 ; plane++)
{
// select the correct plane for reading and writing
outportb (SC_INDEX, MAP_MASK);
outportb (SC_DATA, 1 << plane);
outportb (GC_INDEX, READ_MAP);
outportb (GC_DATA, plane);

for (i=0 ; i<(height << repshift) ; i += reps)
{
for (k=0 ; k<reps ; k++)
{
for (j=0 ; j<(width >> 2) ; j++)
{
backingbuf[(i + k) * 24 + (j << 2) + plane] =
lvid->direct[(y + i + k) * VGA_rowbytes +
(x >> 2) + j];
lvid->direct[(y + i + k) * VGA_rowbytes + (x>>2) + j] =
pbitmap[(i >> repshift) * 24 +
(j << 2) + plane];
}
}
}
}
}

Which contrasts with non-planar mode:

		for (i=0 ; i<(height << repshift) ; i += reps)
{
for (j=0 ; j<reps ; j++)
{
memcpy (&backingbuf[(i + j) * 24],
lvid->direct + x + ((y << repshift) + i + j) *
VGA_rowbytes,
width);
memcpy (lvid->direct + x + ((y << repshift) + i + j) *
VGA_rowbytes,
&pbitmap[(i >> repshift) * width],
width);
}
}

I wonder if the planes were previously enabled:

	// enable all planes for writing
outportb (SC_INDEX, MAP_MASK);
outportb (SC_DATA, 0x0F);

And this shows the way the buffer is filling I think:

	VGA_planar = pcurrentmode->planar;
if (VGA_planar)
VGA_rowbytes = lvid->rowbytes / 4;
else
VGA_rowbytes = lvid->rowbytes;

Reply 167 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

Right, I've seen all this stuff (I may have missed the enabling planes write though, good catch). The biggest problem is I don't really understand all of it. I've never really done any sort of direct low level programming before and DOS VGA program is more or less a dead art now.

lvid->direct I assume is the actual vid.buffer. There is a separate branch where I tried to implement all this code over and ran into issues. Honestly, I'm just concerned about getting 320x240 in. The other weirdo modes like 320x256 (who uses that?!) can all get lost.

Reply 168 of 862, by ggorts

User metadata
Rank Member
Rank
Member

Is the 320x240 lfb mode supported by the older systems which could potentially run q2dos? If not, then I'm hoping that there is source code available with a better example of mode-x. Perhaps the demos. If the examples are not good, and the libraries are not useful, then the mathematics of the planar mode seems like a last resort. I mainly pasted the snippets above for future reference, they may be the one of the few working examples that are applicable.

Reply 169 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

I'm trying to avoid libraries entirely here. It's a matter of me not understanding and nobody here can hold my hand through it.

I have planar output some garbage now instead of just crashing.

Reply 171 of 862, by Maraakate

User metadata
Rank Oldbie
Rank
Oldbie

It's drawing a very small portion and is overlapping. So it's kind of close but the math is wrong and I don't understand it.

Anyways, its pushed if you want to play with it

Reply 172 of 862, by ggorts

User metadata
Rank Member
Rank
Member

Thanks, I'm looking forward to looking over the code!

Edit: attached an example from a demo, I think. The code looks actually interpretable.

Attachments

  • Filename
    LIB.C
    File size
    8.49 KiB
    Downloads
    41 downloads
    File comment
    another mode-x example
    File license
    Fair use/fair dealing exception

Reply 174 of 862, by ggorts

User metadata
Rank Member
Rank
Member

It loaded in dosbox-x better than vanilla dosbox. I'll try to compare it to other examples, hopefully ones that don't demonstrate writing by pixel.

Edit: using the VideoRegisterSet function was a good idea.

Edit: http://fly.srk.fer.hr/GDM/articles/vgamodex/vgamx1.html

I guess the math is all that's left, but this is insightful (320x200 example):

 To implement paging we simply divide up our video memory into four sections, each 200 lines high and set the start address to the top of each page. For example, page 0 would have a start address of 0000h, page 1 would start at line 200 and would have a start address of 3E80h or 16000 (80 bytes per line * 200 lines) The next two pages would have starting addresses of 7D00h (32000) and BB80h (48000) respectively.

Note that we only tell the VGA controller where the offset is in video memory, not the whole address. The VGA graphics screen still begins at segment A000h, however we are telling it to change where it starts reading in video data for display purposes. In our paging example above, our page 0 data is located at the absolute address of A000h:0000h, page 1 at A000h:03E80h, etc.

Attachments

  • Filename
    modex.txt
    File size
    28.1 KiB
    Downloads
    43 downloads
    File comment
    another tutorial in code
    File license
    Fair use/fair dealing exception

Reply 176 of 862, by ggorts

User metadata
Rank Member
Rank
Member

Impressive! I'm still trying to imagine how it works. I'll take a look asap.

Should be simple to bypass, but I have this (I think it's byte versus char type):

dos/vid_dos.h:22:14: error: redefinition of typedef 'pixel_t'
dos/../ref_soft/r_local.h:76:23: note: previous declaration of 'pixel_t' was here

Reply 178 of 862, by ggorts

User metadata
Rank Member
Rank
Member

It's very good progress. I can see almost an image, especially the console. The screen dimension is correct and there is the full screen, it's just the drawing routine that needs adjustment. The register bits must be all correct, too.

That was brilliant in adapting the q1 routine. I didn't think to swap out the buffer names.

Edit: the screen_offset is the only factor left?