-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.c
102 lines (95 loc) · 2.29 KB
/
boot.c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <avr/interrupt.h>
#include <avr/io.h>
#include "global.h"
#include "keyboard_driver.c"
#include "registers.h"
#ifndef boot
#define boot
int main(void) {
// Set up clock divider
// 20 MHz /
TCCR0B |= _BV(CS01);
TIMSK0 |= _BV(TOIE0);
DRIVER_LINE = 0;
uint16_t *x;
x = (void *)0x800102;
return *x;
}
void reset(void) {
syncFlag = false;
imageFrame = 0x0;
DRIVER_LINE = 0x0;
charBufferIndex = 0;
}
ISR(TIMER0_OVF_vect, ISR_NAKED) {
cli();
Z = imageFrame + startImageFrame;
// If we re-enter the interrupt and the sync flag is set, we should roll back
// a DRIVER_LINE, otherwise it will skip vertical DRIVER_LINEs
if (syncFlag) --DRIVER_LINE;
for (;; ++DRIVER_LINE) {
if (DRIVER_LINE <= 75) {
// Image Display Vertical
//
// 400 clock cycles
asm volatile(
#include "pixel.S"
::
: "r16", "r30", "r31");
// Horizontal - Front Porch (20 cycles)
VGAPORT = 0xFF;
// Horizontal - Sync (64 cycles)
VGAPORT = ~0x01;
// Horizontal - Back Porch (44 cycles)
VGAPORT = 0xFF;
} else if (DRIVER_LINE <= 76) {
// Vertical - Front Porch (1 DRIVER_LINE - 528 clock cycles)
if (syncFlag) {
// Hsync (64 cycles)
VGAPORT = ~0x01;
// ...
// Back Porch (44 cycles)
VGAPORT = 0xFF;
syncFlag = false;
} else {
syncFlag = true;
// Set timer
// Keyboard Driver
keyboardDriver();
break;
}
} else if (DRIVER_LINE <= 80) {
// Vertical - Sync (4 lines - 2112 clock cycles)
if (syncFlag) {
// Horizontal - sync (64 cycles)
// Can we fit a keyboard driver in ~50 cycles?
VGAPORT = ~0x11;
//...
// Vertical - Back Porch (44 cycles)
VGAPORT = ~0x10;
syncFlag = false;
} else {
syncFlag = true;
// Set timer
// Work
// 400 + 20 - X
break;
}
} else if (DRIVER_LINE <= 91) {
// Vertical - Back Porch (11 lines - 12144 cycles)
if (syncFlag) {
// Hsync (64 cycles)
VGAPORT = ~0x01;
// ...
// Vertical - Back Porch (44 cycles)
VGAPORT = 0xFF;
// ...
syncFlag = false;
}
} else {
DRIVER_LINE = 0;
}
sei();
}
}
#endif