-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPALTSR2.ASM
222 lines (197 loc) · 4.04 KB
/
PALTSR2.ASM
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
.model tiny
.code
org 100h
begin: jmp inst
ctrl db 0
pal db 0
palmask = 11001111b
cmpmask = 11111011b
P:
P11 db 00110000b ;Bright MCW
P12 db 00000000b ;No Burst
P31 db 00100000b ;Dim MCW
P32 db 00000000b ;No Burst
P21 db 00010000b ;Bright RGY
P22 db 00000000b ;No Burst
P41 db 00000000b ;Dim RGY
P42 db 00000000b ;No Burst
P51 db 00110000b ;Bright RCW
P52 db 00000100b ;Burst On
P61 db 00000000b ;Dim RCW
P62 db 00000100b ;Burst On
chkkey proc
in al,60h
cmp al,1Dh
jne n9
mov cs:ctrl,1
n9: cmp al,9Dh
jne ne9
mov cs:ctrl,0
ne9: cmp al,29h
jne nex9
cmp cs:ctrl,1
jne nex9
xor ax,ax
inc ax
ret
nex9: xor ax,ax
ret
chkkey endp
int8 proc
cli
push ds
push ax
xor ax,ax
mov ds,ax
mov ax,cs
cmp word ptr ds:[26h],ax
jne ne8
jmp unch
ne8: mov ax,ds:[24h]
mov word ptr cs:old91,ax
mov ax,ds:[26h]
mov word ptr cs:old91+2,ax
mov ax,offset int91
mov word ptr ds:[24h],ax
mov ax,cs
mov word ptr ds:[26h],ax
unch: pop ax
pop ds
db 0EAh
old8 dd 0
int8 endp
mult proc
cmp ax,0FF00h
jne em
xchg ah,al
iret
em: db 0EAh
old2F dd 0
mult endp
endint proc
in al,61h
mov ah,al
or al,80h
out 61h,al
xchg ah,al
out 61h,al
mov al,20h
out 20h,al
pop ax
sti
iret
endint endp
int9 proc
push ax
call chkkey
cmp ax,0
jz exit9
cli
call palp
jmp endint
exit9: pop ax
db 0EAh
old9 dd 0
int9 endp
int91 proc
push ax
call chkkey
cmp ax,0
jz exit91
cli
call palp
jmp endint
exit91: pop ax
db 0EAh
old91 dd 0
int91 endp
palp proc
push ax bx cx dx si ds
xor ax,ax
mov al,cs:pal
inc al
cmp al,5
jbe xxx
xor al,al
xxx:
mov cs:pal,al
mov si,offset P
shl ax,1
add si,ax
mov bx,cs:[si]
; bh 3D8, bl 3D9
mov ax,40h
mov ds,ax
mov cx,ds:[65h]
; cl 65h, ch 66h
mov dx,3D8h
and cl,cmpmask
or cl,bh
mov al,cl
out dx,al
inc dx ;3D9h
and ch,palmask
or ch,bl
mov al,ch
out dx,al
mov ds:[65h],cx
exitg: pop ds si dx cx bx ax
ret
palp endp
inst proc
jmp instal
mess db 'PALTSR (c) 2023 Serhii Liubshin',0Dh,0Ah
db 'Alters CGA graphic mode palette',0Dh,0Ah
alr: db 'Press Ctrl + ~ to change palette',0Dh,0Ah,'$'
alred db 'PALTSR already installed',0Dh,0Ah,'$'
instal: mov ax,0FF00h
int 2Fh
cmp ax,00FFh
jne ins1
mov ah,09h
mov dx,offset alred
int 21h
mov dx,offset alr
int 21h
ret
ins1: mov dx,offset mess
mov ah,09h
int 21h
cld
cli
xor ax,ax
mov ds,ax
push cs
pop es
mov si,20h
mov di,offset old8
movsw
movsw
mov di,offset old9
movsw
movsw
mov si,2Fh*4
mov di,offset old2F
movsw
movsw
push ds
pop es
mov di,20h
mov ax,offset int8
stosw
mov ax,cs
stosw
mov ax,offset int9
stosw
mov ax,cs
stosw
mov di,2Fh*4
mov ax,offset mult
stosw
mov ax,cs
stosw
sti
mov dx,offset inst
int 27h
inst endp
end begin