cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

main.c (1675B)


      1#include <gb/gb.h>
      2#include <stdint.h>
      3
      4#include <gbdk/incbin.h>
      5
      6INCBIN(logo_tiles_data, "res/gbdk2020.bin") // Variable name to use, Path to file
      7INCBIN_EXTERN(logo_tiles_data)              // Extern declarations for binary data
      8
      9INCBIN(logo_map, "res/gbdk2020_map.bin")
     10INCBIN_EXTERN(logo_map)
     11
     12INCBIN(blank_tile_data, "res/blanktile.bin")
     13INCBIN_EXTERN(blank_tile_data)
     14
     15
     16#define TILE_BYTES 16 // 16 bytes per background tile
     17
     18
     19// Since incbin just includes a binary file (the logo tiles)
     20// a map needs to be created for them. For this example
     21// the tiles are non-deduplciated, so a array of incrementing
     22// values can be used. There are 84 tiles.
     23#define LOGO_MAP_WIDTH  7u
     24#define LOGO_MAP_HEIGHT 12u
     25#define LOGO_MAP_X      (20u - LOGO_MAP_WIDTH) / 2u  // Center on X axis
     26#define LOGO_MAP_Y      (18u - LOGO_MAP_HEIGHT) / 2u // Center on Y axis
     27
     28void init_gfx() {
     29    // Load a single clear background tile at location 0x80 and clear/fill the map with it
     30    set_bkg_data(0x80u, 1u, blank_tile_data); // The first 0x80u here is the tile ID
     31	fill_bkg_rect(0u, 0u, 20u, 18u, 0x80u);   // The last 0x80u here is the tile ID 
     32
     33    // Load logo background tiles and map
     34	// They start at 0u
     35    set_bkg_data(0u, INCBIN_SIZE(logo_tiles_data) / TILE_BYTES, logo_tiles_data);
     36	set_bkg_tiles(LOGO_MAP_X, LOGO_MAP_Y,
     37                  LOGO_MAP_WIDTH, LOGO_MAP_HEIGHT,
     38                  logo_map);
     39
     40	// Turn the background map on to make it visible
     41    SHOW_BKG;
     42}
     43
     44
     45
     46void main(void)
     47{
     48	init_gfx();
     49
     50    // Loop forever
     51    while(1) {
     52
     53		// Game main loop processing goes here
     54
     55		// Done processing, yield CPU and wait for start of next frame
     56        wait_vbl_done();
     57    }
     58}