git @ Cat's Eye Technologies BefOS / rel_0_9_2011_0427
Import og BefOS version 0.9 revision 2011.0427 sources. Cat's Eye Technologies 12 years ago
32 changed file(s) with 469 addition(s) and 4973 deletion(s). Raw diff Collapse all Expand all
+0
-234
README less more
0 BefOS - an Operating System for the Linearly Challenged
1 =======================================================
2
3 BefOS v2006.0204
4 (c)1999-2006 Cat's Eye Technologies. All rights reserved.
5
6 ,---------------------------------------------------.
7 | * WARNING! * CAUTION * PROCEED AT YOUR OWN RISK * |
8 | |
9 | * THIS PRODUCT IS PROVIDED "AS IS" * |
10 | |
11 | * CAT'S EYE TECHNOLOGIES CAN NOT BE HELD LIABLE * |
12 | * FOR ANY DAMAGES RESULTING FROM ITS USE * |
13 `---------------------------------------------------'
14
15 What is it?
16 -----------
17
18 BefOS is a toy OS written in 100% 8086 assembler. It requires the
19 following hardware (or a decently emulated version thereof):
20
21 Processor: 100% Intel 8086+ Compatible
22 BIOS: 100% IBM PC Compatible
23 Video: 100% VGA Compatible
24 Keyboard: 100% Standard 101/102-Key Compatible
25 RAM: 640K base, 8M extended
26 Storage: 1.44M floppy drive 0 (A:)
27
28 BefOS was originally written in Borland's Turbo Assembler format,
29 but this version has been translated to use the free assembler
30 NASM.
31
32 Booting into BefOS
33 ------------------
34
35 Using Bochs or some other emulator: point the emulated A: drive of
36 the emulator at the file disk/befos.flp, and boot from the floppy.
37 The 'test' target in the top-level (and disk/) Makefile will run
38 Bochs automatically on this floppy image.
39
40 Using Windows: run BEKERNEL.COM. (Note that I'm not sure if this
41 works anymore in the NASM version; I haven't tried it. You still
42 need a blank floppy in drive A:, though.)
43
44 For real: install the floppy image (disk/befos.flp) onto a blank,
45 1.44M floppy disk, using a tool such as 'fdimage.exe' (which is
46 available at ftp://ftp.freebsd.org/pub/FreeBSD/tools/). Then
47 reset your computer and boot off that floppy.
48
49 Using BefOS
50 -----------
51
52 Once you've booted into BefOS, you'll see a blue screen with some stuff
53 on it.
54
55 Here is a quick-and-dirty guide to the top line of this display:
56
57 B the BefOS 'logo.'
58 (light) yellow = working, green = worked, red = failed
59 (4 hex digits) amount of base memory available, in K
60 (4 hex digits) amount of extended memory available, in K
61 (green bar)
62 (4 hex digits) link to next cluster of current cluster
63 (4 hex digits) link to previous cluster of current cluster
64 (4 hex digits) link to application cluster of current cluster
65 (4 hex digits) link to colour cluster of current cluster
66 (4 hex digits) link to help cluster of current cluster
67 (green bar)
68 (16 OEM chars) description of current cluster
69 (green bar)
70 (4 hex digits) value of last keystroke detected
71 (2 hex digits) value of current byte under cursor
72 (4 hex digits) current cluster number, starts at 0
73
74 And here are some key bindings: (NYI=Not Yet Implemented):
75
76 PgUp Up One Cluster
77 PgDn Down One cluster
78
79 Ctrl-PgUp Link to Previous Cluster (header)
80 Ctrl-PgDn Link to Next Cluster (header)
81 F1 Link to Help Cluster (header)
82
83 Up Move Pointer Up One Row
84 Down Move Pointer Down One Row
85 Left Move Pointer Left One Column
86 Right Move Pointer Right One Column
87
88 ^2 (^@) Write 0
89 ^A to ^Z Write 1 - 26
90 ESC Write 27
91 ^\ Write 28
92 ^] Write 29
93 ^6 (^^) Write 30
94 ^- (^_) Write 31
95 Space Write 32
96 !..~ Write 33 - 126
97 Ctrl-Bkspc Write 127
98
99 Alt-L Load (refresh from disk)
100 Alt-R Run (if AA==ffff, executes machine code)
101
102 F4 Change Properties (Header)
103 Alt-- Delete Properties (Header)
104 Alt-= Initialize Properties (Header)
105
106 Alt-M show More data on screen
107 Alt-N show less data on screeN
108
109 Alt-G Go to cluster number
110
111 NYI*1 Alt-E Edit: allow writes
112 Alt-U fill cluster Uniformly with current byte
113 Alt-C Copy cluster data & header to clipboard
114 Alt-P Paste cluster data & header from clipboard
115 Alt-H toggle High bit
116 Alt-S Save (commit changes to data & header to disk)
117
118 Alt-Q Quit (MS-DOS only)
119 *2 Alt-I Install cluster from file (MS-DOS only)
120
121 *1: writes are always allowed in this version so BE CAREFUL WITH ALT-S.
122 *2: type the filename into the start of the cluster buffer and
123 terminate it with a null (Ctrl-2)
124
125 Cluster Format
126 --------------
127
128 Each cluster has a 'header' which is in fact stored in the LAST
129 48 bytes of the second cluster. The first 2000 bytes are data.
130 The header is structured thus:
131
132 +------------------------------------------------+
133 |VVNNPPAACCHHxxxxxxxxxxxxxxxxxxxxDDDDDDDDDDDDDDDD|
134 +------------------------------------------------+
135
136 VV = word indicating header type.
137
138 bef0 indicates standard BefOS header, the only type supported.
139
140 NN = word containing the cluster number of the next cluster.
141
142 0000 indicates that there is no next cluster.
143
144 PP = word containing the cluster number of the previous cluster.
145
146 0000 indicates that there is no previous cluster.
147
148 AA = word containing the cluster number of the first cluster of
149 the application for which this is a document.
150
151 0000 indicates that there is no special application for this
152 generic document.
153
154 ffff indicates that this IS an application written in
155 x86 machine code.
156
157 CC = word containing the cluster number of
158 this cluster's colour cluster.
159
160 0000 indicates that this cluster is monochrome.
161
162 HH = 2 bytes containing the cluster number of
163 this cluster's help-cluster.
164
165 0000 indicates that this cluster is helpless.
166
167 xxxxxxxxxxxxxxxxxxxx = 20 bytes reserved.
168
169 DDDDDDDDDDDDDDDD = 16 bytes ASCII description e.g. "Seismology Now"
170
171
172
173 ------------------------------------------------------------------
174
175 But the following is more like what I would like it to be...
176
177 ------------------------------------------------------------------
178
179 First, we say that 1 "screen" is 4096 bytes:
180 80x25char + 80x25colour + 96 bytes header.
181 A "tableau" is a set of 80x25 screens = 2000 * 4K = 8M.
182 There is one tableau on the computer which maps to it's extended RAM.
183
184 One 1.44M floppy disk can contain six columns = 150 screens.
185
186 Header:
187
188 +------------------------------------------------+
189 |VVAAxxxxxxxxxxxxDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
190 |DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
191 +------------------------------------------------+
192
193 VV = word indicating header type.
194
195 bef0 indicates standard BefOS header, the only type supported.
196
197 AA = word containing the cluster number of the first cluster of
198 the application for which this is a document.
199
200 0000 indicates that there is no special application for this
201 generic document.
202
203 ffff indicates that this IS an application written in
204 x86 machine code.
205
206 xxxxxxxxxxxx = 12 bytes reserved.
207
208 DD..DD = 80 bytes ASCII description.
209
210
211 Building BefOS
212 --------------
213
214 BefOS can be built on FreeBSD (and probably Linux and Cygwin.)
215 Just type 'make clean all' from the top level to build it all.
216
217 Here is what is in the various directories:
218
219 bin/
220 amalgam8 Constructs a boot disk image from BefOS objects
221 extract8 Extracts BefOS objects from a boot disk image
222 txt2page Turns a text file into a BefOS object file
223 mkbfinc.pl Used during build to generate list of API calls
224 disk/ Contains bootable BefOS boot disk images
225 obj/ Contains BefOS objects that will be amalgamated
226 src/ Contains source code for BefOS:
227 apps/ Source code for the BefOS applications installed
228 boot/ Source code for the boot disk's boot block
229 inc/ Include files shared by many BefOS object sources
230 kernel/ Source file for the core components of BefOS
231 page/ Misc files that become BefOS pages on the disk
232 tools/ Source code for the util programs put in bin/
233 turbo/ The original Turbo Assembler sources for BefOS
1212 $(OBJDIR)/belife.com \
1313 $(OBJDIR)/welcome.bin \
1414 $(OBJDIR)/legend.bin \
15 $(OBJDIR)/keybind.bin \
1516 $(BINDIR)/amalgam8
1617 $(BINDIR)/amalgam8 befos.flp \
1718 $(OBJDIR)/beboot.com 0 \
1819 $(OBJDIR)/bekernel.com 1 \
1920 $(OBJDIR)/welcome.bin 8 \
2021 $(OBJDIR)/legend.bin 9 \
21 $(OBJDIR)/belife.com 10 \
22 $(OBJDIR)/keybind.bin 10 \
23 $(OBJDIR)/belife.com 11
2224
2325 clean:
26 echo 'Use `make cleandist` to delete disk image.'
27
28 cleandist:
2429 rm -f *.flp
2530
2631 test: befos.flp
Binary diff not shown
0 BefOS - an Operating System for the Linearly Challenged
1 =======================================================
2
3 BefOS v2006.0204
4 (c)1999-2006 Cat's Eye Technologies. All rights reserved.
5
6 ,---------------------------------------------------.
7 | * WARNING! * CAUTION * PROCEED AT YOUR OWN RISK * |
8 | |
9 | * THIS PRODUCT IS PROVIDED "AS IS" * |
10 | |
11 | * CAT'S EYE TECHNOLOGIES CAN NOT BE HELD LIABLE * |
12 | * FOR ANY DAMAGES RESULTING FROM ITS USE * |
13 `---------------------------------------------------'
14
15 What is it?
16 -----------
17
18 BefOS is a toy OS written in 100% 8086 assembler. It requires the
19 following hardware (or a decently emulated version thereof):
20
21 Processor: 100% Intel 8086+ Compatible
22 BIOS: 100% IBM PC Compatible
23 Video: 100% VGA Compatible
24 Keyboard: 100% Standard 101/102-Key Compatible
25 RAM: 640K base, 8M extended
26 Storage: 1.44M floppy drive 0 (A:)
27
28 BefOS was originally written in Borland's Turbo Assembler format,
29 but this version has been translated to use the free assembler
30 NASM.
31
32 Booting into BefOS
33 ------------------
34
35 Using Bochs or some other emulator: point the emulated A: drive of
36 the emulator at the file disk/befos.flp, and boot from the floppy.
37 The 'test' target in the top-level (and disk/) Makefile will run
38 Bochs automatically on this floppy image.
39
40 Using Windows: run BEKERNEL.COM. (Note that I'm not sure if this
41 works anymore in the NASM version; I haven't tried it. You still
42 need a blank floppy in drive A:, though.)
43
44 For real: install the floppy image (disk/befos.flp) onto a blank,
45 1.44M floppy disk, using a tool such as 'fdimage.exe' (which is
46 available at ftp://ftp.freebsd.org/pub/FreeBSD/tools/). Then
47 reset your computer and boot off that floppy.
48
49 Using BefOS
50 -----------
51
52 Once you've booted into BefOS, you'll see a blue screen with some stuff
53 on it.
54
55 Here is a quick-and-dirty guide to the top line of this display:
56
57 B the BefOS 'logo.'
58 (light) yellow = working, green = worked, red = failed
59 (4 hex digits) amount of base memory available, in K
60 (4 hex digits) amount of extended memory available, in K
61 (green bar)
62 (4 hex digits) link to next cluster of current cluster
63 (4 hex digits) link to previous cluster of current cluster
64 (4 hex digits) link to application cluster of current cluster
65 (4 hex digits) link to colour cluster of current cluster
66 (4 hex digits) link to help cluster of current cluster
67 (green bar)
68 (16 OEM chars) description of current cluster
69 (green bar)
70 (4 hex digits) value of last keystroke detected
71 (2 hex digits) value of current byte under cursor
72 (4 hex digits) current cluster number, starts at 0
73
74 And here are some key bindings: (NYI=Not Yet Implemented):
75
76 PgUp Up One Cluster
77 PgDn Down One cluster
78
79 Ctrl-PgUp Link to Previous Cluster (header)
80 Ctrl-PgDn Link to Next Cluster (header)
81 F1 Link to Help Cluster (header)
82
83 Up Move Pointer Up One Row
84 Down Move Pointer Down One Row
85 Left Move Pointer Left One Column
86 Right Move Pointer Right One Column
87
88 ^2 (^@) Write 0
89 ^A to ^Z Write 1 - 26
90 ESC Write 27
91 ^\ Write 28
92 ^] Write 29
93 ^6 (^^) Write 30
94 ^- (^_) Write 31
95 Space Write 32
96 !..~ Write 33 - 126
97 Ctrl-Bkspc Write 127
98
99 Alt-L Load (refresh from disk)
100 Alt-R Run (if AA==ffff, executes machine code)
101
102 F4 Change Properties (Header)
103 Alt-- Delete Properties (Header)
104 Alt-= Initialize Properties (Header)
105
106 Alt-M show More data on screen
107 Alt-N show less data on screeN
108
109 Alt-G Go to cluster number
110
111 NYI*1 Alt-E Edit: allow writes
112 Alt-U fill cluster Uniformly with current byte
113 Alt-C Copy cluster data & header to clipboard
114 Alt-P Paste cluster data & header from clipboard
115 Alt-H toggle High bit
116 Alt-S Save (commit changes to data & header to disk)
117
118 Alt-Q Quit (MS-DOS only)
119 *2 Alt-I Install cluster from file (MS-DOS only)
120
121 *1: writes are always allowed in this version so BE CAREFUL WITH ALT-S.
122 *2: type the filename into the start of the cluster buffer and
123 terminate it with a null (Ctrl-2)
124
125 Cluster Format
126 --------------
127
128 Each cluster has a 'header' which is in fact stored in the LAST
129 48 bytes of the second cluster. The first 2000 bytes are data.
130 The header is structured thus:
131
132 +------------------------------------------------+
133 |VVNNPPAACCHHxxxxxxxxxxxxxxxxxxxxDDDDDDDDDDDDDDDD|
134 +------------------------------------------------+
135
136 VV = word indicating header type.
137
138 bef0 indicates standard BefOS header, the only type supported.
139
140 NN = word containing the cluster number of the next cluster.
141
142 0000 indicates that there is no next cluster.
143
144 PP = word containing the cluster number of the previous cluster.
145
146 0000 indicates that there is no previous cluster.
147
148 AA = word containing the cluster number of the first cluster of
149 the application for which this is a document.
150
151 0000 indicates that there is no special application for this
152 generic document.
153
154 ffff indicates that this IS an application written in
155 x86 machine code.
156
157 CC = word containing the cluster number of
158 this cluster's colour cluster.
159
160 0000 indicates that this cluster is monochrome.
161
162 HH = 2 bytes containing the cluster number of
163 this cluster's help-cluster.
164
165 0000 indicates that this cluster is helpless.
166
167 xxxxxxxxxxxxxxxxxxxx = 20 bytes reserved.
168
169 DDDDDDDDDDDDDDDD = 16 bytes ASCII description e.g. "Seismology Now"
170
171
172
173 ------------------------------------------------------------------
174
175 But the following is more like what I would like it to be...
176
177 ------------------------------------------------------------------
178
179 First, we say that 1 "screen" is 4096 bytes:
180 80x25char + 80x25colour + 96 bytes header.
181 A "tableau" is a set of 80x25 screens = 2000 * 4K = 8M.
182 There is one tableau on the computer which maps to it's extended RAM.
183
184 One 1.44M floppy disk can contain six columns = 150 screens.
185
186 Header:
187
188 +------------------------------------------------+
189 |VVAAxxxxxxxxxxxxDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
190 |DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD|
191 +------------------------------------------------+
192
193 VV = word indicating header type.
194
195 bef0 indicates standard BefOS header, the only type supported.
196
197 AA = word containing the cluster number of the first cluster of
198 the application for which this is a document.
199
200 0000 indicates that there is no special application for this
201 generic document.
202
203 ffff indicates that this IS an application written in
204 x86 machine code.
205
206 xxxxxxxxxxxx = 12 bytes reserved.
207
208 DD..DD = 80 bytes ASCII description.
209
210
211 Building BefOS
212 --------------
213
214 BefOS can be built on FreeBSD (and probably Linux and Cygwin.)
215 Just type 'make clean all' from the top level to build it all.
216
217 Here is what is in the various directories:
218
219 bin/
220 amalgam8 Constructs a boot disk image from BefOS objects
221 extract8 Extracts BefOS objects from a boot disk image
222 txt2page Turns a text file into a BefOS object file
223 mkbfinc.pl Used during build to generate list of API calls
224 disk/ Contains bootable BefOS boot disk images
225 obj/ Contains BefOS objects that will be amalgamated
226 src/ Contains source code for BefOS:
227 apps/ Source code for the BefOS applications installed
228 boot/ Source code for the boot disk's boot block
229 inc/ Include files shared by many BefOS object sources
230 kernel/ Source file for the core components of BefOS
231 page/ Misc files that become BefOS pages on the disk
232 tools/ Source code for the util programs put in bin/
233 turbo/ The original Turbo Assembler sources for BefOS
0 Putative todo list:
1
2 Clean up the code base
3 Rebrand the thing because I don't like the name BefOS
4 Update the README
5 Document the entry points
6 Abstract "main loop" out of bekernel.s, into editor.s
7 Translate all tools to Python? Or at least Perl.
8
9 Switch to unreal mode on boot
10
11 Allow editing memory pages
12 - "current page" also needs "current device"
13 - can be just the base RAM for now
14
15 Implement an actual VM for it (likely something rather befungeoid, but not Befunge)
16 - Execute from "current exection page"
17 - If "current execution page" is "current displayed page",
18 also update cursor while executing
19 Rewrite Editor in the befungeoid VM?
20
21
22 Fix syscalls
23 - Really, you should only be able to syscall a Beeble (=Befunge-05) instruction
24
0 #!/bin/sh
1 # $Id$
2
3 # This is chintzy. But at least it's not a recursive Makefile, right?
4
5 TARGET=$1
6
7 cd src/tools && make ${TARGET} && cd ../..
8 cd src/kernel && make ${TARGET} && cd ../..
9 cd src/inc && make ${TARGET} && cd ../..
10 cd src/apps && make ${TARGET} && cd ../..
11 cd src/page && make ${TARGET} && cd ../..
12 cd src/boot && make ${TARGET} && cd ../..
13 cd disk && make ${TARGET} && cd ..
66 all: $(OBJDIR)/belife.com
77
88 $(OBJDIR)/belife.com: belife.s
9 $(ASM) -f bin -o $(.TARGET) -l belife.lst belife.s
9 $(ASM) -f bin -o $@ -l belife.lst belife.s
1010
1111 $(OBJDIR)/befterm.com: befterm.s ../inc/bekernel.inc
12 $(ASM) -f bin -o $(.TARGET) -l befterm.lst befterm.s
12 $(ASM) -f bin -o $@ -l befterm.lst befterm.s
1313
1414 clean:
1515 rm -f $(OBJDIR)/*.com *.lst
66 all: $(OBJDIR)/beboot.com
77
88 $(OBJDIR)/beboot.com: beboot.s ../inc/befos.inc
9 $(ASM) -f bin -o $(.TARGET) -l beboot.lst beboot.s
9 $(ASM) -f bin -o $@ -l beboot.lst beboot.s
1010
1111 clean:
1212 rm -f $(OBJDIR)/*.com *.lst
0 SEGMENT .data
0 SEGMENT .data
11
2 keytab dw Unimp ; 0000
3 dw Unimp ; 0100 Alt-ESC
4 dw Unimp ; 0200
5 dw Unimp ; 0300 Ctrl-2
6 dw Unimp ; 0400
7 dw Unimp ; 0500
8 dw Unimp ; 0600
9 dw Unimp ; 0700
10 dw Unimp ; 0800
11 dw Unimp ; 0900
12 dw Unimp ; 0a00
13 dw Unimp ; 0b00
14 dw Unimp ; 0c00
15 dw Unimp ; 0d00
16 dw Unimp ; 0e00 Alt-BkSp
17 dw Unimp ; 0f00
2 keytab dw Unimp ; 0000
3 dw Unimp ; 0100 Alt-ESC
4 dw Unimp ; 0200
5 dw Unimp ; 0300 Ctrl-2
6 dw Unimp ; 0400
7 dw Unimp ; 0500
8 dw Unimp ; 0600
9 dw Unimp ; 0700
10 dw Unimp ; 0800
11 dw Unimp ; 0900
12 dw Unimp ; 0a00
13 dw Unimp ; 0b00
14 dw Unimp ; 0c00
15 dw Unimp ; 0d00
16 dw Unimp ; 0e00 Alt-BkSp
17 dw Unimp ; 0f00
1818
19 dw Unimp ; 1000 Alt-Q
20 dw Unimp ; 1100 Alt-W
21 dw EditMode ; 1200 Alt-E
22 dw RunAsm ; 1300 Alt-R
23 dw ColourPage ; 1400 Alt-T
24 dw Unimp ; 1500 Alt-Y
25 dw FillPage ; 1600 Alt-U
26 dw Unimp ; 1700 Alt-I
27 dw CopyByte ; 1800 Alt-O
28 dw PasteByte ; 1900 Alt-P
29 dw Unimp ; 1a00 Alt-[ (sometimes)
30 dw Unimp ; 1b00 Alt-] (sometimes)
31 dw Unimp ; 1c00
32 dw Unimp ; 1d00
33 dw PopUpTest ; 1e00 Alt-A
34 dw SavePage ; 1f00 Alt-S
19 dw Unimp ; 1000 Alt-Q
20 dw Unimp ; 1100 Alt-W
21 dw EditMode ; 1200 Alt-E
22 dw RunAsm ; 1300 Alt-R
23 dw ColourPage ; 1400 Alt-T
24 dw Unimp ; 1500 Alt-Y
25 dw FillPage ; 1600 Alt-U
26 dw Unimp ; 1700 Alt-I
27 dw CopyByte ; 1800 Alt-O
28 dw PasteByte ; 1900 Alt-P
29 dw Unimp ; 1a00 Alt-[ (sometimes)
30 dw Unimp ; 1b00 Alt-] (sometimes)
31 dw Unimp ; 1c00
32 dw Unimp ; 1d00
33 dw PopUpTest ; 1e00 Alt-A
34 dw SavePage ; 1f00 Alt-S
3535
36 dw Unimp ; 2000 Alt-D
37 dw Unimp ; 2100 Alt-F
38 dw AskGoPage ; 2200 Alt-G
39 dw ToggleHighBit ; 2300 Alt-H
40 dw JumpPage ; 2400 Alt-J
41 dw Unimp ; 2500 Alt-K
42 dw LoadPage ; 2600 Alt-L
43 dw Unimp ; 2700
44 dw Unimp ; 2800
45 dw Unimp ; 2900
46 dw Unimp ; 2a00
47 dw Unimp ; 2b00
48 dw Unimp ; 2c00 Alt-Z
49 dw CutPage ; 2d00 Alt-X
50 dw CopyPage ; 2e00 Alt-C
51 dw PastePage ; 2f00 Alt-V
36 dw Unimp ; 2000 Alt-D
37 dw Unimp ; 2100 Alt-F
38 dw AskGoPage ; 2200 Alt-G
39 dw ToggleHighBit ; 2300 Alt-H
40 dw JumpPage ; 2400 Alt-J
41 dw Unimp ; 2500 Alt-K
42 dw LoadPage ; 2600 Alt-L
43 dw Unimp ; 2700
44 dw Unimp ; 2800
45 dw Unimp ; 2900
46 dw Unimp ; 2a00
47 dw Unimp ; 2b00
48 dw Unimp ; 2c00 Alt-Z
49 dw CutPage ; 2d00 Alt-X
50 dw CopyPage ; 2e00 Alt-C
51 dw PastePage ; 2f00 Alt-V
5252
53 dw Unimp ; 3000 Alt-B
54 dw LessScreen ; 3100 Alt-N
55 dw MoreScreen ; 3200 Alt-M
56 dw Unimp ; 3300
57 dw Unimp ; 3400
58 dw Unimp ; 3500
59 dw Unimp ; 3600
60 dw Unimp ; 3700 Alt-* (sometimes)
61 dw Unimp ; 3800
62 dw Unimp ; 3900
63 dw Unimp ; 3a00
64 dw HelpPage ; 3b00 F1
65 dw DiskInfo ; 3c00 F2
66 dw Unimp ; 3d00 F3
67 dw EditPageProps ; 3e00 F4
68 dw RefreshStatus ; 3f00 F5
53 dw Unimp ; 3000 Alt-B
54 dw LessScreen ; 3100 Alt-N
55 dw MoreScreen ; 3200 Alt-M
56 dw Unimp ; 3300
57 dw Unimp ; 3400
58 dw Unimp ; 3500
59 dw Unimp ; 3600
60 dw Unimp ; 3700 Alt-* (sometimes)
61 dw Unimp ; 3800
62 dw Unimp ; 3900
63 dw Unimp ; 3a00
64 dw HelpPage ; 3b00 F1
65 dw DiskInfo ; 3c00 F2
66 dw Unimp ; 3d00 F3
67 dw EditPageProps ; 3e00 F4
68 dw RefreshStatus ; 3f00 F5
6969
70 dw Unimp ; 4000 F6
71 dw ExecBeebInstr ; 4100 F7
72 dw PlugClock ; 4200 F8
73 dw UnplugClock ; 4300 F9
74 dw Unimp ; 4400 F10
75 dw Unimp ; 4500
76 dw Unimp ; 4600
77 dw PrevPage ; 4700 Home
78 dw BufUp ; 4800 Up
79 dw PageUp ; 4900 PgUp
80 dw Unimp ; 4a00
81 dw BufLeft ; 4b00 Left
82 dw Unimp ; 4c00
83 dw BufRight ; 4d00 Right
84 dw Unimp ; 4e00
85 dw NextPage ; 4f00 End
70 dw Unimp ; 4000 F6
71 dw ExecBeebInstr ; 4100 F7
72 dw PlugClock ; 4200 F8
73 dw UnplugClock ; 4300 F9
74 dw Unimp ; 4400 F10
75 dw Unimp ; 4500
76 dw Unimp ; 4600
77 dw PrevPage ; 4700 Home
78 dw BufUp ; 4800 Up
79 dw PageUp ; 4900 PgUp
80 dw Unimp ; 4a00
81 dw BufLeft ; 4b00 Left
82 dw Unimp ; 4c00
83 dw BufRight ; 4d00 Right
84 dw Unimp ; 4e00
85 dw NextPage ; 4f00 End
8686
87 dw BufDown ; 5000 Down
88 dw PageDown ; 5100 PgDn
89 dw InsByte ; 5200 Ins
90 dw DelByte ; 5300 Del
91 dw Unimp ; 5400
92 dw Unimp ; 5500
93 dw Unimp ; 5600
94 dw Unimp ; 5700
95 dw Unimp ; 5800
96 dw Unimp ; 5900
97 dw Unimp ; 5a00
98 dw Unimp ; 5b00
99 dw Unimp ; 5c00
100 dw Unimp ; 5d00
101 dw Unimp ; 5e00
102 dw Unimp ; 5f00
87 dw BufDown ; 5000 Down
88 dw PageDown ; 5100 PgDn
89 dw Unimp ; 5200 Ins
90 dw Unimp ; 5300 Del
91 dw Unimp ; 5400
92 dw Unimp ; 5500
93 dw Unimp ; 5600
94 dw Unimp ; 5700
95 dw Unimp ; 5800
96 dw Unimp ; 5900
97 dw Unimp ; 5a00
98 dw Unimp ; 5b00
99 dw Unimp ; 5c00
100 dw Unimp ; 5d00
101 dw Unimp ; 5e00
102 dw Unimp ; 5f00
103103
104 dw Unimp ; 6000
105 dw Unimp ; 6100
106 dw Unimp ; 6200
107 dw Unimp ; 6300
108 dw Unimp ; 6400
109 dw Unimp ; 6500
110 dw Unimp ; 6600
111 dw Unimp ; 6700
112 dw Unimp ; 6800
113 dw Unimp ; 6900
114 dw Unimp ; 6a00
115 dw Unimp ; 6b00
116 dw Unimp ; 6c00
117 dw Unimp ; 6d00
118 dw Unimp ; 6e00
119 dw Unimp ; 6f00
104 dw Unimp ; 6000
105 dw Unimp ; 6100
106 dw Unimp ; 6200
107 dw Unimp ; 6300
108 dw Unimp ; 6400
109 dw Unimp ; 6500
110 dw Unimp ; 6600
111 dw Unimp ; 6700
112 dw Unimp ; 6800
113 dw Unimp ; 6900
114 dw Unimp ; 6a00
115 dw Unimp ; 6b00
116 dw Unimp ; 6c00
117 dw Unimp ; 6d00
118 dw Unimp ; 6e00
119 dw Unimp ; 6f00
120120
121 dw Unimp ; 7000
122 dw Unimp ; 7100
123 dw Unimp ; 7200
124 dw DecByte ; 7300 Ctrl-Left
125 dw IncByte ; 7400 Ctrl-Right
126 dw NextDisk ; 7500 Ctrl-End
127 dw NextTextVidPage ; 7600 Ctrl-PgDn
128 dw PrevDisk ; 7700 Ctrl-Home
129 dw Unimp ; 7800 Alt-1
130 dw Unimp ; 7900 Alt-2
131 dw Unimp ; 7a00 Alt-3
132 dw Unimp ; 7b00 Alt-4
133 dw Unimp ; 7c00 Alt-5
134 dw Unimp ; 7d00 Alt-6
135 dw Unimp ; 7e00 Alt-7
136 dw Unimp ; 7f00 Alt-8
121 dw Unimp ; 7000
122 dw Unimp ; 7100
123 dw Unimp ; 7200
124 dw DecByte ; 7300 Ctrl-Left
125 dw IncByte ; 7400 Ctrl-Right
126 dw NextDisk ; 7500 Ctrl-End
127 dw NextTextVidPage ; 7600 Ctrl-PgDn
128 dw PrevDisk ; 7700 Ctrl-Home
129 dw Unimp ; 7800 Alt-1
130 dw Unimp ; 7900 Alt-2
131 dw Unimp ; 7a00 Alt-3
132 dw Unimp ; 7b00 Alt-4
133 dw Unimp ; 7c00 Alt-5
134 dw Unimp ; 7d00 Alt-6
135 dw Unimp ; 7e00 Alt-7
136 dw Unimp ; 7f00 Alt-8
137137
138 dw Unimp ; 8000 Alt-9
139 dw Unimp ; 8100 Alt-0
140 dw DelPageProps ; 8200 Alt--
141 dw InitPageProps ; 8300 Alt-=
142 dw PrevTextVidPage ; 8400 Ctrl-PgUp
143 dw Unimp ; 8500
144 dw Unimp ; 8600
145 dw Unimp ; 8700
146 dw Unimp ; 8800
147 dw Unimp ; 8900
148 dw Unimp ; 8a00
149 dw Unimp ; 8b00
150 dw Unimp ; 8c00
151 dw Unimp ; 8d00
152 dw Unimp ; 8e00
153 dw Unimp ; 8f00
138 dw Unimp ; 8000 Alt-9
139 dw Unimp ; 8100 Alt-0
140 dw DelPageProps ; 8200 Alt--
141 dw InitPageProps ; 8300 Alt-=
142 dw PrevTextVidPage ; 8400 Ctrl-PgUp
143 dw Unimp ; 8500
144 dw Unimp ; 8600
145 dw Unimp ; 8700
146 dw Unimp ; 8800
147 dw Unimp ; 8900
148 dw Unimp ; 8a00
149 dw Unimp ; 8b00
150 dw Unimp ; 8c00
151 dw Unimp ; 8d00
152 dw Unimp ; 8e00
153 dw Unimp ; 8f00
+0
-194
src/inc/maybe_so/befcom.inc less more
0 DATASEG
1
2 baud dw 08h
3 comhead dw combuf
4 comtail dw combuf
5
6 CODESEG
7
8 PUBLIC InitCom
9 PROC InitCom
10
11 mov ax, 0400h ; ext. init COM port
12 mov bx, 0
13 mov cx, 0300h
14 add cx, [word baud]
15 mov dx, 0 ; COM1
16 int 14h ; init port
17
18 mov ax, 0500h
19 int 14h
20 or bl, 3 ; up my DTR & RTS
21 mov ax, 0501h
22 int 14h
23
24 and ax, 8e00h
25 cmp ax, 0
26 je @@Great
27 jmp BadLight
28 @@Great: jmp OKLight
29
30 ENDP
31
32 PUBLIC StatCom
33 PROC StatCom
34 mov ax, 0300h
35 mov dx, 0
36 int 14h ; check port
37 mov cx, ax
38 ret
39 ENDP
40
41 PUBLIC WriteCom
42 PROC WriteCom
43 ; cl = char to write
44 @@OutAgain: mov dx, 03f8h + 5
45 in al, dx
46 and al, 020h
47 jz @@OutAgain
48
49 mov al, cl
50 mov dx, 03f8h
51 out dx, al
52 ENDP
53
54 PUBLIC ReadCom
55 PROC ReadCom
56 ; read cl from combuf.
57 ; returns ch = number of chars (0 or 1.)
58
59 mov bx, [word comhead]
60 cmp bx, [word comtail]
61 je @@Nothing
62
63 mov cl, [byte combuf + bx]
64 inc bx
65 cmp bx, 2048
66 jne @@NoWrap
67 xor bx, bx
68
69 @@NoWrap: mov [word comhead], bx
70 mov ch, 1
71 ret
72
73 @@Nothing: xor cx, cx
74 ret
75 ENDP
76
77 PUBLIC PlugCom
78 PROC PlugCom
79
80 call WorkLight
81
82 mov cl, 0ch
83 call ReadIntr
84
85 mov ax, es
86 mov [word comSegment], ax
87 mov [word comOffset], di
88
89 mov ax, cs
90 mov es, ax
91 mov di, offset ComISR
92 mov cl, 0ch ; com #0 interrupt
93 call WriteIntr
94
95 ; the 8259 stuff
96
97 in al, 021h ; 8259_1 line: read 8259 enable masks
98 and al, 0efh ; clear masked bit, enabling IRQ
99 out 021h, al ; spit back out, write new masks
100
101 ; the 8250 stuff
102
103 mov dx, 03f8h + 3 ; LineControl
104 in al, dx
105 and al, 07fh ; clear bit 7 "DLAB"
106 out dx, al
107
108 mov dx, 03f8h + 1 ; InterruptEnable
109 xor al, al
110 inc al
111 out dx, al
112
113 ; clear Rx, LineStatus, ModemStatus
114
115 @@ClearLines: mov dx, 03f8h
116 in al, dx
117 add dx, 5
118 in al, dx
119 inc dx
120 in al, dx
121
122 ; keep doing so until we get green flag.
123
124 mov dx, 03f8h + 2 ; IntIdent
125 in al, dx
126 test al, 1
127 jz @@ClearLines
128
129 ; set bit 3 of ModemControl
130
131 mov dx, 03f8h + 4 ; ModemControl
132 in al, dx
133 or al, 08h
134 out dx, al ; Blastoff!
135
136 call OKLight
137
138 ret
139 ENDP
140
141 PUBLIC UnplugCom
142 PROC UnplugCom
143
144 call WorkLight
145 mov ax, [word comSegment]
146 cmp ax, 0
147 je @@Fail
148 mov [word comSegment], 0
149 mov es, ax
150 mov di, [word comOffset]
151 mov cl, 0ch ; com #0 interrupt
152 call WriteIntr
153 call OKLight
154 ret
155 @@Fail: jmp BadLight
156 ENDP
157
158 PUBLIC ComISR
159 PROC ComISR
160 push ax
161 push bx
162 push dx
163 push ds
164
165 mov ax, cs
166 mov ds, ax
167
168 mov dx, 03f8h
169 in al, dx ; al = char read from port
170
171 mov bx, [word comtail]
172 mov [byte combuf + bx], al ; store in buffer
173 inc bx
174
175 cmp bx, 2048
176 jne @@NoWrap
177
178 xor bx, bx
179
180 @@NoWrap: mov [word comtail], bx
181
182 ; issue end-of-interrupt to 8259.
183
184 mov al, 020h
185 out 020h, al ; 8259_0 line
186
187 pop ds
188 pop dx
189 pop bx
190 pop ax
191
192 iret
193 ENDP
+0
-264
src/inc/maybe_so/befgraph.inc less more
0 CENX EQU 160 ; center of VGA screen xwise
1 CENY EQU 100 ; center of VGA screen ywise
2
3 CODESEG
4
5 ; mov di, [word tcol]
6 ; inc di
7 ; mov [word tcol], di
8 ; mov si, di
9 ; mov ax, [word mx]
10 ; mov bx, [word my]
11 ; mov cx, 160
12 ; mov dx, 199
13 ; call LINE
14 ;
15 ; ; now, is there a keypress outstanding?
16 ;
17 ; mov ah, 1
18 ; int 16h
19 ; jz @@Tram
20 ; jmp @@Test
21 ;
22 ; ; IF A$ = "" THEN
23 ;
24
25 PUBLIC SynchRaster
26 PROC SynchRaster
27 ; dx,al = DESTROYED
28
29 mov dx, 03dah
30 @@VRT3: in al, dx
31 test al, 08h
32 je @@VRT3
33 ENDP
34
35 ; mov si, 0
36 ; mov ax, [word mx]
37 ; mov bx, [word my]
38 ; mov cx, 160
39 ; mov dx, 199
40 ; call LINE
41 ;
42
43 PUBLIC DrawPix
44 PROC DrawPix
45 ; es SHOULD BE SET TO pixbase FIRST!!
46 ; ah = y coordinate
47 ; bx = x coordinate
48 ; dl = colour
49 ; cx, al DESTROYED
50
51 ; VGA[(py<<8)+(py<<6)+px]=color;
52
53 xor al, al
54 mov cx, ax
55 shr cx, 2
56 add ax, cx
57 add ax, bx
58 mov di, ax
59 mov [byte es:di], dl
60 ret
61 ENDP
62
63 ; Thanks for the following algorithm goes to lines.c
64 ; by David Brackeen (http://silo.csci.unt.edu/home/brackeen/vga/)
65
66 PUBLIC DrawLine
67 PROC DrawLine
68 ; es SHOULD BE SET TO pixbase FIRST!!
69 ; ax = x1 coordinate
70 ; bx = y1 coordinate
71 ; cx = x2 coordinate
72 ; dx = y2 coordinate
73 ; si = colour
74
75 ; px=x1;
76 ; py=y1;
77
78 mov [word lpx], ax
79 mov [word lpy], bx
80
81 ; dx=x2-x1; (cx-ax) /* the horizontal distance of the line */
82 ; dy=y2-y1; (bh-bl) /* the vertical distance of the line */
83
84 sub cx, ax
85 mov [word ldx], cx
86
87 sub dx, bx
88 mov [word ldy], dx
89
90 mov bx, si
91 mov [byte lcol], bl
92
93 ; dxabs=abs(dx);
94 ; dyabs=abs(dy);
95 ; sdx=sgn(dx);
96 ; sdy=sgn(dy);
97
98 mov [word lsdx], 1
99 cmp cx, 0
100 jge @@S1
101
102 neg cx
103 mov [word lsdx], -1
104
105 @@S1: mov [word ldxabs], cx
106
107 mov [word lsdy], 1
108 cmp dx, 0
109 jge @@S2
110
111 neg dx
112 mov [word lsdy], -1
113
114 @@S2: mov [word ldyabs], dx
115
116 ; x=dyabs>>1;
117 ; y=dxabs>>1;
118
119 shr cx, 1
120 mov [word ly], cx
121
122 shr dx, 1
123 mov [word lx], dx
124
125 ; VGA[(py<<8)+(py<<6)+px]=color;
126
127 mov bx, [word lpx]
128 mov ax, [word lpy]
129 mov ah, al
130 mov dl, [byte lcol]
131 call DrawPix
132
133 ; if (dxabs>=dyabs) /* the line is more horizontal than vertical */
134 ; {
135
136 mov ax, [word ldyabs]
137 cmp ax, [word ldxabs]
138 jg @@Vert
139
140 ; if dx>=dy we draw dy horizontal lines
141 ; staggered between y1 and y2.
142 ; each line is of length dx/dy
143
144 ; for(i=0;i<dxabs;i++) ( i == bx )
145 ; {
146
147 xor bx, bx
148 @@B1: cmp bx, [word ldxabs]
149 jge @@E1
150
151 ; y+=dyabs;
152
153 mov ax, [word ldyabs]
154 add ax, [word ly]
155 mov [word ly], ax
156
157 ; if (y>=dxabs)
158 ; {
159
160 cmp ax, [word ldxabs]
161 jl @@NE1
162
163 ; y-=dxabs;
164
165 sub ax, [word ldxabs]
166 mov [word ly], ax
167
168 ; py+=sdy;
169
170 mov ax, [word lsdy]
171 add [word lpy], ax
172
173 ; }
174
175 @@NE1:
176 ; px+=sdx;
177
178 mov ax, [word lsdx]
179 add [word lpx], ax
180
181 ; plot_pixel(px,py,color);
182
183 mov [word temp], bx
184 mov bx, [word lpx]
185 mov ax, [word lpy]
186 mov ah, al
187 mov dl, [byte lcol]
188 call DrawPix
189 mov bx, [word temp]
190
191 ; }
192
193 inc bx
194 jmp @@B1
195
196 ; }
197
198 @@E1: jmp @@Exit
199
200 ; else the line is more vertical than horizontal
201
202 @@Vert: ; if dy>dx we draw dx vertical lines
203 ; staggered between x1 and x2.
204 ; each line is of length dy/dx
205
206 ; {
207 ; for(i=0;i<dyabs;i++) (i == bl)
208
209 xor bx, bx
210 @@B2: cmp bx, [word ldyabs]
211 jge @@E1
212
213 ; {
214 ; x+=dxabs;
215
216 mov ax, [word ldxabs]
217 add ax, [word lx]
218 mov [word lx], ax
219
220 ; if (x>=dyabs)
221 ; {
222
223 cmp ax, [word ldyabs]
224 jl @@NE2
225
226 ; x-=dyabs;
227
228 sub ax, [word ldyabs]
229 mov [word lx], ax
230
231 ; px+=sdx;
232
233 mov ax, [word lsdx]
234 add [word lpx], ax
235
236 ; }
237
238 @@NE2:
239 ; py+=sdy;
240
241 mov ax, [word lsdy]
242 add [word lpy], ax
243
244 ; plot_pixel(px,py,color);
245
246 mov [word temp], bx
247 mov bx, [word lpx]
248 mov ax, [word lpy]
249 mov ah, al
250 mov dl, [byte lcol]
251 call DrawPix
252 mov bx, [word temp]
253
254 ; }
255
256 inc bx
257 jmp @@B2
258
259 ; }
260
261 @@Exit: ret
262
263 ENDP
+0
-256
src/inc/maybe_so/befosfnt.inc less more
0 charset db 0, 0, 192, 64, 64, 122, 68, 74, 82, 98, 66, 188, 0, 0, 0, 0
1 db 0, 0, 126, 129, 165, 129, 129, 165, 153, 129, 129, 126, 0, 0, 0, 0
2 db 0, 0, 126, 255, 219, 255, 255, 219, 231, 255, 255, 126, 0, 0, 0, 0
3 db 0, 0, 0, 0, 68, 238, 254, 254, 254, 124, 56, 16, 0, 0, 0, 0
4 db 0, 0, 0, 0, 16, 56, 124, 254, 124, 56, 16, 0, 0, 0, 0, 0
5 db 0, 0, 0, 24, 60, 60, 102, 231, 231, 24, 24, 60, 0, 0, 0, 0
6 db 0, 0, 0, 24, 60, 126, 255, 255, 126, 24, 24, 60, 0, 0, 0, 0
7 db 0, 0, 0, 0, 0, 0, 24, 60, 60, 24, 0, 0, 0, 0, 0, 0
8 db 255, 255, 255, 255, 255, 255, 231, 195, 195, 231, 255, 255, 255, 255, 255, 255
9 db 0, 0, 0, 0, 0, 24, 36, 66, 66, 36, 24, 0, 0, 0, 0, 0
10 db 255, 255, 255, 255, 255, 231, 219, 189, 189, 219, 231, 255, 255, 255, 255, 255
11 db 0, 14, 6, 10, 16, 32, 124, 130, 130, 130, 130, 124, 0, 0, 0, 0
12 db 0, 0, 124, 130, 130, 130, 130, 124, 16, 124, 16, 16, 0, 0, 0, 0
13 db 0, 0, 24, 24, 28, 22, 18, 16, 16, 112, 240, 224, 0, 0, 0, 0
14 db 0, 0, 63, 33, 63, 33, 33, 33, 33, 39, 231, 230, 192, 0, 0, 0
15 db 0, 0, 0, 16, 56, 146, 124, 198, 124, 146, 56, 16, 0, 0, 0, 0
16 db 0, 128, 192, 224, 240, 248, 252, 248, 240, 224, 192, 128, 0, 0, 0, 0
17 db 0, 2, 6, 14, 30, 62, 126, 62, 30, 14, 6, 2, 0, 0, 0, 0
18 db 0, 0, 16, 56, 124, 16, 16, 16, 124, 56, 16, 0, 0, 0, 0, 0
19 db 0, 0, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 0, 0, 0, 0
20 db 0, 0, 126, 148, 148, 148, 116, 20, 20, 20, 20, 20, 0, 0, 0, 0
21 db 0, 124, 130, 64, 56, 68, 130, 130, 68, 56, 4, 130, 124, 0, 0, 0
22 db 0, 0, 0, 0, 0, 0, 0, 0, 254, 254, 254, 254, 0, 0, 0, 0
23 db 0, 0, 16, 56, 124, 16, 16, 16, 124, 56, 16, 124, 0, 0, 0, 0
24 db 16, 56, 124, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
25 db 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 124, 56, 16
26 db 0, 0, 0, 0, 0, 4, 6, 255, 6, 4, 0, 0, 0, 0, 0, 0
27 db 0, 0, 0, 0, 0, 32, 96, 255, 96, 32, 0, 0, 0, 0, 0, 0
28 db 0, 0, 0, 0, 0, 0, 128, 128, 128, 252, 0, 0, 0, 0, 0, 0
29 db 0, 0, 0, 0, 0, 40, 68, 254, 68, 40, 0, 0, 0, 0, 0, 0
30 db 0, 0, 0, 0, 16, 56, 56, 124, 124, 254, 254, 0, 0, 0, 0, 0
31 db 0, 0, 0, 0, 254, 254, 124, 124, 56, 56, 16, 0, 0, 0, 0, 0
32 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
33 db 0, 0, 16, 56, 56, 56, 16, 16, 16, 0, 16, 16, 0, 0, 0, 0
34 db 0, 36, 36, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
35 db 0, 0, 0, 72, 72, 252, 72, 72, 72, 252, 72, 72, 0, 0, 0, 0
36 db 16, 16, 124, 130, 130, 128, 124, 2, 2, 130, 130, 124, 16, 16, 0, 0
37 db 0, 0, 0, 66, 162, 68, 8, 16, 32, 68, 138, 132, 0, 0, 0, 0
38 db 0, 0, 112, 136, 136, 144, 96, 144, 138, 132, 138, 114, 0, 0, 0, 0
39 db 0, 16, 16, 16, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
40 db 0, 0, 12, 16, 32, 32, 32, 32, 32, 32, 16, 12, 0, 0, 0, 0
41 db 0, 0, 48, 8, 4, 4, 4, 4, 4, 4, 8, 48, 0, 0, 0, 0
42 db 0, 0, 0, 0, 0, 108, 56, 254, 56, 108, 0, 0, 0, 0, 0, 0
43 db 0, 0, 0, 0, 0, 16, 16, 124, 16, 16, 0, 0, 0, 0, 0, 0
44 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 16, 0, 0, 0
45 db 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 0
46 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 0, 0, 0, 0
47 db 0, 0, 0, 0, 0, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0
48 db 0, 0, 124, 134, 138, 138, 146, 146, 162, 162, 194, 124, 0, 0, 0, 0
49 db 0, 0, 16, 48, 80, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
50 db 0, 0, 124, 130, 2, 4, 8, 16, 32, 64, 128, 254, 0, 0, 0, 0
51 db 0, 0, 124, 130, 2, 2, 60, 2, 2, 2, 130, 124, 0, 0, 0, 0
52 db 0, 0, 12, 20, 36, 68, 132, 254, 4, 4, 4, 14, 0, 0, 0, 0
53 db 0, 0, 254, 128, 128, 128, 252, 2, 2, 2, 130, 124, 0, 0, 0, 0
54 db 0, 0, 60, 64, 128, 128, 252, 130, 130, 130, 130, 124, 0, 0, 0, 0
55 db 0, 0, 254, 2, 2, 2, 4, 8, 16, 32, 32, 32, 0, 0, 0, 0
56 db 0, 0, 124, 130, 130, 130, 124, 130, 130, 130, 130, 124, 0, 0, 0, 0
57 db 0, 0, 124, 130, 130, 130, 126, 2, 2, 2, 4, 120, 0, 0, 0, 0
58 db 0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0
59 db 0, 0, 0, 0, 16, 16, 0, 0, 0, 16, 16, 32, 0, 0, 0, 0
60 db 0, 0, 0, 4, 8, 16, 32, 64, 32, 16, 8, 4, 0, 0, 0, 0
61 db 0, 0, 0, 0, 0, 124, 0, 0, 124, 0, 0, 0, 0, 0, 0, 0
62 db 0, 0, 0, 32, 16, 8, 4, 2, 4, 8, 16, 32, 0, 0, 0, 0
63 db 0, 0, 124, 130, 130, 4, 8, 16, 16, 0, 16, 16, 0, 0, 0, 0
64 db 0, 0, 0, 124, 130, 130, 158, 146, 146, 156, 128, 124, 0, 0, 0, 0
65 db 0, 0, 16, 40, 68, 130, 130, 254, 130, 130, 130, 130, 0, 0, 0, 0
66 db 0, 0, 252, 66, 66, 66, 124, 66, 66, 66, 66, 252, 0, 0, 0, 0
67 db 0, 0, 60, 66, 128, 128, 128, 128, 128, 128, 66, 60, 0, 0, 0, 0
68 db 0, 0, 248, 68, 66, 66, 66, 66, 66, 66, 68, 248, 0, 0, 0, 0
69 db 0, 0, 254, 66, 66, 72, 120, 72, 64, 66, 66, 254, 0, 0, 0, 0
70 db 0, 0, 254, 66, 64, 64, 120, 64, 64, 64, 64, 224, 0, 0, 0, 0
71 db 0, 0, 60, 66, 130, 128, 128, 158, 130, 130, 70, 58, 0, 0, 0, 0
72 db 0, 0, 130, 130, 130, 130, 254, 130, 130, 130, 130, 130, 0, 0, 0, 0
73 db 0, 0, 124, 16, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
74 db 0, 0, 14, 4, 4, 4, 4, 4, 132, 132, 132, 120, 0, 0, 0, 0
75 db 0, 0, 194, 68, 72, 80, 96, 80, 72, 68, 66, 194, 0, 0, 0, 0
76 db 0, 0, 224, 64, 64, 64, 64, 64, 64, 64, 66, 254, 0, 0, 0, 0
77 db 0, 0, 130, 198, 170, 146, 130, 130, 130, 130, 130, 130, 0, 0, 0, 0
78 db 0, 0, 130, 194, 162, 146, 138, 134, 130, 130, 130, 130, 0, 0, 0, 0
79 db 0, 0, 124, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
80 db 0, 0, 252, 66, 66, 66, 124, 64, 64, 64, 64, 240, 0, 0, 0, 0
81 db 0, 0, 124, 130, 130, 130, 130, 130, 130, 146, 146, 124, 4, 6, 0, 0
82 db 0, 0, 252, 66, 66, 66, 124, 68, 68, 66, 66, 194, 0, 0, 0, 0
83 db 0, 0, 124, 130, 130, 64, 48, 12, 2, 130, 130, 124, 0, 0, 0, 0
84 db 0, 0, 254, 146, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
85 db 0, 0, 130, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
86 db 0, 0, 130, 130, 130, 130, 130, 130, 130, 68, 40, 16, 0, 0, 0, 0
87 db 0, 0, 130, 130, 130, 130, 130, 146, 146, 146, 146, 108, 0, 0, 0, 0
88 db 0, 0, 130, 130, 68, 40, 16, 16, 40, 68, 130, 130, 0, 0, 0, 0
89 db 0, 0, 130, 130, 130, 68, 40, 16, 16, 16, 16, 56, 0, 0, 0, 0
90 db 0, 0, 254, 130, 4, 8, 16, 32, 64, 128, 130, 254, 0, 0, 0, 0
91 db 0, 0, 60, 32, 32, 32, 32, 32, 32, 32, 32, 60, 0, 0, 0, 0
92 db 0, 0, 0, 128, 192, 96, 48, 24, 12, 6, 2, 0, 0, 0, 0, 0
93 db 0, 0, 60, 4, 4, 4, 4, 4, 4, 4, 4, 60, 0, 0, 0, 0
94 db 16, 40, 68, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
95 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0
96 db 0, 16, 16, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
97 db 0, 0, 0, 0, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
98 db 0, 0, 192, 64, 64, 120, 68, 66, 66, 66, 66, 124, 0, 0, 0, 0
99 db 0, 0, 0, 0, 0, 124, 130, 128, 128, 128, 130, 124, 0, 0, 0, 0
100 db 0, 0, 12, 4, 4, 60, 68, 132, 132, 132, 140, 118, 0, 0, 0, 0
101 db 0, 0, 0, 0, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
102 db 0, 0, 28, 34, 32, 32, 120, 32, 32, 32, 32, 112, 0, 0, 0, 0
103 db 0, 0, 0, 0, 0, 118, 140, 132, 132, 132, 132, 124, 4, 132, 120, 0
104 db 0, 0, 192, 64, 64, 92, 98, 66, 66, 66, 66, 194, 0, 0, 0, 0
105 db 0, 0, 16, 16, 0, 48, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
106 db 0, 0, 4, 4, 0, 12, 4, 4, 4, 4, 4, 4, 4, 68, 56, 0
107 db 0, 0, 192, 64, 64, 66, 68, 120, 72, 68, 66, 194, 0, 0, 0, 0
108 db 0, 0, 112, 16, 16, 16, 16, 16, 16, 16, 16, 124, 0, 0, 0, 0
109 db 0, 0, 0, 0, 0, 236, 146, 146, 146, 146, 146, 130, 0, 0, 0, 0
110 db 0, 0, 0, 0, 0, 220, 98, 66, 66, 66, 66, 66, 0, 0, 0, 0
111 db 0, 0, 0, 0, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
112 db 0, 0, 0, 0, 0, 220, 98, 66, 66, 66, 66, 124, 64, 64, 224, 0
113 db 0, 0, 0, 0, 0, 118, 140, 132, 132, 132, 132, 124, 4, 4, 14, 0
114 db 0, 0, 0, 0, 0, 220, 98, 64, 64, 64, 64, 224, 0, 0, 0, 0
115 db 0, 0, 0, 0, 0, 124, 130, 128, 124, 2, 130, 124, 0, 0, 0, 0
116 db 0, 0, 32, 32, 32, 252, 32, 32, 32, 32, 34, 28, 0, 0, 0, 0
117 db 0, 0, 0, 0, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
118 db 0, 0, 0, 0, 0, 130, 130, 130, 130, 68, 40, 16, 0, 0, 0, 0
119 db 0, 0, 0, 0, 0, 130, 130, 146, 146, 146, 146, 108, 0, 0, 0, 0
120 db 0, 0, 0, 0, 0, 198, 40, 40, 16, 40, 40, 198, 0, 0, 0, 0
121 db 0, 0, 0, 0, 0, 130, 130, 130, 130, 130, 134, 122, 2, 4, 248, 0
122 db 0, 0, 0, 0, 0, 254, 132, 8, 16, 32, 66, 254, 0, 0, 0, 0
123 db 0, 0, 14, 16, 16, 16, 96, 16, 16, 16, 16, 14, 0, 0, 0, 0
124 db 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0
125 db 0, 0, 112, 8, 8, 8, 6, 8, 8, 8, 8, 112, 0, 0, 0, 0
126 db 0, 50, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
127 db 0, 0, 0, 16, 16, 40, 40, 68, 68, 130, 254, 0, 0, 0, 0, 0
128 db 0, 0, 60, 66, 128, 128, 128, 128, 128, 128, 66, 60, 16, 48, 0, 0
129 db 0, 0, 132, 0, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
130 db 0, 8, 16, 32, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
131 db 0, 16, 40, 68, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
132 db 0, 0, 132, 0, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
133 db 0, 32, 16, 8, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
134 db 0, 48, 72, 48, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
135 db 0, 0, 0, 0, 0, 124, 130, 128, 128, 128, 130, 124, 8, 48, 0, 0
136 db 0, 16, 40, 68, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
137 db 0, 0, 130, 0, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
138 db 0, 32, 16, 8, 0, 124, 130, 130, 252, 128, 130, 124, 0, 0, 0, 0
139 db 0, 0, 68, 0, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
140 db 0, 16, 40, 68, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
141 db 0, 32, 16, 8, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
142 db 0, 130, 0, 16, 40, 68, 130, 130, 254, 130, 130, 130, 0, 0, 0, 0
143 db 56, 68, 56, 16, 40, 68, 130, 130, 254, 130, 130, 130, 0, 0, 0, 0
144 db 8, 16, 0, 254, 66, 66, 72, 120, 72, 66, 66, 254, 0, 0, 0, 0
145 db 0, 0, 0, 0, 0, 236, 18, 18, 126, 144, 144, 110, 0, 0, 0, 0
146 db 0, 0, 62, 72, 136, 136, 254, 136, 136, 136, 136, 142, 0, 0, 0, 0
147 db 0, 16, 40, 68, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
148 db 0, 0, 130, 0, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
149 db 0, 32, 16, 8, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
150 db 0, 48, 72, 132, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
151 db 0, 32, 16, 8, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
152 db 0, 0, 130, 0, 0, 130, 130, 130, 130, 130, 134, 122, 2, 4, 248, 0
153 db 0, 130, 0, 124, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
154 db 0, 130, 0, 130, 130, 130, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
155 db 0, 16, 16, 124, 146, 144, 144, 144, 146, 124, 16, 16, 0, 0, 0, 0
156 db 0, 56, 68, 68, 64, 240, 64, 240, 64, 64, 66, 252, 0, 0, 0, 0
157 db 0, 0, 68, 68, 56, 16, 124, 16, 124, 16, 16, 16, 0, 0, 0, 0
158 db 0, 240, 136, 136, 240, 136, 136, 158, 136, 136, 136, 134, 0, 0, 0, 0
159 db 0, 14, 17, 16, 16, 16, 124, 16, 16, 16, 144, 96, 0, 0, 0, 0
160 db 0, 8, 16, 32, 0, 120, 4, 124, 132, 132, 140, 118, 0, 0, 0, 0
161 db 0, 8, 16, 32, 0, 48, 16, 16, 16, 16, 16, 56, 0, 0, 0, 0
162 db 0, 8, 16, 32, 0, 124, 130, 130, 130, 130, 130, 124, 0, 0, 0, 0
163 db 0, 8, 16, 32, 0, 132, 132, 132, 132, 132, 140, 118, 0, 0, 0, 0
164 db 0, 0, 100, 152, 0, 220, 98, 66, 66, 66, 66, 66, 0, 0, 0, 0
165 db 100, 152, 0, 130, 194, 162, 146, 138, 134, 130, 130, 130, 0, 0, 0, 0
166 db 0, 0, 48, 72, 72, 52, 0, 124, 0, 0, 0, 0, 0, 0, 0, 0
167 db 0, 0, 48, 72, 72, 48, 0, 120, 0, 0, 0, 0, 0, 0, 0, 0
168 db 0, 0, 16, 16, 0, 16, 32, 64, 128, 130, 130, 124, 0, 0, 0, 0
169 db 0, 0, 0, 0, 0, 0, 254, 128, 128, 128, 128, 0, 0, 0, 0, 0
170 db 0, 0, 0, 0, 0, 0, 254, 2, 2, 2, 2, 0, 0, 0, 0, 0
171 db 0, 64, 192, 66, 68, 72, 16, 32, 64, 156, 2, 12, 16, 30, 0, 0
172 db 0, 64, 192, 66, 68, 72, 16, 32, 70, 138, 18, 31, 2, 2, 0, 0
173 db 0, 0, 8, 8, 0, 8, 8, 8, 28, 28, 28, 8, 0, 0, 0, 0
174 db 0, 0, 0, 0, 0, 36, 72, 144, 72, 36, 0, 0, 0, 0, 0, 0
175 db 0, 0, 0, 0, 0, 144, 72, 36, 72, 144, 0, 0, 0, 0, 0, 0
176 db 17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68, 17, 68
177 db 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170
178 db 221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119, 221, 119
179 db 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
180 db 24, 24, 24, 24, 24, 24, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
181 db 24, 24, 24, 24, 24, 248, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
182 db 54, 54, 54, 54, 54, 54, 54, 246, 54, 54, 54, 54, 54, 54, 54, 54
183 db 0, 0, 0, 0, 0, 0, 0, 252, 54, 54, 54, 54, 54, 54, 54, 54
184 db 0, 0, 0, 0, 0, 240, 24, 248, 24, 24, 24, 24, 24, 24, 24, 24
185 db 54, 54, 54, 54, 54, 230, 6, 230, 54, 54, 54, 54, 54, 54, 54, 54
186 db 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54
187 db 0, 0, 0, 0, 0, 252, 6, 230, 54, 54, 54, 54, 54, 54, 54, 54
188 db 54, 54, 54, 54, 54, 230, 6, 252, 0, 0, 0, 0, 0, 0, 0, 0
189 db 54, 54, 54, 54, 54, 54, 54, 252, 0, 0, 0, 0, 0, 0, 0, 0
190 db 24, 24, 24, 24, 24, 248, 24, 240, 0, 0, 0, 0, 0, 0, 0, 0
191 db 0, 0, 0, 0, 0, 0, 0, 240, 24, 24, 24, 24, 24, 24, 24, 24
192 db 24, 24, 24, 24, 24, 24, 24, 15, 0, 0, 0, 0, 0, 0, 0, 0
193 db 24, 24, 24, 24, 24, 24, 24, 255, 0, 0, 0, 0, 0, 0, 0, 0
194 db 0, 0, 0, 0, 0, 0, 0, 255, 24, 24, 24, 24, 24, 24, 24, 24
195 db 24, 24, 24, 24, 24, 24, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
196 db 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
197 db 24, 24, 24, 24, 24, 24, 24, 255, 24, 24, 24, 24, 24, 24, 24, 24
198 db 24, 24, 24, 24, 24, 31, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
199 db 54, 54, 54, 54, 54, 54, 54, 55, 54, 54, 54, 54, 54, 54, 54, 54
200 db 54, 54, 54, 54, 54, 51, 48, 31, 0, 0, 0, 0, 0, 0, 0, 0
201 db 0, 0, 0, 0, 0, 31, 48, 51, 54, 54, 54, 54, 54, 54, 54, 54
202 db 54, 54, 54, 54, 54, 227, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
203 db 0, 0, 0, 0, 0, 255, 0, 227, 54, 54, 54, 54, 54, 54, 54, 54
204 db 54, 54, 54, 54, 54, 51, 48, 51, 54, 54, 54, 54, 54, 54, 54, 54
205 db 0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
206 db 54, 54, 54, 54, 54, 227, 0, 227, 54, 54, 54, 54, 54, 54, 54, 54
207 db 24, 24, 24, 24, 24, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0
208 db 54, 54, 54, 54, 54, 54, 54, 255, 0, 0, 0, 0, 0, 0, 0, 0
209 db 0, 0, 0, 0, 0, 255, 0, 255, 24, 24, 24, 24, 24, 24, 24, 24
210 db 0, 0, 0, 0, 0, 0, 0, 255, 54, 54, 54, 54, 54, 54, 54, 54
211 db 54, 54, 54, 54, 54, 54, 54, 31, 0, 0, 0, 0, 0, 0, 0, 0
212 db 24, 24, 24, 24, 24, 31, 24, 15, 0, 0, 0, 0, 0, 0, 0, 0
213 db 0, 0, 0, 0, 0, 15, 24, 31, 24, 24, 24, 24, 24, 24, 24, 24
214 db 0, 0, 0, 0, 0, 0, 0, 31, 54, 54, 54, 54, 54, 54, 54, 54
215 db 54, 54, 54, 54, 54, 54, 54, 255, 54, 54, 54, 54, 54, 54, 54, 54
216 db 24, 24, 24, 24, 24, 255, 24, 255, 24, 24, 24, 24, 24, 24, 24, 24
217 db 24, 24, 24, 24, 24, 24, 24, 240, 0, 0, 0, 0, 0, 0, 0, 0
218 db 0, 0, 0, 0, 0, 0, 0, 15, 24, 24, 24, 24, 24, 24, 24, 24
219 db 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
220 db 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255
221 db 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240
222 db 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
223 db 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0
224 db 0, 0, 0, 0, 0, 98, 148, 136, 136, 136, 148, 98, 0, 0, 0, 0
225 db 0, 0, 120, 132, 132, 132, 152, 132, 130, 162, 162, 156, 0, 0, 0, 0
226 db 0, 0, 254, 130, 130, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0
227 db 0, 0, 0, 0, 128, 254, 68, 68, 68, 68, 68, 70, 0, 0, 0, 0
228 db 0, 0, 254, 130, 64, 32, 16, 16, 32, 64, 130, 254, 0, 0, 0, 0
229 db 0, 0, 0, 0, 0, 126, 136, 136, 136, 136, 136, 112, 0, 0, 0, 0
230 db 0, 0, 0, 0, 0, 66, 66, 66, 66, 66, 66, 124, 64, 64, 128, 0
231 db 0, 0, 0, 0, 114, 156, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0
232 db 0, 0, 126, 24, 36, 66, 66, 66, 66, 36, 24, 126, 0, 0, 0, 0
233 db 0, 0, 56, 68, 130, 130, 254, 130, 130, 130, 68, 56, 0, 0, 0, 0
234 db 0, 0, 56, 68, 130, 130, 130, 68, 40, 40, 40, 238, 0, 0, 0, 0
235 db 0, 0, 14, 16, 8, 4, 62, 66, 66, 66, 66, 60, 0, 0, 0, 0
236 db 0, 0, 0, 0, 0, 102, 153, 153, 153, 102, 0, 0, 0, 0, 0, 0
237 db 0, 0, 0, 1, 2, 110, 153, 153, 153, 102, 64, 128, 0, 0, 0, 0
238 db 0, 0, 28, 32, 64, 64, 124, 64, 64, 64, 32, 28, 0, 0, 0, 0
239 db 0, 0, 0, 124, 130, 130, 130, 130, 130, 130, 130, 130, 0, 0, 0, 0
240 db 0, 0, 0, 0, 254, 0, 0, 254, 0, 0, 254, 0, 0, 0, 0, 0
241 db 0, 0, 0, 0, 16, 16, 124, 16, 16, 0, 0, 124, 0, 0, 0, 0
242 db 0, 0, 0, 16, 8, 4, 2, 4, 8, 16, 0, 62, 0, 0, 0, 0
243 db 0, 0, 0, 8, 16, 32, 64, 32, 16, 8, 0, 124, 0, 0, 0, 0
244 db 0, 0, 0, 4, 8, 124, 16, 16, 124, 32, 64, 0, 0, 0, 0, 0
245 db 16, 16, 16, 16, 16, 16, 16, 16, 16, 144, 144, 144, 96, 0, 0, 0
246 db 0, 0, 0, 0, 0, 16, 0, 124, 0, 16, 0, 0, 0, 0, 0, 0
247 db 0, 0, 0, 0, 0, 100, 152, 0, 100, 152, 0, 0, 0, 0, 0, 0
248 db 0, 56, 68, 68, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
249 db 0, 0, 0, 0, 0, 0, 0, 24, 24, 0, 0, 0, 0, 0, 0, 0
250 db 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0
251 db 0, 7, 4, 4, 4, 4, 8, 8, 136, 72, 40, 24, 0, 0, 0, 0
252 db 0, 40, 52, 36, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
253 db 0, 56, 68, 8, 16, 32, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0
254 db 0, 0, 0, 0, 126, 126, 126, 126, 126, 126, 126, 0, 0, 0, 0, 0
255 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
66 all: $(OBJDIR)/bekernel.com
77
88 $(OBJDIR)/bekernel.com: bekernel.s \
9 memory.s interrupt.s keyboard.s video.s disk.s comm.s \
9 memory.s interrupt.s keyboard.s video.s disk.s \
1010 screen.s digit.s display.s statusbar.s dataedit.s \
1111 page.s pageedit.s pageprop.s buffedit.s copypaste.s \
1212 syscall.s interp.s \
1313 ../inc/befos.inc ../inc/befkeys.inc ../inc/beeble.inc
14 $(ASM) -f bin -o $(.TARGET) -l bekernel.lst bekernel.s
14 $(ASM) -f bin -o $@ -l bekernel.lst bekernel.s
1515
1616 clean:
1717 rm -f $(OBJDIR)/*.com *.lst
0 ; BefOS Kernel BEKERNEL.COM
1 ; v2004.0404
2 ; (c)1999-2004 Cat's-Eye Technologies. All rights reserved.
0 ; BefOS Kernel
1 ; $Id$
2 ; (c)1999-2010 Cat's-Eye Technologies. All rights reserved.
33
44 ;--- NOTES ---------------------------------------------------;
55
102102 %include "video.s"
103103 %include "keyboard.s"
104104 %include "disk.s"
105 ; %include "comm.s"
106105
107106 %include "screen.s"
108107 %include "digit.s"
+0
-20
src/kernel/comm.s less more
0 ;--- BEGIN ---------------------------------------------------;
1
2 ;--- CONSTANTS -----------------------------------------------;
3
4 ;--- DATA ----------------------------------------------------;
5
6 SEGMENT .data
7
8 ;--- BSS -----------------------------------------------------;
9
10 SEGMENT .bss
11
12 combuf: RESB 2048 ; communications port buffer
13 comhandle: RESW 1
14
15 ;--- CODE ----------------------------------------------------;
16
17 SEGMENT .text
18
19 ;--- END -----------------------------------------------------;
8888 mov al, [coybyte]
8989 mov [cbuffer + di], al
9090 mov cl, al
91 jmp ShowByte
91 call ShowByte
92 jmp Advance
9293
9394 ;--- END -----------------------------------------------------;
22 ;--- CONSTANTS -----------------------------------------------;
33
44 ;--- DATA ----------------------------------------------------;
5
6 SEGMENT .data
7
8 ;--- Global Descriptor Table (GDT) ---------------------------;
9
10 gdt: times 16 db 0
11 srclen: dw 0
12 srcaddr: dw 0
13 db 0
14 srcacc: db 93h
15 srchigh: dw 0
16 destlen: dw 0
17 destaddr: dw 0
18 db 0
19 destacc: db 93h
20 desthigh: dw 0
21 gdtpad: times 16 db 0
225
236 ;--- BSS -----------------------------------------------------;
247
4023
4124 ret
4225
43
44 StoreExtPage: push es
45 call WorkLight
46
47 mov [srclen], word 2048
48 mov [srcaddr], word cbuffer
49 mov ax, ds
50 shl ax, 4
51 add [srcaddr], ax
52 mov ax, ds
53 shr ax, 12
54 mov [srcaddr+2], al
55
56 mov [destlen], word 2048
57 mov [destaddr], word 0
58 mov [destaddr+2], byte 10h
59
60 mov ax, ds
61 mov es, ax
62 mov ah, 87h
63 mov cx, 1024
64 mov si, gdt
65 int 15h
66
67 jc .Error
68 pop es
69 jmp OKLight
70 .Error: pop es
71 jmp BadLight
72
73
74 RetrieveExtPage:push es
75 call WorkLight
76
77 mov [srclen], word 2048
78 mov [srcaddr], word 0
79 mov [srcaddr+2], byte 10h
80
81 mov [destlen], word 2048
82 mov [destaddr], word cbuffer
83 mov ax, ds
84 shl ax, 4
85 add [destaddr], ax
86 mov ax, ds
87 shr ax, 12
88 mov [destaddr+2], al
89
90 mov ax, ds
91 mov es, ax
92 mov ah, 87h
93 mov cx, 1024
94 mov si, gdt
95 int 15h
96
97 jc .Error
98 pop es
99 call OKLight
100 jmp DisplayPage
101 .Error: pop es
102 jmp BadLight
103
10426 ;--- END -----------------------------------------------------;
7272 jmp UpdateCurByte
7373
7474
75 ; InsertByte
76 ; ax,si,di=DESTROYED
77 InsByte: nop
78
79 ; mov di, 0
80 ;@@Draw: mov ax, di
81 ; shl ax, 1
82 ; mov si, ax ; si = di * 2
83 ; mov ah, 12h
84 ; mov al, [cbuffer + di]
85 ; add si, [hoffs]
86 ; mov [es:si], ax
87 ; inc di
88 ; mov ax, 4000
89 ; cmp si, ax
90 ; jne @@Draw
91 jmp DisplayProperties
92
93
94 ; DeleteByte
95 ; ax,si,di=DESTROYED
96 DelByte: nop
97
98 ; mov di, 0
99 ;@@Draw: mov ax, di
100 ; shl ax, 1
101 ; mov si, ax ; si = di * 2
102 ; mov ah, 12h
103 ; mov al, [cbuffer + di]
104 ; add si, [hoffs]
105 ; mov [es:si], ax
106 ; inc di
107 ; mov ax, 4000
108 ; cmp si, ax
109 ; jne @@Draw
110 jmp DisplayProperties
111
112
11375 ;--- END -----------------------------------------------------;
2727 ;;--------------------------------------------;
2828 ;; Returns from caller if there are not enough
2929 ;: status bar lines visible on the screen.
30 ;; Also switches to text mode if there are.
3130 ;; ah: -> GARBAGE
3231 ;; al: minimum number of lines showing -> GARBAGE
3332 ;; dx: -> GARBAGE
4242 call TextVidBase
4343 ret
4444
45
46
47 BindFunc: nop
48
49 ; es:si -> null-terminated string, naming the desired function
50 ; returns bx = BefOS function pointer
51
52 ; 1 treeptr x = root;
53
54 ; mov bx, offset root
55
56 ; 2 if x == NULL abort
57
58 .Loop: cmp bx, 0
59 jne .SallyForth
60 mov bx, Unimp
61 ret
62
63 .SallyForth:
64
65 ; 3 mov di, x->key
66
67 mov di, [bx + 6]
68
69 ; 4 strcmp es:si, ds:di
70
71 mov al, [es:si]
72 mov dl, [ds:di]
73 cmp al, dl
74 ja .Right
75 ; ...
76
77 ; 5 if si < di, x = x->left, goto 2
78
79 mov bx, [bx]
80 jmp .Loop
81
82 ; 6 if si > di, x = x->right, goto 2
83
84 .Right: mov bx, [bx + 2]
85 jmp .Loop
86
87 ; return x->functionptr
88
89 mov bx, [bx + 2]
90 ret
91
9245 ;--- END -----------------------------------------------------;
44 OBJDIR=../../obj
55 BINDIR=../../bin
66
7 all: $(OBJDIR)/welcome.bin $(OBJDIR)/legend.bin
7 all: $(OBJDIR)/welcome.bin $(OBJDIR)/legend.bin $(OBJDIR)/keybind.bin
88
99 $(OBJDIR)/welcome.bin: welcome.txt
10 $(BINDIR)/txt2page < welcome.txt > $(.TARGET)
10 $(BINDIR)/txt2page < welcome.txt > $@
1111
1212 $(OBJDIR)/legend.bin: legend.bin
13 $(CP) legend.bin $(.TARGET)
13 $(CP) legend.bin $@
14
15 $(OBJDIR)/keybind.bin: ../inc/befkeys.inc
16 $(BINDIR)/mkkeypg.pl < ../inc/befkeys.inc | column -c 79 | expand | $(BINDIR)/txt2page > $@
1417
1518 clean:
1619 rm -f $(OBJDIR)/*.bin
Binary diff not shown
1111
1212 all: $(BINDIR)/amalgam8 $(BINDIR)/extract8 \
1313 $(BINDIR)/txt2page \
14 $(BINDIR)/mkbfinc.pl
14 $(BINDIR)/mkbfinc.pl \
15 $(BINDIR)/mkkeypg.pl
1516
1617 $(BINDIR)/amalgam8: amalgam8.c
17 $(CC) -o $(.TARGET) amalgam8.c
18 $(CC) -o $@ amalgam8.c
1819
1920 $(BINDIR)/extract8: extract8.c
20 $(CC) -o $(.TARGET) extract8.c
21 $(CC) -o $@ extract8.c
2122
2223 $(BINDIR)/txt2page: txt2page.c
23 $(CC) -o $(.TARGET) txt2page.c
24 $(CC) -o $@ txt2page.c
2425
2526 $(BINDIR)/mkbfinc.pl: mkbfinc.pl
26 $(CP) mkbfinc.pl $(.TARGET)
27 $(CHMOD) 755 $(.TARGET)
27 $(CP) mkbfinc.pl $@
28 $(CHMOD) 755 $@
29
30 $(BINDIR)/mkkeypg.pl: mkkeypg.pl
31 $(CP) mkkeypg.pl $@
32 $(CHMOD) 755 $@
2833
2934 clean:
3035 rm -f $(BINDIR)/*
1111 /*
1212 * extract8 - extract binary images from given pages
1313 * on a BefOS boot disk.
14 * Usage: extract8 befos.flp legend.bin 9 1
1415 */
1516 int
1617 main(int argc, char **argv)
0 #!/usr/bin/perl
1
2 my %binding = ();
3 while(defined($line = <STDIN>)) {
4 chomp $line;
5 if ($line =~ /^\s*dw\s+(\S+)\s*\;\s*(\S+)\s*(\S+).*?$/) {
6 my $command = $1;
7 my $scancode = $2;
8 my $key = $3;
9 $binding{$key} = $command;
10 }
11 }
12
13 foreach $key (sort keys %binding) {
14 next if $binding{$key} eq 'Unimp';
15 printf "%-10s => %s\n", $key, $binding{$key};
16 }
+0
-113
src/turbo/befterm.tasm less more
0 IDEAL
1 P8086
2 MODEL TINY
3
4 DATASEG
5
6 status dw ?
7 keyhit dw ?
8
9 CODESEG
10 ORG 0100h
11 PROC MAIN
12 INCLUDE "..\bekernel.inc"
13 call BefTermScreen
14
15 ; mov cx, 19200
16 mov bx, BefOS_InitCom
17 call BefOS
18
19 mov bx, BefOS_PlugCom
20 call BefOS
21
22 PollLoop: mov bx, BefOS_ReadCom
23 call BefOS
24
25 cmp ch, 0
26 je CheckKey
27 jmp ReadData
28
29 CheckKey: mov bx, BefOS_ReadKey
30 call BefOS
31
32 cmp cx, 0
33 je PollLoop
34 mov [word keyhit], cx ; else retrieve
35 mov ax, cx
36
37 FinalAlt: cmp ax, 1000h ; Alt-Q
38 jne RealKey
39
40 mov bx, BefOS_UnplugCom
41 call BefOS
42
43 mov bx, BefOS_TextVid
44 call BefOS
45 retf
46
47 RealKey: cmp al, 0
48 jne ASCIIKey
49
50 ASCIIKey:
51 mov bx, BefOS_WorkLight
52 call BefOS
53
54 mov cx, [word keyhit]
55 mov bx, BefOS_WriteCom
56 call BefOS
57
58 mov bx, BefOS_OKLight
59 call BefOS
60
61 jmp PollLoop
62
63 ReadData: mov al, cl
64
65 ;mov bx, BefOS_EditLight
66 ;call BefOS
67
68 cmp al, 13
69 jne NotReturn
70
71 mov bx, BefOS_LeftMarg
72 call BefOS
73 jmp CheckKey
74
75 NotReturn: cmp al, 10
76 jne NotLineFeed
77
78 mov bx, BefOS_LineFeed
79 call BefOS
80 jmp CheckKey
81
82 NotLineFeed: cmp al, 12
83 jne NotFormFeed
84
85 call BefTermScreen
86 jmp CheckKey
87
88 NotFormFeed: xor cx, cx
89 mov cl, al
90 mov bx, BefOS_WriteByte
91 call BefOS
92 mov bx, BefOS_BufRight
93 call BefOS
94
95 SkipRead: jmp CheckKey
96
97 ENDP
98
99 PROC BefTermScreen
100
101 mov cx, 0
102 mov bx, BefOS_MoveCrsr
103 call BefOS
104 mov cl, 6dh
105 mov bx, BefOS_ClrScreen
106 call BefOS
107 mov bx, BefOS_RefreshStatus
108 jmp BefOS
109
110 ENDP
111
112 END MAIN
+0
-2069
src/turbo/bekernel.tasm less more
0 ; BefOS Kernel BEKERNEL.COM v1999.03.28 (c)1999 Cat's-Eye Technologies.
1
2 IDEAL
3 P8086
4 MODEL TINY
5
6 WORK_LIGHT EQU 0ee0ah
7 OK_LIGHT EQU 02a0ah
8 BAD_LIGHT EQU 0cc0ah
9 EDIT_LIGHT EQU 099b0h
10
11 DATASEG
12 ;---------WORK----------;
13 cluster dw 0010h ; current cluster
14 bufptr dw 0000h ; current byte in the current cluster
15 bdevice dw 0000h ; current illogical device number
16 lastmove dw BufRight ; last direction cursor moved
17 ;--------OPTIONS--------;
18 bits db 00h ; 01 bit 0 - Edit Mode
19 ; 02 bit 1
20 ; 04 bit 2 - High if under DOS
21 ; 08 bit 3 - Stringmode
22 ; 10 bit 4
23 ; 20 bit 5
24 ; 40 bit 6
25 ; 80 bit 7
26 vpage db 00
27 coybyte db 01
28 beeblequit db 00
29 hoffs dw 160 ; number of heading lines displayed, in offset (1 line = 160)
30 timerSegment dw 0
31 timerOffset dw 0
32 comSegment dw 0
33 comOffset dw 0
34 breakSegment dw 0
35 breakOffset dw 0
36 prtscSegment dw 0
37 prtscOffset dw 0
38
39 ;---------VIDEO---------;
40 ALIGN
41 vbase dw 0b800h ; next page = 0b900h?
42 pixbase dw 0a000h
43 ;---------GDT-----------;
44 ALIGN
45 gdt db 16 dup (0)
46 srclen dw 0
47 srcaddr dw 0
48 db 0
49 srcacc db 93h
50 srchigh dw 0
51 destlen dw 0
52 destaddr dw 0
53 db 0
54 destacc db 93h
55 desthigh dw 0
56 gdtpad db 16 dup (0)
57 ;-----BefOS "STACK"-----;
58 ossp dw 0
59 ;-----Key Bindings------;
60
61 INCLUDE "inc/befkeys.inc"
62
63 ;-----Beeblebrox Bindings---;
64
65 INCLUDE "inc/beeble.inc"
66
67 ; variables used by line
68 ; int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
69 ldx dw 0
70 ldy dw 0
71 lsdx dw 0
72 lsdy dw 0
73 ldxabs dw 0
74 ldyabs dw 0
75 lx dw 0
76 ly dw 0
77 lpx dw 0
78 lpy dw 0
79 lcol db 0
80
81 ;----------DISK---------;
82 sectrk dw 18 ; sectors per track
83 bytesec dw 512 ; bytes per sector
84 numhead dw 2 ; number of heads
85 ;---------BUFFERS-------;
86 cbuffer db 2000 dup (?) ; cluster data buffer
87 cheader db 48 dup (?) ; cluster header buffer
88 bbuffer db 2048 dup (?) ; backup cluster buffer
89 obuffer db 2048 dup (?) ; memory copy of colour buffer
90 combuf db 2048 dup (?) ; communications port buffer
91 ;-------KEYBOARD--------;
92 keyhit dw ? ; BIOS code for last key hit
93 shiftflags dw ? ; shift flags for last key hit
94 ;----------RAM----------;
95 basek dw ? ; non-extended kilobytes
96 extk dw ? ; extended kilobytes
97 ;-----SYSTEM STACK------;
98 osstack dw 256 dup (?) ; BefOS system stack
99
100 comhandle dw ?
101 temp dw ?
102 temp2 dw ?
103 templen dw ?
104 attr db ?
105
106 CODESEG
107 ORG 0100h ; strictly necessary
108
109 PROC MAIN
110 Start:
111 ;-FIX DATA SEGMENT----------------------;
112 jmp short GoBefOS
113
114 jmp BindFunc ; always at cs:0102h
115
116 GoBefOS: mov ax, cs
117 mov ds, ax ; fix data segment
118 mov ss, ax ; fix stack segment
119 mov sp, 0fffeh
120
121 mov ax, 1200h
122 int 2fh
123 cmp al, 0ffh ; not if there's no DOS!
124 je @@DOS
125 jmp @@Video
126
127 @@DOS: or [byte bits], 04h ; notify BefOS
128 mov ax, cs ; allocate some memory
129 add ax, 400h ; main prog/data = 16K
130 mov [word runseg+3], ax ; modify the far call!
131
132 ;-VIDEO---------------------------------;
133 @@Video: mov ax, 0500h
134 int 10h
135 mov ah, 15
136 int 10h
137 cmp al, 7
138 jne @@SPSH
139 mov [word vbase], 0b000h
140 ;-SPLASH--------------------------------;
141 @@SPSH: call TextVid
142 mov cl, 2fh
143 call ClrScreen
144
145 ;-RAM-----------------------------------;
146 @@RAM: int 12h ; get avail base mem in k
147 mov [word basek], ax
148
149 mov ax, 8800h
150 int 15h ; SYSTEM - GET EXTENDED MEMORY SIZE (286+)
151 mov [word extk], ax
152
153 call RefreshStatus
154 call LoadClust
155 call MoveCursor
156
157 ;-ISRs----------------------------------;
158
159 call PlugBreak
160 call PlugPrtSc
161
162 ;-SELECT--------------------------------;
163
164 @@Select: call GetKey
165
166 mov ax, [word keyhit]
167 cmp al, 0
168 jne @@ASCIIKey
169 cmp ah, 3
170 je @@ASCIIKey ; Ctrl-2!
171 xor bx, bx
172 mov bl, ah
173 shl bx, 1
174 mov si, bx
175 mov ax, [word keytab + si]
176 call ax
177 jmp @@Select
178
179 @@ASCIIKey: test [byte bits], 01h
180 jz @@NoWrite
181 mov cx, [word keyhit]
182 call WriteByte
183 call Advance
184 jmp @@Select
185
186 @@NoWrite: call BadLight
187 jmp @@Select
188
189 ENDP
190
191 ;=============PROCS=============;
192
193 PUBLIC BindFunc
194 PROC BindFunc
195 ; es:si -> null-terminated string, naming the desired function
196 ; returns bx = BefOS function pointer
197
198 ; 1 treeptr x = root;
199
200 ; mov bx, offset root
201
202 ; 2 if x == NULL abort
203
204 @@Loop: cmp bx, 0
205 jne @@SallyForth
206 mov bx, offset Unimp
207 ret
208
209 @@SallyForth:
210
211 ; 3 mov di, x->key
212
213 mov di, [word bx + 6]
214
215 ; 4 strcmp es:si, ds:di
216
217 mov al, [byte es:si]
218 mov dl, [byte ds:di]
219 cmp al, dl
220 ja @@Right
221 ; ...
222
223 ; 5 if si < di, x = x->left, goto 2
224
225 mov bx, [word bx]
226 jmp @@Loop
227
228 ; 6 if si > di, x = x->right, goto 2
229
230 @@Right: mov bx, [word bx + 2]
231 jmp @@Loop
232
233 ; return x->functionptr
234
235 mov bx, [word bx + 2]
236 ret
237
238 ENDP
239
240 PROC EditModeOnly
241 ; ax may be destroyed
242 test [byte bits], 01h
243 jnz @@Return
244 FallThru: call BadLight
245 pop ax
246 @@Return: ret
247 ENDP
248
249 PROC NotInEditMode
250 ; ax may be destroyed
251 test [byte bits], 01h
252 jz @@Return
253 pop ax
254 @@Return: ret
255 ENDP
256
257 PROC DOSOnly
258 ; ax may be destroyed
259 test [byte bits], 04h
260 jz FallThru
261 ret
262 ENDP
263
264 PROC NotUnderDOS
265 ; ax may be destroyed
266 test [byte bits], 04h
267 jnz FallThru
268 ret
269 ENDP
270
271 PUBLIC Unimp
272 PROC Unimp
273 jmp BadLight
274 ENDP
275
276 PUBLIC SysCall
277 PROC SysCall
278 ; SysCall - this is called far only by BefOS applications.
279
280 ; ax = destroyed
281 ; bx = function number
282
283 mov ax, cs
284 mov ds, ax
285 call bx
286 retf
287 ENDP SysCall
288
289 PUBLIC TextVidBase
290 PROC TextVidBase
291 mov es, [word vbase]
292 ret
293 ENDP
294 PUBLIC PixVidBase
295 PROC PixVidBase
296 mov es, [word pixbase]
297 ret
298 ENDP
299
300 PUBLIC TextVid
301 PROC TextVid
302
303 ; TODO: determine if the text video page is already active;
304 ; if so, only swap pages with TextVidPage.
305 ; this will reduce flicker on return to OS from application.
306
307 mov ax, 0003h
308 int 10h
309 mov ax, 0500h
310 int 10h
311 mov [byte vpage], 0
312
313 ; mov ax, ds
314 ; mov es, ax
315 ; mov ax, 1100h
316 ; mov bp, offset charset
317 ; mov cx, 256 ; num of chars to be reimaged
318 ; mov dx, 0 ; first char num to be reimaged
319 ; mov bl, 0 ; block to load in "map 2"
320 ; mov bh, 16 ; bytes per char-image
321 ; int 10h
322
323 call TextVidBase
324 call OKLight
325 call RefreshStatus
326 jmp DisplayClust
327 ENDP
328
329 PUBLIC PixVid
330 PROC PixVid
331 mov ax, 0013h
332 int 10h
333 jmp PixVidBase
334 ENDP
335
336 PUBLIC NextTextVidPage
337 PROC NextTextVidPage
338 mov al, [byte vpage]
339 inc al
340 and al, 7
341 mov [byte vpage], al
342 mov ah, 05h
343 int 10h
344 ret
345 ENDP
346
347 PUBLIC PrevTextVidPage
348 PROC PrevTextVidPage
349 mov al, [byte vpage]
350 dec al
351 and al, 7
352 mov [byte vpage], al
353 mov ah, 05h
354 int 10h
355 ret
356 ENDP
357
358 PUBLIC PushWord
359 PROC PushWord
360 mov bx, [word ossp]
361 mov [word bx + offset osstack], cx
362 inc [word ossp]
363 ret
364 ENDP
365
366 PUBLIC PopWord
367 PROC PopWord
368 dec [word ossp]
369 mov bx, [word ossp]
370 mov cx, [word bx + offset osstack]
371 ret
372 ENDP
373
374 PUBLIC PushHexInstr
375 PROC PushHexInstr
376 mov bx, [word bufptr]
377 xor ch, ch
378 mov cl, [byte offset cbuffer + bx]
379 sub cl, 'a'
380 jmp PushWord
381 ENDP
382
383 PUBLIC AddWords
384 PROC AddWords
385 call PopWord
386 mov ax, cx
387 call PopWord
388 add ax, cx
389 mov cx, ax
390 jmp PushWord
391 ENDP
392
393 PUBLIC SubWords
394 PROC SubWords
395 call PopWord
396 mov ax, cx
397 call PopWord
398 sub ax, cx
399 mov cx, ax
400 jmp PushWord
401 ENDP
402
403 PUBLIC MulWords
404 PROC MulWords
405 call PopWord
406 mov ax, cx
407 call PopWord
408 mul cx
409 mov cx, ax
410 jmp PushWord
411 ENDP
412
413 PUBLIC DivWords
414 PROC DivWords
415 call PopWord
416 mov ax, cx
417 call PopWord
418 div cx
419 mov cx, ax
420 jmp PushWord
421 ENDP
422
423 PUBLIC GetKey
424 PROC GetKey
425
426 mov ah, 12h
427 int 16h ; get key shift states
428
429 mov [word shiftflags], ax
430
431 mov cx, ax
432 call StatusWord
433
434 ; Notes: AL bit 3 set only for left Alt key on many machines.
435 ; AH bits 7 through 4 always clear on a Compaq SLT/286.
436 ; INT 16/AH=09h should be used to determine whether this function
437 ; is supported.
438
439 ; Bitfields for _al_
440 ;Bit(s) Description (Table 00587)
441 ;7 Insert active
442 ;6 CapsLock active
443 ;5 NumLock active
444 ;4 ScrollLock active
445 ;3 Alt key pressed (either Alt on 101/102-key keyboards)
446 ;2 Ctrl key pressed (either Ctrl on 101/102-key keyboards)
447 ;1 left shift key pressed
448 ;0 right shift key pressed
449
450 ;Bitfields for _ah_
451 ;Bit(s) Description (Table 00588)
452 ;7 SysReq key pressed (SysReq is often labeled SysRq)
453 ;6 CapsLock pressed
454 ;5 NumLock pressed
455 ;4 ScrollLock pressed
456 ;3 right Alt key pressed
457 ;2 right Ctrl key pressed
458 ;1 left Alt key pressed
459 ;0 left Ctrl key pressed
460
461 xor ah, ah ; get a key
462 int 16h
463 mov [word keyhit], ax
464
465 cmp [word hoffs], 0
466 je @@SkipKey
467
468 call TextVidBase
469 mov bx, ax
470 mov ah, 70h
471 mov di, 140
472 call DisplayShort
473
474 mov cx, [word keyhit]
475 @@SkipKey: ret
476 ENDP
477
478 PUBLIC ReadKey
479 PROC ReadKey
480
481 xor ah, ah ; check for outstanding key
482 inc ah
483 int 16h
484 jz @@NoKey
485 jmp GetKey
486 @@NoKey: xor cx, cx
487 ret
488 ENDP
489
490 PUBLIC ReadByte
491 PROC ReadByte
492 xor cx, cx
493 mov di, [word bufptr]
494 mov cl, [byte cbuffer + di]
495 ret
496 ENDP
497
498 PUBLIC WriteByte
499 PROC WriteByte
500 mov si, [word bufptr]
501 mov [byte cbuffer + si], cl
502 call TextVidBase
503 mov bx, si
504 shl bx, 1
505 add bx, [word hoffs]
506 mov si, bx
507 mov ch, 71h
508 mov [word es:si], cx
509 ret
510 ENDP
511
512 PUBLIC BufHome
513 PROC BufHome
514 mov [word bufptr], 0
515 jmp MoveCursor
516 ENDP
517
518 PUBLIC Beeblebrox
519 PROC Beeblebrox
520
521 xor al, al
522 mov [byte beeblequit], al
523
524 @@Loop: mov al, [byte beeblequit]
525 cmp al, 0
526 jne @@BeebleQuit
527 call ExecBeebInstr
528 jmp @@Loop
529 @@BeebleQuit: ret
530 ENDP
531
532 PUBLIC EndBeeblebrox
533 PROC EndBeeblebrox
534
535 mov [byte beeblequit], 1
536 ret
537 ENDP
538
539 PUBLIC ExecBeebInstr
540 PROC ExecBeebInstr
541
542 mov di, [word bufptr]
543 xor bh, bh
544 mov bl, [byte offset cbuffer + di]
545
546 shl bx, 1
547 mov ax, [offset scripttab + bx]
548 call ax
549 jmp Advance
550 ENDP
551
552 PUBLIC Advance
553 PROC Advance
554 mov ax, [word lastmove]
555 jmp ax
556 ENDP
557
558 PUBLIC MoreScreen
559 PROC MoreScreen
560 cmp [word hoffs], 0
561 ja @@LessHeader
562 ret
563 @@LessHeader: sub [word hoffs], 160
564 jmp DisplayClust
565 ENDP
566
567 PUBLIC LessScreen
568 PROC LessScreen
569 cmp [word hoffs], 2560
570 jb @@MoreHeader
571 ret
572 @@MoreHeader: add [word hoffs], 160
573
574 mov ax, [word bufptr]
575 mov bx, [word hoffs]
576 shr bx, 1
577 add ax, bx
578 cmp ax, 2000
579 jb @@InRange
580
581 sub [word bufptr], 80
582
583 @@InRange: cmp [word hoffs], 320
584 jae @@Blanks
585 cmp [word hoffs], 160
586 jne @@StillOn
587 call OKLight
588 call RefreshStatus
589 @@StillOn: jmp DisplayClust
590 @@Blanks:
591 call TextVidBase
592 mov si, 160
593 @@Bloop: mov [word es:si], 2020h
594 inc si
595 inc si
596 cmp si, [word hoffs]
597 jne @@Bloop
598 jmp DisplayClust
599 ENDP
600
601 PUBLIC RefreshStatus
602 PROC RefreshStatus
603 call TextVidBase
604 mov di, 0
605 mov [word es:di], 02f42h ; the BefOS 'logo'
606
607 mov di, 4
608 mov bx, [word basek]
609 mov ah, 07h
610 call DisplayShort
611
612 mov bx, [word extk]
613 mov ah, 70h
614 call DisplayShort
615
616 mov bx, [word keyhit]
617 mov ah, 70h
618 mov di, 140
619 call DisplayShort
620
621 mov ah, 03h
622 mov bx, [word cluster] ; Display cluster number onscreen
623 mov di, 152
624 jmp DisplayShort
625 ENDP
626
627 PUBLIC HighBit
628 PROC HighBit
629 call EditModeOnly
630 mov bx, [word bufptr]
631 mov cl, [byte cbuffer + bx]
632 xor cl, 80h
633 mov [byte cbuffer + bx], cl
634 jmp ShowByte
635 ENDP
636
637 PUBLIC StringMode
638 PROC StringMode
639 jmp Unimp
640 ENDP
641
642 PUBLIC NextDev
643 PROC NextDev
644 call NotInEditMode
645 inc [word bdevice]
646 cmp [word bdevice], 2 ; 2 devices?!?
647 jne @@Return
648 mov [word bdevice], 0
649 @@Return: jmp LoadClust
650 ENDP
651
652 PUBLIC PrevDev
653 PROC PrevDev
654 call NotInEditMode
655 dec [word bdevice]
656 cmp [word bdevice], 0ffffh
657 jne @@Return
658 mov [word bdevice], 1
659 @@Return: jmp LoadClust
660 ENDP
661
662 PUBLIC ClustUp
663 PROC ClustUp
664 call NotInEditMode
665 inc [word cluster]
666 cmp [word cluster], 720 ; 720 clusters
667 jne @@Return
668 mov [word cluster], 0
669 @@Return: jmp LoadClust
670 ENDP
671
672
673 PUBLIC ClustDown
674 PROC ClustDown
675 call NotInEditMode
676 dec [word cluster]
677 cmp [word cluster], 0ffffh
678 jne @@Return
679 mov [word cluster], 719
680 @@Return: jmp LoadClust
681 ENDP
682
683 PUBLIC NextClust
684 PROC NextClust
685 mov cx, [word cheader+2]
686 HyperClust: cmp cx, 0
687 je @@Abort
688 jmp GoClust
689 @@Abort: jmp BadLight
690 ENDP
691
692 PUBLIC PrevClust
693 PROC PrevClust
694 mov cx, [word cheader+4]
695 jmp HyperClust
696 ENDP
697
698 PUBLIC HelpClust
699 PROC HelpClust
700 mov cx, [word cheader+10]
701 jmp HyperClust
702 ENDP
703
704 PUBLIC ColourClust
705 PROC ColourClust
706 mov cx, [word cheader+8]
707 jmp HyperClust
708 ENDP
709
710 PUBLIC BufRight
711 PROC BufRight
712 mov [word lastmove], offset BufRight
713 BufHopRight: inc [word bufptr]
714 mov ax, 2000
715 mov bx, [word hoffs]
716 shr bx, 1
717 sub ax, bx
718 cmp [word bufptr], ax
719 jne @@Return
720 mov [word bufptr], 0
721 @@Return: jmp MoveCursor
722 ENDP
723
724
725 PUBLIC BufLeft
726 PROC BufLeft
727 mov [word lastmove], offset BufLeft
728 BufHopLeft: dec [word bufptr]
729 cmp [word bufptr], 0ffffh
730 jne @@Return
731 mov ax, 2000
732 mov bx, [word hoffs]
733 shr bx, 1
734 sub ax, bx
735 dec ax
736 mov [word bufptr], ax
737 @@Return: jmp MoveCursor
738 ENDP
739
740 PUBLIC BufUp
741 PROC BufUp
742 mov [word lastmove], offset BufUp
743 BufHopUp: sub [word bufptr], 80
744 cmp [word bufptr], 0
745 jge @@Return
746 mov ax, 2000
747 mov bx, [word hoffs]
748 shr bx, 1
749 sub ax, bx
750 add [word bufptr], ax
751 @@Return: jmp MoveCursor
752 ENDP
753
754
755 PUBLIC BufDown
756 PROC BufDown
757 mov [word lastmove], offset BufDown
758 BufHopDown: add [word bufptr], 80
759 mov ax, 2000
760 mov bx, [word hoffs]
761 shr bx, 1
762 sub ax, bx
763 cmp [word bufptr], ax
764 jl @@Return
765 sub [word bufptr], ax
766 @@Return: jmp MoveCursor
767 ENDP
768
769 PUBLIC LineFeed
770 PROC LineFeed
771 ; just like BufDown except invokes a scroll if on bottom line.
772 add [word bufptr], 80
773 mov ax, 2000
774 mov bx, [word hoffs]
775 shr bx, 1
776 sub ax, bx
777 cmp [word bufptr], ax
778 jl @@Return
779 sub [word bufptr], 80 ; back to where we once belonged
780
781 ; get top line of screen = hoffs/160
782 mov ax, bx
783 mov bx, 80
784 xor dx, dx ; Zero high!
785 div bx
786
787 xor cx, cx
788 mov ch, al
789
790 ; scroll area on screen
791
792 mov ax, 0601h
793 mov bh, 27h ; todo: better attribute... need var
794 mov dx, 184fh ; (79,24)
795 int 10h ; scroll it
796
797 @@Return: jmp MoveCursor
798 ENDP
799
800 PUBLIC LeftMarg
801 PROC LeftMarg
802 mov ax, [word bufptr]
803 mov bx, 80
804 xor dx, dx ; Zero high!
805 div bx
806
807 xor ah, ah
808 shl ax, 4
809 mov bx, ax
810 shl bx, 2
811 add ax, bx
812
813 mov [word bufptr], ax
814
815 jmp MoveCursor
816 ENDP
817
818 PUBLIC Shutdown
819 PROC Shutdown
820 ; Under DOS, quits to DOS.
821 ; As true BefOS, may reboot or shut down the system.
822
823 call DOSOnly
824 call NotInEditMode
825
826 call UnplugClock
827 ;call UnplugCom
828 call UnplugPrtSc
829 call UnplugBreak
830
831 mov cl, 07h ; clear me!
832 call ClrScreen
833
834 xor ah, ah ; reset
835 xor dl, dl ; disk 0
836 int 13h
837
838 mov ax, 4c00h
839 int 21h ; exit
840 ENDP
841
842 PUBLIC ImpClust
843 PROC ImpClust
844 ; Import a file into a cluster, only under DOS.
845
846 call DOSOnly
847 call EditModeOnly
848
849 mov dx, offset cbuffer
850 mov ah, 3dh ; open the file
851 mov al, 0 ; 0 = read only
852 int 21h
853 jnc @@GotFile
854 jmp BadLight
855
856 @@GotFile: mov [comhandle], ax
857
858 mov ah, 3fh ; read
859 mov bx, [comhandle] ; from handle
860 mov cx, 2048 ; the .COM file
861 mov dx, offset cbuffer
862 int 21h
863 jnc @@Close
864 @@LocalFail: jmp BadLight
865
866 @@Close: mov bx, [comhandle]
867 mov ah, 3eh
868 int 21h
869 jc @@LocalFail
870
871 jmp DisplayClust
872
873
874 ENDP
875
876 PUBLIC DeviceInfo
877 PROC DeviceInfo
878
879 mov ah, 15h
880 mov bx, [word bufptr]
881 mov dl, [byte cbuffer + bx]
882 int 13h ; DISK - GET DISK TYPE
883 jc @@Error
884
885 push cx
886 push dx
887
888 call TextVidBase
889
890 mov ah, 5fh
891 pop bx
892 mov di, 124
893 call DisplayShort
894 pop bx
895 call DisplayShort
896
897 jmp OKLight
898
899 @@Error: jmp BadLight
900
901 ENDP
902
903 PUBLIC ClrScreen
904 PROC ClrScreen
905 mov bh, cl
906 xor cx, cx ; (0,0)-
907 mov dx, 184fh ; (79,24)
908 mov ax, 0600h ; BIOS clear rectangle
909 int 10h
910 ret
911 ENDP
912
913 PROC UpdateCurByte ; on the status bar
914
915 cmp [word hoffs], 0
916 ja @@OKGO
917 ret
918
919 @@OKGO: mov di, [word bufptr]
920 mov bl, [byte cbuffer + di]
921
922 mov ah, 1fh
923 mov di, 148
924 jmp DisplayByte
925 ENDP
926
927 PROC MoveCursor
928 ; MoveCursor - moves cursor to reflect bufptr.
929 ; ax=DESTROYED
930 ; bx=DESTROYED
931 ; dx=DESTROYED
932
933 xor dx, dx
934 mov ax, [word bufptr]
935 mov bx, [word hoffs]
936 shr bx, 1
937 add ax, bx
938 mov bx, 80
939 div bx
940
941 mov dh, al
942
943 mov ah, 02h
944 mov bh, 00h
945
946 int 10h ; cursor gotoxy
947 jmp UpdateCurByte
948
949 ENDP
950
951 PUBLIC MoveCrsr
952 PROC MoveCrsr
953 mov [word bufptr], cx
954 jmp MoveCursor
955 ENDP
956
957 PROC DisplayProperties
958 ; ax,si,di=DESTROYED
959
960 cmp [word hoffs], 0
961 ja @@OKGO
962 jmp MoveCursor
963
964 @@OKGO: mov di, 0
965 @@Green: mov ax, di
966 shl ax, 1
967 mov si, ax ; si = di * 2
968 mov ax, 2020h
969 mov [word es:si + 20], ax
970 inc di
971 cmp di, 60
972 jne @@Green
973
974 mov di, 0
975 cmp [word cheader], 0bef0h ; validate header ID.
976 je @@Draw
977 jmp MoveCursor
978
979 @@Draw: mov ax, di ; show file description.
980 shl ax, 1
981 mov si, ax ; si = di * 2
982 mov ah, 71h
983 mov al, [byte cheader + 32 + di]
984 mov [word es:si + 100], ax
985 inc di
986 cmp di, 16
987 jne @@Draw
988
989 mov ah, 71h
990 mov bx, [word cheader+2]
991 mov di, 28
992 call DisplayShort
993
994 mov ah, 74h
995 mov bx, [word cheader+4]
996 call DisplayShort
997
998 mov ah, 7ah
999 mov bx, [word cheader+6]
1000 call DisplayShort
1001
1002 mov ah, 7bh
1003 mov bx, [word cheader+8]
1004 call DisplayShort
1005
1006 mov ah, 70h
1007 mov bx, [word cheader+10]
1008 call DisplayShort
1009
1010 jmp MoveCursor
1011 ENDP
1012
1013 PUBLIC EditClustProps
1014 PROC EditClustProps
1015 ; ax,si,di=DESTROYED
1016
1017 cmp [word hoffs], 0
1018 ja @@OKGO
1019 jmp MoveCursor
1020
1021 @@OKGO: cmp [word cheader], 0bef0h ; first off validate header ID.
1022 jnz @@Abort
1023 mov di, 0
1024 jmp @@Edit
1025 @@Abort: jmp BadLight
1026 @@Edit: mov ah, 71h
1027 mov di, 100
1028 mov cx, 16
1029 call EditString
1030
1031 mov di, 0
1032 @@Save: mov ax, di ; show file description.
1033 shl ax, 1
1034 mov si, ax ; si = di * 2
1035 mov ax, [word es:si + 100]
1036 mov [byte cheader + 32 + di], al
1037 inc di
1038 cmp di, 16
1039 jne @@Save
1040
1041 mov ah, 71h
1042 mov bx, [word cheader+2]
1043 push bx
1044 mov di, 28
1045 call EditShort
1046 mov [word cheader+2], bx
1047
1048 mov ah, 74h
1049 mov bx, [word cheader+4]
1050 pop bx
1051 call EditShort
1052 mov [word cheader+4], bx
1053
1054 mov ah, 7ah
1055 mov bx, [word cheader+6]
1056 call EditShort
1057 mov [word cheader+6], bx
1058
1059 mov ah, 7bh
1060 mov bx, [word cheader+8]
1061 call EditShort
1062 mov [word cheader+8], bx
1063
1064 mov ah, 70h
1065 mov bx, [word cheader+10]
1066 call EditShort
1067 mov [word cheader+10], bx
1068
1069 jmp MoveCursor
1070 ret
1071 ENDP
1072
1073 PUBLIC InitClustProps
1074 PROC InitClustProps
1075 ; ax,si,di=DESTROYED
1076
1077 mov [word cheader], 0bef0h
1078 xor ax, ax
1079 mov [word cheader+2], ax
1080 mov [word cheader+4], ax
1081 mov [word cheader+6], ax
1082 mov [word cheader+8], ax
1083 mov [word cheader+10], ax
1084 jmp DisplayProperties
1085
1086 ENDP
1087
1088 PUBLIC DelClustProps
1089 PROC DelClustProps
1090 mov [word cheader], 0000h ; invalidate the header ID.
1091 jmp DisplayProperties
1092
1093 ENDP
1094
1095 PROC DisplayClust
1096 ; DisplayClust - display memory cluster buffer on-screen
1097 ; ax,si,di=DESTROYED
1098
1099 mov di, 0
1100 @@Draw: mov ax, di
1101 shl ax, 1
1102 mov si, ax ; si = di * 2
1103 mov ah, [byte obuffer + di]
1104 mov al, [byte cbuffer + di]
1105 add si, [word hoffs]
1106 mov [word es:si], ax
1107 inc di
1108 mov ax, 4000
1109 cmp si, ax
1110 jne @@Draw
1111 jmp DisplayProperties
1112 ENDP
1113
1114 PUBLIC CopyClust
1115 PROC CopyClust
1116 ; CopyClust - copy cluster in memory to clipboard
1117 ; ax,di=DESTROYED
1118
1119 mov di, 0
1120 @@Copy: mov ax, di
1121 mov al, [byte cbuffer + di]
1122 mov [byte bbuffer + di], al
1123 inc di
1124 cmp di, 2048
1125 jne @@Copy
1126 jmp OKLight
1127 ENDP
1128
1129 PUBLIC CutClust
1130 PROC CutClust
1131 call EditModeOnly
1132 call CopyClust
1133 jmp FillClust
1134 ENDP
1135
1136 PUBLIC CopyByte
1137 PROC CopyByte
1138 ; CopyByte - copy byte from cluster to clipboard
1139 ; al,di=DESTROYED
1140
1141 mov di, [word bufptr]
1142 mov al, [byte cbuffer + di]
1143 mov [byte coybyte], al
1144 jmp OKLight
1145 ENDP
1146
1147 PUBLIC PasteByte
1148 PROC PasteByte
1149 ; CopyByte - copy byte from cluster to clipboard
1150 ; al,cl,di=DESTROYED
1151
1152 call EditModeOnly
1153 mov di, [word bufptr]
1154 mov al, [byte coybyte]
1155 mov [byte cbuffer + di], al
1156 mov cl, al
1157 jmp ShowByte
1158 ENDP
1159
1160 PUBLIC EditMode
1161 PROC EditMode
1162 ; EditMode
1163 or [byte bits], 1
1164 jmp EditLight
1165 ENDP
1166
1167 PUBLIC IncByte
1168 PROC IncByte
1169 ; IncByte
1170 ; al,cl,di=DESTROYED
1171
1172 mov al, 1
1173 jmp DeltaByte
1174 ENDP
1175
1176 PUBLIC DecByte
1177 PROC DecByte
1178 ; DecByte
1179 ; al,cl,di=DESTROYED
1180 mov al, -1
1181 ENDP
1182
1183 PROC DeltaByte
1184 ; DeltaByte
1185 ; al=delta
1186 ; cl,di=DESTROYED
1187
1188 call EditModeOnly
1189 mov di, [word bufptr]
1190 mov cl, [byte cbuffer + di]
1191 add cl, al
1192 jmp ShowByte
1193 ENDP
1194
1195 PUBLIC ShowByte
1196 PROC ShowByte
1197 call WriteByte
1198 jmp UpdateCurByte
1199 ENDP
1200
1201 PUBLIC InsByte
1202 PROC InsByte
1203 ; InsertByte
1204 ; ax,si,di=DESTROYED
1205
1206 ; mov di, 0
1207 ;@@Draw: mov ax, di
1208 ; shl ax, 1
1209 ; mov si, ax ; si = di * 2
1210 ; mov ah, 12h
1211 ; mov al, [byte cbuffer + di]
1212 ; add si, [word hoffs]
1213 ; mov [word es:si], ax
1214 ; inc di
1215 ; mov ax, 4000
1216 ; cmp si, ax
1217 ; jne @@Draw
1218 jmp DisplayProperties
1219 ENDP
1220
1221 PUBLIC DelByte
1222 PROC DelByte
1223 ; DeleteByte
1224 ; ax,si,di=DESTROYED
1225
1226 ; mov di, 0
1227 ;@@Draw: mov ax, di
1228 ; shl ax, 1
1229 ; mov si, ax ; si = di * 2
1230 ; mov ah, 12h
1231 ; mov al, [byte cbuffer + di]
1232 ; add si, [word hoffs]
1233 ; mov [word es:si], ax
1234 ; inc di
1235 ; mov ax, 4000
1236 ; cmp si, ax
1237 ; jne @@Draw
1238 jmp DisplayProperties
1239 ENDP
1240
1241 PUBLIC PasteClust
1242 PROC PasteClust
1243 ; PasteClust - copy cluster in clipboard to memory
1244 ; ax,di=DESTROYED
1245
1246 call EditModeOnly
1247 mov di, 0
1248 @@Copy: mov ax, di
1249 mov al, [byte bbuffer + di]
1250 mov [byte cbuffer + di], al
1251 inc di
1252 cmp di, 2048
1253 jne @@Copy
1254 jmp DisplayClust
1255 ENDP
1256
1257 PUBLIC AskGoClust
1258 PROC AskGoClust
1259 ; ax,si,di=DESTROYED
1260
1261 call NotInEditMode
1262
1263 cmp [word hoffs], 0
1264 ja @@OKGO
1265 ret ; Not with no status bar
1266
1267 @@OKGO: mov ah, 03h
1268 mov bx, [word cluster]
1269 mov di, 152
1270 call EditShort
1271 mov cx, bx
1272 jmp GoClustInEdit
1273 ENDP
1274
1275 PUBLIC GoClust
1276 PROC GoClust
1277 call NotInEditMode
1278 GoClustInEdit: cmp cx, 720
1279 jae @@Abort
1280 mov [word cluster], cx
1281 jmp LoadClust
1282 @@Abort: call LoadClust
1283 jmp BadLight
1284 ENDP
1285
1286 PUBLIC LoadClust
1287 PROC LoadClust
1288 ; LoadClust - read cluster into buffer and display it
1289
1290 call WorkLight
1291
1292 and [byte bits], 0feh ; Feh! Turn off edit.
1293
1294 mov di, 0
1295 mov al, 1ah
1296 @@Fill: mov [byte cbuffer + di], 0 ; clear cluster buffer.
1297 mov [byte obuffer + di], al ; clear colour buffer
1298 inc di
1299 cmp di, 2000
1300 jne @@Fill
1301
1302 mov ax, ds
1303 mov es, ax
1304 mov ax, [word cluster]
1305 mov bx, offset cbuffer
1306 call ReadClust
1307
1308 cmp ax, 1
1309 jne @@Cnt
1310
1311 @@Error: call BadLight
1312 jmp @@Status
1313
1314 @@Cnt: mov ax, [word cheader]
1315 cmp ax, 0bef0h
1316 jne @@OK
1317
1318 mov ax, ds
1319 mov es, ax
1320 mov ax, [word cheader+8] ; colour cluster number
1321 mov bx, offset obuffer
1322
1323 cmp ax, 0
1324 je @@OK
1325 call ReadClust
1326 cmp ax, 1
1327 je @@Error
1328
1329 @@OK: call OKLight
1330
1331 @@Status: cmp [word hoffs], 0
1332 ja @@OKGO
1333 jmp DisplayClust
1334
1335 @@OKGO: mov ah, 03h
1336 mov bx, [word cluster] ; Display cluster number onscreen
1337 mov di, 152
1338 call DisplayShort
1339 jmp DisplayClust
1340 ENDP
1341
1342 PUBLIC SaveClust
1343 PROC SaveClust
1344 ; SaveClust - write cluster from buffer and re-display it
1345
1346 call EditModeOnly
1347 call WorkLight
1348 and [byte bits], 0feh ; Feh! Turn off edit.
1349 mov ax, ds
1350 mov es, ax
1351 mov ax, [word cluster]
1352 mov bx, offset cbuffer
1353 call WriteClust
1354
1355 cmp ax, 1
1356 jne @@OK
1357
1358 call BadLight
1359 jmp @@Cnt
1360
1361 @@OK: call OKLight
1362 jmp DisplayClust
1363 @@Cnt: ret
1364 ENDP
1365
1366 ; possibly one day PUBLIC
1367 PROC RunClust
1368 call NotInEditMode
1369 cmp [word cheader+6], 0ffffh
1370 jne @@MayBeeble
1371 jmp @@RunAsm
1372 @@MayBeeble: cmp [word cheader+6], 0beebh
1373 jne @@Abort
1374 jmp @@RunBeeble
1375 @@Abort: jmp BadLight
1376 @@RunAsm: mov ax, [word runseg+3]
1377 mov es, ax
1378 mov di, 0100h
1379
1380 @@RLoop: mov ax, [word cbuffer - 0100h + di]
1381 mov [word es:di], ax
1382 inc di
1383 inc di
1384 cmp di, 2048 + 0100h
1385 jne @@RLoop
1386
1387 runseg: call far 0800h:0100h
1388 mov ax, cs
1389 mov ds, ax ; reset ds
1390 call TextVidBase
1391 ret
1392
1393 @@RunBeeble: call BufHome
1394 mov [word lastmove], offset BufRight
1395 jmp Beeblebrox
1396 ENDP
1397
1398 PUBLIC FillClust
1399 PROC FillClust
1400 ; FillClust - fill data buffer with current byte
1401
1402 call EditModeOnly
1403 mov di, [word bufptr]
1404 mov bl, [byte cbuffer + di]
1405 mov di, 0
1406 @@Fill: mov [byte cbuffer + di], bl
1407 inc di
1408 cmp di, 2000
1409 jne @@Fill
1410 jmp DisplayClust
1411 ENDP
1412
1413
1414 PUBLIC WorkLight, BadLight, EditLight, OKLight, CustomLight
1415 PROC WorkLight
1416 mov ax, WORK_LIGHT
1417 jmp Light
1418 ENDP
1419 PROC BadLight
1420 mov ax, BAD_LIGHT
1421 jmp Light
1422 ENDP
1423 PROC EditLight
1424 mov ax, EDIT_LIGHT
1425 jmp Light
1426 ENDP
1427 PROC OKLight
1428 mov ax, OK_LIGHT
1429 ENDP
1430 PROC Light
1431 call TextVidBase
1432 mov di, 2
1433
1434 cmp [word hoffs], 0
1435 ja @@OKGO
1436 ret
1437
1438 @@OKGO: mov [word es:di], ax
1439 ret
1440 ENDP
1441
1442 PROC CustomLight
1443 mov ax, cx
1444 jmp Light
1445 ENDP
1446
1447
1448 ;PROC StoreExtClust
1449 ;
1450 ; call WorkLight
1451 ;
1452 ; mov [word srclen], 2048
1453 ; mov [word srcaddr], offset cbuffer
1454 ; mov ax, ds
1455 ; shl ax, 4
1456 ; add [word srcaddr], ax
1457 ; mov ax, ds
1458 ; shr ax, 12
1459 ; mov [byte srcaddr+2], al
1460 ;
1461 ; mov [word destlen], 2048
1462 ; mov [word destaddr], 0
1463 ; mov [byte destaddr+2], 10h
1464 ;
1465 ; mov ax, ds
1466 ; mov es, ax
1467 ; mov ah, 87h
1468 ; mov cx, 1024
1469 ; mov si, offset gdt
1470 ; int 15h
1471
1472 ; jc @@Error
1473 ; jmp OKLight
1474 ;@@Error: jmp BadLight
1475 ;
1476 ;ENDP
1477
1478 ;PROC RetrieveExtClust
1479 ;
1480 ; call WorkLight
1481 ;
1482 ; mov [word srclen], 2048
1483 ; mov [word srcaddr], 0
1484 ; mov [byte srcaddr+2], 10h
1485
1486 ; mov [word destlen], 2048
1487 ; mov [word destaddr], offset cbuffer
1488 ; mov ax, ds
1489 ; shl ax, 4
1490 ; add [word destaddr], ax
1491 ; mov ax, ds
1492 ; shr ax, 12
1493 ; mov [byte destaddr+2], al
1494
1495 ; mov ax, ds
1496 ; mov es, ax
1497 ; mov ah, 87h
1498 ; mov cx, 1024
1499 ; mov si, offset gdt
1500 ; int 15h
1501
1502 ; jc @@Error
1503 ; call OKLight
1504 ; jmp DisplayClust
1505 ;@@Error: jmp BadLight
1506 ;
1507 ;ENDP
1508
1509 PROC ReadK
1510 ; ReadK - read two contiguous sectors from drive #0
1511 ; ax=first sector number
1512 ; es:bx=address of buffer (2x512 = 1024)
1513 ; cx=DESTROYED
1514 ; dx=DESTROYED
1515 ; di=DESTROYED
1516 @@Begin:
1517 xor dx, dx ; Zero high
1518 div [sectrk] ; Calculate track
1519 mov cl, dl ; CL = sector
1520 inc cl
1521 xor dx, dx ; Zero high
1522 div [numhead] ; Compute head
1523 mov ch, al ; CH = cylinder
1524 mov dh, dl ; DH = head
1525 xor dl, dl ; DL = drive 0
1526 mov di, 3 ; Try three times
1527 @@Read1:
1528 mov ax, 0202h ; Read 2 sectors
1529 int 13h ; Call BIOS
1530 jnc @@Read2 ; Success
1531 dec di ; Reduce count
1532 jnz @@Read1 ; Keep trying
1533 mov ax, 1 ; DISK ERROR
1534 ret
1535 @@Read2:
1536 xor ax, ax ; Zero return
1537 ret
1538 ENDP
1539
1540 PROC WriteK
1541 ; WriteK - write two contiguous sectors to drive #0
1542 ; ax=number of first sector
1543 ; es:bx=address of buffer
1544 ; cx=DESTROYED
1545 ; dx=DESTROYED
1546 ; di=DESTROYED
1547
1548 @@Begin:
1549 xor dx, dx ; Zero high
1550 div [sectrk] ; Calculate track
1551 mov cl, dl ; CL = sector
1552 inc cl ; 1-
1553 xor dx, dx ; Zero high
1554 div [numhead] ; Compute head
1555 mov ch, al ; CH = cylinder
1556 mov dh, dl ; DH = head
1557 xor dl, dl ; DL = drive #0
1558 mov di, 3 ; Try three times
1559 @@Write1:
1560 mov ax, 0302h ; Write 2 sectors
1561 int 13h ; Call BIOS
1562 jnc @@Write2 ; Success
1563 dec di ; Reduce count
1564 jnz @@Write1 ; Keep trying
1565 mov ax, 1 ; DISK ERROR
1566 ret
1567 @@Write2:
1568 xor ax, ax ; Zero return
1569 ret
1570 ENDP
1571
1572
1573 PROC ReadClust
1574 ; ReadClust - read a cluster from drive #0
1575 ; ax=cluster number
1576 ; es:bx=address of buffer (4x512 = 2048!)
1577 ; cx=DESTROYED
1578 ; dx=DESTROYED
1579 ; di=DESTROYED
1580 @@Begin:
1581 shl ax, 1
1582 shl ax, 1
1583 mov [temp], ax
1584 call ReadK
1585 mov ax, [temp]
1586 inc ax
1587 inc ax
1588 add bx, 1024
1589 call ReadK
1590 ret
1591 ENDP
1592
1593 PROC WriteClust
1594 ; WriteClust - write a cluster to drive #0
1595 ; ax=cluster number
1596 ; es:bx=address of buffer
1597 ; cx=DESTROYED
1598 ; dx=DESTROYED
1599 ; di=DESTROYED
1600
1601 @@Begin:
1602 shl ax, 1
1603 shl ax, 1
1604 mov [temp], ax
1605 call WriteK
1606 mov ax, [temp]
1607 inc ax
1608 inc ax
1609 add bx, 1024
1610 call WriteK
1611 ret
1612 ENDP
1613
1614
1615 PROC DisplayByte
1616 ; DisplayByte - show an 8-bit unsigned value as onscreen hex
1617 ; ah=attributes, al=DESTROYED
1618 ; bl=number to display
1619 ; di=location on screen- INCREMENTED
1620 ; cl=DESTROYED
1621
1622 mov al, bl
1623 and al, 0f0h
1624 mov cl, 4
1625 shr al, cl
1626
1627 cmp al, 10
1628 jge @@Hex
1629
1630 add al, '0'
1631 jmp @@Then
1632
1633 @@Hex: add al, 'a'-10
1634 @@Then: mov [word es:di], ax
1635 inc di
1636 inc di
1637
1638 mov al, bl
1639 and al, 0fh
1640
1641 cmp al, 10
1642 jge @@Hex2
1643
1644 add al, '0'
1645 jmp @@Then2
1646
1647 @@Hex2: add al, 'a'-10
1648 @@Then2: mov [word es:di], ax
1649 inc di
1650 inc di
1651
1652 ret
1653 ENDP
1654
1655 PROC DisplayShort
1656 ; DisplayShort - show a 16-bit unsigned value as onscreen hex
1657 ; ah=attributes, al=DESTROYED
1658 ; bx=number to display
1659 ; di=location on screen- INCREMENTED
1660 ; cl=DESTROYED
1661 ; dx=DESTROYED
1662
1663 mov dx, bx
1664 mov bl, bh
1665 call DisplayByte
1666 mov bx, dx
1667 jmp DisplayByte
1668 ENDP
1669
1670 PUBLIC StatusWord
1671 PROC StatusWord
1672 call TextVidBase
1673 mov di, 20
1674 mov bx, cx
1675 mov ah, 3fh
1676 jmp DisplayShort
1677 ENDP
1678
1679 PROC EditShort
1680 ; EditShort - allow user to change a 16-bit value as onscreen hex
1681 ; ah=attributes, al=DESTROYED
1682 ; bx=number to edit
1683 ; di=location on screen- INCREMENTED
1684 ; cx,dx=DESTROYED
1685
1686 mov [attr], ah
1687 mov [temp2], bx
1688 mov [temp], di
1689 call DisplayShort
1690
1691 mov ax, [temp]
1692 shr ax, 1
1693 mov [temp], di
1694
1695 @@Cur: xor dx, dx
1696 mov bx, 80
1697 div bx
1698 mov dh, al
1699 add dl, 3 ; cursor to right of num
1700 mov ah, 02h
1701 mov bh, 00h
1702 int 10h ; cursor gotoxy
1703
1704 ; loop and modify temp2
1705 @@Select: xor ah, ah ; get a key
1706 int 16h
1707 mov [word keyhit], ax
1708
1709 cmp al, '0'
1710 jae @@Digit1
1711 jmp @@Bail
1712
1713 @@Digit1: cmp al, '9'
1714 jbe @@DecDigit
1715 cmp al, 'a'
1716 jae @@Hex1
1717
1718 @@DecDigit: sub al, '0'
1719 @@AnyDigit: shl [word temp2], 4
1720 or [byte temp2], al
1721
1722 mov bx, [temp2]
1723 mov ax, [temp]
1724 sub ax, 8
1725 mov di, ax
1726 mov ah, [attr]
1727 call DisplayShort
1728
1729 jmp @@Select
1730
1731 @@Hex1: cmp al, 'f'
1732 jbe @@HexDigit
1733 jmp @@Select
1734 @@HexDigit: sub al, ('a'-10)
1735 jmp @@AnyDigit
1736
1737 ; mov bx, ax
1738 ; mov ah, 07h
1739 ; mov di, 140
1740 ; call DisplayShort
1741
1742 @@Bail: mov di, [temp] ; restore registers
1743 mov bx, [temp2]
1744 ret
1745 ENDP
1746
1747 PROC EditString
1748 ; EditString - allow user to change a string onscreen
1749 ; ah=attributes, al=DESTROYED
1750 ; cx=length
1751 ; di=location on screen
1752 ; bx,dx=DESTROYED
1753
1754 mov [attr], ah
1755 mov [temp], di
1756 mov [templen], cx
1757
1758 mov dx, 0
1759
1760 @@Cur: mov ax, [temp]
1761 shr ax, 1
1762 add ax, dx
1763 mov [temp2], dx
1764
1765 xor dx, dx
1766 mov bx, 80
1767 div bx
1768 mov dh, al
1769 mov ah, 02h
1770 mov bh, 00h
1771 int 10h ; cursor gotoxy
1772
1773 ; loop and modify temp2
1774 @@Select: xor ah, ah ; get a key
1775 int 16h
1776 mov [word keyhit], ax
1777
1778 cmp ax, 4b00h
1779 jne @@Next1
1780
1781 mov dx, [temp2]
1782 cmp dx, 0
1783 je @@CarryOn
1784 dec dx
1785 jmp @@CarryOn
1786
1787 @@Next1: cmp ax, 4d00h
1788 jne @@Next2
1789
1790 mov dx, [temp2]
1791 inc dx
1792 jmp @@CarryOn
1793
1794 @@Next2: cmp al, 13
1795 je @@Bail
1796
1797 ; mov bx, ax
1798 ; mov ah, 07h
1799 ; mov di, 140
1800 ; call DisplayShort
1801
1802 mov dx, [temp2]
1803 shl dx, 1
1804 mov di, [temp]
1805 add di, dx
1806 mov ah, [attr]
1807 mov [word es:di], ax
1808
1809 mov dx, [temp2]
1810 inc dx
1811 @@CarryOn: mov cx, [templen]
1812 cmp dx, cx
1813 je @@Bail
1814
1815 jmp @@Cur
1816
1817 @@Bail: mov di, [temp] ; restore registers
1818 mov bx, [temp2]
1819 ret
1820 ENDP
1821
1822 PUBLIC WriteIntr
1823 PROC WriteIntr
1824 ; cl = interrupt number
1825 ; es:di = pointer to interrupt handler routine
1826 ; ax,bx,cx=DESTROYED
1827
1828 xor bh, bh
1829 mov bl, cl
1830 shl bx, 2 ; bx = zero page intr loc
1831
1832 mov cx, es
1833 xor ax, ax
1834 mov es, ax
1835
1836 cli ; disable interrupts
1837 ; poke vector into zero page
1838
1839 mov [word es:0000h + bx], di
1840 mov [word es:0002h + bx], cx
1841
1842 sti ; enable interrupts
1843
1844 ret
1845 ENDP
1846
1847 PUBLIC ReadIntr
1848 PROC ReadIntr
1849 ; cl = interrupt number
1850 ; ax,bx=DESTROYED
1851 ; RETURNS:
1852 ; es:di = pointer to ISR
1853
1854
1855 xor bh, bh
1856 mov bl, cl
1857 shl bx, 2 ; bx = zero page intr loc
1858 ; peek vector from zero page
1859
1860 xor ax, ax
1861 mov es, ax
1862
1863 mov di, [word es:0000h + bx]
1864 mov ax, [word es:0002h + bx]
1865
1866 mov es, ax
1867 ret
1868 ENDP
1869
1870 PUBLIC PlugClock
1871 PROC PlugClock
1872
1873 call WorkLight
1874
1875 mov cl, 1ch
1876 call ReadIntr
1877
1878 mov ax, es
1879 mov [word timerSegment], ax
1880 mov [word timerOffset], di
1881
1882 mov ax, cs
1883 mov es, ax
1884 mov di, offset ClockISR
1885 mov cl, 1ch ; user clock interrupt
1886 call WriteIntr
1887
1888 call OKLight
1889
1890 ret
1891 ENDP
1892
1893 PUBLIC UnplugClock
1894 PROC UnplugClock
1895
1896 call WorkLight
1897 mov ax, [word timerSegment]
1898 cmp ax, 0
1899 je @@Fail
1900 mov [word timerSegment], 0
1901 mov es, ax
1902 mov di, [word timerOffset]
1903 mov cl, 1ch ; user clock interrupt
1904 call WriteIntr
1905 call OKLight
1906 ret
1907 @@Fail: jmp BadLight
1908 ENDP
1909
1910 PUBLIC ClockISR
1911 PROC ClockISR
1912 push ax
1913 push bx
1914 push cx
1915 push dx
1916 push ds
1917 push es
1918 push di
1919
1920 mov ax, 0040h
1921 mov ds, ax
1922 mov cx, [word 006ch]
1923 mov ax, cs
1924 mov ds, ax
1925 call StatusWord
1926
1927 pop di
1928 pop es
1929 pop ds
1930 pop dx
1931 pop cx
1932 pop bx
1933 pop ax
1934
1935 iret
1936 ENDP
1937
1938 PUBLIC PlugBreak
1939 PROC PlugBreak
1940
1941 call WorkLight
1942
1943 mov cl, 1bh
1944 call ReadIntr
1945
1946 mov ax, es
1947 mov [word breakSegment], ax
1948 mov [word breakOffset], di
1949
1950 mov ax, cs
1951 mov es, ax
1952 mov di, offset BreakISR
1953 mov cl, 1bh ; user clock interrupt
1954 call WriteIntr
1955
1956 call OKLight
1957
1958 ret
1959 ENDP
1960
1961 PUBLIC UnplugBreak
1962 PROC UnplugBreak
1963
1964 call WorkLight
1965 mov ax, [word breakSegment]
1966 cmp ax, 0
1967 je @@Fail
1968 mov [word breakSegment], 0
1969 mov es, ax
1970 mov di, [word breakOffset]
1971 mov cl, 1bh ; user clock interrupt
1972 call WriteIntr
1973 jmp OKLight
1974 @@Fail: jmp BadLight
1975 ENDP
1976
1977 PUBLIC BreakISR
1978 PROC BreakISR
1979
1980 ; This is a *very* special kind of ISR; it takes a very
1981 ; proactive approach to resetting BefOS.
1982
1983 mov ax, cs
1984 mov ds, ax
1985
1986 call UnplugClock
1987 ;call UnplugCom
1988 call UnplugBreak
1989 call UnplugPrtSc
1990
1991 xor al, al
1992 mov [byte bits], al ; clear modes
1993
1994 sti
1995
1996 ; At this point, we can't even get back to the caller,
1997 ; so dismiss the idea of ending this with 'iret' or 'retf'.
1998 ; Instead we shall use a far jump.
1999
2000 jmp far Start
2001
2002 ENDP
2003
2004 PUBLIC PlugPrtSc
2005 PROC PlugPrtSc
2006
2007 call WorkLight
2008
2009 mov cl, 05h
2010 call ReadIntr
2011
2012 mov ax, es
2013 mov [word prtscSegment], ax
2014 mov [word prtscOffset], di
2015
2016 mov ax, cs
2017 mov es, ax
2018 mov di, offset PrtScISR
2019 mov cl, 05h ; prtsc interrupt
2020 call WriteIntr
2021
2022 call OKLight
2023
2024 ret
2025 ENDP
2026
2027 PUBLIC UnplugPrtSc
2028 PROC UnplugPrtSc
2029
2030 call WorkLight
2031 mov ax, [word prtscSegment]
2032 cmp ax, 0
2033 je @@Fail
2034 mov [word prtscSegment], 0
2035 mov es, ax
2036 mov di, [word prtscOffset]
2037 mov cl, 05h ; prtsc interrupt
2038 call WriteIntr
2039 call OKLight
2040 ret
2041 @@Fail: jmp BadLight
2042 ENDP
2043
2044 PUBLIC PrtScISR
2045 PROC PrtScISR
2046 push ax
2047 push bx
2048 push cx
2049 push dx
2050 push ds
2051 push es
2052 push di
2053
2054 mov cx, 1234h
2055 call CustomLight
2056
2057 pop di
2058 pop es
2059 pop ds
2060 pop dx
2061 pop cx
2062 pop bx
2063 pop ax
2064
2065 iret
2066 ENDP
2067
2068 end MAIN
+0
-129
src/turbo/belife.tasm less more
0 IDEAL
1 MODEL tiny
2 P8086
3
4 DATASEG
5 cabuf db 2000 dup (?)
6
7 CODESEG
8 ORG 0100h
9 PROC Main
10 mov ax, cs ; find DATA segment
11 mov ds, ax ; assign to ds register
12 mov ax, 0b800h ; ASSUMES COLOR VGA 80x25 TEXT
13 mov es, ax
14
15 xor ax, ax
16 xor bx, bx
17 xor cx, cx
18 xor dx, dx
19
20 ; mov si, 0
21 ;@@Cloop:mov [byte prebuf+si], 32
22 ; mov [byte postbuf+si], 32
23 ; inc si
24 ; cmp si, 162
25 ; jne @@Cloop
26
27 mov si, 0
28 mov di, 0
29 @@L1: mov al, [byte es:di] ; get pixel at pt
30 cmp al, 32
31 je @@Off
32 @@On: call Neighbours
33 cmp al, 2
34 je @@Life
35 cmp al, 3
36 je @@Life
37 @@Deth: mov [byte cabuf+si], 32 ; stick zero in lifebuf
38 jmp @@Cont
39 @@Off: call Neighbours
40 cmp al, 3
41 jne @@Deth
42 mov [byte cabuf+si], 32
43 @@Life: inc [byte cabuf+si] ; inc lifebuf
44 cmp [byte cabuf+si], 31
45 jne @@Cont
46 dec [byte cabuf+si] ; inc lifebuf
47
48 @@Cont: inc di
49 inc di
50 inc si
51 cmp si, 2000
52 jne @@L1
53
54 ; now, is there a keypress outstanding?
55
56 mov ah, 1
57 int 16h
58 jnz @@Exit
59
60 ; no... update screen and repeat
61
62 mov di, 0
63 mov si, 0
64 @@L2: mov al, [byte cabuf+si]
65 mov [byte es:di], al
66 inc di
67 inc di
68 inc si
69 cmp si, 2000
70 jne @@L2
71
72 mov di, 0
73 mov si, 0
74 jmp @@L1
75
76 @@Exit: ;mov ax, 4c00h
77 ;int 21h
78
79 retf
80
81 ENDP
82
83 PROC Neighbours
84 ; di = position in es where pixel is
85 ; al = returned: number of 'on' neighbours
86
87 ; sum significant bits of: di-1 di+1
88 ; di-321 di-320 di-319
89 ; di+319 di+320 di+321
90
91 xor ax, ax
92
93 cmp [byte es:di-2], 32
94 je @@N1
95 inc al
96
97 @@N1: cmp [byte es:di+2], 32
98 je @@N2
99 inc al
100
101 @@N2: cmp [byte es:di-162], 32
102 je @@N3
103 inc al
104
105 @@N3: cmp [byte es:di-160], 32
106 je @@N4
107 inc al
108
109 @@N4: cmp [byte es:di-158], 32
110 je @@N5
111 inc al
112
113 @@N5: cmp [byte es:di+158], 32
114 je @@N6
115 inc al
116
117 @@N6: cmp [byte es:di+160], 32
118 je @@N7
119 inc al
120
121 @@N7: cmp [byte es:di+162], 32
122 je @@N8
123 inc al
124
125 @@N8: ret
126 ENDP
127
128 end MAIN
+0
-909
src/turbo/bf93.tasm less more
0 IDEAL
1
2 ; bf93.asm, v1999.may.something
3 ; Befunge-93 Interpreter in 8086 - Turbo Assembler
4 ; Copyunder (u)1998 Cat's-Eye Technologies, http://www.cats-eye.com/
5 ; See http://www.cats-eye.com/license/ for license information.
6
7 MODEL tiny
8
9 ; push a long onto the stack:
10 ; push high part
11 ; push low part
12
13 ; pop a long from the stack:
14 ; pop low part
15 ; pop high part
16
17 ; Define Constants
18 BIOS_DATA EQU 0040h ; BIOS data area
19 TIMER_DATA EQU 006ch ; BIOS: timer
20
21 DATASEG
22
23 sm db 0
24
25 x db 0
26 y db 0
27
28 seed dd 0
29
30 f dw 0
31 inbyte db 0
32
33 excode db 0
34
35 instable dw Space, binot, smode, bridg
36 dw stpop, stmod, rdint, Space ; 32-63
37 dw Space, Space, stmul, stadd, wrchr, stsub, wrint, stdiv
38 dw digit, digit, digit, digit, digit, digit, digit, digit
39 dw digit, digit, stdup, Space, dwest, Space, deast, bones
40
41 dw bexit, Space, Space, Space, Space, Space, Space, Space ; 64-95
42 dw Space, Space, Space, Space, Space, Space, Space, Space
43 dw Space, Space, Space, Space, Space, Space, Space, Space
44 dw Space, Space, Space, Space, stswp, Space, dnort, hrzif
45
46 dw grtrt, Space, Space, Space, Space, Space, Space, getxy ; 96-127
47 dw Space, Space, Space, Space, Space, Space, Space, Space
48 dw putxy, Space, Space, Space, Space, Space, dsout, Space
49 dw Space, Space, Space, Space, vrtif, Space, rdchr, Space
50
51 renderint db 12 dup (' '), '$'
52 message db 'befia v0.90, usage: befia <befunge-93-source>', 13, 10, '$'
53 filename db 128 dup (?)
54 playfield db 2000 dup (?)
55
56 CODESEG
57
58 ; Main program.
59 PROC Main ; int main (int argc, char **argv)
60 ; {
61 @@Start: mov ax, cs
62 mov ds, ax
63 mov es, ax ; make es point there
64 mov ax, ss
65 mov [word befos], ax
66
67 ; ...
68
69 xor ch, ch ; get cmdline charcount
70 mov cl, [ds:CMD_LEN]
71 ; inc cx
72 mov si, CMD_STR
73 mov di, offset filename
74
75 push cx
76 jcxz @@NoArgs
77 cld
78 rep movsb
79
80 mov ax, BIOS_DATA ; init random seed
81 mov ds, ax
82 mov bx, [word TIMER_DATA]
83
84 mov ax, @data ; find DATA segment
85 mov ds, ax ; assign to ds register
86 mov es, ax ; make es point here too
87
88 pop si ; fix filename
89 xor ah, ah
90 mov [byte filename + si], ah
91
92 ; ...initialize...
93
94 mov [word seed], bx
95 neg bx
96 mov [word seed + 2], bx
97
98 ; memset(playfield, ' ', 2000);
99
100 @@Clear: mov di, 2000 ; fill 2000 byte playfeld
101 mov bl, 32 ; with spaces
102 @@ClearLoop: dec di
103 mov [playfield + di], bl
104 cmp di, 0
105 jne @@ClearLoop
106
107 ; if (((f=fopen("in.bf","r"))!=NULL))
108
109 mov dx, offset filename + 1
110 mov ah, DOS_OPEN ; open the file
111 mov al, 0 ; 0 = read only
112 int SYS_DOS
113 jnc @@GotFile
114 jmp @@FileErr
115 @@NoArgs:
116
117 mov ax, @data ; find DATA segment
118 mov ds, ax ; assign to ds register
119 mov es, ax ; make es point here too
120
121 mov dx, offset message
122 mov ah, DOS_PRINT
123 int SYS_DOS
124
125 mov [excode], 0
126 jmp GlobalExit
127
128 @@GotFile: mov [f], ax
129
130 ; {
131 ; while (!feof (f))
132
133 @@WhileFile: mov ah, DOS_READ ; read
134 mov bx, [f] ; from f
135 mov cx, 1 ; one byte
136 mov dx, offset inbyte
137 int SYS_DOS
138 jnc @@GotChar
139 jmp @@FileErr
140
141 @@GotChar: or ax, ax ; check for eof
142 jz @@EndFile
143
144 ; {
145 ; if ((y >= 25) || (x >= 80)) break;
146
147 mov al, [y]
148 cmp al, 25
149 jge @@EndFile
150
151 mov al, [x]
152 cmp al, 80
153 jge @@EndFile
154
155 ; if ((playfield[y * 80 + x] = fgetc (f)) == '\n')
156
157 xor ax, ax
158 xor bx, bx
159 mov al, [y]
160 mov bl, [x]
161 ;---- loc cell
162 mov cl, 4
163 mov dx, ax
164 shl ax, cl
165 inc cl
166 inc cl
167 shl dx, cl
168 add ax, dx
169 add ax, bx
170 mov si, ax
171 ;---- loc cell
172
173 mov al, [inbyte]
174 cmp al, 13
175 jne @@LoadCell
176
177 mov ah, DOS_READ ; read
178 mov bx, [f] ; from f
179 mov cx, 1 ; one byte
180 mov dx, offset inbyte
181 int SYS_DOS
182 jc @@FileErr
183
184 jmp @@NextLine
185
186 ; {
187 ; playfield[y * 80 + x] = ' ';
188
189 mov ah, 32
190 mov [playfield + si], ah
191
192 ; x = 0;
193
194 @@NextLine: mov [x], 0
195
196 ; if (++y == 25) break;
197
198 inc [y]
199 mov al, [y]
200 cmp al, 25
201 je @@EndFile
202 jmp @@WhileFile
203
204 ; } else
205
206 @@LoadCell:
207
208 mov ah, [inbyte]
209 mov [playfield + si], ah
210
211 ; if (++x == 80) ...
212
213 inc [x]
214 mov al, [x]
215 cmp al, 80
216 je @@NextLine
217 jmp @@WhileFile
218 ; }
219
220 @@EndFile:
221
222 ; fclose (f);
223
224 mov bx, [f]
225 mov ah, DOS_CLOSE
226 int SYS_DOS
227 jc @@FileErr
228
229 ; x = 0; y = 0;
230
231 jmp @@DoIt
232 ; } else
233 ; {
234 ; exit (1);
235
236 @@FileErr: mov [excode], 32 ; return 32 if file not found
237 jmp GlobalExit
238 ; }
239
240 ; *** From here on in,
241 ; ip is cached in si. y * 80 + x
242 ; ir is cached in dh, d is cached in dl. dy * 80 + dx
243 ; *** Don't use si or dx for your own nefarious purposes
244 ; *** without caching them (perhaps on the stack) first.
245
246 @@DoIt: mov [x], 0
247 mov [y], 0
248 mov si, 0 ; initial x,y=0,0
249 mov dl, 1 ; initial dx,dy=1,0
250
251 ; while (1)
252
253 @@ProcessLoop:
254
255 ; {
256 ; ir = playfield[ip];
257
258 mov dh, [playfield + si] ; dh caches instruction
259
260 ; if (sm && (ir != '"')) push(ir);
261
262 mov al, [sm]
263 cmp al, 0
264 je @@Switch
265 cmp dh, 22h
266 je @@Switch
267
268 xor cx, cx ; place character
269 push cx ; onto stack
270 mov cl, dh
271 push cx
272
273 jmp Space
274
275 ; else instable[ir-32]();
276
277 @@Switch:
278 xor cx, cx ; zero cx
279 mov cl, dh
280 sub cl, 20h
281 shl cx, 1
282 mov di, cx
283 mov ax, [instable + di]
284 jmp ax
285
286 ; if (dx) x = (((x += dx) < 0) ? 79 : x % 80);
287 ; if (dy) y = (((y += dy) < 0) ? 24 : y % 25);
288
289 Space:
290 ; get x and y from si
291 ; x = si mod 80
292 ; y = si div 80
293
294 mov cx, dx
295 mov ax, si
296 xor dx, dx
297 mov bx, 0050h
298 div bx
299
300 ; now, ax = y, dx = x
301 ; now, if we are now in row 0 AND we are going north, we will wrap.
302 @@Wrap1: cmp ax, 0
303 jne @@Wrap2
304 cmp cl, -80
305 jne @@Wrap2
306 add si, (23 * 80)
307 jmp @@EndWrap
308
309 ; now, if we are now in row 24 AND we are going south, we will wrap.
310 @@Wrap2: cmp ax, 24
311 jne @@Wrap3
312 cmp cl, 80
313 jne @@Wrap3
314 sub si, (23 * 80)
315 jmp @@EndWrap
316
317 ; now, if we are now in column 0 AND we are going west, we will wrap.
318 @@Wrap3: cmp dx, 0
319 jne @@Wrap4
320 cmp cl, -1
321 jne @@Wrap4
322 add si, 79
323 jmp @@EndWrap
324
325 ; now, if we are now in column 79 AND we are going east, we will wrap.
326 @@Wrap4: cmp dx, 79
327 jne @@Advance
328 cmp cl, 1
329 jne @@Advance
330 sub si, 79
331 jmp @@EndWrap
332
333 @@Advance: mov al, cl ; load accumulator with delta
334 cbw ; expand byte to a signed word
335 add si, ax ; add to playfield offset
336
337 @@EndWrap: mov dx, cx ; restore dx
338 ; }
339 jmp @@ProcessLoop
340
341 GlobalExit: ; mov bx, 1 ; standard output ;
342 ; mov ah, DOS_DUPH ; duplicate ;
343 ; int SYS_DOS
344
345 ; mov bx, ax
346 ; mov ah, DOS_CLOSE ; and flush ;
347 ; int SYS_DOS
348
349 mov al, [excode] ; get return code
350 mov ah, DOS_EXIT ; exit to DOS function
351 int SYS_DOS ; activate function (exit program)
352 ; }
353
354 ENDP Main
355
356 ; -------------------- INSTRUCTIONS --------------------------
357
358 PROC bexit ; { exit(0); }
359 mov [excode], 0
360 jmp GlobalExit
361 ENDP bexit
362
363 PROC digit ; { push(ir - '0'); }
364 sub dh, '0'
365 xor cx, cx
366 push cx
367 mov cl, dh
368 push cx
369 jmp Space
370 ENDP digit
371
372 PROC dnort ; { dx = 0; dy = -1; }
373 mov dl, -80
374 jmp Space
375 ENDP dnort
376
377 PROC dsout ; { dx = 0; dy = 1; }
378 mov dl, 80
379 jmp Space
380 ENDP dsout
381
382 PROC deast ; { dx = 1; dy = 0; }
383 mov dl, 1
384 jmp Space
385 ENDP deast
386
387 PROC dwest ; { dx = -1; dy = 0; }
388 mov dl, -1
389 jmp Space
390 ENDP dwest
391
392 ; void vrtif(void) { dx = 0; if (pop()) dy = -1; else dy = 1; }
393
394 PROC vrtif
395 cmp sp, 0100h
396 je @@VertFalse
397 pop ax ; low word
398 pop bx ; high word
399 cmp bx, 0
400 je @@CheckLow
401 @@VertTrue: mov dl, -80
402 jmp Space
403 @@CheckLow: cmp ax, 0
404 jne @@VertTrue
405 @@VertFalse: mov dl, 80
406 jmp Space
407 ENDP vrtif
408
409 ; void hrzif(void) { dy = 0; if (pop()) dx = -1; else dx = 1; }
410
411 PROC hrzif
412 cmp sp, 0100h
413 je @@HorzFalse
414 pop ax ; low word
415 pop bx ; high word
416 cmp bx, 0
417 je @@CheckHLow
418 @@HorzTrue: mov dl, -1
419 jmp Space
420 @@CheckHLow: cmp ax, 0
421 jne @@HorzTrue
422 @@HorzFalse: mov dl, 1
423 jmp Space
424 ENDP hrzif
425
426 ; void stadd(void) { push (pop() + pop ()); }
427
428 PROC stadd
429 clc
430 cmp sp, 0100h
431 je AddTwoZeroes
432 pop ax
433 pop bx
434 cmp sp, 0100h
435 je @@OneZero
436 pop cx
437 add ax, cx
438 pop cx
439 adc bx, cx
440 @@OneZero: push bx
441 push ax
442 jmp Space
443 AddTwoZeroes: xor cx, cx
444 push cx
445 push cx
446 ENDP stadd
447
448 ; void stsub(void) { a = pop(); push(pop() - a); }
449
450 PROC stsub
451 mov di, dx
452 clc
453 cmp sp, 0100h
454 je AddTwoZeroes
455 pop ax
456 pop bx
457 cmp sp, 0100h
458 je @@OneZero
459 pop cx
460 pop dx
461 sub cx, ax
462 sbb dx, bx
463 @@Back: push dx
464 push cx
465 mov dx, di
466 jmp Space
467 @@OneZero: neg bx
468 neg ax
469 jmp @@Back
470
471 ENDP stsub
472
473 ; void stmul(void) { push (pop() * pop ()); }
474
475 PROC stmul
476 mov di, dx
477 cmp sp, 0100h
478 je MulByZero
479 pop ax
480 pop dx
481 cmp sp, 0100h
482 je MulByZero
483 pop cx
484 imul cx
485 pop cx
486 ; sbb bx, cx
487 push dx
488 push ax
489 @@ExitMul: mov dx, di
490 jmp Space
491 MulByZero: xor cx, cx
492 push cx
493 push cx
494 jmp @@ExitMul
495 ENDP stmul
496
497 ; void stdiv(void) { a = pop(); if (a) push(pop() / a); else push(0); }
498
499 PROC stdiv
500 mov di, dx
501 cmp sp, 0100h
502 je MulByZero
503 pop cx
504 pop ax
505 cmp sp, 0100h
506 je MulByZero
507 pop ax
508 pop dx
509 cmp cx, 0
510 je ByZero
511 idiv cx
512 xor dx, dx
513 push dx
514 push ax
515 mov dx, di
516 jmp Space
517 ByZero: xor ax, ax
518 push ax
519 push ax
520 mov dx, di
521 jmp Space
522 ENDP stdiv
523
524 ; void stmod(void) { a=pop(); push(pop() mod a); }
525
526 PROC stmod
527 mov di, dx
528 cmp sp, 0100h
529 je ByZero
530 pop cx
531 pop ax
532 cmp sp, 0100h
533 je ByZero
534 pop ax
535 pop dx
536 cmp cx, 0
537 je ByZero
538 idiv cx
539 xor ax, ax
540 push ax
541 push dx
542 mov dx, di
543 jmp Space
544 ENDP stmod
545
546 ; void stswp(void) { a=pop(); b=pop(); push (a); push (b); }
547
548 PROC stswp
549 cmp sp, 0100h
550 je @@TwoZeroes
551 pop ax
552 pop bx
553 cmp sp, 0100h
554 je @@OneZero
555 pop cx
556 pop di
557 push bx
558 push ax
559 push di
560 @@BackABit: push cx
561 jmp Space
562 @@TwoZeroes: xor cx, cx
563 push cx
564 push cx
565 @@BackAWeeBit: push cx
566 jmp @@BackABit
567 @@OneZero: push bx
568 push ax
569 xor cx, cx
570 jmp @@BackAWeeBit
571
572 ENDP stswp
573
574 ; void wrint(void) { printf (int space, pop()); fflush (stdout); }
575
576 PROC wrint
577
578 ; ax = unsigned word to be translated to base
579 ; bx = offset into a string in ds
580 ; (where the rightmost digit is to be written)
581 ; cx = an unsigned base (word) from 2 to 16
582 ; dx = internal
583
584 mov di, dx
585 cmp sp, 0100h
586 je @@PrintZero
587
588 pop ax
589 pop cx
590 @@GoPrint: mov bx, OFFSET renderint + 10
591
592 @@WrintLoop: xor dx, dx ; zero high word of thing to be divided!
593 xor ch, ch
594 mov cl, 10
595 div cx ; divide word by base quotient in ax
596 ; remainder in dx
597 xchg bx, dx ; get a new bx temporarily so we can
598 add bx, '0'
599 mov ch, bl ; get the proper ASCII char
600 mov bx, dx ; get the old bx and discard remainder
601 mov [byte bx], ch ; place the character into the string
602 dec bx ; next character position, left
603
604 or ax, ax ; is ax zero?
605 jnz @@WrintLoop ; if not, repeat
606
607 inc bx
608 mov dx, bx
609 mov ah, DOS_PRINT
610 int SYS_DOS
611
612 mov dx, di
613
614 jmp Space
615 @@PrintZero: xor ax, ax
616 jmp @@GoPrint
617 ENDP wrint
618
619 ; { printf (char, pop()); fflush (stdout); }
620
621 PROC wrchr
622 mov di, dx
623 cmp sp, 0100h
624 je @@ExitWrchr
625 pop ax
626 mov [inbyte], al
627 pop ax
628 mov dl, [inbyte] ;character to be printed
629 cmp dl, 10
630 jne @@PrintIt
631
632 mov dl, 13
633 mov ah, DOS_PUTC
634 int SYS_DOS
635
636 mov dl, 10
637 @@PrintIt: mov ah, DOS_PUTC ;DOS character print function
638 int SYS_DOS ;output contents of dl
639
640 @@ExitWrchr: mov dx, di
641 jmp Space
642 ENDP wrchr
643
644 PROC smode ; { sm = !sm }
645 mov al, [sm]
646 xor al, 0ffh
647 mov [sm], al
648 jmp Space
649 ENDP smode
650
651 ; void stdup(void) { a=pop(); push(a); push(a); }
652
653 PROC stdup
654 cmp sp, 0100h
655 je @@DupNothing
656 pop ax
657 pop bx
658 push bx
659 push ax
660 push bx
661 push ax
662 @@DupNothing: jmp Space
663 ENDP stdup
664
665 ; void binot(void) { if (pop()) push(0); else push(1); }
666
667 PROC binot
668 cmp sp, 0100h
669 je @@NoBinot
670 pop ax
671 pop bx
672 cmp ax, 0
673 jne @@YesBinot
674 cmp bx, 0
675 jne @@YesBinot
676 @@NoBinot: xor ax, ax
677 push ax
678 inc ax
679 push ax
680 jmp Space
681 @@YesBinot: xor ax, ax
682 push ax
683 push ax
684 jmp Space
685 ENDP binot
686
687 ; void grtrt(void) { a=pop(); if (pop() > a) push (1); else push(0); }
688
689 PROC grtrt
690 cmp sp, 0100h
691 je @@Grfalse
692 pop ax
693 pop bx
694 cmp sp, 0100h
695 je @@OneZero
696 pop di
697 pop cx
698 @@Backhere: cmp cx, bx
699 jg @@Grtrue
700 cmp cx, bx
701 je @@Grlow
702 jmp @@Grfalse
703
704 @@Grlow: mov cx, di
705 cmp cx, ax
706 jg @@Grtrue
707
708 @@Grfalse: xor ax, ax
709 push ax
710 push ax
711 jmp Space
712
713 @@Grtrue: xor ax, ax
714 push ax
715 inc ax
716 push ax
717
718 jmp Space
719
720 @@OneZero: mov di, 0
721 xor cx, cx
722 jmp @@Backhere
723
724 ENDP grtrt
725
726 ; void bridg(void) { x += dx; y += dy; }
727
728 PROC bridg
729
730 mov al, dl ; load accumulator with delta
731 cbw ; expand byte to a signed word
732 add si, ax ; add to playfield offset
733
734 ; cheap! no wrap checking is done.
735
736 jmp Space
737 ENDP bridg
738
739 PROC stpop ; { pop(); }
740 cmp sp, 0100h
741 je @@Nothing
742 pop ax
743 pop ax
744 @@Nothing: jmp Space
745 ENDP stpop
746
747 ; void bones(void) { dx=0; dy=1; switch ((rand () / 32) % 4) {
748 ; case 0: dx=1; dy=0; break;
749 ; case 1: dx=-1; dy=0; break;
750 ; case 2: dy=-1; } }
751
752 PROC bones ; quick, get a somewhat random number
753 ; given low word in ax
754 ; given high word in bx
755 mov ax, [word seed]
756 mov bx, [word seed + 2]
757 rcl bx, 1
758 mov bx, [word seed + 2]
759 rcl ax, 1
760 rcl bx, 1
761 xor ax, 2b41h
762 xor bx, 1d87h
763 mov [word seed], ax
764 mov [word seed + 2], bx
765
766 cmp ah, 40h
767 ja @@RandHorz
768
769 cmp al, 40h
770 ja @@NearNorth
771 jmp dsout
772 @@NearNorth: jmp dnort
773
774 @@RandHorz: cmp al, 40h
775 ja @@NearEast
776 jmp dwest
777 @@NearEast: jmp deast
778
779 ENDP bones
780
781 ; void rdint(void) { scanf (int, adr(b)); push(b); }
782
783 PROC rdint
784
785 mov di, 0
786
787 @@RdintLoop: mov ah, DOS_GETC
788 int SYS_DOS ; it's in al
789 cmp al, 13
790 jne @@Parse
791
792 push dx
793 mov dl, 10
794 mov ah, DOS_PUTC
795 int SYS_DOS
796 pop dx
797
798 xor ax, ax
799 push ax
800 push di
801 jmp Space
802
803 @@Parse: mov bx, di
804 shl bx, 3
805 mov cx, di
806 shl cx, 1
807 add bx, cx
808
809 sub al, '0'
810 cbw
811 add bx, ax
812 mov di, bx
813
814 jmp @@RdintLoop
815
816 ENDP rdint
817
818 ; void rdchr(void) { push(fgetc(stdin)); }
819
820 PROC rdchr
821 mov ah, DOS_GETC
822 int SYS_DOS
823 cmp al, 13
824 je @@ReadEnter
825 @@Back: xor bx, bx
826 push bx
827 mov bl, al
828 push bx
829 jmp Space
830 @@ReadEnter: mov al, 10
831 jmp @@Back
832 ENDP rdchr
833
834 ; void getxy(void) { push(playfield[pop() * 80 + pop()]); }
835
836 PROC getxy
837 cmp sp, 0100h
838 je @@TwoZeroes
839 pop ax
840 pop bx
841 cmp sp, 0100h
842 je @@OneZero
843 pop cx
844 pop bx
845
846 @@LocCell: mov bx, ax
847 shl bx, 4 ; bx = low y * 16
848 shl ax, 6 ; ax = low y * 64
849 add ax, bx ; ax += bx (ax = low y * 80)
850 add ax, cx ; ax += low x
851 mov di, ax
852
853 xor ax, ax
854 push ax
855 mov al, [playfield + di]
856 push ax
857
858 jmp Space
859
860 @@TwoZeroes: xor ax, ax
861 xor bx, bx
862 @@OneZero: xor cx, cx
863 jmp @@LocCell
864
865
866 ENDP getxy
867
868 ; void putxy(void) { playfield[pop() * 80 + pop()] = pop(); }
869
870 PROC putxy
871 cmp sp, 0100h
872 je @@TwoZeroes
873 pop ax
874 pop bx
875 cmp sp, 0100h
876 je @@OneZero
877 pop cx
878 pop bx ; low x word = cx; low y word = ax ;
879
880 @@LocCell: mov bx, ax
881 shl bx, 4 ; bx = low y * 16
882 shl ax, 6 ; ax = low y * 64
883 add ax, bx ; ax += bx (ax = low y * 80)
884 add ax, cx ; ax += low x
885 mov di, ax
886
887 cmp sp, 0100h
888 je @@ThreeZeroes
889 pop ax
890 pop bx
891
892 @@Back: mov [playfield + di], al
893
894 jmp Space
895
896 @@TwoZeroes: xor ax, ax
897 xor bx, bx
898 @@OneZero: xor cx, cx
899 jmp @@LocCell
900 @@ThreeZeroes: xor ax, ax
901 mov di, ax
902 jmp @@Back
903
904 ENDP putxy
905
906 ; ------------------------------------------------------------
907
908 END Main
+0
-70
src/turbo/mouse.tasm less more
0 IDEAL
1 MODEL tiny
2 P8086
3
4 CODESEG
5 ORG 0100h
6 PROC Main
7 mov ax, cs ; find DATA segment
8 mov ds, ax ; assign to ds register
9 mov es, ax
10
11 mov ax, 0c205h ; init mouse
12 mov bh, 6 ; 1 - 8???
13 int 15h
14 or ah, ah
15 jnz Bail
16
17 mov ax, 0c207h ; assign handler
18 mov bx, offset MouseHandler
19 int 15h
20 or ah, ah
21 jnz Bail
22
23 mov ax, 0c200h ; enable mouse
24 mov bh, 1 ; enable
25 int 15h
26 or ah, ah
27 jnz Bail
28
29 ; do stuff.
30
31 xor ax, ax
32 int 16h
33
34 mov ax, 0c200h ; disable mouse
35 mov bh, 0 ; disable
36 int 15h
37 or ah, ah
38 jnz Bail
39
40 Exeunt: mov ax, 4c00h
41 int 21h
42
43 Bail: push ax
44 mov ax, 0b800h ; ASSUMES COLOR VGA 80x25 TEXT! urgh
45 mov es, ax
46 mov di, 1234
47 pop ax
48 mov [byte es:di], al
49 jmp Exeunt
50
51 ENDP Main
52
53 PROC MouseHandler
54
55 mov ax, 0b800h ; ASSUMES COLOR VGA 80x25 TEXT! urgh
56 mov es, ax
57
58 ;mov bp, sp
59 ;mov ax, [bp-6]
60
61 mov di, 0
62
63 xor [byte es:di], 0ffh
64
65 retf
66
67 ENDP MouseHandler
68
69 end Main
+0
-42
src/turbo/myapp.tasm less more
0 IDEAL
1 P8086
2 MODEL TINY
3
4 CODESEG
5 ORG 0100h
6 PROC MAIN
7 INCLUDE "..\bekernel.inc"
8
9 ; OK, let's make some of those calls!
10
11 mov cx, 1000
12 mov bx, BefOS_LocateCursor
13 call BefOS
14
15 mov cx, 30h
16 mov bx, BefOS_LocateCluster
17 call BefOS
18
19 mov bx, BefOS_ReadByte
20 call BefOS
21
22 mov bx, BefOS_PushWord
23 call BefOS
24
25 mov bx, BefOS_Advance
26 call BefOS
27
28 mov bx, BefOS_PopWord
29 call BefOS
30
31 mov bx, BefOS_WriteByte
32 call BefOS
33
34 ; DO NOT use Int 21h to exit to DOS from within
35 ; BefOS (generally don't use Int 21h for ANYTHING
36 ; within BefOS!) Use retf instead.
37
38 retf
39
40 ENDP MAIN
41 END MAIN
+0
-344
src/turbo/vgaspin.tasm less more
0 ; VGA Spin - if you do not have VGA, do not run this program.
1
2 IDEAL
3 P8086
4 MODEL TINY
5
6 SYS_BIOS EQU 10h ; call to BIOS
7 VID_VGA EQU 0013h ; 320x200x256 VGA
8 VID_SEG EQU 0a000h ; segment for display RAM map
9 CENX EQU 160 ; center of VGA screen xwise
10 CENY EQU 100 ; center of VGA screen ywise
11
12 DATASEG
13 temp dw 0
14 tcol dw 0
15 mx dw 0
16 my dw 0
17
18 ; used by line
19 ; int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
20
21 ldx dw 0
22 ldy dw 0
23 lsdx dw 0
24 lsdy dw 0
25 ldxabs dw 0
26 ldyabs dw 0
27 lx dw 0
28 ly dw 0
29 lpx dw 0
30 lpy dw 0
31
32 lcol db 0
33
34 CODESEG
35 ORG 0100h
36 PROC MAIN
37 INCLUDE "..\bekernel.inc"
38
39 ; switch to 320x200-pixel,
40 ; 256-colour-palette VGA mode
41
42 mov ax, VID_VGA
43 int SYS_BIOS
44
45 mov ax, VID_SEG
46 mov es, ax ; make es point to video ram
47
48 ; draw some lines
49
50 xor ax, ax
51 mov [word mx], ax
52 mov [word my], ax
53 mov [word tcol], ax
54
55 @@Back:
56
57 ; wait for raster
58 ; mov dx, 03dah
59 ;@@VRT2: in al, dx
60 ; test al, 08h
61 ; je @@VRT2
62
63 mov di, [word tcol]
64 inc di
65 mov [word tcol], di
66 mov si, di
67 mov ax, [word mx]
68 mov bx, [word my]
69 mov cx, 160
70 mov dx, 199
71 call LINE
72
73 ; now, is there a keypress outstanding?
74
75 mov ah, 1
76 int 16h
77 jz @@Tram
78 jmp @@Test
79
80 ; IF A$ = "" THEN
81
82 @@Tram:
83 ; wait for raster
84 mov dx, 03dah
85 @@VRT3: in al, dx
86 test al, 08h
87 je @@VRT3
88
89 mov si, 0
90 mov ax, [word mx]
91 mov bx, [word my]
92 mov cx, 160
93 mov dx, 199
94 call LINE
95
96 mov ax, [word mx]
97 inc ax
98 inc ax
99 inc ax
100 cmp ax, 320
101 jge @@Wrap
102
103 mov [word mx], ax
104
105 jmp @@Back
106 @@Wrap: xor ax, ax
107 mov [word mx], ax
108 jmp @@Back
109
110 @@Test: xor ah, ah
111 int 16h ; read a key
112 or al, al ; is it extended?
113 jnz @@Norm
114
115 jmp @@Back
116
117 @@Norm: cmp al, 'q'
118 je @@Exit
119 jmp @@Back
120
121 @@Exit: mov bx, BefOS_SwitchToText
122 call BefOS
123 retf
124 ENDP
125
126 PROC PSET
127 ; ah = y coordinate
128 ; bx = x coordinate
129 ; dl = colour
130 ; cx, al DESTROYED
131
132 ; VGA[(py<<8)+(py<<6)+px]=color;
133
134 xor al, al
135 mov cx, ax
136 shr cx, 2
137 add ax, cx
138 add ax, bx
139 mov di, ax
140 mov [byte es:di], dl
141 ret
142 ENDP PSET
143
144 ; Thanks for the following algorithm goes to lines.c
145 ; by David Brackeen (http://silo.csci.unt.edu/home/brackeen/vga/)
146
147 PROC LINE
148 ; ax = x1 coordinate
149 ; bx = y1 coordinate
150 ; cx = x2 coordinate
151 ; dx = y2 coordinate
152 ; si = colour
153
154 ; px=x1;
155 ; py=y1;
156
157 mov [word lpx], ax
158 mov [word lpy], bx
159
160 ; dx=x2-x1; (cx-ax) /* the horizontal distance of the line */
161 ; dy=y2-y1; (bh-bl) /* the vertical distance of the line */
162
163 sub cx, ax
164 mov [word ldx], cx
165
166 sub dx, bx
167 mov [word ldy], dx
168
169 mov bx, si
170 mov [byte lcol], bl
171
172 ; dxabs=abs(dx);
173 ; dyabs=abs(dy);
174 ; sdx=sgn(dx);
175 ; sdy=sgn(dy);
176
177 mov [word lsdx], 1
178 cmp cx, 0
179 jge @@S1
180
181 neg cx
182 mov [word lsdx], -1
183
184 @@S1: mov [word ldxabs], cx
185
186 mov [word lsdy], 1
187 cmp dx, 0
188 jge @@S2
189
190 neg dx
191 mov [word lsdy], -1
192
193 @@S2: mov [word ldyabs], dx
194
195 ; x=dyabs>>1;
196 ; y=dxabs>>1;
197
198 shr cx, 1
199 mov [word ly], cx
200
201 shr dx, 1
202 mov [word lx], dx
203
204 ; VGA[(py<<8)+(py<<6)+px]=color;
205
206 mov bx, [word lpx]
207 mov ax, [word lpy]
208 mov ah, al
209 mov dl, [byte lcol]
210 call PSET
211
212 ; if (dxabs>=dyabs) /* the line is more horizontal than vertical */
213 ; {
214
215 mov ax, [word ldyabs]
216 cmp ax, [word ldxabs]
217 jg @@Vert
218
219 ; if dx>=dy we draw dy horizontal lines
220 ; staggered between y1 and y2.
221 ; each line is of length dx/dy
222
223 ; for(i=0;i<dxabs;i++) ( i == bx )
224 ; {
225
226 xor bx, bx
227 @@B1: cmp bx, [word ldxabs]
228 jge @@E1
229
230 ; y+=dyabs;
231
232 mov ax, [word ldyabs]
233 add ax, [word ly]
234 mov [word ly], ax
235
236 ; if (y>=dxabs)
237 ; {
238
239 cmp ax, [word ldxabs]
240 jl @@NE1
241
242 ; y-=dxabs;
243
244 sub ax, [word ldxabs]
245 mov [word ly], ax
246
247 ; py+=sdy;
248
249 mov ax, [word lsdy]
250 add [word lpy], ax
251
252 ; }
253
254 @@NE1:
255 ; px+=sdx;
256
257 mov ax, [word lsdx]
258 add [word lpx], ax
259
260 ; plot_pixel(px,py,color);
261
262 mov [word temp], bx
263 mov bx, [word lpx]
264 mov ax, [word lpy]
265 mov ah, al
266 mov dl, [byte lcol]
267 call PSET
268 mov bx, [word temp]
269
270 ; }
271
272 inc bx
273 jmp @@B1
274
275 ; }
276
277 @@E1: jmp @@Exit
278
279 ; else the line is more vertical than horizontal
280
281 @@Vert: ; if dy>dx we draw dx vertical lines
282 ; staggered between x1 and x2.
283 ; each line is of length dy/dx
284
285 ; {
286 ; for(i=0;i<dyabs;i++) (i == bl)
287
288 xor bx, bx
289 @@B2: cmp bx, [word ldyabs]
290 jge @@E1
291
292 ; {
293 ; x+=dxabs;
294
295 mov ax, [word ldxabs]
296 add ax, [word lx]
297 mov [word lx], ax
298
299 ; if (x>=dyabs)
300 ; {
301
302 cmp ax, [word ldyabs]
303 jl @@NE2
304
305 ; x-=dyabs;
306
307 sub ax, [word ldyabs]
308 mov [word lx], ax
309
310 ; px+=sdx;
311
312 mov ax, [word lsdx]
313 add [word lpx], ax
314
315 ; }
316
317 @@NE2:
318 ; py+=sdy;
319
320 mov ax, [word lsdy]
321 add [word lpy], ax
322
323 ; plot_pixel(px,py,color);
324
325 mov [word temp], bx
326 mov bx, [word lpx]
327 mov ax, [word lpy]
328 mov ah, al
329 mov dl, [byte lcol]
330 call PSET
331 mov bx, [word temp]
332
333 ; }
334
335 inc bx
336 jmp @@B2
337
338 ; }
339
340 @@Exit: ret
341
342 ENDP LINE
343 end MAIN