diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/main.c | 43 |
2 files changed, 38 insertions, 7 deletions
@@ -18,7 +18,7 @@ WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) | |||
18 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) | 18 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) |
19 | 19 | ||
20 | # Output library names and executables. | 20 | # Output library names and executables. |
21 | TARGET := first | 21 | TARGET := experiments |
22 | BUILD_DIR := build | 22 | BUILD_DIR := build |
23 | ELF := $(BUILD_DIR)/$(TARGET).elf | 23 | ELF := $(BUILD_DIR)/$(TARGET).elf |
24 | BIN := $(BUILD_DIR)/$(TARGET).gba | 24 | BIN := $(BUILD_DIR)/$(TARGET).gba |
@@ -21,12 +21,12 @@ | |||
21 | // | 21 | // |
22 | 22 | ||
23 | // Display registers. | 23 | // Display registers. |
24 | #define DISP_CONTROL *((vu32*)(MEM_IO + 0x0000)) | 24 | #define DISP_CTRL *((vu32*)(MEM_IO + 0x0000)) |
25 | #define DISP_STATUS *((vu32*)(MEM_IO + 0x0004)) | 25 | #define DISP_STATUS *((vu32*)(MEM_IO + 0x0004)) |
26 | #define DISP_VCOUNT *((vu32*)(MEM_IO + 0x0006)) | 26 | #define DISP_VCOUNT *((vu32*)(MEM_IO + 0x0006)) |
27 | 27 | ||
28 | // Bits for display control. | 28 | // Bits for display control. |
29 | #define DISP_CONTROL_PAGE (1 << 4) | 29 | #define DISP_CTRL_PAGE (1 << 4) |
30 | 30 | ||
31 | // Display modes. | 31 | // Display modes. |
32 | #define DISP_MODE_0 0x0000 | 32 | #define DISP_MODE_0 0x0000 |
@@ -255,7 +255,7 @@ draw_fill_rect_m4(int x0, int y0, int x1, int y1, u8 col_index, vu16 *buffer) { | |||
255 | 255 | ||
256 | static inline void | 256 | static inline void |
257 | flip_page() { | 257 | flip_page() { |
258 | DISP_CONTROL ^= DISP_CONTROL_PAGE; | 258 | DISP_CTRL ^= DISP_CTRL_PAGE; |
259 | } | 259 | } |
260 | 260 | ||
261 | #define SCREEN_PAGE_1 ((vu16*) MEM_VRAM) | 261 | #define SCREEN_PAGE_1 ((vu16*) MEM_VRAM) |
@@ -352,10 +352,41 @@ key_hold(u32 key) { | |||
352 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) | 352 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) |
353 | 353 | ||
354 | int main(void) { | 354 | int main(void) { |
355 | DISP_CONTROL = DISP_MODE_3 | DISP_BG_2; | 355 | DISP_CTRL = DISP_MODE_3 | DISP_BG_2; |
356 | 356 | ||
357 | draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_GREY); | 357 | draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_GREY); |
358 | 358 | ||
359 | int side = 60; | ||
360 | int line = 35; | ||
361 | int height = side * 0.5; | ||
362 | int x = SCREEN_WIDTH / 2 - height / 2; | ||
363 | int y = SCREEN_HEIGHT / 2; | ||
364 | |||
365 | // Draw red triangle. | ||
366 | draw_line(x + height - 1, y - side / 2, x, y - 1, COLOR_RED); | ||
367 | draw_line(x + height - 1, y + side / 2, x, y + 1, COLOR_RED); | ||
368 | draw_line(x + height - 1, y - side / 2 + 1, x, y, COLOR_RED); | ||
369 | draw_line(x + height - 1, y + side / 2 - 1, x, y, COLOR_RED); | ||
370 | |||
371 | // Draw white triangle. | ||
372 | draw_line(x, y - side / 2, x, y + side / 2, COLOR_WHITE); | ||
373 | draw_line(x + 1, y - side / 2, x + height, y - 1, COLOR_WHITE); | ||
374 | draw_line(x + 1, y + side / 2, x + height, y + 1, COLOR_WHITE); | ||
375 | |||
376 | // Draw white line at triangle tip. | ||
377 | draw_line(x + height, y - side / 2, x + height, y + side / 2, COLOR_WHITE); | ||
378 | draw_line(x + height + 1, y - side / 2, x + height + 1, y + side / 2, COLOR_WHITE); | ||
379 | |||
380 | // Double triangle line. | ||
381 | draw_line(x - 1, y - side / 2, x - 1, y + side / 2, COLOR_WHITE); | ||
382 | draw_line(x + 1, y - side / 2 + 1, x + height, y, COLOR_WHITE); | ||
383 | draw_line(x + 1, y + side / 2 - 1, x + height, y, COLOR_WHITE); | ||
384 | |||
385 | // Draw white lines. | ||
386 | draw_line(x - line, y, x, y, COLOR_WHITE); | ||
387 | draw_line(x + height, y, x + height + line, y, COLOR_WHITE); | ||
388 | draw_line(x - line, y + 1, x, y + 1, COLOR_WHITE); | ||
389 | draw_line(x + height, y + 1, x + height + line, y + 1, COLOR_WHITE); | ||
359 | int frame_counter = 0; | 390 | int frame_counter = 0; |
360 | bool toggle_key_down = false; | 391 | bool toggle_key_down = false; |
361 | while(true) { | 392 | while(true) { |