@Clonkex
Here are the basics:
Pixels are 4 bits each. Each sprite and 8x8 pixel tile can select one of 4 palettes. Colour 0 is always transparent. Colours in the palette are 9-bit and are stored in their own dedicated RAM.
(Here, the last 7 colours in palette 3 are animated to make lights change colour and give a flickering light effect from the torches on the wall.)
Two tile maps are stored in VRAM. They can be 32x32, 64x32, 128x32, 32x64, 32x128, or 64x64 tiles in size. Each tile map has its own horizontal and vertical scrolling setting. The tile maps wrap when their edges are reached, so you can scroll as far as you want by replacing off screen tiles with new ones. Each tile in the map uses 2 bytes:
Priority (1 bit) - Priority flags control which things appear in front of other things.
Horizontal mirror (1 bit) - If set, the tile is mirrored horizontally.
Vertical mirror (1 bit) - If set, the tile is mirrored vertically.
Palette (2 bits) - Selects one of the 4 palettes.
Address (11 bits) - Selects an image stored in VRAM to use for the tile. Each image is 8x8 pixels and uses 32 bytes. With 64 KB of VRAM, an 11-bit address can use an image from anywhere in VRAM, including memory used to store data such as tile maps themselves.
There's a 3rd tile map with no ability to scroll that can replace the 1st tile map on a region of the screen you specify. This can be useful for user interface stuff.
An array of up to 80 sprites is stored in VRAM. Each sprite has the same information as a tile, as well as an X coordinate, Y coordinate, width (8, 16, 24, or 32 pixels), height (same options as width), and link data. Sprites use the same 8x8 pixel images as tiles. If a sprite is larger than 8x8 pixels, it'll use multiple images stored sequentially starting from the address you specified. Up to 20 sprites or 320 pixels of sprites (whatever limit is reached first) can be drawn on each line.
Priority:
Each tile and sprite can be high or low priority depending on its priority flag. Things appear in this order:
FRONT
High priority sprites
High priority tiles from the first tile map
High priority tiles from the second tile map
Low priority sprites
Low priority tiles from the first tile map
Low priority tiles from the second tile map
Background colour
BACK
Sprites' priority flags control where they appear relative to tiles. Link data controls where sprites appear relative to other sprites. Sprite 0 is drawn first. Each sprite's link data specifies which sprite should be drawn next.
Sprites are handled before tiles. By the time tiles are drawn, sprites have been reduced to a bunch of pixels with colours and a priority flag, with no information about individual sprites. Imagine two sprites, which I'll call sprite egg and sprite waffle. Sprite egg appears in front of sprite waffle. However, sprite egg is a low priority sprite and sprite waffle is a high priority sprite. If a high priority tile is drawn in the same spot, it'll cover sprite egg, but sprite egg will still cover sprite waffle. This will result in a sprite egg shaped hole in sprite waffle.
There is no frame buffer. The video chip draws one line and one pixel at a time as it outputs the video signal. That means certain graphical effects can be achieved by changing video related things part way through a frame. The video chip can help you do that by generating interrupts when it reaches lines you want.
This water works by changing the palette part way through the frame.
https://www.youtube.com/watch?v=8cr1rqVcIhA&t=20s
The background here uses the second tile map. It achieves more complex parallax scrolling by changing the horizontal scroll setting multiple times throughout the frame.
Quote: "So did you generate the music using the Yamaha.... YM-whatever? No idea how you do that sort of thing (I always assumed the Mega Drive used some sort of midi system)."
I made the music using LMMS and a VST plugin that emulates a chip very similar to the YM2612. It's stored in the game using my own format that's similar in concept to midi. It's series of instructions that my music playing code interprets.
Here's the music data in a form that probably makes it pointless to post:
D7 22 08 FC 91 FF F3 7F DC FC 73 FF FE 0C 30 F4 73 DA 73 93 A3 0F CF 73 DA 73 A3 F5 03 F4 07 27 CF 77 DA 93 73 57 27 37 57 73 DA 73 D7 88 09 D7 8C 09 93 D9 4A 03 20 73 DA 73 D7 88 09 D7 8C 09 53 D9 43 03 20 F5 0B DA 03 23 DA CB F4 7F DA 77 57 77 97 AB DA A3 2B 23 5B 53 E0 03 23 DA E1 E0 23 53 DA E1 F9 E2 FC 55 FF E0 03 23 DA E1 E0 23 53 DA E1 FB E2 7F DA CF DB FC 37 FF 7F 0F DA CF DC FC 19 FF F3 7F DA F4 07 27 37 57 D2 29 80 73 DA 73 93 A3 F5 0B 03 F4 A1 C1 57 53 7F 77 A3 F5 DF CB F4 7F 71 DA 71 A1 91 73 73 53 9B AF A5 A1 93 53 73 FD DA CB FF DF FC FB FE 7D 71 9D 91 AD A1 F5 05 01 23 31 51 05 01 F4 A3 91 71 F5 05 01 23 31 51 23 DA CB F4 79 71 51 31 99 91 71 51 AD A1 F5 05 01 23 31 51 27 DA 01 F4 A1 91 71 5F DA DF CF DC FC DD FE F2 77 77 7F F3 07 07 0F F2 73 7B DA 7F DA 77 77 7F F3 51 31 01 F2 A1 F3 01 F2 A1 71 51 31 31 51 71 91 F3 01 31 51 E3 E4 E5 E6 D1 02 E3 E4 E5 E6 E3 E7 E5 E6 E3 25 21 03 F2 A3 91 A1 F3 01 21 F2 91 A1 F3 01 21 E5 23 23 F2 A3 F3 23 03 F2 93 F3 03 21 31 57 55 51 01 21 31 51 01 21 31 51 D3 22 81 F2 77 77 7F A3 A3 F3 03 03 F2 A3 93 73 53 77 77 73 53 73 91 A1 F3 05 01 F2 A3 93 73 91 91 F3 07 E5 F2 73 73 53 93 73 53 73 91 A1 53 73 93 F3 03 F2 53 73 93 F3 03 D2 1C 81 F2 79 71 33 53 73 95 91 77 75 71 93 A3 F3 03 21 21 03 03 F2 A1 71 F3 23 03 F2 A3 F3 03 21 31 DF 25 21 03 F2 A3 93 A1 A1 F3 27 DF 55 51 33 23 03 21 21 57 DF F2 73 75 71 33 53 73 95 91 73 73 73 71 71 97 F3 05 01 DF F2 A3 A3 73 A3 93 53 93 A1 F3 01 F2 77 75 71 A1 71 F3 01 F2 71 33 53 DF FC BF FE F9 F3 AF DC FC A1 FE F9 F2 7F DC 2F DC F1 9F DA F2 0F DA E8 D1 02 E8 2F DC 7F DA 5F DA 2F DC F1 AF DA 9F F2 0F 2F DC 7F DA 2F DA 2F DC 9F DA F3 0F DA F2 D3 08 82 7F DD FC 83 FE F9 F4 AF 3F DA FC 65 FE F9 F2 7F DE 5F DA D2 05 82 2F DC 7F DA 2F DA 2F DC F1 AF DA 9F F2 0F DF FC 47 FE FB F3 2F DC FC 29 FE FB F2 3F DC F1 AF DC 5F DA 9F DA E9 D1 02 E9 7F DC F2 0F DA 0F DA F1 7F DC 5F DA 2F 5F 7F DC F2 0F DA F1 9F DA 7F DC F2 2F DA 5F DA D3 65 82 2F DD FC 0B FE FB F4 2F 7F DA FC ED FD FB F2 2F DE 0F DA D2 62 82 F1 7F DC F2 0F DA F1 9F DA 7F DC 5F DA 2F 5F DF FC CF FD F2 7F DC F3 0F DC F2 7F DC 2F DA 5F DA FC B1 FD EA EB EC ED D1 02 EA EB EC ED EA EE EC ED EA EB EC 73 F3 23 27 57 A3 93 57 57 07 37 F2 D3 C5 82 F2 77 77 A7 F3 27 F2 A3 F3 03 27 F2 A7 F3 07 27 F2 77 F3 27 F2 77 F3 07 37 77 07 F2 EC 77 77 A7 F3 27 F2 53 73 97 53 73 57 D2 BF 82 77 77 A7 F3 27 F2 A3 F3 03 27 F2 A3 F3 03 F2 77 33 F3 03 07 37 53 73 DF 23 53 23 53 F2 57 97 DF 53 93 53 93 F2 97 F3 07 F2 DF 77 77 A7 F3 27 F2 A3 F3 03 27 F2 A3 F3 03 F2 77 DF 33 A3 A7 F3 27 73 53 F2 77 77 27 57 DF FD CF DC D7 40 08 20 04 40 01 08 E0 F1 FE 02 06 1F C7 DA 6F 11 01 F0 FE 04 08 51 31 F1 FE 02 06 1F CF DE F2 FE 01 04 01 F1 FE 02 06 A1 51 11 F0 FE 04 08 87 E0 E1 E2 D1 02 E0 E1 E2 E0 E3 E2 F2 FE 01 04 1F F1 FE 02 06 5F A1 F2 FE 01 04 11 51 31 11 F1 FE 02 06 A1 F2 FE 01 04 11 F1 FE 02 06 A1 81 51 81 A1 F2 FE 01 04 11 31 51 31 6F 33 13 F1 FE 02 06 A3 F2 FE 01 04 13 F1 FE 02 06 87 F2 FE 01 04 8F 31 11 F1 FE 02 06 61 51 F2 FE 01 04 1F F1 FE 02 06 5F A1 F2 FE 01 04 11 51 31 11 F1 FE 02 06 A1 F2 FE 01 04 11 F1 FE 02 06 A1 81 51 81 A1 F2 FE 01 04 11 31 51 31 0F 07 37 3D A1 81 61 31 11 61 31 11 F1 FE 02 06 A1 D3 8C 83 C0 D0 BF F0 FE 04 08 AF F1 FE 02 06 1F F2 FE 01 04 07 11 01 F1 FE 02 06 A1 81 63 83 F2 FE 01 04 07 D2 87 83 F1 FE 02 06 1F CF DB 6F CF DF 87 F2 FE 01 04 8F 31 11 F1 FE 02 06 61 51 DF F2 FE 01 04 07 F3 FF 0F F2 FD 61 51 F1 FE 02 06 61 51 DF 1F CD DB 31 5F CF DA F2 FE 01 04 01 F1 FE 02 06 A1 51 11 F0 FE 04 08 87 DF FD CF DC D7 40 08 20 04 40 01 08 E0 F1 FE 02 08 5F CF DA A7 81 61 F0 FE 04 08 A1 81 F1 FE 02 08 5F CF DE F2 FE 02 04 51 31 F1 FE 02 08 A1 61 37 5F CF DB AF CF E4 E5 D1 02 E6 E4 E5 E6 E7 E5 F2 FE 02 04 5F 1F 51 81 F3 FF 01 F2 FD 81 81 51 81 51 31 01 31 51 81 A1 F3 FF 01 F2 FD 81 AF A3 83 53 83 07 C7 F3 FF 07 F2 A1 81 01 F1 FE 02 08 A1 F2 FE 02 04 5F 1F 51 81 F3 FF 01 F2 FD 81 81 51 81 51 31 01 31 51 81 A1 F3 FF 01 F2 FD 81 8F 87 A7 F3 FF 0D 51 31 11 F2 FD A1 81 F3 FF 11 F2 FD A1 81 51 F1 FE 02 08 D3 C3 84 C0 D0 BF 1F F1 FE 02 08 AF F2 FE 02 04 37 61 51 31 11 03 13 37 F1 FE 02 08 D2 BA 84 5F CF DB F2 FE 02 04 3F CF DF 07 C7 F3 FF 07 F2 FD FE 02 04 A1 81 01 F1 FE 02 08 A1 DF 37 C7 F3 FF 37 11 01 F2 FD FE 02 04 01 F1 FE 02 08 A1 DF 5F CD DB 61 8F CF DA F2 FE 02 04 51 31 F1 FE 02 08 A1 61 37 DF F3 01 D7 B0 00 00 B0 00 00 00 00 00 00 00 F2 00 0F DA F2 06 0F F2 03 0F F2 00 07 07 DC 07 07 DA F2 05 0F DA 0F DA F2 00 07 F2 06 07 F2 02 03 F2 01 03 01 F2 02 01 F2 04 01 F2 08 01 E0 E0 E0 E1 E0 E0 E1 F2 07 07 DA F2 03 0F F2 01 0F F2 03 0F F2 01 0F F2 03 0F F2 01 0F F2 06 03 03 F2 07 0F F2 01 07 07 07 07 07 07 07 07 07 07 07 0B 01 F2 06 01 F2 04 01 F2 08 01 F2 04 01 F2 03 01 D2 D1 85 F2 07 0F F2 01 07 F2 03 07 F2 01 07 07 07 F2 02 07 F2 01 07 07 07 F2 03 07 F2 01 07 0B F2 06 03 F2 02 07 F2 08 07 F2 01 07 07 F2 03 07 F2 01 07 07 07 F2 02 07 F2 01 07 07 07 F2 03 07 F2 01 07 07 07 F2 06 01 F2 00 01 F2 01 01 01 DF F2 07 0F F2 01 07 F2 06 07 F2 00 07 F2 06 07 F2 01 07 F2 06 07 F2 00 07 F2 06 07 F2 01 07 F2 06 07 F2 00 07 F2 06 09 F2 01 05 F2 06 07 F2 00 07 F2 06 07 F2 01 07 F2 06 07 F2 00 07 F2 06 07 F2 01 07 F2 06 07 F2 00 07 F2 06 07 F2 01 07 F2 06 07 F2 00 07 F2 06 0B F2 01 01 F2 06 01 F2 04 01 F2 08 01 F2 04 01 F2 03 01 DF F2 06 CB DA F2 01 03 F2 03 0D DA F2 06 01 F2 07 0F DA F2 02 0F DA F2 05 0F F2 02 0F DA 0F DA 0F F2 05 0F F2 00 05 F2 06 01 F2 04 03 F2 06 03 E2 E2 E2 E3 E2 E2 E3 F2 00 0F 0F 0F 0F 0F 0F 0F 07 F2 03 07 F2 00 0F 0F 0F 0F 0F 0F 0F 03 F2 05 03 F2 01 03 F2 06 03 D2 FC 86 F2 00 0F F2 06 0F F2 00 0F F2 06 0F F2 00 0F F2 06 0F F2 00 01 DA F2 01 03 09 F2 00 0F F2 06 0F F2 00 0F F2 06 0F F2 00 0F F2 06 0F F2 00 0F F2 06 07 F2 02 03 F2 06 03 DF F2 00 07 F2 06 07 F2 05 07 F2 02 07 F2 01 07 07 F2 05 07 F2 03 07 F2 01 07 07 F2 05 07 F2 02 07 F2 01 07 0B F2 06 03 F2 08 07 F2 01 07 07 F2 05 07 F2 02 07 F2 01 07 07 F2 05 07 F2 03 07 F2 01 07 07 F2 05 07 F2 02 07 F2 01 07 0B F2 05 03 F2 01 03 F2 06 03 DF
The YM2612 is similar to Yamaha DX keyboards, which were quite popular in the 80s (listen to
https://www.youtube.com/watch?v=djV11Xbc914 and
https://www.youtube.com/watch?v=hf1UXzrZPMM and compare the bass lines.) It has 6 voices of 4 operator FM synth. The last voice can be used to play samples instead. The console has a second processor, a 3.58 MHz Z80, which can be used to handle audio related stuff so the CPU doesn't have to. I used that to do software mixing in addition to playing music, so Exotreve can play 3 samples at the same time. I decided to reserve one sample for sound effects and the other two for music, which the music I posted uses for drums. There's also a Texas Instruments SN76489, which has 3 square wave generators and a noise generator. I decided to reserve 2 square wave generators for music and the rest for sound effects. A lot of games will let sound effects temporarily interrupt instruments in the music, but I find that rather pft.
Quote: "Not to speak for him, but get in contact with Randomness on Skype, and I bet he will gladly tell you everything there is to know about that stuff. At least I think; that's how it was when he and I Skyped all the time."
That would work, but I'd fear for you. What if my procrastination spreads?
Quote: "BTW Randomness, do you guys still have the same chat going? I'll have to check in if you do."
We started a new one for Skype pftness reasons. Also Zach left for some reason.
320x224