-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathengine_internal.c
More file actions
69 lines (62 loc) · 1.42 KB
/
engine_internal.c
File metadata and controls
69 lines (62 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "display.h"
#include "engine.h"
#include "ge0_port_interface.h"
#include "screen.h"
#include "sound.h"
#include <stdint.h>
#define DELAY(x)
uint32_t timeF, timeR, timeSpr, timeGpu;
uint32_t cadr_count;
uint32_t redraw;
uint8_t fps;
extern volatile uint8_t thiskey;
extern volatile uint16_t timers[8];
void screen_worker(void) {
while (1) {
DELAY(timeForRedraw);
timeR = ge0_port_millis();
clearSpriteScr();
redrawSprites();
moveSprites();
testSpriteCollision();
redrawParticles();
timeSpr += ge0_port_millis() - timeR;
timeR = ge0_port_millis();
redrawScreen();
redraw = 1;
timeGpu += ge0_port_millis() - timeR;
cadr_count++;
if (ge0_port_millis() - timeF > 1000) {
timeF = ge0_port_millis();
fps = cadr_count;
cadr_count = cadr_count % 2;
}
}
}
void key_worker(void) {
while (1) {
DELAY(100);
thiskey = ge0_port_get_key(); // 这是否会影响组合键?
}
}
void game_logic_worker(void) {
user_main();
while (1) {
DELAY(1000);
}
}
void sound_worker(void) {
while (1) {
DELAY(1);
if (delay_rtttl <= 0)
delay_rtttl = playRtttl();
}
}
void timer_tick(void) {
for (int16_t i = 0; i < 8; i++) {
if (timers[i] >= 1)
timers[i]--;
}
delay_rtttl--;
updateRtttl();
}