diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 33 |
1 files changed, 29 insertions, 4 deletions
@@ -10,8 +10,11 @@ | |||
10 | #include "uxn/uxn.c" | 10 | #include "uxn/uxn.c" |
11 | #include "uxn/devices/ppu.h" | 11 | #include "uxn/devices/ppu.h" |
12 | #include "uxn/devices/ppu.c" | 12 | #include "uxn/devices/ppu.c" |
13 | // #include "uxn/roms/dvd.c" | 13 | // #include "uxn/roms/console.c" |
14 | #include "uxn/roms/automata.c" | 14 | // #include "uxn/roms/proportional_fonts.c" |
15 | #include "uxn/roms/dvd.c" | ||
16 | // #include "uxn/roms/automata.c" | ||
17 | // #include "uxn/roms/life.c" | ||
15 | 18 | ||
16 | /* | 19 | /* |
17 | Copyright (c) 2021 Bad Diode | 20 | Copyright (c) 2021 Bad Diode |
@@ -24,6 +27,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
24 | WITH REGARD TO THIS SOFTWARE. | 27 | WITH REGARD TO THIS SOFTWARE. |
25 | */ | 28 | */ |
26 | 29 | ||
30 | static size_t drawing_cycles = 0; | ||
31 | |||
27 | static Ppu ppu; | 32 | static Ppu ppu; |
28 | u8 reqdraw = 0; | 33 | u8 reqdraw = 0; |
29 | static Device *devscreen; | 34 | static Device *devscreen; |
@@ -63,6 +68,7 @@ system_talk(Device *d, Uint8 b0, Uint8 w) | |||
63 | 68 | ||
64 | void | 69 | void |
65 | screen_talk(Device *d, Uint8 b0, Uint8 w) { | 70 | screen_talk(Device *d, Uint8 b0, Uint8 w) { |
71 | profile_start(); | ||
66 | if(w && b0 == 0xe) { | 72 | if(w && b0 == 0xe) { |
67 | Uint16 x = mempeek16(d->dat, 0x8); | 73 | Uint16 x = mempeek16(d->dat, 0x8); |
68 | Uint16 y = mempeek16(d->dat, 0xa); | 74 | Uint16 y = mempeek16(d->dat, 0xa); |
@@ -78,6 +84,8 @@ screen_talk(Device *d, Uint8 b0, Uint8 w) { | |||
78 | } | 84 | } |
79 | reqdraw = 1; | 85 | reqdraw = 1; |
80 | } | 86 | } |
87 | int cycles = profile_stop(); | ||
88 | drawing_cycles += cycles; | ||
81 | } | 89 | } |
82 | 90 | ||
83 | void | 91 | void |
@@ -90,7 +98,7 @@ init_uxn(Uxn *u) { | |||
90 | 98 | ||
91 | // Prepare devices. | 99 | // Prepare devices. |
92 | portuxn(u, 0x0, "system", system_talk); | 100 | portuxn(u, 0x0, "system", system_talk); |
93 | portuxn(u, 0x1, "---", nil_talk); | 101 | portuxn(u, 0x1, "console", console_talk); |
94 | devscreen = portuxn(u, 0x2, "screen", screen_talk); | 102 | devscreen = portuxn(u, 0x2, "screen", screen_talk); |
95 | portuxn(u, 0x3, "---", nil_talk); | 103 | portuxn(u, 0x3, "---", nil_talk); |
96 | portuxn(u, 0x4, "---", nil_talk); | 104 | portuxn(u, 0x4, "---", nil_talk); |
@@ -114,9 +122,20 @@ int main(void) { | |||
114 | irq_init(); | 122 | irq_init(); |
115 | irs_set(IRQ_VBLANK, irs_stub); | 123 | irs_set(IRQ_VBLANK, irs_stub); |
116 | 124 | ||
125 | // Initialize text engine. | ||
126 | txt_init_bitmap( | ||
127 | TXT_MODE_HYBRID, | ||
128 | (Font){ | ||
129 | .data = bd_font, | ||
130 | .char_height = 8, | ||
131 | .char_width = 8, | ||
132 | }); | ||
133 | txt_position(0,0); | ||
134 | |||
117 | // Initialize VM. | 135 | // Initialize VM. |
118 | Uxn u = {0}; | 136 | Uxn u = {0}; |
119 | init_uxn(&u); | 137 | init_uxn(&u); |
138 | txt_clear_screen(); | ||
120 | evaluxn(&u, 0x0100); | 139 | evaluxn(&u, 0x0100); |
121 | 140 | ||
122 | // Main loop. | 141 | // Main loop. |
@@ -125,7 +144,13 @@ int main(void) { | |||
125 | bios_vblank_wait(); | 144 | bios_vblank_wait(); |
126 | poll_keys(); | 145 | poll_keys(); |
127 | evaluxn(&u, mempeek16(devscreen->dat, 0)); | 146 | evaluxn(&u, mempeek16(devscreen->dat, 0)); |
128 | }; | 147 | txt_position(0,0); |
148 | txt_clear_screen(); | ||
149 | txt_printf("FRAME: %d\n", frame_counter); | ||
150 | txt_printf("DRAWING: %d\n", drawing_cycles); | ||
151 | drawing_cycles = 0; | ||
152 | frame_counter++; | ||
153 | } | ||
129 | 154 | ||
130 | return 0; | 155 | return 0; |
131 | } | 156 | } |