cscg22-gearboy

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

bcd.c (703B)


      1#include <stdint.h>
      2#include <stdio.h>
      3
      4#include <gbdk/platform.h>
      5#include <gbdk/font.h>
      6#include <gbdk/bcd.h>
      7
      8BCD bcd  = MAKE_BCD(10203040);
      9BCD bcd2 = MAKE_BCD(05060708);
     10BCD bcd3 = MAKE_BCD(11111111);
     11
     12uint8_t len = 0;
     13unsigned char buf[10];
     14
     15void main() {
     16    font_init();
     17    font_set(font_load(font_spect));
     18
     19    len = bcd2text(&bcd, 0x10, buf);
     20    set_bkg_tiles(5, 5, len, 1, buf);
     21
     22    bcd_add(&bcd, &bcd2);
     23
     24    len = bcd2text(&bcd, 0x10, buf);
     25    set_bkg_tiles(5, 6, len, 1, buf);
     26
     27    bcd_sub(&bcd, &bcd3);
     28
     29    len = bcd2text(&bcd, 0x10, buf);
     30    set_bkg_tiles(5, 7, len, 1, buf);
     31
     32    uint2bcd(12345, &bcd);
     33
     34    len = bcd2text(&bcd, 0x10, buf);
     35    set_bkg_tiles(5, 8, len, 1, buf);
     36}