diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-19 16:29:20 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-19 16:29:20 +0200 |
commit | 9911609e8fff312c406e3407a519b39db79bdb97 (patch) | |
tree | bbef38c5eaac06e6658ec93c2e07c571166a836d /src/main.c | |
parent | 60684bb15f5c68eb8248673da48cc4469537ffc9 (diff) | |
download | uxngba-9911609e8fff312c406e3407a519b39db79bdb97.tar.gz uxngba-9911609e8fff312c406e3407a519b39db79bdb97.zip |
Implement double buffering drawing
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | #include "common.h" | 3 | #include "common.h" |
4 | #include "bitmap.h" | 4 | #include "bitmap.h" |
5 | #include "text.h" | ||
6 | // #include "small-font.c" | 5 | // #include "small-font.c" |
7 | #include "bd-font.c" | 6 | #include "bd-font.c" |
8 | 7 | ||
@@ -15,6 +14,7 @@ | |||
15 | #include "uxn/roms/dvd.c" | 14 | #include "uxn/roms/dvd.c" |
16 | // #include "uxn/roms/automata.c" | 15 | // #include "uxn/roms/automata.c" |
17 | // #include "uxn/roms/life.c" | 16 | // #include "uxn/roms/life.c" |
17 | #include "text.h" | ||
18 | 18 | ||
19 | /* | 19 | /* |
20 | Copyright (c) 2021 Bad Diode | 20 | Copyright (c) 2021 Bad Diode |
@@ -68,7 +68,7 @@ system_talk(Device *d, Uint8 b0, Uint8 w) | |||
68 | 68 | ||
69 | void | 69 | void |
70 | screen_talk(Device *d, Uint8 b0, Uint8 w) { | 70 | screen_talk(Device *d, Uint8 b0, Uint8 w) { |
71 | profile_start(); | 71 | // profile_start(); |
72 | if(w && b0 == 0xe) { | 72 | if(w && b0 == 0xe) { |
73 | Uint16 x = mempeek16(d->dat, 0x8); | 73 | Uint16 x = mempeek16(d->dat, 0x8); |
74 | Uint16 y = mempeek16(d->dat, 0xa); | 74 | Uint16 y = mempeek16(d->dat, 0xa); |
@@ -84,8 +84,8 @@ screen_talk(Device *d, Uint8 b0, Uint8 w) { | |||
84 | } | 84 | } |
85 | reqdraw = 1; | 85 | reqdraw = 1; |
86 | } | 86 | } |
87 | int cycles = profile_stop(); | 87 | // int cycles = profile_stop(); |
88 | drawing_cycles += cycles; | 88 | // drawing_cycles += cycles; |
89 | } | 89 | } |
90 | 90 | ||
91 | void | 91 | void |
@@ -122,32 +122,33 @@ int main(void) { | |||
122 | irq_init(); | 122 | irq_init(); |
123 | irs_set(IRQ_VBLANK, irs_stub); | 123 | irs_set(IRQ_VBLANK, irs_stub); |
124 | 124 | ||
125 | |||
126 | // Initialize VM. | ||
127 | Uxn u = {0}; | ||
128 | init_uxn(&u); | ||
129 | evaluxn(&u, 0x0100); | ||
130 | |||
125 | // Initialize text engine. | 131 | // Initialize text engine. |
126 | txt_init_bitmap( | 132 | txt_init_hybrid( |
127 | TXT_MODE_HYBRID, | 133 | TXT_MODE_HYBRID, |
128 | (Font){ | 134 | (Font){ |
129 | .data = bd_font, | 135 | .data = bd_font, |
130 | .char_height = 8, | 136 | .char_height = 8, |
131 | .char_width = 8, | 137 | .char_width = 8, |
132 | }); | 138 | }, &ppu.fg); |
133 | txt_position(0,0); | ||
134 | |||
135 | // Initialize VM. | ||
136 | Uxn u = {0}; | ||
137 | init_uxn(&u); | ||
138 | txt_clear_screen(); | ||
139 | evaluxn(&u, 0x0100); | ||
140 | 139 | ||
141 | // Main loop. | 140 | // Main loop. |
142 | int frame_counter = 0; | 141 | int frame_counter = 0; |
143 | while(true) { | 142 | while(true) { |
144 | bios_vblank_wait(); | 143 | bios_vblank_wait(); |
145 | poll_keys(); | 144 | poll_keys(); |
145 | profile_start(); | ||
146 | evaluxn(&u, mempeek16(devscreen->dat, 0)); | 146 | evaluxn(&u, mempeek16(devscreen->dat, 0)); |
147 | flipbuf(&ppu); | ||
148 | int eval_cycles = profile_stop(); | ||
147 | txt_position(0,0); | 149 | txt_position(0,0); |
148 | txt_clear_screen(); | 150 | txt_printf("FRAME: %d \n", frame_counter); |
149 | txt_printf("FRAME: %d\n", frame_counter); | 151 | txt_printf("EVAL: %d \n", eval_cycles); |
150 | txt_printf("DRAWING: %d\n", drawing_cycles); | ||
151 | drawing_cycles = 0; | 152 | drawing_cycles = 0; |
152 | frame_counter++; | 153 | frame_counter++; |
153 | } | 154 | } |