-
Notifications
You must be signed in to change notification settings - Fork 1
/
eckbox.inc
166 lines (137 loc) · 3.48 KB
/
eckbox.inc
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
;-------------------------------------------------------------------
; init: macro that gets the pixel delay times
;-------------------------------------------------------------------
%macro init 0
push eax ; prevents stack errors later on
xor eax,eax
%%begin:
rdtsc
mov ecx,eax
push ecx ; save current # of cpu cycles elapsed on stack
in al,378h ; input 1 byte from parallel port to al
cmp 0h,al ; if there was no input from PP (error),
je %%zero ; then start over
cmp 88h,al ; 88h is the black/white threshold here
jg %%black
jng %%white
%%white:
in al,378h
cmp 0h,al
je %%white ; if no value, do over
cmp %1,1
je %%white
cmp 88h,al ; 88h is threshold of black/white
jg %%begin
jmp %%fin
%%w:
cmp 88h,al ; 88h is threshold of black/white
jng %%white
%%fin:
rdtsc ; get current time (in ecx)
mov ecx,eax
pop ebx ; get previous time
sub ecx,ebx ; get time between the 2 pixels
add ecx,15h ; 15h is the threshold between pix/href/vref
cmp pix,ecx
jg %%pixel
jle %%begin
%%black:
in al,378h
cmp 0h,al
je %%whi ; if no value, do over
cmp %1,1
je %%whi
cmp 88h,al ; 88h is threshold of black/white
jg %%begin
jmp %%f
%%whi:
cmp 88h,al ; 88h is threshold of black/white
jng %%black
%%f:
rdtsc ; get current time (in ecx)
mov ecx,eax
pop ebx ; get previous time
sub ecx,ebx ; get time between the 2 pixels
add ecx,15h ; is the threshold between pix/href/vref
cmp pix,ecx
jg %%pixel
jle %%begin
%%zero:
xor al,al ; zero out al
call init ; start over
%%delay:
in al,378h
cmp 0h,al
je %%wi ; if no value, do over
cmp %1,1
je %%wi
cmp 88h,al ; 88h is threshold of black/white
jg %%begin
jmp %%f
%%wi:
cmp 88h,al ; 88h is threshold of black/white
jng %%black
%%fi:
push eax
rdtsc
mov ecx,eax
pop eax
sub ecx,eax ; find time between the two times
cmp ecx,pix ; find if any of the times aren't already taken
jne %%begin ; if they all are, we're done
cmp ecx,href ; else, start over to find the next one
jne %%begin
cmp ecx,vref
jne %%begin
%%finish:
pop eax ; prevents errors from beginning
%endmacro
;-------------------------------------------------------------------
; pause: macro that pauses execution X number of CPU cycles
;-------------------------------------------------------------------
%macro pause 1
push cx
xor cx,cx ; zero out dh (dh is a counter)
mov cx,%1
%%for: ; uses ~10 cycles
nop
loop %%for
pop cx
%endmacro
;-------------------------------------------------------------------
; calibrate: macro that waits until correct pixel is being
; drawn
;-------------------------------------------------------------------
;%macro calibrate 1
;%%begin:
; in al,378h
; cmp 0h,al
; je %%begin ; if no value, do over
; cmp %1,1
; je %%white
; %%black:
; cmp 88h,al ; 88h is threshold of black/white
; jg %%begin
; jmp %%fin
; %%white:
; cmp 88h,al ; 88h is threshold of black/white
; jng %%begin
; %%fin:
;
;%endmacro
;-------------------------------------------------------------------
; putpixel: macro that draws pixel of x,y,color
;-------------------------------------------------------------------
%macro putpixel 3
push al
mov al,320
mul al,%2
add al,%1
mov es:di,al ;these 2 lines I'm not so sure about
mov [es:di],%3
pop al
%endmacro
[SECTION .data]
pix db 2 ; declare delay time variables
hrev db 2
vref db 2