Here I'll provide some code examples for the GameTank system. The information within will be cumulative, meaning that higher-numbered examples may include features from lower-numbered examples without the explanation repeated.
-
Drawing pixels by direct video memory write
-
Draw a colored rectangle using the blitter
-
Load sprite data and draw it using the blitter
-
Write a game loop that renders once per VSync
-
Read input from gamepads
-
Playing sounds and music
-
Using a 2MB cartridge
-
Accessing extended RAM and VRAM
This code was written for vasm by Dr. Volker Barthelmann availble at http://www.compilers.de/vasm.html
The examples that use sprites refer to a sprite sheet in the assets folder, compressed with zopfli.
zlib6502 by Pitor Fusik is used to extract the data. It is included here as a precompiled blob with the following assumptions:
| Use | Mapping |
|---|---|
| INFLATE code | 0xE000 - 0xE1FC |
| reserved RAM | 0x200 - 0x04FD |
| reserved Zero Page | 0xF0 - 0xF3 |