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)
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
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.
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
One of the Quake 1 functions for planar mode is: VGA_UpdatePlanarScreen, in d_copy.s file. The function has a comment:
1// copies 16 rows per plane at a pop; idea is that 16*512 = 8k, and since 2// no Mode X mode is wider than 360, all the data should fit in the cache for 3// 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:
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.
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.
I guess the math is all that's left, but this is insightful (320x200 example):
1 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. 2 3Note 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.
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.