Alright, I got some REALLY cool stuff to show here, or at least I think it's cool.
So, to start off with, I wanted to get bitmap graphics work.
On IBM compatibles with VGA cards, there are two main bitmap VGA modes. You have mode 0x12, and mode 0x13. 0x12 is a planar mode requiring constant switching of memory banks to do anything. It's incredibly annoying to program for, and I haven't done it, or even tried. 0x13 on the other hand is a good, old, regular linear mode. It has a resolution of 320x200, and a 256 colour colour palette reassignable using 6bpc/18bpp colours. For the moment I am going to use the default palette.
Note, this is all compiled using Turbo C as mentioned before. If you want to try these out, grab DOSBox, Turbo C, and the source code. If there is demand I can release the compiled .EXEs
All code is for you to do with as you wish. This is all experimentation before I put time into creating a serious application.
So, my first test was to see if I could, on a delay, fill a screen completely with red.
FOREWARNING: I am linking pictures that take up a small amount of data. Metered users beware.
First off, here is the code:
https://pastebin.com/cS2wXkSuI am using the dos.h delay function, which is completely unpredictable based on what machine you use it on. I had it set to 25ms and the screen filled up instantly on my Prescott laptop, where on DOSBox it takes much longer. My calculations also show it should take around 26 minutes, but those could be wrong. Serious programming won't use this.
The program works perfectly besides that, slowly filling up the screen as you can see the linear buffer fill up "line by line". Here's a picture of it part way:
https://prnt.sc/i8hx1wSo, next up I needed more than one colour. I have 256 of them! I want to see them all. This requires a slight code modification as such:
https://pastebin.com/Y5bzBW8wThis just cycles what colour is being placed for each of the 256 available in the default palette. Here's another picture:
https://prnt.sc/i8hxm7 Looks kinda cool, right?
Anyways, my next job is to somehow get bitmap graphics to work. Of course, the simplest file format is one of raw, unorganized data, and that's what I'm using. I have 256 colours, 0x00 to 0xFF, but in plain DOS I have no way to make an image like that without a third party program, or first...
This program uses a very long 1D array that is formatted like a 2D array, in which I have manually (yes, manually) placed each colour in a grid increasing. Here's the code:
https://pastebin.com/USxmP4rXThis program writes that array to a file, and then reads it back and displays the data onscreen for confirmation. Here's an image:
https://prnt.sc/i8hxy2Sweet! I, however, do now need a program to display this. Here is that program:
https://pastebin.com/at2Kcz7xThis program can display that image generated (or any image if you change the array around) at the top left of the screen as such:
https://prnt.sc/i8hy9kPerfect, but making an image in that array is tedious and difficult. While I could write myself a fancy image editor, the GIMP is already there for me, and can output in this exact raw data format, so long as I give it the right palette. Image:
https://prnt.sc/i8hz9aWith graphic made, it's just a case of renaming it IMGOUT.VGA (just a random extension), plopping it in the root directory, and re-running the program:
https://prnt.sc/i8hz3uNow, this is not all I have done. My current project is to clone one of my favourite puzzle games, Puyo Puyo. (Dosso Dosso anyone?) I need some stuff for this. Modern games are run on game loops dependent on a timer. This is possible on DOS too, with either the RTC, or what I've been experimenting with, the PIT (Programmable Interval Timer). Now, this thing is annoying and complicated to deal with, and while I got a working interrupt loop, uh, working, I couldn't seem to adjust the time used, so I am going to look at the RTC, and see if that works any better for me (like a coward).
Anyways, here is the code I wrote:
https://pastebin.com/bZ7zNV0LI'm going to no longer post pictures here, as there is not much of a need to, and I am too lazy to compile the rest. I will, however, explain what I've done here. All this program does is program the PIT to run at a clock rate (changing the values sent do nothing, so I am likely doing something wrong here, any help?) and then install an interrupt handler at vector 0x08 (IRQ0). This then counts up a number and displays it to screen. This works perfectly.
One last thing, keyboard input. This is easy enough, the BIOS stores keyboard input into a buffer, and it can be read out using BIOS interrupt 0x16. Here it is:
https://pastebin.com/YkHW1aBdThis, on a delay of 100ms, or it's supposed to be, just reads the keyboard buffer, prints it to screen, and then halts if it reads a lowercase k. Works perfectly.
So, this is my progress so far. Sorries for the long post, I just have a lot of stuff to show. Right now, I have to figure out a more reliable timer. wiki.OSDev.org has been a major resource for me, and it claims a better reliability with the RTC, so that's something for me to look into. I also need to ask a quick question. How do I figure out where the executable is on the drive so I can access files that are in the same directory?
Anyways, thanks for reading this far. I hope my petty victories aren't too boring, but I've had a lot of fun.