forked from CatacombGames/CatacombApocalypse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
C6_SCA_A.ASM
153 lines (113 loc) · 3 KB
/
C6_SCA_A.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
; Catacomb Apocalypse Source Code
; Copyright (C) 1993-2014 Flat Rock Software
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License along
; with this program; if not, write to the Free Software Foundation, Inc.,
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
IDEAL
MODEL MEDIUM,C
include "ID_ASM.EQU"
;===========================================================================
;
; SCALING GRAPHICS
;
;===========================================================================
MACRO MAKELAB NUM
lab&NUM:
ENDM
MACRO MAKEREF NUM
dw OFFSET lab&NUM
ENDM
;=========================================================================
MAXSCALES equ 256
DATASEG
EXTRN screenseg:WORD
EXTRN linewidth:WORD
LABEL endtable WORD
labcount = 0
REPT MAXSCALES
MAKEREF %labcount
labcount = labcount + 1
ENDM
CODESEG
;==================================================
;
; void scaleline (int scale, unsigned picseg, unsigned maskseg,
; unsigned screen, unsigned width)
;
;==================================================
PROC ScaleLine pixels:word, scaleptr:dword, picptr:dword, screen:word
USES si,di
PUBLIC ScaleLine
;
; modify doline procedure for proper width
;
mov bx,[pixels]
cmp bx,MAXSCALES
jbe @@scaleok
mov bx,MAXSCALES
@@scaleok:
shl bx,1
mov bx,[endtable+bx]
push [cs:bx] ;save the code that will be modified over
mov [WORD cs:bx],0d18eh ;mov ss,cx
push [cs:bx+2] ;save the code that will be modified over
mov [WORD cs:bx+2],90c3h ;ret / nop
push bx
mov dx,[linewidth]
mov di,[WORD screen]
mov es,[screenseg]
mov si,[WORD scaleptr]
mov ds,[WORD scaleptr+2]
mov bx,[WORD picptr]
mov ax,[WORD picptr+2] ;will be moved into ss after call
mov bp,bx
cli
call doline
sti
;
; restore doline to regular state
;
pop bx ;address of modified code
pop [cs:bx+2]
pop [cs:bx]
mov ax,ss
mov ds,ax
ret
;================
;
; doline
;
; Big unwound scaling routine
;
; ds:si = scale table
; ss:bx = pic data
; es:di = screen location
;
;================
doline:
mov cx,ss
mov ss,ax ;can't call a routine with ss used...
labcount = 0
REPT MAXSCALES
MAKELAB %labcount
labcount = labcount + 1
lodsb ; get scaled pixel number
xlat [ss:bx] ; look it up in the picture
xchg [es:di],al ; load latches and write pixel to screen
add di,dx ; down to next line
ENDM
mov ss,cx
ret
ENDP
END