Monorepo for Aesthetic.Computer
aesthetic.computer
1// BUILD_TARGET: CGB
2#include <gb/gb.h>
3#include <gb/cgb.h>
4#include <gbdk/platform.h>
5#include <string.h>
6
7uint8_t current_sample = 15;
8
9const unsigned char sprite_tile[16] = {
10 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
12};
13
14void main(void) {
15 DISPLAY_OFF;
16
17 // Set up background palette - black
18 BCPS_REG = 0x80;
19 BCPD_REG = 0x00; BCPD_REG = 0x00; // Black
20 BCPD_REG = 0x00; BCPD_REG = 0x00; // Black
21 BCPD_REG = 0x00; BCPD_REG = 0x00; // Black
22 BCPD_REG = 0x00; BCPD_REG = 0x00; // Black
23
24 // Set up sprite palette - white using set_sprite_palette
25 uint16_t white_palette = 0x7FFF; // White color (RGB555: 31,31,31)
26 set_sprite_palette(0, 1, &white_palette);
27
28 set_sprite_data(0, 1, sprite_tile);
29
30 SHOW_BKG;
31 SHOW_SPRITES;
32 DISPLAY_ON;
33
34 uint8_t last_joy = 0;
35
36 while(1) {
37 vsync(); // Use vsync() like GBDK examples
38
39 uint8_t joy = joypad();
40
41 // Simple test: press LEFT to move sprite left, RIGHT to move right
42 if(joy & J_LEFT) {
43 if(current_sample > 0) current_sample--;
44 }
45 if(joy & J_RIGHT) {
46 if(current_sample < 30) current_sample++;
47 }
48
49 // Draw a single sprite at the position
50 set_sprite_tile(0, 0);
51 move_sprite(0, 8 + (current_sample * 4), 80);
52 set_sprite_prop(0, 0);
53 }
54}